[LLVMdev] ConstantInt::getRawValue

Chris Lattner sabre at nondot.org
Thu Jun 17 12:14:01 PDT 2004


On Thu, 17 Jun 2004, Vladimir Prus wrote:

> Is there are reason why ConstantInt::getRawValue method can't be moved one
> step into class hierarchy, into ConstantIntegral::getRawValue
>
> The reason I'd like this is that to handle both ConstantInt and ConstantBool,
> I need the following:
>
>   if (ConstantInt* CI = dyn_cast<ConstantInt>(V)) {
>      BuildMI(*MBB, IPt, NM::MOVE, 1, Reg).addImm(CI->getRawValue());
>    } if (ConstantBool* CB = dyn_cast<ConstantBool>(V)) {
>      BuildMI(*MBB, IPt, NM::MOVE, 1, Reg).addImm(CI->getalue());
>    } ...
>
> If  getRawValue is moved to ConstantIntegral, I'd simply write
>
>   if (ConstantIntegral* CI = dyn_cast<ConstantInt>(V)) {
>      BuildMI(*MBB, IPt, NM::MOVE, 1, Reg).addImm(CI->getRawValue());
>   } ...
>
> which is a bit nicer. Of course, if you think it's a good idea, I can send a
> patch.

Sure that sounds great.  It increases the size of the ConstantBool class,
but since there are only two instances of it ever created, I think we can
live with this. :)

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-dev mailing list