]>
Commit | Line | Data |
---|---|---|
e430824f | 1 | /* Definitions of target machine for Altera Nios II. |
a945c346 | 2 | Copyright (C) 2012-2024 Free Software Foundation, Inc. |
e430824f CLT |
3 | Contributed by Jonah Graham (jgraham@altera.com), |
4 | Will Reece (wreece@altera.com), and Jeff DaSilva (jdasilva@altera.com). | |
5 | Contributed by Mentor Graphics, Inc. | |
6 | ||
7 | This file is part of GCC. | |
8 | ||
9 | GCC is free software; you can redistribute it and/or modify it | |
10 | under the terms of the GNU General Public License as published | |
11 | by the Free Software Foundation; either version 3, or (at your | |
12 | option) any later version. | |
13 | ||
14 | GCC is distributed in the hope that it will be useful, but WITHOUT | |
15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
16 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | |
17 | License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with GCC; see the file COPYING3. If not see | |
21 | <http://www.gnu.org/licenses/>. */ | |
22 | ||
23 | #ifndef GCC_NIOS2_H | |
24 | #define GCC_NIOS2_H | |
25 | ||
77c50d73 SL |
26 | /* Indicate R2 ISA level support. */ |
27 | #define TARGET_ARCH_R2 (nios2_arch_option == ARCH_R2) | |
28 | ||
e430824f CLT |
29 | /* FPU insn codes declared here. */ |
30 | #include "config/nios2/nios2-opts.h" | |
31 | ||
32 | /* Define built-in preprocessor macros. */ | |
33 | #define TARGET_CPU_CPP_BUILTINS() \ | |
34 | do \ | |
35 | { \ | |
36 | builtin_define_std ("NIOS2"); \ | |
37 | builtin_define_std ("nios2"); \ | |
38 | if (TARGET_BIG_ENDIAN) \ | |
39 | builtin_define_std ("nios2_big_endian"); \ | |
40 | else \ | |
41 | builtin_define_std ("nios2_little_endian"); \ | |
77c50d73 SL |
42 | builtin_define_with_int_value ( \ |
43 | "__nios2_arch__", (int) nios2_arch_option); \ | |
44 | } \ | |
e430824f CLT |
45 | while (0) |
46 | ||
47 | /* We're little endian, unless otherwise specified by defining | |
48 | BIG_ENDIAN_FLAG. */ | |
49 | #ifndef TARGET_ENDIAN_DEFAULT | |
50 | # define TARGET_ENDIAN_DEFAULT 0 | |
51 | #endif | |
52 | ||
53 | /* Default target_flags if no switches specified. */ | |
54 | #ifndef TARGET_DEFAULT | |
55 | # define TARGET_DEFAULT (MASK_HAS_MUL | TARGET_ENDIAN_DEFAULT) | |
56 | #endif | |
57 | ||
77c50d73 SL |
58 | #define OPTION_DEFAULT_SPECS \ |
59 | {"arch", "%{!march=*:%{!mcpu=*:-march=%(VALUE)}}" } | |
60 | ||
e430824f CLT |
61 | #define CC1_SPEC "%{G*}" |
62 | ||
63 | #if TARGET_ENDIAN_DEFAULT == 0 | |
77c50d73 | 64 | # define ASM_SPEC "%{!meb:-EL} %{meb:-EB} %{march=*:-march=%*}" |
e430824f CLT |
65 | # define LINK_SPEC_ENDIAN "%{!meb:-EL} %{meb:-EB}" |
66 | # define MULTILIB_DEFAULTS { "EL" } | |
67 | #else | |
77c50d73 | 68 | # define ASM_SPEC "%{!mel:-EB} %{mel:-EL} %{march=*:-march=%*}" |
e430824f CLT |
69 | # define LINK_SPEC_ENDIAN "%{!mel:-EB} %{mel:-EL}" |
70 | # define MULTILIB_DEFAULTS { "EB" } | |
71 | #endif | |
72 | ||
73 | #define LINK_SPEC LINK_SPEC_ENDIAN \ | |
74 | " %{shared:-shared} \ | |
75 | %{static:-Bstatic}" | |
76 | ||
77 | ||
78 | /* Storage layout. */ | |
79 | ||
80 | #define DEFAULT_SIGNED_CHAR 1 | |
81 | #define BITS_BIG_ENDIAN 0 | |
82 | #define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN != 0) | |
83 | #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN != 0) | |
e430824f CLT |
84 | #define BITS_PER_WORD 32 |
85 | #define UNITS_PER_WORD 4 | |
86 | #define POINTER_SIZE 32 | |
87 | #define BIGGEST_ALIGNMENT 32 | |
88 | #define STRICT_ALIGNMENT 1 | |
89 | #define FUNCTION_BOUNDARY 32 | |
90 | #define PARM_BOUNDARY 32 | |
91 | #define STACK_BOUNDARY 32 | |
92 | #define PREFERRED_STACK_BOUNDARY 32 | |
93 | #define MAX_FIXED_MODE_SIZE 64 | |
94 | ||
3bbbe009 SL |
95 | #define LABEL_ALIGN(LABEL) nios2_label_align (LABEL) |
96 | ||
e430824f CLT |
97 | /* Layout of source language data types. */ |
98 | ||
99 | #define INT_TYPE_SIZE 32 | |
100 | #define SHORT_TYPE_SIZE 16 | |
101 | #define LONG_TYPE_SIZE 32 | |
102 | #define LONG_LONG_TYPE_SIZE 64 | |
e430824f CLT |
103 | |
104 | #undef SIZE_TYPE | |
105 | #define SIZE_TYPE "unsigned int" | |
106 | ||
107 | #undef PTRDIFF_TYPE | |
108 | #define PTRDIFF_TYPE "int" | |
109 | ||
110 | ||
111 | /* Basic characteristics of Nios II registers: | |
112 | ||
113 | Regno Name | |
114 | 0 r0 zero always zero | |
115 | 1 r1 at Assembler Temporary | |
116 | 2-3 r2-r3 Return Location | |
117 | 4-7 r4-r7 Register Arguments | |
118 | 8-15 r8-r15 Caller Saved Registers | |
119 | 16-22 r16-r22 Callee Saved Registers | |
120 | 22 r22 Global Offset Table pointer (Linux ABI only) | |
121 | 23 r23 Thread pointer (Linux ABI only) | |
122 | 24 r24 et Exception Temporary | |
123 | 25 r25 bt Breakpoint Temporary | |
124 | 26 r26 gp Global Pointer | |
125 | 27 r27 sp Stack Pointer | |
126 | 28 r28 fp Frame Pointer | |
127 | 29 r29 ea Exception Return Address | |
128 | 30 r30 ba Breakpoint Return Address | |
129 | 31 r31 ra Return Address | |
130 | ||
131 | 32 ctl0 status | |
132 | 33 ctl1 estatus STATUS saved by exception | |
133 | 34 ctl2 bstatus STATUS saved by break | |
134 | 35 ctl3 ipri Interrupt Priority Mask | |
135 | 36 ctl4 ecause Exception Cause | |
136 | ||
137 | 37 pc Not an actual register | |
138 | ||
139 | 38 fake_fp Fake Frame Pointer (always eliminated) | |
140 | 39 fake_ap Fake Argument Pointer (always eliminated) | |
141 | 40 First Pseudo Register | |
142 | ||
143 | In addition, r12 is used as the static chain register and r13, r14, and r15 | |
144 | are clobbered by PLT code sequences. | |
145 | ||
146 | The definitions for all the hard register numbers are located in nios2.md. | |
147 | */ | |
148 | ||
149 | #define FIXED_REGISTERS \ | |
150 | { \ | |
151 | /* +0 1 2 3 4 5 6 7 8 9 */ \ | |
152 | /* 0 */ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, \ | |
153 | /* 10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ | |
154 | /* 20 */ 0, 0, TARGET_LINUX_ABI, TARGET_LINUX_ABI, 1, 1, 1, 1, 0, 1, \ | |
155 | /* 30 */ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
156 | } | |
157 | ||
158 | /* Call used == caller saved + fixed regs + args + ret vals. */ | |
159 | #define CALL_USED_REGISTERS \ | |
160 | { \ | |
161 | /* +0 1 2 3 4 5 6 7 8 9 */ \ | |
162 | /* 0 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
163 | /* 10 */ 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, \ | |
164 | /* 20 */ 0, 0, TARGET_LINUX_ABI, TARGET_LINUX_ABI, 1, 1, 1, 1, 0, 1, \ | |
165 | /* 30 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
166 | } | |
167 | ||
3bbbe009 SL |
168 | /* Order in which to allocate registers. Each register must be |
169 | listed once. This is the default ordering for R1 and non-CDX R2 | |
170 | code. For CDX, we overwrite this in ADJUST_REG_ALLOC_ORDER. */ | |
171 | #define REG_ALLOC_ORDER \ | |
172 | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, \ | |
173 | 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, \ | |
174 | 37, 38, 39 } | |
175 | ||
176 | #define ADJUST_REG_ALLOC_ORDER nios2_adjust_reg_alloc_order () | |
177 | ||
178 | /* Caller-save costs can be less emphasized under R2 CDX, where we can | |
179 | use push.n/pop.n. */ | |
180 | #define HONOR_REG_ALLOC_ORDER (TARGET_HAS_CDX) | |
181 | ||
e430824f CLT |
182 | /* Register Classes. */ |
183 | ||
184 | enum reg_class | |
185 | { | |
186 | NO_REGS, | |
187 | SIB_REGS, | |
3c8c9f0d | 188 | IJMP_REGS, |
e430824f CLT |
189 | GP_REGS, |
190 | ALL_REGS, | |
191 | LIM_REG_CLASSES | |
192 | }; | |
193 | ||
194 | #define N_REG_CLASSES (int) LIM_REG_CLASSES | |
195 | ||
196 | #define REG_CLASS_NAMES \ | |
197 | { "NO_REGS", \ | |
198 | "SIB_REGS", \ | |
3c8c9f0d | 199 | "IJMP_REGS", \ |
e430824f CLT |
200 | "GP_REGS", \ |
201 | "ALL_REGS" } | |
202 | ||
203 | #define GENERAL_REGS ALL_REGS | |
204 | ||
205 | #define REG_CLASS_CONTENTS \ | |
206 | { \ | |
3c8c9f0d CLT |
207 | /* NO_REGS */ { 0, 0}, \ |
208 | /* SIB_REGS */ { 0xfe0c, 0}, \ | |
209 | /* IJMP_REGS */ { 0x7fffffff, 0}, \ | |
210 | /* GP_REGS */ {~0, 0}, \ | |
211 | /* ALL_REGS */ {~0,~0} \ | |
e430824f CLT |
212 | } |
213 | ||
214 | ||
215 | #define GP_REG_P(REGNO) ((unsigned)(REGNO) <= LAST_GP_REG) | |
216 | #define REGNO_REG_CLASS(REGNO) (GP_REG_P (REGNO) ? GP_REGS : ALL_REGS) | |
217 | #define CLASS_MAX_NREGS(CLASS, MODE) \ | |
218 | ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD) | |
219 | ||
3bbbe009 | 220 | #define CDX_REG_P(REGNO) \ |
01512446 | 221 | ((REGNO) == 16 || (REGNO) == 17 || ((REGNO) >= 2 && (REGNO) <= 7)) |
3bbbe009 | 222 | |
e430824f CLT |
223 | /* Tests for various kinds of constants used in the Nios II port. */ |
224 | ||
225 | #define SMALL_INT(X) ((unsigned HOST_WIDE_INT)(X) + 0x8000 < 0x10000) | |
42e6ab74 | 226 | #define SMALL_INT12(X) ((unsigned HOST_WIDE_INT)(X) + 0x800 < 0x1000) |
e430824f CLT |
227 | #define SMALL_INT_UNSIGNED(X) ((X) >= 0 && (X) < 0x10000) |
228 | #define UPPER16_INT(X) (((X) & 0xffff) == 0) | |
229 | #define SHIFT_INT(X) ((X) >= 0 && (X) <= 31) | |
230 | #define RDWRCTL_INT(X) ((X) >= 0 && (X) <= 31) | |
231 | #define CUSTOM_INSN_OPCODE(X) ((X) >= 0 && (X) <= 255) | |
3bbbe009 SL |
232 | #define ANDCLEAR_INT(X) \ |
233 | (((X) & 0xffff) == 0xffff || (((X) >> 16) & 0xffff) == 0xffff) | |
e430824f CLT |
234 | |
235 | /* Say that the epilogue uses the return address register. Note that | |
236 | in the case of sibcalls, the values "used by the epilogue" are | |
237 | considered live at the start of the called function. */ | |
238 | #define EPILOGUE_USES(REGNO) (epilogue_completed && (REGNO) == RA_REGNO) | |
239 | ||
240 | /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, | |
241 | the stack pointer does not matter. The value is tested only in | |
242 | functions that have frame pointers. | |
243 | No definition is equivalent to always zero. */ | |
244 | ||
245 | #define EXIT_IGNORE_STACK 1 | |
246 | ||
247 | /* Trampolines use a 5-instruction sequence. */ | |
248 | #define TRAMPOLINE_SIZE 20 | |
249 | ||
250 | /* Stack layout. */ | |
62f9f30b | 251 | #define STACK_GROWS_DOWNWARD 1 |
9bba3b25 | 252 | #define FRAME_GROWS_DOWNWARD 1 |
e430824f CLT |
253 | #define FIRST_PARM_OFFSET(FUNDECL) 0 |
254 | ||
255 | /* Before the prologue, RA lives in r31. */ | |
240930c4 | 256 | #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, RA_REGNO) |
e430824f CLT |
257 | #define RETURN_ADDR_RTX(C,F) nios2_get_return_address (C) |
258 | ||
259 | #define DWARF_FRAME_RETURN_COLUMN RA_REGNO | |
260 | ||
261 | /* The CFA includes the pretend args. */ | |
262 | #define ARG_POINTER_CFA_OFFSET(FNDECL) \ | |
263 | (gcc_assert ((FNDECL) == current_function_decl), \ | |
264 | FIRST_PARM_OFFSET (FNDECL) + crtl->args.pretend_args_size) | |
265 | ||
266 | /* Frame/arg pointer elimination settings. */ | |
267 | #define ELIMINABLE_REGS \ | |
268 | {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ | |
269 | { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \ | |
270 | { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ | |
271 | { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}} | |
272 | ||
273 | #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ | |
274 | (OFFSET) = nios2_initial_elimination_offset ((FROM), (TO)) | |
275 | ||
276 | /* Calling convention definitions. */ | |
277 | typedef struct nios2_args | |
278 | { | |
279 | int regs_used; | |
280 | } CUMULATIVE_ARGS; | |
281 | ||
282 | #define NUM_ARG_REGS (LAST_ARG_REGNO - FIRST_ARG_REGNO + 1) | |
283 | ||
284 | #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \ | |
285 | do { (CUM).regs_used = 0; } while (0) | |
286 | ||
e430824f | 287 | #define PAD_VARARGS_DOWN \ |
76b0cbf8 | 288 | (targetm.calls.function_arg_padding (TYPE_MODE (type), type) == PAD_DOWNWARD) |
e430824f CLT |
289 | |
290 | #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \ | |
291 | (nios2_block_reg_padding ((MODE), (TYPE), (FIRST))) | |
292 | ||
293 | #define FUNCTION_ARG_REGNO_P(REGNO) \ | |
294 | ((REGNO) >= FIRST_ARG_REGNO && (REGNO) <= LAST_ARG_REGNO) | |
295 | ||
296 | /* Passing function arguments on stack. */ | |
e430824f CLT |
297 | #define ACCUMULATE_OUTGOING_ARGS 1 |
298 | ||
299 | /* We define TARGET_RETURN_IN_MEMORY, so set to zero. */ | |
300 | #define DEFAULT_PCC_STRUCT_RETURN 0 | |
301 | ||
302 | /* Profiling. */ | |
303 | #define PROFILE_BEFORE_PROLOGUE | |
304 | #define NO_PROFILE_COUNTERS 1 | |
305 | #define FUNCTION_PROFILER(FILE, LABELNO) \ | |
306 | nios2_function_profiler ((FILE), (LABELNO)) | |
307 | ||
308 | /* Addressing modes. */ | |
309 | ||
310 | #define CONSTANT_ADDRESS_P(X) \ | |
311 | (CONSTANT_P (X) && memory_address_p (SImode, X)) | |
312 | ||
313 | #define MAX_REGS_PER_ADDRESS 1 | |
314 | #define BASE_REG_CLASS ALL_REGS | |
315 | #define INDEX_REG_CLASS NO_REGS | |
316 | ||
317 | #define REGNO_OK_FOR_BASE_P(REGNO) nios2_regno_ok_for_base_p ((REGNO), true) | |
318 | #define REGNO_OK_FOR_INDEX_P(REGNO) 0 | |
319 | ||
320 | /* Describing Relative Costs of Operations. */ | |
321 | #define MOVE_MAX 4 | |
322 | #define SLOW_BYTE_ACCESS 1 | |
323 | ||
324 | /* It is as good to call a constant function address as to call an address | |
325 | kept in a register. */ | |
1e8552c2 | 326 | #define NO_FUNCTION_CSE 1 |
e430824f CLT |
327 | |
328 | /* Position independent code. */ | |
329 | ||
330 | #define PIC_OFFSET_TABLE_REGNUM 22 | |
331 | #define LEGITIMATE_PIC_OPERAND_P(X) nios2_legitimate_pic_operand_p (X) | |
332 | ||
333 | /* Define output assembler language. */ | |
334 | ||
335 | #define ASM_APP_ON "#APP\n" | |
336 | #define ASM_APP_OFF "#NO_APP\n" | |
337 | ||
338 | #define ASM_COMMENT_START "# " | |
339 | ||
340 | #define GLOBAL_ASM_OP "\t.global\t" | |
341 | ||
342 | #define REGISTER_NAMES \ | |
343 | { \ | |
344 | "zero", \ | |
345 | "at", \ | |
346 | "r2", \ | |
347 | "r3", \ | |
348 | "r4", \ | |
349 | "r5", \ | |
350 | "r6", \ | |
351 | "r7", \ | |
352 | "r8", \ | |
353 | "r9", \ | |
354 | "r10", \ | |
355 | "r11", \ | |
356 | "r12", \ | |
357 | "r13", \ | |
358 | "r14", \ | |
359 | "r15", \ | |
360 | "r16", \ | |
361 | "r17", \ | |
362 | "r18", \ | |
363 | "r19", \ | |
364 | "r20", \ | |
365 | "r21", \ | |
366 | "r22", \ | |
367 | "r23", \ | |
368 | "et", \ | |
369 | "bt", \ | |
370 | "gp", \ | |
371 | "sp", \ | |
372 | "fp", \ | |
373 | "ta", \ | |
374 | "ba", \ | |
375 | "ra", \ | |
376 | "status", \ | |
377 | "estatus", \ | |
378 | "bstatus", \ | |
379 | "ipri", \ | |
380 | "ecause", \ | |
381 | "pc", \ | |
382 | "fake_fp", \ | |
383 | "fake_ap", \ | |
384 | } | |
385 | ||
386 | #define ADDITIONAL_REGISTER_NAMES \ | |
387 | { \ | |
388 | {"r0", 0}, \ | |
389 | {"r1", 1}, \ | |
390 | {"r24", 24}, \ | |
391 | {"r25", 25}, \ | |
392 | {"r26", 26}, \ | |
393 | {"r27", 27}, \ | |
394 | {"r28", 28}, \ | |
395 | {"r29", 29}, \ | |
396 | {"r30", 30}, \ | |
397 | {"r31", 31} \ | |
398 | } | |
399 | ||
400 | #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ | |
401 | do \ | |
402 | { \ | |
403 | fputs (integer_asm_op (POINTER_SIZE / BITS_PER_UNIT, TRUE), FILE); \ | |
404 | fprintf (FILE, ".L%u\n", (unsigned) (VALUE)); \ | |
405 | } \ | |
406 | while (0) | |
407 | ||
408 | #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL)\ | |
409 | do \ | |
410 | { \ | |
411 | fputs (integer_asm_op (POINTER_SIZE / BITS_PER_UNIT, TRUE), STREAM); \ | |
412 | fprintf (STREAM, ".L%u-.L%u\n", (unsigned) (VALUE), (unsigned) (REL)); \ | |
413 | } \ | |
414 | while (0) | |
415 | ||
416 | /* Section directives. */ | |
417 | ||
418 | /* Output before read-only data. */ | |
419 | #define TEXT_SECTION_ASM_OP "\t.section\t.text" | |
420 | ||
421 | /* Output before writable data. */ | |
422 | #define DATA_SECTION_ASM_OP "\t.section\t.data" | |
423 | ||
424 | /* Output before uninitialized data. */ | |
425 | #define BSS_SECTION_ASM_OP "\t.section\t.bss" | |
426 | ||
427 | /* Output before 'small' uninitialized data. */ | |
428 | #define SBSS_SECTION_ASM_OP "\t.section\t.sbss" | |
429 | ||
05122129 | 430 | #ifndef USED_FOR_TARGET |
e430824f CLT |
431 | /* Default the definition of "small data" to 8 bytes. */ |
432 | extern unsigned HOST_WIDE_INT nios2_section_threshold; | |
433 | #endif | |
434 | ||
435 | #define NIOS2_DEFAULT_GVALUE 8 | |
436 | ||
437 | /* This says how to output assembler code to declare an | |
438 | uninitialized external linkage data object. Under SVR4, | |
439 | the linker seems to want the alignment of data objects | |
440 | to depend on their types. We do exactly that here. */ | |
441 | #undef COMMON_ASM_OP | |
442 | #define COMMON_ASM_OP "\t.comm\t" | |
443 | ||
444 | #define ASM_OUTPUT_ALIGN(FILE, LOG) \ | |
445 | do { \ | |
446 | fprintf ((FILE), "%s%d\n", ALIGN_ASM_OP, (LOG)); \ | |
447 | } while (0) | |
448 | ||
449 | #undef ASM_OUTPUT_ALIGNED_COMMON | |
450 | #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ | |
451 | do \ | |
452 | { \ | |
453 | fprintf ((FILE), "%s", COMMON_ASM_OP); \ | |
454 | assemble_name ((FILE), (NAME)); \ | |
16998094 | 455 | fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", (SIZE), \ |
e430824f CLT |
456 | (ALIGN) / BITS_PER_UNIT); \ |
457 | } \ | |
458 | while (0) | |
459 | ||
460 | ||
461 | /* This says how to output assembler code to declare an | |
462 | uninitialized internal linkage data object. Under SVR4, | |
463 | the linker seems to want the alignment of data objects | |
464 | to depend on their types. We do exactly that here. */ | |
465 | ||
4569f8b3 SL |
466 | #undef ASM_OUTPUT_ALIGNED_DECL_LOCAL |
467 | #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \ | |
e430824f | 468 | do { \ |
4569f8b3 | 469 | if (targetm.in_small_data_p (DECL)) \ |
e430824f CLT |
470 | switch_to_section (sbss_section); \ |
471 | else \ | |
472 | switch_to_section (bss_section); \ | |
473 | ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \ | |
474 | if (!flag_inhibit_size_directive) \ | |
475 | ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \ | |
476 | ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \ | |
477 | ASM_OUTPUT_LABEL(FILE, NAME); \ | |
478 | ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \ | |
479 | } while (0) | |
480 | ||
481 | /* Put the jump tables in .text because when using position-independent code, | |
482 | Nios II elf has no relocation that can represent arbitrary differences | |
483 | between symbols in different sections. */ | |
484 | #define JUMP_TABLES_IN_TEXT_SECTION 1 | |
485 | ||
486 | /* Exception handling. */ | |
487 | ||
488 | /* Describe __builtin_eh_return. */ | |
489 | #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, LAST_RETVAL_REGNO) | |
490 | #define EH_RETURN_DATA_REGNO(N) ((N) <= (LAST_ARG_REGNO - FIRST_ARG_REGNO) \ | |
491 | ? (N) + FIRST_ARG_REGNO : INVALID_REGNUM) | |
492 | ||
2d33dcfe SL |
493 | /* For PIC, use indirect for global references; it'll end up using a dynamic |
494 | relocation, which we want to keep out of read-only EH sections. | |
495 | For local references, we want to use GOT-relative offsets provided | |
496 | the assembler supports them. For non-PIC, use an absolute encoding. */ | |
497 | #ifdef HAVE_AS_NIOS2_GOTOFF_RELOCATION | |
e430824f | 498 | #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ |
2d33dcfe SL |
499 | (flag_pic \ |
500 | ? ((GLOBAL) \ | |
501 | ? DW_EH_PE_indirect | DW_EH_PE_absptr \ | |
502 | : DW_EH_PE_datarel | DW_EH_PE_sdata4) \ | |
503 | : DW_EH_PE_absptr) | |
504 | ||
505 | #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \ | |
506 | do { \ | |
507 | if (((ENCODING) & 0xf0) == DW_EH_PE_datarel) \ | |
508 | { \ | |
509 | fputs ("\t.4byte %gotoff(", FILE); \ | |
510 | output_addr_const (FILE, ADDR); \ | |
511 | fputs (")", FILE); \ | |
512 | goto DONE; \ | |
513 | } \ | |
514 | } while (0) | |
515 | ||
516 | #else | |
517 | /* We don't have %gotoff support in the assembler. Fall back to the encoding | |
518 | it used to use instead before the assembler was fixed. This has known | |
519 | bugs but mostly works. */ | |
520 | #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ | |
521 | (flag_pic \ | |
522 | ? ((GLOBAL) \ | |
523 | ? DW_EH_PE_indirect | DW_EH_PE_absptr \ | |
524 | : DW_EH_PE_aligned) \ | |
525 | : DW_EH_PE_absptr) | |
526 | #endif | |
e430824f CLT |
527 | |
528 | /* Misc. parameters. */ | |
529 | ||
530 | #define STORE_FLAG_VALUE 1 | |
531 | #define Pmode SImode | |
532 | #define FUNCTION_MODE QImode | |
533 | ||
534 | #define CASE_VECTOR_MODE Pmode | |
535 | ||
e430824f CLT |
536 | #define LOAD_EXTEND_OP(MODE) (ZERO_EXTEND) |
537 | ||
9e11bfef | 538 | #define WORD_REGISTER_OPERATIONS 1 |
e430824f CLT |
539 | |
540 | #endif /* GCC_NIOS2_H */ |