diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2009-05-03 13:09:57 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2009-05-03 13:09:57 +0000 |
commit | f6af822c7669d43d6e76318bdfbdee957c9aa001 (patch) | |
tree | ee367334e4835ac681c14b530d2a841d210cfb3a /llvm/lib/Target/MSP430/MSP430InstrInfo.cpp | |
parent | ed6567176860511fbb5e5585ba51daa80e96b6c5 (diff) | |
download | bcm5719-llvm-f6af822c7669d43d6e76318bdfbdee957c9aa001.tar.gz bcm5719-llvm-f6af822c7669d43d6e76318bdfbdee957c9aa001.zip |
First draft of stack slot loads / stores lowering
llvm-svn: 70735
Diffstat (limited to 'llvm/lib/Target/MSP430/MSP430InstrInfo.cpp')
-rw-r--r-- | llvm/lib/Target/MSP430/MSP430InstrInfo.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/llvm/lib/Target/MSP430/MSP430InstrInfo.cpp b/llvm/lib/Target/MSP430/MSP430InstrInfo.cpp index dbbf29cdeea..c32dbdca2e2 100644 --- a/llvm/lib/Target/MSP430/MSP430InstrInfo.cpp +++ b/llvm/lib/Target/MSP430/MSP430InstrInfo.cpp @@ -16,10 +16,10 @@ #include "MSP430TargetMachine.h" #include "MSP430GenInstrInfo.inc" #include "llvm/Function.h" -#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" - +#include "llvm/CodeGen/PseudoSourceValue.h" using namespace llvm; @@ -27,6 +27,42 @@ MSP430InstrInfo::MSP430InstrInfo(MSP430TargetMachine &tm) : TargetInstrInfoImpl(MSP430Insts, array_lengthof(MSP430Insts)), RI(tm, *this), TM(tm) {} +void MSP430InstrInfo::storeRegToStackSlot(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + unsigned SrcReg, bool isKill, int FrameIdx, + const TargetRegisterClass *RC) const { + DebugLoc DL = DebugLoc::getUnknownLoc(); + if (MI != MBB.end()) DL = MI->getDebugLoc(); + + if (RC == &MSP430::GR16RegClass) + BuildMI(MBB, MI, DL, get(MSP430::MOV16mr)) + .addFrameIndex(FrameIdx).addImm(0) + .addReg(SrcReg, false, false, isKill); + else if (RC == &MSP430::GR8RegClass) + BuildMI(MBB, MI, DL, get(MSP430::MOV8mr)) + .addFrameIndex(FrameIdx).addImm(0) + .addReg(SrcReg, false, false, isKill); + else + assert(0 && "Cannot store this register to stack slot!"); +} + +void MSP430InstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + unsigned DestReg, int FrameIdx, + const TargetRegisterClass *RC) const{ + DebugLoc DL = DebugLoc::getUnknownLoc(); + if (MI != MBB.end()) DL = MI->getDebugLoc(); + + if (RC == &MSP430::GR16RegClass) + BuildMI(MBB, MI, DL, get(MSP430::MOV16rm)) + .addReg(DestReg).addFrameIndex(FrameIdx).addImm(0); + else if (RC == &MSP430::GR8RegClass) + BuildMI(MBB, MI, DL, get(MSP430::MOV8rm)) + .addReg(DestReg).addFrameIndex(FrameIdx).addImm(0); + else + assert(0 && "Cannot store this register to stack slot!"); +} + bool MSP430InstrInfo::copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned DestReg, unsigned SrcReg, |