aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/opcode.h
AgeCommit message (Collapse)AuthorFilesLines
2020-11-22opcode: add helpers opcode_negate() & opcode_swap()Luc Van Oostenryck1-0/+10
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-11-08cmp: add signed/unsigned to opcode tableLuc Van Oostenryck1-2/+6
The opcode table allows to efficiently store some properties of the IR instructions and the correspondence between some of them. One of these correspondences the 'signed' / 'unsigned' version of otherwise identical instructions. This is useful for some transformation of compare instructions but is not present yet in the table. So, add this now. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2020-10-20add a flag to identify commutative & associative opsLuc Van Oostenryck1-0/+5
The way how the functions doing the simplification of commutative or associative binops are called is simple but complicates the simplification of a specific binop. Fix this by adding a flag to the opcode table to identify the commutative and the associative binops and using this flag to call or not the functions doing the corresponding simplification. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-08-26opcode: add OPF_TARGETLuc Van Oostenryck1-1/+4
Quite a bit of code needs to know, in one way or another, if a given instruction produces a result (insn->target) or not. However, this information is not explicit and when needed it must be retrieved with correct switch/case statements. These statements need to be updated when a new instruction is added. Now that there is a table containing some of the instructions properties, add to this table a flag telling if the instruction produces a result or not. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-08-26opcode: add arity infoLuc Van Oostenryck1-1/+2
The arity is a useful property of each opcode. Add this information to the opcode definitions. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2018-08-26opcode: centralize opcode definitionLuc Van Oostenryck1-0/+9
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>
2017-11-18fix support of floating-point compareLuc Van Oostenryck1-0/+10
Comparision of floating-point values can't be done like for integral values because of the possibility to have NaNs which can't be ordered with normal values or even between themselves. The real difference appears once there is any "reasoning" done with the result of the comparison. For example, once NaNs are taken in account: "!(a < b)" and "(a >= b)" are not the same. In fact the usual comparison operators must be reinterpreted as implicitely first testing if any of the operand is a Nan and return 'false' if it is the case. Thus "a < b" becomes "!isnan(a) && !isnan(b) && (a < b)". If we need to negate the comparison we get "!(a < b)" which naturally becomes "isnan(a) || isnan(b) || (a >= b)". We thus need two sets of operators for comparison of floats: one for the "ordered" values (only true if neither operand is a Nan) and one for the "values" (also true if either operand is a NaN). A negation of the comparison switch from one of the set to the other. So, introduce another set of instructions for the comparison of floats. Note: the C standard requires that: *) "x == x" is false if x is a NaN, *) "x != x" is true if x is a NaN, and this is coherent with "x != x" <-> "!(x == x)". Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16canonicalize compare instructionsLuc Van Oostenryck1-0/+1
Currently only commutative instructions are canonicalized (the "simpler" operands, often a constant, is forced, if present to be in the second operand). This improve CSE (more cases are considered as equivalent) and help to reduce the number of "pattern" to be handled at simplification. Do this also for compare instructions since in thsi case we can swap the order of the operands if at the same time we also swap the 'direction' on the comparison. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16add table to "negate" some opcodeLuc Van Oostenryck1-0/+9
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>