2023-01-20 Thomas Schwinge <thomas@codesourcery.com>
+ * config/nvptx/nvptx.cc (nvptx_assemble_undefined_decl): Notice
+ '__nvptx_stacks', '__nvptx_uni' declarations.
+ (nvptx_file_end): Don't emit duplicate declarations for those.
+
* config/nvptx/nvptx.md (nvptx_uniform_warp_check): Make fit for
non-full-warp execution.
/* True if any function references __nvptx_stacks. */
static bool need_softstack_decl;
+static bool have_softstack_decl;
/* True if any function references __nvptx_uni. */
static bool need_unisimt_decl;
+static bool have_unisimt_decl;
static int nvptx_mach_max_workers ();
TREE_TYPE (decl), size ? tree_to_shwi (size) : 0,
DECL_ALIGN (decl), true);
nvptx_assemble_decl_end ();
+
+ static tree softstack_id = get_identifier ("__nvptx_stacks");
+ static tree unisimt_id = get_identifier ("__nvptx_uni");
+ if (DECL_NAME (decl) == softstack_id)
+ have_softstack_decl = true;
+ else if (DECL_NAME (decl) == unisimt_id)
+ have_unisimt_decl = true;
}
/* Output a pattern for a move instruction. */
write_shared_buffer (asm_out_file, gang_private_shared_sym,
gang_private_shared_align, gang_private_shared_size);
- if (need_softstack_decl)
+ if (need_softstack_decl && !have_softstack_decl)
{
write_var_marker (asm_out_file, false, true, "__nvptx_stacks");
/* 32 is the maximum number of warps in a block. Even though it's an
fprintf (asm_out_file, ".extern .shared .u%d __nvptx_stacks[32];\n",
POINTER_SIZE);
}
- if (need_unisimt_decl)
+
+ if (need_unisimt_decl && !have_unisimt_decl)
{
write_var_marker (asm_out_file, false, true, "__nvptx_uni");
fprintf (asm_out_file, ".extern .shared .u32 __nvptx_uni[32];\n");
-/* { dg-do compile } */
+/* { dg-do assemble } */
/* { dg-options {-save-temps -O0 -msoft-stack} } */
extern void *__nvptx_stacks[32] __attribute__((shared,nocommon));
return stack_array[5];
}
-/* The implicit (via 'need_softstack_decl') and explicit declarations of
- '__nvptx_stacks' are both emitted:
- { dg-final { scan-assembler-times {(?n)\.extern .* __nvptx_stacks\[32\];} 2 } }
+/* Of the implicit (via 'need_softstack_decl') and explicit declarations of
+ '__nvptx_stacks', only one is emitted:
+ { dg-final { scan-assembler-times {(?n)\.extern .* __nvptx_stacks\[32\];} 1 } }
*/
-/* { dg-do compile } */
+/* { dg-do assemble } */
/* { dg-options {-save-temps -O0 -muniform-simt} } */
extern unsigned __nvptx_uni[32] __attribute__((shared,nocommon));
MEMMODEL_RELAXED);
}
-/* The implicit (via 'need_unisimt_decl') and explicit declarations of
- '__nvptx_uni' are both emitted:
- { dg-final { scan-assembler-times {(?n)\.extern .* __nvptx_uni\[32\];} 2 } }
+/* Of the implicit (via 'need_unisimt_decl') and explicit declarations of
+ '__nvptx_uni', only one is emitted:
+ { dg-final { scan-assembler-times {(?n)\.extern .* __nvptx_uni\[32\];} 1 } }
*/