Add zext and ptrtoint.
This commit is contained in:
parent
4aeb986d75
commit
b509ba2595
8
ll.py
8
ll.py
|
@ -102,6 +102,14 @@ def insn2s(insn):
|
|||
return ('icmp {} {} {}, {}'
|
||||
.format(insn.cnd, ty2s(insn.ty),
|
||||
oper2s(insn.left), oper2s(insn.right)))
|
||||
elif isinstance(insn, Zext):
|
||||
return ('zext {} {} to {}'
|
||||
.format(ty2s(insn.from_ty), oper2s(insn.oper),
|
||||
ty2s(insn.to_ty)))
|
||||
elif isinstance(insn, Ptrtoint):
|
||||
return ('ptrtoint {}* {} to {}'
|
||||
.format(ty2s(insn.pointer_ty), oper2s(insn.oper),
|
||||
ty2s(insn.to_ty)))
|
||||
else:
|
||||
# TODO
|
||||
print('insn2s: Unknown insn: {}'
|
||||
|
|
20
stepper.py
20
stepper.py
|
@ -51,6 +51,26 @@ def step(insns, terminator, blocks, stack_frames, ssa_env, global_env, memory,
|
|||
# TODO
|
||||
print('icmp {} {}, {}'
|
||||
.format(cnd, left_v, right_v))
|
||||
elif isinstance(next_insn, ll.Zext):
|
||||
oper = next_insn.oper
|
||||
from_ty = next_insn.from_ty
|
||||
to_ty = next_insn.to_ty
|
||||
oper_v = eval_oper(oper, ssa_env, global_env)
|
||||
res = oper_v
|
||||
|
||||
# TODO
|
||||
print('zext {} {} to {}'
|
||||
.format(ll.ty2s(from_ty), oper_v, ll.ty2s(to_ty)))
|
||||
elif isinstance(next_insn, ll.Ptrtoint):
|
||||
oper = next_insn.oper
|
||||
pointer_ty = next_insn.pointer_ty
|
||||
to_ty = next_insn.to_ty
|
||||
oper_v = eval_oper(oper, ssa_env, global_env)
|
||||
res = oper_v
|
||||
|
||||
# TODO
|
||||
print('ptrtoint {}* {} to {}'
|
||||
.format(ll.ty2s(pointer_ty), oper_v, ll.ty2s(to_ty)))
|
||||
else:
|
||||
err('Unknown LLVM instruction: {}'
|
||||
.format(next_insn))
|
||||
|
|
Loading…
Reference in New Issue
Block a user