fix merge commit
This commit is contained in:
parent
831f470b79
commit
361d8285be
1 changed files with 34 additions and 69 deletions
|
@ -425,106 +425,71 @@ end
|
||||||
|
|
||||||
module InstructionSelector : InstructionSelector = struct
|
module InstructionSelector : InstructionSelector = struct
|
||||||
open T
|
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) =
|
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
|
match src, dst with
|
||||||
| `Reg x, `Reg y when x = y -> []
|
| `Reg x, `Reg y when x = y -> []
|
||||||
| `Addr x, `Addr 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,
|
||||||
| (`Imm _ | `Reg _), _ | _, `Reg _-> [Instruction (movq ~src ~dst)]
|
on créé une instruction movq *)
|
||||||
(*Si la destination est pas un registre, on effectue une copie vers r15 puis on effectue l'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 *)
|
||||||
| _ -> execute ~dst (movq ~src)
|
| _ -> 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 =
|
let move_execute f ~dst ~srcl ~srcr =
|
||||||
mov ~src:srcr ~dst:r15
|
mov ~src:srcr ~dst:r15 @ execute ~dst (f ~src:srcl)
|
||||||
@ (execute ~dst (f ~src:srcl))
|
|
||||||
=======
|
|
||||||
let mov ~(dst : dst) ~(src : src) =
|
|
||||||
(* TODO *)
|
|
||||||
failwith "Students! This is your job! (mov)"
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let bin ins ~dst ~srcl ~srcr =
|
let bin ins ~dst ~srcl ~srcr =
|
||||||
(* TODO *)
|
(* TODO *)
|
||||||
failwith "Students! This is your job! (bin)"
|
failwith "Students! This is your job!"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let add ~dst ~srcl ~srcr =
|
let add ~dst ~srcl ~srcr =
|
||||||
(* TODO *)
|
(* TODO *)
|
||||||
failwith "Students! This is your job! (add)"
|
failwith "Students! This is your job!"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let sub ~dst ~srcl ~srcr =
|
let sub ~dst ~srcl ~srcr = move_execute imulq ~dst ~srcl ~srcr
|
||||||
(* TODO *)
|
let mul ~dst ~srcl ~srcr = move_execute imulq ~dst ~srcl ~srcr
|
||||||
failwith "Students! This is your job! (sub)"
|
|
||||||
;;
|
|
||||||
|
|
||||||
let mul ~dst ~srcl ~srcr =
|
|
||||||
(* TODO *)
|
|
||||||
failwith "Students! This is your job! (mul)"
|
|
||||||
;;
|
|
||||||
|
|
||||||
let div ~dst ~srcl ~srcr =
|
let div ~dst ~srcl ~srcr =
|
||||||
(* TODO *)
|
(* TODO *)
|
||||||
failwith "Students! This is your job! (div)"
|
failwith "Students! This is your job!"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let andl ~dst ~srcl ~srcr =
|
let andl ~dst ~srcl ~srcr = failwith "Students! This is your job!"
|
||||||
(* TODO *)
|
|
||||||
failwith "Students! This is your job! (andl)"
|
|
||||||
;;
|
|
||||||
|
|
||||||
let orl ~dst ~srcl ~srcr =
|
let orl ~dst ~srcl ~srcr =
|
||||||
(* TODO *)
|
(* TODO *)
|
||||||
failwith "Students! This is your job! (orl)"
|
failwith "Students! This is your job!"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let conditional_jump ~cc ~srcl ~srcr ~ll ~lr =
|
let conditional_jump ~cc ~srcl ~srcr ~ll ~lr =
|
||||||
(* TODO *)
|
(* TODO *)
|
||||||
failwith "Students! This is your job! (conditional_jump)"
|
failwith "Students! This is your job!"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let switch ?default ~discriminant ~cases () =
|
let switch ?default ~discriminant ~cases () =
|
||||||
(* TODO *)
|
(* TODO *)
|
||||||
failwith "Students! This is your job! (switch)"
|
failwith "Students! This is your job!"
|
||||||
;;
|
;;
|
||||||
>>>>>>> ac93861c63fb639c260e046373135aea113d7a9c
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module FrameManager (IS : InstructionSelector) : FrameManager = struct
|
module FrameManager (IS : InstructionSelector) : FrameManager = struct
|
||||||
|
|
Reference in a new issue