This is the mail archive of the
cgen@sourceware.org
mailing list for the CGEN project.
[commit] fix pmacro .and/.or snafu
- From: Doug Evans <dje at sebabeach dot org>
- To: cgen at sourceware dot org
- Date: Sun, 19 Jul 2009 10:00:33 -0700 (PDT)
- Subject: [commit] fix pmacro .and/.or snafu
I messed up with some of the new builtin pmacros.
RTL uses andif/orif and I think pmacros should too.
2009-07-19 Doug Evans <dje@sebabeach.org>
Rename builtin boolean pmacros, for consistency with rtl.
* pmacros.scm: .and -> .andif, .or -> .orif, .bitand -> .and,
.bitor -> .or, .bitxor -> .xor, .bitinv -> .inv.
* doc/pmacros.text: Update.
* testsuite/pmacros-1.test: Update.
Index: pmacros.scm
===================================================================
RCS file: /cvs/src/src/cgen/pmacros.scm,v
retrieving revision 1.7
diff -u -p -r1.7 pmacros.scm
--- pmacros.scm 13 Jul 2009 20:55:21 -0000 1.7
+++ pmacros.scm 19 Jul 2009 16:56:44 -0000
@@ -67,8 +67,8 @@
; (.length x) - length of symbol, string, or list
; (.replicate n expr) - return list of expr replicated n times
; (.equals x y) - deep comparison
-; (.and expr . rest) - && in C
-; (.or expr . rest) - || in C
+; (.andif expr . rest) - && in C
+; (.orif expr . rest) - || in C
; (.not expr) - ! in C
; (.eq x y)
; (.ne x y)
@@ -84,10 +84,10 @@
; (.sll x n) - shift left logical
; (.srl x n) - shift right logical
; (.sra x n) - shift right arithmetic
-; (.bitand x y) - bitwise and
-; (.bitor x y) - bitwise or
-; (.bitxor x y) - bitwise xor
-; (.bitinv x) - bitwise invert
+; (.and x y) - bitwise and
+; (.or x y) - bitwise or
+; (.xor x y) - bitwise xor
+; (.inv x) - bitwise invert
; (.car l)
; (.cdr l)
; (.caar l)
@@ -861,12 +861,12 @@
(equal? x y)
)
-; (.and . rest)
+; (.andif . rest)
; Note: syntactic form
; Elements of EXPRS are evaluated one at a time.
; Unprocessed elements are not evaluated.
-(define (-pmacro-builtin-and env . exprs)
+(define (-pmacro-builtin-andif env . exprs)
(if (null? exprs)
#t
(let loop ((exprs exprs))
@@ -876,12 +876,12 @@
(else #f)))))
)
-; (.or . rest)
+; (.orif . rest)
; Note: syntactic form
; Elements of EXPRS are evaluated one at a time.
; Unprocessed elements are not evaluated.
-(define (-pmacro-builtin-or env . exprs)
+(define (-pmacro-builtin-orif env . exprs)
(let loop ((exprs exprs))
(if (null? exprs)
#f
@@ -1049,34 +1049,34 @@
(else (quotient x (* n 2))))
)
-; (.bitand x y) - bitwise and
+; (.and x y) - bitwise and
-(define (-pmacro-builtin-bitand x y)
- (-pmacro-verify-integer ".bitand" x)
- (-pmacro-verify-integer ".bitand" y)
+(define (-pmacro-builtin-and x y)
+ (-pmacro-verify-integer ".and" x)
+ (-pmacro-verify-integer ".and" y)
(logand x y)
)
-; (.bitor x y) - bitwise or
+; (.or x y) - bitwise or
-(define (-pmacro-builtin-bitor x y)
- (-pmacro-verify-integer ".bitor" x)
- (-pmacro-verify-integer ".bitor" y)
+(define (-pmacro-builtin-or x y)
+ (-pmacro-verify-integer ".or" x)
+ (-pmacro-verify-integer ".or" y)
(logior x y)
)
-; (.bitxor x y) - bitwise xor
+; (.xor x y) - bitwise xor
-(define (-pmacro-builtin-bitxor x y)
- (-pmacro-verify-integer ".bitxor" x)
- (-pmacro-verify-integer ".bitxor" y)
+(define (-pmacro-builtin-xor x y)
+ (-pmacro-verify-integer ".xor" x)
+ (-pmacro-verify-integer ".xor" y)
(logxor x y)
)
-; (.bitinv x) - bitwise invert
+; (.inv x) - bitwise invert
-(define (-pmacro-builtin-bitinv x)
- (-pmacro-verify-integer ".bitinv" x)
+(define (-pmacro-builtin-inv x)
+ (-pmacro-verify-integer ".inv" x)
(lognot x)
)
@@ -1165,8 +1165,8 @@
(list '.length '(x) #f -pmacro-builtin-length "return length of symbol, string, or list")
(list '.replicate '(n expr) #f -pmacro-builtin-replicate "return list of expr replicated n times")
(list '.equals '(x y) #f -pmacro-builtin-equals "deep comparison of x and y")
- (list '.and 'rest #t -pmacro-builtin-and "return #f if any element is #f, otherwise return last element")
- (list '.or 'rest #t -pmacro-builtin-or "return first non-#f element, otherwise #f")
+ (list '.andif 'rest #t -pmacro-builtin-andif "return first #f element, otherwise return last element")
+ (list '.orif 'rest #t -pmacro-builtin-orif "return first non-#f element found, otherwise #f")
(list '.not '(x) #f -pmacro-builtin-not "return !x")
(list '.eq '(x y) #f -pmacro-builtin-eq "return true if x == y")
(list '.ne '(x y) #f -pmacro-builtin-ne "return true if x != y")
@@ -1182,10 +1182,10 @@
(list '.sll '(x n) #f -pmacro-builtin-sll "return logical x << n")
(list '.srl '(x n) #f -pmacro-builtin-srl "return logical x >> n")
(list '.sra '(x n) #f -pmacro-builtin-sra "return arithmetic x >> n")
- (list '.bitand '(x y) #f -pmacro-builtin-bitand "return x & y")
- (list '.bitor '(x y) #f -pmacro-builtin-bitor "return x | y")
- (list '.bitxor '(x y) #f -pmacro-builtin-bitxor "return x ^ y")
- (list '.bitinv '(x) #f -pmacro-builtin-bitinv "return ~x")
+ (list '.and '(x y) #f -pmacro-builtin-and "return x & y")
+ (list '.or '(x y) #f -pmacro-builtin-or "return x | y")
+ (list '.xor '(x y) #f -pmacro-builtin-xor "return x ^ y")
+ (list '.inv '(x) #f -pmacro-builtin-inv "return ~x")
(list '.car '(x) #f -pmacro-builtin-car "return (car x)")
(list '.cdr '(x) #f -pmacro-builtin-cdr "return (cdr x)")
(list '.caar '(x) #f -pmacro-builtin-caar "return (caar x)")
Index: doc/pmacros.texi
===================================================================
RCS file: /cvs/src/src/cgen/doc/pmacros.texi,v
retrieving revision 1.6
diff -u -p -r1.6 pmacros.texi
--- doc/pmacros.texi 13 Jul 2009 20:55:21 -0000 1.6
+++ doc/pmacros.texi 19 Jul 2009 16:56:44 -0000
@@ -147,7 +147,7 @@ These pmacros are processed differently
@emph{not} evaluated first. Instead it is up to the pmacro
to decide when, and if, the parameters are evaluated.
The syntactic forms are: @code{.pmacro}, @code{.let}, @code{.if},
-@code{.case}, @code{.cond}, @code{.begin}, @code{.and}, and @code{.or}.
+@code{.case}, @code{.cond}, @code{.begin}, @code{.andif}, and @code{.orif}.
If the result of the pmacro is another pmacro invocation,
it is in turn processed.
@@ -1010,8 +1010,8 @@ and ``false'' is represented by @code{#f
@menu
* .equals:: Deep comparison
-* .and:: && in C
-* .or:: || in C
+* .andif:: && in C
+* .orif:: || in C
* .not:: ! in C
* .eq:: Shallow comparison
* .ne:: Shallow comparison
@@ -1041,11 +1041,11 @@ Examples:
(.equals ((1 2 3) (4 5 6)) ((1 2 3) (4 5 6))) --> #t
@end smallexample
-@node .and
-@subsection .and
-@cindex .and
+@node .andif
+@subsection .andif
+@cindex .andif
-Syntax: @samp{(.and [expr1 [expr2 ...]])}
+Syntax: @samp{(.andif [expr1 [expr2 ...]])}
Each expression is evaluated in turn.
If an expression evaluates to false (@code{#f}) then
@@ -1061,16 +1061,16 @@ that evaluates to ``false''.
Examples:
@smallexample
-(.and 1 #f 2) --> #f
-(.and 1 2 3) --> 3
-(.and) --> #t
+(.andif 1 #f 2) --> #f
+(.andif 1 2 3) --> 3
+(.andif) --> #t
@end smallexample
-@node .or
-@subsection .or
-@cindex .or
+@node .orif
+@subsection .orif
+@cindex .orif
-Syntax: @samp{(.or [expr1 [expr2 ...]])}
+Syntax: @samp{(.orif [expr1 [expr2 ...]])}
Each expression is evaluated in turn.
If an expression evaluates to non-false (@code{#f}) then
@@ -1087,9 +1087,9 @@ that evaluates to non-``false''.
Examples:
@smallexample
-(.or 1 2 3) --> 1
-(.or #f #f #f) --> #f
-(.or) --> #f
+(.orif 1 2 3) --> 1
+(.orif #f #f #f) --> #f
+(.orif) --> #f
@end smallexample
@node .not
@@ -1259,10 +1261,10 @@ Builtin macros for shifts and bitwise fu
* .sll:: Shift left logical
* .srl:: Shift right logical
* .sra:: Shift right arithmetic
-* .bitand:: Bitwise and
-* .bitor:: Bitwise or
-* .bitxor:: Bitwise exclusive-or
-* .bitinv:: Bitwise inversion
+* .and:: Bitwise and
+* .or:: Bitwise or
+* .xor:: Bitwise exclusive-or
+* .inv:: Bitwise inversion
@end menu
@node .sll
@@ -1302,34 +1304,34 @@ The sign bit of @code{x} is shifted into
@code{n} must be a non-negative integer.
-@node .bitand
-@subsection .bitand
-@cindex .bitand
+@node .and
+@subsection .and
+@cindex .and
-Syntax: @samp{(.bitand x y)}
+Syntax: @samp{(.and x y)}
Return the bitwise @code{and} of @code{x} and @code{y}.
-@node .bitor
-@subsection .bitor
-@cindex .bitor
+@node .or
+@subsection .or
+@cindex .or
-Syntax: @samp{(.bitor x y)}
+Syntax: @samp{(.or x y)}
Return the bitwise @code{or} of @code{x} and @code{y}.
-@node .bitxor
-@subsection .bitxor
-@cindex .bitxor
+@node .xor
+@subsection .xor
+@cindex .xor
-Syntax: @samp{(.bitxor x y)}
+Syntax: @samp{(.xor x y)}
Return the bitwise @code{exclusive-or} of @code{x} and @code{y}.
-@node .bitinv
-@subsection .bitinv
-@cindex .bitinv
+@node .inv
+@subsection .inv
+@cindex .inv
-Syntax: @samp{(.bitinv x)}
+Syntax: @samp{(.inv x)}
Return the bitwise @code{inversion} of @code{x}.
Index: testsuite/pmacros-1.test
===================================================================
RCS file: /cvs/src/src/cgen/testsuite/pmacros-1.test,v
retrieving revision 1.1
diff -u -p -r1.1 pmacros-1.test
--- testsuite/pmacros-1.test 13 Jul 2009 20:55:21 -0000 1.1
+++ testsuite/pmacros-1.test 19 Jul 2009 16:56:44 -0000
@@ -144,21 +144,21 @@ cat > ${cpu_file} <<EOF
(print-match "#f")
(print-expr (.equals (yo yo) (yo x)))
-(test-name ".and")
-(print-match "and")
-(print-expr (.and 1 #t and))
+(test-name ".andif")
+(print-match "andif")
+(print-expr (.andif 1 #t andif))
(print-match "#f")
-(print-expr (.and 1 #f and))
+(print-expr (.andif 1 #f andif))
(print-match "#t")
-(print-expr (.and))
+(print-expr (.andif))
-(test-name ".or")
-(print-match "or")
-(print-expr (.or #f or))
+(test-name ".orif")
+(print-match "orif")
+(print-expr (.orif #f orif))
(print-match "#f")
-(print-expr (.or #f #f))
+(print-expr (.orif #f #f))
(print-match "#f")
-(print-expr (.or))
+(print-expr (.orif))
(test-name ".not")
(print-match "yep")
@@ -238,21 +238,21 @@ cat > ${cpu_file} <<EOF
(print-match "-1")
(print-expr (.sra -3 1))
-(test-name ".bitand")
+(test-name ".and")
(print-match "8")
-(print-expr (.bitand 15 8))
+(print-expr (.and 15 8))
-(test-name ".bitor")
+(test-name ".or")
(print-match "15")
-(print-expr (.bitor 15 8))
+(print-expr (.or 15 8))
-(test-name ".bitxor")
+(test-name ".xor")
(print-match "7")
-(print-expr (.bitxor 15 8))
+(print-expr (.xor 15 8))
-(test-name ".bitinv")
+(test-name ".inv")
(print-match "-6")
-(print-expr (.bitinv 5))
+(print-expr (.inv 5))
(test-name ".car")
(print-match "car")