From e87de41189b1591afd88e4dc12eeb17e06b77d3e Mon Sep 17 00:00:00 2001 From: Bruno Cardoso Lopes Date: Wed, 16 Jun 2010 23:24:12 +0000 Subject: let the '!eq' expression support 'int' and 'bit' types git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106171 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/Record.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'utils/TableGen/Record.cpp') diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 4f9f6045c1..d9c5dd30e1 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -721,9 +721,20 @@ Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { break; } case EQ: { - // Make sure we've resolved + // try to fold eq comparison for 'bit' and 'int', otherwise fallback + // to string objects. + IntInit* L = + dynamic_cast(LHS->convertInitializerTo(new IntRecTy())); + IntInit* R = + dynamic_cast(RHS->convertInitializerTo(new IntRecTy())); + + if (L && R) + return new IntInit(L->getValue() == R->getValue()); + StringInit *LHSs = dynamic_cast(LHS); StringInit *RHSs = dynamic_cast(RHS); + + // Make sure we've resolved if (LHSs && RHSs) return new IntInit(LHSs->getValue() == RHSs->getValue()); -- cgit v1.2.3-70-g09d2