diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-03-26 19:35:14 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-11-16 20:37:00 +0100 |
| commit | d0d5529e95d888528a3446bdd48ff5218c7b7dd2 (patch) | |
| tree | f92d695f19459ea0f9a5b138b0408a50f66f26b1 /opcode.c | |
| parent | 3f3a12589b206efe7089520c2f2a1f49245e1dd2 (diff) | |
| download | sparse-dev-d0d5529e95d888528a3446bdd48ff5218c7b7dd2.tar.gz | |
add table to "negate" some opcode
Some optimizations transform an instruction opcode
into another. For example, it may be needed to know
the opcode corresponding to the negation of a comparison.
This patch make this easy and flexible by adding a table
for the relation between opcodes.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'opcode.c')
| -rw-r--r-- | opcode.c | 36 |
1 files changed, 36 insertions, 0 deletions
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, }, +}; |
