44 ------------------------------------------------------------------------------
55 The MIT License (MIT)
66
7- Copyright (c) 2021-2024 Aarno Labs LLC
7+ Copyright (c) 2021-2025 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
@@ -37,6 +37,21 @@ open BCHLibTypes
3737(* bchlibarm32 *)
3838open BCHARMTypes
3939
40+
41+ (* * Returns the predicate condition and associated info for a condidional,
42+ in particular it returns a tuple consisting of:
43+ - a list of temporary variables created to preserve the (frozen) values at
44+ the test location (testloc) for the location of the conditional (condloc)
45+ - the predicate that expresses the joint condition of test and condition
46+ code (cc, e.g., EQ), and
47+ - a list of the operands used in the creation of the predicate.
48+
49+ The arguments to the function are:
50+ - [condopc]: the opcode of the conditional instruction (e.g., Branch)
51+ - [testopc]: the opcode of the test instruction (e.g., Compare)
52+ - [condloc]: the location of conditional instruction
53+ - [testloc]: the location of the test instruction.
54+ *)
4055val arm_conditional_expr :
4156 condopc : arm_opcode_t
4257 -> testopc :arm_opcode_t
@@ -45,6 +60,34 @@ val arm_conditional_expr:
4560 -> (variable_t list * xpr_t option * arm_operand_int list )
4661
4762
63+ (* * Returns the predicate condition and associated info as above for a composite
64+ condtitional of the form
65+ {v
66+ I1: <test1> CMP x, #0
67+ I2: <test2-cc1> CMPEQ y, z
68+ I3: <cond-cc2> BGT
69+ v}
70+ where the ultimate predicate condition depends is a composite of potentially
71+ three test - cc combinations:
72+ - if test1-cc1 is true, I2 is executed and the branch predicate is test2-cc2
73+ - if test2-cc1 is false I2 is not executed and branch predicate is test2-cc1
74+ leading to the composite expression
75+ {v
76+ (test1-cc1 /\ test2-cc2) \/ ((not test1-cc1) /\ test1-cc2)
77+ v}
78+ or, in the case of the example above:
79+ {v
80+ (x = 0 /\ y > z) \/ (x != 0 /\ x > 0)
81+ or
82+ (x = 0 /\ y > z) \/ (x > 0)
83+ v}
84+ - [condopc]: the opcode of the conditional instruction (above: BGT)
85+ - [testopc] the opcode of the second test instruction (above: CMPEQ)
86+ - [testtestopc]: the opcode of the first test instruction (above: CMP)
87+ - [condloc]: the location of [condopc]
88+ - [testloc]: the location of [testopc]
89+ - [testtestloc]: the location of [testtestopc]
90+ *)
4891val arm_conditional_conditional_expr :
4992 condopc : arm_opcode_t
5093 -> testopc : arm_opcode_t
0 commit comments