diff --git a/dmd2/mars.h b/dmd2/mars.h index dc640308..81d42059 100644 --- a/dmd2/mars.h +++ b/dmd2/mars.h @@ -272,6 +272,11 @@ struct Param const char* llvmArch; const char *targetTriple; const char *dataLayout; + + // Codegen cl options + bool singleObj; + bool disableRedZone; + bool noVerify; #endif }; diff --git a/gen/cl_options.cpp b/driver/cl_options.cpp similarity index 96% rename from gen/cl_options.cpp rename to driver/cl_options.cpp index a869620f..4374aa33 100644 --- a/gen/cl_options.cpp +++ b/driver/cl_options.cpp @@ -1,4 +1,4 @@ -#include "gen/cl_options.h" +#include "driver/cl_options.h" #include "gen/cl_helpers.h" #include "llvm/Target/TargetMachine.h" @@ -132,8 +132,9 @@ cl::opt output_o("output-o", cl::desc("Write native object")); // Disabling Red Zone -cl::opt disableRedZone("disable-red-zone", +cl::opt disableRedZone("disable-red-zone", cl::desc("Do not emit code that uses the red zone."), + cl::location(global.params.disableRedZone), cl::init(false)); // DDoc options @@ -360,7 +361,7 @@ static cl::opt postconditions("postconditions", cl::init(true)); -static MultiSetter ContractsSetter(false, +static MultiSetter ContractsSetter(false, &global.params.useIn, &global.params.useOut, NULL); static cl::opt contracts("contracts", cl::desc("(*) Enable function pre- and post-conditions"), @@ -374,10 +375,13 @@ static cl::opt > release("release", cl::location(ReleaseSetter), cl::ValueDisallowed); +cl::opt noVerify("noverify", + llvm::cl::desc("Do not run the validation pass before writing bitcode"), + cl::location(global.params.noVerify)); -cl::opt singleObj("singleobj", +cl::opt singleObj("singleobj", cl::desc("Create only a single output object file"), - cl::ZeroOrMore); + cl::location(global.params.singleObj)); cl::opt linkonceTemplates("linkonce-templates", cl::desc("Use linkonce_odr linkage for template symbols instead of weak_odr"), diff --git a/gen/cl_options.h b/driver/cl_options.h similarity index 95% rename from gen/cl_options.h rename to driver/cl_options.h index 53392e36..2fed81b0 100644 --- a/gen/cl_options.h +++ b/driver/cl_options.h @@ -33,7 +33,7 @@ namespace opts { extern cl::opt output_ll; extern cl::opt output_s; extern cl::opt output_o; - extern cl::opt disableRedZone; + extern cl::opt disableRedZone; extern cl::opt ddocDir; extern cl::opt ddocFile; extern cl::opt jsonFile; @@ -50,7 +50,7 @@ namespace opts { extern cl::opt mTargetTriple; extern cl::opt mRelocModel; extern cl::opt mCodeModel; - extern cl::opt singleObj; + extern cl::opt singleObj; extern cl::opt linkonceTemplates; // Arguments to -d-debug diff --git a/gen/linker.cpp b/driver/linker.cpp similarity index 99% rename from gen/linker.cpp rename to driver/linker.cpp index 33bf2c5c..8d189763 100644 --- a/gen/linker.cpp +++ b/driver/linker.cpp @@ -1,4 +1,3 @@ -#include "gen/linker.h" #include "gen/llvm.h" #include "llvm/Linker.h" #include "llvm/Support/FileSystem.h" @@ -13,10 +12,12 @@ #define NO_COUT_LOGGER #include "gen/logger.h" -#include "gen/cl_options.h" #include "gen/optimizer.h" #include "gen/programs.h" +#include "driver/linker.h" +#include "driver/cl_options.h" + ////////////////////////////////////////////////////////////////////////////// // Is this useful? diff --git a/gen/linker.h b/driver/linker.h similarity index 100% rename from gen/linker.h rename to driver/linker.h diff --git a/driver/main.cpp b/driver/main.cpp index 50f8ba03..633f7dc5 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -30,13 +30,13 @@ #include "gen/logger.h" #include "gen/linkage.h" -#include "gen/linker.h" #include "gen/irstate.h" #include "gen/optimizer.h" #include "gen/metadata.h" #include "gen/passes/Passes.h" -#include "gen/cl_options.h" +#include "driver/linker.h" +#include "driver/cl_options.h" #include "gen/cl_helpers.h" using namespace opts; diff --git a/driver/toobj.cpp b/driver/toobj.cpp index 98ce6abc..bdcb8982 100644 --- a/driver/toobj.cpp +++ b/driver/toobj.cpp @@ -24,12 +24,6 @@ #include "gen/optimizer.h" -////////////////////////////////////////////////////////////////////////////////////////// - -extern llvm::cl::opt noVerify; - -////////////////////////////////////////////////////////////////////////////////////////// - // fwd decl void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& Out, llvm::TargetMachine::CodeGenFileType fileType); @@ -42,7 +36,7 @@ void writeModule(llvm::Module* m, std::string filename) bool reverify = ldc_optimize_module(m); // verify the llvm - if (!noVerify && reverify) { + if (!global.params.noVerify && reverify) { std::string verifyErr; Logger::println("Verifying module... again..."); LOG_SCOPE; diff --git a/gen/arrays.cpp b/gen/arrays.cpp index 62b97266..b5adde87 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -17,8 +17,6 @@ #include "ir/irmodule.h" #include "ir/irtypestruct.h" -#include "gen/cl_options.h" - ////////////////////////////////////////////////////////////////////////////////////////// static LLValue *DtoSlice(DValue *dval) diff --git a/gen/functions.cpp b/gen/functions.cpp index 72c4c342..d7946fa8 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -23,7 +23,6 @@ #include "gen/dvalue.h" #include "gen/abi.h" #include "gen/nested.h" -#include "gen/cl_options.h" #include "gen/pragma.h" using namespace llvm::Attribute; @@ -510,7 +509,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) // parameter attributes if (!fdecl->isIntrinsic()) { set_param_attrs(f, func, fdecl); - if (opts::disableRedZone) { + if (global.params.disableRedZone) { func->addFnAttr(NoRedZone); } } diff --git a/gen/linkage.cpp b/gen/linkage.cpp index 62853374..ba77f90f 100644 --- a/gen/linkage.cpp +++ b/gen/linkage.cpp @@ -1,4 +1,3 @@ #include "linkage.h" -#include "gen/cl_options.h" LLGlobalValue::LinkageTypes templateLinkage; diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 17b7119a..6584e7cd 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -22,7 +22,6 @@ #include "gen/functions.h" #include "gen/typeinf.h" #include "gen/todebug.h" -#include "gen/cl_options.h" #include "gen/nested.h" #include "ir/irmodule.h" @@ -1649,7 +1648,7 @@ bool mustDefineSymbol(Dsymbol* s) TemplateInstance* tinst = DtoIsTemplateInstance(s); if (tinst) { - if (!opts::singleObj) + if (!global.params.singleObj) return true; if (!tinst->emittedInModule) diff --git a/gen/module.cpp b/gen/module.cpp index e17d35ee..fc3ca84b 100644 --- a/gen/module.cpp +++ b/gen/module.cpp @@ -20,7 +20,6 @@ #include "gen/abi.h" #include "gen/arrays.h" #include "gen/classes.h" -#include "gen/cl_options.h" #include "gen/functions.h" #include "gen/llvmhelpers.h" #include "gen/logger.h" @@ -39,13 +38,6 @@ #define NEW_MODULEINFO_LAYOUT 1 #endif -////////////////////////////////////////////////////////////////////////////////////////// - -llvm::cl::opt noVerify("noverify", - llvm::cl::desc("Do not run the validation pass before writing bitcode"), - llvm::cl::ZeroOrMore); - -////////////////////////////////////////////////////////////////////////////////////////// static llvm::Function* build_module_function(const std::string &name, const std::list &funcs, const std::list &gates = std::list()) @@ -276,7 +268,7 @@ llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context, Ir* sir) sir->emitFunctionBodies(); // for singleobj-compilation, fully emit all seen template instances - if (opts::singleObj) + if (global.params.singleObj) { while (!ir.seenTemplateInstances.empty()) { @@ -297,7 +289,7 @@ llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context, Ir* sir) genmoduleinfo(); // verify the llvm - if (!noVerify) { + if (!global.params.noVerify) { std::string verifyErr; Logger::println("Verifying module..."); LOG_SCOPE;