]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/arc/arc.h
arc.h (FUNCTION_ARG, [...]): Move code to...
[thirdparty/gcc.git] / gcc / config / arc / arc.h
1 /* Definitions of target machine for GNU compiler, Argonaut ARC cpu.
2 Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005,
3 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
11
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
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/>. */
20
21 /* ??? This is an old port, and is undoubtedly suffering from bit rot. */
22
23 /* Things to do:
24
25 - incscc, decscc?
26 - print active compiler options in assembler output
27 */
28
29
30 #undef ASM_SPEC
31 #undef LINK_SPEC
32 #undef STARTFILE_SPEC
33 #undef ENDFILE_SPEC
34 #undef SIZE_TYPE
35 #undef PTRDIFF_TYPE
36 #undef WCHAR_TYPE
37 #undef WCHAR_TYPE_SIZE
38 #undef ASM_OUTPUT_LABELREF
39 \f
40 /* Print subsidiary information on the compiler version in use. */
41 #define TARGET_VERSION fprintf (stderr, " (arc)")
42
43 /* Names to predefine in the preprocessor for this target machine. */
44 #define TARGET_CPU_CPP_BUILTINS() \
45 do \
46 { \
47 builtin_define ("__arc__"); \
48 if (TARGET_BIG_ENDIAN) \
49 builtin_define ("__big_endian__"); \
50 if (arc_cpu_type == 0) \
51 builtin_define ("__base__"); \
52 builtin_assert ("cpu=arc"); \
53 builtin_assert ("machine=arc"); \
54 } while (0)
55
56 /* Pass -mmangle-cpu if we get -mcpu=*.
57 Doing it this way lets one have it on as default with -mcpu=*,
58 but also lets one turn it off with -mno-mangle-cpu. */
59 #define CC1_SPEC "\
60 %{mcpu=*:-mmangle-cpu} \
61 %{EB:%{EL:%emay not use both -EB and -EL}} \
62 %{EB:-mbig-endian} %{EL:-mlittle-endian} \
63 "
64
65 #define ASM_SPEC "%{v} %{EB} %{EL}"
66
67 #define LINK_SPEC "%{v} %{EB} %{EL}"
68
69 #define STARTFILE_SPEC "%{!shared:crt0.o%s} crtinit.o%s"
70
71 #define ENDFILE_SPEC "crtfini.o%s"
72 \f
73 /* Instruction set characteristics.
74 These are internal macros, set by the appropriate -mcpu= option. */
75
76 /* Nonzero means the cpu has a barrel shifter. */
77 #define TARGET_SHIFTER 0
78
79 /* Which cpu we're compiling for. */
80 extern int arc_cpu_type;
81
82 /* Check if CPU is an extension and set `arc_cpu_type' and `arc_mangle_cpu'
83 appropriately. The result should be nonzero if the cpu is recognized,
84 otherwise zero. This is intended to be redefined in a cover file.
85 This is used by arc_handle_option. */
86 #define ARC_EXTENSION_CPU(cpu) 0
87
88 \f
89 /* Target machine storage layout. */
90
91 /* Define this if most significant bit is lowest numbered
92 in instructions that operate on numbered bit-fields. */
93 #define BITS_BIG_ENDIAN 1
94
95 /* Define this if most significant byte of a word is the lowest numbered. */
96 #define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN)
97
98 /* Define this if most significant word of a multiword number is the lowest
99 numbered. */
100 #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN)
101
102 /* Width of a word, in units (bytes). */
103 #define UNITS_PER_WORD 4
104
105 /* Define this macro if it is advisable to hold scalars in registers
106 in a wider mode than that declared by the program. In such cases,
107 the value is constrained to be within the bounds of the declared
108 type, but kept valid in the wider mode. The signedness of the
109 extension may differ from that of the type. */
110 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
111 if (GET_MODE_CLASS (MODE) == MODE_INT \
112 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
113 { \
114 (MODE) = SImode; \
115 }
116
117 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
118 #define PARM_BOUNDARY 32
119
120 /* Boundary (in *bits*) on which stack pointer should be aligned. */
121 #define STACK_BOUNDARY 64
122
123 /* ALIGN FRAMES on word boundaries */
124 #define ARC_STACK_ALIGN(LOC) (((LOC)+7) & ~7)
125
126 /* Allocation boundary (in *bits*) for the code of a function. */
127 #define FUNCTION_BOUNDARY 32
128
129 /* Alignment of field after `int : 0' in a structure. */
130 #define EMPTY_FIELD_BOUNDARY 32
131
132 /* Every structure's size must be a multiple of this. */
133 #define STRUCTURE_SIZE_BOUNDARY 8
134
135 /* A bit-field declared as `int' forces `int' alignment for the struct. */
136 #define PCC_BITFIELD_TYPE_MATTERS 1
137
138 /* No data type wants to be aligned rounder than this. */
139 /* This is bigger than currently necessary for the ARC. If 8 byte floats are
140 ever added it's not clear whether they'll need such alignment or not. For
141 now we assume they will. We can always relax it if necessary but the
142 reverse isn't true. */
143 #define BIGGEST_ALIGNMENT 64
144
145 /* The best alignment to use in cases where we have a choice. */
146 #define FASTEST_ALIGNMENT 32
147
148 /* Make strings word-aligned so strcpy from constants will be faster. */
149 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
150 ((TREE_CODE (EXP) == STRING_CST \
151 && (ALIGN) < FASTEST_ALIGNMENT) \
152 ? FASTEST_ALIGNMENT : (ALIGN))
153
154 /* Make arrays of chars word-aligned for the same reasons. */
155 #define DATA_ALIGNMENT(TYPE, ALIGN) \
156 (TREE_CODE (TYPE) == ARRAY_TYPE \
157 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
158 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
159
160 /* Set this nonzero if move instructions will actually fail to work
161 when given unaligned data. */
162 /* On the ARC the lower address bits are masked to 0 as necessary. The chip
163 won't croak when given an unaligned address, but the insn will still fail
164 to produce the correct result. */
165 #define STRICT_ALIGNMENT 1
166 \f
167 /* Layout of source language data types. */
168
169 #define SHORT_TYPE_SIZE 16
170 #define INT_TYPE_SIZE 32
171 #define LONG_TYPE_SIZE 32
172 #define LONG_LONG_TYPE_SIZE 64
173 #define FLOAT_TYPE_SIZE 32
174 #define DOUBLE_TYPE_SIZE 64
175 #define LONG_DOUBLE_TYPE_SIZE 64
176
177 /* Define this as 1 if `char' should by default be signed; else as 0. */
178 #define DEFAULT_SIGNED_CHAR 1
179
180 #define SIZE_TYPE "long unsigned int"
181 #define PTRDIFF_TYPE "long int"
182 #define WCHAR_TYPE "short unsigned int"
183 #define WCHAR_TYPE_SIZE 16
184 \f
185 /* Standard register usage. */
186
187 /* Number of actual hardware registers.
188 The hardware registers are assigned numbers for the compiler
189 from 0 to just below FIRST_PSEUDO_REGISTER.
190 All registers that the compiler knows about must be given numbers,
191 even those that are not normally considered general registers. */
192 /* Registers 61, 62, and 63 are not really registers and we needn't treat
193 them as such. We still need a register for the condition code. */
194 #define FIRST_PSEUDO_REGISTER 62
195
196 /* 1 for registers that have pervasive standard uses
197 and are not available for the register allocator.
198
199 0-28 - general purpose registers
200 29 - ilink1 (interrupt link register)
201 30 - ilink2 (interrupt link register)
202 31 - blink (branch link register)
203 32-59 - reserved for extensions
204 60 - LP_COUNT
205 61 - condition code
206
207 For doc purposes:
208 61 - short immediate data indicator (setting flags)
209 62 - long immediate data indicator
210 63 - short immediate data indicator (not setting flags).
211
212 The general purpose registers are further broken down into:
213 0-7 - arguments/results
214 8-15 - call used
215 16-23 - call saved
216 24 - call used, static chain pointer
217 25 - call used, gptmp
218 26 - global pointer
219 27 - frame pointer
220 28 - stack pointer
221
222 By default, the extension registers are not available. */
223
224 #define FIXED_REGISTERS \
225 { 0, 0, 0, 0, 0, 0, 0, 0, \
226 0, 0, 0, 0, 0, 0, 0, 0, \
227 0, 0, 0, 0, 0, 0, 0, 0, \
228 0, 0, 0, 1, 1, 1, 1, 0, \
229 \
230 1, 1, 1, 1, 1, 1, 1, 1, \
231 1, 1, 1, 1, 1, 1, 1, 1, \
232 1, 1, 1, 1, 1, 1, 1, 1, \
233 1, 1, 1, 1, 1, 1 }
234
235 /* 1 for registers not available across function calls.
236 These must include the FIXED_REGISTERS and also any
237 registers that can be used without being saved.
238 The latter must include the registers where values are returned
239 and the register where structure-value addresses are passed.
240 Aside from that, you can include as many other registers as you like. */
241
242 #define CALL_USED_REGISTERS \
243 { 1, 1, 1, 1, 1, 1, 1, 1, \
244 1, 1, 1, 1, 1, 1, 1, 1, \
245 0, 0, 0, 0, 0, 0, 0, 0, \
246 1, 1, 1, 1, 1, 1, 1, 1, \
247 \
248 1, 1, 1, 1, 1, 1, 1, 1, \
249 1, 1, 1, 1, 1, 1, 1, 1, \
250 1, 1, 1, 1, 1, 1, 1, 1, \
251 1, 1, 1, 1, 1, 1 }
252
253 /* If defined, an initializer for a vector of integers, containing the
254 numbers of hard registers in the order in which GCC should
255 prefer to use them (from most preferred to least). */
256 #define REG_ALLOC_ORDER \
257 { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, \
258 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 31, \
259 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, \
260 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, \
261 27, 28, 29, 30 }
262
263 /* Macro to conditionally modify fixed_regs/call_used_regs. */
264 #define CONDITIONAL_REGISTER_USAGE \
265 do { \
266 if (PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) \
267 { \
268 fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
269 call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
270 } \
271 } while (0)
272
273 /* Return number of consecutive hard regs needed starting at reg REGNO
274 to hold something of mode MODE.
275 This is ordinarily the length in words of a value of mode MODE
276 but can be less for certain modes in special long registers. */
277 #define HARD_REGNO_NREGS(REGNO, MODE) \
278 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
279
280 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. */
281 extern const unsigned int arc_hard_regno_mode_ok[];
282 extern unsigned int arc_mode_class[];
283 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
284 ((arc_hard_regno_mode_ok[REGNO] & arc_mode_class[MODE]) != 0)
285
286 /* A C expression that is nonzero if it is desirable to choose
287 register allocation so as to avoid move instructions between a
288 value of mode MODE1 and a value of mode MODE2.
289
290 If `HARD_REGNO_MODE_OK (R, MODE1)' and `HARD_REGNO_MODE_OK (R,
291 MODE2)' are ever different for any R, then `MODES_TIEABLE_P (MODE1,
292 MODE2)' must be zero. */
293
294 /* Tie QI/HI/SI modes together. */
295 #define MODES_TIEABLE_P(MODE1, MODE2) \
296 (GET_MODE_CLASS (MODE1) == MODE_INT \
297 && GET_MODE_CLASS (MODE2) == MODE_INT \
298 && GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD \
299 && GET_MODE_SIZE (MODE2) <= UNITS_PER_WORD)
300 \f
301 /* Register classes and constants. */
302
303 /* Define the classes of registers for register constraints in the
304 machine description. Also define ranges of constants.
305
306 One of the classes must always be named ALL_REGS and include all hard regs.
307 If there is more than one class, another class must be named NO_REGS
308 and contain no registers.
309
310 The name GENERAL_REGS must be the name of a class (or an alias for
311 another name such as ALL_REGS). This is the class of registers
312 that is allowed by "g" or "r" in a register constraint.
313 Also, registers outside this class are allocated only when
314 instructions express preferences for them.
315
316 The classes must be numbered in nondecreasing order; that is,
317 a larger-numbered class must never be contained completely
318 in a smaller-numbered class.
319
320 For any two classes, it is very desirable that there be another
321 class that represents their union.
322
323 It is important that any condition codes have class NO_REGS.
324 See `register_operand'. */
325
326 enum reg_class {
327 NO_REGS, LPCOUNT_REG, GENERAL_REGS, ALL_REGS, LIM_REG_CLASSES
328 };
329
330 #define N_REG_CLASSES (int) LIM_REG_CLASSES
331
332 /* Give names of register classes as strings for dump file. */
333 #define REG_CLASS_NAMES \
334 { "NO_REGS", "LPCOUNT_REG", "GENERAL_REGS", "ALL_REGS" }
335
336 /* Define which registers fit in which classes.
337 This is an initializer for a vector of HARD_REG_SET
338 of length N_REG_CLASSES. */
339
340 #define REG_CLASS_CONTENTS \
341 { {0, 0}, {0, 0x10000000}, {0xffffffff, 0xfffffff}, \
342 {0xffffffff, 0x1fffffff} }
343
344 /* The same information, inverted:
345 Return the class number of the smallest class containing
346 reg number REGNO. This could be a conditional expression
347 or could index an array. */
348 extern enum reg_class arc_regno_reg_class[FIRST_PSEUDO_REGISTER];
349 #define REGNO_REG_CLASS(REGNO) \
350 (arc_regno_reg_class[REGNO])
351
352 /* The class value for index registers, and the one for base regs. */
353 #define INDEX_REG_CLASS GENERAL_REGS
354 #define BASE_REG_CLASS GENERAL_REGS
355
356 /* Get reg_class from a letter such as appears in the machine description. */
357 #define REG_CLASS_FROM_LETTER(C) \
358 ((C) == 'l' ? LPCOUNT_REG /* ??? needed? */ \
359 : NO_REGS)
360
361 /* These assume that REGNO is a hard or pseudo reg number.
362 They give nonzero only if REGNO is a hard reg of the suitable class
363 or a pseudo reg currently allocated to a suitable hard reg.
364 Since they use reg_renumber, they are safe only once reg_renumber
365 has been allocated, which happens in local-alloc.c. */
366 #define REGNO_OK_FOR_BASE_P(REGNO) \
367 ((REGNO) < 32 || (unsigned) reg_renumber[REGNO] < 32)
368 #define REGNO_OK_FOR_INDEX_P(REGNO) \
369 ((REGNO) < 32 || (unsigned) reg_renumber[REGNO] < 32)
370
371 /* Return the maximum number of consecutive registers
372 needed to represent mode MODE in a register of class CLASS. */
373 #define CLASS_MAX_NREGS(CLASS, MODE) \
374 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
375
376 /* The letters I, J, K, L, M, N, O, P in a register constraint string
377 can be used to stand for particular ranges of immediate operands.
378 This macro defines what the ranges are.
379 C is the letter, and VALUE is a constant value.
380 Return 1 if VALUE is in the range specified by C. */
381 /* 'I' is used for short immediates (always signed).
382 'J' is used for long immediates.
383 'K' is used for any constant up to 64 bits (for 64x32 situations?). */
384
385 /* local to this file */
386 #define SMALL_INT(X) ((unsigned) ((X) + 0x100) < 0x200)
387 /* local to this file */
388 #define LARGE_INT(X) \
389 ((X) >= (-(HOST_WIDE_INT) 0x7fffffff - 1) \
390 && (unsigned HOST_WIDE_INT)(X) <= (unsigned HOST_WIDE_INT) 0xffffffff)
391
392 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
393 ((C) == 'I' ? SMALL_INT (VALUE) \
394 : (C) == 'J' ? LARGE_INT (VALUE) \
395 : (C) == 'K' ? 1 \
396 : 0)
397
398 /* Similar, but for floating constants, and defining letters G and H.
399 Here VALUE is the CONST_DOUBLE rtx itself. */
400 /* 'G' is used for integer values for the multiplication insns where the
401 operands are extended from 4 bytes to 8 bytes.
402 'H' is used when any 64-bit constant is allowed. */
403 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
404 ((C) == 'G' ? arc_double_limm_p (VALUE) \
405 : (C) == 'H' ? 1 \
406 : 0)
407
408 /* A C expression that defines the optional machine-dependent constraint
409 letters that can be used to segregate specific types of operands,
410 usually memory references, for the target machine. It should return 1 if
411 VALUE corresponds to the operand type represented by the constraint letter
412 C. If C is not defined as an extra constraint, the value returned should
413 be 0 regardless of VALUE. */
414 /* ??? This currently isn't used. Waiting for PIC. */
415 #if 0
416 #define EXTRA_CONSTRAINT(VALUE, C) \
417 ((C) == 'R' ? (SYMBOL_REF_FUNCTION_P (VALUE) || GET_CODE (VALUE) == LABEL_REF) \
418 : 0)
419 #endif
420 \f
421 /* Stack layout and stack pointer usage. */
422
423 /* Define this macro if pushing a word onto the stack moves the stack
424 pointer to a smaller address. */
425 #define STACK_GROWS_DOWNWARD
426
427 /* Define this to nonzero if the nominal address of the stack frame
428 is at the high-address end of the local variables;
429 that is, each additional local variable allocated
430 goes at a more negative offset in the frame. */
431 #define FRAME_GROWS_DOWNWARD 1
432
433 /* Offset within stack frame to start allocating local variables at.
434 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
435 first local allocated. Otherwise, it is the offset to the BEGINNING
436 of the first local allocated. */
437 #define STARTING_FRAME_OFFSET 0
438
439 /* Offset from the stack pointer register to the first location at which
440 outgoing arguments are placed. */
441 #define STACK_POINTER_OFFSET FIRST_PARM_OFFSET (0)
442
443 /* Offset of first parameter from the argument pointer register value. */
444 /* 4 bytes for each of previous fp, return address, and previous gp.
445 4 byte reserved area for future considerations. */
446 #define FIRST_PARM_OFFSET(FNDECL) 16
447
448 /* A C expression whose value is RTL representing the address in a
449 stack frame where the pointer to the caller's frame is stored.
450 Assume that FRAMEADDR is an RTL expression for the address of the
451 stack frame itself.
452
453 If you don't define this macro, the default is to return the value
454 of FRAMEADDR--that is, the stack frame address is also the address
455 of the stack word that points to the previous frame. */
456 /* ??? unfinished */
457 /*define DYNAMIC_CHAIN_ADDRESS (FRAMEADDR)*/
458
459 /* A C expression whose value is RTL representing the value of the
460 return address for the frame COUNT steps up from the current frame.
461 FRAMEADDR is the frame pointer of the COUNT frame, or the frame
462 pointer of the COUNT - 1 frame if `RETURN_ADDR_IN_PREVIOUS_FRAME'
463 is defined. */
464 /* The current return address is in r31. The return address of anything
465 farther back is at [%fp,4]. */
466 #if 0 /* The default value should work. */
467 #define RETURN_ADDR_RTX(COUNT, FRAME) \
468 (((COUNT) == -1) \
469 ? gen_rtx_REG (Pmode, 31) \
470 : copy_to_reg (gen_rtx_MEM (Pmode, \
471 memory_address (Pmode, \
472 plus_constant ((FRAME), \
473 UNITS_PER_WORD)))))
474 #endif
475
476 /* Register to use for pushing function arguments. */
477 #define STACK_POINTER_REGNUM 28
478
479 /* Base register for access to local variables of the function. */
480 #define FRAME_POINTER_REGNUM 27
481
482 /* Base register for access to arguments of the function. */
483 #define ARG_POINTER_REGNUM FRAME_POINTER_REGNUM
484
485 /* Register in which static-chain is passed to a function. This must
486 not be a register used by the prologue. */
487 #define STATIC_CHAIN_REGNUM 24
488
489 /* C statement to store the difference between the frame pointer
490 and the stack pointer values immediately after the function prologue. */
491 #define INITIAL_FRAME_POINTER_OFFSET(VAR) \
492 ((VAR) = arc_compute_frame_size (get_frame_size ()))
493 \f
494 /* Function argument passing. */
495
496 /* If defined, the maximum amount of space required for outgoing
497 arguments will be computed and placed into the variable
498 `crtl->outgoing_args_size'. No space will be pushed
499 onto the stack for each call; instead, the function prologue should
500 increase the stack frame size by this amount. */
501 #define ACCUMULATE_OUTGOING_ARGS 1
502
503 /* Define a data type for recording info about an argument list
504 during the scan of that argument list. This data type should
505 hold all necessary information about the function itself
506 and about the args processed so far, enough to enable macros
507 such as FUNCTION_ARG to determine where the next arg should go. */
508 #define CUMULATIVE_ARGS int
509
510 /* Initialize a variable CUM of type CUMULATIVE_ARGS
511 for a call to a function whose data type is FNTYPE.
512 For a library call, FNTYPE is 0. */
513 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
514 ((CUM) = 0)
515
516 /* The number of registers used for parameter passing. Local to this file. */
517 #define MAX_ARC_PARM_REGS 8
518
519 /* 1 if N is a possible register number for function argument passing. */
520 #define FUNCTION_ARG_REGNO_P(N) \
521 ((unsigned) (N) < MAX_ARC_PARM_REGS)
522
523 /* If defined, a C expression that gives the alignment boundary, in bits,
524 of an argument with the specified mode and type. If it is not defined,
525 PARM_BOUNDARY is used for all arguments. */
526 #define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \
527 (((TYPE) ? TYPE_ALIGN (TYPE) : GET_MODE_BITSIZE (MODE)) <= PARM_BOUNDARY \
528 ? PARM_BOUNDARY \
529 : 2 * PARM_BOUNDARY)
530 \f
531 /* Function results. */
532
533 /* Define how to find the value returned by a function.
534 VALTYPE is the data type of the value (as a tree).
535 If the precise function being called is known, FUNC is its FUNCTION_DECL;
536 otherwise, FUNC is 0. */
537 #define FUNCTION_VALUE(VALTYPE, FUNC) gen_rtx_REG (TYPE_MODE (VALTYPE), 0)
538
539 /* Define how to find the value returned by a library function
540 assuming the value has mode MODE. */
541 #define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, 0)
542
543 /* 1 if N is a possible register number for a function value
544 as seen by the caller. */
545 /* ??? What about r1 in DI/DF values. */
546 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
547
548 /* Tell GCC to use TARGET_RETURN_IN_MEMORY. */
549 #define DEFAULT_PCC_STRUCT_RETURN 0
550 \f
551 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
552 the stack pointer does not matter. The value is tested only in
553 functions that have frame pointers.
554 No definition is equivalent to always zero. */
555 #define EXIT_IGNORE_STACK 0
556
557 /* Epilogue delay slots. */
558 #define DELAY_SLOTS_FOR_EPILOGUE arc_delay_slots_for_epilogue ()
559
560 #define ELIGIBLE_FOR_EPILOGUE_DELAY(TRIAL, SLOTS_FILLED) \
561 arc_eligible_for_epilogue_delay (TRIAL, SLOTS_FILLED)
562
563 /* Output assembler code to FILE to increment profiler label # LABELNO
564 for profiling a function entry. */
565 #define FUNCTION_PROFILER(FILE, LABELNO)
566 \f
567 #define TRAMPOLINE_ALIGNMENT 32
568 #define TRAMPOLINE_SIZE 16
569 \f
570 /* Addressing modes, and classification of registers for them. */
571
572 /* Maximum number of registers that can appear in a valid memory address. */
573 /* The `ld' insn allows 2, but the `st' insn only allows 1. */
574 #define MAX_REGS_PER_ADDRESS 1
575
576 /* We have pre inc/dec (load/store with update). */
577 #define HAVE_PRE_INCREMENT 1
578 #define HAVE_PRE_DECREMENT 1
579
580 /* Recognize any constant value that is a valid address. */
581 #define CONSTANT_ADDRESS_P(X) \
582 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
583 || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST)
584
585 /* Nonzero if the constant value X is a legitimate general operand.
586 We can handle any 32- or 64-bit constant. */
587 /* "1" should work since the largest constant should be a 64 bit critter. */
588 /* ??? Not sure what to do for 64x32 compiler. */
589 #define LEGITIMATE_CONSTANT_P(X) 1
590
591 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
592 and check its validity for a certain class.
593 We have two alternate definitions for each of them.
594 The usual definition accepts all pseudo regs; the other rejects
595 them unless they have been allocated suitable hard regs.
596 The symbol REG_OK_STRICT causes the latter definition to be used.
597
598 Most source files want to accept pseudo regs in the hope that
599 they will get allocated to the class that the insn wants them to be in.
600 Source files for reload pass need to be strict.
601 After reload, it makes no difference, since pseudo regs have
602 been eliminated by then. */
603
604 #ifndef REG_OK_STRICT
605
606 /* Nonzero if X is a hard reg that can be used as an index
607 or if it is a pseudo reg. */
608 #define REG_OK_FOR_INDEX_P(X) \
609 ((unsigned) REGNO (X) - 32 >= FIRST_PSEUDO_REGISTER - 32)
610 /* Nonzero if X is a hard reg that can be used as a base reg
611 or if it is a pseudo reg. */
612 #define REG_OK_FOR_BASE_P(X) \
613 ((unsigned) REGNO (X) - 32 >= FIRST_PSEUDO_REGISTER - 32)
614
615 #else
616
617 /* Nonzero if X is a hard reg that can be used as an index. */
618 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
619 /* Nonzero if X is a hard reg that can be used as a base reg. */
620 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
621
622 #endif
623
624 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
625 that is a valid memory address for an instruction.
626 The MODE argument is the machine mode for the MEM expression
627 that wants to use this address. */
628 /* The `ld' insn allows [reg],[reg+shimm],[reg+limm],[reg+reg],[limm]
629 but the `st' insn only allows [reg],[reg+shimm],[limm].
630 The only thing we can do is only allow the most strict case `st' and hope
631 other parts optimize out the restrictions for `ld'. */
632
633 /* local to this file */
634 #define RTX_OK_FOR_BASE_P(X) \
635 (REG_P (X) && REG_OK_FOR_BASE_P (X))
636
637 /* local to this file */
638 #define RTX_OK_FOR_INDEX_P(X) \
639 (0 && /*???*/ REG_P (X) && REG_OK_FOR_INDEX_P (X))
640
641 /* local to this file */
642 /* ??? Loads can handle any constant, stores can only handle small ones. */
643 #define RTX_OK_FOR_OFFSET_P(X) \
644 (GET_CODE (X) == CONST_INT && SMALL_INT (INTVAL (X)))
645
646 #define LEGITIMATE_OFFSET_ADDRESS_P(MODE, X) \
647 (GET_CODE (X) == PLUS \
648 && RTX_OK_FOR_BASE_P (XEXP (X, 0)) \
649 && (RTX_OK_FOR_INDEX_P (XEXP (X, 1)) \
650 || RTX_OK_FOR_OFFSET_P (XEXP (X, 1))))
651
652 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
653 { if (RTX_OK_FOR_BASE_P (X)) \
654 goto ADDR; \
655 if (LEGITIMATE_OFFSET_ADDRESS_P ((MODE), (X))) \
656 goto ADDR; \
657 if (GET_CODE (X) == CONST_INT && LARGE_INT (INTVAL (X))) \
658 goto ADDR; \
659 if (GET_CODE (X) == SYMBOL_REF \
660 || GET_CODE (X) == LABEL_REF \
661 || GET_CODE (X) == CONST) \
662 goto ADDR; \
663 if ((GET_CODE (X) == PRE_DEC || GET_CODE (X) == PRE_INC) \
664 /* We're restricted here by the `st' insn. */ \
665 && RTX_OK_FOR_BASE_P (XEXP ((X), 0))) \
666 goto ADDR; \
667 }
668 \f
669 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
670 return the mode to be used for the comparison. */
671 #define SELECT_CC_MODE(OP, X, Y) \
672 arc_select_cc_mode (OP, X, Y)
673
674 /* Return nonzero if SELECT_CC_MODE will never return MODE for a
675 floating point inequality comparison. */
676 #define REVERSIBLE_CC_MODE(MODE) 1 /*???*/
677 \f
678 /* Costs. */
679
680 /* Compute extra cost of moving data between one register class
681 and another. */
682 #define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) 2
683
684 /* Compute the cost of moving data between registers and memory. */
685 /* Memory is 3 times as expensive as registers.
686 ??? Is that the right way to look at it? */
687 #define MEMORY_MOVE_COST(MODE,CLASS,IN) \
688 (GET_MODE_SIZE (MODE) <= UNITS_PER_WORD ? 6 : 12)
689
690 /* The cost of a branch insn. */
691 /* ??? What's the right value here? Branches are certainly more
692 expensive than reg->reg moves. */
693 #define BRANCH_COST(speed_p, predictable_p) 2
694
695 /* Nonzero if access to memory by bytes is slow and undesirable.
696 For RISC chips, it means that access to memory by bytes is no
697 better than access by words when possible, so grab a whole word
698 and maybe make use of that. */
699 #define SLOW_BYTE_ACCESS 1
700
701 /* Define this macro if it is as good or better to call a constant
702 function address than to call an address kept in a register. */
703 /* On the ARC, calling through registers is slow. */
704 #define NO_FUNCTION_CSE
705 \f
706 /* Section selection. */
707 /* WARNING: These section names also appear in dwarfout.c. */
708
709 /* The names of the text, data, and readonly-data sections are runtime
710 selectable. */
711
712 #define ARC_SECTION_FORMAT "\t.section %s"
713 #define ARC_DEFAULT_TEXT_SECTION ".text"
714 #define ARC_DEFAULT_DATA_SECTION ".data"
715 #define ARC_DEFAULT_RODATA_SECTION ".rodata"
716
717 extern const char *arc_text_section, *arc_data_section, *arc_rodata_section;
718
719 /* initfini.c uses this in an asm. */
720 #if defined (CRT_INIT) || defined (CRT_FINI)
721 #define TEXT_SECTION_ASM_OP "\t.section .text"
722 #else
723 #define TEXT_SECTION_ASM_OP arc_text_section
724 #endif
725 #define DATA_SECTION_ASM_OP arc_data_section
726
727 #undef READONLY_DATA_SECTION_ASM_OP
728 #define READONLY_DATA_SECTION_ASM_OP arc_rodata_section
729
730 #define BSS_SECTION_ASM_OP "\t.section .bss"
731
732 /* Define this macro if jump tables (for tablejump insns) should be
733 output in the text section, along with the assembler instructions.
734 Otherwise, the readonly data section is used.
735 This macro is irrelevant if there is no separate readonly data section. */
736 /*#define JUMP_TABLES_IN_TEXT_SECTION*/
737
738 /* For DWARF. Marginally different than default so output is "prettier"
739 (and consistent with above). */
740 #define PUSHSECTION_ASM_OP "\t.section "
741
742 /* Tell crtstuff.c we're using ELF. */
743 #define OBJECT_FORMAT_ELF
744 \f
745 /* PIC */
746
747 /* The register number of the register used to address a table of static
748 data addresses in memory. In some cases this register is defined by a
749 processor's ``application binary interface'' (ABI). When this macro
750 is defined, RTL is generated for this register once, as with the stack
751 pointer and frame pointer registers. If this macro is not defined, it
752 is up to the machine-dependent files to allocate such a register (if
753 necessary). */
754 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 26 : INVALID_REGNUM)
755
756 /* Define this macro if the register defined by PIC_OFFSET_TABLE_REGNUM is
757 clobbered by calls. Do not define this macro if PIC_OFFSET_TABLE_REGNUM
758 is not defined. */
759 /* This register is call-saved on the ARC. */
760 /*#define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED*/
761
762 /* A C expression that is nonzero if X is a legitimate immediate
763 operand on the target machine when generating position independent code.
764 You can assume that X satisfies CONSTANT_P, so you need not
765 check this. You can also assume `flag_pic' is true, so you need not
766 check it either. You need not define this macro if all constants
767 (including SYMBOL_REF) can be immediate operands when generating
768 position independent code. */
769 /*#define LEGITIMATE_PIC_OPERAND_P(X)*/
770 \f
771 /* Control the assembler format that we output. */
772
773 /* A C string constant describing how to begin a comment in the target
774 assembler language. The compiler assumes that the comment will
775 end at the end of the line. */
776 #define ASM_COMMENT_START ";"
777
778 /* Output to assembler file text saying following lines
779 may contain character constants, extra white space, comments, etc. */
780 #define ASM_APP_ON ""
781
782 /* Output to assembler file text saying following lines
783 no longer contain unusual constructs. */
784 #define ASM_APP_OFF ""
785
786 /* Globalizing directive for a label. */
787 #define GLOBAL_ASM_OP "\t.global\t"
788
789 /* This is how to output a reference to a user-level label named NAME.
790 `assemble_name' uses this. */
791 /* We mangle all user labels to provide protection from linking code
792 compiled for different cpus. */
793 /* We work around a dwarfout.c deficiency by watching for labels from it and
794 not adding the '_' prefix nor the cpu suffix. There is a comment in
795 dwarfout.c that says it should be using (*targetm.asm_out.internal_label). */
796 extern const char *arc_mangle_cpu;
797 #define ASM_OUTPUT_LABELREF(FILE, NAME) \
798 do { \
799 if ((NAME)[0] == '.' && (NAME)[1] == 'L') \
800 fprintf (FILE, "%s", NAME); \
801 else \
802 { \
803 fputc ('_', FILE); \
804 if (TARGET_MANGLE_CPU && arc_mangle_cpu != NULL) \
805 fprintf (FILE, "%s_", arc_mangle_cpu); \
806 fprintf (FILE, "%s", NAME); \
807 } \
808 } while (0)
809
810 /* Assembler pseudo-op to equate one value with another. */
811 /* ??? This is needed because dwarfout.c provides a default definition too
812 late for defaults.h (which contains the default definition of ASM_OUTPUT_DEF
813 that we use). */
814 #define SET_ASM_OP "\t.set\t"
815
816 /* How to refer to registers in assembler output.
817 This sequence is indexed by compiler's hard-register-number (see above). */
818 #define REGISTER_NAMES \
819 {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
820 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
821 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
822 "r24", "r25", "r26", "fp", "sp", "ilink1", "ilink2", "blink", \
823 "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \
824 "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", \
825 "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", \
826 "r56", "r57", "r58", "r59", "lp_count", "cc"}
827
828 /* Entry to the insn conditionalizer. */
829 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
830 arc_final_prescan_insn (INSN, OPVEC, NOPERANDS)
831
832 /* A C expression which evaluates to true if CODE is a valid
833 punctuation character for use in the `PRINT_OPERAND' macro. */
834 extern char arc_punct_chars[256];
835 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
836 arc_punct_chars[(unsigned char) (CHAR)]
837
838 /* Print operand X (an rtx) in assembler syntax to file FILE.
839 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
840 For `%' followed by punctuation, CODE is the punctuation and X is null. */
841 #define PRINT_OPERAND(FILE, X, CODE) \
842 arc_print_operand (FILE, X, CODE)
843
844 /* A C compound statement to output to stdio stream STREAM the
845 assembler syntax for an instruction operand that is a memory
846 reference whose address is ADDR. ADDR is an RTL expression. */
847 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
848 arc_print_operand_address (FILE, ADDR)
849
850 /* This is how to output an element of a case-vector that is absolute. */
851 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
852 do { \
853 char label[30]; \
854 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
855 fprintf (FILE, "\t.word %%st("); \
856 assemble_name (FILE, label); \
857 fprintf (FILE, ")\n"); \
858 } while (0)
859
860 /* This is how to output an element of a case-vector that is relative. */
861 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
862 do { \
863 char label[30]; \
864 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
865 fprintf (FILE, "\t.word %%st("); \
866 assemble_name (FILE, label); \
867 fprintf (FILE, "-"); \
868 ASM_GENERATE_INTERNAL_LABEL (label, "L", REL); \
869 assemble_name (FILE, label); \
870 fprintf (FILE, ")\n"); \
871 } while (0)
872
873 /* The desired alignment for the location counter at the beginning
874 of a loop. */
875 /* On the ARC, align loops to 32 byte boundaries (cache line size)
876 if -malign-loops. */
877 #define LOOP_ALIGN(LABEL) (TARGET_ALIGN_LOOPS ? 5 : 0)
878
879 /* This is how to output an assembler line
880 that says to advance the location counter
881 to a multiple of 2**LOG bytes. */
882 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
883 do { if ((LOG) != 0) fprintf (FILE, "\t.align %d\n", 1 << (LOG)); } while (0)
884 \f
885 /* Debugging information. */
886
887 /* Generate DBX and DWARF debugging information. */
888 #define DBX_DEBUGGING_INFO 1
889
890 /* Prefer STABS (for now). */
891 #undef PREFERRED_DEBUGGING_TYPE
892 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
893
894 /* Turn off splitting of long stabs. */
895 #define DBX_CONTIN_LENGTH 0
896 \f
897 /* Miscellaneous. */
898
899 /* Specify the machine mode that this machine uses
900 for the index in the tablejump instruction. */
901 #define CASE_VECTOR_MODE Pmode
902
903 /* Define if operations between registers always perform the operation
904 on the full register even if a narrower mode is specified. */
905 #define WORD_REGISTER_OPERATIONS
906
907 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
908 will either zero-extend or sign-extend. The value of this macro should
909 be the code that says which one of the two operations is implicitly
910 done, UNKNOWN if none. */
911 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
912
913 /* Max number of bytes we can move from memory to memory
914 in one reasonably fast instruction. */
915 #define MOVE_MAX 4
916
917 /* Define this to be nonzero if shift instructions ignore all but the low-order
918 few bits. */
919 #define SHIFT_COUNT_TRUNCATED 1
920
921 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
922 is done just by pretending it is already truncated. */
923 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
924
925 /* Specify the machine mode that pointers have.
926 After generation of rtl, the compiler makes no further distinction
927 between pointers and any other objects of this machine mode. */
928 /* ??? The arc doesn't have full 32-bit pointers, but making this PSImode has
929 its own problems (you have to add extendpsisi2 and trucnsipsi2 but how does
930 one do it without getting excess code?). Try to avoid it. */
931 #define Pmode SImode
932
933 /* A function address in a call instruction. */
934 #define FUNCTION_MODE SImode
935
936 /* alloca should avoid clobbering the old register save area. */
937 /* ??? Not defined in tm.texi. */
938 #define SETJMP_VIA_SAVE_AREA
939 \f
940 /* ARC function types. */
941 enum arc_function_type {
942 ARC_FUNCTION_UNKNOWN, ARC_FUNCTION_NORMAL,
943 /* These are interrupt handlers. The name corresponds to the register
944 name that contains the return address. */
945 ARC_FUNCTION_ILINK1, ARC_FUNCTION_ILINK2
946 };
947 #define ARC_INTERRUPT_P(TYPE) \
948 ((TYPE) == ARC_FUNCTION_ILINK1 || (TYPE) == ARC_FUNCTION_ILINK2)
949 /* Compute the type of a function from its DECL. */