This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 8/9] Gccgo port to s390[x] -- part I


This is an optional extension of the -fgo-dump-spec option to
handle copmplex data types.  It is not necessary for s390[x] but
was easy to write on top of the previous patch.

gcc/ChangeLog
2014-09-05  Dominik Vogt  <vogt@linux.vnet.ibm.com>

        * godump.c (go_format_type): Represent "float _Complex" and
        "double _Complex" as complex64 or complex128 in Go, as appropriate.

gcc/testsuite/ChangeLog
2014-09-05  Dominik Vogt  <vogt@linux.vnet.ibm.com>

        * gcc.misc-tests/godump-1.c: Add tests for complex types.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany
>From 3eb21882fc7848eefb9c14cfbb0b4c69f8851ad3 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Fri, 5 Sep 2014 07:31:01 +0100
Subject: [PATCH 8/9] godump: Support _Complex types in go_format_type.

1) float/double _Complex are represented as complex64/complex128 in Go as
appropriate.

2) Add tests.
---
 gcc/godump.c                            | 34 +++++++++++++++++++++++++++++++++
 gcc/testsuite/gcc.misc-tests/godump-1.c | 30 +++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/gcc/godump.c b/gcc/godump.c
index 4f3e69d..6b39eba 100644
--- a/gcc/godump.c
+++ b/gcc/godump.c
@@ -776,6 +776,40 @@ go_format_type (struct godump_container *container, tree type,
       }
       break;
 
+    case COMPLEX_TYPE:
+      {
+	const char *s;
+	char buf[100];
+	tree real_type;
+
+	real_type = TREE_TYPE (type);
+	if (TREE_CODE (real_type) == REAL_TYPE)
+	  {
+	    switch (TYPE_PRECISION (real_type))
+	      {
+	      case 32:
+		s = "complex64";
+		break;
+	      case 64:
+		s = "complex128";
+		break;
+	      default:
+		snprintf (buf, sizeof buf, "INVALID-complex-%u",
+			  2 * TYPE_PRECISION (real_type));
+		s = buf;
+		ret = false;
+		break;
+	      }
+	  }
+	else
+	  {
+	    s = "INVALID-complex-non-real";
+	    ret = false;
+	  }
+	obstack_grow (ob, s, strlen (s));
+      }
+      break;
+
     case BOOLEAN_TYPE:
       obstack_grow (ob, "bool", 4);
       break;
diff --git a/gcc/testsuite/gcc.misc-tests/godump-1.c b/gcc/testsuite/gcc.misc-tests/godump-1.c
index 2a8a0fd..c6a3ca5 100644
--- a/gcc/testsuite/gcc.misc-tests/godump-1.c
+++ b/gcc/testsuite/gcc.misc-tests/godump-1.c
@@ -104,6 +104,21 @@ d_t d_v2;
 typedef long double ld_t;
 long double ld_v1;
 ld_t ld_v2;
+typedef _Complex cx_t;
+_Complex cx_v1;
+cx_t cx_v2;
+typedef float _Complex fcx_t;
+float _Complex fcx_v1;
+fcx_t fcx_v2;
+typedef double _Complex dcx_t;
+double _Complex dcx_v1;
+dcx_t dcx_v2;
+typedef long double _Complex ldcx_t;
+long double _Complex ldcx_v1;
+ldcx_t ldcx_v2;
+typedef int _Complex icx_t;
+int _Complex icx_v1;
+icx_t icx_v2;
 
 /* nested typedefs */
 typedef int ni_t;
@@ -295,6 +310,11 @@ typedef int8_t (*func_t)(void *p);
 /* { dg-final { scan-file godump-1.out "(?n)^type _f_t float\[0-9\]*$" } } */
 /* { dg-final { scan-file godump-1.out "(?n)^type _d_t float\[0-9\]*$" } } */
 /* { dg-final { scan-file godump-1.out "(?n)^// type _ld_t INVALID-float-128$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^type _cx_t complex\[0-9\]*$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^type _fcx_t complex\[0-9\]*$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^type _dcx_t complex\[0-9\]*$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^// type _ldcx_t INVALID-complex-256$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^// type _icx_t INVALID-complex-non-real$" } } */
 /* { dg-final { scan-file godump-1.out "(?n)^type _ni_t int\[0-9\]*$" } } */
 /* { dg-final { scan-file godump-1.out "(?n)^type _ni2_t int\[0-9\]*$" } } */
 /* { dg-final { scan-file godump-1.out "(?n)^type _ni3_t int\[0-9\]*$" } } */
@@ -406,6 +426,16 @@ typedef int8_t (*func_t)(void *p);
 /* { dg-final { scan-file godump-1.out "(?n)^var _d_v2 _d_t$" } } */
 /* { dg-final { scan-file godump-1.out "(?n)^// var _ld_v1 INVALID-float-128$" } } */
 /* { dg-final { scan-file godump-1.out "(?n)^// var _ld_v2 INVALID-float-128$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^var _cx_v1 complex\[0-9\]*$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^var _cx_v2 _cx_t$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^var _fcx_v1 complex\[0-9\]*$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^var _fcx_v2 _fcx_t$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^var _dcx_v1 complex\[0-9\]*$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^var _dcx_v2 _dcx_t$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^// var _ldcx_v1 INVALID-complex-256$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^// var _ldcx_v2 INVALID-complex-256$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^// var _icx_v1 INVALID-complex-non-real$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^// var _icx_v2 INVALID-complex-non-real$" } } */
 /* { dg-final { scan-file godump-1.out "(?n)^var _ni2_v2 _ni2_t$" } } */
 /* { dg-final { scan-file godump-1.out "(?n)^var _ni3_v2 _ni3_t$" } } */
 /* { dg-final { scan-file godump-1.out "(?n)^var _e1_v1 int$" } } */
-- 
1.8.4.2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]