Skip to content

Commit e611a6c

Browse files
committed
ARM: add rhs to lhs ast-prov conversion
1 parent c24e603 commit e611a6c

File tree

9 files changed

+24
-9
lines changed

9 files changed

+24
-9
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-20251012"
1+
chbversion: str = "0.3.0-20251021"

chb/arm/opcodes/ARMAdd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def has_cast() -> bool:
319319
defuses = xdata.defuses
320320
defuseshigh = xdata.defuseshigh
321321

322-
hl_lhs = XU.xvariable_to_ast_lval(lhs, xdata, iaddr, astree)
322+
hl_lhs = XU.xvariable_to_ast_lval(lhs, xdata, iaddr, astree, rhs=rhs)
323323

324324
if str(lhs) == "PC":
325325
chklogger.logger.info(

chb/arm/opcodes/ARMArithmeticShiftRight.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def ast_prov(
220220
defuses = xdata.defuses
221221
defuseshigh = xdata.defuseshigh
222222

223-
hl_lhs = XU.xvariable_to_ast_lval(lhs, xdata, iaddr, astree)
223+
hl_lhs = XU.xvariable_to_ast_lval(lhs, xdata, iaddr, astree, rhs=rhs)
224224
hl_rhs = XU.xxpr_to_ast_def_expr(rhs, xdata, iaddr, astree)
225225

226226
hl_assign = astree.mk_assign(

chb/arm/opcodes/ARMLogicalShiftLeft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def ast_prov(
245245
defuses = xdata.defuses
246246
defuseshigh = xdata.defuseshigh
247247

248-
hl_lhs = XU.xvariable_to_ast_lval(lhs, xdata, iaddr, astree)
248+
hl_lhs = XU.xvariable_to_ast_lval(lhs, xdata, iaddr, astree, rhs=rhs)
249249
hl_rhs = XU.xxpr_to_ast_def_expr(rhs, xdata, iaddr, astree)
250250

251251
hl_assign = astree.mk_assign(

chb/arm/opcodes/ARMLogicalShiftRight.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def ast_prov(
234234
defuses = xdata.defuses
235235
defuseshigh = xdata.defuseshigh
236236

237-
hl_lhs = XU.xvariable_to_ast_lval(lhs, xdata, iaddr, astree)
237+
hl_lhs = XU.xvariable_to_ast_lval(lhs, xdata, iaddr, astree, rhs=rhs)
238238
hl_rhs = XU.xxpr_to_ast_def_expr(rhs, xdata, iaddr, astree)
239239

240240
hl_assign = astree.mk_assign(

chb/arm/opcodes/ARMReverseSubtract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def ast_prov(
246246
defuses = xdata.defuses
247247
defuseshigh = xdata.defuseshigh
248248

249-
hl_lhs = XU.xvariable_to_ast_lval(lhs, xdata, iaddr, astree)
249+
hl_lhs = XU.xvariable_to_ast_lval(lhs, xdata, iaddr, astree, rhs=rhs)
250250
hl_rhs = XU.xxpr_to_ast_def_expr(rhs, xdata, iaddr, astree)
251251

252252
hl_assign = astree.mk_assign(

chb/arm/opcodes/ARMStoreRegisterHalfword.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,19 @@ def is_cxaddr_ok(self) -> bool:
145145
@property
146146
def annotation(self) -> str:
147147
wbu = self.writeback_update()
148-
clhs = str(self.cvmem) if self.is_cvmem_ok else "None"
148+
if self.is_cvmem_ok:
149+
clhs = str(self.cvmem)
150+
elif self.is_cxaddr_ok:
151+
if self.cxaddr.is_addressof_var:
152+
lhsvar = self.cxaddr.get_addressof_var
153+
if lhsvar is not None:
154+
clhs = str(lhsvar)
155+
else:
156+
clhs = "*(" + str(self.cxaddr) + ")"
157+
else:
158+
clhs = "*(" + str(self.cxaddr) + ")"
159+
else:
160+
clhs = "None"
149161
crhs = str(self.cxrt) if self.is_cxrt_ok else "None"
150162
assignc = "(C: " + clhs + " := " + crhs + ")"
151163
if self.is_vmem_ok:
@@ -165,7 +177,6 @@ def annotation(self) -> str:
165177
return self.add_instruction_condition(assignment + wbu)
166178

167179

168-
169180
@armregistry.register_tag("STRH", ARMOpcode)
170181
class ARMStoreRegisterHalfword(ARMOpcode):
171182
"""Stores the least significant halfword from a register into memory.

chb/arm/opcodes/ARMSubtract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def ast_prov(
236236
defuses = xdata.defuses
237237
defuseshigh = xdata.defuseshigh
238238

239-
hl_lhs = XU.xvariable_to_ast_lval(lhs, xdata, iaddr, astree)
239+
hl_lhs = XU.xvariable_to_ast_lval(lhs, xdata, iaddr, astree, rhs=rhs)
240240

241241
# resulting expression is a stack address
242242
if str(rhs1) == "SP" and xrhs.is_stack_address:

chb/arm/opcodes/ARMTestEquivalence.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ def __init__(self, d: "ARMDictionary", ixval: IndexedTableValue) -> None:
9090
def operands(self) -> List[ARMOperand]:
9191
return [self.armd.arm_operand(i) for i in self.args]
9292

93+
@property
94+
def opargs(self) -> List[ARMOperand]:
95+
return [self.armd.arm_operand(i) for i in self.args]
96+
9397
def annotation(self, xdata: InstrXData) -> str:
9498
xd = ARMTestEquivalenceXData(xdata)
9599
if xd.is_ok:

0 commit comments

Comments
 (0)