1 //=== SystemZMachineFunctionInfo.h - SystemZ machine function info -*- 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 #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZMACHINEFUNCTIONINFO_H
10 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZMACHINEFUNCTIONINFO_H
11 
12 #include "llvm/CodeGen/MachineFunction.h"
13 
14 namespace llvm {
15 
16 namespace SystemZ {
17 // A struct to hold the low and high GPR registers to be saved/restored as
18 // well as the offset into the register save area of the low register.
19 struct GPRRegs {
20   unsigned LowGPR;
21   unsigned HighGPR;
22   unsigned GPROffset;
GPRRegsGPRRegs23   GPRRegs() : LowGPR(0), HighGPR(0), GPROffset(0) {}
24   };
25 }
26 
27 class SystemZMachineFunctionInfo : public MachineFunctionInfo {
28   virtual void anchor();
29 
30   SystemZ::GPRRegs SpillGPRRegs;
31   SystemZ::GPRRegs RestoreGPRRegs;
32   Register VarArgsFirstGPR;
33   Register VarArgsFirstFPR;
34   unsigned VarArgsFrameIndex;
35   unsigned RegSaveFrameIndex;
36   int FramePointerSaveIndex;
37   unsigned NumLocalDynamics;
38 
39 public:
SystemZMachineFunctionInfo(const Function & F,const TargetSubtargetInfo * STI)40   SystemZMachineFunctionInfo(const Function &F, const TargetSubtargetInfo *STI)
41       : VarArgsFirstGPR(0), VarArgsFirstFPR(0), VarArgsFrameIndex(0),
42         RegSaveFrameIndex(0), FramePointerSaveIndex(0), NumLocalDynamics(0) {}
43 
44   MachineFunctionInfo *
45   clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF,
46         const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB)
47       const override;
48 
49   // Get and set the first and last call-saved GPR that should be saved by
50   // this function and the SP offset for the STMG.  These are 0 if no GPRs
51   // need to be saved or restored.
getSpillGPRRegs()52   SystemZ::GPRRegs getSpillGPRRegs() const { return SpillGPRRegs; }
setSpillGPRRegs(Register Low,Register High,unsigned Offs)53   void setSpillGPRRegs(Register Low, Register High, unsigned Offs) {
54     SpillGPRRegs.LowGPR = Low;
55     SpillGPRRegs.HighGPR = High;
56     SpillGPRRegs.GPROffset = Offs;
57   }
58 
59   // Get and set the first and last call-saved GPR that should be restored by
60   // this function and the SP offset for the LMG.  These are 0 if no GPRs
61   // need to be saved or restored.
getRestoreGPRRegs()62   SystemZ::GPRRegs getRestoreGPRRegs() const { return RestoreGPRRegs; }
setRestoreGPRRegs(Register Low,Register High,unsigned Offs)63   void setRestoreGPRRegs(Register Low, Register High, unsigned Offs) {
64     RestoreGPRRegs.LowGPR = Low;
65     RestoreGPRRegs.HighGPR = High;
66     RestoreGPRRegs.GPROffset = Offs;
67   }
68 
69   // Get and set the number of fixed (as opposed to variable) arguments
70   // that are passed in GPRs to this function.
getVarArgsFirstGPR()71   Register getVarArgsFirstGPR() const { return VarArgsFirstGPR; }
setVarArgsFirstGPR(Register GPR)72   void setVarArgsFirstGPR(Register GPR) { VarArgsFirstGPR = GPR; }
73 
74   // Likewise FPRs.
getVarArgsFirstFPR()75   Register getVarArgsFirstFPR() const { return VarArgsFirstFPR; }
setVarArgsFirstFPR(Register FPR)76   void setVarArgsFirstFPR(Register FPR) { VarArgsFirstFPR = FPR; }
77 
78   // Get and set the frame index of the first stack vararg.
getVarArgsFrameIndex()79   unsigned getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
setVarArgsFrameIndex(unsigned FI)80   void setVarArgsFrameIndex(unsigned FI) { VarArgsFrameIndex = FI; }
81 
82   // Get and set the frame index of the register save area
83   // (i.e. the incoming stack pointer).
getRegSaveFrameIndex()84   unsigned getRegSaveFrameIndex() const { return RegSaveFrameIndex; }
setRegSaveFrameIndex(unsigned FI)85   void setRegSaveFrameIndex(unsigned FI) { RegSaveFrameIndex = FI; }
86 
87   // Get and set the frame index of where the old frame pointer is stored.
getFramePointerSaveIndex()88   int getFramePointerSaveIndex() const { return FramePointerSaveIndex; }
setFramePointerSaveIndex(int Idx)89   void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; }
90 
91   // Count number of local-dynamic TLS symbols used.
getNumLocalDynamicTLSAccesses()92   unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
incNumLocalDynamicTLSAccesses()93   void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
94 };
95 
96 } // end namespace llvm
97 
98 #endif
99