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}"
72 #define CC1_SPEC "%{G*}"
74 /*---------------------------------*/
75 /* Target machine storage layout. */
76 /*---------------------------------*/
78 #define BITS_BIG_ENDIAN 0
79 #define BYTES_BIG_ENDIAN 1
80 #define WORDS_BIG_ENDIAN 1
82 #define BITS_PER_UNIT 8
83 #define BITS_PER_WORD 32
84 #define UNITS_PER_WORD 4
86 #define POINTER_SIZE 32
88 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
90 if (GET_MODE_CLASS (MODE) == MODE_INT \
91 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
95 #define PARM_BOUNDARY 32
97 #define STACK_BOUNDARY 32
99 #define BIGGEST_ALIGNMENT 64
101 #define FUNCTION_BOUNDARY 32
103 #define EMPTY_FIELD_BOUNDARY 32
105 #define STRICT_ALIGNMENT 1
107 #define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
109 /* Make strings word-aligned so strcpy from constants will be faster. */
110 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
111 (TREE_CODE (EXP) == STRING_CST \
112 && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
114 /* Make arrays and structures word-aligned to allow faster copying etc. */
115 #define DATA_ALIGNMENT(TYPE, ALIGN) \
116 ((((ALIGN) < BITS_PER_WORD) \
117 && (TREE_CODE (TYPE) == ARRAY_TYPE \
118 || TREE_CODE (TYPE) == UNION_TYPE \
119 || TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
121 /* We need this for the same reason as DATA_ALIGNMENT, namely to cause
122 character arrays to be word-aligned so that `strcpy' calls that copy
123 constants to character arrays can be done inline, and 'strcmp' can be
124 optimised to use word loads. */
125 #define LOCAL_ALIGNMENT(TYPE, ALIGN) \
126 DATA_ALIGNMENT (TYPE, ALIGN)
128 /*----------------------------------------*/
129 /* Layout of source language data types. */
130 /*----------------------------------------*/
132 #define INT_TYPE_SIZE 32
133 #define SHORT_TYPE_SIZE 16
134 #define LONG_TYPE_SIZE 32
135 #define LONG_LONG_TYPE_SIZE 64
137 #define FLOAT_TYPE_SIZE 32
138 #define DOUBLE_TYPE_SIZE 64
139 #define LONG_DOUBLE_TYPE_SIZE 64
141 #define DEFAULT_SIGNED_CHAR 0
143 #define SIZE_TYPE "unsigned int"
145 #define PTRDIFF_TYPE "int"
147 /*---------------------------*/
148 /* Standard register usage. */
149 /*---------------------------*/
151 #define FIRST_PSEUDO_REGISTER 32
159 #define G_REG_P(X) ((X)<32)
161 #define FIXED_REGISTERS \
162 { 1, 0, 0, 0, 0, 0, 0, 0, \
163 0, 0, 0, 0, 0, 0, 0, 0, \
164 0, 0, 0, 0, 0, 0, 0, 0, \
165 0, 0, 1, 0, 1, 0, 1, 1}
167 #define CALL_USED_REGISTERS \
168 { 1, 1, 1, 1, 1, 1, 1, 1, \
169 1, 1, 1, 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 HARD_REGNO_NREGS(REGNO, MODE) \
174 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
176 #define HARD_REGNO_MODE_OK(REGNO, MODE) G_REG_P(REGNO)
178 #define MODES_TIEABLE_P(MODE1, MODE2) \
179 ( GET_MODE_CLASS (MODE1) == MODE_INT \
180 && GET_MODE_CLASS (MODE2) == MODE_INT \
181 && GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD \
182 && GET_MODE_SIZE (MODE2) <= UNITS_PER_WORD)
184 #define AVOID_CCMODE_COPIES
186 /*----------------------------------*/
187 /* Register classes and constants. */
188 /*----------------------------------*/
198 #define N_REG_CLASSES (int) LIM_REG_CLASSES
200 #define REG_CLASS_NAMES { "NO_REGS", "GENERAL_REGS", "ALL_REGS" }
202 #define REG_CLASS_CONTENTS \
208 #define REGNO_REG_CLASS(REGNO) \
209 (G_REG_P(REGNO) ? GENERAL_REGS : NO_REGS)
211 #define CLASS_MAX_NREGS(CLASS, MODE) \
212 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
214 #define INDEX_REG_CLASS NO_REGS
216 #define BASE_REG_CLASS GENERAL_REGS
218 #define REGNO_OK_FOR_BASE_P(REGNO) \
219 (G_REG_P (REGNO) || G_REG_P ((unsigned) reg_renumber[REGNO]))
221 #define REGNO_OK_FOR_INDEX_P(REGNO) 0
223 /*----------------------------------------*/
224 /* Stack Layout and Calling Conventions. */
225 /*----------------------------------------*/
227 #define STACK_GROWS_DOWNWARD 1
229 #define FRAME_GROWS_DOWNWARD 1
231 #define STACK_POINTER_OFFSET (UNITS_PER_WORD)
233 #define STARTING_FRAME_OFFSET (UNITS_PER_WORD)
235 #define FIRST_PARM_OFFSET(FNDECL) (UNITS_PER_WORD)
237 #define STACK_POINTER_REGNUM SP_REGNUM
239 #define FRAME_POINTER_REGNUM FP_REGNUM
241 #define ARG_POINTER_REGNUM FRAME_POINTER_REGNUM
243 #define RETURN_ADDR_RTX(count, frame) \
244 lm32_return_addr_rtx (count, frame)
246 /* FIXME - This is not yet supported. */
247 #define STATIC_CHAIN_REGNUM 9
249 #define ELIMINABLE_REGS \
250 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
251 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
254 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
255 (OFFSET) = lm32_compute_initial_elimination_offset (FROM, TO)
257 /*-----------------------------*/
258 /* Function argument passing. */
259 /*-----------------------------*/
261 #define ACCUMULATE_OUTGOING_ARGS 1
263 /*--------------------------------*/
264 /* Passing Arguments in Registers */
265 /*--------------------------------*/
267 /* The first argument register. */
268 #define LM32_FIRST_ARG_REG 1
270 /* The number of (integer) argument register available. */
271 #define LM32_NUM_ARG_REGS 8
273 #define CUMULATIVE_ARGS int
275 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT,N_NAMED_ARGS) \
278 #define FUNCTION_ARG_REGNO_P(r) \
279 (((r) >= LM32_FIRST_ARG_REG) && ((r) <= LM32_NUM_ARG_REGS))
281 /*--------------------*/
282 /* Function results. */
283 /*--------------------*/
285 #define FUNCTION_VALUE(VALTYPE, FUNC) \
286 gen_rtx_REG ((INTEGRAL_TYPE_P (VALTYPE) \
287 && TYPE_PRECISION (VALTYPE) < BITS_PER_WORD) \
289 : TYPE_MODE (VALTYPE), \
292 #define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, RV_REGNUM)
294 #define FUNCTION_VALUE_REGNO_P(N) ((N) == RV_REGNUM)
296 #define RETURN_IN_MEMORY(TYPE) lm32_return_in_memory (TYPE)
298 #define DEFAULT_PCC_STRUCT_RETURN 0
300 /* Convert from bytes to ints. */
301 #define LM32_NUM_INTS(X) (((X) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
303 /* The number of (integer) registers required to hold a quantity of
305 #define LM32_NUM_REGS(MODE) LM32_NUM_INTS (GET_MODE_SIZE (MODE))
307 /* The number of (integer) registers required to hold a quantity of
309 #define LM32_NUM_REGS2(MODE, TYPE) \
310 LM32_NUM_INTS ((MODE) == BLKmode ? \
311 int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE))
313 #define STRUCT_VALUE 0
315 /*---------------------------*/
316 /* Function entry and exit. */
317 /*---------------------------*/
323 #define FUNCTION_PROFILER(FILE, LABELNO)
329 #define TRAMPOLINE_SIZE 0
331 /*---------------------*/
332 /* Addressing Modes. */
333 /*---------------------*/
335 #define CONSTANT_ADDRESS_P(X) \
336 ((GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
337 || GET_CODE (X) == CONST_INT || GET_CODE (X) == HIGH \
338 || (GET_CODE (X) == CONST)))
340 #define MAX_REGS_PER_ADDRESS 1
342 #define STRICT_REG_OK_FOR_BASE_P(X) \
343 (REGNO_OK_FOR_BASE_P (REGNO (X)))
344 #define NONSTRICT_REG_OK_FOR_BASE_P(X) \
345 (G_REG_P (REGNO (X)) || !HARD_REGISTER_NUM_P (REGNO (X)))
348 #define REG_OK_FOR_BASE_P(X) STRICT_REG_OK_FOR_BASE_P(X)
350 #define REG_OK_FOR_BASE_P(X) NONSTRICT_REG_OK_FOR_BASE_P(X)
353 #define LEGITIMATE_CONSTANT_P(X) lm32_legitimate_constant_p (X)
355 /*-------------------------*/
356 /* Condition Code Status. */
357 /*-------------------------*/
359 #define REVERSIBLE_CC_MODE(MODE) 1
365 #define SLOW_BYTE_ACCESS 1
367 #define NO_FUNCTION_CSE
369 #define BRANCH_COST(speed_p, predictable_p) 4
371 #define MOVE_RATIO(speed) (speed ? 24 : 3)
377 #define TEXT_SECTION_ASM_OP "\t.section\t.text"
378 #define DATA_SECTION_ASM_OP "\t.section\t.data"
379 #define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\""
380 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
381 #define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\""
387 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? GP_REGNUM : INVALID_REGNUM)
389 #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
391 #define LEGITIMATE_PIC_OPERAND_P(X) \
392 (!(nonpic_symbol_mentioned_p (X)))
398 #define ASM_COMMENT_START "#"
400 #define ASM_APP_ON "#APP\n"
402 #define ASM_APP_OFF "#NO_APP\n"
404 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
406 fputc ( '\t', FILE); \
407 assemble_name (FILE, LABEL1); \
408 fputs ( " = ", FILE); \
409 assemble_name (FILE, LABEL2); \
410 fputc ( '\n', FILE); \
413 /* Override default implementation in elfos.h to support -G. */
414 #undef ASM_OUTPUT_ALIGNED_LOCAL
415 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
417 if ((SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value) \
418 switch_to_section (sbss_section); \
420 switch_to_section (bss_section); \
421 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
422 if (!flag_inhibit_size_directive) \
423 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
424 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
425 ASM_OUTPUT_LABEL(FILE, NAME); \
426 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
429 /* Override default implementation in elfos.h to support -G. */
430 #undef ASM_OUTPUT_ALIGNED_COMMON
431 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
434 if ((SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value) \
436 switch_to_section (sbss_section); \
437 (*targetm.asm_out.globalize_label) (FILE, NAME); \
438 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
439 if (!flag_inhibit_size_directive) \
440 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
441 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
442 ASM_OUTPUT_LABEL(FILE, NAME); \
443 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
447 switch_to_section (bss_section); \
448 fprintf ((FILE), "%s", COMMON_ASM_OP); \
449 assemble_name ((FILE), (NAME)); \
450 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
451 (SIZE), (ALIGN) / BITS_PER_UNIT); \
456 #define ASM_OUTPUT_LABEL(FILE, NAME) \
457 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
459 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
461 const char *xname = (NAME); \
462 if (xname[0] == '@') \
464 if (xname[0] == '*') \
466 fputs (xname, FILE); \
469 #define ASM_OUTPUT_SYMBOL_REF(STREAM, SYMBOL) \
471 assemble_name (STREAM, XSTR (SYMBOL, 0)); \
474 #define GLOBAL_ASM_OP "\t.global\t"
476 #define REGISTER_NAMES \
478 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
479 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
480 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
481 "r24", "r25", "gp", "fp", "sp", "ra", "ea", "ba"}
483 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
484 (((CHAR) == '&') || ((CHAR) == '@') || ((CHAR) == '*'))
486 #define PRINT_OPERAND(FILE, X, CODE) \
487 lm32_print_operand (FILE, X, CODE)
489 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
490 lm32_print_operand_address (FILE, ADDR)
492 #ifndef LOCAL_LABEL_PREFIX
493 #define LOCAL_LABEL_PREFIX "."
496 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
497 do { if ((LOG) != 0) fprintf (FILE, "\t.align %d\n", (1 << (LOG))); } while (0)
499 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
502 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
503 fprintf (FILE, "\n\t.word\t"); \
504 assemble_name (FILE, label); \
505 fprintf (FILE, "\n"); \
508 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
511 fprintf (FILE, "\t.word\t("); \
512 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
513 assemble_name (FILE, label); \
514 fprintf (FILE, "-"); \
515 ASM_GENERATE_INTERNAL_LABEL (label, "L", REL); \
516 assemble_name (FILE, label); \
517 fprintf (FILE, ")\n"); \
524 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
526 #define DEFAULT_GDB_EXTENSIONS 1
532 #define CASE_VECTOR_MODE Pmode
534 #define WORD_REGISTER_OPERATIONS
536 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
538 #define SHORT_IMMEDIATES_SIGN_EXTEND
540 #define MOVE_MAX UNITS_PER_WORD
541 #define MAX_MOVE_MAX 4
543 #define SHIFT_COUNT_TRUNCATED 1
545 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
549 #define FUNCTION_MODE SImode
551 #ifndef NO_IMPLICIT_EXTERN_C
552 #define NO_IMPLICIT_EXTERN_C
555 #define STORE_FLAG_VALUE 1