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').
This commit is contained in:
Quentin Carbonneaux 2015-07-31 10:21:10 -04:00
parent 1a78659dfa
commit d8d17705c4
5 changed files with 28 additions and 16 deletions

View file

@ -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 {