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