24 struct LegacyStructLayout {
28 std::pair<uint32_t, uint32_t> getElementLegacyOffset(
unsigned Idx)
const {
29 assert(
Idx < Offsets.size() &&
"Invalid element idx!");
32 return std::make_pair((
Offset - Ch) / RowAlign, Ch);
43 LegacyStructLayout &getStructLayout(
StructType *ST);
54 return getTypeAllocSize(Ty);
60 if (AlignedOffset ==
Offset)
63 if (isa<StructType>(EltTy) || isa<ArrayType>(EltTy))
72TypeSize LegacyCBufferLayout::getTypeAllocSize(
Type *Ty) {
73 if (
auto *ST = dyn_cast<StructType>(Ty)) {
74 LegacyStructLayout &Layout = getStructLayout(ST);
76 }
else if (
auto *AT = dyn_cast<ArrayType>(Ty)) {
77 unsigned NumElts = AT->getNumElements();
81 TypeSize EltSize = getTypeAllocSize(AT->getElementType());
82 TypeSize AlignedEltSize = alignTo4Dwords(EltSize);
92LegacyCBufferLayout::LegacyStructLayout &
93LegacyCBufferLayout::getStructLayout(StructType *ST) {
94 auto it = StructLayouts.find(ST);
95 if (it != StructLayouts.end())
99 LegacyStructLayout Layout;
101 for (Type *EltTy :
ST->elements()) {
102 TypeSize EltSize = getTypeAllocSize(EltTy);
106 Layout.Offsets.emplace_back(
Offset);
110 StructLayouts[
ST] = Layout;
111 return StructLayouts[
ST];
115 :
DL(
DL), IsLegacyLayout(IsLegacy),
123 return LegacyDL->getTypeAllocSizeInBytes(Ty);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A parsed version of the target data layout string in and methods for querying it.
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Class to represent struct types.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
CBufferDataLayout(const DataLayout &DL, const bool IsLegacy)
llvm::TypeSize getTypeAllocSizeInBytes(Type *Ty)
LegacyCBufferLayout(const DataLayout &DL)
TypeSize getTypeAllocSizeInBytes(Type *Ty)
This is an optimization pass for GlobalISel generic memory operations.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Implement std::hash so that hash_code can be used in STL containers.