1 //===-- MCTargetOptionsCommandFlags.cpp --------------------------*- C++
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 // This file contains machine code-specific flags that are shared between
11 // different command line tools.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/MC/MCTargetOptionsCommandFlags.h"
16 #include "llvm/MC/MCTargetOptions.h"
17 #include "llvm/Support/CommandLine.h"
21 #define MCOPT(TY, NAME) \
22 static cl::opt<TY> *NAME##View; \
23 TY llvm::mc::get##NAME() { \
24 assert(NAME##View && "RegisterMCTargetOptionsFlags not created."); \
28 #define MCOPT_EXP(TY, NAME) \
30 Optional<TY> llvm::mc::getExplicit##NAME() { \
31 if (NAME##View->getNumOccurrences()) { \
32 TY res = *NAME##View; \
38 MCOPT_EXP(bool, RelaxAll
)
39 MCOPT(bool, IncrementalLinkerCompatible
)
40 MCOPT(int, DwarfVersion
)
42 MCOPT(bool, ShowMCInst
)
43 MCOPT(bool, FatalWarnings
)
45 MCOPT(bool, NoDeprecatedWarn
)
46 MCOPT(bool, NoTypeCheck
)
47 MCOPT(std::string
, ABIName
)
49 llvm::mc::RegisterMCTargetOptionsFlags::RegisterMCTargetOptionsFlags() {
50 #define MCBINDOPT(NAME) \
52 NAME##View = std::addressof(NAME); \
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"));
60 static cl::opt
<bool> IncrementalLinkerCompatible(
61 "incremental-linker-compatible",
63 "When used with filetype=obj, "
64 "emit an object file which can be used with an incremental linker"));
65 MCBINDOPT(IncrementalLinkerCompatible
);
67 static cl::opt
<int> DwarfVersion("dwarf-version", cl::desc("Dwarf version"),
69 MCBINDOPT(DwarfVersion
);
71 static cl::opt
<bool> Dwarf64(
73 cl::desc("Generate debugging info in the 64-bit DWARF format"));
76 static cl::opt
<bool> ShowMCInst(
78 cl::desc("Emit internal instruction representation to assembly file"));
79 MCBINDOPT(ShowMCInst
);
81 static cl::opt
<bool> FatalWarnings("fatal-warnings",
82 cl::desc("Treat warnings as errors"));
83 MCBINDOPT(FatalWarnings
);
85 static cl::opt
<bool> NoWarn("no-warn", cl::desc("Suppress all warnings"));
86 static cl::alias
NoWarnW("W", cl::desc("Alias for --no-warn"),
87 cl::aliasopt(NoWarn
));
90 static cl::opt
<bool> NoDeprecatedWarn(
91 "no-deprecated-warn", cl::desc("Suppress all deprecated warnings"));
92 MCBINDOPT(NoDeprecatedWarn
);
94 static cl::opt
<bool> NoTypeCheck(
95 "no-type-check", cl::desc("Suppress type errors (Wasm)"));
96 MCBINDOPT(NoTypeCheck
);
98 static cl::opt
<std::string
> ABIName(
99 "target-abi", cl::Hidden
,
100 cl::desc("The name of the ABI to be targeted from the backend."),
107 MCTargetOptions
llvm::mc::InitMCTargetOptionsFromFlags() {
108 MCTargetOptions Options
;
109 Options
.MCRelaxAll
= getRelaxAll();
110 Options
.MCIncrementalLinkerCompatible
= getIncrementalLinkerCompatible();
111 Options
.Dwarf64
= getDwarf64();
112 Options
.DwarfVersion
= getDwarfVersion();
113 Options
.ShowMCInst
= getShowMCInst();
114 Options
.ABIName
= getABIName();
115 Options
.MCFatalWarnings
= getFatalWarnings();
116 Options
.MCNoWarn
= getNoWarn();
117 Options
.MCNoDeprecatedWarn
= getNoDeprecatedWarn();
118 Options
.MCNoTypeCheck
= getNoTypeCheck();