MLIR
22.0.0git
lib
Target
Cpp
TranslateRegistration.cpp
Go to the documentation of this file.
1
//===- TranslateRegistration.cpp - Register translation -------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "
mlir/Dialect/ControlFlow/IR/ControlFlow.h
"
10
#include "
mlir/Dialect/EmitC/IR/EmitC.h
"
11
#include "
mlir/Dialect/Func/IR/FuncOps.h
"
12
#include "
mlir/Target/Cpp/CppEmitter.h
"
13
#include "
mlir/Tools/mlir-translate/Translation.h
"
14
#include "llvm/Support/CommandLine.h"
15
16
using namespace
mlir
;
17
18
namespace
mlir
{
19
20
//===----------------------------------------------------------------------===//
21
// Cpp registration
22
//===----------------------------------------------------------------------===//
23
24
void
registerToCppTranslation
() {
25
static
llvm::cl::opt<bool> declareVariablesAtTop(
26
"declare-variables-at-top"
,
27
llvm::cl::desc(
"Declare variables at top when emitting C/C++"
),
28
llvm::cl::init(
false
));
29
30
static
llvm::cl::opt<std::string> fileId(
31
"file-id"
, llvm::cl::desc(
"Emit emitc.file ops with matching id"
),
32
llvm::cl::init(
""
));
33
34
TranslateFromMLIRRegistration
reg(
35
"mlir-to-cpp"
,
"translate from mlir to cpp"
,
36
[](
Operation
*op,
raw_ostream
&output) {
37
return
emitc::translateToCpp
(
38
op, output,
39
/*declareVariablesAtTop=*/
declareVariablesAtTop,
40
/*fileId=*/
fileId);
41
},
42
[](
DialectRegistry
®istry) {
43
// clang-format off
44
registry.insert<cf::ControlFlowDialect,
45
emitc::EmitCDialect,
46
func::FuncDialect>();
47
// clang-format on
48
});
49
}
50
51
}
// namespace mlir
CppEmitter.h
FuncOps.h
Translation.h
mlir::DialectRegistry
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
Definition
DialectRegistry.h:139
mlir::Operation
Operation is the basic unit of execution within MLIR.
Definition
Operation.h:88
mlir::raw_ostream
ControlFlow.h
EmitC.h
mlir::emitc::translateToCpp
LogicalResult translateToCpp(Operation *op, raw_ostream &os, bool declareVariablesAtTop=false, StringRef fileId={})
Translates the given operation to C++ code.
Definition
TranslateToCpp.cpp:1953
mlir
Include the generated interface declarations.
Definition
AliasAnalysis.h:19
mlir::registerToCppTranslation
void registerToCppTranslation()
Definition
TranslateRegistration.cpp:24
mlir::TranslateFromMLIRRegistration
Definition
Translation.h:131
Generated on
for MLIR by
1.14.0