Commit 7b310e90 by Dominik Vogt Committed by Ian Lance Taylor

godump.c (go_format_type): Represent "float _Complex" and "double _Complex" as…

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

gcc/:
	* godump.c (go_format_type): Represent "float _Complex" and
	"double _Complex" as complex64 or complex128 in Go, as appropriate.
gcc/testsuite/:
	* gcc.misc-tests/godump-1.c: Add tests for complex types.

From-SVN: r216840
parent d4573ffe
2014-10-29 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.
2014-10-29 Richard Biener <rguenther@suse.de> 2014-10-29 Richard Biener <rguenther@suse.de>
* match.pd: Implement a first set of conversion patterns. * match.pd: Implement a first set of conversion patterns.
...@@ -164,26 +169,26 @@ ...@@ -164,26 +169,26 @@
2014-10-28 Dominik Vogt <vogt@linux.vnet.ibm.com> 2014-10-28 Dominik Vogt <vogt@linux.vnet.ibm.com>
* godump.c (precision_to_units): New helper function. * godump.c (precision_to_units): New helper function.
(go_append_artificial_name): Ditto. (go_append_artificial_name): Ditto.
(go_append_decl_name): Ditto. (go_append_decl_name): Ditto.
(go_append_bitfield): Ditto. (go_append_bitfield): Ditto.
(go_get_uinttype_for_precision): Ditto. (go_get_uinttype_for_precision): Ditto.
(go_append_padding): Ditto. (go_append_padding): Ditto.
(go_force_record_alignment): Ditto. (go_force_record_alignment): Ditto.
(go_format_type): Represent unions with an array of uints of the size (go_format_type): Represent unions with an array of uints of the size
of the alignment in go. This fixes the 'random' size of the union's of the alignment in go. This fixes the 'random' size of the union's
representation using just the first field. representation using just the first field.
(go_format_type): Add argument that indicates whether a record is (go_format_type): Add argument that indicates whether a record is
nested (used for generation of artificial go names). nested (used for generation of artificial go names).
(go_output_fndecl): Adapt to new go_format_type signature. (go_output_fndecl): Adapt to new go_format_type signature.
(go_output_typedef): Ditto. (go_output_typedef): Ditto.
(go_output_var): Ditto. (go_output_var): Ditto.
(go_output_var): Prefer to output type as alias (typedef). (go_output_var): Prefer to output type as alias (typedef).
(go_format_type): Bitfields in records are simulated as arrays of bytes (go_format_type): Bitfields in records are simulated as arrays of bytes
in go. in go.
* godump.c (go_format_type): Fix handling of arrays with zero elements. * godump.c (go_format_type): Fix handling of arrays with zero elements.
2014-10-28 Andrew MacLeod <amacleod@redhat.com> 2014-10-28 Andrew MacLeod <amacleod@redhat.com>
...@@ -780,6 +780,40 @@ go_format_type (struct godump_container *container, tree type, ...@@ -780,6 +780,40 @@ go_format_type (struct godump_container *container, tree type,
} }
break; 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: case BOOLEAN_TYPE:
obstack_grow (ob, "bool", 4); obstack_grow (ob, "bool", 4);
break; break;
......
2014-10-29 Dominik Vogt <vogt@linux.vnet.ibm.com>
* gcc.misc-tests/godump-1.c: Add tests for complex types.
2014-10-29 Thomas Preud'homme <thomas.preudhomme@arm.com> 2014-10-29 Thomas Preud'homme <thomas.preudhomme@arm.com>
* gcc.dg/optimize-bswapsi-1.c (swap32_e): New bswap test. * gcc.dg/optimize-bswapsi-1.c (swap32_e): New bswap test.
......
...@@ -104,6 +104,21 @@ d_t d_v2; ...@@ -104,6 +104,21 @@ d_t d_v2;
typedef long double ld_t; typedef long double ld_t;
long double ld_v1; long double ld_v1;
ld_t ld_v2; 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 */ /* nested typedefs */
typedef int ni_t; typedef int ni_t;
...@@ -301,6 +316,11 @@ typedef int8_t (*func_t)(void *p); ...@@ -301,6 +316,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 _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 _d_t float\[0-9\]*$" } } */
/* { dg-final { scan-file godump-1.out "(?n)^// type _ld_t INVALID-float-\[0-9\]*$" } } */ /* { dg-final { scan-file godump-1.out "(?n)^// type _ld_t INVALID-float-\[0-9\]*$" } } */
/* { 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-\[0-9\]*$" } } */
/* { 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 _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 _ni2_t int\[0-9\]*$" } } */
/* { dg-final { scan-file godump-1.out "(?n)^type _ni3_t int\[0-9\]*$" } } */ /* { dg-final { scan-file godump-1.out "(?n)^type _ni3_t int\[0-9\]*$" } } */
...@@ -414,6 +434,16 @@ typedef int8_t (*func_t)(void *p); ...@@ -414,6 +434,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 _d_v2 _d_t$" } } */
/* { dg-final { scan-file godump-1.out "(?n)^// var _ld_v1 INVALID-float-\[0-9\]*$" } } */ /* { dg-final { scan-file godump-1.out "(?n)^// var _ld_v1 INVALID-float-\[0-9\]*$" } } */
/* { dg-final { scan-file godump-1.out "(?n)^// var _ld_v2 INVALID-float-\[0-9\]*$" } } */ /* { dg-final { scan-file godump-1.out "(?n)^// var _ld_v2 INVALID-float-\[0-9\]*$" } } */
/* { 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-\[0-9\]*$" } } */
/* { dg-final { scan-file godump-1.out "(?n)^// var _ldcx_v2 INVALID-complex-\[0-9\]*$" } } */
/* { 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 _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 _ni3_v2 _ni3_t$" } } */
/* { dg-final { scan-file godump-1.out "(?n)^var _e1_v1 int$" } } */ /* { dg-final { scan-file godump-1.out "(?n)^var _e1_v1 int$" } } */
......
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