OSDN Git Service

Undo patch of May 11. -nostdlib implies -nostartfiles again.
[pf3gnuchains/gcc-fork.git] / gcc / config / dsp16xx / dsp16xx.h
1 /* Definitions of target machine for GNU compiler.  AT&T DSP1600.
2    Copyright (C) 1994, 1995 Free Software Foundation, Inc.
3    Contributed by Michael Collison (collison@world.std.com).
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 1, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
20
21 extern char *low_reg_names[];
22 extern char *text_seg_name;
23 extern char *rsect_text;
24 extern char *data_seg_name;
25 extern char *rsect_data;
26 extern char *bss_seg_name;
27 extern char *rsect_bss;
28 extern char *const_seg_name;
29 extern char *rsect_const;
30 extern char *chip_name;
31 extern char *save_chip_name;
32 extern struct rtx_def *dsp16xx_compare_op0, *dsp16xx_compare_op1;
33 extern struct rtx_def *(*dsp16xx_compare_gen)();
34 extern struct rtx_def *gen_compare_reg();
35 extern struct rtx_def *dsp16xx_addhf3_libcall;
36 extern struct rtx_def *dsp16xx_subhf3_libcall;
37 extern struct rtx_def *dsp16xx_mulhf3_libcall;
38 extern struct rtx_def *dsp16xx_divhf3_libcall;
39 extern struct rtx_def *dsp16xx_cmphf3_libcall;
40 extern struct rtx_def *dsp16xx_fixhfhi2_libcall;
41 extern struct rtx_def *dsp16xx_floathihf2_libcall;
42 extern struct rtx_def *dsp16xx_neghf2_libcall;
43 extern struct rtx_def *dsp16xx_umulhi3_libcall;
44 extern struct rtx_def *dsp16xx_mulhi3_libcall;
45 extern struct rtx_def *dsp16xx_udivqi3_libcall;
46 extern struct rtx_def *dsp16xx_udivhi3_libcall;
47 extern struct rtx_def *dsp16xx_divqi3_libcall;
48 extern struct rtx_def *dsp16xx_divhi3_libcall;
49 extern struct rtx_def *dsp16xx_modqi3_libcall;
50 extern struct rtx_def *dsp16xx_modhi3_libcall;
51 extern struct rtx_def *dsp16xx_umodqi3_libcall;
52 extern struct rtx_def *dsp16xx_umodhi3_libcall;
53
54 extern struct rtx_def *dsp16xx_ashrhi3_libcall;
55 extern struct rtx_def *dsp16xx_ashlhi3_libcall;
56 extern struct rtx_def *dsp16xx_lshrhi3_libcall;
57
58
59 extern int hard_regno_mode_ok ();
60 extern enum reg_class dsp16xx_reg_class_from_letter ();
61 extern enum reg_class dsp16xx_limit_reload_class ();
62 extern int hard_regno_nregs ();
63 extern int regno_reg_class ();
64 extern int move_operand ();
65 extern int symbolic_address_p ();
66 extern int Y_address ();
67 extern int call_address_operand ();
68 extern void notice_update_cc();
69 extern void function_prologue ();
70 extern void function_epilogue ();
71 extern int  dsp1600_comparison_reverse ();
72 extern void double_reg_from_memory ();
73 extern void double_reg_to_memory ();
74 extern void bss_section ();
75 extern struct rtx_def *dsp16xx_function_arg ();
76 extern void dsp16xx_function_arg_advance ();
77 extern enum rtx_code next_cc_user_code ();
78 extern enum rtx_code save_next_cc_user_code;
79 extern struct rtx_def *gen_tst_reg ();
80 extern char *output_block_move();
81
82 /* RUN-TIME TARGET SPECIFICATION */
83 #define DSP16XX   1
84
85 /* Name of the AT&T assembler */
86
87 #define ASM_PROG "as1600"
88
89 /* Name of the AT&T linker */
90
91 #define LD_PROG "ld1600"
92
93 /* Define which switches take word arguments */
94 #define WORD_SWITCH_TAKES_ARG(STR)              \
95   (!strcmp (STR, "ifile") ? 1 :                 \
96    0)
97
98 #ifdef  CC1_SPEC
99 #undef  CC1_SPEC
100 #endif
101 #define CC1_SPEC       ""
102
103 /* Define this as a spec to call the AT&T assembler */
104
105 #define CROSS_ASM_SPEC   "%{!S:as1600 %a %i\n }"
106
107 /* Define this as a spec to call the AT&T linker */
108
109 #define CROSS_LINK_SPEC  "%{!c:%{!M:%{!MM:%{!E:%{!S:ld1600 %l %X %{o*} %{m} \
110                         %{r} %{s} %{t} %{u*} %{x}\
111                         %{!A:%{!nostdlib:%{!nostartfiles:%S}}} %{static:}\
112                         %{L*} %D %o %{!nostdlib:-le1600 %L -le1600}\
113                         %{!A:%{!nostdlib:%{!nostartfiles:%E}}}\n }}}}}"
114
115 /* Nothing complicated here, just link with libc.a under normal
116    circumstances */
117 #define LIB_SPEC "-lc"
118
119 /* Specify the startup file to link with. */
120 #define STARTFILE_SPEC "%{mmap1:m1_crt0.o%s}  \
121 %{mmap2:m2_crt0.o%s}                          \
122 %{mmap3:m3_crt0.o%s}                          \
123 %{mmap4:m4_crt0.o%s}                          \
124 %{!mmap*: %{!ifile*: m4_crt0.o%s} %{ifile*:     \
125 %eA -ifile option requires a -map option}}"
126
127 /* Specify the end file to link with */
128
129 #define ENDFILE_SPEC "%{mmap1:m1_crtn.o%s}  \
130 %{mmap2:m2_crtn.o%s}                          \
131 %{mmap3:m3_crtn.o%s}                          \
132 %{mmap4:m4_crtn.o%s}                          \
133 %{!mmap*: %{!ifile*: m4_crtn.o%s} %{ifile*:     \
134 %eA -ifile option requires a -map option}}"
135
136
137 /* Tell gcc where to look for the startfile */
138 #define STANDARD_STARTFILE_PREFIX   "/d1600/lib"
139
140 /* Tell gcc where to look for it's executables */
141 #define STANDARD_EXEC_PREFIX  "/d1600/bin"
142
143 /* Command line options to the AT&T assembler */
144 #define ASM_SPEC  "%{V} %{v:%{!V:-V}} %{g*:-g}"
145
146 /* Command line options for the AT&T linker */
147 #define LINK_SPEC "%{V} %{v:%{!V:-V}} %{minit:-i}  \
148 %{!ifile*:%{mmap1:-ifile m1_deflt.if%s}         \
149           %{mmap2:-ifile m2_deflt.if%s}         \
150           %{mmap3:-ifile m3_deflt.if%s}         \
151           %{mmap4:-ifile m4_deflt.if%s}         \
152           %{!mmap*:-ifile m4_deflt.if%s}}       \
153 %{ifile*} %{!r:-a}"
154
155 /* Names to predefine in the preprocessor for this target machine.  */
156 #ifdef __MSDOS__
157 #define CPP_PREDEFINES "-Ddsp1600 -DDSP1600 -DMSDOS"
158 #else
159 #define CPP_PREDEFINES "-Ddsp1600 -DDSP1600 -Ddsp1610 -DDSP1610"
160 #endif
161
162 /* Run-time compilation parameters selecting different hardware subsets.  */
163
164 extern int target_flags;
165
166 /* Macros used in the machine description to test the flags.  */
167
168 #define MASK_REGPARM         0x00000001    /* Pass parameters in registers */
169 #define MASK_NEAR_CALL       0x00000002    /* The call is on the same 4k page */
170 #define MASK_NEAR_JUMP       0x00000004    /* The jump is on the same 4k page */
171 #define MASK_BMU             0x00000008    /* Use the 'bmu' shift instructions */
172 #define MASK_OPTIMIZE_MEMORY 0x00000010    /* Optimize to conserve memory */
173 #define MASK_OPTIMIZE_SPEED  0x00000020    /* Optimize for speed */
174 #define MASK_MAP1            0x00000040    /* Link with map1 */
175 #define MASK_MAP2            0x00000080    /* Link with map2 */
176 #define MASK_MAP3            0x00000100    /* Link with map3 */
177 #define MASK_MAP4            0x00000200    /* Link with map4 */
178 #define MASK_YBASE_HIGH      0x00000400    /* The ybase register window starts high */
179 #define MASK_INIT            0x00000800    /* Have the linker generate tables to
180                                               initialize data at startup */
181 #define MASK_INLINE_MULT     0x00001000    /* Inline 32 bit multiplies */
182 #define MASK_RESERVE_YBASE   0x00002000    /* Reserved the ybase registers */
183
184 /* Compile passing first two args in regs 0 and 1.
185    This exists only to test compiler features that will
186    be needed for RISC chips.  It is not usable
187    and is not intended to be usable on this cpu.  */
188 #define TARGET_REGPARM   (target_flags & MASK_REGPARM)
189
190 /* The call is on the same 4k page, so instead of loading
191    the 'pt' register and branching, we can branch directly */
192
193 #define TARGET_NEAR_CALL (target_flags & MASK_NEAR_CALL)
194
195 /* The jump is on the same 4k page, so instead of loading
196    the 'pt' register and branching, we can branch directly */
197
198 #define TARGET_NEAR_JUMP (target_flags & MASK_NEAR_JUMP)
199
200 /* Generate shift instructions to use the 1610 Bit Manipulation
201    Unit. */
202 #define TARGET_BMU (target_flags & MASK_BMU)
203
204 /* Optimize to conserve memory */
205 #define TARGET_OPTIMIZE_MEMORY (target_flags & MASK_OPTIMIZE_MEMORY)
206
207 /* Optimize for maximum speed */
208 #define TARGET_OPTIMIZE_SPEED   (target_flags & MASK_OPTIMIZE_SPEED)
209
210 #define TARGET_YBASE_HIGH (target_flags & MASK_YBASE_HIGH)
211
212 /* Direct the linker to output extra info for initialized data */
213 #define TARGET_MASK_INIT (target_flags & MASK_INIT)
214
215 #define TARGET_INLINE_MULT (target_flags & MASK_INLINE_MULT)
216
217 /* Reserve the ybase registers *(0) - *(31) */
218 #define TARGET_RESERVE_YBASE (target_flags & MASK_RESERVE_YBASE)
219
220 /* Macro to define tables used to set the flags.
221    This is a list in braces of pairs in braces,
222    each pair being { "NAME", VALUE }
223    where VALUE is the bits to set or minus the bits to clear.
224    An empty string NAME is used to identify the default VALUE.  */
225
226
227 #define TARGET_SWITCHES                        \
228   {                                            \
229     { "regparm",       MASK_REGPARM},          \
230     { "no-regparm",   -MASK_REGPARM},          \
231     { "no-near-call", -MASK_NEAR_CALL},        \
232     { "near-jump",     MASK_NEAR_JUMP},        \
233     { "no-near-jump", -MASK_NEAR_JUMP},        \
234     { "bmu",           MASK_BMU},              \
235     { "no-bmu",       -MASK_BMU},              \
236     { "Om",            MASK_OPTIMIZE_MEMORY},  \
237     { "Os",            MASK_OPTIMIZE_SPEED},   \
238     { "map1",          MASK_MAP1},             \
239     { "map2",          MASK_MAP2},             \
240     { "map3",          MASK_MAP3},             \
241     { "map4",          MASK_MAP4},             \
242     { "ybase-high",    MASK_YBASE_HIGH},       \
243     { "init",          MASK_INIT},             \
244     { "inline-mult",   MASK_INLINE_MULT},      \
245     { "reserve-ybase", MASK_RESERVE_YBASE},    \
246     { "",              TARGET_DEFAULT}         \
247   }
248
249 /* Default target_flags if no switches are specified */
250 #ifndef TARGET_DEFAULT
251 #define TARGET_DEFAULT  MASK_OPTIMIZE_MEMORY|MASK_REGPARM|MASK_YBASE_HIGH
252 #endif
253
254 /* This macro is similar to `TARGET_SWITCHES' but defines names of
255    command options that have values.  Its definition is an
256    initializer with a subgrouping for each command option.
257
258    Each subgrouping contains a string constant, that defines the
259    fixed part of the option name, and the address of a variable. 
260    The variable, type `char *', is set to the variable part of the
261    given option if the fixed part matches.  The actual option name
262    is made by appending `-m' to the specified name.
263
264    Here is an example which defines `-mshort-data-NUMBER'.  If the
265    given option is `-mshort-data-512', the variable `m88k_short_data'
266    will be set to the string `"512"'.
267
268         extern char *m88k_short_data;
269         #define TARGET_OPTIONS { { "short-data-", &m88k_short_data } }  */
270
271 #define TARGET_OPTIONS                                          \
272 {                                                               \
273   { "text=",    &text_seg_name  },                              \
274   { "data=",    &data_seg_name  },                              \
275   { "bss=",     &bss_seg_name   },                              \
276   { "const=",   &const_seg_name },                              \
277   { "chip=",    &chip_name      }                               \
278 }
279
280 /* Sometimes certain combinations of command options do not make sense
281    on a particular target machine.  You can define a macro
282    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
283    defined, is executed once just after all the command options have
284    been parsed. */
285
286 #define OVERRIDE_OPTIONS override_options ()
287
288 #define OPTIMIZATION_OPTIONS(LEVEL)                   \
289 {                                                     \
290     flag_gnu_linker             = FALSE;              \
291                                                       \
292     if (LEVEL)                                        \
293     {                                                 \
294         flag_omit_frame_pointer = TRUE;               \
295         flag_thread_jumps       = TRUE;               \
296     }                                                 \
297                                                       \
298     if (LEVEL >= 2)                                   \
299     {                                                 \
300         flag_strength_reduce         = TRUE;          \
301         flag_cse_follow_jumps        = TRUE;          \
302         flag_cse_skip_blocks         = TRUE;          \
303         flag_expensive_optimizations = TRUE;          \
304         flag_rerun_cse_after_loop    = TRUE;          \
305     }                                                 \
306                                                       \
307     if (LEVEL >= 3)                                   \
308     {                                                 \
309        flag_inline_functions = 1;                     \
310     }                                                 \
311 }
312 \f
313 /* STORAGE LAYOUT */
314
315 /* Define if you don't want extended real, but do want to use the
316    software floating point emulator for REAL_ARITHMETIC and
317    decimal <-> binary conversion. */
318 #define REAL_ARITHMETIC
319
320 /* Define this if most significant bit is lowest numbered
321    in instructions that operate on numbered bit-fields.
322  */
323 #define BITS_BIG_ENDIAN  1
324
325 /* Define this if most significant byte of a word is the lowest numbered.
326    We define big-endian, but since the 1600 series cannot address bytes
327    it does not matter. */
328 #define BYTES_BIG_ENDIAN 1
329
330 /* Define this if most significant word of a multiword number is numbered.
331    For the 1600 we can decide arbitrarily since there are no machine instructions for them. */
332 #define WORDS_BIG_ENDIAN 1
333
334 /* number of bits in an addressable storage unit */
335 #define BITS_PER_UNIT 16
336
337 /* Width in bits of a "word", which is the contents of a machine register.
338    Note that this is not necessarily the width of data type `int';
339    if using 16-bit ints on a 68000, this would still be 32.
340    But on a machine with 16-bit registers, this would be 16.  */
341 #define BITS_PER_WORD 16
342
343 /* Maximum number of bits in a word. */
344 #define MAX_BITS_PER_WORD 16
345
346 /* Width of a word, in units (bytes).  */
347 #define UNITS_PER_WORD 1
348
349 /* Width in bits of a pointer.
350    See also the macro `Pmode' defined below.  */
351 #define POINTER_SIZE 16
352
353 /* Allocation boundary (in *bits*) for storing pointers in memory.  */
354 #define POINTER_BOUNDARY 16
355
356 /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
357 #define PARM_BOUNDARY 16
358
359 /* Boundary (in *bits*) on which stack pointer should be aligned.  */
360 #define STACK_BOUNDARY 16
361
362 /* Allocation boundary (in *bits*) for the code of a function.  */
363 #define FUNCTION_BOUNDARY 16
364
365 /* Biggest alignment that any data type can require on this machine, in bits.  */
366 #define BIGGEST_ALIGNMENT 16
367
368 /* Biggest alignment that any structure field can require on this machine, in bits */
369 #define BIGGEST_FIELD_ALIGNMENT 16
370
371 /* Alignment of field after `int : 0' in a structure.  */
372 #define EMPTY_FIELD_BOUNDARY 16
373
374 /* Number of bits which any structure or union's size must be a multiple of. Each structure
375    or union's size is rounded up to a multiple of this */
376 #define STRUCTURE_SIZE_BOUNDARY 16
377
378 /* Define this if move instructions will actually fail to work
379    when given unaligned data.  */
380 #define STRICT_ALIGNMENT  1
381
382 /* An integer expression for the size in bits of the largest integer machine mode that
383    should actually be used. All integer machine modes of this size or smaller can be
384    used for structures and unions with the appropriate sizes. */
385 #define MAX_FIXED_MODE_SIZE 32
386 \f
387 /* LAYOUT OF SOURCE LANGUAGE DATA TYPES */
388
389 #define CHAR_TYPE_SIZE         16
390 #define SHORT_TYPE_SIZE        16
391 #define INT_TYPE_SIZE          16
392 #define LONG_TYPE_SIZE         32
393 #define LONG_LONG_TYPE_SIZE    32
394 #define FLOAT_TYPE_SIZE        32
395 #define DOUBLE_TYPE_SIZE       32
396 #define LONG_DOUBLE_TYPE_SIZE  32
397
398 /* An expression whose value is 1 or 0, according to whether the type char should be
399    signed or unsigned by default. */
400
401 #define DEFAULT_SIGNED_CHAR 1
402
403 /* A C expression to determine whether to give an enum type only as many bytes
404    as it takes to represent the range of possible values of that type. A nonzero
405    value means to do that; a zero value means all enum types should be allocated
406    like int. */
407
408 #define DEFAULT_SHORT_ENUMS 0
409
410 /* A C expression for a string describing the name of the data type to use for
411    size values. */
412
413 #define SIZE_TYPE    "long unsigned int"
414
415 /* A C expression for a string describing the name of the datat type to use for the
416    result of subtracting two pointers */
417
418 #define PTRDIFF_TYPE "long int"
419
420 #define TARGET_BELL     '\a'
421 #define TARGET_BS       '\b'
422 #define TARGET_TAB      '\t'
423 #define TARGET_NEWLINE  '\n'
424 #define TARGET_VT       '\v'
425 #define TARGET_FF       '\f'
426 #define TARGET_CR       '\r'
427
428 \f
429 /* REGISTER USAGE.  */
430
431 #define ALL_16_BIT_REGISTERS  1
432
433 /* Number of actual hardware registers.
434    The hardware registers are assigned numbers for the compiler
435    from 0 to FIRST_PSEUDO_REGISTER-1 */
436
437 #define FIRST_PSEUDO_REGISTER REG_YBASE31 + 1
438
439 /* 1 for registers that have pervasive standard uses
440    and are not available for the register allocator.
441
442    The registers are layed out as follows:
443
444    {a0,a0l,a1,a1l,x,y,yl,p,pl} - Data Arithmetic Unit
445    {r0,r1,r2,r3,j,k,ybase} - Y Space Address Arithmetic Unit
446    {pt} - X Space Address Arithmetic Unit
447    {ar0,ar1,ar2,ar3} - Bit Manipulation UNit
448    {pr} - Return Address Register
449
450    We reserve r2 for the Stack Pointer.
451    We specify r3 for the Frame Pointer but allow the compiler
452    to omit it when possible since we have so few pointer registers. */
453
454 #define REG_A0     0
455 #define REG_A0L    1
456 #define REG_A1     2
457 #define REG_A1L    3 
458 #define REG_X      4
459 #define REG_Y      5
460 #define REG_YL     6
461 #define REG_PROD   7
462 #define REG_PRODL  8
463 #define REG_R0     9
464 #define REG_R1     10
465 #define REG_R2     11
466 #define REG_R3     12
467 #define REG_J      13
468 #define REG_K      14
469 #define REG_YBASE  15
470 #define REG_PT     16
471 #define REG_AR0    17
472 #define REG_AR1    18
473 #define REG_AR2    19
474 #define REG_AR3    20
475 #define REG_C0     21
476 #define REG_C1     22
477 #define REG_C2     23
478 #define REG_PR     24
479 #define REG_RB     25
480 #define REG_YBASE0 26
481 #define REG_YBASE1 27
482 #define REG_YBASE2 28
483 #define REG_YBASE3 29
484 #define REG_YBASE4 30
485 #define REG_YBASE5 31
486 #define REG_YBASE6 32
487 #define REG_YBASE7 33
488 #define REG_YBASE8 34
489 #define REG_YBASE9 35
490 #define REG_YBASE10 36
491 #define REG_YBASE11 37
492 #define REG_YBASE12 38
493 #define REG_YBASE13 39
494 #define REG_YBASE14 40
495 #define REG_YBASE15 41
496 #define REG_YBASE16 42
497 #define REG_YBASE17 43
498 #define REG_YBASE18 44
499 #define REG_YBASE19 45
500 #define REG_YBASE20 46
501 #define REG_YBASE21 47
502 #define REG_YBASE22 48
503 #define REG_YBASE23 49
504 #define REG_YBASE24 50
505 #define REG_YBASE25 51
506 #define REG_YBASE26 52
507 #define REG_YBASE27 53
508 #define REG_YBASE28 54
509 #define REG_YBASE29 55
510 #define REG_YBASE30 56
511 #define REG_YBASE31 57
512
513 /* Do we have a accumulator register? */
514 #define IS_ACCUM_REG(REGNO) ((REGNO) >= REG_A0 && (REGNO) <= REG_A1L)
515 #define IS_ACCUM_LOW_REG(REGNO) ((REGNO) == REG_A0L || (REGNO) == REG_A1L)
516
517 /* Do we have a virtual ybase register */
518 #define IS_YBASE_REGISTER_WINDOW(REGNO) ((REGNO) >= REG_YBASE0 && (REGNO) <= REG_YBASE31)
519
520 #define IS_ADDRESS_REGISTER(REGNO) ((REGNO) >= REG_R0 && (REGNO) <= REG_R3)
521
522 #define FIXED_REGISTERS     \
523 {0, 0, 0, 0, 0, 0, 0, 0, 0, \
524  0, 0, 0, 1, 0, 0, 1,       \
525  1,                         \
526  0, 0, 0, 0,                \
527  1, 1, 1,                   \
528  0, 0,                      \
529  0, 0, 0, 0, 0, 0, 0, 0,    \
530  0, 0, 0, 0, 0, 0, 0, 0,    \
531  0, 0, 0, 0, 0, 0, 0, 0,    \
532  0, 0, 0, 0, 0, 0, 0, 0}
533
534 /* 1 for registers not available across function calls.
535    These must include the FIXED_REGISTERS and also any
536    registers that can be used without being saved.
537    The latter must include the registers where values are returned
538    and the register where structure-value addresses are passed.
539    On the 1610 'a0' holds return values from functions. 'r0' holds
540    structure-value addresses.
541
542    In addition we don't save either j, k, ybase or any of the
543    bit manipulation registers.  */
544
545
546 #define CALL_USED_REGISTERS   \
547 {1, 1, 1, 1, 0, 1, 1, 1, 1,   \
548  1, 0, 0, 1, 1, 1, 1,         \
549  1,                           \
550  0, 0, 1, 1,                  \
551  1, 1, 1,                     \
552  0, 1,                        \
553  0, 0, 0, 0, 0, 0, 0, 0,      \
554  0, 0, 0, 0, 0, 0, 0, 0,      \
555  0, 0, 0, 0, 0, 0, 0, 0,      \
556  0, 0, 0, 0, 0, 0, 0, 0}
557
558 /* List the order in which to allocate registers.  Each register must be
559    listed once, even those in FIXED_REGISTERS.
560
561    We allocate in the following order:
562  */
563
564 #define REG_ALLOC_ORDER                                 \
565 { REG_R0, REG_R1, REG_R2, REG_PROD, REG_Y, REG_X,       \
566   REG_PRODL, REG_YL, REG_AR0, REG_AR1,                  \
567   REG_RB, REG_A0, REG_A1, REG_A0L,                      \
568   REG_A1L, REG_AR2, REG_AR3,                            \
569   REG_YBASE, REG_J, REG_K, REG_PR, REG_PT, REG_C0,      \
570   REG_C1, REG_C2, REG_R3,                               \
571   REG_YBASE0, REG_YBASE1, REG_YBASE2, REG_YBASE3,       \
572   REG_YBASE4, REG_YBASE5, REG_YBASE6, REG_YBASE7,       \
573   REG_YBASE8, REG_YBASE9, REG_YBASE10, REG_YBASE11,     \
574   REG_YBASE12, REG_YBASE13, REG_YBASE14, REG_YBASE15,   \
575   REG_YBASE16, REG_YBASE17, REG_YBASE18, REG_YBASE19,   \
576   REG_YBASE20, REG_YBASE21, REG_YBASE22, REG_YBASE23,   \
577   REG_YBASE24, REG_YBASE25, REG_YBASE26, REG_YBASE27,   \
578   REG_YBASE28, REG_YBASE29, REG_YBASE30, REG_YBASE31 }
579
580 /* Zero or more C statements that may conditionally modify two
581    variables `fixed_regs' and `call_used_regs' (both of type `char
582    []') after they have been initialized from the two preceding
583    macros.
584
585    This is necessary in case the fixed or call-clobbered registers
586    depend on target flags.
587
588    You need not define this macro if it has no work to do.
589
590    If the usage of an entire class of registers depends on the target
591    flags, you may indicate this to GCC by using this macro to modify
592    `fixed_regs' and `call_used_regs' to 1 for each of the registers in
593    the classes which should not be used by GCC.  Also define the macro
594    `REG_CLASS_FROM_LETTER' to return `NO_REGS' if it is called with a
595    letter for a class that shouldn't be used.
596
597    (However, if this class is not included in `GENERAL_REGS' and all
598    of the insn patterns whose constraints permit this class are
599    controlled by target switches, then GCC will automatically avoid
600    using these registers when the target switches are opposed to
601    them.)  If the user tells us there is no BMU, we can't use
602    ar0-ar3 for register allocation */
603
604 #define CONDITIONAL_REGISTER_USAGE                                      \
605 do                                                                      \
606   {                                                                     \
607     if (!TARGET_BMU)                                                    \
608       {                                                                 \
609         int regno;                                                      \
610                                                                         \
611         for (regno = REG_AR0; regno <= REG_AR3; regno++)                \
612           fixed_regs[regno] = call_used_regs[regno] = 1;                \
613       }                                                                 \
614     if (TARGET_RESERVE_YBASE)                                           \
615       {                                                                 \
616         int regno;                                                      \
617                                                                         \
618         for (regno = REG_YBASE0; regno <= REG_YBASE31; regno++)         \
619           fixed_regs[regno] = call_used_regs[regno] = 1;                \
620       }                                                                 \
621   }                                                                     \
622 while (0)
623
624 /* Determine which register classes are very likely used by spill registers.
625    local-alloc.c won't allocate pseudos that have these classes as their
626    preferred class unless they are "preferred or nothing".  */
627
628 #define CLASS_LIKELY_SPILLED_P(CLASS) \
629  ((CLASS) != ALL_REGS && (CLASS) != YBASE_VIRT_REGS)
630
631 /* Return number of consecutive hard regs needed starting at reg REGNO
632    to hold something of mode MODE.
633    This is ordinarily the length in words of a value of mode MODE
634    but can be less for certain modes in special long registers. */
635
636 #define HARD_REGNO_NREGS(REGNO, MODE)                                 \
637   (GET_MODE_SIZE(MODE))
638
639 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. */
640
641 #define HARD_REGNO_MODE_OK(REGNO, MODE) hard_regno_mode_ok(REGNO, MODE)
642
643 /* Value is 1 if it is a good idea to tie two pseudo registers
644    when one has mode MODE1 and one has mode MODE2.
645    If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
646    for any hard reg, then this must be 0 for correct output.  */
647 #define MODES_TIEABLE_P(MODE1, MODE2)                \
648   (((MODE1) == (MODE2)) ||                           \
649    (GET_MODE_CLASS((MODE1)) == MODE_FLOAT)           \
650     == (GET_MODE_CLASS((MODE2)) == MODE_FLOAT))
651
652 /* Specify the registers used for certain standard purposes.
653    The values of these macros are register numbers.  */
654
655 /* DSP1600 pc isn't overloaded on a register.  */
656 /* #define PC_REGNUM  */
657
658 /* Register to use for pushing function arguments.  
659    This is r3 in our case */
660 #define STACK_POINTER_REGNUM  REG_R3
661
662 /* Base register for access to local variables of the function.
663    This is r2 in our case   */
664 #define FRAME_POINTER_REGNUM  REG_R2
665
666 /* We can debug without the frame pointer */
667 #define CAN_DEBUG_WITHOUT_FP 1
668
669 /* The 1610 saves the return address in this register */
670 #define RETURN_ADDRESS_REGNUM REG_PR
671
672 /* Base register for access to arguments of the function.  */
673 #define ARG_POINTER_REGNUM FRAME_POINTER_REGNUM
674
675 /* Register in which static-chain is passed to a function.  */
676
677 #define STATIC_CHAIN_REGNUM 4
678
679 /* Register in which address to store a structure value
680    is passed to a function.  This is 'r0' in our case */
681 #define STRUCT_VALUE_REGNUM   REG_R0
682 \f
683 /* Define the classes of registers for register constraints in the
684    machine description.  Also define ranges of constants.
685
686    One of the classes must always be named ALL_REGS and include all hard regs.
687    If there is more than one class, another class must be named NO_REGS
688    and contain no registers.
689
690    The name GENERAL_REGS must be the name of a class (or an alias for
691    another name such as ALL_REGS).  This is the class of registers
692    that is allowed by "g" or "r" in a register constraint.
693    Also, registers outside this class are allocated only when
694    instructions express preferences for them.
695
696    The classes must be numbered in nondecreasing order; that is,
697    a larger-numbered class must never be contained completely
698    in a smaller-numbered class.
699
700    For any two classes, it is very desirable that there be another
701    class that represents their union.  */
702
703
704 enum reg_class 
705
706     NO_REGS, 
707     A0H_REG,
708     A0L_REG,
709     A0_REG,
710     A1H_REG,
711     ACCUM_HIGH_REGS,
712     A1L_REG,
713     ACCUM_LOW_REGS, 
714     A1_REG,
715     ACCUM_REGS, 
716     X_REG, 
717     X_OR_ACCUM_LOW_REGS,
718     X_OR_ACCUM_REGS,
719     YH_REG,
720     YH_OR_ACCUM_HIGH_REGS,
721     X_OR_YH_REGS,
722     YL_REG,
723     YL_OR_ACCUM_LOW_REGS,
724     X_OR_YL_REGS,
725     X_OR_Y_REGS,
726     Y_REG,
727     ACCUM_OR_Y_REGS,
728     PH_REG,
729     X_OR_PH_REGS, 
730     PL_REG, 
731     PL_OR_ACCUM_LOW_REGS,
732     X_OR_PL_REGS,
733     YL_OR_PL_OR_ACCUM_LOW_REGS,
734     P_REG,
735     ACCUM_OR_P_REGS,
736     YL_OR_P_REGS,
737     ACCUM_LOW_OR_YL_OR_P_REGS,
738     Y_OR_P_REGS,
739     ACCUM_Y_OR_P_REGS, 
740     NO_FRAME_Y_ADDR_REGS,
741     Y_ADDR_REGS, 
742     ACCUM_LOW_OR_Y_ADDR_REGS,
743     ACCUM_OR_Y_ADDR_REGS,
744     X_OR_Y_ADDR_REGS,
745     Y_OR_Y_ADDR_REGS,
746     P_OR_Y_ADDR_REGS,
747     NON_HIGH_YBASE_ELIGIBLE_REGS,
748     YBASE_ELIGIBLE_REGS,
749     J_REG,
750     J_OR_DAU_16_BIT_REGS,
751     BMU_REGS, 
752     NOHIGH_NON_ADDR_REGS,
753     NON_ADDR_REGS,
754     SLOW_MEM_LOAD_REGS,
755     NOHIGH_NON_YBASE_REGS,
756     NO_ACCUM_NON_YBASE_REGS,
757     NON_YBASE_REGS,
758     YBASE_VIRT_REGS,
759     ACCUM_LOW_OR_YBASE_REGS,
760     ACCUM_OR_YBASE_REGS,
761     X_OR_YBASE_REGS,
762     Y_OR_YBASE_REGS,
763     ACCUM_LOW_YL_PL_OR_YBASE_REGS,
764     P_OR_YBASE_REGS,
765     ACCUM_Y_P_OR_YBASE_REGS,
766     Y_ADDR_OR_YBASE_REGS,
767     YBASE_OR_NOHIGH_YBASE_ELIGIBLE_REGS,
768     YBASE_OR_YBASE_ELIGIBLE_REGS,
769     NO_HIGH_ALL_REGS,
770     ALL_REGS, 
771     LIM_REG_CLASSES 
772 };
773
774 /* GENERAL_REGS must be the name of a register class */
775 #define GENERAL_REGS ALL_REGS
776
777 #define N_REG_CLASSES (int) LIM_REG_CLASSES
778
779 /* Give names of register classes as strings for dump file.   */
780
781 #define REG_CLASS_NAMES        \
782 {                              \
783     "NO_REGS",                 \
784     "A0H_REG",                 \
785     "A0L_REG",                 \
786     "A0_REG",                  \
787     "A1H_REG",                 \
788     "ACCUM_HIGH_REGS",         \
789     "A1L_REG",                 \
790     "ACCUM_LOW_REGS",          \
791     "A1_REG",                  \
792     "ACCUM_REGS",              \
793     "X_REG",                   \
794     "X_OR_ACCUM_LOW_REGS",     \
795     "X_OR_ACCUM_REGS",         \
796     "YH_REG",                  \
797     "YH_OR_ACCUM_HIGH_REGS",   \
798     "X_OR_YH_REGS",            \
799     "YL_REG",                  \
800     "YL_OR_ACCUM_LOW_REGS",    \
801     "X_OR_YL_REGS",            \
802     "X_OR_Y_REGS",             \
803     "Y_REG",                   \
804     "ACCUM_OR_Y_REGS",         \
805     "PH_REG",                  \
806     "X_OR_PH_REGS",            \
807     "PL_REG",                  \
808     "PL_OR_ACCUM_LOW_REGS",    \
809     "X_OR_PL_REGS",            \
810     "PL_OR_YL_OR_ACCUM_LOW_REGS", \
811     "P_REG",                   \
812     "ACCUM_OR_P_REGS",         \
813     "YL_OR_P_REGS",            \
814     "ACCUM_LOW_OR_YL_OR_P_REGS", \
815     "Y_OR_P_REGS",             \
816     "ACCUM_Y_OR_P_REGS",       \
817     "NO_FRAME_Y_ADDR_REGS",      \
818     "Y_ADDR_REGS",               \
819     "ACCUM_LOW_OR_Y_ADDR_REGS",  \
820     "ACCUM_OR_Y_ADDR_REGS",    \
821     "X_OR_Y_ADDR_REGS",        \
822     "Y_OR_Y_ADDR_REGS",        \
823     "P_OR_Y_ADDR_REGS",        \
824     "NON_HIGH_YBASE_ELIGIBLE_REGS", \
825     "YBASE_ELIGIBLE_REGS",     \
826     "J_REG",                   \
827     "J_OR_DAU_16_BIT_REGS",    \
828     "BMU_REGS",                \
829     "NOHIGH_NON_ADDR_REGS",    \
830     "NON_ADDR_REGS",           \
831     "SLOW_MEM_LOAD_REGS",      \
832     "NOHIGH_NON_YBASE_REGS",   \
833     "NO_ACCUM_NON_YBASE_REGS", \
834     "NON_YBASE_REGS",          \
835     "YBASE_VIRT_REGS",         \
836     "ACCUM_LOW_OR_YBASE_REGS", \
837     "ACCUM_OR_YBASE_REGS",     \
838     "X_OR_YBASE_REGS",         \
839     "Y_OR_YBASE_REGS",         \
840     "ACCUM_LOW_YL_PL_OR_YBASE_REGS", \
841     "P_OR_YBASE_REGS",         \
842     "ACCUM_Y_P_OR_YBASE_REGS", \
843     "Y_ADDR_OR_YBASE_REGS",    \
844     "YBASE_OR_NOHIGH_YBASE_ELIGIBLE_REGS", \
845     "YBASE_OR_YBASE_ELIGIBLE_REGS", \
846     "NO_HIGH_ALL_REGS",        \
847     "ALL_REGS"                 \
848 }
849
850 /* Define which registers fit in which classes.
851    This is an initializer for a vector of HARD_REG_SET
852    of length N_REG_CLASSES.  */
853
854 #define REG_CLASS_CONTENTS   \
855 {                            \
856     {0x00000000,  0x00000000},      /* no reg */                             \
857     {0x00000001,  0x00000000},      /* a0h */                                \
858     {0x00000002,  0x00000000},      /* a0l */                                \
859     {0x00000003,  0x00000000},      /* a0h:a0l */                            \
860     {0x00000004,  0x00000000},      /* a1h */                                \
861     {0x00000005,  0x00000000},      /* accum high */                         \
862     {0x00000008,  0x00000000},      /* a1l */                                \
863     {0x0000000A,  0x00000000},      /* accum low */                          \
864     {0x0000000c,  0x00000000},      /* a1h:a1l */                            \
865     {0x0000000f,  0x00000000},      /* accum regs */                         \
866     {0x00000010,  0x00000000},      /* x reg */                              \
867     {0x0000001A,  0x00000000},      /* x & accum_low_regs */                 \
868     {0x0000001f,  0x00000000},      /* x & accum regs */                     \
869     {0x00000020,  0x00000000},      /* y high */                             \
870     {0x00000025,  0x00000000},      /* yh, accum high */                     \
871     {0x00000030,  0x00000000},      /* x & yh */                             \
872     {0x00000040,  0x00000000},      /* y low */                              \
873     {0x0000004A,  0x00000000},      /* y low, accum_low */                   \
874     {0x00000050,  0x00000000},      /* x & yl */                             \
875     {0x00000060,  0x00000000},      /* yl:yh */                              \
876     {0x00000070,  0x00000000},      /* x, yh,a nd yl */                      \
877     {0x0000006F,  0x00000000},      /* accum, y */                           \
878     {0x00000080,  0x00000000},      /* p high */                             \
879     {0x00000090,  0x00000000},      /* x & ph */                             \
880     {0x00000100,  0x00000000},      /* p low */                              \
881     {0x0000010A,  0x00000000},      /* p_low and accum_low */                \
882     {0x00000110,  0x00000000},      /* x & pl */                             \
883     {0x0000014A,  0x00000000},      /* pl,yl,a1l,a0l */                      \
884     {0x00000180,  0x00000000},      /* pl:ph */                              \
885     {0x0000018F,  0x00000000},      /* accum, p */                           \
886     {0x000001C0,  0x00000000},      /* pl:ph and yl */                       \
887     {0x000001CA,  0x00000000},      /* pl:ph, yl, a0l, a1l */                \
888     {0x000001E0,  0x00000000},      /* y or p */                             \
889     {0x000001EF,  0x00000000},      /* accum, y or p */                      \
890     {0x00000E00,  0x00000000},      /* r0-r2 */                              \
891     {0x00001E00,  0x00000000},      /* r0-r3 */                              \
892     {0x00001E0A,  0x00000000},      /* r0-r3, accum_low */                   \
893     {0x00001E0F,  0x00000000},      /* accum,r0-r3 */                        \
894     {0x00001E10,  0x00000000},      /* x,r0-r3 */                            \
895     {0x00001E60,  0x00000000},      /* y,r0-r3 */                            \
896     {0x00001F80,  0x00000000},      /* p,r0-r3 */                            \
897     {0x00001FDA,  0x00000000},      /* ph:pl, r0-r3, x,a0l,a1l */            \
898     {0x00001fff,  0x00000000},      /* accum,x,y,p,r0-r3 */                  \
899     {0x00002000,  0x00000000},      /* j */                                  \
900     {0x00002025,  0x00000000},      /* j, yh, a1h, a0h */                    \
901     {0x001E0000,  0x00000000},      /* ar0-ar3 */                            \
902     {0x03FFE1DA,  0x00000000},      /* non_addr except yh,a0h,a1h */         \
903     {0x03FFE1FF,  0x00000000},      /* non_addr regs */                      \
904     {0x03FFFF8F,  0x00000000},      /* non ybase except yh, yl, and x */     \
905     {0x03FFFFDA,  0x00000000},      /* non ybase regs except yh,a0h,a1h */   \
906     {0x03FFFFF0,  0x00000000},      /* non ybase except a0,a0l,a1,a1l */     \
907     {0x03FFFFFF,  0x00000000},      /* non ybase regs */                     \
908     {0xFC000000,  0x03FFFFFF},      /* virt ybase regs */                    \
909     {0xFC00000A,  0x03FFFFFF},      /* accum_low, virt ybase regs */         \
910     {0xFC00000F,  0x03FFFFFF},      /* accum, virt ybase regs */             \
911     {0xFC000010,  0x03FFFFFF},      /* x,virt ybase regs */                  \
912     {0xFC000060,  0x03FFFFFF},      /* y,virt ybase regs */                  \
913     {0xFC00014A,  0x03FFFFFF},      /* accum_low, yl, pl, ybase */           \
914     {0xFC000180,  0x03FFFFFF},      /* p,virt ybase regs */                  \
915     {0xFC0001EF,  0x03FFFFFF},      /* accum,y,p,ybase regs */               \
916     {0xFC001E00,  0x03FFFFFF},      /* r0-r3, ybase regs */                  \
917     {0xFC001FDA,  0x03FFFFFF},      /* r0-r3, pl:ph,yl,x,a1l,a0l */          \
918     {0xFC001FFF,  0x03FFFFFF},      /* virt ybase, ybase eligible regs */    \
919     {0xFCFFFFDA,  0x03FFFFFF},      /* all regs except yh,a0h,a1h */         \
920     {0xFFFFFFFF,  0x03FFFFFF}       /* all regs */                           \
921 }
922
923
924 /* The same information, inverted:
925    Return the class number of the smallest class containing
926    reg number REGNO.  This could be a conditional expression
927    or could index an array.  */
928
929 #define REGNO_REG_CLASS(REGNO) regno_reg_class(REGNO)
930
931 /* The class value for index registers, and the one for base regs.  */
932
933 #define INDEX_REG_CLASS NO_REGS
934 #define BASE_REG_CLASS  Y_ADDR_REGS
935
936 /* Get reg_class from a letter such as appears in the machine description. */
937
938 #define REG_CLASS_FROM_LETTER(C) \
939   dsp16xx_reg_class_from_letter(C)
940
941 #define SECONDARY_RELOAD_CLASS(CLASS, MODE, X)  \
942    secondary_reload_class(CLASS, MODE, X)
943
944 /* When defined, the compiler allows registers explicitly used in the
945    rtl to be used as spill registers but prevents the compiler from
946    extending the lifetime of these registers. */
947
948 #define SMALL_REGISTER_CLASSES
949
950 /* Macros to check register numbers against specific register classes.  */
951
952 /* These assume that REGNO is a hard or pseudo reg number.
953    They give nonzero only if REGNO is a hard reg of the suitable class
954    or a pseudo reg currently allocated to a suitable hard reg.
955    Since they use reg_renumber, they are safe only once reg_renumber
956    has been allocated, which happens in local-alloc.c.  */
957
958 /* A C expression which is nonzero if register REGNO is suitable for use
959    as a base register in operand addresses. It may be either a suitable
960    hard register or a pseudo register that has been allocated such a
961    hard register. 
962
963   On the 1610 the Y address pointers can be used as a base registers */
964 #define REGNO_OK_FOR_BASE_P(REGNO) \
965 (((REGNO) >= REG_R0 && (REGNO) < REG_R3 + 1) || ((unsigned) reg_renumber[REGNO] >= REG_R0  \
966                                    && (unsigned) reg_renumber[REGNO] < REG_R3 + 1))
967
968 #define REGNO_OK_FOR_YBASE_P(REGNO) \
969   (((REGNO) == REG_YBASE) || ((unsigned) reg_renumber[REGNO] == REG_YBASE))
970
971 #define REGNO_OK_FOR_INDEX_P(REGNO)  0
972
973 #ifdef ALL_16_BIT_REGISTERS
974 #define IS_32_BIT_REG(REGNO)  0
975 #else
976 #define IS_32_BIT_REG(REGNO)     \
977   ((REGNO) == REG_A0 || (REGNO) == REG_A1 || (REGNO) == REG_Y || (REGNO) == REG_PROD)
978 #endif
979
980 /* Given an rtx X being reloaded into a reg required to be
981    in class CLASS, return the class of reg to actually use.
982    In general this is just CLASS; but on some machines
983    in some cases it is preferable to use a more restrictive class.
984    Also, we must ensure that a PLUS is reloaded either
985    into an accumulator or an address register.  */
986
987 #define PREFERRED_RELOAD_CLASS(X,CLASS)  preferred_reload_class (X, CLASS)
988
989 /*   A C expression that places additional restrictions on the register
990      class to use when it is necessary to be able to hold a value of
991      mode MODE in a reload register for which class CLASS would
992      ordinarily be used.
993
994      Unlike `PREFERRED_RELOAD_CLASS', this macro should be used when
995      there are certain modes that simply can't go in certain reload
996      classes.
997
998      The value is a register class; perhaps CLASS, or perhaps another,
999      smaller class.
1000
1001      Don't define this macro unless the target machine has limitations
1002      which require the macro to do something nontrivial. */
1003
1004 #if 0
1005 #define LIMIT_RELOAD_CLASS(MODE, CLASS) dsp16xx_limit_reload_class (MODE, CLASS)
1006 #endif
1007
1008 /* A C expression for the maximum number of consecutive registers of class CLASS
1009    needed to hold a vlaue of mode MODE */
1010 #define CLASS_MAX_NREGS(CLASS, MODE)                                \
1011     class_max_nregs(CLASS, MODE)
1012
1013 /* The letters 'I' through 'P' in a register constraint string
1014    can be used to stand for particular ranges of immediate operands.
1015    This macro defines what the ranges are.
1016    C is the letter, and VALUE is a constant value.
1017    Return 1 if VALUE is in the range specified by C.
1018
1019    For the 16xx, the following constraints are used:
1020    'I' requires a non-negative 16-bit value.
1021    'J' requires a non-negative 9-bit value
1022    'K' requires a constant 0 operand.
1023    'L' requires 16-bit value
1024    'M' 32-bit value -- low 16-bits zero
1025  */
1026
1027 #define SMALL_INT(X) (SMALL_INTVAL (INTVAL (X)))
1028 #define SMALL_INTVAL(I) ((unsigned) (I) < 0x10000)
1029 #define SHORT_IMMEDIATE(X)  (SHORT_INTVAL (INTVAL(X)))
1030 #define SHORT_INTVAL(I)     ((unsigned) (I) < 0x100)
1031
1032 #define CONST_OK_FOR_LETTER_P(VALUE, C)                           \
1033    ((C) == 'I' ? (SMALL_INTVAL(VALUE))                            \
1034     : (C) == 'J' ? (SHORT_INTVAL(VALUE))                          \
1035     : (C) == 'K' ? ((VALUE) == 0)                                 \
1036     : (C) == 'L' ? ! ((VALUE) & ~0x0000ffff)                      \
1037     : (C) == 'M' ? ! ((VALUE) & ~0xffff0000)                      \
1038     : (C) == 'N' ? ((VALUE) == -1 || (VALUE) == 1 ||              \
1039                     (VALUE) == -2 || (VALUE) == 2)                \
1040     : 0)
1041
1042 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C)   1
1043
1044 /* Optional extra constraints for this machine */
1045 #define EXTRA_CONSTRAINT(OP,C)                                    \
1046   ((C) == 'R' ? symbolic_address_p (OP)                           \
1047    : 0)
1048 \f
1049 /* DESCRIBING STACK LAYOUT AND CALLING CONVENTIONS */
1050
1051 /* Define this if pushing a word on the stack
1052    makes the stack pointer a smaller address.  */
1053 /* #define STACK_GROWS_DOWNWARD */
1054
1055 /* Define this if the nominal address of the stack frame
1056    is at the high-address end of the local variables;
1057    that is, each additional local variable allocated
1058    goes at a more negative offset in the frame.  */
1059 /* #define FRAME_GROWS_DOWNWARD */
1060
1061 #define ARGS_GROW_DOWNWARD
1062
1063 /* We use post decrement on the 1600 because there isn't
1064    a pre-decrement addressing mode. This means that we
1065    assume the stack pointer always points at the next
1066    FREE location on the stack. */
1067 #define STACK_PUSH_CODE POST_INC
1068
1069 /* Offset within stack frame to start allocating local variables at.
1070    If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
1071    first local allocated.  Otherwise, it is the offset to the BEGINNING
1072    of the first local allocated.  */
1073 #define STARTING_FRAME_OFFSET  0
1074
1075 /* Offset from the stack pointer register to the first
1076    location at which outgoing arguments are placed. */
1077 #define STACK_POINTER_OFFSET (0)
1078
1079 struct dsp16xx_frame_info
1080 {
1081   unsigned long total_size;     /* # bytes that the entire frame takes up */
1082   unsigned long var_size;       /* # bytes that variables take up */
1083   unsigned long args_size;      /* # bytes that outgoing arguments take up */
1084   unsigned long extra_size;     /* # bytes of extra gunk */
1085   unsigned int  reg_size;       /* # bytes needed to store regs */
1086   long          fp_save_offset; /* offset from vfp to store registers */
1087   unsigned long sp_save_offset; /* offset from new sp to store registers */
1088   int           initialized;    /* != 0 if frame size already calculated */
1089   int           num_regs;       /* number of registers saved */
1090   int           function_makes_calls;  /* Does the function make calls */
1091 };
1092
1093 extern struct dsp16xx_frame_info current_frame_info;
1094
1095 /* If we generate an insn to push BYTES bytes,
1096    this says how many the stack pointer really advances by. */
1097 /* #define PUSH_ROUNDING(BYTES) ((BYTES)) */
1098
1099 /* If defined, the maximum amount of space required for outgoing
1100    arguments will be computed and placed into the variable
1101    'current_function_outgoing_args_size'. No space will be pushed
1102    onto the stack for each call; instead, the function prologue should
1103    increase the stack frame size by this amount.
1104
1105    It is not proper to define both 'PUSH_ROUNDING' and
1106    'ACCUMULATE_OUTGOING_ARGS'. */
1107 #define ACCUMULATE_OUTGOING_ARGS
1108
1109 /* Offset of first parameter from the argument pointer
1110    register value. */
1111
1112 #define FIRST_PARM_OFFSET(FNDECL)   (0)
1113
1114 /* Value is 1 if returning from a function call automatically
1115    pops the arguments described by the number-of-args field in the call.
1116    FUNDECL is the declaration node of the function (as a tree),
1117    FUNTYPE is the data type of the function (as a tree),
1118    or for a library call it is an identifier node for the subroutine name. */
1119
1120 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
1121
1122 /* Define how to find the value returned by a function.
1123    VALTYPE is the data type of the value (as a tree).
1124    If the precise function being called is known, FUNC is its FUNCTION_DECL;
1125    otherwise, FUNC is 0. On the 1610 all function return their values
1126    in a0 (i.e. the upper 16 bits). If the return value is 32-bits the
1127    entire register is significant. */
1128
1129 #define VALUE_REGNO(MODE)  (REG_Y)
1130
1131 #define FUNCTION_VALUE(VALTYPE, FUNC)  \
1132   gen_rtx (REG, TYPE_MODE (VALTYPE), VALUE_REGNO(TYPE_MODE(VALTYPE)))
1133
1134 /* Define how to find the value returned by a library function
1135    assuming the value has mode MODE.  */
1136 #define LIBCALL_VALUE(MODE)  gen_rtx (REG, MODE, VALUE_REGNO(MODE))
1137
1138 /* 1 if N is a possible register number for a function value. */
1139 #define FUNCTION_VALUE_REGNO_P(N) ((N) == REG_Y)
1140 \f
1141
1142 /* Define where to put the arguments to a function.
1143    Value is zero to push the argument on the stack,
1144    or a hard register in which to store the argument.
1145
1146    MODE is the argument's machine mode.
1147    TYPE is the data type of the argument (as a tree).
1148     This is null for libcalls where that information may
1149     not be available.
1150    CUM is a variable of type CUMULATIVE_ARGS which gives info about
1151     the preceding args and about the function being called.
1152    NAMED is nonzero if this argument is a named parameter
1153     (otherwise it is an extra parameter matching an ellipsis).  */
1154
1155 /* On the 1610 all args are pushed, except if -mregparm is specified
1156    then the first two words of arguments are passed in a0, a1. */
1157 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1158   dsp16xx_function_arg (CUM, MODE, TYPE, NAMED)
1159
1160 /* Define the first register to be used for argument passing */
1161 #define FIRST_REG_FOR_FUNCTION_ARG REG_Y
1162
1163 /* Define the profitability of saving registers around calls.
1164    NOTE: For now we turn this off because of a bug in the
1165    caller-saves code and also because i'm not sure it is helpful
1166    on the 1610. */
1167
1168 #define CALLER_SAVE_PROFITABLE(REFS,CALLS) 0
1169
1170 /* This indicates that an argument is to be passed with an invisible reference
1171    (i.e., a pointer to the object is passed).
1172
1173    On the dsp16xx, we do this if it must be passed on the stack.  */
1174
1175 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED)  \
1176   (MUST_PASS_IN_STACK (MODE, TYPE))
1177
1178 /* For an arg passed partly in registers and partly in memory,
1179    this is the number of registers used.
1180    For args passed entirely in registers or entirely in memory, zero.  */
1181
1182 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED)  (0)
1183
1184 /* Define a data type for recording info about an argument list
1185    during the scan of that argument list.  This data type should
1186    hold all necessary information about the function itself
1187    and about the args processed so far, enough to enable macros
1188    such as FUNCTION_ARG to determine where the next arg should go. */
1189 #define CUMULATIVE_ARGS int
1190
1191 /* Initialize a variable CUM of type CUMULATIVE_ARGS
1192    for a call to a function whose data type is FNTYPE.
1193    For a library call, FNTYPE is 0. */
1194 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME)  ((CUM) = 0)
1195
1196 /* Update the data in CUM to advance over an argument
1197    of mode MODE and data type TYPE.
1198    (TYPE is null for libcalls where that information may not be available.)  */
1199
1200 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)    \
1201   dsp16xx_function_arg_advance (&CUM, MODE,TYPE, NAMED)
1202
1203 /* 1 if N is a possible register number for function argument passing. */
1204 #define FUNCTION_ARG_REGNO_P(N)   \
1205   ((N) == REG_Y || (N) == REG_YL || (N) == REG_PROD || (N) == REG_PRODL)
1206
1207 /* This macro generates the assembly code for function entry.
1208    FILE is a stdio stream to output the code to.
1209    SIZE is an int: how many units of temporary storage to allocate.
1210    Refer to the array `regs_ever_live' to determine which registers
1211    to save; `regs_ever_live[I]' is nonzero if register number I
1212    is ever used in the function.  This macro is responsible for
1213    knowing which registers should not be saved even if used. */
1214
1215 #define FUNCTION_PROLOGUE(FILE, SIZE)     function_prologue(FILE, SIZE)
1216
1217 /* Output assembler code to FILE to increment profiler label # LABELNO
1218    for profiling a function entry. */
1219
1220 #define FUNCTION_PROFILER(FILE, LABELNO)        fatal("Profiling not implemented yet.")
1221
1222 /* Output assembler code to FILE to initialize this source file's
1223    basic block profiling info, if that has not already been done. */
1224 #define FUNCTION_BLOCK_PROFILER(FILE, LABELNO)  fatal("Profiling not implemented yet.")
1225
1226 /* Output assembler code to FILE to increment the entry-count for
1227    the BLOCKNO'th basic block in this source file. */
1228 #define BLOCK_PROFILER(FILE, BLOCKNO)           fatal("Profiling not implemented yet.")
1229
1230
1231 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1232    the stack pointer does not matter.  The value is tested only in
1233    functions that have frame pointers.
1234    No definition is equivalent to always zero.  */
1235
1236 #define EXIT_IGNORE_STACK  (0)
1237
1238 #define TRAMPOLINE_TEMPLATE(FILE) fatal ("Trampolines not yet implemented");
1239
1240 /* Length in units of the trampoline for entering a nested function.
1241    This is a dummy value  */
1242
1243 #define TRAMPOLINE_SIZE 20
1244
1245 /* Emit RTL insns to initialize the variable parts of a trampoline.
1246    FNADDR is an RTX for the address of the function's pure code.
1247    CXT is an RTX for the static chain value for the function. */
1248
1249 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)                       \
1250   fatal ("Trampolines not yet implemented");
1251
1252 /* This macro generates the assembly code for function exit,
1253    on machines that need it.  If FUNCTION_EPILOGUE is not defined
1254    then individual return instructions are generated for each
1255    return statement.  Args are same as for FUNCTION_PROLOGUE.
1256
1257    The function epilogue should not depend on the current stack pointer!
1258    It should use the frame pointer only.  This is mandatory because
1259    of alloca; we also take advantage of it to omit stack adjustments
1260    before returning. */
1261
1262 #define FUNCTION_EPILOGUE(FILE, SIZE)   function_epilogue(FILE, SIZE)
1263
1264 /* A C expression which is nonzero if a function must have and use a
1265    frame pointer. If its value is nonzero the functions will have a
1266    frame pointer. */
1267 #define FRAME_POINTER_REQUIRED  (current_function_calls_alloca)
1268
1269 /* A C statement to store in the variable 'DEPTH' the difference
1270    between the frame pointer and the stack pointer values immediately
1271    after the function prologue. */
1272 #define INITIAL_FRAME_POINTER_OFFSET(DEPTH)                     \
1273 {  (DEPTH) = initial_frame_pointer_offset();                    \
1274 }
1275 \f
1276 /* IMPLICIT CALLS TO LIBRARY ROUTINES */
1277
1278 #define ADDHF3_LIBCALL      "__Emulate_addhf3"
1279 #define SUBHF3_LIBCALL      "__Emulate_subhf3"
1280 #define MULHF3_LIBCALL      "__Emulate_mulhf3"
1281 #define DIVHF3_LIBCALL      "__Emulate_divhf3"
1282 #define CMPHF3_LIBCALL      "__Emulate_cmphf3"
1283 #define FIXHFHI2_LIBCALL    "__Emulate_fixhfhi2"
1284 #define FLOATHIHF2_LIBCALL  "__Emulate_floathihf2"
1285 #define NEGHF2_LIBCALL      "__Emulate_neghf2"
1286
1287 #define UMULHI3_LIBCALL     "__Emulate_umulhi3"
1288 #define MULHI3_LIBCALL      "__Emulate_mulhi3"
1289 #define UDIVQI3_LIBCALL     "__Emulate_udivqi3"
1290 #define UDIVHI3_LIBCALL     "__Emulate_udivhi3"
1291 #define DIVQI3_LIBCALL      "__Emulate_divqi3"
1292 #define DIVHI3_LIBCALL      "__Emulate_divhi3"
1293 #define MODQI3_LIBCALL      "__Emulate_modqi3"
1294 #define MODHI3_LIBCALL      "__Emulate_modhi3"
1295 #define UMODQI3_LIBCALL     "__Emulate_umodqi3"
1296 #define UMODHI3_LIBCALL     "__Emulate_umodhi3"
1297 #define ASHRHI3_LIBCALL     "__Emulate_ashrhi3"
1298 #define LSHRHI3_LIBCALL     "__Emulate_lshrhi3"
1299 #define ASHLHI3_LIBCALL     "__Emulate_ashlhi3"
1300 #define LSHLHI3_LIBCALL     "__Emulate_lshlhi3"   /* NOT USED */
1301
1302 /* Define this macro if calls to the ANSI C library functions memcpy and
1303    memset should be generated instead of the BSD function bcopy & bzero. */
1304 #define TARGET_MEM_FUNCTIONS
1305
1306 \f
1307 /* ADDRESSING MODES */
1308
1309 /* The 1610 has post-increment and decrement, but no pre-modify */
1310 #define HAVE_POST_INCREMENT
1311 #define HAVE_POST_DECREMENT
1312
1313 /* #define HAVE_PRE_DECREMENT */
1314 /* #define HAVE_PRE_INCREMENT */
1315
1316 /* Recognize any constant value that is a valid address.  */
1317 #define CONSTANT_ADDRESS_P(X)  CONSTANT_P (X)
1318
1319 /* Maximum number of registers that can appear in a valid memory address.  */
1320 #define MAX_REGS_PER_ADDRESS 1
1321
1322 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1323    and check its validity for a certain class.
1324    We have two alternate definitions for each of them.
1325    The usual definition accepts all pseudo regs; the other rejects
1326    them unless they have been allocated suitable hard regs.
1327    The symbol REG_OK_STRICT causes the latter definition to be used.
1328
1329    Most source files want to accept pseudo regs in the hope that
1330    they will get allocated to the class that the insn wants them to be in.
1331    Source files for reload pass need to be strict.
1332    After reload, it makes no difference, since pseudo regs have
1333    been eliminated by then.  */
1334
1335 #ifndef REG_OK_STRICT
1336
1337 /* Nonzero if X is a hard reg that can be used as an index
1338    or if it is a pseudo reg.  */
1339 #define REG_OK_FOR_INDEX_P(X)  0
1340
1341 /* Nonzero if X is a hard reg that can be used as a base reg
1342    or if it is a pseudo reg.  */
1343 #define REG_OK_FOR_BASE_P(X)    \
1344     ((REGNO (X) >= REG_R0 && REGNO (X) < REG_R3 + 1 )          \
1345        || (REGNO (X) >= FIRST_PSEUDO_REGISTER))
1346
1347 /* Nonzero if X is the 'ybase' register */
1348 #define REG_OK_FOR_YBASE_P(X)   \
1349   (REGNO(X) == REG_YBASE || (REGNO (X) >= FIRST_PSEUDO_REGISTER))
1350 #else
1351
1352 /* Nonzero if X is a hard reg that can be used as an index.  */
1353 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
1354
1355 /* Nonzero if X is a hard reg that can be used as a base reg.  */
1356 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
1357
1358 /* Nonzero if X is the 'ybase' register */
1359 #define REG_OK_FOR_YBASE_P(X) REGNO_OK_FOR_YBASE_P (REGNO(X))
1360
1361 #endif
1362 \f
1363 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1364    that is a valid memory address for an instruction.
1365    The MODE argument is the machine mode for the MEM expression
1366    that wants to use this address.
1367
1368    On the 1610, the actual legitimate addresses must be N (N must fit in
1369    5 bits), *rn (register indirect), *rn++, or *rn-- */
1370
1371 #define INT_FITS_5_BITS(I)    ((unsigned long) (I) < 0x20)
1372 #define INT_FITS_16_BITS(I)   ((unsigned long) (I) < 0x10000)
1373 #define YBASE_CONST_OFFSET(I)       ((I) >= -31 && (I) <= 0)
1374 #define YBASE_OFFSET(X)       (GET_CODE (X) == CONST_INT && YBASE_CONST_OFFSET (INTVAL(X)))
1375
1376 #define FITS_16_BITS(X)       (GET_CODE (X) == CONST_INT && INT_FITS_16_BITS(INTVAL(X)))
1377 #define FITS_5_BITS(X)        (GET_CODE (X) == CONST_INT && INT_FITS_5_BITS(INTVAL(X)))
1378 #define ILLEGAL_HIMODE_ADDR(MODE, CONST)  ((MODE) == HImode && CONST == -31)
1379
1380 #define INDIRECTABLE_ADDRESS_P(X)                            \
1381     ((GET_CODE(X) == REG && REG_OK_FOR_BASE_P(X))            \
1382   || ((GET_CODE(X) == POST_DEC || GET_CODE(X) == POST_INC)   \
1383        && REG_P(XEXP(X,0)) && REG_OK_FOR_BASE_P(XEXP(X,0)))  \
1384   || (GET_CODE(X) == CONST_INT && (unsigned long) (X) < 0x20))
1385
1386
1387 #define INDEXABLE_ADDRESS_P(X,MODE)                                 \
1388    ((GET_CODE(X) == PLUS && GET_CODE (XEXP (X,0)) == REG &&         \
1389      XEXP(X,0) == stack_pointer_rtx && YBASE_OFFSET(XEXP(X,1)) &&   \
1390      !ILLEGAL_HIMODE_ADDR(MODE, INTVAL(XEXP(X,1)))) ||              \
1391     (GET_CODE(X) == PLUS && GET_CODE (XEXP (X,1)) == REG &&         \
1392      XEXP(X,1) == stack_pointer_rtx && YBASE_OFFSET(XEXP(X,0)) &&  \
1393      !ILLEGAL_HIMODE_ADDR(MODE, INTVAL(XEXP(X,0)))))
1394
1395 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)                     \
1396 {                                                                   \
1397     if (INDIRECTABLE_ADDRESS_P(X))                                  \
1398         goto ADDR;                                                  \
1399 }
1400
1401 \f
1402 /* Try machine-dependent ways of modifying an illegitimate address
1403    to be legitimate.  If we find one, return the new, valid address.
1404    This macro is used in only one place: `memory_address' in explow.c.
1405
1406    OLDX is the address as it was before break_out_memory_refs was called.
1407    In some cases it is useful to look at this to decide what needs to be done.
1408
1409    MODE and WIN are passed so that this macro can use
1410    GO_IF_LEGITIMATE_ADDRESS.
1411
1412    It is always safe for this macro to do nothing.  It exists to recognize
1413    opportunities to optimize the output.
1414
1415    For the 1610, we need not do anything.  However, if we don't,
1416    `memory_address' will try lots of things to get a valid address, most of
1417    which will result in dead code and extra pseudos.  So we make the address
1418    valid here.
1419
1420    This is easy:  The only valid addresses are an offset from a register
1421    and we know the address isn't valid.  So just call either `force_operand'
1422    or `force_reg' unless this is a (plus (reg ...) (const_int 0)).  */
1423
1424 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN)                     \
1425 { if (GET_CODE (X) == PLUS && XEXP (X, 1) == const0_rtx)        \
1426     X = XEXP (x, 0);                                            \
1427   if (GET_CODE (X) == MULT || GET_CODE (X) == PLUS)             \
1428     X = force_operand (X, 0);                                   \
1429   else                                                          \
1430     X = force_reg (Pmode, X);                                   \
1431   goto WIN;                                                     \
1432 }
1433
1434 /* Go to LABEL if ADDR (a legitimate address expression)
1435    has an effect that depends on the machine mode it is used for.
1436    On the 1610, only postdecrement and postincrement address depend thus
1437    (the amount of decrement or increment being the length of the operand).  */
1438
1439 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)        \
1440  if (GET_CODE (ADDR) == POST_INC || GET_CODE (ADDR) == POST_DEC) goto LABEL
1441
1442 /* Nonzero if the constant value X is a legitimate general operand.
1443    It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.  */
1444 #define LEGITIMATE_CONSTANT_P(X) (1)
1445
1446 \f
1447 /* CONDITION CODE INFORMATION */
1448
1449 /* Store in cc_status the expressions
1450    that the condition codes will describe
1451    after execution of an instruction whose pattern is EXP.
1452    Do not alter them if the instruction would not alter the cc's. */
1453
1454 #define NOTICE_UPDATE_CC(EXP, INSN) \
1455    notice_update_cc( (EXP) )
1456 \f
1457 /* DESCRIBING RELATIVE COSTS OF OPERATIONS */
1458
1459 /* Compute the cost of computing a constant rtl expression RTX
1460    whose rtx-code is CODE.  The body of this macro is a portion
1461    of a switch statement.  If the code is computed here,
1462    return it with a return statement. */
1463 #define CONST_COSTS(RTX,CODE,OUTER_CODE)                                \
1464   case CONST_INT:                                                       \
1465     return 0;                                                           \
1466   case LABEL_REF:                                                       \
1467   case SYMBOL_REF:                                                      \
1468   case CONST:                                                           \
1469     return COSTS_N_INSNS (1);                                           \
1470                                                                         \
1471   case CONST_DOUBLE:                                                    \
1472     return COSTS_N_INSNS (2);
1473
1474 /* Like CONST_COSTS but applies to nonconstant RTL expressions.
1475    This can be used, for example to indicate how costly a multiply
1476    instruction is. */
1477 #define RTX_COSTS(X,CODE,OUTER_CODE)                            \
1478   case MEM:                                                     \
1479     return GET_MODE (X) == QImode ? COSTS_N_INSNS (2) :         \
1480                                     COSTS_N_INSNS (4);          \
1481   case DIV:                                                     \
1482   case MOD:                                                     \
1483     return COSTS_N_INSNS (38);                                  \
1484   case MULT:                                                    \
1485     if (GET_MODE (X) == QImode)                                 \
1486         return COSTS_N_INSNS (2);                               \
1487     else                                                        \
1488         return COSTS_N_INSNS (38);                              \
1489   case PLUS:                                                    \
1490     if (GET_MODE_CLASS (GET_MODE (X)) == MODE_INT)              \
1491     {                                                           \
1492         if (GET_CODE (XEXP (X,1)) == CONST_INT)                 \
1493         {                                                       \
1494             int number = INTVAL(XEXP (X,1));                    \
1495             if (number == 1)                                    \
1496                return COSTS_N_INSNS (1);                        \
1497             if (INT_FITS_16_BITS(number))                       \
1498                 return COSTS_N_INSNS (2);                       \
1499             else                                                \
1500                 return COSTS_N_INSNS (4);                       \
1501         }                                                       \
1502         return COSTS_N_INSNS (1);                               \
1503     }                                                           \
1504     else                                                        \
1505         return COSTS_N_INSNS (38);                              \
1506   case MINUS:                                                   \
1507     if (GET_MODE_CLASS (GET_MODE (X)) == MODE_INT)              \
1508     {                                                           \
1509         if (GET_CODE (XEXP (X,1)) == CONST_INT)                 \
1510         {                                                       \
1511             if (INT_FITS_16_BITS(INTVAL(XEXP(X,1))))            \
1512                 return COSTS_N_INSNS (2);                       \
1513             else                                                \
1514                 return COSTS_N_INSNS (4);                       \
1515         }                                                       \
1516         return COSTS_N_INSNS (1);                               \
1517     }                                                           \
1518     else                                                        \
1519         return COSTS_N_INSNS (38);                              \
1520   case AND: case IOR: case XOR:                                 \
1521     if (GET_CODE (XEXP (X,1)) == CONST_INT)                     \
1522       {                                                         \
1523         if (INT_FITS_16_BITS(INTVAL(XEXP(X,1))))                \
1524             return COSTS_N_INSNS (2);                           \
1525         else                                                    \
1526             return COSTS_N_INSNS (4);                           \
1527       }                                                         \
1528     return COSTS_N_INSNS (1);                                   \
1529   case NEG: case NOT:                                           \
1530     return COSTS_N_INSNS (1);                                   \
1531   case ASHIFT:                                                  \
1532   case ASHIFTRT:                                                \
1533   case LSHIFTRT:                                                \
1534     if (GET_CODE (XEXP (X,1)) == CONST_INT)                     \
1535       {                                                         \
1536         int number = INTVAL(XEXP (X,1));                        \
1537         if (number == 1 || number == 4 || number == 8 ||        \
1538             number == 16)                                       \
1539             return COSTS_N_INSNS (1);                           \
1540         else                                                    \
1541             return COSTS_N_INSNS (2);                           \
1542       }                                                         \
1543     return COSTS_N_INSNS (1);
1544
1545 /* An expression giving the cost of an addressing mode that contains
1546    address. */
1547 #define ADDRESS_COST(ADDR)  dsp16xx_address_cost (ADDR)
1548
1549 /* A c expression for the cost of moving data from a register in
1550    class FROM to one in class TO. The classes are expressed using
1551    the enumeration values such as GENERAL_REGS. A value of 2 is
1552    the default. */
1553 #define REGISTER_MOVE_COST(FROM,TO)  dsp16xx_register_move_cost (FROM, TO)
1554
1555 /* A C expression for the cost of moving data of mode MODE between
1556    a register and memory. A value of 2 is the default. */
1557 #define MEMORY_MOVE_COST(MODE)                                  \
1558   (GET_MODE_CLASS(MODE) == MODE_INT && MODE == QImode ? 12       \
1559    : 16)
1560
1561 /* A C expression for the cost of a branch instruction. A value of
1562    1 is the default; */
1563 #define BRANCH_COST 2
1564 \f
1565
1566 /* Define this because otherwise gcc will try to put the function address
1567    in any old pseudo register. We can only use pt. */
1568 #define NO_FUNCTION_CSE
1569
1570 /* Define this macro as a C expression which is nonzero if accessing less
1571    than a word of memory (i.e a char or short) is no faster than accessing
1572    a word of memory, i.e if such access require more than one instruction
1573    or if ther is no difference in cost between byte and (aligned) word
1574    loads. */
1575 #define SLOW_BYTE_ACCESS 1
1576
1577 /* Define this macro if zero-extension (of a char or short to an int) can
1578    be done faster if the destination is a register that is know to be zero. */
1579 /* #define SLOW_ZERO_EXTEND */
1580
1581 /* Define this macro if unaligned accesses have a cost many times greater than
1582    aligned accesses, for example if they are emulated in a trap handler */
1583 /* define SLOW_UNALIGNED_ACCESS */
1584
1585 /* Define this macro to inhibit strength reduction of memory addresses */
1586 /* #define DONT_REDUCE_ADDR */
1587
1588 \f
1589 /* DIVIDING THE OUTPUT IN SECTIONS */
1590 /* Output before read-only data.  */
1591
1592 #define DEFAULT_TEXT_SEG_NAME ".text"
1593 #define TEXT_SECTION_ASM_OP  rsect_text
1594
1595 /* Output before constants and strings */
1596 #define DEFAULT_CONST_SEG_NAME  ".const"
1597 #define READONLY_SECTION_ASM_OP rsect_const
1598 #define READONLY_DATA_SECTION   const_section
1599
1600 /* Output before writable data.  */
1601 #define DEFAULT_DATA_SEG_NAME ".data"
1602 #define DATA_SECTION_ASM_OP  rsect_data
1603
1604 #define DEFAULT_BSS_SEG_NAME ".bss"
1605 #define BSS_SECTION_ASM_OP rsect_bss
1606
1607 /* We will default to using 1610 if the user doesn't
1608    specify it. */
1609 #define DEFAULT_CHIP_NAME "1610"
1610
1611 /* A list of names for sections other than the standard two, which are
1612    'in_text' and 'in_data'. */
1613 #define EXTRA_SECTIONS in_bss, in_const
1614
1615 #define EXTRA_SECTION_FUNCTIONS  \
1616 void                                                               \
1617 const_section ()                                                   \
1618 {                                                                  \
1619     if (in_section != in_const)                                    \
1620     {                                                              \
1621         fprintf (asm_out_file, "%s\n", READONLY_SECTION_ASM_OP);   \
1622         in_section = in_const;                                     \
1623     }                                                              \
1624 }                                                                  \
1625 void                                                               \
1626 bss_section ()                                                     \
1627 {                                                                  \
1628     if (in_section != in_bss) {                                    \
1629         fprintf (asm_out_file, "%s\n", BSS_SECTION_ASM_OP);        \
1630         in_section = in_bss;                                       \
1631     }                                                              \
1632 }
1633
1634 \f
1635 /* THE OVERALL FRAMEWORK OF AN ASSEMBLER FILE */
1636
1637 /* Output at beginning of assembler file.  */
1638 #define ASM_FILE_START(FILE) dsp16xx_file_start () 
1639
1640 /* Prevent output of .gcc_compiled */
1641 #define ASM_IDENTIFY_GCC(FILE)   
1642
1643 /* A C string constant describing how to begin a comment in the target
1644    assembler language. */
1645 /* define ASM_COMMENT_START */
1646
1647 /* Output to assembler file text saying following lines
1648    may contain character constants, extra white space, comments, etc.  */
1649 #define ASM_APP_ON ""
1650
1651 /* Output to assembler file text saying following lines
1652    no longer contain unusual constructs.  */
1653 #define ASM_APP_OFF ""
1654 \f
1655 /* OUTPUT OF DATA */
1656
1657 /* This is how to output an assembler line defining a `double' constant.  */
1658 #define ASM_OUTPUT_DOUBLE(FILE,VALUE)  asm_output_float (FILE,VALUE)
1659
1660 /* This is how to output an assembler line defining a `float' constant.  */
1661 #define ASM_OUTPUT_FLOAT(FILE,VALUE)  asm_output_float (FILE, VALUE)
1662
1663 /* This is how to output and assembler line defininf a 'float' constant of
1664    size HFmode. */
1665 #define ASM_OUTPUT_SHORT_FLOAT(FILE,VALUE)  asm_output_float (FILE, VALUE)
1666
1667 /* This is how to output an assembler line defining an `char' constant.  */
1668 #define ASM_OUTPUT_CHAR(FILE,VALUE)              \
1669 ( fprintf (FILE, "\tint "),                     \
1670   output_addr_const (FILE, (VALUE)),            \
1671   fprintf (FILE, "\n"))
1672
1673 /* This is how to output an assembler line defining an `short' constant.  */
1674 #define ASM_OUTPUT_SHORT(FILE,EXP)   asm_output_long(FILE,INTVAL(EXP))
1675
1676 /* This is how to output an assembler line defining a 'int' constant. */
1677 #define ASM_OUTPUT_INT(FILE, EXP)    asm_output_long(FILE,INTVAL(EXP))
1678
1679 /* This is how to output an assembler line for a numeric constant byte.  */
1680 #define ASM_OUTPUT_BYTE(FILE,VALUE)    ASM_OUTPUT_CHAR(FILE,VALUE)
1681
1682 /* This is how we output a 'c' character string. For the 16xx
1683    assembler we have to do it one letter at a time */
1684
1685 #define ASCII_LENGTH 10
1686
1687 #define ASM_OUTPUT_ASCII(MYFILE, MYSTRING, MYLENGTH) \
1688   do {                                                                        \
1689     FILE *_hide_asm_out_file = (MYFILE);                                      \
1690     unsigned char *_hide_p = (unsigned char *) (MYSTRING);                    \
1691     int _hide_thissize = (MYLENGTH);                                          \
1692     {                                                                         \
1693       FILE *asm_out_file = _hide_asm_out_file;                                \
1694       unsigned char *p = _hide_p;                                             \
1695       int thissize = _hide_thissize;                                          \
1696       int i;                                                                  \
1697                                                                               \
1698       for (i = 0; i < thissize; i++)                                          \
1699         {                                                                     \
1700           register int c = p[i];                                              \
1701                                                                               \
1702           if (i % ASCII_LENGTH == 0) \
1703             fprintf (asm_out_file, "\tint ");                                 \
1704                                                                         \
1705           if (c >= ' ' && c < 0177 && c != '\'')                              \
1706           {                                                                   \
1707             putc ('\'', asm_out_file);                                        \
1708             putc (c, asm_out_file);                                           \
1709             putc ('\'', asm_out_file);                                        \
1710           }                                                                   \
1711           else                                                                \
1712             {                                                                 \
1713               fprintf (asm_out_file, "%d", c);                                \
1714               /* After an octal-escape, if a digit follows,                   \
1715                  terminate one string constant and start another.             \
1716                  The Vax assembler fails to stop reading the escape           \
1717                  after three digits, so this is the only way we               \
1718                  can get it to parse the data properly.                       \
1719               if (i < thissize - 1                                            \
1720                   && p[i + 1] >= '0' && p[i + 1] <= '9')                      \
1721                 fprintf (asm_out_file, "\'\n\tint \'");                       \
1722                 */ \
1723           }                                                                   \
1724           /* if: \
1725              we are not at the last char (i != thissize -1) \
1726              and (we are not at a line break multiple  \
1727              but i == 0) (it will be the very first time) \
1728              then put out a comma to extend. \
1729            */ \
1730           if ((i != thissize - 1) && ((i + 1) % ASCII_LENGTH))        \
1731             fprintf(asm_out_file, ",");                               \
1732           if (!((i + 1) % ASCII_LENGTH)) \
1733             fprintf (asm_out_file, "\n");                             \
1734         }                                                                     \
1735       fprintf (asm_out_file, "\n");                                           \
1736     }                                                                         \
1737   }                                                                           \
1738   while (0)
1739
1740 /* Store in OUTPUT a string (made with alloca) containing
1741    an assembler-name for a local static variable or function
1742    named NAME. LABELNO is an integer which is different for
1743    each call. */
1744
1745 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO)                  \
1746   do {                                                                  \
1747     int len = strlen (NAME);                                            \
1748     char *temp = (char *) alloca (len + 3);                             \
1749     temp[0] = 'L';                                                      \
1750     strcpy (&temp[1], (NAME));                                          \
1751     temp[len + 1] = '_';                                                \
1752     temp[len + 2] = 0;                                                  \
1753     (OUTPUT) = (char *) alloca (strlen (NAME) + 11);                    \
1754     ASM_GENERATE_INTERNAL_LABEL (OUTPUT, temp, LABELNO);                \
1755   } while (0)
1756
1757 #define ASM_OPEN_PAREN "("
1758 #define ASM_CLOSE_PAREN ")"
1759
1760 \f
1761 /* OUTPUT OF UNINITIALIZED VARIABLES */
1762
1763 /* This says how to output an assembler line
1764    to define a global common symbol.  */
1765
1766 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
1767   asm_output_common (FILE, NAME, SIZE, ROUNDED);
1768
1769 /* This says how to output an assembler line
1770    to define a local common symbol.  */
1771
1772 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)  \
1773   asm_output_local (FILE, NAME, SIZE, ROUNDED);
1774 \f
1775 /* OUTPUT AND GENERATION OF LABELS */
1776
1777 /* This is how to output the definition of a user-level label named NAME,
1778    such as the label on a static function or variable NAME.  */
1779 #define ASM_OUTPUT_LABEL(FILE,NAME)     \
1780   do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
1781
1782 /* This is how to output a command to make the user-level label named NAME
1783    defined for reference from other files.  */
1784
1785 #define ASM_GLOBALIZE_LABEL(FILE,NAME)  \
1786   do { fputs (".global ", FILE); assemble_name (FILE, NAME); fputs ("\n", FILE);} while (0)
1787
1788 /* A C statement to output to the stdio stream any text necessary
1789    for declaring the name of an external symbol named name which
1790    is referenced in this compilation but not defined. */
1791
1792 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)   \
1793 {                                       \
1794         fprintf (FILE, ".extern ");     \
1795         assemble_name (FILE, NAME);     \
1796         fprintf (FILE, "\n");           \
1797 }
1798 /* A C statement to output on stream an assembler pseudo-op to
1799    declare a library function named external. */
1800
1801 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN)    \
1802 {                                               \
1803         fprintf (FILE, ".extern ");             \
1804         assemble_name (FILE, XSTR (FUN, 0));    \
1805         fprintf (FILE, "\n");                   \
1806 }
1807 /* This is how to output a reference to a user-level label named NAME.
1808    `assemble_name' uses this.  */
1809 #define ASM_OUTPUT_LABELREF(FILE,NAME)  \
1810   fprintf (FILE, "_%s", NAME)
1811
1812 /* This is how to output an internal numbered label where
1813    PREFIX is the class of label and NUM is the number within the class.  */
1814 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)      \
1815   fprintf (FILE, "%s%d:\n", PREFIX, NUM)
1816
1817 /* This is how to store into the string LABEL
1818    the symbol_ref name of an internal numbered label where
1819    PREFIX is the class of label and NUM is the number within the class.
1820    This is suitable for output with `assemble_name'.  */
1821 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
1822   sprintf (LABEL, "*%s%d", PREFIX, NUM)
1823
1824 \f
1825 /* OUTPUT OF ASSEMBLER INSTRUCTIONS */
1826
1827 /* How to refer to registers in assembler output.
1828    This sequence is indexed by compiler's hard-register-number (see above).  */
1829
1830 #define REGISTER_NAMES \
1831 {"a0", "a0l", "a1", "a1l", "x", "y", "yl", "p", "pl",  \
1832  "r0", "r1", "r2",  "r3", "j", "k", "ybase", "pt",     \
1833  "ar0", "ar1", "ar2", "ar3",                           \
1834  "c0", "c1", "c2", "pr", "rb",                         \
1835  "*(0)", "*(1)", "*(2)", "*(3)", "*(4)", "*(5)",       \
1836  "*(6)", "*(7)", "*(8)", "*(9)", "*(10)", "*(11)",     \
1837  "*(12)", "*(13)", "*(14)", "*(15)", "*(16)", "*(17)", \
1838  "*(18)", "*(19)", "*(20)", "*(21)", "*(22)", "*(23)", \
1839  "*(24)", "*(25)", "*(26)", "*(27)", "*(28)", "*(29)", \
1840  "*(30)", "*(31)" }
1841
1842 #define HIMODE_REGISTER_NAMES \
1843 {"a0", "a0", "a1", "a1", "x", "y", "y", "p", "p",  \
1844  "r0", "r1", "r2",  "r3", "j", "k", "ybase", "pt",     \
1845  "ar0", "ar1", "ar2", "ar3",                           \
1846  "c0", "c1", "c2", "pr", "rb",                         \
1847  "*(0)", "*(1)", "*(2)", "*(3)", "*(4)", "*(5)",       \
1848  "*(6)", "*(7)", "*(8)", "*(9)", "*(10)", "*(11)",     \
1849  "*(12)", "*(13)", "*(14)", "*(15)", "*(16)", "*(17)", \
1850  "*(18)", "*(19)", "*(20)", "*(21)", "*(22)", "*(23)", \
1851  "*(24)", "*(25)", "*(26)", "*(27)", "*(28)", "*(29)", \
1852  "*(30)", "*(31)" }
1853
1854 #define PRINT_OPERAND_PUNCT_VALID_P(CODE)  0
1855
1856 /* Print operand X (an rtx) in assembler syntax to file FILE.
1857    CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1858    For `%' followed by punctuation, CODE is the punctuation and X is null.
1859    
1860    DSP1610 extensions for operand codes:
1861
1862    %H - print lower 16 bits of constant
1863    %U - print upper 16 bits of constant
1864    %w - print low half of register (e.g 'a0l')
1865    %u - print upper half of register (e.g 'a0')
1866    %b - print high half of accumulator for F3 ALU instructions
1867    %h - print constant in decimal   */
1868
1869 #define PRINT_OPERAND(FILE, X, CODE) print_operand(FILE, X, CODE)
1870
1871
1872 /* Print a memory address as an operand to reference that memory location. */
1873
1874 #define PRINT_OPERAND_ADDRESS(FILE, ADDR)  print_operand_address (FILE, ADDR)
1875
1876 /* This is how to output an insn to push a register on the stack.
1877    It need not be very fast code since it is used only for profiling  */
1878 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO)    fatal("Profiling not implemented yet.");
1879
1880 /* This is how to output an insn to pop a register from the stack.
1881    It need not be very fast code since it is used only for profiling  */
1882 #define ASM_OUTPUT_REG_POP(FILE,REGNO)     fatal("Profiling not implemented yet."); 
1883 \f
1884 /* OUTPUT OF DISPATCH TABLES */
1885
1886 /* This macro should be provided on machines where the addresses in a dispatch
1887    table are relative to the table's own address. */
1888 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL)  \
1889   fprintf (FILE, "\tint L%d-L%d\n", VALUE, REL)
1890
1891 /* This macro should be provided on machines where the addresses in a dispatch
1892    table are absolute. */
1893 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE)  \
1894   fprintf (FILE, "\tint L%d\n", VALUE)
1895
1896 /* ASSEMBLER COMMANDS FOR ALIGNMENT */
1897
1898 /* This is how to output an assembler line that says to advance 
1899    the location counter to a multiple of 2**LOG bytes. We should
1900    not have to do any alignment since the 1610 is a word machine. */
1901 #define ASM_OUTPUT_ALIGN(FILE,LOG)
1902
1903 /* Define this macro if ASM_OUTPUT_SKIP should not be used in the text section
1904    because it fails to put zero1 in the bytes that are skipped. */
1905 #define ASM_NO_SKIP_IN_TEXT 1
1906
1907 #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
1908   fprintf (FILE, "\t%d * int 0\n", (SIZE))
1909
1910 /* CONTROLLING DEBUGGING INFORMATION FORMAT */
1911
1912 /* Define this macro if GCC should produce COFF-style debugging output
1913    for SDB in response to the '-g' option */
1914 #define SDB_DEBUGGING_INFO
1915
1916 /* Support generating stabs for the listing file generator */
1917 #define DBX_DEBUGGING_INFO
1918
1919 /* The default format when -g is given is still COFF debug info */
1920 #define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
1921
1922 #define DBX_REGISTER_NUMBER(REGNO)   (REGNO)
1923 \f
1924 /* MISCELLANEOUS PARAMETERS */
1925
1926 /* Specify the machine mode that this machine uses
1927    for the index in the tablejump instruction.  */
1928 #define CASE_VECTOR_MODE QImode
1929
1930 /* Define this if the tablejump instruction expects the table
1931    to contain offsets from the address of the table.
1932    Do not define this if the table should contain absolute addresses.  */
1933 /* #define CASE_VECTOR_PC_RELATIVE  */
1934
1935 /* Specify the tree operation to be used to convert reals to integers.  */
1936 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1937
1938 /* This is the kind of divide that is easiest to do in the general case.  */
1939 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
1940
1941 /* Max number of bytes we can move from memory to memory
1942    in one reasonably fast instruction.  */
1943 #define MOVE_MAX 1
1944
1945 /* Defining this macro causes the compiler to omit a sign-extend, zero-extend,
1946    or bitwise 'and' instruction that truncates the count of a shift operation
1947    to a width equal to the number of bits needed to represent the size of the
1948    object being shifted. Do not define this macro unless the truncation applies
1949    to both shift operations and bit-field operations (if any). */
1950 /* #define SHIFT_COUNT_TRUNCATED */
1951
1952 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1953    is done just by pretending it is already truncated.  */
1954 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1955
1956 /* When a prototype says `char' or `short', really pass an `int'.  */
1957 #define PROMOTE_PROTOTYPES
1958
1959 /* An alias for the machine mode used for pointers */
1960 #define Pmode  QImode
1961
1962 /* A function address in a call instruction
1963    is a byte address (for indexing purposes)
1964    so give the MEM rtx a byte's mode.  */
1965 #define FUNCTION_MODE  QImode
1966
1967 #if !defined(__DATE__)
1968 #define TARGET_VERSION fprintf (stderr, " (%s)", VERSION_INFO1)
1969 #else
1970 #define TARGET_VERSION fprintf (stderr, " (%s, %s)", VERSION_INFO1, __DATE__)
1971 #endif
1972
1973 #define VERSION_INFO1 "AT&T DSP16xx C Cross Compiler, version 1.2.0"
1974
1975
1976 /* Define this as 1 if `char' should by default be signed; else as 0.  */
1977 #define DEFAULT_SIGNED_CHAR 1
1978
1979 /* If this macro is defined, GNU CC gathers statistics about the number and
1980    kind of tree node it allocates during each run. The option '-fstats' will
1981    tell the compiler to print these statistics about the sizes of it obstacks. */
1982 #define GATHER_STATISTICS
1983
1984 /* Define this so gcc does not output a call to __main, since we
1985    are not currently supporting c++. */
1986 #define INIT_SECTION_ASM_OP  1