Debian Codegraph @

gcc/config/stormy16/stormy16.h

raw
1 /* Xstormy16 cpu description.
2 Copyright (C) 1997-2025 Free Software Foundation, Inc.
3 Contributed by Red Hat, Inc.
4
5 This file is part of GCC.
6
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.
11
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.
16
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/>. */
20
21
22 /* Driver configuration. */
23
24 #undef ASM_SPEC
25 #define ASM_SPEC ""
26
27 #undef LINK_SPEC
28 #define LINK_SPEC "%{h*} %{v:-V} \
29 %{static:-Bstatic} %{shared:-shared} %{symbolic:-Bsymbolic}"
30
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}} -)"
39
40 #undef STARTFILE_SPEC
41 #define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s"
42
43 #undef ENDFILE_SPEC
44 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
45
46
47 /* Run-time target specifications. */
48
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)
57
58 /* Storage Layout. */
59
60 #define BITS_BIG_ENDIAN 1
61
62 #define BYTES_BIG_ENDIAN 0
63
64 #define WORDS_BIG_ENDIAN 0
65
66 #define UNITS_PER_WORD 2
67
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)
76
77 #define PARM_BOUNDARY 16
78
79 #define STACK_BOUNDARY 16
80
81 #define FUNCTION_BOUNDARY 16
82
83 #define BIGGEST_ALIGNMENT 16
84
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))
89
90 #define STRICT_ALIGNMENT 1
91
92 #define PCC_BITFIELD_TYPE_MATTERS 1
93
94 /* Layout of Source Language Data Types. */
95
96 #define INT_TYPE_SIZE 16
97
98 #define SHORT_TYPE_SIZE 16
99
100 #define LONG_TYPE_SIZE 32
101
102 #define LONG_LONG_TYPE_SIZE 64
103
104 #define DEFAULT_SIGNED_CHAR 0
105
106 #define SIZE_TYPE "unsigned int"
107
108 #define PTRDIFF_TYPE "int"
109
110 #undef WCHAR_TYPE
111 #define WCHAR_TYPE "long int"
112
113 #undef WCHAR_TYPE_SIZE
114 #define WCHAR_TYPE_SIZE 32
115
116
117 /* Register Basics. */
118
119 #define FIRST_PSEUDO_REGISTER 19
120
121 #define FIXED_REGISTERS \
122 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1 }
123
124 #define CALL_USED_REGISTERS \
125 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1 }
126
127
128 /* Order of allocation of registers. */
129
130 #define REG_ALLOC_ORDER { 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 10, 11, 12, 13, 14, 15, 16 }
131
132
133 /* Register Classes. */
134
135 enum reg_class
136 {
137 NO_REGS,
138 R0_REGS,
139 R1_REGS,
140 TWO_REGS,
141 R2_REGS,
142 EIGHT_REGS,
143 R8_REGS,
144 ICALL_REGS,
145 GENERAL_REGS,
146 ALL_REGS,
147 LIM_REG_CLASSES
148 };
149
150 #define N_REG_CLASSES ((int) LIM_REG_CLASSES)
151
152 #define REG_CLASS_NAMES \
153 { \
154 "NO_REGS", \
155 "R0_REGS", \
156 "R1_REGS", \
157 "TWO_REGS", \
158 "R2_REGS", \
159 "EIGHT_REGS", \
160 "R8_REGS", \
161 "ICALL_REGS", \
162 "GENERAL_REGS", \
163 "ALL_REGS" \
164 }
165
166 #define REG_CLASS_CONTENTS \
167 { \
168 { 0x00000 }, \
169 { 0x00001 }, \
170 { 0x00002 }, \
171 { 0x00003 }, \
172 { 0x00004 }, \
173 { 0x000FF }, \
174 { 0x00100 }, \
175 { 0x00300 }, \
176 { 0x6FFFF }, \
177 { (1 << FIRST_PSEUDO_REGISTER) - 1 } \
178 }
179
180 #define REGNO_REG_CLASS(REGNO) \
181 ( (REGNO) == 0 ? R0_REGS \
182 : (REGNO) == 1 ? R1_REGS \
183 : (REGNO) == 2 ? R2_REGS \
184 : (REGNO) < 8 ? EIGHT_REGS \
185 : (REGNO) == 8 ? R8_REGS \
186 : (REGNO) <= 18 ? GENERAL_REGS \
187 : ALL_REGS)
188
189 #define BASE_REG_CLASS GENERAL_REGS
190
191 #define INDEX_REG_CLASS GENERAL_REGS
192
193 #define REGNO_OK_FOR_BASE_P(NUM) 1
194
195 #define REGNO_OK_FOR_INDEX_P(NUM) REGNO_OK_FOR_BASE_P (NUM)
196
197 /* This chip has the interesting property that only the first eight
198 registers can be moved to/from memory. */
199 #define SECONDARY_RELOAD_CLASS(CLASS, MODE, X) \
200 xstormy16_secondary_reload_class (CLASS, MODE, X)
201
202
203 /* Basic Stack Layout. */
204
205 /* We want to use post-increment instructions to push things on the stack,
206 because we don't have any pre-increment ones. */
207 #define STACK_PUSH_CODE POST_INC
208
209 #define FRAME_GROWS_DOWNWARD 0
210
211 #define ARGS_GROW_DOWNWARD 1
212
213 #define FIRST_PARM_OFFSET(FUNDECL) 0
214
215 #define RETURN_ADDR_RTX(COUNT, FRAMEADDR) \
216 ((COUNT) == 0 \
217 ? gen_rtx_MEM (Pmode, arg_pointer_rtx) \
218 : NULL_RTX)
219
220 #define INCOMING_RETURN_ADDR_RTX \
221 gen_rtx_MEM (SImode, gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (-4)))
222
223 #define INCOMING_FRAME_SP_OFFSET (xstormy16_interrupt_function_p () ? -6 : -4)
224
225 #define DEFAULT_INCOMING_FRAME_SP_OFFSET -4
226
227 /* Register That Address the Stack Frame. */
228
229 #define STATIC_CHAIN_REGNUM 1
230 #define HARD_FRAME_POINTER_REGNUM 13
231 #define STACK_POINTER_REGNUM 15
232 #define CARRY_REGNUM 16
233 #define FRAME_POINTER_REGNUM 17
234 #define ARG_POINTER_REGNUM 18
235
236
237 /* Eliminating the Frame Pointer and the Arg Pointer. */
238
239 #define ELIMINABLE_REGS \
240 { \
241 {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
242 {FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
243 {ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
244 {ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
245 }
246
247 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
248 (OFFSET) = xstormy16_initial_elimination_offset (FROM, TO)
249
250
251 /* Passing Function Arguments on the Stack. */
252
253 #define PUSH_ROUNDING(BYTES) xstormy16_push_rounding (BYTES)
254
255
256 /* Function Arguments in Registers. */
257
258 #define NUM_ARGUMENT_REGISTERS 6
259 #define FIRST_ARGUMENT_REGISTER 2
260
261 #define XSTORMY16_WORD_SIZE(TYPE, MODE) \
262 ((((TYPE) ? int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE)) \
263 + 1) \
264 / 2)
265
266 /* For this platform, the value of CUMULATIVE_ARGS is the number of words
267 of arguments that have been passed in registers so far. */
268 #define CUMULATIVE_ARGS int
269
270 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
271 (CUM) = 0
272
273 #define FUNCTION_ARG_REGNO_P(REGNO) \
274 ((REGNO) >= FIRST_ARGUMENT_REGISTER \
275 && (REGNO) < FIRST_ARGUMENT_REGISTER + NUM_ARGUMENT_REGISTERS)
276
277
278 /* How Scalar Function Values are Returned. */
279
280 /* The number of the hard register that is used to return a scalar value from a
281 function call. */
282 #define RETURN_VALUE_REGNUM FIRST_ARGUMENT_REGISTER
283
284
285 /* Function Entry and Exit. */
286
287 #define EPILOGUE_USES(REGNO) \
288 xstormy16_epilogue_uses (REGNO)
289
290
291 /* Generating Code for Profiling. */
292
293 /* This declaration must be present, but it can be an abort if profiling is
294 not implemented. */
295
296 #define FUNCTION_PROFILER(FILE, LABELNO) xstormy16_function_profiler ()
297
298
299 /* Trampolines for Nested Functions. */
300
301 #define TRAMPOLINE_SIZE 8
302 #define TRAMPOLINE_ALIGNMENT 16
303
304
305 /* Addressing Modes. */
306
307 #define HAVE_POST_INCREMENT 1
308
309 #define HAVE_PRE_DECREMENT 1
310
311 #define MAX_REGS_PER_ADDRESS 1
312
313
314 /* Describing Relative Costs of Operations. */
315
316 #define BRANCH_COST(speed_p, predictable_p) 5
317
318 #define SLOW_BYTE_ACCESS 0
319
320 #define NO_FUNCTION_CSE 1
321
322
323 /* Dividing the output into sections. */
324
325 #define TEXT_SECTION_ASM_OP ".text"
326
327 #define DATA_SECTION_ASM_OP ".data"
328
329 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
330
331 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
332 There are no shared libraries on this target so these sections need
333 not be writable.
334
335 Defined in elfos.h. */
336
337 #undef CTORS_SECTION_ASM_OP
338 #undef DTORS_SECTION_ASM_OP
339 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"a\""
340 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"a\""
341
342 #define TARGET_ASM_INIT_SECTIONS xstormy16_asm_init_sections
343
344 #define JUMP_TABLES_IN_TEXT_SECTION 1
345
346 /* The Overall Framework of an Assembler File. */
347
348 #define ASM_COMMENT_START ";"
349
350 #define ASM_APP_ON "#APP\n"
351
352 #define ASM_APP_OFF "#NO_APP\n"
353
354 /* Output of Data. */
355
356 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C, STR) ((C) == '|')
357
358 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
359 xstormy16_asm_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 1)
360 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
361 xstormy16_asm_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
362
363
364 /* Output and Generation of Labels. */
365 #define SYMBOL_FLAG_XSTORMY16_BELOW100 (SYMBOL_FLAG_MACH_DEP << 0)
366
367 #define ASM_OUTPUT_SYMBOL_REF(STREAM, SYMBOL) \
368 do \
369 { \
370 const char *rn = XSTR (SYMBOL, 0); \
371 \
372 if (SYMBOL_REF_FUNCTION_P (SYMBOL)) \
373 ASM_OUTPUT_LABEL_REF ((STREAM), rn); \
374 else \
375 assemble_name (STREAM, rn); \
376 } \
377 while (0)
378
379 #define ASM_OUTPUT_LABEL_REF(STREAM, NAME) \
380 do \
381 { \
382 fputs ("@fptr(", STREAM); \
383 assemble_name (STREAM, NAME); \
384 fputc (')', STREAM); \
385 } \
386 while (0)
387
388 /* Globalizing directive for a label. */
389 #define GLOBAL_ASM_OP "\t.globl "
390
391
392 /* Output of Assembler Instructions. */
393
394 #define REGISTER_NAMES \
395 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \
396 "r11", "r12", "r13", "psw", "sp", "carry", "fp", "ap" }
397
398 #define ADDITIONAL_REGISTER_NAMES \
399 { { "r14", 14 }, \
400 { "r15", 15 } }
401
402 #define REGISTER_PREFIX ""
403 #define LOCAL_LABEL_PREFIX "."
404 #define USER_LABEL_PREFIX ""
405 #define IMMEDIATE_PREFIX "#"
406
407 #define ASM_OUTPUT_REG_PUSH(STREAM, REGNO) \
408 fprintf (STREAM, "\tpush %d\n", REGNO)
409
410 #define ASM_OUTPUT_REG_POP(STREAM, REGNO) \
411 fprintf (STREAM, "\tpop %d\n", REGNO)
412
413
414 /* Output of dispatch tables. */
415
416 /* This port does not use the ASM_OUTPUT_ADDR_VEC_ELT macro, because
417 this could cause label alignment to appear between the 'br' and the table,
418 which would be bad. Instead, it controls the output of the table
419 itself. */
420 #define ASM_OUTPUT_ADDR_VEC(LABEL, BODY) \
421 xstormy16_output_addr_vec (file, LABEL, BODY)
422
423 /* Alignment for ADDR_VECs is the same as for code. */
424 #define ADDR_VEC_ALIGN(ADDR_VEC) 1
425
426
427 /* Assembler Commands for Exception Regions. */
428
429 #define DWARF2_UNWIND_INFO 0
430 #define DWARF_CIE_DATA_ALIGNMENT 1
431
432 /* Assembler Commands for Alignment. */
433
434 #define ASM_OUTPUT_ALIGN(STREAM, POWER) \
435 fprintf ((STREAM), "\t.p2align %d\n", (POWER))
436
437
438 /* Macros Affecting all Debug Formats. */
439
440 #undef PREFERRED_DEBUGGING_TYPE
441 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
442
443
444 /* Macros for Dwarf Output. */
445
446 /* Define this macro if addresses in Dwarf 2 debugging info should not
447 be the same size as pointers on the target architecture. The
448 macro's value should be the size, in bytes, to use for addresses in
449 the debugging info.
450
451 Some architectures use word addresses to refer to code locations,
452 but Dwarf 2 info always uses byte addresses. On such machines,
453 Dwarf 2 addresses need to be larger than the architecture's
454 pointers. */
455 #define DWARF2_ADDR_SIZE 4
456
457
458 /* Miscellaneous Parameters. */
459
460 #define CASE_VECTOR_MODE SImode
461
462 #define WORD_REGISTER_OPERATIONS 1
463
464 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
465
466 #define MOVE_MAX 2
467
468 #define SHIFT_COUNT_TRUNCATED 1
469
470 #define Pmode HImode
471
472 #define FUNCTION_MODE HImode