diff options
author | dos-reis <gdr@axiomatics.org> | 2012-04-30 12:57:58 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2012-04-30 12:57:58 +0000 |
commit | 52d8ccbf25a71457f923860824696742328bdb35 (patch) | |
tree | dbfbf21d1ef7c887013a6171e12074663bf95abe | |
parent | ef0788534700412ae77cd7ce4377f57599b11f01 (diff) | |
download | open-axiom-52d8ccbf25a71457f923860824696742328bdb35.tar.gz |
* algebra/si.spad.pamphlet (SingleInteger): Use %iaddmod,
%isubmod, and %imulmod.
* interp/g-opt.boot: These are now builtin side-effect operators.
(optIaddmod): New optimizer. Register.
(optIsubmod): Likewise.
(optImulmod): Likewise.
* interp/sys-macros.lisp (QSADDMOD): Remove.
(QSDIFMOD): Likewise.
(QSMULMOD): Likewise.
-rw-r--r-- | src/ChangeLog | 12 | ||||
-rw-r--r-- | src/algebra/si.spad.pamphlet | 11 | ||||
-rw-r--r-- | src/interp/g-opt.boot | 14 | ||||
-rw-r--r-- | src/interp/sys-macros.lisp | 19 |
4 files changed, 32 insertions, 24 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c95e05fb..ae85c0e4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,17 @@ 2012-04-30 Gabriel Dos Reis <gdr@cs.tamu.edu> + * algebra/si.spad.pamphlet (SingleInteger): Use %iaddmod, + %isubmod, and %imulmod. + * interp/g-opt.boot: These are now builtin side-effect operators. + (optIaddmod): New optimizer. Register. + (optIsubmod): Likewise. + (optImulmod): Likewise. + * interp/sys-macros.lisp (QSADDMOD): Remove. + (QSDIFMOD): Likewise. + (QSMULMOD): Likewise. + +2012-04-30 Gabriel Dos Reis <gdr@cs.tamu.edu> + * interp/compiler.boot: Use float? in lieu of FLOATP. * interp/fortcall.boot: Likewise. * interp/i-object.boot: Likewise. diff --git a/src/algebra/si.spad.pamphlet b/src/algebra/si.spad.pamphlet index 4e3524b4..d982c432 100644 --- a/src/algebra/si.spad.pamphlet +++ b/src/algebra/si.spad.pamphlet @@ -180,7 +180,7 @@ IntegerNumberSystem(): Category == -- Lisp dependencies --- QSLEFTSHIFT, QSADDMOD, QSDIFMOD, QSMULTMOD +-- QSLEFTSHIFT SingleInteger(): Join(IntegerNumberSystem,OrderedFinite,BooleanLogic) with @@ -202,8 +202,11 @@ SingleInteger(): Join(IntegerNumberSystem,OrderedFinite,BooleanLogic) with import %icstmin: % from Foreign Builtin import %icstmax: % from Foreign Builtin import %iadd: (%,%) -> % from Foreign Builtin + import %iaddmod: (%,%,%) -> % from Foreign Builtin import %isub: (%,%) -> % from Foreign Builtin + import %isubmod: (%,%) -> % from Foreign Builtin import %imul: (%,%) -> % from Foreign Builtin + import %imulmod: (%,%,%) -> % from Foreign Builtin import %irem: (%,%) -> % from Foreign Builtin import %iquo: (%,%) -> % from Foreign Builtin import %ineg: % -> % from Foreign Builtin @@ -271,9 +274,9 @@ SingleInteger(): Join(IntegerNumberSystem,OrderedFinite,BooleanLogic) with hash(x) == %hash x length(x) == %ilength x shift(x,n) == QSLEFTSHIFT(x,n)$Lisp - mulmod(a,b,p) == QSMULTMOD(a,b,p)$Lisp - addmod(a,b,p) == QSADDMOD(a,b,p)$Lisp - submod(a,b,p) == QSDIFMOD(a,b,p)$Lisp + mulmod(a,b,p) == %imulmod(a,b,p) + addmod(a,b,p) == %iaddmod(a,b,p)$Lisp + submod(a,b,p) == %isubmod(a,b,p)$Lisp negative?(x) == %ilt(x,%icst0) size() == (%icstmax - %icstmin + %icst1) pretend NonNegativeInteger diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index ecf4b08c..fedbc988 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -639,7 +639,7 @@ $VMsideEffectFreeOperators == %beq %blt %ble %bgt %bge %bitand %bitior %bitxor %bitnot %bcompl %ilength %ibit %icst0 %icst1 %icstmin %icstmax %imul %iadd %isub %igcd %ilcm %ipow %imin %imax %ieven? %iodd? %iinc - %idec %irem %iquo %idivide %idec %irandom + %idec %irem %iquo %idivide %idec %irandom %imulmod %iaddmod %isubmod %feq %flt %fle %fgt %fge %fmul %fadd %fsub %fexp %fmin %fmax %float? %fpowi %fdiv %fneg %i2f %fminval %fmaxval %fbase %fprec %ftrunc %fsqrt %fpowf %flog %flog2 %flog10 %fmanexp %fNaN? %fdecode @@ -917,6 +917,9 @@ optIadd(x is ['%iadd,a,b]) == x x +optIaddmod ['%iaddmod,a,b,c] == + optIrem ['%irem,optIadd ['%iadd,a,b],c] + optIinc(x is ['%iinc,a]) == integer? a => a + 1 a is [op,b,c] and op in '(%isub %iadd) => @@ -951,6 +954,9 @@ optIsub(x is ['%isub,a,b]) == x x +optIsubmod ['%isubmod,a,b,c] == + optIrem ['%irem,optIsub ['%isub,a,b],c] + optIdec(x is ['%idec,a]) == integer? a => a - 1 a is ['%iadd,b,c] => @@ -969,6 +975,9 @@ optImul(x is ['%imul,a,b]) == integer? b and b = 1 => a x +optImulmod(x is ['%imulmod,a,b,c]) == + optIrem ['%irem,optImul ['%imul,a,b],c] + optIneg(x is ['%ineg,a]) == integer? a => -a x @@ -1001,11 +1010,14 @@ for x in '((%call optCall) _ (%ige optIge)_ (%ineg optIneg)_ (%iadd optIadd)_ + (%iaddmod optIaddmod)_ (%iinc optIinc)_ (%isub optIsub)_ + (%isubmod optIsubmod)_ (%irem optIrem)_ (%iquo optIquo)_ (%imul optImul)_ + (%imulmod optImulmod)_ (%2bit opt2bit)_ (%2bool opt2bool)_ (%list optList)_ diff --git a/src/interp/sys-macros.lisp b/src/interp/sys-macros.lisp index 60f71304..8e949642 100644 --- a/src/interp/sys-macros.lisp +++ b/src/interp/sys-macros.lisp @@ -269,25 +269,6 @@ (defmacro SPADDIFFERENCE (&rest x) `(- . ,x)) -;; following macros assume 0 <= x,y < z - -(defmacro QSADDMOD (x y z) - `(let* ((sum (QSPLUS ,x ,y)) - (rsum (QSDIFFERENCE sum ,z))) - (if (QSMINUSP rsum) - sum - rsum))) - -(defmacro QSDIFMOD (x y z) - `(let ((dif (QSDIFFERENCE ,x ,y))) - (if (QSMINUSP dif) - (QSPLUS dif ,z) - dif))) - -(defmacro QSMULTMOD (x y z) - `(REM (* ,x ,y) ,z)) - - ;; ;; -*- Pattern Matching -*- ;; |