xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.h (revision cfd6422a5217410fbd66f7a7a8a64d9d85e61229)
1 //===- lib/Target/AMDGPU/AMDGPUCallLowering.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_LIB_TARGET_AMDGPU_AMDGPUCALLLOWERING_H
15 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUCALLLOWERING_H
16 
17 #include "AMDGPU.h"
18 #include "llvm/CodeGen/GlobalISel/CallLowering.h"
19 
20 namespace llvm {
21 
22 class AMDGPUTargetLowering;
23 class MachineInstrBuilder;
24 
25 class AMDGPUCallLowering: public CallLowering {
26   Register lowerParameterPtr(MachineIRBuilder &B, Type *ParamTy,
27                              uint64_t Offset) const;
28 
29   void lowerParameter(MachineIRBuilder &B, Type *ParamTy, uint64_t Offset,
30                       Align Alignment, Register DstReg) const;
31 
32   /// A function of this type is used to perform value split action.
33   using SplitArgTy = std::function<void(ArrayRef<Register>, Register, LLT, LLT, int)>;
34 
35   void splitToValueTypes(MachineIRBuilder &B,
36                          const ArgInfo &OrigArgInfo,
37                          unsigned OrigArgIdx,
38                          SmallVectorImpl<ArgInfo> &SplitArgs,
39                          const DataLayout &DL,
40                          CallingConv::ID CallConv,
41                          SplitArgTy SplitArg) const;
42 
43   bool lowerReturnVal(MachineIRBuilder &B, const Value *Val,
44                       ArrayRef<Register> VRegs, MachineInstrBuilder &Ret) const;
45 
46 public:
47   AMDGPUCallLowering(const AMDGPUTargetLowering &TLI);
48 
49   bool lowerReturn(MachineIRBuilder &B, const Value *Val,
50                    ArrayRef<Register> VRegs) const override;
51 
52   bool lowerFormalArgumentsKernel(MachineIRBuilder &B, const Function &F,
53                                   ArrayRef<ArrayRef<Register>> VRegs) const;
54 
55   bool lowerFormalArguments(MachineIRBuilder &B, const Function &F,
56                             ArrayRef<ArrayRef<Register>> VRegs) const override;
57   static CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg);
58   static CCAssignFn *CCAssignFnForReturn(CallingConv::ID CC, bool IsVarArg);
59 };
60 } // End of namespace llvm;
61 #endif
62