From 4622f49fd089ae47d0c853343cb0a05f986c962a Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Fri, 27 Mar 2015 08:55:05 +0100 Subject: Extend annotations so that they can keep track of global variables and local variables whose address is taken. - CminorSel, RTL: add "annot" instructions. - CminorSel to Asm: use type "annot_arg" for arguments of "annot" instructions. - AST, Events: simplify EF_annot because constants are now part of the arguments. Implementation is not complete yet. --- backend/XTL.ml | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'backend/XTL.ml') diff --git a/backend/XTL.ml b/backend/XTL.ml index 9cb8e0a1..30c09fdf 100644 --- a/backend/XTL.ml +++ b/backend/XTL.ml @@ -35,6 +35,7 @@ type instruction = | Xcall of signature * (var, ident) sum * var list * var list | Xtailcall of signature * (var, ident) sum * var list | Xbuiltin of external_function * var list * var list + | Xannot of external_function * var annot_arg list | Xbranch of node | Xcond of condition * var list * node * node | Xjumptable of var * node list @@ -124,6 +125,12 @@ let rec set_vars_type vl tyl = let unify_var_type v1 v2 = if typeof v1 <> typeof v2 then raise Type_error +let type_annot_arg a ty = + match a with + | AA_base v -> set_var_type v ty + | AA_longofwords(v1, v2) -> set_var_type v1 Tint; set_var_type v2 Tint + | _ -> () + let type_instr = function | Xmove(src, dst) | Xspill(src, dst) | Xreload(src, dst) -> unify_var_type src dst @@ -153,6 +160,11 @@ let type_instr = function let sg = ef_sig ef in set_vars_type args sg.sig_args; set_vars_type res (Events.proj_sig_res' sg) + | Xannot(ef, args) -> + let sg = ef_sig ef in + if List.length args = List.length sg.sig_args + then List.iter2 type_annot_arg args sg.sig_args + else raise Type_error | Xbranch s -> () | Xcond(cond, args, s1, s2) -> -- cgit From 33b742bb41725e47bd88dc12f2a4f40173023f83 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Fri, 27 Mar 2015 14:24:03 +0100 Subject: Updated the Caml part. Added some more tests in annot1.c. --- backend/XTL.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backend/XTL.ml') diff --git a/backend/XTL.ml b/backend/XTL.ml index 30c09fdf..0e5ce0c4 100644 --- a/backend/XTL.ml +++ b/backend/XTL.ml @@ -125,10 +125,10 @@ let rec set_vars_type vl tyl = let unify_var_type v1 v2 = if typeof v1 <> typeof v2 then raise Type_error -let type_annot_arg a ty = +let rec type_annot_arg a ty = match a with | AA_base v -> set_var_type v ty - | AA_longofwords(v1, v2) -> set_var_type v1 Tint; set_var_type v2 Tint + | AA_longofwords(a1, a2) -> type_annot_arg a1 Tint; type_annot_arg a2 Tint | _ -> () let type_instr = function -- cgit