xref: /freebsd/contrib/llvm-project/llvm/lib/Target/M68k/GISel/M68kCallLowering.h (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
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                         const CCValAssign &VA) override;
57 
58   void assignValueToAddress(Register ValVReg, Register Addr, LLT MemTy,
59                             const MachinePointerInfo &MPO,
60                             const CCValAssign &VA) override;
61 
62   Register getStackAddress(uint64_t Size, int64_t Offset,
63                            MachinePointerInfo &MPO,
64                            ISD::ArgFlagsTy Flags) override;
65 };
66 } // end namespace llvm
67 
68 #endif // LLVM_LIB_TARGET_M68K_GLSEL_M68KCALLLOWERING_H
69