[Mlir-commits] [mlir] 05b4ff0 - [mlir-tblgen] Use fully qualified names in generated code files
Jean-Michel Gorius
llvmlistbot at llvm.org
Fri Jun 26 06:06:11 PDT 2020
Author: Jean-Michel Gorius
Date: 2020-06-26T15:05:33+02:00
New Revision: 05b4ff0a4b1a822449e9bf98782b9d337e6f81cf
URL: https://github.com/llvm/llvm-project/commit/05b4ff0a4b1a822449e9bf98782b9d337e6f81cf
DIFF: https://github.com/llvm/llvm-project/commit/05b4ff0a4b1a822449e9bf98782b9d337e6f81cf.diff
LOG: [mlir-tblgen] Use fully qualified names in generated code files
Using fully qualified names wherever possible avoids ambiguous class and function names. This is a follow-up to D82371.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D82471
Added:
Modified:
mlir/include/mlir/IR/OpBase.td
mlir/lib/TableGen/OpClass.cpp
mlir/test/mlir-tblgen/op-attribute.td
mlir/test/mlir-tblgen/op-decl.td
mlir/test/mlir-tblgen/op-interface.td
mlir/test/mlir-tblgen/op-operand.td
mlir/test/mlir-tblgen/op-result.td
mlir/test/mlir-tblgen/op-side-effects.td
mlir/test/mlir-tblgen/predicate.td
mlir/tools/mlir-tblgen/EnumsGen.cpp
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/tools/mlir-tblgen/OpFormatGen.cpp
mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
mlir/tools/mlir-tblgen/PassGen.cpp
mlir/tools/mlir-tblgen/RewriterGen.cpp
mlir/tools/mlir-tblgen/StructsGen.cpp
mlir/unittests/TableGen/EnumsGenTest.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td
index ae0fde0e939b..dbd81251d870 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -208,25 +208,27 @@ class SuccessorConstraint<Pred predicate, string description = ""> :
//===----------------------------------------------------------------------===//
// Whether a type is a VectorType.
-def IsVectorTypePred : CPred<"$_self.isa<VectorType>()">;
+def IsVectorTypePred : CPred<"$_self.isa<::mlir::VectorType>()">;
// Whether a type is a TensorType.
-def IsTensorTypePred : CPred<"$_self.isa<TensorType>()">;
+def IsTensorTypePred : CPred<"$_self.isa<::mlir::TensorType>()">;
// Whether a type is a MemRefType.
-def IsMemRefTypePred : CPred<"$_self.isa<MemRefType>()">;
+def IsMemRefTypePred : CPred<"$_self.isa<::mlir::MemRefType>()">;
// Whether a type is an IsUnrankedMemRefType
-def IsUnrankedMemRefTypePred : CPred<"$_self.isa<UnrankedMemRefType>()">;
+def IsUnrankedMemRefTypePred
+ : CPred<"$_self.isa<::mlir::UnrankedMemRefType>()">;
// Whether a type is a ShapedType.
-def IsShapedTypePred : CPred<"$_self.isa<ShapedType>()">;
+def IsShapedTypePred : CPred<"$_self.isa<::mlir::ShapedType>()">;
// For a ShapedType, verify that it has a static shape.
-def HasStaticShapePred : CPred<"$_self.cast<ShapedType>().hasStaticShape()">;
+def HasStaticShapePred :
+ CPred<"$_self.cast<::mlir::ShapedType>().hasStaticShape()">;
// Whether a type is a TupleType.
-def IsTupleTypePred : CPred<"$_self.isa<TupleType>()">;
+def IsTupleTypePred : CPred<"$_self.isa<::mlir::TupleType>()">;
//===----------------------------------------------------------------------===//
// Dialect definitions
@@ -323,8 +325,8 @@ class BuildableType<code builder> {
def AnyType : Type<CPred<"true">, "any type">;
// None type
-def NoneType : Type<CPred<"$_self.isa<NoneType>()">, "none type">,
- BuildableType<"$_builder.getType<NoneType>()">;
+def NoneType : Type<CPred<"$_self.isa<::mlir::NoneType>()">, "none type">,
+ BuildableType<"$_builder.getType<::mlir::NoneType>()">;
// Any type from the given list
class AnyTypeOf<list<Type> allowedTypes, string description = ""> : Type<
@@ -337,7 +339,7 @@ class AnyTypeOf<list<Type> allowedTypes, string description = ""> : Type<
// Integer types.
// Any integer type irrespective of its width and signedness semantics.
-def AnyInteger : Type<CPred<"$_self.isa<IntegerType>()">, "integer">;
+def AnyInteger : Type<CPred<"$_self.isa<::mlir::IntegerType>()">, "integer">;
// Any integer type (regardless of signedness semantics) of a specific width.
class AnyI<int width>
@@ -424,13 +426,13 @@ def UI32 : UI<32>;
def UI64 : UI<64>;
// Index type.
-def Index : Type<CPred<"$_self.isa<IndexType>()">, "index">,
+def Index : Type<CPred<"$_self.isa<::mlir::IndexType>()">, "index">,
BuildableType<"$_builder.getIndexType()">;
// Floating point types.
// Any float type irrespective of its width.
-def AnyFloat : Type<CPred<"$_self.isa<FloatType>()">, "floating-point">;
+def AnyFloat : Type<CPred<"$_self.isa<::mlir::FloatType>()">, "floating-point">;
// Float type of a specific width.
class F<int width>
@@ -453,25 +455,28 @@ def BF16 : Type<CPred<"$_self.isBF16()">, "bfloat16 type">,
class Complex<Type type>
: Type<And<[
- CPred<"$_self.isa<ComplexType>()">,
- SubstLeaves<"$_self", "$_self.cast<ComplexType>().getElementType()",
+ CPred<"$_self.isa<::mlir::ComplexType>()">,
+ SubstLeaves<"$_self",
+ "$_self.cast<::mlir::ComplexType>().getElementType()",
type.predicate>]>,
"complex type with " # type.description # " elements"> {
Type elementType = type;
}
-def AnyComplex : Type<CPred<"$_self.isa<ComplexType>()">, "complex-type">;
+def AnyComplex : Type<CPred<"$_self.isa<::mlir::ComplexType>()">,
+ "complex-type">;
class OpaqueType<string dialect, string name, string description>
: Type<CPred<"isOpaqueTypeWithName($_self, \""#dialect#"\", \""#name#"\")">,
description>,
- BuildableType<"OpaqueType::get($_builder.getIdentifier(\"" # dialect #
- "\"), \"" # name # "\", $_builder.getContext())">;
+ BuildableType<"::mlir::OpaqueType::get($_builder.getIdentifier(\""
+ # dialect # "\"), \"" # name # "\", $_builder.getContext())">;
// Function Type
// Any function type.
-def FunctionType : Type<CPred<"$_self.isa<FunctionType>()">, "function type">;
+def FunctionType : Type<CPred<"$_self.isa<::mlir::FunctionType>()">,
+ "function type">;
// A container type is a type that has another type embedded within it.
class ContainerType<Type etype, Pred containerPred, code elementTypeCall,
@@ -489,18 +494,21 @@ class ContainerType<Type etype, Pred containerPred, code elementTypeCall,
code getElementTypeCall = elementTypeCall;
}
-class ShapedContainerType<list<Type> allowedTypes, Pred containerPred, string descr> :
+class ShapedContainerType<list<Type> allowedTypes,
+ Pred containerPred, string descr> :
ContainerType<AnyTypeOf<allowedTypes>, containerPred,
- "$_self.cast<ShapedType>().getElementType()", descr>;
+ "$_self.cast<::mlir::ShapedType>().getElementType()", descr>;
// Whether a shaped type is ranked.
-def HasRankPred : CPred<"$_self.cast<ShapedType>().hasRank()">;
+def HasRankPred : CPred<"$_self.cast<::mlir::ShapedType>().hasRank()">;
// Whether a shaped type has one of the specified ranks.
class HasAnyRankOfPred<list<int> ranks> : And<[
HasRankPred,
Or<!foreach(rank, ranks,
- CPred<"$_self.cast<ShapedType>().getRank() == " # rank>)>]>;
+ CPred<[{$_self.cast<::mlir::ShapedType>().getRank()
+ == }]
+ # rank>)>]>;
// Vector types.
@@ -512,7 +520,7 @@ class VectorOf<list<Type> allowedTypes> :
class IsVectorOfRankPred<list<int> allowedRanks> :
And<[IsVectorTypePred,
Or<!foreach(allowedlength, allowedRanks,
- CPred<[{$_self.cast<VectorType>().getRank()
+ CPred<[{$_self.cast<::mlir::VectorType>().getRank()
== }]
# allowedlength>)>]>;
@@ -535,7 +543,7 @@ class VectorOfRankAndType<list<int> allowedRanks,
class IsVectorOfLengthPred<list<int> allowedLengths> :
And<[IsVectorTypePred,
Or<!foreach(allowedlength, allowedLengths,
- CPred<[{$_self.cast<VectorType>().getNumElements()
+ CPred<[{$_self.cast<::mlir::VectorType>().getNumElements()
== }]
# allowedlength>)>]>;
@@ -641,7 +649,7 @@ class StaticShapeMemRefOf<list<Type> allowedTypes>
def AnyStaticShapeMemRef : StaticShapeMemRefOf<[AnyType]>;
// For a MemRefType, verify that it has strides.
-def HasStridesPred : CPred<[{ isStrided($_self.cast<MemRefType>()) }]>;
+def HasStridesPred : CPred<[{ isStrided($_self.cast<::mlir::MemRefType>()) }]>;
class StridedMemRefOf<list<Type> allowedTypes>
: Type<And<[MemRefOf<allowedTypes>.predicate, HasStridesPred]>,
@@ -666,7 +674,7 @@ class MixedContainerType<Type etype, Pred containerPred, code elementTypesCall,
And<[
containerPred,
Concat<
- "llvm::all_of(" # elementTypesCall # ", [](Type t) { return ",
+ "::llvm::all_of(" # elementTypesCall # ", [](Type t) { return ",
SubstLeaves<"$_self", "t", etype.predicate>,
"; })"
>
@@ -682,13 +690,14 @@ class MixedContainerType<Type etype, Pred containerPred, code elementTypesCall,
// A Tuple that holds a mix of elements of the allowed types.
class TupleOf<list<Type> allowedTypes>
: MixedContainerType<AnyTypeOf<allowedTypes>, IsTupleTypePred,
- "$_self.cast<TupleType>().getTypes()", "tuple">;
+ "$_self.cast<::mlir::TupleType>().getTypes()",
+ "tuple">;
// A Tuple with arbitrary nesting, where all elements are a mix of the allowed
// types.
class NestedTupleOf<list<Type> allowedTypes> :
MixedContainerType<AnyTypeOf<allowedTypes>, IsTupleTypePred,
- "getFlattenedTypes($_self.cast<TupleType>())",
+ "getFlattenedTypes($_self.cast<::mlir::TupleType>())",
"nested tuple">;
//===----------------------------------------------------------------------===//
@@ -806,9 +815,9 @@ class OptionalAttr<Attr attr> : Attr<attr.predicate, attr.description> {
// Rewrite the attribute to be optional.
// Note: this has to be kept up to date with Attr above.
let storageType = attr.storageType;
- let returnType = "Optional<" # attr.returnType #">";
+ let returnType = "::llvm::Optional<" # attr.returnType #">";
let convertFromStorage = "$_self ? " # returnType # "(" #
- attr.convertFromStorage # ") : (llvm::None)";
+ attr.convertFromStorage # ") : (::llvm::None)";
let valueType = attr.valueType;
let isOptional = 1;
@@ -825,20 +834,20 @@ class TypedAttrBase<Type attrValType, string attrKind, Pred condition,
Attr<condition, descr> {
let constBuilderCall = "$_builder.get" # attrKind # "(" #
attrValType.builderCall # ", $0)";
- let storageType = attrKind;
+ let storageType = "::mlir::" # attrKind;
let valueType = attrValType;
}
// Any attribute.
def AnyAttr : Attr<CPred<"true">, "any attribute"> {
- let storageType = "Attribute";
- let returnType = "Attribute";
+ let storageType = "::mlir::Attribute";
+ let returnType = "::mlir::Attribute";
let convertFromStorage = "$_self";
let constBuilderCall = "$0";
}
-def BoolAttr : Attr<CPred<"$_self.isa<BoolAttr>()">, "bool attribute"> {
- let storageType = [{ BoolAttr }];
+def BoolAttr : Attr<CPred<"$_self.isa<::mlir::BoolAttr>()">, "bool attribute"> {
+ let storageType = [{ ::mlir::BoolAttr }];
let returnType = [{ bool }];
let valueType = I1;
let constBuilderCall = "$_builder.getBoolAttr($0)";
@@ -848,10 +857,11 @@ def BoolAttr : Attr<CPred<"$_self.isa<BoolAttr>()">, "bool attribute"> {
def IndexAttr :
TypedAttrBase<
Index, "IntegerAttr",
- And<[CPred<"$_self.isa<IntegerAttr>()">,
- CPred<"$_self.cast<IntegerAttr>().getType().isa<IndexType>()">]>,
+ And<[CPred<"$_self.isa<::mlir::IntegerAttr>()">,
+ CPred<"$_self.cast<::mlir::IntegerAttr>().getType()"
+ ".isa<::mlir::IndexType>()">]>,
"index attribute"> {
- let returnType = [{ APInt }];
+ let returnType = [{ ::llvm::APInt }];
}
// Base class for any integer (regardless of signedness semantics) attributes
@@ -859,11 +869,11 @@ def IndexAttr :
class AnyIntegerAttrBase<AnyI attrValType, string descr> :
TypedAttrBase<
attrValType, "IntegerAttr",
- And<[CPred<"$_self.isa<IntegerAttr>()">,
- CPred<"$_self.cast<IntegerAttr>().getType()."
+ And<[CPred<"$_self.isa<::mlir::IntegerAttr>()">,
+ CPred<"$_self.cast<::mlir::IntegerAttr>().getType()."
"isInteger(" # attrValType.bitwidth # ")">]>,
descr> {
- let returnType = [{ APInt }];
+ let returnType = [{ ::llvm::APInt }];
let constBuilderCall = ?;
}
@@ -873,21 +883,21 @@ def AnyI16Attr : AnyIntegerAttrBase<AnyI16, "16-bit integer attribute">;
def AnyI32Attr : AnyIntegerAttrBase<AnyI32, "32-bit integer attribute">;
def AnyI64Attr : AnyIntegerAttrBase<AnyI64, "64-bit integer attribute">;
-def APIntAttr : Attr<CPred<"$_self.isa<IntegerAttr>()">,
+def APIntAttr : Attr<CPred<"$_self.isa<::mlir::IntegerAttr>()">,
"arbitrary integer attribute"> {
- let storageType = [{ IntegerAttr }];
- let returnType = [{ APInt }];
+ let storageType = [{ ::mlir::IntegerAttr }];
+ let returnType = [{ ::mlir::APInt }];
}
// Base class for signless integer attributes of fixed width.
class SignlessIntegerAttrBase<I attrValType, string descr> :
TypedAttrBase<
attrValType, "IntegerAttr",
- And<[CPred<"$_self.isa<IntegerAttr>()">,
- CPred<"$_self.cast<IntegerAttr>().getType()."
+ And<[CPred<"$_self.isa<::mlir::IntegerAttr>()">,
+ CPred<"$_self.cast<::mlir::IntegerAttr>().getType()."
"isSignlessInteger(" # attrValType.bitwidth # ")">]>,
descr> {
- let returnType = [{ APInt }];
+ let returnType = [{ ::llvm::APInt }];
}
def I1Attr : SignlessIntegerAttrBase<I1, "1-bit signless integer attribute">;
@@ -900,11 +910,11 @@ def I64Attr : SignlessIntegerAttrBase<I64, "64-bit signless integer attribute">;
class SignedIntegerAttrBase<SI attrValType, string descr> :
TypedAttrBase<
attrValType, "IntegerAttr",
- And<[CPred<"$_self.isa<IntegerAttr>()">,
- CPred<"$_self.cast<IntegerAttr>().getType()."
+ And<[CPred<"$_self.isa<::mlir::IntegerAttr>()">,
+ CPred<"$_self.cast<::mlir::IntegerAttr>().getType()."
"isSignedInteger(" # attrValType.bitwidth # ")">]>,
descr> {
- let returnType = [{ APInt }];
+ let returnType = [{ ::llvm::APInt }];
}
def SI1Attr : SignedIntegerAttrBase<
@@ -922,11 +932,11 @@ def SI64Attr : SignedIntegerAttrBase<
class UnsignedIntegerAttrBase<UI attrValType, string descr> :
TypedAttrBase<
attrValType, "IntegerAttr",
- And<[CPred<"$_self.isa<IntegerAttr>()">,
- CPred<"$_self.cast<IntegerAttr>().getType()."
+ And<[CPred<"$_self.isa<::mlir::IntegerAttr>()">,
+ CPred<"$_self.cast<::mlir::IntegerAttr>().getType()."
"isUnsignedInteger(" # attrValType.bitwidth # ")">]>,
descr> {
- let returnType = [{ APInt }];
+ let returnType = [{ ::llvm::APInt }];
}
def UI1Attr : UnsignedIntegerAttrBase<
@@ -943,11 +953,11 @@ def UI64Attr : UnsignedIntegerAttrBase<
// Base class for float attributes of fixed width.
class FloatAttrBase<F attrValType, string descr> :
TypedAttrBase<attrValType, "FloatAttr",
- And<[CPred<"$_self.isa<FloatAttr>()">,
- CPred<"$_self.cast<FloatAttr>().getType().isF" #
+ And<[CPred<"$_self.isa<::mlir::FloatAttr>()">,
+ CPred<"$_self.cast<::mlir::FloatAttr>().getType().isF" #
attrValType.bitwidth # "()">]>,
descr> {
- let returnType = [{ APFloat }];
+ let returnType = [{ ::llvm::APFloat }];
}
def F32Attr : FloatAttrBase<F32, "32-bit float attribute">;
@@ -956,17 +966,18 @@ def F64Attr : FloatAttrBase<F64, "64-bit float attribute">;
// An attribute backed by a string type.
class StringBasedAttr<Pred condition, string descr> : Attr<condition, descr> {
let constBuilderCall = "$_builder.getStringAttr(\"$0\")";
- let storageType = [{ StringAttr }];
- let returnType = [{ StringRef }];
+ let storageType = [{ ::mlir::StringAttr }];
+ let returnType = [{ ::llvm::StringRef }];
let valueType = NoneType;
}
-def StrAttr : StringBasedAttr<CPred<"$_self.isa<StringAttr>()">,
+def StrAttr : StringBasedAttr<CPred<"$_self.isa<::mlir::StringAttr>()">,
"string attribute">;
// String attribute that has a specific value type.
-class TypedStrAttr<Type ty> : StringBasedAttr<CPred<"$_self.isa<StringAttr>()">,
- "string attribute"> {
+class TypedStrAttr<Type ty>
+ : StringBasedAttr<CPred<"$_self.isa<::mlir::StringAttr>()">,
+ "string attribute"> {
let valueType = ty;
}
@@ -975,22 +986,23 @@ class TypedStrAttr<Type ty> : StringBasedAttr<CPred<"$_self.isa<StringAttr>()">,
// defines a type attribute containing an integer type.
class TypeAttrBase<string retType, string description> :
Attr<And<[
- CPred<"$_self.isa<TypeAttr>()">,
- CPred<"$_self.cast<TypeAttr>().getValue().isa<" # retType # ">()">]>,
+ CPred<"$_self.isa<::mlir::TypeAttr>()">,
+ CPred<"$_self.cast<::mlir::TypeAttr>().getValue().isa<"
+ # retType # ">()">]>,
description> {
- let storageType = [{ TypeAttr }];
+ let storageType = [{ ::mlir::TypeAttr }];
let returnType = retType;
let valueType = NoneType;
let convertFromStorage = "$_self.getValue().cast<" # retType # ">()";
}
-def TypeAttr : TypeAttrBase<"Type", "any type attribute">;
+def TypeAttr : TypeAttrBase<"::mlir::Type", "any type attribute">;
// The mere presence of unit attributes has a meaning. Therefore, unit
// attributes are always treated as optional and accessors to them return
// "true" if the attribute is present and "false" otherwise.
-def UnitAttr : Attr<CPred<"$_self.isa<UnitAttr>()">, "unit attribute"> {
- let storageType = [{ UnitAttr }];
+def UnitAttr : Attr<CPred<"$_self.isa<::mlir::UnitAttr>()">, "unit attribute"> {
+ let storageType = [{ ::mlir::UnitAttr }];
let constBuilderCall = "$_builder.getUnitAttr()";
let convertFromStorage = "$_self != nullptr";
let returnType = "bool";
@@ -1019,7 +1031,7 @@ class EnumAttrCaseInfo<string sym, int intVal, string strVal> {
class StrEnumAttrCase<string sym, int val = -1> :
EnumAttrCaseInfo<sym, val, sym>,
StringBasedAttr<
- CPred<"$_self.cast<StringAttr>().getValue() == \"" # sym # "\"">,
+ CPred<"$_self.cast<::mlir::StringAttr>().getValue() == \"" # sym # "\"">,
"case " # sym>;
// An enum attribute case stored with IntegerAttr, which has an integer value,
@@ -1028,7 +1040,7 @@ class IntEnumAttrCaseBase<I intType, string sym, string strVal, int intVal> :
EnumAttrCaseInfo<sym, intVal, strVal>,
SignlessIntegerAttrBase<intType, "case " # strVal> {
let predicate =
- CPred<"$_self.cast<IntegerAttr>().getInt() == " # intVal>;
+ CPred<"$_self.cast<::mlir::IntegerAttr>().getInt() == " # intVal>;
}
// Cases of integer enum attributes with a specific type. By default, the string
@@ -1045,7 +1057,8 @@ class BitEnumAttrCase<string sym, int val> :
EnumAttrCaseInfo<sym, val, sym>,
SignlessIntegerAttrBase<I32, "case " # sym> {
let predicate = CPred<
- "$_self.cast<IntegerAttr>().getValue().getZExtValue() & " # val # "u">;
+ "$_self.cast<::mlir::IntegerAttr>().getValue().getZExtValue() & "
+ # val # "u">;
}
// Additional information for an enum attribute.
@@ -1096,7 +1109,7 @@ class EnumAttrInfo<string name, list<EnumAttrCaseInfo> cases> {
// <return-type> <fn-name>(<qualified-enum-class-name>);
// ```
string symbolToStringFnName = "stringify" # name;
- string symbolToStringFnRetType = "llvm::StringRef";
+ string symbolToStringFnRetType = "::llvm::StringRef";
// The name of the utility function that returns the max enum value used
// within the enum class. It will have the following signature:
@@ -1143,7 +1156,8 @@ class I32EnumAttr<string name, string description,
let returnType = cppNamespace # "::" # name;
let underlyingType = "uint32_t";
let convertFromStorage = "static_cast<" # returnType # ">($_self.getInt())";
- let constBuilderCall = "$_builder.getI32IntegerAttr(static_cast<int32_t>($0))";
+ let constBuilderCall =
+ "$_builder.getI32IntegerAttr(static_cast<int32_t>($0))";
}
class I64EnumAttr<string name, string description,
list<I64EnumAttrCase> cases> :
@@ -1151,7 +1165,8 @@ class I64EnumAttr<string name, string description,
let returnType = cppNamespace # "::" # name;
let underlyingType = "uint64_t";
let convertFromStorage = "static_cast<" # returnType # ">($_self.getInt())";
- let constBuilderCall = "$_builder.getI64IntegerAttr(static_cast<int64_t>($0))";
+ let constBuilderCall =
+ "$_builder.getI64IntegerAttr(static_cast<int64_t>($0))";
}
// A bit enum stored with 32-bit IntegerAttr.
@@ -1166,15 +1181,16 @@ class BitEnumAttr<string name, string description,
let predicate = And<[
I32Attr.predicate,
// Make sure we don't have unknown bit set.
- CPred<"!($_self.cast<IntegerAttr>().getValue().getZExtValue() & (~(" #
- StrJoin<!foreach(case, cases, case.value # "u"), "|">.result #
+ CPred<"!($_self.cast<::mlir::IntegerAttr>().getValue().getZExtValue() & (~("
+ # StrJoin<!foreach(case, cases, case.value # "u"), "|">.result #
")))">
]>;
let returnType = cppNamespace # "::" # name;
let underlyingType = "uint32_t";
let convertFromStorage = "static_cast<" # returnType # ">($_self.getInt())";
- let constBuilderCall = "$_builder.getI32IntegerAttr(static_cast<int32_t>($0))";
+ let constBuilderCall =
+ "$_builder.getI32IntegerAttr(static_cast<int32_t>($0))";
// We need to return a string because we may concatenate symbols for multiple
// bits together.
@@ -1189,44 +1205,45 @@ class BitEnumAttr<string name, string description,
class DictionaryAttrBase<Pred condition, string description> :
Attr<condition, description> {
- let storageType = [{ DictionaryAttr }];
- let returnType = [{ DictionaryAttr }];
+ let storageType = [{ ::mlir::DictionaryAttr }];
+ let returnType = [{ ::mlir::DictionaryAttr }];
let valueType = NoneType;
let convertFromStorage = "$_self";
}
-def DictionaryAttr : DictionaryAttrBase<CPred<"$_self.isa<DictionaryAttr>()">,
- "dictionary of named attribute values">;
+def DictionaryAttr
+ : DictionaryAttrBase<CPred<"$_self.isa<::mlir::DictionaryAttr>()">,
+ "dictionary of named attribute values">;
class ElementsAttrBase<Pred condition, string description> :
Attr<condition, description> {
- let storageType = [{ ElementsAttr }];
- let returnType = [{ ElementsAttr }];
+ let storageType = [{ ::mlir::ElementsAttr }];
+ let returnType = [{ ::mlir::ElementsAttr }];
let convertFromStorage = "$_self";
}
-def ElementsAttr : ElementsAttrBase<CPred<"$_self.isa<ElementsAttr>()">,
+def ElementsAttr : ElementsAttrBase<CPred<"$_self.isa<::mlir::ElementsAttr>()">,
"constant vector/tensor attribute">;
class IntElementsAttrBase<Pred condition, string description> :
- ElementsAttrBase<And<[CPred<"$_self.isa<DenseIntElementsAttr>()">,
+ ElementsAttrBase<And<[CPred<"$_self.isa<::mlir::DenseIntElementsAttr>()">,
condition]>,
description> {
- let storageType = [{ DenseIntElementsAttr }];
- let returnType = [{ DenseIntElementsAttr }];
+ let storageType = [{ ::mlir::DenseIntElementsAttr }];
+ let returnType = [{ ::mlir::DenseIntElementsAttr }];
let convertFromStorage = "$_self";
}
def IndexElementsAttr
- : IntElementsAttrBase<CPred<[{$_self.cast<DenseIntElementsAttr>()
+ : IntElementsAttrBase<CPred<[{$_self.cast<::mlir::DenseIntElementsAttr>()
.getType()
.getElementType()
.isIndex()}]>,
"index elements attribute">;
class AnyIntElementsAttr<int width> : IntElementsAttrBase<
- CPred<"$_self.cast<DenseIntElementsAttr>().getType()."
+ CPred<"$_self.cast<::mlir::DenseIntElementsAttr>().getType()."
"getElementType().isInteger(" # width # ")">,
width # "-bit integer elements attribute">;
@@ -1234,14 +1251,15 @@ def AnyI32ElementsAttr : AnyIntElementsAttr<32>;
def AnyI64ElementsAttr : AnyIntElementsAttr<64>;
class SignlessIntElementsAttr<int width> : IntElementsAttrBase<
- CPred<"$_self.cast<DenseIntElementsAttr>().getType()."
+ CPred<"$_self.cast<::mlir::DenseIntElementsAttr>().getType()."
"getElementType().isSignlessInteger(" # width # ")">,
width # "-bit signless integer elements attribute"> {
// Note that this is only constructing scalar elements attribute.
- let constBuilderCall = "DenseElementsAttr::get("
- "RankedTensorType::get({}, $_builder.getIntegerType(" # width # ")), "
- "llvm::makeArrayRef($0)).cast<DenseIntElementsAttr>()";
+ let constBuilderCall = "::mlir::DenseElementsAttr::get("
+ "::mlir::RankedTensorType::get({}, "
+ "$_builder.getIntegerType(" # width # ")), "
+ "::llvm::makeArrayRef($0)).cast<::mlir::DenseIntElementsAttr>()";
}
def I32ElementsAttr : SignlessIntElementsAttr<32>;
@@ -1254,15 +1272,15 @@ class RankedSignlessIntElementsAttr<int width, list<int> dims> :
// Check that this has the specified shape.
let predicate = And<[
SignlessIntElementsAttr<width>.predicate,
- CPred<"$_self.cast<DenseIntElementsAttr>().getType().getShape() == "
- "ArrayRef<int64_t>({" # StrJoinInt<dims>.result # "})">]>;
+ CPred<"$_self.cast<::mlir::DenseIntElementsAttr>().getType().getShape() == "
+ "::mlir::ArrayRef<int64_t>({" # StrJoinInt<dims>.result # "})">]>;
let description = width # "-bit signless int elements attribute of shape [" #
StrJoinInt<dims>.result # "]";
- let constBuilderCall = "DenseIntElementsAttr::get("
- "RankedTensorType::get({" # StrJoinInt<dims>.result #
- "}, $_builder.getIntegerType(" # width # ")), makeArrayRef($0))";
+ let constBuilderCall = "::mlir::DenseIntElementsAttr::get("
+ "::mlir::RankedTensorType::get({" # StrJoinInt<dims>.result #
+ "}, $_builder.getIntegerType(" # width # ")), ::llvm::makeArrayRef($0))";
}
class RankedI32ElementsAttr<list<int> dims> :
@@ -1271,18 +1289,18 @@ class RankedI64ElementsAttr<list<int> dims> :
RankedSignlessIntElementsAttr<64, dims>;
class FloatElementsAttr<int width> : ElementsAttrBase<
- CPred<"$_self.isa<DenseFPElementsAttr>() &&"
- "$_self.cast<DenseElementsAttr>().getType()."
+ CPred<"$_self.isa<::mlir::DenseFPElementsAttr>() &&"
+ "$_self.cast<::mlir::DenseElementsAttr>().getType()."
"getElementType().isF" # width # "()">,
width # "-bit float elements attribute"> {
- let storageType = [{ DenseElementsAttr }];
- let returnType = [{ DenseElementsAttr }];
+ let storageType = [{ ::mlir::DenseElementsAttr }];
+ let returnType = [{ ::mlir::DenseElementsAttr }];
// Note that this is only constructing scalar elements attribute.
- let constBuilderCall = "DenseElementsAttr::get("
- "RankedTensorType::get({}, $_builder.getF" # width # "Type()),"
- "llvm::makeArrayRef($0))";
+ let constBuilderCall = "::mlir::DenseElementsAttr::get("
+ "::mlir::RankedTensorType::get({}, $_builder.getF" # width # "Type()),"
+ "::llvm::makeArrayRef($0))";
let convertFromStorage = "$_self";
}
@@ -1291,23 +1309,23 @@ def F64ElementsAttr : FloatElementsAttr<64>;
// A `width`-bit floating point elements attribute. The attribute should be
// ranked and has a shape as specified in `dims`.
class RankedFloatElementsAttr<int width, list<int> dims> : ElementsAttrBase<
- CPred<"$_self.isa<DenseFPElementsAttr>() &&"
- "$_self.cast<DenseFPElementsAttr>().getType()."
+ CPred<"$_self.isa<::mlir::DenseFPElementsAttr>() &&"
+ "$_self.cast<::mlir::DenseFPElementsAttr>().getType()."
"getElementType().isF" # width # "() && "
// Check that this is ranked and has the specified shape.
- "$_self.cast<DenseFPElementsAttr>().getType().hasRank() && "
- "$_self.cast<DenseFPElementsAttr>().getType().getShape() == "
- "llvm::ArrayRef<int64_t>({" # StrJoinInt<dims>.result # "})">,
+ "$_self.cast<::mlir::DenseFPElementsAttr>().getType().hasRank() && "
+ "$_self.cast<::mlir::DenseFPElementsAttr>().getType().getShape() == "
+ "::mlir::ArrayRef<int64_t>({" # StrJoinInt<dims>.result # "})">,
width # "-bit float elements attribute of shape [" #
StrJoinInt<dims>.result # "]"> {
- let storageType = [{ DenseFPElementsAttr }];
- let returnType = [{ DenseFPElementsAttr }];
+ let storageType = [{ ::mlir::DenseFPElementsAttr }];
+ let returnType = [{ ::mlir::DenseFPElementsAttr }];
- let constBuilderCall = "DenseElementsAttr::get("
- "RankedTensorType::get({" # StrJoinInt<dims>.result #
+ let constBuilderCall = "::mlir::DenseElementsAttr::get("
+ "::mlir::RankedTensorType::get({" # StrJoinInt<dims>.result #
"}, $_builder.getF" # width # "Type()), "
- "llvm::makeArrayRef($0)).cast<DenseFPElementsAttr>()";
+ "::llvm::makeArrayRef($0)).cast<::mlir::DenseFPElementsAttr>()";
let convertFromStorage = "$_self";
}
@@ -1315,11 +1333,11 @@ class RankedF32ElementsAttr<list<int> dims> : RankedFloatElementsAttr<32, dims>;
class RankedF64ElementsAttr<list<int> dims> : RankedFloatElementsAttr<64, dims>;
def StringElementsAttr : ElementsAttrBase<
- CPred<"$_self.isa<DenseStringElementsAttr>()" >,
+ CPred<"$_self.isa<::mlir::DenseStringElementsAttr>()" >,
"string elements attribute"> {
- let storageType = [{ DenseElementsAttr }];
- let returnType = [{ DenseElementsAttr }];
+ let storageType = [{ ::mlir::DenseElementsAttr }];
+ let returnType = [{ ::mlir::DenseElementsAttr }];
let convertFromStorage = "$_self";
}
@@ -1327,13 +1345,13 @@ def StringElementsAttr : ElementsAttrBase<
// Base class for array attributes.
class ArrayAttrBase<Pred condition, string description> :
Attr<condition, description> {
- let storageType = [{ ArrayAttr }];
- let returnType = [{ ArrayAttr }];
+ let storageType = [{ ::mlir::ArrayAttr }];
+ let returnType = [{ ::mlir::ArrayAttr }];
let valueType = NoneType;
let convertFromStorage = "$_self";
}
-def ArrayAttr : ArrayAttrBase<CPred<"$_self.isa<ArrayAttr>()">,
+def ArrayAttr : ArrayAttrBase<CPred<"$_self.isa<::mlir::ArrayAttr>()">,
"array attribute">;
// Base class for array attributes whose elements are of the same kind.
@@ -1341,12 +1359,12 @@ def ArrayAttr : ArrayAttrBase<CPred<"$_self.isa<ArrayAttr>()">,
class TypedArrayAttrBase<Attr element, string description>: ArrayAttrBase<
And<[
// Guarantee this is an ArrayAttr first
- CPred<"$_self.isa<ArrayAttr>()">,
+ CPred<"$_self.isa<::mlir::ArrayAttr>()">,
// Guarantee all elements satisfy the constraints from `element`
- Concat<"llvm::all_of($_self.cast<ArrayAttr>(), "
- "[](Attribute attr) { return ",
- SubstLeaves<"$_self", "attr", element.predicate>,
- "; })">]>,
+ Concat<"::llvm::all_of($_self.cast<::mlir::ArrayAttr>(), "
+ "[](::mlir::Attribute attr) { return ",
+ SubstLeaves<"$_self", "attr", element.predicate>,
+ "; })">]>,
description> {
let constBuilderCall = "$_builder.getArrayAttr($0)";
@@ -1413,18 +1431,18 @@ class StructAttr<string name, Dialect dialect,
}
// Attributes containing symbol references.
-def SymbolRefAttr : Attr<CPred<"$_self.isa<SymbolRefAttr>()">,
+def SymbolRefAttr : Attr<CPred<"$_self.isa<::mlir::SymbolRefAttr>()">,
"symbol reference attribute"> {
- let storageType = [{ SymbolRefAttr }];
- let returnType = [{ SymbolRefAttr }];
+ let storageType = [{ ::mlir::SymbolRefAttr }];
+ let returnType = [{ ::mlir::SymbolRefAttr }];
let valueType = NoneType;
let constBuilderCall = "$_builder.getSymbolRefAttr($0)";
let convertFromStorage = "$_self";
}
-def FlatSymbolRefAttr : Attr<CPred<"$_self.isa<FlatSymbolRefAttr>()">,
+def FlatSymbolRefAttr : Attr<CPred<"$_self.isa<::mlir::FlatSymbolRefAttr>()">,
"flat symbol reference attribute"> {
- let storageType = [{ FlatSymbolRefAttr }];
- let returnType = [{ StringRef }];
+ let storageType = [{ ::mlir::FlatSymbolRefAttr }];
+ let returnType = [{ ::llvm::StringRef }];
let valueType = NoneType;
let constBuilderCall = "$_builder.getSymbolRefAttr($0)";
let convertFromStorage = "$_self.getValue()";
@@ -1465,7 +1483,7 @@ class DerivedAttr<code ret, code b, code convert = ""> :
// Derived attribute that returns a mlir::Type.
class DerivedTypeAttr<code body> : DerivedAttr<"Type", body> {
- let convertFromStorage = "TypeAttr::get($_self)";
+ let convertFromStorage = "::mlir::TypeAttr::get($_self)";
}
//===----------------------------------------------------------------------===//
@@ -1522,15 +1540,15 @@ class AllAttrConstraintsOf<list<AttrConstraint> constraints> : AttrConstraint<
}
class IntMinValue<int n> : AttrConstraint<
- CPred<"$_self.cast<IntegerAttr>().getInt() >= " # n>,
+ CPred<"$_self.cast<::mlir::IntegerAttr>().getInt() >= " # n>,
"whose minimum value is " # n>;
class IntMaxValue<int n> : AttrConstraint<
- CPred<"$_self.cast<IntegerAttr>().getInt() <= " # n>,
+ CPred<"$_self.cast<::mlir::IntegerAttr>().getInt() <= " # n>,
"whose maximum value is " # n>;
def IntNonNegative : AttrConstraint<
- CPred<"!$_self.cast<IntegerAttr>().getValue().isNegative()">,
+ CPred<"!$_self.cast<::mlir::IntegerAttr>().getValue().isNegative()">,
"whose value is non-negative">;
def IntPositive : AttrConstraint<
@@ -1538,26 +1556,26 @@ def IntPositive : AttrConstraint<
"whose value is positive">;
class ArrayMinCount<int n> : AttrConstraint<
- CPred<"$_self.cast<ArrayAttr>().size() >= " # n>,
+ CPred<"$_self.cast<::mlir::ArrayAttr>().size() >= " # n>,
"with at least " # n # " elements">;
class ArrayCount<int n> : AttrConstraint<
- CPred<"$_self.cast<ArrayAttr>().size() == " #n>,
+ CPred<"$_self.cast<::mlir::ArrayAttr>().size() == " #n>,
"with exactly " # n # " elements">;
class IntArrayNthElemEq<int index, int value> : AttrConstraint<
And<[
- CPred<"$_self.cast<ArrayAttr>().size() > " # index>,
- CPred<"$_self.cast<ArrayAttr>()[" # index # "]"
- ".cast<IntegerAttr>().getInt() == " # value>
+ CPred<"$_self.cast<::mlir::ArrayAttr>().size() > " # index>,
+ CPred<"$_self.cast<::mlir::ArrayAttr>()[" # index # "]"
+ ".cast<::mlir::IntegerAttr>().getInt() == " # value>
]>,
"whose " # index # "-th element must be " # value>;
class IntArrayNthElemMinValue<int index, int min> : AttrConstraint<
And<[
- CPred<"$_self.cast<ArrayAttr>().size() > " # index>,
- CPred<"$_self.cast<ArrayAttr>()[" # index # "]"
- ".cast<IntegerAttr>().getInt() >= " # min>
+ CPred<"$_self.cast<::mlir::ArrayAttr>().size() > " # index>,
+ CPred<"$_self.cast<::mlir::ArrayAttr>()[" # index # "]"
+ ".cast<::mlir::IntegerAttr>().getInt() >= " # min>
]>,
"whose " # index # "-th element must be at least " # min>;
@@ -1571,7 +1589,7 @@ def IsNullAttr : AttrConstraint<
class ReferToOp<string opClass> : AttrConstraint<
CPred<"isa_and_nonnull<" # opClass # ">("
"::mlir::SymbolTable::lookupNearestSymbolFrom("
- "&$_op, $_self.cast<FlatSymbolRefAttr>().getValue()))">,
+ "&$_op, $_self.cast<::mlir::FlatSymbolRefAttr>().getValue()))">,
"referencing to a '" # opClass # "' symbol">;
//===----------------------------------------------------------------------===//
@@ -1586,7 +1604,7 @@ def AnyRegion : Region<CPred<"true">, "any region">;
// A region with the given number of blocks.
class SizedRegion<int numBlocks> : Region<
- CPred<"llvm::hasNItems($_self, " # numBlocks # ")">,
+ CPred<"::llvm::hasNItems($_self, " # numBlocks # ")">,
"region with " # numBlocks # " blocks">;
// A variadic region constraint. It expands to zero or more of the base region.
@@ -1729,7 +1747,8 @@ def ins;
// OpInterfaceTrait corresponds to a specific 'OpInterface' class defined in
// C++. The purpose to wrap around C++ symbol string with this class is to make
// interfaces specified for ops in TableGen less alien and more integrated.
-class OpInterfaceTrait<string name, code verifyBody = [{}]> : NativeOpTrait<""> {
+class OpInterfaceTrait<string name, code verifyBody = [{}]>
+ : NativeOpTrait<""> {
let trait = name # "::Trait";
// Specify the body of the verification function. `$_op` will be replaced with
@@ -1988,18 +2007,20 @@ def HasNoUseOf: Constraint<
// TODO(b/135033717): Improve the autogenerated error messages.
class Rank<string name> :
- StrFunc<"$" # name # ".getType().cast<ShapedType>().getRank()">;
+ StrFunc<"$" # name # ".getType().cast<::mlir::ShapedType>().getRank()">;
class Shape<string name> :
- StrFunc<"$" # name # ".getType().cast<ShapedType>().getShape()">;
+ StrFunc<"$" # name # ".getType().cast<::mlir::ShapedType>().getShape()">;
class ElementCount<string name> :
- StrFunc<"$" # name # ".getType().cast<ShapedType>().getNumElements()">;
+ StrFunc<"$" # name # ".getType().cast<::mlir::ShapedType>()"
+ ".getNumElements()">;
class ElementType<string name> : StrFunc<"getElementTypeOrSelf($" # name # ")">;
class AllMatchPred<list<string> values> :
- CPred<"llvm::is_splat(llvm::makeArrayRef({"# StrJoin<values>.result #"}))">;
+ CPred<"::llvm::is_splat(::llvm::makeArrayRef({"
+ # StrJoin<values>.result #"}))">;
class AllMatch<list<string> values, string description> :
PredOpTrait<description, AllMatchPred<values>>;
@@ -2078,8 +2099,8 @@ class TCopVTEtIsSameAs<int i, int j> : And<[
IsShapedTypePred>,
SubstLeaves<"$_self", "$_op.getOperand(" # j # ").getType()",
IsShapedTypePred>,
- CPred<"mlir::getElementTypeOrSelf($_op.getOperand(" # i # ")) == "
- "mlir::getElementTypeOrSelf($_op.getOperand(" # j # "))">]>;
+ CPred<"::mlir::getElementTypeOrSelf($_op.getOperand(" # i # ")) == "
+ "::mlir::getElementTypeOrSelf($_op.getOperand(" # j # "))">]>;
// Predicate to verify that the i'th result and the j'th operand exist and has
// shaped types.
@@ -2115,9 +2136,9 @@ class TCresVTEtIsSameAsOp<int i, int j> : And<[
// of the resId'th result.
class TCOpIsBroadcastableToRes<int opId, int resId> : And<[
TCOpResIsShapedTypePred<opId, resId>,
- CPred<"OpTrait::util::getBroadcastedType("
- "$_op.getOperand(" # opId # ").getType(), "
- "$_op.getResult(" # resId # ").getType())">]>;
+ CPred<"::mlir::OpTrait::util::getBroadcastedType("
+ "$_op.getOperand(" # opId # ").getType(), "
+ "$_op.getResult(" # resId # ").getType())">]>;
// Predicate to verify that all the operands at the given `indices`
// have the same element type.
@@ -2127,10 +2148,10 @@ class TCOpIsBroadcastableToRes<int opId, int resId> : And<[
// 1) all operands involved are of shaped type and
// 2) the indices are not out of range.
class TCopVTEtAreSameAt<list<int> indices> : CPred<
- "llvm::is_splat(llvm::map_range("
- "llvm::ArrayRef<unsigned>({" # StrJoinInt<indices>.result # "}), "
- "[this](unsigned i) { return getElementTypeOrSelf(this->getOperand(i)); "
- "}))">;
+ "::llvm::is_splat(::llvm::map_range("
+ "::mlir::ArrayRef<unsigned>({" # StrJoinInt<indices>.result # "}), "
+ "[this](unsigned i) { return getElementTypeOrSelf(this->getOperand(i)); "
+ "}))">;
//===----------------------------------------------------------------------===//
// Pattern definitions
diff --git a/mlir/lib/TableGen/OpClass.cpp b/mlir/lib/TableGen/OpClass.cpp
index 9e6c9138a675..2b9da7355929 100644
--- a/mlir/lib/TableGen/OpClass.cpp
+++ b/mlir/lib/TableGen/OpClass.cpp
@@ -222,7 +222,7 @@ void tblgen::OpClass::addTrait(Twine trait) {
}
void tblgen::OpClass::writeDeclTo(raw_ostream &os) const {
- os << "class " << className << " : public Op<" << className;
+ os << "class " << className << " : public ::mlir::Op<" << className;
for (const auto &trait : traitsVec)
os << ", " << trait;
os << "> {\npublic:\n";
diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td
index 766c11e4692c..0868e834bca4 100644
--- a/mlir/test/mlir-tblgen/op-attribute.td
+++ b/mlir/test/mlir-tblgen/op-attribute.td
@@ -33,7 +33,7 @@ def AOp : NS_Op<"a_op", []> {
// Test verify method
// ---
-// DEF: LogicalResult AOpAdaptor::verify
+// DEF: ::mlir::LogicalResult AOpAdaptor::verify
// DEF: auto tblgen_aAttr = odsAttrs.get("aAttr");
// DEF-NEXT: if (!tblgen_aAttr) return emitError(loc, "'test.a_op' op ""requires attribute 'aAttr'");
// DEF: if (!((some-condition))) return emitError(loc, "'test.a_op' op ""attribute 'aAttr' failed to satisfy constraint: some attribute kind");
@@ -58,14 +58,14 @@ def AOp : NS_Op<"a_op", []> {
// DEF: some-return-type AOp::bAttr() {
// DEF-NEXT: auto attr = bAttrAttr();
// DEF-NEXT: if (!attr)
-// DEF-NEXT: return some-const-builder-call(mlir::Builder(this->getContext()), 4.2).some-convert-from-storage();
+// DEF-NEXT: return some-const-builder-call(::mlir::Builder(this->getContext()), 4.2).some-convert-from-storage();
// DEF-NEXT: return attr.some-convert-from-storage();
// DEF: some-attr-kind AOp::cAttrAttr()
// DEF-NEXT: return this->getAttr("cAttr").dyn_cast_or_null<some-attr-kind>()
-// DEF: Optional<some-return-type> AOp::cAttr() {
+// DEF: ::llvm::Optional<some-return-type> AOp::cAttr() {
// DEF-NEXT: auto attr = cAttrAttr()
-// DEF-NEXT: return attr ? Optional<some-return-type>(attr.some-convert-from-storage()) : (llvm::None);
+// DEF-NEXT: return attr ? ::llvm::Optional<some-return-type>(attr.some-convert-from-storage()) : (::llvm::None);
// Test setter methods
// ---
@@ -91,7 +91,7 @@ def AOp : NS_Op<"a_op", []> {
// DEF: odsState.addAttribute("aAttr", some-const-builder-call(odsBuilder, aAttr));
// DEF: void AOp::build(
-// DEF: ArrayRef<NamedAttribute> attributes
+// DEF: ::llvm::ArrayRef<::mlir::NamedAttribute> attributes
// DEF: odsState.addAttributes(attributes);
def SomeTypeAttr : TypeAttrBase<"SomeType", "some type attribute">;
@@ -120,35 +120,35 @@ def BOp : NS_Op<"b_op", []> {
// DEF-LABEL: BOpAdaptor::verify
// DEF: if (!((true)))
-// DEF: if (!((tblgen_bool_attr.isa<BoolAttr>())))
-// DEF: if (!(((tblgen_i32_attr.isa<IntegerAttr>())) && ((tblgen_i32_attr.cast<IntegerAttr>().getType().isSignlessInteger(32)))))
-// DEF: if (!(((tblgen_i64_attr.isa<IntegerAttr>())) && ((tblgen_i64_attr.cast<IntegerAttr>().getType().isSignlessInteger(64)))))
-// DEF: if (!(((tblgen_f32_attr.isa<FloatAttr>())) && ((tblgen_f32_attr.cast<FloatAttr>().getType().isF32()))))
-// DEF: if (!(((tblgen_f64_attr.isa<FloatAttr>())) && ((tblgen_f64_attr.cast<FloatAttr>().getType().isF64()))))
-// DEF: if (!((tblgen_str_attr.isa<StringAttr>())))
-// DEF: if (!((tblgen_elements_attr.isa<ElementsAttr>())))
-// DEF: if (!((tblgen_function_attr.isa<FlatSymbolRefAttr>())))
-// DEF: if (!(((tblgen_type_attr.isa<TypeAttr>())) && ((tblgen_type_attr.cast<TypeAttr>().getValue().isa<SomeType>()))))
-// DEF: if (!((tblgen_array_attr.isa<ArrayAttr>())))
-// DEF: if (!(((tblgen_some_attr_array.isa<ArrayAttr>())) && (llvm::all_of(tblgen_some_attr_array.cast<ArrayAttr>(), [](Attribute attr) { return (some-condition); }))))
-// DEF: if (!(((tblgen_type_attr.isa<TypeAttr>())) && ((tblgen_type_attr.cast<TypeAttr>().getValue().isa<Type>()))))
+// DEF: if (!((tblgen_bool_attr.isa<::mlir::BoolAttr>())))
+// DEF: if (!(((tblgen_i32_attr.isa<::mlir::IntegerAttr>())) && ((tblgen_i32_attr.cast<::mlir::IntegerAttr>().getType().isSignlessInteger(32)))))
+// DEF: if (!(((tblgen_i64_attr.isa<::mlir::IntegerAttr>())) && ((tblgen_i64_attr.cast<::mlir::IntegerAttr>().getType().isSignlessInteger(64)))))
+// DEF: if (!(((tblgen_f32_attr.isa<::mlir::FloatAttr>())) && ((tblgen_f32_attr.cast<::mlir::FloatAttr>().getType().isF32()))))
+// DEF: if (!(((tblgen_f64_attr.isa<::mlir::FloatAttr>())) && ((tblgen_f64_attr.cast<::mlir::FloatAttr>().getType().isF64()))))
+// DEF: if (!((tblgen_str_attr.isa<::mlir::StringAttr>())))
+// DEF: if (!((tblgen_elements_attr.isa<::mlir::ElementsAttr>())))
+// DEF: if (!((tblgen_function_attr.isa<::mlir::FlatSymbolRefAttr>())))
+// DEF: if (!(((tblgen_type_attr.isa<::mlir::TypeAttr>())) && ((tblgen_type_attr.cast<::mlir::TypeAttr>().getValue().isa<SomeType>()))))
+// DEF: if (!((tblgen_array_attr.isa<::mlir::ArrayAttr>())))
+// DEF: if (!(((tblgen_some_attr_array.isa<::mlir::ArrayAttr>())) && (::llvm::all_of(tblgen_some_attr_array.cast<::mlir::ArrayAttr>(), [](::mlir::Attribute attr) { return (some-condition); }))))
+// DEF: if (!(((tblgen_type_attr.isa<::mlir::TypeAttr>())) && ((tblgen_type_attr.cast<::mlir::TypeAttr>().getValue().isa<::mlir::Type>()))))
// Test common attribute kind getters' return types
// ---
-// DEF: Attribute BOp::any_attr()
+// DEF: ::mlir::Attribute BOp::any_attr()
// DEF: bool BOp::bool_attr()
-// DEF: APInt BOp::i32_attr()
-// DEF: APInt BOp::i64_attr()
-// DEF: APFloat BOp::f32_attr()
-// DEF: APFloat BOp::f64_attr()
-// DEF: StringRef BOp::str_attr()
-// DEF: ElementsAttr BOp::elements_attr()
-// DEF: StringRef BOp::function_attr()
+// DEF: ::llvm::APInt BOp::i32_attr()
+// DEF: ::llvm::APInt BOp::i64_attr()
+// DEF: ::llvm::APFloat BOp::f32_attr()
+// DEF: ::llvm::APFloat BOp::f64_attr()
+// DEF: ::llvm::StringRef BOp::str_attr()
+// DEF: ::mlir::ElementsAttr BOp::elements_attr()
+// DEF: ::llvm::StringRef BOp::function_attr()
// DEF: SomeType BOp::type_attr()
-// DEF: ArrayAttr BOp::array_attr()
-// DEF: ArrayAttr BOp::some_attr_array()
-// DEF: Type BOp::type_attr()
+// DEF: ::mlir::ArrayAttr BOp::array_attr()
+// DEF: ::mlir::ArrayAttr BOp::some_attr_array()
+// DEF: ::mlir::Type BOp::type_attr()
// Test building constant values for array attribute kinds
// ---
@@ -164,11 +164,11 @@ def COp : NS_Op<"c_op", []> {
}
// DEF-LABEL: COp definitions
-// DEF: mlir::Builder(this->getContext()).getI32ArrayAttr({1, 2})
-// DEF: mlir::Builder(this->getContext()).getI64ArrayAttr({3, 4})
-// DEF: mlir::Builder(this->getContext()).getF32ArrayAttr({5.f, 6.f})
-// DEF: mlir::Builder(this->getContext()).getF64ArrayAttr({7., 8.})
-// DEF: mlir::Builder(this->getContext()).getStrArrayAttr({"a", "b"})
+// DEF: ::mlir::Builder(this->getContext()).getI32ArrayAttr({1, 2})
+// DEF: ::mlir::Builder(this->getContext()).getI64ArrayAttr({3, 4})
+// DEF: ::mlir::Builder(this->getContext()).getF32ArrayAttr({5.f, 6.f})
+// DEF: ::mlir::Builder(this->getContext()).getF64ArrayAttr({7., 8.})
+// DEF: ::mlir::Builder(this->getContext()).getStrArrayAttr({"a", "b"})
// Test builder method which takes unwrapped values for attributes
@@ -196,7 +196,7 @@ def DOp : NS_Op<"d_op", []> {
}
// DECL-LABEL: DOp declarations
-// DECL: static void build({{.*}}, APInt i32_attr, APFloat f64_attr, StringRef str_attr, bool bool_attr, ::SomeI32Enum enum_attr, APInt dv_i32_attr, APFloat dv_f64_attr, StringRef dv_str_attr = "abc", bool dv_bool_attr = true, ::SomeI32Enum dv_enum_attr = ::SomeI32Enum::case5)
+// DECL: static void build({{.*}}, ::llvm::APInt i32_attr, ::llvm::APFloat f64_attr, ::llvm::StringRef str_attr, bool bool_attr, ::SomeI32Enum enum_attr, ::llvm::APInt dv_i32_attr, ::llvm::APFloat dv_f64_attr, ::llvm::StringRef dv_str_attr = "abc", bool dv_bool_attr = true, ::SomeI32Enum dv_enum_attr = ::SomeI32Enum::case5)
// DEF-LABEL: DOp definitions
// DEF: odsState.addAttribute("str_attr", odsBuilder.getStringAttr(str_attr));
@@ -209,10 +209,10 @@ def DerivedTypeAttrOp : NS_Op<"derived_type_attr_op", []> {
DerivedTypeAttr element_dtype = DerivedTypeAttr<"return output().getType();">;
}
-// DECL: class DerivedTypeAttrOp : public Op
+// DECL: class DerivedTypeAttrOp : public ::mlir::Op
// DECL-SAME: DerivedAttributeOpInterface::Trait
// DECL: static bool isDerivedAttribute
-// DEF: bool DerivedTypeAttrOp::isDerivedAttribute(StringRef name) {
+// DEF: bool DerivedTypeAttrOp::isDerivedAttribute(::llvm::StringRef name) {
// DEF: if (name == "element_dtype") return true;
// DEF: return false;
// DEF: }
@@ -238,7 +238,7 @@ def EOp : NS_Op<"e_op", []> {
}
// DECL-LABEL: EOp declarations
-// DECL: static void build({{.*}}, APInt i32_attr, APInt dv_i32_attr, APFloat f64_attr, APFloat dv_f64_attr, StringRef str_attr, StringRef dv_str_attr, bool bool_attr, bool dv_bool_attr, ::SomeI32Enum enum_attr, ::SomeI32Enum dv_enum_attr = ::SomeI32Enum::case5)
+// DECL: static void build({{.*}}, ::llvm::APInt i32_attr, ::llvm::APInt dv_i32_attr, ::llvm::APFloat f64_attr, ::llvm::APFloat dv_f64_attr, ::llvm::StringRef str_attr, ::llvm::StringRef dv_str_attr, bool bool_attr, bool dv_bool_attr, ::SomeI32Enum enum_attr, ::SomeI32Enum dv_enum_attr = ::SomeI32Enum::case5)
// Test mixing operands and attributes in arbitrary order
// ---
@@ -248,11 +248,11 @@ def MixOperandsAndAttrs : NS_Op<"mix_operands_and_attrs", []> {
}
// DEF-LABEL: MixOperandsAndAttrs definitions
-// DEF-DAG: Value MixOperandsAndAttrs::operand()
-// DEF-DAG: Value MixOperandsAndAttrs::otherArg()
-// DEF-DAG: void MixOperandsAndAttrs::build(OpBuilder &odsBuilder, OperationState &odsState, FloatAttr attr, Value operand, FloatAttr otherAttr, Value otherArg)
-// DEF-DAG: APFloat MixOperandsAndAttrs::attr()
-// DEF-DAG: APFloat MixOperandsAndAttrs::otherAttr()
+// DEF-DAG: ::mlir::Value MixOperandsAndAttrs::operand()
+// DEF-DAG: ::mlir::Value MixOperandsAndAttrs::otherArg()
+// DEF-DAG: void MixOperandsAndAttrs::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::FloatAttr attr, ::mlir::Value operand, ::mlir::FloatAttr otherAttr, ::mlir::Value otherArg)
+// DEF-DAG: ::llvm::APFloat MixOperandsAndAttrs::attr()
+// DEF-DAG: ::llvm::APFloat MixOperandsAndAttrs::otherAttr()
// Test unit attributes.
// ---
@@ -265,7 +265,7 @@ def UnitAttrOp : NS_Op<"unit_attr_op", []> {
// DEF: bool UnitAttrOp::attr() {
// DEF: return {{.*}} != nullptr
-// DEF: build(OpBuilder &odsBuilder, OperationState &odsState, /*optional*/UnitAttr attr)
+// DEF: build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::UnitAttr attr)
// Test elementAttr field of TypedArrayAttr.
diff --git a/mlir/test/mlir-tblgen/op-decl.td b/mlir/test/mlir-tblgen/op-decl.td
index 8d58d5bb7395..728c38f1d024 100644
--- a/mlir/test/mlir-tblgen/op-decl.td
+++ b/mlir/test/mlir-tblgen/op-decl.td
@@ -50,44 +50,44 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> {
// CHECK: class AOpAdaptor {
// CHECK: public:
-// CHECK: AOpAdaptor(ValueRange values
-// CHECK: ValueRange getODSOperands(unsigned index);
-// CHECK: Value a();
-// CHECK: ValueRange b();
-// CHECK: IntegerAttr attr1();
-// CHECL: FloatAttr attr2();
+// CHECK: AOpAdaptor(::mlir::ValueRange values
+// CHECK: ::mlir::ValueRange getODSOperands(unsigned index);
+// CHECK: ::mlir::Value a();
+// CHECK: ::mlir::ValueRange b();
+// CHECK: ::mlir::IntegerAttr attr1();
+// CHECL: ::mlir::FloatAttr attr2();
// CHECK: private:
-// CHECK: ValueRange odsOperands;
+// CHECK: ::mlir::ValueRange odsOperands;
// CHECK: };
-// CHECK: class AOp : public Op<AOp, OpTrait::AtLeastNRegions<1>::Impl, OpTrait::AtLeastNResults<1>::Impl, OpTrait::ZeroSuccessor, OpTrait::AtLeastNOperands<1>::Impl, OpTrait::IsIsolatedFromAbove
+// CHECK: class AOp : public ::mlir::Op<AOp, OpTrait::AtLeastNRegions<1>::Impl, OpTrait::AtLeastNResults<1>::Impl, OpTrait::ZeroSuccessor, OpTrait::AtLeastNOperands<1>::Impl, OpTrait::IsIsolatedFromAbove
// CHECK-NOT: OpTrait::IsIsolatedFromAbove
// CHECK: public:
// CHECK: using Op::Op;
// CHECK: using Adaptor = AOpAdaptor;
-// CHECK: static StringRef getOperationName();
-// CHECK: Operation::operand_range getODSOperands(unsigned index);
-// CHECK: Value a();
-// CHECK: Operation::operand_range b();
+// CHECK: static ::llvm::StringRef getOperationName();
+// CHECK: ::mlir::Operation::operand_range getODSOperands(unsigned index);
+// CHECK: ::mlir::Value a();
+// CHECK: ::mlir::Operation::operand_range b();
// CHECK: ::mlir::MutableOperandRange aMutable();
// CHECK: ::mlir::MutableOperandRange bMutable();
-// CHECK: Operation::result_range getODSResults(unsigned index);
-// CHECK: Value r();
-// CHECK: Region &someRegion();
-// CHECK: MutableArrayRef<Region> someRegions();
-// CHECK: IntegerAttr attr1Attr()
-// CHECK: APInt attr1();
-// CHECK: FloatAttr attr2Attr()
-// CHECK: Optional< APFloat > attr2();
+// CHECK: ::mlir::Operation::result_range getODSResults(unsigned index);
+// CHECK: ::mlir::Value r();
+// CHECK: ::mlir::Region &someRegion();
+// CHECK: ::mlir::MutableArrayRef<Region> someRegions();
+// CHECK: ::mlir::IntegerAttr attr1Attr()
+// CHECK: ::llvm::APInt attr1();
+// CHECK: ::mlir::FloatAttr attr2Attr()
+// CHECK: ::llvm::Optional< ::llvm::APFloat > attr2();
// CHECK: static void build(Value val);
-// CHECK: static void build(OpBuilder &odsBuilder, OperationState &odsState, Type r, ArrayRef<Type> s, Value a, ValueRange b, IntegerAttr attr1, /*optional*/FloatAttr attr2, unsigned someRegionsCount)
-// CHECK: static void build(OpBuilder &odsBuilder, OperationState &odsState, Type r, ArrayRef<Type> s, Value a, ValueRange b, APInt attr1, /*optional*/FloatAttr attr2, unsigned someRegionsCount)
-// CHECK: static void build(OpBuilder &, OperationState &odsState, ArrayRef<Type> resultTypes, ValueRange operands, ArrayRef<NamedAttribute> attributes, unsigned numRegions)
-// CHECK: static ParseResult parse(OpAsmParser &parser, OperationState &result);
-// CHECK: void print(OpAsmPrinter &p);
-// CHECK: LogicalResult verify();
-// CHECK: static void getCanonicalizationPatterns(OwningRewritePatternList &results, MLIRContext *context);
-// CHECK: LogicalResult fold(ArrayRef<Attribute> operands, SmallVectorImpl<OpFoldResult> &results);
+// CHECK: static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type r, ::llvm::ArrayRef<::mlir::Type> s, ::mlir::Value a, ::mlir::ValueRange b, ::mlir::IntegerAttr attr1, /*optional*/::mlir::FloatAttr attr2, unsigned someRegionsCount)
+// CHECK: static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type r, ::llvm::ArrayRef<::mlir::Type> s, ::mlir::Value a, ::mlir::ValueRange b, ::llvm::APInt attr1, /*optional*/::mlir::FloatAttr attr2, unsigned someRegionsCount)
+// CHECK: static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::llvm::ArrayRef<::mlir::Type> resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions)
+// CHECK: static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
+// CHECK: void print(::mlir::OpAsmPrinter &p);
+// CHECK: ::mlir::LogicalResult verify();
+// CHECK: static void getCanonicalizationPatterns(::mlir::OwningRewritePatternList &results, ::mlir::MLIRContext *context);
+// CHECK: ::mlir::LogicalResult fold(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::OpFoldResult> &results);
// CHECK: // Display a graph for debugging purposes.
// CHECK: void displayGraph();
// CHECK: };
@@ -107,13 +107,13 @@ def NS_AttrSizedOperandOp : NS_Op<"attr_sized_operands",
}
// CHECK-LABEL: AttrSizedOperandOpAdaptor(
-// CHECK-SAME: ValueRange values
-// CHECK-SAME: DictionaryAttr attrs
-// CHECK: ValueRange a();
-// CHECK: ValueRange b();
-// CHECK: Value c();
-// CHECK: ValueRange d();
-// CHECK: DenseIntElementsAttr operand_segment_sizes();
+// CHECK-SAME: ::mlir::ValueRange values
+// CHECK-SAME: ::mlir::DictionaryAttr attrs
+// CHECK: ::mlir::ValueRange a();
+// CHECK: ::mlir::ValueRange b();
+// CHECK: ::mlir::Value c();
+// CHECK: ::mlir::ValueRange d();
+// CHECK: ::mlir::DenseIntElementsAttr operand_segment_sizes();
// Check op trait for
diff erent number of operands
// ---
@@ -145,10 +145,10 @@ def NS_EOp : NS_Op<"op_with_optionals", []> {
}
// CHECK-LABEL: NS::EOp declarations
-// CHECK: Value a();
+// CHECK: ::mlir::Value a();
// CHECK: ::mlir::MutableOperandRange aMutable();
-// CHECK: Value b();
-// CHECK: static void build(OpBuilder &odsBuilder, OperationState &odsState, /*optional*/Type b, /*optional*/Value a)
+// CHECK: ::mlir::Value b();
+// CHECK: static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type b, /*optional*/::mlir::Value a)
// Check that all types match constraint results in generating builder.
// ---
@@ -160,7 +160,7 @@ def NS_FOp : NS_Op<"op_with_all_types_constraint",
}
// CHECK-LABEL: class FOp :
-// CHECK: static LogicalResult inferReturnTypes
+// CHECK: static ::mlir::LogicalResult inferReturnTypes
def NS_GOp : NS_Op<"op_with_fixed_return_type", []> {
let arguments = (ins AnyType:$a);
@@ -168,7 +168,7 @@ def NS_GOp : NS_Op<"op_with_fixed_return_type", []> {
}
// CHECK-LABEL: class GOp :
-// CHECK: static LogicalResult inferReturnTypes
+// CHECK: static ::mlir::LogicalResult inferReturnTypes
// Check that default builders can be suppressed.
// ---
@@ -180,7 +180,7 @@ def NS_SkipDefaultBuildersOp : NS_Op<"skip_default_builders", []> {
// CHECK-LABEL: NS::SkipDefaultBuildersOp declarations
// CHECK: class SkipDefaultBuildersOp
-// CHECK-NOT: static void build(Builder
+// CHECK-NOT: static void build(::mlir::Builder
// CHECK: static void build(Value
// Check leading underscore in op name
@@ -189,12 +189,12 @@ def NS_SkipDefaultBuildersOp : NS_Op<"skip_default_builders", []> {
def NS__AOp : NS_Op<"_op_with_leading_underscore", []>;
// CHECK-LABEL: NS::_AOp declarations
-// CHECK: class _AOp : public Op<_AOp
+// CHECK: class _AOp : public ::mlir::Op<_AOp
def _BOp : NS_Op<"_op_with_leading_underscore_and_no_namespace", []>;
// CHECK-LABEL: _BOp declarations
-// CHECK: class _BOp : public Op<_BOp
+// CHECK: class _BOp : public ::mlir::Op<_BOp
// REDUCE-LABEL: NS::AOp declarations
// REDUCE-NOT: NS::BOp declarations
diff --git a/mlir/test/mlir-tblgen/op-interface.td b/mlir/test/mlir-tblgen/op-interface.td
index 8e5167e6fe53..4ca2b798c3c9 100644
--- a/mlir/test/mlir-tblgen/op-interface.td
+++ b/mlir/test/mlir-tblgen/op-interface.td
@@ -40,7 +40,7 @@ def DeclareMethodsWithDefaultOp : Op<TestDialect, "declare_methods_op",
[DeclareOpInterfaceMethods<TestOpInterface, ["default_foo"]>]>;
// DECL-LABEL: TestOpInterfaceInterfaceTraits
-// DECL: class TestOpInterface : public OpInterface<TestOpInterface, detail::TestOpInterfaceInterfaceTraits>
+// DECL: class TestOpInterface : public ::mlir::OpInterface<TestOpInterface, detail::TestOpInterfaceInterfaceTraits>
// DECL: int foo(int input);
// DECL-NOT: TestOpInterface
diff --git a/mlir/test/mlir-tblgen/op-operand.td b/mlir/test/mlir-tblgen/op-operand.td
index a0a57d803771..abeb67f2dbae 100644
--- a/mlir/test/mlir-tblgen/op-operand.td
+++ b/mlir/test/mlir-tblgen/op-operand.td
@@ -18,11 +18,11 @@ def OpA : NS_Op<"one_normal_operand_op", []> {
// CHECK-SAME: odsOperands(values), odsAttrs(attrs)
// CHECK: void OpA::build
-// CHECK: Value input
+// CHECK: ::mlir::Value input
// CHECK: odsState.addOperands(input);
// CHECK: void OpA::build
-// CHECK: ValueRange operands
+// CHECK: ::mlir::ValueRange operands
// CHECK: assert(operands.size() == 1u && "mismatched number of parameters");
// CHECK: odsState.addOperands(operands);
@@ -31,7 +31,7 @@ def OpB : NS_Op<"one_variadic_operand_op", []> {
}
// CHECK-LABEL: OpB::build
-// CHECK: ValueRange input
+// CHECK: ::mlir::ValueRange input
// CHECK-NOT: assert
// CHECK: odsState.addOperands(input);
@@ -39,19 +39,19 @@ def OpD : NS_Op<"mix_variadic_and_normal_inputs_op", [SameVariadicOperandSize]>
let arguments = (ins Variadic<AnyTensor>:$input1, AnyTensor:$input2, Variadic<AnyTensor>:$input3);
}
-// CHECK-LABEL: ValueRange OpDAdaptor::input1
+// CHECK-LABEL: ::mlir::ValueRange OpDAdaptor::input1
// CHECK-NEXT: return getODSOperands(0);
-// CHECK-LABEL: Value OpDAdaptor::input2
+// CHECK-LABEL: ::mlir::Value OpDAdaptor::input2
// CHECK-NEXT: return *getODSOperands(1).begin();
-// CHECK-LABEL: ValueRange OpDAdaptor::input3
+// CHECK-LABEL: ::mlir::ValueRange OpDAdaptor::input3
// CHECK-NEXT: return getODSOperands(2);
-// CHECK-LABEL: Operation::operand_range OpD::input1
+// CHECK-LABEL: ::mlir::Operation::operand_range OpD::input1
// CHECK-NEXT: return getODSOperands(0);
-// CHECK-LABEL: Value OpD::input2
+// CHECK-LABEL: ::mlir::Value OpD::input2
// CHECK-NEXT: return *getODSOperands(1).begin();
// CHECK-LABEL: OpD::build
diff --git a/mlir/test/mlir-tblgen/op-result.td b/mlir/test/mlir-tblgen/op-result.td
index 7886c2772a21..c9959c5bcb1c 100644
--- a/mlir/test/mlir-tblgen/op-result.td
+++ b/mlir/test/mlir-tblgen/op-result.td
@@ -13,7 +13,7 @@ def OpA : NS_Op<"one_normal_result_op", []> {
}
// CHECK-LABEL: void OpA::build
-// CHECK: ArrayRef<Type> resultTypes, ValueRange operands
+// CHECK: ::llvm::ArrayRef<::mlir::Type> resultTypes, ::mlir::ValueRange operands
// CHECK: assert(resultTypes.size() == 1u && "mismatched number of return types");
// CHECK-NEXT: odsState.addTypes(resultTypes);
@@ -23,9 +23,9 @@ def OpB : NS_Op<"same_input_output_type_op", [SameOperandsAndResultType]> {
}
// CHECK-LABEL: OpB definitions
-// CHECK: void OpB::build(OpBuilder &odsBuilder, OperationState &odsState, Type y, Value x)
+// CHECK: void OpB::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type y, ::mlir::Value x)
// CHECK: odsState.addTypes(y);
-// CHECK: void OpB::build(OpBuilder &odsBuilder, OperationState &odsState, Value x)
+// CHECK: void OpB::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x)
// CHECK: odsState.addTypes({x.getType()});
def OpC : NS_Op<"three_normal_result_op", []> {
@@ -33,12 +33,12 @@ def OpC : NS_Op<"three_normal_result_op", []> {
}
// CHECK-LABEL: OpC definitions
-// CHECK: void OpC::build(OpBuilder &odsBuilder, OperationState &odsState, Type x, Type resultType1, Type z)
+// CHECK: void OpC::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type x, ::mlir::Type resultType1, ::mlir::Type z)
// CHECK-NEXT: odsState.addTypes(x)
// CHECK-NEXT: odsState.addTypes(resultType1)
// CHECK-NEXT: odsState.addTypes(z)
-// CHECK: void OpC::build(OpBuilder &odsBuilder, OperationState &odsState, ArrayRef<Type> resultTypes) {
+// CHECK: void OpC::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::ArrayRef<::mlir::Type> resultTypes) {
// CHECK-NEXT: assert(resultTypes.size() == 3u && "mismatched number of results");
// CHECK-NEXT: odsState.addTypes(resultTypes);
@@ -49,8 +49,8 @@ def OpD : NS_Op<"type_attr_as_result_type", [FirstAttrDerivedResultType]> {
}
// CHECK-LABEL: OpD definitions
-// CHECK: void OpD::build(OpBuilder &odsBuilder, OperationState &odsState, ValueRange operands, ArrayRef<NamedAttribute> attributes)
-// CHECK: odsState.addTypes({attr.second.cast<TypeAttr>().getValue()});
+// CHECK: void OpD::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes)
+// CHECK: odsState.addTypes({attr.second.cast<::mlir::TypeAttr>().getValue()});
def OpE : NS_Op<"value_attr_as_result_type", [FirstAttrDerivedResultType]> {
let arguments = (ins I32:$x, F32Attr:$attr);
@@ -58,7 +58,7 @@ def OpE : NS_Op<"value_attr_as_result_type", [FirstAttrDerivedResultType]> {
}
// CHECK-LABEL: OpE definitions
-// CHECK: void OpE::build(OpBuilder &odsBuilder, OperationState &odsState, ValueRange operands, ArrayRef<NamedAttribute> attributes)
+// CHECK: void OpE::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes)
// CHECK: odsState.addTypes({attr.second.getType()});
def OpF : NS_Op<"one_variadic_result_op", []> {
@@ -66,7 +66,7 @@ def OpF : NS_Op<"one_variadic_result_op", []> {
}
// CHECK-LABEL: void OpF::build
-// CHECK-SAME: ArrayRef<Type> x
+// CHECK-SAME: ::llvm::ArrayRef<::mlir::Type> x
// CHECK-NOT: assert
// CHECK: odsState.addTypes(x);
@@ -77,12 +77,12 @@ def OpG : NS_Op<"one_normal_and_one_variadic_result_op", []> {
// CHECK-LABEL: OpG definitions
-// CHECK: void OpG::build(OpBuilder &odsBuilder, OperationState &odsState, Type x, ArrayRef<Type> y)
+// CHECK: void OpG::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type x, ::llvm::ArrayRef<::mlir::Type> y)
// CHECK-NEXT: odsState.addTypes(x);
// CHECK-NEXT: odsState.addTypes(y);
// CHECK: void OpG::build
-// CHECK: ArrayRef<Type> resultTypes
+// CHECK: ::llvm::ArrayRef<::mlir::Type> resultTypes
// CHECK: assert(resultTypes.size() >= 1u && "mismatched number of return types");
// CHECK-NEXT: odsState.addTypes(resultTypes);
@@ -90,10 +90,10 @@ def OpI : NS_Op<"mix_variadic_and_normal_results_op", [SameVariadicResultSize]>
let results = (outs Variadic<AnyTensor>:$output1, AnyTensor:$output2, Variadic<AnyTensor>:$output3);
}
-// CHECK-LABEL: Operation::result_range OpI::output1
+// CHECK-LABEL: ::mlir::Operation::result_range OpI::output1
// CHECK-NEXT: return getODSResults(0);
-// CHECK-LABEL: Value OpI::output2
+// CHECK-LABEL: ::mlir::Value OpI::output2
// CHECK-NEXT: return *getODSResults(1).begin();
// CHECK-LABEL: OpI::build
@@ -109,5 +109,5 @@ def OpK : NS_Op<"only_input_is_variadic_with_same_value_type_op", [SameOperandsA
let results = (outs AnyTensor:$result);
}
-// CHECK-LABEL: OpK::build(OpBuilder &odsBuilder, OperationState &odsState, ValueRange input)
+// CHECK-LABEL: OpK::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange input)
// CHECK: odsState.addTypes({input.front().getType()});
diff --git a/mlir/test/mlir-tblgen/op-side-effects.td b/mlir/test/mlir-tblgen/op-side-effects.td
index a514d46426e9..6bae35aa763b 100644
--- a/mlir/test/mlir-tblgen/op-side-effects.td
+++ b/mlir/test/mlir-tblgen/op-side-effects.td
@@ -19,9 +19,9 @@ def SideEffectOpB : TEST_Op<"side_effect_op_b",
[MemoryEffects<[MemWrite<CustomResource>]>]>;
// CHECK: void SideEffectOpA::getEffects
-// CHECK: for (Value value : getODSOperands(0))
+// CHECK: for (::mlir::Value value : getODSOperands(0))
// CHECK: effects.emplace_back(MemoryEffects::Read::get(), value, ::mlir::SideEffects::DefaultResource::get());
-// CHECK: for (Value value : getODSResults(0))
+// CHECK: for (::mlir::Value value : getODSResults(0))
// CHECK: effects.emplace_back(MemoryEffects::Allocate::get(), value, CustomResource::get());
// CHECK: void SideEffectOpB::getEffects
diff --git a/mlir/test/mlir-tblgen/predicate.td b/mlir/test/mlir-tblgen/predicate.td
index 5f19344f537c..e5d4ac853b50 100644
--- a/mlir/test/mlir-tblgen/predicate.td
+++ b/mlir/test/mlir-tblgen/predicate.td
@@ -17,7 +17,7 @@ def OpA : NS_Op<"op_for_CPred_containing_multiple_same_placeholder", []> {
// CHECK-LABEL: OpA::verify
// CHECK: auto valueGroup0 = getODSOperands(0);
-// CHECK: for (Value v : valueGroup0) {
+// CHECK: for (::mlir::Value v : valueGroup0) {
// CHECK: if (!((v.getType().isInteger(32) || v.getType().isF32())))
def OpB : NS_Op<"op_for_And_PredOpTrait", [
@@ -33,7 +33,7 @@ def OpF : NS_Op<"op_for_int_min_val", []> {
}
// CHECK-LABEL: OpFAdaptor::verify
-// CHECK: (tblgen_attr.cast<IntegerAttr>().getInt() >= 10)
+// CHECK: (tblgen_attr.cast<::mlir::IntegerAttr>().getInt() >= 10)
// CHECK-SAME: "attribute 'attr' failed to satisfy constraint: 32-bit signless integer attribute whose minimum value is 10"
def OpFX : NS_Op<"op_for_int_max_val", []> {
@@ -41,7 +41,7 @@ def OpFX : NS_Op<"op_for_int_max_val", []> {
}
// CHECK-LABEL: OpFXAdaptor::verify
-// CHECK: (tblgen_attr.cast<IntegerAttr>().getInt() <= 10)
+// CHECK: (tblgen_attr.cast<::mlir::IntegerAttr>().getInt() <= 10)
// CHECK-SAME: "attribute 'attr' failed to satisfy constraint: 32-bit signless integer attribute whose maximum value is 10"
def OpG : NS_Op<"op_for_arr_min_count", []> {
@@ -49,7 +49,7 @@ def OpG : NS_Op<"op_for_arr_min_count", []> {
}
// CHECK-LABEL: OpGAdaptor::verify
-// CHECK: (tblgen_attr.cast<ArrayAttr>().size() >= 8)
+// CHECK: (tblgen_attr.cast<::mlir::ArrayAttr>().size() >= 8)
// CHECK-SAME: "attribute 'attr' failed to satisfy constraint: array attribute with at least 8 elements"
def OpH : NS_Op<"op_for_arr_value_at_index", []> {
@@ -57,7 +57,7 @@ def OpH : NS_Op<"op_for_arr_value_at_index", []> {
}
// CHECK-LABEL: OpHAdaptor::verify
-// CHECK: (((tblgen_attr.cast<ArrayAttr>().size() > 0)) && ((tblgen_attr.cast<ArrayAttr>()[0].cast<IntegerAttr>().getInt() == 8)))))
+// CHECK: (((tblgen_attr.cast<::mlir::ArrayAttr>().size() > 0)) && ((tblgen_attr.cast<::mlir::ArrayAttr>()[0].cast<::mlir::IntegerAttr>().getInt() == 8)))))
// CHECK-SAME: "attribute 'attr' failed to satisfy constraint: array attribute whose 0-th element must be 8"
def OpI: NS_Op<"op_for_arr_min_value_at_index", []> {
@@ -65,7 +65,7 @@ def OpI: NS_Op<"op_for_arr_min_value_at_index", []> {
}
// CHECK-LABEL: OpIAdaptor::verify
-// CHECK: (((tblgen_attr.cast<ArrayAttr>().size() > 0)) && ((tblgen_attr.cast<ArrayAttr>()[0].cast<IntegerAttr>().getInt() >= 8)))))
+// CHECK: (((tblgen_attr.cast<::mlir::ArrayAttr>().size() > 0)) && ((tblgen_attr.cast<::mlir::ArrayAttr>()[0].cast<::mlir::IntegerAttr>().getInt() >= 8)))))
// CHECK-SAME: "attribute 'attr' failed to satisfy constraint: array attribute whose 0-th element must be at least 8"
def OpJ: NS_Op<"op_for_TCopVTEtAreSameAt", [
@@ -81,8 +81,8 @@ def OpJ: NS_Op<"op_for_TCopVTEtAreSameAt", [
}
// CHECK-LABEL: OpJAdaptor::verify
-// CHECK: llvm::is_splat(llvm::map_range(
-// CHECK-SAME: llvm::ArrayRef<unsigned>({0, 2, 3}),
+// CHECK: ::llvm::is_splat(::llvm::map_range(
+// CHECK-SAME: ::mlir::ArrayRef<unsigned>({0, 2, 3}),
// CHECK-SAME: [this](unsigned i) { return getElementTypeOrSelf(this->getOperand(i)); }))
// CHECK: "failed to verify that operands indexed at 0, 2, 3 should all have the same type"
@@ -92,5 +92,5 @@ def OpK : NS_Op<"op_for_AnyTensorOf", []> {
// CHECK-LABEL: OpK::verify
// CHECK: auto valueGroup0 = getODSOperands(0);
-// CHECK: for (Value v : valueGroup0) {
-// CHECK: if (!(((v.getType().isa<TensorType>())) && (((v.getType().cast<ShapedType>().getElementType().isF32())) || ((v.getType().cast<ShapedType>().getElementType().isSignlessInteger(32))))))
+// CHECK: for (::mlir::Value v : valueGroup0) {
+// CHECK: if (!(((v.getType().isa<::mlir::TensorType>())) && (((v.getType().cast<::mlir::ShapedType>().getElementType().isF32())) || ((v.getType().cast<::mlir::ShapedType>().getElementType().isSignlessInteger(32))))))
diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp
index 04d357d762da..b0a89153be4c 100644
--- a/mlir/tools/mlir-tblgen/EnumsGen.cpp
+++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp
@@ -71,7 +71,7 @@ static void emitDenseMapInfo(StringRef enumName, std::string underlyingType,
const char *const mapInfo = R"(
namespace llvm {
template<> struct DenseMapInfo<{0}> {{
- using StorageInfo = llvm::DenseMapInfo<{1}>;
+ using StorageInfo = ::llvm::DenseMapInfo<{1}>;
static inline {0} getEmptyKey() {{
return static_cast<{0}>(StorageInfo::getEmptyKey());
@@ -193,7 +193,7 @@ static void emitSymToStrFnForBitEnum(const Record &enumDef, raw_ostream &os) {
os << formatv(" if (val == 0) return \"{0}\";\n\n",
allBitsUnsetCase->getSymbol());
}
- os << " llvm::SmallVector<llvm::StringRef, 2> strs;\n";
+ os << " ::llvm::SmallVector<::llvm::StringRef, 2> strs;\n";
for (const auto &enumerant : enumerants) {
// Skip the special enumerant for None.
if (auto val = enumerant.getValue())
@@ -203,7 +203,7 @@ static void emitSymToStrFnForBitEnum(const Record &enumDef, raw_ostream &os) {
}
// If we have unknown bit set, return an empty string to signal errors.
os << "\n if (val) return \"\";\n";
- os << formatv(" return llvm::join(strs, \"{0}\");\n", separator);
+ os << formatv(" return ::llvm::join(strs, \"{0}\");\n", separator);
os << "}\n\n";
}
@@ -214,9 +214,9 @@ static void emitStrToSymFnForIntEnum(const Record &enumDef, raw_ostream &os) {
StringRef strToSymFnName = enumAttr.getStringToSymbolFnName();
auto enumerants = enumAttr.getAllCases();
- os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef str) {{\n", enumName,
- strToSymFnName);
- os << formatv(" return llvm::StringSwitch<llvm::Optional<{0}>>(str)\n",
+ os << formatv("::llvm::Optional<{0}> {1}(::llvm::StringRef str) {{\n",
+ enumName, strToSymFnName);
+ os << formatv(" return ::llvm::StringSwitch<::llvm::Optional<{0}>>(str)\n",
enumName);
for (const auto &enumerant : enumerants) {
auto symbol = enumerant.getSymbol();
@@ -224,7 +224,7 @@ static void emitStrToSymFnForIntEnum(const Record &enumDef, raw_ostream &os) {
os << formatv(" .Case(\"{1}\", {0}::{2})\n", enumName, str,
makeIdentifier(symbol));
}
- os << " .Default(llvm::None);\n";
+ os << " .Default(::llvm::None);\n";
os << "}\n";
}
@@ -237,8 +237,8 @@ static void emitStrToSymFnForBitEnum(const Record &enumDef, raw_ostream &os) {
auto enumerants = enumAttr.getAllCases();
auto allBitsUnsetCase = getAllBitsUnsetCase(enumerants);
- os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef str) {{\n", enumName,
- strToSymFnName);
+ os << formatv("::llvm::Optional<{0}> {1}(::llvm::StringRef str) {{\n",
+ enumName, strToSymFnName);
if (allBitsUnsetCase) {
os << " // Special case for all bits unset.\n";
@@ -248,7 +248,7 @@ static void emitStrToSymFnForBitEnum(const Record &enumDef, raw_ostream &os) {
}
// Split the string to get symbols for all the bits.
- os << " llvm::SmallVector<llvm::StringRef, 2> symbols;\n";
+ os << " ::llvm::SmallVector<::llvm::StringRef, 2> symbols;\n";
os << formatv(" str.split(symbols, \"{0}\");\n\n", separator);
os << formatv(" {0} val = 0;\n", underlyingType);
@@ -256,7 +256,7 @@ static void emitStrToSymFnForBitEnum(const Record &enumDef, raw_ostream &os) {
// Convert each symbol to the bit ordinal and set the corresponding bit.
os << formatv(
- " auto bit = llvm::StringSwitch<llvm::Optional<{0}>>(symbol)\n",
+ " auto bit = llvm::StringSwitch<::llvm::Optional<{0}>>(symbol)\n",
underlyingType);
for (const auto &enumerant : enumerants) {
// Skip the special enumerant for None.
@@ -264,9 +264,9 @@ static void emitStrToSymFnForBitEnum(const Record &enumDef, raw_ostream &os) {
os.indent(6) << formatv(".Case(\"{0}\", {1})\n", enumerant.getSymbol(),
val);
}
- os.indent(6) << ".Default(llvm::None);\n";
+ os.indent(6) << ".Default(::llvm::None);\n";
- os << " if (bit) { val |= *bit; } else { return llvm::None; }\n";
+ os << " if (bit) { val |= *bit; } else { return ::llvm::None; }\n";
os << " }\n";
os << formatv(" return static_cast<{0}>(val);\n", enumName);
@@ -288,7 +288,7 @@ static void emitUnderlyingToSymFnForIntEnum(const Record &enumDef,
}))
return;
- os << formatv("llvm::Optional<{0}> {1}({2} value) {{\n", enumName,
+ os << formatv("::llvm::Optional<{0}> {1}({2} value) {{\n", enumName,
underlyingToSymFnName,
underlyingType.empty() ? std::string("unsigned")
: underlyingType)
@@ -299,7 +299,7 @@ static void emitUnderlyingToSymFnForIntEnum(const Record &enumDef,
os << formatv(" case {0}: return {1}::{2};\n", value, enumName,
makeIdentifier(symbol));
}
- os << " default: return llvm::None;\n"
+ os << " default: return ::llvm::None;\n"
<< " }\n"
<< "}\n\n";
}
@@ -313,7 +313,7 @@ static void emitUnderlyingToSymFnForBitEnum(const Record &enumDef,
auto enumerants = enumAttr.getAllCases();
auto allBitsUnsetCase = getAllBitsUnsetCase(enumerants);
- os << formatv("llvm::Optional<{0}> {1}({2} value) {{\n", enumName,
+ os << formatv("::llvm::Optional<{0}> {1}({2} value) {{\n", enumName,
underlyingToSymFnName, underlyingType);
if (allBitsUnsetCase) {
os << " // Special case for all bits unset.\n";
@@ -357,11 +357,11 @@ static void emitEnumDecl(const Record &enumDef, raw_ostream &os) {
return enumerant.getValue() >= 0;
})) {
os << formatv(
- "llvm::Optional<{0}> {1}({2});\n", enumName, underlyingToSymFnName,
+ "::llvm::Optional<{0}> {1}({2});\n", enumName, underlyingToSymFnName,
underlyingType.empty() ? std::string("unsigned") : underlyingType);
}
os << formatv("{2} {1}({0});\n", enumName, symToStrFnName, symToStrFnRetType);
- os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef);\n", enumName,
+ os << formatv("::llvm::Optional<{0}> {1}(::llvm::StringRef);\n", enumName,
strToSymFnName);
if (enumAttr.isBitEnum()) {
@@ -383,10 +383,10 @@ inline {0} stringifyEnum({1} enumValue) {{
// specified by the user.
const char *const symbolizeEnumStr = R"(
template <typename EnumType>
-llvm::Optional<EnumType> symbolizeEnum(llvm::StringRef);
+::llvm::Optional<EnumType> symbolizeEnum(::llvm::StringRef);
template <>
-inline llvm::Optional<{0}> symbolizeEnum<{0}>(llvm::StringRef str) {
+inline ::llvm::Optional<{0}> symbolizeEnum<{0}>(::llvm::StringRef str) {
return {1}(str);
}
)";
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index e477c56aeae4..5f0770496724 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -81,10 +81,10 @@ const char *sameVariadicSizeValueRangeCalcCode = R"(
// {0}: The name of the attribute specifying the segment sizes.
const char *adapterSegmentSizeAttrInitCode = R"(
assert(odsAttrs && "missing segment size attribute for op");
- auto sizeAttr = odsAttrs.get("{0}").cast<DenseIntElementsAttr>();
+ auto sizeAttr = odsAttrs.get("{0}").cast<::mlir::DenseIntElementsAttr>();
)";
const char *opSegmentSizeAttrInitCode = R"(
- auto sizeAttr = getAttrOfType<DenseIntElementsAttr>("{0}");
+ auto sizeAttr = getAttrOfType<::mlir::DenseIntElementsAttr>("{0}");
)";
const char *attrSizedSegmentValueRangeCalcCode = R"(
unsigned start = 0;
@@ -484,7 +484,7 @@ void OpEmitter::emitDef(raw_ostream &os) { opClass.writeDefTo(os); }
void OpEmitter::genAttrGetters() {
FmtContext fctx;
- fctx.withBuilder("mlir::Builder(this->getContext())");
+ fctx.withBuilder("::mlir::Builder(this->getContext())");
// Emit the derived attribute body.
auto emitDerivedAttr = [&](StringRef name, Attribute attr) {
@@ -545,13 +545,14 @@ void OpEmitter::genAttrGetters() {
return namedAttr.attr.isDerivedAttr();
});
if (!derivedAttrs.empty()) {
- opClass.addTrait("DerivedAttributeOpInterface::Trait");
+ opClass.addTrait("::mlir::DerivedAttributeOpInterface::Trait");
// Generate helper method to query whether a named attribute is a derived
// attribute. This enables, for example, avoiding adding an attribute that
// overlaps with a derived attribute.
{
- auto &method = opClass.newMethod("bool", "isDerivedAttribute",
- "StringRef name", OpMethod::MP_Static);
+ auto &method =
+ opClass.newMethod("bool", "isDerivedAttribute",
+ "::llvm::StringRef name", OpMethod::MP_Static);
auto &body = method.body();
for (auto namedAttr : derivedAttrs)
body << " if (name == \"" << namedAttr.name << "\") return true;\n";
@@ -559,8 +560,8 @@ void OpEmitter::genAttrGetters() {
}
// Generate method to materialize derived attributes as a DictionaryAttr.
{
- OpMethod &method =
- opClass.newMethod("DictionaryAttr", "materializeDerivedAttributes");
+ OpMethod &method = opClass.newMethod("::mlir::DictionaryAttr",
+ "materializeDerivedAttributes");
auto &body = method.body();
auto nonMaterializable =
@@ -584,14 +585,15 @@ void OpEmitter::genAttrGetters() {
return;
}
- body << " MLIRContext* ctx = getContext();\n";
- body << " Builder odsBuilder(ctx); (void)odsBuilder;\n";
- body << " return DictionaryAttr::get({\n";
+ body << " ::mlir::MLIRContext* ctx = getContext();\n";
+ body << " ::mlir::Builder odsBuilder(ctx); (void)odsBuilder;\n";
+ body << " return ::mlir::DictionaryAttr::get({\n";
interleave(
derivedAttrs, body,
[&](const NamedAttribute &namedAttr) {
auto tmpl = namedAttr.attr.getConvertFromStorageCall();
- body << " {Identifier::get(\"" << namedAttr.name << "\", ctx),\n"
+ body << " {::mlir::Identifier::get(\"" << namedAttr.name
+ << "\", ctx),\n"
<< tgfmt(tmpl, &fctx.withSelf(namedAttr.name + "()")
.withBuilder("odsBuilder")
.addSubst("_ctx", "ctx"))
@@ -713,14 +715,14 @@ static void generateNamedOperandGetters(const Operator &op, Class &opClass,
continue;
if (operand.isOptional()) {
- auto &m = opClass.newMethod("Value", operand.name);
+ auto &m = opClass.newMethod("::mlir::Value", operand.name);
m.body() << " auto operands = getODSOperands(" << i << ");\n"
<< " return operands.empty() ? Value() : *operands.begin();";
} else if (operand.isVariadic()) {
auto &m = opClass.newMethod(rangeType, operand.name);
m.body() << " return getODSOperands(" << i << ");";
} else {
- auto &m = opClass.newMethod("Value", operand.name);
+ auto &m = opClass.newMethod("::mlir::Value", operand.name);
m.body() << " return *getODSOperands(" << i << ").begin();";
}
}
@@ -731,7 +733,7 @@ void OpEmitter::genNamedOperandGetters() {
op, opClass,
/*sizeAttrInit=*/
formatv(opSegmentSizeAttrInitCode, "operand_segment_sizes").str(),
- /*rangeType=*/"Operation::operand_range",
+ /*rangeType=*/"::mlir::Operation::operand_range",
/*rangeBeginCall=*/"getOperation()->operand_begin()",
/*rangeSizeCall=*/"getOperation()->getNumOperands()",
/*getOperandCallPattern=*/"getOperation()->getOperand({0})");
@@ -790,8 +792,8 @@ void OpEmitter::genNamedResultGetters() {
numNormalResults, "getOperation()->getNumResults()", attrSizedResults,
formatv(opSegmentSizeAttrInitCode, "result_segment_sizes").str(),
op.getResults());
- auto &m = opClass.newMethod("Operation::result_range", "getODSResults",
- "unsigned index");
+ auto &m = opClass.newMethod("::mlir::Operation::result_range",
+ "getODSResults", "unsigned index");
m.body() << formatv(valueRangeReturnCode, "getOperation()->result_begin()",
"getODSResultIndexAndLength(index)");
@@ -801,14 +803,16 @@ void OpEmitter::genNamedResultGetters() {
continue;
if (result.isOptional()) {
- auto &m = opClass.newMethod("Value", result.name);
- m.body() << " auto results = getODSResults(" << i << ");\n"
- << " return results.empty() ? Value() : *results.begin();";
+ auto &m = opClass.newMethod("::mlir::Value", result.name);
+ m.body()
+ << " auto results = getODSResults(" << i << ");\n"
+ << " return results.empty() ? ::mlir::Value() : *results.begin();";
} else if (result.isVariadic()) {
- auto &m = opClass.newMethod("Operation::result_range", result.name);
+ auto &m =
+ opClass.newMethod("::mlir::Operation::result_range", result.name);
m.body() << " return getODSResults(" << i << ");";
} else {
- auto &m = opClass.newMethod("Value", result.name);
+ auto &m = opClass.newMethod("::mlir::Value", result.name);
m.body() << " return *getODSResults(" << i << ").begin();";
}
}
@@ -823,13 +827,14 @@ void OpEmitter::genNamedRegionGetters() {
// Generate the accessors for a varidiadic region.
if (region.isVariadic()) {
- auto &m = opClass.newMethod("MutableArrayRef<Region>", region.name);
+ auto &m =
+ opClass.newMethod("::mlir::MutableArrayRef<Region>", region.name);
m.body() << formatv(
" return this->getOperation()->getRegions().drop_front({0});", i);
continue;
}
- auto &m = opClass.newMethod("Region &", region.name);
+ auto &m = opClass.newMethod("::mlir::Region &", region.name);
m.body() << formatv(" return this->getOperation()->getRegion({0});", i);
}
}
@@ -843,7 +848,7 @@ void OpEmitter::genNamedSuccessorGetters() {
// Generate the accessors for a variadic successor list.
if (successor.isVariadic()) {
- auto &m = opClass.newMethod("SuccessorRange", successor.name);
+ auto &m = opClass.newMethod("::mlir::SuccessorRange", successor.name);
m.body() << formatv(
" return {std::next(this->getOperation()->successor_begin(), {0}), "
"this->getOperation()->successor_end()};",
@@ -851,7 +856,7 @@ void OpEmitter::genNamedSuccessorGetters() {
continue;
}
- auto &m = opClass.newMethod("Block *", successor.name);
+ auto &m = opClass.newMethod("::mlir::Block *", successor.name);
m.body() << formatv(" return this->getOperation()->getSuccessor({0});", i);
}
}
@@ -910,14 +915,14 @@ void OpEmitter::genSeparateArgParamBuilder() {
// inferred automatically.
// TODO(jpienaar): Expand to handle regions.
body << formatv(R"(
- SmallVector<Type, 2> inferredReturnTypes;
+ ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
if (succeeded({0}::inferReturnTypes(odsBuilder.getContext(),
{1}.location, {1}.operands,
{1}.attributes.getDictionary({1}.getContext()),
/*regions=*/{{}, inferredReturnTypes)))
{1}.addTypes(inferredReturnTypes);
else
- llvm::report_fatal_error("Failed to infer result type(s).");)",
+ ::llvm::report_fatal_error("Failed to infer result type(s).");)",
opClass.getClassName(), builderOpState);
return;
}
@@ -967,8 +972,10 @@ void OpEmitter::genUseOperandAsResultTypeCollectiveParamBuilder() {
// Signature
std::string params =
- std::string("OpBuilder &odsBuilder, OperationState &") + builderOpState +
- ", ValueRange operands, ArrayRef<NamedAttribute> attributes";
+ std::string("::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &") +
+ builderOpState +
+ ", ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> "
+ "attributes";
if (op.getNumVariadicRegions())
params += ", unsigned numRegions";
auto &m = opClass.newMethod("void", "build", params, OpMethod::MP_Static);
@@ -997,8 +1004,9 @@ void OpEmitter::genUseOperandAsResultTypeCollectiveParamBuilder() {
void OpEmitter::genInferredTypeCollectiveParamBuilder() {
// TODO(jpienaar): Expand to support regions.
const char *params =
- "OpBuilder &odsBuilder, OperationState &{0}, "
- "ValueRange operands, ArrayRef<NamedAttribute> attributes";
+ "::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &{0}, "
+ "::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> "
+ "attributes";
auto &m =
opClass.newMethod("void", "build", formatv(params, builderOpState).str(),
OpMethod::MP_Static);
@@ -1031,7 +1039,7 @@ void OpEmitter::genInferredTypeCollectiveParamBuilder() {
// Result types
body << formatv(R"(
- SmallVector<Type, 2> inferredReturnTypes;
+ ::mlir::SmallVector<::mlir::Type, 2> inferredReturnTypes;
if (succeeded({0}::inferReturnTypes(odsBuilder.getContext(),
{1}.location, operands,
{1}.attributes.getDictionary({1}.getContext()),
@@ -1045,7 +1053,7 @@ void OpEmitter::genInferredTypeCollectiveParamBuilder() {
body << formatv(R"(
} else
- llvm::report_fatal_error("Failed to infer result type(s).");)",
+ ::llvm::report_fatal_error("Failed to infer result type(s).");)",
opClass.getClassName(), builderOpState);
}
@@ -1073,8 +1081,10 @@ void OpEmitter::genUseOperandAsResultTypeSeparateParamBuilder() {
void OpEmitter::genUseAttrAsResultTypeBuilder() {
std::string params =
- std::string("OpBuilder &odsBuilder, OperationState &") + builderOpState +
- ", ValueRange operands, ArrayRef<NamedAttribute> attributes";
+ std::string("::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &") +
+ builderOpState +
+ ", ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> "
+ "attributes";
auto &m = opClass.newMethod("void", "build", params, OpMethod::MP_Static);
auto &body = m.body();
@@ -1085,7 +1095,7 @@ void OpEmitter::genUseAttrAsResultTypeBuilder() {
body << " for (auto attr : attributes) {\n";
body << " if (attr.first != \"" << namedAttr.name << "\") continue;\n";
if (namedAttr.attr.isTypeAttr()) {
- resultType = "attr.second.cast<TypeAttr>().getValue()";
+ resultType = "attr.second.cast<::mlir::TypeAttr>().getValue()";
} else {
resultType = "attr.second.getType()";
}
@@ -1163,10 +1173,12 @@ void OpEmitter::genCollectiveParamBuilder() {
int numVariadicOperands = op.getNumVariableLengthOperands();
int numNonVariadicOperands = numOperands - numVariadicOperands;
// Signature
- std::string params = std::string("OpBuilder &, OperationState &") +
- builderOpState +
- ", ArrayRef<Type> resultTypes, ValueRange operands, "
- "ArrayRef<NamedAttribute> attributes";
+ std::string params =
+ std::string("::mlir::OpBuilder &, ::mlir::OperationState &") +
+ builderOpState +
+ ", ::llvm::ArrayRef<::mlir::Type> resultTypes, ::mlir::ValueRange "
+ "operands, "
+ "::llvm::ArrayRef<::mlir::NamedAttribute> attributes";
if (op.getNumVariadicRegions())
params += ", unsigned numRegions";
auto &m = opClass.newMethod("void", "build", params, OpMethod::MP_Static);
@@ -1212,7 +1224,7 @@ void OpEmitter::buildParamList(std::string ¶mList,
auto numResults = op.getNumResults();
resultTypeNames.reserve(numResults);
- paramList = "OpBuilder &odsBuilder, OperationState &";
+ paramList = "::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &";
paramList.append(builderOpState);
switch (typeParamKind) {
@@ -1227,18 +1239,18 @@ void OpEmitter::buildParamList(std::string ¶mList,
resultName = std::string(formatv("resultType{0}", i));
if (result.isOptional())
- paramList.append(", /*optional*/Type ");
+ paramList.append(", /*optional*/::mlir::Type ");
else if (result.isVariadic())
- paramList.append(", ArrayRef<Type> ");
+ paramList.append(", ::llvm::ArrayRef<::mlir::Type> ");
else
- paramList.append(", Type ");
+ paramList.append(", ::mlir::Type ");
paramList.append(resultName);
resultTypeNames.emplace_back(std::move(resultName));
}
} break;
case TypeParamKind::Collective: {
- paramList.append(", ArrayRef<Type> resultTypes");
+ paramList.append(", ::llvm::ArrayRef<::mlir::Type> resultTypes");
resultTypeNames.push_back("resultTypes");
} break;
}
@@ -1266,7 +1278,7 @@ void OpEmitter::buildParamList(std::string ¶mList,
// TODO(b/144412160) Adjust the 'returnType' field of such attributes
// to support them.
StringRef retType = namedAttr->attr.getReturnType();
- if (retType == "APInt" || retType == "APFloat")
+ if (retType == "::llvm::APInt" || retType == "::llvm::APFloat")
break;
defaultValuedAttrStartIndex = i;
@@ -1278,11 +1290,11 @@ void OpEmitter::buildParamList(std::string ¶mList,
if (argument.is<tblgen::NamedTypeConstraint *>()) {
const auto &operand = op.getOperand(numOperands);
if (operand.isOptional())
- paramList.append(", /*optional*/Value ");
+ paramList.append(", /*optional*/::mlir::Value ");
else if (operand.isVariadic())
- paramList.append(", ValueRange ");
+ paramList.append(", ::mlir::ValueRange ");
else
- paramList.append(", Value ");
+ paramList.append(", ::mlir::Value ");
paramList.append(getArgumentName(op, numOperands));
++numOperands;
} else {
@@ -1311,7 +1323,7 @@ void OpEmitter::buildParamList(std::string ¶mList,
// Attach default value if requested and possible.
if (attrParamKind == AttrParamKind::UnwrappedValue &&
i >= defaultValuedAttrStartIndex) {
- bool isString = attr.getReturnType() == "StringRef";
+ bool isString = attr.getReturnType() == "::llvm::StringRef";
paramList.append(" = ");
if (isString)
paramList.append("\"");
@@ -1325,7 +1337,8 @@ void OpEmitter::buildParamList(std::string ¶mList,
/// Insert parameters for each successor.
for (const NamedSuccessor &succ : op.getSuccessors()) {
- paramList += (succ.isVariadic() ? ", ArrayRef<Block *> " : ", Block *");
+ paramList += (succ.isVariadic() ? ", ::llvm::ArrayRef<::mlir::Block *> "
+ : ", ::mlir::Block *");
paramList += succ.name;
}
@@ -1421,7 +1434,7 @@ void OpEmitter::genCanonicalizerDecls() {
return;
const char *const params =
- "OwningRewritePatternList &results, MLIRContext *context";
+ "::mlir::OwningRewritePatternList &results, ::mlir::MLIRContext *context";
opClass.newMethod("void", "getCanonicalizationPatterns", params,
OpMethod::MP_Static, /*declOnly=*/true);
}
@@ -1432,13 +1445,16 @@ void OpEmitter::genFolderDecls() {
if (def.getValueAsBit("hasFolder")) {
if (hasSingleResult) {
- const char *const params = "ArrayRef<Attribute> operands";
- opClass.newMethod("OpFoldResult", "fold", params, OpMethod::MP_None,
+ const char *const params = "::llvm::ArrayRef<::mlir::Attribute> operands";
+ opClass.newMethod("::mlir::OpFoldResult", "fold", params,
+ OpMethod::MP_None,
/*declOnly=*/true);
} else {
- const char *const params = "ArrayRef<Attribute> operands, "
- "SmallVectorImpl<OpFoldResult> &results";
- opClass.newMethod("LogicalResult", "fold", params, OpMethod::MP_None,
+ const char *const params =
+ "::llvm::ArrayRef<::mlir::Attribute> operands, "
+ "::llvm::SmallVectorImpl<::mlir::OpFoldResult> &results";
+ opClass.newMethod("::mlir::LogicalResult", "fold", params,
+ OpMethod::MP_None,
/*declOnly=*/true);
}
}
@@ -1532,9 +1548,9 @@ void OpEmitter::genSideEffectInterfaceMethods() {
for (auto &it : interfaceEffects) {
auto effectsParam =
- llvm::formatv(
- "SmallVectorImpl<SideEffects::EffectInstance<{0}>> &effects",
- it.first())
+ llvm::formatv("::mlir::SmallVectorImpl<::mlir::SideEffects::"
+ "EffectInstance<{0}>> &effects",
+ it.first())
.str();
// Generate the 'getEffects' method.
@@ -1544,7 +1560,7 @@ void OpEmitter::genSideEffectInterfaceMethods() {
// Add effect instances for each of the locations marked on the operation.
for (auto &location : it.second) {
if (location.kind != EffectKind::Static) {
- body << " for (Value value : getODS"
+ body << " for (::mlir::Value value : getODS"
<< (location.kind == EffectKind::Operand ? "Operands" : "Results")
<< "(" << location.index << "))\n ";
}
@@ -1565,10 +1581,12 @@ void OpEmitter::genTypeInterfaceMethods() {
return;
auto &method = opClass.newMethod(
- "LogicalResult", "inferReturnTypes",
- "MLIRContext* context, Optional<Location> location, "
- "ValueRange operands, DictionaryAttr attributes, RegionRange regions, "
- "SmallVectorImpl<Type>& inferredReturnTypes",
+ "::mlir::LogicalResult", "inferReturnTypes",
+ "::mlir::MLIRContext* context, "
+ "::llvm::Optional<::mlir::Location> location, "
+ "::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, "
+ "::mlir::RegionRange regions, "
+ "::llvm::SmallVectorImpl<::mlir::Type>& inferredReturnTypes",
OpMethod::MP_Static,
/*declOnly=*/false);
auto &os = method.body();
@@ -1576,7 +1594,7 @@ void OpEmitter::genTypeInterfaceMethods() {
FmtContext fctx;
fctx.withBuilder("odsBuilder");
- os << " Builder odsBuilder(context);\n";
+ os << " ::mlir::Builder odsBuilder(context);\n";
auto emitType =
[&](const tblgen::Operator::ArgOrType &type) -> OpMethodBody & {
@@ -1606,7 +1624,8 @@ void OpEmitter::genParser() {
return;
auto &method = opClass.newMethod(
- "ParseResult", "parse", "OpAsmParser &parser, OperationState &result",
+ "::mlir::ParseResult", "parse",
+ "::mlir::OpAsmParser &parser, ::mlir::OperationState &result",
OpMethod::MP_Static);
FmtContext fctx;
fctx.addSubst("cppClass", opClass.getClassName());
@@ -1623,7 +1642,7 @@ void OpEmitter::genPrinter() {
if (!codeInit)
return;
- auto &method = opClass.newMethod("void", "print", "OpAsmPrinter &p");
+ auto &method = opClass.newMethod("void", "print", "::mlir::OpAsmPrinter &p");
FmtContext fctx;
fctx.addSubst("cppClass", opClass.getClassName());
auto printer = codeInit->getValue().ltrim().rtrim(" \t\v\f\r");
@@ -1631,7 +1650,8 @@ void OpEmitter::genPrinter() {
}
void OpEmitter::genVerifier() {
- auto &method = opClass.newMethod("LogicalResult", "verify", /*params=*/"");
+ auto &method =
+ opClass.newMethod("::mlir::LogicalResult", "verify", /*params=*/"");
auto &body = method.body();
body << " if (failed(" << op.getAdaptorName()
<< "(*this).verify(this->getLoc()))) "
@@ -1666,7 +1686,7 @@ void OpEmitter::genVerifier() {
auto printer = codeInit->getValue().ltrim().rtrim(" \t\v\f\r");
body << " " << tgfmt(printer, &fctx);
} else {
- body << " return mlir::success();\n";
+ body << " return ::mlir::success();\n";
}
}
@@ -1703,7 +1723,8 @@ void OpEmitter::genOperandResultVerifier(OpMethodBody &body,
continue;
// Emit a loop to check all the dynamic values in the pack.
- body << " for (Value v : valueGroup" << staticValue.index() << ") {\n";
+ body << " for (::mlir::Value v : valueGroup" << staticValue.index()
+ << ") {\n";
auto constraint = staticValue.value().constraint;
body << " (void)v;\n"
@@ -1736,12 +1757,12 @@ void OpEmitter::genRegionVerifier(OpMethodBody &body) {
if (region.constraint.getPredicate().isNull())
continue;
- body << " for (Region ®ion : ";
- body << formatv(
- region.isVariadic()
- ? "{0}()"
- : "MutableArrayRef<Region>(this->getOperation()->getRegion({1}))",
- region.name, i);
+ body << " for (::mlir::Region ®ion : ";
+ body << formatv(region.isVariadic()
+ ? "{0}()"
+ : "::mlir::MutableArrayRef<::mlir::Region>(this->"
+ "getOperation()->getRegion({1}))",
+ region.name, i);
body << ") {\n";
auto constraint = tgfmt(region.constraint.getConditionTemplate(),
&verifyCtx.withSelf("region"))
@@ -1775,9 +1796,10 @@ void OpEmitter::genSuccessorVerifier(OpMethodBody &body) {
if (successor.constraint.getPredicate().isNull())
continue;
- body << " for (Block *successor : ";
- body << formatv(successor.isVariadic() ? "{0}()"
- : "ArrayRef<Block *>({0}())",
+ body << " for (::mlir::Block *successor : ";
+ body << formatv(successor.isVariadic()
+ ? "{0}()"
+ : "::llvm::ArrayRef<::mlir::Block *>({0}())",
successor.name);
body << ") {\n";
auto constraint = tgfmt(successor.constraint.getConditionTemplate(),
@@ -1873,7 +1895,7 @@ void OpEmitter::genTraits() {
}
void OpEmitter::genOpNameGetter() {
- auto &method = opClass.newMethod("StringRef", "getOperationName",
+ auto &method = opClass.newMethod("::llvm::StringRef", "getOperationName",
/*params=*/"", OpMethod::MP_Static);
method.body() << " return \"" << op.getOperationName() << "\";\n";
}
@@ -1937,15 +1959,16 @@ class OpOperandAdaptorEmitter {
OpOperandAdaptorEmitter::OpOperandAdaptorEmitter(const Operator &op)
: op(op), adaptor(op.getAdaptorName()) {
- adaptor.newField("ValueRange", "odsOperands");
- adaptor.newField("DictionaryAttr", "odsAttrs");
+ adaptor.newField("::mlir::ValueRange", "odsOperands");
+ adaptor.newField("::mlir::DictionaryAttr", "odsAttrs");
const auto *attrSizedOperands =
op.getTrait("OpTrait::AttrSizedOperandSegments");
{
auto &constructor = adaptor.newConstructor(
attrSizedOperands
- ? "ValueRange values, DictionaryAttr attrs"
- : "ValueRange values, DictionaryAttr attrs = nullptr");
+ ? "::mlir::ValueRange values, ::mlir::DictionaryAttr attrs"
+ : "::mlir::ValueRange values, ::mlir::DictionaryAttr attrs = "
+ "nullptr");
constructor.addMemberInitializer("odsOperands", "values");
constructor.addMemberInitializer("odsAttrs", "attrs");
}
@@ -1962,13 +1985,13 @@ OpOperandAdaptorEmitter::OpOperandAdaptorEmitter(const Operator &op)
std::string sizeAttrInit =
formatv(adapterSegmentSizeAttrInitCode, "operand_segment_sizes");
generateNamedOperandGetters(op, adaptor, sizeAttrInit,
- /*rangeType=*/"ValueRange",
+ /*rangeType=*/"::mlir::ValueRange",
/*rangeBeginCall=*/"odsOperands.begin()",
/*rangeSizeCall=*/"odsOperands.size()",
/*getOperandCallPattern=*/"odsOperands[{0}]");
FmtContext fctx;
- fctx.withBuilder("mlir::Builder(odsAttrs.getContext())");
+ fctx.withBuilder("::mlir::Builder(odsAttrs.getContext())");
auto emitAttr = [&](StringRef name, Attribute attr) {
auto &body = adaptor.newMethod(attr.getStorageType(), name).body();
@@ -2004,14 +2027,14 @@ OpOperandAdaptorEmitter::OpOperandAdaptorEmitter(const Operator &op)
}
void OpOperandAdaptorEmitter::addVerification() {
- auto &method = adaptor.newMethod("LogicalResult", "verify",
- /*params=*/"Location loc");
+ auto &method = adaptor.newMethod("::mlir::LogicalResult", "verify",
+ /*params=*/"::mlir::Location loc");
auto &body = method.body();
const char *checkAttrSizedValueSegmentsCode = R"(
{
- auto sizeAttr = odsAttrs.get("{0}").cast<DenseIntElementsAttr>();
- auto numElements = sizeAttr.getType().cast<ShapedType>().getNumElements();
+ auto sizeAttr = odsAttrs.get("{0}").cast<::mlir::DenseIntElementsAttr>();
+ auto numElements = sizeAttr.getType().cast<::mlir::ShapedType>().getNumElements();
if (numElements != {1})
return emitError(loc, "'{0}' attribute for specifying {2} segments "
"must have {1} elements");
diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
index 9fa87e3a8427..8290fc0674e0 100644
--- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
@@ -371,8 +371,8 @@ const char *const attrParserCode = R"(
/// {3}: The constant builder call to create an attribute of the enum type.
const char *const enumAttrParserCode = R"(
{
- StringAttr attrVal;
- NamedAttrList attrStorage;
+ ::mlir::StringAttr attrVal;
+ ::mlir::NamedAttrList attrStorage;
auto loc = parser.getCurrentLocation();
if (parser.parseAttribute(attrVal, parser.getBuilder().getNoneType(),
"{0}", attrStorage))
@@ -396,8 +396,9 @@ const char *const variadicOperandParserCode = R"(
)";
const char *const optionalOperandParserCode = R"(
{
- OpAsmParser::OperandType operand;
- OptionalParseResult parseResult = parser.parseOptionalOperand(operand);
+ ::mlir::OpAsmParser::OperandType operand;
+ ::mlir::OptionalParseResult parseResult =
+ parser.parseOptionalOperand(operand);
if (parseResult.hasValue()) {
if (failed(*parseResult))
return failure();
@@ -419,8 +420,9 @@ const char *const variadicTypeParserCode = R"(
)";
const char *const optionalTypeParserCode = R"(
{
- Type optionalType;
- OptionalParseResult parseResult = parser.parseOptionalType(optionalType);
+ ::mlir::Type optionalType;
+ ::mlir::OptionalParseResult parseResult =
+ parser.parseOptionalType(optionalType);
if (parseResult.hasValue()) {
if (failed(*parseResult))
return failure();
@@ -438,7 +440,7 @@ const char *const typeParserCode = R"(
/// {0}: The name for the input type list.
/// {1}: The name for the result type list.
const char *const functionalTypeParserCode = R"(
- FunctionType {0}__{1}_functionType;
+ ::mlir::FunctionType {0}__{1}_functionType;
if (parser.parseType({0}__{1}_functionType))
return failure();
{0}Types = {0}__{1}_functionType.getInputs();
@@ -449,9 +451,9 @@ const char *const functionalTypeParserCode = R"(
///
/// {0}: The name for the successor list.
const char *successorListParserCode = R"(
- SmallVector<Block *, 2> {0}Successors;
+ ::llvm::SmallVector<::mlir::Block *, 2> {0}Successors;
{
- Block *succ;
+ ::mlir::Block *succ;
auto firstSucc = parser.parseOptionalSuccessor(succ);
if (firstSucc.hasValue()) {
if (failed(*firstSucc))
@@ -472,7 +474,7 @@ const char *successorListParserCode = R"(
///
/// {0}: The name of the successor.
const char *successorParserCode = R"(
- Block *{0}Successor = nullptr;
+ ::mlir::Block *{0}Successor = nullptr;
if (parser.parseSuccessor({0}Successor))
return failure();
)";
@@ -546,31 +548,34 @@ static void genElementParserStorage(Element *element, OpMethodBody &body) {
} else if (auto *operand = dyn_cast<OperandVariable>(element)) {
StringRef name = operand->getVar()->name;
if (operand->getVar()->isVariableLength()) {
- body << " SmallVector<OpAsmParser::OperandType, 4> " << name
- << "Operands;\n";
+ body << " ::mlir::SmallVector<::mlir::OpAsmParser::OperandType, 4> "
+ << name << "Operands;\n";
} else {
- body << " OpAsmParser::OperandType " << name << "RawOperands[1];\n"
- << " ArrayRef<OpAsmParser::OperandType> " << name << "Operands("
- << name << "RawOperands);";
+ body << " ::mlir::OpAsmParser::OperandType " << name
+ << "RawOperands[1];\n"
+ << " ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> " << name
+ << "Operands(" << name << "RawOperands);";
}
body << llvm::formatv(
- " llvm::SMLoc {0}OperandsLoc = parser.getCurrentLocation();\n"
+ " ::llvm::SMLoc {0}OperandsLoc = parser.getCurrentLocation();\n"
" (void){0}OperandsLoc;\n",
name);
} else if (auto *dir = dyn_cast<TypeDirective>(element)) {
ArgumentLengthKind lengthKind;
StringRef name = getTypeListName(dir->getOperand(), lengthKind);
if (lengthKind != ArgumentLengthKind::Single)
- body << " SmallVector<Type, 1> " << name << "Types;\n";
+ body << " ::mlir::SmallVector<::mlir::Type, 1> " << name << "Types;\n";
else
- body << llvm::formatv(" Type {0}RawTypes[1];\n", name)
- << llvm::formatv(" ArrayRef<Type> {0}Types({0}RawTypes);\n", name);
+ body << llvm::formatv(" ::mlir::Type {0}RawTypes[1];\n", name)
+ << llvm::formatv(
+ " ::llvm::ArrayRef<::mlir::Type> {0}Types({0}RawTypes);\n",
+ name);
} else if (auto *dir = dyn_cast<FunctionalTypeDirective>(element)) {
ArgumentLengthKind ignored;
- body << " ArrayRef<Type> " << getTypeListName(dir->getInputs(), ignored)
- << "Types;\n";
- body << " ArrayRef<Type> " << getTypeListName(dir->getResults(), ignored)
- << "Types;\n";
+ body << " ::llvm::ArrayRef<::mlir::Type> "
+ << getTypeListName(dir->getInputs(), ignored) << "Types;\n";
+ body << " ::llvm::ArrayRef<::mlir::Type> "
+ << getTypeListName(dir->getResults(), ignored) << "Types;\n";
}
}
@@ -655,8 +660,9 @@ static void genElementParser(Element *element, OpMethodBody &body,
<< "(result.attributes))\n"
<< " return failure();\n";
} else if (isa<OperandsDirective>(element)) {
- body << " llvm::SMLoc allOperandLoc = parser.getCurrentLocation();\n"
- << " SmallVector<OpAsmParser::OperandType, 4> allOperands;\n"
+ body << " ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();\n"
+ << " ::mlir::SmallVector<::mlir::OpAsmParser::OperandType, 4> "
+ "allOperands;\n"
<< " if (parser.parseOperandList(allOperands))\n"
<< " return failure();\n";
} else if (isa<SuccessorsDirective>(element)) {
@@ -682,7 +688,8 @@ static void genElementParser(Element *element, OpMethodBody &body,
void OperationFormat::genParser(Operator &op, OpClass &opClass) {
auto &method = opClass.newMethod(
- "ParseResult", "parse", "OpAsmParser &parser, OperationState &result",
+ "::mlir::ParseResult", "parse",
+ "::mlir::OpAsmParser &parser, ::mlir::OperationState &result",
OpMethod::MP_Static);
auto &body = method.body();
@@ -726,7 +733,7 @@ void OperationFormat::genParserTypeResolution(Operator &op,
continue;
auto constraint = variable->constraint;
- body << " for (Type type : " << variable->name << "Types) {\n"
+ body << " for (::mlir::Type type : " << variable->name << "Types) {\n"
<< " (void)type;\n"
<< " if (!("
<< tgfmt(constraint.getConditionTemplate(),
@@ -744,7 +751,7 @@ void OperationFormat::genParserTypeResolution(Operator &op,
FmtContext typeBuilderCtx;
typeBuilderCtx.withBuilder("parser.getBuilder()");
for (auto &it : buildableTypes)
- body << " Type odsBuildableType" << it.second << " = "
+ body << " ::mlir::Type odsBuildableType" << it.second << " = "
<< tgfmt(it.first, &typeBuilderCtx) << ";\n";
}
@@ -791,7 +798,7 @@ void OperationFormat::genParserTypeResolution(Operator &op,
// llvm::concat does not allow the case of a single range, so guard it here.
body << " if (parser.resolveOperands(";
if (op.getNumOperands() > 1) {
- body << "llvm::concat<const OpAsmParser::OperandType>(";
+ body << "::llvm::concat<const ::mlir::OpAsmParser::OperandType>(";
llvm::interleaveComma(op.getOperands(), body, [&](auto &operand) {
body << operand.name << "Operands";
});
@@ -811,10 +818,10 @@ void OperationFormat::genParserTypeResolution(Operator &op,
// once. Use llvm::concat to perform the merge. llvm::concat does not allow
// the case of a single range, so guard it here.
if (op.getNumOperands() > 1) {
- body << "llvm::concat<const Type>(";
+ body << "::llvm::concat<const Type>(";
llvm::interleaveComma(
llvm::seq<int>(0, op.getNumOperands()), body, [&](int i) {
- body << "ArrayRef<Type>(";
+ body << "::llvm::ArrayRef<::mlir::Type>(";
emitTypeResolver(operandTypes[i], op.getOperand(i).name);
body << ")";
});
@@ -946,9 +953,11 @@ static OpMethodBody &genTypeOperandPrinter(Element *arg, OpMethodBody &body) {
return body << var->name << "().getTypes()";
if (var->isOptional())
return body << llvm::formatv(
- "({0}() ? ArrayRef<Type>({0}().getType()) : ArrayRef<Type>())",
+ "({0}() ? ::llvm::ArrayRef<::mlir::Type>({0}().getType()) : "
+ "::llvm::ArrayRef<::mlir::Type>())",
var->name);
- return body << "ArrayRef<Type>(" << var->name << "().getType())";
+ return body << "::llvm::ArrayRef<::mlir::Type>(" << var->name
+ << "().getType())";
}
/// Generate the code for printing the given element.
@@ -1014,7 +1023,8 @@ static void genElementPrinter(Element *element, OpMethodBody &body,
body << " p.printAttribute(" << var->name << "Attr());\n";
} else if (auto *operand = dyn_cast<OperandVariable>(element)) {
if (operand->getVar()->isOptional()) {
- body << " if (Value value = " << operand->getVar()->name << "())\n"
+ body << " if (::mlir::Value value = " << operand->getVar()->name
+ << "())\n"
<< " p << value;\n";
} else {
body << " p << " << operand->getVar()->name << "();\n";
@@ -1022,13 +1032,13 @@ static void genElementPrinter(Element *element, OpMethodBody &body,
} else if (auto *successor = dyn_cast<SuccessorVariable>(element)) {
const NamedSuccessor *var = successor->getVar();
if (var->isVariadic())
- body << " llvm::interleaveComma(" << var->name << "(), p);\n";
+ body << " ::llvm::interleaveComma(" << var->name << "(), p);\n";
else
body << " p << " << var->name << "();\n";
} else if (isa<OperandsDirective>(element)) {
body << " p << getOperation()->getOperands();\n";
} else if (isa<SuccessorsDirective>(element)) {
- body << " llvm::interleaveComma(getOperation()->getSuccessors(), p);\n";
+ body << " ::llvm::interleaveComma(getOperation()->getSuccessors(), p);\n";
} else if (auto *dir = dyn_cast<TypeDirective>(element)) {
body << " p << ";
genTypeOperandPrinter(dir->getOperand(), body) << ";\n";
@@ -1301,7 +1311,8 @@ Token FormatLexer::lexIdentifier(const char *tokStart) {
/// Function to find an element within the given range that has the same name as
/// 'name'.
-template <typename RangeT> static auto findArg(RangeT &&range, StringRef name) {
+template <typename RangeT>
+static auto findArg(RangeT &&range, StringRef name) {
auto it = llvm::find_if(range, [=](auto &arg) { return arg.name == name; });
return it != range.end() ? &*it : nullptr;
}
diff --git a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
index a693b0211247..fc15b2dcc1b0 100644
--- a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
@@ -119,7 +119,7 @@ static void emitModelDecl(OpInterface &interface, raw_ostream &os) {
// Provide a definition of the concrete op if this is non static.
if (!method.isStatic()) {
- os << " auto op = llvm::cast<ConcreteOp>(tablegen_opaque_op);\n"
+ os << " auto op = ::mlir::cast<ConcreteOp>(tablegen_opaque_op);\n"
<< " (void)op;\n";
}
@@ -146,7 +146,7 @@ static void emitTraitDecl(OpInterface &interface, raw_ostream &os,
StringRef interfaceName,
StringRef interfaceTraitsName) {
os << " template <typename ConcreteOp>\n "
- << llvm::formatv("struct {0}Trait : public OpInterface<{0},"
+ << llvm::formatv("struct {0}Trait : public ::mlir::OpInterface<{0},"
" detail::{1}>::Trait<ConcreteOp> {{\n",
interfaceName, interfaceTraitsName);
@@ -171,7 +171,7 @@ static void emitTraitDecl(OpInterface &interface, raw_ostream &os,
tblgen::FmtContext traitCtx;
traitCtx.withOp("op");
if (auto verify = interface.getVerify()) {
- os << " static LogicalResult verifyTrait(Operation* op) {\n"
+ os << " static ::mlir::LogicalResult verifyTrait(Operation* op) {\n"
<< std::string(tblgen::tgfmt(*verify, &traitCtx)) << "\n }\n";
}
if (auto extraTraitDecls = interface.getExtraTraitClassDeclaration())
@@ -197,10 +197,11 @@ static void emitInterfaceDecl(OpInterface &interface, raw_ostream &os) {
os << "};\n} // end namespace detail\n";
// Emit the main interface class declaration.
- os << llvm::formatv("class {0} : public OpInterface<{1}, detail::{2}> {\n"
- "public:\n"
- " using OpInterface<{1}, detail::{2}>::OpInterface;\n",
- interfaceName, interfaceName, interfaceTraitsName);
+ os << llvm::formatv(
+ "class {0} : public ::mlir::OpInterface<{1}, detail::{2}> {\n"
+ "public:\n"
+ " using ::mlir::OpInterface<{1}, detail::{2}>::OpInterface;\n",
+ interfaceName, interfaceName, interfaceTraitsName);
// Emit the derived trait for the interface.
emitTraitDecl(interface, os, interfaceName, interfaceTraitsName);
diff --git a/mlir/tools/mlir-tblgen/PassGen.cpp b/mlir/tools/mlir-tblgen/PassGen.cpp
index b662b434950e..f8998f09a436 100644
--- a/mlir/tools/mlir-tblgen/PassGen.cpp
+++ b/mlir/tools/mlir-tblgen/PassGen.cpp
@@ -42,10 +42,10 @@ class {0}Base : public {1} {
{0}Base(const {0}Base &) : {1}(::mlir::TypeID::get<DerivedT>()) {{}
/// Returns the command-line argument attached to this pass.
- llvm::StringRef getArgument() const override { return "{2}"; }
+ ::llvm::StringRef getArgument() const override { return "{2}"; }
/// Returns the derived pass name.
- llvm::StringRef getName() const override { return "{0}"; }
+ ::llvm::StringRef getName() const override { return "{0}"; }
/// Support isa/dyn_cast functionality for the derived pass class.
static bool classof(const ::mlir::Pass *pass) {{
@@ -63,13 +63,14 @@ class {0}Base : public {1} {
/// Emit the declarations for each of the pass options.
static void emitPassOptionDecls(const Pass &pass, raw_ostream &os) {
for (const PassOption &opt : pass.getOptions()) {
- os.indent(2) << "Pass::" << (opt.isListOption() ? "ListOption" : "Option");
+ os.indent(2) << "::mlir::Pass::"
+ << (opt.isListOption() ? "ListOption" : "Option");
- os << llvm::formatv("<{0}> {1}{{*this, \"{2}\", llvm::cl::desc(\"{3}\")",
+ os << llvm::formatv("<{0}> {1}{{*this, \"{2}\", ::llvm::cl::desc(\"{3}\")",
opt.getType(), opt.getCppVariableName(),
opt.getArgument(), opt.getDescription());
if (Optional<StringRef> defaultVal = opt.getDefaultValue())
- os << ", llvm::cl::init(" << defaultVal << ")";
+ os << ", ::llvm::cl::init(" << defaultVal << ")";
if (Optional<StringRef> additionalFlags = opt.getAdditionalFlags())
os << ", " << *additionalFlags;
os << "};\n";
@@ -79,9 +80,9 @@ static void emitPassOptionDecls(const Pass &pass, raw_ostream &os) {
/// Emit the declarations for each of the pass statistics.
static void emitPassStatisticDecls(const Pass &pass, raw_ostream &os) {
for (const PassStatistic &stat : pass.getStatistics()) {
- os << llvm::formatv(" Pass::Statistic {0}{{this, \"{1}\", \"{2}\"};\n",
- stat.getCppVariableName(), stat.getName(),
- stat.getDescription());
+ os << llvm::formatv(
+ " ::mlir::Pass::Statistic {0}{{this, \"{1}\", \"{2}\"};\n",
+ stat.getCppVariableName(), stat.getName(), stat.getDescription());
}
}
diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp
index 13498e06e54e..37af7d222753 100644
--- a/mlir/tools/mlir-tblgen/RewriterGen.cpp
+++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp
@@ -39,7 +39,8 @@ using llvm::RecordKeeper;
#define DEBUG_TYPE "mlir-tblgen-rewritergen"
namespace llvm {
-template <> struct format_provider<mlir::tblgen::Pattern::IdentifierLine> {
+template <>
+struct format_provider<mlir::tblgen::Pattern::IdentifierLine> {
static void format(const mlir::tblgen::Pattern::IdentifierLine &v,
raw_ostream &os, StringRef style) {
os << v.first << ":" << v.second;
@@ -489,9 +490,9 @@ void PatternEmitter::emit(StringRef rewriteName) {
auto locs = pattern.getLocation();
os << formatv("/* Generated from:\n\t{0:$[ instantiating\n\t]}\n*/\n",
make_range(locs.rbegin(), locs.rend()));
- os << formatv(R"(struct {0} : public RewritePattern {
- {0}(MLIRContext *context)
- : RewritePattern("{1}", {{)",
+ os << formatv(R"(struct {0} : public ::mlir::RewritePattern {
+ {0}(::mlir::MLIRContext *context)
+ : ::mlir::RewritePattern("{1}", {{)",
rewriteName, rootName);
// Sort result operators by name.
llvm::SmallVector<const Operator *, 4> sortedResultOps(resultOps.begin(),
@@ -506,8 +507,9 @@ void PatternEmitter::emit(StringRef rewriteName) {
// Emit matchAndRewrite() function.
os << R"(
- LogicalResult matchAndRewrite(Operation *op0,
- PatternRewriter &rewriter) const override {
+ ::mlir::LogicalResult
+ matchAndRewrite(::mlir::Operation *op0,
+ ::mlir::PatternRewriter &rewriter) const override {
)";
// Register all symbols bound in the source pattern.
@@ -526,7 +528,7 @@ void PatternEmitter::emit(StringRef rewriteName) {
}
// TODO(jpienaar): capture ops with consistent numbering so that it can be
// reused for fused loc.
- os.indent(4) << formatv("Operation *tblgen_ops[{0}];\n\n",
+ os.indent(4) << formatv("::mlir::Operation *tblgen_ops[{0}];\n\n",
pattern.getSourcePattern().getNumOps());
LLVM_DEBUG(
llvm::dbgs() << "done creating local variables for capturing matches\n");
@@ -606,7 +608,8 @@ void PatternEmitter::emitRewriteLogic() {
os.indent(4) << "rewriter.eraseOp(op0);\n";
} else {
// Process replacement result patterns.
- os.indent(4) << "SmallVector<Value, 4> tblgen_repl_values;\n";
+ os.indent(4)
+ << "::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values;\n";
for (int i = replStartIndex; i < numResultPatterns; ++i) {
DagNode resultTree = pattern.getResultPattern(i);
auto val = handleResultPattern(resultTree, offsets[i], 0);
@@ -619,7 +622,7 @@ void PatternEmitter::emitRewriteLogic() {
// TODO(b/147096809): Revisit the need for materializing a vector.
os << symbolInfoMap.getAllRangeUse(
val,
- " for (auto v : SmallVector<Value, 4>{ {0} }) {{ "
+ " for (auto v : ::llvm::SmallVector<::mlir::Value, 4>{ {0} }) {{ "
"tblgen_repl_values.push_back(v); }",
"\n");
}
@@ -697,7 +700,7 @@ std::string PatternEmitter::handleLocationDirective(DagNode tree) {
if (tree.getNumArgs() == 1) {
DagLeaf leaf = tree.getArgAsLeaf(0);
if (leaf.isStringAttr())
- return formatv("mlir::NameLoc::get(rewriter.getIdentifier(\"{0}\"), "
+ return formatv("::mlir::NameLoc::get(rewriter.getIdentifier(\"{0}\"), "
"rewriter.getContext())",
leaf.getStringAttr())
.str();
@@ -918,8 +921,8 @@ std::string PatternEmitter::handleOpCreation(DagNode tree, int resultIndex,
// Then prepare the result types. We need to specify the types for all
// results.
- os.indent(6) << formatv(
- "SmallVector<Type, 4> tblgen_types; (void)tblgen_types;\n");
+ os.indent(6) << formatv("::mlir::SmallVector<::mlir::Type, 4> tblgen_types; "
+ "(void)tblgen_types;\n");
int numResults = resultOp.getNumResults();
if (numResults != 0) {
for (int i = 0; i < numResults; ++i)
@@ -956,7 +959,8 @@ void PatternEmitter::createSeparateLocalVarsForOpArgs(
std::string varName;
if (operand->isVariadic()) {
varName = std::string(formatv("tblgen_values_{0}", valueIndex++));
- os.indent(6) << formatv("SmallVector<Value, 4> {0};\n", varName);
+ os.indent(6) << formatv("::mlir::SmallVector<::mlir::Value, 4> {0};\n",
+ varName);
std::string range;
if (node.isNestedDagArg(argIndex)) {
range = childNodeNames[argIndex];
@@ -970,7 +974,7 @@ void PatternEmitter::createSeparateLocalVarsForOpArgs(
varName);
} else {
varName = std::string(formatv("tblgen_value_{0}", valueIndex++));
- os.indent(6) << formatv("Value {0} = ", varName);
+ os.indent(6) << formatv("::mlir::Value {0} = ", varName);
if (node.isNestedDagArg(argIndex)) {
os << symbolInfoMap.getValueAndRangeUse(childNodeNames[argIndex]);
} else {
@@ -1039,10 +1043,10 @@ void PatternEmitter::createAggregateLocalVarsForOpArgs(
DagNode node, const ChildNodeIndexNameMap &childNodeNames) {
Operator &resultOp = node.getDialectOp(opMap);
- os.indent(6) << formatv(
- "SmallVector<Value, 4> tblgen_values; (void)tblgen_values;\n");
- os.indent(6) << formatv(
- "SmallVector<NamedAttribute, 4> tblgen_attrs; (void)tblgen_attrs;\n");
+ os.indent(6) << formatv("::mlir::SmallVector<::mlir::Value, 4> "
+ "tblgen_values; (void)tblgen_values;\n");
+ os.indent(6) << formatv("::mlir::SmallVector<::mlir::NamedAttribute, 4> "
+ "tblgen_attrs; (void)tblgen_attrs;\n");
const char *addAttrCmd =
"if (auto tmpAttr = {1}) "
diff --git a/mlir/tools/mlir-tblgen/StructsGen.cpp b/mlir/tools/mlir-tblgen/StructsGen.cpp
index 005757a62f37..cccacc0cad85 100644
--- a/mlir/tools/mlir-tblgen/StructsGen.cpp
+++ b/mlir/tools/mlir-tblgen/StructsGen.cpp
@@ -36,11 +36,11 @@ emitStructClass(const Record &structDef, StringRef structName,
StringRef description, raw_ostream &os) {
const char *structInfo = R"(
// {0}
-class {1} : public mlir::DictionaryAttr)";
+class {1} : public ::mlir::DictionaryAttr)";
const char *structInfoEnd = R"( {
public:
- using DictionaryAttr::DictionaryAttr;
- static bool classof(mlir::Attribute attr);
+ using ::mlir::DictionaryAttr::DictionaryAttr;
+ static bool classof(::mlir::Attribute attr);
)";
os << formatv(structInfo, description, structName) << structInfoEnd;
@@ -48,7 +48,7 @@ class {1} : public mlir::DictionaryAttr)";
// TblgenStruct::get(MLIRContext context, Type1 Field1, Type2 Field2, ...);
const char *getInfoDecl = " static {0} get(\n";
const char *getInfoDeclArg = " {0} {1},\n";
- const char *getInfoDeclEnd = " mlir::MLIRContext* context);\n\n";
+ const char *getInfoDeclEnd = " ::mlir::MLIRContext* context);\n\n";
os << llvm::formatv(getInfoDecl, structName);
@@ -112,7 +112,7 @@ static void emitFactoryDef(llvm::StringRef structName,
raw_ostream &os) {
const char *getInfoDecl = "{0} {0}::get(\n";
const char *getInfoDeclArg = " {0} {1},\n";
- const char *getInfoDeclEnd = " mlir::MLIRContext* context) {";
+ const char *getInfoDeclEnd = " ::mlir::MLIRContext* context) {";
os << llvm::formatv(getInfoDecl, structName);
@@ -125,19 +125,19 @@ static void emitFactoryDef(llvm::StringRef structName,
os << getInfoDeclEnd;
const char *fieldStart = R"(
- llvm::SmallVector<mlir::NamedAttribute, {0}> fields;
+ ::llvm::SmallVector<::mlir::NamedAttribute, {0}> fields;
)";
os << llvm::formatv(fieldStart, fields.size());
const char *getFieldInfo = R"(
assert({0});
- auto {0}_id = mlir::Identifier::get("{0}", context);
+ auto {0}_id = ::mlir::Identifier::get("{0}", context);
fields.emplace_back({0}_id, {0});
)";
const char *getFieldInfoOptional = R"(
if ({0}) {
- auto {0}_id = mlir::Identifier::get("{0}", context);
+ auto {0}_id = ::mlir::Identifier::get("{0}", context);
fields.emplace_back({0}_id, {0});
}
)";
@@ -150,7 +150,7 @@ static void emitFactoryDef(llvm::StringRef structName,
}
const char *getEndInfo = R"(
- Attribute dict = mlir::DictionaryAttr::get(fields, context);
+ ::mlir::Attribute dict = ::mlir::DictionaryAttr::get(fields, context);
return dict.dyn_cast<{0}>();
}
)";
@@ -161,12 +161,12 @@ static void emitClassofDef(llvm::StringRef structName,
llvm::ArrayRef<mlir::tblgen::StructFieldAttr> fields,
raw_ostream &os) {
const char *classofInfo = R"(
-bool {0}::classof(mlir::Attribute attr))";
+bool {0}::classof(::mlir::Attribute attr))";
const char *classofInfoHeader = R"(
if (!attr)
return false;
- auto derived = attr.dyn_cast<mlir::DictionaryAttr>();
+ auto derived = attr.dyn_cast<::mlir::DictionaryAttr>();
if (!derived)
return false;
int empty_optionals = 0;
@@ -212,7 +212,7 @@ emitAccessorDef(llvm::StringRef structName,
raw_ostream &os) {
const char *fieldInfo = R"(
{0} {2}::{1}() const {
- auto derived = this->cast<mlir::DictionaryAttr>();
+ auto derived = this->cast<::mlir::DictionaryAttr>();
auto {1} = derived.get("{1}");
assert({1} && "attribute not found.");
assert({1}.isa<{0}>() && "incorrect Attribute type found.");
@@ -221,7 +221,7 @@ emitAccessorDef(llvm::StringRef structName,
)";
const char *fieldInfoOptional = R"(
{0} {2}::{1}() const {
- auto derived = this->cast<mlir::DictionaryAttr>();
+ auto derived = this->cast<::mlir::DictionaryAttr>();
auto {1} = derived.get("{1}");
if (!{1})
return nullptr;
diff --git a/mlir/unittests/TableGen/EnumsGenTest.cpp b/mlir/unittests/TableGen/EnumsGenTest.cpp
index 0c3db73109d9..47f0910403b2 100644
--- a/mlir/unittests/TableGen/EnumsGenTest.cpp
+++ b/mlir/unittests/TableGen/EnumsGenTest.cpp
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include "mlir/Support/LLVM.h"
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/Optional.h"
-#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "gmock/gmock.h"
More information about the Mlir-commits
mailing list