diff options
author | Bernhard Schommer <bernhardschommer@gmail.com> | 2018-02-16 13:12:20 +0100 |
---|---|---|
committer | Bernhard Schommer <bernhardschommer@gmail.com> | 2018-02-16 16:29:38 +0100 |
commit | 1099583341e3a218accf80391202a7e5390f54cc (patch) | |
tree | ea108305f673f6d8d65fdf4693116260133ff67e /cparser | |
parent | 455b3384f85a23923001741d6b04deb88e997fd2 (diff) | |
download | compcert-1099583341e3a218accf80391202a7e5390f54cc.tar.gz compcert-1099583341e3a218accf80391202a7e5390f54cc.zip |
Move struct passing/return style to Machine.
Since the used configuration for passing and returning values
struct values is pretty much static it can be hardwired into the
machine settings.
Diffstat (limited to 'cparser')
-rw-r--r-- | cparser/Machine.ml | 67 | ||||
-rw-r--r-- | cparser/Machine.mli | 17 | ||||
-rw-r--r-- | cparser/StructReturn.ml | 5 |
3 files changed, 72 insertions, 17 deletions
diff --git a/cparser/Machine.ml b/cparser/Machine.ml index c95779b9..656c9eb0 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 (* Struct Return needs to be checked *) 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/StructReturn.ml b/cparser/StructReturn.ml index 11fa39ca..3de05e19 100644 --- a/cparser/StructReturn.ml +++ b/cparser/StructReturn.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 |