(RTX_COSTS): Remove LSHIFT.
[gcc.git] / gcc / config / h8300 / h8300.h
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)
5
6 This file is part of GNU CC.
7
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)
11 any later version.
12
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.
17
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. */
21
22 /* Names to predefine in the preprocessor for this target machine. */
23
24 #define CPP_PREDEFINES "-D__H8300__ -D_DOUBLE_IS_32BITS -Acpu(h8300) -Amachine(h8300)"
25
26 #define LIB_SPEC "%{mrelax:-relax} %{g:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} "
27
28 /* Print subsidiary information on the compiler version in use. */
29 #define TARGET_VERSION fprintf (stderr, " (Hitachi H8/300)");
30 \f
31 /* Run-time compilation parameters selecting different hardware subsets. */
32 int target_flags;
33
34 /* Macros used in the machine description to test the flags. */
35
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. */
41
42 #define TARGET_SWITCHES \
43 { {"int32",8}, \
44 {"long16",16}, \
45 {"double64",32}, \
46 {"addresses",64 }, \
47 {"quickcall",128}, \
48 {"slowbyte",256}, \
49 {"noquick",512}, \
50 {"relax",1024}, \
51 { "", TARGET_DEFAULT}}
52
53 /* Show we can debug even without a frame pointer. */
54 #define CAN_DEBUG_WITHOUT_FP
55
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
61
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)
69
70 /* Default target_flags if no switches specified. */
71 #ifndef TARGET_DEFAULT
72 #define TARGET_DEFAULT 0
73 #endif
74
75 #define TARGET_NO_IMPORT (target_flags & MASK_NO_IMPORT)
76 \f
77 /* Target machine storage layout. */
78
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
83
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
87
88 /* Define this if most significant word of a multiword number is lowest
89 numbered.
90
91 This is true on an H8/300 (actually we can make it up, but we choose to
92 be consistent. */
93 #define WORDS_BIG_ENDIAN 1
94
95 /* Number of bits in an addressable storage unit */
96 #define BITS_PER_UNIT 8
97
98 #define UNITS_PER_PTR 2
99
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
106
107 /* Width of a word, in units (bytes). */
108 #define UNITS_PER_WORD 2
109
110 /* Width in bits of a pointer.
111 See also the macro `Pmode' defined below. */
112 #define POINTER_SIZE 16
113
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
121
122 #define MAX_FIXED_MODE_SIZE 32
123
124 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
125 #define PARM_BOUNDARY 16
126
127 /* Allocation boundary (in *bits*) for the code of a function. */
128 #define FUNCTION_BOUNDARY 16
129
130 /* Alignment of field after `int : 0' in a structure. */
131 #define EMPTY_FIELD_BOUNDARY (16)
132
133 /* Every structure's size must be a multiple of this. */
134 #define STRUCTURE_SIZE_BOUNDARY 16
135
136 /* A bitfield declared as `int' forces `int' alignment for the struct. */
137 #define PCC_BITFIELD_TYPE_MATTERS 0
138
139 /* No data type wants to be aligned rounder than this. */
140 #define BIGGEST_ALIGNMENT 16
141
142 /* No structure field wants to be aligned rounder than this. */
143 #define BIGGEST_FIELD_ALIGNMENT 16
144
145 /* The stack goes in 16 bit lumps. */
146 #define STACK_BOUNDARY 16
147
148 /* Define this if move instructions will actually fail to work
149 when given unaligned data. */
150 #define STRICT_ALIGNMENT 1
151 \f
152 /* Standard register usage. */
153
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.
157
158 All registers that the compiler knows about must be given numbers,
159 even those that are not normally considered general registers.
160
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
164 pointer. */
165 #define FIRST_PSEUDO_REGISTER 9
166
167 /* 1 for registers that have pervasive standard uses
168 and are not available for the register allocator.
169
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 }
173
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
180 like.
181
182 The H8/300 destroys r0, r1, r4 and r5. */
183
184 #define CALL_USED_REGISTERS \
185 {1,1,0,0, 1,1,0,1, 1 }
186
187 /* This is the order in which to allocate registers
188 normally. */
189 #define REG_ALLOC_ORDER { 0, 1, 4, 5, 2, 3, 6, 7, 8 }
190
191 /* Return number of consecutive hard regs needed starting at reg REGNO
192 to hold something of mode MODE.
193
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)
198
199 /* Value is 1 if hard register REGNO can hold a value of machine-mode
200 MODE.
201
202 If an even reg, then anything goes. Otherwise the mode must be QI
203 or HI. */
204 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
205 ((((REGNO) & 1) == 0) || (MODE == HImode) || (MODE == QImode))
206
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))
212
213 /* Specify the registers used for certain standard purposes.
214 The values of these macros are register numbers. */
215
216 /* H8/300 pc is not overloaded on a register. */
217 /*#define PC_REGNUM 15*/
218
219 /* Register to use for pushing function arguments. */
220 #define STACK_POINTER_REGNUM 7
221
222 /* Base register for access to local variables of the function. */
223 #define FRAME_POINTER_REGNUM 6
224
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
230
231 /* Base register for access to arguments of the function. */
232 #define ARG_POINTER_REGNUM 8
233
234 /* Register in which static-chain is passed to a function. */
235 #define STATIC_CHAIN_REGNUM 0
236 \f
237 /* Define the classes of registers for register constraints in the
238 machine description. Also define ranges of constants.
239
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.
243
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.
249
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.
253
254 For any two classes, it is very desirable that there be another
255 class that represents their union. */
256
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. */
259
260 enum reg_class { NO_REGS, LONG_REGS, GENERAL_REGS, SP_REG, ALL_REGS, LIM_REG_CLASSES };
261
262 #define N_REG_CLASSES (int) LIM_REG_CLASSES
263
264 /* Give names of register classes as strings for dump file. */
265
266 #define REG_CLASS_NAMES \
267 {"NO_REGS", "LONG_REGS", "GENERAL_REGS", "SP_REG", "ALL_REGS", "LIM_REGS"}
268
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. */
272
273 #define REG_CLASS_CONTENTS \
274 { 0, /* No regs */ \
275 0x7f, /* LONG_REGS */ \
276 0x7f, /* GENERAL_REGS */ \
277 0x80, /* SP_REG */ \
278 0xff, /* ALL_REGS */ \
279 }
280
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. */
285
286 #define REGNO_REG_CLASS(REGNO) \
287 ((REGNO) >= STACK_POINTER_REGNUM \
288 ? ((REGNO) >= FRAME_POINTER_REGNUM \
289 ? SP_REG \
290 : GENERAL_REGS) \
291 : LONG_REGS)
292
293 /* The class value for index registers, and the one for base regs. */
294
295 #define INDEX_REG_CLASS NO_REGS
296 #define BASE_REG_CLASS GENERAL_REGS
297
298 /* Get reg_class from a letter such as appears in the machine description. */
299
300 #define REG_CLASS_FROM_LETTER(C) \
301 ((C) == 'a' ? SP_REG : (((C) == 'l') ? LONG_REGS : NO_REGS))
302
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. */
308
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)) : \
318 0)
319
320 /* Similar, but for floating constants, and defining letters G and H.
321 Here VALUE is the CONST_DOUBLE rtx itself.
322
323 `G' is a floating-point zero. */
324
325 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
326 ((C) == 'G' ? ((VALUE) == CONST0_RTX (DFmode) \
327 || (VALUE) == CONST0_RTX (DFmode)) \
328 : 0)
329
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) \
333 (((C) == 'U') \
334 ? ((GET_CODE (OP) == REG) \
335 || ((GET_CODE (OP) == MEM) \
336 && GET_CODE (XEXP (OP, 0)) == REG)) \
337 : 0)
338
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)
344
345 /* Return the maximum number of consecutive registers
346 needed to represent mode MODE in a register of class CLASS. */
347
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)
352
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
355 shortcuts. */
356 #define REGISTER_MOVE_COST(CLASS1, CLASS2) 3
357 \f
358 /* Stack layout; function entry, exit and calling. */
359
360 /* Define this if pushing a word on the stack
361 makes the stack pointer a smaller address. */
362 #define STACK_GROWS_DOWNWARD
363
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
369
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
375
376 /* If we generate an insn to push BYTES bytes,
377 this says how many the stack pointer really advances by.
378
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)
383
384 /* Offset of first parameter from the argument pointer register value. */
385
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
389
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.
395
396 On the H8/300 the return does not pop anything. */
397 #define RETURN_POPS_ARGS(FUNTYPE,SIZE) 0
398
399 /* Definitions for register eliminations.
400
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.
405
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}}
414
415 #define CAN_ELIMINATE(FROM, TO) \
416 ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM \
417 ? ! frame_pointer_needed \
418 : 1)
419
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)
423
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.
428
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)
432
433 /* Define how to find the value returned by a library function
434 assuming the value has mode MODE. */
435
436 /* On the H8/300 the return value is in R0/R1. */
437 #define LIBCALL_VALUE(MODE) \
438 gen_rtx (REG, MODE, 0)
439
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)
443
444 /* Define this if PCC uses the nonreentrant convention for returning
445 structure and union values. */
446 #define PCC_STATIC_STRUCT_RETURN
447
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
451
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
457
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)
461
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
465
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
470 \f
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.
476
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. */
479
480 #define CUMULATIVE_ARGS struct cum_arg
481 struct cum_arg { int nbytes; struct rtx_def* libcall; };
482
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.
486
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)
490
491 /* Update the data in CUM to advance over an argument
492 of mode MODE and data type TYPE.
493
494 All sizes rounded up to even bytes. */
495
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))
500
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.
504
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
508 not be available.
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). */
513
514 /* On the H8/300 all normal args are pushed, we pass args to named
515 functions in registers. */
516
517 extern struct rtx_def *function_arg();
518 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
519 function_arg (&CUM, MODE, TYPE, NAMED)
520
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. */
528
529 #define FUNCTION_PROLOGUE(FILE, SIZE) \
530 function_prologue (FILE, SIZE)
531
532 /* Output assembler code to FILE to increment profiler label # LABELNO
533 for profiling a function entry. */
534
535 #define FUNCTION_PROFILER(FILE, LABELNO) \
536 fprintf (FILE, "\t; not implemented\n", (LABELNO));
537
538 /* Output assembler code to FILE to initialize this source file's
539 basic block profiling info, if that has not already been done. */
540
541 #define FUNCTION_BLOCK_PROFILER(FILE, LABELNO) \
542 fprintf (FILE, "\t; not implemented \n", LABELNO, LABELNO);
543
544 /* Output assembler code to FILE to increment the entry-count for
545 the BLOCKNO'th basic block in this source file. */
546
547 #define BLOCK_PROFILER(FILE, BLOCKNO) \
548 fprintf (FILE, "\t; not implemented\n");
549
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. */
554
555 #define EXIT_IGNORE_STACK 0
556
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. */
561
562 #define FUNCTION_EPILOGUE(FILE, SIZE) \
563 function_epilogue (FILE, SIZE)
564
565 /* Output assembler code for a block containing the constant parts
566 of a trampoline, leaving space for the variable parts. */
567
568 #define TRAMPOLINE_TEMPLATE(FILE) \
569 fprintf (FILE, " trampolines not implemented\n");
570
571 /* Length in units of the trampoline for entering a nested function. */
572
573 #define TRAMPOLINE_SIZE 15
574
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. */
578
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) \
582 { \
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)); \
588 }
589 \f
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
593 use to gcc */
594
595 /*#define HAVE_POST_INCREMENT*/
596 /*#define HAVE_POST_DECREMENT */
597
598 /*#define HAVE_PRE_DECREMENT*/
599 /*#define HAVE_PRE_INCREMENT */
600
601 /* Macros to check register numbers against specific register classes. */
602
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. */
608
609 #define REGNO_OK_FOR_INDEX_P(regno) 0
610
611 #define REGNO_OK_FOR_BASE_P(regno) \
612 ((regno) < FIRST_PSEUDO_REGISTER || reg_renumber[regno] >= 0)
613 \f
614 /* Maximum number of registers that can appear in a valid memory address. */
615
616 #define MAX_REGS_PER_ADDRESS 1
617
618 /* 1 if X is an rtx for a constant that is a valid address. */
619
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)
624
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. */
627
628 #define LEGITIMATE_CONSTANT_P(X) (GET_CODE (X) != CONST_DOUBLE)
629
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.
636
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. */
642
643 #ifndef REG_OK_STRICT
644
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
651
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))
654
655 #else
656
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))
661
662 #endif
663 \f
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.
668
669 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
670 except for CONSTANT_ADDRESS_P which is actually
671 machine-independent.
672
673
674 On the H8/300, a legitimate address has the form
675 REG, REG+CONSTANT_ADDRESS or CONSTANT_ADDRESS. */
676
677 /* Accept either REG or SUBREG where a register is valid. */
678
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))))
683
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;
690 \f
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.
694
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.
697
698 MODE and WIN are passed so that this macro can use
699 GO_IF_LEGITIMATE_ADDRESS.
700
701 It is always safe for this macro to do nothing. It exists to recognize
702 opportunities to optimize the output.
703
704 For the H8/300, don't do anything. */
705
706 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) {}
707
708 /* Go to LABEL if ADDR (a legitimate address expression)
709 has an effect that depends on the machine mode it is used for.
710
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). */
715
716 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
717 if (GET_CODE (ADDR) == POST_INC || GET_CODE (ADDR) == PRE_DEC) goto LABEL;
718 \f
719 /* Specify the machine mode that this machine uses
720 for the index in the tablejump instruction. */
721 #define CASE_VECTOR_MODE HImode
722
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*/
727
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
732
733 /* Specify the tree operation to be used to convert reals to integers. */
734 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
735
736 /* This is the kind of divide that is easiest to do in the general case. */
737 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
738
739 /* Define this as 1 if `char' should by default be signed; else as 0.
740
741 On the H8/300, sign extension is expensive, so we'll say that chars
742 are unsigned. */
743 #define DEFAULT_SIGNED_CHAR 0
744
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
748
749 /* Max number of bytes we can move from memory to memory
750 in one reasonably fast instruction. */
751 #define MOVE_MAX 2
752
753 /* Define this if zero-extension is slow (more than one real instruction). */
754 /* #define SLOW_ZERO_EXTEND */
755
756 /* Nonzero if access to memory by bytes is slow and undesirable. */
757 #define SLOW_BYTE_ACCESS TARGET_SLOWBYTE
758
759 /* Define if shifts truncate the shift count
760 which implies one can omit a sign-extension or zero-extension
761 of a shift count. */
762 /* #define SHIFT_COUNT_TRUNCATED */
763
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
767
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. */
771 #define Pmode HImode
772
773 #define SIZE_TYPE "unsigned int"
774 #define PTRDIFF_TYPE "int"
775
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
780
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. */
785
786 #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
787 case CONST_INT: \
788 switch (INTVAL (RTX)) \
789 { \
790 case 0: \
791 case 1: \
792 case 2: \
793 case -1: \
794 case -2: \
795 return 0; \
796 default: \
797 return 1; \
798 } \
799 case CONST: \
800 case LABEL_REF: \
801 case SYMBOL_REF: \
802 return 3; \
803 case CONST_DOUBLE: \
804 return 20;
805
806 #define BRANCH_COST 2
807
808 /* Provide the costs of a rtl expression. This is in the body of a
809 switch on CODE. */
810
811 #define RTX_COSTS(RTX,CODE,OUTER_CODE) \
812 case MOD: \
813 case DIV: \
814 return 60; \
815 case MULT: \
816 return 20; \
817 case ASHIFT: \
818 case ASHIFTRT: \
819 case LSHIFTRT: \
820 case ROTATE: \
821 case ROTATERT: \
822 if (GET_MODE (RTX) == HImode) \
823 return 2; \
824 return 10; \
825 \f
826 /* Tell final.c how to eliminate redundant test instructions. */
827
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. */
831
832 #define NOTICE_UPDATE_CC(EXP, INSN) \
833 switch (get_attr_cc (INSN)) \
834 { \
835 case CC_NONE: \
836 /* Insn does not affect the CC at all. */ \
837 break; \
838 case CC_NONE_0HIT: \
839 /* Insn does not change the CC, but the 0'th operand has been \
840 changed. */ \
841 if (cc_status.value1 != 0 \
842 && reg_overlap_mentioned_p (recog_operand[0], cc_status.value1))\
843 cc_status.value1 = 0; \
844 \
845 if (cc_status.value2 != 0 \
846 && reg_overlap_mentioned_p (recog_operand[0], cc_status.value2))\
847 cc_status.value2 = 0; \
848 break; \
849 case CC_SET: \
850 /* Insn sets CC to recog_operand[0], but overflow is impossible. */\
851 CC_STATUS_INIT; \
852 cc_status.flags |= CC_NO_OVERFLOW; \
853 cc_status.value1 = recog_operand[0]; \
854 break; \
855 case CC_COMPARE: \
856 /* The insn is a compare instruction. */ \
857 CC_STATUS_INIT; \
858 cc_status.value1 = recog_operand[0]; \
859 cc_status.value1 = recog_operand[1]; \
860 break; \
861 case CC_WHOOPS: \
862 case CC_CLOBBER: \
863 /* Insn clobbers CC. */ \
864 CC_STATUS_INIT; \
865 break; \
866 } \
867
868 #define OUTPUT_JUMP(NORMAL, FLOAT, NO_OV) \
869 { \
870 if (cc_status.flags & CC_NO_OVERFLOW) \
871 return NO_OV; \
872 return NORMAL; \
873 }
874 \f
875 /* Control the assembler format that we output. */
876
877 #define ASM_IDENTIFY_GCC /* nothing */
878
879 /* Output at beginning of assembler file. */
880 #define ASM_FILE_START(FILE) \
881 { \
882 fprintf (FILE, ";\tGCC For the Hitachi H8/300\n"); \
883 if (optimize) \
884 fprintf (FILE, "; -O%d\n", optimize); \
885 fprintf (FILE, "\n\n"); \
886 output_file_directive (FILE, main_input_filename); \
887 }
888
889 #define ASM_FILE_END(FILE) \
890 fprintf (FILE, "\t.end\n");
891
892 /* Output to assembler file text saying following lines
893 may contain character constants, extra white space, comments, etc. */
894
895 #define ASM_APP_ON "; #APP\n"
896
897 /* Output to assembler file text saying following lines
898 no longer contain unusual constructs. */
899
900 #define ASM_APP_OFF "; #NO_APP\n"
901
902 #define FILE_ASM_OP "\t.file\n"
903 #define IDENT_ASM_OP "\t.ident\n"
904
905 /* Output before read-only data. */
906
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"
910
911 #define MAX_TEXT_ALIGN 16
912
913 /* How to refer to registers in assembler output.
914 This sequence is indexed by compiler's hard-register-number (see above). */
915
916 #define REGISTER_NAMES \
917 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "ap"}
918
919 /* How to renumber registers for dbx and gdb.
920 H8/300 needs no change in the numeration. */
921
922 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
923
924 #define SDB_DEBUGGING_INFO
925 #define SDB_DELIM "\n"
926
927 /* Assemble generic sections.
928 This is currently only used to support section attributes. */
929
930 #define ASM_OUTPUT_SECTION_NAME(FILE, NAME) \
931 fprintf (FILE, ".section\t%s\n", NAME)
932
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. */
935
936 #define ASM_OUTPUT_LABEL(FILE,NAME) \
937 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
938
939 /*#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) */
940
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)
945
946 /*#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
947 ASM_OUTPUT_LABEL(FILE, NAME); */
948
949 /* This is how to output a reference to a user-level label named NAME.
950 `assemble_name' uses this. */
951
952 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
953 fprintf (FILE, "_%s", NAME)
954
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. */
957
958 #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM) \
959 fprintf (FILE, ".%s%d:\n", PREFIX, NUM)
960
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'. */
965
966 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
967 sprintf (LABEL, "*.%s%d", PREFIX, NUM)
968
969 /* This is how to output an assembler line defining a `double' constant.
970 It is .dfloat or .gfloat, depending. */
971
972 /*#define ASM_OUTPUT_DOUBLE(FILE, VALUE) \
973 fprintf (FILE, "\t.double %.20e\n", (VALUE))*/
974
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)));
980
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"))
986
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"))
992
993 #define ASM_OUTPUT_SHORT(FILE, VALUE) \
994 ( fprintf (FILE, "\t.word "), \
995 output_addr_const (FILE, (VALUE)), \
996 fprintf (FILE, "\n"))
997
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))
1001
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])
1006
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])
1011
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)
1015
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)
1019
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) \
1024 if ((LOG) != 0) \
1025 fprintf (FILE, "\t.align %d\n", 1 << (LOG))
1026
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)
1031
1032 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
1033 fprintf (FILE, "\t.space %d\n", (SIZE))
1034
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)))
1041
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)))
1048
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. */
1052
1053 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
1054 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
1055 sprintf ((OUTPUT), "%s___%d", (NAME), (LABELNO)))
1056
1057 /* Define the parentheses used to group arithmetic operations
1058 in assembler code. */
1059
1060 #define ASM_OPEN_PAREN "("
1061 #define ASM_CLOSE_PAREN ")"
1062
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
1071
1072 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
1073 ((CODE) == '#')
1074
1075 #define PRINT_OPERAND(FILE, X, CODE) \
1076 print_operand (FILE, X, CODE)
1077
1078 /* Print a memory operand whose address is X, on file FILE.
1079 This uses a function in h8300.c. */
1080
1081 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
1082 print_operand_address (FILE, ADDR)
1083
1084 #define HANDLE_PRAGMA(FILE) handle_pragma (FILE)
1085
1086 #define FINAL_PRESCAN_INSN(insn, operand, nop) \
1087 final_prescan_insn (insn, operand, nop)
1088
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
1093
1094 /* Define subroutines to call to handle various operations not
1095 supported in the hardware */
1096
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"
1104
1105 #define MOVE_RATIO 3