Unverified Commit 10995833 authored by Bernhard Schommer's avatar Bernhard Schommer
Browse files

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.
parent 455b3384
......@@ -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. *)
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment