LLVM  14.0.0git
ARMCallLowering.cpp
Go to the documentation of this file.
1 //===- llvm/lib/Target/ARM/ARMCallLowering.cpp - Call lowering ------------===//
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 implements the lowering of LLVM calls to machine code calls for
11 /// GlobalISel.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "ARMCallLowering.h"
16 #include "ARMBaseInstrInfo.h"
17 #include "ARMISelLowering.h"
18 #include "ARMSubtarget.h"
19 #include "Utils/ARMBaseInfo.h"
20 #include "llvm/ADT/SmallVector.h"
21 #include "llvm/CodeGen/Analysis.h"
36 #include "llvm/IR/Attributes.h"
37 #include "llvm/IR/DataLayout.h"
38 #include "llvm/IR/DerivedTypes.h"
39 #include "llvm/IR/Function.h"
40 #include "llvm/IR/Type.h"
41 #include "llvm/IR/Value.h"
42 #include "llvm/Support/Casting.h"
45 #include <algorithm>
46 #include <cassert>
47 #include <cstdint>
48 #include <utility>
49 
50 using namespace llvm;
51 
53  : CallLowering(&TLI) {}
54 
55 static bool isSupportedType(const DataLayout &DL, const ARMTargetLowering &TLI,
56  Type *T) {
57  if (T->isArrayTy())
58  return isSupportedType(DL, TLI, T->getArrayElementType());
59 
60  if (T->isStructTy()) {
61  // For now we only allow homogeneous structs that we can manipulate with
62  // G_MERGE_VALUES and G_UNMERGE_VALUES
63  auto StructT = cast<StructType>(T);
64  for (unsigned i = 1, e = StructT->getNumElements(); i != e; ++i)
65  if (StructT->getElementType(i) != StructT->getElementType(0))
66  return false;
67  return isSupportedType(DL, TLI, StructT->getElementType(0));
68  }
69 
70  EVT VT = TLI.getValueType(DL, T, true);
71  if (!VT.isSimple() || VT.isVector() ||
72  !(VT.isInteger() || VT.isFloatingPoint()))
73  return false;
74 
75  unsigned VTSize = VT.getSimpleVT().getSizeInBits();
76 
77  if (VTSize == 64)
78  // FIXME: Support i64 too
79  return VT.isFloatingPoint();
80 
81  return VTSize == 1 || VTSize == 8 || VTSize == 16 || VTSize == 32;
82 }
83 
84 namespace {
85 
86 /// Helper class for values going out through an ABI boundary (used for handling
87 /// function return values and call parameters).
88 struct ARMOutgoingValueHandler : public CallLowering::OutgoingValueHandler {
89  ARMOutgoingValueHandler(MachineIRBuilder &MIRBuilder,
91  : OutgoingValueHandler(MIRBuilder, MRI), MIB(MIB) {}
92 
93  Register getStackAddress(uint64_t Size, int64_t Offset,
94  MachinePointerInfo &MPO,
95  ISD::ArgFlagsTy Flags) override {
96  assert((Size == 1 || Size == 2 || Size == 4 || Size == 8) &&
97  "Unsupported size");
98 
99  LLT p0 = LLT::pointer(0, 32);
100  LLT s32 = LLT::scalar(32);
101  auto SPReg = MIRBuilder.buildCopy(p0, Register(ARM::SP));
102 
103  auto OffsetReg = MIRBuilder.buildConstant(s32, Offset);
104 
105  auto AddrReg = MIRBuilder.buildPtrAdd(p0, SPReg, OffsetReg);
106 
107  MPO = MachinePointerInfo::getStack(MIRBuilder.getMF(), Offset);
108  return AddrReg.getReg(0);
109  }
110 
111  void assignValueToReg(Register ValVReg, Register PhysReg,
112  CCValAssign &VA) override {
113  assert(VA.isRegLoc() && "Value shouldn't be assigned to reg");
114  assert(VA.getLocReg() == PhysReg && "Assigning to the wrong reg?");
115 
116  assert(VA.getValVT().getSizeInBits() <= 64 && "Unsupported value size");
117  assert(VA.getLocVT().getSizeInBits() <= 64 && "Unsupported location size");
118 
119  Register ExtReg = extendRegister(ValVReg, VA);
120  MIRBuilder.buildCopy(PhysReg, ExtReg);
121  MIB.addUse(PhysReg, RegState::Implicit);
122  }
123 
124  void assignValueToAddress(Register ValVReg, Register Addr, LLT MemTy,
125  MachinePointerInfo &MPO, CCValAssign &VA) override {
126  Register ExtReg = extendRegister(ValVReg, VA);
127  auto MMO = MIRBuilder.getMF().getMachineMemOperand(
128  MPO, MachineMemOperand::MOStore, MemTy, Align(1));
129  MIRBuilder.buildStore(ExtReg, Addr, *MMO);
130  }
131 
132  unsigned assignCustomValue(CallLowering::ArgInfo &Arg,
133  ArrayRef<CCValAssign> VAs) override {
134  assert(Arg.Regs.size() == 1 && "Can't handle multple regs yet");
135 
136  CCValAssign VA = VAs[0];
137  assert(VA.needsCustom() && "Value doesn't need custom handling");
138 
139  // Custom lowering for other types, such as f16, is currently not supported
140  if (VA.getValVT() != MVT::f64)
141  return 0;
142 
143  CCValAssign NextVA = VAs[1];
144  assert(NextVA.needsCustom() && "Value doesn't need custom handling");
145  assert(NextVA.getValVT() == MVT::f64 && "Unsupported type");
146 
147  assert(VA.getValNo() == NextVA.getValNo() &&
148  "Values belong to different arguments");
149 
150  assert(VA.isRegLoc() && "Value should be in reg");
151  assert(NextVA.isRegLoc() && "Value should be in reg");
152 
155  MIRBuilder.buildUnmerge(NewRegs, Arg.Regs[0]);
156 
157  bool IsLittle = MIRBuilder.getMF().getSubtarget<ARMSubtarget>().isLittle();
158  if (!IsLittle)
159  std::swap(NewRegs[0], NewRegs[1]);
160 
161  assignValueToReg(NewRegs[0], VA.getLocReg(), VA);
162  assignValueToReg(NewRegs[1], NextVA.getLocReg(), NextVA);
163 
164  return 1;
165  }
166 
168 };
169 
170 } // end anonymous namespace
171 
172 /// Lower the return value for the already existing \p Ret. This assumes that
173 /// \p MIRBuilder's insertion point is correct.
174 bool ARMCallLowering::lowerReturnVal(MachineIRBuilder &MIRBuilder,
175  const Value *Val, ArrayRef<Register> VRegs,
176  MachineInstrBuilder &Ret) const {
177  if (!Val)
178  // Nothing to do here.
179  return true;
180 
181  auto &MF = MIRBuilder.getMF();
182  const auto &F = MF.getFunction();
183 
184  const auto &DL = MF.getDataLayout();
185  auto &TLI = *getTLI<ARMTargetLowering>();
186  if (!isSupportedType(DL, TLI, Val->getType()))
187  return false;
188 
189  ArgInfo OrigRetInfo(VRegs, Val->getType(), 0);
190  setArgFlags(OrigRetInfo, AttributeList::ReturnIndex, DL, F);
191 
192  SmallVector<ArgInfo, 4> SplitRetInfos;
193  splitToValueTypes(OrigRetInfo, SplitRetInfos, DL, F.getCallingConv());
194 
195  CCAssignFn *AssignFn =
196  TLI.CCAssignFnForReturn(F.getCallingConv(), F.isVarArg());
197 
198  OutgoingValueAssigner RetAssigner(AssignFn);
199  ARMOutgoingValueHandler RetHandler(MIRBuilder, MF.getRegInfo(), Ret);
200  return determineAndHandleAssignments(RetHandler, RetAssigner, SplitRetInfos,
201  MIRBuilder, F.getCallingConv(),
202  F.isVarArg());
203 }
204 
206  const Value *Val, ArrayRef<Register> VRegs,
207  FunctionLoweringInfo &FLI) const {
208  assert(!Val == VRegs.empty() && "Return value without a vreg");
209 
210  auto const &ST = MIRBuilder.getMF().getSubtarget<ARMSubtarget>();
211  unsigned Opcode = ST.getReturnOpcode();
212  auto Ret = MIRBuilder.buildInstrNoInsert(Opcode).add(predOps(ARMCC::AL));
213 
214  if (!lowerReturnVal(MIRBuilder, Val, VRegs, Ret))
215  return false;
216 
217  MIRBuilder.insertInstr(Ret);
218  return true;
219 }
220 
221 namespace {
222 
223 /// Helper class for values coming in through an ABI boundary (used for handling
224 /// formal arguments and call return values).
225 struct ARMIncomingValueHandler : public CallLowering::IncomingValueHandler {
226  ARMIncomingValueHandler(MachineIRBuilder &MIRBuilder,
228  : IncomingValueHandler(MIRBuilder, MRI) {}
229 
230  Register getStackAddress(uint64_t Size, int64_t Offset,
231  MachinePointerInfo &MPO,
232  ISD::ArgFlagsTy Flags) override {
233  assert((Size == 1 || Size == 2 || Size == 4 || Size == 8) &&
234  "Unsupported size");
235 
236  auto &MFI = MIRBuilder.getMF().getFrameInfo();
237 
238  // Byval is assumed to be writable memory, but other stack passed arguments
239  // are not.
240  const bool IsImmutable = !Flags.isByVal();
241 
242  int FI = MFI.CreateFixedObject(Size, Offset, IsImmutable);
243  MPO = MachinePointerInfo::getFixedStack(MIRBuilder.getMF(), FI);
244 
245  return MIRBuilder.buildFrameIndex(LLT::pointer(MPO.getAddrSpace(), 32), FI)
246  .getReg(0);
247  }
248 
249  void assignValueToAddress(Register ValVReg, Register Addr, LLT MemTy,
250  MachinePointerInfo &MPO, CCValAssign &VA) override {
251  if (VA.getLocInfo() == CCValAssign::SExt ||
252  VA.getLocInfo() == CCValAssign::ZExt) {
253  // If the value is zero- or sign-extended, its size becomes 4 bytes, so
254  // that's what we should load.
255  MemTy = LLT::scalar(32);
256  assert(MRI.getType(ValVReg).isScalar() && "Only scalars supported atm");
257 
258  auto LoadVReg = buildLoad(LLT::scalar(32), Addr, MemTy, MPO);
259  MIRBuilder.buildTrunc(ValVReg, LoadVReg);
260  } else {
261  // If the value is not extended, a simple load will suffice.
262  buildLoad(ValVReg, Addr, MemTy, MPO);
263  }
264  }
265 
266  MachineInstrBuilder buildLoad(const DstOp &Res, Register Addr, LLT MemTy,
267  MachinePointerInfo &MPO) {
268  MachineFunction &MF = MIRBuilder.getMF();
269 
270  auto MMO = MF.getMachineMemOperand(MPO, MachineMemOperand::MOLoad, MemTy,
271  inferAlignFromPtrInfo(MF, MPO));
272  return MIRBuilder.buildLoad(Res, Addr, *MMO);
273  }
274 
275  void assignValueToReg(Register ValVReg, Register PhysReg,
276  CCValAssign &VA) override {
277  assert(VA.isRegLoc() && "Value shouldn't be assigned to reg");
278  assert(VA.getLocReg() == PhysReg && "Assigning to the wrong reg?");
279 
280  uint64_t ValSize = VA.getValVT().getFixedSizeInBits();
281  uint64_t LocSize = VA.getLocVT().getFixedSizeInBits();
282 
283  assert(ValSize <= 64 && "Unsupported value size");
284  assert(LocSize <= 64 && "Unsupported location size");
285 
286  markPhysRegUsed(PhysReg);
287  if (ValSize == LocSize) {
288  MIRBuilder.buildCopy(ValVReg, PhysReg);
289  } else {
290  assert(ValSize < LocSize && "Extensions not supported");
291 
292  // We cannot create a truncating copy, nor a trunc of a physical register.
293  // Therefore, we need to copy the content of the physical register into a
294  // virtual one and then truncate that.
295  auto PhysRegToVReg = MIRBuilder.buildCopy(LLT::scalar(LocSize), PhysReg);
296  MIRBuilder.buildTrunc(ValVReg, PhysRegToVReg);
297  }
298  }
299 
300  unsigned assignCustomValue(ARMCallLowering::ArgInfo &Arg,
301  ArrayRef<CCValAssign> VAs) override {
302  assert(Arg.Regs.size() == 1 && "Can't handle multple regs yet");
303 
304  CCValAssign VA = VAs[0];
305  assert(VA.needsCustom() && "Value doesn't need custom handling");
306 
307  // Custom lowering for other types, such as f16, is currently not supported
308  if (VA.getValVT() != MVT::f64)
309  return 0;
310 
311  CCValAssign NextVA = VAs[1];
312  assert(NextVA.needsCustom() && "Value doesn't need custom handling");
313  assert(NextVA.getValVT() == MVT::f64 && "Unsupported type");
314 
315  assert(VA.getValNo() == NextVA.getValNo() &&
316  "Values belong to different arguments");
317 
318  assert(VA.isRegLoc() && "Value should be in reg");
319  assert(NextVA.isRegLoc() && "Value should be in reg");
320 
323 
324  assignValueToReg(NewRegs[0], VA.getLocReg(), VA);
325  assignValueToReg(NewRegs[1], NextVA.getLocReg(), NextVA);
326 
327  bool IsLittle = MIRBuilder.getMF().getSubtarget<ARMSubtarget>().isLittle();
328  if (!IsLittle)
329  std::swap(NewRegs[0], NewRegs[1]);
330 
331  MIRBuilder.buildMerge(Arg.Regs[0], NewRegs);
332 
333  return 1;
334  }
335 
336  /// Marking a physical register as used is different between formal
337  /// parameters, where it's a basic block live-in, and call returns, where it's
338  /// an implicit-def of the call instruction.
339  virtual void markPhysRegUsed(unsigned PhysReg) = 0;
340 };
341 
342 struct FormalArgHandler : public ARMIncomingValueHandler {
344  : ARMIncomingValueHandler(MIRBuilder, MRI) {}
345 
346  void markPhysRegUsed(unsigned PhysReg) override {
347  MIRBuilder.getMRI()->addLiveIn(PhysReg);
348  MIRBuilder.getMBB().addLiveIn(PhysReg);
349  }
350 };
351 
352 } // end anonymous namespace
353 
355  const Function &F,
357  FunctionLoweringInfo &FLI) const {
358  auto &TLI = *getTLI<ARMTargetLowering>();
359  auto Subtarget = TLI.getSubtarget();
360 
361  if (Subtarget->isThumb1Only())
362  return false;
363 
364  // Quick exit if there aren't any args
365  if (F.arg_empty())
366  return true;
367 
368  if (F.isVarArg())
369  return false;
370 
371  auto &MF = MIRBuilder.getMF();
372  auto &MBB = MIRBuilder.getMBB();
373  const auto &DL = MF.getDataLayout();
374 
375  for (auto &Arg : F.args()) {
376  if (!isSupportedType(DL, TLI, Arg.getType()))
377  return false;
378  if (Arg.hasPassPointeeByValueCopyAttr())
379  return false;
380  }
381 
382  CCAssignFn *AssignFn =
383  TLI.CCAssignFnForCall(F.getCallingConv(), F.isVarArg());
384 
385  OutgoingValueAssigner ArgAssigner(AssignFn);
386  FormalArgHandler ArgHandler(MIRBuilder, MIRBuilder.getMF().getRegInfo());
387 
388  SmallVector<ArgInfo, 8> SplitArgInfos;
389  unsigned Idx = 0;
390  for (auto &Arg : F.args()) {
391  ArgInfo OrigArgInfo(VRegs[Idx], Arg.getType(), Idx);
392 
393  setArgFlags(OrigArgInfo, Idx + AttributeList::FirstArgIndex, DL, F);
394  splitToValueTypes(OrigArgInfo, SplitArgInfos, DL, F.getCallingConv());
395 
396  Idx++;
397  }
398 
399  if (!MBB.empty())
400  MIRBuilder.setInstr(*MBB.begin());
401 
402  if (!determineAndHandleAssignments(ArgHandler, ArgAssigner, SplitArgInfos,
403  MIRBuilder, F.getCallingConv(),
404  F.isVarArg()))
405  return false;
406 
407  // Move back to the end of the basic block.
408  MIRBuilder.setMBB(MBB);
409  return true;
410 }
411 
412 namespace {
413 
414 struct CallReturnHandler : public ARMIncomingValueHandler {
415  CallReturnHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI,
417  : ARMIncomingValueHandler(MIRBuilder, MRI), MIB(MIB) {}
418 
419  void markPhysRegUsed(unsigned PhysReg) override {
420  MIB.addDef(PhysReg, RegState::Implicit);
421  }
422 
424 };
425 
426 // FIXME: This should move to the ARMSubtarget when it supports all the opcodes.
427 unsigned getCallOpcode(const MachineFunction &MF, const ARMSubtarget &STI,
428  bool isDirect) {
429  if (isDirect)
430  return STI.isThumb() ? ARM::tBL : ARM::BL;
431 
432  if (STI.isThumb())
433  return gettBLXrOpcode(MF);
434 
435  if (STI.hasV5TOps())
436  return getBLXOpcode(MF);
437 
438  if (STI.hasV4TOps())
439  return ARM::BX_CALL;
440 
441  return ARM::BMOVPCRX_CALL;
442 }
443 } // end anonymous namespace
444 
446  MachineFunction &MF = MIRBuilder.getMF();
447  const auto &TLI = *getTLI<ARMTargetLowering>();
448  const auto &DL = MF.getDataLayout();
449  const auto &STI = MF.getSubtarget<ARMSubtarget>();
450  const TargetRegisterInfo *TRI = STI.getRegisterInfo();
452 
453  if (STI.genLongCalls())
454  return false;
455 
456  if (STI.isThumb1Only())
457  return false;
458 
459  auto CallSeqStart = MIRBuilder.buildInstr(ARM::ADJCALLSTACKDOWN);
460 
461  // Create the call instruction so we can add the implicit uses of arg
462  // registers, but don't insert it yet.
463  bool IsDirect = !Info.Callee.isReg();
464  auto CallOpcode = getCallOpcode(MF, STI, IsDirect);
465  auto MIB = MIRBuilder.buildInstrNoInsert(CallOpcode);
466 
467  bool IsThumb = STI.isThumb();
468  if (IsThumb)
469  MIB.add(predOps(ARMCC::AL));
470 
471  MIB.add(Info.Callee);
472  if (!IsDirect) {
473  auto CalleeReg = Info.Callee.getReg();
474  if (CalleeReg && !Register::isPhysicalRegister(CalleeReg)) {
475  unsigned CalleeIdx = IsThumb ? 2 : 0;
476  MIB->getOperand(CalleeIdx).setReg(constrainOperandRegClass(
477  MF, *TRI, MRI, *STI.getInstrInfo(), *STI.getRegBankInfo(),
478  *MIB.getInstr(), MIB->getDesc(), Info.Callee, CalleeIdx));
479  }
480  }
481 
482  MIB.addRegMask(TRI->getCallPreservedMask(MF, Info.CallConv));
483 
484  SmallVector<ArgInfo, 8> ArgInfos;
485  for (auto Arg : Info.OrigArgs) {
486  if (!isSupportedType(DL, TLI, Arg.Ty))
487  return false;
488 
489  if (Arg.Flags[0].isByVal())
490  return false;
491 
492  splitToValueTypes(Arg, ArgInfos, DL, Info.CallConv);
493  }
494 
495  auto ArgAssignFn = TLI.CCAssignFnForCall(Info.CallConv, Info.IsVarArg);
496  OutgoingValueAssigner ArgAssigner(ArgAssignFn);
497  ARMOutgoingValueHandler ArgHandler(MIRBuilder, MRI, MIB);
498  if (!determineAndHandleAssignments(ArgHandler, ArgAssigner, ArgInfos,
499  MIRBuilder, Info.CallConv, Info.IsVarArg))
500  return false;
501 
502  // Now we can add the actual call instruction to the correct basic block.
503  MIRBuilder.insertInstr(MIB);
504 
505  if (!Info.OrigRet.Ty->isVoidTy()) {
506  if (!isSupportedType(DL, TLI, Info.OrigRet.Ty))
507  return false;
508 
509  ArgInfos.clear();
510  splitToValueTypes(Info.OrigRet, ArgInfos, DL, Info.CallConv);
511  auto RetAssignFn = TLI.CCAssignFnForReturn(Info.CallConv, Info.IsVarArg);
512  OutgoingValueAssigner Assigner(RetAssignFn);
513  CallReturnHandler RetHandler(MIRBuilder, MRI, MIB);
514  if (!determineAndHandleAssignments(RetHandler, Assigner, ArgInfos,
515  MIRBuilder, Info.CallConv,
516  Info.IsVarArg))
517  return false;
518  }
519 
520  // We now know the size of the stack - update the ADJCALLSTACKDOWN
521  // accordingly.
522  CallSeqStart.addImm(ArgAssigner.StackOffset)
523  .addImm(0)
524  .add(predOps(ARMCC::AL));
525 
526  MIRBuilder.buildInstr(ARM::ADJCALLSTACKUP)
527  .addImm(ArgAssigner.StackOffset)
528  .addImm(0)
529  .add(predOps(ARMCC::AL));
530 
531  return true;
532 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::CCValAssign::getLocVT
MVT getLocVT() const
Definition: CallingConvLower.h:153
llvm::MachineRegisterInfo::addLiveIn
void addLiveIn(MCRegister Reg, Register vreg=Register())
addLiveIn - Add the specified register as a live-in.
Definition: MachineRegisterInfo.h:944
i
i
Definition: README.txt:29
ARMSubtarget.h
llvm::CCValAssign::ZExt
@ ZExt
Definition: CallingConvLower.h:38
ValueTypes.h
LowLevelType.h
llvm::ARMSubtarget::genLongCalls
bool genLongCalls() const
Definition: ARMSubtarget.h:720
llvm::ARMSubtarget::hasV5TOps
bool hasV5TOps() const
Definition: ARMSubtarget.h:606
llvm::MachineInstrBuilder::addImm
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Definition: MachineInstrBuilder.h:131
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::MVT::getFixedSizeInBits
uint64_t getFixedSizeInBits() const
Return the size of the specified fixed width value type in bits.
Definition: MachineValueType.h:1058
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:112
ARMCallLowering.h
llvm::ARMSubtarget
Definition: ARMSubtarget.h:46
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:52
llvm::MachineInstrBuilder::add
const MachineInstrBuilder & add(const MachineOperand &MO) const
Definition: MachineInstrBuilder.h:224
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::MachineIRBuilder::getMRI
MachineRegisterInfo * getMRI()
Getter for MRI.
Definition: MachineIRBuilder.h:280
llvm::MachineFunction::getMachineMemOperand
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, Align base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
Definition: MachineFunction.cpp:430
MachineBasicBlock.h
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:231
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::ARMTargetLowering
Definition: ARMISelLowering.h:389
llvm::CallLowering::OutgoingValueHandler
Base class for ValueHandlers used for arguments passed to a function call, or for return values.
Definition: CallLowering.h:323
llvm::ARMSubtarget::getInstrInfo
const ARMBaseInstrInfo * getInstrInfo() const override
Definition: ARMSubtarget.h:562
llvm::CallLowering::splitToValueTypes
void splitToValueTypes(const ArgInfo &OrigArgInfo, SmallVectorImpl< ArgInfo > &SplitArgs, const DataLayout &DL, CallingConv::ID CallConv, SmallVectorImpl< uint64_t > *Offsets=nullptr) const
Break OrigArgInfo into one or more pieces the calling convention can process, returned in SplitArgs.
Definition: CallLowering.cpp:207
T
#define T
Definition: Mips16ISelLowering.cpp:341
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::MachineIRBuilder::buildInstrNoInsert
MachineInstrBuilder buildInstrNoInsert(unsigned Opcode)
Build but don't insert <empty> = Opcode <empty>.
Definition: MachineIRBuilder.cpp:40
llvm::MachineIRBuilder::setInstr
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
Definition: MachineIRBuilder.h:333
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:116
MachineIRBuilder.h
llvm::RegState::Implicit
@ Implicit
Not emitted register (e.g. carry, or temporary result).
Definition: MachineInstrBuilder.h:46
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1567
llvm::ARCISD::BL
@ BL
Definition: ARCISelLowering.h:34
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:160
F
#define F(x, y, z)
Definition: MD5.cpp:56
MachineRegisterInfo.h
llvm::EVT::isSimple
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
Definition: ValueTypes.h:130
llvm::getBLXOpcode
unsigned getBLXOpcode(const MachineFunction &MF)
Definition: ARMBaseInstrInfo.cpp:6504
MachineValueType.h
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:206
llvm::MachineInstrBuilder::addDef
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
Definition: MachineInstrBuilder.h:116
llvm::MachineFunction::getRegInfo
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Definition: MachineFunction.h:632
llvm::CCValAssign
CCValAssign - Represent assignment of one arg/retval to a location.
Definition: CallingConvLower.h:33
llvm::MachineIRBuilder::buildLoad
MachineInstrBuilder buildLoad(const DstOp &Res, const SrcOp &Addr, MachineMemOperand &MMO)
Build and insert Res = G_LOAD Addr, MMO.
Definition: MachineIRBuilder.h:832
llvm::ISD::ArgFlagsTy::isByVal
bool isByVal() const
Definition: TargetCallingConv.h:85
llvm::MachineIRBuilder::setMBB
void setMBB(MachineBasicBlock &MBB)
Set the insertion point to the end of MBB.
Definition: MachineIRBuilder.h:324
llvm::CCValAssign::getLocReg
Register getLocReg() const
Definition: CallingConvLower.h:150
llvm::CallLowering::ArgInfo
Definition: CallLowering.h:61
llvm::EVT
Extended Value Type.
Definition: ValueTypes.h:35
llvm::MVT::f64
@ f64
Definition: MachineValueType.h:56
llvm::Register::isPhysicalRegister
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
Definition: Register.h:65
Utils.h
llvm::FormalArgHandler
Definition: M68kCallLowering.h:65
llvm::CallLowering::OutgoingValueAssigner
Definition: CallLowering.h:216
ARMBaseInfo.h
llvm::EVT::isInteger
bool isInteger() const
Return true if this is an integer or a vector integer type.
Definition: ValueTypes.h:145
llvm::MachineIRBuilder::getMF
MachineFunction & getMF()
Getter for the function we currently build.
Definition: MachineIRBuilder.h:262
llvm::CallLowering::IncomingValueHandler
Base class for ValueHandlers used for arguments coming into the current function, or for return value...
Definition: CallLowering.h:308
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
llvm::CCValAssign::getLocInfo
LocInfo getLocInfo() const
Definition: CallingConvLower.h:155
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::CCValAssign::isRegLoc
bool isRegLoc() const
Definition: CallingConvLower.h:145
Type.h
llvm::MachineInstrBuilder::getReg
Register getReg(unsigned Idx) const
Get the register for the operand index.
Definition: MachineInstrBuilder.h:94
llvm::ARMCallLowering::lowerFormalArguments
bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F, ArrayRef< ArrayRef< Register >> VRegs, FunctionLoweringInfo &FLI) const override
This hook must be implemented to lower the incoming (formal) arguments, described by VRegs,...
Definition: ARMCallLowering.cpp:354
LowLevelTypeImpl.h
llvm::ARMSubtarget::getRegBankInfo
const RegisterBankInfo * getRegBankInfo() const override
Definition: ARMSubtarget.cpp:139
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::LLT::pointer
static LLT pointer(unsigned AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space.
Definition: LowLevelTypeImpl.h:50
llvm::ARMCC::AL
@ AL
Definition: ARMBaseInfo.h:45
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:622
llvm::AttributeList::ReturnIndex
@ ReturnIndex
Definition: Attributes.h:401
llvm::MachineIRBuilder
Helper class to build MachineInstr.
Definition: MachineIRBuilder.h:212
llvm::ARMSubtarget::isThumb1Only
bool isThumb1Only() const
Definition: ARMSubtarget.h:811
llvm::CCValAssign::SExt
@ SExt
Definition: CallingConvLower.h:37
llvm::MachineInstrBuilder
Definition: MachineInstrBuilder.h:69
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
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:38
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:57
llvm::inferAlignFromPtrInfo
Align inferAlignFromPtrInfo(MachineFunction &MF, const MachinePointerInfo &MPO)
Definition: Utils.cpp:608
Analysis.h
getCallOpcode
static unsigned getCallOpcode(const MachineFunction &CallerF, bool IsIndirect, bool IsTailCall)
Definition: AArch64CallLowering.cpp:840
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
llvm::MVT::getSizeInBits
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
Definition: MachineValueType.h:860
llvm::MachineIRBuilder::getMBB
const MachineBasicBlock & getMBB() const
Getter for the basic block we currently build.
Definition: MachineIRBuilder.h:287
std::swap
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:840
llvm::MachineFunction::getFrameInfo
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Definition: MachineFunction.h:638
ARMBaseInstrInfo.h
llvm::gettBLXrOpcode
unsigned gettBLXrOpcode(const MachineFunction &MF)
Definition: ARMBaseInstrInfo.cpp:6509
llvm::MachineRegisterInfo::createGenericVirtualRegister
Register createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
Definition: MachineRegisterInfo.cpp:188
llvm::LLT::isScalar
bool isScalar() const
Definition: LowLevelTypeImpl.h:119
llvm::MachineFunction
Definition: MachineFunction.h:230
llvm::MachineIRBuilder::buildInstr
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
Definition: MachineIRBuilder.h:367
llvm::CCValAssign::getValNo
unsigned getValNo() const
Definition: CallingConvLower.h:142
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::EVT::isVector
bool isVector() const
Return true if this is a vector value type.
Definition: ValueTypes.h:155
llvm::ARMSubtarget::getRegisterInfo
const ARMBaseRegisterInfo * getRegisterInfo() const override
Definition: ARMSubtarget.h:574
DataLayout.h
llvm::MachineIRBuilder::insertInstr
MachineInstrBuilder insertInstr(MachineInstrBuilder MIB)
Insert an existing instruction at the insertion point.
Definition: MachineIRBuilder.cpp:45
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:256
llvm::MachineIRBuilder::buildCopy
MachineInstrBuilder buildCopy(const DstOp &Res, const SrcOp &Op)
Build and insert Res = COPY Op.
Definition: MachineIRBuilder.cpp:238
llvm::ISD::ArgFlagsTy
Definition: TargetCallingConv.h:27
TargetSubtargetInfo.h
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::ARMCallLowering::lowerCall
bool lowerCall(MachineIRBuilder &MIRBuilder, CallLoweringInfo &Info) const override
This hook must be implemented to lower the given call instruction, including argument and return valu...
Definition: ARMCallLowering.cpp:445
llvm::ARMSubtarget::hasV4TOps
bool hasV4TOps() const
Definition: ARMSubtarget.h:605
llvm::MachinePointerInfo::getAddrSpace
unsigned getAddrSpace() const
Return the LLVM IR address space number that this pointer points into.
Definition: MachineOperand.cpp:978
llvm::MachineMemOperand::MOLoad
@ MOLoad
The memory access reads data.
Definition: MachineMemOperand.h:135
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::MachineBasicBlock::addLiveIn
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
Definition: MachineBasicBlock.h:367
llvm::MachineIRBuilder::buildFrameIndex
MachineInstrBuilder buildFrameIndex(const DstOp &Res, int Idx)
Build and insert Res = G_FRAME_INDEX Idx.
Definition: MachineIRBuilder.cpp:137
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
Attributes.h
llvm::MachineIRBuilder::buildTrunc
MachineInstrBuilder buildTrunc(const DstOp &Res, const SrcOp &Op)
Build and insert Res = G_TRUNC Op.
Definition: MachineIRBuilder.cpp:736
CallingConvLower.h
llvm::CallLowering::ValueHandler::MRI
MachineRegisterInfo & MRI
Definition: CallLowering.h:224
MachineFrameInfo.h
llvm::CallLowering::determineAndHandleAssignments
bool determineAndHandleAssignments(ValueHandler &Handler, ValueAssigner &Assigner, SmallVectorImpl< ArgInfo > &Args, MachineIRBuilder &MIRBuilder, CallingConv::ID CallConv, bool IsVarArg, Register ThisReturnReg=Register()) const
Invoke ValueAssigner::assignArg on each of the given Args and then use Handler to move them to the as...
Definition: CallLowering.cpp:518
Casting.h
Function.h
llvm::CallLowering::CallLoweringInfo
Definition: CallLowering.h:101
llvm::CallLowering::ValueAssigner::StackOffset
uint64_t StackOffset
Stack offset for next argument.
Definition: CallLowering.h:197
llvm::SmallVectorImpl::clear
void clear()
Definition: SmallVector.h:585
llvm::CallLowering::ValueHandler::MIRBuilder
MachineIRBuilder & MIRBuilder
Definition: CallLowering.h:223
llvm::MachineMemOperand::MOStore
@ MOStore
The memory access writes data.
Definition: MachineMemOperand.h:137
ARMISelLowering.h
SmallVector.h
llvm::MachinePointerInfo::getFixedStack
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
Definition: MachineOperand.cpp:1003
llvm::MachineBasicBlock::begin
iterator begin()
Definition: MachineBasicBlock.h:268
llvm::MachineRegisterInfo::getType
LLT getType(Register Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register.
Definition: MachineRegisterInfo.h:732
MachineInstrBuilder.h
llvm::CCValAssign::getValVT
MVT getValVT() const
Definition: CallingConvLower.h:143
llvm::DstOp
Definition: MachineIRBuilder.h:58
llvm::constrainOperandRegClass
Register constrainOperandRegClass(const MachineFunction &MF, const TargetRegisterInfo &TRI, MachineRegisterInfo &MRI, const TargetInstrInfo &TII, const RegisterBankInfo &RBI, MachineInstr &InsertPt, const TargetRegisterClass &RegClass, MachineOperand &RegMO)
Constrain the Register operand OpIdx, so that it is now constrained to the TargetRegisterClass passed...
Definition: Utils.cpp:48
llvm::MachineFunction::getDataLayout
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Definition: MachineFunction.cpp:260
llvm::MachineIRBuilder::buildMerge
MachineInstrBuilder buildMerge(const DstOp &Res, ArrayRef< Register > Ops)
Build and insert Res = G_MERGE_VALUES Op0, ...
Definition: MachineIRBuilder.cpp:586
llvm::MachineBasicBlock::empty
bool empty() const
Definition: MachineBasicBlock.h:240
MachineMemOperand.h
MachineOperand.h
isSupportedType
static bool isSupportedType(const DataLayout &DL, const ARMTargetLowering &TLI, Type *T)
Definition: ARMCallLowering.cpp:55
DerivedTypes.h
llvm::predOps
static std::array< MachineOperand, 2 > predOps(ARMCC::CondCodes Pred, unsigned PredReg=0)
Get the operands corresponding to the given Pred value.
Definition: ARMBaseInstrInfo.h:541
llvm::TargetLoweringBase::getValueType
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
Definition: TargetLowering.h:1408
llvm::ARMCallLowering::lowerReturn
bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val, ArrayRef< Register > VRegs, FunctionLoweringInfo &FLI) const override
This hook behaves as the extended lowerReturn function, but for targets that do not support swifterro...
Definition: ARMCallLowering.cpp:205
MachineFunction.h
llvm::LLT::scalar
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
Definition: LowLevelTypeImpl.h:43
Value.h
llvm::CallLowering
Definition: CallLowering.h:43
llvm::MachinePointerInfo::getStack
static MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset, uint8_t ID=0)
Stack pointer relative access.
Definition: MachineOperand.cpp:1016
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
TargetRegisterInfo.h
llvm::AttributeList::FirstArgIndex
@ FirstArgIndex
Definition: Attributes.h:403
llvm::EVT::isFloatingPoint
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
Definition: ValueTypes.h:140
llvm::TargetRegisterInfo::getCallPreservedMask
virtual const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const
Return a mask of call-preserved registers for the given calling convention on the current function.
Definition: TargetRegisterInfo.h:485
llvm::CCValAssign::needsCustom
bool needsCustom() const
Definition: CallingConvLower.h:148
llvm::FormalArgHandler::FormalArgHandler
FormalArgHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
Definition: M68kCallLowering.h:66
llvm::ARMSubtarget::isThumb
bool isThumb() const
Definition: ARMSubtarget.h:809
llvm::EVT::getSimpleVT
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
Definition: ValueTypes.h:289
llvm::ARMCallLowering::ARMCallLowering
ARMCallLowering(const ARMTargetLowering &TLI)
Definition: ARMCallLowering.cpp:52
llvm::LLT
Definition: LowLevelTypeImpl.h:40
llvm::CallLowering::setArgFlags
void setArgFlags(ArgInfo &Arg, unsigned OpIdx, const DataLayout &DL, const FuncInfoTy &FuncInfo) const
Definition: CallLowering.cpp:152