From 4f2a68b20880ced54532e8d8a6ac0010b88654cc Mon Sep 17 00:00:00 2001 From: David Greene Date: Fri, 3 Sep 2010 21:00:49 +0000 Subject: Generalize getFieldType to work on all TypedInits. Add a couple of testcases from Amaury Pouly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113010 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/Record.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'utils/TableGen/Record.cpp') diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index d2cf379..dc79358 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -628,23 +628,6 @@ std::string UnOpInit::getAsString() const { return Result + "(" + LHS->getAsString() + ")"; } -RecTy *UnOpInit::getFieldType(const std::string &FieldName) const { - switch (getOpcode()) { - default: assert(0 && "Unknown unop"); - case CAST: { - RecordRecTy *RecordType = dynamic_cast(getType()); - if (RecordType) { - RecordVal *Field = RecordType->getRecord()->getValue(FieldName); - if (Field) { - return Field->getType(); - } - } - break; - } - } - return 0; -} - Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { switch (getOpcode()) { default: assert(0 && "Unknown binop"); @@ -1046,6 +1029,17 @@ std::string TernOpInit::getAsString() const { + RHS->getAsString() + ")"; } +RecTy *TypedInit::getFieldType(const std::string &FieldName) const { + RecordRecTy *RecordType = dynamic_cast(getType()); + if (RecordType) { + RecordVal *Field = RecordType->getRecord()->getValue(FieldName); + if (Field) { + return Field->getType(); + } + } + return 0; +} + Init *TypedInit::convertInitializerBitRange(const std::vector &Bits) { BitsRecTy *T = dynamic_cast(getType()); if (T == 0) return 0; // Cannot subscript a non-bits variable... -- cgit v1.1