Path: blob/main/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZRegisterInfo.h
96353 views
//===-- SystemZRegisterInfo.h - SystemZ register information ----*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZREGISTERINFO_H9#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZREGISTERINFO_H1011#include "SystemZ.h"12#include "llvm/CodeGen/TargetFrameLowering.h"13#include "llvm/CodeGen/TargetRegisterInfo.h"1415#define GET_REGINFO_HEADER16#include "SystemZGenRegisterInfo.inc"1718namespace llvm {1920class LiveIntervals;2122namespace SystemZ {23// Return the subreg to use for referring to the even and odd registers24// in a GR128 pair. Is32Bit says whether we want a GR32 or GR64.25inline unsigned even128(bool Is32bit) {26return Is32bit ? subreg_l32 : subreg_h64;27}28inline unsigned odd128(bool Is32bit) {29return Is32bit ? subreg_ll32 : subreg_l64;30}3132// Reg should be a 32-bit GPR. Return true if it is a high register rather33// than a low register.34inline bool isHighReg(unsigned int Reg) {35if (SystemZ::GRH32BitRegClass.contains(Reg))36return true;37assert(SystemZ::GR32BitRegClass.contains(Reg) && "Invalid GRX32");38return false;39}40} // end namespace SystemZ4142/// A SystemZ-specific class detailing special use registers43/// particular for calling conventions.44/// It is abstract, all calling conventions must override and45/// define the pure virtual member function defined in this class.46class SystemZCallingConventionRegisters {4748public:49/// \returns the register that keeps the return function address.50virtual int getReturnFunctionAddressRegister() = 0;5152/// \returns the register that keeps the53/// stack pointer address.54virtual int getStackPointerRegister() = 0;5556/// \returns the register that keeps the57/// frame pointer address.58virtual int getFramePointerRegister() = 0;5960/// \returns an array of all the callee saved registers.61virtual const MCPhysReg *62getCalleeSavedRegs(const MachineFunction *MF) const = 0;6364/// \returns the mask of all the call preserved registers.65virtual const uint32_t *getCallPreservedMask(const MachineFunction &MF,66CallingConv::ID CC) const = 0;6768/// \returns the offset to the locals area.69virtual int getCallFrameSize() = 0;7071/// \returns the stack pointer bias.72virtual int getStackPointerBias() = 0;7374/// Destroys the object. Bogus destructor allowing derived classes75/// to override it.76virtual ~SystemZCallingConventionRegisters() = default;77};7879/// XPLINK64 calling convention specific use registers80/// Particular to z/OS when in 64 bit mode81class SystemZXPLINK64Registers : public SystemZCallingConventionRegisters {82public:83int getReturnFunctionAddressRegister() final { return SystemZ::R7D; };8485int getStackPointerRegister() final { return SystemZ::R4D; };8687int getFramePointerRegister() final { return SystemZ::R8D; };8889int getAddressOfCalleeRegister() { return SystemZ::R6D; };9091int getADARegister() { return SystemZ::R5D; }9293const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const final;9495const uint32_t *getCallPreservedMask(const MachineFunction &MF,96CallingConv::ID CC) const final;9798int getCallFrameSize() final { return 128; }99100int getStackPointerBias() final { return 2048; }101102/// Destroys the object. Bogus destructor overriding base class destructor103~SystemZXPLINK64Registers() = default;104};105106/// ELF calling convention specific use registers107/// Particular when on zLinux in 64 bit mode108class SystemZELFRegisters : public SystemZCallingConventionRegisters {109public:110int getReturnFunctionAddressRegister() final { return SystemZ::R14D; };111112int getStackPointerRegister() final { return SystemZ::R15D; };113114int getFramePointerRegister() final { return SystemZ::R11D; };115116const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const final;117118const uint32_t *getCallPreservedMask(const MachineFunction &MF,119CallingConv::ID CC) const final;120121int getCallFrameSize() final { return SystemZMC::ELFCallFrameSize; }122123int getStackPointerBias() final { return 0; }124125/// Destroys the object. Bogus destructor overriding base class destructor126~SystemZELFRegisters() = default;127};128129struct SystemZRegisterInfo : public SystemZGenRegisterInfo {130public:131SystemZRegisterInfo(unsigned int RA);132133/// getPointerRegClass - Return the register class to use to hold pointers.134/// This is currently only used by LOAD_STACK_GUARD, which requires a non-%r0135/// register, hence ADDR64.136const TargetRegisterClass *137getPointerRegClass(const MachineFunction &MF,138unsigned Kind=0) const override {139return &SystemZ::ADDR64BitRegClass;140}141142/// getCrossCopyRegClass - Returns a legal register class to copy a register143/// in the specified class to or from. Returns NULL if it is possible to copy144/// between a two registers of the specified class.145const TargetRegisterClass *146getCrossCopyRegClass(const TargetRegisterClass *RC) const override;147148bool getRegAllocationHints(Register VirtReg, ArrayRef<MCPhysReg> Order,149SmallVectorImpl<MCPhysReg> &Hints,150const MachineFunction &MF, const VirtRegMap *VRM,151const LiveRegMatrix *Matrix) const override;152153// Override TargetRegisterInfo.h.154bool requiresRegisterScavenging(const MachineFunction &MF) const override {155return true;156}157bool requiresFrameIndexScavenging(const MachineFunction &MF) const override {158return true;159}160const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;161const uint32_t *getCallPreservedMask(const MachineFunction &MF,162CallingConv::ID CC) const override;163BitVector getReservedRegs(const MachineFunction &MF) const override;164bool eliminateFrameIndex(MachineBasicBlock::iterator MI,165int SPAdj, unsigned FIOperandNum,166RegScavenger *RS) const override;167168/// SrcRC and DstRC will be morphed into NewRC if this returns true.169bool shouldCoalesce(MachineInstr *MI,170const TargetRegisterClass *SrcRC,171unsigned SubReg,172const TargetRegisterClass *DstRC,173unsigned DstSubReg,174const TargetRegisterClass *NewRC,175LiveIntervals &LIS) const override;176177Register getFrameRegister(const MachineFunction &MF) const override;178};179180} // end namespace llvm181182#endif183184185