diff options
author | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2018-02-19 13:59:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-19 13:59:37 +0100 |
commit | 44942a6a6889e79e749e83b6efe9ba7464dde1e7 (patch) | |
tree | 8895723b3b725cd7d06b6d7df70df1de1c28b580 | |
parent | 95395781f2cc8ae8cd4e9a167795f594e3b6dc23 (diff) | |
parent | 4472f312e3d5ef93d1b89b326727a10d34d918ce (diff) | |
download | compcert-44942a6a6889e79e749e83b6efe9ba7464dde1e7.tar.gz compcert-44942a6a6889e79e749e83b6efe9ba7464dde1e7.zip |
Merge pull request #60 from AbsIntPrivate/struct-abi-internal
Move the struct-return / struct-passing platform aspects from compcert.ini to cparser/Machine.ml
-rwxr-xr-x | configure | 44 | ||||
-rw-r--r-- | cparser/Machine.ml | 67 | ||||
-rw-r--r-- | cparser/Machine.mli | 17 | ||||
-rw-r--r-- | cparser/Parse.ml | 2 | ||||
-rw-r--r-- | cparser/StructPassing.ml (renamed from cparser/StructReturn.ml) | 5 | ||||
-rw-r--r-- | cparser/StructPassing.mli (renamed from cparser/StructReturn.mli) | 0 | ||||
-rw-r--r-- | driver/Configuration.ml | 28 | ||||
-rw-r--r-- | driver/Configuration.mli | 21 | ||||
-rw-r--r-- | driver/Frontend.ml | 6 |
9 files changed, 80 insertions, 110 deletions
@@ -176,8 +176,6 @@ casmruntime="" clinker_needs_no_pie=true clinker_options="" cprepro_options="" -struct_passing="" -struct_return="" # @@ -205,8 +203,6 @@ if test "$arch" = "arm"; then cprepro="${toolprefix}gcc" cprepro_options="-std=c99 -U__GNUC__ '-D__REDIRECT(name,proto,alias)=name proto' '-D__REDIRECT_NTH(name,proto,alias)=name proto' -E" libmath="-lm" - struct_passing="ints" - struct_return="int1-4" system="linux" fi @@ -227,16 +223,15 @@ if test "$arch" = "powerpc"; then case "$target" in linux) - struct_return="ref" + abi="linux" ;; *) - struct_return="int1-8" + abi="eabi" ;; esac case "$target" in eabi-diab) - abi="eabi" asm_supports_cfi=false casm="${toolprefix}das" casm_options="-Xalign-value" @@ -246,12 +241,10 @@ if test "$arch" = "powerpc"; then cprepro="${toolprefix}dcc" cprepro_options="-E -D__GNUC__" libmath="-lm" - struct_passing="ref-caller" system="diab" responsefile="diab" ;; *) - abi="eabi" casm="${toolprefix}gcc" casm_options="-c" casmruntime="${toolprefix}gcc -c -Wa,-mregnames" @@ -260,7 +253,6 @@ if test "$arch" = "powerpc"; then cprepro="${toolprefix}gcc" cprepro_options="-std=c99 -U__GNUC__ -E" libmath="-lm" - struct_passing="ref-caller" system="linux" ;; esac @@ -283,8 +275,6 @@ if test "$arch" = "x86" -a "$bitsize" = "32"; then cprepro="${toolprefix}gcc" cprepro_options="-std=c99 -m32 -U__GNUC__ -E" libmath="-lm" - struct_passing="ints" - struct_return="int1248" # to check! system="bsd" ;; cygwin) @@ -297,8 +287,6 @@ if test "$arch" = "x86" -a "$bitsize" = "32"; then cprepro="${toolprefix}gcc" cprepro_options="-std=c99 -m32 -U__GNUC__ '-D__attribute__(x)=' -E" libmath="-lm" - struct_passing="ints" - struct_return="ref" system="cygwin" ;; linux) @@ -311,8 +299,6 @@ if test "$arch" = "x86" -a "$bitsize" = "32"; then cprepro="${toolprefix}gcc" cprepro_options="-std=c99 -m32 -U__GNUC__ -E" libmath="-lm" - struct_passing="ints" - struct_return="ref" system="linux" ;; macosx) @@ -328,8 +314,6 @@ if test "$arch" = "x86" -a "$bitsize" = "32"; then cprepro="${toolprefix}gcc" cprepro_options="-std=c99 -arch i386 -U__GNUC__ -U__clang__ -U__BLOCKS__ '-D__attribute__(x)=' '-D__asm(x)=' '-D_Nullable=' '-D_Nonnull=' -E" libmath="" - struct_passing="ints" - struct_return="int1248" system="macosx" if [[ $kernel_major -gt 11 ]]; then @@ -363,8 +347,6 @@ if test "$arch" = "x86" -a "$bitsize" = "64"; then cprepro="${toolprefix}gcc" cprepro_options="-std=c99 -m64 -U__GNUC__ -E" libmath="-lm" - struct_passing="ref-callee" # wrong! - struct_return="ref" # to check! system="bsd" ;; linux) @@ -377,8 +359,6 @@ if test "$arch" = "x86" -a "$bitsize" = "64"; then cprepro="${toolprefix}gcc" cprepro_options="-std=c99 -m64 -U__GNUC__ -E" libmath="-lm" - struct_passing="ref-callee" # wrong! - struct_return="ref" # to check! system="linux" ;; macosx) @@ -394,8 +374,6 @@ if test "$arch" = "x86" -a "$bitsize" = "64"; then cprepro="${toolprefix}gcc" cprepro_options="-std=c99 -arch x86_64 -U__GNUC__ -U__clang__ -U__BLOCKS__ '-D__attribute__(x)=' '-D__asm(x)=' '-D_Nullable=' '-D_Nonnull=' -E" libmath="" - struct_passing="ref-callee" # wrong! - struct_return="ref" # to check! system="macosx" ;; *) @@ -424,8 +402,6 @@ if test "$arch" = "riscV"; then cprepro="${toolprefix}gcc" cprepro_options="$model_options -std=c99 -U__GNUC__ -E" libmath="-lm" - struct_passing="ref-callee" # wrong! - struct_return="ref" # to check! system="linux" fi @@ -672,8 +648,6 @@ HAS_RUNTIME_LIB=$has_runtime_lib HAS_STANDARD_HEADERS=$has_standard_headers LIBMATH=$libmath MODEL=$model -STRUCT_PASSING=$struct_passing -STRUCT_RETURN=$struct_return SYSTEM=$system RESPONSEFILE=$responsefile EOF @@ -716,19 +690,6 @@ BITSIZE= # ENDIANNESS=little # for ARM or x86 ENDIANNESS= -# Default calling conventions for passing structs and unions by value -# See options -fstruct-passing=<style> and -fstruct-return=<style> -# in the CompCert user's manual -# -STRUCT_PASSING=ref_callee -# STRUCT_PASSING=ref_caller -# STRUCT_PASSING=ints -# -STRUCT_RETURN=ref -# STRUCT_RETURN=int1248 -# STRUCT_RETURN=int1-4 -# STRUCT_RETURN=int1-8 - # Target operating system and development environment # # Possible choices for PowerPC: @@ -808,7 +769,6 @@ CompCert configuration: Hardware model................ $model Application binary interface.. $abi Endianness.................... $endianness - Composite passing conventions. arguments: $struct_passing, return values: $struct_return OS and development env........ $system C compiler.................... $cc C preprocessor................ $cprepro diff --git a/cparser/Machine.ml b/cparser/Machine.ml index c95779b9..4d1e7588 100644 --- a/cparser/Machine.ml +++ b/cparser/Machine.ml @@ -15,6 +15,18 @@ (* Machine-dependent aspects *) +type struct_passing_style = + | SP_ref_callee (* by reference, callee takes copy *) + | SP_ref_caller (* by reference, caller takes copy *) + | SP_split_args (* by value, as a sequence of ints *) + +type struct_return_style = + | SR_int1248 (* return by content if size is 1, 2, 4 or 8 bytes *) + | SR_int1to4 (* return by content if size is <= 4 *) + | SR_int1to8 (* return by content if size is <= 8 *) + | SR_ref (* always return by assignment to a reference + given as extra argument *) + type t = { name: string; char_signed: bool; @@ -44,7 +56,9 @@ type t = { alignof_fun: int option; bigendian: bool; bitfields_msb_first: bool; - supports_unaligned_accesses: bool + supports_unaligned_accesses: bool; + struct_passing_style: struct_passing_style; + struct_return_style : struct_return_style; } let ilp32ll64 = { @@ -76,7 +90,9 @@ let ilp32ll64 = { alignof_fun = None; bigendian = false; bitfields_msb_first = false; - supports_unaligned_accesses = false + supports_unaligned_accesses = false; + struct_passing_style = SP_ref_callee; + struct_return_style = SR_ref; } let i32lpll64 = { @@ -108,7 +124,9 @@ let i32lpll64 = { alignof_fun = None; bigendian = false; bitfields_msb_first = false; - supports_unaligned_accesses = false + supports_unaligned_accesses = false; + struct_passing_style = SP_ref_callee; + struct_return_style = SR_ref; } let il32pll64 = { @@ -140,7 +158,9 @@ let il32pll64 = { alignof_fun = None; bigendian = false; bitfields_msb_first = false; - supports_unaligned_accesses = false + supports_unaligned_accesses = false; + struct_passing_style = SP_ref_callee; + struct_return_style = SR_ref; } (* Canned configurations for some ABIs *) @@ -150,17 +170,27 @@ let x86_32 = char_signed = true; alignof_longlong = 4; alignof_double = 4; alignof_longdouble = 4; - supports_unaligned_accesses = true } + supports_unaligned_accesses = true; + struct_passing_style = SP_split_args; + struct_return_style = SR_ref} let x86_32_macosx = - x86_32 + {x86_32 with struct_passing_style = SP_split_args; + struct_return_style = SR_int1248 } + +let x86_32_bsd = + x86_32_macosx let x86_64 = - { i32lpll64 with name = "x86_64"; char_signed = true } + { i32lpll64 with name = "x86_64"; char_signed = true; + struct_passing_style = SP_ref_callee; (* wrong *) + struct_return_style = SR_ref } (* to check *) let win32 = { ilp32ll64 with name = "win32"; char_signed = true; - sizeof_wchar = 2; wchar_signed = false } + sizeof_wchar = 2; wchar_signed = false; + 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 } @@ -168,22 +198,31 @@ let ppc_32_bigendian = { ilp32ll64 with name = "powerpc"; bigendian = true; bitfields_msb_first = true; - supports_unaligned_accesses = true } + supports_unaligned_accesses = true; + struct_passing_style = SP_ref_caller; + struct_return_style = SR_int1to8; } let ppc_32_diab_bigendian = { ppc_32_bigendian with sizeof_wchar = 2; wchar_signed = false } +let ppc_32_linux_bigendian = {ppc_32_bigendian with struct_return_style = SR_ref;} + let arm_littleendian = - { ilp32ll64 with name = "arm" } + { ilp32ll64 with name = "arm"; struct_passing_style = SP_split_args; + struct_return_style = SR_int1to4;} let arm_bigendian = { arm_littleendian with bigendian = true; bitfields_msb_first = true } let rv32 = - { ilp32ll64 with name = "rv32" } + { ilp32ll64 with name = "rv32"; + struct_passing_style = SP_ref_callee; (* Wrong *) + struct_return_style = SR_ref } (* to check *) let rv64 = - { i32lpll64 with name = "rv64" } + { i32lpll64 with name = "rv64"; + struct_passing_style = SP_ref_callee; (* Wrong *) + struct_return_style = SR_ref } (* to check *) (* Add GCC extensions re: sizeof and alignof *) @@ -227,7 +266,9 @@ let undef = { alignof_fun = None; bigendian = false; bitfields_msb_first = false; - supports_unaligned_accesses = false + supports_unaligned_accesses = false; + struct_passing_style = SP_ref_callee; + struct_return_style = SR_ref; } (* The current configuration. Must be initialized before use. *) diff --git a/cparser/Machine.mli b/cparser/Machine.mli index b971958d..53c13b52 100644 --- a/cparser/Machine.mli +++ b/cparser/Machine.mli @@ -14,6 +14,17 @@ (* *********************************************************************) (* Machine-dependent aspects *) +type struct_passing_style = + | SP_ref_callee (* by reference, callee takes copy *) + | SP_ref_caller (* by reference, caller takes copy *) + | SP_split_args (* by value, as a sequence of ints *) + +type struct_return_style = + | SR_int1248 (* return by content if size is 1, 2, 4 or 8 bytes *) + | SR_int1to4 (* return by content if size is <= 4 *) + | SR_int1to8 (* return by content if size is <= 8 *) + | SR_ref (* always return by assignment to a reference + given as extra argument *) type t = { name: string; @@ -44,7 +55,9 @@ type t = { alignof_fun: int option; bigendian: bool; bitfields_msb_first: bool; - supports_unaligned_accesses: bool + supports_unaligned_accesses: bool; + struct_passing_style: struct_passing_style; + struct_return_style: struct_return_style; } (* The current configuration *) @@ -58,11 +71,13 @@ val i32lpll64 : t val il32pll64 : t val x86_32 : t val x86_32_macosx : t +val x86_32_bsd : t val x86_64 : t val win32 : t val win64 : t val ppc_32_bigendian : t val ppc_32_diab_bigendian : t +val ppc_32_linux_bigendian : t val arm_littleendian : t val arm_bigendian : t val rv32 : t diff --git a/cparser/Parse.ml b/cparser/Parse.ml index 8665e158..8143954b 100644 --- a/cparser/Parse.ml +++ b/cparser/Parse.ml @@ -19,7 +19,7 @@ module CharSet = Set.Make(struct type t = char let compare = compare end) let transform_program t p name = let run_pass pass flag p = if CharSet.mem flag t then pass p else p in - let p1 = (run_pass StructReturn.program 's' + let p1 = (run_pass StructPassing.program 's' (run_pass PackedStructs.program 'p' (run_pass Unblock.program 'b' (run_pass Bitfields.program 'f' diff --git a/cparser/StructReturn.ml b/cparser/StructPassing.ml index 11fa39ca..3de05e19 100644 --- a/cparser/StructReturn.ml +++ b/cparser/StructPassing.ml @@ -18,7 +18,6 @@ - passed by value as function parameters. *) open Machine -open Configuration open C open Cutil open Transform @@ -582,11 +581,11 @@ let program p = struct_passing_style := if !Clflags.option_interp then SP_ref_callee - else Configuration.struct_passing_style; + else !Machine.config.struct_passing_style; struct_return_style := if !Clflags.option_interp then SR_ref - else Configuration.struct_return_style; + else !Machine.config.struct_return_style; Transform.program ~decl:transf_decl ~fundef:transf_fundef diff --git a/cparser/StructReturn.mli b/cparser/StructPassing.mli index 45899a46..45899a46 100644 --- a/cparser/StructReturn.mli +++ b/cparser/StructPassing.mli diff --git a/driver/Configuration.ml b/driver/Configuration.ml index 48f8abde..972fd295 100644 --- a/driver/Configuration.ml +++ b/driver/Configuration.ml @@ -143,34 +143,6 @@ let stdlib_path = "" let asm_supports_cfi = get_bool_config "asm_supports_cfi" - -type struct_passing_style = - | SP_ref_callee (* by reference, callee takes copy *) - | SP_ref_caller (* by reference, caller takes copy *) - | SP_split_args (* by value, as a sequence of ints *) - -type struct_return_style = - | SR_int1248 (* return by content if size is 1, 2, 4 or 8 bytes *) - | SR_int1to4 (* return by content if size is <= 4 *) - | SR_int1to8 (* return by content if size is <= 8 *) - | SR_ref (* always return by assignment to a reference - given as extra argument *) - -let struct_passing_style = - match get_config_string "struct_passing_style" with - | "ref-callee" -> SP_ref_callee - | "ref-caller" -> SP_ref_caller - | "ints" -> SP_split_args - | v -> bad_config "struct_passing_style" [v] - -let struct_return_style = - match get_config_string "struct_return_style" with - | "int1248" -> SR_int1248 - | "int1-4" -> SR_int1to4 - | "int1-8" -> SR_int1to8 - | "ref" -> SR_ref - | v -> bad_config "struct_return_style" [v] - type response_file_style = | Gnu (* responsefiles in gnu compatible syntax *) | Diab (* responsefiles in diab compatible syntax *) diff --git a/driver/Configuration.mli b/driver/Configuration.mli index b918c169..a71da72d 100644 --- a/driver/Configuration.mli +++ b/driver/Configuration.mli @@ -46,27 +46,6 @@ val has_runtime_lib: bool val has_standard_headers: bool (** True if CompCert's standard header files is available. *) - -type struct_passing_style = - | SP_ref_callee (* by reference, callee takes copy *) - | SP_ref_caller (* by reference, caller takes copy *) - | SP_split_args (* by value, as a sequence of ints *) - -type struct_return_style = - | SR_int1248 (* return by content if size is 1, 2, 4 or 8 bytes *) - | SR_int1to4 (* return by content if size is <= 4 *) - | SR_int1to8 (* return by content if size is <= 8 *) - | SR_ref (* always return by assignment to a reference - given as extra argument *) - -val struct_passing_style: struct_passing_style - (** Calling conventions to use for passing structs and unions as - first-class values *) - -val struct_return_style: struct_return_style - (** Calling conventions to use for returning structs and unions as - first-class values *) - type response_file_style = | Gnu (* responsefiles in gnu compatible syntax *) | Diab (* responsefiles in diab compatible syntax *) diff --git a/driver/Frontend.ml b/driver/Frontend.ml index 2bc4f844..209e72e9 100644 --- a/driver/Frontend.ml +++ b/driver/Frontend.ml @@ -65,7 +65,9 @@ let init () = Machine.config:= begin match Configuration.arch with | "powerpc" -> if Configuration.gnu_toolchain - then Machine.ppc_32_bigendian + then if Configuration.abi = "linux" + then Machine.ppc_32_linux_bigendian + else Machine.ppc_32_bigendian else Machine.ppc_32_diab_bigendian | "arm" -> if Configuration.is_big_endian then Machine.arm_bigendian @@ -75,6 +77,8 @@ let init () = else if Configuration.abi = "macosx" then Machine.x86_32_macosx + else if Configuration.system = "bsd" + then Machine.x86_32_bsd else Machine.x86_32 | "riscV" -> if Configuration.model = "64" then Machine.rv64 |