mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-08 19:25:47 +00:00
Expand FP constant to integers if FP types are not legal.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32497 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -488,10 +488,10 @@ void SelectionDAGLegalize::HandleOp(SDOperand Op) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ExpandConstantFP - Expands the ConstantFP node by spilling the constant to
|
/// ExpandConstantFP - Expands the ConstantFP node by either converting it to
|
||||||
/// memory.
|
/// integer constant or spilling the constant to memory.
|
||||||
static SDOperand ExpandConstantFP(ConstantFPSDNode *CFP, SelectionDAG &DAG,
|
static SDOperand ExpandConstantFP(ConstantFPSDNode *CFP, bool ToMem,
|
||||||
TargetLowering &TLI) {
|
SelectionDAG &DAG, TargetLowering &TLI) {
|
||||||
bool Extend = false;
|
bool Extend = false;
|
||||||
|
|
||||||
// If a FP immediate is precise when represented as a float and if the
|
// If a FP immediate is precise when represented as a float and if the
|
||||||
@@ -502,6 +502,13 @@ static SDOperand ExpandConstantFP(ConstantFPSDNode *CFP, SelectionDAG &DAG,
|
|||||||
bool isDouble = VT == MVT::f64;
|
bool isDouble = VT == MVT::f64;
|
||||||
ConstantFP *LLVMC = ConstantFP::get(isDouble ? Type::DoubleTy :
|
ConstantFP *LLVMC = ConstantFP::get(isDouble ? Type::DoubleTy :
|
||||||
Type::FloatTy, CFP->getValue());
|
Type::FloatTy, CFP->getValue());
|
||||||
|
if (!ToMem) {
|
||||||
|
double Val = LLVMC->getValue();
|
||||||
|
return isDouble
|
||||||
|
? DAG.getConstant(DoubleToBits(Val), MVT::i64)
|
||||||
|
: DAG.getConstant(FloatToBits(Val), MVT::i32);
|
||||||
|
}
|
||||||
|
|
||||||
if (isDouble && CFP->isExactlyValue((float)CFP->getValue()) &&
|
if (isDouble && CFP->isExactlyValue((float)CFP->getValue()) &&
|
||||||
// Only do this if the target has a native EXTLOAD instruction from f32.
|
// Only do this if the target has a native EXTLOAD instruction from f32.
|
||||||
TLI.isLoadXLegal(ISD::EXTLOAD, MVT::f32)) {
|
TLI.isLoadXLegal(ISD::EXTLOAD, MVT::f32)) {
|
||||||
@@ -806,7 +813,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
|
|||||||
}
|
}
|
||||||
// FALLTHROUGH
|
// FALLTHROUGH
|
||||||
case TargetLowering::Expand:
|
case TargetLowering::Expand:
|
||||||
Result = ExpandConstantFP(CFP, DAG, TLI);
|
Result = ExpandConstantFP(CFP, true, DAG, TLI);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -4405,8 +4412,7 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){
|
|||||||
}
|
}
|
||||||
case ISD::ConstantFP: {
|
case ISD::ConstantFP: {
|
||||||
ConstantFPSDNode *CFP = cast<ConstantFPSDNode>(Node);
|
ConstantFPSDNode *CFP = cast<ConstantFPSDNode>(Node);
|
||||||
SDOperand Tmp = ExpandConstantFP(CFP, DAG, TLI);
|
Lo = ExpandConstantFP(CFP, false, DAG, TLI);
|
||||||
ExpandOp(Tmp, Lo, Hi);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ISD::BUILD_PAIR:
|
case ISD::BUILD_PAIR:
|
||||||
|
Reference in New Issue
Block a user