X86RegisterInfo.h revision 2926869b4a083fc951484de03a9867eabf81e880
1//===- X86RegisterInfo.h - X86 Register Information Impl --------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the X86 implementation of the MRegisterInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef X86REGISTERINFO_H
15#define X86REGISTERINFO_H
16
17#include "llvm/Target/MRegisterInfo.h"
18#include "X86GenRegisterInfo.h.inc"
19
20namespace llvm {
21  class Type;
22  class TargetInstrInfo;
23
24struct X86RegisterInfo : public X86GenRegisterInfo {
25  const TargetInstrInfo &TII;
26  X86RegisterInfo(const TargetInstrInfo &tii);
27
28  /// Code Generation virtual methods...
29  void storeRegToStackSlot(MachineBasicBlock &MBB,
30                           MachineBasicBlock::iterator MI,
31                           unsigned SrcReg, int FrameIndex,
32                           const TargetRegisterClass *RC) const;
33
34  void loadRegFromStackSlot(MachineBasicBlock &MBB,
35                            MachineBasicBlock::iterator MI,
36                            unsigned DestReg, int FrameIndex,
37                            const TargetRegisterClass *RC) const;
38
39  void copyRegToReg(MachineBasicBlock &MBB,
40                    MachineBasicBlock::iterator MI,
41                    unsigned DestReg, unsigned SrcReg,
42                    const TargetRegisterClass *RC) const;
43
44  /// foldMemoryOperand - If this target supports it, fold a load or store of
45  /// the specified stack slot into the specified machine instruction for the
46  /// specified operand.  If this is possible, the target should perform the
47  /// folding and return true, otherwise it should return false.  If it folds
48  /// the instruction, it is likely that the MachineInstruction the iterator
49  /// references has been changed.
50  MachineInstr* foldMemoryOperand(MachineInstr* MI,
51                                  unsigned OpNum,
52                                  int FrameIndex) const;
53
54  /// getCalleeSaveRegs - Return a null-terminated list of all of the
55  /// callee-save registers on this target.
56  const unsigned *getCalleeSaveRegs() const;
57
58  /// getCalleeSaveRegClasses - Return a null-terminated list of the preferred
59  /// register classes to spill each callee-saved register with.  The order and
60  /// length of this list match the getCalleeSaveRegs() list.
61  const TargetRegisterClass* const* getCalleeSaveRegClasses() const;
62
63  void eliminateCallFramePseudoInstr(MachineFunction &MF,
64                                     MachineBasicBlock &MBB,
65                                     MachineBasicBlock::iterator MI) const;
66
67  void eliminateFrameIndex(MachineBasicBlock::iterator MI) const;
68
69  void processFunctionBeforeFrameFinalized(MachineFunction &MF) const;
70
71  void emitPrologue(MachineFunction &MF) const;
72  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
73
74  // Debug information queries.
75  unsigned getRARegister() const;
76  unsigned getFrameRegister(MachineFunction &MF) const;
77};
78
79// getX86SubSuperRegister - X86 utility function. It returns the sub or super
80// register of a specific X86 register.
81// e.g. getX86SubSuperRegister(X86::EAX, MVT::i16) return X86:AX
82unsigned getX86SubSuperRegister(unsigned, MVT::ValueType, bool High=false);
83
84} // End llvm namespace
85
86#endif
87