summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/TargetLowering.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-03-31 00:28:56 +0000
committerChris Lattner <sabre@nondot.org>2006-03-31 00:28:56 +0000
commit549fb167eb5cb8703b55629b91299411c0f060df (patch)
treeaf4eaee5a478124e58cf892e8540c37d115a8b4a /llvm/lib/Target/TargetLowering.cpp
parent6bf59386248fe43614e2af80bc8e426933b12c82 (diff)
downloadbcm5719-llvm-549fb167eb5cb8703b55629b91299411c0f060df.tar.gz
bcm5719-llvm-549fb167eb5cb8703b55629b91299411c0f060df.zip
Implement TargetLowering::getPackedTypeBreakdown
llvm-svn: 27270
Diffstat (limited to 'llvm/lib/Target/TargetLowering.cpp')
-rw-r--r--llvm/lib/Target/TargetLowering.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/llvm/lib/Target/TargetLowering.cpp b/llvm/lib/Target/TargetLowering.cpp
index 64d1cdb3a84..b9c10ce103e 100644
--- a/llvm/lib/Target/TargetLowering.cpp
+++ b/llvm/lib/Target/TargetLowering.cpp
@@ -14,6 +14,7 @@
#include "llvm/Target/TargetLowering.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/MRegisterInfo.h"
+#include "llvm/DerivedTypes.h"
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/MathExtras.h"
@@ -141,6 +142,46 @@ const char *TargetLowering::getTargetNodeName(unsigned Opcode) const {
return NULL;
}
+/// getPackedTypeBreakdown - Packed types are broken down into some number of
+/// legal scalar types. For example, <8 x float> maps to 2 MVT::v2f32 values
+/// with Altivec or SSE1, or 8 promoted MVT::f64 values with the X86 FP stack.
+///
+/// This method returns the number and type of the resultant breakdown.
+///
+MVT::ValueType TargetLowering::getPackedTypeBreakdown(const PackedType *PTy,
+ unsigned &NumVals) const {
+ // Figure out the right, legal destination reg to copy into.
+ unsigned NumElts = PTy->getNumElements();
+ MVT::ValueType EltTy = getValueType(PTy->getElementType());
+
+ unsigned NumVectorRegs = 1;
+
+ // Divide the input until we get to a supported size. This will always
+ // end with a scalar if the target doesn't support vectors.
+ while (NumElts > 1 && !isTypeLegal(getVectorType(EltTy, NumElts))) {
+ NumElts >>= 1;
+ NumVectorRegs <<= 1;
+ }
+
+ MVT::ValueType VT;
+ if (NumElts == 1)
+ VT = EltTy;
+ else
+ VT = getVectorType(EltTy, NumElts);
+
+ MVT::ValueType DestVT = getTypeToTransformTo(VT);
+ if (DestVT < VT) {
+ // Value is expanded, e.g. i64 -> i16.
+ NumVals = NumVectorRegs*(MVT::getSizeInBits(VT)/MVT::getSizeInBits(DestVT));
+ } else {
+ // Otherwise, promotion or legal types use the same number of registers as
+ // the vector decimated to the appropriate level.
+ NumVals = NumVectorRegs;
+ }
+
+ return DestVT;
+}
+
//===----------------------------------------------------------------------===//
// Optimization Methods
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud