Skip to content

Commit 1828a2d

Browse files
committed
ARM: support for lifting of predicated instructions
1 parent 23409cb commit 1828a2d

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

chb/arm/ARMOpcode.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,18 @@ def has_cxpr(self, index: int) -> bool:
186186
def is_cxpr_ok(self, index: int) -> bool:
187187
return self.xdata.is_cxpr_ok(index)
188188

189+
def has_instruction_condition(self) -> bool:
190+
return self.xdata.has_instruction_condition()
191+
192+
def get_instruction_condition(self) -> "XXpr":
193+
return self.xdata.get_instruction_condition()
194+
195+
def has_valid_instruction_c_condition(self) -> bool:
196+
return self.xdata.has_valid_instruction_c_condition()
197+
198+
def get_instruction_c_condition(self) -> "XXpr":
199+
return self.xdata.get_instruction_c_condition()
200+
189201
def add_instruction_condition(self, s: str) -> str:
190202
if self.xdata.has_unknown_instruction_condition():
191203
return "if ? then " + s
@@ -330,6 +342,37 @@ def ast_condition_prov(
330342
expr = self.ast_condition(astree, iaddr, bytestring, xdata, reverse)
331343
return (expr, expr)
332344

345+
def ast_cc_condition_prov(
346+
self,
347+
astree: ASTInterface,
348+
iaddr: str,
349+
bytestring: str,
350+
xdata: InstrXData
351+
) -> Tuple[Optional[AST.ASTExpr], Optional[AST.ASTExpr]]:
352+
353+
ll_astcond = self.ast_cc_expr(astree)
354+
355+
if xdata.has_instruction_condition():
356+
xd = ARMOpcodeXData(xdata)
357+
if xd.has_valid_instruction_c_condition():
358+
pcond = xd.get_instruction_c_condition()
359+
else:
360+
pcond = xd.get_instruction_condition()
361+
hl_astcond = XU.xxpr_to_ast_def_expr(pcond, xdata, iaddr, astree)
362+
363+
astree.add_expr_mapping(hl_astcond, ll_astcond)
364+
astree.add_expr_reachingdefs(hl_astcond, xdata.reachingdefs)
365+
astree.add_flag_expr_reachingdefs(ll_astcond, xdata.flag_reachingdefs)
366+
astree.add_condition_address(ll_astcond, [iaddr])
367+
368+
return (hl_astcond, ll_astcond)
369+
370+
else:
371+
chklogger.logger.error(
372+
"No condition found at address %s", iaddr)
373+
hl_astcond = astree.mk_temp_lval_expression()
374+
return (hl_astcond, ll_astcond)
375+
333376
def ast_switch_condition_prov(
334377
self,
335378
astree: ASTInterface,

0 commit comments

Comments
 (0)