fix merge commit

This commit is contained in:
Mylloon 2023-12-31 18:24:55 +01:00
parent 831f470b79
commit 361d8285be
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -425,106 +425,71 @@ end
module InstructionSelector : InstructionSelector = struct
open T
open T
let R15 = `Reg X86_64_Architecture.R15 (* Registre R15 que nous utilisons pour le compilateur *)
<<<<<<< HEAD
let r15 =
(* Registre R15 que nous réservons pour le compilateur *)
`Reg X86_64_Architecture.R15
;;
let execute ~(dst : dst) f =
(* On créer une instruction f puis on créer un movq *)
Instruction (f ~dst:r15)
:: (if dst = r15 then [] else [ Instruction (movq ~src:r15 ~dst) ])
;;
let mov ~(dst : dst) ~(src : src) =
(* SI les sources sont égaux (même adresse ou même registre), on ne bouge rien*)
(* Si les sources sont égaux (même adresse ou même registre),
on ne bouge rien *)
match src, dst with
| `Reg x, `Reg y when x = y -> []
| `Addr x, `Addr y when x = y -> []
(*Si au moins un des deux est un accès mémoire, on créé une instruction movq*)
(* Si au moins un des deux est un accès mémoire,
on créé une instruction movq *)
| (`Imm _ | `Reg _), _ | _, `Reg _ -> [ Instruction (movq ~src ~dst) ]
(*Si la destination est pas un registre, on effectue une copie vers r15 puis on effectue l'instruction movq*)
(* Si la destination est pas un registre,
on effectue une copie vers r15
puis on effectue l'instruction movq *)
| _ -> execute ~dst (movq ~src)
let bin ins ~dst ~srcl ~srcr =
failwith "Students! This is your job!"
let add ~dst ~srcl ~srcr =
failwith "Students! This is your job!"
let sub ~dst ~srcl ~srcr =
move_execute imulq ~dst:dst ~srcl:srcl ~srcr:srcr
let mul ~dst ~srcl ~srcr =
move_execute imulq ~dst:dst ~srcl:srcl ~srcr:srcr
let div ~dst ~srcl ~srcr =
failwith "Students! This is your job!"
let andl ~dst ~srcl ~srcr =
failwith "Students! This is your job!"
let orl ~dst ~srcl ~srcr =
failwith "Students! This is your job!"
let conditional_jump ~cc ~srcl ~srcr ~ll ~lr =
failwith "Students! This is your job!"
let switch ?default ~discriminant ~cases () =
failwith "Students! This is your job!"
let execute ~(dst : dst) f = (* On créer une instruction f puis on créer un movq *)
Instruction (f ~dst:r15) :: (if dst = r15 [] else [Instruction (movq ~src:r15 ~dst)])
;;
let move_execute f ~dst ~srcl ~srcr =
mov ~src:srcr ~dst:r15
@ (execute ~dst (f ~src:srcl))
=======
let mov ~(dst : dst) ~(src : src) =
(* TODO *)
failwith "Students! This is your job! (mov)"
mov ~src:srcr ~dst:r15 @ execute ~dst (f ~src:srcl)
;;
let bin ins ~dst ~srcl ~srcr =
(* TODO *)
failwith "Students! This is your job! (bin)"
failwith "Students! This is your job!"
;;
let add ~dst ~srcl ~srcr =
(* TODO *)
failwith "Students! This is your job! (add)"
failwith "Students! This is your job!"
;;
let sub ~dst ~srcl ~srcr =
(* TODO *)
failwith "Students! This is your job! (sub)"
;;
let mul ~dst ~srcl ~srcr =
(* TODO *)
failwith "Students! This is your job! (mul)"
;;
let sub ~dst ~srcl ~srcr = move_execute imulq ~dst ~srcl ~srcr
let mul ~dst ~srcl ~srcr = move_execute imulq ~dst ~srcl ~srcr
let div ~dst ~srcl ~srcr =
(* TODO *)
failwith "Students! This is your job! (div)"
failwith "Students! This is your job!"
;;
let andl ~dst ~srcl ~srcr =
(* TODO *)
failwith "Students! This is your job! (andl)"
;;
let andl ~dst ~srcl ~srcr = failwith "Students! This is your job!"
let orl ~dst ~srcl ~srcr =
(* TODO *)
failwith "Students! This is your job! (orl)"
failwith "Students! This is your job!"
;;
let conditional_jump ~cc ~srcl ~srcr ~ll ~lr =
(* TODO *)
failwith "Students! This is your job! (conditional_jump)"
failwith "Students! This is your job!"
;;
let switch ?default ~discriminant ~cases () =
(* TODO *)
failwith "Students! This is your job! (switch)"
failwith "Students! This is your job!"
;;
>>>>>>> ac93861c63fb639c260e046373135aea113d7a9c
end
module FrameManager (IS : InstructionSelector) : FrameManager = struct