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

[Lang] Support continue on all backends #716

Merged
merged 7 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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: 11 additions & 0 deletions taichi/ir/ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <unordered_map>

#include "taichi/ir/frontend.h"
#include "taichi/ir/statements.h"

TLANG_NAMESPACE_BEGIN

Expand Down Expand Up @@ -546,4 +547,14 @@ std::string OffloadedStmt::task_type_name(TaskType tt) {
return m.find(tt)->second;
}

bool ContinueStmt::as_return() const {
TI_ASSERT(scope != nullptr);
if (auto *offl = scope->cast<OffloadedStmt>(); offl) {
TI_ASSERT(offl->task_type == OffloadedStmt::TaskType::range_for ||
offl->task_type == OffloadedStmt::TaskType::struct_for);
return true;
}
return false;
}

TLANG_NAMESPACE_END
5 changes: 2 additions & 3 deletions taichi/ir/ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -951,9 +951,8 @@ class ContinueStmt : public Stmt {
TI_STMT_REG_FIELDS;
}

bool as_return() const {
return scope->is<OffloadedStmt>();
}
bool as_return() const;

TI_STMT_DEF_FIELDS(scope);
DEFINE_ACCEPT;
};
Expand Down
2 changes: 1 addition & 1 deletion taichi/transforms/ir_printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class IRPrinter : public IRVisitor {

void visit(ContinueStmt *stmt) override {
if (stmt->scope) {
print("{} continue (as_return={})", stmt->name(), stmt->as_return());
print("{} continue (scope={})", stmt->name(), stmt->name());
k-ye marked this conversation as resolved.
Show resolved Hide resolved
} else {
print("{} continue", stmt->name());
}
Expand Down