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