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