|
|
|
@ -42,9 +42,8 @@
|
|
|
|
|
%token LABEL
|
|
|
|
|
%token METADATA
|
|
|
|
|
|
|
|
|
|
%token <int> SIZE
|
|
|
|
|
(* CONSTANTS *)
|
|
|
|
|
%token <int> CONSTINT
|
|
|
|
|
%token <int> CONSTANT_INT
|
|
|
|
|
%token NULL
|
|
|
|
|
|
|
|
|
|
(* INSTRUCTIONS *)
|
|
|
|
@ -162,13 +161,13 @@ typ:
|
|
|
|
|
| tp = element_typ { tp }
|
|
|
|
|
(*| X86_MMX { () }*)
|
|
|
|
|
| tp = vector_typ { tp }
|
|
|
|
|
| LSQBRACK sz = SIZE X tp = element_typ RSQBRACK { Tarray (sz, tp) } (* array type *)
|
|
|
|
|
| LSQBRACK sz = CONSTANT_INT X tp = element_typ RSQBRACK { Tarray (sz, tp) } (* array type *)
|
|
|
|
|
| LABEL { Tlabel }
|
|
|
|
|
| METADATA { Tmetadata }
|
|
|
|
|
(* TODO structs *)
|
|
|
|
|
|
|
|
|
|
vector_typ:
|
|
|
|
|
| LANGLE sz = SIZE X tp = element_typ RANGLE { Tvector (sz, tp) }
|
|
|
|
|
| LANGLE sz = CONSTANT_INT X tp = element_typ RANGLE { Tvector (sz, tp) }
|
|
|
|
|
|
|
|
|
|
element_typ:
|
|
|
|
|
| width = INT { Tint width }
|
|
|
|
@ -196,7 +195,7 @@ instr:
|
|
|
|
|
| BR LABEL lbl=variable { UncondBranch lbl }
|
|
|
|
|
| BR BIT op=operand COMMA LABEL lbl1=variable COMMA LABEL lbl2=variable { CondBranch (op, lbl1, lbl2) }
|
|
|
|
|
(* Memory access operations *)
|
|
|
|
|
| var=variable EQUALS ALLOCA tp=typ (*COMMA ALIGN sz=SIZE*) { Alloc (var, tp, 1, 1) }
|
|
|
|
|
| var=variable EQUALS ALLOCA tp=typ (*COMMA ALIGN sz=CONSTANT_INT*) { Alloc (var, tp, 1, 1) }
|
|
|
|
|
| var = variable EQUALS LOAD tp = ptr_typ ptr = variable { Load (var, tp, ptr) }
|
|
|
|
|
| STORE val_tp = typ value = operand COMMA ptr_tp = ptr_typ var = variable { Store (value, val_tp, var) }
|
|
|
|
|
(* don't yet know why val_tp and ptr_tp would be different *)
|
|
|
|
@ -248,5 +247,5 @@ variable:
|
|
|
|
|
| num = NUMBERED_LOCAL { Local (Number num) }
|
|
|
|
|
|
|
|
|
|
constant:
|
|
|
|
|
| i = CONSTINT { Cint i }
|
|
|
|
|
| i = CONSTANT_INT { Cint i }
|
|
|
|
|
| NULL { Cnull }
|
|
|
|
|