[Mlir-commits] [mlir] 7776b19 - [MLIR] Move TestDialect to ::test namespace
Stephen Neuendorffer
llvmlistbot at llvm.org
Sat Aug 14 13:32:22 PDT 2021
Author: Stephen Neuendorffer
Date: 2021-08-14T13:24:41-07:00
New Revision: 7776b19eed44906e9973bfb240b6279d6feaab41
URL: https://github.com/llvm/llvm-project/commit/7776b19eed44906e9973bfb240b6279d6feaab41
DIFF: https://github.com/llvm/llvm-project/commit/7776b19eed44906e9973bfb240b6279d6feaab41.diff
LOG: [MLIR] Move TestDialect to ::test namespace
While the changes are extensive, they basically fall into a few
categories:
1) Moving the TestDialect itself.
2) Updating C++ code in tablegen to explicitly use ::mlir, since it
will be put in a headers that shouldn't expect a 'using'.
3) Updating some generic MLIR Interface definitions to do the same thing.
4) Updating the Tablegen generator in a few places to be explicit about
namespaces
5) Doing the same thing for llvm references, since we no longer pick
up the definitions from mlir/Support/LLVM.h
Differential Revision: https://reviews.llvm.org/D88251
Added:
Modified:
mlir/include/mlir/IR/BuiltinOps.td
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/IR/RegionKindInterface.td
mlir/include/mlir/Interfaces/InferTypeOpInterface.td
mlir/test/lib/Dialect/Test/TestAttributes.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/test/lib/Dialect/Test/TestDialect.h
mlir/test/lib/Dialect/Test/TestInterfaces.td
mlir/test/lib/Dialect/Test/TestOps.td
mlir/test/lib/Dialect/Test/TestPatterns.cpp
mlir/test/lib/Dialect/Test/TestTraits.cpp
mlir/test/lib/Dialect/Test/TestTypeDefs.td
mlir/test/lib/Dialect/Test/TestTypes.cpp
mlir/test/lib/Dialect/Test/TestTypes.h
mlir/test/lib/IR/TestInterfaces.cpp
mlir/test/lib/IR/TestTypes.cpp
mlir/test/lib/Transforms/TestInlining.cpp
mlir/test/mlir-tblgen/attrdefs.td
mlir/test/mlir-tblgen/typedefs.td
mlir/tools/mlir-opt/mlir-opt.cpp
mlir/tools/mlir-reduce/mlir-reduce.cpp
mlir/unittests/IR/InterfaceAttachmentTest.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/BuiltinOps.td b/mlir/include/mlir/IR/BuiltinOps.td
index a05cfdd944714..8b6852b693936 100644
--- a/mlir/include/mlir/IR/BuiltinOps.td
+++ b/mlir/include/mlir/IR/BuiltinOps.td
@@ -115,7 +115,7 @@ def FuncOp : Builtin_Op<"func", [
/// Returns the region on the current operation that is callable. This may
/// return null in the case of an external callable object, e.g. an external
/// function.
- Region *getCallableRegion() { return isExternal() ? nullptr : &getBody(); }
+ ::mlir::Region *getCallableRegion() { return isExternal() ? nullptr : &getBody(); }
/// Returns the results types that the callable region produces when
/// executed.
diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td
index c3fb49035f8a4..c24c05b877cf3 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -1618,7 +1618,7 @@ class DerivedAttr<code ret, code b, code convert = ""> :
}
// Derived attribute that returns a mlir::Type.
-class DerivedTypeAttr<code body> : DerivedAttr<"Type", body> {
+class DerivedTypeAttr<code body> : DerivedAttr<"::mlir::Type", body> {
let convertFromStorage = "::mlir::TypeAttr::get($_self)";
}
diff --git a/mlir/include/mlir/IR/RegionKindInterface.td b/mlir/include/mlir/IR/RegionKindInterface.td
index bef161c00def2..90c96ac21b43e 100644
--- a/mlir/include/mlir/IR/RegionKindInterface.td
+++ b/mlir/include/mlir/IR/RegionKindInterface.td
@@ -33,7 +33,7 @@ def RegionKindInterface : OpInterface<"RegionKindInterface"> {
/*desc=*/[{
Return the kind of the region with the given index inside this operation.
}],
- /*retTy=*/"RegionKind",
+ /*retTy=*/"::mlir::RegionKind",
/*methodName=*/"getRegionKind",
/*args=*/(ins "unsigned":$index)
>,
@@ -44,7 +44,7 @@ def RegionKindInterface : OpInterface<"RegionKindInterface"> {
/*methodName=*/"hasSSADominance",
/*args=*/(ins "unsigned":$index),
/*methodBody=*/[{
- return getRegionKind(index) == RegionKind::SSACFG;
+ return getRegionKind(index) == ::mlir::RegionKind::SSACFG;
}]
>,
];
diff --git a/mlir/include/mlir/Interfaces/InferTypeOpInterface.td b/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
index 0d2c2b520a178..fe7c8eeb2e134 100644
--- a/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
+++ b/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
@@ -168,10 +168,10 @@ def ReifyRankedShapedTypeOpInterface :
rank of the corresponding result. If the shape of a particular
result cannot be computed it must be empty.
}],
- /*retTy=*/"LogicalResult",
+ /*retTy=*/"::mlir::LogicalResult",
/*methodName=*/"reifyResultShapes",
/*args=*/(ins "::mlir::OpBuilder &":$builder,
- "ReifiedRankedShapedTypeDims &":$reifiedReturnShapes)
+ "::mlir::ReifiedRankedShapedTypeDims &":$reifiedReturnShapes)
>
];
}
diff --git a/mlir/test/lib/Dialect/Test/TestAttributes.cpp b/mlir/test/lib/Dialect/Test/TestAttributes.cpp
index b6a2ca6145e27..94b9ea8429944 100644
--- a/mlir/test/lib/Dialect/Test/TestAttributes.cpp
+++ b/mlir/test/lib/Dialect/Test/TestAttributes.cpp
@@ -21,7 +21,7 @@
#include "llvm/ADT/TypeSwitch.h"
using namespace mlir;
-using namespace mlir::test;
+using namespace test;
//===----------------------------------------------------------------------===//
// AttrWithSelfTypeParamAttr
diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp
index e56c2d1a92d0f..2a1f37119e2d5 100644
--- a/mlir/test/lib/Dialect/Test/TestDialect.cpp
+++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp
@@ -22,12 +22,14 @@
#include "mlir/Transforms/InliningUtils.h"
#include "llvm/ADT/StringSwitch.h"
-using namespace mlir;
-using namespace mlir::test;
-
+// Include this before the using namespace lines below to
+// test that we don't have namespace dependencies.
#include "TestOpsDialect.cpp.inc"
-void mlir::test::registerTestDialect(DialectRegistry ®istry) {
+using namespace mlir;
+using namespace test;
+
+void test::registerTestDialect(DialectRegistry ®istry) {
registry.insert<TestDialect>();
}
diff --git a/mlir/test/lib/Dialect/Test/TestDialect.h b/mlir/test/lib/Dialect/Test/TestDialect.h
index d57a2c119723a..5aca160c3f183 100644
--- a/mlir/test/lib/Dialect/Test/TestDialect.h
+++ b/mlir/test/lib/Dialect/Test/TestDialect.h
@@ -45,11 +45,9 @@ class RewritePatternSet;
#define GET_OP_CLASSES
#include "TestOps.h.inc"
-namespace mlir {
namespace test {
-void registerTestDialect(DialectRegistry ®istry);
-void populateTestReductionPatterns(RewritePatternSet &patterns);
-} // namespace test
-} // namespace mlir
+void registerTestDialect(::mlir::DialectRegistry ®istry);
+void populateTestReductionPatterns(::mlir::RewritePatternSet &patterns);
+} // end namespace test
#endif // MLIR_TESTDIALECT_H
diff --git a/mlir/test/lib/Dialect/Test/TestInterfaces.td b/mlir/test/lib/Dialect/Test/TestInterfaces.td
index 817f2f78bc914..1d9fd9c21e46d 100644
--- a/mlir/test/lib/Dialect/Test/TestInterfaces.td
+++ b/mlir/test/lib/Dialect/Test/TestInterfaces.td
@@ -14,26 +14,26 @@ include "mlir/Interfaces/SideEffectInterfaceBase.td"
// A type interface used to test the ODS generation of type interfaces.
def TestTypeInterface : TypeInterface<"TestTypeInterface"> {
- let cppNamespace = "::mlir::test";
+ let cppNamespace = "::test";
let methods = [
InterfaceMethod<"Prints the type name.",
- "void", "printTypeA", (ins "Location":$loc), [{
+ "void", "printTypeA", (ins "::mlir::Location":$loc), [{
emitRemark(loc) << $_type << " - TestA";
}]
>,
InterfaceMethod<"Prints the type name.",
- "void", "printTypeB", (ins "Location":$loc),
+ "void", "printTypeB", (ins "::mlir::Location":$loc),
[{}], /*defaultImplementation=*/[{
emitRemark(loc) << $_type << " - TestB";
}]
>,
InterfaceMethod<"Prints the type name.",
- "void", "printTypeC", (ins "Location":$loc)
+ "void", "printTypeC", (ins "::mlir::Location":$loc)
>,
// It should be possible to use the interface type name as result type
// as well as in the implementation.
InterfaceMethod<"Prints the type name and returns the type as interface.",
- "TestTypeInterface", "printTypeRet", (ins "Location":$loc),
+ "TestTypeInterface", "printTypeRet", (ins "::mlir::Location":$loc),
[{}], /*defaultImplementation=*/[{
emitRemark(loc) << $_type << " - TestRet";
return $_type;
@@ -42,13 +42,13 @@ def TestTypeInterface : TypeInterface<"TestTypeInterface"> {
];
let extraClassDeclaration = [{
/// Prints the type name.
- void printTypeD(Location loc) const {
+ void printTypeD(::mlir::Location loc) const {
emitRemark(loc) << *this << " - TestD";
}
}];
let extraTraitClassDeclaration = [{
/// Prints the type name.
- void printTypeE(Location loc) const {
+ void printTypeE(::mlir::Location loc) const {
emitRemark(loc) << $_type << " - TestE";
}
}];
diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td
index c8b656a75e0db..add66b421f1f2 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -24,7 +24,7 @@ include "TestInterfaces.td"
def Test_Dialect : Dialect {
let name = "test";
- let cppNamespace = "::mlir::test";
+ let cppNamespace = "::test";
let hasCanonicalizer = 1;
let hasConstantMaterializer = 1;
let hasOperationAttrVerify = 1;
@@ -38,16 +38,16 @@ def Test_Dialect : Dialect {
void registerAttributes();
void registerTypes();
- Attribute parseAttribute(DialectAsmParser &parser,
- Type type) const override;
- void printAttribute(Attribute attr,
- DialectAsmPrinter &printer) const override;
+ ::mlir::Attribute parseAttribute(::mlir::DialectAsmParser &parser,
+ ::mlir::Type type) const override;
+ void printAttribute(::mlir::Attribute attr,
+ ::mlir::DialectAsmPrinter &printer) const override;
// Provides a custom printing/parsing for some operations.
- Optional<ParseOpHook>
- getParseOperationHook(StringRef opName) const override;
- LogicalResult printOperation(Operation *op,
- OpAsmPrinter &printer) const override;
+ ::llvm::Optional<ParseOpHook>
+ getParseOperationHook(::llvm::StringRef opName) const override;
+ ::mlir::LogicalResult printOperation(::mlir::Operation *op,
+ ::mlir::OpAsmPrinter &printer) const override;
private:
// Storage for a custom fallback interface.
void *fallbackEffectOpInterfaces;
@@ -117,8 +117,8 @@ def MultiTensorRankOf : TEST_Op<"multi_tensor_rank_of"> {
}
def TEST_TestType : DialectType<Test_Dialect,
- CPred<"$_self.isa<::mlir::test::TestType>()">, "test">,
- BuildableType<"$_builder.getType<::mlir::test::TestType>()">;
+ CPred<"$_self.isa<::test::TestType>()">, "test">,
+ BuildableType<"$_builder.getType<::test::TestType>()">;
//===----------------------------------------------------------------------===//
// Test Symbols
@@ -372,8 +372,8 @@ def ConversionCallOp : TEST_Op<"conversion_call_op",
operand_range getArgOperands() { return inputs(); }
/// Return the callee of this operation.
- CallInterfaceCallable getCallableForCallee() {
- return (*this)->getAttrOfType<SymbolRefAttr>("callee");
+ ::mlir::CallInterfaceCallable getCallableForCallee() {
+ return (*this)->getAttrOfType<::mlir::SymbolRefAttr>("callee");
}
}];
}
@@ -384,9 +384,9 @@ def FunctionalRegionOp : TEST_Op<"functional_region_op",
let results = (outs FunctionType);
let extraClassDeclaration = [{
- Region *getCallableRegion() { return &body(); }
- ArrayRef<Type> getCallableResults() {
- return getType().cast<FunctionType>().getResults();
+ ::mlir::Region *getCallableRegion() { return &body(); }
+ ::llvm::ArrayRef<::mlir::Type> getCallableResults() {
+ return getType().cast<::mlir::FunctionType>().getResults();
}
}];
}
@@ -748,7 +748,7 @@ def OpFuncRef : TEST_Op<"op_funcref"> {
let description = [{
The "test.op_funcref" is a test op with a reference to a function symbol.
}];
- let builders = [OpBuilder<(ins "FuncOp":$function)>];
+ let builders = [OpBuilder<(ins "::mlir::FuncOp":$function)>];
}
// Pattern add the argument plus a increasing static number hidden in
@@ -898,10 +898,10 @@ def OpAllAttrConstraint2 : TEST_Op<"all_attr_constraint_of2"> {
}
def Constraint0 : AttrConstraint<
CPred<"$_self.cast<ArrayAttr>()[0]."
- "cast<IntegerAttr>().getInt() == 0">,
+ "cast<::mlir::IntegerAttr>().getInt() == 0">,
"[0] == 0">;
def Constraint1 : AttrConstraint<
- CPred<"$_self.cast<ArrayAttr>()[1].cast<IntegerAttr>().getInt() == 1">,
+ CPred<"$_self.cast<ArrayAttr>()[1].cast<::mlir::IntegerAttr>().getInt() == 1">,
"[1] == 1">;
def : Pat<(OpAllAttrConstraint1
AllAttrConstraintsOf<[Constraint0, Constraint1]>:$attr),
@@ -917,7 +917,7 @@ def TestOpConstant : TEST_Op<"constant", [ConstantLike, NoSideEffect]> {
let arguments = (ins AnyAttr:$value);
let results = (outs AnyType);
let extraClassDeclaration = [{
- Attribute getValue() { return (*this)->getAttr("value"); }
+ ::mlir::Attribute getValue() { return (*this)->getAttr("value"); }
}];
let hasFolder = 1;
@@ -1268,7 +1268,7 @@ def MixedVResultOp3 : TEST_Op<"mixed_variadic_out3",
// We will use this op in a nested result pattern, where we cannot deduce the
// result type. So need to provide a builder not requiring result types.
let builders = [
- OpBuilder<(ins "IntegerAttr":$count),
+ OpBuilder<(ins "::mlir::IntegerAttr":$count),
[{
auto i32Type = $_builder.getIntegerType(32);
$_state.addTypes(i32Type); // $output1
@@ -1936,8 +1936,8 @@ def CopyOp : TEST_Op<"copy", [CopyOpInterface]> {
attr-dict
}];
let extraClassDeclaration = [{
- Value getSource() { return source(); }
- Value getTarget() { return target(); }
+ ::mlir::Value getSource() { return source(); }
+ ::mlir::Value getTarget() { return target(); }
}];
}
@@ -2027,16 +2027,16 @@ def RegionIfOp : TEST_Op<"region_if",
AnyRegion:$elseRegion,
AnyRegion:$joinRegion);
let extraClassDeclaration = [{
- Block::BlockArgListType getThenArgs() {
+ ::mlir::Block::BlockArgListType getThenArgs() {
return getBody(0)->getArguments();
}
- Block::BlockArgListType getElseArgs() {
+ ::mlir::Block::BlockArgListType getElseArgs() {
return getBody(1)->getArguments();
}
- Block::BlockArgListType getJoinArgs() {
+ ::mlir::Block::BlockArgListType getJoinArgs() {
return getBody(2)->getArguments();
}
- OperandRange getSuccessorEntryOperands(unsigned index);
+ ::mlir::OperandRange getSuccessorEntryOperands(unsigned index);
}];
}
@@ -2089,12 +2089,12 @@ def TableGenBuildOp5 : TEST_Op<"tblgen_build_5",
let results = (outs AnyType:$result);
let extraClassDeclaration = [{
- static LogicalResult inferReturnTypes(MLIRContext *,
- Optional<Location> location, ValueRange operands,
- DictionaryAttr attributes, RegionRange regions,
- SmallVectorImpl<Type> &inferredReturnTypes) {
+ static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *,
+ ::llvm::Optional<::mlir::Location> location, ::mlir::ValueRange operands,
+ ::mlir::DictionaryAttr attributes, ::mlir::RegionRange regions,
+ ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
inferredReturnTypes.assign({operands[0].getType()});
- return success();
+ return ::mlir::success();
}
}];
}
diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp
index a6b0d970792f7..62bed7e0bba2c 100644
--- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp
+++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp
@@ -17,7 +17,7 @@
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
using namespace mlir;
-using namespace mlir::test;
+using namespace test;
// Native function for testing NativeCodeCall
static Value chooseOperand(Value input1, Value input2, BoolAttr choice) {
@@ -67,7 +67,7 @@ namespace {
// Test Reduce Pattern Interface
//===----------------------------------------------------------------------===//
-void mlir::test::populateTestReductionPatterns(RewritePatternSet &patterns) {
+void test::populateTestReductionPatterns(RewritePatternSet &patterns) {
populateWithGenerated(patterns);
}
diff --git a/mlir/test/lib/Dialect/Test/TestTraits.cpp b/mlir/test/lib/Dialect/Test/TestTraits.cpp
index a1a78e724a584..bb78a4b175da1 100644
--- a/mlir/test/lib/Dialect/Test/TestTraits.cpp
+++ b/mlir/test/lib/Dialect/Test/TestTraits.cpp
@@ -11,7 +11,7 @@
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
using namespace mlir;
-using namespace mlir::test;
+using namespace test;
//===----------------------------------------------------------------------===//
// Trait Folder.
diff --git a/mlir/test/lib/Dialect/Test/TestTypeDefs.td b/mlir/test/lib/Dialect/Test/TestTypeDefs.td
index a5ae219780b4b..e11a042766bf0 100644
--- a/mlir/test/lib/Dialect/Test/TestTypeDefs.td
+++ b/mlir/test/lib/Dialect/Test/TestTypeDefs.td
@@ -56,7 +56,7 @@ def IntegerType : Test_Type<"TestInteger"> {
ins
"unsigned":$width,
// SignednessSemantics is defined below.
- "::mlir::test::TestIntegerType::SignednessSemantics":$signedness
+ "::test::TestIntegerType::SignednessSemantics":$signedness
);
// We define the printer inline.
@@ -84,7 +84,7 @@ def IntegerType : Test_Type<"TestInteger"> {
int width;
if ($_parser.parseInteger(width)) return Type();
if ($_parser.parseGreater()) return Type();
- Location loc = $_parser.getEncodedSourceLoc($_parser.getNameLoc());
+ ::mlir::Location loc = $_parser.getEncodedSourceLoc($_parser.getNameLoc());
return getChecked(loc, loc.getContext(), width, signedness);
}];
@@ -114,7 +114,7 @@ class FieldInfo_Type<string name> : Test_Type<name> {
// An ArrayRef of something which requires allocation in the storage
// constructor.
ArrayRefOfSelfAllocationParameter<
- "::mlir::test::FieldInfo", // FieldInfo is defined/declared in TestTypes.h.
+ "::test::FieldInfo", // FieldInfo is defined/declared in TestTypes.h.
"Models struct fields">: $fields
);
@@ -136,7 +136,7 @@ class FieldInfo_Type<string name> : Test_Type<name> {
llvm::SmallVector<FieldInfo, 4> parameters;
if ($_parser.parseLess()) return Type();
while (mlir::succeeded($_parser.parseOptionalLBrace())) {
- StringRef name;
+ llvm::StringRef name;
if ($_parser.parseKeyword(&name)) return Type();
if ($_parser.parseComma()) return Type();
Type type;
@@ -166,12 +166,12 @@ def TestTypeWithLayoutType : Test_Type<"TestTypeWithLayout", [
let mnemonic = "test_type_with_layout";
let parameters = (ins "unsigned":$key);
let extraClassDeclaration = [{
- LogicalResult verifyEntries(DataLayoutEntryListRef params,
- Location loc) const;
+ ::mlir::LogicalResult verifyEntries(::mlir::DataLayoutEntryListRef params,
+ ::mlir::Location loc) const;
private:
- unsigned extractKind(DataLayoutEntryListRef params,
- StringRef expectedKind) const;
+ unsigned extractKind(::mlir::DataLayoutEntryListRef params,
+ ::llvm::StringRef expectedKind) const;
public:
}];
diff --git a/mlir/test/lib/Dialect/Test/TestTypes.cpp b/mlir/test/lib/Dialect/Test/TestTypes.cpp
index 6f01540c8b393..960fbbb5348ce 100644
--- a/mlir/test/lib/Dialect/Test/TestTypes.cpp
+++ b/mlir/test/lib/Dialect/Test/TestTypes.cpp
@@ -22,7 +22,7 @@
#include "llvm/ADT/TypeSwitch.h"
using namespace mlir;
-using namespace mlir::test;
+using namespace test;
// Custom parser for SignednessSemantics.
static ParseResult
@@ -65,7 +65,6 @@ static void printSignedness(DialectAsmPrinter &printer,
// The functions don't need to be in the header file, but need to be in the mlir
// namespace. Declare them here, then define them immediately below. Separating
// the declaration and definition adheres to the LLVM coding standards.
-namespace mlir {
namespace test {
// FieldInfo is used as part of a parameter, so equality comparison is
// compulsory.
@@ -73,16 +72,15 @@ static bool operator==(const FieldInfo &a, const FieldInfo &b);
// FieldInfo is used as part of a parameter, so a hash will be computed.
static llvm::hash_code hash_value(const FieldInfo &fi); // NOLINT
} // namespace test
-} // namespace mlir
// FieldInfo is used as part of a parameter, so equality comparison is
// compulsory.
-static bool mlir::test::operator==(const FieldInfo &a, const FieldInfo &b) {
+static bool test::operator==(const FieldInfo &a, const FieldInfo &b) {
return a.name == b.name && a.type == b.type;
}
// FieldInfo is used as part of a parameter, so a hash will be computed.
-static llvm::hash_code mlir::test::hash_value(const FieldInfo &fi) { // NOLINT
+static llvm::hash_code test::hash_value(const FieldInfo &fi) { // NOLINT
return llvm::hash_combine(fi.name, fi.type);
}
diff --git a/mlir/test/lib/Dialect/Test/TestTypes.h b/mlir/test/lib/Dialect/Test/TestTypes.h
index f9a0289f20b01..7ee722197a25f 100644
--- a/mlir/test/lib/Dialect/Test/TestTypes.h
+++ b/mlir/test/lib/Dialect/Test/TestTypes.h
@@ -23,81 +23,77 @@
#include "mlir/IR/Types.h"
#include "mlir/Interfaces/DataLayoutInterfaces.h"
-namespace mlir {
namespace test {
/// FieldInfo represents a field in the StructType data type. It is used as a
/// parameter in TestTypeDefs.td.
struct FieldInfo {
- StringRef name;
- Type type;
+ ::llvm::StringRef name;
+ ::mlir::Type type;
// Custom allocation called from generated constructor code
- FieldInfo allocateInto(TypeStorageAllocator &alloc) const {
+ FieldInfo allocateInto(::mlir::TypeStorageAllocator &alloc) const {
return FieldInfo{alloc.copyInto(name), type};
}
};
} // namespace test
-} // namespace mlir
#include "TestTypeInterfaces.h.inc"
#define GET_TYPEDEF_CLASSES
#include "TestTypeDefs.h.inc"
-namespace mlir {
namespace test {
/// Storage for simple named recursive types, where the type is identified by
/// its name and can "contain" another type, including itself.
-struct TestRecursiveTypeStorage : public TypeStorage {
- using KeyTy = StringRef;
+struct TestRecursiveTypeStorage : public ::mlir::TypeStorage {
+ using KeyTy = ::llvm::StringRef;
- explicit TestRecursiveTypeStorage(StringRef key) : name(key), body(Type()) {}
+ explicit TestRecursiveTypeStorage(::llvm::StringRef key) : name(key), body(::mlir::Type()) {}
bool operator==(const KeyTy &other) const { return name == other; }
- static TestRecursiveTypeStorage *construct(TypeStorageAllocator &allocator,
+ static TestRecursiveTypeStorage *construct(::mlir::TypeStorageAllocator &allocator,
const KeyTy &key) {
return new (allocator.allocate<TestRecursiveTypeStorage>())
TestRecursiveTypeStorage(allocator.copyInto(key));
}
- LogicalResult mutate(TypeStorageAllocator &allocator, Type newBody) {
+ ::mlir::LogicalResult mutate(::mlir::TypeStorageAllocator &allocator, ::mlir::Type newBody) {
// Cannot set a
diff erent body than before.
if (body && body != newBody)
- return failure();
+ return ::mlir::failure();
body = newBody;
- return success();
+ return ::mlir::success();
}
- StringRef name;
- Type body;
+ ::llvm::StringRef name;
+ ::mlir::Type body;
};
/// Simple recursive type identified by its name and pointing to another named
/// type, potentially itself. This requires the body to be mutated separately
/// from type creation.
class TestRecursiveType
- : public Type::TypeBase<TestRecursiveType, Type, TestRecursiveTypeStorage> {
+ : public ::mlir::Type::TypeBase<TestRecursiveType, ::mlir::Type, TestRecursiveTypeStorage> {
public:
using Base::Base;
- static TestRecursiveType get(MLIRContext *ctx, StringRef name) {
+ static TestRecursiveType get(::mlir::MLIRContext *ctx, ::llvm::StringRef name) {
return Base::get(ctx, name);
}
/// Body getter and setter.
- LogicalResult setBody(Type body) { return Base::mutate(body); }
- Type getBody() { return getImpl()->body; }
+ ::mlir::LogicalResult setBody(Type body) { return Base::mutate(body); }
+ ::mlir::Type getBody() { return getImpl()->body; }
/// Name/key getter.
- StringRef getName() { return getImpl()->name; }
+ ::llvm::StringRef getName() { return getImpl()->name; }
};
} // namespace test
-} // namespace mlir
#endif // MLIR_TESTTYPES_H
diff --git a/mlir/test/lib/IR/TestInterfaces.cpp b/mlir/test/lib/IR/TestInterfaces.cpp
index d5e1d699502fb..bafcdcb5d0c6f 100644
--- a/mlir/test/lib/IR/TestInterfaces.cpp
+++ b/mlir/test/lib/IR/TestInterfaces.cpp
@@ -10,7 +10,7 @@
#include "mlir/Pass/Pass.h"
using namespace mlir;
-using namespace mlir::test;
+using namespace test;
namespace {
/// This test checks various aspects of Type interface generation and
diff --git a/mlir/test/lib/IR/TestTypes.cpp b/mlir/test/lib/IR/TestTypes.cpp
index 0b6e003902341..7d078868f9dd8 100644
--- a/mlir/test/lib/IR/TestTypes.cpp
+++ b/mlir/test/lib/IR/TestTypes.cpp
@@ -11,7 +11,7 @@
#include "mlir/Pass/Pass.h"
using namespace mlir;
-using namespace mlir::test;
+using namespace test;
namespace {
struct TestRecursiveTypesPass
diff --git a/mlir/test/lib/Transforms/TestInlining.cpp b/mlir/test/lib/Transforms/TestInlining.cpp
index 53a16679b512c..c88ee9e7c1c92 100644
--- a/mlir/test/lib/Transforms/TestInlining.cpp
+++ b/mlir/test/lib/Transforms/TestInlining.cpp
@@ -22,7 +22,7 @@
#include "llvm/ADT/StringSet.h"
using namespace mlir;
-using namespace mlir::test;
+using namespace test;
namespace {
struct Inliner : public PassWrapper<Inliner, FunctionPass> {
diff --git a/mlir/test/mlir-tblgen/attrdefs.td b/mlir/test/mlir-tblgen/attrdefs.td
index a5a41b3039918..c42da9433e434 100644
--- a/mlir/test/mlir-tblgen/attrdefs.td
+++ b/mlir/test/mlir-tblgen/attrdefs.td
@@ -13,21 +13,21 @@ include "mlir/IR/OpBase.td"
// DEF: #ifdef GET_ATTRDEF_LIST
// DEF: #undef GET_ATTRDEF_LIST
-// DEF: ::mlir::test::SimpleAAttr,
-// DEF: ::mlir::test::CompoundAAttr,
-// DEF: ::mlir::test::IndexAttr,
-// DEF: ::mlir::test::SingleParameterAttr
+// DEF: ::test::SimpleAAttr,
+// DEF: ::test::CompoundAAttr,
+// DEF: ::test::IndexAttr,
+// DEF: ::test::SingleParameterAttr
// DEF-LABEL: ::mlir::OptionalParseResult generatedAttributeParser(::mlir::MLIRContext *context,
// DEF-NEXT: ::mlir::DialectAsmParser &parser,
// DEF-NEXT: ::llvm::StringRef mnemonic, ::mlir::Type type,
// DEF-NEXT: ::mlir::Attribute &value) {
-// DEF: if (mnemonic == ::mlir::test::CompoundAAttr::getMnemonic()) {
-// DEF-NEXT: value = ::mlir::test::CompoundAAttr::parse(context, parser, type);
+// DEF: if (mnemonic == ::test::CompoundAAttr::getMnemonic()) {
+// DEF-NEXT: value = ::test::CompoundAAttr::parse(context, parser, type);
// DEF-NEXT: return ::mlir::success(!!value);
// DEF-NEXT: }
-// DEF-NEXT: if (mnemonic == ::mlir::test::IndexAttr::getMnemonic()) {
-// DEF-NEXT: value = ::mlir::test::IndexAttr::parse(context, parser, type);
+// DEF-NEXT: if (mnemonic == ::test::IndexAttr::getMnemonic()) {
+// DEF-NEXT: value = ::test::IndexAttr::parse(context, parser, type);
// DEF-NEXT: return ::mlir::success(!!value);
// DEF: return {};
@@ -35,7 +35,7 @@ def Test_Dialect: Dialect {
// DECL-NOT: TestDialect
// DEF-NOT: TestDialect
let name = "TestDialect";
- let cppNamespace = "::mlir::test";
+ let cppNamespace = "::test";
}
class TestAttr<string name> : AttrDef<Test_Dialect, name> { }
@@ -52,7 +52,7 @@ def B_CompoundAttrA : TestAttr<"CompoundA"> {
let parameters = (
ins
"int":$widthOfSomething,
- "::mlir::test::SimpleTypeA": $exampleTdType,
+ "::test::SimpleTypeA": $exampleTdType,
APFloatParameter<"">: $apFloat,
ArrayRefParameter<"int", "Matrix dimensions">:$dims,
AttributeSelfTypeParameter<"">:$inner
@@ -61,8 +61,8 @@ def B_CompoundAttrA : TestAttr<"CompoundA"> {
let genVerifyDecl = 1;
// DECL-LABEL: class CompoundAAttr : public ::mlir::Attribute
-// DECL: static CompoundAAttr getChecked(llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, int widthOfSomething, ::mlir::test::SimpleTypeA exampleTdType, ::llvm::APFloat apFloat, ::llvm::ArrayRef<int> dims, ::mlir::Type inner);
-// DECL: static ::mlir::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, int widthOfSomething, ::mlir::test::SimpleTypeA exampleTdType, ::llvm::APFloat apFloat, ::llvm::ArrayRef<int> dims, ::mlir::Type inner);
+// DECL: static CompoundAAttr getChecked(llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, int widthOfSomething, ::test::SimpleTypeA exampleTdType, ::llvm::APFloat apFloat, ::llvm::ArrayRef<int> dims, ::mlir::Type inner);
+// DECL: static ::mlir::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, int widthOfSomething, ::test::SimpleTypeA exampleTdType, ::llvm::APFloat apFloat, ::llvm::ArrayRef<int> dims, ::mlir::Type inner);
// DECL: static constexpr ::llvm::StringLiteral getMnemonic() {
// DECL: return ::llvm::StringLiteral("cmpnd_a");
// DECL: }
@@ -70,7 +70,7 @@ def B_CompoundAttrA : TestAttr<"CompoundA"> {
// DECL-NEXT: ::mlir::DialectAsmParser &parser, ::mlir::Type type);
// DECL: void print(::mlir::DialectAsmPrinter &printer) const;
// DECL: int getWidthOfSomething() const;
-// DECL: ::mlir::test::SimpleTypeA getExampleTdType() const;
+// DECL: ::test::SimpleTypeA getExampleTdType() const;
// DECL: ::llvm::APFloat getApFloat() const;
// Check that AttributeSelfTypeParameter is handled properly.
diff --git a/mlir/test/mlir-tblgen/typedefs.td b/mlir/test/mlir-tblgen/typedefs.td
index 69848116fbd36..cffc0ec58faf8 100644
--- a/mlir/test/mlir-tblgen/typedefs.td
+++ b/mlir/test/mlir-tblgen/typedefs.td
@@ -13,22 +13,22 @@ include "mlir/IR/OpBase.td"
// DEF: #ifdef GET_TYPEDEF_LIST
// DEF: #undef GET_TYPEDEF_LIST
-// DEF: ::mlir::test::SimpleAType,
-// DEF: ::mlir::test::CompoundAType,
-// DEF: ::mlir::test::IndexType,
-// DEF: ::mlir::test::SingleParameterType,
-// DEF: ::mlir::test::IntegerType
+// DEF: ::test::SimpleAType,
+// DEF: ::test::CompoundAType,
+// DEF: ::test::IndexType,
+// DEF: ::test::SingleParameterType,
+// DEF: ::test::IntegerType
// DEF-LABEL: ::mlir::OptionalParseResult generatedTypeParser(::mlir::MLIRContext *context,
// DEF-NEXT: ::mlir::DialectAsmParser &parser,
// DEF-NEXT: ::llvm::StringRef mnemonic,
// DEF-NEXT: ::mlir::Type &value) {
-// DEF: if (mnemonic == ::mlir::test::CompoundAType::getMnemonic()) {
-// DEF-NEXT: value = ::mlir::test::CompoundAType::parse(context, parser);
+// DEF: if (mnemonic == ::test::CompoundAType::getMnemonic()) {
+// DEF-NEXT: value = ::test::CompoundAType::parse(context, parser);
// DEF-NEXT: return ::mlir::success(!!value);
// DEF-NEXT: }
-// DEF-NEXT: if (mnemonic == ::mlir::test::IndexType::getMnemonic()) {
-// DEF-NEXT: value = ::mlir::test::IndexType::parse(context, parser);
+// DEF-NEXT: if (mnemonic == ::test::IndexType::getMnemonic()) {
+// DEF-NEXT: value = ::test::IndexType::parse(context, parser);
// DEF-NEXT: return ::mlir::success(!!value);
// DEF: return {};
@@ -36,7 +36,7 @@ def Test_Dialect: Dialect {
// DECL-NOT: TestDialect
// DEF-NOT: TestDialect
let name = "TestDialect";
- let cppNamespace = "::mlir::test";
+ let cppNamespace = "::test";
}
class TestType<string name> : TypeDef<Test_Dialect, name> { }
@@ -57,7 +57,7 @@ def B_CompoundTypeA : TestType<"CompoundA"> {
let parameters = (
ins
"int":$widthOfSomething,
- "::mlir::test::SimpleTypeA": $exampleTdType,
+ "::test::SimpleTypeA": $exampleTdType,
"SomeCppStruct": $exampleCppType,
ArrayRefParameter<"int", "Matrix dimensions">:$dims,
RTLValueType:$inner
@@ -66,8 +66,8 @@ def B_CompoundTypeA : TestType<"CompoundA"> {
let genVerifyDecl = 1;
// DECL-LABEL: class CompoundAType : public ::mlir::Type
-// DECL: static CompoundAType getChecked(llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, int widthOfSomething, ::mlir::test::SimpleTypeA exampleTdType, SomeCppStruct exampleCppType, ::llvm::ArrayRef<int> dims, ::mlir::Type inner);
-// DECL: static ::mlir::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, int widthOfSomething, ::mlir::test::SimpleTypeA exampleTdType, SomeCppStruct exampleCppType, ::llvm::ArrayRef<int> dims, ::mlir::Type inner);
+// DECL: static CompoundAType getChecked(llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, int widthOfSomething, ::test::SimpleTypeA exampleTdType, SomeCppStruct exampleCppType, ::llvm::ArrayRef<int> dims, ::mlir::Type inner);
+// DECL: static ::mlir::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, int widthOfSomething, ::test::SimpleTypeA exampleTdType, SomeCppStruct exampleCppType, ::llvm::ArrayRef<int> dims, ::mlir::Type inner);
// DECL: static constexpr ::llvm::StringLiteral getMnemonic() {
// DECL: return ::llvm::StringLiteral("cmpnd_a");
// DECL: }
@@ -75,7 +75,7 @@ def B_CompoundTypeA : TestType<"CompoundA"> {
// DECL-NEXT: ::mlir::DialectAsmParser &parser);
// DECL: void print(::mlir::DialectAsmPrinter &printer) const;
// DECL: int getWidthOfSomething() const;
-// DECL: ::mlir::test::SimpleTypeA getExampleTdType() const;
+// DECL: ::test::SimpleTypeA getExampleTdType() const;
// DECL: SomeCppStruct getExampleCppType() const;
}
diff --git a/mlir/tools/mlir-opt/mlir-opt.cpp b/mlir/tools/mlir-opt/mlir-opt.cpp
index efbd9ed883b1d..3059b1fafb96a 100644
--- a/mlir/tools/mlir-opt/mlir-opt.cpp
+++ b/mlir/tools/mlir-opt/mlir-opt.cpp
@@ -70,7 +70,6 @@ void registerTestGpuSerializeToHsacoPass();
void registerTestDataLayoutQuery();
void registerTestDecomposeCallGraphTypes();
void registerTestDiagnosticsPass();
-void registerTestDialect(DialectRegistry &);
void registerTestDominancePass();
void registerTestDynamicPipelinePass();
void registerTestExpandTanhPass();
@@ -108,6 +107,10 @@ void registerTestVectorConversions();
} // namespace test
} // namespace mlir
+namespace test {
+void registerTestDialect(DialectRegistry &);
+} // namespace test
+
#ifdef MLIR_INCLUDE_TESTS
void registerTestPasses() {
registerConvertToTargetEnvPass();
@@ -135,58 +138,58 @@ void registerTestPasses() {
registerVectorizerTestPass();
registerTosaTestQuantUtilAPIPass();
- test::registerConvertCallOpPass();
- test::registerInliner();
- test::registerMemRefBoundCheck();
- test::registerPatternsTestPass();
- test::registerSimpleParametricTilingPass();
- test::registerTestAffineLoopParametricTilingPass();
- test::registerTestAliasAnalysisPass();
- test::registerTestCallGraphPass();
- test::registerTestConstantFold();
- test::registerTestDiagnosticsPass();
+ mlir::test::registerConvertCallOpPass();
+ mlir::test::registerInliner();
+ mlir::test::registerMemRefBoundCheck();
+ mlir::test::registerPatternsTestPass();
+ mlir::test::registerSimpleParametricTilingPass();
+ mlir::test::registerTestAffineLoopParametricTilingPass();
+ mlir::test::registerTestAliasAnalysisPass();
+ mlir::test::registerTestCallGraphPass();
+ mlir::test::registerTestConstantFold();
+ mlir::test::registerTestDiagnosticsPass();
#if MLIR_CUDA_CONVERSIONS_ENABLED
- test::registerTestGpuSerializeToCubinPass();
+ mlir::test::registerTestGpuSerializeToCubinPass();
#endif
#if MLIR_ROCM_CONVERSIONS_ENABLED
- test::registerTestGpuSerializeToHsacoPass();
+ mlir::test::registerTestGpuSerializeToHsacoPass();
#endif
- test::registerTestConvVectorization();
- test::registerTestDecomposeCallGraphTypes();
- test::registerTestDataLayoutQuery();
- test::registerTestDominancePass();
- test::registerTestDynamicPipelinePass();
- test::registerTestExpandTanhPass();
- test::registerTestComposeSubView();
- test::registerTestGpuParallelLoopMappingPass();
- test::registerTestIRVisitorsPass();
- test::registerTestInterfaces();
- test::registerTestLinalgCodegenStrategy();
- test::registerTestLinalgDistribution();
- test::registerTestLinalgElementwiseFusion();
- test::registerTestPushExpandingReshape();
- test::registerTestLinalgFusionTransforms();
- test::registerTestLinalgTensorFusionTransforms();
- test::registerTestLinalgTiledLoopFusionTransforms();
- test::registerTestLinalgGreedyFusion();
- test::registerTestLinalgHoisting();
- test::registerTestLinalgTileAndFuseSequencePass();
- test::registerTestLinalgTransforms();
- test::registerTestLivenessPass();
- test::registerTestLoopFusion();
- test::registerTestLoopMappingPass();
- test::registerTestLoopUnrollingPass();
- test::registerTestMathAlgebraicSimplificationPass();
- test::registerTestMathPolynomialApproximationPass();
- test::registerTestMemRefDependenceCheck();
- test::registerTestMemRefStrideCalculation();
- test::registerTestNumberOfBlockExecutionsPass();
- test::registerTestNumberOfOperationExecutionsPass();
- test::registerTestOpaqueLoc();
- test::registerTestPDLByteCodePass();
- test::registerTestRecursiveTypesPass();
- test::registerTestSCFUtilsPass();
- test::registerTestVectorConversions();
+ mlir::test::registerTestConvVectorization();
+ mlir::test::registerTestDecomposeCallGraphTypes();
+ mlir::test::registerTestDataLayoutQuery();
+ mlir::test::registerTestDominancePass();
+ mlir::test::registerTestDynamicPipelinePass();
+ mlir::test::registerTestExpandTanhPass();
+ mlir::test::registerTestComposeSubView();
+ mlir::test::registerTestGpuParallelLoopMappingPass();
+ mlir::test::registerTestIRVisitorsPass();
+ mlir::test::registerTestInterfaces();
+ mlir::test::registerTestLinalgCodegenStrategy();
+ mlir::test::registerTestLinalgDistribution();
+ mlir::test::registerTestLinalgElementwiseFusion();
+ mlir::test::registerTestPushExpandingReshape();
+ mlir::test::registerTestLinalgFusionTransforms();
+ mlir::test::registerTestLinalgTensorFusionTransforms();
+ mlir::test::registerTestLinalgTiledLoopFusionTransforms();
+ mlir::test::registerTestLinalgGreedyFusion();
+ mlir::test::registerTestLinalgHoisting();
+ mlir::test::registerTestLinalgTileAndFuseSequencePass();
+ mlir::test::registerTestLinalgTransforms();
+ mlir::test::registerTestLivenessPass();
+ mlir::test::registerTestLoopFusion();
+ mlir::test::registerTestLoopMappingPass();
+ mlir::test::registerTestLoopUnrollingPass();
+ mlir::test::registerTestMathAlgebraicSimplificationPass();
+ mlir::test::registerTestMathPolynomialApproximationPass();
+ mlir::test::registerTestMemRefDependenceCheck();
+ mlir::test::registerTestMemRefStrideCalculation();
+ mlir::test::registerTestNumberOfBlockExecutionsPass();
+ mlir::test::registerTestNumberOfOperationExecutionsPass();
+ mlir::test::registerTestOpaqueLoc();
+ mlir::test::registerTestPDLByteCodePass();
+ mlir::test::registerTestRecursiveTypesPass();
+ mlir::test::registerTestSCFUtilsPass();
+ mlir::test::registerTestVectorConversions();
}
#endif
@@ -198,7 +201,7 @@ int main(int argc, char **argv) {
DialectRegistry registry;
registerAllDialects(registry);
#ifdef MLIR_INCLUDE_TESTS
- test::registerTestDialect(registry);
+ ::test::registerTestDialect(registry);
#endif
return mlir::asMainReturnCode(
mlir::MlirOptMain(argc, argv, "MLIR modular optimizer driver\n", registry,
diff --git a/mlir/tools/mlir-reduce/mlir-reduce.cpp b/mlir/tools/mlir-reduce/mlir-reduce.cpp
index 01d7c96cd8bbc..44b21b805e8c3 100644
--- a/mlir/tools/mlir-reduce/mlir-reduce.cpp
+++ b/mlir/tools/mlir-reduce/mlir-reduce.cpp
@@ -21,13 +21,11 @@
using namespace mlir;
-namespace mlir {
namespace test {
#ifdef MLIR_INCLUDE_TESTS
void registerTestDialect(DialectRegistry &);
#endif
} // namespace test
-} // namespace mlir
int main(int argc, char **argv) {
registerAllPasses();
diff --git a/mlir/unittests/IR/InterfaceAttachmentTest.cpp b/mlir/unittests/IR/InterfaceAttachmentTest.cpp
index 76124707cbfc7..3b362fa221899 100644
--- a/mlir/unittests/IR/InterfaceAttachmentTest.cpp
+++ b/mlir/unittests/IR/InterfaceAttachmentTest.cpp
@@ -22,7 +22,7 @@
#include "../../test/lib/Dialect/Test/TestTypes.h"
using namespace mlir;
-using namespace mlir::test;
+using namespace test;
namespace {
More information about the Mlir-commits
mailing list