Skip to content

Commit c37cbb5

Browse files
committed
CHB: add scaled expression term arrangement
1 parent 332be20 commit c37cbb5

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

CodeHawk/CHB/bchlib/bCHFunctionStackframe.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ object (self)
578578
let ty = match typ with Some t -> t | _ -> t_unknown in
579579
let blread = StackBlockRead (offset, size, ty) in
580580
let ssrec = {
581-
sslot_name = "blockread";
581+
sslot_name = "localvar_" ^ (string_of_int (-offset));
582582
sslot_offset = offset;
583583
sslot_btype = ty;
584584
sslot_size = size;

CodeHawk/CHB/bchlib/bCHGlobalMemoryMap.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@ object (self)
440440
match optindex with
441441
| None ->
442442
Error [__FILE__ ^ ":" ^ (string_of_int __LINE__) ^ ": "
443-
^ "Unable to extract index from " ^ (x2s xoffset)]
443+
^ "Unable to extract index from " ^ (x2s xoffset)
444+
^ " with element size " ^ (string_of_int elsize)]
444445
| Some (indexxpr, xrem) when
445446
iszero xrem
446447
&& Option.is_none tgtsize

CodeHawk/CHB/bchlib/bCHVersion.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ end
9595

9696

9797
let version = new version_info_t
98-
~version:"0.6.0_20251021"
99-
~date:"2025-10-21"
98+
~version:"0.6.0_20251022"
99+
~date:"2025-10-22"
100100
~licensee: None
101101
~maxfilesize: None
102102
()

CodeHawk/CHB/bchlib/bCHXprUtil.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ let get_array_index_offset (xpr: xpr_t) (size: int): (xpr_t * xpr_t) option =
127127
when n#equal numsize ->
128128
Some (XVar v, xzero)
129129
| XOp (XPlus, [XOp (XMult, [XConst (IntConst n1); XVar v]);
130-
XConst (IntConst n2)]) when n1#equal numsize ->
130+
XConst (IntConst n2)])
131+
| XOp (XPlus, [XConst (IntConst n2);
132+
XOp (XMult, [XConst (IntConst n1); XVar v])])
133+
when n1#equal numsize ->
131134
if n2#equal numerical_zero then
132135
Some (XVar v, xzero)
133136
else
@@ -136,7 +139,10 @@ let get_array_index_offset (xpr: xpr_t) (size: int): (xpr_t * xpr_t) option =
136139
if quo#equal numerical_zero then
137140
Some (XVar v, xrem)
138141
else
139-
Some (XOp (XPlus, [XVar v; num_constant_expr quo]), xrem)
142+
if quo#lt numerical_zero then
143+
Some (XOp (XMinus, [XVar v; num_constant_expr quo#neg]), xrem)
144+
else
145+
Some (XOp (XPlus, [XVar v; num_constant_expr quo]), xrem)
140146
| XOp (XMinus, [XOp (XMult, [XConst (IntConst n1); XVar v]);
141147
XConst (IntConst n2)]) when n1#equal numsize ->
142148
if n2#equal numerical_zero then

0 commit comments

Comments
 (0)