From 4ee0cedff7726a56ebd53125995a7ae131660b4a Mon Sep 17 00:00:00 2001 From: Gaëtan Gilbert Date: Tue, 18 Aug 2020 13:07:54 +0200 Subject: Rename VM-related kernel/cfoo files to kernel/vmfoo --- kernel/vmbytecodes.ml | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 kernel/vmbytecodes.ml (limited to 'kernel/vmbytecodes.ml') diff --git a/kernel/vmbytecodes.ml b/kernel/vmbytecodes.ml new file mode 100644 index 0000000000..74405a0105 --- /dev/null +++ b/kernel/vmbytecodes.ml @@ -0,0 +1,166 @@ +(************************************************************************) +(* * The Coq Proof Assistant / The Coq Development Team *) +(* v * Copyright INRIA, CNRS and contributors *) +(* str "FVnamed(" ++ Id.print id ++ str ")" + | FVrel i -> str "Rel(" ++ int i ++ str ")" + | FVuniv_var v -> str "FVuniv(" ++ int v ++ str ")" + | FVevar e -> str "FVevar(" ++ int (Evar.repr e) ++ str ")" + +let rec pp_instr i = + match i with + | Klabel _ | Ksequence _ -> assert false + | Kacc n -> str "acc " ++ int n + | Kenvacc n -> str "envacc " ++ int n + | Koffsetclosure n -> str "offsetclosure " ++ int n + | Kpush -> str "push" + | Kpop n -> str "pop " ++ int n + | Kpush_retaddr lbl -> str "push_retaddr " ++ pp_lbl lbl + | Kapply n -> str "apply " ++ int n + | Kappterm(n, m) -> + str "appterm " ++ int n ++ str ", " ++ int m + | Kreturn n -> str "return " ++ int n + | Kjump -> str "jump" + | Krestart -> str "restart" + | Kgrab n -> str "grab " ++ int n + | Kgrabrec n -> str "grabrec " ++ int n + | Kclosure(lbl, n) -> + str "closure " ++ pp_lbl lbl ++ str ", " ++ int n + | Kclosurerec(fv,init,lblt,lblb) -> + h 1 (str "closurerec " ++ + int fv ++ str ", " ++ int init ++ + str " types = " ++ + prlist_with_sep spc pp_lbl (Array.to_list lblt) ++ + str " bodies = " ++ + prlist_with_sep spc pp_lbl (Array.to_list lblb)) + | Kclosurecofix (fv,init,lblt,lblb) -> + h 1 (str "closurecofix " ++ + int fv ++ str ", " ++ int init ++ + str " types = " ++ + prlist_with_sep spc pp_lbl (Array.to_list lblt) ++ + str " bodies = " ++ + prlist_with_sep spc pp_lbl (Array.to_list lblb)) + | Kgetglobal idu -> str "getglobal " ++ Constant.print idu + | Kconst sc -> + str "const " ++ pp_struct_const sc + | Kmakeblock(n, m) -> + str "makeblock " ++ int n ++ str ", " ++ int m + | Kmakeprod -> str "makeprod" + | Kmakeswitchblock(lblt,lbls,_,sz) -> + str "makeswitchblock " ++ pp_lbl lblt ++ str ", " ++ + pp_lbl lbls ++ str ", " ++ int sz + | Kswitch(lblc,lblb) -> + h 1 (str "switch " ++ + prlist_with_sep spc pp_lbl (Array.to_list lblc) ++ + str " | " ++ + prlist_with_sep spc pp_lbl (Array.to_list lblb)) + | Kpushfields n -> str "pushfields " ++ int n + | Kfield n -> str "field " ++ int n + | Ksetfield n -> str "setfield " ++ int n + + | Kstop -> str "stop" + + | Kbranch lbl -> str "branch " ++ pp_lbl lbl + + | Kproj p -> str "proj " ++ Projection.Repr.print p + + | Kensurestackcapacity size -> str "growstack " ++ int size + + | Kprim (op, id) -> str (CPrimitives.to_string op) ++ str " " ++ + (match id with Some (id,_u) -> Constant.print id | None -> str "") + + | Kcamlprim (op, lbl) -> + str "camlcall " ++ str (CPrimitives.to_string op) ++ spc () ++ + pp_lbl lbl + + | Kareint n -> str "areint " ++ int n + +and pp_bytecodes c = + match c with + | [] -> str "" + | Klabel lbl :: c -> + str "L" ++ int lbl ++ str ":" ++ fnl () ++ + pp_bytecodes c + | Ksequence (l1, l2) :: c -> + pp_bytecodes l1 ++ pp_bytecodes l2 ++ pp_bytecodes c + | i :: c -> + pp_instr i ++ fnl () ++ pp_bytecodes c -- cgit v1.2.3