//
//===----------------------------------------------------------------------===//
//
-// This file implements float type expansion and conversion of float types to
-// integer types on behalf of LegalizeTypes.
-// Converting to integer is the act of turning a computation in an illegal
-// floating point type into a computation in an integer type of the same size.
-// For example, turning f32 arithmetic into operations using i32. Also known as
-// "soft float". The result is equivalent to bitcasting the float value to the
-// integer type.
+// This file implements float type expansion and softening for LegalizeTypes.
+// Softening is the act of turning a computation in an illegal floating point
+// type into a computation in an integer type of the same size; also known as
+// "soft float". For example, turning f32 arithmetic into operations using i32.
+// The resulting integer value is the same as what you would get by performing
+// the floating point operation and bitcasting the result to the integer type.
// Expansion is the act of changing a computation in an illegal type to be a
// computation in multiple registers of a smaller type. For example,
// implementing ppcf128 arithmetic in two f64 registers.
// Result Float to Integer Conversion.
//===----------------------------------------------------------------------===//
-void DAGTypeLegalizer::PromoteFloatResult(SDNode *N, unsigned ResNo) {
- DEBUG(cerr << "Promote float result " << ResNo << ": "; N->dump(&DAG);
+void DAGTypeLegalizer::SoftenFloatResult(SDNode *N, unsigned ResNo) {
+ DEBUG(cerr << "Soften float result " << ResNo << ": "; N->dump(&DAG);
cerr << "\n");
SDOperand R = SDOperand();
switch (N->getOpcode()) {
default:
#ifndef NDEBUG
- cerr << "PromoteFloatResult #" << ResNo << ": ";
+ cerr << "SoftenFloatResult #" << ResNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
assert(0 && "Do not know how to convert the result of this operator!");
abort();
- case ISD::BIT_CONVERT: R = PromoteFloatRes_BIT_CONVERT(N); break;
- case ISD::BUILD_PAIR: R = PromoteFloatRes_BUILD_PAIR(N); break;
+ case ISD::BIT_CONVERT: R = SoftenFloatRes_BIT_CONVERT(N); break;
+ case ISD::BUILD_PAIR: R = SoftenFloatRes_BUILD_PAIR(N); break;
case ISD::ConstantFP:
- R = PromoteFloatRes_ConstantFP(cast<ConstantFPSDNode>(N));
+ R = SoftenFloatRes_ConstantFP(cast<ConstantFPSDNode>(N));
break;
- case ISD::FCOPYSIGN: R = PromoteFloatRes_FCOPYSIGN(N); break;
- case ISD::LOAD: R = PromoteFloatRes_LOAD(N); break;
+ case ISD::FCOPYSIGN: R = SoftenFloatRes_FCOPYSIGN(N); break;
+ case ISD::LOAD: R = SoftenFloatRes_LOAD(N); break;
case ISD::SINT_TO_FP:
- case ISD::UINT_TO_FP: R = PromoteFloatRes_XINT_TO_FP(N); break;
+ case ISD::UINT_TO_FP: R = SoftenFloatRes_XINT_TO_FP(N); break;
- case ISD::FADD: R = PromoteFloatRes_FADD(N); break;
- case ISD::FMUL: R = PromoteFloatRes_FMUL(N); break;
- case ISD::FSUB: R = PromoteFloatRes_FSUB(N); break;
+ case ISD::FADD: R = SoftenFloatRes_FADD(N); break;
+ case ISD::FMUL: R = SoftenFloatRes_FMUL(N); break;
+ case ISD::FSUB: R = SoftenFloatRes_FSUB(N); break;
}
// If R is null, the sub-method took care of registering the result.
if (R.Val)
- SetPromotedFloat(SDOperand(N, ResNo), R);
+ SetSoftenedFloat(SDOperand(N, ResNo), R);
}
-SDOperand DAGTypeLegalizer::PromoteFloatRes_BIT_CONVERT(SDNode *N) {
+SDOperand DAGTypeLegalizer::SoftenFloatRes_BIT_CONVERT(SDNode *N) {
return BitConvertToInteger(N->getOperand(0));
}
-SDOperand DAGTypeLegalizer::PromoteFloatRes_BUILD_PAIR(SDNode *N) {
+SDOperand DAGTypeLegalizer::SoftenFloatRes_BUILD_PAIR(SDNode *N) {
// Convert the inputs to integers, and build a new pair out of them.
return DAG.getNode(ISD::BUILD_PAIR,
TLI.getTypeToTransformTo(N->getValueType(0)),
BitConvertToInteger(N->getOperand(1)));
}
-SDOperand DAGTypeLegalizer::PromoteFloatRes_ConstantFP(ConstantFPSDNode *N) {
+SDOperand DAGTypeLegalizer::SoftenFloatRes_ConstantFP(ConstantFPSDNode *N) {
return DAG.getConstant(N->getValueAPF().convertToAPInt(),
TLI.getTypeToTransformTo(N->getValueType(0)));
}
-SDOperand DAGTypeLegalizer::PromoteFloatRes_FADD(SDNode *N) {
+SDOperand DAGTypeLegalizer::SoftenFloatRes_FADD(SDNode *N) {
MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
- SDOperand Ops[2] = { GetPromotedFloat(N->getOperand(0)),
- GetPromotedFloat(N->getOperand(1)) };
+ SDOperand Ops[2] = { GetSoftenedFloat(N->getOperand(0)),
+ GetSoftenedFloat(N->getOperand(1)) };
return MakeLibCall(GetFPLibCall(N->getValueType(0),
RTLIB::ADD_F32,
RTLIB::ADD_F64,
NVT, Ops, 2, false/*sign irrelevant*/);
}
-SDOperand DAGTypeLegalizer::PromoteFloatRes_FCOPYSIGN(SDNode *N) {
- SDOperand LHS = GetPromotedFloat(N->getOperand(0));
+SDOperand DAGTypeLegalizer::SoftenFloatRes_FCOPYSIGN(SDNode *N) {
+ SDOperand LHS = GetSoftenedFloat(N->getOperand(0));
SDOperand RHS = BitConvertToInteger(N->getOperand(1));
MVT LVT = LHS.getValueType();
return DAG.getNode(ISD::OR, LVT, LHS, SignBit);
}
-SDOperand DAGTypeLegalizer::PromoteFloatRes_FMUL(SDNode *N) {
+SDOperand DAGTypeLegalizer::SoftenFloatRes_FMUL(SDNode *N) {
MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
- SDOperand Ops[2] = { GetPromotedFloat(N->getOperand(0)),
- GetPromotedFloat(N->getOperand(1)) };
+ SDOperand Ops[2] = { GetSoftenedFloat(N->getOperand(0)),
+ GetSoftenedFloat(N->getOperand(1)) };
return MakeLibCall(GetFPLibCall(N->getValueType(0),
RTLIB::MUL_F32,
RTLIB::MUL_F64,
NVT, Ops, 2, false/*sign irrelevant*/);
}
-SDOperand DAGTypeLegalizer::PromoteFloatRes_FSUB(SDNode *N) {
+SDOperand DAGTypeLegalizer::SoftenFloatRes_FSUB(SDNode *N) {
MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
- SDOperand Ops[2] = { GetPromotedFloat(N->getOperand(0)),
- GetPromotedFloat(N->getOperand(1)) };
+ SDOperand Ops[2] = { GetSoftenedFloat(N->getOperand(0)),
+ GetSoftenedFloat(N->getOperand(1)) };
return MakeLibCall(GetFPLibCall(N->getValueType(0),
RTLIB::SUB_F32,
RTLIB::SUB_F64,
NVT, Ops, 2, false/*sign irrelevant*/);
}
-SDOperand DAGTypeLegalizer::PromoteFloatRes_LOAD(SDNode *N) {
+SDOperand DAGTypeLegalizer::SoftenFloatRes_LOAD(SDNode *N) {
LoadSDNode *L = cast<LoadSDNode>(N);
MVT VT = N->getValueType(0);
MVT NVT = TLI.getTypeToTransformTo(VT);
return BitConvertToInteger(DAG.getNode(ISD::FP_EXTEND, VT, NL));
}
-SDOperand DAGTypeLegalizer::PromoteFloatRes_XINT_TO_FP(SDNode *N) {
+SDOperand DAGTypeLegalizer::SoftenFloatRes_XINT_TO_FP(SDNode *N) {
bool isSigned = N->getOpcode() == ISD::SINT_TO_FP;
MVT DestVT = N->getValueType(0);
SDOperand Op = N->getOperand(0);
// Operand Float to Integer Conversion..
//===----------------------------------------------------------------------===//
-bool DAGTypeLegalizer::PromoteFloatOperand(SDNode *N, unsigned OpNo) {
- DEBUG(cerr << "Promote float operand " << OpNo << ": "; N->dump(&DAG);
+bool DAGTypeLegalizer::SoftenFloatOperand(SDNode *N, unsigned OpNo) {
+ DEBUG(cerr << "Soften float operand " << OpNo << ": "; N->dump(&DAG);
cerr << "\n");
SDOperand Res(0, 0);
switch (N->getOpcode()) {
default:
#ifndef NDEBUG
- cerr << "PromoteFloatOperand Op #" << OpNo << ": ";
+ cerr << "SoftenFloatOperand Op #" << OpNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
assert(0 && "Do not know how to convert this operator's operand!");
abort();
- case ISD::BIT_CONVERT: Res = PromoteFloatOp_BIT_CONVERT(N); break;
+ case ISD::BIT_CONVERT: Res = SoftenFloatOp_BIT_CONVERT(N); break;
}
}
return false;
}
-SDOperand DAGTypeLegalizer::PromoteFloatOp_BIT_CONVERT(SDNode *N) {
+SDOperand DAGTypeLegalizer::SoftenFloatOp_BIT_CONVERT(SDNode *N) {
return DAG.getNode(ISD::BIT_CONVERT, N->getValueType(0),
- GetPromotedFloat(N->getOperand(0)));
+ GetSoftenedFloat(N->getOperand(0)));
}
Legal, // The target natively supports this type.
PromoteInteger, // Replace this integer type with a larger one.
ExpandInteger, // Split this integer type into two of half the size.
- PromoteFloat, // Convert this float type to a same size integer type.
+ SoftenFloat, // Convert this float type to a same size integer type.
ExpandFloat, // Split this float type into two of half the size.
Scalarize, // Replace this one-element vector type with its element type.
Split // This vector type should be split into smaller vectors.
return ExpandInteger;
else if (VT.getSizeInBits() ==
TLI.getTypeToTransformTo(VT).getSizeInBits())
- return PromoteFloat;
+ return SoftenFloat;
else
return ExpandFloat;
} else if (VT.getVectorNumElements() == 1) {
/// indicates which operands are the expanded version of the input.
DenseMap<SDOperand, std::pair<SDOperand, SDOperand> > ExpandedIntegers;
- /// PromotedFloats - For floating point nodes converted to integers of
+ /// SoftenedFloats - For floating point nodes converted to integers of
/// the same size, this map indicates the converted value to use.
- DenseMap<SDOperand, SDOperand> PromotedFloats;
+ DenseMap<SDOperand, SDOperand> SoftenedFloats;
/// ExpandedFloats - For float nodes that need to be expanded this map
/// indicates which operands are the expanded version of the input.
// Float to Integer Conversion Support: LegalizeFloatTypes.cpp
//===--------------------------------------------------------------------===//
- SDOperand GetPromotedFloat(SDOperand Op) {
- SDOperand &PromotedOp = PromotedFloats[Op];
- RemapNode(PromotedOp);
- assert(PromotedOp.Val && "Operand wasn't converted to integer?");
- return PromotedOp;
+ SDOperand GetSoftenedFloat(SDOperand Op) {
+ SDOperand &SoftenedOp = SoftenedFloats[Op];
+ RemapNode(SoftenedOp);
+ assert(SoftenedOp.Val && "Operand wasn't converted to integer?");
+ return SoftenedOp;
}
- void SetPromotedFloat(SDOperand Op, SDOperand Result);
+ void SetSoftenedFloat(SDOperand Op, SDOperand Result);
// Result Float to Integer Conversion.
- void PromoteFloatResult(SDNode *N, unsigned OpNo);
- SDOperand PromoteFloatRes_BIT_CONVERT(SDNode *N);
- SDOperand PromoteFloatRes_BUILD_PAIR(SDNode *N);
- SDOperand PromoteFloatRes_ConstantFP(ConstantFPSDNode *N);
- SDOperand PromoteFloatRes_FADD(SDNode *N);
- SDOperand PromoteFloatRes_FCOPYSIGN(SDNode *N);
- SDOperand PromoteFloatRes_FMUL(SDNode *N);
- SDOperand PromoteFloatRes_FSUB(SDNode *N);
- SDOperand PromoteFloatRes_LOAD(SDNode *N);
- SDOperand PromoteFloatRes_XINT_TO_FP(SDNode *N);
+ void SoftenFloatResult(SDNode *N, unsigned OpNo);
+ SDOperand SoftenFloatRes_BIT_CONVERT(SDNode *N);
+ SDOperand SoftenFloatRes_BUILD_PAIR(SDNode *N);
+ SDOperand SoftenFloatRes_ConstantFP(ConstantFPSDNode *N);
+ SDOperand SoftenFloatRes_FADD(SDNode *N);
+ SDOperand SoftenFloatRes_FCOPYSIGN(SDNode *N);
+ SDOperand SoftenFloatRes_FMUL(SDNode *N);
+ SDOperand SoftenFloatRes_FSUB(SDNode *N);
+ SDOperand SoftenFloatRes_LOAD(SDNode *N);
+ SDOperand SoftenFloatRes_XINT_TO_FP(SDNode *N);
// Operand Float to Integer Conversion.
- bool PromoteFloatOperand(SDNode *N, unsigned OpNo);
- SDOperand PromoteFloatOp_BIT_CONVERT(SDNode *N);
+ bool SoftenFloatOperand(SDNode *N, unsigned OpNo);
+ SDOperand SoftenFloatOp_BIT_CONVERT(SDNode *N);
//===--------------------------------------------------------------------===//
// Float Expansion Support: LegalizeFloatTypes.cpp