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/Target/TargetOptions.h"
21 #include <string>
22 #include <vector>
23 
24 namespace llvm {
25 
26 class Module;
27 class AttrBuilder;
28 class Function;
29 class Triple;
30 
31 namespace codegen {
32 
33 std::string getMArch();
34 
35 std::string getMCPU();
36 
37 std::vector<std::string> getMAttrs();
38 
39 Reloc::Model getRelocModel();
40 Optional<Reloc::Model> getExplicitRelocModel();
41 
42 ThreadModel::Model getThreadModel();
43 
44 CodeModel::Model getCodeModel();
45 Optional<CodeModel::Model> getExplicitCodeModel();
46 
47 llvm::ExceptionHandling getExceptionModel();
48 
49 Optional<CodeGenFileType> getExplicitFileType();
50 
51 CodeGenFileType getFileType();
52 
53 FramePointerKind getFramePointerUsage();
54 
55 bool getEnableUnsafeFPMath();
56 
57 bool getEnableNoInfsFPMath();
58 
59 bool getEnableNoNaNsFPMath();
60 
61 bool getEnableNoSignedZerosFPMath();
62 
63 bool getEnableApproxFuncFPMath();
64 
65 bool getEnableNoTrappingFPMath();
66 
67 DenormalMode::DenormalModeKind getDenormalFPMath();
68 DenormalMode::DenormalModeKind getDenormalFP32Math();
69 
70 bool getEnableHonorSignDependentRoundingFPMath();
71 
72 llvm::FloatABI::ABIType getFloatABIForCalls();
73 
74 llvm::FPOpFusion::FPOpFusionMode getFuseFPOps();
75 
76 SwiftAsyncFramePointerMode getSwiftAsyncFramePointer();
77 
78 bool getDontPlaceZerosInBSS();
79 
80 bool getEnableGuaranteedTailCallOpt();
81 
82 bool getEnableAIXExtendedAltivecABI();
83 
84 bool getDisableTailCalls();
85 
86 bool getStackSymbolOrdering();
87 
88 unsigned getOverrideStackAlignment();
89 
90 bool getStackRealign();
91 
92 std::string getTrapFuncName();
93 
94 bool getUseCtors();
95 
96 bool getLowerGlobalDtorsViaCxaAtExit();
97 
98 bool getRelaxELFRelocations();
99 
100 bool getDataSections();
101 Optional<bool> getExplicitDataSections();
102 
103 bool getFunctionSections();
104 Optional<bool> getExplicitFunctionSections();
105 
106 bool getIgnoreXCOFFVisibility();
107 
108 bool getXCOFFTracebackTable();
109 
110 std::string getBBSections();
111 
112 unsigned getTLSSize();
113 
114 bool getEmulatedTLS();
115 
116 bool getUniqueSectionNames();
117 
118 bool getUniqueBasicBlockSectionNames();
119 
120 llvm::EABI getEABIVersion();
121 
122 llvm::DebuggerKind getDebuggerTuningOpt();
123 
124 bool getEnableStackSizeSection();
125 
126 bool getEnableAddrsig();
127 
128 bool getEmitCallSiteInfo();
129 
130 bool getEnableMachineFunctionSplitter();
131 
132 bool getEnableDebugEntryValues();
133 
134 bool getValueTrackingVariableLocations();
135 Optional<bool> getExplicitValueTrackingVariableLocations();
136 
137 bool getForceDwarfFrameSection();
138 
139 bool getXRayOmitFunctionIndex();
140 
141 bool getDebugStrictDwarf();
142 
143 unsigned getAlignLoops();
144 
145 bool getJMCInstrument();
146 
147 /// Create this object with static storage to register codegen-related command
148 /// line options.
149 struct RegisterCodeGenFlags {
150   RegisterCodeGenFlags();
151 };
152 
153 llvm::BasicBlockSection getBBSectionsMode(llvm::TargetOptions &Options);
154 
155 /// Common utility function tightly tied to the options listed here. Initializes
156 /// a TargetOptions object with CodeGen flags and returns it.
157 /// \p TheTriple is used to determine the default value for options if
158 ///    options are not explicitly specified. If those triple dependant options
159 ///    value do not have effect for your component, a default Triple() could be
160 ///    passed in.
161 TargetOptions InitTargetOptionsFromCodeGenFlags(const llvm::Triple &TheTriple);
162 
163 std::string getCPUStr();
164 
165 std::string getFeaturesStr();
166 
167 std::vector<std::string> getFeatureList();
168 
169 void renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val);
170 
171 /// Set function attributes of function \p F based on CPU, Features, and command
172 /// line flags.
173 void setFunctionAttributes(StringRef CPU, StringRef Features, Function &F);
174 
175 /// Set function attributes of functions in Module M based on CPU,
176 /// Features, and command line flags.
177 void setFunctionAttributes(StringRef CPU, StringRef Features, Module &M);
178 
179 /// Should value-tracking variable locations / instruction referencing be
180 /// enabled by default for this triple?
181 bool getDefaultValueTrackingVariableLocations(const llvm::Triple &T);
182 } // namespace codegen
183 } // namespace llvm
184 
185 #endif // LLVM_CODEGEN_COMMANDFLAGS_H
186