Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / gcc / config / i386 / dgux.c
1 /* Subroutines for GNU compiler for Intel 80x86 running DG/ux
2    Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
3    Currently maintained by (gcc@dg-rtp.dg.com)
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 #include <time.h>
23 #include "i386/i386.c"
24
25
26 extern char *version_string;
27
28 struct option
29 {
30   char *string;
31   int *variable;
32   int on_value;
33   char *description;
34 };
35
36 static int
37 output_option (file, sep, type, name, indent, pos, max)
38      FILE *file;
39      char *sep;
40      char *type;
41      char *name;
42      char *indent;
43      int pos;
44      int max;
45 {
46   if (strlen (sep) + strlen (type) + strlen (name) + pos > max)
47     {
48       fprintf (file, indent);
49       return fprintf (file, "%s%s", type, name);
50     }
51   return pos + fprintf (file, "%s%s%s", sep, type, name);
52 }
53
54 static struct { char *name; int value; } m_options[] = TARGET_SWITCHES;
55
56 static void
57 output_options (file, f_options, f_len, W_options, W_len,
58                 pos, max, sep, indent, term)
59      FILE *file;
60      struct option *f_options;
61      struct option *W_options;
62      int f_len, W_len;
63      int pos;
64      int max;
65      char *indent;
66      char *term;
67 {
68   register int j;
69
70   if (optimize)
71     pos = output_option (file, sep, "-O", "", indent, pos, max);
72   if (write_symbols != NO_DEBUG)
73     pos = output_option (file, sep, "-g", "", indent, pos, max);
74 /*  if (flag_traditional)
75     pos = output_option (file, sep, "-traditional", "", indent, pos, max);*/
76   if (profile_flag)
77     pos = output_option (file, sep, "-p", "", indent, pos, max);
78   if (profile_block_flag)
79     pos = output_option (file, sep, "-a", "", indent, pos, max);
80
81   for (j = 0; j < f_len; j++)
82     if (*f_options[j].variable == f_options[j].on_value)
83       pos = output_option (file, sep, "-f", f_options[j].string,
84                            indent, pos, max);
85
86   for (j = 0; j < W_len; j++)
87     if (*W_options[j].variable == W_options[j].on_value)
88       pos = output_option (file, sep, "-W", W_options[j].string,
89                            indent, pos, max);
90
91   for (j = 0; j < sizeof m_options / sizeof m_options[0]; j++)
92     if (m_options[j].name[0] != '\0'
93         && m_options[j].value > 0
94         && ((m_options[j].value & target_flags)
95             == m_options[j].value))
96       pos = output_option (file, sep, "-m", m_options[j].name,
97                            indent, pos, max);
98
99   pos = output_option (file, sep, "-mcpu=", ix86_cpu_string, indent, pos, max);
100   pos = output_option (file, sep, "-march=", ix86_arch_string, indent, pos, max);
101   fprintf (file, term);
102 }
103
104 /* Output to FILE the start of the assembler file.  */
105
106 void
107 output_file_start (file, f_options, f_len, W_options, W_len)
108      FILE *file;
109      struct option *f_options;
110      struct option *W_options;
111      int f_len, W_len;
112 {
113   register int pos;
114
115   output_file_directive (file, main_input_filename);
116   fprintf (file, "\t.version\t\"01.01\"\n");                    \
117   /* Switch to the data section so that the coffsem symbol and the
118      gcc2_compiled. symbol aren't in the text section.  */
119   data_section ();
120
121   pos = fprintf (file, "\n// cc1 (%s) arguments:", VERSION_STRING);
122   output_options (file, f_options, f_len, W_options, W_len,
123                   pos, 75, " ", "\n// ", "\n\n");
124
125 #ifdef TARGET_IDENTIFY_REVISION
126   if (TARGET_IDENTIFY_REVISION)
127     {
128       char indent[256];
129
130       time_t now = time ((time_t *)0);
131       sprintf (indent, "]\"\n\t%s\t \"@(#)%s [", IDENT_ASM_OP, main_input_filename);
132       fprintf (file, indent+3);
133       pos = fprintf (file, "gcc %s, %.24s,", VERSION_STRING, ctime (&now));
134       output_options (file, f_options, f_len, W_options, W_len,
135                       pos, 150 - strlen (indent), " ", indent, "]\"\n\n");
136     }
137 #endif /* TARGET_IDENTIFY_REVISION */
138 }
139
140 #ifndef CROSS_COMPILE
141 #if defined (_abort_aux) 
142 /* Debugging aid to be registered via `atexit'.  See the definition
143    of abort in dgux.h.  */
144 void
145 abort_aux ()
146 {
147   extern int insn_;
148   extern char * file_;
149   extern int line_;
150   static int done;
151   rtx line_note;
152
153   if (done++)
154     return;
155   if (file_ || line_)
156     {
157       if (write_symbols != NO_DEBUG)
158         {
159           for (line_note = (rtx) insn_ ; line_note != 0 ; line_note = PREV_INSN (line_note))
160             if (GET_CODE (line_note) == NOTE && NOTE_LINE_NUMBER (line_note) > 0)
161               break;
162           if (line_note != 0)
163             {
164               error_with_file_and_line (NOTE_SOURCE_FILE (line_note),
165                                         NOTE_LINE_NUMBER (line_note),
166                                         "Internal gcc abort from %s:%d",
167                                         file_ ? file_ : "<nofile>", line_);
168               if (insn_ && file_ && strcmp (file_, "toplev.c"))
169                 {
170                   error_with_file_and_line (NOTE_SOURCE_FILE (line_note),
171                                             NOTE_LINE_NUMBER (line_note),
172                                             "The local variable `insn' has the value:", 0);
173                   debug_rtx ((rtx) insn_);
174                 }
175             }
176         }
177       if (write_symbols == NO_DEBUG || line_note == 0)
178         {
179           error ("Internal gcc abort from %s:%d",
180                  file_ ? file_ : "<nofile>", line_);
181           if (insn_ && file_ && strcmp (file_, "toplev.c"))
182             {
183               error ("The local variable `insn' has the value:", 0);
184               debug_rtx ((rtx) insn_);
185             }
186         }
187     }
188 }
189 #endif
190 #endif
191
192