]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/gcn/gcn-hsa.h
1 /* Copyright (C) 2016-2022 Free Software Foundation, Inc.
3 This file is free software; you can redistribute it and/or modify it under
4 the terms of the GNU General Public License as published by the Free
5 Software Foundation; either version 3 of the License, or (at your option)
8 This file is distributed in the hope that it will be useful, but WITHOUT
9 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 You should have received a copy of the GNU General Public License
14 along with GCC; see the file COPYING3. If not see
15 <http://www.gnu.org/licenses/>. */
17 #ifndef OBJECT_FORMAT_ELF
18 #error elf.h included before elfos.h
21 #define TEXT_SECTION_ASM_OP "\t.text"
22 #define BSS_SECTION_ASM_OP "\t.bss"
23 #define GLOBAL_ASM_OP "\t.globl\t"
24 #define DATA_SECTION_ASM_OP "\t.data\t"
25 #define SET_ASM_OP "\t.set\t"
26 #define LOCAL_LABEL_PREFIX "."
27 #define USER_LABEL_PREFIX ""
28 #define ASM_COMMENT_START ";"
29 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
31 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
32 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
34 #undef ASM_DECLARE_FUNCTION_NAME
35 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
36 gcn_hsa_declare_function_name ((FILE), (NAME), (DECL))
38 /* Unlike GNU as, the LLVM assembler uses log2 alignments. */
39 #undef ASM_OUTPUT_ALIGNED_COMMON
40 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGNMENT) \
41 (fprintf ((FILE), "%s", COMMON_ASM_OP), \
42 assemble_name ((FILE), (NAME)), \
43 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED ",%u\n", \
44 (SIZE) > 0 ? (SIZE) : 1, exact_log2 ((ALIGNMENT) / BITS_PER_UNIT)))
46 #define ASM_OUTPUT_LABEL(FILE,NAME) \
47 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
49 #define ASM_OUTPUT_LABELREF(FILE, NAME) \
50 asm_fprintf (FILE, "%U%s", default_strip_name_encoding (NAME))
52 extern unsigned int gcn_local_sym_hash (const char *name
);
54 #define ASM_OUTPUT_SYMBOL_REF(FILE, X) gcn_asm_output_symbol_ref (FILE, X)
56 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
57 fprintf (FILE, "\t.word .L%d-.L%d\n", VALUE, REL)
59 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
60 fprintf (FILE, "\t.word .L%d\n", VALUE)
62 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
63 do { if (LOG!=0) fprintf (FILE, "\t.align\t%d\n", 1<<(LOG)); } while (0)
64 #define ASM_OUTPUT_ALIGN_WITH_NOP(FILE,LOG) \
67 fprintf (FILE, "\t.p2alignl\t%d, 0xBF800000" \
68 " ; Fill value is 's_nop 0'\n", (LOG)); \
72 #define ASM_APP_OFF ""
74 /* Avoid the default in ../../gcc.cc, which adds "-pthread", which is not
76 #define GOMP_SELF_SPECS ""
78 #ifdef HAVE_GCN_XNACK_FIJI
81 #define X_FIJI "!march=*:;march=fiji:;"
83 #ifdef HAVE_GCN_XNACK_GFX900
86 #define X_900 "march=gfx900:;"
88 #ifdef HAVE_GCN_XNACK_GFX906
91 #define X_906 "march=gfx906:;"
93 #ifdef HAVE_GCN_XNACK_GFX908
96 #define X_908 "march=gfx908:;"
99 /* These targets can't have SRAM-ECC, even if a broken assembler allows it. */
100 #define S_FIJI "!march=*:;march=fiji:;"
101 #define S_900 "march=gfx900:;"
102 #define S_906 "march=gfx906:;"
103 #ifdef HAVE_GCN_SRAM_ECC_GFX908
106 #define S_908 "march=gfx908:;"
109 #ifdef HAVE_GCN_ASM_V3_SYNTAX
110 #define SRAMOPT "!msram-ecc=off:-mattr=+sram-ecc;:-mattr=-sram-ecc"
112 #ifdef HAVE_GCN_ASM_V4_SYNTAX
113 /* In HSACOv4 no attribute setting means the binary supports "any" hardware
114 configuration. The name of the attribute also changed. */
115 #define SRAMOPT "msram-ecc=on:-mattr=+sramecc;msram-ecc=off:-mattr=-sramecc"
117 #if !defined(SRAMOPT) && !defined(IN_LIBGCC2)
118 #error "No assembler syntax configured"
121 #ifdef HAVE_GCN_ASM_V4_SYNTAX
122 /* FIJI cards don't seem to support drivers new enough to allow HSACOv4. */
123 #define HSACO3_SELECT_OPT \
124 "%{!march=*|march=fiji:--amdhsa-code-object-version=3} "
126 #define HSACO3_SELECT_OPT
129 /* These targets can't have SRAM-ECC, even if a broken assembler allows it. */
130 #define DRIVER_SELF_SPECS \
131 "%{march=fiji|march=gfx900|march=gfx906:%{!msram-ecc=*:-msram-ecc=off}}"
133 /* Use LLVM assembler and linker options. */
134 #define ASM_SPEC "-triple=amdgcn--amdhsa " \
135 "%:last_arg(%{march=*:-mcpu=%*}) " \
137 "%{" X_FIJI X_900 X_906 X_908 \
138 "mxnack:-mattr=+xnack;:-mattr=-xnack} " \
139 "%{" S_FIJI S_900 S_906 S_908 SRAMOPT "} " \
141 #define LINK_SPEC "--pie --export-dynamic"
142 #define LIB_SPEC "-lc"
144 /* Provides a _start symbol to keep the linker happy. */
145 #define STARTFILE_SPEC "crt0.o%s"
146 #define ENDFILE_SPEC ""
147 #define STANDARD_STARTFILE_PREFIX_2 ""
149 /* The LLVM assembler rejects multiple -mcpu options, so we must drop
151 extern const char *last_arg_spec_function (int argc
, const char **argv
);
152 #define EXTRA_SPEC_FUNCTIONS \
153 { "last_arg", last_arg_spec_function },
155 #undef LOCAL_INCLUDE_DIR
157 /* FIXME: Review debug info settings.
158 * In particular, EH_FRAME_THROUGH_COLLECT2 is probably the wrong
159 * thing but stuff fails to build without it.
160 * (Debug info is not a big deal until we get a debugger.) */
161 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
162 #define DWARF2_DEBUGGING_INFO 1
163 #define DWARF2_ASM_LINE_DEBUG_INFO 1
164 #define EH_FRAME_THROUGH_COLLECT2 1
165 #define DBX_REGISTER_NUMBER(REGNO) gcn_dwarf_register_number (REGNO)