From 712f3cbae6bfd3c6f6cc40d44f438aa0affcd371 Mon Sep 17 00:00:00 2001 From: xleroy Date: Tue, 18 Dec 2012 07:54:35 +0000 Subject: Support for inline assembly (asm statements). cparser: add primitive support for enum types. bitfield emulation: for bitfields with enum type, choose signed/unsigned as appropriate git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2074 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- cparser/Cprint.ml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'cparser/Cprint.ml') diff --git a/cparser/Cprint.ml b/cparser/Cprint.ml index 2548f3b9..e97f0411 100644 --- a/cparser/Cprint.ml +++ b/cparser/Cprint.ml @@ -172,6 +172,8 @@ let rec dcl pp ty n = fprintf pp "struct %a%a%t" ident id attributes a n | TUnion(id, a) -> fprintf pp "union %a%a%t" ident id attributes a n + | TEnum(id, a) -> + fprintf pp "enum %a%a%t" ident id attributes a n let typ pp ty = dcl pp ty (fun _ -> ()) @@ -424,6 +426,8 @@ let rec stmt pp s = fprintf pp "@[{@ %a@;<0 -2>}@]" stmt_block s | Sdecl d -> full_decl pp d + | Sasm txt -> + fprintf pp "asm(%a);" const (CStr txt) and slabel pp = function | Slabel s -> @@ -486,17 +490,17 @@ let globdecl pp g = fprintf pp "@;<0 -2>};@]@ @ " | Gtypedef(id, ty) -> fprintf pp "@[typedef %a;@]@ @ " simple_decl (id, ty) - | Genumdef(id, fields) -> - fprintf pp "@[enum %a {" ident id; + | Genumdef(id, attrs, vals) -> + fprintf pp "@[enum%a %a {" attributes attrs ident id; List.iter - (fun (name, opt_e) -> + (fun (name, v, opt_e) -> fprintf pp "@ %a" ident name; begin match opt_e with | None -> () | Some e -> fprintf pp " = %a" exp (0, e) end; fprintf pp ",") - fields; + vals; fprintf pp "@;<0 -2>};@]@ @ " | Gpragma s -> fprintf pp "#pragma %s@ @ " s -- cgit