File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed
include/flang/Optimizer/Dialect/CUF/Attributes
lib/Optimizer/Dialect/CUF/Attributes Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,9 @@ getProcAttribute(mlir::MLIRContext *mlirContext,
106
106
return {};
107
107
}
108
108
109
+ // / Returns the data attribute if the operation has one.
110
+ cuf::DataAttributeAttr getDataAttr (mlir::Operation *op);
111
+
109
112
// / Returns true if the operation has a data attribute with the given value.
110
113
bool hasDataAttr (mlir::Operation *op, cuf::DataAttribute value);
111
114
Original file line number Diff line number Diff line change @@ -30,19 +30,26 @@ void CUFDialect::registerAttributes() {
30
30
LaunchBoundsAttr, ProcAttributeAttr>();
31
31
}
32
32
33
- bool hasDataAttr (mlir::Operation *op, cuf::DataAttribute value ) {
33
+ cuf::DataAttributeAttr getDataAttr (mlir::Operation *op) {
34
34
if (!op)
35
- return false ;
35
+ return {};
36
+
37
+ if (auto dataAttr =
38
+ op->getAttrOfType <cuf::DataAttributeAttr>(cuf::getDataAttrName ()))
39
+ return dataAttr;
36
40
37
- cuf::DataAttributeAttr dataAttr =
38
- op->getAttrOfType <cuf::DataAttributeAttr>(cuf::getDataAttrName ());
39
41
// When the attribute is declared on the operation, it doesn't have a prefix.
40
- if (!dataAttr)
41
- dataAttr = op->getAttrOfType <cuf::DataAttributeAttr>(cuf::dataAttrName);
42
- if (!dataAttr)
43
- return false ;
42
+ if (auto dataAttr =
43
+ op->getAttrOfType <cuf::DataAttributeAttr>(cuf::dataAttrName))
44
+ return dataAttr;
44
45
45
- return dataAttr.getValue () == value;
46
+ return {};
47
+ }
48
+
49
+ bool hasDataAttr (mlir::Operation *op, cuf::DataAttribute value) {
50
+ if (auto dataAttr = getDataAttr (op))
51
+ return dataAttr.getValue () == value;
52
+ return false ;
46
53
}
47
54
48
55
} // namespace cuf
You can’t perform that action at this time.
0 commit comments