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/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"
37 class InstrItineraryData;
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,
46 Wrapper, // Wrapper - A wrapper node for TargetConstantPool,
47 // TargetExternalSymbol, and TargetGlobalAddress.
48 WrapperPIC, // WrapperPIC - A wrapper node for TargetGlobalAddress in
50 WrapperJT, // WrapperJT - A wrapper node for TargetJumpTable
52 // Add pseudo op to model memcpy for struct byval.
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.
64 PIC_ADD, // Add with a PC operand and a PIC label.
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.
73 CMOV, // ARM conditional move instructions.
75 SSAT, // Signed saturation
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.
83 ADDC, // Add with carry
84 ADDE, // Add using carry
85 SUBC, // Sub with carry
86 SUBE, // Sub using carry
88 VMOVRRD, // double to two gprs.
89 VMOVDRR, // Two gprs to double.
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.
95 TC_RETURN, // Tail call return pseudo.
99 DYN_ALLOC, // Dynamic allocation on the stack.
101 MEMBARRIER_MCR, // Memory barrier (MCR)
105 WIN__CHKSTK, // Windows' __chkstk call to do stack probing.
106 WIN__DBZCHK, // Windows' divide by zero check
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.
120 // Vector shift by immediate:
122 VSHRs, // ...right (signed)
123 VSHRu, // ...right (unsigned)
125 // Vector rounding shift by immediate:
126 VRSHRs, // ...right (signed)
127 VRSHRu, // ...right (unsigned)
128 VRSHRN, // ...right narrow
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)
138 // Vector saturating rounding shift by immediate:
139 VQRSHRNs, // ...right narrow (signed)
140 VQRSHRNu, // ...right narrow (unsigned)
141 VQRSHRNsu, // ...right narrow (signed to unsigned)
143 // Vector shift and insert:
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
152 // Vector move immediate and move negated immediate:
156 // Vector move f32 immediate:
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)
171 VTBL1, // 1-register shuffle with mask
172 VTBL2, // 2-register shuffle with mask
174 // Vector multiply long:
176 VMULLu, // ...unsigned
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 SMLALD, // Signed multiply accumulate long dual
188 SMLALDX, // Signed multiply accumulate long dual exchange
189 SMLSLD, // Signed multiply subtract long dual
190 SMLSLDX, // Signed multiply subtract long dual exchange
192 // Operands of the standard BUILD_VECTOR node are not legalized, which
193 // is fine if BUILD_VECTORs are always lowered to shuffles or other
194 // operations, but for ARM some BUILD_VECTORs are legal as-is and their
195 // operands need to be legalized. Define an ARM-specific version of
196 // BUILD_VECTOR for this purpose.
202 // Vector OR with immediate
204 // Vector AND with NOT of immediate
207 // Vector bitwise select
210 // Pseudo-instruction representing a memory copy using ldm/stm
214 // Vector load N-element structure to all lanes:
215 VLD1DUP = ISD::FIRST_TARGET_MEMORY_OPCODE,
220 // NEON loads with post-increment base updates:
233 // NEON stores with post-increment base updates:
243 } // end namespace ARMISD
245 /// Define some predicates that are used for node matching.
248 bool isBitFieldInvertedMask(unsigned v);
250 } // end namespace ARM
252 //===--------------------------------------------------------------------===//
253 // ARMTargetLowering - ARM Implementation of the TargetLowering interface
255 class ARMTargetLowering : public TargetLowering {
257 explicit ARMTargetLowering(const TargetMachine &TM,
258 const ARMSubtarget &STI);
260 unsigned getJumpTableEncoding() const override;
261 bool useSoftFloat() const override;
263 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
265 /// ReplaceNodeResults - Replace the results of node with an illegal result
266 /// type with new values built out of custom code.
268 void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
269 SelectionDAG &DAG) const override;
271 const char *getTargetNodeName(unsigned Opcode) const override;
273 bool isSelectSupported(SelectSupportKind Kind) const override {
274 // ARM does not support scalar condition selects on vectors.
275 return (Kind != ScalarCondVectorVal);
278 /// getSetCCResultType - Return the value type to use for ISD::SETCC.
279 EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
280 EVT VT) const override;
283 EmitInstrWithCustomInserter(MachineInstr &MI,
284 MachineBasicBlock *MBB) const override;
286 void AdjustInstrPostInstrSelection(MachineInstr &MI,
287 SDNode *Node) const override;
289 SDValue PerformCMOVCombine(SDNode *N, SelectionDAG &DAG) const;
290 SDValue PerformBRCONDCombine(SDNode *N, SelectionDAG &DAG) const;
291 SDValue PerformCMOVToBFICombine(SDNode *N, SelectionDAG &DAG) const;
292 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
294 bool isDesirableToTransformToIntegerOp(unsigned Opc, EVT VT) const override;
296 /// allowsMisalignedMemoryAccesses - 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 bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace,
301 bool *Fast) const override;
303 EVT getOptimalMemOpType(uint64_t Size,
304 unsigned DstAlign, unsigned SrcAlign,
305 bool IsMemset, bool ZeroMemset,
307 MachineFunction &MF) const override;
309 using TargetLowering::isZExtFree;
310 bool isZExtFree(SDValue Val, EVT VT2) const override;
312 bool isVectorLoadExtDesirable(SDValue ExtVal) const override;
314 bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override;
317 /// isLegalAddressingMode - Return true if the addressing mode represented
318 /// by AM is legal for this target, for a load/store of the specified type.
319 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
320 Type *Ty, unsigned AS) const override;
322 /// getScalingFactorCost - Return the cost of the scaling used in
323 /// addressing mode represented by AM.
324 /// If the AM is supported, the return value must be >= 0.
325 /// If the AM is not supported, the return value must be negative.
326 int getScalingFactorCost(const DataLayout &DL, const AddrMode &AM, Type *Ty,
327 unsigned AS) const override;
329 bool isLegalT2ScaledAddressingMode(const AddrMode &AM, EVT VT) const;
331 /// isLegalICmpImmediate - Return true if the specified immediate is legal
332 /// icmp immediate, that is the target has icmp instructions which can
333 /// compare a register against the immediate without having to materialize
334 /// the immediate into a register.
335 bool isLegalICmpImmediate(int64_t Imm) const override;
337 /// isLegalAddImmediate - Return true if the specified immediate is legal
338 /// add immediate, that is the target has add instructions which can
339 /// add a register and the immediate without having to materialize
340 /// the immediate into a register.
341 bool isLegalAddImmediate(int64_t Imm) const override;
343 /// getPreIndexedAddressParts - returns true by value, base pointer and
344 /// offset pointer and addressing mode by reference if the node's address
345 /// can be legally represented as pre-indexed load / store address.
346 bool getPreIndexedAddressParts(SDNode *N, SDValue &Base, SDValue &Offset,
347 ISD::MemIndexedMode &AM,
348 SelectionDAG &DAG) const override;
350 /// getPostIndexedAddressParts - returns true by value, base pointer and
351 /// offset pointer and addressing mode by reference if this node can be
352 /// combined with a load / store to form a post-indexed load / store.
353 bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, SDValue &Base,
354 SDValue &Offset, ISD::MemIndexedMode &AM,
355 SelectionDAG &DAG) const override;
357 void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known,
358 const APInt &DemandedElts,
359 const SelectionDAG &DAG,
360 unsigned Depth) const override;
363 bool ExpandInlineAsm(CallInst *CI) const override;
365 ConstraintType getConstraintType(StringRef Constraint) const override;
367 /// Examine constraint string and operand type and determine a weight value.
368 /// The operand object must already have been set up with the operand type.
369 ConstraintWeight getSingleConstraintMatchWeight(
370 AsmOperandInfo &info, const char *constraint) const override;
372 std::pair<unsigned, const TargetRegisterClass *>
373 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
374 StringRef Constraint, MVT VT) const override;
376 const char *LowerXConstraint(EVT ConstraintVT) const override;
378 /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
379 /// vector. If it is invalid, don't add anything to Ops. If hasMemory is
380 /// true it means one of the asm constraint of the inline asm instruction
381 /// being processed is 'm'.
382 void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
383 std::vector<SDValue> &Ops,
384 SelectionDAG &DAG) const override;
387 getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
388 if (ConstraintCode == "Q")
389 return InlineAsm::Constraint_Q;
390 else if (ConstraintCode == "o")
391 return InlineAsm::Constraint_o;
392 else if (ConstraintCode.size() == 2) {
393 if (ConstraintCode[0] == 'U') {
394 switch(ConstraintCode[1]) {
398 return InlineAsm::Constraint_Um;
400 return InlineAsm::Constraint_Un;
402 return InlineAsm::Constraint_Uq;
404 return InlineAsm::Constraint_Us;
406 return InlineAsm::Constraint_Ut;
408 return InlineAsm::Constraint_Uv;
410 return InlineAsm::Constraint_Uy;
414 return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
417 const ARMSubtarget* getSubtarget() const {
421 /// getRegClassFor - Return the register class that should be used for the
422 /// specified value type.
423 const TargetRegisterClass *getRegClassFor(MVT VT) const override;
425 /// Returns true if a cast between SrcAS and DestAS is a noop.
426 bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
427 // Addrspacecasts are always noops.
431 bool shouldAlignPointerArgs(CallInst *CI, unsigned &MinSize,
432 unsigned &PrefAlign) const override;
434 /// createFastISel - This method returns a target specific FastISel object,
435 /// or null if the target does not support "fast" ISel.
436 FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
437 const TargetLibraryInfo *libInfo) const override;
439 Sched::Preference getSchedulingPreference(SDNode *N) const override;
442 isShuffleMaskLegal(const SmallVectorImpl<int> &M, EVT VT) const override;
443 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
445 /// isFPImmLegal - Returns true if the target can instruction select the
446 /// specified FP immediate natively. If false, the legalizer will
447 /// materialize the FP immediate as a load from a constant pool.
448 bool isFPImmLegal(const APFloat &Imm, EVT VT) const override;
450 bool getTgtMemIntrinsic(IntrinsicInfo &Info,
452 unsigned Intrinsic) const override;
454 /// \brief Returns true if it is beneficial to convert a load of a constant
455 /// to just the constant itself.
456 bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
457 Type *Ty) const override;
459 /// Return true if EXTRACT_SUBVECTOR is cheap for this result type
461 bool isExtractSubvectorCheap(EVT ResVT, unsigned Index) const override;
463 /// \brief Returns true if an argument of type Ty needs to be passed in a
464 /// contiguous block of registers in calling convention CallConv.
465 bool functionArgumentNeedsConsecutiveRegisters(
466 Type *Ty, CallingConv::ID CallConv, bool isVarArg) const override;
468 /// If a physical register, this returns the register that receives the
469 /// exception address on entry to an EH pad.
471 getExceptionPointerRegister(const Constant *PersonalityFn) const override;
473 /// If a physical register, this returns the register that receives the
474 /// exception typeid on entry to a landing pad.
476 getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
478 Instruction *makeDMB(IRBuilder<> &Builder, ARM_MB::MemBOpt Domain) const;
479 Value *emitLoadLinked(IRBuilder<> &Builder, Value *Addr,
480 AtomicOrdering Ord) const override;
481 Value *emitStoreConditional(IRBuilder<> &Builder, Value *Val,
482 Value *Addr, AtomicOrdering Ord) const override;
484 void emitAtomicCmpXchgNoStoreLLBalance(IRBuilder<> &Builder) const override;
486 Instruction* emitLeadingFence(IRBuilder<> &Builder, AtomicOrdering Ord,
487 bool IsStore, bool IsLoad) const override;
488 Instruction* emitTrailingFence(IRBuilder<> &Builder, AtomicOrdering Ord,
489 bool IsStore, bool IsLoad) const override;
491 unsigned getMaxSupportedInterleaveFactor() const override { return 4; }
493 bool lowerInterleavedLoad(LoadInst *LI,
494 ArrayRef<ShuffleVectorInst *> Shuffles,
495 ArrayRef<unsigned> Indices,
496 unsigned Factor) const override;
497 bool lowerInterleavedStore(StoreInst *SI, ShuffleVectorInst *SVI,
498 unsigned Factor) const override;
500 bool shouldInsertFencesForAtomic(const Instruction *I) const override;
501 TargetLoweringBase::AtomicExpansionKind
502 shouldExpandAtomicLoadInIR(LoadInst *LI) const override;
503 bool shouldExpandAtomicStoreInIR(StoreInst *SI) const override;
504 TargetLoweringBase::AtomicExpansionKind
505 shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override;
506 bool shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
508 bool useLoadStackGuardNode() const override;
510 bool canCombineStoreAndExtract(Type *VectorTy, Value *Idx,
511 unsigned &Cost) const override;
513 bool canMergeStoresTo(EVT MemVT) const override {
514 // Do not merge to larger than i32.
515 return (MemVT.getSizeInBits() <= 32);
518 bool isCheapToSpeculateCttz() const override;
519 bool isCheapToSpeculateCtlz() const override;
521 bool convertSetCCLogicToBitwiseLogic(EVT VT) const override {
522 return VT.isScalarInteger();
525 bool supportSwiftError() const override {
529 bool hasStandaloneRem(EVT VT) const override {
530 return HasStandaloneRem;
533 CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool isVarArg) const;
534 CCAssignFn *CCAssignFnForReturn(CallingConv::ID CC, bool isVarArg) const;
536 /// Returns true if \p VecTy is a legal interleaved access type. This
537 /// function checks the vector element type and the overall width of the
539 bool isLegalInterleavedAccessType(VectorType *VecTy,
540 const DataLayout &DL) const;
542 /// Returns the number of interleaved accesses that will be generated when
543 /// lowering accesses of the given type.
544 unsigned getNumInterleavedAccesses(VectorType *VecTy,
545 const DataLayout &DL) const;
547 void finalizeLowering(MachineFunction &MF) const override;
550 std::pair<const TargetRegisterClass *, uint8_t>
551 findRepresentativeClass(const TargetRegisterInfo *TRI,
552 MVT VT) const override;
555 /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
556 /// make the right decision when generating code for different targets.
557 const ARMSubtarget *Subtarget;
559 const TargetRegisterInfo *RegInfo;
561 const InstrItineraryData *Itins;
563 /// ARMPCLabelIndex - Keep track of the number of ARM PC labels created.
565 unsigned ARMPCLabelIndex;
567 // TODO: remove this, and have shouldInsertFencesForAtomic do the proper
569 bool InsertFencesForAtomic;
571 bool HasStandaloneRem = true;
573 void addTypeForNEON(MVT VT, MVT PromotedLdStVT, MVT PromotedBitwiseVT);
574 void addDRTypeForNEON(MVT VT);
575 void addQRTypeForNEON(MVT VT);
576 std::pair<SDValue, SDValue> getARMXALUOOp(SDValue Op, SelectionDAG &DAG, SDValue &ARMcc) const;
578 typedef SmallVector<std::pair<unsigned, SDValue>, 8> RegsToPassVector;
580 void PassF64ArgInRegs(const SDLoc &dl, SelectionDAG &DAG, SDValue Chain,
581 SDValue &Arg, RegsToPassVector &RegsToPass,
582 CCValAssign &VA, CCValAssign &NextVA,
584 SmallVectorImpl<SDValue> &MemOpChains,
585 ISD::ArgFlagsTy Flags) const;
586 SDValue GetF64FormalArgument(CCValAssign &VA, CCValAssign &NextVA,
587 SDValue &Root, SelectionDAG &DAG,
588 const SDLoc &dl) const;
590 CallingConv::ID getEffectiveCallingConv(CallingConv::ID CC,
591 bool isVarArg) const;
592 CCAssignFn *CCAssignFnForNode(CallingConv::ID CC, bool Return,
593 bool isVarArg) const;
594 SDValue LowerMemOpCallTo(SDValue Chain, SDValue StackPtr, SDValue Arg,
595 const SDLoc &dl, SelectionDAG &DAG,
596 const CCValAssign &VA,
597 ISD::ArgFlagsTy Flags) const;
598 SDValue LowerEH_SJLJ_SETJMP(SDValue Op, SelectionDAG &DAG) const;
599 SDValue LowerEH_SJLJ_LONGJMP(SDValue Op, SelectionDAG &DAG) const;
600 SDValue LowerEH_SJLJ_SETUP_DISPATCH(SDValue Op, SelectionDAG &DAG) const;
601 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG,
602 const ARMSubtarget *Subtarget) const;
603 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
604 SDValue LowerGlobalAddressDarwin(SDValue Op, SelectionDAG &DAG) const;
605 SDValue LowerGlobalAddressELF(SDValue Op, SelectionDAG &DAG) const;
606 SDValue LowerGlobalAddressWindows(SDValue Op, SelectionDAG &DAG) const;
607 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
608 SDValue LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
609 SelectionDAG &DAG) const;
610 SDValue LowerToTLSExecModels(GlobalAddressSDNode *GA,
612 TLSModel::Model model) const;
613 SDValue LowerGlobalTLSAddressDarwin(SDValue Op, SelectionDAG &DAG) const;
614 SDValue LowerGlobalTLSAddressWindows(SDValue Op, SelectionDAG &DAG) const;
615 SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const;
616 SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
617 SDValue LowerXALUO(SDValue Op, SelectionDAG &DAG) const;
618 SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
619 SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
620 SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
621 SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) const;
622 SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
623 SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
624 SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG) const;
625 SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
626 SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const;
627 SDValue LowerConstantFP(SDValue Op, SelectionDAG &DAG,
628 const ARMSubtarget *ST) const;
629 SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG,
630 const ARMSubtarget *ST) const;
631 SDValue LowerFSINCOS(SDValue Op, SelectionDAG &DAG) const;
632 SDValue LowerDivRem(SDValue Op, SelectionDAG &DAG) const;
633 SDValue LowerDIV_Windows(SDValue Op, SelectionDAG &DAG, bool Signed) const;
634 void ExpandDIV_Windows(SDValue Op, SelectionDAG &DAG, bool Signed,
635 SmallVectorImpl<SDValue> &Results) const;
636 SDValue LowerWindowsDIVLibCall(SDValue Op, SelectionDAG &DAG, bool Signed,
637 SDValue &Chain) const;
638 SDValue LowerREM(SDNode *N, SelectionDAG &DAG) const;
639 SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
640 SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
641 SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const;
642 SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG) const;
643 SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
645 unsigned getRegisterByName(const char* RegName, EVT VT,
646 SelectionDAG &DAG) const override;
648 /// isFMAFasterThanFMulAndFAdd - Return true if an FMA operation is faster
649 /// than a pair of fmul and fadd instructions. fmuladd intrinsics will be
650 /// expanded to FMAs when this method returns true, otherwise fmuladd is
651 /// expanded to fmul + fadd.
653 /// ARM supports both fused and unfused multiply-add operations; we already
654 /// lower a pair of fmul and fadd to the latter so it's not clear that there
655 /// would be a gain or that the gain would be worthwhile enough to risk
656 /// correctness bugs.
657 bool isFMAFasterThanFMulAndFAdd(EVT VT) const override { return false; }
659 SDValue ReconstructShuffle(SDValue Op, SelectionDAG &DAG) const;
661 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
662 CallingConv::ID CallConv, bool isVarArg,
663 const SmallVectorImpl<ISD::InputArg> &Ins,
664 const SDLoc &dl, SelectionDAG &DAG,
665 SmallVectorImpl<SDValue> &InVals, bool isThisReturn,
666 SDValue ThisVal) const;
668 bool supportSplitCSR(MachineFunction *MF) const override {
669 return MF->getFunction()->getCallingConv() == CallingConv::CXX_FAST_TLS &&
670 MF->getFunction()->hasFnAttribute(Attribute::NoUnwind);
673 void initializeSplitCSR(MachineBasicBlock *Entry) const override;
674 void insertCopiesSplitCSR(
675 MachineBasicBlock *Entry,
676 const SmallVectorImpl<MachineBasicBlock *> &Exits) const override;
679 LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
680 const SmallVectorImpl<ISD::InputArg> &Ins,
681 const SDLoc &dl, SelectionDAG &DAG,
682 SmallVectorImpl<SDValue> &InVals) const override;
684 int StoreByValRegs(CCState &CCInfo, SelectionDAG &DAG, const SDLoc &dl,
685 SDValue &Chain, const Value *OrigArg,
686 unsigned InRegsParamRecordIdx, int ArgOffset,
687 unsigned ArgSize) const;
689 void VarArgStyleRegisters(CCState &CCInfo, SelectionDAG &DAG,
690 const SDLoc &dl, SDValue &Chain,
691 unsigned ArgOffset, unsigned TotalArgRegsSaveSize,
692 bool ForceMutable = false) const;
694 SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
695 SmallVectorImpl<SDValue> &InVals) const override;
697 /// HandleByVal - Target-specific cleanup for ByVal support.
698 void HandleByVal(CCState *, unsigned &, unsigned) const override;
700 /// IsEligibleForTailCallOptimization - Check whether the call is eligible
701 /// for tail call optimization. Targets which want to do tail call
702 /// optimization should implement this function.
703 bool IsEligibleForTailCallOptimization(SDValue Callee,
704 CallingConv::ID CalleeCC,
706 bool isCalleeStructRet,
707 bool isCallerStructRet,
708 const SmallVectorImpl<ISD::OutputArg> &Outs,
709 const SmallVectorImpl<SDValue> &OutVals,
710 const SmallVectorImpl<ISD::InputArg> &Ins,
711 SelectionDAG& DAG) const;
713 bool CanLowerReturn(CallingConv::ID CallConv,
714 MachineFunction &MF, bool isVarArg,
715 const SmallVectorImpl<ISD::OutputArg> &Outs,
716 LLVMContext &Context) const override;
718 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
719 const SmallVectorImpl<ISD::OutputArg> &Outs,
720 const SmallVectorImpl<SDValue> &OutVals,
721 const SDLoc &dl, SelectionDAG &DAG) const override;
723 bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override;
725 bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
727 SDValue getCMOV(const SDLoc &dl, EVT VT, SDValue FalseVal, SDValue TrueVal,
728 SDValue ARMcc, SDValue CCR, SDValue Cmp,
729 SelectionDAG &DAG) const;
730 SDValue getARMCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC,
731 SDValue &ARMcc, SelectionDAG &DAG, const SDLoc &dl) const;
732 SDValue getVFPCmp(SDValue LHS, SDValue RHS, SelectionDAG &DAG,
733 const SDLoc &dl, bool InvalidOnQNaN) const;
734 SDValue duplicateCmp(SDValue Cmp, SelectionDAG &DAG) const;
736 SDValue OptimizeVFPBrcond(SDValue Op, SelectionDAG &DAG) const;
738 void SetupEntryBlockForSjLj(MachineInstr &MI, MachineBasicBlock *MBB,
739 MachineBasicBlock *DispatchBB, int FI) const;
741 void EmitSjLjDispatchBlock(MachineInstr &MI, MachineBasicBlock *MBB) const;
743 bool RemapAddSubWithFlags(MachineInstr &MI, MachineBasicBlock *BB) const;
745 MachineBasicBlock *EmitStructByval(MachineInstr &MI,
746 MachineBasicBlock *MBB) const;
748 MachineBasicBlock *EmitLowered__chkstk(MachineInstr &MI,
749 MachineBasicBlock *MBB) const;
750 MachineBasicBlock *EmitLowered__dbzchk(MachineInstr &MI,
751 MachineBasicBlock *MBB) const;
754 enum NEONModImmType {
762 FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
763 const TargetLibraryInfo *libInfo);
765 } // end namespace ARM
767 } // end namespace llvm
769 #endif // LLVM_LIB_TARGET_ARM_ARMISELLOWERING_H