mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-19 17:33:29 +00:00
Rework comparison handling to set a register on true/false. This avoids
problems with phi-nodes in blocks that have hard and not virtual registers. Accordingly update branch handling to compensate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115013 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f8476e6742
commit
229207aa2e
@ -778,24 +778,18 @@ bool ARMFastISel::SelectBranch(const Instruction *I) {
|
|||||||
MachineBasicBlock *FBB = FuncInfo.MBBMap[BI->getSuccessor(1)];
|
MachineBasicBlock *FBB = FuncInfo.MBBMap[BI->getSuccessor(1)];
|
||||||
|
|
||||||
// Simple branch support.
|
// Simple branch support.
|
||||||
// TODO: Hopefully we've already handled the condition since we won't
|
// TODO: Try to avoid the re-computation in some places.
|
||||||
// have left an update in the value map. See the TODO below in SelectCMP.
|
unsigned CondReg = getRegForValue(BI->getCondition());
|
||||||
Value *Cond = BI->getCondition();
|
|
||||||
unsigned CondReg = getRegForValue(Cond);
|
|
||||||
if (CondReg == 0) return false;
|
if (CondReg == 0) return false;
|
||||||
|
|
||||||
CmpInst *CI = dyn_cast<CmpInst>(Cond);
|
// Re-set the flags just in case.
|
||||||
if (!CI) return false;
|
unsigned CmpOpc = isThumb ? ARM::t2CMPri : ARM::CMPri;
|
||||||
|
AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(CmpOpc))
|
||||||
// Get the compare predicate.
|
.addReg(CondReg).addImm(1));
|
||||||
ARMCC::CondCodes ARMPred = getComparePred(CI->getPredicate());
|
|
||||||
|
|
||||||
// We may not handle every CC for now.
|
|
||||||
if (ARMPred == ARMCC::AL) return false;
|
|
||||||
|
|
||||||
unsigned BrOpc = isThumb ? ARM::t2Bcc : ARM::Bcc;
|
unsigned BrOpc = isThumb ? ARM::t2Bcc : ARM::Bcc;
|
||||||
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(BrOpc))
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(BrOpc))
|
||||||
.addMBB(TBB).addImm(ARMPred).addReg(CondReg);
|
.addMBB(TBB).addImm(ARMCC::EQ).addReg(ARM::CPSR);
|
||||||
FastEmitBranch(FBB, DL);
|
FastEmitBranch(FBB, DL);
|
||||||
FuncInfo.MBB->addSuccessor(TBB);
|
FuncInfo.MBB->addSuccessor(TBB);
|
||||||
return true;
|
return true;
|
||||||
@ -814,24 +808,30 @@ bool ARMFastISel::SelectCmp(const Instruction *I) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
unsigned CmpOpc;
|
unsigned CmpOpc;
|
||||||
unsigned DestReg;
|
unsigned CondReg;
|
||||||
switch (VT.getSimpleVT().SimpleTy) {
|
switch (VT.getSimpleVT().SimpleTy) {
|
||||||
default: return false;
|
default: return false;
|
||||||
// TODO: Verify compares.
|
// TODO: Verify compares.
|
||||||
case MVT::f32:
|
case MVT::f32:
|
||||||
CmpOpc = ARM::VCMPES;
|
CmpOpc = ARM::VCMPES;
|
||||||
DestReg = ARM::FPSCR;
|
CondReg = ARM::FPSCR;
|
||||||
break;
|
break;
|
||||||
case MVT::f64:
|
case MVT::f64:
|
||||||
CmpOpc = ARM::VCMPED;
|
CmpOpc = ARM::VCMPED;
|
||||||
DestReg = ARM::FPSCR;
|
CondReg = ARM::FPSCR;
|
||||||
break;
|
break;
|
||||||
case MVT::i32:
|
case MVT::i32:
|
||||||
CmpOpc = isThumb ? ARM::t2CMPrr : ARM::CMPrr;
|
CmpOpc = isThumb ? ARM::t2CMPrr : ARM::CMPrr;
|
||||||
DestReg = ARM::CPSR;
|
CondReg = ARM::CPSR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the compare predicate.
|
||||||
|
ARMCC::CondCodes ARMPred = getComparePred(CI->getPredicate());
|
||||||
|
|
||||||
|
// We may not handle every CC for now.
|
||||||
|
if (ARMPred == ARMCC::AL) return false;
|
||||||
|
|
||||||
unsigned Arg1 = getRegForValue(CI->getOperand(0));
|
unsigned Arg1 = getRegForValue(CI->getOperand(0));
|
||||||
if (Arg1 == 0) return false;
|
if (Arg1 == 0) return false;
|
||||||
|
|
||||||
@ -847,7 +847,17 @@ bool ARMFastISel::SelectCmp(const Instruction *I) {
|
|||||||
AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
|
AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
|
||||||
TII.get(ARM::FMSTAT)));
|
TII.get(ARM::FMSTAT)));
|
||||||
|
|
||||||
// Update the value to the implicit def reg.
|
// Now set a register based on the comparison. Explicitly set the predicates
|
||||||
|
// here.
|
||||||
|
unsigned MovCCOpc = isThumb ? ARM::tMOVCCi : ARM::MOVCCi;
|
||||||
|
unsigned DestReg = createResultReg(ARM::GPRRegisterClass);
|
||||||
|
Constant *Zero
|
||||||
|
= ConstantInt::get(Type::getInt32Ty(I->getType()->getContext()), 0);
|
||||||
|
unsigned ZeroReg = TargetMaterializeConstant(Zero);
|
||||||
|
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(MovCCOpc), DestReg)
|
||||||
|
.addReg(ZeroReg).addImm(1)
|
||||||
|
.addImm(ARMPred).addReg(CondReg);
|
||||||
|
|
||||||
UpdateValueMap(I, DestReg);
|
UpdateValueMap(I, DestReg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user