Commit fc0efeea by Nathan Sidwell Committed by Nathan Sidwell

nvptx.c (nvptx_assemble_decl_begin): Look inside complex and vector types.

	gcc/
	* config/nvptx/nvptx.c (nvptx_assemble_decl_begin): Look inside
	complex and vector types.  Cope with packed structs.

	gcc/testsuite/
	* gcc.target/nvptx/decl-init.c: New.

From-SVN: r231362
parent 09d4cbcd
2015-12-07 Nathan Sidwell <nathan@acm.org>
* config/nvptx/nvptx.c (nvptx_assemble_decl_begin): Look inside
complex and vector types. Cope with packed structs.
2015-12-07 Kirill Yukhin <kirill.yukhin@intel.com> 2015-12-07 Kirill Yukhin <kirill.yukhin@intel.com>
PR target/68627 PR target/68627
...@@ -1643,17 +1643,24 @@ nvptx_assemble_decl_begin (FILE *file, const char *name, const char *section, ...@@ -1643,17 +1643,24 @@ nvptx_assemble_decl_begin (FILE *file, const char *name, const char *section,
while (TREE_CODE (type) == ARRAY_TYPE) while (TREE_CODE (type) == ARRAY_TYPE)
type = TREE_TYPE (type); type = TREE_TYPE (type);
if (!INTEGRAL_TYPE_P (type) && !SCALAR_FLOAT_TYPE_P (type)) if (TREE_CODE (type) == VECTOR_TYPE
type = ptr_type_node; || TREE_CODE (type) == COMPLEX_TYPE)
/* Neither vector nor complex types can contain the other. */
type = TREE_TYPE (type);
unsigned elt_size = int_size_in_bytes (type); unsigned elt_size = int_size_in_bytes (type);
if (elt_size > UNITS_PER_WORD)
{ /* Largest mode we're prepared to accept. For BLKmode types we
type = ptr_type_node; don't know if it'll contain pointer constants, so have to choose
elt_size = int_size_in_bytes (type); pointer size, otherwise we can choose DImode. */
} machine_mode elt_mode = TYPE_MODE (type) == BLKmode ? Pmode : DImode;
elt_size |= GET_MODE_SIZE (elt_mode);
elt_size &= -elt_size; /* Extract LSB set. */
elt_mode = mode_for_size (elt_size * BITS_PER_UNIT, MODE_INT, 0);
decl_chunk_size = elt_size; decl_chunk_size = elt_size;
decl_chunk_mode = int_mode_for_mode (TYPE_MODE (type)); decl_chunk_mode = elt_mode;
decl_offset = 0; decl_offset = 0;
init_part = 0; init_part = 0;
......
2015-12-07 Nathan Sidwell <nathan@acm.org>
* gcc.target/nvptx/decl-init.c: New.
2015-12-07 Kirill Yukhin <kirill.yukhin@intel.com> 2015-12-07 Kirill Yukhin <kirill.yukhin@intel.com>
PR target/68627 PR target/68627
......
/* { dg-do compile } */
/* { dg-additional-options "-Wno-long-long" } */
__extension__ _Complex float cf = 1.0f + 2.0if;
__extension__ _Complex double cd = 3.0 + 4.0i;
long long la[2] =
{0x0102030405060708ll,
0x1112131415161718ll};
struct six
{
char a;
short b, c;
};
struct six six1 = {1, 2, 3};
struct six six2[2] = {{4, 5, 6}, {7, 8, 9}};
struct __attribute__((packed)) five
{
char a;
int b;
};
struct five five1 = {10, 11};
struct five five2[2] = {{12, 13}, {14, 15}};
int __attribute__((vector_size(16))) vi = {16, 17, 18, 19};
/* dg-final { scan-assembler ".align 4 .u32 cf\\\[2\\\] = { 1065353216, 1073741824 };" } } */
/* dg-final { scan-assembler ".align 8 .u64 df\\\[2\\\] = { 4613937818241073152, 4616189618054758400 };" } } */
/* dg-final { scan-assembler ".align 8 .u64 la\\\[2\\\] = { 72623859790382856, 1230066625199609624 };" } } */
/* dg-final { scan-assembler ".align 2 .u16 six1\\\[3\\\] = { 1, 2, 3 };" } } */
/* dg-final { scan-assembler ".align 2 .u16 six2\\\[6\\\] = { 4, 5, 6, 7, 8, 9 };" } } */
/* dg-final { scan-assembler ".align 1 .u8 five1\\\[5\\\] = { 10, 11, 0, 0, 0 };" } } */
/* dg-final { scan-assembler ".align 1 .u8 five2\\\[10\\\] = { 12, 13, 0, 0, 0, 14, 15, 0, 0, 0 };" } } */
/* dg-final { scan-assembler ".align 8 .u32 vi\\\[4\\\] = { 16, 17, 18, 19 };" } } */
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