Skip to content

Commit 6cb5517

Browse files
committed
ARM:AST: update some instructions
1 parent 5181386 commit 6cb5517

File tree

4 files changed

+28
-35
lines changed

4 files changed

+28
-35
lines changed

chb/arm/opcodes/ARMAdr.py

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# ------------------------------------------------------------------------------
55
# The MIT License (MIT)
66
#
7-
# Copyright (c) 2021-2023 Aarno Labs LLC
7+
# Copyright (c) 2021-2024 Aarno Labs LLC
88
#
99
# Permission is hereby granted, free of charge, to any person obtaining a copy
1010
# of this software and associated documentation files (the "Software"), to deal
@@ -102,10 +102,7 @@ def ast_prov(
102102

103103
annotations: List[str] = [iaddr, "ADR"]
104104

105-
lhs = xdata.vars[0]
106-
rhs = xdata.xprs[0]
107-
defuses = xdata.defuses
108-
defuseshigh = xdata.defuseshigh
105+
# low-level assignment
109106

110107
(ll_lhs, _, _) = self.operands[0].ast_lvalue(astree)
111108
(ll_rhs, _, _) = self.operands[1].ast_rvalue(astree)
@@ -117,27 +114,15 @@ def ast_prov(
117114
bytestring=bytestring,
118115
annotations=annotations)
119116

120-
lhsasts = XU.xvariable_to_ast_lvals(lhs, xdata, astree)
121-
if len(lhsasts) == 0:
122-
raise UF.CHBError("Adr: no lval found")
123-
124-
if len(lhsasts) > 1:
125-
raise UF.CHBError(
126-
"Adr: multiple lvals found: "
127-
+ ", ".join(str(v) for v in lhsasts))
128-
129-
hl_lhs = lhsasts[0]
117+
# high-level assignment
130118

131-
rhsasts = XU.xxpr_to_ast_exprs(rhs, xdata, iaddr, astree)
132-
if len(rhsasts) == 0:
133-
raise UF.CHBError("Adr: no rhs value found")
134-
135-
if len(rhsasts) > 1:
136-
raise UF.CHBError(
137-
"Adr: multiple rhs values found: "
138-
+ ", ".join(str(v) for v in rhsasts))
119+
lhs = xdata.vars[0]
120+
rhs = xdata.xprs[0]
121+
defuses = xdata.defuses
122+
defuseshigh = xdata.defuseshigh
139123

140-
hl_rhs = rhsasts[0]
124+
hl_lhs = XU.xvariable_to_ast_lval(lhs, xdata, iaddr, astree, rhs=rhs)
125+
hl_rhs = XU.xxpr_to_ast_def_expr(rhs, xdata, iaddr, astree)
141126

142127
hl_assign = astree.mk_assign(
143128
hl_lhs,
@@ -146,7 +131,6 @@ def ast_prov(
146131
bytestring=bytestring,
147132
annotations=annotations)
148133

149-
astree.add_reg_definition(iaddr, hl_lhs, hl_rhs)
150134
astree.add_instr_mapping(hl_assign, ll_assign)
151135
astree.add_instr_address(hl_assign, [iaddr])
152136
astree.add_expr_mapping(hl_rhs, ll_rhs)

chb/arm/opcodes/ARMLoadRegisterByte.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,14 @@ def ast_prov(
174174

175175
lhs = xdata.vars[0]
176176
rhs = xdata.xprs[3]
177+
xaddr = xdata.xprs[4]
177178
rdefs = xdata.reachingdefs
178179
defuses = xdata.defuses
179180
defuseshigh = xdata.defuseshigh
180181

181182
hl_lhs = XU.xvariable_to_ast_lval(lhs, xdata, iaddr, astree)
182-
183-
if rhs.is_tmp_variable or rhs.has_unknown_memory_base():
184-
xaddr = xdata.xprs[4]
185-
hl_rhs = XU.xmemory_dereference_to_ast_def_expr(
186-
xaddr, xdata, iaddr, astree)
187-
else:
188-
hl_rhs = XU.xxpr_to_ast_def_expr(rhs, xdata, iaddr, astree, size=1)
183+
hl_rhs = XU.xxpr_to_ast_def_expr(
184+
rhs, xdata, iaddr, astree, size=1, memaddr=xaddr)
189185

190186
hl_assign = astree.mk_assign(
191187
hl_lhs,

chb/arm/opcodes/ARMMove.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ def operandstring(self) -> str:
9999
return ", ".join(str(op) for op in self.operands)
100100

101101
def annotation(self, xdata: InstrXData) -> str:
102+
if xdata.is_nop:
103+
return "NOP"
104+
102105
lhs = str(xdata.vars[0])
103106
rhs = str(xdata.xprs[1])
104107
assignment = lhs + " := " + rhs
@@ -149,11 +152,21 @@ def ast_prov(
149152
xdata: InstrXData) -> Tuple[
150153
List[AST.ASTInstruction], List[AST.ASTInstruction]]:
151154

155+
annotations: List[str] = [iaddr, "MOV"]
156+
157+
if xdata.is_nop:
158+
nopinstr = astree.mk_nop_instruction(
159+
"MOV:NOP",
160+
iaddr=iaddr,
161+
bytestring=bytestring,
162+
annotations=annotations)
163+
astree.add_instr_address(nopinstr, [iaddr])
164+
165+
return ([], [nopinstr])
166+
152167
if xdata.instruction_is_subsumed():
153168
return self.ast_prov_subsumed(astree, iaddr, bytestring, xdata)
154169

155-
annotations: List[str] = [iaddr, "MOV"]
156-
157170
# low-level assignment
158171

159172
(ll_lhs, _, _) = self.opargs[0].ast_lvalue(astree)

chb/arm/opcodes/ARMNoOperation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# ------------------------------------------------------------------------------
55
# The MIT License (MIT)
66
#
7-
# Copyright (c) 2021-2023 Aarno Labs LLC
7+
# Copyright (c) 2021-2024 Aarno Labs LLC
88
#
99
# Permission is hereby granted, free of charge, to any person obtaining a copy
1010
# of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)