Skip to content

Commit

Permalink
[FIRRTL] Add ArrayRefAttr to FIRRTL
Browse files Browse the repository at this point in the history
A number of ArrayAttr inherent attributes in the FIRRTL dialect have custom
accessors defined, because we want the getter to return an ArrayRef<Attribute>,
not an ArrayAttr.  This PR adds an untyped ArrayRefAttr that will generate the
accessors we want. Maybe someday this could be delivered upstream to MLIR, if
it proves useful to us.
  • Loading branch information
rwy7 committed Jul 27, 2023
1 parent cbae0eb commit d89cdf0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/circt/Types.td
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,14 @@ def APSIntAttr : Attr<CPred<"$_self.isa<::mlir::IntegerAttr>()">,
let convertFromStorage = "$_self.getAPSInt()";
}

// Compared to the standard ArrayAttr, the accessor to an ArrayRefAttr will
// convert the attribute to an ArrayRef, while an ArrayAttr accessor just
// returns itself.
def ArrayRefAttr :
ArrayAttrBase<
CPred<"::llvm::isa<::mlir::ArrayAttr>($_self)">, "array attribute"> {
let returnType = [{ ::llvm::ArrayRef<Attribute> }];
let convertFromStorage = [{ $_self.getValue() }];
}

#endif // CIRCT_TYPES

0 comments on commit d89cdf0

Please sign in to comment.