Import Upstream version 20180207
[hcoop/debian/mlton.git] / runtime / basis / Real / Real-ops.h
CommitLineData
7f918cf1
CE
1
2#define binary(size, name, op) \
3 MLTON_CODEGEN_STATIC_INLINE \
4 Real##size##_t Real##size##_##name (Real##size##_t r1, Real##size##_t r2) { \
5 return r1 op r2; \
6 }
7
8#define compare(size, name, op) \
9 MLTON_CODEGEN_STATIC_INLINE \
10 Bool Real##size##_##name (Real##size##_t r1, Real##size##_t r2) { \
11 return r1 op r2; \
12 }
13
14#define ternary(size, name, op) \
15 MLTON_CODEGEN_STATIC_INLINE \
16 Real##size##_t Real##size##_mul##name (Real##size##_t r1, Real##size##_t r2, Real##size##_t r3) { \
17 return r1 * r2 op r3; \
18 }
19
20#define unary(size, name, op) \
21 MLTON_CODEGEN_STATIC_INLINE \
22 Real##size##_t Real##size##_##name (Real##size##_t r1) { \
23 return op r1; \
24 }
25
26#define misaligned(size) \
27 MLTON_CODEGEN_STATIC_INLINE \
28 Real##size##_t Real##size##_fetch (Ref(Real##size##_t) rp) { \
29 Real##size##_t r; \
30 memcpy(&r, rp, sizeof(Real##size##_t)); \
31 return r; \
32 } \
33 MLTON_CODEGEN_STATIC_INLINE \
34 void Real##size##_store (Ref(Real##size##_t) rp, Real##size##_t r) { \
35 memcpy(rp, &r, sizeof(Real##size##_t)); \
36 return; \
37 } \
38 MLTON_CODEGEN_STATIC_INLINE \
39 void Real##size##_move (Ref(Real##size##_t) dst, Ref(Real##size##_t) src) { \
40 memcpy(dst, src, sizeof(Real##size##_t)); \
41 return; \
42 }
43
44#define all(size) \
45binary(size, add, +) \
46binary(size, div, /) \
47binary(size, mul, *) \
48binary(size, sub, -) \
49compare(size, equal, ==) \
50compare(size, le, <=) \
51compare(size, lt, <) \
52ternary(size, add, +) \
53ternary(size, sub, -) \
54unary(size, neg, -) \
55misaligned(size)
56
57all(32)
58all(64)
59
60#undef all
61#undef misaligned
62#undef unary
63#undef ternary
64#undef compare
65#undef binary