diff --git a/vyper/venom/basicblock.py b/vyper/venom/basicblock.py index 7e9cc3a737..8b7089c1c7 100644 --- a/vyper/venom/basicblock.py +++ b/vyper/venom/basicblock.py @@ -243,8 +243,8 @@ class IRBasicBlock: %2 = mul %1, 2 is represented as: bb = IRBasicBlock("bb", function) - r1 = bb.add_instruction("add", "%0", "1") - r2 = bb.add_instruction("mul", r1, "2") + r1 = bb.append_inst("add", "%0", "1") + r2 = bb.append_inst("mul", r1, "2") The label of a basic block is used to refer to it from other basic blocks in order to branch to it. @@ -296,19 +296,16 @@ def remove_cfg_out(self, bb: "IRBasicBlock") -> None: def is_reachable(self) -> bool: return len(self.cfg_in) > 0 - def _append_instruction(self, instruction: IRInstruction) -> None: - assert isinstance(instruction, IRInstruction), "instruction must be an IRInstruction" - instruction.parent = self - self.instructions.append(instruction) - - def add_instruction_no_return(self, opcode: str, *args) -> None: + def append_inst_no_ret(self, opcode: str, *args) -> None: inst = IRInstruction(opcode, list(args)) - self._append_instruction(inst) + inst.parent = self + self.instructions.append(inst) - def add_instruction(self, opcode: str, *args) -> IRVariable: + def append_inst(self, opcode: str, *args) -> IRVariable: ret = self.parent.get_next_variable() inst = IRInstruction(opcode, list(args), ret) - self._append_instruction(inst) + inst.parent = self + self.instructions.append(inst) return ret def insert_instruction(self, instruction: IRInstruction, index: int) -> None: diff --git a/vyper/venom/passes/normalization.py b/vyper/venom/passes/normalization.py index b55dd20f23..02ca63efa4 100644 --- a/vyper/venom/passes/normalization.py +++ b/vyper/venom/passes/normalization.py @@ -61,7 +61,7 @@ def _insert_split_basicblock(self, bb: IRBasicBlock, in_bb: IRBasicBlock) -> IRB source = in_bb.label.value target = bb.label.value split_bb = IRBasicBlock(IRLabel(f"{target}_split_{source}"), self.ctx) - split_bb.add_instruction_no_return("jmp", bb.label) + split_bb.append_inst_no_ret("jmp", bb.label) self.ctx.append_basic_block(split_bb) # Rewire the CFG