xref: /freebsd/contrib/llvm-project/llvm/include/llvm/CodeGen/CommandFlags.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===-- CommandFlags.h - Command Line Flags Interface -----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains codegen-specific flags that are shared between different
10 // command line tools. The tools "llc" and "opt" both use this file to prevent
11 // flag duplication.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CODEGEN_COMMANDFLAGS_H
16 #define LLVM_CODEGEN_COMMANDFLAGS_H
17 
18 #include "llvm/ADT/FloatingPointMode.h"
19 #include "llvm/Support/CodeGen.h"
20 #include "llvm/Support/Compiler.h"
21 #include "llvm/Target/TargetOptions.h"
22 #include <optional>
23 #include <string>
24 #include <vector>
25 
26 namespace llvm {
27 
28 class Module;
29 class AttrBuilder;
30 class Function;
31 class Triple;
32 class TargetMachine;
33 
34 namespace codegen {
35 
36 LLVM_ABI std::string getMArch();
37 
38 LLVM_ABI std::string getMCPU();
39 
40 LLVM_ABI std::vector<std::string> getMAttrs();
41 
42 LLVM_ABI Reloc::Model getRelocModel();
43 LLVM_ABI std::optional<Reloc::Model> getExplicitRelocModel();
44 
45 LLVM_ABI ThreadModel::Model getThreadModel();
46 
47 LLVM_ABI CodeModel::Model getCodeModel();
48 LLVM_ABI std::optional<CodeModel::Model> getExplicitCodeModel();
49 
50 LLVM_ABI uint64_t getLargeDataThreshold();
51 LLVM_ABI std::optional<uint64_t> getExplicitLargeDataThreshold();
52 
53 LLVM_ABI llvm::ExceptionHandling getExceptionModel();
54 
55 LLVM_ABI std::optional<CodeGenFileType> getExplicitFileType();
56 
57 LLVM_ABI CodeGenFileType getFileType();
58 
59 LLVM_ABI FramePointerKind getFramePointerUsage();
60 
61 LLVM_ABI bool getEnableUnsafeFPMath();
62 
63 LLVM_ABI bool getEnableNoInfsFPMath();
64 
65 LLVM_ABI bool getEnableNoNaNsFPMath();
66 
67 LLVM_ABI bool getEnableNoSignedZerosFPMath();
68 
69 LLVM_ABI bool getEnableApproxFuncFPMath();
70 
71 LLVM_ABI bool getEnableNoTrappingFPMath();
72 
73 LLVM_ABI DenormalMode::DenormalModeKind getDenormalFPMath();
74 LLVM_ABI DenormalMode::DenormalModeKind getDenormalFP32Math();
75 
76 LLVM_ABI bool getEnableHonorSignDependentRoundingFPMath();
77 
78 LLVM_ABI llvm::FloatABI::ABIType getFloatABIForCalls();
79 
80 LLVM_ABI llvm::FPOpFusion::FPOpFusionMode getFuseFPOps();
81 
82 LLVM_ABI SwiftAsyncFramePointerMode getSwiftAsyncFramePointer();
83 
84 LLVM_ABI bool getDontPlaceZerosInBSS();
85 
86 LLVM_ABI bool getEnableGuaranteedTailCallOpt();
87 
88 LLVM_ABI bool getEnableAIXExtendedAltivecABI();
89 
90 LLVM_ABI bool getDisableTailCalls();
91 
92 LLVM_ABI bool getStackSymbolOrdering();
93 
94 LLVM_ABI bool getStackRealign();
95 
96 LLVM_ABI std::string getTrapFuncName();
97 
98 LLVM_ABI bool getUseCtors();
99 
100 LLVM_ABI bool getDisableIntegratedAS();
101 
102 LLVM_ABI bool getDataSections();
103 LLVM_ABI std::optional<bool> getExplicitDataSections();
104 
105 LLVM_ABI bool getFunctionSections();
106 LLVM_ABI std::optional<bool> getExplicitFunctionSections();
107 
108 LLVM_ABI bool getIgnoreXCOFFVisibility();
109 
110 LLVM_ABI bool getXCOFFTracebackTable();
111 
112 LLVM_ABI std::string getBBSections();
113 
114 LLVM_ABI unsigned getTLSSize();
115 
116 LLVM_ABI bool getEmulatedTLS();
117 LLVM_ABI std::optional<bool> getExplicitEmulatedTLS();
118 
119 LLVM_ABI bool getEnableTLSDESC();
120 LLVM_ABI std::optional<bool> getExplicitEnableTLSDESC();
121 
122 LLVM_ABI bool getUniqueSectionNames();
123 
124 LLVM_ABI bool getUniqueBasicBlockSectionNames();
125 
126 LLVM_ABI bool getSeparateNamedSections();
127 
128 LLVM_ABI llvm::EABI getEABIVersion();
129 
130 LLVM_ABI llvm::DebuggerKind getDebuggerTuningOpt();
131 
132 LLVM_ABI bool getEnableStackSizeSection();
133 
134 LLVM_ABI bool getEnableAddrsig();
135 
136 LLVM_ABI bool getEmitCallSiteInfo();
137 
138 LLVM_ABI bool getEnableMachineFunctionSplitter();
139 
140 LLVM_ABI bool getEnableStaticDataPartitioning();
141 
142 LLVM_ABI bool getEnableDebugEntryValues();
143 
144 LLVM_ABI bool getValueTrackingVariableLocations();
145 LLVM_ABI std::optional<bool> getExplicitValueTrackingVariableLocations();
146 
147 LLVM_ABI bool getForceDwarfFrameSection();
148 
149 LLVM_ABI bool getXRayFunctionIndex();
150 
151 LLVM_ABI bool getDebugStrictDwarf();
152 
153 LLVM_ABI unsigned getAlignLoops();
154 
155 LLVM_ABI bool getJMCInstrument();
156 
157 LLVM_ABI bool getXCOFFReadOnlyPointers();
158 
159 /// Create this object with static storage to register codegen-related command
160 /// line options.
161 struct RegisterCodeGenFlags {
162   LLVM_ABI RegisterCodeGenFlags();
163 };
164 
165 LLVM_ABI bool getEnableBBAddrMap();
166 
167 LLVM_ABI llvm::BasicBlockSection
168 getBBSectionsMode(llvm::TargetOptions &Options);
169 
170 /// Common utility function tightly tied to the options listed here. Initializes
171 /// a TargetOptions object with CodeGen flags and returns it.
172 /// \p TheTriple is used to determine the default value for options if
173 ///    options are not explicitly specified. If those triple dependant options
174 ///    value do not have effect for your component, a default Triple() could be
175 ///    passed in.
176 LLVM_ABI TargetOptions
177 InitTargetOptionsFromCodeGenFlags(const llvm::Triple &TheTriple);
178 
179 LLVM_ABI std::string getCPUStr();
180 
181 LLVM_ABI std::string getFeaturesStr();
182 
183 LLVM_ABI std::vector<std::string> getFeatureList();
184 
185 LLVM_ABI void renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val);
186 
187 /// Set function attributes of function \p F based on CPU, Features, and command
188 /// line flags.
189 LLVM_ABI void setFunctionAttributes(StringRef CPU, StringRef Features,
190                                     Function &F);
191 
192 /// Set function attributes of functions in Module M based on CPU,
193 /// Features, and command line flags.
194 LLVM_ABI void setFunctionAttributes(StringRef CPU, StringRef Features,
195                                     Module &M);
196 
197 /// Should value-tracking variable locations / instruction referencing be
198 /// enabled by default for this triple?
199 LLVM_ABI bool getDefaultValueTrackingVariableLocations(const llvm::Triple &T);
200 
201 /// Creates a TargetMachine instance with the options defined on the command
202 /// line. This can be used for tools that do not need further customization of
203 /// the TargetOptions.
204 LLVM_ABI Expected<std::unique_ptr<TargetMachine>> createTargetMachineForTriple(
205     StringRef TargetTriple,
206     CodeGenOptLevel OptLevel = CodeGenOptLevel::Default);
207 
208 } // namespace codegen
209 } // namespace llvm
210 
211 #endif // LLVM_CODEGEN_COMMANDFLAGS_H
212