enum LegalizeAction {
Legal, // The target natively supports this type.
Promote, // This type should be executed in a larger type.
- Expand // This type should be split into two types of half the size.
+ Expand, // This type should be split into two types of half the size.
+ FloatToInt, // Convert a floating point type to an integer of the same size.
+ Scalarize, // Replace this one-element vector type with its element type.
+ Split // This vector type should be split into smaller vectors.
};
-
+
/// ValueTypeActions - This is a bitvector that contains two bits for each
/// simple value type, where the two bits correspond to the LegalizeAction
- /// enum. This can be queried with "getTypeAction(VT)".
+ /// enum from TargetLowering. This can be queried with "getTypeAction(VT)".
TargetLowering::ValueTypeActionImpl ValueTypeActions;
/// getTypeAction - Return how we should legalize values of this type, either
- /// it is already legal or we need to expand it into multiple registers of
- /// smaller integer type, or we need to promote it to a larger type.
+ /// it is already legal, or we need to promote it to a larger integer type, or
+ /// we need to expand it into multiple registers of a smaller integer type, or
+ /// we need to scalarize a one-element vector type into the element type, or
+ /// we need to split a vector type into smaller vector types.
LegalizeAction getTypeAction(MVT::ValueType VT) const {
- return (LegalizeAction)ValueTypeActions.getTypeAction(VT);
+ switch (ValueTypeActions.getTypeAction(VT)) {
+ default:
+ assert(false && "Unknown legalize action!");
+ case TargetLowering::Legal:
+ return Legal;
+ case TargetLowering::Promote:
+ return Promote;
+ case TargetLowering::Expand:
+ // Expand can mean
+ // 1) split scalar in half, 2) convert a float to an integer,
+ // 3) scalarize a single-element vector, 4) split a vector in two.
+ if (!MVT::isVector(VT)) {
+ if (MVT::getSizeInBits(VT) ==
+ MVT::getSizeInBits(TLI.getTypeToTransformTo(VT)))
+ return FloatToInt;
+ else
+ return Expand;
+ } else if (MVT::getVectorNumElements(VT) == 1) {
+ return Scalarize;
+ } else {
+ return Split;
+ }
+ }
}
-
+
/// isTypeLegal - Return true if this type is legal on this target.
- ///
bool isTypeLegal(MVT::ValueType VT) const {
- return getTypeAction(VT) == Legal;
+ return ValueTypeActions.getTypeAction(VT) == TargetLowering::Legal;
}
-
+
/// PromotedNodes - For nodes that are below legal width, this map indicates
/// what promoted value to use.
- DenseMap<SDOperand, SDOperand> PromotedNodes;
+ DenseMap<SDOperandImpl, SDOperand> PromotedNodes;
/// ExpandedNodes - For nodes that need to be expanded this map indicates
/// which operands are the expanded version of the input.
- DenseMap<SDOperand, std::pair<SDOperand, SDOperand> > ExpandedNodes;
+ DenseMap<SDOperandImpl, std::pair<SDOperand, SDOperand> > ExpandedNodes;
+
+ /// FloatToIntedNodes - For floating point nodes converted to integers of
+ /// the same size, this map indicates the converted value to use.
+ DenseMap<SDOperandImpl, SDOperand> FloatToIntedNodes;
/// ScalarizedNodes - For nodes that are <1 x ty>, this map indicates the
/// scalar value of type 'ty' to use.
- DenseMap<SDOperand, SDOperand> ScalarizedNodes;
+ DenseMap<SDOperandImpl, SDOperand> ScalarizedNodes;
/// SplitNodes - For nodes that need to be split this map indicates
/// which operands are the expanded version of the input.
- DenseMap<SDOperand, std::pair<SDOperand, SDOperand> > SplitNodes;
+ DenseMap<SDOperandImpl, std::pair<SDOperand, SDOperand> > SplitNodes;
/// ReplacedNodes - For nodes that have been replaced with another,
/// indicates the replacement node to use.
- DenseMap<SDOperand, SDOperand> ReplacedNodes;
+ DenseMap<SDOperandImpl, SDOperand> ReplacedNodes;
/// Worklist - This defines a worklist of nodes to process. In order to be
/// pushed onto this worklist, all operands of a node must have already been
void RemapNode(SDOperand &N);
// Common routines.
+ SDOperand BitConvertToInteger(SDOperand Op);
SDOperand CreateStackStoreLoad(SDOperand Op, MVT::ValueType DestVT);
SDOperand HandleMemIntrinsic(SDNode *N);
- void SplitOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi);
+ SDOperand JoinIntegers(SDOperand Lo, SDOperand Hi);
+ void SplitInteger(SDOperand Op, SDOperand &Lo, SDOperand &Hi);
+ void SplitInteger(SDOperand Op, MVT::ValueType LoVT, MVT::ValueType HiVT,
+ SDOperand &Lo, SDOperand &Hi);
//===--------------------------------------------------------------------===//
// Promotion Support: LegalizeTypesPromote.cpp
// Result Promotion.
void PromoteResult(SDNode *N, unsigned ResNo);
+ SDOperand PromoteResult_BIT_CONVERT(SDNode *N);
SDOperand PromoteResult_BUILD_PAIR(SDNode *N);
SDOperand PromoteResult_Constant(SDNode *N);
SDOperand PromoteResult_CTLZ(SDNode *N);
SDOperand PromoteResult_CTPOP(SDNode *N);
SDOperand PromoteResult_CTTZ(SDNode *N);
+ SDOperand PromoteResult_EXTRACT_VECTOR_ELT(SDNode *N);
SDOperand PromoteResult_FP_ROUND(SDNode *N);
SDOperand PromoteResult_FP_TO_XINT(SDNode *N);
SDOperand PromoteResult_INT_EXTEND(SDNode *N);
void ExpandResult_CTLZ (SDNode *N, SDOperand &Lo, SDOperand &Hi);
void ExpandResult_CTPOP (SDNode *N, SDOperand &Lo, SDOperand &Hi);
void ExpandResult_CTTZ (SDNode *N, SDOperand &Lo, SDOperand &Hi);
+ void ExpandResult_EXTRACT_VECTOR_ELT(SDNode *N, SDOperand &Lo, SDOperand &Hi);
void ExpandResult_LOAD (LoadSDNode *N, SDOperand &Lo, SDOperand &Hi);
void ExpandResult_MERGE_VALUES(SDNode *N, SDOperand &Lo, SDOperand &Hi);
void ExpandResult_SIGN_EXTEND(SDNode *N, SDOperand &Lo, SDOperand &Hi);
void ExpandSetCCOperands(SDOperand &NewLHS, SDOperand &NewRHS,
ISD::CondCode &CCCode);
+ //===--------------------------------------------------------------------===//
+ // Float to Integer Conversion Support: LegalizeTypesFloatToInt.cpp
+ //===--------------------------------------------------------------------===//
+
+ SDOperand GetIntegerOp(SDOperand Op) {
+ SDOperand &IntegerOp = FloatToIntedNodes[Op];
+ RemapNode(IntegerOp);
+ assert(IntegerOp.Val && "Operand wasn't converted to integer?");
+ return IntegerOp;
+ }
+ void SetIntegerOp(SDOperand Op, SDOperand Result);
+
+ // Result Float to Integer Conversion.
+ void FloatToIntResult(SDNode *N, unsigned OpNo);
+ SDOperand FloatToIntRes_BIT_CONVERT(SDNode *N);
+ SDOperand FloatToIntRes_BUILD_PAIR(SDNode *N);
+ SDOperand FloatToIntRes_FCOPYSIGN(SDNode *N);
+
+ // Operand Float to Integer Conversion.
+ bool FloatToIntOperand(SDNode *N, unsigned OpNo);
+ SDOperand FloatToIntOp_BIT_CONVERT(SDNode *N);
+
//===--------------------------------------------------------------------===//
// Scalarization Support: LegalizeTypesScalarize.cpp
//===--------------------------------------------------------------------===//
// Operand Vector Scalarization: <1 x ty> -> ty.
bool ScalarizeOperand(SDNode *N, unsigned OpNo);
+ SDOperand ScalarizeOp_BIT_CONVERT(SDNode *N);
SDOperand ScalarizeOp_EXTRACT_VECTOR_ELT(SDNode *N);
SDOperand ScalarizeOp_STORE(StoreSDNode *N, unsigned OpNo);
void SplitRes_FPOWI(SDNode *N, SDOperand &Lo, SDOperand &Hi);
void SplitRes_SELECT(SDNode *N, SDOperand &Lo, SDOperand &Hi);
- // Operand Vector Scalarization: <128 x ty> -> 2 x <64 x ty>.
+ // Operand Vector Splitting: <128 x ty> -> 2 x <64 x ty>.
bool SplitOperand(SDNode *N, unsigned OpNo);
+ SDOperand SplitOp_BIT_CONVERT(SDNode *N);
SDOperand SplitOp_EXTRACT_SUBVECTOR(SDNode *N);
+ SDOperand SplitOp_EXTRACT_VECTOR_ELT(SDNode *N);
SDOperand SplitOp_RET(SDNode *N, unsigned OpNo);
SDOperand SplitOp_STORE(StoreSDNode *N, unsigned OpNo);
SDOperand SplitOp_VECTOR_SHUFFLE(SDNode *N, unsigned OpNo);