]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/lm32/lm32.h
always define WORD_REGISTER_OPERATIONS
[thirdparty/gcc.git] / gcc / config / lm32 / lm32.h
CommitLineData
aa4945c1
JB
1/* Definitions of target machine for GNU compiler, Lattice Mico32 architecture.
2 Contributed by Jon Beniston <jon@beniston.com>
3
5624e564 4 Copyright (C) 2009-2015 Free Software Foundation, Inc.
aa4945c1
JB
5
6 This file is part of GCC.
7
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.
12
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.
17
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/>. */
21
22/*-------------------------------*/
23/* Run-time Target Specification */
24/*-------------------------------*/
25
aa4945c1
JB
26/* Target CPU builtins. */
27#define TARGET_CPU_CPP_BUILTINS() \
28 do \
29 { \
30 builtin_define ("__lm32__"); \
31 builtin_assert ("cpu=lm32"); \
32 builtin_assert ("machine=lm32"); \
33 if (TARGET_MULTIPLY_ENABLED) \
34 builtin_define ("__multiply_enabled__"); \
35 if (TARGET_DIVIDE_ENABLED) \
36 builtin_define ("__divide_enabled__"); \
37 if (TARGET_BARREL_SHIFT_ENABLED) \
38 builtin_define ("__barrel_shift_enabled__"); \
39 if (TARGET_SIGN_EXTEND_ENABLED) \
40 builtin_define ("__sign_extend_enabled__"); \
41 if (TARGET_USER_ENABLED) \
42 builtin_define ("__user_enabled__"); \
43 } \
44 while (0)
45
46#undef ASM_SPEC
47#define ASM_SPEC "\
48%{mmultiply-enabled} \
49%{mdivide-enabled} \
50%{mbarrel-shift-enabled} \
51%{msign-extend-enabled} \
45cab1d7 52%{muser-enabled} \
aa4945c1
JB
53"
54
55/* Let link script define all link options.
56 Default to using simulator link script. */
57
58#undef STARTFILE_SPEC
59#define STARTFILE_SPEC ""
60#undef ENDFILE_SPEC
61#define ENDFILE_SPEC ""
62#undef LIB_SPEC
63#define LIB_SPEC "%{!T*:-T sim.ld}"
64
aa4945c1
JB
65#undef CC1_SPEC
66#define CC1_SPEC "%{G*}"
67
68/*---------------------------------*/
69/* Target machine storage layout. */
70/*---------------------------------*/
71
72#define BITS_BIG_ENDIAN 0
73#define BYTES_BIG_ENDIAN 1
74#define WORDS_BIG_ENDIAN 1
aa4945c1 75
aa4945c1
JB
76#define BITS_PER_WORD 32
77#define UNITS_PER_WORD 4
78
79#define POINTER_SIZE 32
80
81#define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
82do { \
83 if (GET_MODE_CLASS (MODE) == MODE_INT \
84 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
85 (MODE) = word_mode; \
86} while (0)
87
88#define PARM_BOUNDARY 32
89
90#define STACK_BOUNDARY 32
91
92#define BIGGEST_ALIGNMENT 64
93
94#define FUNCTION_BOUNDARY 32
95
96#define EMPTY_FIELD_BOUNDARY 32
97
98#define STRICT_ALIGNMENT 1
99
100#define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
101
102/* Make strings word-aligned so strcpy from constants will be faster. */
103#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
104 (TREE_CODE (EXP) == STRING_CST \
105 && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
106
107/* Make arrays and structures word-aligned to allow faster copying etc. */
108#define DATA_ALIGNMENT(TYPE, ALIGN) \
109 ((((ALIGN) < BITS_PER_WORD) \
110 && (TREE_CODE (TYPE) == ARRAY_TYPE \
111 || TREE_CODE (TYPE) == UNION_TYPE \
112 || TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
113
114/* We need this for the same reason as DATA_ALIGNMENT, namely to cause
115 character arrays to be word-aligned so that `strcpy' calls that copy
116 constants to character arrays can be done inline, and 'strcmp' can be
117 optimised to use word loads. */
118#define LOCAL_ALIGNMENT(TYPE, ALIGN) \
119 DATA_ALIGNMENT (TYPE, ALIGN)
120
121/*----------------------------------------*/
122/* Layout of source language data types. */
123/*----------------------------------------*/
124
125#define INT_TYPE_SIZE 32
126#define SHORT_TYPE_SIZE 16
127#define LONG_TYPE_SIZE 32
128#define LONG_LONG_TYPE_SIZE 64
129
130#define FLOAT_TYPE_SIZE 32
131#define DOUBLE_TYPE_SIZE 64
132#define LONG_DOUBLE_TYPE_SIZE 64
133
134#define DEFAULT_SIGNED_CHAR 0
135
136#define SIZE_TYPE "unsigned int"
137
138#define PTRDIFF_TYPE "int"
139
140/*---------------------------*/
141/* Standard register usage. */
142/*---------------------------*/
143
144#define FIRST_PSEUDO_REGISTER 32
145
146#define RV_REGNUM 1
147#define GP_REGNUM 26
148#define FP_REGNUM 27
149#define SP_REGNUM 28
150#define RA_REGNUM 29
151
152#define G_REG_P(X) ((X)<32)
153
154#define FIXED_REGISTERS \
155{ 1, 0, 0, 0, 0, 0, 0, 0, \
156 0, 0, 0, 0, 0, 0, 0, 0, \
157 0, 0, 0, 0, 0, 0, 0, 0, \
158 0, 0, 1, 0, 1, 0, 1, 1}
159
160#define CALL_USED_REGISTERS \
161{ 1, 1, 1, 1, 1, 1, 1, 1, \
162 1, 1, 1, 0, 0, 0, 0, 0, \
163 0, 0, 0, 0, 0, 0, 0, 0, \
164 0, 0, 1, 0, 1, 0, 1, 1}
165
166#define HARD_REGNO_NREGS(REGNO, MODE) \
167 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
168
169#define HARD_REGNO_MODE_OK(REGNO, MODE) G_REG_P(REGNO)
170
171#define MODES_TIEABLE_P(MODE1, MODE2) \
172( GET_MODE_CLASS (MODE1) == MODE_INT \
173 && GET_MODE_CLASS (MODE2) == MODE_INT \
174 && GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD \
175 && GET_MODE_SIZE (MODE2) <= UNITS_PER_WORD)
176
177#define AVOID_CCMODE_COPIES
178
179/*----------------------------------*/
180/* Register classes and constants. */
181/*----------------------------------*/
182
183enum reg_class
184{
185 NO_REGS,
186 GENERAL_REGS,
187 ALL_REGS,
188 LIM_REG_CLASSES
189};
190
191#define N_REG_CLASSES (int) LIM_REG_CLASSES
192
193#define REG_CLASS_NAMES { "NO_REGS", "GENERAL_REGS", "ALL_REGS" }
194
195#define REG_CLASS_CONTENTS \
196{ {0x00000000}, \
197 {0xffffffff}, \
198 {0xffffffff} \
199}
200
201#define REGNO_REG_CLASS(REGNO) \
202 (G_REG_P(REGNO) ? GENERAL_REGS : NO_REGS)
203
aa4945c1
JB
204#define INDEX_REG_CLASS NO_REGS
205
206#define BASE_REG_CLASS GENERAL_REGS
207
208#define REGNO_OK_FOR_BASE_P(REGNO) \
209 (G_REG_P (REGNO) || G_REG_P ((unsigned) reg_renumber[REGNO]))
210
211#define REGNO_OK_FOR_INDEX_P(REGNO) 0
212
aa4945c1
JB
213/*----------------------------------------*/
214/* Stack Layout and Calling Conventions. */
215/*----------------------------------------*/
216
217#define STACK_GROWS_DOWNWARD 1
218
219#define FRAME_GROWS_DOWNWARD 1
220
221#define STACK_POINTER_OFFSET (UNITS_PER_WORD)
222
223#define STARTING_FRAME_OFFSET (UNITS_PER_WORD)
224
225#define FIRST_PARM_OFFSET(FNDECL) (UNITS_PER_WORD)
226
227#define STACK_POINTER_REGNUM SP_REGNUM
228
229#define FRAME_POINTER_REGNUM FP_REGNUM
230
231#define ARG_POINTER_REGNUM FRAME_POINTER_REGNUM
232
308d39cd
SB
233#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (SImode, RA_REGNUM)
234
aa4945c1
JB
235#define RETURN_ADDR_RTX(count, frame) \
236 lm32_return_addr_rtx (count, frame)
237
238/* FIXME - This is not yet supported. */
239#define STATIC_CHAIN_REGNUM 9
240
241#define ELIMINABLE_REGS \
242{{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
243 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
244}
245
246#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
247 (OFFSET) = lm32_compute_initial_elimination_offset (FROM, TO)
248
249/*-----------------------------*/
250/* Function argument passing. */
251/*-----------------------------*/
252
253#define ACCUMULATE_OUTGOING_ARGS 1
254
aa4945c1
JB
255/*--------------------------------*/
256/* Passing Arguments in Registers */
257/*--------------------------------*/
258
259/* The first argument register. */
260#define LM32_FIRST_ARG_REG 1
261
262/* The number of (integer) argument register available. */
263#define LM32_NUM_ARG_REGS 8
264
aa4945c1
JB
265#define CUMULATIVE_ARGS int
266
267#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT,N_NAMED_ARGS) \
268 (CUM) = 0
269
aa4945c1
JB
270#define FUNCTION_ARG_REGNO_P(r) \
271 (((r) >= LM32_FIRST_ARG_REG) && ((r) <= LM32_NUM_ARG_REGS))
272
273/*--------------------*/
274/* Function results. */
275/*--------------------*/
276
277#define FUNCTION_VALUE(VALTYPE, FUNC) \
278 gen_rtx_REG ((INTEGRAL_TYPE_P (VALTYPE) \
279 && TYPE_PRECISION (VALTYPE) < BITS_PER_WORD) \
280 ? word_mode \
281 : TYPE_MODE (VALTYPE), \
282 RV_REGNUM)
283
284#define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, RV_REGNUM)
285
286#define FUNCTION_VALUE_REGNO_P(N) ((N) == RV_REGNUM)
287
288#define RETURN_IN_MEMORY(TYPE) lm32_return_in_memory (TYPE)
289
290#define DEFAULT_PCC_STRUCT_RETURN 0
291
292/* Convert from bytes to ints. */
293#define LM32_NUM_INTS(X) (((X) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
294
295/* The number of (integer) registers required to hold a quantity of
296 type MODE. */
297#define LM32_NUM_REGS(MODE) LM32_NUM_INTS (GET_MODE_SIZE (MODE))
298
299/* The number of (integer) registers required to hold a quantity of
300 TYPE MODE. */
301#define LM32_NUM_REGS2(MODE, TYPE) \
302 LM32_NUM_INTS ((MODE) == BLKmode ? \
303 int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE))
304
305#define STRUCT_VALUE 0
306
307/*---------------------------*/
308/* Function entry and exit. */
309/*---------------------------*/
310
311/*-------------*/
312/* Profiling. */
313/*-------------*/
314
315#define FUNCTION_PROFILER(FILE, LABELNO)
316
317/*---------------*/
318/* Trampolines. */
319/*---------------*/
320
321#define TRAMPOLINE_SIZE 0
322
323/*---------------------*/
324/* Addressing Modes. */
325/*---------------------*/
326
327#define CONSTANT_ADDRESS_P(X) \
328 ((GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
329 || GET_CODE (X) == CONST_INT || GET_CODE (X) == HIGH \
330 || (GET_CODE (X) == CONST)))
331
332#define MAX_REGS_PER_ADDRESS 1
333
334#define STRICT_REG_OK_FOR_BASE_P(X) \
335 (REGNO_OK_FOR_BASE_P (REGNO (X)))
336#define NONSTRICT_REG_OK_FOR_BASE_P(X) \
337 (G_REG_P (REGNO (X)) || !HARD_REGISTER_NUM_P (REGNO (X)))
338
339#ifdef REG_OK_STRICT
340#define REG_OK_FOR_BASE_P(X) STRICT_REG_OK_FOR_BASE_P(X)
341#else
342#define REG_OK_FOR_BASE_P(X) NONSTRICT_REG_OK_FOR_BASE_P(X)
343#endif
344
aa4945c1
JB
345/*-------------------------*/
346/* Condition Code Status. */
347/*-------------------------*/
348
349#define REVERSIBLE_CC_MODE(MODE) 1
350
351/*---------*/
352/* Costs. */
353/*---------*/
354
355#define SLOW_BYTE_ACCESS 1
356
1e8552c2 357#define NO_FUNCTION_CSE 1
aa4945c1
JB
358
359#define BRANCH_COST(speed_p, predictable_p) 4
360
361#define MOVE_RATIO(speed) (speed ? 24 : 3)
362
363/*------------*/
364/* Sections. */
365/*------------*/
366
367#define TEXT_SECTION_ASM_OP "\t.section\t.text"
368#define DATA_SECTION_ASM_OP "\t.section\t.data"
369#define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\""
370#define BSS_SECTION_ASM_OP "\t.section\t.bss"
371#define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\""
372
373/*-------*/
374/* PIC. */
375/*-------*/
376
377#define PIC_OFFSET_TABLE_REGNUM (flag_pic ? GP_REGNUM : INVALID_REGNUM)
378
379#define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
380
381#define LEGITIMATE_PIC_OPERAND_P(X) \
382 (!(nonpic_symbol_mentioned_p (X)))
383
384/*-------------*/
385/* Assembler. */
386/*-------------*/
387
388#define ASM_COMMENT_START "#"
389
390#define ASM_APP_ON "#APP\n"
391
392#define ASM_APP_OFF "#NO_APP\n"
393
394#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
395 do { \
396 fputc ( '\t', FILE); \
397 assemble_name (FILE, LABEL1); \
398 fputs ( " = ", FILE); \
399 assemble_name (FILE, LABEL2); \
400 fputc ( '\n', FILE); \
401 } while (0)
402
403/* Override default implementation in elfos.h to support -G. */
404#undef ASM_OUTPUT_ALIGNED_LOCAL
405#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
406do { \
fa37ed29 407 if ((SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value) \
aa4945c1
JB
408 switch_to_section (sbss_section); \
409 else \
410 switch_to_section (bss_section); \
411 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
412 if (!flag_inhibit_size_directive) \
413 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
414 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
415 ASM_OUTPUT_LABEL(FILE, NAME); \
416 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
417} while (0)
418
419/* Override default implementation in elfos.h to support -G. */
420#undef ASM_OUTPUT_ALIGNED_COMMON
421#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
422do \
423{ \
fa37ed29 424 if ((SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value) \
aa4945c1
JB
425 { \
426 switch_to_section (sbss_section); \
427 (*targetm.asm_out.globalize_label) (FILE, NAME); \
428 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
429 if (!flag_inhibit_size_directive) \
430 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
431 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
432 ASM_OUTPUT_LABEL(FILE, NAME); \
433 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
434 } \
435 else \
436 { \
437 switch_to_section (bss_section); \
438 fprintf ((FILE), "%s", COMMON_ASM_OP); \
439 assemble_name ((FILE), (NAME)); \
16998094 440 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
aa4945c1
JB
441 (SIZE), (ALIGN) / BITS_PER_UNIT); \
442 } \
443} \
444while (0)
445
446#define ASM_OUTPUT_LABEL(FILE, NAME) \
447 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
448
449#define ASM_OUTPUT_LABELREF(FILE,NAME) \
450 do { \
451 const char *xname = (NAME); \
452 if (xname[0] == '@') \
453 xname += 1; \
454 if (xname[0] == '*') \
455 xname += 1; \
456 fputs (xname, FILE); \
457 } while (0)
458
459#define ASM_OUTPUT_SYMBOL_REF(STREAM, SYMBOL) \
460 do { \
461 assemble_name (STREAM, XSTR (SYMBOL, 0)); \
462 } while (0)
463
464#define GLOBAL_ASM_OP "\t.global\t"
465
466#define REGISTER_NAMES \
467{ \
468 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
469 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
470 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
471 "r24", "r25", "gp", "fp", "sp", "ra", "ea", "ba"}
472
473#define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
474 (((CHAR) == '&') || ((CHAR) == '@') || ((CHAR) == '*'))
475
476#define PRINT_OPERAND(FILE, X, CODE) \
477 lm32_print_operand (FILE, X, CODE)
478
479#define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
480 lm32_print_operand_address (FILE, ADDR)
481
482#ifndef LOCAL_LABEL_PREFIX
483#define LOCAL_LABEL_PREFIX "."
484#endif
485
486#define ASM_OUTPUT_ALIGN(FILE,LOG) \
487 do { if ((LOG) != 0) fprintf (FILE, "\t.align %d\n", (1 << (LOG))); } while (0)
488
489#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
490do { \
491 char label[64]; \
492 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
493 fprintf (FILE, "\n\t.word\t"); \
494 assemble_name (FILE, label); \
495 fprintf (FILE, "\n"); \
496} while (0)
497
498#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
499do { \
500 char label[64]; \
501 fprintf (FILE, "\t.word\t("); \
502 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
503 assemble_name (FILE, label); \
504 fprintf (FILE, "-"); \
505 ASM_GENERATE_INTERNAL_LABEL (label, "L", REL); \
506 assemble_name (FILE, label); \
507 fprintf (FILE, ")\n"); \
508} while (0)
509
510/*-------------*/
511/* Debugging. */
512/*-------------*/
513
514#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
515
aa4945c1
JB
516#define DEFAULT_GDB_EXTENSIONS 1
517
518/*--------*/
519/* Misc. */
520/*--------*/
521
522#define CASE_VECTOR_MODE Pmode
523
9e11bfef 524#define WORD_REGISTER_OPERATIONS 1
aa4945c1
JB
525
526#define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
527
58f2ae18 528#define SHORT_IMMEDIATES_SIGN_EXTEND 1
aa4945c1
JB
529
530#define MOVE_MAX UNITS_PER_WORD
531#define MAX_MOVE_MAX 4
532
533#define SHIFT_COUNT_TRUNCATED 1
534
535#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
536
537#define Pmode SImode
538
539#define FUNCTION_MODE SImode
540
541#ifndef NO_IMPLICIT_EXTERN_C
542#define NO_IMPLICIT_EXTERN_C
543#endif
544
545#define STORE_FLAG_VALUE 1