From ec93c758ced7fa8ae1b5042039dd326ef1db45ef Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 8 Feb 2020 15:45:09 +0100 Subject: [PATCH] Drop some uses of StringLiteral in favor of StringRef StringRef can be used in constexpr contexts, so StringLiteral isn't necessary anymore. --- .../mlir/Dialect/Utils/StructuredOpsUtils.h | 46 +++++++--------------- mlir/lib/Dialect/VectorOps/VectorOps.cpp | 7 ++-- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h b/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h index 8384d77..37cdb2c 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 getAllIteratorTypeNames() { - static StringRef names[3] = {getParallelIteratorTypeName(), - getReductionIteratorTypeName(), - getWindowIteratorTypeName()}; - return llvm::makeArrayRef(names); +inline ArrayRef 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 00fc373..cae22e4 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 ContractionOp::getTraitAttrNames() { - static constexpr StringLiteral names[2] = {getIndexingMapsAttrName(), - getIteratorTypesAttrName()}; - ArrayRef res{names}; - return ArrayRef{res.begin(), res.end()}; + static constexpr StringRef names[2] = {getIndexingMapsAttrName(), + getIteratorTypesAttrName()}; + return names; } static int64_t getResultIndex(AffineMap map, AffineExpr targetExpr) { -- 2.7.4