ajout mov mul et sub
This commit is contained in:
parent
07a65e7bcb
commit
d59d579df9
1 changed files with 47 additions and 10 deletions
|
@ -425,17 +425,54 @@ 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 *)
|
||||||
|
|
||||||
let mov ~(dst : dst) ~(src : src) = failwith "Students! This is your job!"
|
let mov ~(dst : dst) ~(src : src) =
|
||||||
let bin ins ~dst ~srcl ~srcr = failwith "Students! This is your job!"
|
(* SI les sources sont égaux (même adresse ou même registre), on ne bouge rien*)
|
||||||
let add ~dst ~srcl ~srcr = failwith "Students! This is your job!"
|
match src, dst with
|
||||||
let sub ~dst ~srcl ~srcr = failwith "Students! This is your job!"
|
| `Reg x, `Reg y when x = y -> []
|
||||||
let mul ~dst ~srcl ~srcr = failwith "Students! This is your job!"
|
| `Addr x, `Addr y when x = y -> []
|
||||||
let div ~dst ~srcl ~srcr = failwith "Students! This is your job!"
|
(*Si au moins un des deux est un accès mémoire, on créé une instruction movq*)
|
||||||
let andl ~dst ~srcl ~srcr = failwith "Students! This is your job!"
|
| (`Imm _ | `Reg _), _ | _, `Reg _-> [Instruction (movq ~src ~dst)]
|
||||||
let orl ~dst ~srcl ~srcr = failwith "Students! This is your job!"
|
(*Si la destination est pas un registre, on effectue une copie vers r15 puis on effectue l'instruction movq*)
|
||||||
let conditional_jump ~cc ~srcl ~srcr ~ll ~lr = failwith "Students! This is your job!"
|
| _ -> execute ~dst (movq ~src)
|
||||||
let switch ?default ~discriminant ~cases () = failwith "Students! This is your job!"
|
|
||||||
|
|
||||||
|
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))
|
||||||
end
|
end
|
||||||
|
|
||||||
module FrameManager (IS : InstructionSelector) : FrameManager = struct
|
module FrameManager (IS : InstructionSelector) : FrameManager = struct
|
||||||
|
|
Reference in a new issue