Skip to content

Commit 8e44f85

Browse files
committed
Corrected the attrs use in fields
1 parent ec067c7 commit 8e44f85

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,17 +1644,14 @@ def EmitC_FieldOp : EmitC_Op<"field", [Symbol]> {
16441644
Example:
16451645

16461646
```mlir
1647-
// Example with an attribute:
1648-
emitc.field @fieldName0 : !emitc.array<1xf32> {emitc.opaque = "another_feature"}
16491647
// Example with no attribute:
16501648
emitc.field @fieldName0 : !emitc.array<1xf32>
16511649
```
16521650
}];
16531651

1654-
let arguments = (ins SymbolNameAttr:$sym_name, TypeAttr:$type,
1655-
OptionalAttr<AnyAttr>:$attrs);
1652+
let arguments = (ins SymbolNameAttr:$sym_name, TypeAttr:$type);
16561653

1657-
let assemblyFormat = [{ $sym_name `:` $type ($attrs^)? attr-dict}];
1654+
let assemblyFormat = [{ $sym_name `:` $type attr-dict}];
16581655

16591656
let hasVerifier = 1;
16601657
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,9 +1415,6 @@ LogicalResult FieldOp::verify() {
14151415
if (!symName || symName.getValue().empty())
14161416
return emitOpError("field must have a non-empty symbol name");
14171417

1418-
if (!getAttrs())
1419-
return success();
1420-
14211418
return success();
14221419
}
14231420

mlir/lib/Dialect/EmitC/Transforms/WrapFuncInClass.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,12 @@ class WrapFuncInClass : public OpRewritePattern<emitc::FuncOp> {
6868
const mlir::Attribute namedAttribute =
6969
dictAttr.getNamed(attributeName)->getValue();
7070

71-
auto name =
72-
cast<mlir::StringAttr>(cast<mlir::ArrayAttr>(namedAttribute)[0]);
71+
auto name = cast<mlir::StringAttr>(namedAttribute);
7372
bufferFieldAttrs.push_back(name);
7473
}
7574
TypeAttr typeAttr = TypeAttr::get(val.getType());
7675
fields.push_back({fieldName, typeAttr});
77-
rewriter.create<emitc::FieldOp>(funcOp.getLoc(), fieldName, typeAttr,
78-
nullptr);
76+
rewriter.create<emitc::FieldOp>(funcOp.getLoc(), fieldName, typeAttr);
7977
}
8078

8179
if (!bufferFieldAttrs.empty()) {

mlir/test/Dialect/EmitC/wrap_emitc_func_in_class.mlir

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ module attributes { } {
1919

2020
// CHECK: module {
2121
// CHECK-NEXT: emitc.class @modelClass {
22-
// CHECK-NEXT: emitc.field @fieldName0 : !emitc.array<1xf32> {emitc.name_hint = "another_feature"}
23-
// CHECK-NEXT: emitc.field @fieldName1 : !emitc.array<1xf32> {emitc.name_hint = "some_feature"}
24-
// CHECK-NEXT: emitc.field @fieldName2 : !emitc.array<1xf32> {emitc.name_hint = "output_0"}
22+
// CHECK-NEXT: emitc.field @fieldName0 : !emitc.array<1xf32>
23+
// CHECK-NEXT: emitc.field @fieldName1 : !emitc.array<1xf32>
24+
// CHECK-NEXT: emitc.field @fieldName2 : !emitc.array<1xf32>
25+
// CHECK-NEXT: emitc.buffer_map ["another_feature", "some_feature", "output_0"]
2526
// CHECK-NEXT: emitc.func @execute() {
2627
// CHECK-NEXT: get_field @fieldName0 : !emitc.array<1xf32>
2728
// CHECK-NEXT: get_field @fieldName1 : !emitc.array<1xf32>

0 commit comments

Comments
 (0)