[Mlir-commits] [mlir] ec93c75 - Drop some uses of StringLiteral in favor of StringRef

Benjamin Kramer llvmlistbot at llvm.org
Sat Feb 8 06:52:03 PST 2020


Author: Benjamin Kramer
Date: 2020-02-08T15:51:33+01:00
New Revision: ec93c758ced7fa8ae1b5042039dd326ef1db45ef

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

LOG: Drop some uses of StringLiteral in favor of StringRef

StringRef can be used in constexpr contexts, so StringLiteral isn't
necessary anymore.

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h
    mlir/lib/Dialect/VectorOps/VectorOps.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h b/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h
index 8384d7754f2e..37cdb2c0a7b0 100644
--- a/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h
+++ b/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h
@@ -24,63 +24,47 @@
 namespace mlir {
 /// Attribute name for the AffineArrayAttr which encodes the relationship
 /// between a structured op iterators' and its operands.
-static constexpr StringLiteral getIndexingMapsAttrName() {
-  return StringLiteral("indexing_maps");
-}
+constexpr StringRef getIndexingMapsAttrName() { return "indexing_maps"; }
 
 /// Attribute name for the StrArrayAttr which encodes the type of a structured
 /// op's iterators.
-static constexpr StringLiteral getIteratorTypesAttrName() {
-  return StringLiteral("iterator_types");
-}
+constexpr StringRef getIteratorTypesAttrName() { return "iterator_types"; }
 
 /// Attribute name for the IntegerAttr which encodes the number of input buffer
 /// arguments.
-static constexpr StringLiteral getArgsInAttrName() {
-  return StringLiteral("args_in");
-}
+constexpr StringRef getArgsInAttrName() { return "args_in"; }
 
 /// Attribute name for the IntegerAttr which encodes the number of input buffer
 /// arguments.
-static constexpr StringLiteral getArgsOutAttrName() {
-  return StringLiteral("args_out");
-}
+constexpr StringRef getArgsOutAttrName() { return "args_out"; }
 
 /// Attribute name for the StringAttr which encodes an optional documentation
 /// string of the structured op.
-static constexpr StringLiteral getDocAttrName() { return StringLiteral("doc"); }
+constexpr StringRef getDocAttrName() { return "doc"; }
 
 /// Attribute name for the StrArrayAttr which encodes the SymbolAttr for the
 /// MLIR function that implements the body of the structured op.
-static constexpr StringLiteral getFunAttrName() { return StringLiteral("fun"); }
+constexpr StringRef getFunAttrName() { return "fun"; }
 
 /// Attribute name for the StrArrayAttr which encodes the external library
 /// function that implements the structured op.
-static constexpr StringLiteral getLibraryCallAttrName() {
-  return StringLiteral("library_call");
-}
+constexpr StringRef getLibraryCallAttrName() { return "library_call"; }
 
 /// Use to encode that a particular iterator type has parallel semantics.
-inline static constexpr StringLiteral getParallelIteratorTypeName() {
-  return StringLiteral("parallel");
-}
+constexpr StringRef getParallelIteratorTypeName() { return "parallel"; }
 
 /// Use to encode that a particular iterator type has reduction semantics.
-inline static constexpr StringLiteral getReductionIteratorTypeName() {
-  return StringLiteral("reduction");
-}
+constexpr StringRef getReductionIteratorTypeName() { return "reduction"; }
 
 /// Use to encode that a particular iterator type has window semantics.
-inline static constexpr StringLiteral getWindowIteratorTypeName() {
-  return StringLiteral("window");
-}
+constexpr StringRef getWindowIteratorTypeName() { return "window"; }
 
 /// Use to encode that a particular iterator type has window semantics.
-inline static ArrayRef<StringRef> getAllIteratorTypeNames() {
-  static StringRef names[3] = {getParallelIteratorTypeName(),
-                               getReductionIteratorTypeName(),
-                               getWindowIteratorTypeName()};
-  return llvm::makeArrayRef(names);
+inline ArrayRef<StringRef> getAllIteratorTypeNames() {
+  static constexpr StringRef names[3] = {getParallelIteratorTypeName(),
+                                         getReductionIteratorTypeName(),
+                                         getWindowIteratorTypeName()};
+  return names;
 }
 
 /// Returns the iterator of a certain type.

diff  --git a/mlir/lib/Dialect/VectorOps/VectorOps.cpp b/mlir/lib/Dialect/VectorOps/VectorOps.cpp
index 00fc373fc98d..cae22e4bfc4b 100644
--- a/mlir/lib/Dialect/VectorOps/VectorOps.cpp
+++ b/mlir/lib/Dialect/VectorOps/VectorOps.cpp
@@ -278,10 +278,9 @@ static LogicalResult verify(ContractionOp op) {
 }
 
 ArrayRef<StringRef> ContractionOp::getTraitAttrNames() {
-  static constexpr StringLiteral names[2] = {getIndexingMapsAttrName(),
-                                             getIteratorTypesAttrName()};
-  ArrayRef<StringLiteral> res{names};
-  return ArrayRef<StringRef>{res.begin(), res.end()};
+  static constexpr StringRef names[2] = {getIndexingMapsAttrName(),
+                                         getIteratorTypesAttrName()};
+  return names;
 }
 
 static int64_t getResultIndex(AffineMap map, AffineExpr targetExpr) {


        


More information about the Mlir-commits mailing list