mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
Store a DataLayout in Module.
Now that DataLayout is not a pass, store one in Module. Since the C API expects to be able to get a char* to the datalayout description, we have to keep a std::string somewhere. This patch keeps it in Module and also uses it to represent modules without a DataLayout. Once DataLayout is mandatory, we should probably move the string to DataLayout itself since it won't be necessary anymore to represent the special case of a module without a DataLayout. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202190 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -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.
|
||||
//
|
||||
|
Reference in New Issue
Block a user