| 1 |
/* Definitions of target machine for GNU compiler. |
| 2 |
Renesas H8/300 (generic) |
| 3 |
Copyright (C) 1992-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Steve Chamberlain ([email protected]), |
| 5 |
Jim Wilson ([email protected]), and Doug Evans ([email protected]). |
| 6 |
|
| 7 |
This file is part of GCC. |
| 8 |
|
| 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. |
| 13 |
|
| 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. |
| 18 |
|
| 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/>. */ |
| 22 |
|
| 23 |
#ifndef GCC_H8300_H |
| 24 |
#define GCC_H8300_H |
| 25 |
|
| 26 |
extern int cpu_type; |
| 27 |
|
| 28 |
/* Various globals defined in h8300.cc. */ |
| 29 |
|
| 30 |
extern const char *h8_push_op, *h8_pop_op, *h8_mov_op; |
| 31 |
extern const char * const *h8_reg_names; |
| 32 |
|
| 33 |
/* Target CPU builtins. */ |
| 34 |
#define TARGET_CPU_CPP_BUILTINS() \ |
| 35 |
do \ |
| 36 |
{ \ |
| 37 |
if (TARGET_H8300SX) \ |
| 38 |
{ \ |
| 39 |
builtin_define ("__H8300SX__"); \ |
| 40 |
if (TARGET_NORMAL_MODE) \ |
| 41 |
{ \ |
| 42 |
builtin_define ("__NORMAL_MODE__"); \ |
| 43 |
} \ |
| 44 |
} \ |
| 45 |
else if (TARGET_H8300S) \ |
| 46 |
{ \ |
| 47 |
builtin_define ("__H8300S__"); \ |
| 48 |
builtin_assert ("cpu=h8300s"); \ |
| 49 |
builtin_assert ("machine=h8300s"); \ |
| 50 |
if (TARGET_NORMAL_MODE) \ |
| 51 |
{ \ |
| 52 |
builtin_define ("__NORMAL_MODE__"); \ |
| 53 |
} \ |
| 54 |
} \ |
| 55 |
else \ |
| 56 |
{ \ |
| 57 |
builtin_define ("__H8300H__"); \ |
| 58 |
builtin_assert ("cpu=h8300h"); \ |
| 59 |
builtin_assert ("machine=h8300h"); \ |
| 60 |
if (TARGET_NORMAL_MODE) \ |
| 61 |
{ \ |
| 62 |
builtin_define ("__NORMAL_MODE__"); \ |
| 63 |
} \ |
| 64 |
} \ |
| 65 |
} \ |
| 66 |
while (0) |
| 67 |
|
| 68 |
#define LIB_SPEC "%{mrelax:-relax} %{g:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}" |
| 69 |
|
| 70 |
/* Macros used in the machine description to test the flags. */ |
| 71 |
|
| 72 |
/* Select between the H8/300 and H8/300H CPUs. */ |
| 73 |
#define TARGET_H8300S (TARGET_H8300S_1 || TARGET_H8300SX) |
| 74 |
/* Some multiply instructions are not available in all H8SX variants. |
| 75 |
Use this macro instead of TARGET_H8300SX to indicate this, even |
| 76 |
though we don't actually generate different code for now. */ |
| 77 |
#define TARGET_H8300SXMUL TARGET_H8300SX |
| 78 |
|
| 79 |
#ifdef IN_LIBGCC2 |
| 80 |
#undef TARGET_H8300H |
| 81 |
#undef TARGET_H8300S |
| 82 |
#undef TARGET_NORMAL_MODE |
| 83 |
/* If compiling libgcc2, make these compile time constants based on what |
| 84 |
flags are we actually compiling with. */ |
| 85 |
#ifdef __H8300H__ |
| 86 |
#define TARGET_H8300H 1 |
| 87 |
#else |
| 88 |
#define TARGET_H8300H 0 |
| 89 |
#endif |
| 90 |
#ifdef __H8300S__ |
| 91 |
#define TARGET_H8300S 1 |
| 92 |
#else |
| 93 |
#define TARGET_H8300S 0 |
| 94 |
#endif |
| 95 |
#ifdef __NORMAL_MODE__ |
| 96 |
#define TARGET_NORMAL_MODE 1 |
| 97 |
#else |
| 98 |
#define TARGET_NORMAL_MODE 0 |
| 99 |
#endif |
| 100 |
#endif /* !IN_LIBGCC2 */ |
| 101 |
|
| 102 |
/* Default target_flags if no switches specified. */ |
| 103 |
|
| 104 |
#ifndef TARGET_DEFAULT |
| 105 |
#define TARGET_DEFAULT (MASK_H8300H | MASK_QUICKCALL) |
| 106 |
#endif |
| 107 |
|
| 108 |
/* We want dwarf2 info available to gdb. */ |
| 109 |
#define DWARF2_DEBUGGING_INFO 1 |
| 110 |
|
| 111 |
/* The return address is pushed on the stack. */ |
| 112 |
#define INCOMING_RETURN_ADDR_RTX gen_rtx_MEM (Pmode, gen_rtx_REG (Pmode, STACK_POINTER_REGNUM)) |
| 113 |
#define INCOMING_FRAME_SP_OFFSET (POINTER_SIZE / 8) |
| 114 |
|
| 115 |
#define DWARF_CIE_DATA_ALIGNMENT 2 |
| 116 |
|
| 117 |
/* Define this if addresses of constant functions |
| 118 |
shouldn't be put through pseudo regs where they can be cse'd. |
| 119 |
Desirable on machines where ordinary constants are expensive |
| 120 |
but a CALL with constant address is cheap. |
| 121 |
|
| 122 |
Calls through a register are cheaper than calls to named |
| 123 |
functions; however, the register pressure this causes makes |
| 124 |
CSEing of function addresses generally a lose. */ |
| 125 |
#define NO_FUNCTION_CSE 1 |
| 126 |
|
| 127 |
/* Target machine storage layout */ |
| 128 |
|
| 129 |
/* Define this if most significant bit is lowest numbered |
| 130 |
in instructions that operate on numbered bit-fields. |
| 131 |
This is not true on the H8/300. */ |
| 132 |
#define BITS_BIG_ENDIAN 0 |
| 133 |
|
| 134 |
/* Define this if most significant byte of a word is the lowest numbered. */ |
| 135 |
/* That is true on the H8/300. */ |
| 136 |
#define BYTES_BIG_ENDIAN 1 |
| 137 |
|
| 138 |
/* Define this if most significant word of a multiword number is lowest |
| 139 |
numbered. */ |
| 140 |
#define WORDS_BIG_ENDIAN 1 |
| 141 |
|
| 142 |
#define MAX_BITS_PER_WORD 32 |
| 143 |
|
| 144 |
/* Width of a word, in units (bytes). */ |
| 145 |
#define UNITS_PER_WORD 4 |
| 146 |
#define MIN_UNITS_PER_WORD 2 |
| 147 |
|
| 148 |
#define SHORT_TYPE_SIZE 16 |
| 149 |
#define INT_TYPE_SIZE (TARGET_INT32 ? 32 : 16) |
| 150 |
#define LONG_TYPE_SIZE 32 |
| 151 |
#define LONG_LONG_TYPE_SIZE 64 |
| 152 |
#define DOUBLE_TYPE_MODE SFmode |
| 153 |
|
| 154 |
#define MAX_FIXED_MODE_SIZE 32 |
| 155 |
|
| 156 |
/* Allocation boundary (in *bits*) for storing arguments in argument list. */ |
| 157 |
#define PARM_BOUNDARY 32 |
| 158 |
|
| 159 |
/* Allocation boundary (in *bits*) for the code of a function. */ |
| 160 |
#define FUNCTION_BOUNDARY 16 |
| 161 |
|
| 162 |
/* Alignment of field after `int : 0' in a structure. */ |
| 163 |
/* One can argue this should be 32 for -mint32, but since 32-bit ints only |
| 164 |
need 16-bit alignment, this is left as is so that -mint32 doesn't change |
| 165 |
structure layouts. */ |
| 166 |
#define EMPTY_FIELD_BOUNDARY 16 |
| 167 |
|
| 168 |
/* No data type wants to be aligned rounder than this. |
| 169 |
32-bit values are aligned as such on the H8/300H and H8S for speed. */ |
| 170 |
#define BIGGEST_ALIGNMENT \ |
| 171 |
((! TARGET_ALIGN_300) ? 32 : 16) |
| 172 |
|
| 173 |
/* The stack goes in 32 bit lumps. */ |
| 174 |
#define STACK_BOUNDARY 32 |
| 175 |
|
| 176 |
/* Define this if move instructions will actually fail to work |
| 177 |
when given unaligned data. */ |
| 178 |
/* On the H8/300, longs can be aligned on halfword boundaries, but not |
| 179 |
byte boundaries. */ |
| 180 |
#define STRICT_ALIGNMENT 1 |
| 181 |
|
| 182 |
/* Standard register usage. */ |
| 183 |
|
| 184 |
/* Number of actual hardware registers. |
| 185 |
The hardware registers are assigned numbers for the compiler |
| 186 |
from 0 to just below FIRST_PSEUDO_REGISTER. |
| 187 |
|
| 188 |
All registers that the compiler knows about must be given numbers, |
| 189 |
even those that are not normally considered general registers. |
| 190 |
|
| 191 |
Reg 9 does not correspond to any hardware register, but instead |
| 192 |
appears in the RTL as an argument pointer prior to reload, and is |
| 193 |
eliminated during reloading in favor of either the stack or frame |
| 194 |
pointer. */ |
| 195 |
|
| 196 |
#define FIRST_PSEUDO_REGISTER 13 |
| 197 |
|
| 198 |
/* 1 for registers that have pervasive standard uses |
| 199 |
and are not available for the register allocator. */ |
| 200 |
|
| 201 |
#define FIXED_REGISTERS \ |
| 202 |
/* r0 r1 r2 r3 r4 r5 r6 r7 mac ap rap fp cc */ \ |
| 203 |
{ 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1 } |
| 204 |
|
| 205 |
/* 1 for registers not available across function calls. |
| 206 |
These must include the FIXED_REGISTERS and also any |
| 207 |
registers that can be used without being saved. |
| 208 |
The latter must include the registers where values are returned |
| 209 |
and the register where structure-value addresses are passed. |
| 210 |
Aside from that, you can include as many other registers as you |
| 211 |
like. |
| 212 |
|
| 213 |
H8 destroys r0,r1,r2,r3. */ |
| 214 |
|
| 215 |
#define CALL_USED_REGISTERS \ |
| 216 |
/* r0 r1 r2 r3 r4 r5 r6 r7 mac ap rap fp */ \ |
| 217 |
{ 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 } |
| 218 |
|
| 219 |
#define REG_ALLOC_ORDER \ |
| 220 |
/* r0 r1 r2 r3 r4 r5 r6 r7 mac ap rap fp */ \ |
| 221 |
{ 2, 3, 0, 1, 4, 5, 6, 8, 7, 9, 10, 11, 12 } |
| 222 |
|
| 223 |
/* A C expression that is nonzero if hard register NEW_REG can be |
| 224 |
considered for use as a rename register for OLD_REG register */ |
| 225 |
|
| 226 |
#define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \ |
| 227 |
h8300_hard_regno_rename_ok (OLD_REG, NEW_REG) |
| 228 |
|
| 229 |
/* Specify the registers used for certain standard purposes. |
| 230 |
The values of these macros are register numbers. */ |
| 231 |
|
| 232 |
/* H8/300 pc is not overloaded on a register. */ |
| 233 |
|
| 234 |
/*#define PC_REGNUM 15*/ |
| 235 |
|
| 236 |
/* Register to use for pushing function arguments. */ |
| 237 |
#define STACK_POINTER_REGNUM SP_REG |
| 238 |
|
| 239 |
/* Base register for access to local variables of the function. */ |
| 240 |
#define HARD_FRAME_POINTER_REGNUM HFP_REG |
| 241 |
|
| 242 |
/* Base register for access to local variables of the function. */ |
| 243 |
#define FRAME_POINTER_REGNUM FP_REG |
| 244 |
|
| 245 |
/* Base register for access to arguments of the function. */ |
| 246 |
#define ARG_POINTER_REGNUM AP_REG |
| 247 |
|
| 248 |
/* Register in which static-chain is passed to a function. */ |
| 249 |
#define STATIC_CHAIN_REGNUM SC_REG |
| 250 |
|
| 251 |
/* Fake register that holds the address on the stack of the |
| 252 |
current function's return address. */ |
| 253 |
#define RETURN_ADDRESS_POINTER_REGNUM RAP_REG |
| 254 |
|
| 255 |
/* A C expression whose value is RTL representing the value of the return |
| 256 |
address for the frame COUNT steps up from the current frame. |
| 257 |
FRAMEADDR is already the frame pointer of the COUNT frame, assuming |
| 258 |
a stack layout with the frame pointer as the first saved register. */ |
| 259 |
#define RETURN_ADDR_RTX(COUNT, FRAME) h8300_return_addr_rtx ((COUNT), (FRAME)) |
| 260 |
|
| 261 |
/* Define the classes of registers for register constraints in the |
| 262 |
machine description. Also define ranges of constants. |
| 263 |
|
| 264 |
One of the classes must always be named ALL_REGS and include all hard regs. |
| 265 |
If there is more than one class, another class must be named NO_REGS |
| 266 |
and contain no registers. |
| 267 |
|
| 268 |
The name GENERAL_REGS must be the name of a class (or an alias for |
| 269 |
another name such as ALL_REGS). This is the class of registers |
| 270 |
that is allowed by "g" or "r" in a register constraint. |
| 271 |
Also, registers outside this class are allocated only when |
| 272 |
instructions express preferences for them. |
| 273 |
|
| 274 |
The classes must be numbered in nondecreasing order; that is, |
| 275 |
a larger-numbered class must never be contained completely |
| 276 |
in a smaller-numbered class. |
| 277 |
|
| 278 |
For any two classes, it is very desirable that there be another |
| 279 |
class that represents their union. */ |
| 280 |
|
| 281 |
enum reg_class { |
| 282 |
NO_REGS, COUNTER_REGS, SOURCE_REGS, DESTINATION_REGS, |
| 283 |
NOT_R0_REGS, NOT_R1_REGS, NOT_R2_REGS, NOT_R3_REGS, |
| 284 |
NOT_R4_REGS, NOT_R5_REGS, NOT_R6_REGS, NOT_SP_REGS, |
| 285 |
GENERAL_REGS, MAC_REGS, ALL_REGS, LIM_REG_CLASSES |
| 286 |
}; |
| 287 |
|
| 288 |
#define N_REG_CLASSES ((int) LIM_REG_CLASSES) |
| 289 |
|
| 290 |
/* Give names of register classes as strings for dump file. */ |
| 291 |
|
| 292 |
#define REG_CLASS_NAMES \ |
| 293 |
{ "NO_REGS", "COUNTER_REGS", "SOURCE_REGS", "DESTINATION_REGS", \ |
| 294 |
"NOT_R0_REGS", "NOT_R1_REGS", "NOT_R2_REGS", "NOT_R3_REGS", \ |
| 295 |
"NOT_R4_REGS", "NOT_R5_REGS", "NOT_R6_REGS", "NOT_SP_REGS", \ |
| 296 |
"GENERAL_REGS", "MAC_REGS", "ALL_REGS", "LIM_REGS" } |
| 297 |
|
| 298 |
/* Define which registers fit in which classes. |
| 299 |
This is an initializer for a vector of HARD_REG_SET |
| 300 |
of length N_REG_CLASSES. */ |
| 301 |
|
| 302 |
#define REG_CLASS_CONTENTS \ |
| 303 |
{ {0}, /* No regs */ \ |
| 304 |
{0x010}, /* COUNTER_REGS */ \ |
| 305 |
{0x020}, /* SOURCE_REGS */ \ |
| 306 |
{0x040}, /* DESTINATION_REGS */ \ |
| 307 |
{0x0fe}, /* NOT_R0_REGS */ \ |
| 308 |
{0x0fd}, /* NOT_R1_REGS */ \ |
| 309 |
{0x0fb}, /* NOT_R2_REGS */ \ |
| 310 |
{0x0f7}, /* NOT_R3_REGS */ \ |
| 311 |
{0x0ef}, /* NOT_R4_REGS */ \ |
| 312 |
{0x0df}, /* NOT_R5_REGS */ \ |
| 313 |
{0x0bf}, /* NOT_R6_REGS */ \ |
| 314 |
{0x07f}, /* NOT_SP_REGS */ \ |
| 315 |
{0xeff}, /* GENERAL_REGS */ \ |
| 316 |
{0x100}, /* MAC_REGS */ \ |
| 317 |
{0xfff}, /* ALL_REGS */ \ |
| 318 |
} |
| 319 |
|
| 320 |
/* The same information, inverted: |
| 321 |
Return the class number of the smallest class containing |
| 322 |
reg number REGNO. This could be a conditional expression |
| 323 |
or could index an array. */ |
| 324 |
|
| 325 |
#define REGNO_REG_CLASS(REGNO) \ |
| 326 |
((REGNO) == MAC_REG ? MAC_REGS \ |
| 327 |
: (REGNO) == COUNTER_REG ? COUNTER_REGS \ |
| 328 |
: (REGNO) == SOURCE_REG ? SOURCE_REGS \ |
| 329 |
: (REGNO) == DESTINATION_REG ? DESTINATION_REGS \ |
| 330 |
: GENERAL_REGS) |
| 331 |
|
| 332 |
/* The class value for index registers, and the one for base regs. */ |
| 333 |
|
| 334 |
#define INDEX_REG_CLASS (TARGET_H8300SX ? GENERAL_REGS : NO_REGS) |
| 335 |
#define BASE_REG_CLASS GENERAL_REGS |
| 336 |
|
| 337 |
/* Stack layout; function entry, exit and calling. */ |
| 338 |
|
| 339 |
/* Define this if pushing a word on the stack |
| 340 |
makes the stack pointer a smaller address. */ |
| 341 |
|
| 342 |
#define STACK_GROWS_DOWNWARD 1 |
| 343 |
|
| 344 |
/* Define this to nonzero if the nominal address of the stack frame |
| 345 |
is at the high-address end of the local variables; |
| 346 |
that is, each additional local variable allocated |
| 347 |
goes at a more negative offset in the frame. */ |
| 348 |
|
| 349 |
#define FRAME_GROWS_DOWNWARD 1 |
| 350 |
|
| 351 |
#define PUSH_ROUNDING(BYTES) h8300_push_rounding (BYTES) |
| 352 |
|
| 353 |
/* Offset of first parameter from the argument pointer register value. */ |
| 354 |
/* Is equal to the size of the saved fp + pc, even if an fp isn't |
| 355 |
saved since the value is used before we know. */ |
| 356 |
|
| 357 |
#define FIRST_PARM_OFFSET(FNDECL) 0 |
| 358 |
|
| 359 |
/* Definitions for register eliminations. |
| 360 |
|
| 361 |
This is an array of structures. Each structure initializes one pair |
| 362 |
of eliminable registers. The "from" register number is given first, |
| 363 |
followed by "to". Eliminations of the same "from" register are listed |
| 364 |
in order of preference. |
| 365 |
|
| 366 |
We have three registers that can be eliminated on the h8300. |
| 367 |
First, the frame pointer register can often be eliminated in favor |
| 368 |
of the stack pointer register. Secondly, the argument pointer |
| 369 |
register and the return address pointer register are always |
| 370 |
eliminated; they are replaced with either the stack or frame |
| 371 |
pointer. */ |
| 372 |
|
| 373 |
#define ELIMINABLE_REGS \ |
| 374 |
{{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ |
| 375 |
{ ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \ |
| 376 |
{ RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ |
| 377 |
{ RETURN_ADDRESS_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \ |
| 378 |
{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ |
| 379 |
{ FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}} |
| 380 |
|
| 381 |
/* Define the offset between two registers, one to be eliminated, and the other |
| 382 |
its replacement, at the start of a routine. */ |
| 383 |
|
| 384 |
#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ |
| 385 |
((OFFSET) = h8300_initial_elimination_offset ((FROM), (TO))) |
| 386 |
|
| 387 |
/* Define this if PCC uses the nonreentrant convention for returning |
| 388 |
structure and union values. */ |
| 389 |
|
| 390 |
/*#define PCC_STATIC_STRUCT_RETURN*/ |
| 391 |
|
| 392 |
/* 1 if N is a possible register number for function argument passing. |
| 393 |
On the H8, no registers are used in this way. */ |
| 394 |
|
| 395 |
#define FUNCTION_ARG_REGNO_P(N) (TARGET_QUICKCALL ? N < 3 : 0) |
| 396 |
|
| 397 |
/* When this hook returns true for MODE, the compiler allows |
| 398 |
registers explicitly used in the rtl to be used as spill registers |
| 399 |
but prevents the compiler from extending the lifetime of these |
| 400 |
registers. */ |
| 401 |
#define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true |
| 402 |
|
| 403 |
/* Define a data type for recording info about an argument list |
| 404 |
during the scan of that argument list. This data type should |
| 405 |
hold all necessary information about the function itself |
| 406 |
and about the args processed so far, enough to enable macros |
| 407 |
such as FUNCTION_ARG to determine where the next arg should go. |
| 408 |
|
| 409 |
On the H8/300, this is a two item struct, the first is the number |
| 410 |
of bytes scanned so far and the second is the rtx of the called |
| 411 |
library function if any. */ |
| 412 |
|
| 413 |
#define CUMULATIVE_ARGS struct cum_arg |
| 414 |
struct cum_arg |
| 415 |
{ |
| 416 |
int nbytes; |
| 417 |
rtx libcall; |
| 418 |
}; |
| 419 |
|
| 420 |
/* Initialize a variable CUM of type CUMULATIVE_ARGS |
| 421 |
for a call to a function whose data type is FNTYPE. |
| 422 |
For a library call, FNTYPE is 0. |
| 423 |
|
| 424 |
On the H8/300, the offset starts at 0. */ |
| 425 |
|
| 426 |
#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \ |
| 427 |
((CUM).nbytes = 0, (CUM).libcall = LIBNAME) |
| 428 |
|
| 429 |
/* Output assembler code to FILE to increment profiler label # LABELNO |
| 430 |
for profiling a function entry. */ |
| 431 |
|
| 432 |
#define FUNCTION_PROFILER(FILE, LABELNO) \ |
| 433 |
fprintf (FILE, "\t%s\t#.LP%d,%s\n\tjsr @mcount\n", \ |
| 434 |
h8_mov_op, (LABELNO), h8_reg_names[0]); |
| 435 |
|
| 436 |
/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, |
| 437 |
the stack pointer does not matter. The value is tested only in |
| 438 |
functions that have frame pointers. |
| 439 |
No definition is equivalent to always zero. */ |
| 440 |
|
| 441 |
#define EXIT_IGNORE_STACK 0 |
| 442 |
|
| 443 |
/* Length in units of the trampoline for entering a nested function. */ |
| 444 |
|
| 445 |
#define TRAMPOLINE_SIZE ((Pmode == HImode) ? 8 : 12) |
| 446 |
|
| 447 |
/* Addressing modes, and classification of registers for them. */ |
| 448 |
|
| 449 |
#define HAVE_POST_INCREMENT 1 |
| 450 |
#define HAVE_PRE_DECREMENT 1 |
| 451 |
#define HAVE_POST_DECREMENT TARGET_H8300SX |
| 452 |
#define HAVE_PRE_INCREMENT TARGET_H8300SX |
| 453 |
|
| 454 |
/* Macros to check register numbers against specific register classes. */ |
| 455 |
|
| 456 |
/* These assume that REGNO is a hard or pseudo reg number. |
| 457 |
They give nonzero only if REGNO is a hard reg of the suitable class |
| 458 |
or a pseudo reg currently allocated to a suitable hard reg. |
| 459 |
Since they use reg_renumber, they are safe only once reg_renumber |
| 460 |
has been allocated, which happens in reginfo.cc during register |
| 461 |
allocation. */ |
| 462 |
|
| 463 |
#define REGNO_OK_FOR_INDEX_P(regno) 0 |
| 464 |
|
| 465 |
#define REGNO_OK_FOR_BASE_P(regno) \ |
| 466 |
(((regno) < FIRST_PSEUDO_REGISTER && regno != MAC_REG) \ |
| 467 |
|| reg_renumber[regno] >= 0) |
| 468 |
|
| 469 |
/* Maximum number of registers that can appear in a valid memory address. */ |
| 470 |
|
| 471 |
#define MAX_REGS_PER_ADDRESS 1 |
| 472 |
|
| 473 |
/* 1 if X is an rtx for a constant that is a valid address. */ |
| 474 |
|
| 475 |
#define CONSTANT_ADDRESS_P(X) \ |
| 476 |
(GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \ |
| 477 |
|| (GET_CODE (X) == CONST_INT \ |
| 478 |
/* We handle signed and unsigned offsets here. */ \ |
| 479 |
&& INTVAL (X) > -0x1000000 \ |
| 480 |
&& INTVAL (X) < 0x1000000) \ |
| 481 |
|| (GET_CODE (X) == HIGH || GET_CODE (X) == CONST)) |
| 482 |
|
| 483 |
/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx |
| 484 |
and check its validity for a certain class. |
| 485 |
We have two alternate definitions for each of them. |
| 486 |
The usual definition accepts all pseudo regs; the other rejects |
| 487 |
them unless they have been allocated suitable hard regs. |
| 488 |
The symbol REG_OK_STRICT causes the latter definition to be used. |
| 489 |
|
| 490 |
Most source files want to accept pseudo regs in the hope that |
| 491 |
they will get allocated to the class that the insn wants them to be in. |
| 492 |
Source files for reload pass need to be strict. |
| 493 |
After reload, it makes no difference, since pseudo regs have |
| 494 |
been eliminated by then. */ |
| 495 |
|
| 496 |
/* Non-strict versions. */ |
| 497 |
#define REG_OK_FOR_INDEX_NONSTRICT_P(X) 0 |
| 498 |
/* Don't use REGNO_OK_FOR_BASE_P here because it uses reg_renumber. */ |
| 499 |
#define REG_OK_FOR_BASE_NONSTRICT_P(X) \ |
| 500 |
(REGNO (X) >= FIRST_PSEUDO_REGISTER || REGNO (X) != MAC_REG) |
| 501 |
|
| 502 |
/* Strict versions. */ |
| 503 |
#define REG_OK_FOR_INDEX_STRICT_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X)) |
| 504 |
#define REG_OK_FOR_BASE_STRICT_P(X) REGNO_OK_FOR_BASE_P (REGNO (X)) |
| 505 |
|
| 506 |
#ifndef REG_OK_STRICT |
| 507 |
|
| 508 |
#define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_NONSTRICT_P (X) |
| 509 |
#define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_NONSTRICT_P (X) |
| 510 |
|
| 511 |
#else |
| 512 |
|
| 513 |
#define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_STRICT_P (X) |
| 514 |
#define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_STRICT_P (X) |
| 515 |
|
| 516 |
#endif |
| 517 |
|
| 518 |
|
| 519 |
/* Specify the machine mode that this machine uses |
| 520 |
for the index in the tablejump instruction. */ |
| 521 |
#define CASE_VECTOR_MODE Pmode |
| 522 |
|
| 523 |
/* Define this as 1 if `char' should by default be signed; else as 0. |
| 524 |
|
| 525 |
On the H8/300, sign extension is expensive, so we'll say that chars |
| 526 |
are unsigned. */ |
| 527 |
#define DEFAULT_SIGNED_CHAR 0 |
| 528 |
|
| 529 |
/* Max number of bytes we can move from memory to memory |
| 530 |
in one reasonably fast instruction. */ |
| 531 |
#define MOVE_MAX 4 |
| 532 |
#define MAX_MOVE_MAX 4 |
| 533 |
|
| 534 |
#define SELECT_CC_MODE(OP, X, Y) h8300_select_cc_mode (OP, X, Y) |
| 535 |
|
| 536 |
/* Nonzero if access to memory by bytes is slow and undesirable. */ |
| 537 |
#define SLOW_BYTE_ACCESS TARGET_SLOWBYTE |
| 538 |
|
| 539 |
/* Define if shifts truncate the shift count |
| 540 |
which implies one can omit a sign-extension or zero-extension |
| 541 |
of a shift count. */ |
| 542 |
/* #define SHIFT_COUNT_TRUNCATED */ |
| 543 |
|
| 544 |
/* Specify the machine mode that pointers have. |
| 545 |
After generation of rtl, the compiler makes no further distinction |
| 546 |
between pointers and any other objects of this machine mode. */ |
| 547 |
#define Pmode \ |
| 548 |
(!TARGET_NORMAL_MODE ? SImode : HImode) |
| 549 |
|
| 550 |
/* ANSI C types. |
| 551 |
We use longs for the H8/300H and the H8S because ints can be 16 or 32. |
| 552 |
GCC requires SIZE_TYPE to be the same size as pointers. */ |
| 553 |
#define SIZE_TYPE \ |
| 554 |
(TARGET_NORMAL_MODE ? TARGET_INT32 ? "short unsigned int" : "unsigned int" : "long unsigned int") |
| 555 |
#define PTRDIFF_TYPE \ |
| 556 |
(TARGET_NORMAL_MODE ? TARGET_INT32 ? "short int" : "int" : "long int") |
| 557 |
|
| 558 |
#define POINTER_SIZE \ |
| 559 |
(!TARGET_NORMAL_MODE ? 32 : 16) |
| 560 |
|
| 561 |
#define WCHAR_TYPE "short unsigned int" |
| 562 |
#define WCHAR_TYPE_SIZE 16 |
| 563 |
|
| 564 |
/* A function address in a call instruction |
| 565 |
is a byte address (for indexing purposes) |
| 566 |
so give the MEM rtx a byte's mode. */ |
| 567 |
#define FUNCTION_MODE QImode |
| 568 |
|
| 569 |
/* Return the length of JUMP's delay slot insn (0 if it has none). |
| 570 |
If JUMP is a delayed branch, NEXT_INSN (PREV_INSN (JUMP)) will |
| 571 |
be the containing SEQUENCE, not JUMP itself. */ |
| 572 |
#define DELAY_SLOT_LENGTH(JUMP) \ |
| 573 |
(NEXT_INSN (PREV_INSN (JUMP)) == JUMP ? 0 : 2) |
| 574 |
|
| 575 |
#define BRANCH_COST(speed_p, predictable_p) 0 |
| 576 |
|
| 577 |
/* Tell final.cc how to eliminate redundant test instructions. */ |
| 578 |
|
| 579 |
/* Here we define machine-dependent flags and fields in cc_status |
| 580 |
(see `conditions.h'). No extra ones are needed for the h8300. */ |
| 581 |
|
| 582 |
/* The add insns don't set overflow in a usable way. */ |
| 583 |
#define CC_OVERFLOW_UNUSABLE 01000 |
| 584 |
/* The mov,and,or,xor insns don't set carry. That's OK though as the |
| 585 |
Z bit is all we need when doing unsigned comparisons on the result of |
| 586 |
these insns (since they're always with 0). However, conditions.h has |
| 587 |
CC_NO_OVERFLOW defined for this purpose. Rename it to something more |
| 588 |
understandable. */ |
| 589 |
#define CC_NO_CARRY CC_NO_OVERFLOW |
| 590 |
|
| 591 |
/* Control the assembler format that we output. */ |
| 592 |
|
| 593 |
/* Output to assembler file text saying following lines |
| 594 |
may contain character constants, extra white space, comments, etc. */ |
| 595 |
|
| 596 |
#define ASM_APP_ON "; #APP\n" |
| 597 |
|
| 598 |
/* Output to assembler file text saying following lines |
| 599 |
no longer contain unusual constructs. */ |
| 600 |
|
| 601 |
#define ASM_APP_OFF "; #NO_APP\n" |
| 602 |
|
| 603 |
#define FILE_ASM_OP "\t.file\n" |
| 604 |
|
| 605 |
/* The assembler op to get a word, 2 bytes for the H8/300, 4 for H8/300H. */ |
| 606 |
#define ASM_WORD_OP \ |
| 607 |
(TARGET_NORMAL_MODE ? "\t.word\t" : "\t.long\t") |
| 608 |
|
| 609 |
#define TEXT_SECTION_ASM_OP "\t.section .text" |
| 610 |
#define DATA_SECTION_ASM_OP "\t.section .data" |
| 611 |
#define BSS_SECTION_ASM_OP "\t.section .bss" |
| 612 |
|
| 613 |
#undef DO_GLOBAL_CTORS_BODY |
| 614 |
#define DO_GLOBAL_CTORS_BODY \ |
| 615 |
{ \ |
| 616 |
extern func_ptr __ctors[]; \ |
| 617 |
extern func_ptr __ctors_end[]; \ |
| 618 |
func_ptr *p; \ |
| 619 |
for (p = __ctors_end; p > __ctors; ) \ |
| 620 |
{ \ |
| 621 |
(*--p)(); \ |
| 622 |
} \ |
| 623 |
} |
| 624 |
|
| 625 |
#undef DO_GLOBAL_DTORS_BODY |
| 626 |
#define DO_GLOBAL_DTORS_BODY \ |
| 627 |
{ \ |
| 628 |
extern func_ptr __dtors[]; \ |
| 629 |
extern func_ptr __dtors_end[]; \ |
| 630 |
func_ptr *p; \ |
| 631 |
for (p = __dtors; p < __dtors_end; p++) \ |
| 632 |
{ \ |
| 633 |
(*p)(); \ |
| 634 |
} \ |
| 635 |
} |
| 636 |
|
| 637 |
/* How to refer to registers in assembler output. |
| 638 |
This sequence is indexed by compiler's hard-register-number (see above). */ |
| 639 |
|
| 640 |
#define REGISTER_NAMES \ |
| 641 |
{ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "sp", "mac", "ap", "rap", "fp", "cc" } |
| 642 |
|
| 643 |
#define ADDITIONAL_REGISTER_NAMES \ |
| 644 |
{ {"er0", 0}, {"er1", 1}, {"er2", 2}, {"er3", 3}, {"er4", 4}, \ |
| 645 |
{"er5", 5}, {"er6", 6}, {"er7", 7}, {"r7", 7} } |
| 646 |
|
| 647 |
/* Globalizing directive for a label. */ |
| 648 |
#define GLOBAL_ASM_OP "\t.global " |
| 649 |
|
| 650 |
#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ |
| 651 |
ASM_OUTPUT_FUNCTION_LABEL (FILE, NAME, DECL) |
| 652 |
|
| 653 |
/* This is how to store into the string LABEL |
| 654 |
the symbol_ref name of an internal numbered label where |
| 655 |
PREFIX is the class of label and NUM is the number within the class. |
| 656 |
This is suitable for output with `assemble_name'. |
| 657 |
|
| 658 |
N.B.: The h8300.md branch_true and branch_false patterns also know |
| 659 |
how to generate internal labels. */ |
| 660 |
#define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \ |
| 661 |
sprintf (LABEL, "*.%s%lu", PREFIX, (unsigned long)(NUM)) |
| 662 |
|
| 663 |
/* This is how to output an insn to push a register on the stack. |
| 664 |
It need not be very fast code. */ |
| 665 |
|
| 666 |
#define ASM_OUTPUT_REG_PUSH(FILE, REGNO) \ |
| 667 |
fprintf (FILE, "\t%s\t%s\n", h8_push_op, h8_reg_names[REGNO]) |
| 668 |
|
| 669 |
/* This is how to output an insn to pop a register from the stack. |
| 670 |
It need not be very fast code. */ |
| 671 |
|
| 672 |
#define ASM_OUTPUT_REG_POP(FILE, REGNO) \ |
| 673 |
fprintf (FILE, "\t%s\t%s\n", h8_pop_op, h8_reg_names[REGNO]) |
| 674 |
|
| 675 |
/* This is how to output an element of a case-vector that is absolute. */ |
| 676 |
|
| 677 |
#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ |
| 678 |
fprintf (FILE, "%s.L%d\n", ASM_WORD_OP, VALUE) |
| 679 |
|
| 680 |
/* This is how to output an element of a case-vector that is relative. */ |
| 681 |
|
| 682 |
#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \ |
| 683 |
fprintf (FILE, "%s.L%d-.L%d\n", ASM_WORD_OP, VALUE, REL) |
| 684 |
|
| 685 |
/* This is how to output an assembler line |
| 686 |
that says to advance the location counter |
| 687 |
to a multiple of 2**LOG bytes. */ |
| 688 |
|
| 689 |
#define ASM_OUTPUT_ALIGN(FILE, LOG) \ |
| 690 |
if ((LOG) != 0) \ |
| 691 |
fprintf (FILE, "\t.align %d\n", (LOG)) |
| 692 |
|
| 693 |
#define ASM_OUTPUT_SKIP(FILE, SIZE) \ |
| 694 |
fprintf (FILE, "\t.space %d\n", (int)(SIZE)) |
| 695 |
|
| 696 |
/* This says how to output an assembler line |
| 697 |
to define a global common symbol. */ |
| 698 |
|
| 699 |
#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \ |
| 700 |
( fputs ("\t.comm ", (FILE)), \ |
| 701 |
assemble_name ((FILE), (NAME)), \ |
| 702 |
fprintf ((FILE), ",%lu\n", (unsigned long)(SIZE))) |
| 703 |
|
| 704 |
#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ |
| 705 |
asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN) |
| 706 |
|
| 707 |
/* This says how to output an assembler line |
| 708 |
to define a local common symbol. */ |
| 709 |
|
| 710 |
#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ |
| 711 |
( fputs ("\t.lcomm ", (FILE)), \ |
| 712 |
assemble_name ((FILE), (NAME)), \ |
| 713 |
fprintf ((FILE), ",%d\n", (int)(SIZE))) |
| 714 |
|
| 715 |
#define ASM_PN_FORMAT "%s___%lu" |
| 716 |
|
| 717 |
/* H8300 specific pragmas. */ |
| 718 |
#define REGISTER_TARGET_PRAGMAS() \ |
| 719 |
do \ |
| 720 |
{ \ |
| 721 |
c_register_pragma (0, "saveall", h8300_pr_saveall); \ |
| 722 |
c_register_pragma (0, "interrupt", h8300_pr_interrupt); \ |
| 723 |
} \ |
| 724 |
while (0) |
| 725 |
|
| 726 |
#define FINAL_PRESCAN_INSN(insn, operand, nop) \ |
| 727 |
final_prescan_insn (insn, operand, nop) |
| 728 |
|
| 729 |
extern int h8300_move_ratio; |
| 730 |
#define MOVE_RATIO(speed) h8300_move_ratio |
| 731 |
|
| 732 |
/* Machine-specific symbol_ref flags. */ |
| 733 |
#define SYMBOL_FLAG_FUNCVEC_FUNCTION (SYMBOL_FLAG_MACH_DEP << 0) |
| 734 |
#define SYMBOL_FLAG_EIGHTBIT_DATA (SYMBOL_FLAG_MACH_DEP << 1) |
| 735 |
#define SYMBOL_FLAG_TINY_DATA (SYMBOL_FLAG_MACH_DEP << 2) |
| 736 |
|
| 737 |
#endif /* ! GCC_H8300_H */ |