[LLVMdev] ConstantInt::getRawValue

Vladimir Prus ghost at cs.msu.su
Thu Jun 17 02:17:01 PDT 2004


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.

- Volodya




More information about the llvm-dev mailing list