Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ppc store update instructions #263

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading