From 9c7c84cc40eaacc1e2c13091165785cddecba5ad Mon Sep 17 00:00:00 2001 From: xleroy Date: Tue, 29 Jun 2010 08:27:14 +0000 Subject: Support for inlined built-ins. AST: add ef_inline flag to external functions. Selection: recognize calls to inlined built-ins and inline them as Sbuiltin. CminorSel to Asm: added Sbuiltin/Ibuiltin instruction. PrintAsm: adapted expansion of builtins. C2Clight: adapted detection of builtins. Conventions: refactored in a machine-independent part (backend/Conventions) and a machine-dependent part (ARCH/SYS/Conventions1). git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1356 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- cfrontend/Ctyping.v | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'cfrontend/Ctyping.v') diff --git a/cfrontend/Ctyping.v b/cfrontend/Ctyping.v index b147fbda..8e089f16 100644 --- a/cfrontend/Ctyping.v +++ b/cfrontend/Ctyping.v @@ -155,8 +155,10 @@ Inductive wt_fundef: typenv -> fundef -> Prop := | wt_fundef_Internal: forall env f, wt_function env f -> wt_fundef env (Internal f) - | wt_fundef_External: forall env id args res, - wt_fundef env (External id args res). + | wt_fundef_External: forall env ef args res, + (ef_sig ef).(sig_args) = typlist_of_typelist args -> + (ef_sig ef).(sig_res) = opttyp_of_type res -> + wt_fundef env (External ef args res). Definition add_global_var (env: typenv) (id_v: ident * globvar type) : typenv := @@ -410,8 +412,12 @@ Qed. Definition typecheck_fundef (main: ident) (env: typenv) (id_fd: ident * fundef) : bool := let (id, fd) := id_fd in match fd with - | Internal f => typecheck_function env f - | External _ _ _ => true + | Internal f => + typecheck_function env f + | External ef targs tres => + let s := ef_sig ef in + list_eq_dec typ_eq s.(sig_args) (typlist_of_typelist targs) + && opt_typ_eq s.(sig_res) (opttyp_of_type tres) end && if ident_eq id main then match type_of_fundef fd with @@ -430,8 +436,8 @@ Proof. intros. unfold typecheck_fundef in H; TrueInv. split. destruct fd. - constructor. apply typecheck_function_correct; auto. - constructor. + constructor. apply typecheck_function_correct; auto. + TrueInv. constructor; eapply proj_sumbool_true; eauto. intro. destruct (ident_eq id main). destruct (type_of_fundef fd); try discriminate. exists t; decEq; auto. apply eq_type_correct; auto. -- cgit