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

source code of llvm/include/llvm/CodeGen/CommandFlags.h