LLVM  10.0.0
ARMISelLowering.h
Go to the documentation of this file.
1 //===- ARMISelLowering.h - ARM DAG Lowering Interface -----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the interfaces that ARM uses to lower LLVM code into a
10 // selection DAG.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_ARM_ARMISELLOWERING_H
15 #define LLVM_LIB_TARGET_ARM_ARMISELLOWERING_H
16 
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/StringRef.h"
26 #include "llvm/IR/Attributes.h"
27 #include "llvm/IR/CallingConv.h"
28 #include "llvm/IR/Function.h"
29 #include "llvm/IR/IRBuilder.h"
30 #include "llvm/IR/InlineAsm.h"
31 #include "llvm/Support/CodeGen.h"
33 #include <utility>
34 
35 namespace llvm {
36 
37 class ARMSubtarget;
38 class DataLayout;
39 class FastISel;
40 class FunctionLoweringInfo;
41 class GlobalValue;
42 class InstrItineraryData;
43 class Instruction;
44 class MachineBasicBlock;
45 class MachineInstr;
46 class SelectionDAG;
47 class TargetLibraryInfo;
48 class TargetMachine;
49 class TargetRegisterInfo;
50 class VectorType;
51 
52  namespace ARMISD {
53 
54  // ARM Specific DAG Nodes
55  enum NodeType : unsigned {
56  // Start the numbering where the builtin ops and target ops leave off.
58 
59  Wrapper, // Wrapper - A wrapper node for TargetConstantPool,
60  // TargetExternalSymbol, and TargetGlobalAddress.
61  WrapperPIC, // WrapperPIC - A wrapper node for TargetGlobalAddress in
62  // PIC mode.
63  WrapperJT, // WrapperJT - A wrapper node for TargetJumpTable
64 
65  // Add pseudo op to model memcpy for struct byval.
67 
68  CALL, // Function call.
69  CALL_PRED, // Function call that's predicable.
70  CALL_NOLINK, // Function call with branch not branch-and-link.
71  BRCOND, // Conditional branch.
72  BR_JT, // Jumptable branch.
73  BR2_JT, // Jumptable branch (2 level - jumptable entry is a jump).
74  RET_FLAG, // Return with a flag operand.
75  INTRET_FLAG, // Interrupt return with an LR-offset and a flag operand.
76 
77  PIC_ADD, // Add with a PC operand and a PIC label.
78 
79  ASRL, // MVE long arithmetic shift right.
80  LSRL, // MVE long shift right.
81  LSLL, // MVE long shift left.
82 
83  CMP, // ARM compare instructions.
84  CMN, // ARM CMN instructions.
85  CMPZ, // ARM compare that sets only Z flag.
86  CMPFP, // ARM VFP compare instruction, sets FPSCR.
87  CMPFPE, // ARM VFP signalling compare instruction, sets FPSCR.
88  CMPFPw0, // ARM VFP compare against zero instruction, sets FPSCR.
89  CMPFPEw0, // ARM VFP signalling compare against zero instruction, sets FPSCR.
90  FMSTAT, // ARM fmstat instruction.
91 
92  CMOV, // ARM conditional move instructions.
93  SUBS, // Flag-setting subtraction.
94 
95  SSAT, // Signed saturation
96  USAT, // Unsigned saturation
97 
99 
100  SRL_FLAG, // V,Flag = srl_flag X -> srl X, 1 + save carry out.
101  SRA_FLAG, // V,Flag = sra_flag X -> sra X, 1 + save carry out.
102  RRX, // V = RRX X, Flag -> srl X, 1 + shift in carry flag.
103 
104  ADDC, // Add with carry
105  ADDE, // Add using carry
106  SUBC, // Sub with carry
107  SUBE, // Sub using carry
108  LSLS, // Shift left producing carry
109 
110  VMOVRRD, // double to two gprs.
111  VMOVDRR, // Two gprs to double.
112  VMOVSR, // move gpr to single, used for f32 literal constructed in a gpr
113 
114  EH_SJLJ_SETJMP, // SjLj exception handling setjmp.
115  EH_SJLJ_LONGJMP, // SjLj exception handling longjmp.
116  EH_SJLJ_SETUP_DISPATCH, // SjLj exception handling setup_dispatch.
117 
118  TC_RETURN, // Tail call return pseudo.
119 
121 
122  DYN_ALLOC, // Dynamic allocation on the stack.
123 
124  MEMBARRIER_MCR, // Memory barrier (MCR)
125 
126  PRELOAD, // Preload
127 
128  WIN__CHKSTK, // Windows' __chkstk call to do stack probing.
129  WIN__DBZCHK, // Windows' divide by zero check
130 
131  WLS, // Low-overhead loops, While Loop Start
132  LOOP_DEC, // Really a part of LE, performs the sub
133  LE, // Low-overhead loops, Loop End
134 
135  PREDICATE_CAST, // Predicate cast for MVE i1 types
136 
137  VCMP, // Vector compare.
138  VCMPZ, // Vector compare to zero.
139  VTST, // Vector test bits.
140 
141  // Vector shift by vector
142  VSHLs, // ...left/right by signed
143  VSHLu, // ...left/right by unsigned
144 
145  // Vector shift by immediate:
146  VSHLIMM, // ...left
147  VSHRsIMM, // ...right (signed)
148  VSHRuIMM, // ...right (unsigned)
149 
150  // Vector rounding shift by immediate:
151  VRSHRsIMM, // ...right (signed)
152  VRSHRuIMM, // ...right (unsigned)
153  VRSHRNIMM, // ...right narrow
154 
155  // Vector saturating shift by immediate:
156  VQSHLsIMM, // ...left (signed)
157  VQSHLuIMM, // ...left (unsigned)
158  VQSHLsuIMM, // ...left (signed to unsigned)
159  VQSHRNsIMM, // ...right narrow (signed)
160  VQSHRNuIMM, // ...right narrow (unsigned)
161  VQSHRNsuIMM, // ...right narrow (signed to unsigned)
162 
163  // Vector saturating rounding shift by immediate:
164  VQRSHRNsIMM, // ...right narrow (signed)
165  VQRSHRNuIMM, // ...right narrow (unsigned)
166  VQRSHRNsuIMM, // ...right narrow (signed to unsigned)
167 
168  // Vector shift and insert:
169  VSLIIMM, // ...left
170  VSRIIMM, // ...right
171 
172  // Vector get lane (VMOV scalar to ARM core register)
173  // (These are used for 8- and 16-bit element types only.)
174  VGETLANEu, // zero-extend vector extract element
175  VGETLANEs, // sign-extend vector extract element
176 
177  // Vector move immediate and move negated immediate:
180 
181  // Vector move f32 immediate:
183 
184  // Move H <-> R, clearing top 16 bits
187 
188  // Vector duplicate:
191 
192  // Vector shuffles:
193  VEXT, // extract
194  VREV64, // reverse elements within 64-bit doublewords
195  VREV32, // reverse elements within 32-bit words
196  VREV16, // reverse elements within 16-bit halfwords
197  VZIP, // zip (interleave)
198  VUZP, // unzip (deinterleave)
199  VTRN, // transpose
200  VTBL1, // 1-register shuffle with mask
201  VTBL2, // 2-register shuffle with mask
202  VMOVN, // MVE vmovn
203 
204  // Vector multiply long:
205  VMULLs, // ...signed
206  VMULLu, // ...unsigned
207 
208  SMULWB, // Signed multiply word by half word, bottom
209  SMULWT, // Signed multiply word by half word, top
210  UMLAL, // 64bit Unsigned Accumulate Multiply
211  SMLAL, // 64bit Signed Accumulate Multiply
212  UMAAL, // 64-bit Unsigned Accumulate Accumulate Multiply
213  SMLALBB, // 64-bit signed accumulate multiply bottom, bottom 16
214  SMLALBT, // 64-bit signed accumulate multiply bottom, top 16
215  SMLALTB, // 64-bit signed accumulate multiply top, bottom 16
216  SMLALTT, // 64-bit signed accumulate multiply top, top 16
217  SMLALD, // Signed multiply accumulate long dual
218  SMLALDX, // Signed multiply accumulate long dual exchange
219  SMLSLD, // Signed multiply subtract long dual
220  SMLSLDX, // Signed multiply subtract long dual exchange
221  SMMLAR, // Signed multiply long, round and add
222  SMMLSR, // Signed multiply long, subtract and round
223 
224  // Single Lane QADD8 and QADD16. Only the bottom lane. That's what the b stands for.
229 
230  // Operands of the standard BUILD_VECTOR node are not legalized, which
231  // is fine if BUILD_VECTORs are always lowered to shuffles or other
232  // operations, but for ARM some BUILD_VECTORs are legal as-is and their
233  // operands need to be legalized. Define an ARM-specific version of
234  // BUILD_VECTOR for this purpose.
236 
237  // Bit-field insert
239 
240  // Vector OR with immediate
242  // Vector AND with NOT of immediate
244 
245  // Vector bitwise select
247 
248  // Pseudo-instruction representing a memory copy using ldm/stm
249  // instructions.
251 
252  // V8.1MMainline condition select
253  CSINV, // Conditional select invert.
254  CSNEG, // Conditional select negate.
255  CSINC, // Conditional select increment.
256 
257  // Vector load N-element structure to all lanes:
262 
263  // NEON loads with post-increment base updates:
275 
276  // NEON stores with post-increment base updates:
284  };
285 
286  } // end namespace ARMISD
287 
288  /// Define some predicates that are used for node matching.
289  namespace ARM {
290 
291  bool isBitFieldInvertedMask(unsigned v);
292 
293  } // end namespace ARM
294 
295  //===--------------------------------------------------------------------===//
296  // ARMTargetLowering - ARM Implementation of the TargetLowering interface
297 
299  public:
300  explicit ARMTargetLowering(const TargetMachine &TM,
301  const ARMSubtarget &STI);
302 
303  unsigned getJumpTableEncoding() const override;
304  bool useSoftFloat() const override;
305 
306  SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
307 
308  /// ReplaceNodeResults - Replace the results of node with an illegal result
309  /// type with new values built out of custom code.
310  void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
311  SelectionDAG &DAG) const override;
312 
313  const char *getTargetNodeName(unsigned Opcode) const override;
314 
315  bool isSelectSupported(SelectSupportKind Kind) const override {
316  // ARM does not support scalar condition selects on vectors.
317  return (Kind != ScalarCondVectorVal);
318  }
319 
320  bool isReadOnly(const GlobalValue *GV) const;
321 
322  /// getSetCCResultType - Return the value type to use for ISD::SETCC.
323  EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
324  EVT VT) const override;
325 
327  EmitInstrWithCustomInserter(MachineInstr &MI,
328  MachineBasicBlock *MBB) const override;
329 
330  void AdjustInstrPostInstrSelection(MachineInstr &MI,
331  SDNode *Node) const override;
332 
333  SDValue PerformCMOVCombine(SDNode *N, SelectionDAG &DAG) const;
334  SDValue PerformBRCONDCombine(SDNode *N, SelectionDAG &DAG) const;
335  SDValue PerformCMOVToBFICombine(SDNode *N, SelectionDAG &DAG) const;
336  SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
337 
338  bool isDesirableToTransformToIntegerOp(unsigned Opc, EVT VT) const override;
339 
340  /// allowsMisalignedMemoryAccesses - Returns true if the target allows
341  /// unaligned memory accesses of the specified type. Returns whether it
342  /// is "fast" by reference in the second argument.
343  bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace,
344  unsigned Align,
346  bool *Fast) const override;
347 
348  EVT getOptimalMemOpType(uint64_t Size,
349  unsigned DstAlign, unsigned SrcAlign,
350  bool IsMemset, bool ZeroMemset,
351  bool MemcpyStrSrc,
352  const AttributeList &FuncAttributes) const override;
353 
354  bool isTruncateFree(Type *SrcTy, Type *DstTy) const override;
355  bool isTruncateFree(EVT SrcVT, EVT DstVT) const override;
356  bool isZExtFree(SDValue Val, EVT VT2) const override;
357  bool shouldSinkOperands(Instruction *I,
358  SmallVectorImpl<Use *> &Ops) const override;
359 
360  bool isFNegFree(EVT VT) const override;
361 
362  bool isVectorLoadExtDesirable(SDValue ExtVal) const override;
363 
364  bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override;
365 
366 
367  /// isLegalAddressingMode - Return true if the addressing mode represented
368  /// by AM is legal for this target, for a load/store of the specified type.
369  bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
370  Type *Ty, unsigned AS,
371  Instruction *I = nullptr) const override;
372 
373  /// getScalingFactorCost - Return the cost of the scaling used in
374  /// addressing mode represented by AM.
375  /// If the AM is supported, the return value must be >= 0.
376  /// If the AM is not supported, the return value must be negative.
377  int getScalingFactorCost(const DataLayout &DL, const AddrMode &AM, Type *Ty,
378  unsigned AS) const override;
379 
380  bool isLegalT2ScaledAddressingMode(const AddrMode &AM, EVT VT) const;
381 
382  /// Returns true if the addressing mode representing by AM is legal
383  /// for the Thumb1 target, for a load/store of the specified type.
384  bool isLegalT1ScaledAddressingMode(const AddrMode &AM, EVT VT) const;
385 
386  /// isLegalICmpImmediate - Return true if the specified immediate is legal
387  /// icmp immediate, that is the target has icmp instructions which can
388  /// compare a register against the immediate without having to materialize
389  /// the immediate into a register.
390  bool isLegalICmpImmediate(int64_t Imm) const override;
391 
392  /// isLegalAddImmediate - Return true if the specified immediate is legal
393  /// add immediate, that is the target has add instructions which can
394  /// add a register and the immediate without having to materialize
395  /// the immediate into a register.
396  bool isLegalAddImmediate(int64_t Imm) const override;
397 
398  /// getPreIndexedAddressParts - returns true by value, base pointer and
399  /// offset pointer and addressing mode by reference if the node's address
400  /// can be legally represented as pre-indexed load / store address.
401  bool getPreIndexedAddressParts(SDNode *N, SDValue &Base, SDValue &Offset,
403  SelectionDAG &DAG) const override;
404 
405  /// getPostIndexedAddressParts - returns true by value, base pointer and
406  /// offset pointer and addressing mode by reference if this node can be
407  /// combined with a load / store to form a post-indexed load / store.
408  bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, SDValue &Base,
409  SDValue &Offset, ISD::MemIndexedMode &AM,
410  SelectionDAG &DAG) const override;
411 
412  void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known,
413  const APInt &DemandedElts,
414  const SelectionDAG &DAG,
415  unsigned Depth) const override;
416 
417  bool targetShrinkDemandedConstant(SDValue Op, const APInt &Demanded,
418  TargetLoweringOpt &TLO) const override;
419 
420 
421  bool ExpandInlineAsm(CallInst *CI) const override;
422 
423  ConstraintType getConstraintType(StringRef Constraint) const override;
424 
425  /// Examine constraint string and operand type and determine a weight value.
426  /// The operand object must already have been set up with the operand type.
427  ConstraintWeight getSingleConstraintMatchWeight(
428  AsmOperandInfo &info, const char *constraint) const override;
429 
430  std::pair<unsigned, const TargetRegisterClass *>
431  getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
432  StringRef Constraint, MVT VT) const override;
433 
434  const char *LowerXConstraint(EVT ConstraintVT) const override;
435 
436  /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
437  /// vector. If it is invalid, don't add anything to Ops. If hasMemory is
438  /// true it means one of the asm constraint of the inline asm instruction
439  /// being processed is 'm'.
440  void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
441  std::vector<SDValue> &Ops,
442  SelectionDAG &DAG) const override;
443 
444  unsigned
445  getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
446  if (ConstraintCode == "Q")
448  else if (ConstraintCode == "o")
450  else if (ConstraintCode.size() == 2) {
451  if (ConstraintCode[0] == 'U') {
452  switch(ConstraintCode[1]) {
453  default:
454  break;
455  case 'm':
457  case 'n':
459  case 'q':
461  case 's':
463  case 't':
465  case 'v':
467  case 'y':
469  }
470  }
471  }
472  return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
473  }
474 
475  const ARMSubtarget* getSubtarget() const {
476  return Subtarget;
477  }
478 
479  /// getRegClassFor - Return the register class that should be used for the
480  /// specified value type.
481  const TargetRegisterClass *
482  getRegClassFor(MVT VT, bool isDivergent = false) const override;
483 
484  /// Returns true if a cast between SrcAS and DestAS is a noop.
485  bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
486  // Addrspacecasts are always noops.
487  return true;
488  }
489 
490  bool shouldAlignPointerArgs(CallInst *CI, unsigned &MinSize,
491  unsigned &PrefAlign) const override;
492 
493  /// createFastISel - This method returns a target specific FastISel object,
494  /// or null if the target does not support "fast" ISel.
496  const TargetLibraryInfo *libInfo) const override;
497 
498  Sched::Preference getSchedulingPreference(SDNode *N) const override;
499 
500  bool
501  isShuffleMaskLegal(ArrayRef<int> M, EVT VT) const override;
502  bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
503 
504  /// isFPImmLegal - Returns true if the target can instruction select the
505  /// specified FP immediate natively. If false, the legalizer will
506  /// materialize the FP immediate as a load from a constant pool.
507  bool isFPImmLegal(const APFloat &Imm, EVT VT,
508  bool ForCodeSize = false) const override;
509 
510  bool getTgtMemIntrinsic(IntrinsicInfo &Info,
511  const CallInst &I,
512  MachineFunction &MF,
513  unsigned Intrinsic) const override;
514 
515  /// Returns true if it is beneficial to convert a load of a constant
516  /// to just the constant itself.
517  bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
518  Type *Ty) const override;
519 
520  /// Return true if EXTRACT_SUBVECTOR is cheap for this result type
521  /// with this index.
522  bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
523  unsigned Index) const override;
524 
525  /// Returns true if an argument of type Ty needs to be passed in a
526  /// contiguous block of registers in calling convention CallConv.
527  bool functionArgumentNeedsConsecutiveRegisters(
528  Type *Ty, CallingConv::ID CallConv, bool isVarArg) const override;
529 
530  /// If a physical register, this returns the register that receives the
531  /// exception address on entry to an EH pad.
532  unsigned
533  getExceptionPointerRegister(const Constant *PersonalityFn) const override;
534 
535  /// If a physical register, this returns the register that receives the
536  /// exception typeid on entry to a landing pad.
537  unsigned
538  getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
539 
540  Instruction *makeDMB(IRBuilder<> &Builder, ARM_MB::MemBOpt Domain) const;
541  Value *emitLoadLinked(IRBuilder<> &Builder, Value *Addr,
542  AtomicOrdering Ord) const override;
543  Value *emitStoreConditional(IRBuilder<> &Builder, Value *Val,
544  Value *Addr, AtomicOrdering Ord) const override;
545 
546  void emitAtomicCmpXchgNoStoreLLBalance(IRBuilder<> &Builder) const override;
547 
548  Instruction *emitLeadingFence(IRBuilder<> &Builder, Instruction *Inst,
549  AtomicOrdering Ord) const override;
550  Instruction *emitTrailingFence(IRBuilder<> &Builder, Instruction *Inst,
551  AtomicOrdering Ord) const override;
552 
553  unsigned getMaxSupportedInterleaveFactor() const override;
554 
555  bool lowerInterleavedLoad(LoadInst *LI,
557  ArrayRef<unsigned> Indices,
558  unsigned Factor) const override;
559  bool lowerInterleavedStore(StoreInst *SI, ShuffleVectorInst *SVI,
560  unsigned Factor) const override;
561 
562  bool shouldInsertFencesForAtomic(const Instruction *I) const override;
564  shouldExpandAtomicLoadInIR(LoadInst *LI) const override;
565  bool shouldExpandAtomicStoreInIR(StoreInst *SI) const override;
567  shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override;
569  shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
570 
571  bool useLoadStackGuardNode() const override;
572 
573  void insertSSPDeclarations(Module &M) const override;
574  Value *getSDagStackGuard(const Module &M) const override;
575  Function *getSSPStackGuardCheck(const Module &M) const override;
576 
577  bool canCombineStoreAndExtract(Type *VectorTy, Value *Idx,
578  unsigned &Cost) const override;
579 
580  bool canMergeStoresTo(unsigned AddressSpace, EVT MemVT,
581  const SelectionDAG &DAG) const override {
582  // Do not merge to larger than i32.
583  return (MemVT.getSizeInBits() <= 32);
584  }
585 
586  bool isCheapToSpeculateCttz() const override;
587  bool isCheapToSpeculateCtlz() const override;
588 
589  bool convertSetCCLogicToBitwiseLogic(EVT VT) const override {
590  return VT.isScalarInteger();
591  }
592 
593  bool supportSwiftError() const override {
594  return true;
595  }
596 
597  bool hasStandaloneRem(EVT VT) const override {
598  return HasStandaloneRem;
599  }
600 
601  bool shouldExpandShift(SelectionDAG &DAG, SDNode *N) const override;
602 
603  CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool isVarArg) const;
604  CCAssignFn *CCAssignFnForReturn(CallingConv::ID CC, bool isVarArg) const;
605 
606  /// Returns true if \p VecTy is a legal interleaved access type. This
607  /// function checks the vector element type and the overall width of the
608  /// vector.
609  bool isLegalInterleavedAccessType(unsigned Factor, VectorType *VecTy,
610  const DataLayout &DL) const;
611 
612  bool alignLoopsWithOptSize() const override;
613 
614  /// Returns the number of interleaved accesses that will be generated when
615  /// lowering accesses of the given type.
616  unsigned getNumInterleavedAccesses(VectorType *VecTy,
617  const DataLayout &DL) const;
618 
619  void finalizeLowering(MachineFunction &MF) const override;
620 
621  /// Return the correct alignment for the current calling convention.
622  Align getABIAlignmentForCallingConv(Type *ArgTy,
623  DataLayout DL) const override;
624 
625  bool isDesirableToCommuteWithShift(const SDNode *N,
626  CombineLevel Level) const override;
627 
628  bool shouldFoldConstantShiftPairToMask(const SDNode *N,
629  CombineLevel Level) const override;
630 
631  bool preferIncOfAddToSubOfNot(EVT VT) const override;
632 
633  protected:
634  std::pair<const TargetRegisterClass *, uint8_t>
635  findRepresentativeClass(const TargetRegisterInfo *TRI,
636  MVT VT) const override;
637 
638  private:
639  /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
640  /// make the right decision when generating code for different targets.
641  const ARMSubtarget *Subtarget;
642 
644 
645  const InstrItineraryData *Itins;
646 
647  /// ARMPCLabelIndex - Keep track of the number of ARM PC labels created.
648  unsigned ARMPCLabelIndex;
649 
650  // TODO: remove this, and have shouldInsertFencesForAtomic do the proper
651  // check.
652  bool InsertFencesForAtomic;
653 
654  bool HasStandaloneRem = true;
655 
656  void addTypeForNEON(MVT VT, MVT PromotedLdStVT, MVT PromotedBitwiseVT);
657  void addDRTypeForNEON(MVT VT);
658  void addQRTypeForNEON(MVT VT);
659  std::pair<SDValue, SDValue> getARMXALUOOp(SDValue Op, SelectionDAG &DAG, SDValue &ARMcc) const;
660 
662 
663  void PassF64ArgInRegs(const SDLoc &dl, SelectionDAG &DAG, SDValue Chain,
664  SDValue &Arg, RegsToPassVector &RegsToPass,
665  CCValAssign &VA, CCValAssign &NextVA,
666  SDValue &StackPtr,
667  SmallVectorImpl<SDValue> &MemOpChains,
668  ISD::ArgFlagsTy Flags) const;
669  SDValue GetF64FormalArgument(CCValAssign &VA, CCValAssign &NextVA,
670  SDValue &Root, SelectionDAG &DAG,
671  const SDLoc &dl) const;
672 
673  CallingConv::ID getEffectiveCallingConv(CallingConv::ID CC,
674  bool isVarArg) const;
675  CCAssignFn *CCAssignFnForNode(CallingConv::ID CC, bool Return,
676  bool isVarArg) const;
677  SDValue LowerMemOpCallTo(SDValue Chain, SDValue StackPtr, SDValue Arg,
678  const SDLoc &dl, SelectionDAG &DAG,
679  const CCValAssign &VA,
680  ISD::ArgFlagsTy Flags) const;
681  SDValue LowerEH_SJLJ_SETJMP(SDValue Op, SelectionDAG &DAG) const;
682  SDValue LowerEH_SJLJ_LONGJMP(SDValue Op, SelectionDAG &DAG) const;
683  SDValue LowerEH_SJLJ_SETUP_DISPATCH(SDValue Op, SelectionDAG &DAG) const;
684  SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG,
685  const ARMSubtarget *Subtarget) const;
686  SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG,
687  const ARMSubtarget *Subtarget) const;
688  SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
689  SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
690  SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
691  SDValue LowerGlobalAddressDarwin(SDValue Op, SelectionDAG &DAG) const;
692  SDValue LowerGlobalAddressELF(SDValue Op, SelectionDAG &DAG) const;
693  SDValue LowerGlobalAddressWindows(SDValue Op, SelectionDAG &DAG) const;
694  SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
695  SDValue LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
696  SelectionDAG &DAG) const;
697  SDValue LowerToTLSExecModels(GlobalAddressSDNode *GA,
698  SelectionDAG &DAG,
699  TLSModel::Model model) const;
700  SDValue LowerGlobalTLSAddressDarwin(SDValue Op, SelectionDAG &DAG) const;
701  SDValue LowerGlobalTLSAddressWindows(SDValue Op, SelectionDAG &DAG) const;
702  SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const;
703  SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
704  SDValue LowerSignedALUO(SDValue Op, SelectionDAG &DAG) const;
705  SDValue LowerUnsignedALUO(SDValue Op, SelectionDAG &DAG) const;
706  SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
707  SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
708  SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
709  SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
710  SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) const;
712  SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
713  SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG) const;
714  SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
715  SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const;
716  SDValue LowerConstantFP(SDValue Op, SelectionDAG &DAG,
717  const ARMSubtarget *ST) const;
718  SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG,
719  const ARMSubtarget *ST) const;
720  SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
721  SDValue LowerFSINCOS(SDValue Op, SelectionDAG &DAG) const;
722  SDValue LowerDivRem(SDValue Op, SelectionDAG &DAG) const;
723  SDValue LowerDIV_Windows(SDValue Op, SelectionDAG &DAG, bool Signed) const;
724  void ExpandDIV_Windows(SDValue Op, SelectionDAG &DAG, bool Signed,
725  SmallVectorImpl<SDValue> &Results) const;
726  SDValue LowerWindowsDIVLibCall(SDValue Op, SelectionDAG &DAG, bool Signed,
727  SDValue &Chain) const;
728  SDValue LowerREM(SDNode *N, SelectionDAG &DAG) const;
730  SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
731  SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const;
732  SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG) const;
733  SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
734  SDValue LowerFSETCC(SDValue Op, SelectionDAG &DAG) const;
735  void lowerABS(SDNode *N, SmallVectorImpl<SDValue> &Results,
736  SelectionDAG &DAG) const;
737 
738  Register getRegisterByName(const char* RegName, LLT VT,
739  const MachineFunction &MF) const override;
740 
741  SDValue BuildSDIVPow2(SDNode *N, const APInt &Divisor, SelectionDAG &DAG,
742  SmallVectorImpl<SDNode *> &Created) const override;
743 
744  bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
745  EVT VT) const override;
746 
747  SDValue ReconstructShuffle(SDValue Op, SelectionDAG &DAG) const;
748 
749  SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
750  CallingConv::ID CallConv, bool isVarArg,
752  const SDLoc &dl, SelectionDAG &DAG,
753  SmallVectorImpl<SDValue> &InVals, bool isThisReturn,
754  SDValue ThisVal) const;
755 
756  bool supportSplitCSR(MachineFunction *MF) const override {
758  MF->getFunction().hasFnAttribute(Attribute::NoUnwind);
759  }
760 
761  void initializeSplitCSR(MachineBasicBlock *Entry) const override;
762  void insertCopiesSplitCSR(
763  MachineBasicBlock *Entry,
764  const SmallVectorImpl<MachineBasicBlock *> &Exits) const override;
765 
766  SDValue
767  LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
769  const SDLoc &dl, SelectionDAG &DAG,
770  SmallVectorImpl<SDValue> &InVals) const override;
771 
772  int StoreByValRegs(CCState &CCInfo, SelectionDAG &DAG, const SDLoc &dl,
773  SDValue &Chain, const Value *OrigArg,
774  unsigned InRegsParamRecordIdx, int ArgOffset,
775  unsigned ArgSize) const;
776 
777  void VarArgStyleRegisters(CCState &CCInfo, SelectionDAG &DAG,
778  const SDLoc &dl, SDValue &Chain,
779  unsigned ArgOffset, unsigned TotalArgRegsSaveSize,
780  bool ForceMutable = false) const;
781 
783  SmallVectorImpl<SDValue> &InVals) const override;
784 
785  /// HandleByVal - Target-specific cleanup for ByVal support.
786  void HandleByVal(CCState *, unsigned &, unsigned) const override;
787 
788  /// IsEligibleForTailCallOptimization - Check whether the call is eligible
789  /// for tail call optimization. Targets which want to do tail call
790  /// optimization should implement this function.
791  bool IsEligibleForTailCallOptimization(
792  SDValue Callee, CallingConv::ID CalleeCC, bool isVarArg,
793  bool isCalleeStructRet, bool isCallerStructRet,
795  const SmallVectorImpl<SDValue> &OutVals,
797  const bool isIndirect) const;
798 
799  bool CanLowerReturn(CallingConv::ID CallConv,
800  MachineFunction &MF, bool isVarArg,
802  LLVMContext &Context) const override;
803 
804  SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
806  const SmallVectorImpl<SDValue> &OutVals,
807  const SDLoc &dl, SelectionDAG &DAG) const override;
808 
809  bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override;
810 
811  bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
812 
813  bool shouldConsiderGEPOffsetSplit() const override { return true; }
814 
815  bool isUnsupportedFloatingType(EVT VT) const;
816 
817  SDValue getCMOV(const SDLoc &dl, EVT VT, SDValue FalseVal, SDValue TrueVal,
818  SDValue ARMcc, SDValue CCR, SDValue Cmp,
819  SelectionDAG &DAG) const;
820  SDValue getARMCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC,
821  SDValue &ARMcc, SelectionDAG &DAG, const SDLoc &dl) const;
822  SDValue getVFPCmp(SDValue LHS, SDValue RHS, SelectionDAG &DAG,
823  const SDLoc &dl, bool Signaling = false) const;
824  SDValue duplicateCmp(SDValue Cmp, SelectionDAG &DAG) const;
825 
826  SDValue OptimizeVFPBrcond(SDValue Op, SelectionDAG &DAG) const;
827 
828  void SetupEntryBlockForSjLj(MachineInstr &MI, MachineBasicBlock *MBB,
829  MachineBasicBlock *DispatchBB, int FI) const;
830 
831  void EmitSjLjDispatchBlock(MachineInstr &MI, MachineBasicBlock *MBB) const;
832 
833  bool RemapAddSubWithFlags(MachineInstr &MI, MachineBasicBlock *BB) const;
834 
835  MachineBasicBlock *EmitStructByval(MachineInstr &MI,
836  MachineBasicBlock *MBB) const;
837 
838  MachineBasicBlock *EmitLowered__chkstk(MachineInstr &MI,
839  MachineBasicBlock *MBB) const;
840  MachineBasicBlock *EmitLowered__dbzchk(MachineInstr &MI,
841  MachineBasicBlock *MBB) const;
842  void addMVEVectorTypes(bool HasMVEFP);
843  void addAllExtLoads(const MVT From, const MVT To, LegalizeAction Action);
844  void setAllExpand(MVT VT);
845  };
846 
852  };
853 
854  namespace ARM {
855 
857  const TargetLibraryInfo *libInfo);
858 
859  } // end namespace ARM
860 
861 } // end namespace llvm
862 
863 #endif // LLVM_LIB_TARGET_ARM_ARMISELLOWERING_H
static SDValue LowerCallResult(SDValue Chain, SDValue InFlag, const SmallVectorImpl< CCValAssign > &RVLocs, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals)
LowerCallResult - Lower the result values of a call into the appropriate copies out of appropriate ph...
BUILTIN_OP_END - This must be the last enum value in this list.
Definition: ISDOpcodes.h:943
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg If BaseGV is null...
LLVMContext & Context
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:66
An instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
Definition: Instructions.h:547
static void LowerMemOpCallTo(SelectionDAG &DAG, MachineFunction &MF, SDValue Chain, SDValue Arg, SDValue PtrOff, int SPDiff, unsigned ArgOffset, bool isPPC64, bool isTailCall, bool isVector, SmallVectorImpl< SDValue > &MemOpChains, SmallVectorImpl< TailCallArgumentInfo > &TailCallArguments, const SDLoc &dl)
LowerMemOpCallTo - Store the argument to the stack or remember it in case of tail calls...
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
Definition: ValueTypes.h:146
This class represents a function call, abstracting a target machine&#39;s calling convention.
bool hasStandaloneRem(EVT VT) const override
Return true if the target can handle a standalone remainder operation.
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change...
Function Alias Analysis Results
This instruction constructs a fixed permutation of two input vectors.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:323
unsigned const TargetRegisterInfo * TRI
An instruction for reading from memory.
Definition: Instructions.h:169
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
Definition: Instructions.h:710
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override
Returns true if a cast between SrcAS and DestAS is a noop.
A convenience struct that encapsulates a DAG, and two SDValues for returning information from TargetL...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
This file contains the simple types necessary to represent the attributes associated with functions a...
static SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG, const SparcTargetLowering &TLI, const SparcSubtarget *Subtarget)
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
AtomicOrdering
Atomic ordering for LLVM&#39;s memory model.
This is a fast-path instruction selection class that generates poor code and doesn&#39;t support illegal ...
Definition: FastISel.h:66
This contains information for each constraint that we are lowering.
LLVM_NODISCARD size_t size() const
size - Get the string size.
Definition: StringRef.h:151
Itinerary data supplied by a subtarget to be used by a target.
An instruction for storing to memory.
Definition: Instructions.h:331
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
Definition: ISDOpcodes.h:1047
virtual unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const
Analysis containing CSE Info
Definition: CSEInfo.cpp:25
Machine Value Type.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:63
This is an important base class in LLVM.
Definition: Constant.h:41
CombineLevel
Definition: DAGCombine.h:15
static SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG, const SparcSubtarget *Subtarget)
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
const ARMSubtarget * getSubtarget() const
static SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG, const SparcSubtarget *Subtarget)
lazy value info
Extended Value Type.
Definition: ValueTypes.h:34
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
Definition: ValueTypes.h:298
This structure contains all information that is necessary for lowering calls.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:40
bool canMergeStoresTo(unsigned AddressSpace, EVT MemVT, const SelectionDAG &DAG) const override
Returns if it&#39;s reasonable to merge stores to MemVT size.
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
CCState - This class holds information needed while lowering arguments and return values...
BlockVerifier::State From
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Definition: Function.h:212
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:223
bool supportSwiftError() const override
Return true if the target supports swifterror attribute.
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:837
Provides information about what library functions are available for the current target.
CCValAssign - Represent assignment of one arg/retval to a location.
AddressSpace
Definition: NVPTXBaseInfo.h:21
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const override
static const int FIRST_TARGET_MEMORY_OPCODE
FIRST_TARGET_MEMORY_OPCODE - Target-specific pre-isel operations which do not reference a specific me...
Definition: ISDOpcodes.h:955
Represents one node in the SelectionDAG.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
Class to represent vector types.
Definition: DerivedTypes.h:432
Class for arbitrary precision integers.
Definition: APInt.h:69
amdgpu Simplify well known AMD library false FunctionCallee Callee
static SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG, const SparcTargetLowering &TLI, bool hasHardQuad)
Flags
Flags values. These may be or&#39;d together.
static SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG, const SparcTargetLowering &TLI, bool hasHardQuad)
Representation of each machine instruction.
Definition: MachineInstr.h:63
static unsigned getScalingFactorCost(const TargetTransformInfo &TTI, const LSRUse &LU, const Formula &F, const Loop &L)
SelectSupportKind
Enum that describes what type of support for selects the target has.
#define I(x, y, z)
Definition: MD5.cpp:58
#define N
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
uint32_t Size
Definition: Profile.cpp:46
bool isSelectSupported(SelectSupportKind Kind) const override
FastISel * createFastISel(FunctionLoweringInfo &funcInfo, const TargetLibraryInfo *libInfo)
LLVM Value Representation.
Definition: Value.h:74
Fast - This calling convention attempts to make calls as fast as possible (e.g.
Definition: CallingConv.h:42
static SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG)
bool convertSetCCLogicToBitwiseLogic(EVT VT) const override
Use bitwise logic to make pairs of compares more efficient.
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:65
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:54
static SDValue LowerFSINCOS(SDValue Op, const X86Subtarget &Subtarget, SelectionDAG &DAG)
bool isBitFieldInvertedMask(unsigned v)
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
This file describes how to lower LLVM code to machine code.
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
Definition: ISDOpcodes.h:985