LLVM 22.0.0git
MCTargetOptionsCommandFlags.cpp
Go to the documentation of this file.
1//===-- MCTargetOptionsCommandFlags.cpp -----------------------*- 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 machine code-specific flags that are shared between
10// different command line tools.
11//
12//===----------------------------------------------------------------------===//
13
17
18using namespace llvm;
19
20#define MCOPT(TY, NAME) \
21 static cl::opt<TY> *NAME##View; \
22 TY llvm::mc::get##NAME() { \
23 assert(NAME##View && "RegisterMCTargetOptionsFlags not created."); \
24 return *NAME##View; \
25 }
26
27#define MCOPT_EXP(TY, NAME) \
28 MCOPT(TY, NAME) \
29 std::optional<TY> llvm::mc::getExplicit##NAME() { \
30 if (NAME##View->getNumOccurrences()) { \
31 TY res = *NAME##View; \
32 return res; \
33 } \
34 return std::nullopt; \
35 }
36
37MCOPT_EXP(bool, RelaxAll)
38MCOPT(bool, IncrementalLinkerCompatible)
39MCOPT(bool, FDPIC)
40MCOPT(int, DwarfVersion)
41MCOPT(bool, Dwarf64)
42MCOPT(EmitDwarfUnwindType, EmitDwarfUnwind)
43MCOPT(bool, EmitCompactUnwindNonCanonical)
44MCOPT(bool, EmitSFrameUnwind)
45MCOPT(bool, ShowMCInst)
46MCOPT(bool, FatalWarnings)
47MCOPT(bool, NoWarn)
48MCOPT(bool, NoDeprecatedWarn)
49MCOPT(bool, NoTypeCheck)
50MCOPT(bool, SaveTempLabels)
51MCOPT(bool, Crel)
52MCOPT(bool, ImplicitMapSyms)
53MCOPT(bool, X86RelaxRelocations)
54MCOPT(bool, X86Sse2Avx)
55MCOPT(std::string, ABIName)
56MCOPT(std::string, AsSecureLogFile)
57
59#define MCBINDOPT(NAME) \
60 do { \
61 NAME##View = std::addressof(NAME); \
62 } while (0)
63
64 static cl::opt<bool> RelaxAll(
65 "mc-relax-all", cl::desc("When used with filetype=obj, relax all fixups "
66 "in the emitted object file"));
67 MCBINDOPT(RelaxAll);
68
69 static cl::opt<bool> IncrementalLinkerCompatible(
70 "incremental-linker-compatible",
72 "When used with filetype=obj, "
73 "emit an object file which can be used with an incremental linker"));
74 MCBINDOPT(IncrementalLinkerCompatible);
75
76 static cl::opt<bool> FDPIC("fdpic", cl::desc("Use the FDPIC ABI"));
77 MCBINDOPT(FDPIC);
78
79 static cl::opt<int> DwarfVersion("dwarf-version", cl::desc("Dwarf version"),
80 cl::init(0));
81 MCBINDOPT(DwarfVersion);
82
83 static cl::opt<bool> Dwarf64(
84 "dwarf64",
85 cl::desc("Generate debugging info in the 64-bit DWARF format"));
86 MCBINDOPT(Dwarf64);
87
88 static cl::opt<EmitDwarfUnwindType> EmitDwarfUnwind(
89 "emit-dwarf-unwind", cl::desc("Whether to emit DWARF EH frame entries."),
92 "Always emit EH frame entries"),
94 "no-compact-unwind",
95 "Only emit EH frame entries when compact unwind is "
96 "not available"),
98 "Use target platform default")));
99 MCBINDOPT(EmitDwarfUnwind);
100
101 static cl::opt<bool> EmitCompactUnwindNonCanonical(
102 "emit-compact-unwind-non-canonical",
103 cl::desc(
104 "Whether to try to emit Compact Unwind for non canonical entries."),
105 cl::init(
106 false)); // By default, use DWARF for non-canonical personalities.
107 MCBINDOPT(EmitCompactUnwindNonCanonical);
108
109 static cl::opt<bool> EmitSFrameUnwind(
110 "gsframe", cl::desc("Whether to emit .sframe unwind sections."),
111 cl::init(false));
112 MCBINDOPT(EmitSFrameUnwind);
113
114 static cl::opt<bool> ShowMCInst(
115 "asm-show-inst",
116 cl::desc("Emit internal instruction representation to assembly file"));
117 MCBINDOPT(ShowMCInst);
118
119 static cl::opt<bool> FatalWarnings("fatal-warnings",
120 cl::desc("Treat warnings as errors"));
121 MCBINDOPT(FatalWarnings);
122
123 static cl::opt<bool> NoWarn("no-warn", cl::desc("Suppress all warnings"));
124 static cl::alias NoWarnW("W", cl::desc("Alias for --no-warn"),
125 cl::aliasopt(NoWarn));
126 MCBINDOPT(NoWarn);
127
128 static cl::opt<bool> NoDeprecatedWarn(
129 "no-deprecated-warn", cl::desc("Suppress all deprecated warnings"));
130 MCBINDOPT(NoDeprecatedWarn);
131
132 static cl::opt<bool> NoTypeCheck(
133 "no-type-check", cl::desc("Suppress type errors (Wasm)"));
134 MCBINDOPT(NoTypeCheck);
135
136 static cl::opt<bool> SaveTempLabels(
137 "save-temp-labels", cl::desc("Don't discard temporary labels"));
138 MCBINDOPT(SaveTempLabels);
139
140 static cl::opt<bool> Crel("crel",
141 cl::desc("Use CREL relocation format for ELF"));
142 MCBINDOPT(Crel);
143
144 static cl::opt<bool> ImplicitMapSyms(
145 "implicit-mapsyms",
146 cl::desc("Allow mapping symbol at section beginning to be implicit, "
147 "lowering number of mapping symbols at the expense of some "
148 "portability. Recommended for projects that can build all their "
149 "object files using this option"));
150 MCBINDOPT(ImplicitMapSyms);
151
152 static cl::opt<bool> X86RelaxRelocations(
153 "x86-relax-relocations",
154 cl::desc("Emit GOTPCRELX/REX_GOTPCRELX/CODE_4_GOTPCRELX instead of "
155 "GOTPCREL on x86-64 ELF"),
156 cl::init(true));
157 MCBINDOPT(X86RelaxRelocations);
158
159 static cl::opt<bool> X86Sse2Avx(
160 "x86-sse2avx", cl::desc("Specify that the assembler should encode SSE "
161 "instructions with VEX prefix"));
162 MCBINDOPT(X86Sse2Avx);
163
164 static cl::opt<std::string> ABIName(
165 "target-abi",
166 cl::desc("The name of the ABI to be targeted from the backend."),
167 cl::init(""));
168 MCBINDOPT(ABIName);
169
170 static cl::opt<std::string> AsSecureLogFile(
171 "as-secure-log-file", cl::desc("As secure log file name"), cl::Hidden);
172 MCBINDOPT(AsSecureLogFile);
173
174#undef MCBINDOPT
175}
176
179 Options.MCRelaxAll = getRelaxAll();
180 Options.MCIncrementalLinkerCompatible = getIncrementalLinkerCompatible();
181 Options.FDPIC = getFDPIC();
182 Options.Dwarf64 = getDwarf64();
183 Options.DwarfVersion = getDwarfVersion();
184 Options.ShowMCInst = getShowMCInst();
185 Options.ABIName = getABIName();
186 Options.MCFatalWarnings = getFatalWarnings();
187 Options.MCNoWarn = getNoWarn();
188 Options.MCNoDeprecatedWarn = getNoDeprecatedWarn();
189 Options.MCNoTypeCheck = getNoTypeCheck();
190 Options.MCSaveTempLabels = getSaveTempLabels();
191 Options.Crel = getCrel();
192 Options.ImplicitMapSyms = getImplicitMapSyms();
193 Options.X86RelaxRelocations = getX86RelaxRelocations();
194 Options.X86Sse2Avx = getX86Sse2Avx();
195 Options.EmitDwarfUnwind = getEmitDwarfUnwind();
196 Options.EmitCompactUnwindNonCanonical = getEmitCompactUnwindNonCanonical();
197 Options.EmitSFrameUnwind = getEmitSFrameUnwind();
198 Options.AsSecureLogFile = getAsSecureLogFile();
199
200 return Options;
201}
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
static LVOptions Options
Definition LVOptions.cpp:25
#define MCBINDOPT(NAME)
#define MCOPT(TY, NAME)
#define MCOPT_EXP(TY, NAME)
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
initializer< Ty > init(const Ty &Val)
LLVM_ABI bool getEmitCompactUnwindNonCanonical()
LLVM_ABI bool getDwarf64()
LLVM_ABI bool getEmitSFrameUnwind()
LLVM_ABI bool getX86Sse2Avx()
LLVM_ABI MCTargetOptions InitMCTargetOptionsFromFlags()
LLVM_ABI bool getIncrementalLinkerCompatible()
LLVM_ABI bool getNoDeprecatedWarn()
LLVM_ABI bool getNoTypeCheck()
LLVM_ABI EmitDwarfUnwindType getEmitDwarfUnwind()
LLVM_ABI std::string getABIName()
LLVM_ABI bool getSaveTempLabels()
LLVM_ABI bool getImplicitMapSyms()
LLVM_ABI bool getFDPIC()
LLVM_ABI bool getCrel()
LLVM_ABI bool getFatalWarnings()
LLVM_ABI std::string getAsSecureLogFile()
LLVM_ABI bool getRelaxAll()
LLVM_ABI bool getX86RelaxRelocations()
LLVM_ABI bool getShowMCInst()
LLVM_ABI int getDwarfVersion()
LLVM_ABI bool getNoWarn()
This is an optimization pass for GlobalISel generic memory operations.
EmitDwarfUnwindType