From 0f4b96b2b02822abf6f84903366709b1336905a2 Mon Sep 17 00:00:00 2001 From: Shagun Agrawal Date: Sun, 11 Aug 2024 00:22:05 +0530 Subject: Add bitwise operators --- src/cljcc/tacky.clj | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/cljcc/tacky.clj') diff --git a/src/cljcc/tacky.clj b/src/cljcc/tacky.clj index d87a909..533cb3e 100644 --- a/src/cljcc/tacky.clj +++ b/src/cljcc/tacky.clj @@ -38,7 +38,12 @@ :sub-exp :sub :mul-exp :mul :div-exp :div - :mod-exp :mod)) + :mod-exp :mod + :bit-and-exp :bit-and + :bit-or-exp :bit-or + :bit-xor-exp :bit-xor + :bit-right-shift-exp :bit-right-shift + :bit-left-shift-exp :bit-left-shift)) (defn- unary-instruction [unary-operator src dst] {:type :unary @@ -62,7 +67,12 @@ :sub-exp :mul-exp :mod-exp - :div-exp}) + :div-exp + :bit-and-exp + :bit-or-exp + :bit-xor-exp + :bit-right-shift-exp + :bit-left-shift-exp}) (defn- binary-expr? [v] (contains? binary-exprs v)) @@ -121,7 +131,7 @@ (pp/pprint (tacky-generate - (p/parse "int main(void) {return 1 * 2 - 3 * (4 + 5);}"))) + (p/parse "int main(void) {return 1 * 2 & 3 * (4 + 5);}"))) (pp/pprint (p/parse "int main(void) {return 1 * 2 - 3 * (4 + 5);}")) -- cgit v1.2.3