Add a cppType string in AttrDef to make it possible to use them as parameters in other attributes
Differential Revision: https://reviews.llvm.org/D113737
This commit is contained in:
parent
751aa6c280
commit
f5f11e6b16
|
@ -2938,6 +2938,9 @@ class AttrDef<Dialect dialect, string name, list<Trait> traits = [],
|
||||||
// The underlying C++ value type
|
// The underlying C++ value type
|
||||||
let returnType = dialect.cppNamespace # "::" # cppClassName;
|
let returnType = dialect.cppNamespace # "::" # cppClassName;
|
||||||
|
|
||||||
|
// Make it possible to use such attributes as parameters for other attributes.
|
||||||
|
string cppType = dialect.cppNamespace # "::" # cppClassName;
|
||||||
|
|
||||||
// The call expression to convert from the storage type to the return
|
// The call expression to convert from the storage type to the return
|
||||||
// type. For example, an enum can be stored as an int but returned as an
|
// type. For example, an enum can be stored as an int but returned as an
|
||||||
// enum class.
|
// enum class.
|
||||||
|
|
|
@ -43,6 +43,11 @@ def CompoundAttrA : Test_Attr<"CompoundA"> {
|
||||||
>: $arrayOfInts
|
>: $arrayOfInts
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
def CompoundAttrNested : Test_Attr<"CompoundAttrNested"> {
|
||||||
|
let mnemonic = "cmpnd_nested";
|
||||||
|
let parameters = (ins CompoundAttrA : $nested );
|
||||||
|
let assemblyFormat = "`<` `nested` `=` $nested `>`";
|
||||||
|
}
|
||||||
|
|
||||||
// An attribute testing AttributeSelfTypeParameter.
|
// An attribute testing AttributeSelfTypeParameter.
|
||||||
def AttrWithSelfTypeParam : Test_Attr<"AttrWithSelfTypeParam"> {
|
def AttrWithSelfTypeParam : Test_Attr<"AttrWithSelfTypeParam"> {
|
||||||
|
|
|
@ -1902,6 +1902,11 @@ def FormatCompoundAttr : TEST_Op<"format_compound_attr"> {
|
||||||
let assemblyFormat = "$compound attr-dict-with-keyword";
|
let assemblyFormat = "$compound attr-dict-with-keyword";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def FormatNestedAttr : TEST_Op<"format_nested_attr"> {
|
||||||
|
let arguments = (ins CompoundAttrNested:$nested);
|
||||||
|
let assemblyFormat = "$nested attr-dict-with-keyword";
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Custom Directives
|
// Custom Directives
|
||||||
|
|
||||||
|
|
|
@ -259,6 +259,14 @@ test.format_optional_else else
|
||||||
// CHECK: test.format_compound_attr #test.cmpnd_a<1, !test.smpla, [5, 6]>
|
// CHECK: test.format_compound_attr #test.cmpnd_a<1, !test.smpla, [5, 6]>
|
||||||
test.format_compound_attr #test.cmpnd_a<1, !test.smpla, [5, 6]>
|
test.format_compound_attr #test.cmpnd_a<1, !test.smpla, [5, 6]>
|
||||||
|
|
||||||
|
// CHECK: module attributes {test.nested = #test.cmpnd_nested<nested = #test.cmpnd_a<1, !test.smpla, [5, 6]>>} {
|
||||||
|
module attributes {test.nested = #test.cmpnd_nested<nested = #test.cmpnd_a<1, !test.smpla, [5, 6]>>} {
|
||||||
|
}
|
||||||
|
|
||||||
|
// CHECK: test.format_nested_attr #test.cmpnd_nested<nested = #test.cmpnd_a<1, !test.smpla, [5, 6]>>
|
||||||
|
test.format_nested_attr #test.cmpnd_nested<nested = #test.cmpnd_a<1, !test.smpla, [5, 6]>>
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Format custom directives
|
// Format custom directives
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
Loading…
Reference in a new issue