* Removed sy_forward and replaced it with an undefined expression
[binutils-gdb.git] / gas / config / tc-hppa.h
1 /* tc-hppa.h -- Header file for the PA */
2
3 /* Copyright (C) 1989 Free Software Foundation, Inc.
4
5 This file is part of GAS, the GNU Assembler.
6
7 GAS 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 1, or (at your option)
10 any later version.
11
12 GAS 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 GAS; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21
22 /*
23 HP PA-RISC support was contributed by the Center for Software Science
24 at the University of Utah.
25 */
26
27 #ifndef _TC_HPPA_H
28 #define _TC_HPPA_H
29
30 #ifndef TC_HPPA
31 #define TC_HPPA 1
32 #endif
33
34 #define TARGET_ARCH bfd_arch_hppa
35 #define TARGET_FORMAT "elf32-hppa"
36
37 #define ASEC_NULL (asection *)0
38
39 /* We can do sym1 - sym2 as long as sym2 is $global$ */
40
41 #define SEG_DIFF_ALLOWED
42
43 typedef enum FPOF
44 {
45 SGL, DBL, ILLEGAL_FMT, QUAD
46 } FP_Operand_Format;
47
48 extern char *expr_end;
49
50 extern void s_globl (), s_long (), s_short (), s_space (), cons ();
51 extern void stringer ();
52 extern unsigned int next_char_of_string ();
53
54 extern void pa_big_cons ();
55 extern void pa_cons ();
56 extern void pa_data ();
57 extern void pa_desc ();
58 extern void pa_float_cons ();
59 extern void pa_fill ();
60 extern void pa_lcomm ();
61 extern void pa_lsym ();
62 extern void pa_stringer ();
63 extern void pa_text ();
64 extern void pa_version ();
65
66 int pa_parse_number ();
67
68 int pa_parse_fp_cmp_cond ();
69
70 FP_Operand_Format pa_parse_fp_format ();
71
72 #ifdef __STDC__
73 int getExpression (char *str);
74 #else
75 int getExpression ();
76 #endif
77
78 int getAbsoluteExpression ();
79
80 int evaluateAbsolute ();
81
82 int pa_build_arg_reloc ();
83
84 unsigned int pa_align_arg_reloc ();
85
86 void pa_skip ();
87
88 int pa_parse_nullif ();
89
90 int pa_parse_nonneg_cmpsub_cmpltr ();
91
92 int pa_parse_neg_cmpsub_cmpltr ();
93
94 int pa_parse_nonneg_add_cmpltr ();
95
96 int pa_parse_neg_add_cmpltr ();
97
98 int pa_build_arg_reloc ();
99
100 void s_seg (), s_proc (), s_data1 ();
101
102 void pa_block (), pa_call (), pa_call_args (), pa_callinfo ();
103 void pa_code (), pa_comm (), pa_copyright (), pa_end ();
104 void pa_enter ();
105 void pa_entry (), pa_equ (), pa_exit (), pa_export ();
106 void pa_export_args (), pa_import (), pa_label (), pa_leave ();
107 void pa_origin (), pa_proc (), pa_procend (), pa_space ();
108 void pa_spnum (), pa_subspace (), pa_version ();
109
110 extern const pseudo_typeS md_pseudo_table[];
111
112 /*
113 PA-89 floating point registers are arranged like this:
114
115
116 +--------------+--------------+
117 | 0 or 16L | 16 or 16R |
118 +--------------+--------------+
119 | 1 or 17L | 17 or 17R |
120 +--------------+--------------+
121 | | |
122
123 . . .
124 . . .
125 . . .
126
127 | | |
128 +--------------+--------------+
129 | 14 or 30L | 30 or 30R |
130 +--------------+--------------+
131 | 15 or 31L | 31 or 31R |
132 +--------------+--------------+
133
134
135 The following is a version of pa_parse_number that
136 handles the L/R notation and returns the correct
137 value to put into the instruction register field.
138 The correct value to put into the instruction is
139 encoded in the structure 'pa_89_fp_reg_struct'.
140
141 */
142
143 struct pa_89_fp_reg_struct
144 {
145 char number_part;
146 char L_R_select;
147 };
148
149 int need_89_opcode ();
150 int pa_89_parse_number ();
151
152
153 /* pa-ctrl-func.h -- Control Structures and Functions for the PA */
154
155 extern unsigned int assemble_3 ( /* unsigned int x; */ );
156
157 extern void dis_assemble_3 ( /* unsigned int x, *r; */ );
158
159 extern unsigned int assemble_12 ( /* unsigned int x,y; */ );
160
161 extern void dis_assemble_12 ( /* unsigned int as12, *x,*y */ );
162
163 extern unsigned long assemble_17 ( /* unsigned int x,y,z */ );
164
165 extern void dis_assemble_17 ( /* unsigned int as17, *x,*y,*z */ );
166
167 extern unsigned long assemble_21 ( /* unsigned int x; */ );
168
169 extern void dis_assemble_21 ( /* unsigned int as21,*x; */ );
170
171 extern void sign_unext ( /* unsigned int x,len; unsigned int *result */ );
172
173 extern void low_sign_unext ( /* unsigned int x,len; unsigned int *result */ );
174
175 struct call_desc
176 {
177 unsigned int arg_reloc;
178 unsigned int arg_count;
179 };
180
181 typedef struct call_desc call_descS;
182
183 extern call_descS last_call_desc;
184
185 /* GDB debug support */
186
187 #if defined(OBJ_SOME)
188 #define GDB_DEBUG_SPACE_NAME "$GDB_DEBUG$"
189 #define GDB_STRINGS_SUBSPACE_NAME "$GDB_STRINGS$"
190 #define GDB_SYMBOLS_SUBSPACE_NAME "$GDB_SYMBOLS$"
191 #else
192 #define GDB_DEBUG_SPACE_NAME ".stab"
193 #define GDB_STRINGS_SUBSPACE_NAME ".stabstr"
194 #define GDB_SYMBOLS_SUBSPACE_NAME ".stab"
195 #endif
196 /* pre-defined subsegments (subspaces) for the HP 9000 Series 800 */
197
198 #define SUBSEG_CODE 0
199 #define SUBSEG_DATA 0
200 #define SUBSEG_LIT 1
201 #define SUBSEG_BSS 2
202 #define SUBSEG_UNWIND 3
203 #define SUBSEG_GDB_STRINGS 0
204 #define SUBSEG_GDB_SYMBOLS 1
205
206 #define UNWIND_SECTION_NAME ".hppa_unwind"
207 /* subspace dictionary chain entry structure */
208
209 struct subspace_dictionary_chain
210 {
211 #if defined(OBJ_OSFROSE) | defined(OBJ_ELF)
212 #ifdef OBJ_OSFROSE
213 region_command_t *ssd_entry;/* XXX: not sure this is what we need here */
214 #else
215 Elf_Internal_Shdr *ssd_entry;
216 unsigned long ssd_vm_addr;
217 #endif
218 char *ssd_name; /* used until time of writing object file */
219 /* then we use ssd_entry->regc_region_name */
220 unsigned char ssd_quadrant;
221 unsigned char ssd_sort_key;
222 unsigned char ssd_common;
223 unsigned char ssd_dup_common;
224 unsigned char ssd_loadable;
225 unsigned char ssd_code_only;
226 #else
227 subspace_dictS *ssd_entry; /* this dictionary */
228 #endif
229 int ssd_defined; /* this subspace has been used */
230 int ssd_space_number; /* space # this subspace is in */
231 asection *ssd_seg; /* this subspace = this seg */
232 int ssd_subseg; /* and subseg */
233 int ssd_zero;
234 int object_file_index; /* index of this entry within
235 the subspace dictionary of
236 the object file (not used until
237 the object file is written */
238 int ssd_last_align; /* the size of the last alignment
239 request for this subspace */
240 symbolS *ssd_start_sym; /* a symbol whose value is the
241 start of this subspace */
242 struct subspace_dictionary_chain *ssd_next; /* next subspace dict. entry */
243 };
244
245 typedef struct subspace_dictionary_chain subspace_dict_chainS;
246
247 /* space dictionary chain entry structure */
248
249 struct space_dictionary_chain
250 {
251 #ifdef OBJ_OSFROSE
252 region_command_t *sd_entry; /* XXX: not sure this is what we need here */
253 char *sd_name; /* used until time of writing object file */
254 /* then we use sd_entry->regc_region_name */
255 unsigned int sd_loadable;
256 unsigned int sd_private;
257 unsigned int sd_spnum;
258 unsigned char sd_sort_key;
259 #else
260 #ifdef OBJ_ELF
261 Elf_Internal_Shdr *sd_entry;
262 char *sd_name; /* used until time of writing object file */
263 /* then we use sd_entry->sh_name */
264 unsigned int sd_loadable;
265 unsigned int sd_private;
266 unsigned int sd_spnum;
267 unsigned char sd_sort_key;
268 #else
269 space_dictS *sd_entry; /* this dictionary */
270 #endif
271 #endif
272 int sd_defined; /* this space has been used */
273 asection *sd_seg; /* GAS segment to which this space corresponds */
274 int sd_last_subseg; /* current subsegment number we are using */
275 subspace_dict_chainS *sd_subspaces; /* all subspaces in this space */
276 struct space_dictionary_chain *sd_next; /* the next space dict. entry */
277 };
278
279 typedef struct space_dictionary_chain space_dict_chainS;
280
281 /*
282 Macros to maintain spaces and subspaces
283 */
284
285 #ifdef OBJ_OSFROSE
286 #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined
287 #define SPACE_PRIVATE(space_chain) (space_chain)->sd_private
288 #define SPACE_LOADABLE(space_chain) (space_chain)->sd_loadable
289 #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum
290 #define SPACE_SORT(space_chain) (space_chain)->sd_sort_key
291 #define SPACE_NAME(space_chain) (space_chain)->sd_name
292
293 #define SUBSPACE_QUADRANT(ss_chain) (ss_chain)->ssd_quadrant
294 #define SUBSPACE_ALIGN(ss_chain) (ss_chain)->ssd_entry->regc_addralign
295 #define SUBSPACE_ACCESS(ss_chain) (ss_chain)->ssd_entry->regc_initprot
296 #define SUBSPACE_SORT(ss_chain) (ss_chain)->ssd_sort_key
297 #define SUBSPACE_COMMON(ss_chain) (ss_chain)->ssd_common
298 #define SUBSPACE_ZERO(ss_chain) (ss_chain)->ssd_zero
299 #define SUBSPACE_DUP_COMM(ss_chain) (ss_chain)->ssd_dup_common
300 #define SUBSPACE_CODE_ONLY(ssch) ((ssch)->ssd_entry->regc_flags & REG_TEXT_T)
301 #define SET_SUBSPACE_CODE_ONLY(ssch,val) (ssch)->ssd_entry->regc_flags |= ((val) ? REG_TEXT_T : 0)
302 #define SUBSPACE_LOADABLE(ss_chain) (ss_chain)->ssd_loadable
303 #define SUBSPACE_SUBSPACE_START(ss_chain) (ss_chain)->ssd_entry->regc_addr.vm_addr
304 #define SUBSPACE_SUBSPACE_LENGTH(ss_chain) (ss_chain)->ssd_entry->regc_vm_size
305 #define SUBSPACE_REGION_NAME(ss_chain) (ss_chain)->ssd_entry->regc_region_name
306 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name
307 #endif
308
309 #ifdef OBJ_ELF
310 #define RELOC_EXPANSION_POSSIBLE
311 #define MAX_RELOC_EXPANSION 5
312
313 #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined
314 #define SPACE_PRIVATE(space_chain) (space_chain)->sd_private
315 #define SPACE_LOADABLE(space_chain) (space_chain)->sd_loadable
316 #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum
317 #define SPACE_SORT(space_chain) (space_chain)->sd_sort_key
318 #define SPACE_NAME(space_chain) (space_chain)->sd_name
319
320 #define SUBSPACE_QUADRANT(ss_chain) (ss_chain)->ssd_quadrant
321 #define SUBSPACE_ALIGN(ss_chain) (ss_chain)->ssd_entry->sh_addralign
322 #define SUBSPACE_ACCESS(ss_chain) (ss_chain)->ssd_entry->sh_flags
323 #define SUBSPACE_SORT(ss_chain) (ss_chain)->ssd_sort_key
324 #define SUBSPACE_COMMON(ss_chain) (ss_chain)->ssd_common
325 #define SUBSPACE_ZERO(ss_chain) (ss_chain)->ssd_zero
326 #define SUBSPACE_DUP_COMM(ss_chain) (ss_chain)->ssd_dup_common
327 #define SUBSPACE_CODE_ONLY(ssch) \
328 (((ssch)->ssd_entry->sh_flags & (SHF_ALLOC | SHF_EXECINSTR | SHF_WRITE)) \
329 == (SHF_ALLOC | SHF_EXECINSTR))
330 #define SET_SUBSPACE_CODE_ONLY(ssch,val) \
331 (ssch)->ssd_entry->sh_flags &= ((val) ? ~SHF_WRITE : 0xffffffff)
332 #define SUBSPACE_LOADABLE(ss_chain) (ss_chain)->ssd_loadable
333 #define SUBSPACE_SUBSPACE_START(ss_chain) (ss_chain)->ssd_vm_addr
334 #define SUBSPACE_SUBSPACE_LENGTH(ss_chain) (ss_chain)->ssd_entry->sh_size
335 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name
336
337 #define STAB_FIXUP(frag,toptr,symP,stab_type) \
338 if ( (stab_type == 's' || stab_type == 'n') \
339 && symP->sy_value.X_seg == undefined_section) \
340 { \
341 int i = S_GET_TYPE(symP) & N_TYPE; \
342 fix_new_hppa(frag, \
343 toptr-frag->fr_literal, /* where */ \
344 4, /* size */ \
345 symP->sy_value.X_add_symbol, /* addr of sym for this stab */ \
346 (asymbol *)NULL, \
347 0, \
348 i == N_UNDF || i == N_ABS, /* 1 if internal reloc */ \
349 R_HPPA, /* type */ \
350 e_fsel, /* fixup fld = F% */ \
351 32, \
352 0, /* arg_reloc */ \
353 (char *)0 \
354 ); \
355 } \
356 else if ( stab_type == 'd' ) \
357 { \
358 fix_new_hppa (frag, \
359 toptr-frag->fr_literal, /* where */ \
360 4, /* size */ \
361 symP, /* addr of sym for this stab */ \
362 (asymbol *)NULL, \
363 0, \
364 0, \
365 R_HPPA, /* type */ \
366 e_fsel, /* fixup fld = F% */ \
367 32, \
368 0, /* arg_reloc */ \
369 (char *)0 \
370 ); \
371 }
372
373 #endif
374
375 #ifdef OBJ_SOM
376 #define SPACE_DEFINED(space_chain) (space_chain)->sd_entry->is_defined
377 #define SPACE_PRIVATE(space_chain) (space_chain)->sd_entry->is_private
378 #define SPACE_LOADABLE(space_chain) (space_chain)->sd_entry->is_loadable
379 #define SPACE_SPNUM(space_chain) (space_chain)->sd_entry->space_number
380 #define SPACE_SORT(space_chain) (space_chain)->sd_entry->sort_key
381 #define SPACE_NAME(space_chain) (space_chain)->sd_entry->name
382
383 #define SUBSPACE_QUADRANT(ss_chain) (ss_chain)->ssd_entry->quadrant
384 #define SUBSPACE_ALIGN(ss_chain) (ss_chain)->ssd_entry->alignment
385 #define SUBSPACE_ACCESS(ss_chain) (ss_chain)->ssd_entry->access_control_bits
386 #define SUBSPACE_SORT(ss_chain) (ss_chain)->ssd_entry->sort_key
387 #define SUBSPACE_COMMON(ss_chain) (ss_chain)->ssd_entry->is_common
388 #define SUBSPACE_ZERO(ss_chain) (ss_chain)->ssd_zero
389 #define SUBSPACE_DUP_COMM(ss_chain) (ss_chain)->ssd_entry->dup_common
390 #define SUBSPACE_CODE_ONLY(ss_chain) (ss_chain)->ssd_entry->code_only
391 #define SUBSPACE_LOADABLE(ss_chain) (ss_chain)->ssd_entry->is_loadable
392 #define SUBSPACE_SUBSPACE_START(ss_chain) (ss_chain)->ssd_entry->subspace_start
393 #define SUBSPACE_SUBSPACE_LENGTH(ss_chain) (ss_chain)->ssd_entry->subspace_length
394 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_entry->name
395 #endif
396
397 extern space_dict_chainS *space_dict_root;
398 extern space_dict_chainS *space_dict_last;
399
400 extern space_dict_chainS *current_space;
401 extern subspace_dict_chainS *current_subspace;
402
403 extern space_dict_chainS *create_new_space ();
404
405 extern subspace_dict_chainS *create_new_subspace ();
406
407 extern subspace_dict_chainS *update_subspace ();
408
409 extern space_dict_chainS *is_defined_space ();
410
411 extern space_dict_chainS *pa_segment_to_space ();
412
413 extern subspace_dict_chainS *is_defined_subspace ();
414
415 extern subspace_dict_chainS *pa_subsegment_to_subspace ();
416
417 extern space_dict_chainS *pa_find_space_by_number ();
418
419 extern unsigned int pa_subspace_start ();
420
421 extern int is_last_defined_subspace ();
422
423 /* symbol support */
424
425 extern symbolS *pa_get_start_symbol ();
426
427 extern symbolS *pa_set_start_symbol ();
428
429 /* default space and subspace dictionaries */
430
431 struct default_subspace_dict
432 {
433 char *name;
434 char defined;
435 char loadable, code_only, common, dup_common, zero, sort;
436 int access, space_index, alignment, quadrant;
437 #ifdef OBJ_SOM
438 segT segment;
439 #else
440 int def_space_index; /* this is an index in the default spaces array */
441 char *alias; /* an alias for this section (or NULL if there isn't one) */
442 #endif
443 subsegT subsegment;
444 };
445
446 extern struct default_subspace_dict pa_def_subspaces[];
447
448 struct default_space_dict
449 {
450 char *name;
451 int spnum;
452 char loadable;
453 char defined;
454 char private;
455 char sort;
456 #ifdef OBJ_SOM
457 segT segment;
458 #else
459 asection *segment;
460 char *alias; /* an alias for this section (or NULL if there isn't one) */
461 #endif
462 };
463
464 extern struct default_space_dict pa_def_spaces[];
465
466 /*
467 Support for keeping track of the most recent label in each
468 space.
469 */
470
471 typedef struct label_symbol_struct
472 {
473 symbolS *lss_label; /* the label symbol */
474 space_dict_chainS *lss_space; /* the space to which it applies*/
475 struct label_symbol_struct *lss_next; /* the next label symbol */
476 } label_symbolS;
477
478 extern label_symbolS *label_symbols_rootP;
479
480 label_symbolS *pa_get_label ();
481 int pa_label_is_defined ();
482 void pa_define_label ();
483 void pa_undefine_label ();
484 int pa_pseudo_op_moves_pc ();
485
486 /* end of label symbol support. */
487
488 #define is_DP_relative(exp) ( (exp).X_subtract_symbol \
489 && strcmp((exp).X_subtract_symbol->bsym->name, \
490 "$global$") == 0 )
491
492 #define is_PC_relative(exp) ( (exp).X_subtract_symbol \
493 && strcmp((exp).X_subtract_symbol->bsym->name, \
494 "$PIC_pcrel$0") == 0 )
495
496 #define is_complex(exp) ((exp).X_seg && (exp).X_seg == diff_section)
497
498 #define tc_crawl_symbol_chain(headers) {;} /* Not used. */
499
500 #define tc_headers_hook(headers) {;} /* Not used. */
501
502 #define elf_tc_symbol elf_hppa_tc_symbol
503 #define elf_tc_make_sections elf_hppa_tc_make_sections
504 extern void elf_hppa_final_processing ();
505 #define elf_tc_final_processing elf_hppa_final_processing
506
507 /* We need to parse field selectors in .byte, etc. */
508
509 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) \
510 parse_cons_expression_hppa (exp)
511 #define TC_CONS_FIX_NEW cons_fix_new_hppa
512
513 extern void parse_cons_expression_hppa PARAMS ((expressionS *exp));
514 extern void cons_fix_new_hppa PARAMS ((fragS *frag,
515 int where,
516 int size,
517 expressionS *exp));
518
519 #endif /* _TC_HPPA_H */