LLVM  16.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 
18 using 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 
37 MCOPT_EXP(bool, RelaxAll)
38 MCOPT(bool, IncrementalLinkerCompatible)
39 MCOPT(int, DwarfVersion)
40 MCOPT(bool, Dwarf64)
41 MCOPT(EmitDwarfUnwindType, EmitDwarfUnwind)
42 MCOPT(bool, ShowMCInst)
43 MCOPT(bool, FatalWarnings)
44 MCOPT(bool, NoWarn)
45 MCOPT(bool, NoDeprecatedWarn)
46 MCOPT(bool, NoTypeCheck)
47 MCOPT(std::string, ABIName)
48 MCOPT(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",
63  cl::desc(
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."),
81  "Always emit EH frame entries"),
83  "no-compact-unwind",
84  "Only emit EH frame entries when compact unwind is "
85  "not available"),
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 }
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
MCTargetOptions.h
MCTargetOptionsCommandFlags.h
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:139
llvm::mc::InitMCTargetOptionsFromFlags
MCTargetOptions InitMCTargetOptionsFromFlags()
Definition: MCTargetOptionsCommandFlags.cpp:125
llvm::EmitDwarfUnwindType::NoCompactUnwind
@ NoCompactUnwind
MCBINDOPT
#define MCBINDOPT(NAME)
llvm::EmitDwarfUnwindType
EmitDwarfUnwindType
Definition: MCTargetOptions.h:29
llvm::mc::getIncrementalLinkerCompatible
bool getIncrementalLinkerCompatible()
CommandLine.h
llvm::EmitDwarfUnwindType::Default
@ Default
llvm::cl::aliasopt
Definition: CommandLine.h:1964
MCOPT
#define MCOPT(TY, NAME)
Definition: MCTargetOptionsCommandFlags.cpp:20
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
llvm::mc::getNoTypeCheck
bool getNoTypeCheck()
llvm::cl::opt< bool >
llvm::mc::getDwarf64
bool getDwarf64()
llvm::cl::values
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:704
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:446
llvm::mc::getDwarfVersion
int getDwarfVersion()
llvm::mc::getABIName
std::string getABIName()
llvm::MCTargetOptions
Definition: MCTargetOptions.h:37
MCOPT_EXP
#define MCOPT_EXP(TY, NAME)
Definition: MCTargetOptionsCommandFlags.cpp:27
llvm::cl::alias
Definition: CommandLine.h:1905
clEnumValN
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:679
llvm::mc::RegisterMCTargetOptionsFlags
Create this object with static storage to register mc-related command line options.
Definition: MCTargetOptionsCommandFlags.h:54
llvm::mc::getAsSecureLogFile
std::string getAsSecureLogFile()
llvm::mc::getNoDeprecatedWarn
bool getNoDeprecatedWarn()
llvm::mc::getShowMCInst
bool getShowMCInst()
llvm::mc::getEmitDwarfUnwind
EmitDwarfUnwindType getEmitDwarfUnwind()
llvm::mc::getFatalWarnings
bool getFatalWarnings()
llvm::EmitDwarfUnwindType::Always
@ Always
llvm::mc::getRelaxAll
bool getRelaxAll()
llvm::cl::desc
Definition: CommandLine.h:412
llvm::mc::getNoWarn
bool getNoWarn()