nvptx.c (nvptx_function_arg_boundary): New.
authorNathan Sidwell <nathan@acm.org>
Tue, 17 May 2016 21:16:49 +0000 (21:16 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 17 May 2016 21:16:49 +0000 (21:16 +0000)
* config/nvptx/nvptx.c (nvptx_function_arg_boundary): New.
(TARGET_FUNCTION_ARG_BOUNDARY): Override.

testsuite/
* gcc.target/nvptx/abi-vararg-3.c: New.

From-SVN: r236345

gcc/ChangeLog
gcc/config/nvptx/nvptx.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/nvptx/abi-vararg-3.c [new file with mode: 0644]

index cf13477185f148f0a34b8fb1e84cc6814b727d6a..db31f1c15bd2f1ceaa9e03d3ef28ea68290709ff 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-17  Nathan Sidwell  <nathan@acm.org>
+
+       * config/nvptx/nvptx.c (nvptx_function_arg_boundary): New.
+       (TARGET_FUNCTION_ARG_BOUNDARY): Override.
+
 2016-05-17  Mikhail Maltsev  <maltsevm@gmail.com>
 
        PR tree-optimization/54579
index e81a450a20c7742fca455c2d7eb1ec6e033f27fd..d4a8f29a21ce59969f7bd29cc47bac824b3371ae 100644 (file)
@@ -464,6 +464,17 @@ nvptx_function_arg_advance (cumulative_args_t cum_v,
   cum->count++;
 }
 
+/* Implement TARGET_FUNCTION_ARG_BOUNDARY.
+
+   For nvptx This is only used for varadic args.  The type has already
+   been promoted and/or converted to invisible reference.  */
+
+static unsigned
+nvptx_function_arg_boundary (machine_mode mode, const_tree ARG_UNUSED (type))
+{
+  return GET_MODE_ALIGNMENT (mode);
+}
+
 /* Handle the TARGET_STRICT_ARGUMENT_NAMING target hook.
 
    For nvptx, we know how to handle functions declared as stdarg: by
@@ -4835,6 +4846,8 @@ nvptx_goacc_reduction (gcall *call)
 #define TARGET_FUNCTION_INCOMING_ARG nvptx_function_incoming_arg
 #undef TARGET_FUNCTION_ARG_ADVANCE
 #define TARGET_FUNCTION_ARG_ADVANCE nvptx_function_arg_advance
+#undef TARGET_FUNCTION_ARG_BOUNDARY
+#define TARGET_FUNCTION_ARG_BOUNDARY nvptx_function_arg_boundary
 #undef TARGET_PASS_BY_REFERENCE
 #define TARGET_PASS_BY_REFERENCE nvptx_pass_by_reference
 #undef TARGET_FUNCTION_VALUE_REGNO_P
index e5127affb18b48c382f0ccea6972f76ab53c1575..5e94e1ebbbeb68b09c224d731153966bb48a80c0 100644 (file)
@@ -1,3 +1,7 @@
+2016-05-17  Nathan Sidwell  <nathan@acm.org>
+
+       * gcc.target/nvptx/abi-vararg-3.c: New.
+
 2016-05-17  Mikhail Maltsev  <maltsevm@gmail.com>
 
        PR tree-optimization/54579
diff --git a/gcc/testsuite/gcc.target/nvptx/abi-vararg-3.c b/gcc/testsuite/gcc.target/nvptx/abi-vararg-3.c
new file mode 100644 (file)
index 0000000..24fd684
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Wno-pedantic -Wno-long-long" } */
+
+/* 64-bit var args should be aligned to 64  bits.  */
+
+void Foo (const char *, ...);
+
+void Baz ()
+{
+  Foo ("", 0, 1ll);
+}
+
+/* { dg-final { scan-assembler "st.u64\t\\\[%stack\\+8\\\]," } } */