2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / config / alpha / unicosmk.h
blob4a24bd59321cb6fd03f7f81f194e92fb3e93f39f
1 /* Definitions of target machine for GNU compiler, for DEC Alpha on Cray
2 T3E running Unicos/Mk.
3 Copyright (C) 2001, 2002, 2004, 2005, 2007
4 Free Software Foundation, Inc.
5 Contributed by Roman Lechtchinsky (rl@cs.tu-berlin.de)
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
14 GCC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
23 #undef TARGET_ABI_UNICOSMK
24 #define TARGET_ABI_UNICOSMK 1
26 /* CAM requires a slash before floating-pointing instruction suffixes. */
28 #undef TARGET_AS_SLASH_BEFORE_SUFFIX
29 #define TARGET_AS_SLASH_BEFORE_SUFFIX 1
31 /* The following defines are necessary for the standard headers to work
32 correctly. */
34 #define TARGET_OS_CPP_BUILTINS() \
35 do { \
36 builtin_define ("__unix"); \
37 builtin_define ("_UNICOS=205"); \
38 builtin_define ("_CRAY"); \
39 builtin_define ("_CRAYT3E"); \
40 builtin_define ("_CRAYMPP"); \
41 builtin_define ("_CRAYIEEE"); \
42 builtin_define ("_ADDR64"); \
43 builtin_define ("_LD64"); \
44 builtin_define ("__UNICOSMK__"); \
45 } while (0)
47 #define SHORT_TYPE_SIZE 32
49 #undef INT_TYPE_SIZE
50 #define INT_TYPE_SIZE 64
52 /* This is consistent with the definition Cray CC uses. */
53 #undef WCHAR_TYPE
54 #define WCHAR_TYPE "int"
55 #undef WCHAR_TYPE_SIZE
56 #define WCHAR_TYPE_SIZE 64
59 #define SIZE_TYPE "unsigned int"
60 #define PTRDIFF_TYPE "int"
63 /* Alphas are operated in big endian mode on the Cray T3E. */
65 #undef BITS_BIG_ENDIAN
66 #undef BYTES_BIG_ENDIAN
67 #undef WORDS_BIG_ENDIAN
68 #define BITS_BIG_ENDIAN 0
69 #define BYTES_BIG_ENDIAN 1
70 #define WORDS_BIG_ENDIAN 1
73 /* Every structure's size must be a multiple of this. */
75 #undef STRUCTURE_SIZE_BOUNDARY
76 #define STRUCTURE_SIZE_BOUNDARY 64
78 /* No data type wants to be aligned rounder than this. */
80 #undef BIGGEST_ALIGNMENT
81 #define BIGGEST_ALIGNMENT 256
83 /* Include the frame pointer in fixed_regs and call_used_regs as it can't be
84 used as a general-purpose register even in frameless functions.
85 ??? The global_regs hack is needed for now because -O2 sometimes tries to
86 eliminate $15 increments/decrements in frameless functions. */
88 #undef CONDITIONAL_REGISTER_USAGE
89 #define CONDITIONAL_REGISTER_USAGE \
90 do { \
91 fixed_regs[15] = 1; \
92 call_used_regs[15] = 1; \
93 global_regs[15] = 1; \
94 } while(0)
96 /* The stack frame grows downward. */
98 #define FRAME_GROWS_DOWNWARD 1
100 /* Define the offset between two registers, one to be eliminated, and the
101 other its replacement, at the start of a routine. This is somewhat
102 complicated on the T3E which is why we use a function. */
104 #undef INITIAL_ELIMINATION_OFFSET
105 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
106 do { \
107 (OFFSET) = unicosmk_initial_elimination_offset ((FROM), (TO)); \
108 } while (0)
111 /* Define this if stack space is still allocated for a parameter passed
112 in a register. On the T3E, stack space is preallocated for all outgoing
113 arguments, including those passed in registers. To avoid problems, we
114 assume that at least 48 bytes (i.e. enough space for all arguments passed
115 in registers) are allocated. */
117 #define REG_PARM_STACK_SPACE(DECL) 48
118 #define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
120 /* If an argument can't be passed in registers even though not all argument
121 registers have been used yet, it is passed on the stack in the space
122 preallocated for these registers. */
124 #define STACK_PARMS_IN_REG_PARM_AREA
126 /* Define a data type for recording info about an argument list
127 during the scan of that argument list. This data type should
128 hold all necessary information about the function itself
129 and about the args processed so far, enough to enable macros
130 such as FUNCTION_ARG to determine where the next arg should go.
132 On Unicos/Mk, this is a structure that contains various information for
133 the static subroutine information block (SSIB) and the call information
134 word (CIW). */
136 typedef struct {
138 /* The overall number of arguments. */
139 int num_args;
141 /* The overall size of the arguments in words. */
142 int num_arg_words;
144 /* The number of words passed in registers. */
145 int num_reg_words;
147 /* If an argument must be passed in the stack, all subsequent arguments
148 must be passed there, too. This flag indicates whether this is the
149 case. */
150 int force_stack;
152 /* This array indicates whether a word is passed in an integer register or
153 a floating point one. */
155 /* For each of the 6 register arguments, the corresponding flag in this
156 array indicates whether the argument is passed in an integer or a
157 floating point register. */
158 int reg_args_type[6];
160 } unicosmk_arg_info;
162 #undef CUMULATIVE_ARGS
163 #define CUMULATIVE_ARGS unicosmk_arg_info
165 /* Initialize a variable CUM of type CUMULATIVE_ARGS for a call to a
166 function whose data type is FNTYPE. For a library call, FNTYPE is 0. */
168 #undef INIT_CUMULATIVE_ARGS
169 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
170 do { (CUM).num_args = 0; \
171 (CUM).num_arg_words = 0; \
172 (CUM).num_reg_words = 0; \
173 (CUM).force_stack = 0; \
174 } while(0)
176 /* Update the data in CUM to advance over an argument of mode MODE and data
177 type TYPE. (TYPE is null for libcalls where that information may not be
178 available.)
180 On Unicos/Mk, at most 6 words can be passed in registers. Structures
181 which fit in two words are passed in registers, larger structures are
182 passed on stack. */
184 #undef FUNCTION_ARG_ADVANCE
185 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
186 do { \
187 int size; \
189 size = ALPHA_ARG_SIZE (MODE, TYPE, NAMED); \
191 if (size > 2 \
192 || (CUM).num_reg_words + size > 6 \
193 || targetm.calls.must_pass_in_stack (MODE, TYPE)) \
194 (CUM).force_stack = 1; \
196 if (! (CUM).force_stack) \
198 int i; \
199 int isfloat; \
200 isfloat = (GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \
201 || GET_MODE_CLASS (MODE) == MODE_FLOAT); \
202 for (i = 0; i < size; i++) \
204 (CUM).reg_args_type[(CUM).num_reg_words] = isfloat; \
205 ++(CUM).num_reg_words; \
208 (CUM).num_arg_words += size; \
209 ++(CUM).num_args; \
210 } while(0)
212 /* This ensures that $15 increments/decrements in leaf functions won't get
213 eliminated. */
215 #undef EPILOGUE_USES
216 #define EPILOGUE_USES(REGNO) ((REGNO) == 26 || (REGNO) == 15)
218 /* Would have worked, only the stack doesn't seem to be executable
219 #undef TRAMPOLINE_TEMPLATE
220 #define TRAMPOLINE_TEMPLATE(FILE) \
221 do { fprintf (FILE, "\tbr $1,0\n"); \
222 fprintf (FILE, "\tldq $0,12($1)\n"); \
223 fprintf (FILE, "\tldq $1,20($1)\n"); \
224 fprintf (FILE, "\tjmp $31,(r0)\n"); \
225 fprintf (FILE, "\tbis $31,$31,$31\n"); \
226 fprintf (FILE, "\tbis $31,$31,$31\n"); \
227 } while (0) */
229 /* We don't support nested functions (yet). */
231 #undef TRAMPOLINE_TEMPLATE
232 #define TRAMPOLINE_TEMPLATE(FILE) gcc_unreachable ()
234 /* Specify the machine mode that this machine uses for the index in the
235 tablejump instruction. On Unicos/Mk, we don't support relative case
236 vectors yet, thus the entries should be absolute addresses. */
238 #undef CASE_VECTOR_MODE
239 #define CASE_VECTOR_MODE DImode
241 #undef CASE_VECTOR_PC_RELATIVE
243 /* Define this as 1 if `char' should by default be signed; else as 0. */
244 /* #define DEFAULT_SIGNED_CHAR 1 */
246 /* There are no read-only sections on Unicos/Mk. */
248 #undef READONLY_DATA_SECTION_ASM_OP
250 /* We take care of this in unicosmk_file_start. */
252 #undef ASM_OUTPUT_SOURCE_FILENAME
254 /* This is how to output a label for a jump table. Arguments are the same as
255 for (*targetm.asm_out.internal_label), except the insn for the jump table is
256 passed. */
258 #undef ASM_OUTPUT_CASE_LABEL
259 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLEINSN) \
260 (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM)
262 /* CAM has some restrictions with respect to string literals. It won't
263 accept lines with more that 256 characters which means that we have
264 to split long strings. Moreover, it only accepts escape sequences of
265 the form \nnn in the range 0 to 127. We generate .byte directives for
266 escapes characters greater than 127. And finally, ` must be escaped. */
268 #undef ASM_OUTPUT_ASCII
269 #define ASM_OUTPUT_ASCII(MYFILE, MYSTRING, MYLENGTH) \
270 do { \
271 FILE *_hide_asm_out_file = (MYFILE); \
272 const unsigned char *_hide_p = (const unsigned char *) (MYSTRING); \
273 int _hide_thissize = (MYLENGTH); \
274 int _size_so_far = 0; \
276 FILE *asm_out_file = _hide_asm_out_file; \
277 const unsigned char *p = _hide_p; \
278 int thissize = _hide_thissize; \
279 int in_ascii = 0; \
280 int i; \
282 for (i = 0; i < thissize; i++) \
284 register int c = p[i]; \
286 if (c > 127) \
288 if (in_ascii) \
290 fprintf (asm_out_file, "\"\n"); \
291 in_ascii = 0; \
294 fprintf (asm_out_file, "\t.byte\t%d\n", c); \
296 else \
298 if (! in_ascii) \
300 fprintf (asm_out_file, "\t.ascii\t\""); \
301 in_ascii = 1; \
302 _size_so_far = 0; \
304 else if (_size_so_far >= 64) \
306 fprintf (asm_out_file, "\"\n\t.ascii\t\""); \
307 _size_so_far = 0; \
310 if (c == '\"' || c == '\\' || c == '`') \
311 putc ('\\', asm_out_file); \
312 if (c >= ' ') \
313 putc (c, asm_out_file); \
314 else \
315 fprintf (asm_out_file, "\\%.3o", c); \
316 ++ _size_so_far; \
319 if (in_ascii) \
320 fprintf (asm_out_file, "\"\n"); \
322 } while(0)
324 /* This is how to output an element of a case-vector that is absolute. */
326 #undef ASM_OUTPUT_ADDR_VEC_ELT
327 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
328 fprintf (FILE, "\t.quad $L%d\n", (VALUE))
330 /* This is how to output an element of a case-vector that is relative.
331 (Unicos/Mk does not use such vectors yet). */
333 #undef ASM_OUTPUT_ADDR_DIFF_ELT
334 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) gcc_unreachable ()
336 /* We can't output case vectors in the same section as the function code
337 because CAM doesn't allow data definitions in code sections. Thus, we
338 simply record the case vectors and put them in a separate section after
339 the function. */
341 #define ASM_OUTPUT_ADDR_VEC(LAB,VEC) \
342 unicosmk_defer_case_vector ((LAB),(VEC))
344 #define ASM_OUTPUT_ADDR_DIFF_VEC(LAB,VEC) gcc_unreachable ()
346 /* This is how to output an assembler line that says to advance the location
347 counter to a multiple of 2**LOG bytes. Annoyingly, CAM always uses zeroes
348 to fill the unused space which does not work in code sections. We have to
349 be careful not to use the .align directive in code sections. */
351 #undef ASM_OUTPUT_ALIGN
352 #define ASM_OUTPUT_ALIGN(STREAM,LOG) unicosmk_output_align (STREAM, LOG)
354 /* This is how to advance the location counter by SIZE bytes. */
356 #undef ASM_OUTPUT_SKIP
357 #define ASM_OUTPUT_SKIP(STREAM,SIZE) \
358 fprintf ((STREAM), "\t.byte\t0:"HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
359 (SIZE));
361 /* This says how to output an assembler line to define a global common
362 symbol. We need the alignment information because it has to be supplied
363 in the section header. */
365 #undef ASM_OUTPUT_COMMON
366 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
367 unicosmk_output_common ((FILE), (NAME), (SIZE), (ALIGN))
369 /* This says how to output an assembler line to define a local symbol. */
371 #undef ASM_OUTPUT_LOCAL
372 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
373 do { switch_to_section (data_section); \
374 fprintf (FILE, "\t.align\t%d\n", floor_log2 ((ALIGN) / BITS_PER_UNIT));\
375 ASM_OUTPUT_LABEL ((FILE), (NAME)); \
376 fprintf (FILE, "\t.byte 0:"HOST_WIDE_INT_PRINT_UNSIGNED"\n",(SIZE));\
377 } while (0)
379 /* CAM does not allow us to declare a symbol as external first and then
380 define it in the same file later. Thus, we keep a list of all external
381 references, remove all symbols defined locally from it and output it at
382 the end of the asm file. */
384 #define ASM_OUTPUT_EXTERNAL(FILE,DECL,NAME) \
385 unicosmk_add_extern ((NAME))
387 #define ASM_OUTPUT_EXTERNAL_LIBCALL(STREAM,SYMREF) \
388 unicosmk_add_extern (XSTR ((SYMREF), 0))
390 /* This is how to declare an object. We don't have to output anything if
391 it is a global variable because those go into unique `common' sections
392 and the section name is globally visible. For local variables, we simply
393 output the label. In any case, we have to record that no extern
394 declaration should be generated for the symbol. */
396 #define ASM_DECLARE_OBJECT_NAME(STREAM,NAME,DECL) \
397 do { tree name_tree; \
398 name_tree = get_identifier ((NAME)); \
399 TREE_ASM_WRITTEN (name_tree) = 1; \
400 if (!TREE_PUBLIC (DECL)) \
402 assemble_name (STREAM, NAME); \
403 fputs (":\n", STREAM); \
405 } while(0)
407 /* Switch into a generic section. */
408 #define TARGET_ASM_NAMED_SECTION unicosmk_asm_named_section
409 #define TARGET_ASM_INIT_SECTIONS unicosmk_init_sections
411 #undef ASM_OUTPUT_MAX_SKIP_ALIGN
412 #define ASM_OUTPUT_MAX_SKIP_ALIGN(STREAM,POWER,MAXSKIP)
414 #undef NM_FLAGS
416 #undef OBJECT_FORMAT_COFF
418 /* We cannot generate debugging information on Unicos/Mk. */
420 #undef SDB_DEBUGGING_INFO
421 #undef MIPS_DEBUGGING_INFO
422 #undef DBX_DEBUGGING_INFO
423 #undef DWARF2_DEBUGGING_INFO
424 #undef DWARF2_UNWIND_INFO
425 #undef INCOMING_RETURN_ADDR_RTX
426 #undef PREFERRED_DEBUGGING_TYPE
428 /* We don't need a start file. */
430 #undef STARTFILE_SPEC
431 #define STARTFILE_SPEC ""
433 /* These are the libraries we have to link with.
434 ??? The Craylibs directory should be autoconfed. */
435 #undef LIB_SPEC
436 #define LIB_SPEC "-L/opt/ctl/craylibs/craylibs -lu -lm -lc -lsma"
438 #define EH_FRAME_IN_DATA_SECTION 1