]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/or1k/or1k.h
Update copyright years.
[thirdparty/gcc.git] / gcc / config / or1k / or1k.h
CommitLineData
3965b35f 1/* Target Definitions for OpenRISC.
8d9254fc 2 Copyright (C) 2018-2020 Free Software Foundation, Inc.
3965b35f
SH
3 Contributed by Stafford Horne.
4
5 This file is part of GCC.
6
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.
11
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.
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#ifndef GCC_OR1K_H
22#define GCC_OR1K_H
23
24/* Names to predefine in the preprocessor for this target machine. */
25#define TARGET_CPU_CPP_BUILTINS() \
26 do \
27 { \
28 builtin_define ("__OR1K__"); \
29 builtin_define ("__OR1K_DELAY__"); \
30 builtin_define ("__or1k__"); \
31 if (TARGET_CMOV) \
32 builtin_define ("__or1k_cmov__"); \
33 builtin_assert ("cpu=or1k"); \
34 builtin_assert ("machine=or1k"); \
35 } \
36 while (0)
37
38/* Storage layout. */
39
40#define DEFAULT_SIGNED_CHAR 1
41#define BITS_BIG_ENDIAN 0
42#define BYTES_BIG_ENDIAN 1
43#define WORDS_BIG_ENDIAN 1
44#define BITS_PER_WORD 32
45#define UNITS_PER_WORD 4
46#define POINTER_SIZE 32
47#define BIGGEST_ALIGNMENT 32
48#define STRICT_ALIGNMENT 1
49#define FUNCTION_BOUNDARY 32
50#define PARM_BOUNDARY 32
51#define STACK_BOUNDARY 32
52#define PREFERRED_STACK_BOUNDARY 32
53#define MAX_FIXED_MODE_SIZE 64
54
55/* Layout of source language data types. */
56
57#define INT_TYPE_SIZE 32
58#define SHORT_TYPE_SIZE 16
59#define LONG_TYPE_SIZE 32
60#define LONG_LONG_TYPE_SIZE 64
61#define FLOAT_TYPE_SIZE 32
62#define DOUBLE_TYPE_SIZE 64
63#define LONG_DOUBLE_TYPE_SIZE 64
64#define WCHAR_TYPE_SIZE 32
65
66#undef SIZE_TYPE
67#define SIZE_TYPE "unsigned int"
68
69#undef PTRDIFF_TYPE
70#define PTRDIFF_TYPE "int"
71
72#undef WCHAR_TYPE
73#define WCHAR_TYPE "unsigned int"
74
75/* Describing Relative Costs of Operations. */
76#define MOVE_MAX 4
77#define SLOW_BYTE_ACCESS 1
78
79/* Register usage, class and contents. */
80
81/* In OpenRISC there are 32 general purpose registers with the following
82 designations:
83
84 r0 always 0
85 r1 stack pointer
86 r2 frame pointer (optional)
87 r3 arg 0
88 r4 arg 1
89 r5 arg 2
90 r6 arg 3
91 r7 arg 4
92 r8 arg 5
93 r9 function call return link address
94 r10 thread local storage
95 r11 function return value & static chain
96 r12 function return value high (upper 64-bit)
97 r13 temporary (used in prologue and epilogue)
98 r14 callee saved
99 r15 temporary
100 r16 callee saved & pic base register
101 r17 temporary
102 r18 callee saved
103 r19 temporary
104 r20 callee saved
105 r21 temporary
106 r22 callee saved
107 r23 temporary
108 r24 callee saved
109 r25 temporary
110 r26 callee saved
111 r27 temporary
112 r28 callee saved
113 r29 temporary
114 r30 callee saved
115 r31 temporary
116
117 r32 soft argument pointer
118 r33 soft frame pointer
119 r34 SR[F] (bit) register
120
121 This ABI has no adjacent call-saved register, which means that
122 DImode/DFmode pseudos cannot be call-saved and will always be
123 spilled across calls. To solve this without changing the ABI,
124 remap the compiler internal register numbers to place the even
125 call-saved registers r16-r30 in 24-31, and the odd call-clobbered
126 registers r17-r31 in 16-23. */
127
128#define FIRST_PSEUDO_REGISTER 35
129
130#define HW_TO_GCC_REGNO(X) \
131 ((X) < 16 || (X) > 31 ? (X) \
132 : (X) & 1 ? ((X) - 16) / 2 + 16 \
133 : ((X) - 16) / 2 + 24)
134
135#define GCC_TO_HW_REGNO(X) \
136 ((X) < 16 || (X) > 31 ? (X) \
137 : (X) < 24 ? ((X) - 16) * 2 + 17 \
138 : ((X) - 24) * 2 + 16)
139
140#define DBX_REGISTER_NUMBER(X) GCC_TO_HW_REGNO(X)
141
142#define REGISTER_NAMES { \
143 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
144 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
145 "r17", "r19", "r21", "r23", "r25", "r27", "r29", "r31", \
146 "r16", "r18", "r20", "r22", "r24", "r26", "r28", "r30", \
147 "?ap", "?fp", "?sr_f" }
148
149#define FIXED_REGISTERS \
150{ 1, 1, 0, 0, 0, 0, 0, 0, \
151 0, 0, 1, 0, 0, 0, 0, 0, \
152 0, 0, 0, 0, 0, 0, 0, 0, \
153 0, 0, 0, 0, 0, 0, 0, 0, \
154 1, 1, 1 }
155
156/* Caller saved/temporary registers + args + fixed */
157#define CALL_USED_REGISTERS \
158{ 1, 1, 0, 1, 1, 1, 1, 1, \
159 1, 1, 1, 1, 1, 1, 0, 1, \
160 1, 1, 1, 1, 1, 1, 1, 1, \
161 0, 0, 0, 0, 0, 0, 0, 0, \
162 1, 1, 1 }
163
164/* List the order in which to allocate registers. Each register must
165 be listed once, even those in FIXED_REGISTERS.
166
167 ??? Note that placing REAL_PIC_OFFSET_TABLE_REGNUM (r16 = 24) first
168 happens to make it most likely selected *as* the pic register when
169 compiling without optimization, simply because the pic pseudo happens
170 to be allocated with the lowest pseudo regno. */
171
172#define REG_ALLOC_ORDER { \
173 16, 17, 18, 19, 20, 21, 22, 23, /* r17-r31 (odd), non-saved */ \
174 13, 15, /* non-saved */ \
175 12, 11, /* non-saved return values */ \
176 8, 7, 6, 5, 4, 3, /* non-saved argument regs */ \
177 24, /* r16, saved, pic reg */ \
178 25, 26, 27, 28, 29, 30, 31, /* r18-r31 (even), saved */ \
179 14, /* r14, saved */ \
180 2, /* saved hard frame pointer */ \
181 9, /* saved return address */ \
182 0, /* fixed zero reg */ \
183 1, /* fixed stack pointer */ \
184 10, /* fixed thread pointer */ \
185 32, 33, 34, /* fixed ap, fp, sr[f], */ \
186}
187
188enum reg_class
189{
190 NO_REGS,
191 SIBCALL_REGS,
44080af9 192 DOUBLE_REGS,
fd631eb5 193 GOT_REGS,
3965b35f
SH
194 GENERAL_REGS,
195 FLAG_REGS,
196 ALL_REGS,
197 LIM_REG_CLASSES
198};
199
200#define N_REG_CLASSES (int) LIM_REG_CLASSES
201
202#define REG_CLASS_NAMES { \
203 "NO_REGS", \
204 "SIBCALL_REGS", \
44080af9 205 "DOUBLE_REGS", \
fd631eb5 206 "GOT_REGS", \
3965b35f
SH
207 "GENERAL_REGS", \
208 "FLAG_REGS", \
209 "ALL_REGS" }
210
211/* The SIBCALL_REGS must be call-clobbered, and not used as a temporary
212 in the epilogue. This excludes R9 (LR), R11 (STATIC_CHAIN), and
213 R13 (PE_TMP_REGNUM). */
214#define SIBCALL_REGS_MASK 0x00ff95f8u
215
216#define REG_CLASS_CONTENTS \
217{ { 0x00000000, 0x00000000 }, \
218 { SIBCALL_REGS_MASK, 0 }, \
44080af9 219 { 0x7f7ffffe, 0x00000000 }, \
fd631eb5 220 { 0xfffffdff, 0x00000000 }, \
3965b35f
SH
221 { 0xffffffff, 0x00000003 }, \
222 { 0x00000000, 0x00000004 }, \
223 { 0xffffffff, 0x00000007 } \
224}
225
226/* A C expression whose value is a register class containing hard
227 register REGNO. In general there is more that one such class;
228 choose a class which is "minimal", meaning that no smaller class
229 also contains the register. */
230#define REGNO_REG_CLASS(REGNO) \
231 ((REGNO) >= SR_F_REGNUM ? FLAG_REGS \
232 : (REGNO) < 32 && ((SIBCALL_REGS_MASK >> (REGNO)) & 1) ? SIBCALL_REGS \
233 : GENERAL_REGS)
234
235#define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
236do { \
237 if (GET_MODE_CLASS (MODE) == MODE_INT \
238 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
239 (MODE) = word_mode; \
240} while (0)
241
242/* A macro whose definition is the name of the class to which a valid
243 base register must belong. A base register is one used in an
244 address which is the register value plus a displacement. */
245#define BASE_REG_CLASS GENERAL_REGS
246
247#define INDEX_REG_CLASS NO_REGS
248
249/* Assembly definitions. */
250
251#define ASM_APP_ON ""
252#define ASM_APP_OFF ""
253
254#define ASM_COMMENT_START "# "
255
256#define GLOBAL_ASM_OP "\t.global\t"
257#define TEXT_SECTION_ASM_OP "\t.section\t.text"
258#define DATA_SECTION_ASM_OP "\t.section\t.data"
259#define BSS_SECTION_ASM_OP "\t.section\t.bss"
260#define SBSS_SECTION_ASM_OP "\t.section\t.sbss"
261
262/* This is how to output an assembler line
263 that says to advance the location counter
264 to a multiple of 2**LOG bytes. */
265#define ASM_OUTPUT_ALIGN(FILE,LOG) \
266 do \
267 { \
268 if ((LOG) != 0) \
269 fprintf (FILE, "\t.align %d\n", 1 << (LOG)); \
270 } \
271 while (0)
272
273/* This is used in crtstuff to create call stubs in the
274 _init() and _fini() functions. Defining this here saves
275 a few bytes created by the dummy call_xxx() functions. */
276#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
277 asm (SECTION_OP "\n" \
278" l.jal " #FUNC "\n" \
279" l.nop\n" \
280" .previous");
281
282
283#define PRINT_OPERAND_PUNCT_VALID_P(CODE) (code == '#')
284
285/* Calling convention definitions. */
286#define CUMULATIVE_ARGS int
287#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
288 do { (CUM) = 0; } while (0)
289
290
291/* Trampolines, for nested functions */
292#define TRAMPOLINE_SIZE 20
293#define TRAMPOLINE_ALIGNMENT 32
294
295/* Pointer mode */
296#define Pmode SImode
297#define FUNCTION_MODE SImode
298#define STACK_POINTER_REGNUM SP_REGNUM
299#define FRAME_POINTER_REGNUM SFP_REGNUM
300#define HARD_FRAME_POINTER_REGNUM HFP_REGNUM
301#define STATIC_CHAIN_REGNUM RV_REGNUM
302
303/* The register number of the arg pointer register, which is used to
304 access the function's argument list. */
305#define ARG_POINTER_REGNUM AP_REGNUM
306
307/* Position Independent Code. See or1k_init_pic_reg. */
308#define REAL_PIC_OFFSET_TABLE_REGNUM HW_TO_GCC_REGNO (16)
309
310/* ??? Follow i386 in working around gimple costing estimation, which
311 happens without properly initializing the pic_offset_table pseudo. */
312#define PIC_OFFSET_TABLE_REGNUM \
313 (pic_offset_table_rtx ? INVALID_REGNUM : REAL_PIC_OFFSET_TABLE_REGNUM)
314
315/* A C expression that is nonzero if REGNO is the number of a hard
316 register in which function arguments are sometimes passed. */
317#define FUNCTION_ARG_REGNO_P(r) (r >= 3 && r <= 8)
318
319#define MAX_REGS_PER_ADDRESS 1
320
321/* The ELIMINABLE_REGS macro specifies a table of register pairs used to
322 eliminate unneeded registers that point into the stack frame. Note,
323 the only elimination attempted by the compiler is to replace references
324 to the frame pointer with references to the stack pointer. */
325
326#define ELIMINABLE_REGS \
327{{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
328 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
329 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
330 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }}
331
332#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
333 do { \
334 (OFFSET) = or1k_initial_elimination_offset ((FROM), (TO)); \
335 } while (0)
336
337#define REGNO_OK_FOR_INDEX_P(REGNO) 0
338#define REGNO_OK_FOR_BASE_P(REGNO) ((REGNO) <= SFP_REGNUM)
339
340/* If defined, the maximum amount of space required for outgoing
341 arguments will be computed and placed into the variable
342 'crtl->outgoing_args_size'. No space will be pushed
343 onto the stack for each call; instead, the function prologue
344 should increase the stack frame size by this amount. */
345#define ACCUMULATE_OUTGOING_ARGS 1
346
347/* Stack layout and stack pointer usage. */
348
349/* This plus ARG_POINTER_REGNUM points to the first word of incoming args. */
350#define FIRST_PARM_OFFSET(FNDECL) (0)
351
352/* This plus STACK_POINTER_REGNUM points to the first work of outgoing args. */
353#define STACK_POINTER_OFFSET (0)
354
355/* Define this macro if pushing a word onto the stack moves the stack
356 pointer to a smaller address. */
357#define STACK_GROWS_DOWNWARD 1
358
359#define FRAME_GROWS_DOWNWARD 1
360
361/* An alias for a machine mode name. This is the machine mode that
362 elements of a jump-table should have. */
363#define CASE_VECTOR_MODE SImode
364
365#define STORE_FLAG_VALUE 1
366
367/* Indicates how loads of narrow mode values are loaded into words. */
368#define LOAD_EXTEND_OP(MODE) (ZERO_EXTEND)
369
370/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
371 the stack pointer does not matter. */
372#define EXIT_IGNORE_STACK 1
373
374/* Macros related to the access of the stack frame chain. */
375#define INITIAL_FRAME_ADDRESS_RTX or1k_initial_frame_addr ()
376#define DYNAMIC_CHAIN_ADDRESS or1k_dynamic_chain_addr
377#define RETURN_ADDR_RTX or1k_return_addr
378
379/* Always pass the SYMBOL_REF for direct calls to the expanders. */
380#define NO_FUNCTION_CSE 1
381
382/* Profiling */
383#define FUNCTION_PROFILER(FILE,LABELNO) (abort (), 0)
384
385/* Dwarf 2 Support */
386#define DWARF2_DEBUGGING_INFO 1
387#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LR_REGNUM)
388#define DWARF_FRAME_RETURN_COLUMN LR_REGNUM
389
390/* Describe how we implement __builtin_eh_return. */
391#define EH_RETURN_REGNUM HW_TO_GCC_REGNO (23)
392/* Use r25, r27, r29 and r31 (clobber regs) for exception data.
393 Recall that these are remapped consecutively. */
394#define EH_RETURN_DATA_REGNO(N) \
395 ((N) < 4 ? HW_TO_GCC_REGNO (25) + (N) : INVALID_REGNUM)
396#define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, EH_RETURN_REGNUM)
397
398#endif /* GCC_OR1K_H */