OSDN Git Service

PR target/15491
[pf3gnuchains/gcc-fork.git] / gcc / config / vax / vax.c
1 /* Subroutines for insn-output.c for VAX.
2    Copyright (C) 1987, 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2004
3    Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "rtl.h"
27 #include "tree.h"
28 #include "regs.h"
29 #include "hard-reg-set.h"
30 #include "real.h"
31 #include "insn-config.h"
32 #include "conditions.h"
33 #include "function.h"
34 #include "output.h"
35 #include "insn-attr.h"
36 #include "recog.h"
37 #include "expr.h"
38 #include "optabs.h"
39 #include "flags.h"
40 #include "debug.h"
41 #include "toplev.h"
42 #include "tm_p.h"
43 #include "target.h"
44 #include "target-def.h"
45
46 static void vax_output_function_prologue (FILE *, HOST_WIDE_INT);
47 static void vax_file_start (void);
48 static void vax_init_libfuncs (void);
49 static void vax_output_mi_thunk (FILE *, tree, HOST_WIDE_INT,
50                                  HOST_WIDE_INT, tree);
51 static int vax_address_cost_1 (rtx);
52 static int vax_address_cost (rtx);
53 static bool vax_rtx_costs (rtx, int, int, int *);
54 static rtx vax_struct_value_rtx (tree, int);
55 \f
56 /* Initialize the GCC target structure.  */
57 #undef TARGET_ASM_ALIGNED_HI_OP
58 #define TARGET_ASM_ALIGNED_HI_OP "\t.word\t"
59
60 #undef TARGET_ASM_FUNCTION_PROLOGUE
61 #define TARGET_ASM_FUNCTION_PROLOGUE vax_output_function_prologue
62
63 #undef TARGET_ASM_FILE_START
64 #define TARGET_ASM_FILE_START vax_file_start
65 #undef TARGET_ASM_FILE_START_APP_OFF
66 #define TARGET_ASM_FILE_START_APP_OFF true
67
68 #undef TARGET_INIT_LIBFUNCS
69 #define TARGET_INIT_LIBFUNCS vax_init_libfuncs
70
71 #undef TARGET_ASM_OUTPUT_MI_THUNK
72 #define TARGET_ASM_OUTPUT_MI_THUNK vax_output_mi_thunk
73 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
74 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK default_can_output_mi_thunk_no_vcall
75
76 #undef TARGET_RTX_COSTS
77 #define TARGET_RTX_COSTS vax_rtx_costs
78 #undef TARGET_ADDRESS_COST
79 #define TARGET_ADDRESS_COST vax_address_cost
80
81 #undef TARGET_PROMOTE_PROTOTYPES
82 #define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_true
83
84 #undef TARGET_STRUCT_VALUE_RTX
85 #define TARGET_STRUCT_VALUE_RTX vax_struct_value_rtx
86
87 struct gcc_target targetm = TARGET_INITIALIZER;
88 \f
89 /* Set global variables as needed for the options enabled.  */
90
91 void
92 override_options (void)
93 {
94   /* We're VAX floating point, not IEEE floating point.  */
95   if (TARGET_G_FLOAT)
96     REAL_MODE_FORMAT (DFmode) = &vax_g_format;
97 }
98
99 /* Generate the assembly code for function entry.  FILE is a stdio
100    stream to output the code to.  SIZE is an int: how many units of
101    temporary storage to allocate.
102
103    Refer to the array `regs_ever_live' to determine which registers to
104    save; `regs_ever_live[I]' is nonzero if register number I is ever
105    used in the function.  This function is responsible for knowing
106    which registers should not be saved even if used.  */
107
108 static void
109 vax_output_function_prologue (FILE * file, HOST_WIDE_INT size)
110 {
111   register int regno;
112   register int mask = 0;
113
114   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
115     if (regs_ever_live[regno] && !call_used_regs[regno])
116       mask |= 1 << regno;
117
118   fprintf (file, "\t.word 0x%x\n", mask);
119
120   if (dwarf2out_do_frame ())
121     {
122       const char *label = dwarf2out_cfi_label ();
123       int offset = 0;
124
125       for (regno = FIRST_PSEUDO_REGISTER-1; regno >= 0; --regno)
126         if (regs_ever_live[regno] && !call_used_regs[regno])
127           dwarf2out_reg_save (label, regno, offset -= 4);
128
129       dwarf2out_reg_save (label, PC_REGNUM, offset -= 4);
130       dwarf2out_reg_save (label, FRAME_POINTER_REGNUM, offset -= 4);
131       dwarf2out_reg_save (label, ARG_POINTER_REGNUM, offset -= 4);
132       dwarf2out_def_cfa (label, FRAME_POINTER_REGNUM, -(offset - 4));
133     }
134
135   size -= STARTING_FRAME_OFFSET;
136   if (size >= 64)
137     asm_fprintf (file, "\tmovab %wd(%Rsp),%Rsp\n", -size);
138   else if (size)
139     asm_fprintf (file, "\tsubl2 $%wd,%Rsp\n", size);
140 }
141
142 /* When debugging with stabs, we want to output an extra dummy label
143    so that gas can distinguish between D_float and G_float prior to
144    processing the .stabs directive identifying type double.  */
145 static void
146 vax_file_start (void)
147 {
148   default_file_start ();
149
150   if (write_symbols == DBX_DEBUG)
151     fprintf (asm_out_file, "___vax_%c_doubles:\n", ASM_DOUBLE_CHAR);
152 }
153
154 /* We can use the BSD C library routines for the libgcc calls that are
155    still generated, since that's what they boil down to anyways.  When
156    ELF, avoid the user's namespace.  */
157
158 static void
159 vax_init_libfuncs (void)
160 {
161   set_optab_libfunc (udiv_optab, SImode, TARGET_ELF ? "*__udiv" : "*udiv");
162   set_optab_libfunc (umod_optab, SImode, TARGET_ELF ? "*__urem" : "*urem");
163 }
164
165 /* This is like nonimmediate_operand with a restriction on the type of MEM.  */
166
167 void
168 split_quadword_operands (rtx * operands, rtx * low, int n ATTRIBUTE_UNUSED)
169 {
170   int i;
171   /* Split operands.  */
172
173   low[0] = low[1] = low[2] = 0;
174   for (i = 0; i < 3; i++)
175     {
176       if (low[i])
177         /* it's already been figured out */;
178       else if (GET_CODE (operands[i]) == MEM
179                && (GET_CODE (XEXP (operands[i], 0)) == POST_INC))
180         {
181           rtx addr = XEXP (operands[i], 0);
182           operands[i] = low[i] = gen_rtx_MEM (SImode, addr);
183           if (which_alternative == 0 && i == 0)
184             {
185               addr = XEXP (operands[i], 0);
186               operands[i+1] = low[i+1] = gen_rtx_MEM (SImode, addr);
187             }
188         }
189       else
190         {
191           low[i] = operand_subword (operands[i], 0, 0, DImode);
192           operands[i] = operand_subword (operands[i], 1, 0, DImode);
193         }
194     }
195 }
196 \f
197 void
198 print_operand_address (FILE * file, register rtx addr)
199 {
200   register rtx reg1, breg, ireg;
201   rtx offset;
202
203  retry:
204   switch (GET_CODE (addr))
205     {
206     case MEM:
207       fprintf (file, "*");
208       addr = XEXP (addr, 0);
209       goto retry;
210
211     case REG:
212       fprintf (file, "(%s)", reg_names[REGNO (addr)]);
213       break;
214
215     case PRE_DEC:
216       fprintf (file, "-(%s)", reg_names[REGNO (XEXP (addr, 0))]);
217       break;
218
219     case POST_INC:
220       fprintf (file, "(%s)+", reg_names[REGNO (XEXP (addr, 0))]);
221       break;
222
223     case PLUS:
224       /* There can be either two or three things added here.  One must be a
225          REG.  One can be either a REG or a MULT of a REG and an appropriate
226          constant, and the third can only be a constant or a MEM.
227
228          We get these two or three things and put the constant or MEM in
229          OFFSET, the MULT or REG in IREG, and the REG in BREG.  If we have
230          a register and can't tell yet if it is a base or index register,
231          put it into REG1.  */
232
233       reg1 = 0; ireg = 0; breg = 0; offset = 0;
234
235       if (CONSTANT_ADDRESS_P (XEXP (addr, 0))
236           || GET_CODE (XEXP (addr, 0)) == MEM)
237         {
238           offset = XEXP (addr, 0);
239           addr = XEXP (addr, 1);
240         }
241       else if (CONSTANT_ADDRESS_P (XEXP (addr, 1))
242                || GET_CODE (XEXP (addr, 1)) == MEM)
243         {
244           offset = XEXP (addr, 1);
245           addr = XEXP (addr, 0);
246         }
247       else if (GET_CODE (XEXP (addr, 1)) == MULT)
248         {
249           ireg = XEXP (addr, 1);
250           addr = XEXP (addr, 0);
251         }
252       else if (GET_CODE (XEXP (addr, 0)) == MULT)
253         {
254           ireg = XEXP (addr, 0);
255           addr = XEXP (addr, 1);
256         }
257       else if (GET_CODE (XEXP (addr, 1)) == REG)
258         {
259           reg1 = XEXP (addr, 1);
260           addr = XEXP (addr, 0);
261         }
262       else if (GET_CODE (XEXP (addr, 0)) == REG)
263         {
264           reg1 = XEXP (addr, 0);
265           addr = XEXP (addr, 1);
266         }
267       else
268         abort ();
269
270       if (GET_CODE (addr) == REG)
271         {
272           if (reg1)
273             ireg = addr;
274           else
275             reg1 = addr;
276         }
277       else if (GET_CODE (addr) == MULT)
278         ireg = addr;
279       else if (GET_CODE (addr) == PLUS)
280         {
281           if (CONSTANT_ADDRESS_P (XEXP (addr, 0))
282               || GET_CODE (XEXP (addr, 0)) == MEM)
283             {
284               if (offset)
285                 {
286                   if (GET_CODE (offset) == CONST_INT)
287                     offset = plus_constant (XEXP (addr, 0), INTVAL (offset));
288                   else if (GET_CODE (XEXP (addr, 0)) == CONST_INT)
289                     offset = plus_constant (offset, INTVAL (XEXP (addr, 0)));
290                   else
291                     abort ();
292                 }
293               offset = XEXP (addr, 0);
294             }
295           else if (GET_CODE (XEXP (addr, 0)) == REG)
296             {
297               if (reg1)
298                 ireg = reg1, breg = XEXP (addr, 0), reg1 = 0;
299               else
300                 reg1 = XEXP (addr, 0);
301             }
302           else if (GET_CODE (XEXP (addr, 0)) == MULT)
303             {
304               if (ireg)
305                 abort ();
306               ireg = XEXP (addr, 0);
307             }
308           else
309             abort ();
310
311           if (CONSTANT_ADDRESS_P (XEXP (addr, 1))
312               || GET_CODE (XEXP (addr, 1)) == MEM)
313             {
314               if (offset)
315                 {
316                   if (GET_CODE (offset) == CONST_INT)
317                     offset = plus_constant (XEXP (addr, 1), INTVAL (offset));
318                   else if (GET_CODE (XEXP (addr, 1)) == CONST_INT)
319                     offset = plus_constant (offset, INTVAL (XEXP (addr, 1)));
320                   else
321                     abort ();
322                 }
323               offset = XEXP (addr, 1);
324             }
325           else if (GET_CODE (XEXP (addr, 1)) == REG)
326             {
327               if (reg1)
328                 ireg = reg1, breg = XEXP (addr, 1), reg1 = 0;
329               else
330                 reg1 = XEXP (addr, 1);
331             }
332           else if (GET_CODE (XEXP (addr, 1)) == MULT)
333             {
334               if (ireg)
335                 abort ();
336               ireg = XEXP (addr, 1);
337             }
338           else
339             abort ();
340         }
341       else
342         abort ();
343
344       /* If REG1 is nonzero, figure out if it is a base or index register.  */
345       if (reg1)
346         {
347           if (breg != 0 || (offset && GET_CODE (offset) == MEM))
348             {
349               if (ireg)
350                 abort ();
351               ireg = reg1;
352             }
353           else
354             breg = reg1;
355         }
356
357       if (offset != 0)
358         output_address (offset);
359
360       if (breg != 0)
361         fprintf (file, "(%s)", reg_names[REGNO (breg)]);
362
363       if (ireg != 0)
364         {
365           if (GET_CODE (ireg) == MULT)
366             ireg = XEXP (ireg, 0);
367           if (GET_CODE (ireg) != REG)
368             abort ();
369           fprintf (file, "[%s]", reg_names[REGNO (ireg)]);
370         }
371       break;
372
373     default:
374       output_addr_const (file, addr);
375     }
376 }
377 \f
378 const char *
379 rev_cond_name (rtx op)
380 {
381   switch (GET_CODE (op))
382     {
383     case EQ:
384       return "neq";
385     case NE:
386       return "eql";
387     case LT:
388       return "geq";
389     case LE:
390       return "gtr";
391     case GT:
392       return "leq";
393     case GE:
394       return "lss";
395     case LTU:
396       return "gequ";
397     case LEU:
398       return "gtru";
399     case GTU:
400       return "lequ";
401     case GEU:
402       return "lssu";
403
404     default:
405       abort ();
406     }
407 }
408
409 int
410 vax_float_literal(register rtx c)
411 {
412   register enum machine_mode mode;
413   REAL_VALUE_TYPE r, s;
414   int i;
415
416   if (GET_CODE (c) != CONST_DOUBLE)
417     return 0;
418
419   mode = GET_MODE (c);
420
421   if (c == const_tiny_rtx[(int) mode][0]
422       || c == const_tiny_rtx[(int) mode][1]
423       || c == const_tiny_rtx[(int) mode][2])
424     return 1;
425
426   REAL_VALUE_FROM_CONST_DOUBLE (r, c);
427
428   for (i = 0; i < 7; i++)
429     {
430       int x = 1 << i;
431       REAL_VALUE_FROM_INT (s, x, 0, mode);
432
433       if (REAL_VALUES_EQUAL (r, s))
434         return 1;
435       if (!exact_real_inverse (mode, &s))
436         abort ();
437       if (REAL_VALUES_EQUAL (r, s))
438         return 1;
439     }
440   return 0;
441 }
442
443
444 /* Return the cost in cycles of a memory address, relative to register
445    indirect.
446
447    Each of the following adds the indicated number of cycles:
448
449    1 - symbolic address
450    1 - pre-decrement
451    1 - indexing and/or offset(register)
452    2 - indirect */
453
454
455 static int
456 vax_address_cost_1 (register rtx addr)
457 {
458   int reg = 0, indexed = 0, indir = 0, offset = 0, predec = 0;
459   rtx plus_op0 = 0, plus_op1 = 0;
460  restart:
461   switch (GET_CODE (addr))
462     {
463     case PRE_DEC:
464       predec = 1;
465     case REG:
466     case SUBREG:
467     case POST_INC:
468       reg = 1;
469       break;
470     case MULT:
471       indexed = 1;      /* 2 on VAX 2 */
472       break;
473     case CONST_INT:
474       /* byte offsets cost nothing (on a VAX 2, they cost 1 cycle) */
475       if (offset == 0)
476         offset = (unsigned HOST_WIDE_INT)(INTVAL(addr)+128) > 256;
477       break;
478     case CONST:
479     case SYMBOL_REF:
480       offset = 1;       /* 2 on VAX 2 */
481       break;
482     case LABEL_REF:     /* this is probably a byte offset from the pc */
483       if (offset == 0)
484         offset = 1;
485       break;
486     case PLUS:
487       if (plus_op0)
488         plus_op1 = XEXP (addr, 0);
489       else
490         plus_op0 = XEXP (addr, 0);
491       addr = XEXP (addr, 1);
492       goto restart;
493     case MEM:
494       indir = 2;        /* 3 on VAX 2 */
495       addr = XEXP (addr, 0);
496       goto restart;
497     default:
498       break;
499     }
500
501   /* Up to 3 things can be added in an address.  They are stored in
502      plus_op0, plus_op1, and addr.  */
503
504   if (plus_op0)
505     {
506       addr = plus_op0;
507       plus_op0 = 0;
508       goto restart;
509     }
510   if (plus_op1)
511     {
512       addr = plus_op1;
513       plus_op1 = 0;
514       goto restart;
515     }
516   /* Indexing and register+offset can both be used (except on a VAX 2)
517      without increasing execution time over either one alone.  */
518   if (reg && indexed && offset)
519     return reg + indir + offset + predec;
520   return reg + indexed + indir + offset + predec;
521 }
522
523 static int
524 vax_address_cost (rtx x)
525 {
526   return (1 + (GET_CODE (x) == REG ? 0 : vax_address_cost_1 (x)));
527 }
528
529 /* Cost of an expression on a VAX.  This version has costs tuned for the
530    CVAX chip (found in the VAX 3 series) with comments for variations on
531    other models.
532
533    FIXME: The costs need review, particularly for TRUNCATE, FLOAT_EXTEND
534    and FLOAT_TRUNCATE.  We need a -mcpu option to allow provision of
535    costs on a per cpu basis.  */
536
537 static bool
538 vax_rtx_costs (rtx x, int code, int outer_code, int *total)
539 {
540   enum machine_mode mode = GET_MODE (x);
541   int i = 0;                               /* may be modified in switch */
542   const char *fmt = GET_RTX_FORMAT (code); /* may be modified in switch */
543
544   switch (code)
545     {
546       /* On a VAX, constants from 0..63 are cheap because they can use the
547          1 byte literal constant format.  Compare to -1 should be made cheap
548          so that decrement-and-branch insns can be formed more easily (if
549          the value -1 is copied to a register some decrement-and-branch
550          patterns will not match).  */
551     case CONST_INT:
552       if (INTVAL (x) == 0)
553         return true;
554       if (outer_code == AND)
555         {
556           *total = ((unsigned HOST_WIDE_INT) ~INTVAL (x) <= 077) ? 1 : 2;
557           return true;
558         }
559       if ((unsigned HOST_WIDE_INT) INTVAL (x) <= 077
560           || (outer_code == COMPARE
561               && INTVAL (x) == -1)
562           || ((outer_code == PLUS || outer_code == MINUS)
563               && (unsigned HOST_WIDE_INT) -INTVAL (x) <= 077))
564         {
565           *total = 1;
566           return true;
567         }
568       /* FALLTHRU */
569
570     case CONST:
571     case LABEL_REF:
572     case SYMBOL_REF:
573       *total = 3;
574       return true;
575
576     case CONST_DOUBLE:
577       if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
578         *total = vax_float_literal (x) ? 5 : 8;
579       else
580         *total = ((CONST_DOUBLE_HIGH (x) == 0
581                    && (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (x) < 64)
582                   || (outer_code == PLUS
583                       && CONST_DOUBLE_HIGH (x) == -1
584                       && (unsigned HOST_WIDE_INT)-CONST_DOUBLE_LOW (x) < 64))
585                  ? 2 : 5;
586       return true;
587  
588     case POST_INC:
589       *total = 2;
590       return true;              /* Implies register operand.  */
591
592     case PRE_DEC:
593       *total = 3;
594       return true;              /* Implies register operand.  */
595
596     case MULT:
597       switch (mode)
598         {
599         case DFmode:
600           *total = 16;          /* 4 on VAX 9000 */
601           break;
602         case SFmode:
603           *total = 9;           /* 4 on VAX 9000, 12 on VAX 2 */
604           break;
605         case DImode:
606           *total = 16;          /* 6 on VAX 9000, 28 on VAX 2 */
607           break;
608         case SImode:
609         case HImode:
610         case QImode:
611           *total = 10;          /* 3-4 on VAX 9000, 20-28 on VAX 2 */
612           break;
613         default:
614           *total = MAX_COST;    /* Mode is not supported.  */
615           return true;
616         }
617       break;
618
619     case UDIV:
620       if (mode != SImode)
621         {
622           *total = MAX_COST;    /* Mode is not supported.  */
623           return true;
624         }
625       *total = 17;
626       break;
627
628     case DIV:
629       if (mode == DImode)
630         *total = 30;            /* Highly variable.  */
631       else if (mode == DFmode)
632         /* divide takes 28 cycles if the result is not zero, 13 otherwise */
633         *total = 24;
634       else
635         *total = 11;            /* 25 on VAX 2 */
636       break;
637
638     case MOD:
639       *total = 23;
640       break;
641
642     case UMOD:
643       if (mode != SImode)
644         {
645           *total = MAX_COST;    /* Mode is not supported.  */
646           return true;
647         }
648       *total = 29;
649       break;
650
651     case FLOAT:
652       *total = (6               /* 4 on VAX 9000 */
653                 + (mode == DFmode) + (GET_MODE (XEXP (x, 0)) != SImode));
654       break;
655
656     case FIX:
657       *total = 7;               /* 17 on VAX 2 */
658       break;
659
660     case ASHIFT:
661     case LSHIFTRT:
662     case ASHIFTRT:
663       if (mode == DImode)
664         *total = 12;
665       else
666         *total = 10;            /* 6 on VAX 9000 */
667       break;
668
669     case ROTATE:
670     case ROTATERT:
671       *total = 6;               /* 5 on VAX 2, 4 on VAX 9000 */
672       if (GET_CODE (XEXP (x, 1)) == CONST_INT)
673         fmt = "e";              /* all constant rotate counts are short */
674       break;
675
676     case PLUS:
677     case MINUS:
678       *total = (mode == DFmode) ? 13 : 8; /* 6/8 on VAX 9000, 16/15 on VAX 2 */
679       /* Small integer operands can use subl2 and addl2.  */
680       if ((GET_CODE (XEXP (x, 1)) == CONST_INT)
681           && (unsigned HOST_WIDE_INT)(INTVAL (XEXP (x, 1)) + 63) < 127)
682         fmt = "e";
683       break;
684
685     case IOR:
686     case XOR:
687       *total = 3;
688       break;
689
690     case AND:
691       /* AND is special because the first operand is complemented.  */
692       *total = 3;
693       if (GET_CODE (XEXP (x, 0)) == CONST_INT)
694         {
695           if ((unsigned HOST_WIDE_INT)~INTVAL (XEXP (x, 0)) > 63)
696             *total = 4;
697           fmt = "e";
698           i = 1;
699         }
700       break;
701
702     case NEG:
703       if (mode == DFmode)
704         *total = 9;
705       else if (mode == SFmode)
706         *total = 6;
707       else if (mode == DImode)
708         *total = 4;
709       else
710         *total = 2;
711       break;
712
713     case NOT:
714       *total = 2;
715       break;
716
717     case ZERO_EXTRACT:
718     case SIGN_EXTRACT:
719       *total = 15;
720       break;
721
722     case MEM:
723       if (mode == DImode || mode == DFmode)
724         *total = 5;             /* 7 on VAX 2 */
725       else
726         *total = 3;             /* 4 on VAX 2 */
727       x = XEXP (x, 0);
728       if (GET_CODE (x) != REG && GET_CODE (x) != POST_INC)
729         *total += vax_address_cost_1 (x);
730       return true;
731
732     case FLOAT_EXTEND:
733     case FLOAT_TRUNCATE:
734     case TRUNCATE:
735       *total = 3;               /* FIXME: Costs need to be checked  */
736       break;
737
738     default:
739       return false;
740     }
741
742   /* Now look inside the expression.  Operands which are not registers or
743      short constants add to the cost.
744
745      FMT and I may have been adjusted in the switch above for instructions
746      which require special handling.  */
747
748   while (*fmt++ == 'e')
749     {
750       rtx op = XEXP (x, i);
751
752       i += 1;
753       code = GET_CODE (op);
754
755       /* A NOT is likely to be found as the first operand of an AND
756          (in which case the relevant cost is of the operand inside
757          the not) and not likely to be found anywhere else.  */
758       if (code == NOT)
759         op = XEXP (op, 0), code = GET_CODE (op);
760
761       switch (code)
762         {
763         case CONST_INT:
764           if ((unsigned HOST_WIDE_INT)INTVAL (op) > 63
765               && GET_MODE (x) != QImode)
766             *total += 1;        /* 2 on VAX 2 */
767           break;
768         case CONST:
769         case LABEL_REF:
770         case SYMBOL_REF:
771           *total += 1;          /* 2 on VAX 2 */
772           break;
773         case CONST_DOUBLE:
774           if (GET_MODE_CLASS (GET_MODE (op)) == MODE_FLOAT)
775             {
776               /* Registers are faster than floating point constants -- even
777                  those constants which can be encoded in a single byte.  */
778               if (vax_float_literal (op))
779                 *total += 1;
780               else
781                 *total += (GET_MODE (x) == DFmode) ? 3 : 2;
782             }
783           else
784             {
785               if (CONST_DOUBLE_HIGH (op) != 0
786                   || (unsigned)CONST_DOUBLE_LOW (op) > 63)
787                 *total += 2;
788             }
789           break;
790         case MEM:
791           *total += 1;          /* 2 on VAX 2 */
792           if (GET_CODE (XEXP (op, 0)) != REG)
793             *total += vax_address_cost_1 (XEXP (op, 0));
794           break;
795         case REG:
796         case SUBREG:
797           break;
798         default:
799           *total += 1;
800           break;
801         }
802     }
803   return true;
804 }
805 \f
806 /* Output code to add DELTA to the first argument, and then jump to FUNCTION.
807    Used for C++ multiple inheritance.
808         .mask   ^m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>  #conservative entry mask
809         addl2   $DELTA, 4(ap)   #adjust first argument
810         jmp     FUNCTION+2      #jump beyond FUNCTION's entry mask
811 */
812
813 static void
814 vax_output_mi_thunk (FILE * file,
815                      tree thunk ATTRIBUTE_UNUSED, 
816                      HOST_WIDE_INT delta,
817                      HOST_WIDE_INT vcall_offset ATTRIBUTE_UNUSED,
818                      tree function)
819 {
820   fprintf (file, "\t.word 0x0ffc\n\taddl2 $" HOST_WIDE_INT_PRINT_DEC, delta);
821   asm_fprintf (file, ",4(%Rap)\n");
822   fprintf (file, "\tjmp ");                                             
823   assemble_name (file,  XSTR (XEXP (DECL_RTL (function), 0), 0));       
824   fprintf (file, "+2\n");                                               
825 }
826 \f
827 static rtx
828 vax_struct_value_rtx (tree fntype ATTRIBUTE_UNUSED,
829                       int incoming ATTRIBUTE_UNUSED)
830 {
831   return gen_rtx_REG (Pmode, VAX_STRUCT_VALUE_REGNUM);
832 }
833
834 /* Worker function for NOTICE_UPDATE_CC.  */
835
836 void
837 vax_notice_update_cc (rtx exp, rtx insn ATTRIBUTE_UNUSED)
838 {
839   if (GET_CODE (exp) == SET)
840     {
841       if (GET_CODE (SET_SRC (exp)) == CALL)
842         CC_STATUS_INIT;
843       else if (GET_CODE (SET_DEST (exp)) != ZERO_EXTRACT
844                && GET_CODE (SET_DEST (exp)) != PC)
845         {
846           cc_status.flags = 0;
847           /* The integer operations below don't set carry or
848              set it in an incompatible way.  That's ok though
849              as the Z bit is all we need when doing unsigned
850              comparisons on the result of these insns (since
851              they're always with 0).  Set CC_NO_OVERFLOW to
852              generate the correct unsigned branches.  */
853           switch (GET_CODE (SET_SRC (exp)))
854             {
855             case NEG:
856               if (GET_MODE_CLASS (GET_MODE (exp)) == MODE_FLOAT)
857                 break;
858             case AND:
859             case IOR:
860             case XOR:
861             case NOT:
862             case MEM:
863             case REG:
864               cc_status.flags = CC_NO_OVERFLOW;
865               break;
866             default:
867               break;
868             }
869           cc_status.value1 = SET_DEST (exp);
870           cc_status.value2 = SET_SRC (exp);
871         }
872     }
873   else if (GET_CODE (exp) == PARALLEL
874            && GET_CODE (XVECEXP (exp, 0, 0)) == SET)
875     {
876       if (GET_CODE (SET_SRC (XVECEXP (exp, 0, 0))) == CALL)
877         CC_STATUS_INIT;
878       else if (GET_CODE (SET_DEST (XVECEXP (exp, 0, 0))) != PC)
879         {
880           cc_status.flags = 0;
881           cc_status.value1 = SET_DEST (XVECEXP (exp, 0, 0));
882           cc_status.value2 = SET_SRC (XVECEXP (exp, 0, 0));
883         }
884       else
885         /* PARALLELs whose first element sets the PC are aob,
886            sob insns.  They do change the cc's.  */
887         CC_STATUS_INIT;
888     }
889   else
890     CC_STATUS_INIT;
891   if (cc_status.value1 && GET_CODE (cc_status.value1) == REG
892       && cc_status.value2
893       && reg_overlap_mentioned_p (cc_status.value1, cc_status.value2))
894     cc_status.value2 = 0;
895   if (cc_status.value1 && GET_CODE (cc_status.value1) == MEM
896       && cc_status.value2
897       && GET_CODE (cc_status.value2) == MEM)
898     cc_status.value2 = 0;
899   /* Actual condition, one line up, should be that value2's address
900      depends on value1, but that is too much of a pain.  */
901 }