xref: /openbsd/gnu/gcc/gcc/config/pdp11/pdp11.c (revision 404b540a)
1*404b540aSrobert /* Subroutines for gcc2 for pdp11.
2*404b540aSrobert    Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2004, 2005
3*404b540aSrobert    Free Software Foundation, Inc.
4*404b540aSrobert    Contributed by Michael K. Gschwind (mike@vlsivie.tuwien.ac.at).
5*404b540aSrobert 
6*404b540aSrobert This file is part of GCC.
7*404b540aSrobert 
8*404b540aSrobert GCC is free software; you can redistribute it and/or modify
9*404b540aSrobert it under the terms of the GNU General Public License as published by
10*404b540aSrobert the Free Software Foundation; either version 2, or (at your option)
11*404b540aSrobert any later version.
12*404b540aSrobert 
13*404b540aSrobert GCC is distributed in the hope that it will be useful,
14*404b540aSrobert but WITHOUT ANY WARRANTY; without even the implied warranty of
15*404b540aSrobert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*404b540aSrobert GNU General Public License for more details.
17*404b540aSrobert 
18*404b540aSrobert You should have received a copy of the GNU General Public License
19*404b540aSrobert along with GCC; see the file COPYING.  If not, write to
20*404b540aSrobert the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21*404b540aSrobert Boston, MA 02110-1301, USA.  */
22*404b540aSrobert 
23*404b540aSrobert #include "config.h"
24*404b540aSrobert #include "system.h"
25*404b540aSrobert #include "coretypes.h"
26*404b540aSrobert #include "tm.h"
27*404b540aSrobert #include "rtl.h"
28*404b540aSrobert #include "regs.h"
29*404b540aSrobert #include "hard-reg-set.h"
30*404b540aSrobert #include "real.h"
31*404b540aSrobert #include "insn-config.h"
32*404b540aSrobert #include "conditions.h"
33*404b540aSrobert #include "function.h"
34*404b540aSrobert #include "output.h"
35*404b540aSrobert #include "insn-attr.h"
36*404b540aSrobert #include "flags.h"
37*404b540aSrobert #include "recog.h"
38*404b540aSrobert #include "tree.h"
39*404b540aSrobert #include "expr.h"
40*404b540aSrobert #include "toplev.h"
41*404b540aSrobert #include "tm_p.h"
42*404b540aSrobert #include "target.h"
43*404b540aSrobert #include "target-def.h"
44*404b540aSrobert 
45*404b540aSrobert /*
46*404b540aSrobert #define FPU_REG_P(X)	((X)>=8 && (X)<14)
47*404b540aSrobert #define CPU_REG_P(X)	((X)>=0 && (X)<8)
48*404b540aSrobert */
49*404b540aSrobert 
50*404b540aSrobert /* this is the current value returned by the macro FIRST_PARM_OFFSET
51*404b540aSrobert    defined in tm.h */
52*404b540aSrobert int current_first_parm_offset;
53*404b540aSrobert 
54*404b540aSrobert /* Routines to encode/decode pdp11 floats */
55*404b540aSrobert static void encode_pdp11_f (const struct real_format *fmt,
56*404b540aSrobert 			    long *, const REAL_VALUE_TYPE *);
57*404b540aSrobert static void decode_pdp11_f (const struct real_format *,
58*404b540aSrobert 			    REAL_VALUE_TYPE *, const long *);
59*404b540aSrobert static void encode_pdp11_d (const struct real_format *fmt,
60*404b540aSrobert 			    long *, const REAL_VALUE_TYPE *);
61*404b540aSrobert static void decode_pdp11_d (const struct real_format *,
62*404b540aSrobert 			    REAL_VALUE_TYPE *, const long *);
63*404b540aSrobert 
64*404b540aSrobert /* These two are taken from the corresponding vax descriptors
65*404b540aSrobert    in real.c, changing only the encode/decode routine pointers.  */
66*404b540aSrobert const struct real_format pdp11_f_format =
67*404b540aSrobert   {
68*404b540aSrobert     encode_pdp11_f,
69*404b540aSrobert     decode_pdp11_f,
70*404b540aSrobert     2,
71*404b540aSrobert     1,
72*404b540aSrobert     24,
73*404b540aSrobert     24,
74*404b540aSrobert     -127,
75*404b540aSrobert     127,
76*404b540aSrobert     15,
77*404b540aSrobert     false,
78*404b540aSrobert     false,
79*404b540aSrobert     false,
80*404b540aSrobert     false,
81*404b540aSrobert     false
82*404b540aSrobert   };
83*404b540aSrobert 
84*404b540aSrobert const struct real_format pdp11_d_format =
85*404b540aSrobert   {
86*404b540aSrobert     encode_pdp11_d,
87*404b540aSrobert     decode_pdp11_d,
88*404b540aSrobert     2,
89*404b540aSrobert     1,
90*404b540aSrobert     56,
91*404b540aSrobert     56,
92*404b540aSrobert     -127,
93*404b540aSrobert     127,
94*404b540aSrobert     15,
95*404b540aSrobert     false,
96*404b540aSrobert     false,
97*404b540aSrobert     false,
98*404b540aSrobert     false,
99*404b540aSrobert     false
100*404b540aSrobert   };
101*404b540aSrobert 
102*404b540aSrobert static void
encode_pdp11_f(const struct real_format * fmt ATTRIBUTE_UNUSED,long * buf,const REAL_VALUE_TYPE * r)103*404b540aSrobert encode_pdp11_f (const struct real_format *fmt ATTRIBUTE_UNUSED, long *buf,
104*404b540aSrobert 		const REAL_VALUE_TYPE *r)
105*404b540aSrobert {
106*404b540aSrobert   (*vax_f_format.encode) (fmt, buf, r);
107*404b540aSrobert   buf[0] = ((buf[0] >> 16) & 0xffff) | ((buf[0] & 0xffff) << 16);
108*404b540aSrobert }
109*404b540aSrobert 
110*404b540aSrobert static void
decode_pdp11_f(const struct real_format * fmt ATTRIBUTE_UNUSED,REAL_VALUE_TYPE * r,const long * buf)111*404b540aSrobert decode_pdp11_f (const struct real_format *fmt ATTRIBUTE_UNUSED,
112*404b540aSrobert 		REAL_VALUE_TYPE *r, const long *buf)
113*404b540aSrobert {
114*404b540aSrobert   long tbuf;
115*404b540aSrobert   tbuf = ((buf[0] >> 16) & 0xffff) | ((buf[0] & 0xffff) << 16);
116*404b540aSrobert   (*vax_f_format.decode) (fmt, r, &tbuf);
117*404b540aSrobert }
118*404b540aSrobert 
119*404b540aSrobert static void
encode_pdp11_d(const struct real_format * fmt ATTRIBUTE_UNUSED,long * buf,const REAL_VALUE_TYPE * r)120*404b540aSrobert encode_pdp11_d (const struct real_format *fmt ATTRIBUTE_UNUSED, long *buf,
121*404b540aSrobert 		const REAL_VALUE_TYPE *r)
122*404b540aSrobert {
123*404b540aSrobert   (*vax_d_format.encode) (fmt, buf, r);
124*404b540aSrobert   buf[0] = ((buf[0] >> 16) & 0xffff) | ((buf[0] & 0xffff) << 16);
125*404b540aSrobert   buf[1] = ((buf[1] >> 16) & 0xffff) | ((buf[1] & 0xffff) << 16);
126*404b540aSrobert }
127*404b540aSrobert 
128*404b540aSrobert static void
decode_pdp11_d(const struct real_format * fmt ATTRIBUTE_UNUSED,REAL_VALUE_TYPE * r,const long * buf)129*404b540aSrobert decode_pdp11_d (const struct real_format *fmt ATTRIBUTE_UNUSED,
130*404b540aSrobert 		REAL_VALUE_TYPE *r, const long *buf)
131*404b540aSrobert {
132*404b540aSrobert   long tbuf[2];
133*404b540aSrobert   tbuf[0] = ((buf[0] >> 16) & 0xffff) | ((buf[0] & 0xffff) << 16);
134*404b540aSrobert   tbuf[1] = ((buf[1] >> 16) & 0xffff) | ((buf[1] & 0xffff) << 16);
135*404b540aSrobert   (*vax_d_format.decode) (fmt, r, tbuf);
136*404b540aSrobert }
137*404b540aSrobert 
138*404b540aSrobert /* This is where the condition code register lives.  */
139*404b540aSrobert /* rtx cc0_reg_rtx; - no longer needed? */
140*404b540aSrobert 
141*404b540aSrobert static bool pdp11_handle_option (size_t, const char *, int);
142*404b540aSrobert static rtx find_addr_reg (rtx);
143*404b540aSrobert static const char *singlemove_string (rtx *);
144*404b540aSrobert static bool pdp11_assemble_integer (rtx, unsigned int, int);
145*404b540aSrobert static void pdp11_output_function_prologue (FILE *, HOST_WIDE_INT);
146*404b540aSrobert static void pdp11_output_function_epilogue (FILE *, HOST_WIDE_INT);
147*404b540aSrobert static bool pdp11_rtx_costs (rtx, int, int, int *);
148*404b540aSrobert static bool pdp11_return_in_memory (tree, tree);
149*404b540aSrobert 
150*404b540aSrobert /* Initialize the GCC target structure.  */
151*404b540aSrobert #undef TARGET_ASM_BYTE_OP
152*404b540aSrobert #define TARGET_ASM_BYTE_OP NULL
153*404b540aSrobert #undef TARGET_ASM_ALIGNED_HI_OP
154*404b540aSrobert #define TARGET_ASM_ALIGNED_HI_OP NULL
155*404b540aSrobert #undef TARGET_ASM_ALIGNED_SI_OP
156*404b540aSrobert #define TARGET_ASM_ALIGNED_SI_OP NULL
157*404b540aSrobert #undef TARGET_ASM_INTEGER
158*404b540aSrobert #define TARGET_ASM_INTEGER pdp11_assemble_integer
159*404b540aSrobert 
160*404b540aSrobert #undef TARGET_ASM_FUNCTION_PROLOGUE
161*404b540aSrobert #define TARGET_ASM_FUNCTION_PROLOGUE pdp11_output_function_prologue
162*404b540aSrobert #undef TARGET_ASM_FUNCTION_EPILOGUE
163*404b540aSrobert #define TARGET_ASM_FUNCTION_EPILOGUE pdp11_output_function_epilogue
164*404b540aSrobert 
165*404b540aSrobert #undef TARGET_ASM_OPEN_PAREN
166*404b540aSrobert #define TARGET_ASM_OPEN_PAREN "["
167*404b540aSrobert #undef TARGET_ASM_CLOSE_PAREN
168*404b540aSrobert #define TARGET_ASM_CLOSE_PAREN "]"
169*404b540aSrobert 
170*404b540aSrobert #undef TARGET_DEFAULT_TARGET_FLAGS
171*404b540aSrobert #define TARGET_DEFAULT_TARGET_FLAGS \
172*404b540aSrobert   (MASK_FPU | MASK_45 | MASK_ABSHI_BUILTIN | TARGET_UNIX_ASM_DEFAULT)
173*404b540aSrobert #undef TARGET_HANDLE_OPTION
174*404b540aSrobert #define TARGET_HANDLE_OPTION pdp11_handle_option
175*404b540aSrobert 
176*404b540aSrobert #undef TARGET_RTX_COSTS
177*404b540aSrobert #define TARGET_RTX_COSTS pdp11_rtx_costs
178*404b540aSrobert 
179*404b540aSrobert #undef TARGET_RETURN_IN_MEMORY
180*404b540aSrobert #define TARGET_RETURN_IN_MEMORY pdp11_return_in_memory
181*404b540aSrobert 
182*404b540aSrobert struct gcc_target targetm = TARGET_INITIALIZER;
183*404b540aSrobert 
184*404b540aSrobert /* Implement TARGET_HANDLE_OPTION.  */
185*404b540aSrobert 
186*404b540aSrobert static bool
pdp11_handle_option(size_t code,const char * arg ATTRIBUTE_UNUSED,int value ATTRIBUTE_UNUSED)187*404b540aSrobert pdp11_handle_option (size_t code, const char *arg ATTRIBUTE_UNUSED,
188*404b540aSrobert 		     int value ATTRIBUTE_UNUSED)
189*404b540aSrobert {
190*404b540aSrobert   switch (code)
191*404b540aSrobert     {
192*404b540aSrobert     case OPT_m10:
193*404b540aSrobert       target_flags &= ~(MASK_40 | MASK_45);
194*404b540aSrobert       return true;
195*404b540aSrobert 
196*404b540aSrobert     default:
197*404b540aSrobert       return true;
198*404b540aSrobert     }
199*404b540aSrobert }
200*404b540aSrobert 
201*404b540aSrobert /* Nonzero if OP is a valid second operand for an arithmetic insn.  */
202*404b540aSrobert 
203*404b540aSrobert int
arith_operand(rtx op,enum machine_mode mode)204*404b540aSrobert arith_operand (rtx op, enum machine_mode mode)
205*404b540aSrobert {
206*404b540aSrobert   return (register_operand (op, mode) || GET_CODE (op) == CONST_INT);
207*404b540aSrobert }
208*404b540aSrobert 
209*404b540aSrobert int
const_immediate_operand(rtx op,enum machine_mode mode ATTRIBUTE_UNUSED)210*404b540aSrobert const_immediate_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
211*404b540aSrobert {
212*404b540aSrobert   return (GET_CODE (op) == CONST_INT);
213*404b540aSrobert }
214*404b540aSrobert 
215*404b540aSrobert int
immediate15_operand(rtx op,enum machine_mode mode ATTRIBUTE_UNUSED)216*404b540aSrobert immediate15_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
217*404b540aSrobert {
218*404b540aSrobert     return (GET_CODE (op) == CONST_INT && ((INTVAL (op) & 0x8000) == 0x0000));
219*404b540aSrobert }
220*404b540aSrobert 
221*404b540aSrobert int
expand_shift_operand(rtx op,enum machine_mode mode ATTRIBUTE_UNUSED)222*404b540aSrobert expand_shift_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
223*404b540aSrobert {
224*404b540aSrobert     return (GET_CODE (op) == CONST_INT
225*404b540aSrobert 	    && abs (INTVAL(op)) > 1
226*404b540aSrobert 	    && abs (INTVAL(op)) <= 4);
227*404b540aSrobert }
228*404b540aSrobert 
229*404b540aSrobert /*
230*404b540aSrobert    stream is a stdio stream to output the code to.
231*404b540aSrobert    size is an int: how many units of temporary storage to allocate.
232*404b540aSrobert    Refer to the array `regs_ever_live' to determine which registers
233*404b540aSrobert    to save; `regs_ever_live[I]' is nonzero if register number I
234*404b540aSrobert    is ever used in the function.  This macro is responsible for
235*404b540aSrobert    knowing which registers should not be saved even if used.
236*404b540aSrobert */
237*404b540aSrobert 
238*404b540aSrobert #ifdef TWO_BSD
239*404b540aSrobert 
240*404b540aSrobert static void
pdp11_output_function_prologue(FILE * stream,HOST_WIDE_INT size)241*404b540aSrobert pdp11_output_function_prologue (FILE *stream, HOST_WIDE_INT size)
242*404b540aSrobert {
243*404b540aSrobert   fprintf (stream, "\tjsr	r5, csv\n");
244*404b540aSrobert   if (size)
245*404b540aSrobert     {
246*404b540aSrobert       fprintf (stream, "\t/*abuse empty parameter slot for locals!*/\n");
247*404b540aSrobert       if (size > 2)
248*404b540aSrobert 	asm_fprintf (stream, "\tsub $%#wo, sp\n", size - 2);
249*404b540aSrobert 
250*404b540aSrobert     }
251*404b540aSrobert }
252*404b540aSrobert 
253*404b540aSrobert #else  /* !TWO_BSD */
254*404b540aSrobert 
255*404b540aSrobert static void
pdp11_output_function_prologue(FILE * stream,HOST_WIDE_INT size)256*404b540aSrobert pdp11_output_function_prologue (FILE *stream, HOST_WIDE_INT size)
257*404b540aSrobert {
258*404b540aSrobert     HOST_WIDE_INT fsize = ((size) + 1) & ~1;
259*404b540aSrobert     int regno;
260*404b540aSrobert     int via_ac = -1;
261*404b540aSrobert 
262*404b540aSrobert     fprintf (stream,
263*404b540aSrobert 	     "\n\t;	/* function prologue %s*/\n",
264*404b540aSrobert 	     current_function_name ());
265*404b540aSrobert 
266*404b540aSrobert     /* if we are outputting code for main,
267*404b540aSrobert        the switch FPU to right mode if TARGET_FPU */
268*404b540aSrobert     if (MAIN_NAME_P (DECL_NAME (current_function_decl)) && TARGET_FPU)
269*404b540aSrobert     {
270*404b540aSrobert 	fprintf(stream,
271*404b540aSrobert 		"\t;/* switch cpu to double float, single integer */\n");
272*404b540aSrobert 	fprintf(stream, "\tsetd\n");
273*404b540aSrobert 	fprintf(stream, "\tseti\n\n");
274*404b540aSrobert     }
275*404b540aSrobert 
276*404b540aSrobert     if (frame_pointer_needed)
277*404b540aSrobert     {
278*404b540aSrobert 	fprintf(stream, "\tmov r5, -(sp)\n");
279*404b540aSrobert 	fprintf(stream, "\tmov sp, r5\n");
280*404b540aSrobert     }
281*404b540aSrobert     else
282*404b540aSrobert     {
283*404b540aSrobert 	/* DON'T SAVE FP */
284*404b540aSrobert     }
285*404b540aSrobert 
286*404b540aSrobert     /* make frame */
287*404b540aSrobert     if (fsize)
288*404b540aSrobert 	asm_fprintf (stream, "\tsub $%#wo, sp\n", fsize);
289*404b540aSrobert 
290*404b540aSrobert     /* save CPU registers  */
291*404b540aSrobert     for (regno = 0; regno < 8; regno++)
292*404b540aSrobert 	if (regs_ever_live[regno] && ! call_used_regs[regno])
293*404b540aSrobert 	    if (! ((regno == FRAME_POINTER_REGNUM)
294*404b540aSrobert 		   && frame_pointer_needed))
295*404b540aSrobert 		fprintf (stream, "\tmov %s, -(sp)\n", reg_names[regno]);
296*404b540aSrobert     /* fpu regs saving */
297*404b540aSrobert 
298*404b540aSrobert     /* via_ac specifies the ac to use for saving ac4, ac5 */
299*404b540aSrobert     via_ac = -1;
300*404b540aSrobert 
301*404b540aSrobert     for (regno = 8; regno < FIRST_PSEUDO_REGISTER ; regno++)
302*404b540aSrobert     {
303*404b540aSrobert 	/* ac0 - ac3 */
304*404b540aSrobert 	if (LOAD_FPU_REG_P(regno)
305*404b540aSrobert 	    && regs_ever_live[regno]
306*404b540aSrobert 	    && ! call_used_regs[regno])
307*404b540aSrobert 	{
308*404b540aSrobert 	    fprintf (stream, "\tstd %s, -(sp)\n", reg_names[regno]);
309*404b540aSrobert 	    via_ac = regno;
310*404b540aSrobert 	}
311*404b540aSrobert 
312*404b540aSrobert 	/* maybe make ac4, ac5 call used regs?? */
313*404b540aSrobert 	/* ac4 - ac5 */
314*404b540aSrobert 	if (NO_LOAD_FPU_REG_P(regno)
315*404b540aSrobert 	    && regs_ever_live[regno]
316*404b540aSrobert 	    && ! call_used_regs[regno])
317*404b540aSrobert 	{
318*404b540aSrobert 	  gcc_assert (via_ac != -1);
319*404b540aSrobert 	  fprintf (stream, "\tldd %s, %s\n",
320*404b540aSrobert 		   reg_names[regno], reg_names[via_ac]);
321*404b540aSrobert 	  fprintf (stream, "\tstd %s, -(sp)\n", reg_names[via_ac]);
322*404b540aSrobert 	}
323*404b540aSrobert     }
324*404b540aSrobert 
325*404b540aSrobert     fprintf (stream, "\t;/* end of prologue */\n\n");
326*404b540aSrobert }
327*404b540aSrobert 
328*404b540aSrobert #endif /* !TWO_BSD */
329*404b540aSrobert 
330*404b540aSrobert /*
331*404b540aSrobert    The function epilogue should not depend on the current stack pointer!
332*404b540aSrobert    It should use the frame pointer only.  This is mandatory because
333*404b540aSrobert    of alloca; we also take advantage of it to omit stack adjustments
334*404b540aSrobert    before returning.  */
335*404b540aSrobert 
336*404b540aSrobert /* maybe we can make leaf functions faster by switching to the
337*404b540aSrobert    second register file - this way we don't have to save regs!
338*404b540aSrobert    leaf functions are ~ 50% of all functions (dynamically!)
339*404b540aSrobert 
340*404b540aSrobert    set/clear bit 11 (dec. 2048) of status word for switching register files -
341*404b540aSrobert    but how can we do this? the pdp11/45 manual says bit may only
342*404b540aSrobert    be set (p.24), but not cleared!
343*404b540aSrobert 
344*404b540aSrobert    switching to kernel is probably more expensive, so we'll leave it
345*404b540aSrobert    like this and not use the second set of registers...
346*404b540aSrobert 
347*404b540aSrobert    maybe as option if you want to generate code for kernel mode? */
348*404b540aSrobert 
349*404b540aSrobert #ifdef TWO_BSD
350*404b540aSrobert 
351*404b540aSrobert static void
pdp11_output_function_epilogue(FILE * stream,HOST_WIDE_INT size ATTRIBUTE_UNUSED)352*404b540aSrobert pdp11_output_function_epilogue (FILE *stream,
353*404b540aSrobert 				HOST_WIDE_INT size ATTRIBUTE_UNUSED)
354*404b540aSrobert {
355*404b540aSrobert   fprintf (stream, "\t/* SP ignored by cret? */\n");
356*404b540aSrobert   fprintf (stream, "\tjmp cret\n");
357*404b540aSrobert }
358*404b540aSrobert 
359*404b540aSrobert #else  /* !TWO_BSD */
360*404b540aSrobert 
361*404b540aSrobert static void
pdp11_output_function_epilogue(FILE * stream,HOST_WIDE_INT size)362*404b540aSrobert pdp11_output_function_epilogue (FILE *stream, HOST_WIDE_INT size)
363*404b540aSrobert {
364*404b540aSrobert     HOST_WIDE_INT fsize = ((size) + 1) & ~1;
365*404b540aSrobert     int i, j, k;
366*404b540aSrobert 
367*404b540aSrobert     int via_ac;
368*404b540aSrobert 
369*404b540aSrobert     fprintf (stream, "\n\t;	/*function epilogue */\n");
370*404b540aSrobert 
371*404b540aSrobert     if (frame_pointer_needed)
372*404b540aSrobert     {
373*404b540aSrobert 	/* hope this is safe - m68k does it also .... */
374*404b540aSrobert 	regs_ever_live[FRAME_POINTER_REGNUM] = 0;
375*404b540aSrobert 
376*404b540aSrobert 	for (i =7, j = 0 ; i >= 0 ; i--)
377*404b540aSrobert 	    if (regs_ever_live[i] && ! call_used_regs[i])
378*404b540aSrobert 		j++;
379*404b540aSrobert 
380*404b540aSrobert 	/* remember # of pushed bytes for CPU regs */
381*404b540aSrobert 	k = 2*j;
382*404b540aSrobert 
383*404b540aSrobert 	/* change fp -> r5 due to the compile error on libgcc2.c */
384*404b540aSrobert 	for (i =7 ; i >= 0 ; i--)
385*404b540aSrobert 	    if (regs_ever_live[i] && ! call_used_regs[i])
386*404b540aSrobert 		fprintf(stream, "\tmov %#o(r5), %s\n",(-fsize-2*j--)&0xffff, reg_names[i]);
387*404b540aSrobert 
388*404b540aSrobert 	/* get ACs */
389*404b540aSrobert 	via_ac = FIRST_PSEUDO_REGISTER -1;
390*404b540aSrobert 
391*404b540aSrobert 	for (i = FIRST_PSEUDO_REGISTER; i > 7; i--)
392*404b540aSrobert 	    if (regs_ever_live[i] && ! call_used_regs[i])
393*404b540aSrobert 	    {
394*404b540aSrobert 		via_ac = i;
395*404b540aSrobert 		k += 8;
396*404b540aSrobert 	    }
397*404b540aSrobert 
398*404b540aSrobert 	for (i = FIRST_PSEUDO_REGISTER; i > 7; i--)
399*404b540aSrobert 	{
400*404b540aSrobert 	    if (LOAD_FPU_REG_P(i)
401*404b540aSrobert 		&& regs_ever_live[i]
402*404b540aSrobert 		&& ! call_used_regs[i])
403*404b540aSrobert 	    {
404*404b540aSrobert 		fprintf(stream, "\tldd %#o(r5), %s\n", (-fsize-k)&0xffff, reg_names[i]);
405*404b540aSrobert 		k -= 8;
406*404b540aSrobert 	    }
407*404b540aSrobert 
408*404b540aSrobert 	    if (NO_LOAD_FPU_REG_P(i)
409*404b540aSrobert 		&& regs_ever_live[i]
410*404b540aSrobert 		&& ! call_used_regs[i])
411*404b540aSrobert 	    {
412*404b540aSrobert 	        gcc_assert (LOAD_FPU_REG_P(via_ac));
413*404b540aSrobert 
414*404b540aSrobert 		fprintf(stream, "\tldd %#o(r5), %s\n", (-fsize-k)&0xffff, reg_names[via_ac]);
415*404b540aSrobert 		fprintf(stream, "\tstd %s, %s\n", reg_names[via_ac], reg_names[i]);
416*404b540aSrobert 		k -= 8;
417*404b540aSrobert 	    }
418*404b540aSrobert 	}
419*404b540aSrobert 
420*404b540aSrobert 	fprintf(stream, "\tmov r5, sp\n");
421*404b540aSrobert 	fprintf (stream, "\tmov (sp)+, r5\n");
422*404b540aSrobert     }
423*404b540aSrobert     else
424*404b540aSrobert     {
425*404b540aSrobert 	via_ac = FIRST_PSEUDO_REGISTER -1;
426*404b540aSrobert 
427*404b540aSrobert 	/* get ACs */
428*404b540aSrobert 	for (i = FIRST_PSEUDO_REGISTER; i > 7; i--)
429*404b540aSrobert 	    if (regs_ever_live[i] && call_used_regs[i])
430*404b540aSrobert 		via_ac = i;
431*404b540aSrobert 
432*404b540aSrobert 	for (i = FIRST_PSEUDO_REGISTER; i > 7; i--)
433*404b540aSrobert 	{
434*404b540aSrobert 	    if (LOAD_FPU_REG_P(i)
435*404b540aSrobert 		&& regs_ever_live[i]
436*404b540aSrobert 		&& ! call_used_regs[i])
437*404b540aSrobert 	      fprintf(stream, "\tldd (sp)+, %s\n", reg_names[i]);
438*404b540aSrobert 
439*404b540aSrobert 	    if (NO_LOAD_FPU_REG_P(i)
440*404b540aSrobert 		&& regs_ever_live[i]
441*404b540aSrobert 		&& ! call_used_regs[i])
442*404b540aSrobert 	    {
443*404b540aSrobert 	        gcc_assert (LOAD_FPU_REG_P(via_ac));
444*404b540aSrobert 
445*404b540aSrobert 		fprintf(stream, "\tldd (sp)+, %s\n", reg_names[via_ac]);
446*404b540aSrobert 		fprintf(stream, "\tstd %s, %s\n", reg_names[via_ac], reg_names[i]);
447*404b540aSrobert 	    }
448*404b540aSrobert 	}
449*404b540aSrobert 
450*404b540aSrobert 	for (i=7; i >= 0; i--)
451*404b540aSrobert 	    if (regs_ever_live[i] && !call_used_regs[i])
452*404b540aSrobert 		fprintf(stream, "\tmov (sp)+, %s\n", reg_names[i]);
453*404b540aSrobert 
454*404b540aSrobert 	if (fsize)
455*404b540aSrobert 	    fprintf((stream), "\tadd $%#o, sp\n", (fsize)&0xffff);
456*404b540aSrobert     }
457*404b540aSrobert 
458*404b540aSrobert     fprintf (stream, "\trts pc\n");
459*404b540aSrobert     fprintf (stream, "\t;/* end of epilogue*/\n\n\n");
460*404b540aSrobert }
461*404b540aSrobert 
462*404b540aSrobert #endif /* !TWO_BSD */
463*404b540aSrobert 
464*404b540aSrobert /* Return the best assembler insn template
465*404b540aSrobert    for moving operands[1] into operands[0] as a fullword.  */
466*404b540aSrobert static const char *
singlemove_string(rtx * operands)467*404b540aSrobert singlemove_string (rtx *operands)
468*404b540aSrobert {
469*404b540aSrobert   if (operands[1] != const0_rtx)
470*404b540aSrobert     return "mov %1,%0";
471*404b540aSrobert 
472*404b540aSrobert   return "clr %0";
473*404b540aSrobert }
474*404b540aSrobert 
475*404b540aSrobert 
476*404b540aSrobert /* Output assembler code to perform a doubleword move insn
477*404b540aSrobert    with operands OPERANDS.  */
478*404b540aSrobert 
479*404b540aSrobert const char *
output_move_double(rtx * operands)480*404b540aSrobert output_move_double (rtx *operands)
481*404b540aSrobert {
482*404b540aSrobert   enum { REGOP, OFFSOP, MEMOP, PUSHOP, POPOP, CNSTOP, RNDOP } optype0, optype1;
483*404b540aSrobert   rtx latehalf[2];
484*404b540aSrobert   rtx addreg0 = 0, addreg1 = 0;
485*404b540aSrobert 
486*404b540aSrobert   /* First classify both operands.  */
487*404b540aSrobert 
488*404b540aSrobert   if (REG_P (operands[0]))
489*404b540aSrobert     optype0 = REGOP;
490*404b540aSrobert   else if (offsettable_memref_p (operands[0]))
491*404b540aSrobert     optype0 = OFFSOP;
492*404b540aSrobert   else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
493*404b540aSrobert     optype0 = POPOP;
494*404b540aSrobert   else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
495*404b540aSrobert     optype0 = PUSHOP;
496*404b540aSrobert   else if (GET_CODE (operands[0]) == MEM)
497*404b540aSrobert     optype0 = MEMOP;
498*404b540aSrobert   else
499*404b540aSrobert     optype0 = RNDOP;
500*404b540aSrobert 
501*404b540aSrobert   if (REG_P (operands[1]))
502*404b540aSrobert     optype1 = REGOP;
503*404b540aSrobert   else if (CONSTANT_P (operands[1])
504*404b540aSrobert #if 0
505*404b540aSrobert 	   || GET_CODE (operands[1]) == CONST_DOUBLE
506*404b540aSrobert #endif
507*404b540aSrobert 	   )
508*404b540aSrobert     optype1 = CNSTOP;
509*404b540aSrobert   else if (offsettable_memref_p (operands[1]))
510*404b540aSrobert     optype1 = OFFSOP;
511*404b540aSrobert   else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC)
512*404b540aSrobert     optype1 = POPOP;
513*404b540aSrobert   else if (GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
514*404b540aSrobert     optype1 = PUSHOP;
515*404b540aSrobert   else if (GET_CODE (operands[1]) == MEM)
516*404b540aSrobert     optype1 = MEMOP;
517*404b540aSrobert   else
518*404b540aSrobert     optype1 = RNDOP;
519*404b540aSrobert 
520*404b540aSrobert   /* Check for the cases that the operand constraints are not
521*404b540aSrobert      supposed to allow to happen.  Abort if we get one,
522*404b540aSrobert      because generating code for these cases is painful.  */
523*404b540aSrobert 
524*404b540aSrobert   gcc_assert (optype0 != RNDOP && optype1 != RNDOP);
525*404b540aSrobert 
526*404b540aSrobert   /* If one operand is decrementing and one is incrementing
527*404b540aSrobert      decrement the former register explicitly
528*404b540aSrobert      and change that operand into ordinary indexing.  */
529*404b540aSrobert 
530*404b540aSrobert   if (optype0 == PUSHOP && optype1 == POPOP)
531*404b540aSrobert     {
532*404b540aSrobert       operands[0] = XEXP (XEXP (operands[0], 0), 0);
533*404b540aSrobert       output_asm_insn ("sub $4,%0", operands);
534*404b540aSrobert       operands[0] = gen_rtx_MEM (SImode, operands[0]);
535*404b540aSrobert       optype0 = OFFSOP;
536*404b540aSrobert     }
537*404b540aSrobert   if (optype0 == POPOP && optype1 == PUSHOP)
538*404b540aSrobert     {
539*404b540aSrobert       operands[1] = XEXP (XEXP (operands[1], 0), 0);
540*404b540aSrobert       output_asm_insn ("sub $4,%1", operands);
541*404b540aSrobert       operands[1] = gen_rtx_MEM (SImode, operands[1]);
542*404b540aSrobert       optype1 = OFFSOP;
543*404b540aSrobert     }
544*404b540aSrobert 
545*404b540aSrobert   /* If an operand is an unoffsettable memory ref, find a register
546*404b540aSrobert      we can increment temporarily to make it refer to the second word.  */
547*404b540aSrobert 
548*404b540aSrobert   if (optype0 == MEMOP)
549*404b540aSrobert     addreg0 = find_addr_reg (XEXP (operands[0], 0));
550*404b540aSrobert 
551*404b540aSrobert   if (optype1 == MEMOP)
552*404b540aSrobert     addreg1 = find_addr_reg (XEXP (operands[1], 0));
553*404b540aSrobert 
554*404b540aSrobert   /* Ok, we can do one word at a time.
555*404b540aSrobert      Normally we do the low-numbered word first,
556*404b540aSrobert      but if either operand is autodecrementing then we
557*404b540aSrobert      do the high-numbered word first.
558*404b540aSrobert 
559*404b540aSrobert      In either case, set up in LATEHALF the operands to use
560*404b540aSrobert      for the high-numbered word and in some cases alter the
561*404b540aSrobert      operands in OPERANDS to be suitable for the low-numbered word.  */
562*404b540aSrobert 
563*404b540aSrobert   if (optype0 == REGOP)
564*404b540aSrobert     latehalf[0] = gen_rtx_REG (HImode, REGNO (operands[0]) + 1);
565*404b540aSrobert   else if (optype0 == OFFSOP)
566*404b540aSrobert     latehalf[0] = adjust_address (operands[0], HImode, 2);
567*404b540aSrobert   else
568*404b540aSrobert     latehalf[0] = operands[0];
569*404b540aSrobert 
570*404b540aSrobert   if (optype1 == REGOP)
571*404b540aSrobert     latehalf[1] = gen_rtx_REG (HImode, REGNO (operands[1]) + 1);
572*404b540aSrobert   else if (optype1 == OFFSOP)
573*404b540aSrobert     latehalf[1] = adjust_address (operands[1], HImode, 2);
574*404b540aSrobert   else if (optype1 == CNSTOP)
575*404b540aSrobert     {
576*404b540aSrobert 	if (CONSTANT_P (operands[1]))
577*404b540aSrobert 	{
578*404b540aSrobert 	    /* now the mess begins, high word is in lower word???
579*404b540aSrobert 
580*404b540aSrobert 	       that's what ashc makes me think, but I don't remember :-( */
581*404b540aSrobert 	    latehalf[1] = GEN_INT (INTVAL(operands[1]) >> 16);
582*404b540aSrobert 	    operands[1] = GEN_INT (INTVAL(operands[1]) & 0xff);
583*404b540aSrobert 	}
584*404b540aSrobert 	else
585*404b540aSrobert 	  /* immediate 32 bit values not allowed */
586*404b540aSrobert 	  gcc_assert (GET_CODE (operands[1]) != CONST_DOUBLE);
587*404b540aSrobert     }
588*404b540aSrobert   else
589*404b540aSrobert     latehalf[1] = operands[1];
590*404b540aSrobert 
591*404b540aSrobert   /* If insn is effectively movd N(sp),-(sp) then we will do the
592*404b540aSrobert      high word first.  We should use the adjusted operand 1 (which is N+4(sp))
593*404b540aSrobert      for the low word as well, to compensate for the first decrement of sp.  */
594*404b540aSrobert   if (optype0 == PUSHOP
595*404b540aSrobert       && REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM
596*404b540aSrobert       && reg_overlap_mentioned_p (stack_pointer_rtx, operands[1]))
597*404b540aSrobert     operands[1] = latehalf[1];
598*404b540aSrobert 
599*404b540aSrobert   /* If one or both operands autodecrementing,
600*404b540aSrobert      do the two words, high-numbered first.  */
601*404b540aSrobert 
602*404b540aSrobert   /* Likewise,  the first move would clobber the source of the second one,
603*404b540aSrobert      do them in the other order.  This happens only for registers;
604*404b540aSrobert      such overlap can't happen in memory unless the user explicitly
605*404b540aSrobert      sets it up, and that is an undefined circumstance.  */
606*404b540aSrobert 
607*404b540aSrobert   if (optype0 == PUSHOP || optype1 == PUSHOP
608*404b540aSrobert       || (optype0 == REGOP && optype1 == REGOP
609*404b540aSrobert 	  && REGNO (operands[0]) == REGNO (latehalf[1])))
610*404b540aSrobert     {
611*404b540aSrobert       /* Make any unoffsettable addresses point at high-numbered word.  */
612*404b540aSrobert       if (addreg0)
613*404b540aSrobert 	output_asm_insn ("add $2,%0", &addreg0);
614*404b540aSrobert       if (addreg1)
615*404b540aSrobert 	output_asm_insn ("add $2,%0", &addreg1);
616*404b540aSrobert 
617*404b540aSrobert       /* Do that word.  */
618*404b540aSrobert       output_asm_insn (singlemove_string (latehalf), latehalf);
619*404b540aSrobert 
620*404b540aSrobert       /* Undo the adds we just did.  */
621*404b540aSrobert       if (addreg0)
622*404b540aSrobert 	output_asm_insn ("sub $2,%0", &addreg0);
623*404b540aSrobert       if (addreg1)
624*404b540aSrobert 	output_asm_insn ("sub $2,%0", &addreg1);
625*404b540aSrobert 
626*404b540aSrobert       /* Do low-numbered word.  */
627*404b540aSrobert       return singlemove_string (operands);
628*404b540aSrobert     }
629*404b540aSrobert 
630*404b540aSrobert   /* Normal case: do the two words, low-numbered first.  */
631*404b540aSrobert 
632*404b540aSrobert   output_asm_insn (singlemove_string (operands), operands);
633*404b540aSrobert 
634*404b540aSrobert   /* Make any unoffsettable addresses point at high-numbered word.  */
635*404b540aSrobert   if (addreg0)
636*404b540aSrobert     output_asm_insn ("add $2,%0", &addreg0);
637*404b540aSrobert   if (addreg1)
638*404b540aSrobert     output_asm_insn ("add $2,%0", &addreg1);
639*404b540aSrobert 
640*404b540aSrobert   /* Do that word.  */
641*404b540aSrobert   output_asm_insn (singlemove_string (latehalf), latehalf);
642*404b540aSrobert 
643*404b540aSrobert   /* Undo the adds we just did.  */
644*404b540aSrobert   if (addreg0)
645*404b540aSrobert     output_asm_insn ("sub $2,%0", &addreg0);
646*404b540aSrobert   if (addreg1)
647*404b540aSrobert     output_asm_insn ("sub $2,%0", &addreg1);
648*404b540aSrobert 
649*404b540aSrobert   return "";
650*404b540aSrobert }
651*404b540aSrobert /* Output assembler code to perform a quadword move insn
652*404b540aSrobert    with operands OPERANDS.  */
653*404b540aSrobert 
654*404b540aSrobert const char *
output_move_quad(rtx * operands)655*404b540aSrobert output_move_quad (rtx *operands)
656*404b540aSrobert {
657*404b540aSrobert   enum { REGOP, OFFSOP, MEMOP, PUSHOP, POPOP, CNSTOP, RNDOP } optype0, optype1;
658*404b540aSrobert   rtx latehalf[2];
659*404b540aSrobert   rtx addreg0 = 0, addreg1 = 0;
660*404b540aSrobert 
661*404b540aSrobert   output_asm_insn(";/* movdi/df: %1 -> %0 */", operands);
662*404b540aSrobert 
663*404b540aSrobert   if (REG_P (operands[0]))
664*404b540aSrobert     optype0 = REGOP;
665*404b540aSrobert   else if (offsettable_memref_p (operands[0]))
666*404b540aSrobert     optype0 = OFFSOP;
667*404b540aSrobert   else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
668*404b540aSrobert     optype0 = POPOP;
669*404b540aSrobert   else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
670*404b540aSrobert     optype0 = PUSHOP;
671*404b540aSrobert   else if (GET_CODE (operands[0]) == MEM)
672*404b540aSrobert     optype0 = MEMOP;
673*404b540aSrobert   else
674*404b540aSrobert     optype0 = RNDOP;
675*404b540aSrobert 
676*404b540aSrobert   if (REG_P (operands[1]))
677*404b540aSrobert     optype1 = REGOP;
678*404b540aSrobert   else if (CONSTANT_P (operands[1])
679*404b540aSrobert 	   || GET_CODE (operands[1]) == CONST_DOUBLE)
680*404b540aSrobert     optype1 = CNSTOP;
681*404b540aSrobert   else if (offsettable_memref_p (operands[1]))
682*404b540aSrobert     optype1 = OFFSOP;
683*404b540aSrobert   else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC)
684*404b540aSrobert     optype1 = POPOP;
685*404b540aSrobert   else if (GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
686*404b540aSrobert     optype1 = PUSHOP;
687*404b540aSrobert   else if (GET_CODE (operands[1]) == MEM)
688*404b540aSrobert     optype1 = MEMOP;
689*404b540aSrobert   else
690*404b540aSrobert     optype1 = RNDOP;
691*404b540aSrobert 
692*404b540aSrobert   /* Check for the cases that the operand constraints are not
693*404b540aSrobert      supposed to allow to happen.  Abort if we get one,
694*404b540aSrobert      because generating code for these cases is painful.  */
695*404b540aSrobert 
696*404b540aSrobert   gcc_assert (optype0 != RNDOP && optype1 != RNDOP);
697*404b540aSrobert 
698*404b540aSrobert   /* check if we move a CPU reg to an FPU reg, or vice versa! */
699*404b540aSrobert   if (optype0 == REGOP && optype1 == REGOP)
700*404b540aSrobert       /* bogus - 64 bit cannot reside in CPU! */
701*404b540aSrobert       gcc_assert (!CPU_REG_P(REGNO(operands[0]))
702*404b540aSrobert 		  && !CPU_REG_P (REGNO(operands[1])));
703*404b540aSrobert 
704*404b540aSrobert   if (optype0 == REGOP || optype1 == REGOP)
705*404b540aSrobert   {
706*404b540aSrobert       /* check for use of clrd????
707*404b540aSrobert          if you ever allow ac4 and ac5 (now we require secondary load)
708*404b540aSrobert 	 you must check whether
709*404b540aSrobert 	 you want to load into them or store from them -
710*404b540aSrobert 	 then dump ac0 into $help$ movce ac4/5 to ac0, do the
711*404b540aSrobert 	 store from ac0, and restore ac0 - if you can find
712*404b540aSrobert 	 an unused ac[0-3], use that and you save a store and a load!*/
713*404b540aSrobert 
714*404b540aSrobert       if (FPU_REG_P(REGNO(operands[0])))
715*404b540aSrobert       {
716*404b540aSrobert 	  if (GET_CODE(operands[1]) == CONST_DOUBLE)
717*404b540aSrobert 	  {
718*404b540aSrobert 	      REAL_VALUE_TYPE r;
719*404b540aSrobert 	      REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
720*404b540aSrobert 
721*404b540aSrobert 	      if (REAL_VALUES_EQUAL (r, dconst0))
722*404b540aSrobert 		  return "{clrd|clrf} %0";
723*404b540aSrobert 	  }
724*404b540aSrobert 
725*404b540aSrobert 	  return "{ldd|movf} %1, %0";
726*404b540aSrobert       }
727*404b540aSrobert 
728*404b540aSrobert       if (FPU_REG_P(REGNO(operands[1])))
729*404b540aSrobert 	  return "{std|movf} %1, %0";
730*404b540aSrobert   }
731*404b540aSrobert 
732*404b540aSrobert   /* If one operand is decrementing and one is incrementing
733*404b540aSrobert      decrement the former register explicitly
734*404b540aSrobert      and change that operand into ordinary indexing.  */
735*404b540aSrobert 
736*404b540aSrobert   if (optype0 == PUSHOP && optype1 == POPOP)
737*404b540aSrobert     {
738*404b540aSrobert       operands[0] = XEXP (XEXP (operands[0], 0), 0);
739*404b540aSrobert       output_asm_insn ("sub $8,%0", operands);
740*404b540aSrobert       operands[0] = gen_rtx_MEM (DImode, operands[0]);
741*404b540aSrobert       optype0 = OFFSOP;
742*404b540aSrobert     }
743*404b540aSrobert   if (optype0 == POPOP && optype1 == PUSHOP)
744*404b540aSrobert     {
745*404b540aSrobert       operands[1] = XEXP (XEXP (operands[1], 0), 0);
746*404b540aSrobert       output_asm_insn ("sub $8,%1", operands);
747*404b540aSrobert       operands[1] = gen_rtx_MEM (SImode, operands[1]);
748*404b540aSrobert       optype1 = OFFSOP;
749*404b540aSrobert     }
750*404b540aSrobert 
751*404b540aSrobert   /* If an operand is an unoffsettable memory ref, find a register
752*404b540aSrobert      we can increment temporarily to make it refer to the second word.  */
753*404b540aSrobert 
754*404b540aSrobert   if (optype0 == MEMOP)
755*404b540aSrobert     addreg0 = find_addr_reg (XEXP (operands[0], 0));
756*404b540aSrobert 
757*404b540aSrobert   if (optype1 == MEMOP)
758*404b540aSrobert     addreg1 = find_addr_reg (XEXP (operands[1], 0));
759*404b540aSrobert 
760*404b540aSrobert   /* Ok, we can do one word at a time.
761*404b540aSrobert      Normally we do the low-numbered word first,
762*404b540aSrobert      but if either operand is autodecrementing then we
763*404b540aSrobert      do the high-numbered word first.
764*404b540aSrobert 
765*404b540aSrobert      In either case, set up in LATEHALF the operands to use
766*404b540aSrobert      for the high-numbered word and in some cases alter the
767*404b540aSrobert      operands in OPERANDS to be suitable for the low-numbered word.  */
768*404b540aSrobert 
769*404b540aSrobert   if (optype0 == REGOP)
770*404b540aSrobert     latehalf[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 2);
771*404b540aSrobert   else if (optype0 == OFFSOP)
772*404b540aSrobert     latehalf[0] = adjust_address (operands[0], SImode, 4);
773*404b540aSrobert   else
774*404b540aSrobert     latehalf[0] = operands[0];
775*404b540aSrobert 
776*404b540aSrobert   if (optype1 == REGOP)
777*404b540aSrobert     latehalf[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
778*404b540aSrobert   else if (optype1 == OFFSOP)
779*404b540aSrobert     latehalf[1] = adjust_address (operands[1], SImode, 4);
780*404b540aSrobert   else if (optype1 == CNSTOP)
781*404b540aSrobert     {
782*404b540aSrobert       if (GET_CODE (operands[1]) == CONST_DOUBLE)
783*404b540aSrobert 	{
784*404b540aSrobert 	  REAL_VALUE_TYPE r;
785*404b540aSrobert 	  long dval[2];
786*404b540aSrobert 	  REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
787*404b540aSrobert 	  REAL_VALUE_TO_TARGET_DOUBLE (r, dval);
788*404b540aSrobert 	  latehalf[1] = GEN_INT (dval[1]);
789*404b540aSrobert 	  operands[1] = GEN_INT	(dval[0]);
790*404b540aSrobert 	}
791*404b540aSrobert       else if (GET_CODE(operands[1]) == CONST_INT)
792*404b540aSrobert 	{
793*404b540aSrobert 	  latehalf[1] = const0_rtx;
794*404b540aSrobert 	}
795*404b540aSrobert       else
796*404b540aSrobert 	gcc_unreachable ();
797*404b540aSrobert     }
798*404b540aSrobert   else
799*404b540aSrobert     latehalf[1] = operands[1];
800*404b540aSrobert 
801*404b540aSrobert   /* If insn is effectively movd N(sp),-(sp) then we will do the
802*404b540aSrobert      high word first.  We should use the adjusted operand 1 (which is N+4(sp))
803*404b540aSrobert      for the low word as well, to compensate for the first decrement of sp.  */
804*404b540aSrobert   if (optype0 == PUSHOP
805*404b540aSrobert       && REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM
806*404b540aSrobert       && reg_overlap_mentioned_p (stack_pointer_rtx, operands[1]))
807*404b540aSrobert     operands[1] = latehalf[1];
808*404b540aSrobert 
809*404b540aSrobert   /* If one or both operands autodecrementing,
810*404b540aSrobert      do the two words, high-numbered first.  */
811*404b540aSrobert 
812*404b540aSrobert   /* Likewise,  the first move would clobber the source of the second one,
813*404b540aSrobert      do them in the other order.  This happens only for registers;
814*404b540aSrobert      such overlap can't happen in memory unless the user explicitly
815*404b540aSrobert      sets it up, and that is an undefined circumstance.  */
816*404b540aSrobert 
817*404b540aSrobert   if (optype0 == PUSHOP || optype1 == PUSHOP
818*404b540aSrobert       || (optype0 == REGOP && optype1 == REGOP
819*404b540aSrobert 	  && REGNO (operands[0]) == REGNO (latehalf[1])))
820*404b540aSrobert     {
821*404b540aSrobert       /* Make any unoffsettable addresses point at high-numbered word.  */
822*404b540aSrobert       if (addreg0)
823*404b540aSrobert 	output_asm_insn ("add $4,%0", &addreg0);
824*404b540aSrobert       if (addreg1)
825*404b540aSrobert 	output_asm_insn ("add $4,%0", &addreg1);
826*404b540aSrobert 
827*404b540aSrobert       /* Do that word.  */
828*404b540aSrobert       output_asm_insn(output_move_double(latehalf), latehalf);
829*404b540aSrobert 
830*404b540aSrobert       /* Undo the adds we just did.  */
831*404b540aSrobert       if (addreg0)
832*404b540aSrobert 	output_asm_insn ("sub $4,%0", &addreg0);
833*404b540aSrobert       if (addreg1)
834*404b540aSrobert 	output_asm_insn ("sub $4,%0", &addreg1);
835*404b540aSrobert 
836*404b540aSrobert       /* Do low-numbered word.  */
837*404b540aSrobert       return output_move_double (operands);
838*404b540aSrobert     }
839*404b540aSrobert 
840*404b540aSrobert   /* Normal case: do the two words, low-numbered first.  */
841*404b540aSrobert 
842*404b540aSrobert   output_asm_insn (output_move_double (operands), operands);
843*404b540aSrobert 
844*404b540aSrobert   /* Make any unoffsettable addresses point at high-numbered word.  */
845*404b540aSrobert   if (addreg0)
846*404b540aSrobert     output_asm_insn ("add $4,%0", &addreg0);
847*404b540aSrobert   if (addreg1)
848*404b540aSrobert     output_asm_insn ("add $4,%0", &addreg1);
849*404b540aSrobert 
850*404b540aSrobert   /* Do that word.  */
851*404b540aSrobert   output_asm_insn (output_move_double (latehalf), latehalf);
852*404b540aSrobert 
853*404b540aSrobert   /* Undo the adds we just did.  */
854*404b540aSrobert   if (addreg0)
855*404b540aSrobert     output_asm_insn ("sub $4,%0", &addreg0);
856*404b540aSrobert   if (addreg1)
857*404b540aSrobert     output_asm_insn ("sub $4,%0", &addreg1);
858*404b540aSrobert 
859*404b540aSrobert   return "";
860*404b540aSrobert }
861*404b540aSrobert 
862*404b540aSrobert 
863*404b540aSrobert /* Return a REG that occurs in ADDR with coefficient 1.
864*404b540aSrobert    ADDR can be effectively incremented by incrementing REG.  */
865*404b540aSrobert 
866*404b540aSrobert static rtx
find_addr_reg(rtx addr)867*404b540aSrobert find_addr_reg (rtx addr)
868*404b540aSrobert {
869*404b540aSrobert   while (GET_CODE (addr) == PLUS)
870*404b540aSrobert     {
871*404b540aSrobert       if (GET_CODE (XEXP (addr, 0)) == REG)
872*404b540aSrobert 	addr = XEXP (addr, 0);
873*404b540aSrobert       if (GET_CODE (XEXP (addr, 1)) == REG)
874*404b540aSrobert 	addr = XEXP (addr, 1);
875*404b540aSrobert       if (CONSTANT_P (XEXP (addr, 0)))
876*404b540aSrobert 	addr = XEXP (addr, 1);
877*404b540aSrobert       if (CONSTANT_P (XEXP (addr, 1)))
878*404b540aSrobert 	addr = XEXP (addr, 0);
879*404b540aSrobert     }
880*404b540aSrobert   if (GET_CODE (addr) == REG)
881*404b540aSrobert     return addr;
882*404b540aSrobert   return 0;
883*404b540aSrobert }
884*404b540aSrobert 
885*404b540aSrobert /* Output an ascii string.  */
886*404b540aSrobert void
output_ascii(FILE * file,const char * p,int size)887*404b540aSrobert output_ascii (FILE *file, const char *p, int size)
888*404b540aSrobert {
889*404b540aSrobert   int i;
890*404b540aSrobert 
891*404b540aSrobert   /* This used to output .byte "string", which doesn't work with the UNIX
892*404b540aSrobert      assembler and I think not with DEC ones either.  */
893*404b540aSrobert   fprintf (file, "\t.byte ");
894*404b540aSrobert 
895*404b540aSrobert   for (i = 0; i < size; i++)
896*404b540aSrobert     {
897*404b540aSrobert       register int c = p[i];
898*404b540aSrobert       if (c < 0)
899*404b540aSrobert 	c += 256;
900*404b540aSrobert       fprintf (file, "%#o", c);
901*404b540aSrobert       if (i < size - 1)
902*404b540aSrobert 	putc (',', file);
903*404b540aSrobert     }
904*404b540aSrobert   putc ('\n', file);
905*404b540aSrobert }
906*404b540aSrobert 
907*404b540aSrobert 
908*404b540aSrobert /* --- stole from out-vax, needs changes */
909*404b540aSrobert 
910*404b540aSrobert void
print_operand_address(FILE * file,register rtx addr)911*404b540aSrobert print_operand_address (FILE *file, register rtx addr)
912*404b540aSrobert {
913*404b540aSrobert   register rtx reg1, reg2, breg, ireg;
914*404b540aSrobert   rtx offset;
915*404b540aSrobert 
916*404b540aSrobert  retry:
917*404b540aSrobert 
918*404b540aSrobert   switch (GET_CODE (addr))
919*404b540aSrobert     {
920*404b540aSrobert     case MEM:
921*404b540aSrobert       if (TARGET_UNIX_ASM)
922*404b540aSrobert 	fprintf (file, "*");
923*404b540aSrobert       else
924*404b540aSrobert 	fprintf (file, "@");
925*404b540aSrobert       addr = XEXP (addr, 0);
926*404b540aSrobert       goto retry;
927*404b540aSrobert 
928*404b540aSrobert     case REG:
929*404b540aSrobert       fprintf (file, "(%s)", reg_names[REGNO (addr)]);
930*404b540aSrobert       break;
931*404b540aSrobert 
932*404b540aSrobert     case PRE_MODIFY:
933*404b540aSrobert     case PRE_DEC:
934*404b540aSrobert       fprintf (file, "-(%s)", reg_names[REGNO (XEXP (addr, 0))]);
935*404b540aSrobert       break;
936*404b540aSrobert 
937*404b540aSrobert     case POST_MODIFY:
938*404b540aSrobert     case POST_INC:
939*404b540aSrobert       fprintf (file, "(%s)+", reg_names[REGNO (XEXP (addr, 0))]);
940*404b540aSrobert       break;
941*404b540aSrobert 
942*404b540aSrobert     case PLUS:
943*404b540aSrobert       reg1 = 0;	reg2 = 0;
944*404b540aSrobert       ireg = 0;	breg = 0;
945*404b540aSrobert       offset = 0;
946*404b540aSrobert       if (CONSTANT_ADDRESS_P (XEXP (addr, 0))
947*404b540aSrobert 	  || GET_CODE (XEXP (addr, 0)) == MEM)
948*404b540aSrobert 	{
949*404b540aSrobert 	  offset = XEXP (addr, 0);
950*404b540aSrobert 	  addr = XEXP (addr, 1);
951*404b540aSrobert 	}
952*404b540aSrobert       else if (CONSTANT_ADDRESS_P (XEXP (addr, 1))
953*404b540aSrobert 	       || GET_CODE (XEXP (addr, 1)) == MEM)
954*404b540aSrobert 	{
955*404b540aSrobert 	  offset = XEXP (addr, 1);
956*404b540aSrobert 	  addr = XEXP (addr, 0);
957*404b540aSrobert 	}
958*404b540aSrobert       if (GET_CODE (addr) != PLUS)
959*404b540aSrobert 	;
960*404b540aSrobert       else if (GET_CODE (XEXP (addr, 0)) == MULT)
961*404b540aSrobert 	{
962*404b540aSrobert 	  reg1 = XEXP (addr, 0);
963*404b540aSrobert 	  addr = XEXP (addr, 1);
964*404b540aSrobert 	}
965*404b540aSrobert       else if (GET_CODE (XEXP (addr, 1)) == MULT)
966*404b540aSrobert 	{
967*404b540aSrobert 	  reg1 = XEXP (addr, 1);
968*404b540aSrobert 	  addr = XEXP (addr, 0);
969*404b540aSrobert 	}
970*404b540aSrobert       else if (GET_CODE (XEXP (addr, 0)) == REG)
971*404b540aSrobert 	{
972*404b540aSrobert 	  reg1 = XEXP (addr, 0);
973*404b540aSrobert 	  addr = XEXP (addr, 1);
974*404b540aSrobert 	}
975*404b540aSrobert       else if (GET_CODE (XEXP (addr, 1)) == REG)
976*404b540aSrobert 	{
977*404b540aSrobert 	  reg1 = XEXP (addr, 1);
978*404b540aSrobert 	  addr = XEXP (addr, 0);
979*404b540aSrobert 	}
980*404b540aSrobert       if (GET_CODE (addr) == REG || GET_CODE (addr) == MULT)
981*404b540aSrobert 	{
982*404b540aSrobert 	  if (reg1 == 0)
983*404b540aSrobert 	    reg1 = addr;
984*404b540aSrobert 	  else
985*404b540aSrobert 	    reg2 = addr;
986*404b540aSrobert 	  addr = 0;
987*404b540aSrobert 	}
988*404b540aSrobert       if (offset != 0)
989*404b540aSrobert 	{
990*404b540aSrobert 	  gcc_assert (addr == 0);
991*404b540aSrobert 	  addr = offset;
992*404b540aSrobert 	}
993*404b540aSrobert       if (reg1 != 0 && GET_CODE (reg1) == MULT)
994*404b540aSrobert 	{
995*404b540aSrobert 	  breg = reg2;
996*404b540aSrobert 	  ireg = reg1;
997*404b540aSrobert 	}
998*404b540aSrobert       else if (reg2 != 0 && GET_CODE (reg2) == MULT)
999*404b540aSrobert 	{
1000*404b540aSrobert 	  breg = reg1;
1001*404b540aSrobert 	  ireg = reg2;
1002*404b540aSrobert 	}
1003*404b540aSrobert       else if (reg2 != 0 || GET_CODE (addr) == MEM)
1004*404b540aSrobert 	{
1005*404b540aSrobert 	  breg = reg2;
1006*404b540aSrobert 	  ireg = reg1;
1007*404b540aSrobert 	}
1008*404b540aSrobert       else
1009*404b540aSrobert 	{
1010*404b540aSrobert 	  breg = reg1;
1011*404b540aSrobert 	  ireg = reg2;
1012*404b540aSrobert 	}
1013*404b540aSrobert       if (addr != 0)
1014*404b540aSrobert 	output_address (addr);
1015*404b540aSrobert       if (breg != 0)
1016*404b540aSrobert 	{
1017*404b540aSrobert 	  gcc_assert (GET_CODE (breg) == REG);
1018*404b540aSrobert 	  fprintf (file, "(%s)", reg_names[REGNO (breg)]);
1019*404b540aSrobert 	}
1020*404b540aSrobert       if (ireg != 0)
1021*404b540aSrobert 	{
1022*404b540aSrobert 	  if (GET_CODE (ireg) == MULT)
1023*404b540aSrobert 	    ireg = XEXP (ireg, 0);
1024*404b540aSrobert 	  gcc_assert (GET_CODE (ireg) == REG);
1025*404b540aSrobert 	  gcc_unreachable(); /* ??? */
1026*404b540aSrobert 	  fprintf (file, "[%s]", reg_names[REGNO (ireg)]);
1027*404b540aSrobert 	}
1028*404b540aSrobert       break;
1029*404b540aSrobert 
1030*404b540aSrobert     default:
1031*404b540aSrobert       output_addr_const_pdp11 (file, addr);
1032*404b540aSrobert     }
1033*404b540aSrobert }
1034*404b540aSrobert 
1035*404b540aSrobert /* Target hook to assemble integer objects.  We need to use the
1036*404b540aSrobert    pdp-specific version of output_addr_const.  */
1037*404b540aSrobert 
1038*404b540aSrobert static bool
pdp11_assemble_integer(rtx x,unsigned int size,int aligned_p)1039*404b540aSrobert pdp11_assemble_integer (rtx x, unsigned int size, int aligned_p)
1040*404b540aSrobert {
1041*404b540aSrobert   if (aligned_p)
1042*404b540aSrobert     switch (size)
1043*404b540aSrobert       {
1044*404b540aSrobert       case 1:
1045*404b540aSrobert 	fprintf (asm_out_file, "\t.byte\t");
1046*404b540aSrobert 	output_addr_const_pdp11 (asm_out_file, x);
1047*404b540aSrobert 	fprintf (asm_out_file, " /* char */\n");
1048*404b540aSrobert 	return true;
1049*404b540aSrobert 
1050*404b540aSrobert       case 2:
1051*404b540aSrobert 	fprintf (asm_out_file, TARGET_UNIX_ASM ? "\t" : "\t.word\t");
1052*404b540aSrobert 	output_addr_const_pdp11 (asm_out_file, x);
1053*404b540aSrobert 	fprintf (asm_out_file, " /* short */\n");
1054*404b540aSrobert 	return true;
1055*404b540aSrobert       }
1056*404b540aSrobert   return default_assemble_integer (x, size, aligned_p);
1057*404b540aSrobert }
1058*404b540aSrobert 
1059*404b540aSrobert 
1060*404b540aSrobert /* register move costs, indexed by regs */
1061*404b540aSrobert 
1062*404b540aSrobert static const int move_costs[N_REG_CLASSES][N_REG_CLASSES] =
1063*404b540aSrobert {
1064*404b540aSrobert              /* NO  MUL  GEN  LFPU  NLFPU FPU ALL */
1065*404b540aSrobert 
1066*404b540aSrobert /* NO */     {  0,   0,   0,    0,    0,    0,   0},
1067*404b540aSrobert /* MUL */    {  0,   2,   2,   10,   22,   22,  22},
1068*404b540aSrobert /* GEN */    {  0,   2,   2,   10,   22,   22,  22},
1069*404b540aSrobert /* LFPU */   {  0,  10,  10,    2,    2,    2,  10},
1070*404b540aSrobert /* NLFPU */  {  0,  22,  22,    2,    2,    2,  22},
1071*404b540aSrobert /* FPU */    {  0,  22,  22,    2,    2,    2,  22},
1072*404b540aSrobert /* ALL */    {  0,  22,  22,   10,   22,   22,  22}
1073*404b540aSrobert }  ;
1074*404b540aSrobert 
1075*404b540aSrobert 
1076*404b540aSrobert /* -- note that some moves are tremendously expensive,
1077*404b540aSrobert    because they require lots of tricks! do we have to
1078*404b540aSrobert    charge the costs incurred by secondary reload class
1079*404b540aSrobert    -- as we do here with 22 -- or not ? */
1080*404b540aSrobert 
1081*404b540aSrobert int
register_move_cost(c1,c2)1082*404b540aSrobert register_move_cost(c1, c2)
1083*404b540aSrobert   enum reg_class c1, c2;
1084*404b540aSrobert {
1085*404b540aSrobert     return move_costs[(int)c1][(int)c2];
1086*404b540aSrobert }
1087*404b540aSrobert 
1088*404b540aSrobert static bool
pdp11_rtx_costs(rtx x,int code,int outer_code ATTRIBUTE_UNUSED,int * total)1089*404b540aSrobert pdp11_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int *total)
1090*404b540aSrobert {
1091*404b540aSrobert   switch (code)
1092*404b540aSrobert     {
1093*404b540aSrobert     case CONST_INT:
1094*404b540aSrobert       if (INTVAL (x) == 0 || INTVAL (x) == -1 || INTVAL (x) == 1)
1095*404b540aSrobert 	{
1096*404b540aSrobert 	  *total = 0;
1097*404b540aSrobert 	  return true;
1098*404b540aSrobert 	}
1099*404b540aSrobert       /* FALLTHRU */
1100*404b540aSrobert 
1101*404b540aSrobert     case CONST:
1102*404b540aSrobert     case LABEL_REF:
1103*404b540aSrobert     case SYMBOL_REF:
1104*404b540aSrobert       /* Twice as expensive as REG.  */
1105*404b540aSrobert       *total = 2;
1106*404b540aSrobert       return true;
1107*404b540aSrobert 
1108*404b540aSrobert     case CONST_DOUBLE:
1109*404b540aSrobert       /* Twice (or 4 times) as expensive as 16 bit.  */
1110*404b540aSrobert       *total = 4;
1111*404b540aSrobert       return true;
1112*404b540aSrobert 
1113*404b540aSrobert     case MULT:
1114*404b540aSrobert       /* ??? There is something wrong in MULT because MULT is not
1115*404b540aSrobert          as cheap as total = 2 even if we can shift!  */
1116*404b540aSrobert       /* If optimizing for size make mult etc cheap, but not 1, so when
1117*404b540aSrobert          in doubt the faster insn is chosen.  */
1118*404b540aSrobert       if (optimize_size)
1119*404b540aSrobert         *total = COSTS_N_INSNS (2);
1120*404b540aSrobert       else
1121*404b540aSrobert         *total = COSTS_N_INSNS (11);
1122*404b540aSrobert       return false;
1123*404b540aSrobert 
1124*404b540aSrobert     case DIV:
1125*404b540aSrobert       if (optimize_size)
1126*404b540aSrobert         *total = COSTS_N_INSNS (2);
1127*404b540aSrobert       else
1128*404b540aSrobert         *total = COSTS_N_INSNS (25);
1129*404b540aSrobert       return false;
1130*404b540aSrobert 
1131*404b540aSrobert     case MOD:
1132*404b540aSrobert       if (optimize_size)
1133*404b540aSrobert         *total = COSTS_N_INSNS (2);
1134*404b540aSrobert       else
1135*404b540aSrobert         *total = COSTS_N_INSNS (26);
1136*404b540aSrobert       return false;
1137*404b540aSrobert 
1138*404b540aSrobert     case ABS:
1139*404b540aSrobert       /* Equivalent to length, so same for optimize_size.  */
1140*404b540aSrobert       *total = COSTS_N_INSNS (3);
1141*404b540aSrobert       return false;
1142*404b540aSrobert 
1143*404b540aSrobert     case ZERO_EXTEND:
1144*404b540aSrobert       /* Only used for qi->hi.  */
1145*404b540aSrobert       *total = COSTS_N_INSNS (1);
1146*404b540aSrobert       return false;
1147*404b540aSrobert 
1148*404b540aSrobert     case SIGN_EXTEND:
1149*404b540aSrobert       if (GET_MODE (x) == HImode)
1150*404b540aSrobert       	*total = COSTS_N_INSNS (1);
1151*404b540aSrobert       else if (GET_MODE (x) == SImode)
1152*404b540aSrobert 	*total = COSTS_N_INSNS (6);
1153*404b540aSrobert       else
1154*404b540aSrobert 	*total = COSTS_N_INSNS (2);
1155*404b540aSrobert       return false;
1156*404b540aSrobert 
1157*404b540aSrobert     case ASHIFT:
1158*404b540aSrobert     case LSHIFTRT:
1159*404b540aSrobert     case ASHIFTRT:
1160*404b540aSrobert       if (optimize_size)
1161*404b540aSrobert         *total = COSTS_N_INSNS (1);
1162*404b540aSrobert       else if (GET_MODE (x) ==  QImode)
1163*404b540aSrobert         {
1164*404b540aSrobert           if (GET_CODE (XEXP (x, 1)) != CONST_INT)
1165*404b540aSrobert    	    *total = COSTS_N_INSNS (8); /* worst case */
1166*404b540aSrobert           else
1167*404b540aSrobert 	    *total = COSTS_N_INSNS (INTVAL (XEXP (x, 1)));
1168*404b540aSrobert         }
1169*404b540aSrobert       else if (GET_MODE (x) == HImode)
1170*404b540aSrobert         {
1171*404b540aSrobert           if (GET_CODE (XEXP (x, 1)) == CONST_INT)
1172*404b540aSrobert             {
1173*404b540aSrobert 	      if (abs (INTVAL (XEXP (x, 1))) == 1)
1174*404b540aSrobert                 *total = COSTS_N_INSNS (1);
1175*404b540aSrobert               else
1176*404b540aSrobert 	        *total = COSTS_N_INSNS (2.5 + 0.5 * INTVAL (XEXP (x, 1)));
1177*404b540aSrobert             }
1178*404b540aSrobert           else
1179*404b540aSrobert             *total = COSTS_N_INSNS (10); /* worst case */
1180*404b540aSrobert         }
1181*404b540aSrobert       else if (GET_MODE (x) == SImode)
1182*404b540aSrobert         {
1183*404b540aSrobert           if (GET_CODE (XEXP (x, 1)) == CONST_INT)
1184*404b540aSrobert 	    *total = COSTS_N_INSNS (2.5 + 0.5 * INTVAL (XEXP (x, 1)));
1185*404b540aSrobert           else /* worst case */
1186*404b540aSrobert             *total = COSTS_N_INSNS (18);
1187*404b540aSrobert         }
1188*404b540aSrobert       return false;
1189*404b540aSrobert 
1190*404b540aSrobert     default:
1191*404b540aSrobert       return false;
1192*404b540aSrobert     }
1193*404b540aSrobert }
1194*404b540aSrobert 
1195*404b540aSrobert const char *
output_jump(const char * pos,const char * neg,int length)1196*404b540aSrobert output_jump (const char *pos, const char *neg, int length)
1197*404b540aSrobert {
1198*404b540aSrobert     static int x = 0;
1199*404b540aSrobert 
1200*404b540aSrobert     static char buf[1000];
1201*404b540aSrobert 
1202*404b540aSrobert #if 0
1203*404b540aSrobert /* currently we don't need this, because the tstdf and cmpdf
1204*404b540aSrobert    copy the condition code immediately, and other float operations are not
1205*404b540aSrobert    yet recognized as changing the FCC - if so, then the length-cost of all
1206*404b540aSrobert    jump insns increases by one, because we have to potentially copy the
1207*404b540aSrobert    FCC! */
1208*404b540aSrobert     if (cc_status.flags & CC_IN_FPU)
1209*404b540aSrobert 	output_asm_insn("cfcc", NULL);
1210*404b540aSrobert #endif
1211*404b540aSrobert 
1212*404b540aSrobert     switch (length)
1213*404b540aSrobert     {
1214*404b540aSrobert       case 1:
1215*404b540aSrobert 
1216*404b540aSrobert 	strcpy(buf, pos);
1217*404b540aSrobert 	strcat(buf, " %l0");
1218*404b540aSrobert 
1219*404b540aSrobert 	return buf;
1220*404b540aSrobert 
1221*404b540aSrobert       case 3:
1222*404b540aSrobert 
1223*404b540aSrobert 	sprintf(buf, "%s JMP_%d\n\tjmp %%l0\nJMP_%d:", neg, x, x);
1224*404b540aSrobert 
1225*404b540aSrobert 	x++;
1226*404b540aSrobert 
1227*404b540aSrobert 	return buf;
1228*404b540aSrobert 
1229*404b540aSrobert       default:
1230*404b540aSrobert 
1231*404b540aSrobert 	gcc_unreachable ();
1232*404b540aSrobert     }
1233*404b540aSrobert 
1234*404b540aSrobert }
1235*404b540aSrobert 
1236*404b540aSrobert void
notice_update_cc_on_set(rtx exp,rtx insn ATTRIBUTE_UNUSED)1237*404b540aSrobert notice_update_cc_on_set(rtx exp, rtx insn ATTRIBUTE_UNUSED)
1238*404b540aSrobert {
1239*404b540aSrobert     if (GET_CODE (SET_DEST (exp)) == CC0)
1240*404b540aSrobert     {
1241*404b540aSrobert 	cc_status.flags = 0;
1242*404b540aSrobert 	cc_status.value1 = SET_DEST (exp);
1243*404b540aSrobert 	cc_status.value2 = SET_SRC (exp);
1244*404b540aSrobert 
1245*404b540aSrobert /*
1246*404b540aSrobert 	if (GET_MODE(SET_SRC(exp)) == DFmode)
1247*404b540aSrobert 	    cc_status.flags |= CC_IN_FPU;
1248*404b540aSrobert */
1249*404b540aSrobert     }
1250*404b540aSrobert     else if ((GET_CODE (SET_DEST (exp)) == REG
1251*404b540aSrobert 	      || GET_CODE (SET_DEST (exp)) == MEM)
1252*404b540aSrobert 	     && GET_CODE (SET_SRC (exp)) != PC
1253*404b540aSrobert 	     && (GET_MODE (SET_DEST(exp)) == HImode
1254*404b540aSrobert 		 || GET_MODE (SET_DEST(exp)) == QImode)
1255*404b540aSrobert 		&& (GET_CODE (SET_SRC(exp)) == PLUS
1256*404b540aSrobert 		    || GET_CODE (SET_SRC(exp)) == MINUS
1257*404b540aSrobert 		    || GET_CODE (SET_SRC(exp)) == AND
1258*404b540aSrobert 		    || GET_CODE (SET_SRC(exp)) == IOR
1259*404b540aSrobert 		    || GET_CODE (SET_SRC(exp)) == XOR
1260*404b540aSrobert 		    || GET_CODE (SET_SRC(exp)) == NOT
1261*404b540aSrobert 		    || GET_CODE (SET_SRC(exp)) == NEG
1262*404b540aSrobert 			|| GET_CODE (SET_SRC(exp)) == REG
1263*404b540aSrobert 		    || GET_CODE (SET_SRC(exp)) == MEM))
1264*404b540aSrobert     {
1265*404b540aSrobert 	cc_status.flags = 0;
1266*404b540aSrobert 	cc_status.value1 = SET_SRC (exp);
1267*404b540aSrobert 	cc_status.value2 = SET_DEST (exp);
1268*404b540aSrobert 
1269*404b540aSrobert 	if (cc_status.value1 && GET_CODE (cc_status.value1) == REG
1270*404b540aSrobert 	    && cc_status.value2
1271*404b540aSrobert 	    && reg_overlap_mentioned_p (cc_status.value1, cc_status.value2))
1272*404b540aSrobert     	    cc_status.value2 = 0;
1273*404b540aSrobert 	if (cc_status.value1 && GET_CODE (cc_status.value1) == MEM
1274*404b540aSrobert 	    && cc_status.value2
1275*404b540aSrobert 	    && GET_CODE (cc_status.value2) == MEM)
1276*404b540aSrobert 	    cc_status.value2 = 0;
1277*404b540aSrobert     }
1278*404b540aSrobert     else if (GET_CODE (SET_SRC (exp)) == CALL)
1279*404b540aSrobert     {
1280*404b540aSrobert 	CC_STATUS_INIT;
1281*404b540aSrobert     }
1282*404b540aSrobert     else if (GET_CODE (SET_DEST (exp)) == REG)
1283*404b540aSrobert 	/* what's this ? */
1284*404b540aSrobert     {
1285*404b540aSrobert 	if ((cc_status.value1
1286*404b540aSrobert 	     && reg_overlap_mentioned_p (SET_DEST (exp), cc_status.value1)))
1287*404b540aSrobert 	    cc_status.value1 = 0;
1288*404b540aSrobert 	if ((cc_status.value2
1289*404b540aSrobert 	     && reg_overlap_mentioned_p (SET_DEST (exp), cc_status.value2)))
1290*404b540aSrobert 	    cc_status.value2 = 0;
1291*404b540aSrobert     }
1292*404b540aSrobert     else if (SET_DEST(exp) == pc_rtx)
1293*404b540aSrobert     {
1294*404b540aSrobert 	/* jump */
1295*404b540aSrobert     }
1296*404b540aSrobert     else /* if (GET_CODE (SET_DEST (exp)) == MEM)	*/
1297*404b540aSrobert     {
1298*404b540aSrobert 	/* the last else is a bit paranoiac, but since nearly all instructions
1299*404b540aSrobert 	   play with condition codes, it's reasonable! */
1300*404b540aSrobert 
1301*404b540aSrobert 	CC_STATUS_INIT; /* paranoia*/
1302*404b540aSrobert     }
1303*404b540aSrobert }
1304*404b540aSrobert 
1305*404b540aSrobert 
1306*404b540aSrobert int
simple_memory_operand(rtx op,enum machine_mode mode ATTRIBUTE_UNUSED)1307*404b540aSrobert simple_memory_operand(rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
1308*404b540aSrobert {
1309*404b540aSrobert     rtx addr;
1310*404b540aSrobert 
1311*404b540aSrobert     /* Eliminate non-memory operations */
1312*404b540aSrobert     if (GET_CODE (op) != MEM)
1313*404b540aSrobert 	return FALSE;
1314*404b540aSrobert 
1315*404b540aSrobert #if 0
1316*404b540aSrobert     /* dword operations really put out 2 instructions, so eliminate them.  */
1317*404b540aSrobert     if (GET_MODE_SIZE (GET_MODE (op)) > (HAVE_64BIT_P () ? 8 : 4))
1318*404b540aSrobert 	return FALSE;
1319*404b540aSrobert #endif
1320*404b540aSrobert 
1321*404b540aSrobert     /* Decode the address now.  */
1322*404b540aSrobert 
1323*404b540aSrobert   indirection:
1324*404b540aSrobert 
1325*404b540aSrobert     addr = XEXP (op, 0);
1326*404b540aSrobert 
1327*404b540aSrobert     switch (GET_CODE (addr))
1328*404b540aSrobert     {
1329*404b540aSrobert       case REG:
1330*404b540aSrobert 	/* (R0) - no extra cost */
1331*404b540aSrobert 	return 1;
1332*404b540aSrobert 
1333*404b540aSrobert       case PRE_DEC:
1334*404b540aSrobert       case POST_INC:
1335*404b540aSrobert 	/* -(R0), (R0)+ - cheap! */
1336*404b540aSrobert 	return 0;
1337*404b540aSrobert 
1338*404b540aSrobert       case MEM:
1339*404b540aSrobert 	/* cheap - is encoded in addressing mode info!
1340*404b540aSrobert 
1341*404b540aSrobert 	   -- except for @(R0), which has to be @0(R0) !!! */
1342*404b540aSrobert 
1343*404b540aSrobert 	if (GET_CODE (XEXP (addr, 0)) == REG)
1344*404b540aSrobert 	    return 0;
1345*404b540aSrobert 
1346*404b540aSrobert 	op=addr;
1347*404b540aSrobert 	goto indirection;
1348*404b540aSrobert 
1349*404b540aSrobert       case CONST_INT:
1350*404b540aSrobert       case LABEL_REF:
1351*404b540aSrobert       case CONST:
1352*404b540aSrobert       case SYMBOL_REF:
1353*404b540aSrobert 	/* @#address - extra cost */
1354*404b540aSrobert 	return 0;
1355*404b540aSrobert 
1356*404b540aSrobert       case PLUS:
1357*404b540aSrobert 	/* X(R0) - extra cost */
1358*404b540aSrobert 	return 0;
1359*404b540aSrobert 
1360*404b540aSrobert       default:
1361*404b540aSrobert 	break;
1362*404b540aSrobert     }
1363*404b540aSrobert 
1364*404b540aSrobert     return FALSE;
1365*404b540aSrobert }
1366*404b540aSrobert 
1367*404b540aSrobert 
1368*404b540aSrobert /*
1369*404b540aSrobert  * output a block move:
1370*404b540aSrobert  *
1371*404b540aSrobert  * operands[0]	... to
1372*404b540aSrobert  * operands[1]  ... from
1373*404b540aSrobert  * operands[2]  ... length
1374*404b540aSrobert  * operands[3]  ... alignment
1375*404b540aSrobert  * operands[4]  ... scratch register
1376*404b540aSrobert  */
1377*404b540aSrobert 
1378*404b540aSrobert 
1379*404b540aSrobert const char *
output_block_move(rtx * operands)1380*404b540aSrobert output_block_move(rtx *operands)
1381*404b540aSrobert {
1382*404b540aSrobert     static int count = 0;
1383*404b540aSrobert     char buf[200];
1384*404b540aSrobert 
1385*404b540aSrobert     if (GET_CODE(operands[2]) == CONST_INT
1386*404b540aSrobert 	&& ! optimize_size)
1387*404b540aSrobert     {
1388*404b540aSrobert 	if (INTVAL(operands[2]) < 16
1389*404b540aSrobert 	    && INTVAL(operands[3]) == 1)
1390*404b540aSrobert 	{
1391*404b540aSrobert 	    register int i;
1392*404b540aSrobert 
1393*404b540aSrobert 	    for (i = 1; i <= INTVAL(operands[2]); i++)
1394*404b540aSrobert 		output_asm_insn("movb (%1)+, (%0)+", operands);
1395*404b540aSrobert 
1396*404b540aSrobert 	    return "";
1397*404b540aSrobert 	}
1398*404b540aSrobert 	else if (INTVAL(operands[2]) < 32)
1399*404b540aSrobert 	{
1400*404b540aSrobert 	    register int i;
1401*404b540aSrobert 
1402*404b540aSrobert 	    for (i = 1; i <= INTVAL(operands[2])/2; i++)
1403*404b540aSrobert 		output_asm_insn("mov (%1)+, (%0)+", operands);
1404*404b540aSrobert 
1405*404b540aSrobert 	    /* may I assume that moved quantity is
1406*404b540aSrobert 	       multiple of alignment ???
1407*404b540aSrobert 
1408*404b540aSrobert 	       I HOPE SO !
1409*404b540aSrobert 	    */
1410*404b540aSrobert 
1411*404b540aSrobert 	    return "";
1412*404b540aSrobert 	}
1413*404b540aSrobert 
1414*404b540aSrobert 
1415*404b540aSrobert 	/* can do other clever things, maybe... */
1416*404b540aSrobert     }
1417*404b540aSrobert 
1418*404b540aSrobert     if (CONSTANT_P(operands[2]) )
1419*404b540aSrobert     {
1420*404b540aSrobert 	/* just move count to scratch */
1421*404b540aSrobert 	output_asm_insn("mov %2, %4", operands);
1422*404b540aSrobert     }
1423*404b540aSrobert     else
1424*404b540aSrobert     {
1425*404b540aSrobert 	/* just clobber the register */
1426*404b540aSrobert 	operands[4] = operands[2];
1427*404b540aSrobert     }
1428*404b540aSrobert 
1429*404b540aSrobert 
1430*404b540aSrobert     /* switch over alignment */
1431*404b540aSrobert     switch (INTVAL(operands[3]))
1432*404b540aSrobert     {
1433*404b540aSrobert       case 1:
1434*404b540aSrobert 
1435*404b540aSrobert 	/*
1436*404b540aSrobert 	  x:
1437*404b540aSrobert 	  movb (%1)+, (%0)+
1438*404b540aSrobert 
1439*404b540aSrobert 	  if (TARGET_45)
1440*404b540aSrobert 	     sob %4,x
1441*404b540aSrobert 	  else
1442*404b540aSrobert 	     dec %4
1443*404b540aSrobert 	     bgt x
1444*404b540aSrobert 
1445*404b540aSrobert 	*/
1446*404b540aSrobert 
1447*404b540aSrobert 	sprintf(buf, "\nmovestrhi%d:", count);
1448*404b540aSrobert 	output_asm_insn(buf, NULL);
1449*404b540aSrobert 
1450*404b540aSrobert 	output_asm_insn("movb (%1)+, (%0)+", operands);
1451*404b540aSrobert 
1452*404b540aSrobert 	if (TARGET_45)
1453*404b540aSrobert 	{
1454*404b540aSrobert 	    sprintf(buf, "sob %%4, movestrhi%d", count);
1455*404b540aSrobert 	    output_asm_insn(buf, operands);
1456*404b540aSrobert 	}
1457*404b540aSrobert 	else
1458*404b540aSrobert 	{
1459*404b540aSrobert 	    output_asm_insn("dec %4", operands);
1460*404b540aSrobert 
1461*404b540aSrobert 	    sprintf(buf, "bgt movestrhi%d", count);
1462*404b540aSrobert 	    output_asm_insn(buf, NULL);
1463*404b540aSrobert 	}
1464*404b540aSrobert 
1465*404b540aSrobert 	count ++;
1466*404b540aSrobert 	break;
1467*404b540aSrobert 
1468*404b540aSrobert       case 2:
1469*404b540aSrobert 
1470*404b540aSrobert 	/*
1471*404b540aSrobert 	   asr %4
1472*404b540aSrobert 
1473*404b540aSrobert 	   x:
1474*404b540aSrobert 
1475*404b540aSrobert 	   mov (%1)+, (%0)+
1476*404b540aSrobert 
1477*404b540aSrobert 	   if (TARGET_45)
1478*404b540aSrobert 	     sob %4, x
1479*404b540aSrobert 	   else
1480*404b540aSrobert 	     dec %4
1481*404b540aSrobert 	     bgt x
1482*404b540aSrobert 	*/
1483*404b540aSrobert 
1484*404b540aSrobert       generate_compact_code:
1485*404b540aSrobert 
1486*404b540aSrobert 	output_asm_insn("asr %4", operands);
1487*404b540aSrobert 
1488*404b540aSrobert 	sprintf(buf, "\nmovestrhi%d:", count);
1489*404b540aSrobert 	output_asm_insn(buf, NULL);
1490*404b540aSrobert 
1491*404b540aSrobert 	output_asm_insn("mov (%1)+, (%0)+", operands);
1492*404b540aSrobert 
1493*404b540aSrobert 	if (TARGET_45)
1494*404b540aSrobert 	{
1495*404b540aSrobert 	    sprintf(buf, "sob %%4, movestrhi%d", count);
1496*404b540aSrobert 	    output_asm_insn(buf, operands);
1497*404b540aSrobert 	}
1498*404b540aSrobert 	else
1499*404b540aSrobert 	{
1500*404b540aSrobert 	    output_asm_insn("dec %4", operands);
1501*404b540aSrobert 
1502*404b540aSrobert 	    sprintf(buf, "bgt movestrhi%d", count);
1503*404b540aSrobert 	    output_asm_insn(buf, NULL);
1504*404b540aSrobert 	}
1505*404b540aSrobert 
1506*404b540aSrobert 	count ++;
1507*404b540aSrobert 	break;
1508*404b540aSrobert 
1509*404b540aSrobert       case 4:
1510*404b540aSrobert 
1511*404b540aSrobert 	/*
1512*404b540aSrobert 
1513*404b540aSrobert 	   asr %4
1514*404b540aSrobert 	   asr %4
1515*404b540aSrobert 
1516*404b540aSrobert 	   x:
1517*404b540aSrobert 
1518*404b540aSrobert 	   mov (%1)+, (%0)+
1519*404b540aSrobert 	   mov (%1)+, (%0)+
1520*404b540aSrobert 
1521*404b540aSrobert 	   if (TARGET_45)
1522*404b540aSrobert 	     sob %4, x
1523*404b540aSrobert 	   else
1524*404b540aSrobert 	     dec %4
1525*404b540aSrobert 	     bgt x
1526*404b540aSrobert 	*/
1527*404b540aSrobert 
1528*404b540aSrobert 	if (optimize_size)
1529*404b540aSrobert 	    goto generate_compact_code;
1530*404b540aSrobert 
1531*404b540aSrobert 	output_asm_insn("asr %4", operands);
1532*404b540aSrobert 	output_asm_insn("asr %4", operands);
1533*404b540aSrobert 
1534*404b540aSrobert 	sprintf(buf, "\nmovestrhi%d:", count);
1535*404b540aSrobert 	output_asm_insn(buf, NULL);
1536*404b540aSrobert 
1537*404b540aSrobert 	output_asm_insn("mov (%1)+, (%0)+", operands);
1538*404b540aSrobert 	output_asm_insn("mov (%1)+, (%0)+", operands);
1539*404b540aSrobert 
1540*404b540aSrobert 	if (TARGET_45)
1541*404b540aSrobert 	{
1542*404b540aSrobert 	    sprintf(buf, "sob %%4, movestrhi%d", count);
1543*404b540aSrobert 	    output_asm_insn(buf, operands);
1544*404b540aSrobert 	}
1545*404b540aSrobert 	else
1546*404b540aSrobert 	{
1547*404b540aSrobert 	    output_asm_insn("dec %4", operands);
1548*404b540aSrobert 
1549*404b540aSrobert 	    sprintf(buf, "bgt movestrhi%d", count);
1550*404b540aSrobert 	    output_asm_insn(buf, NULL);
1551*404b540aSrobert 	}
1552*404b540aSrobert 
1553*404b540aSrobert 	count ++;
1554*404b540aSrobert 	break;
1555*404b540aSrobert 
1556*404b540aSrobert       default:
1557*404b540aSrobert 
1558*404b540aSrobert 	/*
1559*404b540aSrobert 
1560*404b540aSrobert 	   asr %4
1561*404b540aSrobert 	   asr %4
1562*404b540aSrobert 	   asr %4
1563*404b540aSrobert 
1564*404b540aSrobert 	   x:
1565*404b540aSrobert 
1566*404b540aSrobert 	   mov (%1)+, (%0)+
1567*404b540aSrobert 	   mov (%1)+, (%0)+
1568*404b540aSrobert 	   mov (%1)+, (%0)+
1569*404b540aSrobert 	   mov (%1)+, (%0)+
1570*404b540aSrobert 
1571*404b540aSrobert 	   if (TARGET_45)
1572*404b540aSrobert 	     sob %4, x
1573*404b540aSrobert 	   else
1574*404b540aSrobert 	     dec %4
1575*404b540aSrobert 	     bgt x
1576*404b540aSrobert 	*/
1577*404b540aSrobert 
1578*404b540aSrobert 
1579*404b540aSrobert 	if (optimize_size)
1580*404b540aSrobert 	    goto generate_compact_code;
1581*404b540aSrobert 
1582*404b540aSrobert 	output_asm_insn("asr %4", operands);
1583*404b540aSrobert 	output_asm_insn("asr %4", operands);
1584*404b540aSrobert 	output_asm_insn("asr %4", operands);
1585*404b540aSrobert 
1586*404b540aSrobert 	sprintf(buf, "\nmovestrhi%d:", count);
1587*404b540aSrobert 	output_asm_insn(buf, NULL);
1588*404b540aSrobert 
1589*404b540aSrobert 	output_asm_insn("mov (%1)+, (%0)+", operands);
1590*404b540aSrobert 	output_asm_insn("mov (%1)+, (%0)+", operands);
1591*404b540aSrobert 	output_asm_insn("mov (%1)+, (%0)+", operands);
1592*404b540aSrobert 	output_asm_insn("mov (%1)+, (%0)+", operands);
1593*404b540aSrobert 
1594*404b540aSrobert 	if (TARGET_45)
1595*404b540aSrobert 	{
1596*404b540aSrobert 	    sprintf(buf, "sob %%4, movestrhi%d", count);
1597*404b540aSrobert 	    output_asm_insn(buf, operands);
1598*404b540aSrobert 	}
1599*404b540aSrobert 	else
1600*404b540aSrobert 	{
1601*404b540aSrobert 	    output_asm_insn("dec %4", operands);
1602*404b540aSrobert 
1603*404b540aSrobert 	    sprintf(buf, "bgt movestrhi%d", count);
1604*404b540aSrobert 	    output_asm_insn(buf, NULL);
1605*404b540aSrobert 	}
1606*404b540aSrobert 
1607*404b540aSrobert 	count ++;
1608*404b540aSrobert 	break;
1609*404b540aSrobert 
1610*404b540aSrobert 	;
1611*404b540aSrobert 
1612*404b540aSrobert     }
1613*404b540aSrobert 
1614*404b540aSrobert     return "";
1615*404b540aSrobert }
1616*404b540aSrobert 
1617*404b540aSrobert int
legitimate_address_p(enum machine_mode mode,rtx address)1618*404b540aSrobert legitimate_address_p (enum machine_mode mode, rtx address)
1619*404b540aSrobert {
1620*404b540aSrobert /* #define REG_OK_STRICT */
1621*404b540aSrobert     GO_IF_LEGITIMATE_ADDRESS(mode, address, win);
1622*404b540aSrobert 
1623*404b540aSrobert     return 0;
1624*404b540aSrobert 
1625*404b540aSrobert   win:
1626*404b540aSrobert     return 1;
1627*404b540aSrobert 
1628*404b540aSrobert /* #undef REG_OK_STRICT */
1629*404b540aSrobert }
1630*404b540aSrobert 
1631*404b540aSrobert /* This function checks whether a real value can be encoded as
1632*404b540aSrobert    a literal, i.e., addressing mode 27.  In that mode, real values
1633*404b540aSrobert    are one word values, so the remaining 48 bits have to be zero.  */
1634*404b540aSrobert int
legitimate_const_double_p(rtx address)1635*404b540aSrobert legitimate_const_double_p (rtx address)
1636*404b540aSrobert {
1637*404b540aSrobert   REAL_VALUE_TYPE r;
1638*404b540aSrobert   long sval[2];
1639*404b540aSrobert   REAL_VALUE_FROM_CONST_DOUBLE (r, address);
1640*404b540aSrobert   REAL_VALUE_TO_TARGET_DOUBLE (r, sval);
1641*404b540aSrobert   if ((sval[0] & 0xffff) == 0 && sval[1] == 0)
1642*404b540aSrobert     return 1;
1643*404b540aSrobert   return 0;
1644*404b540aSrobert }
1645*404b540aSrobert 
1646*404b540aSrobert /* A copy of output_addr_const modified for pdp11 expression syntax.
1647*404b540aSrobert    output_addr_const also gets called for %cDIGIT and %nDIGIT, which we don't
1648*404b540aSrobert    use, and for debugging output, which we don't support with this port either.
1649*404b540aSrobert    So this copy should get called whenever needed.
1650*404b540aSrobert */
1651*404b540aSrobert void
output_addr_const_pdp11(FILE * file,rtx x)1652*404b540aSrobert output_addr_const_pdp11 (FILE *file, rtx x)
1653*404b540aSrobert {
1654*404b540aSrobert   char buf[256];
1655*404b540aSrobert 
1656*404b540aSrobert  restart:
1657*404b540aSrobert   switch (GET_CODE (x))
1658*404b540aSrobert     {
1659*404b540aSrobert     case PC:
1660*404b540aSrobert       gcc_assert (flag_pic);
1661*404b540aSrobert       putc ('.', file);
1662*404b540aSrobert       break;
1663*404b540aSrobert 
1664*404b540aSrobert     case SYMBOL_REF:
1665*404b540aSrobert       assemble_name (file, XSTR (x, 0));
1666*404b540aSrobert       break;
1667*404b540aSrobert 
1668*404b540aSrobert     case LABEL_REF:
1669*404b540aSrobert       ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (XEXP (x, 0)));
1670*404b540aSrobert       assemble_name (file, buf);
1671*404b540aSrobert       break;
1672*404b540aSrobert 
1673*404b540aSrobert     case CODE_LABEL:
1674*404b540aSrobert       ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
1675*404b540aSrobert       assemble_name (file, buf);
1676*404b540aSrobert       break;
1677*404b540aSrobert 
1678*404b540aSrobert     case CONST_INT:
1679*404b540aSrobert       /* Should we check for constants which are too big?  Maybe cutting
1680*404b540aSrobert 	 them off to 16 bits is OK?  */
1681*404b540aSrobert       fprintf (file, "%#ho", (unsigned short) INTVAL (x));
1682*404b540aSrobert       break;
1683*404b540aSrobert 
1684*404b540aSrobert     case CONST:
1685*404b540aSrobert       /* This used to output parentheses around the expression,
1686*404b540aSrobert 	 but that does not work on the 386 (either ATT or BSD assembler).  */
1687*404b540aSrobert       output_addr_const_pdp11 (file, XEXP (x, 0));
1688*404b540aSrobert       break;
1689*404b540aSrobert 
1690*404b540aSrobert     case CONST_DOUBLE:
1691*404b540aSrobert       if (GET_MODE (x) == VOIDmode)
1692*404b540aSrobert 	{
1693*404b540aSrobert 	  /* We can use %o if the number is one word and positive.  */
1694*404b540aSrobert 	  gcc_assert (!CONST_DOUBLE_HIGH (x));
1695*404b540aSrobert 	  fprintf (file, "%#ho", (unsigned short) CONST_DOUBLE_LOW (x));
1696*404b540aSrobert 	}
1697*404b540aSrobert       else
1698*404b540aSrobert 	/* We can't handle floating point constants;
1699*404b540aSrobert 	   PRINT_OPERAND must handle them.  */
1700*404b540aSrobert 	output_operand_lossage ("floating constant misused");
1701*404b540aSrobert       break;
1702*404b540aSrobert 
1703*404b540aSrobert     case PLUS:
1704*404b540aSrobert       /* Some assemblers need integer constants to appear last (e.g. masm).  */
1705*404b540aSrobert       if (GET_CODE (XEXP (x, 0)) == CONST_INT)
1706*404b540aSrobert 	{
1707*404b540aSrobert 	  output_addr_const_pdp11 (file, XEXP (x, 1));
1708*404b540aSrobert 	  if (INTVAL (XEXP (x, 0)) >= 0)
1709*404b540aSrobert 	    fprintf (file, "+");
1710*404b540aSrobert 	  output_addr_const_pdp11 (file, XEXP (x, 0));
1711*404b540aSrobert 	}
1712*404b540aSrobert       else
1713*404b540aSrobert 	{
1714*404b540aSrobert 	  output_addr_const_pdp11 (file, XEXP (x, 0));
1715*404b540aSrobert 	  if (INTVAL (XEXP (x, 1)) >= 0)
1716*404b540aSrobert 	    fprintf (file, "+");
1717*404b540aSrobert 	  output_addr_const_pdp11 (file, XEXP (x, 1));
1718*404b540aSrobert 	}
1719*404b540aSrobert       break;
1720*404b540aSrobert 
1721*404b540aSrobert     case MINUS:
1722*404b540aSrobert       /* Avoid outputting things like x-x or x+5-x,
1723*404b540aSrobert 	 since some assemblers can't handle that.  */
1724*404b540aSrobert       x = simplify_subtraction (x);
1725*404b540aSrobert       if (GET_CODE (x) != MINUS)
1726*404b540aSrobert 	goto restart;
1727*404b540aSrobert 
1728*404b540aSrobert       output_addr_const_pdp11 (file, XEXP (x, 0));
1729*404b540aSrobert       fprintf (file, "-");
1730*404b540aSrobert       if (GET_CODE (XEXP (x, 1)) == CONST_INT
1731*404b540aSrobert 	  && INTVAL (XEXP (x, 1)) < 0)
1732*404b540aSrobert 	{
1733*404b540aSrobert 	  fprintf (file, targetm.asm_out.open_paren);
1734*404b540aSrobert 	  output_addr_const_pdp11 (file, XEXP (x, 1));
1735*404b540aSrobert 	  fprintf (file, targetm.asm_out.close_paren);
1736*404b540aSrobert 	}
1737*404b540aSrobert       else
1738*404b540aSrobert 	output_addr_const_pdp11 (file, XEXP (x, 1));
1739*404b540aSrobert       break;
1740*404b540aSrobert 
1741*404b540aSrobert     case ZERO_EXTEND:
1742*404b540aSrobert     case SIGN_EXTEND:
1743*404b540aSrobert       output_addr_const_pdp11 (file, XEXP (x, 0));
1744*404b540aSrobert       break;
1745*404b540aSrobert 
1746*404b540aSrobert     default:
1747*404b540aSrobert       output_operand_lossage ("invalid expression as operand");
1748*404b540aSrobert     }
1749*404b540aSrobert }
1750*404b540aSrobert 
1751*404b540aSrobert /* Worker function for TARGET_RETURN_IN_MEMORY.  */
1752*404b540aSrobert 
1753*404b540aSrobert static bool
pdp11_return_in_memory(tree type,tree fntype ATTRIBUTE_UNUSED)1754*404b540aSrobert pdp11_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
1755*404b540aSrobert {
1756*404b540aSrobert   /* Should probably return DImode and DFmode in memory, lest
1757*404b540aSrobert      we fill up all regs!
1758*404b540aSrobert 
1759*404b540aSrobert      have to, else we crash - exception: maybe return result in
1760*404b540aSrobert      ac0 if DFmode and FPU present - compatibility problem with
1761*404b540aSrobert      libraries for non-floating point....  */
1762*404b540aSrobert   return (TYPE_MODE (type) == DImode
1763*404b540aSrobert 	  || (TYPE_MODE (type) == DFmode && ! TARGET_AC0));
1764*404b540aSrobert }
1765