35#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID,
40#define PREFIX(NAME, VALUE) \
41 static constexpr StringLiteral NAME##_init[] = VALUE; \
42 static constexpr ArrayRef<StringLiteral> NAME(NAME##_init, \
43 std::size(NAME##_init) - 1);
48#define OPTION(X1, X2, ID, KIND, GROUP, ALIAS, X7, X8, X9, X10, X11, X12) \
49 {X1, X2, X10, X11, OPT_##ID, llvm::opt::Option::KIND##Class, \
50 X9, X8, OPT_##GROUP, OPT_##ALIAS, X7, X12},
57 DllOptTable() :
opt::GenericOptTable(InfoTable,
false) {}
64 if (std::error_code EC = MB.
getError()) {
69 return std::move(*MB);
82 switch (
T.getArch()) {
100std::optional<std::string> getPrefix(
StringRef Argv0) {
105 ProgName = ProgName.
rtrim(
"0123456789.-");
110 return ProgName.
str();
117 unsigned MissingIndex;
118 unsigned MissingCount;
120 Table.ParseArgs(ArgsArr.
slice(1), MissingIndex, MissingCount);
122 llvm::errs() << Args.getArgString(MissingIndex) <<
": missing argument\n";
127 if (Args.hasArgNoClaim(OPT_INPUT) ||
128 (!Args.hasArgNoClaim(OPT_d) && !Args.hasArgNoClaim(OPT_l))) {
129 Table.printHelp(
outs(),
"llvm-dlltool [options] file...",
"llvm-dlltool",
131 llvm::outs() <<
"\nTARGETS: i386, i386:x86-64, arm, arm64\n";
135 for (
auto *
Arg : Args.filtered(OPT_UNKNOWN))
136 llvm::errs() <<
"ignoring unknown argument: " <<
Arg->getAsString(Args)
139 if (!Args.hasArg(OPT_d)) {
140 llvm::errs() <<
"no definition file specified\n";
144 std::unique_ptr<MemoryBuffer> MB =
145 openFile(Args.getLastArg(OPT_d)->getValue());
149 if (!MB->getBufferSize()) {
155 if (std::optional<std::string> Prefix = getPrefix(ArgsArr[0])) {
158 Machine = getMachine(
T);
160 if (
auto *
Arg = Args.getLastArg(OPT_m))
161 Machine = getEmulation(
Arg->getValue());
178 if (
auto *
Arg = Args.getLastArg(OPT_D))
179 Def->OutputFile =
Arg->getValue();
181 if (Def->OutputFile.empty()) {
186 std::string Path = std::string(Args.getLastArgValue(OPT_l));
194 if (!
E.ExtName.empty()) {
202 if (!
E.AliasTarget.empty() || (!
E.Name.empty() &&
E.Name[0] ==
'?'))
204 E.SymbolName =
E.Name;
210 E.Name =
E.Name.substr(0,
E.Name.find(
'@', 1));
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Defines the llvm::Arg class for parsed arguments.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::unique_ptr< MemoryBuffer > openFile(const Twine &Path)
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Represents either an error or a value T.
std::error_code getError() const
Tagged union holding either a T or a Error.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
StringRef rtrim(char Char) const
Return string with consecutive Char characters starting from the right removed.
bool consume_back_insensitive(StringRef Suffix)
Returns true if this StringRef has the given suffix, ignoring case, and removes that suffix.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Specialization of OptTable.
@ IMAGE_FILE_MACHINE_ARM64
@ IMAGE_FILE_MACHINE_UNKNOWN
@ IMAGE_FILE_MACHINE_AMD64
@ IMAGE_FILE_MACHINE_I386
@ IMAGE_FILE_MACHINE_ARMNT
Expected< COFFModuleDefinition > parseCOFFModuleDefinition(MemoryBufferRef MB, COFF::MachineTypes Machine, bool MingwDef=false)
Error writeImportLibrary(StringRef ImportName, StringRef Path, ArrayRef< COFFShortExport > Exports, COFF::MachineTypes Machine, bool MinGW)
StringRef stem(StringRef path, Style style=Style::native)
Get stem.
std::string getDefaultTargetTriple()
getDefaultTargetTriple() - Return the default target triple the compiler has been configured to produ...
This is an optimization pass for GlobalISel generic memory operations.
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
int dlltoolDriverMain(ArrayRef< const char * > ArgsArr)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
std::error_code errorToErrorCode(Error Err)
Helper for converting an ECError to a std::error_code.
Entry for a single option instance in the option data table.