diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-04-05 15:18:50 +0200 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-04-05 15:18:50 +0200 |
commit | 98383707438a3e31ffd86a82b57fbe439945f777 (patch) | |
tree | 6e807f70f72f802fb986adfc343410e0609b705f /test/monniaux/ternary.h | |
parent | cba7f5e13ccea83e60ccfdf1895bef18bf50fe0a (diff) | |
download | compcert-kvx-98383707438a3e31ffd86a82b57fbe439945f777.tar.gz compcert-kvx-98383707438a3e31ffd86a82b57fbe439945f777.zip |
move patterns to include file
Diffstat (limited to 'test/monniaux/ternary.h')
-rw-r--r-- | test/monniaux/ternary.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/monniaux/ternary.h b/test/monniaux/ternary.h new file mode 100644 index 00000000..43cdbd12 --- /dev/null +++ b/test/monniaux/ternary.h @@ -0,0 +1,23 @@ +#include <stdint.h> + +static inline int32_t ternary_int32(int32_t a, int32_t b, int32_t c) { + return (((-((a) == 0)) & (c)) | ((-((a) != 0)) & (b))); +} +static inline uint32_t ternary_uint32(uint32_t a, uint32_t b, uint32_t c) { + return ternary_int32(a, b, c); +} + +static inline int64_t ternary_int64(int64_t a, int64_t b, int64_t c) { + return (((-((a) == 0)) & (c)) | ((-((a) != 0)) & (b))); +} +static inline uint64_t ternary_uint64(uint64_t a, uint64_t b, uint64_t c) { + return ternary_int64(a, b, c); +} + +#if defined(__COMPCERT__) && defined(__K1C__) +#define TERNARY32(a, b, c) ternary_uint32((a), (b), (c)) +#define TERNARY64(a, b, c) ternary_uint64((a), (b), (c)) +#else +#define TERNARY32(a, b, c) ((a) ? (b) : (c)) +#define TERNARY64(a, b, c) ((a) ? (b) : (c)) +#endif |