-SDValue X86TargetLowering::LowerCATCHRET(SDValue Op, SelectionDAG &DAG) const {
- SDValue Chain = Op.getOperand(0);
- SDValue Dest = Op.getOperand(1);
- SDLoc DL(Op);
-
- MVT PtrVT = getPointerTy(DAG.getDataLayout());
-
- MachineFunction &MF = DAG.getMachineFunction();
- if (isAsynchronousEHPersonality(
- classifyEHPersonality(MF.getFunction()->getPersonalityFn()))) {
- // For SEH, codegen catchret as a branch for now.
- // FIXME: Insert something to restore the frame.
- return DAG.getNode(ISD::BR, DL, MVT::Other, Chain, Dest);
- }
-
- unsigned ReturnReg = (PtrVT == MVT::i64 ? X86::RAX : X86::EAX);
-
- // Load the address of the destination block.
- // FIXME: Do this without creating a BlockAddress.
- MachineBasicBlock *DestMBB = cast<BasicBlockSDNode>(Dest)->getBasicBlock();
- BlockAddress *BA =
- BlockAddress::get(const_cast<Function *>(MF.getFunction()),
- const_cast<BasicBlock *>(DestMBB->getBasicBlock()));
- DestMBB->setHasAddressTaken();
- SDValue BlockPtr = DAG.getBlockAddress(BA, PtrVT);
- Chain = DAG.getCopyToReg(Chain, DL, ReturnReg, BlockPtr);
- return DAG.getNode(X86ISD::CATCHRET, DL, MVT::Other, Chain,
- DAG.getRegister(ReturnReg, PtrVT));
-}
-
-SDValue X86TargetLowering::LowerCLEANUPRET(SDValue Op, SelectionDAG &DAG) const {
- return DAG.getNode(X86ISD::CLEANUPRET, SDLoc(Op), MVT::Other,
- Op.getOperand(0));
-}
-