summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2015-12-07 13:46:07 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2015-12-07 13:46:07 +0000
commit7e6e9bffdaa4d15604f9ae370054ce8a83cbf9e6 (patch)
tree5efde36c9a090f2922c1a53b1474a6511ad9a3a4
parentf40f9ee2db149a9e5e2d5d3acd861190b5582691 (diff)
downloadgcc-7e6e9bffdaa4d15604f9ae370054ce8a83cbf9e6.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231362 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/nvptx/nvptx.c23
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/nvptx/decl-init.c37
4 files changed, 61 insertions, 8 deletions
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 <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>
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 <nathan@acm.org>
+
+ * gcc.target/nvptx/decl-init.c: New.
+
2015-12-07 Kirill Yukhin <kirill.yukhin@intel.com>
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 };" } } */