852a36b0c121232b54d11b1bdae1bbccab5827f1
[oota-llvm.git] / lib / Target / ARM / ARMISelLowering.h
1 //===-- ARMISelLowering.h - ARM DAG Lowering Interface ----------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the interfaces that ARM uses to lower LLVM code into a
11 // selection DAG.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_LIB_TARGET_ARM_ARMISELLOWERING_H
16 #define LLVM_LIB_TARGET_ARM_ARMISELLOWERING_H
17
18 #include "MCTargetDesc/ARMBaseInfo.h"
19 #include "llvm/CodeGen/CallingConvLower.h"
20 #include "llvm/CodeGen/SelectionDAG.h"
21 #include "llvm/Target/TargetLowering.h"
22 #include <vector>
23
24 namespace llvm {
25   class ARMConstantPoolValue;
26   class ARMSubtarget;
27
28   namespace ARMISD {
29     // ARM Specific DAG Nodes
30     enum NodeType : unsigned {
31       // Start the numbering where the builtin ops and target ops leave off.
32       FIRST_NUMBER = ISD::BUILTIN_OP_END,
33
34       Wrapper,      // Wrapper - A wrapper node for TargetConstantPool,
35                     // TargetExternalSymbol, and TargetGlobalAddress.
36       WrapperPIC,   // WrapperPIC - A wrapper node for TargetGlobalAddress in
37                     // PIC mode.
38       WrapperJT,    // WrapperJT - A wrapper node for TargetJumpTable
39
40       // Add pseudo op to model memcpy for struct byval.
41       COPY_STRUCT_BYVAL,
42
43       CALL,         // Function call.
44       CALL_PRED,    // Function call that's predicable.
45       CALL_NOLINK,  // Function call with branch not branch-and-link.
46       tCALL,        // Thumb function call.
47       BRCOND,       // Conditional branch.
48       BR_JT,        // Jumptable branch.
49       BR2_JT,       // Jumptable branch (2 level - jumptable entry is a jump).
50       RET_FLAG,     // Return with a flag operand.
51       INTRET_FLAG,  // Interrupt return with an LR-offset and a flag operand.
52
53       PIC_ADD,      // Add with a PC operand and a PIC label.
54
55       CMP,          // ARM compare instructions.
56       CMN,          // ARM CMN instructions.
57       CMPZ,         // ARM compare that sets only Z flag.
58       CMPFP,        // ARM VFP compare instruction, sets FPSCR.
59       CMPFPw0,      // ARM VFP compare against zero instruction, sets FPSCR.
60       FMSTAT,       // ARM fmstat instruction.
61
62       CMOV,         // ARM conditional move instructions.
63
64       BCC_i64,
65
66       RBIT,         // ARM bitreverse instruction
67
68       SRL_FLAG,     // V,Flag = srl_flag X -> srl X, 1 + save carry out.
69       SRA_FLAG,     // V,Flag = sra_flag X -> sra X, 1 + save carry out.
70       RRX,          // V = RRX X, Flag     -> srl X, 1 + shift in carry flag.
71
72       ADDC,         // Add with carry
73       ADDE,         // Add using carry
74       SUBC,         // Sub with carry
75       SUBE,         // Sub using carry
76
77       VMOVRRD,      // double to two gprs.
78       VMOVDRR,      // Two gprs to double.
79
80       EH_SJLJ_SETJMP,         // SjLj exception handling setjmp.
81       EH_SJLJ_LONGJMP,        // SjLj exception handling longjmp.
82       EH_SJLJ_SETUP_DISPATCH, // SjLj exception handling setup_dispatch.
83
84       TC_RETURN,    // Tail call return pseudo.
85
86       THREAD_POINTER,
87
88       DYN_ALLOC,    // Dynamic allocation on the stack.
89
90       MEMBARRIER_MCR, // Memory barrier (MCR)
91
92       PRELOAD,      // Preload
93
94       WIN__CHKSTK,  // Windows' __chkstk call to do stack probing.
95       WIN__DBZCHK,  // Windows' divide by zero check
96
97       VCEQ,         // Vector compare equal.
98       VCEQZ,        // Vector compare equal to zero.
99       VCGE,         // Vector compare greater than or equal.
100       VCGEZ,        // Vector compare greater than or equal to zero.
101       VCLEZ,        // Vector compare less than or equal to zero.
102       VCGEU,        // Vector compare unsigned greater than or equal.
103       VCGT,         // Vector compare greater than.
104       VCGTZ,        // Vector compare greater than zero.
105       VCLTZ,        // Vector compare less than zero.
106       VCGTU,        // Vector compare unsigned greater than.
107       VTST,         // Vector test bits.
108
109       // Vector shift by immediate:
110       VSHL,         // ...left
111       VSHRs,        // ...right (signed)
112       VSHRu,        // ...right (unsigned)
113
114       // Vector rounding shift by immediate:
115       VRSHRs,       // ...right (signed)
116       VRSHRu,       // ...right (unsigned)
117       VRSHRN,       // ...right narrow
118
119       // Vector saturating shift by immediate:
120       VQSHLs,       // ...left (signed)
121       VQSHLu,       // ...left (unsigned)
122       VQSHLsu,      // ...left (signed to unsigned)
123       VQSHRNs,      // ...right narrow (signed)
124       VQSHRNu,      // ...right narrow (unsigned)
125       VQSHRNsu,     // ...right narrow (signed to unsigned)
126
127       // Vector saturating rounding shift by immediate:
128       VQRSHRNs,     // ...right narrow (signed)
129       VQRSHRNu,     // ...right narrow (unsigned)
130       VQRSHRNsu,    // ...right narrow (signed to unsigned)
131
132       // Vector shift and insert:
133       VSLI,         // ...left
134       VSRI,         // ...right
135
136       // Vector get lane (VMOV scalar to ARM core register)
137       // (These are used for 8- and 16-bit element types only.)
138       VGETLANEu,    // zero-extend vector extract element
139       VGETLANEs,    // sign-extend vector extract element
140
141       // Vector move immediate and move negated immediate:
142       VMOVIMM,
143       VMVNIMM,
144
145       // Vector move f32 immediate:
146       VMOVFPIMM,
147
148       // Vector duplicate:
149       VDUP,
150       VDUPLANE,
151
152       // Vector shuffles:
153       VEXT,         // extract
154       VREV64,       // reverse elements within 64-bit doublewords
155       VREV32,       // reverse elements within 32-bit words
156       VREV16,       // reverse elements within 16-bit halfwords
157       VZIP,         // zip (interleave)
158       VUZP,         // unzip (deinterleave)
159       VTRN,         // transpose
160       VTBL1,        // 1-register shuffle with mask
161       VTBL2,        // 2-register shuffle with mask
162
163       // Vector multiply long:
164       VMULLs,       // ...signed
165       VMULLu,       // ...unsigned
166
167       UMLAL,        // 64bit Unsigned Accumulate Multiply
168       SMLAL,        // 64bit Signed Accumulate Multiply
169
170       // Operands of the standard BUILD_VECTOR node are not legalized, which
171       // is fine if BUILD_VECTORs are always lowered to shuffles or other
172       // operations, but for ARM some BUILD_VECTORs are legal as-is and their
173       // operands need to be legalized.  Define an ARM-specific version of
174       // BUILD_VECTOR for this purpose.
175       BUILD_VECTOR,
176
177       // Bit-field insert
178       BFI,
179
180       // Vector OR with immediate
181       VORRIMM,
182       // Vector AND with NOT of immediate
183       VBICIMM,
184
185       // Vector bitwise select
186       VBSL,
187
188       // Pseudo-instruction representing a memory copy using ldm/stm
189       // instructions.
190       MEMCPY,
191
192       // Vector load N-element structure to all lanes:
193       VLD2DUP = ISD::FIRST_TARGET_MEMORY_OPCODE,
194       VLD3DUP,
195       VLD4DUP,
196
197       // NEON loads with post-increment base updates:
198       VLD1_UPD,
199       VLD2_UPD,
200       VLD3_UPD,
201       VLD4_UPD,
202       VLD2LN_UPD,
203       VLD3LN_UPD,
204       VLD4LN_UPD,
205       VLD2DUP_UPD,
206       VLD3DUP_UPD,
207       VLD4DUP_UPD,
208
209       // NEON stores with post-increment base updates:
210       VST1_UPD,
211       VST2_UPD,
212       VST3_UPD,
213       VST4_UPD,
214       VST2LN_UPD,
215       VST3LN_UPD,
216       VST4LN_UPD
217     };
218   }
219
220   /// Define some predicates that are used for node matching.
221   namespace ARM {
222     bool isBitFieldInvertedMask(unsigned v);
223   }
224
225   //===--------------------------------------------------------------------===//
226   //  ARMTargetLowering - ARM Implementation of the TargetLowering interface
227
228   class ARMTargetLowering : public TargetLowering {
229   public:
230     explicit ARMTargetLowering(const TargetMachine &TM,
231                                const ARMSubtarget &STI);
232
233     unsigned getJumpTableEncoding() const override;
234     bool useSoftFloat() const override;
235
236     SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
237
238     /// ReplaceNodeResults - Replace the results of node with an illegal result
239     /// type with new values built out of custom code.
240     ///
241     void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
242                             SelectionDAG &DAG) const override;
243
244     const char *getTargetNodeName(unsigned Opcode) const override;
245
246     bool isSelectSupported(SelectSupportKind Kind) const override {
247       // ARM does not support scalar condition selects on vectors.
248       return (Kind != ScalarCondVectorVal);
249     }
250
251     /// getSetCCResultType - Return the value type to use for ISD::SETCC.
252     EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
253                            EVT VT) const override;
254
255     MachineBasicBlock *
256       EmitInstrWithCustomInserter(MachineInstr *MI,
257                                   MachineBasicBlock *MBB) const override;
258
259     void AdjustInstrPostInstrSelection(MachineInstr *MI,
260                                        SDNode *Node) const override;
261
262     SDValue PerformCMOVCombine(SDNode *N, SelectionDAG &DAG) const;
263     SDValue PerformCMOVToBFICombine(SDNode *N, SelectionDAG &DAG) const;
264     SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
265
266     bool isDesirableToTransformToIntegerOp(unsigned Opc, EVT VT) const override;
267
268     /// allowsMisalignedMemoryAccesses - Returns true if the target allows
269     /// unaligned memory accesses of the specified type. Returns whether it
270     /// is "fast" by reference in the second argument.
271     bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace,
272                                         unsigned Align,
273                                         bool *Fast) const override;
274
275     EVT getOptimalMemOpType(uint64_t Size,
276                             unsigned DstAlign, unsigned SrcAlign,
277                             bool IsMemset, bool ZeroMemset,
278                             bool MemcpyStrSrc,
279                             MachineFunction &MF) const override;
280
281     using TargetLowering::isZExtFree;
282     bool isZExtFree(SDValue Val, EVT VT2) const override;
283
284     bool isVectorLoadExtDesirable(SDValue ExtVal) const override;
285
286     bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override;
287
288
289     /// isLegalAddressingMode - Return true if the addressing mode represented
290     /// by AM is legal for this target, for a load/store of the specified type.
291     bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
292                                Type *Ty, unsigned AS) const override;
293     bool isLegalT2ScaledAddressingMode(const AddrMode &AM, EVT VT) const;
294
295     /// isLegalICmpImmediate - Return true if the specified immediate is legal
296     /// icmp immediate, that is the target has icmp instructions which can
297     /// compare a register against the immediate without having to materialize
298     /// the immediate into a register.
299     bool isLegalICmpImmediate(int64_t Imm) const override;
300
301     /// isLegalAddImmediate - Return true if the specified immediate is legal
302     /// add immediate, that is the target has add instructions which can
303     /// add a register and the immediate without having to materialize
304     /// the immediate into a register.
305     bool isLegalAddImmediate(int64_t Imm) const override;
306
307     /// getPreIndexedAddressParts - returns true by value, base pointer and
308     /// offset pointer and addressing mode by reference if the node's address
309     /// can be legally represented as pre-indexed load / store address.
310     bool getPreIndexedAddressParts(SDNode *N, SDValue &Base, SDValue &Offset,
311                                    ISD::MemIndexedMode &AM,
312                                    SelectionDAG &DAG) const override;
313
314     /// getPostIndexedAddressParts - returns true by value, base pointer and
315     /// offset pointer and addressing mode by reference if this node can be
316     /// combined with a load / store to form a post-indexed load / store.
317     bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, SDValue &Base,
318                                     SDValue &Offset, ISD::MemIndexedMode &AM,
319                                     SelectionDAG &DAG) const override;
320
321     void computeKnownBitsForTargetNode(const SDValue Op, APInt &KnownZero,
322                                        APInt &KnownOne,
323                                        const SelectionDAG &DAG,
324                                        unsigned Depth) const override;
325
326
327     bool ExpandInlineAsm(CallInst *CI) const override;
328
329     ConstraintType getConstraintType(StringRef Constraint) const override;
330
331     /// Examine constraint string and operand type and determine a weight value.
332     /// The operand object must already have been set up with the operand type.
333     ConstraintWeight getSingleConstraintMatchWeight(
334       AsmOperandInfo &info, const char *constraint) const override;
335
336     std::pair<unsigned, const TargetRegisterClass *>
337     getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
338                                  StringRef Constraint, MVT VT) const override;
339
340     /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
341     /// vector.  If it is invalid, don't add anything to Ops. If hasMemory is
342     /// true it means one of the asm constraint of the inline asm instruction
343     /// being processed is 'm'.
344     void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
345                                       std::vector<SDValue> &Ops,
346                                       SelectionDAG &DAG) const override;
347
348     unsigned
349     getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
350       if (ConstraintCode == "Q")
351         return InlineAsm::Constraint_Q;
352       else if (ConstraintCode == "o")
353         return InlineAsm::Constraint_o;
354       else if (ConstraintCode.size() == 2) {
355         if (ConstraintCode[0] == 'U') {
356           switch(ConstraintCode[1]) {
357           default:
358             break;
359           case 'm':
360             return InlineAsm::Constraint_Um;
361           case 'n':
362             return InlineAsm::Constraint_Un;
363           case 'q':
364             return InlineAsm::Constraint_Uq;
365           case 's':
366             return InlineAsm::Constraint_Us;
367           case 't':
368             return InlineAsm::Constraint_Ut;
369           case 'v':
370             return InlineAsm::Constraint_Uv;
371           case 'y':
372             return InlineAsm::Constraint_Uy;
373           }
374         }
375       }
376       return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
377     }
378
379     const ARMSubtarget* getSubtarget() const {
380       return Subtarget;
381     }
382
383     /// getRegClassFor - Return the register class that should be used for the
384     /// specified value type.
385     const TargetRegisterClass *getRegClassFor(MVT VT) const override;
386
387     /// Returns true if a cast between SrcAS and DestAS is a noop.
388     bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
389       // Addrspacecasts are always noops.
390       return true;
391     }
392
393     bool shouldAlignPointerArgs(CallInst *CI, unsigned &MinSize,
394                                 unsigned &PrefAlign) const override;
395
396     /// createFastISel - This method returns a target specific FastISel object,
397     /// or null if the target does not support "fast" ISel.
398     FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
399                              const TargetLibraryInfo *libInfo) const override;
400
401     Sched::Preference getSchedulingPreference(SDNode *N) const override;
402
403     bool
404     isShuffleMaskLegal(const SmallVectorImpl<int> &M, EVT VT) const override;
405     bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
406
407     /// isFPImmLegal - Returns true if the target can instruction select the
408     /// specified FP immediate natively. If false, the legalizer will
409     /// materialize the FP immediate as a load from a constant pool.
410     bool isFPImmLegal(const APFloat &Imm, EVT VT) const override;
411
412     bool getTgtMemIntrinsic(IntrinsicInfo &Info,
413                             const CallInst &I,
414                             unsigned Intrinsic) const override;
415
416     /// \brief Returns true if it is beneficial to convert a load of a constant
417     /// to just the constant itself.
418     bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
419                                            Type *Ty) const override;
420
421     /// \brief Returns true if an argument of type Ty needs to be passed in a
422     /// contiguous block of registers in calling convention CallConv.
423     bool functionArgumentNeedsConsecutiveRegisters(
424         Type *Ty, CallingConv::ID CallConv, bool isVarArg) const override;
425
426     Instruction *makeDMB(IRBuilder<> &Builder, ARM_MB::MemBOpt Domain) const;
427     Value *emitLoadLinked(IRBuilder<> &Builder, Value *Addr,
428                           AtomicOrdering Ord) const override;
429     Value *emitStoreConditional(IRBuilder<> &Builder, Value *Val,
430                                 Value *Addr, AtomicOrdering Ord) const override;
431
432     void emitAtomicCmpXchgNoStoreLLBalance(IRBuilder<> &Builder) const override;
433
434     Instruction* emitLeadingFence(IRBuilder<> &Builder, AtomicOrdering Ord,
435                           bool IsStore, bool IsLoad) const override;
436     Instruction* emitTrailingFence(IRBuilder<> &Builder, AtomicOrdering Ord,
437                            bool IsStore, bool IsLoad) const override;
438
439     unsigned getMaxSupportedInterleaveFactor() const override { return 4; }
440
441     bool lowerInterleavedLoad(LoadInst *LI,
442                               ArrayRef<ShuffleVectorInst *> Shuffles,
443                               ArrayRef<unsigned> Indices,
444                               unsigned Factor) const override;
445     bool lowerInterleavedStore(StoreInst *SI, ShuffleVectorInst *SVI,
446                                unsigned Factor) const override;
447
448     TargetLoweringBase::AtomicExpansionKind
449     shouldExpandAtomicLoadInIR(LoadInst *LI) const override;
450     bool shouldExpandAtomicStoreInIR(StoreInst *SI) const override;
451     TargetLoweringBase::AtomicExpansionKind
452     shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override;
453     bool shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
454
455     bool useLoadStackGuardNode() const override;
456
457     bool canCombineStoreAndExtract(Type *VectorTy, Value *Idx,
458                                    unsigned &Cost) const override;
459
460   protected:
461     std::pair<const TargetRegisterClass *, uint8_t>
462     findRepresentativeClass(const TargetRegisterInfo *TRI,
463                             MVT VT) const override;
464
465   private:
466     /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
467     /// make the right decision when generating code for different targets.
468     const ARMSubtarget *Subtarget;
469
470     const TargetRegisterInfo *RegInfo;
471
472     const InstrItineraryData *Itins;
473
474     /// ARMPCLabelIndex - Keep track of the number of ARM PC labels created.
475     ///
476     unsigned ARMPCLabelIndex;
477
478     void addTypeForNEON(MVT VT, MVT PromotedLdStVT, MVT PromotedBitwiseVT);
479     void addDRTypeForNEON(MVT VT);
480     void addQRTypeForNEON(MVT VT);
481     std::pair<SDValue, SDValue> getARMXALUOOp(SDValue Op, SelectionDAG &DAG, SDValue &ARMcc) const;
482
483     typedef SmallVector<std::pair<unsigned, SDValue>, 8> RegsToPassVector;
484     void PassF64ArgInRegs(SDLoc dl, SelectionDAG &DAG,
485                           SDValue Chain, SDValue &Arg,
486                           RegsToPassVector &RegsToPass,
487                           CCValAssign &VA, CCValAssign &NextVA,
488                           SDValue &StackPtr,
489                           SmallVectorImpl<SDValue> &MemOpChains,
490                           ISD::ArgFlagsTy Flags) const;
491     SDValue GetF64FormalArgument(CCValAssign &VA, CCValAssign &NextVA,
492                                  SDValue &Root, SelectionDAG &DAG,
493                                  SDLoc dl) const;
494
495     CallingConv::ID getEffectiveCallingConv(CallingConv::ID CC,
496                                             bool isVarArg) const;
497     CCAssignFn *CCAssignFnForNode(CallingConv::ID CC, bool Return,
498                                   bool isVarArg) const;
499     SDValue LowerMemOpCallTo(SDValue Chain, SDValue StackPtr, SDValue Arg,
500                              SDLoc dl, SelectionDAG &DAG,
501                              const CCValAssign &VA,
502                              ISD::ArgFlagsTy Flags) const;
503     SDValue LowerEH_SJLJ_SETJMP(SDValue Op, SelectionDAG &DAG) const;
504     SDValue LowerEH_SJLJ_LONGJMP(SDValue Op, SelectionDAG &DAG) const;
505     SDValue LowerEH_SJLJ_SETUP_DISPATCH(SDValue Op, SelectionDAG &DAG) const;
506     SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG,
507                                     const ARMSubtarget *Subtarget) const;
508     SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
509     SDValue LowerGlobalAddressDarwin(SDValue Op, SelectionDAG &DAG) const;
510     SDValue LowerGlobalAddressELF(SDValue Op, SelectionDAG &DAG) const;
511     SDValue LowerGlobalAddressWindows(SDValue Op, SelectionDAG &DAG) const;
512     SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
513     SDValue LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
514                                             SelectionDAG &DAG) const;
515     SDValue LowerToTLSExecModels(GlobalAddressSDNode *GA,
516                                  SelectionDAG &DAG,
517                                  TLSModel::Model model) const;
518     SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
519     SDValue LowerXALUO(SDValue Op, SelectionDAG &DAG) const;
520     SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
521     SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
522     SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
523     SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) const;
524     SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
525     SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
526     SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG) const;
527     SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
528     SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const;
529     SDValue LowerConstantFP(SDValue Op, SelectionDAG &DAG,
530                             const ARMSubtarget *ST) const;
531     SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG,
532                               const ARMSubtarget *ST) const;
533     SDValue LowerFSINCOS(SDValue Op, SelectionDAG &DAG) const;
534     SDValue LowerDivRem(SDValue Op, SelectionDAG &DAG) const;
535     SDValue LowerDIV_Windows(SDValue Op, SelectionDAG &DAG, bool Signed) const;
536     void ExpandDIV_Windows(SDValue Op, SelectionDAG &DAG, bool Signed,
537                            SmallVectorImpl<SDValue> &Results) const;
538     SDValue LowerWindowsDIVLibCall(SDValue Op, SelectionDAG &DAG, bool Signed,
539                                    SDValue &Chain) const;
540     SDValue LowerREM(SDNode *N, SelectionDAG &DAG) const;
541     SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
542     SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
543     SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const;
544     SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG) const;
545     SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
546
547     unsigned getRegisterByName(const char* RegName, EVT VT,
548                                SelectionDAG &DAG) const override;
549
550     /// isFMAFasterThanFMulAndFAdd - Return true if an FMA operation is faster
551     /// than a pair of fmul and fadd instructions. fmuladd intrinsics will be
552     /// expanded to FMAs when this method returns true, otherwise fmuladd is
553     /// expanded to fmul + fadd.
554     ///
555     /// ARM supports both fused and unfused multiply-add operations; we already
556     /// lower a pair of fmul and fadd to the latter so it's not clear that there
557     /// would be a gain or that the gain would be worthwhile enough to risk
558     /// correctness bugs.
559     bool isFMAFasterThanFMulAndFAdd(EVT VT) const override { return false; }
560
561     SDValue ReconstructShuffle(SDValue Op, SelectionDAG &DAG) const;
562
563     SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
564                             CallingConv::ID CallConv, bool isVarArg,
565                             const SmallVectorImpl<ISD::InputArg> &Ins,
566                             SDLoc dl, SelectionDAG &DAG,
567                             SmallVectorImpl<SDValue> &InVals,
568                             bool isThisReturn, SDValue ThisVal) const;
569
570     SDValue
571       LowerFormalArguments(SDValue Chain,
572                            CallingConv::ID CallConv, bool isVarArg,
573                            const SmallVectorImpl<ISD::InputArg> &Ins,
574                            SDLoc dl, SelectionDAG &DAG,
575                            SmallVectorImpl<SDValue> &InVals) const override;
576
577     int StoreByValRegs(CCState &CCInfo, SelectionDAG &DAG,
578                        SDLoc dl, SDValue &Chain,
579                        const Value *OrigArg,
580                        unsigned InRegsParamRecordIdx,
581                        int ArgOffset,
582                        unsigned ArgSize) const;
583
584     void VarArgStyleRegisters(CCState &CCInfo, SelectionDAG &DAG,
585                               SDLoc dl, SDValue &Chain,
586                               unsigned ArgOffset,
587                               unsigned TotalArgRegsSaveSize,
588                               bool ForceMutable = false) const;
589
590     SDValue
591       LowerCall(TargetLowering::CallLoweringInfo &CLI,
592                 SmallVectorImpl<SDValue> &InVals) const override;
593
594     /// HandleByVal - Target-specific cleanup for ByVal support.
595     void HandleByVal(CCState *, unsigned &, unsigned) const override;
596
597     /// IsEligibleForTailCallOptimization - Check whether the call is eligible
598     /// for tail call optimization. Targets which want to do tail call
599     /// optimization should implement this function.
600     bool IsEligibleForTailCallOptimization(SDValue Callee,
601                                            CallingConv::ID CalleeCC,
602                                            bool isVarArg,
603                                            bool isCalleeStructRet,
604                                            bool isCallerStructRet,
605                                     const SmallVectorImpl<ISD::OutputArg> &Outs,
606                                     const SmallVectorImpl<SDValue> &OutVals,
607                                     const SmallVectorImpl<ISD::InputArg> &Ins,
608                                            SelectionDAG& DAG) const;
609
610     bool CanLowerReturn(CallingConv::ID CallConv,
611                         MachineFunction &MF, bool isVarArg,
612                         const SmallVectorImpl<ISD::OutputArg> &Outs,
613                         LLVMContext &Context) const override;
614
615     SDValue
616       LowerReturn(SDValue Chain,
617                   CallingConv::ID CallConv, bool isVarArg,
618                   const SmallVectorImpl<ISD::OutputArg> &Outs,
619                   const SmallVectorImpl<SDValue> &OutVals,
620                   SDLoc dl, SelectionDAG &DAG) const override;
621
622     bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override;
623
624     bool mayBeEmittedAsTailCall(CallInst *CI) const override;
625
626     SDValue getCMOV(SDLoc dl, EVT VT, SDValue FalseVal, SDValue TrueVal,
627                     SDValue ARMcc, SDValue CCR, SDValue Cmp,
628                     SelectionDAG &DAG) const;
629     SDValue getARMCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC,
630                       SDValue &ARMcc, SelectionDAG &DAG, SDLoc dl) const;
631     SDValue getVFPCmp(SDValue LHS, SDValue RHS,
632                       SelectionDAG &DAG, SDLoc dl) const;
633     SDValue duplicateCmp(SDValue Cmp, SelectionDAG &DAG) const;
634
635     SDValue OptimizeVFPBrcond(SDValue Op, SelectionDAG &DAG) const;
636
637     void SetupEntryBlockForSjLj(MachineInstr *MI,
638                                 MachineBasicBlock *MBB,
639                                 MachineBasicBlock *DispatchBB, int FI) const;
640
641     void EmitSjLjDispatchBlock(MachineInstr *MI, MachineBasicBlock *MBB) const;
642
643     bool RemapAddSubWithFlags(MachineInstr *MI, MachineBasicBlock *BB) const;
644
645     MachineBasicBlock *EmitStructByval(MachineInstr *MI,
646                                        MachineBasicBlock *MBB) const;
647
648     MachineBasicBlock *EmitLowered__chkstk(MachineInstr *MI,
649                                            MachineBasicBlock *MBB) const;
650     MachineBasicBlock *EmitLowered__dbzchk(MachineInstr *MI,
651                                            MachineBasicBlock *MBB) const;
652   };
653
654   enum NEONModImmType {
655     VMOVModImm,
656     VMVNModImm,
657     OtherModImm
658   };
659
660   namespace ARM {
661     FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
662                              const TargetLibraryInfo *libInfo);
663   }
664 }
665
666 #endif  // ARMISELLOWERING_H