1//===-- PPCRegisterInfo.h - PowerPC Register Information Impl ---*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the PowerPC implementation of the TargetRegisterInfo
11// class.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef POWERPC32_REGISTERINFO_H
16#define POWERPC32_REGISTERINFO_H
17
18#include "PPC.h"
19#include <map>
20
21#define GET_REGINFO_HEADER
22#include "PPCGenRegisterInfo.inc"
23
24namespace llvm {
25class PPCSubtarget;
26class TargetInstrInfo;
27class Type;
28
29class PPCRegisterInfo : public PPCGenRegisterInfo {
30  std::map<unsigned, unsigned> ImmToIdxMap;
31  const PPCSubtarget &Subtarget;
32  const TargetInstrInfo &TII;
33  mutable int CRSpillFrameIdx;
34public:
35  PPCRegisterInfo(const PPCSubtarget &SubTarget, const TargetInstrInfo &tii);
36
37  /// getPointerRegClass - Return the register class to use to hold pointers.
38  /// This is used for addressing modes.
39  virtual const TargetRegisterClass *
40  getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const;
41
42  unsigned getRegPressureLimit(const TargetRegisterClass *RC,
43                               MachineFunction &MF) const;
44
45  /// Code Generation virtual methods...
46  const uint16_t *getCalleeSavedRegs(const MachineFunction* MF = 0) const;
47  const uint32_t *getCallPreservedMask(CallingConv::ID CC) const;
48
49  BitVector getReservedRegs(const MachineFunction &MF) const;
50
51  virtual bool avoidWriteAfterWrite(const TargetRegisterClass *RC) const;
52
53  /// requiresRegisterScavenging - We require a register scavenger.
54  /// FIXME (64-bit): Should be inlined.
55  bool requiresRegisterScavenging(const MachineFunction &MF) const;
56
57  bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const;
58
59  void eliminateCallFramePseudoInstr(MachineFunction &MF,
60                                     MachineBasicBlock &MBB,
61                                     MachineBasicBlock::iterator I) const;
62
63  void lowerDynamicAlloc(MachineBasicBlock::iterator II,
64                         int SPAdj, RegScavenger *RS) const;
65  void lowerCRSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex,
66                       int SPAdj, RegScavenger *RS) const;
67  void lowerCRRestore(MachineBasicBlock::iterator II, unsigned FrameIndex,
68                       int SPAdj, RegScavenger *RS) const;
69  bool hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg,
70			    int &FrameIdx) const;
71  void eliminateFrameIndex(MachineBasicBlock::iterator II,
72                           int SPAdj, RegScavenger *RS = NULL) const;
73
74  // Debug information queries.
75  unsigned getFrameRegister(const MachineFunction &MF) const;
76
77  // Exception handling queries.
78  unsigned getEHExceptionRegister() const;
79  unsigned getEHHandlerRegister() const;
80};
81
82} // end namespace llvm
83
84#endif
85