From 9ff9f85f1922da4f9d02c113acdd9d826feeced9 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 14 Jul 2015 22:18:38 +0300 Subject: [PATCH] Add accessors to instructions. --- artiq/compiler/ir.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/artiq/compiler/ir.py b/artiq/compiler/ir.py index 7b1c0432c..5f6688759 100644 --- a/artiq/compiler/ir.py +++ b/artiq/compiler/ir.py @@ -383,6 +383,9 @@ class Branch(Terminator): def opcode(self): return "branch" + def target(self): + return self.operands[0] + class BranchIf(Terminator): """ A conditional branch instruction. @@ -399,6 +402,15 @@ class BranchIf(Terminator): def opcode(self): return "branch_if" + def condition(self): + return self.operands[0] + + def if_true(self): + return self.operands[1] + + def if_false(self): + return self.operands[2] + class Return(Terminator): """ A return instruction. @@ -413,6 +425,9 @@ class Return(Terminator): def opcode(self): return "return" + def value(self): + return self.operands[0] + class Eval(Instruction): """ An instruction that evaluates an AST fragment.