aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2010-06-23 12:57:00 +0000
committerdos-reis <gdr@axiomatics.org>2010-06-23 12:57:00 +0000
commit5c81f5a89627a71d4e0054730eea47cc99a9cef2 (patch)
tree5294366b1c51fc299456864c317bbcdfee21315d /src/interp
parentb06599402ca23cce8ba7eea03886dc11a5d29af4 (diff)
downloadopen-axiom-5c81f5a89627a71d4e0054730eea47cc99a9cef2.tar.gz
* interp/nruncomp.boot (optDeltaEntry): Don't optimize current
domain modemap references here. * interp/g-opt.boot ($VMsideEffectFreeOperators): Include more floating point operators. ($simpleVMoperators): Move FUNCALL here. (isVMConstantForm): Tidy. * interp/g-util.boot: Expand more floating point insns. * interp/c-util.boot (replaceSimpleFunctions): Replace more constants. * algebra/integer.spad.pamphlet (Integer): More cleanup. Use builtin functions. * algebra/sf.spad.pamphlet: Likewise.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/c-util.boot4
-rw-r--r--src/interp/g-opt.boot15
-rw-r--r--src/interp/g-util.boot63
-rw-r--r--src/interp/nruncomp.boot4
4 files changed, 70 insertions, 16 deletions
diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot
index 17d630b4..c2c55b14 100644
--- a/src/interp/c-util.boot
+++ b/src/interp/c-util.boot
@@ -1148,10 +1148,10 @@ replaceSimpleFunctions form ==
optLET mutateLETFormWithUnaryFunction(form,"replaceSimpleFunctions")
form is ["spadConstant","$",n] =>
null(op := getCapsuleDirectoryEntry n) => form
- getFunctionReplacement op is ["XLAM",=nil,body]
- and isAtomicForm body => body
-- Conservatively preserve object identity and storage
-- consumption by not folding non-atomic constant forms.
+ getFunctionReplacement op isnt ['XLAM,=nil,body] => form
+ isAtomicForm body or isVMConstantForm body => body
form
-- 1. process argument first.
for args in tails rest form repeat
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index f8e28b42..a78abadd 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -471,18 +471,19 @@ $VMsideEffectFreeOperators ==
SPADfirst QVELT _+ _- _* _< _= _<_= _> _>_= ASH INTEGER_-LENGTH
QEQCAR QCDR QCAR INTEGERP FLOATP STRINGP IDENTP SYMBOLP
MINUSP GREATERP ZEROP ODDP FLOAT_-RADIX FLOAT FLOAT_-SIGN FLOAT_-DIGITS
- CGREATERP GGREATERP CHAR BOOLE GET BVEC_-GREATER FUNCALL %false %true
+ CGREATERP GGREATERP CHAR BOOLE GET BVEC_-GREATER %false %true
%and %or %not %eq %ieq %ilt %ile %igt %ige %head %tail %integer?
%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 %nil %pair? %lconcat %llength %lfirst %lsecond %lthird
- %lreverse %lempty? %hash %ismall? %string?
- %ceq %clt %cle %cgt %cge %c2i %i2c)
+ %fpow %fdiv %fneg %i2f %fminval %fmaxval %fbase %fprec %ftrunc
+ %nil %pair? %lconcat %llength %lfirst %lsecond %lthird
+ %lreverse %lempty? %hash %ismall? %string?
+ %ceq %clt %cle %cgt %cge %c2i %i2c)
++ List of simple VM operators
$simpleVMoperators ==
append($VMsideEffectFreeOperators,
- ["CONS","LIST","VECTOR","STRINGIMAGE",'%gensym, '%lreverse_!,
+ ['CONS,'LIST,'VECTOR,'STRINGIMAGE,'FUNCALL,'%gensym, '%lreverse_!,
"MAKE-FULL-CVEC","BVEC-MAKE-FULL","COND"])
++ Return true if the `form' is semi-simple with respect to
@@ -513,10 +514,8 @@ isFloatableVMForm form ==
isVMConstantForm: %Code -> %Boolean
isVMConstantForm form ==
integer? form or string? form => true
- form=nil or form=true => true
form isnt [op,:args] => false
- op = "QUOTE" => true
- MEMQ(op,$simpleVMoperators) and
+ MEMQ(op,$VMsideEffectFreeOperators) and
"and"/[isVMConstantForm arg for arg in args]
++ Return the set of free variables in the VM form `form'.
diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot
index bf4a02ee..af20fb51 100644
--- a/src/interp/g-util.boot
+++ b/src/interp/g-util.boot
@@ -226,6 +226,50 @@ expandReturn(x is ['%return,.,y]) ==
expandEq ["%eq",:args] ==
["EQ",:expandToVMForm args]
+
+expandIneg ['%ineg,x] ==
+ x := expandToVMForm x
+ integer? x => -x
+ ['_-,x]
+
+expandIlt ['%ilt,x,y] ==
+ integer? x and x = 0 => ['PLUSP,expandToVMForm y]
+ integer? y and y = 0 => ['MINUSP,expandToVMForm x]
+ ['_<,expandToVMForm x,expandToVMForm y]
+
+expandIgt ['%igt,x,y] ==
+ expandFlt ['%ilt,y,x]
+
+-- Floating point support
+
+expandFbase ['%fbase] ==
+ FLOAT_-RADIX $DoubleFloatMaximum
+
+expandFprec ['%fprec] ==
+ FLOAT_-DIGITS $DoubleFloatMaximum
+
+expandFminval ['%fminval] ==
+ '$DoubleFloatMinimum
+
+expandFmaxval ['%fmaxval] ==
+ '$DoubleFloatMaximum
+
+expandI2f ['%i2f,x] ==
+ x := expandToVMForm x
+ integer? x and (x = 0 or x = 1) => FLOAT(x,$DoubleFloatMaximum)
+ ['FLOAT,x,'$DoubleFloatMaximum]
+
+expandFneg ['%fneg,x] ==
+ ['_-,expandToVMForm x]
+
+expandFlt ['%flt,x,y] ==
+ x is ['%i2f,0] => ['PLUSP,expandToVMForm y]
+ y is ['%i2f,0] => ['MINUSP,expandToVMForm x]
+ ['_<,expandToVMForm x,expandToVMForm y]
+
+expandFgt ['%fgt,x,y] ==
+ expandFlt ['%flt,y,x]
+
-- Local variable bindings
expandBind ['%bind,inits,body] ==
body := expandToVMForm body
@@ -274,7 +318,6 @@ for x in [
-- unary integer operations.
['%iabs, :'ABS],
['%ieven?, :'EVENP],
- ['%ineg, :"-"],
['%integer?,:'INTEGERP],
['%iodd?, :'ODDP],
['%ismall?, :'FIXNUMP],
@@ -283,11 +326,9 @@ for x in [
['%ieq, :"EQL"],
['%igcd,:'GCD],
['%ige, :">="],
- ['%igt, :">"],
['%iinc,:"1+"],
['%ilcm,:'LCM],
['%ile, :"<="],
- ['%ilt, :"<"],
['%imax,:'MAX],
['%imin,:'MIN],
['%imul,:"*"],
@@ -297,14 +338,13 @@ for x in [
-- unary float operations.
['%fabs, :'ABS],
['%float?,:'FLOATP],
+ ['%ftrunc,:'TRUNCATE],
-- binary float operations.
['%fadd, :"+"],
['%fdiv, :"/"],
['%feq, :"="],
['%fge, :">="],
- ['%fgt, :">"],
['%fle, :"<="],
- ['%flt, :"<"],
['%fmax, :'MAX],
['%fmin, :'MIN],
['%fmul, :"*"],
@@ -348,6 +388,19 @@ for x in [
['%loop, :function expandLoop],
['%return, :function expandReturn],
+ ['%igt, :function expandIgt],
+ ['%ilt, :function expandIlt],
+ ['%ineg, :function expandIneg],
+
+ ['%i2f, :function expandI2f],
+ ['%fbase, :function expandFbase],
+ ['%fgt, :function expandFgt],
+ ['%flt, :function expandFlt],
+ ['%fmaxval, :function expandFmaxval],
+ ['%fminval, :function expandFminval],
+ ['%fneg, :function expandFneg],
+ ['%fprec, :function expandFprec],
+
["%eq",:function expandEq],
["%bind",:function expandBind],
diff --git a/src/interp/nruncomp.boot b/src/interp/nruncomp.boot
index 71cd6a21..8981fd7e 100644
--- a/src/interp/nruncomp.boot
+++ b/src/interp/nruncomp.boot
@@ -164,8 +164,10 @@ needToQuoteFlags?(sig,env) ==
optDeltaEntry(op,sig,dc,eltOrConst) ==
$killOptimizeIfTrue = true => nil
+ -- references to modemaps from current domain are folded in a later
+ -- stage of the compilation process.
+ dc = '$ => nil
ndc :=
- dc = '$ => $functorForm
atom dc and (dcval := get(dc,'value,$e)) => dcval.expr
dc
sig := MSUBST(ndc,dc,sig)