aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2010-07-22 21:44:34 +0000
committerdos-reis <gdr@axiomatics.org>2010-07-22 21:44:34 +0000
commit024f4b2055594e528ec98e733bd50684b2366db0 (patch)
treecf3da9fdf92fe71c354e720428fa4f4c43bb98b1 /src/interp
parent510c2f70ce377d60eed221e46294767f7f548f5d (diff)
downloadopen-axiom-024f4b2055594e528ec98e733bd50684b2366db0.tar.gz
* interp/g-util.boot (expandIeq): New expander for %ieq.
* interp/g-opt.boot (optIeq): New. (optIadd): Likewise. (optIsub): Likewise. (optImul): Likewise. (optIneg): Likewise. (lispize): Remove.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/define.boot2
-rw-r--r--src/interp/g-opt.boot33
-rw-r--r--src/interp/g-timer.boot4
-rw-r--r--src/interp/g-util.boot9
-rw-r--r--src/interp/nruncomp.boot2
5 files changed, 42 insertions, 8 deletions
diff --git a/src/interp/define.boot b/src/interp/define.boot
index dbd8bfc7..c2f08f1d 100644
--- a/src/interp/define.boot
+++ b/src/interp/define.boot
@@ -1414,7 +1414,7 @@ compSubDomain1(domainForm,predicate,m,e) ==
compCompilerPredicate(predicate,e) or
stackSemanticError(["predicate: ",predicate,
" cannot be interpreted with #1: ",domainForm],nil)
- pred := lispize u.expr
+ pred := simplifyVMForm u.expr
-- For now, reject predicates that directly reference domains
CONTAINED("$",pred) =>
stackAndThrow('"predicate %1pb is not simple enough",[predicate])
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index b29d9034..1c8964f6 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -694,6 +694,12 @@ optOr(x is ['%or,a,b]) ==
a = '%true => '%true
x
+optIeq(x is ['%ieq,a,b]) ==
+ integer? a and integer? b =>
+ a = b => '%true
+ '%false
+ x
+
optIlt(x is ['%ilt,a,b]) ==
integer? a and integer? b =>
a < b => '%true
@@ -709,11 +715,27 @@ optIgt x ==
optIge x ==
optNot ['%not,optIlt ['%ilt,second x,third x]]
---%
+--% Integer operations
-lispize x == simplifyVMForm x
-
+optIadd(x is ['%iadd,a,b]) ==
+ integer? a and integer? b => a + b
+ x
+
+optIsub(x is ['%isub,a,b]) ==
+ integer? a and integer? b => a - b
+ x
+
+optImul(x is ['%imul,a,b]) ==
+ integer? a and integer? b => a * b
+ x
+
+optIneg(x is ['%ineg,a]) ==
+ integer? a => -a
+ x
+
+--%
--% optimizer hash table
+--%
for x in '( (%call optCall) _
(SEQ optSEQ)_
@@ -723,10 +745,15 @@ for x in '( (%call optCall) _
(%not optNot)_
(%and optAnd)_
(%or optOr)_
+ (%ieq optIeq)_
(%ilt optIlt)_
(%ile optIle)_
(%igt optIgt)_
(%ige optIge)_
+ (%ineg optIneg)_
+ (%iadd optIadd)_
+ (%isub optIsub)_
+ (%imul optImul)_
(LIST optLIST)_
(MINUS optMINUS)_
(QSMINUS optQSMINUS)_
diff --git a/src/interp/g-timer.boot b/src/interp/g-timer.boot
index edd7020d..9f1fd02f 100644
--- a/src/interp/g-timer.boot
+++ b/src/interp/g-timer.boot
@@ -246,9 +246,9 @@ timedAlgebraEvaluation(code) ==
timedOptimization(code) ==
startTimingProcess 'optimization
$getDomainCode : local := NIL
- r := lispize code
+ r := simplifyVMForm code
if $reportOptimization then
- sayBrightlyI bright '"Optimized LISP code:"
+ sayBrightlyI bright '"Optimized intermediate code:"
pp r
stopTimingProcess 'optimization
r
diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot
index 012a9ccc..669998cd 100644
--- a/src/interp/g-util.boot
+++ b/src/interp/g-util.boot
@@ -250,6 +250,13 @@ expandIneg ['%ineg,x] ==
integer? x => -x
['_-,x]
+expandIeq ['%ieq,a,b] ==
+ a := expandToVMForm a
+ integer? a and a = 0 => ['ZEROP,expandToVMForm b]
+ b := expandToVMForm b
+ integer? b and b = 0 => ['ZEROP,a]
+ ['EQL,a,b]
+
expandIlt ['%ilt,x,y] ==
integer? x and x = 0 =>
integer? y => y > 0
@@ -358,7 +365,6 @@ for x in [
['%ismall?, :'FIXNUMP],
-- binary integer operations.
['%iadd,:"+"],
- ['%ieq, :"EQL"],
['%igcd,:'GCD],
['%ige, :">="],
['%iinc,:"1+"],
@@ -437,6 +443,7 @@ for x in [
['%bge, :function expandBge],
['%bcompl, :function expandBcompl],
+ ['%ieq, :function expandIeq],
['%igt, :function expandIgt],
['%ilt, :function expandIlt],
['%ineg, :function expandIneg],
diff --git a/src/interp/nruncomp.boot b/src/interp/nruncomp.boot
index 4c5c3b11..965c851f 100644
--- a/src/interp/nruncomp.boot
+++ b/src/interp/nruncomp.boot
@@ -129,7 +129,7 @@ NRTencode(x,y) == encode(x,y,true) where encode(x,compForm,firstTime) ==
-- enumeration constants are like field names, they do not need
-- to be encoded.
op = "Enumeration" => x
- ["NRTEVAL",NRTreplaceAllLocalReferences COPY_-TREE lispize compForm]
+ ["NRTEVAL",NRTreplaceAllLocalReferences COPY_-TREE simplifyVMForm compForm]
MEMQ(x,$formalArgList) =>
v := $FormalMapVariableList.(POSN1(x,$formalArgList))
firstTime => ["local",v]