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; };