Skip to content

Commit d413f4b

Browse files
committed
[mlir] Fix missing namespaces in OpBuildGen.cpp
Differential Revision: https://reviews.llvm.org/D90858
1 parent 7eb7015 commit d413f4b

File tree

2 files changed

+38
-35
lines changed

2 files changed

+38
-35
lines changed

mlir/tools/mlir-reduce/mlir-reduce.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
using namespace mlir;
3434

3535
namespace mlir {
36+
namespace test {
3637
void registerTestDialect(DialectRegistry &);
37-
}
38+
} // namespace test
39+
} // namespace mlir
3840

3941
static llvm::cl::opt<std::string> inputFilename(llvm::cl::Positional,
4042
llvm::cl::Required,
@@ -90,7 +92,7 @@ int main(int argc, char **argv) {
9092
mlir::MLIRContext context;
9193
registerAllDialects(context.getDialectRegistry());
9294
#ifdef MLIR_INCLUDE_TESTS
93-
mlir::registerTestDialect(context.getDialectRegistry());
95+
mlir::test::registerTestDialect(context.getDialectRegistry());
9496
#endif
9597

9698
mlir::OwningModuleRef moduleRef;

mlir/unittests/TableGen/OpBuildGen.cpp

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace mlir {
2727

2828
static MLIRContext &getContext() {
2929
static MLIRContext ctx;
30-
ctx.getOrLoadDialect<TestDialect>();
30+
ctx.getOrLoadDialect<test::TestDialect>();
3131
return ctx;
3232
}
3333
/// Test fixture for providing basic utilities for testing.
@@ -36,8 +36,8 @@ class OpBuildGenTest : public ::testing::Test {
3636
OpBuildGenTest()
3737
: ctx(getContext()), builder(&ctx), loc(builder.getUnknownLoc()),
3838
i32Ty(builder.getI32Type()), f32Ty(builder.getF32Type()),
39-
cstI32(builder.create<TableGenConstant>(loc, i32Ty)),
40-
cstF32(builder.create<TableGenConstant>(loc, f32Ty)),
39+
cstI32(builder.create<test::TableGenConstant>(loc, i32Ty)),
40+
cstF32(builder.create<test::TableGenConstant>(loc, f32Ty)),
4141
noAttrs(), attrStorage{builder.getNamedAttr("attr0",
4242
builder.getBoolAttr(true)),
4343
builder.getNamedAttr(
@@ -96,8 +96,8 @@ class OpBuildGenTest : public ::testing::Test {
9696
Location loc;
9797
Type i32Ty;
9898
Type f32Ty;
99-
TableGenConstant cstI32;
100-
TableGenConstant cstF32;
99+
test::TableGenConstant cstI32;
100+
test::TableGenConstant cstF32;
101101

102102
ArrayRef<NamedAttribute> noAttrs;
103103
std::vector<NamedAttribute> attrStorage;
@@ -107,21 +107,21 @@ class OpBuildGenTest : public ::testing::Test {
107107
/// Test basic build methods.
108108
TEST_F(OpBuildGenTest, BasicBuildMethods) {
109109
// Test separate args, separate results build method.
110-
auto op = builder.create<TableGenBuildOp0>(loc, i32Ty, cstI32);
110+
auto op = builder.create<test::TableGenBuildOp0>(loc, i32Ty, cstI32);
111111
verifyOp(op, {i32Ty}, {cstI32}, noAttrs);
112112

113113
// Test separate args, collective results build method.
114-
op = builder.create<TableGenBuildOp0>(loc, TypeRange{i32Ty}, cstI32);
114+
op = builder.create<test::TableGenBuildOp0>(loc, TypeRange{i32Ty}, cstI32);
115115
verifyOp(op, {i32Ty}, {cstI32}, noAttrs);
116116

117117
// Test collective args, collective params build method.
118-
op = builder.create<TableGenBuildOp0>(loc, TypeRange{i32Ty},
119-
ValueRange{cstI32});
118+
op = builder.create<test::TableGenBuildOp0>(loc, TypeRange{i32Ty},
119+
ValueRange{cstI32});
120120
verifyOp(op, {i32Ty}, {cstI32}, noAttrs);
121121

122122
// Test collective args, collective results, non-empty attributes
123-
op = builder.create<TableGenBuildOp0>(loc, TypeRange{i32Ty},
124-
ValueRange{cstI32}, attrs);
123+
op = builder.create<test::TableGenBuildOp0>(loc, TypeRange{i32Ty},
124+
ValueRange{cstI32}, attrs);
125125
verifyOp(op, {i32Ty}, {cstI32}, attrs);
126126
}
127127

@@ -138,48 +138,49 @@ TEST_F(OpBuildGenTest, BasicBuildMethods) {
138138
/// variadic result.
139139
TEST_F(OpBuildGenTest, BuildMethodsSingleVariadicArgAndResult) {
140140
// Test collective args, collective results method, building a unary op.
141-
auto op = builder.create<TableGenBuildOp1>(loc, TypeRange{i32Ty},
142-
ValueRange{cstI32});
141+
auto op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty},
142+
ValueRange{cstI32});
143143
verifyOp(std::move(op), {i32Ty}, {cstI32}, noAttrs);
144144

145145
// Test collective args, collective results method, building a unary op with
146146
// named attributes.
147-
op = builder.create<TableGenBuildOp1>(loc, TypeRange{i32Ty},
148-
ValueRange{cstI32}, attrs);
147+
op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty},
148+
ValueRange{cstI32}, attrs);
149149
verifyOp(std::move(op), {i32Ty}, {cstI32}, attrs);
150150

151151
// Test collective args, collective results method, building a binary op.
152-
op = builder.create<TableGenBuildOp1>(loc, TypeRange{i32Ty, f32Ty},
153-
ValueRange{cstI32, cstF32});
152+
op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty, f32Ty},
153+
ValueRange{cstI32, cstF32});
154154
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32, cstF32}, noAttrs);
155155

156156
// Test collective args, collective results method, building a binary op with
157157
// named attributes.
158-
op = builder.create<TableGenBuildOp1>(loc, TypeRange{i32Ty, f32Ty},
159-
ValueRange{cstI32, cstF32}, attrs);
158+
op = builder.create<test::TableGenBuildOp1>(
159+
loc, TypeRange{i32Ty, f32Ty}, ValueRange{cstI32, cstF32}, attrs);
160160
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32, cstF32}, attrs);
161161
}
162162

