llvm-project/mlir/lib/Target/Cpp/TranslateRegistration.cpp
changkaiyan c4cc755c72 [mlir][mlir-translation] patch for standalone-translation command line description missing.
Differential Revision: https://reviews.llvm.org/D134696

	modified:   mlir/examples/standalone/standalone-translate/standalone-translate.cpp
	modified:   mlir/include/mlir/Tools/mlir-translate/Translation.h
	modified:   mlir/lib/Target/Cpp/TranslateRegistration.cpp
	modified:   mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
	modified:   mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp
	modified:   mlir/lib/Target/SPIRV/TranslateRegistration.cpp
	modified:   mlir/lib/Tools/mlir-translate/Translation.cpp
2022-10-04 09:14:40 +08:00

55 lines
1.9 KiB
C++

//===- TranslateRegistration.cpp - Register translation -------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlow.h"
#include "mlir/Dialect/EmitC/IR/EmitC.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Math/IR/Math.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Dialect.h"
#include "mlir/Target/Cpp/CppEmitter.h"
#include "mlir/Tools/mlir-translate/Translation.h"
#include "llvm/Support/CommandLine.h"
using namespace mlir;
namespace mlir {
//===----------------------------------------------------------------------===//
// Cpp registration
//===----------------------------------------------------------------------===//
void registerToCppTranslation() {
static llvm::cl::opt<bool> declareVariablesAtTop(
"declare-variables-at-top",
llvm::cl::desc("Declare variables at top when emitting C/C++"),
llvm::cl::init(false));
TranslateFromMLIRRegistration reg(
"mlir-to-cpp", "translate from mlir to cpp",
[](ModuleOp module, raw_ostream &output) {
return emitc::translateToCpp(
module, output,
/*declareVariablesAtTop=*/declareVariablesAtTop);
},
[](DialectRegistry &registry) {
// clang-format off
registry.insert<arith::ArithDialect,
cf::ControlFlowDialect,
emitc::EmitCDialect,
func::FuncDialect,
math::MathDialect,
scf::SCFDialect>();
// clang-format on
});
}
} // namespace mlir