#include "opts.h"
#include "tree-pretty-print.h"
#include "rtl-iter.h"
+#include "cgraph.h"
/* This file should be included last. */
#include "target-def.h"
write_fn_proto_1 (std::stringstream &s, bool is_defn,
const char *name, const_tree decl)
{
- write_fn_marker (s, is_defn, TREE_PUBLIC (decl), name);
+ if (lookup_attribute ("alias", DECL_ATTRIBUTES (decl)) == NULL)
+ write_fn_marker (s, is_defn, TREE_PUBLIC (decl), name);
/* PTX declaration. */
if (DECL_EXTERNAL (decl))
return false;
}
+/* Define locally, for use in NVPTX_ASM_OUTPUT_DEF. */
+#define SET_ASM_OP ".alias "
+
+/* Define locally, for use in nvptx_asm_output_def_from_decls. Add NVPTX_
+ prefix to avoid clash with ASM_OUTPUT_DEF from nvptx.h.
+ Copy of ASM_OUTPUT_DEF from defaults.h, with added terminating
+ semicolon. */
+#define NVPTX_ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
+ do \
+ { \
+ fprintf ((FILE), "%s", SET_ASM_OP); \
+ assemble_name (FILE, LABEL1); \
+ fprintf (FILE, ","); \
+ assemble_name (FILE, LABEL2); \
+ fprintf (FILE, ";\n"); \
+ } \
+ while (0)
+
+void
+nvptx_asm_output_def_from_decls (FILE *stream, tree name, tree value)
+{
+ if (nvptx_alias == 0 || !TARGET_PTX_6_3)
+ {
+ /* Copied from assemble_alias. */
+ error_at (DECL_SOURCE_LOCATION (name),
+ "alias definitions not supported in this configuration");
+ TREE_ASM_WRITTEN (name) = 1;
+ return;
+ }
+
+ if (lookup_attribute ("weak", DECL_ATTRIBUTES (name)))
+ {
+ /* Prevent execution FAILs for gcc.dg/globalalias.c and
+ gcc.dg/pr77587.c. */
+ error_at (DECL_SOURCE_LOCATION (name),
+ "weak alias definitions not supported in this configuration");
+ TREE_ASM_WRITTEN (name) = 1;
+ return;
+ }
+
+ /* Ptx also doesn't support value having weak linkage, but we can't detect
+ that here, so we'll end up with:
+ "error: Function test with .weak scope cannot be aliased".
+ See gcc.dg/localalias.c. */
+
+ if (TREE_CODE (name) != FUNCTION_DECL)
+ {
+ error_at (DECL_SOURCE_LOCATION (name),
+ "non-function alias definitions not supported"
+ " in this configuration");
+ TREE_ASM_WRITTEN (name) = 1;
+ return;
+ }
+
+ if (!cgraph_node::get (name)->referred_to_p ())
+ /* Prevent "Internal error: reference to deleted section". */
+ return;
+
+ std::stringstream s;
+ write_fn_proto (s, false, get_fnname_from_decl (name), name);
+ fputs (s.str ().c_str (), stream);
+
+ tree id = DECL_ASSEMBLER_NAME (name);
+ NVPTX_ASM_OUTPUT_DEF (stream, IDENTIFIER_POINTER (id),
+ IDENTIFIER_POINTER (value));
+}
+
+#undef NVPTX_ASM_OUTPUT_DEF
+#undef SET_ASM_OP
+
#undef TARGET_OPTION_OVERRIDE
#define TARGET_OPTION_OVERRIDE nvptx_option_override
((VALUE) = GET_MODE_BITSIZE ((MODE)), 2)
#define SUPPORTS_WEAK 1
+
+/* The documentation states that ASM_OUTPUT_DEF_FROM_DECLS is used in
+ preference to ASM_OUTPUT_DEF if the tree nodes are available. However, we
+ need the tree nodes to emit the prototype, so at this point it's not clear
+ how we can support ASM_OUTPUT_DEF. Still, we need to define it, or
+ ASM_OUTPUT_DEF_FROM_DECLS is ignored. For now, assert, and once we run
+ into it possibly improve by somehow emitting the prototype elsewhere, or
+ emitting a reasonable error message. */
+#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
+ do \
+ { \
+ gcc_unreachable (); \
+ } \
+ while (0)
+#define ASM_OUTPUT_DEF_FROM_DECLS(STREAM, NAME, VALUE) \
+ nvptx_asm_output_def_from_decls (STREAM, NAME, VALUE)
+
#define NO_DOT_IN_LABEL
#define ASM_COMMENT_START "//"