02fdede601e6758ce4f0f51690012dee7d69bda4
[gcc.git] / gcc / config / ia64 / sysv4.h
1 /* Override definitions in elfos.h/svr4.h to be correct for IA64. */
2
3 /* We want DWARF2 as specified by the IA64 ABI. */
4 #undef PREFERRED_DEBUGGING_TYPE
5 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
6
7 /* Various pseudo-ops for which the Intel assembler uses non-standard
8 definitions. */
9
10 #undef ASM_BYTE_OP
11 #define ASM_BYTE_OP "data1"
12
13 #undef STRING_ASM_OP
14 #define STRING_ASM_OP "stringz"
15
16 #undef SKIP_ASM_OP
17 #define SKIP_ASM_OP ".skip"
18
19 #undef COMMON_ASM_OP
20 #define COMMON_ASM_OP ".common"
21
22 #undef ASCII_DATA_ASM_OP
23 #define ASCII_DATA_ASM_OP "string"
24
25 /* ??? Unfortunately, .lcomm doesn't work, because it puts things in either
26 .bss or .sbss, and we can't control the decision of which is used. When
27 I use .lcomm, I get a cryptic "Section group has no member" error from
28 the Intel simulator. So we must explicitly put variables in .bss
29 instead. This matters only if we care about the Intel assembler. */
30
31 /* This is asm_output_aligned_bss from varasm.c without the ASM_GLOBALIZE_LABEL
32 call at the beginning. */
33
34 /* This is for final.c, because it is used by ASM_DECLARE_OBJECT_NAME. */
35 extern int size_directive_output;
36
37 #undef ASM_OUTPUT_ALIGNED_LOCAL
38 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
39 do { \
40 if ((DECL) \
41 && XSTR (XEXP (DECL_RTL (DECL), 0), 0)[0] == SDATA_NAME_FLAG_CHAR) \
42 sbss_section (); \
43 else \
44 bss_section (); \
45 ASM_OUTPUT_ALIGN (FILE, floor_log2 ((ALIGN) / BITS_PER_UNIT)); \
46 ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL); \
47 ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1); \
48 } while (0)
49
50 /* ??? Intel assembler does not allow "." in section names, so turn off
51 gnu.linkonce section support, but only when using the Intel assembler. */
52 #undef UNIQUE_SECTION_P
53 #define UNIQUE_SECTION_P(DECL) (TARGET_GNU_AS ? DECL_ONE_ONLY (DECL) : 0)
54
55 /* The # tells the Intel assembler that this is not a register name.
56 However, we can't emit the # in a label definition, so we set a variable
57 in ASM_OUTPUT_LABEL to control whether we want the postfix here or not. */
58
59 #undef ASM_OUTPUT_LABELREF
60 #define ASM_OUTPUT_LABELREF(STREAM, NAME) \
61 do \
62 { \
63 const char *real_name; \
64 STRIP_NAME_ENCODING (real_name, NAME); \
65 asm_fprintf (STREAM, "%U%s%s", real_name, \
66 (ia64_asm_output_label ? "" : "#")); \
67 } \
68 while (0)
69
70 /* Intel assembler requires both flags and type if declaring a non-predefined
71 section. */
72 #undef INIT_SECTION_ASM_OP
73 #define INIT_SECTION_ASM_OP ".section\t.init,\"ax\",\"progbits\""
74 #undef FINI_SECTION_ASM_OP
75 #define FINI_SECTION_ASM_OP ".section\t.fini,\"ax\",\"progbits\""
76 #undef CTORS_SECTION_ASM_OP
77 #define CTORS_SECTION_ASM_OP ".section\t.ctors,\"aw\",\"progbits\""
78 #undef DTORS_SECTION_ASM_OP
79 #define DTORS_SECTION_ASM_OP ".section\t.dtors,\"aw\",\"progbits\""
80
81 /* A C statement (sans semicolon) to output an element in the table of
82 global constructors. */
83 /* Must override this to get @fptr relocation. */
84 #undef ASM_OUTPUT_CONSTRUCTOR
85 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
86 do { \
87 ctors_section (); \
88 if (TARGET_NO_PIC || TARGET_AUTO_PIC) \
89 fputs ("\tdata8\t ", FILE); \
90 else \
91 fputs ("\tdata8\t @fptr(", FILE); \
92 assemble_name (FILE, NAME); \
93 if (TARGET_NO_PIC || TARGET_AUTO_PIC) \
94 fputs ("\n", FILE); \
95 else \
96 fputs (")\n", FILE); \
97 } while (0)
98
99 /* A C statement (sans semicolon) to output an element in the table of
100 global destructors. */
101 /* Must override this to get @fptr relocation. */
102 #undef ASM_OUTPUT_DESTRUCTOR
103 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
104 do { \
105 dtors_section (); \
106 if (TARGET_NO_PIC || TARGET_AUTO_PIC) \
107 fputs ("\tdata8\t ", FILE); \
108 else \
109 fputs ("\tdata8\t @fptr(", FILE); \
110 assemble_name (FILE, NAME); \
111 if (TARGET_NO_PIC || TARGET_AUTO_PIC) \
112 fputs ("\n", FILE); \
113 else \
114 fputs (")\n", FILE); \
115 } while (0)
116
117 /* svr4.h undefines this, so we need to define it here. */
118 #define DBX_REGISTER_NUMBER(REGNO) \
119 (IN_REGNO_P (REGNO) ? (32 + (REGNO) - IN_REG (0)) \
120 : LOC_REGNO_P (REGNO) ? (32 + ia64_input_regs + \
121 (REGNO) - LOC_REG (0)) \
122 : OUT_REGNO_P (REGNO) ? (32 + ia64_input_regs + ia64_local_regs \
123 + (REGNO) - OUT_REG (0)) \
124 : (REGNO) == FRAME_POINTER_REGNUM ? ia64_fp_regno \
125 : (REGNO))
126
127 /* Things that svr4.h defines to the wrong type, because it assumes 32 bit
128 ints and 32 bit longs. */
129
130 #undef SIZE_TYPE
131 #define SIZE_TYPE "long unsigned int"
132
133 #undef PTRDIFF_TYPE
134 #define PTRDIFF_TYPE "long int"
135
136 #undef WCHAR_TYPE
137 #define WCHAR_TYPE "int"
138
139 #undef WCHAR_TYPE_SIZE
140 #define WCHAR_TYPE_SIZE 32
141
142 /* We don't want any symbol at the beginning of the file. This is defined in
143 dbxelf.h which is included from elfos.h, so we need to undef/define it
144 here. */
145
146 #undef ASM_IDENTIFY_GCC
147 #define ASM_IDENTIFY_GCC(FILE)
148
149 /* We redefine this to use the ia64 .proc pseudo-op. */
150
151 #undef ASM_DECLARE_FUNCTION_NAME
152 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
153 do { \
154 fputs ("\t.proc ", FILE); \
155 assemble_name (FILE, NAME); \
156 fputc ('\n', FILE); \
157 ASM_OUTPUT_LABEL (FILE, NAME); \
158 } while (0)
159
160 /* We redefine this to use the ia64 .endp pseudo-op. */
161
162 #undef ASM_DECLARE_FUNCTION_SIZE
163 #define ASM_DECLARE_FUNCTION_SIZE(FILE, NAME, DECL) \
164 do { \
165 fputs ("\t.endp ", FILE); \
166 assemble_name (FILE, NAME); \
167 fputc ('\n', FILE); \
168 } while (0)
169
170 /* A C expression which outputs to the stdio stream STREAM some appropriate
171 text to go at the start of an assembler file. */
172
173 /* ??? Looks like almost every port, except for a few original ones, get this
174 wrong. Must emit #NO_APP as first line of file to turn of special assembler
175 preprocessing of files. */
176
177 /* ??? Even worse, it doesn't work, because gas does not accept the tab chars
178 that dwarf2out.c emits when #NO_APP. */
179
180 /* ??? Unrelated, but dwarf2out.c emits unnecessary newlines after strings,
181 may as well fix at the same time. */
182
183 #undef ASM_FILE_START
184 #define ASM_FILE_START(STREAM) \
185 do { \
186 output_file_directive (STREAM, main_input_filename); \
187 ia64_file_start(STREAM); \
188 } while (0)
189
190 /* Case label alignment is handled by ADDR_VEC_ALIGN now. */
191
192 #undef ASM_OUTPUT_BEFORE_CASE_LABEL
193 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE)
194
195 /* We override svr4.h so that we can support the sdata section. */
196
197 #undef SELECT_SECTION
198 #define SELECT_SECTION(DECL,RELOC) \
199 { \
200 if (TREE_CODE (DECL) == STRING_CST) \
201 { \
202 if (! flag_writable_strings) \
203 const_section (); \
204 else \
205 data_section (); \
206 } \
207 else if (TREE_CODE (DECL) == VAR_DECL) \
208 { \
209 if (XSTR (XEXP (DECL_RTL (DECL), 0), 0)[0] \
210 == SDATA_NAME_FLAG_CHAR) \
211 sdata_section (); \
212 /* ??? We need the extra ! RELOC check, because the default is to \
213 only check RELOC if flag_pic is set, and we don't set flag_pic \
214 (yet?). */ \
215 else if (DECL_READONLY_SECTION (DECL, RELOC) && ! (RELOC)) \
216 const_section (); \
217 else \
218 data_section (); \
219 } \
220 /* This could be a CONSTRUCTOR containing ADDR_EXPR of a VAR_DECL, \
221 in which case we can't put it in a shared library rodata. */ \
222 else if (flag_pic && (RELOC)) \
223 data_section (); \
224 else \
225 const_section (); \
226 }
227
228 /* Similarly for constant pool data. */
229
230 extern unsigned int ia64_section_threshold;
231 #undef SELECT_RTX_SECTION
232 #define SELECT_RTX_SECTION(MODE, RTX) \
233 { \
234 if (GET_MODE_SIZE (MODE) > 0 \
235 && GET_MODE_SIZE (MODE) <= ia64_section_threshold) \
236 sdata_section (); \
237 else if (flag_pic && symbolic_operand ((RTX), (MODE))) \
238 data_section (); \
239 else \
240 const_section (); \
241 }
242
243 #undef EXTRA_SECTIONS
244 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_sdata, in_sbss
245
246 #undef EXTRA_SECTION_FUNCTIONS
247 #define EXTRA_SECTION_FUNCTIONS \
248 CONST_SECTION_FUNCTION \
249 CTORS_SECTION_FUNCTION \
250 DTORS_SECTION_FUNCTION \
251 SDATA_SECTION_FUNCTION \
252 SBSS_SECTION_FUNCTION
253
254 #define SDATA_SECTION_ASM_OP ".sdata"
255
256 #define SDATA_SECTION_FUNCTION \
257 void \
258 sdata_section () \
259 { \
260 if (in_section != in_sdata) \
261 { \
262 fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP); \
263 in_section = in_sdata; \
264 } \
265 }
266
267 #define SBSS_SECTION_ASM_OP ".sbss"
268
269 #define SBSS_SECTION_FUNCTION \
270 void \
271 sbss_section () \
272 { \
273 if (in_section != in_sbss) \
274 { \
275 fprintf (asm_out_file, "%s\n", SBSS_SECTION_ASM_OP); \
276 in_section = in_sbss; \
277 } \
278 }