mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-14 17:34:41 +00:00
encapsulate the rest of the StructLayout members.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34157 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b1919e2f08
commit
b0c39a3b4d
@ -276,10 +276,18 @@ public:
|
|||||||
///
|
///
|
||||||
class StructLayout {
|
class StructLayout {
|
||||||
std::vector<uint64_t> MemberOffsets;
|
std::vector<uint64_t> MemberOffsets;
|
||||||
public:
|
|
||||||
unsigned StructAlignment;
|
unsigned StructAlignment;
|
||||||
uint64_t StructSize;
|
uint64_t StructSize;
|
||||||
|
public:
|
||||||
|
|
||||||
|
uint64_t getSizeInBytes() const {
|
||||||
|
return StructSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned getAlignment() const {
|
||||||
|
return StructAlignment;
|
||||||
|
}
|
||||||
|
|
||||||
/// getElementContainingOffset - Given a valid offset into the structure,
|
/// getElementContainingOffset - Given a valid offset into the structure,
|
||||||
/// return the structure index that contains it.
|
/// return the structure index that contains it.
|
||||||
///
|
///
|
||||||
|
@ -738,7 +738,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
|
|||||||
|
|
||||||
// Check if padding is needed and insert one or more 0s.
|
// Check if padding is needed and insert one or more 0s.
|
||||||
uint64_t fieldSize = TD->getTypeSize(field->getType());
|
uint64_t fieldSize = TD->getTypeSize(field->getType());
|
||||||
uint64_t padSize = ((i == e-1? cvsLayout->StructSize
|
uint64_t padSize = ((i == e-1? cvsLayout->getSizeInBytes()
|
||||||
: cvsLayout->getElementOffset(i+1))
|
: cvsLayout->getElementOffset(i+1))
|
||||||
- cvsLayout->getElementOffset(i)) - fieldSize;
|
- cvsLayout->getElementOffset(i)) - fieldSize;
|
||||||
sizeSoFar += fieldSize + padSize;
|
sizeSoFar += fieldSize + padSize;
|
||||||
@ -749,7 +749,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
|
|||||||
// Insert the field padding unless it's zero bytes...
|
// Insert the field padding unless it's zero bytes...
|
||||||
EmitZeros(padSize);
|
EmitZeros(padSize);
|
||||||
}
|
}
|
||||||
assert(sizeSoFar == cvsLayout->StructSize &&
|
assert(sizeSoFar == cvsLayout->getSizeInBytes() &&
|
||||||
"Layout of constant struct may be incorrect!");
|
"Layout of constant struct may be incorrect!");
|
||||||
return;
|
return;
|
||||||
} else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
|
} else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
|
||||||
|
@ -325,7 +325,7 @@ static inline void getTypeInfoABI(const Type *Ty, const TargetData *TD,
|
|||||||
case Type::StructTyID: {
|
case Type::StructTyID: {
|
||||||
// Get the layout annotation... which is lazily created on demand.
|
// Get the layout annotation... which is lazily created on demand.
|
||||||
const StructLayout *Layout = TD->getStructLayout(cast<StructType>(Ty));
|
const StructLayout *Layout = TD->getStructLayout(cast<StructType>(Ty));
|
||||||
Size = Layout->StructSize; Alignment = Layout->StructAlignment;
|
Size = Layout->getSizeInBytes(); Alignment = Layout->getAlignment();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,9 +387,9 @@ static inline void getTypeInfoPref(const Type *Ty, const TargetData *TD,
|
|||||||
// Get the layout annotation... which is lazily created on demand;
|
// Get the layout annotation... which is lazily created on demand;
|
||||||
// enforce minimum aggregate alignment.
|
// enforce minimum aggregate alignment.
|
||||||
const StructLayout *Layout = TD->getStructLayout(cast<StructType>(Ty));
|
const StructLayout *Layout = TD->getStructLayout(cast<StructType>(Ty));
|
||||||
Size = Layout->StructSize;
|
Size = Layout->getSizeInBytes();
|
||||||
Alignment = std::max(Layout->StructAlignment,
|
Alignment = std::max(Layout->getAlignment(),
|
||||||
(const unsigned int) TD->getAggMinPrefAlignment());
|
(const unsigned int)TD->getAggMinPrefAlignment());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user