summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DataLayout.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-02-25 17:30:31 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-02-25 17:30:31 +0000
commit935125126c4ffde74ef3a82959fde69ee8c6b648 (patch)
treec8f13ff32afa704ca5ae5ad3faf4650f9ea2f4c2 /llvm/lib/IR/DataLayout.cpp
parent48f52e926d6e8273587f5befc997fc784b04855b (diff)
downloadbcm5719-llvm-935125126c4ffde74ef3a82959fde69ee8c6b648.tar.gz
bcm5719-llvm-935125126c4ffde74ef3a82959fde69ee8c6b648.zip
Make DataLayout a plain object, not a pass.
Instead, have a DataLayoutPass that holds one. This will allow parts of LLVM don't don't handle passes to also use DataLayout. llvm-svn: 202168
Diffstat (limited to 'llvm/lib/IR/DataLayout.cpp')
-rw-r--r--llvm/lib/IR/DataLayout.cpp47
1 files changed, 23 insertions, 24 deletions
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index 7de41faac4f..44410ceb684 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/lib/IR/DataLayout.cpp
@@ -35,9 +35,8 @@ using namespace llvm;
// Handle the Pass registration stuff necessary to use DataLayout's.
-// Register the default SparcV9 implementation...
-INITIALIZE_PASS(DataLayout, "datalayout", "Data Layout", false, true)
-char DataLayout::ID = 0;
+INITIALIZE_PASS(DataLayoutPass, "datalayout", "Data Layout", false, true)
+char DataLayoutPass::ID = 0;
//===----------------------------------------------------------------------===//
// Support for StructLayout
@@ -178,8 +177,6 @@ static const LayoutAlignElem DefaultAlignments[] = {
};
void DataLayout::init(StringRef Desc) {
- initializeDataLayoutPass(*PassRegistry::getPassRegistry());
-
LayoutMap = 0;
LittleEndian = false;
StackNaturalAlign = 0;
@@ -347,19 +344,7 @@ void DataLayout::parseSpecifier(StringRef Desc) {
}
}
-/// Default ctor.
-///
-/// @note This has to exist, because this is a pass, but it should never be
-/// used.
-DataLayout::DataLayout() : ImmutablePass(ID) {
- report_fatal_error("Bad DataLayout ctor used. "
- "Tool did not specify a DataLayout to use?");
-}
-
-DataLayout::DataLayout(const Module *M)
- : ImmutablePass(ID) {
- init(M->getDataLayout());
-}
+DataLayout::DataLayout(const Module *M) { init(M->getDataLayout()); }
void
DataLayout::setAlignment(AlignTypeEnum align_type, unsigned abi_align,
@@ -482,12 +467,6 @@ DataLayout::~DataLayout() {
delete static_cast<StructLayoutMap*>(LayoutMap);
}
-bool DataLayout::doFinalization(Module &M) {
- delete static_cast<StructLayoutMap*>(LayoutMap);
- LayoutMap = 0;
- return false;
-}
-
const StructLayout *DataLayout::getStructLayout(StructType *Ty) const {
if (!LayoutMap)
LayoutMap = new StructLayoutMap();
@@ -778,3 +757,23 @@ unsigned DataLayout::getPreferredAlignment(const GlobalVariable *GV) const {
unsigned DataLayout::getPreferredAlignmentLog(const GlobalVariable *GV) const {
return Log2_32(getPreferredAlignment(GV));
}
+
+DataLayoutPass::DataLayoutPass() : ImmutablePass(ID), DL("") {
+ report_fatal_error("Bad DataLayoutPass ctor used. Tool did not specify a "
+ "DataLayout to use?");
+}
+
+DataLayoutPass::~DataLayoutPass() {}
+
+DataLayoutPass::DataLayoutPass(const DataLayout &DL)
+ : ImmutablePass(ID), DL(DL) {
+ initializeDataLayoutPassPass(*PassRegistry::getPassRegistry());
+}
+
+DataLayoutPass::DataLayoutPass(StringRef Str) : ImmutablePass(ID), DL(Str) {
+ initializeDataLayoutPassPass(*PassRegistry::getPassRegistry());
+}
+
+DataLayoutPass::DataLayoutPass(const Module *M) : ImmutablePass(ID), DL(M) {
+ initializeDataLayoutPassPass(*PassRegistry::getPassRegistry());
+}
OpenPOWER on IntegriCloud