SystemZRegisterInfo.h revision 344779
1223534Shselasky//===-- SystemZRegisterInfo.h - SystemZ register information ----*- C++ -*-===//
2223534Shselasky//
3223534Shselasky//                     The LLVM Compiler Infrastructure
4223534Shselasky//
5223534Shselasky// This file is distributed under the University of Illinois Open Source
6223534Shselasky// License. See LICENSE.TXT for details.
7223534Shselasky//
8223534Shselasky//===----------------------------------------------------------------------===//
9223534Shselasky
10223534Shselasky#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZREGISTERINFO_H
11223534Shselasky#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZREGISTERINFO_H
12223534Shselasky
13223534Shselasky#include "SystemZ.h"
14223534Shselasky#include "llvm/CodeGen/TargetRegisterInfo.h"
15223534Shselasky
16223534Shselasky#define GET_REGINFO_HEADER
17223534Shselasky#include "SystemZGenRegisterInfo.inc"
18223534Shselasky
19223534Shselaskynamespace llvm {
20223534Shselasky
21223534Shselaskyclass LiveIntervals;
22223534Shselasky
23223534Shselaskynamespace SystemZ {
24223534Shselasky// Return the subreg to use for referring to the even and odd registers
25223534Shselasky// in a GR128 pair.  Is32Bit says whether we want a GR32 or GR64.
26223534Shselaskyinline unsigned even128(bool Is32bit) {
27223534Shselasky  return Is32bit ? subreg_hl32 : subreg_h64;
28223534Shselasky}
29223534Shselaskyinline unsigned odd128(bool Is32bit) {
30223534Shselasky  return Is32bit ? subreg_l32 : subreg_l64;
31223534Shselasky}
32223534Shselasky} // end namespace SystemZ
33223534Shselasky
34struct SystemZRegisterInfo : public SystemZGenRegisterInfo {
35public:
36  SystemZRegisterInfo();
37
38  /// getPointerRegClass - Return the register class to use to hold pointers.
39  /// This is currently only used by LOAD_STACK_GUARD, which requires a non-%r0
40  /// register, hence ADDR64.
41  const TargetRegisterClass *
42  getPointerRegClass(const MachineFunction &MF,
43                     unsigned Kind=0) const override {
44    return &SystemZ::ADDR64BitRegClass;
45  }
46
47  /// getCrossCopyRegClass - Returns a legal register class to copy a register
48  /// in the specified class to or from. Returns NULL if it is possible to copy
49  /// between a two registers of the specified class.
50  const TargetRegisterClass *
51  getCrossCopyRegClass(const TargetRegisterClass *RC) const override;
52
53  bool getRegAllocationHints(unsigned VirtReg,
54                             ArrayRef<MCPhysReg> Order,
55                             SmallVectorImpl<MCPhysReg> &Hints,
56                             const MachineFunction &MF,
57                             const VirtRegMap *VRM,
58                             const LiveRegMatrix *Matrix) const override;
59
60  // Override TargetRegisterInfo.h.
61  bool requiresRegisterScavenging(const MachineFunction &MF) const override {
62    return true;
63  }
64  bool requiresFrameIndexScavenging(const MachineFunction &MF) const override {
65    return true;
66  }
67  bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const override {
68    return true;
69  }
70  const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;
71  const uint32_t *getCallPreservedMask(const MachineFunction &MF,
72                                       CallingConv::ID CC) const override;
73  BitVector getReservedRegs(const MachineFunction &MF) const override;
74  void eliminateFrameIndex(MachineBasicBlock::iterator MI,
75                           int SPAdj, unsigned FIOperandNum,
76                           RegScavenger *RS) const override;
77
78  /// SrcRC and DstRC will be morphed into NewRC if this returns true.
79 bool shouldCoalesce(MachineInstr *MI,
80                      const TargetRegisterClass *SrcRC,
81                      unsigned SubReg,
82                      const TargetRegisterClass *DstRC,
83                      unsigned DstSubReg,
84                      const TargetRegisterClass *NewRC,
85                      LiveIntervals &LIS) const override;
86
87  unsigned getFrameRegister(const MachineFunction &MF) const override;
88};
89
90} // end namespace llvm
91
92#endif
93