1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

implementing shifting of literal integers

llvm-svn: 21336
This commit is contained in:
Chris Lattner 2005-04-19 01:17:35 +00:00
parent 414d27b765
commit 57b0bbfcbd
2 changed files with 16 additions and 0 deletions

View File

@ -297,6 +297,20 @@ Init *BitsInit::resolveReferences(Record &R) {
return this;
}
Init *IntInit::getBinaryOp(BinaryOp Op, Init *RHS) {
IntInit *RHSi = dynamic_cast<IntInit*>(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<unsigned> &Bits) {
BitsInit *BI = new BitsInit(Bits.size());

View File

@ -567,6 +567,8 @@ public:
}
virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
virtual Init *getBinaryOp(BinaryOp Op, Init *RHS);
virtual void print(std::ostream &OS) const { OS << Value; }
};