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
//===----------------------------------------------------------------------===//
// 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
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<
// 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>
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>
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,
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.
class IsVectorOfRankPred<list<int> allowedRanks> :
And<[IsVectorTypePred,
Or<!foreach(allowedlength, allowedRanks,
- CPred<[{$_self.cast<VectorType>().getRank()
+ CPred<[{$_self.cast<::mlir::VectorType>().getRank()
== }]
# allowedlength>)>]>;
class IsVectorOfLengthPred<list<int> allowedLengths> :
And<[IsVectorTypePred,
Or<!foreach(allowedlength, allowedLengths,
- CPred<[{$_self.cast<VectorType>().getNumElements()
+ CPred<[{$_self.cast<::mlir::VectorType>().getNumElements()
== }]
# allowedlength>)>]>;
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]>,
And<[
containerPred,
Concat<
- "llvm::all_of(" # elementTypesCall # ", [](Type t) { return ",
+ "::llvm::all_of(" # elementTypesCall # ", [](Type t) { return ",
SubstLeaves<"$_self", "t", etype.predicate>,
"; })"
>
// 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">;
//===----------------------------------------------------------------------===//
// 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;
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)";
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
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 = ?;
}
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">;
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<
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<
// 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">;
// 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;
}
// 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";
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,
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
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.
// <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:
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> :
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.
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.
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">;
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>;
// 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> :
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";
}
// 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";
}
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";
}
// 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.
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)";
}
// 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()";
// 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)";
}
//===----------------------------------------------------------------------===//
}
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<
"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>;
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">;
//===----------------------------------------------------------------------===//
// 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.
// 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
// 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>>;
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.
// 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.
// 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
}
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";
// 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");
// 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
// ---
// 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">;
// 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
// ---
}
// 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
}
// 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));
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: }
}
// 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
// ---
}
// 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.
// ---
// 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.
// 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: };
}
// 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 different number of operands
// ---
}
// 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.
// ---
}
// 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);
}
// CHECK-LABEL: class GOp :
-// CHECK: static LogicalResult inferReturnTypes
+// CHECK: static ::mlir::LogicalResult inferReturnTypes
// Check that default builders can be suppressed.
// ---
// 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
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
[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
// 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);
}
// CHECK-LABEL: OpB::build
-// CHECK: ValueRange input
+// CHECK: ::mlir::ValueRange input
// CHECK-NOT: assert
// CHECK: odsState.addOperands(input);
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
}
// 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);
}
// 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", []> {
}
// 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);
}
// 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);
}
// 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", []> {
}
// CHECK-LABEL: void OpF::build
-// CHECK-SAME: ArrayRef<Type> x
+// CHECK-SAME: ::llvm::ArrayRef<::mlir::Type> x
// CHECK-NOT: assert
// CHECK: odsState.addTypes(x);
// 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);
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
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()});
[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
// 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", [
}
// 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", []> {
}
// 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", []> {
}
// 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", []> {
}
// 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", []> {
}
// 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", [
}
// 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"
// 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))))))
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());
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())
}
// 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";
}
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();
os << formatv(" .Case(\"{1}\", {0}::{2})\n", enumName, str,
makeIdentifier(symbol));
}
- os << " .Default(llvm::None);\n";
+ os << " .Default(::llvm::None);\n";
os << "}\n";
}
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";
}
// 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);
// 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.
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);
}))
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)
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";
}
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";
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()) {
// 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);
}
)";
// {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;
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) {
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";
}
// 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 =
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"))
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();";
}
}
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})");
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)");
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();";
}
}
// 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);
}
}
// 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()};",
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);
}
}
// 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;
}
// 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);
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);
// 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()),
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);
}
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();
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()";
}
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);
auto numResults = op.getNumResults();
resultTypeNames.reserve(numResults);
- paramList = "OpBuilder &odsBuilder, OperationState &";
+ paramList = "::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &";
paramList.append(builderOpState);
switch (typeParamKind) {
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;
}
// 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;
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 {
// 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("\"");
/// 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;
}
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);
}
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);
}
}
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.
// 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 ";
}
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();
FmtContext fctx;
fctx.withBuilder("odsBuilder");
- os << " Builder odsBuilder(context);\n";
+ os << " ::mlir::Builder odsBuilder(context);\n";
auto emitType =
[&](const tblgen::Operator::ArgOrType &type) -> OpMethodBody & {
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());
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");
}
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()))) "
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";
}
}
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"
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"))
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(),
}
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";
}
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");
}
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();
}
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");
/// {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))
)";
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();
)";
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();
/// {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();
///
/// {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))
///
/// {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();
)";
} 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";
}
}
<< "(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)) {
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();
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(),
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";
}
// 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";
});
// 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 << ")";
});
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.
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";
} 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";
/// 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;
}
// 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";
}
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);
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())
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);
{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) {{
/// 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";
/// 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());
}
}
#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;
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(),
// 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.
}
// 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");
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);
// 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");
}
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();
// 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)
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];
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 {
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}) "
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;
// 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);
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);
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});
}
)";
}
const char *getEndInfo = R"(
- Attribute dict = mlir::DictionaryAttr::get(fields, context);
+ ::mlir::Attribute dict = ::mlir::DictionaryAttr::get(fields, context);
return dict.dyn_cast<{0}>();
}
)";
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;
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.");
)";
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;
//
//===----------------------------------------------------------------------===//
+#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"