LLVM  8.0.1
AArch64ISelLowering.h
Go to the documentation of this file.
1 //==-- AArch64ISelLowering.h - AArch64 DAG Lowering Interface ----*- C++ -*-==//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the interfaces that AArch64 uses to lower LLVM code into a
11 // selection DAG.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64ISELLOWERING_H
16 #define LLVM_LIB_TARGET_AARCH64_AARCH64ISELLOWERING_H
17 
18 #include "AArch64.h"
22 #include "llvm/IR/CallingConv.h"
23 #include "llvm/IR/Instruction.h"
24 
25 namespace llvm {
26 
27 namespace AArch64ISD {
28 
29 enum NodeType : unsigned {
31  WrapperLarge, // 4-instruction MOVZ/MOVK sequence for 64-bit addresses.
32  CALL, // Function call.
33 
34  // Produces the full sequence of instructions for getting the thread pointer
35  // offset of a variable into X0, using the TLSDesc model.
37  ADRP, // Page address of a TargetGlobalAddress operand.
38  ADR, // ADR
39  ADDlow, // Add the low 12 bits of a TargetGlobalAddress operand.
40  LOADgot, // Load from automatically generated descriptor (e.g. Global
41  // Offset Table, TLS record).
42  RET_FLAG, // Return with a flag operand. Operand 0 is the chain operand.
43  BRCOND, // Conditional branch instruction; "b.cond".
45  FCSEL, // Conditional move instruction.
46  CSINV, // Conditional select invert.
47  CSNEG, // Conditional select negate.
48  CSINC, // Conditional select increment.
49 
50  // Pointer to the thread's local storage area. Materialised from TPIDR_EL0 on
51  // ELF.
53  ADC,
54  SBC, // adc, sbc instructions
55 
56  // Arithmetic instructions which write flags.
62 
63  // Conditional compares. Operands: left,right,falsecc,cc,flags
67 
68  // Floating point comparison
70 
71  // Scalar extract
73 
74  // Scalar-to-vector duplication
75  DUP,
80 
81  // Vector immedate moves
89 
90  // Vector immediate ops
93 
94  // Vector bit select: similar to ISD::VSELECT but not all bits within an
95  // element must be identical.
96  BSL,
97 
98  // Vector arithmetic negation
99  NEG,
100 
101  // Vector shuffles
112 
113  // Vector shift by scalar
117 
118  // Vector shift by scalar (again)
124 
125  // Vector comparisons
134 
135  // Vector zero comparisons
146 
147  // Vector across-lanes addition
148  // Only the lower result lane is defined.
151 
152  // Vector across-lanes min/max
153  // Only the lower result lane is defined.
158 
159  // Vector bitwise negation
161 
162  // Vector bitwise selection
164 
165  // Compare-and-branch
170 
171  // Tail calls
173 
174  // Custom prefetch handling
176 
177  // {s|u}int to FP within a FP register.
180 
181  /// Natural vector cast. ISD::BITCAST is not natural in the big-endian
182  /// world w.r.t vectors; which causes additional REV instructions to be
183  /// generated to compensate for the byte-swapping. But sometimes we do
184  /// need to re-interpret the data in SIMD vector registers in big-endian
185  /// mode without emitting such REV instructions.
187 
190 
191  // Reciprocal estimates and steps.
194 
195  // NEON Load/Store with post-increment base updates
219 };
220 
221 } // end namespace AArch64ISD
222 
223 namespace {
224 
225 // Any instruction that defines a 32-bit result zeros out the high half of the
226 // register. Truncate can be lowered to EXTRACT_SUBREG. CopyFromReg may
227 // be copying from a truncate. But any other 32-bit operation will zero-extend
228 // up to 64 bits.
229 // FIXME: X86 also checks for CMOV here. Do we need something similar?
230 static inline bool isDef32(const SDNode &N) {
231  unsigned Opc = N.getOpcode();
232  return Opc != ISD::TRUNCATE && Opc != TargetOpcode::EXTRACT_SUBREG &&
233  Opc != ISD::CopyFromReg;
234 }
235 
236 } // end anonymous namespace
237 
238 class AArch64Subtarget;
240 
242 public:
243  explicit AArch64TargetLowering(const TargetMachine &TM,
244  const AArch64Subtarget &STI);
245 
246  /// Selects the correct CCAssignFn for a given CallingConvention value.
247  CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg) const;
248 
249  /// Selects the correct CCAssignFn for a given CallingConvention value.
250  CCAssignFn *CCAssignFnForReturn(CallingConv::ID CC) const;
251 
252  /// Determine which of the bits specified in Mask are known to be either zero
253  /// or one and return them in the KnownZero/KnownOne bitsets.
254  void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known,
255  const APInt &DemandedElts,
256  const SelectionDAG &DAG,
257  unsigned Depth = 0) const override;
258 
259  bool targetShrinkDemandedConstant(SDValue Op, const APInt &Demanded,
260  TargetLoweringOpt &TLO) const override;
261 
262  MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override;
263 
264  /// Returns true if the target allows unaligned memory accesses of the
265  /// specified type.
266  bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace = 0,
267  unsigned Align = 1,
268  bool *Fast = nullptr) const override;
269 
270  /// Provide custom lowering hooks for some operations.
271  SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
272 
273  const char *getTargetNodeName(unsigned Opcode) const override;
274 
275  SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
276 
277  /// Returns true if a cast between SrcAS and DestAS is a noop.
278  bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
279  // Addrspacecasts are always noops.
280  return true;
281  }
282 
283  /// This method returns a target specific FastISel object, or null if the
284  /// target does not support "fast" ISel.
286  const TargetLibraryInfo *libInfo) const override;
287 
288  bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
289 
290  bool isFPImmLegal(const APFloat &Imm, EVT VT) const override;
291 
292  /// Return true if the given shuffle mask can be codegen'd directly, or if it
293  /// should be stack expanded.
294  bool isShuffleMaskLegal(ArrayRef<int> M, EVT VT) const override;
295 
296  /// Return the ISD::SETCC ValueType.
297  EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
298  EVT VT) const override;
299 
300  SDValue ReconstructShuffle(SDValue Op, SelectionDAG &DAG) const;
301 
302  MachineBasicBlock *EmitF128CSEL(MachineInstr &MI,
303  MachineBasicBlock *BB) const;
304 
305  MachineBasicBlock *EmitLoweredCatchRet(MachineInstr &MI,
306  MachineBasicBlock *BB) const;
307 
308  MachineBasicBlock *EmitLoweredCatchPad(MachineInstr &MI,
309  MachineBasicBlock *BB) const;
310 
312  EmitInstrWithCustomInserter(MachineInstr &MI,
313  MachineBasicBlock *MBB) const override;
314 
315  bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
316  MachineFunction &MF,
317  unsigned Intrinsic) const override;
318 
319  bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtTy,
320  EVT NewVT) const override;
321 
322  bool isTruncateFree(Type *Ty1, Type *Ty2) const override;
323  bool isTruncateFree(EVT VT1, EVT VT2) const override;
324 
325  bool isProfitableToHoist(Instruction *I) const override;
326 
327  bool isZExtFree(Type *Ty1, Type *Ty2) const override;
328  bool isZExtFree(EVT VT1, EVT VT2) const override;
329  bool isZExtFree(SDValue Val, EVT VT2) const override;
330 
331  bool hasPairedLoad(EVT LoadedType, unsigned &RequiredAligment) const override;
332 
333  unsigned getMaxSupportedInterleaveFactor() const override { return 4; }
334 
335  bool lowerInterleavedLoad(LoadInst *LI,
337  ArrayRef<unsigned> Indices,
338  unsigned Factor) const override;
339  bool lowerInterleavedStore(StoreInst *SI, ShuffleVectorInst *SVI,
340  unsigned Factor) const override;
341 
342  bool isLegalAddImmediate(int64_t) const override;
343  bool isLegalICmpImmediate(int64_t) const override;
344 
345  bool shouldConsiderGEPOffsetSplit() const override;
346 
347  EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign,
348  bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc,
349  MachineFunction &MF) const override;
350 
351  /// Return true if the addressing mode represented by AM is legal for this
352  /// target, for a load/store of the specified type.
353  bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
354  unsigned AS,
355  Instruction *I = nullptr) const override;
356 
357  /// Return the cost of the scaling factor used in the addressing
358  /// mode represented by AM for this target, for a load/store
359  /// of the specified type.
360  /// If the AM is supported, the return value must be >= 0.
361  /// If the AM is not supported, it returns a negative value.
362  int getScalingFactorCost(const DataLayout &DL, const AddrMode &AM, Type *Ty,
363  unsigned AS) const override;
364 
365  /// Return true if an FMA operation is faster than a pair of fmul and fadd
366  /// instructions. fmuladd intrinsics will be expanded to FMAs when this method
367  /// returns true, otherwise fmuladd is expanded to fmul + fadd.
368  bool isFMAFasterThanFMulAndFAdd(EVT VT) const override;
369 
370  const MCPhysReg *getScratchRegisters(CallingConv::ID CC) const override;
371 
372  /// Returns false if N is a bit extraction pattern of (X >> C) & Mask.
373  bool isDesirableToCommuteWithShift(const SDNode *N,
374  CombineLevel Level) const override;
375 
376  /// Returns true if it is beneficial to convert a load of a constant
377  /// to just the constant itself.
378  bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
379  Type *Ty) const override;
380 
381  /// Return true if EXTRACT_SUBVECTOR is cheap for this result type
382  /// with this index.
383  bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
384  unsigned Index) const override;
385 
386  Value *emitLoadLinked(IRBuilder<> &Builder, Value *Addr,
387  AtomicOrdering Ord) const override;
388  Value *emitStoreConditional(IRBuilder<> &Builder, Value *Val,
389  Value *Addr, AtomicOrdering Ord) const override;
390 
391  void emitAtomicCmpXchgNoStoreLLBalance(IRBuilder<> &Builder) const override;
392 
394  shouldExpandAtomicLoadInIR(LoadInst *LI) const override;
395  bool shouldExpandAtomicStoreInIR(StoreInst *SI) const override;
397  shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override;
398 
400  shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
401 
402  bool useLoadStackGuardNode() const override;
404  getPreferredVectorAction(MVT VT) const override;
405 
406  /// If the target has a standard location for the stack protector cookie,
407  /// returns the address of that location. Otherwise, returns nullptr.
408  Value *getIRStackGuard(IRBuilder<> &IRB) const override;
409 
410  void insertSSPDeclarations(Module &M) const override;
411  Value *getSDagStackGuard(const Module &M) const override;
412  Value *getSSPStackGuardCheck(const Module &M) const override;
413 
414  /// If the target has a standard location for the unsafe stack pointer,
415  /// returns the address of that location. Otherwise, returns nullptr.
416  Value *getSafeStackPointerLocation(IRBuilder<> &IRB) const override;
417 
418  /// If a physical register, this returns the register that receives the
419  /// exception address on entry to an EH pad.
420  unsigned
421  getExceptionPointerRegister(const Constant *PersonalityFn) const override {
422  // FIXME: This is a guess. Has this been defined yet?
423  return AArch64::X0;
424  }
425 
426  /// If a physical register, this returns the register that receives the
427  /// exception typeid on entry to a landing pad.
428  unsigned
429  getExceptionSelectorRegister(const Constant *PersonalityFn) const override {
430  // FIXME: This is a guess. Has this been defined yet?
431  return AArch64::X1;
432  }
433 
434  bool isIntDivCheap(EVT VT, AttributeList Attr) const override;
435 
436  bool canMergeStoresTo(unsigned AddressSpace, EVT MemVT,
437  const SelectionDAG &DAG) const override {
438  // Do not merge to float value size (128 bytes) if no implicit
439  // float attribute is set.
440 
441  bool NoFloat = DAG.getMachineFunction().getFunction().hasFnAttribute(
443 
444  if (NoFloat)
445  return (MemVT.getSizeInBits() <= 64);
446  return true;
447  }
448 
449  bool isCheapToSpeculateCttz() const override {
450  return true;
451  }
452 
453  bool isCheapToSpeculateCtlz() const override {
454  return true;
455  }
456 
457  bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override;
458 
459  bool hasAndNotCompare(SDValue V) const override {
460  // We can use bics for any scalar.
461  return V.getValueType().isScalarInteger();
462  }
463 
464  bool hasAndNot(SDValue Y) const override {
465  EVT VT = Y.getValueType();
466 
467  if (!VT.isVector())
468  return hasAndNotCompare(Y);
469 
470  return VT.getSizeInBits() >= 64; // vector 'bic'
471  }
472 
474  unsigned KeptBits) const override {
475  // For vectors, we don't have a preference..
476  if (XVT.isVector())
477  return false;
478 
479  auto VTIsOk = [](EVT VT) -> bool {
480  return VT == MVT::i8 || VT == MVT::i16 || VT == MVT::i32 ||
481  VT == MVT::i64;
482  };
483 
484  // We are ok with KeptBitsVT being byte/word/dword, what SXT supports.
485  // XVT will be larger than KeptBitsVT.
486  MVT KeptBitsVT = MVT::getIntegerVT(KeptBits);
487  return VTIsOk(XVT) && VTIsOk(KeptBitsVT);
488  }
489 
490  bool hasBitPreservingFPLogic(EVT VT) const override {
491  // FIXME: Is this always true? It should be true for vectors at least.
492  return VT == MVT::f32 || VT == MVT::f64;
493  }
494 
495  bool supportSplitCSR(MachineFunction *MF) const override {
498  }
499  void initializeSplitCSR(MachineBasicBlock *Entry) const override;
500  void insertCopiesSplitCSR(
501  MachineBasicBlock *Entry,
502  const SmallVectorImpl<MachineBasicBlock *> &Exits) const override;
503 
504  bool supportSwiftError() const override {
505  return true;
506  }
507 
508  /// Enable aggressive FMA fusion on targets that want it.
509  bool enableAggressiveFMAFusion(EVT VT) const override;
510 
511  /// Returns the size of the platform's va_list object.
512  unsigned getVaListSizeInBits(const DataLayout &DL) const override;
513 
514  /// Returns true if \p VecTy is a legal interleaved access type. This
515  /// function checks the vector element type and the overall width of the
516  /// vector.
517  bool isLegalInterleavedAccessType(VectorType *VecTy,
518  const DataLayout &DL) const;
519 
520  /// Returns the number of interleaved accesses that will be generated when
521  /// lowering accesses of the given type.
522  unsigned getNumInterleavedAccesses(VectorType *VecTy,
523  const DataLayout &DL) const;
524 
525  MachineMemOperand::Flags getMMOFlags(const Instruction &I) const override;
526 
527  bool functionArgumentNeedsConsecutiveRegisters(Type *Ty,
528  CallingConv::ID CallConv,
529  bool isVarArg) const override;
530  /// Used for exception handling on Win64.
531  bool needsFixedCatchObjects() const override;
532 private:
533  /// Keep a pointer to the AArch64Subtarget around so that we can
534  /// make the right decision when generating code for different targets.
535  const AArch64Subtarget *Subtarget;
536 
537  bool isExtFreeImpl(const Instruction *Ext) const override;
538 
539  void addTypeForNEON(MVT VT, MVT PromotedBitwiseVT);
540  void addDRTypeForNEON(MVT VT);
541  void addQRTypeForNEON(MVT VT);
542 
543  SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
544  bool isVarArg,
546  const SDLoc &DL, SelectionDAG &DAG,
547  SmallVectorImpl<SDValue> &InVals) const override;
548 
549  SDValue LowerCall(CallLoweringInfo & /*CLI*/,
550  SmallVectorImpl<SDValue> &InVals) const override;
551 
552  SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
553  CallingConv::ID CallConv, bool isVarArg,
555  const SDLoc &DL, SelectionDAG &DAG,
556  SmallVectorImpl<SDValue> &InVals, bool isThisReturn,
557  SDValue ThisVal) const;
558 
559  SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
560 
561  SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
562 
563  bool isEligibleForTailCallOptimization(
564  SDValue Callee, CallingConv::ID CalleeCC, bool isVarArg,
566  const SmallVectorImpl<SDValue> &OutVals,
567  const SmallVectorImpl<ISD::InputArg> &Ins, SelectionDAG &DAG) const;
568 
569  /// Finds the incoming stack arguments which overlap the given fixed stack
570  /// object and incorporates their load into the current chain. This prevents
571  /// an upcoming store from clobbering the stack argument before it's used.
572  SDValue addTokenForArgument(SDValue Chain, SelectionDAG &DAG,
573  MachineFrameInfo &MFI, int ClobberedFI) const;
574 
575  bool DoesCalleeRestoreStack(CallingConv::ID CallCC, bool TailCallOpt) const;
576 
577  void saveVarArgRegisters(CCState &CCInfo, SelectionDAG &DAG, const SDLoc &DL,
578  SDValue &Chain) const;
579 
580  bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
581  bool isVarArg,
583  LLVMContext &Context) const override;
584 
585  SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
587  const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
588  SelectionDAG &DAG) const override;
589 
590  SDValue getTargetNode(GlobalAddressSDNode *N, EVT Ty, SelectionDAG &DAG,
591  unsigned Flag) const;
592  SDValue getTargetNode(JumpTableSDNode *N, EVT Ty, SelectionDAG &DAG,
593  unsigned Flag) const;
594  SDValue getTargetNode(ConstantPoolSDNode *N, EVT Ty, SelectionDAG &DAG,
595  unsigned Flag) const;
596  SDValue getTargetNode(BlockAddressSDNode *N, EVT Ty, SelectionDAG &DAG,
597  unsigned Flag) const;
598  template <class NodeTy>
599  SDValue getGOT(NodeTy *N, SelectionDAG &DAG, unsigned Flags = 0) const;
600  template <class NodeTy>
601  SDValue getAddrLarge(NodeTy *N, SelectionDAG &DAG, unsigned Flags = 0) const;
602  template <class NodeTy>
603  SDValue getAddr(NodeTy *N, SelectionDAG &DAG, unsigned Flags = 0) const;
604  template <class NodeTy>
605  SDValue getAddrTiny(NodeTy *N, SelectionDAG &DAG, unsigned Flags = 0) const;
606  SDValue LowerADDROFRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
607  SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
608  SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
609  SDValue LowerDarwinGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
610  SDValue LowerELFGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
611  SDValue LowerELFTLSDescCallSeq(SDValue SymAddr, const SDLoc &DL,
612  SelectionDAG &DAG) const;
613  SDValue LowerWindowsGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
614  SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
615  SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
616  SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
617  SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
619  SDValue TVal, SDValue FVal, const SDLoc &dl,
620  SelectionDAG &DAG) const;
621  SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
622  SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
623  SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
624  SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
625  SDValue LowerAAPCS_VASTART(SDValue Op, SelectionDAG &DAG) const;
626  SDValue LowerDarwin_VASTART(SDValue Op, SelectionDAG &DAG) const;
627  SDValue LowerWin64_VASTART(SDValue Op, SelectionDAG &DAG) const;
628  SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
629  SDValue LowerVACOPY(SDValue Op, SelectionDAG &DAG) const;
630  SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) const;
631  SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
632  SDValue LowerSPONENTRY(SDValue Op, SelectionDAG &DAG) const;
634  SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const;
638  SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
641  SDValue LowerVectorSRA_SRL_SHL(SDValue Op, SelectionDAG &DAG) const;
642  SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
643  SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG) const;
644  SDValue LowerVSETCC(SDValue Op, SelectionDAG &DAG) const;
645  SDValue LowerCTPOP(SDValue Op, SelectionDAG &DAG) const;
646  SDValue LowerF128Call(SDValue Op, SelectionDAG &DAG,
647  RTLIB::Libcall Call) const;
648  SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) const;
649  SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const;
650  SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
651  SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG) const;
652  SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
653  SDValue LowerVectorAND(SDValue Op, SelectionDAG &DAG) const;
654  SDValue LowerVectorOR(SDValue Op, SelectionDAG &DAG) const;
656  SDValue LowerFSINCOS(SDValue Op, SelectionDAG &DAG) const;
657  SDValue LowerVECREDUCE(SDValue Op, SelectionDAG &DAG) const;
658  SDValue LowerATOMIC_LOAD_SUB(SDValue Op, SelectionDAG &DAG) const;
659  SDValue LowerATOMIC_LOAD_AND(SDValue Op, SelectionDAG &DAG) const;
661  SDValue LowerWindowsDYNAMIC_STACKALLOC(SDValue Op, SDValue Chain,
662  SDValue &Size,
663  SelectionDAG &DAG) const;
664 
665  SDValue BuildSDIVPow2(SDNode *N, const APInt &Divisor, SelectionDAG &DAG,
666  SmallVectorImpl<SDNode *> &Created) const override;
667  SDValue getSqrtEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled,
668  int &ExtraSteps, bool &UseOneConst,
669  bool Reciprocal) const override;
670  SDValue getRecipEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled,
671  int &ExtraSteps) const override;
672  unsigned combineRepeatedFPDivisors() const override;
673 
674  ConstraintType getConstraintType(StringRef Constraint) const override;
675  unsigned getRegisterByName(const char* RegName, EVT VT,
676  SelectionDAG &DAG) const override;
677 
678  /// Examine constraint string and operand type and determine a weight value.
679  /// The operand object must already have been set up with the operand type.
681  getSingleConstraintMatchWeight(AsmOperandInfo &info,
682  const char *constraint) const override;
683 
684  std::pair<unsigned, const TargetRegisterClass *>
685  getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
686  StringRef Constraint, MVT VT) const override;
687 
688  const char *LowerXConstraint(EVT ConstraintVT) const override;
689 
690  void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
691  std::vector<SDValue> &Ops,
692  SelectionDAG &DAG) const override;
693 
694  unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
695  if (ConstraintCode == "Q")
697  // FIXME: clang has code for 'Ump', 'Utf', 'Usa', and 'Ush' but these are
698  // followed by llvm_unreachable so we'll leave them unimplemented in
699  // the backend for now.
700  return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
701  }
702 
703  bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override;
704  bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
705  bool getIndexedAddressParts(SDNode *Op, SDValue &Base, SDValue &Offset,
706  ISD::MemIndexedMode &AM, bool &IsInc,
707  SelectionDAG &DAG) const;
708  bool getPreIndexedAddressParts(SDNode *N, SDValue &Base, SDValue &Offset,
710  SelectionDAG &DAG) const override;
711  bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, SDValue &Base,
712  SDValue &Offset, ISD::MemIndexedMode &AM,
713  SelectionDAG &DAG) const override;
714 
715  void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
716  SelectionDAG &DAG) const override;
717 
718  bool shouldNormalizeToSelectSequence(LLVMContext &, EVT) const override;
719 
720  void finalizeLowering(MachineFunction &MF) const override;
721 };
722 
723 namespace AArch64 {
725  const TargetLibraryInfo *libInfo);
726 } // end namespace AArch64
727 
728 } // end namespace llvm
729 
730 #endif
static SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG)
static MVT getIntegerVT(unsigned BitWidth)
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:877
unsigned getExceptionSelectorRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception typeid on entry to a la...
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
EVT getValueType() const
Return the ValueType of the referenced return value.
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg If BaseGV is null...
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
LLVMContext & Context
bool supportSplitCSR(MachineFunction *MF) const override
Return true if the target supports that a subset of CSRs for the given machine function is handled ex...
This class represents lattice values for constants.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
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:529
static SDValue LowerVACOPY(SDValue Op, const X86Subtarget &Subtarget, SelectionDAG &DAG)
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.
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit...
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:321
unsigned const TargetRegisterInfo * TRI
An instruction for reading from memory.
Definition: Instructions.h:168
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
Definition: Instructions.h:692
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
bool hasAndNotCompare(SDValue V) const override
Return true if the target should transform: (X & Y) == Y —> (~X & Y) == 0 (X & Y) != Y —> (~X & Y) ...
bool supportSwiftError() const override
Return true if the target supports swifterror attribute.
A convenience struct that encapsulates a DAG, and two SDValues for returning information from TargetL...
static SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:743
static SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG, const SparcTargetLowering &TLI, const SparcSubtarget *Subtarget)
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override
Returns true if a cast between SrcAS and DestAS is a noop.
AtomicOrdering
Atomic ordering for LLVM&#39;s memory model.
static SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG)
Fast - This calling convention attempts to make calls as fast as possible (e.g.
Definition: CallingConv.h:43
This is a fast-path instruction selection class that generates poor code and doesn&#39;t support illegal ...
Definition: FastISel.h:67
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
Definition: ValueTypes.h:292
MachineFunction & getMachineFunction() const
Definition: SelectionDAG.h:398
static SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG)
This contains information for each constraint that we are lowering.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
An instruction for storing to memory.
Definition: Instructions.h:321
Natural vector cast.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
Definition: ISDOpcodes.h:959
virtual unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const
static SDValue LowerVSETCC(SDValue Op, SelectionDAG &DAG)
FastISel * createFastISel(FunctionLoweringInfo &funcInfo, const TargetLibraryInfo *libInfo)
amdgpu Simplify well known AMD library false Value * Callee
Analysis containing CSE Info
Definition: CSEInfo.cpp:21
unsigned getExceptionPointerRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception address on entry to an ...
static SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:118
static SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG)
Machine Value Type.
static SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG)
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:69
This is an important base class in LLVM.
Definition: Constant.h:42
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
Definition: ISDOpcodes.h:934
CombineLevel
Definition: DAGCombine.h:16
static SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG, const SparcSubtarget *Subtarget)
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...
This structure contains all information that is necessary for lowering calls.
static Value * LowerCTPOP(LLVMContext &Context, Value *V, Instruction *IP)
Emit the code to lower ctpop of V before the specified instruction IP.
CCState - This class holds information needed while lowering arguments and return values...
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Definition: Function.h:213
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:222
Provides information about what library functions are available for the current target.
AddressSpace
Definition: NVPTXBaseInfo.h:22
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
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:884
Represents one node in the SelectionDAG.
static bool Enabled
Definition: Statistic.cpp:51
const Function & getFunction() const
Return the LLVM function that this machine code represents.
bool hasBitPreservingFPLogic(EVT VT) const override
Return true if it is safe to transform an integer-domain bitwise operation into the equivalent floati...
Class to represent vector types.
Definition: DerivedTypes.h:393
Class for arbitrary precision integers.
Definition: APInt.h:70
bool canMergeStoresTo(unsigned AddressSpace, EVT MemVT, const SelectionDAG &DAG) const override
Returns if it&#39;s reasonable to merge stores to MemVT size.
static SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG)
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 LowerEXTRACT_SUBVECTOR(SDValue Op, const X86Subtarget &Subtarget, SelectionDAG &DAG)
static SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG, const SparcTargetLowering &TLI, bool hasHardQuad)
Representation of each machine instruction.
Definition: MachineInstr.h:64
static unsigned getScalingFactorCost(const TargetTransformInfo &TTI, const LSRUse &LU, const Formula &F, const Loop &L)
bool isVector() const
Return true if this is a vector value type.
Definition: ValueTypes.h:151
#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:47
bool hasAndNot(SDValue Y) const override
Return true if the target has a bitwise and-not operation: X = ~A & B This can be used to simplify se...
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
Definition: ISDOpcodes.h:175
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
LLVM Value Representation.
Definition: Value.h:73
static SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG)
bool shouldTransformSignedTruncationCheck(EVT XVT, unsigned KeptBits) const override
Should we tranform the IR-optimal check for whether given truncation down into KeptBits would be trun...
unsigned getMaxSupportedInterleaveFactor() const override
Get the maximum supported factor for interleaved memory accesses.
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:59
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
static SDValue LowerFSINCOS(SDValue Op, const X86Subtarget &Subtarget, SelectionDAG &DAG)
bool isCheapToSpeculateCttz() const override
Return true if it is cheap to speculate a call to intrinsic cttz.
TRUNCATE - Completely drop the high bits.
Definition: ISDOpcodes.h:474
bool isCheapToSpeculateCtlz() const override
Return true if it is cheap to speculate a call to intrinsic ctlz.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
static SDValue LowerSCALAR_TO_VECTOR(SDValue Op, const X86Subtarget &Subtarget, SelectionDAG &DAG)
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:914