[TableGen] Replace some calls to ListInit::getSize() with ListInit::empty() if it was just comparing to 0. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237340 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper
2015-05-14 05:53:53 +00:00
parent e6fb4ac3ed
commit bbf57b36bb
4 changed files with 7 additions and 7 deletions

View File

@@ -778,14 +778,14 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
} }
case HEAD: { case HEAD: {
if (ListInit *LHSl = dyn_cast<ListInit>(LHS)) { if (ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
assert(LHSl->getSize() != 0 && "Empty list in car"); assert(!LHSl->empty() && "Empty list in car");
return LHSl->getElement(0); return LHSl->getElement(0);
} }
break; break;
} }
case TAIL: { case TAIL: {
if (ListInit *LHSl = dyn_cast<ListInit>(LHS)) { if (ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
assert(LHSl->getSize() != 0 && "Empty list in cdr"); assert(!LHSl->empty() && "Empty list in cdr");
// Note the +1. We can't just pass the result of getValues() // Note the +1. We can't just pass the result of getValues()
// directly. // directly.
return ListInit::get(LHSl->getValues().slice(1), LHSl->getType()); return ListInit::get(LHSl->getValues().slice(1), LHSl->getType());
@@ -794,7 +794,7 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
} }
case EMPTY: { case EMPTY: {
if (ListInit *LHSl = dyn_cast<ListInit>(LHS)) { if (ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
if (LHSl->getSize() == 0) if (LHSl->empty())
return IntInit::get(1); return IntInit::get(1);
return IntInit::get(0); return IntInit::get(0);
} }

View File

@@ -841,7 +841,7 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) {
return nullptr; return nullptr;
} }
if (LHSl && LHSl->getSize() == 0) { if (LHSl && LHSl->empty()) {
TokError("empty list argument in unary operator"); TokError("empty list argument in unary operator");
return nullptr; return nullptr;
} }

View File

@@ -3076,7 +3076,7 @@ void CodeGenDAGPatterns::ParseInstructions() {
// null_frag operator is as-if no pattern were specified. Normally this // null_frag operator is as-if no pattern were specified. Normally this
// is from a multiclass expansion w/ a SDPatternOperator passed in as // is from a multiclass expansion w/ a SDPatternOperator passed in as
// null_frag. // null_frag.
if (!LI || LI->getSize() == 0 || hasNullFragReference(LI)) { if (!LI || LI->empty() || hasNullFragReference(LI)) {
std::vector<Record*> Results; std::vector<Record*> Results;
std::vector<Record*> Operands; std::vector<Record*> Operands;
@@ -3399,7 +3399,7 @@ void CodeGenDAGPatterns::ParsePatterns() {
Pattern->InlinePatternFragments(); Pattern->InlinePatternFragments();
ListInit *LI = CurPattern->getValueAsListInit("ResultInstrs"); ListInit *LI = CurPattern->getValueAsListInit("ResultInstrs");
if (LI->getSize() == 0) continue; // no pattern. if (LI->empty()) continue; // no pattern.
// Parse the instruction. // Parse the instruction.
TreePattern Result(CurPattern, LI, false, *this); TreePattern Result(CurPattern, LI, false, *this);

View File

@@ -128,7 +128,7 @@ public:
ListInit *ColValList = MapRec->getValueAsListInit("ValueCols"); ListInit *ColValList = MapRec->getValueAsListInit("ValueCols");
// Each instruction map must specify at least one column for it to be valid. // Each instruction map must specify at least one column for it to be valid.
if (ColValList->getSize() == 0) if (ColValList->empty())
PrintFatalError(MapRec->getLoc(), "InstrMapping record `" + PrintFatalError(MapRec->getLoc(), "InstrMapping record `" +
MapRec->getName() + "' has empty " + "`ValueCols' field!"); MapRec->getName() + "' has empty " + "`ValueCols' field!");