aboutsummaryrefslogtreecommitdiffstats
path: root/mppa_k1c/DuplicateOpcodeHeuristic.ml
diff options
context:
space:
mode:
Diffstat (limited to 'mppa_k1c/DuplicateOpcodeHeuristic.ml')
-rw-r--r--mppa_k1c/DuplicateOpcodeHeuristic.ml32
1 files changed, 32 insertions, 0 deletions
diff --git a/mppa_k1c/DuplicateOpcodeHeuristic.ml b/mppa_k1c/DuplicateOpcodeHeuristic.ml
new file mode 100644
index 00000000..690553ce
--- /dev/null
+++ b/mppa_k1c/DuplicateOpcodeHeuristic.ml
@@ -0,0 +1,32 @@
+(* open Camlcoq *)
+open Op
+open Integers
+
+exception HeuristicSucceeded
+
+let opcode_heuristic code cond ifso ifnot preferred =
+ let decision = match cond with
+ | Ccompimm (c, n) | Ccompuimm (c, n) -> if n == Integers.Int.zero then (match c with
+ | Clt | Cle -> Some false
+ | Cgt | Cge -> Some true
+ | _ -> None
+ ) else None
+ | Ccomplimm (c, n) | Ccompluimm (c, n) -> if n == Integers.Int64.zero then (match c with
+ | Clt | Cle -> Some false
+ | Cgt | Cge -> Some true
+ | _ -> None
+ ) else None
+ | Ccompf c | Ccompfs c -> (match c with
+ | Ceq -> Some false
+ | Cne -> Some true
+ | _ -> None
+ )
+ | Cnotcompf c | Cnotcompfs c -> (match c with
+ | Ceq -> Some true
+ | Cne -> Some false
+ | _ -> None
+ )
+ | _ -> None
+ in match decision with
+ | Some b -> (preferred := b; raise HeuristicSucceeded)
+ | None -> ()