Skip to content

Commit 93b8577

Browse files
committed
CHB:ARM: handle MOV aggregates without predicate
1 parent 8b4fa19 commit 93b8577

File tree

6 files changed

+39
-22
lines changed

6 files changed

+39
-22
lines changed

CodeHawk/CHB/bchlibarm32/bCHARMAnalysisResults.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ object (self)
7777
&& (match instr#get_opcode with
7878
| Branch _ | BranchExchange _ -> false
7979
| Compare _ | CompareNegative _ -> false
80+
| Move (_, _, rd, rm, _, _) when rm#is_register ->
81+
not (rd#get_register = rm#get_register)
8082
| _ -> true)
8183
&& (Option.is_none instr#is_in_aggregate) in
8284
begin

CodeHawk/CHB/bchlibarm32/bCHARMAssemblyInstructions.ml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -573,22 +573,27 @@ object (self)
573573
end
574574

575575
method write_xml (node:xml_element_int) =
576+
let subnodes = ref [] in
576577
let bnode = ref (xmlElement "b") in
577-
self#itera
578-
(fun va instr ->
579-
if instr#is_valid_instruction then
580-
let _ =
581-
if instr#is_block_entry then
582-
begin
583-
bnode := xmlElement "b";
584-
(!bnode)#setAttribute "ba" va#to_hex_string;
585-
node#appendChildren [!bnode]
586-
end in
587-
let inode = xmlElement "i" in
588-
begin
589-
instr#write_xml inode;
590-
(!bnode)#appendChildren [inode]
591-
end)
578+
begin
579+
self#itera
580+
(fun va instr ->
581+
if instr#is_valid_instruction then
582+
let _ =
583+
if instr#is_block_entry then
584+
begin
585+
bnode := xmlElement "b";
586+
(!bnode)#setAttribute "ba" va#to_hex_string;
587+
(* node#appendChildren [!bnode] *)
588+
subnodes := !bnode :: !subnodes
589+
end in
590+
let inode = xmlElement "i" in
591+
begin
592+
instr#write_xml inode;
593+
(!bnode)#appendChildren [inode]
594+
end);
595+
node#appendChildren (List.rev !subnodes)
596+
end
592597

593598
method private not_code_to_string
594599
(datarefstr: doubleword_int -> string) (nc: not_code_t): string =

CodeHawk/CHB/bchlibarm32/bCHARMOperand.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ object (self:'a)
443443
Error [__FILE__ ^ ":" ^ (string_of_int __LINE__) ^ ": "
444444
^ "offset type "
445445
^ (arm_memory_offset_to_string offset)
446-
^ "not covered for offset address update"]
446+
^ " not covered for offset address update"]
447447
| Some inc ->
448448
TR.tmap
449449
~msg:(__FILE__ ^ ":" ^ (string_of_int __LINE__))

CodeHawk/CHB/bchlibarm32/bCHFnARMDictionary.ml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,9 +1770,11 @@ object (self)
17701770
~ok:(fun (inc, xaddr) ->
17711771
add_base_update tags args vrn_r inc (Ok xaddr))
17721772
~error:(fun e ->
1773+
let xaddr_r =
1774+
Error (e @ [__FILE__ ^ ":" ^ (string_of_int __LINE__)]) in
17731775
begin
17741776
log_dc_error_result __FILE__ __LINE__ e;
1775-
(tags, args)
1777+
add_base_update tags args vrn_r 0 xaddr_r
17761778
end)
17771779
(mem#to_updated_offset_address floc)
17781780
else
@@ -1920,7 +1922,7 @@ object (self)
19201922
let uses = [get_def_use_r vrt_r] in
19211923
let useshigh = [get_def_use_high_r vrt_r] in
19221924
let xxaddr_r = TR.tmap rewrite_expr xaddr_r in
1923-
let cxaddr_r = TR.tbind floc#xpr_to_cxpr xxaddr_r in
1925+
let cxaddr_r = TR.tbind (floc#xpr_to_cxpr ~size:(Some 2)) xxaddr_r in
19241926
let xrmem_r = TR.tmap rewrite_expr xmem_r in
19251927
let cxrmem_r =
19261928
TR.tbind (floc#xpr_to_cxpr ~size:(Some 2)) xrmem_r in
@@ -3054,9 +3056,11 @@ object (self)
30543056
~ok:(fun (inc, xaddr) ->
30553057
add_base_update tags args vrn_r inc (Ok xaddr))
30563058
~error:(fun e ->
3059+
let xaddr_r =
3060+
Error (e @ [__FILE__ ^ ":" ^ (string_of_int __LINE__)]) in
30573061
begin
30583062
log_dc_error_result __FILE__ __LINE__ e;
3059-
(tags, args)
3063+
add_base_update tags args vrn_r 0 xaddr_r
30603064
end)
30613065
(mem#to_updated_offset_address floc)
30623066
else

CodeHawk/CHB/bchlibarm32/bCHFnARMTypeConstraints.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ object (self)
501501
log_subtype_rule_disabled __LINE__ rule tctypeterm lhstypeterm)
502502
end
503503

504-
| BitwiseNot (_, _, rd, rm, _) ->
504+
| BitwiseNot (_, _, rd, rm, _) when rm#is_register->
505505
let rdreg = rd#to_register in
506506
let lhstypevar = mk_reglhs_typevar rdreg faddr iaddr in
507507
let rmdefs = get_variable_rdefs_r (rm#to_variable floc) in

CodeHawk/CHB/bchlibarm32/bCHTranslateARMToCHIF.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ let translate_arm_instruction
20592059
* APSR.N = result<31>;
20602060
* APSR.Z = IsZeroBit(result);
20612061
* ------------------------------------------------------------------------ *)
2062-
| Move _ when instr#is_aggregate_anchor ->
2062+
| Move (_, _, rd, _, _, _) when instr#is_aggregate_anchor ->
20632063
(match get_associated_test_instr finfo ctxtiaddr with
20642064
| Some (testloc, testinstr) ->
20652065
let movagg = get_aggregate loc#i in
@@ -2145,11 +2145,17 @@ let translate_arm_instruction
21452145
(BCH_failure
21462146
(LBLOCK [floc#l#toPretty; STR ": Unknown MOV aggregate kind"])))
21472147
| _ ->
2148+
(* no predicate found *)
2149+
let vrd = floc#env#mk_register_variable rd#to_register in
2150+
let lhs_r = TR.tmap fst (rd#to_lhs floc) in
2151+
let cmds = floc#get_abstract_commands_r lhs_r in
2152+
let defcmds = floc#get_vardef_commands ~defs:[vrd] ctxtiaddr in
2153+
let cmds = defcmds @ cmds in
21482154
let _ =
21492155
chlog#add
21502156
"predicate assignment aggregate without predicate"
21512157
(LBLOCK [loc#toPretty; STR ": "; instr#toPretty]) in
2152-
default [])
2158+
default cmds)
21532159

21542160
| Move _ when Option.is_some instr#is_in_aggregate ->
21552161
default []

0 commit comments

Comments
 (0)