-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor][ir] Simplify ir.h to reduce compile-time (#934)
* try remove statements.h in ir.h * remove visitor re-add * fix * passes & analysis * I believe that expr is frontend * balance ir.cpp and expr.cpp * fix import error * move RangeForStmt and StructForStmt definition to ir.cpp * [skip ci] add comment * [skip ci] enforce code format * [skip ci] passes.h -> transoforms.h * namespace irpass::analysis fix Co-authored-by: Taichi Gardener <taichigardener@gmail.com>
- Loading branch information
1 parent
3b79511
commit e0ef399
Showing
61 changed files
with
599 additions
and
461 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#include "taichi/ir/ir.h" | ||
#include "taichi/ir/analysis.h" | ||
#include "taichi/ir/visitors.h" | ||
|
||
TLANG_NAMESPACE_BEGIN | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#include "taichi/ir/ir.h" | ||
#include "taichi/ir/analysis.h" | ||
#include "taichi/ir/visitors.h" | ||
|
||
TLANG_NAMESPACE_BEGIN | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#include "taichi/ir/ir.h" | ||
#include "taichi/ir/analysis.h" | ||
#include "taichi/ir/visitors.h" | ||
|
||
TLANG_NAMESPACE_BEGIN | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#include "taichi/ir/ir.h" | ||
#include "taichi/ir/analysis.h" | ||
#include "taichi/ir/visitors.h" | ||
|
||
TLANG_NAMESPACE_BEGIN | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#include "taichi/ir/ir.h" | ||
#include "taichi/ir/analysis.h" | ||
#include "taichi/ir/visitors.h" | ||
|
||
TLANG_NAMESPACE_BEGIN | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#pragma once | ||
|
||
#include "taichi/ir/ir.h" | ||
#include <atomic> | ||
#include <unordered_set> | ||
#include <unordered_map> | ||
|
||
TLANG_NAMESPACE_BEGIN | ||
|
||
class DiffRange { | ||
private: | ||
bool related; | ||
|
||
public: | ||
int coeff; | ||
int low, high; | ||
|
||
DiffRange() : DiffRange(false, 0) { | ||
} | ||
|
||
DiffRange(bool related, int coeff) : DiffRange(related, 0, 0) { | ||
TI_ASSERT(related == false); | ||
} | ||
|
||
DiffRange(bool related, int coeff, int low) | ||
: DiffRange(related, coeff, low, low + 1) { | ||
} | ||
|
||
DiffRange(bool related, int coeff, int low, int high) | ||
: related(related), coeff(coeff), low(low), high(high) { | ||
if (!related) { | ||
this->low = this->high = 0; | ||
} | ||
} | ||
|
||
bool related_() const { | ||
return related; | ||
} | ||
|
||
bool linear_related() const { | ||
return related && coeff == 1; | ||
} | ||
|
||
bool certain() { | ||
TI_ASSERT(related); | ||
return high == low + 1; | ||
} | ||
}; | ||
|
||
// IR Analysis | ||
namespace irpass::analysis { | ||
|
||
void check_fields_registered(IRNode *root); | ||
int count_statements(IRNode *root); | ||
std::unordered_set<Stmt *> detect_fors_with_break(IRNode *root); | ||
std::unordered_set<Stmt *> detect_loops_with_continue(IRNode *root); | ||
std::unordered_set<SNode *> gather_deactivations(IRNode *root); | ||
std::vector<Stmt *> gather_statements(IRNode *root, | ||
const std::function<bool(Stmt *)> &test); | ||
std::unique_ptr<std::unordered_set<AtomicOpStmt *>> gather_used_atomics( | ||
IRNode *root); | ||
bool has_store_or_atomic(IRNode *root, const std::vector<Stmt *> &vars); | ||
std::pair<bool, Stmt *> last_store_or_atomic(IRNode *root, Stmt *var); | ||
bool same_statements(IRNode *root1, IRNode *root2); | ||
DiffRange value_diff(Stmt *stmt, int lane, Stmt *alloca); | ||
void verify(IRNode *root); | ||
|
||
} // namespace irpass::analysis | ||
|
||
TLANG_NAMESPACE_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.