summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-03-31 01:27:51 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-03-31 01:27:51 +0000
commit168e45b0b3688e2e4d15c8c3d9d00665e2a1e570 (patch)
tree9e45feea925e94afcee329b25098d3c879b466c0 /llvm/lib
parentf144dac7b7ef86d4336131e82871eca4e8f32224 (diff)
downloadbcm5719-llvm-168e45b0b3688e2e4d15c8c3d9d00665e2a1e570.tar.gz
bcm5719-llvm-168e45b0b3688e2e4d15c8c3d9d00665e2a1e570.zip
Expand INSERT_VECTOR_ELT to store vec, sp; store elt, sp+k; vec = load sp;
llvm-svn: 27274
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index d6c3fe0920f..29d7a5ebf6a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -798,7 +798,30 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
// with a "move to register" or "extload into register" instruction, then
// permute it into place, if the idx is a constant and if the idx is
// supported by the target.
- assert(0 && "INSERT_VECTOR_ELT expand not supported yet!");
+ SDOperand StackPtr = CreateStackTemporary(Tmp1.getValueType());
+ // Store the vector.
+ SDOperand Ch = DAG.getNode(ISD::STORE, MVT::Other, DAG.getEntryNode(),
+ Tmp1, StackPtr, DAG.getSrcValue(NULL));
+
+ // Truncate or zero extend offset to target pointer type.
+ MVT::ValueType IntPtr = TLI.getPointerTy();
+ if (Tmp3.getValueType() > IntPtr)
+ Tmp3 = DAG.getNode(ISD::TRUNCATE, IntPtr, Tmp3);
+ else
+ Tmp3 = DAG.getNode(ISD::ZERO_EXTEND, IntPtr, Tmp3);
+
+ // Add the offset to the index.
+ unsigned EltSize = MVT::getSizeInBits(Result.getValueType())/8;
+ Tmp3 = DAG.getNode(ISD::MUL, Tmp3.getValueType(), Tmp3,
+ DAG.getConstant(EltSize, Tmp3.getValueType()));
+ SDOperand StackPtr2 =
+ DAG.getNode(ISD::ADD, Tmp3.getValueType(), Tmp3, StackPtr);
+ // Store the scalar value.
+ Ch = DAG.getNode(ISD::STORE, MVT::Other, Ch,
+ Tmp2, StackPtr2, DAG.getSrcValue(NULL));
+ // Load the updated vector.
+ Result = DAG.getLoad(Result.getValueType(), Ch, StackPtr,
+ DAG.getSrcValue(NULL));
break;
}
}
OpenPOWER on IntegriCloud