[llvm-commits] CVS: llvm/include/llvm/CodeGen/ValueTypes.h
Nate Begeman
natebegeman at mac.com
Wed Nov 30 00:22:41 PST 2005
Changes in directory llvm/include/llvm/CodeGen:
ValueTypes.h updated: 1.14 -> 1.15
---
Log message:
First chunk of actually generating vector code for packed types. These
changes allow us to generate the following code:
_foo:
li r2, 0
lvx v0, r2, r3
vaddfp v0, v0, v0
stvx v0, r2, r3
blr
for this llvm:
void %foo(<4 x float>* %a) {
entry:
%tmp1 = load <4 x float>* %a
%tmp2 = add <4 x float> %tmp1, %tmp1
store <4 x float> %tmp2, <4 x float>* %a
ret void
}
---
Diffs of the changes: (+17 -4)
ValueTypes.h | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
Index: llvm/include/llvm/CodeGen/ValueTypes.h
diff -u llvm/include/llvm/CodeGen/ValueTypes.h:1.14 llvm/include/llvm/CodeGen/ValueTypes.h:1.15
--- llvm/include/llvm/CodeGen/ValueTypes.h:1.14 Mon Nov 28 23:45:28 2005
+++ llvm/include/llvm/CodeGen/ValueTypes.h Wed Nov 30 02:22:02 2005
@@ -45,10 +45,8 @@
isVoid = 12, // This has no value
Vector = 13, // This is an abstract vector type, which will
- // be refined into a target vector type, or
- // scalarized.
-
- // These are 128 bit vectors of varying packed types
+ // be expanded into a target vector type, or scalars
+ // if no matching vector type is available.
v16i8 = 14, // 16 x i8
v8i16 = 15, // 8 x i16
v4i32 = 16, // 4 x i32
@@ -70,6 +68,21 @@
return (VT >= v16i8 && VT <= v2f64);
}
+ /// 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.
+ ///
+ static inline ValueType getVectorType(ValueType VT, unsigned NumElements) {
+ switch (VT) {
+ default:
+ break;
+ case MVT::f32:
+ if (NumElements == 4) return MVT::v4f32;
+ break;
+ }
+ return MVT::Other;
+ }
+
static inline unsigned getSizeInBits(ValueType VT) {
switch (VT) {
default: assert(0 && "ValueType has no known size!");
More information about the llvm-commits
mailing list