Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mlir/test/lib/Dialect/Test/TestAttrDefs.td
Original file line number Diff line number Diff line change
Expand Up @@ -402,4 +402,11 @@ def TestCustomLocationAttr : Test_LocAttr<"TestCustomLocation"> {
let assemblyFormat = "`<` $file `*` $line `>`";
}

def TestCustomStorageCtorAttr : Test_Attr<"TestCustomStorageCtorAttr"> {
let mnemonic = "custom_storage_ctor_attr";
let parameters = (ins "int":$value);
let assemblyFormat = "`<` $value `>`";
let hasStorageCustomConstructor = 1;
}

#endif // TEST_ATTRDEFS
12 changes: 12 additions & 0 deletions mlir/test/lib/Dialect/Test/TestAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,18 @@ getDynamicCustomAssemblyFormatAttr(TestDialect *testDialect) {
std::move(parser), std::move(printer));
}

//===----------------------------------------------------------------------===//
// TestCustomStorageCtorAttr
//===----------------------------------------------------------------------===//

test::detail::TestCustomStorageCtorAttrAttrStorage *
test::detail::TestCustomStorageCtorAttrAttrStorage::construct(
mlir::StorageUniquer::StorageAllocator &, std::tuple<int> &&) {
// Note: this tests linker error ("undefined symbol"), the actual
// implementation is not important.
return nullptr;
}

//===----------------------------------------------------------------------===//
// TestDialect
//===----------------------------------------------------------------------===//
Expand Down
7 changes: 7 additions & 0 deletions mlir/test/lib/Dialect/Test/TestTypeDefs.td
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,13 @@ def TestTypeCustomString : Test_Type<"TestTypeCustomString"> {
custom<BarString>(ref($foo)) `>` }];
}

def TestCustomStorageCtor : Test_Type<"TestCustomStorageCtor"> {
let mnemonic = "custom_storage_ctor_type";
let parameters = (ins "int":$value);
let assemblyFormat = "`<` $value `>`";
let hasStorageCustomConstructor = 1;
}

def TestTypeOptionalString : Test_Type<"TestTypeOptionalString"> {
let parameters = (ins StringRefParameter<"description", [{"default"}]>:$str);
let mnemonic = "optional_type_string";
Expand Down
8 changes: 8 additions & 0 deletions mlir/test/lib/Dialect/Test/TestTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ getCustomAssemblyFormatDynamicType(TestDialect *testDialect) {
std::move(parser), std::move(printer));
}

test::detail::TestCustomStorageCtorTypeStorage *
test::detail::TestCustomStorageCtorTypeStorage::construct(
mlir::StorageUniquer::StorageAllocator &, std::tuple<int> &&) {
// Note: this tests linker error ("undefined symbol"), the actual
// implementation is not important.
return nullptr;
}

//===----------------------------------------------------------------------===//
// TestDialect
//===----------------------------------------------------------------------===//
Expand Down
4 changes: 2 additions & 2 deletions mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,10 @@ void DefGen::emitHashKey() {
}

void DefGen::emitConstruct() {
Method *construct = storageCls->addMethod<Method::Inline>(
Method *construct = storageCls->addMethod(
strfmt("{0} *", def.getStorageClassName()), "construct",
def.hasStorageCustomConstructor() ? Method::StaticDeclaration
: Method::Static,
: Method::StaticInline,
MethodParameter(strfmt("::mlir::{0}StorageAllocator &", valueType),
"allocator"),
MethodParameter("KeyTy &&", "tblgenKey"));
Expand Down
Loading