From 209f58503377534d445914764d47faa4924ffa21 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 16 Jan 2005 02:23:07 +0000 Subject: [PATCH] Add support for promoted registers being live across blocks. llvm-svn: 19595 --- .../CodeGen/SelectionDAG/SelectionDAGISel.cpp | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 0b4ffa54f0a1..aab9d468571f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -257,7 +257,20 @@ public: std::map::const_iterator VMI = FuncInfo.ValueMap.find(V); assert(VMI != FuncInfo.ValueMap.end() && "Value not in map!"); - return N = DAG.getCopyFromReg(VMI->second, VT, DAG.getEntryNode()); + + MVT::ValueType RegVT = VT; + if (TLI.getTypeAction(VT) == 1) // Must promote this value? + RegVT = TLI.getTypeToTransformTo(VT); + + N = DAG.getCopyFromReg(VMI->second, RegVT, DAG.getEntryNode()); + + if (RegVT != VT) + if (MVT::isFloatingPoint(VT)) + N = DAG.getNode(ISD::FP_ROUND, VT, N); + else + N = DAG.getNode(ISD::TRUNCATE, VT, N); + + return N; } const SDOperand &setValue(const Value *V, SDOperand NewN) { @@ -777,6 +790,14 @@ CopyValueToVirtualRegister(SelectionDAGLowering &SDL, Value *V, unsigned Reg) { assert((Op.getOpcode() != ISD::CopyFromReg || cast(Op)->getReg() != Reg) && "Copy from a reg to the same reg!"); + MVT::ValueType VT = Op.getValueType(); + if (TLI.getTypeAction(VT) == 1) { // Must promote this value? + if (MVT::isFloatingPoint(VT)) + Op = DAG.getNode(ISD::FP_EXTEND, TLI.getTypeToTransformTo(VT), Op); + else + Op = DAG.getNode(ISD::ZERO_EXTEND, TLI.getTypeToTransformTo(VT), Op); + } + return DAG.getCopyToReg(DAG.getRoot(), Op, Reg); }