Skip to content

Commit f6adbc2

Browse files
Simon CamphausenSimon Camphausen
authored andcommitted
Review comment
1 parent 7841bd7 commit f6adbc2

File tree

6 files changed

+76
-37
lines changed

6 files changed

+76
-37
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===- ConvertToEmitC.h - Convert to EmitC Patterns -------------*- C++ -*-===//
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+
#ifndef MLIR_CONVERSION_CONVERTTOEMITC_CONVERTTOEMITC_H
10+
#define MLIR_CONVERSION_CONVERTTOEMITC_CONVERTTOEMITC_H
11+
12+
namespace mlir {
13+
class RewritePatternSet;
14+
class TypeConverter;
15+
16+
void populateConvertToEmitCPatterns(TypeConverter &typeConverter,
17+
RewritePatternSet &patterns);
18+
19+
void populateConvertToEmitCTypeConverter(TypeConverter &typeConverter);
20+
21+
} // namespace mlir
22+
23+
#endif // MLIR_CONVERSION_CONVERTTOEMITC_CONVERTTOEMITC_H

mlir/include/mlir/Conversion/ConvertToEmitC/ConvertToEmitCPass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace mlir {
1515
class Pass;
1616

17-
#define GEN_PASS_DECL_CONVERTTOEMITCPASS
17+
#define GEN_PASS_DECL_CONVERTTOEMITC
1818
#include "mlir/Conversion/Passes.h.inc"
1919

2020
} // namespace mlir

mlir/include/mlir/Conversion/Passes.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ include "mlir/Pass/PassBase.td"
1616
// ToEmitC
1717
//===----------------------------------------------------------------------===//
1818

