]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/rx/rx.h
1 /* GCC backend definitions for the Renesas RX processor.
2 Copyright (C) 2008, 2009 Free Software Foundation, Inc.
3 Contributed by Red Hat.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published
9 by the Free Software Foundation; either version 3, or (at your
10 option) any later version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
22 #define TARGET_CPU_CPP_BUILTINS() \
25 builtin_define ("__RX__"); \
26 builtin_assert ("cpu=RX"); \
27 builtin_assert ("machine=RX"); \
29 if (TARGET_BIG_ENDIAN_DATA) \
30 builtin_define ("__RX_BIG_ENDIAN__"); \
32 builtin_define ("__RX_LITTLE_ENDIAN__");\
34 if (TARGET_64BIT_DOUBLES) \
35 builtin_define ("__RX_64BIT_DOUBLES__");\
37 builtin_define ("__RX_32BIT_DOUBLES__");\
39 if (TARGET_AS100_SYNTAX) \
40 builtin_define ("__RX_AS100_SYNTAX__"); \
42 builtin_define ("__RX_GAS_SYNTAX__"); \
47 #define STARTFILE_SPEC "%{pg:gcrt0.o%s}%{!pg:crt0.o%s} crtbegin.o%s"
50 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
54 %{mbig-endian-data:-mbig-endian-data} \
55 %{m64bit-doubles:-m64bit-doubles} \
56 %{msmall-data-limit*:-msmall-data-limit} \
64 %{msim*:-lsim}%{!msim*:-lnosys} \
65 %{fprofile-arcs|fprofile-generate|coverage:-lgcov} \
67 %{!T*: %{msim*:%Trx-sim.ld}%{!msim*:%Trx.ld}} \
71 #define LINK_SPEC "%{mbig-endian-data:--oformat elf32-rx-be} %{mrelax:-relax}"
74 #define BITS_BIG_ENDIAN 0
75 #define BYTES_BIG_ENDIAN TARGET_BIG_ENDIAN_DATA
76 #define WORDS_BIG_ENDIAN TARGET_BIG_ENDIAN_DATA
78 #ifdef __RX_BIG_ENDIAN__
79 #define LIBGCC2_WORDS_BIG_ENDIAN 1
81 #define LIBGCC2_WORDS_BIG_ENDIAN 0
84 #define UNITS_PER_WORD 4
86 #define INT_TYPE_SIZE 32
87 #define LONG_TYPE_SIZE 32
88 #define LONG_LONG_TYPE_SIZE 64
90 #define FLOAT_TYPE_SIZE 32
91 #define DOUBLE_TYPE_SIZE (TARGET_64BIT_DOUBLES ? 64 : 32)
92 #define LONG_DOUBLE_TYPE_SIZE DOUBLE_TYPE_SIZE
94 #ifdef __RX_64BIT_DOUBLES__
95 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
96 #define LIBGCC2_DOUBLE_TYPE_SIZE 64
97 #define LIBGCC2_HAS_DF_MODE 1
99 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 32
100 #define LIBGCC2_DOUBLE_TYPE_SIZE 32
103 #define DEFAULT_SIGNED_CHAR 0
105 #define STRICT_ALIGNMENT 1
106 #define FUNCTION_BOUNDARY 8
107 #define BIGGEST_ALIGNMENT 32
108 #define STACK_BOUNDARY 32
109 #define PARM_BOUNDARY 8
111 #define FUNCTION_ARG_BOUNDARY(MODE, TYPE) 32
113 #define STACK_GROWS_DOWNWARD 1
114 #define FRAME_GROWS_DOWNWARD 0
115 #define FIRST_PARM_OFFSET(FNDECL) 0
117 #define MAX_REGS_PER_ADDRESS 2
120 #define POINTER_SIZE 32
122 #define SIZE_TYPE "long unsigned int"
123 #define POINTERS_EXTEND_UNSIGNED 1
124 #define FUNCTION_MODE QImode
125 #define CASE_VECTOR_MODE Pmode
126 #define WORD_REGISTER_OPERATIONS 1
127 #define HAS_LONG_COND_BRANCH 0
128 #define HAS_LONG_UNCOND_BRANCH 0
131 #define STARTING_FRAME_OFFSET 0
133 #define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, SIZE) 0
134 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
136 #define LEGITIMATE_CONSTANT_P(X) rx_is_legitimate_constant (X)
138 #define HANDLE_PRAGMA_PACK_PUSH_POP 1
140 #define HAVE_PRE_DECCREMENT 1
141 #define HAVE_POST_INCREMENT 1
143 #define MOVE_RATIO(SPEED) ((SPEED) ? 4 : 2)
144 #define SLOW_BYTE_ACCESS 1
146 #define STORE_FLAG_VALUE 1
147 #define LOAD_EXTEND_OP(MODE) SIGN_EXTEND
148 #define SHORT_IMMEDIATES_SIGN_EXTEND 1
152 NO_REGS
, /* No registers in set. */
153 GR_REGS
, /* Integer registers. */
154 ALL_REGS
, /* All registers. */
155 LIM_REG_CLASSES
/* Max value + 1. */
158 #define REG_CLASS_NAMES \
165 #define REG_CLASS_CONTENTS \
167 { 0x00000000 }, /* No registers, */ \
168 { 0x0000ffff }, /* Integer registers. */ \
169 { 0x0000ffff } /* All registers. */ \
172 #define IRA_COVER_CLASSES \
174 GR_REGS, LIM_REG_CLASSES \
177 #define SMALL_REGISTER_CLASSES 0
178 #define N_REG_CLASSES (int) LIM_REG_CLASSES
179 #define CLASS_MAX_NREGS(CLASS, MODE) ((GET_MODE_SIZE (MODE) \
180 + UNITS_PER_WORD - 1) \
183 #define GENERAL_REGS GR_REGS
184 #define BASE_REG_CLASS GR_REGS
185 #define INDEX_REG_CLASS GR_REGS
187 #define FIRST_PSEUDO_REGISTER 16
189 #define REGNO_REG_CLASS(REGNO) ((REGNO) < FIRST_PSEUDO_REGISTER \
192 #define STACK_POINTER_REGNUM 0
193 #define FUNC_RETURN_REGNUM 1
194 #define FRAME_POINTER_REGNUM 6
195 #define ARG_POINTER_REGNUM 7
196 #define STATIC_CHAIN_REGNUM 8
197 #define TRAMPOLINE_TEMP_REGNUM 9
198 #define STRUCT_VAL_REGNUM 15
200 /* This is the register which is used to hold the address of the start
201 of the small data area, if that feature is being used. Note - this
202 register must not be call_used because otherwise library functions
203 that are compiled without small data support might clobber it.
205 FIXME: The function gcc/config/rx/rx.c:rx_gen_move_template() has a
206 built in copy of this register's name, rather than constructing the
207 name from this #define. */
208 #define GP_BASE_REGNUM 13
210 #define ELIMINABLE_REGS \
211 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
212 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM }, \
213 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }}
215 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
216 (OFFSET) = rx_initial_elimination_offset ((FROM), (TO))
219 #define FUNCTION_ARG_REGNO_P(N) (((N) >= 1) && ((N) <= 4))
220 #define FUNCTION_VALUE_REGNO_P(N) ((N) == FUNC_RETURN_REGNUM)
221 #define DEFAULT_PCC_STRUCT_RETURN 0
223 #define FIXED_REGISTERS \
225 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
228 #define CALL_USED_REGISTERS \
230 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 \
233 #define CONDITIONAL_REGISTER_USAGE \
234 rx_conditional_register_usage ()
236 #define LIBCALL_VALUE(MODE) \
237 gen_rtx_REG (((GET_MODE_CLASS (MODE) != MODE_INT \
238 || GET_MODE_SIZE (MODE) >= 4) \
243 /* Order of allocation of registers. */
245 #define REG_ALLOC_ORDER \
246 { 7, 10, 11, 12, 13, 14, 4, 3, 2, 1, 9, 8, 6, 5, 15 \
249 #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
251 #define REGNO_IN_RANGE(REGNO, MIN, MAX) \
252 (IN_RANGE ((REGNO), (MIN), (MAX)) \
253 || (reg_renumber != NULL \
254 && reg_renumber[(REGNO)] >= (MIN) \
255 && reg_renumber[(REGNO)] <= (MAX)))
258 #define REGNO_OK_FOR_BASE_P(regno) REGNO_IN_RANGE (regno, 0, 15)
260 #define REGNO_OK_FOR_BASE_P(regno) 1
263 #define REGNO_OK_FOR_INDEX_P(regno) REGNO_OK_FOR_BASE_P (regno)
265 #define RTX_OK_FOR_BASE(X, STRICT) \
268 && REGNO_IN_RANGE (REGNO (X), 0, 15)) \
269 || (GET_CODE (X) == SUBREG \
270 && REG_P (SUBREG_REG (X)) \
271 && REGNO_IN_RANGE (REGNO (SUBREG_REG (X)), 0, 15))) \
274 || (GET_CODE (X) == SUBREG \
275 && REG_P (SUBREG_REG (X))))))
277 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) \
280 if (rx_is_mode_dependent_addr (ADDR)) \
286 #define RETURN_ADDR_RTX(COUNT, FRAMEADDR) \
288 ? gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, arg_pointer_rtx, GEN_INT (-4))) \
291 #define INCOMING_RETURN_ADDR_RTX gen_rtx_MEM (Pmode, stack_pointer_rtx)
293 #define ACCUMULATE_OUTGOING_ARGS 1
295 typedef unsigned int CUMULATIVE_ARGS
;
297 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
300 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
301 rx_function_arg (& CUM, MODE, TYPE, NAMED)
303 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
304 (CUM) += rx_function_arg_size (MODE, TYPE)
306 #define TRAMPOLINE_SIZE (! TARGET_BIG_ENDIAN_DATA ? 14 : 20)
307 #define TRAMPOLINE_ALIGNMENT 32
309 #define NO_PROFILE_COUNTERS 1
310 #define PROFILE_BEFORE_PROLOGUE 1
312 #define FUNCTION_PROFILER(FILE, LABELNO) \
313 fprintf (FILE, "\tbsr\t__mcount\n");
316 #define HARD_REGNO_NREGS(REGNO, MODE) CLASS_MAX_NREGS (0, MODE)
318 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
319 REGNO_REG_CLASS (REGNO) == GR_REGS
321 #define MODES_TIEABLE_P(MODE1, MODE2) \
322 ( ( GET_MODE_CLASS (MODE1) == MODE_FLOAT \
323 || GET_MODE_CLASS (MODE1) == MODE_COMPLEX_FLOAT) \
324 == ( GET_MODE_CLASS (MODE2) == MODE_FLOAT \
325 || GET_MODE_CLASS (MODE2) == MODE_COMPLEX_FLOAT))
328 #define REGISTER_NAMES \
330 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
331 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" \
334 #define ADDITIONAL_REGISTER_NAMES \
336 { "sp", STACK_POINTER_REGNUM } \
337 , { "fp", FRAME_POINTER_REGNUM } \
338 , { "arg", ARG_POINTER_REGNUM } \
339 , { "chain", STATIC_CHAIN_REGNUM } \
342 #define DATA_SECTION_ASM_OP \
343 (TARGET_AS100_SYNTAX ? "\t.SECTION D,DATA" \
344 : "\t.section D,\"aw\",@progbits\n\t.p2align 2")
346 #define SDATA_SECTION_ASM_OP \
347 (TARGET_AS100_SYNTAX ? "\t.SECTION D_2,DATA,ALIGN=2" \
348 : "\t.section D_2,\"aw\",@progbits\n\t.p2align 1")
350 #undef READONLY_DATA_SECTION_ASM_OP
351 #define READONLY_DATA_SECTION_ASM_OP \
352 (TARGET_AS100_SYNTAX ? "\t.SECTION C,ROMDATA,ALIGN=4" \
353 : "\t.section C,\"a\",@progbits\n\t.p2align 2")
355 #define BSS_SECTION_ASM_OP \
356 (TARGET_AS100_SYNTAX ? "\t.SECTION B,DATA,ALIGN=4" \
357 : "\t.section B,\"w\",@nobits\n\t.p2align 2")
359 #define SBSS_SECTION_ASM_OP \
360 (TARGET_AS100_SYNTAX ? "\t.SECTION B_2,DATA,ALIGN=2" \
361 : "\t.section B_2,\"w\",@nobits\n\t.p2align 1")
363 /* The following definitions are conditional depending upon whether the
364 compiler is being built or crtstuff.c is being compiled by the built
366 #if defined CRT_BEGIN || defined CRT_END
367 # ifdef __RX_AS100_SYNTAX
368 # define TEXT_SECTION_ASM_OP "\t.SECTION P,CODE"
369 # define CTORS_SECTION_ASM_OP "\t.SECTION init_array,CODE"
370 # define DTORS_SECTION_ASM_OP "\t.SECTION fini_array,CODE"
371 # define INIT_ARRAY_SECTION_ASM_OP "\t.SECTION init_array,CODE"
372 # define FINI_ARRAY_SECTION_ASM_OP "\t.SECTION fini_array,CODE"
374 # define TEXT_SECTION_ASM_OP "\t.section P,\"ax\""
375 # define CTORS_SECTION_ASM_OP \
376 "\t.section\t.init_array,\"aw\",@init_array"
377 # define DTORS_SECTION_ASM_OP \
378 "\t.section\t.fini_array,\"aw\",@fini_array"
379 # define INIT_ARRAY_SECTION_ASM_OP \
380 "\t.section\t.init_array,\"aw\",@init_array"
381 # define FINI_ARRAY_SECTION_ASM_OP \
382 "\t.section\t.fini_array,\"aw\",@fini_array"
385 # define TEXT_SECTION_ASM_OP \
386 (TARGET_AS100_SYNTAX ? "\t.SECTION P,CODE" : "\t.section P,\"ax\"")
388 # define CTORS_SECTION_ASM_OP \
389 (TARGET_AS100_SYNTAX ? "\t.SECTION init_array,CODE" \
390 : "\t.section\t.init_array,\"aw\",@init_array")
392 # define DTORS_SECTION_ASM_OP \
393 (TARGET_AS100_SYNTAX ? "\t.SECTION fini_array,CODE" \
394 : "\t.section\t.fini_array,\"aw\",@fini_array")
396 # define INIT_ARRAY_SECTION_ASM_OP \
397 (TARGET_AS100_SYNTAX ? "\t.SECTION init_array,CODE" \
398 : "\t.section\t.init_array,\"aw\",@init_array")
400 # define FINI_ARRAY_SECTION_ASM_OP \
401 (TARGET_AS100_SYNTAX ? "\t.SECTION fini_array,CODE" \
402 : "\t.section\t.fini_array,\"aw\",@fini_array")
405 #define GLOBAL_ASM_OP \
406 (TARGET_AS100_SYNTAX ? "\t.GLB\t" : "\t.global\t")
407 #define ASM_COMMENT_START " ;"
408 #define ASM_APP_ON ""
409 #define ASM_APP_OFF ""
410 #define LOCAL_LABEL_PREFIX "L"
411 #undef USER_LABEL_PREFIX
412 #define USER_LABEL_PREFIX "_"
414 #define ASM_OUTPUT_ALIGN(STREAM, LOG) \
419 if (TARGET_AS100_SYNTAX) \
422 fprintf (STREAM, "\t.ALIGN 4\t; %d alignment actually requested\n", 1 << (LOG)); \
424 fprintf (STREAM, "\t.ALIGN 2\n"); \
427 fprintf (STREAM, "\t.balign %d\n", 1 << (LOG)); \
431 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
432 fprintf (FILE, TARGET_AS100_SYNTAX ? "\t.LWORD L%d\n" : "\t.long .L%d\n", \
435 /* This is how to output an element of a case-vector that is relative.
436 Note: The local label referenced by the "3b" below is emitted by
437 the tablejump insn. */
439 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
440 fprintf (FILE, TARGET_AS100_SYNTAX \
441 ? "\t.LWORD L%d - ?-\n" : "\t.long .L%d - 1b\n", VALUE)
443 #define ASM_OUTPUT_SIZE_DIRECTIVE(STREAM, NAME, SIZE) \
446 HOST_WIDE_INT size_ = (SIZE); \
448 /* The as100 assembler does not have an equivalent of the SVR4 \
449 .size pseudo-op. */ \
450 if (TARGET_AS100_SYNTAX) \
453 fputs (SIZE_ASM_OP, STREAM); \
454 assemble_name (STREAM, NAME); \
455 fprintf (STREAM, ", " HOST_WIDE_INT_PRINT_DEC "\n", size_); \
459 #define ASM_OUTPUT_MEASURED_SIZE(STREAM, NAME) \
462 /* The as100 assembler does not have an equivalent of the SVR4 \
463 .size pseudo-op. */ \
464 if (TARGET_AS100_SYNTAX) \
466 fputs (SIZE_ASM_OP, STREAM); \
467 assemble_name (STREAM, NAME); \
468 fputs (", .-", STREAM); \
469 assemble_name (STREAM, NAME); \
470 putc ('\n', STREAM); \
474 #define ASM_OUTPUT_TYPE_DIRECTIVE(STREAM, NAME, TYPE) \
477 /* The as100 assembler does not have an equivalent of the SVR4 \
478 .size pseudo-op. */ \
479 if (TARGET_AS100_SYNTAX) \
481 fputs (TYPE_ASM_OP, STREAM); \
482 assemble_name (STREAM, NAME); \
483 fputs (", ", STREAM); \
484 fprintf (STREAM, TYPE_OPERAND_FMT, TYPE); \
485 putc ('\n', STREAM); \
489 #undef ASM_GENERATE_INTERNAL_LABEL
490 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
493 sprintf (LABEL, TARGET_AS100_SYNTAX ? "*%s%u" : "*.%s%u", \
494 PREFIX, (unsigned) (NUM)); \
498 #undef ASM_OUTPUT_EXTERNAL
499 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
502 if (TARGET_AS100_SYNTAX) \
503 targetm.asm_out.globalize_label (FILE, NAME); \
504 default_elf_asm_output_external (FILE, DECL, NAME); \
508 #undef ASM_OUTPUT_ALIGNED_COMMON
509 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
512 if (TARGET_AS100_SYNTAX) \
514 fprintf ((FILE), "\t.GLB\t"); \
515 assemble_name ((FILE), (NAME)); \
516 fprintf ((FILE), "\n"); \
517 assemble_name ((FILE), (NAME)); \
518 switch ((ALIGN) / BITS_PER_UNIT) \
521 fprintf ((FILE), ":\t.BLKL\t"HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
525 fprintf ((FILE), ":\t.BLKW\t"HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
529 fprintf ((FILE), ":\t.BLKB\t"HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
536 fprintf ((FILE), "%s", COMMON_ASM_OP); \
537 assemble_name ((FILE), (NAME)); \
538 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
539 (SIZE), (ALIGN) / BITS_PER_UNIT); \
545 #define SKIP_ASM_OP (TARGET_AS100_SYNTAX ? "\t.BLKB\t" : "\t.zero\t")
547 #undef ASM_OUTPUT_LIMITED_STRING
548 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \
551 const unsigned char *_limited_str = \
552 (const unsigned char *) (STR); \
555 fprintf ((FILE), TARGET_AS100_SYNTAX \
556 ? "\t.BYTE\t\"" : "\t.string\t\""); \
558 for (; (ch = *_limited_str); _limited_str++) \
562 switch (escape = ESCAPES[ch]) \
568 fprintf ((FILE), "\\%03o", ch); \
571 putc ('\\', (FILE)); \
572 putc (escape, (FILE)); \
577 fprintf ((FILE), TARGET_AS100_SYNTAX ? "\"\n\t.BYTE\t0\n" : "\"\n");\
582 #define IDENT_ASM_OP (TARGET_AS100_SYNTAX \
583 ? "\t.END\t; Built by: ": "\t.ident\t")
585 /* For PIC put jump tables into the text section so that the offsets that
586 they contain are always computed between two same-section symbols. */
587 #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
589 #define PRINT_OPERAND(FILE, X, CODE) \
590 rx_print_operand (FILE, X, CODE)
591 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
592 rx_print_operand_address (FILE, ADDR)
595 #define CC_NO_CARRY 0400
596 #define NOTICE_UPDATE_CC(EXP, INSN) rx_notice_update_cc (EXP, INSN)
598 extern int rx_float_compare_mode
;
600 /* This is a version of REG_P that also returns TRUE for SUBREGs. */
601 #define RX_REG_P(rtl) (REG_P (rtl) || GET_CODE (rtl) == SUBREG)
603 /* Like REG_P except that this macro is true for SET expressions. */
604 #define SET_P(rtl) (GET_CODE (rtl) == SET)
606 #define CAN_DEBUG_WITHOUT_FP 1
608 /* The AS100 assembler does not support .leb128 and .uleb128, but
609 the compiler-build-time configure tests will have enabled their
610 use because GAS supports them. So default to generating STABS
611 debug information instead of DWARF2 when generating AS100
612 compatible output. */
613 #undef PREFERRED_DEBUGGING_TYPE
614 #define PREFERRED_DEBUGGING_TYPE (TARGET_AS100_SYNTAX \
615 ? DBX_DEBUG : DWARF2_DEBUG)
618 #define CC1_SPEC "%{mas100-syntax:%{gdwarf*:%e-mas100-syntax is incompatible with -gdwarf}}"
620 /* For some unknown reason LTO compression is not working, at
621 least on my local system. So set the default compression
622 level to none, for now. */
623 #define OVERRIDE_OPTIONS \
626 if (flag_lto_compression_level == -1) \
627 flag_lto_compression_level = 0; \
631 /* This macro is used to decide when RX FPU instructions can be used. */
632 #define ALLOW_RX_FPU_INSNS flag_unsafe_math_optimizations