[llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp SlotCalculator.h Writer.cpp

Chris Lattner clattner at apple.com
Fri Jan 12 15:25:47 PST 2007


On Jan 11, 2007, at 11:06 PM, Reid Spencer wrote:
> @@ -484,12 +488,12 @@
>        assert(Slot >= 0 && "No slot number for value!?!?");
>
>        if (isa<SequentialType>(*TI)) {
> -        unsigned IdxId;
> -        switch (I->getOperand(Idx)->getType()->getTypeID()) {
> -        default: assert(0 && "Unknown index type!");
> -        case Type::Int32TyID:  IdxId = 0; break;
> -        case Type::Int64TyID:  IdxId = 1; break;
> -        }
> +        // 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;
>          Slot = (Slot << 1) | IdxId;
>        }
>        output_vbr(unsigned(Slot));
> @@ -735,12 +739,12 @@
>        for (gep_type_iterator I = gep_type_begin(GEP), E =  
> gep_type_end(GEP);
>             I != E; ++I, ++Idx)
>          if (isa<SequentialType>(*I)) {
> -          unsigned IdxId;
> -          switch (GEP->getOperand(Idx)->getType()->getTypeID()) {
> -          default: assert(0 && "Unknown index type!");
> -          case Type::Int32TyID: IdxId = 0; break;
> -          case Type::Int64TyID: IdxId = 1; break;
> -          }
> +          // 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;
>            Slots[Idx] = (Slots[Idx] << 1) | IdxId;
>            if (Slots[Idx] > MaxOpSlot) MaxOpSlot = Slots[Idx];
>          }

Sorry, actually both of these are wrong and need to be corrected.

-Chris




More information about the llvm-commits mailing list