Polly 20.0.0git
|
A class to store information about arrays in the SCoP. More...
#include <ScopInfo.h>
Public Member Functions | |
ScopArrayInfo (Value *BasePtr, Type *ElementType, isl::ctx IslCtx, ArrayRef< const SCEV * > DimensionSizes, MemoryKind Kind, const DataLayout &DL, Scop *S, const char *BaseName=nullptr) | |
Construct a ScopArrayInfo object. | |
~ScopArrayInfo () | |
Destructor to free the isl id of the base pointer. | |
void | updateElementType (Type *NewElementType) |
Update the element type of the ScopArrayInfo object. | |
bool | updateSizes (ArrayRef< const SCEV * > Sizes, bool CheckConsistency=true) |
Update the sizes of the ScopArrayInfo object. | |
void | setBasePtr (Value *BP) |
Set the base pointer to BP . | |
Value * | getBasePtr () const |
Return the base pointer. | |
void | setIsOnHeap (bool value) |
const ScopArrayInfo * | getBasePtrOriginSAI () const |
For indirect accesses return the origin SAI of the BP, else null. | |
const SmallSetVector< ScopArrayInfo *, 2 > & | getDerivedSAIs () const |
The set of derived indirect SAIs for this origin SAI. | |
unsigned | getNumberOfDimensions () const |
Return the number of dimensions. | |
const SCEV * | getDimensionSize (unsigned Dim) const |
Return the size of dimension dim as SCEV*. | |
isl::pw_aff | getDimensionSizePw (unsigned Dim) const |
Return the size of dimension dim as isl::pw_aff. | |
Type * | getElementType () const |
Get the canonical element type of this array. | |
int | getElemSizeInBytes () const |
Get element size in bytes. | |
std::string | getName () const |
Get the name of this memory reference. | |
isl::id | getBasePtrId () const |
Return the isl id for the base pointer. | |
MemoryKind | getKind () const |
Return what kind of memory this represents. | |
bool | isValueKind () const |
Is this array info modeling an llvm::Value? | |
bool | isPHIKind () const |
Is this array info modeling special PHI node memory? | |
bool | isExitPHIKind () const |
Is this array info modeling an MemoryKind::ExitPHI? | |
bool | isArrayKind () const |
Is this array info modeling an array? | |
bool | isOnHeap () const |
Is this array allocated on heap. | |
void | dump () const |
Dump a readable representation to stderr. | |
void | print (raw_ostream &OS, bool SizeAsPwAff=false) const |
Print a readable representation to OS . | |
isl::space | getSpace () const |
Get the space of this array access. | |
bool | isReadOnly () |
If the array is read only. | |
bool | isCompatibleWith (const ScopArrayInfo *Array) const |
Verify that Array is compatible to this ScopArrayInfo. | |
Static Public Member Functions | |
static const ScopArrayInfo * | getFromAccessFunction (isl::pw_multi_aff PMA) |
Access the ScopArrayInfo associated with an access function. | |
static const ScopArrayInfo * | getFromId (isl::id Id) |
Access the ScopArrayInfo associated with an isl Id. | |
Private Member Functions | |
void | addDerivedSAI (ScopArrayInfo *DerivedSAI) |
Private Attributes | |
const ScopArrayInfo * | BasePtrOriginSAI |
For indirect accesses this is the SAI of the BP origin. | |
SmallSetVector< ScopArrayInfo *, 2 > | DerivedSAIs |
For origin SAIs the set of derived indirect SAIs. | |
AssertingVH< Value > | BasePtr |
The base pointer. | |
Type * | ElementType |
The canonical element type of this array. | |
isl::id | Id |
The isl id for the base pointer. | |
bool | IsOnHeap = false |
True if the newly allocated array is on heap. | |
SmallVector< const SCEV *, 4 > | DimensionSizes |
The sizes of each dimension as SCEV*. | |
SmallVector< isl::pw_aff, 4 > | DimensionSizesPw |
The sizes of each dimension as isl::pw_aff. | |
MemoryKind | Kind |
The type of this scop array info object. | |
const DataLayout & | DL |
The data layout of the module. | |
Scop & | S |
The scop this SAI object belongs to. | |
A class to store information about arrays in the SCoP.
Objects are accessible via the ScoP, MemoryAccess or the id associated with the MemoryAccess access function.
Definition at line 219 of file ScopInfo.h.
ScopArrayInfo::ScopArrayInfo | ( | Value * | BasePtr, |
Type * | ElementType, | ||
isl::ctx | IslCtx, | ||
ArrayRef< const SCEV * > | DimensionSizes, | ||
MemoryKind | Kind, | ||
const DataLayout & | DL, | ||
Scop * | S, | ||
const char * | BaseName = nullptr |
||
) |
Construct a ScopArrayInfo object.
BasePtr | The array base pointer. |
ElementType | The type of the elements stored in the array. |
IslCtx | The isl context used to create the base pointer id. |
DimensionSizes | A vector containing the size of each dimension. |
Kind | The kind of the array object. |
DL | The data layout of the module. |
S | The scop this array object belongs to. |
BaseName | The optional name of this memory reference. |
Definition at line 231 of file ScopInfo.cpp.
References addDerivedSAI(), isl::id::alloc(), polly::Array, BasePtr, BasePtrOriginSAI, Ctx, polly::getIslCompatibleName(), Id, identifyBasePtrOriginSAI(), polly::PHI, updateSizes(), and polly::UseInstructionNames.
|
default |
Destructor to free the isl id of the base pointer.
|
inlineprivate |
LLVM_DUMP_METHOD void ScopArrayInfo::dump | ( | ) | const |
Dump a readable representation to stderr.
Definition at line 345 of file ScopInfo.cpp.
References print().
|
inline |
Return the base pointer.
Definition at line 266 of file ScopInfo.h.
References BasePtr, and polly::Value.
Referenced by polly::ZoneAlgorithm::computePerPHI(), polly::IslExprBuilder::createAccessAddress(), polly::Scop::getPHIRead(), and polly::Scop::getValueDef().
isl::id ScopArrayInfo::getBasePtrId | ( | ) | const |
Return the isl id for the base pointer.
Definition at line 342 of file ScopInfo.cpp.
References Id.
Referenced by polly::MemoryAccess::buildAccessRelation(), polly::MemoryAccess::foldAccessRelation(), and replaceBasePtrArrays().
|
inline |
For indirect accesses return the origin SAI of the BP, else null.
Definition at line 272 of file ScopInfo.h.
References BasePtrOriginSAI.
Referenced by buildCondition().
|
inline |
The set of derived indirect SAIs for this origin SAI.
Definition at line 275 of file ScopInfo.h.
References DerivedSAIs.
|
inline |
Return the size of dimension dim
as SCEV*.
Definition at line 292 of file ScopInfo.h.
References assert, DimensionSizes, and getNumberOfDimensions().
Referenced by areArraysEqual(), polly::IslExprBuilder::createAccessAddress(), isCompatibleWith(), and print().
|
inline |
Return the size of dimension dim
as isl::pw_aff.
Definition at line 302 of file ScopInfo.h.
References assert, DimensionSizesPw, and getNumberOfDimensions().
Referenced by print().
|
inline |
Get the canonical element type of this array.
Definition at line 310 of file ScopInfo.h.
References ElementType.
Referenced by areArraysEqual(), polly::IslExprBuilder::createAccessAddress(), polly::ZoneAlgorithm::getWrittenValue(), isCompatibleWith(), and print().
int ScopArrayInfo::getElemSizeInBytes | ( | ) | const |
Get element size in bytes.
Definition at line 338 of file ScopInfo.cpp.
References DL, and ElementType.
Referenced by print(), and polly::MemoryAccess::updateDimensionality().
|
static |
Access the ScopArrayInfo associated with an access function.
Definition at line 378 of file ScopInfo.cpp.
References assert, isl::pw_multi_aff::get_tuple_id(), getFromId(), Id, isl::id::is_null(), and isl::out.
|
static |
Access the ScopArrayInfo associated with an isl Id.
Definition at line 384 of file ScopInfo.cpp.
References isl::id::get_user(), and Id.
Referenced by buildCondition(), polly::IslExprBuilder::createAccessAddress(), getFromAccessFunction(), importAccesses(), and polly::MemoryAccess::MemoryAccess().
|
inline |
Return what kind of memory this represents.
Definition at line 322 of file ScopInfo.h.
References Kind.
Referenced by polly::MemoryAccess::getLatestKind().
std::string ScopArrayInfo::getName | ( | ) | const |
Get the name of this memory reference.
Definition at line 336 of file ScopInfo.cpp.
References isl::id::get_name(), and Id.
Referenced by areArraysEqual(), and print().
|
inline |
Return the number of dimensions.
Definition at line 280 of file ScopInfo.h.
References DimensionSizes, polly::ExitPHI, polly::PHI, and polly::Value.
Referenced by areArraysEqual(), getDimensionSize(), getDimensionSizePw(), getSpace(), isCompatibleWith(), and print().
isl::space ScopArrayInfo::getSpace | ( | ) | const |
Get the space of this array access.
Definition at line 257 of file ScopInfo.cpp.
References isl::id::ctx(), getNumberOfDimensions(), Id, and isl::set.
Referenced by isReadOnly().
|
inline |
Is this array info modeling an array?
Definition at line 343 of file ScopInfo.h.
References polly::Array.
bool ScopArrayInfo::isCompatibleWith | ( | const ScopArrayInfo * | Array | ) | const |
Verify that Array
is compatible to this ScopArrayInfo.
Two arrays are compatible if their dimensionality, the sizes of their dimensions, and their element sizes match.
Array | The array to compare against. |
Definition at line 271 of file ScopInfo.cpp.
References polly::Array, getDimensionSize(), getElementType(), and getNumberOfDimensions().
Referenced by polly::ScopBuilder::canonicalizeDynamicBasePtrs().
|
inline |
Is this array info modeling an MemoryKind::ExitPHI?
Definition at line 340 of file ScopInfo.h.
References polly::ExitPHI.
Referenced by polly::Scop::getPHIIncomings(), and polly::Scop::getPHIRead().
|
inline |
Is this array allocated on heap.
This property is only relevant if the array is allocated by Polly instead of pre-existing. If false, it is allocated using alloca instead malloca.
Definition at line 349 of file ScopInfo.h.
References IsOnHeap.
|
inline |
Is this array info modeling special PHI node memory?
During code generation of PHI nodes, there is a need for two kinds of virtual storage. The normal one as it is used for all scalar dependences, where the result of the PHI node is stored and later loaded from as well as a second one where the incoming values of the PHI nodes are stored into and reloaded when the PHI is executed. As both memories use the original PHI node as virtual base pointer, we have this additional attribute to distinguish the PHI node specific array modeling from the normal scalar array modeling.
Definition at line 337 of file ScopInfo.h.
References polly::PHI.
Referenced by polly::ZoneAlgorithm::computePerPHI(), polly::Scop::getPHIIncomings(), and polly::Scop::getPHIRead().
bool ScopArrayInfo::isReadOnly | ( | ) |
If the array is read only.
Definition at line 263 of file ScopInfo.cpp.
References isl::union_set::extract_set(), getSpace(), and isl::union_set::is_empty().
|
inline |
Is this array info modeling an llvm::Value?
Definition at line 325 of file ScopInfo.h.
References polly::Value.
Referenced by polly::Scop::getValueDef(), and polly::Scop::getValueUses().
void ScopArrayInfo::print | ( | raw_ostream & | OS, |
bool | SizeAsPwAff = false |
||
) | const |
Print a readable representation to OS
.
SizeAsPwAff | Print the size as isl::pw_aff |
Definition at line 348 of file ScopInfo.cpp.
References BasePtrOriginSAI, getDimensionSize(), getDimensionSizePw(), getElementType(), getElemSizeInBytes(), getName(), and getNumberOfDimensions().
Referenced by dump().
|
inline |
|
inline |
Definition at line 269 of file ScopInfo.h.
References IsOnHeap.
void ScopArrayInfo::updateElementType | ( | Type * | NewElementType | ) |
Update the element type of the ScopArrayInfo object.
Memory accesses referencing this ScopArrayInfo object may use different element sizes. This function ensures the canonical element type stored is small enough to model accesses to the current element type as well as to NewElementType
.
NewElementType | An element type that is used to access this array. |
Definition at line 285 of file ScopInfo.cpp.
References DL, and ElementType.
bool ScopArrayInfo::updateSizes | ( | ArrayRef< const SCEV * > | Sizes, |
bool | CheckConsistency = true |
||
) |
Update the sizes of the ScopArrayInfo object.
A ScopArrayInfo object may be created without all outer dimensions being available. This function is called when new memory accesses are added for this ScopArrayInfo object. It verifies that sizes are compatible and adds additional outer array dimensions, if needed.
Sizes | A vector of array sizes where the rightmost array sizes need to match the innermost array sizes already defined in SAI. |
CheckConsistency | Update sizes, even if new sizes are inconsistent with old sizes |
Definition at line 303 of file ScopInfo.cpp.
References DimensionSizes, and DimensionSizesPw.
Referenced by ScopArrayInfo().
|
private |
The base pointer.
Definition at line 395 of file ScopInfo.h.
Referenced by getBasePtr(), ScopArrayInfo(), and setBasePtr().
|
private |
For indirect accesses this is the SAI of the BP origin.
Definition at line 389 of file ScopInfo.h.
Referenced by getBasePtrOriginSAI(), print(), and ScopArrayInfo().
|
private |
For origin SAIs the set of derived indirect SAIs.
Definition at line 392 of file ScopInfo.h.
Referenced by addDerivedSAI(), and getDerivedSAIs().
|
private |
The sizes of each dimension as SCEV*.
Definition at line 413 of file ScopInfo.h.
Referenced by getDimensionSize(), getNumberOfDimensions(), and updateSizes().
|
private |
The sizes of each dimension as isl::pw_aff.
Definition at line 416 of file ScopInfo.h.
Referenced by getDimensionSizePw(), and updateSizes().
|
private |
The data layout of the module.
Definition at line 424 of file ScopInfo.h.
Referenced by getElemSizeInBytes(), and updateElementType().
|
private |
The canonical element type of this array.
The canonical element type describes the minimal accessible element in this array. Not all elements accessed, need to be of the very same type, but the allocation size of the type of the elements loaded/stored from/to this array needs to be a multiple of the allocation size of the canonical type.
Definition at line 404 of file ScopInfo.h.
Referenced by getElementType(), getElemSizeInBytes(), and updateElementType().
|
private |
The isl id for the base pointer.
Definition at line 407 of file ScopInfo.h.
Referenced by getBasePtrId(), getFromAccessFunction(), getFromId(), getName(), getSpace(), and ScopArrayInfo().
|
private |
True if the newly allocated array is on heap.
Definition at line 410 of file ScopInfo.h.
Referenced by isOnHeap(), and setIsOnHeap().
|
private |
The type of this scop array info object.
We distinguish between SCALAR, PHI and ARRAY objects.
Definition at line 421 of file ScopInfo.h.
Referenced by getKind().
|
private |
The scop this SAI object belongs to.
Definition at line 427 of file ScopInfo.h.