#include "llvm/Type.h"
#include "llvm/Constants.h"
#include "llvm/Pass.h"
#include "llvm/Type.h"
#include "llvm/Constants.h"
#include "llvm/Pass.h"
-#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/Target/MachineInstrInfo.h"
#include "llvm/Target/MRegisterInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/Target/MachineInstrInfo.h"
#include "llvm/Target/MRegisterInfo.h"
-#include "llvm/Target/MachineRegInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/InstVisitor.h"
#include "Support/Statistic.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/InstVisitor.h"
#include "Support/Statistic.h"
namespace {
struct RegAllocSimple : public FunctionPass {
namespace {
struct RegAllocSimple : public FunctionPass {
unsigned NumBytesAllocated, ByteAlignment;
// Maps SSA Regs => offsets on the stack where these values are stored
unsigned NumBytesAllocated, ByteAlignment;
// Maps SSA Regs => offsets on the stack where these values are stored
- // FIXME: change name to VirtReg2OffsetMap
- std::map<unsigned, unsigned> RegMap;
+ std::map<unsigned, unsigned> VirtReg2OffsetMap;
// Maps SSA Regs => physical regs
std::map<unsigned, unsigned> SSA2PhysRegMap;
// Maps SSA Regs => physical regs
std::map<unsigned, unsigned> SSA2PhysRegMap;
}
void cleanupAfterFunction() {
}
void cleanupAfterFunction() {
+ VirtReg2OffsetMap.clear();
SSA2PhysRegMap.clear();
NumBytesAllocated = ByteAlignment;
}
SSA2PhysRegMap.clear();
NumBytesAllocated = ByteAlignment;
}
unsigned RegAllocSimple::allocateStackSpaceFor(unsigned VirtReg,
const TargetRegisterClass *regClass)
{
unsigned RegAllocSimple::allocateStackSpaceFor(unsigned VirtReg,
const TargetRegisterClass *regClass)
{
- if (RegMap.find(VirtReg) == RegMap.end()) {
+ if (VirtReg2OffsetMap.find(VirtReg) == VirtReg2OffsetMap.end()) {
#if 0
unsigned size = regClass->getDataSize();
unsigned over = NumBytesAllocated - (NumBytesAllocated % ByteAlignment);
#if 0
unsigned size = regClass->getDataSize();
unsigned over = NumBytesAllocated - (NumBytesAllocated % ByteAlignment);
// need to pad by (ByteAlignment - over)
NumBytesAllocated += ByteAlignment - over;
}
// need to pad by (ByteAlignment - over)
NumBytesAllocated += ByteAlignment - over;
}
- RegMap[VirtReg] = NumBytesAllocated;
+ VirtReg2OffsetMap[VirtReg] = NumBytesAllocated;
NumBytesAllocated += size;
#endif
// FIXME: forcing each arg to take 4 bytes on the stack
NumBytesAllocated += size;
#endif
// FIXME: forcing each arg to take 4 bytes on the stack
- RegMap[VirtReg] = NumBytesAllocated;
+ VirtReg2OffsetMap[VirtReg] = NumBytesAllocated;
NumBytesAllocated += ByteAlignment;
}
NumBytesAllocated += ByteAlignment;
}
- return RegMap[VirtReg];
+ return VirtReg2OffsetMap[VirtReg];
}
unsigned RegAllocSimple::getFreeReg(unsigned virtualReg) {
}
unsigned RegAllocSimple::getFreeReg(unsigned virtualReg) {