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 unsigned Align, 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>, LLT, LLT, int)>; 34 35 void splitToValueTypes(const ArgInfo &OrigArgInfo, 36 SmallVectorImpl<ArgInfo> &SplitArgs, 37 const DataLayout &DL, MachineRegisterInfo &MRI, 38 CallingConv::ID CallConv, 39 SplitArgTy SplitArg) const; 40 41 bool lowerReturnVal(MachineIRBuilder &B, const Value *Val, 42 ArrayRef<Register> VRegs, MachineInstrBuilder &Ret) const; 43 44 public: 45 AMDGPUCallLowering(const AMDGPUTargetLowering &TLI); 46 47 bool lowerReturn(MachineIRBuilder &B, const Value *Val, 48 ArrayRef<Register> VRegs) const override; 49 50 bool lowerFormalArgumentsKernel(MachineIRBuilder &B, const Function &F, 51 ArrayRef<ArrayRef<Register>> VRegs) const; 52 53 bool lowerFormalArguments(MachineIRBuilder &B, const Function &F, 54 ArrayRef<ArrayRef<Register>> VRegs) const override; 55 static CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg); 56 static CCAssignFn *CCAssignFnForReturn(CallingConv::ID CC, bool IsVarArg); 57 }; 58 } // End of namespace llvm; 59 #endif 60