1 //===- ARMISelLowering.h - ARM DAG Lowering Interface -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the interfaces that ARM uses to lower LLVM code into a
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_TARGET_ARM_ARMISELLOWERING_H
16 #define LLVM_LIB_TARGET_ARM_ARMISELLOWERING_H
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/ISDOpcodes.h"
23 #include "llvm/CodeGen/MachineFunction.h"
24 #include "llvm/CodeGen/SelectionDAGNodes.h"
25 #include "llvm/CodeGen/TargetLowering.h"
26 #include "llvm/CodeGen/ValueTypes.h"
27 #include "llvm/IR/Attributes.h"
28 #include "llvm/IR/CallingConv.h"
29 #include "llvm/IR/Function.h"
30 #include "llvm/IR/IRBuilder.h"
31 #include "llvm/IR/InlineAsm.h"
32 #include "llvm/Support/CodeGen.h"
33 #include "llvm/Support/MachineValueType.h"
41 class FunctionLoweringInfo;
43 class InstrItineraryData;
45 class MachineBasicBlock;
48 class TargetLibraryInfo;
50 class TargetRegisterInfo;
55 // ARM Specific DAG Nodes
56 enum NodeType : unsigned {
57 // Start the numbering where the builtin ops and target ops leave off.
58 FIRST_NUMBER = ISD::BUILTIN_OP_END,
60 Wrapper, // Wrapper - A wrapper node for TargetConstantPool,
61 // TargetExternalSymbol, and TargetGlobalAddress.
62 WrapperPIC, // WrapperPIC - A wrapper node for TargetGlobalAddress in
64 WrapperJT, // WrapperJT - A wrapper node for TargetJumpTable
66 // Add pseudo op to model memcpy for struct byval.
69 CALL, // Function call.
70 CALL_PRED, // Function call that's predicable.
71 CALL_NOLINK, // Function call with branch not branch-and-link.
72 BRCOND, // Conditional branch.
73 BR_JT, // Jumptable branch.
74 BR2_JT, // Jumptable branch (2 level - jumptable entry is a jump).
75 RET_FLAG, // Return with a flag operand.
76 INTRET_FLAG, // Interrupt return with an LR-offset and a flag operand.
78 PIC_ADD, // Add with a PC operand and a PIC label.
80 CMP, // ARM compare instructions.
81 CMN, // ARM CMN instructions.
82 CMPZ, // ARM compare that sets only Z flag.
83 CMPFP, // ARM VFP compare instruction, sets FPSCR.
84 CMPFPw0, // ARM VFP compare against zero instruction, sets FPSCR.
85 FMSTAT, // ARM fmstat instruction.
87 CMOV, // ARM conditional move instructions.
89 SSAT, // Signed saturation
90 USAT, // Unsigned saturation
94 SRL_FLAG, // V,Flag = srl_flag X -> srl X, 1 + save carry out.
95 SRA_FLAG, // V,Flag = sra_flag X -> sra X, 1 + save carry out.
96 RRX, // V = RRX X, Flag -> srl X, 1 + shift in carry flag.
98 ADDC, // Add with carry
99 ADDE, // Add using carry
100 SUBC, // Sub with carry
101 SUBE, // Sub using carry
103 VMOVRRD, // double to two gprs.
104 VMOVDRR, // Two gprs to double.
105 VMOVSR, // move gpr to single, used for f32 literal constructed in a gpr
107 EH_SJLJ_SETJMP, // SjLj exception handling setjmp.
108 EH_SJLJ_LONGJMP, // SjLj exception handling longjmp.
109 EH_SJLJ_SETUP_DISPATCH, // SjLj exception handling setup_dispatch.
111 TC_RETURN, // Tail call return pseudo.
115 DYN_ALLOC, // Dynamic allocation on the stack.
117 MEMBARRIER_MCR, // Memory barrier (MCR)
121 WIN__CHKSTK, // Windows' __chkstk call to do stack probing.
122 WIN__DBZCHK, // Windows' divide by zero check
124 VCEQ, // Vector compare equal.
125 VCEQZ, // Vector compare equal to zero.
126 VCGE, // Vector compare greater than or equal.
127 VCGEZ, // Vector compare greater than or equal to zero.
128 VCLEZ, // Vector compare less than or equal to zero.
129 VCGEU, // Vector compare unsigned greater than or equal.
130 VCGT, // Vector compare greater than.
131 VCGTZ, // Vector compare greater than zero.
132 VCLTZ, // Vector compare less than zero.
133 VCGTU, // Vector compare unsigned greater than.
134 VTST, // Vector test bits.
136 // Vector shift by immediate:
138 VSHRs, // ...right (signed)
139 VSHRu, // ...right (unsigned)
141 // Vector rounding shift by immediate:
142 VRSHRs, // ...right (signed)
143 VRSHRu, // ...right (unsigned)
144 VRSHRN, // ...right narrow
146 // Vector saturating shift by immediate:
147 VQSHLs, // ...left (signed)
148 VQSHLu, // ...left (unsigned)
149 VQSHLsu, // ...left (signed to unsigned)
150 VQSHRNs, // ...right narrow (signed)
151 VQSHRNu, // ...right narrow (unsigned)
152 VQSHRNsu, // ...right narrow (signed to unsigned)
154 // Vector saturating rounding shift by immediate:
155 VQRSHRNs, // ...right narrow (signed)
156 VQRSHRNu, // ...right narrow (unsigned)
157 VQRSHRNsu, // ...right narrow (signed to unsigned)
159 // Vector shift and insert:
163 // Vector get lane (VMOV scalar to ARM core register)
164 // (These are used for 8- and 16-bit element types only.)
165 VGETLANEu, // zero-extend vector extract element
166 VGETLANEs, // sign-extend vector extract element
168 // Vector move immediate and move negated immediate:
172 // Vector move f32 immediate:
175 // Move H <-> R, clearing top 16 bits
185 VREV64, // reverse elements within 64-bit doublewords
186 VREV32, // reverse elements within 32-bit words
187 VREV16, // reverse elements within 16-bit halfwords
188 VZIP, // zip (interleave)
189 VUZP, // unzip (deinterleave)
191 VTBL1, // 1-register shuffle with mask
192 VTBL2, // 2-register shuffle with mask
194 // Vector multiply long:
196 VMULLu, // ...unsigned
198 SMULWB, // Signed multiply word by half word, bottom
199 SMULWT, // Signed multiply word by half word, top
200 UMLAL, // 64bit Unsigned Accumulate Multiply
201 SMLAL, // 64bit Signed Accumulate Multiply
202 UMAAL, // 64-bit Unsigned Accumulate Accumulate Multiply
203 SMLALBB, // 64-bit signed accumulate multiply bottom, bottom 16
204 SMLALBT, // 64-bit signed accumulate multiply bottom, top 16
205 SMLALTB, // 64-bit signed accumulate multiply top, bottom 16
206 SMLALTT, // 64-bit signed accumulate multiply top, top 16
207 SMLALD, // Signed multiply accumulate long dual
208 SMLALDX, // Signed multiply accumulate long dual exchange
209 SMLSLD, // Signed multiply subtract long dual
210 SMLSLDX, // Signed multiply subtract long dual exchange
211 SMMLAR, // Signed multiply long, round and add
212 SMMLSR, // Signed multiply long, subtract and round
214 // Operands of the standard BUILD_VECTOR node are not legalized, which
215 // is fine if BUILD_VECTORs are always lowered to shuffles or other
216 // operations, but for ARM some BUILD_VECTORs are legal as-is and their
217 // operands need to be legalized. Define an ARM-specific version of
218 // BUILD_VECTOR for this purpose.
224 // Vector OR with immediate
226 // Vector AND with NOT of immediate
229 // Vector bitwise select
232 // Pseudo-instruction representing a memory copy using ldm/stm
236 // Vector load N-element structure to all lanes:
237 VLD1DUP = ISD::FIRST_TARGET_MEMORY_OPCODE,
242 // NEON loads with post-increment base updates:
255 // NEON stores with post-increment base updates:
265 } // end namespace ARMISD
267 /// Define some predicates that are used for node matching.
270 bool isBitFieldInvertedMask(unsigned v);
272 } // end namespace ARM
274 //===--------------------------------------------------------------------===//
275 // ARMTargetLowering - ARM Implementation of the TargetLowering interface
277 class ARMTargetLowering : public TargetLowering {
279 explicit ARMTargetLowering(const TargetMachine &TM,
280 const ARMSubtarget &STI);
282 unsigned getJumpTableEncoding() const override;
283 bool useSoftFloat() const override;
285 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
287 /// ReplaceNodeResults - Replace the results of node with an illegal result
288 /// type with new values built out of custom code.
289 void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
290 SelectionDAG &DAG) const override;
292 const char *getTargetNodeName(unsigned Opcode) const override;
294 bool isSelectSupported(SelectSupportKind Kind) const override {
295 // ARM does not support scalar condition selects on vectors.
296 return (Kind != ScalarCondVectorVal);
299 bool isReadOnly(const GlobalValue *GV) const;
301 /// getSetCCResultType - Return the value type to use for ISD::SETCC.
302 EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
303 EVT VT) const override;
306 EmitInstrWithCustomInserter(MachineInstr &MI,
307 MachineBasicBlock *MBB) const override;
309 void AdjustInstrPostInstrSelection(MachineInstr &MI,
310 SDNode *Node) const override;
312 SDValue PerformCMOVCombine(SDNode *N, SelectionDAG &DAG) const;
313 SDValue PerformBRCONDCombine(SDNode *N, SelectionDAG &DAG) const;
314 SDValue PerformCMOVToBFICombine(SDNode *N, SelectionDAG &DAG) const;
315 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
317 bool isDesirableToTransformToIntegerOp(unsigned Opc, EVT VT) const override;
319 /// allowsMisalignedMemoryAccesses - Returns true if the target allows
320 /// unaligned memory accesses of the specified type. Returns whether it
321 /// is "fast" by reference in the second argument.
322 bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace,
324 bool *Fast) const override;
326 EVT getOptimalMemOpType(uint64_t Size,
327 unsigned DstAlign, unsigned SrcAlign,
328 bool IsMemset, bool ZeroMemset,
330 MachineFunction &MF) const override;
332 bool isTruncateFree(Type *SrcTy, Type *DstTy) const override;
333 bool isTruncateFree(EVT SrcVT, EVT DstVT) const override;
334 bool isZExtFree(SDValue Val, EVT VT2) const override;
335 bool isFNegFree(EVT VT) const override;
337 bool isVectorLoadExtDesirable(SDValue ExtVal) const override;
339 bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override;
342 /// isLegalAddressingMode - Return true if the addressing mode represented
343 /// by AM is legal for this target, for a load/store of the specified type.
344 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
345 Type *Ty, unsigned AS,
346 Instruction *I = nullptr) const override;
348 /// getScalingFactorCost - Return the cost of the scaling used in
349 /// addressing mode represented by AM.
350 /// If the AM is supported, the return value must be >= 0.
351 /// If the AM is not supported, the return value must be negative.
352 int getScalingFactorCost(const DataLayout &DL, const AddrMode &AM, Type *Ty,
353 unsigned AS) const override;
355 bool isLegalT2ScaledAddressingMode(const AddrMode &AM, EVT VT) const;
357 /// Returns true if the addresing mode representing by AM is legal
358 /// for the Thumb1 target, for a load/store of the specified type.
359 bool isLegalT1ScaledAddressingMode(const AddrMode &AM, EVT VT) const;
361 /// isLegalICmpImmediate - Return true if the specified immediate is legal
362 /// icmp immediate, that is the target has icmp instructions which can
363 /// compare a register against the immediate without having to materialize
364 /// the immediate into a register.
365 bool isLegalICmpImmediate(int64_t Imm) const override;
367 /// isLegalAddImmediate - Return true if the specified immediate is legal
368 /// add immediate, that is the target has add instructions which can
369 /// add a register and the immediate without having to materialize
370 /// the immediate into a register.
371 bool isLegalAddImmediate(int64_t Imm) const override;
373 /// getPreIndexedAddressParts - returns true by value, base pointer and
374 /// offset pointer and addressing mode by reference if the node's address
375 /// can be legally represented as pre-indexed load / store address.
376 bool getPreIndexedAddressParts(SDNode *N, SDValue &Base, SDValue &Offset,
377 ISD::MemIndexedMode &AM,
378 SelectionDAG &DAG) const override;
380 /// getPostIndexedAddressParts - returns true by value, base pointer and
381 /// offset pointer and addressing mode by reference if this node can be
382 /// combined with a load / store to form a post-indexed load / store.
383 bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, SDValue &Base,
384 SDValue &Offset, ISD::MemIndexedMode &AM,
385 SelectionDAG &DAG) const override;
387 void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known,
388 const APInt &DemandedElts,
389 const SelectionDAG &DAG,
390 unsigned Depth) const override;
393 bool ExpandInlineAsm(CallInst *CI) const override;
395 ConstraintType getConstraintType(StringRef Constraint) const override;
397 /// Examine constraint string and operand type and determine a weight value.
398 /// The operand object must already have been set up with the operand type.
399 ConstraintWeight getSingleConstraintMatchWeight(
400 AsmOperandInfo &info, const char *constraint) const override;
402 std::pair<unsigned, const TargetRegisterClass *>
403 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
404 StringRef Constraint, MVT VT) const override;
406 const char *LowerXConstraint(EVT ConstraintVT) const override;
408 /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
409 /// vector. If it is invalid, don't add anything to Ops. If hasMemory is
410 /// true it means one of the asm constraint of the inline asm instruction
411 /// being processed is 'm'.
412 void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
413 std::vector<SDValue> &Ops,
414 SelectionDAG &DAG) const override;
417 getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
418 if (ConstraintCode == "Q")
419 return InlineAsm::Constraint_Q;
420 else if (ConstraintCode == "o")
421 return InlineAsm::Constraint_o;
422 else if (ConstraintCode.size() == 2) {
423 if (ConstraintCode[0] == 'U') {
424 switch(ConstraintCode[1]) {
428 return InlineAsm::Constraint_Um;
430 return InlineAsm::Constraint_Un;
432 return InlineAsm::Constraint_Uq;
434 return InlineAsm::Constraint_Us;
436 return InlineAsm::Constraint_Ut;
438 return InlineAsm::Constraint_Uv;
440 return InlineAsm::Constraint_Uy;
444 return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
447 const ARMSubtarget* getSubtarget() const {
451 /// getRegClassFor - Return the register class that should be used for the
452 /// specified value type.
453 const TargetRegisterClass *getRegClassFor(MVT VT) const override;
455 /// Returns true if a cast between SrcAS and DestAS is a noop.
456 bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
457 // Addrspacecasts are always noops.
461 bool shouldAlignPointerArgs(CallInst *CI, unsigned &MinSize,
462 unsigned &PrefAlign) const override;
464 /// createFastISel - This method returns a target specific FastISel object,
465 /// or null if the target does not support "fast" ISel.
466 FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
467 const TargetLibraryInfo *libInfo) const override;
469 Sched::Preference getSchedulingPreference(SDNode *N) const override;
472 isShuffleMaskLegal(ArrayRef<int> M, EVT VT) const override;
473 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
475 /// isFPImmLegal - Returns true if the target can instruction select the
476 /// specified FP immediate natively. If false, the legalizer will
477 /// materialize the FP immediate as a load from a constant pool.
478 bool isFPImmLegal(const APFloat &Imm, EVT VT) const override;
480 bool getTgtMemIntrinsic(IntrinsicInfo &Info,
483 unsigned Intrinsic) const override;
485 /// Returns true if it is beneficial to convert a load of a constant
486 /// to just the constant itself.
487 bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
488 Type *Ty) const override;
490 /// Return true if EXTRACT_SUBVECTOR is cheap for this result type
492 bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
493 unsigned Index) const override;
495 /// Returns true if an argument of type Ty needs to be passed in a
496 /// contiguous block of registers in calling convention CallConv.
497 bool functionArgumentNeedsConsecutiveRegisters(
498 Type *Ty, CallingConv::ID CallConv, bool isVarArg) const override;
500 /// If a physical register, this returns the register that receives the
501 /// exception address on entry to an EH pad.
503 getExceptionPointerRegister(const Constant *PersonalityFn) const override;
505 /// If a physical register, this returns the register that receives the
506 /// exception typeid on entry to a landing pad.
508 getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
510 Instruction *makeDMB(IRBuilder<> &Builder, ARM_MB::MemBOpt Domain) const;
511 Value *emitLoadLinked(IRBuilder<> &Builder, Value *Addr,
512 AtomicOrdering Ord) const override;
513 Value *emitStoreConditional(IRBuilder<> &Builder, Value *Val,
514 Value *Addr, AtomicOrdering Ord) const override;
516 void emitAtomicCmpXchgNoStoreLLBalance(IRBuilder<> &Builder) const override;
518 Instruction *emitLeadingFence(IRBuilder<> &Builder, Instruction *Inst,
519 AtomicOrdering Ord) const override;
520 Instruction *emitTrailingFence(IRBuilder<> &Builder, Instruction *Inst,
521 AtomicOrdering Ord) const override;
523 unsigned getMaxSupportedInterleaveFactor() const override { return 4; }
525 bool lowerInterleavedLoad(LoadInst *LI,
526 ArrayRef<ShuffleVectorInst *> Shuffles,
527 ArrayRef<unsigned> Indices,
528 unsigned Factor) const override;
529 bool lowerInterleavedStore(StoreInst *SI, ShuffleVectorInst *SVI,
530 unsigned Factor) const override;
532 bool shouldInsertFencesForAtomic(const Instruction *I) const override;
533 TargetLoweringBase::AtomicExpansionKind
534 shouldExpandAtomicLoadInIR(LoadInst *LI) const override;
535 bool shouldExpandAtomicStoreInIR(StoreInst *SI) const override;
536 TargetLoweringBase::AtomicExpansionKind
537 shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override;
538 bool shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
540 bool useLoadStackGuardNode() const override;
542 bool canCombineStoreAndExtract(Type *VectorTy, Value *Idx,
543 unsigned &Cost) const override;
545 bool canMergeStoresTo(unsigned AddressSpace, EVT MemVT,
546 const SelectionDAG &DAG) const override {
547 // Do not merge to larger than i32.
548 return (MemVT.getSizeInBits() <= 32);
551 bool isCheapToSpeculateCttz() const override;
552 bool isCheapToSpeculateCtlz() const override;
554 bool convertSetCCLogicToBitwiseLogic(EVT VT) const override {
555 return VT.isScalarInteger();
558 bool supportSwiftError() const override {
562 bool hasStandaloneRem(EVT VT) const override {
563 return HasStandaloneRem;
566 CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool isVarArg) const;
567 CCAssignFn *CCAssignFnForReturn(CallingConv::ID CC, bool isVarArg) const;
569 /// Returns true if \p VecTy is a legal interleaved access type. This
570 /// function checks the vector element type and the overall width of the
572 bool isLegalInterleavedAccessType(VectorType *VecTy,
573 const DataLayout &DL) const;
575 /// Returns the number of interleaved accesses that will be generated when
576 /// lowering accesses of the given type.
577 unsigned getNumInterleavedAccesses(VectorType *VecTy,
578 const DataLayout &DL) const;
580 void finalizeLowering(MachineFunction &MF) const override;
582 /// Return the correct alignment for the current calling convention.
583 unsigned getABIAlignmentForCallingConv(Type *ArgTy,
584 DataLayout DL) const override;
586 bool isDesirableToCommuteWithShift(const SDNode *N,
587 CombineLevel Level) const override;
590 std::pair<const TargetRegisterClass *, uint8_t>
591 findRepresentativeClass(const TargetRegisterInfo *TRI,
592 MVT VT) const override;
595 /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
596 /// make the right decision when generating code for different targets.
597 const ARMSubtarget *Subtarget;
599 const TargetRegisterInfo *RegInfo;
601 const InstrItineraryData *Itins;
603 /// ARMPCLabelIndex - Keep track of the number of ARM PC labels created.
604 unsigned ARMPCLabelIndex;
606 // TODO: remove this, and have shouldInsertFencesForAtomic do the proper
608 bool InsertFencesForAtomic;
610 bool HasStandaloneRem = true;
612 void addTypeForNEON(MVT VT, MVT PromotedLdStVT, MVT PromotedBitwiseVT);
613 void addDRTypeForNEON(MVT VT);
614 void addQRTypeForNEON(MVT VT);
615 std::pair<SDValue, SDValue> getARMXALUOOp(SDValue Op, SelectionDAG &DAG, SDValue &ARMcc) const;
617 using RegsToPassVector = SmallVector<std::pair<unsigned, SDValue>, 8>;
619 void PassF64ArgInRegs(const SDLoc &dl, SelectionDAG &DAG, SDValue Chain,
620 SDValue &Arg, RegsToPassVector &RegsToPass,
621 CCValAssign &VA, CCValAssign &NextVA,
623 SmallVectorImpl<SDValue> &MemOpChains,
624 ISD::ArgFlagsTy Flags) const;
625 SDValue GetF64FormalArgument(CCValAssign &VA, CCValAssign &NextVA,
626 SDValue &Root, SelectionDAG &DAG,
627 const SDLoc &dl) const;
629 CallingConv::ID getEffectiveCallingConv(CallingConv::ID CC,
630 bool isVarArg) const;
631 CCAssignFn *CCAssignFnForNode(CallingConv::ID CC, bool Return,
632 bool isVarArg) const;
633 SDValue LowerMemOpCallTo(SDValue Chain, SDValue StackPtr, SDValue Arg,
634 const SDLoc &dl, SelectionDAG &DAG,
635 const CCValAssign &VA,
636 ISD::ArgFlagsTy Flags) const;
637 SDValue LowerEH_SJLJ_SETJMP(SDValue Op, SelectionDAG &DAG) const;
638 SDValue LowerEH_SJLJ_LONGJMP(SDValue Op, SelectionDAG &DAG) const;
639 SDValue LowerEH_SJLJ_SETUP_DISPATCH(SDValue Op, SelectionDAG &DAG) const;
640 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG,
641 const ARMSubtarget *Subtarget) const;
642 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
643 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
644 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
645 SDValue LowerGlobalAddressDarwin(SDValue Op, SelectionDAG &DAG) const;
646 SDValue LowerGlobalAddressELF(SDValue Op, SelectionDAG &DAG) const;
647 SDValue LowerGlobalAddressWindows(SDValue Op, SelectionDAG &DAG) const;
648 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
649 SDValue LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
650 SelectionDAG &DAG) const;
651 SDValue LowerToTLSExecModels(GlobalAddressSDNode *GA,
653 TLSModel::Model model) const;
654 SDValue LowerGlobalTLSAddressDarwin(SDValue Op, SelectionDAG &DAG) const;
655 SDValue LowerGlobalTLSAddressWindows(SDValue Op, SelectionDAG &DAG) const;
656 SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const;
657 SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
658 SDValue LowerSignedALUO(SDValue Op, SelectionDAG &DAG) const;
659 SDValue LowerUnsignedALUO(SDValue Op, SelectionDAG &DAG) const;
660 SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
661 SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
662 SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
663 SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
664 SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) const;
665 SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
666 SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
667 SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG) const;
668 SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
669 SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const;
670 SDValue LowerConstantFP(SDValue Op, SelectionDAG &DAG,
671 const ARMSubtarget *ST) const;
672 SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG,
673 const ARMSubtarget *ST) const;
674 SDValue LowerFSINCOS(SDValue Op, SelectionDAG &DAG) const;
675 SDValue LowerDivRem(SDValue Op, SelectionDAG &DAG) const;
676 SDValue LowerDIV_Windows(SDValue Op, SelectionDAG &DAG, bool Signed) const;
677 void ExpandDIV_Windows(SDValue Op, SelectionDAG &DAG, bool Signed,
678 SmallVectorImpl<SDValue> &Results) const;
679 SDValue LowerWindowsDIVLibCall(SDValue Op, SelectionDAG &DAG, bool Signed,
680 SDValue &Chain) const;
681 SDValue LowerREM(SDNode *N, SelectionDAG &DAG) const;
682 SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
683 SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
684 SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const;
685 SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG) const;
686 SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
688 unsigned getRegisterByName(const char* RegName, EVT VT,
689 SelectionDAG &DAG) const override;
691 /// isFMAFasterThanFMulAndFAdd - Return true if an FMA operation is faster
692 /// than a pair of fmul and fadd instructions. fmuladd intrinsics will be
693 /// expanded to FMAs when this method returns true, otherwise fmuladd is
694 /// expanded to fmul + fadd.
696 /// ARM supports both fused and unfused multiply-add operations; we already
697 /// lower a pair of fmul and fadd to the latter so it's not clear that there
698 /// would be a gain or that the gain would be worthwhile enough to risk
699 /// correctness bugs.
700 bool isFMAFasterThanFMulAndFAdd(EVT VT) const override { return false; }
702 SDValue ReconstructShuffle(SDValue Op, SelectionDAG &DAG) const;
704 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
705 CallingConv::ID CallConv, bool isVarArg,
706 const SmallVectorImpl<ISD::InputArg> &Ins,
707 const SDLoc &dl, SelectionDAG &DAG,
708 SmallVectorImpl<SDValue> &InVals, bool isThisReturn,
709 SDValue ThisVal) const;
711 bool supportSplitCSR(MachineFunction *MF) const override {
712 return MF->getFunction().getCallingConv() == CallingConv::CXX_FAST_TLS &&
713 MF->getFunction().hasFnAttribute(Attribute::NoUnwind);
716 void initializeSplitCSR(MachineBasicBlock *Entry) const override;
717 void insertCopiesSplitCSR(
718 MachineBasicBlock *Entry,
719 const SmallVectorImpl<MachineBasicBlock *> &Exits) const override;
722 LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
723 const SmallVectorImpl<ISD::InputArg> &Ins,
724 const SDLoc &dl, SelectionDAG &DAG,
725 SmallVectorImpl<SDValue> &InVals) const override;
727 int StoreByValRegs(CCState &CCInfo, SelectionDAG &DAG, const SDLoc &dl,
728 SDValue &Chain, const Value *OrigArg,
729 unsigned InRegsParamRecordIdx, int ArgOffset,
730 unsigned ArgSize) const;
732 void VarArgStyleRegisters(CCState &CCInfo, SelectionDAG &DAG,
733 const SDLoc &dl, SDValue &Chain,
734 unsigned ArgOffset, unsigned TotalArgRegsSaveSize,
735 bool ForceMutable = false) const;
737 SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
738 SmallVectorImpl<SDValue> &InVals) const override;
740 /// HandleByVal - Target-specific cleanup for ByVal support.
741 void HandleByVal(CCState *, unsigned &, unsigned) const override;
743 /// IsEligibleForTailCallOptimization - Check whether the call is eligible
744 /// for tail call optimization. Targets which want to do tail call
745 /// optimization should implement this function.
746 bool IsEligibleForTailCallOptimization(SDValue Callee,
747 CallingConv::ID CalleeCC,
749 bool isCalleeStructRet,
750 bool isCallerStructRet,
751 const SmallVectorImpl<ISD::OutputArg> &Outs,
752 const SmallVectorImpl<SDValue> &OutVals,
753 const SmallVectorImpl<ISD::InputArg> &Ins,
754 SelectionDAG& DAG) const;
756 bool CanLowerReturn(CallingConv::ID CallConv,
757 MachineFunction &MF, bool isVarArg,
758 const SmallVectorImpl<ISD::OutputArg> &Outs,
759 LLVMContext &Context) const override;
761 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
762 const SmallVectorImpl<ISD::OutputArg> &Outs,
763 const SmallVectorImpl<SDValue> &OutVals,
764 const SDLoc &dl, SelectionDAG &DAG) const override;
766 bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override;
768 bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
770 SDValue getCMOV(const SDLoc &dl, EVT VT, SDValue FalseVal, SDValue TrueVal,
771 SDValue ARMcc, SDValue CCR, SDValue Cmp,
772 SelectionDAG &DAG) const;
773 SDValue getARMCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC,
774 SDValue &ARMcc, SelectionDAG &DAG, const SDLoc &dl) const;
775 SDValue getVFPCmp(SDValue LHS, SDValue RHS, SelectionDAG &DAG,
776 const SDLoc &dl, bool InvalidOnQNaN) const;
777 SDValue duplicateCmp(SDValue Cmp, SelectionDAG &DAG) const;
779 SDValue OptimizeVFPBrcond(SDValue Op, SelectionDAG &DAG) const;
781 void SetupEntryBlockForSjLj(MachineInstr &MI, MachineBasicBlock *MBB,
782 MachineBasicBlock *DispatchBB, int FI) const;
784 void EmitSjLjDispatchBlock(MachineInstr &MI, MachineBasicBlock *MBB) const;
786 bool RemapAddSubWithFlags(MachineInstr &MI, MachineBasicBlock *BB) const;
788 MachineBasicBlock *EmitStructByval(MachineInstr &MI,
789 MachineBasicBlock *MBB) const;
791 MachineBasicBlock *EmitLowered__chkstk(MachineInstr &MI,
792 MachineBasicBlock *MBB) const;
793 MachineBasicBlock *EmitLowered__dbzchk(MachineInstr &MI,
794 MachineBasicBlock *MBB) const;
797 enum NEONModImmType {
805 FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
806 const TargetLibraryInfo *libInfo);
808 } // end namespace ARM
810 } // end namespace llvm
812 #endif // LLVM_LIB_TARGET_ARM_ARMISELLOWERING_H