From 934ea49a5581e02586edd313c59ce65914f3a59f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 15 Jan 2006 08:55:25 +0000 Subject: [PATCH] Have legalize take care of DYNAMIC_STACKALLOC for us, implement llvm.stacksave/stackrestore. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25332 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Sparc/SparcISelDAGToDAG.cpp | 22 ++++------------------ lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp | 22 ++++------------------ 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/lib/Target/Sparc/SparcISelDAGToDAG.cpp b/lib/Target/Sparc/SparcISelDAGToDAG.cpp index c67b5aa5923..96b442cfb65 100644 --- a/lib/Target/Sparc/SparcISelDAGToDAG.cpp +++ b/lib/Target/Sparc/SparcISelDAGToDAG.cpp @@ -136,8 +136,6 @@ SparcV8TargetLowering::SparcV8TargetLowering(TargetMachine &TM) setOperationAction(ISD::SELECT_CC, MVT::f32, Custom); setOperationAction(ISD::SELECT_CC, MVT::f64, Custom); - setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Custom); - // V8 has no intrinsics for these particular operations. setOperationAction(ISD::MEMMOVE, MVT::Other, Expand); setOperationAction(ISD::MEMSET, MVT::Other, Expand); @@ -163,9 +161,12 @@ SparcV8TargetLowering::SparcV8TargetLowering(TargetMachine &TM) setOperationAction(ISD::DEBUG_LOC, MVT::Other, Expand); setOperationAction(ISD::DEBUG_LABEL, MVT::Other, Expand); - // Not implemented yet. + // Expand these to their default code. setOperationAction(ISD::STACKSAVE, MVT::Other, Expand); setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand); + setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Expand); + + setStackPointerRegisterToSaveRestore(V8::O6); computeRegisterProperties(); } @@ -701,21 +702,6 @@ LowerOperation(SDOperand Op, SelectionDAG &DAG) { return DAG.getNode(Opc, TrueVal.getValueType(), TrueVal, FalseVal, DAG.getConstant(CC, MVT::i32), CompareFlag); } - case ISD::DYNAMIC_STACKALLOC: { - SDOperand Chain = Op.getOperand(0); - SDOperand Size = Op.getOperand(1); - - SDOperand SP = DAG.getCopyFromReg(Chain, V8::O6, MVT::i32); - Chain = SP.getValue(1); - SDOperand Res = DAG.getNode(ISD::SUB, MVT::i32, SP, Size); - Chain = DAG.getCopyToReg(Chain, V8::O6, Res); - - std::vector VTs(Op.Val->value_begin(), Op.Val->value_end()); - std::vector Ops; - Ops.push_back(Res); - Ops.push_back(Chain); - return DAG.getNode(ISD::MERGE_VALUES, VTs, Ops); - } } } diff --git a/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp b/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp index c67b5aa5923..96b442cfb65 100644 --- a/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp +++ b/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp @@ -136,8 +136,6 @@ SparcV8TargetLowering::SparcV8TargetLowering(TargetMachine &TM) setOperationAction(ISD::SELECT_CC, MVT::f32, Custom); setOperationAction(ISD::SELECT_CC, MVT::f64, Custom); - setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Custom); - // V8 has no intrinsics for these particular operations. setOperationAction(ISD::MEMMOVE, MVT::Other, Expand); setOperationAction(ISD::MEMSET, MVT::Other, Expand); @@ -163,9 +161,12 @@ SparcV8TargetLowering::SparcV8TargetLowering(TargetMachine &TM) setOperationAction(ISD::DEBUG_LOC, MVT::Other, Expand); setOperationAction(ISD::DEBUG_LABEL, MVT::Other, Expand); - // Not implemented yet. + // Expand these to their default code. setOperationAction(ISD::STACKSAVE, MVT::Other, Expand); setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand); + setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Expand); + + setStackPointerRegisterToSaveRestore(V8::O6); computeRegisterProperties(); } @@ -701,21 +702,6 @@ LowerOperation(SDOperand Op, SelectionDAG &DAG) { return DAG.getNode(Opc, TrueVal.getValueType(), TrueVal, FalseVal, DAG.getConstant(CC, MVT::i32), CompareFlag); } - case ISD::DYNAMIC_STACKALLOC: { - SDOperand Chain = Op.getOperand(0); - SDOperand Size = Op.getOperand(1); - - SDOperand SP = DAG.getCopyFromReg(Chain, V8::O6, MVT::i32); - Chain = SP.getValue(1); - SDOperand Res = DAG.getNode(ISD::SUB, MVT::i32, SP, Size); - Chain = DAG.getCopyToReg(Chain, V8::O6, Res); - - std::vector VTs(Op.Val->value_begin(), Op.Val->value_end()); - std::vector Ops; - Ops.push_back(Res); - Ops.push_back(Chain); - return DAG.getNode(ISD::MERGE_VALUES, VTs, Ops); - } } } -- 2.34.1