mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-19 02:25:01 +00:00
Modify the ISD::ADD opcode case to use new immediate constant predicates.
Includes support for 32-bit constants using addi/addis. Patch by Jim Laskey. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22711 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1689,19 +1689,23 @@ unsigned ISel::SelectExpr(SDOperand N, bool Recording) {
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
Tmp1 = SelectExpr(N.getOperand(0));
|
Tmp1 = SelectExpr(N.getOperand(0));
|
||||||
switch(getImmediateForOpcode(N.getOperand(1), opcode, Tmp2)) {
|
if (isImmediate(N.getOperand(1), Tmp2)) {
|
||||||
default: assert(0 && "unhandled result code");
|
Tmp3 = HA16(Tmp2);
|
||||||
case 0: // No immediate
|
Tmp2 = Lo16(Tmp2);
|
||||||
Tmp2 = SelectExpr(N.getOperand(1));
|
if (Tmp2 && Tmp3) {
|
||||||
BuildMI(BB, PPC::ADD, 2, Result).addReg(Tmp1).addReg(Tmp2);
|
unsigned Reg = MakeReg(MVT::i32);
|
||||||
break;
|
BuildMI(BB, PPC::ADDI, 2, Reg).addReg(Tmp1).addSImm(Tmp2);
|
||||||
case 1: // Low immediate
|
BuildMI(BB, PPC::ADDIS, 2, Result).addReg(Reg).addSImm(Tmp3);
|
||||||
|
} else if (Tmp2) {
|
||||||
BuildMI(BB, PPC::ADDI, 2, Result).addReg(Tmp1).addSImm(Tmp2);
|
BuildMI(BB, PPC::ADDI, 2, Result).addReg(Tmp1).addSImm(Tmp2);
|
||||||
break;
|
} else {
|
||||||
case 2: // Shifted immediate
|
BuildMI(BB, PPC::ADDIS, 2, Result).addReg(Tmp1).addSImm(Tmp3);
|
||||||
BuildMI(BB, PPC::ADDIS, 2, Result).addReg(Tmp1).addSImm(Tmp2);
|
}
|
||||||
break;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tmp2 = SelectExpr(N.getOperand(1));
|
||||||
|
BuildMI(BB, PPC::ADD, 2, Result).addReg(Tmp1).addReg(Tmp2);
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
case ISD::AND:
|
case ISD::AND:
|
||||||
|
Reference in New Issue
Block a user