19-
def ConvertToEmitCPass : Pass<"convert-to-emitc"> {
19+
def ConvertToEmitC : Pass<"convert-to-emitc"> {
2020
let summary = "Convert to EmitC dialect";
2121
let description = [{
2222
This is a generic pass to convert to the EmitC dialect.
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
set(LLVM_OPTIONAL_SOURCES
2-
ConvertToEmitCPass.cpp
3-
)
4-
5-
add_mlir_conversion_library(MLIRConvertToEmitCPass
1+
add_mlir_conversion_library(MLIRConvertToEmitC
62
ConvertToEmitCPass.cpp
3+
ConvertToEmitC.cpp
74

85
ADDITIONAL_HEADER_DIRS
96
${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/ConvertToEmitC
@@ -14,12 +11,8 @@ add_mlir_conversion_library(MLIRConvertToEmitCPass
1411
LINK_LIBS PUBLIC
1512
MLIRArithToEmitC
1613
MLIRFuncToEmitC
17-
MLIRIR
1814
MLIRMemRefToEmitC
1915
MLIRPass
20-
MLIRRewrite
2116
MLIRSCFToEmitC
22-
MLIRSupport
23-
MLIRTransforms
2417
MLIRTransformUtils
2518
)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//===- ConvertToEmitC.cpp - Convert to EmitC Patterns -----------*- C++ -*-===//
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/Conversion/ConvertToEmitC/ConvertToEmitC.h"
10+
#include "mlir/Conversion/ArithToEmitC/ArithToEmitC.h"
11+
#include "mlir/Conversion/FuncToEmitC/FuncToEmitC.h"
12+
#include "mlir/Conversion/MemRefToEmitC/MemRefToEmitC.h"
13+
#include "mlir/Conversion/SCFToEmitC/SCFToEmitC.h"
14+
#include "mlir/Dialect/Arith/IR/Arith.h"
15+
#include "mlir/Dialect/EmitC/IR/EmitC.h"
16+
#include "mlir/Dialect/Func/IR/FuncOps.h"
17+
#include "mlir/Dialect/MemRef/IR/MemRef.h"
18+
#include "mlir/Dialect/SCF/IR/SCF.h"
19+
#include "mlir/IR/PatternMatch.h"
20+
#include "mlir/Pass/Pass.h"
21+
#include "mlir/Rewrite/FrozenRewritePatternSet.h"
22+
#include "mlir/Transforms/DialectConversion.h"
23+
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
24+
25+
#define DEBUG_TYPE "convert-to-emitc"
26+
27+
using namespace mlir;
28+
29+
void mlir::populateConvertToEmitCTypeConverter(TypeConverter &typeConverter) {
30+
typeConverter.addConversion([](Type type) { return type; });
31+
populateMemRefToEmitCTypeConversion(typeConverter);
32+
}
33+
34+
/// Populate patterns for each dialect.
35+
void mlir::populateConvertToEmitCPatterns(TypeConverter &typeConverter,
36+
RewritePatternSet &patterns) {
37+
populateArithToEmitCPatterns(typeConverter, patterns);
38+
populateFuncToEmitCPatterns(patterns);
39+
populateMemRefToEmitCConversionPatterns(patterns, typeConverter);
40+
populateSCFToEmitCConversionPatterns(patterns);
41+
populateFunctionOpInterfaceTypeConversionPattern<emitc::FuncOp>(
42+
patterns, typeConverter);
43+
}

mlir/lib/Conversion/ConvertToEmitC/ConvertToEmitCPass.cpp

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- ConvertToEmitCPass.cpp - MLIR EmitC Conversion ---------------------===//
1+
//===- ConvertToEmitCPass.cpp - Conversion to EmitC pass --*- C++ -*-=========//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,10 +7,9 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "mlir/Conversion/ConvertToEmitC/ConvertToEmitCPass.h"
10+
1011
#include "mlir/Conversion/ArithToEmitC/ArithToEmitC.h"
11-
#include "mlir/Conversion/FuncToEmitC/FuncToEmitC.h"
12-
#include "mlir/Conversion/MemRefToEmitC/MemRefToEmitC.h"
13-
#include "mlir/Conversion/SCFToEmitC/SCFToEmitC.h"
12+
#include "mlir/Conversion/ConvertToEmitC/ConvertToEmitC.h"
1413
#include "mlir/Dialect/Arith/IR/Arith.h"
1514
#include "mlir/Dialect/EmitC/IR/EmitC.h"
1615
#include "mlir/Dialect/Func/IR/FuncOps.h"
@@ -22,37 +21,18 @@
2221
#include "mlir/Transforms/DialectConversion.h"
2322
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
2423

25-
#define DEBUG_TYPE "convert-to-emitc"
26-
2724
namespace mlir {
28-
#define GEN_PASS_DEF_CONVERTTOEMITCPASS
25+
#define GEN_PASS_DEF_CONVERTTOEMITC
2926
#include "mlir/Conversion/Passes.h.inc"
3027
} // namespace mlir
3128

3229
using namespace mlir;
3330

3431
namespace {
3532

36-
void populateConvertToEmitCTypeConverter(TypeConverter &typeConverter) {
37-
typeConverter.addConversion([](Type type) { return type; });
38-
populateMemRefToEmitCTypeConversion(typeConverter);
39-
}
40-
41-
/// Populate patterns for each dialect.
42-
void populateConvertToEmitCPatterns(TypeConverter &typeConverter,
43-
RewritePatternSet &patterns) {
44-
populateArithToEmitCPatterns(typeConverter, patterns);
45-
populateFuncToEmitCPatterns(patterns);
46-
populateMemRefToEmitCConversionPatterns(patterns, typeConverter);
47-
populateSCFToEmitCConversionPatterns(patterns);
48-
populateFunctionOpInterfaceTypeConversionPattern<emitc::FuncOp>(
49-
patterns, typeConverter);
50-
}
51-
5233
/// A pass to perform the EmitC conversion.
53-
struct ConvertToEmitCPass final
54-
: impl::ConvertToEmitCPassBase<ConvertToEmitCPass> {
55-
using ConvertToEmitCPassBase::ConvertToEmitCPassBase;
34+
struct ConvertToEmitC final : impl::ConvertToEmitCBase<ConvertToEmitC> {
35+
using ConvertToEmitCBase::ConvertToEmitCBase;
5636

5737
void runOnOperation() override {
5838
Operation *op = getOperation();

0 commit comments

Comments
 (0)