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