* Makefile.in (cse.o): Depend on TARGET_H.
[official-gcc.git] / gcc / config / m68hc11 / m68hc11.h
blob8f3740cb27dac5c118c5abc9b6ce9014e3046cfc
1 /* Definitions of target machine for GNU compiler.
2 Motorola 68HC11 and 68HC12.
3 Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
4 Contributed by Stephane Carrez (stcarrez@nerim.fr)
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.
23 Note:
24 A first 68HC11 port was made by Otto Lind (otto@coactive.com)
25 on gcc 2.6.3. I have used it as a starting point for this port.
26 However, this new port is a complete re-write. Its internal
27 design is completely different. The generated code is not
28 compatible with the gcc 2.6.3 port.
30 The gcc 2.6.3 port is available at:
32 ftp.unina.it/pub/electronics/motorola/68hc11/gcc/gcc-6811-fsf.tar.gz
36 /*****************************************************************************
38 ** Controlling the Compilation Driver, `gcc'
40 *****************************************************************************/
42 #undef ENDFILE_SPEC
44 /* Compile and assemble for a 68hc11 unless there is a -m68hc12 option. */
45 #ifndef ASM_SPEC
46 #define ASM_SPEC \
47 "%{m68hc12:-m68hc12}" \
48 "%{m68hcs12:-m68hcs12}" \
49 "%{!m68hc12:%{!m68hcs12:-m68hc11}} " \
50 "%{mshort:-mshort}%{!mshort:-mlong} " \
51 "%{fshort-double:-mshort-double}%{!fshort-double:-mlong-double}"
52 #endif
54 /* We need to tell the linker the target elf format. Just pass an
55 emulation option. This can be overridden by -Wl option of gcc. */
56 #ifndef LINK_SPEC
57 #define LINK_SPEC \
58 "%{m68hc12:-m m68hc12elf}" \
59 "%{m68hcs12:-m m68hc12elf}" \
60 "%{!m68hc12:%{!m68hcs12:-m m68hc11elf}} " \
61 "%{!mnorelax:%{!m68hc12:%{!m68hcs12:-relax}}}"
62 #endif
64 #ifndef LIB_SPEC
65 #define LIB_SPEC ""
66 #endif
68 #ifndef CC1_SPEC
69 #define CC1_SPEC ""
70 #endif
72 #ifndef CPP_SPEC
73 #define CPP_SPEC \
74 "%{mshort:-D__HAVE_SHORT_INT__ -D__INT__=16}\
75 %{!mshort:-D__INT__=32}\
76 %{m68hc12:-Dmc6812 -DMC6812 -Dmc68hc12}\
77 %{m68hcs12:-Dmc6812 -DMC6812 -Dmc68hcs12}\
78 %{!m68hc12:%{!m68hcs12:-Dmc6811 -DMC6811 -Dmc68hc11}}\
79 %{fshort-double:-D__HAVE_SHORT_DOUBLE__}\
80 %{mlong-calls:-D__USE_RTC__}"
81 #endif
83 #undef STARTFILE_SPEC
84 #define STARTFILE_SPEC "crt1%O%s"
86 /* Names to predefine in the preprocessor for this target machine. */
87 #define CPP_PREDEFINES "-Dmc68hc1x"
89 /* As an embedded target, we have no libc. */
90 #define inhibit_libc
92 /* Forward type declaration for prototypes definitions.
93 rtx_ptr is equivalent to rtx. Can't use the same name. */
94 struct rtx_def;
95 typedef struct rtx_def *rtx_ptr;
97 union tree_node;
98 typedef union tree_node *tree_ptr;
100 /* We can't declare enum machine_mode forward nor include 'machmode.h' here.
101 Prototypes defined here will use an int instead. It's better than no
102 prototype at all. */
103 typedef int enum_machine_mode;
105 /*****************************************************************************
107 ** Run-time Target Specification
109 *****************************************************************************/
111 /* Run-time compilation parameters selecting different hardware subsets. */
113 extern int target_flags;
115 extern short *reg_renumber; /* def in local_alloc.c */
117 /* Macros used in the machine description to test the flags. */
119 /* 6811 specific options
121 * For 68HC12, the auto inc/dec mode is disabled by default. The reason
122 * is that for most programs, the reload pass will fail because it needs
123 * more registers to save the value of the indexed register after the
124 * memory access. For simple programs, you can enable this
125 * with -mauto-incdec.
128 #define MASK_SHORT 0002 /* Compile with 16-bit `int' */
129 #define MASK_AUTO_INC_DEC 0004
130 #define MASK_M6811 0010
131 #define MASK_M6812 0020
132 #define MASK_M68S12 0040
133 #define MASK_NO_DIRECT_MODE 0100
134 #define MASK_MIN_MAX 0200
135 #define MASK_LONG_CALLS 0400
137 #define TARGET_OP_TIME (optimize && optimize_size == 0)
138 #define TARGET_SHORT (target_flags & MASK_SHORT)
139 #define TARGET_M6811 (target_flags & MASK_M6811)
140 #define TARGET_M6812 (target_flags & MASK_M6812)
141 #define TARGET_M68S12 (target_flags & MASK_M68S12)
142 #define TARGET_AUTO_INC_DEC (target_flags & MASK_AUTO_INC_DEC)
143 #define TARGET_MIN_MAX (target_flags & MASK_MIN_MAX)
144 #define TARGET_NO_DIRECT_MODE (target_flags & MASK_NO_DIRECT_MODE)
145 #define TARGET_RELAX (TARGET_NO_DIRECT_MODE)
146 #define TARGET_LONG_CALLS (target_flags & MASK_LONG_CALLS)
148 /* Default target_flags if no switches specified. */
149 #ifndef TARGET_DEFAULT
150 # define TARGET_DEFAULT (MASK_M6811)
151 #endif
153 /* Define this macro as a C expression for the initializer of an
154 array of string to tell the driver program which options are
155 defaults for this target and thus do not need to be handled
156 specially when using `MULTILIB_OPTIONS'. */
157 #ifndef MULTILIB_DEFAULTS
158 # if TARGET_DEFAULT & MASK_M6811
159 # define MULTILIB_DEFAULTS { "m68hc11" }
160 # else
161 # define MULTILIB_DEFAULTS { "m68hc12" }
162 # endif
163 #endif
165 /* Macro to define tables used to set the flags. This is a list in braces of
166 pairs in braces, each pair being { "NAME", VALUE } where VALUE is the bits
167 to set or minus the bits to clear. An empty string NAME is used to
168 identify the default VALUE. */
170 #define TARGET_SWITCHES \
171 { { "short", MASK_SHORT, \
172 N_("Compile with 16-bit integer mode")}, \
173 { "noshort", - MASK_SHORT, \
174 N_("Compile with 32-bit integer mode")}, \
175 { "auto-incdec", MASK_AUTO_INC_DEC, \
176 N_("Auto pre/post decrement increment allowed")}, \
177 { "noauto-incdec", - MASK_AUTO_INC_DEC, \
178 N_("Auto pre/post decrement increment not allowed")}, \
179 { "inmax", MASK_MIN_MAX, \
180 N_("Min/max instructions allowed")}, \
181 { "nominmax", MASK_MIN_MAX, \
182 N_("Min/max instructions not allowed")}, \
183 { "long-calls", MASK_LONG_CALLS, \
184 N_("Use call and rtc for function calls and returns")}, \
185 { "nolong-calls", - MASK_LONG_CALLS, \
186 N_("Use jsr and rts for function calls and returns")}, \
187 { "relax", MASK_NO_DIRECT_MODE, \
188 N_("Do not use direct addressing mode for soft registers")},\
189 { "68hc11", MASK_M6811, \
190 N_("Compile for a 68HC11")}, \
191 { "68hc12", MASK_M6812, \
192 N_("Compile for a 68HC12")}, \
193 { "68hcs12", MASK_M6812 | MASK_M68S12, \
194 N_("Compile for a 68HCS12")}, \
195 { "6811", MASK_M6811, \
196 N_("Compile for a 68HC11")}, \
197 { "6812", MASK_M6812, \
198 N_("Compile for a 68HC12")}, \
199 { "68S12", MASK_M6812 | MASK_M68S12, \
200 N_("Compile for a 68HCS12")}, \
201 { "", TARGET_DEFAULT, 0 }}
203 /* This macro is similar to `TARGET_SWITCHES' but defines names of
204 command options that have values. Its definition is an
205 initializer with a subgrouping for each command option.
207 Each subgrouping contains a string constant, that defines the
208 fixed part of the option name, and the address of a variable. The
209 variable, type `char *', is set to the variable part of the given
210 option if the fixed part matches. The actual option name is made
211 by appending `-m' to the specified name. */
212 #define TARGET_OPTIONS \
213 { { "reg-alloc=", &m68hc11_reg_alloc_order, \
214 N_("Specify the register allocation order")}, \
215 { "soft-reg-count=", &m68hc11_soft_reg_count, \
216 N_("Indicate the number of soft registers available") }, \
217 SUBTARGET_OPTIONS \
220 /* These are meant to be redefined in the host dependent files */
221 #define SUBTARGET_SWITCHES
222 #define SUBTARGET_OPTIONS
224 extern const char *m68hc11_regparm_string;
225 extern const char *m68hc11_reg_alloc_order;
226 extern const char *m68hc11_soft_reg_count;
228 #ifndef TARGET_M68HC12
229 # define TARGET_M68HC11 1
230 #endif
232 /* Print subsidiary information on the compiler version in use. */
233 #define TARGET_VERSION fprintf (stderr, " (MC68HC11/MC68HC12/MC68HCS12)")
235 /* Sometimes certain combinations of command options do not make
236 sense on a particular target machine. You can define a macro
237 `OVERRIDE_OPTIONS' to take account of this. This macro, if
238 defined, is executed once just after all the command options have
239 been parsed.
241 Don't use this macro to turn on various extra optimizations for
242 `-O'. That is what `OPTIMIZATION_OPTIONS' is for. */
244 #define OVERRIDE_OPTIONS m68hc11_override_options ();
247 /* Define cost parameters for a given processor variant. */
248 struct processor_costs {
249 const int add; /* cost of an add instruction */
250 const int logical; /* cost of a logical instruction */
251 const int shift_var;
252 const int shiftQI_const[8];
253 const int shiftHI_const[16];
254 const int multQI;
255 const int multHI;
256 const int multSI;
257 const int divQI;
258 const int divHI;
259 const int divSI;
262 /* Costs for the current processor. */
263 extern const struct processor_costs *m68hc11_cost;
266 /* target machine storage layout */
268 /* Define this if most significant byte of a word is the lowest numbered. */
269 #define BYTES_BIG_ENDIAN 1
271 /* Define this if most significant bit is lowest numbered
272 in instructions that operate on numbered bit-fields. */
273 #define BITS_BIG_ENDIAN 0
275 /* Define this if most significant word of a multiword number is numbered. */
276 #define WORDS_BIG_ENDIAN 1
278 /* Width of a word, in units (bytes). */
279 #define UNITS_PER_WORD 2
281 /* Definition of size_t. This is really an unsigned short as the
282 68hc11 only handles a 64K address space. */
283 #define SIZE_TYPE "short unsigned int"
285 /* A C expression for a string describing the name of the data type
286 to use for the result of subtracting two pointers. The typedef
287 name `ptrdiff_t' is defined using the contents of the string.
288 The 68hc11 only has a 64K address space. */
289 #define PTRDIFF_TYPE "short int"
291 /* Allocation boundary (bits) for storing pointers in memory. */
292 #define POINTER_BOUNDARY 8
294 /* Normal alignment required for function parameters on the stack, in bits.
295 This can't be less than BITS_PER_WORD */
296 #define PARM_BOUNDARY (BITS_PER_WORD)
298 /* Boundary (bits) on which stack pointer should be aligned. */
299 #define STACK_BOUNDARY 8
301 /* Allocation boundary (bits) for the code of a function. */
302 #define FUNCTION_BOUNDARY 8
304 #define BIGGEST_ALIGNMENT 8
306 /* Alignment of field after `int : 0' in a structure. */
307 #define EMPTY_FIELD_BOUNDARY 8
309 /* Every structure's size must be a multiple of this. */
310 #define STRUCTURE_SIZE_BOUNDARY 8
312 /* Define this if instructions will fail to work if given data not
313 on the nominal alignment. If instructions will merely go slower
314 in that case, do not define this macro. */
315 #define STRICT_ALIGNMENT 0
317 /* An integer expression for the size in bits of the largest integer
318 machine mode that should actually be used. All integer machine modes of
319 this size or smaller can be used for structures and unions with the
320 appropriate sizes. */
321 #define MAX_FIXED_MODE_SIZE 64
323 /* target machine storage layout */
325 /* Size (bits) of the type "int" on target machine
326 (If undefined, default is BITS_PER_WORD). */
327 #define INT_TYPE_SIZE (TARGET_SHORT ? 16 : 32)
329 /* Size (bits) of the type "short" on target machine */
330 #define SHORT_TYPE_SIZE 16
332 /* Size (bits) of the type "long" on target machine */
333 #define LONG_TYPE_SIZE 32
335 /* Size (bits) of the type "long long" on target machine */
336 #define LONG_LONG_TYPE_SIZE 64
338 /* A C expression for the size in bits of the type `float' on the
339 target machine. If you don't define this, the default is one word.
340 Don't use default: a word is only 16. */
341 #define FLOAT_TYPE_SIZE 32
343 /* A C expression for the size in bits of the type double on the target
344 machine. If you don't define this, the default is two words.
345 Be IEEE compliant. */
346 #define DOUBLE_TYPE_SIZE 64
348 #define LONG_DOUBLE_TYPE_SIZE 64
350 /* Define this as 1 if `char' should by default be signed; else as 0. */
351 #define DEFAULT_SIGNED_CHAR 0
353 /* Define these to avoid dependence on meaning of `int'.
354 Note that WCHAR_TYPE_SIZE is used in cexp.y,
355 where TARGET_SHORT is not available. */
356 #define WCHAR_TYPE "short int"
357 #define WCHAR_TYPE_SIZE 16
360 /* Standard register usage. */
362 #define HARD_REG_SIZE (UNITS_PER_WORD)
364 /* Assign names to real MC68HC11 registers.
365 A and B registers are not really used (A+B = D)
366 X register is first so that GCC allocates X+D for 32-bit integers and
367 the lowpart of that integer will be D. Having the lower part in D is
368 better for 32<->16bit conversions and for many arithmetic operations. */
369 #define HARD_X_REGNUM 0
370 #define HARD_D_REGNUM 1
371 #define HARD_Y_REGNUM 2
372 #define HARD_SP_REGNUM 3
373 #define HARD_PC_REGNUM 4
374 #define HARD_A_REGNUM 5
375 #define HARD_B_REGNUM 6
376 #define HARD_CCR_REGNUM 7
378 /* The Z register does not really exist in the 68HC11. This a fake register
379 for GCC. It is treated exactly as an index register (X or Y). It is only
380 in the A_REGS class, which is the BASE_REG_CLASS for GCC. Defining this
381 register helps the reload pass of GCC. Otherwise, the reload often aborts
382 with register spill failures.
384 The Z register is replaced by either X or Y during the machine specific
385 reorg (m68hc11_reorg). It is saved in the SOFT_Z_REGNUM soft-register
386 when this is necessary.
388 It's possible to tell GCC not to use this register with -ffixed-z. */
389 #define HARD_Z_REGNUM 8
391 /* The frame pointer is a soft-register. It's treated as such by GCC:
392 it is not and must not be part of the BASE_REG_CLASS. */
393 #define DEFAULT_HARD_FP_REGNUM (9)
394 #define HARD_FP_REGNUM (9)
395 #define HARD_AP_REGNUM (HARD_FP_REGNUM)
397 /* Temporary soft-register used in some cases when an operand came
398 up into a bad register class (D, X, Y, SP) and gcc failed to
399 recognize this. This register is never allocated by GCC. */
400 #define SOFT_TMP_REGNUM 10
402 /* The soft-register which is used to save the Z register
403 (see Z register replacement notes in m68hc11.c). */
404 #define SOFT_Z_REGNUM 11
406 /* The soft-register which is used to save either X or Y. */
407 #define SOFT_SAVED_XY_REGNUM 12
409 /* A fake clobber register for 68HC12 patterns. */
410 #define FAKE_CLOBBER_REGNUM (13)
412 /* Define 32 soft-registers of 16-bit each. By default,
413 only 12 of them are enabled and can be used by GCC. The
414 -msoft-reg-count=<n> option allows to control the number of valid
415 soft-registers. GCC can put 32-bit values in them
416 by allocating consecutive registers. The first 3 soft-registers
417 are never allocated by GCC. They are used in case the insn template needs
418 a temporary register, or for the Z register replacement. */
420 #define MAX_SOFT_REG_COUNT (32)
421 #define SOFT_REG_FIXED 0, 0, 0, 0, 0, 0, 0, 0, \
422 0, 0, 0, 0, 1, 1, 1, 1, \
423 1, 1, 1, 1, 1, 1, 1, 1, \
424 1, 1, 1, 1, 1, 1, 1, 1
425 #define SOFT_REG_USED 0, 0, 0, 0, 0, 0, 0, 0, \
426 0, 0, 0, 0, 1, 1, 1, 1, \
427 1, 1, 1, 1, 1, 1, 1, 1, \
428 1, 1, 1, 1, 1, 1, 1, 1
429 #define SOFT_REG_ORDER \
430 SOFT_REG_FIRST, SOFT_REG_FIRST+1,SOFT_REG_FIRST+2,SOFT_REG_FIRST+3,\
431 SOFT_REG_FIRST+4, SOFT_REG_FIRST+5,SOFT_REG_FIRST+6,SOFT_REG_FIRST+7,\
432 SOFT_REG_FIRST+8, SOFT_REG_FIRST+9,SOFT_REG_FIRST+10,SOFT_REG_FIRST+11,\
433 SOFT_REG_FIRST+12, SOFT_REG_FIRST+13,SOFT_REG_FIRST+14,SOFT_REG_FIRST+15,\
434 SOFT_REG_FIRST+16, SOFT_REG_FIRST+17,SOFT_REG_FIRST+18,SOFT_REG_FIRST+19,\
435 SOFT_REG_FIRST+20, SOFT_REG_FIRST+21,SOFT_REG_FIRST+22,SOFT_REG_FIRST+23,\
436 SOFT_REG_FIRST+24, SOFT_REG_FIRST+25,SOFT_REG_FIRST+26,SOFT_REG_FIRST+27,\
437 SOFT_REG_FIRST+28, SOFT_REG_FIRST+29,SOFT_REG_FIRST+30,SOFT_REG_FIRST+31
439 #define SOFT_REG_NAMES \
440 "*_.d1", "*_.d2", "*_.d3", "*_.d4", \
441 "*_.d5", "*_.d6", "*_.d7", "*_.d8", \
442 "*_.d9", "*_.d10", "*_.d11", "*_.d12", \
443 "*_.d13", "*_.d14", "*_.d15", "*_.d16", \
444 "*_.d17", "*_.d18", "*_.d19", "*_.d20", \
445 "*_.d21", "*_.d22", "*_.d23", "*_.d24", \
446 "*_.d25", "*_.d26", "*_.d27", "*_.d28", \
447 "*_.d29", "*_.d30", "*_.d31", "*_.d32"
449 /* First available soft-register for GCC. */
450 #define SOFT_REG_FIRST (SOFT_SAVED_XY_REGNUM+2)
452 /* Last available soft-register for GCC. */
453 #define SOFT_REG_LAST (SOFT_REG_FIRST+MAX_SOFT_REG_COUNT)
454 #define SOFT_FP_REGNUM (SOFT_REG_LAST)
455 #define SOFT_AP_REGNUM (SOFT_FP_REGNUM+1)
457 /* Number of actual hardware registers. The hardware registers are assigned
458 numbers for the compiler from 0 to just below FIRST_PSEUDO_REGISTER.
459 All registers that the compiler knows about must be given numbers, even
460 those that are not normally considered general registers. */
461 #define FIRST_PSEUDO_REGISTER (SOFT_REG_LAST+2)
463 /* 1 for registers that have pervasive standard uses and are not available
464 for the register allocator. */
465 #define FIXED_REGISTERS \
466 {0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1,1, 1, SOFT_REG_FIXED, 1, 1}
467 /* X, D, Y, SP,PC,A, B, CCR, Z, FP,ZTMP,ZR,XYR, FK, D1 - D32, SOFT-FP, AP */
469 /* 1 for registers not available across function calls. For our pseudo
470 registers, all are available. */
471 #define CALL_USED_REGISTERS \
472 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, SOFT_REG_USED, 1, 1}
473 /* X, D, Y, SP,PC,A, B, CCR, Z, FP, ZTMP,ZR,XYR, D1 - 32, SOFT-FP, AP */
476 /* Define this macro to change register usage conditional on target flags.
478 The soft-registers are disabled or enabled according to the
479 -msoft-reg-count=<n> option. */
482 #define CONDITIONAL_REGISTER_USAGE (m68hc11_conditional_register_usage ())
484 /* List the order in which to allocate registers. Each register must be
485 listed once, even those in FIXED_REGISTERS. */
486 #define REG_ALLOC_ORDER \
487 { HARD_D_REGNUM, HARD_X_REGNUM, HARD_Y_REGNUM, \
488 SOFT_REG_ORDER, HARD_Z_REGNUM, HARD_PC_REGNUM, HARD_A_REGNUM, \
489 HARD_B_REGNUM, HARD_CCR_REGNUM, HARD_FP_REGNUM, SOFT_FP_REGNUM, \
490 HARD_SP_REGNUM, SOFT_TMP_REGNUM, SOFT_Z_REGNUM, SOFT_SAVED_XY_REGNUM, \
491 SOFT_AP_REGNUM, FAKE_CLOBBER_REGNUM }
493 /* A C expression for the number of consecutive hard registers,
494 starting at register number REGNO, required to hold a value of
495 mode MODE. */
496 #define HARD_REGNO_NREGS(REGNO, MODE) \
497 ((Q_REGNO_P (REGNO)) ? (GET_MODE_SIZE (MODE)) : \
498 ((GET_MODE_SIZE (MODE) + HARD_REG_SIZE - 1) / HARD_REG_SIZE))
500 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
501 - 8 bit values are stored anywhere (except the SP register).
502 - 16 bit values can be stored in any register whose mode is 16
503 - 32 bit values can be stored in D, X registers or in a soft register
504 (except the last one because we need 2 soft registers)
505 - Values whose size is > 32 bit are not stored in real hard
506 registers. They may be stored in soft registers if there are
507 enough of them. */
508 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
509 hard_regno_mode_ok (REGNO,MODE)
511 /* Value is 1 if it is a good idea to tie two pseudo registers when one has
512 mode MODE1 and one has mode MODE2. If HARD_REGNO_MODE_OK could produce
513 different values for MODE1 and MODE2, for any hard reg, then this must be
514 0 for correct output.
516 All modes are tieable except QImode. */
517 #define MODES_TIEABLE_P(MODE1, MODE2) \
518 (((MODE1) == (MODE2)) \
519 || ((MODE1) != QImode && (MODE2) != QImode))
522 /* Define the classes of registers for register constraints in the
523 machine description. Also define ranges of constants.
525 One of the classes must always be named ALL_REGS and include all hard regs.
526 If there is more than one class, another class must be named NO_REGS
527 and contain no registers.
529 The name GENERAL_REGS must be the name of a class (or an alias for
530 another name such as ALL_REGS). This is the class of registers
531 that is allowed by "g" or "r" in a register constraint.
532 Also, registers outside this class are allocated only when
533 instructions express preferences for them.
535 The classes must be numbered in nondecreasing order; that is,
536 a larger-numbered class must never be contained completely
537 in a smaller-numbered class.
539 For any two classes, it is very desirable that there be another
540 class that represents their union. */
542 /* The M68hc11 has so fiew registers that it's not possible for GCC to
543 do any register allocation without breaking. We extend the processor
544 registers by having soft registers. These registers are treated as
545 hard registers by GCC but they are located in memory and accessed by page0
546 accesses (IND mode). */
547 enum reg_class
549 NO_REGS,
550 D_REGS, /* 16-bit data register */
551 X_REGS, /* 16-bit X register */
552 Y_REGS, /* 16-bit Y register */
553 SP_REGS, /* 16 bit stack pointer */
554 DA_REGS, /* 8-bit A reg. */
555 DB_REGS, /* 8-bit B reg. */
556 Z_REGS, /* 16-bit fake Z register */
557 D8_REGS, /* 8-bit A or B reg. */
558 Q_REGS, /* 8-bit (byte (QI)) data (A, B or D) */
559 D_OR_X_REGS, /* D or X register */
560 D_OR_Y_REGS, /* D or Y register */
561 D_OR_SP_REGS, /* D or SP register */
562 X_OR_Y_REGS, /* IX or Y register */
563 A_REGS, /* 16-bit address register (X, Y, Z) */
564 X_OR_SP_REGS, /* X or SP register */
565 Y_OR_SP_REGS, /* Y or SP register */
566 X_OR_Y_OR_D_REGS, /* X, Y or D */
567 A_OR_D_REGS, /* X, Y, Z or D */
568 A_OR_SP_REGS, /* X, Y, Z or SP */
569 H_REGS, /* 16-bit hard register (D, X, Y, Z, SP) */
570 S_REGS, /* 16-bit soft register */
571 D_OR_S_REGS, /* 16-bit soft register or D register */
572 X_OR_S_REGS, /* 16-bit soft register or X register */
573 Y_OR_S_REGS, /* 16-bit soft register or Y register */
574 SP_OR_S_REGS, /* 16-bit soft register or SP register */
575 D_OR_X_OR_S_REGS, /* 16-bit soft register or D or X register */
576 D_OR_Y_OR_S_REGS, /* 16-bit soft register or D or Y register */
577 D_OR_SP_OR_S_REGS, /* 16-bit soft register or D or SP register */
578 A_OR_S_REGS, /* 16-bit soft register or X, Y registers */
579 D_OR_A_OR_S_REGS, /* 16-bit soft register or D, X, Y registers */
580 TMP_REGS, /* 16 bit fake scratch register */
581 D_OR_A_OR_TMP_REGS, /* General scratch register */
582 G_REGS, /* 16-bit general register
583 (H_REGS + soft registers) */
584 ALL_REGS,
585 LIM_REG_CLASSES
588 /* alias GENERAL_REGS to G_REGS. */
589 #define GENERAL_REGS G_REGS
591 #define N_REG_CLASSES (int) LIM_REG_CLASSES
593 /* Give names of register classes as strings for dump file. */
594 #define REG_CLASS_NAMES \
595 { "NO_REGS", \
596 "D_REGS", \
597 "X_REGS", \
598 "Y_REGS", \
599 "SP_REGS", \
600 "DA_REGS", \
601 "DB_REGS", \
602 "D8_REGS", \
603 "Z_REGS", \
604 "Q_REGS", \
605 "D_OR_X_REGS", \
606 "D_OR_Y_REGS", \
607 "D_OR_SP_REGS", \
608 "X_OR_Y_REGS", \
609 "A_REGS", \
610 "X_OR_SP_REGS", \
611 "Y_OR_SP_REGS", \
612 "X_OR_Y_OR_D_REGS", \
613 "A_OR_D_REGS", \
614 "A_OR_SP_REGS", \
615 "H_REGS", \
616 "S_REGS", \
617 "D_OR_S_REGS", \
618 "X_OR_S_REGS", \
619 "Y_OR_S_REGS", \
620 "SP_OR_S_REGS", \
621 "D_OR_X_OR_S_REGS", \
622 "D_OR_Y_OR_S_REGS", \
623 "D_OR_SP_OR_S_REGS", \
624 "A_OR_S_REGS", \
625 "D_OR_A_OR_S_REGS", \
626 "TMP_REGS", \
627 "D_OR_A_OR_TMP_REGS", \
628 "G_REGS", \
629 "ALL_REGS" }
631 /* An initializer containing the contents of the register classes,
632 as integers which are bit masks. The Nth integer specifies the
633 contents of class N. The way the integer MASK is interpreted is
634 that register R is in the class if `MASK & (1 << R)' is 1. */
636 /*--------------------------------------------------------------
637 X 0x00000001
638 D 0x00000002
639 Y 0x00000004
640 SP 0x00000008
641 PC 0x00000010
642 A 0x00000020
643 B 0x00000040
644 CCR 0x00000080
645 Z 0x00000100
646 FRAME 0x00000200
647 ZTMP 0x00000400
648 ZREG 0x00000800
649 XYREG 0x00001000
650 FAKE 0x00002000
651 Di 0xFFFFc000, 0x03FFF
652 SFRAME 0x00000000, 0x04000
653 AP 0x00000000, 0x08000
655 D_OR_X_REGS represents D+X. It is used for 32-bits numbers.
656 A_REGS represents a valid base register for indexing. It represents
657 X,Y and the Z register.
658 S_REGS represents the soft-registers. This includes the hard frame
659 and soft frame registers.
660 --------------------------------------------------------------*/
662 #define REG_CLASS_CONTENTS \
663 /* NO_REGS */ {{ 0x00000000, 0x00000000 }, \
664 /* D_REGS */ { 0x00000002, 0x00000000 }, /* D */ \
665 /* X_REGS */ { 0x00000001, 0x00000000 }, /* X */ \
666 /* Y_REGS */ { 0x00000004, 0x00000000 }, /* Y */ \
667 /* SP_REGS */ { 0x00000008, 0x00000000 }, /* SP */ \
668 /* DA_REGS */ { 0x00000020, 0x00000000 }, /* A */ \
669 /* DB_REGS */ { 0x00000040, 0x00000000 }, /* B */ \
670 /* Z_REGS */ { 0x00000100, 0x00000000 }, /* Z */ \
671 /* D8_REGS */ { 0x00000060, 0x00000000 }, /* A B */ \
672 /* Q_REGS */ { 0x00000062, 0x00000000 }, /* A B D */ \
673 /* D_OR_X_REGS */ { 0x00000003, 0x00000000 }, /* D X */ \
674 /* D_OR_Y_REGS */ { 0x00000006, 0x00000000 }, /* D Y */ \
675 /* D_OR_SP_REGS */ { 0x0000000A, 0x00000000 }, /* D SP */ \
676 /* X_OR_Y_REGS */ { 0x00000005, 0x00000000 }, /* X Y */ \
677 /* A_REGS */ { 0x00000105, 0x00000000 }, /* X Y Z */ \
678 /* X_OR_SP_REGS */ { 0x00000009, 0x00000000 }, /* X SP */ \
679 /* Y_OR_SP_REGS */ { 0x0000000C, 0x00000000 }, /* Y SP */ \
680 /* X_OR_Y_OR_D_REGS */ { 0x00000007, 0x00000000 }, /* D X Y */ \
681 /* A_OR_D_REGS */ { 0x00000107, 0x00000000 }, /* D X Y Z */ \
682 /* A_OR_SP_REGS */ { 0x0000010D, 0x00000000 }, /* X Y SP */ \
683 /* H_REGS */ { 0x0000010F, 0x00000000 }, /* D X Y SP */ \
684 /* S_REGS */ { 0xFFFFDE00, 0x00007FFF }, /* _.D,..,FP,Z* */ \
685 /* D_OR_S_REGS */ { 0xFFFFDE02, 0x00007FFF }, /* D _.D */ \
686 /* X_OR_S_REGS */ { 0xFFFFDE01, 0x00007FFF }, /* X _.D */ \
687 /* Y_OR_S_REGS */ { 0xFFFFDE04, 0x00007FFF }, /* Y _.D */ \
688 /* SP_OR_S_REGS */ { 0xFFFFDE08, 0x00007FFF }, /* SP _.D */ \
689 /* D_OR_X_OR_S_REGS */ { 0xFFFFDE03, 0x00007FFF }, /* D X _.D */ \
690 /* D_OR_Y_OR_S_REGS */ { 0xFFFFDE06, 0x00007FFF }, /* D Y _.D */ \
691 /* D_OR_SP_OR_S_REGS */ { 0xFFFFDE0A, 0x00007FFF }, /* D SP _.D */ \
692 /* A_OR_S_REGS */ { 0xFFFFDF05, 0x00007FFF }, /* X Y _.D */ \
693 /* D_OR_A_OR_S_REGS */ { 0xFFFFDF07, 0x00007FFF }, /* D X Y _.D */ \
694 /* TMP_REGS */ { 0x00002000, 0x00000000 }, /* FAKE */ \
695 /* D_OR_A_OR_TMP_REGS*/ { 0x00002107, 0x00000000 }, /* D X Y Z Fake */ \
696 /* G_REGS */ { 0xFFFFFF1F, 0x00007FFF }, /* ? _.D D X Y */ \
697 /* ALL_REGS*/ { 0xFFFFFFFF, 0x00007FFF }}
700 /* set up a C expression whose value is a register class containing hard
701 register REGNO */
702 #define Q_REGNO_P(REGNO) ((REGNO) == HARD_A_REGNUM \
703 || (REGNO) == HARD_B_REGNUM)
704 #define Q_REG_P(X) (REG_P (X) && Q_REGNO_P (REGNO (X)))
706 #define D_REGNO_P(REGNO) ((REGNO) == HARD_D_REGNUM)
707 #define D_REG_P(X) (REG_P (X) && D_REGNO_P (REGNO (X)))
709 #define DB_REGNO_P(REGNO) ((REGNO) == HARD_B_REGNUM)
710 #define DB_REG_P(X) (REG_P (X) && DB_REGNO_P (REGNO (X)))
711 #define DA_REGNO_P(REGNO) ((REGNO) == HARD_A_REGNUM)
712 #define DA_REG_P(X) (REG_P (X) && DA_REGNO_P (REGNO (X)))
714 #define X_REGNO_P(REGNO) ((REGNO) == HARD_X_REGNUM)
715 #define X_REG_P(X) (REG_P (X) && X_REGNO_P (REGNO (X)))
717 #define Y_REGNO_P(REGNO) ((REGNO) == HARD_Y_REGNUM)
718 #define Y_REG_P(X) (REG_P (X) && Y_REGNO_P (REGNO (X)))
720 #define Z_REGNO_P(REGNO) ((REGNO) == HARD_Z_REGNUM)
721 #define Z_REG_P(X) (REG_P (X) && Z_REGNO_P (REGNO (X)))
723 #define SP_REGNO_P(REGNO) ((REGNO) == HARD_SP_REGNUM)
724 #define SP_REG_P(X) (REG_P (X) && SP_REGNO_P (REGNO (X)))
726 /* Address register. */
727 #define A_REGNO_P(REGNO) ((REGNO) == HARD_X_REGNUM \
728 || (REGNO) == HARD_Y_REGNUM \
729 || (REGNO) == HARD_Z_REGNUM)
730 #define A_REG_P(X) (REG_P (X) && A_REGNO_P (REGNO (X)))
732 /* M68hc11 hard registers. */
733 #define H_REGNO_P(REGNO) (D_REGNO_P (REGNO) || A_REGNO_P (REGNO) \
734 || SP_REGNO_P (REGNO) || Q_REGNO_P (REGNO))
735 #define H_REG_P(X) (REG_P (X) && H_REGNO_P (REGNO (X)))
737 #define FAKE_REGNO_P(REGNO) ((REGNO) == FAKE_CLOBBER_REGNUM)
738 #define FAKE_REG_P(X) (REG_P (X) && FAKE_REGNO_P (REGNO (X)))
740 /* Soft registers (or register emulation for gcc). The temporary register
741 used by insn template must be part of the S_REGS class so that it
742 matches the 'u' constraint. */
743 #define S_REGNO_P(REGNO) ((REGNO) >= SOFT_TMP_REGNUM \
744 && (REGNO) <= SOFT_REG_LAST \
745 && (REGNO) != FAKE_CLOBBER_REGNUM)
746 #define S_REG_P(X) (REG_P (X) && S_REGNO_P (REGNO (X)))
748 #define Z_REGNO_P(REGNO) ((REGNO) == HARD_Z_REGNUM)
749 #define Z_REG_P(X) (REG_P (X) && Z_REGNO_P (REGNO (X)))
751 /* General register. */
752 #define G_REGNO_P(REGNO) (H_REGNO_P (REGNO) || S_REGNO_P (REGNO) \
753 || ((REGNO) == HARD_PC_REGNUM) \
754 || ((REGNO) == HARD_FP_REGNUM) \
755 || ((REGNO) == SOFT_FP_REGNUM) \
756 || ((REGNO) == FAKE_CLOBBER_REGNUM) \
757 || ((REGNO) == SOFT_AP_REGNUM))
759 #define G_REG_P(X) (REG_P (X) && G_REGNO_P (REGNO (X)))
761 #define REGNO_REG_CLASS(REGNO) \
762 (D_REGNO_P (REGNO) ? D_REGS : \
763 (X_REGNO_P (REGNO) ? X_REGS : \
764 (Y_REGNO_P (REGNO) ? Y_REGS : \
765 (SP_REGNO_P (REGNO) ? SP_REGS : \
766 (Z_REGNO_P (REGNO) ? Z_REGS : \
767 (H_REGNO_P (REGNO) ? H_REGS : \
768 (FAKE_REGNO_P (REGNO) ? TMP_REGS : \
769 (S_REGNO_P (REGNO) ? S_REGS : \
770 (DA_REGNO_P (REGNO) ? DA_REGS: \
771 (DB_REGNO_P (REGNO) ? DB_REGS: \
772 (G_REGNO_P (REGNO) ? G_REGS : ALL_REGS)))))))))))
775 /* Get reg_class from a letter in the machine description. */
777 extern enum reg_class m68hc11_tmp_regs_class;
778 #define REG_CLASS_FROM_LETTER(C) \
779 ((C) == 'a' ? DA_REGS : \
780 (C) == 'A' ? A_REGS : \
781 (C) == 'b' ? DB_REGS : \
782 (C) == 'B' ? X_OR_Y_REGS : \
783 (C) == 'd' ? D_REGS : \
784 (C) == 'D' ? D_OR_X_REGS : \
785 (C) == 'q' ? Q_REGS : \
786 (C) == 'h' ? H_REGS : \
787 (C) == 't' ? TMP_REGS : \
788 (C) == 'u' ? S_REGS : \
789 (C) == 'v' ? m68hc11_tmp_regs_class : \
790 (C) == 'w' ? SP_REGS : \
791 (C) == 'x' ? X_REGS : \
792 (C) == 'y' ? Y_REGS : \
793 (C) == 'z' ? Z_REGS : NO_REGS)
795 #define PREFERRED_RELOAD_CLASS(X,CLASS) preferred_reload_class(X,CLASS)
797 #define SMALL_REGISTER_CLASSES 1
799 /* A C expression whose value is nonzero if pseudos that have been
800 assigned to registers of class CLASS would likely be spilled
801 because registers of CLASS are needed for spill registers.
803 The default value of this macro returns 1 if CLASS has exactly one
804 register and zero otherwise. On most machines, this default
805 should be used. Only define this macro to some other expression
806 if pseudo allocated by `local-alloc.c' end up in memory because
807 their hard registers were needed for spill registers. If this
808 macro returns nonzero for those classes, those pseudos will only
809 be allocated by `global.c', which knows how to reallocate the
810 pseudo to another register. If there would not be another
811 register available for reallocation, you should not change the
812 definition of this macro since the only effect of such a
813 definition would be to slow down register allocation. */
815 #define CLASS_LIKELY_SPILLED_P(CLASS) \
816 (((CLASS) == D_REGS) \
817 || ((CLASS) == X_REGS) \
818 || ((CLASS) == Y_REGS) \
819 || ((CLASS) == A_REGS) \
820 || ((CLASS) == SP_REGS) \
821 || ((CLASS) == D_OR_X_REGS) \
822 || ((CLASS) == D_OR_Y_REGS) \
823 || ((CLASS) == X_OR_SP_REGS) \
824 || ((CLASS) == Y_OR_SP_REGS) \
825 || ((CLASS) == D_OR_SP_REGS))
827 /* Return the maximum number of consecutive registers needed to represent
828 mode MODE in a register of class CLASS. */
829 #define CLASS_MAX_NREGS(CLASS, MODE) \
830 (((CLASS) == DA_REGS || (CLASS) == DB_REGS \
831 || (CLASS) == D8_REGS || (CLASS) == Q_REGS) ? GET_MODE_SIZE (MODE) \
832 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
834 /* The letters I, J, K, L and M in a register constraint string
835 can be used to stand for particular ranges of immediate operands.
836 This macro defines what the ranges are.
837 C is the letter, and VALUE is a constant value.
838 Return 1 if VALUE is in the range specified by C.
840 `K' is for 0.
841 `L' is for range -65536 to 65536
842 `M' is for values whose 16-bit low part is 0
843 'N' is for +1 or -1.
844 'O' is for 16 (for rotate using swap).
845 'P' is for range -8 to 2 (used by addhi_sp)
847 'I', 'J' are not used. */
849 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
850 ((C) == 'K' ? (VALUE) == 0 : \
851 (C) == 'L' ? ((VALUE) >= -65536 && (VALUE) <= 65535) : \
852 (C) == 'M' ? ((VALUE) & 0x0ffffL) == 0 : \
853 (C) == 'N' ? ((VALUE) == 1 || (VALUE) == -1) : \
854 (C) == 'O' ? (VALUE) == 16 : \
855 (C) == 'P' ? ((VALUE) <= 2 && (VALUE) >= -8) : 0)
857 /* Similar, but for floating constants, and defining letters G and H.
859 `G' is for 0.0. */
860 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
861 ((C) == 'G' ? (GET_MODE_CLASS (GET_MODE (VALUE)) == MODE_FLOAT \
862 && VALUE == CONST0_RTX (GET_MODE (VALUE))) : 0)
864 /* 'U' represents certain kind of memory indexed operand for 68HC12.
865 and any memory operand for 68HC11. */
866 #define EXTRA_CONSTRAINT(OP, C) \
867 ((C) == 'U' ? m68hc11_small_indexed_indirect_p (OP, GET_MODE (OP)) \
868 : (C) == 'Q' ? m68hc11_symbolic_p (OP, GET_MODE (OP)) \
869 : (C) == 'R' ? m68hc11_indirect_p (OP, GET_MODE (OP)) \
870 : (C) == 'S' ? (memory_operand (OP, GET_MODE (OP)) \
871 && non_push_operand (OP, GET_MODE (OP))) : 0)
874 /* Stack layout; function entry, exit and calling. */
876 /* Define this if pushing a word on the stack
877 makes the stack pointer a smaller address. */
878 #define STACK_GROWS_DOWNWARD
880 /* Define this if the nominal address of the stack frame
881 is at the high-address end of the local variables;
882 that is, each additional local variable allocated
883 goes at a more negative offset in the frame.
885 Don't define for 68HC11, the frame pointer is the bottom
886 of local variables. */
887 /* #define FRAME_GROWS_DOWNWARD */
889 /* Define this if successive arguments to a function occupy decreasing
890 addresses in the stack. */
891 /* #define ARGS_GROW_DOWNWARD */
893 /* Offset within stack frame to start allocating local variables at.
894 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
895 first local allocated. Otherwise, it is the offset to the BEGINNING
896 of the first local allocated. */
897 #define STARTING_FRAME_OFFSET 0
899 /* Offset of first parameter from the argument pointer register value. */
901 #define FIRST_PARM_OFFSET(FNDECL) 2
903 /* After the prologue, RA is at 0(AP) in the current frame. */
904 #define RETURN_ADDR_RTX(COUNT, FRAME) \
905 ((COUNT) == 0 \
906 ? gen_rtx_MEM (Pmode, arg_pointer_rtx) \
907 : 0)
909 /* Before the prologue, the top of the frame is at 2(sp). */
910 #define INCOMING_FRAME_SP_OFFSET 2
912 /* Define this if functions should assume that stack space has been
913 allocated for arguments even when their values are passed in
914 registers.
916 The value of this macro is the size, in bytes, of the area reserved for
917 arguments passed in registers.
919 This space can either be allocated by the caller or be a part of the
920 machine-dependent stack frame: `OUTGOING_REG_PARM_STACK_SPACE'
921 says which. */
922 /* #define REG_PARM_STACK_SPACE(FNDECL) 2 */
924 /* Define this macro if REG_PARM_STACK_SPACE is defined but stack
925 parameters don't skip the area specified by REG_PARM_STACK_SPACE.
926 Normally, when a parameter is not passed in registers, it is placed on
927 the stack beyond the REG_PARM_STACK_SPACE area. Defining this macro
928 suppresses this behavior and causes the parameter to be passed on the
929 stack in its natural location. */
930 /* #define STACK_PARMS_IN_REG_PARM_AREA */
932 /* Register to use for pushing function arguments. */
933 #define STACK_POINTER_REGNUM HARD_SP_REGNUM
935 /* Base register for access to local variables of the function. */
936 #define FRAME_POINTER_REGNUM SOFT_FP_REGNUM
938 #define HARD_FRAME_POINTER_REGNUM HARD_FP_REGNUM
940 /* Base register for access to arguments of the function. */
941 #define ARG_POINTER_REGNUM SOFT_AP_REGNUM
943 /* Register in which static-chain is passed to a function. */
944 #define STATIC_CHAIN_REGNUM SOFT_Z_REGNUM
947 /* Definitions for register eliminations.
949 This is an array of structures. Each structure initializes one pair
950 of eliminable registers. The "from" register number is given first,
951 followed by "to". Eliminations of the same "from" register are listed
952 in order of preference.
954 We have two registers that are eliminated on the 6811. The psuedo arg
955 pointer and pseudo frame pointer registers can always be eliminated;
956 they are replaced with either the stack or the real frame pointer. */
958 #define ELIMINABLE_REGS \
959 {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
960 {ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
961 {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
962 {FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}
964 /* Value should be nonzero if functions must have frame pointers.
965 Zero means the frame pointer need not be set up (and parms may be
966 accessed via the stack pointer) in functions that seem suitable.
967 This is computed in `reload', in reload1.c. */
968 #define FRAME_POINTER_REQUIRED 0
970 /* Given FROM and TO register numbers, say whether this elimination is allowed.
971 Frame pointer elimination is automatically handled.
973 All other eliminations are valid. */
975 #define CAN_ELIMINATE(FROM, TO) \
976 ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM \
977 ? ! frame_pointer_needed \
978 : 1)
981 /* Define the offset between two registers, one to be eliminated, and the other
982 its replacement, at the start of a routine. */
984 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
985 { OFFSET = m68hc11_initial_elimination_offset (FROM, TO); }
988 /* Passing Function Arguments on the Stack. */
990 /* When a prototype says `char' or `short', really pass an `int'. */
991 /* #define PROMOTE_PROTOTYPES */
993 /* If we generate an insn to push BYTES bytes, this says how many the
994 stack pointer really advances by. No rounding or alignment needed
995 for MC6811. */
996 #define PUSH_ROUNDING(BYTES) (BYTES)
998 /* Value is 1 if returning from a function call automatically pops the
999 arguments described by the number-of-args field in the call. FUNTYPE is
1000 the data type of the function (as a tree), or for a library call it is
1001 an identifier node for the subroutine name.
1003 The standard MC6811 call, with arg count word, includes popping the
1004 args as part of the call template. */
1005 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
1007 /* Nonzero if type TYPE should be returned in memory.
1008 Blocks and data types largers than 4 bytes cannot be returned
1009 in the register (D + X = 4). */
1010 #define RETURN_IN_MEMORY(TYPE) \
1011 ((TYPE_MODE (TYPE) == BLKmode) \
1012 ? (int_size_in_bytes (TYPE) > 4) \
1013 : (GET_MODE_SIZE (TYPE_MODE (TYPE)) > 4))
1016 /* Passing Arguments in Registers. */
1018 /* Define a data type for recording info about an argument list
1019 during the scan of that argument list. This data type should
1020 hold all necessary information about the function itself
1021 and about the args processed so far, enough to enable macros
1022 such as FUNCTION_ARG to determine where the next arg should go. */
1024 typedef struct m68hc11_args
1026 int words;
1027 int nregs;
1028 } CUMULATIVE_ARGS;
1030 /* A C expression that indicates when an argument must be passed by reference.
1031 If nonzero for an argument, a copy of that argument is made in memory and a
1032 pointer to the argument is passed instead of the argument itself.
1033 The pointer is passed in whatever way is appropriate for passing a pointer
1034 to that type.
1036 64-bit numbers are passed by reference. */
1037 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
1038 m68hc11_function_arg_pass_by_reference (& (CUM), (MODE), (TYPE), (NAMED))
1041 /* If defined, a C expression which determines whether, and in which direction,
1042 to pad out an argument with extra space. The value should be of type
1043 `enum direction': either `upward' to pad above the argument,
1044 `downward' to pad below, or `none' to inhibit padding.
1046 Structures are stored left shifted in their argument slot. */
1047 #define FUNCTION_ARG_PADDING(MODE, TYPE) \
1048 m68hc11_function_arg_padding ((MODE), (TYPE))
1050 /* A C expression that indicates when it is the called function's
1051 responsibility to make a copy of arguments passed by invisible
1052 reference. Normally, the caller makes a copy and passes the
1053 address of the copy to the routine being called. When
1054 FUNCTION_ARG_CALLEE_COPIES is defined and is nonzero, the caller
1055 does not make a copy. Instead, it passes a pointer to the "live"
1056 value. The called function must not modify this value. If it can
1057 be determined that the value won't be modified, it need not make a
1058 copy; otherwise a copy must be made. */
1059 #define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) \
1060 ((NAMED) && FUNCTION_ARG_PASS_BY_REFERENCE (CUM, MODE, TYPE, NAMED))
1062 /* Initialize a variable CUM of type CUMULATIVE_ARGS for a call to a
1063 function whose data type is FNTYPE. For a library call, FNTYPE is 0. */
1064 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
1065 (m68hc11_init_cumulative_args (&CUM, FNTYPE, LIBNAME))
1067 /* Update the data in CUM to advance over an argument of mode MODE and data
1068 type TYPE. (TYPE is null for libcalls where that information may not be
1069 available.) */
1070 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
1071 (m68hc11_function_arg_advance (&CUM, MODE, TYPE, NAMED))
1073 /* Define where to put the arguments to a function.
1074 Value is zero to push the argument on the stack,
1075 or a hard register in which to store the argument.
1077 MODE is the argument's machine mode.
1078 TYPE is the data type of the argument (as a tree).
1079 This is null for libcalls where that information may
1080 not be available.
1081 CUM is a variable of type CUMULATIVE_ARGS which gives info about
1082 the preceding args and about the function being called.
1083 NAMED is nonzero if this argument is a named parameter
1084 (otherwise it is an extra parameter matching an ellipsis). */
1085 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1086 (m68hc11_function_arg (&CUM, MODE, TYPE, NAMED))
1088 /* Define the profitability of saving registers around calls.
1090 Disable this because the saving instructions generated by
1091 caller-save need a reload and the way it is implemented,
1092 it forbids all spill registers at that point. Enabling
1093 caller saving results in spill failure. */
1094 #define CALLER_SAVE_PROFITABLE(REFS,CALLS) 0
1096 /* Implement `va_arg'. */
1097 #define EXPAND_BUILTIN_VA_ARG(valist, type) \
1098 m68hc11_va_arg (valist, type)
1100 /* For an arg passed partly in registers and partly in memory,
1101 this is the number of registers used.
1102 For args passed entirely in registers or entirely in memory, zero.
1104 Passing an arg partly in register and memory does not work at all.
1105 Don't do that. */
1106 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) (0)
1108 /* 1 if N is a possible register number for function argument passing.
1109 D is for 16-bit values, X is for 32-bit (X+D). */
1110 #define FUNCTION_ARG_REGNO_P(N) \
1111 (((N) == HARD_D_REGNUM) || ((N) == HARD_X_REGNUM))
1113 /* All return values are in the D or X+D registers:
1114 - 8 and 16-bit values are returned in D.
1115 BLKmode are passed in D as pointer.
1116 - 32-bit values are returned in X + D.
1117 The high part is passed in X and the low part in D.
1118 For GCC, the register number must be HARD_X_REGNUM. */
1119 #define FUNCTION_VALUE(VALTYPE, FUNC) \
1120 gen_rtx (REG, TYPE_MODE (VALTYPE), \
1121 ((TYPE_MODE (VALTYPE) == BLKmode \
1122 || GET_MODE_SIZE (TYPE_MODE (VALTYPE)) <= 2) \
1123 ? HARD_D_REGNUM : HARD_X_REGNUM))
1125 #define LIBCALL_VALUE(MODE) \
1126 gen_rtx (REG, MODE, \
1127 (((MODE) == BLKmode || GET_MODE_SIZE (MODE) <= 2) \
1128 ? HARD_D_REGNUM : HARD_X_REGNUM))
1130 /* 1 if N is a possible register number for a function value. */
1131 #define FUNCTION_VALUE_REGNO_P(N) \
1132 ((N) == HARD_D_REGNUM || (N) == HARD_X_REGNUM)
1134 /* Register in which address to store a structure value is passed to a
1135 function. */
1136 #define STRUCT_VALUE_REGNUM HARD_D_REGNUM
1138 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1139 the stack pointer does not matter. The value is tested only in functions
1140 that have frame pointers. No definition is equivalent to always zero. */
1141 #define EXIT_IGNORE_STACK 0
1144 /* Generating Code for Profiling. */
1146 /* Output assembler code to FILE to increment profiler label # LABELNO
1147 for profiling a function entry. */
1148 #define FUNCTION_PROFILER(FILE, LABELNO) \
1149 fprintf (FILE, "\tldy\t.LP%d\n\tjsr mcount\n", (LABELNO))
1150 /* Length in units of the trampoline for entering a nested function. */
1151 #define TRAMPOLINE_SIZE (TARGET_M6811 ? 11 : 9)
1153 /* A C statement to initialize the variable parts of a trampoline.
1154 ADDR is an RTX for the address of the trampoline; FNADDR is an
1155 RTX for the address of the nested function; STATIC_CHAIN is an
1156 RTX for the static chain value that should be passed to the
1157 function when it is called. */
1158 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
1159 m68hc11_initialize_trampoline ((TRAMP), (FNADDR), (CXT))
1162 /* `INIT_TARGET_OPTABS'
1163 Define this macro as a C statement that declares additional library
1164 routines renames existing ones. `init_optabs' calls this macro
1165 after initializing all the normal library routines.
1167 Overrides the memcpy */
1169 #define INIT_TARGET_OPTABS \
1170 do \
1172 memcpy_libfunc = gen_rtx_SYMBOL_REF (Pmode, "__memcpy"); \
1173 memcmp_libfunc = gen_rtx_SYMBOL_REF (Pmode, "__memcmp"); \
1174 memset_libfunc = gen_rtx_SYMBOL_REF (Pmode, "__memset"); \
1176 while (0)
1179 /* Addressing modes, and classification of registers for them. */
1181 /* The 68HC12 has all the post/pre increment/decrement modes. */
1182 #define HAVE_POST_INCREMENT (TARGET_M6812 && TARGET_AUTO_INC_DEC)
1183 #define HAVE_PRE_INCREMENT (TARGET_M6812 && TARGET_AUTO_INC_DEC)
1184 #define HAVE_POST_DECREMENT (TARGET_M6812 && TARGET_AUTO_INC_DEC)
1185 #define HAVE_PRE_DECREMENT (TARGET_M6812 && TARGET_AUTO_INC_DEC)
1187 /* The class value for base registers. This depends on the target:
1188 A_REGS for 68HC11 and A_OR_SP_REGS for 68HC12. The class value
1189 is stored at init time. */
1190 extern enum reg_class m68hc11_base_reg_class;
1191 #define BASE_REG_CLASS m68hc11_base_reg_class
1193 /* The class value for index registers. This is NO_REGS for 68HC11. */
1195 extern enum reg_class m68hc11_index_reg_class;
1196 #define INDEX_REG_CLASS m68hc11_index_reg_class
1198 /* These assume that REGNO is a hard or pseudo reg number. They give nonzero
1199 only if REGNO is a hard reg of the suitable class or a pseudo reg currently
1200 allocated to a suitable hard reg. Since they use reg_renumber, they are
1201 safe only once reg_renumber has been allocated, which happens in
1202 local-alloc.c. */
1205 /* Internal macro, return 1 if REGNO is a valid base register. */
1206 #define REG_VALID_P(REGNO) (1) /* ? */
1208 extern unsigned char m68hc11_reg_valid_for_base[FIRST_PSEUDO_REGISTER];
1209 #define REG_VALID_FOR_BASE_P(REGNO) \
1210 (REG_VALID_P (REGNO) && (REGNO) < FIRST_PSEUDO_REGISTER \
1211 && m68hc11_reg_valid_for_base[REGNO])
1213 /* Internal macro, return 1 if REGNO is a valid index register. */
1214 extern unsigned char m68hc11_reg_valid_for_index[FIRST_PSEUDO_REGISTER];
1215 #define REG_VALID_FOR_INDEX_P(REGNO) \
1216 (REG_VALID_P (REGNO) >= 0 && (REGNO) < FIRST_PSEUDO_REGISTER \
1217 && m68hc11_reg_valid_for_index[REGNO])
1219 /* Internal macro, the nonstrict definition for REGNO_OK_FOR_BASE_P. */
1220 #define REGNO_OK_FOR_BASE_NONSTRICT_P(REGNO) \
1221 ((REGNO) >= FIRST_PSEUDO_REGISTER \
1222 || REG_VALID_FOR_BASE_P (REGNO) \
1223 || (REGNO) == FRAME_POINTER_REGNUM \
1224 || (REGNO) == HARD_FRAME_POINTER_REGNUM \
1225 || (REGNO) == ARG_POINTER_REGNUM \
1226 || (reg_renumber && REG_VALID_FOR_BASE_P (reg_renumber[REGNO])))
1228 /* Internal macro, the nonstrict definition for REGNO_OK_FOR_INDEX_P. */
1229 #define REGNO_OK_FOR_INDEX_NONSTRICT_P(REGNO) \
1230 (TARGET_M6812 \
1231 && ((REGNO) >= FIRST_PSEUDO_REGISTER \
1232 || REG_VALID_FOR_INDEX_P (REGNO) \
1233 || (reg_renumber && REG_VALID_FOR_INDEX_P (reg_renumber[REGNO]))))
1235 /* Internal macro, the strict definition for REGNO_OK_FOR_BASE_P. */
1236 #define REGNO_OK_FOR_BASE_STRICT_P(REGNO) \
1237 ((REGNO) < FIRST_PSEUDO_REGISTER ? REG_VALID_FOR_BASE_P (REGNO) \
1238 : (reg_renumber && REG_VALID_FOR_BASE_P (reg_renumber[REGNO])))
1240 /* Internal macro, the strict definition for REGNO_OK_FOR_INDEX_P. */
1241 #define REGNO_OK_FOR_INDEX_STRICT_P(REGNO) \
1242 (TARGET_M6812 \
1243 && ((REGNO) < FIRST_PSEUDO_REGISTER ? REG_VALID_FOR_INDEX_P (REGNO) \
1244 : (reg_renumber && REG_VALID_FOR_INDEX_P (reg_renumber[REGNO]))))
1246 #define REGNO_OK_FOR_BASE_P2(REGNO,STRICT) \
1247 ((STRICT) ? (REGNO_OK_FOR_BASE_STRICT_P (REGNO)) \
1248 : (REGNO_OK_FOR_BASE_NONSTRICT_P (REGNO)))
1250 #define REGNO_OK_FOR_INDEX_P2(REGNO,STRICT) \
1251 ((STRICT) ? (REGNO_OK_FOR_INDEX_STRICT_P (REGNO)) \
1252 : (REGNO_OK_FOR_INDEX_NONSTRICT_P (REGNO)))
1254 #define REGNO_OK_FOR_BASE_P(REGNO) REGNO_OK_FOR_BASE_STRICT_P (REGNO)
1255 #define REGNO_OK_FOR_INDEX_P(REGNO) REGNO_OK_FOR_INDEX_STRICT_P (REGNO)
1257 #define REG_OK_FOR_BASE_STRICT_P(X) REGNO_OK_FOR_BASE_STRICT_P (REGNO (X))
1258 #define REG_OK_FOR_BASE_NONSTRICT_P(X) REGNO_OK_FOR_BASE_NONSTRICT_P (REGNO (X))
1259 #define REG_OK_FOR_INDEX_STRICT_P(X) REGNO_OK_FOR_INDEX_STRICT_P (REGNO (X))
1260 #define REG_OK_FOR_INDEX_NONSTRICT_P(X) REGNO_OK_FOR_INDEX_NONSTRICT_P (REGNO (X))
1262 /* see PUSH_POP_ADDRESS_P() below for an explanation of this. */
1263 #define IS_STACK_PUSH(operand) \
1264 ((GET_CODE (operand) == MEM) \
1265 && (GET_CODE (XEXP (operand, 0)) == PRE_DEC) \
1266 && (SP_REG_P (XEXP (XEXP (operand, 0), 0))))
1268 #define IS_STACK_POP(operand) \
1269 ((GET_CODE (operand) == MEM) \
1270 && (GET_CODE (XEXP (operand, 0)) == POST_INC) \
1271 && (SP_REG_P (XEXP (XEXP (operand, 0), 0))))
1273 /* 1 if X is an rtx for a constant that is a valid address. */
1274 #define CONSTANT_ADDRESS_P(X) (CONSTANT_P (X))
1276 /* Maximum number of registers that can appear in a valid memory address */
1277 #define MAX_REGS_PER_ADDRESS 2
1279 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression that is a
1280 valid memory address for an instruction. The MODE argument is the
1281 machine mode for the MEM expression that wants to use this address. */
1283 /*--------------------------------------------------------------
1284 Valid addresses are either direct or indirect (MEM) versions
1285 of the following forms:
1286 constant N
1287 register ,X
1288 indexed N,X
1289 --------------------------------------------------------------*/
1291 /* The range of index that is allowed by indirect addressing. */
1293 #define VALID_MIN_OFFSET m68hc11_min_offset
1294 #define VALID_MAX_OFFSET m68hc11_max_offset
1296 /* The offset values which are allowed by the n,x and n,y addressing modes.
1297 Take into account the size of the mode because we may have to add
1298 a mode offset to access the lowest part of the data.
1299 (For example, for an SImode, the last valid offset is 252.) */
1300 #define VALID_CONSTANT_OFFSET_P(X,MODE) \
1301 (((GET_CODE (X) == CONST_INT) && \
1302 ((INTVAL (X) >= VALID_MIN_OFFSET) \
1303 && ((INTVAL (X) <= VALID_MAX_OFFSET \
1304 - (HOST_WIDE_INT) (GET_MODE_SIZE (MODE) + 1))))) \
1305 || (TARGET_M6812 \
1306 && ((GET_CODE (X) == SYMBOL_REF) \
1307 || GET_CODE (X) == LABEL_REF \
1308 || GET_CODE (X) == CONST)))
1310 /* This is included to allow stack push/pop operations. Special hacks in the
1311 md and m6811.c files exist to support this. */
1312 #define PUSH_POP_ADDRESS_P(X) \
1313 (((GET_CODE (X) == PRE_DEC) || (GET_CODE (X) == POST_INC)) \
1314 && SP_REG_P (XEXP (X, 0)))
1316 /* Go to ADDR if X is a valid address. */
1317 #ifndef REG_OK_STRICT
1318 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
1320 if (m68hc11_go_if_legitimate_address ((X), (MODE), 0)) goto ADDR; \
1322 #else
1323 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
1325 if (m68hc11_go_if_legitimate_address ((X), (MODE), 1)) goto ADDR; \
1327 #endif
1329 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx and check its
1330 validity for a certain class. We have two alternate definitions for each
1331 of them. The usual definition accepts all pseudo regs; the other rejects
1332 them unless they have been allocated suitable hard regs. The symbol
1333 REG_OK_STRICT causes the latter definition to be used.
1335 Most source files want to accept pseudo regs in the hope that they will
1336 get allocated to the class that the insn wants them to be in. Source files
1337 for reload pass need to be strict. After reload, it makes no difference,
1338 since pseudo regs have been eliminated by then. */
1340 #ifndef REG_OK_STRICT
1341 /* Nonzero if X is a hard reg that can be used as a base reg. */
1342 #define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_NONSTRICT_P(X)
1344 /* Nonzero if X is a hard reg that can be used as an index. */
1345 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_NONSTRICT_P(X)
1346 #else
1347 #define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_STRICT_P(X)
1348 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_STRICT_P(X)
1349 #endif
1352 /* Try machine-dependent ways of modifying an illegitimate address
1353 to be legitimate. If we find one, return the new, valid address.
1354 This macro is used in only one place: `memory_address' in explow.c.
1356 OLDX is the address as it was before break_out_memory_refs was called.
1357 In some cases it is useful to look at this to decide what needs to be done.
1359 MODE and WIN are passed so that this macro can use
1360 GO_IF_LEGITIMATE_ADDRESS.
1362 It is always safe for this macro to do nothing.
1363 It exists to recognize opportunities to optimize the output. */
1365 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
1366 { rtx operand = (X); \
1367 if (m68hc11_legitimize_address (&operand, (OLDX), (MODE))) \
1369 (X) = operand; \
1370 GO_IF_LEGITIMATE_ADDRESS (MODE,X,WIN); \
1374 /* Go to LABEL if ADDR (a legitimate address expression)
1375 has an effect that depends on the machine mode it is used for. */
1376 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1378 if (GET_CODE (ADDR) == PRE_DEC || GET_CODE (ADDR) == POST_DEC \
1379 || GET_CODE (ADDR) == PRE_INC || GET_CODE (ADDR) == POST_INC) \
1380 goto LABEL; \
1383 /* Nonzero if the constant value X is a legitimate general operand.
1384 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
1386 #define LEGITIMATE_CONSTANT_P(X) 1
1389 /* Tell final.c how to eliminate redundant test instructions. */
1391 #define NOTICE_UPDATE_CC(EXP, INSN) \
1392 m68hc11_notice_update_cc ((EXP), (INSN))
1394 /* An expression giving the cost of an addressing mode that contains
1395 ADDRESS. */
1397 #define ADDRESS_COST(RTX) m68hc11_address_cost (RTX)
1399 /* Move costs between classes of registers */
1400 #define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \
1401 (m68hc11_register_move_cost (MODE, CLASS1, CLASS2))
1403 /* Move cost between register and memory.
1404 - Move to a 16-bit register is reasonable,
1405 - Move to a soft register can be expensive. */
1406 #define MEMORY_MOVE_COST(MODE,CLASS,IN) \
1407 m68hc11_memory_move_cost ((MODE),(CLASS),(IN))
1409 /* A C expression for the cost of a branch instruction. A value of 1
1410 is the default; other values are interpreted relative to that.
1412 Pretend branches are cheap because GCC generates sub-optimal code
1413 for the default value. */
1414 #define BRANCH_COST 0
1416 /* Nonzero if access to memory by bytes is slow and undesirable. */
1417 #define SLOW_BYTE_ACCESS 0
1419 /* It is as good to call a constant function address as to call an address
1420 kept in a register. */
1421 #define NO_FUNCTION_CSE
1423 /* Try a machine-dependent way of reloading an illegitimate address
1424 operand. If we find one, push the reload and jump to WIN. This
1425 macro is used in only one place: `find_reloads_address' in reload.c.
1427 For M68HC11, we handle large displacements of a base register
1428 by splitting the addend accors an addhi3 insn.
1430 For M68HC12, the 64K offset range is available.
1433 #define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN) \
1434 do { \
1435 /* We must recognize output that we have already generated ourselves. */ \
1436 if (GET_CODE (X) == PLUS \
1437 && GET_CODE (XEXP (X, 0)) == PLUS \
1438 && GET_CODE (XEXP (XEXP (X, 0), 0)) == REG \
1439 && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT \
1440 && GET_CODE (XEXP (X, 1)) == CONST_INT) \
1442 push_reload (XEXP (X, 0), NULL_RTX, &XEXP (X, 0), NULL, \
1443 BASE_REG_CLASS, GET_MODE (X), VOIDmode, 0, 0, \
1444 OPNUM, TYPE); \
1445 goto WIN; \
1447 if (GET_CODE (X) == PLUS \
1448 && GET_CODE (XEXP (X, 0)) == REG \
1449 && GET_CODE (XEXP (X, 1)) == CONST_INT \
1450 && !VALID_CONSTANT_OFFSET_P (XEXP (X, 1), MODE)) \
1452 HOST_WIDE_INT val = INTVAL (XEXP (X, 1)); \
1453 HOST_WIDE_INT low, high; \
1454 high = val & (~0x0FF); \
1455 low = val & 0x00FF; \
1456 if (low >= 256-15) { high += 16; low -= 16; } \
1457 /* Reload the high part into a base reg; leave the low part \
1458 in the mem directly. */ \
1460 X = gen_rtx_PLUS (Pmode, \
1461 gen_rtx_PLUS (Pmode, XEXP (X, 0), \
1462 GEN_INT (high)), \
1463 GEN_INT (low)); \
1465 push_reload (XEXP (X, 0), NULL_RTX, &XEXP (X, 0), NULL, \
1466 BASE_REG_CLASS, GET_MODE (X), VOIDmode, 0, 0, \
1467 OPNUM, TYPE); \
1468 goto WIN; \
1470 } while (0)
1473 /* Defining the Output Assembler Language. */
1475 /* A default list of other sections which we might be "in" at any given
1476 time. For targets that use additional sections (e.g. .tdesc) you
1477 should override this definition in the target-specific file which
1478 includes this file. */
1480 /* Output before read-only data. */
1481 #define TEXT_SECTION_ASM_OP ("\t.sect\t.text")
1483 /* Output before writable data. */
1484 #define DATA_SECTION_ASM_OP ("\t.sect\t.data")
1486 /* Output before uninitialized data. */
1487 #define BSS_SECTION_ASM_OP ("\t.sect\t.bss")
1489 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
1491 Same as config/elfos.h but don't mark these section SHF_WRITE since
1492 there is no shared library problem. */
1493 #undef CTORS_SECTION_ASM_OP
1494 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"a\""
1496 #undef DTORS_SECTION_ASM_OP
1497 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"a\""
1499 #define TARGET_ASM_CONSTRUCTOR m68hc11_asm_out_constructor
1500 #define TARGET_ASM_DESTRUCTOR m68hc11_asm_out_destructor
1502 /* This is how to begin an assembly language file. Most svr4 assemblers want
1503 at least a .file directive to come first, and some want to see a .version
1504 directive come right after that. Here we just establish a default
1505 which generates only the .file directive. If you need a .version
1506 directive for any specific target, you should override this definition
1507 in the target-specific file which includes this one. */
1509 #undef ASM_FILE_START
1510 #define ASM_FILE_START(FILE) \
1511 m68hc11_asm_file_start ((FILE), main_input_filename)
1513 /* Comment character */
1514 #define ASM_COMMENT_START ";"
1516 /* Output to assembler file text saying following lines
1517 may contain character constants, extra white space, comments, etc. */
1518 #define ASM_APP_ON "; Begin inline assembler code\n#APP\n"
1520 /* Output to assembler file text saying following lines
1521 no longer contain unusual constructs. */
1522 #define ASM_APP_OFF "; End of inline assembler code\n#NO_APP\n"
1524 /* Write the extra assembler code needed to declare a function properly.
1525 Some svr4 assemblers need to also have something extra said about the
1526 function's return value. We allow for that here.
1528 For 68HC12 we mark functions that return with 'rtc'. The linker
1529 will ensure that a 'call' is really made (instead of 'jsr').
1530 The debugger needs this information to correctly compute the stack frame.
1532 For 68HC11/68HC12 we also mark interrupt handlers for gdb to
1533 compute the correct stack frame. */
1535 #undef ASM_DECLARE_FUNCTION_NAME
1536 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
1537 do \
1539 fprintf (FILE, "%s", TYPE_ASM_OP); \
1540 assemble_name (FILE, NAME); \
1541 putc (',', FILE); \
1542 fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
1543 putc ('\n', FILE); \
1545 if (TARGET_M6812 && current_function_far) \
1547 fprintf (FILE, "\t.far\t"); \
1548 assemble_name (FILE, NAME); \
1549 putc ('\n', FILE); \
1551 else if (current_function_interrupt \
1552 || current_function_trap) \
1554 fprintf (FILE, "\t.interrupt\t"); \
1555 assemble_name (FILE, NAME); \
1556 putc ('\b', FILE); \
1558 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
1559 ASM_OUTPUT_LABEL(FILE, NAME); \
1561 while (0)
1563 /* Output #ident as a .ident. */
1565 /* output external reference */
1566 #define ASM_OUTPUT_EXTERNAL(FILE,DECL,NAME) \
1567 {fputs ("\t; extern\t", FILE); \
1568 assemble_name (FILE, NAME); \
1569 fputs ("\n", FILE);}
1571 /* How to refer to registers in assembler output. This sequence is indexed
1572 by compiler's hard-register-number (see above). */
1573 #define REGISTER_NAMES \
1574 { "x", "d", "y", "sp", "pc", "a", "b", "ccr", "z", \
1575 "*_.frame", "*_.tmp", "*_.z", "*_.xy", "*fake clobber", \
1576 SOFT_REG_NAMES, "*sframe", "*ap"}
1578 /* Print an instruction operand X on file FILE. CODE is the code from the
1579 %-spec for printing this operand. If `%z3' was used to print operand
1580 3, then CODE is 'z'. */
1582 #define PRINT_OPERAND(FILE, X, CODE) \
1583 print_operand (FILE, X, CODE)
1585 /* Print a memory operand whose address is X, on file FILE. */
1586 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
1587 print_operand_address (FILE, ADDR)
1589 /* This is how to output an insn to push/pop a register on the stack.
1590 It need not be very fast code.
1592 Don't define because we don't know how to handle that with
1593 the STATIC_CHAIN_REGNUM (soft register). Saving the static
1594 chain must be made inside FUNCTION_PROFILER. */
1596 #undef ASM_OUTPUT_REG_PUSH
1597 #undef ASM_OUTPUT_REG_POP
1599 /* This is how to output an element of a case-vector that is relative. */
1601 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
1602 fprintf (FILE, "\t%s\tL%d-L%d\n", integer_asm_op (2, TRUE), VALUE, REL)
1604 /* This is how to output an element of a case-vector that is absolute. */
1605 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
1606 fprintf (FILE, "\t%s\t.L%d\n", integer_asm_op (2, TRUE), VALUE)
1608 /* This is how to output an assembler line that says to advance the
1609 location counter to a multiple of 2**LOG bytes. */
1610 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
1611 do { \
1612 if ((LOG) > 1) \
1613 fprintf ((FILE), "%s\n", ALIGN_ASM_OP); \
1614 } while (0)
1617 /* Assembler Commands for Exception Regions. */
1619 /* Default values provided by GCC should be ok. Assumming that DWARF-2
1620 frame unwind info is ok for this platform. */
1622 #undef PREFERRED_DEBUGGING_TYPE
1623 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
1625 /* The prefix for local labels. You should be able to define this as
1626 an empty string, or any arbitrary string (such as ".", ".L%", etc)
1627 without having to make any other changes to account for the specific
1628 definition. Note it is a string literal, not interpreted by printf
1629 and friends. */
1630 #define LOCAL_LABEL_PREFIX "."
1632 /* The prefix for immediate operands. */
1633 #define IMMEDIATE_PREFIX "#"
1634 #define GLOBAL_ASM_OP "\t.globl\t"
1637 /* Miscellaneous Parameters. */
1639 /* Define the codes that are matched by predicates in m68hc11.c. */
1640 #define PREDICATE_CODES \
1641 {"stack_register_operand", {SUBREG, REG}}, \
1642 {"d_register_operand", {SUBREG, REG}}, \
1643 {"hard_addr_reg_operand", {SUBREG, REG}}, \
1644 {"hard_reg_operand", {SUBREG, REG}}, \
1645 {"m68hc11_logical_operator", {AND, IOR, XOR}}, \
1646 {"m68hc11_arith_operator", {AND, IOR, XOR, PLUS, MINUS, \
1647 ASHIFT, ASHIFTRT, LSHIFTRT, \
1648 ROTATE, ROTATERT }}, \
1649 {"m68hc11_non_shift_operator", {AND, IOR, XOR, PLUS, MINUS}}, \
1650 {"m68hc11_unary_operator", {NEG, NOT, SIGN_EXTEND, ZERO_EXTEND}}, \
1651 {"non_push_operand", {SUBREG, REG, MEM}}, \
1652 {"reg_or_some_mem_operand", {SUBREG, REG, MEM}}, \
1653 {"tst_operand", {SUBREG, REG, MEM}}, \
1654 {"cmp_operand", {SUBREG, REG, MEM, SYMBOL_REF, LABEL_REF, \
1655 CONST_INT, CONST_DOUBLE}},
1657 /* Specify the machine mode that this machine uses
1658 for the index in the tablejump instruction. */
1659 #define CASE_VECTOR_MODE Pmode
1661 /* This flag, if defined, says the same insns that convert to a signed fixnum
1662 also convert validly to an unsigned one. */
1663 #define FIXUNS_TRUNC_LIKE_FIX_TRUNC
1665 /* Max number of bytes we can move from memory to memory in one
1666 reasonably fast instruction. */
1667 #define MOVE_MAX 2
1669 /* MOVE_RATIO is the number of move instructions that is better than a
1670 block move. Make this small on 6811, since the code size grows very
1671 large with each move. */
1672 #define MOVE_RATIO 3
1674 /* Define if shifts truncate the shift count which implies one can omit
1675 a sign-extension or zero-extension of a shift count. */
1676 #define SHIFT_COUNT_TRUNCATED 1
1678 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1679 is done just by pretending it is already truncated. */
1680 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1682 /* Specify the machine mode that pointers have. After generation of rtl, the
1683 compiler makes no further distinction between pointers and any other
1684 objects of this machine mode. */
1685 #define Pmode HImode
1687 /* A function address in a call instruction is a byte address (for indexing
1688 purposes) so give the MEM rtx a byte's mode. */
1689 #define FUNCTION_MODE QImode
1691 /* Allow $ in identifiers */
1692 #define DOLLARS_IN_IDENTIFIERS 1
1694 /* Machine-dependent reorg pass.
1695 Specific optimizations are defined here:
1696 - this pass changes the Z register into either X or Y
1697 (it preserves X/Y previous values in a memory slot in page0).
1699 When this pass is finished, the global variable
1700 'z_replacement_completed' is set to 2. */
1701 #define MACHINE_DEPENDENT_REORG(X) m68hc11_reorg (X)
1703 extern int debug_m6811;
1704 extern int z_replacement_completed;
1705 extern int current_function_interrupt;
1706 extern int current_function_trap;
1707 extern int current_function_far;
1709 extern GTY(()) rtx m68hc11_compare_op0;
1710 extern GTY(()) rtx m68hc11_compare_op1;
1711 extern GTY(()) rtx m68hc11_soft_tmp_reg;
1712 extern GTY(()) rtx ix_reg;
1713 extern GTY(()) rtx iy_reg;
1714 extern GTY(()) rtx d_reg;