1 //===- lib/Target/AMDGPU/AMDGPUCallLowering.h - Call lowering -*- C++ -*---===//
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
7 //===----------------------------------------------------------------------===//
10 /// This file describes how to lower LLVM calls to machine code calls.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUCALLLOWERING_H
15 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUCALLLOWERING_H
18 #include "llvm/CodeGen/GlobalISel/CallLowering.h"
22 class AMDGPUTargetLowering
;
23 class MachineInstrBuilder
;
25 class AMDGPUCallLowering
: public CallLowering
{
26 Register
lowerParameterPtr(MachineIRBuilder
&MIRBuilder
, Type
*ParamTy
,
27 uint64_t Offset
) const;
29 void lowerParameter(MachineIRBuilder
&MIRBuilder
, Type
*ParamTy
,
30 uint64_t Offset
, unsigned Align
,
31 Register DstReg
) const;
33 /// A function of this type is used to perform value split action.
34 using SplitArgTy
= std::function
<void(ArrayRef
<Register
>, LLT
, LLT
, int)>;
36 void splitToValueTypes(const ArgInfo
&OrigArgInfo
,
37 SmallVectorImpl
<ArgInfo
> &SplitArgs
,
38 const DataLayout
&DL
, MachineRegisterInfo
&MRI
,
39 CallingConv::ID CallConv
,
40 SplitArgTy SplitArg
) const;
42 bool lowerReturnVal(MachineIRBuilder
&MIRBuilder
,
43 const Value
*Val
, ArrayRef
<Register
> VRegs
,
44 MachineInstrBuilder
&Ret
) const;
47 AMDGPUCallLowering(const AMDGPUTargetLowering
&TLI
);
49 bool lowerReturn(MachineIRBuilder
&MIRBuilder
, const Value
*Val
,
50 ArrayRef
<Register
> VRegs
) const override
;
52 bool lowerFormalArgumentsKernel(MachineIRBuilder
&MIRBuilder
,
54 ArrayRef
<ArrayRef
<Register
>> VRegs
) const;
56 bool lowerFormalArguments(MachineIRBuilder
&MIRBuilder
, const Function
&F
,
57 ArrayRef
<ArrayRef
<Register
>> VRegs
) const override
;
58 static CCAssignFn
*CCAssignFnForCall(CallingConv::ID CC
, bool IsVarArg
);
59 static CCAssignFn
*CCAssignFnForReturn(CallingConv::ID CC
, bool IsVarArg
);
61 } // End of namespace llvm;