eca6b79ce2e1aeda7a4abd22fb8edbcf53f65271
[platform/upstream/gcc.git] / gcc / config / i860 / sysv4.h
1 /* Target definitions for GNU compiler for Intel 80860 running System V.4
2    Copyright (C) 1991, 1996 Free Software Foundation, Inc.
3    Contributed by Ron Guilmette (rfg@monkeys.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 #undef TARGET_VERSION
23 #define TARGET_VERSION fprintf (stderr, " (i860 System V Release 4)");
24
25 /* Provide a set of pre-definitions and pre-assertions appropriate for
26    the i860 running svr4.  Note that the symbol `__svr4__' MUST BE
27    DEFINED!  It is needed so that the va_list struct in va-i860.h
28    will get correctly defined for the svr4 (ABI compliant) case rather
29    than for the previous (svr3, svr2, ...) case.  It also needs to be
30    defined so that the correct (svr4) version of __builtin_saveregs
31    will be selected when we are building gnulib2.c.
32    __svr4__ is our extension.  */
33
34 #define CPP_PREDEFINES \
35   "-Di860 -Dunix -DSVR4 -D__svr4__ -Asystem(unix) -Asystem(svr4) -Acpu(i860) -Amachine(i860)"
36
37 /* The prefix to be used in assembler output for all names of registers.
38    This string gets prepended to all i860 register names (svr4 only).  */
39
40 #define I860_REG_PREFIX "%"
41
42 #define ASM_COMMENT_START "#"
43
44 #undef TYPE_OPERAND_FMT
45 #define TYPE_OPERAND_FMT      "\"%s\""
46
47 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
48
49 /* The following macro definition overrides the one in i860.h
50    because the svr4 i860 assembler requires a different syntax
51    for getting parts of constant/relocatable values.  */
52
53 #undef PRINT_OPERAND_PART
54 #define PRINT_OPERAND_PART(FILE, X, PART_CODE)                          \
55   do { fprintf (FILE, "[");                                             \
56         output_address (X);                                             \
57         fprintf (FILE, "]@%s", PART_CODE);                              \
58   } while (0)
59
60 /* If the host and target formats match, output the floats as hex.  */
61 #if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
62 #if defined (HOST_WORDS_BIG_ENDIAN) == WORDS_BIG_ENDIAN
63
64 /* This is how to output an assembler line defining a `double' constant.
65    Note that the native i860/svr4 ELF assembler can't properly handle
66    infinity.  It generates an incorrect (non-infinity) value when given
67    `.double 99e9999' and it doesn't grok `inf' at all.  It also mishandles
68    NaNs and -0.0.  */
69
70 #undef ASM_OUTPUT_DOUBLE
71 #define ASM_OUTPUT_DOUBLE(FILE,VALUE)                                   \
72   {                                                                     \
73     if (REAL_VALUE_ISINF (VALUE)                                        \
74         || REAL_VALUE_ISNAN (VALUE)                                     \
75         || REAL_VALUE_MINUS_ZERO (VALUE))                               \
76       {                                                                 \
77         long t[2];                                                      \
78         REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), t);                       \
79         fprintf (FILE, "\t.word 0x%lx\n\t.word 0x%lx\n", t[0], t[1]);   \
80       }                                                                 \
81     else                                                                \
82       fprintf (FILE, "\t.double %.20e\n", VALUE);                       \
83   }
84
85 /* This is how to output an assembler line defining a `float' constant.
86    Note that the native i860/svr4 ELF assembler can't properly handle
87    infinity.  It actually generates an assembly time error when given
88    `.float 99e9999' and it doesn't grok `inf' at all.  It also mishandles
89    NaNs and -0.0.  */
90
91 #undef ASM_OUTPUT_FLOAT
92 #define ASM_OUTPUT_FLOAT(FILE,VALUE)                                    \
93   {                                                                     \
94     if (REAL_VALUE_ISINF (VALUE)                                        \
95         || REAL_VALUE_ISNAN (VALUE)                                     \
96         || REAL_VALUE_MINUS_ZERO (VALUE))                               \
97       {                                                                 \
98         long t;                                                         \
99         REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t);                       \
100         fprintf (FILE, "\t.word 0x%lx\n", t);                           \
101       }                                                                 \
102     else                                                                \
103       fprintf (FILE, "\t.float %.12e\n", VALUE);                        \
104   }
105
106 #endif /* word order matches */
107 #endif /* HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT */
108
109 #undef ASM_FILE_START
110 #define ASM_FILE_START(FILE)                                            \
111   do {  output_file_directive (FILE, main_input_filename);              \
112         fprintf (FILE, "\t.version\t\"01.01\"\n");                      \
113   } while (0)
114
115 /* Output the special word the svr4 SDB wants to see just before
116    the first word of each function's prologue code.  */
117
118 extern char *current_function_original_name;
119
120 /* This special macro is used to output a magic word just before the
121    first word of each function.  On some versions of UNIX running on
122    the i860, this word can be any word that looks like a NOP, however
123    under svr4, this neds to be an `shr r0,r0,r0' instruction in which
124    the normally unused low-order bits contain the length of the function
125    prologue code (in bytes).  This is needed to make the svr4 SDB debugger
126    happy.  */
127
128 #undef ASM_OUTPUT_FUNCTION_PREFIX
129 #define ASM_OUTPUT_FUNCTION_PREFIX(FILE, FNNAME)                        \
130   do {  ASM_OUTPUT_ALIGN (FILE, 2);                                     \
131         fprintf ((FILE), "\t.long\t.ep.");                              \
132         assemble_name (FILE, FNNAME);                                   \
133         fprintf (FILE, "-");                                            \
134         assemble_name (FILE, FNNAME);                                   \
135         fprintf (FILE, "+0xc8000000\n");                                \
136         current_function_original_name = (FNNAME);                      \
137   } while (0)
138
139 /* Output the special label that must go just after each function's
140    prologue code to support svr4 SDB.  */
141
142 #define ASM_OUTPUT_PROLOGUE_SUFFIX(FILE)                                \
143   do {  fprintf (FILE, ".ep.");                                         \
144         assemble_name (FILE, current_function_original_name);           \
145         fprintf (FILE, ":\n");                                          \
146   } while (0)
147
148 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
149  
150    Note that we want to give these sections the SHF_WRITE attribute
151    because these sections will actually contain data (i.e. tables of
152    addresses of functions in the current root executable or shared library
153    file) and, in the case of a shared library, the relocatable addresses
154    will have to be properly resolved/relocated (and then written into) by
155    the dynamic linker when it actually attaches the given shared library
156    to the executing process.  (Note that on SVR4, you may wish to use the
157    `-z text' option to the ELF linker, when building a shared library, as
158    an additional check that you are doing everything right.  But if you do
159    use the `-z text' option when building a shared library, you will get
160    errors unless the .ctors and .dtors sections are marked as writable
161    via the SHF_WRITE attribute.)  */
162  
163 #undef CTORS_SECTION_ASM_OP
164 #define CTORS_SECTION_ASM_OP    ".section\t.ctors,\"aw\""
165 #undef DTORS_SECTION_ASM_OP
166 #define DTORS_SECTION_ASM_OP    ".section\t.dtors,\"aw\""
167
168 /* Add definitions to support the .tdesc section as specified in the svr4
169    ABI for the i860.  */
170
171 #define TDESC_SECTION_ASM_OP    ".section\t.tdesc"
172
173 #undef EXTRA_SECTIONS
174 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_tdesc
175
176 #undef EXTRA_SECTION_FUNCTIONS
177 #define EXTRA_SECTION_FUNCTIONS                                         \
178   CONST_SECTION_FUNCTION                                                \
179   CTORS_SECTION_FUNCTION                                                \
180   DTORS_SECTION_FUNCTION                                                \
181   TDESC_SECTION_FUNCTION
182
183 #define TDESC_SECTION_FUNCTION                                          \
184 void                                                                    \
185 tdesc_section ()                                                        \
186 {                                                                       \
187   if (in_section != in_tdesc)                                           \
188     {                                                                   \
189       fprintf (asm_out_file, "%s\n", TDESC_SECTION_ASM_OP);             \
190       in_section = in_tdesc;                                            \
191     }                                                                   \
192 }
193