Skip to content

Commit

Permalink
Fix ppc store update instructions (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeekyCt authored Aug 25, 2023
1 parent eefca95 commit 4b2b612
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions m2c/arch_ppc.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,27 +769,41 @@ def eval_fn(s: NodeState, a: InstrArgs) -> None:
)
inputs = [args[0], args[1], args[2]]
outputs = [args[1]]

def eval_fn(s: NodeState, a: InstrArgs) -> None:
store = cls.instrs_store_update[mnemonic](a)

# Update the register in the second argument
update = a.reg_ref(1)
offset = a.reg(2)
s.set_reg(update, add_imm(update, a.regs[update], offset, a))

if store is not None:
s.store_memory(store, a.reg_ref(0))

else:
assert len(args) == 2 + psq_imms and isinstance(args[1], AsmAddressMode)
inputs = [args[0], args[1].rhs]
outputs = make_memory_access(args[1], size) + [args[1].rhs]

def eval_fn(s: NodeState, a: InstrArgs) -> None:
store = cls.instrs_store_update[mnemonic](a)
def eval_fn(s: NodeState, a: InstrArgs) -> None:
store = cls.instrs_store_update[mnemonic](a)

# Update the register in the second argument
update = a.memory_ref(1)
if not isinstance(update, AddressMode):
raise DecompFailure(
f"Unhandled store-and-update arg in {instr_str}: {update!r}"
# Update the register in the second argument
update = a.memory_ref(1)
if not isinstance(update, AddressMode):
raise DecompFailure(
f"Unhandled store-and-update arg in {instr_str}: {update!r}"
)
s.set_reg(
update.rhs,
add_imm(
update.rhs, a.regs[update.rhs], Literal(update.offset), a
),
)
s.set_reg(
update.rhs,
add_imm(update.rhs, a.regs[update.rhs], Literal(update.offset), a),
)

if store is not None:
s.store_memory(store, a.reg_ref(0))
if store is not None:
s.store_memory(store, a.reg_ref(0))

elif mnemonic in cls.instrs_load:
assert isinstance(args[0], Register) and size is not None
Expand Down

0 comments on commit 4b2b612

Please sign in to comment.