• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 std::string getBBSections();
103 
104 std::string getStackProtectorGuard();
105 unsigned getStackProtectorGuardOffset();
106 std::string getStackProtectorGuardReg();
107 
108 unsigned getTLSSize();
109 
110 bool getEmulatedTLS();
111 
112 bool getUniqueSectionNames();
113 
114 bool getUniqueBasicBlockSectionNames();
115 
116 llvm::EABI getEABIVersion();
117 
118 llvm::DebuggerKind getDebuggerTuningOpt();
119 
120 bool getEnableStackSizeSection();
121 
122 bool getEnableAddrsig();
123 
124 bool getEmitCallSiteInfo();
125 
126 bool getEnableMachineFunctionSplitter();
127 
128 bool getEnableDebugEntryValues();
129 
130 bool getPseudoProbeForProfiling();
131 
132 bool getValueTrackingVariableLocations();
133 
134 bool getForceDwarfFrameSection();
135 
136 bool getXRayOmitFunctionIndex();
137 
138 /// Create this object with static storage to register codegen-related command
139 /// line options.
140 struct RegisterCodeGenFlags {
141   RegisterCodeGenFlags();
142 };
143 
144 llvm::BasicBlockSection getBBSectionsMode(llvm::TargetOptions &Options);
145 
146 llvm::StackProtectorGuards
147 getStackProtectorGuardMode(llvm::TargetOptions &Options);
148 
149 /// Common utility function tightly tied to the options listed here. Initializes
150 /// a TargetOptions object with CodeGen flags and returns it.
151 /// \p TheTriple is used to determine the default value for options if
152 ///    options are not explicitly specified. If those triple dependant options
153 ///    value do not have effect for your component, a default Triple() could be
154 ///    passed in.
155 TargetOptions InitTargetOptionsFromCodeGenFlags(const llvm::Triple &TheTriple);
156 
157 std::string getCPUStr();
158 
159 std::string getFeaturesStr();
160 
161 std::vector<std::string> getFeatureList();
162 
163 void renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val);
164 
165 /// Set function attributes of function \p F based on CPU, Features, and command
166 /// line flags.
167 void setFunctionAttributes(StringRef CPU, StringRef Features, Function &F);
168 
169 /// Set function attributes of functions in Module M based on CPU,
170 /// Features, and command line flags.
171 void setFunctionAttributes(StringRef CPU, StringRef Features, Module &M);
172 } // namespace codegen
173 } // namespace llvm
174