aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Machine.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2018-02-16 13:12:20 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2018-02-16 16:29:38 +0100
commit1099583341e3a218accf80391202a7e5390f54cc (patch)
treeea108305f673f6d8d65fdf4693116260133ff67e /cparser/Machine.ml
parent455b3384f85a23923001741d6b04deb88e997fd2 (diff)
downloadcompcert-kvx-1099583341e3a218accf80391202a7e5390f54cc.tar.gz
compcert-kvx-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/Machine.ml')
-rw-r--r--cparser/Machine.ml67
1 files changed, 54 insertions, 13 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. *)