OSDN Git Service

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