LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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_TARGET_AARCH64_ISELLOWERING_H
16 #define LLVM_TARGET_AARCH64_ISELLOWERING_H
17 
18 #include "Utils/AArch64BaseInfo.h"
22 #include "llvm/IR/Intrinsics.h"
23 
24 namespace llvm {
25 namespace AArch64ISD {
26  enum NodeType {
27  // Start the numbering from where ISD NodeType finishes.
29 
30  // This is a conditional branch which also notes the flag needed
31  // (eq/sgt/...). A64 puts this information on the branches rather than
32  // compares as LLVM does.
34 
35  // A node to be selected to an actual call operation: either BL or BLR in
36  // the absence of tail calls.
38 
39  // Indicates a floating-point immediate which fits into the format required
40  // by the FMOV instructions. First (and only) operand is the 8-bit encoded
41  // value of that immediate.
43 
44  // Corresponds directly to an EXTR instruction. Operands are an LHS an RHS
45  // and an LSB.
47 
48  // Wraps a load from the GOT, which should always be performed with a 64-bit
49  // load instruction. This prevents the DAG combiner folding a truncate to
50  // form a smaller memory access.
52 
53  // Performs a bitfield insert. Arguments are: the value being inserted into;
54  // the value being inserted; least significant bit changed; width of the
55  // field.
56  BFI,
57 
58  // Simply a convenient node inserted during ISelLowering to represent
59  // procedure return. Will almost certainly be selected to "RET".
60  Ret,
61 
62  /// Extracts a field of contiguous bits from the source and sign extends
63  /// them into a single register. Arguments are: source; immr; imms. Note
64  /// these are pre-encoded since DAG matching can't cope with combining LSB
65  /// and Width into these values itself.
67 
68  /// This is an A64-ification of the standard LLVM SELECT_CC operation. The
69  /// main difference is that it only has the values and an A64 condition,
70  /// which will be produced by a setcc instruction.
72 
73  /// This serves most of the functions of the LLVM SETCC instruction, for two
74  /// purposes. First, it prevents optimisations from fiddling with the
75  /// compare after we've moved the CondCode information onto the SELECT_CC or
76  /// BR_CC instructions. Second, it gives a legal instruction for the actual
77  /// comparison.
78  ///
79  /// It keeps a record of the condition flags asked for because certain
80  /// instructions are only valid for a subset of condition codes.
82 
83  // Designates a node which is a tail call: both a call and a return
84  // instruction as far as selction is concerned. It should be selected to an
85  // unconditional branch. Has the usual plethora of call operands, but: 1st
86  // is callee, 2nd is stack adjustment required immediately before branch.
88 
89  // Designates a call used to support the TLS descriptor ABI. The call itself
90  // will be indirect ("BLR xN") but a relocation-specifier (".tlsdesccall
91  // var") must be attached somehow during code generation. It takes two
92  // operands: the callee and the symbol to be relocated against.
94 
95  // Leaf node which will be lowered to an appropriate MRS to obtain the
96  // thread pointer: TPIDR_EL0.
98 
99  /// Extracts a field of contiguous bits from the source and zero extends
100  /// them into a single register. Arguments are: source; immr; imms. Note
101  /// these are pre-encoded since DAG matching can't cope with combining LSB
102  /// and Width into these values itself.
104 
105  // Wraps an address which the ISelLowering phase has decided should be
106  // created using the large memory model style: i.e. a sequence of four
107  // movz/movk instructions.
109 
110  // Wraps an address which the ISelLowering phase has decided should be
111  // created using the small memory model style: i.e. adrp/add or
112  // adrp/mem-op. This exists to prevent bare TargetAddresses which may never
113  // get selected.
115 
116  // Vector bitwise select
118 
119  // Vector move immediate
121 
122  // Vector Move Inverted Immediate
124 
125  // Vector FP move immediate
127 
128  // Vector permute
135 
136  // Vector Element reverse
140 
141  // Vector compare
143 
144  // Vector compare zero
146 
147  // Vector compare bitwise test
149 
150  // Vector saturating shift
153 
154  // Vector dup
156 
157  // Vector dup by lane
159 
160  // Vector extract
162 
163  // NEON duplicate lane loads
167 
168  // NEON loads with post-increment base updates:
176 
177  // NEON stores with post-increment base updates:
185 
186  // NEON duplicate lane loads with post-increment base updates:
190 
191  // NEON lane loads with post-increment base updates:
195 
196  // NEON lane store with post-increment base updates:
200  };
201 }
202 
203 
204 class AArch64Subtarget;
205 class AArch64TargetMachine;
206 
208 public:
210 
211  const char *getTargetNodeName(unsigned Opcode) const;
212 
214 
216  CallingConv::ID CallConv, bool isVarArg,
218  SDLoc dl, SelectionDAG &DAG,
219  SmallVectorImpl<SDValue> &InVals) const;
220 
222  CallingConv::ID CallConv, bool isVarArg,
224  const SmallVectorImpl<SDValue> &OutVals,
225  SDLoc dl, SelectionDAG &DAG) const;
226 
228  SmallVectorImpl<SDValue> &InVals) const;
229 
230  SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
231  CallingConv::ID CallConv, bool IsVarArg,
233  SDLoc dl, SelectionDAG &DAG,
234  SmallVectorImpl<SDValue> &InVals) const;
235 
236  bool isKnownShuffleVector(SDValue Op, SelectionDAG &DAG, SDValue &Res) const;
237 
239  const AArch64Subtarget *ST) const;
240 
242 
243  void SaveVarArgRegisters(CCState &CCInfo, SelectionDAG &DAG, SDLoc DL,
244  SDValue &Chain) const;
245 
246  /// IsEligibleForTailCallOptimization - Check whether the call is eligible
247  /// for tail call optimization. Targets which want to do tail call
248  /// optimization should implement this function.
250  CallingConv::ID CalleeCC,
251  bool IsVarArg,
252  bool IsCalleeStructRet,
253  bool IsCallerStructRet,
255  const SmallVectorImpl<SDValue> &OutVals,
257  SelectionDAG& DAG) const;
258 
259  /// Finds the incoming stack arguments which overlap the given fixed stack
260  /// object and incorporates their load into the current chain. This prevents
261  /// an upcoming store from clobbering the stack argument before it's used.
263  MachineFrameInfo *MFI, int ClobberedFI) const;
264 
265  EVT getSetCCResultType(LLVMContext &Context, EVT VT) const;
266 
267  bool DoesCalleeRestoreStack(CallingConv::ID CallCC, bool TailCallOpt) const;
268 
269  bool IsTailCallConvention(CallingConv::ID CallCC) const;
270 
271  SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
272 
273  bool isLegalICmpImmediate(int64_t Val) const;
275  SDValue &A64cc, SelectionDAG &DAG, SDLoc &dl) const;
276 
277  virtual MachineBasicBlock *
279 
282  unsigned Size, unsigned Opcode) const;
283 
286  unsigned Size, unsigned CmpOp,
287  A64CC::CondCodes Cond) const;
290  unsigned Size) const;
291 
294 
298  SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
299  SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
301  RTLIB::Libcall Call) const;
302  SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const;
303  SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
304  SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG, bool IsSigned) const;
306  SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
307 
311 
312  SDValue LowerTLSDescCall(SDValue SymAddr, SDValue DescAddr, SDLoc DL,
313  SelectionDAG &DAG) const;
315  SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG, bool IsSigned) const;
316  SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
317  SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
318  SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
319  SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
320  SDValue LowerVACOPY(SDValue Op, SelectionDAG &DAG) const;
321  SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
322 
323  virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
324 
325  /// isFMAFasterThanFMulAndFAdd - Return true if an FMA operation is faster
326  /// than a pair of fmul and fadd instructions. fmuladd intrinsics will be
327  /// expanded to FMAs when this method returns true, otherwise fmuladd is
328  /// expanded to fmul + fadd.
329  virtual bool isFMAFasterThanFMulAndFAdd(EVT VT) const;
330 
331  ConstraintType getConstraintType(const std::string &Constraint) const;
332 
334  const char *Constraint) const;
336  std::string &Constraint,
337  std::vector<SDValue> &Ops,
338  SelectionDAG &DAG) const;
339 
340  std::pair<unsigned, const TargetRegisterClass*>
341  getRegForInlineAsmConstraint(const std::string &Constraint, MVT VT) const;
342 
343  virtual bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
344  unsigned Intrinsic) const LLVM_OVERRIDE;
345 
346 private:
347  const InstrItineraryData *Itins;
348 
349  const AArch64Subtarget *getSubtarget() const {
351  }
352 };
356 };
357 
358 extern SDValue ScanBUILD_VECTOR(SDValue Op, bool &isOnlyLowElement,
359  bool &usesOnlyOneValue, bool &hasDominantValue,
360  bool &isConstant, bool &isUNDEF);
361 } // namespace llvm
362 
363 #endif // LLVM_TARGET_AARCH64_ISELLOWERING_H
AArch64TargetLowering(AArch64TargetMachine &TM)
SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const
MachineBasicBlock * emitAtomicBinaryMinMax(MachineInstr *MI, MachineBasicBlock *BB, unsigned Size, unsigned CmpOp, A64CC::CondCodes Cond) const
virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const
void SaveVarArgRegisters(CCState &CCInfo, SelectionDAG &DAG, SDLoc DL, SDValue &Chain) const
SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const
virtual bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I, unsigned Intrinsic) const LLVM_OVERRIDE
const TargetMachine & getTargetMachine() const
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, SDLoc dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const
SDValue ScanBUILD_VECTOR(SDValue Op, bool &isOnlyLowElement, bool &usesOnlyOneValue, bool &hasDominantValue, bool &isConstant, bool &isUNDEF)
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const
SDValue LowerTLSDescCall(SDValue SymAddr, SDValue DescAddr, SDLoc DL, SelectionDAG &DAG) const
SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG, const AArch64Subtarget *ST) const
SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const
SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const
SDValue LowerGlobalAddressELFLarge(SDValue Op, SelectionDAG &DAG) const
SDValue getSelectableIntSetCC(SDValue LHS, SDValue RHS, ISD::CondCode CC, SDValue &A64cc, SelectionDAG &DAG, SDLoc &dl) const
CCAssignFn * CCAssignFnForNode(CallingConv::ID CC) const
const char * getTargetNodeName(unsigned Opcode) const
This method returns the name of a target specific DAG node.
SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const
SDValue addTokenForArgument(SDValue Chain, SelectionDAG &DAG, MachineFrameInfo *MFI, int ClobberedFI) const
Abstract Stack Frame Information.
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const std::string &Constraint, MVT VT) const
bool isKnownShuffleVector(SDValue Op, SelectionDAG &DAG, SDValue &Res) const
ID
LLVM Calling Convention Representation.
Definition: CallingConv.h:26
MachineBasicBlock * emitAtomicBinary(MachineInstr *MI, MachineBasicBlock *MBB, unsigned Size, unsigned Opcode) const
This contains information for each constraint that we are lowering.
SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const
SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const
SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const
SDValue LowerATOMIC_STORE(SDValue Op, SelectionDAG &DAG) const
virtual MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr *MI, MachineBasicBlock *MBB) const
SDValue LowerCallResult(SDValue Chain, SDValue InFlag, CallingConv::ID CallConv, bool IsVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, SDLoc dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const
SDValue LowerCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const
SDValue LowerGlobalAddressELF(SDValue Op, SelectionDAG &DAG) const
ConstraintType getConstraintType(const std::string &Constraint) const
Given a constraint, return the type of constraint it is for this target.
SDValue LowerF128ToCall(SDValue Op, SelectionDAG &DAG, RTLIB::Libcall Call) const
virtual bool isFMAFasterThanFMulAndFAdd(EVT VT) const
bool IsEligibleForTailCallOptimization(SDValue Callee, CallingConv::ID CalleeCC, bool IsVarArg, bool IsCalleeStructRet, bool IsCallerStructRet, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SmallVectorImpl< ISD::InputArg > &Ins, SelectionDAG &DAG) const
const STC & getSubtarget() const
ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &Info, const char *Constraint) const
MachineBasicBlock * emitAtomicCmpSwap(MachineInstr *MI, MachineBasicBlock *BB, unsigned Size) const
static const int FIRST_TARGET_MEMORY_OPCODE
Definition: ISDOpcodes.h:648
bool isLegalICmpImmediate(int64_t Val) const
MachineBasicBlock * EmitF128CSEL(MachineInstr *MI, MachineBasicBlock *MBB) const
SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const
SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, SDLoc dl, SelectionDAG &DAG) const
#define I(x, y, z)
Definition: MD5.cpp:54
#define N
SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG, bool IsSigned) const
SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const
SDValue LowerGlobalAddressELFSmall(SDValue Op, SelectionDAG &DAG) const
SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG, bool IsSigned) const
bool IsTailCallConvention(CallingConv::ID CallCC) const
SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const
SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const
bool DoesCalleeRestoreStack(CallingConv::ID CallCC, bool TailCallOpt) const
SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG &DAG) const
EVT getSetCCResultType(LLVMContext &Context, EVT VT) const
#define LLVM_OVERRIDE
Definition: Compiler.h:155
SDValue LowerVACOPY(SDValue Op, SelectionDAG &DAG) const