Jim Stichnoth | 7da431b | 2014-08-05 11:22:37 -0700 | [diff] [blame] | 1 | //===- subzero/crosstest/test_arith.def - macros for tests ----*- C++ -*---===// |
| 2 | // |
| 3 | // The Subzero Code Generator |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines macros for crosstesting arithmetic operations. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 14 | #ifndef TEST_ARITH_DEF |
| 15 | #define TEST_ARITH_DEF |
| 16 | |
| 17 | #define XSTR(s) STR(s) |
| 18 | #define STR(s) #s |
| 19 | |
Matt Wala | afeaee4 | 2014-08-07 13:47:30 -0700 | [diff] [blame] | 20 | #define UINTOP_TABLE \ |
| 21 | /* inst, operator, div, shift */ \ |
| 22 | X(Add, +, 0, 0) \ |
| 23 | X(Sub, -, 0, 0) \ |
| 24 | X(Mul, *, 0, 0) \ |
| 25 | X(Udiv, /, 1, 0) \ |
| 26 | X(Urem, %, 1, 0) \ |
| 27 | X(Shl, <<, 0, 1) \ |
| 28 | X(Lshr, >>, 0, 1) \ |
| 29 | X(And, &, 0, 0) \ |
| 30 | X(Or, |, 0, 0) \ |
| 31 | X(Xor, ^, 0, 0) \ |
| 32 | //#define X(inst, op, isdiv, isshift) |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 33 | |
Matt Wala | afeaee4 | 2014-08-07 13:47:30 -0700 | [diff] [blame] | 34 | #define SINTOP_TABLE \ |
| 35 | /* inst, operator, div, shift */ \ |
| 36 | X(Sdiv, /, 1, 0) \ |
| 37 | X(Srem, %, 1, 0) \ |
| 38 | X(Ashr, >>, 0, 1) \ |
| 39 | //#define X(inst, op, isdiv, isshift) |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 40 | |
| 41 | #define COMMA , |
Matt Wala | afeaee4 | 2014-08-07 13:47:30 -0700 | [diff] [blame] | 42 | #define FPOP_TABLE \ |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 43 | /* inst, infix_op, func */ \ |
| 44 | X(Fadd, +, ) \ |
| 45 | X(Fsub, -, ) \ |
| 46 | X(Fmul, *, ) \ |
| 47 | X(Fdiv, /, ) \ |
| 48 | X(Frem, COMMA, myFrem) \ |
| 49 | //#define X(inst, op, func) |
| 50 | |
| 51 | // Note: The above definition of COMMA, plus the "func" argument to |
| 52 | // the X macro, are because C++ does not allow the % operator on |
| 53 | // floating-point primitive types. To work around this, the expansion |
| 54 | // is "func(a infix_op b)", which becomes "myFrem(a , b)" for the Frem |
| 55 | // instruction and "(a + b)" for the Fadd instruction. The two |
| 56 | // versions of myFrem() are defined in a separate bitcode file. |
| 57 | |
Matt Wala | 7fa22d8 | 2014-07-17 12:41:31 -0700 | [diff] [blame] | 58 | #define INT_VALUE_ARRAY \ |
| 59 | { 0x0, 0x1, 0x7ffffffe, 0x7fffffff, \ |
| 60 | 0x80000000, 0x80000001, 0xfffffffe, 0xffffffff, \ |
| 61 | 0x7e, 0x7f, 0x80, 0x81, \ |
| 62 | 0xfe, 0xff, 0x100, 0x101, \ |
| 63 | 0x7ffe, 0x7fff, 0x8000, 0x8001, \ |
| 64 | 0xfffe, 0xffff, 0x10000, 0x10001 } |
| 65 | |
| 66 | #define FP_VALUE_ARRAY(NegInf, PosInf, NegNan, NaN) \ |
Jan Voung | 109fa15 | 2014-10-07 17:22:51 -0700 | [diff] [blame] | 67 | { 0, 1, 1.4, \ |
| 68 | 1.5, 1.6, -1.4, \ |
| 69 | -1.5, -1.6, 0x7e, \ |
Matt Wala | 7fa22d8 | 2014-07-17 12:41:31 -0700 | [diff] [blame] | 70 | 0x7f, 0x80, 0x81, \ |
| 71 | 0xfe, 0xff, 0x7ffe, \ |
| 72 | 0x7fff, 0x8000, 0x8001, \ |
| 73 | 0xfffe, 0xffff, 0x7ffffffe, \ |
| 74 | 0x7fffffff, 0x80000000, 0x80000001, \ |
| 75 | 0xfffffffe, 0xffffffff, 0x100000000ll, \ |
| 76 | 0x100000001ll, 0x7ffffffffffffffell, 0x7fffffffffffffffll, \ |
| 77 | 0x8000000000000000ll, 0x8000000000000001ll, 0xfffffffffffffffell, \ |
| 78 | 0xffffffffffffffffll, NegInf, PosInf, \ |
| 79 | Nan, NegNan, -0.0, \ |
Jan Voung | 109fa15 | 2014-10-07 17:22:51 -0700 | [diff] [blame] | 80 | 10.0, FLT_MIN, FLT_MAX, \ |
| 81 | DBL_MIN, DBL_MAX } |
Matt Wala | 7fa22d8 | 2014-07-17 12:41:31 -0700 | [diff] [blame] | 82 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 83 | #endif // TEST_ARITH_DEF |