diff --git a/llvm/utils/TableGen/Record.cpp b/llvm/utils/TableGen/Record.cpp index 8c8e7b97f7bf..d2422ff74b30 100644 --- a/llvm/utils/TableGen/Record.cpp +++ b/llvm/utils/TableGen/Record.cpp @@ -297,6 +297,20 @@ Init *BitsInit::resolveReferences(Record &R) { return this; } +Init *IntInit::getBinaryOp(BinaryOp Op, Init *RHS) { + IntInit *RHSi = dynamic_cast(RHS); + if (RHSi == 0) return 0; + + int NewValue; + switch (Op) { + case SHL: NewValue = Value << RHSi->getValue(); break; + case SRA: NewValue = Value >> RHSi->getValue(); break; + case SRL: NewValue = (unsigned)Value >> (unsigned)RHSi->getValue(); break; + } + return new IntInit(NewValue); +} + + Init *IntInit::convertInitializerBitRange(const std::vector &Bits) { BitsInit *BI = new BitsInit(Bits.size()); diff --git a/llvm/utils/TableGen/Record.h b/llvm/utils/TableGen/Record.h index 9c5166c0cc83..82db72094b3f 100644 --- a/llvm/utils/TableGen/Record.h +++ b/llvm/utils/TableGen/Record.h @@ -567,6 +567,8 @@ public: } virtual Init *convertInitializerBitRange(const std::vector &Bits); + virtual Init *getBinaryOp(BinaryOp Op, Init *RHS); + virtual void print(std::ostream &OS) const { OS << Value; } };