From 344609e54bd24454265d1bbbe4bfc641ab3aa3ea Mon Sep 17 00:00:00 2001 From: cfreksen Date: Sun, 29 Oct 2017 19:12:30 +0100 Subject: [PATCH] Print when evaluating terminators. --- ll.py | 22 ++++++++++++++++++++++ stepper.py | 8 ++++++++ 2 files changed, 30 insertions(+) diff --git a/ll.py b/ll.py index a0a9c01..66260a4 100644 --- a/ll.py +++ b/ll.py @@ -106,3 +106,25 @@ def insn2s(insn): # TODO print('insn2s: Unknown insn: {}' .format(insn)) + +def terminator2s(terminator): + if isinstance(terminator, Ret): + if terminator.oper is None: + return ('ret {}' + .format(ty2s(terminator.ty))) + else: + return ('ret {} {}' + .format(ty2s(terminator.ty), + oper2s(terminator.oper))) + elif isinstance(terminator, Br): + return ('br label %{}' + .format(terminator.label)) + elif isinstance(terminator, Cbr): + return ('br {} {}, label %{}, label %{}' + .format(ty2s(terminator.ty), + oper2s(terminator.oper), + terminator.then_label, + terminator.else_label)) + else: + print('terminator2s: Unknown terminator {}' + .format(terminator)) diff --git a/stepper.py b/stepper.py index 1ebcb21..6523881 100644 --- a/stepper.py +++ b/stepper.py @@ -69,12 +69,19 @@ def terminate(terminator, blocks, stack_frames, ssa_env, global_env, memory): if id is not None and id in ssa_env: del ssa_env[id] + print('Evaluating {}' + .format(ll.terminator2s(terminator))) + if isinstance(terminator, ll.Ret): oper = terminator.oper if oper is None: oper_v = None else: oper_v = eval_oper(oper, ssa_env, global_env) + + # TODO + print('Returning {}' + .format(oper_v)) if len(stack_frames) == 0: new_insns = [] new_terminator = None @@ -97,6 +104,7 @@ def terminate(terminator, blocks, stack_frames, ssa_env, global_env, memory): # blocks. clear_block_from_ssa_env(new_insns, ssa_env) + # TODO print('Jumping unconditionally to {}' .format(label))