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

Remove Break from IR #71

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 0 additions & 6 deletions src/tensora/codegen/_ir_to_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
BooleanLiteral,
BooleanToInteger,
Branch,
Break,
Declaration,
DeclarationAssignment,
Equal,
Expand Down Expand Up @@ -302,11 +301,6 @@ def ir_to_c_loop(self: Loop) -> list[str]:
]


@ir_to_c_statement.register(Break)
def ir_to_c_break(self: Break) -> list[str]:
return ["break;"]


@ir_to_c_statement.register(Return)
def ir_to_c_return(self: Return) -> list[str]:
return [f"return {ir_to_c_expression(self.value)};"]
Expand Down
6 changes: 0 additions & 6 deletions src/tensora/ir/_peephole.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
BooleanLiteral,
BooleanToInteger,
Branch,
Break,
Declaration,
DeclarationAssignment,
Equal,
Expand Down Expand Up @@ -327,11 +326,6 @@ def peephole_loop(self: Loop) -> Statement:
return Loop(condition, body)


@peephole_statement.register(Break)
def peephole_break(self: Break) -> Statement:
return self


@peephole_statement.register(Return)
def peephole_return(self: Return) -> Statement:
value = peephole_expression(self.value)
Expand Down
6 changes: 0 additions & 6 deletions src/tensora/ir/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"Block",
"Branch",
"Loop",
"Break",
"Return",
"FunctionDefinition",
"Module",
Expand Down Expand Up @@ -333,11 +332,6 @@ class Loop(Statement):
body: Statement


@dataclass(frozen=True, slots=True)
class Break(Statement):
pass


@dataclass(frozen=True, slots=True)
class Return(Statement):
value: Expression
Expand Down
2 changes: 0 additions & 2 deletions tests/codegen/test_ast_to_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ def clean(string: str) -> str:
(Assignment(Variable("x"), Subtract(Variable("x"), IntegerLiteral(2))), "x -= 2"),
(Assignment(Variable("x"), Multiply(Variable("x"), IntegerLiteral(2))), "x *= 2"),
(DeclarationAssignment(Declaration(Variable("x"), integer), Variable("y")), "int32_t x = y"),
# Break
(Break(), "break"),
# Return
(Return(IntegerLiteral(0)), "return 0"),
]
Expand Down
1 change: 0 additions & 1 deletion tests/ir/test_peephole.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def test_pass_through_left_right(cls):
GreaterThan(Variable("x"), Variable("y")),
Loop(BooleanLiteral(True), Variable("x")),
Assignment(Variable("x"), ArrayIndex(ArrayIndex(Variable("y"), Variable("i")), Variable("j"))),
Break(),
Declaration(Variable("x"), float),
]

Expand Down