Skip to content
Closed
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
17 changes: 11 additions & 6 deletions python/flydsl/compiler/ast_rewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,22 @@ def rewrite_globals(cls):
"scf_if_dispatch": cls.scf_if_dispatch,
}

_REWRITE_HELPER_NAMES = {"dsl_not_", "dsl_and_", "dsl_or_",
"scf_if_dispatch", "const_expr", "type",
"bool", "isinstance", "hasattr"}
_REWRITE_HELPER_NAMES = {
"scf_if_dispatch",
"const_expr",
"type",
"bool",
"isinstance",
"hasattr",
}

@staticmethod
def _could_be_dynamic(test_node):
"""Check if an if-condition AST could produce an MLIR Value at runtime.

Calls to RewriteBoolOps helpers (dsl_not_, dsl_and_, dsl_or_) and
Python builtins are NOT considered dynamic they just wrap Python-level
boolean logic. Only calls to user/MLIR functions can produce Values.
Calls to Python builtins are NOT considered dynamic. BoolOp helpers like
dsl_and_/dsl_or_ may still produce dynamic predicates, so they should
not be filtered out here.
"""
for child in ast.walk(test_node):
if isinstance(child, ast.Call):
Expand Down
Loading