Skip to content

Commit 195730a

Browse files
committed
[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
1 parent e7568b6 commit 195730a

File tree

85 files changed

+350
-385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+350
-385
lines changed

mlir/docs/DataLayout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ conceptually a collection of key-value pairs called data layout specification
102102
_entries_. Data layout specification attributes implement the
103103
`DataLayoutSpecInterface`, described below. Each entry is itself an attribute
104104
that implements the `DataLayoutEntryInterface`. Entries have a key, either a
105-
`Type` or an `Identifier`, and a value. Keys are used to associate entries with
105+
`Type` or a `StringAttr`, and a value. Keys are used to associate entries with
106106
specific types or dialects: when handling a data layout properties request, a
107107
type or a dialect can only see the specification entries relevant to them and
108108
must go through the supplied `DataLayout` object for any recursive query. This

mlir/docs/Interfaces.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ operations by overriding the `getRegisteredInterfaceForOp` method :
327327

328328
```c++
329329
void *TestDialect::getRegisteredInterfaceForOp(TypeID typeID,
330-
Identifier opName) {
330+
StringAttr opName) {
331331
if (typeID == TypeID::get<ExampleOpInterface>()) {
332332
if (isSupported(opName))
333333
return fallbackExampleOpInterface;

mlir/docs/Tutorials/DataFlowAnalysis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ struct MetadataLatticeValue {
137137

138138
/// Our value represents the combined metadata, which is originally a
139139
/// DictionaryAttr, so we use a map.
140-
DenseMap<Identifier, Attribute> metadata;
140+
DenseMap<StringAttr, Attribute> metadata;
141141
};
142142
```
143143

mlir/examples/toy/Ch2/mlir/MLIRGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class MLIRGenImpl {
9393

9494
/// Helper conversion for a Toy AST location to an MLIR location.
9595
mlir::Location loc(Location loc) {
96-
return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line,
96+
return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line,
9797
loc.col);
9898
}
9999

mlir/examples/toy/Ch3/mlir/MLIRGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class MLIRGenImpl {
9393

9494
/// Helper conversion for a Toy AST location to an MLIR location.
9595
mlir::Location loc(Location loc) {
96-
return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line,
96+
return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line,
9797
loc.col);
9898
}
9999

mlir/examples/toy/Ch4/mlir/MLIRGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class MLIRGenImpl {
9393

9494
/// Helper conversion for a Toy AST location to an MLIR location.
9595
mlir::Location loc(Location loc) {
96-
return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line,
96+
return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line,
9797
loc.col);
9898
}
9999

mlir/examples/toy/Ch5/mlir/MLIRGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class MLIRGenImpl {
9393

9494
/// Helper conversion for a Toy AST location to an MLIR location.
9595
mlir::Location loc(Location loc) {
96-
return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line,
96+
return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line,
9797
loc.col);
9898
}
9999

mlir/examples/toy/Ch6/mlir/MLIRGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class MLIRGenImpl {
9393

9494
/// Helper conversion for a Toy AST location to an MLIR location.
9595
mlir::Location loc(Location loc) {
96-
return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line,
96+
return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line,
9797
loc.col);
9898
}
9999

mlir/examples/toy/Ch7/mlir/MLIRGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class MLIRGenImpl {
113113

114114
/// Helper conversion for a Toy AST location to an MLIR location.
115115
mlir::Location loc(Location loc) {
116-
return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line,
116+
return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line,
117117
loc.col);
118118
}
119119

mlir/include/mlir/CAPI/IR.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "mlir/CAPI/Wrap.h"
1919
#include "mlir/IR/BuiltinOps.h"
20-
#include "mlir/IR/Identifier.h"
2120
#include "mlir/IR/MLIRContext.h"
2221
#include "mlir/IR/Operation.h"
2322

mlir/include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def AffineMapAccessInterface : OpInterface<"AffineMapAccessInterface"> {
167167
ConcreteOp op = cast<ConcreteOp>(this->getOperation());
168168
assert(memref == op.getMemRef() &&
169169
"Expected memref argument to match memref operand");
170-
return {Identifier::get(op.getMapAttrName(), op.getContext()),
170+
return {StringAttr::get(op.getContext(), op.getMapAttrName()),
171171
op.getAffineMapAttr()};
172172
}]
173173
>,

mlir/include/mlir/Dialect/Affine/IR/AffineOps.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,14 @@ class AffineDmaStartOp
188188
/// Returns the AffineMapAttr associated with 'memref'.
189189
NamedAttribute getAffineMapAttrForMemRef(Value memref) {
190190
if (memref == getSrcMemRef())
191-
return {Identifier::get(getSrcMapAttrName(), getContext()),
191+
return {StringAttr::get(getContext(), getSrcMapAttrName()),
192192
getSrcMapAttr()};
193193
if (memref == getDstMemRef())
194-
return {Identifier::get(getDstMapAttrName(), getContext()),
194+
return {StringAttr::get(getContext(), getDstMapAttrName()),
195195
getDstMapAttr()};
196196
assert(memref == getTagMemRef() &&
197197
"DmaStartOp expected source, destination or tag memref");
198-
return {Identifier::get(getTagMapAttrName(), getContext()),
198+
return {StringAttr::get(getContext(), getTagMapAttrName()),
199199
getTagMapAttr()};
200200
}
201201

@@ -303,7 +303,7 @@ class AffineDmaWaitOp
303303
/// associated with 'memref'.
304304
NamedAttribute getAffineMapAttrForMemRef(Value memref) {
305305
assert(memref == getTagMemRef());
306-
return {Identifier::get(getTagMapAttrName(), getContext()),
306+
return {StringAttr::get(getContext(), getTagMapAttrName()),
307307
getTagMapAttr()};
308308
}
309309

mlir/include/mlir/Dialect/Affine/IR/AffineOps.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def AffineForOp : Affine_Op<"for",
309309
void setStep(int64_t step) {
310310
assert(step > 0 && "step has to be a positive integer constant");
311311
auto *context = getLowerBoundMap().getContext();
312-
(*this)->setAttr(Identifier::get(getStepAttrName(), context),
312+
(*this)->setAttr(StringAttr::get(context, getStepAttrName()),
313313
IntegerAttr::get(IndexType::get(context), step));
314314
}
315315

@@ -815,7 +815,7 @@ def AffinePrefetchOp : Affine_Op<"prefetch",
815815
NamedAttribute getAffineMapAttrForMemRef(Value mref) {
816816
assert(mref == memref() &&
817817
"Expected mref argument to match memref operand");
818-
return {Identifier::get(getMapAttrName(), getContext()),
818+
return {StringAttr::get(getContext(), getMapAttrName()),
819819
getAffineMapAttr()};
820820
}
821821

mlir/include/mlir/Dialect/DLTI/DLTI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class DataLayoutEntryAttr
4141
constexpr const static llvm::StringLiteral kAttrKeyword = "dl_entry";
4242

4343
/// Returns the entry with the given key and value.
44-
static DataLayoutEntryAttr get(Identifier key, Attribute value);
44+
static DataLayoutEntryAttr get(StringAttr key, Attribute value);
4545
static DataLayoutEntryAttr get(Type key, Attribute value);
4646

4747
/// Returns the key of this entry.

mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "mlir/Dialect/Utils/StaticValueUtils.h"
1818
#include "mlir/Dialect/Vector/VectorTransforms.h"
1919
#include "mlir/Dialect/X86Vector/Transforms.h"
20-
#include "mlir/IR/Identifier.h"
2120
#include "mlir/IR/PatternMatch.h"
2221
#include "mlir/Transforms/Bufferize.h"
2322
#include "llvm/ADT/SmallBitVector.h"
@@ -426,12 +425,12 @@ struct LinalgTransformationFilter {
426425
using FilterFunction = std::function<LogicalResult(Operation *)>;
427426

428427
explicit LinalgTransformationFilter(
429-
ArrayRef<Identifier> matchDisjunction = {},
430-
Optional<Identifier> replacement = None);
428+
ArrayRef<StringAttr> matchDisjunction = {},
429+
Optional<StringAttr> replacement = None);
431430

432431
explicit LinalgTransformationFilter(
433-
FilterFunction f, ArrayRef<Identifier> matchDisjunction = {},
434-
Optional<Identifier> replacement = None);
432+
FilterFunction f, ArrayRef<StringAttr> matchDisjunction = {},
433+
Optional<StringAttr> replacement = None);
435434

436435
LinalgTransformationFilter(LinalgTransformationFilter &&) = default;
437436
LinalgTransformationFilter(const LinalgTransformationFilter &) = default;
@@ -456,8 +455,8 @@ struct LinalgTransformationFilter {
456455

457456
private:
458457
SmallVector<FilterFunction> filters;
459-
SmallVector<Identifier> matchDisjunction;
460-
Optional<Identifier> replacement;
458+
SmallVector<StringAttr> matchDisjunction;
459+
Optional<StringAttr> replacement;
461460
/// When set to true, if the attribute is not set, it will be treated as
462461
/// a match. Default is false.
463462
bool matchByDefault;

mlir/include/mlir/IR/Attributes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ inline ::llvm::hash_code hash_value(Attribute arg) {
136136
// NamedAttribute
137137
//===----------------------------------------------------------------------===//
138138

139-
/// NamedAttribute is combination of a name, represented by an Identifier, and a
139+
/// NamedAttribute is combination of a name, represented by a StringAttr, and a
140140
/// value, represented by an Attribute. The attribute pointer should always be
141141
/// non-null.
142-
using NamedAttribute = std::pair<Identifier, Attribute>;
142+
using NamedAttribute = std::pair<StringAttr, Attribute>;
143143

144144
bool operator<(const NamedAttribute &lhs, const NamedAttribute &rhs);
145145
bool operator<(const NamedAttribute &lhs, StringRef rhs);

mlir/include/mlir/IR/Builders.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Builder {
5353

5454
MLIRContext *getContext() const { return context; }
5555

56-
Identifier getIdentifier(const Twine &str);
56+
StringAttr getIdentifier(const Twine &str);
5757

5858
// Locations.
5959
Location getUnknownLoc();

mlir/include/mlir/IR/BuiltinAttributes.td

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,15 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary", [
379379

380380
/// Return the specified attribute if present, null otherwise.
381381
Attribute get(StringRef name) const;
382-
Attribute get(Identifier name) const;
382+
Attribute get(StringAttr name) const;
383383

384384
/// Return the specified named attribute if present, None otherwise.
385385
Optional<NamedAttribute> getNamed(StringRef name) const;
386-
Optional<NamedAttribute> getNamed(Identifier name) const;
386+
Optional<NamedAttribute> getNamed(StringAttr name) const;
387387

388388
/// Return whether the specified attribute is present.
389389
bool contains(StringRef name) const;
390-
bool contains(Identifier name) const;
390+
bool contains(StringAttr name) const;
391391

392392
/// Support range iteration.
393393
using iterator = llvm::ArrayRef<NamedAttribute>::iterator;
@@ -641,11 +641,11 @@ def Builtin_OpaqueAttr : Builtin_Attr<"Opaque"> {
641641
#dialect<"opaque attribute data">
642642
```
643643
}];
644-
let parameters = (ins "Identifier":$dialectNamespace,
644+
let parameters = (ins "StringAttr":$dialectNamespace,
645645
StringRefParameter<"">:$attrData,
646646
AttributeSelfTypeParameter<"">:$type);
647647
let builders = [
648-
AttrBuilderWithInferredContext<(ins "Identifier":$dialect,
648+
AttrBuilderWithInferredContext<(ins "StringAttr":$dialect,
649649
"StringRef":$attrData,
650650
"Type":$type), [{
651651
return $_get(dialect.getContext(), dialect, attrData, type);
@@ -688,11 +688,11 @@ def Builtin_OpaqueElementsAttr : Builtin_Attr<
688688

689689
// TODO: Provide a way to avoid copying content of large opaque
690690
// tensors This will likely require a new reference attribute kind.
691-
let parameters = (ins "Identifier":$dialect,
691+
let parameters = (ins "StringAttr":$dialect,
692692
StringRefParameter<"">:$value,
693693
AttributeSelfTypeParameter<"", "ShapedType">:$type);
694694
let builders = [
695-
AttrBuilderWithInferredContext<(ins "Identifier":$dialect,
695+
AttrBuilderWithInferredContext<(ins "StringAttr":$dialect,
696696
"ShapedType":$type,
697697
"StringRef":$value), [{
698698
return $_get(dialect.getContext(), dialect, value, type);
@@ -701,7 +701,7 @@ def Builtin_OpaqueElementsAttr : Builtin_Attr<
701701
"ShapedType":$type,
702702
"StringRef":$value), [{
703703
MLIRContext *ctxt = dialect->getContext();
704-
Identifier dialectName = Identifier::get(dialect->getNamespace(), ctxt);
704+
StringAttr dialectName = StringAttr::get(ctxt, dialect->getNamespace());
705705
return $_get(ctxt, dialectName, value, type);
706706
}]>
707707
];

mlir/include/mlir/IR/BuiltinLocationAttributes.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,18 @@ def FileLineColLoc : Builtin_LocationAttr<"FileLineColLoc"> {
8181
loc("mysource.cc":10:8)
8282
```
8383
}];
84-
let parameters = (ins "Identifier":$filename, "unsigned":$line,
84+
let parameters = (ins "StringAttr":$filename, "unsigned":$line,
8585
"unsigned":$column);
8686
let builders = [
87-
AttrBuilderWithInferredContext<(ins "Identifier":$filename,
87+
AttrBuilderWithInferredContext<(ins "StringAttr":$filename,
8888
"unsigned":$line,
8989
"unsigned":$column), [{
9090
return $_get(filename.getContext(), filename, line, column);
9191
}]>,
9292
AttrBuilder<(ins "StringRef":$filename, "unsigned":$line,
9393
"unsigned":$column), [{
9494
return $_get($_ctxt,
95-
Identifier::get(filename.empty() ? "-" : filename, $_ctxt),
95+
StringAttr::get($_ctxt, filename.empty() ? "-" : filename),
9696
line, column);
9797
}]>
9898
];
@@ -161,13 +161,13 @@ def NameLoc : Builtin_LocationAttr<"NameLoc"> {
161161
loc("CSE"("mysource.cc":10:8))
162162
```
163163
}];
164-
let parameters = (ins "Identifier":$name, "Location":$childLoc);
164+
let parameters = (ins "StringAttr":$name, "Location":$childLoc);
165165
let builders = [
166-
AttrBuilderWithInferredContext<(ins "Identifier":$name,
166+
AttrBuilderWithInferredContext<(ins "StringAttr":$name,
167167
"Location":$childLoc), [{
168168
return $_get(name.getContext(), name, childLoc);
169169
}]>,
170-
AttrBuilderWithInferredContext<(ins "Identifier":$name), [{
170+
AttrBuilderWithInferredContext<(ins "StringAttr":$name), [{
171171
return $_get(name.getContext(), name,
172172
UnknownLoc::get(name.getContext()));
173173
}]>

mlir/include/mlir/IR/BuiltinTypes.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ class IntegerType;
2525
class StringAttr;
2626
class TypeRange;
2727

28-
// TODO: Remove this when all usages have been replaced with StringAttr.
29-
using Identifier = StringAttr;
30-
3128
//===----------------------------------------------------------------------===//
3229
// FloatType
3330
//===----------------------------------------------------------------------===//

mlir/include/mlir/IR/BuiltinTypes.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,13 +600,13 @@ def Builtin_Opaque : Builtin_Type<"Opaque"> {
600600
```
601601
}];
602602
let parameters = (ins
603-
"Identifier":$dialectNamespace,
603+
"StringAttr":$dialectNamespace,
604604
StringRefParameter<"">:$typeData
605605
);
606606

607607
let builders = [
608608
TypeBuilderWithInferredContext<(ins
609-
"Identifier":$dialectNamespace, CArg<"StringRef", "{}">:$typeData
609+
"StringAttr":$dialectNamespace, CArg<"StringRef", "{}">:$typeData
610610
), [{
611611
return $_get(dialectNamespace.getContext(), dialectNamespace, typeData);
612612
}]>

0 commit comments

Comments
 (0)