LLVM 19.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, ShowMCInst)
45MCOPT(bool, FatalWarnings)
46MCOPT(bool, NoWarn)
47MCOPT(bool, NoDeprecatedWarn)
48MCOPT(bool, NoTypeCheck)
49MCOPT(bool, X86RelaxRelocations)
50MCOPT(std::string, ABIName)
51MCOPT(std::string, AsSecureLogFile)
52
54#define MCBINDOPT(NAME) \
55 do { \
56 NAME##View = std::addressof(NAME); \
57 } while (0)
58
59 static cl::opt<bool> RelaxAll(
60 "mc-relax-all", cl::desc("When used with filetype=obj, relax all fixups "
61 "in the emitted object file"));
62 MCBINDOPT(RelaxAll);
63
64 static cl::opt<bool> IncrementalLinkerCompatible(
65 "incremental-linker-compatible",
67 "When used with filetype=obj, "
68 "emit an object file which can be used with an incremental linker"));
69 MCBINDOPT(IncrementalLinkerCompatible);
70
71 static cl::opt<bool> FDPIC("fdpic", cl::desc("Use the FDPIC ABI"));
72 MCBINDOPT(FDPIC);
73
74 static cl::opt<int> DwarfVersion("dwarf-version", cl::desc("Dwarf version"),
75 cl::init(0));
76 MCBINDOPT(DwarfVersion);
77
78 static cl::opt<bool> Dwarf64(
79 "dwarf64",
80 cl::desc("Generate debugging info in the 64-bit DWARF format"));
81 MCBINDOPT(Dwarf64);
82
83 static cl::opt<EmitDwarfUnwindType> EmitDwarfUnwind(
84 "emit-dwarf-unwind", cl::desc("Whether to emit DWARF EH frame entries."),
85 cl::init(EmitDwarfUnwindType::Default),
86 cl::values(clEnumValN(EmitDwarfUnwindType::Always, "always",
87 "Always emit EH frame entries"),
88 clEnumValN(EmitDwarfUnwindType::NoCompactUnwind,
89 "no-compact-unwind",
90 "Only emit EH frame entries when compact unwind is "
91 "not available"),
92 clEnumValN(EmitDwarfUnwindType::Default, "default",
93 "Use target platform default")));
94 MCBINDOPT(EmitDwarfUnwind);
95
96 static cl::opt<bool> EmitCompactUnwindNonCanonical(
97 "emit-compact-unwind-non-canonical",
99 "Whether to try to emit Compact Unwind for non canonical entries."),
100 cl::init(
101 false)); // By default, use DWARF for non-canonical personalities.
102 MCBINDOPT(EmitCompactUnwindNonCanonical);
103
104 static cl::opt<bool> ShowMCInst(
105 "asm-show-inst",
106 cl::desc("Emit internal instruction representation to assembly file"));
107 MCBINDOPT(ShowMCInst);
108
109 static cl::opt<bool> FatalWarnings("fatal-warnings",
110 cl::desc("Treat warnings as errors"));
111 MCBINDOPT(FatalWarnings);
112
113 static cl::opt<bool> NoWarn("no-warn", cl::desc("Suppress all warnings"));
114 static cl::alias NoWarnW("W", cl::desc("Alias for --no-warn"),
115 cl::aliasopt(NoWarn));
116 MCBINDOPT(NoWarn);
117
118 static cl::opt<bool> NoDeprecatedWarn(
119 "no-deprecated-warn", cl::desc("Suppress all deprecated warnings"));
120 MCBINDOPT(NoDeprecatedWarn);
121
122 static cl::opt<bool> NoTypeCheck(
123 "no-type-check", cl::desc("Suppress type errors (Wasm)"));
124 MCBINDOPT(NoTypeCheck);
125
126 static cl::opt<bool> X86RelaxRelocations(
127 "x86-relax-relocations",
128 cl::desc(
129 "Emit GOTPCRELX/REX_GOTPCRELX instead of GOTPCREL on x86-64 ELF"),
130 cl::init(true));
131 MCBINDOPT(X86RelaxRelocations);
132
133 static cl::opt<std::string> ABIName(
134 "target-abi", cl::Hidden,
135 cl::desc("The name of the ABI to be targeted from the backend."),
136 cl::init(""));
137 MCBINDOPT(ABIName);
138
139 static cl::opt<std::string> AsSecureLogFile(
140 "as-secure-log-file", cl::desc("As secure log file name"), cl::Hidden);
141 MCBINDOPT(AsSecureLogFile);
142
143#undef MCBINDOPT
144}
145
148 Options.MCRelaxAll = getRelaxAll();
149 Options.MCIncrementalLinkerCompatible = getIncrementalLinkerCompatible();
150 Options.FDPIC = getFDPIC();
151 Options.Dwarf64 = getDwarf64();
152 Options.DwarfVersion = getDwarfVersion();
153 Options.ShowMCInst = getShowMCInst();
154 Options.ABIName = getABIName();
155 Options.MCFatalWarnings = getFatalWarnings();
156 Options.MCNoWarn = getNoWarn();
157 Options.MCNoDeprecatedWarn = getNoDeprecatedWarn();
158 Options.MCNoTypeCheck = getNoTypeCheck();
159 Options.X86RelaxRelocations = getX86RelaxRelocations();
160 Options.EmitDwarfUnwind = getEmitDwarfUnwind();
161 Options.EmitCompactUnwindNonCanonical = getEmitCompactUnwindNonCanonical();
162 Options.AsSecureLogFile = getAsSecureLogFile();
163
164 return Options;
165}
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:693
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 ...
Definition: CommandLine.h:718
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:450
bool getNoWarn()
bool getIncrementalLinkerCompatible()
int getDwarfVersion()
std::string getAsSecureLogFile()
bool getShowMCInst()
MCTargetOptions InitMCTargetOptionsFromFlags()
bool getEmitCompactUnwindNonCanonical()
bool getFatalWarnings()
bool getNoDeprecatedWarn()
bool getNoTypeCheck()
bool getFDPIC()
EmitDwarfUnwindType getEmitDwarfUnwind()
bool getX86RelaxRelocations()
bool getRelaxAll()
std::string getABIName()
bool getDwarf64()
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
EmitDwarfUnwindType
Create this object with static storage to register mc-related command line options.