OSDN Git Service

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