]> gcc.gnu.org Git - gcc.git/blob - gcc/config/arc/arc.h
alpha.h, [...]: Remove commented out target macro definitions and non-target-specific...
[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
3 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC 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 2, or (at your option)
10 any later version.
11
12 GNU CC 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 GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 /* ??? This is an old port, and is undoubtedly suffering from bit rot. */
23
24 /* Things to do:
25
26 - PREDICATE_CODES
27 - incscc, decscc?
28 - print active compiler options in assembler output
29 */
30
31
32 #undef ASM_SPEC
33 #undef LINK_SPEC
34 #undef STARTFILE_SPEC
35 #undef ENDFILE_SPEC
36 #undef SIZE_TYPE
37 #undef PTRDIFF_TYPE
38 #undef WCHAR_TYPE
39 #undef WCHAR_TYPE_SIZE
40 #undef ASM_OUTPUT_LABELREF
41 \f
42 /* Print subsidiary information on the compiler version in use. */
43 #define TARGET_VERSION fprintf (stderr, " (arc)")
44
45 /* Names to predefine in the preprocessor for this target machine. */
46 #define CPP_PREDEFINES "-Acpu=arc -Amachine=arc -D__arc__"
47
48 /* Additional flags for the preprocessor. */
49 #define CPP_SPEC "\
50 %{!mcpu=*:-D__base__} %{mcpu=base:-D__base__} \
51 %{EB:-D__big_endian__} \
52 "
53
54 /* Pass -mmangle-cpu if we get -mcpu=*.
55 Doing it this way lets one have it on as default with -mcpu=*,
56 but also lets one turn it off with -mno-mangle-cpu. */
57 #define CC1_SPEC "\
58 %{mcpu=*:-mmangle-cpu} \
59 %{EB:%{EL:%emay not use both -EB and -EL}} \
60 %{EB:-mbig-endian} %{EL:-mlittle-endian} \
61 "
62
63 #define ASM_SPEC "%{v} %{EB} %{EL}"
64
65 #define LINK_SPEC "%{v} %{EB} %{EL}"
66
67 #define STARTFILE_SPEC "%{!shared:crt0.o%s} crtinit.o%s"
68
69 #define ENDFILE_SPEC "crtfini.o%s"
70 \f
71 /* Run-time compilation parameters selecting different hardware subsets. */
72
73 extern int target_flags;
74
75 /* Mangle all user symbols for the specified cpu.
76 ARC's can be shipped in which a collection of cpus are coupled together.
77 Each CPU may be different in some way, and thus we may need to distinguish
78 code compiled for one to ensure it isn't linked with code compiled for
79 another. */
80 #define TARGET_MASK_MANGLE_CPU 1
81 #define TARGET_MANGLE_CPU (target_flags & TARGET_MASK_MANGLE_CPU)
82
83 #if 0
84 /* Mangle libgcc symbols by adding a suffix for the specified cpu. */
85 #define TARGET_MASK_MANGLE_CPU_LIBGCC 2
86 #define TARGET_MANGLE_CPU_LIBGCC (target_flags & TARGET_MASK_MANGLE_CPU_LIBGCC)
87 #endif
88
89 /* Align loops to 32 byte boundaries (cache line size). */
90 #define TARGET_MASK_ALIGN_LOOPS 4
91 #define TARGET_ALIGN_LOOPS (target_flags & TARGET_MASK_ALIGN_LOOPS)
92
93 /* Big Endian. */
94 #define TARGET_MASK_BIG_ENDIAN 8
95 #define TARGET_BIG_ENDIAN (target_flags & TARGET_MASK_BIG_ENDIAN)
96
97 /* Turn off conditional execution optimization,
98 so we can see how well it does, or in case it's buggy. */
99 #define TARGET_MASK_NO_COND_EXEC 0x10
100 #define TARGET_NO_COND_EXEC (target_flags & TARGET_MASK_NO_COND_EXEC)
101
102 /* Macro to define tables used to set the flags.
103 This is a list in braces of pairs in braces,
104 each pair being { "NAME", VALUE }
105 where VALUE is the bits to set or minus the bits to clear.
106 An empty string NAME is used to identify the default VALUE. */
107
108 #define TARGET_SWITCHES \
109 { \
110 { "mangle-cpu", TARGET_MASK_MANGLE_CPU }, \
111 { "no-mangle-cpu", -TARGET_MASK_MANGLE_CPU }, \
112 /* { "mangle-cpu-libgcc", TARGET_MASK_MANGLE_CPU_LIBGCC }, */ \
113 /* { "no-mangle-cpu-libgcc", -TARGET_MASK_MANGLE_CPU_LIBGCC }, */ \
114 { "align-loops", TARGET_MASK_ALIGN_LOOPS }, \
115 { "no-align-loops", -TARGET_MASK_ALIGN_LOOPS }, \
116 { "big-endian", TARGET_MASK_BIG_ENDIAN }, \
117 { "little-endian", -TARGET_MASK_BIG_ENDIAN }, \
118 { "no-cond-exec", TARGET_MASK_NO_COND_EXEC }, \
119 SUBTARGET_SWITCHES \
120 { "", TARGET_DEFAULT } \
121 }
122
123 #define TARGET_DEFAULT (0)
124
125 #define SUBTARGET_SWITCHES
126
127 /* Instruction set characteristics.
128 These are internal macros, set by the appropriate -mcpu= option. */
129
130 /* Non-zero means the cpu has a barrel shifter. */
131 #define TARGET_SHIFTER 0
132
133 extern const char *arc_cpu_string;
134 extern const char *arc_text_string,*arc_data_string,*arc_rodata_string;
135
136 #define TARGET_OPTIONS \
137 { \
138 { "cpu=", &arc_cpu_string }, \
139 { "text=", &arc_text_string }, \
140 { "data=", &arc_data_string }, \
141 { "rodata=", &arc_rodata_string }, \
142 }
143
144 /* Which cpu we're compiling for. */
145 extern int arc_cpu_type;
146
147 /* Check if CPU is an extension and set `arc_cpu_type' and `arc_mangle_cpu'
148 appropriately. The result should be non-zero if the cpu is recognized,
149 otherwise zero. This is intended to be redefined in a cover file.
150 This is used by arc_init. */
151 #define ARC_EXTENSION_CPU(cpu) 0
152
153 /* Sometimes certain combinations of command options do not make
154 sense on a particular target machine. You can define a macro
155 `OVERRIDE_OPTIONS' to take account of this. This macro, if
156 defined, is executed once just after all the command options have
157 been parsed.
158
159 Don't use this macro to turn on various extra optimizations for
160 `-O'. That is what `OPTIMIZATION_OPTIONS' is for. */
161
162
163 #define OVERRIDE_OPTIONS \
164 do { \
165 /* These need to be done at start up. It's convenient to do them here. */ \
166 arc_init (); \
167 } while (0)
168 \f
169 /* Target machine storage layout. */
170
171 /* Define to use software floating point emulator for REAL_ARITHMETIC and
172 decimal <-> binary conversion. */
173 #define REAL_ARITHMETIC
174
175 /* Define this if most significant bit is lowest numbered
176 in instructions that operate on numbered bit-fields. */
177 #define BITS_BIG_ENDIAN 1
178
179 /* Define this if most significant byte of a word is the lowest numbered. */
180 #define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN)
181
182 /* Define this if most significant word of a multiword number is the lowest
183 numbered. */
184 #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN)
185
186 /* Define this to set the endianness to use in libgcc2.c, which can
187 not depend on target_flags. */
188 #ifdef __big_endian__
189 #define LIBGCC2_WORDS_BIG_ENDIAN 1
190 #else
191 #define LIBGCC2_WORDS_BIG_ENDIAN 0
192 #endif
193
194 /* Number of bits in an addressable storage unit. */
195 #define BITS_PER_UNIT 8
196
197 /* Width in bits of a "word", which is the contents of a machine register.
198 Note that this is not necessarily the width of data type `int';
199 if using 16-bit ints on a 68000, this would still be 32.
200 But on a machine with 16-bit registers, this would be 16. */
201 #define BITS_PER_WORD 32
202
203 /* Width of a word, in units (bytes). */
204 #define UNITS_PER_WORD 4
205
206 /* Define this macro if it is advisable to hold scalars in registers
207 in a wider mode than that declared by the program. In such cases,
208 the value is constrained to be within the bounds of the declared
209 type, but kept valid in the wider mode. The signedness of the
210 extension may differ from that of the type. */
211 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
212 if (GET_MODE_CLASS (MODE) == MODE_INT \
213 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
214 { \
215 (MODE) = SImode; \
216 }
217
218 /* Define this macro if the promotion described by `PROMOTE_MODE'
219 should also be done for outgoing function arguments. */
220 #define PROMOTE_FUNCTION_ARGS
221
222 /* Likewise, if the function return value is promoted. */
223 #define PROMOTE_FUNCTION_RETURN
224
225 /* Width in bits of a pointer.
226 See also the macro `Pmode' defined below. */
227 #define POINTER_SIZE 32
228
229 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
230 #define PARM_BOUNDARY 32
231
232 /* Boundary (in *bits*) on which stack pointer should be aligned. */
233 #define STACK_BOUNDARY 64
234
235 /* ALIGN FRAMES on word boundaries */
236 #define ARC_STACK_ALIGN(LOC) (((LOC)+7) & ~7)
237
238 /* Allocation boundary (in *bits*) for the code of a function. */
239 #define FUNCTION_BOUNDARY 32
240
241 /* Alignment of field after `int : 0' in a structure. */
242 #define EMPTY_FIELD_BOUNDARY 32
243
244 /* Every structure's size must be a multiple of this. */
245 #define STRUCTURE_SIZE_BOUNDARY 8
246
247 /* A bitfield declared as `int' forces `int' alignment for the struct. */
248 #define PCC_BITFIELD_TYPE_MATTERS 1
249
250 /* No data type wants to be aligned rounder than this. */
251 /* This is bigger than currently necessary for the ARC. If 8 byte floats are
252 ever added it's not clear whether they'll need such alignment or not. For
253 now we assume they will. We can always relax it if necessary but the
254 reverse isn't true. */
255 #define BIGGEST_ALIGNMENT 64
256
257 /* The best alignment to use in cases where we have a choice. */
258 #define FASTEST_ALIGNMENT 32
259
260 /* Make strings word-aligned so strcpy from constants will be faster. */
261 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
262 ((TREE_CODE (EXP) == STRING_CST \
263 && (ALIGN) < FASTEST_ALIGNMENT) \
264 ? FASTEST_ALIGNMENT : (ALIGN))
265
266 /* Make arrays of chars word-aligned for the same reasons. */
267 #define DATA_ALIGNMENT(TYPE, ALIGN) \
268 (TREE_CODE (TYPE) == ARRAY_TYPE \
269 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
270 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
271
272 /* Set this nonzero if move instructions will actually fail to work
273 when given unaligned data. */
274 /* On the ARC the lower address bits are masked to 0 as necessary. The chip
275 won't croak when given an unaligned address, but the insn will still fail
276 to produce the correct result. */
277 #define STRICT_ALIGNMENT 1
278 \f
279 /* Layout of source language data types. */
280
281 #define SHORT_TYPE_SIZE 16
282 #define INT_TYPE_SIZE 32
283 #define LONG_TYPE_SIZE 32
284 #define LONG_LONG_TYPE_SIZE 64
285 #define FLOAT_TYPE_SIZE 32
286 #define DOUBLE_TYPE_SIZE 64
287 #define LONG_DOUBLE_TYPE_SIZE 64
288
289 /* Define this as 1 if `char' should by default be signed; else as 0. */
290 #define DEFAULT_SIGNED_CHAR 1
291
292 #define SIZE_TYPE "long unsigned int"
293 #define PTRDIFF_TYPE "long int"
294 #define WCHAR_TYPE "short unsigned int"
295 #define WCHAR_TYPE_SIZE 16
296 \f
297 /* Standard register usage. */
298
299 /* Number of actual hardware registers.
300 The hardware registers are assigned numbers for the compiler
301 from 0 to just below FIRST_PSEUDO_REGISTER.
302 All registers that the compiler knows about must be given numbers,
303 even those that are not normally considered general registers. */
304 /* Registers 61, 62, and 63 are not really registers and we needn't treat
305 them as such. We still need a register for the condition code. */
306 #define FIRST_PSEUDO_REGISTER 62
307
308 /* 1 for registers that have pervasive standard uses
309 and are not available for the register allocator.
310
311 0-28 - general purpose registers
312 29 - ilink1 (interrupt link register)
313 30 - ilink2 (interrupt link register)
314 31 - blink (branch link register)
315 32-59 - reserved for extensions
316 60 - LP_COUNT
317 61 - condition code
318
319 For doc purposes:
320 61 - short immediate data indicator (setting flags)
321 62 - long immediate data indicator
322 63 - short immediate data indicator (not setting flags).
323
324 The general purpose registers are further broken down into:
325 0-7 - arguments/results
326 8-15 - call used
327 16-23 - call saved
328 24 - call used, static chain pointer
329 25 - call used, gptmp
330 26 - global pointer
331 27 - frame pointer
332 28 - stack pointer
333
334 By default, the extension registers are not available. */
335
336 #define FIXED_REGISTERS \
337 { 0, 0, 0, 0, 0, 0, 0, 0, \
338 0, 0, 0, 0, 0, 0, 0, 0, \
339 0, 0, 0, 0, 0, 0, 0, 0, \
340 0, 0, 0, 1, 1, 1, 1, 0, \
341 \
342 1, 1, 1, 1, 1, 1, 1, 1, \
343 1, 1, 1, 1, 1, 1, 1, 1, \
344 1, 1, 1, 1, 1, 1, 1, 1, \
345 1, 1, 1, 1, 1, 1 }
346
347 /* 1 for registers not available across function calls.
348 These must include the FIXED_REGISTERS and also any
349 registers that can be used without being saved.
350 The latter must include the registers where values are returned
351 and the register where structure-value addresses are passed.
352 Aside from that, you can include as many other registers as you like. */
353
354 #define CALL_USED_REGISTERS \
355 { 1, 1, 1, 1, 1, 1, 1, 1, \
356 1, 1, 1, 1, 1, 1, 1, 1, \
357 0, 0, 0, 0, 0, 0, 0, 0, \
358 1, 1, 1, 1, 1, 1, 1, 1, \
359 \
360 1, 1, 1, 1, 1, 1, 1, 1, \
361 1, 1, 1, 1, 1, 1, 1, 1, \
362 1, 1, 1, 1, 1, 1, 1, 1, \
363 1, 1, 1, 1, 1, 1 }
364
365 /* If defined, an initializer for a vector of integers, containing the
366 numbers of hard registers in the order in which GNU CC should
367 prefer to use them (from most preferred to least). */
368 #define REG_ALLOC_ORDER \
369 { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, \
370 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 31, \
371 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, \
372 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, \
373 27, 28, 29, 30 }
374
375 /* Return number of consecutive hard regs needed starting at reg REGNO
376 to hold something of mode MODE.
377 This is ordinarily the length in words of a value of mode MODE
378 but can be less for certain modes in special long registers. */
379 #define HARD_REGNO_NREGS(REGNO, MODE) \
380 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
381
382 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. */
383 extern const unsigned int arc_hard_regno_mode_ok[];
384 extern unsigned int arc_mode_class[];
385 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
386 ((arc_hard_regno_mode_ok[REGNO] & arc_mode_class[MODE]) != 0)
387
388 /* A C expression that is nonzero if it is desirable to choose
389 register allocation so as to avoid move instructions between a
390 value of mode MODE1 and a value of mode MODE2.
391
392 If `HARD_REGNO_MODE_OK (R, MODE1)' and `HARD_REGNO_MODE_OK (R,
393 MODE2)' are ever different for any R, then `MODES_TIEABLE_P (MODE1,
394 MODE2)' must be zero. */
395
396 /* Tie QI/HI/SI modes together. */
397 #define MODES_TIEABLE_P(MODE1, MODE2) \
398 (GET_MODE_CLASS (MODE1) == MODE_INT \
399 && GET_MODE_CLASS (MODE2) == MODE_INT \
400 && GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD \
401 && GET_MODE_SIZE (MODE2) <= UNITS_PER_WORD)
402 \f
403 /* Register classes and constants. */
404
405 /* Define the classes of registers for register constraints in the
406 machine description. Also define ranges of constants.
407
408 One of the classes must always be named ALL_REGS and include all hard regs.
409 If there is more than one class, another class must be named NO_REGS
410 and contain no registers.
411
412 The name GENERAL_REGS must be the name of a class (or an alias for
413 another name such as ALL_REGS). This is the class of registers
414 that is allowed by "g" or "r" in a register constraint.
415 Also, registers outside this class are allocated only when
416 instructions express preferences for them.
417
418 The classes must be numbered in nondecreasing order; that is,
419 a larger-numbered class must never be contained completely
420 in a smaller-numbered class.
421
422 For any two classes, it is very desirable that there be another
423 class that represents their union.
424
425 It is important that any condition codes have class NO_REGS.
426 See `register_operand'. */
427
428 enum reg_class {
429 NO_REGS, LPCOUNT_REG, GENERAL_REGS, ALL_REGS, LIM_REG_CLASSES
430 };
431
432 #define N_REG_CLASSES (int) LIM_REG_CLASSES
433
434 /* Give names of register classes as strings for dump file. */
435 #define REG_CLASS_NAMES \
436 { "NO_REGS", "LPCOUNT_REG", "GENERAL_REGS", "ALL_REGS" }
437
438 /* Define which registers fit in which classes.
439 This is an initializer for a vector of HARD_REG_SET
440 of length N_REG_CLASSES. */
441
442 #define REG_CLASS_CONTENTS \
443 { {0, 0}, {0, 0x10000000}, {0xffffffff, 0xfffffff}, \
444 {0xffffffff, 0x1fffffff} }
445
446 /* The same information, inverted:
447 Return the class number of the smallest class containing
448 reg number REGNO. This could be a conditional expression
449 or could index an array. */
450 extern enum reg_class arc_regno_reg_class[FIRST_PSEUDO_REGISTER];
451 #define REGNO_REG_CLASS(REGNO) \
452 (arc_regno_reg_class[REGNO])
453
454 /* The class value for index registers, and the one for base regs. */
455 #define INDEX_REG_CLASS GENERAL_REGS
456 #define BASE_REG_CLASS GENERAL_REGS
457
458 /* Get reg_class from a letter such as appears in the machine description. */
459 #define REG_CLASS_FROM_LETTER(C) \
460 ((C) == 'l' ? LPCOUNT_REG /* ??? needed? */ \
461 : NO_REGS)
462
463 /* These assume that REGNO is a hard or pseudo reg number.
464 They give nonzero only if REGNO is a hard reg of the suitable class
465 or a pseudo reg currently allocated to a suitable hard reg.
466 Since they use reg_renumber, they are safe only once reg_renumber
467 has been allocated, which happens in local-alloc.c. */
468 #define REGNO_OK_FOR_BASE_P(REGNO) \
469 ((REGNO) < 29 || (unsigned) reg_renumber[REGNO] < 29)
470 #define REGNO_OK_FOR_INDEX_P(REGNO) \
471 ((REGNO) < 29 || (unsigned) reg_renumber[REGNO] < 29)
472
473 /* Given an rtx X being reloaded into a reg required to be
474 in class CLASS, return the class of reg to actually use.
475 In general this is just CLASS; but on some machines
476 in some cases it is preferable to use a more restrictive class. */
477 #define PREFERRED_RELOAD_CLASS(X,CLASS) \
478 (CLASS)
479
480 /* Return the maximum number of consecutive registers
481 needed to represent mode MODE in a register of class CLASS. */
482 #define CLASS_MAX_NREGS(CLASS, MODE) \
483 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
484
485 /* The letters I, J, K, L, M, N, O, P in a register constraint string
486 can be used to stand for particular ranges of immediate operands.
487 This macro defines what the ranges are.
488 C is the letter, and VALUE is a constant value.
489 Return 1 if VALUE is in the range specified by C. */
490 /* 'I' is used for short immediates (always signed).
491 'J' is used for long immediates.
492 'K' is used for any constant up to 64 bits (for 64x32 situations?). */
493
494 /* local to this file */
495 #define SMALL_INT(X) ((unsigned) ((X) + 0x100) < 0x200)
496 /* local to this file */
497 #define LARGE_INT(X) \
498 ((X) >= (-(HOST_WIDE_INT) 0x7fffffff - 1) \
499 && (X) <= (unsigned HOST_WIDE_INT) 0xffffffff)
500
501 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
502 ((C) == 'I' ? SMALL_INT (VALUE) \
503 : (C) == 'J' ? LARGE_INT (VALUE) \
504 : (C) == 'K' ? 1 \
505 : 0)
506
507 /* Similar, but for floating constants, and defining letters G and H.
508 Here VALUE is the CONST_DOUBLE rtx itself. */
509 /* 'G' is used for integer values for the multiplication insns where the
510 operands are extended from 4 bytes to 8 bytes.
511 'H' is used when any 64 bit constant is allowed. */
512 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
513 ((C) == 'G' ? arc_double_limm_p (VALUE) \
514 : (C) == 'H' ? 1 \
515 : 0)
516
517 /* A C expression that defines the optional machine-dependent constraint
518 letters that can be used to segregate specific types of operands,
519 usually memory references, for the target machine. It should return 1 if
520 VALUE corresponds to the operand type represented by the constraint letter
521 C. If C is not defined as an extra constraint, the value returned should
522 be 0 regardless of VALUE. */
523 /* ??? This currently isn't used. Waiting for PIC. */
524 #if 0
525 #define EXTRA_CONSTRAINT(VALUE, C) \
526 ((C) == 'R' ? (SYMBOL_REF_FLAG (VALUE) || GET_CODE (VALUE) == LABEL_REF) \
527 : 0)
528 #endif
529 \f
530 /* Stack layout and stack pointer usage. */
531
532 /* Define this macro if pushing a word onto the stack moves the stack
533 pointer to a smaller address. */
534 #define STACK_GROWS_DOWNWARD
535
536 /* Define this if the nominal address of the stack frame
537 is at the high-address end of the local variables;
538 that is, each additional local variable allocated
539 goes at a more negative offset in the frame. */
540 #define FRAME_GROWS_DOWNWARD
541
542 /* Offset within stack frame to start allocating local variables at.
543 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
544 first local allocated. Otherwise, it is the offset to the BEGINNING
545 of the first local allocated. */
546 #define STARTING_FRAME_OFFSET 0
547
548 /* Offset from the stack pointer register to the first location at which
549 outgoing arguments are placed. */
550 #define STACK_POINTER_OFFSET FIRST_PARM_OFFSET (0)
551
552 /* Offset of first parameter from the argument pointer register value. */
553 /* 4 bytes for each of previous fp, return address, and previous gp.
554 4 byte reserved area for future considerations. */
555 #define FIRST_PARM_OFFSET(FNDECL) 16
556
557 /* A C expression whose value is RTL representing the address in a
558 stack frame where the pointer to the caller's frame is stored.
559 Assume that FRAMEADDR is an RTL expression for the address of the
560 stack frame itself.
561
562 If you don't define this macro, the default is to return the value
563 of FRAMEADDR--that is, the stack frame address is also the address
564 of the stack word that points to the previous frame. */
565 /* ??? unfinished */
566 /*define DYNAMIC_CHAIN_ADDRESS (FRAMEADDR)*/
567
568 /* A C expression whose value is RTL representing the value of the
569 return address for the frame COUNT steps up from the current frame.
570 FRAMEADDR is the frame pointer of the COUNT frame, or the frame
571 pointer of the COUNT - 1 frame if `RETURN_ADDR_IN_PREVIOUS_FRAME'
572 is defined. */
573 /* The current return address is in r31. The return address of anything
574 farther back is at [%fp,4]. */
575 #if 0 /* The default value should work. */
576 #define RETURN_ADDR_RTX(COUNT, FRAME) \
577 (((COUNT) == -1) \
578 ? gen_rtx_REG (Pmode, 31) \
579 : copy_to_reg (gen_rtx_MEM (Pmode, \
580 memory_address (Pmode, \
581 plus_constant ((FRAME), \
582 UNITS_PER_WORD)))))
583 #endif
584
585 /* Register to use for pushing function arguments. */
586 #define STACK_POINTER_REGNUM 28
587
588 /* Base register for access to local variables of the function. */
589 #define FRAME_POINTER_REGNUM 27
590
591 /* Base register for access to arguments of the function. */
592 #define ARG_POINTER_REGNUM FRAME_POINTER_REGNUM
593
594 /* Register in which static-chain is passed to a function. This must
595 not be a register used by the prologue. */
596 #define STATIC_CHAIN_REGNUM 24
597
598 /* A C expression which is nonzero if a function must have and use a
599 frame pointer. This expression is evaluated in the reload pass.
600 If its value is nonzero the function will have a frame pointer. */
601 #define FRAME_POINTER_REQUIRED \
602 (current_function_calls_alloca)
603
604 /* C statement to store the difference between the frame pointer
605 and the stack pointer values immediately after the function prologue. */
606 #define INITIAL_FRAME_POINTER_OFFSET(VAR) \
607 ((VAR) = arc_compute_frame_size (get_frame_size ()))
608 \f
609 /* Function argument passing. */
610
611 /* When a prototype says `char' or `short', really pass an `int'. */
612 #define PROMOTE_PROTOTYPES 1
613
614 /* If defined, the maximum amount of space required for outgoing
615 arguments will be computed and placed into the variable
616 `current_function_outgoing_args_size'. No space will be pushed
617 onto the stack for each call; instead, the function prologue should
618 increase the stack frame size by this amount. */
619 #define ACCUMULATE_OUTGOING_ARGS 1
620
621 /* Value is the number of bytes of arguments automatically
622 popped when returning from a subroutine call.
623 FUNDECL is the declaration node of the function (as a tree),
624 FUNTYPE is the data type of the function (as a tree),
625 or for a library call it is an identifier node for the subroutine name.
626 SIZE is the number of bytes of arguments passed on the stack. */
627 #define RETURN_POPS_ARGS(DECL, FUNTYPE, SIZE) 0
628
629 /* Define a data type for recording info about an argument list
630 during the scan of that argument list. This data type should
631 hold all necessary information about the function itself
632 and about the args processed so far, enough to enable macros
633 such as FUNCTION_ARG to determine where the next arg should go. */
634 #define CUMULATIVE_ARGS int
635
636 /* Initialize a variable CUM of type CUMULATIVE_ARGS
637 for a call to a function whose data type is FNTYPE.
638 For a library call, FNTYPE is 0. */
639 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
640 ((CUM) = 0)
641
642 /* The number of registers used for parameter passing. Local to this file. */
643 #define MAX_ARC_PARM_REGS 8
644
645 /* 1 if N is a possible register number for function argument passing. */
646 #define FUNCTION_ARG_REGNO_P(N) \
647 ((unsigned) (N) < MAX_ARC_PARM_REGS)
648
649 /* The ROUND_ADVANCE* macros are local to this file. */
650 /* Round SIZE up to a word boundary. */
651 #define ROUND_ADVANCE(SIZE) \
652 (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
653
654 /* Round arg MODE/TYPE up to the next word boundary. */
655 #define ROUND_ADVANCE_ARG(MODE, TYPE) \
656 ((MODE) == BLKmode \
657 ? ROUND_ADVANCE (int_size_in_bytes (TYPE)) \
658 : ROUND_ADVANCE (GET_MODE_SIZE (MODE)))
659
660 /* Round CUM up to the necessary point for argument MODE/TYPE. */
661 #define ROUND_ADVANCE_CUM(CUM, MODE, TYPE) \
662 ((((MODE) == BLKmode ? TYPE_ALIGN (TYPE) : GET_MODE_BITSIZE (MODE)) \
663 > BITS_PER_WORD) \
664 ? (((CUM) + 1) & ~1) \
665 : (CUM))
666
667 /* Return boolean indicating arg of type TYPE and mode MODE will be passed in
668 a reg. This includes arguments that have to be passed by reference as the
669 pointer to them is passed in a reg if one is available (and that is what
670 we're given).
671 When passing arguments NAMED is always 1. When receiving arguments NAMED
672 is 1 for each argument except the last in a stdarg/varargs function. In
673 a stdarg function we want to treat the last named arg as named. In a
674 varargs function we want to treat the last named arg (which is
675 `__builtin_va_alist') as unnamed.
676 This macro is only used in this file. */
677 #define PASS_IN_REG_P(CUM, MODE, TYPE, NAMED) \
678 ((!current_function_varargs || (NAMED)) \
679 && (CUM) < MAX_ARC_PARM_REGS \
680 && ((ROUND_ADVANCE_CUM ((CUM), (MODE), (TYPE)) \
681 + ROUND_ADVANCE_ARG ((MODE), (TYPE)) \
682 <= MAX_ARC_PARM_REGS)))
683
684 /* Determine where to put an argument to a function.
685 Value is zero to push the argument on the stack,
686 or a hard register in which to store the argument.
687
688 MODE is the argument's machine mode.
689 TYPE is the data type of the argument (as a tree).
690 This is null for libcalls where that information may
691 not be available.
692 CUM is a variable of type CUMULATIVE_ARGS which gives info about
693 the preceding args and about the function being called.
694 NAMED is nonzero if this argument is a named parameter
695 (otherwise it is an extra parameter matching an ellipsis). */
696 /* On the ARC the first MAX_ARC_PARM_REGS args are normally in registers
697 and the rest are pushed. */
698 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
699 (PASS_IN_REG_P ((CUM), (MODE), (TYPE), (NAMED)) \
700 ? gen_rtx_REG ((MODE), ROUND_ADVANCE_CUM ((CUM), (MODE), (TYPE))) \
701 : 0)
702
703 /* A C expression for the number of words, at the beginning of an
704 argument, must be put in registers. The value must be zero for
705 arguments that are passed entirely in registers or that are entirely
706 pushed on the stack.
707
708 On some machines, certain arguments must be passed partially in
709 registers and partially in memory. On these machines, typically the
710 first @var{n} words of arguments are passed in registers, and the rest
711 on the stack. If a multi-word argument (a @code{double} or a
712 structure) crosses that boundary, its first few words must be passed
713 in registers and the rest must be pushed. This macro tells the
714 compiler when this occurs, and how many of the words should go in
715 registers. */
716 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) 0
717
718 /* A C expression that indicates when an argument must be passed by
719 reference. If nonzero for an argument, a copy of that argument is
720 made in memory and a pointer to the argument is passed instead of
721 the argument itself. The pointer is passed in whatever way is
722 appropriate for passing a pointer to that type. */
723 /* All aggregates and arguments greater than 8 bytes are passed this way. */
724 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
725 (TYPE \
726 && (AGGREGATE_TYPE_P (TYPE) \
727 || int_size_in_bytes (TYPE) > 8))
728
729 /* A C expression that indicates when it is the called function's
730 responsibility to make copies of arguments passed by reference.
731 If the callee can determine that the argument won't be modified, it can
732 avoid the copy. */
733 /* ??? We'd love to be able to use NAMED here. Unfortunately, it doesn't
734 include the last named argument so we keep track of the args ourselves. */
735
736 #define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) \
737 FUNCTION_ARG_PASS_BY_REFERENCE ((CUM), (MODE), (TYPE), (NAMED))
738
739 /* Update the data in CUM to advance over an argument
740 of mode MODE and data type TYPE.
741 (TYPE is null for libcalls where that information may not be available.) */
742 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
743 ((CUM) = (ROUND_ADVANCE_CUM ((CUM), (MODE), (TYPE)) \
744 + ROUND_ADVANCE_ARG ((MODE), (TYPE))))
745
746 /* If defined, a C expression that gives the alignment boundary, in bits,
747 of an argument with the specified mode and type. If it is not defined,
748 PARM_BOUNDARY is used for all arguments. */
749 #define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \
750 (((TYPE) ? TYPE_ALIGN (TYPE) : GET_MODE_BITSIZE (MODE)) <= PARM_BOUNDARY \
751 ? PARM_BOUNDARY \
752 : 2 * PARM_BOUNDARY)
753
754 /* This macro offers an alternative
755 to using `__builtin_saveregs' and defining the macro
756 `EXPAND_BUILTIN_SAVEREGS'. Use it to store the anonymous register
757 arguments into the stack so that all the arguments appear to have
758 been passed consecutively on the stack. Once this is done, you
759 can use the standard implementation of varargs that works for
760 machines that pass all their arguments on the stack.
761
762 The argument ARGS_SO_FAR is the `CUMULATIVE_ARGS' data structure,
763 containing the values that obtain after processing of the named
764 arguments. The arguments MODE and TYPE describe the last named
765 argument--its machine mode and its data type as a tree node.
766
767 The macro implementation should do two things: first, push onto the
768 stack all the argument registers *not* used for the named
769 arguments, and second, store the size of the data thus pushed into
770 the `int'-valued variable whose name is supplied as the argument
771 PRETEND_SIZE. The value that you store here will serve as
772 additional offset for setting up the stack frame.
773
774 If the argument NO_RTL is nonzero, it means that the
775 arguments of the function are being analyzed for the second time.
776 This happens for an inline function, which is not actually
777 compiled until the end of the source file. The macro
778 `SETUP_INCOMING_VARARGS' should not generate any instructions in
779 this case. */
780
781 #define SETUP_INCOMING_VARARGS(ARGS_SO_FAR, MODE, TYPE, PRETEND_SIZE, NO_RTL) \
782 arc_setup_incoming_varargs(&ARGS_SO_FAR, MODE, TYPE, &PRETEND_SIZE, NO_RTL)
783 \f
784 /* Function results. */
785
786 /* Define how to find the value returned by a function.
787 VALTYPE is the data type of the value (as a tree).
788 If the precise function being called is known, FUNC is its FUNCTION_DECL;
789 otherwise, FUNC is 0. */
790 #define FUNCTION_VALUE(VALTYPE, FUNC) gen_rtx_REG (TYPE_MODE (VALTYPE), 0)
791
792 /* Define how to find the value returned by a library function
793 assuming the value has mode MODE. */
794 #define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, 0)
795
796 /* 1 if N is a possible register number for a function value
797 as seen by the caller. */
798 /* ??? What about r1 in DI/DF values. */
799 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
800
801 /* A C expression which can inhibit the returning of certain function
802 values in registers, based on the type of value. A nonzero value says
803 to return the function value in memory, just as large structures are
804 always returned. Here TYPE will be a C expression of type `tree',
805 representing the data type of the value. */
806 #define RETURN_IN_MEMORY(TYPE) \
807 (AGGREGATE_TYPE_P (TYPE) \
808 || int_size_in_bytes (TYPE) > 8 \
809 || TREE_ADDRESSABLE (TYPE))
810
811 /* Tell GCC to use RETURN_IN_MEMORY. */
812 #define DEFAULT_PCC_STRUCT_RETURN 0
813
814 /* Register in which address to store a structure value
815 is passed to a function, or 0 to use `invisible' first argument. */
816 #define STRUCT_VALUE 0
817 \f
818 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
819 the stack pointer does not matter. The value is tested only in
820 functions that have frame pointers.
821 No definition is equivalent to always zero. */
822 #define EXIT_IGNORE_STACK 0
823
824 /* Epilogue delay slots. */
825 #define DELAY_SLOTS_FOR_EPILOGUE arc_delay_slots_for_epilogue ()
826
827 #define ELIGIBLE_FOR_EPILOGUE_DELAY(TRIAL, SLOTS_FILLED) \
828 arc_eligible_for_epilogue_delay (TRIAL, SLOTS_FILLED)
829
830 /* Output assembler code to FILE to increment profiler label # LABELNO
831 for profiling a function entry. */
832 #define FUNCTION_PROFILER(FILE, LABELNO)
833 \f
834 /* Trampolines. */
835 /* ??? This doesn't work yet because GCC will use as the address of a nested
836 function the address of the trampoline. We need to use that address
837 right shifted by 2. It looks like we'll need PSImode after all. :-( */
838
839 /* Output assembler code for a block containing the constant parts
840 of a trampoline, leaving space for the variable parts. */
841 /* On the ARC, the trampoline is quite simple as we have 32 bit immediate
842 constants.
843
844 mov r24,STATIC
845 j.nd FUNCTION
846 */
847 #define TRAMPOLINE_TEMPLATE(FILE) \
848 do { \
849 assemble_aligned_integer (UNITS_PER_WORD, GEN_INT (0x631f7c00)); \
850 assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \
851 assemble_aligned_integer (UNITS_PER_WORD, GEN_INT (0x381f0000)); \
852 assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \
853 } while (0)
854
855 /* Length in units of the trampoline for entering a nested function. */
856 #define TRAMPOLINE_SIZE 16
857
858 /* Emit RTL insns to initialize the variable parts of a trampoline.
859 FNADDR is an RTX for the address of the function's pure code.
860 CXT is an RTX for the static chain value for the function. */
861 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
862 do { \
863 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 4)), CXT); \
864 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 12)), FNADDR); \
865 emit_insn (gen_flush_icache (validize_mem (gen_rtx_MEM (SImode, TRAMP)))); \
866 } while (0)
867 \f
868 /* Library calls. */
869
870 /* Generate calls to memcpy, memcmp and memset. */
871 #define TARGET_MEM_FUNCTIONS
872 \f
873 /* Addressing modes, and classification of registers for them. */
874
875 /* Maximum number of registers that can appear in a valid memory address. */
876 /* The `ld' insn allows 2, but the `st' insn only allows 1. */
877 #define MAX_REGS_PER_ADDRESS 1
878
879 /* We have pre inc/dec (load/store with update). */
880 #define HAVE_PRE_INCREMENT 1
881 #define HAVE_PRE_DECREMENT 1
882
883 /* Recognize any constant value that is a valid address. */
884 #define CONSTANT_ADDRESS_P(X) \
885 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
886 || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST)
887
888 /* Nonzero if the constant value X is a legitimate general operand.
889 We can handle any 32 or 64 bit constant. */
890 /* "1" should work since the largest constant should be a 64 bit critter. */
891 /* ??? Not sure what to do for 64x32 compiler. */
892 #define LEGITIMATE_CONSTANT_P(X) 1
893
894 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
895 and check its validity for a certain class.
896 We have two alternate definitions for each of them.
897 The usual definition accepts all pseudo regs; the other rejects
898 them unless they have been allocated suitable hard regs.
899 The symbol REG_OK_STRICT causes the latter definition to be used.
900
901 Most source files want to accept pseudo regs in the hope that
902 they will get allocated to the class that the insn wants them to be in.
903 Source files for reload pass need to be strict.
904 After reload, it makes no difference, since pseudo regs have
905 been eliminated by then. */
906
907 #ifndef REG_OK_STRICT
908
909 /* Nonzero if X is a hard reg that can be used as an index
910 or if it is a pseudo reg. */
911 #define REG_OK_FOR_INDEX_P(X) \
912 ((unsigned) REGNO (X) - 29 >= FIRST_PSEUDO_REGISTER - 29)
913 /* Nonzero if X is a hard reg that can be used as a base reg
914 or if it is a pseudo reg. */
915 #define REG_OK_FOR_BASE_P(X) \
916 ((unsigned) REGNO (X) - 29 >= FIRST_PSEUDO_REGISTER - 29)
917
918 #else
919
920 /* Nonzero if X is a hard reg that can be used as an index. */
921 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
922 /* Nonzero if X is a hard reg that can be used as a base reg. */
923 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
924
925 #endif
926
927 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
928 that is a valid memory address for an instruction.
929 The MODE argument is the machine mode for the MEM expression
930 that wants to use this address. */
931 /* The `ld' insn allows [reg],[reg+shimm],[reg+limm],[reg+reg],[limm]
932 but the `st' insn only allows [reg],[reg+shimm],[limm].
933 The only thing we can do is only allow the most strict case `st' and hope
934 other parts optimize out the restrictions for `ld'. */
935
936 /* local to this file */
937 #define RTX_OK_FOR_BASE_P(X) \
938 (REG_P (X) && REG_OK_FOR_BASE_P (X))
939
940 /* local to this file */
941 #define RTX_OK_FOR_INDEX_P(X) \
942 (0 && /*???*/ REG_P (X) && REG_OK_FOR_INDEX_P (X))
943
944 /* local to this file */
945 /* ??? Loads can handle any constant, stores can only handle small ones. */
946 #define RTX_OK_FOR_OFFSET_P(X) \
947 (GET_CODE (X) == CONST_INT && SMALL_INT (INTVAL (X)))
948
949 #define LEGITIMATE_OFFSET_ADDRESS_P(MODE, X) \
950 (GET_CODE (X) == PLUS \
951 && RTX_OK_FOR_BASE_P (XEXP (X, 0)) \
952 && (RTX_OK_FOR_INDEX_P (XEXP (X, 1)) \
953 || RTX_OK_FOR_OFFSET_P (XEXP (X, 1))))
954
955 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
956 { if (RTX_OK_FOR_BASE_P (X)) \
957 goto ADDR; \
958 if (LEGITIMATE_OFFSET_ADDRESS_P ((MODE), (X))) \
959 goto ADDR; \
960 if (GET_CODE (X) == CONST_INT && LARGE_INT (INTVAL (X))) \
961 goto ADDR; \
962 if (GET_CODE (X) == SYMBOL_REF \
963 || GET_CODE (X) == LABEL_REF \
964 || GET_CODE (X) == CONST) \
965 goto ADDR; \
966 if ((GET_CODE (X) == PRE_DEC || GET_CODE (X) == PRE_INC) \
967 /* We're restricted here by the `st' insn. */ \
968 && RTX_OK_FOR_BASE_P (XEXP ((X), 0))) \
969 goto ADDR; \
970 }
971
972 /* Try machine-dependent ways of modifying an illegitimate address
973 to be legitimate. If we find one, return the new, valid address.
974 This macro is used in only one place: `memory_address' in explow.c.
975
976 OLDX is the address as it was before break_out_memory_refs was called.
977 In some cases it is useful to look at this to decide what needs to be done.
978
979 MODE and WIN are passed so that this macro can use
980 GO_IF_LEGITIMATE_ADDRESS.
981
982 It is always safe for this macro to do nothing. It exists to recognize
983 opportunities to optimize the output. */
984
985 #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN)
986
987 /* Go to LABEL if ADDR (a legitimate address expression)
988 has an effect that depends on the machine mode it is used for. */
989 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) \
990 { if (GET_CODE (ADDR) == PRE_DEC) \
991 goto LABEL; \
992 if (GET_CODE (ADDR) == PRE_INC) \
993 goto LABEL; \
994 }
995 \f
996 /* Condition code usage. */
997
998 /* Some insns set all condition code flags, some only set the ZNC flags, and
999 some only set the ZN flags. */
1000
1001 #define EXTRA_CC_MODES \
1002 CC(CCZNCmode, "CCZNC") \
1003 CC(CCZNmode, "CCZN")
1004
1005 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
1006 return the mode to be used for the comparison. */
1007 #define SELECT_CC_MODE(OP, X, Y) \
1008 arc_select_cc_mode (OP, X, Y)
1009
1010 /* Return non-zero if SELECT_CC_MODE will never return MODE for a
1011 floating point inequality comparison. */
1012 #define REVERSIBLE_CC_MODE(MODE) 1 /*???*/
1013 \f
1014 /* Costs. */
1015
1016 /* An insn is define to cost 4 "units", and we work from there.
1017 COSTS_N_INSNS (N) is defined as (N) * 4 - 2 so that seems reasonable.
1018 Some values are supposed to be defined relative to each other and thus
1019 aren't necessarily related to COSTS_N_INSNS. */
1020
1021 /* Compute the cost of computing a constant rtl expression RTX
1022 whose rtx-code is CODE. The body of this macro is a portion
1023 of a switch statement. If the code is computed here,
1024 return it with a return statement. Otherwise, break from the switch. */
1025 /* Small integers are as cheap as registers. 4 byte values can be fetched
1026 as immediate constants - let's give that the cost of an extra insn. */
1027 #define CONST_COSTS(X, CODE, OUTER_CODE) \
1028 case CONST_INT : \
1029 if (SMALL_INT (INTVAL (X))) \
1030 return 0; \
1031 /* fall through */ \
1032 case CONST : \
1033 case LABEL_REF : \
1034 case SYMBOL_REF : \
1035 return 4; \
1036 case CONST_DOUBLE : \
1037 { \
1038 rtx high, low; \
1039 split_double (X, &high, &low); \
1040 return 4 * (!SMALL_INT (INTVAL (high)) \
1041 + !SMALL_INT (INTVAL (low))); \
1042 }
1043
1044 /* Compute the cost of an address. */
1045 #define ADDRESS_COST(ADDR) (REG_P (ADDR) ? 1 : arc_address_cost (ADDR))
1046
1047 /* Compute extra cost of moving data between one register class
1048 and another. */
1049 #define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) 2
1050
1051 /* Compute the cost of moving data between registers and memory. */
1052 /* Memory is 3 times as expensive as registers.
1053 ??? Is that the right way to look at it? */
1054 #define MEMORY_MOVE_COST(MODE,CLASS,IN) \
1055 (GET_MODE_SIZE (MODE) <= UNITS_PER_WORD ? 6 : 12)
1056
1057 /* The cost of a branch insn. */
1058 /* ??? What's the right value here? Branches are certainly more
1059 expensive than reg->reg moves. */
1060 #define BRANCH_COST 2
1061
1062 /* Provide the costs of a rtl expression. This is in the body of a
1063 switch on CODE. The purpose for the cost of MULT is to encourage
1064 `synth_mult' to find a synthetic multiply when reasonable.
1065
1066 If we need more than 12 insns to do a multiply, then go out-of-line,
1067 since the call overhead will be < 10% of the cost of the multiply. */
1068 #define RTX_COSTS(X, CODE, OUTER_CODE) \
1069 case ASHIFT : \
1070 case ASHIFTRT : \
1071 case LSHIFTRT : \
1072 if (TARGET_SHIFTER) \
1073 return COSTS_N_INSNS (1); \
1074 if (GET_CODE (XEXP ((X), 1)) != CONST_INT) \
1075 return COSTS_N_INSNS (16); \
1076 return COSTS_N_INSNS (INTVAL (XEXP ((X), 1)));
1077
1078 /* Nonzero if access to memory by bytes is slow and undesirable.
1079 For RISC chips, it means that access to memory by bytes is no
1080 better than access by words when possible, so grab a whole word
1081 and maybe make use of that. */
1082 #define SLOW_BYTE_ACCESS 1
1083
1084 /* Define this macro if it is as good or better to call a constant
1085 function address than to call an address kept in a register. */
1086 /* On the ARC, calling through registers is slow. */
1087 #define NO_FUNCTION_CSE
1088
1089 /* Define this macro if it is as good or better for a function to call
1090 itself with an explicit address than to call an address kept in a
1091 register. */
1092 /* On the ARC, calling through registers is slow. */
1093 #define NO_RECURSIVE_FUNCTION_CSE
1094 \f
1095 /* Section selection. */
1096 /* WARNING: These section names also appear in dwarfout.c. */
1097
1098 /* The names of the text, data, and readonly-data sections are runtime
1099 selectable. */
1100
1101 #define ARC_SECTION_FORMAT "\t.section %s"
1102 #define ARC_DEFAULT_TEXT_SECTION ".text"
1103 #define ARC_DEFAULT_DATA_SECTION ".data"
1104 #define ARC_DEFAULT_RODATA_SECTION ".rodata"
1105
1106 extern const char *arc_text_section, *arc_data_section, *arc_rodata_section;
1107
1108 /* initfini.c uses this in an asm. */
1109 #if defined (CRT_INIT) || defined (CRT_FINI)
1110 #define TEXT_SECTION_ASM_OP "\t.section .text"
1111 #else
1112 #define TEXT_SECTION_ASM_OP arc_text_section /*"\t.section .text"*/
1113 #endif
1114 #define DATA_SECTION_ASM_OP arc_data_section /*"\t.section .data"*/
1115
1116 #undef CONST_SECTION_ASM_OP
1117 #define CONST_SECTION_ASM_OP arc_rodata_section /*"\t.section .rodata"*/
1118
1119 #define BSS_SECTION_ASM_OP "\t.section .bss"
1120
1121 /* Define this macro if jump tables (for tablejump insns) should be
1122 output in the text section, along with the assembler instructions.
1123 Otherwise, the readonly data section is used.
1124 This macro is irrelevant if there is no separate readonly data section. */
1125 /*#define JUMP_TABLES_IN_TEXT_SECTION*/
1126
1127 /* Define this macro if references to a symbol must be treated
1128 differently depending on something about the variable or
1129 function named by the symbol (such as what section it is in).
1130
1131 The macro definition, if any, is executed immediately after the
1132 rtl for DECL or other node is created.
1133 The value of the rtl will be a `mem' whose address is a
1134 `symbol_ref'.
1135
1136 The usual thing for this macro to do is to store a flag in the
1137 `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified
1138 name string in the `symbol_ref' (if one bit is not enough
1139 information). */
1140
1141 /* On the ARC, function addresses are not the same as normal addresses.
1142 Branch to absolute address insns take an address that is right-shifted
1143 by 2. We encode the fact that we have a function here, and then emit a
1144 special assembler op when outputting the address. */
1145 #define ENCODE_SECTION_INFO(DECL) \
1146 do { \
1147 if (TREE_CODE (DECL) == FUNCTION_DECL) \
1148 SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1; \
1149 } while (0)
1150
1151 /* Decode SYM_NAME and store the real name part in VAR, sans
1152 the characters that encode section info. Define this macro if
1153 ENCODE_SECTION_INFO alters the symbol's name string. */
1154 /*#define STRIP_NAME_ENCODING(VAR, SYM_NAME)*/
1155
1156 /* For DWARF. Marginally different than default so output is "prettier"
1157 (and consistent with above). */
1158 #define PUSHSECTION_ASM_OP "\t.section "
1159
1160 /* Tell crtstuff.c we're using ELF. */
1161 #define OBJECT_FORMAT_ELF
1162 \f
1163 /* PIC */
1164
1165 /* The register number of the register used to address a table of static
1166 data addresses in memory. In some cases this register is defined by a
1167 processor's ``application binary interface'' (ABI). When this macro
1168 is defined, RTL is generated for this register once, as with the stack
1169 pointer and frame pointer registers. If this macro is not defined, it
1170 is up to the machine-dependent files to allocate such a register (if
1171 necessary). */
1172 #define PIC_OFFSET_TABLE_REGNUM 26
1173
1174 /* Define this macro if the register defined by PIC_OFFSET_TABLE_REGNUM is
1175 clobbered by calls. Do not define this macro if PIC_OFFSET_TABLE_REGNUM
1176 is not defined. */
1177 /* This register is call-saved on the ARC. */
1178 /*#define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED*/
1179
1180 /* By generating position-independent code, when two different programs (A
1181 and B) share a common library (libC.a), the text of the library can be
1182 shared whether or not the library is linked at the same address for both
1183 programs. In some of these environments, position-independent code
1184 requires not only the use of different addressing modes, but also
1185 special code to enable the use of these addressing modes.
1186
1187 The FINALIZE_PIC macro serves as a hook to emit these special
1188 codes once the function is being compiled into assembly code, but not
1189 before. (It is not done before, because in the case of compiling an
1190 inline function, it would lead to multiple PIC prologues being
1191 included in functions which used inline functions and were compiled to
1192 assembly language.) */
1193
1194 #define FINALIZE_PIC arc_finalize_pic ()
1195
1196 /* A C expression that is nonzero if X is a legitimate immediate
1197 operand on the target machine when generating position independent code.
1198 You can assume that X satisfies CONSTANT_P, so you need not
1199 check this. You can also assume `flag_pic' is true, so you need not
1200 check it either. You need not define this macro if all constants
1201 (including SYMBOL_REF) can be immediate operands when generating
1202 position independent code. */
1203 /*#define LEGITIMATE_PIC_OPERAND_P(X)*/
1204 \f
1205 /* Control the assembler format that we output. */
1206
1207 /* Output at beginning of assembler file. */
1208 #undef ASM_FILE_START
1209 #define ASM_FILE_START(FILE) arc_asm_file_start (FILE)
1210
1211 /* A C string constant describing how to begin a comment in the target
1212 assembler language. The compiler assumes that the comment will
1213 end at the end of the line. */
1214 #define ASM_COMMENT_START ";"
1215
1216 /* Output to assembler file text saying following lines
1217 may contain character constants, extra white space, comments, etc. */
1218 #define ASM_APP_ON ""
1219
1220 /* Output to assembler file text saying following lines
1221 no longer contain unusual constructs. */
1222 #define ASM_APP_OFF ""
1223
1224 /* This is how to output the definition of a user-level label named NAME,
1225 such as the label on a static function or variable NAME. */
1226 #define ASM_OUTPUT_LABEL(FILE, NAME) \
1227 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
1228
1229 /* This is how to output a command to make the user-level label named NAME
1230 defined for reference from other files. */
1231 #define ASM_GLOBALIZE_LABEL(FILE, NAME) \
1232 do { \
1233 fputs ("\t.global\t", FILE); \
1234 assemble_name (FILE, NAME); \
1235 fputs ("\n", FILE); \
1236 } while (0)
1237
1238 /* A C statement (sans semicolon) to output on FILE an assembler pseudo-op to
1239 declare a library function name external. The name of the library function
1240 is given by SYMREF, which has type RTX and is a SYMBOL_REF. */
1241 #if 0
1242 /* On the ARC we want to have libgcc's for multiple cpus in one binary.
1243 We can't use `assemble_name' here as that will call ASM_OUTPUT_LABELREF
1244 and we'll get another suffix added on if -mmangle-cpu. */
1245 extern const char *arc_mangle_cpu;
1246 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, SYMREF) \
1247 do { \
1248 if (TARGET_MANGLE_CPU_LIBGCC) \
1249 { \
1250 fprintf (FILE, "\t.rename\t_%s, _%s%s\n", \
1251 XSTR (SYMREF, 0), XSTR (SYMREF, 0), \
1252 arc_mangle_suffix); \
1253 } \
1254 } while (0)
1255 #endif
1256
1257 /* This is how to output a reference to a user-level label named NAME.
1258 `assemble_name' uses this. */
1259 /* We mangle all user labels to provide protection from linking code
1260 compiled for different cpus. */
1261 /* We work around a dwarfout.c deficiency by watching for labels from it and
1262 not adding the '_' prefix nor the cpu suffix. There is a comment in
1263 dwarfout.c that says it should be using ASM_OUTPUT_INTERNAL_LABEL. */
1264 extern const char *arc_mangle_cpu;
1265 #define ASM_OUTPUT_LABELREF(FILE, NAME) \
1266 do { \
1267 if ((NAME)[0] == '.' && (NAME)[1] == 'L') \
1268 fprintf (FILE, "%s", NAME); \
1269 else \
1270 { \
1271 fputc ('_', FILE); \
1272 if (TARGET_MANGLE_CPU && arc_mangle_cpu != NULL) \
1273 fprintf (FILE, "%s_", arc_mangle_cpu); \
1274 fprintf (FILE, "%s", NAME); \
1275 } \
1276 } while (0)
1277
1278 /* This is how to output a definition of an internal numbered label where
1279 PREFIX is the class of label and NUM is the number within the class. */
1280 #undef ASM_OUTPUT_INTERNAL_LABEL
1281 #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM) \
1282 do { \
1283 arc_ccfsm_at_label (PREFIX, NUM); \
1284 fprintf (FILE, ".%s%d:\n", PREFIX, NUM); \
1285 } while (0)
1286
1287 /* Store in OUTPUT a string (made with alloca) containing
1288 an assembler-name for a local static variable named NAME.
1289 LABELNO is an integer which is different for each call. */
1290 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
1291 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
1292 sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
1293
1294 /* Assembler pseudo-op to equate one value with another. */
1295 /* ??? This is needed because dwarfout.c provides a default definition too
1296 late for defaults.h (which contains the default definition of ASM_OUTPUT_DEF
1297 that we use). */
1298 #define SET_ASM_OP "\t.set\t"
1299
1300 /* How to refer to registers in assembler output.
1301 This sequence is indexed by compiler's hard-register-number (see above). */
1302 #define REGISTER_NAMES \
1303 {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
1304 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
1305 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
1306 "r24", "r25", "r26", "fp", "sp", "ilink1", "ilink2", "blink", \
1307 "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \
1308 "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", \
1309 "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", \
1310 "r56", "r57", "r58", "r59", "lp_count", "cc"}
1311
1312 /* Entry to the insn conditionalizer. */
1313 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
1314 arc_final_prescan_insn (INSN, OPVEC, NOPERANDS)
1315
1316 /* A C expression which evaluates to true if CODE is a valid
1317 punctuation character for use in the `PRINT_OPERAND' macro. */
1318 extern char arc_punct_chars[256];
1319 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
1320 arc_punct_chars[(unsigned char) (CHAR)]
1321
1322 /* Print operand X (an rtx) in assembler syntax to file FILE.
1323 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1324 For `%' followed by punctuation, CODE is the punctuation and X is null. */
1325 #define PRINT_OPERAND(FILE, X, CODE) \
1326 arc_print_operand (FILE, X, CODE)
1327
1328 /* A C compound statement to output to stdio stream STREAM the
1329 assembler syntax for an instruction operand that is a memory
1330 reference whose address is ADDR. ADDR is an RTL expression.
1331
1332 On some machines, the syntax for a symbolic address depends on
1333 the section that the address refers to. On these machines,
1334 define the macro `ENCODE_SECTION_INFO' to store the information
1335 into the `symbol_ref', and then check for it here. */
1336 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
1337 arc_print_operand_address (FILE, ADDR)
1338
1339 /* This is how to output an element of a case-vector that is absolute. */
1340 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
1341 do { \
1342 char label[30]; \
1343 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
1344 fprintf (FILE, "\t.word %%st("); \
1345 assemble_name (FILE, label); \
1346 fprintf (FILE, ")\n"); \
1347 } while (0)
1348
1349 /* This is how to output an element of a case-vector that is relative. */
1350 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
1351 do { \
1352 char label[30]; \
1353 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
1354 fprintf (FILE, "\t.word %%st("); \
1355 assemble_name (FILE, label); \
1356 fprintf (FILE, "-"); \
1357 ASM_GENERATE_INTERNAL_LABEL (label, "L", REL); \
1358 assemble_name (FILE, label); \
1359 fprintf (FILE, ")\n"); \
1360 } while (0)
1361
1362 /* The desired alignment for the location counter at the beginning
1363 of a loop. */
1364 /* On the ARC, align loops to 32 byte boundaries (cache line size)
1365 if -malign-loops. */
1366 #define LOOP_ALIGN(LABEL) (TARGET_ALIGN_LOOPS ? 5 : 0)
1367
1368 /* This is how to output an assembler line
1369 that says to advance the location counter
1370 to a multiple of 2**LOG bytes. */
1371 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
1372 do { if ((LOG) != 0) fprintf (FILE, "\t.align %d\n", 1 << (LOG)); } while (0)
1373 \f
1374 /* Debugging information. */
1375
1376 /* Generate DBX and DWARF debugging information. */
1377 #ifndef DBX_DEBUGGING_INFO
1378 #define DBX_DEBUGGING_INFO
1379 #endif
1380 #ifndef DWARF_DEBUGGING_INFO
1381 #define DWARF_DEBUGGING_INFO
1382 #endif
1383
1384 /* Prefer STABS (for now). */
1385 #undef PREFERRED_DEBUGGING_TYPE
1386 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
1387
1388 /* Turn off splitting of long stabs. */
1389 #define DBX_CONTIN_LENGTH 0
1390 \f
1391 /* Miscellaneous. */
1392
1393 /* Specify the machine mode that this machine uses
1394 for the index in the tablejump instruction. */
1395 #define CASE_VECTOR_MODE Pmode
1396
1397 /* Define as C expression which evaluates to nonzero if the tablejump
1398 instruction expects the table to contain offsets from the address of the
1399 table.
1400 Do not define this if the table should contain absolute addresses. */
1401 /* It's not clear what PIC will look like or whether we want to use -fpic
1402 for the embedded form currently being talked about. For now require -fpic
1403 to get pc relative switch tables. */
1404 /*#define CASE_VECTOR_PC_RELATIVE 1 */
1405
1406 /* Define if operations between registers always perform the operation
1407 on the full register even if a narrower mode is specified. */
1408 #define WORD_REGISTER_OPERATIONS
1409
1410 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1411 will either zero-extend or sign-extend. The value of this macro should
1412 be the code that says which one of the two operations is implicitly
1413 done, NIL if none. */
1414 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
1415
1416 /* Max number of bytes we can move from memory to memory
1417 in one reasonably fast instruction. */
1418 #define MOVE_MAX 4
1419
1420 /* Define this to be nonzero if shift instructions ignore all but the low-order
1421 few bits. */
1422 #define SHIFT_COUNT_TRUNCATED 1
1423
1424 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1425 is done just by pretending it is already truncated. */
1426 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1427
1428 /* We assume that the store-condition-codes instructions store 0 for false
1429 and some other value for true. This is the value stored for true. */
1430 #define STORE_FLAG_VALUE 1
1431
1432 /* Specify the machine mode that pointers have.
1433 After generation of rtl, the compiler makes no further distinction
1434 between pointers and any other objects of this machine mode. */
1435 /* ??? The arc doesn't have full 32 bit pointers, but making this PSImode has
1436 its own problems (you have to add extendpsisi2 and trucnsipsi2 but how does
1437 one do it without getting excess code?). Try to avoid it. */
1438 #define Pmode SImode
1439
1440 /* A function address in a call instruction. */
1441 #define FUNCTION_MODE SImode
1442
1443 /* alloca should avoid clobbering the old register save area. */
1444 /* ??? Not defined in tm.texi. */
1445 #define SETJMP_VIA_SAVE_AREA
1446 \f
1447 /* Define the information needed to generate branch and scc insns. This is
1448 stored from the compare operation. Note that we can't use "rtx" here
1449 since it hasn't been defined! */
1450 extern struct rtx_def *arc_compare_op0, *arc_compare_op1;
1451
1452 /* ARC function types. */
1453 enum arc_function_type {
1454 ARC_FUNCTION_UNKNOWN, ARC_FUNCTION_NORMAL,
1455 /* These are interrupt handlers. The name corresponds to the register
1456 name that contains the return address. */
1457 ARC_FUNCTION_ILINK1, ARC_FUNCTION_ILINK2
1458 };
1459 #define ARC_INTERRUPT_P(TYPE) \
1460 ((TYPE) == ARC_FUNCTION_ILINK1 || (TYPE) == ARC_FUNCTION_ILINK2)
1461 /* Compute the type of a function from its DECL. */
1462
1463 \f
1464 /* Implement `va_start' for varargs and stdarg. */
1465 #define EXPAND_BUILTIN_VA_START(stdarg, valist, nextarg) \
1466 arc_va_start (stdarg, valist, nextarg)
1467
1468 /* Implement `va_arg'. */
1469 #define EXPAND_BUILTIN_VA_ARG(valist, type) \
1470 arc_va_arg (valist, type)
This page took 0.109711 seconds and 5 git commands to generate.