2012-11-28 Oleg Raikhman <oleg@adapteva.com>
[official-gcc.git] / gcc / config / epiphany / epiphany.h
blob26a908a67ce295690bf3b572e8d6a1945f72c363
1 /* Definitions of target machine for GNU compiler, Argonaut EPIPHANY cpu.
2 Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005,
3 2007, 2009, 2011 Free Software Foundation, Inc.
4 Contributed by Embecosm on behalf of Adapteva, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #ifndef GCC_EPIPHANY_H
23 #define GCC_EPIPHANY_H
25 #undef LINK_SPEC
26 #undef STARTFILE_SPEC
27 #undef ENDFILE_SPEC
28 #undef SIZE_TYPE
29 #undef PTRDIFF_TYPE
30 #undef WCHAR_TYPE
31 #undef WCHAR_TYPE_SIZE
33 /* Names to predefine in the preprocessor for this target machine. */
34 #define TARGET_CPU_CPP_BUILTINS() \
35 do \
36 { \
37 builtin_define ("__epiphany__"); \
38 builtin_define ("__little_endian__"); \
39 builtin_define_with_int_value ("__EPIPHANY_STACK_OFFSET__", \
40 epiphany_stack_offset); \
41 builtin_assert ("cpu=epiphany"); \
42 builtin_assert ("machine=epiphany"); \
43 } while (0)
45 /* Pick up the libgloss library. One day we may do this by linker script, but
46 for now its static.
47 libgloss might use errno/__errno, which might not have been needed when we
48 saw libc the first time, so link with libc a second time. */
49 #undef LIB_SPEC
50 #define LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}} -lepiphany %{!shared:%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
52 #define LINK_SPEC "%{v}"
54 #define STARTFILE_SPEC "%{!shared:crt0.o%s} crti.o%s " \
55 "%{mfp-mode=int:crtint.o%s} %{mfp-mode=truncate:crtrunc.o%s} " \
56 "%{m1reg-r43:crtm1reg-r43.o%s} %{m1reg-r63:crtm1reg-r63.o%s} " \
57 "crtbegin.o%s"
59 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
61 #undef USER_LABEL_PREFIX
62 #define USER_LABEL_PREFIX "_"
64 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
65 asm (SECTION_OP "\n\
66 mov r0,%low(" USER_LABEL_PREFIX #FUNC")\n\
67 movt r0,%high(" USER_LABEL_PREFIX #FUNC")\n\
68 jalr r0\n\
69 .text");
71 #if 0 /* We would like to use Posix for profiling, but the simulator
72 interface still lacks mkdir. */
73 #define TARGET_POSIX_IO
74 #endif
76 /* Target machine storage layout. */
78 /* Define this if most significant bit is lowest numbered
79 in instructions that operate on numbered bit-fields. */
80 #define BITS_BIG_ENDIAN 0
82 /* Define this if most significant byte of a word is the lowest numbered. */
83 #define BYTES_BIG_ENDIAN 0
85 /* Define this if most significant word of a multiword number is the lowest
86 numbered. */
87 #define WORDS_BIG_ENDIAN 0
89 /* Width of a word, in units (bytes). */
90 #define UNITS_PER_WORD 4
92 /* Define this macro if it is advisable to hold scalars in registers
93 in a wider mode than that declared by the program. In such cases,
94 the value is constrained to be within the bounds of the declared
95 type, but kept valid in the wider mode. The signedness of the
96 extension may differ from that of the type. */
97 /* It is far faster to zero extend chars than to sign extend them */
99 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
100 if (GET_MODE_CLASS (MODE) == MODE_INT \
101 && GET_MODE_SIZE (MODE) < 4) \
103 if (MODE == QImode) \
104 UNSIGNEDP = 1; \
105 else if (MODE == HImode) \
106 UNSIGNEDP = 1; \
107 (MODE) = SImode; \
110 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
111 #define PARM_BOUNDARY 32
113 /* Boundary (in *bits*) on which stack pointer should be aligned. */
114 #define STACK_BOUNDARY 64
116 /* ALIGN FRAMES on word boundaries */
117 #define EPIPHANY_STACK_ALIGN(LOC) (((LOC)+7) & ~7)
119 /* Allocation boundary (in *bits*) for the code of a function. */
120 #define FUNCTION_BOUNDARY 32
122 /* Every structure's size must be a multiple of this. */
123 #define STRUCTURE_SIZE_BOUNDARY 8
125 /* A bit-field declared as `int' forces `int' alignment for the struct. */
126 #define PCC_BITFIELD_TYPE_MATTERS 1
128 /* No data type wants to be aligned rounder than this. */
129 /* This is bigger than currently necessary for the EPIPHANY. If 8 byte floats are
130 ever added it's not clear whether they'll need such alignment or not. For
131 now we assume they will. We can always relax it if necessary but the
132 reverse isn't true. */
133 #define BIGGEST_ALIGNMENT 64
135 /* The best alignment to use in cases where we have a choice. */
136 #define FASTEST_ALIGNMENT 64
138 #define MALLOC_ABI_ALIGNMENT BIGGEST_ALIGNMENT
140 /* Make strings dword-aligned so strcpy from constants will be faster. */
141 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
142 ((TREE_CODE (EXP) == STRING_CST \
143 && (ALIGN) < FASTEST_ALIGNMENT) \
144 ? FASTEST_ALIGNMENT : (ALIGN))
146 /* Make arrays of chars dword-aligned for the same reasons.
147 Also, align arrays of SImode items. */
148 #define DATA_ALIGNMENT(TYPE, ALIGN) \
149 (TREE_CODE (TYPE) == ARRAY_TYPE \
150 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
151 && (ALIGN) < FASTEST_ALIGNMENT \
152 ? FASTEST_ALIGNMENT \
153 : (TREE_CODE (TYPE) == ARRAY_TYPE \
154 && TYPE_MODE (TREE_TYPE (TYPE)) == SImode \
155 && (ALIGN) < FASTEST_ALIGNMENT) \
156 ? FASTEST_ALIGNMENT \
157 : (ALIGN))
159 /* Set this nonzero if move instructions will actually fail to work
160 when given unaligned data. */
161 /* On the EPIPHANY the lower address bits are masked to 0 as necessary. The chip
162 won't croak when given an unaligned address, but the insn will still fail
163 to produce the correct result. */
164 #define STRICT_ALIGNMENT 1
166 /* layout_type overrides our ADJUST_ALIGNMENT settings from epiphany-modes.def
167 for vector modes, so we have to override it back. */
168 #define ROUND_TYPE_ALIGN(TYPE, MANGLED_ALIGN, SPECIFIED_ALIGN) \
169 (TREE_CODE (TYPE) == VECTOR_TYPE && !TYPE_USER_ALIGN (TYPE) \
170 && SPECIFIED_ALIGN <= GET_MODE_ALIGNMENT (TYPE_MODE (TYPE)) \
171 ? GET_MODE_ALIGNMENT (TYPE_MODE (TYPE)) \
172 : ((TREE_CODE (TYPE) == RECORD_TYPE \
173 || TREE_CODE (TYPE) == UNION_TYPE \
174 || TREE_CODE (TYPE) == QUAL_UNION_TYPE) \
175 && !TYPE_PACKED (TYPE)) \
176 ? epiphany_special_round_type_align ((TYPE), (MANGLED_ALIGN), \
177 (SPECIFIED_ALIGN)) \
178 : MAX ((MANGLED_ALIGN), (SPECIFIED_ALIGN)))
180 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
181 epiphany_adjust_field_align((FIELD), (COMPUTED))
183 /* Layout of source language data types. */
185 #define SHORT_TYPE_SIZE 16
186 #define INT_TYPE_SIZE 32
187 #define LONG_TYPE_SIZE 32
188 #define LONG_LONG_TYPE_SIZE 64
189 #define FLOAT_TYPE_SIZE 32
190 #define DOUBLE_TYPE_SIZE 64
191 #define LONG_DOUBLE_TYPE_SIZE 64
193 /* Define this as 1 if `char' should by default be signed; else as 0. */
194 #define DEFAULT_SIGNED_CHAR 0
196 #define SIZE_TYPE "long unsigned int"
197 #define PTRDIFF_TYPE "long int"
198 #define WCHAR_TYPE "unsigned int"
199 #define WCHAR_TYPE_SIZE BITS_PER_WORD
201 /* Standard register usage. */
203 /* Number of actual hardware registers.
204 The hardware registers are assigned numbers for the compiler
205 from 0 to just below FIRST_PSEUDO_REGISTER.
206 All registers that the compiler knows about must be given numbers,
207 even those that are not normally considered general registers. */
209 #define FIRST_PSEUDO_REGISTER 78
212 /* General purpose registers. */
213 #define GPR_FIRST 0 /* First gpr */
215 #define PIC_REGNO (GPR_FIRST + 28) /* PIC register. */
216 #define GPR_LAST (GPR_FIRST + 63) /* Last gpr */
217 #define CORE_CONTROL_FIRST CONFIG_REGNUM
218 #define CORE_CONTROL_LAST IRET_REGNUM
220 #define GPR_P(R) IN_RANGE (R, GPR_FIRST, GPR_LAST)
221 #define GPR_OR_AP_P(R) (GPR_P (R) || (R) == ARG_POINTER_REGNUM)
223 #define GPR_OR_PSEUDO_P(R) (GPR_P (R) || (R) >= FIRST_PSEUDO_REGISTER)
224 #define GPR_AP_OR_PSEUDO_P(R) (GPR_OR_AP_P (R) || (R) >= FIRST_PSEUDO_REGISTER)
226 #define FIXED_REGISTERS \
227 { /* Integer Registers */ \
228 0, 0, 0, 0, 0, 0, 0, 0, /* 000-007, gr0 - gr7 */ \
229 0, 0, 0, 0, 0, 1, 0, 0, /* 008-015, gr8 - gr15 */ \
230 0, 0, 0, 0, 0, 0, 0, 0, /* 016-023, gr16 - gr23 */ \
231 0, 0, 0, 0, 1, 1, 1, 1, /* 024-031, gr24 - gr31 */ \
232 0, 0, 0, 0, 0, 0, 0, 0, /* 032-039, gr32 - gr39 */ \
233 1, 1, 1, 1, 0, 0, 0, 0, /* 040-047, gr40 - gr47 */ \
234 0, 0, 0, 0, 0, 0, 0, 0, /* 048-055, gr48 - gr55 */ \
235 0, 0, 0, 0, 0, 0, 0, 0, /* 056-063, gr56 - gr63 */ \
236 /* Other registers */ \
237 1, /* 64 AP - fake arg ptr */ \
238 1, /* soft frame pointer */ \
239 1, /* CC_REGNUM - integer conditions */\
240 1, /* CCFP_REGNUM - fp conditions */\
241 1, 1, 1, 1, 1, 1, /* Core Control Registers. */ \
242 1, 1, 1, /* FP_{NEAREST,...}_REGNUM */\
243 1, /* UNKNOWN_REGNUM - placeholder. */\
246 /* Like `FIXED_REGISTERS' but has 1 for each register that is clobbered (in
247 general) by function calls as well as for fixed registers. This macro
248 therefore identifies the registers that are not available for general
249 allocation of values that must live across function calls.
251 If a register has 0 in `CALL_USED_REGISTERS', the compiler automatically
252 saves it on function entry and restores it on function exit, if the register
253 is used within the function. */
255 #define CALL_USED_REGISTERS \
256 { /* Integer Registers */ \
257 1, 1, 1, 1, 0, 0, 0, 0, /* 000-007, gr0 - gr7 */ \
258 0, 0, 0, 0, 1, 1, 1, 0, /* 008-015, gr8 - gr15 */ \
259 1, 1, 1, 1, 1, 1, 1, 1, /* 016-023, gr16 - gr23 */ \
260 1, 1, 1, 1, 1, 1, 1, 1, /* 024-031, gr24 - gr31 */ \
261 0, 0, 0, 0, 0, 0, 0, 0, /* 032-039, gr32 - gr38 */ \
262 1, 1, 1, 1, 1, 1, 1, 1, /* 040-047, gr40 - gr47 */ \
263 1, 1, 1, 1, 1, 1, 1, 1, /* 048-055, gr48 - gr55 */ \
264 1, 1, 1, 1, 1, 1, 1, 1, /* 056-063, gr56 - gr63 */ \
265 1, /* 64 AP - fake arg ptr */ \
266 1, /* soft frame pointer */ \
267 1, /* 66 CC_REGNUM */ \
268 1, /* 67 CCFP_REGNUM */ \
269 1, 1, 1, 1, 1, 1, /* Core Control Registers. */ \
270 1, 1, 1, /* FP_{NEAREST,...}_REGNUM */\
271 1, /* UNKNOWN_REGNUM - placeholder. */\
274 #define REG_ALLOC_ORDER \
276 0, 1, 2, 3, /* Caller-saved 'small' registers. */ \
277 12, /* Caller-saved unpaired register. */ \
278 /* Caller-saved registers. */ \
279 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, \
280 44, 45, 46, 47, \
281 48, 49, 50, 51, 52, 53, 54, 55, \
282 56, 57, 58, 59, 60, 61, 62, 63, \
283 4, 5, 6, 7, /* Calle-saved 'small' registers. */ \
284 15, /* Calle-saved unpaired register. */ \
285 8, 9, 10, 11, /* Calle-saved registers. */ \
286 32, 33, 34, 35, 36, 37, 38, 39, \
287 14, 13, /* Link register, stack pointer. */ \
288 40, 41, 42, 43, /* Usually constant, but might be made callee-saved. */ \
289 /* Can't allocate, but must name these... */ \
290 28, 29, 30, 31, \
291 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77 \
294 #define HARD_REGNO_RENAME_OK(SRC, DST) epiphany_regno_rename_ok (SRC, DST)
296 /* Return number of consecutive hard regs needed starting at reg REGNO
297 to hold something of mode MODE.
298 This is ordinarily the length in words of a value of mode MODE
299 but can be less for certain modes in special long registers. */
300 #define HARD_REGNO_NREGS(REGNO, MODE) \
301 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
303 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. */
304 extern const unsigned int epiphany_hard_regno_mode_ok[];
305 extern unsigned int epiphany_mode_class[];
306 #define HARD_REGNO_MODE_OK(REGNO, MODE) hard_regno_mode_ok((REGNO), (MODE))
308 /* A C expression that is nonzero if it is desirable to choose
309 register allocation so as to avoid move instructions between a
310 value of mode MODE1 and a value of mode MODE2.
312 If `HARD_REGNO_MODE_OK (R, MODE1)' and `HARD_REGNO_MODE_OK (R,
313 MODE2)' are ever different for any R, then `MODES_TIEABLE_P (MODE1,
314 MODE2)' must be zero. */
316 #define MODES_TIEABLE_P(MODE1, MODE2) 1
318 /* Register classes and constants. */
320 /* Define the classes of registers for register constraints in the
321 machine description. Also define ranges of constants.
323 One of the classes must always be named ALL_REGS and include all hard regs.
324 If there is more than one class, another class must be named NO_REGS
325 and contain no registers.
327 The name GENERAL_REGS must be the name of a class (or an alias for
328 another name such as ALL_REGS). This is the class of registers
329 that is allowed by "g" or "r" in a register constraint.
330 Also, registers outside this class are allocated only when
331 instructions express preferences for them.
333 The classes must be numbered in nondecreasing order; that is,
334 a larger-numbered class must never be contained completely
335 in a smaller-numbered class.
337 For any two classes, it is very desirable that there be another
338 class that represents their union.
340 It is important that any condition codes have class NO_REGS.
341 See `register_operand'. */
343 enum reg_class {
344 NO_REGS,
345 LR_REGS,
346 SHORT_INSN_REGS,
347 SIBCALL_REGS,
348 GENERAL_REGS,
349 CORE_CONTROL_REGS,
350 ALL_REGS,
351 LIM_REG_CLASSES
354 #define N_REG_CLASSES ((int) LIM_REG_CLASSES)
356 /* Give names of register classes as strings for dump file. */
357 #define REG_CLASS_NAMES \
359 "NO_REGS", \
360 "LR_REGS", \
361 "SHORT_INSN_REGS", \
362 "SIBCALL_REGS", \
363 "GENERAL_REGS", \
364 "CORE_CONTROL_REGS", \
365 "ALL_REGS" \
368 /* Define which registers fit in which classes.
369 This is an initializer for a vector of HARD_REG_SET
370 of length N_REG_CLASSES. */
372 #define REG_CLASS_CONTENTS \
373 { /* r0-r31 r32-r63 ap/sfp/cc1/cc2/iret/status */ \
374 { 0x00000000,0x00000000,0x0}, /* NO_REGS */ \
375 { 0x00004000,0x00000000,0x0}, /* LR_REGS */ \
376 { 0x000000ff,0x00000000,0x0}, /* SHORT_INSN_REGS */ \
377 { 0xffff100f,0xffffff00,0x0}, /* SIBCALL_REGS */ \
378 { 0xffffffff,0xffffffff,0x0003}, /* GENERAL_REGS */ \
379 { 0x00000000,0x00000000,0x03f0}, /* CORE_CONTROL_REGS */ \
380 { 0xffffffff,0xffffffff,0x3fff}, /* ALL_REGS */ \
384 /* The same information, inverted:
385 Return the class number of the smallest class containing
386 reg number REGNO. This could be a conditional expression
387 or could index an array. */
388 extern enum reg_class epiphany_regno_reg_class[FIRST_PSEUDO_REGISTER];
389 #define REGNO_REG_CLASS(REGNO) \
390 (epiphany_regno_reg_class[REGNO])
392 /* The class value for index registers, and the one for base regs. */
393 #define BASE_REG_CLASS GENERAL_REGS
394 #define INDEX_REG_CLASS GENERAL_REGS
396 /* These assume that REGNO is a hard or pseudo reg number.
397 They give nonzero only if REGNO is a hard reg of the suitable class
398 or a pseudo reg currently allocated to a suitable hard reg.
399 Since they use reg_renumber, they are safe only once reg_renumber
400 has been allocated, which happens in local-alloc.c. */
401 #define REGNO_OK_FOR_BASE_P(REGNO) \
402 ((REGNO) < FIRST_PSEUDO_REGISTER || (unsigned) reg_renumber[REGNO] < FIRST_PSEUDO_REGISTER)
403 #define REGNO_OK_FOR_INDEX_P(REGNO) \
404 ((REGNO) < FIRST_PSEUDO_REGISTER || (unsigned) reg_renumber[REGNO] < FIRST_PSEUDO_REGISTER)
408 /* Given an rtx X being reloaded into a reg required to be
409 in class CLASS, return the class of reg to actually use.
410 In general this is just CLASS; but on some machines
411 in some cases it is preferable to use a more restrictive class. */
412 #define PREFERRED_RELOAD_CLASS(X,CLASS) \
413 (CLASS)
415 /* Return the maximum number of consecutive registers
416 needed to represent mode MODE in a register of class CLASS. */
417 #define CLASS_MAX_NREGS(CLASS, MODE) \
418 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
420 /* The letters I, J, K, L, M, N, O, P in a register constraint string
421 can be used to stand for particular ranges of immediate operands.
422 This macro defines what the ranges are.
423 C is the letter, and VALUE is a constant value.
424 Return 1 if VALUE is in the range specified by C. */
426 /* 'I' is used for 16 bit unsigned.
427 'Cal' is used for long immediates (32 bits)
428 'K' is used for any constant up to 5 bits.
429 'L' is used for any 11 bit signed.
432 #define IMM16(X) (IN_RANGE ((X), 0, 0xFFFF))
433 #define SIMM16(X) (IN_RANGE ((X), -65536, 65535))
434 #define SIMM11(X) (IN_RANGE ((X), -1024, 1023))
435 #define IMM5(X) (IN_RANGE ((X), 0, 0x1F))
437 typedef struct GTY (()) machine_function
439 unsigned args_parsed : 1;
440 unsigned pretend_args_odd : 1;
441 unsigned lr_clobbered : 1;
442 unsigned control_use_inserted : 1;
443 unsigned sw_entities_processed : 6;
444 long lr_slot_offset;
445 rtx and_mask;
446 rtx or_mask;
447 unsigned unknown_mode_uses;
448 unsigned unknown_mode_sets;
449 } machine_function_t;
451 #define MACHINE_FUNCTION(fun) (fun)->machine
453 #define INIT_EXPANDERS epiphany_init_expanders ()
455 /* Stack layout and stack pointer usage. */
457 /* Define this macro if pushing a word onto the stack moves the stack
458 pointer to a smaller address. */
459 #define STACK_GROWS_DOWNWARD
461 /* Define this to nonzero if the nominal address of the stack frame
462 is at the high-address end of the local variables;
463 that is, each additional local variable allocated
464 goes at a more negative offset in the frame. */
465 #define FRAME_GROWS_DOWNWARD 1
467 /* Offset within stack frame to start allocating local variables at.
468 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
469 first local allocated. Otherwise, it is the offset to the BEGINNING
470 of the first local allocated. */
471 #define STARTING_FRAME_OFFSET epiphany_stack_offset
473 /* Offset from the stack pointer register to the first location at which
474 outgoing arguments are placed. */
475 #define STACK_POINTER_OFFSET epiphany_stack_offset
477 /* Offset of first parameter from the argument pointer register value. */
478 /* 4 bytes for each of previous fp, return address, and previous gp.
479 4 byte reserved area for future considerations. */
480 #define FIRST_PARM_OFFSET(FNDECL) \
481 (epiphany_stack_offset \
482 + (MACHINE_FUNCTION (DECL_STRUCT_FUNCTION (FNDECL))->pretend_args_odd \
483 ? 4 : 0))
485 #define INCOMING_FRAME_SP_OFFSET epiphany_stack_offset
487 /* Register to use for pushing function arguments. */
488 #define STACK_POINTER_REGNUM GPR_SP
490 /* Base register for access to local variables of the function. */
491 #define HARD_FRAME_POINTER_REGNUM GPR_FP
493 /* Register in which static-chain is passed to a function. This must
494 not be a register used by the prologue. */
495 #define STATIC_CHAIN_REGNUM GPR_IP
497 /* Define the offset between two registers, one to be eliminated, and the other
498 its replacement, at the start of a routine. */
500 #define ELIMINABLE_REGS \
501 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
502 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
503 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
504 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
507 /* Define the offset between two registers, one to be eliminated, and the other
508 its replacement, at the start of a routine. */
510 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
511 ((OFFSET) = epiphany_initial_elimination_offset ((FROM), (TO)))
513 /* Function argument passing. */
515 /* If defined, the maximum amount of space required for outgoing
516 arguments will be computed and placed into the variable
517 `current_function_outgoing_args_size'. No space will be pushed
518 onto the stack for each call; instead, the function prologue should
519 increase the stack frame size by this amount. */
520 #define ACCUMULATE_OUTGOING_ARGS 1
522 /* Define a data type for recording info about an argument list
523 during the scan of that argument list. This data type should
524 hold all necessary information about the function itself
525 and about the args processed so far, enough to enable macros
526 such as FUNCTION_ARG to determine where the next arg should go. */
527 #define CUMULATIVE_ARGS int
529 /* Initialize a variable CUM of type CUMULATIVE_ARGS
530 for a call to a function whose data type is FNTYPE.
531 For a library call, FNTYPE is 0. */
532 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
533 ((CUM) = 0)
535 /* The number of registers used for parameter passing. Local to this file. */
536 #define MAX_EPIPHANY_PARM_REGS 4
538 /* 1 if N is a possible register number for function argument passing. */
539 #define FUNCTION_ARG_REGNO_P(N) \
540 ((unsigned) (N) < MAX_EPIPHANY_PARM_REGS)
542 /* Return boolean indicating arg of type TYPE and mode MODE will be passed in
543 a reg. This includes arguments that have to be passed by reference as the
544 pointer to them is passed in a reg if one is available (and that is what
545 we're given).
546 This macro is only used in this file. */
547 /* We must use partial argument passing because of the chosen mode
548 of varargs handling. */
549 #define PASS_IN_REG_P(CUM, MODE, TYPE) \
550 (ROUND_ADVANCE_CUM ((CUM), (MODE), (TYPE)) < MAX_EPIPHANY_PARM_REGS)
552 /* Tell GCC to use TARGET_RETURN_IN_MEMORY. */
553 #define DEFAULT_PCC_STRUCT_RETURN 0
555 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
556 the stack pointer does not matter. The value is tested only in
557 functions that have frame pointers.
558 No definition is equivalent to always zero. */
559 #define EXIT_IGNORE_STACK 1
561 #define EPILOGUE_USES(REGNO) epiphany_epilogue_uses (REGNO)
563 /* Output assembler code to FILE to increment profiler label # LABELNO
564 for profiling a function entry. */
565 #define FUNCTION_PROFILER(FILE, LABELNO)
567 /* Given an rtx for the frame pointer,
568 return an rtx for the address of the frame. */
569 #define FRAME_ADDR_RTX(frame) \
570 ((frame) == hard_frame_pointer_rtx ? arg_pointer_rtx : NULL)
572 #define EPIPHANY_RETURN_REGNO \
573 ((current_function_decl != NULL \
574 && epiphany_is_interrupt_p (current_function_decl)) \
575 ? IRET_REGNUM : GPR_LR)
576 /* This is not only for dwarf unwind info, but also for the benefit of
577 df-scan.c to tell it that LR is live at the function start. */
578 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, EPIPHANY_RETURN_REGNO)
580 /* However, we haven't implemented the rest needed for dwarf2 unwind info. */
581 #define DWARF2_UNWIND_INFO 0
583 #define RETURN_ADDR_RTX(count, frame) \
584 (count ? NULL_RTX \
585 : gen_rtx_UNSPEC (SImode, gen_rtvec (1, const0_rtx), UNSPEC_RETURN_ADDR))
587 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (EPIPHANY_RETURN_REGNO)
589 /* Trampolines.
590 An epiphany trampoline looks like this:
591 mov r16,%low(fnaddr)
592 movt r16,%high(fnaddr)
593 mov ip,%low(cxt)
594 movt ip,%high(cxt)
595 jr r16 */
597 /* Length in units of the trampoline for entering a nested function. */
598 #define TRAMPOLINE_SIZE 20
600 /* Addressing modes, and classification of registers for them. */
602 /* Maximum number of registers that can appear in a valid memory address. */
603 #define MAX_REGS_PER_ADDRESS 2
605 /* We have post_modify (load/store with update). */
606 #define HAVE_POST_INCREMENT TARGET_POST_INC
607 #define HAVE_POST_DECREMENT TARGET_POST_INC
608 #define HAVE_POST_MODIFY_DISP TARGET_POST_MODIFY
609 #define HAVE_POST_MODIFY_REG TARGET_POST_MODIFY
611 /* Currently, the only users of the USE_*CREMENT macros are
612 move_by_pieces / store_by_pieces_1 . We don't want them to use
613 POST_MODIFY modes, because we got ample addressing range for the
614 reg+offset addressing mode; besides, there are short index+offset loads,
615 but the only short post-modify load uses POST_MODIFY_REG.
616 Moreover, using auto-increment in move_by_pieces from structure copying
617 in the prologue causes confused debug output.
618 If another pass starts using these macros where the use of these
619 addressing modes would make more sense, we can try checking the
620 current pass. */
621 #define USE_LOAD_POST_INCREMENT(MODE) 0
622 #define USE_LOAD_POST_DECREMENT(MODE) 0
623 #define USE_STORE_POST_INCREMENT(MODE) 0
624 #define USE_STORE_POST_DECREMENT(MODE) 0
626 /* Recognize any constant value that is a valid address. */
627 #define CONSTANT_ADDRESS_P(X) \
628 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
629 || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST)
631 #define RTX_OK_FOR_OFFSET_P(MODE, X) \
632 RTX_OK_FOR_OFFSET_1 (GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \
633 && epiphany_vect_align == 4 ? SImode : (MODE), X)
634 #define RTX_OK_FOR_OFFSET_1(MODE, X) \
635 (GET_CODE (X) == CONST_INT \
636 && !(INTVAL (X) & (GET_MODE_SIZE (MODE) - 1)) \
637 && INTVAL (X) >= -2047 * (int) GET_MODE_SIZE (MODE) \
638 && INTVAL (X) <= 2047 * (int) GET_MODE_SIZE (MODE))
640 /* Frame offsets cannot be evaluated till the frame pointer is eliminated. */
641 #define RTX_FRAME_OFFSET_P(X) \
642 ((X) == frame_pointer_rtx \
643 || (GET_CODE (X) == PLUS && XEXP ((X), 0) == frame_pointer_rtx \
644 && CONST_INT_P (XEXP ((X), 1))))
646 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
647 return the mode to be used for the comparison. */
648 #define SELECT_CC_MODE(OP, X, Y) \
649 epiphany_select_cc_mode (OP, X, Y)
651 /* Return nonzero if SELECT_CC_MODE will never return MODE for a
652 floating point inequality comparison. */
654 #define REVERSE_CONDITION(CODE, MODE) \
655 ((MODE) == CC_FPmode || (MODE) == CC_FP_EQmode || (MODE) == CC_FP_GTEmode \
656 || (MODE) == CC_FP_ORDmode || (MODE) == CC_FP_UNEQmode \
657 ? reverse_condition_maybe_unordered (CODE) \
658 : (MODE) == CCmode ? reverse_condition (CODE) \
659 : UNKNOWN)
661 /* We can reverse all CCmodes with REVERSE_CONDITION. */
662 #define REVERSIBLE_CC_MODE(MODE) \
663 ((MODE) == CCmode || (MODE) == CC_FPmode || (MODE) == CC_FP_EQmode \
664 || (MODE) == CC_FP_GTEmode || (MODE) == CC_FP_ORDmode \
665 || (MODE) == CC_FP_UNEQmode)
667 /* Costs. */
669 /* The cost of a branch insn. */
670 /* ??? What's the right value here? Branches are certainly more
671 expensive than reg->reg moves. */
672 #define BRANCH_COST(speed_p, predictable_p) \
673 (speed_p ? epiphany_branch_cost : 1)
675 /* Nonzero if access to memory by bytes is slow and undesirable.
676 For RISC chips, it means that access to memory by bytes is no
677 better than access by words when possible, so grab a whole word
678 and maybe make use of that. */
679 #define SLOW_BYTE_ACCESS 1
681 /* Define this macro if it is as good or better to call a constant
682 function address than to call an address kept in a register. */
683 /* On the EPIPHANY, calling through registers is slow. */
684 #define NO_FUNCTION_CSE
686 /* Section selection. */
687 /* WARNING: These section names also appear in dwarf2out.c. */
689 #define TEXT_SECTION_ASM_OP "\t.section .text"
690 #define DATA_SECTION_ASM_OP "\t.section .data"
692 #undef READONLY_DATA_SECTION_ASM_OP
693 #define READONLY_DATA_SECTION_ASM_OP "\t.section .rodata"
695 #define BSS_SECTION_ASM_OP "\t.section .bss"
697 /* Define this macro if jump tables (for tablejump insns) should be
698 output in the text section, along with the assembler instructions.
699 Otherwise, the readonly data section is used.
700 This macro is irrelevant if there is no separate readonly data section. */
701 #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
703 /* PIC */
705 /* The register number of the register used to address a table of static
706 data addresses in memory. In some cases this register is defined by a
707 processor's ``application binary interface'' (ABI). When this macro
708 is defined, RTL is generated for this register once, as with the stack
709 pointer and frame pointer registers. If this macro is not defined, it
710 is up to the machine-dependent files to allocate such a register (if
711 necessary). */
712 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? PIC_REGNO : INVALID_REGNUM)
714 /* Control the assembler format that we output. */
716 /* A C string constant describing how to begin a comment in the target
717 assembler language. The compiler assumes that the comment will
718 end at the end of the line. */
719 #define ASM_COMMENT_START ";"
721 /* Output to assembler file text saying following lines
722 may contain character constants, extra white space, comments, etc. */
723 #define ASM_APP_ON ""
725 /* Output to assembler file text saying following lines
726 no longer contain unusual constructs. */
727 #define ASM_APP_OFF ""
729 /* Globalizing directive for a label. */
730 #define GLOBAL_ASM_OP "\t.global\t"
732 /* How to refer to registers in assembler output.
733 This sequence is indexed by compiler's hard-register-number (see above). */
735 #define REGISTER_NAMES \
737 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
738 "r8", "r9", "r10", "fp", "ip", "sp", "lr", "r15", \
739 "r16", "r17","r18", "r19", "r20", "r21", "r22", "r23", \
740 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \
741 "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \
742 "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", \
743 "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", \
744 "r56", "r57", "r58", "r59", "r60", "r61", "r62", "r63", \
745 "ap", "sfp", "cc1", "cc2", \
746 "config", "status", "lc", "ls", "le", "iret", \
747 "fp_near", "fp_trunc", "fp_anyfp", "unknown" \
750 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
751 epiphany_final_prescan_insn (INSN, OPVEC, NOPERANDS)
753 #define LOCAL_LABEL_PREFIX "."
755 /* A C expression which evaluates to true if CODE is a valid
756 punctuation character for use in the `PRINT_OPERAND' macro. */
757 extern char epiphany_punct_chars[256];
758 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
759 epiphany_punct_chars[(unsigned char) (CHAR)]
761 /* This is how to output an element of a case-vector that is absolute. */
762 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
763 do { \
764 if (CASE_VECTOR_MODE == Pmode) \
765 asm_fprintf ((FILE), "\t.word %LL%d\n", (VALUE)); \
766 else \
767 asm_fprintf ((FILE), "\t.short %LL%d\n", (VALUE)); \
768 } while (0)
770 /* This is how to output an element of a case-vector that is relative. */
771 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
772 do { \
773 if (CASE_VECTOR_MODE == Pmode) \
774 asm_fprintf ((FILE), "\t.word"); \
775 else \
776 asm_fprintf ((FILE), "\t.short"); \
777 asm_fprintf ((FILE), " %LL%d-%LL%d\n", (VALUE), (REL)); \
778 } while (0)
780 /* This is how to output an assembler line
781 that says to advance the location counter
782 to a multiple of 2**LOG bytes. */
783 #define ASM_OUTPUT_ALIGN(FILE, LOG) \
784 do { if ((LOG) != 0) fprintf (FILE, "\t.balign %d\n", 1 << (LOG)); } while (0)
786 /* Inside the text section, align with nops rather than zeros. */
787 #define ASM_OUTPUT_ALIGN_WITH_NOP(FILE, LOG) \
788 do \
790 if ((LOG) != 0) fprintf (FILE, "\t.balignw %d,0x01a2\n", 1 << (LOG)); \
791 } while (0)
793 /* This is how to declare the size of a function. */
794 #undef ASM_DECLARE_FUNCTION_SIZE
795 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
796 do \
798 const char *__name = (FNAME); \
799 tree attrs = DECL_ATTRIBUTES ((DECL)); \
801 if (!flag_inhibit_size_directive) \
803 if (lookup_attribute ("forwarder_section", attrs)) \
805 const char *prefix = "__forwarder_dst_"; \
806 char *dst_name \
807 = (char *) alloca (strlen (prefix) + strlen (__name) + 1); \
809 strcpy (dst_name, prefix); \
810 strcat (dst_name, __name); \
811 __name = dst_name; \
813 ASM_OUTPUT_MEASURED_SIZE ((FILE), __name); \
816 while (0)
818 /* Debugging information. */
820 /* Generate DBX and DWARF debugging information. */
821 #define DBX_DEBUGGING_INFO 1
823 #undef PREFERRED_DEBUGGING_TYPE
824 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
826 /* Turn off splitting of long stabs. */
827 #define DBX_CONTIN_LENGTH 0
829 /* Miscellaneous. */
831 /* Specify the machine mode that this machine uses
832 for the index in the tablejump instruction. */
833 #define CASE_VECTOR_MODE (TARGET_SMALL16 && optimize_size ? HImode : Pmode)
835 /* Define if operations between registers always perform the operation
836 on the full register even if a narrower mode is specified. */
837 #define WORD_REGISTER_OPERATIONS
839 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
840 will either zero-extend or sign-extend. The value of this macro should
841 be the code that says which one of the two operations is implicitly
842 done, UNKNOWN if none. */
843 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
845 /* Max number of bytes we can move from memory to memory
846 in one reasonably fast instruction. */
847 #define MOVE_MAX 8
849 /* Define this to be nonzero if shift instructions ignore all but the low-order
850 few bits. */
851 #define SHIFT_COUNT_TRUNCATED 1
853 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
854 is done just by pretending it is already truncated. */
855 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
857 /* Specify the machine mode that pointers have.
858 After generation of rtl, the compiler makes no further distinction
859 between pointers and any other objects of this machine mode. */
861 #define Pmode SImode
863 /* A function address in a call instruction. */
864 #define FUNCTION_MODE SImode
866 /* EPIPHANY function types. */
867 enum epiphany_function_type
869 EPIPHANY_FUNCTION_UNKNOWN, EPIPHANY_FUNCTION_NORMAL,
870 EPIPHANY_FUNCTION_INTERRUPT
873 #define EPIPHANY_INTERRUPT_P(TYPE) ((TYPE) == EPIPHANY_FUNCTION_INTERRUPT)
875 /* Compute the type of a function from its DECL. */
877 #define IMMEDIATE_PREFIX "#"
879 #define OPTIMIZE_MODE_SWITCHING(ENTITY) \
880 (epiphany_optimize_mode_switching (ENTITY))
882 /* We have two fake entities for lazy code motion of the mask constants,
883 one entity each for round-to-nearest / truncating
884 with a different idea what FP_MODE_ROUND_UNKNOWN will be, and
885 finally an entity that runs in a second mode switching pass to
886 resolve FP_MODE_ROUND_UNKNOWN. */
887 #define NUM_MODES_FOR_MODE_SWITCHING \
888 { 2, 2, FP_MODE_NONE, FP_MODE_NONE, FP_MODE_NONE, FP_MODE_NONE, FP_MODE_NONE }
890 #define MODE_NEEDED(ENTITY, INSN) epiphany_mode_needed((ENTITY), (INSN))
892 #define MODE_PRIORITY_TO_MODE(ENTITY, N) \
893 (epiphany_mode_priority_to_mode ((ENTITY), (N)))
895 #define EMIT_MODE_SET(ENTITY, MODE, HARD_REGS_LIVE) \
896 emit_set_fp_mode ((ENTITY), (MODE), (HARD_REGS_LIVE))
898 #define MODE_ENTRY(ENTITY) (epiphany_mode_entry_exit ((ENTITY), false))
899 #define MODE_EXIT(ENTITY) (epiphany_mode_entry_exit ((ENTITY), true))
900 #define MODE_AFTER(ENTITY, LAST_MODE, INSN) \
901 (epiphany_mode_after ((ENTITY), (LAST_MODE), (INSN)))
903 #define TARGET_INSERT_MODE_SWITCH_USE epiphany_insert_mode_switch_use
905 /* Mode switching entities. */
906 enum
908 EPIPHANY_MSW_ENTITY_AND,
909 EPIPHANY_MSW_ENTITY_OR,
910 EPIPHANY_MSW_ENTITY_NEAREST,
911 EPIPHANY_MSW_ENTITY_TRUNC,
912 EPIPHANY_MSW_ENTITY_ROUND_UNKNOWN,
913 EPIPHANY_MSW_ENTITY_ROUND_KNOWN,
914 EPIPHANY_MSW_ENTITY_FPU_OMNIBUS
917 extern int epiphany_normal_fp_rounding;
918 extern struct rtl_opt_pass pass_mode_switch_use;
919 extern struct rtl_opt_pass pass_resolve_sw_modes;
921 /* This will need to be adjusted when FP_CONTRACT_ON is properly
922 implemented. */
923 #define TARGET_FUSED_MADD (flag_fp_contract_mode == FP_CONTRACT_FAST)
925 #undef ASM_DECLARE_FUNCTION_NAME
926 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
927 epiphany_start_function ((FILE), (NAME), (DECL))
929 #endif /* !GCC_EPIPHANY_H */