OSDN Git Service

* clipper.h (ASM_OUTPUT_REG_POP): Fix typo.
[pf3gnuchains/gcc-fork.git] / gcc / config / clipper / clipper.h
1 /* Definitions of target machine for GNU compiler.  Clipper version.
2    Copyright (C) 1987, 1988, 1991, 1993, 1994, 1995, 1996, 1998,
3    1999, 2000 Free Software Foundation, Inc.
4    Contributed by Holger Teutsch (holger@hotbso.rhein-main.de)
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 /* Print subsidiary information on the compiler version in use.  */
24
25 #define TARGET_VERSION fprintf (stderr, " (clipper)");
26
27 /* Run-time compilation parameters selecting different hardware subsets.  */
28
29 extern int target_flags;
30
31 /* Macros used in the machine description to test the flags.  */
32
33 /* Macro to define tables used to set the flags.
34    This is a list in braces of pairs in braces,
35    each pair being { "NAME", VALUE }
36    where VALUE is the bits to set or minus the bits to clear.
37    An empty string NAME is used to identify the default VALUE.  */
38
39 #define TARGET_SWITCHES                                         \
40   { { "c400", 1, N_("Generate code for the C400") },            \
41     { "c300", -1, N_("Generate code for the C300") },           \
42     { "", TARGET_DEFAULT, NULL} }
43
44 #define TARGET_C400 1
45 #define TARGET_C300 0
46
47 /* Default target_flags if no switches specified.  */
48
49 #ifndef TARGET_DEFAULT
50 #define TARGET_DEFAULT TARGET_C300
51 #endif
52
53 /* Show that we can debug generated code without a frame pointer.  */
54 #define CAN_DEBUG_WITHOUT_FP
55 \f
56 /* Target machine storage layout */
57
58 /* Define this if most significant bit is lowest numbered
59    in instructions that operate on numbered bit-fields. */
60
61 #define BITS_BIG_ENDIAN 0
62
63 /* Define this if most significant byte of a word is the lowest numbered.  */
64
65 #define BYTES_BIG_ENDIAN 0
66
67 /* Define this if most significant word of a multiword number is the lowest
68    numbered.  */
69
70 #define WORDS_BIG_ENDIAN 0
71
72 /* Number of bits in an addressable storage unit */
73 #define BITS_PER_UNIT 8
74
75 /* Width in bits of a "word", which is the contents of a machine register.
76    Note that this is not necessarily the width of data type `int';
77    if using 16-bit ints on a 68000, this would still be 32.
78    But on a machine with 16-bit registers, this would be 16.  */
79 #define BITS_PER_WORD 32
80
81 /* Width of a word, in units (bytes).  */
82 #define UNITS_PER_WORD 4
83
84 /* Width in bits of a pointer.
85    See also the macro `Pmode' defined below.  */
86 #define POINTER_SIZE 32
87
88 /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
89 #define PARM_BOUNDARY 32
90
91 /* Largest alignment for stack parameters (if greater than PARM_BOUNDARY).  */
92 #define MAX_PARM_BOUNDARY 64
93
94 /* Allocation boundary (in *bits*) for the code of a function.  */
95 #define FUNCTION_BOUNDARY 128
96
97 /* Alignment of field after `int : 0' in a structure.  */
98 #define EMPTY_FIELD_BOUNDARY 32
99
100 /* Every structure's size must be a multiple of this.  */
101 #define STRUCTURE_SIZE_BOUNDARY 8
102
103 /* A bitfield declared as `int' forces `int' alignment for the struct.  */
104 #define PCC_BITFIELD_TYPE_MATTERS 1
105
106 /* No data type wants to be aligned rounder than this.  */
107 #define BIGGEST_ALIGNMENT 64
108
109 /* No structure field wants to be aligned rounder than this.  */
110 #define BIGGEST_FIELD_ALIGNMENT 64
111
112 /*  Make strcpy of constants fast. */
113 #define CONSTANT_ALIGNMENT(CODE, TYPEALIGN) \
114   ((TYPEALIGN) < 32 ? 32 : (TYPEALIGN))
115
116 /* Make arrays of chars word-aligned for the same reasons.  */
117 #define DATA_ALIGNMENT(TYPE, ALIGN)             \
118   (TREE_CODE (TYPE) == ARRAY_TYPE               \
119    && TYPE_MODE (TREE_TYPE (TYPE)) == QImode    \
120    && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
121
122 /* Set this nonzero if move instructions will actually fail to work
123    when given unaligned data.  */
124 #define STRICT_ALIGNMENT 1
125
126 /* Let's keep the stack somewhat aligned.  */
127 #define STACK_BOUNDARY 64
128
129 /* Define this macro if it is advisable to hold scalars in registers
130    in a wider mode than that declared by the program.  In such cases, 
131    the value is constrained to be within the bounds of the declared
132    type, but kept valid in the wider mode.  The signedness of the
133    extension may differ from that of the type.
134
135    For Clipper, we always store objects in a full register. */
136
137 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE)  \
138   if (GET_MODE_CLASS (MODE) == MODE_INT         \
139       && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
140     {                                           \
141       (UNSIGNEDP) = 0;                          \
142       (MODE) = SImode;                          \
143     }
144
145
146 /* Define this if function arguments should also be promoted using the above
147    procedure.  */
148
149 /* FIXME: do we loose compatibility to acc if we define this? */
150
151 /* #define PROMOTE_FUNCTION_ARGS */
152
153 /* Likewise, if the function return value is promoted.  */
154
155 /* #define PROMOTE_FUNCTION_RETURN */
156
157 \f
158 /* Standard register usage.  */
159
160 /* Number of actual hardware registers.
161    The hardware registers are assigned numbers for the compiler
162    from 0 to just below FIRST_PSEUDO_REGISTER.
163    All registers that the compiler knows about must be given numbers,
164    even those that are not normally considered general registers.  */
165 #define FIRST_PSEUDO_REGISTER 32
166
167 /* 1 for registers that have pervasive standard uses
168    and are not available for the register allocator.
169    On the clipper, these are the FP and SP .  */
170 #define FIXED_REGISTERS \
171 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,\
172  0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1} /* Default: C300 */
173
174 /* 1 for registers not available across function calls.
175    These must include the FIXED_REGISTERS and also any
176    registers that can be used without being saved.
177    The latter must include the registers where values are returned
178    and the register where structure-value addresses are passed.
179    Aside from that, you can include as many other registers as you like.  */
180 #define CALL_USED_REGISTERS \
181 {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,\
182  1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1} /* default: C300 */
183
184 /* Zero or more C statements that may conditionally modify two
185    variables `fixed_regs' and `call_used_regs' (both of type `char
186    []') after they have been initialized from the two preceding
187    macros. A C400 has additional floating registers f8 -> f15 */
188
189 #define CONDITIONAL_REGISTER_USAGE      \
190    if (target_flags & TARGET_C400)      \
191      { int i;                           \
192        for (i = 24; i < 32; i++) fixed_regs[i] = call_used_regs[i] = 0; }
193
194 /* Return number of consecutive hard regs needed starting at reg REGNO
195    to hold something of mode MODE.
196    This is ordinarily the length in words of a value of mode MODE
197    but can be less for certain modes in special long registers.
198    On the clipper, fp registers are 64 bits.  */
199
200 #define HARD_REGNO_NREGS(REGNO, MODE)   \
201   ((REGNO) >= 16 ? 1 \
202    : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
203
204 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
205    On the clipper 0-15 may hold any mode but DImode and DFmode must be even.
206    Registers 16-31 hold SFmode and DFmode */
207
208 #define HARD_REGNO_MODE_OK(REGNO, MODE)                                 \
209   ((REGNO) < 16                                                         \
210    ? (((MODE) != DImode && (MODE) != DFmode) || ((REGNO) & 1) == 0)     \
211    : ((MODE) == SFmode || (MODE) == DFmode))
212
213 /* Value is 1 if it is a good idea to tie two pseudo registers
214    when one has mode MODE1 and one has mode MODE2.
215    If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
216    for any hard reg, then this must be 0 for correct output.  */
217 #define MODES_TIEABLE_P(MODE1, MODE2)  ((MODE1) == (MODE2))
218
219 /* Specify the registers used for certain standard purposes.
220    The values of these macros are register numbers.  */
221
222 /* clipper has extra PC  */
223 /* #define PC_REGNUM */
224
225 /* Register to use for pushing function arguments.  */
226 #define STACK_POINTER_REGNUM 15
227
228 /* Base register for access to local variables of the function.  */
229 #define FRAME_POINTER_REGNUM 14
230
231 /* Value should be nonzero if functions must have frame pointers.
232    Zero means the frame pointer need not be set up (and parms
233    may be accessed via the stack pointer) in functions that seem suitable.
234    This is computed in `reload', in reload1.c.  */
235 #define FRAME_POINTER_REQUIRED \
236    (! leaf_function_p ())
237
238 /* Base register for access to arguments of the function.  */
239 #define ARG_POINTER_REGNUM FRAME_POINTER_REGNUM
240
241 /* Register in which static-chain is passed to a function.  */
242 #define STATIC_CHAIN_REGNUM 2
243
244 /* Register in which address to store a structure value
245    is passed to a function.  */
246 #define STRUCT_VALUE_REGNUM 0
247 \f
248 /* Define the classes of registers for register constraints in the
249    machine description.  Also define ranges of constants.
250
251    One of the classes must always be named ALL_REGS and include all hard regs.
252    If there is more than one class, another class must be named NO_REGS
253    and contain no registers.
254
255    The name GENERAL_REGS must be the name of a class (or an alias for
256    another name such as ALL_REGS).  This is the class of registers
257    that is allowed by "g" or "r" in a register constraint.
258    Also, registers outside this class are allocated only when
259    instructions express preferences for them.
260
261    The classes must be numbered in nondecreasing order; that is,
262    a larger-numbered class must never be contained completely
263    in a smaller-numbered class.
264
265    For any two classes, it is very desirable that there be another
266    class that represents their union.  */
267    
268 /* The clipper has general and FP regs.  */
269
270 enum reg_class { NO_REGS, GENERAL_REGS, FLOAT_REGS, ALL_REGS, LIM_REG_CLASSES};
271
272 #define N_REG_CLASSES (int) LIM_REG_CLASSES
273
274 /* Give names of register classes as strings for dump file.   */
275
276 #define REG_CLASS_NAMES \
277  {"NO_REGS", "GENERAL_REGS", "FLOAT_REGS", "ALL_REGS" }
278
279 /* Define which registers fit in which classes.
280    This is an initializer for a vector of HARD_REG_SET
281    of length N_REG_CLASSES.  */
282
283 #define REG_CLASS_CONTENTS { {0}, {0x0000ffff}, {0xffff0000}, {0xffffffff} }
284
285 /* The same information, inverted:
286    Return the class number of the smallest class containing
287    reg number REGNO.  This could be a conditional expression
288    or could index an array.  */
289
290 #define REGNO_REG_CLASS(REGNO) ((REGNO) >= 16 ? FLOAT_REGS : GENERAL_REGS)
291
292 /* The class value for index registers, and the one for base regs.  */
293
294 #define INDEX_REG_CLASS GENERAL_REGS
295 #define BASE_REG_CLASS GENERAL_REGS
296
297 /* Get reg_class from a letter such as appears in the machine description.  */
298
299 #define REG_CLASS_FROM_LETTER(C) \
300   ((C) == 'r' ? GENERAL_REGS : ((C) == 'f' ? FLOAT_REGS: NO_REGS))
301
302 /* The letters I, J, K, L and M in a register constraint string
303    can be used to stand for particular ranges of immediate operands.
304    This macro defines what the ranges are.
305    C is the letter, and VALUE is a constant value.
306    Return 1 if VALUE is in the range specified by C. */
307
308 #define CONST_OK_FOR_LETTER_P(VALUE, C) 0
309
310 /* Similar, but for floating constants, and defining letters G and H.
311    Here VALUE is the CONST_DOUBLE rtx itself. */
312
313 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) 0
314
315 /* Optional extra constraints for this machine. */
316
317 /* #define EXTRA_CONSTRAINT(OP, C) */
318
319
320 /* Given an rtx X being reloaded into a reg required to be
321    in class CLASS, return the class of reg to actually use.
322    In general this is just CLASS; but on some machines
323    in some cases it is preferable to use a more restrictive class.  */
324
325 #define PREFERRED_RELOAD_CLASS(X,CLASS)  (CLASS)
326
327 /* Return the maximum number of consecutive registers
328    needed to represent mode MODE in a register of class CLASS.  */
329
330 #define CLASS_MAX_NREGS(CLASS, MODE)    \
331  ((CLASS) == FLOAT_REGS                 \
332   ? 1                                   \
333   : (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
334 \f
335 /* Stack layout; function entry, exit and calling.  */
336
337 /* Define this if pushing a word on the stack
338    makes the stack pointer a smaller address.  */
339 #define STACK_GROWS_DOWNWARD
340
341 /* Define this if longjmp restores from saved registers
342    rather than from what setjmp saved.  */
343 /* #define LONGJMP_RESTORE_FROM_STACK */
344
345 /* Define this if the nominal address of the stack frame
346    is at the high-address end of the local variables;
347    that is, each additional local variable allocated
348    goes at a more negative offset in the frame.  */
349 #define FRAME_GROWS_DOWNWARD
350
351 /* Offset within stack frame to start allocating local variables at.
352    If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
353    first local allocated.  Otherwise, it is the offset to the BEGINNING
354    of the first local allocated.  */
355 #define STARTING_FRAME_OFFSET 0
356
357 /* Given an rtx for the address of a frame,
358    return an rtx for the address of the word in the frame
359    that holds the dynamic chain--the previous frame's address.  */
360 #define DYNAMIC_CHAIN_ADDRESS(frame) (frame)
361
362 /* If we generate an insn to push BYTES bytes,
363    this says how many the stack pointer really advances by. */
364
365 /* #define PUSH_ROUNDING(BYTES) (BYTES) */
366
367 /* Keep the stack pointer constant throughout the function. */
368 /* we can't set this for clipper as library calls may have 3 args and we pass
369    only 2 args in regs. */
370
371 /* #define ACCUMULATE_OUTGOING_ARGS 1*/
372   
373
374 /* Offset of first parameter from the argument pointer register value.
375    size of PC + FP  */
376
377 #define FIRST_PARM_OFFSET(FNDECL) 8
378
379 /* Value is the number of bytes of arguments automatically
380    popped when returning from a subroutine call.
381    FUNDECL is the declaration node of the function (as a tree),
382    FUNTYPE is the data type of the function (as a tree),
383    or for a library call it is an identifier node for the subroutine name.
384    SIZE is the number of bytes of arguments passed on the stack. */
385
386 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
387
388 /* Define how to find the value returned by a function.
389    VALTYPE is the data type of the value (as a tree).
390    If the precise function being called is known, FUNC is its FUNCTION_DECL;
391    otherwise, FUNC is 0.  */
392
393 #define FUNCTION_VALUE(VALTYPE, FUNC)  \
394   gen_rtx_REG (TYPE_MODE (VALTYPE), ((TYPE_MODE (VALTYPE) == SFmode ||\
395                                       TYPE_MODE (VALTYPE) == DFmode) ? \
396                                      16 : 0))
397
398 /* Define how to find the value returned by a library function
399    assuming the value has mode MODE.  */
400
401 #define LIBCALL_VALUE(MODE)  \
402   gen_rtx_REG ((MODE), ((MODE) == SFmode || (MODE) == DFmode ? 16 : 0))
403
404
405 /* 1 if N is a possible register number for a function value
406    as seen by the caller.  */
407
408 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0 || (N) == 16)
409
410 /* 1 if N is a possible register number for function argument passing.  */
411
412 #define FUNCTION_ARG_REGNO_P(N) \
413   ((N) == 0 || (N) == 1 || (N) == 16 || (N) == 17)
414
415 /* Define this if PCC uses the nonreentrant convention for returning
416    structure and union values. Old Green Hills C-Clipper returns static
417    structs but the newer Apogee compiler passes structs as hidden arg 0.
418    Structs etc are always passed in memory */
419
420 /* #define PCC_STATIC_STRUCT_RETURN */
421
422 \f
423 /* Define a data type for recording info about an argument list
424    during the scan of that argument list.  This data type should
425    hold all necessary information about the function itself
426    and about the args processed so far, enough to enable macros
427    such as FUNCTION_ARG to determine where the next arg should go.
428
429    Clipper uses 2 register 'slots' that pass arguments in r0/r1 or f0/f1.
430    An argument that must be passed in memory (struct... ) leaves that slot
431    free.
432    We pass 'long long' only in registers when both slots are free.
433    Returned structs must be allocated by the caller, the address is passed
434    in r0.
435
436    struct ss {..}
437
438    fun (i,j,k)          i in r0, j in r1, k on stack
439    fun (s,j,k)          s on stack, j in r1, k on stack
440    fun (i,s,k)          i in r0, s on stack, k on stack
441    s1 = fun (i,s,k)     &s1 in r0, i in r1, s on stack, k on stack
442
443    We must keep enough information for varargs/stdargs.
444
445    _clipper_cum_args is a struct of 2 integers, with
446         num =  slots used
447         size = size of all stack args = offset to next arg without alignment
448
449    If we use stdarg.h, size points to the first unnamed arg,
450    see va-clipper.h */
451
452 struct _clipper_cum_args { int num; int size; };
453
454 #define CUMULATIVE_ARGS struct _clipper_cum_args
455
456 /* Initialize a variable CUM of type CUMULATIVE_ARGS
457    for a call to a function whose data type is FNTYPE.
458    For a library call, FNTYPE is 0.
459
460    clipper passes the address of a struct in r0, set num = 1 in this case */
461
462 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
463   ((CUM).num = ((FNTYPE) != 0 && aggregate_value_p (TREE_TYPE (FNTYPE))), \
464    (CUM).size = 0)
465
466 /* internal helper : size of an argument */
467
468 #define CLIPPER_ARG_SIZE(MODE, TYPE)                            \
469 (((MODE) != BLKmode                                                     \
470   ? (GET_MODE_SIZE (MODE) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD      \
471   : (int_size_in_bytes (TYPE) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD) \
472  * UNITS_PER_WORD)
473
474 /* Update the data in CUM to advance over an argument
475    of mode MODE and data type TYPE.
476    (TYPE is null for libcalls where that information may not be available.)  */
477
478 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)                          \
479 do                                                                            \
480 {                                                                             \
481   int reg = 0;                                                                \
482                                                                               \
483   if ((CUM).num < 2                                                           \
484       && (GET_MODE_CLASS(MODE)==MODE_INT || GET_MODE_CLASS(MODE)==MODE_FLOAT) \
485       && (GET_MODE_SIZE (MODE) <= 8)                                          \
486       && ((TYPE) == NULL || !AGGREGATE_TYPE_P(TYPE))                          \
487       && ((MODE) != DImode || (CUM).num == 0))                                \
488     {                                                                         \
489       reg = 1;                                                                \
490       if ((MODE) == DImode)                                                   \
491         (CUM).num = 1;                                                        \
492     }                                                                         \
493                                                                               \
494   (CUM).num++;                                                                \
495                                                                               \
496   if (! reg)                                                                  \
497     {                                                                         \
498       int align = FUNCTION_ARG_BOUNDARY (MODE, TYPE) / BITS_PER_UNIT;         \
499       (CUM).size += align - 1;                                                \
500       (CUM).size &= ~(align - 1);                                             \
501       (CUM).size += CLIPPER_ARG_SIZE (MODE, TYPE);                            \
502     }                                                                         \
503 } while (0)
504
505 /* Define where to put the arguments to a function.
506    Value is zero to push the argument on the stack,
507    or a hard register in which to store the argument.
508
509    MODE is the argument's machine mode.
510    TYPE is the data type of the argument (as a tree).
511     This is null for libcalls where that information may
512     not be available.
513    CUM is a variable of type CUMULATIVE_ARGS which gives info about
514     the preceding args and about the function being called.
515    NAMED is nonzero if this argument is a named parameter
516     (otherwise it is an extra parameter matching an ellipsis).
517
518    2 args may go into regs. These must be MODE_INT or MODE_FLOAT but only
519    if they really fit into ONE register. The exception is a DImode arg
520    that occupies both register slots. */
521
522 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED)                                 \
523   (((CUM).num < 2                                                            \
524     && (GET_MODE_CLASS(MODE)==MODE_INT || GET_MODE_CLASS(MODE)==MODE_FLOAT)  \
525     && (GET_MODE_SIZE (MODE) <= 8)                                           \
526     && ((TYPE) == NULL || !AGGREGATE_TYPE_P(TYPE))                           \
527     && ((MODE) != DImode || (CUM).num == 0))                                 \
528    ? gen_rtx_REG ((MODE),                                                    \
529                   GET_MODE_CLASS(MODE) == MODE_FLOAT                         \
530                   ? (CUM).num+16 : (CUM).num)                                \
531    : 0)
532
533 /* If defined, a C expression that gives the alignment boundary, in bits,
534    of an argument with the specified mode and type.  If it is not defined,
535    `PARM_BOUNDARY' is used for all arguments.  */
536
537 #define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \
538   (((TYPE) ? TYPE_ALIGN (TYPE) : GET_MODE_SIZE (MODE)) <= PARM_BOUNDARY \
539     ? PARM_BOUNDARY : 2 * PARM_BOUNDARY)
540
541 /* For an arg passed partly in registers and partly in memory,
542    this is the number of registers used.
543    For args passed entirely in registers or entirely in memory, zero.
544    Clipper never passed args partially in regs/mem. */
545
546 /* #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED)  0 */
547
548 /* Generate necessary RTL for __builtin_saveregs().
549    ARGLIST is the argument list; see expr.c.  */
550
551 #define EXPAND_BUILTIN_SAVEREGS() clipper_builtin_saveregs ()
552
553 /* Output assembler code to FILE to increment profiler label # LABELNO
554    for profiling a function entry.  */
555
556 #define FUNCTION_PROFILER(FILE, LABELNO)  /* FIXME */
557
558 /* Output assembler code to FILE to initialize this source file's
559    basic block profiling info, if that has not already been done.  */
560
561 #define FUNCTION_BLOCK_PROFILER(FILE, LABELNO)  /* FIXME */
562
563 /* Output assembler code to FILE to increment the entry-count for
564    the BLOCKNO'th basic block in this source file.  */
565
566 #define BLOCK_PROFILER(FILE, BLOCKNO)   /* FIXME */
567
568 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
569    the stack pointer does not matter.  The value is tested only in
570    functions that have frame pointers.
571    No definition is equivalent to always zero.  */
572
573 #define EXIT_IGNORE_STACK 1
574
575 /* Store in the variable DEPTH the initial difference between the
576    frame pointer reg contents and the stack pointer reg contents,
577    as of the start of the function body.  This depends on the layout
578    of the fixed parts of the stack frame and on how registers are saved. */
579
580 #define INITIAL_FRAME_POINTER_OFFSET(DEPTH) \
581   DEPTH = clipper_frame_size (get_frame_size ())
582
583
584 /* Output assembler code for a block containing the constant parts
585    of a trampoline, leaving space for the variable parts.  */
586
587 #define TRAMPOLINE_TEMPLATE(FILE)                                             \
588 {                                                                             \
589   fputs ("\t.word  0x459F,0x0004\t# call   sp,.+4\n", FILE);                  \
590   fputs ("\tmovw   (sp),r3\n", FILE);                                         \
591   fputs ("\taddq   $4,sp\n", FILE);                                           \
592   fputs ("\tloadw  20(r3),r2\n", FILE);                                       \
593   fputs ("\tloadw  24(r3),r3\n", FILE);                                       \
594   fputs ("\tb      (r3)\n", FILE);                                            \
595   fputs ("\t.long  0,0\n", FILE);                                             \
596 }
597
598 /* Length in units of the trampoline for entering a nested function.  */
599
600 #define TRAMPOLINE_SIZE 32
601
602 /* Alignment required for a trampoline.  128 is used to find the
603    beginning of a line in the instruction cache and to allow for
604    instruction cache lines of up to 128 bytes.  */
605
606 #define TRAMPOLINE_ALIGNMENT 128
607
608 /* Section in which to place the trampoline.  */
609
610 #define TRAMPOLINE_SECTION text_section
611
612 /* Emit RTL insns to initialize the variable parts of a trampoline.
613    FNADDR is an RTX for the address of the function's pure code.
614    CXT is an RTX for the static chain value for the function.  */
615
616 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)                       \
617 {                                                                       \
618   emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 24)), CXT); \
619   emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 28)), FNADDR); \
620 }
621 \f
622 /* Addressing modes, and classification of registers for them.  */
623
624 /* #define HAVE_POST_DECREMENT 0 */
625
626 /* #define HAVE_PRE_INCREMENT 0 */
627
628 /* Macros to check register numbers against specific register classes.  */
629
630 /* These assume that REGNO is a hard or pseudo reg number.
631    They give nonzero only if REGNO is a hard reg of the suitable class
632    or a pseudo reg currently allocated to a suitable hard reg.
633    Since they use reg_renumber, they are safe only once reg_renumber
634    has been allocated, which happens in local-alloc.c.  */
635
636 #define REGNO_OK_FOR_INDEX_P(regno)  \
637 ((regno) < 16 || (unsigned)reg_renumber[regno] < 16)
638 #define REGNO_OK_FOR_BASE_P(regno) \
639 ((regno) < 16 || (unsigned)reg_renumber[regno] < 16)
640 \f
641 /* Maximum number of registers that can appear in a valid memory address.  */
642
643 #define MAX_REGS_PER_ADDRESS 2
644
645 /* 1 if X is an rtx for a constant that is a valid address.  */
646
647 #define CONSTANT_ADDRESS_P(X)   \
648   (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF              \
649    || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST                \
650    || GET_CODE (X) == HIGH)
651
652 /* Nonzero if the constant value X is a legitimate general operand.
653    It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.  */
654
655 #define LEGITIMATE_CONSTANT_P(X) 1
656
657 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
658    and check its validity for a certain class.
659    We have two alternate definitions for each of them.
660    The usual definition accepts all pseudo regs; the other rejects
661    them unless they have been allocated suitable hard regs.
662    The symbol REG_OK_STRICT causes the latter definition to be used.
663
664    Most source files want to accept pseudo regs in the hope that
665    they will get allocated to the class that the insn wants them to be in.
666    Source files for reload pass need to be strict.
667    After reload, it makes no difference, since pseudo regs have
668    been eliminated by then.  */
669
670   /* clipper doesn't have true indexing */
671
672 #ifndef REG_OK_STRICT
673
674 /* Nonzero if X is a hard reg that can be used as an index
675    or if it is a pseudo reg.  */
676
677 #define REG_OK_FOR_INDEX_P(X) \
678   (REGNO (X) < 16 || REGNO(X) >= FIRST_PSEUDO_REGISTER)
679
680 /* Nonzero if X is a hard reg that can be used as a base reg
681    or if it is a pseudo reg.  */
682
683 #define REG_OK_FOR_BASE_P(X) \
684   (REGNO (X) < 16 || REGNO(X) >= FIRST_PSEUDO_REGISTER)
685
686 #else
687
688 /* Nonzero if X is a hard reg that can be used as an index.  */
689 #define REG_OK_FOR_INDEX_P(X) (REGNO(X) < 16)
690
691 /* Nonzero if X is a hard reg that can be used as a base reg.  */
692 #define REG_OK_FOR_BASE_P(X) (REGNO(X) < 16)
693
694 #endif
695 \f
696 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
697    that is a valid memory address for an instruction.
698    The MODE argument is the machine mode for the MEM expression
699    that wants to use this address.
700
701    The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
702    except for CONSTANT_ADDRESS_P which is actually machine-independent.  */
703
704 /* Non-zero if X is an address which can be indirected. */
705
706 #define INDIRECTABLE_CONSTANT_ADDRESS_P(X) 0
707
708 #define INDIRECTABLE_ADDRESS_P(X)  \
709   (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X))
710
711 /* Go to ADDR if X is a valid address not using indexing.
712    (This much is the easy part.)  */
713
714 #define GO_IF_NONINDEXED_ADDRESS(X, ADDR)       \
715 { if (CONSTANT_ADDRESS_P (X)) goto ADDR;        \
716   if (INDIRECTABLE_ADDRESS_P (X)) goto ADDR; }
717
718 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
719 { register rtx xfoo = (X);                      \
720   GO_IF_NONINDEXED_ADDRESS (xfoo, ADDR);        \
721   if (GET_CODE (xfoo) == PLUS)                  \
722     { register rtx xfoo0, xfoo1;                \
723       xfoo0 = XEXP (xfoo, 0);                   \
724       xfoo1 = XEXP (xfoo, 1);                   \
725     /* handle reg + reg -> [r1](r0) */          \
726       if (INDIRECTABLE_ADDRESS_P (xfoo0) && INDIRECTABLE_ADDRESS_P (xfoo1)) \
727         goto ADDR;                                                      \
728     /* Handle <symbol>(reg) -> xxx(r0) */                               \
729       if (INDIRECTABLE_ADDRESS_P (xfoo0) && CONSTANT_ADDRESS_P (xfoo1)) \
730         goto ADDR;                                                      \
731       if (INDIRECTABLE_ADDRESS_P (xfoo1) && CONSTANT_ADDRESS_P (xfoo0)) \
732         goto ADDR; }}
733
734 \f
735 /* Try machine-dependent ways of modifying an illegitimate address
736    to be legitimate.  If we find one, return the new, valid address.
737    This macro is used in only one place: `memory_address' in explow.c.
738
739    OLDX is the address as it was before break_out_memory_refs was called.
740    In some cases it is useful to look at this to decide what needs to be done.
741
742    MODE and WIN are passed so that this macro can use
743    GO_IF_LEGITIMATE_ADDRESS.
744
745    It is always safe for this macro to do nothing.  It exists to recognize
746    opportunities to optimize the output.
747
748    For the clipper, nothing needs to be done.  */
749
750 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN)  {}
751
752 /* Go to LABEL if ADDR (a legitimate address expression)
753    has an effect that depends on the machine mode it is used for. */
754
755 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) {}
756
757 \f
758 /* Specify the machine mode that this machine uses
759    for the index in the tablejump instruction.  */
760 #define CASE_VECTOR_MODE SImode
761
762 /* Define as C expression which evaluates to nonzero if the tablejump
763    instruction expects the table to contain offsets from the address of the
764    table.
765    Do not define this if the table should contain absolute addresses. */
766 /* #define CASE_VECTOR_PC_RELATIVE 1 */
767
768 /* Define this if the case instruction drops through after the table
769    when the index is out of range.  Don't define it if the case insn
770    jumps to the default label instead.  */
771 /* #define CASE_DROPS_THROUGH */
772
773 /* Define if operations between registers always perform the operation
774    on the full register even if a narrower mode is specified.  */
775 #define WORD_REGISTER_OPERATIONS
776
777 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
778    will either zero-extend or sign-extend.  The value of this macro should
779    be the code that says which one of the two operations is implicitly
780    done, NIL if none.  */
781 #define LOAD_EXTEND_OP(MODE) SIGN_EXTEND
782
783 /* Specify the tree operation to be used to convert reals to integers.  */
784 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
785
786 /* This is the kind of divide that is easiest to do in the general case.  */
787 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
788
789 /* Define this as 1 if `char' should by default be signed; else as 0.  */
790 #define DEFAULT_SIGNED_CHAR 1
791
792 /* This flag, if defined, says the same insns that convert to a signed fixnum
793    also convert validly to an unsigned one.  */
794 #define FIXUNS_TRUNC_LIKE_FIX_TRUNC
795
796 /* Max number of bytes we can move from memory to memory
797    in one reasonably fast instruction.  */
798 #define MOVE_MAX 4
799
800 /* If a memory-to-memory move would take MOVE_RATIO or more simple
801    move-instruction pairs, we will do a movstr or libcall instead.
802
803    Make this large on clipper, since the block move is very
804    inefficient with small blocks, and the hard register needs of the
805    block move require much reload work. */
806
807 #define MOVE_RATIO 20
808
809 /* Define this if zero-extension is slow (more than one real instruction).  */
810 /* #define SLOW_ZERO_EXTEND */
811
812 /* Nonzero if access to memory by bytes is slow and undesirable.  */
813 #define SLOW_BYTE_ACCESS 0
814
815 /* Define if shifts truncate the shift count
816    which implies one can omit a sign-extension or zero-extension
817    of a shift count.  */
818 /* #define SHIFT_COUNT_TRUNCATED */
819
820 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
821    is done just by pretending it is already truncated.  */
822 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
823
824 /* Specify the machine mode that pointers have.
825    After generation of rtl, the compiler makes no further distinction
826    between pointers and any other objects of this machine mode.  */
827 #define Pmode SImode
828
829 /* A function address in a call instruction
830    is a byte address (for indexing purposes)
831    so give the MEM rtx a byte's mode.  */
832 #define FUNCTION_MODE QImode
833
834 /* This machine uses IEEE floats.  */
835
836 #define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
837
838 /* Check a `double' value for validity for a particular machine mode.
839    This is defined to avoid crashes outputting certain constants.
840    Since we output the number in hex, the assembler won't choke on it.  */
841 /* #define CHECK_FLOAT_VALUE(MODE,VALUE) */
842
843
844 /* Compute the cost of computing a constant rtl expression RTX
845    whose rtx-code is CODE.  The body of this macro is a portion
846    of a switch statement.  If the code is computed here,
847    return it with a return statement.  Otherwise, break from the switch.  */
848
849 /* On a Clipper, constants from 0..15 are cheap because they can use the
850    'quick' mode. */
851
852 #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
853   case CONST_INT:                                               \
854     if (0 <= INTVAL (RTX) && INTVAL(RTX) <= 15 ) return 0;      \
855       return 1;                                                 \
856   case CONST:                                                   \
857   case LABEL_REF:                                               \
858   case SYMBOL_REF:                                              \
859     return 3;                                                   \
860   case CONST_DOUBLE:                                            \
861     return 5;
862
863 /* Provide the costs of a rtl expression.  This is in the body of a
864    switch on CODE.  */
865
866 #define RTX_COSTS(X,CODE,OUTER_CODE)                    \
867   case MULT:                                            \
868     return COSTS_N_INSNS (4);                           \
869   case DIV:                                             \
870   case UDIV:                                            \
871   case MOD:                                             \
872   case UMOD:                                            \
873     return COSTS_N_INSNS (40);                          \
874   case ASHIFT:                                          \
875   case LSHIFTRT:                                        \
876   case ASHIFTRT:                                        \
877     return COSTS_N_INSNS (2);                           \
878  case SIGN_EXTEND:                                      \
879     return (GET_CODE (XEXP (X,0)) == REG ? COSTS_N_INSNS (3) : 4);
880
881 /* Specify the cost of a branch insn; roughly the number of extra insns that
882    should be added to avoid a branch */
883
884 /* #define BRANCH_COST 0 */
885
886 \f
887 /* Tell final.c how to eliminate redundant test instructions.  */
888
889 /* Here we define machine-dependent flags and fields in cc_status
890    (see `conditions.h').  No extra ones are needed for the clipper.  */
891
892 /* Store in cc_status the expressions
893    that the condition codes will describe
894    after execution of an instruction whose pattern is EXP.
895    Do not alter them if the instruction would not alter the cc's.  */
896
897 #define NOTICE_UPDATE_CC(EXP, INSN) \
898 {                                                                             \
899   enum attr_cc cc = get_attr_cc (INSN);                                       \
900   rtx dest = SET_DEST (EXP);                                                  \
901   switch (cc)                                                                 \
902     {                                                                         \
903     case CC_CHANGE0:                                                          \
904       if (GET_CODE (EXP) == PARALLEL) abort();                                \
905       if ((cc_status.value1 && rtx_equal_p (dest, cc_status.value1)) ||       \
906           (cc_status.value2 && rtx_equal_p (dest, cc_status.value2)))         \
907         CC_STATUS_INIT;                                                       \
908       break;                                                                  \
909                                                                               \
910     case CC_SET1:                                                             \
911       if (GET_CODE (EXP) == PARALLEL) abort();                                \
912       cc_status.flags = 0;                                                    \
913       cc_status.value1 = dest;                                                \
914       cc_status.value2 = 0;                                                   \
915       break;                                                                  \
916                                                                               \
917     case CC_SET2:                                                             \
918       if (GET_CODE (EXP) == PARALLEL) abort();                                \
919       cc_status.flags = 0;                                                    \
920       cc_status.value1 = dest;                                                \
921       cc_status.value2 = SET_SRC (EXP);                                       \
922       break;                                                                  \
923                                                                               \
924     case CC_UNCHANGED:                                                        \
925       break;                                                                  \
926                                                                               \
927     case CC_CLOBBER:                                                          \
928       CC_STATUS_INIT;                                                         \
929       break;                                                                  \
930                                                                               \
931     default:                                                                  \
932       abort ();                                                               \
933     }                                                                         \
934 }
935
936 \f
937 /* Control the assembler format that we output.  */
938
939 /* Output at beginning of assembler file.  */
940
941 #define ASM_FILE_START(FILE) fprintf (FILE, "#NO_APP\n");
942
943 /* Output to assembler file text saying following lines
944    may contain character constants, extra white space, comments, etc.  */
945
946 #define ASM_APP_ON "#APP\n"
947
948 /* Output to assembler file text saying following lines
949    no longer contain unusual constructs.  */
950
951 #define ASM_APP_OFF "#NO_APP\n"
952
953 /* Output before read-only data.  */
954
955 #define TEXT_SECTION_ASM_OP "\t.text"
956
957 /* Output before writable data.  */
958
959 #define DATA_SECTION_ASM_OP "\t.data"
960
961 /* How to refer to registers in assembler output.
962    This sequence is indexed by compiler's hard-register-number (see above).  */
963
964 #define REGISTER_NAMES \
965 {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", \
966  "r9", "r10", "r11", "r12", "r13", "fp", "sp", \
967  "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", \
968  "f9", "f10", "f11", "f12", "f13", "f14", "f15" }
969
970 /* How to renumber registers for dbx and gdb.
971    Clipper needs no change in the numeration.  */
972
973 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
974
975
976 /* This is how to output the definition of a user-level label named NAME,
977    such as the label on a static function or variable NAME.  */
978
979 #define ASM_OUTPUT_LABEL(FILE,NAME)     \
980   do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
981
982 /* This is how to output a command to make the user-level label named NAME
983    defined for reference from other files.  */
984
985 #define ASM_GLOBALIZE_LABEL(FILE,NAME)  \
986   do { fputs (".globl ", FILE); assemble_name (FILE, NAME); fputs ("\n", FILE);} while (0)
987
988 /* This is how to output an assembler line defining an `int' constant.  */
989
990 #define ASM_OUTPUT_INT(FILE,VALUE)  \
991 ( fprintf (FILE, "\t.long "),                   \
992   output_addr_const (FILE, (VALUE)),            \
993   fprintf (FILE, "\n"))
994
995 /* Likewise for `char' and `short' constants.  */
996
997 #define ASM_OUTPUT_SHORT(FILE,VALUE)  \
998 ( fprintf (FILE, "\t.word "),                   \
999   output_addr_const (FILE, (VALUE)),            \
1000   fprintf (FILE, "\n"))
1001
1002 #define ASM_OUTPUT_CHAR(FILE,VALUE)  \
1003 ( fprintf (FILE, "\t.byte "),                   \
1004   output_addr_const (FILE, (VALUE)),            \
1005   fprintf (FILE, "\n"))
1006
1007 /* This is how to output an assembler line for a numeric constant byte.  */
1008
1009 #define ASM_OUTPUT_BYTE(FILE,VALUE)  \
1010   fprintf (FILE, "\t.byte 0x%x\n", (VALUE))
1011
1012 /* This is how to output an insn to push a register on the stack.
1013    It need not be very fast code.  */
1014
1015 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO)  \
1016   fprintf (FILE, "\tsubq   $8,sp\n\t%s  %s,(sp)\n",     \
1017            (REGNO) < 16 ? "storw" : "stord", reg_names[REGNO])
1018
1019 /* This is how to output an insn to pop a register from the stack.
1020    It need not be very fast code.  */
1021
1022 #define ASM_OUTPUT_REG_POP(FILE,REGNO)  \
1023   fprintf (FILE, "\t%s  (sp),%s\n\taddq  $8,sp\n",      \
1024            (REGNO) < 16 ? "loadw" : "loadd", reg_names[REGNO])
1025 /* This is how to output an element of a case-vector that is absolute */
1026
1027 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE)  \
1028   fprintf (FILE, "\t.long .L%d\n", VALUE)
1029
1030 /* This is how to output an element of a case-vector that is relative.  */
1031
1032 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL)  \
1033   fprintf (FILE, "\t.word .L%d-.L%d\n", VALUE, REL)
1034
1035 /* This is how to output an assembler line
1036    that says to advance the location counter by SIZE bytes.  */
1037
1038 #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
1039   fprintf (FILE, "\t.space %u\n", (SIZE))
1040
1041 /* This says how to output an assembler line
1042    to define a local common symbol.  */
1043 /* ??? The use of .bss here seems odd.  */
1044
1045 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE,NAME,SIZE,ALIGN)  \
1046 ( data_section (),                                      \
1047   fputs ("\t.bss\t", (FILE)),                           \
1048   assemble_name ((FILE), (NAME)),                       \
1049   fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN)/BITS_PER_UNIT))
1050
1051 /* Store in OUTPUT a string (made with alloca) containing
1052    an assembler-name for a local static variable named NAME.
1053    LABELNO is an integer which is different for each call.  */
1054
1055 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO)  \
1056 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10),    \
1057   sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
1058
1059 /* Print an instruction operand X on file FILE.
1060    CODE is the code from the %-spec that requested printing this operand;
1061    if `%z3' was used to print operand 3, then CODE is 'z'.
1062
1063 Clipper operand formatting codes:
1064
1065  letter    print
1066    C    reverse branch condition
1067 */
1068
1069 #define PRINT_OPERAND_PUNCT_VALID_P(CODE)                               \
1070   ((CODE) == 'C')
1071
1072 #define PRINT_OPERAND(FILE, X, CODE)  \
1073 { if (CODE == 'C')                                                      \
1074     fputs (rev_cond_name (X), FILE);                                    \
1075   else if (GET_CODE (X) == REG)                                         \
1076     fprintf (FILE, "%s", reg_names[REGNO (X)]);                         \
1077   else if (GET_CODE (X) == MEM)                                         \
1078     output_address (XEXP (X, 0));                                       \
1079   else { putc ('$', FILE); output_addr_const (FILE, X); }}
1080
1081 /* Print a memory operand whose address is X, on file FILE.
1082    This uses a function in output-clipper.c.  */
1083
1084 #define PRINT_OPERAND_ADDRESS(FILE, ADDR)  \
1085  print_operand_address (FILE, ADDR)
1086
1087 /* Define the codes that are matched by predicates in clipper.c */
1088
1089 #define PREDICATE_CODES \
1090   {"int_reg_operand", {SUBREG, REG}},   \
1091   {"fp_reg_operand", {SUBREG, REG}},
1092 \f
1093 /* Define the `__builtin_va_list' type for the ABI.  */
1094 #define BUILD_VA_LIST_TYPE(VALIST) \
1095   (VALIST) = clipper_build_va_list ()
1096
1097 /* Implement `va_start' for varargs and stdarg.  */
1098 #define EXPAND_BUILTIN_VA_START(stdarg, valist, nextarg) \
1099   clipper_va_start (stdarg, valist, nextarg)
1100
1101 /* Implement `va_arg'.  */
1102 #define EXPAND_BUILTIN_VA_ARG(valist, type) \
1103   clipper_va_arg (valist, type)