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