| OLD | NEW | 
|      1 //===-- X86ISelLowering.cpp - X86 DAG Lowering Implementation -------------===// |      1 //===-- X86ISelLowering.cpp - X86 DAG Lowering Implementation -------------===// | 
|      2 // |      2 // | 
|      3 //                     The LLVM Compiler Infrastructure |      3 //                     The LLVM Compiler Infrastructure | 
|      4 // |      4 // | 
|      5 // This file is distributed under the University of Illinois Open Source |      5 // This file is distributed under the University of Illinois Open Source | 
|      6 // License. See LICENSE.TXT for details. |      6 // License. See LICENSE.TXT for details. | 
|      7 // |      7 // | 
|      8 //===----------------------------------------------------------------------===// |      8 //===----------------------------------------------------------------------===// | 
|      9 // |      9 // | 
|     10 // This file defines the interfaces that X86 uses to lower LLVM code into a |     10 // This file defines the interfaces that X86 uses to lower LLVM code into a | 
| (...skipping 7552 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   7563   SDValue RSFIN = DAG.getFrameIndex(FuncInfo->getRegSaveFrameIndex(), |   7563   SDValue RSFIN = DAG.getFrameIndex(FuncInfo->getRegSaveFrameIndex(), | 
|   7564                                     getPointerTy()); |   7564                                     getPointerTy()); | 
|   7565   Store = DAG.getStore(Op.getOperand(0), DL, RSFIN, FIN, |   7565   Store = DAG.getStore(Op.getOperand(0), DL, RSFIN, FIN, | 
|   7566                        MachinePointerInfo(SV, 16), false, false, 0); |   7566                        MachinePointerInfo(SV, 16), false, false, 0); | 
|   7567   MemOps.push_back(Store); |   7567   MemOps.push_back(Store); | 
|   7568   return DAG.getNode(ISD::TokenFactor, DL, MVT::Other, |   7568   return DAG.getNode(ISD::TokenFactor, DL, MVT::Other, | 
|   7569                      &MemOps[0], MemOps.size()); |   7569                      &MemOps[0], MemOps.size()); | 
|   7570 } |   7570 } | 
|   7571  |   7571  | 
|   7572 SDValue X86TargetLowering::LowerVAARG(SDValue Op, SelectionDAG &DAG) const { |   7572 SDValue X86TargetLowering::LowerVAARG(SDValue Op, SelectionDAG &DAG) const { | 
|   7573   // X86-64 va_list is a struct { i32, i32, i8*, i8* }. |   7573   assert(Subtarget->is64Bit() && | 
|   7574   assert(Subtarget->is64Bit() && "This code only handles 64-bit va_arg!"); |   7574          "LowerVAARG only handles 64-bit va_arg!"); | 
 |   7575   assert((Subtarget->isTargetLinux() || | 
 |   7576           Subtarget->isTargetDarwin()) && | 
 |   7577           "Unhandled target in LowerVAARG"); | 
 |   7578   assert(Op.getNode()->getNumOperands() == 4); | 
 |   7579   SDValue Chain = Op.getOperand(0); | 
 |   7580   SDValue SrcPtr = Op.getOperand(1); | 
 |   7581   const Value *SV = cast<SrcValueSDNode>(Op.getOperand(2))->getValue(); | 
 |   7582   unsigned Align = Op.getConstantOperandVal(3); | 
 |   7583   DebugLoc dl = Op.getDebugLoc(); | 
|   7575  |   7584  | 
|   7576   report_fatal_error("VAArgInst is not yet implemented for x86-64!"); |   7585   EVT ArgVT = Op.getNode()->getValueType(0); | 
|   7577   return SDValue(); |   7586   const Type *ArgTy = ArgVT.getTypeForEVT(*DAG.getContext()); | 
 |   7587   uint32_t ArgSize = getTargetData()->getTypeAllocSize(ArgTy); | 
 |   7588   uint8_t ArgMode; | 
 |   7589  | 
 |   7590   // Decide which area this value should be read from. | 
 |   7591   // TODO: Implement the AMD64 ABI in its entirety. This simple | 
 |   7592   // selection mechanism works only for the basic types. | 
 |   7593   if (ArgVT == MVT::f80) { | 
 |   7594     llvm_unreachable("va_arg for f80 not yet implemented"); | 
 |   7595   } else if (ArgVT.isFloatingPoint() && ArgSize <= 16 /*bytes*/) { | 
 |   7596     ArgMode = 2;  // Argument passed in XMM register. Use fp_offset. | 
 |   7597   } else if (ArgVT.isInteger() && ArgSize <= 32 /*bytes*/) { | 
 |   7598     ArgMode = 1;  // Argument passed in GPR64 register(s). Use gp_offset. | 
 |   7599   } else { | 
 |   7600     llvm_unreachable("Unhandled argument type in LowerVAARG"); | 
 |   7601   } | 
 |   7602  | 
 |   7603   if (ArgMode == 2) { | 
 |   7604     // Sanity Check: Make sure using fp_offset makes sense. | 
 |   7605     const Function *Fn = DAG.getMachineFunction().getFunction(); | 
 |   7606     bool NoImplicitFloatOps = Fn->hasFnAttr(Attribute::NoImplicitFloat); | 
 |   7607     assert(!UseSoftFloat && !NoImplicitFloatOps && Subtarget->hasSSE1()); | 
 |   7608   } | 
 |   7609  | 
 |   7610   // Insert VAARG_64 node into the DAG | 
 |   7611   // VAARG_64 returns two values: Variable Argument Address, Chain | 
 |   7612   SmallVector<SDValue, 11> InstOps; | 
 |   7613   InstOps.push_back(Chain); | 
 |   7614   InstOps.push_back(SrcPtr); | 
 |   7615   InstOps.push_back(DAG.getConstant(ArgSize, MVT::i32)); | 
 |   7616   InstOps.push_back(DAG.getConstant(ArgMode, MVT::i8)); | 
 |   7617   InstOps.push_back(DAG.getConstant(Align, MVT::i32)); | 
 |   7618   SDVTList VTs = DAG.getVTList(getPointerTy(), MVT::Other); | 
 |   7619   SDValue VAARG = DAG.getMemIntrinsicNode(X86ISD::VAARG_64, dl, | 
 |   7620                                           VTs, &InstOps[0], InstOps.size(), | 
 |   7621                                           MVT::i64, | 
 |   7622                                           MachinePointerInfo(SV), | 
 |   7623                                           /*Align=*/0, | 
 |   7624                                           /*Volatile=*/false, | 
 |   7625                                           /*ReadMem=*/true, | 
 |   7626                                           /*WriteMem=*/true); | 
 |   7627   Chain = VAARG.getValue(1); | 
 |   7628  | 
 |   7629   // Load the next argument and return it | 
 |   7630   return DAG.getLoad(ArgVT, dl, | 
 |   7631                      Chain, | 
 |   7632                      VAARG, | 
 |   7633                      MachinePointerInfo(), | 
 |   7634                      false, false, 0); | 
|   7578 } |   7635 } | 
|   7579  |   7636  | 
|   7580 SDValue X86TargetLowering::LowerVACOPY(SDValue Op, SelectionDAG &DAG) const { |   7637 SDValue X86TargetLowering::LowerVACOPY(SDValue Op, SelectionDAG &DAG) const { | 
|   7581   // X86-64 va_list is a struct { i32, i32, i8*, i8* }. |   7638   // X86-64 va_list is a struct { i32, i32, i8*, i8* }. | 
|   7582   assert(Subtarget->is64Bit() && "This code only handles 64-bit va_copy!"); |   7639   assert(Subtarget->is64Bit() && "This code only handles 64-bit va_copy!"); | 
|   7583   SDValue Chain = Op.getOperand(0); |   7640   SDValue Chain = Op.getOperand(0); | 
|   7584   SDValue DstPtr = Op.getOperand(1); |   7641   SDValue DstPtr = Op.getOperand(1); | 
|   7585   SDValue SrcPtr = Op.getOperand(2); |   7642   SDValue SrcPtr = Op.getOperand(2); | 
|   7586   const Value *DstSV = cast<SrcValueSDNode>(Op.getOperand(3))->getValue(); |   7643   const Value *DstSV = cast<SrcValueSDNode>(Op.getOperand(3))->getValue(); | 
|   7587   const Value *SrcSV = cast<SrcValueSDNode>(Op.getOperand(4))->getValue(); |   7644   const Value *SrcSV = cast<SrcValueSDNode>(Op.getOperand(4))->getValue(); | 
| (...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   8843   case X86ISD::UNPCKHPD:           return "X86ISD::UNPCKHPD"; |   8900   case X86ISD::UNPCKHPD:           return "X86ISD::UNPCKHPD"; | 
|   8844   case X86ISD::PUNPCKLBW:          return "X86ISD::PUNPCKLBW"; |   8901   case X86ISD::PUNPCKLBW:          return "X86ISD::PUNPCKLBW"; | 
|   8845   case X86ISD::PUNPCKLWD:          return "X86ISD::PUNPCKLWD"; |   8902   case X86ISD::PUNPCKLWD:          return "X86ISD::PUNPCKLWD"; | 
|   8846   case X86ISD::PUNPCKLDQ:          return "X86ISD::PUNPCKLDQ"; |   8903   case X86ISD::PUNPCKLDQ:          return "X86ISD::PUNPCKLDQ"; | 
|   8847   case X86ISD::PUNPCKLQDQ:         return "X86ISD::PUNPCKLQDQ"; |   8904   case X86ISD::PUNPCKLQDQ:         return "X86ISD::PUNPCKLQDQ"; | 
|   8848   case X86ISD::PUNPCKHBW:          return "X86ISD::PUNPCKHBW"; |   8905   case X86ISD::PUNPCKHBW:          return "X86ISD::PUNPCKHBW"; | 
|   8849   case X86ISD::PUNPCKHWD:          return "X86ISD::PUNPCKHWD"; |   8906   case X86ISD::PUNPCKHWD:          return "X86ISD::PUNPCKHWD"; | 
|   8850   case X86ISD::PUNPCKHDQ:          return "X86ISD::PUNPCKHDQ"; |   8907   case X86ISD::PUNPCKHDQ:          return "X86ISD::PUNPCKHDQ"; | 
|   8851   case X86ISD::PUNPCKHQDQ:         return "X86ISD::PUNPCKHQDQ"; |   8908   case X86ISD::PUNPCKHQDQ:         return "X86ISD::PUNPCKHQDQ"; | 
|   8852   case X86ISD::VASTART_SAVE_XMM_REGS: return "X86ISD::VASTART_SAVE_XMM_REGS"; |   8909   case X86ISD::VASTART_SAVE_XMM_REGS: return "X86ISD::VASTART_SAVE_XMM_REGS"; | 
 |   8910   case X86ISD::VAARG_64:           return "X86ISD::VAARG_64"; | 
|   8853   case X86ISD::MINGW_ALLOCA:       return "X86ISD::MINGW_ALLOCA"; |   8911   case X86ISD::MINGW_ALLOCA:       return "X86ISD::MINGW_ALLOCA"; | 
|   8854   } |   8912   } | 
|   8855 } |   8913 } | 
|   8856  |   8914  | 
|   8857 // isLegalAddressingMode - Return true if the addressing mode represented |   8915 // isLegalAddressingMode - Return true if the addressing mode represented | 
|   8858 // by AM is legal for this target, for a load/store of the specified type. |   8916 // by AM is legal for this target, for a load/store of the specified type. | 
|   8859 bool X86TargetLowering::isLegalAddressingMode(const AddrMode &AM, |   8917 bool X86TargetLowering::isLegalAddressingMode(const AddrMode &AM, | 
|   8860                                               const Type *Ty) const { |   8918                                               const Type *Ty) const { | 
|   8861   // X86 supports extremely general addressing modes. |   8919   // X86 supports extremely general addressing modes. | 
|   8862   CodeModel::Model M = getTargetMachine().getCodeModel(); |   8920   CodeModel::Model M = getTargetMachine().getCodeModel(); | 
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   9404  |   9462  | 
|   9405   BuildMI(BB, dl, TII->get(X86::MOVAPSrr), MI->getOperand(0).getReg()) |   9463   BuildMI(BB, dl, TII->get(X86::MOVAPSrr), MI->getOperand(0).getReg()) | 
|   9406     .addReg(X86::XMM0); |   9464     .addReg(X86::XMM0); | 
|   9407  |   9465  | 
|   9408   MI->eraseFromParent(); |   9466   MI->eraseFromParent(); | 
|   9409  |   9467  | 
|   9410   return BB; |   9468   return BB; | 
|   9411 } |   9469 } | 
|   9412  |   9470  | 
|   9413 MachineBasicBlock * |   9471 MachineBasicBlock * | 
 |   9472 X86TargetLowering::EmitVAARG64WithCustomInserter( | 
 |   9473                    MachineInstr *MI, | 
 |   9474                    MachineBasicBlock *MBB) const { | 
 |   9475   // Emit va_arg instruction on X86-64. | 
 |   9476  | 
 |   9477   // Operands to this pseudo-instruction: | 
 |   9478   // 0  ) Output        : destination address (reg) | 
 |   9479   // 1-5) Input         : va_list address (addr, i64mem) | 
 |   9480   // 6  ) ArgSize       : Size (in bytes) of vararg type | 
 |   9481   // 7  ) ArgMode       : 0=overflow only, 1=use gp_offset, 2=use fp_offset | 
 |   9482   // 8  ) Align         : Alignment of type | 
 |   9483   // 9  ) EFLAGS (implicit-def) | 
 |   9484  | 
 |   9485   assert(MI->getNumOperands() == 10 && "VAARG_64 should have 10 operands!"); | 
 |   9486   assert(X86::AddrNumOperands == 5 && "VAARG_64 assumes 5 address operands"); | 
 |   9487  | 
 |   9488   unsigned DestReg = MI->getOperand(0).getReg(); | 
 |   9489   MachineOperand &Base = MI->getOperand(1); | 
 |   9490   MachineOperand &Scale = MI->getOperand(2); | 
 |   9491   MachineOperand &Index = MI->getOperand(3); | 
 |   9492   MachineOperand &Disp = MI->getOperand(4); | 
 |   9493   MachineOperand &Segment = MI->getOperand(5); | 
 |   9494   unsigned ArgSize = MI->getOperand(6).getImm(); | 
 |   9495   unsigned ArgMode = MI->getOperand(7).getImm(); | 
 |   9496   unsigned Align = MI->getOperand(8).getImm(); | 
 |   9497  | 
 |   9498   // Memory Reference | 
 |   9499   assert(MI->hasOneMemOperand() && "Expected VAARG_64 to have one memoperand"); | 
 |   9500   MachineInstr::mmo_iterator MMOBegin = MI->memoperands_begin(); | 
 |   9501   MachineInstr::mmo_iterator MMOEnd = MI->memoperands_end(); | 
 |   9502  | 
 |   9503   // Machine Information | 
 |   9504   const TargetInstrInfo *TII = getTargetMachine().getInstrInfo(); | 
 |   9505   MachineRegisterInfo &MRI = MBB->getParent()->getRegInfo(); | 
 |   9506   const TargetRegisterClass *AddrRegClass = getRegClassFor(MVT::i64); | 
 |   9507   const TargetRegisterClass *OffsetRegClass = getRegClassFor(MVT::i32); | 
 |   9508   DebugLoc DL = MI->getDebugLoc(); | 
 |   9509  | 
 |   9510   // struct va_list { | 
 |   9511   //   i32   gp_offset | 
 |   9512   //   i32   fp_offset | 
 |   9513   //   i64   overflow_area (address) | 
 |   9514   //   i64   reg_save_area (address) | 
 |   9515   // } | 
 |   9516   // sizeof(va_list) = 24 | 
 |   9517   // alignment(va_list) = 8 | 
 |   9518  | 
 |   9519   unsigned TotalNumIntRegs = 6; | 
 |   9520   unsigned TotalNumXMMRegs = 8; | 
 |   9521   bool UseGPOffset = (ArgMode == 1); | 
 |   9522   bool UseFPOffset = (ArgMode == 2); | 
 |   9523   unsigned MaxOffset = TotalNumIntRegs * 8 + | 
 |   9524                        (UseFPOffset ? TotalNumXMMRegs * 16 : 0); | 
 |   9525  | 
 |   9526   /* Align ArgSize to a multiple of 8 */ | 
 |   9527   unsigned ArgSizeA8 = (ArgSize + 7) & ~7; | 
 |   9528   bool NeedsAlign = (Align > 8); | 
 |   9529  | 
 |   9530   MachineBasicBlock *thisMBB = MBB; | 
 |   9531   MachineBasicBlock *overflowMBB; | 
 |   9532   MachineBasicBlock *offsetMBB; | 
 |   9533   MachineBasicBlock *endMBB; | 
 |   9534  | 
 |   9535   unsigned OffsetDestReg = 0;    // Argument address computed by offsetMBB | 
 |   9536   unsigned OverflowDestReg = 0;  // Argument address computed by overflowMBB | 
 |   9537   unsigned OffsetReg = 0; | 
 |   9538  | 
 |   9539   if (!UseGPOffset && !UseFPOffset) { | 
 |   9540     // If we only pull from the overflow region, we don't create a branch. | 
 |   9541     // We don't need to alter control flow. | 
 |   9542     OffsetDestReg = 0; // unused | 
 |   9543     OverflowDestReg = DestReg; | 
 |   9544  | 
 |   9545     offsetMBB = NULL; | 
 |   9546     overflowMBB = thisMBB; | 
 |   9547     endMBB = thisMBB; | 
 |   9548   } else { | 
 |   9549     // First emit code to check if gp_offset (or fp_offset) is below the bound. | 
 |   9550     // If so, pull the argument from reg_save_area. (branch to offsetMBB) | 
 |   9551     // If not, pull from overflow_area. (branch to overflowMBB) | 
 |   9552     // | 
 |   9553     //       thisMBB | 
 |   9554     //         |     . | 
 |   9555     //         |        . | 
 |   9556     //     offsetMBB   overflowMBB | 
 |   9557     //         |        . | 
 |   9558     //         |     . | 
 |   9559     //        endMBB | 
 |   9560  | 
 |   9561     // Registers for the PHI in endMBB | 
 |   9562     OffsetDestReg = MRI.createVirtualRegister(AddrRegClass); | 
 |   9563     OverflowDestReg = MRI.createVirtualRegister(AddrRegClass); | 
 |   9564  | 
 |   9565     const BasicBlock *LLVM_BB = MBB->getBasicBlock(); | 
 |   9566     MachineFunction *MF = MBB->getParent(); | 
 |   9567     overflowMBB = MF->CreateMachineBasicBlock(LLVM_BB); | 
 |   9568     offsetMBB = MF->CreateMachineBasicBlock(LLVM_BB); | 
 |   9569     endMBB = MF->CreateMachineBasicBlock(LLVM_BB); | 
 |   9570  | 
 |   9571     MachineFunction::iterator MBBIter = MBB; | 
 |   9572     ++MBBIter; | 
 |   9573  | 
 |   9574     // Insert the new basic blocks | 
 |   9575     MF->insert(MBBIter, offsetMBB); | 
 |   9576     MF->insert(MBBIter, overflowMBB); | 
 |   9577     MF->insert(MBBIter, endMBB); | 
 |   9578  | 
 |   9579     // Transfer the remainder of MBB and its successor edges to endMBB. | 
 |   9580     endMBB->splice(endMBB->begin(), thisMBB, | 
 |   9581                     llvm::next(MachineBasicBlock::iterator(MI)), | 
 |   9582                     thisMBB->end()); | 
 |   9583     endMBB->transferSuccessorsAndUpdatePHIs(thisMBB); | 
 |   9584  | 
 |   9585     // Make offsetMBB and overflowMBB successors of thisMBB | 
 |   9586     thisMBB->addSuccessor(offsetMBB); | 
 |   9587     thisMBB->addSuccessor(overflowMBB); | 
 |   9588  | 
 |   9589     // endMBB is a successor of both offsetMBB and overflowMBB | 
 |   9590     offsetMBB->addSuccessor(endMBB); | 
 |   9591     overflowMBB->addSuccessor(endMBB); | 
 |   9592  | 
 |   9593     // Load the offset value into a register | 
 |   9594     OffsetReg = MRI.createVirtualRegister(OffsetRegClass); | 
 |   9595     BuildMI(thisMBB, DL, TII->get(X86::MOV32rm), OffsetReg) | 
 |   9596       .addOperand(Base) | 
 |   9597       .addOperand(Scale) | 
 |   9598       .addOperand(Index) | 
 |   9599       .addDisp(Disp, UseFPOffset ? 4 : 0) | 
 |   9600       .addOperand(Segment) | 
 |   9601       .setMemRefs(MMOBegin, MMOEnd); | 
 |   9602  | 
 |   9603     // Check if there is enough room left to pull this argument. | 
 |   9604     BuildMI(thisMBB, DL, TII->get(X86::CMP32ri)) | 
 |   9605       .addReg(OffsetReg) | 
 |   9606       .addImm(MaxOffset + 8 - ArgSizeA8); | 
 |   9607  | 
 |   9608     // Branch to "overflowMBB" if offset >= max | 
 |   9609     // Fall through to "offsetMBB" otherwise | 
 |   9610     BuildMI(thisMBB, DL, TII->get(X86::GetCondBranchFromCond(X86::COND_AE))) | 
 |   9611       .addMBB(overflowMBB); | 
 |   9612   } | 
 |   9613  | 
 |   9614   // In offsetMBB, emit code to use the reg_save_area. | 
 |   9615   if (offsetMBB) { | 
 |   9616     assert(OffsetReg != 0); | 
 |   9617  | 
 |   9618     // Read the reg_save_area address. | 
 |   9619     unsigned RegSaveReg = MRI.createVirtualRegister(AddrRegClass); | 
 |   9620     BuildMI(offsetMBB, DL, TII->get(X86::MOV64rm), RegSaveReg) | 
 |   9621       .addOperand(Base) | 
 |   9622       .addOperand(Scale) | 
 |   9623       .addOperand(Index) | 
 |   9624       .addDisp(Disp, 16) | 
 |   9625       .addOperand(Segment) | 
 |   9626       .setMemRefs(MMOBegin, MMOEnd); | 
 |   9627  | 
 |   9628     // Zero-extend the offset | 
 |   9629     unsigned OffsetReg64 = MRI.createVirtualRegister(AddrRegClass); | 
 |   9630       BuildMI(offsetMBB, DL, TII->get(X86::SUBREG_TO_REG), OffsetReg64) | 
 |   9631         .addImm(0) | 
 |   9632         .addReg(OffsetReg) | 
 |   9633         .addImm(X86::sub_32bit); | 
 |   9634  | 
 |   9635     // Add the offset to the reg_save_area to get the final address. | 
 |   9636     BuildMI(offsetMBB, DL, TII->get(X86::ADD64rr), OffsetDestReg) | 
 |   9637       .addReg(OffsetReg64) | 
 |   9638       .addReg(RegSaveReg); | 
 |   9639  | 
 |   9640     // Compute the offset for the next argument | 
 |   9641     unsigned NextOffsetReg = MRI.createVirtualRegister(OffsetRegClass); | 
 |   9642     BuildMI(offsetMBB, DL, TII->get(X86::ADD32ri), NextOffsetReg) | 
 |   9643       .addReg(OffsetReg) | 
 |   9644       .addImm(UseFPOffset ? 16 : 8); | 
 |   9645  | 
 |   9646     // Store it back into the va_list. | 
 |   9647     BuildMI(offsetMBB, DL, TII->get(X86::MOV32mr)) | 
 |   9648       .addOperand(Base) | 
 |   9649       .addOperand(Scale) | 
 |   9650       .addOperand(Index) | 
 |   9651       .addDisp(Disp, UseFPOffset ? 4 : 0) | 
 |   9652       .addOperand(Segment) | 
 |   9653       .addReg(NextOffsetReg) | 
 |   9654       .setMemRefs(MMOBegin, MMOEnd); | 
 |   9655  | 
 |   9656     // Jump to endMBB | 
 |   9657     BuildMI(offsetMBB, DL, TII->get(X86::JMP_4)) | 
 |   9658       .addMBB(endMBB); | 
 |   9659   } | 
 |   9660  | 
 |   9661   // | 
 |   9662   // Emit code to use overflow area | 
 |   9663   // | 
 |   9664  | 
 |   9665   // Load the overflow_area address into a register. | 
 |   9666   unsigned OverflowAddrReg = MRI.createVirtualRegister(AddrRegClass); | 
 |   9667   BuildMI(overflowMBB, DL, TII->get(X86::MOV64rm), OverflowAddrReg) | 
 |   9668     .addOperand(Base) | 
 |   9669     .addOperand(Scale) | 
 |   9670     .addOperand(Index) | 
 |   9671     .addDisp(Disp, 8) | 
 |   9672     .addOperand(Segment) | 
 |   9673     .setMemRefs(MMOBegin, MMOEnd); | 
 |   9674  | 
 |   9675   // If we need to align it, do so. Otherwise, just copy the address | 
 |   9676   // to OverflowDestReg. | 
 |   9677   if (NeedsAlign) { | 
 |   9678     // Align the overflow address | 
 |   9679     assert((Align & (Align-1)) == 0 && "Alignment must be a power of 2"); | 
 |   9680     unsigned TmpReg = MRI.createVirtualRegister(AddrRegClass); | 
 |   9681  | 
 |   9682     // aligned_addr = (addr + (align-1)) & ~(align-1) | 
 |   9683     BuildMI(overflowMBB, DL, TII->get(X86::ADD64ri32), TmpReg) | 
 |   9684       .addReg(OverflowAddrReg) | 
 |   9685       .addImm(Align-1); | 
 |   9686  | 
 |   9687     BuildMI(overflowMBB, DL, TII->get(X86::AND64ri32), OverflowDestReg) | 
 |   9688       .addReg(TmpReg) | 
 |   9689       .addImm(~(uint64_t)(Align-1)); | 
 |   9690   } else { | 
 |   9691     BuildMI(overflowMBB, DL, TII->get(TargetOpcode::COPY), OverflowDestReg) | 
 |   9692       .addReg(OverflowAddrReg); | 
 |   9693   } | 
 |   9694  | 
 |   9695   // Compute the next overflow address after this argument. | 
 |   9696   // (the overflow address should be kept 8-byte aligned) | 
 |   9697   unsigned NextAddrReg = MRI.createVirtualRegister(AddrRegClass); | 
 |   9698   BuildMI(overflowMBB, DL, TII->get(X86::ADD64ri32), NextAddrReg) | 
 |   9699     .addReg(OverflowDestReg) | 
 |   9700     .addImm(ArgSizeA8); | 
 |   9701  | 
 |   9702   // Store the new overflow address. | 
 |   9703   BuildMI(overflowMBB, DL, TII->get(X86::MOV64mr)) | 
 |   9704     .addOperand(Base) | 
 |   9705     .addOperand(Scale) | 
 |   9706     .addOperand(Index) | 
 |   9707     .addDisp(Disp, 8) | 
 |   9708     .addOperand(Segment) | 
 |   9709     .addReg(NextAddrReg) | 
 |   9710     .setMemRefs(MMOBegin, MMOEnd); | 
 |   9711  | 
 |   9712   // If we branched, emit the PHI to the front of endMBB. | 
 |   9713   if (offsetMBB) { | 
 |   9714     BuildMI(*endMBB, endMBB->begin(), DL, | 
 |   9715             TII->get(X86::PHI), DestReg) | 
 |   9716       .addReg(OffsetDestReg).addMBB(offsetMBB) | 
 |   9717       .addReg(OverflowDestReg).addMBB(overflowMBB); | 
 |   9718   } | 
 |   9719  | 
 |   9720   // Erase the pseudo instruction | 
 |   9721   MI->eraseFromParent(); | 
 |   9722  | 
 |   9723   return endMBB; | 
 |   9724 } | 
 |   9725  | 
 |   9726 MachineBasicBlock * | 
