Skip to content

Commit ec93c75

Browse files
committed
Drop some uses of StringLiteral in favor of StringRef
StringRef can be used in constexpr contexts, so StringLiteral isn't necessary anymore.
1 parent 658495e commit ec93c75

File tree

2 files changed

+18
-35
lines changed

2 files changed

+18
-35
lines changed

mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,63 +24,47 @@
2424
namespace mlir {
2525
/// Attribute name for the AffineArrayAttr which encodes the relationship
2626
/// between a structured op iterators' and its operands.
27-
static constexpr StringLiteral getIndexingMapsAttrName() {
28-
return StringLiteral("indexing_maps");
29-
}
27+
constexpr StringRef getIndexingMapsAttrName() { return "indexing_maps"; }
3028

3129
/// Attribute name for the StrArrayAttr which encodes the type of a structured
3230
/// op's iterators.
33-
static constexpr StringLiteral getIteratorTypesAttrName() {
34-
return StringLiteral("iterator_types");
35-
}
31+
constexpr StringRef getIteratorTypesAttrName() { return "iterator_types"; }
3632

3733
/// Attribute name for the IntegerAttr which encodes the number of input buffer
3834
/// arguments.
39-
static constexpr StringLiteral getArgsInAttrName() {
40-
return StringLiteral("args_in");
41-
}
35+
constexpr StringRef getArgsInAttrName() { return "args_in"; }
4236

4337
/// Attribute name for the IntegerAttr which encodes the number of input buffer
4438
/// arguments.
45-
static constexpr StringLiteral getArgsOutAttrName() {
46-
return StringLiteral("args_out");
47-
}
39+
constexpr StringRef getArgsOutAttrName() { return "args_out"; }
4840

4941
/// Attribute name for the StringAttr which encodes an optional documentation
5042
/// string of the structured op.
51-
static constexpr StringLiteral getDocAttrName() { return StringLiteral("doc"); }
43+
constexpr StringRef getDocAttrName() { return "doc"; }
5244

5345
/// Attribute name for the StrArrayAttr which encodes the SymbolAttr for the
5446
/// MLIR function that implements the body of the structured op.
55-
static constexpr StringLiteral getFunAttrName() { return StringLiteral("fun"); }
47+
constexpr StringRef getFunAttrName() { return "fun"; }
5648

5749
/// Attribute name for the StrArrayAttr which encodes the external library
5850
/// function that implements the structured op.
59-
static constexpr StringLiteral getLibraryCallAttrName() {
60-
return StringLiteral("library_call");
61-
}
51+
constexpr StringRef getLibraryCallAttrName() { return "library_call"; }
6252

6353
/// Use to encode that a particular iterator type has parallel semantics.
64-
inline static constexpr StringLiteral getParallelIteratorTypeName() {
65-
return StringLiteral("parallel");
66-
}
54+
constexpr StringRef getParallelIteratorTypeName() { return "parallel"; }
6755

6856
/// Use to encode that a particular iterator type has reduction semantics.
69-
inline static constexpr StringLiteral getReductionIteratorTypeName() {
70-
return StringLiteral("reduction");
71-
}
57+
constexpr StringRef getReductionIteratorTypeName() { return "reduction"; }
7258

7359
/// Use to encode that a particular iterator type has window semantics.
74-
inline static constexpr StringLiteral getWindowIteratorTypeName() {
75-
return StringLiteral("window");
76-
}
60+
constexpr StringRef getWindowIteratorTypeName() { return "window"; }
7761

7862
/// Use to encode that a particular iterator type has window semantics.
79-
inline static ArrayRef<StringRef> getAllIteratorTypeNames() {
80-
static StringRef names[3] = {getParallelIteratorTypeName(),
81-
getReductionIteratorTypeName(),
82-
getWindowIteratorTypeName()};
83-
return llvm::makeArrayRef(names);
63+
inline ArrayRef<StringRef> getAllIteratorTypeNames() {
64+
static constexpr StringRef names[3] = {getParallelIteratorTypeName(),
65+
getReductionIteratorTypeName(),
66+
getWindowIteratorTypeName()};
67+
return names;
8468
}
8569

8670
/// Returns the iterator of a certain type.

mlir/lib/Dialect/VectorOps/VectorOps.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,9 @@ static LogicalResult verify(ContractionOp op) {
278278
}
279279

280280
ArrayRef<StringRef> ContractionOp::getTraitAttrNames() {
281-
static constexpr StringLiteral names[2] = {getIndexingMapsAttrName(),
282-
getIteratorTypesAttrName()};
283-
ArrayRef<StringLiteral> res{names};
284-
return ArrayRef<StringRef>{res.begin(), res.end()};
281+
static constexpr StringRef names[2] = {getIndexingMapsAttrName(),
282+
getIteratorTypesAttrName()};
283+
return names;
285284
}
286285

287286
static int64_t getResultIndex(AffineMap map, AffineExpr targetExpr) {

0 commit comments

Comments
 (0)