Skip to content

Commit 74e6a5b

Browse files
committed
Eliminate all uses of Identifier::is() in the source tree, this doesn't remove the definition of it (yet). NFC.
Reviewers: mravishankar, antiagainst, herhut, rriddle! Subscribers: jholewinski, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, bader, grosul1, frgossen, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D78042
1 parent dc89a3e commit 74e6a5b

File tree

11 files changed

+25
-21
lines changed

11 files changed

+25
-21
lines changed

mlir/include/mlir/IR/Identifier.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,15 @@ inline raw_ostream &operator<<(raw_ostream &os, Identifier identifier) {
8383
}
8484

8585
// Identifier/Identifier equality comparisons are defined inline.
86-
inline bool operator==(Identifier lhs, StringRef rhs) { return lhs.is(rhs); }
87-
inline bool operator!=(Identifier lhs, StringRef rhs) { return !lhs.is(rhs); }
88-
inline bool operator==(StringRef lhs, Identifier rhs) { return rhs.is(lhs); }
89-
inline bool operator!=(StringRef lhs, Identifier rhs) { return !rhs.is(lhs); }
86+
inline bool operator==(Identifier lhs, StringRef rhs) {
87+
return lhs.strref() == rhs;
88+
}
89+
inline bool operator!=(Identifier lhs, StringRef rhs) { return !(lhs == rhs); }
90+
91+
inline bool operator==(StringRef lhs, Identifier rhs) {
92+
return rhs.strref() == lhs;
93+
}
94+
inline bool operator!=(StringRef lhs, Identifier rhs) { return !(lhs == rhs); }
9095

