X86RegisterInfo.cpp revision 6877dd3fb05bb7f8fabf907e520c7d3ae0fab341
1//===- X86RegisterInfo.cpp - X86 Register Information -----------*- C++ -*-===// 2// 3// This file contains the X86 implementation of the MRegisterInfo class. 4// 5//===----------------------------------------------------------------------===// 6 7#include "X86.h" 8#include "X86RegisterInfo.h" 9#include "X86InstrBuilder.h" 10#include "llvm/Constants.h" 11#include "llvm/Type.h" 12#include "llvm/CodeGen/MachineInstrBuilder.h" 13 14// X86Regs - Turn the X86RegisterInfo.def file into a bunch of register 15// descriptors 16// 17static const MRegisterDesc X86Regs[] = { 18#define R(ENUM, NAME, FLAGS, TSFLAGS) { NAME, FLAGS, TSFLAGS }, 19#include "X86RegisterInfo.def" 20}; 21 22X86RegisterInfo::X86RegisterInfo() 23 : MRegisterInfo(X86Regs, sizeof(X86Regs)/sizeof(X86Regs[0])) { 24} 25 26 27MachineBasicBlock::iterator 28X86RegisterInfo::storeReg2RegOffset(MachineBasicBlock *MBB, 29 MachineBasicBlock::iterator &MBBI, 30 unsigned SrcReg, unsigned DestReg, 31 unsigned ImmOffset, unsigned dataSize) 32 const 33{ 34 MachineInstr *MI = addRegOffset(BuildMI(X86::MOVrm32, 5), 35 DestReg, ImmOffset).addReg(SrcReg); 36 return ++(MBB->insert(MBBI, MI)); 37} 38 39MachineBasicBlock::iterator 40X86RegisterInfo::loadRegOffset2Reg(MachineBasicBlock *MBB, 41 MachineBasicBlock::iterator &MBBI, 42 unsigned DestReg, unsigned SrcReg, 43 unsigned ImmOffset, unsigned dataSize) 44 const 45{ 46 MachineInstr *MI = addRegOffset(BuildMI(X86::MOVmr32, 5).addReg(DestReg), 47 SrcReg, ImmOffset); 48 return ++(MBB->insert(MBBI, MI)); 49} 50 51 52unsigned X86RegisterInfo::getFramePointer() const { 53 return X86::EBP; 54} 55 56unsigned X86RegisterInfo::getStackPointer() const { 57 return X86::ESP; 58} 59