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
88 #define BITS_PER_UNIT 8
89 #define BITS_PER_WORD 32
90 #define UNITS_PER_WORD 4
92 #define POINTER_SIZE 32
94 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
96 if (GET_MODE_CLASS (MODE) == MODE_INT \
97 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
101 #define PARM_BOUNDARY 32
103 #define STACK_BOUNDARY 32
105 #define BIGGEST_ALIGNMENT 64
107 #define FUNCTION_BOUNDARY 32
109 #define EMPTY_FIELD_BOUNDARY 32
111 #define STRICT_ALIGNMENT 1
113 #define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
115 /* Make strings word-aligned so strcpy from constants will be faster. */
116 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
117 (TREE_CODE (EXP) == STRING_CST \
118 && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
120 /* Make arrays and structures word-aligned to allow faster copying etc. */
121 #define DATA_ALIGNMENT(TYPE, ALIGN) \
122 ((((ALIGN) < BITS_PER_WORD) \
123 && (TREE_CODE (TYPE) == ARRAY_TYPE \
124 || TREE_CODE (TYPE) == UNION_TYPE \
125 || TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
127 /* We need this for the same reason as DATA_ALIGNMENT, namely to cause
128 character arrays to be word-aligned so that `strcpy' calls that copy
129 constants to character arrays can be done inline, and 'strcmp' can be
130 optimised to use word loads. */
131 #define LOCAL_ALIGNMENT(TYPE, ALIGN) \
132 DATA_ALIGNMENT (TYPE, ALIGN)
134 /*----------------------------------------*/
135 /* Layout of source language data types. */
136 /*----------------------------------------*/
138 #define INT_TYPE_SIZE 32
139 #define SHORT_TYPE_SIZE 16
140 #define LONG_TYPE_SIZE 32
141 #define LONG_LONG_TYPE_SIZE 64
143 #define FLOAT_TYPE_SIZE 32
144 #define DOUBLE_TYPE_SIZE 64
145 #define LONG_DOUBLE_TYPE_SIZE 64
147 #define DEFAULT_SIGNED_CHAR 0
149 #define SIZE_TYPE "unsigned int"
151 #define PTRDIFF_TYPE "int"
153 /*---------------------------*/
154 /* Standard register usage. */
155 /*---------------------------*/
157 #define FIRST_PSEUDO_REGISTER 32
165 #define G_REG_P(X) ((X)<32)
167 #define FIXED_REGISTERS \
168 { 1, 0, 0, 0, 0, 0, 0, 0, \
169 0, 0, 0, 0, 0, 0, 0, 0, \
170 0, 0, 0, 0, 0, 0, 0, 0, \
171 0, 0, 1, 0, 1, 0, 1, 1}
173 #define CALL_USED_REGISTERS \
174 { 1, 1, 1, 1, 1, 1, 1, 1, \
175 1, 1, 1, 0, 0, 0, 0, 0, \
176 0, 0, 0, 0, 0, 0, 0, 0, \
177 0, 0, 1, 0, 1, 0, 1, 1}
179 #define HARD_REGNO_NREGS(REGNO, MODE) \
180 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
182 #define HARD_REGNO_MODE_OK(REGNO, MODE) G_REG_P(REGNO)
184 #define MODES_TIEABLE_P(MODE1, MODE2) \
185 ( GET_MODE_CLASS (MODE1) == MODE_INT \
186 && GET_MODE_CLASS (MODE2) == MODE_INT \
187 && GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD \
188 && GET_MODE_SIZE (MODE2) <= UNITS_PER_WORD)
190 #define AVOID_CCMODE_COPIES
192 /*----------------------------------*/
193 /* Register classes and constants. */
194 /*----------------------------------*/
204 #define N_REG_CLASSES (int) LIM_REG_CLASSES
206 #define REG_CLASS_NAMES { "NO_REGS", "GENERAL_REGS", "ALL_REGS" }
208 #define REG_CLASS_CONTENTS \
214 #define REGNO_REG_CLASS(REGNO) \
215 (G_REG_P(REGNO) ? GENERAL_REGS : NO_REGS)
217 #define CLASS_MAX_NREGS(CLASS, MODE) \
218 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
220 #define INDEX_REG_CLASS NO_REGS
222 #define BASE_REG_CLASS GENERAL_REGS
224 #define REGNO_OK_FOR_BASE_P(REGNO) \
225 (G_REG_P (REGNO) || G_REG_P ((unsigned) reg_renumber[REGNO]))
227 #define REGNO_OK_FOR_INDEX_P(REGNO) 0
229 /*----------------------------------------*/
230 /* Stack Layout and Calling Conventions. */
231 /*----------------------------------------*/
233 #define STACK_GROWS_DOWNWARD 1
235 #define FRAME_GROWS_DOWNWARD 1
237 #define STACK_POINTER_OFFSET (UNITS_PER_WORD)
239 #define STARTING_FRAME_OFFSET (UNITS_PER_WORD)
241 #define FIRST_PARM_OFFSET(FNDECL) (UNITS_PER_WORD)
243 #define STACK_POINTER_REGNUM SP_REGNUM
245 #define FRAME_POINTER_REGNUM FP_REGNUM
247 #define ARG_POINTER_REGNUM FRAME_POINTER_REGNUM
249 #define RETURN_ADDR_RTX(count, frame) \
250 lm32_return_addr_rtx (count, frame)
252 /* FIXME - This is not yet supported. */
253 #define STATIC_CHAIN_REGNUM 9
255 #define ELIMINABLE_REGS \
256 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
257 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
260 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
261 (OFFSET) = lm32_compute_initial_elimination_offset (FROM, TO)
263 /*-----------------------------*/
264 /* Function argument passing. */
265 /*-----------------------------*/
267 #define ACCUMULATE_OUTGOING_ARGS 1
269 /*--------------------------------*/
270 /* Passing Arguments in Registers */
271 /*--------------------------------*/
273 /* The first argument register. */
274 #define LM32_FIRST_ARG_REG 1
276 /* The number of (integer) argument register available. */
277 #define LM32_NUM_ARG_REGS 8
279 #define CUMULATIVE_ARGS int
281 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT,N_NAMED_ARGS) \
284 #define FUNCTION_ARG_REGNO_P(r) \
285 (((r) >= LM32_FIRST_ARG_REG) && ((r) <= LM32_NUM_ARG_REGS))
287 /*--------------------*/
288 /* Function results. */
289 /*--------------------*/
291 #define FUNCTION_VALUE(VALTYPE, FUNC) \
292 gen_rtx_REG ((INTEGRAL_TYPE_P (VALTYPE) \
293 && TYPE_PRECISION (VALTYPE) < BITS_PER_WORD) \
295 : TYPE_MODE (VALTYPE), \
298 #define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, RV_REGNUM)
300 #define FUNCTION_VALUE_REGNO_P(N) ((N) == RV_REGNUM)
302 #define RETURN_IN_MEMORY(TYPE) lm32_return_in_memory (TYPE)
304 #define DEFAULT_PCC_STRUCT_RETURN 0
306 /* Convert from bytes to ints. */
307 #define LM32_NUM_INTS(X) (((X) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
309 /* The number of (integer) registers required to hold a quantity of
311 #define LM32_NUM_REGS(MODE) LM32_NUM_INTS (GET_MODE_SIZE (MODE))
313 /* The number of (integer) registers required to hold a quantity of
315 #define LM32_NUM_REGS2(MODE, TYPE) \
316 LM32_NUM_INTS ((MODE) == BLKmode ? \
317 int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE))
319 #define STRUCT_VALUE 0
321 /*---------------------------*/
322 /* Function entry and exit. */
323 /*---------------------------*/
329 #define FUNCTION_PROFILER(FILE, LABELNO)
335 #define TRAMPOLINE_SIZE 0
337 /*---------------------*/
338 /* Addressing Modes. */
339 /*---------------------*/
341 #define CONSTANT_ADDRESS_P(X) \
342 ((GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
343 || GET_CODE (X) == CONST_INT || GET_CODE (X) == HIGH \
344 || (GET_CODE (X) == CONST)))
346 #define MAX_REGS_PER_ADDRESS 1
348 #define STRICT_REG_OK_FOR_BASE_P(X) \
349 (REGNO_OK_FOR_BASE_P (REGNO (X)))
350 #define NONSTRICT_REG_OK_FOR_BASE_P(X) \
351 (G_REG_P (REGNO (X)) || !HARD_REGISTER_NUM_P (REGNO (X)))
354 #define REG_OK_FOR_BASE_P(X) STRICT_REG_OK_FOR_BASE_P(X)
356 #define REG_OK_FOR_BASE_P(X) NONSTRICT_REG_OK_FOR_BASE_P(X)
359 #define LEGITIMATE_CONSTANT_P(X) lm32_legitimate_constant_p
361 /*-------------------------*/
362 /* Condition Code Status. */
363 /*-------------------------*/
365 #define REVERSIBLE_CC_MODE(MODE) 1
371 #define SLOW_BYTE_ACCESS 1
373 #define NO_FUNCTION_CSE
375 #define BRANCH_COST(speed_p, predictable_p) 4
377 #define MOVE_RATIO(speed) (speed ? 24 : 3)
383 #define TEXT_SECTION_ASM_OP "\t.section\t.text"
384 #define DATA_SECTION_ASM_OP "\t.section\t.data"
385 #define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\""
386 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
387 #define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\""
393 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? GP_REGNUM : INVALID_REGNUM)
395 #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
397 #define LEGITIMATE_PIC_OPERAND_P(X) \
398 (!(nonpic_symbol_mentioned_p (X)))
404 #define ASM_COMMENT_START "#"
406 #define ASM_APP_ON "#APP\n"
408 #define ASM_APP_OFF "#NO_APP\n"
410 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
412 fputc ( '\t', FILE); \
413 assemble_name (FILE, LABEL1); \
414 fputs ( " = ", FILE); \
415 assemble_name (FILE, LABEL2); \
416 fputc ( '\n', FILE); \
419 /* Override default implementation in elfos.h to support -G. */
420 #undef ASM_OUTPUT_ALIGNED_LOCAL
421 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
423 if ((SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value) \
424 switch_to_section (sbss_section); \
426 switch_to_section (bss_section); \
427 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
428 if (!flag_inhibit_size_directive) \
429 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
430 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
431 ASM_OUTPUT_LABEL(FILE, NAME); \
432 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
435 /* Override default implementation in elfos.h to support -G. */
436 #undef ASM_OUTPUT_ALIGNED_COMMON
437 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
440 if ((SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value) \
442 switch_to_section (sbss_section); \
443 (*targetm.asm_out.globalize_label) (FILE, NAME); \
444 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
445 if (!flag_inhibit_size_directive) \
446 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
447 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
448 ASM_OUTPUT_LABEL(FILE, NAME); \
449 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
453 switch_to_section (bss_section); \
454 fprintf ((FILE), "%s", COMMON_ASM_OP); \
455 assemble_name ((FILE), (NAME)); \
456 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
457 (SIZE), (ALIGN) / BITS_PER_UNIT); \
462 #define ASM_OUTPUT_LABEL(FILE, NAME) \
463 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
465 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
467 const char *xname = (NAME); \
468 if (xname[0] == '@') \
470 if (xname[0] == '*') \
472 fputs (xname, FILE); \
475 #define ASM_OUTPUT_SYMBOL_REF(STREAM, SYMBOL) \
477 assemble_name (STREAM, XSTR (SYMBOL, 0)); \
480 #define GLOBAL_ASM_OP "\t.global\t"
482 #define REGISTER_NAMES \
484 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
485 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
486 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
487 "r24", "r25", "gp", "fp", "sp", "ra", "ea", "ba"}
489 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
490 (((CHAR) == '&') || ((CHAR) == '@') || ((CHAR) == '*'))
492 #define PRINT_OPERAND(FILE, X, CODE) \
493 lm32_print_operand (FILE, X, CODE)
495 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
496 lm32_print_operand_address (FILE, ADDR)
498 #ifndef LOCAL_LABEL_PREFIX
499 #define LOCAL_LABEL_PREFIX "."
502 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
503 do { if ((LOG) != 0) fprintf (FILE, "\t.align %d\n", (1 << (LOG))); } while (0)
505 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
508 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
509 fprintf (FILE, "\n\t.word\t"); \
510 assemble_name (FILE, label); \
511 fprintf (FILE, "\n"); \
514 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
517 fprintf (FILE, "\t.word\t("); \
518 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
519 assemble_name (FILE, label); \
520 fprintf (FILE, "-"); \
521 ASM_GENERATE_INTERNAL_LABEL (label, "L", REL); \
522 assemble_name (FILE, label); \
523 fprintf (FILE, ")\n"); \
530 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
532 #define DEFAULT_GDB_EXTENSIONS 1
538 #define CASE_VECTOR_MODE Pmode
540 #define WORD_REGISTER_OPERATIONS
542 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
544 #define SHORT_IMMEDIATES_SIGN_EXTEND
546 #define MOVE_MAX UNITS_PER_WORD
547 #define MAX_MOVE_MAX 4
549 #define SHIFT_COUNT_TRUNCATED 1
551 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
555 #define FUNCTION_MODE SImode
557 #ifndef NO_IMPLICIT_EXTERN_C
558 #define NO_IMPLICIT_EXTERN_C
561 #define STORE_FLAG_VALUE 1