Skip to content

Commit 5e86788

Browse files
committed
[mlir][emitc][NFC] Clean up EmitC
1 parent ed5bd23 commit 5e86788

File tree

10 files changed

+1492
-1476
lines changed

10 files changed

+1492
-1476
lines changed

mlir/include/mlir/Dialect/EmitC/IR/EmitC.td

Lines changed: 743 additions & 743 deletions
Large diffs are not rendered by default.

mlir/lib/Dialect/EmitC/IR/EmitC.cpp

Lines changed: 502 additions & 498 deletions
Large diffs are not rendered by default.

mlir/test/Dialect/EmitC/attrs.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: mlir-opt -verify-diagnostics %s | FileCheck %s
1+
// RUN: mlir-opt %s | FileCheck %s
22
// check parser
3-
// RUN: mlir-opt -verify-diagnostics %s | mlir-opt -verify-diagnostics | FileCheck %s
3+
// RUN: mlir-opt %s | mlir-opt | FileCheck %s
44

55
// CHECK-LABEL: func @opaque_attrs() {
66
func.func @opaque_attrs() {

mlir/test/Dialect/EmitC/ops.mlir

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,15 @@ func.func @switch() {
310310

311311
return
312312
}
313+
314+
emitc.class final @finalClass {
315+
emitc.field @fieldName0 : !emitc.array<1xf32>
316+
emitc.field @fieldName1 : !emitc.array<1xf32>
317+
emitc.func @execute() {
318+
%0 = "emitc.constant"() <{value = 0 : index}> : () -> !emitc.size_t
319+
%1 = get_field @fieldName0 : !emitc.array<1xf32>
320+
%2 = get_field @fieldName1 : !emitc.array<1xf32>
321+
%3 = subscript %1[%0] : (!emitc.array<1xf32>, !emitc.size_t) -> !emitc.lvalue<f32>
322+
return
323+
}
324+
}

mlir/test/Dialect/EmitC/transforms.mlir

Lines changed: 152 additions & 95 deletions
Large diffs are not rendered by default.

mlir/test/Dialect/EmitC/types.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: mlir-opt -verify-diagnostics -allow-unregistered-dialect %s | FileCheck %s
2-
// check parser
3-
// RUN: mlir-opt -verify-diagnostics -allow-unregistered-dialect %s | mlir-opt -verify-diagnostics --allow-unregistered-dialect | FileCheck %s
1+
// RUN: mlir-opt %s -allow-unregistered-dialect | FileCheck %s
2+
// Check parser
3+
// RUN: mlir-opt %s -allow-unregistered-dialect | mlir-opt -allow-unregistered-dialect | FileCheck %s
44

55
// CHECK-LABEL: func @array_types(
66
func.func @array_types(

mlir/test/Dialect/EmitC/wrap_emitc_func_in_class.mlir

Lines changed: 0 additions & 40 deletions
This file was deleted.

mlir/test/Dialect/EmitC/wrap_emitc_func_in_class_noAttr.mlir

Lines changed: 0 additions & 17 deletions
This file was deleted.

mlir/test/Target/Cpp/class.mlir

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// RUN: mlir-translate -mlir-to-cpp %s | FileCheck %s
2+
3+
emitc.class @modelClass {
4+
emitc.field @fieldName0 : !emitc.array<1xf32>
5+
emitc.field @fieldName1 : !emitc.array<1xf32>
6+
emitc.func @execute() {
7+
%0 = "emitc.constant"() <{value = 0 : index}> : () -> !emitc.size_t
8+
%1 = get_field @fieldName0 : !emitc.array<1xf32>
9+
%2 = get_field @fieldName1 : !emitc.array<1xf32>
10+
%3 = subscript %1[%0] : (!emitc.array<1xf32>, !emitc.size_t) -> !emitc.lvalue<f32>
11+
return
12+
}
13+
}
14+
15+
// CHECK-LABEL: class modelClass {
16+
// CHECK-NEXT: public:
17+
// CHECK-NEXT: float fieldName0[1];
18+
// CHECK-NEXT: float fieldName1[1];
19+
// CHECK-NEXT: void execute() {
20+
// CHECK-NEXT: size_t v1 = 0;
21+
// CHECK-NEXT: return;
22+
// CHECK-NEXT: }
23+
// CHECK-NEXT: };
24+
25+
emitc.class final @finalClass {
26+
emitc.field @fieldName0 : !emitc.array<1xf32>
27+
emitc.field @fieldName1 : !emitc.array<1xf32>
28+
emitc.func @execute() {
29+
%0 = "emitc.constant"() <{value = 0 : index}> : () -> !emitc.size_t
30+
%1 = get_field @fieldName0 : !emitc.array<1xf32>
31+
%2 = get_field @fieldName1 : !emitc.array<1xf32>
32+
%3 = subscript %1[%0] : (!emitc.array<1xf32>, !emitc.size_t) -> !emitc.lvalue<f32>
33+
return
34+
}
35+
}
36+
37+
// CHECK-LABEL: class finalClass final {
38+
// CHECK-NEXT: public:
39+
// CHECK-NEXT: float fieldName0[1];
40+
// CHECK-NEXT: float fieldName1[1];
41+
// CHECK-NEXT: void execute() {
42+
// CHECK-NEXT: size_t v1 = 0;
43+
// CHECK-NEXT: return;
44+
// CHECK-NEXT: }
45+
// CHECK-NEXT: };
46+
47+
emitc.class @mainClass {
48+
emitc.field @fieldName0 : !emitc.array<2xf32> = dense<0.0> {attrs = {emitc.name_hint = "another_feature"}}
49+
emitc.func @get_fieldName0() {
50+
%0 = emitc.get_field @fieldName0 : !emitc.array<2xf32>
51+
return
52+
}
53+
}
54+
55+
// CHECK-LABEL: class mainClass {
56+
// CHECK-NEXT: public:
57+
// CHECK-NEXT: float fieldName0[2] = {0.0e+00f, 0.0e+00f};
58+
// CHECK-NEXT: void get_fieldName0() {
59+
// CHECK-NEXT: return;
60+
// CHECK-NEXT: }
61+
// CHECK-NEXT: };
62+
63+
emitc.class @reflectionClass {
64+
emitc.field @reflectionMap : !emitc.opaque<"const std::map<std::string, std::string>"> = #emitc.opaque<"{ { \22another_feature\22, \22fieldName0\22 } }">
65+
emitc.func @get_reflectionMap() {
66+
%0 = emitc.get_field @reflectionMap : !emitc.opaque<"const std::map<std::string, std::string>">
67+
return
68+
}
69+
}
70+
71+
// CHECK-LABEL: class reflectionClass {
72+
// CHECK-NEXT: public:
73+
// CHECK-NEXT: const std::map<std::string, std::string> reflectionMap = { { "another_feature", "fieldName0" } };
74+
// CHECK-NEXT: void get_reflectionMap() {
75+
// CHECK-NEXT: return;
76+
// CHECK-NEXT: }
77+
// CHECK-NEXT: };
78+

mlir/test/mlir-translate/emitc_classops.mlir

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)