aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2005-12-06 06:18:55 +0000
committerNate Begeman <natebegeman@mac.com>2005-12-06 06:18:55 +0000
commit8cfa57b1b4eade4e0101195b2f94ab288cd03563 (patch)
tree3721af766490b5e0f0cb582115a5cbaadc23a423 /lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
parent4172b10ca1adfc1026428e5f522aaab98bd939ad (diff)
Teach the SelectionDAG ISel how to turn ConstantPacked values into
constant nodes with vector types. Also teach the asm printer how to print ConstantPacked constant pool entries. This allows us to generate altivec code such as the following, which adds a vector constantto a packed float. LCPI1_0: <4 x float> < float 0.0e+0, float 0.0e+0, float 0.0e+0, float 1.0e+0 > .space 4 .space 4 .space 4 .long 1065353216 ; float 1 .text .align 4 .globl _foo _foo: lis r2, ha16(LCPI1_0) la r2, lo16(LCPI1_0)(r2) li r4, 0 lvx v0, r4, r2 lvx v1, r4, r3 vaddfp v0, v1, v0 stvx v0, r4, r3 blr For the llvm code: void %foo(<4 x float> * %a) { entry: %tmp1 = load <4 x float> * %a; %tmp2 = add <4 x float> %tmp1, < float 0.0, float 0.0, float 0.0, float 1.0 > store <4 x float> %tmp2, <4 x float> *%a ret void } git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24616 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/LegalizeDAG.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeDAG.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index c02fc9ac69..18da8168a9 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -690,6 +690,32 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
}
break;
}
+ case ISD::ConstantVec: {
+ // We assume that vector constants are not legal, and will be immediately
+ // spilled to the constant pool.
+ //
+ // FIXME: revisit this when we have some kind of mechanism by which targets
+ // can decided legality of vector constants, of which there may be very
+ // many.
+ //
+ // Create a ConstantPacked, and put it in the constant pool.
+ std::vector<Constant*> CV;
+ MVT::ValueType VT = Node->getValueType(0);
+ for (unsigned I = 0, E = Node->getNumOperands(); I < E; ++I) {
+ SDOperand OpN = Node->getOperand(I);
+ const Type* OpNTy = MVT::getTypeForValueType(OpN.getValueType());
+ if (MVT::isFloatingPoint(VT))
+ CV.push_back(ConstantFP::get(OpNTy,
+ cast<ConstantFPSDNode>(OpN)->getValue()));
+ else
+ CV.push_back(ConstantUInt::get(OpNTy,
+ cast<ConstantSDNode>(OpN)->getValue()));
+ }
+ Constant *CP = ConstantPacked::get(CV);
+ SDOperand CPIdx = DAG.getConstantPool(CP, Node->getValueType(0));
+ Result = DAG.getLoad(VT, DAG.getEntryNode(), CPIdx, DAG.getSrcValue(NULL));
+ break;
+ }
case ISD::TokenFactor:
if (Node->getNumOperands() == 2) {
bool Changed = false;