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