Skip to content

Commit

Permalink
VEXConverter: Convert DirtyStmts to Assignments. (#240)
Browse files Browse the repository at this point in the history
* VEXConverter: Convert DirtyStmts to Assignments.

* Lint code.

* Handle invalid tmps.
  • Loading branch information
ltfish authored Sep 18, 2024
1 parent 765a910 commit dd886ca
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ailment/converter_vex.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint:disable=missing-class-docstring
import logging

import pyvex
Expand Down Expand Up @@ -628,6 +629,32 @@ def CAS(idx, stmt: pyvex.IRStmt.CAS, manager):

return stmts

@staticmethod
def Dirty(idx, stmt: pyvex.IRStmt.Dirty, manager):
# we translate it into tmp = DirtyExpression() if possible

if stmt.tmp == 0xFFFFFFFF:
return DirtyStatement(
idx,
stmt,
ins_addr=manager.ins_addr,
vex_block_addr=manager.block_addr,
vex_stmt_idx=manager.vex_stmt_idx,
)

bits = manager.tyenv.sizeof(stmt.tmp)
tmp = VEXExprConverter.tmp(stmt.tmp, bits, manager)
dirty_expr = DirtyExpression(manager.next_atom(), stmt, bits=bits)

return Assignment(
idx,
tmp,
dirty_expr,
ins_addr=manager.ins_addr,
vex_block_addr=manager.block_addr,
vex_stmt_idx=manager.vex_stmt_idx,
)


STATEMENT_MAPPINGS = {
pyvex.IRStmt.Put: VEXStmtConverter.Put,
Expand All @@ -637,6 +664,7 @@ def CAS(idx, stmt: pyvex.IRStmt.CAS, manager):
pyvex.IRStmt.StoreG: VEXStmtConverter.StoreG,
pyvex.IRStmt.LoadG: VEXStmtConverter.LoadG,
pyvex.IRStmt.CAS: VEXStmtConverter.CAS,
pyvex.IRStmt.Dirty: VEXStmtConverter.Dirty,
}


Expand Down

0 comments on commit dd886ca

Please sign in to comment.