9196
// Make identifiers hashable.
9297
inline llvm::hash_code hash_value(Identifier arg) {

mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ struct GPUFuncOpLowering : ConvertToLLVMPattern {
138138
// not specific to function modeling.
139139
SmallVector<NamedAttribute, 4> attributes;
140140
for (const auto &attr : gpuFuncOp.getAttrs()) {
141-
if (attr.first.is(SymbolTable::getSymbolAttrName()) ||
142-
attr.first.is(impl::getTypeAttrName()) ||
143-
attr.first.is(gpu::GPUFuncOp::getNumWorkgroupAttributionsAttrName()))
141+
if (attr.first == SymbolTable::getSymbolAttrName() ||
142+
attr.first == impl::getTypeAttrName() ||
143+
attr.first == gpu::GPUFuncOp::getNumWorkgroupAttributionsAttrName())
144144
continue;
145145
attributes.push_back(attr);
146146
}

mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, SPIRVTypeConverter &typeConverter,
329329
rewriter.getFunctionType(signatureConverter.getConvertedTypes(),
330330
llvm::None));
331331
for (const auto &namedAttr : funcOp.getAttrs()) {
332-
if (namedAttr.first.is(impl::getTypeAttrName()) ||
333-
namedAttr.first.is(SymbolTable::getSymbolAttrName()))
332+
if (namedAttr.first == impl::getTypeAttrName() ||
333+
namedAttr.first == SymbolTable::getSymbolAttrName())
334334
continue;
335335
newFuncOp.setAttr(namedAttr.first, namedAttr.second);
336336
}

mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -797,9 +797,8 @@ static void filterFuncAttributes(ArrayRef<NamedAttribute> attrs,
797797
bool filterArgAttrs,
798798
SmallVectorImpl<NamedAttribute> &result) {
799799
for (const auto &attr : attrs) {
800-
if (attr.first.is(SymbolTable::getSymbolAttrName()) ||
801-
attr.first.is(impl::getTypeAttrName()) ||
802-
attr.first.is("std.varargs") ||
800+
if (attr.first == SymbolTable::getSymbolAttrName() ||
801+
attr.first == impl::getTypeAttrName() || attr.first == "std.varargs" ||
803802
(filterArgAttrs && impl::isArgAttrName(attr.first.strref())))
804803
continue;
805804
result.push_back(attr);

mlir/lib/Dialect/GPU/IR/GPUDialect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ GPUDialect::GPUDialect(MLIRContext *context)
4444
LogicalResult GPUDialect::verifyOperationAttribute(Operation *op,
4545
NamedAttribute attr) {
4646
if (!attr.second.isa<UnitAttr>() ||
47-
!attr.first.is(getContainerModuleAttrName()))
47+
attr.first != getContainerModuleAttrName())
4848
return success();
4949

5050
auto module = dyn_cast<ModuleOp>(op);

mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ FuncOpConversion::matchAndRewrite(FuncOp funcOp, ArrayRef<Value> operands,
468468

469469
// Copy over all attributes other than the function name and type.
470470
for (const auto &namedAttr : funcOp.getAttrs()) {
471-
if (!namedAttr.first.is(impl::getTypeAttrName()) &&
472-
!namedAttr.first.is(SymbolTable::getSymbolAttrName()))
471+
if (namedAttr.first != impl::getTypeAttrName() &&
472+
namedAttr.first != SymbolTable::getSymbolAttrName())
473473
newFuncOp.setAttr(namedAttr.first, namedAttr.second);
474474
}
475475

mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ LogicalResult Serializer::processVariableOp(spirv::VariableOp op) {
827827
operands);
828828
for (auto attr : op.getAttrs()) {
829829
if (llvm::any_of(elidedAttrs,
830-
[&](StringRef elided) { return attr.first.is(elided); })) {
830+
[&](StringRef elided) { return attr.first == elided; })) {
831831
continue;
832832
}
833833
if (failed(processDecoration(op.getLoc(), resultID, attr))) {
@@ -895,7 +895,7 @@ Serializer::processGlobalVariableOp(spirv::GlobalVariableOp varOp) {
895895
// Encode decorations.
896896
for (auto attr : varOp.getAttrs()) {
897897
if (llvm::any_of(elidedAttrs,
898-
[&](StringRef elided) { return attr.first.is(elided); })) {
898+
[&](StringRef elided) { return attr.first == elided; })) {
899899
continue;
900900
}
901901
if (failed(processDecoration(varOp.getLoc(), resultID, attr))) {

mlir/lib/IR/Attributes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Attribute DictionaryAttr::get(StringRef name) const {
161161
return strncmp(attr.first.data(), name.data(), name.size()) < 0;
162162
};
163163
auto it = llvm::lower_bound(values, name, compare);
164-
return it != values.end() && it->first.is(name) ? it->second : Attribute();
164+
return it != values.end() && it->first == name ? it->second : Attribute();
165165
}
166166
Attribute DictionaryAttr::get(Identifier name) const {
167167
for (auto elt : getValue())

mlir/lib/IR/TypeUtilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ SmallVector<Type, 10> mlir::getFlattenedTypes(TupleType t) {
4343
bool mlir::isOpaqueTypeWithName(Type type, StringRef dialect,
4444
StringRef typeData) {
4545
if (auto opaque = type.dyn_cast<mlir::OpaqueType>())
46-
return opaque.getDialectNamespace().is(dialect) &&
46+
return opaque.getDialectNamespace() == dialect &&
4747
opaque.getTypeData() == typeData;
4848
return false;
4949
}

mlir/test/lib/Dialect/Test/TestDialect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static ParseResult parseStringAttrPrettyNameOp(OpAsmParser &parser,
408408
// If the attribute dictionary contains no 'names' attribute, infer it from
409409
// the SSA name (if specified).
410410
bool hadNames = llvm::any_of(result.attributes, [](NamedAttribute attr) {
411-
return attr.first.is("names");
411+
return attr.first == "names";
412412
});
413413

414414
// If there was no name specified, check to see if there was a useful name

mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ static void emitDecorationSerialization(const Operator &op, StringRef tabs,
617617
os << tabs << formatv("for (auto attr : {0}.getAttrs()) {{\n", opVar);
618618
os << tabs
619619
<< formatv(" if (llvm::any_of({0}, [&](StringRef elided)", elidedAttrs);
620-
os << " {return attr.first.is(elided);})) {\n";
620+
os << " {return attr.first == elided;})) {\n";
621621
os << tabs << " continue;\n";
622622
os << tabs << " }\n";
623623
os << tabs

0 commit comments

Comments
 (0)