|
|
@ -153,7 +153,7 @@
|
|
|
|
%%
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
|
|
prog:
|
|
|
|
prog:
|
|
|
|
| targets defs = list(func_def) metadata_def* EOF { Prog defs }
|
|
|
|
| targets defs = func_def* metadata_def* EOF { Prog defs }
|
|
|
|
|
|
|
|
|
|
|
|
targets:
|
|
|
|
targets:
|
|
|
|
| { (None, None) }
|
|
|
|
| { (None, None) }
|
|
|
@ -177,7 +177,7 @@ metadata_var:
|
|
|
|
|
|
|
|
|
|
|
|
func_def:
|
|
|
|
func_def:
|
|
|
|
| DEFINE ret_tp = ret_typ name = variable LPAREN
|
|
|
|
| DEFINE ret_tp = ret_typ name = variable LPAREN
|
|
|
|
params = separated_list(COMMA, pair(typ, IDENT)) RPAREN list(attribute_group)
|
|
|
|
params = separated_list(COMMA, pair(typ, IDENT)) RPAREN attribute_group*
|
|
|
|
annotated_instrs = block { FuncDef (name, ret_tp, params, annotated_instrs) }
|
|
|
|
annotated_instrs = block { FuncDef (name, ret_tp, params, annotated_instrs) }
|
|
|
|
|
|
|
|
|
|
|
|
attribute_group:
|
|
|
|
attribute_group:
|
|
|
@ -216,7 +216,7 @@ ptr_typ:
|
|
|
|
| tp = typ STAR { tp }
|
|
|
|
| tp = typ STAR { tp }
|
|
|
|
|
|
|
|
|
|
|
|
block:
|
|
|
|
block:
|
|
|
|
| LBRACE annotated_instrs = list(annotated_instr) RBRACE { annotated_instrs }
|
|
|
|
| LBRACE annotated_instrs = annotated_instr* RBRACE { annotated_instrs }
|
|
|
|
|
|
|
|
|
|
|
|
annotated_instr:
|
|
|
|
annotated_instr:
|
|
|
|
| instruction=instr anno=annotation? { (instruction, anno) }
|
|
|
|
| instruction=instr anno=annotation? { (instruction, anno) }
|
|
|
@ -231,9 +231,9 @@ instr:
|
|
|
|
| BR LABEL lbl = variable { UncondBranch lbl }
|
|
|
|
| BR LABEL lbl = variable { UncondBranch lbl }
|
|
|
|
| BR BIT op = operand COMMA LABEL lbl1 = variable COMMA LABEL lbl2 = variable { CondBranch (op, lbl1, lbl2) }
|
|
|
|
| BR BIT op = operand COMMA LABEL lbl1 = variable COMMA LABEL lbl2 = variable { CondBranch (op, lbl1, lbl2) }
|
|
|
|
(* Memory access operations *)
|
|
|
|
(* Memory access operations *)
|
|
|
|
| var = variable EQUALS ALLOCA tp = typ option(align) { Alloc (var, tp, 1) }
|
|
|
|
| var = variable EQUALS ALLOCA tp = typ align? { Alloc (var, tp, 1) }
|
|
|
|
| var = variable EQUALS LOAD tp = ptr_typ ptr = variable option(align) { Load (var, tp, ptr) }
|
|
|
|
| var = variable EQUALS LOAD tp = ptr_typ ptr = variable align? { Load (var, tp, ptr) }
|
|
|
|
| STORE val_tp = typ value = operand COMMA ptr_tp = ptr_typ var = variable option(align) { Store (value, val_tp, var) }
|
|
|
|
| STORE val_tp = typ value = operand COMMA ptr_tp = ptr_typ var = variable align? { Store (value, val_tp, var) }
|
|
|
|
(* don't yet know why val_tp and ptr_tp would be different *)
|
|
|
|
(* don't yet know why val_tp and ptr_tp would be different *)
|
|
|
|
| variable EQUALS binop { Binop }
|
|
|
|
| variable EQUALS binop { Binop }
|
|
|
|
|
|
|
|
|
|
|
@ -247,16 +247,16 @@ binop:
|
|
|
|
| FSUB fast_math_flags binop_args { () }
|
|
|
|
| FSUB fast_math_flags binop_args { () }
|
|
|
|
| MUL binop_args { () }
|
|
|
|
| MUL binop_args { () }
|
|
|
|
| FMUL fast_math_flags binop_args { () }
|
|
|
|
| FMUL fast_math_flags binop_args { () }
|
|
|
|
| UDIV option(EXACT) binop_args { () }
|
|
|
|
| UDIV EXACT? binop_args { () }
|
|
|
|
| SDIV option(EXACT) binop_args { () }
|
|
|
|
| SDIV EXACT? binop_args { () }
|
|
|
|
| FDIV fast_math_flags binop_args { () }
|
|
|
|
| FDIV fast_math_flags binop_args { () }
|
|
|
|
| UREM binop_args { () }
|
|
|
|
| UREM binop_args { () }
|
|
|
|
| SREM binop_args { () }
|
|
|
|
| SREM binop_args { () }
|
|
|
|
| FREM fast_math_flags binop_args { () }
|
|
|
|
| FREM fast_math_flags binop_args { () }
|
|
|
|
(* bitwise *)
|
|
|
|
(* bitwise *)
|
|
|
|
| SHL arith_options binop_args { () }
|
|
|
|
| SHL arith_options binop_args { () }
|
|
|
|
| LSHR option(EXACT) binop_args { () }
|
|
|
|
| LSHR EXACT? binop_args { () }
|
|
|
|
| ASHR option(EXACT) binop_args { () }
|
|
|
|
| ASHR EXACT? binop_args { () }
|
|
|
|
| AND binop_args { () }
|
|
|
|
| AND binop_args { () }
|
|
|
|
| OR binop_args { () }
|
|
|
|
| OR binop_args { () }
|
|
|
|
| XOR binop_args { () }
|
|
|
|
| XOR binop_args { () }
|
|
|
@ -265,10 +265,10 @@ binop:
|
|
|
|
| INSERTELEMENT vector_typ operand COMMA typ operand COMMA typ operand { () }
|
|
|
|
| INSERTELEMENT vector_typ operand COMMA typ operand COMMA typ operand { () }
|
|
|
|
|
|
|
|
|
|
|
|
arith_options:
|
|
|
|
arith_options:
|
|
|
|
| option(NUW) option(NSW) { () }
|
|
|
|
| NUW? NSW? { () }
|
|
|
|
|
|
|
|
|
|
|
|
fast_math_flags:
|
|
|
|
fast_math_flags:
|
|
|
|
| option(NNAN) option(NINF) option(NSZ) option(ARCP) option(FAST) { () }
|
|
|
|
| NNAN? NINF? NSZ? ARCP? FAST? { () }
|
|
|
|
|
|
|
|
|
|
|
|
binop_args:
|
|
|
|
binop_args:
|
|
|
|
| typ operand COMMA operand { () }
|
|
|
|
| typ operand COMMA operand { () }
|
|
|
|