[m-rev.] diff: add reverse modes for uint.xor/2 (part 1)
Julien Fischer
jfischer at opturion.com
Tue May 30 23:38:14 AEST 2017
Add reverse modes for uint.xor/2 (part 1).
compiler/builtin_ops.m:
Implement the reverse modes for uint.xor/1 as builtins.
library/uint.m:
Add the declarations for the reverse modes (commented out
until this change has bootstrapped).
Julien.
diff --git a/compiler/builtin_ops.m b/compiler/builtin_ops.m
index e19eee9c1..6b1f40fcf 100644
--- a/compiler/builtin_ops.m
+++ b/compiler/builtin_ops.m
@@ -432,7 +432,6 @@ builtin_translation(ModuleName, PredName, ProcNum, Args, Code) :-
; PredName = "unchecked_rem", ArithOp = uint_mod
; PredName = "/\\", ArithOp = uint_bitwise_and
; PredName = "\\/", ArithOp = uint_bitwise_or
- ; PredName = "xor", ArithOp = uint_bitwise_xor
; PredName = "unchecked_left_shift",
ArithOp = uint_unchecked_left_shift
; PredName = "unchecked_right_shift",
@@ -442,6 +441,19 @@ builtin_translation(ModuleName, PredName, ProcNum, Args, Code) :-
Args = [X, Y, Z],
Code = assign(Z, binary(ArithOp, leaf(X), leaf(Y)))
;
+ PredName = "xor",
+ Args = [X, Y, Z],
+ (
+ ProcNum = 0,
+ Code = assign(Z, binary(uint_bitwise_xor, leaf(X), leaf(Y)))
+ ;
+ ProcNum = 1,
+ Code = assign(Y, binary(uint_bitwise_xor, leaf(X), leaf(Z)))
+ ;
+ ProcNum = 2,
+ Code = assign(X, binary(uint_bitwise_xor, leaf(Y), leaf(Z)))
+ )
+ ;
( PredName = ">", CompareOp = uint_gt
; PredName = "<", CompareOp = uint_lt
; PredName = ">=", CompareOp = uint_ge
diff --git a/library/uint.m b/library/uint.m
index 2ebee22e2..5f1776b9b 100644
--- a/library/uint.m
+++ b/library/uint.m
@@ -161,7 +161,10 @@
% Bitwise exclusive or (xor).
%
-:- func xor(uint::in, uint::in) = (uint::uo) is det.
+:- func xor(uint, uint) = uint.
+:- mode xor(in, in) = uo is det.
+%:- mode xor(in, uo) = in is det.
+%:- mode xor(uo, in) = in is det.
% Bitwise complement.
%
More information about the reviews
mailing list