summaryrefslogtreecommitdiff
path: root/lib/VMCore/DataLayout.cpp
diff options
context:
space:
mode:
authorMicah Villmow <villmow@gmail.com>2012-10-04 20:49:16 +0000
committerMicah Villmow <villmow@gmail.com>2012-10-04 20:49:16 +0000
commit5afc50a7a39523c36e145a9d647a3a513ac8fa5a (patch)
tree4eb7ba55af149df64bb84a70ae95d32c3905636f /lib/VMCore/DataLayout.cpp
parent0313ced016f3777e806ca2e42a746d3162174c47 (diff)
downloadllvm-5afc50a7a39523c36e145a9d647a3a513ac8fa5a.tar.gz
llvm-5afc50a7a39523c36e145a9d647a3a513ac8fa5a.tar.bz2
llvm-5afc50a7a39523c36e145a9d647a3a513ac8fa5a.tar.xz
Rename TargetData to DataLayout in DataLayout.cpp. This should fix a build failure from r165249 where the wrong version of the file was submitted.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165251 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/DataLayout.cpp')
-rw-r--r--lib/VMCore/DataLayout.cpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/lib/VMCore/DataLayout.cpp b/lib/VMCore/DataLayout.cpp
index 0040147022..f4afb8586b 100644
--- a/lib/VMCore/DataLayout.cpp
+++ b/lib/VMCore/DataLayout.cpp
@@ -1,4 +1,4 @@
-//===-- TargetData.cpp - Data size & alignment routines --------------------==//
+//===-- DataLayout.cpp - Data size & alignment routines --------------------==//
//
// The LLVM Compiler Infrastructure
//
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file defines target properties related to datatype size/offset/alignment
+// This file defines layout properties related to datatype size/offset/alignment
// information.
//
// This structure should be created once, filled in if the defaults are not
@@ -16,7 +16,7 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Target/TargetData.h"
+#include "llvm/DataLayout.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
@@ -31,17 +31,17 @@
#include <cstdlib>
using namespace llvm;
-// Handle the Pass registration stuff necessary to use TargetData's.
+// Handle the Pass registration stuff necessary to use DataLayout's.
// Register the default SparcV9 implementation...
INITIALIZE_PASS(TargetData, "targetdata", "Target Data Layout", false, true)
-char TargetData::ID = 0;
+char DataLayout::ID = 0;
//===----------------------------------------------------------------------===//
// Support for StructLayout
//===----------------------------------------------------------------------===//
-StructLayout::StructLayout(StructType *ST, const TargetData &TD) {
+StructLayout::StructLayout(StructType *ST, const DataLayout &TD) {
assert(!ST->isOpaque() && "Cannot get layout of opaque structs");
StructAlignment = 0;
StructSize = 0;
@@ -54,7 +54,7 @@ StructLayout::StructLayout(StructType *ST, const TargetData &TD) {
// Add padding if necessary to align the data element properly.
if ((StructSize & (TyAlign-1)) != 0)
- StructSize = TargetData::RoundUpAlignment(StructSize, TyAlign);
+ StructSize = DataLayout::RoundUpAlignment(StructSize, TyAlign);
// Keep track of maximum alignment constraint.
StructAlignment = std::max(TyAlign, StructAlignment);
@@ -69,7 +69,7 @@ StructLayout::StructLayout(StructType *ST, const TargetData &TD) {
// Add padding to the end of the struct so that it could be put in an array
// and all array elements would be aligned correctly.
if ((StructSize & (StructAlignment-1)) != 0)
- StructSize = TargetData::RoundUpAlignment(StructSize, StructAlignment);
+ StructSize = DataLayout::RoundUpAlignment(StructSize, StructAlignment);
}
@@ -118,10 +118,10 @@ TargetAlignElem::operator==(const TargetAlignElem &rhs) const {
}
const TargetAlignElem
-TargetData::InvalidAlignmentElem = { (AlignTypeEnum)0xFF, 0, 0, 0 };
+DataLayout::InvalidAlignmentElem = { (AlignTypeEnum)0xFF, 0, 0, 0 };
//===----------------------------------------------------------------------===//
-// TargetData Class Implementation
+// DataLayout Class Implementation
//===----------------------------------------------------------------------===//
/// getInt - Get an integer ignoring errors.
@@ -131,7 +131,7 @@ static int getInt(StringRef R) {
return Result;
}
-void TargetData::init() {
+void DataLayout::init() {
initializeTargetDataPass(*PassRegistry::getPassRegistry());
LayoutMap = 0;
@@ -156,7 +156,7 @@ void TargetData::init() {
setAlignment(AGGREGATE_ALIGN, 0, 8, 0); // struct
}
-std::string TargetData::parseSpecifier(StringRef Desc, TargetData *td) {
+std::string DataLayout::parseSpecifier(StringRef Desc, DataLayout *td) {
if (td)
td->init();
@@ -298,12 +298,12 @@ std::string TargetData::parseSpecifier(StringRef Desc, TargetData *td) {
///
/// @note This has to exist, because this is a pass, but it should never be
/// used.
-TargetData::TargetData() : ImmutablePass(ID) {
- report_fatal_error("Bad TargetData ctor used. "
- "Tool did not specify a TargetData to use?");
+DataLayout::DataLayout() : ImmutablePass(ID) {
+ report_fatal_error("Bad DataLayout ctor used. "
+ "Tool did not specify a DataLayout to use?");
}
-TargetData::TargetData(const Module *M)
+DataLayout::DataLayout(const Module *M)
: ImmutablePass(ID) {
std::string errMsg = parseSpecifier(M->getDataLayout(), this);
assert(errMsg == "" && "Module M has malformed target data layout string.");
@@ -311,7 +311,7 @@ TargetData::TargetData(const Module *M)
}
void
-TargetData::setAlignment(AlignTypeEnum align_type, unsigned abi_align,
+DataLayout::setAlignment(AlignTypeEnum align_type, unsigned abi_align,
unsigned pref_align, uint32_t bit_width) {
assert(abi_align <= pref_align && "Preferred alignment worse than ABI!");
assert(pref_align < (1 << 16) && "Alignment doesn't fit in bitfield");
@@ -332,7 +332,7 @@ TargetData::setAlignment(AlignTypeEnum align_type, unsigned abi_align,
/// getAlignmentInfo - Return the alignment (either ABI if ABIInfo = true or
/// preferred if ABIInfo = false) the target wants for the specified datatype.
-unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType,
+unsigned DataLayout::getAlignmentInfo(AlignTypeEnum AlignType,
uint32_t BitWidth, bool ABIInfo,
Type *Ty) const {
// Check to see if we have an exact match and remember the best match we see.
@@ -412,11 +412,11 @@ public:
} // end anonymous namespace
-TargetData::~TargetData() {
+DataLayout::~DataLayout() {
delete static_cast<StructLayoutMap*>(LayoutMap);
}
-const StructLayout *TargetData::getStructLayout(StructType *Ty) const {
+const StructLayout *DataLayout::getStructLayout(StructType *Ty) const {
if (!LayoutMap)
LayoutMap = new StructLayoutMap();
@@ -439,7 +439,7 @@ const StructLayout *TargetData::getStructLayout(StructType *Ty) const {
return L;
}
-std::string TargetData::getStringRepresentation() const {
+std::string DataLayout::getStringRepresentation() const {
std::string Result;
raw_string_ostream OS(Result);
@@ -464,7 +464,7 @@ std::string TargetData::getStringRepresentation() const {
}
-uint64_t TargetData::getTypeSizeInBits(Type *Ty) const {
+uint64_t DataLayout::getTypeSizeInBits(Type *Ty) const {
assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!");
switch (Ty->getTypeID()) {
case Type::LabelTyID:
@@ -498,7 +498,7 @@ uint64_t TargetData::getTypeSizeInBits(Type *Ty) const {
case Type::VectorTyID:
return cast<VectorType>(Ty)->getBitWidth();
default:
- llvm_unreachable("TargetData::getTypeSizeInBits(): Unsupported type");
+ llvm_unreachable("DataLayout::getTypeSizeInBits(): Unsupported type");
}
}
@@ -510,7 +510,7 @@ uint64_t TargetData::getTypeSizeInBits(Type *Ty) const {
Get the ABI (\a abi_or_pref == true) or preferred alignment (\a abi_or_pref
== false) for the requested type \a Ty.
*/
-unsigned TargetData::getAlignment(Type *Ty, bool abi_or_pref) const {
+unsigned DataLayout::getAlignment(Type *Ty, bool abi_or_pref) const {
int AlignType = -1;
assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!");
@@ -560,18 +560,18 @@ unsigned TargetData::getAlignment(Type *Ty, bool abi_or_pref) const {
abi_or_pref, Ty);
}
-unsigned TargetData::getABITypeAlignment(Type *Ty) const {
+unsigned DataLayout::getABITypeAlignment(Type *Ty) const {
return getAlignment(Ty, true);
}
/// getABIIntegerTypeAlignment - Return the minimum ABI-required alignment for
/// an integer type of the specified bitwidth.
-unsigned TargetData::getABIIntegerTypeAlignment(unsigned BitWidth) const {
+unsigned DataLayout::getABIIntegerTypeAlignment(unsigned BitWidth) const {
return getAlignmentInfo(INTEGER_ALIGN, BitWidth, true, 0);
}
-unsigned TargetData::getCallFrameTypeAlignment(Type *Ty) const {
+unsigned DataLayout::getCallFrameTypeAlignment(Type *Ty) const {
for (unsigned i = 0, e = Alignments.size(); i != e; ++i)
if (Alignments[i].AlignType == STACK_ALIGN)
return Alignments[i].ABIAlign;
@@ -579,11 +579,11 @@ unsigned TargetData::getCallFrameTypeAlignment(Type *Ty) const {
return getABITypeAlignment(Ty);
}
-unsigned TargetData::getPrefTypeAlignment(Type *Ty) const {
+unsigned DataLayout::getPrefTypeAlignment(Type *Ty) const {
return getAlignment(Ty, false);
}
-unsigned TargetData::getPreferredTypeAlignmentShift(Type *Ty) const {
+unsigned DataLayout::getPreferredTypeAlignmentShift(Type *Ty) const {
unsigned Align = getPrefTypeAlignment(Ty);
assert(!(Align & (Align-1)) && "Alignment is not a power of two!");
return Log2_32(Align);
@@ -591,12 +591,12 @@ unsigned TargetData::getPreferredTypeAlignmentShift(Type *Ty) const {
/// getIntPtrType - Return an unsigned integer type that is the same size or
/// greater to the host pointer size.
-IntegerType *TargetData::getIntPtrType(LLVMContext &C) const {
+IntegerType *DataLayout::getIntPtrType(LLVMContext &C) const {
return IntegerType::get(C, getPointerSizeInBits());
}
-uint64_t TargetData::getIndexedOffset(Type *ptrTy,
+uint64_t DataLayout::getIndexedOffset(Type *ptrTy,
ArrayRef<Value *> Indices) const {
Type *Ty = ptrTy;
assert(Ty->isPointerTy() && "Illegal argument for getIndexedOffset()");
@@ -636,7 +636,7 @@ uint64_t TargetData::getIndexedOffset(Type *ptrTy,
/// getPreferredAlignment - Return the preferred alignment of the specified
/// global. This includes an explicitly requested alignment (if the global
/// has one).
-unsigned TargetData::getPreferredAlignment(const GlobalVariable *GV) const {
+unsigned DataLayout::getPreferredAlignment(const GlobalVariable *GV) const {
Type *ElemType = GV->getType()->getElementType();
unsigned Alignment = getPrefTypeAlignment(ElemType);
unsigned GVAlignment = GV->getAlignment();
@@ -660,6 +660,6 @@ unsigned TargetData::getPreferredAlignment(const GlobalVariable *GV) const {
/// getPreferredAlignmentLog - Return the preferred alignment of the
/// specified global, returned in log form. This includes an explicitly
/// requested alignment (if the global has one).
-unsigned TargetData::getPreferredAlignmentLog(const GlobalVariable *GV) const {
+unsigned DataLayout::getPreferredAlignmentLog(const GlobalVariable *GV) const {
return Log2_32(getPreferredAlignment(GV));
}