X86RegisterInfo.h revision 239462
1234353Sdim//===-- X86RegisterInfo.h - X86 Register Information Impl -------*- C++ -*-===//
2193323Sed//
3193323Sed//                     The LLVM Compiler Infrastructure
4193323Sed//
5193323Sed// This file is distributed under the University of Illinois Open Source
6193323Sed// License. See LICENSE.TXT for details.
7193323Sed//
8193323Sed//===----------------------------------------------------------------------===//
9193323Sed//
10193323Sed// This file contains the X86 implementation of the TargetRegisterInfo class.
11193323Sed//
12193323Sed//===----------------------------------------------------------------------===//
13193323Sed
14193323Sed#ifndef X86REGISTERINFO_H
15193323Sed#define X86REGISTERINFO_H
16193323Sed
17193323Sed#include "llvm/Target/TargetRegisterInfo.h"
18193323Sed
19224145Sdim#define GET_REGINFO_HEADER
20224145Sdim#include "X86GenRegisterInfo.inc"
21224145Sdim
22193323Sednamespace llvm {
23193323Sed  class Type;
24193323Sed  class TargetInstrInfo;
25193323Sed  class X86TargetMachine;
26193323Sed
27193323Sedclass X86RegisterInfo : public X86GenRegisterInfo {
28193323Sedpublic:
29193323Sed  X86TargetMachine &TM;
30193323Sed  const TargetInstrInfo &TII;
31193323Sed
32193323Sedprivate:
33193323Sed  /// Is64Bit - Is the target 64-bits.
34193323Sed  ///
35193323Sed  bool Is64Bit;
36193323Sed
37193323Sed  /// IsWin64 - Is the target on of win64 flavours
38193323Sed  ///
39193323Sed  bool IsWin64;
40193323Sed
41193323Sed  /// SlotSize - Stack slot size in bytes.
42193323Sed  ///
43193323Sed  unsigned SlotSize;
44193323Sed
45193323Sed  /// StackPtr - X86 physical register used as stack ptr.
46193323Sed  ///
47193323Sed  unsigned StackPtr;
48193323Sed
49193323Sed  /// FramePtr - X86 physical register used as frame ptr.
50193323Sed  ///
51193323Sed  unsigned FramePtr;
52193323Sed
53239462Sdim  /// BasePtr - X86 physical register used as a base ptr in complex stack
54239462Sdim  /// frames. I.e., when we need a 3rd base, not just SP and FP, due to
55239462Sdim  /// variable size stack objects.
56239462Sdim  unsigned BasePtr;
57239462Sdim
58193323Sedpublic:
59193323Sed  X86RegisterInfo(X86TargetMachine &tm, const TargetInstrInfo &tii);
60193323Sed
61193323Sed  /// getX86RegNum - Returns the native X86 register number for the given LLVM
62193323Sed  /// register identifier.
63193323Sed  static unsigned getX86RegNum(unsigned RegNo);
64193323Sed
65223017Sdim  // FIXME: This should be tablegen'd like getDwarfRegNum is
66223017Sdim  int getSEHRegNum(unsigned i) const;
67223017Sdim
68224145Sdim  /// getCompactUnwindRegNum - This function maps the register to the number for
69224145Sdim  /// compact unwind encoding. Return -1 if the register isn't valid.
70224145Sdim  int getCompactUnwindRegNum(unsigned RegNum, bool isEH) const;
71224145Sdim
72193323Sed  /// Code Generation virtual methods...
73239462Sdim  ///
74239462Sdim  virtual bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const;
75193323Sed
76198090Srdivacky  /// getMatchingSuperRegClass - Return a subclass of the specified register
77198090Srdivacky  /// class A so that each register in it has a sub-register of the
78198090Srdivacky  /// specified sub-register index which is in the specified register class B.
79198090Srdivacky  virtual const TargetRegisterClass *
80198090Srdivacky  getMatchingSuperRegClass(const TargetRegisterClass *A,
81198090Srdivacky                           const TargetRegisterClass *B, unsigned Idx) const;
82198090Srdivacky
83226633Sdim  virtual const TargetRegisterClass *
84226633Sdim  getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const;
85226633Sdim
86221345Sdim  const TargetRegisterClass*
87221345Sdim  getLargestLegalSuperClass(const TargetRegisterClass *RC) const;
88221345Sdim
89193323Sed  /// getPointerRegClass - Returns a TargetRegisterClass used for pointer
90193323Sed  /// values.
91239462Sdim  const TargetRegisterClass *
92239462Sdim  getPointerRegClass(const MachineFunction &MF, unsigned Kind = 0) const;
93193323Sed
94193323Sed  /// getCrossCopyRegClass - Returns a legal register class to copy a register
95193323Sed  /// in the specified class to or from. Returns NULL if it is possible to copy
96193323Sed  /// between a two registers of the specified class.
97193323Sed  const TargetRegisterClass *
98193323Sed  getCrossCopyRegClass(const TargetRegisterClass *RC) const;
99193323Sed
100221345Sdim  unsigned getRegPressureLimit(const TargetRegisterClass *RC,
101221345Sdim                               MachineFunction &MF) const;
102221345Sdim
103193323Sed  /// getCalleeSavedRegs - Return a null-terminated list of all of the
104193323Sed  /// callee-save registers on this target.
105234353Sdim  const uint16_t *getCalleeSavedRegs(const MachineFunction* MF = 0) const;
106234353Sdim  const uint32_t *getCallPreservedMask(CallingConv::ID) const;
107193323Sed
108193323Sed  /// getReservedRegs - Returns a bitset indexed by physical register number
109193323Sed  /// indicating if a register is a special register that has particular uses and
110193323Sed  /// should be considered unavailable at all times, e.g. SP, RA. This is used by
111193323Sed  /// register scavenger to determine what registers are free.
112193323Sed  BitVector getReservedRegs(const MachineFunction &MF) const;
113193323Sed
114239462Sdim  bool hasBasePointer(const MachineFunction &MF) const;
115239462Sdim
116202878Srdivacky  bool canRealignStack(const MachineFunction &MF) const;
117202878Srdivacky
118193323Sed  bool needsStackRealignment(const MachineFunction &MF) const;
119193323Sed
120212904Sdim  bool hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg,
121198090Srdivacky                            int &FrameIdx) const;
122198090Srdivacky
123193323Sed  void eliminateCallFramePseudoInstr(MachineFunction &MF,
124193323Sed                                     MachineBasicBlock &MBB,
125193323Sed                                     MachineBasicBlock::iterator MI) const;
126193323Sed
127212904Sdim  void eliminateFrameIndex(MachineBasicBlock::iterator MI,
128212904Sdim                           int SPAdj, RegScavenger *RS = NULL) const;
129193323Sed
130193323Sed  // Debug information queries.
131199481Srdivacky  unsigned getFrameRegister(const MachineFunction &MF) const;
132218893Sdim  unsigned getStackRegister() const { return StackPtr; }
133239462Sdim  unsigned getBaseRegister() const { return BasePtr; }
134218893Sdim  // FIXME: Move to FrameInfok
135218893Sdim  unsigned getSlotSize() const { return SlotSize; }
136193323Sed
137193323Sed  // Exception handling queries.
138193323Sed  unsigned getEHExceptionRegister() const;
139193323Sed  unsigned getEHHandlerRegister() const;
140193323Sed};
141193323Sed
142193323Sed// getX86SubSuperRegister - X86 utility function. It returns the sub or super
143193323Sed// register of a specific X86 register.
144198090Srdivacky// e.g. getX86SubSuperRegister(X86::EAX, EVT::i16) return X86:AX
145198090Srdivackyunsigned getX86SubSuperRegister(unsigned, EVT, bool High=false);
146193323Sed
147193323Sed} // End llvm namespace
148193323Sed
149193323Sed#endif
150