mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add subcommands and busybox entry points for LLVM tools (#5049)
This adds support for most of the remaining LLVM command line tools using a generic, generated wrapper. The subcommand interface for these is (much) less interesting than our other subcommands, but it gives us a uniform and consistent layer. Note that I structured these as nested sub-sub-commands below an `llvm` subcommand because of an expectation that we will want to add more, and ones that don't use this generic layer. Some concrete future work: - Add the `opt` and `llc` tools as subcommands for easier debugging and experimentation with LLVM IR output from Carbon's toolchain. - Potentially sink `lld` below the `llvm` layer given that it has significantly less user visibility than commands like `clang`. Unfortunately, the current driver subcommand APIs make nested subcommands awkward. I've added a somewhat rough hack here to let the LLVM tools go in, but there are some TODOs that I want to address in a follow-up that works to adjust the structure of this code to be more conducive to nesting like this. Depends on #5048 -- only the last commit should be reviewed here. --------- Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
co-authored by
Geoff Romer
parent
c2281d1250
commit
1459332031
@@ -0,0 +1,41 @@
|
||||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
#include "toolchain/base/llvm_tools.h"
|
||||
|
||||
#include "common/command_line.h"
|
||||
|
||||
// NOLINTBEGIN(readability-identifier-naming): External library name.
|
||||
#define CARBON_LLVM_MAIN_TOOL(Identifier, Name, BinName, MainFn) \
|
||||
extern auto MainFn(int argc, char** argv, const llvm::ToolContext& context) \
|
||||
-> int;
|
||||
#include "toolchain/base/llvm_tools.def"
|
||||
// NOLINTEND(readability-identifier-naming): External library name.
|
||||
|
||||
namespace Carbon {
|
||||
|
||||
CARBON_DEFINE_ENUM_CLASS_NAMES(LLVMTool) = {
|
||||
#define CARBON_LLVM_TOOL(Identifier, Name, BinName, MainFn) Name,
|
||||
#include "toolchain/base/llvm_tools.def"
|
||||
};
|
||||
|
||||
constexpr llvm::StringLiteral LLVMTool::BinNames[] = {
|
||||
#define CARBON_LLVM_TOOL(Identifier, Name, BinName, MainFn) BinName,
|
||||
#include "toolchain/base/llvm_tools.def"
|
||||
};
|
||||
|
||||
constexpr LLVMTool::MainFnT* LLVMTool::MainFns[] = {
|
||||
#define CARBON_LLVM_TOOL(Identifier, Name, BinName, MainFn) &::MainFn,
|
||||
#include "toolchain/base/llvm_tools.def"
|
||||
};
|
||||
|
||||
constexpr CommandLine::CommandInfo LLVMTool::SubcommandInfos[] = {
|
||||
#define CARBON_LLVM_TOOL(Identifier, Name, BinName, MainFn) \
|
||||
{.name = Name, \
|
||||
.help = "Runs the LLVM " Name \
|
||||
" command line tool with the provided arguments."},
|
||||
#include "toolchain/base/llvm_tools.def"
|
||||
};
|
||||
|
||||
} // namespace Carbon
|
||||
Reference in New Issue
Block a user