X86RegisterInfo.h revision 249423
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
61223017Sdim  // FIXME: This should be tablegen'd like getDwarfRegNum is
62223017Sdim  int getSEHRegNum(unsigned i) const;
63223017Sdim
64224145Sdim  /// getCompactUnwindRegNum - This function maps the register to the number for
65224145Sdim  /// compact unwind encoding. Return -1 if the register isn't valid.
66224145Sdim  int getCompactUnwindRegNum(unsigned RegNum, bool isEH) const;
67224145Sdim
68193323Sed  /// Code Generation virtual methods...
69239462Sdim  ///
70239462Sdim  virtual bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const;
71193323Sed
72198090Srdivacky  /// getMatchingSuperRegClass - Return a subclass of the specified register
73198090Srdivacky  /// class A so that each register in it has a sub-register of the
74198090Srdivacky  /// specified sub-register index which is in the specified register class B.
75198090Srdivacky  virtual const TargetRegisterClass *
76198090Srdivacky  getMatchingSuperRegClass(const TargetRegisterClass *A,
77198090Srdivacky                           const TargetRegisterClass *B, unsigned Idx) const;
78198090Srdivacky
79226633Sdim  virtual const TargetRegisterClass *
80226633Sdim  getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const;
81226633Sdim
82221345Sdim  const TargetRegisterClass*
83221345Sdim  getLargestLegalSuperClass(const TargetRegisterClass *RC) const;
84221345Sdim
85193323Sed  /// getPointerRegClass - Returns a TargetRegisterClass used for pointer
86193323Sed  /// values.
87239462Sdim  const TargetRegisterClass *
88239462Sdim  getPointerRegClass(const MachineFunction &MF, unsigned Kind = 0) const;
89193323Sed
90193323Sed  /// getCrossCopyRegClass - Returns a legal register class to copy a register
91193323Sed  /// in the specified class to or from. Returns NULL if it is possible to copy
92193323Sed  /// between a two registers of the specified class.
93193323Sed  const TargetRegisterClass *
94193323Sed  getCrossCopyRegClass(const TargetRegisterClass *RC) const;
95193323Sed
96221345Sdim  unsigned getRegPressureLimit(const TargetRegisterClass *RC,
97221345Sdim                               MachineFunction &MF) const;
98221345Sdim
99193323Sed  /// getCalleeSavedRegs - Return a null-terminated list of all of the
100193323Sed  /// callee-save registers on this target.
101234353Sdim  const uint16_t *getCalleeSavedRegs(const MachineFunction* MF = 0) const;
102234353Sdim  const uint32_t *getCallPreservedMask(CallingConv::ID) const;
103243830Sdim  const uint32_t *getNoPreservedMask() const;
104193323Sed
105193323Sed  /// getReservedRegs - Returns a bitset indexed by physical register number
106193323Sed  /// indicating if a register is a special register that has particular uses and
107193323Sed  /// should be considered unavailable at all times, e.g. SP, RA. This is used by
108193323Sed  /// register scavenger to determine what registers are free.
109193323Sed  BitVector getReservedRegs(const MachineFunction &MF) const;
110193323Sed
111239462Sdim  bool hasBasePointer(const MachineFunction &MF) const;
112239462Sdim
113202878Srdivacky  bool canRealignStack(const MachineFunction &MF) const;
114202878Srdivacky
115193323Sed  bool needsStackRealignment(const MachineFunction &MF) const;
116193323Sed
117212904Sdim  bool hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg,
118198090Srdivacky                            int &FrameIdx) const;
119198090Srdivacky
120212904Sdim  void eliminateFrameIndex(MachineBasicBlock::iterator MI,
121249423Sdim                           int SPAdj, unsigned FIOperandNum,
122249423Sdim                           RegScavenger *RS = NULL) const;
123193323Sed
124193323Sed  // Debug information queries.
125199481Srdivacky  unsigned getFrameRegister(const MachineFunction &MF) const;
126218893Sdim  unsigned getStackRegister() const { return StackPtr; }
127239462Sdim  unsigned getBaseRegister() const { return BasePtr; }
128218893Sdim  // FIXME: Move to FrameInfok
129218893Sdim  unsigned getSlotSize() const { return SlotSize; }
130193323Sed
131193323Sed  // Exception handling queries.
132193323Sed  unsigned getEHExceptionRegister() const;
133193323Sed  unsigned getEHHandlerRegister() const;
134193323Sed};
135193323Sed
136193323Sed// getX86SubSuperRegister - X86 utility function. It returns the sub or super
137193323Sed// register of a specific X86 register.
138243830Sdim// e.g. getX86SubSuperRegister(X86::EAX, MVT::i16) return X86:AX
139243830Sdimunsigned getX86SubSuperRegister(unsigned, MVT::SimpleValueType, bool High=false);
140193323Sed
141193323Sed} // End llvm namespace
142193323Sed
143193323Sed#endif
144