summaryrefslogtreecommitdiff
path: root/lib/IR/Module.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/IR/Module.cpp')
-rw-r--r--lib/IR/Module.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/IR/Module.cpp b/lib/IR/Module.cpp
index d911c7e2b5..739f8888f9 100644
--- a/lib/IR/Module.cpp
+++ b/lib/IR/Module.cpp
@@ -42,8 +42,8 @@ template class llvm::SymbolTableListTraits<GlobalAlias, Module>;
// Primitive Module methods.
//
-Module::Module(StringRef MID, LLVMContext& C)
- : Context(C), Materializer(NULL), ModuleID(MID) {
+Module::Module(StringRef MID, LLVMContext &C)
+ : Context(C), Materializer(NULL), ModuleID(MID), DL("") {
ValSymTab = new ValueSymbolTable();
NamedMDSymTab = new StringMap<NamedMDNode *>();
Context.addModule(this);
@@ -338,6 +338,30 @@ void Module::addModuleFlag(MDNode *Node) {
getOrInsertModuleFlagsMetadata()->addOperand(Node);
}
+void Module::setDataLayout(StringRef Desc) {
+ if (Desc.empty()) {
+ DataLayoutStr = "";
+ } else {
+ DL.init(Desc);
+ DataLayoutStr = DL.getStringRepresentation();
+ }
+}
+
+void Module::setDataLayout(const DataLayout *Other) {
+ if (!Other) {
+ DataLayoutStr = "";
+ } else {
+ DL = *Other;
+ DataLayoutStr = DL.getStringRepresentation();
+ }
+}
+
+const DataLayout *Module::getDataLayout() const {
+ if (DataLayoutStr.empty())
+ return 0;
+ return &DL;
+}
+
//===----------------------------------------------------------------------===//
// Methods to control the materialization of GlobalValues in the Module.
//