LoopVectorize: Fix a bug in the scalarization of instructions.
[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 ARMISELLOWERING_H
16 #define ARMISELLOWERING_H
17
18 #include "ARM.h"
19 #include "ARMSubtarget.h"
20 #include "llvm/CodeGen/CallingConvLower.h"
21 #include "llvm/CodeGen/FastISel.h"
22 #include "llvm/CodeGen/SelectionDAG.h"
23 #include "llvm/Target/TargetLowering.h"
24 #include "llvm/Target/TargetRegisterInfo.h"
25 #include "llvm/Target/TargetTransformImpl.h"
26 #include <vector>
27
28 namespace llvm {
29   class ARMConstantPoolValue;
30
31   namespace ARMISD {
32     // ARM Specific DAG Nodes
33     enum NodeType {
34       // Start the numbering where the builtin ops and target ops leave off.
35       FIRST_NUMBER = ISD::BUILTIN_OP_END,
36
37       Wrapper,      // Wrapper - A wrapper node for TargetConstantPool,
38                     // TargetExternalSymbol, and TargetGlobalAddress.
39       WrapperDYN,   // WrapperDYN - A wrapper node for TargetGlobalAddress in
40                     // DYN mode.
41       WrapperPIC,   // WrapperPIC - A wrapper node for TargetGlobalAddress in
42                     // PIC mode.
43       WrapperJT,    // WrapperJT - A wrapper node for TargetJumpTable
44
45       // Add pseudo op to model memcpy for struct byval.
46       COPY_STRUCT_BYVAL,
47
48       CALL,         // Function call.
49       CALL_PRED,    // Function call that's predicable.
50       CALL_NOLINK,  // Function call with branch not branch-and-link.
51       tCALL,        // Thumb function call.
52       BRCOND,       // Conditional branch.
53       BR_JT,        // Jumptable branch.
54       BR2_JT,       // Jumptable branch (2 level - jumptable entry is a jump).
55       RET_FLAG,     // Return with a flag operand.
56
57       PIC_ADD,      // Add with a PC operand and a PIC label.
58
59       CMP,          // ARM compare instructions.
60       CMN,          // ARM CMN instructions.
61       CMPZ,         // ARM compare that sets only Z flag.
62       CMPFP,        // ARM VFP compare instruction, sets FPSCR.
63       CMPFPw0,      // ARM VFP compare against zero instruction, sets FPSCR.
64       FMSTAT,       // ARM fmstat instruction.
65
66       CMOV,         // ARM conditional move instructions.
67
68       BCC_i64,
69
70       RBIT,         // ARM bitreverse instruction
71
72       FTOSI,        // FP to sint within a FP register.
73       FTOUI,        // FP to uint within a FP register.
74       SITOF,        // sint to FP within a FP register.
75       UITOF,        // uint to FP within a FP register.
76
77       SRL_FLAG,     // V,Flag = srl_flag X -> srl X, 1 + save carry out.
78       SRA_FLAG,     // V,Flag = sra_flag X -> sra X, 1 + save carry out.
79       RRX,          // V = RRX X, Flag     -> srl X, 1 + shift in carry flag.
80
81       ADDC,         // Add with carry
82       ADDE,         // Add using carry
83       SUBC,         // Sub with carry
84       SUBE,         // Sub using carry
85
86       VMOVRRD,      // double to two gprs.
87       VMOVDRR,      // Two gprs to double.
88
89       EH_SJLJ_SETJMP,         // SjLj exception handling setjmp.
90       EH_SJLJ_LONGJMP,        // SjLj exception handling longjmp.
91
92       TC_RETURN,    // Tail call return pseudo.
93
94       THREAD_POINTER,
95
96       DYN_ALLOC,    // Dynamic allocation on the stack.
97
98       MEMBARRIER,   // Memory barrier (DMB)
99       MEMBARRIER_MCR, // Memory barrier (MCR)
100
101       PRELOAD,      // Preload
102
103       VCEQ,         // Vector compare equal.
104       VCEQZ,        // Vector compare equal to zero.
105       VCGE,         // Vector compare greater than or equal.
106       VCGEZ,        // Vector compare greater than or equal to zero.
107       VCLEZ,        // Vector compare less than or equal to zero.
108       VCGEU,        // Vector compare unsigned greater than or equal.
109       VCGT,         // Vector compare greater than.
110       VCGTZ,        // Vector compare greater than zero.
111       VCLTZ,        // Vector compare less than zero.
112       VCGTU,        // Vector compare unsigned greater than.
113       VTST,         // Vector test bits.
114
115       // Vector shift by immediate:
116       VSHL,         // ...left
117       VSHRs,        // ...right (signed)
118       VSHRu,        // ...right (unsigned)
119       VSHLLs,       // ...left long (signed)
120       VSHLLu,       // ...left long (unsigned)
121       VSHLLi,       // ...left long (with maximum shift count)
122       VSHRN,        // ...right narrow
123
124       // Vector rounding shift by immediate:
125       VRSHRs,       // ...right (signed)
126       VRSHRu,       // ...right (unsigned)
127       VRSHRN,       // ...right narrow
128
129       // Vector saturating shift by immediate:
130       VQSHLs,       // ...left (signed)
131       VQSHLu,       // ...left (unsigned)
132       VQSHLsu,      // ...left (signed to unsigned)
133       VQSHRNs,      // ...right narrow (signed)
134       VQSHRNu,      // ...right narrow (unsigned)
135       VQSHRNsu,     // ...right narrow (signed to unsigned)
136
137       // Vector saturating rounding shift by immediate:
138       VQRSHRNs,     // ...right narrow (signed)
139       VQRSHRNu,     // ...right narrow (unsigned)
140       VQRSHRNsu,    // ...right narrow (signed to unsigned)
141
142       // Vector shift and insert:
143       VSLI,         // ...left
144       VSRI,         // ...right
145
146       // Vector get lane (VMOV scalar to ARM core register)
147       // (These are used for 8- and 16-bit element types only.)
148       VGETLANEu,    // zero-extend vector extract element
149       VGETLANEs,    // sign-extend vector extract element
150
151       // Vector move immediate and move negated immediate:
152       VMOVIMM,
153       VMVNIMM,
154
155       // Vector move f32 immediate:
156       VMOVFPIMM,
157
158       // Vector duplicate:
159       VDUP,
160       VDUPLANE,
161
162       // Vector shuffles:
163       VEXT,         // extract
164       VREV64,       // reverse elements within 64-bit doublewords
165       VREV32,       // reverse elements within 32-bit words
166       VREV16,       // reverse elements within 16-bit halfwords
167       VZIP,         // zip (interleave)
168       VUZP,         // unzip (deinterleave)
169       VTRN,         // transpose
170       VTBL1,        // 1-register shuffle with mask
171       VTBL2,        // 2-register shuffle with mask
172
173       // Vector multiply long:
174       VMULLs,       // ...signed
175       VMULLu,       // ...unsigned
176
177       // Vector add long:
178       VADDLs,       // ...signed
179       VADDLu,       // ...unsigned
180
181       // Vector subtract long:
182       VSUBLs,       // ...signed
183       VSUBLu,       // ...unsigned
184
185       UMLAL,        // 64bit Unsigned Accumulate Multiply
186       SMLAL,        // 64bit Signed Accumulate Multiply
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       // Floating-point max and min:
196       FMAX,
197       FMIN,
198
199       // Bit-field insert
200       BFI,
201
202       // Vector OR with immediate
203       VORRIMM,
204       // Vector AND with NOT of immediate
205       VBICIMM,
206
207       // Vector bitwise select
208       VBSL,
209
210       // Vector load N-element structure to all lanes:
211       VLD2DUP = ISD::FIRST_TARGET_MEMORY_OPCODE,
212       VLD3DUP,
213       VLD4DUP,
214
215       // NEON loads with post-increment base updates:
216       VLD1_UPD,
217       VLD2_UPD,
218       VLD3_UPD,
219       VLD4_UPD,
220       VLD2LN_UPD,
221       VLD3LN_UPD,
222       VLD4LN_UPD,
223       VLD2DUP_UPD,
224       VLD3DUP_UPD,
225       VLD4DUP_UPD,
226
227       // NEON stores with post-increment base updates:
228       VST1_UPD,
229       VST2_UPD,
230       VST3_UPD,
231       VST4_UPD,
232       VST2LN_UPD,
233       VST3LN_UPD,
234       VST4LN_UPD,
235
236       // 64-bit atomic ops (value split into two registers)
237       ATOMADD64_DAG,
238       ATOMSUB64_DAG,
239       ATOMOR64_DAG,
240       ATOMXOR64_DAG,
241       ATOMAND64_DAG,
242       ATOMNAND64_DAG,
243       ATOMSWAP64_DAG,
244       ATOMCMPXCHG64_DAG,
245       ATOMMIN64_DAG,
246       ATOMUMIN64_DAG,
247       ATOMMAX64_DAG,
248       ATOMUMAX64_DAG
249     };
250   }
251
252   /// Define some predicates that are used for node matching.
253   namespace ARM {
254     bool isBitFieldInvertedMask(unsigned v);
255   }
256
257   //===--------------------------------------------------------------------===//
258   //  ARMTargetLowering - ARM Implementation of the TargetLowering interface
259
260   class ARMTargetLowering : public TargetLowering {
261   public:
262     explicit ARMTargetLowering(TargetMachine &TM);
263
264     virtual unsigned getJumpTableEncoding() const;
265
266     virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
267
268     /// ReplaceNodeResults - Replace the results of node with an illegal result
269     /// type with new values built out of custom code.
270     ///
271     virtual void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
272                                     SelectionDAG &DAG) const;
273
274     virtual const char *getTargetNodeName(unsigned Opcode) const;
275
276     virtual bool isSelectSupported(SelectSupportKind Kind) const {
277       // ARM does not support scalar condition selects on vectors.
278       return (Kind != ScalarCondVectorVal);
279     }
280
281     /// getSetCCResultType - Return the value type to use for ISD::SETCC.
282     virtual EVT getSetCCResultType(EVT VT) const;
283
284     virtual MachineBasicBlock *
285       EmitInstrWithCustomInserter(MachineInstr *MI,
286                                   MachineBasicBlock *MBB) const;
287
288     virtual void
289     AdjustInstrPostInstrSelection(MachineInstr *MI, SDNode *Node) const;
290
291     SDValue PerformCMOVCombine(SDNode *N, SelectionDAG &DAG) const;
292     virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
293
294     bool isDesirableToTransformToIntegerOp(unsigned Opc, EVT VT) const;
295
296     /// allowsUnalignedMemoryAccesses - Returns true if the target allows
297     /// unaligned memory accesses of the specified type. Returns whether it
298     /// is "fast" by reference in the second argument.
299     virtual bool allowsUnalignedMemoryAccesses(EVT VT, bool *Fast) const;
300
301     virtual EVT getOptimalMemOpType(uint64_t Size,
302                                     unsigned DstAlign, unsigned SrcAlign,
303                                     bool IsMemset, bool ZeroMemset,
304                                     bool MemcpyStrSrc,
305                                     MachineFunction &MF) const;
306
307     using TargetLowering::isZExtFree;
308     virtual bool isZExtFree(SDValue Val, EVT VT2) const;
309
310     /// isLegalAddressingMode - Return true if the addressing mode represented
311     /// by AM is legal for this target, for a load/store of the specified type.
312     virtual bool isLegalAddressingMode(const AddrMode &AM, Type *Ty)const;
313     bool isLegalT2ScaledAddressingMode(const AddrMode &AM, EVT VT) const;
314
315     /// isLegalICmpImmediate - Return true if the specified immediate is legal
316     /// icmp immediate, that is the target has icmp instructions which can
317     /// compare a register against the immediate without having to materialize
318     /// the immediate into a register.
319     virtual bool isLegalICmpImmediate(int64_t Imm) const;
320
321     /// isLegalAddImmediate - Return true if the specified immediate is legal
322     /// add immediate, that is the target has add instructions which can
323     /// add a register and the immediate without having to materialize
324     /// the immediate into a register.
325     virtual bool isLegalAddImmediate(int64_t Imm) const;
326
327     /// getPreIndexedAddressParts - returns true by value, base pointer and
328     /// offset pointer and addressing mode by reference if the node's address
329     /// can be legally represented as pre-indexed load / store address.
330     virtual bool getPreIndexedAddressParts(SDNode *N, SDValue &Base,
331                                            SDValue &Offset,
332                                            ISD::MemIndexedMode &AM,
333                                            SelectionDAG &DAG) const;
334
335     /// getPostIndexedAddressParts - returns true by value, base pointer and
336     /// offset pointer and addressing mode by reference if this node can be
337     /// combined with a load / store to form a post-indexed load / store.
338     virtual bool getPostIndexedAddressParts(SDNode *N, SDNode *Op,
339                                             SDValue &Base, SDValue &Offset,
340                                             ISD::MemIndexedMode &AM,
341                                             SelectionDAG &DAG) const;
342
343     virtual void computeMaskedBitsForTargetNode(const SDValue Op,
344                                                 APInt &KnownZero,
345                                                 APInt &KnownOne,
346                                                 const SelectionDAG &DAG,
347                                                 unsigned Depth) const;
348
349
350     virtual bool ExpandInlineAsm(CallInst *CI) const;
351
352     ConstraintType getConstraintType(const std::string &Constraint) const;
353
354     /// Examine constraint string and operand type and determine a weight value.
355     /// The operand object must already have been set up with the operand type.
356     ConstraintWeight getSingleConstraintMatchWeight(
357       AsmOperandInfo &info, const char *constraint) const;
358
359     std::pair<unsigned, const TargetRegisterClass*>
360       getRegForInlineAsmConstraint(const std::string &Constraint,
361                                    EVT VT) const;
362
363     /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
364     /// vector.  If it is invalid, don't add anything to Ops. If hasMemory is
365     /// true it means one of the asm constraint of the inline asm instruction
366     /// being processed is 'm'.
367     virtual void LowerAsmOperandForConstraint(SDValue Op,
368                                               std::string &Constraint,
369                                               std::vector<SDValue> &Ops,
370                                               SelectionDAG &DAG) const;
371
372     const ARMSubtarget* getSubtarget() const {
373       return Subtarget;
374     }
375
376     /// getRegClassFor - Return the register class that should be used for the
377     /// specified value type.
378     virtual const TargetRegisterClass *getRegClassFor(MVT VT) const;
379
380     /// getMaximalGlobalOffset - Returns the maximal possible offset which can
381     /// be used for loads / stores from the global.
382     virtual unsigned getMaximalGlobalOffset() const;
383
384     /// createFastISel - This method returns a target specific FastISel object,
385     /// or null if the target does not support "fast" ISel.
386     virtual FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
387                                      const TargetLibraryInfo *libInfo) const;
388
389     Sched::Preference getSchedulingPreference(SDNode *N) const;
390
391     bool isShuffleMaskLegal(const SmallVectorImpl<int> &M, EVT VT) const;
392     bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
393
394     /// isFPImmLegal - Returns true if the target can instruction select the
395     /// specified FP immediate natively. If false, the legalizer will
396     /// materialize the FP immediate as a load from a constant pool.
397     virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
398
399     virtual bool getTgtMemIntrinsic(IntrinsicInfo &Info,
400                                     const CallInst &I,
401                                     unsigned Intrinsic) const;
402   protected:
403     std::pair<const TargetRegisterClass*, uint8_t>
404     findRepresentativeClass(MVT VT) const;
405
406   private:
407     /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
408     /// make the right decision when generating code for different targets.
409     const ARMSubtarget *Subtarget;
410
411     const TargetRegisterInfo *RegInfo;
412
413     const InstrItineraryData *Itins;
414
415     /// ARMPCLabelIndex - Keep track of the number of ARM PC labels created.
416     ///
417     unsigned ARMPCLabelIndex;
418
419     void addTypeForNEON(MVT VT, MVT PromotedLdStVT, MVT PromotedBitwiseVT);
420     void addDRTypeForNEON(MVT VT);
421     void addQRTypeForNEON(MVT VT);
422
423     typedef SmallVector<std::pair<unsigned, SDValue>, 8> RegsToPassVector;
424     void PassF64ArgInRegs(DebugLoc dl, SelectionDAG &DAG,
425                           SDValue Chain, SDValue &Arg,
426                           RegsToPassVector &RegsToPass,
427                           CCValAssign &VA, CCValAssign &NextVA,
428                           SDValue &StackPtr,
429                           SmallVector<SDValue, 8> &MemOpChains,
430                           ISD::ArgFlagsTy Flags) const;
431     SDValue GetF64FormalArgument(CCValAssign &VA, CCValAssign &NextVA,
432                                  SDValue &Root, SelectionDAG &DAG,
433                                  DebugLoc dl) const;
434
435     CCAssignFn *CCAssignFnForNode(CallingConv::ID CC, bool Return,
436                                   bool isVarArg) const;
437     SDValue LowerMemOpCallTo(SDValue Chain, SDValue StackPtr, SDValue Arg,
438                              DebugLoc dl, SelectionDAG &DAG,
439                              const CCValAssign &VA,
440                              ISD::ArgFlagsTy Flags) const;
441     SDValue LowerEH_SJLJ_SETJMP(SDValue Op, SelectionDAG &DAG) const;
442     SDValue LowerEH_SJLJ_LONGJMP(SDValue Op, SelectionDAG &DAG) const;
443     SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG,
444                                     const ARMSubtarget *Subtarget) const;
445     SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
446     SDValue LowerGlobalAddressDarwin(SDValue Op, SelectionDAG &DAG) const;
447     SDValue LowerGlobalAddressELF(SDValue Op, SelectionDAG &DAG) const;
448     SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
449     SDValue LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
450                                             SelectionDAG &DAG) const;
451     SDValue LowerToTLSExecModels(GlobalAddressSDNode *GA,
452                                  SelectionDAG &DAG,
453                                  TLSModel::Model model) const;
454     SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const;
455     SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
456     SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
457     SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
458     SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
459     SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) const;
460     SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
461     SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
462     SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG) const;
463     SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
464     SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const;
465     SDValue LowerConstantFP(SDValue Op, SelectionDAG &DAG,
466                             const ARMSubtarget *ST) const;
467     SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG,
468                               const ARMSubtarget *ST) const;
469
470     SDValue ReconstructShuffle(SDValue Op, SelectionDAG &DAG) const;
471
472     SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
473                             CallingConv::ID CallConv, bool isVarArg,
474                             const SmallVectorImpl<ISD::InputArg> &Ins,
475                             DebugLoc dl, SelectionDAG &DAG,
476                             SmallVectorImpl<SDValue> &InVals) const;
477
478     virtual SDValue
479       LowerFormalArguments(SDValue Chain,
480                            CallingConv::ID CallConv, bool isVarArg,
481                            const SmallVectorImpl<ISD::InputArg> &Ins,
482                            DebugLoc dl, SelectionDAG &DAG,
483                            SmallVectorImpl<SDValue> &InVals) const;
484
485     void VarArgStyleRegisters(CCState &CCInfo, SelectionDAG &DAG,
486                               DebugLoc dl, SDValue &Chain,
487                               const Value *OrigArg,
488                               unsigned OffsetFromOrigArg,
489                               unsigned ArgOffset,
490                               bool ForceMutable = false)
491       const;
492
493     void computeRegArea(CCState &CCInfo, MachineFunction &MF,
494                         unsigned &VARegSize, unsigned &VARegSaveSize) const;
495
496     virtual SDValue
497       LowerCall(TargetLowering::CallLoweringInfo &CLI,
498                 SmallVectorImpl<SDValue> &InVals) const;
499
500     /// HandleByVal - Target-specific cleanup for ByVal support.
501     virtual void HandleByVal(CCState *, unsigned &, unsigned) const;
502
503     /// IsEligibleForTailCallOptimization - Check whether the call is eligible
504     /// for tail call optimization. Targets which want to do tail call
505     /// optimization should implement this function.
506     bool IsEligibleForTailCallOptimization(SDValue Callee,
507                                            CallingConv::ID CalleeCC,
508                                            bool isVarArg,
509                                            bool isCalleeStructRet,
510                                            bool isCallerStructRet,
511                                     const SmallVectorImpl<ISD::OutputArg> &Outs,
512                                     const SmallVectorImpl<SDValue> &OutVals,
513                                     const SmallVectorImpl<ISD::InputArg> &Ins,
514                                            SelectionDAG& DAG) const;
515
516     virtual bool CanLowerReturn(CallingConv::ID CallConv,
517                                 MachineFunction &MF, bool isVarArg,
518                                 const SmallVectorImpl<ISD::OutputArg> &Outs,
519                                 LLVMContext &Context) const;
520
521     virtual SDValue
522       LowerReturn(SDValue Chain,
523                   CallingConv::ID CallConv, bool isVarArg,
524                   const SmallVectorImpl<ISD::OutputArg> &Outs,
525                   const SmallVectorImpl<SDValue> &OutVals,
526                   DebugLoc dl, SelectionDAG &DAG) const;
527
528     virtual bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const;
529
530     virtual bool mayBeEmittedAsTailCall(CallInst *CI) const;
531
532     SDValue getARMCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC,
533                       SDValue &ARMcc, SelectionDAG &DAG, DebugLoc dl) const;
534     SDValue getVFPCmp(SDValue LHS, SDValue RHS,
535                       SelectionDAG &DAG, DebugLoc dl) const;
536     SDValue duplicateCmp(SDValue Cmp, SelectionDAG &DAG) const;
537
538     SDValue OptimizeVFPBrcond(SDValue Op, SelectionDAG &DAG) const;
539
540     MachineBasicBlock *EmitAtomicCmpSwap(MachineInstr *MI,
541                                          MachineBasicBlock *BB,
542                                          unsigned Size) const;
543     MachineBasicBlock *EmitAtomicBinary(MachineInstr *MI,
544                                         MachineBasicBlock *BB,
545                                         unsigned Size,
546                                         unsigned BinOpcode) const;
547     MachineBasicBlock *EmitAtomicBinary64(MachineInstr *MI,
548                                           MachineBasicBlock *BB,
549                                           unsigned Op1,
550                                           unsigned Op2,
551                                           bool NeedsCarry = false,
552                                           bool IsCmpxchg = false,
553                                           bool IsMinMax = false,
554                                           ARMCC::CondCodes CC = ARMCC::AL) const;
555     MachineBasicBlock * EmitAtomicBinaryMinMax(MachineInstr *MI,
556                                                MachineBasicBlock *BB,
557                                                unsigned Size,
558                                                bool signExtend,
559                                                ARMCC::CondCodes Cond) const;
560
561     void SetupEntryBlockForSjLj(MachineInstr *MI,
562                                 MachineBasicBlock *MBB,
563                                 MachineBasicBlock *DispatchBB, int FI) const;
564
565     MachineBasicBlock *EmitSjLjDispatchBlock(MachineInstr *MI,
566                                              MachineBasicBlock *MBB) const;
567
568     bool RemapAddSubWithFlags(MachineInstr *MI, MachineBasicBlock *BB) const;
569
570     MachineBasicBlock *EmitStructByval(MachineInstr *MI,
571                                        MachineBasicBlock *MBB) const;
572   };
573
574   enum NEONModImmType {
575     VMOVModImm,
576     VMVNModImm,
577     OtherModImm
578   };
579
580
581   namespace ARM {
582     FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
583                              const TargetLibraryInfo *libInfo);
584   }
585
586   class ARMScalarTargetTransformImpl : public ScalarTargetTransformImpl {
587     const ARMSubtarget *Subtarget;
588   public:
589     explicit ARMScalarTargetTransformImpl(const TargetLowering *TL) :
590       ScalarTargetTransformImpl(TL),
591       Subtarget(&TL->getTargetMachine().getSubtarget<ARMSubtarget>()) {};
592
593     virtual unsigned getIntImmCost(const APInt &Imm, Type *Ty) const;
594   };
595 }
596
597 #endif  // ARMISELLOWERING_H