-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Quick compilation fix * Simplification of the encoding for the permissions * Merge branch 'main' into directed-caps * Refactoring encoding * Merge branch 'main' into directed-caps: normalization * Merge branch 'directed-caps' into bastien/compiler
- Loading branch information
Showing
52 changed files
with
8,219 additions
and
5,548 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
open Convert | ||
open Extract | ||
|
||
let rec pp_of_instrs l = | ||
match l with | ||
| [] -> Printf.printf "" | ||
| i::l' -> | ||
Printf.printf "%s\n%!" (Pretty_printer.string_of_machine_op (Convert.translate_instr i)); | ||
pp_of_instrs l' | ||
|
||
let pp_sealable (sb : Ast.sealable) = | ||
match sb with | ||
| Cap (p, g, b, e, a) -> | ||
Printf.sprintf "(%s, %s, %s, %s, %s)" (Pretty_printer.string_of_perm p) | ||
(Pretty_printer.string_of_locality g) | ||
(Big_int_Z.string_of_big_int b) | ||
(Big_int_Z.string_of_big_int e) | ||
(Big_int_Z.string_of_big_int a) | ||
| SealRange (p, g, b, e, a) -> | ||
Printf.sprintf "[%s, %s, %s, %s, %s]" (Pretty_printer.string_of_seal_perm p) | ||
(Pretty_printer.string_of_locality g) | ||
(Big_int_Z.string_of_big_int b) | ||
(Big_int_Z.string_of_big_int e) | ||
(Big_int_Z.string_of_big_int a) | ||
|
||
let pp_word_reg (w : Ast.word) | ||
= match w with | ||
| I z -> Printf.sprintf "%s" (Big_int_Z.string_of_big_int z) | ||
| Sealable sb -> pp_sealable sb | ||
| Sealed (ot, sb) -> Printf.sprintf "{%s: %s}" (Big_int_Z.string_of_big_int ot) (pp_sealable sb) | ||
|
||
let pp_word_asm (w : Ast.word) | ||
= match w with | ||
| I z -> (Pretty_printer.string_of_machine_op (Convert.translate_instr (Convert.machine_param.decodeInstr z))) | ||
| Sealable sb -> Printf.sprintf "#%s" (pp_sealable sb) | ||
| Sealed (ot, sb) -> Printf.sprintf "#{%s: %s}" (Big_int_Z.string_of_big_int ot) (pp_sealable sb) | ||
|
||
let pp_regname (r : Extract.regName) = | ||
match r with | ||
| PC -> "PC" | ||
| STK -> "stk" | ||
| R n -> Printf.sprintf "r%s" (Big_int_Z.string_of_big_int n) | ||
|
||
let machine_compile | ||
?(addr_max = (Int32.to_int Int32.max_int)/4096 ) | ||
?(start_stack = Big_int_Z.big_int_of_int (addr_max/2) ) | ||
?(end_stack = Big_int_Z.big_int_of_int addr_max) | ||
program | ||
: (regName * Ast.word) list * (addr * Ast.word) list | ||
= | ||
let (regs, compiled_prog) = program Convert.machine_param start_stack end_stack in | ||
let prog = | ||
List.map | ||
(fun w -> (fst w, Convert.translate_word (snd w))) | ||
compiled_prog | ||
in | ||
let regs = | ||
List.map | ||
(fun w -> (fst w, Convert.translate_word (snd w))) | ||
regs | ||
in | ||
(regs, prog) | ||
|
||
let output_machine regfile_output_name asm_output_name regs prog = | ||
let oc = open_out regfile_output_name in | ||
List.iter (fun w -> Printf.fprintf oc "%s := %s\n" (pp_regname (fst w)) | ||
(pp_word_reg (snd w))) regs; | ||
close_out oc; | ||
let oc = open_out asm_output_name in | ||
List.iter (fun w -> Printf.fprintf oc "%s\n" (pp_word_asm (snd w))) prog; | ||
close_out oc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.