diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-01-13 00:10:02 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-01-13 00:10:02 +0000 |
commit | d8d0540d9be2699ec52417afb1b54a694c15cba7 (patch) | |
tree | ba45e86351679e0ed77940d10db28f78dfa61c52 /llvm/lib/Bytecode/Writer/Writer.cpp | |
parent | bea2e4cf23c394ac2465e7ef12e5734100bd3229 (diff) | |
download | bcm5719-llvm-d8d0540d9be2699ec52417afb1b54a694c15cba7.tar.gz bcm5719-llvm-d8d0540d9be2699ec52417afb1b54a694c15cba7.zip |
Make sure that GEP indices are only 32 or 64 bits. We're not ready for
indices with other bit sizes yet.
llvm-svn: 33167
Diffstat (limited to 'llvm/lib/Bytecode/Writer/Writer.cpp')
-rw-r--r-- | llvm/lib/Bytecode/Writer/Writer.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Bytecode/Writer/Writer.cpp b/llvm/lib/Bytecode/Writer/Writer.cpp index b7987b2e944..dab25cad991 100644 --- a/llvm/lib/Bytecode/Writer/Writer.cpp +++ b/llvm/lib/Bytecode/Writer/Writer.cpp @@ -486,9 +486,11 @@ void BytecodeWriter::outputInstructionFormat0(const Instruction *I, // These should be either 32-bits or 64-bits, however, with bit // accurate types we just distinguish between less than or equal to // 32-bits or greater than 32-bits. - const IntegerType *IdxTy = - cast<IntegerType>(I->getOperand(Idx)->getType()); - unsigned IdxId = IdxTy->getBitWidth() <= 32 ? 0 : 1; + unsigned BitWidth = + cast<IntegerType>(I->getOperand(Idx)->getType())->getBitWidth(); + assert(BitWidth == 32 || BitWidth == 64 && + "Invalid bitwidth for GEP index"); + unsigned IdxId = BitWidth == 32 ? 0 : 1; Slot = (Slot << 1) | IdxId; } output_vbr(unsigned(Slot)); @@ -737,9 +739,11 @@ void BytecodeWriter::outputInstruction(const Instruction &I) { // These should be either 32-bits or 64-bits, however, with bit // accurate types we just distinguish between less than or equal to // 32-bits or greater than 32-bits. - const IntegerType *IdxTy = - cast<IntegerType>(GEP->getOperand(Idx)->getType()); - unsigned IdxId = IdxTy->getBitWidth() <= 32 ? 0 : 1; + unsigned BitWidth = + cast<IntegerType>(GEP->getOperand(Idx)->getType())->getBitWidth(); + assert(BitWidth == 32 || BitWidth == 64 && + "Invalid bitwidth for GEP index"); + unsigned IdxId = BitWidth == 32 ? 0 : 1; Slots[Idx] = (Slots[Idx] << 1) | IdxId; if (Slots[Idx] > MaxOpSlot) MaxOpSlot = Slots[Idx]; } |