LLVM  15.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  Optional<TY> llvm::mc::getExplicit##NAME() { \
30  if (NAME##View->getNumOccurrences()) { \
31  TY res = *NAME##View; \
32  return res; \
33  } \
34  return None; \
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 
50 #define MCBINDOPT(NAME) \
51  do { \
52  NAME##View = std::addressof(NAME); \
53  } while (0)
54 
55  static cl::opt<bool> RelaxAll(
56  "mc-relax-all", cl::desc("When used with filetype=obj, relax all fixups "
57  "in the emitted object file"));
58  MCBINDOPT(RelaxAll);
59 
60  static cl::opt<bool> IncrementalLinkerCompatible(
61  "incremental-linker-compatible",
62  cl::desc(
63  "When used with filetype=obj, "
64  "emit an object file which can be used with an incremental linker"));
65  MCBINDOPT(IncrementalLinkerCompatible);
66 
67  static cl::opt<int> DwarfVersion("dwarf-version", cl::desc("Dwarf version"),
68  cl::init(0));
69  MCBINDOPT(DwarfVersion);
70 
71  static cl::opt<bool> Dwarf64(
72  "dwarf64",
73  cl::desc("Generate debugging info in the 64-bit DWARF format"));
74  MCBINDOPT(Dwarf64);
75 
76  static cl::opt<EmitDwarfUnwindType> EmitDwarfUnwind(
77  "emit-dwarf-unwind", cl::desc("Whether to emit DWARF EH frame entries."),
80  "Always emit EH frame entries"),
82  "no-compact-unwind",
83  "Only emit EH frame entries when compact unwind is "
84  "not available"),
86  "Use target platform default")));
87  MCBINDOPT(EmitDwarfUnwind);
88 
89  static cl::opt<bool> ShowMCInst(
90  "asm-show-inst",
91  cl::desc("Emit internal instruction representation to assembly file"));
92  MCBINDOPT(ShowMCInst);
93 
94  static cl::opt<bool> FatalWarnings("fatal-warnings",
95  cl::desc("Treat warnings as errors"));
96  MCBINDOPT(FatalWarnings);
97 
98  static cl::opt<bool> NoWarn("no-warn", cl::desc("Suppress all warnings"));
99  static cl::alias NoWarnW("W", cl::desc("Alias for --no-warn"),
100  cl::aliasopt(NoWarn));
101  MCBINDOPT(NoWarn);
102 
103  static cl::opt<bool> NoDeprecatedWarn(
104  "no-deprecated-warn", cl::desc("Suppress all deprecated warnings"));
105  MCBINDOPT(NoDeprecatedWarn);
106 
107  static cl::opt<bool> NoTypeCheck(
108  "no-type-check", cl::desc("Suppress type errors (Wasm)"));
109  MCBINDOPT(NoTypeCheck);
110 
111  static cl::opt<std::string> ABIName(
112  "target-abi", cl::Hidden,
113  cl::desc("The name of the ABI to be targeted from the backend."),
114  cl::init(""));
115  MCBINDOPT(ABIName);
116 
117 #undef MCBINDOPT
118 }
119 
122  Options.MCRelaxAll = getRelaxAll();
123  Options.MCIncrementalLinkerCompatible = getIncrementalLinkerCompatible();
124  Options.Dwarf64 = getDwarf64();
125  Options.DwarfVersion = getDwarfVersion();
126  Options.ShowMCInst = getShowMCInst();
127  Options.ABIName = getABIName();
128  Options.MCFatalWarnings = getFatalWarnings();
129  Options.MCNoWarn = getNoWarn();
130  Options.MCNoDeprecatedWarn = getNoDeprecatedWarn();
131  Options.MCNoTypeCheck = getNoTypeCheck();
132  Options.EmitDwarfUnwind = getEmitDwarfUnwind();
133 
134  return Options;
135 }
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
MCTargetOptions.h
MCTargetOptionsCommandFlags.h
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:139
llvm::mc::InitMCTargetOptionsFromFlags
MCTargetOptions InitMCTargetOptionsFromFlags()
Definition: MCTargetOptionsCommandFlags.cpp:120
llvm::EmitDwarfUnwindType::NoCompactUnwind
@ NoCompactUnwind
MCBINDOPT
#define MCBINDOPT(NAME)
llvm::EmitDwarfUnwindType
EmitDwarfUnwindType
Definition: MCTargetOptions.h:34
llvm::mc::getIncrementalLinkerCompatible
bool getIncrementalLinkerCompatible()
CommandLine.h
llvm::EmitDwarfUnwindType::Default
@ Default
llvm::cl::aliasopt
Definition: CommandLine.h:1898
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:685
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:432
llvm::mc::getDwarfVersion
int getDwarfVersion()
llvm::mc::getABIName
std::string getABIName()
llvm::MCTargetOptions
Definition: MCTargetOptions.h:42
MCOPT_EXP
#define MCOPT_EXP(TY, NAME)
Definition: MCTargetOptionsCommandFlags.cpp:27
llvm::cl::alias
Definition: CommandLine.h:1839
clEnumValN
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:660
llvm::mc::RegisterMCTargetOptionsFlags
Create this object with static storage to register mc-related command line options.
Definition: MCTargetOptionsCommandFlags.h:52
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:405
llvm::mc::getNoWarn
bool getNoWarn()