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
31193323Sedprivate:
32193323Sed  /// Is64Bit - Is the target 64-bits.
33193323Sed  ///
34193323Sed  bool Is64Bit;
35193323Sed
36193323Sed  /// IsWin64 - Is the target on of win64 flavours
37193323Sed  ///
38193323Sed  bool IsWin64;
39193323Sed
40193323Sed  /// SlotSize - Stack slot size in bytes.
41193323Sed  ///
42193323Sed  unsigned SlotSize;
43193323Sed
44193323Sed  /// StackPtr - X86 physical register used as stack ptr.
45193323Sed  ///
46193323Sed  unsigned StackPtr;
47193323Sed
48193323Sed  /// FramePtr - X86 physical register used as frame ptr.
49193323Sed  ///
50193323Sed  unsigned FramePtr;
51193323Sed
52239462Sdim  /// BasePtr - X86 physical register used as a base ptr in complex stack
53239462Sdim  /// frames. I.e., when we need a 3rd base, not just SP and FP, due to
54239462Sdim  /// variable size stack objects.
55239462Sdim  unsigned BasePtr;
56239462Sdim
57193323Sedpublic:
58263508Sdim  X86RegisterInfo(X86TargetMachine &tm);
59193323Sed
60223017Sdim  // FIXME: This should be tablegen'd like getDwarfRegNum is
61223017Sdim  int getSEHRegNum(unsigned i) const;
62223017Sdim
63224145Sdim  /// getCompactUnwindRegNum - This function maps the register to the number for
64224145Sdim  /// compact unwind encoding. Return -1 if the register isn't valid.
65224145Sdim  int getCompactUnwindRegNum(unsigned RegNum, bool isEH) const;
66224145Sdim
67193323Sed  /// Code Generation virtual methods...
68239462Sdim  ///
69239462Sdim  virtual bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const;
70193323Sed
71198090Srdivacky  /// getMatchingSuperRegClass - Return a subclass of the specified register
72198090Srdivacky  /// class A so that each register in it has a sub-register of the
73198090Srdivacky  /// specified sub-register index which is in the specified register class B.
74198090Srdivacky  virtual const TargetRegisterClass *
75198090Srdivacky  getMatchingSuperRegClass(const TargetRegisterClass *A,
76198090Srdivacky                           const TargetRegisterClass *B, unsigned Idx) const;
77198090Srdivacky
78226633Sdim  virtual const TargetRegisterClass *
79226633Sdim  getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const;
80226633Sdim
81221345Sdim  const TargetRegisterClass*
82221345Sdim  getLargestLegalSuperClass(const TargetRegisterClass *RC) const;
83221345Sdim
84193323Sed  /// getPointerRegClass - Returns a TargetRegisterClass used for pointer
85193323Sed  /// values.
86239462Sdim  const TargetRegisterClass *
87239462Sdim  getPointerRegClass(const MachineFunction &MF, unsigned Kind = 0) const;
88193323Sed
89193323Sed  /// getCrossCopyRegClass - Returns a legal register class to copy a register
90193323Sed  /// in the specified class to or from. Returns NULL if it is possible to copy
91193323Sed  /// between a two registers of the specified class.
92193323Sed  const TargetRegisterClass *
93193323Sed  getCrossCopyRegClass(const TargetRegisterClass *RC) const;
94193323Sed
95221345Sdim  unsigned getRegPressureLimit(const TargetRegisterClass *RC,
96221345Sdim                               MachineFunction &MF) const;
97221345Sdim
98193323Sed  /// getCalleeSavedRegs - Return a null-terminated list of all of the
99193323Sed  /// callee-save registers on this target.
100234353Sdim  const uint16_t *getCalleeSavedRegs(const MachineFunction* MF = 0) const;
101234353Sdim  const uint32_t *getCallPreservedMask(CallingConv::ID) const;
102243830Sdim  const uint32_t *getNoPreservedMask() const;
103193323Sed
104193323Sed  /// getReservedRegs - Returns a bitset indexed by physical register number
105193323Sed  /// indicating if a register is a special register that has particular uses and
106193323Sed  /// should be considered unavailable at all times, e.g. SP, RA. This is used by
107193323Sed  /// register scavenger to determine what registers are free.
108193323Sed  BitVector getReservedRegs(const MachineFunction &MF) const;
109193323Sed
110239462Sdim  bool hasBasePointer(const MachineFunction &MF) const;
111239462Sdim
112202878Srdivacky  bool canRealignStack(const MachineFunction &MF) const;
113202878Srdivacky
114193323Sed  bool needsStackRealignment(const MachineFunction &MF) const;
115193323Sed
116212904Sdim  bool hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg,
117198090Srdivacky                            int &FrameIdx) const;
118198090Srdivacky
119212904Sdim  void eliminateFrameIndex(MachineBasicBlock::iterator MI,
120249423Sdim                           int SPAdj, unsigned FIOperandNum,
121249423Sdim                           RegScavenger *RS = NULL) const;
122193323Sed
123193323Sed  // Debug information queries.
124199481Srdivacky  unsigned getFrameRegister(const MachineFunction &MF) const;
125218893Sdim  unsigned getStackRegister() const { return StackPtr; }
126239462Sdim  unsigned getBaseRegister() const { return BasePtr; }
127218893Sdim  // FIXME: Move to FrameInfok
128218893Sdim  unsigned getSlotSize() const { return SlotSize; }
129193323Sed};
130193323Sed
131193323Sed// getX86SubSuperRegister - X86 utility function. It returns the sub or super
132193323Sed// register of a specific X86 register.
133243830Sdim// e.g. getX86SubSuperRegister(X86::EAX, MVT::i16) return X86:AX
134243830Sdimunsigned getX86SubSuperRegister(unsigned, MVT::SimpleValueType, bool High=false);
135193323Sed
136263508Sdim//get512BitRegister - X86 utility - returns 512-bit super register
137263508Sdimunsigned get512BitSuperRegister(unsigned Reg);
138263508Sdim
139193323Sed} // End llvm namespace
140193323Sed
141193323Sed#endif
142