Revert "[MLIR][IRDL] Added IRDL to C++ Translation" (#138285)
Reverts llvm/llvm-project#133982
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
add_llvm_executable(mlir-irdl-to-cpp
|
||||
mlir-irdl-to-cpp.cpp
|
||||
)
|
||||
mlir_target_link_libraries(mlir-irdl-to-cpp
|
||||
PRIVATE
|
||||
MLIRTargetIRDLToCpp
|
||||
)
|
||||
|
||||
# Set up a native build when cross-compiling.
|
||||
if(LLVM_USE_HOST_TOOLS)
|
||||
build_native_tool(
|
||||
mlir-irdl-to-cpp
|
||||
MLIR_IRDL_TO_CPP_EXE
|
||||
|
||||
# Native tool must depend on target tool so that the native tool gets
|
||||
# properly rebuilt when the target tool changes.
|
||||
DEPENDS mlir-irdl-to-cpp
|
||||
)
|
||||
add_custom_target(mlir-irdl-to-cpp-host DEPENDS ${MLIR_IRDL_TO_CPP_EXE})
|
||||
set(MLIR_IRDL_TO_CPP_TARGET mlir-irdl-to-cpp-host)
|
||||
else()
|
||||
set(MLIR_IRDL_TO_CPP_EXE $<TARGET_FILE:mlir-irdl-to-cpp>)
|
||||
set(MLIR_IRDL_TO_CPP_TARGET mlir-irdl-to-cpp)
|
||||
endif()
|
||||
|
||||
# Save the executable path and target name to the cache to expose it globally.
|
||||
set(MLIR_IRDL_TO_CPP_EXE "${MLIR_IRDL_TO_CPP_EXE}" CACHE INTERNAL "")
|
||||
set(MLIR_IRDL_TO_CPP_TARGET "${MLIR_IRDL_TO_CPP_TARGET}" CACHE INTERNAL "")
|
||||
@@ -1,143 +0,0 @@
|
||||
//===- mlir-irdl-to-cpp.cpp - IRDL to C++ conversion tool -----------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This is a command line utility that translates an IRDL dialect definition
|
||||
// into a C++ implementation to be included in MLIR.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "mlir/Dialect/IRDL/IR/IRDL.h"
|
||||
#include "mlir/IR/AsmState.h"
|
||||
#include "mlir/IR/DialectRegistry.h"
|
||||
#include "mlir/IR/MLIRContext.h"
|
||||
#include "mlir/Support/FileUtilities.h"
|
||||
#include "mlir/Support/ToolUtilities.h"
|
||||
#include "mlir/Target/IRDLToCpp/IRDLToCpp.h"
|
||||
#include "mlir/Tools/ParseUtilities.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/InitLLVM.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/SourceMgr.h"
|
||||
#include "llvm/Support/ToolOutputFile.h"
|
||||
|
||||
using namespace mlir;
|
||||
|
||||
static LogicalResult
|
||||
processBuffer(llvm::raw_ostream &os,
|
||||
std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
|
||||
bool verifyDiagnostics, llvm::ThreadPoolInterface *threadPool) {
|
||||
// Tell sourceMgr about this buffer, which is what the parser will pick up.
|
||||
auto sourceMgr = std::make_shared<llvm::SourceMgr>();
|
||||
sourceMgr->AddNewSourceBuffer(std::move(ownedBuffer), SMLoc());
|
||||
|
||||
DialectRegistry registry;
|
||||
registry.insert<irdl::IRDLDialect>();
|
||||
MLIRContext ctx(registry);
|
||||
|
||||
ctx.printOpOnDiagnostic(!verifyDiagnostics);
|
||||
|
||||
auto runTranslation = [&]() {
|
||||
ParserConfig parseConfig(&ctx);
|
||||
OwningOpRef<Operation *> op =
|
||||
parseSourceFileForTool(sourceMgr, parseConfig, true);
|
||||
if (!op)
|
||||
return failure();
|
||||
|
||||
auto moduleOp = llvm::cast<ModuleOp>(*op);
|
||||
llvm::SmallVector<irdl::DialectOp> dialects{
|
||||
moduleOp.getOps<irdl::DialectOp>(),
|
||||
};
|
||||
|
||||
return irdl::translateIRDLDialectToCpp(dialects, os);
|
||||
};
|
||||
|
||||
if (!verifyDiagnostics) {
|
||||
// If no errors are expected, return translation result.
|
||||
SourceMgrDiagnosticHandler srcManagerHandler(*sourceMgr, &ctx);
|
||||
return runTranslation();
|
||||
}
|
||||
|
||||
// If errors are expected, ignore translation result and check for
|
||||
// diagnostics.
|
||||
SourceMgrDiagnosticVerifierHandler srcManagerHandler(*sourceMgr, &ctx);
|
||||
(void)runTranslation();
|
||||
return srcManagerHandler.verify();
|
||||
}
|
||||
|
||||
static LogicalResult translateIRDLToCpp(int argc, char **argv) {
|
||||
static llvm::cl::opt<std::string> inputFilename(
|
||||
llvm::cl::Positional, llvm::cl::desc("<input file>"),
|
||||
llvm::cl::init("-"));
|
||||
|
||||
static llvm::cl::opt<std::string> outputFilename(
|
||||
"o", llvm::cl::desc("Output filename"), llvm::cl::value_desc("filename"),
|
||||
llvm::cl::init("-"));
|
||||
|
||||
bool verifyDiagnosticsFlag;
|
||||
std::string splitInputFileFlag;
|
||||
static llvm::cl::opt<bool, true> verifyDiagnostics(
|
||||
"verify-diagnostics",
|
||||
llvm::cl::desc("Check that emitted diagnostics match "
|
||||
"expected-* lines on the corresponding line"),
|
||||
llvm::cl::location(verifyDiagnosticsFlag), llvm::cl::init(false));
|
||||
|
||||
static llvm::cl::opt<std::string, true> splitInputFile(
|
||||
"split-input-file", llvm::cl::ValueOptional,
|
||||
llvm::cl::callback([&](const std::string &str) {
|
||||
// Implicit value: use default marker if flag was used without
|
||||
// value.
|
||||
if (str.empty())
|
||||
splitInputFile.setValue(kDefaultSplitMarker);
|
||||
}),
|
||||
llvm::cl::desc("Split the input file into chunks using the given or "
|
||||
"default marker and process each chunk independently"),
|
||||
llvm::cl::location(splitInputFileFlag), llvm::cl::init(""));
|
||||
|
||||
llvm::InitLLVM y(argc, argv);
|
||||
|
||||
llvm::cl::ParseCommandLineOptions(argc, argv, "mlir-irdl-to-cpp");
|
||||
|
||||
std::string errorMessage;
|
||||
std::unique_ptr<llvm::MemoryBuffer> input =
|
||||
openInputFile(inputFilename, &errorMessage);
|
||||
if (!input) {
|
||||
llvm::errs() << errorMessage << "\n";
|
||||
return failure();
|
||||
}
|
||||
|
||||
std::unique_ptr<llvm::ToolOutputFile> output =
|
||||
openOutputFile(outputFilename, &errorMessage);
|
||||
|
||||
if (!output) {
|
||||
llvm::errs() << errorMessage << "\n";
|
||||
return failure();
|
||||
}
|
||||
|
||||
auto chunkFn = [&](std::unique_ptr<llvm::MemoryBuffer> chunkBuffer,
|
||||
raw_ostream &os) {
|
||||
return processBuffer(output->os(), std::move(chunkBuffer),
|
||||
verifyDiagnostics, nullptr);
|
||||
};
|
||||
|
||||
if (splitInputFileFlag.size())
|
||||
return splitAndProcessBuffer(std::move(input), chunkFn, output->os(),
|
||||
splitInputFileFlag, splitInputFileFlag);
|
||||
|
||||
if (failed(chunkFn(std::move(input), output->os())))
|
||||
return failure();
|
||||
|
||||
if (!verifyDiagnosticsFlag)
|
||||
output->keep();
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
return failed(translateIRDLToCpp(argc, argv));
|
||||
}
|
||||
@@ -52,7 +52,6 @@ if(MLIR_INCLUDE_TESTS)
|
||||
set(test_libs ${test_libs}
|
||||
MLIRTestPDLL
|
||||
MLIRTestTransformDialect
|
||||
MLIRTestIRDLToCppDialect
|
||||
)
|
||||
|
||||
if (MLIR_ENABLE_PDL_IN_PATTERNMATCH)
|
||||
|
||||
@@ -128,7 +128,6 @@ void registerTestMatchReductionPass();
|
||||
void registerTestMathAlgebraicSimplificationPass();
|
||||
void registerTestMathPolynomialApproximationPass();
|
||||
void registerTestMathToVCIXPass();
|
||||
void registerTestIrdlTestDialectConversionPass();
|
||||
void registerTestMemRefDependenceCheck();
|
||||
void registerTestMemRefStrideCalculation();
|
||||
void registerTestMeshReshardingSpmdizationPass();
|
||||
@@ -172,7 +171,6 @@ void registerTestDialect(DialectRegistry &);
|
||||
void registerTestDynDialect(DialectRegistry &);
|
||||
void registerTestTilingInterfaceTransformDialectExtension(DialectRegistry &);
|
||||
void registerTestTransformDialectExtension(DialectRegistry &);
|
||||
void registerIrdlTestDialect(DialectRegistry &);
|
||||
void registerTestTransformsTransformDialectExtension(DialectRegistry &);
|
||||
} // namespace test
|
||||
|
||||
@@ -303,7 +301,6 @@ void registerTestPasses() {
|
||||
mlir::test::registerTestVectorReductionToSPIRVDotProd();
|
||||
mlir::test::registerTestVulkanRunnerPipeline();
|
||||
mlir::test::registerTestWrittenToPass();
|
||||
mlir::test::registerTestIrdlTestDialectConversionPass();
|
||||
#if MLIR_ENABLE_PDL_IN_PATTERNMATCH
|
||||
mlir::test::registerTestDialectConversionPasses();
|
||||
mlir::test::registerTestPDLByteCodePass();
|
||||
@@ -332,7 +329,6 @@ int main(int argc, char **argv) {
|
||||
::test::registerTestTransformsTransformDialectExtension(registry);
|
||||
::test::registerTestTilingInterfaceTransformDialectExtension(registry);
|
||||
::test::registerTestDynDialect(registry);
|
||||
::test::registerIrdlTestDialect(registry);
|
||||
#endif
|
||||
return mlir::asMainReturnCode(mlir::MlirOptMain(
|
||||
argc, argv, "MLIR modular optimizer driver\n", registry));
|
||||
|
||||
Reference in New Issue
Block a user