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} \
60 /* Let link script define all link options.
61 Default to using simulator link script. */
64 #define STARTFILE_SPEC ""
66 #define ENDFILE_SPEC ""
68 #define LIB_SPEC "%{!T*:-T sim.ld}"
71 #define CC1_SPEC "%{G*}"
73 /*---------------------------------*/
74 /* Target machine storage layout. */
75 /*---------------------------------*/
77 #define BITS_BIG_ENDIAN 0
78 #define BYTES_BIG_ENDIAN 1
79 #define WORDS_BIG_ENDIAN 1
81 #define BITS_PER_UNIT 8
82 #define BITS_PER_WORD 32
83 #define UNITS_PER_WORD 4
85 #define POINTER_SIZE 32
87 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
89 if (GET_MODE_CLASS (MODE) == MODE_INT \
90 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
94 #define PARM_BOUNDARY 32
96 #define STACK_BOUNDARY 32
98 #define BIGGEST_ALIGNMENT 64
100 #define FUNCTION_BOUNDARY 32
102 #define EMPTY_FIELD_BOUNDARY 32
104 #define STRICT_ALIGNMENT 1
106 #define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
108 /* Make strings word-aligned so strcpy from constants will be faster. */
109 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
110 (TREE_CODE (EXP) == STRING_CST \
111 && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
113 /* Make arrays and structures word-aligned to allow faster copying etc. */
114 #define DATA_ALIGNMENT(TYPE, ALIGN) \
115 ((((ALIGN) < BITS_PER_WORD) \
116 && (TREE_CODE (TYPE) == ARRAY_TYPE \
117 || TREE_CODE (TYPE) == UNION_TYPE \
118 || TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
120 /* We need this for the same reason as DATA_ALIGNMENT, namely to cause
121 character arrays to be word-aligned so that `strcpy' calls that copy
122 constants to character arrays can be done inline, and 'strcmp' can be
123 optimised to use word loads. */
124 #define LOCAL_ALIGNMENT(TYPE, ALIGN) \
125 DATA_ALIGNMENT (TYPE, ALIGN)
127 /*----------------------------------------*/
128 /* Layout of source language data types. */
129 /*----------------------------------------*/
131 #define INT_TYPE_SIZE 32
132 #define SHORT_TYPE_SIZE 16
133 #define LONG_TYPE_SIZE 32
134 #define LONG_LONG_TYPE_SIZE 64
136 #define FLOAT_TYPE_SIZE 32
137 #define DOUBLE_TYPE_SIZE 64
138 #define LONG_DOUBLE_TYPE_SIZE 64
140 #define DEFAULT_SIGNED_CHAR 0
142 #define SIZE_TYPE "unsigned int"
144 #define PTRDIFF_TYPE "int"
146 /*---------------------------*/
147 /* Standard register usage. */
148 /*---------------------------*/
150 #define FIRST_PSEUDO_REGISTER 32
158 #define G_REG_P(X) ((X)<32)
160 #define FIXED_REGISTERS \
161 { 1, 0, 0, 0, 0, 0, 0, 0, \
162 0, 0, 0, 0, 0, 0, 0, 0, \
163 0, 0, 0, 0, 0, 0, 0, 0, \
164 0, 0, 1, 0, 1, 0, 1, 1}
166 #define CALL_USED_REGISTERS \
167 { 1, 1, 1, 1, 1, 1, 1, 1, \
168 1, 1, 1, 0, 0, 0, 0, 0, \
169 0, 0, 0, 0, 0, 0, 0, 0, \
170 0, 0, 1, 0, 1, 0, 1, 1}
172 #define HARD_REGNO_NREGS(REGNO, MODE) \
173 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
175 #define HARD_REGNO_MODE_OK(REGNO, MODE) G_REG_P(REGNO)
177 #define MODES_TIEABLE_P(MODE1, MODE2) \
178 ( GET_MODE_CLASS (MODE1) == MODE_INT \
179 && GET_MODE_CLASS (MODE2) == MODE_INT \
180 && GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD \
181 && GET_MODE_SIZE (MODE2) <= UNITS_PER_WORD)
183 #define AVOID_CCMODE_COPIES
185 /*----------------------------------*/
186 /* Register classes and constants. */
187 /*----------------------------------*/
197 #define N_REG_CLASSES (int) LIM_REG_CLASSES
199 #define REG_CLASS_NAMES { "NO_REGS", "GENERAL_REGS", "ALL_REGS" }
201 #define REG_CLASS_CONTENTS \
207 #define REGNO_REG_CLASS(REGNO) \
208 (G_REG_P(REGNO) ? GENERAL_REGS : NO_REGS)
210 #define CLASS_MAX_NREGS(CLASS, MODE) \
211 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
213 #define INDEX_REG_CLASS NO_REGS
215 #define BASE_REG_CLASS GENERAL_REGS
217 #define REGNO_OK_FOR_BASE_P(REGNO) \
218 (G_REG_P (REGNO) || G_REG_P ((unsigned) reg_renumber[REGNO]))
220 #define REGNO_OK_FOR_INDEX_P(REGNO) 0
222 /*----------------------------------------*/
223 /* Stack Layout and Calling Conventions. */
224 /*----------------------------------------*/
226 #define STACK_GROWS_DOWNWARD 1
228 #define FRAME_GROWS_DOWNWARD 1
230 #define STACK_POINTER_OFFSET (UNITS_PER_WORD)
232 #define STARTING_FRAME_OFFSET (UNITS_PER_WORD)
234 #define FIRST_PARM_OFFSET(FNDECL) (UNITS_PER_WORD)
236 #define STACK_POINTER_REGNUM SP_REGNUM
238 #define FRAME_POINTER_REGNUM FP_REGNUM
240 #define ARG_POINTER_REGNUM FRAME_POINTER_REGNUM
242 #define RETURN_ADDR_RTX(count, frame) \
243 lm32_return_addr_rtx (count, frame)
245 /* FIXME - This is not yet supported. */
246 #define STATIC_CHAIN_REGNUM 9
248 #define ELIMINABLE_REGS \
249 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
250 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
253 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
254 (OFFSET) = lm32_compute_initial_elimination_offset (FROM, TO)
256 /*-----------------------------*/
257 /* Function argument passing. */
258 /*-----------------------------*/
260 #define ACCUMULATE_OUTGOING_ARGS 1
262 /*--------------------------------*/
263 /* Passing Arguments in Registers */
264 /*--------------------------------*/
266 /* The first argument register. */
267 #define LM32_FIRST_ARG_REG 1
269 /* The number of (integer) argument register available. */
270 #define LM32_NUM_ARG_REGS 8
272 #define CUMULATIVE_ARGS int
274 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT,N_NAMED_ARGS) \
277 #define FUNCTION_ARG_REGNO_P(r) \
278 (((r) >= LM32_FIRST_ARG_REG) && ((r) <= LM32_NUM_ARG_REGS))
280 /*--------------------*/
281 /* Function results. */
282 /*--------------------*/
284 #define FUNCTION_VALUE(VALTYPE, FUNC) \
285 gen_rtx_REG ((INTEGRAL_TYPE_P (VALTYPE) \
286 && TYPE_PRECISION (VALTYPE) < BITS_PER_WORD) \
288 : TYPE_MODE (VALTYPE), \
291 #define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, RV_REGNUM)
293 #define FUNCTION_VALUE_REGNO_P(N) ((N) == RV_REGNUM)
295 #define RETURN_IN_MEMORY(TYPE) lm32_return_in_memory (TYPE)
297 #define DEFAULT_PCC_STRUCT_RETURN 0
299 /* Convert from bytes to ints. */
300 #define LM32_NUM_INTS(X) (((X) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
302 /* The number of (integer) registers required to hold a quantity of
304 #define LM32_NUM_REGS(MODE) LM32_NUM_INTS (GET_MODE_SIZE (MODE))
306 /* The number of (integer) registers required to hold a quantity of
308 #define LM32_NUM_REGS2(MODE, TYPE) \
309 LM32_NUM_INTS ((MODE) == BLKmode ? \
310 int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE))
312 #define STRUCT_VALUE 0
314 /*---------------------------*/
315 /* Function entry and exit. */
316 /*---------------------------*/
322 #define FUNCTION_PROFILER(FILE, LABELNO)
328 #define TRAMPOLINE_SIZE 0
330 /*---------------------*/
331 /* Addressing Modes. */
332 /*---------------------*/
334 #define CONSTANT_ADDRESS_P(X) \
335 ((GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
336 || GET_CODE (X) == CONST_INT || GET_CODE (X) == HIGH \
337 || (GET_CODE (X) == CONST)))
339 #define MAX_REGS_PER_ADDRESS 1
341 #define STRICT_REG_OK_FOR_BASE_P(X) \
342 (REGNO_OK_FOR_BASE_P (REGNO (X)))
343 #define NONSTRICT_REG_OK_FOR_BASE_P(X) \
344 (G_REG_P (REGNO (X)) || !HARD_REGISTER_NUM_P (REGNO (X)))
347 #define REG_OK_FOR_BASE_P(X) STRICT_REG_OK_FOR_BASE_P(X)
349 #define REG_OK_FOR_BASE_P(X) NONSTRICT_REG_OK_FOR_BASE_P(X)
352 #define LEGITIMATE_CONSTANT_P(X) lm32_legitimate_constant_p (X)
354 /*-------------------------*/
355 /* Condition Code Status. */
356 /*-------------------------*/
358 #define REVERSIBLE_CC_MODE(MODE) 1
364 #define SLOW_BYTE_ACCESS 1
366 #define NO_FUNCTION_CSE
368 #define BRANCH_COST(speed_p, predictable_p) 4
370 #define MOVE_RATIO(speed) (speed ? 24 : 3)
376 #define TEXT_SECTION_ASM_OP "\t.section\t.text"
377 #define DATA_SECTION_ASM_OP "\t.section\t.data"
378 #define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\""
379 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
380 #define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\""
386 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? GP_REGNUM : INVALID_REGNUM)
388 #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
390 #define LEGITIMATE_PIC_OPERAND_P(X) \
391 (!(nonpic_symbol_mentioned_p (X)))
397 #define ASM_COMMENT_START "#"
399 #define ASM_APP_ON "#APP\n"
401 #define ASM_APP_OFF "#NO_APP\n"
403 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
405 fputc ( '\t', FILE); \
406 assemble_name (FILE, LABEL1); \
407 fputs ( " = ", FILE); \
408 assemble_name (FILE, LABEL2); \
409 fputc ( '\n', FILE); \
412 /* Override default implementation in elfos.h to support -G. */
413 #undef ASM_OUTPUT_ALIGNED_LOCAL
414 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
416 if ((SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value) \
417 switch_to_section (sbss_section); \
419 switch_to_section (bss_section); \
420 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
421 if (!flag_inhibit_size_directive) \
422 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
423 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
424 ASM_OUTPUT_LABEL(FILE, NAME); \
425 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
428 /* Override default implementation in elfos.h to support -G. */
429 #undef ASM_OUTPUT_ALIGNED_COMMON
430 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
433 if ((SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value) \
435 switch_to_section (sbss_section); \
436 (*targetm.asm_out.globalize_label) (FILE, NAME); \
437 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
438 if (!flag_inhibit_size_directive) \
439 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
440 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
441 ASM_OUTPUT_LABEL(FILE, NAME); \
442 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
446 switch_to_section (bss_section); \
447 fprintf ((FILE), "%s", COMMON_ASM_OP); \
448 assemble_name ((FILE), (NAME)); \
449 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
450 (SIZE), (ALIGN) / BITS_PER_UNIT); \
455 #define ASM_OUTPUT_LABEL(FILE, NAME) \
456 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
458 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
460 const char *xname = (NAME); \
461 if (xname[0] == '@') \
463 if (xname[0] == '*') \
465 fputs (xname, FILE); \
468 #define ASM_OUTPUT_SYMBOL_REF(STREAM, SYMBOL) \
470 assemble_name (STREAM, XSTR (SYMBOL, 0)); \
473 #define GLOBAL_ASM_OP "\t.global\t"
475 #define REGISTER_NAMES \
477 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
478 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
479 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
480 "r24", "r25", "gp", "fp", "sp", "ra", "ea", "ba"}
482 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
483 (((CHAR) == '&') || ((CHAR) == '@') || ((CHAR) == '*'))
485 #define PRINT_OPERAND(FILE, X, CODE) \
486 lm32_print_operand (FILE, X, CODE)
488 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
489 lm32_print_operand_address (FILE, ADDR)
491 #ifndef LOCAL_LABEL_PREFIX
492 #define LOCAL_LABEL_PREFIX "."
495 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
496 do { if ((LOG) != 0) fprintf (FILE, "\t.align %d\n", (1 << (LOG))); } while (0)
498 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
501 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
502 fprintf (FILE, "\n\t.word\t"); \
503 assemble_name (FILE, label); \
504 fprintf (FILE, "\n"); \
507 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
510 fprintf (FILE, "\t.word\t("); \
511 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
512 assemble_name (FILE, label); \
513 fprintf (FILE, "-"); \
514 ASM_GENERATE_INTERNAL_LABEL (label, "L", REL); \
515 assemble_name (FILE, label); \
516 fprintf (FILE, ")\n"); \
523 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
525 #define DEFAULT_GDB_EXTENSIONS 1
531 #define CASE_VECTOR_MODE Pmode
533 #define WORD_REGISTER_OPERATIONS
535 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
537 #define SHORT_IMMEDIATES_SIGN_EXTEND
539 #define MOVE_MAX UNITS_PER_WORD
540 #define MAX_MOVE_MAX 4
542 #define SHIFT_COUNT_TRUNCATED 1
544 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
548 #define FUNCTION_MODE SImode
550 #ifndef NO_IMPLICIT_EXTERN_C
551 #define NO_IMPLICIT_EXTERN_C
554 #define STORE_FLAG_VALUE 1