comparison gcc/config/xtensa/xtensa.h @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* Definitions of Tensilica's Xtensa target machine for GNU compiler. 1 /* Definitions of Tensilica's Xtensa target machine for GNU compiler.
2 Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 2 Copyright (C) 2001-2017 Free Software Foundation, Inc.
3 Free Software Foundation, Inc.
4 Contributed by Bob Wilson (bwilson@tensilica.com) at Tensilica. 3 Contributed by Bob Wilson (bwilson@tensilica.com) at Tensilica.
5 4
6 This file is part of GCC. 5 This file is part of GCC.
7 6
8 GCC is free software; you can redistribute it and/or modify it under 7 GCC is free software; you can redistribute it and/or modify it under
21 20
22 /* Get Xtensa configuration settings */ 21 /* Get Xtensa configuration settings */
23 #include "xtensa-config.h" 22 #include "xtensa-config.h"
24 23
25 /* External variables defined in xtensa.c. */ 24 /* External variables defined in xtensa.c. */
26
27 extern unsigned xtensa_current_frame_size;
28 25
29 /* Macros used in the machine description to select various Xtensa 26 /* Macros used in the machine description to select various Xtensa
30 configuration options. */ 27 configuration options. */
31 #ifndef XCHAL_HAVE_MUL32_HIGH 28 #ifndef XCHAL_HAVE_MUL32_HIGH
32 #define XCHAL_HAVE_MUL32_HIGH 0 29 #define XCHAL_HAVE_MUL32_HIGH 0
37 #ifndef XCHAL_HAVE_S32C1I 34 #ifndef XCHAL_HAVE_S32C1I
38 #define XCHAL_HAVE_S32C1I 0 35 #define XCHAL_HAVE_S32C1I 0
39 #endif 36 #endif
40 #ifndef XCHAL_HAVE_THREADPTR 37 #ifndef XCHAL_HAVE_THREADPTR
41 #define XCHAL_HAVE_THREADPTR 0 38 #define XCHAL_HAVE_THREADPTR 0
39 #endif
40 #ifndef XCHAL_HAVE_FP_POSTINC
41 #define XCHAL_HAVE_FP_POSTINC 0
42 #endif 42 #endif
43 #define TARGET_BIG_ENDIAN XCHAL_HAVE_BE 43 #define TARGET_BIG_ENDIAN XCHAL_HAVE_BE
44 #define TARGET_DENSITY XCHAL_HAVE_DENSITY 44 #define TARGET_DENSITY XCHAL_HAVE_DENSITY
45 #define TARGET_MAC16 XCHAL_HAVE_MAC16 45 #define TARGET_MAC16 XCHAL_HAVE_MAC16
46 #define TARGET_MUL16 XCHAL_HAVE_MUL16 46 #define TARGET_MUL16 XCHAL_HAVE_MUL16
54 #define TARGET_HARD_FLOAT XCHAL_HAVE_FP 54 #define TARGET_HARD_FLOAT XCHAL_HAVE_FP
55 #define TARGET_HARD_FLOAT_DIV XCHAL_HAVE_FP_DIV 55 #define TARGET_HARD_FLOAT_DIV XCHAL_HAVE_FP_DIV
56 #define TARGET_HARD_FLOAT_RECIP XCHAL_HAVE_FP_RECIP 56 #define TARGET_HARD_FLOAT_RECIP XCHAL_HAVE_FP_RECIP
57 #define TARGET_HARD_FLOAT_SQRT XCHAL_HAVE_FP_SQRT 57 #define TARGET_HARD_FLOAT_SQRT XCHAL_HAVE_FP_SQRT
58 #define TARGET_HARD_FLOAT_RSQRT XCHAL_HAVE_FP_RSQRT 58 #define TARGET_HARD_FLOAT_RSQRT XCHAL_HAVE_FP_RSQRT
59 #define TARGET_HARD_FLOAT_POSTINC XCHAL_HAVE_FP_POSTINC
59 #define TARGET_ABS XCHAL_HAVE_ABS 60 #define TARGET_ABS XCHAL_HAVE_ABS
60 #define TARGET_ADDX XCHAL_HAVE_ADDX 61 #define TARGET_ADDX XCHAL_HAVE_ADDX
61 #define TARGET_RELEASE_SYNC XCHAL_HAVE_RELEASE_SYNC 62 #define TARGET_RELEASE_SYNC XCHAL_HAVE_RELEASE_SYNC
62 #define TARGET_S32C1I XCHAL_HAVE_S32C1I 63 #define TARGET_S32C1I XCHAL_HAVE_S32C1I
63 #define TARGET_ABSOLUTE_LITERALS XSHAL_USE_ABSOLUTE_LITERALS 64 #define TARGET_ABSOLUTE_LITERALS XSHAL_USE_ABSOLUTE_LITERALS
64 #define TARGET_THREADPTR XCHAL_HAVE_THREADPTR 65 #define TARGET_THREADPTR XCHAL_HAVE_THREADPTR
65 66 #define TARGET_LOOPS XCHAL_HAVE_LOOPS
66 #define TARGET_DEFAULT \ 67 #define TARGET_WINDOWED_ABI (XSHAL_ABI == XTHAL_ABI_WINDOWED)
67 ((XCHAL_HAVE_L32R ? 0 : MASK_CONST16) | \ 68 #define TARGET_DEBUG XCHAL_HAVE_DEBUG
68 MASK_SERIALIZE_VOLATILE) 69 #define TARGET_L32R XCHAL_HAVE_L32R
70
71 #define TARGET_DEFAULT (MASK_SERIALIZE_VOLATILE)
69 72
70 #ifndef HAVE_AS_TLS 73 #ifndef HAVE_AS_TLS
71 #define HAVE_AS_TLS 0 74 #define HAVE_AS_TLS 0
72 #endif 75 #endif
73 76
77 do { \ 80 do { \
78 builtin_assert ("cpu=xtensa"); \ 81 builtin_assert ("cpu=xtensa"); \
79 builtin_assert ("machine=xtensa"); \ 82 builtin_assert ("machine=xtensa"); \
80 builtin_define ("__xtensa__"); \ 83 builtin_define ("__xtensa__"); \
81 builtin_define ("__XTENSA__"); \ 84 builtin_define ("__XTENSA__"); \
82 builtin_define ("__XTENSA_WINDOWED_ABI__"); \ 85 builtin_define (TARGET_WINDOWED_ABI ? \
86 "__XTENSA_WINDOWED_ABI__" : "__XTENSA_CALL0_ABI__");\
83 builtin_define (TARGET_BIG_ENDIAN ? "__XTENSA_EB__" : "__XTENSA_EL__"); \ 87 builtin_define (TARGET_BIG_ENDIAN ? "__XTENSA_EB__" : "__XTENSA_EL__"); \
84 if (!TARGET_HARD_FLOAT) \ 88 if (!TARGET_HARD_FLOAT) \
85 builtin_define ("__XTENSA_SOFT_FLOAT__"); \ 89 builtin_define ("__XTENSA_SOFT_FLOAT__"); \
86 } while (0) 90 } while (0)
87 91
163 167
164 /* Imitate the way many other C compilers handle alignment of 168 /* Imitate the way many other C compilers handle alignment of
165 bitfields and the structures that contain them. */ 169 bitfields and the structures that contain them. */
166 #define PCC_BITFIELD_TYPE_MATTERS 1 170 #define PCC_BITFIELD_TYPE_MATTERS 1
167 171
168 /* Disable the use of word-sized or smaller complex modes for structures,
169 and for function arguments in particular, where they cause problems with
170 register a7. The xtensa_copy_incoming_a7 function assumes that there is
171 a single reference to an argument in a7, but with small complex modes the
172 real and imaginary components may be extracted separately, leading to two
173 uses of the register, only one of which would be replaced. */
174 #define MEMBER_TYPE_FORCES_BLK(FIELD, MODE) \
175 ((MODE) == CQImode || (MODE) == CHImode)
176
177 /* Align string constants and constructors to at least a word boundary.
178 The typical use of this macro is to increase alignment for string
179 constants to be word aligned so that 'strcpy' calls that copy
180 constants can be done inline. */
181 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
182 ((TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR) \
183 && (ALIGN) < BITS_PER_WORD \
184 ? BITS_PER_WORD \
185 : (ALIGN))
186
187 /* Align arrays, unions and records to at least a word boundary. 172 /* Align arrays, unions and records to at least a word boundary.
188 One use of this macro is to increase alignment of medium-size 173 One use of this macro is to increase alignment of medium-size
189 data to make it all fit in fewer cache lines. Another is to 174 data to make it all fit in fewer cache lines. Another is to
190 cause character arrays to be word-aligned so that 'strcpy' calls 175 cause character arrays to be word-aligned so that 'strcpy' calls
191 that copy constants to character arrays can be done inline. */ 176 that copy constants to character arrays can be done inline. */
192 #undef DATA_ALIGNMENT 177 #undef DATA_ALIGNMENT
193 #define DATA_ALIGNMENT(TYPE, ALIGN) \ 178 #define DATA_ALIGNMENT(TYPE, ALIGN) \
194 ((((ALIGN) < BITS_PER_WORD) \ 179 (!optimize_size && (((ALIGN) < BITS_PER_WORD) \
195 && (TREE_CODE (TYPE) == ARRAY_TYPE \ 180 && (TREE_CODE (TYPE) == ARRAY_TYPE \
196 || TREE_CODE (TYPE) == UNION_TYPE \ 181 || TREE_CODE (TYPE) == UNION_TYPE \
197 || TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN)) 182 || TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
198 183
199 /* Operations between registers always perform the operation 184 /* Operations between registers always perform the operation
200 on the full register even if a narrower mode is specified. */ 185 on the full register even if a narrower mode is specified. */
201 #define WORD_REGISTER_OPERATIONS 186 #define WORD_REGISTER_OPERATIONS 1
202 187
203 /* Xtensa loads are zero-extended by default. */ 188 /* Xtensa loads are zero-extended by default. */
204 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND 189 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
205 190
206 /* Standard register usage. */ 191 /* Standard register usage. */
240 /* 1 for registers not available across function calls. 225 /* 1 for registers not available across function calls.
241 These must include the FIXED_REGISTERS and also any 226 These must include the FIXED_REGISTERS and also any
242 registers that can be used without being saved. 227 registers that can be used without being saved.
243 The latter must include the registers where values are returned 228 The latter must include the registers where values are returned
244 and the register where structure-value addresses are passed. 229 and the register where structure-value addresses are passed.
245 Aside from that, you can include as many other registers as you like. */ 230 Aside from that, you can include as many other registers as you like.
231
232 The value encoding is the following:
233 1: register is used by all ABIs;
234 bit 1 is set: register is used by windowed ABI;
235 bit 2 is set: register is used by call0 ABI.
236
237 Proper values are computed in TARGET_CONDITIONAL_REGISTER_USAGE. */
238
246 #define CALL_USED_REGISTERS \ 239 #define CALL_USED_REGISTERS \
247 { \ 240 { \
248 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, \ 241 1, 1, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 2, 2, 2, 2, \
249 1, 1, 1, \ 242 1, 1, 1, \
250 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ 243 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
251 1, \ 244 1, \
252 } 245 }
253 246
315 #define GP_REG_P(REGNO) ((unsigned) ((REGNO) - GP_REG_FIRST) < GP_REG_NUM) 308 #define GP_REG_P(REGNO) ((unsigned) ((REGNO) - GP_REG_FIRST) < GP_REG_NUM)
316 #define BR_REG_P(REGNO) ((unsigned) ((REGNO) - BR_REG_FIRST) < BR_REG_NUM) 309 #define BR_REG_P(REGNO) ((unsigned) ((REGNO) - BR_REG_FIRST) < BR_REG_NUM)
317 #define FP_REG_P(REGNO) ((unsigned) ((REGNO) - FP_REG_FIRST) < FP_REG_NUM) 310 #define FP_REG_P(REGNO) ((unsigned) ((REGNO) - FP_REG_FIRST) < FP_REG_NUM)
318 #define ACC_REG_P(REGNO) ((unsigned) ((REGNO) - ACC_REG_FIRST) < ACC_REG_NUM) 311 #define ACC_REG_P(REGNO) ((unsigned) ((REGNO) - ACC_REG_FIRST) < ACC_REG_NUM)
319 312
320 /* Return number of consecutive hard regs needed starting at reg REGNO
321 to hold something of mode MODE. */
322 #define HARD_REGNO_NREGS(REGNO, MODE) \
323 (FP_REG_P (REGNO) ? \
324 ((GET_MODE_SIZE (MODE) + UNITS_PER_FPREG - 1) / UNITS_PER_FPREG) : \
325 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
326
327 /* Value is 1 if hard register REGNO can hold a value of machine-mode
328 MODE. */
329 extern char xtensa_hard_regno_mode_ok[][FIRST_PSEUDO_REGISTER];
330
331 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
332 xtensa_hard_regno_mode_ok[(int) (MODE)][(REGNO)]
333
334 /* Value is 1 if it is a good idea to tie two pseudo registers
335 when one has mode MODE1 and one has mode MODE2.
336 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
337 for any hard reg, then this must be 0 for correct output. */
338 #define MODES_TIEABLE_P(MODE1, MODE2) \
339 ((GET_MODE_CLASS (MODE1) == MODE_FLOAT || \
340 GET_MODE_CLASS (MODE1) == MODE_COMPLEX_FLOAT) \
341 == (GET_MODE_CLASS (MODE2) == MODE_FLOAT || \
342 GET_MODE_CLASS (MODE2) == MODE_COMPLEX_FLOAT))
343
344 /* Register to use for pushing function arguments. */ 313 /* Register to use for pushing function arguments. */
345 #define STACK_POINTER_REGNUM (GP_REG_FIRST + 1) 314 #define STACK_POINTER_REGNUM (GP_REG_FIRST + 1)
346 315
347 /* Base register for access to local variables of the function. */ 316 /* Base register for access to local variables of the function. */
348 #define HARD_FRAME_POINTER_REGNUM (GP_REG_FIRST + 7) 317 #define HARD_FRAME_POINTER_REGNUM (GP_REG_FIRST + \
318 (TARGET_WINDOWED_ABI ? 7 : 15))
349 319
350 /* The register number of the frame pointer register, which is used to 320 /* The register number of the frame pointer register, which is used to
351 access automatic variables in the stack frame. For Xtensa, this 321 access automatic variables in the stack frame. For Xtensa, this
352 register never appears in the output. It is always eliminated to 322 register never appears in the output. It is always eliminated to
353 either the stack pointer or the hard frame pointer. */ 323 either the stack pointer or the hard frame pointer. */
354 #define FRAME_POINTER_REGNUM (GP_REG_FIRST + 16) 324 #define FRAME_POINTER_REGNUM (GP_REG_FIRST + 16)
355 325
356 /* Base register for access to arguments of the function. */ 326 /* Base register for access to arguments of the function. */
357 #define ARG_POINTER_REGNUM (GP_REG_FIRST + 17) 327 #define ARG_POINTER_REGNUM (GP_REG_FIRST + 17)
358 328
329 /* Hard frame pointer is neither frame nor arg pointer.
330 The definitions are here because actual hard frame pointer register
331 definition is not a preprocessor constant. */
332 #define HARD_FRAME_POINTER_IS_FRAME_POINTER 0
333 #define HARD_FRAME_POINTER_IS_ARG_POINTER 0
334
359 /* For now we don't try to use the full set of boolean registers. Without 335 /* For now we don't try to use the full set of boolean registers. Without
360 software pipelining of FP operations, there's not much to gain and it's 336 software pipelining of FP operations, there's not much to gain and it's
361 a real pain to get them reloaded. */ 337 a real pain to get them reloaded. */
362 #define FPCC_REGNUM (BR_REG_FIRST + 0) 338 #define FPCC_REGNUM (BR_REG_FIRST + 0)
363 339
368 /* Xtensa processors have "register windows". GCC does not currently 344 /* Xtensa processors have "register windows". GCC does not currently
369 take advantage of the possibility for variable-sized windows; instead, 345 take advantage of the possibility for variable-sized windows; instead,
370 we use a fixed window size of 8. */ 346 we use a fixed window size of 8. */
371 347
372 #define INCOMING_REGNO(OUT) \ 348 #define INCOMING_REGNO(OUT) \
373 ((GP_REG_P (OUT) && \ 349 (TARGET_WINDOWED_ABI ? \
374 ((unsigned) ((OUT) - GP_REG_FIRST) >= WINDOW_SIZE)) ? \ 350 ((GP_REG_P (OUT) && \
375 (OUT) - WINDOW_SIZE : (OUT)) 351 ((unsigned) ((OUT) - GP_REG_FIRST) >= WINDOW_SIZE)) ? \
352 (OUT) - WINDOW_SIZE : (OUT)) : (OUT))
376 353
377 #define OUTGOING_REGNO(IN) \ 354 #define OUTGOING_REGNO(IN) \
378 ((GP_REG_P (IN) && \ 355 (TARGET_WINDOWED_ABI ? \
379 ((unsigned) ((IN) - GP_REG_FIRST) < WINDOW_SIZE)) ? \ 356 ((GP_REG_P (IN) && \
380 (IN) + WINDOW_SIZE : (IN)) 357 ((unsigned) ((IN) - GP_REG_FIRST) < WINDOW_SIZE)) ? \
358 (IN) + WINDOW_SIZE : (IN)) : (IN))
381 359
382 360
383 /* Define the classes of registers for register constraints in the 361 /* Define the classes of registers for register constraints in the
384 machine description. */ 362 machine description. */
385 enum reg_class 363 enum reg_class
424 { 0x00000000, 0x00000000 }, /* no registers */ \ 402 { 0x00000000, 0x00000000 }, /* no registers */ \
425 { 0x00040000, 0x00000000 }, /* coprocessor boolean registers */ \ 403 { 0x00040000, 0x00000000 }, /* coprocessor boolean registers */ \
426 { 0xfff80000, 0x00000007 }, /* floating-point registers */ \ 404 { 0xfff80000, 0x00000007 }, /* floating-point registers */ \
427 { 0x00000000, 0x00000008 }, /* MAC16 accumulator */ \ 405 { 0x00000000, 0x00000008 }, /* MAC16 accumulator */ \
428 { 0x00000002, 0x00000000 }, /* stack pointer register */ \ 406 { 0x00000002, 0x00000000 }, /* stack pointer register */ \
429 { 0x0000ff7d, 0x00000000 }, /* preferred reload registers */ \ 407 { 0x0000fffd, 0x00000000 }, /* preferred reload registers */ \
430 { 0x0000fffd, 0x00000000 }, /* general-purpose registers */ \ 408 { 0x0000fffd, 0x00000000 }, /* general-purpose registers */ \
431 { 0x0003ffff, 0x00000000 }, /* integer registers */ \ 409 { 0x0003ffff, 0x00000000 }, /* integer registers */ \
432 { 0xffffffff, 0x0000000f } /* all registers */ \ 410 { 0xffffffff, 0x0000000f } /* all registers */ \
433 } 411 }
434 412
435 #define IRA_COVER_CLASSES \
436 { \
437 BR_REGS, FP_REGS, ACC_REG, AR_REGS, LIM_REG_CLASSES \
438 }
439
440 /* A C expression whose value is a register class containing hard 413 /* A C expression whose value is a register class containing hard
441 register REGNO. In general there is more that one such class; 414 register REGNO. In general there is more that one such class;
442 choose a class which is "minimal", meaning that no smaller class 415 choose a class which is "minimal", meaning that no smaller class
443 also contains the register. */ 416 also contains the register. */
444 extern const enum reg_class xtensa_regno_to_class[FIRST_PSEUDO_REGISTER]; 417 #define REGNO_REG_CLASS(REGNO) xtensa_regno_to_class (REGNO)
445
446 #define REGNO_REG_CLASS(REGNO) xtensa_regno_to_class[ (REGNO) ]
447 418
448 /* Use the Xtensa AR register file for base registers. 419 /* Use the Xtensa AR register file for base registers.
449 No index registers. */ 420 No index registers. */
450 #define BASE_REG_CLASS AR_REGS 421 #define BASE_REG_CLASS AR_REGS
451 #define INDEX_REG_CLASS NO_REGS 422 #define INDEX_REG_CLASS NO_REGS
453 /* The small_register_classes_for_mode_p hook must always return true for 424 /* The small_register_classes_for_mode_p hook must always return true for
454 Xtrnase, because all of the 16 AR registers may be explicitly used in 425 Xtrnase, because all of the 16 AR registers may be explicitly used in
455 the RTL, as either incoming or outgoing arguments. */ 426 the RTL, as either incoming or outgoing arguments. */
456 #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true 427 #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true
457 428
458 /* Return the maximum number of consecutive registers
459 needed to represent mode MODE in a register of class CLASS. */
460 #define CLASS_UNITS(mode, size) \
461 ((GET_MODE_SIZE (mode) + (size) - 1) / (size))
462
463 #define CLASS_MAX_NREGS(CLASS, MODE) \
464 (CLASS_UNITS (MODE, UNITS_PER_WORD))
465
466
467 /* Stack layout; function entry, exit and calling. */ 429 /* Stack layout; function entry, exit and calling. */
468 430
469 #define STACK_GROWS_DOWNWARD 431 #define STACK_GROWS_DOWNWARD 1
470 432
471 /* Offset within stack frame to start allocating local variables at. */ 433 #define FRAME_GROWS_DOWNWARD flag_stack_protect
472 #define STARTING_FRAME_OFFSET \
473 crtl->outgoing_args_size
474 434
475 /* The ARG_POINTER and FRAME_POINTER are not real Xtensa registers, so 435 /* The ARG_POINTER and FRAME_POINTER are not real Xtensa registers, so
476 they are eliminated to either the stack pointer or hard frame pointer. */ 436 they are eliminated to either the stack pointer or hard frame pointer. */
477 #define ELIMINABLE_REGS \ 437 #define ELIMINABLE_REGS \
478 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ 438 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
480 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ 440 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
481 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}} 441 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}
482 442
483 /* Specify the initial difference between the specified pair of registers. */ 443 /* Specify the initial difference between the specified pair of registers. */
484 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ 444 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
485 do { \ 445 (OFFSET) = xtensa_initial_elimination_offset ((FROM), (TO))
486 compute_frame_size (get_frame_size ()); \
487 switch (FROM) \
488 { \
489 case FRAME_POINTER_REGNUM: \
490 (OFFSET) = 0; \
491 break; \
492 case ARG_POINTER_REGNUM: \
493 (OFFSET) = xtensa_current_frame_size; \
494 break; \
495 default: \
496 gcc_unreachable (); \
497 } \
498 } while (0)
499 446
500 /* If defined, the maximum amount of space required for outgoing 447 /* If defined, the maximum amount of space required for outgoing
501 arguments will be computed and placed into the variable 448 arguments will be computed and placed into the variable
502 'crtl->outgoing_args_size'. No space will be pushed 449 'crtl->outgoing_args_size'. No space will be pushed
503 onto the stack for each call; instead, the function prologue 450 onto the stack for each call; instead, the function prologue
513 /* Align stack frames on 128 bits for Xtensa. This is necessary for 460 /* Align stack frames on 128 bits for Xtensa. This is necessary for
514 128-bit datatypes defined in TIE (e.g., for Vectra). */ 461 128-bit datatypes defined in TIE (e.g., for Vectra). */
515 #define STACK_BOUNDARY 128 462 #define STACK_BOUNDARY 128
516 463
517 /* Use a fixed register window size of 8. */ 464 /* Use a fixed register window size of 8. */
518 #define WINDOW_SIZE 8 465 #define WINDOW_SIZE (TARGET_WINDOWED_ABI ? 8 : 0)
519 466
520 /* Symbolic macros for the registers used to return integer, floating 467 /* Symbolic macros for the registers used to return integer, floating
521 point, and values of coprocessor and user-defined modes. */ 468 point, and values of coprocessor and user-defined modes. */
522 #define GP_RETURN (GP_REG_FIRST + 2 + WINDOW_SIZE) 469 #define GP_RETURN (GP_REG_FIRST + 2 + WINDOW_SIZE)
523 #define GP_OUTGOING_RETURN (GP_REG_FIRST + 2) 470 #define GP_OUTGOING_RETURN (GP_REG_FIRST + 2)
577 #define FUNCTION_PROFILER(FILE, LABELNO) \ 524 #define FUNCTION_PROFILER(FILE, LABELNO) \
578 do { \ 525 do { \
579 fprintf (FILE, "\t%s\ta10, a0\n", TARGET_DENSITY ? "mov.n" : "mov"); \ 526 fprintf (FILE, "\t%s\ta10, a0\n", TARGET_DENSITY ? "mov.n" : "mov"); \
580 if (flag_pic) \ 527 if (flag_pic) \
581 { \ 528 { \
582 fprintf (FILE, "\tmovi\ta8, _mcount@PLT\n"); \ 529 fprintf (FILE, "\tmovi\ta%d, _mcount@PLT\n", WINDOW_SIZE); \
583 fprintf (FILE, "\tcallx8\ta8\n"); \ 530 fprintf (FILE, "\tcallx%d\ta%d\n", WINDOW_SIZE, WINDOW_SIZE); \
584 } \ 531 } \
585 else \ 532 else \
586 fprintf (FILE, "\tcall8\t_mcount\n"); \ 533 fprintf (FILE, "\tcall%d\t_mcount\n", WINDOW_SIZE); \
587 } while (0) 534 } while (0)
588 535
589 /* Stack pointer value doesn't matter at exit. */ 536 /* Stack pointer value doesn't matter at exit. */
590 #define EXIT_IGNORE_STACK 1 537 #define EXIT_IGNORE_STACK 1
591 538
592 /* Size in bytes of the trampoline, as an integer. Make sure this is 539 /* Size in bytes of the trampoline, as an integer. Make sure this is
593 a multiple of TRAMPOLINE_ALIGNMENT to avoid -Wpadded warnings. */ 540 a multiple of TRAMPOLINE_ALIGNMENT to avoid -Wpadded warnings. */
594 #define TRAMPOLINE_SIZE (TARGET_CONST16 || TARGET_ABSOLUTE_LITERALS ? 60 : 52) 541 #define TRAMPOLINE_SIZE (TARGET_WINDOWED_ABI ? \
542 (TARGET_CONST16 || TARGET_ABSOLUTE_LITERALS ? \
543 60 : 52) : \
544 (TARGET_CONST16 || TARGET_ABSOLUTE_LITERALS ? \
545 32 : 24))
595 546
596 /* Alignment required for trampolines, in bits. */ 547 /* Alignment required for trampolines, in bits. */
597 #define TRAMPOLINE_ALIGNMENT 32 548 #define TRAMPOLINE_ALIGNMENT 32
598 549
599 /* If defined, a C expression that produces the machine-specific code 550 /* If defined, a C expression that produces the machine-specific code
631 #define DYNAMIC_CHAIN_ADDRESS(frame) \ 582 #define DYNAMIC_CHAIN_ADDRESS(frame) \
632 gen_rtx_PLUS (Pmode, frame, GEN_INT (-3 * UNITS_PER_WORD)) 583 gen_rtx_PLUS (Pmode, frame, GEN_INT (-3 * UNITS_PER_WORD))
633 584
634 /* Define this if the return address of a particular stack frame is 585 /* Define this if the return address of a particular stack frame is
635 accessed from the frame pointer of the previous stack frame. */ 586 accessed from the frame pointer of the previous stack frame. */
636 #define RETURN_ADDR_IN_PREVIOUS_FRAME 587 #define RETURN_ADDR_IN_PREVIOUS_FRAME TARGET_WINDOWED_ABI
637 588
638 /* A C expression whose value is RTL representing the value of the 589 /* A C expression whose value is RTL representing the value of the
639 return address for the frame COUNT steps up from the current 590 return address for the frame COUNT steps up from the current
640 frame, after the prologue. */ 591 frame, after the prologue. */
641 #define RETURN_ADDR_RTX xtensa_return_addr 592 #define RETURN_ADDR_RTX xtensa_return_addr
673 but rejecting CONST_DOUBLE. */ 624 but rejecting CONST_DOUBLE. */
674 #define CONSTANT_ADDRESS_P(X) \ 625 #define CONSTANT_ADDRESS_P(X) \
675 ((GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \ 626 ((GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
676 || GET_CODE (X) == CONST_INT || GET_CODE (X) == HIGH \ 627 || GET_CODE (X) == CONST_INT || GET_CODE (X) == HIGH \
677 || (GET_CODE (X) == CONST))) 628 || (GET_CODE (X) == CONST)))
678
679 /* Nonzero if the constant value X is a legitimate general operand.
680 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
681 #define LEGITIMATE_CONSTANT_P(X) (! xtensa_tls_referenced_p (X))
682 629
683 /* A C expression that is nonzero if X is a legitimate immediate 630 /* A C expression that is nonzero if X is a legitimate immediate
684 operand on the target machine when generating position independent 631 operand on the target machine when generating position independent
685 code. */ 632 code. */
686 #define LEGITIMATE_PIC_OPERAND_P(X) \ 633 #define LEGITIMATE_PIC_OPERAND_P(X) \
704 /* Prefer word-sized loads. */ 651 /* Prefer word-sized loads. */
705 #define SLOW_BYTE_ACCESS 1 652 #define SLOW_BYTE_ACCESS 1
706 653
707 /* Shift instructions ignore all but the low-order few bits. */ 654 /* Shift instructions ignore all but the low-order few bits. */
708 #define SHIFT_COUNT_TRUNCATED 1 655 #define SHIFT_COUNT_TRUNCATED 1
709
710 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
711 is done just by pretending it is already truncated. */
712 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
713 656
714 #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 32, 1) 657 #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 32, 1)
715 #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = -1, 1) 658 #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = -1, 1)
716 659
717 /* Specify the machine mode that pointers have. 660 /* Specify the machine mode that pointers have.
790 733
791 734
792 /* Define output to appear before the constant pool. */ 735 /* Define output to appear before the constant pool. */
793 #define ASM_OUTPUT_POOL_PROLOGUE(FILE, FUNNAME, FUNDECL, SIZE) \ 736 #define ASM_OUTPUT_POOL_PROLOGUE(FILE, FUNNAME, FUNDECL, SIZE) \
794 do { \ 737 do { \
795 if ((SIZE) > 0) \ 738 if ((SIZE) > 0 || !TARGET_WINDOWED_ABI) \
796 { \ 739 { \
797 resolve_unique_section ((FUNDECL), 0, flag_function_sections); \ 740 resolve_unique_section ((FUNDECL), 0, flag_function_sections); \
798 switch_to_section (function_section (FUNDECL)); \ 741 switch_to_section (function_section (FUNDECL)); \
799 fprintf (FILE, "\t.literal_position\n"); \ 742 fprintf (FILE, "\t.literal_position\n"); \
800 } \ 743 } \
817 complicated to efficiently describe with CFI entries. The CFA must 760 complicated to efficiently describe with CFI entries. The CFA must
818 still be specified in DWARF so that DW_AT_frame_base is set correctly 761 still be specified in DWARF so that DW_AT_frame_base is set correctly
819 for debugging. */ 762 for debugging. */
820 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, 0) 763 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, 0)
821 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (0) 764 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (0)
822 #define DWARF_FRAME_REGISTERS 16 765 #define DWARF_ALT_FRAME_RETURN_COLUMN 16
766 #define DWARF_FRAME_REGISTERS (DWARF_ALT_FRAME_RETURN_COLUMN \
767 + (TARGET_WINDOWED_ABI ? 0 : 1))
823 #define EH_RETURN_DATA_REGNO(N) ((N) < 2 ? (N) + 2 : INVALID_REGNUM) 768 #define EH_RETURN_DATA_REGNO(N) ((N) < 2 ? (N) + 2 : INVALID_REGNUM)
824 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ 769 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
825 (flag_pic \ 770 (flag_pic \
826 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) \ 771 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) \
827 | DW_EH_PE_pcrel | DW_EH_PE_sdata4) \ 772 | DW_EH_PE_pcrel | DW_EH_PE_sdata4) \
828 : DW_EH_PE_absptr) 773 : DW_EH_PE_absptr)
774
775 #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, GP_REG_FIRST + 10)
829 776
830 /* Emit a PC-relative relocation. */ 777 /* Emit a PC-relative relocation. */
831 #define ASM_OUTPUT_DWARF_PCREL(FILE, SIZE, LABEL) \ 778 #define ASM_OUTPUT_DWARF_PCREL(FILE, SIZE, LABEL) \
832 do { \ 779 do { \
833 fputs (integer_asm_op (SIZE, FALSE), FILE); \ 780 fputs (integer_asm_op (SIZE, FALSE), FILE); \
838 /* Xtensa constant pool breaks the devices in crtstuff.c to control 785 /* Xtensa constant pool breaks the devices in crtstuff.c to control
839 section in where code resides. We have to write it as asm code. Use 786 section in where code resides. We have to write it as asm code. Use
840 a MOVI and let the assembler relax it -- for the .init and .fini 787 a MOVI and let the assembler relax it -- for the .init and .fini
841 sections, the assembler knows to put the literal in the right 788 sections, the assembler knows to put the literal in the right
842 place. */ 789 place. */
790 #if defined(__XTENSA_WINDOWED_ABI__)
843 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ 791 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
844 asm (SECTION_OP "\n\ 792 asm (SECTION_OP "\n\
845 movi\ta8, " USER_LABEL_PREFIX #FUNC "\n\ 793 movi\ta8, " USER_LABEL_PREFIX #FUNC "\n\
846 callx8\ta8\n" \ 794 callx8\ta8\n" \
847 TEXT_SECTION_ASM_OP); 795 TEXT_SECTION_ASM_OP);
796 #elif defined(__XTENSA_CALL0_ABI__)
797 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
798 asm (SECTION_OP "\n\
799 movi\ta0, " USER_LABEL_PREFIX #FUNC "\n\
800 callx0\ta0\n" \
801 TEXT_SECTION_ASM_OP);
802 #endif