diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-04-19 01:17:35 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-04-19 01:17:35 +0000 |
| commit | 3ff0e11294318e2e8ef7169303f7cf1ee73b0bbd (patch) | |
| tree | ba20ed210dd8b9d7fa657a620ab4b25ec1d0b672 /llvm/utils | |
| parent | 101fc501d00b38277e2e259eb1ab2a0543cc3f6d (diff) | |
| download | bcm5719-llvm-3ff0e11294318e2e8ef7169303f7cf1ee73b0bbd.tar.gz bcm5719-llvm-3ff0e11294318e2e8ef7169303f7cf1ee73b0bbd.zip | |
implementing shifting of literal integers
llvm-svn: 21336
Diffstat (limited to 'llvm/utils')
| -rw-r--r-- | llvm/utils/TableGen/Record.cpp | 14 | ||||
| -rw-r--r-- | llvm/utils/TableGen/Record.h | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/llvm/utils/TableGen/Record.cpp b/llvm/utils/TableGen/Record.cpp index 8c8e7b97f7b..d2422ff74b3 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<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()); diff --git a/llvm/utils/TableGen/Record.h b/llvm/utils/TableGen/Record.h index 9c5166c0cc8..82db72094b3 100644 --- a/llvm/utils/TableGen/Record.h +++ b/llvm/utils/TableGen/Record.h @@ -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; } }; |

