1 //===-- M68kCallLowering.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 implements the lowering of LLVM calls to machine code calls for 11 /// GlobalISel. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_LIB_TARGET_M68K_GLSEL_M68KCALLLOWERING_H 16 #define LLVM_LIB_TARGET_M68K_GLSEL_M68KCALLLOWERING_H 17 18 #include "llvm/CodeGen/CallingConvLower.h" 19 #include "llvm/CodeGen/GlobalISel/CallLowering.h" 20 #include "llvm/CodeGen/ValueTypes.h" 21 22 namespace llvm { 23 24 class M68kTargetLowering; 25 class MachineInstrBuilder; 26 27 class M68kCallLowering : public CallLowering { 28 // TODO: We are only supporting return instruction with no value at this time 29 // point 30 31 public: 32 M68kCallLowering(const M68kTargetLowering &TLI); 33 34 bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val, 35 ArrayRef<Register> VRegs, FunctionLoweringInfo &FLI, 36 Register SwiftErrorVReg) const override; 37 38 bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F, 39 ArrayRef<ArrayRef<Register>> VRegs, 40 FunctionLoweringInfo &FLI) const override; 41 42 bool lowerCall(MachineIRBuilder &MIRBuilder, 43 CallLoweringInfo &Info) const override; 44 45 bool enableBigEndian() const override; 46 }; 47 struct M68kIncomingValueHandler : public CallLowering::IncomingValueHandler { 48 M68kIncomingValueHandler(MachineIRBuilder &MIRBuilder, 49 MachineRegisterInfo &MRI) 50 : CallLowering::IncomingValueHandler(MIRBuilder, MRI) {} 51 52 uint64_t StackUsed; 53 54 private: 55 void assignValueToReg(Register ValVReg, Register PhysReg, 56 CCValAssign VA) override; 57 58 void assignValueToAddress(Register ValVReg, Register Addr, LLT MemTy, 59 MachinePointerInfo &MPO, CCValAssign &VA) override; 60 61 Register getStackAddress(uint64_t Size, int64_t Offset, 62 MachinePointerInfo &MPO, 63 ISD::ArgFlagsTy Flags) override; 64 }; 65 66 struct FormalArgHandler : public M68kIncomingValueHandler { 67 FormalArgHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI) 68 : M68kIncomingValueHandler(MIRBuilder, MRI) {} 69 }; 70 71 struct CallReturnHandler : public M68kIncomingValueHandler { 72 CallReturnHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, 73 MachineInstrBuilder &MIB) 74 : M68kIncomingValueHandler(MIRBuilder, MRI), MIB(MIB) {} 75 76 private: 77 void assignValueToReg(Register ValVReg, Register PhysReg, 78 CCValAssign VA) override; 79 80 MachineInstrBuilder &MIB; 81 }; 82 } // end namespace llvm 83 84 #endif // LLVM_LIB_TARGET_M68K_GLSEL_M68KCALLLOWERING_H 85