#ifndef LLVM_LIB_TARGET_M68K_GLSEL_M68KCALLLOWERING_H
#define LLVM_LIB_TARGET_M68K_GLSEL_M68KCALLLOWERING_H
#include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
#include "llvm/CodeGen/ValueTypes.h"
namespace llvm {
class M68kTargetLowering;
class MachineInstrBuilder;
class M68kCallLowering : public CallLowering {
public:
M68kCallLowering(const M68kTargetLowering &TLI);
bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val,
ArrayRef<Register> VRegs, FunctionLoweringInfo &FLI,
Register SwiftErrorVReg) const override;
bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F,
ArrayRef<ArrayRef<Register>> VRegs,
FunctionLoweringInfo &FLI) const override;
bool lowerCall(MachineIRBuilder &MIRBuilder,
CallLoweringInfo &Info) const override;
bool enableBigEndian() const override;
};
struct M68kIncomingValueHandler : public CallLowering::IncomingValueHandler {
M68kIncomingValueHandler(MachineIRBuilder &MIRBuilder,
MachineRegisterInfo &MRI)
: CallLowering::IncomingValueHandler(MIRBuilder, MRI) {}
uint64_t StackUsed;
private:
void assignValueToReg(Register ValVReg, Register PhysReg,
CCValAssign VA) override;
void assignValueToAddress(Register ValVReg, Register Addr, LLT MemTy,
MachinePointerInfo &MPO, CCValAssign &VA) override;
Register getStackAddress(uint64_t Size, int64_t Offset,
MachinePointerInfo &MPO,
ISD::ArgFlagsTy Flags) override;
};
struct FormalArgHandler : public M68kIncomingValueHandler {
FormalArgHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
: M68kIncomingValueHandler(MIRBuilder, MRI) {}
};
struct CallReturnHandler : public M68kIncomingValueHandler {
CallReturnHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI,
MachineInstrBuilder &MIB)
: M68kIncomingValueHandler(MIRBuilder, MRI), MIB(MIB) {}
private:
void assignValueToReg(Register ValVReg, Register PhysReg,
CCValAssign VA) override;
MachineInstrBuilder &MIB;
};
}
#endif