2016-09-08 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / gcc / config / nvptx / nvptx.h
blob381269e3bcccf946917ce5cd3eadcf286229d145
1 /* Target Definitions for NVPTX.
2 Copyright (C) 2014-2016 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 /* Alignments in bits. */
50 #define PARM_BOUNDARY 32
51 #define STACK_BOUNDARY 64
52 #define FUNCTION_BOUNDARY 32
53 #define BIGGEST_ALIGNMENT 64
54 #define STRICT_ALIGNMENT 1
56 #define MAX_STACK_ALIGNMENT (1024 * 8)
58 /* Copied from elf.h and other places. We'd otherwise use
59 BIGGEST_ALIGNMENT and fail a number of testcases. */
60 #define MAX_OFILE_ALIGNMENT (32768 * 8)
62 /* Type Layout. */
64 #define DEFAULT_SIGNED_CHAR 1
66 #define SHORT_TYPE_SIZE 16
67 #define INT_TYPE_SIZE 32
68 #define LONG_TYPE_SIZE (TARGET_ABI64 ? 64 : 32)
69 #define LONG_LONG_TYPE_SIZE 64
70 #define FLOAT_TYPE_SIZE 32
71 #define DOUBLE_TYPE_SIZE 64
72 #define LONG_DOUBLE_TYPE_SIZE 64
73 #define TARGET_SUPPORTS_WIDE_INT 1
75 #undef SIZE_TYPE
76 #define SIZE_TYPE (TARGET_ABI64 ? "long unsigned int" : "unsigned int")
77 #undef PTRDIFF_TYPE
78 #define PTRDIFF_TYPE (TARGET_ABI64 ? "long int" : "int")
80 #define POINTER_SIZE (TARGET_ABI64 ? 64 : 32)
81 #define Pmode (TARGET_ABI64 ? DImode : SImode)
83 /* Registers. Since ptx is a virtual target, we just define a few
84 hard registers for special purposes and leave pseudos unallocated.
85 We have to have some available hard registers, to keep gcc setup
86 happy. */
87 #define FIRST_PSEUDO_REGISTER 16
88 #define FIXED_REGISTERS { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
89 #define CALL_USED_REGISTERS { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
91 #define HARD_REGNO_NREGS(REG, MODE) \
92 ((void)(REG), (void)(MODE), 1)
93 #define CANNOT_CHANGE_MODE_CLASS(M1, M2, CLS) \
94 ((void)(M1), (void)(M2), (void)(CLS), true)
95 #define HARD_REGNO_MODE_OK(REG, MODE) \
96 ((void)(REG), (void)(MODE), true)
98 /* Register Classes. */
99 enum reg_class { NO_REGS, ALL_REGS, LIM_REG_CLASSES };
100 #define REG_CLASS_NAMES { "NO_REGS", "ALL_REGS" }
101 #define REG_CLASS_CONTENTS { { 0x0000 }, { 0xFFFF } }
102 #define N_REG_CLASSES (int) LIM_REG_CLASSES
104 #define GENERAL_REGS ALL_REGS
105 #define REGNO_REG_CLASS(R) ((void)(R), ALL_REGS)
106 #define BASE_REG_CLASS ALL_REGS
107 #define INDEX_REG_CLASS NO_REGS
109 #define REGNO_OK_FOR_BASE_P(X) true
110 #define REGNO_OK_FOR_INDEX_P(X) false
112 #define CLASS_MAX_NREGS(class, mode) \
113 ((GET_MODE_SIZE (mode) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
115 #define MODES_TIEABLE_P(M1, M2) false
117 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
118 if ((MODE) == QImode || (MODE) == HImode) \
120 (MODE) = SImode; \
121 (void)(UNSIGNEDP); \
122 (void)(TYPE); \
125 /* Stack and Calling. */
127 #define STARTING_FRAME_OFFSET 0
128 #define FRAME_GROWS_DOWNWARD 0
129 #define STACK_GROWS_DOWNWARD 1
131 #define NVPTX_RETURN_REGNUM 0
132 #define STACK_POINTER_REGNUM 1
133 #define FRAME_POINTER_REGNUM 2
134 #define ARG_POINTER_REGNUM 3
135 #define STATIC_CHAIN_REGNUM 4
137 #define REGISTER_NAMES \
139 "%value", "%stack", "%frame", "%args", "%chain", "%hr5", "%hr6", "%hr7", \
140 "%hr8", "%hr9", "%hr10", "%hr11", "%hr12", "%hr13", "%hr14", "%hr15" \
143 #define FIRST_PARM_OFFSET(FNDECL) ((void)(FNDECL), 0)
144 #define PUSH_ARGS_REVERSED 1
145 #define ACCUMULATE_OUTGOING_ARGS 1
147 /* Avoid using the argument pointer for frame-related things. */
148 #define FRAME_POINTER_CFA_OFFSET(FNDECL) ((void)(FNDECL), 0)
150 #ifdef HOST_WIDE_INT
151 struct nvptx_args {
152 tree fntype;
153 /* Number of arguments passed in registers so far. */
154 int count;
156 #endif
158 #define CUMULATIVE_ARGS struct nvptx_args
160 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
161 ((CUM).fntype = (FNTYPE), (CUM).count = 0, (void)0)
163 #define FUNCTION_ARG_REGNO_P(r) 0
165 #define DEFAULT_PCC_STRUCT_RETURN 0
167 #define FUNCTION_PROFILER(file, labelno) \
168 fatal_error (input_location, \
169 "profiling is not yet implemented for this architecture")
171 #define TRAMPOLINE_SIZE 32
172 #define TRAMPOLINE_ALIGNMENT 256
174 /* We don't run reload, so this isn't actually used, but it still needs to be
175 defined. Showing an argp->fp elimination also stops
176 expand_builtin_setjmp_receiver from generating invalid insns. */
177 #define ELIMINABLE_REGS \
179 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM} \
182 /* Define the offset between two registers, one to be eliminated, and the other
183 its replacement, at the start of a routine. */
185 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
186 ((OFFSET) = 0)
188 /* Addressing Modes. */
190 #define MAX_REGS_PER_ADDRESS 1
192 #define LEGITIMATE_PIC_OPERAND_P(X) 1
195 #if defined HOST_WIDE_INT
196 struct GTY(()) machine_function
198 rtx_expr_list *call_args; /* Arg list for the current call. */
199 bool doing_call; /* Within a CALL_ARGS ... CALL_ARGS_END sequence. */
200 bool is_varadic; /* This call is varadic */
201 bool has_varadic; /* Current function has a varadic call. */
202 bool has_chain; /* Current function has outgoing static chain. */
203 int num_args; /* Number of args of current call. */
204 int return_mode; /* Return mode of current fn.
205 (machine_mode not defined yet.) */
206 rtx axis_predicate[2]; /* Neutering predicates. */
208 #endif
210 /* Costs. */
212 #define NO_FUNCTION_CSE 1
213 #define SLOW_BYTE_ACCESS 0
214 #define BRANCH_COST(speed_p, predictable_p) 6
216 /* Assembler Format. */
218 #undef ASM_DECLARE_FUNCTION_NAME
219 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
220 nvptx_declare_function_name (FILE, NAME, DECL)
222 #undef ASM_DECLARE_FUNCTION_SIZE
223 #define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL) \
224 nvptx_function_end (STREAM)
226 #define DWARF2_ASM_LINE_DEBUG_INFO 1
228 #undef ASM_APP_ON
229 #define ASM_APP_ON "\t// #APP \n"
230 #undef ASM_APP_OFF
231 #define ASM_APP_OFF "\t// #NO_APP \n"
233 #define DBX_REGISTER_NUMBER(N) N
235 #define TEXT_SECTION_ASM_OP ""
236 #define DATA_SECTION_ASM_OP ""
238 #undef ASM_GENERATE_INTERNAL_LABEL
239 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
240 do \
242 char *__p; \
243 __p = stpcpy (&(LABEL)[1], PREFIX); \
244 (LABEL)[0] = '$'; \
245 sprint_ul (__p, (unsigned long) (NUM)); \
247 while (0)
249 #define ASM_OUTPUT_ALIGN(FILE, POWER) \
250 do \
252 (void) (FILE); \
253 (void) (POWER); \
255 while (0)
257 #define ASM_OUTPUT_SKIP(FILE, N) \
258 nvptx_output_skip (FILE, N)
260 #undef ASM_OUTPUT_ASCII
261 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
262 nvptx_output_ascii (FILE, STR, LENGTH);
264 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
265 nvptx_declare_object_name (FILE, NAME, DECL)
267 #undef ASM_OUTPUT_ALIGNED_DECL_COMMON
268 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \
269 nvptx_output_aligned_decl (FILE, NAME, DECL, SIZE, ALIGN)
271 #undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
272 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
273 nvptx_output_aligned_decl (FILE, NAME, DECL, SIZE, ALIGN)
275 #define CASE_VECTOR_PC_RELATIVE flag_pic
276 #define JUMP_TABLES_IN_TEXT_SECTION flag_pic
278 #define ADDR_VEC_ALIGN(VEC) (JUMP_TABLES_IN_TEXT_SECTION ? 5 : 2)
280 /* Misc. */
282 #define DWARF2_LINENO_DEBUGGING_INFO 1
284 #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
285 ((VALUE) = GET_MODE_BITSIZE ((MODE)), 2)
286 #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
287 ((VALUE) = GET_MODE_BITSIZE ((MODE)), 2)
289 #define SUPPORTS_WEAK 1
290 #define NO_DOT_IN_LABEL
291 #define ASM_COMMENT_START "//"
293 #define STORE_FLAG_VALUE -1
294 #define FLOAT_STORE_FLAG_VALUE(MODE) REAL_VALUE_ATOF("1.0", (MODE))
296 #define CASE_VECTOR_MODE SImode
297 #define MOVE_MAX 8
298 #define MOVE_RATIO(SPEED) 4
299 #define TRULY_NOOP_TRUNCATION(outprec, inprec) 1
300 #define FUNCTION_MODE QImode
301 #define HAS_INIT_SECTION 1
303 /* The C++ front end insists to link against libstdc++ -- which we don't build.
304 Tell it to instead link against the innocuous libgcc. */
305 #define LIBSTDCXX "gcc"
307 #endif /* GCC_NVPTX_H */