23 #define CGOPT(TY, NAME) \ 24 static cl::opt<TY> *NAME##View; \ 25 TY codegen::get##NAME() { \ 26 assert(NAME##View && "RegisterCodeGenFlags not created."); \ 30 #define CGLIST(TY, NAME) \ 31 static cl::list<TY> *NAME##View; \ 32 std::vector<TY> codegen::get##NAME() { \ 33 assert(NAME##View && "RegisterCodeGenFlags not created."); \ 37 #define CGOPT_EXP(TY, NAME) \ 39 Optional<TY> codegen::getExplicit##NAME() { \ 40 if (NAME##View->getNumOccurrences()) { \ 41 TY res = *NAME##View; \ 47 CGOPT(std::string, MArch)
48 CGOPT(std::string, MCPU)
49 CGLIST(std::string, MAttrs)
56 CGOPT(
bool, EnableUnsafeFPMath)
57 CGOPT(
bool, EnableNoInfsFPMath)
58 CGOPT(
bool, EnableNoNaNsFPMath)
59 CGOPT(
bool, EnableNoSignedZerosFPMath)
60 CGOPT(
bool, EnableNoTrappingFPMath)
61 CGOPT(
bool, EnableAIXExtendedAltivecABI)
64 CGOPT(
bool, EnableHonorSignDependentRoundingFPMath)
67 CGOPT(
bool, DontPlaceZerosInBSS)
68 CGOPT(
bool, EnableGuaranteedTailCallOpt)
69 CGOPT(
bool, DisableTailCalls)
70 CGOPT(
bool, StackSymbolOrdering)
71 CGOPT(
unsigned, OverrideStackAlignment)
72 CGOPT(
bool, StackRealign)
73 CGOPT(std::string, TrapFuncName)
75 CGOPT(
bool, RelaxELFRelocations)
78 CGOPT(
bool, IgnoreXCOFFVisibility)
79 CGOPT(
bool, XCOFFTracebackTable)
80 CGOPT(std::string, BBSections)
81 CGOPT(std::string, StackProtectorGuard)
82 CGOPT(
unsigned, StackProtectorGuardOffset)
83 CGOPT(std::string, StackProtectorGuardReg)
84 CGOPT(
unsigned, TLSSize)
85 CGOPT(
bool, EmulatedTLS)
86 CGOPT(
bool, UniqueSectionNames)
87 CGOPT(
bool, UniqueBasicBlockSectionNames)
90 CGOPT(
bool, EnableStackSizeSection)
91 CGOPT(
bool, EnableAddrsig)
92 CGOPT(
bool, EmitCallSiteInfo)
94 CGOPT(
bool, EnableDebugEntryValues)
95 CGOPT(
bool, PseudoProbeForProfiling)
96 CGOPT(
bool, ValueTrackingVariableLocations)
97 CGOPT(
bool, ForceDwarfFrameSection)
98 CGOPT(
bool, XRayOmitFunctionIndex)
101 #define CGBINDOPT(NAME) \ 103 NAME##View = std::addressof(NAME); \ 107 "march",
cl::desc(
"Architecture to generate code for (see --version)"));
111 "mcpu",
cl::desc(
"Target a specific cpu type (-mcpu=help for details)"),
117 cl::desc(
"Target specific attributes (-mattr=help for details)"),
122 "relocation-model",
cl::desc(
"Choose relocation model"),
126 "Fully relocatable, position independent code"),
128 "Relocatable external references, non-relocatable code"),
131 "Code and read-only data relocatable, accessed PC-relative"),
134 "Read-write data relocatable, accessed relative to static base"),
136 "Combination of ropi and rwpi")));
140 "thread-model",
cl::desc(
"Choose threading model"),
148 "code-model",
cl::desc(
"Choose code model"),
157 "exception-model",
cl::desc(
"exception model"),
161 "default exception handling model"),
163 "DWARF-like CFI based exception handling"),
165 "SjLj exception handling"),
168 "Windows exception model"),
170 "WebAssembly exception handling")));
176 "Choose a file type (not all types are supported by all targets):"),
180 "Emit a native object ('.o') file"),
182 "Emit nothing, for performance testing")));
187 cl::desc(
"Specify frame pointer elimination optimization"),
191 "Disable frame pointer elimination"),
193 "Disable frame pointer elimination for non-leaf frame"),
195 "Enable frame pointer elimination")));
199 "enable-unsafe-fp-math",
200 cl::desc(
"Enable optimizations that may decrease FP precision"),
205 "enable-no-infs-fp-math",
206 cl::desc(
"Enable FP math optimizations that assume no +-Infs"),
211 "enable-no-nans-fp-math",
212 cl::desc(
"Enable FP math optimizations that assume no NaNs"),
217 "enable-no-signed-zeros-fp-math",
218 cl::desc(
"Enable FP math optimizations that assume " 219 "the sign of 0 is insignificant"),
224 "enable-no-trapping-fp-math",
225 cl::desc(
"Enable setting the FP exceptions build " 226 "attribute not to use exceptions"),
230 static const auto DenormFlagEnumOptions =
232 "IEEE 754 denormal numbers"),
234 "the sign of a flushed-to-zero number is preserved " 237 "denormals are flushed to positive zero"));
242 cl::desc(
"Select which denormal numbers the code is permitted to require"),
244 DenormFlagEnumOptions);
248 "denormal-fp-math-f32",
249 cl::desc(
"Select which denormal numbers the code is permitted to require for float"),
251 DenormFlagEnumOptions);
255 "enable-sign-dependent-rounding-fp-math",
cl::Hidden,
256 cl::desc(
"Force codegen to assume rounding mode can change dynamically"),
258 CGBINDOPT(EnableHonorSignDependentRoundingFPMath);
261 "float-abi",
cl::desc(
"Choose float ABI type"),
264 "Target default float ABI type"),
266 "Soft float ABI (implied by -soft-float)"),
268 "Hard float ABI (uses FP registers)")));
272 "fp-contract",
cl::desc(
"Enable aggressive formation of fused FP ops"),
276 "Fuse FP ops whenever profitable"),
279 "Only fuse FP ops when the result won't be affected.")));
283 "nozero-initialized-in-bss",
284 cl::desc(
"Don't place zero-initialized symbols into bss section"),
289 "vec-extabi",
cl::desc(
"Enable the AIX Extended Altivec ABI."),
296 "Turn fastcc calls into tail calls by (potentially) changing ABI."),
305 "stack-symbol-ordering",
cl::desc(
"Order local stack symbols."),
310 "stack-alignment",
cl::desc(
"Override default stack alignment"),
316 cl::desc(
"Force align the stack to the minimum alignment"),
322 cl::desc(
"Emit a call to trap function rather than a trap instruction"),
327 cl::desc(
"Use .ctors instead of .init_array."),
332 "relax-elf-relocations",
334 "Emit GOTPCRELX/REX_GOTPCRELX instead of GOTPCREL on x86-64 ELF"),
339 "data-sections",
cl::desc(
"Emit data into separate sections"),
344 "function-sections",
cl::desc(
"Emit functions into separate sections"),
349 "ignore-xcoff-visibility",
350 cl::desc(
"Not emit the visibility attribute for asm in AIX OS or give " 351 "all symbols 'unspecified' visibility in XCOFF object file"),
356 "xcoff-traceback-table",
cl::desc(
"Emit the XCOFF traceback table"),
361 "basic-block-sections",
362 cl::desc(
"Emit basic blocks into separate sections"),
368 "stack-protector-guard",
cl::desc(
"Stack protector guard mode"),
373 "stack-protector-guard-reg",
cl::desc(
"Stack protector guard register"),
378 "stack-protector-guard-offset",
cl::desc(
"Stack protector guard offset"),
391 "unique-section-names",
cl::desc(
"Give unique names to every section"),
396 "unique-basic-block-section-names",
397 cl::desc(
"Give unique names to every basic block section"),
402 "meabi",
cl::desc(
"Set EABI type (default depends on triple):"),
412 "debugger-tune",
cl::desc(
"Tune debug info for a particular debugger"),
421 "stack-size-section",
422 cl::desc(
"Emit a section containing stack size metadata"),
427 "addrsig",
cl::desc(
"Emit an address-significance table"),
432 "emit-call-site-info",
434 "Emit call site debug information, if debug information is enabled."),
439 "debug-entry-values",
440 cl::desc(
"Enable debug info for the debug entry values."),
445 "pseudo-probe-for-profiling",
cl::desc(
"Emit pseudo probes for AutoFDO"),
450 "experimental-debug-variable-locations",
451 cl::desc(
"Use experimental new value-tracking variable locations"),
453 CGBINDOPT(ValueTrackingVariableLocations);
456 "split-machine-functions",
457 cl::desc(
"Split out cold basic blocks from machine functions based on " 458 "profile information"),
463 "force-dwarf-frame-section",
468 "no-xray-index",
cl::desc(
"Don't emit xray_fn_idx section"),
489 errs() <<
"Error loading basic block sections function list file: " 490 << MBOrErr.
getError().message() <<
"\n";
508 errs() <<
"error illegal stack protector guard mode: " 509 << MBOrErr.
getError().message() <<
"\n";
598 for (
auto &
F : HostFeatures)
618 for (
auto &
F : HostFeatures)
629 B.addAttribute(
Name, Val ?
"true" :
"false");
632 #define HANDLE_BOOL_ATTR(CL, AttrName) \ 634 if (CL->getNumOccurrences() > 0 && !F.hasFnAttribute(AttrName)) \ 635 renderBoolStringAttr(NewAttrs, AttrName, *CL); \ 642 auto &Ctx =
F.getContext();
646 if (!CPU.
empty() && !
F.hasFnAttribute(
"target-cpu"))
648 if (!Features.
empty()) {
651 F.getFnAttribute(
"target-features").getValueAsString();
652 if (OldFeatures.
empty())
657 Appended.
append(Features);
661 if (FramePointerUsageView->getNumOccurrences() > 0 &&
662 !
F.hasFnAttribute(
"frame-pointer")) {
670 if (DisableTailCallsView->getNumOccurrences() > 0)
681 if (DenormalFPMathView->getNumOccurrences() > 0 &&
682 !
F.hasFnAttribute(
"denormal-fp-math")) {
690 if (DenormalFP32MathView->getNumOccurrences() > 0 &&
691 !
F.hasFnAttribute(
"denormal-fp-math-f32")) {
696 "denormal-fp-math-f32",
700 if (TrapFuncNameView->getNumOccurrences() > 0)
703 if (
auto *Call = dyn_cast<CallInst>(&
I))
704 if (
const auto *
F = Call->getCalledFunction())
705 if (
F->getIntrinsicID() == Intrinsic::debugtrap ||
706 F->getIntrinsicID() == Intrinsic::trap)
unsigned StackSymbolOrdering
StackSymbolOrdering - When true, this will allow CodeGen to order the local stack symbols (for code s...
ThreadModel::Model getThreadModel()
bool getFunctionSections()
unsigned NoTrappingFPMath
NoTrappingFPMath - This flag is enabled when the -enable-no-trapping-fp-math is specified on the comm...
Represents either an error or a value T.
bool getPseudoProbeForProfiling()
MCTargetOptions MCOptions
Machine level options.
This class represents lattice values for constants.
bool getEmitCallSiteInfo()
unsigned EnableDebugEntryValues
When set to true, the EnableDebugEntryValues option forces production of debug entry values even if t...
A Module instance is used to store all the information related to an LLVM module.
unsigned EmitCallSiteInfo
The flag enables call site info production.
EABI EABIVersion
EABIVersion - This flag specifies the EABI version.
unsigned DataSections
Emit data into separate sections.
void push_back(const T &Elt)
setjmp/longjmp based exceptions
llvm::FloatABI::ABIType getFloatABIForCalls()
constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION
llvm::EABI getEABIVersion()
bool getUniqueSectionNames()
bool getForceDwarfFrameSection()
std::string getString() const
Returns features as a string.
unsigned EnableAIXExtendedAltivecABI
EnableAIXExtendedAltivecABI - This flag returns true when -vec-extabi is specified.
Create this object with static storage to register codegen-related command line options.
ThreadModel::Model ThreadModel
ThreadModel - This flag specifies the type of threading model to assume for things like atomics.
unsigned ValueTrackingVariableLocations
std::vector< std::string > getFeatureList()
DebuggerKind
Identify a debugger for "tuning" the debug info.
TargetOptions InitTargetOptionsFromCodeGenFlags(const llvm::Triple &TheTriple)
Common utility function tightly tied to the options listed here.
std::string getBBSections()
unsigned getOverrideStackAlignment()
bool getRelaxELFRelocations()
bool getEnableHonorSignDependentRoundingFPMath()
bool getValueTrackingVariableLocations()
ExceptionHandling ExceptionModel
What exception model to use.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
void AddFeature(StringRef String, bool Enable=true)
Adds Features.
#define CGOPT_EXP(TY, NAME)
StringRef toStringRef(const Optional< DWARFFormValue > &V, StringRef Default={})
Take an optional DWARFFormValue and try to extract a string value from it.
MCTargetOptions InitMCTargetOptionsFromFlags()
unsigned NoNaNsFPMath
NoNaNsFPMath - This flag is enabled when the -enable-no-nans-fp-math flag is specified on the command...
void setFunctionAttributes(StringRef CPU, StringRef Features, Function &F)
Set function attributes of function F based on CPU, Features, and command line flags.
unsigned EnableMachineFunctionSplitter
Enables the MachineFunctionSplitter pass.
bool getDisableTailCalls()
unsigned FunctionSections
Emit functions into separate sections.
unsigned UniqueSectionNames
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
unsigned XCOFFTracebackTable
Emit XCOFF traceback table.
bool getXCOFFTracebackTable()
static void codegen(Module *M, llvm::raw_pwrite_stream &OS, function_ref< std::unique_ptr< TargetMachine >()> TMFactory, CodeGenFileType FileType)
WebAssembly Exception Handling.
void append(in_iter S, in_iter E)
Append from an iterator pair.
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
DebuggerKind DebuggerTuning
Which debugger to tune for.
unsigned StackProtectorGuardOffset
Stack protector guard offset to use.
initializer< Ty > init(const Ty &Val)
const std::vector< std::string > & getFeatures() const
Returns the vector of individual subtarget features.
unsigned UnsafeFPMath
UnsafeFPMath - This flag is enabled when the -enable-unsafe-fp-math flag is specified on the command ...
FPOpFusion::FPOpFusionMode AllowFPOpFusion
AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned UniqueBasicBlockSectionNames
Use unique names for basic block sections.
unsigned ExplicitEmulatedTLS
Whether -emulated-tls or -no-emulated-tls is set.
bool getEnableUnsafeFPMath()
unsigned TLSSize
Bit size of immediate TLS offsets (0 == use the default).
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
static cl::opt< bool > EnableMachineFunctionSplitter("enable-split-machine-functions", cl::Hidden, cl::desc("Split out cold blocks from machine functions based on profile " "information."))
Enable the machine function splitter pass.
llvm::StackProtectorGuards getStackProtectorGuardMode(llvm::TargetOptions &Options)
std::error_code getError() const
unsigned EmitStackSizeSection
Emit section containing metadata on function stack sizes.
IEEE-754 denormal numbers preserved.
unsigned GuaranteedTailCallOpt
GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is specified on the commandline.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void setFPDenormalMode(DenormalMode Mode)
unsigned PseudoProbeForProfiling
Emit pseudo probes into the binary for sample profiling.
unsigned NoInfsFPMath
NoInfsFPMath - This flag is enabled when the -enable-no-infs-fp-math flag is specified on the command...
llvm::FPOpFusion::FPOpFusionMode getFuseFPOps()
unsigned NoZerosInBSS
NoZerosInBSS - By default some codegens place zero-initialized data to .bss section.
#define HANDLE_BOOL_ATTR(CL, AttrName)
llvm::FramePointer::FP getFramePointerUsage()
unsigned ForceDwarfFrameSection
Emit DWARF debug frame section.
Triple - Helper class for working with autoconf configuration names.
Represent subnormal handling kind for floating point instruction inputs and outputs.
BasicBlockSection BBSections
Emit basic blocks into separate sections.
unsigned getStackProtectorGuardOffset()
void renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val)
Optional< bool > getExplicitDataSections()
FileType
Defines the file type this file represents.
bool getEnableNoInfsFPMath()
bool getStackSymbolOrdering()
unsigned UseInitArray
UseInitArray - Use .init_array instead of .ctors for static constructors.
bool getEnableMachineFunctionSplitter()
bool getEnableNoTrappingFPMath()
bool getUniqueBasicBlockSectionNames()
Module.h This file contains the declarations for the Module class.
llvm::DebuggerKind getDebuggerTuningOpt()
unsigned XRayOmitFunctionIndex
Emit XRay Function Index section.
unsigned EmitAddrsig
Emit address-significance table.
bool getEnableStackSizeSection()
unsigned StackAlignmentOverride
StackAlignmentOverride - Override default stack alignment for target.
bool getDontPlaceZerosInBSS()
unsigned IgnoreXCOFFVisibility
Do not emit visibility attribute for xcoff.
DenormalModeKind
Represent handled modes for denormal (aka subnormal) modes in the floating point environment.
The sign of a flushed-to-zero number is preserved in the sign of 0.
Manages the enabling and disabling of subtarget specific features.
unsigned EmulatedTLS
EmulatedTLS - This flag enables emulated TLS model, using emutls function in the runtime library.
DenormalMode::DenormalModeKind getDenormalFP32Math()
unsigned RelaxELFRelocations
std::string getStackProtectorGuard()
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
std::string StackProtectorGuardReg
Stack protector guard reg to use, e.g. usually fs or gs in X86.
bool getEnableNoSignedZerosFPMath()
StringRef getHostCPUName()
getHostCPUName - Get the LLVM name for the host CPU.
Windows Exception Handling.
bool getXRayOmitFunctionIndex()
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
Create this object with static storage to register mc-related command line options.
bool getEnableDebugEntryValues()
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
std::shared_ptr< MemoryBuffer > BBSectionsFuncListBuf
Memory Buffer that contains information on sampled basic blocks and used to selectively generate basi...
bool getEnableNoNaNsFPMath()
std::vector< std::string > getMAttrs()
unsigned HonorSignDependentRoundingFPMathOption
HonorSignDependentRoundingFPMath - This returns true when the -enable-sign-dependent-rounding-fp-math...
bool hasDefaultDataSections() const
Tests whether the target uses -data-sections as default.
Denormals are flushed to positive zero.
StackProtectorGuards StackProtectorGuard
Stack protector guard mode to use, e.g. tls, global.
DenormalMode::DenormalModeKind getDenormalFPMath()
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
unsigned NoSignedZerosFPMath
NoSignedZerosFPMath - This flag is enabled when the -enable-no-signed-zeros-fp-math is specified on t...
StringRef - Represent a constant reference to a string, i.e.
std::string getTrapFuncName()
llvm::ExceptionHandling getExceptionModel()
std::string getStackProtectorGuardReg()
DWARF-like instruction based exceptions.
bool getEnableGuaranteedTailCallOpt()
llvm::BasicBlockSection getBBSectionsMode(llvm::TargetOptions &Options)
std::string getFeaturesStr()
bool getIgnoreXCOFFVisibility()
bool getEnableAIXExtendedAltivecABI()
FloatABI::ABIType FloatABIType
FloatABIType - This setting is set by -float-abi=xxx option is specfied on the command line.
bool getHostCPUFeatures(StringMap< bool, MallocAllocator > &Features)
getHostCPUFeatures - Get the LLVM names for the host CPU features.