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

[ir][refactor] Remove the global current_block #908

Merged
merged 1 commit into from
May 1, 2020
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
3 changes: 0 additions & 3 deletions taichi/ir/basic_stmt_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ BasicStmtVisitor::BasicStmtVisitor() {
}

void BasicStmtVisitor::visit(Block *stmt_list) {
auto backup_block = current_block;
current_block = stmt_list;
for (auto &stmt : stmt_list->statements) {
stmt->accept(this);
}
current_block = backup_block;
}

void BasicStmtVisitor::visit(IfStmt *if_stmt) {
Expand Down
2 changes: 0 additions & 2 deletions taichi/ir/ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,6 @@ IRNode *FrontendContext::root() {

std::unique_ptr<FrontendContext> context;

Block *current_block = nullptr;

Expr Var(const Expr &x) {
auto var = Expr(std::make_shared<IdExpression>());
current_ast_builder().insert(std::make_unique<FrontendAllocaStmt>(
Expand Down
4 changes: 0 additions & 4 deletions taichi/ir/ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -1921,10 +1921,6 @@ class RangeAssumptionExpression : public Expression {
}
};

// TODO: fix this hack...
// for current ast
extern Block *current_block;

class IdExpression : public Expression {
public:
Identifier id;
Expand Down
3 changes: 0 additions & 3 deletions taichi/transforms/lower_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ class LowerAccess : public IRVisitor {
}

void visit(Block *stmt_list) override {
auto backup_block = current_block;
current_block = stmt_list;
for (auto &stmt : stmt_list->statements) {
stmt->accept(this);
}
current_block = backup_block;
}

void visit(IfStmt *if_stmt) override {
Expand Down
3 changes: 0 additions & 3 deletions taichi/transforms/statement_replace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ class StatementReplace : public IRVisitor {
}

void visit(Block *stmt_list) override {
auto backup_block = current_block;
current_block = stmt_list;
for (auto &stmt : stmt_list->statements) {
stmt->accept(this);
}
current_block = backup_block;
}

void visit(IfStmt *if_stmt) override {
Expand Down