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; 23 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: 40 explicit SystemZMachineFunctionInfo(MachineFunction &MF) 41 : VarArgsFirstGPR(0), VarArgsFirstFPR(0), VarArgsFrameIndex(0), 42 RegSaveFrameIndex(0), FramePointerSaveIndex(0), NumLocalDynamics(0) {} 43 44 // Get and set the first and last call-saved GPR that should be saved by 45 // this function and the SP offset for the STMG. These are 0 if no GPRs 46 // need to be saved or restored. 47 SystemZ::GPRRegs getSpillGPRRegs() const { return SpillGPRRegs; } 48 void setSpillGPRRegs(Register Low, Register High, unsigned Offs) { 49 SpillGPRRegs.LowGPR = Low; 50 SpillGPRRegs.HighGPR = High; 51 SpillGPRRegs.GPROffset = Offs; 52 } 53 54 // Get and set the first and last call-saved GPR that should be restored by 55 // this function and the SP offset for the LMG. These are 0 if no GPRs 56 // need to be saved or restored. 57 SystemZ::GPRRegs getRestoreGPRRegs() const { return RestoreGPRRegs; } 58 void setRestoreGPRRegs(Register Low, Register High, unsigned Offs) { 59 RestoreGPRRegs.LowGPR = Low; 60 RestoreGPRRegs.HighGPR = High; 61 RestoreGPRRegs.GPROffset = Offs; 62 } 63 64 // Get and set the number of fixed (as opposed to variable) arguments 65 // that are passed in GPRs to this function. 66 Register getVarArgsFirstGPR() const { return VarArgsFirstGPR; } 67 void setVarArgsFirstGPR(Register GPR) { VarArgsFirstGPR = GPR; } 68 69 // Likewise FPRs. 70 Register getVarArgsFirstFPR() const { return VarArgsFirstFPR; } 71 void setVarArgsFirstFPR(Register FPR) { VarArgsFirstFPR = FPR; } 72 73 // Get and set the frame index of the first stack vararg. 74 unsigned getVarArgsFrameIndex() const { return VarArgsFrameIndex; } 75 void setVarArgsFrameIndex(unsigned FI) { VarArgsFrameIndex = FI; } 76 77 // Get and set the frame index of the register save area 78 // (i.e. the incoming stack pointer). 79 unsigned getRegSaveFrameIndex() const { return RegSaveFrameIndex; } 80 void setRegSaveFrameIndex(unsigned FI) { RegSaveFrameIndex = FI; } 81 82 // Get and set the frame index of where the old frame pointer is stored. 83 int getFramePointerSaveIndex() const { return FramePointerSaveIndex; } 84 void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; } 85 86 // Count number of local-dynamic TLS symbols used. 87 unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; } 88 void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; } 89 }; 90 91 } // end namespace llvm 92 93 #endif 94