diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2012-12-18 07:54:35 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2012-12-18 07:54:35 +0000 |
commit | 712f3cbae6bfd3c6f6cc40d44f438aa0affcd371 (patch) | |
tree | 913762a241b5f97b3ef4df086ba6adaeb2ff45c4 /cparser/PackedStructs.ml | |
parent | c629161139899e43a2fe7c5af59ca926cdab370e (diff) |
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
Diffstat (limited to 'cparser/PackedStructs.ml')
-rw-r--r-- | cparser/PackedStructs.ml | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/cparser/PackedStructs.ml b/cparser/PackedStructs.ml index 0dbc7cb..b1af7f6 100644 --- a/cparser/PackedStructs.ml +++ b/cparser/PackedStructs.ml @@ -60,6 +60,7 @@ let align x boundary = let rec can_byte_swap env ty = match unroll env ty with | TInt(ik, _) -> (true, sizeof_ikind ik > 1) + | TEnum(_, _) -> (true, sizeof_ikind enum_ikind > 1) | TPtr(_, _) -> (true, true) (* tolerance? *) | TArray(ty_elt, _, _) -> can_byte_swap env ty_elt | _ -> (false, false) @@ -162,6 +163,7 @@ let lookup_function loc env name = let accessor_type loc env ty = match unroll env ty with | TInt(ik,_) -> (8 * sizeof_ikind ik, TInt(unsigned_ikind_of ik,[])) + | TEnum(_,_) -> (8 * sizeof_ikind enum_ikind, TInt(unsigned_ikind_of enum_ikind,[])) | TPtr _ -> (8 * !config.sizeof_ptr, TInt(ptr_t_ikind,[])) | _ -> error "%a: unsupported type for byte-swapped field access" formatloc loc; @@ -376,6 +378,8 @@ let init_packed_struct loc env struct_id struct_sz initdata = match (unroll env ty, init) with | (TInt(ik, _), Init_single e) -> enter_scalar pos e (sizeof_ikind ik) bigendian + | (TEnum(_, _), Init_single e) -> + enter_scalar pos e (sizeof_ikind enum_ikind) bigendian | (TPtr _, Init_single e) -> enter_scalar pos e ((!Machine.config).sizeof_ptr) bigendian | (TArray(ty_elt, _, _), Init_array il) -> |