summaryrefslogtreecommitdiff
path: root/utils/TableGen/Record.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-03 18:17:22 +0000
committerChris Lattner <sabre@nondot.org>2003-08-03 18:17:22 +0000
commit7cf0ce4b8d122575c3348b5fa4947014c3d8432d (patch)
tree355516465b3ec4fc2da2d6320da98bccffe09559 /utils/TableGen/Record.cpp
parentbc1f0dc7ebf9b60e26459ab44b543755560041f5 (diff)
downloadllvm-7cf0ce4b8d122575c3348b5fa4947014c3d8432d.tar.gz
llvm-7cf0ce4b8d122575c3348b5fa4947014c3d8432d.tar.bz2
llvm-7cf0ce4b8d122575c3348b5fa4947014c3d8432d.tar.xz
Changes to allow lists of any type
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7519 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/Record.cpp')
-rw-r--r--utils/TableGen/Record.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index 309f386e78..ef7d9a044a 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -16,6 +16,10 @@ Init *BitRecTy::convertValue(BitsInit *BI) {
return BI->getBit(0);
}
+bool BitRecTy::baseClassOf(const BitsRecTy *RHS) const {
+ return RHS->getNumBits() == 1;
+}
+
Init *BitRecTy::convertValue(IntInit *II) {
int Val = II->getValue();
if (Val != 0 && Val != 1) return 0; // Only accept 0 or 1 for a bit!
@@ -104,22 +108,27 @@ Init *StringRecTy::convertValue(TypedInit *TI) {
}
void ListRecTy::print(std::ostream &OS) const {
- OS << "list<" << Class->getName() << ">";
+ OS << "list<" << *Ty << ">";
}
Init *ListRecTy::convertValue(ListInit *LI) {
+ std::vector<Init*> Elements;
+
// Verify that all of the elements of the list are subclasses of the
- // appopriate class!
+ // appropriate class!
for (unsigned i = 0, e = LI->getSize(); i != e; ++i)
- if (!LI->getElement(i)->isSubClassOf(Class))
+ if (Init *CI = LI->getElement(i)->convertInitializerTo(Ty))
+ Elements.push_back(CI);
+ else
return 0;
- return LI;
+
+ return new ListInit(Elements);
}
Init *ListRecTy::convertValue(TypedInit *TI) {
// Ensure that TI is compatible with our class.
if (ListRecTy *LRT = dynamic_cast<ListRecTy*>(TI->getType()))
- if (LRT->getElementClass() == getElementClass())
+ if (LRT->getElementType()->typeIsConvertibleTo(getElementType()))
return TI;
return 0;
}
@@ -144,6 +153,11 @@ Init *RecordRecTy::convertValue(TypedInit *TI) {
return 0;
}
+bool RecordRecTy::baseClassOf(const RecordRecTy *RHS) const {
+ return Rec == RHS->getRecord() || RHS->getRecord()->isSubClassOf(Rec);
+}
+
+
//===----------------------------------------------------------------------===//
// Initializer implementations
//===----------------------------------------------------------------------===//
@@ -263,9 +277,9 @@ Init *IntInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) {
void ListInit::print(std::ostream &OS) const {
OS << "[";
- for (unsigned i = 0, e = Records.size(); i != e; ++i) {
+ for (unsigned i = 0, e = Values.size(); i != e; ++i) {
if (i) OS << ", ";
- OS << Records[i]->getName();
+ OS << *Values[i];
}
OS << "]";
}