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