1 //===-- M68kMachineFunctionInfo.h - M68k private data ---------*- 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 declares the M68k specific subclass of MachineFunctionInfo.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_M68K_M68KMACHINEFUNCTION_H
15 #define LLVM_LIB_TARGET_M68K_M68KMACHINEFUNCTION_H
16 
17 #include "llvm/CodeGen/CallingConvLower.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19 #include "llvm/Support/MachineValueType.h"
20 
21 namespace llvm {
22 
23 class M68kMachineFunctionInfo : public MachineFunctionInfo {
24   MachineFunction &MF;
25 
26   /// Non-zero if the function has base pointer and makes call to
27   /// llvm.eh.sjlj.setjmp. When non-zero, the value is a displacement from the
28   /// frame pointer to a slot where the base pointer is stashed.
29   signed char RestoreBasePointerOffset = 0;
30 
31   /// Size of the callee-saved register portion of the stack frame in bytes.
32   unsigned CalleeSavedFrameSize = 0;
33 
34   /// Number of bytes function pops on return (in addition to the space used by
35   /// the return address).  Used on windows platform for stdcall & fastcall
36   /// name decoration
37   unsigned BytesToPopOnReturn = 0;
38 
39   /// FrameIndex for return slot.
40   int ReturnAddrIndex = 0;
41 
42   /// The number of bytes by which return address stack slot is moved as the
43   /// result of tail call optimization.
44   int TailCallReturnAddrDelta = 0;
45 
46   /// keeps track of the virtual register initialized for use as the global
47   /// base register. This is used for PIC in some PIC relocation models.
48   unsigned GlobalBaseReg = 0;
49 
50   /// FrameIndex for start of varargs area.
51   int VarArgsFrameIndex = 0;
52 
53   /// Keeps track of whether this function uses sequences of pushes to pass
54   /// function parameters.
55   bool HasPushSequences = false;
56 
57   /// Some subtargets require that sret lowering includes
58   /// returning the value of the returned struct in a register. This field
59   /// holds the virtual register into which the sret argument is passed.
60   unsigned SRetReturnReg = 0;
61 
62   /// A list of virtual and physical registers that must be forwarded to every
63   /// musttail call.
64   SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms;
65 
66   /// The number of bytes on stack consumed by the arguments being passed on
67   /// the stack.
68   unsigned ArgumentStackSize = 0;
69 
70 public:
71   M68kMachineFunctionInfo() = default;
72   explicit M68kMachineFunctionInfo(MachineFunction &MF) : MF(MF) {}
73 
74   bool getRestoreBasePointer() const { return RestoreBasePointerOffset != 0; }
75   void setRestoreBasePointer(const MachineFunction *MF);
76   int getRestoreBasePointerOffset() const { return RestoreBasePointerOffset; }
77 
78   unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
79   void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }
80 
81   unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
82   void setBytesToPopOnReturn(unsigned bytes) { BytesToPopOnReturn = bytes; }
83 
84   int getRAIndex() const { return ReturnAddrIndex; }
85   void setRAIndex(int Index) { ReturnAddrIndex = Index; }
86 
87   int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
88   void setTCReturnAddrDelta(int delta) { TailCallReturnAddrDelta = delta; }
89 
90   unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
91   void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
92 
93   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
94   void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
95 
96   bool getHasPushSequences() const { return HasPushSequences; }
97   void setHasPushSequences(bool HasPush) { HasPushSequences = HasPush; }
98 
99   unsigned getSRetReturnReg() const { return SRetReturnReg; }
100   void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
101 
102   unsigned getArgumentStackSize() const { return ArgumentStackSize; }
103   void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; }
104 
105   SmallVectorImpl<ForwardedRegister> &getForwardedMustTailRegParms() {
106     return ForwardedMustTailRegParms;
107   }
108 
109 private:
110   virtual void anchor();
111 };
112 
113 } // end of namespace llvm
114 
115 #endif // M68K_MACHINE_FUNCTION_INFO_H
116