[llvm-commits] CVS: llvm/include/llvm/CodeGen/CallingConvLower.h SelectionDAG.h SelectionDAGNodes.h ValueTypes.h
Dan Gohman
djg at cray.com
Mon Jun 25 09:24:13 PDT 2007
Changes in directory llvm/include/llvm/CodeGen:
CallingConvLower.h updated: 1.5 -> 1.6
SelectionDAG.h updated: 1.151 -> 1.152
SelectionDAGNodes.h updated: 1.192 -> 1.193
ValueTypes.h updated: 1.35 -> 1.36
---
Log message:
Generalize MVT::ValueType and associated functions to be able to represent
extended vector types. Remove the special SDNode opcodes used for pre-legalize
vector operations, and the special MVT::Vector type used with them. Adjust
lowering and legalize to work with the normal SDNode kinds instead, and to
use the normal MVT functions to work with vector types instead of using the
two special operands that the pre-legalize nodes held.
This allows pre-legalize and post-legalize DAGs, and the code that operates
on them, to be more consistent. Pre-legalize vector operators can be handled
more consistently with scalar operators. And, -view-dag-combine1-dags and
-view-legalize-dags now look prettier for vector code.
---
Diffs of the changes: (+141 -141)
CallingConvLower.h | 4 -
SelectionDAG.h | 2
SelectionDAGNodes.h | 89 +++---------------------
ValueTypes.h | 187 ++++++++++++++++++++++++++++++++++------------------
4 files changed, 141 insertions(+), 141 deletions(-)
Index: llvm/include/llvm/CodeGen/CallingConvLower.h
diff -u llvm/include/llvm/CodeGen/CallingConvLower.h:1.5 llvm/include/llvm/CodeGen/CallingConvLower.h:1.6
--- llvm/include/llvm/CodeGen/CallingConvLower.h:1.5 Mon Jun 18 19:10:25 2007
+++ llvm/include/llvm/CodeGen/CallingConvLower.h Mon Jun 25 11:23:39 2007
@@ -48,10 +48,10 @@
LocInfo HTP : 7;
/// ValVT - The type of the value being assigned.
- MVT::ValueType ValVT : 8;
+ MVT::ValueType ValVT;
/// LocVT - The type of the location being assigned to.
- MVT::ValueType LocVT : 8;
+ MVT::ValueType LocVT;
public:
static CCValAssign getReg(unsigned ValNo, MVT::ValueType ValVT,
Index: llvm/include/llvm/CodeGen/SelectionDAG.h
diff -u llvm/include/llvm/CodeGen/SelectionDAG.h:1.151 llvm/include/llvm/CodeGen/SelectionDAG.h:1.152
--- llvm/include/llvm/CodeGen/SelectionDAG.h:1.151 Fri Jun 22 09:59:07 2007
+++ llvm/include/llvm/CodeGen/SelectionDAG.h Mon Jun 25 11:23:39 2007
@@ -319,8 +319,6 @@
unsigned Alignment=0);
SDOperand getIndexedLoad(SDOperand OrigLoad, SDOperand Base,
SDOperand Offset, ISD::MemIndexedMode AM);
- SDOperand getVecLoad(unsigned Count, MVT::ValueType VT, SDOperand Chain,
- SDOperand Ptr, SDOperand SV);
/// getStore - Helper function to build ISD::STORE nodes.
///
Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h
diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.192 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.193
--- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.192 Wed Jun 13 10:12:02 2007
+++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Mon Jun 25 11:23:39 2007
@@ -237,58 +237,30 @@
// FCOPYSIGN(f32, f64) is allowed.
FCOPYSIGN,
- /// VBUILD_VECTOR(ELT1, ELT2, ELT3, ELT4,..., COUNT,TYPE) - Return a vector
- /// with the specified, possibly variable, elements. The number of elements
- /// is required to be a power of two.
- VBUILD_VECTOR,
-
/// BUILD_VECTOR(ELT1, ELT2, ELT3, ELT4,...) - Return a vector
/// with the specified, possibly variable, elements. The number of elements
/// is required to be a power of two.
BUILD_VECTOR,
- /// VINSERT_VECTOR_ELT(VECTOR, VAL, IDX, COUNT,TYPE) - Given a vector
- /// VECTOR, an element ELEMENT, and a (potentially variable) index IDX,
- /// return a vector with the specified element of VECTOR replaced with VAL.
- /// COUNT and TYPE specify the type of vector, as is standard for V* nodes.
- VINSERT_VECTOR_ELT,
-
- /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR (a legal packed
- /// type) with the element at IDX replaced with VAL.
+ /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element
+ /// at IDX replaced with VAL.
INSERT_VECTOR_ELT,
- /// VEXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
- /// (an MVT::Vector value) identified by the (potentially variable) element
- /// number IDX.
- VEXTRACT_VECTOR_ELT,
-
/// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
- /// (a legal vector type vector) identified by the (potentially variable)
- /// element number IDX.
+ /// identified by the (potentially variable) element number IDX.
EXTRACT_VECTOR_ELT,
- /// VCONCAT_VECTORS(VECTOR0, VECTOR1, ..., COUNT,TYPE) - Given a number of
- /// values of MVT::Vector type with the same length and element type, this
- /// produces a concatenated MVT::Vector result value, with length equal to
- /// the sum of the input vectors. This can only be used before
- /// legalization.
- VCONCAT_VECTORS,
-
- /// VEXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an
- /// MVT::Vector value) starting with the (potentially variable)
- /// element number IDX, which must be a multiple of the result vector
- /// length. This can only be used before legalization.
- VEXTRACT_SUBVECTOR,
-
- /// VVECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC, COUNT,TYPE) - Returns a vector,
- /// of the same type as VEC1/VEC2. SHUFFLEVEC is a VBUILD_VECTOR of
- /// constant int values that indicate which value each result element will
- /// get. The elements of VEC1/VEC2 are enumerated in order. This is quite
- /// similar to the Altivec 'vperm' instruction, except that the indices must
- /// be constants and are in terms of the element size of VEC1/VEC2, not in
- /// terms of bytes.
- VVECTOR_SHUFFLE,
-
+ /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of
+ /// vector type with the same length and element type, this produces a
+ /// concatenated vector result value, with length equal to the sum of the
+ /// input vectors.
+ CONCAT_VECTORS,
+
+ /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an
+ /// vector value) starting with the (potentially variable) element number
+ /// IDX, which must be a multiple of the result vector length.
+ EXTRACT_SUBVECTOR,
+
/// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same
/// type as VEC1/VEC2. SHUFFLEVEC is a BUILD_VECTOR of constant int values
/// (regardless of whether its datatype is legal or not) that indicate
@@ -298,34 +270,6 @@
/// of the element size of VEC1/VEC2, not in terms of bytes.
VECTOR_SHUFFLE,
- /// X = VBIT_CONVERT(Y) and X = VBIT_CONVERT(Y, COUNT,TYPE) - This node
- /// represents a conversion from or to an ISD::Vector type.
- ///
- /// This is lowered to a BIT_CONVERT of the appropriate input/output types.
- /// The input and output are required to have the same size and at least one
- /// is required to be a vector (if neither is a vector, just use
- /// BIT_CONVERT).
- ///
- /// If the result is a vector, this takes three operands (like any other
- /// vector producer) which indicate the size and type of the vector result.
- /// Otherwise it takes one input.
- VBIT_CONVERT,
-
- /// BINOP(LHS, RHS, COUNT,TYPE)
- /// Simple abstract vector operators. Unlike the integer and floating point
- /// binary operators, these nodes also take two additional operands:
- /// a constant element count, and a value type node indicating the type of
- /// the elements. The order is op0, op1, count, type. All vector opcodes,
- /// including VLOAD and VConstant must currently have count and type as
- /// their last two operands.
- VADD, VSUB, VMUL, VSDIV, VUDIV,
- VAND, VOR, VXOR,
-
- /// VSELECT(COND,LHS,RHS, COUNT,TYPE) - Select for MVT::Vector values.
- /// COND is a boolean value. This node return LHS if COND is true, RHS if
- /// COND is false.
- VSELECT,
-
/// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a
/// scalar value into the low element of the resultant vector type. The top
/// elements of the vector are undefined.
@@ -432,11 +376,6 @@
// indexed memory ops).
LOAD, STORE,
- // Abstract vector version of LOAD. VLOAD has a constant element count as
- // the first operand, followed by a value type node indicating the type of
- // the elements, a token chain, a pointer operand, and a SRCVALUE node.
- VLOAD,
-
// TRUNCSTORE - This operators truncates (for integer) or rounds (for FP) a
// value and stores it to memory in one operation. This can be used for
// either integer or floating point operands. The first four operands of
Index: llvm/include/llvm/CodeGen/ValueTypes.h
diff -u llvm/include/llvm/CodeGen/ValueTypes.h:1.35 llvm/include/llvm/CodeGen/ValueTypes.h:1.36
--- llvm/include/llvm/CodeGen/ValueTypes.h:1.35 Thu Jun 14 17:58:02 2007
+++ llvm/include/llvm/CodeGen/ValueTypes.h Mon Jun 25 11:23:39 2007
@@ -17,16 +17,17 @@
#define LLVM_CODEGEN_VALUETYPES_H
#include <cassert>
+#include <string>
#include "llvm/Support/DataTypes.h"
namespace llvm {
class Type;
-/// MVT namespace - This namespace defines the ValueType enum, which contains
-/// the various low-level value types.
+/// MVT namespace - This namespace defines the SimpleValueType enum, which
+/// contains the various low-level value types, and the ValueType typedef.
///
namespace MVT { // MVT = Machine Value Types
- enum ValueType {
+ enum SimpleValueType {
// If you change this numbering, you must change the values in ValueTypes.td
// well!
Other = 0, // This is a non-standard value
@@ -45,10 +46,6 @@
isVoid = 12, // This has no value
- Vector = 13, // This is an abstract vector type, which will
- // be expanded into a target vector type, or scalars
- // if no matching vector type is available.
-
v8i8 = 14, // 8 x i8
v4i16 = 15, // 4 x i16
v2i32 = 16, // 2 x i32
@@ -76,64 +73,55 @@
iPTR = 255
};
- /// MVT::isInteger - Return true if this is a simple integer, or a packed
- /// vector integer type.
- static inline bool isInteger(ValueType VT) {
- return (VT >= i1 && VT <= i128) || (VT >= v8i8 && VT <= v2i64);
+ /// MVT::ValueType - This type holds low-level value types. Valid values
+ /// include any of the values in the SimpleValueType enum, or any value
+ /// returned from a function in the MVT namespace that has a ValueType
+ /// return type. Any value type equal to one of the SimpleValueType enum
+ /// values is a "simple" value type. All other value types are "extended".
+ ///
+ /// Note that simple doesn't necessary mean legal for the target machine.
+ /// All legal value types must be simple, but often there are some simple
+ /// value types that are not legal.
+ typedef uint32_t ValueType;
+
+ static const int SimpleTypeBits = 8;
+
+ static const uint32_t SimpleTypeMask =
+ (~uint32_t(0) << (32 - SimpleTypeBits)) >> (32 - SimpleTypeBits);
+
+ /// MVT::isExtendedValueType - Test if the given ValueType is extended
+ /// (as opposed to being simple).
+ static inline bool isExtendedValueType(ValueType VT) {
+ return VT & ~SimpleTypeMask;
}
- /// MVT::isFloatingPoint - Return true if this is a simple FP, or a packed
- /// vector FP type.
- static inline bool isFloatingPoint(ValueType VT) {
- return (VT >= f32 && VT <= f128) || (VT >= v2f32 && VT <= v2f64);
+ /// MVT::isInteger - Return true if this is an integer, or a vector integer
+ /// type.
+ static inline bool isInteger(ValueType VT) {
+ ValueType SVT = VT & SimpleTypeMask;
+ return (SVT >= i1 && SVT <= i128) || (SVT >= v8i8 && SVT <= v2i64);
}
- /// MVT::isVector - Return true if this is a packed vector type (i.e. not
- /// MVT::Vector).
- static inline bool isVector(ValueType VT) {
- return VT >= FIRST_VECTOR_VALUETYPE && VT <= LAST_VECTOR_VALUETYPE;
+ /// MVT::isFloatingPoint - Return true if this is an FP, or a vector FP type.
+ static inline bool isFloatingPoint(ValueType VT) {
+ ValueType SVT = VT & SimpleTypeMask;
+ return (SVT >= f32 && SVT <= f128) || (SVT >= v2f32 && SVT <= v2f64);
}
- /// MVT::getSizeInBits - Return the size of the specified value type in bits.
- ///
- static inline unsigned getSizeInBits(ValueType VT) {
- switch (VT) {
- default: assert(0 && "ValueType has no known size!");
- case MVT::i1 : return 1;
- case MVT::i8 : return 8;
- case MVT::i16 : return 16;
- case MVT::f32 :
- case MVT::i32 : return 32;
- case MVT::f64 :
- case MVT::i64 :
- case MVT::v8i8:
- case MVT::v4i16:
- case MVT::v2i32:
- case MVT::v1i64:
- case MVT::v2f32: return 64;
- case MVT::f80 : return 80;
- case MVT::f128:
- case MVT::i128:
- case MVT::v16i8:
- case MVT::v8i16:
- case MVT::v4i32:
- case MVT::v2i64:
- case MVT::v4f32:
- case MVT::v2f64: return 128;
- }
+ /// MVT::isVector - Return true if this is a vector value type.
+ static inline bool isVector(ValueType VT) {
+ return (VT >= FIRST_VECTOR_VALUETYPE && VT <= LAST_VECTOR_VALUETYPE) ||
+ isExtendedValueType(VT);
}
- /// MVT::getVectorType - Returns the ValueType that represents a vector
- /// NumElements in length, where each element is of type VT. If there is no
- /// ValueType that represents this vector, a ValueType of Other is returned.
- ///
- ValueType getVectorType(ValueType VT, unsigned NumElements);
-
- /// MVT::getVectorElementType - Given a packed vector type, return the type of
+ /// MVT::getVectorElementType - Given a vector type, return the type of
/// each element.
static inline ValueType getVectorElementType(ValueType VT) {
switch (VT) {
- default: assert(0 && "Invalid vector type!");
+ default:
+ if (isExtendedValueType(VT))
+ return VT & SimpleTypeMask;
+ assert(0 && "Invalid vector type!");
case v8i8 :
case v16i8: return i8;
case v4i16:
@@ -148,11 +136,14 @@
}
}
- /// MVT::getVectorNumElements - Given a packed vector type, return the number
- /// of elements it contains.
+ /// MVT::getVectorNumElements - Given a vector type, return the
+ /// number of elements it contains.
static inline unsigned getVectorNumElements(ValueType VT) {
switch (VT) {
- default: assert(0 && "Invalid vector type!");
+ default:
+ if (isExtendedValueType(VT))
+ return ((VT & ~SimpleTypeMask) >> SimpleTypeBits) - 1;
+ assert(0 && "Invalid vector type!");
case v16i8: return 16;
case v8i8 :
case v8i16: return 8;
@@ -167,11 +158,84 @@
}
}
+ /// MVT::getSizeInBits - Return the size of the specified value type
+ /// in bits.
+ ///
+ static inline unsigned getSizeInBits(ValueType VT) {
+ switch (VT) {
+ default:
+ if (isExtendedValueType(VT))
+ return getSizeInBits(getVectorElementType(VT)) *
+ getVectorNumElements(VT);
+ assert(0 && "ValueType has no known size!");
+ case MVT::i1 : return 1;
+ case MVT::i8 : return 8;
+ case MVT::i16 : return 16;
+ case MVT::f32 :
+ case MVT::i32 : return 32;
+ case MVT::f64 :
+ case MVT::i64 :
+ case MVT::v8i8:
+ case MVT::v4i16:
+ case MVT::v2i32:
+ case MVT::v1i64:
+ case MVT::v2f32: return 64;
+ case MVT::f80 : return 80;
+ case MVT::f128:
+ case MVT::i128:
+ case MVT::v16i8:
+ case MVT::v8i16:
+ case MVT::v4i32:
+ case MVT::v2i64:
+ case MVT::v4f32:
+ case MVT::v2f64: return 128;
+ }
+ }
+
+ /// MVT::getVectorType - Returns the ValueType that represents a vector
+ /// NumElements in length, where each element is of type VT.
+ ///
+ static inline ValueType getVectorType(ValueType VT, unsigned NumElements) {
+ switch (VT) {
+ default:
+ break;
+ case MVT::i8:
+ if (NumElements == 8) return MVT::v8i8;
+ if (NumElements == 16) return MVT::v16i8;
+ break;
+ case MVT::i16:
+ if (NumElements == 4) return MVT::v4i16;
+ if (NumElements == 8) return MVT::v8i16;
+ break;
+ case MVT::i32:
+ if (NumElements == 2) return MVT::v2i32;
+ if (NumElements == 4) return MVT::v4i32;
+ break;
+ case MVT::i64:
+ if (NumElements == 1) return MVT::v1i64;
+ if (NumElements == 2) return MVT::v2i64;
+ break;
+ case MVT::f32:
+ if (NumElements == 2) return MVT::v2f32;
+ if (NumElements == 4) return MVT::v4f32;
+ break;
+ case MVT::f64:
+ if (NumElements == 2) return MVT::v2f64;
+ break;
+ }
+ ValueType Result = VT | ((NumElements + 1) << SimpleTypeBits);
+ assert(getVectorElementType(Result) == VT &&
+ "Bad vector element type!");
+ assert(getVectorNumElements(Result) == NumElements &&
+ "Bad vector length!");
+ return Result;
+ }
+
/// MVT::getIntVectorWithNumElements - Return any integer vector type that has
/// the specified number of elements.
static inline ValueType getIntVectorWithNumElements(unsigned NumElts) {
switch (NumElts) {
- default: assert(0 && "Invalid vector type!");
+ default: return getVectorType(i8, NumElts);
case 1: return v1i64;
case 2: return v2i32;
case 4: return v4i16;
@@ -196,7 +260,7 @@
/// MVT::getValueTypeString - This function returns value type as a string,
/// e.g. "i32".
- const char *getValueTypeString(ValueType VT);
+ std::string getValueTypeString(ValueType VT);
/// MVT::getTypeForValueType - This method returns an LLVM type corresponding
/// to the specified ValueType. For integer types, this returns an unsigned
@@ -204,9 +268,8 @@
const Type *getTypeForValueType(ValueType VT);
/// MVT::getValueType - Return the value type corresponding to the specified
- /// type. This returns all vectors as MVT::Vector and all pointers as
- /// MVT::iPTR. If HandleUnknown is true, unknown types are returned as Other,
- /// otherwise they are invalid.
+ /// type. This returns all pointers as MVT::iPTR. If HandleUnknown is true,
+ /// unknown types are returned as Other, otherwise they are invalid.
ValueType getValueType(const Type *Ty, bool HandleUnknown = false);
}
More information about the llvm-commits
mailing list