@@ -77,8 +77,8 @@ TEST(Dialect, DelayedInterfaceRegistration) {
77
77
// Delayed registration of an interface for TestDialect.
78
78
registry.addExtension (
79
79
" TEST_DIALECT_DELAYED" , +[](MLIRContext *ctx, TestDialect *dialect) {
80
- dialect->addInterfaces <TestDialectInterface>();
81
- });
80
+ dialect->addInterfaces <TestDialectInterface>();
81
+ });
82
82
83
83
MLIRContext context (registry);
84
84
@@ -116,8 +116,8 @@ TEST(Dialect, RepeatedDelayedRegistration) {
116
116
registry.insert <TestDialect>();
117
117
registry.addExtension (
118
118
" TEST_DIALECT" , +[](MLIRContext *ctx, TestDialect *dialect) {
119
- dialect->addInterfaces <TestDialectInterface>();
120
- });
119
+ dialect->addInterfaces <TestDialectInterface>();
120
+ });
121
121
MLIRContext context (registry);
122
122
123
123
// Load the TestDialect and check that the interface got registered for it.
@@ -132,8 +132,8 @@ TEST(Dialect, RepeatedDelayedRegistration) {
132
132
secondRegistry.insert <TestDialect>();
133
133
secondRegistry.addExtension (
134
134
" TEST_DIALECT" , +[](MLIRContext *ctx, TestDialect *dialect) {
135
- dialect->addInterfaces <TestDialectInterface>();
136
- });
135
+ dialect->addInterfaces <TestDialectInterface>();
136
+ });
137
137
context.appendDialectRegistry (secondRegistry);
138
138
testDialectInterface = dyn_cast<TestDialectInterfaceBase>(testDialect);
139
139
EXPECT_TRUE (testDialectInterface != nullptr );
@@ -193,4 +193,29 @@ TEST(Dialect, NestedDialectExtension) {
193
193
EXPECT_GE (counter2, 1 );
194
194
}
195
195
196
+ TEST (Dialect, SubsetWithExtensions) {
197
+ DialectRegistry registry1, registry2;
198
+ registry1.insert <TestDialect>();
199
+ registry2.insert <TestDialect>();
200
+
201
+ // Validate that the registries are equivalent.
202
+ ASSERT_TRUE (registry1.isSubsetOf (registry2));
203
+ ASSERT_TRUE (registry2.isSubsetOf (registry1));
204
+
205
+ // Add extensions to registry2.
206
+ int counter;
207
+ registry2.addExtension (" EXT" , std::make_unique<DummyExtension>(&counter, 0 ));
208
+
209
+ // Expect that (1) is a subset of (2) but not the other way around.
210
+ ASSERT_TRUE (registry1.isSubsetOf (registry2));
211
+ ASSERT_FALSE (registry2.isSubsetOf (registry1));
212
+
213
+ // Add extensions to registry1.
214
+ registry1.addExtension (" EXT" , std::make_unique<DummyExtension>(&counter, 0 ));
215
+
216
+ // Expect that (1) and (2) are equivalent.
217
+ ASSERT_TRUE (registry1.isSubsetOf (registry2));
218
+ ASSERT_TRUE (registry2.isSubsetOf (registry1));
219
+ }
220
+
196
221
} // namespace
0 commit comments