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,
106106 return {};
107107}
108108
109+ // / Returns the data attribute if the operation has one.
110+ cuf::DataAttributeAttr getDataAttr (mlir::Operation *op);
111+
109112// / Returns true if the operation has a data attribute with the given value.
110113bool hasDataAttr (mlir::Operation *op, cuf::DataAttribute value);
111114
Original file line number Diff line number Diff line change @@ -30,19 +30,26 @@ void CUFDialect::registerAttributes() {
3030 LaunchBoundsAttr, ProcAttributeAttr>();
3131}
3232
33- bool hasDataAttr (mlir::Operation *op, cuf::DataAttribute value ) {
33+ cuf::DataAttributeAttr getDataAttr (mlir::Operation *op) {
3434 if (!op)
35- return false ;
35+ return {};
36+
37+ if (auto dataAttr =
38+ op->getAttrOfType <cuf::DataAttributeAttr>(cuf::getDataAttrName ()))
39+ return dataAttr;
3640
37- cuf::DataAttributeAttr dataAttr =
38- op->getAttrOfType <cuf::DataAttributeAttr>(cuf::getDataAttrName ());
3941 // 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;
4445
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 ;
4653}
4754
4855} // namespace cuf
You can’t perform that action at this time.
0 commit comments