diff mbox

[UPC,10/22] target - rs6000

Message ID 20151201060239.GA31179@intrepid.com
State New
Headers show

Commit Message

Gary Funck Dec. 1, 2015, 6:02 a.m. UTC
Background
----------

An overview email, describing the UPC-related changes is here:
  https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00005.html

The GUPC branch is described here:
  http://gcc.gnu.org/projects/gupc.html

The UPC-related source code differences are summarized here:
  http://gccupc.org/gupc-changes

All languages (c, c++, fortran, go, lto, objc, obj-c++) have been
bootstrapped; no test suite regressions were introduced,
relative to the GCC trunk.

If you are on the cc-list, your name was chosen either
because you are listed as a maintainer for the area that
applies to the patches described in this email, or you
were a frequent contributor of patches made to files listed
in this email.

In the change log entries included in each patch, the directory
containing the affected files is listed, followed by the files.
When the patches are applied, the change log entries will be
distributed to the appropriate ChangeLog file.

Overview
--------

UPC pointers-to-shared have an internal representation that is a 'struct'.
GCC generally assumes that pointers can be targeted into registers.
However, various ABI's will special case how struct's are passed.

In order to insure that UPC pointers-to-shared can be passed to
the UPC runtime, which is written in "C", the convention used
to pass the UPC pointer-to-shared must agree with that of a struct,
because the runtime will describe the internal representation
as a struct.

The code below checks for UPC pointers-to-shared that are
represented as an aggregate type and insures that these
pointers are passed as struct's.

2015-11-30  Gary Funck  <gary@intrepid.com>

	gcc/config/rs6000/
	* rs6000.c (rs6000_return_in_memory):
	If TYPE is a UPC PTS type with a "struct" internal representation,
	handle it as an aggregate type.
	(rs6000_function_arg_boundary): For UPC pointers-to-shared with
	alignment > 64 that have an internal "struct" representation,
	return 128 and skip the ABI warning.
	(rs6000_pass_by_reference): If TYPE is a UPC PTS type with
	a "struct" internal representation, handle it as an aggregate type.
	(rs6000_pass_by_reference): Exclude UPC pointers-to-shared
	from the logic that returns pointers in either SImode or DImode.
diff mbox

Patch

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(.../trunk)	(revision 231059)
+++ gcc/config/rs6000/rs6000.c	(.../branches/gupc)	(revision 231080)
@@ -9709,12 +9709,21 @@  rs6000_return_in_memory (const_tree type
 					     NULL, NULL))
     return false;
 
+  /* TRUE if TYPE is a UPC pointer-to-shared type
+     and its underlying representation is an aggregate.  */
+  bool upc_struct_pts_p = (POINTER_TYPE_P (type)
+			     && SHARED_TYPE_P (TREE_TYPE (type)))
+			   && AGGREGATE_TYPE_P (upc_pts_rep_type_node);
+  /* If TYPE is a UPC struct PTS type, handle it as an aggregate type.  */
+  bool aggregate_p = AGGREGATE_TYPE_P (type)
+                     || upc_struct_pts_p;
+
   /* The ELFv2 ABI returns aggregates up to 16B in registers */
-  if (DEFAULT_ABI == ABI_ELFv2 && AGGREGATE_TYPE_P (type)
+  if (DEFAULT_ABI == ABI_ELFv2 && aggregate_p
       && (unsigned HOST_WIDE_INT) int_size_in_bytes (type) <= 16)
     return false;
 
-  if (AGGREGATE_TYPE_P (type)
+  if (aggregate_p
       && (aix_struct_return
 	  || (unsigned HOST_WIDE_INT) int_size_in_bytes (type) > 8))
     return true;
@@ -10040,6 +10049,18 @@  rs6000_function_arg_boundary (machine_mo
        || DEFAULT_ABI == ABI_ELFv2)
       && type && TYPE_ALIGN (type) > 64)
     {
+
+      /* If the underlying UPC pointer-to-shared representation
+         is an aggregate, and TYPE is either a pointer-to-shared
+	 or the PTS representation type, then return 16-byte
+	 alignment and skip the ABI warning.  */
+      if (upc_pts_rep_type_node
+          && AGGREGATE_TYPE_P (upc_pts_rep_type_node)
+          && ((POINTER_TYPE_P (type)
+	       && SHARED_TYPE_P (TREE_TYPE (type)))
+              || (TYPE_MAIN_VARIANT (type) == upc_pts_rep_type_node)))
+	return 128;
+
       /* "Aggregate" means any AGGREGATE_TYPE except for single-element
          or homogeneous float/vector aggregates here.  We already handled
          vector aggregates above, but still need to check for float here. */
@@ -11320,7 +11341,16 @@  rs6000_pass_by_reference (cumulative_arg
       return 1;
     }
 
-  if (DEFAULT_ABI == ABI_V4 && AGGREGATE_TYPE_P (type))
+  /* TRUE if TYPE is a UPC pointer-to-shared type
+     and its underlying representation is an aggregate.  */
+  bool upc_struct_pts_p = (POINTER_TYPE_P (type)
+                             && SHARED_TYPE_P (TREE_TYPE (type)))
+                           && AGGREGATE_TYPE_P (upc_pts_rep_type_node);
+  /* If TYPE is a UPC struct PTS type, handle it as an aggregate type.  */
+  bool aggregate_p = AGGREGATE_TYPE_P (type)
+                     || upc_struct_pts_p;
+
+  if (DEFAULT_ABI == ABI_V4 && aggregate_p)
     {
       if (TARGET_DEBUG_ARG)
 	fprintf (stderr, "function_arg_pass_by_reference: V4 aggregate\n");
@@ -33682,7 +33712,8 @@  rs6000_function_value (const_tree valtyp
 
   if ((INTEGRAL_TYPE_P (valtype)
        && GET_MODE_BITSIZE (mode) < (TARGET_32BIT ? 32 : 64))
-      || POINTER_TYPE_P (valtype))
+      || (POINTER_TYPE_P (valtype)
+          && !SHARED_TYPE_P (TREE_TYPE (valtype))))
     mode = TARGET_32BIT ? SImode : DImode;
 
   if (DECIMAL_FLOAT_MODE_P (mode) && TARGET_HARD_FLOAT && TARGET_FPRS)