LLVM 24.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
18#include "llvm/ADT/ArrayRef.h"
23#include <optional>
24#include <string>
25#include <vector>
26
27namespace llvm {
28
29class Module;
30class AttrBuilder;
31class Function;
32class Triple;
33class TargetMachine;
34
35namespace cl {
36class LibraryOptions;
37}
38
39namespace codegen {
40
41LLVM_ABI std::string getMArch();
42
43LLVM_ABI std::string getMCPU();
44
45LLVM_ABI std::string getMTune();
46
47LLVM_ABI std::vector<std::string> getMAttrs();
48
50LLVM_ABI std::optional<Reloc::Model> getExplicitRelocModel();
51
53LLVM_ABI std::optional<CodeModel::Model> getExplicitCodeModel();
54
56LLVM_ABI std::optional<uint64_t> getExplicitLargeDataThreshold();
57
59
60LLVM_ABI std::optional<CodeGenFileType> getExplicitFileType();
61
63
65
68
70
72
74
76
78
80
82
84
86
88LLVM_ABI std::optional<bool> getExplicitDataSections();
89
92
94
96
97LLVM_ABI std::string getBBSections();
98
100
102LLVM_ABI std::optional<bool> getExplicitEmulatedTLS();
103
105LLVM_ABI std::optional<bool> getExplicitEnableTLSDESC();
106
108
110
112
114
116
118
120
122
124
126
128
130
132
134
136
138
140
142
143/// Create this object with static storage to register codegen-related command
144/// line options.
148
149/// The options that a tool reading getTargetOptions passes to
150/// cl::parseCommandLineOptions.
152
153/// Tools that support subtarget tuning should create this object with static
154/// storage to register the -mtune command line option.
158
159/// Tools that support stats saving should create this object with static
160/// storage to register the --save-stats command line option.
164
166
169
170/// Common utility function tightly tied to the options listed here. Initializes
171/// a TargetOptions object with CodeGen options and returns it.
172/// \p TheTriple is used to determine the default value for options if
173/// options are not explicitly specified. If those triple dependant options
174/// value do not have effect for your component, a default Triple() could be
175/// passed in.
177getTargetOptions(const cl::LibraryOptionsContext &LibraryOptions,
178 const llvm::Triple &TheTriple);
179
180LLVM_ABI std::string getCPUStr();
181
182LLVM_ABI std::string getTuneCPUStr();
183
184LLVM_ABI std::string getFeaturesStr();
185
186LLVM_ABI std::vector<std::string> getFeatureList();
187
188LLVM_ABI void renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val);
189
190/// Set function attributes of function \p F based on CPU, TuneCPU, Features,
191/// and command line flags.
193 StringRef Features, StringRef TuneCPU = "");
194
195/// Set function attributes of functions in Module M based on CPU,
196/// TuneCPU, Features, and command line flags.
198 StringRef Features, StringRef TuneCPU = "");
199
200/// Creates a TargetMachine instance with the options defined on the command
201/// line. This can be used for tools that do not need further customization of
202/// the TargetOptions.
204 const cl::LibraryOptionsContext &LibraryOptions, const Triple &TargetTriple,
206
207/// Conditionally enables the collection of LLVM statistics during the tool run,
208/// based on the value of the flag. Must be called before the tool run to
209/// actually collect data.
211
212/// Conditionally saves the collected LLVM statistics to the received output
213/// file, based on the value of the flag. Should be called after the tool run,
214/// and must follow a call to `MaybeEnableStatistics()` to actually have data to
215/// write.
217
218} // namespace codegen
219} // namespace llvm
220
221#endif // LLVM_CODEGEN_COMMANDFLAGS_H
uint64_t uint64_t
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:211
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("-"))
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
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:68
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Primary interface to the complete machine description for the target machine.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
The options of a library that declares them in TableGen rather than as cl::opt (see llvm/Option/Libra...
This namespace contains all of the command line option processing machinery.
LLVM_ABI std::string getTrapFuncName()
LLVM_ABI bool getEnableDebugEntryValues()
LLVM_ABI unsigned getTLSSize()
LLVM_ABI bool getEnableGuaranteedTailCallOpt()
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 Expected< std::unique_ptr< TargetMachine > > createTargetMachineForTriple(const cl::LibraryOptionsContext &LibraryOptions, const Triple &TargetTriple, CodeGenOptLevel OptLevel=CodeGenOptLevel::Default)
Creates a TargetMachine instance with the options defined on the command line.
LLVM_ABI bool getStackRealign()
LLVM_ABI std::string getMCPU()
LLVM_ABI bool getJMCInstrument()
LLVM_ABI bool getDataSections()
LLVM_ABI bool getEnableAddrsig()
LLVM_ABI void setFunctionAttributes(Function &F, StringRef CPU, StringRef Features, StringRef TuneCPU="")
Set function attributes of function F based on CPU, TuneCPU, Features, and command line flags.
LLVM_ABI ArrayRef< const cl::LibraryOptions * > getToolOptions()
The options that a tool reading getTargetOptions passes to cl::parseCommandLineOptions.
LLVM_ABI TargetOptions getTargetOptions(const cl::LibraryOptionsContext &LibraryOptions, const llvm::Triple &TheTriple)
Common utility function tightly tied to the options listed here.
LLVM_ABI std::string getTuneCPUStr()
LLVM_ABI std::string getMTune()
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 getEnableStackSizeSection()
LLVM_ABI bool getEnableCallGraphSection()
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 bool getXCOFFTracebackTable()
LLVM_ABI bool getIgnoreXCOFFVisibility()
LLVM_ABI bool getUseCtors()
LLVM_ABI std::vector< std::string > getMAttrs()
LLVM_ABI CodeModel::Model getCodeModel()
LLVM_ABI llvm::BasicBlockSection getBBSectionsMode(llvm::TargetOptions &Options)
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 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.
FramePointerKind
Definition CodeGen.h:326
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition CodeGen.h:309
SwiftAsyncFramePointerMode
Indicates when and how the Swift async frame pointer bit should be set.
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:280
@ Default
-O2, -Os, -Oz
Definition CodeGen.h:283
ExceptionHandling
Definition CodeGen.h:54
BasicBlockSection
VectorLibrary
List of known vector-functions libraries.
DenormalModeKind
Represent handled modes for denormal (aka subnormal) modes in the floating point environment.