LLVM 17.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(int, DwarfVersion)
40MCOPT(bool, Dwarf64)
41MCOPT(EmitDwarfUnwindType, EmitDwarfUnwind)
42MCOPT(bool, ShowMCInst)
43MCOPT(bool, FatalWarnings)
44MCOPT(bool, NoWarn)
45MCOPT(bool, NoDeprecatedWarn)
46MCOPT(bool, NoTypeCheck)
47MCOPT(std::string, ABIName)
48MCOPT(std::string, AsSecureLogFile)
49
51#define MCBINDOPT(NAME) \
52 do { \
53 NAME##View = std::addressof(NAME); \
54 } while (0)
55
56 static cl::opt<bool> RelaxAll(
57 "mc-relax-all", cl::desc("When used with filetype=obj, relax all fixups "
58 "in the emitted object file"));
59 MCBINDOPT(RelaxAll);
60
61 static cl::opt<bool> IncrementalLinkerCompatible(
62 "incremental-linker-compatible",
64 "When used with filetype=obj, "
65 "emit an object file which can be used with an incremental linker"));
66 MCBINDOPT(IncrementalLinkerCompatible);
67
68 static cl::opt<int> DwarfVersion("dwarf-version", cl::desc("Dwarf version"),
69 cl::init(0));
70 MCBINDOPT(DwarfVersion);
71
72 static cl::opt<bool> Dwarf64(
73 "dwarf64",
74 cl::desc("Generate debugging info in the 64-bit DWARF format"));
75 MCBINDOPT(Dwarf64);
76
77 static cl::opt<EmitDwarfUnwindType> EmitDwarfUnwind(
78 "emit-dwarf-unwind", cl::desc("Whether to emit DWARF EH frame entries."),
79 cl::init(EmitDwarfUnwindType::Default),
80 cl::values(clEnumValN(EmitDwarfUnwindType::Always, "always",
81 "Always emit EH frame entries"),
82 clEnumValN(EmitDwarfUnwindType::NoCompactUnwind,
83 "no-compact-unwind",
84 "Only emit EH frame entries when compact unwind is "
85 "not available"),
86 clEnumValN(EmitDwarfUnwindType::Default, "default",
87 "Use target platform default")));
88 MCBINDOPT(EmitDwarfUnwind);
89
90 static cl::opt<bool> ShowMCInst(
91 "asm-show-inst",
92 cl::desc("Emit internal instruction representation to assembly file"));
93 MCBINDOPT(ShowMCInst);
94
95 static cl::opt<bool> FatalWarnings("fatal-warnings",
96 cl::desc("Treat warnings as errors"));
97 MCBINDOPT(FatalWarnings);
98
99 static cl::opt<bool> NoWarn("no-warn", cl::desc("Suppress all warnings"));
100 static cl::alias NoWarnW("W", cl::desc("Alias for --no-warn"),
101 cl::aliasopt(NoWarn));
102 MCBINDOPT(NoWarn);
103
104 static cl::opt<bool> NoDeprecatedWarn(
105 "no-deprecated-warn", cl::desc("Suppress all deprecated warnings"));
106 MCBINDOPT(NoDeprecatedWarn);
107
108 static cl::opt<bool> NoTypeCheck(
109 "no-type-check", cl::desc("Suppress type errors (Wasm)"));
110 MCBINDOPT(NoTypeCheck);
111
112 static cl::opt<std::string> ABIName(
113 "target-abi", cl::Hidden,
114 cl::desc("The name of the ABI to be targeted from the backend."),
115 cl::init(""));
116 MCBINDOPT(ABIName);
117
118 static cl::opt<std::string> AsSecureLogFile(
119 "as-secure-log-file", cl::desc("As secure log file name"), cl::Hidden);
120 MCBINDOPT(AsSecureLogFile);
121
122#undef MCBINDOPT
123}
124
127 Options.MCRelaxAll = getRelaxAll();
128 Options.MCIncrementalLinkerCompatible = getIncrementalLinkerCompatible();
129 Options.Dwarf64 = getDwarf64();
130 Options.DwarfVersion = getDwarfVersion();
131 Options.ShowMCInst = getShowMCInst();
132 Options.ABIName = getABIName();
133 Options.MCFatalWarnings = getFatalWarnings();
134 Options.MCNoWarn = getNoWarn();
135 Options.MCNoDeprecatedWarn = getNoDeprecatedWarn();
136 Options.MCNoTypeCheck = getNoTypeCheck();
137 Options.EmitDwarfUnwind = getEmitDwarfUnwind();
138 Options.AsSecureLogFile = getAsSecureLogFile();
139
140 return Options;
141}
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:678
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:703
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:445
bool getNoWarn()
bool getIncrementalLinkerCompatible()
int getDwarfVersion()
std::string getAsSecureLogFile()
bool getShowMCInst()
MCTargetOptions InitMCTargetOptionsFromFlags()
bool getFatalWarnings()
bool getNoDeprecatedWarn()
bool getNoTypeCheck()
EmitDwarfUnwindType getEmitDwarfUnwind()
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.