diff --git a/ll.py b/ll.py index 83b71a4..ecfff99 100644 --- a/ll.py +++ b/ll.py @@ -49,3 +49,8 @@ Ptrtoint = namedtuple('Ptrtoint', ['pointer_ty', 'oper', 'to_ty']) Ret = namedtuple('Ret', ['ty', 'oper']) Br = namedtuple('Br', ['label']) Cbr = namedtuple('Cbr', ['ty', 'oper', 'then_label', 'else_label']) + +Null = namedtuple('Null', []) +Const = namedtuple('Const', ['val']) +Gid = namedtuple('Gid', ['val']) +Id = namedtuple('Id', ['val']) diff --git a/parser.py b/parser.py index 342c97a..59e9002 100644 --- a/parser.py +++ b/parser.py @@ -439,13 +439,21 @@ class LLVMParser(object): 'terminator : BR ty operand COMMA LABEL PercentID COMMA LABEL PercentID' p[0] = ll.Cbr(p[2], p[3], p[6], p[9]) - def p_operand(self, p): - '''operand : NULL - | INT - | AtID - | PercentID''' - # TODO: distinguish ids - p[0] = p[1] + def p_operand_null(self, p): + 'operand : NULL' + p[0] = ll.Null + + def p_operand_const(self, p): + 'operand : INT' + p[0] = ll.Const(p[1]) + + def p_operand_gid(self, p): + 'operand : AtID' + p[0] = ll.Gid(p[1]) + + def p_operand_id(self, p): + 'operand : PercentID' + p[0] = ll.Id(p[1]) def p_named_block_list_single(self, p): 'named_block_list : ID COLON block'