2002-12-28 21:32:54 +01:00
|
|
|
//===- X86RegisterInfo.h - X86 Register Information Impl --------*- C++ -*-===//
|
2005-04-22 01:38:14 +02:00
|
|
|
//
|
2003-10-21 17:17:13 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 01:38:14 +02:00
|
|
|
//
|
2003-10-21 17:17:13 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-10-26 00:55:53 +02:00
|
|
|
//
|
|
|
|
// This file contains the X86 implementation of the MRegisterInfo class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef X86REGISTERINFO_H
|
|
|
|
#define X86REGISTERINFO_H
|
|
|
|
|
2007-10-02 01:44:33 +02:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2007-08-30 07:54:07 +02:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2002-10-26 00:55:53 +02:00
|
|
|
#include "llvm/Target/MRegisterInfo.h"
|
2003-08-03 17:48:14 +02:00
|
|
|
#include "X86GenRegisterInfo.h.inc"
|
2002-12-25 06:06:43 +01:00
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
2006-09-05 04:12:02 +02:00
|
|
|
class Type;
|
|
|
|
class TargetInstrInfo;
|
2006-09-08 08:48:29 +02:00
|
|
|
class X86TargetMachine;
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2007-08-29 21:01:20 +02:00
|
|
|
/// N86 namespace - Native X86 register numbers
|
|
|
|
///
|
|
|
|
namespace N86 {
|
|
|
|
enum {
|
|
|
|
EAX = 0, ECX = 1, EDX = 2, EBX = 3, ESP = 4, EBP = 5, ESI = 6, EDI = 7
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2007-11-11 20:50:10 +01:00
|
|
|
/// DWARFFlavour - Flavour of dwarf regnumbers
|
|
|
|
///
|
|
|
|
namespace DWARFFlavour {
|
|
|
|
enum {
|
|
|
|
X86_64 = 0, X86_32_Darwin = 1, X86_32_ELF = 2
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2006-11-05 20:31:28 +01:00
|
|
|
class X86RegisterInfo : public X86GenRegisterInfo {
|
|
|
|
public:
|
2006-09-08 08:48:29 +02:00
|
|
|
X86TargetMachine &TM;
|
2006-09-05 04:12:02 +02:00
|
|
|
const TargetInstrInfo &TII;
|
2006-11-05 20:31:28 +01:00
|
|
|
|
2006-09-08 08:48:29 +02:00
|
|
|
private:
|
|
|
|
/// Is64Bit - Is the target 64-bits.
|
2007-10-02 01:44:33 +02:00
|
|
|
///
|
2006-09-08 08:48:29 +02:00
|
|
|
bool Is64Bit;
|
|
|
|
|
|
|
|
/// SlotSize - Stack slot size in bytes.
|
2007-10-02 01:44:33 +02:00
|
|
|
///
|
2006-09-08 08:48:29 +02:00
|
|
|
unsigned SlotSize;
|
|
|
|
|
2007-11-05 08:30:01 +01:00
|
|
|
/// StackAlign - Default stack alignment.
|
|
|
|
///
|
|
|
|
unsigned StackAlign;
|
|
|
|
|
2006-09-08 08:48:29 +02:00
|
|
|
/// StackPtr - X86 physical register used as stack ptr.
|
2007-10-02 01:44:33 +02:00
|
|
|
///
|
2006-09-08 08:48:29 +02:00
|
|
|
unsigned StackPtr;
|
|
|
|
|
|
|
|
/// FramePtr - X86 physical register used as frame ptr.
|
2007-10-02 01:44:33 +02:00
|
|
|
///
|
2006-09-08 08:48:29 +02:00
|
|
|
unsigned FramePtr;
|
|
|
|
|
2007-10-02 01:44:33 +02:00
|
|
|
/// RegOp2MemOpTable2Addr, RegOp2MemOpTable0, RegOp2MemOpTable1,
|
|
|
|
/// RegOp2MemOpTable2 - Load / store folding opcode maps.
|
|
|
|
///
|
|
|
|
DenseMap<unsigned*, unsigned> RegOp2MemOpTable2Addr;
|
|
|
|
DenseMap<unsigned*, unsigned> RegOp2MemOpTable0;
|
|
|
|
DenseMap<unsigned*, unsigned> RegOp2MemOpTable1;
|
|
|
|
DenseMap<unsigned*, unsigned> RegOp2MemOpTable2;
|
|
|
|
|
|
|
|
/// MemOp2RegOpTable - Load / store unfolding opcode map.
|
|
|
|
///
|
2007-10-05 03:34:55 +02:00
|
|
|
DenseMap<unsigned*, std::pair<unsigned, unsigned> > MemOp2RegOpTable;
|
2007-10-02 01:44:33 +02:00
|
|
|
|
2006-09-08 08:48:29 +02:00
|
|
|
public:
|
|
|
|
X86RegisterInfo(X86TargetMachine &tm, const TargetInstrInfo &tii);
|
2002-12-25 06:06:43 +01:00
|
|
|
|
2007-08-29 21:01:20 +02:00
|
|
|
/// getX86RegNum - Returns the native X86 register number for the given LLVM
|
|
|
|
/// register identifier.
|
|
|
|
unsigned getX86RegNum(unsigned RegNo);
|
|
|
|
|
2008-01-01 22:11:32 +01:00
|
|
|
unsigned getStackAlignment() const { return StackAlign; }
|
|
|
|
|
2007-11-07 01:25:05 +01:00
|
|
|
/// getDwarfRegNum - allows modification of X86GenRegisterInfo::getDwarfRegNum
|
|
|
|
/// (created by TableGen) for target dependencies.
|
2007-11-13 20:13:01 +01:00
|
|
|
int getDwarfRegNum(unsigned RegNum, bool isEH) const;
|
2007-11-07 01:25:05 +01:00
|
|
|
|
2002-12-28 21:32:54 +01:00
|
|
|
/// Code Generation virtual methods...
|
2007-10-02 01:44:33 +02:00
|
|
|
///
|
2007-07-17 09:59:08 +02:00
|
|
|
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
const std::vector<CalleeSavedInfo> &CSI) const;
|
|
|
|
|
|
|
|
bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
const std::vector<CalleeSavedInfo> &CSI) const;
|
2007-03-20 09:09:38 +01:00
|
|
|
|
2007-09-26 23:31:07 +02:00
|
|
|
const TargetRegisterClass *
|
|
|
|
getCrossCopyRegClass(const TargetRegisterClass *RC) const;
|
|
|
|
|
2007-03-20 09:09:38 +01:00
|
|
|
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
|
|
|
|
unsigned DestReg, const MachineInstr *Orig) const;
|
2002-12-25 06:06:43 +01:00
|
|
|
|
2004-02-17 06:54:57 +01:00
|
|
|
/// foldMemoryOperand - If this target supports it, fold a load or store of
|
|
|
|
/// the specified stack slot into the specified machine instruction for the
|
2007-12-02 09:30:39 +01:00
|
|
|
/// specified operand(s). If this is possible, the target should perform the
|
2004-02-17 06:54:57 +01:00
|
|
|
/// folding and return true, otherwise it should return false. If it folds
|
|
|
|
/// the instruction, it is likely that the MachineInstruction the iterator
|
|
|
|
/// references has been changed.
|
2006-05-18 02:12:58 +02:00
|
|
|
MachineInstr* foldMemoryOperand(MachineInstr* MI,
|
2007-12-02 09:30:39 +01:00
|
|
|
SmallVectorImpl<unsigned> &Ops,
|
2006-05-18 02:12:58 +02:00
|
|
|
int FrameIndex) const;
|
|
|
|
|
2007-12-01 03:07:52 +01:00
|
|
|
/// foldMemoryOperand - Same as the previous version except it allows folding
|
|
|
|
/// of any load and store from / to any address, not just from a specific
|
|
|
|
/// stack slot.
|
|
|
|
MachineInstr* foldMemoryOperand(MachineInstr* MI,
|
2007-12-02 09:30:39 +01:00
|
|
|
SmallVectorImpl<unsigned> &Ops,
|
2007-12-01 03:07:52 +01:00
|
|
|
MachineInstr* LoadMI) const;
|
|
|
|
|
2007-12-05 04:14:33 +01:00
|
|
|
/// canFoldMemoryOperand - Returns true if the specified load / store is
|
|
|
|
/// folding is possible.
|
|
|
|
bool canFoldMemoryOperand(MachineInstr*, SmallVectorImpl<unsigned> &) const;
|
2007-10-19 23:23:22 +02:00
|
|
|
|
2007-10-18 21:28:55 +02:00
|
|
|
/// unfoldMemoryOperand - Separate a single instruction which folded a load or
|
2007-10-05 03:34:55 +02:00
|
|
|
/// a store or a load and a store into two or more instruction. If this is
|
|
|
|
/// possible, returns true as well as the new instructions by reference.
|
|
|
|
bool unfoldMemoryOperand(MachineFunction &MF, MachineInstr *MI,
|
2007-10-13 04:35:06 +02:00
|
|
|
unsigned Reg, bool UnfoldLoad, bool UnfoldStore,
|
2007-10-18 23:29:24 +02:00
|
|
|
SmallVectorImpl<MachineInstr*> &NewMIs) const;
|
2007-10-05 03:34:55 +02:00
|
|
|
|
|
|
|
bool unfoldMemoryOperand(SelectionDAG &DAG, SDNode *N,
|
2007-10-18 23:29:24 +02:00
|
|
|
SmallVectorImpl<SDNode*> &NewNodes) const;
|
2007-10-05 03:34:55 +02:00
|
|
|
|
2007-10-19 00:40:57 +02:00
|
|
|
/// getOpcodeAfterMemoryUnfold - Returns the opcode of the would be new
|
2007-10-19 23:23:22 +02:00
|
|
|
/// instruction after load / store are unfolded from an instruction of the
|
|
|
|
/// specified opcode. It returns zero if the specified unfolding is not
|
|
|
|
/// possible.
|
2007-10-19 00:40:57 +02:00
|
|
|
unsigned getOpcodeAfterMemoryUnfold(unsigned Opc,
|
|
|
|
bool UnfoldLoad, bool UnfoldStore) const;
|
|
|
|
|
2007-01-02 22:33:40 +01:00
|
|
|
/// getCalleeSavedRegs - Return a null-terminated list of all of the
|
2006-05-18 02:12:58 +02:00
|
|
|
/// callee-save registers on this target.
|
2007-07-14 16:06:15 +02:00
|
|
|
const unsigned *getCalleeSavedRegs(const MachineFunction* MF = 0) const;
|
2006-05-18 02:12:58 +02:00
|
|
|
|
2007-01-02 22:33:40 +01:00
|
|
|
/// getCalleeSavedRegClasses - Return a null-terminated list of the preferred
|
2006-05-18 02:12:58 +02:00
|
|
|
/// register classes to spill each callee-saved register with. The order and
|
2007-01-02 22:33:40 +01:00
|
|
|
/// length of this list match the getCalleeSavedRegs() list.
|
Change instruction description to split OperandList into OutOperandList and
InOperandList. This gives one piece of important information: # of results
produced by an instruction.
An example of the change:
def ADD32rr : I<0x01, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
"add{l} {$src2, $dst|$dst, $src2}",
[(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
=>
def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
"add{l} {$src2, $dst|$dst, $src2}",
[(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
llvm-svn: 40033
2007-07-19 03:14:50 +02:00
|
|
|
const TargetRegisterClass* const*
|
|
|
|
getCalleeSavedRegClasses(const MachineFunction *MF = 0) const;
|
2004-02-17 05:33:18 +01:00
|
|
|
|
2007-02-19 22:49:54 +01:00
|
|
|
/// getReservedRegs - Returns a bitset indexed by physical register number
|
|
|
|
/// indicating if a register is a special register that has particular uses and
|
|
|
|
/// should be considered unavailable at all times, e.g. SP, RA. This is used by
|
|
|
|
/// register scavenger to determine what registers are free.
|
|
|
|
BitVector getReservedRegs(const MachineFunction &MF) const;
|
|
|
|
|
2007-01-23 01:57:47 +01:00
|
|
|
bool hasFP(const MachineFunction &MF) const;
|
|
|
|
|
2007-07-19 02:42:05 +02:00
|
|
|
bool hasReservedCallFrame(MachineFunction &MF) const;
|
|
|
|
|
2004-02-14 20:49:54 +01:00
|
|
|
void eliminateCallFramePseudoInstr(MachineFunction &MF,
|
|
|
|
MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI) const;
|
2002-12-13 10:54:12 +01:00
|
|
|
|
2007-02-28 01:21:17 +01:00
|
|
|
void eliminateFrameIndex(MachineBasicBlock::iterator MI,
|
2007-05-01 11:13:03 +02:00
|
|
|
int SPAdj, RegScavenger *RS = NULL) const;
|
2002-11-20 19:59:43 +01:00
|
|
|
|
2004-02-14 20:49:54 +01:00
|
|
|
void processFunctionBeforeFrameFinalized(MachineFunction &MF) const;
|
2002-12-04 00:11:21 +01:00
|
|
|
|
2004-02-14 20:49:54 +01:00
|
|
|
void emitPrologue(MachineFunction &MF) const;
|
|
|
|
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
|
2006-03-23 19:12:57 +01:00
|
|
|
|
2006-03-28 15:48:33 +02:00
|
|
|
// Debug information queries.
|
2006-04-07 18:34:46 +02:00
|
|
|
unsigned getRARegister() const;
|
2006-03-28 15:48:33 +02:00
|
|
|
unsigned getFrameRegister(MachineFunction &MF) const;
|
2007-01-24 20:15:24 +01:00
|
|
|
void getInitialFrameState(std::vector<MachineMove> &Moves) const;
|
2007-02-21 23:54:50 +01:00
|
|
|
|
|
|
|
// Exception handling queries.
|
|
|
|
unsigned getEHExceptionRegister() const;
|
|
|
|
unsigned getEHHandlerRegister() const;
|
2007-08-30 07:54:07 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
MachineInstr* foldMemoryOperand(MachineInstr* MI,
|
|
|
|
unsigned OpNum,
|
|
|
|
SmallVector<MachineOperand,4> &MOs) const;
|
2002-10-26 00:55:53 +02:00
|
|
|
};
|
|
|
|
|
2006-05-05 07:40:20 +02:00
|
|
|
// getX86SubSuperRegister - X86 utility function. It returns the sub or super
|
|
|
|
// register of a specific X86 register.
|
|
|
|
// e.g. getX86SubSuperRegister(X86::EAX, MVT::i16) return X86:AX
|
|
|
|
unsigned getX86SubSuperRegister(unsigned, MVT::ValueType, bool High=false);
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2002-10-26 00:55:53 +02:00
|
|
|
#endif
|