[MLIR] Add LocationAttr declarations to ODS
authorAndrew Young <youngar17@gmail.com>
Tue, 24 Jan 2023 04:08:35 +0000 (20:08 -0800)
committerAndrew Young <youngar17@gmail.com>
Tue, 24 Jan 2023 04:42:14 +0000 (20:42 -0800)
This commit adds location attributes and arrays of locations to OpBase.td.
Using LocationAttrs directly in an operation is useful when the location does
not correspond 1-1 to an operation or value in the IR.  We use this in CIRCT to
store the declaration location of result ports of HWModule operations.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D142148

mlir/include/mlir/IR/OpBase.td

index e859e40..7fb583f 100644 (file)
@@ -1078,6 +1078,9 @@ class AnyAttrOf<list<Attr> allowedAttrs, string summary = "",
     let convertFromStorage = fromStorage;
 }
 
+def LocationAttr : Attr<CPred<"$_self.isa<::mlir::LocationAttr>()">,
+                        "location attribute">;
+
 def BoolAttr : Attr<CPred<"$_self.isa<::mlir::BoolAttr>()">, "bool attribute"> {
   let storageType = [{ ::mlir::BoolAttr }];
   let returnType = [{ bool }];
@@ -1477,6 +1480,9 @@ class TypedArrayAttrBase<Attr element, string summary>: ArrayAttrBase<
   Attr elementAttr = element;
 }
 
+def LocationArrayAttr : TypedArrayAttrBase<LocationAttr,
+                                           "location array attribute">;
+
 def AffineMapArrayAttr : TypedArrayAttrBase<AffineMapAttr,
                                       "AffineMap array attribute"> {
   let constBuilderCall = "$_builder.getAffineMapArrayAttr($0)";