This commit is contained in:
patchzyy
2026-09-24 18:06:32 +02:00
committed by GitHub
parent b59e035b87
commit 583e702547
2 changed files with 33 additions and 0 deletions
@@ -1942,6 +1942,22 @@ public sealed partial class PpcLifter
new IrCall(string.Empty, TargetLabel(ins, validAddresses, preferFallthrough: false), blArgs)
};
case "bltl":
{
var crField = "cr0";
if (ops.Count > 0 && ops[0] is PpcConditionRegisterOperand crOp)
{
crField = NormalizeRegister(crOp.Name);
}
return new IrInstruction[]
{
new IrAssign("lr", IrValue.Imm((int)ins.EndAddress)),
new IrBranch("blt", TargetLabel(ins, validAddresses, preferFallthrough: false),
$"0x{ins.EndAddress:X8}", crField)
};
}
case "bcl":
{
var rawInstr = ReadRawInstruction(ins);
@@ -14,6 +14,23 @@ public class PpcLifterAdditionalCoverageTests
private static PpcInstruction Instruction(uint raw, string mnemonic, params PpcOperand[] operands)
=> PpcInstruction.Synthetic(0x80000000, raw, mnemonic, operands);
[Fact]
public void LinkedConditionalBranchSetsLrBeforeEitherPath()
{
var branch = PpcDecoder.Decode(0x80004394, 0x41800029);
var ir = Assert.Single(new PpcLifter().Lift(new[] { branch })).Ir;
Assert.Equal("bltl", branch.Mnemonic);
var lr = Assert.IsType<IrAssign>(ir[0]);
Assert.Equal("lr", lr.Destination);
Assert.Equal(unchecked((int)0x80004398u), lr.Value.Constant);
var decision = Assert.IsType<IrBranch>(ir[1]);
Assert.Equal("blt", decision.Condition);
Assert.Equal("0x800043BC", decision.TrueLabel);
Assert.Equal("0x80004398", decision.FalseLabel);
}
[Fact]
public void LiftsAdditionalNonDotArithmeticAndLogicalForms()
{