From 60b6624ae2b28ebe9fb30c2aa6115e4d5c1ab436 Mon Sep 17 00:00:00 2001 From: xleroy Date: Sat, 26 Nov 2011 15:40:57 +0000 Subject: cparser/*: refactoring of the expansion of read-modify-write operators cparser/PackedStructs: treat r-m-w operations over byte-swapped fields cparser/PackedStructs: allow static initialization of packed structs test/regression: more packedstruct tests git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1738 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- cparser/Transform.mli | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'cparser/Transform.mli') diff --git a/cparser/Transform.mli b/cparser/Transform.mli index 82159975..5736abc9 100644 --- a/cparser/Transform.mli +++ b/cparser/Transform.mli @@ -15,18 +15,41 @@ (** Creation of fresh temporary variables. *) val reset_temps : unit -> unit +val get_temps : unit -> C.decl list val new_temp_var : ?name:string -> C.typ -> C.ident val new_temp : ?name:string -> C.typ -> C.exp -val get_temps : unit -> C.decl list +val mk_temp : Env.t -> ?name:string -> C.typ -> C.exp (** Avoiding repeated evaluation of a l-value *) val bind_lvalue: Env.t -> C.exp -> (C.exp -> C.exp) -> C.exp -(** Generic transformation of a statement *) +(* Most transformations over expressions can be optimized if the + value of the expression is not needed and it is evaluated only + for its side-effects. The type [context] records whether + we are in a side-effects-only position ([Effects]) or not ([Val]). *) type context = Val | Effects +(** Expansion of assignment expressions *) +val op_for_assignop : C.binary_operator -> C.binary_operator +val op_for_incr_decr : C.unary_operator -> C.binary_operator +val assignop_for_incr_decr : C.unary_operator -> C.binary_operator +val expand_assign : + write:(C.exp -> C.exp -> C.exp) -> + Env.t -> context -> C.exp -> C.exp -> C.exp +val expand_assignop : + read:(C.exp -> C.exp) -> write:(C.exp -> C.exp -> C.exp) -> + Env.t -> context -> C.binary_operator -> C.exp -> C.exp -> C.typ -> C.exp +val expand_preincrdecr : + read:(C.exp -> C.exp) -> write:(C.exp -> C.exp -> C.exp) -> + Env.t -> context -> C.unary_operator -> C.exp -> C.exp +val expand_postincrdecr : + read:(C.exp -> C.exp) -> write:(C.exp -> C.exp -> C.exp) -> + Env.t -> context -> C.unary_operator -> C.exp -> C.exp + +(** Generic transformation of a statement *) + val stmt : (C.location -> Env.t -> context -> C.exp -> C.exp) -> Env.t -> C.stmt -> C.stmt -- cgit