|   9414 X86TargetLowering::EmitVAStartSaveXMMRegsWithCustomInserter( |   9727 X86TargetLowering::EmitVAStartSaveXMMRegsWithCustomInserter( | 
|   9415                                                  MachineInstr *MI, |   9728                                                  MachineInstr *MI, | 
|   9416                                                  MachineBasicBlock *MBB) const { |   9729                                                  MachineBasicBlock *MBB) const { | 
|   9417   // Emit code to save XMM registers to the stack. The ABI says that the |   9730   // Emit code to save XMM registers to the stack. The ABI says that the | 
|   9418   // number of registers to save is given in %al, so it's theoretically |   9731   // number of registers to save is given in %al, so it's theoretically | 
|   9419   // possible to do an indirect jump trick to avoid saving all of them, |   9732   // possible to do an indirect jump trick to avoid saving all of them, | 
|   9420   // however this code takes a simpler approach and just executes all |   9733   // however this code takes a simpler approach and just executes all | 
|   9421   // of the stores if %al is non-zero. It's less code, and it's probably |   9734   // of the stores if %al is non-zero. It's less code, and it's probably | 
|   9422   // easier on the hardware branch predictor, and stores aren't all that |   9735   // easier on the hardware branch predictor, and stores aren't all that | 
|   9423   // expensive anyway. |   9736   // expensive anyway. | 
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   9908                                                X86::SUB32rr, X86::SBB32rr, |  10221                                                X86::SUB32rr, X86::SBB32rr, | 
|   9909                                                X86::SUB32ri, X86::SBB32ri, |  10222                                                X86::SUB32ri, X86::SBB32ri, | 
|   9910                                                false); |  10223                                                false); | 
|   9911   case X86::ATOMSWAP6432: |  10224   case X86::ATOMSWAP6432: | 
|   9912     return EmitAtomicBit6432WithCustomInserter(MI, BB, |  10225     return EmitAtomicBit6432WithCustomInserter(MI, BB, | 
|   9913                                                X86::MOV32rr, X86::MOV32rr, |  10226                                                X86::MOV32rr, X86::MOV32rr, | 
|   9914                                                X86::MOV32ri, X86::MOV32ri, |  10227                                                X86::MOV32ri, X86::MOV32ri, | 
|   9915                                                false); |  10228                                                false); | 
|   9916   case X86::VASTART_SAVE_XMM_REGS: |  10229   case X86::VASTART_SAVE_XMM_REGS: | 
|   9917     return EmitVAStartSaveXMMRegsWithCustomInserter(MI, BB); |  10230     return EmitVAStartSaveXMMRegsWithCustomInserter(MI, BB); | 
 |  10231  | 
 |  10232   case X86::VAARG_64: | 
 |  10233     return EmitVAARG64WithCustomInserter(MI, BB); | 
