[Mlir-commits] [mlir] [mlir] Add loaded URI attribute type (PR #67276)

Jeff Niu llvmlistbot at llvm.org
Mon Sep 25 09:55:03 PDT 2023


================
@@ -1046,6 +1046,92 @@ class DistinctAttr
   static DistinctAttr create(Attribute referencedAttr);
 };
 
+//===----------------------------------------------------------------------===//
+// LoadedURIDenseResourceAttr
+//===----------------------------------------------------------------------===//
+
+namespace detail {
+struct LoadedURIDenseResourceAttrStorage;
+} // namespace detail
+
+/// An attribute that parses/prints as a identifier (file & symbol) while in
+/// memory representing the loaded attribute.
+
+class LoadedURIDenseResourceAttr
+    : public Attribute::AttrBase<LoadedURIDenseResourceAttr, Attribute,
+                                 detail::LoadedURIDenseResourceAttrStorage,
+                                 TypedAttr::Trait, ElementsAttr::Trait> {
+public:
+  using Base::Base;
+  using Base::getChecked;
+
+  static LoadedURIDenseResourceAttr
+  get(StringRef uri, Type type, std::optional<int64_t> alignment,
+      std::optional<int64_t> offset, std::optional<int64_t> size,
+      ArrayRef<FlatSymbolRefAttr> nestedReferences = {});
+
+  static LoadedURIDenseResourceAttr
+  getChecked(function_ref<::mlir::InFlightDiagnostic()> emitError,
+             StringRef uri, Type type, std::optional<int64_t> alignment,
+             std::optional<int64_t> offset, std::optional<int64_t> size,
+             ArrayRef<FlatSymbolRefAttr> nestedReferences = {});
+
+  /// The set of data types that can be iterated by this attribute.
+  // TODO: Expand as needed; consider maybe reuse with DenseElementsAttr.
----------------
Mogball wrote:

Yeah, I think these days, in practice this API is less useful than the `getDataAs`-style APIs for accessing dense elements/resources.

https://github.com/llvm/llvm-project/pull/67276


More information about the Mlir-commits mailing list