LLVM  13.0.0git
CallLowering.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/GlobalISel/CallLowering.h - Call lowering ---*- 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 /// \file
10 /// This file describes how to lower LLVM calls to machine code calls.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
15 #define LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
16 
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/SmallVector.h"
23 #include "llvm/IR/Attributes.h"
24 #include "llvm/IR/CallingConv.h"
25 #include "llvm/IR/Type.h"
26 #include "llvm/IR/Value.h"
29 #include <cstdint>
30 #include <functional>
31 
32 namespace llvm {
33 
34 class CallBase;
35 class DataLayout;
36 class Function;
37 class FunctionLoweringInfo;
38 class MachineIRBuilder;
39 struct MachinePointerInfo;
40 class MachineRegisterInfo;
41 class TargetLowering;
42 
43 class CallLowering {
44  const TargetLowering *TLI;
45 
46  virtual void anchor();
47 public:
48  struct BaseArgInfo {
49  Type *Ty;
51  bool IsFixed;
52 
55  bool IsFixed = true)
56  : Ty(Ty), Flags(Flags.begin(), Flags.end()), IsFixed(IsFixed) {}
57 
58  BaseArgInfo() : Ty(nullptr), IsFixed(false) {}
59  };
60 
61  struct ArgInfo : public BaseArgInfo {
63  // If the argument had to be split into multiple parts according to the
64  // target calling convention, then this contains the original vregs
65  // if the argument was an incoming arg.
67 
68  /// Optionally track the original IR value for the argument. This may not be
69  /// meaningful in all contexts. This should only be used on for forwarding
70  /// through to use for aliasing information in MachinePointerInfo for memory
71  /// arguments.
72  const Value *OrigValue = nullptr;
73 
76  bool IsFixed = true, const Value *OrigValue = nullptr)
79  if (!Regs.empty() && Flags.empty())
80  this->Flags.push_back(ISD::ArgFlagsTy());
81  // FIXME: We should have just one way of saying "no register".
82  assert(((Ty->isVoidTy() || Ty->isEmptyTy()) ==
83  (Regs.empty() || Regs[0] == 0)) &&
84  "only void types should have no register");
85  }
86 
89  bool IsFixed = true)
91 
93  };
94 
96  /// Calling convention to be used for the call.
98 
99  /// Destination of the call. It should be either a register, globaladdress,
100  /// or externalsymbol.
102 
103  /// Descriptor for the return type of the function.
105 
106  /// List of descriptors of the arguments passed to the function.
108 
109  /// Valid if the call has a swifterror inout parameter, and contains the
110  /// vreg that the swifterror should be copied into after the call.
112 
113  MDNode *KnownCallees = nullptr;
114 
115  /// True if the call must be tail call optimized.
116  bool IsMustTailCall = false;
117 
118  /// True if the call passes all target-independent checks for tail call
119  /// optimization.
120  bool IsTailCall = false;
121 
122  /// True if the call was lowered as a tail call. This is consumed by the
123  /// legalizer. This allows the legalizer to lower libcalls as tail calls.
124  bool LoweredTailCall = false;
125 
126  /// True if the call is to a vararg function.
127  bool IsVarArg = false;
128 
129  /// True if the function's return value can be lowered to registers.
130  bool CanLowerReturn = true;
131 
132  /// VReg to hold the hidden sret parameter.
134 
135  /// The stack index for sret demotion.
137  };
138 
139  /// Argument handling is mostly uniform between the four places that
140  /// make these decisions: function formal arguments, call
141  /// instruction args, call instruction returns and function
142  /// returns. However, once a decision has been made on where an
143  /// argument should go, exactly what happens can vary slightly. This
144  /// class abstracts the differences.
145  struct ValueHandler {
149  IsIncomingArgumentHandler(IsIncoming) {}
150 
151  virtual ~ValueHandler() = default;
152 
153  /// Returns true if the handler is dealing with incoming arguments,
154  /// i.e. those that move values from some physical location to vregs.
156  return IsIncomingArgumentHandler;
157  }
158 
159  /// Materialize a VReg containing the address of the specified
160  /// stack-based object. This is either based on a FrameIndex or
161  /// direct SP manipulation, depending on the context. \p MPO
162  /// should be initialized to an appropriate description of the
163  /// address created.
164  virtual Register getStackAddress(uint64_t Size, int64_t Offset,
165  MachinePointerInfo &MPO,
166  ISD::ArgFlagsTy Flags) = 0;
167 
168  /// The specified value has been assigned to a physical register,
169  /// handle the appropriate COPY (either to or from) and mark any
170  /// relevant uses/defines as needed.
171  virtual void assignValueToReg(Register ValVReg, Register PhysReg,
172  CCValAssign &VA) = 0;
173 
174  /// The specified value has been assigned to a stack
175  /// location. Load or store it there, with appropriate extension
176  /// if necessary.
177  virtual void assignValueToAddress(Register ValVReg, Register Addr,
178  uint64_t Size, MachinePointerInfo &MPO,
179  CCValAssign &VA) = 0;
180 
181  /// An overload which takes an ArgInfo if additional information about the
182  /// arg is needed. \p ValRegIndex is the index in \p Arg.Regs for the value
183  /// to store.
184  virtual void assignValueToAddress(const ArgInfo &Arg, unsigned ValRegIndex,
185  Register Addr, uint64_t Size,
186  MachinePointerInfo &MPO,
187  CCValAssign &VA) {
188  assignValueToAddress(Arg.Regs[ValRegIndex], Addr, Size, MPO, VA);
189  }
190 
191  /// Handle custom values, which may be passed into one or more of \p VAs.
192  /// \return The number of \p VAs that have been assigned after the first
193  /// one, and which should therefore be skipped from further
194  /// processing.
195  virtual unsigned assignCustomValue(const ArgInfo &Arg,
196  ArrayRef<CCValAssign> VAs) {
197  // This is not a pure virtual method because not all targets need to worry
198  // about custom values.
199  llvm_unreachable("Custom values not supported");
200  }
201 
202  /// Do a memory copy of \p MemSize bytes from \p SrcPtr to \p DstPtr. This
203  /// is necessary for outgoing stack-passed byval arguments.
204  void
205  copyArgumentMemory(const ArgInfo &Arg, Register DstPtr, Register SrcPtr,
206  const MachinePointerInfo &DstPtrInfo, Align DstAlign,
207  const MachinePointerInfo &SrcPtrInfo, Align SrcAlign,
208  uint64_t MemSize, CCValAssign &VA) const;
209 
210  /// Extend a register to the location type given in VA, capped at extending
211  /// to at most MaxSize bits. If MaxSizeBits is 0 then no maximum is set.
213  unsigned MaxSizeBits = 0);
214 
215  virtual bool assignArg(unsigned ValNo, MVT ValVT, MVT LocVT,
216  CCValAssign::LocInfo LocInfo, const ArgInfo &Info,
217  ISD::ArgFlagsTy Flags, CCState &State) {
218  return AssignFn(ValNo, ValVT, LocVT, LocInfo, Flags, State);
219  }
220 
224 
225  private:
226  bool IsIncomingArgumentHandler;
227  virtual void anchor();
228  };
229 
234 
235  /// Insert G_ASSERT_ZEXT/G_ASSERT_SEXT or other hint instruction based on \p
236  /// VA, returning the new register if a hint was inserted.
237  Register buildExtensionHint(CCValAssign &VA, Register SrcReg, LLT NarrowTy);
238 
239  /// Provides a default implementation for argument handling.
240  void assignValueToReg(Register ValVReg, Register PhysReg,
241  CCValAssign &VA) override;
242  };
243 
248  };
249 
250 protected:
251  /// Getter for generic TargetLowering class.
252  const TargetLowering *getTLI() const {
253  return TLI;
254  }
255 
256  /// Getter for target specific TargetLowering class.
257  template <class XXXTargetLowering>
258  const XXXTargetLowering *getTLI() const {
259  return static_cast<const XXXTargetLowering *>(TLI);
260  }
261 
262  /// \returns Flags corresponding to the attributes on the \p ArgIdx-th
263  /// parameter of \p Call.
265  unsigned ArgIdx) const;
266 
267  /// Adds flags to \p Flags based off of the attributes in \p Attrs.
268  /// \p OpIdx is the index in \p Attrs to add flags from.
270  const AttributeList &Attrs,
271  unsigned OpIdx) const;
272 
273  template <typename FuncInfoTy>
274  void setArgFlags(ArgInfo &Arg, unsigned OpIdx, const DataLayout &DL,
275  const FuncInfoTy &FuncInfo) const;
276 
277  /// Break \p OrigArgInfo into one or more pieces the calling convention can
278  /// process, returned in \p SplitArgs. For example, this should break structs
279  /// down into individual fields.
280  void splitToValueTypes(const ArgInfo &OrigArgInfo,
281  SmallVectorImpl<ArgInfo> &SplitArgs,
282  const DataLayout &DL, CallingConv::ID CallConv) const;
283 
284  /// Generate instructions for unpacking \p SrcReg into the \p DstRegs
285  /// corresponding to the aggregate type \p PackedTy.
286  ///
287  /// \param DstRegs should contain one virtual register for each base type in
288  /// \p PackedTy, as returned by computeValueLLTs.
289  void unpackRegs(ArrayRef<Register> DstRegs, Register SrcReg, Type *PackedTy,
290  MachineIRBuilder &MIRBuilder) const;
291 
292  /// Invoke Handler::assignArg on each of the given \p Args and then use
293  /// \p Handler to move them to the assigned locations.
294  ///
295  /// \return True if everything has succeeded, false otherwise.
296  bool handleAssignments(MachineIRBuilder &MIRBuilder,
297  SmallVectorImpl<ArgInfo> &Args, ValueHandler &Handler,
298  CallingConv::ID CallConv, bool IsVarArg,
299  Register ThisReturnReg = Register()) const;
302  MachineIRBuilder &MIRBuilder,
303  SmallVectorImpl<ArgInfo> &Args, ValueHandler &Handler,
304  Register ThisReturnReg = Register()) const;
305 
306  /// Analyze passed or returned values from a call, supplied in \p ArgInfo,
307  /// incorporating info about the passed values into \p CCState.
308  ///
309  /// Used to check if arguments are suitable for tail call lowering.
311  CCAssignFn &AssignFnFixed,
312  CCAssignFn &AssignFnVarArg) const;
313 
314  /// Check whether parameters to a call that are passed in callee saved
315  /// registers are the same as from the calling function. This needs to be
316  /// checked for tail call eligibility.
318  const uint32_t *CallerPreservedMask,
319  const SmallVectorImpl<CCValAssign> &ArgLocs,
320  const SmallVectorImpl<ArgInfo> &OutVals) const;
321 
322  /// \returns True if the calling convention for a callee and its caller pass
323  /// results in the same way. Typically used for tail call eligibility checks.
324  ///
325  /// \p Info is the CallLoweringInfo for the call.
326  /// \p MF is the MachineFunction for the caller.
327  /// \p InArgs contains the results of the call.
328  /// \p CalleeAssignFnFixed is the CCAssignFn to be used for the callee for
329  /// fixed arguments.
330  /// \p CalleeAssignFnVarArg is similar, but for varargs.
331  /// \p CallerAssignFnFixed is the CCAssignFn to be used for the caller for
332  /// fixed arguments.
333  /// \p CallerAssignFnVarArg is similar, but for varargs.
334  bool resultsCompatible(CallLoweringInfo &Info, MachineFunction &MF,
335  SmallVectorImpl<ArgInfo> &InArgs,
336  CCAssignFn &CalleeAssignFnFixed,
337  CCAssignFn &CalleeAssignFnVarArg,
338  CCAssignFn &CallerAssignFnFixed,
339  CCAssignFn &CallerAssignFnVarArg) const;
340 
341 public:
342  CallLowering(const TargetLowering *TLI) : TLI(TLI) {}
343  virtual ~CallLowering() = default;
344 
345  /// \return true if the target is capable of handling swifterror values that
346  /// have been promoted to a specified register. The extended versions of
347  /// lowerReturn and lowerCall should be implemented.
348  virtual bool supportSwiftError() const {
349  return false;
350  }
351 
352  /// Load the returned value from the stack into virtual registers in \p VRegs.
353  /// It uses the frame index \p FI and the start offset from \p DemoteReg.
354  /// The loaded data size will be determined from \p RetTy.
355  void insertSRetLoads(MachineIRBuilder &MIRBuilder, Type *RetTy,
356  ArrayRef<Register> VRegs, Register DemoteReg,
357  int FI) const;
358 
359  /// Store the return value given by \p VRegs into stack starting at the offset
360  /// specified in \p DemoteReg.
361  void insertSRetStores(MachineIRBuilder &MIRBuilder, Type *RetTy,
362  ArrayRef<Register> VRegs, Register DemoteReg) const;
363 
364  /// Insert the hidden sret ArgInfo to the beginning of \p SplitArgs.
365  /// This function should be called from the target specific
366  /// lowerFormalArguments when \p F requires the sret demotion.
368  SmallVectorImpl<ArgInfo> &SplitArgs,
369  Register &DemoteReg, MachineRegisterInfo &MRI,
370  const DataLayout &DL) const;
371 
372  /// For the call-base described by \p CB, insert the hidden sret ArgInfo to
373  /// the OrigArgs field of \p Info.
375  const CallBase &CB,
376  CallLoweringInfo &Info) const;
377 
378  /// \return True if the return type described by \p Outs can be returned
379  /// without performing sret demotion.
381  CCAssignFn *Fn) const;
382 
383  /// Get the type and the ArgFlags for the split components of \p RetTy as
384  /// returned by \c ComputeValueVTs.
385  void getReturnInfo(CallingConv::ID CallConv, Type *RetTy, AttributeList Attrs,
387  const DataLayout &DL) const;
388 
389  /// Toplevel function to check the return type based on the target calling
390  /// convention. \return True if the return value of \p MF can be returned
391  /// without performing sret demotion.
393 
394  /// This hook must be implemented to check whether the return values
395  /// described by \p Outs can fit into the return registers. If false
396  /// is returned, an sret-demotion is performed.
397  virtual bool canLowerReturn(MachineFunction &MF, CallingConv::ID CallConv,
399  bool IsVarArg) const {
400  return true;
401  }
402 
403  /// This hook must be implemented to lower outgoing return values, described
404  /// by \p Val, into the specified virtual registers \p VRegs.
405  /// This hook is used by GlobalISel.
406  ///
407  /// \p FLI is required for sret demotion.
408  ///
409  /// \p SwiftErrorVReg is non-zero if the function has a swifterror parameter
410  /// that needs to be implicitly returned.
411  ///
412  /// \return True if the lowering succeeds, false otherwise.
413  virtual bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val,
415  Register SwiftErrorVReg) const {
416  if (!supportSwiftError()) {
417  assert(SwiftErrorVReg == 0 && "attempt to use unsupported swifterror");
418  return lowerReturn(MIRBuilder, Val, VRegs, FLI);
419  }
420  return false;
421  }
422 
423  /// This hook behaves as the extended lowerReturn function, but for targets
424  /// that do not support swifterror value promotion.
425  virtual bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val,
426  ArrayRef<Register> VRegs,
427  FunctionLoweringInfo &FLI) const {
428  return false;
429  }
430 
431  virtual bool fallBackToDAGISel(const MachineFunction &MF) const {
432  return false;
433  }
434 
435  /// This hook must be implemented to lower the incoming (formal)
436  /// arguments, described by \p VRegs, for GlobalISel. Each argument
437  /// must end up in the related virtual registers described by \p VRegs.
438  /// In other words, the first argument should end up in \c VRegs[0],
439  /// the second in \c VRegs[1], and so on. For each argument, there will be one
440  /// register for each non-aggregate type, as returned by \c computeValueLLTs.
441  /// \p MIRBuilder is set to the proper insertion for the argument
442  /// lowering. \p FLI is required for sret demotion.
443  ///
444  /// \return True if the lowering succeeded, false otherwise.
445  virtual bool lowerFormalArguments(MachineIRBuilder &MIRBuilder,
446  const Function &F,
448  FunctionLoweringInfo &FLI) const {
449  return false;
450  }
451 
452  /// This hook must be implemented to lower the given call instruction,
453  /// including argument and return value marshalling.
454  ///
455  ///
456  /// \return true if the lowering succeeded, false otherwise.
457  virtual bool lowerCall(MachineIRBuilder &MIRBuilder,
458  CallLoweringInfo &Info) const {
459  return false;
460  }
461 
462  /// Lower the given call instruction, including argument and return value
463  /// marshalling.
464  ///
465  /// \p CI is the call/invoke instruction.
466  ///
467  /// \p ResRegs are the registers where the call's return value should be
468  /// stored (or 0 if there is no return value). There will be one register for
469  /// each non-aggregate type, as returned by \c computeValueLLTs.
470  ///
471  /// \p ArgRegs is a list of lists of virtual registers containing each
472  /// argument that needs to be passed (argument \c i should be placed in \c
473  /// ArgRegs[i]). For each argument, there will be one register for each
474  /// non-aggregate type, as returned by \c computeValueLLTs.
475  ///
476  /// \p SwiftErrorVReg is non-zero if the call has a swifterror inout
477  /// parameter, and contains the vreg that the swifterror should be copied into
478  /// after the call.
479  ///
480  /// \p GetCalleeReg is a callback to materialize a register for the callee if
481  /// the target determines it cannot jump to the destination based purely on \p
482  /// CI. This might be because \p CI is indirect, or because of the limited
483  /// range of an immediate jump.
484  ///
485  /// \return true if the lowering succeeded, false otherwise.
486  bool lowerCall(MachineIRBuilder &MIRBuilder, const CallBase &Call,
487  ArrayRef<Register> ResRegs,
488  ArrayRef<ArrayRef<Register>> ArgRegs, Register SwiftErrorVReg,
489  std::function<unsigned()> GetCalleeReg) const;
490 
491  /// For targets which support the "returned" parameter attribute, returns
492  /// true if the given type is a valid one to use with "returned".
493  virtual bool isTypeIsValidForThisReturn(EVT Ty) const { return false; }
494 };
495 
496 } // end namespace llvm
497 
498 #endif // LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
Attrs
Function Attrs
Definition: README_ALTIVEC.txt:215
llvm::CallLowering::CallLoweringInfo::CanLowerReturn
bool CanLowerReturn
True if the function's return value can be lowered to registers.
Definition: CallLowering.h:130
llvm
Definition: AllocatorList.h:23
llvm::CallLowering::ValueHandler::~ValueHandler
virtual ~ValueHandler()=default
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:112
llvm::CallLowering::CallLoweringInfo::IsMustTailCall
bool IsMustTailCall
True if the call must be tail call optimized.
Definition: CallLowering.h:116
llvm::CCState
CCState - This class holds information needed while lowering arguments and return values.
Definition: CallingConvLower.h:191
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:52
llvm::Function
Definition: Function.h:61
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::CallLowering::ValueHandler::AssignFn
CCAssignFn * AssignFn
Definition: CallLowering.h:223
llvm::CallLowering::ValueHandler::extendRegister
Register extendRegister(Register ValReg, CCValAssign &VA, unsigned MaxSizeBits=0)
Extend a register to the location type given in VA, capped at extending to at most MaxSize bits.
Definition: CallLowering.cpp:1023
llvm::CallLowering::CallLoweringInfo::LoweredTailCall
bool LoweredTailCall
True if the call was lowered as a tail call.
Definition: CallLowering.h:124
ErrorHandling.h
llvm::CallLowering::CallLoweringInfo::SwiftErrorVReg
Register SwiftErrorVReg
Valid if the call has a swifterror inout parameter, and contains the vreg that the swifterror should ...
Definition: CallLowering.h:111
llvm::CallLowering::ArgInfo::ArgInfo
ArgInfo(ArrayRef< Register > Regs, Type *Ty, ArrayRef< ISD::ArgFlagsTy > Flags=ArrayRef< ISD::ArgFlagsTy >(), bool IsFixed=true, const Value *OrigValue=nullptr)
Definition: CallLowering.h:74
llvm::CallLowering::ValueHandler
Argument handling is mostly uniform between the four places that make these decisions: function forma...
Definition: CallLowering.h:145
llvm::CallLowering::lowerReturn
virtual bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val, ArrayRef< Register > VRegs, FunctionLoweringInfo &FLI) const
This hook behaves as the extended lowerReturn function, but for targets that do not support swifterro...
Definition: CallLowering.h:425
llvm::CallLowering::insertSRetOutgoingArgument
void insertSRetOutgoingArgument(MachineIRBuilder &MIRBuilder, const CallBase &CB, CallLoweringInfo &Info) const
For the call-base described by CB, insert the hidden sret ArgInfo to the OrigArgs field of Info.
Definition: CallLowering.cpp:807
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
llvm::CallLowering::ValueHandler::assignValueToReg
virtual void assignValueToReg(Register ValVReg, Register PhysReg, CCValAssign &VA)=0
The specified value has been assigned to a physical register, handle the appropriate COPY (either to ...
llvm::CallLowering::OutgoingValueHandler
Definition: CallLowering.h:244
llvm::AttributeList
Definition: Attributes.h:385
llvm::sys::path::end
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:233
llvm::sys::path::begin
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:224
llvm::CallLowering::supportSwiftError
virtual bool supportSwiftError() const
Definition: CallLowering.h:348
llvm::CallLowering::CallLoweringInfo::DemoteRegister
Register DemoteRegister
VReg to hold the hidden sret parameter.
Definition: CallLowering.h:133
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::CallLowering::ValueHandler::assignCustomValue
virtual unsigned assignCustomValue(const ArgInfo &Arg, ArrayRef< CCValAssign > VAs)
Handle custom values, which may be passed into one or more of VAs.
Definition: CallLowering.h:195
llvm::CallLowering::BaseArgInfo
Definition: CallLowering.h:48
llvm::CallLowering::ValueHandler::getStackAddress
virtual Register getStackAddress(uint64_t Size, int64_t Offset, MachinePointerInfo &MPO, ISD::ArgFlagsTy Flags)=0
Materialize a VReg containing the address of the specified stack-based object.
llvm::CallLowering::ValueHandler::ValueHandler
ValueHandler(bool IsIncoming, MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, CCAssignFn *AssignFn)
Definition: CallLowering.h:146
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::CallLowering::ValueHandler::assignArg
virtual bool assignArg(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, const ArgInfo &Info, ISD::ArgFlagsTy Flags, CCState &State)
Definition: CallLowering.h:215
MachineValueType.h
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:205
llvm::Intrinsic::getType
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
Definition: Function.cpp:1251
llvm::CallLowering::getTLI
const TargetLowering * getTLI() const
Getter for generic TargetLowering class.
Definition: CallLowering.h:252
llvm::CallLowering::analyzeArgInfo
bool analyzeArgInfo(CCState &CCState, SmallVectorImpl< ArgInfo > &Args, CCAssignFn &AssignFnFixed, CCAssignFn &AssignFnVarArg) const
Analyze passed or returned values from a call, supplied in ArgInfo, incorporating info about the pass...
Definition: CallLowering.cpp:873
llvm::CCValAssign
CCValAssign - Represent assignment of one arg/retval to a location.
Definition: CallingConvLower.h:33
llvm::CallLowering::checkReturnTypeForCallConv
bool checkReturnTypeForCallConv(MachineFunction &MF) const
Toplevel function to check the return type based on the target calling convention.
Definition: CallLowering.cpp:862
llvm::MachineOperand::CreateImm
static MachineOperand CreateImm(int64_t Val)
Definition: MachineOperand.h:770
llvm::CallLowering::ValueHandler::assignValueToAddress
virtual void assignValueToAddress(Register ValVReg, Register Addr, uint64_t Size, MachinePointerInfo &MPO, CCValAssign &VA)=0
The specified value has been assigned to a stack location.
llvm::CallLowering::ArgInfo
Definition: CallLowering.h:61
llvm::EVT
Extended Value Type.
Definition: ValueTypes.h:35
llvm::CallLowering::BaseArgInfo::BaseArgInfo
BaseArgInfo(Type *Ty, ArrayRef< ISD::ArgFlagsTy > Flags=ArrayRef< ISD::ArgFlagsTy >(), bool IsFixed=true)
Definition: CallLowering.h:53
llvm::TargetLowering
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Definition: TargetLowering.h:3141
llvm::CallLowering::lowerFormalArguments
virtual bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F, ArrayRef< ArrayRef< Register >> VRegs, FunctionLoweringInfo &FLI) const
This hook must be implemented to lower the incoming (formal) arguments, described by VRegs,...
Definition: CallLowering.h:445
llvm::CallLowering::lowerReturn
virtual bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val, ArrayRef< Register > VRegs, FunctionLoweringInfo &FLI, Register SwiftErrorVReg) const
This hook must be implemented to lower outgoing return values, described by Val, into the specified v...
Definition: CallLowering.h:413
llvm::CallLowering::handleAssignments
bool handleAssignments(MachineIRBuilder &MIRBuilder, SmallVectorImpl< ArgInfo > &Args, ValueHandler &Handler, CallingConv::ID CallConv, bool IsVarArg, Register ThisReturnReg=Register()) const
Invoke Handler::assignArg on each of the given Args and then use Handler to move them to the assigned...
Definition: CallLowering.cpp:454
llvm::CallLowering::CallLoweringInfo::DemoteStackIndex
int DemoteStackIndex
The stack index for sret demotion.
Definition: CallLowering.h:136
false
Definition: StackSlotColoring.cpp:142
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:49
llvm::CallLowering::IncomingValueHandler
Definition: CallLowering.h:230
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:26
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::CallLowering::ArgInfo::ArgInfo
ArgInfo(ArrayRef< Register > Regs, const Value &OrigValue, ArrayRef< ISD::ArgFlagsTy > Flags=ArrayRef< ISD::ArgFlagsTy >(), bool IsFixed=true)
Definition: CallLowering.h:87
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
Type.h
llvm::CallLowering::BaseArgInfo::BaseArgInfo
BaseArgInfo()
Definition: CallLowering.h:58
llvm::CallLowering::ArgInfo::OrigRegs
SmallVector< Register, 2 > OrigRegs
Definition: CallLowering.h:66
llvm::CCAssignFn
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.
Definition: CallingConvLower.h:177
llvm::CallLowering::isTypeIsValidForThisReturn
virtual bool isTypeIsValidForThisReturn(EVT Ty) const
For targets which support the "returned" parameter attribute, returns true if the given type is a val...
Definition: CallLowering.h:493
llvm::CCValAssign::LocInfo
LocInfo
Definition: CallingConvLower.h:35
llvm::MachineIRBuilder
Helper class to build MachineInstr.
Definition: MachineIRBuilder.h:220
TargetCallingConv.h
llvm::CallLowering::checkReturn
bool checkReturn(CCState &CCInfo, SmallVectorImpl< BaseArgInfo > &Outs, CCAssignFn *Fn) const
Definition: CallLowering.cpp:828
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:80
llvm::MachinePointerInfo
This class contains a discriminated union of information about pointers in memory operands,...
Definition: MachineMemOperand.h:37
llvm::CallLowering::CallLoweringInfo::OrigArgs
SmallVector< ArgInfo, 8 > OrigArgs
List of descriptors of the arguments passed to the function.
Definition: CallLowering.h:107
llvm::CallLowering::OutgoingValueHandler::OutgoingValueHandler
OutgoingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, CCAssignFn *AssignFn)
Definition: CallLowering.h:245
ArrayRef.h
llvm::CallLowering::ArgInfo::ArgInfo
ArgInfo()
Definition: CallLowering.h:92
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::FunctionLoweringInfo
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
Definition: FunctionLoweringInfo.h:53
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::Type::isVoidTy
bool isVoidTy() const
Return true if this is 'void'.
Definition: Type.h:139
llvm::MVT
Machine Value Type.
Definition: MachineValueType.h:30
llvm::MDNode
Metadata node.
Definition: Metadata.h:897
llvm::CallLowering::CallLoweringInfo::KnownCallees
MDNode * KnownCallees
Definition: CallLowering.h:113
llvm::CallLowering::addArgFlagsFromAttributes
void addArgFlagsFromAttributes(ISD::ArgFlagsTy &Flags, const AttributeList &Attrs, unsigned OpIdx) const
Adds flags to Flags based off of the attributes in Attrs.
Definition: CallLowering.cpp:70
llvm::MachineFunction
Definition: MachineFunction.h:227
llvm::CallLowering::ValueHandler::assignValueToAddress
virtual void assignValueToAddress(const ArgInfo &Arg, unsigned ValRegIndex, Register Addr, uint64_t Size, MachinePointerInfo &MPO, CCValAssign &VA)
An overload which takes an ArgInfo if additional information about the arg is needed.
Definition: CallLowering.h:184
llvm::CallLowering::ValueHandler::copyArgumentMemory
void copyArgumentMemory(const ArgInfo &Arg, Register DstPtr, Register SrcPtr, const MachinePointerInfo &DstPtrInfo, Align DstAlign, const MachinePointerInfo &SrcPtrInfo, Align SrcAlign, uint64_t MemSize, CCValAssign &VA) const
Do a memory copy of MemSize bytes from SrcPtr to DstPtr.
Definition: CallLowering.cpp:1000
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:33
llvm::CallLowering::~CallLowering
virtual ~CallLowering()=default
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::CallLowering::insertSRetLoads
void insertSRetLoads(MachineIRBuilder &MIRBuilder, Type *RetTy, ArrayRef< Register > VRegs, Register DemoteReg, int FI) const
Load the returned value from the stack into virtual registers in VRegs.
Definition: CallLowering.cpp:725
llvm::CallLowering::CallLoweringInfo::IsVarArg
bool IsVarArg
True if the call is to a vararg function.
Definition: CallLowering.h:127
uint32_t
llvm::CallLowering::getTLI
const XXXTargetLowering * getTLI() const
Getter for target specific TargetLowering class.
Definition: CallLowering.h:258
llvm::ISD::ArgFlagsTy
Definition: TargetCallingConv.h:27
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::CallLowering::insertSRetIncomingArgument
void insertSRetIncomingArgument(const Function &F, SmallVectorImpl< ArgInfo > &SplitArgs, Register &DemoteReg, MachineRegisterInfo &MRI, const DataLayout &DL) const
Insert the hidden sret ArgInfo to the beginning of SplitArgs.
Definition: CallLowering.cpp:786
llvm::CallLowering::unpackRegs
void unpackRegs(ArrayRef< Register > DstRegs, Register SrcReg, Type *PackedTy, MachineIRBuilder &MIRBuilder) const
Generate instructions for unpacking SrcReg into the DstRegs corresponding to the aggregate type Packe...
Definition: CallLowering.cpp:234
llvm::CallLowering::getAttributesForArgIdx
ISD::ArgFlagsTy getAttributesForArgIdx(const CallBase &Call, unsigned ArgIdx) const
Definition: CallLowering.cpp:61
CallingConv.h
Attributes.h
llvm::CallLowering::canLowerReturn
virtual bool canLowerReturn(MachineFunction &MF, CallingConv::ID CallConv, SmallVectorImpl< BaseArgInfo > &Outs, bool IsVarArg) const
This hook must be implemented to check whether the return values described by Outs can fit into the r...
Definition: CallLowering.h:397
llvm::CallLowering::insertSRetStores
void insertSRetStores(MachineIRBuilder &MIRBuilder, Type *RetTy, ArrayRef< Register > VRegs, Register DemoteReg) const
Store the return value given by VRegs into stack starting at the offset specified in DemoteReg.
Definition: CallLowering.cpp:755
llvm::CallingConv::C
@ C
C - The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
CallingConvLower.h
llvm::CallLowering::ValueHandler::MRI
MachineRegisterInfo & MRI
Definition: CallLowering.h:222
llvm::CallLowering::CallLoweringInfo::CallConv
CallingConv::ID CallConv
Calling convention to be used for the call.
Definition: CallLowering.h:97
llvm::Type::isEmptyTy
bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty.
Definition: Type.cpp:112
llvm::CallLowering::IncomingValueHandler::assignValueToReg
void assignValueToReg(Register ValVReg, Register PhysReg, CCValAssign &VA) override
Provides a default implementation for argument handling.
Definition: CallLowering.cpp:1086
llvm::CallLowering::ArgInfo::Regs
SmallVector< Register, 4 > Regs
Definition: CallLowering.h:62
llvm::CallLowering::BaseArgInfo::Ty
Type * Ty
Definition: CallLowering.h:49
llvm::CallLowering::CallLoweringInfo
Definition: CallLowering.h:95
llvm::CallLowering::fallBackToDAGISel
virtual bool fallBackToDAGISel(const MachineFunction &MF) const
Definition: CallLowering.h:431
llvm::CallLowering::IncomingValueHandler::buildExtensionHint
Register buildExtensionHint(CCValAssign &VA, Register SrcReg, LLT NarrowTy)
Insert G_ASSERT_ZEXT/G_ASSERT_SEXT or other hint instruction based on VA, returning the new register ...
Definition: CallLowering.cpp:1064
llvm::CallLowering::CallLowering
CallLowering(const TargetLowering *TLI)
Definition: CallLowering.h:342
llvm::CallLowering::ValueHandler::MIRBuilder
MachineIRBuilder & MIRBuilder
Definition: CallLowering.h:221
llvm::CallLowering::resultsCompatible
bool resultsCompatible(CallLoweringInfo &Info, MachineFunction &MF, SmallVectorImpl< ArgInfo > &InArgs, CCAssignFn &CalleeAssignFnFixed, CCAssignFn &CalleeAssignFnVarArg, CCAssignFn &CallerAssignFnFixed, CCAssignFn &CallerAssignFnVarArg) const
Definition: CallLowering.cpp:942
llvm::CallLowering::splitToValueTypes
void splitToValueTypes(const ArgInfo &OrigArgInfo, SmallVectorImpl< ArgInfo > &SplitArgs, const DataLayout &DL, CallingConv::ID CallConv) const
Break OrigArgInfo into one or more pieces the calling convention can process, returned in SplitArgs.
Definition: CallLowering.cpp:196
SmallVector.h
llvm::CallLowering::IncomingValueHandler::IncomingValueHandler
IncomingValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, CCAssignFn *AssignFn)
Definition: CallLowering.h:231
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:43
llvm::CallLowering::getReturnInfo
void getReturnInfo(CallingConv::ID CallConv, Type *RetTy, AttributeList Attrs, SmallVectorImpl< BaseArgInfo > &Outs, const DataLayout &DL) const
Get the type and the ArgFlags for the split components of RetTy as returned by ComputeValueVTs.
Definition: CallLowering.cpp:839
MachineOperand.h
llvm::CallLowering::CallLoweringInfo::OrigRet
ArgInfo OrigRet
Descriptor for the return type of the function.
Definition: CallLowering.h:104
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1164
llvm::CallLowering::BaseArgInfo::IsFixed
bool IsFixed
Definition: CallLowering.h:51
llvm::CallLowering::ArgInfo::OrigValue
const Value * OrigValue
Optionally track the original IR value for the argument.
Definition: CallLowering.h:72
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:389
llvm::CallLowering::CallLoweringInfo::IsTailCall
bool IsTailCall
True if the call passes all target-independent checks for tail call optimization.
Definition: CallLowering.h:120
MachineFunction.h
llvm::CallLowering::parametersInCSRMatch
bool parametersInCSRMatch(const MachineRegisterInfo &MRI, const uint32_t *CallerPreservedMask, const SmallVectorImpl< CCValAssign > &ArgLocs, const SmallVectorImpl< ArgInfo > &OutVals) const
Check whether parameters to a call that are passed in callee saved registers are the same as from the...
Definition: CallLowering.cpp:890
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1789
Value.h
llvm::CallLowering
Definition: CallLowering.h:43
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::CallLowering::ValueHandler::isIncomingArgumentHandler
bool isIncomingArgumentHandler() const
Returns true if the handler is dealing with incoming arguments, i.e.
Definition: CallLowering.h:155
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::CallLowering::BaseArgInfo::Flags
SmallVector< ISD::ArgFlagsTy, 4 > Flags
Definition: CallLowering.h:50
llvm::CallLowering::CallLoweringInfo::Callee
MachineOperand Callee
Destination of the call.
Definition: CallLowering.h:101
llvm::LLT
Definition: LowLevelTypeImpl.h:40
llvm::CallLowering::lowerCall
virtual bool lowerCall(MachineIRBuilder &MIRBuilder, CallLoweringInfo &Info) const
This hook must be implemented to lower the given call instruction, including argument and return valu...
Definition: CallLowering.h:457
llvm::CallLowering::setArgFlags
void setArgFlags(ArgInfo &Arg, unsigned OpIdx, const DataLayout &DL, const FuncInfoTy &FuncInfo) const
Definition: CallLowering.cpp:150