LLVM 23.0.0git
CommandFlags.h
Go to the documentation of this file.
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
22#include <optional>
23#include <string>
24#include <vector>
25
26namespace llvm {
27
28class Module;
29class AttrBuilder;
30class Function;
31class Triple;
32class TargetMachine;
33
34namespace codegen {
35
36LLVM_ABI std::string getMArch();
37
38LLVM_ABI std::string getMCPU();
39
40LLVM_ABI std::vector<std::string> getMAttrs();
41
43LLVM_ABI std::optional<Reloc::Model> getExplicitRelocModel();
44
46
48LLVM_ABI std::optional<CodeModel::Model> getExplicitCodeModel();
49
51LLVM_ABI std::optional<uint64_t> getExplicitLargeDataThreshold();
52
54
55LLVM_ABI std::optional<CodeGenFileType> getExplicitFileType();
56
58
60
62
64
67
69
71
73
75
77
79
81
83
85
87
89
91
93
95LLVM_ABI std::optional<bool> getExplicitDataSections();
96
99
101
103
105
107
109LLVM_ABI std::optional<bool> getExplicitEmulatedTLS();
110
112LLVM_ABI std::optional<bool> getExplicitEnableTLSDESC();
113
115
117
119
121
123
125
127
129
131
133
135
137
139
142
144
146
148
150
152
154
156
158
159/// Create this object with static storage to register codegen-related command
160/// line options.
164
165/// Tools that support stats saving should create this object with static
166/// storage to register the --save-stats command line option.
170
172
175
176/// Common utility function tightly tied to the options listed here. Initializes
177/// a TargetOptions object with CodeGen flags and returns it.
178/// \p TheTriple is used to determine the default value for options if
179/// options are not explicitly specified. If those triple dependant options
180/// value do not have effect for your component, a default Triple() could be
181/// passed in.
184
185LLVM_ABI std::string getCPUStr();
186
187LLVM_ABI std::string getFeaturesStr();
188
189LLVM_ABI std::vector<std::string> getFeatureList();
190
191LLVM_ABI void renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val);
192
193/// Set function attributes of function \p F based on CPU, Features, and command
194/// line flags.
196 Function &F);
197
198/// Set function attributes of functions in Module M based on CPU,
199/// Features, and command line flags.
201 Module &M);
202
203/// Should value-tracking variable locations / instruction referencing be
204/// enabled by default for this triple?
206
207/// Creates a TargetMachine instance with the options defined on the command
208/// line. This can be used for tools that do not need further customization of
209/// the TargetOptions.
211 StringRef TargetTriple,
213
214/// Conditionally enables the collection of LLVM statistics during the tool run,
215/// based on the value of the flag. Must be called before the tool run to
216/// actually collect data.
218
219/// Conditionally saves the collected LLVM statistics to the received output
220/// file, based on the value of the flag. Should be called after the tool run,
221/// and must follow a call to `MaybeEnableStatistics()` to actually have data to
222/// write.
224
225} // namespace codegen
226} // namespace llvm
227
228#endif // LLVM_CODEGEN_COMMANDFLAGS_H
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:213
Utilities for dealing with flags related to floating point properties and mode controls.
static LVOptions Options
Definition LVOptions.cpp:25
#define F(x, y, z)
Definition MD5.cpp:54
static cl::opt< std::string > OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"), cl::init("-"))
#define T
Tagged union holding either a T or a Error.
Definition Error.h:485
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Primary interface to the complete machine description for the target machine.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
LLVM_ABI bool getEnableMachineFunctionSplitter()
LLVM_ABI bool getEnableHonorSignDependentRoundingFPMath()
LLVM_ABI std::string getTrapFuncName()
LLVM_ABI bool getEnableDebugEntryValues()
LLVM_ABI unsigned getTLSSize()
LLVM_ABI bool getEnableGuaranteedTailCallOpt()
LLVM_ABI llvm::FPOpFusion::FPOpFusionMode getFuseFPOps()
LLVM_ABI std::optional< CodeModel::Model > getExplicitCodeModel()
LLVM_ABI bool getFunctionSections()
LLVM_ABI bool getDisableTailCalls()
LLVM_ABI std::string getCPUStr()
LLVM_ABI llvm::VectorLibrary getVectorLibrary()
LLVM_ABI bool getXCOFFReadOnlyPointers()
LLVM_ABI std::string getFeaturesStr()
LLVM_ABI bool getUniqueSectionNames()
LLVM_ABI DenormalMode::DenormalModeKind getDenormalFPMath()
LLVM_ABI llvm::FloatABI::ABIType getFloatABIForCalls()
LLVM_ABI void renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val)
LLVM_ABI Reloc::Model getRelocModel()
LLVM_ABI bool getDebugStrictDwarf()
LLVM_ABI bool getEmulatedTLS()
LLVM_ABI bool getForceDwarfFrameSection()
LLVM_ABI bool getStackRealign()
LLVM_ABI std::string getMCPU()
LLVM_ABI bool getJMCInstrument()
LLVM_ABI bool getValueTrackingVariableLocations()
LLVM_ABI bool getDataSections()
LLVM_ABI bool getEnableAddrsig()
LLVM_ABI bool getStackSymbolOrdering()
LLVM_ABI void MaybeEnableStatistics()
Conditionally enables the collection of LLVM statistics during the tool run, based on the value of th...
LLVM_ABI SwiftAsyncFramePointerMode getSwiftAsyncFramePointer()
LLVM_ABI bool getEnableBBAddrMap()
LLVM_ABI std::optional< bool > getExplicitFunctionSections()
LLVM_ABI uint64_t getLargeDataThreshold()
LLVM_ABI std::vector< std::string > getFeatureList()
LLVM_ABI bool getEnableStaticDataPartitioning()
LLVM_ABI std::string getMArch()
LLVM_ABI DenormalMode::DenormalModeKind getDenormalFP32Math()
LLVM_ABI CodeGenFileType getFileType()
LLVM_ABI bool getEnableNoSignedZerosFPMath()
LLVM_ABI bool getEnableStackSizeSection()
LLVM_ABI bool getDefaultValueTrackingVariableLocations(const llvm::Triple &T)
Should value-tracking variable locations / instruction referencing be enabled by default for this tri...
LLVM_ABI llvm::EABI getEABIVersion()
LLVM_ABI bool getEnableCallGraphSection()
LLVM_ABI bool getEnableNoTrappingFPMath()
LLVM_ABI Expected< std::unique_ptr< TargetMachine > > createTargetMachineForTriple(StringRef TargetTriple, CodeGenOptLevel OptLevel=CodeGenOptLevel::Default)
Creates a TargetMachine instance with the options defined on the command line.
LLVM_ABI SaveStatsMode getSaveStats()
LLVM_ABI bool getUniqueBasicBlockSectionNames()
LLVM_ABI FramePointerKind getFramePointerUsage()
LLVM_ABI bool getDontPlaceZerosInBSS()
LLVM_ABI bool getSeparateNamedSections()
LLVM_ABI std::optional< bool > getExplicitDataSections()
LLVM_ABI ThreadModel::Model getThreadModel()
LLVM_ABI bool getXCOFFTracebackTable()
LLVM_ABI bool getIgnoreXCOFFVisibility()
LLVM_ABI std::optional< bool > getExplicitValueTrackingVariableLocations()
LLVM_ABI bool getDisableIntegratedAS()
LLVM_ABI bool getUseCtors()
LLVM_ABI llvm::DebuggerKind getDebuggerTuningOpt()
LLVM_ABI std::vector< std::string > getMAttrs()
LLVM_ABI CodeModel::Model getCodeModel()
LLVM_ABI void setFunctionAttributes(StringRef CPU, StringRef Features, Function &F)
Set function attributes of function F based on CPU, Features, and command line flags.
LLVM_ABI llvm::BasicBlockSection getBBSectionsMode(llvm::TargetOptions &Options)
LLVM_ABI TargetOptions InitTargetOptionsFromCodeGenFlags(const llvm::Triple &TheTriple)
Common utility function tightly tied to the options listed here.
LLVM_ABI std::string getBBSections()
LLVM_ABI std::optional< bool > getExplicitEnableTLSDESC()
LLVM_ABI std::optional< uint64_t > getExplicitLargeDataThreshold()
LLVM_ABI unsigned getAlignLoops()
LLVM_ABI std::optional< Reloc::Model > getExplicitRelocModel()
LLVM_ABI std::optional< CodeGenFileType > getExplicitFileType()
LLVM_ABI int MaybeSaveStatistics(StringRef OutputFilename, StringRef ToolName)
Conditionally saves the collected LLVM statistics to the received output file, based on the value of ...
LLVM_ABI bool getEnableAIXExtendedAltivecABI()
LLVM_ABI bool getXRayFunctionIndex()
LLVM_ABI llvm::ExceptionHandling getExceptionModel()
LLVM_ABI bool getEmitCallSiteInfo()
LLVM_ABI std::optional< bool > getExplicitEmulatedTLS()
LLVM_ABI bool getEnableTLSDESC()
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
FramePointerKind
Definition CodeGen.h:118
ExceptionHandling
Definition CodeGen.h:53
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition CodeGen.h:111
SwiftAsyncFramePointerMode
Indicates when and how the Swift async frame pointer bit should be set.
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:82
@ Default
-O2, -Os, -Oz
Definition CodeGen.h:85
BasicBlockSection
VectorLibrary
List of known vector-functions libraries.
EABI
Definition CodeGen.h:73
DebuggerKind
Identify a debugger for "tuning" the debug info.
DenormalModeKind
Represent handled modes for denormal (aka subnormal) modes in the floating point environment.