From: Chris Lattner Date: Mon, 28 Jul 2003 03:39:57 +0000 (+0000) Subject: Allow initializing variable initializers with variables X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ce3d64025b32d10dbaf9c77f5b1b56a09bc88f82;p=oota-llvm.git Allow initializing variable initializers with variables git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7354 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/support/tools/TableGen/Record.cpp b/support/tools/TableGen/Record.cpp index 469faa9b01b..2aabef408dd 100644 --- a/support/tools/TableGen/Record.cpp +++ b/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/support/tools/TableGen/Record.h b/support/tools/TableGen/Record.h index 73b5c741022..72123cb5205 100644 --- a/support/tools/TableGen/Record.h +++ b/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; }; diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 469faa9b01b..2aabef408dd 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(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 73b5c741022..72123cb5205 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; };