diff options
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | linearize.h | 3 | ||||
| -rw-r--r-- | opcode.c | 36 | ||||
| -rw-r--r-- | opcode.h | 9 |
4 files changed, 49 insertions, 0 deletions
@@ -46,6 +46,7 @@ LIB_OBJS += lib.o LIB_OBJS += linearize.o LIB_OBJS += liveness.o LIB_OBJS += memops.o +LIB_OBJS += opcode.o LIB_OBJS += parse.o LIB_OBJS += pre-process.o LIB_OBJS += ptrlist.o diff --git a/linearize.h b/linearize.h index 68efd891..0a9d2547 100644 --- a/linearize.h +++ b/linearize.h @@ -4,6 +4,7 @@ #include "lib.h" #include "allocate.h" #include "token.h" +#include "opcode.h" #include "parse.h" #include "symbol.h" @@ -217,6 +218,8 @@ enum opcode { /* Needed to translate SSA back to normal form */ OP_COPY, + + OP_LAST, /* keep this one last! */ }; struct basic_block_list; diff --git a/opcode.c b/opcode.c new file mode 100644 index 00000000..0aed1ca1 --- /dev/null +++ b/opcode.c @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2017 Luc Van Oostenryck + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "linearize.h" + +const struct opcode_table opcode_table[OP_LAST] = { + [OP_SET_EQ] = { .negate = OP_SET_NE, }, + [OP_SET_NE] = { .negate = OP_SET_EQ, }, + [OP_SET_LT] = { .negate = OP_SET_GE, }, + [OP_SET_LE] = { .negate = OP_SET_GT, }, + [OP_SET_GE] = { .negate = OP_SET_LT, }, + [OP_SET_GT] = { .negate = OP_SET_LE, }, + [OP_SET_B ] = { .negate = OP_SET_AE, }, + [OP_SET_BE] = { .negate = OP_SET_A , }, + [OP_SET_AE] = { .negate = OP_SET_B , }, + [OP_SET_A ] = { .negate = OP_SET_BE, }, +}; diff --git a/opcode.h b/opcode.h new file mode 100644 index 00000000..3a89de05 --- /dev/null +++ b/opcode.h @@ -0,0 +1,9 @@ +#ifndef OPCODE_H +#define OPCODE_H + + +extern const struct opcode_table { + int negate:8; +} opcode_table[]; + +#endif |
