1 /* Definitions of target machine of Andes NDS32 cpu for GNU compiler
2 Copyright (C) 2012-2018 Free Software Foundation, Inc.
3 Contributed by Andes Technology Corporation.
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 /* ------------------------------------------------------------------------ */
24 /* The following are auxiliary macros or structure declarations
25 that are used all over the nds32.c and nds32.h. */
27 #define ADJUST_INSN_LENGTH(INSN, LENGTH) \
28 (LENGTH = nds32_adjust_insn_length (INSN, LENGTH))
30 /* Use SYMBOL_FLAG_MACH_DEP to define our own symbol_ref flag.
31 It is used in nds32_encode_section_info() to store flag in symbol_ref
32 in case the symbol should be placed in .rodata section.
33 So that we can check it in nds32_legitimate_address_p(). */
34 #define NDS32_SYMBOL_FLAG_RODATA \
35 (SYMBOL_FLAG_MACH_DEP << 0)
36 #define NDS32_SYMBOL_REF_RODATA_P(x) \
37 ((SYMBOL_REF_FLAGS (x) & NDS32_SYMBOL_FLAG_RODATA) != 0)
39 /* Classifies expand result for expand helper function. */
40 enum nds32_expand_result_type
44 EXPAND_CREATE_TEMPLATE
47 /* Check instruction LS-37-FP-implied form.
48 Note: actually its immediate range is imm9u
49 since it is used for lwi37/swi37 instructions. */
50 #define NDS32_LS_37_FP_P(rt, ra, imm) \
51 (REGNO_REG_CLASS (REGNO (rt)) == LOW_REGS \
52 && REGNO (ra) == FP_REGNUM \
53 && satisfies_constraint_Iu09 (imm))
55 /* Check instruction LS-37-SP-implied form.
56 Note: actually its immediate range is imm9u
57 since it is used for lwi37/swi37 instructions. */
58 #define NDS32_LS_37_SP_P(rt, ra, imm) \
59 (REGNO_REG_CLASS (REGNO (rt)) == LOW_REGS \
60 && REGNO (ra) == SP_REGNUM \
61 && satisfies_constraint_Iu09 (imm))
64 /* Check load/store instruction form : Rt3, Ra3, imm3u. */
65 #define NDS32_LS_333_P(rt, ra, imm, mode) nds32_ls_333_p (rt, ra, imm, mode)
67 /* Check load/store instruction form : Rt4, Ra5, const_int_0.
68 Note: no need to check ra because Ra5 means it covers all registers. */
69 #define NDS32_LS_450_P(rt, ra, imm) \
70 ((imm == const0_rtx) \
71 && (REGNO_REG_CLASS (REGNO (rt)) == LOW_REGS \
72 || REGNO_REG_CLASS (REGNO (rt)) == MIDDLE_REGS))
74 /* Check instruction RRI-333-form. */
75 #define NDS32_RRI_333_P(rt, ra, imm) \
76 (REGNO_REG_CLASS (REGNO (rt)) == LOW_REGS \
77 && REGNO_REG_CLASS (REGNO (ra)) == LOW_REGS \
78 && satisfies_constraint_Iu03 (imm))
80 /* Check instruction RI-45-form. */
81 #define NDS32_RI_45_P(rt, ra, imm) \
82 (REGNO (rt) == REGNO (ra) \
83 && (REGNO_REG_CLASS (REGNO (rt)) == LOW_REGS \
84 || REGNO_REG_CLASS (REGNO (rt)) == MIDDLE_REGS) \
85 && satisfies_constraint_Iu05 (imm))
88 /* Check instruction RR-33-form. */
89 #define NDS32_RR_33_P(rt, ra) \
90 (REGNO_REG_CLASS (REGNO (rt)) == LOW_REGS \
91 && REGNO_REG_CLASS (REGNO (ra)) == LOW_REGS)
93 /* Check instruction RRR-333-form. */
94 #define NDS32_RRR_333_P(rt, ra, rb) \
95 (REGNO_REG_CLASS (REGNO (rt)) == LOW_REGS \
96 && REGNO_REG_CLASS (REGNO (ra)) == LOW_REGS \
97 && REGNO_REG_CLASS (REGNO (rb)) == LOW_REGS)
99 /* Check instruction RR-45-form.
100 Note: no need to check rb because Rb5 means it covers all registers. */
101 #define NDS32_RR_45_P(rt, ra, rb) \
102 (REGNO (rt) == REGNO (ra) \
103 && (REGNO_REG_CLASS (REGNO (rt)) == LOW_REGS \
104 || REGNO_REG_CLASS (REGNO (rt)) == MIDDLE_REGS))
106 /* Classifies address type to distinguish 16-bit/32-bit format. */
107 enum nds32_16bit_address_type
109 /* [reg]: 45 format address. */
111 /* [lo_reg + imm3u]: 333 format address. */
112 ADDRESS_LO_REG_IMM3U
,
113 /* post_inc [lo_reg + imm3u]: 333 format address. */
114 ADDRESS_POST_INC_LO_REG_IMM3U
,
115 /* post_modify [lo_reg + imm3u]: 333 format address. */
116 ADDRESS_POST_MODIFY_LO_REG_IMM3U
,
117 /* [$r8 + imm7u]: r8 imply address. */
119 /* [$fp + imm7u]: fp imply address. */
121 /* [$sp + imm7u]: sp imply address. */
123 /* Other address format. */
124 ADDRESS_NOT_16BIT_FORMAT
128 /* ------------------------------------------------------------------------ */
130 /* Define maximum numbers of registers for passing arguments. */
131 #define NDS32_MAX_GPR_REGS_FOR_ARGS 6
132 #define NDS32_MAX_FPR_REGS_FOR_ARGS 6
134 /* Define the register number for first argument. */
135 #define NDS32_GPR_ARG_FIRST_REGNUM 0
136 #define NDS32_FPR_ARG_FIRST_REGNUM 34
138 /* Define the register number for return value. */
139 #define NDS32_GPR_RET_FIRST_REGNUM 0
140 #define NDS32_FPR_RET_FIRST_REGNUM 34
142 /* Define the first integer register number. */
143 #define NDS32_FIRST_GPR_REGNUM 0
144 /* Define the last integer register number. */
145 #define NDS32_LAST_GPR_REGNUM 31
147 #define NDS32_FIRST_CALLEE_SAVE_GPR_REGNUM 6
148 #define NDS32_LAST_CALLEE_SAVE_GPR_REGNUM \
149 (TARGET_REDUCED_REGS ? 10 : 14)
151 /* Define the floating-point number of registers. */
152 #define NDS32_FLOAT_REGISTER_NUMBER \
153 (((nds32_fp_regnum == NDS32_CONFIG_FPU_0) \
154 || (nds32_fp_regnum == NDS32_CONFIG_FPU_4)) ? 8 \
155 : ((nds32_fp_regnum == NDS32_CONFIG_FPU_1) \
156 || (nds32_fp_regnum == NDS32_CONFIG_FPU_5)) ? 16 \
157 : ((nds32_fp_regnum == NDS32_CONFIG_FPU_2) \
158 || (nds32_fp_regnum == NDS32_CONFIG_FPU_6)) ? 32 \
159 : ((nds32_fp_regnum == NDS32_CONFIG_FPU_3) \
160 || (nds32_fp_regnum == NDS32_CONFIG_FPU_7)) ? 64 \
163 #define NDS32_EXT_FPU_DOT_E (nds32_fp_regnum >= 4)
165 /* Define the first floating-point register number. */
166 #define NDS32_FIRST_FPR_REGNUM 34
167 /* Define the last floating-point register number. */
168 #define NDS32_LAST_FPR_REGNUM \
169 (NDS32_FIRST_FPR_REGNUM + NDS32_FLOAT_REGISTER_NUMBER - 1)
172 #define NDS32_IS_EXT_FPR_REGNUM(regno) \
173 (((regno) >= NDS32_FIRST_FPR_REGNUM + 32) \
174 && ((regno) < NDS32_FIRST_FPR_REGNUM + 64))
176 #define NDS32_IS_FPR_REGNUM(regno) \
177 (((regno) >= NDS32_FIRST_FPR_REGNUM) \
178 && ((regno) <= NDS32_LAST_FPR_REGNUM))
180 #define NDS32_FPR_REGNO_OK_FOR_SINGLE(regno) \
181 ((regno) <= NDS32_LAST_FPR_REGNUM)
183 #define NDS32_FPR_REGNO_OK_FOR_DOUBLE(regno) \
184 ((((regno) - NDS32_FIRST_FPR_REGNUM) & 1) == 0)
186 #define NDS32_IS_GPR_REGNUM(regno) \
187 (((regno) <= NDS32_LAST_GPR_REGNUM))
189 /* Define double word alignment bits. */
190 #define NDS32_DOUBLE_WORD_ALIGNMENT 64
192 /* Define alignment checking macros for convenience. */
193 #define NDS32_HALF_WORD_ALIGN_P(value) (((value) & 0x01) == 0)
194 #define NDS32_SINGLE_WORD_ALIGN_P(value) (((value) & 0x03) == 0)
195 #define NDS32_DOUBLE_WORD_ALIGN_P(value) (((value) & 0x07) == 0)
197 /* Get alignment according to mode or type information.
198 When 'type' is nonnull, there is no need to look at 'mode'. */
199 #define NDS32_MODE_TYPE_ALIGN(mode, type) \
200 (type ? TYPE_ALIGN (type) : GET_MODE_ALIGNMENT (mode))
202 /* Round X up to the nearest double word. */
203 #define NDS32_ROUND_UP_DOUBLE_WORD(value) (((value) + 7) & ~7)
206 /* This macro is used to calculate the numbers of registers for
207 containing 'size' bytes of the argument.
208 The size of a register is a word in nds32 target.
209 So we use UNITS_PER_WORD to do the calculation. */
210 #define NDS32_NEED_N_REGS_FOR_ARG(mode, type) \
212 ? ((int_size_in_bytes (type) + UNITS_PER_WORD - 1) / UNITS_PER_WORD) \
213 : ((GET_MODE_SIZE (mode) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
215 /* This macro is used to return the register number for passing argument.
216 We need to obey the following rules:
217 1. If it is required MORE THAN one register,
218 we need to further check if it really needs to be
219 aligned on double words.
220 a) If double word alignment is necessary,
221 the register number must be even value.
222 b) Otherwise, the register number can be odd or even value.
223 2. If it is required ONLY one register,
224 the register number can be odd or even value. */
225 #define NDS32_AVAILABLE_REGNUM_FOR_GPR_ARG(reg_offset, mode, type) \
226 ((NDS32_NEED_N_REGS_FOR_ARG (mode, type) > 1) \
227 ? ((NDS32_MODE_TYPE_ALIGN (mode, type) > PARM_BOUNDARY) \
228 ? (((reg_offset) + NDS32_GPR_ARG_FIRST_REGNUM + 1) & ~1) \
229 : ((reg_offset) + NDS32_GPR_ARG_FIRST_REGNUM)) \
230 : ((reg_offset) + NDS32_GPR_ARG_FIRST_REGNUM))
232 #define NDS32_AVAILABLE_REGNUM_FOR_FPR_ARG(reg_offset, mode, type) \
233 ((NDS32_NEED_N_REGS_FOR_ARG (mode, type) > 1) \
234 ? ((NDS32_MODE_TYPE_ALIGN (mode, type) > PARM_BOUNDARY) \
235 ? (((reg_offset) + NDS32_FPR_ARG_FIRST_REGNUM + 1) & ~1) \
236 : ((reg_offset) + NDS32_FPR_ARG_FIRST_REGNUM)) \
237 : ((reg_offset) + NDS32_FPR_ARG_FIRST_REGNUM))
239 /* These two macros are to check if there are still available registers
240 for passing argument, which must be entirely in registers. */
241 #define NDS32_ARG_ENTIRE_IN_GPR_REG_P(reg_offset, mode, type) \
242 ((NDS32_AVAILABLE_REGNUM_FOR_GPR_ARG (reg_offset, mode, type) \
243 + NDS32_NEED_N_REGS_FOR_ARG (mode, type)) \
244 <= (NDS32_GPR_ARG_FIRST_REGNUM \
245 + NDS32_MAX_GPR_REGS_FOR_ARGS))
247 #define NDS32_ARG_ENTIRE_IN_FPR_REG_P(reg_offset, mode, type) \
248 ((NDS32_AVAILABLE_REGNUM_FOR_FPR_ARG (reg_offset, mode, type) \
249 + NDS32_NEED_N_REGS_FOR_ARG (mode, type)) \
250 <= (NDS32_FPR_ARG_FIRST_REGNUM \
251 + NDS32_MAX_FPR_REGS_FOR_ARGS))
253 /* These two macros are to check if there are still available registers
254 for passing argument, either entirely in registers or partially
256 #define NDS32_ARG_PARTIAL_IN_GPR_REG_P(reg_offset, mode, type) \
257 (NDS32_AVAILABLE_REGNUM_FOR_GPR_ARG (reg_offset, mode, type) \
258 < NDS32_GPR_ARG_FIRST_REGNUM + NDS32_MAX_GPR_REGS_FOR_ARGS)
260 #define NDS32_ARG_PARTIAL_IN_FPR_REG_P(reg_offset, mode, type) \
261 (NDS32_AVAILABLE_REGNUM_FOR_FPR_ARG (reg_offset, mode, type) \
262 < NDS32_FPR_ARG_FIRST_REGNUM + NDS32_MAX_FPR_REGS_FOR_ARGS)
264 /* This macro is to check if the register is required to be saved on stack.
265 If call_used_regs[regno] == 0, regno is the callee-saved register.
266 If df_regs_ever_live_p(regno) == true, it is used in the current function.
267 As long as the register satisfies both criteria above,
268 it is required to be saved. */
269 #define NDS32_REQUIRED_CALLEE_SAVED_P(regno) \
270 ((!call_used_regs[regno]) && (df_regs_ever_live_p (regno)))
272 /* This macro is to check if the push25/pop25 are available to be used
273 for code generation. Because pop25 also performs return behavior,
274 the instructions may not be available for some cases.
275 If we want to use push25/pop25, all the following conditions must
277 1. TARGET_V3PUSH is set.
278 2. Current function is not an ISR function.
279 3. Current function is not a variadic function.*/
280 #define NDS32_V3PUSH_AVAILABLE_P \
282 && !nds32_isr_function_p (current_function_decl) \
283 && (cfun->machine->va_args_size == 0))
285 /* ------------------------------------------------------------------------ */
287 /* A C structure for machine-specific, per-function data.
288 This is added to the cfun structure. */
289 struct GTY(()) machine_function
291 /* Number of bytes allocated on the stack for variadic args
292 if we want to push them into stack as pretend arguments by ourself. */
294 /* Number of bytes reserved on the stack for
295 local and temporary variables. */
297 /* Number of bytes allocated on the stack for outgoing arguments. */
300 /* Number of bytes on the stack for saving $fp. */
302 /* Number of bytes on the stack for saving $gp. */
304 /* Number of bytes on the stack for saving $lp. */
307 /* Number of bytes on the stack for saving general purpose
308 callee-saved registers. */
309 int callee_saved_gpr_regs_size
;
311 /* Number of bytes on the stack for saving floating-point
312 callee-saved registers. */
313 int callee_saved_fpr_regs_size
;
315 /* The padding bytes in callee-saved area may be required. */
316 int callee_saved_area_gpr_padding_bytes
;
318 /* The first required general purpose callee-saved register. */
319 int callee_saved_first_gpr_regno
;
320 /* The last required general purpose callee-saved register. */
321 int callee_saved_last_gpr_regno
;
323 /* The first required floating-point callee-saved register. */
324 int callee_saved_first_fpr_regno
;
325 /* The last required floating-point callee-saved register. */
326 int callee_saved_last_fpr_regno
;
328 /* The padding bytes in varargs area may be required. */
329 int va_args_area_padding_bytes
;
331 /* The first required register that should be saved on stack for va_args. */
332 int va_args_first_regno
;
333 /* The last required register that should be saved on stack for va_args. */
334 int va_args_last_regno
;
336 /* Indicate that whether this function needs
337 prologue/epilogue code generation. */
339 /* Indicate that whether this function
340 uses fp_as_gp optimization. */
344 /* A C structure that contains the arguments information. */
347 unsigned int gpr_offset
;
348 unsigned int fpr_offset
;
349 } nds32_cumulative_args
;
351 /* ------------------------------------------------------------------------ */
353 /* The following we define C-ISR related stuff.
354 In nds32 architecture, we have 73 vectors for interrupt/exception.
355 For each vector (except for vector 0, which is used for reset behavior),
356 we allow users to set its register saving scheme and interrupt level. */
358 /* There are 73 vectors in nds32 architecture.
360 1-8 for exception handler,
361 and 9-72 for interrupt handler.
362 We use an array, which is defined in nds32.c, to record
363 essential information for each vector. */
364 #define NDS32_N_ISR_VECTORS 73
366 /* Define possible isr category. */
367 enum nds32_isr_category
375 /* Define isr register saving scheme. */
376 enum nds32_isr_save_reg
382 /* Define isr nested type. */
383 enum nds32_isr_nested_type
390 /* Define structure to record isr information.
391 The isr vector array 'isr_vectors[]' with this structure
392 is defined in nds32.c. */
393 struct nds32_isr_info
395 /* The field to identify isr category.
396 It should be set to NDS32_ISR_NONE by default.
397 If user specifies a function as isr by using attribute,
398 this field will be set accordingly. */
399 enum nds32_isr_category category
;
401 /* A string for the applied function name.
402 It should be set to empty string by default. */
405 /* The register saving scheme.
406 It should be set to NDS32_PARTIAL_SAVE by default
407 unless user specifies attribute to change it. */
408 enum nds32_isr_save_reg save_reg
;
411 It should be set to NDS32_NOT_NESTED by default
412 unless user specifies attribute to change it. */
413 enum nds32_isr_nested_type nested_type
;
416 The total vectors = interrupt + exception numbers + reset.
417 It should be set to 0 by default.
418 This field is ONLY used in NDS32_ISR_RESET category. */
419 unsigned int total_n_vectors
;
421 /* A string for nmi handler name.
422 It should be set to empty string by default.
423 This field is ONLY used in NDS32_ISR_RESET category. */
426 /* A string for warm handler name.
427 It should be set to empty string by default.
428 This field is ONLY used in NDS32_ISR_RESET category. */
432 /* ------------------------------------------------------------------------ */
434 /* Define code for all nds32 builtins. */
443 NDS32_BUILTIN_SETGIE_EN
,
444 NDS32_BUILTIN_SETGIE_DIS
,
445 NDS32_BUILTIN_FMFCFG
,
446 NDS32_BUILTIN_FMFCSR
,
447 NDS32_BUILTIN_FMTCSR
,
448 NDS32_BUILTIN_FCPYNSS
,
449 NDS32_BUILTIN_FCPYSS
,
450 NDS32_BUILTIN_FCPYNSD
,
451 NDS32_BUILTIN_FCPYSD
,
453 NDS32_BUILTIN_FFMISM
,
454 NDS32_BUILTIN_FLMISM
,
455 NDS32_BUILTIN_UALOAD_HW
,
456 NDS32_BUILTIN_UALOAD_W
,
457 NDS32_BUILTIN_UALOAD_DW
,
458 NDS32_BUILTIN_UASTORE_HW
,
459 NDS32_BUILTIN_UASTORE_W
,
460 NDS32_BUILTIN_UASTORE_DW
,
464 /* ------------------------------------------------------------------------ */
466 #define TARGET_ISA_V2 (nds32_arch_option == ARCH_V2)
468 #define TARGET_ISA_V3 \
469 (nds32_arch_option == ARCH_V3 \
470 || nds32_arch_option == ARCH_V3F \
471 || nds32_arch_option == ARCH_V3S)
472 #define TARGET_ISA_V3M (nds32_arch_option == ARCH_V3M)
474 #define TARGET_CMODEL_SMALL \
475 (nds32_cmodel_option == CMODEL_SMALL)
476 #define TARGET_CMODEL_MEDIUM \
477 (nds32_cmodel_option == CMODEL_MEDIUM)
478 #define TARGET_CMODEL_LARGE \
479 (nds32_cmodel_option == CMODEL_LARGE)
481 /* When -mcmodel=small or -mcmodel=medium,
482 compiler may generate gp-base instruction directly. */
483 #define TARGET_GP_DIRECT \
484 (nds32_cmodel_option == CMODEL_SMALL\
485 || nds32_cmodel_option == CMODEL_MEDIUM)
488 /* Run-time Target Specification. */
489 #define TARGET_SOFT_FLOAT (nds32_abi == NDS32_ABI_V2)
490 /* Use hardware floating point calling convention. */
491 #define TARGET_HARD_FLOAT (nds32_abi == NDS32_ABI_V2_FP_PLUS)
493 /* Record arch version in TARGET_ARCH_DEFAULT. 0 means soft ABI,
494 1 means hard ABI and using full floating-point instruction,
495 2 means hard ABI and only using single-precision floating-point
497 #if TARGET_ARCH_DEFAULT == 1
498 # define TARGET_DEFAULT_ABI NDS32_ABI_V2_FP_PLUS
499 # define TARGET_DEFAULT_FPU_ISA MASK_FPU_DOUBLE | MASK_FPU_SINGLE
500 # define TARGET_DEFAULT_FPU_FMA 0
502 # if TARGET_ARCH_DEFAULT == 2
503 # define TARGET_DEFAULT_ABI NDS32_ABI_V2_FP_PLUS
504 # define TARGET_DEFAULT_FPU_ISA MASK_FPU_SINGLE
505 # define TARGET_DEFAULT_FPU_FMA 0
507 # define TARGET_DEFAULT_ABI NDS32_ABI_V2
508 # define TARGET_DEFAULT_FPU_ISA 0
509 # define TARGET_DEFAULT_FPU_FMA 0
513 #define TARGET_CONFIG_FPU_DEFAULT NDS32_CONFIG_FPU_2
514 /* ------------------------------------------------------------------------ */
516 /* Controlling the Compilation Driver. */
518 #define OPTION_DEFAULT_SPECS \
519 {"arch", " %{!march=*:-march=%(VALUE)}" \
520 " %{march=v3f:%{!mfloat-abi=*:-mfloat-abi=hard}" \
521 " %{!mno-ext-fpu-sp:%{!mext-fpu-sp:-mext-fpu-sp}}" \
522 " %{!mno-ext-fpu-dp:%{!mext-fpu-dp:-mext-fpu-dp}}}" \
523 " %{march=v3s:%{!mfloat-abi=*:-mfloat-abi=hard}" \
524 " %{!mno-ext-fpu-sp:%{!mext-fpu-sp:-mext-fpu-sp}}}" }, \
525 {"float", "%{!mfloat-abi=*:-mfloat-abi=%(VALUE)}" }
531 " %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
532 " %{march=*:-march=%*}" \
533 " %{mabi=*:-mabi=v%*}" \
534 " %{mconfig-fpu=*:-mfpu-freg=%*}" \
535 " %{mext-fpu-mac:-mmac}" \
536 " %{mno-ext-fpu-mac:-mno-mac}" \
537 " %{mext-fpu-sp:-mfpu-sp-ext}" \
538 " %{mno-ext-fpu-sp:-mno-fpu-sp-ext}" \
539 " %{mext-fpu-dp:-mfpu-dp-ext}" \
540 " %{mno-ext-fpu-sp:-mno-fpu-dp-ext}"
542 /* If user issues -mrelax, we need to pass '--relax' to linker. */
544 " %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
550 /* The option -mno-ctor-dtor can disable constructor/destructor feature
551 by applying different crt stuff. In the convention, crt0.o is the
552 startup file without constructor/destructor;
553 crt1.o, crti.o, crtbegin.o, crtend.o, and crtn.o are the
554 startup files with constructor/destructor.
555 Note that crt0.o, crt1.o, crti.o, and crtn.o are provided
556 by newlib/mculib/glibc/ublic, while crtbegin.o and crtend.o are
557 currently provided by GCC for nds32 target.
559 For nds32 target so far:
560 If -mno-ctor-dtor, we are going to link
561 "crt0.o [user objects]".
562 If general cases, we are going to link
563 "crt1.o crtbegin1.o [user objects] crtend1.o". */
564 #define STARTFILE_SPEC \
565 " %{!mno-ctor-dtor:crt1.o%s;:crt0.o%s}" \
566 " %{!mno-ctor-dtor:crtbegin1.o%s}"
567 #define ENDFILE_SPEC \
568 " %{!mno-ctor-dtor:crtend1.o%s}"
570 /* The TARGET_BIG_ENDIAN_DEFAULT is defined if we
571 configure gcc with --target=nds32be-* setting.
572 Check gcc/config.gcc for more information. */
573 #ifdef TARGET_BIG_ENDIAN_DEFAULT
574 # define NDS32_ENDIAN_DEFAULT "mbig-endian"
576 # define NDS32_ENDIAN_DEFAULT "mlittle-endian"
579 /* Currently we only have elf toolchain,
580 where -mcmodel=medium is always the default. */
581 #define NDS32_CMODEL_DEFAULT "mcmodel=medium"
583 #define MULTILIB_DEFAULTS \
584 { NDS32_ENDIAN_DEFAULT, NDS32_CMODEL_DEFAULT }
587 /* Run-time Target Specification. */
589 #define TARGET_CPU_CPP_BUILTINS() \
590 nds32_cpu_cpp_builtins (pfile)
593 /* Defining Data Structures for Per-function Information. */
595 /* This macro is called once per function,
596 before generation of any RTL has begun. */
597 #define INIT_EXPANDERS nds32_init_expanders ()
600 /* Storage Layout. */
602 #define BITS_BIG_ENDIAN 0
604 #define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN)
606 #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN)
608 #define UNITS_PER_WORD 4
610 #define PROMOTE_MODE(m, unsignedp, type) \
611 if (GET_MODE_CLASS (m) == MODE_INT && GET_MODE_SIZE (m) < UNITS_PER_WORD) \
616 #define PARM_BOUNDARY 32
618 #define STACK_BOUNDARY 64
620 #define FUNCTION_BOUNDARY 32
622 #define BIGGEST_ALIGNMENT 64
624 #define EMPTY_FIELD_BOUNDARY 32
626 #define STRUCTURE_SIZE_BOUNDARY 8
628 #define STRICT_ALIGNMENT 1
630 #define PCC_BITFIELD_TYPE_MATTERS 1
633 /* Layout of Source Language Data Types. */
635 #define INT_TYPE_SIZE 32
636 #define SHORT_TYPE_SIZE 16
637 #define LONG_TYPE_SIZE 32
638 #define LONG_LONG_TYPE_SIZE 64
640 #define FLOAT_TYPE_SIZE 32
641 #define DOUBLE_TYPE_SIZE 64
642 #define LONG_DOUBLE_TYPE_SIZE 64
644 #define DEFAULT_SIGNED_CHAR 1
646 #define SIZE_TYPE "long unsigned int"
647 #define PTRDIFF_TYPE "long int"
648 #define WCHAR_TYPE "unsigned int"
649 #define WCHAR_TYPE_SIZE 32
652 /* Register Usage. */
654 /* Number of actual hardware registers.
655 The hardware registers are assigned numbers for the compiler
656 from 0 to just below FIRST_PSEUDO_REGISTER.
657 All registers that the compiler knows about must be given numbers,
658 even those that are not normally considered general registers. */
659 #define FIRST_PSEUDO_REGISTER 101
661 /* An initializer that says which registers are used for fixed
662 purposes all throughout the compiled code and are therefore
663 not available for general allocation.
670 caller-save registers: $r0 ~ $r5, $r16 ~ $r23, $fs0 ~ $fs5, $fs22 ~ $fs47
671 callee-save registers: $r6 ~ $r10, $r11 ~ $r14, $fs6 ~ $fs21, $fs48 ~ $fs63
673 reserved for assembler : $r15
674 reserved for other use : $r24, $r25, $r26, $r27 */
675 #define FIXED_REGISTERS \
676 { /* r0 r1 r2 r3 r4 r5 r6 r7 */ \
677 0, 0, 0, 0, 0, 0, 0, 0, \
678 /* r8 r9 r10 r11 r12 r13 r14 r15 */ \
679 0, 0, 0, 0, 0, 0, 0, 1, \
680 /* r16 r17 r18 r19 r20 r21 r22 r23 */ \
681 0, 0, 0, 0, 0, 0, 0, 0, \
682 /* r24 r25 r26 r27 r28 r29 r30 r31 */ \
683 1, 1, 1, 1, 0, 1, 0, 1, \
684 /* AP FP fs0 fs1 fs2 fs3 fs4 fs5 */ \
685 1, 1, 1, 1, 1, 1, 1, 1, \
686 /* fs6 fs7 fs8 fs9 fs10 fs11 fs12 fs13 */ \
687 1, 1, 1, 1, 1, 1, 1, 1, \
688 /* fs14 fs15 fs16 fs17 fs18 fs19 fs20 fs21 */ \
689 1, 1, 1, 1, 1, 1, 1, 1, \
690 /* fs22 fs23 fs24 fs25 fs26 fs27 fs28 fs29 */ \
691 1, 1, 1, 1, 1, 1, 1, 1, \
692 /* fs30 fs31 fd16 fd17 fd18 */ \
693 1, 1, 1, 1, 1, 1, 1, 1, \
694 /* fd19 fd20 fd21 fd22 */ \
695 1, 1, 1, 1, 1, 1, 1, 1, \
696 /* fd23 fd24 fd25 fd26 */ \
697 1, 1, 1, 1, 1, 1, 1, 1, \
698 /* fd27 fd28 fd29 fd30 */ \
699 1, 1, 1, 1, 1, 1, 1, 1, \
700 /* fd31 Reserved..................... */ \
704 /* Identifies the registers that are not available for
705 general allocation of values that must live across
706 function calls -- so they are caller-save registers.
708 0 : callee-save registers
709 1 : caller-save registers */
710 #define CALL_USED_REGISTERS \
711 { /* r0 r1 r2 r3 r4 r5 r6 r7 */ \
712 1, 1, 1, 1, 1, 1, 0, 0, \
713 /* r8 r9 r10 r11 r12 r13 r14 r15 */ \
714 0, 0, 0, 0, 0, 0, 0, 1, \
715 /* r16 r17 r18 r19 r20 r21 r22 r23 */ \
716 1, 1, 1, 1, 1, 1, 1, 1, \
717 /* r24 r25 r26 r27 r28 r29 r30 r31 */ \
718 1, 1, 1, 1, 0, 1, 0, 1, \
719 /* AP FP fs0 fs1 fs2 fs3 fs4 fs5 */ \
720 1, 1, 1, 1, 1, 1, 1, 1, \
721 /* fs6 fs7 fs8 fs9 fs10 fs11 fs12 fs13 */ \
722 1, 1, 1, 1, 1, 1, 1, 1, \
723 /* fs14 fs15 fs16 fs17 fs18 fs19 fs20 fs21 */ \
724 1, 1, 1, 1, 1, 1, 1, 1, \
725 /* fs22 fs23 fs24 fs25 fs26 fs27 fs28 fs29 */ \
726 1, 1, 1, 1, 1, 1, 1, 1, \
727 /* fs30 fs31 fd16 fd17 fd18 */ \
728 1, 1, 1, 1, 1, 1, 1, 1, \
729 /* fd19 fd20 fd21 fd22 */ \
730 1, 1, 1, 1, 1, 1, 1, 1, \
731 /* fd23 fd24 fd25 fd26 */ \
732 1, 1, 1, 1, 1, 1, 1, 1, \
733 /* fd27 fd28 fd29 fd30 */ \
734 1, 1, 1, 1, 1, 1, 1, 1, \
735 /* fd31 Reserved..................... */ \
739 /* In nds32 target, we have three levels of registers:
740 LOW_COST_REGS : $r0 ~ $r7
741 MIDDLE_COST_REGS : $r8 ~ $r11, $r16 ~ $r19
742 HIGH_COST_REGS : $r12 ~ $r14, $r20 ~ $r31 */
743 #define REG_ALLOC_ORDER \
744 { 0, 1, 2, 3, 4, 5, 6, 7, \
745 16, 17, 18, 19, 9, 10, 11, 12, \
746 13, 14, 8, 15, 20, 21, 22, 23, \
747 24, 25, 26, 27, 28, 29, 30, 31, \
748 32, 33, 34, 35, 36, 37, 38, 39, \
749 40, 41, 42, 43, 44, 45, 46, 47, \
750 48, 49, 50, 51, 52, 53, 54, 55, \
751 56, 57, 58, 59, 60, 61, 62, 63, \
752 64, 65, 66, 67, 68, 69, 70, 71, \
753 72, 73, 74, 75, 76, 77, 78, 79, \
754 80, 81, 82, 83, 84, 85, 86, 87, \
755 88, 89, 90, 91, 92, 93, 94, 95, \
756 96, 97, 98, 99, 100, \
759 /* ADJUST_REG_ALLOC_ORDER is a macro which permits reg_alloc_order
760 to be rearranged based on optimizing for speed or size. */
761 #define ADJUST_REG_ALLOC_ORDER nds32_adjust_reg_alloc_order ()
763 /* Tell IRA to use the order we define rather than messing it up with its
764 own cost calculations. */
765 #define HONOR_REG_ALLOC_ORDER optimize_size
768 /* Register Classes. */
770 /* In nds32 target, we have three levels of registers:
771 Low cost regsiters : $r0 ~ $r7
772 Middle cost registers : $r8 ~ $r11, $r16 ~ $r19
773 High cost registers : $r12 ~ $r14, $r20 ~ $r31
775 In practice, we have MIDDLE_REGS cover LOW_REGS register class contents
776 so that it provides more chance to use low cost registers. */
795 #define N_REG_CLASSES (int) LIM_REG_CLASSES
797 #define REG_CLASS_NAMES \
804 "FRAME_POINTER_REG", \
814 #define REG_CLASS_CONTENTS \
816 {0x00000000, 0x00000000, 0x00000000, 0x00000000}, \
818 {0x00000020, 0x00000000, 0x00000000, 0x00000000}, \
820 {0x00000100, 0x00000000, 0x00000000, 0x00000000}, \
821 /* R15_TA_REG : 15 */ \
822 {0x00008000, 0x00000000, 0x00000000, 0x00000000}, \
823 /* STACK_REG : 31 */ \
824 {0x80000000, 0x00000000, 0x00000000, 0x00000000}, \
825 /* FRAME_POINTER_REG : 28 */ \
826 {0x10000000, 0x00000000, 0x00000000, 0x00000000}, \
827 /* LOW_REGS : 0-7 */ \
828 {0x000000ff, 0x00000000, 0x00000000, 0x00000000}, \
829 /* MIDDLE_REGS : 0-11, 16-19 */ \
830 {0x000f0fff, 0x00000000, 0x00000000, 0x00000000}, \
831 /* HIGH_REGS : 12-14, 20-31 */ \
832 {0xfff07000, 0x00000000, 0x00000000, 0x00000000}, \
833 /* GENERAL_REGS : 0-31 */ \
834 {0xffffffff, 0x00000000, 0x00000000, 0x00000000}, \
835 /* FRAME_REGS : 32, 33 */ \
836 {0x00000000, 0x00000003, 0x00000000, 0x00000000}, \
837 /* FP_REGS : 34-98 */ \
838 {0x00000000, 0xfffffffc, 0xffffffff, 0x00000003}, \
839 /* ALL_REGS : 0-100 */ \
840 {0xffffffff, 0xffffffff, 0xffffffff, 0x0000001f} \
843 #define REGNO_REG_CLASS(regno) nds32_regno_reg_class (regno)
845 #define BASE_REG_CLASS GENERAL_REGS
846 #define INDEX_REG_CLASS GENERAL_REGS
848 #define TEST_REGNO(R, TEST, VALUE) \
849 ((R TEST VALUE) || ((unsigned) reg_renumber[R] TEST VALUE))
851 /* Return nonzero if it is suitable for use as a
852 base register in operand addresses.
853 So far, we return nonzero only if "num" is a hard reg
854 of the suitable class or a pseudo register which is
855 allocated to a suitable hard reg. */
856 #define REGNO_OK_FOR_BASE_P(num) \
857 (TEST_REGNO (num, <, 32) \
858 || TEST_REGNO (num, ==, FRAME_POINTER_REGNUM) \
859 || TEST_REGNO (num, ==, ARG_POINTER_REGNUM))
861 /* Return nonzero if it is suitable for use as a
862 index register in operand addresses.
863 So far, we return nonzero only if "num" is a hard reg
864 of the suitable class or a pseudo register which is
865 allocated to a suitable hard reg.
866 The difference between an index register and a base register is that
867 the index register may be scaled. */
868 #define REGNO_OK_FOR_INDEX_P(num) \
869 (TEST_REGNO (num, <, 32) \
870 || TEST_REGNO (num, ==, FRAME_POINTER_REGNUM) \
871 || TEST_REGNO (num, ==, ARG_POINTER_REGNUM))
874 /* Obsolete Macros for Defining Constraints. */
877 /* Stack Layout and Calling Conventions. */
879 #define STACK_GROWS_DOWNWARD 1
881 #define FRAME_GROWS_DOWNWARD 1
883 #define STACK_POINTER_OFFSET 0
885 #define FIRST_PARM_OFFSET(fundecl) \
886 (NDS32_DOUBLE_WORD_ALIGN_P (crtl->args.pretend_args_size) ? 0 : 4)
888 #define RETURN_ADDR_RTX(count, frameaddr) \
889 nds32_return_addr_rtx (count, frameaddr)
891 /* A C expression whose value is RTL representing the location
892 of the incoming return address at the beginning of any function
894 If this RTL is REG, you should also define
895 DWARF_FRAME_RETURN_COLUMN to DWARF_FRAME_REGNUM (REGNO). */
896 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LP_REGNUM)
897 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (LP_REGNUM)
899 #define DBX_REGISTER_NUMBER(REGNO) nds32_dbx_register_number (REGNO)
901 #define STACK_POINTER_REGNUM SP_REGNUM
903 #define FRAME_POINTER_REGNUM 33
905 #define HARD_FRAME_POINTER_REGNUM FP_REGNUM
907 #define ARG_POINTER_REGNUM 32
909 #define STATIC_CHAIN_REGNUM 16
911 #define ELIMINABLE_REGS \
912 { { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
913 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
914 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
915 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM } }
917 #define INITIAL_ELIMINATION_OFFSET(from_reg, to_reg, offset_var) \
918 (offset_var) = nds32_initial_elimination_offset (from_reg, to_reg)
920 #define ACCUMULATE_OUTGOING_ARGS 1
922 #define OUTGOING_REG_PARM_STACK_SPACE(fntype) 1
924 #define CUMULATIVE_ARGS nds32_cumulative_args
926 #define INIT_CUMULATIVE_ARGS(cum, fntype, libname, fndecl, n_named_args) \
927 nds32_init_cumulative_args (&cum, fntype, libname, fndecl, n_named_args)
929 #define FUNCTION_ARG_REGNO_P(regno) \
930 (IN_RANGE ((regno), NDS32_FIRST_GPR_REGNUM, NDS32_MAX_GPR_REGS_FOR_ARGS - 1) \
931 || ((TARGET_FPU_SINGLE || TARGET_FPU_DOUBLE) \
932 && IN_RANGE ((regno), NDS32_FPR_ARG_FIRST_REGNUM, \
933 NDS32_FIRST_FPR_REGNUM + NDS32_MAX_FPR_REGS_FOR_ARGS - 1)))
935 #define DEFAULT_PCC_STRUCT_RETURN 0
937 /* EXIT_IGNORE_STACK should be nonzero if, when returning
938 from a function, the stack pointer does not matter.
939 The value is tested only in functions that have frame pointers.
940 In nds32 target, the function epilogue recovers the
941 stack pointer from the frame. */
942 #define EXIT_IGNORE_STACK 1
944 #define FUNCTION_PROFILER(file, labelno) \
945 fprintf (file, "/* profiler %d */\n", (labelno))
947 #define PROFILE_HOOK(LABEL) \
950 lp = get_hard_reg_initial_val (Pmode, LP_REGNUM); \
951 fun = gen_rtx_SYMBOL_REF (Pmode, "_mcount"); \
952 emit_library_call (fun, LCT_NORMAL, VOIDmode, lp, Pmode); \
956 /* Implementing the Varargs Macros. */
959 /* Trampolines for Nested Functions. */
961 /* Giving A-function and B-function,
962 if B-function wants to call A-function's nested function,
963 we need to fill trampoline code into A-function's stack
964 so that B-function can execute the code in stack to indirectly
965 jump to (like 'trampoline' action) desired nested function.
967 The trampoline code for nds32 target must contains following parts:
969 1. instructions (4 * 4 = 16 bytes):
971 load chain_value to static chain register via $pc
972 load nested function address to $r15 via $pc
973 jump to desired nested function via $r15
974 2. data (4 * 2 = 8 bytes):
976 nested function address
978 Please check nds32.c implementation for more information. */
979 #define TRAMPOLINE_SIZE 24
981 /* Because all instructions/data in trampoline template are 4-byte size,
982 we set trampoline alignment 8*4=32 bits. */
983 #define TRAMPOLINE_ALIGNMENT 32
986 /* Implicit Calls to Library Routines. */
989 /* Addressing Modes. */
991 /* We can use "LWI.bi Rt, [Ra], 4" to support post increment. */
992 #define HAVE_POST_INCREMENT 1
993 /* We can use "LWI.bi Rt, [Ra], -4" to support post decrement. */
994 #define HAVE_POST_DECREMENT 1
996 /* We have "LWI.bi Rt, [Ra], imm" instruction form. */
997 #define HAVE_POST_MODIFY_DISP 1
998 /* We have "LW.bi Rt, [Ra], Rb" instruction form. */
999 #define HAVE_POST_MODIFY_REG 1
1001 #define CONSTANT_ADDRESS_P(x) (CONSTANT_P (x) && GET_CODE (x) != CONST_DOUBLE)
1003 #define MAX_REGS_PER_ADDRESS 3
1006 /* Anchored Addresses. */
1009 /* Condition Code Status. */
1012 /* Describing Relative Costs of Operations. */
1014 /* A C expression for the cost of a branch instruction.
1015 A value of 1 is the default;
1016 other values are interpreted relative to that. */
1017 #define BRANCH_COST(speed_p, predictable_p) ((speed_p) ? 2 : 1)
1019 /* Override BRANCH_COST heuristic which empirically produces worse
1020 performance for removing short circuiting from the logical ops. */
1021 #define LOGICAL_OP_NON_SHORT_CIRCUIT 0
1023 #define SLOW_BYTE_ACCESS 1
1025 #define NO_FUNCTION_CSE 1
1028 /* Adjusting the Instruction Scheduler. */
1031 /* Dividing the Output into Sections (Texts, Data, . . . ). */
1033 #define TEXT_SECTION_ASM_OP "\t.text"
1034 #define DATA_SECTION_ASM_OP "\t.data"
1036 /* Currently, nds32 assembler does NOT handle '.bss' pseudo-op.
1037 So we use '.section .bss' alternatively. */
1038 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
1040 /* Define this macro to be an expression with a nonzero value if jump tables
1041 (for tablejump insns) should be output in the text section,
1042 along with the assembler instructions.
1043 Otherwise, the readonly data section is used. */
1044 #define JUMP_TABLES_IN_TEXT_SECTION 1
1047 /* Position Independent Code. */
1049 #define PIC_OFFSET_TABLE_REGNUM GP_REGNUM
1052 /* Defining the Output Assembler Language. */
1054 #define ASM_COMMENT_START "!"
1056 #define ASM_APP_ON "! #APP"
1058 #define ASM_APP_OFF "! #NO_APP\n"
1060 #define ASM_OUTPUT_LABELREF(stream, name) \
1061 asm_fprintf (stream, "%U%s", (*targetm.strip_name_encoding) (name))
1063 #define ASM_OUTPUT_SYMBOL_REF(stream, sym) \
1064 assemble_name (stream, XSTR (sym, 0))
1066 #define ASM_OUTPUT_LABEL_REF(stream, buf) \
1067 assemble_name (stream, buf)
1069 #define LOCAL_LABEL_PREFIX "."
1071 #define REGISTER_NAMES \
1072 { "$r0", "$r1", "$r2", "$r3", "$r4", "$r5", "$r6", "$r7", \
1073 "$r8", "$r9", "$r10", "$r11", "$r12", "$r13", "$r14", "$ta", \
1074 "$r16", "$r17", "$r18", "$r19", "$r20", "$r21", "$r22", "$r23", \
1075 "$r24", "$r25", "$r26", "$r27", "$fp", "$gp", "$lp", "$sp", \
1076 "$AP", "$SFP", "$fs0", "$fs1", "$fs2", "$fs3", "$fs4", "$fs5", \
1077 "$fs6", "$fs7", "$fs8", "$fs9", "$fs10","$fs11","$fs12","$fs13",\
1078 "$fs14","$fs15","$fs16","$fs17","$fs18","$fs19","$fs20","$fs21",\
1079 "$fs22","$fs23","$fs24","$fs25","$fs26","$fs27","$fs28","$fs29",\
1080 "$fs30","$fs31","$fs32","$fs33","$fs34","$fs35","$fs36","$fs37",\
1081 "$fs38","$fs39","$fs40","$fs41","$fs42","$fs43","$fs44","$fs45",\
1082 "$fs46","$fs47","$fs48","$fs49","$fs50","$fs51","$fs52","$fs53",\
1083 "$fs54","$fs55","$fs56","$fs57","$fs58","$fs59","$fs60","$fs61",\
1084 "$fs62","$fs63", "LB", "LE", "LC" \
1087 #define ADDITIONAL_REGISTER_NAMES \
1090 {"$r28", 28}, {"$r29", 29}, {"$r30", 30}, {"$r31", 31}, \
1091 {"$a0", 0}, {"$a1", 1}, {"$a2", 2}, \
1092 {"$a3", 3}, {"$a4", 4}, {"$a5", 5}, \
1093 {"$s0", 6}, {"$s1", 7}, {"$s2", 8}, {"$s3", 9}, \
1094 {"$s4", 10}, {"$s5", 11}, {"$s6", 12}, {"$s7", 13}, \
1096 {"$t0", 16}, {"$t1", 17}, {"$t2", 18}, {"$t3", 19}, \
1097 {"$t4", 20}, {"$t5", 21}, {"$t6", 22}, {"$t7", 23}, \
1098 {"$t8", 24}, {"$t9", 25}, \
1099 {"$p0", 26}, {"$p1", 27}, \
1100 {"$h0", 0}, {"$h1", 1}, {"$h2", 2}, {"$h3", 3}, \
1101 {"$h4", 4}, {"$h5", 5}, {"$h6", 6}, {"$h7", 7}, \
1102 {"$h8", 8}, {"$h9", 9}, {"$h10", 10}, {"$h11", 11}, \
1103 {"$h12", 16}, {"$h13", 17}, {"$h14", 18}, {"$h15", 19}, \
1104 {"$o0", 0}, {"$o1", 1}, {"$o2", 2}, {"$o3", 3}, \
1105 {"$o4", 4}, {"$o5", 5}, {"$o6", 6}, {"$o7", 7}, \
1108 #define OVERLAPPING_REGISTER_NAMES \
1110 {"$fd0", NDS32_FIRST_FPR_REGNUM + 0, 2}, \
1111 {"$fd1", NDS32_FIRST_FPR_REGNUM + 2, 2}, \
1112 {"$fd2", NDS32_FIRST_FPR_REGNUM + 4, 2}, \
1113 {"$fd3", NDS32_FIRST_FPR_REGNUM + 6, 2}, \
1114 {"$fd4", NDS32_FIRST_FPR_REGNUM + 8, 2}, \
1115 {"$fd5", NDS32_FIRST_FPR_REGNUM + 10, 2}, \
1116 {"$fd6", NDS32_FIRST_FPR_REGNUM + 12, 2}, \
1117 {"$fd7", NDS32_FIRST_FPR_REGNUM + 14, 2}, \
1118 {"$fd8", NDS32_FIRST_FPR_REGNUM + 16, 2}, \
1119 {"$fd9", NDS32_FIRST_FPR_REGNUM + 18, 2}, \
1120 {"$fd10", NDS32_FIRST_FPR_REGNUM + 20, 2}, \
1121 {"$fd11", NDS32_FIRST_FPR_REGNUM + 22, 2}, \
1122 {"$fd12", NDS32_FIRST_FPR_REGNUM + 24, 2}, \
1123 {"$fd13", NDS32_FIRST_FPR_REGNUM + 26, 2}, \
1124 {"$fd14", NDS32_FIRST_FPR_REGNUM + 28, 2}, \
1125 {"$fd15", NDS32_FIRST_FPR_REGNUM + 30, 2}, \
1126 {"$fd16", NDS32_FIRST_FPR_REGNUM + 32, 2}, \
1127 {"$fd17", NDS32_FIRST_FPR_REGNUM + 34, 2}, \
1128 {"$fd18", NDS32_FIRST_FPR_REGNUM + 36, 2}, \
1129 {"$fd19", NDS32_FIRST_FPR_REGNUM + 38, 2}, \
1130 {"$fd20", NDS32_FIRST_FPR_REGNUM + 40, 2}, \
1131 {"$fd21", NDS32_FIRST_FPR_REGNUM + 42, 2}, \
1132 {"$fd22", NDS32_FIRST_FPR_REGNUM + 44, 2}, \
1133 {"$fd23", NDS32_FIRST_FPR_REGNUM + 46, 2}, \
1134 {"$fd24", NDS32_FIRST_FPR_REGNUM + 48, 2}, \
1135 {"$fd25", NDS32_FIRST_FPR_REGNUM + 50, 2}, \
1136 {"$fd26", NDS32_FIRST_FPR_REGNUM + 52, 2}, \
1137 {"$fd27", NDS32_FIRST_FPR_REGNUM + 54, 2}, \
1138 {"$fd28", NDS32_FIRST_FPR_REGNUM + 56, 2}, \
1139 {"$fd29", NDS32_FIRST_FPR_REGNUM + 58, 2}, \
1140 {"$fd30", NDS32_FIRST_FPR_REGNUM + 60, 2}, \
1141 {"$fd31", NDS32_FIRST_FPR_REGNUM + 62, 2}, \
1144 /* Output normal jump table entry. */
1145 #define ASM_OUTPUT_ADDR_VEC_ELT(stream, value) \
1146 asm_fprintf (stream, "\t.word\t%LL%d\n", value)
1148 /* Output pc relative jump table entry. */
1149 #define ASM_OUTPUT_ADDR_DIFF_ELT(stream, body, value, rel) \
1152 switch (GET_MODE (body)) \
1155 asm_fprintf (stream, "\t.byte\t.L%d-.L%d\n", value, rel); \
1158 asm_fprintf (stream, "\t.short\t.L%d-.L%d\n", value, rel); \
1161 asm_fprintf (stream, "\t.word\t.L%d-.L%d\n", value, rel); \
1164 gcc_unreachable(); \
1168 /* We have to undef it first because elfos.h formerly define it
1169 check gcc/config.gcc and gcc/config/elfos.h for more information. */
1170 #undef ASM_OUTPUT_CASE_LABEL
1171 #define ASM_OUTPUT_CASE_LABEL(stream, prefix, num, table) \
1174 asm_fprintf (stream, "\t! Jump Table Begin\n"); \
1175 (*targetm.asm_out.internal_label) (stream, prefix, num); \
1178 #define ASM_OUTPUT_CASE_END(stream, num, table) \
1181 /* Because our jump table is in text section, \
1182 we need to make sure 2-byte alignment after \
1183 the jump table for instructions fetch. */ \
1184 if (GET_MODE (PATTERN (table)) == QImode) \
1185 ASM_OUTPUT_ALIGN (stream, 1); \
1186 asm_fprintf (stream, "\t! Jump Table End\n"); \
1189 /* This macro is not documented yet.
1190 But we do need it to make jump table vector aligned. */
1191 #define ADDR_VEC_ALIGN(JUMPTABLE) 2
1193 #define DWARF2_UNWIND_INFO 1
1195 #define JUMP_ALIGN(x) \
1196 (align_jumps_log ? align_jumps_log : nds32_target_alignment (x))
1198 #define LOOP_ALIGN(x) \
1199 (align_loops_log ? align_loops_log : nds32_target_alignment (x))
1201 #define LABEL_ALIGN(x) \
1202 (align_labels_log ? align_labels_log : nds32_target_alignment (x))
1204 #define ASM_OUTPUT_ALIGN(stream, power) \
1205 fprintf (stream, "\t.align\t%d\n", power)
1208 /* Controlling Debugging Information Format. */
1210 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
1212 #define DWARF2_DEBUGGING_INFO 1
1214 #define DWARF2_ASM_LINE_DEBUG_INFO 1
1217 /* Cross Compilation and Floating Point. */
1220 /* Mode Switching Instructions. */
1223 /* Defining target-specific uses of __attribute__. */
1226 /* Emulating TLS. */
1229 /* Defining coprocessor specifics for MIPS targets. */
1232 /* Parameters for Precompiled Header Validity Checking. */
1235 /* C++ ABI parameters. */
1238 /* Adding support for named address spaces. */
1241 /* Miscellaneous Parameters. */
1243 /* This is the machine mode that elements of a jump-table should have. */
1244 #define CASE_VECTOR_MODE Pmode
1246 /* Return the preferred mode for and addr_diff_vec when the mininum
1247 and maximum offset are known. */
1248 #define CASE_VECTOR_SHORTEN_MODE(min_offset, max_offset, body) \
1249 ((min_offset < 0 || max_offset >= 0x2000 ) ? SImode \
1250 : (max_offset >= 100) ? HImode \
1253 /* Generate pc relative jump table when -fpic or -Os. */
1254 #define CASE_VECTOR_PC_RELATIVE (flag_pic || optimize_size)
1256 /* Define this macro if operations between registers with integral mode
1257 smaller than a word are always performed on the entire register. */
1258 #define WORD_REGISTER_OPERATIONS 1
1260 /* A C expression indicating when insns that read memory in mem_mode,
1261 an integral mode narrower than a word, set the bits outside of mem_mode
1262 to be either the sign-extension or the zero-extension of the data read. */
1263 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
1265 /* The maximum number of bytes that a single instruction can move quickly
1266 between memory and registers or between two memory locations. */
1269 /* A C expression that is nonzero if on this machine the number of bits
1270 actually used for the count of a shift operation is equal to the number
1271 of bits needed to represent the size of the object being shifted. */
1272 #define SHIFT_COUNT_TRUNCATED 1
1274 /* A C expression describing the value returned by a comparison operator with
1275 an integral mode and stored by a store-flag instruction ('cstoremode4')
1276 when the condition is true. */
1277 #define STORE_FLAG_VALUE 1
1279 /* A C expression that indicates whether the architecture defines a value for
1280 clz or ctz with a zero operand. In nds32 clz for 0 result 32 is defined
1282 #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 32, 1)
1284 /* An alias for the machine mode for pointers. */
1285 #define Pmode SImode
1287 /* An alias for the machine mode used for memory references to functions
1288 being called, in call RTL expressions. */
1289 #define FUNCTION_MODE SImode
1291 /* ------------------------------------------------------------------------ */