1 /* Definitions of target machine for GNU compiler.
2 Hitachi H8/300 version generating coff
3 Copyright (C) 1992, 1993 Free Software Foundation, Inc.
4 Contributed by Steve Chamberlain (sac@cygnus.com)
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
22 /* Names to predefine in the preprocessor for this target machine. */
24 #define CPP_PREDEFINES "-D__H8300__ -D_DOUBLE_IS_32BITS -Acpu(h8300) -Amachine(h8300)"
26 #define LIB_SPEC "%{mrelax:-relax} %{g:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} "
28 /* Print subsidiary information on the compiler version in use. */
29 #define TARGET_VERSION fprintf (stderr, " (Hitachi H8/300)");
31 /* Run-time compilation parameters selecting different hardware subsets. */
34 /* Macros used in the machine description to test the flags. */
36 /* Macro to define tables used to set the flags.
37 This is a list in braces of pairs in braces,
38 each pair being { "NAME", VALUE }
39 where VALUE is the bits to set or minus the bits to clear.
40 An empty string NAME is used to identify the default VALUE. */
42 #define TARGET_SWITCHES \
51 { "", TARGET_DEFAULT}}
53 /* Show we can debug even without a frame pointer. */
54 #define CAN_DEBUG_WITHOUT_FP
56 /* Define this if addresses of constant functions
57 shouldn't be put through pseudo regs where they can be cse'd.
58 Desirable on machines where ordinary constants are expensive
59 but a CALL with constant address is cheap. */
60 #define NO_FUNCTION_CSE
62 #define TARGET_INT32 (target_flags & 8)
63 #define TARGET_LONG16 (target_flags & 16)
64 #define TARGET_DOUBLE32 (!(target_flags & 32))
65 #define TARGET_ADDRESSES (target_flags & 64)
66 #define TARGET_QUICKCALL (target_flags & 128)
67 #define TARGET_SLOWBYTE (target_flags & 256)
68 #define TARGET_NOQUICK (target_flags & 512)
70 /* Default target_flags if no switches specified. */
71 #ifndef TARGET_DEFAULT
72 #define TARGET_DEFAULT 0
75 #define TARGET_NO_IMPORT (target_flags & MASK_NO_IMPORT)
77 /* Target machine storage layout. */
79 /* Define this if most significant bit is lowest numbered
80 in instructions that operate on numbered bit-fields.
81 This is not true on the H8/300. */
82 #define BITS_BIG_ENDIAN 0
84 /* Define this if most significant byte of a word is the lowest numbered. */
85 /* That is true on the H8/300. */
86 #define BYTES_BIG_ENDIAN 1
88 /* Define this if most significant word of a multiword number is lowest
91 This is true on an H8/300 (actually we can make it up, but we choose to
93 #define WORDS_BIG_ENDIAN 1
95 /* Number of bits in an addressable storage unit */
96 #define BITS_PER_UNIT 8
98 #define UNITS_PER_PTR 2
100 /* Width in bits of a "word", which is the contents of a machine register.
101 Note that this is not necessarily the width of data type `int';
102 if using 16-bit ints on a 68000, this would still be 32.
103 But on a machine with 16-bit registers, this would be 16. */
104 #define BITS_PER_WORD 16
105 #define MAX_BITS_PER_WORD 16
107 /* Width of a word, in units (bytes). */
108 #define UNITS_PER_WORD 2
110 /* Width in bits of a pointer.
111 See also the macro `Pmode' defined below. */
112 #define POINTER_SIZE 16
114 #define SHORT_TYPE_SIZE 16
115 #define INT_TYPE_SIZE (TARGET_INT32 ? 32 : 16)
116 #define LONG_TYPE_SIZE 32
117 #define LONG_LONG_TYPE_SIZE 32
118 #define DOUBLE_TYPE_SIZE (TARGET_DOUBLE32 ? 32 : 64)
119 #define FLOAT_TYPE_SIZE 32
120 #define LONG_DOUBLE_TYPE_SIZE DOUBLE_TYPE_SIZE
122 #define MAX_FIXED_MODE_SIZE 32
124 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
125 #define PARM_BOUNDARY 16
127 /* Allocation boundary (in *bits*) for the code of a function. */
128 #define FUNCTION_BOUNDARY 16
130 /* Alignment of field after `int : 0' in a structure. */
131 #define EMPTY_FIELD_BOUNDARY (16)
133 /* Every structure's size must be a multiple of this. */
134 #define STRUCTURE_SIZE_BOUNDARY 16
136 /* A bitfield declared as `int' forces `int' alignment for the struct. */
137 #define PCC_BITFIELD_TYPE_MATTERS 0
139 /* No data type wants to be aligned rounder than this. */
140 #define BIGGEST_ALIGNMENT 16
142 /* No structure field wants to be aligned rounder than this. */
143 #define BIGGEST_FIELD_ALIGNMENT 16
145 /* The stack goes in 16 bit lumps. */
146 #define STACK_BOUNDARY 16
148 /* Define this if move instructions will actually fail to work
149 when given unaligned data. */
150 #define STRICT_ALIGNMENT 1
152 /* Standard register usage. */
154 /* Number of actual hardware registers.
155 The hardware registers are assigned numbers for the compiler
156 from 0 to just below FIRST_PSEUDO_REGISTER.
158 All registers that the compiler knows about must be given numbers,
159 even those that are not normally considered general registers.
161 Reg 8 does not correspond to any hardware register, but instead
162 appears in the RTL as an argument pointer prior to reload, and is
163 eliminated during reloading in favor of either the stack or frame
165 #define FIRST_PSEUDO_REGISTER 9
167 /* 1 for registers that have pervasive standard uses
168 and are not available for the register allocator.
170 r7 is the stack pointer, r8 is the arg pointer. */
171 #define FIXED_REGISTERS \
172 { 0,0,0,0, 0,0,0,1, 1 }
174 /* 1 for registers not available across function calls.
175 These must include the FIXED_REGISTERS and also any
176 registers that can be used without being saved.
177 The latter must include the registers where values are returned
178 and the register where structure-value addresses are passed.
179 Aside from that, you can include as many other registers as you
182 The H8/300 destroys r0, r1, r4 and r5. */
184 #define CALL_USED_REGISTERS \
185 {1,1,0,0, 1,1,0,1, 1 }
187 /* This is the order in which to allocate registers
189 #define REG_ALLOC_ORDER { 0, 1, 4, 5, 2, 3, 6, 7, 8 }
191 /* Return number of consecutive hard regs needed starting at reg REGNO
192 to hold something of mode MODE.
194 This is ordinarily the length in words of a value of mode MODE
195 but can be less for certain modes in special long registers. */
196 #define HARD_REGNO_NREGS(REGNO, MODE) \
197 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
199 /* Value is 1 if hard register REGNO can hold a value of machine-mode
202 If an even reg, then anything goes. Otherwise the mode must be QI
204 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
205 ((((REGNO) & 1) == 0) || (MODE == HImode) || (MODE == QImode))
207 /* Value is 1 if it is a good idea to tie two pseudo registers
208 when one has mode MODE1 and one has mode MODE2.
209 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
210 for any hard reg, then this must be 0 for correct output. */
211 #define MODES_TIEABLE_P(MODE1, MODE2) ((MODE1) == (MODE2))
213 /* Specify the registers used for certain standard purposes.
214 The values of these macros are register numbers. */
216 /* H8/300 pc is not overloaded on a register. */
217 /*#define PC_REGNUM 15*/
219 /* Register to use for pushing function arguments. */
220 #define STACK_POINTER_REGNUM 7
222 /* Base register for access to local variables of the function. */
223 #define FRAME_POINTER_REGNUM 6
225 /* Value should be nonzero if functions must have frame pointers.
226 Zero means the frame pointer need not be set up (and parms
227 may be accessed via the stack pointer) in functions that seem suitable.
228 This is computed in `reload', in reload1.c. */
229 #define FRAME_POINTER_REQUIRED 0
231 /* Base register for access to arguments of the function. */
232 #define ARG_POINTER_REGNUM 8
234 /* Register in which static-chain is passed to a function. */
235 #define STATIC_CHAIN_REGNUM 0
237 /* Define the classes of registers for register constraints in the
238 machine description. Also define ranges of constants.
240 One of the classes must always be named ALL_REGS and include all hard regs.
241 If there is more than one class, another class must be named NO_REGS
242 and contain no registers.
244 The name GENERAL_REGS must be the name of a class (or an alias for
245 another name such as ALL_REGS). This is the class of registers
246 that is allowed by "g" or "r" in a register constraint.
247 Also, registers outside this class are allocated only when
248 instructions express preferences for them.
250 The classes must be numbered in nondecreasing order; that is,
251 a larger-numbered class must never be contained completely
252 in a smaller-numbered class.
254 For any two classes, it is very desirable that there be another
255 class that represents their union. */
257 /* The H8/300 has only one kind of register, but we mustn't do byte by
258 byte operations on the sp, so we keep it as a different class. */
260 enum reg_class
{ NO_REGS
, LONG_REGS
, GENERAL_REGS
, SP_REG
, ALL_REGS
, LIM_REG_CLASSES
};
262 #define N_REG_CLASSES (int) LIM_REG_CLASSES
264 /* Give names of register classes as strings for dump file. */
266 #define REG_CLASS_NAMES \
267 {"NO_REGS", "LONG_REGS", "GENERAL_REGS", "SP_REG", "ALL_REGS", "LIM_REGS"}
269 /* Define which registers fit in which classes.
270 This is an initializer for a vector of HARD_REG_SET
271 of length N_REG_CLASSES. */
273 #define REG_CLASS_CONTENTS \
275 0x7f, /* LONG_REGS */ \
276 0x7f, /* GENERAL_REGS */ \
278 0xff, /* ALL_REGS */ \
281 /* The same information, inverted:
282 Return the class number of the smallest class containing
283 reg number REGNO. This could be a conditional expression
284 or could index an array. */
286 #define REGNO_REG_CLASS(REGNO) \
287 ((REGNO) >= STACK_POINTER_REGNUM \
288 ? ((REGNO) >= FRAME_POINTER_REGNUM \
293 /* The class value for index registers, and the one for base regs. */
295 #define INDEX_REG_CLASS NO_REGS
296 #define BASE_REG_CLASS GENERAL_REGS
298 /* Get reg_class from a letter such as appears in the machine description. */
300 #define REG_CLASS_FROM_LETTER(C) \
301 ((C) == 'a' ? SP_REG : (((C) == 'l') ? LONG_REGS : NO_REGS))
303 /* The letters I, J, K, L, M, N, O, P in a register constraint string
304 can be used to stand for particular ranges of immediate operands.
305 This macro defines what the ranges are.
306 C is the letter, and VALUE is a constant value.
307 Return 1 if VALUE is in the range specified by C. */
309 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
310 ((C) == 'I' ? (VALUE) == 0 : \
311 (C) == 'J' ? (((VALUE) & 0xff00) == 0) : \
312 (C) == 'K' ? ((VALUE) == 1 || (VALUE) == 2) : \
313 (C) == 'L' ? ((VALUE) == -1 || (VALUE) == -2) : \
314 (C) == 'M' ? ((VALUE) == 3 || (VALUE) == 4) : \
315 (C) == 'N' ? ((VALUE) == -3 || (VALUE) == -4) : \
316 (C) == 'O' ? (potg8 (VALUE)) : \
317 (C) == 'P' ? (potl8 (VALUE)) : \
320 /* Similar, but for floating constants, and defining letters G and H.
321 Here VALUE is the CONST_DOUBLE rtx itself.
323 `G' is a floating-point zero. */
325 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
326 ((C) == 'G' ? ((VALUE) == CONST0_RTX (DFmode) \
327 || (VALUE) == CONST0_RTX (DFmode)) \
330 /* Extra constraints - 'U' if for an operand valid for a bset
331 destination; i.e. a register or register indirect target. */
332 #define EXTRA_CONSTRAINT(OP, C) \
334 ? ((GET_CODE (OP) == REG) \
335 || ((GET_CODE (OP) == MEM) \
336 && GET_CODE (XEXP (OP, 0)) == REG)) \
339 /* Given an rtx X being reloaded into a reg required to be
340 in class CLASS, return the class of reg to actually use.
341 In general this is just CLASS; but on some machines
342 in some cases it is preferable to use a more restrictive class. */
343 #define PREFERRED_RELOAD_CLASS(X,CLASS) (CLASS)
345 /* Return the maximum number of consecutive registers
346 needed to represent mode MODE in a register of class CLASS. */
348 /* On the H8, this is the size of MODE in words,
349 except in the FP regs, where a single reg is always enough. */
350 #define CLASS_MAX_NREGS(CLASS, MODE) \
351 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
353 /* Any SI register to register move may need to be reloaded,
354 so define REGISTER_MOVE_COST to be > 2 so that reload never
356 #define REGISTER_MOVE_COST(CLASS1, CLASS2) 3
358 /* Stack layout; function entry, exit and calling. */
360 /* Define this if pushing a word on the stack
361 makes the stack pointer a smaller address. */
362 #define STACK_GROWS_DOWNWARD
364 /* Define this if the nominal address of the stack frame
365 is at the high-address end of the local variables;
366 that is, each additional local variable allocated
367 goes at a more negative offset in the frame. */
368 #define FRAME_GROWS_DOWNWARD
370 /* Offset within stack frame to start allocating local variables at.
371 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
372 first local allocated. Otherwise, it is the offset to the BEGINNING
373 of the first local allocated. */
374 #define STARTING_FRAME_OFFSET 0
376 /* If we generate an insn to push BYTES bytes,
377 this says how many the stack pointer really advances by.
379 On the H8/300, @-sp really pushes a byte if you ask it to - but that's
380 dangerous, so we claim that it always pushes a word, then we catch
381 the mov.b rx,@-sp and turn it into a mov.w rx,@-sp on output. */
382 #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
384 /* Offset of first parameter from the argument pointer register value. */
386 /* Is equal to the size of the saved fp + pc, even if an fp isn't
387 saved since the value is used before we know. */
388 #define FIRST_PARM_OFFSET(FNDECL) 0
390 /* Value is the number of bytes of arguments automatically
391 popped when returning from a subroutine call.
392 FUNTYPE is the data type of the function (as a tree),
393 or for a library call it is an identifier node for the subroutine name.
394 SIZE is the number of bytes of arguments passed on the stack.
396 On the H8/300 the return does not pop anything. */
397 #define RETURN_POPS_ARGS(FUNTYPE,SIZE) 0
399 /* Definitions for register eliminations.
401 This is an array of structures. Each structure initializes one pair
402 of eliminable registers. The "from" register number is given first,
403 followed by "to". Eliminations of the same "from" register are listed
404 in order of preference.
406 We have two registers that can be eliminated on the i386. First, the
407 frame pointer register can often be eliminated in favor of the stack
408 pointer register. Secondly, the argument pointer register can always be
409 eliminated; it is replaced with either the stack or frame pointer. */
410 #define ELIMINABLE_REGS \
411 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
412 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
413 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
415 #define CAN_ELIMINATE(FROM, TO) \
416 ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM \
417 ? ! frame_pointer_needed \
420 /* Define the offset between two registers, one to be eliminated, and the other
421 its replacement, at the start of a routine. */
422 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) OFFSET = io (FROM,TO)
424 /* Define how to find the value returned by a function.
425 VALTYPE is the data type of the value (as a tree).
426 If the precise function being called is known, FUNC is its FUNCTION_DECL;
427 otherwise, FUNC is 0.
429 On the H8/300 the return value is in R0/R1. */
430 #define FUNCTION_VALUE(VALTYPE, FUNC) \
431 gen_rtx (REG, TYPE_MODE (VALTYPE), 0)
433 /* Define how to find the value returned by a library function
434 assuming the value has mode MODE. */
436 /* On the H8/300 the return value is in R0/R1. */
437 #define LIBCALL_VALUE(MODE) \
438 gen_rtx (REG, MODE, 0)
440 /* 1 if N is a possible register number for a function value.
441 On the H8/300, R0 is the only register thus used. */
442 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
444 /* Define this if PCC uses the nonreentrant convention for returning
445 structure and union values. */
446 #define PCC_STATIC_STRUCT_RETURN
448 /* 1 if N is a possible register number for function argument passing.
449 On the H8/300, no registers are used in this way. */
450 #define FUNCTION_ARG_REGNO_P(N) 0
452 /* Register in which address to store a structure value
453 is passed to a function. */
454 #define STRUCT_VALUE 0
455 #define STRUCT_VALUE_REGNUM 0
456 #define STRUCT_VALUE_INCOMING 0
458 /* Return true if X should be returned in memory. */
459 #define RETURN_IN_MEMORY(X) \
460 (TYPE_MODE (X) == BLKmode || GET_MODE_SIZE (TYPE_MODE (X)) > 4)
462 /* Don't default to pcc-struct-return, because we have already specified
463 exactly how to return structures in the RETURN_IN_MEMORY macro. */
464 #define DEFAULT_PCC_STRUCT_RETURN 0
466 /* When defined, the compiler allows registers explicitly used in the
467 rtl to be used as spill registers but prevents the compiler from
468 extending the lifetime of these registers. */
469 #define SMALL_REGISTER_CLASSES
471 /* Define a data type for recording info about an argument list
472 during the scan of that argument list. This data type should
473 Hold all necessary information about the function itself
474 and about the args processed so far, enough to enable macros
475 such as FUNCTION_ARG to determine where the next arg should go.
477 On the H8/300, this is a two item struct, the first is the number of bytes
478 scanned so far, the second the name of any libcall. */
480 #define CUMULATIVE_ARGS struct cum_arg
481 struct cum_arg
{ int nbytes
; struct rtx_def
* libcall
; };
483 /* Initialize a variable CUM of type CUMULATIVE_ARGS
484 for a call to a function whose data type is FNTYPE.
485 For a library call, FNTYPE is 0.
487 On the H8/300, the offset starts at 0. */
488 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME) \
489 ((CUM).nbytes = 0, (CUM).libcall = LIBNAME)
491 /* Update the data in CUM to advance over an argument
492 of mode MODE and data type TYPE.
494 All sizes rounded up to even bytes. */
496 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
497 ((CUM).nbytes += ((MODE) != BLKmode \
498 ? (GET_MODE_SIZE (MODE) + 1) & ~1 \
499 : (int_size_in_bytes (TYPE) + 1) & ~1))
501 /* Define where to put the arguments to a function.
502 Value is zero to push the argument on the stack,
503 or a hard register in which to store the argument.
505 MODE is the argument's machine mode.
506 TYPE is the data type of the argument (as a tree).
507 This is null for libcalls where that information may
509 CUM is a variable of type CUMULATIVE_ARGS which gives info about
510 the preceding args and about the function being called.
511 NAMED is nonzero if this argument is a named parameter
512 (otherwise it is an extra parameter matching an ellipsis). */
514 /* On the H8/300 all normal args are pushed, we pass args to named
515 functions in registers. */
517 extern struct rtx_def
*function_arg();
518 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
519 function_arg (&CUM, MODE, TYPE, NAMED)
521 /* This macro generates the assembly code for function entry.
522 FILE is a stdio stream to output the code to.
523 SIZE is an int: how many units of temporary storage to allocate.
524 Refer to the array `regs_ever_live' to determine which registers
525 to save; `regs_ever_live[I]' is nonzero if register number I
526 is ever used in the function. This macro is responsible for
527 knowing which registers should not be saved even if used. */
529 #define FUNCTION_PROLOGUE(FILE, SIZE) \
530 function_prologue (FILE, SIZE)
532 /* Output assembler code to FILE to increment profiler label # LABELNO
533 for profiling a function entry. */
535 #define FUNCTION_PROFILER(FILE, LABELNO) \
536 fprintf (FILE, "\t; not implemented\n", (LABELNO));
538 /* Output assembler code to FILE to initialize this source file's
539 basic block profiling info, if that has not already been done. */
541 #define FUNCTION_BLOCK_PROFILER(FILE, LABELNO) \
542 fprintf (FILE, "\t; not implemented \n", LABELNO, LABELNO);
544 /* Output assembler code to FILE to increment the entry-count for
545 the BLOCKNO'th basic block in this source file. */
547 #define BLOCK_PROFILER(FILE, BLOCKNO) \
548 fprintf (FILE, "\t; not implemented\n");
550 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
551 the stack pointer does not matter. The value is tested only in
552 functions that have frame pointers.
553 No definition is equivalent to always zero. */
555 #define EXIT_IGNORE_STACK 0
557 /* This macro generates the assembly code for function exit,
558 on machines that need it. If FUNCTION_EPILOGUE is not defined
559 then individual return instructions are generated for each
560 return statement. Args are same as for FUNCTION_PROLOGUE. */
562 #define FUNCTION_EPILOGUE(FILE, SIZE) \
563 function_epilogue (FILE, SIZE)
565 /* Output assembler code for a block containing the constant parts
566 of a trampoline, leaving space for the variable parts. */
568 #define TRAMPOLINE_TEMPLATE(FILE) \
569 fprintf (FILE, " trampolines not implemented\n");
571 /* Length in units of the trampoline for entering a nested function. */
573 #define TRAMPOLINE_SIZE 15
575 /* Emit RTL insns to initialize the variable parts of a trampoline.
576 FNADDR is an RTX for the address of the function's pure code.
577 CXT is an RTX for the static chain value for the function. */
579 /* We copy the register-mask from the function's pure code
580 to the start of the trampoline. */
581 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
583 emit_move_insn (gen_rtx (MEM, HImode, TRAMP), \
584 gen_rtx (MEM, HImode, FNADDR)); \
585 emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 4)), CXT);\
586 emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 11)), \
587 plus_constant (FNADDR, 2)); \
590 /* Addressing modes, and classification of registers for them.
591 Although the H8/300 has pre decrement destinations and post
592 increment sources on moves, they are not general enough to be much
595 /*#define HAVE_POST_INCREMENT*/
596 /*#define HAVE_POST_DECREMENT */
598 /*#define HAVE_PRE_DECREMENT*/
599 /*#define HAVE_PRE_INCREMENT */
601 /* Macros to check register numbers against specific register classes. */
603 /* These assume that REGNO is a hard or pseudo reg number.
604 They give nonzero only if REGNO is a hard reg of the suitable class
605 or a pseudo reg currently allocated to a suitable hard reg.
606 Since they use reg_renumber, they are safe only once reg_renumber
607 has been allocated, which happens in local-alloc.c. */
609 #define REGNO_OK_FOR_INDEX_P(regno) 0
611 #define REGNO_OK_FOR_BASE_P(regno) \
612 ((regno) < FIRST_PSEUDO_REGISTER || reg_renumber[regno] >= 0)
614 /* Maximum number of registers that can appear in a valid memory address. */
616 #define MAX_REGS_PER_ADDRESS 1
618 /* 1 if X is an rtx for a constant that is a valid address. */
620 #define CONSTANT_ADDRESS_P(X) \
621 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
622 || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \
623 || GET_CODE (X) == HIGH)
625 /* Nonzero if the constant value X is a legitimate general operand.
626 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
628 #define LEGITIMATE_CONSTANT_P(X) (GET_CODE (X) != CONST_DOUBLE)
630 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
631 and check its validity for a certain class.
632 We have two alternate definitions for each of them.
633 The usual definition accepts all pseudo regs; the other rejects
634 them unless they have been allocated suitable hard regs.
635 The symbol REG_OK_STRICT causes the latter definition to be used.
637 Most source files want to accept pseudo regs in the hope that
638 they will get allocated to the class that the insn wants them to be in.
639 Source files for reload pass need to be strict.
640 After reload, it makes no difference, since pseudo regs have
641 been eliminated by then. */
643 #ifndef REG_OK_STRICT
645 /* Nonzero if X is a hard reg that can be used as an index
646 or if it is a pseudo reg. */
647 #define REG_OK_FOR_INDEX_P(X) 0
648 /* Nonzero if X is a hard reg that can be used as a base reg
649 or if it is a pseudo reg. */
650 #define REG_OK_FOR_BASE_P(X) 1
652 #define REG_OK_FOR_INDEX_P_STRICT(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
653 #define REG_OK_FOR_BASE_P_STRICT(X) REGNO_OK_FOR_BASE_P (REGNO (X))
657 /* Nonzero if X is a hard reg that can be used as an index. */
658 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
659 /* Nonzero if X is a hard reg that can be used as a base reg. */
660 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
664 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
665 that is a valid memory address for an instruction.
666 The MODE argument is the machine mode for the MEM expression
667 that wants to use this address.
669 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
670 except for CONSTANT_ADDRESS_P which is actually
674 On the H8/300, a legitimate address has the form
675 REG, REG+CONSTANT_ADDRESS or CONSTANT_ADDRESS. */
677 /* Accept either REG or SUBREG where a register is valid. */
679 #define RTX_OK_FOR_BASE_P(X) \
680 ((REG_P (X) && REG_OK_FOR_BASE_P (X)) \
681 || (GET_CODE (X) == SUBREG && REG_P (SUBREG_REG (X)) \
682 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
684 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
685 if (RTX_OK_FOR_BASE_P (X)) goto ADDR; \
686 if (CONSTANT_ADDRESS_P (X)) goto ADDR; \
687 if (GET_CODE (X) == PLUS \
688 && CONSTANT_ADDRESS_P (XEXP (X, 1)) \
689 && RTX_OK_FOR_BASE_P (XEXP (X, 0))) goto ADDR;
691 /* Try machine-dependent ways of modifying an illegitimate address
692 to be legitimate. If we find one, return the new, valid address.
693 This macro is used in only one place: `memory_address' in explow.c.
695 OLDX is the address as it was before break_out_memory_refs was called.
696 In some cases it is useful to look at this to decide what needs to be done.
698 MODE and WIN are passed so that this macro can use
699 GO_IF_LEGITIMATE_ADDRESS.
701 It is always safe for this macro to do nothing. It exists to recognize
702 opportunities to optimize the output.
704 For the H8/300, don't do anything. */
706 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) {}
708 /* Go to LABEL if ADDR (a legitimate address expression)
709 has an effect that depends on the machine mode it is used for.
711 On the H8/300, the predecrement and postincrement address depend thus
712 (the amount of decrement or increment being the length of the operand)
713 and all indexed address depend thus (because the index scale factor
714 is the length of the operand). */
716 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
717 if (GET_CODE (ADDR) == POST_INC || GET_CODE (ADDR) == PRE_DEC) goto LABEL;
719 /* Specify the machine mode that this machine uses
720 for the index in the tablejump instruction. */
721 #define CASE_VECTOR_MODE HImode
723 /* Define this if the case instruction expects the table
724 to contain offsets from the address of the table.
725 Do not define this if the table should contain absolute addresses. */
726 /*#define CASE_VECTOR_PC_RELATIVE*/
728 /* Define this if the case instruction drops through after the table
729 when the index is out of range. Don't define it if the case insn
730 jumps to the default label instead. */
731 #define CASE_DROPS_THROUGH
733 /* Specify the tree operation to be used to convert reals to integers. */
734 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
736 /* This is the kind of divide that is easiest to do in the general case. */
737 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
739 /* Define this as 1 if `char' should by default be signed; else as 0.
741 On the H8/300, sign extension is expensive, so we'll say that chars
743 #define DEFAULT_SIGNED_CHAR 0
745 /* This flag, if defined, says the same insns that convert to a signed fixnum
746 also convert validly to an unsigned one. */
747 #define FIXUNS_TRUNC_LIKE_FIX_TRUNC
749 /* Max number of bytes we can move from memory to memory
750 in one reasonably fast instruction. */
753 /* Define this if zero-extension is slow (more than one real instruction). */
754 /* #define SLOW_ZERO_EXTEND */
756 /* Nonzero if access to memory by bytes is slow and undesirable. */
757 #define SLOW_BYTE_ACCESS TARGET_SLOWBYTE
759 /* Define if shifts truncate the shift count
760 which implies one can omit a sign-extension or zero-extension
762 /* #define SHIFT_COUNT_TRUNCATED */
764 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
765 is done just by pretending it is already truncated. */
766 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
768 /* Specify the machine mode that pointers have.
769 After generation of rtl, the compiler makes no further distinction
770 between pointers and any other objects of this machine mode. */
773 #define SIZE_TYPE "unsigned int"
774 #define PTRDIFF_TYPE "int"
776 /* A function address in a call instruction
777 is a byte address (for indexing purposes)
778 so give the MEM rtx a byte's mode. */
779 #define FUNCTION_MODE QImode
781 /* Compute the cost of computing a constant rtl expression RTX
782 whose rtx-code is CODE. The body of this macro is a portion
783 of a switch statement. If the code is computed here,
784 return it with a return statement. Otherwise, break from the switch. */
786 #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
788 switch (INTVAL (RTX)) \
806 #define BRANCH_COST 2
808 /* Provide the costs of a rtl expression. This is in the body of a
811 #define RTX_COSTS(RTX,CODE,OUTER_CODE) \
822 if (GET_MODE (RTX) == HImode) \
826 /* Tell final.c how to eliminate redundant test instructions. */
828 /* Store in cc_status the expressions that the condition codes will describe
829 after execution of an instruction whose pattern is EXP. Do not
830 alter them if the instruction would not alter the cc's. */
832 #define NOTICE_UPDATE_CC(EXP, INSN) \
833 switch (get_attr_cc (INSN)) \
836 /* Insn does not affect the CC at all. */ \
839 /* Insn does not change the CC, but the 0'th operand has been \
841 if (cc_status.value1 != 0 \
842 && reg_overlap_mentioned_p (recog_operand[0], cc_status.value1))\
843 cc_status.value1 = 0; \
845 if (cc_status.value2 != 0 \
846 && reg_overlap_mentioned_p (recog_operand[0], cc_status.value2))\
847 cc_status.value2 = 0; \
850 /* Insn sets CC to recog_operand[0], but overflow is impossible. */\
852 cc_status.flags |= CC_NO_OVERFLOW; \
853 cc_status.value1 = recog_operand[0]; \
856 /* The insn is a compare instruction. */ \
858 cc_status.value1 = recog_operand[0]; \
859 cc_status.value1 = recog_operand[1]; \
863 /* Insn clobbers CC. */ \
868 #define OUTPUT_JUMP(NORMAL, FLOAT, NO_OV) \
870 if (cc_status.flags & CC_NO_OVERFLOW) \
875 /* Control the assembler format that we output. */
877 #define ASM_IDENTIFY_GCC /* nothing */
879 /* Output at beginning of assembler file. */
880 #define ASM_FILE_START(FILE) \
882 fprintf (FILE, ";\tGCC For the Hitachi H8/300\n"); \
884 fprintf (FILE, "; -O%d\n", optimize); \
885 fprintf (FILE, "\n\n"); \
886 output_file_directive (FILE, main_input_filename); \
889 #define ASM_FILE_END(FILE) \
890 fprintf (FILE, "\t.end\n");
892 /* Output to assembler file text saying following lines
893 may contain character constants, extra white space, comments, etc. */
895 #define ASM_APP_ON "; #APP\n"
897 /* Output to assembler file text saying following lines
898 no longer contain unusual constructs. */
900 #define ASM_APP_OFF "; #NO_APP\n"
902 #define FILE_ASM_OP "\t.file\n"
903 #define IDENT_ASM_OP "\t.ident\n"
905 /* Output before read-only data. */
907 #define TEXT_SECTION_ASM_OP "\t.section .text"
908 #define DATA_SECTION_ASM_OP "\t.section .data"
909 #define BSS_SECTION_ASM_OP "\t.section .bss"
911 #define MAX_TEXT_ALIGN 16
913 /* How to refer to registers in assembler output.
914 This sequence is indexed by compiler's hard-register-number (see above). */
916 #define REGISTER_NAMES \
917 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "ap"}
919 /* How to renumber registers for dbx and gdb.
920 H8/300 needs no change in the numeration. */
922 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
924 #define SDB_DEBUGGING_INFO
925 #define SDB_DELIM "\n"
927 /* Assemble generic sections.
928 This is currently only used to support section attributes. */
930 #define ASM_OUTPUT_SECTION_NAME(FILE, NAME) \
931 fprintf (FILE, ".section\t%s\n", NAME)
933 /* This is how to output the definition of a user-level label named NAME,
934 such as the label on a static function or variable NAME. */
936 #define ASM_OUTPUT_LABEL(FILE,NAME) \
937 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
939 /*#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) */
941 /* This is how to output a command to make the user-level label named NAME
942 defined for reference from other files. */
943 #define ASM_GLOBALIZE_LABEL(FILE,NAME) \
944 do { fputs ("\t.global ", FILE); assemble_name (FILE, NAME); fputs ("\n", FILE);} while (0)
946 /*#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
947 ASM_OUTPUT_LABEL(FILE, NAME); */
949 /* This is how to output a reference to a user-level label named NAME.
950 `assemble_name' uses this. */
952 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
953 fprintf (FILE, "_%s", NAME)
955 /* This is how to output an internal numbered label where
956 PREFIX is the class of label and NUM is the number within the class. */
958 #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM) \
959 fprintf (FILE, ".%s%d:\n", PREFIX, NUM)
961 /* This is how to store into the string LABEL
962 the symbol_ref name of an internal numbered label where
963 PREFIX is the class of label and NUM is the number within the class.
964 This is suitable for output with `assemble_name'. */
966 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
967 sprintf (LABEL, "*.%s%d", PREFIX, NUM)
969 /* This is how to output an assembler line defining a `double' constant.
970 It is .dfloat or .gfloat, depending. */
972 /*#define ASM_OUTPUT_DOUBLE(FILE, VALUE) \
973 fprintf (FILE, "\t.double %.20e\n", (VALUE))*/
975 /* This is how to output an assembler line defining a `float' constant. */
976 #define ASM_OUTPUT_FLOAT(FILE, VALUE) \
977 fprintf (FILE, "\t.float %.20e\n", \
978 ((VALUE) > 1e30 ? 1e30 \
979 : ((VALUE) < -1e30) ? -1e30 : (double) ((float) VALUE)));
981 /* This is how to output an assembler line defining an `int' constant. */
982 #define ASM_OUTPUT_INT(FILE, VALUE) \
983 ( fprintf (FILE, "\t.long "), \
984 output_addr_const (FILE, (VALUE)), \
985 fprintf (FILE, "\n"))
987 /* Likewise for `char' and `short' constants. */
988 #define ASM_OUTPUT_CHAR(FILE, VALUE) \
989 ( fprintf (FILE, "\t.byte "), \
990 output_addr_const (FILE, (VALUE)), \
991 fprintf (FILE, "\n"))
993 #define ASM_OUTPUT_SHORT(FILE, VALUE) \
994 ( fprintf (FILE, "\t.word "), \
995 output_addr_const (FILE, (VALUE)), \
996 fprintf (FILE, "\n"))
998 /* This is how to output an assembler line for a numeric constant byte. */
999 #define ASM_OUTPUT_BYTE(FILE, VALUE) \
1000 fprintf (FILE, "\t.byte 0x%x\n", (VALUE))
1002 /* This is how to output an insn to push a register on the stack.
1003 It need not be very fast code. */
1004 #define ASM_OUTPUT_REG_PUSH(FILE, REGNO) \
1005 fprintf (FILE, "\tpush %s\n", reg_names[REGNO])
1007 /* This is how to output an insn to pop a register from the stack.
1008 It need not be very fast code. */
1009 #define ASM_OUTPUT_REG_POP(FILE, REGNO) \
1010 fprintf (FILE, "\tpop\t%s\n", reg_names[REGNO])
1012 /* This is how to output an element of a case-vector that is absolute. */
1013 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
1014 asm_fprintf (FILE, "\t.word .L%d\n", VALUE)
1016 /* This is how to output an element of a case-vector that is relative. */
1017 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
1018 fprintf (FILE, "\t.word.w .L%d-.L%d\n", VALUE, REL)
1020 /* This is how to output an assembler line
1021 that says to advance the location counter
1022 to a multiple of 2**LOG bytes. */
1023 #define ASM_OUTPUT_ALIGN(FILE, LOG) \
1025 fprintf (FILE, "\t.align %d\n", 1 << (LOG))
1027 /* This is how to output an assembler line
1028 that says to advance the location counter by SIZE bytes. */
1029 #define ASM_OUTPUT_IDENT(FILE, NAME) \
1030 fprintf (FILE, "%s\t \"%s\"\n", IDENT_ASM_OP, NAME)
1032 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
1033 fprintf (FILE, "\t.space %d\n", (SIZE))
1035 /* This says how to output an assembler line
1036 to define a global common symbol. */
1037 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
1038 ( fputs ("\t.comm ", (FILE)), \
1039 assemble_name ((FILE), (NAME)), \
1040 fprintf ((FILE), ",%d\n", (SIZE)))
1042 /* This says how to output an assembler line
1043 to define a local common symbol. */
1044 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE,ROUNDED) \
1045 ( fputs ("\t.lcomm ", (FILE)), \
1046 assemble_name ((FILE), (NAME)), \
1047 fprintf ((FILE), ",%d\n", (SIZE)))
1049 /* Store in OUTPUT a string (made with alloca) containing
1050 an assembler-name for a local static variable named NAME.
1051 LABELNO is an integer which is different for each call. */
1053 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
1054 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
1055 sprintf ((OUTPUT), "%s___%d", (NAME), (LABELNO)))
1057 /* Define the parentheses used to group arithmetic operations
1058 in assembler code. */
1060 #define ASM_OPEN_PAREN "("
1061 #define ASM_CLOSE_PAREN ")"
1063 /* Define results of standard character escape sequences. */
1064 #define TARGET_BELL 007
1065 #define TARGET_BS 010
1066 #define TARGET_TAB 011
1067 #define TARGET_NEWLINE 012
1068 #define TARGET_VT 013
1069 #define TARGET_FF 014
1070 #define TARGET_CR 015
1072 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
1075 #define PRINT_OPERAND(FILE, X, CODE) \
1076 print_operand (FILE, X, CODE)
1078 /* Print a memory operand whose address is X, on file FILE.
1079 This uses a function in h8300.c. */
1081 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
1082 print_operand_address (FILE, ADDR)
1084 #define HANDLE_PRAGMA(FILE) handle_pragma (FILE)
1086 #define FINAL_PRESCAN_INSN(insn, operand, nop) \
1087 final_prescan_insn (insn, operand, nop)
1089 /* Define this macro if GNU CC should generate calls to the System V
1090 (and ANSI C) library functions `memcpy' and `memset' rather than
1091 the BSD functions `bcopy' and `bzero'. */
1092 #define TARGET_MEM_FUNCTIONS 1
1094 /* Define subroutines to call to handle various operations not
1095 supported in the hardware */
1097 #define DIVHI3_LIBCALL "__divhi3"
1098 #define UDIVHI3_LIBCALL "__udivhi3"
1099 #define MULHI3_LIBCALL "__mulhi3"
1100 #define MODHI3_LIBCALL "__modhi3"
1101 #define UMODHI3_LIBCALL "__umodhi3"
1102 #define ADDSI3_LIBCALL "__addsi3"
1103 #define SUBSI3_LIBCALL "__subsi3"
1105 #define MOVE_RATIO 3