target.h (asm_out.byte_op, [...]): New fields.
[gcc.git] / gcc / config / mcore / mcore.h
1 /* Definitions of target machine for GNU compiler,
2 for Motorola M*CORE Processor.
3 Copyright (C) 1993, 1999, 2000, 2001 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 #ifndef GCC_MCORE_H
23 #define GCC_MCORE_H
24
25 /* RBE: need to move these elsewhere. */
26 #undef LIKE_PPC_ABI
27 #define MCORE_STRUCT_ARGS
28 /* RBE: end of "move elsewhere". */
29
30 #include "hwint.h"
31
32 #ifndef HAVE_MACHINE_MODES
33 #include "machmode.h"
34 #endif
35
36 /* Run-time Target Specification. */
37 #define TARGET_MCORE
38
39 /* Get tree.c to declare a target-specific specialization of
40 merge_decl_attributes. */
41 #define TARGET_DLLIMPORT_DECL_ATTRIBUTES
42
43 /* Support the __declspec keyword by turning them into attributes.
44 We currently only support: dllexport and dllimport.
45 Note that the current way we do this may result in a collision with
46 predefined attributes later on. This can be solved by using one attribute,
47 say __declspec__, and passing args to it. The problem with that approach
48 is that args are not accumulated: each new appearance would clobber any
49 existing args. XXX- FIXME the definition below relies upon string
50 concatenation, which is non-portable. */
51 #define CPP_PREDEFINES \
52 "-D__mcore__ -D__MCORE__=1 -D__declspec(x)=__attribute__((x))" SUBTARGET_CPP_PREDEFINES
53
54 /* If -m4align is ever re-enabled then uncomment this line as well:
55 #define CPP_SPEC "%{!m4align:-D__MCORE_ALIGN_8__} %{m4align:-D__MCORE__ALIGN_4__}" */
56
57 #undef CPP_SPEC
58 #define CPP_SPEC " \
59 %{mbig-endian: \
60 %{mlittle-endian:%echoose either big or little endian, not both} \
61 -D__MCOREBE__} \
62 %{m210: \
63 %{m340:%echoose either m340 or m210 not both} \
64 %{mlittle-endian:%ethe m210 does not have little endian support} \
65 -D__M210__} \
66 %{!mbig-endian: -D__MCORELE__} \
67 %{!m210: -D__M340__} \
68 "
69 /* If -m4align is ever re-enabled then add this line to the definition of CPP_SPEC
70 %{!m4align:-D__MCORE_ALIGN_8__} %{m4align:-D__MCORE__ALIGN_4__} */
71
72 /* We don't have a -lg library, so don't put it in the list. */
73 #undef LIB_SPEC
74 #define LIB_SPEC "%{!shared: %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
75
76 #undef ASM_SPEC
77 #define ASM_SPEC "%{mbig-endian:-EB} %{m210:-cpu=210 -EB}"
78
79 #undef LINK_SPEC
80 #define LINK_SPEC "%{mbig-endian:-EB} %{m210:-EB} -X"
81
82 /* Can only count on 16 bits of availability; change to long would affect
83 many architecture specific files (other architectures...). */
84 extern int target_flags;
85
86 #define HARDLIT_BIT (1 << 0) /* Build in-line literals using 2 insns */
87 #define ALIGN8_BIT (1 << 1) /* Max alignment goes to 8 instead of 4 */
88 #define DIV_BIT (1 << 2) /* Generate divide instructions */
89 #define RELAX_IMM_BIT (1 << 3) /* Arbitrary immediates in and, or, tst */
90 #define W_FIELD_BIT (1 << 4) /* Generate bit insv/extv using SImode */
91 #define OVERALIGN_FUNC_BIT (1 << 5) /* Align functions to 4 byte boundary */
92 #define CGDATA_BIT (1 << 6) /* Generate callgraph data */
93 #define SLOW_BYTES_BIT (1 << 7) /* Slow byte access */
94 #define LITTLE_END_BIT (1 << 8) /* Generate little endian code */
95 #define M340_BIT (1 << 9) /* Generate code for the m340 */
96
97 #define TARGET_DEFAULT \
98 (HARDLIT_BIT | ALIGN8_BIT | DIV_BIT | RELAX_IMM_BIT | M340_BIT | LITTLE_END_BIT)
99
100 #ifndef MULTILIB_DEFAULTS
101 #define MULTILIB_DEFAULTS { "mlittle-endian", "m340" }
102 #endif
103
104 #define TARGET_HARDLIT (target_flags & HARDLIT_BIT)
105 /* The ability to have 4 byte alignment is being suppressed for now.
106 If this ability is reenabled, you must enable the definition below
107 *and* edit t-mcore to enable multilibs for 4 byte alignment code. */
108 #if 0
109 #define TARGET_8ALIGN (target_flags & ALIGN8_BIT)
110 #else
111 #define TARGET_8ALIGN 1
112 #endif
113 #define TARGET_DIV (target_flags & DIV_BIT)
114 #define TARGET_RELAX_IMM (target_flags & RELAX_IMM_BIT)
115 #define TARGET_W_FIELD (target_flags & W_FIELD_BIT)
116 #define TARGET_OVERALIGN_FUNC (target_flags & OVERALIGN_FUNC_BIT)
117 #define TARGET_CG_DATA (target_flags & CGDATA_BIT)
118 #define TARGET_CG_DATA (target_flags & CGDATA_BIT)
119 #define TARGET_SLOW_BYTES (target_flags & SLOW_BYTES_BIT)
120 #define TARGET_LITTLE_END (target_flags & LITTLE_END_BIT)
121 #define TARGET_M340 (target_flags & M340_BIT)
122
123
124 #define TARGET_SWITCHES \
125 { {"hardlit", HARDLIT_BIT, \
126 N_("Inline constants if it can be done in 2 insns or less") }, \
127 {"no-hardlit", - HARDLIT_BIT, \
128 N_("Inline constants if it only takes 1 instruction") }, \
129 {"4align", - ALIGN8_BIT, \
130 N_("Set maximum alignment to 4") }, \
131 {"8align", ALIGN8_BIT, \
132 N_("Set maximum alignment to 8") }, \
133 {"div", DIV_BIT, \
134 "" }, \
135 {"no-div", - DIV_BIT, \
136 N_("Do not use the divide instruction") }, \
137 {"relax-immediates", RELAX_IMM_BIT, \
138 "" }, \
139 {"no-relax-immediates", - RELAX_IMM_BIT, \
140 N_("Do not arbitary sized immediates in bit operations") }, \
141 {"wide-bitfields", W_FIELD_BIT, \
142 N_("Always treat bit-field as int-sized") }, \
143 {"no-wide-bitfields", - W_FIELD_BIT, \
144 "" }, \
145 {"4byte-functions", OVERALIGN_FUNC_BIT, \
146 N_("Force functions to be aligned to a 4 byte boundary") }, \
147 {"no-4byte-functions", - OVERALIGN_FUNC_BIT, \
148 N_("Force functions to be aligned to a 2 byte boundary") }, \
149 {"callgraph-data", CGDATA_BIT, \
150 N_("Emit call graph information") }, \
151 {"no-callgraph-data", - CGDATA_BIT, \
152 "" }, \
153 {"slow-bytes", SLOW_BYTES_BIT, \
154 N_("Prefer word accesses over byte accesses") }, \
155 {"no-slow-bytes", - SLOW_BYTES_BIT, \
156 "" }, \
157 { "no-lsim", 0, "" }, \
158 {"little-endian", LITTLE_END_BIT, \
159 N_("Generate little endian code") }, \
160 {"big-endian", - LITTLE_END_BIT, \
161 "" }, \
162 {"210", - M340_BIT, \
163 "" }, \
164 {"340", M340_BIT, \
165 N_("Generate code for the M*Core M340") }, \
166 {"", TARGET_DEFAULT, \
167 "" } \
168 }
169
170 extern char * mcore_current_function_name;
171
172 /* Target specific options (as opposed to the switches above). */
173 extern const char * mcore_stack_increment_string;
174
175 #define TARGET_OPTIONS \
176 { \
177 {"stack-increment=", & mcore_stack_increment_string, \
178 N_("Maximum amount for a single stack increment operation")} \
179 }
180
181 /* The MCore ABI says that bitfields are unsigned by default. */
182 /* The EPOC C++ environment does not support exceptions. */
183 #define CC1_SPEC "-funsigned-bitfields %{!DIN_GCC:-fno-rtti} %{!DIN_GCC:-fno-exceptions}"
184
185 /* What options are we going to default to specific settings when
186 -O* happens; the user can subsequently override these settings.
187
188 Omitting the frame pointer is a very good idea on the MCore.
189 Scheduling isn't worth anything on the current MCore implementation. */
190 #define OPTIMIZATION_OPTIONS(LEVEL,SIZE) \
191 { \
192 if (LEVEL) \
193 { \
194 flag_no_function_cse = 1; \
195 flag_omit_frame_pointer = 1; \
196 \
197 if (LEVEL >= 2) \
198 { \
199 flag_caller_saves = 0; \
200 flag_schedule_insns = 0; \
201 flag_schedule_insns_after_reload = 0; \
202 } \
203 } \
204 if (SIZE) \
205 { \
206 target_flags &= ~ HARDLIT_BIT; \
207 } \
208 }
209
210 /* What options are we going to force to specific settings,
211 regardless of what the user thought he wanted.
212 We also use this for some post-processing of options. */
213 #define OVERRIDE_OPTIONS mcore_override_options ()
214
215 /* Target machine storage Layout. */
216
217 /* Define to use software floating point emulator for REAL_ARITHMETIC and
218 decimal <-> binary conversion. */
219 #define REAL_ARITHMETIC
220
221 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
222 if (GET_MODE_CLASS (MODE) == MODE_INT \
223 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
224 { \
225 (MODE) = SImode; \
226 (UNSIGNEDP) = 1; \
227 }
228
229 #define PROMOTE_FUNCTION_ARGS
230
231 #define PROMOTE_FUNCTION_RETURN
232
233 /* Define this if most significant bit is lowest numbered
234 in instructions that operate on numbered bit-fields. */
235 #define BITS_BIG_ENDIAN 0
236
237 /* Define this if most significant byte of a word is the lowest numbered. */
238 #define BYTES_BIG_ENDIAN (! TARGET_LITTLE_END)
239
240 /* Define this if most significant word of a multiword number is the lowest
241 numbered. */
242 #define WORDS_BIG_ENDIAN (! TARGET_LITTLE_END)
243
244 #define LIBGCC2_WORDS_BIG_ENDIAN 1
245 #ifdef __MCORELE__
246 #undef LIBGCC2_WORDS_BIG_ENDIAN
247 #define LIBGCC2_WORDS_BIG_ENDIAN 0
248 #endif
249
250 /* Number of bits in an addressable storage unit. */
251 #define BITS_PER_UNIT 8
252
253 /* Width in bits of a "word", which is the contents of a machine register.
254 Note that this is not necessarily the width of data type `int';
255 if using 16-bit ints on a 68000, this would still be 32.
256 But on a machine with 16-bit registers, this would be 16. */
257 #define BITS_PER_WORD 32
258 #define MAX_BITS_PER_WORD 32
259
260 /* Width of a word, in units (bytes). */
261 #define UNITS_PER_WORD 4
262
263 /* Width in bits of a pointer.
264 See also the macro `Pmode' defined below. */
265 #define POINTER_SIZE 32
266
267 /* A C expression for the size in bits of the type `long long' on the
268 target machine. If you don't define this, the default is two
269 words. */
270 #define LONG_LONG_TYPE_SIZE 64
271
272 /* the size of the boolean type -- in C++; */
273 #define BOOL_TYPE_SIZE 8
274
275 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
276 #define PARM_BOUNDARY 32
277
278 /* Doubles must be alogned to an 8 byte boundary. */
279 #define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \
280 ((MODE != BLKmode && (GET_MODE_SIZE (MODE) == 8)) \
281 ? BIGGEST_ALIGNMENT : PARM_BOUNDARY)
282
283 /* Boundary (in *bits*) on which stack pointer should be aligned. */
284 #define STACK_BOUNDARY (TARGET_8ALIGN ? 64 : 32)
285
286 /* Largest increment in UNITS we allow the stack to grow in a single operation. */
287 extern int mcore_stack_increment;
288 #define STACK_UNITS_MAXSTEP 4096
289
290 /* Allocation boundary (in *bits*) for the code of a function. */
291 #define FUNCTION_BOUNDARY ((TARGET_OVERALIGN_FUNC) ? 32 : 16)
292
293 /* Alignment of field after `int : 0' in a structure. */
294 #define EMPTY_FIELD_BOUNDARY 32
295
296 /* No data type wants to be aligned rounder than this. */
297 #define BIGGEST_ALIGNMENT (TARGET_8ALIGN ? 64 : 32)
298
299 /* The best alignment to use in cases where we have a choice. */
300 #define FASTEST_ALIGNMENT 32
301
302 /* Every structures size must be a multiple of 8 bits. */
303 #define STRUCTURE_SIZE_BOUNDARY 8
304
305 /* Look at the fundamental type that is used for a bitfield and use
306 that to impose alignment on the enclosing structure.
307 struct s {int a:8}; should have same alignment as "int", not "char". */
308 #define PCC_BITFIELD_TYPE_MATTERS 1
309
310 /* Largest integer machine mode for structures. If undefined, the default
311 is GET_MODE_SIZE(DImode). */
312 #define MAX_FIXED_MODE_SIZE 32
313
314 /* Make strings word-aligned so strcpy from constants will be faster. */
315 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
316 ((TREE_CODE (EXP) == STRING_CST \
317 && (ALIGN) < FASTEST_ALIGNMENT) \
318 ? FASTEST_ALIGNMENT : (ALIGN))
319
320 /* Make arrays of chars word-aligned for the same reasons. */
321 #define DATA_ALIGNMENT(TYPE, ALIGN) \
322 (TREE_CODE (TYPE) == ARRAY_TYPE \
323 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
324 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
325
326 /* Set this nonzero if move instructions will actually fail to work
327 when given unaligned data. */
328 #define STRICT_ALIGNMENT 1
329
330 /* Standard register usage. */
331
332 /* Register allocation for our first guess
333
334 r0 stack pointer
335 r1 scratch, target reg for xtrb?
336 r2-r7 arguments.
337 r8-r14 call saved
338 r15 link register
339 ap arg pointer (doesn't really exist, always eliminated)
340 c c bit
341 fp frame pointer (doesn't really exist, always eliminated)
342 x19 two control registers */
343
344 /* Number of actual hardware registers.
345 The hardware registers are assigned numbers for the compiler
346 from 0 to just below FIRST_PSEUDO_REGISTER.
347 All registers that the compiler knows about must be given numbers,
348 even those that are not normally considered general registers.
349
350 MCore has 16 integer registers and 2 control registers + the arg
351 pointer. */
352
353 #define FIRST_PSEUDO_REGISTER 20
354
355 #define R1_REG 1 /* where literals are forced */
356 #define LK_REG 15 /* overloaded on general register */
357 #define AP_REG 16 /* fake arg pointer register */
358 /* RBE: mcore.md depends on CC_REG being set to 17 */
359 #define CC_REG 17 /* can't name it C_REG */
360 #define FP_REG 18 /* fake frame pointer register */
361
362 /* Specify the registers used for certain standard purposes.
363 The values of these macros are register numbers. */
364
365
366 #undef PC_REGNUM /* Define this if the program counter is overloaded on a register. */
367 #define STACK_POINTER_REGNUM 0 /* Register to use for pushing function arguments. */
368 #define FRAME_POINTER_REGNUM 8 /* When we need FP, use r8. */
369
370 /* The assembler's names for the registers. RFP need not always be used as
371 the Real framepointer; it can also be used as a normal general register.
372 Note that the name `fp' is horribly misleading since `fp' is in fact only
373 the argument-and-return-context pointer. */
374 #define REGISTER_NAMES \
375 { \
376 "sp", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
377 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
378 "apvirtual", "c", "fpvirtual", "x19" \
379 }
380
381 /* 1 for registers that have pervasive standard uses
382 and are not available for the register allocator. */
383 #define FIXED_REGISTERS \
384 /* r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 ap c fp x19 */ \
385 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1}
386
387 /* 1 for registers not available across function calls.
388 These must include the FIXED_REGISTERS and also any
389 registers that can be used without being saved.
390 The latter must include the registers where values are returned
391 and the register where structure-value addresses are passed.
392 Aside from that, you can include as many other registers as you like. */
393
394 /* RBE: r15 {link register} not available across calls,
395 * But we don't mark it that way here... */
396 #define CALL_USED_REGISTERS \
397 /* r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 ap c fp x19 */ \
398 { 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1}
399
400 /* The order in which register should be allocated. */
401 #define REG_ALLOC_ORDER \
402 /* r7 r6 r5 r4 r3 r2 r15 r14 r13 r12 r11 r10 r9 r8 r1 r0 ap c fp x19*/ \
403 { 7, 6, 5, 4, 3, 2, 15, 14, 13, 12, 11, 10, 9, 8, 1, 0, 16, 17, 18, 19}
404
405 /* Return number of consecutive hard regs needed starting at reg REGNO
406 to hold something of mode MODE.
407 This is ordinarily the length in words of a value of mode MODE
408 but can be less for certain modes in special long registers.
409
410 On the MCore regs are UNITS_PER_WORD bits wide; */
411 #define HARD_REGNO_NREGS(REGNO, MODE) \
412 (((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
413
414 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
415 We may keep double values in even registers. */
416 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
417 ((TARGET_8ALIGN && GET_MODE_SIZE (MODE) > UNITS_PER_WORD) ? (((REGNO) & 1) == 0) : (REGNO < 18))
418
419 /* Value is 1 if it is a good idea to tie two pseudo registers
420 when one has mode MODE1 and one has mode MODE2.
421 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
422 for any hard reg, then this must be 0 for correct output. */
423 #define MODES_TIEABLE_P(MODE1, MODE2) \
424 ((MODE1) == (MODE2) || GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
425
426 /* Value should be nonzero if functions must have frame pointers.
427 Zero means the frame pointer need not be set up (and parms may be accessed
428 via the stack pointer) in functions that seem suitable. */
429 #define FRAME_POINTER_REQUIRED 0
430
431 /* Definitions for register eliminations.
432
433 We have two registers that can be eliminated on the MCore. First, the
434 frame pointer register can often be eliminated in favor of the stack
435 pointer register. Secondly, the argument pointer register can always be
436 eliminated; it is replaced with either the stack or frame pointer. */
437
438 /* Base register for access to arguments of the function. */
439 #define ARG_POINTER_REGNUM 16
440
441 /* Register in which the static-chain is passed to a function. */
442 #define STATIC_CHAIN_REGNUM 1
443
444 /* This is an array of structures. Each structure initializes one pair
445 of eliminable registers. The "from" register number is given first,
446 followed by "to". Eliminations of the same "from" register are listed
447 in order of preference. */
448 #define ELIMINABLE_REGS \
449 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
450 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
451 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},}
452
453 /* Given FROM and TO register numbers, say whether this elimination
454 is allowed. */
455 #define CAN_ELIMINATE(FROM, TO) \
456 (!((FROM) == FRAME_POINTER_REGNUM && FRAME_POINTER_REQUIRED))
457
458 /* Define the offset between two registers, one to be eliminated, and the other
459 its replacement, at the start of a routine. */
460 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
461 OFFSET = mcore_initial_elimination_offset (FROM, TO)
462
463 /* Place that structure value return address is placed. */
464 #define STRUCT_VALUE 0
465
466 /* Define the classes of registers for register constraints in the
467 machine description. Also define ranges of constants.
468
469 One of the classes must always be named ALL_REGS and include all hard regs.
470 If there is more than one class, another class must be named NO_REGS
471 and contain no registers.
472
473 The name GENERAL_REGS must be the name of a class (or an alias for
474 another name such as ALL_REGS). This is the class of registers
475 that is allowed by "g" or "r" in a register constraint.
476 Also, registers outside this class are allocated only when
477 instructions express preferences for them.
478
479 The classes must be numbered in nondecreasing order; that is,
480 a larger-numbered class must never be contained completely
481 in a smaller-numbered class.
482
483 For any two classes, it is very desirable that there be another
484 class that represents their union. */
485
486 /* The MCore has only general registers. There are
487 also some special purpose registers: the T bit register, the
488 procedure Link and the Count Registers */
489 enum reg_class
490 {
491 NO_REGS,
492 ONLYR1_REGS,
493 LRW_REGS,
494 GENERAL_REGS,
495 C_REGS,
496 ALL_REGS,
497 LIM_REG_CLASSES
498 };
499
500 #define N_REG_CLASSES (int) LIM_REG_CLASSES
501
502 /* Give names of register classes as strings for dump file. */
503 #define REG_CLASS_NAMES \
504 { \
505 "NO_REGS", \
506 "ONLYR1_REGS", \
507 "LRW_REGS", \
508 "GENERAL_REGS", \
509 "C_REGS", \
510 "ALL_REGS", \
511 }
512
513 /* Define which registers fit in which classes.
514 This is an initializer for a vector of HARD_REG_SET
515 of length N_REG_CLASSES. */
516
517 /* ??? STACK_POINTER_REGNUM should be excluded from LRW_REGS. */
518 #define REG_CLASS_CONTENTS \
519 { \
520 {0x000000}, /* NO_REGS */ \
521 {0x000002}, /* ONLYR1_REGS */ \
522 {0x007FFE}, /* LRW_REGS */ \
523 {0x01FFFF}, /* GENERAL_REGS */ \
524 {0x020000}, /* C_REGS */ \
525 {0x0FFFFF} /* ALL_REGS */ \
526 }
527
528 /* The same information, inverted:
529 Return the class number of the smallest class containing
530 reg number REGNO. This could be a conditional expression
531 or could index an array. */
532
533 extern int regno_reg_class[];
534 #define REGNO_REG_CLASS(REGNO) regno_reg_class[REGNO]
535
536 /* When defined, the compiler allows registers explicitly used in the
537 rtl to be used as spill registers but prevents the compiler from
538 extending the lifetime of these registers. */
539 #define SMALL_REGISTER_CLASSES 1
540
541 /* The class value for index registers, and the one for base regs. */
542 #define INDEX_REG_CLASS NO_REGS
543 #define BASE_REG_CLASS GENERAL_REGS
544
545 /* Get reg_class from a letter such as appears in the machine
546 description. */
547 extern enum reg_class reg_class_from_letter[];
548
549 #define REG_CLASS_FROM_LETTER(C) \
550 ( ISLOWER (C) ? reg_class_from_letter[(C) - 'a'] : NO_REGS )
551
552 /* The letters I, J, K, L, M, N, O, and P in a register constraint string
553 can be used to stand for particular ranges of immediate operands.
554 This macro defines what the ranges are.
555 C is the letter, and VALUE is a constant value.
556 Return 1 if VALUE is in the range specified by C.
557 I: loadable by movi (0..127)
558 J: arithmetic operand 1..32
559 K: shift operand 0..31
560 L: negative arithmetic operand -1..-32
561 M: powers of two, constants loadable by bgeni
562 N: powers of two minus 1, constants loadable by bmaski, including -1
563 O: allowed by cmov with two constants +/- 1 of each other
564 P: values we will generate 'inline' -- without an 'lrw'
565
566 Others defined for use after reload
567 Q: constant 1
568 R: a label
569 S: 0/1/2 cleared bits out of 32 [for bclri's]
570 T: 2 set bits out of 32 [for bseti's]
571 U: constant 0
572 xxxS: 1 cleared bit out of 32 (complement of power of 2). for bclri
573 xxxT: 2 cleared bits out of 32. for pairs of bclris. */
574 #define CONST_OK_FOR_I(VALUE) (((int)(VALUE)) >= 0 && ((int)(VALUE)) <= 0x7f)
575 #define CONST_OK_FOR_J(VALUE) (((int)(VALUE)) > 0 && ((int)(VALUE)) <= 32)
576 #define CONST_OK_FOR_L(VALUE) (((int)(VALUE)) < 0 && ((int)(VALUE)) >= -32)
577 #define CONST_OK_FOR_K(VALUE) (((int)(VALUE)) >= 0 && ((int)(VALUE)) <= 31)
578 #define CONST_OK_FOR_M(VALUE) (exact_log2 (VALUE) >= 0)
579 #define CONST_OK_FOR_N(VALUE) (((int)(VALUE)) == -1 || exact_log2 ((VALUE) + 1) >= 0)
580 #define CONST_OK_FOR_O(VALUE) (CONST_OK_FOR_I(VALUE) || \
581 CONST_OK_FOR_M(VALUE) || \
582 CONST_OK_FOR_N(VALUE) || \
583 CONST_OK_FOR_M((int)(VALUE) - 1) || \
584 CONST_OK_FOR_N((int)(VALUE) + 1))
585
586 #define CONST_OK_FOR_P(VALUE) (mcore_const_ok_for_inline (VALUE))
587
588 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
589 ((C) == 'I' ? CONST_OK_FOR_I (VALUE) \
590 : (C) == 'J' ? CONST_OK_FOR_J (VALUE) \
591 : (C) == 'L' ? CONST_OK_FOR_L (VALUE) \
592 : (C) == 'K' ? CONST_OK_FOR_K (VALUE) \
593 : (C) == 'M' ? CONST_OK_FOR_M (VALUE) \
594 : (C) == 'N' ? CONST_OK_FOR_N (VALUE) \
595 : (C) == 'P' ? CONST_OK_FOR_P (VALUE) \
596 : (C) == 'O' ? CONST_OK_FOR_O (VALUE) \
597 : 0)
598
599 /* Similar, but for floating constants, and defining letters G and H.
600 Here VALUE is the CONST_DOUBLE rtx itself. */
601 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
602 ((C) == 'G' ? CONST_OK_FOR_I (CONST_DOUBLE_HIGH (VALUE)) \
603 && CONST_OK_FOR_I (CONST_DOUBLE_LOW (VALUE)) \
604 : 0)
605
606 /* Letters in the range `Q' through `U' in a register constraint string
607 may be defined in a machine-dependent fashion to stand for arbitrary
608 operand types. */
609 #define EXTRA_CONSTRAINT(OP, C) \
610 ((C) == 'R' ? (GET_CODE (OP) == MEM \
611 && GET_CODE (XEXP (OP, 0)) == LABEL_REF) \
612 : (C) == 'S' ? (GET_CODE (OP) == CONST_INT \
613 && mcore_num_zeros (INTVAL (OP)) <= 2) \
614 : (C) == 'T' ? (GET_CODE (OP) == CONST_INT \
615 && mcore_num_ones (INTVAL (OP)) == 2) \
616 : (C) == 'Q' ? (GET_CODE (OP) == CONST_INT \
617 && INTVAL(OP) == 1) \
618 : (C) == 'U' ? (GET_CODE (OP) == CONST_INT \
619 && INTVAL(OP) == 0) \
620 : 0)
621
622 /* Given an rtx X being reloaded into a reg required to be
623 in class CLASS, return the class of reg to actually use.
624 In general this is just CLASS; but on some machines
625 in some cases it is preferable to use a more restrictive class. */
626 #define PREFERRED_RELOAD_CLASS(X, CLASS) mcore_reload_class (X, CLASS)
627
628 /* Return the register class of a scratch register needed to copy IN into
629 or out of a register in CLASS in MODE. If it can be done directly,
630 NO_REGS is returned. */
631 #define SECONDARY_RELOAD_CLASS(CLASS, MODE, X) NO_REGS
632
633 /* Return the maximum number of consecutive registers
634 needed to represent mode MODE in a register of class CLASS.
635
636 On MCore this is the size of MODE in words. */
637 #define CLASS_MAX_NREGS(CLASS, MODE) \
638 (ROUND_ADVANCE (GET_MODE_SIZE (MODE)))
639
640 /* Stack layout; function entry, exit and calling. */
641
642 /* Define the number of register that can hold parameters.
643 These two macros are used only in other macro definitions below. */
644 #define NPARM_REGS 6
645 #define FIRST_PARM_REG 2
646 #define FIRST_RET_REG 2
647
648 /* Define this if pushing a word on the stack
649 makes the stack pointer a smaller address. */
650 #define STACK_GROWS_DOWNWARD
651
652 /* Define this if the nominal address of the stack frame
653 is at the high-address end of the local variables;
654 that is, each additional local variable allocated
655 goes at a more negative offset in the frame. */
656 /* We don't define this, because the MCore does not support
657 addresses with negative offsets. */
658 /* #define FRAME_GROWS_DOWNWARD */
659
660 /* Offset within stack frame to start allocating local variables at.
661 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
662 first local allocated. Otherwise, it is the offset to the BEGINNING
663 of the first local allocated. */
664 #define STARTING_FRAME_OFFSET 0
665
666 /* If defined, the maximum amount of space required for outgoing arguments
667 will be computed and placed into the variable
668 `current_function_outgoing_args_size'. No space will be pushed
669 onto the stack for each call; instead, the function prologue should
670 increase the stack frame size by this amount. */
671 #define ACCUMULATE_OUTGOING_ARGS 1
672
673 /* Offset of first parameter from the argument pointer register value. */
674 #define FIRST_PARM_OFFSET(FNDECL) 0
675
676 /* Value is the number of byte of arguments automatically
677 popped when returning from a subroutine call.
678 FUNTYPE is the data type of the function (as a tree),
679 or for a library call it is an identifier node for the subroutine name.
680 SIZE is the number of bytes of arguments passed on the stack.
681
682 On the MCore, the callee does not pop any of its arguments that were passed
683 on the stack. */
684 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
685
686 /* Define how to find the value returned by a function.
687 VALTYPE is the data type of the value (as a tree).
688 If the precise function being called is known, FUNC is its FUNCTION_DECL;
689 otherwise, FUNC is 0. */
690 #define FUNCTION_VALUE(VALTYPE, FUNC) mcore_function_value (VALTYPE, FUNC)
691
692 /* Don't default to pcc-struct-return, because gcc is the only compiler, and
693 we want to retain compatibility with older gcc versions. */
694 #define DEFAULT_PCC_STRUCT_RETURN 0
695
696 /* how we are going to return big values */
697 /*
698 * #define RETURN_IN_MEMORY(TYPE) \
699 * (TYPE_MODE (TYPE) == BLKmode \
700 * || ((TREE_CODE (TYPE) == RECORD_TYPE || TREE_CODE(TYPE) == UNION_TYPE) \
701 * && !(TYPE_MODE (TYPE) == SImode \
702 * || (TYPE_MODE (TYPE) == BLKmode \
703 * && TYPE_ALIGN (TYPE) == BITS_PER_WORD \
704 * && int_size_in_bytes (TYPE) == UNITS_PER_WORD))))
705 */
706
707
708 /* How many registers to use for struct return. */
709 #define RETURN_IN_MEMORY(TYPE) (int_size_in_bytes (TYPE) > 2 * UNITS_PER_WORD)
710
711 /* Define how to find the value returned by a library function
712 assuming the value has mode MODE. */
713 #define LIBCALL_VALUE(MODE) gen_rtx (REG, MODE, FIRST_RET_REG)
714
715 /* 1 if N is a possible register number for a function value.
716 On the MCore, only r4 can return results. */
717 #define FUNCTION_VALUE_REGNO_P(REGNO) ((REGNO) == FIRST_RET_REG)
718
719 #define MUST_PASS_IN_STACK(MODE,TYPE) \
720 mcore_must_pass_on_stack (MODE, TYPE)
721
722 /* 1 if N is a possible register number for function argument passing. */
723 #define FUNCTION_ARG_REGNO_P(REGNO) \
724 ((REGNO) >= FIRST_PARM_REG && (REGNO) < (NPARM_REGS + FIRST_PARM_REG))
725
726 /* Define a data type for recording info about an argument list
727 during the scan of that argument list. This data type should
728 hold all necessary information about the function itself
729 and about the args processed so far, enough to enable macros
730 such as FUNCTION_ARG to determine where the next arg should go.
731
732 On MCore, this is a single integer, which is a number of words
733 of arguments scanned so far (including the invisible argument,
734 if any, which holds the structure-value-address).
735 Thus NARGREGS or more means all following args should go on the stack. */
736 #define CUMULATIVE_ARGS int
737
738 #define ROUND_ADVANCE(SIZE) \
739 ((SIZE + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
740
741 /* Round a register number up to a proper boundary for an arg of mode
742 MODE.
743
744 We round to an even reg for things larger than a word. */
745 #define ROUND_REG(X, MODE) \
746 ((TARGET_8ALIGN \
747 && GET_MODE_UNIT_SIZE ((MODE)) > UNITS_PER_WORD) \
748 ? ((X) + ((X) & 1)) : (X))
749
750
751 /* Initialize a variable CUM of type CUMULATIVE_ARGS
752 for a call to a function whose data type is FNTYPE.
753 For a library call, FNTYPE is 0.
754
755 On MCore, the offset always starts at 0: the first parm reg is always
756 the same reg. */
757 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT) \
758 ((CUM) = 0)
759
760 /* Update the data in CUM to advance over an argument
761 of mode MODE and data type TYPE.
762 (TYPE is null for libcalls where that information may not be
763 available.) */
764 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
765 ((CUM) = (ROUND_REG ((CUM), (MODE)) \
766 + ((NAMED) * mcore_num_arg_regs (MODE, TYPE)))) \
767
768 /* Define where to put the arguments to a function. */
769 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
770 mcore_function_arg (CUM, MODE, TYPE, NAMED)
771
772 /* A C expression that indicates when an argument must be passed by
773 reference. If nonzero for an argument, a copy of that argument is
774 made in memory and a pointer to the argument is passed instead of
775 the argument itself. The pointer is passed in whatever way is
776 appropriate for passing a pointer to that type. */
777 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
778 MUST_PASS_IN_STACK (MODE, TYPE)
779
780 /* For an arg passed partly in registers and partly in memory,
781 this is the number of registers used.
782 For args passed entirely in registers or entirely in memory, zero.
783 Any arg that starts in the first NPARM_REGS regs but won't entirely
784 fit in them needs partial registers on the MCore. */
785 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
786 mcore_function_arg_partial_nregs (CUM, MODE, TYPE, NAMED)
787
788 /* Perform any needed actions needed for a function that is receiving a
789 variable number of arguments. */
790 #define SETUP_INCOMING_VARARGS(ASF, MODE, TYPE, PAS, ST) \
791 mcore_setup_incoming_varargs (ASF, MODE, TYPE, & PAS)
792
793 /* Call the function profiler with a given profile label. */
794 #define FUNCTION_PROFILER(STREAM,LABELNO) \
795 { \
796 fprintf (STREAM, " trap 1\n"); \
797 fprintf (STREAM, " .align 2\n"); \
798 fprintf (STREAM, " .long LP%d\n", (LABELNO)); \
799 }
800
801 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
802 the stack pointer does not matter. The value is tested only in
803 functions that have frame pointers.
804 No definition is equivalent to always zero. */
805 #define EXIT_IGNORE_STACK 0
806
807 /* Output assembler code for a block containing the constant parts
808 of a trampoline, leaving space for the variable parts.
809
810 On the MCore, the trapoline looks like:
811 lrw r1, function
812 lrw r13, area
813 jmp r13
814 or r0, r0
815 .literals */
816 #define TRAMPOLINE_TEMPLATE(FILE) \
817 { \
818 fprintf ((FILE), " .short 0x7102\n"); \
819 fprintf ((FILE), " .short 0x7d02\n"); \
820 fprintf ((FILE), " .short 0x00cd\n"); \
821 fprintf ((FILE), " .short 0x1e00\n"); \
822 fprintf ((FILE), " .long 0\n"); \
823 fprintf ((FILE), " .long 0\n"); \
824 }
825
826 /* Length in units of the trampoline for entering a nested function. */
827 #define TRAMPOLINE_SIZE 12
828
829 /* Alignment required for a trampoline in units. */
830 #define TRAMPOLINE_ALIGN 4
831
832 /* Emit RTL insns to initialize the variable parts of a trampoline.
833 FNADDR is an RTX for the address of the function's pure code.
834 CXT is an RTX for the static chain value for the function. */
835 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
836 { \
837 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 8)), \
838 (CXT)); \
839 emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 12)), \
840 (FNADDR)); \
841 }
842
843 /* Macros to check register numbers against specific register classes. */
844
845 /* These assume that REGNO is a hard or pseudo reg number.
846 They give nonzero only if REGNO is a hard reg of the suitable class
847 or a pseudo reg currently allocated to a suitable hard reg.
848 Since they use reg_renumber, they are safe only once reg_renumber
849 has been allocated, which happens in local-alloc.c. */
850 #define REGNO_OK_FOR_BASE_P(REGNO) \
851 ((REGNO) < AP_REG || (unsigned) reg_renumber[(REGNO)] < AP_REG)
852
853 #define REGNO_OK_FOR_INDEX_P(REGNO) 0
854
855 /* Maximum number of registers that can appear in a valid memory
856 address. */
857 #define MAX_REGS_PER_ADDRESS 1
858
859 /* Recognize any constant value that is a valid address. */
860 #define CONSTANT_ADDRESS_P(X) (GET_CODE (X) == LABEL_REF)
861
862 /* Nonzero if the constant value X is a legitimate general operand.
863 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.
864
865 On the MCore, allow anything but a double. */
866 #define LEGITIMATE_CONSTANT_P(X) (GET_CODE(X) != CONST_DOUBLE)
867
868 #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN)
869 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
870 and check its validity for a certain class.
871 We have two alternate definitions for each of them.
872 The usual definition accepts all pseudo regs; the other rejects
873 them unless they have been allocated suitable hard regs.
874 The symbol REG_OK_STRICT causes the latter definition to be used. */
875 #ifndef REG_OK_STRICT
876
877 /* Nonzero if X is a hard reg that can be used as a base reg
878 or if it is a pseudo reg. */
879 #define REG_OK_FOR_BASE_P(X) \
880 (REGNO (X) <= 16 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
881
882 /* Nonzero if X is a hard reg that can be used as an index
883 or if it is a pseudo reg. */
884 #define REG_OK_FOR_INDEX_P(X) 0
885
886 #else
887
888 /* Nonzero if X is a hard reg that can be used as a base reg. */
889 #define REG_OK_FOR_BASE_P(X) \
890 REGNO_OK_FOR_BASE_P (REGNO (X))
891
892 /* Nonzero if X is a hard reg that can be used as an index. */
893 #define REG_OK_FOR_INDEX_P(X) 0
894
895 #endif
896 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
897 that is a valid memory address for an instruction.
898 The MODE argument is the machine mode for the MEM expression
899 that wants to use this address.
900
901 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS. */
902 #define BASE_REGISTER_RTX_P(X) \
903 (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X))
904
905 #define INDEX_REGISTER_RTX_P(X) \
906 (GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X))
907
908
909 /* Jump to LABEL if X is a valid address RTX. This must also take
910 REG_OK_STRICT into account when deciding about valid registers, but it uses
911 the above macros so we are in luck.
912
913 Allow REG
914 REG+disp
915
916 A legitimate index for a QI is 0..15, for HI is 0..30, for SI is 0..60,
917 and for DI is 0..56 because we use two SI loads, etc. */
918 #define GO_IF_LEGITIMATE_INDEX(MODE, REGNO, OP, LABEL) \
919 do \
920 { \
921 if (GET_CODE (OP) == CONST_INT) \
922 { \
923 if (GET_MODE_SIZE (MODE) >= 4 \
924 && (((unsigned)INTVAL (OP)) % 4) == 0 \
925 && ((unsigned)INTVAL (OP)) <= 64 - GET_MODE_SIZE (MODE)) \
926 goto LABEL; \
927 if (GET_MODE_SIZE (MODE) == 2 \
928 && (((unsigned)INTVAL (OP)) % 2) == 0 \
929 && ((unsigned)INTVAL (OP)) <= 30) \
930 goto LABEL; \
931 if (GET_MODE_SIZE (MODE) == 1 \
932 && ((unsigned)INTVAL (OP)) <= 15) \
933 goto LABEL; \
934 } \
935 } \
936 while (0)
937
938 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
939 { \
940 if (BASE_REGISTER_RTX_P (X)) \
941 goto LABEL; \
942 else if (GET_CODE (X) == PLUS || GET_CODE (X) == LO_SUM) \
943 { \
944 rtx xop0 = XEXP (X,0); \
945 rtx xop1 = XEXP (X,1); \
946 if (BASE_REGISTER_RTX_P (xop0)) \
947 GO_IF_LEGITIMATE_INDEX (MODE, REGNO (xop0), xop1, LABEL); \
948 if (BASE_REGISTER_RTX_P (xop1)) \
949 GO_IF_LEGITIMATE_INDEX (MODE, REGNO (xop1), xop0, LABEL); \
950 } \
951 }
952
953 /* Go to LABEL if ADDR (a legitimate address expression)
954 has an effect that depends on the machine mode it is used for. */
955 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
956 { \
957 if ( GET_CODE (ADDR) == PRE_DEC || GET_CODE (ADDR) == POST_DEC \
958 || GET_CODE (ADDR) == PRE_INC || GET_CODE (ADDR) == POST_INC) \
959 goto LABEL; \
960 }
961
962 /* Specify the machine mode that this machine uses
963 for the index in the tablejump instruction. */
964 #define CASE_VECTOR_MODE SImode
965
966 /* Define this if the tablejump instruction expects the table
967 to contain offsets from the address of the table.
968 Do not define this if the table should contain absolute addresses. */
969 /* #define CASE_VECTOR_PC_RELATIVE */
970
971 /* Specify the tree operation to be used to convert reals to integers. */
972 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
973
974 /* This is the kind of divide that is easiest to do in the general case. */
975 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
976
977 /* 'char' is signed by default. */
978 #define DEFAULT_SIGNED_CHAR 0
979
980 /* The type of size_t unsigned int. */
981 #define SIZE_TYPE "unsigned int"
982
983 /* Don't cse the address of the function being compiled. */
984 #define NO_RECURSIVE_FUNCTION_CSE 1
985
986 /* Max number of bytes we can move from memory to memory
987 in one reasonably fast instruction. */
988 #define MOVE_MAX 4
989
990 /* Define if operations between registers always perform the operation
991 on the full register even if a narrower mode is specified. */
992 #define WORD_REGISTER_OPERATIONS
993
994 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
995 will either zero-extend or sign-extend. The value of this macro should
996 be the code that says which one of the two operations is implicitly
997 done, NIL if none. */
998 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
999
1000 /* Nonzero if access to memory by bytes is slow and undesirable. */
1001 #define SLOW_BYTE_ACCESS TARGET_SLOW_BYTES
1002
1003 /* We assume that the store-condition-codes instructions store 0 for false
1004 and some other value for true. This is the value stored for true. */
1005 #define STORE_FLAG_VALUE 1
1006
1007 /* Immediate shift counts are truncated by the output routines (or was it
1008 the assembler?). Shift counts in a register are truncated by ARM. Note
1009 that the native compiler puts too large (> 32) immediate shift counts
1010 into a register and shifts by the register, letting the ARM decide what
1011 to do instead of doing that itself. */
1012 #define SHIFT_COUNT_TRUNCATED 1
1013
1014 /* All integers have the same format so truncation is easy. */
1015 #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) 1
1016
1017 /* Define this if addresses of constant functions
1018 shouldn't be put through pseudo regs where they can be cse'd.
1019 Desirable on machines where ordinary constants are expensive
1020 but a CALL with constant address is cheap. */
1021 /* why is this defined??? -- dac */
1022 #define NO_FUNCTION_CSE 1
1023
1024 /* Chars and shorts should be passed as ints. */
1025 #define PROMOTE_PROTOTYPES 1
1026
1027 /* The machine modes of pointers and functions. */
1028 #define Pmode SImode
1029 #define FUNCTION_MODE Pmode
1030
1031 /* The relative costs of various types of constants. Note that cse.c defines
1032 REG = 1, SUBREG = 2, any node = (2 + sum of subnodes). */
1033 #define CONST_COSTS(RTX, CODE, OUTER_CODE) \
1034 case CONST_INT: \
1035 return mcore_const_costs (RTX, OUTER_CODE); \
1036 case CONST: \
1037 case LABEL_REF: \
1038 case SYMBOL_REF: \
1039 return 5; \
1040 case CONST_DOUBLE: \
1041 return 10;
1042
1043 /* provide the cost for an address calculation.
1044 All addressing modes cost the same on the MCore. */
1045 #define ADDRESS_COST(RTX) 1
1046
1047 /* Provide the cost of an rtl expression. */
1048 #define RTX_COSTS(X, CODE, OUTER_CODE) \
1049 case AND: \
1050 return COSTS_N_INSNS (mcore_and_cost (X)); \
1051 case IOR: \
1052 return COSTS_N_INSNS (mcore_ior_cost (X)); \
1053 case DIV: \
1054 case UDIV: \
1055 case MOD: \
1056 case UMOD: \
1057 return COSTS_N_INSNS (100); \
1058 case FLOAT: \
1059 case FIX: \
1060 return 100;
1061
1062 /* Compute extra cost of moving data between one register class
1063 and another. All register moves are cheap. */
1064 #define REGISTER_MOVE_COST(MODE, SRCCLASS, DSTCLASS) 2
1065
1066 #define WORD_REGISTER_OPERATIONS
1067
1068 /* Implicit library calls should use memcpy, not bcopy, etc. */
1069 #define TARGET_MEM_FUNCTIONS
1070
1071 /* Assembler output control. */
1072 #define ASM_COMMENT_START "\t//"
1073
1074 #define ASM_APP_ON "// inline asm begin\n"
1075 #define ASM_APP_OFF "// inline asm end\n"
1076
1077 #define FILE_ASM_OP "\t.file\n"
1078
1079 /* Switch to the text or data segment. */
1080 #define TEXT_SECTION_ASM_OP "\t.text"
1081 #define DATA_SECTION_ASM_OP "\t.data"
1082
1083 #undef EXTRA_SECTIONS
1084 #define EXTRA_SECTIONS SUBTARGET_EXTRA_SECTIONS
1085
1086 #undef EXTRA_SECTION_FUNCTIONS
1087 #define EXTRA_SECTION_FUNCTIONS \
1088 SUBTARGET_EXTRA_SECTION_FUNCTIONS \
1089 SWITCH_SECTION_FUNCTION
1090
1091 /* Switch to SECTION (an `enum in_section').
1092
1093 ??? This facility should be provided by GCC proper.
1094 The problem is that we want to temporarily switch sections in
1095 ASM_DECLARE_OBJECT_NAME and then switch back to the original section
1096 afterwards. */
1097 #define SWITCH_SECTION_FUNCTION \
1098 static void switch_to_section PARAMS ((enum in_section, tree)); \
1099 static void \
1100 switch_to_section (section, decl) \
1101 enum in_section section; \
1102 tree decl; \
1103 { \
1104 switch (section) \
1105 { \
1106 case in_text: text_section (); break; \
1107 case in_data: data_section (); break; \
1108 case in_named: named_section (decl, NULL, 0); break; \
1109 SUBTARGET_SWITCH_SECTIONS \
1110 default: abort (); break; \
1111 } \
1112 }
1113
1114 /* Switch into a generic section. */
1115 #undef TARGET_ASM_NAMED_SECTION
1116 #define TARGET_ASM_NAMED_SECTION mcore_asm_named_section
1117
1118 /* This is how to output an insn to push a register on the stack.
1119 It need not be very fast code. */
1120 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \
1121 fprintf (FILE, "\tsubi\t %s,%d\n\tstw\t %s,(%s)\n", \
1122 reg_names[STACK_POINTER_REGNUM], \
1123 (STACK_BOUNDARY / BITS_PER_UNIT), \
1124 reg_names[REGNO], \
1125 reg_names[STACK_POINTER_REGNUM])
1126
1127 /* Length in instructions of the code output by ASM_OUTPUT_REG_PUSH. */
1128 #define REG_PUSH_LENGTH 2
1129
1130 /* This is how to output an insn to pop a register from the stack. */
1131 #define ASM_OUTPUT_REG_POP(FILE,REGNO) \
1132 fprintf (FILE, "\tldw\t %s,(%s)\n\taddi\t %s,%d\n", \
1133 reg_names[REGNO], \
1134 reg_names[STACK_POINTER_REGNUM], \
1135 reg_names[STACK_POINTER_REGNUM], \
1136 (STACK_BOUNDARY / BITS_PER_UNIT))
1137
1138
1139 /* Output a label definition. */
1140 #define ASM_OUTPUT_LABEL(FILE,NAME) \
1141 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
1142
1143 /* Output a reference to a label. */
1144 #undef ASM_OUTPUT_LABELREF
1145 #define ASM_OUTPUT_LABELREF(STREAM, NAME) \
1146 fprintf (STREAM, "%s%s", USER_LABEL_PREFIX, MCORE_STRIP_NAME_ENCODING (NAME))
1147
1148
1149 /* This is how to output an assembler line
1150 that says to advance the location counter
1151 to a multiple of 2**LOG bytes. */
1152 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
1153 if ((LOG) != 0) \
1154 fprintf (FILE, "\t.align\t%d\n", LOG)
1155
1156 #ifndef ASM_DECLARE_RESULT
1157 #define ASM_DECLARE_RESULT(FILE, RESULT)
1158 #endif
1159
1160 /* Strip export encoding from a function name. */
1161 #define MCORE_STRIP_NAME_ENCODING(SYM_NAME) \
1162 ((SYM_NAME) + ((SYM_NAME)[0] == '@' ? 3 : 0))
1163
1164 /* Strip any text from SYM_NAME added by ENCODE_SECTION_INFO and store
1165 the result in VAR. */
1166 #undef STRIP_NAME_ENCODING
1167 #define STRIP_NAME_ENCODING(VAR, SYM_NAME) \
1168 (VAR) = MCORE_STRIP_NAME_ENCODING (SYM_NAME)
1169
1170 #undef UNIQUE_SECTION
1171 #define UNIQUE_SECTION(DECL, RELOC) mcore_unique_section (DECL, RELOC)
1172
1173 #define REDO_SECTION_INFO_P(DECL) 1
1174
1175 #define MULTIPLE_SYMBOL_SPACES 1
1176
1177 #define SUPPORTS_ONE_ONLY 1
1178
1179 /* A pair of macros to output things for the callgraph data.
1180 VALUE means (to the tools that reads this info later):
1181 0 a call from src to dst
1182 1 the call is special (e.g. dst is "unknown" or "alloca")
1183 2 the call is special (e.g., the src is a table instead of routine)
1184
1185 Frame sizes are augmented with timestamps to help later tools
1186 differentiate between static entities with same names in different
1187 files. */
1188 extern long mcore_current_compilation_timestamp;
1189 #define ASM_OUTPUT_CG_NODE(FILE,SRCNAME,VALUE) \
1190 do \
1191 { \
1192 if (mcore_current_compilation_timestamp == 0) \
1193 mcore_current_compilation_timestamp = time (0); \
1194 fprintf ((FILE),"\t.equ\t__$frame$size$_%s_$_%08lx,%d\n", \
1195 (SRCNAME), mcore_current_compilation_timestamp, (VALUE)); \
1196 } \
1197 while (0)
1198
1199 #define ASM_OUTPUT_CG_EDGE(FILE,SRCNAME,DSTNAME,VALUE) \
1200 do \
1201 { \
1202 fprintf ((FILE),"\t.equ\t__$function$call$_%s_$_%s,%d\n", \
1203 (SRCNAME), (DSTNAME), (VALUE)); \
1204 } \
1205 while (0)
1206
1207 /* Output a globalising directive for a label. */
1208 #define ASM_GLOBALIZE_LABEL(STREAM,NAME) \
1209 (fprintf (STREAM, "\t.export\t"), \
1210 assemble_name (STREAM, NAME), \
1211 fputc ('\n',STREAM)) \
1212
1213 /* The prefix to add to user-visible assembler symbols. */
1214 #undef USER_LABEL_PREFIX
1215 #define USER_LABEL_PREFIX ""
1216
1217 /* Make an internal label into a string. */
1218 #undef ASM_GENERATE_INTERNAL_LABEL
1219 #define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
1220 sprintf (STRING, "*.%s%ld", PREFIX, (long) NUM)
1221
1222 /* Output an internal label definition. */
1223 #undef ASM_OUTPUT_INTERNAL_LABEL
1224 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
1225 fprintf (FILE, ".%s%d:\n", PREFIX, NUM)
1226
1227 /* Construct a private name. */
1228 #define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER) \
1229 ((OUTVAR) = (char *) alloca (strlen (NAME) + 10), \
1230 sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)))
1231
1232 /* Jump tables must be 32 bit aligned. */
1233 #undef ASM_OUTPUT_CASE_LABEL
1234 #define ASM_OUTPUT_CASE_LABEL(STREAM,PREFIX,NUM,TABLE) \
1235 fprintf (STREAM, "\t.align 2\n.%s%d:\n", PREFIX, NUM);
1236
1237 /* Output a relative address. Not needed since jump tables are absolute
1238 but we must define it anyway. */
1239 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL) \
1240 fputs ("- - - ASM_OUTPUT_ADDR_DIFF_ELT called!\n", STREAM)
1241
1242 /* Output an element of a dispatch table. */
1243 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
1244 fprintf (STREAM, "\t.long\t.L%d\n", VALUE)
1245
1246 /* Output various types of constants. */
1247
1248 /* This is how to output an assembler line defining a `double'. */
1249 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
1250 do \
1251 { \
1252 char dstr[30]; \
1253 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
1254 fprintf (FILE, "\t.double %s\n", dstr); \
1255 } \
1256 while (0)
1257
1258
1259 /* This is how to output an assembler line defining a `float' constant. */
1260 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
1261 do \
1262 { \
1263 char dstr[30]; \
1264 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr); \
1265 fprintf (FILE, "\t.float %s\n", dstr); \
1266 } \
1267 while (0)
1268
1269 /* This is how to output an assembler line
1270 that says to advance the location counter by SIZE bytes. */
1271 #undef ASM_OUTPUT_SKIP
1272 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
1273 fprintf (FILE, "\t.fill %d, 1\n", (SIZE))
1274
1275 /* This says how to output an assembler line
1276 to define a global common symbol, with alignment information. */
1277 /* XXX - for now we ignore the alignment. */
1278 #undef ASM_OUTPUT_ALIGNED_COMMON
1279 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
1280 do \
1281 { \
1282 if (mcore_dllexport_name_p (NAME)) \
1283 MCORE_EXPORT_NAME (FILE, NAME) \
1284 if (! mcore_dllimport_name_p (NAME)) \
1285 { \
1286 fputs ("\t.comm\t", FILE); \
1287 assemble_name (FILE, NAME); \
1288 fprintf (FILE, ",%d\n", SIZE); \
1289 } \
1290 } \
1291 while (0)
1292
1293 /* This says how to output an assembler line
1294 to define an external symbol. */
1295 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
1296 do \
1297 { \
1298 fputs ("\t.import\t", (FILE)); \
1299 assemble_name ((FILE), (NAME)); \
1300 fputs ("\n", (FILE)); \
1301 } \
1302 while (0)
1303
1304 #undef ASM_OUTPUT_EXTERNAL
1305 /* RBE: we undefined this and let gas do it's "undefined is imported"
1306 games. This is because when we use this, we get a marked
1307 reference through the call to assemble_name and this forces C++
1308 inlined member functions (or any inlined function) to be instantiated
1309 regardless of whether any callsites remain.
1310 This makes this aspect of the compiler non-ABI compliant. */
1311
1312 /* Similar, but for libcall. FUN is an rtx. */
1313 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
1314 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
1315 do \
1316 { \
1317 fprintf (FILE, "\t.import\t"); \
1318 assemble_name (FILE, XSTR (FUN, 0)); \
1319 fprintf (FILE, "\n"); \
1320 } \
1321 while (0)
1322
1323
1324 /* This says how to output an assembler line
1325 to define a local common symbol... */
1326 #undef ASM_OUTPUT_LOCAL
1327 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
1328 (fputs ("\t.lcomm\t", FILE), \
1329 assemble_name (FILE, NAME), \
1330 fprintf (FILE, ",%d\n", SIZE))
1331
1332 /* ... and how to define a local common symbol whose alignment
1333 we wish to specify. ALIGN comes in as bits, we have to turn
1334 it into bytes. */
1335 #undef ASM_OUTPUT_ALIGNED_LOCAL
1336 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
1337 do \
1338 { \
1339 fputs ("\t.bss\t", (FILE)); \
1340 assemble_name ((FILE), (NAME)); \
1341 fprintf ((FILE), ",%d,%d\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
1342 } \
1343 while (0)
1344
1345 /* We must mark dll symbols specially. Definitions of dllexport'd objects
1346 install some info in the .drective (PE) or .exports (ELF) sections. */
1347 #undef ENCODE_SECTION_INFO
1348 #define ENCODE_SECTION_INFO(DECL) mcore_encode_section_info (DECL)
1349
1350 /* Print operand X (an rtx) in assembler syntax to file FILE.
1351 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1352 For `%' followed by punctuation, CODE is the punctuation and X is null. */
1353 #define PRINT_OPERAND(STREAM, X, CODE) mcore_print_operand (STREAM, X, CODE)
1354
1355 /* Print a memory address as an operand to reference that memory location. */
1356 #define PRINT_OPERAND_ADDRESS(STREAM,X) mcore_print_operand_address (STREAM, X)
1357
1358 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
1359 ((CHAR)=='.' || (CHAR) == '#' || (CHAR) == '*' || (CHAR) == '^' || (CHAR) == '!')
1360
1361 /* This is to handle loads from the constant pool. */
1362 #define MACHINE_DEPENDENT_REORG(X) mcore_dependent_reorg (X)
1363
1364 #define PREDICATE_CODES \
1365 { "mcore_arith_reg_operand", { REG, SUBREG }}, \
1366 { "mcore_general_movsrc_operand", { MEM, CONST_INT, REG, SUBREG }},\
1367 { "mcore_general_movdst_operand", { MEM, CONST_INT, REG, SUBREG }},\
1368 { "mcore_reload_operand", { MEM, REG, SUBREG }}, \
1369 { "mcore_arith_J_operand", { CONST_INT, REG, SUBREG }}, \
1370 { "mcore_arith_K_operand", { CONST_INT, REG, SUBREG }}, \
1371 { "mcore_arith_K_operand_not_0", { CONST_INT, REG, SUBREG }}, \
1372 { "mcore_arith_M_operand", { CONST_INT, REG, SUBREG }}, \
1373 { "mcore_arith_K_S_operand", { CONST_INT, REG, SUBREG }}, \
1374 { "mcore_arith_O_operand", { CONST_INT, REG, SUBREG }}, \
1375 { "mcore_arith_imm_operand", { CONST_INT, REG, SUBREG }}, \
1376 { "mcore_arith_any_imm_operand", { CONST_INT, REG, SUBREG }}, \
1377 { "mcore_literal_K_operand", { CONST_INT }}, \
1378 { "mcore_addsub_operand", { CONST_INT, REG, SUBREG }}, \
1379 { "mcore_compare_operand", { CONST_INT, REG, SUBREG }}, \
1380 { "mcore_load_multiple_operation", { PARALLEL }}, \
1381 { "mcore_store_multiple_operation", { PARALLEL }}, \
1382 { "mcore_call_address_operand", { REG, SUBREG, CONST_INT }}, \
1383
1384 #endif /* ! GCC_MCORE_H */