Fix type in the changelog entry,
[official-gcc.git] / gcc / config / nvptx / nvptx.h
blob60a922af93fec96dae016783b3aff025f88b5f00
1 /* Target Definitions for NVPTX.
2 Copyright (C) 2014-2015 Free Software Foundation, Inc.
3 Contributed by Bernd Schmidt <bernds@codesourcery.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published
9 by the Free Software Foundation; either version 3, or (at your
10 option) any later version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_NVPTX_H
22 #define GCC_NVPTX_H
24 /* Run-time Target. */
26 #define STARTFILE_SPEC "%{mmainkernel:crt0.o}"
28 #define TARGET_CPU_CPP_BUILTINS() \
29 do \
30 { \
31 builtin_assert ("machine=nvptx"); \
32 builtin_assert ("cpu=nvptx"); \
33 builtin_define ("__nvptx__"); \
34 } while (0)
36 /* Avoid the default in ../../gcc.c, which adds "-pthread", which is not
37 supported for nvptx. */
38 #define GOMP_SELF_SPECS ""
40 /* Storage Layout. */
42 #define BITS_BIG_ENDIAN 0
43 #define BYTES_BIG_ENDIAN 0
44 #define WORDS_BIG_ENDIAN 0
46 /* Chosen such that we won't have to deal with multi-word subregs. */
47 #define UNITS_PER_WORD 8
49 #define PARM_BOUNDARY 8
50 #define STACK_BOUNDARY 64
51 #define FUNCTION_BOUNDARY 32
52 #define BIGGEST_ALIGNMENT 64
53 #define STRICT_ALIGNMENT 1
55 #define MAX_STACK_ALIGNMENT (1024 * 8)
57 /* Copied from elf.h and other places. We'd otherwise use
58 BIGGEST_ALIGNMENT and fail a number of testcases. */
59 #define MAX_OFILE_ALIGNMENT (32768 * 8)
61 /* Type Layout. */
63 #define DEFAULT_SIGNED_CHAR 1
65 #define SHORT_TYPE_SIZE 16
66 #define INT_TYPE_SIZE 32
67 #define LONG_TYPE_SIZE (TARGET_ABI64 ? 64 : 32)
68 #define LONG_LONG_TYPE_SIZE 64
69 #define FLOAT_TYPE_SIZE 32
70 #define DOUBLE_TYPE_SIZE 64
71 #define LONG_DOUBLE_TYPE_SIZE 64
73 #undef SIZE_TYPE
74 #define SIZE_TYPE (TARGET_ABI64 ? "long unsigned int" : "unsigned int")
75 #undef PTRDIFF_TYPE
76 #define PTRDIFF_TYPE (TARGET_ABI64 ? "long int" : "int")
78 #define POINTER_SIZE (TARGET_ABI64 ? 64 : 32)
80 #define Pmode (TARGET_ABI64 ? DImode : SImode)
82 /* Registers. Since ptx is a virtual target, we just define a few
83 hard registers for special purposes and leave pseudos unallocated. */
85 #define FIRST_PSEUDO_REGISTER 16
86 #define FIXED_REGISTERS \
87 { 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1 }
88 #define CALL_USED_REGISTERS \
89 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
91 #define HARD_REGNO_NREGS(regno, mode) 1
92 #define CANNOT_CHANGE_MODE_CLASS(M1, M2, CLS) ((CLS) == RETURN_REG)
93 #define HARD_REGNO_MODE_OK(REG, MODE) nvptx_hard_regno_mode_ok (REG, MODE)
95 /* Register Classes. */
97 enum reg_class
99 NO_REGS,
100 RETURN_REG,
101 ALL_REGS,
102 LIM_REG_CLASSES
105 #define N_REG_CLASSES (int) LIM_REG_CLASSES
107 #define REG_CLASS_NAMES { \
108 "RETURN_REG", \
109 "NO_REGS", \
110 "ALL_REGS" }
112 #define REG_CLASS_CONTENTS \
114 /* NO_REGS. */ \
115 { 0x0000 }, \
116 /* RETURN_REG. */ \
117 { 0x0008 }, \
118 /* ALL_REGS. */ \
119 { 0xFFFF }, \
122 #define GENERAL_REGS ALL_REGS
124 #define REGNO_REG_CLASS(R) ((R) == 4 ? RETURN_REG : ALL_REGS)
126 #define BASE_REG_CLASS ALL_REGS
127 #define INDEX_REG_CLASS NO_REGS
129 #define REGNO_OK_FOR_BASE_P(X) true
130 #define REGNO_OK_FOR_INDEX_P(X) false
132 #define CLASS_MAX_NREGS(class, mode) \
133 ((GET_MODE_SIZE (mode) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
135 #define MODES_TIEABLE_P(M1, M2) false
137 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
138 if (GET_MODE_CLASS (MODE) == MODE_INT \
139 && GET_MODE_SIZE (MODE) < GET_MODE_SIZE (SImode)) \
141 (MODE) = SImode; \
144 /* Address spaces. */
145 #define ADDR_SPACE_GLOBAL 1
146 #define ADDR_SPACE_SHARED 3
147 #define ADDR_SPACE_CONST 4
148 #define ADDR_SPACE_LOCAL 5
149 #define ADDR_SPACE_PARAM 101
151 /* Stack and Calling. */
153 #define STARTING_FRAME_OFFSET 0
154 #define FRAME_GROWS_DOWNWARD 0
155 #define STACK_GROWS_DOWNWARD 1
157 #define STACK_POINTER_REGNUM 1
158 #define HARD_FRAME_POINTER_REGNUM 2
159 #define NVPTX_PUNNING_BUFFER_REGNUM 3
160 #define NVPTX_RETURN_REGNUM 4
161 #define FRAME_POINTER_REGNUM 15
162 #define ARG_POINTER_REGNUM 14
163 #define RETURN_ADDR_REGNO 13
165 #define STATIC_CHAIN_REGNUM 12
166 #define OUTGOING_ARG_POINTER_REGNUM 11
167 #define OUTGOING_STATIC_CHAIN_REGNUM 10
169 #define FIRST_PARM_OFFSET(FNDECL) 0
170 #define PUSH_ARGS_REVERSED 1
172 #define ACCUMULATE_OUTGOING_ARGS 1
174 #ifdef HOST_WIDE_INT
175 struct nvptx_args {
176 union tree_node *fntype;
177 /* Number of arguments passed in registers so far. */
178 int count;
179 /* Offset into the stdarg area so far. */
180 HOST_WIDE_INT off;
182 #endif
184 #define CUMULATIVE_ARGS struct nvptx_args
186 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
187 do { (CUM).fntype = (FNTYPE); (CUM).count = 0; (CUM).off = 0; } while (0)
189 #define FUNCTION_ARG_REGNO_P(r) 0
191 #define DEFAULT_PCC_STRUCT_RETURN 0
193 #define FUNCTION_PROFILER(file, labelno) \
194 fatal_error (input_location, \
195 "profiling is not yet implemented for this architecture")
197 #define TRAMPOLINE_SIZE 32
198 #define TRAMPOLINE_ALIGNMENT 256
200 /* We don't run reload, so this isn't actually used, but it still needs to be
201 defined. Showing an argp->fp elimination also stops
202 expand_builtin_setjmp_receiver from generating invalid insns. */
203 #define ELIMINABLE_REGS \
205 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
206 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM} \
209 /* Define the offset between two registers, one to be eliminated, and the other
210 its replacement, at the start of a routine. */
212 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
213 ((OFFSET) = 0)
215 /* Addressing Modes. */
217 #define MAX_REGS_PER_ADDRESS 1
219 #define LEGITIMATE_PIC_OPERAND_P(X) 1
222 #if defined HOST_WIDE_INT
223 struct GTY(()) machine_function
225 rtx_expr_list *call_args;
226 rtx start_call;
227 tree funtype;
228 bool has_call_with_varargs;
229 bool has_call_with_sc;
230 HOST_WIDE_INT outgoing_stdarg_size;
231 int ret_reg_mode;
232 int punning_buffer_size;
234 #endif
236 /* Costs. */
238 #define NO_FUNCTION_CSE 1
239 #define SLOW_BYTE_ACCESS 0
240 #define BRANCH_COST(speed_p, predictable_p) 6
242 /* Assembler Format. */
244 #undef ASM_DECLARE_FUNCTION_NAME
245 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
246 nvptx_declare_function_name (FILE, NAME, DECL)
248 #undef ASM_DECLARE_FUNCTION_SIZE
249 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL) \
250 nvptx_function_end (STREAM)
252 #define DWARF2_ASM_LINE_DEBUG_INFO 1
254 #undef ASM_APP_ON
255 #define ASM_APP_ON "\t// #APP \n"
256 #undef ASM_APP_OFF
257 #define ASM_APP_OFF "\t// #NO_APP \n"
259 #define ASM_OUTPUT_COMMON(stream, name, size, rounded)
260 #define ASM_OUTPUT_LOCAL(stream, name, size, rounded)
262 #define REGISTER_NAMES \
264 "%hr0", "%outargs", "%hfp", "%punbuffer", "%retval", "%retval_in", "%hr6", "%hr7", \
265 "%hr8", "%hr9", "%hr10", "%hr11", "%hr12", "%hr13", "%argp", "%frame" \
268 #define DBX_REGISTER_NUMBER(N) N
270 #define TEXT_SECTION_ASM_OP ""
271 #define DATA_SECTION_ASM_OP ""
273 #undef ASM_GENERATE_INTERNAL_LABEL
274 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
275 do \
277 char *__p; \
278 __p = stpcpy (&(LABEL)[1], PREFIX); \
279 (LABEL)[0] = '$'; \
280 sprint_ul (__p, (unsigned long) (NUM)); \
282 while (0)
284 #define ASM_OUTPUT_ALIGN(FILE, POWER) \
285 do \
287 (void) (FILE); \
288 (void) (POWER); \
290 while (0)
292 #define ASM_OUTPUT_SKIP(FILE, N) \
293 nvptx_output_skip (FILE, N)
295 #undef ASM_OUTPUT_ASCII
296 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
297 nvptx_output_ascii (FILE, STR, LENGTH);
299 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
300 nvptx_declare_object_name (FILE, NAME, DECL)
302 #undef ASM_OUTPUT_ALIGNED_DECL_COMMON
303 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \
304 do \
306 fprintf (FILE, "// BEGIN%s VAR DEF: ", \
307 TREE_PUBLIC (DECL) ? " GLOBAL" : ""); \
308 assemble_name_raw (FILE, NAME); \
309 fputc ('\n', FILE); \
310 const char *sec = nvptx_section_for_decl (DECL); \
311 fprintf (FILE, ".visible%s.align %d .b8 ", sec, \
312 (ALIGN) / BITS_PER_UNIT); \
313 assemble_name ((FILE), (NAME)); \
314 if ((SIZE) > 0) \
315 fprintf (FILE, "[" HOST_WIDE_INT_PRINT_DEC"]", (SIZE)); \
316 fprintf (FILE, ";\n"); \
318 while (0)
320 #undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
321 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
322 do \
324 fprintf (FILE, "// BEGIN VAR DEF: "); \
325 assemble_name_raw (FILE, NAME); \
326 fputc ('\n', FILE); \
327 const char *sec = nvptx_section_for_decl (DECL); \
328 fprintf (FILE, ".visible%s.align %d .b8 ", sec, \
329 (ALIGN) / BITS_PER_UNIT); \
330 assemble_name ((FILE), (NAME)); \
331 if ((SIZE) > 0) \
332 fprintf (FILE, "[" HOST_WIDE_INT_PRINT_DEC"]", (SIZE)); \
333 fprintf (FILE, ";\n"); \
335 while (0)
337 #define CASE_VECTOR_PC_RELATIVE flag_pic
338 #define JUMP_TABLES_IN_TEXT_SECTION flag_pic
340 #define ADDR_VEC_ALIGN(VEC) (JUMP_TABLES_IN_TEXT_SECTION ? 5 : 2)
342 /* Misc. */
344 #define DWARF2_LINENO_DEBUGGING_INFO 1
346 #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
347 ((VALUE) = GET_MODE_BITSIZE ((MODE)), 2)
348 #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
349 ((VALUE) = GET_MODE_BITSIZE ((MODE)), 2)
351 #define NO_DOT_IN_LABEL
352 #define ASM_COMMENT_START "//"
354 #define STORE_FLAG_VALUE -1
355 #define FLOAT_STORE_FLAG_VALUE(MODE) REAL_VALUE_ATOF("1.0", (MODE))
357 #define CASE_VECTOR_MODE SImode
358 #define MOVE_MAX 4
359 #define MOVE_RATIO(SPEED) 4
360 #define TRULY_NOOP_TRUNCATION(outprec, inprec) 1
361 #define FUNCTION_MODE QImode
362 #define HAS_INIT_SECTION 1
364 /* The C++ front end insists to link against libstdc++ -- which we don't build.
365 Tell it to instead link against the innocuous libgcc. */
366 #define LIBSTDCXX "gcc"
368 #endif /* GCC_NVPTX_H */