mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 00:55:49 +03:00
Move cl_options out of LDCShared
This commit is contained in:
parent
71044056e4
commit
feefad412c
12 changed files with 26 additions and 35 deletions
|
@ -272,6 +272,11 @@ struct Param
|
||||||
const char* llvmArch;
|
const char* llvmArch;
|
||||||
const char *targetTriple;
|
const char *targetTriple;
|
||||||
const char *dataLayout;
|
const char *dataLayout;
|
||||||
|
|
||||||
|
// Codegen cl options
|
||||||
|
bool singleObj;
|
||||||
|
bool disableRedZone;
|
||||||
|
bool noVerify;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "gen/cl_options.h"
|
#include "driver/cl_options.h"
|
||||||
#include "gen/cl_helpers.h"
|
#include "gen/cl_helpers.h"
|
||||||
|
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
|
@ -132,8 +132,9 @@ cl::opt<cl::boolOrDefault> output_o("output-o",
|
||||||
cl::desc("Write native object"));
|
cl::desc("Write native object"));
|
||||||
|
|
||||||
// Disabling Red Zone
|
// Disabling Red Zone
|
||||||
cl::opt<bool> disableRedZone("disable-red-zone",
|
cl::opt<bool, true> disableRedZone("disable-red-zone",
|
||||||
cl::desc("Do not emit code that uses the red zone."),
|
cl::desc("Do not emit code that uses the red zone."),
|
||||||
|
cl::location(global.params.disableRedZone),
|
||||||
cl::init(false));
|
cl::init(false));
|
||||||
|
|
||||||
// DDoc options
|
// DDoc options
|
||||||
|
@ -360,7 +361,7 @@ static cl::opt<bool, true, FlagParser> postconditions("postconditions",
|
||||||
cl::init(true));
|
cl::init(true));
|
||||||
|
|
||||||
|
|
||||||
static MultiSetter ContractsSetter(false,
|
static MultiSetter ContractsSetter(false,
|
||||||
&global.params.useIn, &global.params.useOut, NULL);
|
&global.params.useIn, &global.params.useOut, NULL);
|
||||||
static cl::opt<MultiSetter, true, FlagParser> contracts("contracts",
|
static cl::opt<MultiSetter, true, FlagParser> contracts("contracts",
|
||||||
cl::desc("(*) Enable function pre- and post-conditions"),
|
cl::desc("(*) Enable function pre- and post-conditions"),
|
||||||
|
@ -374,10 +375,13 @@ static cl::opt<MultiSetter, true, cl::parser<bool> > release("release",
|
||||||
cl::location(ReleaseSetter),
|
cl::location(ReleaseSetter),
|
||||||
cl::ValueDisallowed);
|
cl::ValueDisallowed);
|
||||||
|
|
||||||
|
cl::opt<bool, true> noVerify("noverify",
|
||||||
|
llvm::cl::desc("Do not run the validation pass before writing bitcode"),
|
||||||
|
cl::location(global.params.noVerify));
|
||||||
|
|
||||||
cl::opt<bool> singleObj("singleobj",
|
cl::opt<bool, true> singleObj("singleobj",
|
||||||
cl::desc("Create only a single output object file"),
|
cl::desc("Create only a single output object file"),
|
||||||
cl::ZeroOrMore);
|
cl::location(global.params.singleObj));
|
||||||
|
|
||||||
cl::opt<bool> linkonceTemplates("linkonce-templates",
|
cl::opt<bool> linkonceTemplates("linkonce-templates",
|
||||||
cl::desc("Use linkonce_odr linkage for template symbols instead of weak_odr"),
|
cl::desc("Use linkonce_odr linkage for template symbols instead of weak_odr"),
|
|
@ -33,7 +33,7 @@ namespace opts {
|
||||||
extern cl::opt<bool> output_ll;
|
extern cl::opt<bool> output_ll;
|
||||||
extern cl::opt<bool> output_s;
|
extern cl::opt<bool> output_s;
|
||||||
extern cl::opt<cl::boolOrDefault> output_o;
|
extern cl::opt<cl::boolOrDefault> output_o;
|
||||||
extern cl::opt<bool> disableRedZone;
|
extern cl::opt<bool, true> disableRedZone;
|
||||||
extern cl::opt<std::string> ddocDir;
|
extern cl::opt<std::string> ddocDir;
|
||||||
extern cl::opt<std::string> ddocFile;
|
extern cl::opt<std::string> ddocFile;
|
||||||
extern cl::opt<std::string> jsonFile;
|
extern cl::opt<std::string> jsonFile;
|
||||||
|
@ -50,7 +50,7 @@ namespace opts {
|
||||||
extern cl::opt<std::string> mTargetTriple;
|
extern cl::opt<std::string> mTargetTriple;
|
||||||
extern cl::opt<llvm::Reloc::Model> mRelocModel;
|
extern cl::opt<llvm::Reloc::Model> mRelocModel;
|
||||||
extern cl::opt<llvm::CodeModel::Model> mCodeModel;
|
extern cl::opt<llvm::CodeModel::Model> mCodeModel;
|
||||||
extern cl::opt<bool> singleObj;
|
extern cl::opt<bool, true> singleObj;
|
||||||
extern cl::opt<bool> linkonceTemplates;
|
extern cl::opt<bool> linkonceTemplates;
|
||||||
|
|
||||||
// Arguments to -d-debug
|
// Arguments to -d-debug
|
|
@ -1,4 +1,3 @@
|
||||||
#include "gen/linker.h"
|
|
||||||
#include "gen/llvm.h"
|
#include "gen/llvm.h"
|
||||||
#include "llvm/Linker.h"
|
#include "llvm/Linker.h"
|
||||||
#include "llvm/Support/FileSystem.h"
|
#include "llvm/Support/FileSystem.h"
|
||||||
|
@ -13,10 +12,12 @@
|
||||||
|
|
||||||
#define NO_COUT_LOGGER
|
#define NO_COUT_LOGGER
|
||||||
#include "gen/logger.h"
|
#include "gen/logger.h"
|
||||||
#include "gen/cl_options.h"
|
|
||||||
#include "gen/optimizer.h"
|
#include "gen/optimizer.h"
|
||||||
#include "gen/programs.h"
|
#include "gen/programs.h"
|
||||||
|
|
||||||
|
#include "driver/linker.h"
|
||||||
|
#include "driver/cl_options.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Is this useful?
|
// Is this useful?
|
|
@ -30,13 +30,13 @@
|
||||||
|
|
||||||
#include "gen/logger.h"
|
#include "gen/logger.h"
|
||||||
#include "gen/linkage.h"
|
#include "gen/linkage.h"
|
||||||
#include "gen/linker.h"
|
|
||||||
#include "gen/irstate.h"
|
#include "gen/irstate.h"
|
||||||
#include "gen/optimizer.h"
|
#include "gen/optimizer.h"
|
||||||
#include "gen/metadata.h"
|
#include "gen/metadata.h"
|
||||||
#include "gen/passes/Passes.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"
|
#include "gen/cl_helpers.h"
|
||||||
using namespace opts;
|
using namespace opts;
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,6 @@
|
||||||
#include "gen/optimizer.h"
|
#include "gen/optimizer.h"
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
extern llvm::cl::opt<bool> noVerify;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// fwd decl
|
// fwd decl
|
||||||
void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& Out,
|
void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& Out,
|
||||||
llvm::TargetMachine::CodeGenFileType fileType);
|
llvm::TargetMachine::CodeGenFileType fileType);
|
||||||
|
@ -42,7 +36,7 @@ void writeModule(llvm::Module* m, std::string filename)
|
||||||
bool reverify = ldc_optimize_module(m);
|
bool reverify = ldc_optimize_module(m);
|
||||||
|
|
||||||
// verify the llvm
|
// verify the llvm
|
||||||
if (!noVerify && reverify) {
|
if (!global.params.noVerify && reverify) {
|
||||||
std::string verifyErr;
|
std::string verifyErr;
|
||||||
Logger::println("Verifying module... again...");
|
Logger::println("Verifying module... again...");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
#include "ir/irmodule.h"
|
#include "ir/irmodule.h"
|
||||||
#include "ir/irtypestruct.h"
|
#include "ir/irtypestruct.h"
|
||||||
|
|
||||||
#include "gen/cl_options.h"
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static LLValue *DtoSlice(DValue *dval)
|
static LLValue *DtoSlice(DValue *dval)
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "gen/dvalue.h"
|
#include "gen/dvalue.h"
|
||||||
#include "gen/abi.h"
|
#include "gen/abi.h"
|
||||||
#include "gen/nested.h"
|
#include "gen/nested.h"
|
||||||
#include "gen/cl_options.h"
|
|
||||||
#include "gen/pragma.h"
|
#include "gen/pragma.h"
|
||||||
|
|
||||||
using namespace llvm::Attribute;
|
using namespace llvm::Attribute;
|
||||||
|
@ -510,7 +509,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
|
||||||
// parameter attributes
|
// parameter attributes
|
||||||
if (!fdecl->isIntrinsic()) {
|
if (!fdecl->isIntrinsic()) {
|
||||||
set_param_attrs(f, func, fdecl);
|
set_param_attrs(f, func, fdecl);
|
||||||
if (opts::disableRedZone) {
|
if (global.params.disableRedZone) {
|
||||||
func->addFnAttr(NoRedZone);
|
func->addFnAttr(NoRedZone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include "linkage.h"
|
#include "linkage.h"
|
||||||
#include "gen/cl_options.h"
|
|
||||||
|
|
||||||
LLGlobalValue::LinkageTypes templateLinkage;
|
LLGlobalValue::LinkageTypes templateLinkage;
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "gen/functions.h"
|
#include "gen/functions.h"
|
||||||
#include "gen/typeinf.h"
|
#include "gen/typeinf.h"
|
||||||
#include "gen/todebug.h"
|
#include "gen/todebug.h"
|
||||||
#include "gen/cl_options.h"
|
|
||||||
#include "gen/nested.h"
|
#include "gen/nested.h"
|
||||||
#include "ir/irmodule.h"
|
#include "ir/irmodule.h"
|
||||||
|
|
||||||
|
@ -1649,7 +1648,7 @@ bool mustDefineSymbol(Dsymbol* s)
|
||||||
TemplateInstance* tinst = DtoIsTemplateInstance(s);
|
TemplateInstance* tinst = DtoIsTemplateInstance(s);
|
||||||
if (tinst)
|
if (tinst)
|
||||||
{
|
{
|
||||||
if (!opts::singleObj)
|
if (!global.params.singleObj)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!tinst->emittedInModule)
|
if (!tinst->emittedInModule)
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include "gen/abi.h"
|
#include "gen/abi.h"
|
||||||
#include "gen/arrays.h"
|
#include "gen/arrays.h"
|
||||||
#include "gen/classes.h"
|
#include "gen/classes.h"
|
||||||
#include "gen/cl_options.h"
|
|
||||||
#include "gen/functions.h"
|
#include "gen/functions.h"
|
||||||
#include "gen/llvmhelpers.h"
|
#include "gen/llvmhelpers.h"
|
||||||
#include "gen/logger.h"
|
#include "gen/logger.h"
|
||||||
|
@ -39,13 +38,6 @@
|
||||||
#define NEW_MODULEINFO_LAYOUT 1
|
#define NEW_MODULEINFO_LAYOUT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
llvm::cl::opt<bool> 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<FuncDeclaration*> &funcs,
|
static llvm::Function* build_module_function(const std::string &name, const std::list<FuncDeclaration*> &funcs,
|
||||||
const std::list<VarDeclaration*> &gates = std::list<VarDeclaration*>())
|
const std::list<VarDeclaration*> &gates = std::list<VarDeclaration*>())
|
||||||
|
@ -276,7 +268,7 @@ llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context, Ir* sir)
|
||||||
sir->emitFunctionBodies();
|
sir->emitFunctionBodies();
|
||||||
|
|
||||||
// for singleobj-compilation, fully emit all seen template instances
|
// for singleobj-compilation, fully emit all seen template instances
|
||||||
if (opts::singleObj)
|
if (global.params.singleObj)
|
||||||
{
|
{
|
||||||
while (!ir.seenTemplateInstances.empty())
|
while (!ir.seenTemplateInstances.empty())
|
||||||
{
|
{
|
||||||
|
@ -297,7 +289,7 @@ llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context, Ir* sir)
|
||||||
genmoduleinfo();
|
genmoduleinfo();
|
||||||
|
|
||||||
// verify the llvm
|
// verify the llvm
|
||||||
if (!noVerify) {
|
if (!global.params.noVerify) {
|
||||||
std::string verifyErr;
|
std::string verifyErr;
|
||||||
Logger::println("Verifying module...");
|
Logger::println("Verifying module...");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue