From d8d17705c4f525314471f5526ef3328dd41625cd Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Fri, 31 Jul 2015 10:21:10 -0400 Subject: clean the commutativity + fix bug in emit The commutativity information only makes sense for arithmetic expressions. To account for that, I introduced a new tri-valued boolean type B3. Memory operations, for example, will receive an undefined commutativity trit. The code emitter was buggy when rega emitted instructions like 'rax = add 1, rax', this is now fixed using the commutativity information (we rewrite it in 'rax = add rax, 1'). --- lisc/lisc.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lisc/lisc.h') diff --git a/lisc/lisc.h b/lisc/lisc.h index 7f558b0..2f00e09 100644 --- a/lisc/lisc.h +++ b/lisc/lisc.h @@ -16,6 +16,8 @@ typedef struct Sym Sym; typedef struct Const Const; typedef struct Fn Fn; +typedef enum { U, F, T } B3; + enum { RAX = 1, RCX, @@ -105,9 +107,9 @@ enum { }; struct OpDesc { - int arity; - uint commut:1; char *name; + int arity; + B3 comm; }; struct Ins { -- cgit 1.4.1