diff options
Diffstat (limited to 'cparser')
-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 |
5 files changed, 73 insertions, 18 deletions
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 |