diff --git a/mlir/include/mlir/IR/Identifier.h b/mlir/include/mlir/IR/Identifier.h --- a/mlir/include/mlir/IR/Identifier.h +++ b/mlir/include/mlir/IR/Identifier.h @@ -83,10 +83,15 @@ } // Identifier/Identifier equality comparisons are defined inline. -inline bool operator==(Identifier lhs, StringRef rhs) { return lhs.is(rhs); } -inline bool operator!=(Identifier lhs, StringRef rhs) { return !lhs.is(rhs); } -inline bool operator==(StringRef lhs, Identifier rhs) { return rhs.is(lhs); } -inline bool operator!=(StringRef lhs, Identifier rhs) { return !rhs.is(lhs); } +inline bool operator==(Identifier lhs, StringRef rhs) { + return lhs.strref() == rhs; +} +inline bool operator!=(Identifier lhs, StringRef rhs) { return !(lhs == rhs); } + +inline bool operator==(StringRef lhs, Identifier rhs) { + return rhs.strref() == lhs; +} +inline bool operator!=(StringRef lhs, Identifier rhs) { return !(lhs == rhs); } // Make identifiers hashable. inline llvm::hash_code hash_value(Identifier arg) { diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp --- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp +++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp @@ -138,9 +138,9 @@ // not specific to function modeling. SmallVector attributes; for (const auto &attr : gpuFuncOp.getAttrs()) { - if (attr.first.is(SymbolTable::getSymbolAttrName()) || - attr.first.is(impl::getTypeAttrName()) || - attr.first.is(gpu::GPUFuncOp::getNumWorkgroupAttributionsAttrName())) + if (attr.first == SymbolTable::getSymbolAttrName() || + attr.first == impl::getTypeAttrName() || + attr.first == gpu::GPUFuncOp::getNumWorkgroupAttributionsAttrName()) continue; attributes.push_back(attr); } diff --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp --- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp @@ -329,8 +329,8 @@ rewriter.getFunctionType(signatureConverter.getConvertedTypes(), llvm::None)); for (const auto &namedAttr : funcOp.getAttrs()) { - if (namedAttr.first.is(impl::getTypeAttrName()) || - namedAttr.first.is(SymbolTable::getSymbolAttrName())) + if (namedAttr.first == impl::getTypeAttrName() || + namedAttr.first == SymbolTable::getSymbolAttrName()) continue; newFuncOp.setAttr(namedAttr.first, namedAttr.second); } diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -797,9 +797,8 @@ bool filterArgAttrs, SmallVectorImpl &result) { for (const auto &attr : attrs) { - if (attr.first.is(SymbolTable::getSymbolAttrName()) || - attr.first.is(impl::getTypeAttrName()) || - attr.first.is("std.varargs") || + if (attr.first == SymbolTable::getSymbolAttrName() || + attr.first == impl::getTypeAttrName() || attr.first == "std.varargs" || (filterArgAttrs && impl::isArgAttrName(attr.first.strref()))) continue; result.push_back(attr); diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -44,7 +44,7 @@ LogicalResult GPUDialect::verifyOperationAttribute(Operation *op, NamedAttribute attr) { if (!attr.second.isa() || - !attr.first.is(getContainerModuleAttrName())) + attr.first != getContainerModuleAttrName()) return success(); auto module = dyn_cast(op); diff --git a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp --- a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp @@ -468,8 +468,8 @@ // Copy over all attributes other than the function name and type. for (const auto &namedAttr : funcOp.getAttrs()) { - if (!namedAttr.first.is(impl::getTypeAttrName()) && - !namedAttr.first.is(SymbolTable::getSymbolAttrName())) + if (namedAttr.first != impl::getTypeAttrName() && + namedAttr.first != SymbolTable::getSymbolAttrName()) newFuncOp.setAttr(namedAttr.first, namedAttr.second); } diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp --- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp @@ -818,7 +818,7 @@ operands); for (auto attr : op.getAttrs()) { if (llvm::any_of(elidedAttrs, - [&](StringRef elided) { return attr.first.is(elided); })) { + [&](StringRef elided) { return attr.first == elided; })) { continue; } if (failed(processDecoration(op.getLoc(), resultID, attr))) { @@ -886,7 +886,7 @@ // Encode decorations. for (auto attr : varOp.getAttrs()) { if (llvm::any_of(elidedAttrs, - [&](StringRef elided) { return attr.first.is(elided); })) { + [&](StringRef elided) { return attr.first == elided; })) { continue; } if (failed(processDecoration(varOp.getLoc(), resultID, attr))) { diff --git a/mlir/lib/IR/Attributes.cpp b/mlir/lib/IR/Attributes.cpp --- a/mlir/lib/IR/Attributes.cpp +++ b/mlir/lib/IR/Attributes.cpp @@ -161,7 +161,7 @@ return strncmp(attr.first.data(), name.data(), name.size()) < 0; }; auto it = llvm::lower_bound(values, name, compare); - return it != values.end() && it->first.is(name) ? it->second : Attribute(); + return it != values.end() && it->first == name ? it->second : Attribute(); } Attribute DictionaryAttr::get(Identifier name) const { for (auto elt : getValue()) diff --git a/mlir/lib/IR/TypeUtilities.cpp b/mlir/lib/IR/TypeUtilities.cpp --- a/mlir/lib/IR/TypeUtilities.cpp +++ b/mlir/lib/IR/TypeUtilities.cpp @@ -43,7 +43,7 @@ bool mlir::isOpaqueTypeWithName(Type type, StringRef dialect, StringRef typeData) { if (auto opaque = type.dyn_cast()) - return opaque.getDialectNamespace().is(dialect) && + return opaque.getDialectNamespace() == dialect && opaque.getTypeData() == typeData; return false; } diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -408,7 +408,7 @@ // If the attribute dictionary contains no 'names' attribute, infer it from // the SSA name (if specified). bool hadNames = llvm::any_of(result.attributes, [](NamedAttribute attr) { - return attr.first.is("names"); + return attr.first == "names"; }); // If there was no name specified, check to see if there was a useful name diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp --- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp +++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp @@ -617,7 +617,7 @@ os << tabs << formatv("for (auto attr : {0}.getAttrs()) {{\n", opVar); os << tabs << formatv(" if (llvm::any_of({0}, [&](StringRef elided)", elidedAttrs); - os << " {return attr.first.is(elided);})) {\n"; + os << " {return attr.first == elided;})) {\n"; os << tabs << " continue;\n"; os << tabs << " }\n"; os << tabs