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