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