1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

Added moveReg2Reg() and moveImm2Reg() to accomodate moving data around due to

PHI nodes.

llvm-svn: 5001
This commit is contained in:
Misha Brukman 2002-12-13 09:54:12 +00:00
parent 74e9df0627
commit fb02408496
3 changed files with 56 additions and 0 deletions

View File

@ -129,6 +129,16 @@ public:
unsigned DestReg, unsigned SrcReg,
unsigned ImmOffset, unsigned dataSize) const = 0;
virtual MachineBasicBlock::iterator
moveReg2Reg(MachineBasicBlock *MBB,
MachineBasicBlock::iterator MBBI,
unsigned DestReg, unsigned SrcReg, unsigned dataSize) const = 0;
virtual MachineBasicBlock::iterator
moveImm2Reg(MachineBasicBlock *MBB,
MachineBasicBlock::iterator MBBI,
unsigned DestReg, unsigned Imm, unsigned dataSize) const = 0;
virtual MachineBasicBlock::iterator
emitPrologue(MachineBasicBlock *MBB,
MachineBasicBlock::iterator MBBI,

View File

@ -63,6 +63,42 @@ X86RegisterInfo::loadRegOffset2Reg(MachineBasicBlock *MBB,
return ++(MBB->insert(MBBI, MI));
}
MachineBasicBlock::iterator
X86RegisterInfo::moveReg2Reg(MachineBasicBlock *MBB,
MachineBasicBlock::iterator MBBI,
unsigned DestReg, unsigned SrcReg,
unsigned dataSize) const
{
unsigned opcode;
switch (dataSize) {
case 1: opcode = X86::MOVrr8; break;
case 2: opcode = X86::MOVrr16; break;
case 4: opcode = X86::MOVrr32; break;
default: assert(0 && "Invalid data size!");
}
MachineInstr *MI = BuildMI(opcode, 2).addReg(DestReg).addReg(SrcReg);
return ++(MBB->insert(MBBI, MI));
}
MachineBasicBlock::iterator
X86RegisterInfo::moveImm2Reg(MachineBasicBlock *MBB,
MachineBasicBlock::iterator MBBI,
unsigned DestReg, unsigned Imm, unsigned dataSize)
const
{
unsigned opcode;
switch (dataSize) {
case 1: opcode = X86::MOVir8; break;
case 2: opcode = X86::MOVir16; break;
case 4: opcode = X86::MOVir32; break;
default: assert(0 && "Invalid data size!");
}
MachineInstr *MI = BuildMI(opcode, 2).addReg(DestReg).addReg(Imm);
return ++(MBB->insert(MBBI, MI));
}
unsigned X86RegisterInfo::getFramePointer() const {
return X86::EBP;

View File

@ -29,6 +29,16 @@ struct X86RegisterInfo : public MRegisterInfo {
unsigned DestReg, unsigned SrcReg,
unsigned ImmOffset, unsigned dataSize) const;
MachineBasicBlock::iterator
moveReg2Reg(MachineBasicBlock *MBB,
MachineBasicBlock::iterator MBBI,
unsigned DestReg, unsigned SrcReg, unsigned dataSize) const;
MachineBasicBlock::iterator
moveImm2Reg(MachineBasicBlock *MBB,
MachineBasicBlock::iterator MBBI,
unsigned DestReg, unsigned Imm, unsigned dataSize) const;
unsigned getFramePointer() const;
unsigned getStackPointer() const;