diff options
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 69 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 1 |
2 files changed, 48 insertions, 22 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 5c8c9e3e33d..8187b3c0803 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -3194,33 +3194,58 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { } break; - case ISD::FP_ROUND: - if (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0)) == - TargetLowering::Expand) { - // The only way we can lower this is to turn it into a TRUNCSTORE, - // EXTLOAD pair, targetting a temporary location (a stack slot). - - // NOTE: there is a choice here between constantly creating new stack - // slots and always reusing the same one. We currently always create - // new ones, as reuse may inhibit scheduling. - MVT::ValueType VT = Op.getValueType(); // 32 - const Type *Ty = MVT::getTypeForValueType(VT); - uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty); - unsigned Align = TLI.getTargetData()->getPrefTypeAlignment(Ty); - MachineFunction &MF = DAG.getMachineFunction(); - int SSFI = - MF.getFrameInfo()->CreateStackObject(TySize, Align); - SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy()); - Result = DAG.getTruncStore(DAG.getEntryNode(), Node->getOperand(0), - StackSlot, NULL, 0, VT); - Result = DAG.getLoad(VT, Result, StackSlot, NULL, 0, VT); - break; + case ISD::FP_EXTEND: { + MVT::ValueType newVT = Op.getValueType(); + MVT::ValueType oldVT = Op.getOperand(0).getValueType(); + if (TLI.getConvertAction(oldVT, newVT) == TargetLowering::Expand) { + // The only way we can lower this is to turn it into a STORE, + // EXTLOAD pair, targetting a temporary location (a stack slot). + + // NOTE: there is a choice here between constantly creating new stack + // slots and always reusing the same one. We currently always create + // new ones, as reuse may inhibit scheduling. + const Type *Ty = MVT::getTypeForValueType(oldVT); + uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty); + unsigned Align = TLI.getTargetData()->getPrefTypeAlignment(Ty); + MachineFunction &MF = DAG.getMachineFunction(); + int SSFI = + MF.getFrameInfo()->CreateStackObject(TySize, Align); + SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy()); + Result = DAG.getStore(DAG.getEntryNode(), Node->getOperand(0), + StackSlot, NULL, 0); + Result = DAG.getExtLoad(ISD::EXTLOAD, newVT, + Result, StackSlot, NULL, 0, oldVT); + break; + } + } + // FALL THROUGH (to ANY_EXTEND case) + case ISD::FP_ROUND: { + MVT::ValueType newVT = Op.getValueType(); + MVT::ValueType oldVT = Op.getOperand(0).getValueType(); + if (TLI.getConvertAction(oldVT, newVT) == TargetLowering::Expand) { + // The only way we can lower this is to turn it into a TRUNCSTORE, + // LOAD pair, targetting a temporary location (a stack slot). + + // NOTE: there is a choice here between constantly creating new stack + // slots and always reusing the same one. We currently always create + // new ones, as reuse may inhibit scheduling. + const Type *Ty = MVT::getTypeForValueType(newVT); + uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty); + unsigned Align = TLI.getTargetData()->getPrefTypeAlignment(Ty); + MachineFunction &MF = DAG.getMachineFunction(); + int SSFI = + MF.getFrameInfo()->CreateStackObject(TySize, Align); + SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy()); + Result = DAG.getTruncStore(DAG.getEntryNode(), Node->getOperand(0), + StackSlot, NULL, 0, newVT); + Result = DAG.getLoad(newVT, Result, StackSlot, NULL, 0, newVT); + break; + } } // FALL THROUGH case ISD::ANY_EXTEND: case ISD::ZERO_EXTEND: case ISD::SIGN_EXTEND: - case ISD::FP_EXTEND: switch (getTypeAction(Node->getOperand(0).getValueType())) { case Expand: assert(0 && "Shouldn't need to expand other operators here!"); case Legal: diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 1b7b436b031..2e91359b430 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -129,6 +129,7 @@ TargetLowering::TargetLowering(TargetMachine &tm) memset(LoadXActions, 0, sizeof(LoadXActions)); memset(&StoreXActions, 0, sizeof(StoreXActions)); memset(&IndexedModeActions, 0, sizeof(IndexedModeActions)); + memset(&ConvertActions, 0, sizeof(ConvertActions)); // Set all indexed load / store to expand. for (unsigned VT = 0; VT != (unsigned)MVT::LAST_VALUETYPE; ++VT) { |