Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version __loop_cont__ variable #154

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions numba_rvsdg/core/datastructures/ast_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ def transform(
body: MutableSequence[ast.AST] = []
self.region_stack = [scfg.region]
self.scfg = scfg
self.loop_cont_counter = 0
for name, block in scfg.concealed_region_view.items():
if type(block) is RegionBlock and block.kind == "branch":
continue
Expand Down Expand Up @@ -768,14 +769,16 @@ def codegen_view() -> list[Any]:
# A loop region gives rise to a Python while __scfg_loop_cont__
# loop. We recursively visit the body. The exiting latch will
# update __scfg_loop_continue__.
self.loop_cont_counter += 1
loop_continue = f"__scfg_loop_cont_{self.loop_cont_counter}__"
rval = [
ast.Assign(
[ast.Name("__scfg_loop_cont__")],
[ast.Name(loop_continue)],
ast.Constant(True),
lineno=0,
),
ast.While(
test=ast.Name("__scfg_loop_cont__"),
test=ast.Name(loop_continue),
body=codegen_view(),
orelse=[],
),
Expand Down Expand Up @@ -807,9 +810,11 @@ def codegen_view() -> list[Any]:
# the exit variable to '__scfg_loop_cont__'.
assert len(block.jump_targets) == 1
assert len(block.backedges) == 1
loop_continue = f"__scfg_loop_cont_{self.loop_cont_counter}__"
self.loop_cont_counter -= 1
return [
ast.Assign(
[ast.Name("__scfg_loop_cont__")],
[ast.Name(loop_continue)],
ast.UnaryOp(ast.Not(), ast.Name(block.variable)),
lineno=0,
)
Expand Down