Turn SLOW_UNALIGNED_ACCESS into a target hook
[official-gcc.git] / gcc / config / stormy16 / stormy16.h
blob6e43fbe59c46cea37a78475f8189158f3cbdf3a9
1 /* Xstormy16 cpu description.
2 Copyright (C) 1997-2017 Free Software Foundation, Inc.
3 Contributed by Red Hat, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public 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 /* Driver configuration. */
24 #undef ASM_SPEC
25 #define ASM_SPEC ""
27 #undef LINK_SPEC
28 #define LINK_SPEC "%{h*} %{v:-V} \
29 %{static:-Bstatic} %{shared:-shared} %{symbolic:-Bsymbolic}"
31 /* For xstormy16:
32 - If -msim is specified, everything is built and linked as for the sim.
33 - If -T is specified, that linker script is used, and it should provide
34 appropriate libraries.
35 - If neither is specified, everything is built as for the sim, but no
36 I/O support is assumed. */
37 #undef LIB_SPEC
38 #define LIB_SPEC "-( -lc %{msim:-lsim}%{!msim:%{!T*:-lnosys}} -)"
40 #undef STARTFILE_SPEC
41 #define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s"
43 #undef ENDFILE_SPEC
44 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
47 /* Run-time target specifications. */
49 #define TARGET_CPU_CPP_BUILTINS() \
50 do \
51 { \
52 builtin_define_std ("xstormy16"); \
53 builtin_assert ("machine=xstormy16"); \
54 builtin_assert ("cpu=xstormy16"); \
55 } \
56 while (0)
58 /* Storage Layout. */
60 #define BITS_BIG_ENDIAN 1
62 #define BYTES_BIG_ENDIAN 0
64 #define WORDS_BIG_ENDIAN 0
66 #define UNITS_PER_WORD 2
68 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
69 do \
70 { \
71 if (GET_MODE_CLASS (MODE) == MODE_INT \
72 && GET_MODE_SIZE (MODE) < 2) \
73 (MODE) = HImode; \
74 } \
75 while (0)
77 #define PARM_BOUNDARY 16
79 #define STACK_BOUNDARY 16
81 #define FUNCTION_BOUNDARY 16
83 #define BIGGEST_ALIGNMENT 16
85 #define DATA_ALIGNMENT(TYPE, ALIGN) \
86 (TREE_CODE (TYPE) == ARRAY_TYPE \
87 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
88 && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
90 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
91 (TREE_CODE (EXP) == STRING_CST \
92 && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
94 #define STRICT_ALIGNMENT 1
96 #define PCC_BITFIELD_TYPE_MATTERS 1
98 /* Layout of Source Language Data Types. */
100 #define INT_TYPE_SIZE 16
102 #define SHORT_TYPE_SIZE 16
104 #define LONG_TYPE_SIZE 32
106 #define LONG_LONG_TYPE_SIZE 64
108 #define FLOAT_TYPE_SIZE 32
110 #define DOUBLE_TYPE_SIZE 64
112 #define LONG_DOUBLE_TYPE_SIZE 64
114 #define DEFAULT_SIGNED_CHAR 0
116 #define SIZE_TYPE "unsigned int"
118 #define PTRDIFF_TYPE "int"
120 #undef WCHAR_TYPE
121 #define WCHAR_TYPE "long int"
123 #undef WCHAR_TYPE_SIZE
124 #define WCHAR_TYPE_SIZE 32
127 /* Register Basics. */
129 #define FIRST_PSEUDO_REGISTER 19
131 #define FIXED_REGISTERS \
132 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1 }
134 #define CALL_USED_REGISTERS \
135 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1 }
138 /* Order of allocation of registers. */
140 #define REG_ALLOC_ORDER { 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 10, 11, 12, 13, 14, 15, 16 }
143 /* How Values Fit in Registers. */
145 #define HARD_REGNO_NREGS(REGNO, MODE) \
146 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
149 /* Register Classes. */
151 enum reg_class
153 NO_REGS,
154 R0_REGS,
155 R1_REGS,
156 TWO_REGS,
157 R2_REGS,
158 EIGHT_REGS,
159 R8_REGS,
160 ICALL_REGS,
161 GENERAL_REGS,
162 ALL_REGS,
163 LIM_REG_CLASSES
166 #define N_REG_CLASSES ((int) LIM_REG_CLASSES)
168 #define REG_CLASS_NAMES \
170 "NO_REGS", \
171 "R0_REGS", \
172 "R1_REGS", \
173 "TWO_REGS", \
174 "R2_REGS", \
175 "EIGHT_REGS", \
176 "R8_REGS", \
177 "ICALL_REGS", \
178 "GENERAL_REGS", \
179 "ALL_REGS" \
182 #define REG_CLASS_CONTENTS \
184 { 0x00000 }, \
185 { 0x00001 }, \
186 { 0x00002 }, \
187 { 0x00003 }, \
188 { 0x00004 }, \
189 { 0x000FF }, \
190 { 0x00100 }, \
191 { 0x00300 }, \
192 { 0x6FFFF }, \
193 { (1 << FIRST_PSEUDO_REGISTER) - 1 } \
196 #define REGNO_REG_CLASS(REGNO) \
197 ( (REGNO) == 0 ? R0_REGS \
198 : (REGNO) == 1 ? R1_REGS \
199 : (REGNO) == 2 ? R2_REGS \
200 : (REGNO) < 8 ? EIGHT_REGS \
201 : (REGNO) == 8 ? R8_REGS \
202 : (REGNO) <= 18 ? GENERAL_REGS \
203 : ALL_REGS)
205 #define BASE_REG_CLASS GENERAL_REGS
207 #define INDEX_REG_CLASS GENERAL_REGS
209 #define REGNO_OK_FOR_BASE_P(NUM) 1
211 #define REGNO_OK_FOR_INDEX_P(NUM) REGNO_OK_FOR_BASE_P (NUM)
213 /* This chip has the interesting property that only the first eight
214 registers can be moved to/from memory. */
215 #define SECONDARY_RELOAD_CLASS(CLASS, MODE, X) \
216 xstormy16_secondary_reload_class (CLASS, MODE, X)
219 /* Basic Stack Layout. */
221 /* We want to use post-increment instructions to push things on the stack,
222 because we don't have any pre-increment ones. */
223 #define STACK_PUSH_CODE POST_INC
225 #define FRAME_GROWS_DOWNWARD 0
227 #define ARGS_GROW_DOWNWARD 1
229 #define STARTING_FRAME_OFFSET 0
231 #define FIRST_PARM_OFFSET(FUNDECL) 0
233 #define RETURN_ADDR_RTX(COUNT, FRAMEADDR) \
234 ((COUNT) == 0 \
235 ? gen_rtx_MEM (Pmode, arg_pointer_rtx) \
236 : NULL_RTX)
238 #define INCOMING_RETURN_ADDR_RTX \
239 gen_rtx_MEM (SImode, gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (-4)))
241 #define INCOMING_FRAME_SP_OFFSET (xstormy16_interrupt_function_p () ? -6 : -4)
244 /* Register That Address the Stack Frame. */
246 #define STATIC_CHAIN_REGNUM 1
247 #define HARD_FRAME_POINTER_REGNUM 13
248 #define STACK_POINTER_REGNUM 15
249 #define CARRY_REGNUM 16
250 #define FRAME_POINTER_REGNUM 17
251 #define ARG_POINTER_REGNUM 18
254 /* Eliminating the Frame Pointer and the Arg Pointer. */
256 #define ELIMINABLE_REGS \
258 {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
259 {FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
260 {ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
261 {ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
264 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
265 (OFFSET) = xstormy16_initial_elimination_offset (FROM, TO)
268 /* Passing Function Arguments on the Stack. */
270 #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
273 /* Function Arguments in Registers. */
275 #define NUM_ARGUMENT_REGISTERS 6
276 #define FIRST_ARGUMENT_REGISTER 2
278 #define XSTORMY16_WORD_SIZE(TYPE, MODE) \
279 ((((TYPE) ? int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE)) \
280 + 1) \
281 / 2)
283 /* For this platform, the value of CUMULATIVE_ARGS is the number of words
284 of arguments that have been passed in registers so far. */
285 #define CUMULATIVE_ARGS int
287 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
288 (CUM) = 0
290 #define FUNCTION_ARG_REGNO_P(REGNO) \
291 ((REGNO) >= FIRST_ARGUMENT_REGISTER \
292 && (REGNO) < FIRST_ARGUMENT_REGISTER + NUM_ARGUMENT_REGISTERS)
295 /* How Scalar Function Values are Returned. */
297 /* The number of the hard register that is used to return a scalar value from a
298 function call. */
299 #define RETURN_VALUE_REGNUM FIRST_ARGUMENT_REGISTER
302 /* Function Entry and Exit. */
304 #define EPILOGUE_USES(REGNO) \
305 xstormy16_epilogue_uses (REGNO)
308 /* Generating Code for Profiling. */
310 /* This declaration must be present, but it can be an abort if profiling is
311 not implemented. */
313 #define FUNCTION_PROFILER(FILE, LABELNO) xstormy16_function_profiler ()
316 /* Trampolines for Nested Functions. */
318 #define TRAMPOLINE_SIZE 8
319 #define TRAMPOLINE_ALIGNMENT 16
322 /* Addressing Modes. */
324 #define HAVE_POST_INCREMENT 1
326 #define HAVE_PRE_DECREMENT 1
328 #define MAX_REGS_PER_ADDRESS 1
331 /* Describing Relative Costs of Operations. */
333 #define BRANCH_COST(speed_p, predictable_p) 5
335 #define SLOW_BYTE_ACCESS 0
337 #define NO_FUNCTION_CSE 1
340 /* Dividing the output into sections. */
342 #define TEXT_SECTION_ASM_OP ".text"
344 #define DATA_SECTION_ASM_OP ".data"
346 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
348 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
349 There are no shared libraries on this target so these sections need
350 not be writable.
352 Defined in elfos.h. */
354 #undef CTORS_SECTION_ASM_OP
355 #undef DTORS_SECTION_ASM_OP
356 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"a\""
357 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"a\""
359 #define TARGET_ASM_INIT_SECTIONS xstormy16_asm_init_sections
361 #define JUMP_TABLES_IN_TEXT_SECTION 1
363 /* The Overall Framework of an Assembler File. */
365 #define ASM_COMMENT_START ";"
367 #define ASM_APP_ON "#APP\n"
369 #define ASM_APP_OFF "#NO_APP\n"
371 /* Output of Data. */
373 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C, STR) ((C) == '|')
375 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
376 xstormy16_asm_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 1)
377 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
378 xstormy16_asm_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
381 /* Output and Generation of Labels. */
382 #define SYMBOL_FLAG_XSTORMY16_BELOW100 (SYMBOL_FLAG_MACH_DEP << 0)
384 #define ASM_OUTPUT_SYMBOL_REF(STREAM, SYMBOL) \
385 do \
387 const char *rn = XSTR (SYMBOL, 0); \
389 if (SYMBOL_REF_FUNCTION_P (SYMBOL)) \
390 ASM_OUTPUT_LABEL_REF ((STREAM), rn); \
391 else \
392 assemble_name (STREAM, rn); \
394 while (0)
396 #define ASM_OUTPUT_LABEL_REF(STREAM, NAME) \
397 do \
399 fputs ("@fptr(", STREAM); \
400 assemble_name (STREAM, NAME); \
401 fputc (')', STREAM); \
403 while (0)
405 /* Globalizing directive for a label. */
406 #define GLOBAL_ASM_OP "\t.globl "
409 /* Output of Assembler Instructions. */
411 #define REGISTER_NAMES \
412 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \
413 "r11", "r12", "r13", "psw", "sp", "carry", "fp", "ap" }
415 #define ADDITIONAL_REGISTER_NAMES \
416 { { "r14", 14 }, \
417 { "r15", 15 } }
419 #define REGISTER_PREFIX ""
420 #define LOCAL_LABEL_PREFIX "."
421 #define USER_LABEL_PREFIX ""
422 #define IMMEDIATE_PREFIX "#"
424 #define ASM_OUTPUT_REG_PUSH(STREAM, REGNO) \
425 fprintf (STREAM, "\tpush %d\n", REGNO)
427 #define ASM_OUTPUT_REG_POP(STREAM, REGNO) \
428 fprintf (STREAM, "\tpop %d\n", REGNO)
431 /* Output of dispatch tables. */
433 /* This port does not use the ASM_OUTPUT_ADDR_VEC_ELT macro, because
434 this could cause label alignment to appear between the 'br' and the table,
435 which would be bad. Instead, it controls the output of the table
436 itself. */
437 #define ASM_OUTPUT_ADDR_VEC(LABEL, BODY) \
438 xstormy16_output_addr_vec (file, LABEL, BODY)
440 /* Alignment for ADDR_VECs is the same as for code. */
441 #define ADDR_VEC_ALIGN(ADDR_VEC) 1
444 /* Assembler Commands for Exception Regions. */
446 #define DWARF2_UNWIND_INFO 0
447 #define DWARF_CIE_DATA_ALIGNMENT 1
449 /* Assembler Commands for Alignment. */
451 #define ASM_OUTPUT_ALIGN(STREAM, POWER) \
452 fprintf ((STREAM), "\t.p2align %d\n", (POWER))
455 /* Macros Affecting all Debug Formats. */
457 #undef PREFERRED_DEBUGGING_TYPE
458 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
461 /* Macros for SDB and Dwarf Output. */
463 /* Define this macro if addresses in Dwarf 2 debugging info should not
464 be the same size as pointers on the target architecture. The
465 macro's value should be the size, in bytes, to use for addresses in
466 the debugging info.
468 Some architectures use word addresses to refer to code locations,
469 but Dwarf 2 info always uses byte addresses. On such machines,
470 Dwarf 2 addresses need to be larger than the architecture's
471 pointers. */
472 #define DWARF2_ADDR_SIZE 4
475 /* Miscellaneous Parameters. */
477 #define CASE_VECTOR_MODE SImode
479 #define WORD_REGISTER_OPERATIONS 1
481 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
483 #define MOVE_MAX 2
485 #define SHIFT_COUNT_TRUNCATED 1
487 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
489 #define Pmode HImode
491 #define FUNCTION_MODE HImode
493 #define NO_IMPLICIT_EXTERN_C