Add mapping in MachineFunction from SSA regs to Register Classes. Also,

uncovered a bug where registers were not being put in a map if they were not
found...

llvm-svn: 4776
This commit is contained in:
Misha Brukman 2002-11-20 00:58:23 +00:00
parent ade1143692
commit eaaceb1210
1 changed files with 11 additions and 1 deletions

View File

@ -17,7 +17,11 @@
#include "llvm/Constants.h"
#include "llvm/Pass.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Target/MRegisterInfo.h"
#include <map>
using namespace MOTy; // Get Use, Def, UseAndDef
@ -105,8 +109,14 @@ namespace {
unsigned getReg(Value &V) { return getReg(&V); } // Allow references
unsigned getReg(Value *V) {
unsigned &Reg = RegMap[V];
if (Reg == 0)
if (Reg == 0) {
Reg = CurReg++;
RegMap[V] = Reg;
// Add the mapping of regnumber => reg class to MachineFunction
F->addRegMap(Reg,
TM.getRegisterInfo()->getRegClassForType(V->getType()));
}
// If this operand is a constant, emit the code to copy the constant into
// the register here...