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 16*480093f4SDimitry Andric namespace SystemZ { 17*480093f4SDimitry Andric // A struct to hold the low and high GPR registers to be saved/restored as 18*480093f4SDimitry Andric // well as the offset into the register save area of the low register. 19*480093f4SDimitry Andric struct GPRRegs { 20*480093f4SDimitry Andric unsigned LowGPR; 21*480093f4SDimitry Andric unsigned HighGPR; 22*480093f4SDimitry Andric unsigned GPROffset; 23*480093f4SDimitry Andric GPRRegs() : LowGPR(0), HighGPR(0), GPROffset(0) {} 24*480093f4SDimitry Andric }; 25*480093f4SDimitry Andric } 26*480093f4SDimitry Andric 270b57cec5SDimitry Andric class SystemZMachineFunctionInfo : public MachineFunctionInfo { 280b57cec5SDimitry Andric virtual void anchor(); 29*480093f4SDimitry Andric 30*480093f4SDimitry Andric SystemZ::GPRRegs SpillGPRRegs; 31*480093f4SDimitry Andric SystemZ::GPRRegs RestoreGPRRegs; 320b57cec5SDimitry Andric unsigned VarArgsFirstGPR; 330b57cec5SDimitry Andric unsigned VarArgsFirstFPR; 340b57cec5SDimitry Andric unsigned VarArgsFrameIndex; 350b57cec5SDimitry Andric unsigned RegSaveFrameIndex; 360b57cec5SDimitry Andric int FramePointerSaveIndex; 370b57cec5SDimitry Andric bool ManipulatesSP; 380b57cec5SDimitry Andric unsigned NumLocalDynamics; 390b57cec5SDimitry Andric 400b57cec5SDimitry Andric public: 410b57cec5SDimitry Andric explicit SystemZMachineFunctionInfo(MachineFunction &MF) 42*480093f4SDimitry Andric : VarArgsFirstGPR(0), VarArgsFirstFPR(0), VarArgsFrameIndex(0), 43*480093f4SDimitry Andric RegSaveFrameIndex(0), FramePointerSaveIndex(0), ManipulatesSP(false), 44*480093f4SDimitry Andric NumLocalDynamics(0) {} 450b57cec5SDimitry Andric 46*480093f4SDimitry Andric // Get and set the first and last call-saved GPR that should be saved by 47*480093f4SDimitry Andric // this function and the SP offset for the STMG. These are 0 if no GPRs 48*480093f4SDimitry Andric // need to be saved or restored. 49*480093f4SDimitry Andric SystemZ::GPRRegs getSpillGPRRegs() const { return SpillGPRRegs; } 50*480093f4SDimitry Andric void setSpillGPRRegs(unsigned Low, unsigned High, unsigned Offs) { 51*480093f4SDimitry Andric SpillGPRRegs.LowGPR = Low; 52*480093f4SDimitry Andric SpillGPRRegs.HighGPR = High; 53*480093f4SDimitry Andric SpillGPRRegs.GPROffset = Offs; 54*480093f4SDimitry Andric } 550b57cec5SDimitry Andric 56*480093f4SDimitry Andric // Get and set the first and last call-saved GPR that should be restored by 57*480093f4SDimitry Andric // this function and the SP offset for the LMG. These are 0 if no GPRs 58*480093f4SDimitry Andric // need to be saved or restored. 59*480093f4SDimitry Andric SystemZ::GPRRegs getRestoreGPRRegs() const { return RestoreGPRRegs; } 60*480093f4SDimitry Andric void setRestoreGPRRegs(unsigned Low, unsigned High, unsigned Offs) { 61*480093f4SDimitry Andric RestoreGPRRegs.LowGPR = Low; 62*480093f4SDimitry Andric RestoreGPRRegs.HighGPR = High; 63*480093f4SDimitry Andric RestoreGPRRegs.GPROffset = Offs; 64*480093f4SDimitry Andric } 650b57cec5SDimitry Andric 660b57cec5SDimitry Andric // Get and set the number of fixed (as opposed to variable) arguments 670b57cec5SDimitry Andric // that are passed in GPRs to this function. 680b57cec5SDimitry Andric unsigned getVarArgsFirstGPR() const { return VarArgsFirstGPR; } 690b57cec5SDimitry Andric void setVarArgsFirstGPR(unsigned GPR) { VarArgsFirstGPR = GPR; } 700b57cec5SDimitry Andric 710b57cec5SDimitry Andric // Likewise FPRs. 720b57cec5SDimitry Andric unsigned getVarArgsFirstFPR() const { return VarArgsFirstFPR; } 730b57cec5SDimitry Andric void setVarArgsFirstFPR(unsigned FPR) { VarArgsFirstFPR = FPR; } 740b57cec5SDimitry Andric 750b57cec5SDimitry Andric // Get and set the frame index of the first stack vararg. 760b57cec5SDimitry Andric unsigned getVarArgsFrameIndex() const { return VarArgsFrameIndex; } 770b57cec5SDimitry Andric void setVarArgsFrameIndex(unsigned FI) { VarArgsFrameIndex = FI; } 780b57cec5SDimitry Andric 790b57cec5SDimitry Andric // Get and set the frame index of the register save area 800b57cec5SDimitry Andric // (i.e. the incoming stack pointer). 810b57cec5SDimitry Andric unsigned getRegSaveFrameIndex() const { return RegSaveFrameIndex; } 820b57cec5SDimitry Andric void setRegSaveFrameIndex(unsigned FI) { RegSaveFrameIndex = FI; } 830b57cec5SDimitry Andric 840b57cec5SDimitry Andric // Get and set the frame index of where the old frame pointer is stored. 850b57cec5SDimitry Andric int getFramePointerSaveIndex() const { return FramePointerSaveIndex; } 860b57cec5SDimitry Andric void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; } 870b57cec5SDimitry Andric 880b57cec5SDimitry Andric // Get and set whether the function directly manipulates the stack pointer, 890b57cec5SDimitry Andric // e.g. through STACKSAVE or STACKRESTORE. 900b57cec5SDimitry Andric bool getManipulatesSP() const { return ManipulatesSP; } 910b57cec5SDimitry Andric void setManipulatesSP(bool MSP) { ManipulatesSP = MSP; } 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric // Count number of local-dynamic TLS symbols used. 940b57cec5SDimitry Andric unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; } 950b57cec5SDimitry Andric void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; } 960b57cec5SDimitry Andric }; 970b57cec5SDimitry Andric 980b57cec5SDimitry Andric } // end namespace llvm 990b57cec5SDimitry Andric 1000b57cec5SDimitry Andric #endif 101