LLVM 20.0.0git
X86CallLowering.cpp
Go to the documentation of this file.
1//===- llvm/lib/Target/X86/X86CallLowering.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 "X86CallLowering.h"
16#include "X86CallingConv.h"
17#include "X86ISelLowering.h"
18#include "X86InstrInfo.h"
20#include "X86RegisterInfo.h"
21#include "X86Subtarget.h"
22#include "llvm/ADT/ArrayRef.h"
42#include "llvm/IR/Attributes.h"
43#include "llvm/IR/DataLayout.h"
44#include "llvm/IR/Function.h"
45#include "llvm/IR/Value.h"
46#include <cassert>
47#include <cstdint>
48
49using namespace llvm;
50
52 : CallLowering(&TLI) {}
53
54namespace {
55
56struct X86OutgoingValueAssigner : public CallLowering::OutgoingValueAssigner {
57private:
58 uint64_t StackSize = 0;
59 unsigned NumXMMRegs = 0;
60
61public:
62 uint64_t getStackSize() { return StackSize; }
63 unsigned getNumXmmRegs() { return NumXMMRegs; }
64
65 X86OutgoingValueAssigner(CCAssignFn *AssignFn_)
66 : CallLowering::OutgoingValueAssigner(AssignFn_) {}
67
68 bool assignArg(unsigned ValNo, EVT OrigVT, MVT ValVT, MVT LocVT,
71 CCState &State) override {
72 bool Res = AssignFn(ValNo, ValVT, LocVT, LocInfo, Flags, State);
73 StackSize = State.getStackSize();
74
75 static const MCPhysReg XMMArgRegs[] = {X86::XMM0, X86::XMM1, X86::XMM2,
76 X86::XMM3, X86::XMM4, X86::XMM5,
77 X86::XMM6, X86::XMM7};
78 if (!Info.IsFixed)
79 NumXMMRegs = State.getFirstUnallocated(XMMArgRegs);
80
81 return Res;
82 }
83};
84
85struct X86OutgoingValueHandler : public CallLowering::OutgoingValueHandler {
86 X86OutgoingValueHandler(MachineIRBuilder &MIRBuilder,
88 : OutgoingValueHandler(MIRBuilder, MRI), MIB(MIB),
89 DL(MIRBuilder.getMF().getDataLayout()),
90 STI(MIRBuilder.getMF().getSubtarget<X86Subtarget>()) {}
91
92 Register getStackAddress(uint64_t Size, int64_t Offset,
94 ISD::ArgFlagsTy Flags) override {
95 LLT p0 = LLT::pointer(0, DL.getPointerSizeInBits(0));
96 LLT SType = LLT::scalar(DL.getPointerSizeInBits(0));
97 auto SPReg =
98 MIRBuilder.buildCopy(p0, STI.getRegisterInfo()->getStackRegister());
99
100 auto OffsetReg = MIRBuilder.buildConstant(SType, Offset);
101
102 auto AddrReg = MIRBuilder.buildPtrAdd(p0, SPReg, OffsetReg);
103
104 MPO = MachinePointerInfo::getStack(MIRBuilder.getMF(), Offset);
105 return AddrReg.getReg(0);
106 }
107
108 void assignValueToReg(Register ValVReg, Register PhysReg,
109 const CCValAssign &VA) override {
110 MIB.addUse(PhysReg, RegState::Implicit);
111 Register ExtReg = extendRegister(ValVReg, VA);
112 MIRBuilder.buildCopy(PhysReg, ExtReg);
113 }
114
115 void assignValueToAddress(Register ValVReg, Register Addr, LLT MemTy,
116 const MachinePointerInfo &MPO,
117 const CCValAssign &VA) override {
118 MachineFunction &MF = MIRBuilder.getMF();
119 Register ExtReg = extendRegister(ValVReg, VA);
120
121 auto *MMO = MF.getMachineMemOperand(MPO, MachineMemOperand::MOStore, MemTy,
122 inferAlignFromPtrInfo(MF, MPO));
123 MIRBuilder.buildStore(ExtReg, Addr, *MMO);
124 }
125
126protected:
128 const DataLayout &DL;
129 const X86Subtarget &STI;
130};
131
132} // end anonymous namespace
133
135 MachineFunction &MF, CallingConv::ID CallConv,
136 SmallVectorImpl<CallLowering::BaseArgInfo> &Outs, bool IsVarArg) const {
137 LLVMContext &Context = MF.getFunction().getContext();
139 CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, Context);
140 return checkReturn(CCInfo, Outs, RetCC_X86);
141}
142
144 const Value *Val, ArrayRef<Register> VRegs,
145 FunctionLoweringInfo &FLI) const {
146 assert(((Val && !VRegs.empty()) || (!Val && VRegs.empty())) &&
147 "Return value without a vreg");
148 MachineFunction &MF = MIRBuilder.getMF();
149 auto MIB = MIRBuilder.buildInstrNoInsert(X86::RET).addImm(0);
150 auto FuncInfo = MF.getInfo<X86MachineFunctionInfo>();
151 const auto &STI = MF.getSubtarget<X86Subtarget>();
152 Register RetReg = STI.is64Bit() ? X86::RAX : X86::EAX;
153
154 if (!FLI.CanLowerReturn) {
155 insertSRetStores(MIRBuilder, Val->getType(), VRegs, FLI.DemoteRegister);
156 MIRBuilder.buildCopy(RetReg, FLI.DemoteRegister);
157 MIB.addReg(RetReg);
158 } else if (Register Reg = FuncInfo->getSRetReturnReg()) {
159 MIRBuilder.buildCopy(RetReg, Reg);
160 MIB.addReg(RetReg);
161 } else if (!VRegs.empty()) {
162 const Function &F = MF.getFunction();
164 const DataLayout &DL = MF.getDataLayout();
165
166 ArgInfo OrigRetInfo(VRegs, Val->getType(), 0);
168
169 SmallVector<ArgInfo, 4> SplitRetInfos;
170 splitToValueTypes(OrigRetInfo, SplitRetInfos, DL, F.getCallingConv());
171
172 X86OutgoingValueAssigner Assigner(RetCC_X86);
173 X86OutgoingValueHandler Handler(MIRBuilder, MRI, MIB);
174 if (!determineAndHandleAssignments(Handler, Assigner, SplitRetInfos,
175 MIRBuilder, F.getCallingConv(),
176 F.isVarArg()))
177 return false;
178 }
179
180 MIRBuilder.insertInstr(MIB);
181 return true;
182}
183
184namespace {
185
186struct X86IncomingValueHandler : public CallLowering::IncomingValueHandler {
187 X86IncomingValueHandler(MachineIRBuilder &MIRBuilder,
189 : IncomingValueHandler(MIRBuilder, MRI),
190 DL(MIRBuilder.getMF().getDataLayout()) {}
191
192 Register getStackAddress(uint64_t Size, int64_t Offset,
194 ISD::ArgFlagsTy Flags) override {
195 auto &MFI = MIRBuilder.getMF().getFrameInfo();
196
197 // Byval is assumed to be writable memory, but other stack passed arguments
198 // are not.
199 const bool IsImmutable = !Flags.isByVal();
200
201 int FI = MFI.CreateFixedObject(Size, Offset, IsImmutable);
202 MPO = MachinePointerInfo::getFixedStack(MIRBuilder.getMF(), FI);
203
204 return MIRBuilder
205 .buildFrameIndex(LLT::pointer(0, DL.getPointerSizeInBits(0)), FI)
206 .getReg(0);
207 }
208
209 void assignValueToAddress(Register ValVReg, Register Addr, LLT MemTy,
210 const MachinePointerInfo &MPO,
211 const CCValAssign &VA) override {
212 MachineFunction &MF = MIRBuilder.getMF();
213 auto *MMO = MF.getMachineMemOperand(
215 inferAlignFromPtrInfo(MF, MPO));
216 MIRBuilder.buildLoad(ValVReg, Addr, *MMO);
217 }
218
219 void assignValueToReg(Register ValVReg, Register PhysReg,
220 const CCValAssign &VA) override {
221 markPhysRegUsed(PhysReg);
222 IncomingValueHandler::assignValueToReg(ValVReg, PhysReg, VA);
223 }
224
225 /// How the physical register gets marked varies between formal
226 /// parameters (it's a basic-block live-in), and a call instruction
227 /// (it's an implicit-def of the BL).
228 virtual void markPhysRegUsed(unsigned PhysReg) = 0;
229
230protected:
231 const DataLayout &DL;
232};
233
234struct FormalArgHandler : public X86IncomingValueHandler {
236 : X86IncomingValueHandler(MIRBuilder, MRI) {}
237
238 void markPhysRegUsed(unsigned PhysReg) override {
239 MIRBuilder.getMRI()->addLiveIn(PhysReg);
240 MIRBuilder.getMBB().addLiveIn(PhysReg);
241 }
242};
243
244struct CallReturnHandler : public X86IncomingValueHandler {
245 CallReturnHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI,
247 : X86IncomingValueHandler(MIRBuilder, MRI), MIB(MIB) {}
248
249 void markPhysRegUsed(unsigned PhysReg) override {
250 MIB.addDef(PhysReg, RegState::Implicit);
251 }
252
253protected:
255};
256
257} // end anonymous namespace
258
260 const Function &F,
262 FunctionLoweringInfo &FLI) const {
263 MachineFunction &MF = MIRBuilder.getMF();
265 auto DL = MF.getDataLayout();
266 auto FuncInfo = MF.getInfo<X86MachineFunctionInfo>();
267
268 SmallVector<ArgInfo, 8> SplitArgs;
269
270 if (!FLI.CanLowerReturn)
271 insertSRetIncomingArgument(F, SplitArgs, FLI.DemoteRegister, MRI, DL);
272
273 // TODO: handle variadic function
274 if (F.isVarArg())
275 return false;
276
277 unsigned Idx = 0;
278 for (const auto &Arg : F.args()) {
279 // TODO: handle not simple cases.
280 if (Arg.hasAttribute(Attribute::ByVal) ||
281 Arg.hasAttribute(Attribute::InReg) ||
282 Arg.hasAttribute(Attribute::SwiftSelf) ||
283 Arg.hasAttribute(Attribute::SwiftError) ||
284 Arg.hasAttribute(Attribute::Nest) || VRegs[Idx].size() > 1)
285 return false;
286
287 if (Arg.hasAttribute(Attribute::StructRet)) {
288 assert(VRegs[Idx].size() == 1 &&
289 "Unexpected amount of registers for sret argument.");
290 FuncInfo->setSRetReturnReg(VRegs[Idx][0]);
291 }
292
293 ArgInfo OrigArg(VRegs[Idx], Arg.getType(), Idx);
295 splitToValueTypes(OrigArg, SplitArgs, DL, F.getCallingConv());
296 Idx++;
297 }
298
299 if (SplitArgs.empty())
300 return true;
301
302 MachineBasicBlock &MBB = MIRBuilder.getMBB();
303 if (!MBB.empty())
304 MIRBuilder.setInstr(*MBB.begin());
305
306 X86OutgoingValueAssigner Assigner(CC_X86);
307 FormalArgHandler Handler(MIRBuilder, MRI);
308 if (!determineAndHandleAssignments(Handler, Assigner, SplitArgs, MIRBuilder,
309 F.getCallingConv(), F.isVarArg()))
310 return false;
311
312 // Move back to the end of the basic block.
313 MIRBuilder.setMBB(MBB);
314
315 return true;
316}
317
319 CallLoweringInfo &Info) const {
320 MachineFunction &MF = MIRBuilder.getMF();
321 const Function &F = MF.getFunction();
323 const DataLayout &DL = F.getDataLayout();
324 const X86Subtarget &STI = MF.getSubtarget<X86Subtarget>();
325 const TargetInstrInfo &TII = *STI.getInstrInfo();
326 const X86RegisterInfo *TRI = STI.getRegisterInfo();
327
328 // Handle only Linux C, X86_64_SysV calling conventions for now.
329 if (!STI.isTargetLinux() || !(Info.CallConv == CallingConv::C ||
330 Info.CallConv == CallingConv::X86_64_SysV))
331 return false;
332
333 unsigned AdjStackDown = TII.getCallFrameSetupOpcode();
334 auto CallSeqStart = MIRBuilder.buildInstr(AdjStackDown);
335
336 // Create a temporarily-floating call instruction so we can add the implicit
337 // uses of arg registers.
338 bool Is64Bit = STI.is64Bit();
339 unsigned CallOpc = Info.Callee.isReg()
340 ? (Is64Bit ? X86::CALL64r : X86::CALL32r)
341 : (Is64Bit ? X86::CALL64pcrel32 : X86::CALLpcrel32);
342
343 auto MIB = MIRBuilder.buildInstrNoInsert(CallOpc)
344 .add(Info.Callee)
345 .addRegMask(TRI->getCallPreservedMask(MF, Info.CallConv));
346
347 SmallVector<ArgInfo, 8> SplitArgs;
348 for (const auto &OrigArg : Info.OrigArgs) {
349
350 // TODO: handle not simple cases.
351 if (OrigArg.Flags[0].isByVal())
352 return false;
353
354 if (OrigArg.Regs.size() > 1)
355 return false;
356
357 splitToValueTypes(OrigArg, SplitArgs, DL, Info.CallConv);
358 }
359 // Do the actual argument marshalling.
360 X86OutgoingValueAssigner Assigner(CC_X86);
361 X86OutgoingValueHandler Handler(MIRBuilder, MRI, MIB);
362 if (!determineAndHandleAssignments(Handler, Assigner, SplitArgs, MIRBuilder,
363 Info.CallConv, Info.IsVarArg))
364 return false;
365
366 bool IsFixed = Info.OrigArgs.empty() ? true : Info.OrigArgs.back().IsFixed;
367 if (STI.is64Bit() && !IsFixed && !STI.isCallingConvWin64(Info.CallConv)) {
368 // From AMD64 ABI document:
369 // For calls that may call functions that use varargs or stdargs
370 // (prototype-less calls or calls to functions containing ellipsis (...) in
371 // the declaration) %al is used as hidden argument to specify the number
372 // of SSE registers used. The contents of %al do not need to match exactly
373 // the number of registers, but must be an ubound on the number of SSE
374 // registers used and is in the range 0 - 8 inclusive.
375
376 MIRBuilder.buildInstr(X86::MOV8ri)
377 .addDef(X86::AL)
378 .addImm(Assigner.getNumXmmRegs());
379 MIB.addUse(X86::AL, RegState::Implicit);
380 }
381
382 // Now we can add the actual call instruction to the correct basic block.
383 MIRBuilder.insertInstr(MIB);
384
385 // If Callee is a reg, since it is used by a target specific
386 // instruction, it must have a register class matching the
387 // constraint of that instruction.
388 if (Info.Callee.isReg())
390 MF, *TRI, MRI, *MF.getSubtarget().getInstrInfo(),
391 *MF.getSubtarget().getRegBankInfo(), *MIB, MIB->getDesc(), Info.Callee,
392 0));
393
394 // Finally we can copy the returned value back into its virtual-register. In
395 // symmetry with the arguments, the physical register must be an
396 // implicit-define of the call instruction.
397
398 if (Info.CanLowerReturn && !Info.OrigRet.Ty->isVoidTy()) {
399 if (Info.OrigRet.Regs.size() > 1)
400 return false;
401
402 SplitArgs.clear();
404
405 splitToValueTypes(Info.OrigRet, SplitArgs, DL, Info.CallConv);
406
407 X86OutgoingValueAssigner Assigner(RetCC_X86);
408 CallReturnHandler Handler(MIRBuilder, MRI, MIB);
409 if (!determineAndHandleAssignments(Handler, Assigner, SplitArgs, MIRBuilder,
410 Info.CallConv, Info.IsVarArg))
411 return false;
412
413 if (!NewRegs.empty())
414 MIRBuilder.buildMergeLikeInstr(Info.OrigRet.Regs[0], NewRegs);
415 }
416
417 CallSeqStart.addImm(Assigner.getStackSize())
418 .addImm(0 /* see getFrameTotalSize */)
419 .addImm(0 /* see getFrameAdjustment */);
420
421 unsigned AdjStackUp = TII.getCallFrameDestroyOpcode();
422 MIRBuilder.buildInstr(AdjStackUp)
423 .addImm(Assigner.getStackSize())
424 .addImm(0 /* NumBytesForCalleeToPop */);
425
426 if (!Info.CanLowerReturn)
427 insertSRetLoads(MIRBuilder, Info.OrigRet.Ty, Info.OrigRet.Regs,
428 Info.DemoteRegister, Info.DemoteStackIndex);
429
430 return true;
431}
unsigned const MachineRegisterInfo * MRI
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the simple types necessary to represent the attributes associated with functions a...
basic Basic Alias true
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
uint64_t Addr
uint64_t Size
const HexagonInstrInfo * TII
Implement a low-level type suitable for MachineInstr level instruction selection.
Implement a low-level type suitable for MachineInstr level instruction selection.
#define F(x, y, z)
Definition: MD5.cpp:55
This file declares the MachineIRBuilder class.
unsigned const TargetRegisterInfo * TRI
static constexpr Register SPReg
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
This file describes how to lower LLVM calls to machine code calls.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:163
CCState - This class holds information needed while lowering arguments and return values.
unsigned getFirstUnallocated(ArrayRef< MCPhysReg > Regs) const
getFirstUnallocated - Return the index of the first unallocated register in the set,...
uint64_t getStackSize() const
Returns the size of the currently allocated portion of the stack.
CCValAssign - Represent assignment of one arg/retval to a location.
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.
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.
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.
bool determineAndHandleAssignments(ValueHandler &Handler, ValueAssigner &Assigner, SmallVectorImpl< ArgInfo > &Args, MachineIRBuilder &MIRBuilder, CallingConv::ID CallConv, bool IsVarArg, ArrayRef< Register > ThisReturnRegs={}) const
Invoke ValueAssigner::assignArg on each of the given Args and then use Handler to move them to the as...
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.
bool checkReturn(CCState &CCInfo, SmallVectorImpl< BaseArgInfo > &Outs, CCAssignFn *Fn) const
void setArgFlags(ArgInfo &Arg, unsigned OpIdx, const DataLayout &DL, const FuncInfoTy &FuncInfo) const
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:63
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Definition: Function.cpp:369
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
Definition: LowLevelType.h:42
static constexpr LLT pointer(unsigned AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space.
Definition: LowLevelType.h:57
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
Machine Value Type.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, LLT MemTy, 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.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Function & getFunction()
Return the LLVM function that this machine code represents.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Helper class to build MachineInstr.
MachineInstrBuilder insertInstr(MachineInstrBuilder MIB)
Insert an existing instruction at the insertion point.
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
MachineInstrBuilder buildMergeLikeInstr(const DstOp &Res, ArrayRef< Register > Ops)
Build and insert Res = G_MERGE_VALUES Op0, ... or Res = G_BUILD_VECTOR Op0, ... or Res = G_CONCAT_VEC...
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
MachineFunction & getMF()
Getter for the function we currently build.
const MachineBasicBlock & getMBB() const
Getter for the basic block we currently build.
void setMBB(MachineBasicBlock &MBB)
Set the insertion point to the end of MBB.
MachineRegisterInfo * getMRI()
Getter for MRI.
MachineInstrBuilder buildInstrNoInsert(unsigned Opcode)
Build but don't insert <empty> = Opcode <empty>.
MachineInstrBuilder buildCopy(const DstOp &Res, const SrcOp &Op)
Build and insert Res = COPY Op.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addUse(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:585
@ MOLoad
The memory access reads data.
@ MOInvariant
The memory access always returns the same value (or traps).
@ MOStore
The memory access writes data.
void setReg(Register Reg)
Change the register this operand corresponds to.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
void addLiveIn(MCRegister Reg, Register vreg=Register())
addLiveIn - Add the specified register as a live-in.
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
bool empty() const
Definition: SmallVector.h:81
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
TargetInstrInfo - Interface to description of machine instruction set.
virtual const RegisterBankInfo * getRegBankInfo() const
If the information for the register banks is available, return it.
virtual const TargetInstrInfo * getInstrInfo() const
LLVM Value Representation.
Definition: Value.h:74
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
X86CallLowering(const X86TargetLowering &TLI)
bool lowerCall(MachineIRBuilder &MIRBuilder, CallLoweringInfo &Info) const override
This hook must be implemented to lower the given call instruction, including argument and return valu...
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...
bool canLowerReturn(MachineFunction &MF, CallingConv::ID CallConv, SmallVectorImpl< BaseArgInfo > &Outs, bool IsVarArg) const override
This hook must be implemented to check whether the return values described by Outs can fit into the r...
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,...
X86MachineFunctionInfo - This class is derived from MachineFunction and contains private X86 target-s...
const X86InstrInfo * getInstrInfo() const override
Definition: X86Subtarget.h:122
bool isCallingConvWin64(CallingConv::ID CC) const
Definition: X86Subtarget.h:337
const X86RegisterInfo * getRegisterInfo() const override
Definition: X86Subtarget.h:132
bool isTargetLinux() const
Definition: X86Subtarget.h:290
@ X86_64_SysV
The C convention as specified in the x86-64 supplement to the System V ABI, used on most non-Windows ...
Definition: CallingConv.h:151
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
@ Implicit
Not emitted register (e.g. carry, or temporary result).
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
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:56
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition: STLExtras.h:1697
bool RetCC_X86(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
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.
bool CC_X86(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
Align inferAlignFromPtrInfo(MachineFunction &MF, const MachinePointerInfo &MPO)
Definition: Utils.cpp:878
Base class for ValueHandlers used for arguments coming into the current function, or for return value...
Definition: CallLowering.h:331
Base class for ValueHandlers used for arguments passed to a function call, or for return values.
Definition: CallLowering.h:347
MachineRegisterInfo & MRI
Definition: CallLowering.h:244
Extended Value Type.
Definition: ValueTypes.h:35
This class contains a discriminated union of information about pointers in memory operands,...
static MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset, uint8_t ID=0)
Stack pointer relative access.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.