mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
integer promotion checks for right shift, division, remainder
This commit is contained in:
parent
cf4a4e825e
commit
037745b823
1 changed files with 34 additions and 16 deletions
|
@ -1161,8 +1161,12 @@ Datatype *TypeOpIntRight::getInputCast(const PcodeOp *op,int4 slot,const CastStr
|
||||||
|
|
||||||
{
|
{
|
||||||
if (slot == 0) {
|
if (slot == 0) {
|
||||||
|
const Varnode *vn = op->getIn(0);
|
||||||
Datatype *reqtype = op->inputTypeLocal(slot);
|
Datatype *reqtype = op->inputTypeLocal(slot);
|
||||||
Datatype *curtype = op->getIn(slot)->getHigh()->getType();
|
Datatype *curtype = vn->getHigh()->getType();
|
||||||
|
int4 promoType = castStrategy->intPromotionType(vn);
|
||||||
|
if (promoType != CastStrategy::NO_PROMOTION && ((promoType & CastStrategy::UNSIGNED_EXTENSION)==0))
|
||||||
|
return reqtype;
|
||||||
return castStrategy->castStandard(reqtype,curtype,true,true);
|
return castStrategy->castStandard(reqtype,curtype,true,true);
|
||||||
}
|
}
|
||||||
return TypeOpBinary::getInputCast(op,slot,castStrategy);
|
return TypeOpBinary::getInputCast(op,slot,castStrategy);
|
||||||
|
@ -1199,8 +1203,12 @@ Datatype *TypeOpIntSright::getInputCast(const PcodeOp *op,int4 slot,const CastSt
|
||||||
|
|
||||||
{
|
{
|
||||||
if (slot == 0) {
|
if (slot == 0) {
|
||||||
|
const Varnode *vn = op->getIn(0);
|
||||||
Datatype *reqtype = op->inputTypeLocal(slot);
|
Datatype *reqtype = op->inputTypeLocal(slot);
|
||||||
Datatype *curtype = op->getIn(slot)->getHigh()->getType();
|
Datatype *curtype = vn->getHigh()->getType();
|
||||||
|
int4 promoType = castStrategy->intPromotionType(vn);
|
||||||
|
if (promoType != CastStrategy::NO_PROMOTION && ((promoType & CastStrategy::SIGNED_EXTENSION)==0))
|
||||||
|
return reqtype;
|
||||||
return castStrategy->castStandard(reqtype,curtype,true,true);
|
return castStrategy->castStandard(reqtype,curtype,true,true);
|
||||||
}
|
}
|
||||||
return TypeOpBinary::getInputCast(op,slot,castStrategy);
|
return TypeOpBinary::getInputCast(op,slot,castStrategy);
|
||||||
|
@ -1248,8 +1256,12 @@ TypeOpIntDiv::TypeOpIntDiv(TypeFactory *t)
|
||||||
Datatype *TypeOpIntDiv::getInputCast(const PcodeOp *op,int4 slot,const CastStrategy *castStrategy) const
|
Datatype *TypeOpIntDiv::getInputCast(const PcodeOp *op,int4 slot,const CastStrategy *castStrategy) const
|
||||||
|
|
||||||
{
|
{
|
||||||
|
const Varnode *vn = op->getIn(slot);
|
||||||
Datatype *reqtype = op->inputTypeLocal(slot);
|
Datatype *reqtype = op->inputTypeLocal(slot);
|
||||||
Datatype *curtype = op->getIn(slot)->getHigh()->getType();
|
Datatype *curtype = vn->getHigh()->getType();
|
||||||
|
int4 promoType = castStrategy->intPromotionType(vn);
|
||||||
|
if (promoType != CastStrategy::NO_PROMOTION && ((promoType & CastStrategy::UNSIGNED_EXTENSION)==0))
|
||||||
|
return reqtype;
|
||||||
return castStrategy->castStandard(reqtype,curtype,true,true);
|
return castStrategy->castStandard(reqtype,curtype,true,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1264,8 +1276,12 @@ TypeOpIntSdiv::TypeOpIntSdiv(TypeFactory *t)
|
||||||
Datatype *TypeOpIntSdiv::getInputCast(const PcodeOp *op,int4 slot,const CastStrategy *castStrategy) const
|
Datatype *TypeOpIntSdiv::getInputCast(const PcodeOp *op,int4 slot,const CastStrategy *castStrategy) const
|
||||||
|
|
||||||
{
|
{
|
||||||
|
const Varnode *vn = op->getIn(slot);
|
||||||
Datatype *reqtype = op->inputTypeLocal(slot);
|
Datatype *reqtype = op->inputTypeLocal(slot);
|
||||||
Datatype *curtype = op->getIn(slot)->getHigh()->getType();
|
Datatype *curtype = vn->getHigh()->getType();
|
||||||
|
int4 promoType = castStrategy->intPromotionType(vn);
|
||||||
|
if (promoType != CastStrategy::NO_PROMOTION && ((promoType & CastStrategy::SIGNED_EXTENSION)==0))
|
||||||
|
return reqtype;
|
||||||
return castStrategy->castStandard(reqtype,curtype,true,true);
|
return castStrategy->castStandard(reqtype,curtype,true,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1280,12 +1296,13 @@ TypeOpIntRem::TypeOpIntRem(TypeFactory *t)
|
||||||
Datatype *TypeOpIntRem::getInputCast(const PcodeOp *op,int4 slot,const CastStrategy *castStrategy) const
|
Datatype *TypeOpIntRem::getInputCast(const PcodeOp *op,int4 slot,const CastStrategy *castStrategy) const
|
||||||
|
|
||||||
{
|
{
|
||||||
if (slot == 0) {
|
const Varnode *vn = op->getIn(slot);
|
||||||
Datatype *reqtype = op->inputTypeLocal(slot);
|
Datatype *reqtype = op->inputTypeLocal(slot);
|
||||||
Datatype *curtype = op->getIn(slot)->getHigh()->getType();
|
Datatype *curtype = vn->getHigh()->getType();
|
||||||
return castStrategy->castStandard(reqtype,curtype,true,true);
|
int4 promoType = castStrategy->intPromotionType(vn);
|
||||||
}
|
if (promoType != CastStrategy::NO_PROMOTION && ((promoType & CastStrategy::UNSIGNED_EXTENSION)==0))
|
||||||
return TypeOpBinary::getInputCast(op,slot,castStrategy);
|
return reqtype;
|
||||||
|
return castStrategy->castStandard(reqtype,curtype,true,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeOpIntSrem::TypeOpIntSrem(TypeFactory *t)
|
TypeOpIntSrem::TypeOpIntSrem(TypeFactory *t)
|
||||||
|
@ -1299,12 +1316,13 @@ TypeOpIntSrem::TypeOpIntSrem(TypeFactory *t)
|
||||||
Datatype *TypeOpIntSrem::getInputCast(const PcodeOp *op,int4 slot,const CastStrategy *castStrategy) const
|
Datatype *TypeOpIntSrem::getInputCast(const PcodeOp *op,int4 slot,const CastStrategy *castStrategy) const
|
||||||
|
|
||||||
{
|
{
|
||||||
if (slot == 0) {
|
const Varnode *vn = op->getIn(slot);
|
||||||
Datatype *reqtype = op->inputTypeLocal(slot);
|
Datatype *reqtype = op->inputTypeLocal(slot);
|
||||||
Datatype *curtype = op->getIn(slot)->getHigh()->getType();
|
Datatype *curtype = vn->getHigh()->getType();
|
||||||
return castStrategy->castStandard(reqtype,curtype,true,true);
|
int4 promoType = castStrategy->intPromotionType(vn);
|
||||||
}
|
if (promoType != CastStrategy::NO_PROMOTION && ((promoType & CastStrategy::SIGNED_EXTENSION)==0))
|
||||||
return TypeOpBinary::getInputCast(op,slot,castStrategy);
|
return reqtype;
|
||||||
|
return castStrategy->castStandard(reqtype,curtype,true,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeOpBoolNegate::TypeOpBoolNegate(TypeFactory *t)
|
TypeOpBoolNegate::TypeOpBoolNegate(TypeFactory *t)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue