merge conflict truc la

This commit is contained in:
Nicolas PENELOUX 2023-12-31 17:00:54 +01:00
commit 831f470b79
10 changed files with 206 additions and 5 deletions

View file

@ -0,0 +1,3 @@
globals ()
exit;
end

View file

@ -0,0 +1,24 @@
globals (x, y, z, k)
x <- copy 6;
%rdi <- copy x;
print_int();
%rdi <- copy " ";
print_string();
y <- copy 7;
%rdi <- copy y;
print_int();
%rdi <- copy " ";
print_string();
z <- mul y, x;
%rdi <- copy z;
print_int();
%rdi <- copy " ";
print_string();
k <- sub z, x;
%rdi <- copy k;
print_int();
end

View file

@ -0,0 +1,17 @@
globals (res)
local compteur:
compteur <- copy 5;
res <- copy 1;
condition:
jumpif lte compteur, 1 -> fin, boucle;
boucle:
res <- mul res, compteur;
compteur <- sub compteur, 1;
jump condition;
fin:
%rdi <- copy res;
print_int();
end

View file

@ -0,0 +1,4 @@
globals ()
%rdi <- copy 42;
observe_int();
end

View file

@ -0,0 +1,12 @@
globals ()
%rdi <- copy 1;
%rsi <- copy 2;
%rdx <- copy 3;
%rcx <- copy 4;
%r8 <- copy 5;
%r9 <- copy 6;
add_eight_int(7, 8);
%rdi <- copy %rax;
observe_int();
end

View file

@ -0,0 +1,25 @@
def fact ()
%rax <- copy 1;
condition:
jumpif lte %rdi, 1 -> fin, boucle;
boucle:
%rax <- mul %rax, %rdi;
%rdi <- sub %rdi, 1;
jump condition;
fin:
ret;
end
globals (x)
x <- copy 5;
%rdi <- copy x;
fact();
x <- copy %rax;
%rdi <- copy x;
observe_int();
end

View file

@ -0,0 +1,26 @@
def fact ()
local x:
jumpif lte %rdi, 1 -> fini, rec;
fini:
%rax <- copy 1;
ret;
rec:
x <- copy %rdi;
%rdi <- sub %rdi, 1;
fact();
%rax <- mul %rax, x;
ret;
end
globals (x)
x <- copy 5;
%rdi <- copy x;
fact();
x <- copy %rax;
%rdi <- copy x;
observe_int();
end

View file

@ -0,0 +1,23 @@
def my_add_eight_int (i7, i8)
%rax <- add %rdi, %rsi;
%rax <- add %rax, %rdx;
%rax <- add %rax, %rcx;
%rax <- add %rax, %r8;
%rax <- add %rax, %r9;
%rax <- add %rax, i7;
%rax <- add %rax, i8;
ret;
end
globals ()
%rdi <- copy 1;
%rsi <- copy 2;
%rdx <- copy 3;
%rcx <- copy 4;
%r8 <- copy 5;
%r9 <- copy 6;
my_add_eight_int(7, 8);
%rdi <- copy %rax;
observe_int();
end

View file

@ -0,0 +1,9 @@
FLAP = ../../_build/default/src/flap.exe
TARGET = retrolix
main:
@for f in $(wildcard *.$(TARGET)); do \
printf "%s: " $$f; \
./$(FLAP) -s $(TARGET) -d true -r true $$f; \
printf "\n"; \
done

View file

@ -428,6 +428,7 @@ module InstructionSelector : InstructionSelector = struct
open T
let R15 = `Reg X86_64_Architecture.R15 (* Registre R15 que nous utilisons pour le compilateur *)
<<<<<<< HEAD
let mov ~(dst : dst) ~(src : src) =
(* SI les sources sont égaux (même adresse ou même registre), on ne bouge rien*)
match src, dst with
@ -473,6 +474,57 @@ open T
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)"
;;
let bin ins ~dst ~srcl ~srcr =
(* TODO *)
failwith "Students! This is your job! (bin)"
;;
let add ~dst ~srcl ~srcr =
(* TODO *)
failwith "Students! This is your job! (add)"
;;
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 div ~dst ~srcl ~srcr =
(* TODO *)
failwith "Students! This is your job! (div)"
;;
let andl ~dst ~srcl ~srcr =
(* TODO *)
failwith "Students! This is your job! (andl)"
;;
let orl ~dst ~srcl ~srcr =
(* TODO *)
failwith "Students! This is your job! (orl)"
;;
let conditional_jump ~cc ~srcl ~srcr ~ll ~lr =
(* TODO *)
failwith "Students! This is your job! (conditional_jump)"
;;
let switch ?default ~discriminant ~cases () =
(* TODO *)
failwith "Students! This is your job! (switch)"
;;
>>>>>>> ac93861c63fb639c260e046373135aea113d7a9c
end
module FrameManager (IS : InstructionSelector) : FrameManager = struct
@ -498,23 +550,29 @@ module FrameManager (IS : InstructionSelector) : FrameManager = struct
;;
let frame_descriptor ~params ~locals =
(* Student! Implement me! *)
(* TODO: Student! Implement me! *)
{ param_count = 0; locals_space = 0; stack_map = S.IdMap.empty }
;;
let location_of fd id = failwith "Students! This is your job!"
let location_of fd id =
(* TODO *)
failwith "Students! This is your job! (location_of)"
;;
let function_prologue fd =
(* Student! Implement me! *)
(* TODO: Student! Implement me! *)
[]
;;
let function_epilogue fd =
(* Student! Implement me! *)
(* TODO: Student! Implement me! *)
[]
;;
let call fd ~kind ~f ~args = failwith "Students! This is your job!"
let call fd ~kind ~f ~args =
(* TODO *)
failwith "Students! This is your job! (call)"
;;
end
module CG = Codegen (InstructionSelector) (FrameManager (InstructionSelector))