]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/arc/arc.h
arc.h (BITS_PER_UNIT): Removed.
[thirdparty/gcc.git] / gcc / config / arc / arc.h
1 /* Definitions of target machine for GNU compiler, Synopsys DesignWare ARC cpu.
2 Copyright (C) 1994, 1995, 1997, 1998, 2007-2013
3 Free Software Foundation, Inc.
4
5 Sources derived from work done by Sankhya Technologies (www.sankhya.com) on
6 behalf of Synopsys Inc.
7
8 Position Independent Code support added,Code cleaned up,
9 Comments and Support For ARC700 instructions added by
10 Saurabh Verma (saurabh.verma@codito.com)
11 Ramana Radhakrishnan(ramana.radhakrishnan@codito.com)
12
13 This file is part of GCC.
14
15 GCC is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 3, or (at your option)
18 any later version.
19
20 GCC is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with GCC; see the file COPYING3. If not see
27 <http://www.gnu.org/licenses/>. */
28
29 #ifndef GCC_ARC_H
30 #define GCC_ARC_H
31
32 /* Things to do:
33
34 - incscc, decscc?
35
36 */
37
38 #define SYMBOL_FLAG_SHORT_CALL (SYMBOL_FLAG_MACH_DEP << 0)
39 #define SYMBOL_FLAG_MEDIUM_CALL (SYMBOL_FLAG_MACH_DEP << 1)
40 #define SYMBOL_FLAG_LONG_CALL (SYMBOL_FLAG_MACH_DEP << 2)
41
42 /* Check if this symbol has a long_call attribute in its declaration */
43 #define SYMBOL_REF_LONG_CALL_P(X) \
44 ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_LONG_CALL) != 0)
45
46 /* Check if this symbol has a medium_call attribute in its declaration */
47 #define SYMBOL_REF_MEDIUM_CALL_P(X) \
48 ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_MEDIUM_CALL) != 0)
49
50 /* Check if this symbol has a short_call attribute in its declaration */
51 #define SYMBOL_REF_SHORT_CALL_P(X) \
52 ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_SHORT_CALL) != 0)
53
54 #undef ASM_SPEC
55 #undef LINK_SPEC
56 #undef STARTFILE_SPEC
57 #undef ENDFILE_SPEC
58 #undef SIZE_TYPE
59 #undef PTRDIFF_TYPE
60 #undef WCHAR_TYPE
61 #undef WCHAR_TYPE_SIZE
62 #undef ASM_APP_ON
63 #undef ASM_APP_OFF
64 #undef CC1_SPEC
65
66 /* Names to predefine in the preprocessor for this target machine. */
67 #define TARGET_CPU_CPP_BUILTINS() \
68 do { \
69 builtin_define ("__arc__"); \
70 if (TARGET_A5) \
71 builtin_define ("__A5__"); \
72 else if (TARGET_ARC600) \
73 { \
74 builtin_define ("__A6__"); \
75 builtin_define ("__ARC600__"); \
76 } \
77 else if (TARGET_ARC601) \
78 { \
79 builtin_define ("__ARC601__"); \
80 } \
81 else if (TARGET_ARC700) \
82 { \
83 builtin_define ("__A7__"); \
84 builtin_define ("__ARC700__"); \
85 } \
86 if (TARGET_NORM) \
87 { \
88 builtin_define ("__ARC_NORM__");\
89 builtin_define ("__Xnorm"); \
90 } \
91 if (TARGET_MUL64_SET) \
92 builtin_define ("__ARC_MUL64__");\
93 if (TARGET_MULMAC_32BY16_SET) \
94 builtin_define ("__ARC_MUL32BY16__");\
95 if (TARGET_SIMD_SET) \
96 builtin_define ("__ARC_SIMD__"); \
97 if (TARGET_BARREL_SHIFTER) \
98 builtin_define ("__Xbarrel_shifter");\
99 builtin_assert ("cpu=arc"); \
100 builtin_assert ("machine=arc"); \
101 builtin_define (TARGET_BIG_ENDIAN \
102 ? "__BIG_ENDIAN__" : "__LITTLE_ENDIAN__"); \
103 if (TARGET_BIG_ENDIAN) \
104 builtin_define ("__big_endian__"); \
105 } while(0)
106
107 #if DEFAULT_LIBC == LIBC_UCLIBC
108
109 #define TARGET_OS_CPP_BUILTINS() \
110 do \
111 { \
112 GNU_USER_TARGET_OS_CPP_BUILTINS (); \
113 } \
114 while (0)
115 #endif
116
117 /* Match the macros used in the assembler. */
118 #define CPP_SPEC "\
119 %{msimd:-D__Xsimd} %{mno-mpy:-D__Xno_mpy} %{mswap:-D__Xswap} \
120 %{mmin-max:-D__Xmin_max} %{mEA:-D__Xea} \
121 %{mspfp*:-D__Xspfp} %{mdpfp*:-D__Xdpfp} \
122 %{mmac-d16:-D__Xxmac_d16} %{mmac-24:-D__Xxmac_24} \
123 %{mdsp-packa:-D__Xdsp_packa} %{mcrc:-D__Xcrc} %{mdvbf:-D__Xdvbf} \
124 %{mtelephony:-D__Xtelephony} %{mxy:-D__Xxy} %{mmul64: -D__Xmult32} \
125 %{mlock:-D__Xlock} %{mswape:-D__Xswape} %{mrtsc:-D__Xrtsc} \
126 "
127
128 #define CC1_SPEC "\
129 %{EB:%{EL:%emay not use both -EB and -EL}} \
130 %{EB:-mbig-endian} %{EL:-mlittle-endian} \
131 "
132
133 #define ASM_DEFAULT "-mARC700 -mEA"
134
135 #define ASM_SPEC "\
136 %{mbig-endian|EB:-EB} %{EL} \
137 %{mcpu=A5|mcpu=a5|mA5:-mA5} \
138 %{mcpu=ARC600:-mARC600} \
139 %{mcpu=ARC601:-mARC601} \
140 %{mcpu=ARC700:-mARC700} \
141 %{mcpu=ARC700:-mEA} \
142 %{!mcpu=*:" ASM_DEFAULT "} \
143 %{mbarrel-shifter} %{mno-mpy} %{mmul64} %{mmul32x16:-mdsp-packa} %{mnorm} \
144 %{mswap} %{mEA} %{mmin-max} %{mspfp*} %{mdpfp*} \
145 %{msimd} \
146 %{mmac-d16} %{mmac-24} %{mdsp-packa} %{mcrc} %{mdvbf} %{mtelephony} %{mxy} \
147 %{mcpu=ARC700|!mcpu=*:%{mlock}} \
148 %{mcpu=ARC700|!mcpu=*:%{mswape}} \
149 %{mcpu=ARC700|!mcpu=*:%{mrtsc}} \
150 "
151
152 #if DEFAULT_LIBC == LIBC_UCLIBC
153 /* Note that the default is to link against dynamic libraries, if they are
154 available. Override with -static. */
155 #define LINK_SPEC "%{h*} \
156 %{static:-Bstatic} \
157 %{symbolic:-Bsymbolic} \
158 %{rdynamic:-export-dynamic}\
159 -dynamic-linker /lib/ld-uClibc.so.0 \
160 -X %{mbig-endian:-EB} \
161 %{EB} %{EL} \
162 %{marclinux*} \
163 %{!marclinux*: %{pg|p|profile:-marclinux_prof;: -marclinux}} \
164 %{!z:-z max-page-size=0x2000 -z common-page-size=0x2000} \
165 %{shared:-shared}"
166 /* Like the standard LINK_COMMAND_SPEC, but add %G when building
167 a shared library with -nostdlib, so that the hidden functions of libgcc
168 will be incorporated.
169 N.B., we don't want a plain -lgcc, as this would lead to re-exporting
170 non-hidden functions, so we have to consider libgcc_s.so.* first, which in
171 turn should be wrapped with --as-needed. */
172 #define LINK_COMMAND_SPEC "\
173 %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
174 %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
175 %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
176 %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\
177 %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\
178 %(mflib)\
179 %{fprofile-arcs|fprofile-generate|coverage:-lgcov}\
180 %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\
181 %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}"
182
183 #else
184 #define LINK_SPEC "%{mbig-endian:-EB} %{EB} %{EL}\
185 %{pg|p:-marcelf_prof;mA7|mARC700|mcpu=arc700|mcpu=ARC700: -marcelf}"
186 #endif
187
188 #if DEFAULT_LIBC != LIBC_UCLIBC
189 #define STARTFILE_SPEC "%{!shared:crt0.o%s} crti%O%s %{pg|p:crtg.o%s} crtbegin.o%s"
190 #else
191 #define STARTFILE_SPEC "%{!shared:%{!mkernel:crt1.o%s}} crti.o%s \
192 %{!shared:%{pg|p|profile:crtg.o%s} crtbegin.o%s} %{shared:crtbeginS.o%s}"
193
194 #endif
195
196 #if DEFAULT_LIBC != LIBC_UCLIBC
197 #define ENDFILE_SPEC "%{pg|p:crtgend.o%s} crtend.o%s crtn%O%s"
198 #else
199 #define ENDFILE_SPEC "%{!shared:%{pg|p|profile:crtgend.o%s} crtend.o%s} \
200 %{shared:crtendS.o%s} crtn.o%s"
201
202 #endif
203
204 #if DEFAULT_LIBC == LIBC_UCLIBC
205 #undef LIB_SPEC
206 #define LIB_SPEC \
207 "%{pthread:-lpthread} \
208 %{shared:-lc} \
209 %{!shared:%{pg|p|profile:-lgmon -u profil --defsym __profil=profil} -lc}"
210 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
211 #else
212 #undef LIB_SPEC
213 /* -lc_p not present for arc-elf32-* : ashwin */
214 #define LIB_SPEC "%{!shared:%{g*:-lg} %{pg|p:-lgmon} -lc}"
215 #endif
216
217 #ifndef DRIVER_ENDIAN_SELF_SPECS
218 #define DRIVER_ENDIAN_SELF_SPECS ""
219 #endif
220 #ifndef TARGET_SDATA_DEFAULT
221 #define TARGET_SDATA_DEFAULT 1
222 #endif
223 #ifndef TARGET_MMEDIUM_CALLS_DEFAULT
224 #define TARGET_MMEDIUM_CALLS_DEFAULT 0
225 #endif
226
227 #define DRIVER_SELF_SPECS DRIVER_ENDIAN_SELF_SPECS \
228 "%{mARC5|mA5: -mcpu=A5 %<mARC5 %<mA5}" \
229 "%{mARC600|mA6: -mcpu=ARC600 %<mARC600 %<mA6}" \
230 "%{mARC601: -mcpu=ARC601 %<mARC601}" \
231 "%{mARC700|mA7: -mcpu=ARC700 %<mARC700 %<mA7}" \
232 "%{mbarrel_shifte*: -mbarrel-shifte%* %<mbarrel_shifte*}" \
233 "%{mEA: -mea %<mEA}" \
234 "%{mspfp_*: -mspfp-%* %<mspfp_*}" \
235 "%{mdpfp_*: -mdpfp-%* %<mdpfp_*}" \
236 "%{mdsp_pack*: -mdsp-pack%* %<mdsp_pack*}" \
237 "%{mmac_*: -mmac-%* %<mmac_*}" \
238 "%{multcost=*: -mmultcost=%* %<multcost=*}"
239
240 /* Run-time compilation parameters selecting different hardware subsets. */
241
242 #define TARGET_MIXED_CODE (TARGET_MIXED_CODE_SET)
243
244 #define TARGET_SPFP (TARGET_SPFP_FAST_SET || TARGET_SPFP_COMPACT_SET)
245 #define TARGET_DPFP (TARGET_DPFP_FAST_SET || TARGET_DPFP_COMPACT_SET)
246
247 #define SUBTARGET_SWITCHES
248
249 /* Instruction set characteristics.
250 These are internal macros, set by the appropriate -m option. */
251
252 /* Non-zero means the cpu supports norm instruction. This flag is set by
253 default for A7, and only for pre A7 cores when -mnorm is given. */
254 #define TARGET_NORM (TARGET_ARC700 || TARGET_NORM_SET)
255 /* Indicate if an optimized floating point emulation library is available. */
256 #define TARGET_OPTFPE \
257 (TARGET_ARC700 \
258 /* We need a barrel shifter and NORM. */ \
259 || (TARGET_ARC600 && TARGET_NORM_SET))
260
261 /* Non-zero means the cpu supports swap instruction. This flag is set by
262 default for A7, and only for pre A7 cores when -mswap is given. */
263 #define TARGET_SWAP (TARGET_ARC700 || TARGET_SWAP_SET)
264
265 /* Provide some macros for size / scheduling features of the ARC700, so
266 that we can pick & choose features if we get a new cpu family member. */
267
268 /* Should we try to unalign likely taken branches without a delay slot. */
269 #define TARGET_UNALIGN_BRANCH (TARGET_ARC700 && !optimize_size)
270
271 /* Should we upsize short delayed branches with a short delay insn? */
272 #define TARGET_UPSIZE_DBR (TARGET_ARC700 && !optimize_size)
273
274 /* Should we add padding before a return insn to avoid mispredict? */
275 #define TARGET_PAD_RETURN (TARGET_ARC700 && !optimize_size)
276
277 /* For an anulled-true delay slot insn for a delayed branch, should we only
278 use conditional execution? */
279 #define TARGET_AT_DBR_CONDEXEC (!TARGET_ARC700)
280
281 #define TARGET_A5 (arc_cpu == PROCESSOR_A5)
282 #define TARGET_ARC600 (arc_cpu == PROCESSOR_ARC600)
283 #define TARGET_ARC601 (arc_cpu == PROCESSOR_ARC601)
284 #define TARGET_ARC700 (arc_cpu == PROCESSOR_ARC700)
285
286 /* Recast the cpu class to be the cpu attribute. */
287 #define arc_cpu_attr ((enum attr_cpu)arc_cpu)
288
289 #ifndef MULTILIB_DEFAULTS
290 #define MULTILIB_DEFAULTS { "mARC700" }
291 #endif
292
293 /* Target machine storage layout. */
294
295 /* We want zero_extract to mean the same
296 no matter what the byte endianness is. */
297 #define BITS_BIG_ENDIAN 0
298
299 /* Define this if most significant byte of a word is the lowest numbered. */
300 #define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN)
301
302 /* Define this if most significant word of a multiword number is the lowest
303 numbered. */
304 #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN)
305
306 /* Width in bits of a "word", which is the contents of a machine register.
307 Note that this is not necessarily the width of data type `int';
308 if using 16-bit ints on a 68000, this would still be 32.
309 But on a machine with 16-bit registers, this would be 16. */
310 #define BITS_PER_WORD 32
311
312 /* Width of a word, in units (bytes). */
313 #define UNITS_PER_WORD 4
314
315 /* Define this macro if it is advisable to hold scalars in registers
316 in a wider mode than that declared by the program. In such cases,
317 the value is constrained to be within the bounds of the declared
318 type, but kept valid in the wider mode. The signedness of the
319 extension may differ from that of the type. */
320 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
321 if (GET_MODE_CLASS (MODE) == MODE_INT \
322 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
323 { \
324 (MODE) = SImode; \
325 }
326
327 /* Width in bits of a pointer.
328 See also the macro `Pmode' defined below. */
329 #define POINTER_SIZE 32
330
331 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
332 #define PARM_BOUNDARY 32
333
334 /* Boundary (in *bits*) on which stack pointer should be aligned. */
335 /* TOCHECK: Changed from 64 to 32 */
336 #define STACK_BOUNDARY 32
337
338 /* ALIGN FRAMES on word boundaries. */
339 #define ARC_STACK_ALIGN(LOC) \
340 (((LOC) + STACK_BOUNDARY / BITS_PER_UNIT - 1) & -STACK_BOUNDARY/BITS_PER_UNIT)
341
342 /* Allocation boundary (in *bits*) for the code of a function. */
343 #define FUNCTION_BOUNDARY 32
344
345 /* Alignment of field after `int : 0' in a structure. */
346 #define EMPTY_FIELD_BOUNDARY 32
347
348 /* Every structure's size must be a multiple of this. */
349 #define STRUCTURE_SIZE_BOUNDARY 8
350
351 /* A bitfield declared as `int' forces `int' alignment for the struct. */
352 #define PCC_BITFIELD_TYPE_MATTERS 1
353
354 /* An expression for the alignment of a structure field FIELD if the
355 alignment computed in the usual way (including applying of
356 `BIGGEST_ALIGNMENT' and `BIGGEST_FIELD_ALIGNMENT' to the
357 alignment) is COMPUTED. It overrides alignment only if the field
358 alignment has not been set by the `__attribute__ ((aligned (N)))'
359 construct.
360 */
361
362 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
363 (TYPE_MODE (strip_array_types (TREE_TYPE (FIELD))) == DFmode \
364 ? MIN ((COMPUTED), 32) : (COMPUTED))
365
366
367
368 /* No data type wants to be aligned rounder than this. */
369 /* This is bigger than currently necessary for the ARC. If 8 byte floats are
370 ever added it's not clear whether they'll need such alignment or not. For
371 now we assume they will. We can always relax it if necessary but the
372 reverse isn't true. */
373 /* TOCHECK: Changed from 64 to 32 */
374 #define BIGGEST_ALIGNMENT 32
375
376 /* The best alignment to use in cases where we have a choice. */
377 #define FASTEST_ALIGNMENT 32
378
379 /* Make strings word-aligned so strcpy from constants will be faster. */
380 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
381 ((TREE_CODE (EXP) == STRING_CST \
382 && (ALIGN) < FASTEST_ALIGNMENT) \
383 ? FASTEST_ALIGNMENT : (ALIGN))
384
385
386 /* Make arrays of chars word-aligned for the same reasons. */
387 #define LOCAL_ALIGNMENT(TYPE, ALIGN) \
388 (TREE_CODE (TYPE) == ARRAY_TYPE \
389 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
390 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
391
392 #define DATA_ALIGNMENT(TYPE, ALIGN) \
393 (TREE_CODE (TYPE) == ARRAY_TYPE \
394 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
395 && arc_size_opt_level < 3 \
396 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
397
398 /* Set this nonzero if move instructions will actually fail to work
399 when given unaligned data. */
400 /* On the ARC the lower address bits are masked to 0 as necessary. The chip
401 won't croak when given an unaligned address, but the insn will still fail
402 to produce the correct result. */
403 #define STRICT_ALIGNMENT 1
404
405 /* Layout of source language data types. */
406
407 #define SHORT_TYPE_SIZE 16
408 #define INT_TYPE_SIZE 32
409 #define LONG_TYPE_SIZE 32
410 #define LONG_LONG_TYPE_SIZE 64
411 #define FLOAT_TYPE_SIZE 32
412 #define DOUBLE_TYPE_SIZE 64
413 #define LONG_DOUBLE_TYPE_SIZE 64
414
415 /* Define this as 1 if `char' should by default be signed; else as 0. */
416 #define DEFAULT_SIGNED_CHAR 0
417
418 #define SIZE_TYPE "long unsigned int"
419 #define PTRDIFF_TYPE "long int"
420 #define WCHAR_TYPE "int"
421 #define WCHAR_TYPE_SIZE 32
422
423
424 /* ashwin : shifted from arc.c:102 */
425 #define PROGRAM_COUNTER_REGNO 63
426
427 /* Standard register usage. */
428
429 /* Number of actual hardware registers.
430 The hardware registers are assigned numbers for the compiler
431 from 0 to just below FIRST_PSEUDO_REGISTER.
432 All registers that the compiler knows about must be given numbers,
433 even those that are not normally considered general registers.
434
435 Registers 61, 62, and 63 are not really registers and we needn't treat
436 them as such. We still need a register for the condition code and
437 argument pointer. */
438
439 /* r63 is pc, r64-r127 = simd vregs, r128-r143 = simd dma config regs
440 r144, r145 = lp_start, lp_end
441 and therefore the pseudo registers start from r146. */
442 #define FIRST_PSEUDO_REGISTER 146
443
444 /* 1 for registers that have pervasive standard uses
445 and are not available for the register allocator.
446
447 0-28 - general purpose registers
448 29 - ilink1 (interrupt link register)
449 30 - ilink2 (interrupt link register)
450 31 - blink (branch link register)
451 32-59 - reserved for extensions
452 60 - LP_COUNT
453 61 - condition code
454 62 - argument pointer
455 63 - program counter
456
457 FWIW, this is how the 61-63 encodings are used by the hardware:
458 61 - reserved
459 62 - long immediate data indicator
460 63 - PCL (program counter aligned to 32 bit, read-only)
461
462 The general purpose registers are further broken down into:
463
464 0-7 - arguments/results
465 8-12 - call used (r11 - static chain pointer)
466 13-25 - call saved
467 26 - global pointer
468 27 - frame pointer
469 28 - stack pointer
470 29 - ilink1
471 30 - ilink2
472 31 - return address register
473
474 By default, the extension registers are not available. */
475 /* Present implementations only have VR0-VR23 only. */
476 /* ??? FIXME: r27 and r31 should not be fixed registers. */
477 #define FIXED_REGISTERS \
478 { 0, 0, 0, 0, 0, 0, 0, 0, \
479 0, 0, 0, 0, 0, 0, 0, 0, \
480 0, 0, 0, 0, 0, 0, 0, 0, \
481 0, 0, 1, 1, 1, 1, 1, 1, \
482 \
483 1, 1, 1, 1, 1, 1, 1, 1, \
484 0, 0, 0, 0, 1, 1, 1, 1, \
485 1, 1, 1, 1, 1, 1, 1, 1, \
486 1, 1, 1, 1, 0, 1, 1, 1, \
487 \
488 0, 0, 0, 0, 0, 0, 0, 0, \
489 0, 0, 0, 0, 0, 0, 0, 0, \
490 0, 0, 0, 0, 0, 0, 0, 0, \
491 1, 1, 1, 1, 1, 1, 1, 1, \
492 \
493 1, 1, 1, 1, 1, 1, 1, 1, \
494 1, 1, 1, 1, 1, 1, 1, 1, \
495 1, 1, 1, 1, 1, 1, 1, 1, \
496 1, 1, 1, 1, 1, 1, 1, 1, \
497 \
498 0, 0, 0, 0, 0, 0, 0, 0, \
499 0, 0, 0, 0, 0, 0, 0, 0, \
500 1, 1}
501
502 /* 1 for registers not available across function calls.
503 These must include the FIXED_REGISTERS and also any
504 registers that can be used without being saved.
505 The latter must include the registers where values are returned
506 and the register where structure-value addresses are passed.
507 Aside from that, you can include as many other registers as you like. */
508 #define CALL_USED_REGISTERS \
509 { \
510 1, 1, 1, 1, 1, 1, 1, 1, \
511 1, 1, 1, 1, 1, 0, 0, 0, \
512 0, 0, 0, 0, 0, 0, 0, 0, \
513 0, 0, 1, 1, 1, 1, 1, 1, \
514 \
515 1, 1, 1, 1, 1, 1, 1, 1, \
516 1, 1, 1, 1, 1, 1, 1, 1, \
517 1, 1, 1, 1, 1, 1, 1, 1, \
518 1, 1, 1, 1, 1, 1, 1, 1, \
519 \
520 0, 0, 0, 0, 0, 0, 0, 0, \
521 0, 0, 0, 0, 0, 0, 0, 0, \
522 0, 0, 0, 0, 0, 0, 0, 0, \
523 1, 1, 1, 1, 1, 1, 1, 1, \
524 \
525 1, 1, 1, 1, 1, 1, 1, 1, \
526 1, 1, 1, 1, 1, 1, 1, 1, \
527 1, 1, 1, 1, 1, 1, 1, 1, \
528 1, 1, 1, 1, 1, 1, 1, 1, \
529 \
530 0, 0, 0, 0, 0, 0, 0, 0, \
531 0, 0, 0, 0, 0, 0, 0, 0, \
532 1, 1}
533
534 /* If defined, an initializer for a vector of integers, containing the
535 numbers of hard registers in the order in which GCC should
536 prefer to use them (from most preferred to least). */
537 #define REG_ALLOC_ORDER \
538 { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, \
539 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, \
540 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, \
541 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, \
542 27, 28, 29, 30, 31, 63}
543
544 /* Return number of consecutive hard regs needed starting at reg REGNO
545 to hold something of mode MODE.
546 This is ordinarily the length in words of a value of mode MODE
547 but can be less for certain modes in special long registers. */
548 #define HARD_REGNO_NREGS(REGNO, MODE) \
549 ((GET_MODE_SIZE (MODE) == 16 \
550 && REGNO >= ARC_FIRST_SIMD_VR_REG && REGNO <= ARC_LAST_SIMD_VR_REG) ? 1 \
551 : (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
552
553 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. */
554 extern unsigned int arc_hard_regno_mode_ok[];
555 extern unsigned int arc_mode_class[];
556 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
557 ((arc_hard_regno_mode_ok[REGNO] & arc_mode_class[MODE]) != 0)
558
559 /* A C expression that is nonzero if it is desirable to choose
560 register allocation so as to avoid move instructions between a
561 value of mode MODE1 and a value of mode MODE2.
562
563 If `HARD_REGNO_MODE_OK (R, MODE1)' and `HARD_REGNO_MODE_OK (R,
564 MODE2)' are ever different for any R, then `MODES_TIEABLE_P (MODE1,
565 MODE2)' must be zero. */
566
567 /* Tie QI/HI/SI modes together. */
568 #define MODES_TIEABLE_P(MODE1, MODE2) \
569 (GET_MODE_CLASS (MODE1) == MODE_INT \
570 && GET_MODE_CLASS (MODE2) == MODE_INT \
571 && GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD \
572 && GET_MODE_SIZE (MODE2) <= UNITS_PER_WORD)
573
574 /* Internal macros to classify a register number as to whether it's a
575 general purpose register for compact insns (r0-r3,r12-r15), or
576 stack pointer (r28). */
577
578 #define COMPACT_GP_REG_P(REGNO) \
579 (((signed)(REGNO) >= 0 && (REGNO) <= 3) || ((REGNO) >= 12 && (REGNO) <= 15))
580 #define SP_REG_P(REGNO) ((REGNO) == 28)
581
582
583
584 /* Register classes and constants. */
585
586 /* Define the classes of registers for register constraints in the
587 machine description. Also define ranges of constants.
588
589 One of the classes must always be named ALL_REGS and include all hard regs.
590 If there is more than one class, another class must be named NO_REGS
591 and contain no registers.
592
593 The name GENERAL_REGS must be the name of a class (or an alias for
594 another name such as ALL_REGS). This is the class of registers
595 that is allowed by "g" or "r" in a register constraint.
596 Also, registers outside this class are allocated only when
597 instructions express preferences for them.
598
599 The classes must be numbered in nondecreasing order; that is,
600 a larger-numbered class must never be contained completely
601 in a smaller-numbered class.
602
603 For any two classes, it is very desirable that there be another
604 class that represents their union.
605
606 It is important that any condition codes have class NO_REGS.
607 See `register_operand'. */
608
609 enum reg_class
610 {
611 NO_REGS,
612 R0_REGS, /* 'x' */
613 GP_REG, /* 'Rgp' */
614 FP_REG, /* 'f' */
615 SP_REGS, /* 'b' */
616 LPCOUNT_REG, /* 'l' */
617 LINK_REGS, /* 'k' */
618 DOUBLE_REGS, /* D0, D1 */
619 SIMD_VR_REGS, /* VR00-VR63 */
620 SIMD_DMA_CONFIG_REGS, /* DI0-DI7,DO0-DO7 */
621 ARCOMPACT16_REGS, /* 'q' */
622 AC16_BASE_REGS, /* 'e' */
623 SIBCALL_REGS, /* "Rsc" */
624 GENERAL_REGS, /* 'r' */
625 MPY_WRITABLE_CORE_REGS, /* 'W' */
626 WRITABLE_CORE_REGS, /* 'w' */
627 CHEAP_CORE_REGS, /* 'c' */
628 ALL_CORE_REGS, /* 'Rac' */
629 ALL_REGS,
630 LIM_REG_CLASSES
631 };
632
633 #define N_REG_CLASSES (int) LIM_REG_CLASSES
634
635 /* Give names of register classes as strings for dump file. */
636 #define REG_CLASS_NAMES \
637 { \
638 "NO_REGS", \
639 "R0_REGS", \
640 "GP_REG", \
641 "FP_REG", \
642 "SP_REGS", \
643 "LPCOUNT_REG", \
644 "LINK_REGS", \
645 "DOUBLE_REGS", \
646 "SIMD_VR_REGS", \
647 "SIMD_DMA_CONFIG_REGS", \
648 "ARCOMPACT16_REGS", \
649 "AC16_BASE_REGS", \
650 "SIBCALL_REGS", \
651 "GENERAL_REGS", \
652 "MPY_WRITABLE_CORE_REGS", \
653 "WRITABLE_CORE_REGS", \
654 "CHEAP_CORE_REGS", \
655 "ALL_CORE_REGS", \
656 "ALL_REGS" \
657 }
658
659 /* Define which registers fit in which classes.
660 This is an initializer for a vector of HARD_REG_SET
661 of length N_REG_CLASSES. */
662
663 #define REG_CLASS_CONTENTS \
664 { \
665 {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, /* No Registers */ \
666 {0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, /* 'x', r0 register , r0 */ \
667 {0x04000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, /* 'Rgp', Global Pointer, r26 */ \
668 {0x08000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, /* 'f', Frame Pointer, r27 */ \
669 {0x10000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, /* 'b', Stack Pointer, r28 */ \
670 {0x00000000, 0x10000000, 0x00000000, 0x00000000, 0x00000000}, /* 'l', LPCOUNT Register, r60 */ \
671 {0xe0000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, /* 'k', LINK Registers, r29-r31 */ \
672 {0x00000000, 0x00000f00, 0x00000000, 0x00000000, 0x00000000}, /* 'D', D1, D2 Registers */ \
673 {0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x00000000}, /* 'V', VR00-VR63 Registers */ \
674 {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000ffff}, /* 'V', DI0-7,DO0-7 Registers */ \
675 {0x0000f00f, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, /* 'q', r0-r3, r12-r15 */ \
676 {0x1000f00f, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, /* 'e', r0-r3, r12-r15, sp */ \
677 {0x1c001fff, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, /* "Rsc", r0-r12 */ \
678 {0x9fffffff, 0xc0000000, 0x00000000, 0x00000000, 0x00000000}, /* 'r', r0-r28, blink, ap and pcl */ \
679 {0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, /* 'W', r0-r31 */ \
680 /* Include ap / pcl in WRITABLE_CORE_REGS for sake of symmetry. As these \
681 registers are fixed, it does not affect the literal meaning of the \
682 constraints, but it makes it a superset of GENERAL_REGS, thus \
683 enabling some operations that would otherwise not be possible. */ \
684 {0xffffffff, 0xd0000000, 0x00000000, 0x00000000, 0x00000000}, /* 'w', r0-r31, r60 */ \
685 {0xffffffff, 0xdfffffff, 0x00000000, 0x00000000, 0x00000000}, /* 'c', r0-r60, ap, pcl */ \
686 {0xffffffff, 0xdfffffff, 0x00000000, 0x00000000, 0x00000000}, /* 'Rac', r0-r60, ap, pcl */ \
687 {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0003ffff} /* All Registers */ \
688 }
689
690 /* Local macros to mark the first and last regs of different classes. */
691 #define ARC_FIRST_SIMD_VR_REG 64
692 #define ARC_LAST_SIMD_VR_REG 127
693
694 #define ARC_FIRST_SIMD_DMA_CONFIG_REG 128
695 #define ARC_FIRST_SIMD_DMA_CONFIG_IN_REG 128
696 #define ARC_FIRST_SIMD_DMA_CONFIG_OUT_REG 136
697 #define ARC_LAST_SIMD_DMA_CONFIG_REG 143
698
699 /* The same information, inverted:
700 Return the class number of the smallest class containing
701 reg number REGNO. This could be a conditional expression
702 or could index an array. */
703
704 extern enum reg_class arc_regno_reg_class[];
705
706 #define REGNO_REG_CLASS(REGNO) (arc_regno_reg_class[REGNO])
707
708 /* The class value for valid index registers. An index register is
709 one used in an address where its value is either multiplied by
710 a scale factor or added to another register (as well as added to a
711 displacement). */
712
713 #define INDEX_REG_CLASS (TARGET_MIXED_CODE ? ARCOMPACT16_REGS : GENERAL_REGS)
714
715 /* The class value for valid base registers. A base register is one used in
716 an address which is the register value plus a displacement. */
717
718 #define BASE_REG_CLASS (TARGET_MIXED_CODE ? AC16_BASE_REGS : GENERAL_REGS)
719
720 /* These assume that REGNO is a hard or pseudo reg number.
721 They give nonzero only if REGNO is a hard reg of the suitable class
722 or a pseudo reg currently allocated to a suitable hard reg.
723 Since they use reg_renumber, they are safe only once reg_renumber
724 has been allocated, which happens in local-alloc.c. */
725 #define REGNO_OK_FOR_BASE_P(REGNO) \
726 ((REGNO) < 29 || ((REGNO) == ARG_POINTER_REGNUM) || ((REGNO) == 63) ||\
727 (unsigned) reg_renumber[REGNO] < 29)
728
729 #define REGNO_OK_FOR_INDEX_P(REGNO) REGNO_OK_FOR_BASE_P(REGNO)
730
731 /* Given an rtx X being reloaded into a reg required to be
732 in class CLASS, return the class of reg to actually use.
733 In general this is just CLASS; but on some machines
734 in some cases it is preferable to use a more restrictive class. */
735
736 #define PREFERRED_RELOAD_CLASS(X, CLASS) \
737 arc_preferred_reload_class((X), (CLASS))
738
739 extern enum reg_class arc_preferred_reload_class (rtx, enum reg_class);
740
741 /* Return the maximum number of consecutive registers
742 needed to represent mode MODE in a register of class CLASS. */
743
744 #define CLASS_MAX_NREGS(CLASS, MODE) \
745 (( GET_MODE_SIZE (MODE) == 16 && CLASS == SIMD_VR_REGS) ? 1: \
746 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
747
748 #define SMALL_INT(X) ((unsigned) ((X) + 0x100) < 0x200)
749 #define SMALL_INT_RANGE(X, OFFSET, SHIFT) \
750 ((unsigned) (((X) >> (SHIFT)) + 0x100) \
751 < 0x200 - ((unsigned) (OFFSET) >> (SHIFT)))
752 #define SIGNED_INT12(X) ((unsigned) ((X) + 0x800) < 0x1000)
753 #define LARGE_INT(X) \
754 (((X) < 0) \
755 ? (X) >= (-(HOST_WIDE_INT) 0x7fffffff - 1) \
756 : (unsigned HOST_WIDE_INT) (X) <= (unsigned HOST_WIDE_INT) 0xffffffff)
757 #define UNSIGNED_INT3(X) ((unsigned) (X) < 0x8)
758 #define UNSIGNED_INT5(X) ((unsigned) (X) < 0x20)
759 #define UNSIGNED_INT6(X) ((unsigned) (X) < 0x40)
760 #define UNSIGNED_INT7(X) ((unsigned) (X) < 0x80)
761 #define UNSIGNED_INT8(X) ((unsigned) (X) < 0x100)
762 #define IS_ONE(X) ((X) == 1)
763 #define IS_ZERO(X) ((X) == 0)
764
765 /* Stack layout and stack pointer usage. */
766
767 /* Define this macro if pushing a word onto the stack moves the stack
768 pointer to a smaller address. */
769 #define STACK_GROWS_DOWNWARD
770
771 /* Define this if the nominal address of the stack frame
772 is at the high-address end of the local variables;
773 that is, each additional local variable allocated
774 goes at a more negative offset in the frame. */
775 #define FRAME_GROWS_DOWNWARD 1
776
777 /* Offset within stack frame to start allocating local variables at.
778 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
779 first local allocated. Otherwise, it is the offset to the BEGINNING
780 of the first local allocated. */
781 #define STARTING_FRAME_OFFSET 0
782
783 /* Offset from the stack pointer register to the first location at which
784 outgoing arguments are placed. */
785 #define STACK_POINTER_OFFSET (0)
786
787 /* Offset of first parameter from the argument pointer register value. */
788 #define FIRST_PARM_OFFSET(FNDECL) (0)
789
790 /* A C expression whose value is RTL representing the address in a
791 stack frame where the pointer to the caller's frame is stored.
792 Assume that FRAMEADDR is an RTL expression for the address of the
793 stack frame itself.
794
795 If you don't define this macro, the default is to return the value
796 of FRAMEADDR--that is, the stack frame address is also the address
797 of the stack word that points to the previous frame. */
798 /* ??? unfinished */
799 /*define DYNAMIC_CHAIN_ADDRESS (FRAMEADDR)*/
800
801 /* A C expression whose value is RTL representing the value of the
802 return address for the frame COUNT steps up from the current frame.
803 FRAMEADDR is the frame pointer of the COUNT frame, or the frame
804 pointer of the COUNT - 1 frame if `RETURN_ADDR_IN_PREVIOUS_FRAME'
805 is defined. */
806 /* The current return address is in r31. The return address of anything
807 farther back is at [%fp,4]. */
808
809 #define RETURN_ADDR_RTX(COUNT, FRAME) \
810 arc_return_addr_rtx(COUNT,FRAME)
811
812 /* Register to use for pushing function arguments. */
813 #define STACK_POINTER_REGNUM 28
814
815 /* Base register for access to local variables of the function. */
816 #define FRAME_POINTER_REGNUM 27
817
818 /* Base register for access to arguments of the function. This register
819 will be eliminated into either fp or sp. */
820 #define ARG_POINTER_REGNUM 62
821
822 #define RETURN_ADDR_REGNUM 31
823
824 /* TODO - check usage of STATIC_CHAIN_REGNUM with a testcase */
825 /* Register in which static-chain is passed to a function. This must
826 not be a register used by the prologue. */
827 #define STATIC_CHAIN_REGNUM 11
828
829 /* Function argument passing. */
830
831 /* If defined, the maximum amount of space required for outgoing
832 arguments will be computed and placed into the variable
833 `crtl->outgoing_args_size'. No space will be pushed
834 onto the stack for each call; instead, the function prologue should
835 increase the stack frame size by this amount. */
836 #define ACCUMULATE_OUTGOING_ARGS 1
837
838 /* Define a data type for recording info about an argument list
839 during the scan of that argument list. This data type should
840 hold all necessary information about the function itself
841 and about the args processed so far, enough to enable macros
842 such as FUNCTION_ARG to determine where the next arg should go. */
843 #define CUMULATIVE_ARGS int
844
845 /* Initialize a variable CUM of type CUMULATIVE_ARGS
846 for a call to a function whose data type is FNTYPE.
847 For a library call, FNTYPE is 0. */
848 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT,N_NAMED_ARGS) \
849 ((CUM) = 0)
850
851 /* The number of registers used for parameter passing. Local to this file. */
852 #define MAX_ARC_PARM_REGS 8
853
854 /* 1 if N is a possible register number for function argument passing. */
855 #define FUNCTION_ARG_REGNO_P(N) \
856 ((unsigned) (N) < MAX_ARC_PARM_REGS)
857
858 /* The ROUND_ADVANCE* macros are local to this file. */
859 /* Round SIZE up to a word boundary. */
860 #define ROUND_ADVANCE(SIZE) \
861 (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
862
863 /* Round arg MODE/TYPE up to the next word boundary. */
864 #define ROUND_ADVANCE_ARG(MODE, TYPE) \
865 ((MODE) == BLKmode \
866 ? ROUND_ADVANCE (int_size_in_bytes (TYPE)) \
867 : ROUND_ADVANCE (GET_MODE_SIZE (MODE)))
868
869 #define ARC_FUNCTION_ARG_BOUNDARY(MODE,TYPE) PARM_BOUNDARY
870 /* Round CUM up to the necessary point for argument MODE/TYPE. */
871 /* N.B. Vectors have alignment exceeding BIGGEST_ALIGNMENT.
872 ARC_FUNCTION_ARG_BOUNDARY reduces this to no more than 32 bit. */
873 #define ROUND_ADVANCE_CUM(CUM, MODE, TYPE) \
874 ((((CUM) - 1) | (ARC_FUNCTION_ARG_BOUNDARY ((MODE), (TYPE)) - 1)/BITS_PER_WORD)\
875 + 1)
876
877 /* Return boolean indicating arg of type TYPE and mode MODE will be passed in
878 a reg. This includes arguments that have to be passed by reference as the
879 pointer to them is passed in a reg if one is available (and that is what
880 we're given).
881 When passing arguments NAMED is always 1. When receiving arguments NAMED
882 is 1 for each argument except the last in a stdarg/varargs function. In
883 a stdarg function we want to treat the last named arg as named. In a
884 varargs function we want to treat the last named arg (which is
885 `__builtin_va_alist') as unnamed.
886 This macro is only used in this file. */
887 #define PASS_IN_REG_P(CUM, MODE, TYPE) \
888 ((CUM) < MAX_ARC_PARM_REGS)
889
890
891 /* Function results. */
892
893 /* Define how to find the value returned by a library function
894 assuming the value has mode MODE. */
895 #define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, 0)
896
897 /* 1 if N is a possible register number for a function value
898 as seen by the caller. */
899 /* ??? What about r1 in DI/DF values. */
900 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
901
902 /* Tell GCC to use RETURN_IN_MEMORY. */
903 #define DEFAULT_PCC_STRUCT_RETURN 0
904
905 /* Register in which address to store a structure value
906 is passed to a function, or 0 to use `invisible' first argument. */
907 #define STRUCT_VALUE 0
908
909 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
910 the stack pointer does not matter. The value is tested only in
911 functions that have frame pointers.
912 No definition is equivalent to always zero. */
913 #define EXIT_IGNORE_STACK 0
914
915 #define EPILOGUE_USES(REGNO) arc_epilogue_uses ((REGNO))
916
917 /* Definitions for register eliminations.
918
919 This is an array of structures. Each structure initializes one pair
920 of eliminable registers. The "from" register number is given first,
921 followed by "to". Eliminations of the same "from" register are listed
922 in order of preference.
923
924 We have two registers that can be eliminated on the ARC. First, the
925 argument pointer register can always be eliminated in favor of the stack
926 pointer register or frame pointer register. Secondly, the frame pointer
927 register can often be eliminated in favor of the stack pointer register.
928 */
929
930 #define ELIMINABLE_REGS \
931 {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
932 {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
933 {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
934
935 /* Define the offset between two registers, one to be eliminated, and the other
936 its replacement, at the start of a routine. */
937 extern int arc_initial_elimination_offset(int from, int to);
938 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
939 (OFFSET) = arc_initial_elimination_offset ((FROM), (TO))
940
941 /* Output assembler code to FILE to increment profiler label # LABELNO
942 for profiling a function entry.
943 We actually emit the profiler code at the call site, so leave this one
944 empty. */
945 #define FUNCTION_PROFILER(FILE, LABELNO) \
946 if (TARGET_UCB_MCOUNT) \
947 fprintf (FILE, "\t%s\n", arc_output_libcall ("__mcount"))
948
949 #define NO_PROFILE_COUNTERS 1
950
951 /* Trampolines. */
952
953 /* Length in units of the trampoline for entering a nested function. */
954 #define TRAMPOLINE_SIZE 20
955
956 /* Alignment required for a trampoline in bits . */
957 /* For actual data alignment we just need 32, no more than the stack;
958 however, to reduce cache coherency issues, we want to make sure that
959 trampoline instructions always appear the same in any given cache line. */
960 #define TRAMPOLINE_ALIGNMENT 256
961
962 /* Library calls. */
963
964 /* Addressing modes, and classification of registers for them. */
965
966 /* Maximum number of registers that can appear in a valid memory address. */
967 /* The `ld' insn allows 2, but the `st' insn only allows 1. */
968 #define MAX_REGS_PER_ADDRESS 1
969
970 /* We have pre inc/dec (load/store with update). */
971 #define HAVE_PRE_INCREMENT 1
972 #define HAVE_PRE_DECREMENT 1
973 #define HAVE_POST_INCREMENT 1
974 #define HAVE_POST_DECREMENT 1
975 #define HAVE_PRE_MODIFY_DISP 1
976 #define HAVE_POST_MODIFY_DISP 1
977 #define HAVE_PRE_MODIFY_REG 1
978 #define HAVE_POST_MODIFY_REG 1
979 /* ??? should also do PRE_MODIFY_REG / POST_MODIFY_REG, but that requires
980 a special predicate for the memory operand of stores, like for the SH. */
981
982 /* Recognize any constant value that is a valid address. */
983 #define CONSTANT_ADDRESS_P(X) \
984 (flag_pic?arc_legitimate_pic_addr_p (X): \
985 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
986 || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST))
987
988 /* Is the argument a const_int rtx, containing an exact power of 2 */
989 #define IS_POWEROF2_P(X) (! ( (X) & ((X) - 1)) && (X))
990
991 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
992 and check its validity for a certain class.
993 We have two alternate definitions for each of them.
994 The *_NONSTRICT definition accepts all pseudo regs; the other rejects
995 them unless they have been allocated suitable hard regs.
996
997 Most source files want to accept pseudo regs in the hope that
998 they will get allocated to the class that the insn wants them to be in.
999 Source files for reload pass need to be strict.
1000 After reload, it makes no difference, since pseudo regs have
1001 been eliminated by then. */
1002
1003 /* Nonzero if X is a hard reg that can be used as an index
1004 or if it is a pseudo reg. */
1005 #define REG_OK_FOR_INDEX_P_NONSTRICT(X) \
1006 ((unsigned) REGNO (X) >= FIRST_PSEUDO_REGISTER || \
1007 (unsigned) REGNO (X) < 29 || \
1008 (unsigned) REGNO (X) == 63 || \
1009 (unsigned) REGNO (X) == ARG_POINTER_REGNUM)
1010 /* Nonzero if X is a hard reg that can be used as a base reg
1011 or if it is a pseudo reg. */
1012 #define REG_OK_FOR_BASE_P_NONSTRICT(X) \
1013 ((unsigned) REGNO (X) >= FIRST_PSEUDO_REGISTER || \
1014 (unsigned) REGNO (X) < 29 || \
1015 (unsigned) REGNO (X) == 63 || \
1016 (unsigned) REGNO (X) == ARG_POINTER_REGNUM)
1017
1018 /* Nonzero if X is a hard reg that can be used as an index. */
1019 #define REG_OK_FOR_INDEX_P_STRICT(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
1020 /* Nonzero if X is a hard reg that can be used as a base reg. */
1021 #define REG_OK_FOR_BASE_P_STRICT(X) REGNO_OK_FOR_BASE_P (REGNO (X))
1022
1023 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1024 that is a valid memory address for an instruction.
1025 The MODE argument is the machine mode for the MEM expression
1026 that wants to use this address. */
1027 /* The `ld' insn allows [reg],[reg+shimm],[reg+limm],[reg+reg],[limm]
1028 but the `st' insn only allows [reg],[reg+shimm],[limm].
1029 The only thing we can do is only allow the most strict case `st' and hope
1030 other parts optimize out the restrictions for `ld'. */
1031
1032 #define RTX_OK_FOR_BASE_P(X, STRICT) \
1033 (REG_P (X) \
1034 && ((STRICT) ? REG_OK_FOR_BASE_P_STRICT (X) : REG_OK_FOR_BASE_P_NONSTRICT (X)))
1035
1036 #define RTX_OK_FOR_INDEX_P(X, STRICT) \
1037 (REG_P (X) \
1038 && ((STRICT) ? REG_OK_FOR_INDEX_P_STRICT (X) : REG_OK_FOR_INDEX_P_NONSTRICT (X)))
1039
1040 /* A C compound statement that attempts to replace X, which is an address
1041 that needs reloading, with a valid memory address for an operand of
1042 mode MODE. WIN is a C statement label elsewhere in the code.
1043
1044 We try to get a normal form
1045 of the address. That will allow inheritance of the address reloads. */
1046
1047 #define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN) \
1048 do { \
1049 if (arc_legitimize_reload_address (&(X), (MODE), (OPNUM), (TYPE))) \
1050 goto WIN; \
1051 } while (0)
1052
1053 /* Reading lp_count for anything but the lp instruction is very slow on the
1054 ARC700. */
1055 #define DONT_REALLOC(REGNO,MODE) \
1056 (TARGET_ARC700 && (REGNO) == 60)
1057
1058
1059 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
1060 return the mode to be used for the comparison. */
1061 /*extern enum machine_mode arc_select_cc_mode ();*/
1062 #define SELECT_CC_MODE(OP, X, Y) \
1063 arc_select_cc_mode (OP, X, Y)
1064
1065 /* Return non-zero if SELECT_CC_MODE will never return MODE for a
1066 floating point inequality comparison. */
1067 #define REVERSIBLE_CC_MODE(MODE) 1 /*???*/
1068
1069 /* Costs. */
1070
1071 /* Compute extra cost of moving data between one register class
1072 and another. */
1073 #define REGISTER_MOVE_COST(MODE, CLASS, TO_CLASS) \
1074 arc_register_move_cost ((MODE), (CLASS), (TO_CLASS))
1075
1076 /* Compute the cost of moving data between registers and memory. */
1077 /* Memory is 3 times as expensive as registers.
1078 ??? Is that the right way to look at it? */
1079 #define MEMORY_MOVE_COST(MODE,CLASS,IN) \
1080 (GET_MODE_SIZE (MODE) <= UNITS_PER_WORD ? 6 : 12)
1081
1082 /* The cost of a branch insn. */
1083 /* ??? What's the right value here? Branches are certainly more
1084 expensive than reg->reg moves. */
1085 #define BRANCH_COST(speed_p, predictable_p) 2
1086
1087 /* Scc sets the destination to 1 and then conditionally zeroes it.
1088 Best case, ORed SCCs can be made into clear - condset - condset.
1089 But it could also end up as five insns. So say it costs four on
1090 average.
1091 These extra instructions - and the second comparison - will also be
1092 an extra cost if the first comparison would have been decisive.
1093 So get an average saving, with a probability of the first branch
1094 beging decisive of p0, we want:
1095 p0 * (branch_cost - 4) > (1 - p0) * 5
1096 ??? We don't get to see that probability to evaluate, so we can
1097 only wildly guess that it might be 50%.
1098 ??? The compiler also lacks the notion of branch predictability. */
1099 #define LOGICAL_OP_NON_SHORT_CIRCUIT \
1100 (BRANCH_COST (optimize_function_for_speed_p (cfun), \
1101 false) > 9)
1102
1103 /* Nonzero if access to memory by bytes is slow and undesirable.
1104 For RISC chips, it means that access to memory by bytes is no
1105 better than access by words when possible, so grab a whole word
1106 and maybe make use of that. */
1107 #define SLOW_BYTE_ACCESS 0
1108
1109 /* Define this macro if it is as good or better to call a constant
1110 function address than to call an address kept in a register. */
1111 /* On the ARC, calling through registers is slow. */
1112 #define NO_FUNCTION_CSE
1113
1114 /* Section selection. */
1115 /* WARNING: These section names also appear in dwarfout.c. */
1116
1117 #define TEXT_SECTION_ASM_OP "\t.section\t.text"
1118 #define DATA_SECTION_ASM_OP "\t.section\t.data"
1119
1120 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
1121 #define SDATA_SECTION_ASM_OP "\t.section\t.sdata"
1122 #define SBSS_SECTION_ASM_OP "\t.section\t.sbss"
1123
1124 /* Expression whose value is a string, including spacing, containing the
1125 assembler operation to identify the following data as initialization/termination
1126 code. If not defined, GCC will assume such a section does not exist. */
1127 #define INIT_SECTION_ASM_OP "\t.section\t.init"
1128 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
1129
1130 /* Define this macro if jump tables (for tablejump insns) should be
1131 output in the text section, along with the assembler instructions.
1132 Otherwise, the readonly data section is used.
1133 This macro is irrelevant if there is no separate readonly data section. */
1134 #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic || CASE_VECTOR_PC_RELATIVE)
1135
1136 /* For DWARF. Marginally different than default so output is "prettier"
1137 (and consistent with above). */
1138 #define PUSHSECTION_FORMAT "\t%s %s\n"
1139
1140 /* Tell crtstuff.c we're using ELF. */
1141 #define OBJECT_FORMAT_ELF
1142
1143 /* PIC */
1144
1145 /* The register number of the register used to address a table of static
1146 data addresses in memory. In some cases this register is defined by a
1147 processor's ``application binary interface'' (ABI). When this macro
1148 is defined, RTL is generated for this register once, as with the stack
1149 pointer and frame pointer registers. If this macro is not defined, it
1150 is up to the machine-dependent files to allocate such a register (if
1151 necessary). */
1152 #define PIC_OFFSET_TABLE_REGNUM 26
1153
1154 /* Define this macro if the register defined by PIC_OFFSET_TABLE_REGNUM is
1155 clobbered by calls. Do not define this macro if PIC_OFFSET_TABLE_REGNUM
1156 is not defined. */
1157 /* This register is call-saved on the ARC. */
1158 /*#define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED*/
1159
1160 /* A C expression that is nonzero if X is a legitimate immediate
1161 operand on the target machine when generating position independent code.
1162 You can assume that X satisfies CONSTANT_P, so you need not
1163 check this. You can also assume `flag_pic' is true, so you need not
1164 check it either. You need not define this macro if all constants
1165 (including SYMBOL_REF) can be immediate operands when generating
1166 position independent code. */
1167 #define LEGITIMATE_PIC_OPERAND_P(X) (arc_legitimate_pic_operand_p(X))
1168
1169 /* PIC and small data don't mix on ARC because they use the same register. */
1170 #define SDATA_BASE_REGNUM 26
1171
1172 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
1173 (flag_pic \
1174 ? (GLOBAL ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4 \
1175 : DW_EH_PE_absptr)
1176
1177 /* Control the assembler format that we output. */
1178
1179 /* A C string constant describing how to begin a comment in the target
1180 assembler language. The compiler assumes that the comment will
1181 end at the end of the line. */
1182 /* Gas needs this to be "#" in order to recognize line directives. */
1183 #define ASM_COMMENT_START "#"
1184
1185 /* Output to assembler file text saying following lines
1186 may contain character constants, extra white space, comments, etc. */
1187 #define ASM_APP_ON ""
1188
1189 /* Output to assembler file text saying following lines
1190 no longer contain unusual constructs. */
1191 #define ASM_APP_OFF ""
1192
1193 /* Globalizing directive for a label. */
1194 #define GLOBAL_ASM_OP "\t.global\t"
1195
1196 /* This is how to output an assembler line defining a `char' constant. */
1197 #define ASM_OUTPUT_CHAR(FILE, VALUE) \
1198 ( fprintf (FILE, "\t.byte\t"), \
1199 output_addr_const (FILE, (VALUE)), \
1200 fprintf (FILE, "\n"))
1201
1202 /* This is how to output an assembler line defining a `short' constant. */
1203 #define ASM_OUTPUT_SHORT(FILE, VALUE) \
1204 ( fprintf (FILE, "\t.hword\t"), \
1205 output_addr_const (FILE, (VALUE)), \
1206 fprintf (FILE, "\n"))
1207
1208 /* This is how to output an assembler line defining an `int' constant.
1209 We also handle symbol output here. Code addresses must be right shifted
1210 by 2 because that's how the jump instruction wants them. */
1211 #define ASM_OUTPUT_INT(FILE, VALUE) \
1212 do { \
1213 fprintf (FILE, "\t.word\t"); \
1214 if (GET_CODE (VALUE) == LABEL_REF) \
1215 { \
1216 fprintf (FILE, "%%st(@"); \
1217 output_addr_const (FILE, (VALUE)); \
1218 fprintf (FILE, ")"); \
1219 } \
1220 else \
1221 output_addr_const (FILE, (VALUE)); \
1222 fprintf (FILE, "\n"); \
1223 } while (0)
1224
1225 /* This is how to output an assembler line defining a `float' constant. */
1226 #define ASM_OUTPUT_FLOAT(FILE, VALUE) \
1227 { \
1228 long t; \
1229 char str[30]; \
1230 REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t); \
1231 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", str); \
1232 fprintf (FILE, "\t.word\t0x%lx %s %s\n", \
1233 t, ASM_COMMENT_START, str); \
1234 }
1235
1236 /* This is how to output an assembler line defining a `double' constant. */
1237 #define ASM_OUTPUT_DOUBLE(FILE, VALUE) \
1238 { \
1239 long t[2]; \
1240 char str[30]; \
1241 REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), t); \
1242 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", str); \
1243 fprintf (FILE, "\t.word\t0x%lx %s %s\n\t.word\t0x%lx\n", \
1244 t[0], ASM_COMMENT_START, str, t[1]); \
1245 }
1246
1247 /* This is how to output the definition of a user-level label named NAME,
1248 such as the label on a static function or variable NAME. */
1249 #define ASM_OUTPUT_LABEL(FILE, NAME) \
1250 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
1251
1252 #define ASM_NAME_P(NAME) ( NAME[0]=='*')
1253
1254 /* This is how to output a reference to a user-level label named NAME.
1255 `assemble_name' uses this. */
1256 /* We work around a dwarfout.c deficiency by watching for labels from it and
1257 not adding the '_' prefix. There is a comment in
1258 dwarfout.c that says it should be using ASM_OUTPUT_INTERNAL_LABEL. */
1259 #define ASM_OUTPUT_LABELREF(FILE, NAME1) \
1260 do { \
1261 const char *NAME; \
1262 NAME = (*targetm.strip_name_encoding)(NAME1); \
1263 if ((NAME)[0] == '.' && (NAME)[1] == 'L') \
1264 fprintf (FILE, "%s", NAME); \
1265 else \
1266 { \
1267 if (!ASM_NAME_P (NAME1)) \
1268 fprintf (FILE, "%s", user_label_prefix); \
1269 fprintf (FILE, "%s", NAME); \
1270 } \
1271 } while (0)
1272
1273 /* This is how to output a reference to a symbol_ref / label_ref as
1274 (part of) an operand. To disambiguate from register names like
1275 a1 / a2 / status etc, symbols are preceded by '@'. */
1276 #define ASM_OUTPUT_SYMBOL_REF(FILE,SYM) \
1277 ASM_OUTPUT_LABEL_REF ((FILE), XSTR ((SYM), 0))
1278 #define ASM_OUTPUT_LABEL_REF(FILE,STR) \
1279 do \
1280 { \
1281 fputc ('@', file); \
1282 assemble_name ((FILE), (STR)); \
1283 } \
1284 while (0)
1285
1286 /* Store in OUTPUT a string (made with alloca) containing
1287 an assembler-name for a local static variable named NAME.
1288 LABELNO is an integer which is different for each call. */
1289 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
1290 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
1291 sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
1292
1293 /* The following macro defines the format used to output the second
1294 operand of the .type assembler directive. Different svr4 assemblers
1295 expect various different forms for this operand. The one given here
1296 is just a default. You may need to override it in your machine-
1297 specific tm.h file (depending upon the particulars of your assembler). */
1298
1299 #undef TYPE_OPERAND_FMT
1300 #define TYPE_OPERAND_FMT "@%s"
1301
1302 /* A C string containing the appropriate assembler directive to
1303 specify the size of a symbol, without any arguments. On systems
1304 that use ELF, the default (in `config/elfos.h') is `"\t.size\t"';
1305 on other systems, the default is not to define this macro. */
1306 #undef SIZE_ASM_OP
1307 #define SIZE_ASM_OP "\t.size\t"
1308
1309 /* Assembler pseudo-op to equate one value with another. */
1310 /* ??? This is needed because dwarfout.c provides a default definition too
1311 late for defaults.h (which contains the default definition of ASM_OTPUT_DEF
1312 that we use). */
1313 #ifdef SET_ASM_OP
1314 #undef SET_ASM_OP
1315 #endif
1316 #define SET_ASM_OP "\t.set\t"
1317
1318 extern char rname56[], rname57[], rname58[], rname59[];
1319 /* How to refer to registers in assembler output.
1320 This sequence is indexed by compiler's hard-register-number (see above). */
1321 #define REGISTER_NAMES \
1322 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
1323 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
1324 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
1325 "r24", "r25", "gp", "fp", "sp", "ilink1", "ilink2", "blink", \
1326 "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \
1327 "d1", "d1", "d2", "d2", "r44", "r45", "r46", "r47", \
1328 "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", \
1329 rname56,rname57,rname58,rname59,"lp_count", "cc", "ap", "pcl", \
1330 "vr0", "vr1", "vr2", "vr3", "vr4", "vr5", "vr6", "vr7", \
1331 "vr8", "vr9", "vr10", "vr11", "vr12", "vr13", "vr14", "vr15", \
1332 "vr16", "vr17", "vr18", "vr19", "vr20", "vr21", "vr22", "vr23", \
1333 "vr24", "vr25", "vr26", "vr27", "vr28", "vr29", "vr30", "vr31", \
1334 "vr32", "vr33", "vr34", "vr35", "vr36", "vr37", "vr38", "vr39", \
1335 "vr40", "vr41", "vr42", "vr43", "vr44", "vr45", "vr46", "vr47", \
1336 "vr48", "vr49", "vr50", "vr51", "vr52", "vr53", "vr54", "vr55", \
1337 "vr56", "vr57", "vr58", "vr59", "vr60", "vr61", "vr62", "vr63", \
1338 "dr0", "dr1", "dr2", "dr3", "dr4", "dr5", "dr6", "dr7", \
1339 "dr0", "dr1", "dr2", "dr3", "dr4", "dr5", "dr6", "dr7", \
1340 "lp_start", "lp_end" \
1341 }
1342
1343 /* Entry to the insn conditionalizer. */
1344 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
1345 arc_final_prescan_insn (INSN, OPVEC, NOPERANDS)
1346
1347 /* A C expression which evaluates to true if CODE is a valid
1348 punctuation character for use in the `PRINT_OPERAND' macro. */
1349 extern char arc_punct_chars[];
1350 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
1351 arc_punct_chars[(unsigned char) (CHAR)]
1352
1353 /* Print operand X (an rtx) in assembler syntax to file FILE.
1354 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1355 For `%' followed by punctuation, CODE is the punctuation and X is null. */
1356 #define PRINT_OPERAND(FILE, X, CODE) \
1357 arc_print_operand (FILE, X, CODE)
1358
1359 /* A C compound statement to output to stdio stream STREAM the
1360 assembler syntax for an instruction operand that is a memory
1361 reference whose address is ADDR. ADDR is an RTL expression.
1362
1363 On some machines, the syntax for a symbolic address depends on
1364 the section that the address refers to. On these machines,
1365 define the macro `ENCODE_SECTION_INFO' to store the information
1366 into the `symbol_ref', and then check for it here. */
1367 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
1368 arc_print_operand_address (FILE, ADDR)
1369
1370 /* This is how to output an element of a case-vector that is absolute. */
1371 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
1372 do { \
1373 char label[30]; \
1374 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
1375 fprintf (FILE, "\t.word "); \
1376 assemble_name (FILE, label); \
1377 fprintf(FILE, "\n"); \
1378 } while (0)
1379
1380 /* This is how to output an element of a case-vector that is relative. */
1381 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
1382 do { \
1383 char label[30]; \
1384 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
1385 switch (GET_MODE (BODY)) \
1386 { \
1387 case QImode: fprintf (FILE, "\t.byte "); break; \
1388 case HImode: fprintf (FILE, "\t.hword "); break; \
1389 case SImode: fprintf (FILE, "\t.word "); break; \
1390 default: gcc_unreachable (); \
1391 } \
1392 assemble_name (FILE, label); \
1393 fprintf (FILE, "-"); \
1394 ASM_GENERATE_INTERNAL_LABEL (label, "L", REL); \
1395 assemble_name (FILE, label); \
1396 if (TARGET_COMPACT_CASESI) \
1397 fprintf (FILE, " + %d", 4 + arc_get_unalign ()); \
1398 fprintf(FILE, "\n"); \
1399 } while (0)
1400
1401 /* ADDR_DIFF_VECs are in the text section and thus can affect the
1402 current alignment. */
1403 #define ASM_OUTPUT_CASE_END(FILE, NUM, JUMPTABLE) \
1404 do \
1405 { \
1406 if (GET_CODE (PATTERN (JUMPTABLE)) == ADDR_DIFF_VEC \
1407 && ((GET_MODE_SIZE (GET_MODE (PATTERN (JUMPTABLE))) \
1408 * XVECLEN (PATTERN (JUMPTABLE), 1) + 1) \
1409 & 2)) \
1410 arc_toggle_unalign (); \
1411 } \
1412 while (0)
1413
1414 #define JUMP_ALIGN(LABEL) (arc_size_opt_level < 2 ? 2 : 0)
1415 #define LABEL_ALIGN_AFTER_BARRIER(LABEL) \
1416 (JUMP_ALIGN(LABEL) \
1417 ? JUMP_ALIGN(LABEL) \
1418 : GET_CODE (PATTERN (prev_active_insn (LABEL))) == ADDR_DIFF_VEC \
1419 ? 1 : 0)
1420 /* The desired alignment for the location counter at the beginning
1421 of a loop. */
1422 /* On the ARC, align loops to 4 byte boundaries unless doing all-out size
1423 optimization. */
1424 #define LOOP_ALIGN JUMP_ALIGN
1425
1426 #define LABEL_ALIGN(LABEL) (arc_label_align (LABEL))
1427
1428 /* This is how to output an assembler line
1429 that says to advance the location counter
1430 to a multiple of 2**LOG bytes. */
1431 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
1432 do { \
1433 if ((LOG) != 0) fprintf (FILE, "\t.align %d\n", 1 << (LOG)); \
1434 if ((LOG) > 1) \
1435 arc_clear_unalign (); \
1436 } while (0)
1437
1438 /* ASM_OUTPUT_ALIGNED_DECL_LOCAL (STREAM, DECL, NAME, SIZE, ALIGNMENT)
1439 Define this macro when you need to see the variable's decl in order to
1440 chose what to output. */
1441 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
1442 arc_asm_output_aligned_decl_local (STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
1443
1444 /* To translate the return value of arc_function_type into a register number
1445 to jump through for function return. */
1446 extern int arc_return_address_regs[4];
1447
1448 /* Debugging information. */
1449
1450 /* Generate DBX and DWARF debugging information. */
1451 #ifdef DBX_DEBUGGING_INFO
1452 #undef DBX_DEBUGGING_INFO
1453 #endif
1454 #define DBX_DEBUGGING_INFO
1455
1456 #ifdef DWARF2_DEBUGGING_INFO
1457 #undef DWARF2_DEBUGGING_INFO
1458 #endif
1459 #define DWARF2_DEBUGGING_INFO
1460
1461 /* Prefer STABS (for now). */
1462 #undef PREFERRED_DEBUGGING_TYPE
1463 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
1464
1465 /* How to renumber registers for dbx and gdb. */
1466 #define DBX_REGISTER_NUMBER(REGNO) \
1467 ((TARGET_MULMAC_32BY16_SET && (REGNO) >= 56 && (REGNO) <= 57) \
1468 ? ((REGNO) ^ !TARGET_BIG_ENDIAN) \
1469 : (TARGET_MUL64_SET && (REGNO) >= 57 && (REGNO) <= 59) \
1470 ? ((REGNO) == 57 \
1471 ? 58 /* MMED */ \
1472 : ((REGNO) & 1) ^ TARGET_BIG_ENDIAN \
1473 ? 59 /* MHI */ \
1474 : 57 + !!TARGET_MULMAC_32BY16_SET) /* MLO */ \
1475 : (REGNO))
1476
1477 #define DWARF_FRAME_REGNUM(REG) (REG)
1478
1479 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (31)
1480
1481 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, 31)
1482
1483 /* Frame info. */
1484
1485 /* Define this macro to 0 if your target supports DWARF 2 frame unwind
1486 information, but it does not yet work with exception handling. */
1487 /* N.B. the below test is valid in an #if, but not in a C expression. */
1488 #if DEFAULT_LIBC == LIBC_UCLIBC
1489 #define DWARF2_UNWIND_INFO 1
1490 #else
1491 #define DWARF2_UNWIND_INFO 0
1492 #endif
1493
1494 #define EH_RETURN_DATA_REGNO(N) \
1495 ((N) < 4 ? (N) : INVALID_REGNUM)
1496
1497 /* Turn off splitting of long stabs. */
1498 #define DBX_CONTIN_LENGTH 0
1499
1500 /* Miscellaneous. */
1501
1502 /* Specify the machine mode that this machine uses
1503 for the index in the tablejump instruction.
1504 If we have pc relative case vectors, we start the case vector shortening
1505 with QImode. */
1506 #define CASE_VECTOR_MODE \
1507 ((optimize && (CASE_VECTOR_PC_RELATIVE || flag_pic)) ? QImode : Pmode)
1508
1509 /* Define as C expression which evaluates to nonzero if the tablejump
1510 instruction expects the table to contain offsets from the address of the
1511 table.
1512 Do not define this if the table should contain absolute addresses. */
1513 #define CASE_VECTOR_PC_RELATIVE TARGET_CASE_VECTOR_PC_RELATIVE
1514
1515 #define CASE_VECTOR_SHORTEN_MODE(MIN_OFFSET, MAX_OFFSET, BODY) \
1516 CASE_VECTOR_SHORTEN_MODE_1 \
1517 (MIN_OFFSET, TARGET_COMPACT_CASESI ? MAX_OFFSET + 6 : MAX_OFFSET, BODY)
1518
1519 #define CASE_VECTOR_SHORTEN_MODE_1(MIN_OFFSET, MAX_OFFSET, BODY) \
1520 ((MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 255 \
1521 ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 1, QImode) \
1522 : (MIN_OFFSET) >= -128 && (MAX_OFFSET) <= 127 \
1523 ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 0, QImode) \
1524 : (MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 65535 \
1525 ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 1, HImode) \
1526 : (MIN_OFFSET) >= -32768 && (MAX_OFFSET) <= 32767 \
1527 ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 0, HImode) \
1528 : SImode)
1529
1530 #define ADDR_VEC_ALIGN(VEC_INSN) \
1531 (exact_log2 (GET_MODE_SIZE (GET_MODE (PATTERN (VEC_INSN)))))
1532 #undef ASM_OUTPUT_BEFORE_CASE_LABEL
1533 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
1534 ASM_OUTPUT_ALIGN ((FILE), ADDR_VEC_ALIGN (TABLE));
1535
1536 #define INSN_LENGTH_ALIGNMENT(INSN) \
1537 ((JUMP_P (INSN) \
1538 && GET_CODE (PATTERN (INSN)) == ADDR_DIFF_VEC \
1539 && GET_MODE (PATTERN (INSN)) == QImode) \
1540 ? 0 : length_unit_log)
1541
1542 /* Define if operations between registers always perform the operation
1543 on the full register even if a narrower mode is specified. */
1544 #define WORD_REGISTER_OPERATIONS
1545
1546 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
1547 will either zero-extend or sign-extend. The value of this macro should
1548 be the code that says which one of the two operations is implicitly
1549 done, NIL if none. */
1550 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
1551
1552
1553 /* Max number of bytes we can move from memory to memory
1554 in one reasonably fast instruction. */
1555 #define MOVE_MAX 4
1556
1557 /* Let the movmem expander handle small block moves. */
1558 #define MOVE_BY_PIECES_P(LEN, ALIGN) 0
1559 #define CAN_MOVE_BY_PIECES(SIZE, ALIGN) \
1560 (move_by_pieces_ninsns (SIZE, ALIGN, MOVE_MAX_PIECES + 1) \
1561 < (unsigned int) MOVE_RATIO (!optimize_size))
1562
1563 /* Undo the effects of the movmem pattern presence on STORE_BY_PIECES_P . */
1564 #define MOVE_RATIO(SPEED) ((SPEED) ? 15 : 3)
1565
1566 /* Define this to be nonzero if shift instructions ignore all but the low-order
1567 few bits. Changed from 1 to 0 for rotate pattern testcases
1568 (e.g. 20020226-1.c). This change truncates the upper 27 bits of a word
1569 while rotating a word. Came to notice through a combine phase
1570 optimization viz. a << (32-b) is equivalent to a << (-b).
1571 */
1572 #define SHIFT_COUNT_TRUNCATED 0
1573
1574 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1575 is done just by pretending it is already truncated. */
1576 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1577
1578 /* We assume that the store-condition-codes instructions store 0 for false
1579 and some other value for true. This is the value stored for true. */
1580 #define STORE_FLAG_VALUE 1
1581
1582 /* Specify the machine mode that pointers have.
1583 After generation of rtl, the compiler makes no further distinction
1584 between pointers and any other objects of this machine mode. */
1585 /* ARCompact has full 32-bit pointers. */
1586 #define Pmode SImode
1587
1588 /* A function address in a call instruction. */
1589 #define FUNCTION_MODE SImode
1590
1591 /* Define the information needed to generate branch and scc insns. This is
1592 stored from the compare operation. Note that we can't use "rtx" here
1593 since it hasn't been defined! */
1594 extern struct rtx_def *arc_compare_op0, *arc_compare_op1;
1595
1596 /* ARC function types. */
1597 enum arc_function_type {
1598 ARC_FUNCTION_UNKNOWN, ARC_FUNCTION_NORMAL,
1599 /* These are interrupt handlers. The name corresponds to the register
1600 name that contains the return address. */
1601 ARC_FUNCTION_ILINK1, ARC_FUNCTION_ILINK2
1602 };
1603 #define ARC_INTERRUPT_P(TYPE) \
1604 ((TYPE) == ARC_FUNCTION_ILINK1 || (TYPE) == ARC_FUNCTION_ILINK2)
1605
1606 /* Compute the type of a function from its DECL. Needed for EPILOGUE_USES. */
1607 struct function;
1608 extern enum arc_function_type arc_compute_function_type (struct function *);
1609
1610 /* Called by crtstuff.c to make calls to function FUNCTION that are defined in
1611 SECTION_OP, and then to switch back to text section. */
1612 #undef CRT_CALL_STATIC_FUNCTION
1613 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
1614 asm (SECTION_OP "\n\t" \
1615 "bl @" USER_LABEL_PREFIX #FUNC "\n" \
1616 TEXT_SECTION_ASM_OP);
1617
1618 /* This macro expands to the name of the scratch register r12, used for
1619 temporary calculations according to the ABI. */
1620 #define ARC_TEMP_SCRATCH_REG "r12"
1621
1622 /* The C++ compiler must use one bit to indicate whether the function
1623 that will be called through a pointer-to-member-function is
1624 virtual. Normally, we assume that the low-order bit of a function
1625 pointer must always be zero. Then, by ensuring that the
1626 vtable_index is odd, we can distinguish which variant of the union
1627 is in use. But, on some platforms function pointers can be odd,
1628 and so this doesn't work. In that case, we use the low-order bit
1629 of the `delta' field, and shift the remainder of the `delta' field
1630 to the left. We needed to do this for A4 because the address was always
1631 shifted and thus could be odd. */
1632 #define TARGET_PTRMEMFUNC_VBIT_LOCATION \
1633 (ptrmemfunc_vbit_in_pfn)
1634
1635 #define INSN_SETS_ARE_DELAYED(X) \
1636 (GET_CODE (X) == INSN \
1637 && GET_CODE (PATTERN (X)) != SEQUENCE \
1638 && GET_CODE (PATTERN (X)) != USE \
1639 && GET_CODE (PATTERN (X)) != CLOBBER \
1640 && (get_attr_type (X) == TYPE_CALL || get_attr_type (X) == TYPE_SFUNC))
1641
1642 #define INSN_REFERENCES_ARE_DELAYED(insn) INSN_SETS_ARE_DELAYED (insn)
1643
1644 #define CALL_ATTR(X, NAME) \
1645 ((CALL_P (X) || NONJUMP_INSN_P (X)) \
1646 && GET_CODE (PATTERN (X)) != USE \
1647 && GET_CODE (PATTERN (X)) != CLOBBER \
1648 && get_attr_is_##NAME (X) == IS_##NAME##_YES) \
1649
1650 #define REVERSE_CONDITION(CODE,MODE) \
1651 (((MODE) == CC_FP_GTmode || (MODE) == CC_FP_GEmode \
1652 || (MODE) == CC_FP_UNEQmode || (MODE) == CC_FP_ORDmode \
1653 || (MODE) == CC_FPXmode) \
1654 ? reverse_condition_maybe_unordered ((CODE)) \
1655 : reverse_condition ((CODE)))
1656
1657 #define ADJUST_INSN_LENGTH(X, LENGTH) \
1658 ((LENGTH) \
1659 = (GET_CODE (PATTERN (X)) == SEQUENCE \
1660 ? ((LENGTH) \
1661 + arc_adjust_insn_length (XVECEXP (PATTERN (X), 0, 0), \
1662 get_attr_length (XVECEXP (PATTERN (X), \
1663 0, 0)), \
1664 true) \
1665 - get_attr_length (XVECEXP (PATTERN (X), 0, 0)) \
1666 + arc_adjust_insn_length (XVECEXP (PATTERN (X), 0, 1), \
1667 get_attr_length (XVECEXP (PATTERN (X), \
1668 0, 1)), \
1669 true) \
1670 - get_attr_length (XVECEXP (PATTERN (X), 0, 1))) \
1671 : arc_adjust_insn_length ((X), (LENGTH), false)))
1672
1673 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C,STR) ((C) == '`')
1674
1675 #define INIT_EXPANDERS arc_init_expanders ()
1676
1677 #define CFA_FRAME_BASE_OFFSET(FUNDECL) (-arc_decl_pretend_args ((FUNDECL)))
1678
1679 #define ARG_POINTER_CFA_OFFSET(FNDECL) \
1680 (FIRST_PARM_OFFSET (FNDECL) + arc_decl_pretend_args ((FNDECL)))
1681
1682 enum
1683 {
1684 ARC_LRA_PRIORITY_NONE, ARC_LRA_PRIORITY_NONCOMPACT, ARC_LRA_PRIORITY_COMPACT
1685 };
1686
1687 /* The define_cond_exec construct is rather crude, as we can't have
1688 different ones with different conditions apply to different sets
1689 of instructions. We can't use an attribute test inside the condition,
1690 because that would lead to infinite recursion as the attribute test
1691 needs to recognize the insn. So, instead we have a clause for
1692 the pattern condition of all sfunc patterns which is only relevant for
1693 the predicated varaint. */
1694 #define SFUNC_CHECK_PREDICABLE \
1695 (GET_CODE (PATTERN (insn)) != COND_EXEC || !flag_pic || !TARGET_MEDIUM_CALLS)
1696
1697 #endif /* GCC_ARC_H */