Skip to content

Commit

Permalink
add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Dec 1, 2023
1 parent f596312 commit febd073
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion vyper/venom/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ def append_data(self, opcode: str, args: list[IROperand]) -> None:
@property
def normalized(self) -> bool:
"""
Check if function is normalized.
Check if function is normalized. A function is normalized if in the
CFG, no basic block simultaneously has multiple inputs and outputs.
That is, a basic block can be jumped to *from* multiple blocks, or it
can jump *to* multiple blocks, but it cannot simultaneously do both.
Having a normalized CFG makes calculation of stack layout easier when
emitting assembly.
"""
for bb in self.basic_blocks:
# Ignore if there are no multiple predecessors
Expand All @@ -127,6 +132,12 @@ def normalized(self) -> bool:

# Check if there is a conditional jump at the end
# of one of the predecessors
#
# TODO: this check could be:
# `if len(in_bb.cfg_out) > 1: return False`
# but the cfg is currently not calculated "correctly" for
# certain special instructions (deploy instruction and
# selector table indirect jumps).
for in_bb in bb.cfg_in:
jump_inst = in_bb.instructions[-1]
if jump_inst.opcode != "jnz":
Expand Down

0 comments on commit febd073

Please sign in to comment.