|   9918   } |  10234   } | 
|   9919 } |  10235 } | 
|   9920  |  10236  | 
|   9921 //===----------------------------------------------------------------------===// |  10237 //===----------------------------------------------------------------------===// | 
|   9922 //                           X86 Optimization Hooks |  10238 //                           X86 Optimization Hooks | 
|   9923 //===----------------------------------------------------------------------===// |  10239 //===----------------------------------------------------------------------===// | 
|   9924  |  10240  | 
|   9925 void X86TargetLowering::computeMaskedBitsForTargetNode(const SDValue Op, |  10241 void X86TargetLowering::computeMaskedBitsForTargetNode(const SDValue Op, | 
|   9926                                                        const APInt &Mask, |  10242                                                        const APInt &Mask, | 
|   9927                                                        APInt &KnownZero, |  10243                                                        APInt &KnownZero, | 
| (...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  11611     if (VT == MVT::f32) |  11927     if (VT == MVT::f32) | 
|  11612       Res.second = X86::FR32RegisterClass; |  11928       Res.second = X86::FR32RegisterClass; | 
|  11613     else if (VT == MVT::f64) |  11929     else if (VT == MVT::f64) | 
|  11614       Res.second = X86::FR64RegisterClass; |  11930       Res.second = X86::FR64RegisterClass; | 
|  11615     else if (X86::VR128RegisterClass->hasType(VT)) |  11931     else if (X86::VR128RegisterClass->hasType(VT)) | 
|  11616       Res.second = X86::VR128RegisterClass; |  11932       Res.second = X86::VR128RegisterClass; | 
|  11617   } |  11933   } | 
|  11618  |  11934  | 
|  11619   return Res; |  11935   return Res; | 
|  11620 } |  11936 } | 
| OLD | NEW |