]>
Commit | Line | Data |
---|---|---|
800eeca4 | 1 | /* tc-ia64.c -- Assembler for the HP/Intel IA-64 architecture. |
b3dfd7fe | 2 | Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. |
800eeca4 JW |
3 | Contributed by David Mosberger-Tang <davidm@hpl.hp.com> |
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 2, 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, 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | /* | |
23 | TODO: | |
24 | ||
25 | - optional operands | |
26 | - directives: | |
800eeca4 JW |
27 | .eb |
28 | .estate | |
29 | .lb | |
30 | .popsection | |
31 | .previous | |
32 | .psr | |
33 | .pushsection | |
800eeca4 JW |
34 | - labels are wrong if automatic alignment is introduced |
35 | (e.g., checkout the second real10 definition in test-data.s) | |
36 | - DV-related stuff: | |
542d6675 KH |
37 | <reg>.safe_across_calls and any other DV-related directives I don't |
38 | have documentation for. | |
39 | verify mod-sched-brs reads/writes are checked/marked (and other | |
40 | notes) | |
800eeca4 JW |
41 | |
42 | */ | |
43 | ||
44 | #include "as.h" | |
3882b010 | 45 | #include "safe-ctype.h" |
800eeca4 JW |
46 | #include "dwarf2dbg.h" |
47 | #include "subsegs.h" | |
48 | ||
49 | #include "opcode/ia64.h" | |
50 | ||
51 | #include "elf/ia64.h" | |
52 | ||
53 | #define NELEMS(a) ((int) (sizeof (a)/sizeof ((a)[0]))) | |
54 | #define MIN(a,b) ((a) < (b) ? (a) : (b)) | |
55 | ||
56 | #define NUM_SLOTS 4 | |
57 | #define PREV_SLOT md.slot[(md.curr_slot + NUM_SLOTS - 1) % NUM_SLOTS] | |
58 | #define CURR_SLOT md.slot[md.curr_slot] | |
59 | ||
60 | #define O_pseudo_fixup (O_max + 1) | |
61 | ||
62 | enum special_section | |
63 | { | |
557debba | 64 | /* IA-64 ABI section pseudo-ops. */ |
800eeca4 JW |
65 | SPECIAL_SECTION_BSS = 0, |
66 | SPECIAL_SECTION_SBSS, | |
67 | SPECIAL_SECTION_SDATA, | |
68 | SPECIAL_SECTION_RODATA, | |
69 | SPECIAL_SECTION_COMMENT, | |
70 | SPECIAL_SECTION_UNWIND, | |
557debba JW |
71 | SPECIAL_SECTION_UNWIND_INFO, |
72 | /* HPUX specific section pseudo-ops. */ | |
73 | SPECIAL_SECTION_INIT_ARRAY, | |
74 | SPECIAL_SECTION_FINI_ARRAY, | |
800eeca4 JW |
75 | }; |
76 | ||
77 | enum reloc_func | |
78 | { | |
13ae64f3 JJ |
79 | FUNC_DTP_MODULE, |
80 | FUNC_DTP_RELATIVE, | |
800eeca4 JW |
81 | FUNC_FPTR_RELATIVE, |
82 | FUNC_GP_RELATIVE, | |
83 | FUNC_LT_RELATIVE, | |
fa2c7eff | 84 | FUNC_LT_RELATIVE_X, |
c67e42c9 | 85 | FUNC_PC_RELATIVE, |
800eeca4 JW |
86 | FUNC_PLT_RELATIVE, |
87 | FUNC_SEC_RELATIVE, | |
88 | FUNC_SEG_RELATIVE, | |
13ae64f3 | 89 | FUNC_TP_RELATIVE, |
800eeca4 JW |
90 | FUNC_LTV_RELATIVE, |
91 | FUNC_LT_FPTR_RELATIVE, | |
13ae64f3 JJ |
92 | FUNC_LT_DTP_MODULE, |
93 | FUNC_LT_DTP_RELATIVE, | |
94 | FUNC_LT_TP_RELATIVE, | |
3969b680 | 95 | FUNC_IPLT_RELOC, |
800eeca4 JW |
96 | }; |
97 | ||
98 | enum reg_symbol | |
99 | { | |
100 | REG_GR = 0, | |
101 | REG_FR = (REG_GR + 128), | |
102 | REG_AR = (REG_FR + 128), | |
103 | REG_CR = (REG_AR + 128), | |
104 | REG_P = (REG_CR + 128), | |
105 | REG_BR = (REG_P + 64), | |
106 | REG_IP = (REG_BR + 8), | |
107 | REG_CFM, | |
108 | REG_PR, | |
109 | REG_PR_ROT, | |
110 | REG_PSR, | |
111 | REG_PSR_L, | |
112 | REG_PSR_UM, | |
113 | /* The following are pseudo-registers for use by gas only. */ | |
114 | IND_CPUID, | |
115 | IND_DBR, | |
116 | IND_DTR, | |
117 | IND_ITR, | |
118 | IND_IBR, | |
119 | IND_MEM, | |
120 | IND_MSR, | |
121 | IND_PKR, | |
122 | IND_PMC, | |
123 | IND_PMD, | |
124 | IND_RR, | |
542d6675 | 125 | /* The following pseudo-registers are used for unwind directives only: */ |
e0c9811a JW |
126 | REG_PSP, |
127 | REG_PRIUNAT, | |
800eeca4 JW |
128 | REG_NUM |
129 | }; | |
130 | ||
131 | enum dynreg_type | |
132 | { | |
133 | DYNREG_GR = 0, /* dynamic general purpose register */ | |
134 | DYNREG_FR, /* dynamic floating point register */ | |
135 | DYNREG_PR, /* dynamic predicate register */ | |
136 | DYNREG_NUM_TYPES | |
137 | }; | |
138 | ||
87f8eb97 JW |
139 | enum operand_match_result |
140 | { | |
141 | OPERAND_MATCH, | |
142 | OPERAND_OUT_OF_RANGE, | |
143 | OPERAND_MISMATCH | |
144 | }; | |
145 | ||
800eeca4 JW |
146 | /* On the ia64, we can't know the address of a text label until the |
147 | instructions are packed into a bundle. To handle this, we keep | |
148 | track of the list of labels that appear in front of each | |
149 | instruction. */ | |
150 | struct label_fix | |
542d6675 KH |
151 | { |
152 | struct label_fix *next; | |
153 | struct symbol *sym; | |
154 | }; | |
800eeca4 JW |
155 | |
156 | extern int target_big_endian; | |
157 | ||
10a98291 L |
158 | void (*ia64_number_to_chars) PARAMS ((char *, valueT, int)); |
159 | ||
160 | static void ia64_float_to_chars_bigendian | |
161 | PARAMS ((char *, LITTLENUM_TYPE *, int)); | |
162 | static void ia64_float_to_chars_littleendian | |
163 | PARAMS ((char *, LITTLENUM_TYPE *, int)); | |
164 | static void (*ia64_float_to_chars) | |
165 | PARAMS ((char *, LITTLENUM_TYPE *, int)); | |
166 | ||
35f5df7f L |
167 | static struct hash_control *alias_hash; |
168 | static struct hash_control *alias_name_hash; | |
169 | static struct hash_control *secalias_hash; | |
170 | static struct hash_control *secalias_name_hash; | |
171 | ||
800eeca4 JW |
172 | /* Characters which always start a comment. */ |
173 | const char comment_chars[] = ""; | |
174 | ||
175 | /* Characters which start a comment at the beginning of a line. */ | |
176 | const char line_comment_chars[] = "#"; | |
177 | ||
178 | /* Characters which may be used to separate multiple commands on a | |
179 | single line. */ | |
180 | const char line_separator_chars[] = ";"; | |
181 | ||
182 | /* Characters which are used to indicate an exponent in a floating | |
183 | point number. */ | |
184 | const char EXP_CHARS[] = "eE"; | |
185 | ||
186 | /* Characters which mean that a number is a floating point constant, | |
187 | as in 0d1.0. */ | |
188 | const char FLT_CHARS[] = "rRsSfFdDxXpP"; | |
189 | ||
542d6675 | 190 | /* ia64-specific option processing: */ |
800eeca4 | 191 | |
44f5c83a | 192 | const char *md_shortopts = "m:N:x::"; |
800eeca4 JW |
193 | |
194 | struct option md_longopts[] = | |
195 | { | |
c43c2cc5 JW |
196 | #define OPTION_MCONSTANT_GP (OPTION_MD_BASE + 1) |
197 | {"mconstant-gp", no_argument, NULL, OPTION_MCONSTANT_GP}, | |
198 | #define OPTION_MAUTO_PIC (OPTION_MD_BASE + 2) | |
199 | {"mauto-pic", no_argument, NULL, OPTION_MAUTO_PIC} | |
800eeca4 JW |
200 | }; |
201 | ||
202 | size_t md_longopts_size = sizeof (md_longopts); | |
203 | ||
204 | static struct | |
205 | { | |
206 | struct hash_control *pseudo_hash; /* pseudo opcode hash table */ | |
207 | struct hash_control *reg_hash; /* register name hash table */ | |
208 | struct hash_control *dynreg_hash; /* dynamic register hash table */ | |
209 | struct hash_control *const_hash; /* constant hash table */ | |
210 | struct hash_control *entry_hash; /* code entry hint hash table */ | |
211 | ||
212 | symbolS *regsym[REG_NUM]; | |
213 | ||
214 | /* If X_op is != O_absent, the registername for the instruction's | |
215 | qualifying predicate. If NULL, p0 is assumed for instructions | |
216 | that are predicatable. */ | |
217 | expressionS qp; | |
218 | ||
219 | unsigned int | |
197865e8 | 220 | manual_bundling : 1, |
800eeca4 JW |
221 | debug_dv: 1, |
222 | detect_dv: 1, | |
223 | explicit_mode : 1, /* which mode we're in */ | |
224 | default_explicit_mode : 1, /* which mode is the default */ | |
225 | mode_explicitly_set : 1, /* was the current mode explicitly set? */ | |
4d5a53ff JW |
226 | auto_align : 1, |
227 | keep_pending_output : 1; | |
800eeca4 JW |
228 | |
229 | /* Each bundle consists of up to three instructions. We keep | |
230 | track of four most recent instructions so we can correctly set | |
197865e8 | 231 | the end_of_insn_group for the last instruction in a bundle. */ |
800eeca4 JW |
232 | int curr_slot; |
233 | int num_slots_in_use; | |
234 | struct slot | |
235 | { | |
236 | unsigned int | |
237 | end_of_insn_group : 1, | |
238 | manual_bundling_on : 1, | |
239 | manual_bundling_off : 1; | |
240 | signed char user_template; /* user-selected template, if any */ | |
241 | unsigned char qp_regno; /* qualifying predicate */ | |
242 | /* This duplicates a good fraction of "struct fix" but we | |
243 | can't use a "struct fix" instead since we can't call | |
244 | fix_new_exp() until we know the address of the instruction. */ | |
245 | int num_fixups; | |
246 | struct insn_fix | |
247 | { | |
248 | bfd_reloc_code_real_type code; | |
249 | enum ia64_opnd opnd; /* type of operand in need of fix */ | |
250 | unsigned int is_pcrel : 1; /* is operand pc-relative? */ | |
251 | expressionS expr; /* the value to be inserted */ | |
252 | } | |
253 | fixup[2]; /* at most two fixups per insn */ | |
254 | struct ia64_opcode *idesc; | |
255 | struct label_fix *label_fixups; | |
f1bcba5b | 256 | struct label_fix *tag_fixups; |
800eeca4 JW |
257 | struct unw_rec_list *unwind_record; /* Unwind directive. */ |
258 | expressionS opnd[6]; | |
259 | char *src_file; | |
260 | unsigned int src_line; | |
261 | struct dwarf2_line_info debug_line; | |
262 | } | |
263 | slot[NUM_SLOTS]; | |
264 | ||
265 | segT last_text_seg; | |
266 | ||
267 | struct dynreg | |
268 | { | |
269 | struct dynreg *next; /* next dynamic register */ | |
270 | const char *name; | |
271 | unsigned short base; /* the base register number */ | |
272 | unsigned short num_regs; /* # of registers in this set */ | |
273 | } | |
274 | *dynreg[DYNREG_NUM_TYPES], in, loc, out, rot; | |
275 | ||
276 | flagword flags; /* ELF-header flags */ | |
277 | ||
278 | struct mem_offset { | |
279 | unsigned hint:1; /* is this hint currently valid? */ | |
280 | bfd_vma offset; /* mem.offset offset */ | |
281 | bfd_vma base; /* mem.offset base */ | |
282 | } mem_offset; | |
283 | ||
284 | int path; /* number of alt. entry points seen */ | |
285 | const char **entry_labels; /* labels of all alternate paths in | |
542d6675 | 286 | the current DV-checking block. */ |
800eeca4 | 287 | int maxpaths; /* size currently allocated for |
542d6675 | 288 | entry_labels */ |
88be23ec BS |
289 | /* Support for hardware errata workarounds. */ |
290 | ||
291 | /* Record data about the last three insn groups. */ | |
292 | struct group | |
293 | { | |
294 | /* B-step workaround. | |
295 | For each predicate register, this is set if the corresponding insn | |
296 | group conditionally sets this register with one of the affected | |
297 | instructions. */ | |
298 | int p_reg_set[64]; | |
299 | /* B-step workaround. | |
300 | For each general register, this is set if the corresponding insn | |
301 | a) is conditional one one of the predicate registers for which | |
302 | P_REG_SET is 1 in the corresponding entry of the previous group, | |
303 | b) sets this general register with one of the affected | |
304 | instructions. */ | |
305 | int g_reg_set_conditionally[128]; | |
306 | } last_groups[3]; | |
307 | int group_idx; | |
557debba JW |
308 | |
309 | int pointer_size; /* size in bytes of a pointer */ | |
310 | int pointer_size_shift; /* shift size of a pointer for alignment */ | |
800eeca4 JW |
311 | } |
312 | md; | |
313 | ||
542d6675 | 314 | /* application registers: */ |
800eeca4 | 315 | |
e0c9811a JW |
316 | #define AR_K0 0 |
317 | #define AR_K7 7 | |
318 | #define AR_RSC 16 | |
319 | #define AR_BSP 17 | |
320 | #define AR_BSPSTORE 18 | |
321 | #define AR_RNAT 19 | |
322 | #define AR_UNAT 36 | |
323 | #define AR_FPSR 40 | |
324 | #define AR_ITC 44 | |
325 | #define AR_PFS 64 | |
326 | #define AR_LC 65 | |
800eeca4 JW |
327 | |
328 | static const struct | |
329 | { | |
330 | const char *name; | |
331 | int regnum; | |
332 | } | |
333 | ar[] = | |
334 | { | |
335 | {"ar.k0", 0}, {"ar.k1", 1}, {"ar.k2", 2}, {"ar.k3", 3}, | |
336 | {"ar.k4", 4}, {"ar.k5", 5}, {"ar.k6", 6}, {"ar.k7", 7}, | |
337 | {"ar.rsc", 16}, {"ar.bsp", 17}, | |
338 | {"ar.bspstore", 18}, {"ar.rnat", 19}, | |
339 | {"ar.fcr", 21}, {"ar.eflag", 24}, | |
340 | {"ar.csd", 25}, {"ar.ssd", 26}, | |
341 | {"ar.cflg", 27}, {"ar.fsr", 28}, | |
342 | {"ar.fir", 29}, {"ar.fdr", 30}, | |
343 | {"ar.ccv", 32}, {"ar.unat", 36}, | |
344 | {"ar.fpsr", 40}, {"ar.itc", 44}, | |
345 | {"ar.pfs", 64}, {"ar.lc", 65}, | |
197865e8 | 346 | {"ar.ec", 66}, |
800eeca4 JW |
347 | }; |
348 | ||
349 | #define CR_IPSR 16 | |
350 | #define CR_ISR 17 | |
351 | #define CR_IIP 19 | |
352 | #define CR_IFA 20 | |
353 | #define CR_ITIR 21 | |
354 | #define CR_IIPA 22 | |
355 | #define CR_IFS 23 | |
356 | #define CR_IIM 24 | |
357 | #define CR_IHA 25 | |
358 | #define CR_IVR 65 | |
359 | #define CR_TPR 66 | |
360 | #define CR_EOI 67 | |
361 | #define CR_IRR0 68 | |
362 | #define CR_IRR3 71 | |
363 | #define CR_LRR0 80 | |
364 | #define CR_LRR1 81 | |
365 | ||
542d6675 | 366 | /* control registers: */ |
800eeca4 JW |
367 | static const struct |
368 | { | |
369 | const char *name; | |
370 | int regnum; | |
371 | } | |
372 | cr[] = | |
373 | { | |
374 | {"cr.dcr", 0}, | |
375 | {"cr.itm", 1}, | |
376 | {"cr.iva", 2}, | |
377 | {"cr.pta", 8}, | |
378 | {"cr.gpta", 9}, | |
379 | {"cr.ipsr", 16}, | |
380 | {"cr.isr", 17}, | |
381 | {"cr.iip", 19}, | |
382 | {"cr.ifa", 20}, | |
383 | {"cr.itir", 21}, | |
384 | {"cr.iipa", 22}, | |
385 | {"cr.ifs", 23}, | |
386 | {"cr.iim", 24}, | |
387 | {"cr.iha", 25}, | |
388 | {"cr.lid", 64}, | |
389 | {"cr.ivr", 65}, | |
390 | {"cr.tpr", 66}, | |
391 | {"cr.eoi", 67}, | |
392 | {"cr.irr0", 68}, | |
393 | {"cr.irr1", 69}, | |
394 | {"cr.irr2", 70}, | |
395 | {"cr.irr3", 71}, | |
396 | {"cr.itv", 72}, | |
397 | {"cr.pmv", 73}, | |
398 | {"cr.cmcv", 74}, | |
399 | {"cr.lrr0", 80}, | |
400 | {"cr.lrr1", 81} | |
401 | }; | |
402 | ||
403 | #define PSR_MFL 4 | |
404 | #define PSR_IC 13 | |
405 | #define PSR_DFL 18 | |
406 | #define PSR_CPL 32 | |
407 | ||
408 | static const struct const_desc | |
409 | { | |
410 | const char *name; | |
411 | valueT value; | |
412 | } | |
413 | const_bits[] = | |
414 | { | |
542d6675 | 415 | /* PSR constant masks: */ |
800eeca4 JW |
416 | |
417 | /* 0: reserved */ | |
418 | {"psr.be", ((valueT) 1) << 1}, | |
419 | {"psr.up", ((valueT) 1) << 2}, | |
420 | {"psr.ac", ((valueT) 1) << 3}, | |
421 | {"psr.mfl", ((valueT) 1) << 4}, | |
422 | {"psr.mfh", ((valueT) 1) << 5}, | |
423 | /* 6-12: reserved */ | |
424 | {"psr.ic", ((valueT) 1) << 13}, | |
425 | {"psr.i", ((valueT) 1) << 14}, | |
426 | {"psr.pk", ((valueT) 1) << 15}, | |
427 | /* 16: reserved */ | |
428 | {"psr.dt", ((valueT) 1) << 17}, | |
429 | {"psr.dfl", ((valueT) 1) << 18}, | |
430 | {"psr.dfh", ((valueT) 1) << 19}, | |
431 | {"psr.sp", ((valueT) 1) << 20}, | |
432 | {"psr.pp", ((valueT) 1) << 21}, | |
433 | {"psr.di", ((valueT) 1) << 22}, | |
434 | {"psr.si", ((valueT) 1) << 23}, | |
435 | {"psr.db", ((valueT) 1) << 24}, | |
436 | {"psr.lp", ((valueT) 1) << 25}, | |
437 | {"psr.tb", ((valueT) 1) << 26}, | |
438 | {"psr.rt", ((valueT) 1) << 27}, | |
439 | /* 28-31: reserved */ | |
440 | /* 32-33: cpl (current privilege level) */ | |
441 | {"psr.is", ((valueT) 1) << 34}, | |
442 | {"psr.mc", ((valueT) 1) << 35}, | |
443 | {"psr.it", ((valueT) 1) << 36}, | |
444 | {"psr.id", ((valueT) 1) << 37}, | |
445 | {"psr.da", ((valueT) 1) << 38}, | |
446 | {"psr.dd", ((valueT) 1) << 39}, | |
447 | {"psr.ss", ((valueT) 1) << 40}, | |
448 | /* 41-42: ri (restart instruction) */ | |
449 | {"psr.ed", ((valueT) 1) << 43}, | |
450 | {"psr.bn", ((valueT) 1) << 44}, | |
451 | }; | |
452 | ||
542d6675 | 453 | /* indirect register-sets/memory: */ |
800eeca4 JW |
454 | |
455 | static const struct | |
456 | { | |
457 | const char *name; | |
458 | int regnum; | |
459 | } | |
460 | indirect_reg[] = | |
461 | { | |
462 | { "CPUID", IND_CPUID }, | |
463 | { "cpuid", IND_CPUID }, | |
464 | { "dbr", IND_DBR }, | |
465 | { "dtr", IND_DTR }, | |
466 | { "itr", IND_ITR }, | |
467 | { "ibr", IND_IBR }, | |
468 | { "msr", IND_MSR }, | |
469 | { "pkr", IND_PKR }, | |
470 | { "pmc", IND_PMC }, | |
471 | { "pmd", IND_PMD }, | |
472 | { "rr", IND_RR }, | |
473 | }; | |
474 | ||
475 | /* Pseudo functions used to indicate relocation types (these functions | |
476 | start with an at sign (@). */ | |
477 | static struct | |
478 | { | |
479 | const char *name; | |
480 | enum pseudo_type | |
481 | { | |
482 | PSEUDO_FUNC_NONE, | |
483 | PSEUDO_FUNC_RELOC, | |
484 | PSEUDO_FUNC_CONST, | |
e0c9811a | 485 | PSEUDO_FUNC_REG, |
800eeca4 JW |
486 | PSEUDO_FUNC_FLOAT |
487 | } | |
488 | type; | |
489 | union | |
490 | { | |
491 | unsigned long ival; | |
492 | symbolS *sym; | |
493 | } | |
494 | u; | |
495 | } | |
496 | pseudo_func[] = | |
497 | { | |
542d6675 | 498 | /* reloc pseudo functions (these must come first!): */ |
13ae64f3 JJ |
499 | { "dtpmod", PSEUDO_FUNC_RELOC, { 0 } }, |
500 | { "dtprel", PSEUDO_FUNC_RELOC, { 0 } }, | |
2434f565 JW |
501 | { "fptr", PSEUDO_FUNC_RELOC, { 0 } }, |
502 | { "gprel", PSEUDO_FUNC_RELOC, { 0 } }, | |
503 | { "ltoff", PSEUDO_FUNC_RELOC, { 0 } }, | |
fa2c7eff | 504 | { "ltoffx", PSEUDO_FUNC_RELOC, { 0 } }, |
2434f565 JW |
505 | { "pcrel", PSEUDO_FUNC_RELOC, { 0 } }, |
506 | { "pltoff", PSEUDO_FUNC_RELOC, { 0 } }, | |
507 | { "secrel", PSEUDO_FUNC_RELOC, { 0 } }, | |
508 | { "segrel", PSEUDO_FUNC_RELOC, { 0 } }, | |
13ae64f3 | 509 | { "tprel", PSEUDO_FUNC_RELOC, { 0 } }, |
2434f565 JW |
510 | { "ltv", PSEUDO_FUNC_RELOC, { 0 } }, |
511 | { "", 0, { 0 } }, /* placeholder for FUNC_LT_FPTR_RELATIVE */ | |
13ae64f3 JJ |
512 | { "", 0, { 0 } }, /* placeholder for FUNC_LT_DTP_MODULE */ |
513 | { "", 0, { 0 } }, /* placeholder for FUNC_LT_DTP_RELATIVE */ | |
514 | { "", 0, { 0 } }, /* placeholder for FUNC_LT_TP_RELATIVE */ | |
3969b680 | 515 | { "iplt", PSEUDO_FUNC_RELOC, { 0 } }, |
800eeca4 | 516 | |
542d6675 | 517 | /* mbtype4 constants: */ |
800eeca4 JW |
518 | { "alt", PSEUDO_FUNC_CONST, { 0xa } }, |
519 | { "brcst", PSEUDO_FUNC_CONST, { 0x0 } }, | |
520 | { "mix", PSEUDO_FUNC_CONST, { 0x8 } }, | |
521 | { "rev", PSEUDO_FUNC_CONST, { 0xb } }, | |
522 | { "shuf", PSEUDO_FUNC_CONST, { 0x9 } }, | |
523 | ||
542d6675 | 524 | /* fclass constants: */ |
bf3ca999 | 525 | { "nat", PSEUDO_FUNC_CONST, { 0x100 } }, |
800eeca4 JW |
526 | { "qnan", PSEUDO_FUNC_CONST, { 0x080 } }, |
527 | { "snan", PSEUDO_FUNC_CONST, { 0x040 } }, | |
528 | { "pos", PSEUDO_FUNC_CONST, { 0x001 } }, | |
529 | { "neg", PSEUDO_FUNC_CONST, { 0x002 } }, | |
530 | { "zero", PSEUDO_FUNC_CONST, { 0x004 } }, | |
531 | { "unorm", PSEUDO_FUNC_CONST, { 0x008 } }, | |
532 | { "norm", PSEUDO_FUNC_CONST, { 0x010 } }, | |
533 | { "inf", PSEUDO_FUNC_CONST, { 0x020 } }, | |
bf3ca999 TW |
534 | |
535 | { "natval", PSEUDO_FUNC_CONST, { 0x100 } }, /* old usage */ | |
e0c9811a | 536 | |
c10d9d8f JW |
537 | /* hint constants: */ |
538 | { "pause", PSEUDO_FUNC_CONST, { 0x0 } }, | |
539 | ||
542d6675 | 540 | /* unwind-related constants: */ |
041340ad JW |
541 | { "svr4", PSEUDO_FUNC_CONST, { ELFOSABI_NONE } }, |
542 | { "hpux", PSEUDO_FUNC_CONST, { ELFOSABI_HPUX } }, | |
543 | { "nt", PSEUDO_FUNC_CONST, { 2 } }, /* conflicts w/ELFOSABI_NETBSD */ | |
544 | { "linux", PSEUDO_FUNC_CONST, { ELFOSABI_LINUX } }, | |
545 | { "freebsd", PSEUDO_FUNC_CONST, { ELFOSABI_FREEBSD } }, | |
546 | { "openvms", PSEUDO_FUNC_CONST, { ELFOSABI_OPENVMS } }, | |
547 | { "nsk", PSEUDO_FUNC_CONST, { ELFOSABI_NSK } }, | |
e0c9811a | 548 | |
542d6675 | 549 | /* unwind-related registers: */ |
e0c9811a | 550 | { "priunat",PSEUDO_FUNC_REG, { REG_PRIUNAT } } |
800eeca4 JW |
551 | }; |
552 | ||
542d6675 | 553 | /* 41-bit nop opcodes (one per unit): */ |
800eeca4 JW |
554 | static const bfd_vma nop[IA64_NUM_UNITS] = |
555 | { | |
556 | 0x0000000000LL, /* NIL => break 0 */ | |
557 | 0x0008000000LL, /* I-unit nop */ | |
558 | 0x0008000000LL, /* M-unit nop */ | |
559 | 0x4000000000LL, /* B-unit nop */ | |
560 | 0x0008000000LL, /* F-unit nop */ | |
561 | 0x0008000000LL, /* L-"unit" nop */ | |
562 | 0x0008000000LL, /* X-unit nop */ | |
563 | }; | |
564 | ||
565 | /* Can't be `const' as it's passed to input routines (which have the | |
566 | habit of setting temporary sentinels. */ | |
567 | static char special_section_name[][20] = | |
568 | { | |
569 | {".bss"}, {".sbss"}, {".sdata"}, {".rodata"}, {".comment"}, | |
557debba JW |
570 | {".IA_64.unwind"}, {".IA_64.unwind_info"}, |
571 | {".init_array"}, {".fini_array"} | |
800eeca4 JW |
572 | }; |
573 | ||
579f31ac JJ |
574 | static char *special_linkonce_name[] = |
575 | { | |
576 | ".gnu.linkonce.ia64unw.", ".gnu.linkonce.ia64unwi." | |
577 | }; | |
578 | ||
800eeca4 JW |
579 | /* The best template for a particular sequence of up to three |
580 | instructions: */ | |
581 | #define N IA64_NUM_TYPES | |
582 | static unsigned char best_template[N][N][N]; | |
583 | #undef N | |
584 | ||
585 | /* Resource dependencies currently in effect */ | |
586 | static struct rsrc { | |
587 | int depind; /* dependency index */ | |
588 | const struct ia64_dependency *dependency; /* actual dependency */ | |
589 | unsigned specific:1, /* is this a specific bit/regno? */ | |
590 | link_to_qp_branch:1; /* will a branch on the same QP clear it?*/ | |
591 | int index; /* specific regno/bit within dependency */ | |
592 | int note; /* optional qualifying note (0 if none) */ | |
593 | #define STATE_NONE 0 | |
594 | #define STATE_STOP 1 | |
595 | #define STATE_SRLZ 2 | |
596 | int insn_srlz; /* current insn serialization state */ | |
597 | int data_srlz; /* current data serialization state */ | |
598 | int qp_regno; /* qualifying predicate for this usage */ | |
599 | char *file; /* what file marked this dependency */ | |
2434f565 | 600 | unsigned int line; /* what line marked this dependency */ |
800eeca4 | 601 | struct mem_offset mem_offset; /* optional memory offset hint */ |
7484b8e6 | 602 | enum { CMP_NONE, CMP_OR, CMP_AND } cmp_type; /* OR or AND compare? */ |
800eeca4 JW |
603 | int path; /* corresponding code entry index */ |
604 | } *regdeps = NULL; | |
605 | static int regdepslen = 0; | |
606 | static int regdepstotlen = 0; | |
607 | static const char *dv_mode[] = { "RAW", "WAW", "WAR" }; | |
608 | static const char *dv_sem[] = { "none", "implied", "impliedf", | |
139368c9 | 609 | "data", "instr", "specific", "stop", "other" }; |
7484b8e6 | 610 | static const char *dv_cmp_type[] = { "none", "OR", "AND" }; |
800eeca4 JW |
611 | |
612 | /* Current state of PR mutexation */ | |
613 | static struct qpmutex { | |
614 | valueT prmask; | |
615 | int path; | |
616 | } *qp_mutexes = NULL; /* QP mutex bitmasks */ | |
617 | static int qp_mutexeslen = 0; | |
618 | static int qp_mutexestotlen = 0; | |
197865e8 | 619 | static valueT qp_safe_across_calls = 0; |
800eeca4 JW |
620 | |
621 | /* Current state of PR implications */ | |
622 | static struct qp_imply { | |
623 | unsigned p1:6; | |
624 | unsigned p2:6; | |
625 | unsigned p2_branched:1; | |
626 | int path; | |
627 | } *qp_implies = NULL; | |
628 | static int qp_implieslen = 0; | |
629 | static int qp_impliestotlen = 0; | |
630 | ||
197865e8 KH |
631 | /* Keep track of static GR values so that indirect register usage can |
632 | sometimes be tracked. */ | |
800eeca4 JW |
633 | static struct gr { |
634 | unsigned known:1; | |
635 | int path; | |
636 | valueT value; | |
2434f565 | 637 | } gr_values[128] = {{ 1, 0, 0 }}; |
800eeca4 | 638 | |
9545c4ce L |
639 | /* Remember the alignment frag. */ |
640 | static fragS *align_frag; | |
641 | ||
800eeca4 JW |
642 | /* These are the routines required to output the various types of |
643 | unwind records. */ | |
644 | ||
f5a30c2e JW |
645 | /* A slot_number is a frag address plus the slot index (0-2). We use the |
646 | frag address here so that if there is a section switch in the middle of | |
647 | a function, then instructions emitted to a different section are not | |
648 | counted. Since there may be more than one frag for a function, this | |
649 | means we also need to keep track of which frag this address belongs to | |
650 | so we can compute inter-frag distances. This also nicely solves the | |
651 | problem with nops emitted for align directives, which can't easily be | |
652 | counted, but can easily be derived from frag sizes. */ | |
653 | ||
800eeca4 JW |
654 | typedef struct unw_rec_list { |
655 | unwind_record r; | |
e0c9811a | 656 | unsigned long slot_number; |
f5a30c2e | 657 | fragS *slot_frag; |
73f20958 L |
658 | unsigned long next_slot_number; |
659 | fragS *next_slot_frag; | |
800eeca4 JW |
660 | struct unw_rec_list *next; |
661 | } unw_rec_list; | |
662 | ||
2434f565 | 663 | #define SLOT_NUM_NOT_SET (unsigned)-1 |
800eeca4 | 664 | |
6290819d NC |
665 | /* Linked list of saved prologue counts. A very poor |
666 | implementation of a map from label numbers to prologue counts. */ | |
667 | typedef struct label_prologue_count | |
668 | { | |
669 | struct label_prologue_count *next; | |
670 | unsigned long label_number; | |
671 | unsigned int prologue_count; | |
672 | } label_prologue_count; | |
673 | ||
e0c9811a JW |
674 | static struct |
675 | { | |
e0c9811a JW |
676 | /* Maintain a list of unwind entries for the current function. */ |
677 | unw_rec_list *list; | |
678 | unw_rec_list *tail; | |
800eeca4 | 679 | |
e0c9811a JW |
680 | /* Any unwind entires that should be attached to the current slot |
681 | that an insn is being constructed for. */ | |
682 | unw_rec_list *current_entry; | |
800eeca4 | 683 | |
e0c9811a JW |
684 | /* These are used to create the unwind table entry for this function. */ |
685 | symbolS *proc_start; | |
686 | symbolS *proc_end; | |
687 | symbolS *info; /* pointer to unwind info */ | |
688 | symbolS *personality_routine; | |
91a2ae2a RH |
689 | segT saved_text_seg; |
690 | subsegT saved_text_subseg; | |
691 | unsigned int force_unwind_entry : 1; /* force generation of unwind entry? */ | |
800eeca4 | 692 | |
e0c9811a JW |
693 | /* TRUE if processing unwind directives in a prologue region. */ |
694 | int prologue; | |
30d25259 | 695 | int prologue_mask; |
33d01f33 | 696 | unsigned int prologue_count; /* number of .prologues seen so far */ |
6290819d NC |
697 | /* Prologue counts at previous .label_state directives. */ |
698 | struct label_prologue_count * saved_prologue_counts; | |
e0c9811a | 699 | } unwind; |
800eeca4 JW |
700 | |
701 | typedef void (*vbyte_func) PARAMS ((int, char *, char *)); | |
702 | ||
0234cb7c | 703 | /* Forward declarations: */ |
800eeca4 JW |
704 | static int ar_is_in_integer_unit PARAMS ((int regnum)); |
705 | static void set_section PARAMS ((char *name)); | |
706 | static unsigned int set_regstack PARAMS ((unsigned int, unsigned int, | |
707 | unsigned int, unsigned int)); | |
708 | static void dot_radix PARAMS ((int)); | |
709 | static void dot_special_section PARAMS ((int)); | |
710 | static void dot_proc PARAMS ((int)); | |
711 | static void dot_fframe PARAMS ((int)); | |
712 | static void dot_vframe PARAMS ((int)); | |
150f24a2 JW |
713 | static void dot_vframesp PARAMS ((int)); |
714 | static void dot_vframepsp PARAMS ((int)); | |
800eeca4 JW |
715 | static void dot_save PARAMS ((int)); |
716 | static void dot_restore PARAMS ((int)); | |
150f24a2 JW |
717 | static void dot_restorereg PARAMS ((int)); |
718 | static void dot_restorereg_p PARAMS ((int)); | |
800eeca4 JW |
719 | static void dot_handlerdata PARAMS ((int)); |
720 | static void dot_unwentry PARAMS ((int)); | |
721 | static void dot_altrp PARAMS ((int)); | |
e0c9811a | 722 | static void dot_savemem PARAMS ((int)); |
800eeca4 JW |
723 | static void dot_saveg PARAMS ((int)); |
724 | static void dot_savef PARAMS ((int)); | |
725 | static void dot_saveb PARAMS ((int)); | |
726 | static void dot_savegf PARAMS ((int)); | |
727 | static void dot_spill PARAMS ((int)); | |
150f24a2 JW |
728 | static void dot_spillreg PARAMS ((int)); |
729 | static void dot_spillmem PARAMS ((int)); | |
730 | static void dot_spillreg_p PARAMS ((int)); | |
731 | static void dot_spillmem_p PARAMS ((int)); | |
732 | static void dot_label_state PARAMS ((int)); | |
733 | static void dot_copy_state PARAMS ((int)); | |
800eeca4 JW |
734 | static void dot_unwabi PARAMS ((int)); |
735 | static void dot_personality PARAMS ((int)); | |
736 | static void dot_body PARAMS ((int)); | |
737 | static void dot_prologue PARAMS ((int)); | |
738 | static void dot_endp PARAMS ((int)); | |
739 | static void dot_template PARAMS ((int)); | |
740 | static void dot_regstk PARAMS ((int)); | |
741 | static void dot_rot PARAMS ((int)); | |
742 | static void dot_byteorder PARAMS ((int)); | |
743 | static void dot_psr PARAMS ((int)); | |
744 | static void dot_alias PARAMS ((int)); | |
745 | static void dot_ln PARAMS ((int)); | |
746 | static char *parse_section_name PARAMS ((void)); | |
747 | static void dot_xdata PARAMS ((int)); | |
748 | static void stmt_float_cons PARAMS ((int)); | |
749 | static void stmt_cons_ua PARAMS ((int)); | |
750 | static void dot_xfloat_cons PARAMS ((int)); | |
751 | static void dot_xstringer PARAMS ((int)); | |
752 | static void dot_xdata_ua PARAMS ((int)); | |
753 | static void dot_xfloat_cons_ua PARAMS ((int)); | |
150f24a2 | 754 | static void print_prmask PARAMS ((valueT mask)); |
800eeca4 JW |
755 | static void dot_pred_rel PARAMS ((int)); |
756 | static void dot_reg_val PARAMS ((int)); | |
757 | static void dot_dv_mode PARAMS ((int)); | |
758 | static void dot_entry PARAMS ((int)); | |
759 | static void dot_mem_offset PARAMS ((int)); | |
e0c9811a | 760 | static void add_unwind_entry PARAMS((unw_rec_list *ptr)); |
542d6675 | 761 | static symbolS *declare_register PARAMS ((const char *name, int regnum)); |
800eeca4 JW |
762 | static void declare_register_set PARAMS ((const char *, int, int)); |
763 | static unsigned int operand_width PARAMS ((enum ia64_opnd)); | |
87f8eb97 JW |
764 | static enum operand_match_result operand_match PARAMS ((const struct ia64_opcode *idesc, |
765 | int index, | |
766 | expressionS *e)); | |
800eeca4 JW |
767 | static int parse_operand PARAMS ((expressionS *e)); |
768 | static struct ia64_opcode * parse_operands PARAMS ((struct ia64_opcode *)); | |
86cf98f3 | 769 | static int errata_nop_necessary_p PARAMS ((struct slot *, enum ia64_unit)); |
800eeca4 JW |
770 | static void build_insn PARAMS ((struct slot *, bfd_vma *)); |
771 | static void emit_one_bundle PARAMS ((void)); | |
772 | static void fix_insn PARAMS ((fixS *, const struct ia64_operand *, valueT)); | |
197865e8 | 773 | static bfd_reloc_code_real_type ia64_gen_real_reloc_type PARAMS ((struct symbol *sym, |
800eeca4 JW |
774 | bfd_reloc_code_real_type r_type)); |
775 | static void insn_group_break PARAMS ((int, int, int)); | |
150f24a2 JW |
776 | static void mark_resource PARAMS ((struct ia64_opcode *, const struct ia64_dependency *, |
777 | struct rsrc *, int depind, int path)); | |
800eeca4 JW |
778 | static void add_qp_mutex PARAMS((valueT mask)); |
779 | static void add_qp_imply PARAMS((int p1, int p2)); | |
780 | static void clear_qp_branch_flag PARAMS((valueT mask)); | |
781 | static void clear_qp_mutex PARAMS((valueT mask)); | |
782 | static void clear_qp_implies PARAMS((valueT p1_mask, valueT p2_mask)); | |
cb5301b6 | 783 | static int has_suffix_p PARAMS((const char *, const char *)); |
800eeca4 JW |
784 | static void clear_register_values PARAMS ((void)); |
785 | static void print_dependency PARAMS ((const char *action, int depind)); | |
150f24a2 JW |
786 | static void instruction_serialization PARAMS ((void)); |
787 | static void data_serialization PARAMS ((void)); | |
788 | static void remove_marked_resource PARAMS ((struct rsrc *)); | |
800eeca4 | 789 | static int is_conditional_branch PARAMS ((struct ia64_opcode *)); |
150f24a2 | 790 | static int is_taken_branch PARAMS ((struct ia64_opcode *)); |
800eeca4 | 791 | static int is_interruption_or_rfi PARAMS ((struct ia64_opcode *)); |
150f24a2 JW |
792 | static int depends_on PARAMS ((int, struct ia64_opcode *)); |
793 | static int specify_resource PARAMS ((const struct ia64_dependency *, | |
794 | struct ia64_opcode *, int, struct rsrc [], int, int)); | |
800eeca4 JW |
795 | static int check_dv PARAMS((struct ia64_opcode *idesc)); |
796 | static void check_dependencies PARAMS((struct ia64_opcode *)); | |
797 | static void mark_resources PARAMS((struct ia64_opcode *)); | |
798 | static void update_dependencies PARAMS((struct ia64_opcode *)); | |
799 | static void note_register_values PARAMS((struct ia64_opcode *)); | |
150f24a2 JW |
800 | static int qp_mutex PARAMS ((int, int, int)); |
801 | static int resources_match PARAMS ((struct rsrc *, struct ia64_opcode *, int, int, int)); | |
802 | static void output_vbyte_mem PARAMS ((int, char *, char *)); | |
803 | static void count_output PARAMS ((int, char *, char *)); | |
804 | static void output_R1_format PARAMS ((vbyte_func, unw_record_type, int)); | |
805 | static void output_R2_format PARAMS ((vbyte_func, int, int, unsigned long)); | |
800eeca4 | 806 | static void output_R3_format PARAMS ((vbyte_func, unw_record_type, unsigned long)); |
150f24a2 JW |
807 | static void output_P1_format PARAMS ((vbyte_func, int)); |
808 | static void output_P2_format PARAMS ((vbyte_func, int, int)); | |
809 | static void output_P3_format PARAMS ((vbyte_func, unw_record_type, int)); | |
810 | static void output_P4_format PARAMS ((vbyte_func, unsigned char *, unsigned long)); | |
811 | static void output_P5_format PARAMS ((vbyte_func, int, unsigned long)); | |
812 | static void output_P6_format PARAMS ((vbyte_func, unw_record_type, int)); | |
813 | static void output_P7_format PARAMS ((vbyte_func, unw_record_type, unsigned long, unsigned long)); | |
814 | static void output_P8_format PARAMS ((vbyte_func, unw_record_type, unsigned long)); | |
815 | static void output_P9_format PARAMS ((vbyte_func, int, int)); | |
816 | static void output_P10_format PARAMS ((vbyte_func, int, int)); | |
817 | static void output_B1_format PARAMS ((vbyte_func, unw_record_type, unsigned long)); | |
818 | static void output_B2_format PARAMS ((vbyte_func, unsigned long, unsigned long)); | |
800eeca4 JW |
819 | static void output_B3_format PARAMS ((vbyte_func, unsigned long, unsigned long)); |
820 | static void output_B4_format PARAMS ((vbyte_func, unw_record_type, unsigned long)); | |
150f24a2 JW |
821 | static char format_ab_reg PARAMS ((int, int)); |
822 | static void output_X1_format PARAMS ((vbyte_func, unw_record_type, int, int, unsigned long, | |
823 | unsigned long)); | |
824 | static void output_X2_format PARAMS ((vbyte_func, int, int, int, int, int, unsigned long)); | |
825 | static void output_X3_format PARAMS ((vbyte_func, unw_record_type, int, int, int, unsigned long, | |
826 | unsigned long)); | |
827 | static void output_X4_format PARAMS ((vbyte_func, int, int, int, int, int, int, unsigned long)); | |
5738bc24 | 828 | static unw_rec_list *output_endp PARAMS ((void)); |
150f24a2 JW |
829 | static unw_rec_list *output_prologue PARAMS ((void)); |
830 | static unw_rec_list *output_prologue_gr PARAMS ((unsigned int, unsigned int)); | |
831 | static unw_rec_list *output_body PARAMS ((void)); | |
832 | static unw_rec_list *output_mem_stack_f PARAMS ((unsigned int)); | |
833 | static unw_rec_list *output_mem_stack_v PARAMS ((void)); | |
834 | static unw_rec_list *output_psp_gr PARAMS ((unsigned int)); | |
835 | static unw_rec_list *output_psp_sprel PARAMS ((unsigned int)); | |
836 | static unw_rec_list *output_rp_when PARAMS ((void)); | |
837 | static unw_rec_list *output_rp_gr PARAMS ((unsigned int)); | |
838 | static unw_rec_list *output_rp_br PARAMS ((unsigned int)); | |
839 | static unw_rec_list *output_rp_psprel PARAMS ((unsigned int)); | |
840 | static unw_rec_list *output_rp_sprel PARAMS ((unsigned int)); | |
841 | static unw_rec_list *output_pfs_when PARAMS ((void)); | |
842 | static unw_rec_list *output_pfs_gr PARAMS ((unsigned int)); | |
843 | static unw_rec_list *output_pfs_psprel PARAMS ((unsigned int)); | |
844 | static unw_rec_list *output_pfs_sprel PARAMS ((unsigned int)); | |
845 | static unw_rec_list *output_preds_when PARAMS ((void)); | |
846 | static unw_rec_list *output_preds_gr PARAMS ((unsigned int)); | |
847 | static unw_rec_list *output_preds_psprel PARAMS ((unsigned int)); | |
848 | static unw_rec_list *output_preds_sprel PARAMS ((unsigned int)); | |
849 | static unw_rec_list *output_fr_mem PARAMS ((unsigned int)); | |
850 | static unw_rec_list *output_frgr_mem PARAMS ((unsigned int, unsigned int)); | |
851 | static unw_rec_list *output_gr_gr PARAMS ((unsigned int, unsigned int)); | |
852 | static unw_rec_list *output_gr_mem PARAMS ((unsigned int)); | |
853 | static unw_rec_list *output_br_mem PARAMS ((unsigned int)); | |
854 | static unw_rec_list *output_br_gr PARAMS ((unsigned int, unsigned int)); | |
855 | static unw_rec_list *output_spill_base PARAMS ((unsigned int)); | |
856 | static unw_rec_list *output_unat_when PARAMS ((void)); | |
857 | static unw_rec_list *output_unat_gr PARAMS ((unsigned int)); | |
858 | static unw_rec_list *output_unat_psprel PARAMS ((unsigned int)); | |
859 | static unw_rec_list *output_unat_sprel PARAMS ((unsigned int)); | |
860 | static unw_rec_list *output_lc_when PARAMS ((void)); | |
861 | static unw_rec_list *output_lc_gr PARAMS ((unsigned int)); | |
862 | static unw_rec_list *output_lc_psprel PARAMS ((unsigned int)); | |
863 | static unw_rec_list *output_lc_sprel PARAMS ((unsigned int)); | |
864 | static unw_rec_list *output_fpsr_when PARAMS ((void)); | |
865 | static unw_rec_list *output_fpsr_gr PARAMS ((unsigned int)); | |
866 | static unw_rec_list *output_fpsr_psprel PARAMS ((unsigned int)); | |
867 | static unw_rec_list *output_fpsr_sprel PARAMS ((unsigned int)); | |
868 | static unw_rec_list *output_priunat_when_gr PARAMS ((void)); | |
869 | static unw_rec_list *output_priunat_when_mem PARAMS ((void)); | |
870 | static unw_rec_list *output_priunat_gr PARAMS ((unsigned int)); | |
871 | static unw_rec_list *output_priunat_psprel PARAMS ((unsigned int)); | |
872 | static unw_rec_list *output_priunat_sprel PARAMS ((unsigned int)); | |
873 | static unw_rec_list *output_bsp_when PARAMS ((void)); | |
874 | static unw_rec_list *output_bsp_gr PARAMS ((unsigned int)); | |
875 | static unw_rec_list *output_bsp_psprel PARAMS ((unsigned int)); | |
876 | static unw_rec_list *output_bsp_sprel PARAMS ((unsigned int)); | |
877 | static unw_rec_list *output_bspstore_when PARAMS ((void)); | |
878 | static unw_rec_list *output_bspstore_gr PARAMS ((unsigned int)); | |
879 | static unw_rec_list *output_bspstore_psprel PARAMS ((unsigned int)); | |
880 | static unw_rec_list *output_bspstore_sprel PARAMS ((unsigned int)); | |
881 | static unw_rec_list *output_rnat_when PARAMS ((void)); | |
882 | static unw_rec_list *output_rnat_gr PARAMS ((unsigned int)); | |
883 | static unw_rec_list *output_rnat_psprel PARAMS ((unsigned int)); | |
884 | static unw_rec_list *output_rnat_sprel PARAMS ((unsigned int)); | |
885 | static unw_rec_list *output_unwabi PARAMS ((unsigned long, unsigned long)); | |
886 | static unw_rec_list *output_epilogue PARAMS ((unsigned long)); | |
887 | static unw_rec_list *output_label_state PARAMS ((unsigned long)); | |
888 | static unw_rec_list *output_copy_state PARAMS ((unsigned long)); | |
889 | static unw_rec_list *output_spill_psprel PARAMS ((unsigned int, unsigned int, unsigned int)); | |
890 | static unw_rec_list *output_spill_sprel PARAMS ((unsigned int, unsigned int, unsigned int)); | |
891 | static unw_rec_list *output_spill_psprel_p PARAMS ((unsigned int, unsigned int, unsigned int, | |
892 | unsigned int)); | |
893 | static unw_rec_list *output_spill_sprel_p PARAMS ((unsigned int, unsigned int, unsigned int, | |
894 | unsigned int)); | |
895 | static unw_rec_list *output_spill_reg PARAMS ((unsigned int, unsigned int, unsigned int, | |
896 | unsigned int)); | |
897 | static unw_rec_list *output_spill_reg_p PARAMS ((unsigned int, unsigned int, unsigned int, | |
898 | unsigned int, unsigned int)); | |
899 | static void process_one_record PARAMS ((unw_rec_list *, vbyte_func)); | |
900 | static void process_unw_records PARAMS ((unw_rec_list *, vbyte_func)); | |
901 | static int calc_record_size PARAMS ((unw_rec_list *)); | |
902 | static void set_imask PARAMS ((unw_rec_list *, unsigned long, unsigned long, unsigned int)); | |
f5a30c2e | 903 | static unsigned long slot_index PARAMS ((unsigned long, fragS *, |
b5e0fabd JW |
904 | unsigned long, fragS *, |
905 | int)); | |
91a2ae2a | 906 | static unw_rec_list *optimize_unw_records PARAMS ((unw_rec_list *)); |
b5e0fabd | 907 | static void fixup_unw_records PARAMS ((unw_rec_list *, int)); |
150f24a2 JW |
908 | static int convert_expr_to_ab_reg PARAMS ((expressionS *, unsigned int *, unsigned int *)); |
909 | static int convert_expr_to_xy_reg PARAMS ((expressionS *, unsigned int *, unsigned int *)); | |
73f20958 | 910 | static void generate_unwind_image PARAMS ((const char *)); |
6290819d NC |
911 | static unsigned int get_saved_prologue_count PARAMS ((unsigned long)); |
912 | static void save_prologue_count PARAMS ((unsigned long, unsigned int)); | |
913 | static void free_saved_prologue_counts PARAMS ((void)); | |
91a2ae2a RH |
914 | |
915 | /* Build the unwind section name by appending the (possibly stripped) | |
916 | text section NAME to the unwind PREFIX. The resulting string | |
917 | pointer is assigned to RESULT. The string is allocated on the | |
40449e9f | 918 | stack, so this must be a macro... */ |
91a2ae2a RH |
919 | #define make_unw_section_name(special, text_name, result) \ |
920 | { \ | |
86cf98f3 RH |
921 | const char *_prefix = special_section_name[special]; \ |
922 | const char *_suffix = text_name; \ | |
579f31ac JJ |
923 | size_t _prefix_len, _suffix_len; \ |
924 | char *_result; \ | |
925 | if (strncmp (text_name, ".gnu.linkonce.t.", \ | |
926 | sizeof (".gnu.linkonce.t.") - 1) == 0) \ | |
927 | { \ | |
928 | _prefix = special_linkonce_name[special - SPECIAL_SECTION_UNWIND]; \ | |
929 | _suffix += sizeof (".gnu.linkonce.t.") - 1; \ | |
930 | } \ | |
931 | _prefix_len = strlen (_prefix), _suffix_len = strlen (_suffix); \ | |
932 | _result = alloca (_prefix_len + _suffix_len + 1); \ | |
07726851 KH |
933 | memcpy (_result, _prefix, _prefix_len); \ |
934 | memcpy (_result + _prefix_len, _suffix, _suffix_len); \ | |
579f31ac | 935 | _result[_prefix_len + _suffix_len] = '\0'; \ |
91a2ae2a RH |
936 | result = _result; \ |
937 | } \ | |
938 | while (0) | |
800eeca4 JW |
939 | |
940 | /* Determine if application register REGNUM resides in the integer | |
941 | unit (as opposed to the memory unit). */ | |
942 | static int | |
943 | ar_is_in_integer_unit (reg) | |
944 | int reg; | |
945 | { | |
946 | reg -= REG_AR; | |
947 | ||
948 | return (reg == 64 /* pfs */ | |
949 | || reg == 65 /* lc */ | |
950 | || reg == 66 /* ec */ | |
951 | /* ??? ias accepts and puts these in the integer unit. */ | |
952 | || (reg >= 112 && reg <= 127)); | |
953 | } | |
954 | ||
955 | /* Switch to section NAME and create section if necessary. It's | |
956 | rather ugly that we have to manipulate input_line_pointer but I | |
957 | don't see any other way to accomplish the same thing without | |
958 | changing obj-elf.c (which may be the Right Thing, in the end). */ | |
959 | static void | |
960 | set_section (name) | |
961 | char *name; | |
962 | { | |
963 | char *saved_input_line_pointer; | |
964 | ||
965 | saved_input_line_pointer = input_line_pointer; | |
966 | input_line_pointer = name; | |
967 | obj_elf_section (0); | |
968 | input_line_pointer = saved_input_line_pointer; | |
969 | } | |
970 | ||
d61a78a7 RH |
971 | /* Map 's' to SHF_IA_64_SHORT. */ |
972 | ||
973 | int | |
974 | ia64_elf_section_letter (letter, ptr_msg) | |
975 | int letter; | |
976 | char **ptr_msg; | |
977 | { | |
978 | if (letter == 's') | |
979 | return SHF_IA_64_SHORT; | |
711ef82f L |
980 | else if (letter == 'o') |
981 | return SHF_LINK_ORDER; | |
d61a78a7 | 982 | |
711ef82f L |
983 | *ptr_msg = _("Bad .section directive: want a,o,s,w,x,M,S,G,T in string"); |
984 | return -1; | |
d61a78a7 RH |
985 | } |
986 | ||
800eeca4 JW |
987 | /* Map SHF_IA_64_SHORT to SEC_SMALL_DATA. */ |
988 | ||
989 | flagword | |
990 | ia64_elf_section_flags (flags, attr, type) | |
991 | flagword flags; | |
2434f565 | 992 | int attr, type ATTRIBUTE_UNUSED; |
800eeca4 JW |
993 | { |
994 | if (attr & SHF_IA_64_SHORT) | |
995 | flags |= SEC_SMALL_DATA; | |
996 | return flags; | |
997 | } | |
998 | ||
91a2ae2a RH |
999 | int |
1000 | ia64_elf_section_type (str, len) | |
40449e9f KH |
1001 | const char *str; |
1002 | size_t len; | |
91a2ae2a | 1003 | { |
1cd8ff38 | 1004 | #define STREQ(s) ((len == sizeof (s) - 1) && (strncmp (str, s, sizeof (s) - 1) == 0)) |
40449e9f | 1005 | |
1cd8ff38 | 1006 | if (STREQ (ELF_STRING_ia64_unwind_info)) |
91a2ae2a RH |
1007 | return SHT_PROGBITS; |
1008 | ||
1cd8ff38 | 1009 | if (STREQ (ELF_STRING_ia64_unwind_info_once)) |
579f31ac JJ |
1010 | return SHT_PROGBITS; |
1011 | ||
1cd8ff38 | 1012 | if (STREQ (ELF_STRING_ia64_unwind)) |
91a2ae2a RH |
1013 | return SHT_IA_64_UNWIND; |
1014 | ||
1cd8ff38 | 1015 | if (STREQ (ELF_STRING_ia64_unwind_once)) |
579f31ac JJ |
1016 | return SHT_IA_64_UNWIND; |
1017 | ||
711ef82f L |
1018 | if (STREQ ("unwind")) |
1019 | return SHT_IA_64_UNWIND; | |
1020 | ||
1cd8ff38 NC |
1021 | if (STREQ ("init_array")) |
1022 | return SHT_INIT_ARRAY; | |
40449e9f | 1023 | |
1cd8ff38 NC |
1024 | if (STREQ ("fini_array")) |
1025 | return SHT_FINI_ARRAY; | |
40449e9f | 1026 | |
91a2ae2a | 1027 | return -1; |
1cd8ff38 | 1028 | #undef STREQ |
91a2ae2a RH |
1029 | } |
1030 | ||
800eeca4 JW |
1031 | static unsigned int |
1032 | set_regstack (ins, locs, outs, rots) | |
1033 | unsigned int ins, locs, outs, rots; | |
1034 | { | |
542d6675 KH |
1035 | /* Size of frame. */ |
1036 | unsigned int sof; | |
800eeca4 JW |
1037 | |
1038 | sof = ins + locs + outs; | |
1039 | if (sof > 96) | |
1040 | { | |
1041 | as_bad ("Size of frame exceeds maximum of 96 registers"); | |
1042 | return 0; | |
1043 | } | |
1044 | if (rots > sof) | |
1045 | { | |
1046 | as_warn ("Size of rotating registers exceeds frame size"); | |
1047 | return 0; | |
1048 | } | |
1049 | md.in.base = REG_GR + 32; | |
1050 | md.loc.base = md.in.base + ins; | |
1051 | md.out.base = md.loc.base + locs; | |
1052 | ||
1053 | md.in.num_regs = ins; | |
1054 | md.loc.num_regs = locs; | |
1055 | md.out.num_regs = outs; | |
1056 | md.rot.num_regs = rots; | |
1057 | return sof; | |
1058 | } | |
1059 | ||
1060 | void | |
1061 | ia64_flush_insns () | |
1062 | { | |
1063 | struct label_fix *lfix; | |
1064 | segT saved_seg; | |
1065 | subsegT saved_subseg; | |
b44b1b85 | 1066 | unw_rec_list *ptr; |
800eeca4 JW |
1067 | |
1068 | if (!md.last_text_seg) | |
1069 | return; | |
1070 | ||
1071 | saved_seg = now_seg; | |
1072 | saved_subseg = now_subseg; | |
1073 | ||
1074 | subseg_set (md.last_text_seg, 0); | |
1075 | ||
1076 | while (md.num_slots_in_use > 0) | |
1077 | emit_one_bundle (); /* force out queued instructions */ | |
1078 | ||
1079 | /* In case there are labels following the last instruction, resolve | |
542d6675 | 1080 | those now: */ |
800eeca4 JW |
1081 | for (lfix = CURR_SLOT.label_fixups; lfix; lfix = lfix->next) |
1082 | { | |
1083 | S_SET_VALUE (lfix->sym, frag_now_fix ()); | |
1084 | symbol_set_frag (lfix->sym, frag_now); | |
1085 | } | |
1086 | CURR_SLOT.label_fixups = 0; | |
f1bcba5b JW |
1087 | for (lfix = CURR_SLOT.tag_fixups; lfix; lfix = lfix->next) |
1088 | { | |
1089 | S_SET_VALUE (lfix->sym, frag_now_fix ()); | |
1090 | symbol_set_frag (lfix->sym, frag_now); | |
1091 | } | |
1092 | CURR_SLOT.tag_fixups = 0; | |
800eeca4 | 1093 | |
b44b1b85 | 1094 | /* In case there are unwind directives following the last instruction, |
5738bc24 JW |
1095 | resolve those now. We only handle prologue, body, and endp directives |
1096 | here. Give an error for others. */ | |
b44b1b85 JW |
1097 | for (ptr = unwind.current_entry; ptr; ptr = ptr->next) |
1098 | { | |
9c59842f | 1099 | switch (ptr->r.type) |
b44b1b85 | 1100 | { |
9c59842f JW |
1101 | case prologue: |
1102 | case prologue_gr: | |
1103 | case body: | |
1104 | case endp: | |
b44b1b85 JW |
1105 | ptr->slot_number = (unsigned long) frag_more (0); |
1106 | ptr->slot_frag = frag_now; | |
9c59842f JW |
1107 | break; |
1108 | ||
1109 | /* Allow any record which doesn't have a "t" field (i.e., | |
1110 | doesn't relate to a particular instruction). */ | |
1111 | case unwabi: | |
1112 | case br_gr: | |
1113 | case copy_state: | |
1114 | case fr_mem: | |
1115 | case frgr_mem: | |
1116 | case gr_gr: | |
1117 | case gr_mem: | |
1118 | case label_state: | |
1119 | case rp_br: | |
1120 | case spill_base: | |
1121 | case spill_mask: | |
1122 | /* nothing */ | |
1123 | break; | |
1124 | ||
1125 | default: | |
1126 | as_bad (_("Unwind directive not followed by an instruction.")); | |
1127 | break; | |
b44b1b85 | 1128 | } |
b44b1b85 JW |
1129 | } |
1130 | unwind.current_entry = NULL; | |
1131 | ||
800eeca4 | 1132 | subseg_set (saved_seg, saved_subseg); |
f1bcba5b JW |
1133 | |
1134 | if (md.qp.X_op == O_register) | |
1135 | as_bad ("qualifying predicate not followed by instruction"); | |
800eeca4 JW |
1136 | } |
1137 | ||
1138 | void | |
1139 | ia64_do_align (nbytes) | |
1140 | int nbytes; | |
1141 | { | |
1142 | char *saved_input_line_pointer = input_line_pointer; | |
1143 | ||
1144 | input_line_pointer = ""; | |
1145 | s_align_bytes (nbytes); | |
1146 | input_line_pointer = saved_input_line_pointer; | |
1147 | } | |
1148 | ||
1149 | void | |
1150 | ia64_cons_align (nbytes) | |
1151 | int nbytes; | |
1152 | { | |
1153 | if (md.auto_align) | |
1154 | { | |
1155 | char *saved_input_line_pointer = input_line_pointer; | |
1156 | input_line_pointer = ""; | |
1157 | s_align_bytes (nbytes); | |
1158 | input_line_pointer = saved_input_line_pointer; | |
1159 | } | |
1160 | } | |
1161 | ||
1162 | /* Output COUNT bytes to a memory location. */ | |
1163 | static unsigned char *vbyte_mem_ptr = NULL; | |
1164 | ||
197865e8 | 1165 | void |
800eeca4 JW |
1166 | output_vbyte_mem (count, ptr, comment) |
1167 | int count; | |
1168 | char *ptr; | |
2434f565 | 1169 | char *comment ATTRIBUTE_UNUSED; |
800eeca4 JW |
1170 | { |
1171 | int x; | |
1172 | if (vbyte_mem_ptr == NULL) | |
1173 | abort (); | |
1174 | ||
1175 | if (count == 0) | |
1176 | return; | |
1177 | for (x = 0; x < count; x++) | |
1178 | *(vbyte_mem_ptr++) = ptr[x]; | |
1179 | } | |
1180 | ||
1181 | /* Count the number of bytes required for records. */ | |
1182 | static int vbyte_count = 0; | |
197865e8 | 1183 | void |
800eeca4 JW |
1184 | count_output (count, ptr, comment) |
1185 | int count; | |
2434f565 JW |
1186 | char *ptr ATTRIBUTE_UNUSED; |
1187 | char *comment ATTRIBUTE_UNUSED; | |
800eeca4 JW |
1188 | { |
1189 | vbyte_count += count; | |
1190 | } | |
1191 | ||
1192 | static void | |
1193 | output_R1_format (f, rtype, rlen) | |
1194 | vbyte_func f; | |
1195 | unw_record_type rtype; | |
1196 | int rlen; | |
1197 | { | |
e0c9811a | 1198 | int r = 0; |
800eeca4 JW |
1199 | char byte; |
1200 | if (rlen > 0x1f) | |
1201 | { | |
1202 | output_R3_format (f, rtype, rlen); | |
1203 | return; | |
1204 | } | |
197865e8 | 1205 | |
e0c9811a JW |
1206 | if (rtype == body) |
1207 | r = 1; | |
1208 | else if (rtype != prologue) | |
1209 | as_bad ("record type is not valid"); | |
1210 | ||
800eeca4 JW |
1211 | byte = UNW_R1 | (r << 5) | (rlen & 0x1f); |
1212 | (*f) (1, &byte, NULL); | |
1213 | } | |
1214 | ||
1215 | static void | |
1216 | output_R2_format (f, mask, grsave, rlen) | |
1217 | vbyte_func f; | |
1218 | int mask, grsave; | |
1219 | unsigned long rlen; | |
1220 | { | |
1221 | char bytes[20]; | |
1222 | int count = 2; | |
1223 | mask = (mask & 0x0f); | |
1224 | grsave = (grsave & 0x7f); | |
1225 | ||
1226 | bytes[0] = (UNW_R2 | (mask >> 1)); | |
1227 | bytes[1] = (((mask & 0x01) << 7) | grsave); | |
1228 | count += output_leb128 (bytes + 2, rlen, 0); | |
1229 | (*f) (count, bytes, NULL); | |
1230 | } | |
1231 | ||
1232 | static void | |
1233 | output_R3_format (f, rtype, rlen) | |
1234 | vbyte_func f; | |
1235 | unw_record_type rtype; | |
1236 | unsigned long rlen; | |
1237 | { | |
e0c9811a | 1238 | int r = 0, count; |
800eeca4 JW |
1239 | char bytes[20]; |
1240 | if (rlen <= 0x1f) | |
1241 | { | |
1242 | output_R1_format (f, rtype, rlen); | |
1243 | return; | |
1244 | } | |
197865e8 | 1245 | |
e0c9811a JW |
1246 | if (rtype == body) |
1247 | r = 1; | |
1248 | else if (rtype != prologue) | |
1249 | as_bad ("record type is not valid"); | |
800eeca4 JW |
1250 | bytes[0] = (UNW_R3 | r); |
1251 | count = output_leb128 (bytes + 1, rlen, 0); | |
1252 | (*f) (count + 1, bytes, NULL); | |
1253 | } | |
1254 | ||
1255 | static void | |
1256 | output_P1_format (f, brmask) | |
1257 | vbyte_func f; | |
1258 | int brmask; | |
1259 | { | |
1260 | char byte; | |
1261 | byte = UNW_P1 | (brmask & 0x1f); | |
1262 | (*f) (1, &byte, NULL); | |
1263 | } | |
1264 | ||
1265 | static void | |
1266 | output_P2_format (f, brmask, gr) | |
1267 | vbyte_func f; | |
1268 | int brmask; | |
1269 | int gr; | |
1270 | { | |
1271 | char bytes[2]; | |
1272 | brmask = (brmask & 0x1f); | |
1273 | bytes[0] = UNW_P2 | (brmask >> 1); | |
1274 | bytes[1] = (((brmask & 1) << 7) | gr); | |
1275 | (*f) (2, bytes, NULL); | |
1276 | } | |
1277 | ||
1278 | static void | |
1279 | output_P3_format (f, rtype, reg) | |
1280 | vbyte_func f; | |
1281 | unw_record_type rtype; | |
1282 | int reg; | |
1283 | { | |
1284 | char bytes[2]; | |
e0c9811a | 1285 | int r = 0; |
800eeca4 JW |
1286 | reg = (reg & 0x7f); |
1287 | switch (rtype) | |
542d6675 | 1288 | { |
800eeca4 JW |
1289 | case psp_gr: |
1290 | r = 0; | |
1291 | break; | |
1292 | case rp_gr: | |
1293 | r = 1; | |
1294 | break; | |
1295 | case pfs_gr: | |
1296 | r = 2; | |
1297 | break; | |
1298 | case preds_gr: | |
1299 | r = 3; | |
1300 | break; | |
1301 | case unat_gr: | |
1302 | r = 4; | |
1303 | break; | |
1304 | case lc_gr: | |
1305 | r = 5; | |
1306 | break; | |
1307 | case rp_br: | |
1308 | r = 6; | |
1309 | break; | |
1310 | case rnat_gr: | |
1311 | r = 7; | |
1312 | break; | |
1313 | case bsp_gr: | |
1314 | r = 8; | |
1315 | break; | |
1316 | case bspstore_gr: | |
1317 | r = 9; | |
1318 | break; | |
1319 | case fpsr_gr: | |
1320 | r = 10; | |
1321 | break; | |
1322 | case priunat_gr: | |
1323 | r = 11; | |
1324 | break; | |
1325 | default: | |
1326 | as_bad ("Invalid record type for P3 format."); | |
542d6675 | 1327 | } |
800eeca4 JW |
1328 | bytes[0] = (UNW_P3 | (r >> 1)); |
1329 | bytes[1] = (((r & 1) << 7) | reg); | |
1330 | (*f) (2, bytes, NULL); | |
1331 | } | |
1332 | ||
800eeca4 | 1333 | static void |
e0c9811a | 1334 | output_P4_format (f, imask, imask_size) |
800eeca4 | 1335 | vbyte_func f; |
e0c9811a JW |
1336 | unsigned char *imask; |
1337 | unsigned long imask_size; | |
800eeca4 | 1338 | { |
e0c9811a JW |
1339 | imask[0] = UNW_P4; |
1340 | (*f) (imask_size, imask, NULL); | |
800eeca4 JW |
1341 | } |
1342 | ||
1343 | static void | |
1344 | output_P5_format (f, grmask, frmask) | |
1345 | vbyte_func f; | |
1346 | int grmask; | |
1347 | unsigned long frmask; | |
1348 | { | |
1349 | char bytes[4]; | |
1350 | grmask = (grmask & 0x0f); | |
1351 | ||
1352 | bytes[0] = UNW_P5; | |
1353 | bytes[1] = ((grmask << 4) | ((frmask & 0x000f0000) >> 16)); | |
1354 | bytes[2] = ((frmask & 0x0000ff00) >> 8); | |
1355 | bytes[3] = (frmask & 0x000000ff); | |
1356 | (*f) (4, bytes, NULL); | |
1357 | } | |
1358 | ||
1359 | static void | |
1360 | output_P6_format (f, rtype, rmask) | |
1361 | vbyte_func f; | |
1362 | unw_record_type rtype; | |
1363 | int rmask; | |
1364 | { | |
1365 | char byte; | |
e0c9811a | 1366 | int r = 0; |
197865e8 | 1367 | |
e0c9811a JW |
1368 | if (rtype == gr_mem) |
1369 | r = 1; | |
1370 | else if (rtype != fr_mem) | |
1371 | as_bad ("Invalid record type for format P6"); | |
800eeca4 JW |
1372 | byte = (UNW_P6 | (r << 4) | (rmask & 0x0f)); |
1373 | (*f) (1, &byte, NULL); | |
1374 | } | |
1375 | ||
1376 | static void | |
1377 | output_P7_format (f, rtype, w1, w2) | |
1378 | vbyte_func f; | |
1379 | unw_record_type rtype; | |
1380 | unsigned long w1; | |
1381 | unsigned long w2; | |
1382 | { | |
1383 | char bytes[20]; | |
1384 | int count = 1; | |
e0c9811a | 1385 | int r = 0; |
800eeca4 JW |
1386 | count += output_leb128 (bytes + 1, w1, 0); |
1387 | switch (rtype) | |
1388 | { | |
542d6675 KH |
1389 | case mem_stack_f: |
1390 | r = 0; | |
1391 | count += output_leb128 (bytes + count, w2 >> 4, 0); | |
1392 | break; | |
1393 | case mem_stack_v: | |
1394 | r = 1; | |
1395 | break; | |
1396 | case spill_base: | |
1397 | r = 2; | |
1398 | break; | |
1399 | case psp_sprel: | |
1400 | r = 3; | |
1401 | break; | |
1402 | case rp_when: | |
1403 | r = 4; | |
1404 | break; | |
1405 | case rp_psprel: | |
1406 | r = 5; | |
1407 | break; | |
1408 | case pfs_when: | |
1409 | r = 6; | |
1410 | break; | |
1411 | case pfs_psprel: | |
1412 | r = 7; | |
1413 | break; | |
1414 | case preds_when: | |
1415 | r = 8; | |
1416 | break; | |
1417 | case preds_psprel: | |
1418 | r = 9; | |
1419 | break; | |
1420 | case lc_when: | |
1421 | r = 10; | |
1422 | break; | |
1423 | case lc_psprel: | |
1424 | r = 11; | |
1425 | break; | |
1426 | case unat_when: | |
1427 | r = 12; | |
1428 | break; | |
1429 | case unat_psprel: | |
1430 | r = 13; | |
1431 | break; | |
1432 | case fpsr_when: | |
1433 | r = 14; | |
1434 | break; | |
1435 | case fpsr_psprel: | |
1436 | r = 15; | |
1437 | break; | |
1438 | default: | |
1439 | break; | |
800eeca4 JW |
1440 | } |
1441 | bytes[0] = (UNW_P7 | r); | |
1442 | (*f) (count, bytes, NULL); | |
1443 | } | |
1444 | ||
1445 | static void | |
1446 | output_P8_format (f, rtype, t) | |
1447 | vbyte_func f; | |
1448 | unw_record_type rtype; | |
1449 | unsigned long t; | |
1450 | { | |
1451 | char bytes[20]; | |
e0c9811a | 1452 | int r = 0; |
800eeca4 JW |
1453 | int count = 2; |
1454 | bytes[0] = UNW_P8; | |
1455 | switch (rtype) | |
1456 | { | |
542d6675 KH |
1457 | case rp_sprel: |
1458 | r = 1; | |
1459 | break; | |
1460 | case pfs_sprel: | |
1461 | r = 2; | |
1462 | break; | |
1463 | case preds_sprel: | |
1464 | r = 3; | |
1465 | break; | |
1466 | case lc_sprel: | |
1467 | r = 4; | |
1468 | break; | |
1469 | case unat_sprel: | |
1470 | r = 5; | |
1471 | break; | |
1472 | case fpsr_sprel: | |
1473 | r = 6; | |
1474 | break; | |
1475 | case bsp_when: | |
1476 | r = 7; | |
1477 | break; | |
1478 | case bsp_psprel: | |
1479 | r = 8; | |
1480 | break; | |
1481 | case bsp_sprel: | |
1482 | r = 9; | |
1483 | break; | |
1484 | case bspstore_when: | |
1485 | r = 10; | |
1486 | break; | |
1487 | case bspstore_psprel: | |
1488 | r = 11; | |
1489 | break; | |
1490 | case bspstore_sprel: | |
1491 | r = 12; | |
1492 | break; | |
1493 | case rnat_when: | |
1494 | r = 13; | |
1495 | break; | |
1496 | case rnat_psprel: | |
1497 | r = 14; | |
1498 | break; | |
1499 | case rnat_sprel: | |
1500 | r = 15; | |
1501 | break; | |
1502 | case priunat_when_gr: | |
1503 | r = 16; | |
1504 | break; | |
1505 | case priunat_psprel: | |
1506 | r = 17; | |
1507 | break; | |
1508 | case priunat_sprel: | |
1509 | r = 18; | |
1510 | break; | |
1511 | case priunat_when_mem: | |
1512 | r = 19; | |
1513 | break; | |
1514 | default: | |
1515 | break; | |
800eeca4 JW |
1516 | } |
1517 | bytes[1] = r; | |
1518 | count += output_leb128 (bytes + 2, t, 0); | |
1519 | (*f) (count, bytes, NULL); | |
1520 | } | |
1521 | ||
1522 | static void | |
1523 | output_P9_format (f, grmask, gr) | |
1524 | vbyte_func f; | |
1525 | int grmask; | |
1526 | int gr; | |
1527 | { | |
1528 | char bytes[3]; | |
1529 | bytes[0] = UNW_P9; | |
1530 | bytes[1] = (grmask & 0x0f); | |
1531 | bytes[2] = (gr & 0x7f); | |
1532 | (*f) (3, bytes, NULL); | |
1533 | } | |
1534 | ||
1535 | static void | |
1536 | output_P10_format (f, abi, context) | |
1537 | vbyte_func f; | |
1538 | int abi; | |
1539 | int context; | |
1540 | { | |
1541 | char bytes[3]; | |
1542 | bytes[0] = UNW_P10; | |
1543 | bytes[1] = (abi & 0xff); | |
1544 | bytes[2] = (context & 0xff); | |
1545 | (*f) (3, bytes, NULL); | |
1546 | } | |
1547 | ||
1548 | static void | |
1549 | output_B1_format (f, rtype, label) | |
1550 | vbyte_func f; | |
1551 | unw_record_type rtype; | |
1552 | unsigned long label; | |
1553 | { | |
1554 | char byte; | |
e0c9811a | 1555 | int r = 0; |
197865e8 | 1556 | if (label > 0x1f) |
800eeca4 JW |
1557 | { |
1558 | output_B4_format (f, rtype, label); | |
1559 | return; | |
1560 | } | |
e0c9811a JW |
1561 | if (rtype == copy_state) |
1562 | r = 1; | |
1563 | else if (rtype != label_state) | |
1564 | as_bad ("Invalid record type for format B1"); | |
800eeca4 JW |
1565 | |
1566 | byte = (UNW_B1 | (r << 5) | (label & 0x1f)); | |
1567 | (*f) (1, &byte, NULL); | |
1568 | } | |
1569 | ||
1570 | static void | |
1571 | output_B2_format (f, ecount, t) | |
1572 | vbyte_func f; | |
1573 | unsigned long ecount; | |
1574 | unsigned long t; | |
1575 | { | |
1576 | char bytes[20]; | |
1577 | int count = 1; | |
1578 | if (ecount > 0x1f) | |
1579 | { | |
1580 | output_B3_format (f, ecount, t); | |
1581 | return; | |
1582 | } | |
1583 | bytes[0] = (UNW_B2 | (ecount & 0x1f)); | |
1584 | count += output_leb128 (bytes + 1, t, 0); | |
1585 | (*f) (count, bytes, NULL); | |
1586 | } | |
1587 | ||
1588 | static void | |
1589 | output_B3_format (f, ecount, t) | |
1590 | vbyte_func f; | |
1591 | unsigned long ecount; | |
1592 | unsigned long t; | |
1593 | { | |
1594 | char bytes[20]; | |
1595 | int count = 1; | |
1596 | if (ecount <= 0x1f) | |
1597 | { | |
1598 | output_B2_format (f, ecount, t); | |
1599 | return; | |
1600 | } | |
1601 | bytes[0] = UNW_B3; | |
1602 | count += output_leb128 (bytes + 1, t, 0); | |
1603 | count += output_leb128 (bytes + count, ecount, 0); | |
1604 | (*f) (count, bytes, NULL); | |
1605 | } | |
1606 | ||
1607 | static void | |
1608 | output_B4_format (f, rtype, label) | |
1609 | vbyte_func f; | |
1610 | unw_record_type rtype; | |
1611 | unsigned long label; | |
1612 | { | |
1613 | char bytes[20]; | |
e0c9811a | 1614 | int r = 0; |
800eeca4 | 1615 | int count = 1; |
197865e8 | 1616 | if (label <= 0x1f) |
800eeca4 JW |
1617 | { |
1618 | output_B1_format (f, rtype, label); | |
1619 | return; | |
1620 | } | |
197865e8 | 1621 | |
e0c9811a JW |
1622 | if (rtype == copy_state) |
1623 | r = 1; | |
1624 | else if (rtype != label_state) | |
1625 | as_bad ("Invalid record type for format B1"); | |
800eeca4 JW |
1626 | |
1627 | bytes[0] = (UNW_B4 | (r << 3)); | |
1628 | count += output_leb128 (bytes + 1, label, 0); | |
1629 | (*f) (count, bytes, NULL); | |
1630 | } | |
1631 | ||
1632 | static char | |
e0c9811a | 1633 | format_ab_reg (ab, reg) |
542d6675 KH |
1634 | int ab; |
1635 | int reg; | |
800eeca4 JW |
1636 | { |
1637 | int ret; | |
e0c9811a | 1638 | ab = (ab & 3); |
800eeca4 | 1639 | reg = (reg & 0x1f); |
e0c9811a | 1640 | ret = (ab << 5) | reg; |
800eeca4 JW |
1641 | return ret; |
1642 | } | |
1643 | ||
1644 | static void | |
e0c9811a | 1645 | output_X1_format (f, rtype, ab, reg, t, w1) |
800eeca4 JW |
1646 | vbyte_func f; |
1647 | unw_record_type rtype; | |
e0c9811a | 1648 | int ab, reg; |
800eeca4 JW |
1649 | unsigned long t; |
1650 | unsigned long w1; | |
1651 | { | |
1652 | char bytes[20]; | |
e0c9811a | 1653 | int r = 0; |
800eeca4 JW |
1654 | int count = 2; |
1655 | bytes[0] = UNW_X1; | |
197865e8 | 1656 | |
e0c9811a JW |
1657 | if (rtype == spill_sprel) |
1658 | r = 1; | |
1659 | else if (rtype != spill_psprel) | |
1660 | as_bad ("Invalid record type for format X1"); | |
1661 | bytes[1] = ((r << 7) | format_ab_reg (ab, reg)); | |
800eeca4 JW |
1662 | count += output_leb128 (bytes + 2, t, 0); |
1663 | count += output_leb128 (bytes + count, w1, 0); | |
1664 | (*f) (count, bytes, NULL); | |
1665 | } | |
1666 | ||
1667 | static void | |
e0c9811a | 1668 | output_X2_format (f, ab, reg, x, y, treg, t) |
800eeca4 | 1669 | vbyte_func f; |
e0c9811a | 1670 | int ab, reg; |
800eeca4 JW |
1671 | int x, y, treg; |
1672 | unsigned long t; | |
1673 | { | |
1674 | char bytes[20]; | |
800eeca4 JW |
1675 | int count = 3; |
1676 | bytes[0] = UNW_X2; | |
e0c9811a | 1677 | bytes[1] = (((x & 1) << 7) | format_ab_reg (ab, reg)); |
800eeca4 JW |
1678 | bytes[2] = (((y & 1) << 7) | (treg & 0x7f)); |
1679 | count += output_leb128 (bytes + 3, t, 0); | |
1680 | (*f) (count, bytes, NULL); | |
1681 | } | |
1682 | ||
1683 | static void | |
e0c9811a | 1684 | output_X3_format (f, rtype, qp, ab, reg, t, w1) |
800eeca4 JW |
1685 | vbyte_func f; |
1686 | unw_record_type rtype; | |
1687 | int qp; | |
e0c9811a | 1688 | int ab, reg; |
800eeca4 JW |
1689 | unsigned long t; |
1690 | unsigned long w1; | |
1691 | { | |
1692 | char bytes[20]; | |
e0c9811a | 1693 | int r = 0; |
800eeca4 | 1694 | int count = 3; |
e0c9811a JW |
1695 | bytes[0] = UNW_X3; |
1696 | ||
1697 | if (rtype == spill_sprel_p) | |
1698 | r = 1; | |
1699 | else if (rtype != spill_psprel_p) | |
1700 | as_bad ("Invalid record type for format X3"); | |
800eeca4 | 1701 | bytes[1] = ((r << 7) | (qp & 0x3f)); |
e0c9811a | 1702 | bytes[2] = format_ab_reg (ab, reg); |
800eeca4 JW |
1703 | count += output_leb128 (bytes + 3, t, 0); |
1704 | count += output_leb128 (bytes + count, w1, 0); | |
1705 | (*f) (count, bytes, NULL); | |
1706 | } | |
1707 | ||
1708 | static void | |
e0c9811a | 1709 | output_X4_format (f, qp, ab, reg, x, y, treg, t) |
800eeca4 JW |
1710 | vbyte_func f; |
1711 | int qp; | |
e0c9811a | 1712 | int ab, reg; |
800eeca4 JW |
1713 | int x, y, treg; |
1714 | unsigned long t; | |
1715 | { | |
1716 | char bytes[20]; | |
800eeca4 | 1717 | int count = 4; |
e0c9811a | 1718 | bytes[0] = UNW_X4; |
800eeca4 | 1719 | bytes[1] = (qp & 0x3f); |
e0c9811a | 1720 | bytes[2] = (((x & 1) << 7) | format_ab_reg (ab, reg)); |
800eeca4 JW |
1721 | bytes[3] = (((y & 1) << 7) | (treg & 0x7f)); |
1722 | count += output_leb128 (bytes + 4, t, 0); | |
1723 | (*f) (count, bytes, NULL); | |
1724 | } | |
1725 | ||
1726 | /* This function allocates a record list structure, and initializes fields. */ | |
542d6675 | 1727 | |
800eeca4 | 1728 | static unw_rec_list * |
197865e8 | 1729 | alloc_record (unw_record_type t) |
800eeca4 JW |
1730 | { |
1731 | unw_rec_list *ptr; | |
1732 | ptr = xmalloc (sizeof (*ptr)); | |
1733 | ptr->next = NULL; | |
1734 | ptr->slot_number = SLOT_NUM_NOT_SET; | |
1735 | ptr->r.type = t; | |
73f20958 L |
1736 | ptr->next_slot_number = 0; |
1737 | ptr->next_slot_frag = 0; | |
800eeca4 JW |
1738 | return ptr; |
1739 | } | |
1740 | ||
5738bc24 JW |
1741 | /* Dummy unwind record used for calculating the length of the last prologue or |
1742 | body region. */ | |
1743 | ||
1744 | static unw_rec_list * | |
1745 | output_endp () | |
1746 | { | |
1747 | unw_rec_list *ptr = alloc_record (endp); | |
1748 | return ptr; | |
1749 | } | |
1750 | ||
800eeca4 JW |
1751 | static unw_rec_list * |
1752 | output_prologue () | |
1753 | { | |
1754 | unw_rec_list *ptr = alloc_record (prologue); | |
e0c9811a | 1755 | memset (&ptr->r.record.r.mask, 0, sizeof (ptr->r.record.r.mask)); |
800eeca4 JW |
1756 | return ptr; |
1757 | } | |
1758 | ||
1759 | static unw_rec_list * | |
1760 | output_prologue_gr (saved_mask, reg) | |
1761 | unsigned int saved_mask; | |
1762 | unsigned int reg; | |
1763 | { | |
1764 | unw_rec_list *ptr = alloc_record (prologue_gr); | |
e0c9811a JW |
1765 | memset (&ptr->r.record.r.mask, 0, sizeof (ptr->r.record.r.mask)); |
1766 | ptr->r.record.r.grmask = saved_mask; | |
800eeca4 JW |
1767 | ptr->r.record.r.grsave = reg; |
1768 | return ptr; | |
1769 | } | |
1770 | ||
1771 | static unw_rec_list * | |
1772 | output_body () | |
1773 | { | |
1774 | unw_rec_list *ptr = alloc_record (body); | |
1775 | return ptr; | |
1776 | } | |
1777 | ||
1778 | static unw_rec_list * | |
1779 | output_mem_stack_f (size) | |
1780 | unsigned int size; | |
1781 | { | |
1782 | unw_rec_list *ptr = alloc_record (mem_stack_f); | |
1783 | ptr->r.record.p.size = size; | |
1784 | return ptr; | |
1785 | } | |
1786 | ||
1787 | static unw_rec_list * | |
1788 | output_mem_stack_v () | |
1789 | { | |
1790 | unw_rec_list *ptr = alloc_record (mem_stack_v); | |
1791 | return ptr; | |
1792 | } | |
1793 | ||
1794 | static unw_rec_list * | |
1795 | output_psp_gr (gr) | |
1796 | unsigned int gr; | |
1797 | { | |
1798 | unw_rec_list *ptr = alloc_record (psp_gr); | |
1799 | ptr->r.record.p.gr = gr; | |
1800 | return ptr; | |
1801 | } | |
1802 | ||
1803 | static unw_rec_list * | |
1804 | output_psp_sprel (offset) | |
1805 | unsigned int offset; | |
1806 | { | |
1807 | unw_rec_list *ptr = alloc_record (psp_sprel); | |
542d6675 | 1808 | ptr->r.record.p.spoff = offset / 4; |
800eeca4 JW |
1809 | return ptr; |
1810 | } | |
1811 | ||
1812 | static unw_rec_list * | |
1813 | output_rp_when () | |
1814 | { | |
1815 | unw_rec_list *ptr = alloc_record (rp_when); | |
1816 | return ptr; | |
1817 | } | |
1818 | ||
1819 | static unw_rec_list * | |
1820 | output_rp_gr (gr) | |
1821 | unsigned int gr; | |
1822 | { | |
1823 | unw_rec_list *ptr = alloc_record (rp_gr); | |
1824 | ptr->r.record.p.gr = gr; | |
1825 | return ptr; | |
1826 | } | |
1827 | ||
1828 | static unw_rec_list * | |
1829 | output_rp_br (br) | |
1830 | unsigned int br; | |
1831 | { | |
1832 | unw_rec_list *ptr = alloc_record (rp_br); | |
1833 | ptr->r.record.p.br = br; | |
1834 | return ptr; | |
1835 | } | |
1836 | ||
1837 | static unw_rec_list * | |
1838 | output_rp_psprel (offset) | |
1839 | unsigned int offset; | |
1840 | { | |
1841 | unw_rec_list *ptr = alloc_record (rp_psprel); | |
542d6675 | 1842 | ptr->r.record.p.pspoff = offset / 4; |
800eeca4 JW |
1843 | return ptr; |
1844 | } | |
1845 | ||
1846 | static unw_rec_list * | |
1847 | output_rp_sprel (offset) | |
1848 | unsigned int offset; | |
1849 | { | |
1850 | unw_rec_list *ptr = alloc_record (rp_sprel); | |
542d6675 | 1851 | ptr->r.record.p.spoff = offset / 4; |
800eeca4 JW |
1852 | return ptr; |
1853 | } | |
1854 | ||
1855 | static unw_rec_list * | |
1856 | output_pfs_when () | |
1857 | { | |
1858 | unw_rec_list *ptr = alloc_record (pfs_when); | |
1859 | return ptr; | |
1860 | } | |
1861 | ||
1862 | static unw_rec_list * | |
1863 | output_pfs_gr (gr) | |
1864 | unsigned int gr; | |
1865 | { | |
1866 | unw_rec_list *ptr = alloc_record (pfs_gr); | |
1867 | ptr->r.record.p.gr = gr; | |
1868 | return ptr; | |
1869 | } | |
1870 | ||
1871 | static unw_rec_list * | |
1872 | output_pfs_psprel (offset) | |
1873 | unsigned int offset; | |
1874 | { | |
1875 | unw_rec_list *ptr = alloc_record (pfs_psprel); | |
542d6675 | 1876 | ptr->r.record.p.pspoff = offset / 4; |
800eeca4 JW |
1877 | return ptr; |
1878 | } | |
1879 | ||
1880 | static unw_rec_list * | |
1881 | output_pfs_sprel (offset) | |
1882 | unsigned int offset; | |
1883 | { | |
1884 | unw_rec_list *ptr = alloc_record (pfs_sprel); | |
542d6675 | 1885 | ptr->r.record.p.spoff = offset / 4; |
800eeca4 JW |
1886 | return ptr; |
1887 | } | |
1888 | ||
1889 | static unw_rec_list * | |
1890 | output_preds_when () | |
1891 | { | |
1892 | unw_rec_list *ptr = alloc_record (preds_when); | |
1893 | return ptr; | |
1894 | } | |
1895 | ||
1896 | static unw_rec_list * | |
1897 | output_preds_gr (gr) | |
1898 | unsigned int gr; | |
1899 | { | |
1900 | unw_rec_list *ptr = alloc_record (preds_gr); | |
1901 | ptr->r.record.p.gr = gr; | |
1902 | return ptr; | |
1903 | } | |
1904 | ||
1905 | static unw_rec_list * | |
1906 | output_preds_psprel (offset) | |
1907 | unsigned int offset; | |
1908 | { | |
1909 | unw_rec_list *ptr = alloc_record (preds_psprel); | |
542d6675 | 1910 | ptr->r.record.p.pspoff = offset / 4; |
800eeca4 JW |
1911 | return ptr; |
1912 | } | |
1913 | ||
1914 | static unw_rec_list * | |
1915 | output_preds_sprel (offset) | |
1916 | unsigned int offset; | |
1917 | { | |
1918 | unw_rec_list *ptr = alloc_record (preds_sprel); | |
542d6675 | 1919 | ptr->r.record.p.spoff = offset / 4; |
800eeca4 JW |
1920 | return ptr; |
1921 | } | |
1922 | ||
1923 | static unw_rec_list * | |
1924 | output_fr_mem (mask) | |
1925 | unsigned int mask; | |
1926 | { | |
1927 | unw_rec_list *ptr = alloc_record (fr_mem); | |
1928 | ptr->r.record.p.rmask = mask; | |
1929 | return ptr; | |
1930 | } | |
1931 | ||
1932 | static unw_rec_list * | |
1933 | output_frgr_mem (gr_mask, fr_mask) | |
1934 | unsigned int gr_mask; | |
1935 | unsigned int fr_mask; | |
1936 | { | |
1937 | unw_rec_list *ptr = alloc_record (frgr_mem); | |
1938 | ptr->r.record.p.grmask = gr_mask; | |
1939 | ptr->r.record.p.frmask = fr_mask; | |
1940 | return ptr; | |
1941 | } | |
1942 | ||
1943 | static unw_rec_list * | |
1944 | output_gr_gr (mask, reg) | |
1945 | unsigned int mask; | |
1946 | unsigned int reg; | |
1947 | { | |
1948 | unw_rec_list *ptr = alloc_record (gr_gr); | |
1949 | ptr->r.record.p.grmask = mask; | |
1950 | ptr->r.record.p.gr = reg; | |
1951 | return ptr; | |
1952 | } | |
1953 | ||
1954 | static unw_rec_list * | |
1955 | output_gr_mem (mask) | |
1956 | unsigned int mask; | |
1957 | { | |
1958 | unw_rec_list *ptr = alloc_record (gr_mem); | |
1959 | ptr->r.record.p.rmask = mask; | |
1960 | return ptr; | |
1961 | } | |
1962 | ||
1963 | static unw_rec_list * | |
1964 | output_br_mem (unsigned int mask) | |
1965 | { | |
1966 | unw_rec_list *ptr = alloc_record (br_mem); | |
1967 | ptr->r.record.p.brmask = mask; | |
1968 | return ptr; | |
1969 | } | |
1970 | ||
1971 | static unw_rec_list * | |
1972 | output_br_gr (save_mask, reg) | |
1973 | unsigned int save_mask; | |
1974 | unsigned int reg; | |
1975 | { | |
1976 | unw_rec_list *ptr = alloc_record (br_gr); | |
1977 | ptr->r.record.p.brmask = save_mask; | |
1978 | ptr->r.record.p.gr = reg; | |
1979 | return ptr; | |
1980 | } | |
1981 | ||
1982 | static unw_rec_list * | |
1983 | output_spill_base (offset) | |
1984 | unsigned int offset; | |
1985 | { | |
1986 | unw_rec_list *ptr = alloc_record (spill_base); | |
542d6675 | 1987 | ptr->r.record.p.pspoff = offset / 4; |
800eeca4 JW |
1988 | return ptr; |
1989 | } | |
1990 | ||
1991 | static unw_rec_list * | |
1992 | output_unat_when () | |
1993 | { | |
1994 | unw_rec_list *ptr = alloc_record (unat_when); | |
1995 | return ptr; | |
1996 | } | |
1997 | ||
1998 | static unw_rec_list * | |
1999 | output_unat_gr (gr) | |
2000 | unsigned int gr; | |
2001 | { | |
2002 | unw_rec_list *ptr = alloc_record (unat_gr); | |
2003 | ptr->r.record.p.gr = gr; | |
2004 | return ptr; | |
2005 | } | |
2006 | ||
2007 | static unw_rec_list * | |
2008 | output_unat_psprel (offset) | |
2009 | unsigned int offset; | |
2010 | { | |
2011 | unw_rec_list *ptr = alloc_record (unat_psprel); | |
542d6675 | 2012 | ptr->r.record.p.pspoff = offset / 4; |
800eeca4 JW |
2013 | return ptr; |
2014 | } | |
2015 | ||
2016 | static unw_rec_list * | |
2017 | output_unat_sprel (offset) | |
2018 | unsigned int offset; | |
2019 | { | |
2020 | unw_rec_list *ptr = alloc_record (unat_sprel); | |
542d6675 | 2021 | ptr->r.record.p.spoff = offset / 4; |
800eeca4 JW |
2022 | return ptr; |
2023 | } | |
2024 | ||
2025 | static unw_rec_list * | |
2026 | output_lc_when () | |
2027 | { | |
2028 | unw_rec_list *ptr = alloc_record (lc_when); | |
2029 | return ptr; | |
2030 | } | |
2031 | ||
2032 | static unw_rec_list * | |
2033 | output_lc_gr (gr) | |
2034 | unsigned int gr; | |
2035 | { | |
2036 | unw_rec_list *ptr = alloc_record (lc_gr); | |
2037 | ptr->r.record.p.gr = gr; | |
2038 | return ptr; | |
2039 | } | |
2040 | ||
2041 | static unw_rec_list * | |
2042 | output_lc_psprel (offset) | |
2043 | unsigned int offset; | |
2044 | { | |
2045 | unw_rec_list *ptr = alloc_record (lc_psprel); | |
542d6675 | 2046 | ptr->r.record.p.pspoff = offset / 4; |
800eeca4 JW |
2047 | return ptr; |
2048 | } | |
2049 | ||
2050 | static unw_rec_list * | |
2051 | output_lc_sprel (offset) | |
2052 | unsigned int offset; | |
2053 | { | |
2054 | unw_rec_list *ptr = alloc_record (lc_sprel); | |
542d6675 | 2055 | ptr->r.record.p.spoff = offset / 4; |
800eeca4 JW |
2056 | return ptr; |
2057 | } | |
2058 | ||
2059 | static unw_rec_list * | |
2060 | output_fpsr_when () | |
2061 | { | |
2062 | unw_rec_list *ptr = alloc_record (fpsr_when); | |
2063 | return ptr; | |
2064 | } | |
2065 | ||
2066 | static unw_rec_list * | |
2067 | output_fpsr_gr (gr) | |
2068 | unsigned int gr; | |
2069 | { | |
2070 | unw_rec_list *ptr = alloc_record (fpsr_gr); | |
2071 | ptr->r.record.p.gr = gr; | |
2072 | return ptr; | |
2073 | } | |
2074 | ||
2075 | static unw_rec_list * | |
2076 | output_fpsr_psprel (offset) | |
2077 | unsigned int offset; | |
2078 | { | |
2079 | unw_rec_list *ptr = alloc_record (fpsr_psprel); | |
542d6675 | 2080 | ptr->r.record.p.pspoff = offset / 4; |
800eeca4 JW |
2081 | return ptr; |
2082 | } | |
2083 | ||
2084 | static unw_rec_list * | |
2085 | output_fpsr_sprel (offset) | |
2086 | unsigned int offset; | |
2087 | { | |
2088 | unw_rec_list *ptr = alloc_record (fpsr_sprel); | |
542d6675 | 2089 | ptr->r.record.p.spoff = offset / 4; |
800eeca4 JW |
2090 | return ptr; |
2091 | } | |
2092 | ||
2093 | static unw_rec_list * | |
2094 | output_priunat_when_gr () | |
2095 | { | |
2096 | unw_rec_list *ptr = alloc_record (priunat_when_gr); | |
2097 | return ptr; | |
2098 | } | |
2099 | ||
2100 | static unw_rec_list * | |
2101 | output_priunat_when_mem () | |
2102 | { | |
2103 | unw_rec_list *ptr = alloc_record (priunat_when_mem); | |
2104 | return ptr; | |
2105 | } | |
2106 | ||
2107 | static unw_rec_list * | |
2108 | output_priunat_gr (gr) | |
2109 | unsigned int gr; | |
2110 | { | |
2111 | unw_rec_list *ptr = alloc_record (priunat_gr); | |
2112 | ptr->r.record.p.gr = gr; | |
2113 | return ptr; | |
2114 | } | |
2115 | ||
2116 | static unw_rec_list * | |
2117 | output_priunat_psprel (offset) | |
2118 | unsigned int offset; | |
2119 | { | |
2120 | unw_rec_list *ptr = alloc_record (priunat_psprel); | |
542d6675 | 2121 | ptr->r.record.p.pspoff = offset / 4; |
800eeca4 JW |
2122 | return ptr; |
2123 | } | |
2124 | ||
2125 | static unw_rec_list * | |
2126 | output_priunat_sprel (offset) | |
2127 | unsigned int offset; | |
2128 | { | |
2129 | unw_rec_list *ptr = alloc_record (priunat_sprel); | |
542d6675 | 2130 | ptr->r.record.p.spoff = offset / 4; |
800eeca4 JW |
2131 | return ptr; |
2132 | } | |
2133 | ||
2134 | static unw_rec_list * | |
2135 | output_bsp_when () | |
2136 | { | |
2137 | unw_rec_list *ptr = alloc_record (bsp_when); | |
2138 | return ptr; | |
2139 | } | |
2140 | ||
2141 | static unw_rec_list * | |
2142 | output_bsp_gr (gr) | |
2143 | unsigned int gr; | |
2144 | { | |
2145 | unw_rec_list *ptr = alloc_record (bsp_gr); | |
2146 | ptr->r.record.p.gr = gr; | |
2147 | return ptr; | |
2148 | } | |
2149 | ||
2150 | static unw_rec_list * | |
2151 | output_bsp_psprel (offset) | |
2152 | unsigned int offset; | |
2153 | { | |
2154 | unw_rec_list *ptr = alloc_record (bsp_psprel); | |
542d6675 | 2155 | ptr->r.record.p.pspoff = offset / 4; |
800eeca4 JW |
2156 | return ptr; |
2157 | } | |
2158 | ||
2159 | static unw_rec_list * | |
2160 | output_bsp_sprel (offset) | |
2161 | unsigned int offset; | |
2162 | { | |
2163 | unw_rec_list *ptr = alloc_record (bsp_sprel); | |
542d6675 | 2164 | ptr->r.record.p.spoff = offset / 4; |
800eeca4 JW |
2165 | return ptr; |
2166 | } | |
2167 | ||
2168 | static unw_rec_list * | |
2169 | output_bspstore_when () | |
2170 | { | |
2171 | unw_rec_list *ptr = alloc_record (bspstore_when); | |
2172 | return ptr; | |
2173 | } | |
2174 | ||
2175 | static unw_rec_list * | |
2176 | output_bspstore_gr (gr) | |
2177 | unsigned int gr; | |
2178 | { | |
2179 | unw_rec_list *ptr = alloc_record (bspstore_gr); | |
2180 | ptr->r.record.p.gr = gr; | |
2181 | return ptr; | |
2182 | } | |
2183 | ||
2184 | static unw_rec_list * | |
2185 | output_bspstore_psprel (offset) | |
2186 | unsigned int offset; | |
2187 | { | |
2188 | unw_rec_list *ptr = alloc_record (bspstore_psprel); | |
542d6675 | 2189 | ptr->r.record.p.pspoff = offset / 4; |
800eeca4 JW |
2190 | return ptr; |
2191 | } | |
2192 | ||
2193 | static unw_rec_list * | |
2194 | output_bspstore_sprel (offset) | |
2195 | unsigned int offset; | |
2196 | { | |
2197 | unw_rec_list *ptr = alloc_record (bspstore_sprel); | |
542d6675 | 2198 | ptr->r.record.p.spoff = offset / 4; |
800eeca4 JW |
2199 | return ptr; |
2200 | } | |
2201 | ||
2202 | static unw_rec_list * | |
2203 | output_rnat_when () | |
2204 | { | |
2205 | unw_rec_list *ptr = alloc_record (rnat_when); | |
2206 | return ptr; | |
2207 | } | |
2208 | ||
2209 | static unw_rec_list * | |
2210 | output_rnat_gr (gr) | |
2211 | unsigned int gr; | |
2212 | { | |
2213 | unw_rec_list *ptr = alloc_record (rnat_gr); | |
2214 | ptr->r.record.p.gr = gr; | |
2215 | return ptr; | |
2216 | } | |
2217 | ||
2218 | static unw_rec_list * | |
2219 | output_rnat_psprel (offset) | |
2220 | unsigned int offset; | |
2221 | { | |
2222 | unw_rec_list *ptr = alloc_record (rnat_psprel); | |
542d6675 | 2223 | ptr->r.record.p.pspoff = offset / 4; |
800eeca4 JW |
2224 | return ptr; |
2225 | } | |
2226 | ||
2227 | static unw_rec_list * | |
2228 | output_rnat_sprel (offset) | |
2229 | unsigned int offset; | |
2230 | { | |
2231 | unw_rec_list *ptr = alloc_record (rnat_sprel); | |
542d6675 | 2232 | ptr->r.record.p.spoff = offset / 4; |
800eeca4 JW |
2233 | return ptr; |
2234 | } | |
2235 | ||
2236 | static unw_rec_list * | |
e0c9811a JW |
2237 | output_unwabi (abi, context) |
2238 | unsigned long abi; | |
2239 | unsigned long context; | |
800eeca4 | 2240 | { |
e0c9811a JW |
2241 | unw_rec_list *ptr = alloc_record (unwabi); |
2242 | ptr->r.record.p.abi = abi; | |
2243 | ptr->r.record.p.context = context; | |
800eeca4 JW |
2244 | return ptr; |
2245 | } | |
2246 | ||
2247 | static unw_rec_list * | |
e0c9811a | 2248 | output_epilogue (unsigned long ecount) |
800eeca4 | 2249 | { |
e0c9811a JW |
2250 | unw_rec_list *ptr = alloc_record (epilogue); |
2251 | ptr->r.record.b.ecount = ecount; | |
800eeca4 JW |
2252 | return ptr; |
2253 | } | |
2254 | ||
2255 | static unw_rec_list * | |
e0c9811a | 2256 | output_label_state (unsigned long label) |
800eeca4 | 2257 | { |
e0c9811a JW |
2258 | unw_rec_list *ptr = alloc_record (label_state); |
2259 | ptr->r.record.b.label = label; | |
800eeca4 JW |
2260 | return ptr; |
2261 | } | |
2262 | ||
2263 | static unw_rec_list * | |
e0c9811a JW |
2264 | output_copy_state (unsigned long label) |
2265 | { | |
2266 | unw_rec_list *ptr = alloc_record (copy_state); | |
2267 | ptr->r.record.b.label = label; | |
2268 | return ptr; | |
2269 | } | |
2270 | ||
2271 | static unw_rec_list * | |
2272 | output_spill_psprel (ab, reg, offset) | |
2273 | unsigned int ab; | |
800eeca4 JW |
2274 | unsigned int reg; |
2275 | unsigned int offset; | |
2276 | { | |
2277 | unw_rec_list *ptr = alloc_record (spill_psprel); | |
e0c9811a | 2278 | ptr->r.record.x.ab = ab; |
800eeca4 | 2279 | ptr->r.record.x.reg = reg; |
542d6675 | 2280 | ptr->r.record.x.pspoff = offset / 4; |
800eeca4 JW |
2281 | return ptr; |
2282 | } | |
2283 | ||
2284 | static unw_rec_list * | |
e0c9811a JW |
2285 | output_spill_sprel (ab, reg, offset) |
2286 | unsigned int ab; | |
800eeca4 JW |
2287 | unsigned int reg; |
2288 | unsigned int offset; | |
2289 | { | |
2290 | unw_rec_list *ptr = alloc_record (spill_sprel); | |
e0c9811a | 2291 | ptr->r.record.x.ab = ab; |
800eeca4 | 2292 | ptr->r.record.x.reg = reg; |
542d6675 | 2293 | ptr->r.record.x.spoff = offset / 4; |
800eeca4 JW |
2294 | return ptr; |
2295 | } | |
2296 | ||
2297 | static unw_rec_list * | |
e0c9811a JW |
2298 | output_spill_psprel_p (ab, reg, offset, predicate) |
2299 | unsigned int ab; | |
800eeca4 JW |
2300 | unsigned int reg; |
2301 | unsigned int offset; | |
2302 | unsigned int predicate; | |
2303 | { | |
2304 | unw_rec_list *ptr = alloc_record (spill_psprel_p); | |
e0c9811a | 2305 | ptr->r.record.x.ab = ab; |
800eeca4 | 2306 | ptr->r.record.x.reg = reg; |
542d6675 | 2307 | ptr->r.record.x.pspoff = offset / 4; |
800eeca4 JW |
2308 | ptr->r.record.x.qp = predicate; |
2309 | return ptr; | |
2310 | } | |
2311 | ||
2312 | static unw_rec_list * | |
e0c9811a JW |
2313 | output_spill_sprel_p (ab, reg, offset, predicate) |
2314 | unsigned int ab; | |
800eeca4 JW |
2315 | unsigned int reg; |
2316 | unsigned int offset; | |
2317 | unsigned int predicate; | |
2318 | { | |
2319 | unw_rec_list *ptr = alloc_record (spill_sprel_p); | |
e0c9811a | 2320 | ptr->r.record.x.ab = ab; |
800eeca4 | 2321 | ptr->r.record.x.reg = reg; |
542d6675 | 2322 | ptr->r.record.x.spoff = offset / 4; |
800eeca4 JW |
2323 | ptr->r.record.x.qp = predicate; |
2324 | return ptr; | |
2325 | } | |
2326 | ||
2327 | static unw_rec_list * | |
e0c9811a JW |
2328 | output_spill_reg (ab, reg, targ_reg, xy) |
2329 | unsigned int ab; | |
800eeca4 JW |
2330 | unsigned int reg; |
2331 | unsigned int targ_reg; | |
2332 | unsigned int xy; | |
2333 | { | |
2334 | unw_rec_list *ptr = alloc_record (spill_reg); | |
e0c9811a | 2335 | ptr->r.record.x.ab = ab; |
800eeca4 JW |
2336 | ptr->r.record.x.reg = reg; |
2337 | ptr->r.record.x.treg = targ_reg; | |
2338 | ptr->r.record.x.xy = xy; | |
2339 | return ptr; | |
2340 | } | |
2341 | ||
2342 | static unw_rec_list * | |
e0c9811a JW |
2343 | output_spill_reg_p (ab, reg, targ_reg, xy, predicate) |
2344 | unsigned int ab; | |
800eeca4 JW |
2345 | unsigned int reg; |
2346 | unsigned int targ_reg; | |
2347 | unsigned int xy; | |
2348 | unsigned int predicate; | |
2349 | { | |
2350 | unw_rec_list *ptr = alloc_record (spill_reg_p); | |
e0c9811a | 2351 | ptr->r.record.x.ab = ab; |
800eeca4 JW |
2352 | ptr->r.record.x.reg = reg; |
2353 | ptr->r.record.x.treg = targ_reg; | |
2354 | ptr->r.record.x.xy = xy; | |
2355 | ptr->r.record.x.qp = predicate; | |
2356 | return ptr; | |
2357 | } | |
2358 | ||
197865e8 | 2359 | /* Given a unw_rec_list process the correct format with the |
800eeca4 | 2360 | specified function. */ |
542d6675 | 2361 | |
800eeca4 JW |
2362 | static void |
2363 | process_one_record (ptr, f) | |
2364 | unw_rec_list *ptr; | |
2365 | vbyte_func f; | |
2366 | { | |
e0c9811a JW |
2367 | unsigned long fr_mask, gr_mask; |
2368 | ||
197865e8 | 2369 | switch (ptr->r.type) |
800eeca4 | 2370 | { |
5738bc24 JW |
2371 | /* This is a dummy record that takes up no space in the output. */ |
2372 | case endp: | |
2373 | break; | |
2374 | ||
542d6675 KH |
2375 | case gr_mem: |
2376 | case fr_mem: | |
2377 | case br_mem: | |
2378 | case frgr_mem: | |
2379 | /* These are taken care of by prologue/prologue_gr. */ | |
2380 | break; | |
e0c9811a | 2381 | |
542d6675 KH |
2382 | case prologue_gr: |
2383 | case prologue: | |
2384 | if (ptr->r.type == prologue_gr) | |
2385 | output_R2_format (f, ptr->r.record.r.grmask, | |
2386 | ptr->r.record.r.grsave, ptr->r.record.r.rlen); | |
2387 | else | |
800eeca4 | 2388 | output_R1_format (f, ptr->r.type, ptr->r.record.r.rlen); |
542d6675 KH |
2389 | |
2390 | /* Output descriptor(s) for union of register spills (if any). */ | |
2391 | gr_mask = ptr->r.record.r.mask.gr_mem; | |
2392 | fr_mask = ptr->r.record.r.mask.fr_mem; | |
2393 | if (fr_mask) | |
2394 | { | |
2395 | if ((fr_mask & ~0xfUL) == 0) | |
2396 | output_P6_format (f, fr_mem, fr_mask); | |
2397 | else | |
2398 | { | |
2399 | output_P5_format (f, gr_mask, fr_mask); | |
2400 | gr_mask = 0; | |
2401 | } | |
2402 | } | |
2403 | if (gr_mask) | |
2404 | output_P6_format (f, gr_mem, gr_mask); | |
2405 | if (ptr->r.record.r.mask.br_mem) | |
2406 | output_P1_format (f, ptr->r.record.r.mask.br_mem); | |
2407 | ||
2408 | /* output imask descriptor if necessary: */ | |
2409 | if (ptr->r.record.r.mask.i) | |
2410 | output_P4_format (f, ptr->r.record.r.mask.i, | |
2411 | ptr->r.record.r.imask_size); | |
2412 | break; | |
2413 | ||
2414 | case body: | |
2415 | output_R1_format (f, ptr->r.type, ptr->r.record.r.rlen); | |
2416 | break; | |
2417 | case mem_stack_f: | |
2418 | case mem_stack_v: | |
2419 | output_P7_format (f, ptr->r.type, ptr->r.record.p.t, | |
2420 | ptr->r.record.p.size); | |
2421 | break; | |
2422 | case psp_gr: | |
2423 | case rp_gr: | |
2424 | case pfs_gr: | |
2425 | case preds_gr: | |
2426 | case unat_gr: | |
2427 | case lc_gr: | |
2428 | case fpsr_gr: | |
2429 | case priunat_gr: | |
2430 | case bsp_gr: | |
2431 | case bspstore_gr: | |
2432 | case rnat_gr: | |
2433 | output_P3_format (f, ptr->r.type, ptr->r.record.p.gr); | |
2434 | break; | |
2435 | case rp_br: | |
2436 | output_P3_format (f, rp_br, ptr->r.record.p.br); | |
2437 | break; | |
2438 | case psp_sprel: | |
2439 | output_P7_format (f, psp_sprel, ptr->r.record.p.spoff, 0); | |
2440 | break; | |
2441 | case rp_when: | |
2442 | case pfs_when: | |
2443 | case preds_when: | |
2444 | case unat_when: | |
2445 | case lc_when: | |
2446 | case fpsr_when: | |
2447 | output_P7_format (f, ptr->r.type, ptr->r.record.p.t, 0); | |
2448 | break; | |
2449 | case rp_psprel: | |
2450 | case pfs_psprel: | |
2451 | case preds_psprel: | |
2452 | case unat_psprel: | |
2453 | case lc_psprel: | |
2454 | case fpsr_psprel: | |
2455 | case spill_base: | |
2456 | output_P7_format (f, ptr->r.type, ptr->r.record.p.pspoff, 0); | |
2457 | break; | |
2458 | case rp_sprel: | |
2459 | case pfs_sprel: | |
2460 | case preds_sprel: | |
2461 | case unat_sprel: | |
2462 | case lc_sprel: | |
2463 | case fpsr_sprel: | |
2464 | case priunat_sprel: | |
2465 | case bsp_sprel: | |
2466 | case bspstore_sprel: | |
2467 | case rnat_sprel: | |
2468 | output_P8_format (f, ptr->r.type, ptr->r.record.p.spoff); | |
2469 | break; | |
2470 | case gr_gr: | |
2471 | output_P9_format (f, ptr->r.record.p.grmask, ptr->r.record.p.gr); | |
2472 | break; | |
2473 | case br_gr: | |
2474 | output_P2_format (f, ptr->r.record.p.brmask, ptr->r.record.p.gr); | |
2475 | break; | |
2476 | case spill_mask: | |
2477 | as_bad ("spill_mask record unimplemented."); | |
2478 | break; | |
2479 | case priunat_when_gr: | |
2480 | case priunat_when_mem: | |
2481 | case bsp_when: | |
2482 | case bspstore_when: | |
2483 | case rnat_when: | |
2484 | output_P8_format (f, ptr->r.type, ptr->r.record.p.t); | |
2485 | break; | |
2486 | case priunat_psprel: | |
2487 | case bsp_psprel: | |
2488 | case bspstore_psprel: | |
2489 | case rnat_psprel: | |
2490 | output_P8_format (f, ptr->r.type, ptr->r.record.p.pspoff); | |
2491 | break; | |
2492 | case unwabi: | |
2493 | output_P10_format (f, ptr->r.record.p.abi, ptr->r.record.p.context); | |
2494 | break; | |
2495 | case epilogue: | |
2496 | output_B3_format (f, ptr->r.record.b.ecount, ptr->r.record.b.t); | |
2497 | break; | |
2498 | case label_state: | |
2499 | case copy_state: | |
2500 | output_B4_format (f, ptr->r.type, ptr->r.record.b.label); | |
2501 | break; | |
2502 | case spill_psprel: | |
2503 | output_X1_format (f, ptr->r.type, ptr->r.record.x.ab, | |
2504 | ptr->r.record.x.reg, ptr->r.record.x.t, | |
2505 | ptr->r.record.x.pspoff); | |
2506 | break; | |
2507 | case spill_sprel: | |
2508 | output_X1_format (f, ptr->r.type, ptr->r.record.x.ab, | |
2509 | ptr->r.record.x.reg, ptr->r.record.x.t, | |
2510 | ptr->r.record.x.spoff); | |
2511 | break; | |
2512 | case spill_reg: | |
2513 | output_X2_format (f, ptr->r.record.x.ab, ptr->r.record.x.reg, | |
2514 | ptr->r.record.x.xy >> 1, ptr->r.record.x.xy, | |
2515 | ptr->r.record.x.treg, ptr->r.record.x.t); | |
2516 | break; | |
2517 | case spill_psprel_p: | |
2518 | output_X3_format (f, ptr->r.type, ptr->r.record.x.qp, | |
2519 | ptr->r.record.x.ab, ptr->r.record.x.reg, | |
2520 | ptr->r.record.x.t, ptr->r.record.x.pspoff); | |
2521 | break; | |
2522 | case spill_sprel_p: | |
2523 | output_X3_format (f, ptr->r.type, ptr->r.record.x.qp, | |
2524 | ptr->r.record.x.ab, ptr->r.record.x.reg, | |
2525 | ptr->r.record.x.t, ptr->r.record.x.spoff); | |
2526 | break; | |
2527 | case spill_reg_p: | |
2528 | output_X4_format (f, ptr->r.record.x.qp, ptr->r.record.x.ab, | |
2529 | ptr->r.record.x.reg, ptr->r.record.x.xy >> 1, | |
2530 | ptr->r.record.x.xy, ptr->r.record.x.treg, | |
2531 | ptr->r.record.x.t); | |
2532 | break; | |
2533 | default: | |
2534 | as_bad ("record_type_not_valid"); | |
2535 | break; | |
800eeca4 JW |
2536 | } |
2537 | } | |
2538 | ||
197865e8 | 2539 | /* Given a unw_rec_list list, process all the records with |
800eeca4 JW |
2540 | the specified function. */ |
2541 | static void | |
2542 | process_unw_records (list, f) | |
2543 | unw_rec_list *list; | |
2544 | vbyte_func f; | |
2545 | { | |
2546 | unw_rec_list *ptr; | |
2547 | for (ptr = list; ptr; ptr = ptr->next) | |
2548 | process_one_record (ptr, f); | |
2549 | } | |
2550 | ||
2551 | /* Determine the size of a record list in bytes. */ | |
2552 | static int | |
2553 | calc_record_size (list) | |
2554 | unw_rec_list *list; | |
2555 | { | |
2556 | vbyte_count = 0; | |
2557 | process_unw_records (list, count_output); | |
2558 | return vbyte_count; | |
2559 | } | |
2560 | ||
e0c9811a JW |
2561 | /* Update IMASK bitmask to reflect the fact that one or more registers |
2562 | of type TYPE are saved starting at instruction with index T. If N | |
2563 | bits are set in REGMASK, it is assumed that instructions T through | |
2564 | T+N-1 save these registers. | |
2565 | ||
2566 | TYPE values: | |
2567 | 0: no save | |
2568 | 1: instruction saves next fp reg | |
2569 | 2: instruction saves next general reg | |
2570 | 3: instruction saves next branch reg */ | |
2571 | static void | |
2572 | set_imask (region, regmask, t, type) | |
2573 | unw_rec_list *region; | |
2574 | unsigned long regmask; | |
2575 | unsigned long t; | |
2576 | unsigned int type; | |
2577 | { | |
2578 | unsigned char *imask; | |
2579 | unsigned long imask_size; | |
2580 | unsigned int i; | |
2581 | int pos; | |
2582 | ||
2583 | imask = region->r.record.r.mask.i; | |
2584 | imask_size = region->r.record.r.imask_size; | |
2585 | if (!imask) | |
2586 | { | |
542d6675 | 2587 | imask_size = (region->r.record.r.rlen * 2 + 7) / 8 + 1; |
e0c9811a JW |
2588 | imask = xmalloc (imask_size); |
2589 | memset (imask, 0, imask_size); | |
2590 | ||
2591 | region->r.record.r.imask_size = imask_size; | |
2592 | region->r.record.r.mask.i = imask; | |
2593 | } | |
2594 | ||
542d6675 KH |
2595 | i = (t / 4) + 1; |
2596 | pos = 2 * (3 - t % 4); | |
e0c9811a JW |
2597 | while (regmask) |
2598 | { | |
2599 | if (i >= imask_size) | |
2600 | { | |
2601 | as_bad ("Ignoring attempt to spill beyond end of region"); | |
2602 | return; | |
2603 | } | |
2604 | ||
2605 | imask[i] |= (type & 0x3) << pos; | |
197865e8 | 2606 | |
e0c9811a JW |
2607 | regmask &= (regmask - 1); |
2608 | pos -= 2; | |
2609 | if (pos < 0) | |
2610 | { | |
2611 | pos = 0; | |
2612 | ++i; | |
2613 | } | |
2614 | } | |
2615 | } | |
2616 | ||
f5a30c2e JW |
2617 | /* Return the number of instruction slots from FIRST_ADDR to SLOT_ADDR. |
2618 | SLOT_FRAG is the frag containing SLOT_ADDR, and FIRST_FRAG is the frag | |
b5e0fabd JW |
2619 | containing FIRST_ADDR. If BEFORE_RELAX, then we use worst-case estimates |
2620 | for frag sizes. */ | |
f5a30c2e | 2621 | |
e0c9811a | 2622 | unsigned long |
b5e0fabd | 2623 | slot_index (slot_addr, slot_frag, first_addr, first_frag, before_relax) |
f5a30c2e JW |
2624 | unsigned long slot_addr; |
2625 | fragS *slot_frag; | |
2626 | unsigned long first_addr; | |
2627 | fragS *first_frag; | |
b5e0fabd | 2628 | int before_relax; |
e0c9811a | 2629 | { |
f5a30c2e JW |
2630 | unsigned long index = 0; |
2631 | ||
2632 | /* First time we are called, the initial address and frag are invalid. */ | |
2633 | if (first_addr == 0) | |
2634 | return 0; | |
2635 | ||
2636 | /* If the two addresses are in different frags, then we need to add in | |
2637 | the remaining size of this frag, and then the entire size of intermediate | |
2638 | frags. */ | |
2639 | while (slot_frag != first_frag) | |
2640 | { | |
2641 | unsigned long start_addr = (unsigned long) &first_frag->fr_literal; | |
2642 | ||
b5e0fabd | 2643 | if (! before_relax) |
73f20958 | 2644 | { |
b5e0fabd JW |
2645 | /* We can get the final addresses only during and after |
2646 | relaxation. */ | |
73f20958 L |
2647 | if (first_frag->fr_next && first_frag->fr_next->fr_address) |
2648 | index += 3 * ((first_frag->fr_next->fr_address | |
2649 | - first_frag->fr_address | |
2650 | - first_frag->fr_fix) >> 4); | |
2651 | } | |
2652 | else | |
2653 | /* We don't know what the final addresses will be. We try our | |
2654 | best to estimate. */ | |
2655 | switch (first_frag->fr_type) | |
2656 | { | |
2657 | default: | |
2658 | break; | |
2659 | ||
2660 | case rs_space: | |
2661 | as_fatal ("only constant space allocation is supported"); | |
2662 | break; | |
2663 | ||
2664 | case rs_align: | |
2665 | case rs_align_code: | |
2666 | case rs_align_test: | |
2667 | /* Take alignment into account. Assume the worst case | |
2668 | before relaxation. */ | |
2669 | index += 3 * ((1 << first_frag->fr_offset) >> 4); | |
2670 | break; | |
2671 | ||
2672 | case rs_org: | |
2673 | if (first_frag->fr_symbol) | |
2674 | { | |
2675 | as_fatal ("only constant offsets are supported"); | |
2676 | break; | |
2677 | } | |
2678 | case rs_fill: | |
2679 | index += 3 * (first_frag->fr_offset >> 4); | |
2680 | break; | |
2681 | } | |
2682 | ||
f5a30c2e JW |
2683 | /* Add in the full size of the frag converted to instruction slots. */ |
2684 | index += 3 * (first_frag->fr_fix >> 4); | |
2685 | /* Subtract away the initial part before first_addr. */ | |
2686 | index -= (3 * ((first_addr >> 4) - (start_addr >> 4)) | |
2687 | + ((first_addr & 0x3) - (start_addr & 0x3))); | |
e0c9811a | 2688 | |
f5a30c2e JW |
2689 | /* Move to the beginning of the next frag. */ |
2690 | first_frag = first_frag->fr_next; | |
2691 | first_addr = (unsigned long) &first_frag->fr_literal; | |
2692 | } | |
2693 | ||
2694 | /* Add in the used part of the last frag. */ | |
2695 | index += (3 * ((slot_addr >> 4) - (first_addr >> 4)) | |
2696 | + ((slot_addr & 0x3) - (first_addr & 0x3))); | |
2697 | return index; | |
2698 | } | |
4a1805b1 | 2699 | |
91a2ae2a RH |
2700 | /* Optimize unwind record directives. */ |
2701 | ||
2702 | static unw_rec_list * | |
2703 | optimize_unw_records (list) | |
2704 | unw_rec_list *list; | |
2705 | { | |
2706 | if (!list) | |
2707 | return NULL; | |
2708 | ||
2709 | /* If the only unwind record is ".prologue" or ".prologue" followed | |
2710 | by ".body", then we can optimize the unwind directives away. */ | |
2711 | if (list->r.type == prologue | |
5738bc24 JW |
2712 | && (list->next->r.type == endp |
2713 | || (list->next->r.type == body && list->next->next->r.type == endp))) | |
91a2ae2a RH |
2714 | return NULL; |
2715 | ||
2716 | return list; | |
2717 | } | |
2718 | ||
800eeca4 JW |
2719 | /* Given a complete record list, process any records which have |
2720 | unresolved fields, (ie length counts for a prologue). After | |
0234cb7c | 2721 | this has been run, all necessary information should be available |
800eeca4 | 2722 | within each record to generate an image. */ |
542d6675 | 2723 | |
800eeca4 | 2724 | static void |
b5e0fabd | 2725 | fixup_unw_records (list, before_relax) |
800eeca4 | 2726 | unw_rec_list *list; |
b5e0fabd | 2727 | int before_relax; |
800eeca4 | 2728 | { |
e0c9811a JW |
2729 | unw_rec_list *ptr, *region = 0; |
2730 | unsigned long first_addr = 0, rlen = 0, t; | |
f5a30c2e | 2731 | fragS *first_frag = 0; |
e0c9811a | 2732 | |
800eeca4 JW |
2733 | for (ptr = list; ptr; ptr = ptr->next) |
2734 | { | |
2735 | if (ptr->slot_number == SLOT_NUM_NOT_SET) | |
542d6675 | 2736 | as_bad (" Insn slot not set in unwind record."); |
f5a30c2e | 2737 | t = slot_index (ptr->slot_number, ptr->slot_frag, |
b5e0fabd | 2738 | first_addr, first_frag, before_relax); |
800eeca4 JW |
2739 | switch (ptr->r.type) |
2740 | { | |
542d6675 KH |
2741 | case prologue: |
2742 | case prologue_gr: | |
2743 | case body: | |
2744 | { | |
2745 | unw_rec_list *last; | |
5738bc24 JW |
2746 | int size; |
2747 | unsigned long last_addr = 0; | |
2748 | fragS *last_frag = NULL; | |
542d6675 KH |
2749 | |
2750 | first_addr = ptr->slot_number; | |
f5a30c2e | 2751 | first_frag = ptr->slot_frag; |
542d6675 | 2752 | /* Find either the next body/prologue start, or the end of |
5738bc24 | 2753 | the function, and determine the size of the region. */ |
542d6675 KH |
2754 | for (last = ptr->next; last != NULL; last = last->next) |
2755 | if (last->r.type == prologue || last->r.type == prologue_gr | |
5738bc24 | 2756 | || last->r.type == body || last->r.type == endp) |
542d6675 KH |
2757 | { |
2758 | last_addr = last->slot_number; | |
f5a30c2e | 2759 | last_frag = last->slot_frag; |
542d6675 KH |
2760 | break; |
2761 | } | |
b5e0fabd JW |
2762 | size = slot_index (last_addr, last_frag, first_addr, first_frag, |
2763 | before_relax); | |
542d6675 | 2764 | rlen = ptr->r.record.r.rlen = size; |
1e16b528 AS |
2765 | if (ptr->r.type == body) |
2766 | /* End of region. */ | |
2767 | region = 0; | |
2768 | else | |
2769 | region = ptr; | |
e0c9811a | 2770 | break; |
542d6675 KH |
2771 | } |
2772 | case epilogue: | |
2773 | ptr->r.record.b.t = rlen - 1 - t; | |
2774 | break; | |
e0c9811a | 2775 | |
542d6675 KH |
2776 | case mem_stack_f: |
2777 | case mem_stack_v: | |
2778 | case rp_when: | |
2779 | case pfs_when: | |
2780 | case preds_when: | |
2781 | case unat_when: | |
2782 | case lc_when: | |
2783 | case fpsr_when: | |
2784 | case priunat_when_gr: | |
2785 | case priunat_when_mem: | |
2786 | case bsp_when: | |
2787 | case bspstore_when: | |
2788 | case rnat_when: | |
2789 | ptr->r.record.p.t = t; | |
2790 | break; | |
e0c9811a | 2791 | |
542d6675 KH |
2792 | case spill_reg: |
2793 | case spill_sprel: | |
2794 | case spill_psprel: | |
2795 | case spill_reg_p: | |
2796 | case spill_sprel_p: | |
2797 | case spill_psprel_p: | |
2798 | ptr->r.record.x.t = t; | |
2799 | break; | |
e0c9811a | 2800 | |
542d6675 KH |
2801 | case frgr_mem: |
2802 | if (!region) | |
2803 | { | |
2804 | as_bad ("frgr_mem record before region record!\n"); | |
2805 | return; | |
2806 | } | |
2807 | region->r.record.r.mask.fr_mem |= ptr->r.record.p.frmask; | |
2808 | region->r.record.r.mask.gr_mem |= ptr->r.record.p.grmask; | |
2809 | set_imask (region, ptr->r.record.p.frmask, t, 1); | |
2810 | set_imask (region, ptr->r.record.p.grmask, t, 2); | |
2811 | break; | |
2812 | case fr_mem: | |
2813 | if (!region) | |
2814 | { | |
2815 | as_bad ("fr_mem record before region record!\n"); | |
2816 | return; | |
2817 | } | |
2818 | region->r.record.r.mask.fr_mem |= ptr->r.record.p.rmask; | |
2819 | set_imask (region, ptr->r.record.p.rmask, t, 1); | |
2820 | break; | |
2821 | case gr_mem: | |
2822 | if (!region) | |
2823 | { | |
2824 | as_bad ("gr_mem record before region record!\n"); | |
2825 | return; | |
2826 | } | |
2827 | region->r.record.r.mask.gr_mem |= ptr->r.record.p.rmask; | |
2828 | set_imask (region, ptr->r.record.p.rmask, t, 2); | |
2829 | break; | |
2830 | case br_mem: | |
2831 | if (!region) | |
2832 | { | |
2833 | as_bad ("br_mem record before region record!\n"); | |
2834 | return; | |
2835 | } | |
2836 | region->r.record.r.mask.br_mem |= ptr->r.record.p.brmask; | |
2837 | set_imask (region, ptr->r.record.p.brmask, t, 3); | |
2838 | break; | |
e0c9811a | 2839 | |
542d6675 KH |
2840 | case gr_gr: |
2841 | if (!region) | |
2842 | { | |
2843 | as_bad ("gr_gr record before region record!\n"); | |
2844 | return; | |
2845 | } | |
2846 | set_imask (region, ptr->r.record.p.grmask, t, 2); | |
2847 | break; | |
2848 | case br_gr: | |
2849 | if (!region) | |
2850 | { | |
2851 | as_bad ("br_gr record before region record!\n"); | |
2852 | return; | |
2853 | } | |
2854 | set_imask (region, ptr->r.record.p.brmask, t, 3); | |
2855 | break; | |
e0c9811a | 2856 | |
542d6675 KH |
2857 | default: |
2858 | break; | |
800eeca4 JW |
2859 | } |
2860 | } | |
2861 | } | |
2862 | ||
b5e0fabd JW |
2863 | /* Estimate the size of a frag before relaxing. We only have one type of frag |
2864 | to handle here, which is the unwind info frag. */ | |
2865 | ||
2866 | int | |
2867 | ia64_estimate_size_before_relax (fragS *frag, | |
2868 | asection *segtype ATTRIBUTE_UNUSED) | |
2869 | { | |
2870 | unw_rec_list *list; | |
2871 | int len, size, pad; | |
2872 | ||
2873 | /* ??? This code is identical to the first part of ia64_convert_frag. */ | |
2874 | list = (unw_rec_list *) frag->fr_opcode; | |
2875 | fixup_unw_records (list, 0); | |
2876 | ||
2877 | len = calc_record_size (list); | |
2878 | /* pad to pointer-size boundary. */ | |
2879 | pad = len % md.pointer_size; | |
2880 | if (pad != 0) | |
2881 | len += md.pointer_size - pad; | |
2882 | /* Add 8 for the header + a pointer for the personality offset. */ | |
2883 | size = len + 8 + md.pointer_size; | |
2884 | ||
2885 | /* fr_var carries the max_chars that we created the fragment with. | |
2886 | We must, of course, have allocated enough memory earlier. */ | |
2887 | assert (frag->fr_var >= size); | |
2888 | ||
2889 | return frag->fr_fix + size; | |
2890 | } | |
2891 | ||
73f20958 L |
2892 | /* This function converts a rs_machine_dependent variant frag into a |
2893 | normal fill frag with the unwind image from the the record list. */ | |
2894 | void | |
2895 | ia64_convert_frag (fragS *frag) | |
557debba | 2896 | { |
73f20958 L |
2897 | unw_rec_list *list; |
2898 | int len, size, pad; | |
1cd8ff38 | 2899 | valueT flag_value; |
557debba | 2900 | |
b5e0fabd | 2901 | /* ??? This code is identical to ia64_estimate_size_before_relax. */ |
73f20958 | 2902 | list = (unw_rec_list *) frag->fr_opcode; |
b5e0fabd | 2903 | fixup_unw_records (list, 0); |
1cd8ff38 | 2904 | |
73f20958 L |
2905 | len = calc_record_size (list); |
2906 | /* pad to pointer-size boundary. */ | |
2907 | pad = len % md.pointer_size; | |
2908 | if (pad != 0) | |
2909 | len += md.pointer_size - pad; | |
2910 | /* Add 8 for the header + a pointer for the personality offset. */ | |
2911 | size = len + 8 + md.pointer_size; | |
2912 | ||
2913 | /* fr_var carries the max_chars that we created the fragment with. | |
2914 | We must, of course, have allocated enough memory earlier. */ | |
2915 | assert (frag->fr_var >= size); | |
2916 | ||
2917 | /* Initialize the header area. fr_offset is initialized with | |
2918 | unwind.personality_routine. */ | |
2919 | if (frag->fr_offset) | |
1cd8ff38 NC |
2920 | { |
2921 | if (md.flags & EF_IA_64_ABI64) | |
2922 | flag_value = (bfd_vma) 3 << 32; | |
2923 | else | |
2924 | /* 32-bit unwind info block. */ | |
2925 | flag_value = (bfd_vma) 0x1003 << 32; | |
2926 | } | |
2927 | else | |
2928 | flag_value = 0; | |
557debba | 2929 | |
73f20958 L |
2930 | md_number_to_chars (frag->fr_literal, |
2931 | (((bfd_vma) 1 << 48) /* Version. */ | |
2932 | | flag_value /* U & E handler flags. */ | |
2933 | | (len / md.pointer_size)), /* Length. */ | |
2934 | 8); | |
557debba | 2935 | |
73f20958 L |
2936 | /* Skip the header. */ |
2937 | vbyte_mem_ptr = frag->fr_literal + 8; | |
2938 | process_unw_records (list, output_vbyte_mem); | |
d6e78c11 JW |
2939 | |
2940 | /* Fill the padding bytes with zeros. */ | |
2941 | if (pad != 0) | |
2942 | md_number_to_chars (frag->fr_literal + len + 8 - md.pointer_size + pad, 0, | |
2943 | md.pointer_size - pad); | |
2944 | ||
73f20958 L |
2945 | frag->fr_fix += size; |
2946 | frag->fr_type = rs_fill; | |
2947 | frag->fr_var = 0; | |
2948 | frag->fr_offset = 0; | |
800eeca4 JW |
2949 | } |
2950 | ||
e0c9811a JW |
2951 | static int |
2952 | convert_expr_to_ab_reg (e, ab, regp) | |
2953 | expressionS *e; | |
2954 | unsigned int *ab; | |
2955 | unsigned int *regp; | |
2956 | { | |
2957 | unsigned int reg; | |
2958 | ||
2959 | if (e->X_op != O_register) | |
2960 | return 0; | |
2961 | ||
2962 | reg = e->X_add_number; | |
2434f565 | 2963 | if (reg >= (REG_GR + 4) && reg <= (REG_GR + 7)) |
e0c9811a JW |
2964 | { |
2965 | *ab = 0; | |
2966 | *regp = reg - REG_GR; | |
2967 | } | |
2434f565 JW |
2968 | else if ((reg >= (REG_FR + 2) && reg <= (REG_FR + 5)) |
2969 | || (reg >= (REG_FR + 16) && reg <= (REG_FR + 31))) | |
e0c9811a JW |
2970 | { |
2971 | *ab = 1; | |
2972 | *regp = reg - REG_FR; | |
2973 | } | |
2434f565 | 2974 | else if (reg >= (REG_BR + 1) && reg <= (REG_BR + 5)) |
e0c9811a JW |
2975 | { |
2976 | *ab = 2; | |
2977 | *regp = reg - REG_BR; | |
2978 | } | |
2979 | else | |
2980 | { | |
2981 | *ab = 3; | |
2982 | switch (reg) | |
2983 | { | |
2984 | case REG_PR: *regp = 0; break; | |
2985 | case REG_PSP: *regp = 1; break; | |
2986 | case REG_PRIUNAT: *regp = 2; break; | |
2987 | case REG_BR + 0: *regp = 3; break; | |
2988 | case REG_AR + AR_BSP: *regp = 4; break; | |
2989 | case REG_AR + AR_BSPSTORE: *regp = 5; break; | |
2990 | case REG_AR + AR_RNAT: *regp = 6; break; | |
2991 | case REG_AR + AR_UNAT: *regp = 7; break; | |
2992 | case REG_AR + AR_FPSR: *regp = 8; break; | |
2993 | case REG_AR + AR_PFS: *regp = 9; break; | |
2994 | case REG_AR + AR_LC: *regp = 10; break; | |
2995 | ||
2996 | default: | |
2997 | return 0; | |
2998 | } | |
2999 | } | |
3000 | return 1; | |
197865e8 | 3001 | } |
e0c9811a JW |
3002 | |
3003 | static int | |
3004 | convert_expr_to_xy_reg (e, xy, regp) | |
3005 | expressionS *e; | |
3006 | unsigned int *xy; | |
3007 | unsigned int *regp; | |
3008 | { | |
3009 | unsigned int reg; | |
3010 | ||
3011 | if (e->X_op != O_register) | |
3012 | return 0; | |
3013 | ||
3014 | reg = e->X_add_number; | |
3015 | ||
2434f565 | 3016 | if (/* reg >= REG_GR && */ reg <= (REG_GR + 127)) |
e0c9811a JW |
3017 | { |
3018 | *xy = 0; | |
3019 | *regp = reg - REG_GR; | |
3020 | } | |
2434f565 | 3021 | else if (reg >= REG_FR && reg <= (REG_FR + 127)) |
e0c9811a JW |
3022 | { |
3023 | *xy = 1; | |
3024 | *regp = reg - REG_FR; | |
3025 | } | |
2434f565 | 3026 | else if (reg >= REG_BR && reg <= (REG_BR + 7)) |
e0c9811a JW |
3027 | { |
3028 | *xy = 2; | |
3029 | *regp = reg - REG_BR; | |
3030 | } | |
3031 | else | |
3032 | return -1; | |
3033 | return 1; | |
197865e8 | 3034 | } |
e0c9811a | 3035 | |
800eeca4 JW |
3036 | static void |
3037 | dot_radix (dummy) | |
2434f565 | 3038 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
3039 | { |
3040 | int radix; | |
3041 | ||
3042 | SKIP_WHITESPACE (); | |
3043 | radix = *input_line_pointer++; | |
3044 | ||
3045 | if (radix != 'C' && !is_end_of_line[(unsigned char) radix]) | |
3046 | { | |
3047 | as_bad ("Radix `%c' unsupported", *input_line_pointer); | |
542d6675 | 3048 | ignore_rest_of_line (); |
800eeca4 JW |
3049 | return; |
3050 | } | |
3051 | } | |
3052 | ||
3053 | /* .sbss, .bss etc. are macros that expand into ".section SECNAME". */ | |
3054 | static void | |
3055 | dot_special_section (which) | |
3056 | int which; | |
3057 | { | |
3058 | set_section ((char *) special_section_name[which]); | |
3059 | } | |
3060 | ||
3061 | static void | |
3062 | add_unwind_entry (ptr) | |
3063 | unw_rec_list *ptr; | |
3064 | { | |
e0c9811a JW |
3065 | if (unwind.tail) |
3066 | unwind.tail->next = ptr; | |
800eeca4 | 3067 | else |
e0c9811a JW |
3068 | unwind.list = ptr; |
3069 | unwind.tail = ptr; | |
800eeca4 JW |
3070 | |
3071 | /* The current entry can in fact be a chain of unwind entries. */ | |
e0c9811a JW |
3072 | if (unwind.current_entry == NULL) |
3073 | unwind.current_entry = ptr; | |
800eeca4 JW |
3074 | } |
3075 | ||
197865e8 | 3076 | static void |
800eeca4 | 3077 | dot_fframe (dummy) |
2434f565 | 3078 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
3079 | { |
3080 | expressionS e; | |
e0c9811a | 3081 | |
800eeca4 | 3082 | parse_operand (&e); |
197865e8 | 3083 | |
800eeca4 JW |
3084 | if (e.X_op != O_constant) |
3085 | as_bad ("Operand to .fframe must be a constant"); | |
3086 | else | |
e0c9811a JW |
3087 | add_unwind_entry (output_mem_stack_f (e.X_add_number)); |
3088 | } | |
3089 | ||
197865e8 | 3090 | static void |
e0c9811a | 3091 | dot_vframe (dummy) |
2434f565 | 3092 | int dummy ATTRIBUTE_UNUSED; |
e0c9811a JW |
3093 | { |
3094 | expressionS e; | |
3095 | unsigned reg; | |
3096 | ||
3097 | parse_operand (&e); | |
3098 | reg = e.X_add_number - REG_GR; | |
3099 | if (e.X_op == O_register && reg < 128) | |
800eeca4 | 3100 | { |
e0c9811a | 3101 | add_unwind_entry (output_mem_stack_v ()); |
30d25259 RH |
3102 | if (! (unwind.prologue_mask & 2)) |
3103 | add_unwind_entry (output_psp_gr (reg)); | |
800eeca4 | 3104 | } |
e0c9811a JW |
3105 | else |
3106 | as_bad ("First operand to .vframe must be a general register"); | |
800eeca4 JW |
3107 | } |
3108 | ||
197865e8 | 3109 | static void |
e0c9811a | 3110 | dot_vframesp (dummy) |
2434f565 | 3111 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 | 3112 | { |
e0c9811a JW |
3113 | expressionS e; |
3114 | ||
3115 | parse_operand (&e); | |
3116 | if (e.X_op == O_constant) | |
3117 | { | |
3118 | add_unwind_entry (output_mem_stack_v ()); | |
3119 | add_unwind_entry (output_psp_sprel (e.X_add_number)); | |
3120 | } | |
3121 | else | |
69906a9b | 3122 | as_bad ("Operand to .vframesp must be a constant (sp-relative offset)"); |
e0c9811a JW |
3123 | } |
3124 | ||
197865e8 | 3125 | static void |
e0c9811a | 3126 | dot_vframepsp (dummy) |
2434f565 | 3127 | int dummy ATTRIBUTE_UNUSED; |
e0c9811a JW |
3128 | { |
3129 | expressionS e; | |
3130 | ||
3131 | parse_operand (&e); | |
3132 | if (e.X_op == O_constant) | |
3133 | { | |
3134 | add_unwind_entry (output_mem_stack_v ()); | |
3135 | add_unwind_entry (output_psp_sprel (e.X_add_number)); | |
3136 | } | |
3137 | else | |
69906a9b | 3138 | as_bad ("Operand to .vframepsp must be a constant (psp-relative offset)"); |
800eeca4 JW |
3139 | } |
3140 | ||
197865e8 | 3141 | static void |
800eeca4 | 3142 | dot_save (dummy) |
2434f565 | 3143 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
3144 | { |
3145 | expressionS e1, e2; | |
3146 | int sep; | |
3147 | int reg1, reg2; | |
3148 | ||
3149 | sep = parse_operand (&e1); | |
3150 | if (sep != ',') | |
3151 | as_bad ("No second operand to .save"); | |
3152 | sep = parse_operand (&e2); | |
3153 | ||
e0c9811a | 3154 | reg1 = e1.X_add_number; |
800eeca4 | 3155 | reg2 = e2.X_add_number - REG_GR; |
197865e8 | 3156 | |
800eeca4 | 3157 | /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */ |
e0c9811a | 3158 | if (e1.X_op == O_register) |
800eeca4 | 3159 | { |
542d6675 | 3160 | if (e2.X_op == O_register && reg2 >= 0 && reg2 < 128) |
800eeca4 JW |
3161 | { |
3162 | switch (reg1) | |
3163 | { | |
542d6675 KH |
3164 | case REG_AR + AR_BSP: |
3165 | add_unwind_entry (output_bsp_when ()); | |
3166 | add_unwind_entry (output_bsp_gr (reg2)); | |
3167 | break; | |
3168 | case REG_AR + AR_BSPSTORE: | |
3169 | add_unwind_entry (output_bspstore_when ()); | |
3170 | add_unwind_entry (output_bspstore_gr (reg2)); | |
3171 | break; | |
3172 | case REG_AR + AR_RNAT: | |
3173 | add_unwind_entry (output_rnat_when ()); | |
3174 | add_unwind_entry (output_rnat_gr (reg2)); | |
3175 | break; | |
3176 | case REG_AR + AR_UNAT: | |
3177 | add_unwind_entry (output_unat_when ()); | |
3178 | add_unwind_entry (output_unat_gr (reg2)); | |
3179 | break; | |
3180 | case REG_AR + AR_FPSR: | |
3181 | add_unwind_entry (output_fpsr_when ()); | |
3182 | add_unwind_entry (output_fpsr_gr (reg2)); | |
3183 | break; | |
3184 | case REG_AR + AR_PFS: | |
3185 | add_unwind_entry (output_pfs_when ()); | |
3186 | if (! (unwind.prologue_mask & 4)) | |
3187 | add_unwind_entry (output_pfs_gr (reg2)); | |
3188 | break; | |
3189 | case REG_AR + AR_LC: | |
3190 | add_unwind_entry (output_lc_when ()); | |
3191 | add_unwind_entry (output_lc_gr (reg2)); | |
3192 | break; | |
3193 | case REG_BR: | |
3194 | add_unwind_entry (output_rp_when ()); | |
3195 | if (! (unwind.prologue_mask & 8)) | |
3196 | add_unwind_entry (output_rp_gr (reg2)); | |
3197 | break; | |
3198 | case REG_PR: | |
3199 | add_unwind_entry (output_preds_when ()); | |
3200 | if (! (unwind.prologue_mask & 1)) | |
3201 | add_unwind_entry (output_preds_gr (reg2)); | |
3202 | break; | |
3203 | case REG_PRIUNAT: | |
3204 | add_unwind_entry (output_priunat_when_gr ()); | |
3205 | add_unwind_entry (output_priunat_gr (reg2)); | |
3206 | break; | |
3207 | default: | |
3208 | as_bad ("First operand not a valid register"); | |
800eeca4 JW |
3209 | } |
3210 | } | |
3211 | else | |
3212 | as_bad (" Second operand not a valid register"); | |
3213 | } | |
3214 | else | |
e0c9811a | 3215 | as_bad ("First operand not a register"); |
800eeca4 JW |
3216 | } |
3217 | ||
197865e8 | 3218 | static void |
800eeca4 | 3219 | dot_restore (dummy) |
2434f565 | 3220 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 | 3221 | { |
e0c9811a | 3222 | expressionS e1, e2; |
33d01f33 | 3223 | unsigned long ecount; /* # of _additional_ regions to pop */ |
e0c9811a JW |
3224 | int sep; |
3225 | ||
3226 | sep = parse_operand (&e1); | |
3227 | if (e1.X_op != O_register || e1.X_add_number != REG_GR + 12) | |
3228 | { | |
3229 | as_bad ("First operand to .restore must be stack pointer (sp)"); | |
3230 | return; | |
3231 | } | |
3232 | ||
3233 | if (sep == ',') | |
3234 | { | |
3235 | parse_operand (&e2); | |
33d01f33 | 3236 | if (e2.X_op != O_constant || e2.X_add_number < 0) |
e0c9811a | 3237 | { |
33d01f33 | 3238 | as_bad ("Second operand to .restore must be a constant >= 0"); |
e0c9811a JW |
3239 | return; |
3240 | } | |
33d01f33 | 3241 | ecount = e2.X_add_number; |
e0c9811a | 3242 | } |
33d01f33 JW |
3243 | else |
3244 | ecount = unwind.prologue_count - 1; | |
6290819d NC |
3245 | |
3246 | if (ecount >= unwind.prologue_count) | |
3247 | { | |
3248 | as_bad ("Epilogue count of %lu exceeds number of nested prologues (%u)", | |
3249 | ecount + 1, unwind.prologue_count); | |
3250 | return; | |
3251 | } | |
3252 | ||
e0c9811a | 3253 | add_unwind_entry (output_epilogue (ecount)); |
33d01f33 JW |
3254 | |
3255 | if (ecount < unwind.prologue_count) | |
3256 | unwind.prologue_count -= ecount + 1; | |
3257 | else | |
3258 | unwind.prologue_count = 0; | |
e0c9811a JW |
3259 | } |
3260 | ||
197865e8 | 3261 | static void |
e0c9811a | 3262 | dot_restorereg (dummy) |
2434f565 | 3263 | int dummy ATTRIBUTE_UNUSED; |
e0c9811a JW |
3264 | { |
3265 | unsigned int ab, reg; | |
3266 | expressionS e; | |
3267 | ||
3268 | parse_operand (&e); | |
3269 | ||
3270 | if (!convert_expr_to_ab_reg (&e, &ab, ®)) | |
3271 | { | |
3272 | as_bad ("First operand to .restorereg must be a preserved register"); | |
3273 | return; | |
3274 | } | |
3275 | add_unwind_entry (output_spill_reg (ab, reg, 0, 0)); | |
3276 | } | |
3277 | ||
197865e8 | 3278 | static void |
e0c9811a | 3279 | dot_restorereg_p (dummy) |
2434f565 | 3280 | int dummy ATTRIBUTE_UNUSED; |
e0c9811a JW |
3281 | { |
3282 | unsigned int qp, ab, reg; | |
3283 | expressionS e1, e2; | |
3284 | int sep; | |
3285 | ||
3286 | sep = parse_operand (&e1); | |
3287 | if (sep != ',') | |
3288 | { | |
3289 | as_bad ("No second operand to .restorereg.p"); | |
3290 | return; | |
3291 | } | |
3292 | ||
3293 | parse_operand (&e2); | |
3294 | ||
3295 | qp = e1.X_add_number - REG_P; | |
3296 | if (e1.X_op != O_register || qp > 63) | |
3297 | { | |
3298 | as_bad ("First operand to .restorereg.p must be a predicate"); | |
3299 | return; | |
3300 | } | |
3301 | ||
3302 | if (!convert_expr_to_ab_reg (&e2, &ab, ®)) | |
3303 | { | |
3304 | as_bad ("Second operand to .restorereg.p must be a preserved register"); | |
3305 | return; | |
3306 | } | |
3307 | add_unwind_entry (output_spill_reg_p (ab, reg, 0, 0, qp)); | |
800eeca4 JW |
3308 | } |
3309 | ||
73f20958 | 3310 | static void |
91a2ae2a RH |
3311 | generate_unwind_image (text_name) |
3312 | const char *text_name; | |
800eeca4 | 3313 | { |
73f20958 L |
3314 | int size, pad; |
3315 | unw_rec_list *list; | |
800eeca4 | 3316 | |
c97b7ef6 JW |
3317 | /* Mark the end of the unwind info, so that we can compute the size of the |
3318 | last unwind region. */ | |
3319 | add_unwind_entry (output_endp ()); | |
3320 | ||
10850f29 JW |
3321 | /* Force out pending instructions, to make sure all unwind records have |
3322 | a valid slot_number field. */ | |
3323 | ia64_flush_insns (); | |
3324 | ||
800eeca4 | 3325 | /* Generate the unwind record. */ |
73f20958 | 3326 | list = optimize_unw_records (unwind.list); |
b5e0fabd | 3327 | fixup_unw_records (list, 1); |
73f20958 L |
3328 | size = calc_record_size (list); |
3329 | ||
3330 | if (size > 0 || unwind.force_unwind_entry) | |
3331 | { | |
3332 | unwind.force_unwind_entry = 0; | |
3333 | /* pad to pointer-size boundary. */ | |
3334 | pad = size % md.pointer_size; | |
3335 | if (pad != 0) | |
3336 | size += md.pointer_size - pad; | |
3337 | /* Add 8 for the header + a pointer for the personality | |
3338 | offset. */ | |
3339 | size += 8 + md.pointer_size; | |
3340 | } | |
6290819d | 3341 | |
800eeca4 JW |
3342 | /* If there are unwind records, switch sections, and output the info. */ |
3343 | if (size != 0) | |
3344 | { | |
91a2ae2a | 3345 | char *sec_name; |
800eeca4 | 3346 | expressionS exp; |
1cd8ff38 | 3347 | bfd_reloc_code_real_type reloc; |
91a2ae2a RH |
3348 | |
3349 | make_unw_section_name (SPECIAL_SECTION_UNWIND_INFO, text_name, sec_name); | |
3350 | set_section (sec_name); | |
3351 | bfd_set_section_flags (stdoutput, now_seg, | |
3352 | SEC_LOAD | SEC_ALLOC | SEC_READONLY); | |
800eeca4 | 3353 | |
557debba JW |
3354 | /* Make sure the section has 4 byte alignment for ILP32 and |
3355 | 8 byte alignment for LP64. */ | |
3356 | frag_align (md.pointer_size_shift, 0, 0); | |
3357 | record_alignment (now_seg, md.pointer_size_shift); | |
5e7474a7 | 3358 | |
800eeca4 | 3359 | /* Set expression which points to start of unwind descriptor area. */ |
e0c9811a | 3360 | unwind.info = expr_build_dot (); |
73f20958 L |
3361 | |
3362 | frag_var (rs_machine_dependent, size, size, 0, 0, | |
3363 | (offsetT) unwind.personality_routine, (char *) list); | |
91a2ae2a | 3364 | |
800eeca4 | 3365 | /* Add the personality address to the image. */ |
e0c9811a | 3366 | if (unwind.personality_routine != 0) |
542d6675 | 3367 | { |
40449e9f | 3368 | exp.X_op = O_symbol; |
e0c9811a | 3369 | exp.X_add_symbol = unwind.personality_routine; |
800eeca4 | 3370 | exp.X_add_number = 0; |
1cd8ff38 NC |
3371 | |
3372 | if (md.flags & EF_IA_64_BE) | |
3373 | { | |
3374 | if (md.flags & EF_IA_64_ABI64) | |
3375 | reloc = BFD_RELOC_IA64_LTOFF_FPTR64MSB; | |
3376 | else | |
3377 | reloc = BFD_RELOC_IA64_LTOFF_FPTR32MSB; | |
3378 | } | |
40449e9f | 3379 | else |
1cd8ff38 NC |
3380 | { |
3381 | if (md.flags & EF_IA_64_ABI64) | |
3382 | reloc = BFD_RELOC_IA64_LTOFF_FPTR64LSB; | |
3383 | else | |
3384 | reloc = BFD_RELOC_IA64_LTOFF_FPTR32LSB; | |
3385 | } | |
3386 | ||
3387 | fix_new_exp (frag_now, frag_now_fix () - md.pointer_size, | |
40449e9f | 3388 | md.pointer_size, &exp, 0, reloc); |
e0c9811a | 3389 | unwind.personality_routine = 0; |
542d6675 | 3390 | } |
800eeca4 JW |
3391 | } |
3392 | ||
6290819d | 3393 | free_saved_prologue_counts (); |
e0c9811a | 3394 | unwind.list = unwind.tail = unwind.current_entry = NULL; |
800eeca4 JW |
3395 | } |
3396 | ||
197865e8 | 3397 | static void |
542d6675 | 3398 | dot_handlerdata (dummy) |
2434f565 | 3399 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 | 3400 | { |
91a2ae2a RH |
3401 | const char *text_name = segment_name (now_seg); |
3402 | ||
3403 | /* If text section name starts with ".text" (which it should), | |
3404 | strip this prefix off. */ | |
3405 | if (strcmp (text_name, ".text") == 0) | |
3406 | text_name = ""; | |
3407 | ||
3408 | unwind.force_unwind_entry = 1; | |
3409 | ||
3410 | /* Remember which segment we're in so we can switch back after .endp */ | |
3411 | unwind.saved_text_seg = now_seg; | |
3412 | unwind.saved_text_subseg = now_subseg; | |
3413 | ||
3414 | /* Generate unwind info into unwind-info section and then leave that | |
3415 | section as the currently active one so dataXX directives go into | |
3416 | the language specific data area of the unwind info block. */ | |
3417 | generate_unwind_image (text_name); | |
e0c9811a | 3418 | demand_empty_rest_of_line (); |
800eeca4 JW |
3419 | } |
3420 | ||
197865e8 | 3421 | static void |
800eeca4 | 3422 | dot_unwentry (dummy) |
2434f565 | 3423 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 | 3424 | { |
91a2ae2a | 3425 | unwind.force_unwind_entry = 1; |
e0c9811a | 3426 | demand_empty_rest_of_line (); |
800eeca4 JW |
3427 | } |
3428 | ||
197865e8 | 3429 | static void |
800eeca4 | 3430 | dot_altrp (dummy) |
2434f565 | 3431 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 | 3432 | { |
e0c9811a JW |
3433 | expressionS e; |
3434 | unsigned reg; | |
3435 | ||
3436 | parse_operand (&e); | |
3437 | reg = e.X_add_number - REG_BR; | |
3438 | if (e.X_op == O_register && reg < 8) | |
3439 | add_unwind_entry (output_rp_br (reg)); | |
3440 | else | |
3441 | as_bad ("First operand not a valid branch register"); | |
800eeca4 JW |
3442 | } |
3443 | ||
197865e8 | 3444 | static void |
e0c9811a JW |
3445 | dot_savemem (psprel) |
3446 | int psprel; | |
800eeca4 JW |
3447 | { |
3448 | expressionS e1, e2; | |
3449 | int sep; | |
3450 | int reg1, val; | |
3451 | ||
3452 | sep = parse_operand (&e1); | |
3453 | if (sep != ',') | |
e0c9811a | 3454 | as_bad ("No second operand to .save%ssp", psprel ? "p" : ""); |
800eeca4 JW |
3455 | sep = parse_operand (&e2); |
3456 | ||
e0c9811a | 3457 | reg1 = e1.X_add_number; |
800eeca4 | 3458 | val = e2.X_add_number; |
197865e8 | 3459 | |
800eeca4 | 3460 | /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */ |
e0c9811a | 3461 | if (e1.X_op == O_register) |
800eeca4 JW |
3462 | { |
3463 | if (e2.X_op == O_constant) | |
3464 | { | |
3465 | switch (reg1) | |
3466 | { | |
542d6675 KH |
3467 | case REG_AR + AR_BSP: |
3468 | add_unwind_entry (output_bsp_when ()); | |
3469 | add_unwind_entry ((psprel | |
3470 | ? output_bsp_psprel | |
3471 | : output_bsp_sprel) (val)); | |
3472 | break; | |
3473 | case REG_AR + AR_BSPSTORE: | |
3474 | add_unwind_entry (output_bspstore_when ()); | |
3475 | add_unwind_entry ((psprel | |
3476 | ? output_bspstore_psprel | |
3477 | : output_bspstore_sprel) (val)); | |
3478 | break; | |
3479 | case REG_AR + AR_RNAT: | |
3480 | add_unwind_entry (output_rnat_when ()); | |
3481 | add_unwind_entry ((psprel | |
3482 | ? output_rnat_psprel | |
3483 | : output_rnat_sprel) (val)); | |
3484 | break; | |
3485 | case REG_AR + AR_UNAT: | |
3486 | add_unwind_entry (output_unat_when ()); | |
3487 | add_unwind_entry ((psprel | |
3488 | ? output_unat_psprel | |
3489 | : output_unat_sprel) (val)); | |
3490 | break; | |
3491 | case REG_AR + AR_FPSR: | |
3492 | add_unwind_entry (output_fpsr_when ()); | |
3493 | add_unwind_entry ((psprel | |
3494 | ? output_fpsr_psprel | |
3495 | : output_fpsr_sprel) (val)); | |
3496 | break; | |
3497 | case REG_AR + AR_PFS: | |
3498 | add_unwind_entry (output_pfs_when ()); | |
3499 | add_unwind_entry ((psprel | |
3500 | ? output_pfs_psprel | |
3501 | : output_pfs_sprel) (val)); | |
3502 | break; | |
3503 | case REG_AR + AR_LC: | |
3504 | add_unwind_entry (output_lc_when ()); | |
3505 | add_unwind_entry ((psprel | |
3506 | ? output_lc_psprel | |
3507 | : output_lc_sprel) (val)); | |
3508 | break; | |
3509 | case REG_BR: | |
3510 | add_unwind_entry (output_rp_when ()); | |
3511 | add_unwind_entry ((psprel | |
3512 | ? output_rp_psprel | |
3513 | : output_rp_sprel) (val)); | |
3514 | break; | |
3515 | case REG_PR: | |
3516 | add_unwind_entry (output_preds_when ()); | |
3517 | add_unwind_entry ((psprel | |
3518 | ? output_preds_psprel | |
3519 | : output_preds_sprel) (val)); | |
3520 | break; | |
3521 | case REG_PRIUNAT: | |
3522 | add_unwind_entry (output_priunat_when_mem ()); | |
3523 | add_unwind_entry ((psprel | |
3524 | ? output_priunat_psprel | |
3525 | : output_priunat_sprel) (val)); | |
3526 | break; | |
3527 | default: | |
3528 | as_bad ("First operand not a valid register"); | |
800eeca4 JW |
3529 | } |
3530 | } | |
3531 | else | |
3532 | as_bad (" Second operand not a valid constant"); | |
3533 | } | |
3534 | else | |
e0c9811a | 3535 | as_bad ("First operand not a register"); |
800eeca4 JW |
3536 | } |
3537 | ||
197865e8 | 3538 | static void |
800eeca4 | 3539 | dot_saveg (dummy) |
2434f565 | 3540 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
3541 | { |
3542 | expressionS e1, e2; | |
3543 | int sep; | |
3544 | sep = parse_operand (&e1); | |
3545 | if (sep == ',') | |
3546 | parse_operand (&e2); | |
197865e8 | 3547 | |
800eeca4 JW |
3548 | if (e1.X_op != O_constant) |
3549 | as_bad ("First operand to .save.g must be a constant."); | |
3550 | else | |
3551 | { | |
3552 | int grmask = e1.X_add_number; | |
3553 | if (sep != ',') | |
3554 | add_unwind_entry (output_gr_mem (grmask)); | |
3555 | else | |
542d6675 | 3556 | { |
800eeca4 | 3557 | int reg = e2.X_add_number - REG_GR; |
542d6675 | 3558 | if (e2.X_op == O_register && reg >= 0 && reg < 128) |
800eeca4 JW |
3559 | add_unwind_entry (output_gr_gr (grmask, reg)); |
3560 | else | |
3561 | as_bad ("Second operand is an invalid register."); | |
3562 | } | |
3563 | } | |
3564 | } | |
3565 | ||
197865e8 | 3566 | static void |
800eeca4 | 3567 | dot_savef (dummy) |
2434f565 | 3568 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 | 3569 | { |
e0c9811a | 3570 | expressionS e1; |
800eeca4 JW |
3571 | int sep; |
3572 | sep = parse_operand (&e1); | |
197865e8 | 3573 | |
800eeca4 JW |
3574 | if (e1.X_op != O_constant) |
3575 | as_bad ("Operand to .save.f must be a constant."); | |
3576 | else | |
e0c9811a | 3577 | add_unwind_entry (output_fr_mem (e1.X_add_number)); |
800eeca4 JW |
3578 | } |
3579 | ||
197865e8 | 3580 | static void |
800eeca4 | 3581 | dot_saveb (dummy) |
2434f565 | 3582 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 | 3583 | { |
e0c9811a JW |
3584 | expressionS e1, e2; |
3585 | unsigned int reg; | |
3586 | unsigned char sep; | |
3587 | int brmask; | |
3588 | ||
800eeca4 | 3589 | sep = parse_operand (&e1); |
800eeca4 | 3590 | if (e1.X_op != O_constant) |
800eeca4 | 3591 | { |
e0c9811a JW |
3592 | as_bad ("First operand to .save.b must be a constant."); |
3593 | return; | |
800eeca4 | 3594 | } |
e0c9811a JW |
3595 | brmask = e1.X_add_number; |
3596 | ||
3597 | if (sep == ',') | |
3598 | { | |
3599 | sep = parse_operand (&e2); | |
3600 | reg = e2.X_add_number - REG_GR; | |
3601 | if (e2.X_op != O_register || reg > 127) | |
3602 | { | |
3603 | as_bad ("Second operand to .save.b must be a general register."); | |
3604 | return; | |
3605 | } | |
3606 | add_unwind_entry (output_br_gr (brmask, e2.X_add_number)); | |
3607 | } | |
3608 | else | |
3609 | add_unwind_entry (output_br_mem (brmask)); | |
3610 | ||
3611 | if (!is_end_of_line[sep] && !is_it_end_of_statement ()) | |
3612 | ignore_rest_of_line (); | |
800eeca4 JW |
3613 | } |
3614 | ||
197865e8 | 3615 | static void |
800eeca4 | 3616 | dot_savegf (dummy) |
2434f565 | 3617 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
3618 | { |
3619 | expressionS e1, e2; | |
3620 | int sep; | |
3621 | sep = parse_operand (&e1); | |
3622 | if (sep == ',') | |
3623 | parse_operand (&e2); | |
197865e8 | 3624 | |
800eeca4 JW |
3625 | if (e1.X_op != O_constant || sep != ',' || e2.X_op != O_constant) |
3626 | as_bad ("Both operands of .save.gf must be constants."); | |
3627 | else | |
3628 | { | |
3629 | int grmask = e1.X_add_number; | |
3630 | int frmask = e2.X_add_number; | |
3631 | add_unwind_entry (output_frgr_mem (grmask, frmask)); | |
3632 | } | |
3633 | } | |
3634 | ||
197865e8 | 3635 | static void |
800eeca4 | 3636 | dot_spill (dummy) |
2434f565 | 3637 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
3638 | { |
3639 | expressionS e; | |
e0c9811a JW |
3640 | unsigned char sep; |
3641 | ||
3642 | sep = parse_operand (&e); | |
3643 | if (!is_end_of_line[sep] && !is_it_end_of_statement ()) | |
3644 | ignore_rest_of_line (); | |
197865e8 | 3645 | |
800eeca4 JW |
3646 | if (e.X_op != O_constant) |
3647 | as_bad ("Operand to .spill must be a constant"); | |
3648 | else | |
e0c9811a JW |
3649 | add_unwind_entry (output_spill_base (e.X_add_number)); |
3650 | } | |
3651 | ||
3652 | static void | |
3653 | dot_spillreg (dummy) | |
2434f565 | 3654 | int dummy ATTRIBUTE_UNUSED; |
e0c9811a JW |
3655 | { |
3656 | int sep, ab, xy, reg, treg; | |
3657 | expressionS e1, e2; | |
3658 | ||
3659 | sep = parse_operand (&e1); | |
3660 | if (sep != ',') | |
3661 | { | |
3662 | as_bad ("No second operand to .spillreg"); | |
3663 | return; | |
3664 | } | |
3665 | ||
3666 | parse_operand (&e2); | |
3667 | ||
3668 | if (!convert_expr_to_ab_reg (&e1, &ab, ®)) | |
800eeca4 | 3669 | { |
e0c9811a JW |
3670 | as_bad ("First operand to .spillreg must be a preserved register"); |
3671 | return; | |
800eeca4 | 3672 | } |
e0c9811a JW |
3673 | |
3674 | if (!convert_expr_to_xy_reg (&e2, &xy, &treg)) | |
3675 | { | |
3676 | as_bad ("Second operand to .spillreg must be a register"); | |
3677 | return; | |
3678 | } | |
3679 | ||
3680 | add_unwind_entry (output_spill_reg (ab, reg, treg, xy)); | |
3681 | } | |
3682 | ||
3683 | static void | |
3684 | dot_spillmem (psprel) | |
3685 | int psprel; | |
3686 | { | |
3687 | expressionS e1, e2; | |
3688 | int sep, ab, reg; | |
3689 | ||
3690 | sep = parse_operand (&e1); | |
3691 | if (sep != ',') | |
3692 | { | |
3693 | as_bad ("Second operand missing"); | |
3694 | return; | |
3695 | } | |
3696 | ||
3697 | parse_operand (&e2); | |
3698 | ||
3699 | if (!convert_expr_to_ab_reg (&e1, &ab, ®)) | |
3700 | { | |
3701 | as_bad ("First operand to .spill%s must be a preserved register", | |
3702 | psprel ? "psp" : "sp"); | |
3703 | return; | |
3704 | } | |
3705 | ||
3706 | if (e2.X_op != O_constant) | |
3707 | { | |
3708 | as_bad ("Second operand to .spill%s must be a constant", | |
3709 | psprel ? "psp" : "sp"); | |
3710 | return; | |
3711 | } | |
3712 | ||
3713 | if (psprel) | |
3714 | add_unwind_entry (output_spill_psprel (ab, reg, e2.X_add_number)); | |
3715 | else | |
3716 | add_unwind_entry (output_spill_sprel (ab, reg, e2.X_add_number)); | |
3717 | } | |
3718 | ||
3719 | static void | |
3720 | dot_spillreg_p (dummy) | |
2434f565 | 3721 | int dummy ATTRIBUTE_UNUSED; |
e0c9811a JW |
3722 | { |
3723 | int sep, ab, xy, reg, treg; | |
3724 | expressionS e1, e2, e3; | |
3725 | unsigned int qp; | |
3726 | ||
3727 | sep = parse_operand (&e1); | |
3728 | if (sep != ',') | |
3729 | { | |
3730 | as_bad ("No second and third operand to .spillreg.p"); | |
3731 | return; | |
3732 | } | |
3733 | ||
3734 | sep = parse_operand (&e2); | |
3735 | if (sep != ',') | |
3736 | { | |
3737 | as_bad ("No third operand to .spillreg.p"); | |
3738 | return; | |
3739 | } | |
3740 | ||
3741 | parse_operand (&e3); | |
3742 | ||
3743 | qp = e1.X_add_number - REG_P; | |
3744 | ||
3745 | if (e1.X_op != O_register || qp > 63) | |
3746 | { | |
3747 | as_bad ("First operand to .spillreg.p must be a predicate"); | |
3748 | return; | |
3749 | } | |
3750 | ||
3751 | if (!convert_expr_to_ab_reg (&e2, &ab, ®)) | |
3752 | { | |
3753 | as_bad ("Second operand to .spillreg.p must be a preserved register"); | |
3754 | return; | |
3755 | } | |
3756 | ||
3757 | if (!convert_expr_to_xy_reg (&e3, &xy, &treg)) | |
3758 | { | |
3759 | as_bad ("Third operand to .spillreg.p must be a register"); | |
3760 | return; | |
3761 | } | |
3762 | ||
3763 | add_unwind_entry (output_spill_reg_p (ab, reg, treg, xy, qp)); | |
3764 | } | |
3765 | ||
3766 | static void | |
3767 | dot_spillmem_p (psprel) | |
3768 | int psprel; | |
3769 | { | |
3770 | expressionS e1, e2, e3; | |
3771 | int sep, ab, reg; | |
3772 | unsigned int qp; | |
3773 | ||
3774 | sep = parse_operand (&e1); | |
3775 | if (sep != ',') | |
3776 | { | |
3777 | as_bad ("Second operand missing"); | |
3778 | return; | |
3779 | } | |
3780 | ||
3781 | parse_operand (&e2); | |
3782 | if (sep != ',') | |
3783 | { | |
3784 | as_bad ("Second operand missing"); | |
3785 | return; | |
3786 | } | |
3787 | ||
3788 | parse_operand (&e3); | |
3789 | ||
3790 | qp = e1.X_add_number - REG_P; | |
3791 | if (e1.X_op != O_register || qp > 63) | |
3792 | { | |
3793 | as_bad ("First operand to .spill%s_p must be a predicate", | |
3794 | psprel ? "psp" : "sp"); | |
3795 | return; | |
3796 | } | |
3797 | ||
3798 | if (!convert_expr_to_ab_reg (&e2, &ab, ®)) | |
3799 | { | |
3800 | as_bad ("Second operand to .spill%s_p must be a preserved register", | |
3801 | psprel ? "psp" : "sp"); | |
3802 | return; | |
3803 | } | |
3804 | ||
3805 | if (e3.X_op != O_constant) | |
3806 | { | |
3807 | as_bad ("Third operand to .spill%s_p must be a constant", | |
3808 | psprel ? "psp" : "sp"); | |
3809 | return; | |
3810 | } | |
3811 | ||
3812 | if (psprel) | |
fa7fda74 | 3813 | add_unwind_entry (output_spill_psprel_p (ab, reg, e3.X_add_number, qp)); |
e0c9811a | 3814 | else |
fa7fda74 | 3815 | add_unwind_entry (output_spill_sprel_p (ab, reg, e3.X_add_number, qp)); |
e0c9811a JW |
3816 | } |
3817 | ||
6290819d NC |
3818 | static unsigned int |
3819 | get_saved_prologue_count (lbl) | |
3820 | unsigned long lbl; | |
3821 | { | |
3822 | label_prologue_count *lpc = unwind.saved_prologue_counts; | |
3823 | ||
3824 | while (lpc != NULL && lpc->label_number != lbl) | |
3825 | lpc = lpc->next; | |
3826 | ||
3827 | if (lpc != NULL) | |
3828 | return lpc->prologue_count; | |
3829 | ||
3830 | as_bad ("Missing .label_state %ld", lbl); | |
3831 | return 1; | |
3832 | } | |
3833 | ||
3834 | static void | |
3835 | save_prologue_count (lbl, count) | |
3836 | unsigned long lbl; | |
3837 | unsigned int count; | |
3838 | { | |
3839 | label_prologue_count *lpc = unwind.saved_prologue_counts; | |
3840 | ||
3841 | while (lpc != NULL && lpc->label_number != lbl) | |
3842 | lpc = lpc->next; | |
3843 | ||
3844 | if (lpc != NULL) | |
3845 | lpc->prologue_count = count; | |
3846 | else | |
3847 | { | |
40449e9f | 3848 | label_prologue_count *new_lpc = xmalloc (sizeof (* new_lpc)); |
6290819d NC |
3849 | |
3850 | new_lpc->next = unwind.saved_prologue_counts; | |
3851 | new_lpc->label_number = lbl; | |
3852 | new_lpc->prologue_count = count; | |
3853 | unwind.saved_prologue_counts = new_lpc; | |
3854 | } | |
3855 | } | |
3856 | ||
3857 | static void | |
3858 | free_saved_prologue_counts () | |
3859 | { | |
40449e9f KH |
3860 | label_prologue_count *lpc = unwind.saved_prologue_counts; |
3861 | label_prologue_count *next; | |
6290819d NC |
3862 | |
3863 | while (lpc != NULL) | |
3864 | { | |
3865 | next = lpc->next; | |
3866 | free (lpc); | |
3867 | lpc = next; | |
3868 | } | |
3869 | ||
3870 | unwind.saved_prologue_counts = NULL; | |
3871 | } | |
3872 | ||
e0c9811a JW |
3873 | static void |
3874 | dot_label_state (dummy) | |
2434f565 | 3875 | int dummy ATTRIBUTE_UNUSED; |
e0c9811a JW |
3876 | { |
3877 | expressionS e; | |
3878 | ||
3879 | parse_operand (&e); | |
3880 | if (e.X_op != O_constant) | |
3881 | { | |
3882 | as_bad ("Operand to .label_state must be a constant"); | |
3883 | return; | |
3884 | } | |
3885 | add_unwind_entry (output_label_state (e.X_add_number)); | |
6290819d | 3886 | save_prologue_count (e.X_add_number, unwind.prologue_count); |
e0c9811a JW |
3887 | } |
3888 | ||
3889 | static void | |
3890 | dot_copy_state (dummy) | |
2434f565 | 3891 | int dummy ATTRIBUTE_UNUSED; |
e0c9811a JW |
3892 | { |
3893 | expressionS e; | |
3894 | ||
3895 | parse_operand (&e); | |
3896 | if (e.X_op != O_constant) | |
3897 | { | |
3898 | as_bad ("Operand to .copy_state must be a constant"); | |
3899 | return; | |
3900 | } | |
3901 | add_unwind_entry (output_copy_state (e.X_add_number)); | |
6290819d | 3902 | unwind.prologue_count = get_saved_prologue_count (e.X_add_number); |
800eeca4 JW |
3903 | } |
3904 | ||
197865e8 | 3905 | static void |
800eeca4 | 3906 | dot_unwabi (dummy) |
2434f565 | 3907 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 | 3908 | { |
e0c9811a JW |
3909 | expressionS e1, e2; |
3910 | unsigned char sep; | |
3911 | ||
3912 | sep = parse_operand (&e1); | |
3913 | if (sep != ',') | |
3914 | { | |
3915 | as_bad ("Second operand to .unwabi missing"); | |
3916 | return; | |
3917 | } | |
3918 | sep = parse_operand (&e2); | |
3919 | if (!is_end_of_line[sep] && !is_it_end_of_statement ()) | |
3920 | ignore_rest_of_line (); | |
3921 | ||
3922 | if (e1.X_op != O_constant) | |
3923 | { | |
3924 | as_bad ("First operand to .unwabi must be a constant"); | |
3925 | return; | |
3926 | } | |
3927 | ||
3928 | if (e2.X_op != O_constant) | |
3929 | { | |
3930 | as_bad ("Second operand to .unwabi must be a constant"); | |
3931 | return; | |
3932 | } | |
3933 | ||
3934 | add_unwind_entry (output_unwabi (e1.X_add_number, e2.X_add_number)); | |
800eeca4 JW |
3935 | } |
3936 | ||
197865e8 | 3937 | static void |
800eeca4 | 3938 | dot_personality (dummy) |
2434f565 | 3939 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
3940 | { |
3941 | char *name, *p, c; | |
3942 | SKIP_WHITESPACE (); | |
3943 | name = input_line_pointer; | |
3944 | c = get_symbol_end (); | |
3945 | p = input_line_pointer; | |
e0c9811a | 3946 | unwind.personality_routine = symbol_find_or_make (name); |
91a2ae2a | 3947 | unwind.force_unwind_entry = 1; |
800eeca4 JW |
3948 | *p = c; |
3949 | SKIP_WHITESPACE (); | |
3950 | demand_empty_rest_of_line (); | |
3951 | } | |
3952 | ||
3953 | static void | |
3954 | dot_proc (dummy) | |
2434f565 | 3955 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
3956 | { |
3957 | char *name, *p, c; | |
3958 | symbolS *sym; | |
3959 | ||
e0c9811a JW |
3960 | unwind.proc_start = expr_build_dot (); |
3961 | /* Parse names of main and alternate entry points and mark them as | |
542d6675 | 3962 | function symbols: */ |
800eeca4 JW |
3963 | while (1) |
3964 | { | |
3965 | SKIP_WHITESPACE (); | |
3966 | name = input_line_pointer; | |
3967 | c = get_symbol_end (); | |
3968 | p = input_line_pointer; | |
3969 | sym = symbol_find_or_make (name); | |
e0c9811a | 3970 | if (unwind.proc_start == 0) |
542d6675 | 3971 | { |
e0c9811a | 3972 | unwind.proc_start = sym; |
800eeca4 JW |
3973 | } |
3974 | symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION; | |
3975 | *p = c; | |
3976 | SKIP_WHITESPACE (); | |
3977 | if (*input_line_pointer != ',') | |
3978 | break; | |
3979 | ++input_line_pointer; | |
3980 | } | |
3981 | demand_empty_rest_of_line (); | |
3982 | ia64_do_align (16); | |
3983 | ||
33d01f33 | 3984 | unwind.prologue_count = 0; |
e0c9811a JW |
3985 | unwind.list = unwind.tail = unwind.current_entry = NULL; |
3986 | unwind.personality_routine = 0; | |
800eeca4 JW |
3987 | } |
3988 | ||
3989 | static void | |
3990 | dot_body (dummy) | |
2434f565 | 3991 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 | 3992 | { |
e0c9811a | 3993 | unwind.prologue = 0; |
30d25259 RH |
3994 | unwind.prologue_mask = 0; |
3995 | ||
800eeca4 | 3996 | add_unwind_entry (output_body ()); |
e0c9811a | 3997 | demand_empty_rest_of_line (); |
800eeca4 JW |
3998 | } |
3999 | ||
4000 | static void | |
4001 | dot_prologue (dummy) | |
2434f565 | 4002 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 | 4003 | { |
e0c9811a | 4004 | unsigned char sep; |
2434f565 | 4005 | int mask = 0, grsave = 0; |
e0c9811a | 4006 | |
e0c9811a | 4007 | if (!is_it_end_of_statement ()) |
800eeca4 JW |
4008 | { |
4009 | expressionS e1, e2; | |
800eeca4 JW |
4010 | sep = parse_operand (&e1); |
4011 | if (sep != ',') | |
4012 | as_bad ("No second operand to .prologue"); | |
4013 | sep = parse_operand (&e2); | |
e0c9811a | 4014 | if (!is_end_of_line[sep] && !is_it_end_of_statement ()) |
542d6675 | 4015 | ignore_rest_of_line (); |
800eeca4 JW |
4016 | |
4017 | if (e1.X_op == O_constant) | |
542d6675 | 4018 | { |
30d25259 RH |
4019 | mask = e1.X_add_number; |
4020 | ||
800eeca4 | 4021 | if (e2.X_op == O_constant) |
30d25259 RH |
4022 | grsave = e2.X_add_number; |
4023 | else if (e2.X_op == O_register | |
4024 | && (grsave = e2.X_add_number - REG_GR) < 128) | |
4025 | ; | |
800eeca4 | 4026 | else |
30d25259 RH |
4027 | as_bad ("Second operand not a constant or general register"); |
4028 | ||
4029 | add_unwind_entry (output_prologue_gr (mask, grsave)); | |
800eeca4 JW |
4030 | } |
4031 | else | |
4032 | as_bad ("First operand not a constant"); | |
4033 | } | |
4034 | else | |
4035 | add_unwind_entry (output_prologue ()); | |
30d25259 RH |
4036 | |
4037 | unwind.prologue = 1; | |
4038 | unwind.prologue_mask = mask; | |
33d01f33 | 4039 | ++unwind.prologue_count; |
800eeca4 JW |
4040 | } |
4041 | ||
4042 | static void | |
4043 | dot_endp (dummy) | |
2434f565 | 4044 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
4045 | { |
4046 | expressionS e; | |
4047 | unsigned char *ptr; | |
44f5c83a | 4048 | int bytes_per_address; |
800eeca4 JW |
4049 | long where; |
4050 | segT saved_seg; | |
4051 | subsegT saved_subseg; | |
91a2ae2a | 4052 | const char *sec_name, *text_name; |
c538998c JJ |
4053 | char *name, *p, c; |
4054 | symbolS *sym; | |
800eeca4 | 4055 | |
91a2ae2a RH |
4056 | if (unwind.saved_text_seg) |
4057 | { | |
4058 | saved_seg = unwind.saved_text_seg; | |
4059 | saved_subseg = unwind.saved_text_subseg; | |
4060 | unwind.saved_text_seg = NULL; | |
4061 | } | |
4062 | else | |
4063 | { | |
4064 | saved_seg = now_seg; | |
4065 | saved_subseg = now_subseg; | |
4066 | } | |
4067 | ||
4068 | /* | |
4069 | Use a slightly ugly scheme to derive the unwind section names from | |
4070 | the text section name: | |
4071 | ||
4072 | text sect. unwind table sect. | |
4073 | name: name: comments: | |
4074 | ---------- ----------------- -------------------------------- | |
4075 | .text .IA_64.unwind | |
4076 | .text.foo .IA_64.unwind.text.foo | |
4077 | .foo .IA_64.unwind.foo | |
579f31ac JJ |
4078 | .gnu.linkonce.t.foo |
4079 | .gnu.linkonce.ia64unw.foo | |
91a2ae2a RH |
4080 | _info .IA_64.unwind_info gas issues error message (ditto) |
4081 | _infoFOO .IA_64.unwind_infoFOO gas issues error message (ditto) | |
4082 | ||
4083 | This mapping is done so that: | |
4084 | ||
4085 | (a) An object file with unwind info only in .text will use | |
4086 | unwind section names .IA_64.unwind and .IA_64.unwind_info. | |
4087 | This follows the letter of the ABI and also ensures backwards | |
4088 | compatibility with older toolchains. | |
4089 | ||
4090 | (b) An object file with unwind info in multiple text sections | |
4091 | will use separate unwind sections for each text section. | |
4092 | This allows us to properly set the "sh_info" and "sh_link" | |
4093 | fields in SHT_IA_64_UNWIND as required by the ABI and also | |
4094 | lets GNU ld support programs with multiple segments | |
4095 | containing unwind info (as might be the case for certain | |
4096 | embedded applications). | |
40449e9f | 4097 | |
91a2ae2a RH |
4098 | (c) An error is issued if there would be a name clash. |
4099 | */ | |
4100 | text_name = segment_name (saved_seg); | |
4101 | if (strncmp (text_name, "_info", 5) == 0) | |
4102 | { | |
4103 | as_bad ("Illegal section name `%s' (causes unwind section name clash)", | |
4104 | text_name); | |
4105 | ignore_rest_of_line (); | |
4106 | return; | |
4107 | } | |
4108 | if (strcmp (text_name, ".text") == 0) | |
4109 | text_name = ""; | |
800eeca4 | 4110 | |
800eeca4 | 4111 | insn_group_break (1, 0, 0); |
800eeca4 | 4112 | |
91a2ae2a RH |
4113 | /* If there wasn't a .handlerdata, we haven't generated an image yet. */ |
4114 | if (!unwind.info) | |
4115 | generate_unwind_image (text_name); | |
800eeca4 | 4116 | |
91a2ae2a RH |
4117 | if (unwind.info || unwind.force_unwind_entry) |
4118 | { | |
4119 | subseg_set (md.last_text_seg, 0); | |
4120 | unwind.proc_end = expr_build_dot (); | |
5e7474a7 | 4121 | |
91a2ae2a RH |
4122 | make_unw_section_name (SPECIAL_SECTION_UNWIND, text_name, sec_name); |
4123 | set_section ((char *) sec_name); | |
4124 | bfd_set_section_flags (stdoutput, now_seg, | |
4125 | SEC_LOAD | SEC_ALLOC | SEC_READONLY); | |
5e7474a7 | 4126 | |
557debba JW |
4127 | /* Make sure that section has 4 byte alignment for ILP32 and |
4128 | 8 byte alignment for LP64. */ | |
4129 | record_alignment (now_seg, md.pointer_size_shift); | |
800eeca4 | 4130 | |
557debba JW |
4131 | /* Need space for 3 pointers for procedure start, procedure end, |
4132 | and unwind info. */ | |
4133 | ptr = frag_more (3 * md.pointer_size); | |
4134 | where = frag_now_fix () - (3 * md.pointer_size); | |
91a2ae2a | 4135 | bytes_per_address = bfd_arch_bits_per_address (stdoutput) / 8; |
800eeca4 | 4136 | |
40449e9f | 4137 | /* Issue the values of a) Proc Begin, b) Proc End, c) Unwind Record. */ |
91a2ae2a RH |
4138 | e.X_op = O_pseudo_fixup; |
4139 | e.X_op_symbol = pseudo_func[FUNC_SEG_RELATIVE].u.sym; | |
4140 | e.X_add_number = 0; | |
4141 | e.X_add_symbol = unwind.proc_start; | |
4142 | ia64_cons_fix_new (frag_now, where, bytes_per_address, &e); | |
800eeca4 | 4143 | |
800eeca4 JW |
4144 | e.X_op = O_pseudo_fixup; |
4145 | e.X_op_symbol = pseudo_func[FUNC_SEG_RELATIVE].u.sym; | |
4146 | e.X_add_number = 0; | |
91a2ae2a RH |
4147 | e.X_add_symbol = unwind.proc_end; |
4148 | ia64_cons_fix_new (frag_now, where + bytes_per_address, | |
4149 | bytes_per_address, &e); | |
4150 | ||
4151 | if (unwind.info) | |
4152 | { | |
4153 | e.X_op = O_pseudo_fixup; | |
4154 | e.X_op_symbol = pseudo_func[FUNC_SEG_RELATIVE].u.sym; | |
4155 | e.X_add_number = 0; | |
4156 | e.X_add_symbol = unwind.info; | |
4157 | ia64_cons_fix_new (frag_now, where + (bytes_per_address * 2), | |
4158 | bytes_per_address, &e); | |
4159 | } | |
4160 | else | |
4161 | md_number_to_chars (ptr + (bytes_per_address * 2), 0, | |
4162 | bytes_per_address); | |
800eeca4 | 4163 | |
91a2ae2a | 4164 | } |
800eeca4 | 4165 | subseg_set (saved_seg, saved_subseg); |
c538998c JJ |
4166 | |
4167 | /* Parse names of main and alternate entry points and set symbol sizes. */ | |
4168 | while (1) | |
4169 | { | |
4170 | SKIP_WHITESPACE (); | |
4171 | name = input_line_pointer; | |
4172 | c = get_symbol_end (); | |
4173 | p = input_line_pointer; | |
4174 | sym = symbol_find (name); | |
4175 | if (sym && unwind.proc_start | |
4176 | && (symbol_get_bfdsym (sym)->flags & BSF_FUNCTION) | |
4177 | && S_GET_SIZE (sym) == 0 && symbol_get_obj (sym)->size == NULL) | |
4178 | { | |
4179 | fragS *fr = symbol_get_frag (unwind.proc_start); | |
4180 | fragS *frag = symbol_get_frag (sym); | |
4181 | ||
4182 | /* Check whether the function label is at or beyond last | |
4183 | .proc directive. */ | |
4184 | while (fr && fr != frag) | |
4185 | fr = fr->fr_next; | |
4186 | if (fr) | |
4187 | { | |
4188 | if (frag == frag_now && SEG_NORMAL (now_seg)) | |
4189 | S_SET_SIZE (sym, frag_now_fix () - S_GET_VALUE (sym)); | |
4190 | else | |
4191 | { | |
4192 | symbol_get_obj (sym)->size = | |
4193 | (expressionS *) xmalloc (sizeof (expressionS)); | |
4194 | symbol_get_obj (sym)->size->X_op = O_subtract; | |
4195 | symbol_get_obj (sym)->size->X_add_symbol | |
4196 | = symbol_new (FAKE_LABEL_NAME, now_seg, | |
4197 | frag_now_fix (), frag_now); | |
4198 | symbol_get_obj (sym)->size->X_op_symbol = sym; | |
4199 | symbol_get_obj (sym)->size->X_add_number = 0; | |
4200 | } | |
4201 | } | |
4202 | } | |
4203 | *p = c; | |
4204 | SKIP_WHITESPACE (); | |
4205 | if (*input_line_pointer != ',') | |
4206 | break; | |
4207 | ++input_line_pointer; | |
4208 | } | |
4209 | demand_empty_rest_of_line (); | |
e0c9811a | 4210 | unwind.proc_start = unwind.proc_end = unwind.info = 0; |
800eeca4 JW |
4211 | } |
4212 | ||
4213 | static void | |
4214 | dot_template (template) | |
4215 | int template; | |
4216 | { | |
4217 | CURR_SLOT.user_template = template; | |
4218 | } | |
4219 | ||
4220 | static void | |
4221 | dot_regstk (dummy) | |
2434f565 | 4222 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
4223 | { |
4224 | int ins, locs, outs, rots; | |
4225 | ||
4226 | if (is_it_end_of_statement ()) | |
4227 | ins = locs = outs = rots = 0; | |
4228 | else | |
4229 | { | |
4230 | ins = get_absolute_expression (); | |
4231 | if (*input_line_pointer++ != ',') | |
4232 | goto err; | |
4233 | locs = get_absolute_expression (); | |
4234 | if (*input_line_pointer++ != ',') | |
4235 | goto err; | |
4236 | outs = get_absolute_expression (); | |
4237 | if (*input_line_pointer++ != ',') | |
4238 | goto err; | |
4239 | rots = get_absolute_expression (); | |
4240 | } | |
4241 | set_regstack (ins, locs, outs, rots); | |
4242 | return; | |
4243 | ||
4244 | err: | |
4245 | as_bad ("Comma expected"); | |
4246 | ignore_rest_of_line (); | |
4247 | } | |
4248 | ||
4249 | static void | |
4250 | dot_rot (type) | |
4251 | int type; | |
4252 | { | |
4253 | unsigned num_regs, num_alloced = 0; | |
4254 | struct dynreg **drpp, *dr; | |
4255 | int ch, base_reg = 0; | |
4256 | char *name, *start; | |
4257 | size_t len; | |
4258 | ||
4259 | switch (type) | |
4260 | { | |
4261 | case DYNREG_GR: base_reg = REG_GR + 32; break; | |
4262 | case DYNREG_FR: base_reg = REG_FR + 32; break; | |
4263 | case DYNREG_PR: base_reg = REG_P + 16; break; | |
4264 | default: break; | |
4265 | } | |
4266 | ||
542d6675 | 4267 | /* First, remove existing names from hash table. */ |
800eeca4 JW |
4268 | for (dr = md.dynreg[type]; dr && dr->num_regs; dr = dr->next) |
4269 | { | |
4270 | hash_delete (md.dynreg_hash, dr->name); | |
4271 | dr->num_regs = 0; | |
4272 | } | |
4273 | ||
4274 | drpp = &md.dynreg[type]; | |
4275 | while (1) | |
4276 | { | |
4277 | start = input_line_pointer; | |
4278 | ch = get_symbol_end (); | |
4279 | *input_line_pointer = ch; | |
4280 | len = (input_line_pointer - start); | |
4281 | ||
4282 | SKIP_WHITESPACE (); | |
4283 | if (*input_line_pointer != '[') | |
4284 | { | |
4285 | as_bad ("Expected '['"); | |
4286 | goto err; | |
4287 | } | |
4288 | ++input_line_pointer; /* skip '[' */ | |
4289 | ||
4290 | num_regs = get_absolute_expression (); | |
4291 | ||
4292 | if (*input_line_pointer++ != ']') | |
4293 | { | |
4294 | as_bad ("Expected ']'"); | |
4295 | goto err; | |
4296 | } | |
4297 | SKIP_WHITESPACE (); | |
4298 | ||
4299 | num_alloced += num_regs; | |
4300 | switch (type) | |
4301 | { | |
4302 | case DYNREG_GR: | |
4303 | if (num_alloced > md.rot.num_regs) | |
4304 | { | |
4305 | as_bad ("Used more than the declared %d rotating registers", | |
4306 | md.rot.num_regs); | |
4307 | goto err; | |
4308 | } | |
4309 | break; | |
4310 | case DYNREG_FR: | |
4311 | if (num_alloced > 96) | |
4312 | { | |
4313 | as_bad ("Used more than the available 96 rotating registers"); | |
4314 | goto err; | |
4315 | } | |
4316 | break; | |
4317 | case DYNREG_PR: | |
4318 | if (num_alloced > 48) | |
4319 | { | |
4320 | as_bad ("Used more than the available 48 rotating registers"); | |
4321 | goto err; | |
4322 | } | |
4323 | break; | |
4324 | ||
4325 | default: | |
4326 | break; | |
4327 | } | |
4328 | ||
4329 | name = obstack_alloc (¬es, len + 1); | |
4330 | memcpy (name, start, len); | |
4331 | name[len] = '\0'; | |
4332 | ||
4333 | if (!*drpp) | |
4334 | { | |
4335 | *drpp = obstack_alloc (¬es, sizeof (*dr)); | |
4336 | memset (*drpp, 0, sizeof (*dr)); | |
4337 | } | |
4338 | ||
4339 | dr = *drpp; | |
4340 | dr->name = name; | |
4341 | dr->num_regs = num_regs; | |
4342 | dr->base = base_reg; | |
4343 | drpp = &dr->next; | |
4344 | base_reg += num_regs; | |
4345 | ||
4346 | if (hash_insert (md.dynreg_hash, name, dr)) | |
4347 | { | |
4348 | as_bad ("Attempt to redefine register set `%s'", name); | |
4349 | goto err; | |
4350 | } | |
4351 | ||
4352 | if (*input_line_pointer != ',') | |
4353 | break; | |
4354 | ++input_line_pointer; /* skip comma */ | |
4355 | SKIP_WHITESPACE (); | |
4356 | } | |
4357 | demand_empty_rest_of_line (); | |
4358 | return; | |
4359 | ||
4360 | err: | |
4361 | ignore_rest_of_line (); | |
4362 | } | |
4363 | ||
4364 | static void | |
4365 | dot_byteorder (byteorder) | |
4366 | int byteorder; | |
4367 | { | |
10a98291 L |
4368 | segment_info_type *seginfo = seg_info (now_seg); |
4369 | ||
4370 | if (byteorder == -1) | |
4371 | { | |
4372 | if (seginfo->tc_segment_info_data.endian == 0) | |
4373 | seginfo->tc_segment_info_data.endian | |
4374 | = TARGET_BYTES_BIG_ENDIAN ? 1 : 2; | |
4375 | byteorder = seginfo->tc_segment_info_data.endian == 1; | |
4376 | } | |
4377 | else | |
4378 | seginfo->tc_segment_info_data.endian = byteorder ? 1 : 2; | |
4379 | ||
4380 | if (target_big_endian != byteorder) | |
4381 | { | |
4382 | target_big_endian = byteorder; | |
4383 | if (target_big_endian) | |
4384 | { | |
4385 | ia64_number_to_chars = number_to_chars_bigendian; | |
4386 | ia64_float_to_chars = ia64_float_to_chars_bigendian; | |
4387 | } | |
4388 | else | |
4389 | { | |
4390 | ia64_number_to_chars = number_to_chars_littleendian; | |
4391 | ia64_float_to_chars = ia64_float_to_chars_littleendian; | |
4392 | } | |
4393 | } | |
800eeca4 JW |
4394 | } |
4395 | ||
4396 | static void | |
4397 | dot_psr (dummy) | |
2434f565 | 4398 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
4399 | { |
4400 | char *option; | |
4401 | int ch; | |
4402 | ||
4403 | while (1) | |
4404 | { | |
4405 | option = input_line_pointer; | |
4406 | ch = get_symbol_end (); | |
4407 | if (strcmp (option, "lsb") == 0) | |
4408 | md.flags &= ~EF_IA_64_BE; | |
4409 | else if (strcmp (option, "msb") == 0) | |
4410 | md.flags |= EF_IA_64_BE; | |
4411 | else if (strcmp (option, "abi32") == 0) | |
4412 | md.flags &= ~EF_IA_64_ABI64; | |
4413 | else if (strcmp (option, "abi64") == 0) | |
4414 | md.flags |= EF_IA_64_ABI64; | |
4415 | else | |
4416 | as_bad ("Unknown psr option `%s'", option); | |
4417 | *input_line_pointer = ch; | |
4418 | ||
4419 | SKIP_WHITESPACE (); | |
4420 | if (*input_line_pointer != ',') | |
4421 | break; | |
4422 | ||
4423 | ++input_line_pointer; | |
4424 | SKIP_WHITESPACE (); | |
4425 | } | |
4426 | demand_empty_rest_of_line (); | |
4427 | } | |
4428 | ||
800eeca4 JW |
4429 | static void |
4430 | dot_ln (dummy) | |
2434f565 | 4431 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
4432 | { |
4433 | new_logical_line (0, get_absolute_expression ()); | |
4434 | demand_empty_rest_of_line (); | |
4435 | } | |
4436 | ||
542d6675 | 4437 | static char * |
800eeca4 JW |
4438 | parse_section_name () |
4439 | { | |
4440 | char *name; | |
4441 | int len; | |
4442 | ||
4443 | SKIP_WHITESPACE (); | |
4444 | if (*input_line_pointer != '"') | |
4445 | { | |
4446 | as_bad ("Missing section name"); | |
4447 | ignore_rest_of_line (); | |
4448 | return 0; | |
4449 | } | |
4450 | name = demand_copy_C_string (&len); | |
4451 | if (!name) | |
4452 | { | |
4453 | ignore_rest_of_line (); | |
4454 | return 0; | |
4455 | } | |
4456 | SKIP_WHITESPACE (); | |
4457 | if (*input_line_pointer != ',') | |
4458 | { | |
4459 | as_bad ("Comma expected after section name"); | |
4460 | ignore_rest_of_line (); | |
4461 | return 0; | |
4462 | } | |
4463 | ++input_line_pointer; /* skip comma */ | |
4464 | return name; | |
4465 | } | |
4466 | ||
4467 | static void | |
4468 | dot_xdata (size) | |
4469 | int size; | |
4470 | { | |
4471 | char *name = parse_section_name (); | |
4472 | if (!name) | |
4473 | return; | |
4474 | ||
4d5a53ff | 4475 | md.keep_pending_output = 1; |
800eeca4 JW |
4476 | set_section (name); |
4477 | cons (size); | |
4478 | obj_elf_previous (0); | |
4d5a53ff | 4479 | md.keep_pending_output = 0; |
800eeca4 JW |
4480 | } |
4481 | ||
4482 | /* Why doesn't float_cons() call md_cons_align() the way cons() does? */ | |
542d6675 | 4483 | |
800eeca4 JW |
4484 | static void |
4485 | stmt_float_cons (kind) | |
4486 | int kind; | |
4487 | { | |
165a7f90 | 4488 | size_t alignment; |
800eeca4 JW |
4489 | |
4490 | switch (kind) | |
4491 | { | |
165a7f90 L |
4492 | case 'd': |
4493 | alignment = 8; | |
4494 | break; | |
4495 | ||
4496 | case 'x': | |
4497 | case 'X': | |
4498 | alignment = 16; | |
4499 | break; | |
800eeca4 JW |
4500 | |
4501 | case 'f': | |
4502 | default: | |
165a7f90 | 4503 | alignment = 4; |
800eeca4 JW |
4504 | break; |
4505 | } | |
165a7f90 | 4506 | ia64_do_align (alignment); |
800eeca4 JW |
4507 | float_cons (kind); |
4508 | } | |
4509 | ||
4510 | static void | |
4511 | stmt_cons_ua (size) | |
4512 | int size; | |
4513 | { | |
4514 | int saved_auto_align = md.auto_align; | |
4515 | ||
4516 | md.auto_align = 0; | |
4517 | cons (size); | |
4518 | md.auto_align = saved_auto_align; | |
4519 | } | |
4520 | ||
4521 | static void | |
4522 | dot_xfloat_cons (kind) | |
4523 | int kind; | |
4524 | { | |
4525 | char *name = parse_section_name (); | |
4526 | if (!name) | |
4527 | return; | |
4528 | ||
4d5a53ff | 4529 | md.keep_pending_output = 1; |
800eeca4 JW |
4530 | set_section (name); |
4531 | stmt_float_cons (kind); | |
4532 | obj_elf_previous (0); | |
4d5a53ff | 4533 | md.keep_pending_output = 0; |
800eeca4 JW |
4534 | } |
4535 | ||
4536 | static void | |
4537 | dot_xstringer (zero) | |
4538 | int zero; | |
4539 | { | |
4540 | char *name = parse_section_name (); | |
4541 | if (!name) | |
4542 | return; | |
4543 | ||
4d5a53ff | 4544 | md.keep_pending_output = 1; |
800eeca4 JW |
4545 | set_section (name); |
4546 | stringer (zero); | |
4547 | obj_elf_previous (0); | |
4d5a53ff | 4548 | md.keep_pending_output = 0; |
800eeca4 JW |
4549 | } |
4550 | ||
4551 | static void | |
4552 | dot_xdata_ua (size) | |
4553 | int size; | |
4554 | { | |
4555 | int saved_auto_align = md.auto_align; | |
4556 | char *name = parse_section_name (); | |
4557 | if (!name) | |
4558 | return; | |
4559 | ||
4d5a53ff | 4560 | md.keep_pending_output = 1; |
800eeca4 JW |
4561 | set_section (name); |
4562 | md.auto_align = 0; | |
4563 | cons (size); | |
4564 | md.auto_align = saved_auto_align; | |
4565 | obj_elf_previous (0); | |
4d5a53ff | 4566 | md.keep_pending_output = 0; |
800eeca4 JW |
4567 | } |
4568 | ||
4569 | static void | |
4570 | dot_xfloat_cons_ua (kind) | |
4571 | int kind; | |
4572 | { | |
4573 | int saved_auto_align = md.auto_align; | |
4574 | char *name = parse_section_name (); | |
4575 | if (!name) | |
4576 | return; | |
4577 | ||
4d5a53ff | 4578 | md.keep_pending_output = 1; |
800eeca4 JW |
4579 | set_section (name); |
4580 | md.auto_align = 0; | |
4581 | stmt_float_cons (kind); | |
4582 | md.auto_align = saved_auto_align; | |
4583 | obj_elf_previous (0); | |
4d5a53ff | 4584 | md.keep_pending_output = 0; |
800eeca4 JW |
4585 | } |
4586 | ||
4587 | /* .reg.val <regname>,value */ | |
542d6675 | 4588 | |
800eeca4 JW |
4589 | static void |
4590 | dot_reg_val (dummy) | |
2434f565 | 4591 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
4592 | { |
4593 | expressionS reg; | |
4594 | ||
4595 | expression (®); | |
4596 | if (reg.X_op != O_register) | |
4597 | { | |
4598 | as_bad (_("Register name expected")); | |
4599 | ignore_rest_of_line (); | |
4600 | } | |
4601 | else if (*input_line_pointer++ != ',') | |
4602 | { | |
4603 | as_bad (_("Comma expected")); | |
4604 | ignore_rest_of_line (); | |
4605 | } | |
197865e8 | 4606 | else |
800eeca4 JW |
4607 | { |
4608 | valueT value = get_absolute_expression (); | |
4609 | int regno = reg.X_add_number; | |
542d6675 KH |
4610 | if (regno < REG_GR || regno > REG_GR + 128) |
4611 | as_warn (_("Register value annotation ignored")); | |
800eeca4 | 4612 | else |
542d6675 KH |
4613 | { |
4614 | gr_values[regno - REG_GR].known = 1; | |
4615 | gr_values[regno - REG_GR].value = value; | |
4616 | gr_values[regno - REG_GR].path = md.path; | |
4617 | } | |
800eeca4 JW |
4618 | } |
4619 | demand_empty_rest_of_line (); | |
4620 | } | |
4621 | ||
197865e8 | 4622 | /* select dv checking mode |
800eeca4 JW |
4623 | .auto |
4624 | .explicit | |
4625 | .default | |
4626 | ||
197865e8 | 4627 | A stop is inserted when changing modes |
800eeca4 | 4628 | */ |
542d6675 | 4629 | |
800eeca4 JW |
4630 | static void |
4631 | dot_dv_mode (type) | |
542d6675 | 4632 | int type; |
800eeca4 JW |
4633 | { |
4634 | if (md.manual_bundling) | |
4635 | as_warn (_("Directive invalid within a bundle")); | |
4636 | ||
4637 | if (type == 'E' || type == 'A') | |
4638 | md.mode_explicitly_set = 0; | |
4639 | else | |
4640 | md.mode_explicitly_set = 1; | |
4641 | ||
4642 | md.detect_dv = 1; | |
4643 | switch (type) | |
4644 | { | |
4645 | case 'A': | |
4646 | case 'a': | |
4647 | if (md.explicit_mode) | |
542d6675 | 4648 | insn_group_break (1, 0, 0); |
800eeca4 JW |
4649 | md.explicit_mode = 0; |
4650 | break; | |
4651 | case 'E': | |
4652 | case 'e': | |
4653 | if (!md.explicit_mode) | |
542d6675 | 4654 | insn_group_break (1, 0, 0); |
800eeca4 JW |
4655 | md.explicit_mode = 1; |
4656 | break; | |
4657 | default: | |
4658 | case 'd': | |
4659 | if (md.explicit_mode != md.default_explicit_mode) | |
542d6675 | 4660 | insn_group_break (1, 0, 0); |
800eeca4 JW |
4661 | md.explicit_mode = md.default_explicit_mode; |
4662 | md.mode_explicitly_set = 0; | |
4663 | break; | |
4664 | } | |
4665 | } | |
4666 | ||
4667 | static void | |
4668 | print_prmask (mask) | |
542d6675 | 4669 | valueT mask; |
800eeca4 JW |
4670 | { |
4671 | int regno; | |
4672 | char *comma = ""; | |
542d6675 | 4673 | for (regno = 0; regno < 64; regno++) |
800eeca4 | 4674 | { |
542d6675 KH |
4675 | if (mask & ((valueT) 1 << regno)) |
4676 | { | |
4677 | fprintf (stderr, "%s p%d", comma, regno); | |
4678 | comma = ","; | |
4679 | } | |
800eeca4 JW |
4680 | } |
4681 | } | |
4682 | ||
4683 | /* | |
4684 | .pred.rel.clear [p1 [,p2 [,...]]] (also .pred.rel "clear") | |
4685 | .pred.rel.imply p1, p2 (also .pred.rel "imply") | |
4686 | .pred.rel.mutex p1, p2 [,...] (also .pred.rel "mutex") | |
4687 | .pred.safe_across_calls p1 [, p2 [,...]] | |
4688 | */ | |
542d6675 | 4689 | |
800eeca4 JW |
4690 | static void |
4691 | dot_pred_rel (type) | |
542d6675 | 4692 | int type; |
800eeca4 JW |
4693 | { |
4694 | valueT mask = 0; | |
4695 | int count = 0; | |
4696 | int p1 = -1, p2 = -1; | |
4697 | ||
4698 | if (type == 0) | |
4699 | { | |
4700 | if (*input_line_pointer != '"') | |
542d6675 KH |
4701 | { |
4702 | as_bad (_("Missing predicate relation type")); | |
4703 | ignore_rest_of_line (); | |
4704 | return; | |
4705 | } | |
197865e8 | 4706 | else |
542d6675 KH |
4707 | { |
4708 | int len; | |
4709 | char *form = demand_copy_C_string (&len); | |
4710 | if (strcmp (form, "mutex") == 0) | |
4711 | type = 'm'; | |
4712 | else if (strcmp (form, "clear") == 0) | |
4713 | type = 'c'; | |
4714 | else if (strcmp (form, "imply") == 0) | |
4715 | type = 'i'; | |
4716 | else | |
4717 | { | |
4718 | as_bad (_("Unrecognized predicate relation type")); | |
4719 | ignore_rest_of_line (); | |
4720 | return; | |
4721 | } | |
4722 | } | |
800eeca4 | 4723 | if (*input_line_pointer == ',') |
542d6675 | 4724 | ++input_line_pointer; |
800eeca4 JW |
4725 | SKIP_WHITESPACE (); |
4726 | } | |
4727 | ||
4728 | SKIP_WHITESPACE (); | |
4729 | while (1) | |
4730 | { | |
4731 | valueT bit = 1; | |
4732 | int regno; | |
197865e8 | 4733 | |
3882b010 | 4734 | if (TOUPPER (*input_line_pointer) != 'P' |
542d6675 KH |
4735 | || (regno = atoi (++input_line_pointer)) < 0 |
4736 | || regno > 63) | |
4737 | { | |
4738 | as_bad (_("Predicate register expected")); | |
4739 | ignore_rest_of_line (); | |
4740 | return; | |
4741 | } | |
3882b010 | 4742 | while (ISDIGIT (*input_line_pointer)) |
542d6675 | 4743 | ++input_line_pointer; |
800eeca4 | 4744 | if (p1 == -1) |
542d6675 | 4745 | p1 = regno; |
800eeca4 | 4746 | else if (p2 == -1) |
542d6675 | 4747 | p2 = regno; |
800eeca4 JW |
4748 | bit <<= regno; |
4749 | if (mask & bit) | |
542d6675 KH |
4750 | as_warn (_("Duplicate predicate register ignored")); |
4751 | mask |= bit; | |
4752 | count++; | |
4753 | /* See if it's a range. */ | |
800eeca4 | 4754 | if (*input_line_pointer == '-') |
542d6675 KH |
4755 | { |
4756 | valueT stop = 1; | |
4757 | ++input_line_pointer; | |
4758 | ||
3882b010 | 4759 | if (TOUPPER (*input_line_pointer) != 'P' |
542d6675 KH |
4760 | || (regno = atoi (++input_line_pointer)) < 0 |
4761 | || regno > 63) | |
4762 | { | |
4763 | as_bad (_("Predicate register expected")); | |
4764 | ignore_rest_of_line (); | |
4765 | return; | |
4766 | } | |
3882b010 | 4767 | while (ISDIGIT (*input_line_pointer)) |
542d6675 KH |
4768 | ++input_line_pointer; |
4769 | stop <<= regno; | |
4770 | if (bit >= stop) | |
4771 | { | |
4772 | as_bad (_("Bad register range")); | |
4773 | ignore_rest_of_line (); | |
4774 | return; | |
4775 | } | |
4776 | while (bit < stop) | |
4777 | { | |
4778 | bit <<= 1; | |
4779 | mask |= bit; | |
4780 | count++; | |
4781 | } | |
4782 | SKIP_WHITESPACE (); | |
4783 | } | |
800eeca4 | 4784 | if (*input_line_pointer != ',') |
542d6675 | 4785 | break; |
800eeca4 JW |
4786 | ++input_line_pointer; |
4787 | SKIP_WHITESPACE (); | |
4788 | } | |
4789 | ||
4790 | switch (type) | |
4791 | { | |
4792 | case 'c': | |
4793 | if (count == 0) | |
542d6675 | 4794 | mask = ~(valueT) 0; |
800eeca4 | 4795 | clear_qp_mutex (mask); |
197865e8 | 4796 | clear_qp_implies (mask, (valueT) 0); |
800eeca4 JW |
4797 | break; |
4798 | case 'i': | |
4799 | if (count != 2 || p1 == -1 || p2 == -1) | |
542d6675 | 4800 | as_bad (_("Predicate source and target required")); |
800eeca4 | 4801 | else if (p1 == 0 || p2 == 0) |
542d6675 | 4802 | as_bad (_("Use of p0 is not valid in this context")); |
800eeca4 | 4803 | else |
542d6675 | 4804 | add_qp_imply (p1, p2); |
800eeca4 JW |
4805 | break; |
4806 | case 'm': | |
4807 | if (count < 2) | |
542d6675 KH |
4808 | { |
4809 | as_bad (_("At least two PR arguments expected")); | |
4810 | break; | |
4811 | } | |
800eeca4 | 4812 | else if (mask & 1) |
542d6675 KH |
4813 | { |
4814 | as_bad (_("Use of p0 is not valid in this context")); | |
4815 | break; | |
4816 | } | |
800eeca4 JW |
4817 | add_qp_mutex (mask); |
4818 | break; | |
4819 | case 's': | |
4820 | /* note that we don't override any existing relations */ | |
4821 | if (count == 0) | |
542d6675 KH |
4822 | { |
4823 | as_bad (_("At least one PR argument expected")); | |
4824 | break; | |
4825 | } | |
800eeca4 | 4826 | if (md.debug_dv) |
542d6675 KH |
4827 | { |
4828 | fprintf (stderr, "Safe across calls: "); | |
4829 | print_prmask (mask); | |
4830 | fprintf (stderr, "\n"); | |
4831 | } | |
800eeca4 JW |
4832 | qp_safe_across_calls = mask; |
4833 | break; | |
4834 | } | |
4835 | demand_empty_rest_of_line (); | |
4836 | } | |
4837 | ||
4838 | /* .entry label [, label [, ...]] | |
4839 | Hint to DV code that the given labels are to be considered entry points. | |
542d6675 KH |
4840 | Otherwise, only global labels are considered entry points. */ |
4841 | ||
800eeca4 JW |
4842 | static void |
4843 | dot_entry (dummy) | |
2434f565 | 4844 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
4845 | { |
4846 | const char *err; | |
4847 | char *name; | |
4848 | int c; | |
4849 | symbolS *symbolP; | |
4850 | ||
4851 | do | |
4852 | { | |
4853 | name = input_line_pointer; | |
4854 | c = get_symbol_end (); | |
4855 | symbolP = symbol_find_or_make (name); | |
4856 | ||
4857 | err = hash_insert (md.entry_hash, S_GET_NAME (symbolP), (PTR) symbolP); | |
4858 | if (err) | |
542d6675 KH |
4859 | as_fatal (_("Inserting \"%s\" into entry hint table failed: %s"), |
4860 | name, err); | |
800eeca4 JW |
4861 | |
4862 | *input_line_pointer = c; | |
4863 | SKIP_WHITESPACE (); | |
4864 | c = *input_line_pointer; | |
4865 | if (c == ',') | |
4866 | { | |
4867 | input_line_pointer++; | |
4868 | SKIP_WHITESPACE (); | |
4869 | if (*input_line_pointer == '\n') | |
4870 | c = '\n'; | |
4871 | } | |
4872 | } | |
4873 | while (c == ','); | |
4874 | ||
4875 | demand_empty_rest_of_line (); | |
4876 | } | |
4877 | ||
197865e8 | 4878 | /* .mem.offset offset, base |
542d6675 KH |
4879 | "base" is used to distinguish between offsets from a different base. */ |
4880 | ||
800eeca4 JW |
4881 | static void |
4882 | dot_mem_offset (dummy) | |
2434f565 | 4883 | int dummy ATTRIBUTE_UNUSED; |
800eeca4 JW |
4884 | { |
4885 | md.mem_offset.hint = 1; | |
4886 | md.mem_offset.offset = get_absolute_expression (); | |
4887 | if (*input_line_pointer != ',') | |
4888 | { | |
4889 | as_bad (_("Comma expected")); | |
4890 | ignore_rest_of_line (); | |
4891 | return; | |
4892 | } | |
4893 | ++input_line_pointer; | |
4894 | md.mem_offset.base = get_absolute_expression (); | |
4895 | demand_empty_rest_of_line (); | |
4896 | } | |
4897 | ||
542d6675 | 4898 | /* ia64-specific pseudo-ops: */ |
800eeca4 JW |
4899 | const pseudo_typeS md_pseudo_table[] = |
4900 | { | |
4901 | { "radix", dot_radix, 0 }, | |
4902 | { "lcomm", s_lcomm_bytes, 1 }, | |
4903 | { "bss", dot_special_section, SPECIAL_SECTION_BSS }, | |
4904 | { "sbss", dot_special_section, SPECIAL_SECTION_SBSS }, | |
4905 | { "sdata", dot_special_section, SPECIAL_SECTION_SDATA }, | |
4906 | { "rodata", dot_special_section, SPECIAL_SECTION_RODATA }, | |
4907 | { "comment", dot_special_section, SPECIAL_SECTION_COMMENT }, | |
4908 | { "ia_64.unwind", dot_special_section, SPECIAL_SECTION_UNWIND }, | |
4909 | { "ia_64.unwind_info", dot_special_section, SPECIAL_SECTION_UNWIND_INFO }, | |
557debba JW |
4910 | { "init_array", dot_special_section, SPECIAL_SECTION_INIT_ARRAY }, |
4911 | { "fini_array", dot_special_section, SPECIAL_SECTION_FINI_ARRAY }, | |
800eeca4 JW |
4912 | { "proc", dot_proc, 0 }, |
4913 | { "body", dot_body, 0 }, | |
4914 | { "prologue", dot_prologue, 0 }, | |
2434f565 | 4915 | { "endp", dot_endp, 0 }, |
2434f565 JW |
4916 | |
4917 | { "fframe", dot_fframe, 0 }, | |
4918 | { "vframe", dot_vframe, 0 }, | |
4919 | { "vframesp", dot_vframesp, 0 }, | |
4920 | { "vframepsp", dot_vframepsp, 0 }, | |
4921 | { "save", dot_save, 0 }, | |
4922 | { "restore", dot_restore, 0 }, | |
4923 | { "restorereg", dot_restorereg, 0 }, | |
4924 | { "restorereg.p", dot_restorereg_p, 0 }, | |
4925 | { "handlerdata", dot_handlerdata, 0 }, | |
4926 | { "unwentry", dot_unwentry, 0 }, | |
4927 | { "altrp", dot_altrp, 0 }, | |
e0c9811a JW |
4928 | { "savesp", dot_savemem, 0 }, |
4929 | { "savepsp", dot_savemem, 1 }, | |
2434f565 JW |
4930 | { "save.g", dot_saveg, 0 }, |
4931 | { "save.f", dot_savef, 0 }, | |
4932 | { "save.b", dot_saveb, 0 }, | |
4933 | { "save.gf", dot_savegf, 0 }, | |
4934 | { "spill", dot_spill, 0 }, | |
4935 | { "spillreg", dot_spillreg, 0 }, | |
e0c9811a JW |
4936 | { "spillsp", dot_spillmem, 0 }, |
4937 | { "spillpsp", dot_spillmem, 1 }, | |
2434f565 | 4938 | { "spillreg.p", dot_spillreg_p, 0 }, |
e0c9811a JW |
4939 | { "spillsp.p", dot_spillmem_p, 0 }, |
4940 | { "spillpsp.p", dot_spillmem_p, 1 }, | |
2434f565 JW |
4941 | { "label_state", dot_label_state, 0 }, |
4942 | { "copy_state", dot_copy_state, 0 }, | |
4943 | { "unwabi", dot_unwabi, 0 }, | |
4944 | { "personality", dot_personality, 0 }, | |
800eeca4 | 4945 | #if 0 |
2434f565 | 4946 | { "estate", dot_estate, 0 }, |
800eeca4 JW |
4947 | #endif |
4948 | { "mii", dot_template, 0x0 }, | |
4949 | { "mli", dot_template, 0x2 }, /* old format, for compatibility */ | |
4950 | { "mlx", dot_template, 0x2 }, | |
4951 | { "mmi", dot_template, 0x4 }, | |
4952 | { "mfi", dot_template, 0x6 }, | |
4953 | { "mmf", dot_template, 0x7 }, | |
4954 | { "mib", dot_template, 0x8 }, | |
4955 | { "mbb", dot_template, 0x9 }, | |
4956 | { "bbb", dot_template, 0xb }, | |
4957 | { "mmb", dot_template, 0xc }, | |
4958 | { "mfb", dot_template, 0xe }, | |
4959 | #if 0 | |
4960 | { "lb", dot_scope, 0 }, | |
4961 | { "le", dot_scope, 1 }, | |
4962 | #endif | |
4963 | { "align", s_align_bytes, 0 }, | |
4964 | { "regstk", dot_regstk, 0 }, | |
4965 | { "rotr", dot_rot, DYNREG_GR }, | |
4966 | { "rotf", dot_rot, DYNREG_FR }, | |
4967 | { "rotp", dot_rot, DYNREG_PR }, | |
4968 | { "lsb", dot_byteorder, 0 }, | |
4969 | { "msb", dot_byteorder, 1 }, | |
4970 | { "psr", dot_psr, 0 }, | |
4971 | { "alias", dot_alias, 0 }, | |
35f5df7f | 4972 | { "secalias", dot_alias, 1 }, |
800eeca4 JW |
4973 | { "ln", dot_ln, 0 }, /* source line info (for debugging) */ |
4974 | ||
4975 | { "xdata1", dot_xdata, 1 }, | |
4976 | { "xdata2", dot_xdata, 2 }, | |
4977 | { "xdata4", dot_xdata, 4 }, | |
4978 | { "xdata8", dot_xdata, 8 }, | |
4979 | { "xreal4", dot_xfloat_cons, 'f' }, | |
4980 | { "xreal8", dot_xfloat_cons, 'd' }, | |
4981 | { "xreal10", dot_xfloat_cons, 'x' }, | |
165a7f90 | 4982 | { "xreal16", dot_xfloat_cons, 'X' }, |
800eeca4 JW |
4983 | { "xstring", dot_xstringer, 0 }, |
4984 | { "xstringz", dot_xstringer, 1 }, | |
4985 | ||
542d6675 | 4986 | /* unaligned versions: */ |
800eeca4 JW |
4987 | { "xdata2.ua", dot_xdata_ua, 2 }, |
4988 | { "xdata4.ua", dot_xdata_ua, 4 }, | |
4989 | { "xdata8.ua", dot_xdata_ua, 8 }, | |
4990 | { "xreal4.ua", dot_xfloat_cons_ua, 'f' }, | |
4991 | { "xreal8.ua", dot_xfloat_cons_ua, 'd' }, | |
4992 | { "xreal10.ua", dot_xfloat_cons_ua, 'x' }, | |
165a7f90 | 4993 | { "xreal16.ua", dot_xfloat_cons_ua, 'X' }, |
800eeca4 JW |
4994 | |
4995 | /* annotations/DV checking support */ | |
4996 | { "entry", dot_entry, 0 }, | |
2434f565 | 4997 | { "mem.offset", dot_mem_offset, 0 }, |
800eeca4 JW |
4998 | { "pred.rel", dot_pred_rel, 0 }, |
4999 | { "pred.rel.clear", dot_pred_rel, 'c' }, | |
5000 | { "pred.rel.imply", dot_pred_rel, 'i' }, | |
5001 | { "pred.rel.mutex", dot_pred_rel, 'm' }, | |
5002 | { "pred.safe_across_calls", dot_pred_rel, 's' }, | |
2434f565 | 5003 | { "reg.val", dot_reg_val, 0 }, |
800eeca4 JW |
5004 | { "auto", dot_dv_mode, 'a' }, |
5005 | { "explicit", dot_dv_mode, 'e' }, | |
5006 | { "default", dot_dv_mode, 'd' }, | |
5007 | ||
87885043 JW |
5008 | /* ??? These are needed to make gas/testsuite/gas/elf/ehopt.s work. |
5009 | IA-64 aligns data allocation pseudo-ops by default, so we have to | |
5010 | tell it that these ones are supposed to be unaligned. Long term, | |
5011 | should rewrite so that only IA-64 specific data allocation pseudo-ops | |
5012 | are aligned by default. */ | |
5013 | {"2byte", stmt_cons_ua, 2}, | |
5014 | {"4byte", stmt_cons_ua, 4}, | |
5015 | {"8byte", stmt_cons_ua, 8}, | |
5016 | ||
800eeca4 JW |
5017 | { NULL, 0, 0 } |
5018 | }; | |
5019 | ||
5020 | static const struct pseudo_opcode | |
5021 | { | |
5022 | const char *name; | |
5023 | void (*handler) (int); | |
5024 | int arg; | |
5025 | } | |
5026 | pseudo_opcode[] = | |
5027 | { | |
5028 | /* these are more like pseudo-ops, but don't start with a dot */ | |
5029 | { "data1", cons, 1 }, | |
5030 | { "data2", cons, 2 }, | |
5031 | { "data4", cons, 4 }, | |
5032 | { "data8", cons, 8 }, | |
3969b680 | 5033 | { "data16", cons, 16 }, |
800eeca4 JW |
5034 | { "real4", stmt_float_cons, 'f' }, |
5035 | { "real8", stmt_float_cons, 'd' }, | |
5036 | { "real10", stmt_float_cons, 'x' }, | |
165a7f90 | 5037 | { "real16", stmt_float_cons, 'X' }, |
800eeca4 JW |
5038 | { "string", stringer, 0 }, |
5039 | { "stringz", stringer, 1 }, | |
5040 | ||
542d6675 | 5041 | /* unaligned versions: */ |
800eeca4 JW |
5042 | { "data2.ua", stmt_cons_ua, 2 }, |
5043 | { "data4.ua", stmt_cons_ua, 4 }, | |
5044 | { "data8.ua", stmt_cons_ua, 8 }, | |
3969b680 | 5045 | { "data16.ua", stmt_cons_ua, 16 }, |
800eeca4 JW |
5046 | { "real4.ua", float_cons, 'f' }, |
5047 | { "real8.ua", float_cons, 'd' }, | |
5048 | { "real10.ua", float_cons, 'x' }, | |
165a7f90 | 5049 | { "real16.ua", float_cons, 'X' }, |
800eeca4 JW |
5050 | }; |
5051 | ||
5052 | /* Declare a register by creating a symbol for it and entering it in | |
5053 | the symbol table. */ | |
542d6675 KH |
5054 | |
5055 | static symbolS * | |
800eeca4 JW |
5056 | declare_register (name, regnum) |
5057 | const char *name; | |
5058 | int regnum; | |
5059 | { | |
5060 | const char *err; | |
5061 | symbolS *sym; | |
5062 | ||
5063 | sym = symbol_new (name, reg_section, regnum, &zero_address_frag); | |
5064 | ||
5065 | err = hash_insert (md.reg_hash, S_GET_NAME (sym), (PTR) sym); | |
5066 | if (err) | |
5067 | as_fatal ("Inserting \"%s\" into register table failed: %s", | |
5068 | name, err); | |
5069 | ||
5070 | return sym; | |
5071 | } | |
5072 | ||
5073 | static void | |
5074 | declare_register_set (prefix, num_regs, base_regnum) | |
5075 | const char *prefix; | |
5076 | int num_regs; | |
5077 | int base_regnum; | |
5078 | { | |
5079 | char name[8]; | |
5080 | int i; | |
5081 | ||
5082 | for (i = 0; i < num_regs; ++i) | |
5083 | { | |
5084 | sprintf (name, "%s%u", prefix, i); | |
5085 | declare_register (name, base_regnum + i); | |
5086 | } | |
5087 | } | |
5088 | ||
5089 | static unsigned int | |
5090 | operand_width (opnd) | |
5091 | enum ia64_opnd opnd; | |
5092 | { | |
5093 | const struct ia64_operand *odesc = &elf64_ia64_operands[opnd]; | |
5094 | unsigned int bits = 0; | |
5095 | int i; | |
5096 | ||
5097 | bits = 0; | |
5098 | for (i = 0; i < NELEMS (odesc->field) && odesc->field[i].bits; ++i) | |
5099 | bits += odesc->field[i].bits; | |
5100 | ||
5101 | return bits; | |
5102 | } | |
5103 | ||
87f8eb97 | 5104 | static enum operand_match_result |
800eeca4 JW |
5105 | operand_match (idesc, index, e) |
5106 | const struct ia64_opcode *idesc; | |
5107 | int index; | |
5108 | expressionS *e; | |
5109 | { | |
5110 | enum ia64_opnd opnd = idesc->operands[index]; | |
5111 | int bits, relocatable = 0; | |
5112 | struct insn_fix *fix; | |
5113 | bfd_signed_vma val; | |
5114 | ||
5115 | switch (opnd) | |
5116 | { | |
542d6675 | 5117 | /* constants: */ |
800eeca4 JW |
5118 | |
5119 | case IA64_OPND_AR_CCV: | |
5120 | if (e->X_op == O_register && e->X_add_number == REG_AR + 32) | |
87f8eb97 | 5121 | return OPERAND_MATCH; |
800eeca4 JW |
5122 | break; |
5123 | ||
c10d9d8f JW |
5124 | case IA64_OPND_AR_CSD: |
5125 | if (e->X_op == O_register && e->X_add_number == REG_AR + 25) | |
5126 | return OPERAND_MATCH; | |
5127 | break; | |
5128 | ||
800eeca4 JW |
5129 | case IA64_OPND_AR_PFS: |
5130 | if (e->X_op == O_register && e->X_add_number == REG_AR + 64) | |
87f8eb97 | 5131 | return OPERAND_MATCH; |
800eeca4 JW |
5132 | break; |
5133 | ||
5134 | case IA64_OPND_GR0: | |
5135 | if (e->X_op == O_register && e->X_add_number == REG_GR + 0) | |
87f8eb97 | 5136 | return OPERAND_MATCH; |
800eeca4 JW |
5137 | break; |
5138 | ||
5139 | case IA64_OPND_IP: | |
5140 | if (e->X_op == O_register && e->X_add_number == REG_IP) | |
87f8eb97 | 5141 | return OPERAND_MATCH; |
800eeca4 JW |
5142 | break; |
5143 | ||
5144 | case IA64_OPND_PR: | |
5145 | if (e->X_op == O_register && e->X_add_number == REG_PR) | |
87f8eb97 | 5146 | return OPERAND_MATCH; |
800eeca4 JW |
5147 | break; |
5148 | ||
5149 | case IA64_OPND_PR_ROT: | |
5150 | if (e->X_op == O_register && e->X_add_number == REG_PR_ROT) | |
87f8eb97 | 5151 | return OPERAND_MATCH; |
800eeca4 JW |
5152 | break; |
5153 | ||
5154 | case IA64_OPND_PSR: | |
5155 | if (e->X_op == O_register && e->X_add_number == REG_PSR) | |
87f8eb97 | 5156 | return OPERAND_MATCH; |
800eeca4 JW |
5157 | break; |
5158 | ||
5159 | case IA64_OPND_PSR_L: | |
5160 | if (e->X_op == O_register && e->X_add_number == REG_PSR_L) | |
87f8eb97 | 5161 | return OPERAND_MATCH; |
800eeca4 JW |
5162 | break; |
5163 | ||
5164 | case IA64_OPND_PSR_UM: | |
5165 | if (e->X_op == O_register && e->X_add_number == REG_PSR_UM) | |
87f8eb97 | 5166 | return OPERAND_MATCH; |
800eeca4 JW |
5167 | break; |
5168 | ||
5169 | case IA64_OPND_C1: | |
87f8eb97 JW |
5170 | if (e->X_op == O_constant) |
5171 | { | |
5172 | if (e->X_add_number == 1) | |
5173 | return OPERAND_MATCH; | |
5174 | else | |
5175 | return OPERAND_OUT_OF_RANGE; | |
5176 | } | |
800eeca4 JW |
5177 | break; |
5178 | ||
5179 | case IA64_OPND_C8: | |
87f8eb97 JW |
5180 | if (e->X_op == O_constant) |
5181 | { | |
5182 | if (e->X_add_number == 8) | |
5183 | return OPERAND_MATCH; | |
5184 | else | |
5185 | return OPERAND_OUT_OF_RANGE; | |
5186 | } | |
800eeca4 JW |
5187 | break; |
5188 | ||
5189 | case IA64_OPND_C16: | |
87f8eb97 JW |
5190 | if (e->X_op == O_constant) |
5191 | { | |
5192 | if (e->X_add_number == 16) | |
5193 | return OPERAND_MATCH; | |
5194 | else | |
5195 | return OPERAND_OUT_OF_RANGE; | |
5196 | } | |
800eeca4 JW |
5197 | break; |
5198 | ||
542d6675 | 5199 | /* register operands: */ |
800eeca4 JW |
5200 | |
5201 | case IA64_OPND_AR3: | |
5202 | if (e->X_op == O_register && e->X_add_number >= REG_AR | |
5203 | && e->X_add_number < REG_AR + 128) | |
87f8eb97 | 5204 | return OPERAND_MATCH; |
800eeca4 JW |
5205 | break; |
5206 | ||
5207 | case IA64_OPND_B1: | |
5208 | case IA64_OPND_B2: | |
5209 | if (e->X_op == O_register && e->X_add_number >= REG_BR | |
5210 | && e->X_add_number < REG_BR + 8) | |
87f8eb97 | 5211 | return OPERAND_MATCH; |
800eeca4 JW |
5212 | break; |
5213 | ||
5214 | case IA64_OPND_CR3: | |
5215 | if (e->X_op == O_register && e->X_add_number >= REG_CR | |
5216 | && e->X_add_number < REG_CR + 128) | |
87f8eb97 | 5217 | return OPERAND_MATCH; |
800eeca4 JW |
5218 | break; |
5219 | ||
5220 | case IA64_OPND_F1: | |
5221 | case IA64_OPND_F2: | |
5222 | case IA64_OPND_F3: | |
5223 | case IA64_OPND_F4: | |
5224 | if (e->X_op == O_register && e->X_add_number >= REG_FR | |
5225 | && e->X_add_number < REG_FR + 128) | |
87f8eb97 | 5226 | return OPERAND_MATCH; |
800eeca4 JW |
5227 | break; |
5228 | ||
5229 | case IA64_OPND_P1: | |
5230 | case IA64_OPND_P2: | |
5231 | if (e->X_op == O_register && e->X_add_number >= REG_P | |
5232 | && e->X_add_number < REG_P + 64) | |
87f8eb97 | 5233 | return OPERAND_MATCH; |
800eeca4 JW |
5234 | break; |
5235 | ||
5236 | case IA64_OPND_R1: | |
5237 | case IA64_OPND_R2: | |
5238 | case IA64_OPND_R3: | |
5239 | if (e->X_op == O_register && e->X_add_number >= REG_GR | |
5240 | && e->X_add_number < REG_GR + 128) | |
87f8eb97 | 5241 | return OPERAND_MATCH; |
800eeca4 JW |
5242 | break; |
5243 | ||
5244 | case IA64_OPND_R3_2: | |
87f8eb97 | 5245 | if (e->X_op == O_register && e->X_add_number >= REG_GR) |
40449e9f | 5246 | { |
87f8eb97 JW |
5247 | if (e->X_add_number < REG_GR + 4) |
5248 | return OPERAND_MATCH; | |
5249 | else if (e->X_add_number < REG_GR + 128) | |
5250 | return OPERAND_OUT_OF_RANGE; | |
5251 | } | |
800eeca4 JW |
5252 | break; |
5253 | ||
542d6675 | 5254 | /* indirect operands: */ |
800eeca4 JW |
5255 | case IA64_OPND_CPUID_R3: |
5256 | case IA64_OPND_DBR_R3: | |
5257 | case IA64_OPND_DTR_R3: | |
5258 | case IA64_OPND_ITR_R3: | |
5259 | case IA64_OPND_IBR_R3: | |
5260 | case IA64_OPND_MSR_R3: | |
5261 | case IA64_OPND_PKR_R3: | |
5262 | case IA64_OPND_PMC_R3: | |
5263 | case IA64_OPND_PMD_R3: | |
5264 | case IA64_OPND_RR_R3: | |
5265 | if (e->X_op == O_index && e->X_op_symbol | |
5266 | && (S_GET_VALUE (e->X_op_symbol) - IND_CPUID | |
5267 | == opnd - IA64_OPND_CPUID_R3)) | |
87f8eb97 | 5268 | return OPERAND_MATCH; |
800eeca4 JW |
5269 | break; |
5270 | ||
5271 | case IA64_OPND_MR3: | |
5272 | if (e->X_op == O_index && !e->X_op_symbol) | |
87f8eb97 | 5273 | return OPERAND_MATCH; |
800eeca4 JW |
5274 | break; |
5275 | ||
542d6675 | 5276 | /* immediate operands: */ |
800eeca4 JW |
5277 | case IA64_OPND_CNT2a: |
5278 | case IA64_OPND_LEN4: | |
5279 | case IA64_OPND_LEN6: | |
5280 | bits = operand_width (idesc->operands[index]); | |
87f8eb97 JW |
5281 | if (e->X_op == O_constant) |
5282 | { | |
5283 | if ((bfd_vma) (e->X_add_number - 1) < ((bfd_vma) 1 << bits)) | |
5284 | return OPERAND_MATCH; | |
5285 | else | |
5286 | return OPERAND_OUT_OF_RANGE; | |
5287 | } | |
800eeca4 JW |
5288 | break; |
5289 | ||
5290 | case IA64_OPND_CNT2b: | |
87f8eb97 JW |
5291 | if (e->X_op == O_constant) |
5292 | { | |
5293 | if ((bfd_vma) (e->X_add_number - 1) < 3) | |
5294 | return OPERAND_MATCH; | |
5295 | else | |
5296 | return OPERAND_OUT_OF_RANGE; | |
5297 | } | |
800eeca4 JW |
5298 | break; |
5299 | ||
5300 | case IA64_OPND_CNT2c: | |
5301 | val = e->X_add_number; | |
87f8eb97 JW |
5302 | if (e->X_op == O_constant) |
5303 | { | |
5304 | if ((val == 0 || val == 7 || val == 15 || val == 16)) | |
5305 | return OPERAND_MATCH; | |
5306 | else | |
5307 | return OPERAND_OUT_OF_RANGE; | |
5308 | } | |
800eeca4 JW |
5309 | break; |
5310 | ||
5311 | case IA64_OPND_SOR: | |
5312 | /* SOR must be an integer multiple of 8 */ | |
87f8eb97 JW |
5313 | if (e->X_op == O_constant && e->X_add_number & 0x7) |
5314 | return OPERAND_OUT_OF_RANGE; | |
800eeca4 JW |
5315 | case IA64_OPND_SOF: |
5316 | case IA64_OPND_SOL: | |
87f8eb97 JW |
5317 | if (e->X_op == O_constant) |
5318 | { | |
5319 | if ((bfd_vma) e->X_add_number <= 96) | |
5320 | return OPERAND_MATCH; | |
5321 | else | |
5322 | return OPERAND_OUT_OF_RANGE; | |
5323 | } | |
800eeca4 JW |
5324 | break; |
5325 | ||
5326 | case IA64_OPND_IMMU62: | |
5327 | if (e->X_op == O_constant) | |
542d6675 | 5328 | { |
800eeca4 | 5329 | if ((bfd_vma) e->X_add_number < ((bfd_vma) 1 << 62)) |
87f8eb97 JW |
5330 | return OPERAND_MATCH; |
5331 | else | |
5332 | return OPERAND_OUT_OF_RANGE; | |
542d6675 | 5333 | } |
197865e8 | 5334 | else |
542d6675 KH |
5335 | { |
5336 | /* FIXME -- need 62-bit relocation type */ | |
5337 | as_bad (_("62-bit relocation not yet implemented")); | |
5338 | } | |
800eeca4 JW |
5339 | break; |
5340 | ||
5341 | case IA64_OPND_IMMU64: | |
5342 | if (e->X_op == O_symbol || e->X_op == O_pseudo_fixup | |
5343 | || e->X_op == O_subtract) | |
5344 | { | |
5345 | fix = CURR_SLOT.fixup + CURR_SLOT.num_fixups; | |
5346 | fix->code = BFD_RELOC_IA64_IMM64; | |
5347 | if (e->X_op != O_subtract) | |
5348 | { | |
5349 | fix->code = ia64_gen_real_reloc_type (e->X_op_symbol, fix->code); | |
5350 | if (e->X_op == O_pseudo_fixup) | |
5351 | e->X_op = O_symbol; | |
5352 | } | |
5353 | ||
5354 | fix->opnd = idesc->operands[index]; | |
5355 | fix->expr = *e; | |
5356 | fix->is_pcrel = 0; | |
5357 | ++CURR_SLOT.num_fixups; | |
87f8eb97 | 5358 | return OPERAND_MATCH; |
800eeca4 JW |
5359 | } |
5360 | else if (e->X_op == O_constant) | |
87f8eb97 | 5361 | return OPERAND_MATCH; |
800eeca4 JW |
5362 | break; |
5363 | ||
5364 | case IA64_OPND_CCNT5: | |
5365 | case IA64_OPND_CNT5: | |
5366 | case IA64_OPND_CNT6: | |
5367 | case IA64_OPND_CPOS6a: | |
5368 | case IA64_OPND_CPOS6b: | |
5369 | case IA64_OPND_CPOS6c: | |
5370 | case IA64_OPND_IMMU2: | |
5371 | case IA64_OPND_IMMU7a: | |
5372 | case IA64_OPND_IMMU7b: | |
800eeca4 JW |
5373 | case IA64_OPND_IMMU21: |
5374 | case IA64_OPND_IMMU24: | |
5375 | case IA64_OPND_MBTYPE4: | |
5376 | case IA64_OPND_MHTYPE8: | |
5377 | case IA64_OPND_POS6: | |
5378 | bits = operand_width (idesc->operands[index]); | |
87f8eb97 JW |
5379 | if (e->X_op == O_constant) |
5380 | { | |
5381 | if ((bfd_vma) e->X_add_number < ((bfd_vma) 1 << bits)) | |
5382 | return OPERAND_MATCH; | |
5383 | else | |
5384 | return OPERAND_OUT_OF_RANGE; | |
5385 | } | |
800eeca4 JW |
5386 | break; |
5387 | ||
bf3ca999 TW |
5388 | case IA64_OPND_IMMU9: |
5389 | bits = operand_width (idesc->operands[index]); | |
87f8eb97 | 5390 | if (e->X_op == O_constant) |
542d6675 | 5391 | { |
87f8eb97 JW |
5392 | if ((bfd_vma) e->X_add_number < ((bfd_vma) 1 << bits)) |
5393 | { | |
5394 | int lobits = e->X_add_number & 0x3; | |
5395 | if (((bfd_vma) e->X_add_number & 0x3C) != 0 && lobits == 0) | |
5396 | e->X_add_number |= (bfd_vma) 0x3; | |
5397 | return OPERAND_MATCH; | |
5398 | } | |
5399 | else | |
5400 | return OPERAND_OUT_OF_RANGE; | |
542d6675 | 5401 | } |
bf3ca999 TW |
5402 | break; |
5403 | ||
800eeca4 JW |
5404 | case IA64_OPND_IMM44: |
5405 | /* least 16 bits must be zero */ | |
5406 | if ((e->X_add_number & 0xffff) != 0) | |
87f8eb97 JW |
5407 | /* XXX technically, this is wrong: we should not be issuing warning |
5408 | messages until we're sure this instruction pattern is going to | |
5409 | be used! */ | |
542d6675 | 5410 | as_warn (_("lower 16 bits of mask ignored")); |
800eeca4 | 5411 | |
87f8eb97 | 5412 | if (e->X_op == O_constant) |
542d6675 | 5413 | { |
87f8eb97 JW |
5414 | if (((e->X_add_number >= 0 |
5415 | && (bfd_vma) e->X_add_number < ((bfd_vma) 1 << 44)) | |
5416 | || (e->X_add_number < 0 | |
5417 | && (bfd_vma) -e->X_add_number <= ((bfd_vma) 1 << 44)))) | |
542d6675 | 5418 | { |
87f8eb97 JW |
5419 | /* sign-extend */ |
5420 | if (e->X_add_number >= 0 | |
5421 | && (e->X_add_number & ((bfd_vma) 1 << 43)) != 0) | |
5422 | { | |
5423 | e->X_add_number |= ~(((bfd_vma) 1 << 44) - 1); | |
5424 | } | |
5425 | return OPERAND_MATCH; | |
542d6675 | 5426 | } |
87f8eb97 JW |
5427 | else |
5428 | return OPERAND_OUT_OF_RANGE; | |
542d6675 | 5429 | } |
800eeca4 JW |
5430 | break; |
5431 | ||
5432 | case IA64_OPND_IMM17: | |
5433 | /* bit 0 is a don't care (pr0 is hardwired to 1) */ | |
87f8eb97 | 5434 | if (e->X_op == O_constant) |
542d6675 | 5435 | { |
87f8eb97 JW |
5436 | if (((e->X_add_number >= 0 |
5437 | && (bfd_vma) e->X_add_number < ((bfd_vma) 1 << 17)) | |
5438 | || (e->X_add_number < 0 | |
5439 | && (bfd_vma) -e->X_add_number <= ((bfd_vma) 1 << 17)))) | |
542d6675 | 5440 | { |
87f8eb97 JW |
5441 | /* sign-extend */ |
5442 | if (e->X_add_number >= 0 | |
5443 | && (e->X_add_number & ((bfd_vma) 1 << 16)) != 0) | |
5444 | { | |
5445 | e->X_add_number |= ~(((bfd_vma) 1 << 17) - 1); | |
5446 | } | |
5447 | return OPERAND_MATCH; | |
542d6675 | 5448 | } |
87f8eb97 JW |
5449 | else |
5450 | return OPERAND_OUT_OF_RANGE; | |
542d6675 | 5451 | } |
800eeca4 JW |
5452 | break; |
5453 | ||
5454 | case IA64_OPND_IMM14: | |
5455 | case IA64_OPND_IMM22: | |
5456 | relocatable = 1; | |
5457 | case IA64_OPND_IMM1: | |
5458 | case IA64_OPND_IMM8: | |
5459 | case IA64_OPND_IMM8U4: | |
5460 | case IA64_OPND_IMM8M1: | |
5461 | case IA64_OPND_IMM8M1U4: | |
5462 | case IA64_OPND_IMM8M1U8: | |
5463 | case IA64_OPND_IMM9a: | |
5464 | case IA64_OPND_IMM9b: | |
5465 | bits = operand_width (idesc->operands[index]); | |
5466 | if (relocatable && (e->X_op == O_symbol | |
5467 | || e->X_op == O_subtract | |
5468 | || e->X_op == O_pseudo_fixup)) | |
5469 | { | |
5470 | fix = CURR_SLOT.fixup + CURR_SLOT.num_fixups; | |
5471 | ||
5472 | if (idesc->operands[index] == IA64_OPND_IMM14) | |
5473 | fix->code = BFD_RELOC_IA64_IMM14; | |
5474 | else | |
5475 | fix->code = BFD_RELOC_IA64_IMM22; | |
5476 | ||
5477 | if (e->X_op != O_subtract) | |
5478 | { | |
5479 | fix->code = ia64_gen_real_reloc_type (e->X_op_symbol, fix->code); | |
5480 | if (e->X_op == O_pseudo_fixup) | |
5481 | e->X_op = O_symbol; | |
5482 | } | |
5483 | ||
5484 | fix->opnd = idesc->operands[index]; | |
5485 | fix->expr = *e; | |
5486 | fix->is_pcrel = 0; | |
5487 | ++CURR_SLOT.num_fixups; | |
87f8eb97 | 5488 | return OPERAND_MATCH; |
800eeca4 JW |
5489 | } |
5490 | else if (e->X_op != O_constant | |
5491 | && ! (e->X_op == O_big && opnd == IA64_OPND_IMM8M1U8)) | |
87f8eb97 | 5492 | return OPERAND_MISMATCH; |
800eeca4 JW |
5493 | |
5494 | if (opnd == IA64_OPND_IMM8M1U4) | |
5495 | { | |
5496 | /* Zero is not valid for unsigned compares that take an adjusted | |
5497 | constant immediate range. */ | |
5498 | if (e->X_add_number == 0) | |
87f8eb97 | 5499 | return OPERAND_OUT_OF_RANGE; |
800eeca4 JW |
5500 | |
5501 | /* Sign-extend 32-bit unsigned numbers, so that the following range | |
5502 | checks will work. */ | |
5503 | val = e->X_add_number; | |
197865e8 KH |
5504 | if (((val & (~(bfd_vma) 0 << 32)) == 0) |
5505 | && ((val & ((bfd_vma) 1 << 31)) != 0)) | |
800eeca4 JW |
5506 | val = ((val << 32) >> 32); |
5507 | ||
5508 | /* Check for 0x100000000. This is valid because | |
5509 | 0x100000000-1 is the same as ((uint32_t) -1). */ | |
5510 | if (val == ((bfd_signed_vma) 1 << 32)) | |
87f8eb97 | 5511 | return OPERAND_MATCH; |
800eeca4 JW |
5512 | |
5513 | val = val - 1; | |
5514 | } | |
5515 | else if (opnd == IA64_OPND_IMM8M1U8) | |
5516 | { | |
5517 | /* Zero is not valid for unsigned compares that take an adjusted | |
5518 | constant immediate range. */ | |
5519 | if (e->X_add_number == 0) | |
87f8eb97 | 5520 | return OPERAND_OUT_OF_RANGE; |
800eeca4 JW |
5521 | |
5522 | /* Check for 0x10000000000000000. */ | |
5523 | if (e->X_op == O_big) | |
5524 | { | |
5525 | if (generic_bignum[0] == 0 | |
5526 | && generic_bignum[1] == 0 | |
5527 | && generic_bignum[2] == 0 | |
5528 | && generic_bignum[3] == 0 | |
5529 | && generic_bignum[4] == 1) | |
87f8eb97 | 5530 | return OPERAND_MATCH; |
800eeca4 | 5531 | else |
87f8eb97 | 5532 | return OPERAND_OUT_OF_RANGE; |
800eeca4 JW |
5533 | } |
5534 | else | |
5535 | val = e->X_add_number - 1; | |
5536 | } | |
5537 | else if (opnd == IA64_OPND_IMM8M1) | |
5538 | val = e->X_add_number - 1; | |
5539 | else if (opnd == IA64_OPND_IMM8U4) | |
5540 | { | |
5541 | /* Sign-extend 32-bit unsigned numbers, so that the following range | |
5542 | checks will work. */ | |
5543 | val = e->X_add_number; | |
197865e8 KH |
5544 | if (((val & (~(bfd_vma) 0 << 32)) == 0) |
5545 | && ((val & ((bfd_vma) 1 << 31)) != 0)) | |
800eeca4 JW |
5546 | val = ((val << 32) >> 32); |
5547 | } | |
5548 | else | |
5549 | val = e->X_add_number; | |
5550 | ||
2434f565 JW |
5551 | if ((val >= 0 && (bfd_vma) val < ((bfd_vma) 1 << (bits - 1))) |
5552 | || (val < 0 && (bfd_vma) -val <= ((bfd_vma) 1 << (bits - 1)))) | |
87f8eb97 JW |
5553 | return OPERAND_MATCH; |
5554 | else | |
5555 | return OPERAND_OUT_OF_RANGE; | |
800eeca4 JW |
5556 | |
5557 | case IA64_OPND_INC3: | |
5558 | /* +/- 1, 4, 8, 16 */ | |
5559 | val = e->X_add_number; | |
5560 | if (val < 0) | |
5561 | val = -val; | |
87f8eb97 JW |
5562 | if (e->X_op == O_constant) |
5563 | { | |
5564 | if ((val == 1 || val == 4 || val == 8 || val == 16)) | |
5565 | return OPERAND_MATCH; | |
5566 | else | |
5567 | return OPERAND_OUT_OF_RANGE; | |
5568 | } | |
800eeca4 JW |
5569 | break; |
5570 | ||
5571 | case IA64_OPND_TGT25: | |
5572 | case IA64_OPND_TGT25b: | |
5573 | case IA64_OPND_TGT25c: | |
5574 | case IA64_OPND_TGT64: | |
5575 | if (e->X_op == O_symbol) | |
5576 | { | |
5577 | fix = CURR_SLOT.fixup + CURR_SLOT.num_fixups; | |
5578 | if (opnd == IA64_OPND_TGT25) | |
5579 | fix->code = BFD_RELOC_IA64_PCREL21F; | |
5580 | else if (opnd == IA64_OPND_TGT25b) | |
5581 | fix->code = BFD_RELOC_IA64_PCREL21M; | |
5582 | else if (opnd == IA64_OPND_TGT25c) | |
5583 | fix->code = BFD_RELOC_IA64_PCREL21B; | |
542d6675 | 5584 | else if (opnd == IA64_OPND_TGT64) |
c67e42c9 RH |
5585 | fix->code = BFD_RELOC_IA64_PCREL60B; |
5586 | else | |
5587 | abort (); | |
5588 | ||
800eeca4 JW |
5589 | fix->code = ia64_gen_real_reloc_type (e->X_op_symbol, fix->code); |
5590 | fix->opnd = idesc->operands[index]; | |
5591 | fix->expr = *e; | |
5592 | fix->is_pcrel = 1; | |
5593 | ++CURR_SLOT.num_fixups; | |
87f8eb97 | 5594 | return OPERAND_MATCH; |
800eeca4 JW |
5595 | } |
5596 | case IA64_OPND_TAG13: | |
5597 | case IA64_OPND_TAG13b: | |
5598 | switch (e->X_op) | |
5599 | { | |
5600 | case O_constant: | |
87f8eb97 | 5601 | return OPERAND_MATCH; |
800eeca4 JW |
5602 | |
5603 | case O_symbol: | |
5604 | fix = CURR_SLOT.fixup + CURR_SLOT.num_fixups; | |
fa1cb89c JW |
5605 | /* There are no external relocs for TAG13/TAG13b fields, so we |
5606 | create a dummy reloc. This will not live past md_apply_fix3. */ | |
5607 | fix->code = BFD_RELOC_UNUSED; | |
5608 | fix->code = ia64_gen_real_reloc_type (e->X_op_symbol, fix->code); | |
800eeca4 JW |
5609 | fix->opnd = idesc->operands[index]; |
5610 | fix->expr = *e; | |
5611 | fix->is_pcrel = 1; | |
5612 | ++CURR_SLOT.num_fixups; | |
87f8eb97 | 5613 | return OPERAND_MATCH; |
800eeca4 JW |
5614 | |
5615 | default: | |
5616 | break; | |
5617 | } | |
5618 | break; | |
5619 | ||
a823923b RH |
5620 | case IA64_OPND_LDXMOV: |
5621 | fix = CURR_SLOT.fixup + CURR_SLOT.num_fixups; | |
5622 | fix->code = BFD_RELOC_IA64_LDXMOV; | |
5623 | fix->opnd = idesc->operands[index]; | |
5624 | fix->expr = *e; | |
5625 | fix->is_pcrel = 0; | |
5626 | ++CURR_SLOT.num_fixups; | |
5627 | return OPERAND_MATCH; | |
5628 | ||
800eeca4 JW |
5629 | default: |
5630 | break; | |
5631 | } | |
87f8eb97 | 5632 | return OPERAND_MISMATCH; |
800eeca4 JW |
5633 | } |
5634 | ||
5635 | static int | |
5636 | parse_operand (e) | |
5637 | expressionS *e; | |
5638 | { | |
5639 | int sep = '\0'; | |
5640 | ||
5641 | memset (e, 0, sizeof (*e)); | |
5642 | e->X_op = O_absent; | |
5643 | SKIP_WHITESPACE (); | |
5644 | if (*input_line_pointer != '}') | |
5645 | expression (e); | |
5646 | sep = *input_line_pointer++; | |
5647 | ||
5648 | if (sep == '}') | |
5649 | { | |
5650 | if (!md.manual_bundling) | |
5651 | as_warn ("Found '}' when manual bundling is off"); | |
5652 | else | |
5653 | CURR_SLOT.manual_bundling_off = 1; | |
5654 | md.manual_bundling = 0; | |
5655 | sep = '\0'; | |
5656 | } | |
5657 | return sep; | |
5658 | } | |
5659 | ||
5660 | /* Returns the next entry in the opcode table that matches the one in | |
5661 | IDESC, and frees the entry in IDESC. If no matching entry is | |
197865e8 | 5662 | found, NULL is returned instead. */ |
800eeca4 JW |
5663 | |
5664 | static struct ia64_opcode * | |
5665 | get_next_opcode (struct ia64_opcode *idesc) | |
5666 | { | |
5667 | struct ia64_opcode *next = ia64_find_next_opcode (idesc); | |
5668 | ia64_free_opcode (idesc); | |
5669 | return next; | |
5670 | } | |
5671 | ||
5672 | /* Parse the operands for the opcode and find the opcode variant that | |
5673 | matches the specified operands, or NULL if no match is possible. */ | |
542d6675 KH |
5674 | |
5675 | static struct ia64_opcode * | |
800eeca4 JW |
5676 | parse_operands (idesc) |
5677 | struct ia64_opcode *idesc; | |
5678 | { | |
5679 | int i = 0, highest_unmatched_operand, num_operands = 0, num_outputs = 0; | |
87f8eb97 | 5680 | int error_pos, out_of_range_pos, curr_out_of_range_pos, sep = 0; |
800eeca4 | 5681 | enum ia64_opnd expected_operand = IA64_OPND_NIL; |
87f8eb97 | 5682 | enum operand_match_result result; |
800eeca4 JW |
5683 | char mnemonic[129]; |
5684 | char *first_arg = 0, *end, *saved_input_pointer; | |
5685 | unsigned int sof; | |
5686 | ||
5687 | assert (strlen (idesc->name) <= 128); | |
5688 | ||
5689 | strcpy (mnemonic, idesc->name); | |
5690 | if (idesc->operands[2] == IA64_OPND_SOF) | |
5691 | { | |
5692 | /* To make the common idiom "alloc loc?=ar.pfs,0,1,0,0" work, we | |
5693 | can't parse the first operand until we have parsed the | |
5694 | remaining operands of the "alloc" instruction. */ | |
5695 | SKIP_WHITESPACE (); | |
5696 | first_arg = input_line_pointer; | |
5697 | end = strchr (input_line_pointer, '='); | |
5698 | if (!end) | |
5699 | { | |
5700 | as_bad ("Expected separator `='"); | |
5701 | return 0; | |
5702 | } | |
5703 | input_line_pointer = end + 1; | |
5704 | ++i; | |
5705 | ++num_outputs; | |
5706 | } | |
5707 | ||
5708 | for (; i < NELEMS (CURR_SLOT.opnd); ++i) | |
5709 | { | |
5710 | sep = parse_operand (CURR_SLOT.opnd + i); | |
5711 | if (CURR_SLOT.opnd[i].X_op == O_absent) | |
5712 | break; | |
5713 | ||
5714 | ++num_operands; | |
5715 | ||
5716 | if (sep != '=' && sep != ',') | |
5717 | break; | |
5718 | ||
5719 | if (sep == '=') | |
5720 | { | |
5721 | if (num_outputs > 0) | |
5722 | as_bad ("Duplicate equal sign (=) in instruction"); | |
5723 | else | |
5724 | num_outputs = i + 1; | |
5725 | } | |
5726 | } | |
5727 | if (sep != '\0') | |
5728 | { | |
5729 | as_bad ("Illegal operand separator `%c'", sep); | |
5730 | return 0; | |
5731 | } | |
197865e8 | 5732 | |
800eeca4 JW |
5733 | if (idesc->operands[2] == IA64_OPND_SOF) |
5734 | { | |
5735 | /* map alloc r1=ar.pfs,i,l,o,r to alloc r1=ar.pfs,(i+l+o),(i+l),r */ | |
5736 | know (strcmp (idesc->name, "alloc") == 0); | |
5737 | if (num_operands == 5 /* first_arg not included in this count! */ | |
5738 | && CURR_SLOT.opnd[2].X_op == O_constant | |
5739 | && CURR_SLOT.opnd[3].X_op == O_constant | |
5740 | && CURR_SLOT.opnd[4].X_op == O_constant | |
5741 | && CURR_SLOT.opnd[5].X_op == O_constant) | |
5742 | { | |
5743 | sof = set_regstack (CURR_SLOT.opnd[2].X_add_number, | |
5744 | CURR_SLOT.opnd[3].X_add_number, | |
5745 | CURR_SLOT.opnd[4].X_add_number, | |
5746 | CURR_SLOT.opnd[5].X_add_number); | |
5747 | ||
542d6675 | 5748 | /* now we can parse the first arg: */ |
800eeca4 JW |
5749 | saved_input_pointer = input_line_pointer; |
5750 | input_line_pointer = first_arg; | |
5751 | sep = parse_operand (CURR_SLOT.opnd + 0); | |
5752 | if (sep != '=') | |
5753 | --num_outputs; /* force error */ | |
5754 | input_line_pointer = saved_input_pointer; | |
5755 | ||
5756 | CURR_SLOT.opnd[2].X_add_number = sof; | |
5757 | CURR_SLOT.opnd[3].X_add_number | |
5758 | = sof - CURR_SLOT.opnd[4].X_add_number; | |
5759 | CURR_SLOT.opnd[4] = CURR_SLOT.opnd[5]; | |
5760 | } | |
5761 | } | |
5762 | ||
5763 | highest_unmatched_operand = 0; | |
87f8eb97 JW |
5764 | curr_out_of_range_pos = -1; |
5765 | error_pos = 0; | |
800eeca4 JW |
5766 | expected_operand = idesc->operands[0]; |
5767 | for (; idesc; idesc = get_next_opcode (idesc)) | |
5768 | { | |
5769 | if (num_outputs != idesc->num_outputs) | |
5770 | continue; /* mismatch in # of outputs */ | |
5771 | ||
5772 | CURR_SLOT.num_fixups = 0; | |
87f8eb97 JW |
5773 | |
5774 | /* Try to match all operands. If we see an out-of-range operand, | |
5775 | then continue trying to match the rest of the operands, since if | |
5776 | the rest match, then this idesc will give the best error message. */ | |
5777 | ||
5778 | out_of_range_pos = -1; | |
800eeca4 | 5779 | for (i = 0; i < num_operands && idesc->operands[i]; ++i) |
87f8eb97 JW |
5780 | { |
5781 | result = operand_match (idesc, i, CURR_SLOT.opnd + i); | |
5782 | if (result != OPERAND_MATCH) | |
5783 | { | |
5784 | if (result != OPERAND_OUT_OF_RANGE) | |
5785 | break; | |
5786 | if (out_of_range_pos < 0) | |
5787 | /* remember position of the first out-of-range operand: */ | |
5788 | out_of_range_pos = i; | |
5789 | } | |
5790 | } | |
800eeca4 | 5791 | |
87f8eb97 JW |
5792 | /* If we did not match all operands, or if at least one operand was |
5793 | out-of-range, then this idesc does not match. Keep track of which | |
5794 | idesc matched the most operands before failing. If we have two | |
5795 | idescs that failed at the same position, and one had an out-of-range | |
5796 | operand, then prefer the out-of-range operand. Thus if we have | |
5797 | "add r0=0x1000000,r1" we get an error saying the constant is out | |
5798 | of range instead of an error saying that the constant should have been | |
5799 | a register. */ | |
5800 | ||
5801 | if (i != num_operands || out_of_range_pos >= 0) | |
800eeca4 | 5802 | { |
87f8eb97 JW |
5803 | if (i > highest_unmatched_operand |
5804 | || (i == highest_unmatched_operand | |
5805 | && out_of_range_pos > curr_out_of_range_pos)) | |
800eeca4 JW |
5806 | { |
5807 | highest_unmatched_operand = i; | |
87f8eb97 JW |
5808 | if (out_of_range_pos >= 0) |
5809 | { | |
5810 | expected_operand = idesc->operands[out_of_range_pos]; | |
5811 | error_pos = out_of_range_pos; | |
5812 | } | |
5813 | else | |
5814 | { | |
5815 | expected_operand = idesc->operands[i]; | |
5816 | error_pos = i; | |
5817 | } | |
5818 | curr_out_of_range_pos = out_of_range_pos; | |
800eeca4 JW |
5819 | } |
5820 | continue; | |
5821 | } | |
5822 | ||
5823 | if (num_operands < NELEMS (idesc->operands) | |
5824 | && idesc->operands[num_operands]) | |
5825 | continue; /* mismatch in number of arguments */ | |
5826 | ||
5827 | break; | |
5828 | } | |
5829 | if (!idesc) | |
5830 | { | |
5831 | if (expected_operand) | |
5832 | as_bad ("Operand %u of `%s' should be %s", | |
87f8eb97 | 5833 | error_pos + 1, mnemonic, |
800eeca4 JW |
5834 | elf64_ia64_operands[expected_operand].desc); |
5835 | else | |
5836 | as_bad ("Operand mismatch"); | |
5837 | return 0; | |
5838 | } | |
5839 | return idesc; | |
5840 | } | |
5841 | ||
88be23ec BS |
5842 | /* Keep track of state necessary to determine whether a NOP is necessary |
5843 | to avoid an erratum in A and B step Itanium chips, and return 1 if we | |
5844 | detect a case where additional NOPs may be necessary. */ | |
5845 | static int | |
5846 | errata_nop_necessary_p (slot, insn_unit) | |
5847 | struct slot *slot; | |
5848 | enum ia64_unit insn_unit; | |
5849 | { | |
5850 | int i; | |
5851 | struct group *this_group = md.last_groups + md.group_idx; | |
5852 | struct group *prev_group = md.last_groups + (md.group_idx + 2) % 3; | |
5853 | struct ia64_opcode *idesc = slot->idesc; | |
5854 | ||
5855 | /* Test whether this could be the first insn in a problematic sequence. */ | |
5856 | if (insn_unit == IA64_UNIT_F) | |
5857 | { | |
5858 | for (i = 0; i < idesc->num_outputs; i++) | |
5859 | if (idesc->operands[i] == IA64_OPND_P1 | |
5860 | || idesc->operands[i] == IA64_OPND_P2) | |
5861 | { | |
5862 | int regno = slot->opnd[i].X_add_number - REG_P; | |
3557da92 | 5863 | /* Ignore invalid operands; they generate errors elsewhere. */ |
ca683b78 | 5864 | if (regno >= 64) |
3557da92 | 5865 | return 0; |
88be23ec BS |
5866 | this_group->p_reg_set[regno] = 1; |
5867 | } | |
5868 | } | |
5869 | ||
5870 | /* Test whether this could be the second insn in a problematic sequence. */ | |
5871 | if (insn_unit == IA64_UNIT_M && slot->qp_regno > 0 | |
5872 | && prev_group->p_reg_set[slot->qp_regno]) | |
5873 | { | |
5874 | for (i = 0; i < idesc->num_outputs; i++) | |
5875 | if (idesc->operands[i] == IA64_OPND_R1 | |
5876 | || idesc->operands[i] == IA64_OPND_R2 | |
5877 | || idesc->operands[i] == IA64_OPND_R3) | |
5878 | { | |
5879 | int regno = slot->opnd[i].X_add_number - REG_GR; | |
3557da92 | 5880 | /* Ignore invalid operands; they generate errors elsewhere. */ |
ca683b78 | 5881 | if (regno >= 128) |
3557da92 | 5882 | return 0; |
88be23ec BS |
5883 | if (strncmp (idesc->name, "add", 3) != 0 |
5884 | && strncmp (idesc->name, "sub", 3) != 0 | |
5885 | && strncmp (idesc->name, "shladd", 6) != 0 | |
5886 | && (idesc->flags & IA64_OPCODE_POSTINC) == 0) | |
5887 | this_group->g_reg_set_conditionally[regno] = 1; | |
5888 | } | |
5889 | } | |
5890 | ||
5891 | /* Test whether this could be the third insn in a problematic sequence. */ | |
5892 | for (i = 0; i < NELEMS (idesc->operands) && idesc->operands[i]; i++) | |
5893 | { | |
5894 | if (/* For fc, ptc, ptr, tak, thash, tpa, ttag, probe, ptr, ptc. */ | |
5895 | idesc->operands[i] == IA64_OPND_R3 | |
5896 | /* For mov indirect. */ | |
5897 | || idesc->operands[i] == IA64_OPND_RR_R3 | |
5898 | || idesc->operands[i] == IA64_OPND_DBR_R3 | |
5899 | || idesc->operands[i] == IA64_OPND_IBR_R3 | |
5900 | || idesc->operands[i] == IA64_OPND_PKR_R3 | |
5901 | || idesc->operands[i] == IA64_OPND_PMC_R3 | |
5902 | || idesc->operands[i] == IA64_OPND_PMD_R3 | |
5903 | || idesc->operands[i] == IA64_OPND_MSR_R3 | |
5904 | || idesc->operands[i] == IA64_OPND_CPUID_R3 | |
5905 | /* For itr. */ | |
5906 | || idesc->operands[i] == IA64_OPND_ITR_R3 | |
5907 | || idesc->operands[i] == IA64_OPND_DTR_R3 | |
5908 | /* Normal memory addresses (load, store, xchg, cmpxchg, etc.). */ | |
5909 | || idesc->operands[i] == IA64_OPND_MR3) | |
5910 | { | |
5911 | int regno = slot->opnd[i].X_add_number - REG_GR; | |
3557da92 | 5912 | /* Ignore invalid operands; they generate errors elsewhere. */ |
ca683b78 | 5913 | if (regno >= 128) |
3557da92 | 5914 | return 0; |
88be23ec BS |
5915 | if (idesc->operands[i] == IA64_OPND_R3) |
5916 | { | |
5917 | if (strcmp (idesc->name, "fc") != 0 | |
5918 | && strcmp (idesc->name, "tak") != 0 | |
5919 | && strcmp (idesc->name, "thash") != 0 | |
5920 | && strcmp (idesc->name, "tpa") != 0 | |
5921 | && strcmp (idesc->name, "ttag") != 0 | |
5922 | && strncmp (idesc->name, "ptr", 3) != 0 | |
5923 | && strncmp (idesc->name, "ptc", 3) != 0 | |
5924 | && strncmp (idesc->name, "probe", 5) != 0) | |
40449e9f | 5925 | return 0; |
88be23ec | 5926 | } |
bc805888 | 5927 | if (prev_group->g_reg_set_conditionally[regno]) |
88be23ec BS |
5928 | return 1; |
5929 | } | |
5930 | } | |
5931 | return 0; | |
5932 | } | |
5933 | ||
800eeca4 JW |
5934 | static void |
5935 | build_insn (slot, insnp) | |
5936 | struct slot *slot; | |
5937 | bfd_vma *insnp; | |
5938 | { | |
5939 | const struct ia64_operand *odesc, *o2desc; | |
5940 | struct ia64_opcode *idesc = slot->idesc; | |
5941 | bfd_signed_vma insn, val; | |
5942 | const char *err; | |
5943 | int i; | |
5944 | ||
5945 | insn = idesc->opcode | slot->qp_regno; | |
5946 | ||
5947 | for (i = 0; i < NELEMS (idesc->operands) && idesc->operands[i]; ++i) | |
5948 | { | |
c67e42c9 RH |
5949 | if (slot->opnd[i].X_op == O_register |
5950 | || slot->opnd[i].X_op == O_constant | |
5951 | || slot->opnd[i].X_op == O_index) | |
5952 | val = slot->opnd[i].X_add_number; | |
5953 | else if (slot->opnd[i].X_op == O_big) | |
800eeca4 | 5954 | { |
c67e42c9 RH |
5955 | /* This must be the value 0x10000000000000000. */ |
5956 | assert (idesc->operands[i] == IA64_OPND_IMM8M1U8); | |
5957 | val = 0; | |
5958 | } | |
5959 | else | |
5960 | val = 0; | |
5961 | ||
5962 | switch (idesc->operands[i]) | |
5963 | { | |
5964 | case IA64_OPND_IMMU64: | |
800eeca4 JW |
5965 | *insnp++ = (val >> 22) & 0x1ffffffffffLL; |
5966 | insn |= (((val & 0x7f) << 13) | (((val >> 7) & 0x1ff) << 27) | |
5967 | | (((val >> 16) & 0x1f) << 22) | (((val >> 21) & 0x1) << 21) | |
5968 | | (((val >> 63) & 0x1) << 36)); | |
c67e42c9 RH |
5969 | continue; |
5970 | ||
5971 | case IA64_OPND_IMMU62: | |
542d6675 KH |
5972 | val &= 0x3fffffffffffffffULL; |
5973 | if (val != slot->opnd[i].X_add_number) | |
5974 | as_warn (_("Value truncated to 62 bits")); | |
5975 | *insnp++ = (val >> 21) & 0x1ffffffffffLL; | |
5976 | insn |= (((val & 0xfffff) << 6) | (((val >> 20) & 0x1) << 36)); | |
c67e42c9 | 5977 | continue; |
800eeca4 | 5978 | |
c67e42c9 RH |
5979 | case IA64_OPND_TGT64: |
5980 | val >>= 4; | |
5981 | *insnp++ = ((val >> 20) & 0x7fffffffffLL) << 2; | |
5982 | insn |= ((((val >> 59) & 0x1) << 36) | |
5983 | | (((val >> 0) & 0xfffff) << 13)); | |
5984 | continue; | |
800eeca4 | 5985 | |
c67e42c9 RH |
5986 | case IA64_OPND_AR3: |
5987 | val -= REG_AR; | |
5988 | break; | |
5989 | ||
5990 | case IA64_OPND_B1: | |
5991 | case IA64_OPND_B2: | |
5992 | val -= REG_BR; | |
5993 | break; | |
5994 | ||
5995 | case IA64_OPND_CR3: | |
5996 | val -= REG_CR; | |
5997 | break; | |
5998 | ||
5999 | case IA64_OPND_F1: | |
6000 | case IA64_OPND_F2: | |
6001 | case IA64_OPND_F3: | |
6002 | case IA64_OPND_F4: | |
6003 | val -= REG_FR; | |
6004 | break; | |
6005 | ||
6006 | case IA64_OPND_P1: | |
6007 | case IA64_OPND_P2: | |
6008 | val -= REG_P; | |
6009 | break; | |
6010 | ||
6011 | case IA64_OPND_R1: | |
6012 | case IA64_OPND_R2: | |
6013 | case IA64_OPND_R3: | |
6014 | case IA64_OPND_R3_2: | |
6015 | case IA64_OPND_CPUID_R3: | |
6016 | case IA64_OPND_DBR_R3: | |
6017 | case IA64_OPND_DTR_R3: | |
6018 | case IA64_OPND_ITR_R3: | |
6019 | case IA64_OPND_IBR_R3: | |
6020 | case IA64_OPND_MR3: | |
6021 | case IA64_OPND_MSR_R3: | |
6022 | case IA64_OPND_PKR_R3: | |
6023 | case IA64_OPND_PMC_R3: | |
6024 | case IA64_OPND_PMD_R3: | |
197865e8 | 6025 | case IA64_OPND_RR_R3: |
c67e42c9 RH |
6026 | val -= REG_GR; |
6027 | break; | |
6028 | ||
6029 | default: | |
6030 | break; | |
6031 | } | |
6032 | ||
6033 | odesc = elf64_ia64_operands + idesc->operands[i]; | |
6034 | err = (*odesc->insert) (odesc, val, &insn); | |
6035 | if (err) | |
6036 | as_bad_where (slot->src_file, slot->src_line, | |
6037 | "Bad operand value: %s", err); | |
6038 | if (idesc->flags & IA64_OPCODE_PSEUDO) | |
6039 | { | |
6040 | if ((idesc->flags & IA64_OPCODE_F2_EQ_F3) | |
6041 | && odesc == elf64_ia64_operands + IA64_OPND_F3) | |
6042 | { | |
6043 | o2desc = elf64_ia64_operands + IA64_OPND_F2; | |
6044 | (*o2desc->insert) (o2desc, val, &insn); | |
800eeca4 | 6045 | } |
c67e42c9 RH |
6046 | if ((idesc->flags & IA64_OPCODE_LEN_EQ_64MCNT) |
6047 | && (odesc == elf64_ia64_operands + IA64_OPND_CPOS6a | |
6048 | || odesc == elf64_ia64_operands + IA64_OPND_POS6)) | |
800eeca4 | 6049 | { |
c67e42c9 RH |
6050 | o2desc = elf64_ia64_operands + IA64_OPND_LEN6; |
6051 | (*o2desc->insert) (o2desc, 64 - val, &insn); | |
800eeca4 JW |
6052 | } |
6053 | } | |
6054 | } | |
6055 | *insnp = insn; | |
6056 | } | |
6057 | ||
6058 | static void | |
6059 | emit_one_bundle () | |
6060 | { | |
6061 | unsigned int manual_bundling_on = 0, manual_bundling_off = 0; | |
6062 | unsigned int manual_bundling = 0; | |
6063 | enum ia64_unit required_unit, insn_unit = 0; | |
6064 | enum ia64_insn_type type[3], insn_type; | |
6065 | unsigned int template, orig_template; | |
542d6675 | 6066 | bfd_vma insn[3] = { -1, -1, -1 }; |
800eeca4 JW |
6067 | struct ia64_opcode *idesc; |
6068 | int end_of_insn_group = 0, user_template = -1; | |
6069 | int n, i, j, first, curr; | |
d6e78c11 | 6070 | unw_rec_list *ptr, *last_ptr, *end_ptr; |
800eeca4 JW |
6071 | bfd_vma t0 = 0, t1 = 0; |
6072 | struct label_fix *lfix; | |
6073 | struct insn_fix *ifix; | |
6074 | char mnemonic[16]; | |
6075 | fixS *fix; | |
6076 | char *f; | |
6077 | ||
6078 | first = (md.curr_slot + NUM_SLOTS - md.num_slots_in_use) % NUM_SLOTS; | |
6079 | know (first >= 0 & first < NUM_SLOTS); | |
6080 | n = MIN (3, md.num_slots_in_use); | |
6081 | ||
6082 | /* Determine template: user user_template if specified, best match | |
542d6675 | 6083 | otherwise: */ |
800eeca4 JW |
6084 | |
6085 | if (md.slot[first].user_template >= 0) | |
6086 | user_template = template = md.slot[first].user_template; | |
6087 | else | |
6088 | { | |
032efc85 | 6089 | /* Auto select appropriate template. */ |
800eeca4 JW |
6090 | memset (type, 0, sizeof (type)); |
6091 | curr = first; | |
6092 | for (i = 0; i < n; ++i) | |
6093 | { | |
032efc85 RH |
6094 | if (md.slot[curr].label_fixups && i != 0) |
6095 | break; | |
800eeca4 JW |
6096 | type[i] = md.slot[curr].idesc->type; |
6097 | curr = (curr + 1) % NUM_SLOTS; | |
6098 | } | |
6099 | template = best_template[type[0]][type[1]][type[2]]; | |
6100 | } | |
6101 | ||
542d6675 | 6102 | /* initialize instructions with appropriate nops: */ |
800eeca4 JW |
6103 | for (i = 0; i < 3; ++i) |
6104 | insn[i] = nop[ia64_templ_desc[template].exec_unit[i]]; | |
6105 | ||
6106 | f = frag_more (16); | |
6107 | ||
542d6675 | 6108 | /* now fill in slots with as many insns as possible: */ |
800eeca4 JW |
6109 | curr = first; |
6110 | idesc = md.slot[curr].idesc; | |
6111 | end_of_insn_group = 0; | |
6112 | for (i = 0; i < 3 && md.num_slots_in_use > 0; ++i) | |
6113 | { | |
d6e78c11 JW |
6114 | /* If we have unwind records, we may need to update some now. */ |
6115 | ptr = md.slot[curr].unwind_record; | |
6116 | if (ptr) | |
6117 | { | |
6118 | /* Find the last prologue/body record in the list for the current | |
6119 | insn, and set the slot number for all records up to that point. | |
6120 | This needs to be done now, because prologue/body records refer to | |
6121 | the current point, not the point after the instruction has been | |
6122 | issued. This matters because there may have been nops emitted | |
6123 | meanwhile. Any non-prologue non-body record followed by a | |
6124 | prologue/body record must also refer to the current point. */ | |
6125 | last_ptr = NULL; | |
6126 | end_ptr = md.slot[(curr + 1) % NUM_SLOTS].unwind_record; | |
6127 | for (; ptr != end_ptr; ptr = ptr->next) | |
6128 | if (ptr->r.type == prologue || ptr->r.type == prologue_gr | |
6129 | || ptr->r.type == body) | |
6130 | last_ptr = ptr; | |
6131 | if (last_ptr) | |
6132 | { | |
6133 | /* Make last_ptr point one after the last prologue/body | |
6134 | record. */ | |
6135 | last_ptr = last_ptr->next; | |
6136 | for (ptr = md.slot[curr].unwind_record; ptr != last_ptr; | |
6137 | ptr = ptr->next) | |
6138 | { | |
6139 | ptr->slot_number = (unsigned long) f + i; | |
6140 | ptr->slot_frag = frag_now; | |
6141 | } | |
6142 | /* Remove the initialized records, so that we won't accidentally | |
6143 | update them again if we insert a nop and continue. */ | |
6144 | md.slot[curr].unwind_record = last_ptr; | |
6145 | } | |
6146 | } | |
e0c9811a | 6147 | |
800eeca4 JW |
6148 | if (idesc->flags & IA64_OPCODE_SLOT2) |
6149 | { | |
6150 | if (manual_bundling && i != 2) | |
6151 | as_bad_where (md.slot[curr].src_file, md.slot[curr].src_line, | |
6152 | "`%s' must be last in bundle", idesc->name); | |
6153 | else | |
6154 | i = 2; | |
6155 | } | |
6156 | if (idesc->flags & IA64_OPCODE_LAST) | |
6157 | { | |
2434f565 JW |
6158 | int required_slot; |
6159 | unsigned int required_template; | |
800eeca4 JW |
6160 | |
6161 | /* If we need a stop bit after an M slot, our only choice is | |
6162 | template 5 (M;;MI). If we need a stop bit after a B | |
6163 | slot, our only choice is to place it at the end of the | |
6164 | bundle, because the only available templates are MIB, | |
6165 | MBB, BBB, MMB, and MFB. We don't handle anything other | |
6166 | than M and B slots because these are the only kind of | |
6167 | instructions that can have the IA64_OPCODE_LAST bit set. */ | |
6168 | required_template = template; | |
6169 | switch (idesc->type) | |
6170 | { | |
6171 | case IA64_TYPE_M: | |
6172 | required_slot = 0; | |
6173 | required_template = 5; | |
6174 | break; | |
6175 | ||
6176 | case IA64_TYPE_B: | |
6177 | required_slot = 2; | |
6178 | break; | |
6179 | ||
6180 | default: | |
6181 | as_bad_where (md.slot[curr].src_file, md.slot[curr].src_line, | |
6182 | "Internal error: don't know how to force %s to end" | |
6183 | "of instruction group", idesc->name); | |
6184 | required_slot = i; | |
6185 | break; | |
6186 | } | |
6187 | if (manual_bundling && i != required_slot) | |
6188 | as_bad_where (md.slot[curr].src_file, md.slot[curr].src_line, | |
6189 | "`%s' must be last in instruction group", | |
6190 | idesc->name); | |
6191 | if (required_slot < i) | |
6192 | /* Can't fit this instruction. */ | |
6193 | break; | |
6194 | ||
6195 | i = required_slot; | |
6196 | if (required_template != template) | |
6197 | { | |
6198 | /* If we switch the template, we need to reset the NOPs | |
6199 | after slot i. The slot-types of the instructions ahead | |
6200 | of i never change, so we don't need to worry about | |
6201 | changing NOPs in front of this slot. */ | |
6202 | for (j = i; j < 3; ++j) | |
6203 | insn[j] = nop[ia64_templ_desc[required_template].exec_unit[j]]; | |
6204 | } | |
6205 | template = required_template; | |
6206 | } | |
6207 | if (curr != first && md.slot[curr].label_fixups) | |
6208 | { | |
6209 | if (manual_bundling_on) | |
6210 | as_bad_where (md.slot[curr].src_file, md.slot[curr].src_line, | |
6211 | "Label must be first in a bundle"); | |
6212 | /* This insn must go into the first slot of a bundle. */ | |
6213 | break; | |
6214 | } | |
6215 | ||
6216 | manual_bundling_on = md.slot[curr].manual_bundling_on; | |
6217 | manual_bundling_off = md.slot[curr].manual_bundling_off; | |
6218 | ||
6219 | if (manual_bundling_on) | |
6220 | { | |
6221 | if (curr == first) | |
6222 | manual_bundling = 1; | |
6223 | else | |
6224 | break; /* need to start a new bundle */ | |
6225 | } | |
6226 | ||
6227 | if (end_of_insn_group && md.num_slots_in_use >= 1) | |
6228 | { | |
6229 | /* We need an instruction group boundary in the middle of a | |
6230 | bundle. See if we can switch to an other template with | |
6231 | an appropriate boundary. */ | |
6232 | ||
6233 | orig_template = template; | |
6234 | if (i == 1 && (user_template == 4 | |
6235 | || (user_template < 0 | |
6236 | && (ia64_templ_desc[template].exec_unit[0] | |
6237 | == IA64_UNIT_M)))) | |
6238 | { | |
6239 | template = 5; | |
6240 | end_of_insn_group = 0; | |
6241 | } | |
6242 | else if (i == 2 && (user_template == 0 | |
6243 | || (user_template < 0 | |
6244 | && (ia64_templ_desc[template].exec_unit[1] | |
6245 | == IA64_UNIT_I))) | |
6246 | /* This test makes sure we don't switch the template if | |
6247 | the next instruction is one that needs to be first in | |
6248 | an instruction group. Since all those instructions are | |
6249 | in the M group, there is no way such an instruction can | |
6250 | fit in this bundle even if we switch the template. The | |
6251 | reason we have to check for this is that otherwise we | |
6252 | may end up generating "MI;;I M.." which has the deadly | |
6253 | effect that the second M instruction is no longer the | |
6254 | first in the bundle! --davidm 99/12/16 */ | |
6255 | && (idesc->flags & IA64_OPCODE_FIRST) == 0) | |
6256 | { | |
6257 | template = 1; | |
6258 | end_of_insn_group = 0; | |
6259 | } | |
6260 | else if (curr != first) | |
6261 | /* can't fit this insn */ | |
6262 | break; | |
6263 | ||
6264 | if (template != orig_template) | |
6265 | /* if we switch the template, we need to reset the NOPs | |
6266 | after slot i. The slot-types of the instructions ahead | |
6267 | of i never change, so we don't need to worry about | |
6268 | changing NOPs in front of this slot. */ | |
6269 | for (j = i; j < 3; ++j) | |
6270 | insn[j] = nop[ia64_templ_desc[template].exec_unit[j]]; | |
6271 | } | |
6272 | required_unit = ia64_templ_desc[template].exec_unit[i]; | |
6273 | ||
c10d9d8f | 6274 | /* resolve dynamic opcodes such as "break", "hint", and "nop": */ |
800eeca4 JW |
6275 | if (idesc->type == IA64_TYPE_DYN) |
6276 | { | |
6277 | if ((strcmp (idesc->name, "nop") == 0) | |
c10d9d8f | 6278 | || (strcmp (idesc->name, "hint") == 0) |
800eeca4 JW |
6279 | || (strcmp (idesc->name, "break") == 0)) |
6280 | insn_unit = required_unit; | |
6281 | else if (strcmp (idesc->name, "chk.s") == 0) | |
6282 | { | |
6283 | insn_unit = IA64_UNIT_M; | |
6284 | if (required_unit == IA64_UNIT_I) | |
6285 | insn_unit = IA64_UNIT_I; | |
6286 | } | |
6287 | else | |
6288 | as_fatal ("emit_one_bundle: unexpected dynamic op"); | |
6289 | ||
6290 | sprintf (mnemonic, "%s.%c", idesc->name, "?imbf??"[insn_unit]); | |
3d56ab85 | 6291 | ia64_free_opcode (idesc); |
800eeca4 JW |
6292 | md.slot[curr].idesc = idesc = ia64_find_opcode (mnemonic); |
6293 | #if 0 | |
6294 | know (!idesc->next); /* no resolved dynamic ops have collisions */ | |
6295 | #endif | |
6296 | } | |
6297 | else | |
6298 | { | |
6299 | insn_type = idesc->type; | |
6300 | insn_unit = IA64_UNIT_NIL; | |
6301 | switch (insn_type) | |
6302 | { | |
6303 | case IA64_TYPE_A: | |
6304 | if (required_unit == IA64_UNIT_I || required_unit == IA64_UNIT_M) | |
6305 | insn_unit = required_unit; | |
6306 | break; | |
542d6675 | 6307 | case IA64_TYPE_X: insn_unit = IA64_UNIT_L; break; |
800eeca4 JW |
6308 | case IA64_TYPE_I: insn_unit = IA64_UNIT_I; break; |
6309 | case IA64_TYPE_M: insn_unit = IA64_UNIT_M; break; | |
6310 | case IA64_TYPE_B: insn_unit = IA64_UNIT_B; break; | |
6311 | case IA64_TYPE_F: insn_unit = IA64_UNIT_F; break; | |
6312 | default: break; | |
6313 | } | |
6314 | } | |
6315 | ||
6316 | if (insn_unit != required_unit) | |
6317 | { | |
6318 | if (required_unit == IA64_UNIT_L | |
542d6675 | 6319 | && insn_unit == IA64_UNIT_I |
800eeca4 JW |
6320 | && !(idesc->flags & IA64_OPCODE_X_IN_MLX)) |
6321 | { | |
6322 | /* we got ourselves an MLX template but the current | |
197865e8 | 6323 | instruction isn't an X-unit, or an I-unit instruction |
800eeca4 JW |
6324 | that can go into the X slot of an MLX template. Duh. */ |
6325 | if (md.num_slots_in_use >= NUM_SLOTS) | |
6326 | { | |
6327 | as_bad_where (md.slot[curr].src_file, | |
6328 | md.slot[curr].src_line, | |
6329 | "`%s' can't go in X slot of " | |
6330 | "MLX template", idesc->name); | |
542d6675 | 6331 | /* drop this insn so we don't livelock: */ |
800eeca4 JW |
6332 | --md.num_slots_in_use; |
6333 | } | |
6334 | break; | |
6335 | } | |
6336 | continue; /* try next slot */ | |
6337 | } | |
6338 | ||
40449e9f KH |
6339 | { |
6340 | bfd_vma addr; | |
800eeca4 | 6341 | |
40449e9f KH |
6342 | addr = frag_now->fr_address + frag_now_fix () - 16 + i; |
6343 | dwarf2_gen_line_info (addr, &md.slot[curr].debug_line); | |
6344 | } | |
800eeca4 | 6345 | |
88be23ec BS |
6346 | if (errata_nop_necessary_p (md.slot + curr, insn_unit)) |
6347 | as_warn (_("Additional NOP may be necessary to workaround Itanium processor A/B step errata")); | |
6348 | ||
800eeca4 JW |
6349 | build_insn (md.slot + curr, insn + i); |
6350 | ||
d6e78c11 JW |
6351 | ptr = md.slot[curr].unwind_record; |
6352 | if (ptr) | |
6353 | { | |
6354 | /* Set slot numbers for all remaining unwind records belonging to the | |
6355 | current insn. There can not be any prologue/body unwind records | |
6356 | here. */ | |
6357 | end_ptr = md.slot[(curr + 1) % NUM_SLOTS].unwind_record; | |
6358 | for (; ptr != end_ptr; ptr = ptr->next) | |
6359 | { | |
6360 | ptr->slot_number = (unsigned long) f + i; | |
6361 | ptr->slot_frag = frag_now; | |
6362 | } | |
6363 | md.slot[curr].unwind_record = NULL; | |
6364 | } | |
10850f29 | 6365 | |
800eeca4 JW |
6366 | if (required_unit == IA64_UNIT_L) |
6367 | { | |
6368 | know (i == 1); | |
6369 | /* skip one slot for long/X-unit instructions */ | |
6370 | ++i; | |
6371 | } | |
6372 | --md.num_slots_in_use; | |
6373 | ||
542d6675 | 6374 | /* now is a good time to fix up the labels for this insn: */ |
800eeca4 JW |
6375 | for (lfix = md.slot[curr].label_fixups; lfix; lfix = lfix->next) |
6376 | { | |
6377 | S_SET_VALUE (lfix->sym, frag_now_fix () - 16); | |
6378 | symbol_set_frag (lfix->sym, frag_now); | |
6379 | } | |
f1bcba5b JW |
6380 | /* and fix up the tags also. */ |
6381 | for (lfix = md.slot[curr].tag_fixups; lfix; lfix = lfix->next) | |
6382 | { | |
6383 | S_SET_VALUE (lfix->sym, frag_now_fix () - 16 + i); | |
6384 | symbol_set_frag (lfix->sym, frag_now); | |
6385 | } | |
800eeca4 JW |
6386 | |
6387 | for (j = 0; j < md.slot[curr].num_fixups; ++j) | |
6388 | { | |
6389 | ifix = md.slot[curr].fixup + j; | |
5a080f89 | 6390 | fix = fix_new_exp (frag_now, frag_now_fix () - 16 + i, 8, |
800eeca4 JW |
6391 | &ifix->expr, ifix->is_pcrel, ifix->code); |
6392 | fix->tc_fix_data.opnd = ifix->opnd; | |
6393 | fix->fx_plt = (fix->fx_r_type == BFD_RELOC_IA64_PLTOFF22); | |
6394 | fix->fx_file = md.slot[curr].src_file; | |
6395 | fix->fx_line = md.slot[curr].src_line; | |
6396 | } | |
6397 | ||
6398 | end_of_insn_group = md.slot[curr].end_of_insn_group; | |
6399 | ||
88be23ec BS |
6400 | if (end_of_insn_group) |
6401 | { | |
6402 | md.group_idx = (md.group_idx + 1) % 3; | |
6403 | memset (md.last_groups + md.group_idx, 0, sizeof md.last_groups[0]); | |
6404 | } | |
6405 | ||
542d6675 | 6406 | /* clear slot: */ |
800eeca4 JW |
6407 | ia64_free_opcode (md.slot[curr].idesc); |
6408 | memset (md.slot + curr, 0, sizeof (md.slot[curr])); | |
6409 | md.slot[curr].user_template = -1; | |
6410 | ||
6411 | if (manual_bundling_off) | |
6412 | { | |
6413 | manual_bundling = 0; | |
6414 | break; | |
6415 | } | |
6416 | curr = (curr + 1) % NUM_SLOTS; | |
6417 | idesc = md.slot[curr].idesc; | |
6418 | } | |
6419 | if (manual_bundling) | |
6420 | { | |
6421 | if (md.num_slots_in_use > 0) | |
6422 | as_bad_where (md.slot[curr].src_file, md.slot[curr].src_line, | |
6423 | "`%s' does not fit into %s template", | |
6424 | idesc->name, ia64_templ_desc[template].name); | |
6425 | else | |
6426 | as_bad_where (md.slot[curr].src_file, md.slot[curr].src_line, | |
6427 | "Missing '}' at end of file"); | |
6428 | } | |
6429 | know (md.num_slots_in_use < NUM_SLOTS); | |
6430 | ||
6431 | t0 = end_of_insn_group | (template << 1) | (insn[0] << 5) | (insn[1] << 46); | |
6432 | t1 = ((insn[1] >> 18) & 0x7fffff) | (insn[2] << 23); | |
6433 | ||
44f5c83a JW |
6434 | number_to_chars_littleendian (f + 0, t0, 8); |
6435 | number_to_chars_littleendian (f + 8, t1, 8); | |
f5a30c2e | 6436 | |
73f20958 L |
6437 | if (unwind.list) |
6438 | { | |
127cab00 L |
6439 | unwind.list->next_slot_number = (unsigned long) f + 16; |
6440 | unwind.list->next_slot_frag = frag_now; | |
73f20958 | 6441 | } |
800eeca4 JW |
6442 | } |
6443 | ||
6444 | int | |
6445 | md_parse_option (c, arg) | |
6446 | int c; | |
6447 | char *arg; | |
6448 | { | |
7463c317 | 6449 | |
800eeca4 JW |
6450 | switch (c) |
6451 | { | |
c43c2cc5 | 6452 | /* Switches from the Intel assembler. */ |
44f5c83a | 6453 | case 'm': |
800eeca4 JW |
6454 | if (strcmp (arg, "ilp64") == 0 |
6455 | || strcmp (arg, "lp64") == 0 | |
6456 | || strcmp (arg, "p64") == 0) | |
6457 | { | |
6458 | md.flags |= EF_IA_64_ABI64; | |
6459 | } | |
6460 | else if (strcmp (arg, "ilp32") == 0) | |
6461 | { | |
6462 | md.flags &= ~EF_IA_64_ABI64; | |
6463 | } | |
6464 | else if (strcmp (arg, "le") == 0) | |
6465 | { | |
6466 | md.flags &= ~EF_IA_64_BE; | |
6467 | } | |
6468 | else if (strcmp (arg, "be") == 0) | |
6469 | { | |
6470 | md.flags |= EF_IA_64_BE; | |
6471 | } | |
6472 | else | |
6473 | return 0; | |
6474 | break; | |
6475 | ||
6476 | case 'N': | |
6477 | if (strcmp (arg, "so") == 0) | |
6478 | { | |
542d6675 | 6479 | /* Suppress signon message. */ |
800eeca4 JW |
6480 | } |
6481 | else if (strcmp (arg, "pi") == 0) | |
6482 | { | |
6483 | /* Reject privileged instructions. FIXME */ | |
6484 | } | |
6485 | else if (strcmp (arg, "us") == 0) | |
6486 | { | |
6487 | /* Allow union of signed and unsigned range. FIXME */ | |
6488 | } | |
6489 | else if (strcmp (arg, "close_fcalls") == 0) | |
6490 | { | |
6491 | /* Do not resolve global function calls. */ | |
6492 | } | |
6493 | else | |
6494 | return 0; | |
6495 | break; | |
6496 | ||
6497 | case 'C': | |
6498 | /* temp[="prefix"] Insert temporary labels into the object file | |
6499 | symbol table prefixed by "prefix". | |
6500 | Default prefix is ":temp:". | |
6501 | */ | |
6502 | break; | |
6503 | ||
6504 | case 'a': | |
800eeca4 JW |
6505 | /* indirect=<tgt> Assume unannotated indirect branches behavior |
6506 | according to <tgt> -- | |
6507 | exit: branch out from the current context (default) | |
6508 | labels: all labels in context may be branch targets | |
6509 | */ | |
85b40035 L |
6510 | if (strncmp (arg, "indirect=", 9) != 0) |
6511 | return 0; | |
800eeca4 JW |
6512 | break; |
6513 | ||
6514 | case 'x': | |
6515 | /* -X conflicts with an ignored option, use -x instead */ | |
6516 | md.detect_dv = 1; | |
6517 | if (!arg || strcmp (arg, "explicit") == 0) | |
542d6675 KH |
6518 | { |
6519 | /* set default mode to explicit */ | |
6520 | md.default_explicit_mode = 1; | |
6521 | break; | |
6522 | } | |
800eeca4 | 6523 | else if (strcmp (arg, "auto") == 0) |
542d6675 KH |
6524 | { |
6525 | md.default_explicit_mode = 0; | |
6526 | } | |
800eeca4 | 6527 | else if (strcmp (arg, "debug") == 0) |
542d6675 KH |
6528 | { |
6529 | md.debug_dv = 1; | |
6530 | } | |
800eeca4 | 6531 | else if (strcmp (arg, "debugx") == 0) |
542d6675 KH |
6532 | { |
6533 | md.default_explicit_mode = 1; | |
6534 | md.debug_dv = 1; | |
6535 | } | |
800eeca4 | 6536 | else |
542d6675 KH |
6537 | { |
6538 | as_bad (_("Unrecognized option '-x%s'"), arg); | |
6539 | } | |
800eeca4 JW |
6540 | break; |
6541 | ||
6542 | case 'S': | |
6543 | /* nops Print nops statistics. */ | |
6544 | break; | |
6545 | ||
c43c2cc5 JW |
6546 | /* GNU specific switches for gcc. */ |
6547 | case OPTION_MCONSTANT_GP: | |
6548 | md.flags |= EF_IA_64_CONS_GP; | |
6549 | break; | |
6550 | ||
6551 | case OPTION_MAUTO_PIC: | |
6552 | md.flags |= EF_IA_64_NOFUNCDESC_CONS_GP; | |
6553 | break; | |
6554 | ||
800eeca4 JW |
6555 | default: |
6556 | return 0; | |
6557 | } | |
6558 | ||
6559 | return 1; | |
6560 | } | |
6561 | ||
6562 | void | |
6563 | md_show_usage (stream) | |
6564 | FILE *stream; | |
6565 | { | |
542d6675 | 6566 | fputs (_("\ |
800eeca4 | 6567 | IA-64 options:\n\ |
6290819d NC |
6568 | --mconstant-gp mark output file as using the constant-GP model\n\ |
6569 | (sets ELF header flag EF_IA_64_CONS_GP)\n\ | |
6570 | --mauto-pic mark output file as using the constant-GP model\n\ | |
6571 | without function descriptors (sets ELF header flag\n\ | |
6572 | EF_IA_64_NOFUNCDESC_CONS_GP)\n\ | |
44f5c83a JW |
6573 | -milp32|-milp64|-mlp64|-mp64 select data model (default -mlp64)\n\ |
6574 | -mle | -mbe select little- or big-endian byte order (default -mle)\n\ | |
800eeca4 JW |
6575 | -x | -xexplicit turn on dependency violation checking (default)\n\ |
6576 | -xauto automagically remove dependency violations\n\ | |
6577 | -xdebug debug dependency violation checker\n"), | |
6578 | stream); | |
6579 | } | |
6580 | ||
acebd4ce AS |
6581 | void |
6582 | ia64_after_parse_args () | |
6583 | { | |
6584 | if (debug_type == DEBUG_STABS) | |
6585 | as_fatal (_("--gstabs is not supported for ia64")); | |
6586 | } | |
6587 | ||
44576e1f RH |
6588 | /* Return true if TYPE fits in TEMPL at SLOT. */ |
6589 | ||
6590 | static int | |
800eeca4 JW |
6591 | match (int templ, int type, int slot) |
6592 | { | |
6593 | enum ia64_unit unit; | |
6594 | int result; | |
6595 | ||
6596 | unit = ia64_templ_desc[templ].exec_unit[slot]; | |
6597 | switch (type) | |
6598 | { | |
6599 | case IA64_TYPE_DYN: result = 1; break; /* for nop and break */ | |
6600 | case IA64_TYPE_A: | |
6601 | result = (unit == IA64_UNIT_I || unit == IA64_UNIT_M); | |
6602 | break; | |
6603 | case IA64_TYPE_X: result = (unit == IA64_UNIT_L); break; | |
6604 | case IA64_TYPE_I: result = (unit == IA64_UNIT_I); break; | |
6605 | case IA64_TYPE_M: result = (unit == IA64_UNIT_M); break; | |
6606 | case IA64_TYPE_B: result = (unit == IA64_UNIT_B); break; | |
6607 | case IA64_TYPE_F: result = (unit == IA64_UNIT_F); break; | |
6608 | default: result = 0; break; | |
6609 | } | |
6610 | return result; | |
6611 | } | |
6612 | ||
44576e1f RH |
6613 | /* Add a bit of extra goodness if a nop of type F or B would fit |
6614 | in TEMPL at SLOT. */ | |
6615 | ||
6616 | static inline int | |
6617 | extra_goodness (int templ, int slot) | |
6618 | { | |
ebeeafe6 | 6619 | if (slot == 1 && match (templ, IA64_TYPE_F, slot)) |
44576e1f | 6620 | return 2; |
ebeeafe6 | 6621 | if (slot == 2 && match (templ, IA64_TYPE_B, slot)) |
44576e1f RH |
6622 | return 1; |
6623 | return 0; | |
6624 | } | |
6625 | ||
800eeca4 JW |
6626 | /* This function is called once, at assembler startup time. It sets |
6627 | up all the tables, etc. that the MD part of the assembler will need | |
6628 | that can be determined before arguments are parsed. */ | |
6629 | void | |
6630 | md_begin () | |
6631 | { | |
44f5c83a | 6632 | int i, j, k, t, total, ar_base, cr_base, goodness, best, regnum, ok; |
800eeca4 JW |
6633 | const char *err; |
6634 | char name[8]; | |
6635 | ||
6636 | md.auto_align = 1; | |
6637 | md.explicit_mode = md.default_explicit_mode; | |
6638 | ||
6639 | bfd_set_section_alignment (stdoutput, text_section, 4); | |
6640 | ||
0234cb7c | 6641 | /* Make sure function pointers get initialized. */ |
10a98291 L |
6642 | target_big_endian = -1; |
6643 | dot_byteorder (TARGET_BYTES_BIG_ENDIAN); | |
6644 | ||
35f5df7f L |
6645 | alias_hash = hash_new (); |
6646 | alias_name_hash = hash_new (); | |
6647 | secalias_hash = hash_new (); | |
6648 | secalias_name_hash = hash_new (); | |
6649 | ||
13ae64f3 JJ |
6650 | pseudo_func[FUNC_DTP_MODULE].u.sym = |
6651 | symbol_new (".<dtpmod>", undefined_section, FUNC_DTP_MODULE, | |
6652 | &zero_address_frag); | |
6653 | ||
6654 | pseudo_func[FUNC_DTP_RELATIVE].u.sym = | |
6655 | symbol_new (".<dtprel>", undefined_section, FUNC_DTP_RELATIVE, | |
6656 | &zero_address_frag); | |
6657 | ||
800eeca4 | 6658 | pseudo_func[FUNC_FPTR_RELATIVE].u.sym = |
542d6675 KH |
6659 | symbol_new (".<fptr>", undefined_section, FUNC_FPTR_RELATIVE, |
6660 | &zero_address_frag); | |
800eeca4 JW |
6661 | |
6662 | pseudo_func[FUNC_GP_RELATIVE].u.sym = | |
542d6675 KH |
6663 | symbol_new (".<gprel>", undefined_section, FUNC_GP_RELATIVE, |
6664 | &zero_address_frag); | |
800eeca4 JW |
6665 | |
6666 | pseudo_func[FUNC_LT_RELATIVE].u.sym = | |
542d6675 KH |
6667 | symbol_new (".<ltoff>", undefined_section, FUNC_LT_RELATIVE, |
6668 | &zero_address_frag); | |
800eeca4 | 6669 | |
fa2c7eff RH |
6670 | pseudo_func[FUNC_LT_RELATIVE_X].u.sym = |
6671 | symbol_new (".<ltoffx>", undefined_section, FUNC_LT_RELATIVE_X, | |
6672 | &zero_address_frag); | |
6673 | ||
c67e42c9 | 6674 | pseudo_func[FUNC_PC_RELATIVE].u.sym = |
542d6675 KH |
6675 | symbol_new (".<pcrel>", undefined_section, FUNC_PC_RELATIVE, |
6676 | &zero_address_frag); | |
c67e42c9 | 6677 | |
800eeca4 | 6678 | pseudo_func[FUNC_PLT_RELATIVE].u.sym = |
542d6675 KH |
6679 | symbol_new (".<pltoff>", undefined_section, FUNC_PLT_RELATIVE, |
6680 | &zero_address_frag); | |
800eeca4 JW |
6681 | |
6682 | pseudo_func[FUNC_SEC_RELATIVE].u.sym = | |
542d6675 KH |
6683 | symbol_new (".<secrel>", undefined_section, FUNC_SEC_RELATIVE, |
6684 | &zero_address_frag); | |
800eeca4 JW |
6685 | |
6686 | pseudo_func[FUNC_SEG_RELATIVE].u.sym = | |
542d6675 KH |
6687 | symbol_new (".<segrel>", undefined_section, FUNC_SEG_RELATIVE, |
6688 | &zero_address_frag); | |
800eeca4 | 6689 | |
13ae64f3 JJ |
6690 | pseudo_func[FUNC_TP_RELATIVE].u.sym = |
6691 | symbol_new (".<tprel>", undefined_section, FUNC_TP_RELATIVE, | |
6692 | &zero_address_frag); | |
6693 | ||
800eeca4 | 6694 | pseudo_func[FUNC_LTV_RELATIVE].u.sym = |
542d6675 KH |
6695 | symbol_new (".<ltv>", undefined_section, FUNC_LTV_RELATIVE, |
6696 | &zero_address_frag); | |
800eeca4 JW |
6697 | |
6698 | pseudo_func[FUNC_LT_FPTR_RELATIVE].u.sym = | |
542d6675 KH |
6699 | symbol_new (".<ltoff.fptr>", undefined_section, FUNC_LT_FPTR_RELATIVE, |
6700 | &zero_address_frag); | |
800eeca4 | 6701 | |
13ae64f3 JJ |
6702 | pseudo_func[FUNC_LT_DTP_MODULE].u.sym = |
6703 | symbol_new (".<ltoff.dtpmod>", undefined_section, FUNC_LT_DTP_MODULE, | |
6704 | &zero_address_frag); | |
6705 | ||
6706 | pseudo_func[FUNC_LT_DTP_RELATIVE].u.sym = | |
6707 | symbol_new (".<ltoff.dptrel>", undefined_section, FUNC_LT_DTP_RELATIVE, | |
6708 | &zero_address_frag); | |
6709 | ||
6710 | pseudo_func[FUNC_LT_TP_RELATIVE].u.sym = | |
6711 | symbol_new (".<ltoff.tprel>", undefined_section, FUNC_LT_TP_RELATIVE, | |
6712 | &zero_address_frag); | |
6713 | ||
3969b680 RH |
6714 | pseudo_func[FUNC_IPLT_RELOC].u.sym = |
6715 | symbol_new (".<iplt>", undefined_section, FUNC_IPLT_RELOC, | |
6716 | &zero_address_frag); | |
6717 | ||
197865e8 | 6718 | /* Compute the table of best templates. We compute goodness as a |
44576e1f RH |
6719 | base 4 value, in which each match counts for 3, each F counts |
6720 | for 2, each B counts for 1. This should maximize the number of | |
6721 | F and B nops in the chosen bundles, which is good because these | |
6722 | pipelines are least likely to be overcommitted. */ | |
800eeca4 JW |
6723 | for (i = 0; i < IA64_NUM_TYPES; ++i) |
6724 | for (j = 0; j < IA64_NUM_TYPES; ++j) | |
6725 | for (k = 0; k < IA64_NUM_TYPES; ++k) | |
6726 | { | |
6727 | best = 0; | |
6728 | for (t = 0; t < NELEMS (ia64_templ_desc); ++t) | |
6729 | { | |
6730 | goodness = 0; | |
6731 | if (match (t, i, 0)) | |
6732 | { | |
6733 | if (match (t, j, 1)) | |
6734 | { | |
6735 | if (match (t, k, 2)) | |
44576e1f | 6736 | goodness = 3 + 3 + 3; |
800eeca4 | 6737 | else |
44576e1f | 6738 | goodness = 3 + 3 + extra_goodness (t, 2); |
800eeca4 JW |
6739 | } |
6740 | else if (match (t, j, 2)) | |
44576e1f | 6741 | goodness = 3 + 3 + extra_goodness (t, 1); |
800eeca4 | 6742 | else |
44576e1f RH |
6743 | { |
6744 | goodness = 3; | |
6745 | goodness += extra_goodness (t, 1); | |
6746 | goodness += extra_goodness (t, 2); | |
6747 | } | |
800eeca4 JW |
6748 | } |
6749 | else if (match (t, i, 1)) | |
6750 | { | |
6751 | if (match (t, j, 2)) | |
44576e1f | 6752 | goodness = 3 + 3; |
800eeca4 | 6753 | else |
44576e1f | 6754 | goodness = 3 + extra_goodness (t, 2); |
800eeca4 JW |
6755 | } |
6756 | else if (match (t, i, 2)) | |
44576e1f | 6757 | goodness = 3 + extra_goodness (t, 1); |
800eeca4 JW |
6758 | |
6759 | if (goodness > best) | |
6760 | { | |
6761 | best = goodness; | |
6762 | best_template[i][j][k] = t; | |
6763 | } | |
6764 | } | |
6765 | } | |
6766 | ||
6767 | for (i = 0; i < NUM_SLOTS; ++i) | |
6768 | md.slot[i].user_template = -1; | |
6769 | ||
6770 | md.pseudo_hash = hash_new (); | |
6771 | for (i = 0; i < NELEMS (pseudo_opcode); ++i) | |
6772 | { | |
6773 | err = hash_insert (md.pseudo_hash, pseudo_opcode[i].name, | |
6774 | (void *) (pseudo_opcode + i)); | |
6775 | if (err) | |
6776 | as_fatal ("ia64.md_begin: can't hash `%s': %s", | |
6777 | pseudo_opcode[i].name, err); | |
6778 | } | |
6779 | ||
6780 | md.reg_hash = hash_new (); | |
6781 | md.dynreg_hash = hash_new (); | |
6782 | md.const_hash = hash_new (); | |
6783 | md.entry_hash = hash_new (); | |
6784 | ||
542d6675 | 6785 | /* general registers: */ |
800eeca4 JW |
6786 | |
6787 | total = 128; | |
6788 | for (i = 0; i < total; ++i) | |
6789 | { | |
6790 | sprintf (name, "r%d", i - REG_GR); | |
6791 | md.regsym[i] = declare_register (name, i); | |
6792 | } | |
6793 | ||
542d6675 | 6794 | /* floating point registers: */ |
800eeca4 JW |
6795 | total += 128; |
6796 | for (; i < total; ++i) | |
6797 | { | |
6798 | sprintf (name, "f%d", i - REG_FR); | |
6799 | md.regsym[i] = declare_register (name, i); | |
6800 | } | |
6801 | ||
542d6675 | 6802 | /* application registers: */ |
800eeca4 JW |
6803 | total += 128; |
6804 | ar_base = i; | |
6805 | for (; i < total; ++i) | |
6806 | { | |
6807 | sprintf (name, "ar%d", i - REG_AR); | |
6808 | md.regsym[i] = declare_register (name, i); | |
6809 | } | |
6810 | ||
542d6675 | 6811 | /* control registers: */ |
800eeca4 JW |
6812 | total += 128; |
6813 | cr_base = i; | |
6814 | for (; i < total; ++i) | |
6815 | { | |
6816 | sprintf (name, "cr%d", i - REG_CR); | |
6817 | md.regsym[i] = declare_register (name, i); | |
6818 | } | |
6819 | ||
542d6675 | 6820 | /* predicate registers: */ |
800eeca4 JW |
6821 | total += 64; |
6822 | for (; i < total; ++i) | |
6823 | { | |
6824 | sprintf (name, "p%d", i - REG_P); | |
6825 | md.regsym[i] = declare_register (name, i); | |
6826 | } | |
6827 | ||
542d6675 | 6828 | /* branch registers: */ |
800eeca4 JW |
6829 | total += 8; |
6830 | for (; i < total; ++i) | |
6831 | { | |
6832 | sprintf (name, "b%d", i - REG_BR); | |
6833 | md.regsym[i] = declare_register (name, i); | |
6834 | } | |
6835 | ||
6836 | md.regsym[REG_IP] = declare_register ("ip", REG_IP); | |
6837 | md.regsym[REG_CFM] = declare_register ("cfm", REG_CFM); | |
6838 | md.regsym[REG_PR] = declare_register ("pr", REG_PR); | |
6839 | md.regsym[REG_PR_ROT] = declare_register ("pr.rot", REG_PR_ROT); | |
6840 | md.regsym[REG_PSR] = declare_register ("psr", REG_PSR); | |
6841 | md.regsym[REG_PSR_L] = declare_register ("psr.l", REG_PSR_L); | |
6842 | md.regsym[REG_PSR_UM] = declare_register ("psr.um", REG_PSR_UM); | |
6843 | ||
6844 | for (i = 0; i < NELEMS (indirect_reg); ++i) | |
6845 | { | |
6846 | regnum = indirect_reg[i].regnum; | |
6847 | md.regsym[regnum] = declare_register (indirect_reg[i].name, regnum); | |
6848 | } | |
6849 | ||
542d6675 | 6850 | /* define synonyms for application registers: */ |
800eeca4 JW |
6851 | for (i = REG_AR; i < REG_AR + NELEMS (ar); ++i) |
6852 | md.regsym[i] = declare_register (ar[i - REG_AR].name, | |
6853 | REG_AR + ar[i - REG_AR].regnum); | |
6854 | ||
542d6675 | 6855 | /* define synonyms for control registers: */ |
800eeca4 JW |
6856 | for (i = REG_CR; i < REG_CR + NELEMS (cr); ++i) |
6857 | md.regsym[i] = declare_register (cr[i - REG_CR].name, | |
6858 | REG_CR + cr[i - REG_CR].regnum); | |
6859 | ||
6860 | declare_register ("gp", REG_GR + 1); | |
6861 | declare_register ("sp", REG_GR + 12); | |
6862 | declare_register ("rp", REG_BR + 0); | |
6863 | ||
542d6675 | 6864 | /* pseudo-registers used to specify unwind info: */ |
e0c9811a JW |
6865 | declare_register ("psp", REG_PSP); |
6866 | ||
800eeca4 JW |
6867 | declare_register_set ("ret", 4, REG_GR + 8); |
6868 | declare_register_set ("farg", 8, REG_FR + 8); | |
6869 | declare_register_set ("fret", 8, REG_FR + 8); | |
6870 | ||
6871 | for (i = 0; i < NELEMS (const_bits); ++i) | |
6872 | { | |
6873 | err = hash_insert (md.const_hash, const_bits[i].name, | |
6874 | (PTR) (const_bits + i)); | |
6875 | if (err) | |
6876 | as_fatal ("Inserting \"%s\" into constant hash table failed: %s", | |
6877 | name, err); | |
6878 | } | |
6879 | ||
44f5c83a JW |
6880 | /* Set the architecture and machine depending on defaults and command line |
6881 | options. */ | |
6882 | if (md.flags & EF_IA_64_ABI64) | |
6883 | ok = bfd_set_arch_mach (stdoutput, bfd_arch_ia64, bfd_mach_ia64_elf64); | |
6884 | else | |
6885 | ok = bfd_set_arch_mach (stdoutput, bfd_arch_ia64, bfd_mach_ia64_elf32); | |
6886 | ||
6887 | if (! ok) | |
6888 | as_warn (_("Could not set architecture and machine")); | |
800eeca4 | 6889 | |
557debba JW |
6890 | /* Set the pointer size and pointer shift size depending on md.flags */ |
6891 | ||
6892 | if (md.flags & EF_IA_64_ABI64) | |
6893 | { | |
6894 | md.pointer_size = 8; /* pointers are 8 bytes */ | |
6895 | md.pointer_size_shift = 3; /* alignment is 8 bytes = 2^2 */ | |
6896 | } | |
6897 | else | |
6898 | { | |
6899 | md.pointer_size = 4; /* pointers are 4 bytes */ | |
6900 | md.pointer_size_shift = 2; /* alignment is 4 bytes = 2^2 */ | |
6901 | } | |
6902 | ||
800eeca4 JW |
6903 | md.mem_offset.hint = 0; |
6904 | md.path = 0; | |
6905 | md.maxpaths = 0; | |
6906 | md.entry_labels = NULL; | |
6907 | } | |
6908 | ||
44f5c83a JW |
6909 | /* Set the elf type to 64 bit ABI by default. Cannot do this in md_begin |
6910 | because that is called after md_parse_option which is where we do the | |
6911 | dynamic changing of md.flags based on -mlp64 or -milp32. Also, set the | |
6912 | default endianness. */ | |
6913 | ||
6914 | void | |
6915 | ia64_init (argc, argv) | |
2434f565 JW |
6916 | int argc ATTRIBUTE_UNUSED; |
6917 | char **argv ATTRIBUTE_UNUSED; | |
44f5c83a | 6918 | { |
1cd8ff38 | 6919 | md.flags = MD_FLAGS_DEFAULT; |
44f5c83a JW |
6920 | } |
6921 | ||
6922 | /* Return a string for the target object file format. */ | |
6923 | ||
6924 | const char * | |
6925 | ia64_target_format () | |
6926 | { | |
6927 | if (OUTPUT_FLAVOR == bfd_target_elf_flavour) | |
6928 | { | |
72a76794 JW |
6929 | if (md.flags & EF_IA_64_BE) |
6930 | { | |
6931 | if (md.flags & EF_IA_64_ABI64) | |
1cd8ff38 | 6932 | #if defined(TE_AIX50) |
7463c317 | 6933 | return "elf64-ia64-aix-big"; |
1cd8ff38 NC |
6934 | #elif defined(TE_HPUX) |
6935 | return "elf64-ia64-hpux-big"; | |
7463c317 | 6936 | #else |
72a76794 | 6937 | return "elf64-ia64-big"; |
7463c317 | 6938 | #endif |
72a76794 | 6939 | else |
1cd8ff38 | 6940 | #if defined(TE_AIX50) |
7463c317 | 6941 | return "elf32-ia64-aix-big"; |
1cd8ff38 NC |
6942 | #elif defined(TE_HPUX) |
6943 | return "elf32-ia64-hpux-big"; | |
7463c317 | 6944 | #else |
72a76794 | 6945 | return "elf32-ia64-big"; |
7463c317 | 6946 | #endif |
72a76794 | 6947 | } |
44f5c83a | 6948 | else |
72a76794 JW |
6949 | { |
6950 | if (md.flags & EF_IA_64_ABI64) | |
7463c317 TW |
6951 | #ifdef TE_AIX50 |
6952 | return "elf64-ia64-aix-little"; | |
6953 | #else | |
72a76794 | 6954 | return "elf64-ia64-little"; |
7463c317 | 6955 | #endif |
72a76794 | 6956 | else |
7463c317 TW |
6957 | #ifdef TE_AIX50 |
6958 | return "elf32-ia64-aix-little"; | |
6959 | #else | |
72a76794 | 6960 | return "elf32-ia64-little"; |
7463c317 | 6961 | #endif |
72a76794 | 6962 | } |
44f5c83a JW |
6963 | } |
6964 | else | |
6965 | return "unknown-format"; | |
6966 | } | |
6967 | ||
800eeca4 JW |
6968 | void |
6969 | ia64_end_of_source () | |
6970 | { | |
542d6675 | 6971 | /* terminate insn group upon reaching end of file: */ |
800eeca4 JW |
6972 | insn_group_break (1, 0, 0); |
6973 | ||
542d6675 | 6974 | /* emits slots we haven't written yet: */ |
800eeca4 JW |
6975 | ia64_flush_insns (); |
6976 | ||
6977 | bfd_set_private_flags (stdoutput, md.flags); | |
6978 | ||
800eeca4 JW |
6979 | md.mem_offset.hint = 0; |
6980 | } | |
6981 | ||
6982 | void | |
6983 | ia64_start_line () | |
6984 | { | |
f1bcba5b JW |
6985 | if (md.qp.X_op == O_register) |
6986 | as_bad ("qualifying predicate not followed by instruction"); | |
800eeca4 JW |
6987 | md.qp.X_op = O_absent; |
6988 | ||
6989 | if (ignore_input ()) | |
6990 | return; | |
6991 | ||
6992 | if (input_line_pointer[0] == ';' && input_line_pointer[-1] == ';') | |
6993 | { | |
6994 | if (md.detect_dv && !md.explicit_mode) | |
542d6675 | 6995 | as_warn (_("Explicit stops are ignored in auto mode")); |
800eeca4 | 6996 | else |
542d6675 | 6997 | insn_group_break (1, 0, 0); |
800eeca4 JW |
6998 | } |
6999 | } | |
7000 | ||
f1bcba5b JW |
7001 | /* This is a hook for ia64_frob_label, so that it can distinguish tags from |
7002 | labels. */ | |
7003 | static int defining_tag = 0; | |
7004 | ||
800eeca4 JW |
7005 | int |
7006 | ia64_unrecognized_line (ch) | |
7007 | int ch; | |
7008 | { | |
7009 | switch (ch) | |
7010 | { | |
7011 | case '(': | |
7012 | expression (&md.qp); | |
7013 | if (*input_line_pointer++ != ')') | |
7014 | { | |
7015 | as_bad ("Expected ')'"); | |
7016 | return 0; | |
7017 | } | |
7018 | if (md.qp.X_op != O_register) | |
7019 | { | |
7020 | as_bad ("Qualifying predicate expected"); | |
7021 | return 0; | |
7022 | } | |
7023 | if (md.qp.X_add_number < REG_P || md.qp.X_add_number >= REG_P + 64) | |
7024 | { | |
7025 | as_bad ("Predicate register expected"); | |
7026 | return 0; | |
7027 | } | |
7028 | return 1; | |
7029 | ||
7030 | case '{': | |
7031 | if (md.manual_bundling) | |
7032 | as_warn ("Found '{' when manual bundling is already turned on"); | |
7033 | else | |
7034 | CURR_SLOT.manual_bundling_on = 1; | |
7035 | md.manual_bundling = 1; | |
7036 | ||
542d6675 KH |
7037 | /* Bundling is only acceptable in explicit mode |
7038 | or when in default automatic mode. */ | |
800eeca4 | 7039 | if (md.detect_dv && !md.explicit_mode) |
542d6675 KH |
7040 | { |
7041 | if (!md.mode_explicitly_set | |
7042 | && !md.default_explicit_mode) | |
7043 | dot_dv_mode ('E'); | |
7044 | else | |
7045 | as_warn (_("Found '{' after explicit switch to automatic mode")); | |
7046 | } | |
800eeca4 JW |
7047 | return 1; |
7048 | ||
7049 | case '}': | |
7050 | if (!md.manual_bundling) | |
7051 | as_warn ("Found '}' when manual bundling is off"); | |
7052 | else | |
7053 | PREV_SLOT.manual_bundling_off = 1; | |
7054 | md.manual_bundling = 0; | |
7055 | ||
7056 | /* switch back to automatic mode, if applicable */ | |
197865e8 | 7057 | if (md.detect_dv |
542d6675 KH |
7058 | && md.explicit_mode |
7059 | && !md.mode_explicitly_set | |
7060 | && !md.default_explicit_mode) | |
7061 | dot_dv_mode ('A'); | |
800eeca4 JW |
7062 | |
7063 | /* Allow '{' to follow on the same line. We also allow ";;", but that | |
7064 | happens automatically because ';' is an end of line marker. */ | |
7065 | SKIP_WHITESPACE (); | |
7066 | if (input_line_pointer[0] == '{') | |
7067 | { | |
7068 | input_line_pointer++; | |
7069 | return ia64_unrecognized_line ('{'); | |
7070 | } | |
7071 | ||
7072 | demand_empty_rest_of_line (); | |
7073 | return 1; | |
7074 | ||
f1bcba5b JW |
7075 | case '[': |
7076 | { | |
7077 | char *s; | |
7078 | char c; | |
7079 | symbolS *tag; | |
4d5a53ff | 7080 | int temp; |
f1bcba5b JW |
7081 | |
7082 | if (md.qp.X_op == O_register) | |
7083 | { | |
7084 | as_bad ("Tag must come before qualifying predicate."); | |
7085 | return 0; | |
7086 | } | |
4d5a53ff JW |
7087 | |
7088 | /* This implements just enough of read_a_source_file in read.c to | |
7089 | recognize labels. */ | |
7090 | if (is_name_beginner (*input_line_pointer)) | |
7091 | { | |
7092 | s = input_line_pointer; | |
7093 | c = get_symbol_end (); | |
7094 | } | |
7095 | else if (LOCAL_LABELS_FB | |
3882b010 | 7096 | && ISDIGIT (*input_line_pointer)) |
4d5a53ff JW |
7097 | { |
7098 | temp = 0; | |
3882b010 | 7099 | while (ISDIGIT (*input_line_pointer)) |
4d5a53ff JW |
7100 | temp = (temp * 10) + *input_line_pointer++ - '0'; |
7101 | fb_label_instance_inc (temp); | |
7102 | s = fb_label_name (temp, 0); | |
7103 | c = *input_line_pointer; | |
7104 | } | |
7105 | else | |
7106 | { | |
7107 | s = NULL; | |
7108 | c = '\0'; | |
7109 | } | |
f1bcba5b JW |
7110 | if (c != ':') |
7111 | { | |
7112 | /* Put ':' back for error messages' sake. */ | |
7113 | *input_line_pointer++ = ':'; | |
7114 | as_bad ("Expected ':'"); | |
7115 | return 0; | |
7116 | } | |
4d5a53ff | 7117 | |
f1bcba5b JW |
7118 | defining_tag = 1; |
7119 | tag = colon (s); | |
7120 | defining_tag = 0; | |
7121 | /* Put ':' back for error messages' sake. */ | |
7122 | *input_line_pointer++ = ':'; | |
7123 | if (*input_line_pointer++ != ']') | |
7124 | { | |
7125 | as_bad ("Expected ']'"); | |
7126 | return 0; | |
7127 | } | |
7128 | if (! tag) | |
7129 | { | |
7130 | as_bad ("Tag name expected"); | |
7131 | return 0; | |
7132 | } | |
7133 | return 1; | |
7134 | } | |
7135 | ||
800eeca4 JW |
7136 | default: |
7137 | break; | |
7138 | } | |
542d6675 KH |
7139 | |
7140 | /* Not a valid line. */ | |
7141 | return 0; | |
800eeca4 JW |
7142 | } |
7143 | ||
7144 | void | |
7145 | ia64_frob_label (sym) | |
7146 | struct symbol *sym; | |
7147 | { | |
7148 | struct label_fix *fix; | |
7149 | ||
f1bcba5b JW |
7150 | /* Tags need special handling since they are not bundle breaks like |
7151 | labels. */ | |
7152 | if (defining_tag) | |
7153 | { | |
7154 | fix = obstack_alloc (¬es, sizeof (*fix)); | |
7155 | fix->sym = sym; | |
7156 | fix->next = CURR_SLOT.tag_fixups; | |
7157 | CURR_SLOT.tag_fixups = fix; | |
7158 | ||
7159 | return; | |
7160 | } | |
7161 | ||
800eeca4 JW |
7162 | if (bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE) |
7163 | { | |
7164 | md.last_text_seg = now_seg; | |
7165 | fix = obstack_alloc (¬es, sizeof (*fix)); | |
7166 | fix->sym = sym; | |
7167 | fix->next = CURR_SLOT.label_fixups; | |
7168 | CURR_SLOT.label_fixups = fix; | |
7169 | ||
542d6675 | 7170 | /* Keep track of how many code entry points we've seen. */ |
800eeca4 | 7171 | if (md.path == md.maxpaths) |
542d6675 KH |
7172 | { |
7173 | md.maxpaths += 20; | |
7174 | md.entry_labels = (const char **) | |
7175 | xrealloc ((void *) md.entry_labels, | |
7176 | md.maxpaths * sizeof (char *)); | |
7177 | } | |
800eeca4 JW |
7178 | md.entry_labels[md.path++] = S_GET_NAME (sym); |
7179 | } | |
7180 | } | |
7181 | ||
936cf02e JW |
7182 | #ifdef TE_HPUX |
7183 | /* The HP-UX linker will give unresolved symbol errors for symbols | |
7184 | that are declared but unused. This routine removes declared, | |
7185 | unused symbols from an object. */ | |
7186 | int | |
7187 | ia64_frob_symbol (sym) | |
7188 | struct symbol *sym; | |
7189 | { | |
7190 | if ((S_GET_SEGMENT (sym) == &bfd_und_section && ! symbol_used_p (sym) && | |
7191 | ELF_ST_VISIBILITY (S_GET_OTHER (sym)) == STV_DEFAULT) | |
7192 | || (S_GET_SEGMENT (sym) == &bfd_abs_section | |
7193 | && ! S_IS_EXTERNAL (sym))) | |
7194 | return 1; | |
7195 | return 0; | |
7196 | } | |
7197 | #endif | |
7198 | ||
800eeca4 JW |
7199 | void |
7200 | ia64_flush_pending_output () | |
7201 | { | |
4d5a53ff JW |
7202 | if (!md.keep_pending_output |
7203 | && bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE) | |
800eeca4 JW |
7204 | { |
7205 | /* ??? This causes many unnecessary stop bits to be emitted. | |
7206 | Unfortunately, it isn't clear if it is safe to remove this. */ | |
7207 | insn_group_break (1, 0, 0); | |
7208 | ia64_flush_insns (); | |
7209 | } | |
7210 | } | |
7211 | ||
7212 | /* Do ia64-specific expression optimization. All that's done here is | |
7213 | to transform index expressions that are either due to the indexing | |
7214 | of rotating registers or due to the indexing of indirect register | |
7215 | sets. */ | |
7216 | int | |
7217 | ia64_optimize_expr (l, op, r) | |
7218 | expressionS *l; | |
7219 | operatorT op; | |
7220 | expressionS *r; | |
7221 | { | |
7222 | unsigned num_regs; | |
7223 | ||
7224 | if (op == O_index) | |
7225 | { | |
7226 | if (l->X_op == O_register && r->X_op == O_constant) | |
7227 | { | |
7228 | num_regs = (l->X_add_number >> 16); | |
7229 | if ((unsigned) r->X_add_number >= num_regs) | |
7230 | { | |
7231 | if (!num_regs) | |
7232 | as_bad ("No current frame"); | |
7233 | else | |
7234 | as_bad ("Index out of range 0..%u", num_regs - 1); | |
7235 | r->X_add_number = 0; | |
7236 | } | |
7237 | l->X_add_number = (l->X_add_number & 0xffff) + r->X_add_number; | |
7238 | return 1; | |
7239 | } | |
7240 | else if (l->X_op == O_register && r->X_op == O_register) | |
7241 | { | |
7242 | if (l->X_add_number < IND_CPUID || l->X_add_number > IND_RR | |
7243 | || l->X_add_number == IND_MEM) | |
7244 | { | |
7245 | as_bad ("Indirect register set name expected"); | |
7246 | l->X_add_number = IND_CPUID; | |
7247 | } | |
7248 | l->X_op = O_index; | |
7249 | l->X_op_symbol = md.regsym[l->X_add_number]; | |
7250 | l->X_add_number = r->X_add_number; | |
7251 | return 1; | |
7252 | } | |
7253 | } | |
7254 | return 0; | |
7255 | } | |
7256 | ||
7257 | int | |
7258 | ia64_parse_name (name, e) | |
7259 | char *name; | |
7260 | expressionS *e; | |
7261 | { | |
7262 | struct const_desc *cdesc; | |
7263 | struct dynreg *dr = 0; | |
7264 | unsigned int regnum; | |
7265 | struct symbol *sym; | |
7266 | char *end; | |
7267 | ||
542d6675 | 7268 | /* first see if NAME is a known register name: */ |
800eeca4 JW |
7269 | sym = hash_find (md.reg_hash, name); |
7270 | if (sym) | |
7271 | { | |
7272 | e->X_op = O_register; | |
7273 | e->X_add_number = S_GET_VALUE (sym); | |
7274 | return 1; | |
7275 | } | |
7276 | ||
7277 | cdesc = hash_find (md.const_hash, name); | |
7278 | if (cdesc) | |
7279 | { | |
7280 | e->X_op = O_constant; | |
7281 | e->X_add_number = cdesc->value; | |
7282 | return 1; | |
7283 | } | |
7284 | ||
542d6675 | 7285 | /* check for inN, locN, or outN: */ |
800eeca4 JW |
7286 | switch (name[0]) |
7287 | { | |
7288 | case 'i': | |
3882b010 | 7289 | if (name[1] == 'n' && ISDIGIT (name[2])) |
800eeca4 JW |
7290 | { |
7291 | dr = &md.in; | |
7292 | name += 2; | |
7293 | } | |
7294 | break; | |
7295 | ||
7296 | case 'l': | |
3882b010 | 7297 | if (name[1] == 'o' && name[2] == 'c' && ISDIGIT (name[3])) |
800eeca4 JW |
7298 | { |
7299 | dr = &md.loc; | |
7300 | name += 3; | |
7301 | } | |
7302 | break; | |
7303 | ||
7304 | case 'o': | |
3882b010 | 7305 | if (name[1] == 'u' && name[2] == 't' && ISDIGIT (name[3])) |
800eeca4 JW |
7306 | { |
7307 | dr = &md.out; | |
7308 | name += 3; | |
7309 | } | |
7310 | break; | |
7311 | ||
7312 | default: | |
7313 | break; | |
7314 | } | |
7315 | ||
7316 | if (dr) | |
7317 | { | |
542d6675 | 7318 | /* The name is inN, locN, or outN; parse the register number. */ |
800eeca4 JW |
7319 | regnum = strtoul (name, &end, 10); |
7320 | if (end > name && *end == '\0') | |
7321 | { | |
7322 | if ((unsigned) regnum >= dr->num_regs) | |
7323 | { | |
7324 | if (!dr->num_regs) | |
7325 | as_bad ("No current frame"); | |
7326 | else | |
542d6675 KH |
7327 | as_bad ("Register number out of range 0..%u", |
7328 | dr->num_regs - 1); | |
800eeca4 JW |
7329 | regnum = 0; |
7330 | } | |
7331 | e->X_op = O_register; | |
7332 | e->X_add_number = dr->base + regnum; | |
7333 | return 1; | |
7334 | } | |
7335 | } | |
7336 | ||
7337 | if ((dr = hash_find (md.dynreg_hash, name))) | |
7338 | { | |
7339 | /* We've got ourselves the name of a rotating register set. | |
542d6675 KH |
7340 | Store the base register number in the low 16 bits of |
7341 | X_add_number and the size of the register set in the top 16 | |
7342 | bits. */ | |
800eeca4 JW |
7343 | e->X_op = O_register; |
7344 | e->X_add_number = dr->base | (dr->num_regs << 16); | |
7345 | return 1; | |
7346 | } | |
7347 | return 0; | |
7348 | } | |
7349 | ||
7350 | /* Remove the '#' suffix that indicates a symbol as opposed to a register. */ | |
7351 | ||
7352 | char * | |
7353 | ia64_canonicalize_symbol_name (name) | |
7354 | char *name; | |
7355 | { | |
542d6675 KH |
7356 | size_t len = strlen (name); |
7357 | if (len > 1 && name[len - 1] == '#') | |
7358 | name[len - 1] = '\0'; | |
800eeca4 JW |
7359 | return name; |
7360 | } | |
7361 | ||
3e37788f JW |
7362 | /* Return true if idesc is a conditional branch instruction. This excludes |
7363 | the modulo scheduled branches, and br.ia. Mod-sched branches are excluded | |
7364 | because they always read/write resources regardless of the value of the | |
7365 | qualifying predicate. br.ia must always use p0, and hence is always | |
7366 | taken. Thus this function returns true for branches which can fall | |
7367 | through, and which use no resources if they do fall through. */ | |
1deb8127 | 7368 | |
800eeca4 JW |
7369 | static int |
7370 | is_conditional_branch (idesc) | |
542d6675 | 7371 | struct ia64_opcode *idesc; |
800eeca4 | 7372 | { |
1deb8127 | 7373 | /* br is a conditional branch. Everything that starts with br. except |
3e37788f JW |
7374 | br.ia, br.c{loop,top,exit}, and br.w{top,exit} is a conditional branch. |
7375 | Everything that starts with brl is a conditional branch. */ | |
1deb8127 JW |
7376 | return (idesc->name[0] == 'b' && idesc->name[1] == 'r' |
7377 | && (idesc->name[2] == '\0' | |
3e37788f JW |
7378 | || (idesc->name[2] == '.' && idesc->name[3] != 'i' |
7379 | && idesc->name[3] != 'c' && idesc->name[3] != 'w') | |
7380 | || idesc->name[2] == 'l' | |
7381 | /* br.cond, br.call, br.clr */ | |
7382 | || (idesc->name[2] == '.' && idesc->name[3] == 'c' | |
7383 | && (idesc->name[4] == 'a' || idesc->name[4] == 'o' | |
7384 | || (idesc->name[4] == 'l' && idesc->name[5] == 'r'))))); | |
800eeca4 JW |
7385 | } |
7386 | ||
7387 | /* Return whether the given opcode is a taken branch. If there's any doubt, | |
542d6675 KH |
7388 | returns zero. */ |
7389 | ||
800eeca4 JW |
7390 | static int |
7391 | is_taken_branch (idesc) | |
542d6675 | 7392 | struct ia64_opcode *idesc; |
800eeca4 JW |
7393 | { |
7394 | return ((is_conditional_branch (idesc) && CURR_SLOT.qp_regno == 0) | |
542d6675 | 7395 | || strncmp (idesc->name, "br.ia", 5) == 0); |
800eeca4 JW |
7396 | } |
7397 | ||
7398 | /* Return whether the given opcode is an interruption or rfi. If there's any | |
542d6675 KH |
7399 | doubt, returns zero. */ |
7400 | ||
800eeca4 JW |
7401 | static int |
7402 | is_interruption_or_rfi (idesc) | |
542d6675 | 7403 | struct ia64_opcode *idesc; |
800eeca4 JW |
7404 | { |
7405 | if (strcmp (idesc->name, "rfi") == 0) | |
7406 | return 1; | |
7407 | return 0; | |
7408 | } | |
7409 | ||
7410 | /* Returns the index of the given dependency in the opcode's list of chks, or | |
7411 | -1 if there is no dependency. */ | |
542d6675 | 7412 | |
800eeca4 JW |
7413 | static int |
7414 | depends_on (depind, idesc) | |
542d6675 KH |
7415 | int depind; |
7416 | struct ia64_opcode *idesc; | |
800eeca4 JW |
7417 | { |
7418 | int i; | |
7419 | const struct ia64_opcode_dependency *dep = idesc->dependencies; | |
542d6675 | 7420 | for (i = 0; i < dep->nchks; i++) |
800eeca4 | 7421 | { |
542d6675 KH |
7422 | if (depind == DEP (dep->chks[i])) |
7423 | return i; | |
800eeca4 JW |
7424 | } |
7425 | return -1; | |
7426 | } | |
7427 | ||
7428 | /* Determine a set of specific resources used for a particular resource | |
7429 | class. Returns the number of specific resources identified For those | |
7430 | cases which are not determinable statically, the resource returned is | |
197865e8 | 7431 | marked nonspecific. |
800eeca4 JW |
7432 | |
7433 | Meanings of value in 'NOTE': | |
7434 | 1) only read/write when the register number is explicitly encoded in the | |
7435 | insn. | |
7436 | 2) only read CFM when accessing a rotating GR, FR, or PR. mov pr only | |
197865e8 | 7437 | accesses CFM when qualifying predicate is in the rotating region. |
800eeca4 JW |
7438 | 3) general register value is used to specify an indirect register; not |
7439 | determinable statically. | |
7440 | 4) only read the given resource when bits 7:0 of the indirect index | |
7441 | register value does not match the register number of the resource; not | |
7442 | determinable statically. | |
7443 | 5) all rules are implementation specific. | |
7444 | 6) only when both the index specified by the reader and the index specified | |
7445 | by the writer have the same value in bits 63:61; not determinable | |
197865e8 | 7446 | statically. |
800eeca4 | 7447 | 7) only access the specified resource when the corresponding mask bit is |
197865e8 | 7448 | set |
800eeca4 JW |
7449 | 8) PSR.dfh is only read when these insns reference FR32-127. PSR.dfl is |
7450 | only read when these insns reference FR2-31 | |
7451 | 9) PSR.mfl is only written when these insns write FR2-31. PSR.mfh is only | |
7452 | written when these insns write FR32-127 | |
7453 | 10) The PSR.bn bit is only accessed when one of GR16-31 is specified in the | |
7454 | instruction | |
7455 | 11) The target predicates are written independently of PR[qp], but source | |
7456 | registers are only read if PR[qp] is true. Since the state of PR[qp] | |
7457 | cannot statically be determined, all source registers are marked used. | |
7458 | 12) This insn only reads the specified predicate register when that | |
7459 | register is the PR[qp]. | |
7460 | 13) This reference to ld-c only applies to teh GR whose value is loaded | |
197865e8 | 7461 | with data returned from memory, not the post-incremented address register. |
800eeca4 JW |
7462 | 14) The RSE resource includes the implementation-specific RSE internal |
7463 | state resources. At least one (and possibly more) of these resources are | |
7464 | read by each instruction listed in IC:rse-readers. At least one (and | |
7465 | possibly more) of these resources are written by each insn listed in | |
197865e8 | 7466 | IC:rse-writers. |
800eeca4 | 7467 | 15+16) Represents reserved instructions, which the assembler does not |
197865e8 | 7468 | generate. |
800eeca4 JW |
7469 | |
7470 | Memory resources (i.e. locations in memory) are *not* marked or tracked by | |
7471 | this code; there are no dependency violations based on memory access. | |
800eeca4 JW |
7472 | */ |
7473 | ||
7474 | #define MAX_SPECS 256 | |
7475 | #define DV_CHK 1 | |
7476 | #define DV_REG 0 | |
7477 | ||
7478 | static int | |
7479 | specify_resource (dep, idesc, type, specs, note, path) | |
542d6675 KH |
7480 | const struct ia64_dependency *dep; |
7481 | struct ia64_opcode *idesc; | |
7482 | int type; /* is this a DV chk or a DV reg? */ | |
7483 | struct rsrc specs[MAX_SPECS]; /* returned specific resources */ | |
7484 | int note; /* resource note for this insn's usage */ | |
7485 | int path; /* which execution path to examine */ | |
800eeca4 JW |
7486 | { |
7487 | int count = 0; | |
7488 | int i; | |
7489 | int rsrc_write = 0; | |
7490 | struct rsrc tmpl; | |
197865e8 | 7491 | |
800eeca4 JW |
7492 | if (dep->mode == IA64_DV_WAW |
7493 | || (dep->mode == IA64_DV_RAW && type == DV_REG) | |
7494 | || (dep->mode == IA64_DV_WAR && type == DV_CHK)) | |
7495 | rsrc_write = 1; | |
7496 | ||
7497 | /* template for any resources we identify */ | |
7498 | tmpl.dependency = dep; | |
7499 | tmpl.note = note; | |
7500 | tmpl.insn_srlz = tmpl.data_srlz = 0; | |
7501 | tmpl.qp_regno = CURR_SLOT.qp_regno; | |
7502 | tmpl.link_to_qp_branch = 1; | |
7503 | tmpl.mem_offset.hint = 0; | |
7504 | tmpl.specific = 1; | |
7505 | tmpl.index = 0; | |
7484b8e6 | 7506 | tmpl.cmp_type = CMP_NONE; |
800eeca4 JW |
7507 | |
7508 | #define UNHANDLED \ | |
7509 | as_warn (_("Unhandled dependency %s for %s (%s), note %d"), \ | |
7510 | dep->name, idesc->name, (rsrc_write?"write":"read"), note) | |
7511 | #define KNOWN(REG) (gr_values[REG].known && gr_values[REG].path >= path) | |
7512 | ||
7513 | /* we don't need to track these */ | |
7514 | if (dep->semantics == IA64_DVS_NONE) | |
7515 | return 0; | |
7516 | ||
7517 | switch (dep->specifier) | |
7518 | { | |
7519 | case IA64_RS_AR_K: | |
7520 | if (note == 1) | |
542d6675 KH |
7521 | { |
7522 | if (idesc->operands[!rsrc_write] == IA64_OPND_AR3) | |
7523 | { | |
7524 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_AR; | |
7525 | if (regno >= 0 && regno <= 7) | |
7526 | { | |
7527 | specs[count] = tmpl; | |
7528 | specs[count++].index = regno; | |
7529 | } | |
7530 | } | |
7531 | } | |
800eeca4 | 7532 | else if (note == 0) |
542d6675 KH |
7533 | { |
7534 | for (i = 0; i < 8; i++) | |
7535 | { | |
7536 | specs[count] = tmpl; | |
7537 | specs[count++].index = i; | |
7538 | } | |
7539 | } | |
800eeca4 | 7540 | else |
542d6675 KH |
7541 | { |
7542 | UNHANDLED; | |
7543 | } | |
800eeca4 JW |
7544 | break; |
7545 | ||
7546 | case IA64_RS_AR_UNAT: | |
7547 | /* This is a mov =AR or mov AR= instruction. */ | |
7548 | if (idesc->operands[!rsrc_write] == IA64_OPND_AR3) | |
7549 | { | |
7550 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_AR; | |
7551 | if (regno == AR_UNAT) | |
7552 | { | |
7553 | specs[count++] = tmpl; | |
7554 | } | |
7555 | } | |
7556 | else | |
7557 | { | |
7558 | /* This is a spill/fill, or other instruction that modifies the | |
7559 | unat register. */ | |
7560 | ||
7561 | /* Unless we can determine the specific bits used, mark the whole | |
7562 | thing; bits 8:3 of the memory address indicate the bit used in | |
7563 | UNAT. The .mem.offset hint may be used to eliminate a small | |
7564 | subset of conflicts. */ | |
7565 | specs[count] = tmpl; | |
7566 | if (md.mem_offset.hint) | |
7567 | { | |
542d6675 KH |
7568 | if (md.debug_dv) |
7569 | fprintf (stderr, " Using hint for spill/fill\n"); | |
7570 | /* The index isn't actually used, just set it to something | |
7571 | approximating the bit index. */ | |
800eeca4 JW |
7572 | specs[count].index = (md.mem_offset.offset >> 3) & 0x3F; |
7573 | specs[count].mem_offset.hint = 1; | |
7574 | specs[count].mem_offset.offset = md.mem_offset.offset; | |
7575 | specs[count++].mem_offset.base = md.mem_offset.base; | |
7576 | } | |
7577 | else | |
7578 | { | |
7579 | specs[count++].specific = 0; | |
7580 | } | |
7581 | } | |
7582 | break; | |
7583 | ||
7584 | case IA64_RS_AR: | |
7585 | if (note == 1) | |
542d6675 KH |
7586 | { |
7587 | if (idesc->operands[!rsrc_write] == IA64_OPND_AR3) | |
7588 | { | |
7589 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_AR; | |
7590 | if ((regno >= 8 && regno <= 15) | |
7591 | || (regno >= 20 && regno <= 23) | |
7592 | || (regno >= 31 && regno <= 39) | |
7593 | || (regno >= 41 && regno <= 47) | |
7594 | || (regno >= 67 && regno <= 111)) | |
7595 | { | |
7596 | specs[count] = tmpl; | |
7597 | specs[count++].index = regno; | |
7598 | } | |
7599 | } | |
7600 | } | |
800eeca4 | 7601 | else |
542d6675 KH |
7602 | { |
7603 | UNHANDLED; | |
7604 | } | |
800eeca4 JW |
7605 | break; |
7606 | ||
7607 | case IA64_RS_ARb: | |
7608 | if (note == 1) | |
542d6675 KH |
7609 | { |
7610 | if (idesc->operands[!rsrc_write] == IA64_OPND_AR3) | |
7611 | { | |
7612 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_AR; | |
7613 | if ((regno >= 48 && regno <= 63) | |
7614 | || (regno >= 112 && regno <= 127)) | |
7615 | { | |
7616 | specs[count] = tmpl; | |
7617 | specs[count++].index = regno; | |
7618 | } | |
7619 | } | |
7620 | } | |
800eeca4 | 7621 | else if (note == 0) |
542d6675 KH |
7622 | { |
7623 | for (i = 48; i < 64; i++) | |
7624 | { | |
7625 | specs[count] = tmpl; | |
7626 | specs[count++].index = i; | |
7627 | } | |
7628 | for (i = 112; i < 128; i++) | |
7629 | { | |
7630 | specs[count] = tmpl; | |
7631 | specs[count++].index = i; | |
7632 | } | |
7633 | } | |
197865e8 | 7634 | else |
542d6675 KH |
7635 | { |
7636 | UNHANDLED; | |
7637 | } | |
800eeca4 JW |
7638 | break; |
7639 | ||
7640 | case IA64_RS_BR: | |
7641 | if (note != 1) | |
542d6675 KH |
7642 | { |
7643 | UNHANDLED; | |
7644 | } | |
800eeca4 | 7645 | else |
542d6675 KH |
7646 | { |
7647 | if (rsrc_write) | |
7648 | { | |
7649 | for (i = 0; i < idesc->num_outputs; i++) | |
7650 | if (idesc->operands[i] == IA64_OPND_B1 | |
7651 | || idesc->operands[i] == IA64_OPND_B2) | |
7652 | { | |
7653 | specs[count] = tmpl; | |
7654 | specs[count++].index = | |
7655 | CURR_SLOT.opnd[i].X_add_number - REG_BR; | |
7656 | } | |
7657 | } | |
7658 | else | |
7659 | { | |
40449e9f | 7660 | for (i = idesc->num_outputs; i < NELEMS (idesc->operands); i++) |
542d6675 KH |
7661 | if (idesc->operands[i] == IA64_OPND_B1 |
7662 | || idesc->operands[i] == IA64_OPND_B2) | |
7663 | { | |
7664 | specs[count] = tmpl; | |
7665 | specs[count++].index = | |
7666 | CURR_SLOT.opnd[i].X_add_number - REG_BR; | |
7667 | } | |
7668 | } | |
7669 | } | |
800eeca4 JW |
7670 | break; |
7671 | ||
7672 | case IA64_RS_CPUID: /* four or more registers */ | |
7673 | if (note == 3) | |
542d6675 KH |
7674 | { |
7675 | if (idesc->operands[!rsrc_write] == IA64_OPND_CPUID_R3) | |
7676 | { | |
7677 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_GR; | |
7678 | if (regno >= 0 && regno < NELEMS (gr_values) | |
7679 | && KNOWN (regno)) | |
7680 | { | |
7681 | specs[count] = tmpl; | |
7682 | specs[count++].index = gr_values[regno].value & 0xFF; | |
7683 | } | |
7684 | else | |
7685 | { | |
7686 | specs[count] = tmpl; | |
7687 | specs[count++].specific = 0; | |
7688 | } | |
7689 | } | |
7690 | } | |
800eeca4 | 7691 | else |
542d6675 KH |
7692 | { |
7693 | UNHANDLED; | |
7694 | } | |
800eeca4 JW |
7695 | break; |
7696 | ||
7697 | case IA64_RS_DBR: /* four or more registers */ | |
7698 | if (note == 3) | |
542d6675 KH |
7699 | { |
7700 | if (idesc->operands[!rsrc_write] == IA64_OPND_DBR_R3) | |
7701 | { | |
7702 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_GR; | |
7703 | if (regno >= 0 && regno < NELEMS (gr_values) | |
7704 | && KNOWN (regno)) | |
7705 | { | |
7706 | specs[count] = tmpl; | |
7707 | specs[count++].index = gr_values[regno].value & 0xFF; | |
7708 | } | |
7709 | else | |
7710 | { | |
7711 | specs[count] = tmpl; | |
7712 | specs[count++].specific = 0; | |
7713 | } | |
7714 | } | |
7715 | } | |
800eeca4 | 7716 | else if (note == 0 && !rsrc_write) |
542d6675 KH |
7717 | { |
7718 | specs[count] = tmpl; | |
7719 | specs[count++].specific = 0; | |
7720 | } | |
800eeca4 | 7721 | else |
542d6675 KH |
7722 | { |
7723 | UNHANDLED; | |
7724 | } | |
800eeca4 JW |
7725 | break; |
7726 | ||
7727 | case IA64_RS_IBR: /* four or more registers */ | |
7728 | if (note == 3) | |
542d6675 KH |
7729 | { |
7730 | if (idesc->operands[!rsrc_write] == IA64_OPND_IBR_R3) | |
7731 | { | |
7732 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_GR; | |
7733 | if (regno >= 0 && regno < NELEMS (gr_values) | |
7734 | && KNOWN (regno)) | |
7735 | { | |
7736 | specs[count] = tmpl; | |
7737 | specs[count++].index = gr_values[regno].value & 0xFF; | |
7738 | } | |
7739 | else | |
7740 | { | |
7741 | specs[count] = tmpl; | |
7742 | specs[count++].specific = 0; | |
7743 | } | |
7744 | } | |
7745 | } | |
800eeca4 | 7746 | else |
542d6675 KH |
7747 | { |
7748 | UNHANDLED; | |
7749 | } | |
800eeca4 JW |
7750 | break; |
7751 | ||
7752 | case IA64_RS_MSR: | |
7753 | if (note == 5) | |
7754 | { | |
7755 | /* These are implementation specific. Force all references to | |
7756 | conflict with all other references. */ | |
7757 | specs[count] = tmpl; | |
7758 | specs[count++].specific = 0; | |
7759 | } | |
7760 | else | |
7761 | { | |
7762 | UNHANDLED; | |
7763 | } | |
7764 | break; | |
7765 | ||
7766 | case IA64_RS_PKR: /* 16 or more registers */ | |
7767 | if (note == 3 || note == 4) | |
542d6675 KH |
7768 | { |
7769 | if (idesc->operands[!rsrc_write] == IA64_OPND_PKR_R3) | |
7770 | { | |
7771 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_GR; | |
7772 | if (regno >= 0 && regno < NELEMS (gr_values) | |
7773 | && KNOWN (regno)) | |
7774 | { | |
7775 | if (note == 3) | |
7776 | { | |
7777 | specs[count] = tmpl; | |
7778 | specs[count++].index = gr_values[regno].value & 0xFF; | |
7779 | } | |
7780 | else | |
7781 | for (i = 0; i < NELEMS (gr_values); i++) | |
7782 | { | |
7783 | /* Uses all registers *except* the one in R3. */ | |
2434f565 | 7784 | if ((unsigned)i != (gr_values[regno].value & 0xFF)) |
542d6675 KH |
7785 | { |
7786 | specs[count] = tmpl; | |
7787 | specs[count++].index = i; | |
7788 | } | |
7789 | } | |
7790 | } | |
7791 | else | |
7792 | { | |
7793 | specs[count] = tmpl; | |
7794 | specs[count++].specific = 0; | |
7795 | } | |
7796 | } | |
7797 | } | |
7798 | else if (note == 0) | |
7799 | { | |
7800 | /* probe et al. */ | |
7801 | specs[count] = tmpl; | |
7802 | specs[count++].specific = 0; | |
7803 | } | |
7804 | break; | |
7805 | ||
7806 | case IA64_RS_PMC: /* four or more registers */ | |
7807 | if (note == 3) | |
7808 | { | |
7809 | if (idesc->operands[!rsrc_write] == IA64_OPND_PMC_R3 | |
7810 | || (!rsrc_write && idesc->operands[1] == IA64_OPND_PMD_R3)) | |
7811 | ||
7812 | { | |
7813 | int index = ((idesc->operands[1] == IA64_OPND_R3 && !rsrc_write) | |
7814 | ? 1 : !rsrc_write); | |
7815 | int regno = CURR_SLOT.opnd[index].X_add_number - REG_GR; | |
7816 | if (regno >= 0 && regno < NELEMS (gr_values) | |
7817 | && KNOWN (regno)) | |
7818 | { | |
7819 | specs[count] = tmpl; | |
7820 | specs[count++].index = gr_values[regno].value & 0xFF; | |
7821 | } | |
7822 | else | |
7823 | { | |
7824 | specs[count] = tmpl; | |
7825 | specs[count++].specific = 0; | |
7826 | } | |
7827 | } | |
7828 | } | |
7829 | else | |
7830 | { | |
7831 | UNHANDLED; | |
7832 | } | |
800eeca4 JW |
7833 | break; |
7834 | ||
7835 | case IA64_RS_PMD: /* four or more registers */ | |
7836 | if (note == 3) | |
542d6675 KH |
7837 | { |
7838 | if (idesc->operands[!rsrc_write] == IA64_OPND_PMD_R3) | |
7839 | { | |
7840 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_GR; | |
7841 | if (regno >= 0 && regno < NELEMS (gr_values) | |
7842 | && KNOWN (regno)) | |
7843 | { | |
7844 | specs[count] = tmpl; | |
7845 | specs[count++].index = gr_values[regno].value & 0xFF; | |
7846 | } | |
7847 | else | |
7848 | { | |
7849 | specs[count] = tmpl; | |
7850 | specs[count++].specific = 0; | |
7851 | } | |
7852 | } | |
7853 | } | |
800eeca4 | 7854 | else |
542d6675 KH |
7855 | { |
7856 | UNHANDLED; | |
7857 | } | |
800eeca4 JW |
7858 | break; |
7859 | ||
7860 | case IA64_RS_RR: /* eight registers */ | |
7861 | if (note == 6) | |
542d6675 KH |
7862 | { |
7863 | if (idesc->operands[!rsrc_write] == IA64_OPND_RR_R3) | |
7864 | { | |
7865 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_GR; | |
7866 | if (regno >= 0 && regno < NELEMS (gr_values) | |
7867 | && KNOWN (regno)) | |
7868 | { | |
7869 | specs[count] = tmpl; | |
7870 | specs[count++].index = (gr_values[regno].value >> 61) & 0x7; | |
7871 | } | |
7872 | else | |
7873 | { | |
7874 | specs[count] = tmpl; | |
7875 | specs[count++].specific = 0; | |
7876 | } | |
7877 | } | |
7878 | } | |
800eeca4 | 7879 | else if (note == 0 && !rsrc_write) |
542d6675 KH |
7880 | { |
7881 | specs[count] = tmpl; | |
7882 | specs[count++].specific = 0; | |
7883 | } | |
197865e8 | 7884 | else |
542d6675 KH |
7885 | { |
7886 | UNHANDLED; | |
7887 | } | |
800eeca4 JW |
7888 | break; |
7889 | ||
7890 | case IA64_RS_CR_IRR: | |
197865e8 | 7891 | if (note == 0) |
542d6675 KH |
7892 | { |
7893 | /* handle mov-from-CR-IVR; it's a read that writes CR[IRR] */ | |
7894 | int regno = CURR_SLOT.opnd[1].X_add_number - REG_CR; | |
7895 | if (rsrc_write | |
7896 | && idesc->operands[1] == IA64_OPND_CR3 | |
7897 | && regno == CR_IVR) | |
7898 | { | |
7899 | for (i = 0; i < 4; i++) | |
7900 | { | |
7901 | specs[count] = tmpl; | |
7902 | specs[count++].index = CR_IRR0 + i; | |
7903 | } | |
7904 | } | |
7905 | } | |
800eeca4 | 7906 | else if (note == 1) |
542d6675 KH |
7907 | { |
7908 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_CR; | |
7909 | if (idesc->operands[!rsrc_write] == IA64_OPND_CR3 | |
7910 | && regno >= CR_IRR0 | |
7911 | && regno <= CR_IRR3) | |
7912 | { | |
7913 | specs[count] = tmpl; | |
7914 | specs[count++].index = regno; | |
7915 | } | |
7916 | } | |
800eeca4 | 7917 | else |
542d6675 KH |
7918 | { |
7919 | UNHANDLED; | |
7920 | } | |
800eeca4 JW |
7921 | break; |
7922 | ||
7923 | case IA64_RS_CR_LRR: | |
7924 | if (note != 1) | |
542d6675 KH |
7925 | { |
7926 | UNHANDLED; | |
7927 | } | |
197865e8 | 7928 | else |
542d6675 KH |
7929 | { |
7930 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_CR; | |
7931 | if (idesc->operands[!rsrc_write] == IA64_OPND_CR3 | |
7932 | && (regno == CR_LRR0 || regno == CR_LRR1)) | |
7933 | { | |
7934 | specs[count] = tmpl; | |
7935 | specs[count++].index = regno; | |
7936 | } | |
7937 | } | |
800eeca4 JW |
7938 | break; |
7939 | ||
7940 | case IA64_RS_CR: | |
7941 | if (note == 1) | |
542d6675 KH |
7942 | { |
7943 | if (idesc->operands[!rsrc_write] == IA64_OPND_CR3) | |
7944 | { | |
7945 | specs[count] = tmpl; | |
7946 | specs[count++].index = | |
7947 | CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_CR; | |
7948 | } | |
7949 | } | |
800eeca4 | 7950 | else |
542d6675 KH |
7951 | { |
7952 | UNHANDLED; | |
7953 | } | |
800eeca4 JW |
7954 | break; |
7955 | ||
7956 | case IA64_RS_FR: | |
7957 | case IA64_RS_FRb: | |
7958 | if (note != 1) | |
542d6675 KH |
7959 | { |
7960 | UNHANDLED; | |
7961 | } | |
800eeca4 | 7962 | else if (rsrc_write) |
542d6675 KH |
7963 | { |
7964 | if (dep->specifier == IA64_RS_FRb | |
7965 | && idesc->operands[0] == IA64_OPND_F1) | |
7966 | { | |
7967 | specs[count] = tmpl; | |
7968 | specs[count++].index = CURR_SLOT.opnd[0].X_add_number - REG_FR; | |
7969 | } | |
7970 | } | |
800eeca4 | 7971 | else |
542d6675 KH |
7972 | { |
7973 | for (i = idesc->num_outputs; i < NELEMS (idesc->operands); i++) | |
7974 | { | |
7975 | if (idesc->operands[i] == IA64_OPND_F2 | |
7976 | || idesc->operands[i] == IA64_OPND_F3 | |
7977 | || idesc->operands[i] == IA64_OPND_F4) | |
7978 | { | |
7979 | specs[count] = tmpl; | |
7980 | specs[count++].index = | |
7981 | CURR_SLOT.opnd[i].X_add_number - REG_FR; | |
7982 | } | |
7983 | } | |
7984 | } | |
800eeca4 JW |
7985 | break; |
7986 | ||
7987 | case IA64_RS_GR: | |
7988 | if (note == 13) | |
542d6675 KH |
7989 | { |
7990 | /* This reference applies only to the GR whose value is loaded with | |
7991 | data returned from memory. */ | |
7992 | specs[count] = tmpl; | |
7993 | specs[count++].index = CURR_SLOT.opnd[0].X_add_number - REG_GR; | |
7994 | } | |
800eeca4 | 7995 | else if (note == 1) |
542d6675 KH |
7996 | { |
7997 | if (rsrc_write) | |
7998 | { | |
7999 | for (i = 0; i < idesc->num_outputs; i++) | |
50b81f19 JW |
8000 | if (idesc->operands[i] == IA64_OPND_R1 |
8001 | || idesc->operands[i] == IA64_OPND_R2 | |
8002 | || idesc->operands[i] == IA64_OPND_R3) | |
8003 | { | |
8004 | specs[count] = tmpl; | |
197865e8 | 8005 | specs[count++].index = |
50b81f19 JW |
8006 | CURR_SLOT.opnd[i].X_add_number - REG_GR; |
8007 | } | |
8008 | if (idesc->flags & IA64_OPCODE_POSTINC) | |
8009 | for (i = 0; i < NELEMS (idesc->operands); i++) | |
8010 | if (idesc->operands[i] == IA64_OPND_MR3) | |
8011 | { | |
8012 | specs[count] = tmpl; | |
8013 | specs[count++].index = | |
8014 | CURR_SLOT.opnd[i].X_add_number - REG_GR; | |
8015 | } | |
542d6675 KH |
8016 | } |
8017 | else | |
8018 | { | |
8019 | /* Look for anything that reads a GR. */ | |
8020 | for (i = 0; i < NELEMS (idesc->operands); i++) | |
8021 | { | |
8022 | if (idesc->operands[i] == IA64_OPND_MR3 | |
8023 | || idesc->operands[i] == IA64_OPND_CPUID_R3 | |
8024 | || idesc->operands[i] == IA64_OPND_DBR_R3 | |
8025 | || idesc->operands[i] == IA64_OPND_IBR_R3 | |
800eeca4 | 8026 | || idesc->operands[i] == IA64_OPND_MSR_R3 |
542d6675 KH |
8027 | || idesc->operands[i] == IA64_OPND_PKR_R3 |
8028 | || idesc->operands[i] == IA64_OPND_PMC_R3 | |
8029 | || idesc->operands[i] == IA64_OPND_PMD_R3 | |
8030 | || idesc->operands[i] == IA64_OPND_RR_R3 | |
8031 | || ((i >= idesc->num_outputs) | |
8032 | && (idesc->operands[i] == IA64_OPND_R1 | |
8033 | || idesc->operands[i] == IA64_OPND_R2 | |
8034 | || idesc->operands[i] == IA64_OPND_R3 | |
50b81f19 JW |
8035 | /* addl source register. */ |
8036 | || idesc->operands[i] == IA64_OPND_R3_2))) | |
542d6675 KH |
8037 | { |
8038 | specs[count] = tmpl; | |
8039 | specs[count++].index = | |
8040 | CURR_SLOT.opnd[i].X_add_number - REG_GR; | |
8041 | } | |
8042 | } | |
8043 | } | |
8044 | } | |
197865e8 | 8045 | else |
542d6675 KH |
8046 | { |
8047 | UNHANDLED; | |
8048 | } | |
800eeca4 JW |
8049 | break; |
8050 | ||
139368c9 JW |
8051 | /* This is the same as IA64_RS_PRr, except that the register range is |
8052 | from 1 - 15, and there are no rotating register reads/writes here. */ | |
800eeca4 JW |
8053 | case IA64_RS_PR: |
8054 | if (note == 0) | |
542d6675 | 8055 | { |
139368c9 | 8056 | for (i = 1; i < 16; i++) |
542d6675 | 8057 | { |
139368c9 JW |
8058 | specs[count] = tmpl; |
8059 | specs[count++].index = i; | |
8060 | } | |
8061 | } | |
8062 | else if (note == 7) | |
8063 | { | |
8064 | valueT mask = 0; | |
8065 | /* Mark only those registers indicated by the mask. */ | |
8066 | if (rsrc_write) | |
8067 | { | |
8068 | mask = CURR_SLOT.opnd[2].X_add_number; | |
8069 | for (i = 1; i < 16; i++) | |
8070 | if (mask & ((valueT) 1 << i)) | |
8071 | { | |
8072 | specs[count] = tmpl; | |
8073 | specs[count++].index = i; | |
8074 | } | |
8075 | } | |
8076 | else | |
8077 | { | |
8078 | UNHANDLED; | |
8079 | } | |
8080 | } | |
8081 | else if (note == 11) /* note 11 implies note 1 as well */ | |
8082 | { | |
8083 | if (rsrc_write) | |
8084 | { | |
8085 | for (i = 0; i < idesc->num_outputs; i++) | |
8086 | { | |
8087 | if (idesc->operands[i] == IA64_OPND_P1 | |
8088 | || idesc->operands[i] == IA64_OPND_P2) | |
8089 | { | |
8090 | int regno = CURR_SLOT.opnd[i].X_add_number - REG_P; | |
8091 | if (regno >= 1 && regno < 16) | |
8092 | { | |
8093 | specs[count] = tmpl; | |
8094 | specs[count++].index = regno; | |
8095 | } | |
8096 | } | |
8097 | } | |
8098 | } | |
8099 | else | |
8100 | { | |
8101 | UNHANDLED; | |
8102 | } | |
8103 | } | |
8104 | else if (note == 12) | |
8105 | { | |
8106 | if (CURR_SLOT.qp_regno >= 1 && CURR_SLOT.qp_regno < 16) | |
8107 | { | |
8108 | specs[count] = tmpl; | |
8109 | specs[count++].index = CURR_SLOT.qp_regno; | |
8110 | } | |
8111 | } | |
8112 | else if (note == 1) | |
8113 | { | |
8114 | if (rsrc_write) | |
8115 | { | |
8116 | int p1 = CURR_SLOT.opnd[0].X_add_number - REG_P; | |
8117 | int p2 = CURR_SLOT.opnd[1].X_add_number - REG_P; | |
07726851 KH |
8118 | int or_andcm = strstr (idesc->name, "or.andcm") != NULL; |
8119 | int and_orcm = strstr (idesc->name, "and.orcm") != NULL; | |
139368c9 JW |
8120 | |
8121 | if ((idesc->operands[0] == IA64_OPND_P1 | |
8122 | || idesc->operands[0] == IA64_OPND_P2) | |
8123 | && p1 >= 1 && p1 < 16) | |
542d6675 KH |
8124 | { |
8125 | specs[count] = tmpl; | |
139368c9 JW |
8126 | specs[count].cmp_type = |
8127 | (or_andcm ? CMP_OR : (and_orcm ? CMP_AND : CMP_NONE)); | |
8128 | specs[count++].index = p1; | |
8129 | } | |
8130 | if ((idesc->operands[1] == IA64_OPND_P1 | |
8131 | || idesc->operands[1] == IA64_OPND_P2) | |
8132 | && p2 >= 1 && p2 < 16) | |
8133 | { | |
8134 | specs[count] = tmpl; | |
8135 | specs[count].cmp_type = | |
8136 | (or_andcm ? CMP_AND : (and_orcm ? CMP_OR : CMP_NONE)); | |
8137 | specs[count++].index = p2; | |
542d6675 KH |
8138 | } |
8139 | } | |
8140 | else | |
8141 | { | |
139368c9 | 8142 | if (CURR_SLOT.qp_regno >= 1 && CURR_SLOT.qp_regno < 16) |
542d6675 KH |
8143 | { |
8144 | specs[count] = tmpl; | |
139368c9 JW |
8145 | specs[count++].index = CURR_SLOT.qp_regno; |
8146 | } | |
8147 | if (idesc->operands[1] == IA64_OPND_PR) | |
8148 | { | |
8149 | for (i = 1; i < 16; i++) | |
8150 | { | |
8151 | specs[count] = tmpl; | |
8152 | specs[count++].index = i; | |
8153 | } | |
542d6675 KH |
8154 | } |
8155 | } | |
8156 | } | |
139368c9 JW |
8157 | else |
8158 | { | |
8159 | UNHANDLED; | |
8160 | } | |
8161 | break; | |
8162 | ||
8163 | /* This is the general case for PRs. IA64_RS_PR and IA64_RS_PR63 are | |
8164 | simplified cases of this. */ | |
8165 | case IA64_RS_PRr: | |
8166 | if (note == 0) | |
8167 | { | |
8168 | for (i = 16; i < 63; i++) | |
8169 | { | |
8170 | specs[count] = tmpl; | |
8171 | specs[count++].index = i; | |
8172 | } | |
8173 | } | |
800eeca4 | 8174 | else if (note == 7) |
542d6675 KH |
8175 | { |
8176 | valueT mask = 0; | |
8177 | /* Mark only those registers indicated by the mask. */ | |
8178 | if (rsrc_write | |
8179 | && idesc->operands[0] == IA64_OPND_PR) | |
8180 | { | |
8181 | mask = CURR_SLOT.opnd[2].X_add_number; | |
40449e9f | 8182 | if (mask & ((valueT) 1 << 16)) |
139368c9 JW |
8183 | for (i = 16; i < 63; i++) |
8184 | { | |
8185 | specs[count] = tmpl; | |
8186 | specs[count++].index = i; | |
8187 | } | |
542d6675 KH |
8188 | } |
8189 | else if (rsrc_write | |
8190 | && idesc->operands[0] == IA64_OPND_PR_ROT) | |
8191 | { | |
8192 | for (i = 16; i < 63; i++) | |
8193 | { | |
8194 | specs[count] = tmpl; | |
8195 | specs[count++].index = i; | |
8196 | } | |
8197 | } | |
8198 | else | |
8199 | { | |
8200 | UNHANDLED; | |
8201 | } | |
8202 | } | |
800eeca4 | 8203 | else if (note == 11) /* note 11 implies note 1 as well */ |
542d6675 KH |
8204 | { |
8205 | if (rsrc_write) | |
8206 | { | |
8207 | for (i = 0; i < idesc->num_outputs; i++) | |
8208 | { | |
8209 | if (idesc->operands[i] == IA64_OPND_P1 | |
8210 | || idesc->operands[i] == IA64_OPND_P2) | |
8211 | { | |
8212 | int regno = CURR_SLOT.opnd[i].X_add_number - REG_P; | |
139368c9 | 8213 | if (regno >= 16 && regno < 63) |
542d6675 KH |
8214 | { |
8215 | specs[count] = tmpl; | |
8216 | specs[count++].index = regno; | |
8217 | } | |
8218 | } | |
8219 | } | |
8220 | } | |
8221 | else | |
8222 | { | |
8223 | UNHANDLED; | |
8224 | } | |
8225 | } | |
800eeca4 | 8226 | else if (note == 12) |
542d6675 | 8227 | { |
139368c9 | 8228 | if (CURR_SLOT.qp_regno >= 16 && CURR_SLOT.qp_regno < 63) |
542d6675 KH |
8229 | { |
8230 | specs[count] = tmpl; | |
8231 | specs[count++].index = CURR_SLOT.qp_regno; | |
8232 | } | |
8233 | } | |
800eeca4 | 8234 | else if (note == 1) |
542d6675 KH |
8235 | { |
8236 | if (rsrc_write) | |
8237 | { | |
8238 | int p1 = CURR_SLOT.opnd[0].X_add_number - REG_P; | |
8239 | int p2 = CURR_SLOT.opnd[1].X_add_number - REG_P; | |
07726851 KH |
8240 | int or_andcm = strstr (idesc->name, "or.andcm") != NULL; |
8241 | int and_orcm = strstr (idesc->name, "and.orcm") != NULL; | |
7484b8e6 | 8242 | |
542d6675 KH |
8243 | if ((idesc->operands[0] == IA64_OPND_P1 |
8244 | || idesc->operands[0] == IA64_OPND_P2) | |
139368c9 | 8245 | && p1 >= 16 && p1 < 63) |
542d6675 KH |
8246 | { |
8247 | specs[count] = tmpl; | |
4a4f25cf | 8248 | specs[count].cmp_type = |
7484b8e6 | 8249 | (or_andcm ? CMP_OR : (and_orcm ? CMP_AND : CMP_NONE)); |
542d6675 KH |
8250 | specs[count++].index = p1; |
8251 | } | |
8252 | if ((idesc->operands[1] == IA64_OPND_P1 | |
8253 | || idesc->operands[1] == IA64_OPND_P2) | |
139368c9 | 8254 | && p2 >= 16 && p2 < 63) |
542d6675 KH |
8255 | { |
8256 | specs[count] = tmpl; | |
4a4f25cf | 8257 | specs[count].cmp_type = |
7484b8e6 | 8258 | (or_andcm ? CMP_AND : (and_orcm ? CMP_OR : CMP_NONE)); |
542d6675 KH |
8259 | specs[count++].index = p2; |
8260 | } | |
8261 | } | |
8262 | else | |
8263 | { | |
139368c9 | 8264 | if (CURR_SLOT.qp_regno >= 16 && CURR_SLOT.qp_regno < 63) |
542d6675 KH |
8265 | { |
8266 | specs[count] = tmpl; | |
8267 | specs[count++].index = CURR_SLOT.qp_regno; | |
8268 | } | |
8269 | if (idesc->operands[1] == IA64_OPND_PR) | |
8270 | { | |
139368c9 | 8271 | for (i = 16; i < 63; i++) |
542d6675 KH |
8272 | { |
8273 | specs[count] = tmpl; | |
8274 | specs[count++].index = i; | |
8275 | } | |
8276 | } | |
8277 | } | |
8278 | } | |
197865e8 | 8279 | else |
542d6675 KH |
8280 | { |
8281 | UNHANDLED; | |
8282 | } | |
800eeca4 JW |
8283 | break; |
8284 | ||
8285 | case IA64_RS_PSR: | |
197865e8 | 8286 | /* Verify that the instruction is using the PSR bit indicated in |
542d6675 | 8287 | dep->regindex. */ |
800eeca4 | 8288 | if (note == 0) |
542d6675 KH |
8289 | { |
8290 | if (idesc->operands[!rsrc_write] == IA64_OPND_PSR_UM) | |
8291 | { | |
8292 | if (dep->regindex < 6) | |
8293 | { | |
8294 | specs[count++] = tmpl; | |
8295 | } | |
8296 | } | |
8297 | else if (idesc->operands[!rsrc_write] == IA64_OPND_PSR) | |
8298 | { | |
8299 | if (dep->regindex < 32 | |
8300 | || dep->regindex == 35 | |
8301 | || dep->regindex == 36 | |
8302 | || (!rsrc_write && dep->regindex == PSR_CPL)) | |
8303 | { | |
8304 | specs[count++] = tmpl; | |
8305 | } | |
8306 | } | |
8307 | else if (idesc->operands[!rsrc_write] == IA64_OPND_PSR_L) | |
8308 | { | |
8309 | if (dep->regindex < 32 | |
8310 | || dep->regindex == 35 | |
8311 | || dep->regindex == 36 | |
8312 | || (rsrc_write && dep->regindex == PSR_CPL)) | |
8313 | { | |
8314 | specs[count++] = tmpl; | |
8315 | } | |
8316 | } | |
8317 | else | |
8318 | { | |
8319 | /* Several PSR bits have very specific dependencies. */ | |
8320 | switch (dep->regindex) | |
8321 | { | |
8322 | default: | |
8323 | specs[count++] = tmpl; | |
8324 | break; | |
8325 | case PSR_IC: | |
8326 | if (rsrc_write) | |
8327 | { | |
8328 | specs[count++] = tmpl; | |
8329 | } | |
8330 | else | |
8331 | { | |
8332 | /* Only certain CR accesses use PSR.ic */ | |
8333 | if (idesc->operands[0] == IA64_OPND_CR3 | |
8334 | || idesc->operands[1] == IA64_OPND_CR3) | |
8335 | { | |
8336 | int index = | |
8337 | ((idesc->operands[0] == IA64_OPND_CR3) | |
8338 | ? 0 : 1); | |
8339 | int regno = | |
8340 | CURR_SLOT.opnd[index].X_add_number - REG_CR; | |
8341 | ||
8342 | switch (regno) | |
8343 | { | |
8344 | default: | |
8345 | break; | |
8346 | case CR_ITIR: | |
8347 | case CR_IFS: | |
8348 | case CR_IIM: | |
8349 | case CR_IIP: | |
8350 | case CR_IPSR: | |
8351 | case CR_ISR: | |
8352 | case CR_IFA: | |
8353 | case CR_IHA: | |
8354 | case CR_IIPA: | |
8355 | specs[count++] = tmpl; | |
8356 | break; | |
8357 | } | |
8358 | } | |
8359 | } | |
8360 | break; | |
8361 | case PSR_CPL: | |
8362 | if (rsrc_write) | |
8363 | { | |
8364 | specs[count++] = tmpl; | |
8365 | } | |
8366 | else | |
8367 | { | |
8368 | /* Only some AR accesses use cpl */ | |
8369 | if (idesc->operands[0] == IA64_OPND_AR3 | |
8370 | || idesc->operands[1] == IA64_OPND_AR3) | |
8371 | { | |
8372 | int index = | |
8373 | ((idesc->operands[0] == IA64_OPND_AR3) | |
8374 | ? 0 : 1); | |
8375 | int regno = | |
8376 | CURR_SLOT.opnd[index].X_add_number - REG_AR; | |
8377 | ||
8378 | if (regno == AR_ITC | |
8379 | || (index == 0 | |
8380 | && (regno == AR_ITC | |
8381 | || regno == AR_RSC | |
8382 | || (regno >= AR_K0 | |
8383 | && regno <= AR_K7)))) | |
8384 | { | |
8385 | specs[count++] = tmpl; | |
8386 | } | |
8387 | } | |
8388 | else | |
8389 | { | |
8390 | specs[count++] = tmpl; | |
8391 | } | |
8392 | break; | |
8393 | } | |
8394 | } | |
8395 | } | |
8396 | } | |
800eeca4 | 8397 | else if (note == 7) |
542d6675 KH |
8398 | { |
8399 | valueT mask = 0; | |
8400 | if (idesc->operands[0] == IA64_OPND_IMMU24) | |
8401 | { | |
8402 | mask = CURR_SLOT.opnd[0].X_add_number; | |
8403 | } | |
8404 | else | |
8405 | { | |
8406 | UNHANDLED; | |
8407 | } | |
8408 | if (mask & ((valueT) 1 << dep->regindex)) | |
8409 | { | |
8410 | specs[count++] = tmpl; | |
8411 | } | |
8412 | } | |
800eeca4 | 8413 | else if (note == 8) |
542d6675 KH |
8414 | { |
8415 | int min = dep->regindex == PSR_DFL ? 2 : 32; | |
8416 | int max = dep->regindex == PSR_DFL ? 31 : 127; | |
8417 | /* dfh is read on FR32-127; dfl is read on FR2-31 */ | |
8418 | for (i = 0; i < NELEMS (idesc->operands); i++) | |
8419 | { | |
8420 | if (idesc->operands[i] == IA64_OPND_F1 | |
8421 | || idesc->operands[i] == IA64_OPND_F2 | |
8422 | || idesc->operands[i] == IA64_OPND_F3 | |
8423 | || idesc->operands[i] == IA64_OPND_F4) | |
8424 | { | |
8425 | int reg = CURR_SLOT.opnd[i].X_add_number - REG_FR; | |
8426 | if (reg >= min && reg <= max) | |
8427 | { | |
8428 | specs[count++] = tmpl; | |
8429 | } | |
8430 | } | |
8431 | } | |
8432 | } | |
800eeca4 | 8433 | else if (note == 9) |
542d6675 KH |
8434 | { |
8435 | int min = dep->regindex == PSR_MFL ? 2 : 32; | |
8436 | int max = dep->regindex == PSR_MFL ? 31 : 127; | |
8437 | /* mfh is read on writes to FR32-127; mfl is read on writes to | |
8438 | FR2-31 */ | |
8439 | for (i = 0; i < idesc->num_outputs; i++) | |
8440 | { | |
8441 | if (idesc->operands[i] == IA64_OPND_F1) | |
8442 | { | |
8443 | int reg = CURR_SLOT.opnd[i].X_add_number - REG_FR; | |
8444 | if (reg >= min && reg <= max) | |
8445 | { | |
8446 | specs[count++] = tmpl; | |
8447 | } | |
8448 | } | |
8449 | } | |
8450 | } | |
800eeca4 | 8451 | else if (note == 10) |
542d6675 KH |
8452 | { |
8453 | for (i = 0; i < NELEMS (idesc->operands); i++) | |
8454 | { | |
8455 | if (idesc->operands[i] == IA64_OPND_R1 | |
8456 | || idesc->operands[i] == IA64_OPND_R2 | |
8457 | || idesc->operands[i] == IA64_OPND_R3) | |
8458 | { | |
8459 | int regno = CURR_SLOT.opnd[i].X_add_number - REG_GR; | |
8460 | if (regno >= 16 && regno <= 31) | |
8461 | { | |
8462 | specs[count++] = tmpl; | |
8463 | } | |
8464 | } | |
8465 | } | |
8466 | } | |
800eeca4 | 8467 | else |
542d6675 KH |
8468 | { |
8469 | UNHANDLED; | |
8470 | } | |
800eeca4 JW |
8471 | break; |
8472 | ||
8473 | case IA64_RS_AR_FPSR: | |
8474 | if (idesc->operands[!rsrc_write] == IA64_OPND_AR3) | |
542d6675 KH |
8475 | { |
8476 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_AR; | |
8477 | if (regno == AR_FPSR) | |
8478 | { | |
8479 | specs[count++] = tmpl; | |
8480 | } | |
8481 | } | |
800eeca4 | 8482 | else |
542d6675 KH |
8483 | { |
8484 | specs[count++] = tmpl; | |
8485 | } | |
800eeca4 JW |
8486 | break; |
8487 | ||
197865e8 | 8488 | case IA64_RS_ARX: |
800eeca4 JW |
8489 | /* Handle all AR[REG] resources */ |
8490 | if (note == 0 || note == 1) | |
542d6675 KH |
8491 | { |
8492 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_AR; | |
8493 | if (idesc->operands[!rsrc_write] == IA64_OPND_AR3 | |
8494 | && regno == dep->regindex) | |
8495 | { | |
8496 | specs[count++] = tmpl; | |
8497 | } | |
8498 | /* other AR[REG] resources may be affected by AR accesses */ | |
8499 | else if (idesc->operands[0] == IA64_OPND_AR3) | |
8500 | { | |
8501 | /* AR[] writes */ | |
8502 | regno = CURR_SLOT.opnd[0].X_add_number - REG_AR; | |
8503 | switch (dep->regindex) | |
8504 | { | |
8505 | default: | |
8506 | break; | |
8507 | case AR_BSP: | |
8508 | case AR_RNAT: | |
8509 | if (regno == AR_BSPSTORE) | |
8510 | { | |
8511 | specs[count++] = tmpl; | |
8512 | } | |
8513 | case AR_RSC: | |
8514 | if (!rsrc_write && | |
8515 | (regno == AR_BSPSTORE | |
8516 | || regno == AR_RNAT)) | |
8517 | { | |
8518 | specs[count++] = tmpl; | |
8519 | } | |
8520 | break; | |
8521 | } | |
8522 | } | |
8523 | else if (idesc->operands[1] == IA64_OPND_AR3) | |
8524 | { | |
8525 | /* AR[] reads */ | |
8526 | regno = CURR_SLOT.opnd[1].X_add_number - REG_AR; | |
8527 | switch (dep->regindex) | |
8528 | { | |
8529 | default: | |
8530 | break; | |
8531 | case AR_RSC: | |
8532 | if (regno == AR_BSPSTORE || regno == AR_RNAT) | |
8533 | { | |
8534 | specs[count++] = tmpl; | |
8535 | } | |
8536 | break; | |
8537 | } | |
8538 | } | |
8539 | else | |
8540 | { | |
8541 | specs[count++] = tmpl; | |
8542 | } | |
8543 | } | |
800eeca4 | 8544 | else |
542d6675 KH |
8545 | { |
8546 | UNHANDLED; | |
8547 | } | |
800eeca4 JW |
8548 | break; |
8549 | ||
8550 | case IA64_RS_CRX: | |
8551 | /* Handle all CR[REG] resources */ | |
8552 | if (note == 0 || note == 1) | |
542d6675 KH |
8553 | { |
8554 | if (idesc->operands[!rsrc_write] == IA64_OPND_CR3) | |
8555 | { | |
8556 | int regno = CURR_SLOT.opnd[!rsrc_write].X_add_number - REG_CR; | |
8557 | if (regno == dep->regindex) | |
8558 | { | |
8559 | specs[count++] = tmpl; | |
8560 | } | |
8561 | else if (!rsrc_write) | |
8562 | { | |
8563 | /* Reads from CR[IVR] affect other resources. */ | |
8564 | if (regno == CR_IVR) | |
8565 | { | |
8566 | if ((dep->regindex >= CR_IRR0 | |
8567 | && dep->regindex <= CR_IRR3) | |
8568 | || dep->regindex == CR_TPR) | |
8569 | { | |
8570 | specs[count++] = tmpl; | |
8571 | } | |
8572 | } | |
8573 | } | |
8574 | } | |
8575 | else | |
8576 | { | |
8577 | specs[count++] = tmpl; | |
8578 | } | |
8579 | } | |
800eeca4 | 8580 | else |
542d6675 KH |
8581 | { |
8582 | UNHANDLED; | |
8583 | } | |
800eeca4 JW |
8584 | break; |
8585 | ||
8586 | case IA64_RS_INSERVICE: | |
8587 | /* look for write of EOI (67) or read of IVR (65) */ | |
8588 | if ((idesc->operands[0] == IA64_OPND_CR3 | |
542d6675 KH |
8589 | && CURR_SLOT.opnd[0].X_add_number - REG_CR == CR_EOI) |
8590 | || (idesc->operands[1] == IA64_OPND_CR3 | |
8591 | && CURR_SLOT.opnd[1].X_add_number - REG_CR == CR_IVR)) | |
8592 | { | |
8593 | specs[count++] = tmpl; | |
8594 | } | |
800eeca4 JW |
8595 | break; |
8596 | ||
8597 | case IA64_RS_GR0: | |
8598 | if (note == 1) | |
542d6675 KH |
8599 | { |
8600 | specs[count++] = tmpl; | |
8601 | } | |
800eeca4 | 8602 | else |
542d6675 KH |
8603 | { |
8604 | UNHANDLED; | |
8605 | } | |
800eeca4 JW |
8606 | break; |
8607 | ||
8608 | case IA64_RS_CFM: | |
8609 | if (note != 2) | |
542d6675 KH |
8610 | { |
8611 | specs[count++] = tmpl; | |
8612 | } | |
800eeca4 | 8613 | else |
542d6675 KH |
8614 | { |
8615 | /* Check if any of the registers accessed are in the rotating region. | |
8616 | mov to/from pr accesses CFM only when qp_regno is in the rotating | |
8617 | region */ | |
8618 | for (i = 0; i < NELEMS (idesc->operands); i++) | |
8619 | { | |
8620 | if (idesc->operands[i] == IA64_OPND_R1 | |
8621 | || idesc->operands[i] == IA64_OPND_R2 | |
8622 | || idesc->operands[i] == IA64_OPND_R3) | |
8623 | { | |
8624 | int num = CURR_SLOT.opnd[i].X_add_number - REG_GR; | |
8625 | /* Assumes that md.rot.num_regs is always valid */ | |
8626 | if (md.rot.num_regs > 0 | |
8627 | && num > 31 | |
8628 | && num < 31 + md.rot.num_regs) | |
8629 | { | |
8630 | specs[count] = tmpl; | |
8631 | specs[count++].specific = 0; | |
8632 | } | |
8633 | } | |
8634 | else if (idesc->operands[i] == IA64_OPND_F1 | |
8635 | || idesc->operands[i] == IA64_OPND_F2 | |
8636 | || idesc->operands[i] == IA64_OPND_F3 | |
8637 | || idesc->operands[i] == IA64_OPND_F4) | |
8638 | { | |
8639 | int num = CURR_SLOT.opnd[i].X_add_number - REG_FR; | |
8640 | if (num > 31) | |
8641 | { | |
8642 | specs[count] = tmpl; | |
8643 | specs[count++].specific = 0; | |
8644 | } | |
8645 | } | |
8646 | else if (idesc->operands[i] == IA64_OPND_P1 | |
8647 | || idesc->operands[i] == IA64_OPND_P2) | |
8648 | { | |
8649 | int num = CURR_SLOT.opnd[i].X_add_number - REG_P; | |
8650 | if (num > 15) | |
8651 | { | |
8652 | specs[count] = tmpl; | |
8653 | specs[count++].specific = 0; | |
8654 | } | |
8655 | } | |
8656 | } | |
8657 | if (CURR_SLOT.qp_regno > 15) | |
8658 | { | |
8659 | specs[count] = tmpl; | |
8660 | specs[count++].specific = 0; | |
8661 | } | |
8662 | } | |
800eeca4 JW |
8663 | break; |
8664 | ||
139368c9 JW |
8665 | /* This is the same as IA64_RS_PRr, except simplified to account for |
8666 | the fact that there is only one register. */ | |
800eeca4 JW |
8667 | case IA64_RS_PR63: |
8668 | if (note == 0) | |
542d6675 KH |
8669 | { |
8670 | specs[count++] = tmpl; | |
8671 | } | |
139368c9 | 8672 | else if (note == 7) |
40449e9f KH |
8673 | { |
8674 | valueT mask = 0; | |
8675 | if (idesc->operands[2] == IA64_OPND_IMM17) | |
8676 | mask = CURR_SLOT.opnd[2].X_add_number; | |
8677 | if (mask & ((valueT) 1 << 63)) | |
139368c9 | 8678 | specs[count++] = tmpl; |
40449e9f | 8679 | } |
800eeca4 | 8680 | else if (note == 11) |
542d6675 KH |
8681 | { |
8682 | if ((idesc->operands[0] == IA64_OPND_P1 | |
8683 | && CURR_SLOT.opnd[0].X_add_number - REG_P == 63) | |
8684 | || (idesc->operands[1] == IA64_OPND_P2 | |
8685 | && CURR_SLOT.opnd[1].X_add_number - REG_P == 63)) | |
8686 | { | |
8687 | specs[count++] = tmpl; | |
8688 | } | |
8689 | } | |
800eeca4 | 8690 | else if (note == 12) |
542d6675 KH |
8691 | { |
8692 | if (CURR_SLOT.qp_regno == 63) | |
8693 | { | |
8694 | specs[count++] = tmpl; | |
8695 | } | |
8696 | } | |
800eeca4 | 8697 | else if (note == 1) |
542d6675 KH |
8698 | { |
8699 | if (rsrc_write) | |
8700 | { | |
40449e9f KH |
8701 | int p1 = CURR_SLOT.opnd[0].X_add_number - REG_P; |
8702 | int p2 = CURR_SLOT.opnd[1].X_add_number - REG_P; | |
07726851 KH |
8703 | int or_andcm = strstr (idesc->name, "or.andcm") != NULL; |
8704 | int and_orcm = strstr (idesc->name, "and.orcm") != NULL; | |
7484b8e6 | 8705 | |
4a4f25cf | 8706 | if (p1 == 63 |
7484b8e6 TW |
8707 | && (idesc->operands[0] == IA64_OPND_P1 |
8708 | || idesc->operands[0] == IA64_OPND_P2)) | |
8709 | { | |
40449e9f | 8710 | specs[count] = tmpl; |
4a4f25cf | 8711 | specs[count++].cmp_type = |
7484b8e6 TW |
8712 | (or_andcm ? CMP_OR : (and_orcm ? CMP_AND : CMP_NONE)); |
8713 | } | |
8714 | if (p2 == 63 | |
8715 | && (idesc->operands[1] == IA64_OPND_P1 | |
8716 | || idesc->operands[1] == IA64_OPND_P2)) | |
8717 | { | |
40449e9f | 8718 | specs[count] = tmpl; |
4a4f25cf | 8719 | specs[count++].cmp_type = |
7484b8e6 TW |
8720 | (or_andcm ? CMP_AND : (and_orcm ? CMP_OR : CMP_NONE)); |
8721 | } | |
542d6675 KH |
8722 | } |
8723 | else | |
8724 | { | |
8725 | if (CURR_SLOT.qp_regno == 63) | |
8726 | { | |
8727 | specs[count++] = tmpl; | |
8728 | } | |
8729 | } | |
8730 | } | |
800eeca4 | 8731 | else |
542d6675 KH |
8732 | { |
8733 | UNHANDLED; | |
8734 | } | |
800eeca4 JW |
8735 | break; |
8736 | ||
8737 | case IA64_RS_RSE: | |
8738 | /* FIXME we can identify some individual RSE written resources, but RSE | |
542d6675 KH |
8739 | read resources have not yet been completely identified, so for now |
8740 | treat RSE as a single resource */ | |
800eeca4 | 8741 | if (strncmp (idesc->name, "mov", 3) == 0) |
542d6675 KH |
8742 | { |
8743 | if (rsrc_write) | |
8744 | { | |
8745 | if (idesc->operands[0] == IA64_OPND_AR3 | |
8746 | && CURR_SLOT.opnd[0].X_add_number - REG_AR == AR_BSPSTORE) | |
8747 | { | |
8748 | specs[count] = tmpl; | |
8749 | specs[count++].index = 0; /* IA64_RSE_BSPLOAD/RNATBITINDEX */ | |
8750 | } | |
8751 | } | |
8752 | else | |
8753 | { | |
8754 | if (idesc->operands[0] == IA64_OPND_AR3) | |
8755 | { | |
8756 | if (CURR_SLOT.opnd[0].X_add_number - REG_AR == AR_BSPSTORE | |
8757 | || CURR_SLOT.opnd[0].X_add_number - REG_AR == AR_RNAT) | |
8758 | { | |
8759 | specs[count++] = tmpl; | |
8760 | } | |
8761 | } | |
8762 | else if (idesc->operands[1] == IA64_OPND_AR3) | |
8763 | { | |
8764 | if (CURR_SLOT.opnd[1].X_add_number - REG_AR == AR_BSP | |
8765 | || CURR_SLOT.opnd[1].X_add_number - REG_AR == AR_BSPSTORE | |
8766 | || CURR_SLOT.opnd[1].X_add_number - REG_AR == AR_RNAT) | |
8767 | { | |
8768 | specs[count++] = tmpl; | |
8769 | } | |
8770 | } | |
8771 | } | |
8772 | } | |
197865e8 | 8773 | else |
542d6675 KH |
8774 | { |
8775 | specs[count++] = tmpl; | |
8776 | } | |
800eeca4 JW |
8777 | break; |
8778 | ||
8779 | case IA64_RS_ANY: | |
8780 | /* FIXME -- do any of these need to be non-specific? */ | |
8781 | specs[count++] = tmpl; | |
8782 | break; | |
8783 | ||
8784 | default: | |
8785 | as_bad (_("Unrecognized dependency specifier %d\n"), dep->specifier); | |
8786 | break; | |
8787 | } | |
8788 | ||
8789 | return count; | |
8790 | } | |
8791 | ||
8792 | /* Clear branch flags on marked resources. This breaks the link between the | |
542d6675 KH |
8793 | QP of the marking instruction and a subsequent branch on the same QP. */ |
8794 | ||
800eeca4 JW |
8795 | static void |
8796 | clear_qp_branch_flag (mask) | |
542d6675 | 8797 | valueT mask; |
800eeca4 JW |
8798 | { |
8799 | int i; | |
542d6675 | 8800 | for (i = 0; i < regdepslen; i++) |
800eeca4 | 8801 | { |
197865e8 | 8802 | valueT bit = ((valueT) 1 << regdeps[i].qp_regno); |
800eeca4 | 8803 | if ((bit & mask) != 0) |
542d6675 KH |
8804 | { |
8805 | regdeps[i].link_to_qp_branch = 0; | |
8806 | } | |
800eeca4 JW |
8807 | } |
8808 | } | |
8809 | ||
5e2f6673 L |
8810 | /* MASK contains 2 and only 2 PRs which are mutually exclusive. Remove |
8811 | any mutexes which contain one of the PRs and create new ones when | |
8812 | needed. */ | |
8813 | ||
8814 | static int | |
8815 | update_qp_mutex (valueT mask) | |
8816 | { | |
8817 | int i; | |
8818 | int add = 0; | |
8819 | ||
8820 | i = 0; | |
8821 | while (i < qp_mutexeslen) | |
8822 | { | |
8823 | if ((qp_mutexes[i].prmask & mask) != 0) | |
8824 | { | |
8825 | /* If it destroys and creates the same mutex, do nothing. */ | |
8826 | if (qp_mutexes[i].prmask == mask | |
8827 | && qp_mutexes[i].path == md.path) | |
8828 | { | |
8829 | i++; | |
8830 | add = -1; | |
8831 | } | |
8832 | else | |
8833 | { | |
8834 | int keep = 0; | |
8835 | ||
8836 | if (md.debug_dv) | |
8837 | { | |
8838 | fprintf (stderr, " Clearing mutex relation"); | |
8839 | print_prmask (qp_mutexes[i].prmask); | |
8840 | fprintf (stderr, "\n"); | |
8841 | } | |
8842 | ||
8843 | /* Deal with the old mutex with more than 3+ PRs only if | |
8844 | the new mutex on the same execution path with it. | |
8845 | ||
8846 | FIXME: The 3+ mutex support is incomplete. | |
8847 | dot_pred_rel () may be a better place to fix it. */ | |
8848 | if (qp_mutexes[i].path == md.path) | |
8849 | { | |
8850 | /* If it is a proper subset of the mutex, create a | |
8851 | new mutex. */ | |
8852 | if (add == 0 | |
8853 | && (qp_mutexes[i].prmask & mask) == mask) | |
8854 | add = 1; | |
8855 | ||
8856 | qp_mutexes[i].prmask &= ~mask; | |
8857 | if (qp_mutexes[i].prmask & (qp_mutexes[i].prmask - 1)) | |
8858 | { | |
8859 | /* Modify the mutex if there are more than one | |
8860 | PR left. */ | |
8861 | keep = 1; | |
8862 | i++; | |
8863 | } | |
8864 | } | |
8865 | ||
8866 | if (keep == 0) | |
8867 | /* Remove the mutex. */ | |
8868 | qp_mutexes[i] = qp_mutexes[--qp_mutexeslen]; | |
8869 | } | |
8870 | } | |
8871 | else | |
8872 | ++i; | |
8873 | } | |
8874 | ||
8875 | if (add == 1) | |
8876 | add_qp_mutex (mask); | |
8877 | ||
8878 | return add; | |
8879 | } | |
8880 | ||
197865e8 | 8881 | /* Remove any mutexes which contain any of the PRs indicated in the mask. |
800eeca4 | 8882 | |
542d6675 KH |
8883 | Any changes to a PR clears the mutex relations which include that PR. */ |
8884 | ||
800eeca4 JW |
8885 | static void |
8886 | clear_qp_mutex (mask) | |
542d6675 | 8887 | valueT mask; |
800eeca4 JW |
8888 | { |
8889 | int i; | |
8890 | ||
8891 | i = 0; | |
8892 | while (i < qp_mutexeslen) | |
8893 | { | |
8894 | if ((qp_mutexes[i].prmask & mask) != 0) | |
542d6675 KH |
8895 | { |
8896 | if (md.debug_dv) | |
8897 | { | |
8898 | fprintf (stderr, " Clearing mutex relation"); | |
8899 | print_prmask (qp_mutexes[i].prmask); | |
8900 | fprintf (stderr, "\n"); | |
8901 | } | |
8902 | qp_mutexes[i] = qp_mutexes[--qp_mutexeslen]; | |
8903 | } | |
800eeca4 | 8904 | else |
542d6675 | 8905 | ++i; |
800eeca4 JW |
8906 | } |
8907 | } | |
8908 | ||
8909 | /* Clear implies relations which contain PRs in the given masks. | |
8910 | P1_MASK indicates the source of the implies relation, while P2_MASK | |
542d6675 KH |
8911 | indicates the implied PR. */ |
8912 | ||
800eeca4 JW |
8913 | static void |
8914 | clear_qp_implies (p1_mask, p2_mask) | |
542d6675 KH |
8915 | valueT p1_mask; |
8916 | valueT p2_mask; | |
800eeca4 JW |
8917 | { |
8918 | int i; | |
8919 | ||
8920 | i = 0; | |
8921 | while (i < qp_implieslen) | |
8922 | { | |
197865e8 | 8923 | if ((((valueT) 1 << qp_implies[i].p1) & p1_mask) != 0 |
542d6675 KH |
8924 | || (((valueT) 1 << qp_implies[i].p2) & p2_mask) != 0) |
8925 | { | |
8926 | if (md.debug_dv) | |
8927 | fprintf (stderr, "Clearing implied relation PR%d->PR%d\n", | |
8928 | qp_implies[i].p1, qp_implies[i].p2); | |
8929 | qp_implies[i] = qp_implies[--qp_implieslen]; | |
8930 | } | |
197865e8 | 8931 | else |
542d6675 | 8932 | ++i; |
800eeca4 JW |
8933 | } |
8934 | } | |
8935 | ||
542d6675 KH |
8936 | /* Add the PRs specified to the list of implied relations. */ |
8937 | ||
800eeca4 JW |
8938 | static void |
8939 | add_qp_imply (p1, p2) | |
542d6675 | 8940 | int p1, p2; |
800eeca4 JW |
8941 | { |
8942 | valueT mask; | |
8943 | valueT bit; | |
8944 | int i; | |
8945 | ||
542d6675 | 8946 | /* p0 is not meaningful here. */ |
800eeca4 JW |
8947 | if (p1 == 0 || p2 == 0) |
8948 | abort (); | |
8949 | ||
8950 | if (p1 == p2) | |
8951 | return; | |
8952 | ||
542d6675 KH |
8953 | /* If it exists already, ignore it. */ |
8954 | for (i = 0; i < qp_implieslen; i++) | |
800eeca4 | 8955 | { |
197865e8 | 8956 | if (qp_implies[i].p1 == p1 |
542d6675 KH |
8957 | && qp_implies[i].p2 == p2 |
8958 | && qp_implies[i].path == md.path | |
8959 | && !qp_implies[i].p2_branched) | |
8960 | return; | |
800eeca4 JW |
8961 | } |
8962 | ||
8963 | if (qp_implieslen == qp_impliestotlen) | |
8964 | { | |
8965 | qp_impliestotlen += 20; | |
8966 | qp_implies = (struct qp_imply *) | |
542d6675 KH |
8967 | xrealloc ((void *) qp_implies, |
8968 | qp_impliestotlen * sizeof (struct qp_imply)); | |
800eeca4 JW |
8969 | } |
8970 | if (md.debug_dv) | |
8971 | fprintf (stderr, " Registering PR%d implies PR%d\n", p1, p2); | |
8972 | qp_implies[qp_implieslen].p1 = p1; | |
8973 | qp_implies[qp_implieslen].p2 = p2; | |
8974 | qp_implies[qp_implieslen].path = md.path; | |
8975 | qp_implies[qp_implieslen++].p2_branched = 0; | |
8976 | ||
8977 | /* Add in the implied transitive relations; for everything that p2 implies, | |
8978 | make p1 imply that, too; for everything that implies p1, make it imply p2 | |
197865e8 | 8979 | as well. */ |
542d6675 | 8980 | for (i = 0; i < qp_implieslen; i++) |
800eeca4 JW |
8981 | { |
8982 | if (qp_implies[i].p1 == p2) | |
542d6675 | 8983 | add_qp_imply (p1, qp_implies[i].p2); |
800eeca4 | 8984 | if (qp_implies[i].p2 == p1) |
542d6675 | 8985 | add_qp_imply (qp_implies[i].p1, p2); |
800eeca4 JW |
8986 | } |
8987 | /* Add in mutex relations implied by this implies relation; for each mutex | |
197865e8 KH |
8988 | relation containing p2, duplicate it and replace p2 with p1. */ |
8989 | bit = (valueT) 1 << p1; | |
8990 | mask = (valueT) 1 << p2; | |
542d6675 | 8991 | for (i = 0; i < qp_mutexeslen; i++) |
800eeca4 JW |
8992 | { |
8993 | if (qp_mutexes[i].prmask & mask) | |
542d6675 | 8994 | add_qp_mutex ((qp_mutexes[i].prmask & ~mask) | bit); |
800eeca4 JW |
8995 | } |
8996 | } | |
8997 | ||
800eeca4 JW |
8998 | /* Add the PRs specified in the mask to the mutex list; this means that only |
8999 | one of the PRs can be true at any time. PR0 should never be included in | |
9000 | the mask. */ | |
542d6675 | 9001 | |
800eeca4 JW |
9002 | static void |
9003 | add_qp_mutex (mask) | |
542d6675 | 9004 | valueT mask; |
800eeca4 JW |
9005 | { |
9006 | if (mask & 0x1) | |
9007 | abort (); | |
9008 | ||
9009 | if (qp_mutexeslen == qp_mutexestotlen) | |
9010 | { | |
9011 | qp_mutexestotlen += 20; | |
9012 | qp_mutexes = (struct qpmutex *) | |
542d6675 KH |
9013 | xrealloc ((void *) qp_mutexes, |
9014 | qp_mutexestotlen * sizeof (struct qpmutex)); | |
800eeca4 JW |
9015 | } |
9016 | if (md.debug_dv) | |
9017 | { | |
9018 | fprintf (stderr, " Registering mutex on"); | |
9019 | print_prmask (mask); | |
9020 | fprintf (stderr, "\n"); | |
9021 | } | |
9022 | qp_mutexes[qp_mutexeslen].path = md.path; | |
9023 | qp_mutexes[qp_mutexeslen++].prmask = mask; | |
9024 | } | |
9025 | ||
cb5301b6 RH |
9026 | static int |
9027 | has_suffix_p (name, suffix) | |
40449e9f KH |
9028 | const char *name; |
9029 | const char *suffix; | |
cb5301b6 RH |
9030 | { |
9031 | size_t namelen = strlen (name); | |
9032 | size_t sufflen = strlen (suffix); | |
9033 | ||
9034 | if (namelen <= sufflen) | |
9035 | return 0; | |
9036 | return strcmp (name + namelen - sufflen, suffix) == 0; | |
9037 | } | |
9038 | ||
800eeca4 JW |
9039 | static void |
9040 | clear_register_values () | |
9041 | { | |
9042 | int i; | |
9043 | if (md.debug_dv) | |
9044 | fprintf (stderr, " Clearing register values\n"); | |
542d6675 | 9045 | for (i = 1; i < NELEMS (gr_values); i++) |
800eeca4 JW |
9046 | gr_values[i].known = 0; |
9047 | } | |
9048 | ||
9049 | /* Keep track of register values/changes which affect DV tracking. | |
9050 | ||
9051 | optimization note: should add a flag to classes of insns where otherwise we | |
542d6675 | 9052 | have to examine a group of strings to identify them. */ |
800eeca4 | 9053 | |
800eeca4 JW |
9054 | static void |
9055 | note_register_values (idesc) | |
542d6675 | 9056 | struct ia64_opcode *idesc; |
800eeca4 JW |
9057 | { |
9058 | valueT qp_changemask = 0; | |
9059 | int i; | |
9060 | ||
542d6675 KH |
9061 | /* Invalidate values for registers being written to. */ |
9062 | for (i = 0; i < idesc->num_outputs; i++) | |
800eeca4 | 9063 | { |
197865e8 | 9064 | if (idesc->operands[i] == IA64_OPND_R1 |
542d6675 KH |
9065 | || idesc->operands[i] == IA64_OPND_R2 |
9066 | || idesc->operands[i] == IA64_OPND_R3) | |
9067 | { | |
9068 | int regno = CURR_SLOT.opnd[i].X_add_number - REG_GR; | |
9069 | if (regno > 0 && regno < NELEMS (gr_values)) | |
9070 | gr_values[regno].known = 0; | |
9071 | } | |
50b81f19 JW |
9072 | else if (idesc->operands[i] == IA64_OPND_R3_2) |
9073 | { | |
9074 | int regno = CURR_SLOT.opnd[i].X_add_number - REG_GR; | |
9075 | if (regno > 0 && regno < 4) | |
9076 | gr_values[regno].known = 0; | |
9077 | } | |
197865e8 | 9078 | else if (idesc->operands[i] == IA64_OPND_P1 |
542d6675 KH |
9079 | || idesc->operands[i] == IA64_OPND_P2) |
9080 | { | |
9081 | int regno = CURR_SLOT.opnd[i].X_add_number - REG_P; | |
9082 | qp_changemask |= (valueT) 1 << regno; | |
9083 | } | |
800eeca4 | 9084 | else if (idesc->operands[i] == IA64_OPND_PR) |
542d6675 KH |
9085 | { |
9086 | if (idesc->operands[2] & (valueT) 0x10000) | |
9087 | qp_changemask = ~(valueT) 0x1FFFF | idesc->operands[2]; | |
9088 | else | |
9089 | qp_changemask = idesc->operands[2]; | |
9090 | break; | |
9091 | } | |
800eeca4 | 9092 | else if (idesc->operands[i] == IA64_OPND_PR_ROT) |
542d6675 KH |
9093 | { |
9094 | if (idesc->operands[1] & ((valueT) 1 << 43)) | |
6344efa4 | 9095 | qp_changemask = -((valueT) 1 << 44) | idesc->operands[1]; |
542d6675 KH |
9096 | else |
9097 | qp_changemask = idesc->operands[1]; | |
9098 | qp_changemask &= ~(valueT) 0xFFFF; | |
9099 | break; | |
9100 | } | |
9101 | } | |
9102 | ||
9103 | /* Always clear qp branch flags on any PR change. */ | |
9104 | /* FIXME there may be exceptions for certain compares. */ | |
800eeca4 JW |
9105 | clear_qp_branch_flag (qp_changemask); |
9106 | ||
542d6675 | 9107 | /* Invalidate rotating registers on insns which affect RRBs in CFM. */ |
800eeca4 JW |
9108 | if (idesc->flags & IA64_OPCODE_MOD_RRBS) |
9109 | { | |
197865e8 | 9110 | qp_changemask |= ~(valueT) 0xFFFF; |
800eeca4 | 9111 | if (strcmp (idesc->name, "clrrrb.pr") != 0) |
542d6675 KH |
9112 | { |
9113 | for (i = 32; i < 32 + md.rot.num_regs; i++) | |
9114 | gr_values[i].known = 0; | |
9115 | } | |
800eeca4 JW |
9116 | clear_qp_mutex (qp_changemask); |
9117 | clear_qp_implies (qp_changemask, qp_changemask); | |
9118 | } | |
542d6675 KH |
9119 | /* After a call, all register values are undefined, except those marked |
9120 | as "safe". */ | |
800eeca4 | 9121 | else if (strncmp (idesc->name, "br.call", 6) == 0 |
542d6675 | 9122 | || strncmp (idesc->name, "brl.call", 7) == 0) |
800eeca4 | 9123 | { |
56d27c17 | 9124 | /* FIXME keep GR values which are marked as "safe_across_calls" */ |
800eeca4 JW |
9125 | clear_register_values (); |
9126 | clear_qp_mutex (~qp_safe_across_calls); | |
9127 | clear_qp_implies (~qp_safe_across_calls, ~qp_safe_across_calls); | |
9128 | clear_qp_branch_flag (~qp_safe_across_calls); | |
9129 | } | |
e9718fe1 | 9130 | else if (is_interruption_or_rfi (idesc) |
542d6675 | 9131 | || is_taken_branch (idesc)) |
e9718fe1 TW |
9132 | { |
9133 | clear_register_values (); | |
197865e8 KH |
9134 | clear_qp_mutex (~(valueT) 0); |
9135 | clear_qp_implies (~(valueT) 0, ~(valueT) 0); | |
e9718fe1 | 9136 | } |
542d6675 | 9137 | /* Look for mutex and implies relations. */ |
197865e8 | 9138 | else if ((idesc->operands[0] == IA64_OPND_P1 |
542d6675 KH |
9139 | || idesc->operands[0] == IA64_OPND_P2) |
9140 | && (idesc->operands[1] == IA64_OPND_P1 | |
9141 | || idesc->operands[1] == IA64_OPND_P2)) | |
800eeca4 JW |
9142 | { |
9143 | int p1 = CURR_SLOT.opnd[0].X_add_number - REG_P; | |
197865e8 | 9144 | int p2 = CURR_SLOT.opnd[1].X_add_number - REG_P; |
5e2f6673 L |
9145 | valueT p1mask = (p1 != 0) ? (valueT) 1 << p1 : 0; |
9146 | valueT p2mask = (p2 != 0) ? (valueT) 1 << p2 : 0; | |
800eeca4 | 9147 | |
5e2f6673 L |
9148 | /* If both PRs are PR0, we can't really do anything. */ |
9149 | if (p1 == 0 && p2 == 0) | |
542d6675 KH |
9150 | { |
9151 | if (md.debug_dv) | |
9152 | fprintf (stderr, " Ignoring PRs due to inclusion of p0\n"); | |
9153 | } | |
800eeca4 | 9154 | /* In general, clear mutexes and implies which include P1 or P2, |
542d6675 | 9155 | with the following exceptions. */ |
cb5301b6 RH |
9156 | else if (has_suffix_p (idesc->name, ".or.andcm") |
9157 | || has_suffix_p (idesc->name, ".and.orcm")) | |
542d6675 | 9158 | { |
542d6675 KH |
9159 | clear_qp_implies (p2mask, p1mask); |
9160 | } | |
cb5301b6 RH |
9161 | else if (has_suffix_p (idesc->name, ".andcm") |
9162 | || has_suffix_p (idesc->name, ".and")) | |
542d6675 KH |
9163 | { |
9164 | clear_qp_implies (0, p1mask | p2mask); | |
9165 | } | |
cb5301b6 RH |
9166 | else if (has_suffix_p (idesc->name, ".orcm") |
9167 | || has_suffix_p (idesc->name, ".or")) | |
542d6675 KH |
9168 | { |
9169 | clear_qp_mutex (p1mask | p2mask); | |
9170 | clear_qp_implies (p1mask | p2mask, 0); | |
9171 | } | |
800eeca4 | 9172 | else |
542d6675 | 9173 | { |
5e2f6673 L |
9174 | int added = 0; |
9175 | ||
542d6675 | 9176 | clear_qp_implies (p1mask | p2mask, p1mask | p2mask); |
5e2f6673 L |
9177 | |
9178 | /* If one of the PRs is PR0, we call clear_qp_mutex. */ | |
9179 | if (p1 == 0 || p2 == 0) | |
9180 | clear_qp_mutex (p1mask | p2mask); | |
9181 | else | |
9182 | added = update_qp_mutex (p1mask | p2mask); | |
9183 | ||
9184 | if (CURR_SLOT.qp_regno == 0 | |
9185 | || has_suffix_p (idesc->name, ".unc")) | |
542d6675 | 9186 | { |
5e2f6673 L |
9187 | if (added == 0 && p1 && p2) |
9188 | add_qp_mutex (p1mask | p2mask); | |
542d6675 KH |
9189 | if (CURR_SLOT.qp_regno != 0) |
9190 | { | |
5e2f6673 L |
9191 | if (p1) |
9192 | add_qp_imply (p1, CURR_SLOT.qp_regno); | |
9193 | if (p2) | |
9194 | add_qp_imply (p2, CURR_SLOT.qp_regno); | |
542d6675 KH |
9195 | } |
9196 | } | |
542d6675 KH |
9197 | } |
9198 | } | |
9199 | /* Look for mov imm insns into GRs. */ | |
800eeca4 | 9200 | else if (idesc->operands[0] == IA64_OPND_R1 |
542d6675 KH |
9201 | && (idesc->operands[1] == IA64_OPND_IMM22 |
9202 | || idesc->operands[1] == IA64_OPND_IMMU64) | |
9203 | && (strcmp (idesc->name, "mov") == 0 | |
9204 | || strcmp (idesc->name, "movl") == 0)) | |
800eeca4 JW |
9205 | { |
9206 | int regno = CURR_SLOT.opnd[0].X_add_number - REG_GR; | |
542d6675 KH |
9207 | if (regno > 0 && regno < NELEMS (gr_values)) |
9208 | { | |
9209 | gr_values[regno].known = 1; | |
9210 | gr_values[regno].value = CURR_SLOT.opnd[1].X_add_number; | |
9211 | gr_values[regno].path = md.path; | |
9212 | if (md.debug_dv) | |
2434f565 JW |
9213 | { |
9214 | fprintf (stderr, " Know gr%d = ", regno); | |
9215 | fprintf_vma (stderr, gr_values[regno].value); | |
9216 | fputs ("\n", stderr); | |
9217 | } | |
542d6675 | 9218 | } |
800eeca4 | 9219 | } |
197865e8 | 9220 | else |
800eeca4 JW |
9221 | { |
9222 | clear_qp_mutex (qp_changemask); | |
9223 | clear_qp_implies (qp_changemask, qp_changemask); | |
9224 | } | |
9225 | } | |
9226 | ||
542d6675 KH |
9227 | /* Return whether the given predicate registers are currently mutex. */ |
9228 | ||
800eeca4 JW |
9229 | static int |
9230 | qp_mutex (p1, p2, path) | |
542d6675 KH |
9231 | int p1; |
9232 | int p2; | |
9233 | int path; | |
800eeca4 JW |
9234 | { |
9235 | int i; | |
9236 | valueT mask; | |
9237 | ||
9238 | if (p1 != p2) | |
9239 | { | |
542d6675 KH |
9240 | mask = ((valueT) 1 << p1) | (valueT) 1 << p2; |
9241 | for (i = 0; i < qp_mutexeslen; i++) | |
9242 | { | |
9243 | if (qp_mutexes[i].path >= path | |
9244 | && (qp_mutexes[i].prmask & mask) == mask) | |
9245 | return 1; | |
9246 | } | |
800eeca4 JW |
9247 | } |
9248 | return 0; | |
9249 | } | |
9250 | ||
9251 | /* Return whether the given resource is in the given insn's list of chks | |
9252 | Return 1 if the conflict is absolutely determined, 2 if it's a potential | |
542d6675 KH |
9253 | conflict. */ |
9254 | ||
800eeca4 JW |
9255 | static int |
9256 | resources_match (rs, idesc, note, qp_regno, path) | |
542d6675 KH |
9257 | struct rsrc *rs; |
9258 | struct ia64_opcode *idesc; | |
9259 | int note; | |
9260 | int qp_regno; | |
9261 | int path; | |
800eeca4 JW |
9262 | { |
9263 | struct rsrc specs[MAX_SPECS]; | |
9264 | int count; | |
9265 | ||
9266 | /* If the marked resource's qp_regno and the given qp_regno are mutex, | |
9267 | we don't need to check. One exception is note 11, which indicates that | |
9268 | target predicates are written regardless of PR[qp]. */ | |
197865e8 | 9269 | if (qp_mutex (rs->qp_regno, qp_regno, path) |
800eeca4 JW |
9270 | && note != 11) |
9271 | return 0; | |
9272 | ||
9273 | count = specify_resource (rs->dependency, idesc, DV_CHK, specs, note, path); | |
9274 | while (count-- > 0) | |
9275 | { | |
9276 | /* UNAT checking is a bit more specific than other resources */ | |
9277 | if (rs->dependency->specifier == IA64_RS_AR_UNAT | |
542d6675 KH |
9278 | && specs[count].mem_offset.hint |
9279 | && rs->mem_offset.hint) | |
9280 | { | |
9281 | if (rs->mem_offset.base == specs[count].mem_offset.base) | |
9282 | { | |
9283 | if (((rs->mem_offset.offset >> 3) & 0x3F) == | |
9284 | ((specs[count].mem_offset.offset >> 3) & 0x3F)) | |
9285 | return 1; | |
9286 | else | |
9287 | continue; | |
9288 | } | |
9289 | } | |
800eeca4 | 9290 | |
7484b8e6 | 9291 | /* Skip apparent PR write conflicts where both writes are an AND or both |
4a4f25cf | 9292 | writes are an OR. */ |
7484b8e6 | 9293 | if (rs->dependency->specifier == IA64_RS_PR |
afa680f8 | 9294 | || rs->dependency->specifier == IA64_RS_PRr |
7484b8e6 TW |
9295 | || rs->dependency->specifier == IA64_RS_PR63) |
9296 | { | |
9297 | if (specs[count].cmp_type != CMP_NONE | |
9298 | && specs[count].cmp_type == rs->cmp_type) | |
9299 | { | |
9300 | if (md.debug_dv) | |
9301 | fprintf (stderr, " %s on parallel compare allowed (PR%d)\n", | |
9302 | dv_mode[rs->dependency->mode], | |
afa680f8 | 9303 | rs->dependency->specifier != IA64_RS_PR63 ? |
7484b8e6 TW |
9304 | specs[count].index : 63); |
9305 | continue; | |
9306 | } | |
9307 | if (md.debug_dv) | |
4a4f25cf | 9308 | fprintf (stderr, |
7484b8e6 TW |
9309 | " %s on parallel compare conflict %s vs %s on PR%d\n", |
9310 | dv_mode[rs->dependency->mode], | |
4a4f25cf | 9311 | dv_cmp_type[rs->cmp_type], |
7484b8e6 | 9312 | dv_cmp_type[specs[count].cmp_type], |
afa680f8 | 9313 | rs->dependency->specifier != IA64_RS_PR63 ? |
7484b8e6 | 9314 | specs[count].index : 63); |
4a4f25cf | 9315 | |
7484b8e6 TW |
9316 | } |
9317 | ||
800eeca4 | 9318 | /* If either resource is not specific, conservatively assume a conflict |
197865e8 | 9319 | */ |
800eeca4 | 9320 | if (!specs[count].specific || !rs->specific) |
542d6675 | 9321 | return 2; |
800eeca4 | 9322 | else if (specs[count].index == rs->index) |
542d6675 | 9323 | return 1; |
800eeca4 JW |
9324 | } |
9325 | #if 0 | |
9326 | if (md.debug_dv) | |
9327 | fprintf (stderr, " No %s conflicts\n", rs->dependency->name); | |
9328 | #endif | |
9329 | ||
9330 | return 0; | |
9331 | } | |
9332 | ||
9333 | /* Indicate an instruction group break; if INSERT_STOP is non-zero, then | |
9334 | insert a stop to create the break. Update all resource dependencies | |
9335 | appropriately. If QP_REGNO is non-zero, only apply the break to resources | |
9336 | which use the same QP_REGNO and have the link_to_qp_branch flag set. | |
9337 | If SAVE_CURRENT is non-zero, don't affect resources marked by the current | |
542d6675 | 9338 | instruction. */ |
800eeca4 JW |
9339 | |
9340 | static void | |
9341 | insn_group_break (insert_stop, qp_regno, save_current) | |
542d6675 KH |
9342 | int insert_stop; |
9343 | int qp_regno; | |
9344 | int save_current; | |
800eeca4 JW |
9345 | { |
9346 | int i; | |
9347 | ||
9348 | if (insert_stop && md.num_slots_in_use > 0) | |
9349 | PREV_SLOT.end_of_insn_group = 1; | |
9350 | ||
9351 | if (md.debug_dv) | |
9352 | { | |
197865e8 | 9353 | fprintf (stderr, " Insn group break%s", |
542d6675 | 9354 | (insert_stop ? " (w/stop)" : "")); |
800eeca4 | 9355 | if (qp_regno != 0) |
542d6675 | 9356 | fprintf (stderr, " effective for QP=%d", qp_regno); |
800eeca4 JW |
9357 | fprintf (stderr, "\n"); |
9358 | } | |
9359 | ||
9360 | i = 0; | |
9361 | while (i < regdepslen) | |
9362 | { | |
9363 | const struct ia64_dependency *dep = regdeps[i].dependency; | |
9364 | ||
9365 | if (qp_regno != 0 | |
542d6675 KH |
9366 | && regdeps[i].qp_regno != qp_regno) |
9367 | { | |
9368 | ++i; | |
9369 | continue; | |
9370 | } | |
800eeca4 JW |
9371 | |
9372 | if (save_current | |
542d6675 KH |
9373 | && CURR_SLOT.src_file == regdeps[i].file |
9374 | && CURR_SLOT.src_line == regdeps[i].line) | |
9375 | { | |
9376 | ++i; | |
9377 | continue; | |
9378 | } | |
800eeca4 JW |
9379 | |
9380 | /* clear dependencies which are automatically cleared by a stop, or | |
542d6675 | 9381 | those that have reached the appropriate state of insn serialization */ |
800eeca4 | 9382 | if (dep->semantics == IA64_DVS_IMPLIED |
542d6675 KH |
9383 | || dep->semantics == IA64_DVS_IMPLIEDF |
9384 | || regdeps[i].insn_srlz == STATE_SRLZ) | |
9385 | { | |
9386 | print_dependency ("Removing", i); | |
9387 | regdeps[i] = regdeps[--regdepslen]; | |
9388 | } | |
800eeca4 | 9389 | else |
542d6675 KH |
9390 | { |
9391 | if (dep->semantics == IA64_DVS_DATA | |
9392 | || dep->semantics == IA64_DVS_INSTR | |
800eeca4 | 9393 | || dep->semantics == IA64_DVS_SPECIFIC) |
542d6675 KH |
9394 | { |
9395 | if (regdeps[i].insn_srlz == STATE_NONE) | |
9396 | regdeps[i].insn_srlz = STATE_STOP; | |
9397 | if (regdeps[i].data_srlz == STATE_NONE) | |
9398 | regdeps[i].data_srlz = STATE_STOP; | |
9399 | } | |
9400 | ++i; | |
9401 | } | |
800eeca4 JW |
9402 | } |
9403 | } | |
9404 | ||
542d6675 KH |
9405 | /* Add the given resource usage spec to the list of active dependencies. */ |
9406 | ||
197865e8 | 9407 | static void |
800eeca4 | 9408 | mark_resource (idesc, dep, spec, depind, path) |
2434f565 JW |
9409 | struct ia64_opcode *idesc ATTRIBUTE_UNUSED; |
9410 | const struct ia64_dependency *dep ATTRIBUTE_UNUSED; | |
542d6675 KH |
9411 | struct rsrc *spec; |
9412 | int depind; | |
9413 | int path; | |
800eeca4 JW |
9414 | { |
9415 | if (regdepslen == regdepstotlen) | |
9416 | { | |
9417 | regdepstotlen += 20; | |
9418 | regdeps = (struct rsrc *) | |
542d6675 | 9419 | xrealloc ((void *) regdeps, |
bc805888 | 9420 | regdepstotlen * sizeof (struct rsrc)); |
800eeca4 JW |
9421 | } |
9422 | ||
9423 | regdeps[regdepslen] = *spec; | |
9424 | regdeps[regdepslen].depind = depind; | |
9425 | regdeps[regdepslen].path = path; | |
9426 | regdeps[regdepslen].file = CURR_SLOT.src_file; | |
9427 | regdeps[regdepslen].line = CURR_SLOT.src_line; | |
9428 | ||
9429 | print_dependency ("Adding", regdepslen); | |
9430 | ||
9431 | ++regdepslen; | |
9432 | } | |
9433 | ||
9434 | static void | |
9435 | print_dependency (action, depind) | |
542d6675 KH |
9436 | const char *action; |
9437 | int depind; | |
800eeca4 JW |
9438 | { |
9439 | if (md.debug_dv) | |
9440 | { | |
197865e8 | 9441 | fprintf (stderr, " %s %s '%s'", |
542d6675 KH |
9442 | action, dv_mode[(regdeps[depind].dependency)->mode], |
9443 | (regdeps[depind].dependency)->name); | |
800eeca4 | 9444 | if (regdeps[depind].specific && regdeps[depind].index != 0) |
542d6675 | 9445 | fprintf (stderr, " (%d)", regdeps[depind].index); |
800eeca4 | 9446 | if (regdeps[depind].mem_offset.hint) |
2434f565 JW |
9447 | { |
9448 | fputs (" ", stderr); | |
9449 | fprintf_vma (stderr, regdeps[depind].mem_offset.base); | |
9450 | fputs ("+", stderr); | |
9451 | fprintf_vma (stderr, regdeps[depind].mem_offset.offset); | |
9452 | } | |
800eeca4 JW |
9453 | fprintf (stderr, "\n"); |
9454 | } | |
9455 | } | |
9456 | ||
9457 | static void | |
9458 | instruction_serialization () | |
9459 | { | |
9460 | int i; | |
9461 | if (md.debug_dv) | |
9462 | fprintf (stderr, " Instruction serialization\n"); | |
542d6675 | 9463 | for (i = 0; i < regdepslen; i++) |
800eeca4 JW |
9464 | if (regdeps[i].insn_srlz == STATE_STOP) |
9465 | regdeps[i].insn_srlz = STATE_SRLZ; | |
9466 | } | |
9467 | ||
9468 | static void | |
9469 | data_serialization () | |
9470 | { | |
9471 | int i = 0; | |
9472 | if (md.debug_dv) | |
9473 | fprintf (stderr, " Data serialization\n"); | |
9474 | while (i < regdepslen) | |
9475 | { | |
9476 | if (regdeps[i].data_srlz == STATE_STOP | |
542d6675 KH |
9477 | /* Note: as of 991210, all "other" dependencies are cleared by a |
9478 | data serialization. This might change with new tables */ | |
9479 | || (regdeps[i].dependency)->semantics == IA64_DVS_OTHER) | |
9480 | { | |
9481 | print_dependency ("Removing", i); | |
9482 | regdeps[i] = regdeps[--regdepslen]; | |
9483 | } | |
800eeca4 | 9484 | else |
542d6675 | 9485 | ++i; |
800eeca4 JW |
9486 | } |
9487 | } | |
9488 | ||
542d6675 KH |
9489 | /* Insert stops and serializations as needed to avoid DVs. */ |
9490 | ||
800eeca4 JW |
9491 | static void |
9492 | remove_marked_resource (rs) | |
542d6675 | 9493 | struct rsrc *rs; |
800eeca4 JW |
9494 | { |
9495 | switch (rs->dependency->semantics) | |
9496 | { | |
9497 | case IA64_DVS_SPECIFIC: | |
9498 | if (md.debug_dv) | |
9499 | fprintf (stderr, "Implementation-specific, assume worst case...\n"); | |
197865e8 | 9500 | /* ...fall through... */ |
800eeca4 JW |
9501 | case IA64_DVS_INSTR: |
9502 | if (md.debug_dv) | |
542d6675 | 9503 | fprintf (stderr, "Inserting instr serialization\n"); |
800eeca4 | 9504 | if (rs->insn_srlz < STATE_STOP) |
542d6675 | 9505 | insn_group_break (1, 0, 0); |
800eeca4 | 9506 | if (rs->insn_srlz < STATE_SRLZ) |
542d6675 KH |
9507 | { |
9508 | int oldqp = CURR_SLOT.qp_regno; | |
9509 | struct ia64_opcode *oldidesc = CURR_SLOT.idesc; | |
9510 | /* Manually jam a srlz.i insn into the stream */ | |
9511 | CURR_SLOT.qp_regno = 0; | |
9512 | CURR_SLOT.idesc = ia64_find_opcode ("srlz.i"); | |
9513 | instruction_serialization (); | |
9514 | md.curr_slot = (md.curr_slot + 1) % NUM_SLOTS; | |
9515 | if (++md.num_slots_in_use >= NUM_SLOTS) | |
9516 | emit_one_bundle (); | |
9517 | CURR_SLOT.qp_regno = oldqp; | |
9518 | CURR_SLOT.idesc = oldidesc; | |
9519 | } | |
800eeca4 JW |
9520 | insn_group_break (1, 0, 0); |
9521 | break; | |
9522 | case IA64_DVS_OTHER: /* as of rev2 (991220) of the DV tables, all | |
542d6675 KH |
9523 | "other" types of DV are eliminated |
9524 | by a data serialization */ | |
800eeca4 JW |
9525 | case IA64_DVS_DATA: |
9526 | if (md.debug_dv) | |
542d6675 | 9527 | fprintf (stderr, "Inserting data serialization\n"); |
800eeca4 | 9528 | if (rs->data_srlz < STATE_STOP) |
542d6675 | 9529 | insn_group_break (1, 0, 0); |
800eeca4 | 9530 | { |
542d6675 KH |
9531 | int oldqp = CURR_SLOT.qp_regno; |
9532 | struct ia64_opcode *oldidesc = CURR_SLOT.idesc; | |
9533 | /* Manually jam a srlz.d insn into the stream */ | |
9534 | CURR_SLOT.qp_regno = 0; | |
9535 | CURR_SLOT.idesc = ia64_find_opcode ("srlz.d"); | |
9536 | data_serialization (); | |
9537 | md.curr_slot = (md.curr_slot + 1) % NUM_SLOTS; | |
9538 | if (++md.num_slots_in_use >= NUM_SLOTS) | |
9539 | emit_one_bundle (); | |
9540 | CURR_SLOT.qp_regno = oldqp; | |
9541 | CURR_SLOT.idesc = oldidesc; | |
800eeca4 JW |
9542 | } |
9543 | break; | |
9544 | case IA64_DVS_IMPLIED: | |
9545 | case IA64_DVS_IMPLIEDF: | |
9546 | if (md.debug_dv) | |
542d6675 | 9547 | fprintf (stderr, "Inserting stop\n"); |
800eeca4 JW |
9548 | insn_group_break (1, 0, 0); |
9549 | break; | |
9550 | default: | |
9551 | break; | |
9552 | } | |
9553 | } | |
9554 | ||
9555 | /* Check the resources used by the given opcode against the current dependency | |
197865e8 | 9556 | list. |
800eeca4 JW |
9557 | |
9558 | The check is run once for each execution path encountered. In this case, | |
9559 | a unique execution path is the sequence of instructions following a code | |
9560 | entry point, e.g. the following has three execution paths, one starting | |
9561 | at L0, one at L1, and one at L2. | |
197865e8 | 9562 | |
800eeca4 JW |
9563 | L0: nop |
9564 | L1: add | |
9565 | L2: add | |
197865e8 | 9566 | br.ret |
800eeca4 | 9567 | */ |
542d6675 | 9568 | |
800eeca4 JW |
9569 | static void |
9570 | check_dependencies (idesc) | |
542d6675 | 9571 | struct ia64_opcode *idesc; |
800eeca4 JW |
9572 | { |
9573 | const struct ia64_opcode_dependency *opdeps = idesc->dependencies; | |
9574 | int path; | |
9575 | int i; | |
9576 | ||
9577 | /* Note that the number of marked resources may change within the | |
197865e8 | 9578 | loop if in auto mode. */ |
800eeca4 JW |
9579 | i = 0; |
9580 | while (i < regdepslen) | |
9581 | { | |
9582 | struct rsrc *rs = ®deps[i]; | |
9583 | const struct ia64_dependency *dep = rs->dependency; | |
9584 | int chkind; | |
9585 | int note; | |
9586 | int start_over = 0; | |
9587 | ||
9588 | if (dep->semantics == IA64_DVS_NONE | |
542d6675 KH |
9589 | || (chkind = depends_on (rs->depind, idesc)) == -1) |
9590 | { | |
9591 | ++i; | |
9592 | continue; | |
9593 | } | |
9594 | ||
9595 | note = NOTE (opdeps->chks[chkind]); | |
9596 | ||
9597 | /* Check this resource against each execution path seen thus far. */ | |
9598 | for (path = 0; path <= md.path; path++) | |
9599 | { | |
9600 | int matchtype; | |
9601 | ||
9602 | /* If the dependency wasn't on the path being checked, ignore it. */ | |
9603 | if (rs->path < path) | |
9604 | continue; | |
9605 | ||
9606 | /* If the QP for this insn implies a QP which has branched, don't | |
9607 | bother checking. Ed. NOTE: I don't think this check is terribly | |
9608 | useful; what's the point of generating code which will only be | |
9609 | reached if its QP is zero? | |
9610 | This code was specifically inserted to handle the following code, | |
9611 | based on notes from Intel's DV checking code, where p1 implies p2. | |
9612 | ||
9613 | mov r4 = 2 | |
9614 | (p2) br.cond L | |
9615 | (p1) mov r4 = 7 | |
9616 | */ | |
9617 | if (CURR_SLOT.qp_regno != 0) | |
9618 | { | |
9619 | int skip = 0; | |
9620 | int implies; | |
9621 | for (implies = 0; implies < qp_implieslen; implies++) | |
9622 | { | |
9623 | if (qp_implies[implies].path >= path | |
9624 | && qp_implies[implies].p1 == CURR_SLOT.qp_regno | |
9625 | && qp_implies[implies].p2_branched) | |
9626 | { | |
9627 | skip = 1; | |
9628 | break; | |
9629 | } | |
9630 | } | |
9631 | if (skip) | |
9632 | continue; | |
9633 | } | |
9634 | ||
9635 | if ((matchtype = resources_match (rs, idesc, note, | |
9636 | CURR_SLOT.qp_regno, path)) != 0) | |
9637 | { | |
9638 | char msg[1024]; | |
9639 | char pathmsg[256] = ""; | |
9640 | char indexmsg[256] = ""; | |
9641 | int certain = (matchtype == 1 && CURR_SLOT.qp_regno == 0); | |
9642 | ||
9643 | if (path != 0) | |
9644 | sprintf (pathmsg, " when entry is at label '%s'", | |
9645 | md.entry_labels[path - 1]); | |
9646 | if (rs->specific && rs->index != 0) | |
9647 | sprintf (indexmsg, ", specific resource number is %d", | |
9648 | rs->index); | |
9649 | sprintf (msg, "Use of '%s' %s %s dependency '%s' (%s)%s%s", | |
9650 | idesc->name, | |
9651 | (certain ? "violates" : "may violate"), | |
9652 | dv_mode[dep->mode], dep->name, | |
9653 | dv_sem[dep->semantics], | |
9654 | pathmsg, indexmsg); | |
9655 | ||
9656 | if (md.explicit_mode) | |
9657 | { | |
9658 | as_warn ("%s", msg); | |
9659 | if (path < md.path) | |
9660 | as_warn (_("Only the first path encountering the conflict " | |
9661 | "is reported")); | |
9662 | as_warn_where (rs->file, rs->line, | |
9663 | _("This is the location of the " | |
9664 | "conflicting usage")); | |
9665 | /* Don't bother checking other paths, to avoid duplicating | |
9666 | the same warning */ | |
9667 | break; | |
9668 | } | |
9669 | else | |
9670 | { | |
9671 | if (md.debug_dv) | |
9672 | fprintf (stderr, "%s @ %s:%d\n", msg, rs->file, rs->line); | |
9673 | ||
9674 | remove_marked_resource (rs); | |
9675 | ||
9676 | /* since the set of dependencies has changed, start over */ | |
9677 | /* FIXME -- since we're removing dvs as we go, we | |
9678 | probably don't really need to start over... */ | |
9679 | start_over = 1; | |
9680 | break; | |
9681 | } | |
9682 | } | |
9683 | } | |
800eeca4 | 9684 | if (start_over) |
542d6675 | 9685 | i = 0; |
800eeca4 | 9686 | else |
542d6675 | 9687 | ++i; |
800eeca4 JW |
9688 | } |
9689 | } | |
9690 | ||
542d6675 KH |
9691 | /* Register new dependencies based on the given opcode. */ |
9692 | ||
800eeca4 JW |
9693 | static void |
9694 | mark_resources (idesc) | |
542d6675 | 9695 | struct ia64_opcode *idesc; |
800eeca4 JW |
9696 | { |
9697 | int i; | |
9698 | const struct ia64_opcode_dependency *opdeps = idesc->dependencies; | |
9699 | int add_only_qp_reads = 0; | |
9700 | ||
9701 | /* A conditional branch only uses its resources if it is taken; if it is | |
9702 | taken, we stop following that path. The other branch types effectively | |
9703 | *always* write their resources. If it's not taken, register only QP | |
197865e8 | 9704 | reads. */ |
800eeca4 JW |
9705 | if (is_conditional_branch (idesc) || is_interruption_or_rfi (idesc)) |
9706 | { | |
9707 | add_only_qp_reads = 1; | |
9708 | } | |
9709 | ||
9710 | if (md.debug_dv) | |
9711 | fprintf (stderr, "Registering '%s' resource usage\n", idesc->name); | |
9712 | ||
542d6675 | 9713 | for (i = 0; i < opdeps->nregs; i++) |
800eeca4 JW |
9714 | { |
9715 | const struct ia64_dependency *dep; | |
9716 | struct rsrc specs[MAX_SPECS]; | |
9717 | int note; | |
9718 | int path; | |
9719 | int count; | |
197865e8 | 9720 | |
800eeca4 | 9721 | dep = ia64_find_dependency (opdeps->regs[i]); |
542d6675 | 9722 | note = NOTE (opdeps->regs[i]); |
800eeca4 JW |
9723 | |
9724 | if (add_only_qp_reads | |
542d6675 KH |
9725 | && !(dep->mode == IA64_DV_WAR |
9726 | && (dep->specifier == IA64_RS_PR | |
139368c9 | 9727 | || dep->specifier == IA64_RS_PRr |
542d6675 KH |
9728 | || dep->specifier == IA64_RS_PR63))) |
9729 | continue; | |
800eeca4 JW |
9730 | |
9731 | count = specify_resource (dep, idesc, DV_REG, specs, note, md.path); | |
9732 | ||
9733 | #if 0 | |
9734 | if (md.debug_dv && !count) | |
542d6675 KH |
9735 | fprintf (stderr, " No %s %s usage found (path %d)\n", |
9736 | dv_mode[dep->mode], dep->name, md.path); | |
800eeca4 | 9737 | #endif |
197865e8 | 9738 | |
800eeca4 | 9739 | while (count-- > 0) |
542d6675 KH |
9740 | { |
9741 | mark_resource (idesc, dep, &specs[count], | |
9742 | DEP (opdeps->regs[i]), md.path); | |
9743 | } | |
800eeca4 JW |
9744 | |
9745 | /* The execution path may affect register values, which may in turn | |
542d6675 | 9746 | affect which indirect-access resources are accessed. */ |
800eeca4 | 9747 | switch (dep->specifier) |
542d6675 KH |
9748 | { |
9749 | default: | |
9750 | break; | |
9751 | case IA64_RS_CPUID: | |
9752 | case IA64_RS_DBR: | |
9753 | case IA64_RS_IBR: | |
800eeca4 | 9754 | case IA64_RS_MSR: |
542d6675 KH |
9755 | case IA64_RS_PKR: |
9756 | case IA64_RS_PMC: | |
9757 | case IA64_RS_PMD: | |
9758 | case IA64_RS_RR: | |
9759 | for (path = 0; path < md.path; path++) | |
9760 | { | |
9761 | count = specify_resource (dep, idesc, DV_REG, specs, note, path); | |
9762 | while (count-- > 0) | |
9763 | mark_resource (idesc, dep, &specs[count], | |
9764 | DEP (opdeps->regs[i]), path); | |
9765 | } | |
9766 | break; | |
9767 | } | |
9768 | } | |
9769 | } | |
9770 | ||
9771 | /* Remove dependencies when they no longer apply. */ | |
9772 | ||
800eeca4 JW |
9773 | static void |
9774 | update_dependencies (idesc) | |
542d6675 | 9775 | struct ia64_opcode *idesc; |
800eeca4 JW |
9776 | { |
9777 | int i; | |
9778 | ||
9779 | if (strcmp (idesc->name, "srlz.i") == 0) | |
9780 | { | |
9781 | instruction_serialization (); | |
9782 | } | |
9783 | else if (strcmp (idesc->name, "srlz.d") == 0) | |
9784 | { | |
9785 | data_serialization (); | |
9786 | } | |
9787 | else if (is_interruption_or_rfi (idesc) | |
542d6675 | 9788 | || is_taken_branch (idesc)) |
800eeca4 | 9789 | { |
542d6675 KH |
9790 | /* Although technically the taken branch doesn't clear dependencies |
9791 | which require a srlz.[id], we don't follow the branch; the next | |
9792 | instruction is assumed to start with a clean slate. */ | |
800eeca4 | 9793 | regdepslen = 0; |
800eeca4 JW |
9794 | md.path = 0; |
9795 | } | |
9796 | else if (is_conditional_branch (idesc) | |
542d6675 | 9797 | && CURR_SLOT.qp_regno != 0) |
800eeca4 JW |
9798 | { |
9799 | int is_call = strstr (idesc->name, ".call") != NULL; | |
9800 | ||
542d6675 KH |
9801 | for (i = 0; i < qp_implieslen; i++) |
9802 | { | |
9803 | /* If the conditional branch's predicate is implied by the predicate | |
9804 | in an existing dependency, remove that dependency. */ | |
9805 | if (qp_implies[i].p2 == CURR_SLOT.qp_regno) | |
9806 | { | |
9807 | int depind = 0; | |
9808 | /* Note that this implied predicate takes a branch so that if | |
9809 | a later insn generates a DV but its predicate implies this | |
9810 | one, we can avoid the false DV warning. */ | |
9811 | qp_implies[i].p2_branched = 1; | |
9812 | while (depind < regdepslen) | |
9813 | { | |
9814 | if (regdeps[depind].qp_regno == qp_implies[i].p1) | |
9815 | { | |
9816 | print_dependency ("Removing", depind); | |
9817 | regdeps[depind] = regdeps[--regdepslen]; | |
9818 | } | |
9819 | else | |
9820 | ++depind; | |
9821 | } | |
9822 | } | |
9823 | } | |
800eeca4 | 9824 | /* Any marked resources which have this same predicate should be |
542d6675 KH |
9825 | cleared, provided that the QP hasn't been modified between the |
9826 | marking instruction and the branch. */ | |
800eeca4 | 9827 | if (is_call) |
542d6675 KH |
9828 | { |
9829 | insn_group_break (0, CURR_SLOT.qp_regno, 1); | |
9830 | } | |
800eeca4 | 9831 | else |
542d6675 KH |
9832 | { |
9833 | i = 0; | |
9834 | while (i < regdepslen) | |
9835 | { | |
9836 | if (regdeps[i].qp_regno == CURR_SLOT.qp_regno | |
9837 | && regdeps[i].link_to_qp_branch | |
9838 | && (regdeps[i].file != CURR_SLOT.src_file | |
9839 | || regdeps[i].line != CURR_SLOT.src_line)) | |
9840 | { | |
9841 | /* Treat like a taken branch */ | |
9842 | print_dependency ("Removing", i); | |
9843 | regdeps[i] = regdeps[--regdepslen]; | |
9844 | } | |
9845 | else | |
9846 | ++i; | |
9847 | } | |
9848 | } | |
800eeca4 JW |
9849 | } |
9850 | } | |
9851 | ||
9852 | /* Examine the current instruction for dependency violations. */ | |
542d6675 | 9853 | |
800eeca4 JW |
9854 | static int |
9855 | check_dv (idesc) | |
542d6675 | 9856 | struct ia64_opcode *idesc; |
800eeca4 JW |
9857 | { |
9858 | if (md.debug_dv) | |
9859 | { | |
197865e8 | 9860 | fprintf (stderr, "Checking %s for violations (line %d, %d/%d)\n", |
542d6675 KH |
9861 | idesc->name, CURR_SLOT.src_line, |
9862 | idesc->dependencies->nchks, | |
9863 | idesc->dependencies->nregs); | |
800eeca4 JW |
9864 | } |
9865 | ||
197865e8 | 9866 | /* Look through the list of currently marked resources; if the current |
800eeca4 | 9867 | instruction has the dependency in its chks list which uses that resource, |
542d6675 | 9868 | check against the specific resources used. */ |
800eeca4 JW |
9869 | check_dependencies (idesc); |
9870 | ||
542d6675 KH |
9871 | /* Look up the instruction's regdeps (RAW writes, WAW writes, and WAR reads), |
9872 | then add them to the list of marked resources. */ | |
800eeca4 JW |
9873 | mark_resources (idesc); |
9874 | ||
9875 | /* There are several types of dependency semantics, and each has its own | |
197865e8 KH |
9876 | requirements for being cleared |
9877 | ||
800eeca4 JW |
9878 | Instruction serialization (insns separated by interruption, rfi, or |
9879 | writer + srlz.i + reader, all in separate groups) clears DVS_INSTR. | |
9880 | ||
9881 | Data serialization (instruction serialization, or writer + srlz.d + | |
9882 | reader, where writer and srlz.d are in separate groups) clears | |
9883 | DVS_DATA. (This also clears DVS_OTHER, but that is not guaranteed to | |
9884 | always be the case). | |
9885 | ||
9886 | Instruction group break (groups separated by stop, taken branch, | |
9887 | interruption or rfi) clears DVS_IMPLIED and DVS_IMPLIEDF. | |
9888 | */ | |
9889 | update_dependencies (idesc); | |
9890 | ||
9891 | /* Sometimes, knowing a register value allows us to avoid giving a false DV | |
197865e8 | 9892 | warning. Keep track of as many as possible that are useful. */ |
800eeca4 JW |
9893 | note_register_values (idesc); |
9894 | ||
197865e8 | 9895 | /* We don't need or want this anymore. */ |
800eeca4 JW |
9896 | md.mem_offset.hint = 0; |
9897 | ||
9898 | return 0; | |
9899 | } | |
9900 | ||
9901 | /* Translate one line of assembly. Pseudo ops and labels do not show | |
9902 | here. */ | |
9903 | void | |
9904 | md_assemble (str) | |
9905 | char *str; | |
9906 | { | |
9907 | char *saved_input_line_pointer, *mnemonic; | |
9908 | const struct pseudo_opcode *pdesc; | |
9909 | struct ia64_opcode *idesc; | |
9910 | unsigned char qp_regno; | |
9911 | unsigned int flags; | |
9912 | int ch; | |
9913 | ||
9914 | saved_input_line_pointer = input_line_pointer; | |
9915 | input_line_pointer = str; | |
9916 | ||
542d6675 | 9917 | /* extract the opcode (mnemonic): */ |
800eeca4 JW |
9918 | |
9919 | mnemonic = input_line_pointer; | |
9920 | ch = get_symbol_end (); | |
9921 | pdesc = (struct pseudo_opcode *) hash_find (md.pseudo_hash, mnemonic); | |
9922 | if (pdesc) | |
9923 | { | |
9924 | *input_line_pointer = ch; | |
9925 | (*pdesc->handler) (pdesc->arg); | |
9926 | goto done; | |
9927 | } | |
9928 | ||
542d6675 | 9929 | /* Find the instruction descriptor matching the arguments. */ |
800eeca4 JW |
9930 | |
9931 | idesc = ia64_find_opcode (mnemonic); | |
9932 | *input_line_pointer = ch; | |
9933 | if (!idesc) | |
9934 | { | |
9935 | as_bad ("Unknown opcode `%s'", mnemonic); | |
9936 | goto done; | |
9937 | } | |
9938 | ||
9939 | idesc = parse_operands (idesc); | |
9940 | if (!idesc) | |
9941 | goto done; | |
9942 | ||
542d6675 | 9943 | /* Handle the dynamic ops we can handle now: */ |
800eeca4 JW |
9944 | if (idesc->type == IA64_TYPE_DYN) |
9945 | { | |
9946 | if (strcmp (idesc->name, "add") == 0) | |
9947 | { | |
9948 | if (CURR_SLOT.opnd[2].X_op == O_register | |
9949 | && CURR_SLOT.opnd[2].X_add_number < 4) | |
9950 | mnemonic = "addl"; | |
9951 | else | |
9952 | mnemonic = "adds"; | |
3d56ab85 | 9953 | ia64_free_opcode (idesc); |
800eeca4 JW |
9954 | idesc = ia64_find_opcode (mnemonic); |
9955 | #if 0 | |
9956 | know (!idesc->next); | |
9957 | #endif | |
9958 | } | |
9959 | else if (strcmp (idesc->name, "mov") == 0) | |
9960 | { | |
9961 | enum ia64_opnd opnd1, opnd2; | |
9962 | int rop; | |
9963 | ||
9964 | opnd1 = idesc->operands[0]; | |
9965 | opnd2 = idesc->operands[1]; | |
9966 | if (opnd1 == IA64_OPND_AR3) | |
9967 | rop = 0; | |
9968 | else if (opnd2 == IA64_OPND_AR3) | |
9969 | rop = 1; | |
9970 | else | |
9971 | abort (); | |
9972 | if (CURR_SLOT.opnd[rop].X_op == O_register | |
9973 | && ar_is_in_integer_unit (CURR_SLOT.opnd[rop].X_add_number)) | |
9974 | mnemonic = "mov.i"; | |
9975 | else | |
9976 | mnemonic = "mov.m"; | |
3d56ab85 | 9977 | ia64_free_opcode (idesc); |
800eeca4 JW |
9978 | idesc = ia64_find_opcode (mnemonic); |
9979 | while (idesc != NULL | |
9980 | && (idesc->operands[0] != opnd1 | |
9981 | || idesc->operands[1] != opnd2)) | |
9982 | idesc = get_next_opcode (idesc); | |
9983 | } | |
9984 | } | |
9985 | ||
9986 | qp_regno = 0; | |
9987 | if (md.qp.X_op == O_register) | |
f1bcba5b JW |
9988 | { |
9989 | qp_regno = md.qp.X_add_number - REG_P; | |
9990 | md.qp.X_op = O_absent; | |
9991 | } | |
800eeca4 JW |
9992 | |
9993 | flags = idesc->flags; | |
9994 | ||
9995 | if ((flags & IA64_OPCODE_FIRST) != 0) | |
9545c4ce L |
9996 | { |
9997 | /* The alignment frag has to end with a stop bit only if the | |
9998 | next instruction after the alignment directive has to be | |
9999 | the first instruction in an instruction group. */ | |
10000 | if (align_frag) | |
10001 | { | |
10002 | while (align_frag->fr_type != rs_align_code) | |
10003 | { | |
10004 | align_frag = align_frag->fr_next; | |
10005 | assert (align_frag); | |
10006 | } | |
10007 | if (align_frag->fr_next == frag_now) | |
10008 | align_frag->tc_frag_data = 1; | |
10009 | } | |
10010 | ||
10011 | insn_group_break (1, 0, 0); | |
10012 | } | |
10013 | align_frag = NULL; | |
800eeca4 JW |
10014 | |
10015 | if ((flags & IA64_OPCODE_NO_PRED) != 0 && qp_regno != 0) | |
10016 | { | |
10017 | as_bad ("`%s' cannot be predicated", idesc->name); | |
10018 | goto done; | |
10019 | } | |
10020 | ||
542d6675 | 10021 | /* Build the instruction. */ |
800eeca4 JW |
10022 | CURR_SLOT.qp_regno = qp_regno; |
10023 | CURR_SLOT.idesc = idesc; | |
10024 | as_where (&CURR_SLOT.src_file, &CURR_SLOT.src_line); | |
4dc7ead9 | 10025 | dwarf2_where (&CURR_SLOT.debug_line); |
800eeca4 JW |
10026 | |
10027 | /* Add unwind entry, if there is one. */ | |
e0c9811a | 10028 | if (unwind.current_entry) |
800eeca4 | 10029 | { |
e0c9811a JW |
10030 | CURR_SLOT.unwind_record = unwind.current_entry; |
10031 | unwind.current_entry = NULL; | |
800eeca4 JW |
10032 | } |
10033 | ||
542d6675 | 10034 | /* Check for dependency violations. */ |
800eeca4 | 10035 | if (md.detect_dv) |
542d6675 | 10036 | check_dv (idesc); |
800eeca4 JW |
10037 | |
10038 | md.curr_slot = (md.curr_slot + 1) % NUM_SLOTS; | |
10039 | if (++md.num_slots_in_use >= NUM_SLOTS) | |
10040 | emit_one_bundle (); | |
10041 | ||
10042 | if ((flags & IA64_OPCODE_LAST) != 0) | |
10043 | insn_group_break (1, 0, 0); | |
10044 | ||
10045 | md.last_text_seg = now_seg; | |
10046 | ||
10047 | done: | |
10048 | input_line_pointer = saved_input_line_pointer; | |
10049 | } | |
10050 | ||
10051 | /* Called when symbol NAME cannot be found in the symbol table. | |
10052 | Should be used for dynamic valued symbols only. */ | |
542d6675 KH |
10053 | |
10054 | symbolS * | |
800eeca4 | 10055 | md_undefined_symbol (name) |
2434f565 | 10056 | char *name ATTRIBUTE_UNUSED; |
800eeca4 JW |
10057 | { |
10058 | return 0; | |
10059 | } | |
10060 | ||
10061 | /* Called for any expression that can not be recognized. When the | |
10062 | function is called, `input_line_pointer' will point to the start of | |
10063 | the expression. */ | |
542d6675 | 10064 | |
800eeca4 JW |
10065 | void |
10066 | md_operand (e) | |
10067 | expressionS *e; | |
10068 | { | |
10069 | enum pseudo_type pseudo_type; | |
e0c9811a | 10070 | const char *name; |
800eeca4 JW |
10071 | size_t len; |
10072 | int ch, i; | |
10073 | ||
10074 | switch (*input_line_pointer) | |
10075 | { | |
10076 | case '@': | |
542d6675 | 10077 | /* Find what relocation pseudo-function we're dealing with. */ |
800eeca4 JW |
10078 | pseudo_type = 0; |
10079 | ch = *++input_line_pointer; | |
10080 | for (i = 0; i < NELEMS (pseudo_func); ++i) | |
10081 | if (pseudo_func[i].name && pseudo_func[i].name[0] == ch) | |
10082 | { | |
10083 | len = strlen (pseudo_func[i].name); | |
10084 | if (strncmp (pseudo_func[i].name + 1, | |
10085 | input_line_pointer + 1, len - 1) == 0 | |
10086 | && !is_part_of_name (input_line_pointer[len])) | |
10087 | { | |
10088 | input_line_pointer += len; | |
10089 | pseudo_type = pseudo_func[i].type; | |
10090 | break; | |
10091 | } | |
10092 | } | |
10093 | switch (pseudo_type) | |
10094 | { | |
10095 | case PSEUDO_FUNC_RELOC: | |
10096 | SKIP_WHITESPACE (); | |
10097 | if (*input_line_pointer != '(') | |
10098 | { | |
10099 | as_bad ("Expected '('"); | |
10100 | goto err; | |
10101 | } | |
542d6675 KH |
10102 | /* Skip '('. */ |
10103 | ++input_line_pointer; | |
800eeca4 JW |
10104 | expression (e); |
10105 | if (*input_line_pointer++ != ')') | |
10106 | { | |
10107 | as_bad ("Missing ')'"); | |
10108 | goto err; | |
10109 | } | |
10110 | if (e->X_op != O_symbol) | |
10111 | { | |
10112 | if (e->X_op != O_pseudo_fixup) | |
10113 | { | |
10114 | as_bad ("Not a symbolic expression"); | |
10115 | goto err; | |
10116 | } | |
13ae64f3 JJ |
10117 | if (i != FUNC_LT_RELATIVE) |
10118 | { | |
10119 | as_bad ("Illegal combination of relocation functions"); | |
10120 | goto err; | |
10121 | } | |
10122 | switch (S_GET_VALUE (e->X_op_symbol)) | |
800eeca4 | 10123 | { |
13ae64f3 JJ |
10124 | case FUNC_FPTR_RELATIVE: |
10125 | i = FUNC_LT_FPTR_RELATIVE; break; | |
10126 | case FUNC_DTP_MODULE: | |
10127 | i = FUNC_LT_DTP_MODULE; break; | |
10128 | case FUNC_DTP_RELATIVE: | |
10129 | i = FUNC_LT_DTP_RELATIVE; break; | |
10130 | case FUNC_TP_RELATIVE: | |
10131 | i = FUNC_LT_TP_RELATIVE; break; | |
10132 | default: | |
800eeca4 JW |
10133 | as_bad ("Illegal combination of relocation functions"); |
10134 | goto err; | |
10135 | } | |
10136 | } | |
542d6675 KH |
10137 | /* Make sure gas doesn't get rid of local symbols that are used |
10138 | in relocs. */ | |
800eeca4 JW |
10139 | e->X_op = O_pseudo_fixup; |
10140 | e->X_op_symbol = pseudo_func[i].u.sym; | |
10141 | break; | |
10142 | ||
10143 | case PSEUDO_FUNC_CONST: | |
10144 | e->X_op = O_constant; | |
10145 | e->X_add_number = pseudo_func[i].u.ival; | |
10146 | break; | |
10147 | ||
e0c9811a JW |
10148 | case PSEUDO_FUNC_REG: |
10149 | e->X_op = O_register; | |
10150 | e->X_add_number = pseudo_func[i].u.ival; | |
10151 | break; | |
10152 | ||
800eeca4 | 10153 | default: |
e0c9811a JW |
10154 | name = input_line_pointer - 1; |
10155 | get_symbol_end (); | |
10156 | as_bad ("Unknown pseudo function `%s'", name); | |
800eeca4 JW |
10157 | goto err; |
10158 | } | |
10159 | break; | |
10160 | ||
10161 | case '[': | |
10162 | ++input_line_pointer; | |
10163 | expression (e); | |
10164 | if (*input_line_pointer != ']') | |
10165 | { | |
10166 | as_bad ("Closing bracket misssing"); | |
10167 | goto err; | |
10168 | } | |
10169 | else | |
10170 | { | |
10171 | if (e->X_op != O_register) | |
10172 | as_bad ("Register expected as index"); | |
10173 | ||
10174 | ++input_line_pointer; | |
10175 | e->X_op = O_index; | |
10176 | } | |
10177 | break; | |
10178 | ||
10179 | default: | |
10180 | break; | |
10181 | } | |
10182 | return; | |
10183 | ||
10184 | err: | |
10185 | ignore_rest_of_line (); | |
10186 | } | |
10187 | ||
10188 | /* Return 1 if it's OK to adjust a reloc by replacing the symbol with | |
10189 | a section symbol plus some offset. For relocs involving @fptr(), | |
10190 | directives we don't want such adjustments since we need to have the | |
10191 | original symbol's name in the reloc. */ | |
10192 | int | |
10193 | ia64_fix_adjustable (fix) | |
10194 | fixS *fix; | |
10195 | { | |
10196 | /* Prevent all adjustments to global symbols */ | |
10197 | if (S_IS_EXTERN (fix->fx_addsy) || S_IS_WEAK (fix->fx_addsy)) | |
10198 | return 0; | |
10199 | ||
10200 | switch (fix->fx_r_type) | |
10201 | { | |
10202 | case BFD_RELOC_IA64_FPTR64I: | |
10203 | case BFD_RELOC_IA64_FPTR32MSB: | |
10204 | case BFD_RELOC_IA64_FPTR32LSB: | |
10205 | case BFD_RELOC_IA64_FPTR64MSB: | |
10206 | case BFD_RELOC_IA64_FPTR64LSB: | |
10207 | case BFD_RELOC_IA64_LTOFF_FPTR22: | |
10208 | case BFD_RELOC_IA64_LTOFF_FPTR64I: | |
10209 | return 0; | |
10210 | default: | |
10211 | break; | |
10212 | } | |
10213 | ||
10214 | return 1; | |
10215 | } | |
10216 | ||
10217 | int | |
10218 | ia64_force_relocation (fix) | |
10219 | fixS *fix; | |
10220 | { | |
10221 | switch (fix->fx_r_type) | |
10222 | { | |
10223 | case BFD_RELOC_IA64_FPTR64I: | |
10224 | case BFD_RELOC_IA64_FPTR32MSB: | |
10225 | case BFD_RELOC_IA64_FPTR32LSB: | |
10226 | case BFD_RELOC_IA64_FPTR64MSB: | |
10227 | case BFD_RELOC_IA64_FPTR64LSB: | |
10228 | ||
10229 | case BFD_RELOC_IA64_LTOFF22: | |
10230 | case BFD_RELOC_IA64_LTOFF64I: | |
10231 | case BFD_RELOC_IA64_LTOFF_FPTR22: | |
10232 | case BFD_RELOC_IA64_LTOFF_FPTR64I: | |
10233 | case BFD_RELOC_IA64_PLTOFF22: | |
10234 | case BFD_RELOC_IA64_PLTOFF64I: | |
10235 | case BFD_RELOC_IA64_PLTOFF64MSB: | |
10236 | case BFD_RELOC_IA64_PLTOFF64LSB: | |
fa2c7eff RH |
10237 | |
10238 | case BFD_RELOC_IA64_LTOFF22X: | |
10239 | case BFD_RELOC_IA64_LDXMOV: | |
800eeca4 JW |
10240 | return 1; |
10241 | ||
10242 | default: | |
a161fe53 | 10243 | break; |
800eeca4 | 10244 | } |
a161fe53 | 10245 | |
ae6063d4 | 10246 | return generic_force_reloc (fix); |
800eeca4 JW |
10247 | } |
10248 | ||
10249 | /* Decide from what point a pc-relative relocation is relative to, | |
10250 | relative to the pc-relative fixup. Er, relatively speaking. */ | |
10251 | long | |
10252 | ia64_pcrel_from_section (fix, sec) | |
10253 | fixS *fix; | |
10254 | segT sec; | |
10255 | { | |
10256 | unsigned long off = fix->fx_frag->fr_address + fix->fx_where; | |
197865e8 | 10257 | |
800eeca4 JW |
10258 | if (bfd_get_section_flags (stdoutput, sec) & SEC_CODE) |
10259 | off &= ~0xfUL; | |
10260 | ||
10261 | return off; | |
10262 | } | |
10263 | ||
6174d9c8 RH |
10264 | |
10265 | /* Used to emit section-relative relocs for the dwarf2 debug data. */ | |
10266 | void | |
10267 | ia64_dwarf2_emit_offset (symbolS *symbol, unsigned int size) | |
10268 | { | |
10269 | expressionS expr; | |
10270 | ||
10271 | expr.X_op = O_pseudo_fixup; | |
10272 | expr.X_op_symbol = pseudo_func[FUNC_SEC_RELATIVE].u.sym; | |
10273 | expr.X_add_number = 0; | |
10274 | expr.X_add_symbol = symbol; | |
10275 | emit_expr (&expr, size); | |
10276 | } | |
10277 | ||
800eeca4 JW |
10278 | /* This is called whenever some data item (not an instruction) needs a |
10279 | fixup. We pick the right reloc code depending on the byteorder | |
10280 | currently in effect. */ | |
10281 | void | |
10282 | ia64_cons_fix_new (f, where, nbytes, exp) | |
10283 | fragS *f; | |
10284 | int where; | |
10285 | int nbytes; | |
10286 | expressionS *exp; | |
10287 | { | |
10288 | bfd_reloc_code_real_type code; | |
10289 | fixS *fix; | |
10290 | ||
10291 | switch (nbytes) | |
10292 | { | |
10293 | /* There are no reloc for 8 and 16 bit quantities, but we allow | |
10294 | them here since they will work fine as long as the expression | |
10295 | is fully defined at the end of the pass over the source file. */ | |
10296 | case 1: code = BFD_RELOC_8; break; | |
10297 | case 2: code = BFD_RELOC_16; break; | |
10298 | case 4: | |
10299 | if (target_big_endian) | |
10300 | code = BFD_RELOC_IA64_DIR32MSB; | |
10301 | else | |
10302 | code = BFD_RELOC_IA64_DIR32LSB; | |
10303 | break; | |
10304 | ||
10305 | case 8: | |
40449e9f | 10306 | /* In 32-bit mode, data8 could mean function descriptors too. */ |
5f44c186 | 10307 | if (exp->X_op == O_pseudo_fixup |
40449e9f KH |
10308 | && exp->X_op_symbol |
10309 | && S_GET_VALUE (exp->X_op_symbol) == FUNC_IPLT_RELOC | |
10310 | && !(md.flags & EF_IA_64_ABI64)) | |
10311 | { | |
10312 | if (target_big_endian) | |
10313 | code = BFD_RELOC_IA64_IPLTMSB; | |
10314 | else | |
10315 | code = BFD_RELOC_IA64_IPLTLSB; | |
10316 | exp->X_op = O_symbol; | |
10317 | break; | |
10318 | } | |
10319 | else | |
10320 | { | |
10321 | if (target_big_endian) | |
10322 | code = BFD_RELOC_IA64_DIR64MSB; | |
10323 | else | |
10324 | code = BFD_RELOC_IA64_DIR64LSB; | |
10325 | break; | |
10326 | } | |
800eeca4 | 10327 | |
3969b680 RH |
10328 | case 16: |
10329 | if (exp->X_op == O_pseudo_fixup | |
10330 | && exp->X_op_symbol | |
10331 | && S_GET_VALUE (exp->X_op_symbol) == FUNC_IPLT_RELOC) | |
10332 | { | |
10333 | if (target_big_endian) | |
10334 | code = BFD_RELOC_IA64_IPLTMSB; | |
10335 | else | |
10336 | code = BFD_RELOC_IA64_IPLTLSB; | |
3969b680 RH |
10337 | exp->X_op = O_symbol; |
10338 | break; | |
10339 | } | |
10340 | /* FALLTHRU */ | |
10341 | ||
800eeca4 JW |
10342 | default: |
10343 | as_bad ("Unsupported fixup size %d", nbytes); | |
10344 | ignore_rest_of_line (); | |
10345 | return; | |
10346 | } | |
6174d9c8 | 10347 | |
800eeca4 JW |
10348 | if (exp->X_op == O_pseudo_fixup) |
10349 | { | |
800eeca4 JW |
10350 | exp->X_op = O_symbol; |
10351 | code = ia64_gen_real_reloc_type (exp->X_op_symbol, code); | |
6174d9c8 | 10352 | /* ??? If code unchanged, unsupported. */ |
800eeca4 | 10353 | } |
3969b680 | 10354 | |
800eeca4 JW |
10355 | fix = fix_new_exp (f, where, nbytes, exp, 0, code); |
10356 | /* We need to store the byte order in effect in case we're going | |
10357 | to fix an 8 or 16 bit relocation (for which there no real | |
94f592af | 10358 | relocs available). See md_apply_fix3(). */ |
800eeca4 JW |
10359 | fix->tc_fix_data.bigendian = target_big_endian; |
10360 | } | |
10361 | ||
10362 | /* Return the actual relocation we wish to associate with the pseudo | |
10363 | reloc described by SYM and R_TYPE. SYM should be one of the | |
197865e8 | 10364 | symbols in the pseudo_func array, or NULL. */ |
800eeca4 JW |
10365 | |
10366 | static bfd_reloc_code_real_type | |
10367 | ia64_gen_real_reloc_type (sym, r_type) | |
10368 | struct symbol *sym; | |
10369 | bfd_reloc_code_real_type r_type; | |
10370 | { | |
10371 | bfd_reloc_code_real_type new = 0; | |
10372 | ||
10373 | if (sym == NULL) | |
10374 | { | |
10375 | return r_type; | |
10376 | } | |
10377 | ||
10378 | switch (S_GET_VALUE (sym)) | |
10379 | { | |
10380 | case FUNC_FPTR_RELATIVE: | |
10381 | switch (r_type) | |
10382 | { | |
10383 | case BFD_RELOC_IA64_IMM64: new = BFD_RELOC_IA64_FPTR64I; break; | |
10384 | case BFD_RELOC_IA64_DIR32MSB: new = BFD_RELOC_IA64_FPTR32MSB; break; | |
10385 | case BFD_RELOC_IA64_DIR32LSB: new = BFD_RELOC_IA64_FPTR32LSB; break; | |
10386 | case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_FPTR64MSB; break; | |
10387 | case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_FPTR64LSB; break; | |
10388 | default: break; | |
10389 | } | |
10390 | break; | |
10391 | ||
10392 | case FUNC_GP_RELATIVE: | |
10393 | switch (r_type) | |
10394 | { | |
10395 | case BFD_RELOC_IA64_IMM22: new = BFD_RELOC_IA64_GPREL22; break; | |
10396 | case BFD_RELOC_IA64_IMM64: new = BFD_RELOC_IA64_GPREL64I; break; | |
10397 | case BFD_RELOC_IA64_DIR32MSB: new = BFD_RELOC_IA64_GPREL32MSB; break; | |
10398 | case BFD_RELOC_IA64_DIR32LSB: new = BFD_RELOC_IA64_GPREL32LSB; break; | |
10399 | case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_GPREL64MSB; break; | |
10400 | case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_GPREL64LSB; break; | |
10401 | default: break; | |
10402 | } | |
10403 | break; | |
10404 | ||
10405 | case FUNC_LT_RELATIVE: | |
10406 | switch (r_type) | |
10407 | { | |
10408 | case BFD_RELOC_IA64_IMM22: new = BFD_RELOC_IA64_LTOFF22; break; | |
10409 | case BFD_RELOC_IA64_IMM64: new = BFD_RELOC_IA64_LTOFF64I; break; | |
10410 | default: break; | |
10411 | } | |
10412 | break; | |
10413 | ||
fa2c7eff RH |
10414 | case FUNC_LT_RELATIVE_X: |
10415 | switch (r_type) | |
10416 | { | |
10417 | case BFD_RELOC_IA64_IMM22: new = BFD_RELOC_IA64_LTOFF22X; break; | |
10418 | default: break; | |
10419 | } | |
10420 | break; | |
10421 | ||
c67e42c9 RH |
10422 | case FUNC_PC_RELATIVE: |
10423 | switch (r_type) | |
10424 | { | |
10425 | case BFD_RELOC_IA64_IMM22: new = BFD_RELOC_IA64_PCREL22; break; | |
10426 | case BFD_RELOC_IA64_IMM64: new = BFD_RELOC_IA64_PCREL64I; break; | |
10427 | case BFD_RELOC_IA64_DIR32MSB: new = BFD_RELOC_IA64_PCREL32MSB; break; | |
10428 | case BFD_RELOC_IA64_DIR32LSB: new = BFD_RELOC_IA64_PCREL32LSB; break; | |
10429 | case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_PCREL64MSB; break; | |
10430 | case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_PCREL64LSB; break; | |
10431 | default: break; | |
10432 | } | |
10433 | break; | |
10434 | ||
800eeca4 JW |
10435 | case FUNC_PLT_RELATIVE: |
10436 | switch (r_type) | |
10437 | { | |
10438 | case BFD_RELOC_IA64_IMM22: new = BFD_RELOC_IA64_PLTOFF22; break; | |
10439 | case BFD_RELOC_IA64_IMM64: new = BFD_RELOC_IA64_PLTOFF64I; break; | |
10440 | case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_PLTOFF64MSB;break; | |
10441 | case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_PLTOFF64LSB;break; | |
10442 | default: break; | |
10443 | } | |
10444 | break; | |
10445 | ||
10446 | case FUNC_SEC_RELATIVE: | |
10447 | switch (r_type) | |
10448 | { | |
10449 | case BFD_RELOC_IA64_DIR32MSB: new = BFD_RELOC_IA64_SECREL32MSB;break; | |
10450 | case BFD_RELOC_IA64_DIR32LSB: new = BFD_RELOC_IA64_SECREL32LSB;break; | |
10451 | case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_SECREL64MSB;break; | |
10452 | case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_SECREL64LSB;break; | |
10453 | default: break; | |
10454 | } | |
10455 | break; | |
10456 | ||
10457 | case FUNC_SEG_RELATIVE: | |
10458 | switch (r_type) | |
10459 | { | |
10460 | case BFD_RELOC_IA64_DIR32MSB: new = BFD_RELOC_IA64_SEGREL32MSB;break; | |
10461 | case BFD_RELOC_IA64_DIR32LSB: new = BFD_RELOC_IA64_SEGREL32LSB;break; | |
10462 | case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_SEGREL64MSB;break; | |
10463 | case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_SEGREL64LSB;break; | |
10464 | default: break; | |
10465 | } | |
10466 | break; | |
10467 | ||
10468 | case FUNC_LTV_RELATIVE: | |
10469 | switch (r_type) | |
10470 | { | |
10471 | case BFD_RELOC_IA64_DIR32MSB: new = BFD_RELOC_IA64_LTV32MSB; break; | |
10472 | case BFD_RELOC_IA64_DIR32LSB: new = BFD_RELOC_IA64_LTV32LSB; break; | |
10473 | case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_LTV64MSB; break; | |
10474 | case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_LTV64LSB; break; | |
10475 | default: break; | |
10476 | } | |
10477 | break; | |
10478 | ||
10479 | case FUNC_LT_FPTR_RELATIVE: | |
10480 | switch (r_type) | |
10481 | { | |
10482 | case BFD_RELOC_IA64_IMM22: | |
10483 | new = BFD_RELOC_IA64_LTOFF_FPTR22; break; | |
10484 | case BFD_RELOC_IA64_IMM64: | |
10485 | new = BFD_RELOC_IA64_LTOFF_FPTR64I; break; | |
10486 | default: | |
10487 | break; | |
10488 | } | |
10489 | break; | |
3969b680 | 10490 | |
13ae64f3 JJ |
10491 | case FUNC_TP_RELATIVE: |
10492 | switch (r_type) | |
10493 | { | |
10494 | case BFD_RELOC_IA64_IMM14: | |
10495 | new = BFD_RELOC_IA64_TPREL14; break; | |
10496 | case BFD_RELOC_IA64_IMM22: | |
10497 | new = BFD_RELOC_IA64_TPREL22; break; | |
10498 | case BFD_RELOC_IA64_IMM64: | |
10499 | new = BFD_RELOC_IA64_TPREL64I; break; | |
10500 | default: | |
10501 | break; | |
10502 | } | |
10503 | break; | |
10504 | ||
10505 | case FUNC_LT_TP_RELATIVE: | |
10506 | switch (r_type) | |
10507 | { | |
10508 | case BFD_RELOC_IA64_IMM22: | |
10509 | new = BFD_RELOC_IA64_LTOFF_TPREL22; break; | |
10510 | default: | |
10511 | break; | |
10512 | } | |
10513 | break; | |
10514 | ||
10515 | case FUNC_LT_DTP_MODULE: | |
10516 | switch (r_type) | |
10517 | { | |
10518 | case BFD_RELOC_IA64_IMM22: | |
10519 | new = BFD_RELOC_IA64_LTOFF_DTPMOD22; break; | |
10520 | default: | |
10521 | break; | |
10522 | } | |
10523 | break; | |
10524 | ||
10525 | case FUNC_DTP_RELATIVE: | |
10526 | switch (r_type) | |
10527 | { | |
6174d9c8 RH |
10528 | case BFD_RELOC_IA64_DIR64MSB: |
10529 | new = BFD_RELOC_IA64_DTPREL64MSB; break; | |
10530 | case BFD_RELOC_IA64_DIR64LSB: | |
10531 | new = BFD_RELOC_IA64_DTPREL64LSB; break; | |
13ae64f3 JJ |
10532 | case BFD_RELOC_IA64_IMM14: |
10533 | new = BFD_RELOC_IA64_DTPREL14; break; | |
10534 | case BFD_RELOC_IA64_IMM22: | |
10535 | new = BFD_RELOC_IA64_DTPREL22; break; | |
10536 | case BFD_RELOC_IA64_IMM64: | |
10537 | new = BFD_RELOC_IA64_DTPREL64I; break; | |
10538 | default: | |
10539 | break; | |
10540 | } | |
10541 | break; | |
10542 | ||
10543 | case FUNC_LT_DTP_RELATIVE: | |
10544 | switch (r_type) | |
10545 | { | |
10546 | case BFD_RELOC_IA64_IMM22: | |
10547 | new = BFD_RELOC_IA64_LTOFF_DTPREL22; break; | |
10548 | default: | |
10549 | break; | |
10550 | } | |
10551 | break; | |
10552 | ||
40449e9f KH |
10553 | case FUNC_IPLT_RELOC: |
10554 | break; | |
1cd8ff38 | 10555 | |
800eeca4 JW |
10556 | default: |
10557 | abort (); | |
10558 | } | |
6174d9c8 | 10559 | |
800eeca4 JW |
10560 | /* Hmmmm. Should this ever occur? */ |
10561 | if (new) | |
10562 | return new; | |
10563 | else | |
10564 | return r_type; | |
10565 | } | |
10566 | ||
10567 | /* Here is where generate the appropriate reloc for pseudo relocation | |
10568 | functions. */ | |
10569 | void | |
10570 | ia64_validate_fix (fix) | |
10571 | fixS *fix; | |
10572 | { | |
10573 | switch (fix->fx_r_type) | |
10574 | { | |
10575 | case BFD_RELOC_IA64_FPTR64I: | |
10576 | case BFD_RELOC_IA64_FPTR32MSB: | |
10577 | case BFD_RELOC_IA64_FPTR64LSB: | |
10578 | case BFD_RELOC_IA64_LTOFF_FPTR22: | |
10579 | case BFD_RELOC_IA64_LTOFF_FPTR64I: | |
10580 | if (fix->fx_offset != 0) | |
10581 | as_bad_where (fix->fx_file, fix->fx_line, | |
10582 | "No addend allowed in @fptr() relocation"); | |
10583 | break; | |
10584 | default: | |
10585 | break; | |
10586 | } | |
800eeca4 JW |
10587 | } |
10588 | ||
10589 | static void | |
10590 | fix_insn (fix, odesc, value) | |
10591 | fixS *fix; | |
10592 | const struct ia64_operand *odesc; | |
10593 | valueT value; | |
10594 | { | |
10595 | bfd_vma insn[3], t0, t1, control_bits; | |
10596 | const char *err; | |
10597 | char *fixpos; | |
10598 | long slot; | |
10599 | ||
10600 | slot = fix->fx_where & 0x3; | |
10601 | fixpos = fix->fx_frag->fr_literal + (fix->fx_where - slot); | |
10602 | ||
c67e42c9 | 10603 | /* Bundles are always in little-endian byte order */ |
800eeca4 JW |
10604 | t0 = bfd_getl64 (fixpos); |
10605 | t1 = bfd_getl64 (fixpos + 8); | |
10606 | control_bits = t0 & 0x1f; | |
10607 | insn[0] = (t0 >> 5) & 0x1ffffffffffLL; | |
10608 | insn[1] = ((t0 >> 46) & 0x3ffff) | ((t1 & 0x7fffff) << 18); | |
10609 | insn[2] = (t1 >> 23) & 0x1ffffffffffLL; | |
10610 | ||
c67e42c9 RH |
10611 | err = NULL; |
10612 | if (odesc - elf64_ia64_operands == IA64_OPND_IMMU64) | |
800eeca4 | 10613 | { |
c67e42c9 RH |
10614 | insn[1] = (value >> 22) & 0x1ffffffffffLL; |
10615 | insn[2] |= (((value & 0x7f) << 13) | |
10616 | | (((value >> 7) & 0x1ff) << 27) | |
10617 | | (((value >> 16) & 0x1f) << 22) | |
10618 | | (((value >> 21) & 0x1) << 21) | |
10619 | | (((value >> 63) & 0x1) << 36)); | |
800eeca4 | 10620 | } |
c67e42c9 RH |
10621 | else if (odesc - elf64_ia64_operands == IA64_OPND_IMMU62) |
10622 | { | |
10623 | if (value & ~0x3fffffffffffffffULL) | |
10624 | err = "integer operand out of range"; | |
10625 | insn[1] = (value >> 21) & 0x1ffffffffffLL; | |
10626 | insn[2] |= (((value & 0xfffff) << 6) | (((value >> 20) & 0x1) << 36)); | |
10627 | } | |
10628 | else if (odesc - elf64_ia64_operands == IA64_OPND_TGT64) | |
10629 | { | |
10630 | value >>= 4; | |
10631 | insn[1] = ((value >> 20) & 0x7fffffffffLL) << 2; | |
10632 | insn[2] |= ((((value >> 59) & 0x1) << 36) | |
10633 | | (((value >> 0) & 0xfffff) << 13)); | |
10634 | } | |
10635 | else | |
10636 | err = (*odesc->insert) (odesc, value, insn + slot); | |
10637 | ||
10638 | if (err) | |
10639 | as_bad_where (fix->fx_file, fix->fx_line, err); | |
800eeca4 JW |
10640 | |
10641 | t0 = control_bits | (insn[0] << 5) | (insn[1] << 46); | |
10642 | t1 = ((insn[1] >> 18) & 0x7fffff) | (insn[2] << 23); | |
44f5c83a JW |
10643 | number_to_chars_littleendian (fixpos + 0, t0, 8); |
10644 | number_to_chars_littleendian (fixpos + 8, t1, 8); | |
800eeca4 JW |
10645 | } |
10646 | ||
10647 | /* Attempt to simplify or even eliminate a fixup. The return value is | |
10648 | ignored; perhaps it was once meaningful, but now it is historical. | |
10649 | To indicate that a fixup has been eliminated, set FIXP->FX_DONE. | |
10650 | ||
10651 | If fixp->fx_addsy is non-NULL, we'll have to generate a reloc entry | |
197865e8 | 10652 | (if possible). */ |
94f592af NC |
10653 | |
10654 | void | |
10655 | md_apply_fix3 (fix, valP, seg) | |
800eeca4 | 10656 | fixS *fix; |
40449e9f | 10657 | valueT *valP; |
2434f565 | 10658 | segT seg ATTRIBUTE_UNUSED; |
800eeca4 JW |
10659 | { |
10660 | char *fixpos; | |
40449e9f | 10661 | valueT value = *valP; |
800eeca4 JW |
10662 | |
10663 | fixpos = fix->fx_frag->fr_literal + fix->fx_where; | |
10664 | ||
10665 | if (fix->fx_pcrel) | |
10666 | { | |
10667 | switch (fix->fx_r_type) | |
10668 | { | |
10669 | case BFD_RELOC_IA64_DIR32MSB: | |
10670 | fix->fx_r_type = BFD_RELOC_IA64_PCREL32MSB; | |
800eeca4 JW |
10671 | break; |
10672 | ||
10673 | case BFD_RELOC_IA64_DIR32LSB: | |
10674 | fix->fx_r_type = BFD_RELOC_IA64_PCREL32LSB; | |
800eeca4 JW |
10675 | break; |
10676 | ||
10677 | case BFD_RELOC_IA64_DIR64MSB: | |
10678 | fix->fx_r_type = BFD_RELOC_IA64_PCREL64MSB; | |
800eeca4 JW |
10679 | break; |
10680 | ||
10681 | case BFD_RELOC_IA64_DIR64LSB: | |
10682 | fix->fx_r_type = BFD_RELOC_IA64_PCREL64LSB; | |
800eeca4 JW |
10683 | break; |
10684 | ||
10685 | default: | |
10686 | break; | |
10687 | } | |
10688 | } | |
10689 | if (fix->fx_addsy) | |
10690 | { | |
00f7efb6 | 10691 | switch (fix->fx_r_type) |
800eeca4 | 10692 | { |
00f7efb6 | 10693 | case BFD_RELOC_UNUSED: |
fa1cb89c JW |
10694 | /* This must be a TAG13 or TAG13b operand. There are no external |
10695 | relocs defined for them, so we must give an error. */ | |
800eeca4 JW |
10696 | as_bad_where (fix->fx_file, fix->fx_line, |
10697 | "%s must have a constant value", | |
10698 | elf64_ia64_operands[fix->tc_fix_data.opnd].desc); | |
fa1cb89c | 10699 | fix->fx_done = 1; |
94f592af | 10700 | return; |
00f7efb6 JJ |
10701 | |
10702 | case BFD_RELOC_IA64_TPREL14: | |
10703 | case BFD_RELOC_IA64_TPREL22: | |
10704 | case BFD_RELOC_IA64_TPREL64I: | |
10705 | case BFD_RELOC_IA64_LTOFF_TPREL22: | |
10706 | case BFD_RELOC_IA64_LTOFF_DTPMOD22: | |
10707 | case BFD_RELOC_IA64_DTPREL14: | |
10708 | case BFD_RELOC_IA64_DTPREL22: | |
10709 | case BFD_RELOC_IA64_DTPREL64I: | |
10710 | case BFD_RELOC_IA64_LTOFF_DTPREL22: | |
10711 | S_SET_THREAD_LOCAL (fix->fx_addsy); | |
10712 | break; | |
7925dd68 JJ |
10713 | |
10714 | default: | |
10715 | break; | |
800eeca4 | 10716 | } |
800eeca4 JW |
10717 | } |
10718 | else if (fix->tc_fix_data.opnd == IA64_OPND_NIL) | |
10719 | { | |
10720 | if (fix->tc_fix_data.bigendian) | |
10721 | number_to_chars_bigendian (fixpos, value, fix->fx_size); | |
10722 | else | |
10723 | number_to_chars_littleendian (fixpos, value, fix->fx_size); | |
10724 | fix->fx_done = 1; | |
800eeca4 JW |
10725 | } |
10726 | else | |
10727 | { | |
10728 | fix_insn (fix, elf64_ia64_operands + fix->tc_fix_data.opnd, value); | |
10729 | fix->fx_done = 1; | |
800eeca4 | 10730 | } |
800eeca4 JW |
10731 | } |
10732 | ||
10733 | /* Generate the BFD reloc to be stuck in the object file from the | |
10734 | fixup used internally in the assembler. */ | |
542d6675 KH |
10735 | |
10736 | arelent * | |
800eeca4 | 10737 | tc_gen_reloc (sec, fixp) |
2434f565 | 10738 | asection *sec ATTRIBUTE_UNUSED; |
800eeca4 JW |
10739 | fixS *fixp; |
10740 | { | |
10741 | arelent *reloc; | |
10742 | ||
10743 | reloc = xmalloc (sizeof (*reloc)); | |
10744 | reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); | |
10745 | *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); | |
10746 | reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; | |
10747 | reloc->addend = fixp->fx_offset; | |
10748 | reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); | |
10749 | ||
10750 | if (!reloc->howto) | |
10751 | { | |
10752 | as_bad_where (fixp->fx_file, fixp->fx_line, | |
10753 | "Cannot represent %s relocation in object file", | |
10754 | bfd_get_reloc_code_name (fixp->fx_r_type)); | |
10755 | } | |
10756 | return reloc; | |
10757 | } | |
10758 | ||
10759 | /* Turn a string in input_line_pointer into a floating point constant | |
bc0d738a NC |
10760 | of type TYPE, and store the appropriate bytes in *LIT. The number |
10761 | of LITTLENUMS emitted is stored in *SIZE. An error message is | |
800eeca4 JW |
10762 | returned, or NULL on OK. */ |
10763 | ||
10764 | #define MAX_LITTLENUMS 5 | |
10765 | ||
542d6675 | 10766 | char * |
800eeca4 JW |
10767 | md_atof (type, lit, size) |
10768 | int type; | |
10769 | char *lit; | |
10770 | int *size; | |
10771 | { | |
10772 | LITTLENUM_TYPE words[MAX_LITTLENUMS]; | |
800eeca4 JW |
10773 | char *t; |
10774 | int prec; | |
10775 | ||
10776 | switch (type) | |
10777 | { | |
10778 | /* IEEE floats */ | |
10779 | case 'f': | |
10780 | case 'F': | |
10781 | case 's': | |
10782 | case 'S': | |
10783 | prec = 2; | |
10784 | break; | |
10785 | ||
10786 | case 'd': | |
10787 | case 'D': | |
10788 | case 'r': | |
10789 | case 'R': | |
10790 | prec = 4; | |
10791 | break; | |
10792 | ||
10793 | case 'x': | |
10794 | case 'X': | |
10795 | case 'p': | |
10796 | case 'P': | |
10797 | prec = 5; | |
10798 | break; | |
10799 | ||
10800 | default: | |
10801 | *size = 0; | |
10802 | return "Bad call to MD_ATOF()"; | |
10803 | } | |
10804 | t = atof_ieee (input_line_pointer, type, words); | |
10805 | if (t) | |
10806 | input_line_pointer = t; | |
800eeca4 | 10807 | |
10a98291 L |
10808 | (*ia64_float_to_chars) (lit, words, prec); |
10809 | ||
165a7f90 L |
10810 | if (type == 'X') |
10811 | { | |
10812 | /* It is 10 byte floating point with 6 byte padding. */ | |
10a98291 | 10813 | memset (&lit [10], 0, 6); |
165a7f90 L |
10814 | *size = 8 * sizeof (LITTLENUM_TYPE); |
10815 | } | |
10a98291 L |
10816 | else |
10817 | *size = prec * sizeof (LITTLENUM_TYPE); | |
10818 | ||
800eeca4 JW |
10819 | return 0; |
10820 | } | |
10821 | ||
800eeca4 JW |
10822 | /* Handle ia64 specific semantics of the align directive. */ |
10823 | ||
0a9ef439 | 10824 | void |
800eeca4 | 10825 | ia64_md_do_align (n, fill, len, max) |
91a2ae2a RH |
10826 | int n ATTRIBUTE_UNUSED; |
10827 | const char *fill ATTRIBUTE_UNUSED; | |
2434f565 | 10828 | int len ATTRIBUTE_UNUSED; |
91a2ae2a | 10829 | int max ATTRIBUTE_UNUSED; |
800eeca4 | 10830 | { |
9545c4ce L |
10831 | /* The current frag is an alignment frag. */ |
10832 | align_frag = frag_now; | |
0a9ef439 | 10833 | if (subseg_text_p (now_seg)) |
800eeca4 | 10834 | ia64_flush_insns (); |
0a9ef439 | 10835 | } |
800eeca4 | 10836 | |
0a9ef439 RH |
10837 | /* This is called from HANDLE_ALIGN in write.c. Fill in the contents |
10838 | of an rs_align_code fragment. */ | |
800eeca4 | 10839 | |
0a9ef439 RH |
10840 | void |
10841 | ia64_handle_align (fragp) | |
10842 | fragS *fragp; | |
10843 | { | |
10844 | /* Use mfi bundle of nops with no stop bits. */ | |
0a9ef439 RH |
10845 | static const unsigned char le_nop[] |
10846 | = { 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | |
10847 | 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00}; | |
9545c4ce L |
10848 | static const unsigned char le_nop_stop[] |
10849 | = { 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | |
10850 | 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00}; | |
0a9ef439 RH |
10851 | |
10852 | int bytes; | |
10853 | char *p; | |
9545c4ce | 10854 | const unsigned char *nop; |
0a9ef439 RH |
10855 | |
10856 | if (fragp->fr_type != rs_align_code) | |
10857 | return; | |
10858 | ||
9545c4ce L |
10859 | /* Check if this frag has to end with a stop bit. */ |
10860 | nop = fragp->tc_frag_data ? le_nop_stop : le_nop; | |
10861 | ||
0a9ef439 RH |
10862 | bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix; |
10863 | p = fragp->fr_literal + fragp->fr_fix; | |
10864 | ||
10865 | /* Make sure we are on a 16-byte boundary, in case someone has been | |
10866 | putting data into a text section. */ | |
10867 | if (bytes & 15) | |
10868 | { | |
10869 | int fix = bytes & 15; | |
10870 | memset (p, 0, fix); | |
10871 | p += fix; | |
10872 | bytes -= fix; | |
10873 | fragp->fr_fix += fix; | |
800eeca4 JW |
10874 | } |
10875 | ||
012a452b | 10876 | /* Instruction bundles are always little-endian. */ |
9545c4ce | 10877 | memcpy (p, nop, 16); |
0a9ef439 | 10878 | fragp->fr_var = 16; |
800eeca4 | 10879 | } |
10a98291 L |
10880 | |
10881 | static void | |
10882 | ia64_float_to_chars_bigendian (char *lit, LITTLENUM_TYPE *words, | |
10883 | int prec) | |
10884 | { | |
10885 | while (prec--) | |
10886 | { | |
10887 | number_to_chars_bigendian (lit, (long) (*words++), | |
10888 | sizeof (LITTLENUM_TYPE)); | |
10889 | lit += sizeof (LITTLENUM_TYPE); | |
10890 | } | |
10891 | } | |
10892 | ||
10893 | static void | |
10894 | ia64_float_to_chars_littleendian (char *lit, LITTLENUM_TYPE *words, | |
10895 | int prec) | |
10896 | { | |
10897 | while (prec--) | |
10898 | { | |
10899 | number_to_chars_littleendian (lit, (long) (words[prec]), | |
10900 | sizeof (LITTLENUM_TYPE)); | |
10901 | lit += sizeof (LITTLENUM_TYPE); | |
10902 | } | |
10903 | } | |
10904 | ||
10905 | void | |
10906 | ia64_elf_section_change_hook (void) | |
10907 | { | |
10908 | dot_byteorder (-1); | |
10909 | } | |
a645d1eb L |
10910 | |
10911 | /* Check if a label should be made global. */ | |
10912 | void | |
10913 | ia64_check_label (symbolS *label) | |
10914 | { | |
10915 | if (*input_line_pointer == ':') | |
10916 | { | |
10917 | S_SET_EXTERNAL (label); | |
10918 | input_line_pointer++; | |
10919 | } | |
10920 | } | |
35f5df7f L |
10921 | |
10922 | /* Used to remember where .alias and .secalias directives are seen. We | |
10923 | will rename symbol and section names when we are about to output | |
10924 | the relocatable file. */ | |
10925 | struct alias | |
10926 | { | |
10927 | char *file; /* The file where the directive is seen. */ | |
10928 | unsigned int line; /* The line number the directive is at. */ | |
10929 | const char *name; /* The orignale name of the symbol. */ | |
10930 | }; | |
10931 | ||
10932 | /* Called for .alias and .secalias directives. If SECTION is 1, it is | |
10933 | .secalias. Otherwise, it is .alias. */ | |
10934 | static void | |
10935 | dot_alias (int section) | |
10936 | { | |
10937 | char *name, *alias; | |
10938 | char delim; | |
10939 | char *end_name; | |
10940 | int len; | |
10941 | const char *error_string; | |
10942 | struct alias *h; | |
10943 | const char *a; | |
10944 | struct hash_control *ahash, *nhash; | |
10945 | const char *kind; | |
10946 | ||
10947 | name = input_line_pointer; | |
10948 | delim = get_symbol_end (); | |
10949 | end_name = input_line_pointer; | |
10950 | *end_name = delim; | |
10951 | ||
10952 | if (name == end_name) | |
10953 | { | |
10954 | as_bad (_("expected symbol name")); | |
10955 | discard_rest_of_line (); | |
10956 | return; | |
10957 | } | |
10958 | ||
10959 | SKIP_WHITESPACE (); | |
10960 | ||
10961 | if (*input_line_pointer != ',') | |
10962 | { | |
10963 | *end_name = 0; | |
10964 | as_bad (_("expected comma after \"%s\""), name); | |
10965 | *end_name = delim; | |
10966 | ignore_rest_of_line (); | |
10967 | return; | |
10968 | } | |
10969 | ||
10970 | input_line_pointer++; | |
10971 | *end_name = 0; | |
10972 | ||
10973 | /* We call demand_copy_C_string to check if alias string is valid. | |
10974 | There should be a closing `"' and no `\0' in the string. */ | |
10975 | alias = demand_copy_C_string (&len); | |
10976 | if (alias == NULL) | |
10977 | { | |
10978 | ignore_rest_of_line (); | |
10979 | return; | |
10980 | } | |
10981 | ||
10982 | /* Make a copy of name string. */ | |
10983 | len = strlen (name) + 1; | |
10984 | obstack_grow (¬es, name, len); | |
10985 | name = obstack_finish (¬es); | |
10986 | ||
10987 | if (section) | |
10988 | { | |
10989 | kind = "section"; | |
10990 | ahash = secalias_hash; | |
10991 | nhash = secalias_name_hash; | |
10992 | } | |
10993 | else | |
10994 | { | |
10995 | kind = "symbol"; | |
10996 | ahash = alias_hash; | |
10997 | nhash = alias_name_hash; | |
10998 | } | |
10999 | ||
11000 | /* Check if alias has been used before. */ | |
11001 | h = (struct alias *) hash_find (ahash, alias); | |
11002 | if (h) | |
11003 | { | |
11004 | if (strcmp (h->name, name)) | |
11005 | as_bad (_("`%s' is already the alias of %s `%s'"), | |
11006 | alias, kind, h->name); | |
11007 | goto out; | |
11008 | } | |
11009 | ||
11010 | /* Check if name already has an alias. */ | |
11011 | a = (const char *) hash_find (nhash, name); | |
11012 | if (a) | |
11013 | { | |
11014 | if (strcmp (a, alias)) | |
11015 | as_bad (_("%s `%s' already has an alias `%s'"), kind, name, a); | |
11016 | goto out; | |
11017 | } | |
11018 | ||
11019 | h = (struct alias *) xmalloc (sizeof (struct alias)); | |
11020 | as_where (&h->file, &h->line); | |
11021 | h->name = name; | |
11022 | ||
11023 | error_string = hash_jam (ahash, alias, (PTR) h); | |
11024 | if (error_string) | |
11025 | { | |
11026 | as_fatal (_("inserting \"%s\" into %s alias hash table failed: %s"), | |
11027 | alias, kind, error_string); | |
11028 | goto out; | |
11029 | } | |
11030 | ||
11031 | error_string = hash_jam (nhash, name, (PTR) alias); | |
11032 | if (error_string) | |
11033 | { | |
11034 | as_fatal (_("inserting \"%s\" into %s name hash table failed: %s"), | |
11035 | alias, kind, error_string); | |
11036 | out: | |
11037 | obstack_free (¬es, name); | |
11038 | obstack_free (¬es, alias); | |
11039 | } | |
11040 | ||
11041 | demand_empty_rest_of_line (); | |
11042 | } | |
11043 | ||
11044 | /* It renames the original symbol name to its alias. */ | |
11045 | static void | |
11046 | do_alias (const char *alias, PTR value) | |
11047 | { | |
11048 | struct alias *h = (struct alias *) value; | |
11049 | symbolS *sym = symbol_find (h->name); | |
11050 | ||
11051 | if (sym == NULL) | |
11052 | as_warn_where (h->file, h->line, | |
11053 | _("symbol `%s' aliased to `%s' is not used"), | |
11054 | h->name, alias); | |
11055 | else | |
11056 | S_SET_NAME (sym, (char *) alias); | |
11057 | } | |
11058 | ||
11059 | /* Called from write_object_file. */ | |
11060 | void | |
11061 | ia64_adjust_symtab (void) | |
11062 | { | |
11063 | hash_traverse (alias_hash, do_alias); | |
11064 | } | |
11065 | ||
11066 | /* It renames the original section name to its alias. */ | |
11067 | static void | |
11068 | do_secalias (const char *alias, PTR value) | |
11069 | { | |
11070 | struct alias *h = (struct alias *) value; | |
11071 | segT sec = bfd_get_section_by_name (stdoutput, h->name); | |
11072 | ||
11073 | if (sec == NULL) | |
11074 | as_warn_where (h->file, h->line, | |
11075 | _("section `%s' aliased to `%s' is not used"), | |
11076 | h->name, alias); | |
11077 | else | |
11078 | sec->name = alias; | |
11079 | } | |
11080 | ||
11081 | /* Called from write_object_file. */ | |
11082 | void | |
11083 | ia64_frob_file (void) | |
11084 | { | |
11085 | hash_traverse (secalias_hash, do_secalias); | |
11086 | } |