163163
/// Test build methods for an Op with a single varadic arg and a non-variadic
164164
/// result.
165165
TEST_F(OpBuildGenTest, BuildMethodsSingleVariadicArgNonVariadicResults) {
166166
// Test separate arg, separate param build method.
167-
auto op = builder.create<TableGenBuildOp1>(loc, i32Ty, ValueRange{cstI32});
167+
auto op =
168+
builder.create<test::TableGenBuildOp1>(loc, i32Ty, ValueRange{cstI32});
168169
verifyOp(std::move(op), {i32Ty}, {cstI32}, noAttrs);
169170

170171
// Test collective params build method, no attributes.
171-
op = builder.create<TableGenBuildOp1>(loc, TypeRange{i32Ty},
172-
ValueRange{cstI32});
172+
op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty},
173+
ValueRange{cstI32});
173174
verifyOp(std::move(op), {i32Ty}, {cstI32}, noAttrs);
174175

175176
// Test collective params build method no attributes, 2 inputs.
176-
op = builder.create<TableGenBuildOp1>(loc, TypeRange{i32Ty},
177-
ValueRange{cstI32, cstF32});
177+
op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty},
178+
ValueRange{cstI32, cstF32});
178179
verifyOp(std::move(op), {i32Ty}, {cstI32, cstF32}, noAttrs);
179180

180181
// Test collective params build method, non-empty attributes.
181-
op = builder.create<TableGenBuildOp1>(loc, TypeRange{i32Ty},
182-
ValueRange{cstI32, cstF32}, attrs);
182+
op = builder.create<test::TableGenBuildOp1>(
183+
loc, TypeRange{i32Ty}, ValueRange{cstI32, cstF32}, attrs);
183184
verifyOp(std::move(op), {i32Ty}, {cstI32, cstF32}, attrs);
184185
}
185186

@@ -188,18 +189,18 @@ TEST_F(OpBuildGenTest, BuildMethodsSingleVariadicArgNonVariadicResults) {
188189
TEST_F(OpBuildGenTest,
189190
BuildMethodsSingleVariadicArgAndMultipleVariadicResults) {
190191
// Test separate arg, separate param build method.
191-
auto op = builder.create<TableGenBuildOp3>(
192+
auto op = builder.create<test::TableGenBuildOp3>(
192193
loc, TypeRange{i32Ty}, TypeRange{f32Ty}, ValueRange{cstI32});
193194
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32}, noAttrs);
194195

195196
// Test collective params build method, no attributes.
196-
op = builder.create<TableGenBuildOp3>(loc, TypeRange{i32Ty, f32Ty},
197-
ValueRange{cstI32});
197+
op = builder.create<test::TableGenBuildOp3>(loc, TypeRange{i32Ty, f32Ty},
198+
ValueRange{cstI32});
198199
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32}, noAttrs);
199200

200201
// Test collective params build method, with attributes.
201-
op = builder.create<TableGenBuildOp3>(loc, TypeRange{i32Ty, f32Ty},
202-
ValueRange{cstI32}, attrs);
202+
op = builder.create<test::TableGenBuildOp3>(loc, TypeRange{i32Ty, f32Ty},
203+
ValueRange{cstI32}, attrs);
203204
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32}, attrs);
204205
}
205206

@@ -209,13 +210,13 @@ TEST_F(OpBuildGenTest,
209210
// InferOpTypeInterface interface. For such ops, the ODS framework generates
210211
// build methods with no result types as they are inferred from the input types.
211212
TEST_F(OpBuildGenTest, BuildMethodsSameOperandsAndResultTypeSuppression) {
212-
testSingleVariadicInputInferredType<TableGenBuildOp4>();
213+
testSingleVariadicInputInferredType<test::TableGenBuildOp4>();
213214
}
214215

215216
TEST_F(
216217
OpBuildGenTest,
217218
BuildMethodsSameOperandsAndResultTypeAndInferOpTypeInterfaceSuppression) {
218-
testSingleVariadicInputInferredType<TableGenBuildOp5>();
219+
testSingleVariadicInputInferredType<test::TableGenBuildOp5>();
219220
}
220221

221222
} // namespace mlir

0 commit comments

Comments
 (0)