summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-03-21 21:02:03 +0000
committerChris Lattner <sabre@nondot.org>2006-03-21 21:02:03 +0000
commit340a6b5c263c22c1b135ee2fbc0f9016dd78616e (patch)
tree7efd339a105d030c3b66f5813d701921e4b3984c /llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
parent00f4683bf6216ea2b1beb199dea155c87e9cd8b0 (diff)
downloadbcm5719-llvm-340a6b5c263c22c1b135ee2fbc0f9016dd78616e.tar.gz
bcm5719-llvm-340a6b5c263c22c1b135ee2fbc0f9016dd78616e.zip
add expand support for extractelement
llvm-svn: 26931
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 041340ee53f..6c2b188b38f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -826,7 +826,37 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
Tmp1 = LegalizeOp(Node->getOperand(0));
Tmp2 = LegalizeOp(Node->getOperand(1));
Result = DAG.UpdateNodeOperands(Result, Tmp1, Tmp2);
- // FIXME: LOWER.
+
+ switch (TLI.getOperationAction(ISD::EXTRACT_VECTOR_ELT,
+ Tmp1.getValueType())) {
+ default: assert(0 && "This action is not supported yet!");
+ case TargetLowering::Legal:
+ break;
+ case TargetLowering::Custom:
+ Tmp3 = TLI.LowerOperation(Result, DAG);
+ if (Tmp3.Val) {
+ Result = Tmp3;
+ break;
+ }
+ // FALLTHROUGH
+ case TargetLowering::Expand: {
+ // If the target doesn't support this, store the value to a temporary
+ // stack slot, then LOAD the scalar element back out.
+ SDOperand StackPtr = CreateStackTemporary(Tmp1.getValueType());
+ SDOperand Ch = DAG.getNode(ISD::STORE, MVT::Other, DAG.getEntryNode(),
+ Tmp1, StackPtr, DAG.getSrcValue(NULL));
+
+ // Add the offset to the index.
+ unsigned EltSize = MVT::getSizeInBits(Result.getValueType())/8;
+ Tmp2 = DAG.getNode(ISD::MUL, Tmp2.getValueType(), Tmp2,
+ DAG.getConstant(EltSize, Tmp2.getValueType()));
+ StackPtr = DAG.getNode(ISD::ADD, Tmp2.getValueType(), Tmp2, StackPtr);
+
+ Result = DAG.getLoad(Result.getValueType(), Ch, StackPtr,
+ DAG.getSrcValue(NULL));
+ break;
+ }
+ }
break;
case ISD::VEXTRACT_VECTOR_ELT:
OpenPOWER on IntegriCloud