Commit 9882b342 authored by Léo Gourdin's avatar Léo Gourdin
Browse files

some simplification in miniCSE

parent c19ecc93
......@@ -46,13 +46,10 @@ let n2pi () =
type immt = Xoriw | Xoril | Sltiw | Sltiuw | Sltil | Sltiul
let debug_was_cse = ref false
let find_or_addnmove op args rd succ sargs map_consts =
let sop = Sop (op, sargs) in
let find_or_addnmove op args rd succ map_consts =
let sop = Sop (op, args) in
match Hashtbl.find_opt map_consts sop with
| Some r ->
debug_was_cse := true;
Sr (P.of_int r)
| None ->
Hashtbl.add map_consts sop (p2i rd);
......@@ -64,40 +61,40 @@ let build_head_tuple head sv =
let load_hilo32 dest hi lo succ map_consts =
let op1 = OEluiw hi in
if Int.eq lo Int.zero then
let sv = find_or_addnmove op1 [] dest succ [] map_consts in
let sv = find_or_addnmove op1 [] dest succ map_consts in
build_head_tuple [] sv
else
let r = r2pi () in
let op2 = Oaddimm lo in
match find_or_addnmove op1 [] r (n2pi ()) [] map_consts with
match find_or_addnmove op1 [] r (n2pi ()) map_consts with
| Si i ->
let sv = find_or_addnmove op2 [ r ] dest succ [ r ] map_consts in
let sv = find_or_addnmove op2 [ r ] dest succ map_consts in
build_head_tuple [ i ] sv
| Sr r' ->
let sv = find_or_addnmove op2 [ r' ] dest succ [ r' ] map_consts in
let sv = find_or_addnmove op2 [ r' ] dest succ map_consts in
build_head_tuple [] sv
let load_hilo64 dest hi lo succ map_consts =
let op1 = OEluil hi in
if Int64.eq lo Int64.zero then
let sv = find_or_addnmove op1 [] dest succ [] map_consts in
let sv = find_or_addnmove op1 [] dest succ map_consts in
build_head_tuple [] sv
else
let r = r2pi () in
let op2 = Oaddlimm lo in
match find_or_addnmove op1 [] r (n2pi ()) [] map_consts with
match find_or_addnmove op1 [] r (n2pi ()) map_consts with
| Si i ->
let sv = find_or_addnmove op2 [ r ] dest succ [ r ] map_consts in
let sv = find_or_addnmove op2 [ r ] dest succ map_consts in
build_head_tuple [ i ] sv
| Sr r' ->
let sv = find_or_addnmove op2 [ r' ] dest succ [ r' ] map_consts in
let sv = find_or_addnmove op2 [ r' ] dest succ map_consts in
build_head_tuple [] sv
let loadimm32 dest n succ map_consts =
match make_immed32 n with
| Imm32_single imm ->
let op1 = OEaddiwr0 imm in
let sv = find_or_addnmove op1 [] dest succ [] map_consts in
let sv = find_or_addnmove op1 [] dest succ map_consts in
build_head_tuple [] sv
| Imm32_pair (hi, lo) -> load_hilo32 dest hi lo succ map_consts
......@@ -105,12 +102,12 @@ let loadimm64 dest n succ map_consts =
match make_immed64 n with
| Imm64_single imm ->
let op1 = OEaddilr0 imm in
let sv = find_or_addnmove op1 [] dest succ [] map_consts in
let sv = find_or_addnmove op1 [] dest succ map_consts in
build_head_tuple [] sv
| Imm64_pair (hi, lo) -> load_hilo64 dest hi lo succ map_consts
| Imm64_large imm ->
let op1 = OEloadli imm in
let sv = find_or_addnmove op1 [] dest succ [] map_consts in
let sv = find_or_addnmove op1 [] dest succ map_consts in
build_head_tuple [] sv
let get_opimm imm = function
......@@ -144,7 +141,7 @@ let opimm64 a1 dest n succ k op opimm map_consts =
let r = r2pi () in
let op1 = OEloadli imm in
let inode = n2pi () in
let sv = find_or_addnmove op1 [] r inode [] map_consts in
let sv = find_or_addnmove op1 [] r inode map_consts in
let ht = build_head_tuple [] sv in
let r' = unzip_head_tuple ht r in
fst ht @ Iop (op, [ a1; r' ], dest, succ) :: k
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment