diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-03-26 17:29:33 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-11-18 14:03:26 +0100 |
| commit | 25dbd228c11410218242e585c598697005c707ea (patch) | |
| tree | 4371572c4e7f05fb61720b950250cc7821b48b27 /Documentation | |
| parent | 1c182507c3981aa20193c68d7cfd32d750b571cf (diff) | |
| download | sparse-dev-25dbd228c11410218242e585c598697005c707ea.tar.gz | |
add support of floating-point specific arithmetic ops
Floating-point arithmetic is quite different from the
arithmetic on integers or the one of real numbers.
In particular, most transformations, simplifications that can
be done on integers are invalid when done on floats.
For example:
- associativity doesn't hold
- distributivity doesn't hold
- comparison is tricky & complex
This is because (among others things):
- limited precision, rounding everywhere
- presence of signed zeroes
- presence of infinities
- presence of NaNs (signaling or quiet)
- presence of numbers without inverse
- several kind of exceptions.
Since they don't follow the same rules as their integer
counterpart, better to give them a specific opcode
instead of having to test the type of the operands at
each manipulation.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'Documentation')
| -rw-r--r-- | Documentation/IR.md | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/Documentation/IR.md b/Documentation/IR.md index 8d49936f..af972f93 100644 --- a/Documentation/IR.md +++ b/Documentation/IR.md @@ -45,32 +45,32 @@ Computed goto / branch to register ### Arithmetic binops They all follow the same signature: - .src1, .src1: operands (types must be compatible with .target) -- .target: result of the operation +- .target: result of the operation (must be an integral type) - .type: type of .target #### OP_ADD -Addition. +Integer addition. #### OP_SUB -Subtraction. +Integer subtraction. #### OP_MULU -Multiplication (unsigned ints & floating-points) +Integer unsigned multiplication. #### OP_MULS -Multiplication (signed ints) +Integer signed multiplication. #### OP_DIVU -Division (unsigned ints & floating-points) +Integer unsigned division. #### OP_DIVS -Division (signed ints) +Integer signed division. #### OP_MODU -Modulo (unsigned division remainder, integer only) +Integer unsigned remainder. #### OP_MODS -Modulo (signed division remainder, integer only) +Integer signed remainder. #### OP_SHL Shift left (integer only) @@ -81,6 +81,24 @@ Logical Shift right (integer only) #### OP_ASR Arithmetic Shift right (integer only) +### Floating-point binops +They all follow the same signature: +- .src1, .src1: operands (types must be compatible with .target) +- .target: result of the operation (must be a floating-point type) +- .type: type of .target + +#### OP_FADD +Floating-point addition. + +#### OP_FSUB +Floating-point subtraction. + +#### OP_FMUL +Floating-point multiplication. + +#### OP_FDIV +Floating-point division. + ### Logical ops They all follow the same signature: - .src1, .src2: operands (types must be compatible with .target) @@ -193,9 +211,15 @@ Logical not. - .type: type of .target, must be an integral type #### OP_NEG -Arithmetic negation. +Integer negation. - .src: operand (type must be compatible with .target) -- .target: result of the operation +- .target: result of the operation (must be an integral type) +- .type: type of .target + +#### OP_FNEG +Floating-point negation. +- .src: operand (type must be compatible with .target) +- .target: result of the operation (must be a floating-point type) - .type: type of .target #### OP_COPY |
