OSDN Git Service

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