1 /* Definitions of target machine for GNU compiler, Lattice Mico32 architecture.
2 Contributed by Jon Beniston <jon@beniston.com>
4 Copyright (C) 2009, 2010 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 3, or (at your
11 option) any later version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 /*-------------------------------*/
23 /* Run-time Target Specification */
24 /*-------------------------------*/
26 /* Print subsidiary information on the compiler version in use. */
27 #ifndef TARGET_VERSION
28 #define TARGET_VERSION fprintf (stderr, " (LatticeMico32)")
31 /* Target CPU builtins. */
32 #define TARGET_CPU_CPP_BUILTINS() \
35 builtin_define ("__lm32__"); \
36 builtin_assert ("cpu=lm32"); \
37 builtin_assert ("machine=lm32"); \
38 if (TARGET_MULTIPLY_ENABLED) \
39 builtin_define ("__multiply_enabled__"); \
40 if (TARGET_DIVIDE_ENABLED) \
41 builtin_define ("__divide_enabled__"); \
42 if (TARGET_BARREL_SHIFT_ENABLED) \
43 builtin_define ("__barrel_shift_enabled__"); \
44 if (TARGET_SIGN_EXTEND_ENABLED) \
45 builtin_define ("__sign_extend_enabled__"); \
46 if (TARGET_USER_ENABLED) \
47 builtin_define ("__user_enabled__"); \
53 %{mmultiply-enabled} \
55 %{mbarrel-shift-enabled} \
56 %{msign-extend-enabled} \
57 %{muser-extend-enabled} \
61 /* Let link script define all link options.
62 Default to using simulator link script. */
65 #define STARTFILE_SPEC ""
67 #define ENDFILE_SPEC ""
69 #define LIB_SPEC "%{!T*:-T sim.ld}"
71 /* Add -G xx support. */
73 #undef SWITCH_TAKES_ARG
74 #define SWITCH_TAKES_ARG(CHAR) \
75 (DEFAULT_SWITCH_TAKES_ARG (CHAR) || (CHAR) == 'G')
78 #define CC1_SPEC "%{G*}"
80 /*---------------------------------*/
81 /* Target machine storage layout. */
82 /*---------------------------------*/
84 #define BITS_BIG_ENDIAN 0
85 #define BYTES_BIG_ENDIAN 1
86 #define WORDS_BIG_ENDIAN 1
87 #define LIBGCC2_WORDS_BIG_ENDIAN 1
89 #define BITS_PER_UNIT 8
90 #define BITS_PER_WORD 32
91 #define UNITS_PER_WORD 4
93 #define POINTER_SIZE 32
95 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
97 if (GET_MODE_CLASS (MODE) == MODE_INT \
98 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
102 #define PARM_BOUNDARY 32
104 #define STACK_BOUNDARY 32
106 #define BIGGEST_ALIGNMENT 64
108 #define FUNCTION_BOUNDARY 32
110 #define EMPTY_FIELD_BOUNDARY 32
112 #define STRICT_ALIGNMENT 1
114 #define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
116 /* Make strings word-aligned so strcpy from constants will be faster. */
117 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
118 (TREE_CODE (EXP) == STRING_CST \
119 && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
121 /* Make arrays and structures word-aligned to allow faster copying etc. */
122 #define DATA_ALIGNMENT(TYPE, ALIGN) \
123 ((((ALIGN) < BITS_PER_WORD) \
124 && (TREE_CODE (TYPE) == ARRAY_TYPE \
125 || TREE_CODE (TYPE) == UNION_TYPE \
126 || TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
128 /* We need this for the same reason as DATA_ALIGNMENT, namely to cause
129 character arrays to be word-aligned so that `strcpy' calls that copy
130 constants to character arrays can be done inline, and 'strcmp' can be
131 optimised to use word loads. */
132 #define LOCAL_ALIGNMENT(TYPE, ALIGN) \
133 DATA_ALIGNMENT (TYPE, ALIGN)
135 /*----------------------------------------*/
136 /* Layout of source language data types. */
137 /*----------------------------------------*/
139 #define INT_TYPE_SIZE 32
140 #define SHORT_TYPE_SIZE 16
141 #define LONG_TYPE_SIZE 32
142 #define LONG_LONG_TYPE_SIZE 64
144 #define FLOAT_TYPE_SIZE 32
145 #define DOUBLE_TYPE_SIZE 64
146 #define LONG_DOUBLE_TYPE_SIZE 64
148 #define DEFAULT_SIGNED_CHAR 0
150 #define SIZE_TYPE "unsigned int"
152 #define PTRDIFF_TYPE "int"
154 /*---------------------------*/
155 /* Standard register usage. */
156 /*---------------------------*/
158 #define FIRST_PSEUDO_REGISTER 32
166 #define G_REG_P(X) ((X)<32)
168 #define FIXED_REGISTERS \
169 { 1, 0, 0, 0, 0, 0, 0, 0, \
170 0, 0, 0, 0, 0, 0, 0, 0, \
171 0, 0, 0, 0, 0, 0, 0, 0, \
172 0, 0, 1, 0, 1, 0, 1, 1}
174 #define CALL_USED_REGISTERS \
175 { 1, 1, 1, 1, 1, 1, 1, 1, \
176 1, 1, 1, 0, 0, 0, 0, 0, \
177 0, 0, 0, 0, 0, 0, 0, 0, \
178 0, 0, 1, 0, 1, 0, 1, 1}
180 #define HARD_REGNO_NREGS(REGNO, MODE) \
181 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
183 #define HARD_REGNO_MODE_OK(REGNO, MODE) G_REG_P(REGNO)
185 #define MODES_TIEABLE_P(MODE1, MODE2) \
186 ( GET_MODE_CLASS (MODE1) == MODE_INT \
187 && GET_MODE_CLASS (MODE2) == MODE_INT \
188 && GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD \
189 && GET_MODE_SIZE (MODE2) <= UNITS_PER_WORD)
191 #define AVOID_CCMODE_COPIES
193 /*----------------------------------*/
194 /* Register classes and constants. */
195 /*----------------------------------*/
205 #define N_REG_CLASSES (int) LIM_REG_CLASSES
207 #define REG_CLASS_NAMES { "NO_REGS", "GENERAL_REGS", "ALL_REGS" }
209 #define REG_CLASS_CONTENTS \
215 #define REGNO_REG_CLASS(REGNO) \
216 (G_REG_P(REGNO) ? GENERAL_REGS : NO_REGS)
218 #define CLASS_MAX_NREGS(CLASS, MODE) \
219 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
221 #define INDEX_REG_CLASS NO_REGS
223 #define BASE_REG_CLASS GENERAL_REGS
225 #define REGNO_OK_FOR_BASE_P(REGNO) \
226 (G_REG_P (REGNO) || G_REG_P ((unsigned) reg_renumber[REGNO]))
228 #define REGNO_OK_FOR_INDEX_P(REGNO) 0
230 #define PREFERRED_RELOAD_CLASS(X,CLASS) (CLASS)
232 /*----------------------------------------*/
233 /* Stack Layout and Calling Conventions. */
234 /*----------------------------------------*/
236 #define STACK_GROWS_DOWNWARD 1
238 #define FRAME_GROWS_DOWNWARD 1
240 #define STACK_POINTER_OFFSET (UNITS_PER_WORD)
242 #define STARTING_FRAME_OFFSET (UNITS_PER_WORD)
244 #define FIRST_PARM_OFFSET(FNDECL) (UNITS_PER_WORD)
246 #define STACK_POINTER_REGNUM SP_REGNUM
248 #define FRAME_POINTER_REGNUM FP_REGNUM
250 #define ARG_POINTER_REGNUM FRAME_POINTER_REGNUM
252 #define RETURN_ADDR_RTX(count, frame) \
253 lm32_return_addr_rtx (count, frame)
255 /* FIXME - This is not yet supported. */
256 #define STATIC_CHAIN_REGNUM 9
258 #define ELIMINABLE_REGS \
259 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
260 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
263 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
264 (OFFSET) = lm32_compute_initial_elimination_offset (FROM, TO)
266 /*-----------------------------*/
267 /* Function argument passing. */
268 /*-----------------------------*/
270 #define ACCUMULATE_OUTGOING_ARGS 1
272 /*--------------------------------*/
273 /* Passing Arguments in Registers */
274 /*--------------------------------*/
276 /* The first argument register. */
277 #define LM32_FIRST_ARG_REG 1
279 /* The number of (integer) argument register available. */
280 #define LM32_NUM_ARG_REGS 8
282 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
283 lm32_function_arg ((CUM), (MODE), (TYPE), (NAMED))
285 #define CUMULATIVE_ARGS int
287 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT,N_NAMED_ARGS) \
290 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
291 (CUM) += LM32_NUM_REGS2 (MODE, TYPE)
293 #define FUNCTION_ARG_REGNO_P(r) \
294 (((r) >= LM32_FIRST_ARG_REG) && ((r) <= LM32_NUM_ARG_REGS))
296 /*--------------------*/
297 /* Function results. */
298 /*--------------------*/
300 #define FUNCTION_VALUE(VALTYPE, FUNC) \
301 gen_rtx_REG ((INTEGRAL_TYPE_P (VALTYPE) \
302 && TYPE_PRECISION (VALTYPE) < BITS_PER_WORD) \
304 : TYPE_MODE (VALTYPE), \
307 #define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, RV_REGNUM)
309 #define FUNCTION_VALUE_REGNO_P(N) ((N) == RV_REGNUM)
311 #define RETURN_IN_MEMORY(TYPE) lm32_return_in_memory (TYPE)
313 #define DEFAULT_PCC_STRUCT_RETURN 0
315 /* Convert from bytes to ints. */
316 #define LM32_NUM_INTS(X) (((X) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
318 /* The number of (integer) registers required to hold a quantity of
320 #define LM32_NUM_REGS(MODE) LM32_NUM_INTS (GET_MODE_SIZE (MODE))
322 /* The number of (integer) registers required to hold a quantity of
324 #define LM32_NUM_REGS2(MODE, TYPE) \
325 LM32_NUM_INTS ((MODE) == BLKmode ? \
326 int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE))
328 #define STRUCT_VALUE 0
330 /*---------------------------*/
331 /* Function entry and exit. */
332 /*---------------------------*/
338 #define FUNCTION_PROFILER(FILE, LABELNO)
344 #define TRAMPOLINE_SIZE 0
346 /*---------------------*/
347 /* Addressing Modes. */
348 /*---------------------*/
350 #define CONSTANT_ADDRESS_P(X) \
351 ((GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
352 || GET_CODE (X) == CONST_INT || GET_CODE (X) == HIGH \
353 || (GET_CODE (X) == CONST)))
355 #define MAX_REGS_PER_ADDRESS 1
357 #define STRICT_REG_OK_FOR_BASE_P(X) \
358 (REGNO_OK_FOR_BASE_P (REGNO (X)))
359 #define NONSTRICT_REG_OK_FOR_BASE_P(X) \
360 (G_REG_P (REGNO (X)) || !HARD_REGISTER_NUM_P (REGNO (X)))
363 #define REG_OK_FOR_BASE_P(X) STRICT_REG_OK_FOR_BASE_P(X)
365 #define REG_OK_FOR_BASE_P(X) NONSTRICT_REG_OK_FOR_BASE_P(X)
368 #define LEGITIMATE_CONSTANT_P(X) lm32_legitimate_constant_p
370 /*-------------------------*/
371 /* Condition Code Status. */
372 /*-------------------------*/
374 #define REVERSIBLE_CC_MODE(MODE) 1
380 #define SLOW_BYTE_ACCESS 1
382 #define NO_FUNCTION_CSE
384 #define BRANCH_COST(speed_p, predictable_p) 4
386 #define MOVE_RATIO(speed) (speed ? 24 : 3)
392 #define TEXT_SECTION_ASM_OP "\t.section\t.text"
393 #define DATA_SECTION_ASM_OP "\t.section\t.data"
394 #define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\""
395 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
396 #define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\""
402 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? GP_REGNUM : INVALID_REGNUM)
404 #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
406 #define LEGITIMATE_PIC_OPERAND_P(X) \
407 (!(nonpic_symbol_mentioned_p (X)))
413 #define ASM_COMMENT_START "#"
415 #define ASM_APP_ON "#APP\n"
417 #define ASM_APP_OFF "#NO_APP\n"
419 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
421 fputc ( '\t', FILE); \
422 assemble_name (FILE, LABEL1); \
423 fputs ( " = ", FILE); \
424 assemble_name (FILE, LABEL2); \
425 fputc ( '\n', FILE); \
428 /* Override default implementation in elfos.h to support -G. */
429 #undef ASM_OUTPUT_ALIGNED_LOCAL
430 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
432 if ((SIZE) <= g_switch_value) \
433 switch_to_section (sbss_section); \
435 switch_to_section (bss_section); \
436 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
437 if (!flag_inhibit_size_directive) \
438 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
439 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
440 ASM_OUTPUT_LABEL(FILE, NAME); \
441 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
444 /* Override default implementation in elfos.h to support -G. */
445 #undef ASM_OUTPUT_ALIGNED_COMMON
446 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
449 if ((SIZE) <= g_switch_value) \
451 switch_to_section (sbss_section); \
452 (*targetm.asm_out.globalize_label) (FILE, NAME); \
453 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
454 if (!flag_inhibit_size_directive) \
455 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
456 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
457 ASM_OUTPUT_LABEL(FILE, NAME); \
458 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
462 switch_to_section (bss_section); \
463 fprintf ((FILE), "%s", COMMON_ASM_OP); \
464 assemble_name ((FILE), (NAME)); \
465 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
466 (SIZE), (ALIGN) / BITS_PER_UNIT); \
471 #define ASM_OUTPUT_LABEL(FILE, NAME) \
472 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
474 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
476 const char *xname = (NAME); \
477 if (xname[0] == '@') \
479 if (xname[0] == '*') \
481 fputs (xname, FILE); \
484 #define ASM_OUTPUT_SYMBOL_REF(STREAM, SYMBOL) \
486 assemble_name (STREAM, XSTR (SYMBOL, 0)); \
489 #define GLOBAL_ASM_OP "\t.global\t"
491 #define REGISTER_NAMES \
493 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
494 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
495 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
496 "r24", "r25", "gp", "fp", "sp", "ra", "ea", "ba"}
498 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
499 (((CHAR) == '&') || ((CHAR) == '@') || ((CHAR) == '*'))
501 #define PRINT_OPERAND(FILE, X, CODE) \
502 lm32_print_operand (FILE, X, CODE)
504 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
505 lm32_print_operand_address (FILE, ADDR)
507 #ifndef LOCAL_LABEL_PREFIX
508 #define LOCAL_LABEL_PREFIX "."
511 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
512 do { if ((LOG) != 0) fprintf (FILE, "\t.align %d\n", (1 << (LOG))); } while (0)
514 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
517 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
518 fprintf (FILE, "\n\t.word\t"); \
519 assemble_name (FILE, label); \
520 fprintf (FILE, "\n"); \
523 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
526 fprintf (FILE, "\t.word\t("); \
527 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
528 assemble_name (FILE, label); \
529 fprintf (FILE, "-"); \
530 ASM_GENERATE_INTERNAL_LABEL (label, "L", REL); \
531 assemble_name (FILE, label); \
532 fprintf (FILE, ")\n"); \
539 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
541 #define CAN_DEBUG_WITHOUT_FP
543 #define DEFAULT_GDB_EXTENSIONS 1
549 #define CASE_VECTOR_MODE Pmode
551 #define WORD_REGISTER_OPERATIONS
553 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
555 #define SHORT_IMMEDIATES_SIGN_EXTEND
557 #define MOVE_MAX UNITS_PER_WORD
558 #define MAX_MOVE_MAX 4
560 #define SHIFT_COUNT_TRUNCATED 1
562 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
566 #define FUNCTION_MODE SImode
568 #ifndef NO_IMPLICIT_EXTERN_C
569 #define NO_IMPLICIT_EXTERN_C
572 #define STORE_FLAG_VALUE 1