LLVM  14.0.0git
SystemZRegisterInfo.h
Go to the documentation of this file.
1 //===-- SystemZRegisterInfo.h - SystemZ register information ----*- 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_SYSTEMZREGISTERINFO_H
10 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZREGISTERINFO_H
11 
12 #include "SystemZ.h"
14 
15 #define GET_REGINFO_HEADER
16 #include "SystemZGenRegisterInfo.inc"
17 
18 namespace llvm {
19 
20 class LiveIntervals;
21 
22 namespace SystemZ {
23 // Return the subreg to use for referring to the even and odd registers
24 // in a GR128 pair. Is32Bit says whether we want a GR32 or GR64.
25 inline unsigned even128(bool Is32bit) {
26  return Is32bit ? subreg_hl32 : subreg_h64;
27 }
28 inline unsigned odd128(bool Is32bit) {
29  return Is32bit ? subreg_l32 : subreg_l64;
30 }
31 
32 // Reg should be a 32-bit GPR. Return true if it is a high register rather
33 // than a low register.
34 inline bool isHighReg(unsigned int Reg) {
35  if (SystemZ::GRH32BitRegClass.contains(Reg))
36  return true;
37  assert(SystemZ::GR32BitRegClass.contains(Reg) && "Invalid GRX32");
38  return false;
39 }
40 } // end namespace SystemZ
41 
42 /// A SystemZ-specific class detailing special use registers
43 /// particular for calling conventions.
44 /// It is abstract, all calling conventions must override and
45 /// define the pure virtual member function defined in this class.
47 public:
48  /// \returns the register that keeps the
49  /// return function address.
50  virtual int getReturnFunctionAddressRegister() = 0;
51 
52  /// \returns the register that keeps the
53  /// stack pointer address.
54  virtual int getStackPointerRegister() = 0;
55 
56  /// \returns the register that keeps the
57  /// frame pointer address.
58  virtual int getFramePointerRegister() = 0;
59 
60  /// \returns an array of all the callee saved registers.
61  virtual const MCPhysReg *
62  getCalleeSavedRegs(const MachineFunction *MF) const = 0;
63 
64  /// \returns the mask of all the call preserved registers.
65  virtual const uint32_t *getCallPreservedMask(const MachineFunction &MF,
66  CallingConv::ID CC) const = 0;
67 
68  /// Destroys the object. Bogus destructor allowing derived classes
69  /// to override it.
71 };
72 
73 /// XPLINK64 calling convention specific use registers
74 /// Particular to z/OS when in 64 bit mode
76 public:
77  int getReturnFunctionAddressRegister() override final {
78  return SystemZ::R7D;
79  };
80 
81  int getStackPointerRegister() override final { return SystemZ::R4D; };
82 
83  int getFramePointerRegister() override final { return SystemZ::R8D; };
84 
85  const MCPhysReg *
86  getCalleeSavedRegs(const MachineFunction *MF) const override final;
87 
89  CallingConv::ID CC) const override final;
90 
91  /// Destroys the object. Bogus destructor overriding base class destructor
93 };
94 
95 /// ELF calling convention specific use registers
96 /// Particular when on zLinux in 64 bit mode
98 public:
99  int getReturnFunctionAddressRegister() override final {
100  return SystemZ::R14D;
101  };
102 
103  int getStackPointerRegister() override final { return SystemZ::R15D; };
104 
105  int getFramePointerRegister() override final { return SystemZ::R11D; };
106 
107  const MCPhysReg *
108  getCalleeSavedRegs(const MachineFunction *MF) const override final;
109 
111  CallingConv::ID CC) const override final;
112 
113  /// Destroys the object. Bogus destructor overriding base class destructor
115 };
116 
118 public:
119  SystemZRegisterInfo(unsigned int RA);
120 
121  /// getPointerRegClass - Return the register class to use to hold pointers.
122  /// This is currently only used by LOAD_STACK_GUARD, which requires a non-%r0
123  /// register, hence ADDR64.
124  const TargetRegisterClass *
126  unsigned Kind=0) const override {
127  return &SystemZ::ADDR64BitRegClass;
128  }
129 
130  /// getCrossCopyRegClass - Returns a legal register class to copy a register
131  /// in the specified class to or from. Returns NULL if it is possible to copy
132  /// between a two registers of the specified class.
133  const TargetRegisterClass *
134  getCrossCopyRegClass(const TargetRegisterClass *RC) const override;
135 
138  const MachineFunction &MF, const VirtRegMap *VRM,
139  const LiveRegMatrix *Matrix) const override;
140 
141  // Override TargetRegisterInfo.h.
142  bool requiresRegisterScavenging(const MachineFunction &MF) const override {
143  return true;
144  }
145  bool requiresFrameIndexScavenging(const MachineFunction &MF) const override {
146  return true;
147  }
148  const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;
150  CallingConv::ID CC) const override;
151  BitVector getReservedRegs(const MachineFunction &MF) const override;
153  int SPAdj, unsigned FIOperandNum,
154  RegScavenger *RS) const override;
155 
156  /// SrcRC and DstRC will be morphed into NewRC if this returns true.
158  const TargetRegisterClass *SrcRC,
159  unsigned SubReg,
160  const TargetRegisterClass *DstRC,
161  unsigned DstSubReg,
162  const TargetRegisterClass *NewRC,
163  LiveIntervals &LIS) const override;
164 
165  Register getFrameRegister(const MachineFunction &MF) const override;
166 };
167 
168 } // end namespace llvm
169 
170 #endif
llvm::SystemZXPLINK64Registers::getFramePointerRegister
int getFramePointerRegister() override final
Definition: SystemZRegisterInfo.h:83
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:102
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::SystemZELFRegisters::getStackPointerRegister
int getStackPointerRegister() override final
Definition: SystemZRegisterInfo.h:103
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
llvm::SystemZCallingConventionRegisters::getReturnFunctionAddressRegister
virtual int getReturnFunctionAddressRegister()=0
llvm::SystemZXPLINK64Registers::getCallPreservedMask
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID CC) const override final
Definition: SystemZRegisterInfo.cpp:212
llvm::SystemZRegisterInfo::SystemZRegisterInfo
SystemZRegisterInfo(unsigned int RA)
Definition: SystemZRegisterInfo.cpp:233
contains
return AArch64::GPR64RegClass contains(Reg)
llvm::VirtRegMap
Definition: VirtRegMap.h:33
llvm::SystemZRegisterInfo::getFrameRegister
Register getFrameRegister(const MachineFunction &MF) const override
Definition: SystemZRegisterInfo.cpp:448
llvm::SystemZRegisterInfo::eliminateFrameIndex
void eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, unsigned FIOperandNum, RegScavenger *RS) const override
Definition: SystemZRegisterInfo.cpp:282
llvm::SystemZCallingConventionRegisters::~SystemZCallingConventionRegisters
virtual ~SystemZCallingConventionRegisters()
Destroys the object.
Definition: SystemZRegisterInfo.h:70
llvm::SystemZXPLINK64Registers::getStackPointerRegister
int getStackPointerRegister() override final
Definition: SystemZRegisterInfo.h:81
llvm::SystemZRegisterInfo::getReservedRegs
BitVector getReservedRegs(const MachineFunction &MF) const override
Definition: SystemZRegisterInfo.cpp:255
llvm::SystemZXPLINK64Registers
XPLINK64 calling convention specific use registers Particular to z/OS when in 64 bit mode.
Definition: SystemZRegisterInfo.h:75
llvm::SystemZRegisterInfo::shouldCoalesce
bool shouldCoalesce(MachineInstr *MI, const TargetRegisterClass *SrcRC, unsigned SubReg, const TargetRegisterClass *DstRC, unsigned DstSubReg, const TargetRegisterClass *NewRC, LiveIntervals &LIS) const override
SrcRC and DstRC will be morphed into NewRC if this returns true.
Definition: SystemZRegisterInfo.cpp:376
llvm::SystemZXPLINK64Registers::getReturnFunctionAddressRegister
int getReturnFunctionAddressRegister() override final
Definition: SystemZRegisterInfo.h:77
llvm::SystemZELFRegisters::getCallPreservedMask
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID CC) const override final
Definition: SystemZRegisterInfo.cpp:218
llvm::TargetRegisterClass
Definition: TargetRegisterInfo.h:46
llvm::SystemZCallingConventionRegisters::getCalleeSavedRegs
virtual const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const =0
llvm::SystemZXPLINK64Registers::getCalleeSavedRegs
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override final
Definition: SystemZRegisterInfo.cpp:192
llvm::SystemZ::isHighReg
bool isHighReg(unsigned int Reg)
Definition: SystemZRegisterInfo.h:34
llvm::BitVector
Definition: BitVector.h:74
SystemZ.h
llvm::SystemZRegisterInfo::getRegAllocationHints
bool getRegAllocationHints(Register VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const override
Definition: SystemZRegisterInfo.cpp:74
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::SystemZ::odd128
unsigned odd128(bool Is32bit)
Definition: SystemZRegisterInfo.h:28
llvm::SystemZRegisterInfo::requiresFrameIndexScavenging
bool requiresFrameIndexScavenging(const MachineFunction &MF) const override
Definition: SystemZRegisterInfo.h:145
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:64
llvm::SystemZRegisterInfo::getCrossCopyRegClass
const TargetRegisterClass * getCrossCopyRegClass(const TargetRegisterClass *RC) const override
getCrossCopyRegClass - Returns a legal register class to copy a register in the specified class to or...
Definition: SystemZRegisterInfo.cpp:458
llvm::SystemZELFRegisters::~SystemZELFRegisters
~SystemZELFRegisters()
Destroys the object. Bogus destructor overriding base class destructor.
Definition: SystemZRegisterInfo.h:114
llvm::RegScavenger
Definition: RegisterScavenging.h:34
llvm::SystemZRegisterInfo::getCallPreservedMask
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID CC) const override
Definition: SystemZRegisterInfo.cpp:246
llvm::SystemZCallingConventionRegisters::getStackPointerRegister
virtual int getStackPointerRegister()=0
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
RA
SI optimize exec mask operations pre RA
Definition: SIOptimizeExecMaskingPreRA.cpp:71
llvm::SystemZCallingConventionRegisters::getCallPreservedMask
virtual const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID CC) const =0
llvm::MachineFunction
Definition: MachineFunction.h:230
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::SystemZELFRegisters::getFramePointerRegister
int getFramePointerRegister() override final
Definition: SystemZRegisterInfo.h:105
uint32_t
llvm::SystemZRegisterInfo::getCalleeSavedRegs
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Definition: SystemZRegisterInfo.cpp:237
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::SystemZCallingConventionRegisters
A SystemZ-specific class detailing special use registers particular for calling conventions.
Definition: SystemZRegisterInfo.h:46
llvm::SystemZ::even128
unsigned even128(bool Is32bit)
Definition: SystemZRegisterInfo.h:25
uint16_t
SystemZGenRegisterInfo
llvm::LiveIntervals
Definition: LiveIntervals.h:54
llvm::SystemZXPLINK64Registers::~SystemZXPLINK64Registers
~SystemZXPLINK64Registers()
Destroys the object. Bogus destructor overriding base class destructor.
Definition: SystemZRegisterInfo.h:92
llvm::SystemZRegisterInfo
Definition: SystemZRegisterInfo.h:117
llvm::SystemZRegisterInfo::requiresRegisterScavenging
bool requiresRegisterScavenging(const MachineFunction &MF) const override
Definition: SystemZRegisterInfo.h:142
llvm::SystemZCallingConventionRegisters::getFramePointerRegister
virtual int getFramePointerRegister()=0
llvm::SmallVectorImpl< MCPhysReg >
llvm::SystemZELFRegisters
ELF calling convention specific use registers Particular when on zLinux in 64 bit mode.
Definition: SystemZRegisterInfo.h:97
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::SystemZELFRegisters::getReturnFunctionAddressRegister
int getReturnFunctionAddressRegister() override final
Definition: SystemZRegisterInfo.h:99
llvm::SystemZRegisterInfo::getPointerRegClass
const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const override
getPointerRegClass - Return the register class to use to hold pointers.
Definition: SystemZRegisterInfo.h:125
llvm::SystemZELFRegisters::getCalleeSavedRegs
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override final
Definition: SystemZRegisterInfo.cpp:197
TargetRegisterInfo.h
SubReg
unsigned SubReg
Definition: AArch64AdvSIMDScalarPass.cpp:104
llvm::LiveRegMatrix
Definition: LiveRegMatrix.h:40