1 /* Definitions of target machine for GNU compiler.
2 Renesas H8/300 (generic)
3 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1996, 1997, 1998, 1999,
4 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
5 Free Software Foundation, Inc.
6 Contributed by Steve Chamberlain (sac@cygnus.com),
7 Jim Wilson (wilson@cygnus.com), and Doug Evans (dje@cygnus.com).
9 This file is part of GCC.
11 GCC is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3, or (at your option)
16 GCC is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with GCC; see the file COPYING3. If not see
23 <http://www.gnu.org/licenses/>. */
28 /* Which CPU to compile for.
29 We use int for CPU_TYPE to avoid lots of casts. */
30 #if 0 /* defined in insn-attr.h, here for documentation */
31 enum attr_cpu
{ CPU_H8300
, CPU_H8300H
};
35 /* Various globals defined in h8300.c. */
37 extern const char *h8_push_op
, *h8_pop_op
, *h8_mov_op
;
38 extern const char * const *h8_reg_names
;
40 /* Target CPU builtins. */
41 #define TARGET_CPU_CPP_BUILTINS() \
46 builtin_define ("__H8300H__"); \
47 builtin_assert ("cpu=h8300h"); \
48 builtin_assert ("machine=h8300h"); \
49 if (TARGET_NORMAL_MODE) \
51 builtin_define ("__NORMAL_MODE__"); \
54 else if (TARGET_H8300SX) \
56 builtin_define ("__H8300SX__"); \
57 if (TARGET_NORMAL_MODE) \
59 builtin_define ("__NORMAL_MODE__"); \
62 else if (TARGET_H8300S) \
64 builtin_define ("__H8300S__"); \
65 builtin_assert ("cpu=h8300s"); \
66 builtin_assert ("machine=h8300s"); \
67 if (TARGET_NORMAL_MODE) \
69 builtin_define ("__NORMAL_MODE__"); \
74 builtin_define ("__H8300__"); \
75 builtin_assert ("cpu=h8300"); \
76 builtin_assert ("machine=h8300"); \
81 #define LINK_SPEC "%{mh:%{mn:-m h8300hn}} %{mh:%{!mn:-m h8300h}} %{ms:%{mn:-m h8300sn}} %{ms:%{!mn:-m h8300s}}"
83 #define LIB_SPEC "%{mrelax:-relax} %{g:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
85 /* Print subsidiary information on the compiler version in use. */
87 #define TARGET_VERSION fprintf (stderr, " (Renesas H8/300)");
89 /* Macros used in the machine description to test the flags. */
91 /* Select between the H8/300 and H8/300H CPUs. */
92 #define TARGET_H8300 (! TARGET_H8300H && ! TARGET_H8300S)
93 #define TARGET_H8300S (TARGET_H8300S_1 || TARGET_H8300SX)
94 /* Some multiply instructions are not available in all H8SX variants.
95 Use this macro instead of TARGET_H8300SX to indicate this, even
96 though we don't actually generate different code for now. */
97 #define TARGET_H8300SXMUL TARGET_H8300SX
102 #undef TARGET_NORMAL_MODE
103 /* If compiling libgcc2, make these compile time constants based on what
104 flags are we actually compiling with. */
106 #define TARGET_H8300H 1
108 #define TARGET_H8300H 0
111 #define TARGET_H8300S 1
113 #define TARGET_H8300S 0
115 #ifdef __NORMAL_MODE__
116 #define TARGET_NORMAL_MODE 1
118 #define TARGET_NORMAL_MODE 0
120 #endif /* !IN_LIBGCC2 */
122 /* Default target_flags if no switches specified. */
124 #ifndef TARGET_DEFAULT
125 #define TARGET_DEFAULT (MASK_QUICKCALL)
128 /* We want dwarf2 info available to gdb... */
129 #define DWARF2_DEBUGGING_INFO 1
130 /* ... but we don't actually support full dwarf2 EH. */
131 #define MUST_USE_SJLJ_EXCEPTIONS 1
133 /* The return address is pushed on the stack. */
134 #define INCOMING_RETURN_ADDR_RTX gen_rtx_MEM (Pmode, gen_rtx_REG (Pmode, STACK_POINTER_REGNUM))
135 #define INCOMING_FRAME_SP_OFFSET (POINTER_SIZE / 8)
137 #define DWARF_CIE_DATA_ALIGNMENT 2
139 /* Define this if addresses of constant functions
140 shouldn't be put through pseudo regs where they can be cse'd.
141 Desirable on machines where ordinary constants are expensive
142 but a CALL with constant address is cheap.
144 Calls through a register are cheaper than calls to named
145 functions; however, the register pressure this causes makes
146 CSEing of function addresses generally a lose. */
147 #define NO_FUNCTION_CSE
149 /* Target machine storage layout */
151 /* Define this if most significant bit is lowest numbered
152 in instructions that operate on numbered bit-fields.
153 This is not true on the H8/300. */
154 #define BITS_BIG_ENDIAN 0
156 /* Define this if most significant byte of a word is the lowest numbered. */
157 /* That is true on the H8/300. */
158 #define BYTES_BIG_ENDIAN 1
160 /* Define this if most significant word of a multiword number is lowest
162 #define WORDS_BIG_ENDIAN 1
164 #define MAX_BITS_PER_WORD 32
166 /* Width of a word, in units (bytes). */
167 #define UNITS_PER_WORD (TARGET_H8300H || TARGET_H8300S ? 4 : 2)
168 #define MIN_UNITS_PER_WORD 2
170 #define SHORT_TYPE_SIZE 16
171 #define INT_TYPE_SIZE (TARGET_INT32 ? 32 : 16)
172 #define LONG_TYPE_SIZE 32
173 #define LONG_LONG_TYPE_SIZE 64
174 #define FLOAT_TYPE_SIZE 32
175 #define DOUBLE_TYPE_SIZE 32
176 #define LONG_DOUBLE_TYPE_SIZE DOUBLE_TYPE_SIZE
178 #define MAX_FIXED_MODE_SIZE 32
180 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
181 #define PARM_BOUNDARY (TARGET_H8300H || TARGET_H8300S ? 32 : 16)
183 /* Allocation boundary (in *bits*) for the code of a function. */
184 #define FUNCTION_BOUNDARY 16
186 /* Alignment of field after `int : 0' in a structure. */
187 /* One can argue this should be 32 for -mint32, but since 32-bit ints only
188 need 16-bit alignment, this is left as is so that -mint32 doesn't change
189 structure layouts. */
190 #define EMPTY_FIELD_BOUNDARY 16
192 /* No data type wants to be aligned rounder than this.
193 32-bit values are aligned as such on the H8/300H and H8S for speed. */
194 #define BIGGEST_ALIGNMENT \
195 (((TARGET_H8300H || TARGET_H8300S) && ! TARGET_ALIGN_300) ? 32 : 16)
197 /* The stack goes in 16/32 bit lumps. */
198 #define STACK_BOUNDARY (TARGET_H8300 ? 16 : 32)
200 /* Define this if move instructions will actually fail to work
201 when given unaligned data. */
202 /* On the H8/300, longs can be aligned on halfword boundaries, but not
204 #define STRICT_ALIGNMENT 1
206 /* Standard register usage. */
208 /* Number of actual hardware registers.
209 The hardware registers are assigned numbers for the compiler
210 from 0 to just below FIRST_PSEUDO_REGISTER.
212 All registers that the compiler knows about must be given numbers,
213 even those that are not normally considered general registers.
215 Reg 9 does not correspond to any hardware register, but instead
216 appears in the RTL as an argument pointer prior to reload, and is
217 eliminated during reloading in favor of either the stack or frame
220 #define FIRST_PSEUDO_REGISTER 12
222 /* 1 for registers that have pervasive standard uses
223 and are not available for the register allocator. */
225 #define FIXED_REGISTERS \
226 /* r0 r1 r2 r3 r4 r5 r6 r7 mac ap rap fp */ \
227 { 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1 }
229 /* 1 for registers not available across function calls.
230 These must include the FIXED_REGISTERS and also any
231 registers that can be used without being saved.
232 The latter must include the registers where values are returned
233 and the register where structure-value addresses are passed.
234 Aside from that, you can include as many other registers as you
237 H8 destroys r0,r1,r2,r3. */
239 #define CALL_USED_REGISTERS \
240 /* r0 r1 r2 r3 r4 r5 r6 r7 mac ap rap fp */ \
241 { 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1 }
243 #define REG_ALLOC_ORDER \
244 /* r0 r1 r2 r3 r4 r5 r6 r7 mac ap rap fp */ \
245 { 2, 3, 0, 1, 4, 5, 6, 8, 7, 9, 10, 11 }
247 #define CONDITIONAL_REGISTER_USAGE \
250 fixed_regs[MAC_REG] = call_used_regs[MAC_REG] = 1; \
253 #define HARD_REGNO_NREGS(REGNO, MODE) \
254 h8300_hard_regno_nregs ((REGNO), (MODE))
256 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
257 h8300_hard_regno_mode_ok ((REGNO), (MODE))
259 /* Value is 1 if it is a good idea to tie two pseudo registers
260 when one has mode MODE1 and one has mode MODE2.
261 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
262 for any hard reg, then this must be 0 for correct output. */
263 #define MODES_TIEABLE_P(MODE1, MODE2) \
264 ((MODE1) == (MODE2) \
265 || (((MODE1) == QImode || (MODE1) == HImode \
266 || ((TARGET_H8300H || TARGET_H8300S) && (MODE1) == SImode)) \
267 && ((MODE2) == QImode || (MODE2) == HImode \
268 || ((TARGET_H8300H || TARGET_H8300S) && (MODE2) == SImode))))
270 /* A C expression that is nonzero if hard register NEW_REG can be
271 considered for use as a rename register for OLD_REG register */
273 #define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
274 h8300_hard_regno_rename_ok (OLD_REG, NEW_REG)
276 /* Specify the registers used for certain standard purposes.
277 The values of these macros are register numbers. */
279 /* H8/300 pc is not overloaded on a register. */
281 /*#define PC_REGNUM 15*/
283 /* Register to use for pushing function arguments. */
284 #define STACK_POINTER_REGNUM SP_REG
286 /* Base register for access to local variables of the function. */
287 #define HARD_FRAME_POINTER_REGNUM HFP_REG
289 /* Base register for access to local variables of the function. */
290 #define FRAME_POINTER_REGNUM FP_REG
292 /* Base register for access to arguments of the function. */
293 #define ARG_POINTER_REGNUM AP_REG
295 /* Register in which static-chain is passed to a function. */
296 #define STATIC_CHAIN_REGNUM SC_REG
298 /* Fake register that holds the address on the stack of the
299 current function's return address. */
300 #define RETURN_ADDRESS_POINTER_REGNUM RAP_REG
302 /* A C expression whose value is RTL representing the value of the return
303 address for the frame COUNT steps up from the current frame.
304 FRAMEADDR is already the frame pointer of the COUNT frame, assuming
305 a stack layout with the frame pointer as the first saved register. */
306 #define RETURN_ADDR_RTX(COUNT, FRAME) h8300_return_addr_rtx ((COUNT), (FRAME))
308 /* Define the classes of registers for register constraints in the
309 machine description. Also define ranges of constants.
311 One of the classes must always be named ALL_REGS and include all hard regs.
312 If there is more than one class, another class must be named NO_REGS
313 and contain no registers.
315 The name GENERAL_REGS must be the name of a class (or an alias for
316 another name such as ALL_REGS). This is the class of registers
317 that is allowed by "g" or "r" in a register constraint.
318 Also, registers outside this class are allocated only when
319 instructions express preferences for them.
321 The classes must be numbered in nondecreasing order; that is,
322 a larger-numbered class must never be contained completely
323 in a smaller-numbered class.
325 For any two classes, it is very desirable that there be another
326 class that represents their union. */
329 NO_REGS
, COUNTER_REGS
, SOURCE_REGS
, DESTINATION_REGS
,
330 GENERAL_REGS
, MAC_REGS
, ALL_REGS
, LIM_REG_CLASSES
333 #define N_REG_CLASSES ((int) LIM_REG_CLASSES)
335 /* Give names of register classes as strings for dump file. */
337 #define REG_CLASS_NAMES \
338 { "NO_REGS", "COUNTER_REGS", "SOURCE_REGS", "DESTINATION_REGS", \
339 "GENERAL_REGS", "MAC_REGS", "ALL_REGS", "LIM_REGS" }
341 /* The following macro defines cover classes for Integrated Register
342 Allocator. Cover classes is a set of non-intersected register
343 classes covering all hard registers used for register allocation
344 purpose. Any move between two registers of a cover class should be
345 cheaper than load or store of the registers. The macro value is
346 array of register classes with LIM_REG_CLASSES used as the end
349 #define IRA_COVER_CLASSES \
351 GENERAL_REGS, MAC_REGS, LIM_REG_CLASSES \
354 /* Define which registers fit in which classes.
355 This is an initializer for a vector of HARD_REG_SET
356 of length N_REG_CLASSES. */
358 #define REG_CLASS_CONTENTS \
359 { {0}, /* No regs */ \
360 {0x010}, /* COUNTER_REGS */ \
361 {0x020}, /* SOURCE_REGS */ \
362 {0x040}, /* DESTINATION_REGS */ \
363 {0xeff}, /* GENERAL_REGS */ \
364 {0x100}, /* MAC_REGS */ \
365 {0xfff}, /* ALL_REGS */ \
368 /* The same information, inverted:
369 Return the class number of the smallest class containing
370 reg number REGNO. This could be a conditional expression
371 or could index an array. */
373 #define REGNO_REG_CLASS(REGNO) \
374 ((REGNO) == MAC_REG ? MAC_REGS \
375 : (REGNO) == COUNTER_REG ? COUNTER_REGS \
376 : (REGNO) == SOURCE_REG ? SOURCE_REGS \
377 : (REGNO) == DESTINATION_REG ? DESTINATION_REGS \
380 /* The class value for index registers, and the one for base regs. */
382 #define INDEX_REG_CLASS (TARGET_H8300SX ? GENERAL_REGS : NO_REGS)
383 #define BASE_REG_CLASS GENERAL_REGS
385 /* Get reg_class from a letter such as appears in the machine description.
387 'a' is the MAC register. */
389 #define REG_CLASS_FROM_LETTER(C) (h8300_reg_class_from_letter (C))
391 /* The letters I, J, K, L, M, N, O, P in a register constraint string
392 can be used to stand for particular ranges of immediate operands.
393 This macro defines what the ranges are.
394 C is the letter, and VALUE is a constant value.
395 Return 1 if VALUE is in the range specified by C. */
397 #define CONST_OK_FOR_I(VALUE) ((VALUE) == 0)
398 #define CONST_OK_FOR_J(VALUE) (((VALUE) & 0xff) == 0)
399 #define CONST_OK_FOR_L(VALUE) \
400 (TARGET_H8300H || TARGET_H8300S \
401 ? (VALUE) == 1 || (VALUE) == 2 || (VALUE) == 4 \
402 : (VALUE) == 1 || (VALUE) == 2)
403 #define CONST_OK_FOR_M(VALUE) \
404 ((VALUE) == 1 || (VALUE) == 2)
405 #define CONST_OK_FOR_N(VALUE) \
406 (TARGET_H8300H || TARGET_H8300S \
407 ? (VALUE) == -1 || (VALUE) == -2 || (VALUE) == -4 \
408 : (VALUE) == -1 || (VALUE) == -2)
409 #define CONST_OK_FOR_O(VALUE) \
410 ((VALUE) == -1 || (VALUE) == -2)
412 /* Multi-letter constraints for constant are always started with P
413 (just because it was the only letter in the range left. New
414 constraints for constants should be added here. */
415 #define CONST_OK_FOR_Ppositive(VALUE, NBITS) \
416 ((VALUE) > 0 && (VALUE) < (1 << (NBITS)))
417 #define CONST_OK_FOR_Pnegative(VALUE, NBITS) \
418 ((VALUE) < 0 && (VALUE) > -(1 << (NBITS)))
419 #define CONST_OK_FOR_P(VALUE, STR) \
420 ((STR)[1] >= '1' && (STR)[1] <= '9' && (STR)[2] == '<' \
421 ? (((STR)[3] == '0' || ((STR)[3] == 'X' && TARGET_H8300SX)) \
422 && CONST_OK_FOR_Pnegative ((VALUE), (STR)[1] - '0')) \
423 : ((STR)[1] >= '1' && (STR)[1] <= '9' && (STR)[2] == '>') \
424 ? (((STR)[3] == '0' || ((STR)[3] == 'X' && TARGET_H8300SX)) \
425 && CONST_OK_FOR_Ppositive ((VALUE), (STR)[1] - '0')) \
427 #define CONSTRAINT_LEN_FOR_P(STR) \
428 ((((STR)[1] >= '1' && (STR)[1] <= '9') \
429 && ((STR)[2] == '<' || (STR)[2] == '>') \
430 && ((STR)[3] == 'X' || (STR)[3] == '0')) ? 4 \
433 #define CONST_OK_FOR_CONSTRAINT_P(VALUE, C, STR) \
434 ((C) == 'P' ? CONST_OK_FOR_P ((VALUE), (STR)) \
435 : CONST_OK_FOR_LETTER_P ((VALUE), (C)))
437 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
438 ((C) == 'I' ? CONST_OK_FOR_I (VALUE) : \
439 (C) == 'J' ? CONST_OK_FOR_J (VALUE) : \
440 (C) == 'L' ? CONST_OK_FOR_L (VALUE) : \
441 (C) == 'M' ? CONST_OK_FOR_M (VALUE) : \
442 (C) == 'N' ? CONST_OK_FOR_N (VALUE) : \
443 (C) == 'O' ? CONST_OK_FOR_O (VALUE) : \
446 /* Similar, but for floating constants, and defining letters G and H.
447 Here VALUE is the CONST_DOUBLE rtx itself.
449 `G' is a floating-point zero. */
451 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
452 ((C) == 'G' ? (VALUE) == CONST0_RTX (SFmode) \
455 /* Return the maximum number of consecutive registers
456 needed to represent mode MODE in a register of class CLASS. */
458 /* On the H8, this is the size of MODE in words. */
460 #define CLASS_MAX_NREGS(CLASS, MODE) \
461 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
463 /* Any SI register-to-register move may need to be reloaded,
464 so define REGISTER_MOVE_COST to be > 2 so that reload never
467 #define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \
468 (CLASS1 == MAC_REGS || CLASS2 == MAC_REGS ? 6 : 3)
470 /* Stack layout; function entry, exit and calling. */
472 /* Define this if pushing a word on the stack
473 makes the stack pointer a smaller address. */
475 #define STACK_GROWS_DOWNWARD
477 /* Define this to nonzero if the nominal address of the stack frame
478 is at the high-address end of the local variables;
479 that is, each additional local variable allocated
480 goes at a more negative offset in the frame. */
482 #define FRAME_GROWS_DOWNWARD 1
484 /* Offset within stack frame to start allocating local variables at.
485 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
486 first local allocated. Otherwise, it is the offset to the BEGINNING
487 of the first local allocated. */
489 #define STARTING_FRAME_OFFSET 0
491 /* If we generate an insn to push BYTES bytes,
492 this says how many the stack pointer really advances by.
494 On the H8/300, @-sp really pushes a byte if you ask it to - but that's
495 dangerous, so we claim that it always pushes a word, then we catch
496 the mov.b rx,@-sp and turn it into a mov.w rx,@-sp on output.
498 On the H8/300H, we simplify TARGET_QUICKCALL by setting this to 4
499 and doing a similar thing. */
501 #define PUSH_ROUNDING(BYTES) \
502 (((BYTES) + PARM_BOUNDARY / 8 - 1) & -PARM_BOUNDARY / 8)
504 /* Offset of first parameter from the argument pointer register value. */
505 /* Is equal to the size of the saved fp + pc, even if an fp isn't
506 saved since the value is used before we know. */
508 #define FIRST_PARM_OFFSET(FNDECL) 0
510 /* Definitions for register eliminations.
512 This is an array of structures. Each structure initializes one pair
513 of eliminable registers. The "from" register number is given first,
514 followed by "to". Eliminations of the same "from" register are listed
515 in order of preference.
517 We have three registers that can be eliminated on the h8300.
518 First, the frame pointer register can often be eliminated in favor
519 of the stack pointer register. Secondly, the argument pointer
520 register and the return address pointer register are always
521 eliminated; they are replaced with either the stack or frame
524 #define ELIMINABLE_REGS \
525 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
526 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
527 { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
528 { RETURN_ADDRESS_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
529 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
530 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}
532 /* Define the offset between two registers, one to be eliminated, and the other
533 its replacement, at the start of a routine. */
535 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
536 ((OFFSET) = h8300_initial_elimination_offset ((FROM), (TO)))
538 /* Define how to find the value returned by a function.
539 VALTYPE is the data type of the value (as a tree).
540 If the precise function being called is known, FUNC is its FUNCTION_DECL;
541 otherwise, FUNC is 0.
543 On the H8 the return value is in R0/R1. */
545 #define FUNCTION_VALUE(VALTYPE, FUNC) \
546 gen_rtx_REG (TYPE_MODE (VALTYPE), R0_REG)
548 /* Define how to find the value returned by a library function
549 assuming the value has mode MODE. */
551 /* On the H8 the return value is in R0/R1. */
553 #define LIBCALL_VALUE(MODE) \
554 gen_rtx_REG (MODE, R0_REG)
556 /* 1 if N is a possible register number for a function value.
557 On the H8, R0 is the only register thus used. */
559 #define FUNCTION_VALUE_REGNO_P(N) ((N) == R0_REG)
561 /* Define this if PCC uses the nonreentrant convention for returning
562 structure and union values. */
564 /*#define PCC_STATIC_STRUCT_RETURN*/
566 /* 1 if N is a possible register number for function argument passing.
567 On the H8, no registers are used in this way. */
569 #define FUNCTION_ARG_REGNO_P(N) (TARGET_QUICKCALL ? N < 3 : 0)
571 /* When this hook returns true for MODE, the compiler allows
572 registers explicitly used in the rtl to be used as spill registers
573 but prevents the compiler from extending the lifetime of these
575 #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true
577 /* Define a data type for recording info about an argument list
578 during the scan of that argument list. This data type should
579 hold all necessary information about the function itself
580 and about the args processed so far, enough to enable macros
581 such as FUNCTION_ARG to determine where the next arg should go.
583 On the H8/300, this is a two item struct, the first is the number
584 of bytes scanned so far and the second is the rtx of the called
585 library function if any. */
587 #define CUMULATIVE_ARGS struct cum_arg
591 struct rtx_def
*libcall
;
594 /* Initialize a variable CUM of type CUMULATIVE_ARGS
595 for a call to a function whose data type is FNTYPE.
596 For a library call, FNTYPE is 0.
598 On the H8/300, the offset starts at 0. */
600 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
601 ((CUM).nbytes = 0, (CUM).libcall = LIBNAME)
603 /* Update the data in CUM to advance over an argument
604 of mode MODE and data type TYPE.
605 (TYPE is null for libcalls where that information may not be available.) */
607 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
608 ((CUM).nbytes += ((MODE) != BLKmode \
609 ? (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) & -UNITS_PER_WORD \
610 : (int_size_in_bytes (TYPE) + UNITS_PER_WORD - 1) & -UNITS_PER_WORD))
612 /* Define where to put the arguments to a function.
613 Value is zero to push the argument on the stack,
614 or a hard register in which to store the argument.
616 MODE is the argument's machine mode.
617 TYPE is the data type of the argument (as a tree).
618 This is null for libcalls where that information may
620 CUM is a variable of type CUMULATIVE_ARGS which gives info about
621 the preceding args and about the function being called.
622 NAMED is nonzero if this argument is a named parameter
623 (otherwise it is an extra parameter matching an ellipsis). */
625 /* On the H8/300 all normal args are pushed, unless -mquickcall in which
626 case the first 3 arguments are passed in registers.
627 See function `function_arg'. */
629 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
630 function_arg (&CUM, MODE, TYPE, NAMED)
632 /* Output assembler code to FILE to increment profiler label # LABELNO
633 for profiling a function entry. */
635 #define FUNCTION_PROFILER(FILE, LABELNO) \
636 fprintf (FILE, "\t%s\t#LP%d,%s\n\tjsr @mcount\n", \
637 h8_mov_op, (LABELNO), h8_reg_names[0]);
639 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
640 the stack pointer does not matter. The value is tested only in
641 functions that have frame pointers.
642 No definition is equivalent to always zero. */
644 #define EXIT_IGNORE_STACK 0
646 /* Length in units of the trampoline for entering a nested function. */
648 #define TRAMPOLINE_SIZE ((Pmode == HImode) ? 8 : 12)
650 /* Addressing modes, and classification of registers for them. */
652 #define HAVE_POST_INCREMENT 1
653 #define HAVE_PRE_DECREMENT 1
654 #define HAVE_POST_DECREMENT TARGET_H8300SX
655 #define HAVE_PRE_INCREMENT TARGET_H8300SX
657 /* Macros to check register numbers against specific register classes. */
659 /* These assume that REGNO is a hard or pseudo reg number.
660 They give nonzero only if REGNO is a hard reg of the suitable class
661 or a pseudo reg currently allocated to a suitable hard reg.
662 Since they use reg_renumber, they are safe only once reg_renumber
663 has been allocated, which happens in local-alloc.c. */
665 #define REGNO_OK_FOR_INDEX_P(regno) 0
667 #define REGNO_OK_FOR_BASE_P(regno) \
668 (((regno) < FIRST_PSEUDO_REGISTER && regno != MAC_REG) \
669 || reg_renumber[regno] >= 0)
671 /* Maximum number of registers that can appear in a valid memory address. */
673 #define MAX_REGS_PER_ADDRESS 1
675 /* 1 if X is an rtx for a constant that is a valid address. */
677 #define CONSTANT_ADDRESS_P(X) \
678 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
679 || (GET_CODE (X) == CONST_INT \
680 /* We handle signed and unsigned offsets here. */ \
681 && INTVAL (X) > (TARGET_H8300 ? -0x10000 : -0x1000000) \
682 && INTVAL (X) < (TARGET_H8300 ? 0x10000 : 0x1000000)) \
683 || (GET_CODE (X) == HIGH || GET_CODE (X) == CONST))
685 /* Nonzero if the constant value X is a legitimate general operand.
686 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
688 #define LEGITIMATE_CONSTANT_P(X) (h8300_legitimate_constant_p (X))
690 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
691 and check its validity for a certain class.
692 We have two alternate definitions for each of them.
693 The usual definition accepts all pseudo regs; the other rejects
694 them unless they have been allocated suitable hard regs.
695 The symbol REG_OK_STRICT causes the latter definition to be used.
697 Most source files want to accept pseudo regs in the hope that
698 they will get allocated to the class that the insn wants them to be in.
699 Source files for reload pass need to be strict.
700 After reload, it makes no difference, since pseudo regs have
701 been eliminated by then. */
703 /* Non-strict versions. */
704 #define REG_OK_FOR_INDEX_NONSTRICT_P(X) 0
705 /* Don't use REGNO_OK_FOR_BASE_P here because it uses reg_renumber. */
706 #define REG_OK_FOR_BASE_NONSTRICT_P(X) \
707 (REGNO (X) >= FIRST_PSEUDO_REGISTER || REGNO (X) != MAC_REG)
709 /* Strict versions. */
710 #define REG_OK_FOR_INDEX_STRICT_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
711 #define REG_OK_FOR_BASE_STRICT_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
713 #ifndef REG_OK_STRICT
715 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_NONSTRICT_P (X)
716 #define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_NONSTRICT_P (X)
720 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_STRICT_P (X)
721 #define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_STRICT_P (X)
725 /* Extra constraints. */
727 #define OK_FOR_Q(OP) \
728 (TARGET_H8300SX && memory_operand ((OP), VOIDmode))
730 #define OK_FOR_R(OP) \
731 (GET_CODE (OP) == CONST_INT \
732 ? !h8300_shift_needs_scratch_p (INTVAL (OP), QImode) \
735 #define OK_FOR_S(OP) \
736 (GET_CODE (OP) == CONST_INT \
737 ? !h8300_shift_needs_scratch_p (INTVAL (OP), HImode) \
740 #define OK_FOR_T(OP) \
741 (GET_CODE (OP) == CONST_INT \
742 ? !h8300_shift_needs_scratch_p (INTVAL (OP), SImode) \
745 /* 'U' if valid for a bset destination;
746 i.e. a register, register indirect, or the eightbit memory region
747 (a SYMBOL_REF with an SYMBOL_REF_FLAG set).
749 On the H8S 'U' can also be a 16bit or 32bit absolute. */
750 #define OK_FOR_U(OP) \
751 ((GET_CODE (OP) == REG && REG_OK_FOR_BASE_P (OP)) \
752 || (GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG \
753 && REG_OK_FOR_BASE_P (XEXP (OP, 0))) \
754 || (GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == SYMBOL_REF \
756 || (GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == CONST \
757 && GET_CODE (XEXP (XEXP (OP, 0), 0)) == PLUS \
758 && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 0)) == SYMBOL_REF \
759 && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 1)) == CONST_INT \
761 || SYMBOL_REF_FLAG (XEXP (XEXP (XEXP (OP, 0), 0), 0)))) \
762 || (GET_CODE (OP) == MEM \
763 && h8300_eightbit_constant_address_p (XEXP (OP, 0))) \
764 || (GET_CODE (OP) == MEM && (TARGET_H8300S || TARGET_H8300SX) \
765 && GET_CODE (XEXP (OP, 0)) == CONST_INT))
767 /* Multi-letter constraints starting with W are to be used for
768 operands that require a memory operand, i.e,. that are never used
769 along with register constraints (see EXTRA_MEMORY_CONSTRAINTS). */
771 #define OK_FOR_WU(OP) \
772 (GET_CODE (OP) == MEM && OK_FOR_U (OP))
774 #define OK_FOR_W(OP, STR) \
775 ((STR)[1] == 'U' ? OK_FOR_WU (OP) \
778 #define CONSTRAINT_LEN_FOR_W(STR) \
779 ((STR)[1] == 'U' ? 2 \
782 /* Multi-letter constraints starting with Y are to be used for operands
783 that are constant immediates and have single 1 or 0 in their binary
786 #define OK_FOR_Y2(OP) \
787 ((GET_CODE (OP) == CONST_INT) && (exact_log2 (INTVAL (OP) & 0xff) != -1))
789 #define OK_FOR_Y0(OP) \
790 ((GET_CODE (OP) == CONST_INT) && (exact_log2 (~INTVAL (OP) & 0xff) != -1))
792 #define OK_FOR_Y(OP, STR) \
793 ((STR)[1] == '2' ? OK_FOR_Y2 (OP) \
794 : (STR)[1] == '0' ? OK_FOR_Y0 (OP) \
797 #define CONSTRAINT_LEN_FOR_Y(STR) \
798 ((STR)[1] == '2' ? 2 \
799 : (STR)[1] == '0' ? 2 \
802 #define OK_FOR_Z(OP) \
804 && GET_CODE (OP) == MEM \
805 && CONSTANT_P (XEXP ((OP), 0)))
807 #define EXTRA_CONSTRAINT_STR(OP, C, STR) \
808 ((C) == 'Q' ? OK_FOR_Q (OP) : \
809 (C) == 'R' ? OK_FOR_R (OP) : \
810 (C) == 'S' ? OK_FOR_S (OP) : \
811 (C) == 'T' ? OK_FOR_T (OP) : \
812 (C) == 'U' ? OK_FOR_U (OP) : \
813 (C) == 'W' ? OK_FOR_W ((OP), (STR)) : \
814 (C) == 'Y' ? OK_FOR_Y ((OP), (STR)) : \
815 (C) == 'Z' ? OK_FOR_Z (OP) : \
818 #define CONSTRAINT_LEN(C, STR) \
819 ((C) == 'P' ? CONSTRAINT_LEN_FOR_P (STR) \
820 : (C) == 'W' ? CONSTRAINT_LEN_FOR_W (STR) \
821 : (C) == 'Y' ? CONSTRAINT_LEN_FOR_Y (STR) \
822 : DEFAULT_CONSTRAINT_LEN ((C), (STR)))
824 /* Experiments suggest that it's better not add 'Q' or 'U' here. No
825 patterns need it for correctness (no patterns use 'Q' and 'U'
826 without also providing a register alternative). And defining it
827 will mean that a spilled pseudo could be replaced by its frame
828 location in several consecutive insns.
830 Instead, it seems to be better to force pseudos to be reloaded
831 into registers and then use peepholes to recombine insns when
834 Unfortunately, for WU (unlike plain U, that matches regs as well),
835 we must require a memory address. In fact, all multi-letter
836 constraints started with W are supposed to have this property, so
837 we just test for W here. */
838 #define EXTRA_MEMORY_CONSTRAINT(C, STR) \
842 /* Go to LABEL if ADDR (a legitimate address expression)
843 has an effect that depends on the machine mode it is used for.
845 On the H8/300, the predecrement and postincrement address depend thus
846 (the amount of decrement or increment being the length of the operand). */
848 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) \
849 if (GET_CODE (ADDR) == PLUS \
850 && h8300_get_index (XEXP (ADDR, 0), VOIDmode, 0) != XEXP (ADDR, 0)) \
853 /* Specify the machine mode that this machine uses
854 for the index in the tablejump instruction. */
855 #define CASE_VECTOR_MODE Pmode
857 /* Define this as 1 if `char' should by default be signed; else as 0.
859 On the H8/300, sign extension is expensive, so we'll say that chars
861 #define DEFAULT_SIGNED_CHAR 0
863 /* This flag, if defined, says the same insns that convert to a signed fixnum
864 also convert validly to an unsigned one. */
865 #define FIXUNS_TRUNC_LIKE_FIX_TRUNC
867 /* Max number of bytes we can move from memory to memory
868 in one reasonably fast instruction. */
869 #define MOVE_MAX (TARGET_H8300H || TARGET_H8300S ? 4 : 2)
870 #define MAX_MOVE_MAX 4
872 /* Nonzero if access to memory by bytes is slow and undesirable. */
873 #define SLOW_BYTE_ACCESS TARGET_SLOWBYTE
875 /* Define if shifts truncate the shift count
876 which implies one can omit a sign-extension or zero-extension
878 /* #define SHIFT_COUNT_TRUNCATED */
880 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
881 is done just by pretending it is already truncated. */
882 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
884 /* Specify the machine mode that pointers have.
885 After generation of rtl, the compiler makes no further distinction
886 between pointers and any other objects of this machine mode. */
888 ((TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE ? SImode : HImode)
891 We use longs for the H8/300H and the H8S because ints can be 16 or 32.
892 GCC requires SIZE_TYPE to be the same size as pointers. */
894 (TARGET_H8300 || TARGET_NORMAL_MODE ? TARGET_INT32 ? "short unsigned int" : "unsigned int" : "long unsigned int")
895 #define PTRDIFF_TYPE \
896 (TARGET_H8300 || TARGET_NORMAL_MODE ? TARGET_INT32 ? "short int" : "int" : "long int")
898 #define POINTER_SIZE \
899 ((TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE ? 32 : 16)
901 #define WCHAR_TYPE "short unsigned int"
902 #define WCHAR_TYPE_SIZE 16
904 /* A function address in a call instruction
905 is a byte address (for indexing purposes)
906 so give the MEM rtx a byte's mode. */
907 #define FUNCTION_MODE QImode
909 /* Return the length of JUMP's delay slot insn (0 if it has none).
910 If JUMP is a delayed branch, NEXT_INSN (PREV_INSN (JUMP)) will
911 be the containing SEQUENCE, not JUMP itself. */
912 #define DELAY_SLOT_LENGTH(JUMP) \
913 (NEXT_INSN (PREV_INSN (JUMP)) == JUMP ? 0 : 2)
915 #define BRANCH_COST(speed_p, predictable_p) 0
917 /* Tell final.c how to eliminate redundant test instructions. */
919 /* Here we define machine-dependent flags and fields in cc_status
920 (see `conditions.h'). No extra ones are needed for the h8300. */
922 /* Store in cc_status the expressions
923 that the condition codes will describe
924 after execution of an instruction whose pattern is EXP.
925 Do not alter them if the instruction would not alter the cc's. */
927 #define NOTICE_UPDATE_CC(EXP, INSN) notice_update_cc (EXP, INSN)
929 /* The add insns don't set overflow in a usable way. */
930 #define CC_OVERFLOW_UNUSABLE 01000
931 /* The mov,and,or,xor insns don't set carry. That's OK though as the
932 Z bit is all we need when doing unsigned comparisons on the result of
933 these insns (since they're always with 0). However, conditions.h has
934 CC_NO_OVERFLOW defined for this purpose. Rename it to something more
936 #define CC_NO_CARRY CC_NO_OVERFLOW
938 /* Control the assembler format that we output. */
940 /* Output to assembler file text saying following lines
941 may contain character constants, extra white space, comments, etc. */
943 #define ASM_APP_ON "; #APP\n"
945 /* Output to assembler file text saying following lines
946 no longer contain unusual constructs. */
948 #define ASM_APP_OFF "; #NO_APP\n"
950 #define FILE_ASM_OP "\t.file\n"
952 /* The assembler op to get a word, 2 bytes for the H8/300, 4 for H8/300H. */
953 #define ASM_WORD_OP \
954 (TARGET_H8300 || TARGET_NORMAL_MODE ? "\t.word\t" : "\t.long\t")
956 #define TEXT_SECTION_ASM_OP "\t.section .text"
957 #define DATA_SECTION_ASM_OP "\t.section .data"
958 #define BSS_SECTION_ASM_OP "\t.section .bss"
960 #undef DO_GLOBAL_CTORS_BODY
961 #define DO_GLOBAL_CTORS_BODY \
963 extern func_ptr __ctors[]; \
964 extern func_ptr __ctors_end[]; \
966 for (p = __ctors_end; p > __ctors; ) \
972 #undef DO_GLOBAL_DTORS_BODY
973 #define DO_GLOBAL_DTORS_BODY \
975 extern func_ptr __dtors[]; \
976 extern func_ptr __dtors_end[]; \
978 for (p = __dtors; p < __dtors_end; p++) \
984 /* How to refer to registers in assembler output.
985 This sequence is indexed by compiler's hard-register-number (see above). */
987 #define REGISTER_NAMES \
988 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "sp", "mac", "ap", "rap", "fp" }
990 #define ADDITIONAL_REGISTER_NAMES \
991 { {"er0", 0}, {"er1", 1}, {"er2", 2}, {"er3", 3}, {"er4", 4}, \
992 {"er5", 5}, {"er6", 6}, {"er7", 7}, {"r7", 7} }
994 /* Globalizing directive for a label. */
995 #define GLOBAL_ASM_OP "\t.global "
997 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
998 ASM_OUTPUT_LABEL (FILE, NAME)
1000 /* The prefix to add to user-visible assembler symbols. */
1002 #define USER_LABEL_PREFIX "_"
1004 /* This is how to store into the string LABEL
1005 the symbol_ref name of an internal numbered label where
1006 PREFIX is the class of label and NUM is the number within the class.
1007 This is suitable for output with `assemble_name'.
1009 N.B.: The h8300.md branch_true and branch_false patterns also know
1010 how to generate internal labels. */
1011 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
1012 sprintf (LABEL, "*.%s%lu", PREFIX, (unsigned long)(NUM))
1014 /* This is how to output an insn to push a register on the stack.
1015 It need not be very fast code. */
1017 #define ASM_OUTPUT_REG_PUSH(FILE, REGNO) \
1018 fprintf (FILE, "\t%s\t%s\n", h8_push_op, h8_reg_names[REGNO])
1020 /* This is how to output an insn to pop a register from the stack.
1021 It need not be very fast code. */
1023 #define ASM_OUTPUT_REG_POP(FILE, REGNO) \
1024 fprintf (FILE, "\t%s\t%s\n", h8_pop_op, h8_reg_names[REGNO])
1026 /* This is how to output an element of a case-vector that is absolute. */
1028 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
1029 fprintf (FILE, "%s.L%d\n", ASM_WORD_OP, VALUE)
1031 /* This is how to output an element of a case-vector that is relative. */
1033 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
1034 fprintf (FILE, "%s.L%d-.L%d\n", ASM_WORD_OP, VALUE, REL)
1036 /* This is how to output an assembler line
1037 that says to advance the location counter
1038 to a multiple of 2**LOG bytes. */
1040 #define ASM_OUTPUT_ALIGN(FILE, LOG) \
1042 fprintf (FILE, "\t.align %d\n", (LOG))
1044 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
1045 fprintf (FILE, "\t.space %d\n", (int)(SIZE))
1047 /* This says how to output an assembler line
1048 to define a global common symbol. */
1050 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
1051 ( fputs ("\t.comm ", (FILE)), \
1052 assemble_name ((FILE), (NAME)), \
1053 fprintf ((FILE), ",%lu\n", (unsigned long)(SIZE)))
1055 /* This says how to output the assembler to define a global
1056 uninitialized but not common symbol.
1057 Try to use asm_output_bss to implement this macro. */
1059 #define ASM_OUTPUT_BSS(FILE, DECL, NAME, SIZE, ROUNDED) \
1060 asm_output_bss ((FILE), (DECL), (NAME), (SIZE), (ROUNDED))
1062 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
1063 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
1065 /* This says how to output an assembler line
1066 to define a local common symbol. */
1068 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
1069 ( fputs ("\t.lcomm ", (FILE)), \
1070 assemble_name ((FILE), (NAME)), \
1071 fprintf ((FILE), ",%d\n", (int)(SIZE)))
1073 #define ASM_PN_FORMAT "%s___%lu"
1075 /* Print an instruction operand X on file FILE.
1076 Look in h8300.c for details. */
1078 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
1081 #define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
1083 /* Print a memory operand whose address is X, on file FILE.
1084 This uses a function in h8300.c. */
1086 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
1088 /* H8300 specific pragmas. */
1089 #define REGISTER_TARGET_PRAGMAS() \
1092 c_register_pragma (0, "saveall", h8300_pr_saveall); \
1093 c_register_pragma (0, "interrupt", h8300_pr_interrupt); \
1097 #define FINAL_PRESCAN_INSN(insn, operand, nop) \
1098 final_prescan_insn (insn, operand, nop)
1100 extern int h8300_move_ratio
;
1101 #define MOVE_RATIO(speed) h8300_move_ratio
1103 /* Machine-specific symbol_ref flags. */
1104 #define SYMBOL_FLAG_FUNCVEC_FUNCTION (SYMBOL_FLAG_MACH_DEP << 0)
1105 #define SYMBOL_FLAG_EIGHTBIT_DATA (SYMBOL_FLAG_MACH_DEP << 1)
1106 #define SYMBOL_FLAG_TINY_DATA (SYMBOL_FLAG_MACH_DEP << 2)
1108 #endif /* ! GCC_H8300_H */