Be more precise about operands in AST.
This commit is contained in:
parent
8128f72264
commit
1ffe310f97
5
ll.py
5
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'])
|
||||
|
|
22
parser.py
22
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'
|
||||
|
|
Loading…
Reference in New Issue
Block a user