aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/g-opt.boot2
-rw-r--r--src/interp/g-util.boot32
2 files changed, 27 insertions, 7 deletions
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index 4d598b05..b9705f6b 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -473,7 +473,7 @@ $VMsideEffectFreeOperators ==
MINUSP GREATERP ZEROP ODDP FLOAT_-RADIX FLOAT FLOAT_-SIGN FLOAT_-DIGITS
CGREATERP GGREATERP CHAR BOOLE GET BVEC_-GREATER %false %true
%and %or %not %peq %ieq %ilt %ile %igt %ige %head %tail %integer?
- %beq %blt %ble %bgt %bge %bitand %bitior %bitnot
+ %beq %blt %ble %bgt %bge %bitand %bitior %bitnot %bcompl
%imul %iadd %isub %igcd %ilcm %ipow %imin %imax %ieven? %iodd? %iinc
%feq %flt %fle %fgt %fge %fmul %fadd %fsub %fexp %fmin %fmax %float?
%fpow %fdiv %fneg %i2f %fminval %fmaxval %fbase %fprec %ftrunc
diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot
index df6628f9..012a9ccc 100644
--- a/src/interp/g-util.boot
+++ b/src/interp/g-util.boot
@@ -230,6 +230,20 @@ expandPeq ['%peq,x,y] ==
expandBefore? ['%before?,x,y] ==
['GGREATERP,expandToVMForm y,expandToVMForm x]
+-- Byte operations
+expandBle ['%ble,x,y] ==
+ expandToVMForm ['%not,['%blt,y,x]]
+
+expandBgt ['%bgt,x,y] ==
+ expandToVMForm ['%blt,y,x]
+
+expandBge ['%bge,x,y] ==
+ expandToVMForm ['%not,['%blt,x,y]]
+
+expandBcompl ['%bcompl,x] ==
+ integer? x => 255 - x
+ ['_+,256,['LOGNOT,expandToVMForm x]]
+
-- Integer operations
expandIneg ['%ineg,x] ==
x := expandToVMForm x
@@ -237,12 +251,16 @@ expandIneg ['%ineg,x] ==
['_-,x]
expandIlt ['%ilt,x,y] ==
- integer? x and x = 0 => ['PLUSP,expandToVMForm y]
- integer? y and y = 0 => ['MINUSP,expandToVMForm x]
+ integer? x and x = 0 =>
+ integer? y => y > 0
+ ['PLUSP,expandToVMForm y]
+ integer? y and y = 0 =>
+ integer? x => x < 0
+ ['MINUSP,expandToVMForm x]
['_<,expandToVMForm x,expandToVMForm y]
expandIgt ['%igt,x,y] ==
- expandFlt ['%ilt,y,x]
+ expandIlt ['%ilt,y,x]
expandBitand ['%bitand,x,y] ==
['BOOLE,'BOOLE_-AND,expandToVMForm x,expandToVMForm y]
@@ -331,9 +349,6 @@ for x in [
-- byte operations
['%beq, :'byteEqual],
['%blt, :'byteLessThan],
- ['%ble, :'byteLessEqual],
- ['%bgt, :'byteGreaterThan],
- ['%bge, :'byteGreaterEqual],
-- unary integer operations.
['%iabs, :'ABS],
@@ -417,6 +432,11 @@ for x in [
['%loop, :function expandLoop],
['%return, :function expandReturn],
+ ['%ble, :function expandBle],
+ ['%bgt, :function expandBgt],
+ ['%bge, :function expandBge],
+ ['%bcompl, :function expandBcompl],
+
['%igt, :function expandIgt],
['%ilt, :function expandIlt],
['%ineg, :function expandIneg],