Polly 19.0.0git
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
polly::ScopArrayInfo Class Referencefinal

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 ScopArrayInfogetBasePtrOriginSAI () 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 ScopArrayInfogetFromAccessFunction (isl::pw_multi_aff PMA)
 Access the ScopArrayInfo associated with an access function.
 
static const ScopArrayInfogetFromId (isl::id Id)
 Access the ScopArrayInfo associated with an isl Id.
 

Private Member Functions

void addDerivedSAI (ScopArrayInfo *DerivedSAI)
 

Private Attributes

const ScopArrayInfoBasePtrOriginSAI
 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.
 
ScopS
 The scop this SAI object belongs to.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ScopArrayInfo()

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.

Parameters
BasePtrThe array base pointer.
ElementTypeThe type of the elements stored in the array.
IslCtxThe isl context used to create the base pointer id.
DimensionSizesA vector containing the size of each dimension.
KindThe kind of the array object.
DLThe data layout of the module.
SThe scop this array object belongs to.
BaseNameThe 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.

◆ ~ScopArrayInfo()

ScopArrayInfo::~ScopArrayInfo ( )
default

Destructor to free the isl id of the base pointer.

Member Function Documentation

◆ addDerivedSAI()

void polly::ScopArrayInfo::addDerivedSAI ( ScopArrayInfo DerivedSAI)
inlineprivate

Definition at line 384 of file ScopInfo.h.

References DerivedSAIs.

Referenced by ScopArrayInfo().

◆ dump()

LLVM_DUMP_METHOD void ScopArrayInfo::dump ( ) const

Dump a readable representation to stderr.

Definition at line 345 of file ScopInfo.cpp.

References print().

◆ getBasePtr()

Value * polly::ScopArrayInfo::getBasePtr ( ) const
inline

◆ getBasePtrId()

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().

◆ getBasePtrOriginSAI()

const ScopArrayInfo * polly::ScopArrayInfo::getBasePtrOriginSAI ( ) const
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().

◆ getDerivedSAIs()

const SmallSetVector< ScopArrayInfo *, 2 > & polly::ScopArrayInfo::getDerivedSAIs ( ) const
inline

The set of derived indirect SAIs for this origin SAI.

Definition at line 275 of file ScopInfo.h.

References DerivedSAIs.

◆ getDimensionSize()

const SCEV * polly::ScopArrayInfo::getDimensionSize ( unsigned  Dim) const
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().

◆ getDimensionSizePw()

isl::pw_aff polly::ScopArrayInfo::getDimensionSizePw ( unsigned  Dim) const
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().

◆ getElementType()

Type * polly::ScopArrayInfo::getElementType ( ) const
inline

Get the canonical element type of this array.

Returns
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().

◆ getElemSizeInBytes()

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().

◆ getFromAccessFunction()

const ScopArrayInfo * ScopArrayInfo::getFromAccessFunction ( isl::pw_multi_aff  PMA)
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.

◆ getFromId()

const ScopArrayInfo * ScopArrayInfo::getFromId ( isl::id  Id)
static

◆ getKind()

MemoryKind polly::ScopArrayInfo::getKind ( ) const
inline

Return what kind of memory this represents.

Definition at line 322 of file ScopInfo.h.

References Kind.

Referenced by polly::MemoryAccess::getLatestKind().

◆ getName()

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().

◆ getNumberOfDimensions()

unsigned polly::ScopArrayInfo::getNumberOfDimensions ( ) const
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().

◆ getSpace()

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().

◆ isArrayKind()

bool polly::ScopArrayInfo::isArrayKind ( ) const
inline

Is this array info modeling an array?

Definition at line 343 of file ScopInfo.h.

References polly::Array.

◆ isCompatibleWith()

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.

Parameters
ArrayThe array to compare against.
Returns
True, if the arrays are compatible, False otherwise.

Definition at line 271 of file ScopInfo.cpp.

References polly::Array, getDimensionSize(), getElementType(), and getNumberOfDimensions().

Referenced by polly::ScopBuilder::canonicalizeDynamicBasePtrs().

◆ isExitPHIKind()

bool polly::ScopArrayInfo::isExitPHIKind ( ) const
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().

◆ isOnHeap()

bool polly::ScopArrayInfo::isOnHeap ( ) const
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.

◆ isPHIKind()

bool polly::ScopArrayInfo::isPHIKind ( ) const
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().

◆ isReadOnly()

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().

◆ isValueKind()

bool polly::ScopArrayInfo::isValueKind ( ) const
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().

◆ print()

void ScopArrayInfo::print ( raw_ostream &  OS,
bool  SizeAsPwAff = false 
) const

Print a readable representation to OS.

Parameters
SizeAsPwAffPrint 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().

◆ setBasePtr()

void polly::ScopArrayInfo::setBasePtr ( Value *  BP)
inline

Set the base pointer to BP.

Definition at line 263 of file ScopInfo.h.

References BasePtr.

◆ setIsOnHeap()

void polly::ScopArrayInfo::setIsOnHeap ( bool  value)
inline

Definition at line 269 of file ScopInfo.h.

References IsOnHeap.

◆ updateElementType()

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.

Parameters
NewElementTypeAn element type that is used to access this array.

Definition at line 285 of file ScopInfo.cpp.

References DL, and ElementType.

◆ updateSizes()

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.

Parameters
SizesA vector of array sizes where the rightmost array sizes need to match the innermost array sizes already defined in SAI.
CheckConsistencyUpdate 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().

Member Data Documentation

◆ BasePtr

AssertingVH<Value> polly::ScopArrayInfo::BasePtr
private

The base pointer.

Definition at line 395 of file ScopInfo.h.

Referenced by getBasePtr(), ScopArrayInfo(), and setBasePtr().

◆ BasePtrOriginSAI

const ScopArrayInfo* polly::ScopArrayInfo::BasePtrOriginSAI
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().

◆ DerivedSAIs

SmallSetVector<ScopArrayInfo *, 2> polly::ScopArrayInfo::DerivedSAIs
private

For origin SAIs the set of derived indirect SAIs.

Definition at line 392 of file ScopInfo.h.

Referenced by addDerivedSAI(), and getDerivedSAIs().

◆ DimensionSizes

SmallVector<const SCEV *, 4> polly::ScopArrayInfo::DimensionSizes
private

The sizes of each dimension as SCEV*.

Definition at line 413 of file ScopInfo.h.

Referenced by getDimensionSize(), getNumberOfDimensions(), and updateSizes().

◆ DimensionSizesPw

SmallVector<isl::pw_aff, 4> polly::ScopArrayInfo::DimensionSizesPw
private

The sizes of each dimension as isl::pw_aff.

Definition at line 416 of file ScopInfo.h.

Referenced by getDimensionSizePw(), and updateSizes().

◆ DL

const DataLayout& polly::ScopArrayInfo::DL
private

The data layout of the module.

Definition at line 424 of file ScopInfo.h.

Referenced by getElemSizeInBytes(), and updateElementType().

◆ ElementType

Type* polly::ScopArrayInfo::ElementType
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().

◆ Id

isl::id polly::ScopArrayInfo::Id
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().

◆ IsOnHeap

bool polly::ScopArrayInfo::IsOnHeap = false
private

True if the newly allocated array is on heap.

Definition at line 410 of file ScopInfo.h.

Referenced by isOnHeap(), and setIsOnHeap().

◆ Kind

MemoryKind polly::ScopArrayInfo::Kind
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().

◆ S

Scop& polly::ScopArrayInfo::S
private

The scop this SAI object belongs to.

Definition at line 427 of file ScopInfo.h.


The documentation for this class was generated from the following files: