encapsulate the rest of the StructLayout members.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34157 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/Target/TargetData.h b/include/llvm/Target/TargetData.h
index 516aae7..18f9d3b 100644
--- a/include/llvm/Target/TargetData.h
+++ b/include/llvm/Target/TargetData.h
@@ -276,10 +276,18 @@
///
class StructLayout {
std::vector<uint64_t> MemberOffsets;
-public:
unsigned StructAlignment;
uint64_t StructSize;
+public:
+ uint64_t getSizeInBytes() const {
+ return StructSize;
+ }
+
+ unsigned getAlignment() const {
+ return StructAlignment;
+ }
+
/// getElementContainingOffset - Given a valid offset into the structure,
/// return the structure index that contains it.
///
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp
index 6dac1ea..2d7dec4 100644
--- a/lib/CodeGen/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter.cpp
@@ -738,7 +738,7 @@
// Check if padding is needed and insert one or more 0s.
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)) - fieldSize;
sizeSoFar += fieldSize + padSize;
@@ -749,7 +749,7 @@
// Insert the field padding unless it's zero bytes...
EmitZeros(padSize);
}
- assert(sizeSoFar == cvsLayout->StructSize &&
+ assert(sizeSoFar == cvsLayout->getSizeInBytes() &&
"Layout of constant struct may be incorrect!");
return;
} else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp
index 1ebe5b5..adbd22a 100644
--- a/lib/Target/TargetData.cpp
+++ b/lib/Target/TargetData.cpp
@@ -325,7 +325,7 @@
case Type::StructTyID: {
// Get the layout annotation... which is lazily created on demand.
const StructLayout *Layout = TD->getStructLayout(cast<StructType>(Ty));
- Size = Layout->StructSize; Alignment = Layout->StructAlignment;
+ Size = Layout->getSizeInBytes(); Alignment = Layout->getAlignment();
return;
}
@@ -387,9 +387,9 @@
// Get the layout annotation... which is lazily created on demand;
// enforce minimum aggregate alignment.
const StructLayout *Layout = TD->getStructLayout(cast<StructType>(Ty));
- Size = Layout->StructSize;
- Alignment = std::max(Layout->StructAlignment,
- (const unsigned int) TD->getAggMinPrefAlignment());
+ Size = Layout->getSizeInBytes();
+ Alignment = std::max(Layout->getAlignment(),
+ (const unsigned int)TD->getAggMinPrefAlignment());
return;
}