mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-03 16:03:21 +00:00
[Refactor] C++11 Memory access iterators in SCoP stmts
+ Added const iterator version + Changed name to begin/end to allow range loops + Changed call sites to range loops + Changed typename to (const_)iterator llvm-svn: 210927
This commit is contained in:
parent
fdd9f2b23d
commit
f675289d87
@ -354,9 +354,13 @@ public:
|
||||
|
||||
void setBasicBlock(BasicBlock *Block) { BB = Block; }
|
||||
|
||||
typedef MemoryAccessVec::iterator memacc_iterator;
|
||||
memacc_iterator memacc_begin() { return MemAccs.begin(); }
|
||||
memacc_iterator memacc_end() { return MemAccs.end(); }
|
||||
typedef MemoryAccessVec::iterator iterator;
|
||||
typedef MemoryAccessVec::const_iterator const_iterator;
|
||||
|
||||
iterator begin() { return MemAccs.begin(); }
|
||||
iterator end() { return MemAccs.end(); }
|
||||
const_iterator begin() const { return MemAccs.begin(); }
|
||||
const_iterator end() const { return MemAccs.end(); }
|
||||
|
||||
unsigned getNumParams() const;
|
||||
unsigned getNumIterators() const;
|
||||
|
@ -77,15 +77,13 @@ void Dependences::collectInfo(Scop &S, isl_union_map **Read,
|
||||
*Schedule = isl_union_map_empty(Space);
|
||||
|
||||
for (ScopStmt *Stmt : S) {
|
||||
for (ScopStmt::memacc_iterator MI = Stmt->memacc_begin(),
|
||||
ME = Stmt->memacc_end();
|
||||
MI != ME; ++MI) {
|
||||
for (MemoryAccess *MA : *Stmt) {
|
||||
isl_set *domcp = Stmt->getDomain();
|
||||
isl_map *accdom = (*MI)->getAccessRelation();
|
||||
isl_map *accdom = MA->getAccessRelation();
|
||||
|
||||
accdom = isl_map_intersect_domain(accdom, domcp);
|
||||
|
||||
if ((*MI)->isRead())
|
||||
if (MA->isRead())
|
||||
*Read = isl_union_map_add_map(*Read, accdom);
|
||||
else
|
||||
*Write = isl_union_map_add_map(*Write, accdom);
|
||||
|
@ -567,8 +567,8 @@ void ScopStmt::buildAccesses(TempScop &tempScop, const Region &CurRegion) {
|
||||
}
|
||||
|
||||
void ScopStmt::realignParams() {
|
||||
for (memacc_iterator MI = memacc_begin(), ME = memacc_end(); MI != ME; ++MI)
|
||||
(*MI)->realignParams();
|
||||
for (MemoryAccess *MA : *this)
|
||||
MA->realignParams();
|
||||
|
||||
Domain = isl_set_align_params(Domain, Parent.getParamSpace());
|
||||
Scattering = isl_map_align_params(Scattering, Parent.getParamSpace());
|
||||
@ -988,14 +988,12 @@ __isl_give isl_union_map *Scop::getWrites() {
|
||||
for (Scop::iterator SI = this->begin(), SE = this->end(); SI != SE; ++SI) {
|
||||
ScopStmt *Stmt = *SI;
|
||||
|
||||
for (ScopStmt::memacc_iterator MI = Stmt->memacc_begin(),
|
||||
ME = Stmt->memacc_end();
|
||||
MI != ME; ++MI) {
|
||||
if (!(*MI)->isWrite())
|
||||
for (MemoryAccess *MA : *Stmt) {
|
||||
if (!MA->isWrite())
|
||||
continue;
|
||||
|
||||
isl_set *Domain = Stmt->getDomain();
|
||||
isl_map *AccessDomain = (*MI)->getAccessRelation();
|
||||
isl_map *AccessDomain = MA->getAccessRelation();
|
||||
|
||||
AccessDomain = isl_map_intersect_domain(AccessDomain, Domain);
|
||||
Write = isl_union_map_add_map(Write, AccessDomain);
|
||||
@ -1010,14 +1008,12 @@ __isl_give isl_union_map *Scop::getReads() {
|
||||
for (Scop::iterator SI = this->begin(), SE = this->end(); SI != SE; ++SI) {
|
||||
ScopStmt *Stmt = *SI;
|
||||
|
||||
for (ScopStmt::memacc_iterator MI = Stmt->memacc_begin(),
|
||||
ME = Stmt->memacc_end();
|
||||
MI != ME; ++MI) {
|
||||
if (!(*MI)->isRead())
|
||||
for (MemoryAccess *MA : *Stmt) {
|
||||
if (!MA->isRead())
|
||||
continue;
|
||||
|
||||
isl_set *Domain = Stmt->getDomain();
|
||||
isl_map *AccessDomain = (*MI)->getAccessRelation();
|
||||
isl_map *AccessDomain = MA->getAccessRelation();
|
||||
|
||||
AccessDomain = isl_map_intersect_domain(AccessDomain, Domain);
|
||||
Read = isl_union_map_add_map(Read, AccessDomain);
|
||||
|
@ -104,13 +104,11 @@ Json::Value JSONExporter::getJSON(Scop &scop) const {
|
||||
statement["schedule"] = Stmt->getScatteringStr();
|
||||
statement["accesses"];
|
||||
|
||||
for (ScopStmt::memacc_iterator MI = Stmt->memacc_begin(),
|
||||
ME = Stmt->memacc_end();
|
||||
MI != ME; ++MI) {
|
||||
for (MemoryAccess *MA : *Stmt) {
|
||||
Json::Value access;
|
||||
|
||||
access["kind"] = (*MI)->isRead() ? "read" : "write";
|
||||
access["relation"] = (*MI)->getAccessRelationStr();
|
||||
access["kind"] = MA->isRead() ? "read" : "write";
|
||||
access["relation"] = MA->getAccessRelationStr();
|
||||
|
||||
statement["accesses"].append(access);
|
||||
}
|
||||
@ -263,14 +261,12 @@ bool JSONImporter::runOnScop(Scop &scop) {
|
||||
ScopStmt *Stmt = *SI;
|
||||
|
||||
int memoryAccessIdx = 0;
|
||||
for (ScopStmt::memacc_iterator MI = Stmt->memacc_begin(),
|
||||
ME = Stmt->memacc_end();
|
||||
MI != ME; ++MI) {
|
||||
for (MemoryAccess *MA : *Stmt) {
|
||||
Json::Value accesses = jscop["statements"][statementIdx]["accesses"]
|
||||
[memoryAccessIdx]["relation"];
|
||||
isl_map *newAccessMap =
|
||||
isl_map_read_from_str(S->getIslCtx(), accesses.asCString());
|
||||
isl_map *currentAccessMap = (*MI)->getAccessRelation();
|
||||
isl_map *currentAccessMap = MA->getAccessRelation();
|
||||
|
||||
if (isl_map_dim(newAccessMap, isl_dim_param) !=
|
||||
isl_map_dim(currentAccessMap, isl_dim_param)) {
|
||||
@ -311,7 +307,7 @@ bool JSONImporter::runOnScop(Scop &scop) {
|
||||
// Statistics.
|
||||
++NewAccessMapFound;
|
||||
newAccessStrings.push_back(accesses.asCString());
|
||||
(*MI)->setNewAccessRelation(newAccessMap);
|
||||
MA->setNewAccessRelation(newAccessMap);
|
||||
} else {
|
||||
isl_map_free(newAccessMap);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user