[Mlir-commits] [mlir] 63dc264 - Revert "[mlir][ODS] Use StringLiteral instead of StringRef when applicable"

Lei Zhang llvmlistbot at llvm.org
Thu Feb 4 10:59:53 PST 2021


Author: Lei Zhang
Date: 2021-02-04T13:59:37-05:00
New Revision: 63dc26450b34312b5fe63fe2dee2b85d5a47b4a6

URL: https://github.com/llvm/llvm-project/commit/63dc26450b34312b5fe63fe2dee2b85d5a47b4a6
DIFF: https://github.com/llvm/llvm-project/commit/63dc26450b34312b5fe63fe2dee2b85d5a47b4a6.diff

LOG: Revert "[mlir][ODS] Use StringLiteral instead of StringRef when applicable"

This reverts commit 953086ddbb593289fafcf0e7cc6e74847f1635af because
it breaks GCC 5 build:

  error: could not convert '(const char*)""' from 'const char*' to 'llvm::StringLiteral'
     static ::llvm::StringLiteral getDialectNamespace() { return ""; }

Added: 
    

Modified: 
    mlir/include/mlir/IR/OpBase.td
    mlir/test/mlir-tblgen/op-decl.td
    mlir/tools/mlir-tblgen/DialectGen.cpp
    mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
    mlir/tools/mlir-tblgen/PassGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td
index cd41902d7824..0bd1ee38bf1f 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -1177,7 +1177,7 @@ class EnumAttrInfo<string name, list<EnumAttrCaseInfo> cases> {
   // <return-type> <fn-name>(<qualified-enum-class-name>);
   // ```
   string symbolToStringFnName = "stringify" # name;
-  string symbolToStringFnRetType = "::llvm::StringLiteral";
+  string symbolToStringFnRetType = "::llvm::StringRef";
 
   // The name of the utility function that returns the max enum value used
   // within the enum class. It will have the following signature:

diff  --git a/mlir/test/mlir-tblgen/op-decl.td b/mlir/test/mlir-tblgen/op-decl.td
index 955bf00063df..91e46b59c2e6 100644
--- a/mlir/test/mlir-tblgen/op-decl.td
+++ b/mlir/test/mlir-tblgen/op-decl.td
@@ -67,7 +67,7 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> {
 // CHECK: public:
 // CHECK:   using Op::Op;
 // CHECK:   using Adaptor = AOpAdaptor;
-// CHECK:   static ::llvm::StringLiteral getOperationName();
+// CHECK:   static ::llvm::StringRef getOperationName();
 // CHECK:   ::mlir::Operation::operand_range getODSOperands(unsigned index);
 // CHECK:   ::mlir::Value a();
 // CHECK:   ::mlir::Operation::operand_range b();

diff  --git a/mlir/tools/mlir-tblgen/DialectGen.cpp b/mlir/tools/mlir-tblgen/DialectGen.cpp
index 1eb768ec5f27..43f3968ca9c8 100644
--- a/mlir/tools/mlir-tblgen/DialectGen.cpp
+++ b/mlir/tools/mlir-tblgen/DialectGen.cpp
@@ -75,7 +75,7 @@ class {0} : public ::mlir::Dialect {
   void initialize();
   friend class ::mlir::MLIRContext;
 public:
-  static ::llvm::StringLiteral getDialectNamespace() { return "{1}"; }
+  static ::llvm::StringRef getDialectNamespace() { return "{1}"; }
 )";
 
 /// Registration for a single dependent dialect: to be inserted in the ctor

diff  --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index d7d3d65403b2..2f0b3379d152 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -2180,7 +2180,7 @@ void OpEmitter::genTraits() {
 
 void OpEmitter::genOpNameGetter() {
   auto *method = opClass.addMethodAndPrune(
-      "::llvm::StringLiteral", "getOperationName", OpMethod::MP_Static);
+      "::llvm::StringRef", "getOperationName", OpMethod::MP_Static);
   method->body() << "  return \"" << op.getOperationName() << "\";\n";
 }
 

diff  --git a/mlir/tools/mlir-tblgen/PassGen.cpp b/mlir/tools/mlir-tblgen/PassGen.cpp
index 5ffedcc55082..c1664a0c826c 100644
--- a/mlir/tools/mlir-tblgen/PassGen.cpp
+++ b/mlir/tools/mlir-tblgen/PassGen.cpp
@@ -45,17 +45,13 @@ const char *const passDeclBegin = R"(
 template <typename DerivedT>
 class {0}Base : public {1} {
 public:
-  using Base = {0}Base;
-
   {0}Base() : {1}(::mlir::TypeID::get<DerivedT>()) {{}
   {0}Base(const {0}Base &) : {1}(::mlir::TypeID::get<DerivedT>()) {{}
 
   /// Returns the command-line argument attached to this pass.
-  static ::llvm::StringLiteral getArgumentName() { return "{2}"; }
   ::llvm::StringRef getArgument() const override { return "{2}"; }
 
   /// Returns the derived pass name.
-  static ::llvm::StringLiteral getPassName() { return "{0}"; }
   ::llvm::StringRef getName() const override { return "{0}"; }
 
   /// Support isa/dyn_cast functionality for the derived pass class.


        


More information about the Mlir-commits mailing list