Turn HARD_REGNO_MODE_OK into a target hook
[official-gcc.git] / gcc / config / h8300 / h8300.h
blob6a72e8704c8d6d63d6eb4419708f61ebeb33d112
1 /* Definitions of target machine for GNU compiler.
2 Renesas H8/300 (generic)
3 Copyright (C) 1992-2017 Free Software Foundation, Inc.
4 Contributed by Steve Chamberlain (sac@cygnus.com),
5 Jim Wilson (wilson@cygnus.com), and Doug Evans (dje@cygnus.com).
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
14 GCC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
23 #ifndef GCC_H8300_H
24 #define GCC_H8300_H
26 /* Which CPU to compile for.
27 We use int for CPU_TYPE to avoid lots of casts. */
28 #if 0 /* defined in insn-attr.h, here for documentation */
29 enum attr_cpu { CPU_H8300, CPU_H8300H };
30 #endif
31 extern int cpu_type;
33 /* Various globals defined in h8300.c. */
35 extern const char *h8_push_op, *h8_pop_op, *h8_mov_op;
36 extern const char * const *h8_reg_names;
38 /* Target CPU builtins. */
39 #define TARGET_CPU_CPP_BUILTINS() \
40 do \
41 { \
42 if (TARGET_H8300SX) \
43 { \
44 builtin_define ("__H8300SX__"); \
45 if (TARGET_NORMAL_MODE) \
46 { \
47 builtin_define ("__NORMAL_MODE__"); \
48 } \
49 } \
50 else if (TARGET_H8300S) \
51 { \
52 builtin_define ("__H8300S__"); \
53 builtin_assert ("cpu=h8300s"); \
54 builtin_assert ("machine=h8300s"); \
55 if (TARGET_NORMAL_MODE) \
56 { \
57 builtin_define ("__NORMAL_MODE__"); \
58 } \
59 } \
60 else if (TARGET_H8300H) \
61 { \
62 builtin_define ("__H8300H__"); \
63 builtin_assert ("cpu=h8300h"); \
64 builtin_assert ("machine=h8300h"); \
65 if (TARGET_NORMAL_MODE) \
66 { \
67 builtin_define ("__NORMAL_MODE__"); \
68 } \
69 } \
70 else \
71 { \
72 builtin_define ("__H8300__"); \
73 builtin_assert ("cpu=h8300"); \
74 builtin_assert ("machine=h8300"); \
75 } \
76 } \
77 while (0)
79 #define LINK_SPEC "%{mh:%{mn:-m h8300hn}} %{mh:%{!mn:-m h8300h}} %{ms:%{mn:-m h8300sn}} %{ms:%{!mn:-m h8300s}}"
81 #define LIB_SPEC "%{mrelax:-relax} %{g:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
83 /* Macros used in the machine description to test the flags. */
85 /* Select between the H8/300 and H8/300H CPUs. */
86 #define TARGET_H8300 (! TARGET_H8300H && ! TARGET_H8300S)
87 #define TARGET_H8300S (TARGET_H8300S_1 || TARGET_H8300SX)
88 /* Some multiply instructions are not available in all H8SX variants.
89 Use this macro instead of TARGET_H8300SX to indicate this, even
90 though we don't actually generate different code for now. */
91 #define TARGET_H8300SXMUL TARGET_H8300SX
93 #ifdef IN_LIBGCC2
94 #undef TARGET_H8300H
95 #undef TARGET_H8300S
96 #undef TARGET_NORMAL_MODE
97 /* If compiling libgcc2, make these compile time constants based on what
98 flags are we actually compiling with. */
99 #ifdef __H8300H__
100 #define TARGET_H8300H 1
101 #else
102 #define TARGET_H8300H 0
103 #endif
104 #ifdef __H8300S__
105 #define TARGET_H8300S 1
106 #else
107 #define TARGET_H8300S 0
108 #endif
109 #ifdef __NORMAL_MODE__
110 #define TARGET_NORMAL_MODE 1
111 #else
112 #define TARGET_NORMAL_MODE 0
113 #endif
114 #endif /* !IN_LIBGCC2 */
116 /* Default target_flags if no switches specified. */
118 #ifndef TARGET_DEFAULT
119 #define TARGET_DEFAULT (MASK_QUICKCALL)
120 #endif
122 /* We want dwarf2 info available to gdb. */
123 #define DWARF2_DEBUGGING_INFO 1
125 /* The return address is pushed on the stack. */
126 #define INCOMING_RETURN_ADDR_RTX gen_rtx_MEM (Pmode, gen_rtx_REG (Pmode, STACK_POINTER_REGNUM))
127 #define INCOMING_FRAME_SP_OFFSET (POINTER_SIZE / 8)
129 #define DWARF_CIE_DATA_ALIGNMENT 2
131 /* Define this if addresses of constant functions
132 shouldn't be put through pseudo regs where they can be cse'd.
133 Desirable on machines where ordinary constants are expensive
134 but a CALL with constant address is cheap.
136 Calls through a register are cheaper than calls to named
137 functions; however, the register pressure this causes makes
138 CSEing of function addresses generally a lose. */
139 #define NO_FUNCTION_CSE 1
141 /* Target machine storage layout */
143 /* Define this if most significant bit is lowest numbered
144 in instructions that operate on numbered bit-fields.
145 This is not true on the H8/300. */
146 #define BITS_BIG_ENDIAN 0
148 /* Define this if most significant byte of a word is the lowest numbered. */
149 /* That is true on the H8/300. */
150 #define BYTES_BIG_ENDIAN 1
152 /* Define this if most significant word of a multiword number is lowest
153 numbered. */
154 #define WORDS_BIG_ENDIAN 1
156 #define MAX_BITS_PER_WORD 32
158 /* Width of a word, in units (bytes). */
159 #define UNITS_PER_WORD (TARGET_H8300H || TARGET_H8300S ? 4 : 2)
160 #define MIN_UNITS_PER_WORD 2
162 #define SHORT_TYPE_SIZE 16
163 #define INT_TYPE_SIZE (TARGET_INT32 ? 32 : 16)
164 #define LONG_TYPE_SIZE 32
165 #define LONG_LONG_TYPE_SIZE 64
166 #define FLOAT_TYPE_SIZE 32
167 #define DOUBLE_TYPE_SIZE 32
168 #define LONG_DOUBLE_TYPE_SIZE DOUBLE_TYPE_SIZE
170 #define MAX_FIXED_MODE_SIZE 32
172 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
173 #define PARM_BOUNDARY (TARGET_H8300H || TARGET_H8300S ? 32 : 16)
175 /* Allocation boundary (in *bits*) for the code of a function. */
176 #define FUNCTION_BOUNDARY 16
178 /* Alignment of field after `int : 0' in a structure. */
179 /* One can argue this should be 32 for -mint32, but since 32-bit ints only
180 need 16-bit alignment, this is left as is so that -mint32 doesn't change
181 structure layouts. */
182 #define EMPTY_FIELD_BOUNDARY 16
184 /* No data type wants to be aligned rounder than this.
185 32-bit values are aligned as such on the H8/300H and H8S for speed. */
186 #define BIGGEST_ALIGNMENT \
187 (((TARGET_H8300H || TARGET_H8300S) && ! TARGET_ALIGN_300) ? 32 : 16)
189 /* The stack goes in 16/32 bit lumps. */
190 #define STACK_BOUNDARY (TARGET_H8300 ? 16 : 32)
192 /* Define this if move instructions will actually fail to work
193 when given unaligned data. */
194 /* On the H8/300, longs can be aligned on halfword boundaries, but not
195 byte boundaries. */
196 #define STRICT_ALIGNMENT 1
198 /* Standard register usage. */
200 /* Number of actual hardware registers.
201 The hardware registers are assigned numbers for the compiler
202 from 0 to just below FIRST_PSEUDO_REGISTER.
204 All registers that the compiler knows about must be given numbers,
205 even those that are not normally considered general registers.
207 Reg 9 does not correspond to any hardware register, but instead
208 appears in the RTL as an argument pointer prior to reload, and is
209 eliminated during reloading in favor of either the stack or frame
210 pointer. */
212 #define FIRST_PSEUDO_REGISTER 12
214 /* 1 for registers that have pervasive standard uses
215 and are not available for the register allocator. */
217 #define FIXED_REGISTERS \
218 /* r0 r1 r2 r3 r4 r5 r6 r7 mac ap rap fp */ \
219 { 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1 }
221 /* 1 for registers not available across function calls.
222 These must include the FIXED_REGISTERS and also any
223 registers that can be used without being saved.
224 The latter must include the registers where values are returned
225 and the register where structure-value addresses are passed.
226 Aside from that, you can include as many other registers as you
227 like.
229 H8 destroys r0,r1,r2,r3. */
231 #define CALL_USED_REGISTERS \
232 /* r0 r1 r2 r3 r4 r5 r6 r7 mac ap rap fp */ \
233 { 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1 }
235 #define REG_ALLOC_ORDER \
236 /* r0 r1 r2 r3 r4 r5 r6 r7 mac ap rap fp */ \
237 { 2, 3, 0, 1, 4, 5, 6, 8, 7, 9, 10, 11 }
239 #define HARD_REGNO_NREGS(REGNO, MODE) \
240 h8300_hard_regno_nregs ((REGNO), (MODE))
242 /* Value is 1 if it is a good idea to tie two pseudo registers
243 when one has mode MODE1 and one has mode MODE2.
244 If TARGET_HARD_REGNO_MODE_OK could produce different values for MODE1
245 and MODE2, for any hard reg, then this must be 0 for correct output. */
246 #define MODES_TIEABLE_P(MODE1, MODE2) \
247 ((MODE1) == (MODE2) \
248 || (((MODE1) == QImode || (MODE1) == HImode \
249 || ((TARGET_H8300H || TARGET_H8300S) && (MODE1) == SImode)) \
250 && ((MODE2) == QImode || (MODE2) == HImode \
251 || ((TARGET_H8300H || TARGET_H8300S) && (MODE2) == SImode))))
253 /* A C expression that is nonzero if hard register NEW_REG can be
254 considered for use as a rename register for OLD_REG register */
256 #define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
257 h8300_hard_regno_rename_ok (OLD_REG, NEW_REG)
259 /* Specify the registers used for certain standard purposes.
260 The values of these macros are register numbers. */
262 /* H8/300 pc is not overloaded on a register. */
264 /*#define PC_REGNUM 15*/
266 /* Register to use for pushing function arguments. */
267 #define STACK_POINTER_REGNUM SP_REG
269 /* Base register for access to local variables of the function. */
270 #define HARD_FRAME_POINTER_REGNUM HFP_REG
272 /* Base register for access to local variables of the function. */
273 #define FRAME_POINTER_REGNUM FP_REG
275 /* Base register for access to arguments of the function. */
276 #define ARG_POINTER_REGNUM AP_REG
278 /* Register in which static-chain is passed to a function. */
279 #define STATIC_CHAIN_REGNUM SC_REG
281 /* Fake register that holds the address on the stack of the
282 current function's return address. */
283 #define RETURN_ADDRESS_POINTER_REGNUM RAP_REG
285 /* A C expression whose value is RTL representing the value of the return
286 address for the frame COUNT steps up from the current frame.
287 FRAMEADDR is already the frame pointer of the COUNT frame, assuming
288 a stack layout with the frame pointer as the first saved register. */
289 #define RETURN_ADDR_RTX(COUNT, FRAME) h8300_return_addr_rtx ((COUNT), (FRAME))
291 /* Define the classes of registers for register constraints in the
292 machine description. Also define ranges of constants.
294 One of the classes must always be named ALL_REGS and include all hard regs.
295 If there is more than one class, another class must be named NO_REGS
296 and contain no registers.
298 The name GENERAL_REGS must be the name of a class (or an alias for
299 another name such as ALL_REGS). This is the class of registers
300 that is allowed by "g" or "r" in a register constraint.
301 Also, registers outside this class are allocated only when
302 instructions express preferences for them.
304 The classes must be numbered in nondecreasing order; that is,
305 a larger-numbered class must never be contained completely
306 in a smaller-numbered class.
308 For any two classes, it is very desirable that there be another
309 class that represents their union. */
311 enum reg_class {
312 NO_REGS, COUNTER_REGS, SOURCE_REGS, DESTINATION_REGS,
313 GENERAL_REGS, MAC_REGS, ALL_REGS, LIM_REG_CLASSES
316 #define N_REG_CLASSES ((int) LIM_REG_CLASSES)
318 /* Give names of register classes as strings for dump file. */
320 #define REG_CLASS_NAMES \
321 { "NO_REGS", "COUNTER_REGS", "SOURCE_REGS", "DESTINATION_REGS", \
322 "GENERAL_REGS", "MAC_REGS", "ALL_REGS", "LIM_REGS" }
324 /* Define which registers fit in which classes.
325 This is an initializer for a vector of HARD_REG_SET
326 of length N_REG_CLASSES. */
328 #define REG_CLASS_CONTENTS \
329 { {0}, /* No regs */ \
330 {0x010}, /* COUNTER_REGS */ \
331 {0x020}, /* SOURCE_REGS */ \
332 {0x040}, /* DESTINATION_REGS */ \
333 {0xeff}, /* GENERAL_REGS */ \
334 {0x100}, /* MAC_REGS */ \
335 {0xfff}, /* ALL_REGS */ \
338 /* The same information, inverted:
339 Return the class number of the smallest class containing
340 reg number REGNO. This could be a conditional expression
341 or could index an array. */
343 #define REGNO_REG_CLASS(REGNO) \
344 ((REGNO) == MAC_REG ? MAC_REGS \
345 : (REGNO) == COUNTER_REG ? COUNTER_REGS \
346 : (REGNO) == SOURCE_REG ? SOURCE_REGS \
347 : (REGNO) == DESTINATION_REG ? DESTINATION_REGS \
348 : GENERAL_REGS)
350 /* The class value for index registers, and the one for base regs. */
352 #define INDEX_REG_CLASS (TARGET_H8300SX ? GENERAL_REGS : NO_REGS)
353 #define BASE_REG_CLASS GENERAL_REGS
355 /* Stack layout; function entry, exit and calling. */
357 /* Define this if pushing a word on the stack
358 makes the stack pointer a smaller address. */
360 #define STACK_GROWS_DOWNWARD 1
362 /* Define this to nonzero if the nominal address of the stack frame
363 is at the high-address end of the local variables;
364 that is, each additional local variable allocated
365 goes at a more negative offset in the frame. */
367 #define FRAME_GROWS_DOWNWARD 1
369 /* Offset within stack frame to start allocating local variables at.
370 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
371 first local allocated. Otherwise, it is the offset to the BEGINNING
372 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.
383 On the H8/300H, we simplify TARGET_QUICKCALL by setting this to 4
384 and doing a similar thing. */
386 #define PUSH_ROUNDING(BYTES) \
387 (((BYTES) + PARM_BOUNDARY / 8 - 1) & -PARM_BOUNDARY / 8)
389 /* Offset of first parameter from the argument pointer register value. */
390 /* Is equal to the size of the saved fp + pc, even if an fp isn't
391 saved since the value is used before we know. */
393 #define FIRST_PARM_OFFSET(FNDECL) 0
395 /* Definitions for register eliminations.
397 This is an array of structures. Each structure initializes one pair
398 of eliminable registers. The "from" register number is given first,
399 followed by "to". Eliminations of the same "from" register are listed
400 in order of preference.
402 We have three registers that can be eliminated on the h8300.
403 First, the frame pointer register can often be eliminated in favor
404 of the stack pointer register. Secondly, the argument pointer
405 register and the return address pointer register are always
406 eliminated; they are replaced with either the stack or frame
407 pointer. */
409 #define ELIMINABLE_REGS \
410 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
411 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
412 { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
413 { RETURN_ADDRESS_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
414 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
415 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}
417 /* Define the offset between two registers, one to be eliminated, and the other
418 its replacement, at the start of a routine. */
420 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
421 ((OFFSET) = h8300_initial_elimination_offset ((FROM), (TO)))
423 /* Define this if PCC uses the nonreentrant convention for returning
424 structure and union values. */
426 /*#define PCC_STATIC_STRUCT_RETURN*/
428 /* 1 if N is a possible register number for function argument passing.
429 On the H8, no registers are used in this way. */
431 #define FUNCTION_ARG_REGNO_P(N) (TARGET_QUICKCALL ? N < 3 : 0)
433 /* When this hook returns true for MODE, the compiler allows
434 registers explicitly used in the rtl to be used as spill registers
435 but prevents the compiler from extending the lifetime of these
436 registers. */
437 #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true
439 /* Define a data type for recording info about an argument list
440 during the scan of that argument list. This data type should
441 hold all necessary information about the function itself
442 and about the args processed so far, enough to enable macros
443 such as FUNCTION_ARG to determine where the next arg should go.
445 On the H8/300, this is a two item struct, the first is the number
446 of bytes scanned so far and the second is the rtx of the called
447 library function if any. */
449 #define CUMULATIVE_ARGS struct cum_arg
450 struct cum_arg
452 int nbytes;
453 rtx libcall;
456 /* Initialize a variable CUM of type CUMULATIVE_ARGS
457 for a call to a function whose data type is FNTYPE.
458 For a library call, FNTYPE is 0.
460 On the H8/300, the offset starts at 0. */
462 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
463 ((CUM).nbytes = 0, (CUM).libcall = LIBNAME)
465 /* Output assembler code to FILE to increment profiler label # LABELNO
466 for profiling a function entry. */
468 #define FUNCTION_PROFILER(FILE, LABELNO) \
469 fprintf (FILE, "\t%s\t#LP%d,%s\n\tjsr @mcount\n", \
470 h8_mov_op, (LABELNO), h8_reg_names[0]);
472 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
473 the stack pointer does not matter. The value is tested only in
474 functions that have frame pointers.
475 No definition is equivalent to always zero. */
477 #define EXIT_IGNORE_STACK 0
479 /* Length in units of the trampoline for entering a nested function. */
481 #define TRAMPOLINE_SIZE ((Pmode == HImode) ? 8 : 12)
483 /* Addressing modes, and classification of registers for them. */
485 #define HAVE_POST_INCREMENT 1
486 #define HAVE_PRE_DECREMENT 1
487 #define HAVE_POST_DECREMENT TARGET_H8300SX
488 #define HAVE_PRE_INCREMENT TARGET_H8300SX
490 /* Macros to check register numbers against specific register classes. */
492 /* These assume that REGNO is a hard or pseudo reg number.
493 They give nonzero only if REGNO is a hard reg of the suitable class
494 or a pseudo reg currently allocated to a suitable hard reg.
495 Since they use reg_renumber, they are safe only once reg_renumber
496 has been allocated, which happens in reginfo.c during register
497 allocation. */
499 #define REGNO_OK_FOR_INDEX_P(regno) 0
501 #define REGNO_OK_FOR_BASE_P(regno) \
502 (((regno) < FIRST_PSEUDO_REGISTER && regno != MAC_REG) \
503 || reg_renumber[regno] >= 0)
505 /* Maximum number of registers that can appear in a valid memory address. */
507 #define MAX_REGS_PER_ADDRESS 1
509 /* 1 if X is an rtx for a constant that is a valid address. */
511 #define CONSTANT_ADDRESS_P(X) \
512 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
513 || (GET_CODE (X) == CONST_INT \
514 /* We handle signed and unsigned offsets here. */ \
515 && INTVAL (X) > (TARGET_H8300 ? -0x10000 : -0x1000000) \
516 && INTVAL (X) < (TARGET_H8300 ? 0x10000 : 0x1000000)) \
517 || (GET_CODE (X) == HIGH || GET_CODE (X) == CONST))
519 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
520 and check its validity for a certain class.
521 We have two alternate definitions for each of them.
522 The usual definition accepts all pseudo regs; the other rejects
523 them unless they have been allocated suitable hard regs.
524 The symbol REG_OK_STRICT causes the latter definition to be used.
526 Most source files want to accept pseudo regs in the hope that
527 they will get allocated to the class that the insn wants them to be in.
528 Source files for reload pass need to be strict.
529 After reload, it makes no difference, since pseudo regs have
530 been eliminated by then. */
532 /* Non-strict versions. */
533 #define REG_OK_FOR_INDEX_NONSTRICT_P(X) 0
534 /* Don't use REGNO_OK_FOR_BASE_P here because it uses reg_renumber. */
535 #define REG_OK_FOR_BASE_NONSTRICT_P(X) \
536 (REGNO (X) >= FIRST_PSEUDO_REGISTER || REGNO (X) != MAC_REG)
538 /* Strict versions. */
539 #define REG_OK_FOR_INDEX_STRICT_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
540 #define REG_OK_FOR_BASE_STRICT_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
542 #ifndef REG_OK_STRICT
544 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_NONSTRICT_P (X)
545 #define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_NONSTRICT_P (X)
547 #else
549 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_STRICT_P (X)
550 #define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_STRICT_P (X)
552 #endif
555 /* Specify the machine mode that this machine uses
556 for the index in the tablejump instruction. */
557 #define CASE_VECTOR_MODE Pmode
559 /* Define this as 1 if `char' should by default be signed; else as 0.
561 On the H8/300, sign extension is expensive, so we'll say that chars
562 are unsigned. */
563 #define DEFAULT_SIGNED_CHAR 0
565 /* Max number of bytes we can move from memory to memory
566 in one reasonably fast instruction. */
567 #define MOVE_MAX (TARGET_H8300H || TARGET_H8300S ? 4 : 2)
568 #define MAX_MOVE_MAX 4
570 /* Nonzero if access to memory by bytes is slow and undesirable. */
571 #define SLOW_BYTE_ACCESS TARGET_SLOWBYTE
573 /* Define if shifts truncate the shift count
574 which implies one can omit a sign-extension or zero-extension
575 of a shift count. */
576 /* #define SHIFT_COUNT_TRUNCATED */
578 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
579 is done just by pretending it is already truncated. */
580 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
582 /* Specify the machine mode that pointers have.
583 After generation of rtl, the compiler makes no further distinction
584 between pointers and any other objects of this machine mode. */
585 #define Pmode \
586 ((TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE ? SImode : HImode)
588 /* ANSI C types.
589 We use longs for the H8/300H and the H8S because ints can be 16 or 32.
590 GCC requires SIZE_TYPE to be the same size as pointers. */
591 #define SIZE_TYPE \
592 (TARGET_H8300 || TARGET_NORMAL_MODE ? TARGET_INT32 ? "short unsigned int" : "unsigned int" : "long unsigned int")
593 #define PTRDIFF_TYPE \
594 (TARGET_H8300 || TARGET_NORMAL_MODE ? TARGET_INT32 ? "short int" : "int" : "long int")
596 #define POINTER_SIZE \
597 ((TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE ? 32 : 16)
599 #define WCHAR_TYPE "short unsigned int"
600 #define WCHAR_TYPE_SIZE 16
602 /* A function address in a call instruction
603 is a byte address (for indexing purposes)
604 so give the MEM rtx a byte's mode. */
605 #define FUNCTION_MODE QImode
607 /* Return the length of JUMP's delay slot insn (0 if it has none).
608 If JUMP is a delayed branch, NEXT_INSN (PREV_INSN (JUMP)) will
609 be the containing SEQUENCE, not JUMP itself. */
610 #define DELAY_SLOT_LENGTH(JUMP) \
611 (NEXT_INSN (PREV_INSN (JUMP)) == JUMP ? 0 : 2)
613 #define BRANCH_COST(speed_p, predictable_p) 0
615 /* Tell final.c how to eliminate redundant test instructions. */
617 /* Here we define machine-dependent flags and fields in cc_status
618 (see `conditions.h'). No extra ones are needed for the h8300. */
620 /* Store in cc_status the expressions
621 that the condition codes will describe
622 after execution of an instruction whose pattern is EXP.
623 Do not alter them if the instruction would not alter the cc's. */
625 #define NOTICE_UPDATE_CC(EXP, INSN) notice_update_cc (EXP, INSN)
627 /* The add insns don't set overflow in a usable way. */
628 #define CC_OVERFLOW_UNUSABLE 01000
629 /* The mov,and,or,xor insns don't set carry. That's OK though as the
630 Z bit is all we need when doing unsigned comparisons on the result of
631 these insns (since they're always with 0). However, conditions.h has
632 CC_NO_OVERFLOW defined for this purpose. Rename it to something more
633 understandable. */
634 #define CC_NO_CARRY CC_NO_OVERFLOW
636 /* Control the assembler format that we output. */
638 /* Output to assembler file text saying following lines
639 may contain character constants, extra white space, comments, etc. */
641 #define ASM_APP_ON "; #APP\n"
643 /* Output to assembler file text saying following lines
644 no longer contain unusual constructs. */
646 #define ASM_APP_OFF "; #NO_APP\n"
648 #define FILE_ASM_OP "\t.file\n"
650 /* The assembler op to get a word, 2 bytes for the H8/300, 4 for H8/300H. */
651 #define ASM_WORD_OP \
652 (TARGET_H8300 || TARGET_NORMAL_MODE ? "\t.word\t" : "\t.long\t")
654 #define TEXT_SECTION_ASM_OP "\t.section .text"
655 #define DATA_SECTION_ASM_OP "\t.section .data"
656 #define BSS_SECTION_ASM_OP "\t.section .bss"
658 #undef DO_GLOBAL_CTORS_BODY
659 #define DO_GLOBAL_CTORS_BODY \
661 extern func_ptr __ctors[]; \
662 extern func_ptr __ctors_end[]; \
663 func_ptr *p; \
664 for (p = __ctors_end; p > __ctors; ) \
666 (*--p)(); \
670 #undef DO_GLOBAL_DTORS_BODY
671 #define DO_GLOBAL_DTORS_BODY \
673 extern func_ptr __dtors[]; \
674 extern func_ptr __dtors_end[]; \
675 func_ptr *p; \
676 for (p = __dtors; p < __dtors_end; p++) \
678 (*p)(); \
682 /* How to refer to registers in assembler output.
683 This sequence is indexed by compiler's hard-register-number (see above). */
685 #define REGISTER_NAMES \
686 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "sp", "mac", "ap", "rap", "fp" }
688 #define ADDITIONAL_REGISTER_NAMES \
689 { {"er0", 0}, {"er1", 1}, {"er2", 2}, {"er3", 3}, {"er4", 4}, \
690 {"er5", 5}, {"er6", 6}, {"er7", 7}, {"r7", 7} }
692 /* Globalizing directive for a label. */
693 #define GLOBAL_ASM_OP "\t.global "
695 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
696 ASM_OUTPUT_LABEL (FILE, NAME)
698 /* The prefix to add to user-visible assembler symbols. */
700 #define USER_LABEL_PREFIX "_"
702 /* This is how to store into the string LABEL
703 the symbol_ref name of an internal numbered label where
704 PREFIX is the class of label and NUM is the number within the class.
705 This is suitable for output with `assemble_name'.
707 N.B.: The h8300.md branch_true and branch_false patterns also know
708 how to generate internal labels. */
709 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
710 sprintf (LABEL, "*.%s%lu", PREFIX, (unsigned long)(NUM))
712 /* This is how to output an insn to push a register on the stack.
713 It need not be very fast code. */
715 #define ASM_OUTPUT_REG_PUSH(FILE, REGNO) \
716 fprintf (FILE, "\t%s\t%s\n", h8_push_op, h8_reg_names[REGNO])
718 /* This is how to output an insn to pop a register from the stack.
719 It need not be very fast code. */
721 #define ASM_OUTPUT_REG_POP(FILE, REGNO) \
722 fprintf (FILE, "\t%s\t%s\n", h8_pop_op, h8_reg_names[REGNO])
724 /* This is how to output an element of a case-vector that is absolute. */
726 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
727 fprintf (FILE, "%s.L%d\n", ASM_WORD_OP, VALUE)
729 /* This is how to output an element of a case-vector that is relative. */
731 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
732 fprintf (FILE, "%s.L%d-.L%d\n", ASM_WORD_OP, VALUE, REL)
734 /* This is how to output an assembler line
735 that says to advance the location counter
736 to a multiple of 2**LOG bytes. */
738 #define ASM_OUTPUT_ALIGN(FILE, LOG) \
739 if ((LOG) != 0) \
740 fprintf (FILE, "\t.align %d\n", (LOG))
742 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
743 fprintf (FILE, "\t.space %d\n", (int)(SIZE))
745 /* This says how to output an assembler line
746 to define a global common symbol. */
748 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
749 ( fputs ("\t.comm ", (FILE)), \
750 assemble_name ((FILE), (NAME)), \
751 fprintf ((FILE), ",%lu\n", (unsigned long)(SIZE)))
753 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
754 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
756 /* This says how to output an assembler line
757 to define a local common symbol. */
759 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
760 ( fputs ("\t.lcomm ", (FILE)), \
761 assemble_name ((FILE), (NAME)), \
762 fprintf ((FILE), ",%d\n", (int)(SIZE)))
764 #define ASM_PN_FORMAT "%s___%lu"
766 /* H8300 specific pragmas. */
767 #define REGISTER_TARGET_PRAGMAS() \
768 do \
770 c_register_pragma (0, "saveall", h8300_pr_saveall); \
771 c_register_pragma (0, "interrupt", h8300_pr_interrupt); \
773 while (0)
775 #define FINAL_PRESCAN_INSN(insn, operand, nop) \
776 final_prescan_insn (insn, operand, nop)
778 extern int h8300_move_ratio;
779 #define MOVE_RATIO(speed) h8300_move_ratio
781 /* Machine-specific symbol_ref flags. */
782 #define SYMBOL_FLAG_FUNCVEC_FUNCTION (SYMBOL_FLAG_MACH_DEP << 0)
783 #define SYMBOL_FLAG_EIGHTBIT_DATA (SYMBOL_FLAG_MACH_DEP << 1)
784 #define SYMBOL_FLAG_TINY_DATA (SYMBOL_FLAG_MACH_DEP << 2)
786 #endif /* ! GCC_H8300_H */