Skip to content

Commit fe374a8

Browse files
authored
[NFC][MLIR][TableGen] Use ArrayRef instead of const vector reference (#162016)
1 parent c6bfbc5 commit fe374a8

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ getAllCppAttrConstraints(const RecordKeeper &records) {
11661166

11671167
/// Emit the declarations for the given constraints, of the form:
11681168
/// `bool <constraintCppFunctionName>(<parameterTypeName> <parameterName>);`
1169-
static void emitConstraintDecls(const std::vector<Constraint> &constraints,
1169+
static void emitConstraintDecls(ArrayRef<Constraint> constraints,
11701170
raw_ostream &os, StringRef parameterTypeName,
11711171
StringRef parameterName) {
11721172
static const char *const constraintDecl = "bool {0}({1} {2});\n";
@@ -1192,7 +1192,7 @@ static void emitAttrConstraintDecls(const RecordKeeper &records,
11921192
/// return (<condition>); }`
11931193
/// where `<condition>` is the condition template with the `self` variable
11941194
/// replaced with the `selfName` parameter.
1195-
static void emitConstraintDefs(const std::vector<Constraint> &constraints,
1195+
static void emitConstraintDefs(ArrayRef<Constraint> constraints,
11961196
raw_ostream &os, StringRef parameterTypeName,
11971197
StringRef selfName) {
11981198
static const char *const constraintDef = R"(

mlir/tools/mlir-tblgen/EnumsGen.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,21 @@ static std::string makeIdentifier(StringRef str) {
4646

4747
static void emitEnumClass(const Record &enumDef, StringRef enumName,
4848
StringRef underlyingType, StringRef description,
49-
const std::vector<EnumCase> &enumerants,
50-
raw_ostream &os) {
49+
ArrayRef<EnumCase> enumerants, raw_ostream &os) {
5150
os << "// " << description << "\n";
5251
os << "enum class " << enumName;
5352

5453
if (!underlyingType.empty())
5554
os << " : " << underlyingType;
5655
os << " {\n";
5756

58-
for (const auto &enumerant : enumerants) {
57+
for (const EnumCase &enumerant : enumerants) {
5958
auto symbol = makeIdentifier(enumerant.getSymbol());
6059
auto value = enumerant.getValue();
61-
if (value >= 0) {
60+
if (value >= 0)
6261
os << formatv(" {0} = {1},\n", symbol, value);
63-
} else {
62+
else
6463
os << formatv(" {0},\n", symbol);
65-
}
6664
}
6765
os << "};\n\n";
6866
}

mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4801,11 +4801,9 @@ void OpOperandAdaptorEmitter::emitDef(
48014801
}
48024802

48034803
/// Emit the class declarations or definitions for the given op defs.
4804-
static void
4805-
emitOpClasses(const RecordKeeper &records,
4806-
const std::vector<const Record *> &defs, raw_ostream &os,
4807-
const StaticVerifierFunctionEmitter &staticVerifierEmitter,
4808-
bool emitDecl) {
4804+
static void emitOpClasses(
4805+
const RecordKeeper &records, ArrayRef<const Record *> defs, raw_ostream &os,
4806+
const StaticVerifierFunctionEmitter &staticVerifierEmitter, bool emitDecl) {
48094807
if (defs.empty())
48104808
return;
48114809

@@ -4840,11 +4838,10 @@ emitOpClasses(const RecordKeeper &records,
48404838

48414839
/// Emit the declarations for the provided op classes.
48424840
static void emitOpClassDecls(const RecordKeeper &records,
4843-
const std::vector<const Record *> &defs,
4844-
raw_ostream &os) {
4841+
ArrayRef<const Record *> defs, raw_ostream &os) {
48454842
// First emit forward declaration for each class, this allows them to refer
48464843
// to each others in traits for example.
4847-
for (auto *def : defs) {
4844+
for (const Record *def : defs) {
48484845
Operator op(*def);
48494846
NamespaceEmitter emitter(os, op.getCppNamespace());
48504847
std::string comments = tblgen::emitSummaryAndDescComments(

mlir/tools/mlir-tblgen/TosaUtilsGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- TosaUtilsGen.cpp - Tosa utility generator -===//
1+
//===----------------------------------------------------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

0 commit comments

Comments
 (0)