Add incomplete LLVM pretty printing.
This commit is contained in:
parent
1ffe310f97
commit
1341911459
31
ll.py
31
ll.py
|
@ -54,3 +54,34 @@ Null = namedtuple('Null', [])
|
|||
Const = namedtuple('Const', ['val'])
|
||||
Gid = namedtuple('Gid', ['val'])
|
||||
Id = namedtuple('Id', ['val'])
|
||||
|
||||
|
||||
def ty2s(ty):
|
||||
if ty == SimpleType.I64:
|
||||
return 'i64'
|
||||
else:
|
||||
# TODO
|
||||
print('Unknown type: {}'
|
||||
.format(ty))
|
||||
|
||||
|
||||
def oper2s(operand):
|
||||
if isinstance(operand, Const):
|
||||
return str(operand.val)
|
||||
elif isinstance(operand, Id):
|
||||
return '%' + operand.val
|
||||
else:
|
||||
# TODO
|
||||
print('Unknown operand: {}'
|
||||
.format(operand))
|
||||
|
||||
|
||||
def insn2s(insn):
|
||||
if isinstance(insn, Binop):
|
||||
return ('{} {} {}, {}'
|
||||
.format(insn.bop, ty2s(insn.ty),
|
||||
oper2s(insn.left), oper2s(insn.right)))
|
||||
else:
|
||||
# TODO
|
||||
print('Unknown insn: {}'
|
||||
.format(insn))
|
||||
|
|
Loading…
Reference in New Issue
Block a user