From 4b0c4bf4ae8ea60af1757c91875d4365ab626de7 Mon Sep 17 00:00:00 2001 From: kai Date: Sat, 8 Sep 2012 20:25:42 +0200 Subject: [PATCH] Get rid of global.params.dataLayout. The string representation of the data layout is retrieved from the TargetData class (in main) and passed via global.params.dataLayout to the module. Since the gTargetData is also a global variable it makes no sense to pass this information using another global variable. --- dmd/mars.h | 1 - dmd2/mars.h | 1 - driver/main.cpp | 4 ---- gen/module.cpp | 6 ++++-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/dmd/mars.h b/dmd/mars.h index 9bf63165..343c3600 100644 --- a/dmd/mars.h +++ b/dmd/mars.h @@ -305,7 +305,6 @@ struct Param // target stuff const char* llvmArch; const char *targetTriple; - const char *dataLayout; // Codegen cl options bool singleObj; diff --git a/dmd2/mars.h b/dmd2/mars.h index ccc27469..4d339feb 100644 --- a/dmd2/mars.h +++ b/dmd2/mars.h @@ -273,7 +273,6 @@ struct Param // target stuff const char* llvmArch; const char *targetTriple; - const char *dataLayout; // Codegen cl options bool singleObj; diff --git a/driver/main.cpp b/driver/main.cpp index 32052c46..677a3364 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -566,10 +566,6 @@ int main(int argc, char** argv) gTargetData = target->getTargetData(); - // get final data layout - std::string datalayout = gTargetData->getStringRepresentation(); - global.params.dataLayout = datalayout.c_str(); - global.params.llvmArch = theTarget->getName(); if (strcmp(global.params.llvmArch,"x86")==0) { diff --git a/gen/module.cpp b/gen/module.cpp index a52a4c1b..284a0961 100644 --- a/gen/module.cpp +++ b/gen/module.cpp @@ -2,6 +2,7 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/Module.h" #include "llvm/LinkAllPasses.h" +#include "llvm/Target/TargetData.h" #include "mars.h" #include "module.h" @@ -21,6 +22,7 @@ #include "gen/arrays.h" #include "gen/classes.h" #include "gen/functions.h" +#include "gen/irstate.h" #include "gen/llvmhelpers.h" #include "gen/logger.h" #include "gen/programs.h" @@ -243,9 +245,9 @@ llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context, Ir* sir) ir.module->setTargetTriple(global.params.targetTriple); // set final data layout - ir.module->setDataLayout(global.params.dataLayout); + ir.module->setDataLayout(gTargetData->getStringRepresentation()); if (Logger::enabled()) - Logger::cout() << "Final data layout: " << global.params.dataLayout << '\n'; + Logger::cout() << "Final data layout: " << ir.module->getDataLayout() << '\n'; // allocate the target abi gABI = TargetABI::getTarget();