diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2010-06-16 23:24:12 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2010-06-16 23:24:12 +0000 |
commit | 77a4a56251c609b5fa7697762d000d41307f11fc (patch) | |
tree | d6204cce11e79af3f8f4e102faab750a506df5a7 /llvm/utils/TableGen/Record.cpp | |
parent | 13d0568ecc2b30a1922eb72a80be4486ecbabe26 (diff) | |
download | bcm5719-llvm-77a4a56251c609b5fa7697762d000d41307f11fc.tar.gz bcm5719-llvm-77a4a56251c609b5fa7697762d000d41307f11fc.zip |
let the '!eq' expression support 'int' and 'bit' types
llvm-svn: 106171
Diffstat (limited to 'llvm/utils/TableGen/Record.cpp')
-rw-r--r-- | llvm/utils/TableGen/Record.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/utils/TableGen/Record.cpp b/llvm/utils/TableGen/Record.cpp index 4f9f6045c14..d9c5dd30e18 100644 --- a/llvm/utils/TableGen/Record.cpp +++ b/llvm/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<IntInit*>(LHS->convertInitializerTo(new IntRecTy())); + IntInit* R = + dynamic_cast<IntInit*>(RHS->convertInitializerTo(new IntRecTy())); + + if (L && R) + return new IntInit(L->getValue() == R->getValue()); + StringInit *LHSs = dynamic_cast<StringInit*>(LHS); StringInit *RHSs = dynamic_cast<StringInit*>(RHS); + + // Make sure we've resolved if (LHSs && RHSs) return new IntInit(LHSs->getValue() == RHSs->getValue()); |