aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@college-de-france.fr>2023-01-24 15:58:38 +0100
committerXavier Leroy <xavier.leroy@college-de-france.fr>2023-01-24 15:58:38 +0100
commit2d23ce58cb53a3a9026bc12c79e6c0fa99b5aa30 (patch)
tree47908ee14fbfa6a490d8df8931b6c3cd4b11c63e
parent856da72d4190b42a012043a745dddc07a36c60c0 (diff)
downloadcompcert-2d23ce58cb53a3a9026bc12c79e6c0fa99b5aa30.tar.gz
compcert-2d23ce58cb53a3a9026bc12c79e6c0fa99b5aa30.zip
Introduce `wchar_ikind` in machine descriptions
This replaces `sizeof_wchar` and `wchar_signed`, and makes it possible to request that `wchar_t` is `long` instead of `int`, something that seems needed for PowerPC.
-rw-r--r--cparser/Cutil.ml5
-rw-r--r--cparser/Lexer.mll2
-rw-r--r--cparser/Machine.ml22
-rw-r--r--cparser/Machine.mli3
4 files changed, 12 insertions, 20 deletions
diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml
index f226d51b..5b099d7f 100644
--- a/cparser/Cutil.ml
+++ b/cparser/Cutil.ml
@@ -1008,10 +1008,7 @@ let find_matching_signed_ikind sz =
else if sz = !config.sizeof_longlong then ILongLong
else assert false
-let wchar_ikind () =
- if !config.wchar_signed
- then find_matching_signed_ikind !config.sizeof_wchar
- else find_matching_unsigned_ikind !config.sizeof_wchar
+let wchar_ikind () = !config.wchar_ikind
let size_t_ikind () = find_matching_unsigned_ikind !config.sizeof_size_t
let ptr_t_ikind () = find_matching_unsigned_ikind !config.sizeof_ptr
let ptrdiff_t_ikind () = find_matching_signed_ikind !config.sizeof_ptrdiff_t
diff --git a/cparser/Lexer.mll b/cparser/Lexer.mll
index 2efa4216..95374afe 100644
--- a/cparser/Lexer.mll
+++ b/cparser/Lexer.mll
@@ -241,7 +241,7 @@ let add_char enc c accu =
| Chr x, Cabs.EncU32 -> (* Characters are not encoded *)
Int64.of_int x :: accu
| Chr x, Cabs.EncWide -> (* Depends on size of wchar_t *)
- if Machine.(!config.sizeof_wchar) = 2
+ if Cutil.sizeof_ikind (Cutil.wchar_ikind ()) = 2
then add_char_utf16 x accu
else Int64.of_int x :: accu
}
diff --git a/cparser/Machine.ml b/cparser/Machine.ml
index c47ec594..81511ac3 100644
--- a/cparser/Machine.ml
+++ b/cparser/Machine.ml
@@ -41,8 +41,7 @@ type t = {
sizeof_longdouble: int;
sizeof_void: int option;
sizeof_fun: int option;
- sizeof_wchar: int;
- wchar_signed: bool;
+ wchar_ikind: C.ikind;
sizeof_size_t: int;
sizeof_ptrdiff_t: int;
sizeof_intreg: int;
@@ -76,8 +75,7 @@ let ilp32ll64 = {
sizeof_longdouble = 8;
sizeof_void = None;
sizeof_fun = None;
- sizeof_wchar = 4;
- wchar_signed = true;
+ wchar_ikind = C.IInt;
sizeof_size_t = 4;
sizeof_ptrdiff_t = 4;
sizeof_intreg = 4;
@@ -111,8 +109,7 @@ let i32lpll64 = {
sizeof_longdouble = 8;
sizeof_void = None;
sizeof_fun = None;
- sizeof_wchar = 4;
- wchar_signed = true;
+ wchar_ikind = C.IInt;
sizeof_size_t = 8;
sizeof_ptrdiff_t = 8;
sizeof_intreg = 8;
@@ -146,8 +143,7 @@ let il32pll64 = {
sizeof_longdouble = 8;
sizeof_void = None;
sizeof_fun = None;
- sizeof_wchar = 4;
- wchar_signed = true;
+ wchar_ikind = C.IInt;
sizeof_size_t = 8;
sizeof_ptrdiff_t = 8;
sizeof_intreg = 8;
@@ -193,15 +189,16 @@ let x86_64 =
let win32 =
{ ilp32ll64 with name = "win32"; char_signed = true;
- sizeof_wchar = 2; wchar_signed = false;
+ wchar_ikind = C.IUShort;
struct_passing_style = SP_split_args;
struct_return_style = SR_ref }
let win64 =
{ il32pll64 with name = "win64"; char_signed = true;
- sizeof_wchar = 2; wchar_signed = false }
+ wchar_ikind = C.IUShort }
let ppc_32_bigendian =
{ ilp32ll64 with name = "powerpc";
bigendian = true;
+ wchar_ikind = C.ILong;
bitfields_msb_first = true;
supports_unaligned_accesses = true;
struct_passing_style = SP_ref_caller;
@@ -211,7 +208,7 @@ let ppc_32_r64_bigendian =
{ ppc_32_bigendian with sizeof_intreg = 8;}
let ppc_32_diab_bigendian =
- { ppc_32_bigendian with sizeof_wchar = 2; wchar_signed = false }
+ { ppc_32_bigendian with wchar_ikind = C.IUShort }
let ppc_32_r64_diab_bigendian =
{ ppc_32_diab_bigendian with sizeof_intreg = 8;}
@@ -272,8 +269,7 @@ let undef = {
sizeof_longdouble = 0;
sizeof_void = None;
sizeof_fun = None;
- sizeof_wchar = 0;
- wchar_signed = true;
+ wchar_ikind = C.IInt;
sizeof_size_t = 0;
sizeof_ptrdiff_t = 0;
sizeof_intreg = 0;
diff --git a/cparser/Machine.mli b/cparser/Machine.mli
index f9d347b9..3cc6d5f4 100644
--- a/cparser/Machine.mli
+++ b/cparser/Machine.mli
@@ -40,8 +40,7 @@ type t = {
sizeof_longdouble: int;
sizeof_void: int option;
sizeof_fun: int option;
- sizeof_wchar: int;
- wchar_signed: bool;
+ wchar_ikind: C.ikind;
sizeof_size_t: int;
sizeof_ptrdiff_t: int;
sizeof_intreg: int;