xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZMachineFunctionInfo.h (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
10b57cec5SDimitry Andric //=== SystemZMachineFunctionInfo.h - SystemZ machine function info -*- C++ -*-//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZMACHINEFUNCTIONINFO_H
100b57cec5SDimitry Andric #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZMACHINEFUNCTIONINFO_H
110b57cec5SDimitry Andric 
120b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFunction.h"
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric namespace llvm {
150b57cec5SDimitry Andric 
16480093f4SDimitry Andric namespace SystemZ {
17480093f4SDimitry Andric // A struct to hold the low and high GPR registers to be saved/restored as
18480093f4SDimitry Andric // well as the offset into the register save area of the low register.
19480093f4SDimitry Andric struct GPRRegs {
20480093f4SDimitry Andric   unsigned LowGPR;
21480093f4SDimitry Andric   unsigned HighGPR;
22480093f4SDimitry Andric   unsigned GPROffset;
23480093f4SDimitry Andric   GPRRegs() : LowGPR(0), HighGPR(0), GPROffset(0) {}
24480093f4SDimitry Andric   };
25480093f4SDimitry Andric }
26480093f4SDimitry Andric 
270b57cec5SDimitry Andric class SystemZMachineFunctionInfo : public MachineFunctionInfo {
280b57cec5SDimitry Andric   virtual void anchor();
29480093f4SDimitry Andric 
30480093f4SDimitry Andric   SystemZ::GPRRegs SpillGPRRegs;
31480093f4SDimitry Andric   SystemZ::GPRRegs RestoreGPRRegs;
325ffd83dbSDimitry Andric   Register VarArgsFirstGPR;
335ffd83dbSDimitry Andric   Register VarArgsFirstFPR;
340b57cec5SDimitry Andric   unsigned VarArgsFrameIndex;
350b57cec5SDimitry Andric   unsigned RegSaveFrameIndex;
360b57cec5SDimitry Andric   int FramePointerSaveIndex;
370b57cec5SDimitry Andric   unsigned NumLocalDynamics;
380b57cec5SDimitry Andric 
390b57cec5SDimitry Andric public:
400b57cec5SDimitry Andric   explicit SystemZMachineFunctionInfo(MachineFunction &MF)
41480093f4SDimitry Andric     : VarArgsFirstGPR(0), VarArgsFirstFPR(0), VarArgsFrameIndex(0),
4204eeddc0SDimitry Andric       RegSaveFrameIndex(0), FramePointerSaveIndex(0), NumLocalDynamics(0) {}
430b57cec5SDimitry Andric 
44*81ad6265SDimitry Andric   MachineFunctionInfo *
45*81ad6265SDimitry Andric   clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF,
46*81ad6265SDimitry Andric         const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB)
47*81ad6265SDimitry Andric       const override;
48*81ad6265SDimitry Andric 
49480093f4SDimitry Andric   // Get and set the first and last call-saved GPR that should be saved by
50480093f4SDimitry Andric   // this function and the SP offset for the STMG.  These are 0 if no GPRs
51480093f4SDimitry Andric   // need to be saved or restored.
52480093f4SDimitry Andric   SystemZ::GPRRegs getSpillGPRRegs() const { return SpillGPRRegs; }
535ffd83dbSDimitry Andric   void setSpillGPRRegs(Register Low, Register High, unsigned Offs) {
54480093f4SDimitry Andric     SpillGPRRegs.LowGPR = Low;
55480093f4SDimitry Andric     SpillGPRRegs.HighGPR = High;
56480093f4SDimitry Andric     SpillGPRRegs.GPROffset = Offs;
57480093f4SDimitry Andric   }
580b57cec5SDimitry Andric 
59480093f4SDimitry Andric   // Get and set the first and last call-saved GPR that should be restored by
60480093f4SDimitry Andric   // this function and the SP offset for the LMG.  These are 0 if no GPRs
61480093f4SDimitry Andric   // need to be saved or restored.
62480093f4SDimitry Andric   SystemZ::GPRRegs getRestoreGPRRegs() const { return RestoreGPRRegs; }
635ffd83dbSDimitry Andric   void setRestoreGPRRegs(Register Low, Register High, unsigned Offs) {
64480093f4SDimitry Andric     RestoreGPRRegs.LowGPR = Low;
65480093f4SDimitry Andric     RestoreGPRRegs.HighGPR = High;
66480093f4SDimitry Andric     RestoreGPRRegs.GPROffset = Offs;
67480093f4SDimitry Andric   }
680b57cec5SDimitry Andric 
690b57cec5SDimitry Andric   // Get and set the number of fixed (as opposed to variable) arguments
700b57cec5SDimitry Andric   // that are passed in GPRs to this function.
715ffd83dbSDimitry Andric   Register getVarArgsFirstGPR() const { return VarArgsFirstGPR; }
725ffd83dbSDimitry Andric   void setVarArgsFirstGPR(Register GPR) { VarArgsFirstGPR = GPR; }
730b57cec5SDimitry Andric 
740b57cec5SDimitry Andric   // Likewise FPRs.
755ffd83dbSDimitry Andric   Register getVarArgsFirstFPR() const { return VarArgsFirstFPR; }
765ffd83dbSDimitry Andric   void setVarArgsFirstFPR(Register FPR) { VarArgsFirstFPR = FPR; }
770b57cec5SDimitry Andric 
780b57cec5SDimitry Andric   // Get and set the frame index of the first stack vararg.
790b57cec5SDimitry Andric   unsigned getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
800b57cec5SDimitry Andric   void setVarArgsFrameIndex(unsigned FI) { VarArgsFrameIndex = FI; }
810b57cec5SDimitry Andric 
820b57cec5SDimitry Andric   // Get and set the frame index of the register save area
830b57cec5SDimitry Andric   // (i.e. the incoming stack pointer).
840b57cec5SDimitry Andric   unsigned getRegSaveFrameIndex() const { return RegSaveFrameIndex; }
850b57cec5SDimitry Andric   void setRegSaveFrameIndex(unsigned FI) { RegSaveFrameIndex = FI; }
860b57cec5SDimitry Andric 
870b57cec5SDimitry Andric   // Get and set the frame index of where the old frame pointer is stored.
880b57cec5SDimitry Andric   int getFramePointerSaveIndex() const { return FramePointerSaveIndex; }
890b57cec5SDimitry Andric   void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; }
900b57cec5SDimitry Andric 
910b57cec5SDimitry Andric   // Count number of local-dynamic TLS symbols used.
920b57cec5SDimitry Andric   unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
930b57cec5SDimitry Andric   void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
940b57cec5SDimitry Andric };
950b57cec5SDimitry Andric 
960b57cec5SDimitry Andric } // end namespace llvm
970b57cec5SDimitry Andric 
980b57cec5SDimitry Andric #endif
99