Eliminate all uses of Identifier::is() in the source tree, this doesn't remove the...
authorChris Lattner <clattner@nondot.org>
Mon, 13 Apr 2020 18:17:35 +0000 (11:17 -0700)
committerChris Lattner <clattner@nondot.org>
Mon, 13 Apr 2020 18:49:31 +0000 (11:49 -0700)
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

mlir/include/mlir/IR/Identifier.h
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
mlir/lib/IR/Attributes.cpp
mlir/lib/IR/TypeUtilities.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp

index ce0f119..98a792a 100644 (file)
@@ -83,10 +83,15 @@ inline raw_ostream &operator<<(raw_ostream &os, Identifier identifier) {
 }
 
 // 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) {
index 9391466..66a0a94 100644 (file)
@@ -138,9 +138,9 @@ struct GPUFuncOpLowering : ConvertToLLVMPattern {
     // not specific to function modeling.
     SmallVector<NamedAttribute, 4> 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);
     }
index 7636f20..14f6474 100644 (file)
@@ -329,8 +329,8 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, SPIRVTypeConverter &typeConverter,
       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);
   }
index ea4f996..2f3fdd0 100644 (file)
@@ -797,9 +797,8 @@ static void filterFuncAttributes(ArrayRef<NamedAttribute> attrs,
                                  bool filterArgAttrs,
                                  SmallVectorImpl<NamedAttribute> &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);
index e2434e3..69d2c35 100644 (file)
@@ -44,7 +44,7 @@ GPUDialect::GPUDialect(MLIRContext *context)
 LogicalResult GPUDialect::verifyOperationAttribute(Operation *op,
                                                    NamedAttribute attr) {
   if (!attr.second.isa<UnitAttr>() ||
-      !attr.first.is(getContainerModuleAttrName()))
+      attr.first != getContainerModuleAttrName())
     return success();
 
   auto module = dyn_cast<ModuleOp>(op);
index cfd16c3..0f83412 100644 (file)
@@ -468,8 +468,8 @@ FuncOpConversion::matchAndRewrite(FuncOp funcOp, ArrayRef<Value> operands,
 
   // 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);
   }
 
index b25a99c..b951f5a 100644 (file)
@@ -827,7 +827,7 @@ LogicalResult Serializer::processVariableOp(spirv::VariableOp op) {
                         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))) {
@@ -895,7 +895,7 @@ Serializer::processGlobalVariableOp(spirv::GlobalVariableOp varOp) {
   // 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))) {
index 6829e8a..daa5f9c 100644 (file)
@@ -161,7 +161,7 @@ Attribute DictionaryAttr::get(StringRef name) const {
     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())
index 9b689dc..3b69a0a 100644 (file)
@@ -43,7 +43,7 @@ SmallVector<Type, 10> mlir::getFlattenedTypes(TupleType t) {
 bool mlir::isOpaqueTypeWithName(Type type, StringRef dialect,
                                 StringRef typeData) {
   if (auto opaque = type.dyn_cast<mlir::OpaqueType>())
-    return opaque.getDialectNamespace().is(dialect) &&
+    return opaque.getDialectNamespace() == dialect &&
            opaque.getTypeData() == typeData;
   return false;
 }
index 21941f0..fa99d47 100644 (file)
@@ -408,7 +408,7 @@ static ParseResult parseStringAttrPrettyNameOp(OpAsmParser &parser,
   // 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
index 509b551..fa0d78e 100644 (file)
@@ -617,7 +617,7 @@ static void emitDecorationSerialization(const Operator &op, StringRef tabs,
     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