summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-07-28 03:39:57 +0000
committerChris Lattner <sabre@nondot.org>2003-07-28 03:39:57 +0000
commitce3d64025b32d10dbaf9c77f5b1b56a09bc88f82 (patch)
tree6022f3bca78b4a49cec915904da83585c5911be0 /utils
parent699104633afb16c22ce3cd8fe1dc8054aacdc613 (diff)
downloadllvm-ce3d64025b32d10dbaf9c77f5b1b56a09bc88f82.tar.gz
llvm-ce3d64025b32d10dbaf9c77f5b1b56a09bc88f82.tar.bz2
llvm-ce3d64025b32d10dbaf9c77f5b1b56a09bc88f82.tar.xz
Allow initializing variable initializers with variables
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7354 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/Record.cpp9
-rw-r--r--utils/TableGen/Record.h3
2 files changed, 11 insertions, 1 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index 469faa9b01..2aabef408d 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -127,6 +127,15 @@ Init *RecordRecTy::convertValue(DefInit *DI) {
return DI;
}
+Init *RecordRecTy::convertValue(TypedInit *VI) {
+ // Ensure that VI is compatible with Rec.
+ if (RecordRecTy *RRT = dynamic_cast<RecordRecTy*>(VI->getType()))
+ if (RRT->getRecord()->isSubClassOf(getRecord()) ||
+ RRT->getRecord() == getRecord())
+ return VI;
+ return 0;
+}
+
//===----------------------------------------------------------------------===//
// Initializer implementations
//===----------------------------------------------------------------------===//
diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h
index 73b5c74102..72123cb520 100644
--- a/utils/TableGen/Record.h
+++ b/utils/TableGen/Record.h
@@ -136,7 +136,8 @@ public:
Record *getRecord() const { return Rec; }
Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
- Init *convertValue( DefInit *DI);
+ Init *convertValue( DefInit *DI);
+ Init *convertValue(TypedInit *VI);
void print(std::ostream &OS) const;
};