Skip to content

Commit 6dfce04

Browse files
committed
[NFC][TableGen] Use ArrayRef instead of const vector reference
1 parent 9a6a87d commit 6dfce04

File tree

7 files changed

+20
-19
lines changed

7 files changed

+20
-19
lines changed

llvm/include/llvm/CodeGen/SelectionDAGISel.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,9 @@ class SelectionDAGISel {
435435
/// It runs node predicate number PredNo and returns true if it succeeds or
436436
/// false if it fails. The number is a private implementation detail to the
437437
/// code tblgen produces.
438-
virtual bool CheckNodePredicateWithOperands(
439-
SDValue Op, unsigned PredNo,
440-
const SmallVectorImpl<SDValue> &Operands) const {
438+
virtual bool
439+
CheckNodePredicateWithOperands(SDValue Op, unsigned PredNo,
440+
ArrayRef<SDValue> Operands) const {
441441
llvm_unreachable("Tblgen should generate the implementation of this!");
442442
}
443443

llvm/lib/TableGen/StringMatcher.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "llvm/TableGen/StringMatcher.h"
14-
#include "llvm/ADT/StringRef.h"
14+
#include "llvm/ADT/STLExtras.h"
1515
#include "llvm/Support/ErrorHandling.h"
1616
#include "llvm/Support/raw_ostream.h"
1717
#include <cassert>
@@ -23,14 +23,15 @@
2323
using namespace llvm;
2424

2525
/// FindFirstNonCommonLetter - Find the first character in the keys of the
26-
/// string pairs that is not shared across the whole set of strings. All
26+
/// string pairs that is not shared across the whole set of strings. All
2727
/// strings are assumed to have the same length.
2828
static unsigned
2929
FindFirstNonCommonLetter(ArrayRef<const StringMatcher::StringPair *> Matches) {
3030
assert(!Matches.empty());
3131
for (auto [Idx, Letter] : enumerate(Matches[0]->first)) {
32-
// Check to see if `Letter` is the same across the set.
33-
for (const StringMatcher::StringPair *Match : Matches)
32+
// Check to see if `Letter` is the same across the set. Since the letter is
33+
// from `Matches[0]`, we can skip `Matches[0]` in the loop below.
34+
for (const StringMatcher::StringPair *Match : Matches.drop_front())
3435
if (Match->first[Idx] != Letter)
3536
return Idx;
3637
}

llvm/lib/TableGen/StringToOffsetTable.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ void StringToOffsetTable::EmitStringTableDef(raw_ostream &OS, const Twine &Name,
4444
bool UseChars = !EmitLongStrLiterals && AggregateString.size() > (64 * 1024);
4545
OS << (UseChars ? "{\n" : "\n");
4646

47-
llvm::ListSeparator LineSep(UseChars ? ",\n" : "\n");
48-
llvm::SmallVector<StringRef> Strings(split(AggregateString, '\0'));
47+
ListSeparator LineSep(UseChars ? ",\n" : "\n");
48+
SmallVector<StringRef> Strings(split(AggregateString, '\0'));
4949
// We should always have an empty string at the start, and because these are
5050
// null terminators rather than separators, we'll have one at the end as
5151
// well. Skip the end one.
@@ -63,7 +63,7 @@ void StringToOffsetTable::EmitStringTableDef(raw_ostream &OS, const Twine &Name,
6363
continue;
6464
}
6565

66-
llvm::ListSeparator CharSep(", ");
66+
ListSeparator CharSep(", ");
6767
for (char C : Str) {
6868
OS << CharSep << "'";
6969
OS.write_escaped(StringRef(&C, 1));

llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3187,7 +3187,7 @@ bool TreePattern::InferAllTypes(
31873187
return true;
31883188
}
31893189

3190-
const SmallVectorImpl<TreePatternNode *> &InNodes = InIter->second;
3190+
ArrayRef<TreePatternNode *> InNodes = InIter->second;
31913191

31923192
// The input types should be fully resolved by now.
31933193
for (TreePatternNode *Node : Nodes) {

llvm/utils/TableGen/Common/CodeGenSchedule.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,8 +1292,8 @@ class PredTransitions {
12921292

12931293
PredTransitions(CodeGenSchedModels &sm) : SchedModels(sm) {}
12941294

1295-
bool substituteVariantOperand(const SmallVectorImpl<unsigned> &RWSeq,
1296-
bool IsRead, unsigned StartIdx);
1295+
bool substituteVariantOperand(ArrayRef<unsigned> RWSeq, bool IsRead,
1296+
unsigned StartIdx);
12971297

12981298
bool substituteVariants(const PredTransition &Trans);
12991299

@@ -1526,8 +1526,8 @@ void PredTransitions::pushVariant(const TransVariant &VInfo, bool IsRead) {
15261526
// operand. StartIdx is an index into TransVec where partial results
15271527
// starts. RWSeq must be applied to all transitions between StartIdx and the end
15281528
// of TransVec.
1529-
bool PredTransitions::substituteVariantOperand(
1530-
const SmallVectorImpl<unsigned> &RWSeq, bool IsRead, unsigned StartIdx) {
1529+
bool PredTransitions::substituteVariantOperand(ArrayRef<unsigned> RWSeq,
1530+
bool IsRead, unsigned StartIdx) {
15311531
bool Subst = false;
15321532
// Visit each original RW within the current sequence.
15331533
for (unsigned int RWI : RWSeq) {
@@ -1591,7 +1591,7 @@ bool PredTransitions::substituteVariants(const PredTransition &Trans) {
15911591
}
15921592

15931593
static void addSequences(CodeGenSchedModels &SchedModels,
1594-
const SmallVectorImpl<SmallVector<unsigned, 4>> &Seqs,
1594+
ArrayRef<SmallVector<unsigned, 4>> Seqs,
15951595
IdxVec &Result, bool IsRead) {
15961596
for (const auto &S : Seqs)
15971597
if (!S.empty())

llvm/utils/TableGen/DAGISelMatcherEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ void MatcherTableEmitter::EmitPredicateFunctions(raw_ostream &OS) {
11581158
EmitNodePredicatesFunction(
11591159
NodePredicatesWithOperands,
11601160
"CheckNodePredicateWithOperands(SDValue Op, unsigned PredNo, "
1161-
"const SmallVectorImpl<SDValue> &Operands) const",
1161+
"ArrayRef<SDValue> Operands) const",
11621162
OS);
11631163

11641164
// Emit CompletePattern matchers.

llvm/utils/TableGen/DAGISelMatcherOpt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ static void ContractNodes(std::unique_ptr<Matcher> &InputMatcherPtr,
282282
#endif
283283

284284
if (ResultsMatch) {
285-
const SmallVectorImpl<MVT::SimpleValueType> &VTs = EN->getVTList();
286-
const SmallVectorImpl<unsigned> &Operands = EN->getOperandList();
285+
ArrayRef<MVT::SimpleValueType> VTs = EN->getVTList();
286+
ArrayRef<unsigned> Operands = EN->getOperandList();
287287
MatcherPtr->reset(new MorphNodeToMatcher(
288288
EN->getInstruction(), VTs, Operands, EN->hasChain(),
289289
EN->hasInGlue(), EN->hasOutGlue(), EN->hasMemRefs(),

0 commit comments

Comments
 (0)