[Mlir-commits] [mlir] [MLIR][LLVM] Support Recursive DITypes (PR #80251)
Tobias Gysi
llvmlistbot at llvm.org
Thu Feb 29 12:07:07 PST 2024
================
@@ -87,4 +91,31 @@ using linkage::Linkage;
#define GET_ATTRDEF_CLASSES
#include "mlir/Dialect/LLVMIR/LLVMOpsAttrDefs.h.inc"
+namespace mlir {
+namespace LLVM {
+/// This class represents either a concrete attr, or a DIRecursiveTypeAttr
+/// containing such a concrete attr.
+template <typename BaseType>
+class DIRecursiveTypeAttrOf : public DITypeAttr {
+public:
+ static_assert(std::is_base_of_v<DITypeAttr, BaseType>);
+ using DITypeAttr::DITypeAttr;
+ /// Support LLVM type casting.
+ static bool classof(Attribute attr) {
+ if (auto rec = llvm::dyn_cast<DIRecursiveTypeAttr>(attr))
+ return llvm::isa<BaseType>(rec.getBaseType());
+ return llvm::isa<BaseType>(attr);
+ }
+
+ DIRecursiveTypeAttrOf(BaseType baseType) : DITypeAttr(baseType) {}
----------------
gysit wrote:
```suggestion
DIRecursiveTypeAttrOf(BaseType baseTypeAttr) : DITypeAttr(baseTypeAttr) {}
```
nit: I would go with baseTypeAttr or attr to clarify it is not a type but actually an attribute :).
https://github.com/llvm/llvm-project/pull/80251
More information about the Mlir-commits
mailing list