mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
Add register class hack that needs to go away, but makes it more obvious
that it needs to go away. Use loadRegFromStackSlot where possible. Also, remember to update the value map. llvm-svn: 111883
This commit is contained in:
parent
115fdde871
commit
5d1289db95
@ -58,6 +58,9 @@ class ARMFastISel : public FastISel {
|
|||||||
const TargetInstrInfo &TII;
|
const TargetInstrInfo &TII;
|
||||||
const TargetLowering &TLI;
|
const TargetLowering &TLI;
|
||||||
const ARMFunctionInfo *AFI;
|
const ARMFunctionInfo *AFI;
|
||||||
|
|
||||||
|
// FIXME: Remove this and replace it with queries.
|
||||||
|
const TargetRegisterClass *FixedRC;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ARMFastISel(FunctionLoweringInfo &funcInfo)
|
explicit ARMFastISel(FunctionLoweringInfo &funcInfo)
|
||||||
@ -67,6 +70,7 @@ class ARMFastISel : public FastISel {
|
|||||||
TLI(*TM.getTargetLowering()) {
|
TLI(*TM.getTargetLowering()) {
|
||||||
Subtarget = &TM.getSubtarget<ARMSubtarget>();
|
Subtarget = &TM.getSubtarget<ARMSubtarget>();
|
||||||
AFI = funcInfo.MF->getInfo<ARMFunctionInfo>();
|
AFI = funcInfo.MF->getInfo<ARMFunctionInfo>();
|
||||||
|
FixedRC = ARM::GPRRegisterClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Code from FastISel.cpp.
|
// Code from FastISel.cpp.
|
||||||
@ -109,6 +113,7 @@ class ARMFastISel : public FastISel {
|
|||||||
|
|
||||||
// Utility routines.
|
// Utility routines.
|
||||||
private:
|
private:
|
||||||
|
bool ARMLoadAlloca(const Instruction *I);
|
||||||
bool ARMComputeRegOffset(const Value *Obj, unsigned &Reg, int &Offset);
|
bool ARMComputeRegOffset(const Value *Obj, unsigned &Reg, int &Offset);
|
||||||
|
|
||||||
bool DefinesOptionalPredicate(MachineInstr *MI, bool *CPSR);
|
bool DefinesOptionalPredicate(MachineInstr *MI, bool *CPSR);
|
||||||
@ -340,22 +345,14 @@ bool ARMFastISel::ARMComputeRegOffset(const Value *Obj, unsigned &Reg,
|
|||||||
//errs() << "Failing Opcode is: " << *Op1 << "\n";
|
//errs() << "Failing Opcode is: " << *Op1 << "\n";
|
||||||
break;
|
break;
|
||||||
case Instruction::Alloca: {
|
case Instruction::Alloca: {
|
||||||
// Do static allocas.
|
assert(false && "Alloca should have been handled earlier!");
|
||||||
const AllocaInst *A = cast<AllocaInst>(Obj);
|
return false;
|
||||||
DenseMap<const AllocaInst*, int>::iterator SI =
|
|
||||||
FuncInfo.StaticAllocaMap.find(A);
|
|
||||||
if (SI != FuncInfo.StaticAllocaMap.end())
|
|
||||||
Offset =
|
|
||||||
TM.getRegisterInfo()->getFrameIndexReference(*FuncInfo.MF,
|
|
||||||
SI->second, Reg);
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const GlobalValue *GV = dyn_cast<GlobalValue>(Obj)) {
|
if (const GlobalValue *GV = dyn_cast<GlobalValue>(Obj)) {
|
||||||
//errs() << "Failing GV is: " << GV << "\n";
|
//errs() << "Failing GV is: " << GV << "\n";
|
||||||
|
(void)GV;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,12 +361,37 @@ bool ARMFastISel::ARMComputeRegOffset(const Value *Obj, unsigned &Reg,
|
|||||||
return Reg != 0;
|
return Reg != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ARMFastISel::ARMLoadAlloca(const Instruction *I) {
|
||||||
|
Value *Op0 = I->getOperand(0);
|
||||||
|
|
||||||
|
// Verify it's an alloca.
|
||||||
|
const Instruction *Inst = dyn_cast<Instruction>(Op0);
|
||||||
|
if (!Inst || Inst->getOpcode() != Instruction::Alloca) return false;
|
||||||
|
|
||||||
|
const AllocaInst *AI = cast<AllocaInst>(Op0);
|
||||||
|
DenseMap<const AllocaInst*, int>::iterator SI =
|
||||||
|
FuncInfo.StaticAllocaMap.find(AI);
|
||||||
|
|
||||||
|
if (SI != FuncInfo.StaticAllocaMap.end()) {
|
||||||
|
unsigned ResultReg = createResultReg(FixedRC);
|
||||||
|
TII.loadRegFromStackSlot(*FuncInfo.MBB, *FuncInfo.InsertPt,
|
||||||
|
ResultReg, SI->second, FixedRC,
|
||||||
|
TM.getRegisterInfo());
|
||||||
|
UpdateValueMap(I, ResultReg);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool ARMFastISel::ARMSelectLoad(const Instruction *I) {
|
bool ARMFastISel::ARMSelectLoad(const Instruction *I) {
|
||||||
// Our register and offset with innocuous defaults.
|
// Our register and offset with innocuous defaults.
|
||||||
unsigned Reg = 0;
|
unsigned Reg = 0;
|
||||||
int Offset = 0;
|
int Offset = 0;
|
||||||
|
|
||||||
// TODO: Think about using loadRegFromStackSlot() here when we can.
|
// TODO: Think about using loadRegFromStackSlot() here when we can.
|
||||||
|
if (ARMLoadAlloca(I))
|
||||||
|
return true;
|
||||||
|
|
||||||
// See if we can handle this as Reg + Offset
|
// See if we can handle this as Reg + Offset
|
||||||
if (!ARMComputeRegOffset(I->getOperand(0), Reg, Offset))
|
if (!ARMComputeRegOffset(I->getOperand(0), Reg, Offset))
|
||||||
@ -393,10 +415,11 @@ bool ARMFastISel::ARMSelectLoad(const Instruction *I) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: There is more than one register class in the world...
|
// FIXME: There is more than one register class in the world...
|
||||||
unsigned ResultReg = createResultReg(ARM::GPRRegisterClass);
|
unsigned ResultReg = createResultReg(FixedRC);
|
||||||
AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
|
AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
|
||||||
TII.get(ARM::LDR), ResultReg)
|
TII.get(ARM::LDR), ResultReg)
|
||||||
.addImm(0).addReg(Reg).addImm(Offset));
|
.addImm(0).addReg(Reg).addImm(Offset));
|
||||||
|
UpdateValueMap(I, ResultReg);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user