From 195730a6505ac352ae9347010ba701ab5267aad7 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Tue, 16 Nov 2021 17:21:15 +0000 Subject: [PATCH] [mlir][NFC] Replace references to Identifier with StringAttr This is part of the replacement of Identifier with StringAttr. Differential Revision: https://reviews.llvm.org/D113953 --- mlir/docs/DataLayout.md | 2 +- mlir/docs/Interfaces.md | 2 +- mlir/docs/Tutorials/DataFlowAnalysis.md | 2 +- mlir/examples/toy/Ch2/mlir/MLIRGen.cpp | 2 +- mlir/examples/toy/Ch3/mlir/MLIRGen.cpp | 2 +- mlir/examples/toy/Ch4/mlir/MLIRGen.cpp | 2 +- mlir/examples/toy/Ch5/mlir/MLIRGen.cpp | 2 +- mlir/examples/toy/Ch6/mlir/MLIRGen.cpp | 2 +- mlir/examples/toy/Ch7/mlir/MLIRGen.cpp | 2 +- mlir/include/mlir/CAPI/IR.h | 1 - .../Dialect/Affine/IR/AffineMemoryOpInterfaces.td | 2 +- mlir/include/mlir/Dialect/Affine/IR/AffineOps.h | 8 +- mlir/include/mlir/Dialect/Affine/IR/AffineOps.td | 4 +- mlir/include/mlir/Dialect/DLTI/DLTI.h | 2 +- .../mlir/Dialect/Linalg/Transforms/Transforms.h | 13 ++- mlir/include/mlir/IR/Attributes.h | 4 +- mlir/include/mlir/IR/Builders.h | 2 +- mlir/include/mlir/IR/BuiltinAttributes.td | 16 +-- mlir/include/mlir/IR/BuiltinLocationAttributes.td | 12 +-- mlir/include/mlir/IR/BuiltinTypes.h | 3 - mlir/include/mlir/IR/BuiltinTypes.td | 4 +- mlir/include/mlir/IR/FunctionSupport.h | 30 +++--- mlir/include/mlir/IR/OpBase.td | 2 +- mlir/include/mlir/IR/Operation.h | 18 ++-- mlir/include/mlir/IR/OperationSupport.h | 35 +++--- .../include/mlir/Interfaces/DataLayoutInterfaces.h | 4 +- .../mlir/Interfaces/DataLayoutInterfaces.td | 4 +- mlir/include/mlir/Pass/PassInstrumentation.h | 10 +- mlir/include/mlir/Pass/PassManager.h | 9 +- .../mlir/Target/LLVMIR/LLVMTranslationInterface.h | 3 +- mlir/lib/CAPI/IR/BuiltinAttributes.cpp | 2 +- mlir/lib/CAPI/IR/IR.cpp | 6 +- mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h | 4 +- .../Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp | 4 +- .../GPUToROCDL/LowerGpuOpsToROCDLOps.cpp | 4 +- mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp | 4 +- mlir/lib/Conversion/PDLToPDLInterp/Predicate.h | 6 +- .../Affine/Transforms/SimplifyAffineStructures.cpp | 2 +- mlir/lib/Dialect/Affine/Utils/Utils.cpp | 2 +- mlir/lib/Dialect/DLTI/DLTI.cpp | 20 ++-- .../Dialect/Linalg/Transforms/CodegenStrategy.cpp | 6 +- mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp | 4 +- mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp | 12 +-- .../Dialect/Linalg/Transforms/Vectorization.cpp | 8 +- mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp | 1 - mlir/lib/Dialect/Shape/IR/Shape.cpp | 2 +- mlir/lib/IR/AttributeDetail.h | 1 - mlir/lib/IR/Builders.cpp | 6 +- mlir/lib/IR/BuiltinAttributes.cpp | 10 +- mlir/lib/IR/BuiltinDialect.cpp | 2 +- mlir/lib/IR/BuiltinTypes.cpp | 2 +- mlir/lib/IR/Dialect.cpp | 2 +- mlir/lib/IR/Location.cpp | 1 - mlir/lib/IR/MLIRContext.cpp | 12 +-- mlir/lib/IR/Operation.cpp | 6 +- mlir/lib/IR/OperationSupport.cpp | 12 +-- mlir/lib/IR/SymbolTable.cpp | 16 +-- mlir/lib/IR/TypeDetail.h | 1 - mlir/lib/Interfaces/DataLayoutInterfaces.cpp | 14 +-- mlir/lib/Parser/AttributeParser.cpp | 10 +- mlir/lib/Parser/DialectSymbolParser.cpp | 4 +- mlir/lib/Parser/Lexer.cpp | 1 - mlir/lib/Parser/LocationParser.cpp | 4 +- mlir/lib/Pass/Pass.cpp | 26 ++--- mlir/lib/Pass/PassTiming.cpp | 4 +- mlir/lib/Rewrite/ByteCode.cpp | 13 +-- mlir/lib/Rewrite/ByteCode.h | 2 +- mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp | 2 +- .../Target/SPIRV/Deserialization/Deserializer.cpp | 4 +- mlir/lib/Transforms/LocationSnapshot.cpp | 6 +- .../lib/Dialect/Linalg/TestLinalgDistribution.cpp | 4 +- .../Dialect/Linalg/TestLinalgFusionTransforms.cpp | 72 ++++++------- .../lib/Dialect/Linalg/TestLinalgTransforms.cpp | 120 ++++++++++----------- mlir/test/lib/Dialect/Shape/TestShapeFunctions.cpp | 2 +- mlir/test/lib/Dialect/Test/TestDialect.cpp | 2 +- mlir/test/mlir-tblgen/op-attribute.td | 24 ++--- .../mlir-linalg-ods-yaml-gen.cpp | 2 +- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 8 +- mlir/tools/mlir-tblgen/RewriterGen.cpp | 4 +- mlir/tools/mlir-tblgen/StructsGen.cpp | 4 +- mlir/unittests/IR/AttributeTest.cpp | 7 +- mlir/unittests/IR/OperationSupportTest.cpp | 8 +- mlir/unittests/TableGen/OpBuildGen.cpp | 1 - mlir/unittests/TableGen/StructsGenTest.cpp | 9 +- mlir/utils/gdb-scripts/prettyprinters.py | 16 --- 85 files changed, 350 insertions(+), 385 deletions(-) diff --git a/mlir/docs/DataLayout.md b/mlir/docs/DataLayout.md index abf53e2..4ffbf03 100644 --- a/mlir/docs/DataLayout.md +++ b/mlir/docs/DataLayout.md @@ -102,7 +102,7 @@ conceptually a collection of key-value pairs called data layout specification _entries_. Data layout specification attributes implement the `DataLayoutSpecInterface`, described below. Each entry is itself an attribute that implements the `DataLayoutEntryInterface`. Entries have a key, either a -`Type` or an `Identifier`, and a value. Keys are used to associate entries with +`Type` or a `StringAttr`, and a value. Keys are used to associate entries with specific types or dialects: when handling a data layout properties request, a type or a dialect can only see the specification entries relevant to them and must go through the supplied `DataLayout` object for any recursive query. This diff --git a/mlir/docs/Interfaces.md b/mlir/docs/Interfaces.md index 7a6f783..30fb86c 100644 --- a/mlir/docs/Interfaces.md +++ b/mlir/docs/Interfaces.md @@ -327,7 +327,7 @@ operations by overriding the `getRegisteredInterfaceForOp` method : ```c++ void *TestDialect::getRegisteredInterfaceForOp(TypeID typeID, - Identifier opName) { + StringAttr opName) { if (typeID == TypeID::get()) { if (isSupported(opName)) return fallbackExampleOpInterface; diff --git a/mlir/docs/Tutorials/DataFlowAnalysis.md b/mlir/docs/Tutorials/DataFlowAnalysis.md index ee8d9cf..8265eff 100644 --- a/mlir/docs/Tutorials/DataFlowAnalysis.md +++ b/mlir/docs/Tutorials/DataFlowAnalysis.md @@ -137,7 +137,7 @@ struct MetadataLatticeValue { /// Our value represents the combined metadata, which is originally a /// DictionaryAttr, so we use a map. - DenseMap metadata; + DenseMap metadata; }; ``` diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp index 39b8681..e4df329 100644 --- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp @@ -93,7 +93,7 @@ private: /// Helper conversion for a Toy AST location to an MLIR location. mlir::Location loc(Location loc) { - return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line, + return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line, loc.col); } diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp index 39b8681..e4df329 100644 --- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp @@ -93,7 +93,7 @@ private: /// Helper conversion for a Toy AST location to an MLIR location. mlir::Location loc(Location loc) { - return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line, + return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line, loc.col); } diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp index 3b90fc2..add53ce 100644 --- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp @@ -93,7 +93,7 @@ private: /// Helper conversion for a Toy AST location to an MLIR location. mlir::Location loc(Location loc) { - return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line, + return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line, loc.col); } diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp index 3b90fc2..add53ce 100644 --- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp @@ -93,7 +93,7 @@ private: /// Helper conversion for a Toy AST location to an MLIR location. mlir::Location loc(Location loc) { - return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line, + return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line, loc.col); } diff --git a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp index 3b90fc2..add53ce 100644 --- a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp @@ -93,7 +93,7 @@ private: /// Helper conversion for a Toy AST location to an MLIR location. mlir::Location loc(Location loc) { - return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line, + return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line, loc.col); } diff --git a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp index f4e8ced..23cacb6 100644 --- a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp @@ -113,7 +113,7 @@ private: /// Helper conversion for a Toy AST location to an MLIR location. mlir::Location loc(Location loc) { - return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line, + return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line, loc.col); } diff --git a/mlir/include/mlir/CAPI/IR.h b/mlir/include/mlir/CAPI/IR.h index 7fd4750..af7ae89 100644 --- a/mlir/include/mlir/CAPI/IR.h +++ b/mlir/include/mlir/CAPI/IR.h @@ -17,7 +17,6 @@ #include "mlir/CAPI/Wrap.h" #include "mlir/IR/BuiltinOps.h" -#include "mlir/IR/Identifier.h" #include "mlir/IR/MLIRContext.h" #include "mlir/IR/Operation.h" diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.td b/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.td index 29a379c..8a4c0f6 100644 --- a/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.td +++ b/mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.td @@ -167,7 +167,7 @@ def AffineMapAccessInterface : OpInterface<"AffineMapAccessInterface"> { ConcreteOp op = cast(this->getOperation()); assert(memref == op.getMemRef() && "Expected memref argument to match memref operand"); - return {Identifier::get(op.getMapAttrName(), op.getContext()), + return {StringAttr::get(op.getContext(), op.getMapAttrName()), op.getAffineMapAttr()}; }] >, diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h index eaab9ca..06e8911 100644 --- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h +++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h @@ -188,14 +188,14 @@ public: /// Returns the AffineMapAttr associated with 'memref'. NamedAttribute getAffineMapAttrForMemRef(Value memref) { if (memref == getSrcMemRef()) - return {Identifier::get(getSrcMapAttrName(), getContext()), + return {StringAttr::get(getContext(), getSrcMapAttrName()), getSrcMapAttr()}; if (memref == getDstMemRef()) - return {Identifier::get(getDstMapAttrName(), getContext()), + return {StringAttr::get(getContext(), getDstMapAttrName()), getDstMapAttr()}; assert(memref == getTagMemRef() && "DmaStartOp expected source, destination or tag memref"); - return {Identifier::get(getTagMapAttrName(), getContext()), + return {StringAttr::get(getContext(), getTagMapAttrName()), getTagMapAttr()}; } @@ -303,7 +303,7 @@ public: /// associated with 'memref'. NamedAttribute getAffineMapAttrForMemRef(Value memref) { assert(memref == getTagMemRef()); - return {Identifier::get(getTagMapAttrName(), getContext()), + return {StringAttr::get(getContext(), getTagMapAttrName()), getTagMapAttr()}; } diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td index c8d3f57..c041154 100644 --- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td +++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td @@ -309,7 +309,7 @@ def AffineForOp : Affine_Op<"for", void setStep(int64_t step) { assert(step > 0 && "step has to be a positive integer constant"); auto *context = getLowerBoundMap().getContext(); - (*this)->setAttr(Identifier::get(getStepAttrName(), context), + (*this)->setAttr(StringAttr::get(context, getStepAttrName()), IntegerAttr::get(IndexType::get(context), step)); } @@ -815,7 +815,7 @@ def AffinePrefetchOp : Affine_Op<"prefetch", NamedAttribute getAffineMapAttrForMemRef(Value mref) { assert(mref == memref() && "Expected mref argument to match memref operand"); - return {Identifier::get(getMapAttrName(), getContext()), + return {StringAttr::get(getContext(), getMapAttrName()), getAffineMapAttr()}; } diff --git a/mlir/include/mlir/Dialect/DLTI/DLTI.h b/mlir/include/mlir/Dialect/DLTI/DLTI.h index c80b45b..1aa9ab5 100644 --- a/mlir/include/mlir/Dialect/DLTI/DLTI.h +++ b/mlir/include/mlir/Dialect/DLTI/DLTI.h @@ -41,7 +41,7 @@ public: constexpr const static llvm::StringLiteral kAttrKeyword = "dl_entry"; /// Returns the entry with the given key and value. - static DataLayoutEntryAttr get(Identifier key, Attribute value); + static DataLayoutEntryAttr get(StringAttr key, Attribute value); static DataLayoutEntryAttr get(Type key, Attribute value); /// Returns the key of this entry. diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h index 6b816f9..8099fe9 100644 --- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h @@ -17,7 +17,6 @@ #include "mlir/Dialect/Utils/StaticValueUtils.h" #include "mlir/Dialect/Vector/VectorTransforms.h" #include "mlir/Dialect/X86Vector/Transforms.h" -#include "mlir/IR/Identifier.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Transforms/Bufferize.h" #include "llvm/ADT/SmallBitVector.h" @@ -426,12 +425,12 @@ struct LinalgTransformationFilter { using FilterFunction = std::function; explicit LinalgTransformationFilter( - ArrayRef matchDisjunction = {}, - Optional replacement = None); + ArrayRef matchDisjunction = {}, + Optional replacement = None); explicit LinalgTransformationFilter( - FilterFunction f, ArrayRef matchDisjunction = {}, - Optional replacement = None); + FilterFunction f, ArrayRef matchDisjunction = {}, + Optional replacement = None); LinalgTransformationFilter(LinalgTransformationFilter &&) = default; LinalgTransformationFilter(const LinalgTransformationFilter &) = default; @@ -456,8 +455,8 @@ struct LinalgTransformationFilter { private: SmallVector filters; - SmallVector matchDisjunction; - Optional replacement; + SmallVector matchDisjunction; + Optional replacement; /// When set to true, if the attribute is not set, it will be treated as /// a match. Default is false. bool matchByDefault; diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h index 74a4405a..3cacd67 100644 --- a/mlir/include/mlir/IR/Attributes.h +++ b/mlir/include/mlir/IR/Attributes.h @@ -136,10 +136,10 @@ inline ::llvm::hash_code hash_value(Attribute arg) { // NamedAttribute //===----------------------------------------------------------------------===// -/// NamedAttribute is combination of a name, represented by an Identifier, and a +/// NamedAttribute is combination of a name, represented by a StringAttr, and a /// value, represented by an Attribute. The attribute pointer should always be /// non-null. -using NamedAttribute = std::pair; +using NamedAttribute = std::pair; bool operator<(const NamedAttribute &lhs, const NamedAttribute &rhs); bool operator<(const NamedAttribute &lhs, StringRef rhs); diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h index 9e26c31..d0e12b7 100644 --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -53,7 +53,7 @@ public: MLIRContext *getContext() const { return context; } - Identifier getIdentifier(const Twine &str); + StringAttr getIdentifier(const Twine &str); // Locations. Location getUnknownLoc(); diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td index a0393df..724120a 100644 --- a/mlir/include/mlir/IR/BuiltinAttributes.td +++ b/mlir/include/mlir/IR/BuiltinAttributes.td @@ -379,15 +379,15 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary", [ /// Return the specified attribute if present, null otherwise. Attribute get(StringRef name) const; - Attribute get(Identifier name) const; + Attribute get(StringAttr name) const; /// Return the specified named attribute if present, None otherwise. Optional getNamed(StringRef name) const; - Optional getNamed(Identifier name) const; + Optional getNamed(StringAttr name) const; /// Return whether the specified attribute is present. bool contains(StringRef name) const; - bool contains(Identifier name) const; + bool contains(StringAttr name) const; /// Support range iteration. using iterator = llvm::ArrayRef::iterator; @@ -641,11 +641,11 @@ def Builtin_OpaqueAttr : Builtin_Attr<"Opaque"> { #dialect<"opaque attribute data"> ``` }]; - let parameters = (ins "Identifier":$dialectNamespace, + let parameters = (ins "StringAttr":$dialectNamespace, StringRefParameter<"">:$attrData, AttributeSelfTypeParameter<"">:$type); let builders = [ - AttrBuilderWithInferredContext<(ins "Identifier":$dialect, + AttrBuilderWithInferredContext<(ins "StringAttr":$dialect, "StringRef":$attrData, "Type":$type), [{ return $_get(dialect.getContext(), dialect, attrData, type); @@ -688,11 +688,11 @@ def Builtin_OpaqueElementsAttr : Builtin_Attr< // TODO: Provide a way to avoid copying content of large opaque // tensors This will likely require a new reference attribute kind. - let parameters = (ins "Identifier":$dialect, + let parameters = (ins "StringAttr":$dialect, StringRefParameter<"">:$value, AttributeSelfTypeParameter<"", "ShapedType">:$type); let builders = [ - AttrBuilderWithInferredContext<(ins "Identifier":$dialect, + AttrBuilderWithInferredContext<(ins "StringAttr":$dialect, "ShapedType":$type, "StringRef":$value), [{ return $_get(dialect.getContext(), dialect, value, type); @@ -701,7 +701,7 @@ def Builtin_OpaqueElementsAttr : Builtin_Attr< "ShapedType":$type, "StringRef":$value), [{ MLIRContext *ctxt = dialect->getContext(); - Identifier dialectName = Identifier::get(dialect->getNamespace(), ctxt); + StringAttr dialectName = StringAttr::get(ctxt, dialect->getNamespace()); return $_get(ctxt, dialectName, value, type); }]> ]; diff --git a/mlir/include/mlir/IR/BuiltinLocationAttributes.td b/mlir/include/mlir/IR/BuiltinLocationAttributes.td index 3858b11..535016b 100644 --- a/mlir/include/mlir/IR/BuiltinLocationAttributes.td +++ b/mlir/include/mlir/IR/BuiltinLocationAttributes.td @@ -81,10 +81,10 @@ def FileLineColLoc : Builtin_LocationAttr<"FileLineColLoc"> { loc("mysource.cc":10:8) ``` }]; - let parameters = (ins "Identifier":$filename, "unsigned":$line, + let parameters = (ins "StringAttr":$filename, "unsigned":$line, "unsigned":$column); let builders = [ - AttrBuilderWithInferredContext<(ins "Identifier":$filename, + AttrBuilderWithInferredContext<(ins "StringAttr":$filename, "unsigned":$line, "unsigned":$column), [{ return $_get(filename.getContext(), filename, line, column); @@ -92,7 +92,7 @@ def FileLineColLoc : Builtin_LocationAttr<"FileLineColLoc"> { AttrBuilder<(ins "StringRef":$filename, "unsigned":$line, "unsigned":$column), [{ return $_get($_ctxt, - Identifier::get(filename.empty() ? "-" : filename, $_ctxt), + StringAttr::get($_ctxt, filename.empty() ? "-" : filename), line, column); }]> ]; @@ -161,13 +161,13 @@ def NameLoc : Builtin_LocationAttr<"NameLoc"> { loc("CSE"("mysource.cc":10:8)) ``` }]; - let parameters = (ins "Identifier":$name, "Location":$childLoc); + let parameters = (ins "StringAttr":$name, "Location":$childLoc); let builders = [ - AttrBuilderWithInferredContext<(ins "Identifier":$name, + AttrBuilderWithInferredContext<(ins "StringAttr":$name, "Location":$childLoc), [{ return $_get(name.getContext(), name, childLoc); }]>, - AttrBuilderWithInferredContext<(ins "Identifier":$name), [{ + AttrBuilderWithInferredContext<(ins "StringAttr":$name), [{ return $_get(name.getContext(), name, UnknownLoc::get(name.getContext())); }]> diff --git a/mlir/include/mlir/IR/BuiltinTypes.h b/mlir/include/mlir/IR/BuiltinTypes.h index 82cc584..b4ce23a 100644 --- a/mlir/include/mlir/IR/BuiltinTypes.h +++ b/mlir/include/mlir/IR/BuiltinTypes.h @@ -25,9 +25,6 @@ class IntegerType; class StringAttr; class TypeRange; -// TODO: Remove this when all usages have been replaced with StringAttr. -using Identifier = StringAttr; - //===----------------------------------------------------------------------===// // FloatType //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/IR/BuiltinTypes.td b/mlir/include/mlir/IR/BuiltinTypes.td index c38a9c4..4157719 100644 --- a/mlir/include/mlir/IR/BuiltinTypes.td +++ b/mlir/include/mlir/IR/BuiltinTypes.td @@ -600,13 +600,13 @@ def Builtin_Opaque : Builtin_Type<"Opaque"> { ``` }]; let parameters = (ins - "Identifier":$dialectNamespace, + "StringAttr":$dialectNamespace, StringRefParameter<"">:$typeData ); let builders = [ TypeBuilderWithInferredContext<(ins - "Identifier":$dialectNamespace, CArg<"StringRef", "{}">:$typeData + "StringAttr":$dialectNamespace, CArg<"StringRef", "{}">:$typeData ), [{ return $_get(dialectNamespace.getContext(), dialectNamespace, typeData); }]> diff --git a/mlir/include/mlir/IR/FunctionSupport.h b/mlir/include/mlir/IR/FunctionSupport.h index 51a3f9d..3add909 100644 --- a/mlir/include/mlir/IR/FunctionSupport.h +++ b/mlir/include/mlir/IR/FunctionSupport.h @@ -396,7 +396,7 @@ public: /// Return the specified attribute, if present, for the argument at 'index', /// null otherwise. - Attribute getArgAttr(unsigned index, Identifier name) { + Attribute getArgAttr(unsigned index, StringAttr name) { auto argDict = getArgAttrDict(index); return argDict ? argDict.get(name) : nullptr; } @@ -406,7 +406,7 @@ public: } template - AttrClass getArgAttrOfType(unsigned index, Identifier name) { + AttrClass getArgAttrOfType(unsigned index, StringAttr name) { return getArgAttr(index, name).template dyn_cast_or_null(); } template @@ -436,19 +436,19 @@ public: /// If the an attribute exists with the specified name, change it to the new /// value. Otherwise, add a new attribute with the specified name/value. - void setArgAttr(unsigned index, Identifier name, Attribute value); + void setArgAttr(unsigned index, StringAttr name, Attribute value); void setArgAttr(unsigned index, StringRef name, Attribute value) { - setArgAttr(index, Identifier::get(name, this->getOperation()->getContext()), + setArgAttr(index, StringAttr::get(this->getOperation()->getContext(), name), value); } /// Remove the attribute 'name' from the argument at 'index'. Return the /// attribute that was erased, or nullptr if there was no attribute with such /// name. - Attribute removeArgAttr(unsigned index, Identifier name); + Attribute removeArgAttr(unsigned index, StringAttr name); Attribute removeArgAttr(unsigned index, StringRef name) { return removeArgAttr( - index, Identifier::get(name, this->getOperation()->getContext())); + index, StringAttr::get(this->getOperation()->getContext(), name)); } //===--------------------------------------------------------------------===// @@ -485,7 +485,7 @@ public: /// Return the specified attribute, if present, for the result at 'index', /// null otherwise. - Attribute getResultAttr(unsigned index, Identifier name) { + Attribute getResultAttr(unsigned index, StringAttr name) { auto argDict = getResultAttrDict(index); return argDict ? argDict.get(name) : nullptr; } @@ -495,7 +495,7 @@ public: } template - AttrClass getResultAttrOfType(unsigned index, Identifier name) { + AttrClass getResultAttrOfType(unsigned index, StringAttr name) { return getResultAttr(index, name).template dyn_cast_or_null(); } template @@ -525,17 +525,17 @@ public: /// If the an attribute exists with the specified name, change it to the new /// value. Otherwise, add a new attribute with the specified name/value. - void setResultAttr(unsigned index, Identifier name, Attribute value); + void setResultAttr(unsigned index, StringAttr name, Attribute value); void setResultAttr(unsigned index, StringRef name, Attribute value) { setResultAttr(index, - Identifier::get(name, this->getOperation()->getContext()), + StringAttr::get(this->getOperation()->getContext(), name), value); } /// Remove the attribute 'name' from the result at 'index'. Return the /// attribute that was erased, or nullptr if there was no attribute with such /// name. - Attribute removeResultAttr(unsigned index, Identifier name); + Attribute removeResultAttr(unsigned index, StringAttr name); protected: /// Returns the dictionary attribute corresponding to the argument at 'index'. @@ -718,7 +718,7 @@ void FunctionLike::setArgAttrs(unsigned index, /// If the an attribute exists with the specified name, change it to the new /// value. Otherwise, add a new attribute with the specified name/value. template -void FunctionLike::setArgAttr(unsigned index, Identifier name, +void FunctionLike::setArgAttr(unsigned index, StringAttr name, Attribute value) { NamedAttrList attributes(getArgAttrDict(index)); Attribute oldValue = attributes.set(name, value); @@ -731,7 +731,7 @@ void FunctionLike::setArgAttr(unsigned index, Identifier name, /// Remove the attribute 'name' from the argument at 'index'. template Attribute FunctionLike::removeArgAttr(unsigned index, - Identifier name) { + StringAttr name) { // Build an attribute list and remove the attribute at 'name'. NamedAttrList attributes(getArgAttrDict(index)); Attribute removedAttr = attributes.erase(name); @@ -770,7 +770,7 @@ void FunctionLike::setResultAttrs(unsigned index, /// If the an attribute exists with the specified name, change it to the new /// value. Otherwise, add a new attribute with the specified name/value. template -void FunctionLike::setResultAttr(unsigned index, Identifier name, +void FunctionLike::setResultAttr(unsigned index, StringAttr name, Attribute value) { NamedAttrList attributes(getResultAttrDict(index)); Attribute oldAttr = attributes.set(name, value); @@ -783,7 +783,7 @@ void FunctionLike::setResultAttr(unsigned index, Identifier name, /// Remove the attribute 'name' from the result at 'index'. template Attribute FunctionLike::removeResultAttr(unsigned index, - Identifier name) { + StringAttr name) { // Build an attribute list and remove the attribute at 'name'. NamedAttrList attributes(getResultAttrDict(index)); Attribute removedAttr = attributes.erase(name); diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index b234dbe..1398bd7 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -549,7 +549,7 @@ class OpaqueType : Type, summary, "::mlir::OpaqueType">, BuildableType<"::mlir::OpaqueType::get(" - "$_builder.getIdentifier(\"" # dialect # "\"), \"" + "$_builder.getStringAttr(\"" # dialect # "\"), \"" # name # "\")">; // Function Type diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index 15f8e6b..112284a 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -320,19 +320,21 @@ public: } /// Return the specified attribute if present, null otherwise. - Attribute getAttr(Identifier name) { return attrs.get(name); } + Attribute getAttr(StringAttr name) { return attrs.get(name); } Attribute getAttr(StringRef name) { return attrs.get(name); } - template AttrClass getAttrOfType(Identifier name) { + template + AttrClass getAttrOfType(StringAttr name) { return getAttr(name).dyn_cast_or_null(); } - template AttrClass getAttrOfType(StringRef name) { + template + AttrClass getAttrOfType(StringRef name) { return getAttr(name).dyn_cast_or_null(); } /// Return true if the operation has an attribute with the provided name, /// false otherwise. - bool hasAttr(Identifier name) { return attrs.contains(name); } + bool hasAttr(StringAttr name) { return attrs.contains(name); } bool hasAttr(StringRef name) { return attrs.contains(name); } template bool hasAttrOfType(NameT &&name) { @@ -342,19 +344,19 @@ public: /// If the an attribute exists with the specified name, change it to the new /// value. Otherwise, add a new attribute with the specified name/value. - void setAttr(Identifier name, Attribute value) { + void setAttr(StringAttr name, Attribute value) { NamedAttrList attributes(attrs); if (attributes.set(name, value) != value) attrs = attributes.getDictionary(getContext()); } void setAttr(StringRef name, Attribute value) { - setAttr(Identifier::get(name, getContext()), value); + setAttr(StringAttr::get(getContext(), name), value); } /// Remove the attribute with the specified name if it exists. Return the /// attribute that was erased, or nullptr if there was no attribute with such /// name. - Attribute removeAttr(Identifier name) { + Attribute removeAttr(StringAttr name) { NamedAttrList attributes(attrs); Attribute removedAttr = attributes.erase(name); if (removedAttr) @@ -362,7 +364,7 @@ public: return removedAttr; } Attribute removeAttr(StringRef name) { - return removeAttr(Identifier::get(name, getContext())); + return removeAttr(StringAttr::get(getContext(), name)); } /// A utility iterator that filters out non-dialect attributes. diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h index 887306f..a18d2af 100644 --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -14,9 +14,8 @@ #ifndef MLIR_IR_OPERATION_SUPPORT_H #define MLIR_IR_OPERATION_SUPPORT_H -#include "mlir/IR/Attributes.h" #include "mlir/IR/BlockSupport.h" -#include "mlir/IR/Identifier.h" +#include "mlir/IR/BuiltinAttributes.h" #include "mlir/IR/Location.h" #include "mlir/IR/TypeRange.h" #include "mlir/IR/Types.h" @@ -82,7 +81,7 @@ public: llvm::unique_function; /// This is the name of the operation. - const Identifier name; + const StringAttr name; /// This is the dialect that this operation belongs to. Dialect &dialect; @@ -207,7 +206,7 @@ public: /// greatly simplifying the cost and complexity of attribute usage produced by /// the generator. /// - ArrayRef getAttributeNames() const { return attributeNames; } + ArrayRef getAttributeNames() const { return attributeNames; } private: AbstractOperation(StringRef name, Dialect &dialect, TypeID typeID, @@ -217,7 +216,7 @@ private: FoldHookFn &&foldHook, GetCanonicalizationPatternsFn &&getCanonicalizationPatterns, detail::InterfaceMap &&interfaceMap, HasTraitFn &&hasTrait, - ArrayRef attrNames); + ArrayRef attrNames); /// Give Op access to lookupMutable. template class... Traits> @@ -242,7 +241,7 @@ private: /// A list of attribute names registered to this operation in identifier form. /// This allows for operation classes to use identifiers for attribute /// lookup/creation/etc., as opposed to strings. - ArrayRef attributeNames; + ArrayRef attributeNames; }; //===----------------------------------------------------------------------===// @@ -288,12 +287,12 @@ std::pair findAttrSorted(IteratorT first, IteratorT last, return {first, false}; } -/// Identifier lookups on large attribute lists will switch to string binary +/// StringAttr lookups on large attribute lists will switch to string binary /// search. String binary searches become significantly faster than linear scans /// with the identifier when the attribute list becomes very large. template std::pair findAttrSorted(IteratorT first, IteratorT last, - Identifier name) { + StringAttr name) { constexpr unsigned kSmallAttributeList = 16; if (std::distance(first, last) > kSmallAttributeList) return findAttrSorted(first, last, name.strref()); @@ -332,7 +331,7 @@ public: void append(StringRef name, Attribute attr); /// Add an attribute with the specified name. - void append(Identifier name, Attribute attr) { + void append(StringAttr name, Attribute attr) { append(NamedAttribute(name, attr)); } @@ -384,24 +383,24 @@ public: ArrayRef getAttrs() const; /// Return the specified attribute if present, null otherwise. - Attribute get(Identifier name) const; + Attribute get(StringAttr name) const; Attribute get(StringRef name) const; /// Return the specified named attribute if present, None otherwise. Optional getNamed(StringRef name) const; - Optional getNamed(Identifier name) const; + Optional getNamed(StringAttr name) const; /// If the an attribute exists with the specified name, change it to the new /// value. Otherwise, add a new attribute with the specified name/value. /// Returns the previous attribute value of `name`, or null if no /// attribute previously existed with `name`. - Attribute set(Identifier name, Attribute value); + Attribute set(StringAttr name, Attribute value); Attribute set(StringRef name, Attribute value); /// Erase the attribute with the given name from the list. Return the /// attribute that was erased, or nullptr if there was no attribute with such /// name. - Attribute erase(Identifier name); + Attribute erase(StringAttr name); Attribute erase(StringRef name); iterator begin() { return attrs.begin(); } @@ -443,7 +442,7 @@ private: class OperationName { public: using RepresentationUnion = - PointerUnion; + PointerUnion; OperationName(AbstractOperation *op) : representation(op) {} OperationName(StringRef name, MLIRContext *context); @@ -456,7 +455,7 @@ public: Dialect *getDialect() const { if (const auto *abstractOp = getAbstractOperation()) return &abstractOp->dialect; - return representation.get().getReferencedDialect(); + return representation.get().getReferencedDialect(); } /// Return the operation name with dialect name stripped, if it has one. @@ -466,7 +465,7 @@ public: StringRef getStringRef() const; /// Return the name of this operation as an identifier. This always succeeds. - Identifier getIdentifier() const; + StringAttr getIdentifier() const; /// If this operation has a registered operation description, return it. /// Otherwise return null. @@ -549,11 +548,11 @@ public: /// Add an attribute with the specified name. void addAttribute(StringRef name, Attribute attr) { - addAttribute(Identifier::get(name, getContext()), attr); + addAttribute(StringAttr::get(getContext(), name), attr); } /// Add an attribute with the specified name. - void addAttribute(Identifier name, Attribute attr) { + void addAttribute(StringAttr name, Attribute attr) { attributes.append(name, attr); } diff --git a/mlir/include/mlir/Interfaces/DataLayoutInterfaces.h b/mlir/include/mlir/Interfaces/DataLayoutInterfaces.h index 84fee54..6d214ed 100644 --- a/mlir/include/mlir/Interfaces/DataLayoutInterfaces.h +++ b/mlir/include/mlir/Interfaces/DataLayoutInterfaces.h @@ -22,7 +22,7 @@ namespace mlir { class DataLayout; class DataLayoutEntryInterface; -using DataLayoutEntryKey = llvm::PointerUnion; +using DataLayoutEntryKey = llvm::PointerUnion; // Using explicit SmallVector size because we cannot infer the size from the // forward declaration, and we need the typedef in the actual declaration. using DataLayoutEntryList = llvm::SmallVector; @@ -65,7 +65,7 @@ DataLayoutEntryList filterEntriesForType(DataLayoutEntryListRef entries, /// Given a list of data layout entries, returns the entry that has the given /// identifier as key, if such an entry exists in the list. DataLayoutEntryInterface -filterEntryForIdentifier(DataLayoutEntryListRef entries, Identifier id); +filterEntryForIdentifier(DataLayoutEntryListRef entries, StringAttr id); /// Verifies that the operation implementing the data layout interface, or a /// module operation, is valid. This calls the verifier of the spec attribute diff --git a/mlir/include/mlir/Interfaces/DataLayoutInterfaces.td b/mlir/include/mlir/Interfaces/DataLayoutInterfaces.td index fc3d6a8..0ca0f9e 100644 --- a/mlir/include/mlir/Interfaces/DataLayoutInterfaces.td +++ b/mlir/include/mlir/Interfaces/DataLayoutInterfaces.td @@ -126,7 +126,7 @@ def DataLayoutSpecInterface : AttrInterface<"DataLayoutSpecInterface"> { "present.", /*retTy=*/"::mlir::DataLayoutEntryInterface", /*methodName=*/"getSpecForIdentifier", - /*args=*/(ins "::mlir::Identifier":$identifier), + /*args=*/(ins "::mlir::StringAttr":$identifier), /*methodBody=*/"", /*defaultImplementation=*/[{ return ::mlir::detail::filterEntryForIdentifier($_attr.getEntries(), @@ -159,7 +159,7 @@ def DataLayoutSpecInterface : AttrInterface<"DataLayoutSpecInterface"> { /// method directly. void bucketEntriesByType( ::llvm::DenseMap<::mlir::TypeID, ::mlir::DataLayoutEntryList> &types, - ::llvm::DenseMap<::mlir::Identifier, + ::llvm::DenseMap<::mlir::StringAttr, ::mlir::DataLayoutEntryInterface> &ids); }]; } diff --git a/mlir/include/mlir/Pass/PassInstrumentation.h b/mlir/include/mlir/Pass/PassInstrumentation.h index baf230f..88c8516 100644 --- a/mlir/include/mlir/Pass/PassInstrumentation.h +++ b/mlir/include/mlir/Pass/PassInstrumentation.h @@ -9,7 +9,7 @@ #ifndef MLIR_PASS_PASSINSTRUMENTATION_H_ #define MLIR_PASS_PASSINSTRUMENTATION_H_ -#include "mlir/IR/Identifier.h" +#include "mlir/IR/BuiltinAttributes.h" #include "mlir/Support/LLVM.h" #include "mlir/Support/TypeID.h" @@ -43,13 +43,13 @@ public: /// A callback to run before a pass pipeline is executed. This function takes /// the name of the operation type being operated on, and information related /// to the parent that spawned this pipeline. - virtual void runBeforePipeline(Identifier name, + virtual void runBeforePipeline(StringAttr name, const PipelineParentInfo &parentInfo) {} /// A callback to run after a pass pipeline has executed. This function takes /// the name of the operation type being operated on, and information related /// to the parent that spawned this pipeline. - virtual void runAfterPipeline(Identifier name, + virtual void runAfterPipeline(StringAttr name, const PipelineParentInfo &parentInfo) {} /// A callback to run before a pass is executed. This function takes a pointer @@ -90,12 +90,12 @@ public: /// See PassInstrumentation::runBeforePipeline for details. void - runBeforePipeline(Identifier name, + runBeforePipeline(StringAttr name, const PassInstrumentation::PipelineParentInfo &parentInfo); /// See PassInstrumentation::runAfterPipeline for details. void - runAfterPipeline(Identifier name, + runAfterPipeline(StringAttr name, const PassInstrumentation::PipelineParentInfo &parentInfo); /// See PassInstrumentation::runBeforePass for details. diff --git a/mlir/include/mlir/Pass/PassManager.h b/mlir/include/mlir/Pass/PassManager.h index 9e68b90..0846888 100644 --- a/mlir/include/mlir/Pass/PassManager.h +++ b/mlir/include/mlir/Pass/PassManager.h @@ -34,9 +34,6 @@ class PassInstrumentation; class PassInstrumentor; class StringAttr; -// TODO: Remove this when all usages have been replaced with StringAttr. -using Identifier = StringAttr; - namespace detail { struct OpPassManagerImpl; class OpToOpPassAdaptor; @@ -54,7 +51,7 @@ struct PassExecutionState; class OpPassManager { public: enum class Nesting { Implicit, Explicit }; - OpPassManager(Identifier name, Nesting nesting = Nesting::Explicit); + OpPassManager(StringAttr name, Nesting nesting = Nesting::Explicit); OpPassManager(StringRef name, Nesting nesting = Nesting::Explicit); OpPassManager(OpPassManager &&rhs); OpPassManager(const OpPassManager &rhs); @@ -78,7 +75,7 @@ public: /// Nest a new operation pass manager for the given operation kind under this /// pass manager. - OpPassManager &nest(Identifier nestedName); + OpPassManager &nest(StringAttr nestedName); OpPassManager &nest(StringRef nestedName); template OpPassManager &nest() { return nest(OpT::getOperationName()); @@ -101,7 +98,7 @@ public: size_t size() const; /// Return the operation name that this pass manager operates on. - Identifier getOpName(MLIRContext &context) const; + StringAttr getOpName(MLIRContext &context) const; /// Return the operation name that this pass manager operates on. StringRef getOpName() const; diff --git a/mlir/include/mlir/Target/LLVMIR/LLVMTranslationInterface.h b/mlir/include/mlir/Target/LLVMIR/LLVMTranslationInterface.h index beabfa4..875c799 100644 --- a/mlir/include/mlir/Target/LLVMIR/LLVMTranslationInterface.h +++ b/mlir/include/mlir/Target/LLVMIR/LLVMTranslationInterface.h @@ -13,9 +13,8 @@ #ifndef MLIR_TARGET_LLVMIR_LLVMTRANSLATIONINTERFACE_H #define MLIR_TARGET_LLVMIR_LLVMTRANSLATIONINTERFACE_H -#include "mlir/IR/Attributes.h" +#include "mlir/IR/BuiltinAttributes.h" #include "mlir/IR/DialectInterface.h" -#include "mlir/IR/Identifier.h" #include "mlir/Support/LogicalResult.h" namespace llvm { diff --git a/mlir/lib/CAPI/IR/BuiltinAttributes.cpp b/mlir/lib/CAPI/IR/BuiltinAttributes.cpp index 7ce4283..5ec7e34 100644 --- a/mlir/lib/CAPI/IR/BuiltinAttributes.cpp +++ b/mlir/lib/CAPI/IR/BuiltinAttributes.cpp @@ -165,7 +165,7 @@ MlirAttribute mlirOpaqueAttrGet(MlirContext ctx, MlirStringRef dialectNamespace, intptr_t dataLength, const char *data, MlirType type) { return wrap( - OpaqueAttr::get(Identifier::get(unwrap(dialectNamespace), unwrap(ctx)), + OpaqueAttr::get(StringAttr::get(unwrap(ctx), unwrap(dialectNamespace)), StringRef(data, dataLength), unwrap(type))); } diff --git a/mlir/lib/CAPI/IR/IR.cpp b/mlir/lib/CAPI/IR/IR.cpp index 7bbbc4a..a339aef 100644 --- a/mlir/lib/CAPI/IR/IR.cpp +++ b/mlir/lib/CAPI/IR/IR.cpp @@ -145,9 +145,9 @@ MlirLocation mlirLocationNameGet(MlirContext context, MlirStringRef name, MlirLocation childLoc) { if (mlirLocationIsNull(childLoc)) return wrap( - Location(NameLoc::get(Identifier::get(unwrap(name), unwrap(context))))); + Location(NameLoc::get(StringAttr::get(unwrap(context), unwrap(name))))); return wrap(Location(NameLoc::get( - Identifier::get(unwrap(name), unwrap(context)), unwrap(childLoc)))); + StringAttr::get(unwrap(context), unwrap(name)), unwrap(childLoc)))); } MlirLocation mlirLocationUnknownGet(MlirContext context) { @@ -753,7 +753,7 @@ MlirNamedAttribute mlirNamedAttributeGet(MlirIdentifier name, //===----------------------------------------------------------------------===// MlirIdentifier mlirIdentifierGet(MlirContext context, MlirStringRef str) { - return wrap(Identifier::get(unwrap(str), unwrap(context))); + return wrap(StringAttr::get(unwrap(context), unwrap(str))); } MlirContext mlirIdentifierGetContext(MlirIdentifier ident) { diff --git a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h index 72805dc..4abafb9 100644 --- a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h +++ b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h @@ -16,7 +16,7 @@ namespace mlir { struct GPUFuncOpLowering : ConvertOpToLLVMPattern { GPUFuncOpLowering(LLVMTypeConverter &converter, unsigned allocaAddrSpace, - Identifier kernelAttributeName) + StringAttr kernelAttributeName) : ConvertOpToLLVMPattern(converter), allocaAddrSpace(allocaAddrSpace), kernelAttributeName(kernelAttributeName) {} @@ -30,7 +30,7 @@ private: unsigned allocaAddrSpace; /// The attribute name to use instead of `gpu.kernel`. - Identifier kernelAttributeName; + StringAttr kernelAttributeName; }; struct GPUReturnOpLowering : public ConvertOpToLLVMPattern { diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp index d0589f1..5cec21e 100644 --- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp +++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp @@ -192,8 +192,8 @@ void mlir::populateGpuToNVVMConversionPatterns(LLVMTypeConverter &converter, // memory space and does not support `alloca`s with addrspace(5). patterns.add( converter, /*allocaAddrSpace=*/0, - Identifier::get(NVVM::NVVMDialect::getKernelFuncAttrName(), - &converter.getContext())); + StringAttr::get(&converter.getContext(), + NVVM::NVVMDialect::getKernelFuncAttrName())); patterns.add>(converter, "__nv_fabsf", "__nv_fabs"); diff --git a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp index 6232cc1..b074e41 100644 --- a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp +++ b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp @@ -117,8 +117,8 @@ void mlir::populateGpuToROCDLConversionPatterns(LLVMTypeConverter &converter, GPUReturnOpLowering>(converter); patterns.add( converter, /*allocaAddrSpace=*/5, - Identifier::get(ROCDL::ROCDLDialect::getKernelFuncAttrName(), - &converter.getContext())); + StringAttr::get(&converter.getContext(), + ROCDL::ROCDLDialect::getKernelFuncAttrName())); patterns.add>(converter, "__ocml_fabs_f32", "__ocml_fabs_f64"); patterns.add>(converter, "__ocml_atan_f32", diff --git a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp index d55deb5..fd047b2 100644 --- a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp @@ -296,8 +296,8 @@ LogicalResult GPUFuncOpConversion::matchAndRewrite( funcOp, *getTypeConverter(), rewriter, entryPointAttr, argABI); if (!newFuncOp) return failure(); - newFuncOp->removeAttr(Identifier::get( - gpu::GPUDialect::getKernelFuncAttrName(), rewriter.getContext())); + newFuncOp->removeAttr( + rewriter.getStringAttr(gpu::GPUDialect::getKernelFuncAttrName())); return success(); } diff --git a/mlir/lib/Conversion/PDLToPDLInterp/Predicate.h b/mlir/lib/Conversion/PDLToPDLInterp/Predicate.h index 1c8fece..e943d55 100644 --- a/mlir/lib/Conversion/PDLToPDLInterp/Predicate.h +++ b/mlir/lib/Conversion/PDLToPDLInterp/Predicate.h @@ -164,12 +164,12 @@ private: /// A position describing an attribute of an operation. struct AttributePosition : public PredicateBase, + std::pair, Predicates::AttributePos> { explicit AttributePosition(const KeyTy &key); /// Returns the attribute name of this position. - Identifier getName() const { return key.second; } + StringAttr getName() const { return key.second; } }; //===----------------------------------------------------------------------===// @@ -487,7 +487,7 @@ public: /// Returns an attribute position for an attribute of the given operation. Position *getAttribute(OperationPosition *p, StringRef name) { - return AttributePosition::get(uniquer, p, Identifier::get(name, ctx)); + return AttributePosition::get(uniquer, p, StringAttr::get(ctx, name)); } /// Returns an operand position for an operand of the given operation. diff --git a/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp b/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp index cc1e89f..0861ec0 100644 --- a/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp @@ -35,7 +35,7 @@ struct SimplifyAffineStructures /// Utility to simplify an affine attribute and update its entry in the parent /// operation if necessary. template - void simplifyAndUpdateAttribute(Operation *op, Identifier name, + void simplifyAndUpdateAttribute(Operation *op, StringAttr name, AttributeT attr) { auto &simplified = simplifiedAttributes[attr]; if (simplified == attr) diff --git a/mlir/lib/Dialect/Affine/Utils/Utils.cpp b/mlir/lib/Dialect/Affine/Utils/Utils.cpp index cbbc0c6..3f26687 100644 --- a/mlir/lib/Dialect/Affine/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Affine/Utils/Utils.cpp @@ -88,7 +88,7 @@ static AffineIfOp hoistAffineIfOp(AffineIfOp ifOp, Operation *hoistOverOp) { Operation *hoistOverOpClone = nullptr; // We use this unique name to identify/find `ifOp`'s clone in the else // version. - Identifier idForIfOp = b.getIdentifier("__mlir_if_hoisting"); + StringAttr idForIfOp = b.getStringAttr("__mlir_if_hoisting"); operandMap.clear(); b.setInsertionPointAfter(hoistOverOp); // We'll set an attribute to identify this op in a clone of this sub-tree. diff --git a/mlir/lib/Dialect/DLTI/DLTI.cpp b/mlir/lib/Dialect/DLTI/DLTI.cpp index b18f3db..86ad28b 100644 --- a/mlir/lib/Dialect/DLTI/DLTI.cpp +++ b/mlir/lib/Dialect/DLTI/DLTI.cpp @@ -49,7 +49,7 @@ public: } // namespace impl } // namespace mlir -DataLayoutEntryAttr DataLayoutEntryAttr::get(Identifier key, Attribute value) { +DataLayoutEntryAttr DataLayoutEntryAttr::get(StringAttr key, Attribute value) { return Base::get(key.getContext(), key, value); } @@ -89,7 +89,7 @@ DataLayoutEntryAttr DataLayoutEntryAttr::parse(AsmParser &parser) { return {}; return type ? get(type, value) - : get(parser.getBuilder().getIdentifier(identifier), value); + : get(parser.getBuilder().getStringAttr(identifier), value); } void DataLayoutEntryAttr::print(AsmPrinter &os) const { @@ -97,7 +97,7 @@ void DataLayoutEntryAttr::print(AsmPrinter &os) const { if (auto type = getKey().dyn_cast()) os << type; else - os << "\"" << getKey().get().strref() << "\""; + os << "\"" << getKey().get().strref() << "\""; os << ", " << getValue() << ">"; } @@ -146,13 +146,13 @@ LogicalResult DataLayoutSpecAttr::verify(function_ref emitError, ArrayRef entries) { DenseSet types; - DenseSet ids; + DenseSet ids; for (DataLayoutEntryInterface entry : entries) { if (auto type = entry.getKey().dyn_cast()) { if (!types.insert(type).second) return emitError() << "repeated layout entry key: " << type; } else { - auto id = entry.getKey().get(); + auto id = entry.getKey().get(); if (!ids.insert(id).second) return emitError() << "repeated layout entry key: " << id.getValue(); } @@ -191,13 +191,13 @@ overwriteDuplicateEntries(SmallVectorImpl &oldEntries, static LogicalResult combineOneSpec(DataLayoutSpecInterface spec, DenseMap &entriesForType, - DenseMap &entriesForID) { + DenseMap &entriesForID) { // A missing spec should be fine. if (!spec) return success(); DenseMap newEntriesForType; - DenseMap newEntriesForID; + DenseMap newEntriesForID; spec.bucketEntriesByType(newEntriesForType, newEntriesForID); // Try overwriting the old entries with the new ones. @@ -220,7 +220,7 @@ combineOneSpec(DataLayoutSpecInterface spec, } for (const auto &kvp : newEntriesForID) { - Identifier id = kvp.second.getKey().get(); + StringAttr id = kvp.second.getKey().get(); Dialect *dialect = id.getReferencedDialect(); if (!entriesForID.count(id)) { entriesForID[id] = kvp.second; @@ -253,7 +253,7 @@ DataLayoutSpecAttr::combineWith(ArrayRef specs) const { // Combine all specs in order, with `this` being the last one. DenseMap entriesForType; - DenseMap entriesForID; + DenseMap entriesForID; for (DataLayoutSpecInterface spec : specs) if (failed(combineOneSpec(spec, entriesForType, entriesForID))) return nullptr; @@ -320,7 +320,7 @@ public: LogicalResult verifyEntry(DataLayoutEntryInterface entry, Location loc) const final { - StringRef entryName = entry.getKey().get().strref(); + StringRef entryName = entry.getKey().get().strref(); if (entryName == DLTIDialect::kDataLayoutEndiannessKey) { auto value = entry.getValue().dyn_cast(); if (value && diff --git a/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp b/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp index d2d1752..db5da26 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp @@ -35,12 +35,12 @@ void mlir::linalg::CodegenStrategy::configurePassPipeline( const std::unique_ptr &t = transformationSequence[stepCount]; std::string currentStr = std::to_string(stepCount); - auto currentState = Identifier::get(currentStr, context); + auto currentState = StringAttr::get(context, currentStr); std::string nextStr = std::to_string(stepCount + 1); - auto nextState = Identifier::get(nextStr, context); + auto nextState = StringAttr::get(context, nextStr); auto filter = (currentState.str() == std::to_string(0)) ? linalg::LinalgTransformationFilter( - t->filter, ArrayRef{}, nextState) + t->filter, ArrayRef{}, nextState) : linalg::LinalgTransformationFilter( t->filter, currentState, nextState); t->addToPassPipeline(pm, filter); diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp index d7a26ee..8ccdb7f 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -447,8 +447,8 @@ public: auto *ctx = patterns.getContext(); patterns.add>( ctx, options, - LinalgTransformationFilter(ArrayRef{}, - Identifier::get("tiled", ctx))); + LinalgTransformationFilter(ArrayRef{}, + StringAttr::get(ctx, "tiled"))); RewritePatternList::insert(patterns, options); } }; diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp index a4b4d78..57cc48f 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp @@ -49,13 +49,13 @@ const StringLiteral mlir::linalg::LinalgTransforms::kLinalgTransformMarker = "__internal_linalg_transform__"; mlir::linalg::LinalgTransformationFilter::LinalgTransformationFilter( - ArrayRef matchDisjunction, Optional replacement) + ArrayRef matchDisjunction, Optional replacement) : matchDisjunction(matchDisjunction.begin(), matchDisjunction.end()), replacement(replacement), matchByDefault(false) {} mlir::linalg::LinalgTransformationFilter::LinalgTransformationFilter( - FilterFunction f, ArrayRef matchDisjunction, - Optional replacement) + FilterFunction f, ArrayRef matchDisjunction, + Optional replacement) : filters(), matchDisjunction(matchDisjunction.begin(), matchDisjunction.end()), replacement(replacement), matchByDefault(false) { @@ -101,10 +101,10 @@ void mlir::linalg::LinalgTransformationFilter:: Operation *op) const { if (replacement.hasValue()) op->setAttr(LinalgTransforms::kLinalgTransformMarker, - rewriter.getStringAttr(replacement.getValue().strref())); + replacement.getValue()); else - op->removeAttr(Identifier::get(LinalgTransforms::kLinalgTransformMarker, - rewriter.getContext())); + op->removeAttr( + rewriter.getStringAttr(LinalgTransforms::kLinalgTransformMarker)); } LinalgTilingOptions & diff --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp index 002f791..206daf9 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp @@ -1171,13 +1171,13 @@ static void populateVectorizationPatterns( constexpr static StringRef kPromotedMarker = "PROMOTED"; tilingPatterns.add>( context, LinalgTilingOptions().setTileSizes(tileSizes), - LinalgTransformationFilter(ArrayRef{}, - Identifier::get(kTiledMarker, context))); + LinalgTransformationFilter(ArrayRef{}, + StringAttr::get(kTiledMarker, context))); promotionPatterns.add>( context, LinalgPromotionOptions().setUseFullTileBuffersByDefault(true), - LinalgTransformationFilter(Identifier::get(kTiledMarker, context), - Identifier::get(kPromotedMarker, context))); + LinalgTransformationFilter(StringAttr::get(kTiledMarker, context), + StringAttr::get(kPromotedMarker, context))); SmallVector mask(N); int offset = tileSizes.size() - N; diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp index 17ee2df..05b5daf 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp @@ -14,7 +14,6 @@ #include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/BuiltinTypes.h" -#include "mlir/IR/Identifier.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/TypeSwitch.h" diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp index 27d60b5..f697893 100644 --- a/mlir/lib/Dialect/Shape/IR/Shape.cpp +++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp @@ -207,7 +207,7 @@ LogicalResult ShapeDialect::verifyOperationAttribute(Operation *op, if (auto arr = attribute.second.dyn_cast()) { // Verify all entries are function libraries and mappings in libraries // refer to unique ops. - DenseSet key; + DenseSet key; for (auto it : arr) { if (!it.isa()) return op->emitError( diff --git a/mlir/lib/IR/AttributeDetail.h b/mlir/lib/IR/AttributeDetail.h index 03373ae..6300402 100644 --- a/mlir/lib/IR/AttributeDetail.h +++ b/mlir/lib/IR/AttributeDetail.h @@ -16,7 +16,6 @@ #include "mlir/IR/AffineMap.h" #include "mlir/IR/BuiltinAttributes.h" #include "mlir/IR/BuiltinTypes.h" -#include "mlir/IR/Identifier.h" #include "mlir/IR/IntegerSet.h" #include "mlir/IR/MLIRContext.h" #include "mlir/Support/StorageUniquer.h" diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp index 68471a5..9b91054 100644 --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -19,8 +19,8 @@ using namespace mlir; -Identifier Builder::getIdentifier(const Twine &str) { - return Identifier::get(str, context); +StringAttr Builder::getIdentifier(const Twine &str) { + return getStringAttr(str); } //===----------------------------------------------------------------------===// @@ -83,7 +83,7 @@ NoneType Builder::getNoneType() { return NoneType::get(context); } //===----------------------------------------------------------------------===// NamedAttribute Builder::getNamedAttr(StringRef name, Attribute val) { - return NamedAttribute(getIdentifier(name), val); + return NamedAttribute(getStringAttr(name), val); } UnitAttr Builder::getUnitAttr() { return UnitAttr::get(context); } diff --git a/mlir/lib/IR/BuiltinAttributes.cpp b/mlir/lib/IR/BuiltinAttributes.cpp index 6b48e31..d4477fe 100644 --- a/mlir/lib/IR/BuiltinAttributes.cpp +++ b/mlir/lib/IR/BuiltinAttributes.cpp @@ -188,7 +188,7 @@ Attribute DictionaryAttr::get(StringRef name) const { auto it = impl::findAttrSorted(begin(), end(), name); return it.second ? it.first->second : Attribute(); } -Attribute DictionaryAttr::get(Identifier name) const { +Attribute DictionaryAttr::get(StringAttr name) const { auto it = impl::findAttrSorted(begin(), end(), name); return it.second ? it.first->second : Attribute(); } @@ -198,7 +198,7 @@ Optional DictionaryAttr::getNamed(StringRef name) const { auto it = impl::findAttrSorted(begin(), end(), name); return it.second ? *it.first : Optional(); } -Optional DictionaryAttr::getNamed(Identifier name) const { +Optional DictionaryAttr::getNamed(StringAttr name) const { auto it = impl::findAttrSorted(begin(), end(), name); return it.second ? *it.first : Optional(); } @@ -207,7 +207,7 @@ Optional DictionaryAttr::getNamed(Identifier name) const { bool DictionaryAttr::contains(StringRef name) const { return impl::findAttrSorted(begin(), end(), name).second; } -bool DictionaryAttr::contains(Identifier name) const { +bool DictionaryAttr::contains(StringAttr name) const { return impl::findAttrSorted(begin(), end(), name).second; } @@ -394,7 +394,7 @@ bool BoolAttr::classof(Attribute attr) { //===----------------------------------------------------------------------===// LogicalResult OpaqueAttr::verify(function_ref emitError, - Identifier dialect, StringRef attrData, + StringAttr dialect, StringRef attrData, Type type) { if (!Dialect::isValidNamespace(dialect.strref())) return emitError() << "invalid dialect namespace '" << dialect << "'"; @@ -1247,7 +1247,7 @@ bool OpaqueElementsAttr::decode(ElementsAttr &result) { LogicalResult OpaqueElementsAttr::verify(function_ref emitError, - Identifier dialect, StringRef value, + StringAttr dialect, StringRef value, ShapedType type) { if (!Dialect::isValidNamespace(dialect.strref())) return emitError() << "invalid dialect namespace '" << dialect << "'"; diff --git a/mlir/lib/IR/BuiltinDialect.cpp b/mlir/lib/IR/BuiltinDialect.cpp index a007a487..3dd653dd 100644 --- a/mlir/lib/IR/BuiltinDialect.cpp +++ b/mlir/lib/IR/BuiltinDialect.cpp @@ -153,7 +153,7 @@ static LogicalResult verify(FuncOp op) { /// from this function to dest. void FuncOp::cloneInto(FuncOp dest, BlockAndValueMapping &mapper) { // Add the attributes of this function to dest. - llvm::MapVector newAttrs; + llvm::MapVector newAttrs; for (const auto &attr : dest->getAttrs()) newAttrs.insert(attr); for (const auto &attr : (*this)->getAttrs()) diff --git a/mlir/lib/IR/BuiltinTypes.cpp b/mlir/lib/IR/BuiltinTypes.cpp index 2ca794e..e71f335 100644 --- a/mlir/lib/IR/BuiltinTypes.cpp +++ b/mlir/lib/IR/BuiltinTypes.cpp @@ -251,7 +251,7 @@ void FunctionType::walkImmediateSubElements( /// Verify the construction of an opaque type. LogicalResult OpaqueType::verify(function_ref emitError, - Identifier dialect, StringRef typeData) { + StringAttr dialect, StringRef typeData) { if (!Dialect::isValidNamespace(dialect.strref())) return emitError() << "invalid dialect namespace '" << dialect << "'"; diff --git a/mlir/lib/IR/Dialect.cpp b/mlir/lib/IR/Dialect.cpp index 0170b99..56bd669 100644 --- a/mlir/lib/IR/Dialect.cpp +++ b/mlir/lib/IR/Dialect.cpp @@ -156,7 +156,7 @@ Attribute Dialect::parseAttribute(DialectAsmParser &parser, Type type) const { Type Dialect::parseType(DialectAsmParser &parser) const { // If this dialect allows unknown types, then represent this with OpaqueType. if (allowsUnknownTypes()) { - Identifier ns = Identifier::get(getNamespace(), getContext()); + StringAttr ns = StringAttr::get(getContext(), getNamespace()); return OpaqueType::get(ns, parser.getFullSymbolSpec()); } diff --git a/mlir/lib/IR/Location.cpp b/mlir/lib/IR/Location.cpp index 6a39efa..1de4d73 100644 --- a/mlir/lib/IR/Location.cpp +++ b/mlir/lib/IR/Location.cpp @@ -8,7 +8,6 @@ #include "mlir/IR/Location.h" #include "mlir/IR/BuiltinDialect.h" -#include "mlir/IR/Identifier.h" #include "mlir/IR/Visitors.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/TypeSwitch.h" diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp index aa907ea..91f51d9 100644 --- a/mlir/lib/IR/MLIRContext.cpp +++ b/mlir/lib/IR/MLIRContext.cpp @@ -772,14 +772,14 @@ void AbstractOperation::insert( "context"); // Register the attribute names of this operation. - MutableArrayRef cachedAttrNames; + MutableArrayRef cachedAttrNames; if (!attrNames.empty()) { - cachedAttrNames = MutableArrayRef( - impl.abstractDialectSymbolAllocator.Allocate( + cachedAttrNames = MutableArrayRef( + impl.abstractDialectSymbolAllocator.Allocate( attrNames.size()), attrNames.size()); for (unsigned i : llvm::seq(0, attrNames.size())) - new (&cachedAttrNames[i]) Identifier(Identifier::get(attrNames[i], ctx)); + new (&cachedAttrNames[i]) StringAttr(StringAttr::get(ctx, attrNames[i])); } // Register the information for this operation. @@ -801,8 +801,8 @@ AbstractOperation::AbstractOperation( VerifyInvariantsFn &&verifyInvariants, FoldHookFn &&foldHook, GetCanonicalizationPatternsFn &&getCanonicalizationPatterns, detail::InterfaceMap &&interfaceMap, HasTraitFn &&hasTrait, - ArrayRef attrNames) - : name(Identifier::get(name, dialect.getContext())), dialect(dialect), + ArrayRef attrNames) + : name(StringAttr::get(dialect.getContext(), name)), dialect(dialect), typeID(typeID), interfaceMap(std::move(interfaceMap)), foldHookFn(std::move(foldHook)), getCanonicalizationPatternsFn(std::move(getCanonicalizationPatterns)), diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp index d232b1d..cfbb9a97e 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -30,7 +30,7 @@ OperationName::OperationName(StringRef name, MLIRContext *context) { if (auto *op = AbstractOperation::lookup(name, context)) representation = op; else - representation = Identifier::get(name, context); + representation = StringAttr::get(name, context); } /// Return the name of the dialect this operation is registered to. @@ -51,10 +51,10 @@ StringRef OperationName::getStringRef() const { } /// Return the name of this operation as an identifier. This always succeeds. -Identifier OperationName::getIdentifier() const { +StringAttr OperationName::getIdentifier() const { if (auto *op = representation.dyn_cast()) return op->name; - return representation.get(); + return representation.get(); } OperationName OperationName::getFromOpaquePointer(const void *pointer) { diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp index c78fc52..a0303bd3 100644 --- a/mlir/lib/IR/OperationSupport.cpp +++ b/mlir/lib/IR/OperationSupport.cpp @@ -62,7 +62,7 @@ DictionaryAttr NamedAttrList::getDictionary(MLIRContext *context) const { /// Add an attribute with the specified name. void NamedAttrList::append(StringRef name, Attribute attr) { - append(Identifier::get(name, attr.getContext()), attr); + append(StringAttr::get(attr.getContext(), name), attr); } /// Replaces the attributes with new list of attributes. @@ -86,7 +86,7 @@ Attribute NamedAttrList::get(StringRef name) const { auto it = findAttr(*this, name); return it.second ? it.first->second : Attribute(); } -Attribute NamedAttrList::get(Identifier name) const { +Attribute NamedAttrList::get(StringAttr name) const { auto it = findAttr(*this, name); return it.second ? it.first->second : Attribute(); } @@ -96,14 +96,14 @@ Optional NamedAttrList::getNamed(StringRef name) const { auto it = findAttr(*this, name); return it.second ? *it.first : Optional(); } -Optional NamedAttrList::getNamed(Identifier name) const { +Optional NamedAttrList::getNamed(StringAttr name) const { auto it = findAttr(*this, name); return it.second ? *it.first : Optional(); } /// If the an attribute exists with the specified name, change it to the new /// value. Otherwise, add a new attribute with the specified name/value. -Attribute NamedAttrList::set(Identifier name, Attribute value) { +Attribute NamedAttrList::set(StringAttr name, Attribute value) { assert(value && "attributes may never be null"); // Look for an existing attribute with the given name, and set its value @@ -131,7 +131,7 @@ Attribute NamedAttrList::set(Identifier name, Attribute value) { Attribute NamedAttrList::set(StringRef name, Attribute value) { assert(value && "attributes may never be null"); - return set(mlir::Identifier::get(name, value.getContext()), value); + return set(mlir::StringAttr::get(value.getContext(), name), value); } Attribute @@ -143,7 +143,7 @@ NamedAttrList::eraseImpl(SmallVectorImpl::iterator it) { return attr; } -Attribute NamedAttrList::erase(Identifier name) { +Attribute NamedAttrList::erase(StringAttr name) { auto it = findAttr(*this, name); return it.second ? eraseImpl(it.first) : Attribute(); } diff --git a/mlir/lib/IR/SymbolTable.cpp b/mlir/lib/IR/SymbolTable.cpp index 93d605f..1dbb116 100644 --- a/mlir/lib/IR/SymbolTable.cpp +++ b/mlir/lib/IR/SymbolTable.cpp @@ -27,7 +27,7 @@ static bool isPotentiallyUnknownSymbolTable(Operation *op) { static StringAttr getNameIfSymbol(Operation *op) { return op->getAttrOfType(SymbolTable::getSymbolAttrName()); } -static StringAttr getNameIfSymbol(Operation *op, Identifier symbolAttrNameId) { +static StringAttr getNameIfSymbol(Operation *op, StringAttr symbolAttrNameId) { return op->getAttrOfType(symbolAttrNameId); } @@ -52,8 +52,8 @@ collectValidReferencesFor(Operation *symbol, StringAttr symbolName, // Collect references until 'symbolTableOp' reaches 'within'. SmallVector nestedRefs(1, leafRef); - Identifier symbolNameId = - Identifier::get(SymbolTable::getSymbolAttrName(), ctx); + StringAttr symbolNameId = + StringAttr::get(ctx, SymbolTable::getSymbolAttrName()); do { // Each parent of 'symbol' should define a symbol table. if (!symbolTableOp->hasTrait()) @@ -111,8 +111,8 @@ SymbolTable::SymbolTable(Operation *symbolTableOp) assert(llvm::hasSingleElement(symbolTableOp->getRegion(0)) && "expected operation to have a single block"); - Identifier symbolNameId = Identifier::get(SymbolTable::getSymbolAttrName(), - symbolTableOp->getContext()); + StringAttr symbolNameId = StringAttr::get(symbolTableOp->getContext(), + SymbolTable::getSymbolAttrName()); for (auto &op : symbolTableOp->getRegion(0).front()) { StringAttr name = getNameIfSymbol(&op, symbolNameId); if (!name) @@ -235,7 +235,7 @@ void SymbolTable::setSymbolVisibility(Operation *symbol, Visibility vis) { // If the visibility is public, just drop the attribute as this is the // default. if (vis == Visibility::Public) { - symbol->removeAttr(Identifier::get(getVisibilityAttrName(), ctx)); + symbol->removeAttr(StringAttr::get(ctx, getVisibilityAttrName())); return; } @@ -305,8 +305,8 @@ Operation *SymbolTable::lookupSymbolIn(Operation *symbolTableOp, return nullptr; // Look for a symbol with the given name. - Identifier symbolNameId = Identifier::get(SymbolTable::getSymbolAttrName(), - symbolTableOp->getContext()); + StringAttr symbolNameId = StringAttr::get(symbolTableOp->getContext(), + SymbolTable::getSymbolAttrName()); for (auto &op : region.front()) if (getNameIfSymbol(&op, symbolNameId) == symbol) return &op; diff --git a/mlir/lib/IR/TypeDetail.h b/mlir/lib/IR/TypeDetail.h index 09bfbf0..c1079a4 100644 --- a/mlir/lib/IR/TypeDetail.h +++ b/mlir/lib/IR/TypeDetail.h @@ -14,7 +14,6 @@ #include "mlir/IR/AffineMap.h" #include "mlir/IR/BuiltinTypes.h" -#include "mlir/IR/Identifier.h" #include "mlir/IR/MLIRContext.h" #include "mlir/IR/OperationSupport.h" #include "mlir/IR/TypeRange.h" diff --git a/mlir/lib/Interfaces/DataLayoutInterfaces.cpp b/mlir/lib/Interfaces/DataLayoutInterfaces.cpp index 5223c31..2b7ff5e 100644 --- a/mlir/lib/Interfaces/DataLayoutInterfaces.cpp +++ b/mlir/lib/Interfaces/DataLayoutInterfaces.cpp @@ -147,11 +147,11 @@ mlir::detail::filterEntriesForType(DataLayoutEntryListRef entries, DataLayoutEntryInterface mlir::detail::filterEntryForIdentifier(DataLayoutEntryListRef entries, - Identifier id) { + StringAttr id) { const auto *it = llvm::find_if(entries, [id](DataLayoutEntryInterface entry) { - if (!entry.getKey().is()) + if (!entry.getKey().is()) return false; - return entry.getKey().get() == id; + return entry.getKey().get() == id; }); return it == entries.end() ? DataLayoutEntryInterface() : *it; } @@ -384,12 +384,12 @@ unsigned mlir::DataLayout::getTypePreferredAlignment(Type t) const { void DataLayoutSpecInterface::bucketEntriesByType( DenseMap &types, - DenseMap &ids) { + DenseMap &ids) { for (DataLayoutEntryInterface entry : getEntries()) { if (auto type = entry.getKey().dyn_cast()) types[type.getTypeID()].push_back(entry); else - ids[entry.getKey().get()] = entry; + ids[entry.getKey().get()] = entry; } } @@ -403,7 +403,7 @@ LogicalResult mlir::detail::verifyDataLayoutSpec(DataLayoutSpecInterface spec, // Second, dispatch verifications of entry groups to types or dialects they // are are associated with. DenseMap types; - DenseMap ids; + DenseMap ids; spec.bucketEntriesByType(types, ids); for (const auto &kvp : types) { @@ -430,7 +430,7 @@ LogicalResult mlir::detail::verifyDataLayoutSpec(DataLayoutSpecInterface spec, } for (const auto &kvp : ids) { - Identifier identifier = kvp.second.getKey().get(); + StringAttr identifier = kvp.second.getKey().get(); Dialect *dialect = identifier.getReferencedDialect(); // Ignore attributes that belong to an unknown dialect, the dialect may diff --git a/mlir/lib/Parser/AttributeParser.cpp b/mlir/lib/Parser/AttributeParser.cpp index 11b9f03..63b8542 100644 --- a/mlir/lib/Parser/AttributeParser.cpp +++ b/mlir/lib/Parser/AttributeParser.cpp @@ -260,15 +260,15 @@ OptionalParseResult Parser::parseOptionalAttribute(StringAttr &attribute, /// attribute-entry ::= (bare-id | string-literal) `=` attribute-value /// ParseResult Parser::parseAttributeDict(NamedAttrList &attributes) { - llvm::SmallDenseSet seenKeys; + llvm::SmallDenseSet seenKeys; auto parseElt = [&]() -> ParseResult { // The name of an attribute can either be a bare identifier, or a string. - Optional nameId; + Optional nameId; if (getToken().is(Token::string)) - nameId = builder.getIdentifier(getToken().getStringValue()); + nameId = builder.getStringAttr(getToken().getStringValue()); else if (getToken().isAny(Token::bare_identifier, Token::inttype) || getToken().isKeyword()) - nameId = builder.getIdentifier(getTokenSpelling()); + nameId = builder.getStringAttr(getTokenSpelling()); else return emitError("expected attribute name"); if (!seenKeys.insert(*nameId).second) @@ -856,7 +856,7 @@ Attribute Parser::parseOpaqueElementsAttr(Type attrType) { std::string data; if (parseElementAttrHexValues(*this, hexTok, data)) return nullptr; - return OpaqueElementsAttr::get(builder.getIdentifier(name), type, data); + return OpaqueElementsAttr::get(builder.getStringAttr(name), type, data); } /// Shaped type for elements attribute. diff --git a/mlir/lib/Parser/DialectSymbolParser.cpp b/mlir/lib/Parser/DialectSymbolParser.cpp index b6b3207..36f583c 100644 --- a/mlir/lib/Parser/DialectSymbolParser.cpp +++ b/mlir/lib/Parser/DialectSymbolParser.cpp @@ -258,7 +258,7 @@ Attribute Parser::parseExtendedAttr(Type type) { // Otherwise, form a new opaque attribute. return OpaqueAttr::getChecked( [&] { return emitError(loc); }, - Identifier::get(dialectName, state.context), symbolData, + StringAttr::get(state.context, dialectName), symbolData, attrType ? attrType : NoneType::get(state.context)); }); @@ -297,7 +297,7 @@ Type Parser::parseExtendedType() { // Otherwise, form a new opaque type. return OpaqueType::getChecked( [&] { return emitError(loc); }, - Identifier::get(dialectName, state.context), symbolData); + StringAttr::get(state.context, dialectName), symbolData); }); } diff --git a/mlir/lib/Parser/Lexer.cpp b/mlir/lib/Parser/Lexer.cpp index 129fb3e..56ffc90 100644 --- a/mlir/lib/Parser/Lexer.cpp +++ b/mlir/lib/Parser/Lexer.cpp @@ -12,7 +12,6 @@ #include "Lexer.h" #include "mlir/IR/Diagnostics.h" -#include "mlir/IR/Identifier.h" #include "mlir/IR/Location.h" #include "mlir/IR/MLIRContext.h" #include "llvm/ADT/StringExtras.h" diff --git a/mlir/lib/Parser/LocationParser.cpp b/mlir/lib/Parser/LocationParser.cpp index d010260..469fa9f 100644 --- a/mlir/lib/Parser/LocationParser.cpp +++ b/mlir/lib/Parser/LocationParser.cpp @@ -137,14 +137,14 @@ ParseResult Parser::parseNameOrFileLineColLocation(LocationAttr &loc) { if (childLoc.isa()) return emitError(childSourceLoc, "child of NameLoc cannot be another NameLoc"); - loc = NameLoc::get(Identifier::get(str, ctx), childLoc); + loc = NameLoc::get(StringAttr::get(ctx, str), childLoc); // Parse the closing ')'. if (parseToken(Token::r_paren, "expected ')' after child location of NameLoc")) return failure(); } else { - loc = NameLoc::get(Identifier::get(str, ctx)); + loc = NameLoc::get(StringAttr::get(ctx, str)); } return success(); diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp index f8551fc..57ede84 100644 --- a/mlir/lib/Pass/Pass.cpp +++ b/mlir/lib/Pass/Pass.cpp @@ -80,7 +80,7 @@ void Pass::printAsTextualPipeline(raw_ostream &os) { namespace mlir { namespace detail { struct OpPassManagerImpl { - OpPassManagerImpl(Identifier identifier, OpPassManager::Nesting nesting) + OpPassManagerImpl(StringAttr identifier, OpPassManager::Nesting nesting) : name(identifier.str()), identifier(identifier), initializationGeneration(0), nesting(nesting) {} OpPassManagerImpl(StringRef name, OpPassManager::Nesting nesting) @@ -91,7 +91,7 @@ struct OpPassManagerImpl { /// Nest a new operation pass manager for the given operation kind under this /// pass manager. - OpPassManager &nest(Identifier nestedName); + OpPassManager &nest(StringAttr nestedName); OpPassManager &nest(StringRef nestedName); /// Add the given pass to this pass manager. If this pass has a concrete @@ -107,9 +107,9 @@ struct OpPassManagerImpl { void coalesceAdjacentAdaptorPasses(); /// Return the operation name of this pass manager as an identifier. - Identifier getOpName(MLIRContext &context) { + StringAttr getOpName(MLIRContext &context) { if (!identifier) - identifier = Identifier::get(name, &context); + identifier = StringAttr::get(name, &context); return *identifier; } @@ -118,7 +118,7 @@ struct OpPassManagerImpl { /// The cached identifier (internalized in the context) for the name of the /// operation that passes of this pass manager operate on. - Optional identifier; + Optional identifier; /// The set of passes to run as part of this pass manager. std::vector> passes; @@ -141,7 +141,7 @@ void OpPassManagerImpl::mergeInto(OpPassManagerImpl &rhs) { passes.clear(); } -OpPassManager &OpPassManagerImpl::nest(Identifier nestedName) { +OpPassManager &OpPassManagerImpl::nest(StringAttr nestedName) { OpPassManager nested(nestedName, nesting); auto *adaptor = new OpToOpPassAdaptor(std::move(nested)); addPass(std::unique_ptr(adaptor)); @@ -219,7 +219,7 @@ void OpPassManagerImpl::coalesceAdjacentAdaptorPasses() { // OpPassManager //===----------------------------------------------------------------------===// -OpPassManager::OpPassManager(Identifier name, Nesting nesting) +OpPassManager::OpPassManager(StringAttr name, Nesting nesting) : impl(new OpPassManagerImpl(name, nesting)) {} OpPassManager::OpPassManager(StringRef name, Nesting nesting) : impl(new OpPassManagerImpl(name, nesting)) {} @@ -254,7 +254,7 @@ OpPassManager::const_pass_iterator OpPassManager::end() const { /// Nest a new operation pass manager for the given operation kind under this /// pass manager. -OpPassManager &OpPassManager::nest(Identifier nestedName) { +OpPassManager &OpPassManager::nest(StringAttr nestedName) { return impl->nest(nestedName); } OpPassManager &OpPassManager::nest(StringRef nestedName) { @@ -279,7 +279,7 @@ OpPassManagerImpl &OpPassManager::getImpl() { return *impl; } StringRef OpPassManager::getOpName() const { return impl->name; } /// Return the operation name that this pass manager operates on. -Identifier OpPassManager::getOpName(MLIRContext &context) const { +StringAttr OpPassManager::getOpName(MLIRContext &context) const { return impl->getOpName(context); } @@ -468,7 +468,7 @@ static OpPassManager *findPassManagerFor(MutableArrayRef mgrs, /// Find an operation pass manager that can operate on an operation of the given /// type, or nullptr if one does not exist. static OpPassManager *findPassManagerFor(MutableArrayRef mgrs, - Identifier name, + StringAttr name, MLIRContext &context) { auto it = llvm::find_if( mgrs, [&](OpPassManager &mgr) { return mgr.getOpName(context) == name; }); @@ -630,7 +630,7 @@ void OpToOpPassAdaptor::runOnOperationAsyncImpl(bool verifyPasses) { PassManager::PassManager(MLIRContext *ctx, Nesting nesting, StringRef operationName) - : OpPassManager(Identifier::get(operationName, ctx), nesting), context(ctx), + : OpPassManager(StringAttr::get(ctx, operationName), nesting), context(ctx), initializationKey(DenseMapInfo::getTombstoneKey()), passTiming(false), verifyPasses(true) {} @@ -794,7 +794,7 @@ PassInstrumentor::~PassInstrumentor() {} /// See PassInstrumentation::runBeforePipeline for details. void PassInstrumentor::runBeforePipeline( - Identifier name, + StringAttr name, const PassInstrumentation::PipelineParentInfo &parentInfo) { llvm::sys::SmartScopedLock instrumentationLock(impl->mutex); for (auto &instr : impl->instrumentations) @@ -803,7 +803,7 @@ void PassInstrumentor::runBeforePipeline( /// See PassInstrumentation::runAfterPipeline for details. void PassInstrumentor::runAfterPipeline( - Identifier name, + StringAttr name, const PassInstrumentation::PipelineParentInfo &parentInfo) { llvm::sys::SmartScopedLock instrumentationLock(impl->mutex); for (auto &instr : llvm::reverse(impl->instrumentations)) diff --git a/mlir/lib/Pass/PassTiming.cpp b/mlir/lib/Pass/PassTiming.cpp index ef22443..f063d95 100644 --- a/mlir/lib/Pass/PassTiming.cpp +++ b/mlir/lib/Pass/PassTiming.cpp @@ -52,7 +52,7 @@ struct PassTiming : public PassInstrumentation { // Pipeline //===--------------------------------------------------------------------===// - void runBeforePipeline(Identifier name, + void runBeforePipeline(StringAttr name, const PipelineParentInfo &parentInfo) override { auto tid = llvm::get_threadid(); auto &activeTimers = activeThreadTimers[tid]; @@ -73,7 +73,7 @@ struct PassTiming : public PassInstrumentation { })); } - void runAfterPipeline(Identifier, const PipelineParentInfo &) override { + void runAfterPipeline(StringAttr, const PipelineParentInfo &) override { auto &activeTimers = activeThreadTimers[llvm::get_threadid()]; assert(!activeTimers.empty() && "expected active timer"); activeTimers.pop_back(); diff --git a/mlir/lib/Rewrite/ByteCode.cpp b/mlir/lib/Rewrite/ByteCode.cpp index 4370b23..9885456 100644 --- a/mlir/lib/Rewrite/ByteCode.cpp +++ b/mlir/lib/Rewrite/ByteCode.cpp @@ -721,11 +721,8 @@ void Generator::generate(pdl_interp::CreateOperationOp op, // Add the attributes. OperandRange attributes = op.attributes(); writer.append(static_cast(attributes.size())); - for (auto it : llvm::zip(op.attributeNames(), op.attributes())) { - writer.append( - Identifier::get(std::get<0>(it).cast().getValue(), ctx), - std::get<1>(it)); - } + for (auto it : llvm::zip(op.attributeNames(), op.attributes())) + writer.append(std::get<0>(it), std::get<1>(it)); writer.appendPDLValueList(op.types()); } void Generator::generate(pdl_interp::CreateTypeOp op, ByteCodeWriter &writer) { @@ -745,7 +742,7 @@ void Generator::generate(pdl_interp::FinalizeOp op, ByteCodeWriter &writer) { void Generator::generate(pdl_interp::GetAttributeOp op, ByteCodeWriter &writer) { writer.append(OpCode::GetAttribute, op.attribute(), op.operation(), - Identifier::get(op.name(), ctx)); + op.nameAttr()); } void Generator::generate(pdl_interp::GetAttributeTypeOp op, ByteCodeWriter &writer) { @@ -1307,7 +1304,7 @@ void ByteCodeExecutor::executeCreateOperation(PatternRewriter &rewriter, OperationState state(mainRewriteLoc, read()); readValueList(state.operands); for (unsigned i = 0, e = read(); i != e; ++i) { - Identifier name = read(); + StringAttr name = read(); if (Attribute attr = read()) state.addAttribute(name, attr); } @@ -1364,7 +1361,7 @@ void ByteCodeExecutor::executeGetAttribute() { LLVM_DEBUG(llvm::dbgs() << "Executing GetAttribute:\n"); unsigned memIndex = read(); Operation *op = read(); - Identifier attrName = read(); + StringAttr attrName = read(); Attribute attr = op->getAttr(attrName); LLVM_DEBUG(llvm::dbgs() << " * Operation: " << *op << "\n" diff --git a/mlir/lib/Rewrite/ByteCode.h b/mlir/lib/Rewrite/ByteCode.h index c6f41be..941b782 100644 --- a/mlir/lib/Rewrite/ByteCode.h +++ b/mlir/lib/Rewrite/ByteCode.h @@ -168,7 +168,7 @@ private: /// A vector containing pointers to uniqued data. The storage is intentionally /// opaque such that we can store a wide range of data types. The types of /// data stored here include: - /// * Attribute, Identifier, OperationName, Type + /// * Attribute, OperationName, Type std::vector uniquedData; /// A vector containing the generated bytecode for the matcher. diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp index 077c7c3..e8adf0d 100644 --- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp @@ -803,7 +803,7 @@ LogicalResult Importer::processFunction(llvm::Function *f) { convertLinkageFromLLVM(f->getLinkage())); if (FlatSymbolRefAttr personality = getPersonalityAsAttr(f)) - fop->setAttr(b.getIdentifier("personality"), personality); + fop->setAttr(b.getStringAttr("personality"), personality); else if (f->hasPersonalityFn()) emitWarning(UnknownLoc::get(context), "could not deduce personality, skipping it"); diff --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp index b74b487..e60d1a9 100644 --- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp +++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp @@ -227,7 +227,7 @@ LogicalResult spirv::Deserializer::processDecoration(ArrayRef words) { return emitError(unknownLoc, "invalid Decoration code : ") << words[1]; } auto attrName = llvm::convertToSnakeFromCamelCase(decorationName); - auto symbol = opBuilder.getIdentifier(attrName); + auto symbol = opBuilder.getStringAttr(attrName); switch (static_cast(words[1])) { case spirv::Decoration::DescriptorSet: case spirv::Decoration::Binding: @@ -1964,7 +1964,7 @@ Location spirv::Deserializer::createFileLineColLoc(OpBuilder opBuilder) { auto fileName = debugInfoMap.lookup(debugLine->fileID).str(); if (fileName.empty()) fileName = ""; - return FileLineColLoc::get(opBuilder.getIdentifier(fileName), debugLine->line, + return FileLineColLoc::get(opBuilder.getStringAttr(fileName), debugLine->line, debugLine->col); } diff --git a/mlir/lib/Transforms/LocationSnapshot.cpp b/mlir/lib/Transforms/LocationSnapshot.cpp index a7e0872..4e77b1d 100644 --- a/mlir/lib/Transforms/LocationSnapshot.cpp +++ b/mlir/lib/Transforms/LocationSnapshot.cpp @@ -30,12 +30,12 @@ static void generateLocationsFromIR(raw_ostream &os, StringRef fileName, op->print(os, state, flags); Builder builder(op->getContext()); - Optional tagIdentifier; + Optional tagIdentifier; if (!tag.empty()) - tagIdentifier = builder.getIdentifier(tag); + tagIdentifier = builder.getStringAttr(tag); // Walk and generate new locations for each of the operations. - Identifier file = builder.getIdentifier(fileName); + StringAttr file = builder.getStringAttr(fileName); op->walk([&](Operation *opIt) { // Check to see if this operation has a mapped location. Some operations may // be elided from the printed form, e.g. the body terminators of some region diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgDistribution.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgDistribution.cpp index 5e7c5d5..54c5bd1 100644 --- a/mlir/test/lib/Dialect/Linalg/TestLinalgDistribution.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgDistribution.cpp @@ -58,8 +58,8 @@ void TestLinalgDistribution::runOnFunction() { populateLinalgDistributeTiledLoopPattern( distributeTiledLoopsPatterns, getDistributionOptions(), LinalgTransformationFilter( - ArrayRef{}, - {Identifier::get("distributed", funcOp.getContext())}) + ArrayRef{}, + {StringAttr::get("distributed", funcOp.getContext())}) .addFilter([](Operation *op) { return success(!op->getParentOfType()); })); diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp index 7d87e9a..39f8cca 100644 --- a/mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp @@ -31,81 +31,81 @@ static void fillFusionPatterns(MLIRContext *context, LinalgTilingOptions().setTileSizes({32, 64, 16}).setLoopType(LoopType), LinalgFusionOptions().setIndicesToFuse({2}), LinalgTransformationFilter( - Identifier::get("basic_fusion", context), - Identifier::get("after_basic_fusion", context)), + StringAttr::get(context, "basic_fusion"), + StringAttr::get(context, "after_basic_fusion")), LinalgTransformationFilter( - ArrayRef(), - Identifier::get("after_basic_fusion_producer", context)), + ArrayRef(), + StringAttr::get(context, "after_basic_fusion_producer")), LinalgTransformationFilter( - ArrayRef(), - Identifier::get("after_basic_fusion_original", context))); + ArrayRef(), + StringAttr::get(context, "after_basic_fusion_original"))); patterns.add>( context, dependenceGraph, LinalgTilingOptions().setTileSizes({32, 64, 16}).setLoopType(LoopType), LinalgFusionOptions().setIndicesToFuse({0}), - LinalgTransformationFilter(Identifier::get("lhs_fusion", context), - Identifier::get("after_lhs_fusion", context)), + LinalgTransformationFilter(StringAttr::get(context, "lhs_fusion"), + StringAttr::get(context, "after_lhs_fusion")), LinalgTransformationFilter( - ArrayRef(), - Identifier::get("after_lhs_fusion_producer", context)), + ArrayRef(), + StringAttr::get(context, "after_lhs_fusion_producer")), LinalgTransformationFilter( - ArrayRef(), - Identifier::get("after_lhs_fusion_original", context))); + ArrayRef(), + StringAttr::get(context, "after_lhs_fusion_original"))); patterns.add>( context, dependenceGraph, LinalgTilingOptions().setTileSizes({32, 64, 16}).setLoopType(LoopType), LinalgFusionOptions().setIndicesToFuse({2}), - LinalgTransformationFilter(Identifier::get("out_fusion", context), - Identifier::get("after_out_fusion", context)), + LinalgTransformationFilter(StringAttr::get(context, "out_fusion"), + StringAttr::get(context, "after_out_fusion")), LinalgTransformationFilter( - ArrayRef(), - Identifier::get("after_out_fusion_producer", context)), + ArrayRef(), + StringAttr::get(context, "after_out_fusion_producer")), LinalgTransformationFilter( - ArrayRef(), - Identifier::get("after_out_fusion_original", context))); + ArrayRef(), + StringAttr::get(context, "after_out_fusion_original"))); patterns.add>( context, dependenceGraph, LinalgTilingOptions().setTileSizes({32, 64, 16}).setLoopType(LoopType), LinalgFusionOptions().setIndicesToFuse({1}), - LinalgTransformationFilter(Identifier::get("rhs_fusion", context), - Identifier::get("after_rhs_fusion", context)), + LinalgTransformationFilter(StringAttr::get(context, "rhs_fusion"), + StringAttr::get(context, "after_rhs_fusion")), LinalgTransformationFilter( - ArrayRef(), - Identifier::get("after_rhs_fusion_producer", context)), + ArrayRef(), + StringAttr::get(context, "after_rhs_fusion_producer")), LinalgTransformationFilter( - ArrayRef(), - Identifier::get("after_rhs_fusion_original", context))); + ArrayRef(), + StringAttr::get(context, "after_rhs_fusion_original"))); patterns.add>( context, dependenceGraph, LinalgTilingOptions().setTileSizes({32, 64, 16}).setLoopType(LoopType), LinalgFusionOptions().setIndicesToFuse({0, 2}), LinalgTransformationFilter( - Identifier::get("two_operand_fusion", context), - Identifier::get("after_two_operand_fusion", context)), + StringAttr::get(context, "two_operand_fusion"), + StringAttr::get(context, "after_two_operand_fusion")), LinalgTransformationFilter( - ArrayRef(), - Identifier::get("after_two_operand_fusion_producer", context)), + ArrayRef(), + StringAttr::get(context, "after_two_operand_fusion_producer")), LinalgTransformationFilter( - ArrayRef(), - Identifier::get("after_two_operand_fusion_original", context))); + ArrayRef(), + StringAttr::get(context, "after_two_operand_fusion_original"))); patterns.add>( context, dependenceGraph, LinalgTilingOptions().setTileSizes({32, 64}).setLoopType(LoopType), LinalgFusionOptions().setIndicesToFuse({0, 1}), LinalgTransformationFilter( - Identifier::get("transpose_fusion", context), - Identifier::get("after_transpose_fusion", context)), + StringAttr::get(context, "transpose_fusion"), + StringAttr::get(context, "after_transpose_fusion")), LinalgTransformationFilter( - ArrayRef(), - Identifier::get("after_transpose_fusion_producer", context)), + ArrayRef(), + StringAttr::get(context, "after_transpose_fusion_producer")), LinalgTransformationFilter( - ArrayRef(), - Identifier::get("after_transpose_fusion_original", context))); + ArrayRef(), + StringAttr::get(context, "after_transpose_fusion_original"))); } namespace { diff --git a/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp index 8f0b43a..c9ae47d 100644 --- a/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp @@ -145,35 +145,35 @@ static void applyPatterns(FuncOp funcOp) { //===--------------------------------------------------------------------===// patterns.add>( ctx, LinalgTilingOptions().setTileSizes({2000, 3000, 4000}), - LinalgTransformationFilter(Identifier::get("MEM", ctx), - Identifier::get("L3", ctx))); + LinalgTransformationFilter(StringAttr::get(ctx, "MEM"), + StringAttr::get(ctx, "L3"))); patterns.add>( ctx, LinalgTilingOptions().setTileSizes({200, 300, 400}), - LinalgTransformationFilter(Identifier::get("L3", ctx), - Identifier::get("L2", ctx))); + LinalgTransformationFilter(StringAttr::get(ctx, "L3"), + StringAttr::get(ctx, "L2"))); patterns.add>( ctx, LinalgTilingOptions().setTileSizes({20, 30, 40}), - LinalgTransformationFilter(Identifier::get("L2", ctx), - Identifier::get("L1", ctx))); + LinalgTransformationFilter(StringAttr::get(ctx, "L2"), + StringAttr::get(ctx, "L1"))); patterns.add>( ctx, LinalgTilingOptions().setTileSizes({2, 3, 4}), - LinalgTransformationFilter(Identifier::get("L1", ctx), - Identifier::get("REG", ctx))); + LinalgTransformationFilter(StringAttr::get(ctx, "L1"), + StringAttr::get(ctx, "REG"))); patterns.add>( ctx, LinalgTilingOptions().setTileSizes({5, 6}).setLoopType( LinalgTilingLoopType::ParallelLoops), - LinalgTransformationFilter(ArrayRef{}, - Identifier::get("L1", ctx))); + LinalgTransformationFilter(ArrayRef{}, + StringAttr::get(ctx, "L1"))); patterns.add>( ctx, LinalgTilingOptions().setTileSizes(8000), LinalgTransformationFilter( - ArrayRef{Identifier::get("MEM", ctx), - Identifier::get("L3", ctx), - Identifier::get("L2", ctx)}, - Identifier::get("REG", ctx))); + ArrayRef{StringAttr::get(ctx, "MEM"), + StringAttr::get(ctx, "L3"), + StringAttr::get(ctx, "L2")}, + StringAttr::get(ctx, "REG"))); //===--------------------------------------------------------------------===// // Linalg tiling and permutation patterns. @@ -183,24 +183,24 @@ static void applyPatterns(FuncOp funcOp) { LinalgTilingOptions() .setTileSizes({2000, 3000, 4000}) .setInterchange({1, 2, 0}), - LinalgTransformationFilter(Identifier::get("__with_perm__", ctx), - Identifier::get("L2__with_perm__", ctx))); + LinalgTransformationFilter(StringAttr::get(ctx, "__with_perm__"), + StringAttr::get(ctx, "L2__with_perm__"))); patterns.add>( ctx, LinalgTilingOptions() .setTileSizes({200, 300, 400}) .setInterchange({1, 0, 2}), - LinalgTransformationFilter(Identifier::get("L2__with_perm__", ctx), - Identifier::get("L1__with_perm__", ctx))); + LinalgTransformationFilter(StringAttr::get(ctx, "L2__with_perm__"), + StringAttr::get(ctx, "L1__with_perm__"))); patterns.add>( ctx, LinalgTilingOptions().setTileSizes({20, 30, 40}), - LinalgTransformationFilter(Identifier::get("L1__with_perm__", ctx), - Identifier::get("REG__with_perm__", ctx))); + LinalgTransformationFilter(StringAttr::get(ctx, "L1__with_perm__"), + StringAttr::get(ctx, "REG__with_perm__"))); patterns.add>( ctx, LinalgTilingOptions().setTileSizes({5, 6}).setInterchange({1, 0}), - LinalgTransformationFilter(Identifier::get("__with_perm__", ctx), - Identifier::get("L1__with_perm__", ctx))); + LinalgTransformationFilter(StringAttr::get(ctx, "__with_perm__"), + StringAttr::get(ctx, "L1__with_perm__"))); patterns.add>( ctx, @@ -209,8 +209,8 @@ static void applyPatterns(FuncOp funcOp) { .setInterchange({1, 2, 0}) .setLoopType(LinalgTilingLoopType::ParallelLoops), LinalgTransformationFilter( - Identifier::get("par__with_perm__", ctx), - Identifier::get("after_par__with_perm__", ctx))); + StringAttr::get(ctx, "par__with_perm__"), + StringAttr::get(ctx, "after_par__with_perm__"))); //===--------------------------------------------------------------------===// // Linalg to loops patterns. @@ -218,7 +218,7 @@ static void applyPatterns(FuncOp funcOp) { patterns.add>( ctx, /*loweringType=*/LinalgLoweringType::Loops, - LinalgTransformationFilter(Identifier::get("REG", ctx))); + LinalgTransformationFilter(StringAttr::get(ctx, "REG"))); //===--------------------------------------------------------------------===// // Linalg distribution patterns. @@ -229,7 +229,7 @@ static void applyPatterns(FuncOp funcOp) { // Linalg to vector contraction patterns. //===--------------------------------------------------------------------===// patterns.add( - ctx, LinalgTransformationFilter(Identifier::get("VECTORIZE", ctx)) + ctx, LinalgTransformationFilter(StringAttr::get(ctx, "VECTORIZE")) .addOpFilter()); //===--------------------------------------------------------------------===// @@ -238,24 +238,24 @@ static void applyPatterns(FuncOp funcOp) { patterns.add( ctx, /*interchangeVector=*/ArrayRef{1, 2, 0}, - LinalgTransformationFilter(ArrayRef{}, - Identifier::get("PERMUTED", ctx))); + LinalgTransformationFilter(ArrayRef{}, + StringAttr::get(ctx, "PERMUTED"))); //===--------------------------------------------------------------------===// // Linalg subview operands promotion. //===--------------------------------------------------------------------===// patterns.add>( ctx, LinalgPromotionOptions().setUseFullTileBuffersByDefault(true), - LinalgTransformationFilter(Identifier::get("_promote_views_", ctx), - Identifier::get("_views_promoted_", ctx))); + LinalgTransformationFilter(StringAttr::get(ctx, "_promote_views_"), + StringAttr::get(ctx, "_views_promoted_"))); patterns.add>( ctx, LinalgPromotionOptions() .setOperandsToPromote({0}) .setUseFullTileBuffersByDefault(true), LinalgTransformationFilter( - Identifier::get("_promote_first_view_", ctx), - Identifier::get("_first_view_promoted_", ctx))); + StringAttr::get(ctx, "_promote_first_view_"), + StringAttr::get(ctx, "_first_view_promoted_"))); patterns.add>( ctx, LinalgPromotionOptions() @@ -263,8 +263,8 @@ static void applyPatterns(FuncOp funcOp) { .setUseFullTileBuffers({false, true}) .setAlignment(32), LinalgTransformationFilter( - Identifier::get("_promote_views_aligned_", ctx), - Identifier::get("_views_aligned_promoted_", ctx))); + StringAttr::get(ctx, "_promote_views_aligned_"), + StringAttr::get(ctx, "_views_aligned_promoted_"))); (void)applyPatternsAndFoldGreedily(funcOp, std::move(patterns)); @@ -284,20 +284,20 @@ static void fillL1TilingAndMatmulToVectorPatterns( LinalgTilingOptions() .setTileSizes({8, 12, 16}) .setInterchange({1, 0, 2}), - LinalgTransformationFilter(Identifier::get(startMarker, ctx), - Identifier::get("L1", ctx)))); + LinalgTransformationFilter(StringAttr::get(ctx, startMarker), + StringAttr::get(ctx, "L1")))); patternsVector.emplace_back( ctx, std::make_unique>( ctx, LinalgPromotionOptions().setUseFullTileBuffersByDefault(true), - LinalgTransformationFilter(Identifier::get("L1", ctx), - Identifier::get("VEC", ctx)))); + LinalgTransformationFilter(StringAttr::get(ctx, "L1"), + StringAttr::get(ctx, "VEC")))); patternsVector.emplace_back( ctx, std::make_unique( MatmulOp::getOperationName(), ctx, LinalgVectorizationOptions(), - LinalgTransformationFilter(Identifier::get("VEC", ctx)))); + LinalgTransformationFilter(StringAttr::get(ctx, "VEC")))); patternsVector.back().add( ctx, LinalgTransformationFilter().addFilter( [](Operation *op) { return success(isa(op)); })); @@ -346,8 +346,8 @@ static void fillPromotionCallBackPatterns(MLIRContext *ctx, RewritePatternSet &patterns) { patterns.add>( ctx, LinalgTilingOptions().setTileSizes({16, 16, 16}), - LinalgTransformationFilter(Identifier::get("START", ctx), - Identifier::get("PROMOTE", ctx))); + LinalgTransformationFilter(StringAttr::get(ctx, "START"), + StringAttr::get(ctx, "PROMOTE"))); patterns.add>( ctx, LinalgPromotionOptions() @@ -361,7 +361,7 @@ static void fillPromotionCallBackPatterns(MLIRContext *ctx, [](OpBuilder &b, Value src, Value dst) -> LogicalResult { return copyCallBackFn(b, src, dst, true); }), - LinalgTransformationFilter(Identifier::get("PROMOTE", ctx))); + LinalgTransformationFilter(StringAttr::get(ctx, "PROMOTE"))); } template @@ -394,8 +394,8 @@ static void fillTileAndDistributePatterns(MLIRContext *context, .setLoopType(LinalgTilingLoopType::ParallelLoops) .setDistributionOptions(cyclicNprocsEqNiters), LinalgTransformationFilter( - Identifier::get("distribute1", context), - Identifier::get("after_distribute1", context))); + StringAttr::get(context, "distribute1"), + StringAttr::get(context, "after_distribute1"))); } { @@ -411,8 +411,8 @@ static void fillTileAndDistributePatterns(MLIRContext *context, .setLoopType(LinalgTilingLoopType::ParallelLoops) .setDistributionOptions(cyclicNprocsGeNiters), LinalgTransformationFilter( - Identifier::get("distribute2", context), - Identifier::get("after_distribute2", context))); + StringAttr::get(context, "distribute2"), + StringAttr::get(context, "after_distribute2"))); } { @@ -428,8 +428,8 @@ static void fillTileAndDistributePatterns(MLIRContext *context, .setLoopType(LinalgTilingLoopType::ParallelLoops) .setDistributionOptions(cyclicNprocsDefault), LinalgTransformationFilter( - Identifier::get("distribute3", context), - Identifier::get("after_distribute3", context))); + StringAttr::get(context, "distribute3"), + StringAttr::get(context, "after_distribute3"))); } { @@ -445,8 +445,8 @@ static void fillTileAndDistributePatterns(MLIRContext *context, .setLoopType(LinalgTilingLoopType::ParallelLoops) .setDistributionOptions(cyclicNprocsMixed1), LinalgTransformationFilter( - Identifier::get("distribute4", context), - Identifier::get("after_distribute4", context))); + StringAttr::get(context, "distribute4"), + StringAttr::get(context, "after_distribute4"))); } { @@ -462,8 +462,8 @@ static void fillTileAndDistributePatterns(MLIRContext *context, .setLoopType(LinalgTilingLoopType::ParallelLoops) .setDistributionOptions(cyclicNprocsMixed2), LinalgTransformationFilter( - Identifier::get("distribute5", context), - Identifier::get("after_distribute5", context))); + StringAttr::get(context, "distribute5"), + StringAttr::get(context, "after_distribute5"))); } { @@ -480,8 +480,8 @@ static void fillTileAndDistributePatterns(MLIRContext *context, .setLoopType(LinalgTilingLoopType::ParallelLoops) .setDistributionOptions(cyclicNprocsMixed3), LinalgTransformationFilter( - Identifier::get("distribute6", context), - Identifier::get("after_distribute6", context))); + StringAttr::get(context, "distribute6"), + StringAttr::get(context, "after_distribute6"))); } { @@ -495,10 +495,10 @@ static void fillTileAndDistributePatterns(MLIRContext *context, LinalgTilingOptions() .setTileSizes({8, 8, 4}) .setLoopType(LinalgTilingLoopType::Loops) - .setDistributionOptions(cyclicNprocsEqNiters), + .setDistributionOptions(cyclicNprocsEqNiters), LinalgTransformationFilter( - Identifier::get("tensors_distribute1", context), - Identifier::get("tensors_after_distribute1", context))); + StringAttr::get(context, "tensors_distribute1"), + StringAttr::get(context, "tensors_after_distribute1"))); } } @@ -517,8 +517,8 @@ applyMatmulToVectorPatterns(FuncOp funcOp, LinalgTilingOptions() .setTileSizes({768, 264, 768}) .setInterchange({1, 2, 0}), - LinalgTransformationFilter(Identifier::get("START", ctx), - Identifier::get("L2", ctx)))); + LinalgTransformationFilter(StringAttr::get(ctx, "START"), + StringAttr::get(ctx, "L2")))); fillL1TilingAndMatmulToVectorPatterns(funcOp, "L2", stage1Patterns); } { @@ -598,7 +598,7 @@ static void applyTilePattern(FuncOp funcOp, std::string loopType, tilingPattern.add, linalg::LinalgTilingPattern>( context, linalgTilingOptions, - linalg::LinalgTransformationFilter(Identifier::get("tile", context))); + linalg::LinalgTransformationFilter(StringAttr::get(context, "tile"))); (void)applyPatternsAndFoldGreedily(funcOp, std::move(tilingPattern)); } diff --git a/mlir/test/lib/Dialect/Shape/TestShapeFunctions.cpp b/mlir/test/lib/Dialect/Shape/TestShapeFunctions.cpp index b147945..03ab46a 100644 --- a/mlir/test/lib/Dialect/Shape/TestShapeFunctions.cpp +++ b/mlir/test/lib/Dialect/Shape/TestShapeFunctions.cpp @@ -31,7 +31,7 @@ void ReportShapeFnPass::runOnOperation() { auto module = getOperation(); // Report the shape function available to refine the op. - auto shapeFnId = Identifier::get("shape.function", &getContext()); + auto shapeFnId = StringAttr::get(&getContext(), "shape.function"); auto remarkShapeFn = [&](shape::FunctionLibraryOp shapeFnLib, Operation *op) { if (op->hasTrait()) return true; diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp index 6ee1e79..e52bdfb 100644 --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -963,7 +963,7 @@ static ParseResult parseStringAttrPrettyNameOp(OpAsmParser &parser, } auto namesAttr = parser.getBuilder().getStrArrayAttr(names); - result.attributes.push_back({Identifier::get("names", context), namesAttr}); + result.attributes.push_back({StringAttr::get(context, "names"), namesAttr}); return success(); } diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td index ee3f7ba..823c55f 100644 --- a/mlir/test/mlir-tblgen/op-attribute.td +++ b/mlir/test/mlir-tblgen/op-attribute.td @@ -43,19 +43,19 @@ def AOp : NS_Op<"a_op", []> { // DECL-SAME: {::llvm::StringRef("aAttr"), ::llvm::StringRef("bAttr"), ::llvm::StringRef("cAttr")}; // DECL-NEXT: return ::llvm::makeArrayRef(attrNames); -// DECL: ::mlir::Identifier aAttrAttrName() +// DECL: ::mlir::StringAttr aAttrAttrName() // DECL-NEXT: return getAttributeNameForIndex(0); -// DECL: ::mlir::Identifier aAttrAttrName(::mlir::OperationName name) +// DECL: ::mlir::StringAttr aAttrAttrName(::mlir::OperationName name) // DECL-NEXT: return getAttributeNameForIndex(name, 0); -// DECL: ::mlir::Identifier bAttrAttrName() +// DECL: ::mlir::StringAttr bAttrAttrName() // DECL-NEXT: return getAttributeNameForIndex(1); -// DECL: ::mlir::Identifier bAttrAttrName(::mlir::OperationName name) +// DECL: ::mlir::StringAttr bAttrAttrName(::mlir::OperationName name) // DECL-NEXT: return getAttributeNameForIndex(name, 1); -// DECL: ::mlir::Identifier cAttrAttrName() +// DECL: ::mlir::StringAttr cAttrAttrName() // DECL-NEXT: return getAttributeNameForIndex(2); -// DECL: ::mlir::Identifier cAttrAttrName(::mlir::OperationName name) +// DECL: ::mlir::StringAttr cAttrAttrName(::mlir::OperationName name) // DECL-NEXT: return getAttributeNameForIndex(name, 2); // DEF-LABEL: AOp definitions @@ -157,19 +157,19 @@ def AgetOp : Op { // DECL-SAME: {::llvm::StringRef("aAttr"), ::llvm::StringRef("bAttr"), ::llvm::StringRef("cAttr")}; // DECL-NEXT: return ::llvm::makeArrayRef(attrNames); -// DECL: ::mlir::Identifier getAAttrAttrName() +// DECL: ::mlir::StringAttr getAAttrAttrName() // DECL-NEXT: return getAttributeNameForIndex(0); -// DECL: ::mlir::Identifier getAAttrAttrName(::mlir::OperationName name) +// DECL: ::mlir::StringAttr getAAttrAttrName(::mlir::OperationName name) // DECL-NEXT: return getAttributeNameForIndex(name, 0); -// DECL: ::mlir::Identifier getBAttrAttrName() +// DECL: ::mlir::StringAttr getBAttrAttrName() // DECL-NEXT: return getAttributeNameForIndex(1); -// DECL: ::mlir::Identifier getBAttrAttrName(::mlir::OperationName name) +// DECL: ::mlir::StringAttr getBAttrAttrName(::mlir::OperationName name) // DECL-NEXT: return getAttributeNameForIndex(name, 1); -// DECL: ::mlir::Identifier getCAttrAttrName() +// DECL: ::mlir::StringAttr getCAttrAttrName() // DECL-NEXT: return getAttributeNameForIndex(2); -// DECL: ::mlir::Identifier getCAttrAttrName(::mlir::OperationName name) +// DECL: ::mlir::StringAttr getCAttrAttrName(::mlir::OperationName name) // DECL-NEXT: return getAttributeNameForIndex(name, 2); // DEF-LABEL: AgetOp definitions diff --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp index 507713e..63ce33a 100644 --- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp +++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp @@ -1092,7 +1092,7 @@ int main(int argc, char **argv) { } genContext.setLoc(NameLoc::get( - Identifier::get(opConfig.metadata->cppClassName, &mlirContext))); + StringAttr::get(&mlirContext, opConfig.metadata->cppClassName))); if (failed(generateOp(opConfig, genContext))) { return 1; } diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index 5e1cb84..b93a9e1 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -655,7 +655,7 @@ void OpEmitter::genAttrNameGetters() { // Emit the getAttributeNameForIndex methods. { auto *method = opClass.addInlineMethod( - "::mlir::Identifier", "getAttributeNameForIndex", + "::mlir::StringAttr", "getAttributeNameForIndex", MethodParameter("unsigned", "index")); ERROR_IF_PRUNED(method, "getAttributeNameForIndex", op); method->body() @@ -663,7 +663,7 @@ void OpEmitter::genAttrNameGetters() { } { auto *method = opClass.addStaticInlineMethod( - "::mlir::Identifier", "getAttributeNameForIndex", + "::mlir::StringAttr", "getAttributeNameForIndex", MethodParameter("::mlir::OperationName", "name"), MethodParameter("unsigned", "index")); ERROR_IF_PRUNED(method, "getAttributeNameForIndex", op); @@ -683,7 +683,7 @@ void OpEmitter::genAttrNameGetters() { // Generate the non-static variant. { auto *method = - opClass.addInlineMethod("::mlir::Identifier", methodName); + opClass.addInlineMethod("::mlir::StringAttr", methodName); ERROR_IF_PRUNED(method, methodName, op); method->body() << llvm::formatv(attrNameMethodBody, attrIt.second).str(); @@ -692,7 +692,7 @@ void OpEmitter::genAttrNameGetters() { // Generate the static variant. { auto *method = opClass.addStaticInlineMethod( - "::mlir::Identifier", methodName, + "::mlir::StringAttr", methodName, MethodParameter("::mlir::OperationName", "name")); ERROR_IF_PRUNED(method, methodName, op); method->body() << llvm::formatv(attrNameMethodBody, diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index bc74503..b217298 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -1145,7 +1145,7 @@ std::string PatternEmitter::handleLocationDirective(DagNode tree) { if (tree.getNumArgs() == 1) { DagLeaf leaf = tree.getArgAsLeaf(0); if (leaf.isStringAttr()) - return formatv("::mlir::NameLoc::get(rewriter.getIdentifier(\"{0}\"))", + return formatv("::mlir::NameLoc::get(rewriter.getStringAttr(\"{0}\"))", leaf.getStringAttr()) .str(); return lookUpArgLoc(0); @@ -1607,7 +1607,7 @@ void PatternEmitter::createAggregateLocalVarsForOpArgs( const char *addAttrCmd = "if (auto tmpAttr = {1}) {\n" - " tblgen_attrs.emplace_back(rewriter.getIdentifier(\"{0}\"), " + " tblgen_attrs.emplace_back(rewriter.getStringAttr(\"{0}\"), " "tmpAttr);\n}\n"; for (int argIndex = 0, e = resultOp.getNumArgs(); argIndex < e; ++argIndex) { if (resultOp.getArg(argIndex).is()) { diff --git a/mlir/tools/mlir-tblgen/StructsGen.cpp b/mlir/tools/mlir-tblgen/StructsGen.cpp index 52f5223..e33b74b 100644 --- a/mlir/tools/mlir-tblgen/StructsGen.cpp +++ b/mlir/tools/mlir-tblgen/StructsGen.cpp @@ -131,13 +131,13 @@ static void emitFactoryDef(llvm::StringRef structName, const char *getFieldInfo = R"( assert({0}); - auto {0}_id = ::mlir::Identifier::get("{0}", context); + auto {0}_id = ::mlir::StringAttr::get(context, "{0}"); fields.emplace_back({0}_id, {0}); )"; const char *getFieldInfoOptional = R"( if ({0}) { - auto {0}_id = ::mlir::Identifier::get("{0}", context); + auto {0}_id = ::mlir::StringAttr::get(context, "{0}"); fields.emplace_back({0}_id, {0}); } )"; diff --git a/mlir/unittests/IR/AttributeTest.cpp b/mlir/unittests/IR/AttributeTest.cpp index 19b57fa..f76ab45 100644 --- a/mlir/unittests/IR/AttributeTest.cpp +++ b/mlir/unittests/IR/AttributeTest.cpp @@ -8,7 +8,6 @@ #include "mlir/IR/BuiltinAttributes.h" #include "mlir/IR/BuiltinTypes.h" -#include "mlir/IR/Identifier.h" #include "gtest/gtest.h" using namespace mlir; @@ -152,7 +151,7 @@ TEST(DenseSplatTest, StringSplat) { MLIRContext context; context.allowUnregisteredDialects(); Type stringType = - OpaqueType::get(Identifier::get("test", &context), "string"); + OpaqueType::get(StringAttr::get(&context, "test"), "string"); StringRef value = "test-string"; testSplat(stringType, value); } @@ -161,7 +160,7 @@ TEST(DenseSplatTest, StringAttrSplat) { MLIRContext context; context.allowUnregisteredDialects(); Type stringType = - OpaqueType::get(Identifier::get("test", &context), "string"); + OpaqueType::get(StringAttr::get(&context, "test"), "string"); Attribute stringAttr = StringAttr::get("test-string", stringType); testSplat(stringType, stringAttr); } @@ -211,7 +210,7 @@ TEST(SparseElementsAttrTest, GetZero) { IntegerType intTy = IntegerType::get(&context, 32); FloatType floatTy = FloatType::getF32(&context); - Type stringTy = OpaqueType::get(Identifier::get("test", &context), "string"); + Type stringTy = OpaqueType::get(StringAttr::get(&context, "test"), "string"); ShapedType tensorI32 = RankedTensorType::get({2, 2}, intTy); ShapedType tensorF32 = RankedTensorType::get({2, 2}, floatTy); diff --git a/mlir/unittests/IR/OperationSupportTest.cpp b/mlir/unittests/IR/OperationSupportTest.cpp index 8c46d96..b0b48b0 100644 --- a/mlir/unittests/IR/OperationSupportTest.cpp +++ b/mlir/unittests/IR/OperationSupportTest.cpp @@ -237,10 +237,10 @@ TEST(NamedAttrListTest, TestAppendAssign) { { auto it = attrs.begin(); - EXPECT_EQ(it->first, b.getIdentifier("foo")); + EXPECT_EQ(it->first, b.getStringAttr("foo")); EXPECT_EQ(it->second, b.getStringAttr("bar")); ++it; - EXPECT_EQ(it->first, b.getIdentifier("baz")); + EXPECT_EQ(it->first, b.getStringAttr("baz")); EXPECT_EQ(it->second, b.getStringAttr("boo")); } @@ -261,10 +261,10 @@ TEST(NamedAttrListTest, TestAppendAssign) { { auto it = attrs.begin(); - EXPECT_EQ(it->first, b.getIdentifier("foo")); + EXPECT_EQ(it->first, b.getStringAttr("foo")); EXPECT_EQ(it->second, b.getStringAttr("f")); ++it; - EXPECT_EQ(it->first, b.getIdentifier("zoo")); + EXPECT_EQ(it->first, b.getStringAttr("zoo")); EXPECT_EQ(it->second, b.getStringAttr("z")); } diff --git a/mlir/unittests/TableGen/OpBuildGen.cpp b/mlir/unittests/TableGen/OpBuildGen.cpp index 672e441..5228390 100644 --- a/mlir/unittests/TableGen/OpBuildGen.cpp +++ b/mlir/unittests/TableGen/OpBuildGen.cpp @@ -15,7 +15,6 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/Identifier.h" #include "gmock/gmock.h" #include diff --git a/mlir/unittests/TableGen/StructsGenTest.cpp b/mlir/unittests/TableGen/StructsGenTest.cpp index 4fcdf1d..e1ebf1d6 100644 --- a/mlir/unittests/TableGen/StructsGenTest.cpp +++ b/mlir/unittests/TableGen/StructsGenTest.cpp @@ -9,7 +9,6 @@ #include "mlir/IR/Attributes.h" #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" -#include "mlir/IR/Identifier.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringSwitch.h" @@ -62,7 +61,7 @@ TEST(StructsGenTest, ClassofExtraFalse) { expectedValues.end()); // Add an extra NamedAttribute. - auto wrongId = mlir::Identifier::get("wrong", &context); + auto wrongId = mlir::StringAttr::get(&context, "wrong"); auto wrongAttr = mlir::NamedAttribute(wrongId, expectedValues[0].second); newValues.push_back(wrongAttr); @@ -83,8 +82,8 @@ TEST(StructsGenTest, ClassofBadNameFalse) { llvm::SmallVector newValues( expectedValues.begin() + 1, expectedValues.end()); - // Add a copy of the first attribute with the wrong Identifier. - auto wrongId = mlir::Identifier::get("wrong", &context); + // Add a copy of the first attribute with the wrong name. + auto wrongId = mlir::StringAttr::get(&context, "wrong"); auto wrongAttr = mlir::NamedAttribute(wrongId, expectedValues[0].second); newValues.push_back(wrongAttr); @@ -109,7 +108,7 @@ TEST(StructsGenTest, ClassofBadTypeFalse) { auto elementsType = mlir::RankedTensorType::get({3}, i64Type); auto elementsAttr = mlir::DenseIntElementsAttr::get(elementsType, ArrayRef{1, 2, 3}); - mlir::Identifier id = expectedValues.back().first; + mlir::StringAttr id = expectedValues.back().first; auto wrongAttr = mlir::NamedAttribute(id, elementsAttr); newValues.push_back(wrongAttr); diff --git a/mlir/utils/gdb-scripts/prettyprinters.py b/mlir/utils/gdb-scripts/prettyprinters.py index 84a9a45..b495b7c 100644 --- a/mlir/utils/gdb-scripts/prettyprinters.py +++ b/mlir/utils/gdb-scripts/prettyprinters.py @@ -3,20 +3,6 @@ import gdb.printing -class IdentifierPrinter: - """Prints an mlir::Identifier instance.""" - - def __init__(self, val): - self.entry = val['entry'] - - def to_string(self): - ptr = (self.entry + 1).cast(gdb.lookup_type('char').pointer()) - return ptr.string(length=self.entry['keyLength']) - - def display_hint(self): - return 'string' - - class StoragePrinter: """Prints bases of a struct and its fields.""" @@ -159,8 +145,6 @@ def get_attr_or_type_printer(val, get_type_id): pp = gdb.printing.RegexpCollectionPrettyPrinter('MLIRSupport') -pp.add_printer('mlir::Identifier', '^mlir::Identifier$', IdentifierPrinter) - # Printers for types deriving from AttributeStorage or TypeStorage. pp.add_printer('mlir::detail::FusedLocationStorage', '^mlir::detail::FusedLocationStorage', -- 2.7.4