blob: e6c64cd4dd8e0581dc3296ebd4885d28ca165ef5 [file] [log] [blame]
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001//===-- 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
26namespace llvm {
27
28class Module;
29
30namespace codegen {
31
32std::string getMArch();
33
34std::string getMCPU();
35
36std::vector<std::string> getMAttrs();
37
38Reloc::Model getRelocModel();
39Optional<Reloc::Model> getExplicitRelocModel();
40
41ThreadModel::Model getThreadModel();
42
43CodeModel::Model getCodeModel();
44Optional<CodeModel::Model> getExplicitCodeModel();
45
46llvm::ExceptionHandling getExceptionModel();
47
48CodeGenFileType getFileType();
49Optional<CodeGenFileType> getExplicitFileType();
50
51CodeGenFileType getFileType();
52
53llvm::FramePointer::FP getFramePointerUsage();
54
55bool getEnableUnsafeFPMath();
56
57bool getEnableNoInfsFPMath();
58
59bool getEnableNoNaNsFPMath();
60
61bool getEnableNoSignedZerosFPMath();
62
63bool getEnableNoTrappingFPMath();
64
65DenormalMode::DenormalModeKind getDenormalFPMath();
66DenormalMode::DenormalModeKind getDenormalFP32Math();
67
68bool getEnableHonorSignDependentRoundingFPMath();
69
70llvm::FloatABI::ABIType getFloatABIForCalls();
71
72llvm::FPOpFusion::FPOpFusionMode getFuseFPOps();
73
74bool getDontPlaceZerosInBSS();
75
76bool getEnableGuaranteedTailCallOpt();
77
78bool getEnableAIXExtendedAltivecABI();
79
80bool getDisableTailCalls();
81
82bool getStackSymbolOrdering();
83
84unsigned getOverrideStackAlignment();
85
86bool getStackRealign();
87
88std::string getTrapFuncName();
89
90bool getUseCtors();
91
92bool getRelaxELFRelocations();
93
94bool getDataSections();
95Optional<bool> getExplicitDataSections();
96
97bool getFunctionSections();
98Optional<bool> getExplicitFunctionSections();
99
100bool getIgnoreXCOFFVisibility();
101
102bool getXCOFFTracebackTable();
103
104std::string getBBSections();
105
106std::string getStackProtectorGuard();
107unsigned getStackProtectorGuardOffset();
108std::string getStackProtectorGuardReg();
109
110unsigned getTLSSize();
111
112bool getEmulatedTLS();
113
114bool getUniqueSectionNames();
115
116bool getUniqueBasicBlockSectionNames();
117
118llvm::EABI getEABIVersion();
119
120llvm::DebuggerKind getDebuggerTuningOpt();
121
122bool getEnableStackSizeSection();
123
124bool getEnableAddrsig();
125
126bool getEmitCallSiteInfo();
127
128bool getEnableMachineFunctionSplitter();
129
130bool getEnableDebugEntryValues();
131
132bool getPseudoProbeForProfiling();
133
134bool getValueTrackingVariableLocations();
135
136bool getForceDwarfFrameSection();
137
138bool getXRayOmitFunctionIndex();
139
140/// Create this object with static storage to register codegen-related command
141/// line options.
142struct RegisterCodeGenFlags {
143 RegisterCodeGenFlags();
144};
145
146llvm::BasicBlockSection getBBSectionsMode(llvm::TargetOptions &Options);
147
148llvm::StackProtectorGuards
149getStackProtectorGuardMode(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.
157TargetOptions InitTargetOptionsFromCodeGenFlags(const llvm::Triple &TheTriple);
158
159std::string getCPUStr();
160
161std::string getFeaturesStr();
162
163std::vector<std::string> getFeatureList();
164
165void 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.
169void 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.
173void setFunctionAttributes(StringRef CPU, StringRef Features, Module &M);
174} // namespace codegen
175} // namespace llvm