aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/LegalizeTypes.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/SelectionDAG/LegalizeTypes.h')
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeTypes.h179
1 files changed, 87 insertions, 92 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.h b/lib/CodeGen/SelectionDAG/LegalizeTypes.h
index 8ba19f76797f..84ad8f83d906 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -17,7 +17,6 @@
#define LLVM_LIB_CODEGEN_SELECTIONDAG_LEGALIZETYPES_H
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/DenseSet.h"
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
@@ -26,58 +25,56 @@
namespace llvm {
//===----------------------------------------------------------------------===//
-/// DAGTypeLegalizer - This takes an arbitrary SelectionDAG as input and hacks
-/// on it until only value types the target machine can handle are left. This
-/// involves promoting small sizes to large sizes or splitting up large values
-/// into small values.
+/// This takes an arbitrary SelectionDAG as input and hacks on it until only
+/// value types the target machine can handle are left. This involves promoting
+/// small sizes to large sizes or splitting up large values into small values.
///
class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
const TargetLowering &TLI;
SelectionDAG &DAG;
public:
- // NodeIdFlags - This pass uses the NodeId on the SDNodes to hold information
- // about the state of the node. The enum has all the values.
+ /// This pass uses the NodeId on the SDNodes to hold information about the
+ /// state of the node. The enum has all the values.
enum NodeIdFlags {
- /// ReadyToProcess - All operands have been processed, so this node is ready
- /// to be handled.
+ /// All operands have been processed, so this node is ready to be handled.
ReadyToProcess = 0,
- /// NewNode - This is a new node, not before seen, that was created in the
- /// process of legalizing some other node.
+ /// This is a new node, not before seen, that was created in the process of
+ /// legalizing some other node.
NewNode = -1,
- /// Unanalyzed - This node's ID needs to be set to the number of its
- /// unprocessed operands.
+ /// This node's ID needs to be set to the number of its unprocessed
+ /// operands.
Unanalyzed = -2,
- /// Processed - This is a node that has already been processed.
+ /// This is a node that has already been processed.
Processed = -3
// 1+ - This is a node which has this many unprocessed operands.
};
private:
- /// ValueTypeActions - This is a bitvector that contains two bits for each
- /// simple value type, where the two bits correspond to the LegalizeAction
- /// enum from TargetLowering. This can be queried with "getTypeAction(VT)".
+ /// This is a bitvector that contains two bits for each simple value type,
+ /// where the two bits correspond to the LegalizeAction enum from
+ /// TargetLowering. This can be queried with "getTypeAction(VT)".
TargetLowering::ValueTypeActionImpl ValueTypeActions;
- /// getTypeAction - Return how we should legalize values of this type.
+ /// Return how we should legalize values of this type.
TargetLowering::LegalizeTypeAction getTypeAction(EVT VT) const {
return TLI.getTypeAction(*DAG.getContext(), VT);
}
- /// isTypeLegal - Return true if this type is legal on this target.
+ /// Return true if this type is legal on this target.
bool isTypeLegal(EVT VT) const {
return TLI.getTypeAction(*DAG.getContext(), VT) == TargetLowering::TypeLegal;
}
- /// isSimpleLegalType - Return true if this is a simple legal type.
+ /// Return true if this is a simple legal type.
bool isSimpleLegalType(EVT VT) const {
return VT.isSimple() && TLI.isTypeLegal(VT);
}
- /// isLegalInHWReg - Return true if this type can be passed in registers.
+ /// Return true if this type can be passed in registers.
/// For example, x86_64's f128, should to be legally in registers
/// and only some operations converted to library calls or integer
/// bitwise operations.
@@ -90,51 +87,49 @@ private:
return TLI.getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
}
- /// IgnoreNodeResults - Pretend all of this node's results are legal.
+ /// Pretend all of this node's results are legal.
bool IgnoreNodeResults(SDNode *N) const {
return N->getOpcode() == ISD::TargetConstant;
}
- /// PromotedIntegers - For integer nodes that are below legal width, this map
- /// indicates what promoted value to use.
+ /// For integer nodes that are below legal width, this map indicates what
+ /// promoted value to use.
SmallDenseMap<SDValue, SDValue, 8> PromotedIntegers;
- /// ExpandedIntegers - For integer nodes that need to be expanded this map
- /// indicates which operands are the expanded version of the input.
+ /// For integer nodes that need to be expanded this map indicates which
+ /// operands are the expanded version of the input.
SmallDenseMap<SDValue, std::pair<SDValue, SDValue>, 8> ExpandedIntegers;
- /// SoftenedFloats - For floating point nodes converted to integers of
- /// the same size, this map indicates the converted value to use.
+ /// For floating-point nodes converted to integers of the same size, this map
+ /// indicates the converted value to use.
SmallDenseMap<SDValue, SDValue, 8> SoftenedFloats;
- /// PromotedFloats - For floating point nodes that have a smaller precision
- /// than the smallest supported precision, this map indicates what promoted
- /// value to use.
+ /// For floating-point nodes that have a smaller precision than the smallest
+ /// supported precision, this map indicates what promoted value to use.
SmallDenseMap<SDValue, SDValue, 8> PromotedFloats;
- /// ExpandedFloats - For float nodes that need to be expanded this map
- /// indicates which operands are the expanded version of the input.
+ /// For float nodes that need to be expanded this map indicates which operands
+ /// are the expanded version of the input.
SmallDenseMap<SDValue, std::pair<SDValue, SDValue>, 8> ExpandedFloats;
- /// ScalarizedVectors - For nodes that are <1 x ty>, this map indicates the
- /// scalar value of type 'ty' to use.
+ /// For nodes that are <1 x ty>, this map indicates the scalar value of type
+ /// 'ty' to use.
SmallDenseMap<SDValue, SDValue, 8> ScalarizedVectors;
- /// SplitVectors - For nodes that need to be split this map indicates
- /// which operands are the expanded version of the input.
+ /// For nodes that need to be split this map indicates which operands are the
+ /// expanded version of the input.
SmallDenseMap<SDValue, std::pair<SDValue, SDValue>, 8> SplitVectors;
- /// WidenedVectors - For vector nodes that need to be widened, indicates
- /// the widened value to use.
+ /// For vector nodes that need to be widened, indicates the widened value to
+ /// use.
SmallDenseMap<SDValue, SDValue, 8> WidenedVectors;
- /// ReplacedValues - For values that have been replaced with another,
- /// indicates the replacement value to use.
+ /// For values that have been replaced with another, indicates the replacement
+ /// value to use.
SmallDenseMap<SDValue, SDValue, 8> ReplacedValues;
- /// 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
- /// processed.
+ /// 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 processed.
SmallVector<SDNode*, 128> Worklist;
public:
@@ -145,7 +140,7 @@ public:
"Too many value types for ValueTypeActions to hold!");
}
- /// run - This is the main entry point for the type legalizer. This does a
+ /// This is the main entry point for the type legalizer. This does a
/// top-down traversal of the dag, legalizing types as it goes. Returns
/// "true" if it made any changes.
bool run();
@@ -173,9 +168,9 @@ private:
bool CustomLowerNode(SDNode *N, EVT VT, bool LegalizeResult);
bool CustomWidenLowerNode(SDNode *N, EVT VT);
- /// DisintegrateMERGE_VALUES - Replace each result of the given MERGE_VALUES
- /// node with the corresponding input operand, except for the result 'ResNo',
- /// for which the corresponding input operand is returned.
+ /// Replace each result of the given MERGE_VALUES node with the corresponding
+ /// input operand, except for the result 'ResNo', for which the corresponding
+ /// input operand is returned.
SDValue DisintegrateMERGE_VALUES(SDNode *N, unsigned ResNo);
SDValue GetVectorElementPointer(SDValue VecPtr, EVT EltVT, SDValue Index);
@@ -201,9 +196,9 @@ private:
// Integer Promotion Support: LegalizeIntegerTypes.cpp
//===--------------------------------------------------------------------===//
- /// GetPromotedInteger - Given a processed operand Op which was promoted to a
- /// larger integer type, this returns the promoted value. The low bits of the
- /// promoted value corresponding to the original type are exactly equal to Op.
+ /// Given a processed operand Op which was promoted to a larger integer type,
+ /// this returns the promoted value. The low bits of the promoted value
+ /// corresponding to the original type are exactly equal to Op.
/// The extra bits contain rubbish, so the promoted value may need to be zero-
/// or sign-extended from the original type before it is usable (the helpers
/// SExtPromotedInteger and ZExtPromotedInteger can do this for you).
@@ -218,8 +213,7 @@ private:
}
void SetPromotedInteger(SDValue Op, SDValue Result);
- /// SExtPromotedInteger - Get a promoted operand and sign extend it to the
- /// final size.
+ /// Get a promoted operand and sign extend it to the final size.
SDValue SExtPromotedInteger(SDValue Op) {
EVT OldVT = Op.getValueType();
SDLoc dl(Op);
@@ -228,8 +222,7 @@ private:
DAG.getValueType(OldVT));
}
- /// ZExtPromotedInteger - Get a promoted operand and zero extend it to the
- /// final size.
+ /// Get a promoted operand and zero extend it to the final size.
SDValue ZExtPromotedInteger(SDValue Op) {
EVT OldVT = Op.getValueType();
SDLoc dl(Op);
@@ -322,9 +315,9 @@ private:
// Integer Expansion Support: LegalizeIntegerTypes.cpp
//===--------------------------------------------------------------------===//
- /// GetExpandedInteger - Given a processed operand Op which was expanded into
- /// two integers of half the size, this returns the two halves. The low bits
- /// of Op are exactly equal to the bits of Lo; the high bits exactly equal Hi.
+ /// Given a processed operand Op which was expanded into two integers of half
+ /// the size, this returns the two halves. The low bits of Op are exactly
+ /// equal to the bits of Lo; the high bits exactly equal Hi.
/// For example, if Op is an i64 which was expanded into two i32's, then this
/// method returns the two i32's, with Lo being equal to the lower 32 bits of
/// Op, and Hi being equal to the upper 32 bits.
@@ -362,6 +355,8 @@ private:
void ExpandIntRes_UREM (SDNode *N, SDValue &Lo, SDValue &Hi);
void ExpandIntRes_Shift (SDNode *N, SDValue &Lo, SDValue &Hi);
+ void ExpandIntRes_MINMAX (SDNode *N, SDValue &Lo, SDValue &Hi);
+
void ExpandIntRes_SADDSUBO (SDNode *N, SDValue &Lo, SDValue &Hi);
void ExpandIntRes_UADDSUBO (SDNode *N, SDValue &Lo, SDValue &Hi);
void ExpandIntRes_XMULO (SDNode *N, SDValue &Lo, SDValue &Hi);
@@ -388,14 +383,14 @@ private:
SDValue ExpandIntOp_ATOMIC_STORE(SDNode *N);
void IntegerExpandSetCCOperands(SDValue &NewLHS, SDValue &NewRHS,
- ISD::CondCode &CCCode, SDLoc dl);
+ ISD::CondCode &CCCode, const SDLoc &dl);
//===--------------------------------------------------------------------===//
// Float to Integer Conversion Support: LegalizeFloatTypes.cpp
//===--------------------------------------------------------------------===//
- /// GetSoftenedFloat - Given an operand Op of Float type, returns the integer
- /// if the Op is not supported in target HW and converted to the integer.
+ /// Given an operand Op of Float type, returns the integer if the Op is not
+ /// supported in target HW and converted to the integer.
/// The integer contains exactly the same bits as Op - only the type changed.
/// For example, if Op is an f32 which was softened to an i32, then this method
/// returns an i32, the bits of which coincide with those of Op.
@@ -487,8 +482,8 @@ private:
// Float Expansion Support: LegalizeFloatTypes.cpp
//===--------------------------------------------------------------------===//
- /// GetExpandedFloat - Given a processed operand Op which was expanded into
- /// two floating point values of half the size, this returns the two halves.
+ /// Given a processed operand Op which was expanded into two floating-point
+ /// values of half the size, this returns the two halves.
/// The low bits of Op are exactly equal to the bits of Lo; the high bits
/// exactly equal Hi. For example, if Op is a ppcf128 which was expanded
/// into two f64's, then this method returns the two f64's, with Lo being
@@ -542,8 +537,7 @@ private:
SDValue ExpandFloatOp_STORE(SDNode *N, unsigned OpNo);
void FloatExpandSetCCOperands(SDValue &NewLHS, SDValue &NewRHS,
- ISD::CondCode &CCCode, SDLoc dl);
-
+ ISD::CondCode &CCCode, const SDLoc &dl);
//===--------------------------------------------------------------------===//
// Float promotion support: LegalizeFloatTypes.cpp
@@ -586,9 +580,9 @@ private:
// Scalarization Support: LegalizeVectorTypes.cpp
//===--------------------------------------------------------------------===//
- /// GetScalarizedVector - Given a processed one-element vector Op which was
- /// scalarized to its element type, this returns the element. For example,
- /// if Op is a v1i32, Op = < i32 val >, this method returns val, an i32.
+ /// Given a processed one-element vector Op which was scalarized to its
+ /// element type, this returns the element. For example, if Op is a v1i32,
+ /// Op = < i32 val >, this method returns val, an i32.
SDValue GetScalarizedVector(SDValue Op) {
SDValue &ScalarizedOp = ScalarizedVectors[Op];
RemapValue(ScalarizedOp);
@@ -636,12 +630,12 @@ private:
// Vector Splitting Support: LegalizeVectorTypes.cpp
//===--------------------------------------------------------------------===//
- /// GetSplitVector - Given a processed vector Op which was split into vectors
- /// of half the size, this method returns the halves. The first elements of
- /// Op coincide with the elements of Lo; the remaining elements of Op coincide
- /// with the elements of Hi: Op is what you would get by concatenating Lo and
- /// Hi. For example, if Op is a v8i32 that was split into two v4i32's, then
- /// this method returns the two v4i32's, with Lo corresponding to the first 4
+ /// Given a processed vector Op which was split into vectors of half the size,
+ /// this method returns the halves. The first elements of Op coincide with the
+ /// elements of Lo; the remaining elements of Op coincide with the elements of
+ /// Hi: Op is what you would get by concatenating Lo and Hi.
+ /// For example, if Op is a v8i32 that was split into two v4i32's, then this
+ /// method returns the two v4i32's, with Lo corresponding to the first 4
/// elements of Op, and Hi to the last 4 elements.
void GetSplitVector(SDValue Op, SDValue &Lo, SDValue &Hi);
void SetSplitVector(SDValue Op, SDValue Lo, SDValue Hi);
@@ -653,6 +647,7 @@ private:
void SplitVecRes_UnaryOp(SDNode *N, SDValue &Lo, SDValue &Hi);
void SplitVecRes_ExtendOp(SDNode *N, SDValue &Lo, SDValue &Hi);
void SplitVecRes_InregOp(SDNode *N, SDValue &Lo, SDValue &Hi);
+ void SplitVecRes_ExtVecInRegOp(SDNode *N, SDValue &Lo, SDValue &Hi);
void SplitVecRes_BITCAST(SDNode *N, SDValue &Lo, SDValue &Hi);
void SplitVecRes_BUILD_VECTOR(SDNode *N, SDValue &Lo, SDValue &Hi);
@@ -692,12 +687,12 @@ private:
// Vector Widening Support: LegalizeVectorTypes.cpp
//===--------------------------------------------------------------------===//
- /// GetWidenedVector - Given a processed vector Op which was widened into a
- /// larger vector, this method returns the larger vector. The elements of
- /// the returned vector consist of the elements of Op followed by elements
- /// containing rubbish. For example, if Op is a v2i32 that was widened to a
- /// v4i32, then this method returns a v4i32 for which the first two elements
- /// are the same as those of Op, while the last two elements contain rubbish.
+ /// Given a processed vector Op which was widened into a larger vector, this
+ /// method returns the larger vector. The elements of the returned vector
+ /// consist of the elements of Op followed by elements containing rubbish.
+ /// For example, if Op is a v2i32 that was widened to a v4i32, then this
+ /// method returns a v4i32 for which the first two elements are the same as
+ /// those of Op, while the last two elements contain rubbish.
SDValue GetWidenedVector(SDValue Op) {
SDValue &WidenedOp = WidenedVectors[Op];
RemapValue(WidenedOp);
@@ -713,6 +708,7 @@ private:
SDValue WidenVecRes_BUILD_VECTOR(SDNode* N);
SDValue WidenVecRes_CONCAT_VECTORS(SDNode* N);
SDValue WidenVecRes_CONVERT_RNDSAT(SDNode* N);
+ SDValue WidenVecRes_EXTEND_VECTOR_INREG(SDNode* N);
SDValue WidenVecRes_EXTRACT_SUBVECTOR(SDNode* N);
SDValue WidenVecRes_INSERT_VECTOR_ELT(SDNode* N);
SDValue WidenVecRes_LOAD(SDNode* N);
@@ -755,29 +751,29 @@ private:
// Vector Widening Utilities Support: LegalizeVectorTypes.cpp
//===--------------------------------------------------------------------===//
- /// Helper GenWidenVectorLoads - Helper function to generate a set of
- /// loads to load a vector with a resulting wider type. It takes
+ /// Helper function to generate a set of loads to load a vector with a
+ /// resulting wider type. It takes:
/// LdChain: list of chains for the load to be generated.
/// Ld: load to widen
SDValue GenWidenVectorLoads(SmallVectorImpl<SDValue> &LdChain,
LoadSDNode *LD);
- /// GenWidenVectorExtLoads - Helper function to generate a set of extension
- /// loads to load a ector with a resulting wider type. It takes
+ /// Helper function to generate a set of extension loads to load a vector with
+ /// a resulting wider type. It takes:
/// LdChain: list of chains for the load to be generated.
/// Ld: load to widen
/// ExtType: extension element type
SDValue GenWidenVectorExtLoads(SmallVectorImpl<SDValue> &LdChain,
LoadSDNode *LD, ISD::LoadExtType ExtType);
- /// Helper genWidenVectorStores - Helper function to generate a set of
- /// stores to store a widen vector into non-widen memory
+ /// Helper function to generate a set of stores to store a widen vector into
+ /// non-widen memory.
/// StChain: list of chains for the stores we have generated
/// ST: store of a widen value
void GenWidenVectorStores(SmallVectorImpl<SDValue> &StChain, StoreSDNode *ST);
- /// Helper genWidenVectorTruncStores - Helper function to generate a set of
- /// stores to store a truncate widen vector into non-widen memory
+ /// Helper function to generate a set of stores to store a truncate widen
+ /// vector into non-widen memory.
/// StChain: list of chains for the stores we have generated
/// ST: store of a widen value
void GenWidenVectorTruncStores(SmallVectorImpl<SDValue> &StChain,
@@ -785,8 +781,7 @@ private:
/// Modifies a vector input (widen or narrows) to a vector of NVT. The
/// input vector must have the same element type as NVT.
- /// When FillWithZeroes is "on" the vector will be widened with
- /// zeroes.
+ /// When FillWithZeroes is "on" the vector will be widened with zeroes.
/// By default, the vector will be widened with undefined values.
SDValue ModifyToType(SDValue InOp, EVT NVT, bool FillWithZeroes = false);
@@ -807,8 +802,8 @@ private:
GetExpandedFloat(Op, Lo, Hi);
}
- /// GetPairElements - Use ISD::EXTRACT_ELEMENT nodes to extract the low and
- /// high parts of the given value.
+ /// Use ISD::EXTRACT_ELEMENT nodes to extract the low and high parts of the
+ /// given value.
void GetPairElements(SDValue Pair, SDValue &Lo, SDValue &Hi);
// Generic Result Splitting.