diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2016-03-16 11:40:47 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2016-03-16 11:40:47 -0400 |
commit | 8ac4af4875eb9cf5814dcc971632b0a4e7a008c2 (patch) | |
tree | 598918aa1df924b146582cbd950dfb54d1cc386c | |
parent | ce7fd0cb49fc1864eb1ef290cd835a64ce25efbf (diff) | |
download | roux-8ac4af4875eb9cf5814dcc971632b0a4e7a008c2.tar.gz |
document new shift operations
-rw-r--r-- | doc/il.txt | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/il.txt b/doc/il.txt index 9896672..964c864 100644 --- a/doc/il.txt +++ b/doc/il.txt @@ -491,6 +491,7 @@ return type used is long, the argument must be of type double. * `add`, `sub`, `div`, `mul` -- `T(T,T)` * `udiv`, `rem`, `urem` -- `I(I,I)` * `or`, `xor`, `and` -- `I(I,I)` + * `sar`, `shr`, `shl` -- `I(I,ww)` The base arithmetic instructions in the first bullet are available for all types, integers and floating points. @@ -512,6 +513,20 @@ integer types. Logical operations of typical programming languages can be implemented using <@ Comparisons > and <@ Jumps >. +Shift instructions `sar`, `shr`, and `shl` shift right or +left their first operand by the amount in the second +operand. The shifting amount is taken modulo the size of +the result type. Shifting right can either preserve the +sign of the value (using `sar`), or fill the newly freed +bits with zeroes (using `shr`). Shifting left always +fills the freed bits with zeroes. + +Remark that an arithmetic shift right (`sar`) is only +equivalent to a division by a power of two for non-negative +numbers. This is because the shift right "truncates" +towards minus infinity, while the division truncates +towards zero. + ~ Memory ~~~~~~~~ |