forked from OSchip/llvm-project
Add missing storageType to AttrDef to ODS
This is only noticeable when using an attribute across dialects I think. Previously the namespace would be ommited, but it wouldn't matter as long as the generated code stays within a single namespace. Differential Revision: https://reviews.llvm.org/D110367
This commit is contained in:
parent
2190f8a8b1
commit
83f3c615dd
|
@ -2861,6 +2861,7 @@ class AttrDef<Dialect dialect, string name, list<Trait> traits = [],
|
|||
AttrOrTypeDef<"Attr", name, traits, baseCppClass> {
|
||||
// The name of the C++ Attribute class.
|
||||
string cppClassName = name # "Attr";
|
||||
let storageType = dialect.cppNamespace # "::" # name # "Attr";
|
||||
|
||||
// The underlying C++ value type
|
||||
let returnType = dialect.cppNamespace # "::" # cppClassName;
|
||||
|
|
|
@ -6,6 +6,7 @@ include "mlir/IR/OpBase.td"
|
|||
|
||||
def Test_Dialect : Dialect {
|
||||
let name = "test";
|
||||
let cppNamespace = "foobar";
|
||||
}
|
||||
class NS_Op<string mnemonic, list<OpTrait> traits> :
|
||||
Op<Test_Dialect, mnemonic, traits>;
|
||||
|
@ -17,6 +18,10 @@ def SomeAttr : Attr<CPred<"some-condition">, "some attribute kind"> {
|
|||
let constBuilderCall = "some-const-builder-call($_builder, $0)";
|
||||
}
|
||||
|
||||
def SomeAttrDef : AttrDef<Test_Dialect, "SomeAttr"> {
|
||||
}
|
||||
|
||||
|
||||
// Test required, optional, default-valued attributes
|
||||
// ---
|
||||
|
||||
|
@ -271,6 +276,19 @@ def EOp : NS_Op<"e_op", []> {
|
|||
// DECL-LABEL: EOp declarations
|
||||
// DECL: static void build({{.*}}, uint32_t i32_attr, uint32_t dv_i32_attr, ::llvm::APFloat f64_attr, ::llvm::APFloat dv_f64_attr, ::llvm::StringRef str_attr, ::llvm::StringRef dv_str_attr, bool bool_attr, bool dv_bool_attr, ::SomeI32Enum enum_attr, ::SomeI32Enum dv_enum_attr = ::SomeI32Enum::case5)
|
||||
|
||||
|
||||
// Test proper namespacing for AttrDef
|
||||
// ---
|
||||
|
||||
def NamespaceOp : NS_Op<"namespace_op", []> {
|
||||
let arguments = (ins
|
||||
SomeAttrDef:$AttrDef
|
||||
);
|
||||
}
|
||||
// DECL: NamespaceOp
|
||||
// DECL: foobar::SomeAttrAttr AttrDef()
|
||||
|
||||
|
||||
// Test mixing operands and attributes in arbitrary order
|
||||
// ---
|
||||
|
||||
|
|
Loading…
Reference in New Issue