Skip to content

Commit

Permalink
[ir] [refactor] Remove the global current_block (#908)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-ye committed May 1, 2020
1 parent eef5139 commit f5373b1
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 15 deletions.
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

0 comments on commit f5373b1

Please sign in to comment.