]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/rl78/rl78.h
1 /* GCC backend definitions for the Renesas RL78 processor.
2 Copyright (C) 2011-2017 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 RL78_MUL_NONE (rl78_mul_type == MUL_NONE)
23 #define RL78_MUL_G13 (rl78_mul_type == MUL_G13)
24 #define RL78_MUL_G14 (rl78_mul_type == MUL_G14)
26 #define TARGET_G10 (rl78_cpu_type == CPU_G10)
27 #define TARGET_G13 (rl78_cpu_type == CPU_G13)
28 #define TARGET_G14 (rl78_cpu_type == CPU_G14)
30 #define TARGET_CPU_CPP_BUILTINS() \
33 builtin_define ("__RL78__"); \
34 builtin_assert ("cpu=RL78"); \
37 builtin_define ("__RL78_MUL_NONE__"); \
38 else if (RL78_MUL_G13) \
39 builtin_define ("__RL78_MUL_G13__"); \
40 else if (RL78_MUL_G14) \
41 builtin_define ("__RL78_MUL_G14__"); \
44 builtin_define ("__RL78_G10__"); \
45 else if (TARGET_G13) \
46 builtin_define ("__RL78_G13__"); \
47 else if (TARGET_G14) \
48 builtin_define ("__RL78_G14__"); \
53 #define STARTFILE_SPEC "%{pg:gcrt0.o%s}%{!pg:crt0.o%s} crtbegin.o%s"
56 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
82 %{fprofile-arcs|fprofile-generate|coverage:-lgcov} \
84 %{!T*: %{msim:%Trl78-sim.ld}%{!msim:%Trl78.ld}} \
88 #define BITS_BIG_ENDIAN 0
89 #define BYTES_BIG_ENDIAN 0
90 #define WORDS_BIG_ENDIAN 0
93 /* This is to get correct SI and DI modes in libgcc2.c (32 and 64 bits). */
94 #define UNITS_PER_WORD 4
95 /* We have a problem with libgcc2. It only defines two versions of
96 each function, one for "int" and one for "long long". Ie it assumes
97 that "sizeof (int) == sizeof (long)". For the RL78 this is not true
98 and we need a third set of functions. We explicitly define
99 LIBGCC2_UNITS_PER_WORD here so that it is clear that we are expecting
100 to get the SI and DI versions from the libgcc2.c sources, and we
101 provide our own set of HI functions, which is why this
102 definition is surrounded by #ifndef..#endif. */
103 #ifndef LIBGCC2_UNITS_PER_WORD
104 #define LIBGCC2_UNITS_PER_WORD 4
107 /* Actual width of a word, in units (bytes). */
108 #define UNITS_PER_WORD 1
111 #define SHORT_TYPE_SIZE 16
112 #define INT_TYPE_SIZE 16
113 #define LONG_TYPE_SIZE 32
114 #define LONG_LONG_TYPE_SIZE 64
116 #define FLOAT_TYPE_SIZE 32
117 #define DOUBLE_TYPE_SIZE 32 /*64*/
118 #define LONG_DOUBLE_TYPE_SIZE 64 /*DOUBLE_TYPE_SIZE*/
120 #define DEFAULT_SIGNED_CHAR 0
122 #define STRICT_ALIGNMENT 1
123 #define FUNCTION_BOUNDARY 8
124 #define BIGGEST_ALIGNMENT 16
125 #define STACK_BOUNDARY 16
126 #define PARM_BOUNDARY 16
128 #define STACK_GROWS_DOWNWARD 1
129 #define FRAME_GROWS_DOWNWARD 1
130 #define FIRST_PARM_OFFSET(FNDECL) 0
132 #define MAX_REGS_PER_ADDRESS 1
135 #define POINTER_SIZE 16
137 #define SIZE_TYPE "unsigned int"
139 #define PTRDIFF_TYPE "int"
141 #define WCHAR_TYPE "long int"
142 #undef WCHAR_TYPE_SIZE
143 #define WCHAR_TYPE_SIZE BITS_PER_WORD
144 #define POINTERS_EXTEND_UNSIGNED 1
145 #define FUNCTION_MODE HImode
146 #define CASE_VECTOR_MODE Pmode
147 #define WORD_REGISTER_OPERATIONS 1
148 #define HAS_LONG_COND_BRANCH 0
149 #define HAS_LONG_UNCOND_BRANCH 0
152 #define STARTING_FRAME_OFFSET 0
154 #define ADDR_SPACE_NEAR 1
155 #define ADDR_SPACE_FAR 2
157 #define HAVE_PRE_DECCREMENT 0
158 #define HAVE_POST_INCREMENT 0
160 #define MOVE_RATIO(SPEED) ((SPEED) ? 24 : 16)
161 #define SLOW_BYTE_ACCESS 0
163 #define STORE_FLAG_VALUE 1
164 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
167 /* The RL78 has four register banks. Normal operation uses RB0 as
168 real registers, RB1 and RB2 as "virtual" registers (because we know
169 they'll be there, and not used as variables), and RB3 is reserved
170 for interrupt handlers. The virtual registers are accessed as
178 #define REGISTER_NAMES \
180 "x", "a", "c", "b", "e", "d", "l", "h", \
181 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
182 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
183 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \
184 "sp", "ap", "psw", "es", "cs" \
187 #define ADDITIONAL_REGISTER_NAMES \
209 NO_REGS
, /* No registers in set. */
228 V_REGS
, /* Virtual registers. */
229 GR_REGS
, /* Integer registers. */
231 ALL_REGS
, /* All registers. */
232 LIM_REG_CLASSES
/* Max value + 1. */
235 #define REG_CLASS_NAMES \
262 /* Note that no class may include the second register in $fp, because
263 we treat $fp as a single HImode register. */
264 #define REG_CLASS_CONTENTS \
266 { 0x00000000, 0x00000000 }, /* No registers, */ \
267 { 0x00000001, 0x00000000 }, \
268 { 0x00000002, 0x00000000 }, \
269 { 0x00000003, 0x00000000 }, \
270 { 0x00000004, 0x00000000 }, \
271 { 0x00000008, 0x00000000 }, \
272 { 0x0000000c, 0x00000000 }, \
273 { 0x00000010, 0x00000000 }, \
274 { 0x00000020, 0x00000000 }, \
275 { 0x00000030, 0x00000000 }, \
276 { 0x00000040, 0x00000000 }, \
277 { 0x00000080, 0x00000000 }, \
278 { 0x000000c0, 0x00000000 }, \
279 { 0x0000000c, 0x00000000 }, /* B and C - index regs. */ \
280 { 0x000000ff, 0x00000000 }, /* all real registers. */ \
281 { 0x00000000, 0x00000001 }, /* SP */ \
282 { 0x00000300, 0x00000000 }, /* R8 - HImode */ \
283 { 0x00000c00, 0x00000000 }, /* R10 - HImode */ \
284 { 0xff000000, 0x00000000 }, /* INT - HImode */ \
285 { 0xff7fff00, 0x00000000 }, /* Virtual registers. */ \
286 { 0xff7fff00, 0x00000002 }, /* General registers. */ \
287 { 0x04000000, 0x00000004 }, /* PSW. */ \
288 { 0xff7fffff, 0x0000001f } /* All registers. */ \
291 #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true
292 #define N_REG_CLASSES (int) LIM_REG_CLASSES
293 #define CLASS_MAX_NREGS(CLASS, MODE) ((GET_MODE_SIZE (MODE) \
294 + UNITS_PER_WORD - 1) \
297 #define GENERAL_REGS GR_REGS
298 #define BASE_REG_CLASS V_REGS
299 #define INDEX_REG_CLASS V_REGS
301 #define FIRST_PSEUDO_REGISTER 37
303 #define REGNO_REG_CLASS(REGNO) ((REGNO) < FIRST_PSEUDO_REGISTER \
306 #define FRAME_POINTER_REGNUM 22
307 #define STACK_POINTER_REGNUM 32
308 #define ARG_POINTER_REGNUM 33
310 #define FUNC_RETURN_REGNUM 8
311 #define STATIC_CHAIN_REGNUM 14
313 /* Trampolines are implemented with a separate data stack. The memory
314 on stack only holds the function pointer for the chosen stub.
317 #define TRAMPOLINE_SIZE 4
318 #define TRAMPOLINE_ALIGNMENT 16
320 #define ELIMINABLE_REGS \
321 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
322 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM }, \
323 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }}
325 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
326 (OFFSET) = rl78_initial_elimination_offset ((FROM), (TO))
329 #define FUNCTION_ARG_REGNO_P(N) 0
330 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 8)
331 #define DEFAULT_PCC_STRUCT_RETURN 0
333 #define FIXED_REGISTERS \
342 #define CALL_USED_REGISTERS \
351 #define LIBCALL_VALUE(MODE) \
352 gen_rtx_REG ((MODE), \
355 /* Order of allocation of registers. */
357 #define REG_ALLOC_ORDER \
358 { 8, 9, 10, 11, 12, 13, 14, 15, \
359 16, 17, 18, 19, 20, 21, 22, 23, \
360 0, 1, 6, 7, 2, 3, 4, 5, \
361 24, 25, 26, 27, 28, 29, 30, 31, \
365 #define REGNO_IN_RANGE(REGNO, MIN, MAX) \
366 (IN_RANGE ((REGNO), (MIN), (MAX)) \
367 || (reg_renumber != NULL \
368 && reg_renumber[(REGNO)] >= (MIN) \
369 && reg_renumber[(REGNO)] <= (MAX)))
372 #define REGNO_OK_FOR_BASE_P(regno) REGNO_IN_RANGE (regno, 16, 31)
374 #define REGNO_OK_FOR_BASE_P(regno) 1
377 #define REGNO_OK_FOR_INDEX_P(regno) REGNO_OK_FOR_BASE_P (regno)
379 #define REGNO_MODE_CODE_OK_FOR_BASE_P(regno, mode, address_space, outer_code, index_code) \
380 rl78_regno_mode_code_ok_for_base_p (regno, mode, address_space, outer_code, index_code)
382 #define MODE_CODE_BASE_REG_CLASS(mode, address_space, outer_code, index_code) \
383 rl78_mode_code_base_reg_class (mode, address_space, outer_code, index_code)
385 #define RETURN_ADDR_RTX(COUNT, FRAMEADDR) \
387 ? gen_rtx_MEM (Pmode, gen_rtx_PLUS (HImode, arg_pointer_rtx, GEN_INT (-4))) \
390 #define INCOMING_RETURN_ADDR_RTX gen_rtx_MEM (Pmode, stack_pointer_rtx)
392 #define ACCUMULATE_OUTGOING_ARGS 1
394 typedef unsigned int CUMULATIVE_ARGS
;
396 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
401 #define NO_PROFILE_COUNTERS 1
402 #define PROFILE_BEFORE_PROLOGUE 1
404 #define FUNCTION_PROFILER(FILE, LABELNO) \
405 fprintf (FILE, "\tbsr\t__mcount\n");
408 #define TEXT_SECTION_ASM_OP ".text"
409 #define DATA_SECTION_ASM_OP ".data"
410 #define BSS_SECTION_ASM_OP ".bss"
411 #define CTORS_SECTION_ASM_OP ".section \".ctors\",\"a\""
412 #define DTORS_SECTION_ASM_OP ".section \".dtors\",\"a\""
414 #define ASM_COMMENT_START " ;"
415 #define ASM_APP_ON ""
416 #define ASM_APP_OFF ""
417 #define LOCAL_LABEL_PREFIX ".L"
418 #undef USER_LABEL_PREFIX
419 #define USER_LABEL_PREFIX "_"
421 #define GLOBAL_ASM_OP "\t.global\t"
423 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
424 fprintf (FILE, "\t.long .L%d\n", VALUE)
426 /* This is how to output an element of a case-vector that is relative.
427 Note: The local label referenced by the "3b" below is emitted by
428 the tablejump insn. */
430 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
431 fprintf (FILE, "\t.long .L%d - 1b\n", VALUE)
434 #define ASM_OUTPUT_SYMBOL_REF(FILE, SYM) rl78_output_symbol_ref ((FILE), (SYM))
436 #define ASM_OUTPUT_LABELREF(FILE, SYM) rl78_output_labelref ((FILE), (SYM))
438 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
439 rl78_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 1)
441 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
442 rl78_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
444 #define ASM_OUTPUT_ALIGN(STREAM, LOG) \
449 fprintf (STREAM, "\t.balign %d\n", 1 << (LOG)); \
453 /* For PIC put jump tables into the text section so that the offsets that
454 they contain are always computed between two same-section symbols. */
455 #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
457 /* This is a version of REG_P that also returns TRUE for SUBREGs. */
458 #define RL78_REG_P(rtl) (REG_P (rtl) || GET_CODE (rtl) == SUBREG)
460 /* Like REG_P except that this macro is true for SET expressions. */
461 #define SET_P(rtl) (GET_CODE (rtl) == SET)
463 #undef PREFERRED_DEBUGGING_TYPE
464 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
466 #undef DWARF2_ADDR_SIZE
467 #define DWARF2_ADDR_SIZE 4
469 #define DWARF2_ASM_LINE_DEBUG_INFO 1
471 #define EXIT_IGNORE_STACK 0
472 #define INCOMING_FRAME_SP_OFFSET 4
475 #define BRANCH_COST(SPEED,PREDICT) 1
476 #define REGISTER_MOVE_COST(MODE,FROM,TO) 2
478 #define EH_RETURN_DATA_REGNO(N) (N < 2 ? (8+(N)*2) : INVALID_REGNUM)
479 #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (HImode, 20)
481 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) DW_EH_PE_udata4
483 /* NOTE: defined but zero means dwarf2 debugging, but sjlj EH. */
484 #define DWARF2_UNWIND_INFO 0
486 #define REGISTER_TARGET_PRAGMAS() rl78_register_pragmas()