[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / mlir / lib / Target / Cpp / TranslateRegistration.cpp
blobb486e5429ea6a86e9d0d6563dcb111366bf75c33
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 //===----------------------------------------------------------------------===//
9 #include "mlir/Dialect/Arith/IR/Arith.h"
10 #include "mlir/Dialect/ControlFlow/IR/ControlFlow.h"
11 #include "mlir/Dialect/EmitC/IR/EmitC.h"
12 #include "mlir/Dialect/Func/IR/FuncOps.h"
13 #include "mlir/Dialect/Math/IR/Math.h"
14 #include "mlir/Dialect/SCF/IR/SCF.h"
15 #include "mlir/IR/BuiltinOps.h"
16 #include "mlir/IR/Dialect.h"
17 #include "mlir/Target/Cpp/CppEmitter.h"
18 #include "mlir/Tools/mlir-translate/Translation.h"
19 #include "llvm/Support/CommandLine.h"
21 using namespace mlir;
23 namespace mlir {
25 //===----------------------------------------------------------------------===//
26 // Cpp registration
27 //===----------------------------------------------------------------------===//
29 void registerToCppTranslation() {
30 static llvm::cl::opt<bool> declareVariablesAtTop(
31 "declare-variables-at-top",
32 llvm::cl::desc("Declare variables at top when emitting C/C++"),
33 llvm::cl::init(false));
35 TranslateFromMLIRRegistration reg(
36 "mlir-to-cpp", "translate from mlir to cpp",
37 [](Operation *op, raw_ostream &output) {
38 return emitc::translateToCpp(
39 op, output,
40 /*declareVariablesAtTop=*/declareVariablesAtTop);
42 [](DialectRegistry &registry) {
43 // clang-format off
44 registry.insert<arith::ArithDialect,
45 cf::ControlFlowDialect,
46 emitc::EmitCDialect,
47 func::FuncDialect,
48 math::MathDialect,
49 scf::SCFDialect>();
50 // clang-format on
51 });
54 } // namespace mlir