mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 03:16:05 +03:00

I.e., llvm/CodeGen/CommandFlags.h which in turn includes llvm/MC/MCTargetOptionsCommandFlags.h. This gets rid of a few duplicates on our side and includes about 35 (depending on LLVM version) new command-line options. LLVM provides a helper function to set up the TargetOptions according to (most of) these options. Newer LLVM versions may add new options and we'll automatically inherit them, including setting up the TargetOptions accordingly. I did my best (TM) to remove a few unused/undesirable options and hide all remaining new ones except for `-fp-contract`. The lists will need to be tweaked from time to time.
125 lines
3.6 KiB
C++
125 lines
3.6 KiB
C++
//===-- driver/cl_options.h - LDC command line options ----------*- C++ -*-===//
|
||
//
|
||
// LDC – the LLVM D compiler
|
||
//
|
||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||
// file for details.
|
||
//
|
||
//===----------------------------------------------------------------------===//
|
||
//
|
||
// Defines the LDC command line options as handled using the LLVM command
|
||
// line parsing library.
|
||
//
|
||
//===----------------------------------------------------------------------===//
|
||
|
||
#ifndef LDC_DRIVER_CL_OPTIONS_H
|
||
#define LDC_DRIVER_CL_OPTIONS_H
|
||
|
||
#include "driver/cl_options-llvm.h"
|
||
#include "driver/targetmachine.h"
|
||
#include "gen/cl_helpers.h"
|
||
#include "llvm/ADT/SmallVector.h"
|
||
#include "llvm/Support/CodeGen.h"
|
||
#include "llvm/Support/CommandLine.h"
|
||
#include <deque>
|
||
#include <vector>
|
||
|
||
// FIXME: Just for the BOUDNSCHECK enum; this is not pretty
|
||
#include "globals.h"
|
||
|
||
namespace llvm {
|
||
class FastMathFlags;
|
||
class TargetMachine;
|
||
}
|
||
|
||
namespace opts {
|
||
namespace cl = llvm::cl;
|
||
|
||
/// Stores the commandline arguments list, including the ones specified by the
|
||
/// config and response files.
|
||
extern llvm::SmallVector<const char *, 32> allArguments;
|
||
|
||
/* Mostly generated with the following command:
|
||
egrep -e '^(cl::|#if|#e)' gen/cl_options.cpp \
|
||
| sed -re 's/^(cl::.*)\(.*$/ extern \1;/'
|
||
*/
|
||
extern cl::list<std::string> fileList;
|
||
extern cl::list<std::string> runargs;
|
||
extern cl::opt<bool> invokedByLDMD;
|
||
extern cl::opt<bool> compileOnly;
|
||
extern cl::opt<bool> useDIP1000;
|
||
extern cl::opt<bool> noAsm;
|
||
extern cl::opt<bool> dontWriteObj;
|
||
extern cl::opt<std::string> objectFile;
|
||
extern cl::opt<std::string> objectDir;
|
||
extern cl::opt<std::string> soname;
|
||
extern cl::opt<bool> output_bc;
|
||
extern cl::opt<bool> output_ll;
|
||
extern cl::opt<bool> output_s;
|
||
extern cl::opt<cl::boolOrDefault> output_o;
|
||
extern cl::opt<std::string> ddocDir;
|
||
extern cl::opt<std::string> ddocFile;
|
||
extern cl::opt<std::string> jsonFile;
|
||
extern cl::opt<std::string> hdrDir;
|
||
extern cl::opt<std::string> hdrFile;
|
||
extern cl::opt<bool> hdrKeepAllBodies;
|
||
extern cl::list<std::string> versions;
|
||
extern cl::list<std::string> transitions;
|
||
extern cl::opt<std::string> moduleDeps;
|
||
extern cl::opt<std::string> cacheDir;
|
||
extern cl::list<std::string> linkerSwitches;
|
||
extern cl::list<std::string> ccSwitches;
|
||
|
||
extern cl::opt<bool> m32bits;
|
||
extern cl::opt<bool> m64bits;
|
||
extern cl::opt<std::string> mTargetTriple;
|
||
extern cl::opt<std::string> mABI;
|
||
extern FloatABI::Type floatABI;
|
||
extern cl::opt<bool> linkonceTemplates;
|
||
extern cl::opt<bool> disableLinkerStripDead;
|
||
|
||
// Math options
|
||
extern bool fFastMath;
|
||
extern llvm::FastMathFlags defaultFMF;
|
||
void setDefaultMathOptions(llvm::TargetOptions &targetOptions);
|
||
|
||
extern cl::opt<BOUNDSCHECK> boundsCheck;
|
||
extern bool nonSafeBoundsChecks;
|
||
|
||
#if LDC_WITH_PGO
|
||
extern cl::opt<std::string> genfileInstrProf;
|
||
extern cl::opt<std::string> usefileInstrProf;
|
||
#endif
|
||
extern cl::opt<bool> instrumentFunctions;
|
||
|
||
// Arguments to -d-debug
|
||
extern std::vector<std::string> debugArgs;
|
||
// Arguments to -run
|
||
|
||
void createClashingOptions();
|
||
void hideLLVMOptions();
|
||
|
||
#if LDC_LLVM_VER >= 309
|
||
// LTO options
|
||
enum LTOKind {
|
||
LTO_None,
|
||
LTO_Full,
|
||
LTO_Thin,
|
||
};
|
||
extern cl::opt<LTOKind> ltoMode;
|
||
inline bool isUsingLTO() { return ltoMode != LTO_None; }
|
||
inline bool isUsingThinLTO() { return ltoMode == LTO_Thin; }
|
||
#else
|
||
inline bool isUsingLTO() { return false; }
|
||
inline bool isUsingThinLTO() { return false; }
|
||
#endif
|
||
|
||
#if LDC_LLVM_VER >= 400
|
||
extern cl::opt<std::string> saveOptimizationRecord;
|
||
#endif
|
||
#if LDC_LLVM_SUPPORTED_TARGET_SPIRV || LDC_LLVM_SUPPORTED_TARGET_NVPTX
|
||
extern cl::list<std::string> dcomputeTargets;
|
||
extern cl::opt<std::string> dcomputeFilePrefix;
|
||
#endif
|
||
}
|
||
#endif
|