OSDN Git Service

abb50c97dff4975125917522385db18e74d2ec20
[pf3gnuchains/gcc-fork.git] / gcc / config / mn10200 / mn10200.h
1 /* Definitions of target machine for GNU compiler. Matsushita MN10200 series
2    Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
3    Contributed by Jeff Law (law@cygnus.com).
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 #include "svr4.h"
23
24 /* Get rid of svr4.h stuff we don't want/need.  */
25 #undef ASM_SPEC
26 #undef ASM_FINAL_SPEC
27 #undef LIB_SPEC
28 #undef ENDFILE_SPEC
29 #undef LINK_SPEC
30 #undef STARTFILE_SPEC
31
32 /* Names to predefine in the preprocessor for this target machine.  */
33
34 #define CPP_PREDEFINES "-D__mn10200__ -D__MN10200__ -D__LONG_MAX__=2147483647L -D__LONG_LONG_MAX__=2147483647L -D__INT_MAX__=32767"
35
36 /* Run-time compilation parameters selecting different hardware subsets.  */
37
38 /* We don't have any switched on the mn10200.  Though there are some things
39    that might be worth a switch:
40
41    -mspace to optimize even more for space.
42
43    -mrelax to enable the relaxing linker.  */
44
45 extern int target_flags;
46
47 /* Macros used in the machine description to test the flags.  */
48
49 /* Macro to define tables used to set the flags.
50    This is a list in braces of pairs in braces,
51    each pair being { "NAME", VALUE }
52    where VALUE is the bits to set or minus the bits to clear.
53    An empty string NAME is used to identify the default VALUE.  */
54
55 #define TARGET_SWITCHES  \
56   {{ "", TARGET_DEFAULT}}
57
58 #ifndef TARGET_DEFAULT
59 #define TARGET_DEFAULT 0
60 #endif
61
62 /* Print subsidiary information on the compiler version in use.  */
63
64 #define TARGET_VERSION fprintf (stderr, " (MN10200)");
65
66 \f
67 /* Target machine storage layout */
68
69 /* Define this if most significant bit is lowest numbered
70    in instructions that operate on numbered bit-fields.
71    This is not true on the Matsushita MN10300.  */
72 #define BITS_BIG_ENDIAN 0
73
74 /* Define this if most significant byte of a word is the lowest numbered.  */
75 /* This is not true on the Matsushita MN10200.  */
76 #define BYTES_BIG_ENDIAN 0
77
78 /* Define this if most significant word of a multiword number is lowest
79    numbered.
80    This is not true on the Matsushita MN10200.  */
81 #define WORDS_BIG_ENDIAN 0
82
83 /* Number of bits in an addressable storage unit */
84 #define BITS_PER_UNIT 8
85
86 /* Width in bits of a "word", which is the contents of a machine register.
87    Note that this is not necessarily the width of data type `int';
88    if using 16-bit ints on a 68000, this would still be 32.
89    But on a machine with 16-bit registers, this would be 16.
90
91    This is a white lie.  Registers are really 24bits, but most operations
92    only operate on 16 bits.   GCC chokes badly if we set this to a value
93    that is not a power of two.  */
94 #define BITS_PER_WORD           16
95
96 /* Width of a word, in units (bytes).  */
97 #define UNITS_PER_WORD          2
98
99 /* Width in bits of a pointer.
100    See also the macro `Pmode' defined below.
101
102    This differs from Pmode because we need to allocate 32bits of space
103    to hold the 24bit pointers on this machine.  */
104 #define POINTER_SIZE            32
105
106 /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
107 #define PARM_BOUNDARY           16
108
109 /* The stack goes in 16 bit lumps.  */
110 #define STACK_BOUNDARY          16
111
112 /* Allocation boundary (in *bits*) for the code of a function.
113    8 is the minimum boundary; it's unclear if bigger alignments
114    would improve performance.  */
115 #define FUNCTION_BOUNDARY 8
116
117 /* No data type wants to be aligned rounder than this.   */
118 #define BIGGEST_ALIGNMENT       16
119
120 /* Alignment of field after `int : 0' in a structure.  */
121 #define EMPTY_FIELD_BOUNDARY 16
122
123 /* Seems to be how the Matsushita compiler does things, and there's
124    no real reason to be different.  */
125 #define STRUCTURE_SIZE_BOUNDARY 16
126 #undef PCC_BITFIELD_TYPE_MATTERS
127
128 /* Define this if move instructions will actually fail to work
129    when given unaligned data.  */
130 #define STRICT_ALIGNMENT 1
131
132 /* Define this as 1 if `char' should by default be signed; else as 0.  */
133 #define DEFAULT_SIGNED_CHAR 0
134
135 /* Define results of standard character escape sequences.  */
136 #define TARGET_BELL 007
137 #define TARGET_BS 010
138 #define TARGET_TAB 011
139 #define TARGET_NEWLINE 012
140 #define TARGET_VT 013
141 #define TARGET_FF 014
142 #define TARGET_CR 015
143 \f
144 /* Standard register usage.  */
145
146 /* Number of actual hardware registers.
147    The hardware registers are assigned numbers for the compiler
148    from 0 to just below FIRST_PSEUDO_REGISTER.
149
150    All registers that the compiler knows about must be given numbers,
151    even those that are not normally considered general registers.
152
153    XXX Long term we should probably expose the MDR register, we use
154    it for division, multiplication, and some extension operations.  */
155
156 #define FIRST_PSEUDO_REGISTER 8
157
158 /* 1 for registers that have pervasive standard uses
159    and are not available for the register allocator.  */
160
161 #define FIXED_REGISTERS \
162   { 0, 0, 0, 0, 0, 0, 0, 1}
163
164 /* 1 for registers not available across function calls.
165    These must include the FIXED_REGISTERS and also any
166    registers that can be used without being saved.
167    The latter must include the registers where values are returned
168    and the register where structure-value addresses are passed.
169    Aside from that, you can include as many other registers as you
170    like.  */
171
172 #define CALL_USED_REGISTERS \
173   { 1, 1, 0, 0, 1, 0, 0, 1}
174
175 #define REG_ALLOC_ORDER \
176   { 0, 1, 4, 2, 3, 5, 6, 7}
177
178 /* Return number of consecutive hard regs needed starting at reg REGNO
179    to hold something of mode MODE.
180
181    This is ordinarily the length in words of a value of mode MODE
182    but can be less for certain modes in special long registers.  */
183
184 #define HARD_REGNO_NREGS(REGNO, MODE)   \
185   ((MODE) == PSImode ? 1 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
186                             / UNITS_PER_WORD))
187
188 /* Value is 1 if hard register REGNO can hold a value of machine-mode
189    MODE.
190
191    We allow any register to hold a PSImode value.  We allow any register
192    to hold values <= 16 bits.  For values > 16 bits we require aligned
193    register pairs.  */
194 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
195  ((MODE) == PSImode ? 1 : ((REGNO) & 1) == 0 || GET_MODE_SIZE (MODE) <= 2)
196
197 /* Value is 1 if it is a good idea to tie two pseudo registers
198    when one has mode MODE1 and one has mode MODE2.
199    If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
200    for any hard reg, then this must be 0 for correct output.  */
201 #define MODES_TIEABLE_P(MODE1, MODE2) \
202   (MODE1 == MODE2 || (GET_MODE_SIZE (MODE1) <= 2 && GET_MODE_SIZE (MODE2) <= 2))
203
204 /* 4 data, and effectively 2 address registers is small as far as I'm
205    concerned.  Especially since we use 2 data registers for argument
206    passing and return values.
207
208    We used to define CLASS_LIKELY_SPILLED_P as true for DATA_REGS too,
209    but we've made improvements to the port which greatly reduce register
210    pressure.  As a result we no longer need to define CLASS_LIKELY_SPILLED_P
211    for DATA_REGS (and by not defining it we get significantly better code).  */
212 #define SMALL_REGISTER_CLASSES 1
213 #define CLASS_LIKELY_SPILLED_P(CLASS) (CLASS == ADDRESS_REGS)
214 \f
215 /* Define the classes of registers for register constraints in the
216    machine description.  Also define ranges of constants.
217
218    One of the classes must always be named ALL_REGS and include all hard regs.
219    If there is more than one class, another class must be named NO_REGS
220    and contain no registers.
221
222    The name GENERAL_REGS must be the name of a class (or an alias for
223    another name such as ALL_REGS).  This is the class of registers
224    that is allowed by "g" or "r" in a register constraint.
225    Also, registers outside this class are allocated only when
226    instructions express preferences for them.
227
228    The classes must be numbered in nondecreasing order; that is,
229    a larger-numbered class must never be contained completely
230    in a smaller-numbered class.
231
232    For any two classes, it is very desirable that there be another
233    class that represents their union.  */
234    
235 enum reg_class {
236   NO_REGS, DATA_REGS, ADDRESS_REGS, GENERAL_REGS, ALL_REGS, LIM_REG_CLASSES
237 };
238
239 #define N_REG_CLASSES (int) LIM_REG_CLASSES
240
241 /* Give names of register classes as strings for dump file.   */
242
243 #define REG_CLASS_NAMES \
244 { "NO_REGS", "DATA_REGS", "ADDRESS_REGS", \
245   "GENERAL_REGS", "ALL_REGS", "LIM_REGS" }
246
247 /* Define which registers fit in which classes.
248    This is an initializer for a vector of HARD_REG_SET
249    of length N_REG_CLASSES.  */
250
251 #define REG_CLASS_CONTENTS                      \
252 {     0,                /* No regs      */      \
253    0x0f,                /* DATA_REGS */         \
254    0xf0,                /* ADDRESS_REGS */      \
255    0xff,                /* GENERAL_REGS */      \
256    0xff,                /* ALL_REGS     */      \
257 }
258
259 /* The same information, inverted:
260    Return the class number of the smallest class containing
261    reg number REGNO.  This could be a conditional expression
262    or could index an array.  */
263
264 #define REGNO_REG_CLASS(REGNO) \
265   ((REGNO) < 4 ? DATA_REGS : ADDRESS_REGS)
266
267 /* The class value for index registers, and the one for base regs.  */
268
269 #define INDEX_REG_CLASS DATA_REGS
270 #define BASE_REG_CLASS  ADDRESS_REGS
271
272 /* Get reg_class from a letter such as appears in the machine description.  */
273
274 #define REG_CLASS_FROM_LETTER(C) \
275   ((C) == 'd' ? DATA_REGS : \
276    (C) == 'a' ? ADDRESS_REGS : NO_REGS)
277
278 /* Macros to check register numbers against specific register classes.  */
279
280 /* These assume that REGNO is a hard or pseudo reg number.
281    They give nonzero only if REGNO is a hard reg of the suitable class
282    or a pseudo reg currently allocated to a suitable hard reg.
283    Since they use reg_renumber, they are safe only once reg_renumber
284    has been allocated, which happens in local-alloc.c.  */
285  
286 #define REGNO_OK_FOR_BASE_P(regno) \
287   (((regno) > 3 && regno < FIRST_PSEUDO_REGISTER)       \
288    || (reg_renumber[regno] > 3 && reg_renumber[regno] < FIRST_PSEUDO_REGISTER))
289
290 #define REGNO_OK_FOR_INDEX_P(regno) \
291   (((regno) >= 0 && regno < 4)  \
292    || (reg_renumber[regno] >= 0 && reg_renumber[regno] < 4))
293
294
295 /* Given an rtx X being reloaded into a reg required to be
296    in class CLASS, return the class of reg to actually use.
297    In general this is just CLASS; but on some machines
298    in some cases it is preferable to use a more restrictive class.  */
299
300 #define PREFERRED_RELOAD_CLASS(X,CLASS) \
301   ((GET_MODE (X) != PSImode) ? DATA_REGS : CLASS)
302
303 /* We want to use DATA_REGS for anything that is not PSImode.  */
304 #define LIMIT_RELOAD_CLASS(MODE, CLASS) \
305   ((MODE != PSImode) ? DATA_REGS : CLASS)
306
307 /* We have/need secondary reloads on the mn10200.  Mostly to deal
308    with problems using address registers.  */
309 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS,MODE,IN) \
310   secondary_reload_class(CLASS,MODE,IN, 1)
311
312 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,IN) \
313   secondary_reload_class(CLASS,MODE,IN, 0)
314
315 /* Return the maximum number of consecutive registers
316    needed to represent mode MODE in a register of class CLASS.  */
317
318 #define CLASS_MAX_NREGS(CLASS, MODE)    \
319   ((MODE) == PSImode ? 1 : (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
320
321 /* The letters I, J, K, L, M, N, O, P in a register constraint string
322    can be used to stand for particular ranges of immediate operands.
323    This macro defines what the ranges are.
324    C is the letter, and VALUE is a constant value.
325    Return 1 if VALUE is in the range specified by C.  */
326
327 #define INT_8_BITS(VALUE) ((unsigned) (VALUE) + 0x80 < 0x100)
328 #define INT_16_BITS(VALUE) ((unsigned) (VALUE) + 0x8000 < 0x10000)
329
330 #define CONST_OK_FOR_I(VALUE) ((VALUE) == 0)
331 #define CONST_OK_FOR_J(VALUE) ((VALUE) >= 1 && (VALUE) <= 3)
332 #define CONST_OK_FOR_K(VALUE) ((VALUE) >= 1 && (VALUE) <= 4)
333 #define CONST_OK_FOR_L(VALUE) ((VALUE) == 15)
334 #define CONST_OK_FOR_M(VALUE) ((VALUE) == 255)
335
336 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
337   ((C) == 'I' ? CONST_OK_FOR_I (VALUE) : \
338    (C) == 'J' ? CONST_OK_FOR_J (VALUE) : \
339    (C) == 'K' ? CONST_OK_FOR_K (VALUE) : \
340    (C) == 'L' ? CONST_OK_FOR_L (VALUE) : \
341    (C) == 'M' ? CONST_OK_FOR_M (VALUE) : 0)
342
343 /* Similar, but for floating constants, and defining letters G and H.
344    Here VALUE is the CONST_DOUBLE rtx itself. 
345      
346   `G' is a floating-point zero.  */
347
348 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
349   ((C) == 'G' ? (GET_MODE_CLASS (GET_MODE (VALUE)) == MODE_FLOAT        \
350                  && (VALUE) == CONST0_RTX (GET_MODE (VALUE)))           \
351    : 0)
352
353
354 \f
355 /* Stack layout; function entry, exit and calling.  */
356
357 /* Define this if pushing a word on the stack
358    makes the stack pointer a smaller address.  */
359
360 #define STACK_GROWS_DOWNWARD
361
362 /* Define this if the nominal address of the stack frame
363    is at the high-address end of the local variables;
364    that is, each additional local variable allocated
365    goes at a more negative offset in the frame.  */
366
367 #define FRAME_GROWS_DOWNWARD
368
369 /* Offset within stack frame to start allocating local variables at.
370    If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
371    first local allocated.  Otherwise, it is the offset to the BEGINNING
372    of the first local allocated.  */
373
374 #define STARTING_FRAME_OFFSET 0
375
376 /* Offset of first parameter from the argument pointer register value.  */
377 /* Is equal to the size of the saved fp + pc, even if an fp isn't
378    saved since the value is used before we know.  */
379
380 #define FIRST_PARM_OFFSET(FNDECL) (current_function_needs_context ? 8 : 4)
381
382 /* Specify the registers used for certain standard purposes.
383    The values of these macros are register numbers.  */
384
385 /* Register to use for pushing function arguments.  */
386 #define STACK_POINTER_REGNUM 7
387
388 /* Base register for access to local variables of the function.  */
389 #define FRAME_POINTER_REGNUM 6
390
391 /* Base register for access to arguments of the function.  */
392 #define ARG_POINTER_REGNUM 6
393
394 /* Register in which static-chain is passed to a function.  */
395 #define STATIC_CHAIN_REGNUM 4
396
397 /* Value should be nonzero if functions must have frame pointers.
398    Zero means the frame pointer need not be set up (and parms
399    may be accessed via the stack pointer) in functions that seem suitable.
400    This is computed in `reload', in reload1.c.
401
402    We allow frame pointers to be eliminated when not having one will
403    not interfere with debugging.  */
404 #define ACCUMULATE_OUTGOING_ARGS
405 #define FRAME_POINTER_REQUIRED 0
406 #define CAN_DEBUG_WITHOUT_FP
407
408 /* Store in the variable DEPTH the initial difference between the
409    frame pointer reg contents and the stack pointer reg contents,
410    as of the start of the function body.  This depends on the layout
411    of the fixed parts of the stack frame and on how registers are saved.  */
412
413 #define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = total_frame_size()
414
415 /* Various type size information.
416
417    The mn10200 has a limited number of small registers.  Sizes of basic
418    data types are adjusted accordingly.  */
419 #define SHORT_TYPE_SIZE         16
420 #define INT_TYPE_SIZE           16
421 #define LONG_TYPE_SIZE          32
422 #define LONG_LONG_TYPE_SIZE     32
423 #define FLOAT_TYPE_SIZE         32
424 #define DOUBLE_TYPE_SIZE        32
425 #define LONG_DOUBLE_TYPE_SIZE   DOUBLE_TYPE_SIZE
426
427 /* Any size less than 64bits will work; but a smarter definition
428    can make G++ code smaller and faster.  Most operations on the
429    mn10200 occur on 16bit hunks, so the best size for a boolean
430    is 16bits.  */
431 #define BOOL_TYPE_SIZE          16
432
433 /* The difference of two pointers must be at least 24bits since pointers
434    are 24bits; however, no basic data type is 24bits, so we have to round
435    up to a 32bits for the difference of pointers.  */
436 #undef SIZE_TYPE
437 #undef PTRDIFF_TYPE
438 #define SIZE_TYPE "long unsigned int"
439 #define PTRDIFF_TYPE "long unsigned int"
440
441 /* Note sizeof (WCHAR_TYPE) must be equal to the value of WCHAR_TYPE_SIZE!  */
442 #undef WCHAR_TYPE
443 #define WCHAR_TYPE "int"
444
445 #undef WCHAR_TYPE_SIZE
446 #define WCHAR_TYPE_SIZE BITS_PER_WORD
447
448 #define MAX_FIXED_MODE_SIZE     32
449
450 /* A guess for the MN10200.  */
451 #define PROMOTE_PROTOTYPES 1
452
453 /* Value is the number of bytes of arguments automatically
454    popped when returning from a subroutine call.
455    FUNDECL is the declaration node of the function (as a tree),
456    FUNTYPE is the data type of the function (as a tree),
457    or for a library call it is an identifier node for the subroutine name.
458    SIZE is the number of bytes of arguments passed on the stack.  */
459
460 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
461
462 /* 1 if N is a possible register number for function argument passing.  */
463
464 #define FUNCTION_ARG_REGNO_P(N) ((N) <= 1)
465 \f
466 /* Define a data type for recording info about an argument list
467    during the scan of that argument list.  This data type should
468    hold all necessary information about the function itself
469    and about the args processed so far, enough to enable macros
470    such as FUNCTION_ARG to determine where the next arg should go.  */
471
472 #define CUMULATIVE_ARGS struct cum_arg
473 struct cum_arg { int nbytes; };
474
475 /* Initialize a variable CUM of type CUMULATIVE_ARGS
476    for a call to a function whose data type is FNTYPE.
477    For a library call, FNTYPE is 0.
478
479    On the MN10200, the offset starts at 0.  */
480
481 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT)       \
482  ((CUM).nbytes = 0)
483
484 /* Update the data in CUM to advance over an argument
485    of mode MODE and data type TYPE.
486    (TYPE is null for libcalls where that information may not be available.)  */
487
488 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)    \
489  ((CUM).nbytes += ((MODE) != BLKmode                    \
490         ? (MODE) == PSImode ? 2 :                       \
491             (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) & -UNITS_PER_WORD \
492         : (int_size_in_bytes (TYPE) + UNITS_PER_WORD - 1) & -UNITS_PER_WORD))
493
494 /* Define where to put the arguments to a function.
495    Value is zero to push the argument on the stack,
496    or a hard register in which to store the argument.
497
498    MODE is the argument's machine mode.
499    TYPE is the data type of the argument (as a tree).
500     This is null for libcalls where that information may
501     not be available.
502    CUM is a variable of type CUMULATIVE_ARGS which gives info about
503     the preceding args and about the function being called.
504    NAMED is nonzero if this argument is a named parameter
505     (otherwise it is an extra parameter matching an ellipsis).  */
506
507 extern struct rtx_def *function_arg();
508 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
509   function_arg (&CUM, MODE, TYPE, NAMED)
510
511 /* Implement `va_arg'.  */
512 extern struct rtx_def *mn10200_va_arg();
513 #define EXPAND_BUILTIN_VA_ARG(valist, type) \
514   mn10200_va_arg (valist, type)
515 \f
516 /* For "large" items, we pass them by invisible reference, and the
517    callee is responsible for copying the data item if it might be
518    modified.  */
519 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED)          \
520   ((TYPE) && int_size_in_bytes (TYPE) > 8)
521  
522 #define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) \
523   ((TYPE) && int_size_in_bytes (TYPE) > 8)
524
525 /* Define how to find the value returned by a function.
526    VALTYPE is the data type of the value (as a tree).
527    If the precise function being called is known, FUNC is its FUNCTION_DECL;
528    otherwise, FUNC is 0.   */
529    
530 #define FUNCTION_VALUE(VALTYPE, FUNC) \
531   gen_rtx_REG (TYPE_MODE (VALTYPE), TYPE_MODE (VALTYPE) == PSImode ? 4 : 0)
532
533 /* Define how to find the value returned by a library function
534    assuming the value has mode MODE.  */
535
536 #define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, (MODE) == PSImode ? 4 : 0)
537
538 /* 1 if N is a possible register number for a function value.  */
539
540 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0 || (N) == 4)
541
542 /* Return values > 8 bytes in length in memory.  */
543 #define DEFAULT_PCC_STRUCT_RETURN 0
544 #define RETURN_IN_MEMORY(TYPE)  \
545   (int_size_in_bytes (TYPE) > 8 || TYPE_MODE (TYPE) == BLKmode)
546
547 /* Register in which address to store a structure value
548    is passed to a function.  On the MN10200 it's passed as
549    the first parameter.  */
550
551 #define STRUCT_VALUE 0
552
553 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
554    the stack pointer does not matter.  The value is tested only in
555    functions that have frame pointers.
556    No definition is equivalent to always zero.  */
557
558 #define EXIT_IGNORE_STACK 1
559
560 /* Output assembler code to FILE to increment profiler label # LABELNO
561    for profiling a function entry.
562
563    ?!? Profiling is not currently supported.  */
564
565 #define FUNCTION_PROFILER(FILE, LABELNO) ;
566
567 /* Yes, we actually support trampolines on this machine, even though
568    nobody is likely to ever use them.  */
569 #define TRAMPOLINE_TEMPLATE(FILE)                       \
570   do {                                                  \
571     fprintf (FILE, "\t.byte 0xfd\n");                   \
572     fprintf (FILE, "\t.byte 0x00\n");                   \
573     fprintf (FILE, "\t.byte 0x00\n");                   \
574     fprintf (FILE, "\tmov (a3),a0\n");                  \
575     fprintf (FILE, "\tadd -4,a3\n");                    \
576     fprintf (FILE, "\tmov a0,(0,a3)\n");                \
577     fprintf (FILE, "\tmov (21,a0),a0\n");               \
578     fprintf (FILE, "\tmov a0,(4,a3)\n");                \
579     fprintf (FILE, "\tmov (0,a3),a0\n");                \
580     fprintf (FILE, "\tmov (17,a0),a0\n");               \
581     fprintf (FILE, "\tadd 4,a3\n");                     \
582     fprintf (FILE, "\trts\n");                          \
583     fprintf (FILE, "\t.long 0\n");                      \
584     fprintf (FILE, "\t.long 0\n");                      \
585   } while (0)
586
587 /* Length in units of the trampoline for entering a nested function.  */
588
589 #define TRAMPOLINE_SIZE 0x1c
590
591 /* Emit RTL insns to initialize the variable parts of a trampoline.
592    FNADDR is an RTX for the address of the function's pure code.
593    CXT is an RTX for the static chain value for the function.  */
594
595 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)                       \
596 {                                                                       \
597   emit_move_insn (gen_rtx_MEM (PSImode, plus_constant ((TRAMP), 20)),   \
598                   (CXT));                                               \
599   emit_move_insn (gen_rtx_MEM (PSImode, plus_constant ((TRAMP), 24)),   \
600                   (FNADDR));                                            \
601 }
602
603 /* A C expression whose value is RTL representing the value of the return
604    address for the frame COUNT steps up from the current frame.  */
605
606 #define RETURN_ADDR_RTX(COUNT, FRAME)   \
607   ((COUNT == 0)                         \
608    ? gen_rtx_MEM (Pmode, frame_pointer_rtx) \
609    : (rtx) 0)
610
611
612 /* Addressing modes, and classification of registers for them.  */
613
614 \f
615 /* 1 if X is an rtx for a constant that is a valid address.  */
616
617 #define CONSTANT_ADDRESS_P(X)   CONSTANT_P (X)
618
619 /* Extra constraints.  */
620 #define OK_FOR_R(OP) \
621    (GET_CODE (OP) == MEM                                        \
622     && GET_MODE (OP) == QImode                                  \
623     && REG_P (XEXP (OP, 0)))
624  
625 /* Q is used for sp + <something> in the {zero,sign}_extendpsisi2 patterns.  */
626 #define EXTRA_CONSTRAINT(OP, C) \
627  ((C) == 'R' ? OK_FOR_R (OP) : \
628   (C) == 'S' ? GET_CODE (OP) == SYMBOL_REF : \
629   (C) == 'Q' ? GET_CODE (OP) == PLUS : 0)
630
631 /* Maximum number of registers that can appear in a valid memory address.  */
632
633 #define MAX_REGS_PER_ADDRESS 2
634
635 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
636    and check its validity for a certain class.
637    We have two alternate definitions for each of them.
638    The usual definition accepts all pseudo regs; the other rejects
639    them unless they have been allocated suitable hard regs.
640    The symbol REG_OK_STRICT causes the latter definition to be used.
641
642    Most source files want to accept pseudo regs in the hope that
643    they will get allocated to the class that the insn wants them to be in.
644    Source files for reload pass need to be strict.
645    After reload, it makes no difference, since pseudo regs have
646    been eliminated by then.  */
647
648 #ifndef REG_OK_STRICT
649 /* Nonzero if X is a hard reg that can be used as an index
650    or if it is a pseudo reg.  */
651 #define REG_OK_FOR_INDEX_P(X)  \
652   (((REGNO (X) >= 0 && REGNO(X) <= 3) || REGNO (X) >= FIRST_PSEUDO_REGISTER))
653 /* Nonzero if X is a hard reg that can be used as a base reg
654    or if it is a pseudo reg.  */
655 #define REG_OK_FOR_BASE_P(X) \
656   (((REGNO (X) >= 4 && REGNO(X) <= 8) || REGNO (X) >= FIRST_PSEUDO_REGISTER))
657 #else
658 /* Nonzero if X is a hard reg that can be used as an index.  */
659 #define REG_OK_FOR_INDEX_P(X) \
660   REGNO_OK_FOR_INDEX_P (REGNO (X))
661 /* Nonzero if X is a hard reg that can be used as a base reg.  */
662 #define REG_OK_FOR_BASE_P(X) \
663   REGNO_OK_FOR_BASE_P (REGNO (X))
664 #endif
665
666 \f
667 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
668    that is a valid memory address for an instruction.
669    The MODE argument is the machine mode for the MEM expression
670    that wants to use this address.
671
672    We used to allow reg+reg addresses for QImode and HImode; however,
673    they tended to cause the register allocator to run out of registers.
674    Basically, an indexed load/store always keeps 2 data and one address
675    register live, which is just too many for this machine.
676
677    The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
678    except for CONSTANT_ADDRESS_P which is actually machine-independent.  */
679
680 /* Accept either REG or SUBREG where a register is valid.  */
681   
682 #define RTX_OK_FOR_BASE_P(X)                                    \
683   ((REG_P (X) && REG_OK_FOR_BASE_P (X))                         \
684    || (GET_CODE (X) == SUBREG && REG_P (SUBREG_REG (X))         \
685        && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
686
687 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)         \
688 {                                                       \
689   if ((MODE != PSImode) && CONSTANT_ADDRESS_P (X))      \
690     goto ADDR;                                          \
691   if (RTX_OK_FOR_BASE_P (X))                            \
692     goto ADDR;                                          \
693   if (GET_CODE (X) == PLUS)                             \
694     {                                                   \
695       rtx base = 0, index = 0;                          \
696       if (RTX_OK_FOR_BASE_P (XEXP (X, 0)))              \
697         base = XEXP (X, 0), index = XEXP (X, 1);        \
698       if (RTX_OK_FOR_BASE_P (XEXP (X, 1)))              \
699         base = XEXP (X, 1), index = XEXP (X, 0);        \
700       if (base != 0 && index != 0)                      \
701         {                                               \
702           if (GET_CODE (index) == CONST_INT)            \
703             goto ADDR;                                  \
704         }                                               \
705     }                                                   \
706 }
707
708 \f
709 /* Try machine-dependent ways of modifying an illegitimate address
710    to be legitimate.  If we find one, return the new, valid address.
711    This macro is used in only one place: `memory_address' in explow.c.
712
713    OLDX is the address as it was before break_out_memory_refs was called.
714    In some cases it is useful to look at this to decide what needs to be done.
715
716    MODE and WIN are passed so that this macro can use
717    GO_IF_LEGITIMATE_ADDRESS.
718
719    It is always safe for this macro to do nothing.  It exists to recognize
720    opportunities to optimize the output.   */
721
722 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN)  {}
723
724 /* Go to LABEL if ADDR (a legitimate address expression)
725    has an effect that depends on the machine mode it is used for.  */
726
727 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)  {}
728
729 /* Nonzero if the constant value X is a legitimate general operand.
730    It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.  */
731
732 #define LEGITIMATE_CONSTANT_P(X) 1
733
734 \f
735 /* Tell final.c how to eliminate redundant test instructions.  */
736
737 /* Here we define machine-dependent flags and fields in cc_status
738    (see `conditions.h').  No extra ones are needed for the vax.  */
739
740 /* Store in cc_status the expressions
741    that the condition codes will describe
742    after execution of an instruction whose pattern is EXP.
743    Do not alter them if the instruction would not alter the cc's.  */
744
745 #define CC_OVERFLOW_UNUSABLE 0x200
746 #define CC_NO_CARRY CC_NO_OVERFLOW
747 #define NOTICE_UPDATE_CC(EXP, INSN) notice_update_cc(EXP, INSN)
748
749 /* The mn10200 has a limited number of registers, so CSE of function
750    addresses generally makes code worse due to register pressure.  */
751 #define NO_FUNCTION_CSE
752
753 /* Compute the cost of computing a constant rtl expression RTX
754    whose rtx-code is CODE.  The body of this macro is a portion
755    of a switch statement.  If the code is computed here,
756    return it with a return statement.  Otherwise, break from the switch.  */
757
758 #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
759   case CONST_INT:                                                       \
760     /* Zeros are extremely cheap.  */                                   \
761     if (INTVAL (RTX) == 0)                                              \
762       return 0;                                                         \
763     /* If it fits in 8 bits, then it's still relatively cheap.  */      \
764     if (INT_8_BITS (INTVAL (RTX)))                                      \
765       return 1;                                                         \
766     /* This is the "base" cost, includes constants where either the     \
767        upper or lower 16bits are all zeros.  */                         \
768     if (INT_16_BITS (INTVAL (RTX))                                      \
769         || (INTVAL (RTX) & 0xffff) == 0                                 \
770         || (INTVAL (RTX) & 0xffff0000) == 0)                            \
771       return 2;                                                         \
772     return 4;                                                           \
773   /* These are more costly than a CONST_INT, but we can relax them,     \
774      so they're less costly than a CONST_DOUBLE.  */                    \
775   case CONST:                                                           \
776   case LABEL_REF:                                                       \
777   case SYMBOL_REF:                                                      \
778     return 6;                                                           \
779   /* We don't optimize CONST_DOUBLEs well nor do we relax them well,    \
780      so their cost is very high.  */                                    \
781   case CONST_DOUBLE:                                                    \
782     return 8;
783
784 /* Make moves between different classes more expensive than moves
785    within the same class.  */
786 #define REGISTER_MOVE_COST(CLASS1, CLASS2)  (CLASS1 != CLASS2 ? 4 : 2)
787
788 /* Provide the costs of a rtl expression.  This is in the body of a
789    switch on CODE. 
790
791    ?!? This probably needs more work.  The definitions below were first
792    taken from the H8 port, then tweaked slightly to improve code density
793    on various sample codes.  */
794
795 #define RTX_COSTS(RTX,CODE,OUTER_CODE) \
796   case MOD:                                             \
797   case DIV:                                             \
798     return 8;                                           \
799   case MULT:                                            \
800     return (GET_MODE (RTX) == SImode ? 20 : 8);
801
802 /* Nonzero if access to memory by bytes or half words is no faster
803    than accessing full words.  */
804 #define SLOW_BYTE_ACCESS 1
805
806 /* According expr.c, a value of around 6 should minimize code size, and
807    for the MN10200 series, code size our primary concern.  */
808 #define MOVE_RATIO 6
809
810 #define TEXT_SECTION_ASM_OP "\t.section .text"
811 #define DATA_SECTION_ASM_OP "\t.section .data"
812 #define BSS_SECTION_ASM_OP "\t.section .bss"
813
814 /* Output at beginning/end of assembler file.  */
815 #undef ASM_FILE_START
816 #define ASM_FILE_START(FILE) asm_file_start(FILE)
817
818 #define ASM_COMMENT_START "#"
819
820 /* Output to assembler file text saying following lines
821    may contain character constants, extra white space, comments, etc.  */
822
823 #define ASM_APP_ON "#APP\n"
824
825 /* Output to assembler file text saying following lines
826    no longer contain unusual constructs.  */
827
828 #define ASM_APP_OFF "#NO_APP\n"
829
830 /* This is how to output an assembler line defining a `double' constant.
831    It is .dfloat or .gfloat, depending.  */
832
833 #define ASM_OUTPUT_DOUBLE(FILE, VALUE)                  \
834 do { char dstr[30];                                     \
835      REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr);    \
836      fprintf (FILE, "\t.double %s\n", dstr);            \
837    } while (0)
838
839
840 /* This is how to output an assembler line defining a `float' constant.  */
841 #define ASM_OUTPUT_FLOAT(FILE, VALUE)                   \
842 do { char dstr[30];                                     \
843      REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", dstr);    \
844      fprintf (FILE, "\t.float %s\n", dstr);             \
845    } while (0)
846
847 /* This is how to output an assembler line defining an `int' constant.  */
848
849 #define ASM_OUTPUT_INT(FILE, VALUE)             \
850 ( fprintf (FILE, "\t.long "),                   \
851   output_addr_const (FILE, (VALUE)),            \
852   fprintf (FILE, "\n"))
853
854 /* Likewise for `char' and `short' constants.  */
855
856 #define ASM_OUTPUT_SHORT(FILE, VALUE)           \
857 ( fprintf (FILE, "\t.hword "),                  \
858   output_addr_const (FILE, (VALUE)),            \
859   fprintf (FILE, "\n"))
860
861 #define ASM_OUTPUT_CHAR(FILE, VALUE)            \
862 ( fprintf (FILE, "\t.byte "),                   \
863   output_addr_const (FILE, (VALUE)),            \
864   fprintf (FILE, "\n"))
865
866 /* This is how to output an assembler line for a numeric constant byte.  */
867 #define ASM_OUTPUT_BYTE(FILE, VALUE)  \
868   fprintf (FILE, "\t.byte 0x%x\n", (VALUE))
869
870 /* Define the parentheses used to group arithmetic operations
871    in assembler code.  */
872
873 #define ASM_OPEN_PAREN "("
874 #define ASM_CLOSE_PAREN ")"
875
876 /* This says how to output the assembler to define a global
877    uninitialized but not common symbol.
878    Try to use asm_output_bss to implement this macro.  */
879
880 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
881   asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
882
883 /* This is how to output the definition of a user-level label named NAME,
884    such as the label on a static function or variable NAME.  */
885
886 #define ASM_OUTPUT_LABEL(FILE, NAME)    \
887   do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
888
889 /* This is how to output a command to make the user-level label named NAME
890    defined for reference from other files.  */
891
892 #define ASM_GLOBALIZE_LABEL(FILE, NAME) \
893   do { fputs ("\t.global ", FILE); assemble_name (FILE, NAME); fputs ("\n", FILE);} while (0)
894
895 /* This is how to output a reference to a user-level label named NAME.
896    `assemble_name' uses this.  */
897
898 #undef ASM_OUTPUT_LABELREF
899 #define ASM_OUTPUT_LABELREF(FILE, NAME)           \
900   do {                                            \
901   const char* real_name;                          \
902   STRIP_NAME_ENCODING (real_name, (NAME));        \
903   fprintf (FILE, "_%s", real_name);               \
904   } while (0)           
905
906 /* Store in OUTPUT a string (made with alloca) containing
907    an assembler-name for a local static variable named NAME.
908    LABELNO is an integer which is different for each call.  */
909
910 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO)  \
911 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10),    \
912   sprintf ((OUTPUT), "%s___%d", (NAME), (LABELNO)))
913
914 /* This is how we tell the assembler that two symbols have the same value.  */
915
916 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
917   do { assemble_name(FILE, NAME1);       \
918        fputs(" = ", FILE);               \
919        assemble_name(FILE, NAME2);       \
920        fputc('\n', FILE); } while (0)
921
922
923 /* How to refer to registers in assembler output.
924    This sequence is indexed by compiler's hard-register-number (see above).  */
925
926 #define REGISTER_NAMES \
927 { "d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3"}
928
929 /* Print an instruction operand X on file FILE.
930    look in mn10200.c for details */
931
932 #define PRINT_OPERAND(FILE, X, CODE)  print_operand(FILE,X,CODE)
933
934 /* Print a memory operand whose address is X, on file FILE.
935    This uses a function in output-vax.c.  */
936
937 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
938
939 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO)
940 #define ASM_OUTPUT_REG_POP(FILE,REGNO)
941
942 /* This is how to output an element of a case-vector that is absolute.  */
943
944 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
945   asm_fprintf (FILE, "\t%s .L%d\n", ".long", VALUE)
946
947 /* This is how to output an element of a case-vector that is relative.  */
948
949 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
950   fprintf (FILE, "\t%s .L%d-.L%d\n", ".long", VALUE, REL)
951
952 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
953   if ((LOG) != 0)                       \
954     fprintf (FILE, "\t.align %d\n", (LOG))
955
956 /* We don't have to worry about dbx compatibility for the mn10200.  */
957 #define DEFAULT_GDB_EXTENSIONS 1
958
959 /* Use stabs debugging info by default.  */
960 #undef PREFERRED_DEBUGGING_TYPE
961 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
962
963 #define DBX_REGISTER_NUMBER(REGNO) REGNO
964
965 /* GDB always assumes the current function's frame begins at the value
966    of the stack pointer upon entry to the current function.  Accessing
967    local variables and parameters passed on the stack is done using the
968    base of the frame + an offset provided by GCC.
969
970    For functions which have frame pointers this method works fine;
971    the (frame pointer) == (stack pointer at function entry) and GCC provides
972    an offset relative to the frame pointer.
973
974    This loses for functions without a frame pointer; GCC provides an offset
975    which is relative to the stack pointer after adjusting for the function's
976    frame size.  GDB would prefer the offset to be relative to the value of
977    the stack pointer at the function's entry.  Yuk!  */
978 #define DEBUGGER_AUTO_OFFSET(X) \
979   ((GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0) \
980     + (frame_pointer_needed ? 0 : -total_frame_size ()))
981
982 #define DEBUGGER_ARG_OFFSET(OFFSET, X) \
983   ((GET_CODE (X) == PLUS ? OFFSET : 0) \
984     + (frame_pointer_needed ? 0 : -total_frame_size ()))
985
986 /* We need to prepend underscores.  */
987 #define ASM_OUTPUT_DWARF2_ADDR_CONST(FILE,ADDR) \
988   fprintf ((FILE), "\t%s\t_%s", UNALIGNED_WORD_ASM_OP, (ADDR))
989   
990 /* Define to use software floating point emulator for REAL_ARITHMETIC and
991    decimal <-> binary conversion. */
992 #define REAL_ARITHMETIC
993
994 /* Specify the machine mode that this machine uses
995    for the index in the tablejump instruction.  */
996 #define CASE_VECTOR_MODE Pmode
997
998 /* Dispatch tables on the mn10200 are extremely expensive in terms of code
999    and readonly data size.  So we crank up the case threshold value to
1000    encourage a series of if/else comparisons to implement many small switch
1001    statements.  In theory, this value could be increased much more if we
1002    were solely optimizing for space, but we keep it "reasonable" to avoid
1003    serious code efficiency lossage.  */
1004 #define CASE_VALUES_THRESHOLD 8
1005
1006 /* Define if operations between registers always perform the operation
1007    on the full register even if a narrower mode is specified.  */
1008 #define WORD_REGISTER_OPERATIONS
1009
1010 /* We could define this either way.  Using ZERO_EXTEND for QImode makes slightly
1011    fast and more compact code.  */
1012 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
1013
1014 /* Specify the tree operation to be used to convert reals to integers.  */
1015 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1016
1017 /* This flag, if defined, says the same insns that convert to a signed fixnum
1018    also convert validly to an unsigned one.  */
1019 #define FIXUNS_TRUNC_LIKE_FIX_TRUNC
1020
1021 /* This is the kind of divide that is easiest to do in the general case.  */
1022 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
1023
1024 /* Max number of bytes we can move from memory to memory
1025    in one reasonably fast instruction.  */
1026 #define MOVE_MAX        2
1027
1028 /* Define if shifts truncate the shift count
1029    which implies one can omit a sign-extension or zero-extension
1030    of a shift count.  */
1031 #define SHIFT_COUNT_TRUNCATED 1
1032
1033 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1034    is done just by pretending it is already truncated.  */
1035 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) (OUTPREC != 32)
1036
1037 /* Specify the machine mode that pointers have.
1038    After generation of rtl, the compiler makes no further distinction
1039    between pointers and any other objects of this machine mode.  */
1040 #define Pmode PSImode
1041
1042 /* A function address in a call instruction
1043    is a byte address (for indexing purposes)
1044    so give the MEM rtx a byte's mode.  */
1045 #define FUNCTION_MODE QImode
1046
1047 /* Perform target dependent optabs initialization.  */
1048 #define MODHI3_LIBCALL "__modhi3"
1049 #define DIVHI3_LIBCALL "__divhi3"
1050
1051 #define INIT_TARGET_OPTABS \
1052   do { \
1053     sdiv_optab->handlers[(int) HImode].libfunc          \
1054       = init_one_libfunc (DIVHI3_LIBCALL);              \
1055     smod_optab->handlers[(int) HImode].libfunc          \
1056       = init_one_libfunc (MODHI3_LIBCALL);              \
1057   } while (0)
1058
1059 /* The assembler op to get a word.  */
1060
1061 #define FILE_ASM_OP "\t.file\n"
1062
1063 #define PREDICATE_CODES                                                 \
1064   {"call_address_operand",      { SYMBOL_REF, REG }},                   \
1065   {"constant_memory_operand",   { MEM }},                               \
1066   {"psimode_truncation_operand",{ PLUS, CONST_INT, CONST_DOUBLE, CONST, \
1067                                   SYMBOL_REF, LABEL_REF, SUBREG, REG, MEM }},\
1068   {"extendpsi_operand",         { PLUS, CONST_INT, CONST_DOUBLE, CONST, \
1069                                   SYMBOL_REF, LABEL_REF, SUBREG, REG, MEM }}, \
1070   {"nshift_operator",           { ASHIFTRT, LSHIFTRT, ASHIFT }},
1071
1072 extern void asm_file_start ();
1073 extern void print_operand ();
1074 extern void print_operand_address ();
1075 extern void expand_prologue ();
1076 extern void expand_epilogue ();
1077 extern void notice_update_cc ();
1078 extern int call_address_operand ();
1079 extern enum reg_class secondary_reload_class ();
1080 extern char *emit_a_shift ();
1081 extern char *output_tst ();
1082 extern int extendpsi_operand ();
1083 extern int psimode_truncation_operand ();
1084 extern struct rtx_def *zero_dreg;
1085 extern struct rtx_def *zero_areg;