diff --git a/mlir/include/mlir/IR/BuiltinOps.td b/mlir/include/mlir/IR/BuiltinOps.td --- a/mlir/include/mlir/IR/BuiltinOps.td +++ b/mlir/include/mlir/IR/BuiltinOps.td @@ -115,7 +115,7 @@ /// 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 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -1618,7 +1618,7 @@ } // Derived attribute that returns a mlir::Type. -class DerivedTypeAttr : DerivedAttr<"Type", body> { +class DerivedTypeAttr : 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 --- a/mlir/include/mlir/IR/RegionKindInterface.td +++ b/mlir/include/mlir/IR/RegionKindInterface.td @@ -33,7 +33,7 @@ /*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 @@ /*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 --- a/mlir/include/mlir/Interfaces/InferTypeOpInterface.td +++ b/mlir/include/mlir/Interfaces/InferTypeOpInterface.td @@ -168,10 +168,10 @@ 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 --- 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.h b/mlir/test/lib/Dialect/Test/TestDialect.h --- a/mlir/test/lib/Dialect/Test/TestDialect.h +++ b/mlir/test/lib/Dialect/Test/TestDialect.h @@ -45,11 +45,9 @@ #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/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp --- 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(); } diff --git a/mlir/test/lib/Dialect/Test/TestInterfaces.td b/mlir/test/lib/Dialect/Test/TestInterfaces.td --- a/mlir/test/lib/Dialect/Test/TestInterfaces.td +++ b/mlir/test/lib/Dialect/Test/TestInterfaces.td @@ -14,26 +14,26 @@ // 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 @@ ]; 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 --- a/mlir/test/lib/Dialect/Test/TestOps.td +++ b/mlir/test/lib/Dialect/Test/TestOps.td @@ -24,7 +24,7 @@ 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 @@ 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 - getParseOperationHook(StringRef opName) const override; - LogicalResult printOperation(Operation *op, - OpAsmPrinter &printer) const override; + ::llvm::Optional + 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 TEST_TestType : DialectType()">, "test">, - BuildableType<"$_builder.getType<::mlir::test::TestType>()">; + CPred<"$_self.isa<::test::TestType>()">, "test">, + BuildableType<"$_builder.getType<::test::TestType>()">; //===----------------------------------------------------------------------===// // Test Symbols @@ -372,8 +372,8 @@ operand_range getArgOperands() { return inputs(); } /// Return the callee of this operation. - CallInterfaceCallable getCallableForCallee() { - return (*this)->getAttrOfType("callee"); + ::mlir::CallInterfaceCallable getCallableForCallee() { + return (*this)->getAttrOfType<::mlir::SymbolRefAttr>("callee"); } }]; } @@ -384,9 +384,9 @@ let results = (outs FunctionType); let extraClassDeclaration = [{ - Region *getCallableRegion() { return &body(); } - ArrayRef getCallableResults() { - return getType().cast().getResults(); + ::mlir::Region *getCallableRegion() { return &body(); } + ::llvm::ArrayRef<::mlir::Type> getCallableResults() { + return getType().cast<::mlir::FunctionType>().getResults(); } }]; } @@ -748,7 +748,7 @@ 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 Constraint0 : AttrConstraint< CPred<"$_self.cast()[0]." - "cast().getInt() == 0">, + "cast<::mlir::IntegerAttr>().getInt() == 0">, "[0] == 0">; def Constraint1 : AttrConstraint< - CPred<"$_self.cast()[1].cast().getInt() == 1">, + CPred<"$_self.cast()[1].cast<::mlir::IntegerAttr>().getInt() == 1">, "[1] == 1">; def : Pat<(OpAllAttrConstraint1 AllAttrConstraintsOf<[Constraint0, Constraint1]>:$attr), @@ -917,7 +917,7 @@ 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 @@ // 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 @@ 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 @@ 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 @@ let results = (outs AnyType:$result); let extraClassDeclaration = [{ - static LogicalResult inferReturnTypes(MLIRContext *, - Optional location, ValueRange operands, - DictionaryAttr attributes, RegionRange regions, - SmallVectorImpl &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 --- 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 @@ // 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 --- 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 --- a/mlir/test/lib/Dialect/Test/TestTypeDefs.td +++ b/mlir/test/lib/Dialect/Test/TestTypeDefs.td @@ -56,7 +56,7 @@ 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 @@ 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 @@ // 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 @@ llvm::SmallVector 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 @@ 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.h b/mlir/test/lib/Dialect/Test/TestTypes.h --- 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(allocator.copyInto(key)); } - LogicalResult mutate(TypeStorageAllocator &allocator, Type newBody) { + ::mlir::LogicalResult mutate(::mlir::TypeStorageAllocator &allocator, ::mlir::Type newBody) { // Cannot set a different 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 { + : public ::mlir::Type::TypeBase { 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/Dialect/Test/TestTypes.cpp b/mlir/test/lib/Dialect/Test/TestTypes.cpp --- 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 @@ // 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 @@ // 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/IR/TestInterfaces.cpp b/mlir/test/lib/IR/TestInterfaces.cpp --- 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 --- 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 --- 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 { diff --git a/mlir/test/mlir-tblgen/attrdefs.td b/mlir/test/mlir-tblgen/attrdefs.td --- a/mlir/test/mlir-tblgen/attrdefs.td +++ b/mlir/test/mlir-tblgen/attrdefs.td @@ -13,21 +13,21 @@ // 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 @@ // DECL-NOT: TestDialect // DEF-NOT: TestDialect let name = "TestDialect"; - let cppNamespace = "::mlir::test"; + let cppNamespace = "::test"; } class TestAttr : AttrDef { } @@ -52,7 +52,7 @@ 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 @@ 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 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 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 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 dims, ::mlir::Type inner); // DECL: static constexpr ::llvm::StringLiteral getMnemonic() { // DECL: return ::llvm::StringLiteral("cmpnd_a"); // DECL: } @@ -70,7 +70,7 @@ // 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 --- a/mlir/test/mlir-tblgen/typedefs.td +++ b/mlir/test/mlir-tblgen/typedefs.td @@ -13,22 +13,22 @@ // 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 @@ // DECL-NOT: TestDialect // DEF-NOT: TestDialect let name = "TestDialect"; - let cppNamespace = "::mlir::test"; + let cppNamespace = "::test"; } class TestType : TypeDef { } @@ -57,7 +57,7 @@ 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 @@ 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 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 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 dims, ::mlir::Type inner); +// DECL: static ::mlir::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, int widthOfSomething, ::test::SimpleTypeA exampleTdType, SomeCppStruct exampleCppType, ::llvm::ArrayRef dims, ::mlir::Type inner); // DECL: static constexpr ::llvm::StringLiteral getMnemonic() { // DECL: return ::llvm::StringLiteral("cmpnd_a"); // DECL: } @@ -75,7 +75,7 @@ // 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 --- a/mlir/tools/mlir-opt/mlir-opt.cpp +++ b/mlir/tools/mlir-opt/mlir-opt.cpp @@ -70,7 +70,6 @@ void registerTestDataLayoutQuery(); void registerTestDecomposeCallGraphTypes(); void registerTestDiagnosticsPass(); -void registerTestDialect(DialectRegistry &); void registerTestDominancePass(); void registerTestDynamicPipelinePass(); void registerTestExpandTanhPass(); @@ -108,6 +107,10 @@ } // namespace test } // namespace mlir +namespace test { +void registerTestDialect(DialectRegistry &); +} // namespace test + #ifdef MLIR_INCLUDE_TESTS void registerTestPasses() { registerConvertToTargetEnvPass(); @@ -135,58 +138,58 @@ 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 @@ 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 --- 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 --- 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 {