add div64 and mod64
This commit is contained in:
parent
8480d55faf
commit
e69048ad3d
5 changed files with 35 additions and 2 deletions
|
|
@ -17,6 +17,6 @@ clean:
|
|||
make -C lib clean
|
||||
|
||||
install: ir
|
||||
make -C lib clean-test
|
||||
cp llrt_*.ll ../llvm/llrt
|
||||
make -C lib clean-temp
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
OUTPUT = llrt
|
||||
SOURCES = udivmod64.c sdivmod64.c
|
||||
SOURCES = udivmod64.c sdivmod64.c div64.c mod64.c
|
||||
TESTS = test_udivmod64.c test_sdivmod64.c
|
||||
|
||||
CLANG = clang
|
||||
|
|
|
|||
11
llrtc/lib/div64.c
Normal file
11
llrtc/lib/div64.c
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include "llrt.h"
|
||||
|
||||
uint64_t udiv64(uint64_t dividend, uint64_t divisor)
|
||||
{
|
||||
return udivmod64(dividend, divisor, NULL);
|
||||
}
|
||||
|
||||
int64_t sdiv64(int64_t dividend, int64_t divisor)
|
||||
{
|
||||
return sdivmod64(dividend, divisor, NULL);
|
||||
}
|
||||
|
|
@ -3,10 +3,17 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#define NULL 0
|
||||
#define BITS_PER_BYTE 8
|
||||
|
||||
uint64_t udivmod64(uint64_t dividend, uint64_t divisor, uint64_t *remainder);
|
||||
int64_t sdivmod64(int64_t dividend, int64_t divisor, int64_t *remainder);
|
||||
|
||||
uint64_t udiv64(uint64_t dividend, uint64_t divisor);
|
||||
int64_t sdiv64(int64_t dividend, int64_t divisor);
|
||||
|
||||
uint64_t umod64(uint64_t dividend, uint64_t divisor);
|
||||
int64_t smod64(int64_t dividend, int64_t divisor);
|
||||
|
||||
#endif /* LLRT_H_ */
|
||||
|
||||
|
|
|
|||
15
llrtc/lib/mod64.c
Normal file
15
llrtc/lib/mod64.c
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#include "llrt.h"
|
||||
|
||||
uint64_t umod64(uint64_t dividend, uint64_t divisor)
|
||||
{
|
||||
uint64_t rem;
|
||||
udivmod64(dividend, divisor, &rem);
|
||||
return rem;
|
||||
}
|
||||
|
||||
int64_t smod64(int64_t dividend, int64_t divisor)
|
||||
{
|
||||
int64_t rem;
|
||||
sdivmod64(dividend, divisor, &rem);
|
||||
return rem;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue