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