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
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/
Chris Lattner wrote:> > 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. :)I actually meant making getRawValue into a virtual function, so the size of ConstantBool won't change, but speed might change. I'm not at all sure that the virtual call overhead will be noticable, but if you prefer to move both getRawValue and Val into ConstantIntergal, that's fine with me, too -- I can make a change either way. - Volodya