Skip to content

Commit bc52567

Browse files
committed
ARM: additional astprov handling
1 parent 0940b73 commit bc52567

File tree

4 files changed

+34
-14
lines changed

4 files changed

+34
-14
lines changed

chb/app/CHVersion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
chbversion: str = "0.3.0-20250312"
1+
chbversion: str = "0.3.0-20250313"

chb/arm/opcodes/ARMMove.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,9 @@ def ast_prov(
237237
astree.add_lval_defuses(hl_lhs, defuses[0])
238238
astree.add_lval_defuses_high(hl_lhs, defuseshigh[0])
239239

240+
if astree.has_register_variable_intro(iaddr):
241+
rvintro = astree.get_register_variable_intro(iaddr)
242+
if rvintro.has_cast():
243+
astree.add_expose_instruction(hl_assign.instrid)
244+
240245
return ([hl_assign], [ll_assign])

chb/ast/ASTCPrettyPrinter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ def write_global_declarations(self) -> None:
185185
continue
186186
self.ccode.newline(indent=self.indent)
187187
if vinfo.vtype is None:
188-
self.ccode.write("? " + vinfo.vname + ";")
188+
self.ccode.write("int " + vinfo.vname + ";")
189+
self.ccode.write(" // no type available; int inserted here")
189190
continue
190191

191192
if vinfo.vtype.is_function:

chb/invariants/XXprUtil.py

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,25 @@ def vargument_deref_value_to_ast_lval_expression(
656656
astree,
657657
anonymous=anonymous)
658658

659-
elif tgttype.is_scalar and coff == 0:
659+
if tgttype.is_pointer:
660+
ioff = coff // 4
661+
aoff = astree.mk_scalar_index_offset(ioff)
662+
if xinitarg.is_ast_lval_expr:
663+
xinitarg = cast(AST.ASTLvalExpr, xinitarg)
664+
lhost = xinitarg.lval.lhost
665+
lval = astree.mk_lval(lhost, offset=aoff, anonymous=anonymous)
666+
return astree.mk_lval_expression(lval, anonymous=anonymous)
667+
668+
if tgttype.is_scalar and coff == 0:
660669
return astree.mk_memref_expr(xinitarg, anonymous=anonymous)
661670

671+
if not anonymous:
672+
chklogger.logger.error(
673+
"AST conversion of initial register deref value: %s with offset %s "
674+
+ "and type %s not yet handled at %s",
675+
str(xinitarg), str(coff), str(argtype), iaddr)
676+
return astree.mk_temp_lval_expression()
677+
662678
if not anonymous:
663679
chklogger.logger.error(
664680
"AST conversion of argument deref value: %s with offset %s and type %s "
@@ -1122,17 +1138,15 @@ def default() -> AST.ASTExpr:
11221138
astxpr2 = xxpr_to_ast_expr(xpr2, xdata, iaddr, astree, anonymous=anonymous)
11231139
if operator in ["plus", "minus"]:
11241140
ty1 = astxpr1.ctype(astree.ctyper)
1125-
if ty1 is not None:
1126-
if ty1.is_pointer:
1127-
return mk_xpointer_expr(
1128-
operator,
1129-
astxpr1,
1130-
cast(AST.ASTTypPtr, ty1),
1131-
astxpr2,
1132-
iaddr,
1133-
astree,
1134-
anonymous=anonymous)
1135-
return astree.mk_binary_expression(operator, astxpr1, astxpr2)
1141+
if ty1 is not None and ty1.is_pointer:
1142+
return mk_xpointer_expr(
1143+
operator,
1144+
astxpr1,
1145+
cast(AST.ASTTypPtr, ty1),
1146+
astxpr2,
1147+
iaddr,
1148+
astree,
1149+
anonymous=anonymous)
11361150
else:
11371151
return default()
11381152
else:

0 commit comments

Comments
 (0)