Skip to content

Commit b4d8651

Browse files
committed
CHB:ARM:add c expressions to instruction predicate
1 parent 4471615 commit b4d8651

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

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_20250608"
99-
~date:"2025-06-08"
98+
~version:"0.6.0_20250623"
99+
~date:"2025-06-23"
100100
~licensee: None
101101
~maxfilesize: None
102102
()

CodeHawk/CHB/bchlibarm32/bCHARMInstructionAggregate.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ object (self)
149149
STR "Aggregate of ";
150150
INT (List.length self#instrs);
151151
STR " with anchor ";
152+
self#anchor#get_address#toPretty;
153+
STR " ";
152154
self#anchor#toPretty;
153155
STR ": ";
154156
STR (arm_aggregate_kind_to_string self#kind)]

CodeHawk/CHB/bchlibarm32/bCHFnARMDictionary.ml

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -233,24 +233,6 @@ object (self)
233233
else
234234
xpr in
235235
simplify_xpr xpr in
236-
let add_instr_condition
237-
(tags: string list)
238-
(args: int list)
239-
(x: xpr_t): (string list) * (int list) =
240-
let _ =
241-
if (List.length tags) = 0 then
242-
raise
243-
(BCH_failure
244-
(LBLOCK [STR "Empty tag list in add_instr_condition"])) in
245-
let argslen = List.length args in
246-
let xtag = (List.hd tags) ^ "xx" in
247-
let ictag = "ic:" ^ (string_of_int argslen) in
248-
let icrtag = "icr:" ^ (string_of_int (argslen + 1)) in
249-
let tags = xtag :: ((List.tl tags) @ [ictag; icrtag]) in
250-
let xneg = XOp (XLNot, [x]) in
251-
let xneg = simplify_xpr xneg in
252-
let args = args @ [xd#index_xpr x; xd#index_xpr xneg] in
253-
(tags, args) in
254236

255237
let flagrdefs: int list =
256238
let flags_used = get_arm_flags_used instr#get_opcode in
@@ -552,8 +534,29 @@ object (self)
552534
| _ when instr#is_condition_covered -> ([tagstring], args)
553535
| c when is_cond_conditional c && floc#has_test_expr ->
554536
let csetter = floc#f#get_associated_cc_setter floc#cia in
555-
let tcond = rewrite_test_expr csetter floc#get_test_expr in
556-
add_instr_condition [tagstring] args tcond
537+
let txpr = floc#get_test_expr in
538+
let fxpr = simplify_xpr (XOp (XLNot, [txpr])) in
539+
let tcond = rewrite_test_expr csetter txpr in
540+
let fcond = rewrite_test_expr csetter fxpr in
541+
let ctcond_r = floc#convert_xpr_to_c_expr ~size:(Some 4) tcond in
542+
let cfcond_r = floc#convert_xpr_to_c_expr ~size:(Some 4) fcond in
543+
let rdefs = (get_all_rdefs txpr) @ (get_all_rdefs tcond) in
544+
let argslen = List.length args in
545+
let xtag = "xxcc" ^ (string_repeat "r" (List.length rdefs)) in
546+
let xtag = tagstring ^ xtag in
547+
let newargs = [
548+
index_xpr (Ok tcond);
549+
index_xpr (Ok fcond);
550+
index_xpr ctcond_r;
551+
index_xpr cfcond_r
552+
] @ rdefs in
553+
let ictag = "ic:" ^ (string_of_int argslen) in
554+
let icrtag = "icr:" ^ (string_of_int (argslen + 1)) in
555+
let icctag = "icc:" ^ (string_of_int (argslen + 2)) in
556+
let iccrtag = "iccr:" ^ (string_of_int (argslen + 3)) in
557+
let tags = xtag :: [ictag; icrtag; icctag; iccrtag] in
558+
let args = args @ newargs in
559+
(tags, args)
557560
| _ -> (tagstring :: ["uc"], args) in
558561

559562
let add_optional_subsumption (tags: string list): string list =

0 commit comments

Comments
 (0)