• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
14#ifndef TEST_ARITH_DEF
15#define TEST_ARITH_DEF
16
17#define XSTR(s) STR(s)
18#define STR(s) #s
19
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)
33
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)
40
41#define COMMA ,
42#define FPOP_TABLE                                                             \
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
58#define INT_VALUE_ARRAY                                                        \
59{ 0x0,        0x1,        0x7ffffffe, 0x7fffffff,                              \
60  0x80000000, 0x80000001, 0xfffffffe, 0xffffffff,                              \
61  0x1e, 0x1f, 0x20, 0x21, 0x3e, 0x3f, 0x40, 0x41,                              \
62  0x7e,       0x7f,       0x80,       0x81,                                    \
63  0xfe,       0xff,       0x100,      0x101,                                   \
64  0x7ffe,     0x7fff,     0x8000,     0x8001,                                  \
65  0xfffe,     0xffff,     0x10000,    0x10001 }
66
67#define FP_VALUE_ARRAY(NegInf, PosInf, NegNan, NaN)                            \
68{ 0,                    1,                    1.4,                             \
69  1.5,                  1.6,                  -1.4,                            \
70  -1.5,                 -1.6,                 0x7e,                            \
71  0x7f,                 0x80,                 0x81,                            \
72  0xfe,                 0xff,                 0x7ffe,                          \
73  0x7fff,               0x8000,               0x8001,                          \
74  0xfffe,               0xffff,               0x7ffffffe,                      \
75  0x7fffffff,           0x80000000,           0x80000001,                      \
76  0xfffffffe,           0xffffffff,           0x100000000ll,                   \
77  0x100000001ll,        0x7ffffffffffffffell, 0x7fffffffffffffffll,            \
78  0x8000000000000000ll, 0x8000000000000001ll, 0xfffffffffffffffell,            \
79  0xffffffffffffffffll, NegInf,               PosInf,                          \
80  Nan,                  NegNan,               -0.0,                            \
81  10.0,                 FLT_MIN,              FLT_MAX,                         \
82  DBL_MIN,              DBL_MAX }
83
84#define MULIMM_TABLE                                                           \
85   /* mult_by */                                                               \
86  X(         0)                                                                \
87  X(         1)                                                                \
88  X(         2)                                                                \
89  X(         3)                                                                \
90  X(         4)                                                                \
91  X(         5)                                                                \
92  X(         7)                                                                \
93  X(         8)                                                                \
94  X(         9)                                                                \
95  X(        10)                                                                \
96  X(        25)                                                                \
97  X(       100)                                                                \
98  X(       232)                                                                \
99  X(0x00FFF001)                                                                \
100  X(0x01000000)                                                                \
101  X(0x7FFFF07F)                                                                \
102  X(0x80000000)                                                                \
103//#define X(mult_by)
104
105#endif // TEST_ARITH_DEF
106