Go to the documentation of this file.
29 #define CGOPT(TY, NAME) \
30 static cl::opt<TY> *NAME##View; \
31 TY codegen::get##NAME() { \
32 assert(NAME##View && "RegisterCodeGenFlags not created."); \
36 #define CGLIST(TY, NAME) \
37 static cl::list<TY> *NAME##View; \
38 std::vector<TY> codegen::get##NAME() { \
39 assert(NAME##View && "RegisterCodeGenFlags not created."); \
43 #define CGOPT_EXP(TY, NAME) \
45 Optional<TY> codegen::getExplicit##NAME() { \
46 if (NAME##View->getNumOccurrences()) { \
47 TY res = *NAME##View; \
53 CGOPT(std::string, MArch)
54 CGOPT(std::string, MCPU)
55 CGLIST(std::string, MAttrs)
62 CGOPT(
bool, EnableUnsafeFPMath)
63 CGOPT(
bool, EnableNoInfsFPMath)
64 CGOPT(
bool, EnableNoNaNsFPMath)
65 CGOPT(
bool, EnableNoSignedZerosFPMath)
66 CGOPT(
bool, EnableApproxFuncFPMath)
67 CGOPT(
bool, EnableNoTrappingFPMath)
68 CGOPT(
bool, EnableAIXExtendedAltivecABI)
71 CGOPT(
bool, EnableHonorSignDependentRoundingFPMath)
75 CGOPT(
bool, DontPlaceZerosInBSS)
76 CGOPT(
bool, EnableGuaranteedTailCallOpt)
77 CGOPT(
bool, DisableTailCalls)
78 CGOPT(
bool, StackSymbolOrdering)
79 CGOPT(
bool, StackRealign)
80 CGOPT(std::string, TrapFuncName)
82 CGOPT(
bool, LowerGlobalDtorsViaCxaAtExit)
83 CGOPT(
bool, RelaxELFRelocations)
86 CGOPT(
bool, IgnoreXCOFFVisibility)
87 CGOPT(
bool, XCOFFTracebackTable)
88 CGOPT(std::string, BBSections)
89 CGOPT(
unsigned, TLSSize)
90 CGOPT(
bool, EmulatedTLS)
91 CGOPT(
bool, UniqueSectionNames)
92 CGOPT(
bool, UniqueBasicBlockSectionNames)
95 CGOPT(
bool, EnableStackSizeSection)
96 CGOPT(
bool, EnableAddrsig)
97 CGOPT(
bool, EmitCallSiteInfo)
99 CGOPT(
bool, EnableDebugEntryValues)
100 CGOPT(
bool, ForceDwarfFrameSection)
101 CGOPT(
bool, XRayOmitFunctionIndex)
102 CGOPT(
bool, DebugStrictDwarf)
103 CGOPT(
unsigned, AlignLoops)
104 CGOPT(
bool, JMCInstrument)
107 #define CGBINDOPT(NAME) \
109 NAME##View = std::addressof(NAME); \
113 "march",
cl::desc(
"Architecture to generate code for (see --version)"));
117 "mcpu",
cl::desc(
"Target a specific cpu type (-mcpu=help for details)"),
123 cl::desc(
"Target specific attributes (-mattr=help for details)"),
128 "relocation-model",
cl::desc(
"Choose relocation model"),
132 "Fully relocatable, position independent code"),
134 "Relocatable external references, non-relocatable code"),
137 "Code and read-only data relocatable, accessed PC-relative"),
140 "Read-write data relocatable, accessed relative to static base"),
142 "Combination of ropi and rwpi")));
146 "thread-model",
cl::desc(
"Choose threading model"),
154 "code-model",
cl::desc(
"Choose code model"),
163 "exception-model",
cl::desc(
"exception model"),
167 "default exception handling model"),
169 "DWARF-like CFI based exception handling"),
171 "SjLj exception handling"),
174 "Windows exception model"),
176 "WebAssembly exception handling")));
182 "Choose a file type (not all types are supported by all targets):"),
186 "Emit a native object ('.o') file"),
188 "Emit nothing, for performance testing")));
193 cl::desc(
"Specify frame pointer elimination optimization"),
197 "Disable frame pointer elimination"),
199 "Disable frame pointer elimination for non-leaf frame"),
201 "Enable frame pointer elimination")));
205 "enable-unsafe-fp-math",
206 cl::desc(
"Enable optimizations that may decrease FP precision"),
211 "enable-no-infs-fp-math",
212 cl::desc(
"Enable FP math optimizations that assume no +-Infs"),
217 "enable-no-nans-fp-math",
218 cl::desc(
"Enable FP math optimizations that assume no NaNs"),
223 "enable-no-signed-zeros-fp-math",
224 cl::desc(
"Enable FP math optimizations that assume "
225 "the sign of 0 is insignificant"),
230 "enable-approx-func-fp-math",
231 cl::desc(
"Enable FP math optimizations that assume approx func"),
236 "enable-no-trapping-fp-math",
237 cl::desc(
"Enable setting the FP exceptions build "
238 "attribute not to use exceptions"),
242 static const auto DenormFlagEnumOptions =
244 "IEEE 754 denormal numbers"),
246 "the sign of a flushed-to-zero number is preserved "
249 "denormals are flushed to positive zero"));
254 cl::desc(
"Select which denormal numbers the code is permitted to require"),
256 DenormFlagEnumOptions);
260 "denormal-fp-math-f32",
261 cl::desc(
"Select which denormal numbers the code is permitted to require for float"),
263 DenormFlagEnumOptions);
267 "enable-sign-dependent-rounding-fp-math",
cl::Hidden,
268 cl::desc(
"Force codegen to assume rounding mode can change dynamically"),
270 CGBINDOPT(EnableHonorSignDependentRoundingFPMath);
273 "float-abi",
cl::desc(
"Choose float ABI type"),
276 "Target default float ABI type"),
278 "Soft float ABI (implied by -soft-float)"),
280 "Hard float ABI (uses FP registers)")));
284 "fp-contract",
cl::desc(
"Enable aggressive formation of fused FP ops"),
288 "Fuse FP ops whenever profitable"),
291 "Only fuse FP ops when the result won't be affected.")));
296 cl::desc(
"Determine when the Swift async frame pointer should be set"),
299 "Determine based on deployment target"),
301 "Always set the bit"),
303 "Never set the bit")));
307 "nozero-initialized-in-bss",
308 cl::desc(
"Don't place zero-initialized symbols into bss section"),
313 "vec-extabi",
cl::desc(
"Enable the AIX Extended Altivec ABI."),
320 "Turn fastcc calls into tail calls by (potentially) changing ABI."),
329 "stack-symbol-ordering",
cl::desc(
"Order local stack symbols."),
335 cl::desc(
"Force align the stack to the minimum alignment"),
341 cl::desc(
"Emit a call to trap function rather than a trap instruction"),
346 cl::desc(
"Use .ctors instead of .init_array."),
351 "lower-global-dtors-via-cxa-atexit",
352 cl::desc(
"Lower llvm.global_dtors (global destructors) via __cxa_atexit"),
357 "relax-elf-relocations",
359 "Emit GOTPCRELX/REX_GOTPCRELX instead of GOTPCREL on x86-64 ELF"),
364 "data-sections",
cl::desc(
"Emit data into separate sections"),
369 "function-sections",
cl::desc(
"Emit functions into separate sections"),
374 "ignore-xcoff-visibility",
375 cl::desc(
"Not emit the visibility attribute for asm in AIX OS or give "
376 "all symbols 'unspecified' visibility in XCOFF object file"),
381 "xcoff-traceback-table",
cl::desc(
"Emit the XCOFF traceback table"),
386 "basic-block-sections",
387 cl::desc(
"Emit basic blocks into separate sections"),
401 "unique-section-names",
cl::desc(
"Give unique names to every section"),
406 "unique-basic-block-section-names",
407 cl::desc(
"Give unique names to every basic block section"),
412 "meabi",
cl::desc(
"Set EABI type (default depends on triple):"),
422 "debugger-tune",
cl::desc(
"Tune debug info for a particular debugger"),
432 "stack-size-section",
433 cl::desc(
"Emit a section containing stack size metadata"),
438 "addrsig",
cl::desc(
"Emit an address-significance table"),
443 "emit-call-site-info",
445 "Emit call site debug information, if debug information is enabled."),
450 "debug-entry-values",
451 cl::desc(
"Enable debug info for the debug entry values."),
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"),
477 cl::desc(
"Default alignment for loops"));
481 "enable-jmc-instrument",
482 cl::desc(
"Instrument functions with a call to __CheckForDebuggerJustMyCode"),
503 errs() <<
"Error loading basic block sections function list file: "
504 << MBOrErr.
getError().message() <<
"\n";
530 Options.HonorSignDependentRoundingFPMathOption =
551 Options.ExplicitEmulatedTLS = EmulatedTLSView->getNumOccurrences() > 0;
593 for (
auto &
F : HostFeatures)
613 for (
auto &
F : HostFeatures)
624 B.addAttribute(
Name, Val ?
"true" :
"false");
627 #define HANDLE_BOOL_ATTR(CL, AttrName) \
629 if (CL->getNumOccurrences() > 0 && !F.hasFnAttribute(AttrName)) \
630 renderBoolStringAttr(NewAttrs, AttrName, *CL); \
637 auto &Ctx =
F.getContext();
641 if (!CPU.
empty() && !
F.hasFnAttribute(
"target-cpu"))
643 if (!Features.
empty()) {
646 F.getFnAttribute(
"target-features").getValueAsString();
647 if (OldFeatures.
empty())
651 Appended.push_back(
',');
652 Appended.
append(Features);
656 if (FramePointerUsageView->getNumOccurrences() > 0 &&
657 !
F.hasFnAttribute(
"frame-pointer")) {
665 if (DisableTailCallsView->getNumOccurrences() > 0)
677 if (DenormalFPMathView->getNumOccurrences() > 0 &&
678 !
F.hasFnAttribute(
"denormal-fp-math")) {
686 if (DenormalFP32MathView->getNumOccurrences() > 0 &&
687 !
F.hasFnAttribute(
"denormal-fp-math-f32")) {
692 "denormal-fp-math-f32",
696 if (TrapFuncNameView->getNumOccurrences() > 0)
699 if (
auto *Call = dyn_cast<CallInst>(&
I))
700 if (
const auto *
F = Call->getCalledFunction())
701 if (
F->getIntrinsicID() == Intrinsic::debugtrap ||
702 F->getIntrinsicID() == Intrinsic::trap)
707 F.setAttributes(
Attrs.addFnAttributes(Ctx, NewAttrs));
DenormalMode::DenormalModeKind getDenormalFP32Math()
This is an optimization pass for GlobalISel generic memory operations.
bool getDontPlaceZerosInBSS()
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
DebuggerKind
Identify a debugger for "tuning" the debug info.
@ SjLj
setjmp/longjmp based exceptions
bool getDisableTailCalls()
void AddFeature(StringRef String, bool Enable=true)
Adds Features.
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
Optional< bool > getExplicitDataSections()
Since we know that Vector is byte aligned and we know the element offset of we should change the load into a lve *x instead of doing a load store lve *x sequence Implement passing vectors by value into calls and receiving them as arguments GCC apparently tries to codegen
TargetOptions InitTargetOptionsFromCodeGenFlags(const llvm::Triple &TheTriple)
Common utility function tightly tied to the options listed here.
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.
bool getEnableNoTrappingFPMath()
Triple - Helper class for working with autoconf configuration names.
std::string getTrapFuncName()
bool getHostCPUFeatures(StringMap< bool, MallocAllocator > &Features)
getHostCPUFeatures - Get the LLVM names for the host CPU features.
llvm::ExceptionHandling getExceptionModel()
DenormalMode::DenormalModeKind getDenormalFPMath()
MCTargetOptions InitMCTargetOptionsFromFlags()
bool getEnableApproxFuncFPMath()
bool getLowerGlobalDtorsViaCxaAtExit()
std::string getFeaturesStr()
bool getEnableMachineFunctionSplitter()
bool hasDefaultDataSections() const
Tests whether the target uses -data-sections as default.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
@ GDB
Tune debug info for gdb.
bool getEnableNoSignedZerosFPMath()
llvm::FloatABI::ABIType getFloatABIForCalls()
@ Never
Never set the bit.
bool getFunctionSections()
bool getStackSymbolOrdering()
bool getXRayOmitFunctionIndex()
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
llvm::BasicBlockSection getBBSectionsMode(llvm::TargetOptions &Options)
llvm::DebuggerKind getDebuggerTuningOpt()
void renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val)
SwiftAsyncFramePointerMode getSwiftAsyncFramePointer()
const std::vector< std::string > & getFeatures() const
Returns the vector of individual subtarget features.
Manages the enabling and disabling of subtarget specific features.
ThreadModel::Model getThreadModel()
std::error_code getError() const
StringRef toStringRef(const Optional< DWARFFormValue > &V, StringRef Default={})
Take an optional DWARFFormValue and try to extract a string value from it.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
@ Wasm
WebAssembly Exception Handling.
bool getEnableUnsafeFPMath()
bool getEnableNoNaNsFPMath()
DenormalModeKind
Represent handled modes for denormal (aka subnormal) modes in the floating point environment.
FileType
Defines the file type this file represents.
@ DBX
Tune debug info for dbx.
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
void append(StringRef RHS)
Append from a StringRef.
std::string getString() const
Returns features as a string.
bool getEnableGuaranteedTailCallOpt()
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
bool getIgnoreXCOFFVisibility()
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
bool getEnableNoInfsFPMath()
bool getEnableHonorSignDependentRoundingFPMath()
bool getEnableStackSizeSection()
std::vector< std::string > getFeatureList()
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Represent subnormal handling kind for floating point instruction inputs and outputs.
initializer< Ty > init(const Ty &Val)
bool getUniqueBasicBlockSectionNames()
#define HANDLE_BOOL_ATTR(CL, AttrName)
#define CGOPT_EXP(TY, NAME)
A Module instance is used to store all the information related to an LLVM module.
@ IEEE
IEEE-754 denormal numbers preserved.
std::vector< std::string > getMAttrs()
llvm::EABI getEABIVersion()
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
StringRef - Represent a constant reference to a string, i.e.
@ Default
No specific tuning requested.
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
@ DeploymentBased
Determine whether to set the bit statically or dynamically based on the deployment target.
@ PositiveZero
Denormals are flushed to positive zero.
llvm::FPOpFusion::FPOpFusionMode getFuseFPOps()
void setFunctionAttributes(StringRef CPU, StringRef Features, Function &F)
Set function attributes of function F based on CPU, Features, and command line flags.
bool getDebugStrictDwarf()
Create this object with static storage to register mc-related command line options.
bool getRelaxELFRelocations()
bool getUniqueSectionNames()
bool getEnableDebugEntryValues()
@ WinEH
Windows Exception Handling.
bool getEmitCallSiteInfo()
@ None
No exception support.
bool getForceDwarfFrameSection()
Represents either an error or a value T.
bool getXCOFFTracebackTable()
StringRef getHostCPUName()
getHostCPUName - Get the LLVM name for the host CPU.
bool getEnableAIXExtendedAltivecABI()
SwiftAsyncFramePointerMode
Indicates when and how the Swift async frame pointer bit should be set.
@ PreserveSign
The sign of a flushed-to-zero number is preserved in the sign of 0.
@ SCE
Tune debug info for SCE targets (e.g. PS4).
@ LLDB
Tune debug info for lldb.
constexpr T value_or(U &&alt) const &
@ DwarfCFI
DWARF-like instruction based exceptions.
Create this object with static storage to register codegen-related command line options.
@ Always
Always set the bit.
std::string getBBSections()
FramePointerKind getFramePointerUsage()