return nvptx_output_set_softstack (REGNO (operands[0]));
})
+(define_expand "save_stack_block"
+ [(match_operand 0 "register_operand" "")
+ (match_operand 1 "register_operand" "")]
+ "!TARGET_SOFT_STACK"
+{
+ /* The concept of a '%stack' pointer doesn't apply like this for
+ PTX "native" stacks. GCC however occasionally synthesizes
+ '__builtin_stack_save ()', '__builtin_stack_restore ()', and isn't able to
+ optimize them all away. Just submit a dummy -- user code shouldn't be
+ able to observe this. */
+ emit_move_insn (operands[0], GEN_INT (0xdeadbeef));
+ DONE;
+})
+
(define_expand "restore_stack_block"
[(match_operand 0 "register_operand" "")
(match_operand 1 "register_operand" "")]
""
{
- if (TARGET_SOFT_STACK)
+ if (!TARGET_SOFT_STACK)
+ ; /* See 'save_stack_block'. */
+ else
{
emit_move_insn (operands[0], operands[1]);
emit_insn (gen_set_softstack (Pmode, operands[0]));
/* Document what we do for '__builtin_stack_save()', '__builtin_stack_restore()'. */
-/* { dg-do compile }
- TODO We can't 'assemble' this -- it's invalid PTX code. */
+/* { dg-do assemble } */
/* { dg-options {-O3 -mno-soft-stack} } */
/* { dg-additional-options -save-temps } */
/* { dg-final { check-function-bodies {** } {} } } */
void f(void)
{
+ // 0xdeadbeef
p = __builtin_stack_save();
asm volatile ("" : : : "memory");
+ // no-op
__builtin_stack_restore(p);
asm volatile ("" : : : "memory");
}
** f:
** \.visible \.func f
** {
-** st\.global\.u64 \[p\], %stack;
+** \.reg\.u64 (%r[0-9]+);
+** mov\.u64 \1, 3735928559;
+** st\.global\.u64 \[p\], \1;
** ret;
*/
-
-/* The concept of a '%stack' pointer doesn't apply like this for
- '-mno-soft-stack': PTX "native" stacks (TODO).
-
- { dg-final { scan-assembler-not {%stack} { xfail *-*-* } } } */
-
-/* As these are an internal-use built-in function, we don't bother with
- emitting proper error diagnostics. */