From fc0efeeab37395550cedc351e023f9c1d9e47552 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 7 Dec 2015 13:46:07 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 5 +++ gcc/config/nvptx/nvptx.c | 23 +++++++++----- gcc/testsuite/ChangeLog | 4 +++ gcc/testsuite/gcc.target/nvptx/decl-init.c | 37 ++++++++++++++++++++++ 4 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gcc.target/nvptx/decl-init.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4d38d48f571..62a601c6ee6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-12-07 Nathan Sidwell + + * config/nvptx/nvptx.c (nvptx_assemble_decl_begin): Look inside + complex and vector types. Cope with packed structs. + 2015-12-07 Kirill Yukhin PR target/68627 diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index fc0e9b8a9df..2dec8467437 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -1643,17 +1643,24 @@ nvptx_assemble_decl_begin (FILE *file, const char *name, const char *section, while (TREE_CODE (type) == ARRAY_TYPE) type = TREE_TYPE (type); - if (!INTEGRAL_TYPE_P (type) && !SCALAR_FLOAT_TYPE_P (type)) - type = ptr_type_node; + if (TREE_CODE (type) == VECTOR_TYPE + || 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); - if (elt_size > UNITS_PER_WORD) - { - type = ptr_type_node; - elt_size = int_size_in_bytes (type); - } + + /* Largest mode we're prepared to accept. For BLKmode types we + don't know if it'll contain pointer constants, so have to choose + 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_mode = int_mode_for_mode (TYPE_MODE (type)); + decl_chunk_mode = elt_mode; decl_offset = 0; init_part = 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 188ed2b44fb..0c96d70676e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-12-07 Nathan Sidwell + + * gcc.target/nvptx/decl-init.c: New. + 2015-12-07 Kirill Yukhin PR target/68627 diff --git a/gcc/testsuite/gcc.target/nvptx/decl-init.c b/gcc/testsuite/gcc.target/nvptx/decl-init.c new file mode 100644 index 00000000000..76f499c1714 --- /dev/null +++ b/gcc/testsuite/gcc.target/nvptx/decl-init.c @@ -0,0 +1,37 @@ +/* { 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 };" } } */ -- 2.30.2