Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/polly/lib
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2015-05-20 11:05:31 +0300
committerTobias Grosser <tobias@grosser.es>2015-05-20 11:05:31 +0300
commit49ad36ca1689fdbf88275765c4e5b47e166e9e0f (patch)
tree41c0c4b95d33564a97e540be97ea088d8060162d /polly/lib
parent76190042115da6375c576d693f393cbdf3b1f93f (diff)
Add printing and testing to ScopArrayInfo
Being here, we extend the interface to return the element type and not a pointer to the element type. We also provide a function to get the size (in bytes) of the elements stored in this array. We currently still store the element size as an innermost dimension in ScopArrayInfo, which is somehow inconsistent and should be addressed in future patches. llvm-svn: 237779
Diffstat (limited to 'polly/lib')
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp34
-rw-r--r--polly/lib/CodeGen/IslExprBuilder.cpp4
2 files changed, 26 insertions, 12 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 558da0a55cd2..951dfc79a4d2 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -327,27 +327,31 @@ static __isl_give isl_set *addRangeBoundsToSet(__isl_take isl_set *S,
return isl_set_intersect(SLB, SUB);
}
-ScopArrayInfo::ScopArrayInfo(Value *BasePtr, Type *AccessType, isl_ctx *Ctx,
+ScopArrayInfo::ScopArrayInfo(Value *BasePtr, Type *ElementType, isl_ctx *Ctx,
const SmallVector<const SCEV *, 4> &DimensionSizes)
- : BasePtr(BasePtr), AccessType(AccessType), DimensionSizes(DimensionSizes) {
+ : BasePtr(BasePtr), ElementType(ElementType),
+ DimensionSizes(DimensionSizes) {
const std::string BasePtrName = getIslCompatibleName("MemRef_", BasePtr, "");
Id = isl_id_alloc(Ctx, BasePtrName.c_str(), this);
}
ScopArrayInfo::~ScopArrayInfo() { isl_id_free(Id); }
+std::string ScopArrayInfo::getName() const { return isl_id_get_name(Id); }
+
+int ScopArrayInfo::getElemSizeInBytes() const {
+ return ElementType->getPrimitiveSizeInBits() / 8;
+}
+
isl_id *ScopArrayInfo::getBasePtrId() const { return isl_id_copy(Id); }
void ScopArrayInfo::dump() const { print(errs()); }
void ScopArrayInfo::print(raw_ostream &OS) const {
- OS << "ScopArrayInfo:\n";
- OS << " Base: " << *getBasePtr() << "\n";
- OS << " Type: " << *getType() << "\n";
- OS << " Dimension Sizes:\n";
+ OS.indent(8) << *getElementType() << " " << getName() << "[*]";
for (unsigned u = 0; u < getNumberOfDimensions(); u++)
- OS << " " << u << ") " << *DimensionSizes[u] << "\n";
- OS << "\n";
+ OS << "[" << *DimensionSizes[u] << "]";
+ OS << " // Element size " << getElemSizeInBytes() << "\n";
}
const ScopArrayInfo *
@@ -879,9 +883,9 @@ void ScopStmt::buildAccesses(TempScop &tempScop, BasicBlock *Block,
IRAccess &Access = AccessPair.first;
Instruction *AccessInst = AccessPair.second;
- Type *AccessType = getAccessInstType(AccessInst)->getPointerTo();
+ Type *ElementType = getAccessInstType(AccessInst);
const ScopArrayInfo *SAI = getParent()->getOrCreateScopArrayInfo(
- Access.getBase(), AccessType, Access.Sizes);
+ Access.getBase(), ElementType, Access.Sizes);
if (isApproximated && Access.isWrite())
Access.setMayWrite();
@@ -1843,12 +1847,22 @@ void Scop::printStatements(raw_ostream &OS) const {
OS.indent(4) << "}\n";
}
+void Scop::printArrayInfo(raw_ostream &OS) const {
+ OS << "Arrays {\n";
+
+ for (auto Array : arrays())
+ Array.second->print(OS);
+
+ OS.indent(4) << "}\n";
+}
+
void Scop::print(raw_ostream &OS) const {
OS.indent(4) << "Function: " << getRegion().getEntry()->getParent()->getName()
<< "\n";
OS.indent(4) << "Region: " << getNameStr() << "\n";
OS.indent(4) << "Max Loop Depth: " << getMaxLoopDepth() << "\n";
printContext(OS.indent(4));
+ printArrayInfo(OS.indent(4));
printAliasAssumptions(OS);
printStatements(OS.indent(4));
}
diff --git a/polly/lib/CodeGen/IslExprBuilder.cpp b/polly/lib/CodeGen/IslExprBuilder.cpp
index 8cd145ca7c18..ed2641fbd2df 100644
--- a/polly/lib/CodeGen/IslExprBuilder.cpp
+++ b/polly/lib/CodeGen/IslExprBuilder.cpp
@@ -115,8 +115,8 @@ Value *IslExprBuilder::createAccessAddress(isl_ast_expr *Expr) {
assert(Base->getType()->isPointerTy() && "Access base should be a pointer");
StringRef BaseName = Base->getName();
- if (Base->getType() != SAI->getType())
- Base = Builder.CreateBitCast(Base, SAI->getType(),
+ if (Base->getType() != SAI->getElementType()->getPointerTo())
+ Base = Builder.CreateBitCast(Base, SAI->getElementType()->getPointerTo(),
"polly.access.cast." + BaseName);
IndexOp = nullptr;