diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-03-31 11:30:40 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-08-26 01:13:24 +0200 |
| commit | a48473a1d02a4a03e29486a9ba4566c0eca5b96f (patch) | |
| tree | 95b90dd658acbfe888059550907390bbc64c41d8 /opcode.c | |
| parent | b01160b296a2c0810b5b9acc39c44de083533601 (diff) | |
| download | sparse-dev-a48473a1d02a4a03e29486a9ba4566c0eca5b96f.tar.gz | |
opcode: centralize opcode definition
Opcodes are defined in linearize.c:enum opcode.
The file opcode.c also contains a table with opcodes properties.
Centralize these definitions into a single file: opcode.def that
will then be reused for enum opcode & the table.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'opcode.c')
| -rw-r--r-- | opcode.c | 47 |
1 files changed, 11 insertions, 36 deletions
@@ -20,42 +20,17 @@ * THE SOFTWARE. */ -#include "linearize.h" +#include "opcode.h" const struct opcode_table opcode_table[OP_LAST] = { - [OP_SET_EQ] = { .negate = OP_SET_NE, .swap = OP_SET_EQ, .to_float = OP_FCMP_OEQ, }, - [OP_SET_NE] = { .negate = OP_SET_EQ, .swap = OP_SET_NE, .to_float = OP_FCMP_UNE, }, - [OP_SET_LT] = { .negate = OP_SET_GE, .swap = OP_SET_GT, .to_float = OP_FCMP_OLT, }, - [OP_SET_LE] = { .negate = OP_SET_GT, .swap = OP_SET_GE, .to_float = OP_FCMP_OLE, }, - [OP_SET_GE] = { .negate = OP_SET_LT, .swap = OP_SET_LE, .to_float = OP_FCMP_OGE, }, - [OP_SET_GT] = { .negate = OP_SET_LE, .swap = OP_SET_LT, .to_float = OP_FCMP_OGT, }, - [OP_SET_B ] = { .negate = OP_SET_AE, .swap = OP_SET_A , .to_float = OP_FCMP_OLT, }, - [OP_SET_BE] = { .negate = OP_SET_A , .swap = OP_SET_AE, .to_float = OP_FCMP_OLE, }, - [OP_SET_AE] = { .negate = OP_SET_B , .swap = OP_SET_BE, .to_float = OP_FCMP_OGE, }, - [OP_SET_A ] = { .negate = OP_SET_BE, .swap = OP_SET_B , .to_float = OP_FCMP_OGT, }, - - [OP_FCMP_ORD] = { .negate = OP_FCMP_UNO, .swap = OP_FCMP_ORD, }, - [OP_FCMP_UNO] = { .negate = OP_FCMP_ORD, .swap = OP_FCMP_UNO, }, - - [OP_FCMP_OEQ] = { .negate = OP_FCMP_UNE, .swap = OP_FCMP_OEQ, }, - [OP_FCMP_ONE] = { .negate = OP_FCMP_UEQ, .swap = OP_FCMP_ONE, }, - [OP_FCMP_UEQ] = { .negate = OP_FCMP_ONE, .swap = OP_FCMP_UEQ, }, - [OP_FCMP_UNE] = { .negate = OP_FCMP_OEQ, .swap = OP_FCMP_UNE, }, - - [OP_FCMP_OLT] = { .negate = OP_FCMP_UGE, .swap = OP_FCMP_OGT, }, - [OP_FCMP_OLE] = { .negate = OP_FCMP_UGT, .swap = OP_FCMP_OGE, }, - [OP_FCMP_OGE] = { .negate = OP_FCMP_ULT, .swap = OP_FCMP_OLE, }, - [OP_FCMP_OGT] = { .negate = OP_FCMP_ULE, .swap = OP_FCMP_OLT, }, - - [OP_FCMP_ULT] = { .negate = OP_FCMP_OGE, .swap = OP_FCMP_UGT, }, - [OP_FCMP_ULE] = { .negate = OP_FCMP_OGT, .swap = OP_FCMP_UGE, }, - [OP_FCMP_UGE] = { .negate = OP_FCMP_OLT, .swap = OP_FCMP_ULE, }, - [OP_FCMP_UGT] = { .negate = OP_FCMP_OLE, .swap = OP_FCMP_ULT, }, - - [OP_ADD] = { .to_float = OP_FADD, }, - [OP_SUB] = { .to_float = OP_FSUB, }, - [OP_MUL] = { .to_float = OP_FMUL, }, - [OP_DIVS] = { .to_float = OP_FDIV, }, - [OP_DIVU] = { .to_float = OP_FDIV, }, - [OP_NEG] = { .to_float = OP_FNEG, }, +#define OPCODE(OP,NG,SW,TF) \ + [OP_##OP] = { \ + .negate = OP_##NG, \ + .swap = OP_##SW, \ + .to_float = OP_##TF, \ + }, +#define OPCODE_RANGE(OP,S,E) +#include "opcode.def" +#undef OPCODE +#undef OPCODE_RANGE }; |
