From 2c76692496a96f2f6fb56496b442a3614fccaaaf Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 28 Jul 2003 03:39:57 +0000 Subject: [PATCH] Allow initializing variable initializers with variables llvm-svn: 7354 --- llvm/support/tools/TableGen/Record.cpp | 9 +++++++++ llvm/support/tools/TableGen/Record.h | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/llvm/support/tools/TableGen/Record.cpp b/llvm/support/tools/TableGen/Record.cpp index 469faa9b01bf..2aabef408ddd 100644 --- a/llvm/support/tools/TableGen/Record.cpp +++ b/llvm/support/tools/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(VI->getType())) + if (RRT->getRecord()->isSubClassOf(getRecord()) || + RRT->getRecord() == getRecord()) + return VI; + return 0; +} + //===----------------------------------------------------------------------===// // Initializer implementations //===----------------------------------------------------------------------===// diff --git a/llvm/support/tools/TableGen/Record.h b/llvm/support/tools/TableGen/Record.h index 73b5c7410226..72123cb52057 100644 --- a/llvm/support/tools/TableGen/Record.h +++ b/llvm/support/tools/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; };