Skip to content

Commit 90908ec

Browse files
committed
[NFC][TableGen] Minor code cleanup in CodeGenRegister
- Use range for loops.
1 parent 349dc34 commit 90908ec

File tree

3 files changed

+117
-127
lines changed

3 files changed

+117
-127
lines changed

llvm/include/llvm/TableGen/Record.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -632,10 +632,11 @@ class BitsInit final : public TypedInit,
632632

633633
const Init *resolveReferences(Resolver &R) const override;
634634

635-
const Init *getBit(unsigned Bit) const override {
636-
assert(Bit < NumBits && "Bit index out of range!");
637-
return getTrailingObjects<const Init *>()[Bit];
635+
ArrayRef<const Init *> getBits() const {
636+
return ArrayRef(getTrailingObjects<const Init *>(), NumBits);
638637
}
638+
639+
const Init *getBit(unsigned Bit) const override { return getBits()[Bit]; }
639640
};
640641

641642
/// '7' - Represent an initialization by a literal integer value.
@@ -781,10 +782,15 @@ class ListInit final : public TypedInit,
781782

782783
void Profile(FoldingSetNodeID &ID) const;
783784

785+
ArrayRef<const Init *> getValues() const {
786+
return ArrayRef(getTrailingObjects<const Init *>(), NumValues);
787+
}
788+
784789
const Init *getElement(unsigned i) const {
785790
assert(i < NumValues && "List element index out of range!");
786-
return getTrailingObjects<const Init *>()[i];
791+
return getValues()[i];
787792
}
793+
788794
const RecTy *getElementType() const {
789795
return cast<ListRecTy>(getType())->getElementType();
790796
}
@@ -804,12 +810,8 @@ class ListInit final : public TypedInit,
804810
bool isConcrete() const override;
805811
std::string getAsString() const override;
806812

807-
ArrayRef<const Init *> getValues() const {
808-
return ArrayRef(getTrailingObjects<const Init *>(), NumValues);
809-
}
810-
811-
const_iterator begin() const { return getTrailingObjects<const Init *>(); }
812-
const_iterator end () const { return begin() + NumValues; }
813+
const_iterator begin() const { return getValues().begin(); }
814+
const_iterator end() const { return getValues().end(); }
813815

814816
size_t size () const { return NumValues; }
815817
bool empty() const { return NumValues == 0; }

0 commit comments

Comments
 (0)