[m-rev.] diff: make some int operations builtins.
Julien Fischer
juliensf at cs.mu.OZ.AU
Fri Apr 1 16:25:53 AEST 2005
On Fri, 1 Apr 2005, Zoltan Somogyi wrote:
> compiler/builtin_ops.m:
> Make int.plus, int.minus and int.times builtin operations, with
> the same implementations as int.+, int.- and int.*.
>
In which case, I intend to add the following as well:
Estimated hours taken: 0.1
Branches: main
compiler/const_prop.m:
Perform constant propagation of int.plus/2, int.minus/2
and int.times/2.
Julien.
Index: compiler/const_prop.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/const_prop.m,v
retrieving revision 1.27
diff -u -r1.27 const_prop.m
--- compiler/const_prop.m 24 Mar 2005 02:00:19 -0000 1.27
+++ compiler/const_prop.m 1 Apr 2005 05:42:30 -0000
@@ -217,6 +217,21 @@
YVal \= 0,
ZVal = XVal // YVal.
+evaluate_det_call("int", "plus", 0, [X, Y, Z], Z, int_const(ZVal)) :-
+ X ^ arg_inst = bound(_XUniq, [functor(int_const(XVal), [])]),
+ Y ^ arg_inst = bound(_YUniq, [functor(int_const(YVal), [])]),
+ ZVal = XVal + YVal.
+
+evaluate_det_call("int", "minus", 0, [X, Y, Z], Z, int_const(ZVal)) :-
+ X ^ arg_inst = bound(_XUniq, [functor(int_const(XVal), [])]),
+ Y ^ arg_inst = bound(_YUniq, [functor(int_const(YVal), [])]),
+ ZVal = XVal - YVal.
+
+evaluate_det_call("int", "times", 0, [X, Y, Z], Z, int_const(ZVal)) :-
+ X ^ arg_inst = bound(_XUniq, [functor(int_const(XVal), [])]),
+ Y ^ arg_inst = bound(_YUniq, [functor(int_const(YVal), [])]),
+ ZVal = XVal * YVal.
+
evaluate_det_call("int", "unchecked_quotient", 0, [X, Y, Z], Z,
int_const(ZVal)) :-
X ^ arg_inst = bound(_XUniq, [functor(int_const(XVal), [])]),
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list