1 /* tc-ia64.c -- Assembler for the HP/Intel IA-64 architecture.
2 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
3 Free Software Foundation, Inc.
4 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
6 This file is part of GAS, the GNU Assembler.
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GAS is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GAS; see the file COPYING. If not, write to
20 the Free Software Foundation, 51 Franklin Street - Fifth Floor,
21 Boston, MA 02110-1301, USA. */
35 - labels are wrong if automatic alignment is introduced
36 (e.g., checkout the second real10 definition in test-data.s)
38 <reg>.safe_across_calls and any other DV-related directives I don't
39 have documentation for.
40 verify mod-sched-brs reads/writes are checked/marked (and other
46 #include "safe-ctype.h"
47 #include "dwarf2dbg.h"
50 #include "opcode/ia64.h"
58 #define NELEMS(a) ((int) (sizeof (a)/sizeof ((a)[0])))
60 /* Some systems define MIN in, e.g., param.h. */
62 #define MIN(a,b) ((a) < (b) ? (a) : (b))
65 #define PREV_SLOT md.slot[(md.curr_slot + NUM_SLOTS - 1) % NUM_SLOTS]
66 #define CURR_SLOT md.slot[md.curr_slot]
68 #define O_pseudo_fixup (O_max + 1)
72 /* IA-64 ABI section pseudo-ops. */
73 SPECIAL_SECTION_BSS
= 0,
75 SPECIAL_SECTION_SDATA
,
76 SPECIAL_SECTION_RODATA
,
77 SPECIAL_SECTION_COMMENT
,
78 SPECIAL_SECTION_UNWIND
,
79 SPECIAL_SECTION_UNWIND_INFO
,
80 /* HPUX specific section pseudo-ops. */
81 SPECIAL_SECTION_INIT_ARRAY
,
82 SPECIAL_SECTION_FINI_ARRAY
,
99 FUNC_LT_FPTR_RELATIVE
,
101 FUNC_LT_DTP_RELATIVE
,
109 REG_FR
= (REG_GR
+ 128),
110 REG_AR
= (REG_FR
+ 128),
111 REG_CR
= (REG_AR
+ 128),
112 REG_P
= (REG_CR
+ 128),
113 REG_BR
= (REG_P
+ 64),
114 REG_IP
= (REG_BR
+ 8),
121 /* The following are pseudo-registers for use by gas only. */
132 /* The following pseudo-registers are used for unwind directives only: */
140 DYNREG_GR
= 0, /* dynamic general purpose register */
141 DYNREG_FR
, /* dynamic floating point register */
142 DYNREG_PR
, /* dynamic predicate register */
146 enum operand_match_result
149 OPERAND_OUT_OF_RANGE
,
153 /* On the ia64, we can't know the address of a text label until the
154 instructions are packed into a bundle. To handle this, we keep
155 track of the list of labels that appear in front of each
159 struct label_fix
*next
;
161 bfd_boolean dw2_mark_labels
;
164 /* This is the endianness of the current section. */
165 extern int target_big_endian
;
167 /* This is the default endianness. */
168 static int default_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
170 void (*ia64_number_to_chars
) (char *, valueT
, int);
172 static void ia64_float_to_chars_bigendian (char *, LITTLENUM_TYPE
*, int);
173 static void ia64_float_to_chars_littleendian (char *, LITTLENUM_TYPE
*, int);
175 static void (*ia64_float_to_chars
) (char *, LITTLENUM_TYPE
*, int);
177 static struct hash_control
*alias_hash
;
178 static struct hash_control
*alias_name_hash
;
179 static struct hash_control
*secalias_hash
;
180 static struct hash_control
*secalias_name_hash
;
182 /* List of chars besides those in app.c:symbol_chars that can start an
183 operand. Used to prevent the scrubber eating vital white-space. */
184 const char ia64_symbol_chars
[] = "@?";
186 /* Characters which always start a comment. */
187 const char comment_chars
[] = "";
189 /* Characters which start a comment at the beginning of a line. */
190 const char line_comment_chars
[] = "#";
192 /* Characters which may be used to separate multiple commands on a
194 const char line_separator_chars
[] = ";{}";
196 /* Characters which are used to indicate an exponent in a floating
198 const char EXP_CHARS
[] = "eE";
200 /* Characters which mean that a number is a floating point constant,
202 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
204 /* ia64-specific option processing: */
206 const char *md_shortopts
= "m:N:x::";
208 struct option md_longopts
[] =
210 #define OPTION_MCONSTANT_GP (OPTION_MD_BASE + 1)
211 {"mconstant-gp", no_argument
, NULL
, OPTION_MCONSTANT_GP
},
212 #define OPTION_MAUTO_PIC (OPTION_MD_BASE + 2)
213 {"mauto-pic", no_argument
, NULL
, OPTION_MAUTO_PIC
}
216 size_t md_longopts_size
= sizeof (md_longopts
);
220 struct hash_control
*pseudo_hash
; /* pseudo opcode hash table */
221 struct hash_control
*reg_hash
; /* register name hash table */
222 struct hash_control
*dynreg_hash
; /* dynamic register hash table */
223 struct hash_control
*const_hash
; /* constant hash table */
224 struct hash_control
*entry_hash
; /* code entry hint hash table */
226 /* If X_op is != O_absent, the registername for the instruction's
227 qualifying predicate. If NULL, p0 is assumed for instructions
228 that are predictable. */
231 /* Optimize for which CPU. */
238 /* What to do when hint.b is used. */
250 explicit_mode
: 1, /* which mode we're in */
251 default_explicit_mode
: 1, /* which mode is the default */
252 mode_explicitly_set
: 1, /* was the current mode explicitly set? */
254 keep_pending_output
: 1;
256 /* What to do when something is wrong with unwind directives. */
259 unwind_check_warning
,
263 /* Each bundle consists of up to three instructions. We keep
264 track of four most recent instructions so we can correctly set
265 the end_of_insn_group for the last instruction in a bundle. */
267 int num_slots_in_use
;
271 end_of_insn_group
: 1,
272 manual_bundling_on
: 1,
273 manual_bundling_off
: 1,
274 loc_directive_seen
: 1;
275 signed char user_template
; /* user-selected template, if any */
276 unsigned char qp_regno
; /* qualifying predicate */
277 /* This duplicates a good fraction of "struct fix" but we
278 can't use a "struct fix" instead since we can't call
279 fix_new_exp() until we know the address of the instruction. */
283 bfd_reloc_code_real_type code
;
284 enum ia64_opnd opnd
; /* type of operand in need of fix */
285 unsigned int is_pcrel
: 1; /* is operand pc-relative? */
286 expressionS expr
; /* the value to be inserted */
288 fixup
[2]; /* at most two fixups per insn */
289 struct ia64_opcode
*idesc
;
290 struct label_fix
*label_fixups
;
291 struct label_fix
*tag_fixups
;
292 struct unw_rec_list
*unwind_record
; /* Unwind directive. */
295 unsigned int src_line
;
296 struct dwarf2_line_info debug_line
;
304 struct dynreg
*next
; /* next dynamic register */
306 unsigned short base
; /* the base register number */
307 unsigned short num_regs
; /* # of registers in this set */
309 *dynreg
[DYNREG_NUM_TYPES
], in
, loc
, out
, rot
;
311 flagword flags
; /* ELF-header flags */
314 unsigned hint
:1; /* is this hint currently valid? */
315 bfd_vma offset
; /* mem.offset offset */
316 bfd_vma base
; /* mem.offset base */
319 int path
; /* number of alt. entry points seen */
320 const char **entry_labels
; /* labels of all alternate paths in
321 the current DV-checking block. */
322 int maxpaths
; /* size currently allocated for
325 int pointer_size
; /* size in bytes of a pointer */
326 int pointer_size_shift
; /* shift size of a pointer for alignment */
328 symbolS
*indregsym
[IND_RR
- IND_CPUID
+ 1];
332 /* These are not const, because they are modified to MMI for non-itanium1
334 /* MFI bundle of nops. */
335 static unsigned char le_nop
[16] =
337 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
338 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00
340 /* MFI bundle of nops with stop-bit. */
341 static unsigned char le_nop_stop
[16] =
343 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
344 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00
347 /* application registers: */
353 #define AR_BSPSTORE 18
379 {"ar.k0", AR_K0
}, {"ar.k1", AR_K0
+ 1},
380 {"ar.k2", AR_K0
+ 2}, {"ar.k3", AR_K0
+ 3},
381 {"ar.k4", AR_K0
+ 4}, {"ar.k5", AR_K0
+ 5},
382 {"ar.k6", AR_K0
+ 6}, {"ar.k7", AR_K7
},
383 {"ar.rsc", AR_RSC
}, {"ar.bsp", AR_BSP
},
384 {"ar.bspstore", AR_BSPSTORE
}, {"ar.rnat", AR_RNAT
},
385 {"ar.fcr", AR_FCR
}, {"ar.eflag", AR_EFLAG
},
386 {"ar.csd", AR_CSD
}, {"ar.ssd", AR_SSD
},
387 {"ar.cflg", AR_CFLG
}, {"ar.fsr", AR_FSR
},
388 {"ar.fir", AR_FIR
}, {"ar.fdr", AR_FDR
},
389 {"ar.ccv", AR_CCV
}, {"ar.unat", AR_UNAT
},
390 {"ar.fpsr", AR_FPSR
}, {"ar.itc", AR_ITC
},
391 {"ar.ruc", AR_RUC
}, {"ar.pfs", AR_PFS
},
392 {"ar.lc", AR_LC
}, {"ar.ec", AR_EC
},
395 /* control registers: */
436 {"cr.gpta", CR_GPTA
},
437 {"cr.ipsr", CR_IPSR
},
441 {"cr.itir", CR_ITIR
},
442 {"cr.iipa", CR_IIPA
},
446 {"cr.iib0", CR_IIB0
},
447 {"cr.iib1", CR_IIB1
},
452 {"cr.irr0", CR_IRR0
},
453 {"cr.irr1", CR_IRR0
+ 1},
454 {"cr.irr2", CR_IRR0
+ 2},
455 {"cr.irr3", CR_IRR3
},
458 {"cr.cmcv", CR_CMCV
},
459 {"cr.lrr0", CR_LRR0
},
468 static const struct const_desc
475 /* PSR constant masks: */
478 {"psr.be", ((valueT
) 1) << 1},
479 {"psr.up", ((valueT
) 1) << 2},
480 {"psr.ac", ((valueT
) 1) << 3},
481 {"psr.mfl", ((valueT
) 1) << 4},
482 {"psr.mfh", ((valueT
) 1) << 5},
484 {"psr.ic", ((valueT
) 1) << 13},
485 {"psr.i", ((valueT
) 1) << 14},
486 {"psr.pk", ((valueT
) 1) << 15},
488 {"psr.dt", ((valueT
) 1) << 17},
489 {"psr.dfl", ((valueT
) 1) << 18},
490 {"psr.dfh", ((valueT
) 1) << 19},
491 {"psr.sp", ((valueT
) 1) << 20},
492 {"psr.pp", ((valueT
) 1) << 21},
493 {"psr.di", ((valueT
) 1) << 22},
494 {"psr.si", ((valueT
) 1) << 23},
495 {"psr.db", ((valueT
) 1) << 24},
496 {"psr.lp", ((valueT
) 1) << 25},
497 {"psr.tb", ((valueT
) 1) << 26},
498 {"psr.rt", ((valueT
) 1) << 27},
499 /* 28-31: reserved */
500 /* 32-33: cpl (current privilege level) */
501 {"psr.is", ((valueT
) 1) << 34},
502 {"psr.mc", ((valueT
) 1) << 35},
503 {"psr.it", ((valueT
) 1) << 36},
504 {"psr.id", ((valueT
) 1) << 37},
505 {"psr.da", ((valueT
) 1) << 38},
506 {"psr.dd", ((valueT
) 1) << 39},
507 {"psr.ss", ((valueT
) 1) << 40},
508 /* 41-42: ri (restart instruction) */
509 {"psr.ed", ((valueT
) 1) << 43},
510 {"psr.bn", ((valueT
) 1) << 44},
513 /* indirect register-sets/memory: */
522 { "CPUID", IND_CPUID
},
523 { "cpuid", IND_CPUID
},
535 /* Pseudo functions used to indicate relocation types (these functions
536 start with an at sign (@). */
558 /* reloc pseudo functions (these must come first!): */
559 { "dtpmod", PSEUDO_FUNC_RELOC
, { 0 } },
560 { "dtprel", PSEUDO_FUNC_RELOC
, { 0 } },
561 { "fptr", PSEUDO_FUNC_RELOC
, { 0 } },
562 { "gprel", PSEUDO_FUNC_RELOC
, { 0 } },
563 { "ltoff", PSEUDO_FUNC_RELOC
, { 0 } },
564 { "ltoffx", PSEUDO_FUNC_RELOC
, { 0 } },
565 { "pcrel", PSEUDO_FUNC_RELOC
, { 0 } },
566 { "pltoff", PSEUDO_FUNC_RELOC
, { 0 } },
567 { "secrel", PSEUDO_FUNC_RELOC
, { 0 } },
568 { "segrel", PSEUDO_FUNC_RELOC
, { 0 } },
569 { "tprel", PSEUDO_FUNC_RELOC
, { 0 } },
570 { "ltv", PSEUDO_FUNC_RELOC
, { 0 } },
571 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_FPTR_RELATIVE */
572 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_DTP_MODULE */
573 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_DTP_RELATIVE */
574 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_TP_RELATIVE */
575 { "iplt", PSEUDO_FUNC_RELOC
, { 0 } },
577 /* mbtype4 constants: */
578 { "alt", PSEUDO_FUNC_CONST
, { 0xa } },
579 { "brcst", PSEUDO_FUNC_CONST
, { 0x0 } },
580 { "mix", PSEUDO_FUNC_CONST
, { 0x8 } },
581 { "rev", PSEUDO_FUNC_CONST
, { 0xb } },
582 { "shuf", PSEUDO_FUNC_CONST
, { 0x9 } },
584 /* fclass constants: */
585 { "nat", PSEUDO_FUNC_CONST
, { 0x100 } },
586 { "qnan", PSEUDO_FUNC_CONST
, { 0x080 } },
587 { "snan", PSEUDO_FUNC_CONST
, { 0x040 } },
588 { "pos", PSEUDO_FUNC_CONST
, { 0x001 } },
589 { "neg", PSEUDO_FUNC_CONST
, { 0x002 } },
590 { "zero", PSEUDO_FUNC_CONST
, { 0x004 } },
591 { "unorm", PSEUDO_FUNC_CONST
, { 0x008 } },
592 { "norm", PSEUDO_FUNC_CONST
, { 0x010 } },
593 { "inf", PSEUDO_FUNC_CONST
, { 0x020 } },
595 { "natval", PSEUDO_FUNC_CONST
, { 0x100 } }, /* old usage */
597 /* hint constants: */
598 { "pause", PSEUDO_FUNC_CONST
, { 0x0 } },
600 /* unwind-related constants: */
601 { "svr4", PSEUDO_FUNC_CONST
, { ELFOSABI_NONE
} },
602 { "hpux", PSEUDO_FUNC_CONST
, { ELFOSABI_HPUX
} },
603 { "nt", PSEUDO_FUNC_CONST
, { 2 } }, /* conflicts w/ELFOSABI_NETBSD */
604 { "linux", PSEUDO_FUNC_CONST
, { ELFOSABI_LINUX
} },
605 { "freebsd", PSEUDO_FUNC_CONST
, { ELFOSABI_FREEBSD
} },
606 { "openvms", PSEUDO_FUNC_CONST
, { ELFOSABI_OPENVMS
} },
607 { "nsk", PSEUDO_FUNC_CONST
, { ELFOSABI_NSK
} },
609 /* unwind-related registers: */
610 { "priunat",PSEUDO_FUNC_REG
, { REG_PRIUNAT
} }
613 /* 41-bit nop opcodes (one per unit): */
614 static const bfd_vma nop
[IA64_NUM_UNITS
] =
616 0x0000000000LL
, /* NIL => break 0 */
617 0x0008000000LL
, /* I-unit nop */
618 0x0008000000LL
, /* M-unit nop */
619 0x4000000000LL
, /* B-unit nop */
620 0x0008000000LL
, /* F-unit nop */
621 0x0000000000LL
, /* L-"unit" nop immediate */
622 0x0008000000LL
, /* X-unit nop */
625 /* Can't be `const' as it's passed to input routines (which have the
626 habit of setting temporary sentinels. */
627 static char special_section_name
[][20] =
629 {".bss"}, {".sbss"}, {".sdata"}, {".rodata"}, {".comment"},
630 {".IA_64.unwind"}, {".IA_64.unwind_info"},
631 {".init_array"}, {".fini_array"}
634 /* The best template for a particular sequence of up to three
636 #define N IA64_NUM_TYPES
637 static unsigned char best_template
[N
][N
][N
];
640 /* Resource dependencies currently in effect */
642 int depind
; /* dependency index */
643 const struct ia64_dependency
*dependency
; /* actual dependency */
644 unsigned specific
:1, /* is this a specific bit/regno? */
645 link_to_qp_branch
:1; /* will a branch on the same QP clear it?*/
646 int index
; /* specific regno/bit within dependency */
647 int note
; /* optional qualifying note (0 if none) */
651 int insn_srlz
; /* current insn serialization state */
652 int data_srlz
; /* current data serialization state */
653 int qp_regno
; /* qualifying predicate for this usage */
654 char *file
; /* what file marked this dependency */
655 unsigned int line
; /* what line marked this dependency */
656 struct mem_offset mem_offset
; /* optional memory offset hint */
657 enum { CMP_NONE
, CMP_OR
, CMP_AND
} cmp_type
; /* OR or AND compare? */
658 int path
; /* corresponding code entry index */
660 static int regdepslen
= 0;
661 static int regdepstotlen
= 0;
662 static const char *dv_mode
[] = { "RAW", "WAW", "WAR" };
663 static const char *dv_sem
[] = { "none", "implied", "impliedf",
664 "data", "instr", "specific", "stop", "other" };
665 static const char *dv_cmp_type
[] = { "none", "OR", "AND" };
667 /* Current state of PR mutexation */
668 static struct qpmutex
{
671 } *qp_mutexes
= NULL
; /* QP mutex bitmasks */
672 static int qp_mutexeslen
= 0;
673 static int qp_mutexestotlen
= 0;
674 static valueT qp_safe_across_calls
= 0;
676 /* Current state of PR implications */
677 static struct qp_imply
{
680 unsigned p2_branched
:1;
682 } *qp_implies
= NULL
;
683 static int qp_implieslen
= 0;
684 static int qp_impliestotlen
= 0;
686 /* Keep track of static GR values so that indirect register usage can
687 sometimes be tracked. */
698 (((1 << (8 * sizeof(gr_values
->path
) - 2)) - 1) << 1) + 1,
704 /* Remember the alignment frag. */
705 static fragS
*align_frag
;
707 /* These are the routines required to output the various types of
710 /* A slot_number is a frag address plus the slot index (0-2). We use the
711 frag address here so that if there is a section switch in the middle of
712 a function, then instructions emitted to a different section are not
713 counted. Since there may be more than one frag for a function, this
714 means we also need to keep track of which frag this address belongs to
715 so we can compute inter-frag distances. This also nicely solves the
716 problem with nops emitted for align directives, which can't easily be
717 counted, but can easily be derived from frag sizes. */
719 typedef struct unw_rec_list
{
721 unsigned long slot_number
;
723 struct unw_rec_list
*next
;
726 #define SLOT_NUM_NOT_SET (unsigned)-1
728 /* Linked list of saved prologue counts. A very poor
729 implementation of a map from label numbers to prologue counts. */
730 typedef struct label_prologue_count
732 struct label_prologue_count
*next
;
733 unsigned long label_number
;
734 unsigned int prologue_count
;
735 } label_prologue_count
;
737 typedef struct proc_pending
740 struct proc_pending
*next
;
745 /* Maintain a list of unwind entries for the current function. */
749 /* Any unwind entries that should be attached to the current slot
750 that an insn is being constructed for. */
751 unw_rec_list
*current_entry
;
753 /* These are used to create the unwind table entry for this function. */
754 proc_pending proc_pending
;
755 symbolS
*info
; /* pointer to unwind info */
756 symbolS
*personality_routine
;
758 subsegT saved_text_subseg
;
759 unsigned int force_unwind_entry
: 1; /* force generation of unwind entry? */
761 /* TRUE if processing unwind directives in a prologue region. */
762 unsigned int prologue
: 1;
763 unsigned int prologue_mask
: 4;
764 unsigned int prologue_gr
: 7;
765 unsigned int body
: 1;
766 unsigned int insn
: 1;
767 unsigned int prologue_count
; /* number of .prologues seen so far */
768 /* Prologue counts at previous .label_state directives. */
769 struct label_prologue_count
* saved_prologue_counts
;
771 /* List of split up .save-s. */
772 unw_p_record
*pending_saves
;
775 /* The input value is a negated offset from psp, and specifies an address
776 psp - offset. The encoded value is psp + 16 - (4 * offset). Thus we
777 must add 16 and divide by 4 to get the encoded value. */
779 #define ENCODED_PSP_OFFSET(OFFSET) (((OFFSET) + 16) / 4)
781 typedef void (*vbyte_func
) (int, char *, char *);
783 /* Forward declarations: */
784 static void dot_alias (int);
785 static int parse_operand (expressionS
*, int);
786 static void emit_one_bundle (void);
787 static bfd_reloc_code_real_type
ia64_gen_real_reloc_type (struct symbol
*,
788 bfd_reloc_code_real_type
);
789 static void insn_group_break (int, int, int);
790 static void add_qp_mutex (valueT
);
791 static void add_qp_imply (int, int);
792 static void clear_qp_mutex (valueT
);
793 static void clear_qp_implies (valueT
, valueT
);
794 static void print_dependency (const char *, int);
795 static void instruction_serialization (void);
796 static void data_serialization (void);
797 static void output_R3_format (vbyte_func
, unw_record_type
, unsigned long);
798 static void output_B3_format (vbyte_func
, unsigned long, unsigned long);
799 static void output_B4_format (vbyte_func
, unw_record_type
, unsigned long);
800 static void free_saved_prologue_counts (void);
802 /* Determine if application register REGNUM resides only in the integer
803 unit (as opposed to the memory unit). */
805 ar_is_only_in_integer_unit (int reg
)
808 return reg
>= 64 && reg
<= 111;
811 /* Determine if application register REGNUM resides only in the memory
812 unit (as opposed to the integer unit). */
814 ar_is_only_in_memory_unit (int reg
)
817 return reg
>= 0 && reg
<= 47;
820 /* Switch to section NAME and create section if necessary. It's
821 rather ugly that we have to manipulate input_line_pointer but I
822 don't see any other way to accomplish the same thing without
823 changing obj-elf.c (which may be the Right Thing, in the end). */
825 set_section (char *name
)
827 char *saved_input_line_pointer
;
829 saved_input_line_pointer
= input_line_pointer
;
830 input_line_pointer
= name
;
832 input_line_pointer
= saved_input_line_pointer
;
835 /* Map 's' to SHF_IA_64_SHORT. */
838 ia64_elf_section_letter (int letter
, char **ptr_msg
)
841 return SHF_IA_64_SHORT
;
842 else if (letter
== 'o')
843 return SHF_LINK_ORDER
;
845 *ptr_msg
= _("Bad .section directive: want a,o,s,w,x,M,S,G,T in string");
849 /* Map SHF_IA_64_SHORT to SEC_SMALL_DATA. */
852 ia64_elf_section_flags (flagword flags
,
854 int type ATTRIBUTE_UNUSED
)
856 if (attr
& SHF_IA_64_SHORT
)
857 flags
|= SEC_SMALL_DATA
;
862 ia64_elf_section_type (const char *str
, size_t len
)
864 #define STREQ(s) ((len == sizeof (s) - 1) && (strncmp (str, s, sizeof (s) - 1) == 0))
866 if (STREQ (ELF_STRING_ia64_unwind_info
))
869 if (STREQ (ELF_STRING_ia64_unwind_info_once
))
872 if (STREQ (ELF_STRING_ia64_unwind
))
873 return SHT_IA_64_UNWIND
;
875 if (STREQ (ELF_STRING_ia64_unwind_once
))
876 return SHT_IA_64_UNWIND
;
878 if (STREQ ("unwind"))
879 return SHT_IA_64_UNWIND
;
886 set_regstack (unsigned int ins
,
894 sof
= ins
+ locs
+ outs
;
897 as_bad (_("Size of frame exceeds maximum of 96 registers"));
902 as_warn (_("Size of rotating registers exceeds frame size"));
905 md
.in
.base
= REG_GR
+ 32;
906 md
.loc
.base
= md
.in
.base
+ ins
;
907 md
.out
.base
= md
.loc
.base
+ locs
;
909 md
.in
.num_regs
= ins
;
910 md
.loc
.num_regs
= locs
;
911 md
.out
.num_regs
= outs
;
912 md
.rot
.num_regs
= rots
;
917 ia64_flush_insns (void)
919 struct label_fix
*lfix
;
921 subsegT saved_subseg
;
925 if (!md
.last_text_seg
)
929 saved_subseg
= now_subseg
;
931 subseg_set (md
.last_text_seg
, 0);
933 while (md
.num_slots_in_use
> 0)
934 emit_one_bundle (); /* force out queued instructions */
936 /* In case there are labels following the last instruction, resolve
939 for (lfix
= CURR_SLOT
.label_fixups
; lfix
; lfix
= lfix
->next
)
941 symbol_set_value_now (lfix
->sym
);
942 mark
|= lfix
->dw2_mark_labels
;
946 dwarf2_where (&CURR_SLOT
.debug_line
);
947 CURR_SLOT
.debug_line
.flags
|= DWARF2_FLAG_BASIC_BLOCK
;
948 dwarf2_gen_line_info (frag_now_fix (), &CURR_SLOT
.debug_line
);
949 dwarf2_consume_line_info ();
951 CURR_SLOT
.label_fixups
= 0;
953 for (lfix
= CURR_SLOT
.tag_fixups
; lfix
; lfix
= lfix
->next
)
954 symbol_set_value_now (lfix
->sym
);
955 CURR_SLOT
.tag_fixups
= 0;
957 /* In case there are unwind directives following the last instruction,
958 resolve those now. We only handle prologue, body, and endp directives
959 here. Give an error for others. */
960 for (ptr
= unwind
.current_entry
; ptr
; ptr
= ptr
->next
)
968 ptr
->slot_number
= (unsigned long) frag_more (0);
969 ptr
->slot_frag
= frag_now
;
972 /* Allow any record which doesn't have a "t" field (i.e.,
973 doesn't relate to a particular instruction). */
989 as_bad (_("Unwind directive not followed by an instruction."));
993 unwind
.current_entry
= NULL
;
995 subseg_set (saved_seg
, saved_subseg
);
997 if (md
.qp
.X_op
== O_register
)
998 as_bad (_("qualifying predicate not followed by instruction"));
1002 ia64_do_align (int nbytes
)
1004 char *saved_input_line_pointer
= input_line_pointer
;
1006 input_line_pointer
= "";
1007 s_align_bytes (nbytes
);
1008 input_line_pointer
= saved_input_line_pointer
;
1012 ia64_cons_align (int nbytes
)
1016 char *saved_input_line_pointer
= input_line_pointer
;
1017 input_line_pointer
= "";
1018 s_align_bytes (nbytes
);
1019 input_line_pointer
= saved_input_line_pointer
;
1023 /* Output COUNT bytes to a memory location. */
1024 static char *vbyte_mem_ptr
= NULL
;
1027 output_vbyte_mem (int count
, char *ptr
, char *comment ATTRIBUTE_UNUSED
)
1030 if (vbyte_mem_ptr
== NULL
)
1035 for (x
= 0; x
< count
; x
++)
1036 *(vbyte_mem_ptr
++) = ptr
[x
];
1039 /* Count the number of bytes required for records. */
1040 static int vbyte_count
= 0;
1042 count_output (int count
,
1043 char *ptr ATTRIBUTE_UNUSED
,
1044 char *comment ATTRIBUTE_UNUSED
)
1046 vbyte_count
+= count
;
1050 output_R1_format (vbyte_func f
, unw_record_type rtype
, int rlen
)
1056 output_R3_format (f
, rtype
, rlen
);
1062 else if (rtype
!= prologue
)
1063 as_bad (_("record type is not valid"));
1065 byte
= UNW_R1
| (r
<< 5) | (rlen
& 0x1f);
1066 (*f
) (1, &byte
, NULL
);
1070 output_R2_format (vbyte_func f
, int mask
, int grsave
, unsigned long rlen
)
1074 mask
= (mask
& 0x0f);
1075 grsave
= (grsave
& 0x7f);
1077 bytes
[0] = (UNW_R2
| (mask
>> 1));
1078 bytes
[1] = (((mask
& 0x01) << 7) | grsave
);
1079 count
+= output_leb128 (bytes
+ 2, rlen
, 0);
1080 (*f
) (count
, bytes
, NULL
);
1084 output_R3_format (vbyte_func f
, unw_record_type rtype
, unsigned long rlen
)
1090 output_R1_format (f
, rtype
, rlen
);
1096 else if (rtype
!= prologue
)
1097 as_bad (_("record type is not valid"));
1098 bytes
[0] = (UNW_R3
| r
);
1099 count
= output_leb128 (bytes
+ 1, rlen
, 0);
1100 (*f
) (count
+ 1, bytes
, NULL
);
1104 output_P1_format (vbyte_func f
, int brmask
)
1107 byte
= UNW_P1
| (brmask
& 0x1f);
1108 (*f
) (1, &byte
, NULL
);
1112 output_P2_format (vbyte_func f
, int brmask
, int gr
)
1115 brmask
= (brmask
& 0x1f);
1116 bytes
[0] = UNW_P2
| (brmask
>> 1);
1117 bytes
[1] = (((brmask
& 1) << 7) | gr
);
1118 (*f
) (2, bytes
, NULL
);
1122 output_P3_format (vbyte_func f
, unw_record_type rtype
, int reg
)
1166 as_bad (_("Invalid record type for P3 format."));
1168 bytes
[0] = (UNW_P3
| (r
>> 1));
1169 bytes
[1] = (((r
& 1) << 7) | reg
);
1170 (*f
) (2, bytes
, NULL
);
1174 output_P4_format (vbyte_func f
, unsigned char *imask
, unsigned long imask_size
)
1177 (*f
) (imask_size
, (char *) imask
, NULL
);
1181 output_P5_format (vbyte_func f
, int grmask
, unsigned long frmask
)
1184 grmask
= (grmask
& 0x0f);
1187 bytes
[1] = ((grmask
<< 4) | ((frmask
& 0x000f0000) >> 16));
1188 bytes
[2] = ((frmask
& 0x0000ff00) >> 8);
1189 bytes
[3] = (frmask
& 0x000000ff);
1190 (*f
) (4, bytes
, NULL
);
1194 output_P6_format (vbyte_func f
, unw_record_type rtype
, int rmask
)
1199 if (rtype
== gr_mem
)
1201 else if (rtype
!= fr_mem
)
1202 as_bad (_("Invalid record type for format P6"));
1203 byte
= (UNW_P6
| (r
<< 4) | (rmask
& 0x0f));
1204 (*f
) (1, &byte
, NULL
);
1208 output_P7_format (vbyte_func f
,
1209 unw_record_type rtype
,
1216 count
+= output_leb128 (bytes
+ 1, w1
, 0);
1221 count
+= output_leb128 (bytes
+ count
, w2
>> 4, 0);
1271 bytes
[0] = (UNW_P7
| r
);
1272 (*f
) (count
, bytes
, NULL
);
1276 output_P8_format (vbyte_func f
, unw_record_type rtype
, unsigned long t
)
1314 case bspstore_psprel
:
1317 case bspstore_sprel
:
1329 case priunat_when_gr
:
1332 case priunat_psprel
:
1338 case priunat_when_mem
:
1345 count
+= output_leb128 (bytes
+ 2, t
, 0);
1346 (*f
) (count
, bytes
, NULL
);
1350 output_P9_format (vbyte_func f
, int grmask
, int gr
)
1354 bytes
[1] = (grmask
& 0x0f);
1355 bytes
[2] = (gr
& 0x7f);
1356 (*f
) (3, bytes
, NULL
);
1360 output_P10_format (vbyte_func f
, int abi
, int context
)
1364 bytes
[1] = (abi
& 0xff);
1365 bytes
[2] = (context
& 0xff);
1366 (*f
) (3, bytes
, NULL
);
1370 output_B1_format (vbyte_func f
, unw_record_type rtype
, unsigned long label
)
1376 output_B4_format (f
, rtype
, label
);
1379 if (rtype
== copy_state
)
1381 else if (rtype
!= label_state
)
1382 as_bad (_("Invalid record type for format B1"));
1384 byte
= (UNW_B1
| (r
<< 5) | (label
& 0x1f));
1385 (*f
) (1, &byte
, NULL
);
1389 output_B2_format (vbyte_func f
, unsigned long ecount
, unsigned long t
)
1395 output_B3_format (f
, ecount
, t
);
1398 bytes
[0] = (UNW_B2
| (ecount
& 0x1f));
1399 count
+= output_leb128 (bytes
+ 1, t
, 0);
1400 (*f
) (count
, bytes
, NULL
);
1404 output_B3_format (vbyte_func f
, unsigned long ecount
, unsigned long t
)
1410 output_B2_format (f
, ecount
, t
);
1414 count
+= output_leb128 (bytes
+ 1, t
, 0);
1415 count
+= output_leb128 (bytes
+ count
, ecount
, 0);
1416 (*f
) (count
, bytes
, NULL
);
1420 output_B4_format (vbyte_func f
, unw_record_type rtype
, unsigned long label
)
1427 output_B1_format (f
, rtype
, label
);
1431 if (rtype
== copy_state
)
1433 else if (rtype
!= label_state
)
1434 as_bad (_("Invalid record type for format B1"));
1436 bytes
[0] = (UNW_B4
| (r
<< 3));
1437 count
+= output_leb128 (bytes
+ 1, label
, 0);
1438 (*f
) (count
, bytes
, NULL
);
1442 format_ab_reg (int ab
, int reg
)
1447 ret
= (ab
<< 5) | reg
;
1452 output_X1_format (vbyte_func f
,
1453 unw_record_type rtype
,
1464 if (rtype
== spill_sprel
)
1466 else if (rtype
!= spill_psprel
)
1467 as_bad (_("Invalid record type for format X1"));
1468 bytes
[1] = ((r
<< 7) | format_ab_reg (ab
, reg
));
1469 count
+= output_leb128 (bytes
+ 2, t
, 0);
1470 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1471 (*f
) (count
, bytes
, NULL
);
1475 output_X2_format (vbyte_func f
,
1486 bytes
[1] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1487 bytes
[2] = (((y
& 1) << 7) | (treg
& 0x7f));
1488 count
+= output_leb128 (bytes
+ 3, t
, 0);
1489 (*f
) (count
, bytes
, NULL
);
1493 output_X3_format (vbyte_func f
,
1494 unw_record_type rtype
,
1506 if (rtype
== spill_sprel_p
)
1508 else if (rtype
!= spill_psprel_p
)
1509 as_bad (_("Invalid record type for format X3"));
1510 bytes
[1] = ((r
<< 7) | (qp
& 0x3f));
1511 bytes
[2] = format_ab_reg (ab
, reg
);
1512 count
+= output_leb128 (bytes
+ 3, t
, 0);
1513 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1514 (*f
) (count
, bytes
, NULL
);
1518 output_X4_format (vbyte_func f
,
1530 bytes
[1] = (qp
& 0x3f);
1531 bytes
[2] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1532 bytes
[3] = (((y
& 1) << 7) | (treg
& 0x7f));
1533 count
+= output_leb128 (bytes
+ 4, t
, 0);
1534 (*f
) (count
, bytes
, NULL
);
1537 /* This function checks whether there are any outstanding .save-s and
1538 discards them if so. */
1541 check_pending_save (void)
1543 if (unwind
.pending_saves
)
1545 unw_rec_list
*cur
, *prev
;
1547 as_warn (_("Previous .save incomplete"));
1548 for (cur
= unwind
.list
, prev
= NULL
; cur
; )
1549 if (&cur
->r
.record
.p
== unwind
.pending_saves
)
1552 prev
->next
= cur
->next
;
1554 unwind
.list
= cur
->next
;
1555 if (cur
== unwind
.tail
)
1557 if (cur
== unwind
.current_entry
)
1558 unwind
.current_entry
= cur
->next
;
1559 /* Don't free the first discarded record, it's being used as
1560 terminator for (currently) br_gr and gr_gr processing, and
1561 also prevents leaving a dangling pointer to it in its
1563 cur
->r
.record
.p
.grmask
= 0;
1564 cur
->r
.record
.p
.brmask
= 0;
1565 cur
->r
.record
.p
.frmask
= 0;
1566 prev
= cur
->r
.record
.p
.next
;
1567 cur
->r
.record
.p
.next
= NULL
;
1579 cur
= cur
->r
.record
.p
.next
;
1582 unwind
.pending_saves
= NULL
;
1586 /* This function allocates a record list structure, and initializes fields. */
1588 static unw_rec_list
*
1589 alloc_record (unw_record_type t
)
1592 ptr
= xmalloc (sizeof (*ptr
));
1593 memset (ptr
, 0, sizeof (*ptr
));
1594 ptr
->slot_number
= SLOT_NUM_NOT_SET
;
1599 /* Dummy unwind record used for calculating the length of the last prologue or
1602 static unw_rec_list
*
1605 unw_rec_list
*ptr
= alloc_record (endp
);
1609 static unw_rec_list
*
1610 output_prologue (void)
1612 unw_rec_list
*ptr
= alloc_record (prologue
);
1613 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1617 static unw_rec_list
*
1618 output_prologue_gr (unsigned int saved_mask
, unsigned int reg
)
1620 unw_rec_list
*ptr
= alloc_record (prologue_gr
);
1621 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1622 ptr
->r
.record
.r
.grmask
= saved_mask
;
1623 ptr
->r
.record
.r
.grsave
= reg
;
1627 static unw_rec_list
*
1630 unw_rec_list
*ptr
= alloc_record (body
);
1634 static unw_rec_list
*
1635 output_mem_stack_f (unsigned int size
)
1637 unw_rec_list
*ptr
= alloc_record (mem_stack_f
);
1638 ptr
->r
.record
.p
.size
= size
;
1642 static unw_rec_list
*
1643 output_mem_stack_v (void)
1645 unw_rec_list
*ptr
= alloc_record (mem_stack_v
);
1649 static unw_rec_list
*
1650 output_psp_gr (unsigned int gr
)
1652 unw_rec_list
*ptr
= alloc_record (psp_gr
);
1653 ptr
->r
.record
.p
.r
.gr
= gr
;
1657 static unw_rec_list
*
1658 output_psp_sprel (unsigned int offset
)
1660 unw_rec_list
*ptr
= alloc_record (psp_sprel
);
1661 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1665 static unw_rec_list
*
1666 output_rp_when (void)
1668 unw_rec_list
*ptr
= alloc_record (rp_when
);
1672 static unw_rec_list
*
1673 output_rp_gr (unsigned int gr
)
1675 unw_rec_list
*ptr
= alloc_record (rp_gr
);
1676 ptr
->r
.record
.p
.r
.gr
= gr
;
1680 static unw_rec_list
*
1681 output_rp_br (unsigned int br
)
1683 unw_rec_list
*ptr
= alloc_record (rp_br
);
1684 ptr
->r
.record
.p
.r
.br
= br
;
1688 static unw_rec_list
*
1689 output_rp_psprel (unsigned int offset
)
1691 unw_rec_list
*ptr
= alloc_record (rp_psprel
);
1692 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1696 static unw_rec_list
*
1697 output_rp_sprel (unsigned int offset
)
1699 unw_rec_list
*ptr
= alloc_record (rp_sprel
);
1700 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1704 static unw_rec_list
*
1705 output_pfs_when (void)
1707 unw_rec_list
*ptr
= alloc_record (pfs_when
);
1711 static unw_rec_list
*
1712 output_pfs_gr (unsigned int gr
)
1714 unw_rec_list
*ptr
= alloc_record (pfs_gr
);
1715 ptr
->r
.record
.p
.r
.gr
= gr
;
1719 static unw_rec_list
*
1720 output_pfs_psprel (unsigned int offset
)
1722 unw_rec_list
*ptr
= alloc_record (pfs_psprel
);
1723 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1727 static unw_rec_list
*
1728 output_pfs_sprel (unsigned int offset
)
1730 unw_rec_list
*ptr
= alloc_record (pfs_sprel
);
1731 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1735 static unw_rec_list
*
1736 output_preds_when (void)
1738 unw_rec_list
*ptr
= alloc_record (preds_when
);
1742 static unw_rec_list
*
1743 output_preds_gr (unsigned int gr
)
1745 unw_rec_list
*ptr
= alloc_record (preds_gr
);
1746 ptr
->r
.record
.p
.r
.gr
= gr
;
1750 static unw_rec_list
*
1751 output_preds_psprel (unsigned int offset
)
1753 unw_rec_list
*ptr
= alloc_record (preds_psprel
);
1754 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1758 static unw_rec_list
*
1759 output_preds_sprel (unsigned int offset
)
1761 unw_rec_list
*ptr
= alloc_record (preds_sprel
);
1762 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1766 static unw_rec_list
*
1767 output_fr_mem (unsigned int mask
)
1769 unw_rec_list
*ptr
= alloc_record (fr_mem
);
1770 unw_rec_list
*cur
= ptr
;
1772 ptr
->r
.record
.p
.frmask
= mask
;
1773 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1776 unw_rec_list
*prev
= cur
;
1778 /* Clear least significant set bit. */
1779 mask
&= ~(mask
& (~mask
+ 1));
1782 cur
= alloc_record (fr_mem
);
1783 cur
->r
.record
.p
.frmask
= mask
;
1784 /* Retain only least significant bit. */
1785 prev
->r
.record
.p
.frmask
^= mask
;
1786 prev
->r
.record
.p
.next
= cur
;
1790 static unw_rec_list
*
1791 output_frgr_mem (unsigned int gr_mask
, unsigned int fr_mask
)
1793 unw_rec_list
*ptr
= alloc_record (frgr_mem
);
1794 unw_rec_list
*cur
= ptr
;
1796 unwind
.pending_saves
= &cur
->r
.record
.p
;
1797 cur
->r
.record
.p
.frmask
= fr_mask
;
1800 unw_rec_list
*prev
= cur
;
1802 /* Clear least significant set bit. */
1803 fr_mask
&= ~(fr_mask
& (~fr_mask
+ 1));
1804 if (!gr_mask
&& !fr_mask
)
1806 cur
= alloc_record (frgr_mem
);
1807 cur
->r
.record
.p
.frmask
= fr_mask
;
1808 /* Retain only least significant bit. */
1809 prev
->r
.record
.p
.frmask
^= fr_mask
;
1810 prev
->r
.record
.p
.next
= cur
;
1812 cur
->r
.record
.p
.grmask
= gr_mask
;
1815 unw_rec_list
*prev
= cur
;
1817 /* Clear least significant set bit. */
1818 gr_mask
&= ~(gr_mask
& (~gr_mask
+ 1));
1821 cur
= alloc_record (frgr_mem
);
1822 cur
->r
.record
.p
.grmask
= gr_mask
;
1823 /* Retain only least significant bit. */
1824 prev
->r
.record
.p
.grmask
^= gr_mask
;
1825 prev
->r
.record
.p
.next
= cur
;
1829 static unw_rec_list
*
1830 output_gr_gr (unsigned int mask
, unsigned int reg
)
1832 unw_rec_list
*ptr
= alloc_record (gr_gr
);
1833 unw_rec_list
*cur
= ptr
;
1835 ptr
->r
.record
.p
.grmask
= mask
;
1836 ptr
->r
.record
.p
.r
.gr
= reg
;
1837 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1840 unw_rec_list
*prev
= cur
;
1842 /* Clear least significant set bit. */
1843 mask
&= ~(mask
& (~mask
+ 1));
1846 cur
= alloc_record (gr_gr
);
1847 cur
->r
.record
.p
.grmask
= mask
;
1848 /* Indicate this record shouldn't be output. */
1849 cur
->r
.record
.p
.r
.gr
= REG_NUM
;
1850 /* Retain only least significant bit. */
1851 prev
->r
.record
.p
.grmask
^= mask
;
1852 prev
->r
.record
.p
.next
= cur
;
1856 static unw_rec_list
*
1857 output_gr_mem (unsigned int mask
)
1859 unw_rec_list
*ptr
= alloc_record (gr_mem
);
1860 unw_rec_list
*cur
= ptr
;
1862 ptr
->r
.record
.p
.grmask
= mask
;
1863 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1866 unw_rec_list
*prev
= cur
;
1868 /* Clear least significant set bit. */
1869 mask
&= ~(mask
& (~mask
+ 1));
1872 cur
= alloc_record (gr_mem
);
1873 cur
->r
.record
.p
.grmask
= mask
;
1874 /* Retain only least significant bit. */
1875 prev
->r
.record
.p
.grmask
^= mask
;
1876 prev
->r
.record
.p
.next
= cur
;
1880 static unw_rec_list
*
1881 output_br_mem (unsigned int mask
)
1883 unw_rec_list
*ptr
= alloc_record (br_mem
);
1884 unw_rec_list
*cur
= ptr
;
1886 ptr
->r
.record
.p
.brmask
= mask
;
1887 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1890 unw_rec_list
*prev
= cur
;
1892 /* Clear least significant set bit. */
1893 mask
&= ~(mask
& (~mask
+ 1));
1896 cur
= alloc_record (br_mem
);
1897 cur
->r
.record
.p
.brmask
= mask
;
1898 /* Retain only least significant bit. */
1899 prev
->r
.record
.p
.brmask
^= mask
;
1900 prev
->r
.record
.p
.next
= cur
;
1904 static unw_rec_list
*
1905 output_br_gr (unsigned int mask
, unsigned int reg
)
1907 unw_rec_list
*ptr
= alloc_record (br_gr
);
1908 unw_rec_list
*cur
= ptr
;
1910 ptr
->r
.record
.p
.brmask
= mask
;
1911 ptr
->r
.record
.p
.r
.gr
= reg
;
1912 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1915 unw_rec_list
*prev
= cur
;
1917 /* Clear least significant set bit. */
1918 mask
&= ~(mask
& (~mask
+ 1));
1921 cur
= alloc_record (br_gr
);
1922 cur
->r
.record
.p
.brmask
= mask
;
1923 /* Indicate this record shouldn't be output. */
1924 cur
->r
.record
.p
.r
.gr
= REG_NUM
;
1925 /* Retain only least significant bit. */
1926 prev
->r
.record
.p
.brmask
^= mask
;
1927 prev
->r
.record
.p
.next
= cur
;
1931 static unw_rec_list
*
1932 output_spill_base (unsigned int offset
)
1934 unw_rec_list
*ptr
= alloc_record (spill_base
);
1935 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1939 static unw_rec_list
*
1940 output_unat_when (void)
1942 unw_rec_list
*ptr
= alloc_record (unat_when
);
1946 static unw_rec_list
*
1947 output_unat_gr (unsigned int gr
)
1949 unw_rec_list
*ptr
= alloc_record (unat_gr
);
1950 ptr
->r
.record
.p
.r
.gr
= gr
;
1954 static unw_rec_list
*
1955 output_unat_psprel (unsigned int offset
)
1957 unw_rec_list
*ptr
= alloc_record (unat_psprel
);
1958 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1962 static unw_rec_list
*
1963 output_unat_sprel (unsigned int offset
)
1965 unw_rec_list
*ptr
= alloc_record (unat_sprel
);
1966 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1970 static unw_rec_list
*
1971 output_lc_when (void)
1973 unw_rec_list
*ptr
= alloc_record (lc_when
);
1977 static unw_rec_list
*
1978 output_lc_gr (unsigned int gr
)
1980 unw_rec_list
*ptr
= alloc_record (lc_gr
);
1981 ptr
->r
.record
.p
.r
.gr
= gr
;
1985 static unw_rec_list
*
1986 output_lc_psprel (unsigned int offset
)
1988 unw_rec_list
*ptr
= alloc_record (lc_psprel
);
1989 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1993 static unw_rec_list
*
1994 output_lc_sprel (unsigned int offset
)
1996 unw_rec_list
*ptr
= alloc_record (lc_sprel
);
1997 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2001 static unw_rec_list
*
2002 output_fpsr_when (void)
2004 unw_rec_list
*ptr
= alloc_record (fpsr_when
);
2008 static unw_rec_list
*
2009 output_fpsr_gr (unsigned int gr
)
2011 unw_rec_list
*ptr
= alloc_record (fpsr_gr
);
2012 ptr
->r
.record
.p
.r
.gr
= gr
;
2016 static unw_rec_list
*
2017 output_fpsr_psprel (unsigned int offset
)
2019 unw_rec_list
*ptr
= alloc_record (fpsr_psprel
);
2020 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2024 static unw_rec_list
*
2025 output_fpsr_sprel (unsigned int offset
)
2027 unw_rec_list
*ptr
= alloc_record (fpsr_sprel
);
2028 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2032 static unw_rec_list
*
2033 output_priunat_when_gr (void)
2035 unw_rec_list
*ptr
= alloc_record (priunat_when_gr
);
2039 static unw_rec_list
*
2040 output_priunat_when_mem (void)
2042 unw_rec_list
*ptr
= alloc_record (priunat_when_mem
);
2046 static unw_rec_list
*
2047 output_priunat_gr (unsigned int gr
)
2049 unw_rec_list
*ptr
= alloc_record (priunat_gr
);
2050 ptr
->r
.record
.p
.r
.gr
= gr
;
2054 static unw_rec_list
*
2055 output_priunat_psprel (unsigned int offset
)
2057 unw_rec_list
*ptr
= alloc_record (priunat_psprel
);
2058 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2062 static unw_rec_list
*
2063 output_priunat_sprel (unsigned int offset
)
2065 unw_rec_list
*ptr
= alloc_record (priunat_sprel
);
2066 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2070 static unw_rec_list
*
2071 output_bsp_when (void)
2073 unw_rec_list
*ptr
= alloc_record (bsp_when
);
2077 static unw_rec_list
*
2078 output_bsp_gr (unsigned int gr
)
2080 unw_rec_list
*ptr
= alloc_record (bsp_gr
);
2081 ptr
->r
.record
.p
.r
.gr
= gr
;
2085 static unw_rec_list
*
2086 output_bsp_psprel (unsigned int offset
)
2088 unw_rec_list
*ptr
= alloc_record (bsp_psprel
);
2089 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2093 static unw_rec_list
*
2094 output_bsp_sprel (unsigned int offset
)
2096 unw_rec_list
*ptr
= alloc_record (bsp_sprel
);
2097 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2101 static unw_rec_list
*
2102 output_bspstore_when (void)
2104 unw_rec_list
*ptr
= alloc_record (bspstore_when
);
2108 static unw_rec_list
*
2109 output_bspstore_gr (unsigned int gr
)
2111 unw_rec_list
*ptr
= alloc_record (bspstore_gr
);
2112 ptr
->r
.record
.p
.r
.gr
= gr
;
2116 static unw_rec_list
*
2117 output_bspstore_psprel (unsigned int offset
)
2119 unw_rec_list
*ptr
= alloc_record (bspstore_psprel
);
2120 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2124 static unw_rec_list
*
2125 output_bspstore_sprel (unsigned int offset
)
2127 unw_rec_list
*ptr
= alloc_record (bspstore_sprel
);
2128 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2132 static unw_rec_list
*
2133 output_rnat_when (void)
2135 unw_rec_list
*ptr
= alloc_record (rnat_when
);
2139 static unw_rec_list
*
2140 output_rnat_gr (unsigned int gr
)
2142 unw_rec_list
*ptr
= alloc_record (rnat_gr
);
2143 ptr
->r
.record
.p
.r
.gr
= gr
;
2147 static unw_rec_list
*
2148 output_rnat_psprel (unsigned int offset
)
2150 unw_rec_list
*ptr
= alloc_record (rnat_psprel
);
2151 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2155 static unw_rec_list
*
2156 output_rnat_sprel (unsigned int offset
)
2158 unw_rec_list
*ptr
= alloc_record (rnat_sprel
);
2159 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2163 static unw_rec_list
*
2164 output_unwabi (unsigned long abi
, unsigned long context
)
2166 unw_rec_list
*ptr
= alloc_record (unwabi
);
2167 ptr
->r
.record
.p
.abi
= abi
;
2168 ptr
->r
.record
.p
.context
= context
;
2172 static unw_rec_list
*
2173 output_epilogue (unsigned long ecount
)
2175 unw_rec_list
*ptr
= alloc_record (epilogue
);
2176 ptr
->r
.record
.b
.ecount
= ecount
;
2180 static unw_rec_list
*
2181 output_label_state (unsigned long label
)
2183 unw_rec_list
*ptr
= alloc_record (label_state
);
2184 ptr
->r
.record
.b
.label
= label
;
2188 static unw_rec_list
*
2189 output_copy_state (unsigned long label
)
2191 unw_rec_list
*ptr
= alloc_record (copy_state
);
2192 ptr
->r
.record
.b
.label
= label
;
2196 static unw_rec_list
*
2197 output_spill_psprel (unsigned int ab
,
2199 unsigned int offset
,
2200 unsigned int predicate
)
2202 unw_rec_list
*ptr
= alloc_record (predicate
? spill_psprel_p
: spill_psprel
);
2203 ptr
->r
.record
.x
.ab
= ab
;
2204 ptr
->r
.record
.x
.reg
= reg
;
2205 ptr
->r
.record
.x
.where
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2206 ptr
->r
.record
.x
.qp
= predicate
;
2210 static unw_rec_list
*
2211 output_spill_sprel (unsigned int ab
,
2213 unsigned int offset
,
2214 unsigned int predicate
)
2216 unw_rec_list
*ptr
= alloc_record (predicate
? spill_sprel_p
: spill_sprel
);
2217 ptr
->r
.record
.x
.ab
= ab
;
2218 ptr
->r
.record
.x
.reg
= reg
;
2219 ptr
->r
.record
.x
.where
.spoff
= offset
/ 4;
2220 ptr
->r
.record
.x
.qp
= predicate
;
2224 static unw_rec_list
*
2225 output_spill_reg (unsigned int ab
,
2227 unsigned int targ_reg
,
2229 unsigned int predicate
)
2231 unw_rec_list
*ptr
= alloc_record (predicate
? spill_reg_p
: spill_reg
);
2232 ptr
->r
.record
.x
.ab
= ab
;
2233 ptr
->r
.record
.x
.reg
= reg
;
2234 ptr
->r
.record
.x
.where
.reg
= targ_reg
;
2235 ptr
->r
.record
.x
.xy
= xy
;
2236 ptr
->r
.record
.x
.qp
= predicate
;
2240 /* Given a unw_rec_list process the correct format with the
2241 specified function. */
2244 process_one_record (unw_rec_list
*ptr
, vbyte_func f
)
2246 unsigned int fr_mask
, gr_mask
;
2248 switch (ptr
->r
.type
)
2250 /* This is a dummy record that takes up no space in the output. */
2258 /* These are taken care of by prologue/prologue_gr. */
2263 if (ptr
->r
.type
== prologue_gr
)
2264 output_R2_format (f
, ptr
->r
.record
.r
.grmask
,
2265 ptr
->r
.record
.r
.grsave
, ptr
->r
.record
.r
.rlen
);
2267 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2269 /* Output descriptor(s) for union of register spills (if any). */
2270 gr_mask
= ptr
->r
.record
.r
.mask
.gr_mem
;
2271 fr_mask
= ptr
->r
.record
.r
.mask
.fr_mem
;
2274 if ((fr_mask
& ~0xfUL
) == 0)
2275 output_P6_format (f
, fr_mem
, fr_mask
);
2278 output_P5_format (f
, gr_mask
, fr_mask
);
2283 output_P6_format (f
, gr_mem
, gr_mask
);
2284 if (ptr
->r
.record
.r
.mask
.br_mem
)
2285 output_P1_format (f
, ptr
->r
.record
.r
.mask
.br_mem
);
2287 /* output imask descriptor if necessary: */
2288 if (ptr
->r
.record
.r
.mask
.i
)
2289 output_P4_format (f
, ptr
->r
.record
.r
.mask
.i
,
2290 ptr
->r
.record
.r
.imask_size
);
2294 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2298 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
,
2299 ptr
->r
.record
.p
.size
);
2312 output_P3_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.r
.gr
);
2315 output_P3_format (f
, rp_br
, ptr
->r
.record
.p
.r
.br
);
2318 output_P7_format (f
, psp_sprel
, ptr
->r
.record
.p
.off
.sp
, 0);
2326 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
, 0);
2335 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.off
.psp
, 0);
2345 case bspstore_sprel
:
2347 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.off
.sp
);
2350 if (ptr
->r
.record
.p
.r
.gr
< REG_NUM
)
2352 const unw_rec_list
*cur
= ptr
;
2354 gr_mask
= cur
->r
.record
.p
.grmask
;
2355 while ((cur
= cur
->r
.record
.p
.next
) != NULL
)
2356 gr_mask
|= cur
->r
.record
.p
.grmask
;
2357 output_P9_format (f
, gr_mask
, ptr
->r
.record
.p
.r
.gr
);
2361 if (ptr
->r
.record
.p
.r
.gr
< REG_NUM
)
2363 const unw_rec_list
*cur
= ptr
;
2365 gr_mask
= cur
->r
.record
.p
.brmask
;
2366 while ((cur
= cur
->r
.record
.p
.next
) != NULL
)
2367 gr_mask
|= cur
->r
.record
.p
.brmask
;
2368 output_P2_format (f
, gr_mask
, ptr
->r
.record
.p
.r
.gr
);
2372 as_bad (_("spill_mask record unimplemented."));
2374 case priunat_when_gr
:
2375 case priunat_when_mem
:
2379 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
);
2381 case priunat_psprel
:
2383 case bspstore_psprel
:
2385 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.off
.psp
);
2388 output_P10_format (f
, ptr
->r
.record
.p
.abi
, ptr
->r
.record
.p
.context
);
2391 output_B3_format (f
, ptr
->r
.record
.b
.ecount
, ptr
->r
.record
.b
.t
);
2395 output_B4_format (f
, ptr
->r
.type
, ptr
->r
.record
.b
.label
);
2398 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2399 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2400 ptr
->r
.record
.x
.where
.pspoff
);
2403 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2404 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2405 ptr
->r
.record
.x
.where
.spoff
);
2408 output_X2_format (f
, ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2409 ptr
->r
.record
.x
.xy
>> 1, ptr
->r
.record
.x
.xy
,
2410 ptr
->r
.record
.x
.where
.reg
, ptr
->r
.record
.x
.t
);
2412 case spill_psprel_p
:
2413 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2414 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2415 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.where
.pspoff
);
2418 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2419 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2420 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.where
.spoff
);
2423 output_X4_format (f
, ptr
->r
.record
.x
.qp
, ptr
->r
.record
.x
.ab
,
2424 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.xy
>> 1,
2425 ptr
->r
.record
.x
.xy
, ptr
->r
.record
.x
.where
.reg
,
2429 as_bad (_("record_type_not_valid"));
2434 /* Given a unw_rec_list list, process all the records with
2435 the specified function. */
2437 process_unw_records (unw_rec_list
*list
, vbyte_func f
)
2440 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2441 process_one_record (ptr
, f
);
2444 /* Determine the size of a record list in bytes. */
2446 calc_record_size (unw_rec_list
*list
)
2449 process_unw_records (list
, count_output
);
2453 /* Return the number of bits set in the input value.
2454 Perhaps this has a better place... */
2455 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
2456 # define popcount __builtin_popcount
2459 popcount (unsigned x
)
2461 static const unsigned char popcnt
[16] =
2469 if (x
< NELEMS (popcnt
))
2471 return popcnt
[x
% NELEMS (popcnt
)] + popcount (x
/ NELEMS (popcnt
));
2475 /* Update IMASK bitmask to reflect the fact that one or more registers
2476 of type TYPE are saved starting at instruction with index T. If N
2477 bits are set in REGMASK, it is assumed that instructions T through
2478 T+N-1 save these registers.
2482 1: instruction saves next fp reg
2483 2: instruction saves next general reg
2484 3: instruction saves next branch reg */
2486 set_imask (unw_rec_list
*region
,
2487 unsigned long regmask
,
2491 unsigned char *imask
;
2492 unsigned long imask_size
;
2496 imask
= region
->r
.record
.r
.mask
.i
;
2497 imask_size
= region
->r
.record
.r
.imask_size
;
2500 imask_size
= (region
->r
.record
.r
.rlen
* 2 + 7) / 8 + 1;
2501 imask
= xmalloc (imask_size
);
2502 memset (imask
, 0, imask_size
);
2504 region
->r
.record
.r
.imask_size
= imask_size
;
2505 region
->r
.record
.r
.mask
.i
= imask
;
2509 pos
= 2 * (3 - t
% 4);
2512 if (i
>= imask_size
)
2514 as_bad (_("Ignoring attempt to spill beyond end of region"));
2518 imask
[i
] |= (type
& 0x3) << pos
;
2520 regmask
&= (regmask
- 1);
2530 /* Return the number of instruction slots from FIRST_ADDR to SLOT_ADDR.
2531 SLOT_FRAG is the frag containing SLOT_ADDR, and FIRST_FRAG is the frag
2532 containing FIRST_ADDR. If BEFORE_RELAX, then we use worst-case estimates
2535 static unsigned long
2536 slot_index (unsigned long slot_addr
,
2538 unsigned long first_addr
,
2542 unsigned long index
= 0;
2544 /* First time we are called, the initial address and frag are invalid. */
2545 if (first_addr
== 0)
2548 /* If the two addresses are in different frags, then we need to add in
2549 the remaining size of this frag, and then the entire size of intermediate
2551 while (slot_frag
!= first_frag
)
2553 unsigned long start_addr
= (unsigned long) &first_frag
->fr_literal
;
2557 /* We can get the final addresses only during and after
2559 if (first_frag
->fr_next
&& first_frag
->fr_next
->fr_address
)
2560 index
+= 3 * ((first_frag
->fr_next
->fr_address
2561 - first_frag
->fr_address
2562 - first_frag
->fr_fix
) >> 4);
2565 /* We don't know what the final addresses will be. We try our
2566 best to estimate. */
2567 switch (first_frag
->fr_type
)
2573 as_fatal (_("Only constant space allocation is supported"));
2579 /* Take alignment into account. Assume the worst case
2580 before relaxation. */
2581 index
+= 3 * ((1 << first_frag
->fr_offset
) >> 4);
2585 if (first_frag
->fr_symbol
)
2587 as_fatal (_("Only constant offsets are supported"));
2591 index
+= 3 * (first_frag
->fr_offset
>> 4);
2595 /* Add in the full size of the frag converted to instruction slots. */
2596 index
+= 3 * (first_frag
->fr_fix
>> 4);
2597 /* Subtract away the initial part before first_addr. */
2598 index
-= (3 * ((first_addr
>> 4) - (start_addr
>> 4))
2599 + ((first_addr
& 0x3) - (start_addr
& 0x3)));
2601 /* Move to the beginning of the next frag. */
2602 first_frag
= first_frag
->fr_next
;
2603 first_addr
= (unsigned long) &first_frag
->fr_literal
;
2605 /* This can happen if there is section switching in the middle of a
2606 function, causing the frag chain for the function to be broken.
2607 It is too difficult to recover safely from this problem, so we just
2608 exit with an error. */
2609 if (first_frag
== NULL
)
2610 as_fatal (_("Section switching in code is not supported."));
2613 /* Add in the used part of the last frag. */
2614 index
+= (3 * ((slot_addr
>> 4) - (first_addr
>> 4))
2615 + ((slot_addr
& 0x3) - (first_addr
& 0x3)));
2619 /* Optimize unwind record directives. */
2621 static unw_rec_list
*
2622 optimize_unw_records (unw_rec_list
*list
)
2627 /* If the only unwind record is ".prologue" or ".prologue" followed
2628 by ".body", then we can optimize the unwind directives away. */
2629 if (list
->r
.type
== prologue
2630 && (list
->next
->r
.type
== endp
2631 || (list
->next
->r
.type
== body
&& list
->next
->next
->r
.type
== endp
)))
2637 /* Given a complete record list, process any records which have
2638 unresolved fields, (ie length counts for a prologue). After
2639 this has been run, all necessary information should be available
2640 within each record to generate an image. */
2643 fixup_unw_records (unw_rec_list
*list
, int before_relax
)
2645 unw_rec_list
*ptr
, *region
= 0;
2646 unsigned long first_addr
= 0, rlen
= 0, t
;
2647 fragS
*first_frag
= 0;
2649 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2651 if (ptr
->slot_number
== SLOT_NUM_NOT_SET
)
2652 as_bad (_(" Insn slot not set in unwind record."));
2653 t
= slot_index (ptr
->slot_number
, ptr
->slot_frag
,
2654 first_addr
, first_frag
, before_relax
);
2655 switch (ptr
->r
.type
)
2663 unsigned long last_addr
= 0;
2664 fragS
*last_frag
= NULL
;
2666 first_addr
= ptr
->slot_number
;
2667 first_frag
= ptr
->slot_frag
;
2668 /* Find either the next body/prologue start, or the end of
2669 the function, and determine the size of the region. */
2670 for (last
= ptr
->next
; last
!= NULL
; last
= last
->next
)
2671 if (last
->r
.type
== prologue
|| last
->r
.type
== prologue_gr
2672 || last
->r
.type
== body
|| last
->r
.type
== endp
)
2674 last_addr
= last
->slot_number
;
2675 last_frag
= last
->slot_frag
;
2678 size
= slot_index (last_addr
, last_frag
, first_addr
, first_frag
,
2680 rlen
= ptr
->r
.record
.r
.rlen
= size
;
2681 if (ptr
->r
.type
== body
)
2682 /* End of region. */
2690 ptr
->r
.record
.b
.t
= rlen
- 1 - t
;
2692 /* This happens when a memory-stack-less procedure uses a
2693 ".restore sp" directive at the end of a region to pop
2695 ptr
->r
.record
.b
.t
= 0;
2706 case priunat_when_gr
:
2707 case priunat_when_mem
:
2711 ptr
->r
.record
.p
.t
= t
;
2719 case spill_psprel_p
:
2720 ptr
->r
.record
.x
.t
= t
;
2726 as_bad (_("frgr_mem record before region record!"));
2729 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.frmask
;
2730 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.grmask
;
2731 set_imask (region
, ptr
->r
.record
.p
.frmask
, t
, 1);
2732 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2737 as_bad (_("fr_mem record before region record!"));
2740 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.frmask
;
2741 set_imask (region
, ptr
->r
.record
.p
.frmask
, t
, 1);
2746 as_bad (_("gr_mem record before region record!"));
2749 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.grmask
;
2750 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2755 as_bad (_("br_mem record before region record!"));
2758 region
->r
.record
.r
.mask
.br_mem
|= ptr
->r
.record
.p
.brmask
;
2759 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2765 as_bad (_("gr_gr record before region record!"));
2768 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2773 as_bad (_("br_gr record before region record!"));
2776 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2785 /* Estimate the size of a frag before relaxing. We only have one type of frag
2786 to handle here, which is the unwind info frag. */
2789 ia64_estimate_size_before_relax (fragS
*frag
,
2790 asection
*segtype ATTRIBUTE_UNUSED
)
2795 /* ??? This code is identical to the first part of ia64_convert_frag. */
2796 list
= (unw_rec_list
*) frag
->fr_opcode
;
2797 fixup_unw_records (list
, 0);
2799 len
= calc_record_size (list
);
2800 /* pad to pointer-size boundary. */
2801 pad
= len
% md
.pointer_size
;
2803 len
+= md
.pointer_size
- pad
;
2804 /* Add 8 for the header. */
2806 /* Add a pointer for the personality offset. */
2807 if (frag
->fr_offset
)
2808 size
+= md
.pointer_size
;
2810 /* fr_var carries the max_chars that we created the fragment with.
2811 We must, of course, have allocated enough memory earlier. */
2812 assert (frag
->fr_var
>= size
);
2814 return frag
->fr_fix
+ size
;
2817 /* This function converts a rs_machine_dependent variant frag into a
2818 normal fill frag with the unwind image from the the record list. */
2820 ia64_convert_frag (fragS
*frag
)
2826 /* ??? This code is identical to ia64_estimate_size_before_relax. */
2827 list
= (unw_rec_list
*) frag
->fr_opcode
;
2828 fixup_unw_records (list
, 0);
2830 len
= calc_record_size (list
);
2831 /* pad to pointer-size boundary. */
2832 pad
= len
% md
.pointer_size
;
2834 len
+= md
.pointer_size
- pad
;
2835 /* Add 8 for the header. */
2837 /* Add a pointer for the personality offset. */
2838 if (frag
->fr_offset
)
2839 size
+= md
.pointer_size
;
2841 /* fr_var carries the max_chars that we created the fragment with.
2842 We must, of course, have allocated enough memory earlier. */
2843 assert (frag
->fr_var
>= size
);
2845 /* Initialize the header area. fr_offset is initialized with
2846 unwind.personality_routine. */
2847 if (frag
->fr_offset
)
2849 if (md
.flags
& EF_IA_64_ABI64
)
2850 flag_value
= (bfd_vma
) 3 << 32;
2852 /* 32-bit unwind info block. */
2853 flag_value
= (bfd_vma
) 0x1003 << 32;
2858 md_number_to_chars (frag
->fr_literal
,
2859 (((bfd_vma
) 1 << 48) /* Version. */
2860 | flag_value
/* U & E handler flags. */
2861 | (len
/ md
.pointer_size
)), /* Length. */
2864 /* Skip the header. */
2865 vbyte_mem_ptr
= frag
->fr_literal
+ 8;
2866 process_unw_records (list
, output_vbyte_mem
);
2868 /* Fill the padding bytes with zeros. */
2870 md_number_to_chars (frag
->fr_literal
+ len
+ 8 - md
.pointer_size
+ pad
, 0,
2871 md
.pointer_size
- pad
);
2872 /* Fill the unwind personality with zeros. */
2873 if (frag
->fr_offset
)
2874 md_number_to_chars (frag
->fr_literal
+ size
- md
.pointer_size
, 0,
2877 frag
->fr_fix
+= size
;
2878 frag
->fr_type
= rs_fill
;
2880 frag
->fr_offset
= 0;
2884 parse_predicate_and_operand (expressionS
*e
, unsigned *qp
, const char *po
)
2886 int sep
= parse_operand (e
, ',');
2888 *qp
= e
->X_add_number
- REG_P
;
2889 if (e
->X_op
!= O_register
|| *qp
> 63)
2891 as_bad (_("First operand to .%s must be a predicate"), po
);
2895 as_warn (_("Pointless use of p0 as first operand to .%s"), po
);
2897 sep
= parse_operand (e
, ',');
2904 convert_expr_to_ab_reg (const expressionS
*e
,
2910 unsigned int reg
= e
->X_add_number
;
2912 *ab
= *regp
= 0; /* Anything valid is good here. */
2914 if (e
->X_op
!= O_register
)
2915 reg
= REG_GR
; /* Anything invalid is good here. */
2917 if (reg
>= (REG_GR
+ 4) && reg
<= (REG_GR
+ 7))
2920 *regp
= reg
- REG_GR
;
2922 else if ((reg
>= (REG_FR
+ 2) && reg
<= (REG_FR
+ 5))
2923 || (reg
>= (REG_FR
+ 16) && reg
<= (REG_FR
+ 31)))
2926 *regp
= reg
- REG_FR
;
2928 else if (reg
>= (REG_BR
+ 1) && reg
<= (REG_BR
+ 5))
2931 *regp
= reg
- REG_BR
;
2938 case REG_PR
: *regp
= 0; break;
2939 case REG_PSP
: *regp
= 1; break;
2940 case REG_PRIUNAT
: *regp
= 2; break;
2941 case REG_BR
+ 0: *regp
= 3; break;
2942 case REG_AR
+ AR_BSP
: *regp
= 4; break;
2943 case REG_AR
+ AR_BSPSTORE
: *regp
= 5; break;
2944 case REG_AR
+ AR_RNAT
: *regp
= 6; break;
2945 case REG_AR
+ AR_UNAT
: *regp
= 7; break;
2946 case REG_AR
+ AR_FPSR
: *regp
= 8; break;
2947 case REG_AR
+ AR_PFS
: *regp
= 9; break;
2948 case REG_AR
+ AR_LC
: *regp
= 10; break;
2951 as_bad (_("Operand %d to .%s must be a preserved register"), n
, po
);
2958 convert_expr_to_xy_reg (const expressionS
*e
,
2964 unsigned int reg
= e
->X_add_number
;
2966 *xy
= *regp
= 0; /* Anything valid is good here. */
2968 if (e
->X_op
!= O_register
)
2969 reg
= REG_GR
; /* Anything invalid is good here. */
2971 if (reg
>= (REG_GR
+ 1) && reg
<= (REG_GR
+ 127))
2974 *regp
= reg
- REG_GR
;
2976 else if (reg
>= (REG_FR
+ 2) && reg
<= (REG_FR
+ 127))
2979 *regp
= reg
- REG_FR
;
2981 else if (reg
>= REG_BR
&& reg
<= (REG_BR
+ 7))
2984 *regp
= reg
- REG_BR
;
2987 as_bad (_("Operand %d to .%s must be a writable register"), n
, po
);
2993 /* The current frag is an alignment frag. */
2994 align_frag
= frag_now
;
2995 s_align_bytes (arg
);
2999 dot_radix (int dummy ATTRIBUTE_UNUSED
)
3006 if (is_it_end_of_statement ())
3008 radix
= input_line_pointer
;
3009 ch
= get_symbol_end ();
3010 ia64_canonicalize_symbol_name (radix
);
3011 if (strcasecmp (radix
, "C"))
3012 as_bad (_("Radix `%s' unsupported or invalid"), radix
);
3013 *input_line_pointer
= ch
;
3014 demand_empty_rest_of_line ();
3017 /* Helper function for .loc directives. If the assembler is not generating
3018 line number info, then we need to remember which instructions have a .loc
3019 directive, and only call dwarf2_gen_line_info for those instructions. */
3024 CURR_SLOT
.loc_directive_seen
= 1;
3025 dwarf2_directive_loc (x
);
3028 /* .sbss, .bss etc. are macros that expand into ".section SECNAME". */
3030 dot_special_section (int which
)
3032 set_section ((char *) special_section_name
[which
]);
3035 /* Return -1 for warning and 0 for error. */
3038 unwind_diagnostic (const char * region
, const char *directive
)
3040 if (md
.unwind_check
== unwind_check_warning
)
3042 as_warn (_(".%s outside of %s"), directive
, region
);
3047 as_bad (_(".%s outside of %s"), directive
, region
);
3048 ignore_rest_of_line ();
3053 /* Return 1 if a directive is in a procedure, -1 if a directive isn't in
3054 a procedure but the unwind directive check is set to warning, 0 if
3055 a directive isn't in a procedure and the unwind directive check is set
3059 in_procedure (const char *directive
)
3061 if (unwind
.proc_pending
.sym
3062 && (!unwind
.saved_text_seg
|| strcmp (directive
, "endp") == 0))
3064 return unwind_diagnostic ("procedure", directive
);
3067 /* Return 1 if a directive is in a prologue, -1 if a directive isn't in
3068 a prologue but the unwind directive check is set to warning, 0 if
3069 a directive isn't in a prologue and the unwind directive check is set
3073 in_prologue (const char *directive
)
3075 int in
= in_procedure (directive
);
3077 if (in
> 0 && !unwind
.prologue
)
3078 in
= unwind_diagnostic ("prologue", directive
);
3079 check_pending_save ();
3083 /* Return 1 if a directive is in a body, -1 if a directive isn't in
3084 a body but the unwind directive check is set to warning, 0 if
3085 a directive isn't in a body and the unwind directive check is set
3089 in_body (const char *directive
)
3091 int in
= in_procedure (directive
);
3093 if (in
> 0 && !unwind
.body
)
3094 in
= unwind_diagnostic ("body region", directive
);
3099 add_unwind_entry (unw_rec_list
*ptr
, int sep
)
3104 unwind
.tail
->next
= ptr
;
3109 /* The current entry can in fact be a chain of unwind entries. */
3110 if (unwind
.current_entry
== NULL
)
3111 unwind
.current_entry
= ptr
;
3114 /* The current entry can in fact be a chain of unwind entries. */
3115 if (unwind
.current_entry
== NULL
)
3116 unwind
.current_entry
= ptr
;
3120 /* Parse a tag permitted for the current directive. */
3124 ch
= get_symbol_end ();
3125 /* FIXME: For now, just issue a warning that this isn't implemented. */
3132 as_warn (_("Tags on unwind pseudo-ops aren't supported, yet"));
3135 *input_line_pointer
= ch
;
3137 if (sep
!= NOT_A_CHAR
)
3138 demand_empty_rest_of_line ();
3142 dot_fframe (int dummy ATTRIBUTE_UNUSED
)
3147 if (!in_prologue ("fframe"))
3150 sep
= parse_operand (&e
, ',');
3152 if (e
.X_op
!= O_constant
)
3154 as_bad (_("First operand to .fframe must be a constant"));
3157 add_unwind_entry (output_mem_stack_f (e
.X_add_number
), sep
);
3161 dot_vframe (int dummy ATTRIBUTE_UNUSED
)
3167 if (!in_prologue ("vframe"))
3170 sep
= parse_operand (&e
, ',');
3171 reg
= e
.X_add_number
- REG_GR
;
3172 if (e
.X_op
!= O_register
|| reg
> 127)
3174 as_bad (_("First operand to .vframe must be a general register"));
3177 add_unwind_entry (output_mem_stack_v (), sep
);
3178 if (! (unwind
.prologue_mask
& 2))
3179 add_unwind_entry (output_psp_gr (reg
), NOT_A_CHAR
);
3180 else if (reg
!= unwind
.prologue_gr
3181 + (unsigned) popcount (unwind
.prologue_mask
& (-2 << 1)))
3182 as_warn (_("Operand of .vframe contradicts .prologue"));
3186 dot_vframesp (int psp
)
3192 as_warn (_(".vframepsp is meaningless, assuming .vframesp was meant"));
3194 if (!in_prologue ("vframesp"))
3197 sep
= parse_operand (&e
, ',');
3198 if (e
.X_op
!= O_constant
)
3200 as_bad (_("Operand to .vframesp must be a constant (sp-relative offset)"));
3203 add_unwind_entry (output_mem_stack_v (), sep
);
3204 add_unwind_entry (output_psp_sprel (e
.X_add_number
), NOT_A_CHAR
);
3208 dot_save (int dummy ATTRIBUTE_UNUSED
)
3211 unsigned reg1
, reg2
;
3214 if (!in_prologue ("save"))
3217 sep
= parse_operand (&e1
, ',');
3219 sep
= parse_operand (&e2
, ',');
3223 reg1
= e1
.X_add_number
;
3224 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3225 if (e1
.X_op
!= O_register
)
3227 as_bad (_("First operand to .save not a register"));
3228 reg1
= REG_PR
; /* Anything valid is good here. */
3230 reg2
= e2
.X_add_number
- REG_GR
;
3231 if (e2
.X_op
!= O_register
|| reg2
> 127)
3233 as_bad (_("Second operand to .save not a valid register"));
3238 case REG_AR
+ AR_BSP
:
3239 add_unwind_entry (output_bsp_when (), sep
);
3240 add_unwind_entry (output_bsp_gr (reg2
), NOT_A_CHAR
);
3242 case REG_AR
+ AR_BSPSTORE
:
3243 add_unwind_entry (output_bspstore_when (), sep
);
3244 add_unwind_entry (output_bspstore_gr (reg2
), NOT_A_CHAR
);
3246 case REG_AR
+ AR_RNAT
:
3247 add_unwind_entry (output_rnat_when (), sep
);
3248 add_unwind_entry (output_rnat_gr (reg2
), NOT_A_CHAR
);
3250 case REG_AR
+ AR_UNAT
:
3251 add_unwind_entry (output_unat_when (), sep
);
3252 add_unwind_entry (output_unat_gr (reg2
), NOT_A_CHAR
);
3254 case REG_AR
+ AR_FPSR
:
3255 add_unwind_entry (output_fpsr_when (), sep
);
3256 add_unwind_entry (output_fpsr_gr (reg2
), NOT_A_CHAR
);
3258 case REG_AR
+ AR_PFS
:
3259 add_unwind_entry (output_pfs_when (), sep
);
3260 if (! (unwind
.prologue_mask
& 4))
3261 add_unwind_entry (output_pfs_gr (reg2
), NOT_A_CHAR
);
3262 else if (reg2
!= unwind
.prologue_gr
3263 + (unsigned) popcount (unwind
.prologue_mask
& (-4 << 1)))
3264 as_warn (_("Second operand of .save contradicts .prologue"));
3266 case REG_AR
+ AR_LC
:
3267 add_unwind_entry (output_lc_when (), sep
);
3268 add_unwind_entry (output_lc_gr (reg2
), NOT_A_CHAR
);
3271 add_unwind_entry (output_rp_when (), sep
);
3272 if (! (unwind
.prologue_mask
& 8))
3273 add_unwind_entry (output_rp_gr (reg2
), NOT_A_CHAR
);
3274 else if (reg2
!= unwind
.prologue_gr
)
3275 as_warn (_("Second operand of .save contradicts .prologue"));
3278 add_unwind_entry (output_preds_when (), sep
);
3279 if (! (unwind
.prologue_mask
& 1))
3280 add_unwind_entry (output_preds_gr (reg2
), NOT_A_CHAR
);
3281 else if (reg2
!= unwind
.prologue_gr
3282 + (unsigned) popcount (unwind
.prologue_mask
& (-1 << 1)))
3283 as_warn (_("Second operand of .save contradicts .prologue"));
3286 add_unwind_entry (output_priunat_when_gr (), sep
);
3287 add_unwind_entry (output_priunat_gr (reg2
), NOT_A_CHAR
);
3290 as_bad (_("First operand to .save not a valid register"));
3291 add_unwind_entry (NULL
, sep
);
3297 dot_restore (int dummy ATTRIBUTE_UNUSED
)
3300 unsigned long ecount
; /* # of _additional_ regions to pop */
3303 if (!in_body ("restore"))
3306 sep
= parse_operand (&e1
, ',');
3307 if (e1
.X_op
!= O_register
|| e1
.X_add_number
!= REG_GR
+ 12)
3308 as_bad (_("First operand to .restore must be stack pointer (sp)"));
3314 sep
= parse_operand (&e2
, ',');
3315 if (e2
.X_op
!= O_constant
|| e2
.X_add_number
< 0)
3317 as_bad (_("Second operand to .restore must be a constant >= 0"));
3318 e2
.X_add_number
= 0;
3320 ecount
= e2
.X_add_number
;
3323 ecount
= unwind
.prologue_count
- 1;
3325 if (ecount
>= unwind
.prologue_count
)
3327 as_bad (_("Epilogue count of %lu exceeds number of nested prologues (%u)"),
3328 ecount
+ 1, unwind
.prologue_count
);
3332 add_unwind_entry (output_epilogue (ecount
), sep
);
3334 if (ecount
< unwind
.prologue_count
)
3335 unwind
.prologue_count
-= ecount
+ 1;
3337 unwind
.prologue_count
= 0;
3341 dot_restorereg (int pred
)
3343 unsigned int qp
, ab
, reg
;
3346 const char * const po
= pred
? "restorereg.p" : "restorereg";
3348 if (!in_procedure (po
))
3352 sep
= parse_predicate_and_operand (&e
, &qp
, po
);
3355 sep
= parse_operand (&e
, ',');
3358 convert_expr_to_ab_reg (&e
, &ab
, ®
, po
, 1 + pred
);
3360 add_unwind_entry (output_spill_reg (ab
, reg
, 0, 0, qp
), sep
);
3363 static char *special_linkonce_name
[] =
3365 ".gnu.linkonce.ia64unw.", ".gnu.linkonce.ia64unwi."
3369 start_unwind_section (const segT text_seg
, int sec_index
)
3372 Use a slightly ugly scheme to derive the unwind section names from
3373 the text section name:
3375 text sect. unwind table sect.
3376 name: name: comments:
3377 ---------- ----------------- --------------------------------
3379 .text.foo .IA_64.unwind.text.foo
3380 .foo .IA_64.unwind.foo
3382 .gnu.linkonce.ia64unw.foo
3383 _info .IA_64.unwind_info gas issues error message (ditto)
3384 _infoFOO .IA_64.unwind_infoFOO gas issues error message (ditto)
3386 This mapping is done so that:
3388 (a) An object file with unwind info only in .text will use
3389 unwind section names .IA_64.unwind and .IA_64.unwind_info.
3390 This follows the letter of the ABI and also ensures backwards
3391 compatibility with older toolchains.
3393 (b) An object file with unwind info in multiple text sections
3394 will use separate unwind sections for each text section.
3395 This allows us to properly set the "sh_info" and "sh_link"
3396 fields in SHT_IA_64_UNWIND as required by the ABI and also
3397 lets GNU ld support programs with multiple segments
3398 containing unwind info (as might be the case for certain
3399 embedded applications).
3401 (c) An error is issued if there would be a name clash.
3404 const char *text_name
, *sec_text_name
;
3406 const char *prefix
= special_section_name
[sec_index
];
3408 size_t prefix_len
, suffix_len
, sec_name_len
;
3410 sec_text_name
= segment_name (text_seg
);
3411 text_name
= sec_text_name
;
3412 if (strncmp (text_name
, "_info", 5) == 0)
3414 as_bad (_("Illegal section name `%s' (causes unwind section name clash)"),
3416 ignore_rest_of_line ();
3419 if (strcmp (text_name
, ".text") == 0)
3422 /* Build the unwind section name by appending the (possibly stripped)
3423 text section name to the unwind prefix. */
3425 if (strncmp (text_name
, ".gnu.linkonce.t.",
3426 sizeof (".gnu.linkonce.t.") - 1) == 0)
3428 prefix
= special_linkonce_name
[sec_index
- SPECIAL_SECTION_UNWIND
];
3429 suffix
+= sizeof (".gnu.linkonce.t.") - 1;
3432 prefix_len
= strlen (prefix
);
3433 suffix_len
= strlen (suffix
);
3434 sec_name_len
= prefix_len
+ suffix_len
;
3435 sec_name
= alloca (sec_name_len
+ 1);
3436 memcpy (sec_name
, prefix
, prefix_len
);
3437 memcpy (sec_name
+ prefix_len
, suffix
, suffix_len
);
3438 sec_name
[sec_name_len
] = '\0';
3440 /* Handle COMDAT group. */
3441 if ((text_seg
->flags
& SEC_LINK_ONCE
) != 0
3442 && (elf_section_flags (text_seg
) & SHF_GROUP
) != 0)
3445 size_t len
, group_name_len
;
3446 const char *group_name
= elf_group_name (text_seg
);
3448 if (group_name
== NULL
)
3450 as_bad (_("Group section `%s' has no group signature"),
3452 ignore_rest_of_line ();
3455 /* We have to construct a fake section directive. */
3456 group_name_len
= strlen (group_name
);
3458 + 16 /* ,"aG",@progbits, */
3459 + group_name_len
/* ,group_name */
3462 section
= alloca (len
+ 1);
3463 memcpy (section
, sec_name
, sec_name_len
);
3464 memcpy (section
+ sec_name_len
, ",\"aG\",@progbits,", 16);
3465 memcpy (section
+ sec_name_len
+ 16, group_name
, group_name_len
);
3466 memcpy (section
+ len
- 7, ",comdat", 7);
3467 section
[len
] = '\0';
3468 set_section (section
);
3472 set_section (sec_name
);
3473 bfd_set_section_flags (stdoutput
, now_seg
,
3474 SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
);
3477 elf_linked_to_section (now_seg
) = text_seg
;
3481 generate_unwind_image (const segT text_seg
)
3486 /* Mark the end of the unwind info, so that we can compute the size of the
3487 last unwind region. */
3488 add_unwind_entry (output_endp (), NOT_A_CHAR
);
3490 /* Force out pending instructions, to make sure all unwind records have
3491 a valid slot_number field. */
3492 ia64_flush_insns ();
3494 /* Generate the unwind record. */
3495 list
= optimize_unw_records (unwind
.list
);
3496 fixup_unw_records (list
, 1);
3497 size
= calc_record_size (list
);
3499 if (size
> 0 || unwind
.force_unwind_entry
)
3501 unwind
.force_unwind_entry
= 0;
3502 /* pad to pointer-size boundary. */
3503 pad
= size
% md
.pointer_size
;
3505 size
+= md
.pointer_size
- pad
;
3506 /* Add 8 for the header. */
3508 /* Add a pointer for the personality offset. */
3509 if (unwind
.personality_routine
)
3510 size
+= md
.pointer_size
;
3513 /* If there are unwind records, switch sections, and output the info. */
3517 bfd_reloc_code_real_type reloc
;
3519 start_unwind_section (text_seg
, SPECIAL_SECTION_UNWIND_INFO
);
3521 /* Make sure the section has 4 byte alignment for ILP32 and
3522 8 byte alignment for LP64. */
3523 frag_align (md
.pointer_size_shift
, 0, 0);
3524 record_alignment (now_seg
, md
.pointer_size_shift
);
3526 /* Set expression which points to start of unwind descriptor area. */
3527 unwind
.info
= expr_build_dot ();
3529 frag_var (rs_machine_dependent
, size
, size
, 0, 0,
3530 (offsetT
) (long) unwind
.personality_routine
,
3533 /* Add the personality address to the image. */
3534 if (unwind
.personality_routine
!= 0)
3536 exp
.X_op
= O_symbol
;
3537 exp
.X_add_symbol
= unwind
.personality_routine
;
3538 exp
.X_add_number
= 0;
3540 if (md
.flags
& EF_IA_64_BE
)
3542 if (md
.flags
& EF_IA_64_ABI64
)
3543 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64MSB
;
3545 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32MSB
;
3549 if (md
.flags
& EF_IA_64_ABI64
)
3550 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64LSB
;
3552 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32LSB
;
3555 fix_new_exp (frag_now
, frag_now_fix () - md
.pointer_size
,
3556 md
.pointer_size
, &exp
, 0, reloc
);
3557 unwind
.personality_routine
= 0;
3561 free_saved_prologue_counts ();
3562 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
3566 dot_handlerdata (int dummy ATTRIBUTE_UNUSED
)
3568 if (!in_procedure ("handlerdata"))
3570 unwind
.force_unwind_entry
= 1;
3572 /* Remember which segment we're in so we can switch back after .endp */
3573 unwind
.saved_text_seg
= now_seg
;
3574 unwind
.saved_text_subseg
= now_subseg
;
3576 /* Generate unwind info into unwind-info section and then leave that
3577 section as the currently active one so dataXX directives go into
3578 the language specific data area of the unwind info block. */
3579 generate_unwind_image (now_seg
);
3580 demand_empty_rest_of_line ();
3584 dot_unwentry (int dummy ATTRIBUTE_UNUSED
)
3586 if (!in_procedure ("unwentry"))
3588 unwind
.force_unwind_entry
= 1;
3589 demand_empty_rest_of_line ();
3593 dot_altrp (int dummy ATTRIBUTE_UNUSED
)
3598 if (!in_prologue ("altrp"))
3601 parse_operand (&e
, 0);
3602 reg
= e
.X_add_number
- REG_BR
;
3603 if (e
.X_op
!= O_register
|| reg
> 7)
3605 as_bad (_("First operand to .altrp not a valid branch register"));
3608 add_unwind_entry (output_rp_br (reg
), 0);
3612 dot_savemem (int psprel
)
3617 const char * const po
= psprel
? "savepsp" : "savesp";
3619 if (!in_prologue (po
))
3622 sep
= parse_operand (&e1
, ',');
3624 sep
= parse_operand (&e2
, ',');
3628 reg1
= e1
.X_add_number
;
3629 val
= e2
.X_add_number
;
3631 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3632 if (e1
.X_op
!= O_register
)
3634 as_bad (_("First operand to .%s not a register"), po
);
3635 reg1
= REG_PR
; /* Anything valid is good here. */
3637 if (e2
.X_op
!= O_constant
)
3639 as_bad (_("Second operand to .%s not a constant"), po
);
3645 case REG_AR
+ AR_BSP
:
3646 add_unwind_entry (output_bsp_when (), sep
);
3647 add_unwind_entry ((psprel
3649 : output_bsp_sprel
) (val
), NOT_A_CHAR
);
3651 case REG_AR
+ AR_BSPSTORE
:
3652 add_unwind_entry (output_bspstore_when (), sep
);
3653 add_unwind_entry ((psprel
3654 ? output_bspstore_psprel
3655 : output_bspstore_sprel
) (val
), NOT_A_CHAR
);
3657 case REG_AR
+ AR_RNAT
:
3658 add_unwind_entry (output_rnat_when (), sep
);
3659 add_unwind_entry ((psprel
3660 ? output_rnat_psprel
3661 : output_rnat_sprel
) (val
), NOT_A_CHAR
);
3663 case REG_AR
+ AR_UNAT
:
3664 add_unwind_entry (output_unat_when (), sep
);
3665 add_unwind_entry ((psprel
3666 ? output_unat_psprel
3667 : output_unat_sprel
) (val
), NOT_A_CHAR
);
3669 case REG_AR
+ AR_FPSR
:
3670 add_unwind_entry (output_fpsr_when (), sep
);
3671 add_unwind_entry ((psprel
3672 ? output_fpsr_psprel
3673 : output_fpsr_sprel
) (val
), NOT_A_CHAR
);
3675 case REG_AR
+ AR_PFS
:
3676 add_unwind_entry (output_pfs_when (), sep
);
3677 add_unwind_entry ((psprel
3679 : output_pfs_sprel
) (val
), NOT_A_CHAR
);
3681 case REG_AR
+ AR_LC
:
3682 add_unwind_entry (output_lc_when (), sep
);
3683 add_unwind_entry ((psprel
3685 : output_lc_sprel
) (val
), NOT_A_CHAR
);
3688 add_unwind_entry (output_rp_when (), sep
);
3689 add_unwind_entry ((psprel
3691 : output_rp_sprel
) (val
), NOT_A_CHAR
);
3694 add_unwind_entry (output_preds_when (), sep
);
3695 add_unwind_entry ((psprel
3696 ? output_preds_psprel
3697 : output_preds_sprel
) (val
), NOT_A_CHAR
);
3700 add_unwind_entry (output_priunat_when_mem (), sep
);
3701 add_unwind_entry ((psprel
3702 ? output_priunat_psprel
3703 : output_priunat_sprel
) (val
), NOT_A_CHAR
);
3706 as_bad (_("First operand to .%s not a valid register"), po
);
3707 add_unwind_entry (NULL
, sep
);
3713 dot_saveg (int dummy ATTRIBUTE_UNUSED
)
3719 if (!in_prologue ("save.g"))
3722 sep
= parse_operand (&e
, ',');
3724 grmask
= e
.X_add_number
;
3725 if (e
.X_op
!= O_constant
3726 || e
.X_add_number
<= 0
3727 || e
.X_add_number
> 0xf)
3729 as_bad (_("First operand to .save.g must be a positive 4-bit constant"));
3736 int n
= popcount (grmask
);
3738 parse_operand (&e
, 0);
3739 reg
= e
.X_add_number
- REG_GR
;
3740 if (e
.X_op
!= O_register
|| reg
> 127)
3742 as_bad (_("Second operand to .save.g must be a general register"));
3745 else if (reg
> 128U - n
)
3747 as_bad (_("Second operand to .save.g must be the first of %d general registers"), n
);
3750 add_unwind_entry (output_gr_gr (grmask
, reg
), 0);
3753 add_unwind_entry (output_gr_mem (grmask
), 0);
3757 dot_savef (int dummy ATTRIBUTE_UNUSED
)
3761 if (!in_prologue ("save.f"))
3764 parse_operand (&e
, 0);
3766 if (e
.X_op
!= O_constant
3767 || e
.X_add_number
<= 0
3768 || e
.X_add_number
> 0xfffff)
3770 as_bad (_("Operand to .save.f must be a positive 20-bit constant"));
3773 add_unwind_entry (output_fr_mem (e
.X_add_number
), 0);
3777 dot_saveb (int dummy ATTRIBUTE_UNUSED
)
3783 if (!in_prologue ("save.b"))
3786 sep
= parse_operand (&e
, ',');
3788 brmask
= e
.X_add_number
;
3789 if (e
.X_op
!= O_constant
3790 || e
.X_add_number
<= 0
3791 || e
.X_add_number
> 0x1f)
3793 as_bad (_("First operand to .save.b must be a positive 5-bit constant"));
3800 int n
= popcount (brmask
);
3802 parse_operand (&e
, 0);
3803 reg
= e
.X_add_number
- REG_GR
;
3804 if (e
.X_op
!= O_register
|| reg
> 127)
3806 as_bad (_("Second operand to .save.b must be a general register"));
3809 else if (reg
> 128U - n
)
3811 as_bad (_("Second operand to .save.b must be the first of %d general registers"), n
);
3814 add_unwind_entry (output_br_gr (brmask
, reg
), 0);
3817 add_unwind_entry (output_br_mem (brmask
), 0);
3821 dot_savegf (int dummy ATTRIBUTE_UNUSED
)
3825 if (!in_prologue ("save.gf"))
3828 if (parse_operand (&e1
, ',') == ',')
3829 parse_operand (&e2
, 0);
3833 if (e1
.X_op
!= O_constant
3834 || e1
.X_add_number
< 0
3835 || e1
.X_add_number
> 0xf)
3837 as_bad (_("First operand to .save.gf must be a non-negative 4-bit constant"));
3839 e1
.X_add_number
= 0;
3841 if (e2
.X_op
!= O_constant
3842 || e2
.X_add_number
< 0
3843 || e2
.X_add_number
> 0xfffff)
3845 as_bad (_("Second operand to .save.gf must be a non-negative 20-bit constant"));
3847 e2
.X_add_number
= 0;
3849 if (e1
.X_op
== O_constant
3850 && e2
.X_op
== O_constant
3851 && e1
.X_add_number
== 0
3852 && e2
.X_add_number
== 0)
3853 as_bad (_("Operands to .save.gf may not be both zero"));
3855 add_unwind_entry (output_frgr_mem (e1
.X_add_number
, e2
.X_add_number
), 0);
3859 dot_spill (int dummy ATTRIBUTE_UNUSED
)
3863 if (!in_prologue ("spill"))
3866 parse_operand (&e
, 0);
3868 if (e
.X_op
!= O_constant
)
3870 as_bad (_("Operand to .spill must be a constant"));
3873 add_unwind_entry (output_spill_base (e
.X_add_number
), 0);
3877 dot_spillreg (int pred
)
3880 unsigned int qp
, ab
, xy
, reg
, treg
;
3882 const char * const po
= pred
? "spillreg.p" : "spillreg";
3884 if (!in_procedure (po
))
3888 sep
= parse_predicate_and_operand (&e
, &qp
, po
);
3891 sep
= parse_operand (&e
, ',');
3894 convert_expr_to_ab_reg (&e
, &ab
, ®
, po
, 1 + pred
);
3897 sep
= parse_operand (&e
, ',');
3900 convert_expr_to_xy_reg (&e
, &xy
, &treg
, po
, 2 + pred
);
3902 add_unwind_entry (output_spill_reg (ab
, reg
, treg
, xy
, qp
), sep
);
3906 dot_spillmem (int psprel
)
3909 int pred
= (psprel
< 0), sep
;
3910 unsigned int qp
, ab
, reg
;
3916 po
= psprel
? "spillpsp.p" : "spillsp.p";
3919 po
= psprel
? "spillpsp" : "spillsp";
3921 if (!in_procedure (po
))
3925 sep
= parse_predicate_and_operand (&e
, &qp
, po
);
3928 sep
= parse_operand (&e
, ',');
3931 convert_expr_to_ab_reg (&e
, &ab
, ®
, po
, 1 + pred
);
3934 sep
= parse_operand (&e
, ',');
3937 if (e
.X_op
!= O_constant
)
3939 as_bad (_("Operand %d to .%s must be a constant"), 2 + pred
, po
);
3944 add_unwind_entry (output_spill_psprel (ab
, reg
, e
.X_add_number
, qp
), sep
);
3946 add_unwind_entry (output_spill_sprel (ab
, reg
, e
.X_add_number
, qp
), sep
);
3950 get_saved_prologue_count (unsigned long lbl
)
3952 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3954 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
3958 return lpc
->prologue_count
;
3960 as_bad (_("Missing .label_state %ld"), lbl
);
3965 save_prologue_count (unsigned long lbl
, unsigned int count
)
3967 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3969 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
3973 lpc
->prologue_count
= count
;
3976 label_prologue_count
*new_lpc
= xmalloc (sizeof (* new_lpc
));
3978 new_lpc
->next
= unwind
.saved_prologue_counts
;
3979 new_lpc
->label_number
= lbl
;
3980 new_lpc
->prologue_count
= count
;
3981 unwind
.saved_prologue_counts
= new_lpc
;
3986 free_saved_prologue_counts ()
3988 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3989 label_prologue_count
*next
;
3998 unwind
.saved_prologue_counts
= NULL
;
4002 dot_label_state (int dummy ATTRIBUTE_UNUSED
)
4006 if (!in_body ("label_state"))
4009 parse_operand (&e
, 0);
4010 if (e
.X_op
== O_constant
)
4011 save_prologue_count (e
.X_add_number
, unwind
.prologue_count
);
4014 as_bad (_("Operand to .label_state must be a constant"));
4017 add_unwind_entry (output_label_state (e
.X_add_number
), 0);
4021 dot_copy_state (int dummy ATTRIBUTE_UNUSED
)
4025 if (!in_body ("copy_state"))
4028 parse_operand (&e
, 0);
4029 if (e
.X_op
== O_constant
)
4030 unwind
.prologue_count
= get_saved_prologue_count (e
.X_add_number
);
4033 as_bad (_("Operand to .copy_state must be a constant"));
4036 add_unwind_entry (output_copy_state (e
.X_add_number
), 0);
4040 dot_unwabi (int dummy ATTRIBUTE_UNUSED
)
4045 if (!in_prologue ("unwabi"))
4048 sep
= parse_operand (&e1
, ',');
4050 parse_operand (&e2
, 0);
4054 if (e1
.X_op
!= O_constant
)
4056 as_bad (_("First operand to .unwabi must be a constant"));
4057 e1
.X_add_number
= 0;
4060 if (e2
.X_op
!= O_constant
)
4062 as_bad (_("Second operand to .unwabi must be a constant"));
4063 e2
.X_add_number
= 0;
4066 add_unwind_entry (output_unwabi (e1
.X_add_number
, e2
.X_add_number
), 0);
4070 dot_personality (int dummy ATTRIBUTE_UNUSED
)
4073 if (!in_procedure ("personality"))
4076 name
= input_line_pointer
;
4077 c
= get_symbol_end ();
4078 p
= input_line_pointer
;
4079 unwind
.personality_routine
= symbol_find_or_make (name
);
4080 unwind
.force_unwind_entry
= 1;
4083 demand_empty_rest_of_line ();
4087 dot_proc (int dummy ATTRIBUTE_UNUSED
)
4091 proc_pending
*pending
, *last_pending
;
4093 if (unwind
.proc_pending
.sym
)
4095 (md
.unwind_check
== unwind_check_warning
4097 : as_bad
) (_("Missing .endp after previous .proc"));
4098 while (unwind
.proc_pending
.next
)
4100 pending
= unwind
.proc_pending
.next
;
4101 unwind
.proc_pending
.next
= pending
->next
;
4105 last_pending
= NULL
;
4107 /* Parse names of main and alternate entry points and mark them as
4108 function symbols: */
4112 name
= input_line_pointer
;
4113 c
= get_symbol_end ();
4114 p
= input_line_pointer
;
4116 as_bad (_("Empty argument of .proc"));
4119 sym
= symbol_find_or_make (name
);
4120 if (S_IS_DEFINED (sym
))
4121 as_bad (_("`%s' was already defined"), name
);
4122 else if (!last_pending
)
4124 unwind
.proc_pending
.sym
= sym
;
4125 last_pending
= &unwind
.proc_pending
;
4129 pending
= xmalloc (sizeof (*pending
));
4131 last_pending
= last_pending
->next
= pending
;
4133 symbol_get_bfdsym (sym
)->flags
|= BSF_FUNCTION
;
4137 if (*input_line_pointer
!= ',')
4139 ++input_line_pointer
;
4143 unwind
.proc_pending
.sym
= expr_build_dot ();
4144 last_pending
= &unwind
.proc_pending
;
4146 last_pending
->next
= NULL
;
4147 demand_empty_rest_of_line ();
4150 unwind
.prologue
= 0;
4151 unwind
.prologue_count
= 0;
4154 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
4155 unwind
.personality_routine
= 0;
4159 dot_body (int dummy ATTRIBUTE_UNUSED
)
4161 if (!in_procedure ("body"))
4163 if (!unwind
.prologue
&& !unwind
.body
&& unwind
.insn
)
4164 as_warn (_("Initial .body should precede any instructions"));
4165 check_pending_save ();
4167 unwind
.prologue
= 0;
4168 unwind
.prologue_mask
= 0;
4171 add_unwind_entry (output_body (), 0);
4175 dot_prologue (int dummy ATTRIBUTE_UNUSED
)
4177 unsigned mask
= 0, grsave
= 0;
4179 if (!in_procedure ("prologue"))
4181 if (unwind
.prologue
)
4183 as_bad (_(".prologue within prologue"));
4184 ignore_rest_of_line ();
4187 if (!unwind
.body
&& unwind
.insn
)
4188 as_warn (_("Initial .prologue should precede any instructions"));
4190 if (!is_it_end_of_statement ())
4193 int n
, sep
= parse_operand (&e
, ',');
4195 if (e
.X_op
!= O_constant
4196 || e
.X_add_number
< 0
4197 || e
.X_add_number
> 0xf)
4198 as_bad (_("First operand to .prologue must be a positive 4-bit constant"));
4199 else if (e
.X_add_number
== 0)
4200 as_warn (_("Pointless use of zero first operand to .prologue"));
4202 mask
= e
.X_add_number
;
4203 n
= popcount (mask
);
4206 parse_operand (&e
, 0);
4209 if (e
.X_op
== O_constant
4210 && e
.X_add_number
>= 0
4211 && e
.X_add_number
< 128)
4213 if (md
.unwind_check
== unwind_check_error
)
4214 as_warn (_("Using a constant as second operand to .prologue is deprecated"));
4215 grsave
= e
.X_add_number
;
4217 else if (e
.X_op
!= O_register
4218 || (grsave
= e
.X_add_number
- REG_GR
) > 127)
4220 as_bad (_("Second operand to .prologue must be a general register"));
4223 else if (grsave
> 128U - n
)
4225 as_bad (_("Second operand to .prologue must be the first of %d general registers"), n
);
4232 add_unwind_entry (output_prologue_gr (mask
, grsave
), 0);
4234 add_unwind_entry (output_prologue (), 0);
4236 unwind
.prologue
= 1;
4237 unwind
.prologue_mask
= mask
;
4238 unwind
.prologue_gr
= grsave
;
4240 ++unwind
.prologue_count
;
4244 dot_endp (int dummy ATTRIBUTE_UNUSED
)
4247 int bytes_per_address
;
4250 subsegT saved_subseg
;
4251 proc_pending
*pending
;
4252 int unwind_check
= md
.unwind_check
;
4254 md
.unwind_check
= unwind_check_error
;
4255 if (!in_procedure ("endp"))
4257 md
.unwind_check
= unwind_check
;
4259 if (unwind
.saved_text_seg
)
4261 saved_seg
= unwind
.saved_text_seg
;
4262 saved_subseg
= unwind
.saved_text_subseg
;
4263 unwind
.saved_text_seg
= NULL
;
4267 saved_seg
= now_seg
;
4268 saved_subseg
= now_subseg
;
4271 insn_group_break (1, 0, 0);
4273 /* If there wasn't a .handlerdata, we haven't generated an image yet. */
4275 generate_unwind_image (saved_seg
);
4277 if (unwind
.info
|| unwind
.force_unwind_entry
)
4281 subseg_set (md
.last_text_seg
, 0);
4282 proc_end
= expr_build_dot ();
4284 start_unwind_section (saved_seg
, SPECIAL_SECTION_UNWIND
);
4286 /* Make sure that section has 4 byte alignment for ILP32 and
4287 8 byte alignment for LP64. */
4288 record_alignment (now_seg
, md
.pointer_size_shift
);
4290 /* Need space for 3 pointers for procedure start, procedure end,
4292 memset (frag_more (3 * md
.pointer_size
), 0, 3 * md
.pointer_size
);
4293 where
= frag_now_fix () - (3 * md
.pointer_size
);
4294 bytes_per_address
= bfd_arch_bits_per_address (stdoutput
) / 8;
4296 /* Issue the values of a) Proc Begin, b) Proc End, c) Unwind Record. */
4297 e
.X_op
= O_pseudo_fixup
;
4298 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4300 if (!S_IS_LOCAL (unwind
.proc_pending
.sym
)
4301 && S_IS_DEFINED (unwind
.proc_pending
.sym
))
4302 e
.X_add_symbol
= symbol_temp_new (S_GET_SEGMENT (unwind
.proc_pending
.sym
),
4303 S_GET_VALUE (unwind
.proc_pending
.sym
),
4304 symbol_get_frag (unwind
.proc_pending
.sym
));
4306 e
.X_add_symbol
= unwind
.proc_pending
.sym
;
4307 ia64_cons_fix_new (frag_now
, where
, bytes_per_address
, &e
);
4309 e
.X_op
= O_pseudo_fixup
;
4310 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4312 e
.X_add_symbol
= proc_end
;
4313 ia64_cons_fix_new (frag_now
, where
+ bytes_per_address
,
4314 bytes_per_address
, &e
);
4318 e
.X_op
= O_pseudo_fixup
;
4319 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4321 e
.X_add_symbol
= unwind
.info
;
4322 ia64_cons_fix_new (frag_now
, where
+ (bytes_per_address
* 2),
4323 bytes_per_address
, &e
);
4326 subseg_set (saved_seg
, saved_subseg
);
4328 /* Set symbol sizes. */
4329 pending
= &unwind
.proc_pending
;
4330 if (S_GET_NAME (pending
->sym
))
4334 symbolS
*sym
= pending
->sym
;
4336 if (!S_IS_DEFINED (sym
))
4337 as_bad (_("`%s' was not defined within procedure"), S_GET_NAME (sym
));
4338 else if (S_GET_SIZE (sym
) == 0
4339 && symbol_get_obj (sym
)->size
== NULL
)
4341 fragS
*frag
= symbol_get_frag (sym
);
4345 if (frag
== frag_now
&& SEG_NORMAL (now_seg
))
4346 S_SET_SIZE (sym
, frag_now_fix () - S_GET_VALUE (sym
));
4349 symbol_get_obj (sym
)->size
=
4350 (expressionS
*) xmalloc (sizeof (expressionS
));
4351 symbol_get_obj (sym
)->size
->X_op
= O_subtract
;
4352 symbol_get_obj (sym
)->size
->X_add_symbol
4353 = symbol_new (FAKE_LABEL_NAME
, now_seg
,
4354 frag_now_fix (), frag_now
);
4355 symbol_get_obj (sym
)->size
->X_op_symbol
= sym
;
4356 symbol_get_obj (sym
)->size
->X_add_number
= 0;
4360 } while ((pending
= pending
->next
) != NULL
);
4363 /* Parse names of main and alternate entry points. */
4369 name
= input_line_pointer
;
4370 c
= get_symbol_end ();
4371 p
= input_line_pointer
;
4373 (md
.unwind_check
== unwind_check_warning
4375 : as_bad
) (_("Empty argument of .endp"));
4378 symbolS
*sym
= symbol_find (name
);
4380 for (pending
= &unwind
.proc_pending
; pending
; pending
= pending
->next
)
4382 if (sym
== pending
->sym
)
4384 pending
->sym
= NULL
;
4388 if (!sym
|| !pending
)
4389 as_warn (_("`%s' was not specified with previous .proc"), name
);
4393 if (*input_line_pointer
!= ',')
4395 ++input_line_pointer
;
4397 demand_empty_rest_of_line ();
4399 /* Deliberately only checking for the main entry point here; the
4400 language spec even says all arguments to .endp are ignored. */
4401 if (unwind
.proc_pending
.sym
4402 && S_GET_NAME (unwind
.proc_pending
.sym
)
4403 && strcmp (S_GET_NAME (unwind
.proc_pending
.sym
), FAKE_LABEL_NAME
))
4404 as_warn (_("`%s' should be an operand to this .endp"),
4405 S_GET_NAME (unwind
.proc_pending
.sym
));
4406 while (unwind
.proc_pending
.next
)
4408 pending
= unwind
.proc_pending
.next
;
4409 unwind
.proc_pending
.next
= pending
->next
;
4412 unwind
.proc_pending
.sym
= unwind
.info
= NULL
;
4416 dot_template (int template)
4418 CURR_SLOT
.user_template
= template;
4422 dot_regstk (int dummy ATTRIBUTE_UNUSED
)
4424 int ins
, locs
, outs
, rots
;
4426 if (is_it_end_of_statement ())
4427 ins
= locs
= outs
= rots
= 0;
4430 ins
= get_absolute_expression ();
4431 if (*input_line_pointer
++ != ',')
4433 locs
= get_absolute_expression ();
4434 if (*input_line_pointer
++ != ',')
4436 outs
= get_absolute_expression ();
4437 if (*input_line_pointer
++ != ',')
4439 rots
= get_absolute_expression ();
4441 set_regstack (ins
, locs
, outs
, rots
);
4445 as_bad (_("Comma expected"));
4446 ignore_rest_of_line ();
4453 valueT num_alloced
= 0;
4454 struct dynreg
**drpp
, *dr
;
4455 int ch
, base_reg
= 0;
4461 case DYNREG_GR
: base_reg
= REG_GR
+ 32; break;
4462 case DYNREG_FR
: base_reg
= REG_FR
+ 32; break;
4463 case DYNREG_PR
: base_reg
= REG_P
+ 16; break;
4467 /* First, remove existing names from hash table. */
4468 for (dr
= md
.dynreg
[type
]; dr
&& dr
->num_regs
; dr
= dr
->next
)
4470 hash_delete (md
.dynreg_hash
, dr
->name
, FALSE
);
4471 /* FIXME: Free dr->name. */
4475 drpp
= &md
.dynreg
[type
];
4478 start
= input_line_pointer
;
4479 ch
= get_symbol_end ();
4480 len
= strlen (ia64_canonicalize_symbol_name (start
));
4481 *input_line_pointer
= ch
;
4484 if (*input_line_pointer
!= '[')
4486 as_bad (_("Expected '['"));
4489 ++input_line_pointer
; /* skip '[' */
4491 num_regs
= get_absolute_expression ();
4493 if (*input_line_pointer
++ != ']')
4495 as_bad (_("Expected ']'"));
4500 as_bad (_("Number of elements must be positive"));
4505 num_alloced
+= num_regs
;
4509 if (num_alloced
> md
.rot
.num_regs
)
4511 as_bad (_("Used more than the declared %d rotating registers"),
4517 if (num_alloced
> 96)
4519 as_bad (_("Used more than the available 96 rotating registers"));
4524 if (num_alloced
> 48)
4526 as_bad (_("Used more than the available 48 rotating registers"));
4537 *drpp
= obstack_alloc (¬es
, sizeof (*dr
));
4538 memset (*drpp
, 0, sizeof (*dr
));
4541 name
= obstack_alloc (¬es
, len
+ 1);
4542 memcpy (name
, start
, len
);
4547 dr
->num_regs
= num_regs
;
4548 dr
->base
= base_reg
;
4550 base_reg
+= num_regs
;
4552 if (hash_insert (md
.dynreg_hash
, name
, dr
))
4554 as_bad (_("Attempt to redefine register set `%s'"), name
);
4555 obstack_free (¬es
, name
);
4559 if (*input_line_pointer
!= ',')
4561 ++input_line_pointer
; /* skip comma */
4564 demand_empty_rest_of_line ();
4568 ignore_rest_of_line ();
4572 dot_byteorder (int byteorder
)
4574 segment_info_type
*seginfo
= seg_info (now_seg
);
4576 if (byteorder
== -1)
4578 if (seginfo
->tc_segment_info_data
.endian
== 0)
4579 seginfo
->tc_segment_info_data
.endian
= default_big_endian
? 1 : 2;
4580 byteorder
= seginfo
->tc_segment_info_data
.endian
== 1;
4583 seginfo
->tc_segment_info_data
.endian
= byteorder
? 1 : 2;
4585 if (target_big_endian
!= byteorder
)
4587 target_big_endian
= byteorder
;
4588 if (target_big_endian
)
4590 ia64_number_to_chars
= number_to_chars_bigendian
;
4591 ia64_float_to_chars
= ia64_float_to_chars_bigendian
;
4595 ia64_number_to_chars
= number_to_chars_littleendian
;
4596 ia64_float_to_chars
= ia64_float_to_chars_littleendian
;
4602 dot_psr (int dummy ATTRIBUTE_UNUSED
)
4609 option
= input_line_pointer
;
4610 ch
= get_symbol_end ();
4611 if (strcmp (option
, "lsb") == 0)
4612 md
.flags
&= ~EF_IA_64_BE
;
4613 else if (strcmp (option
, "msb") == 0)
4614 md
.flags
|= EF_IA_64_BE
;
4615 else if (strcmp (option
, "abi32") == 0)
4616 md
.flags
&= ~EF_IA_64_ABI64
;
4617 else if (strcmp (option
, "abi64") == 0)
4618 md
.flags
|= EF_IA_64_ABI64
;
4620 as_bad (_("Unknown psr option `%s'"), option
);
4621 *input_line_pointer
= ch
;
4624 if (*input_line_pointer
!= ',')
4627 ++input_line_pointer
;
4630 demand_empty_rest_of_line ();
4634 dot_ln (int dummy ATTRIBUTE_UNUSED
)
4636 new_logical_line (0, get_absolute_expression ());
4637 demand_empty_rest_of_line ();
4641 cross_section (int ref
, void (*cons
) (int), int ua
)
4644 int saved_auto_align
;
4645 unsigned int section_count
;
4648 start
= input_line_pointer
;
4654 name
= demand_copy_C_string (&len
);
4655 obstack_free(¬es
, name
);
4658 ignore_rest_of_line ();
4664 char c
= get_symbol_end ();
4666 if (input_line_pointer
== start
)
4668 as_bad (_("Missing section name"));
4669 ignore_rest_of_line ();
4672 *input_line_pointer
= c
;
4674 end
= input_line_pointer
;
4676 if (*input_line_pointer
!= ',')
4678 as_bad (_("Comma expected after section name"));
4679 ignore_rest_of_line ();
4683 end
= input_line_pointer
+ 1; /* skip comma */
4684 input_line_pointer
= start
;
4685 md
.keep_pending_output
= 1;
4686 section_count
= bfd_count_sections(stdoutput
);
4687 obj_elf_section (0);
4688 if (section_count
!= bfd_count_sections(stdoutput
))
4689 as_warn (_("Creating sections with .xdataN/.xrealN/.xstringZ is deprecated."));
4690 input_line_pointer
= end
;
4691 saved_auto_align
= md
.auto_align
;
4696 md
.auto_align
= saved_auto_align
;
4697 obj_elf_previous (0);
4698 md
.keep_pending_output
= 0;
4702 dot_xdata (int size
)
4704 cross_section (size
, cons
, 0);
4707 /* Why doesn't float_cons() call md_cons_align() the way cons() does? */
4710 stmt_float_cons (int kind
)
4730 ia64_do_align (alignment
);
4735 stmt_cons_ua (int size
)
4737 int saved_auto_align
= md
.auto_align
;
4741 md
.auto_align
= saved_auto_align
;
4745 dot_xfloat_cons (int kind
)
4747 cross_section (kind
, stmt_float_cons
, 0);
4751 dot_xstringer (int zero
)
4753 cross_section (zero
, stringer
, 0);
4757 dot_xdata_ua (int size
)
4759 cross_section (size
, cons
, 1);
4763 dot_xfloat_cons_ua (int kind
)
4765 cross_section (kind
, float_cons
, 1);
4768 /* .reg.val <regname>,value */
4771 dot_reg_val (int dummy ATTRIBUTE_UNUSED
)
4775 expression_and_evaluate (®
);
4776 if (reg
.X_op
!= O_register
)
4778 as_bad (_("Register name expected"));
4779 ignore_rest_of_line ();
4781 else if (*input_line_pointer
++ != ',')
4783 as_bad (_("Comma expected"));
4784 ignore_rest_of_line ();
4788 valueT value
= get_absolute_expression ();
4789 int regno
= reg
.X_add_number
;
4790 if (regno
<= REG_GR
|| regno
> REG_GR
+ 127)
4791 as_warn (_("Register value annotation ignored"));
4794 gr_values
[regno
- REG_GR
].known
= 1;
4795 gr_values
[regno
- REG_GR
].value
= value
;
4796 gr_values
[regno
- REG_GR
].path
= md
.path
;
4799 demand_empty_rest_of_line ();
4804 .serialize.instruction
4807 dot_serialize (int type
)
4809 insn_group_break (0, 0, 0);
4811 instruction_serialization ();
4813 data_serialization ();
4814 insn_group_break (0, 0, 0);
4815 demand_empty_rest_of_line ();
4818 /* select dv checking mode
4823 A stop is inserted when changing modes
4827 dot_dv_mode (int type
)
4829 if (md
.manual_bundling
)
4830 as_warn (_("Directive invalid within a bundle"));
4832 if (type
== 'E' || type
== 'A')
4833 md
.mode_explicitly_set
= 0;
4835 md
.mode_explicitly_set
= 1;
4842 if (md
.explicit_mode
)
4843 insn_group_break (1, 0, 0);
4844 md
.explicit_mode
= 0;
4848 if (!md
.explicit_mode
)
4849 insn_group_break (1, 0, 0);
4850 md
.explicit_mode
= 1;
4854 if (md
.explicit_mode
!= md
.default_explicit_mode
)
4855 insn_group_break (1, 0, 0);
4856 md
.explicit_mode
= md
.default_explicit_mode
;
4857 md
.mode_explicitly_set
= 0;
4863 print_prmask (valueT mask
)
4867 for (regno
= 0; regno
< 64; regno
++)
4869 if (mask
& ((valueT
) 1 << regno
))
4871 fprintf (stderr
, "%s p%d", comma
, regno
);
4878 .pred.rel.clear [p1 [,p2 [,...]]] (also .pred.rel "clear" or @clear)
4879 .pred.rel.imply p1, p2 (also .pred.rel "imply" or @imply)
4880 .pred.rel.mutex p1, p2 [,...] (also .pred.rel "mutex" or @mutex)
4881 .pred.safe_across_calls p1 [, p2 [,...]]
4885 dot_pred_rel (int type
)
4889 int p1
= -1, p2
= -1;
4893 if (*input_line_pointer
== '"')
4896 char *form
= demand_copy_C_string (&len
);
4898 if (strcmp (form
, "mutex") == 0)
4900 else if (strcmp (form
, "clear") == 0)
4902 else if (strcmp (form
, "imply") == 0)
4904 obstack_free (¬es
, form
);
4906 else if (*input_line_pointer
== '@')
4908 char *form
= ++input_line_pointer
;
4909 char c
= get_symbol_end();
4911 if (strcmp (form
, "mutex") == 0)
4913 else if (strcmp (form
, "clear") == 0)
4915 else if (strcmp (form
, "imply") == 0)
4917 *input_line_pointer
= c
;
4921 as_bad (_("Missing predicate relation type"));
4922 ignore_rest_of_line ();
4927 as_bad (_("Unrecognized predicate relation type"));
4928 ignore_rest_of_line ();
4931 if (*input_line_pointer
== ',')
4932 ++input_line_pointer
;
4940 expressionS pr
, *pr1
, *pr2
;
4942 sep
= parse_operand (&pr
, ',');
4943 if (pr
.X_op
== O_register
4944 && pr
.X_add_number
>= REG_P
4945 && pr
.X_add_number
<= REG_P
+ 63)
4947 regno
= pr
.X_add_number
- REG_P
;
4955 else if (type
!= 'i'
4956 && pr
.X_op
== O_subtract
4957 && (pr1
= symbol_get_value_expression (pr
.X_add_symbol
))
4958 && pr1
->X_op
== O_register
4959 && pr1
->X_add_number
>= REG_P
4960 && pr1
->X_add_number
<= REG_P
+ 63
4961 && (pr2
= symbol_get_value_expression (pr
.X_op_symbol
))
4962 && pr2
->X_op
== O_register
4963 && pr2
->X_add_number
>= REG_P
4964 && pr2
->X_add_number
<= REG_P
+ 63)
4969 regno
= pr1
->X_add_number
- REG_P
;
4970 stop
= pr2
->X_add_number
- REG_P
;
4973 as_bad (_("Bad register range"));
4974 ignore_rest_of_line ();
4977 bits
= ((bits
<< stop
) << 1) - (bits
<< regno
);
4978 count
+= stop
- regno
+ 1;
4982 as_bad (_("Predicate register expected"));
4983 ignore_rest_of_line ();
4987 as_warn (_("Duplicate predicate register ignored"));
4998 clear_qp_mutex (mask
);
4999 clear_qp_implies (mask
, (valueT
) 0);
5002 if (count
!= 2 || p1
== -1 || p2
== -1)
5003 as_bad (_("Predicate source and target required"));
5004 else if (p1
== 0 || p2
== 0)
5005 as_bad (_("Use of p0 is not valid in this context"));
5007 add_qp_imply (p1
, p2
);
5012 as_bad (_("At least two PR arguments expected"));
5017 as_bad (_("Use of p0 is not valid in this context"));
5020 add_qp_mutex (mask
);
5023 /* note that we don't override any existing relations */
5026 as_bad (_("At least one PR argument expected"));
5031 fprintf (stderr
, "Safe across calls: ");
5032 print_prmask (mask
);
5033 fprintf (stderr
, "\n");
5035 qp_safe_across_calls
= mask
;
5038 demand_empty_rest_of_line ();
5041 /* .entry label [, label [, ...]]
5042 Hint to DV code that the given labels are to be considered entry points.
5043 Otherwise, only global labels are considered entry points. */
5046 dot_entry (int dummy ATTRIBUTE_UNUSED
)
5055 name
= input_line_pointer
;
5056 c
= get_symbol_end ();
5057 symbolP
= symbol_find_or_make (name
);
5059 err
= hash_insert (md
.entry_hash
, S_GET_NAME (symbolP
), (void *) symbolP
);
5061 as_fatal (_("Inserting \"%s\" into entry hint table failed: %s"),
5064 *input_line_pointer
= c
;
5066 c
= *input_line_pointer
;
5069 input_line_pointer
++;
5071 if (*input_line_pointer
== '\n')
5077 demand_empty_rest_of_line ();
5080 /* .mem.offset offset, base
5081 "base" is used to distinguish between offsets from a different base. */
5084 dot_mem_offset (int dummy ATTRIBUTE_UNUSED
)
5086 md
.mem_offset
.hint
= 1;
5087 md
.mem_offset
.offset
= get_absolute_expression ();
5088 if (*input_line_pointer
!= ',')
5090 as_bad (_("Comma expected"));
5091 ignore_rest_of_line ();
5094 ++input_line_pointer
;
5095 md
.mem_offset
.base
= get_absolute_expression ();
5096 demand_empty_rest_of_line ();
5099 /* ia64-specific pseudo-ops: */
5100 const pseudo_typeS md_pseudo_table
[] =
5102 { "radix", dot_radix
, 0 },
5103 { "lcomm", s_lcomm_bytes
, 1 },
5104 { "loc", dot_loc
, 0 },
5105 { "bss", dot_special_section
, SPECIAL_SECTION_BSS
},
5106 { "sbss", dot_special_section
, SPECIAL_SECTION_SBSS
},
5107 { "sdata", dot_special_section
, SPECIAL_SECTION_SDATA
},
5108 { "rodata", dot_special_section
, SPECIAL_SECTION_RODATA
},
5109 { "comment", dot_special_section
, SPECIAL_SECTION_COMMENT
},
5110 { "ia_64.unwind", dot_special_section
, SPECIAL_SECTION_UNWIND
},
5111 { "ia_64.unwind_info", dot_special_section
, SPECIAL_SECTION_UNWIND_INFO
},
5112 { "init_array", dot_special_section
, SPECIAL_SECTION_INIT_ARRAY
},
5113 { "fini_array", dot_special_section
, SPECIAL_SECTION_FINI_ARRAY
},
5114 { "proc", dot_proc
, 0 },
5115 { "body", dot_body
, 0 },
5116 { "prologue", dot_prologue
, 0 },
5117 { "endp", dot_endp
, 0 },
5119 { "fframe", dot_fframe
, 0 },
5120 { "vframe", dot_vframe
, 0 },
5121 { "vframesp", dot_vframesp
, 0 },
5122 { "vframepsp", dot_vframesp
, 1 },
5123 { "save", dot_save
, 0 },
5124 { "restore", dot_restore
, 0 },
5125 { "restorereg", dot_restorereg
, 0 },
5126 { "restorereg.p", dot_restorereg
, 1 },
5127 { "handlerdata", dot_handlerdata
, 0 },
5128 { "unwentry", dot_unwentry
, 0 },
5129 { "altrp", dot_altrp
, 0 },
5130 { "savesp", dot_savemem
, 0 },
5131 { "savepsp", dot_savemem
, 1 },
5132 { "save.g", dot_saveg
, 0 },
5133 { "save.f", dot_savef
, 0 },
5134 { "save.b", dot_saveb
, 0 },
5135 { "save.gf", dot_savegf
, 0 },
5136 { "spill", dot_spill
, 0 },
5137 { "spillreg", dot_spillreg
, 0 },
5138 { "spillsp", dot_spillmem
, 0 },
5139 { "spillpsp", dot_spillmem
, 1 },
5140 { "spillreg.p", dot_spillreg
, 1 },
5141 { "spillsp.p", dot_spillmem
, ~0 },
5142 { "spillpsp.p", dot_spillmem
, ~1 },
5143 { "label_state", dot_label_state
, 0 },
5144 { "copy_state", dot_copy_state
, 0 },
5145 { "unwabi", dot_unwabi
, 0 },
5146 { "personality", dot_personality
, 0 },
5147 { "mii", dot_template
, 0x0 },
5148 { "mli", dot_template
, 0x2 }, /* old format, for compatibility */
5149 { "mlx", dot_template
, 0x2 },
5150 { "mmi", dot_template
, 0x4 },
5151 { "mfi", dot_template
, 0x6 },
5152 { "mmf", dot_template
, 0x7 },
5153 { "mib", dot_template
, 0x8 },
5154 { "mbb", dot_template
, 0x9 },
5155 { "bbb", dot_template
, 0xb },
5156 { "mmb", dot_template
, 0xc },
5157 { "mfb", dot_template
, 0xe },
5158 { "align", dot_align
, 0 },
5159 { "regstk", dot_regstk
, 0 },
5160 { "rotr", dot_rot
, DYNREG_GR
},
5161 { "rotf", dot_rot
, DYNREG_FR
},
5162 { "rotp", dot_rot
, DYNREG_PR
},
5163 { "lsb", dot_byteorder
, 0 },
5164 { "msb", dot_byteorder
, 1 },
5165 { "psr", dot_psr
, 0 },
5166 { "alias", dot_alias
, 0 },
5167 { "secalias", dot_alias
, 1 },
5168 { "ln", dot_ln
, 0 }, /* source line info (for debugging) */
5170 { "xdata1", dot_xdata
, 1 },
5171 { "xdata2", dot_xdata
, 2 },
5172 { "xdata4", dot_xdata
, 4 },
5173 { "xdata8", dot_xdata
, 8 },
5174 { "xdata16", dot_xdata
, 16 },
5175 { "xreal4", dot_xfloat_cons
, 'f' },
5176 { "xreal8", dot_xfloat_cons
, 'd' },
5177 { "xreal10", dot_xfloat_cons
, 'x' },
5178 { "xreal16", dot_xfloat_cons
, 'X' },
5179 { "xstring", dot_xstringer
, 8 + 0 },
5180 { "xstringz", dot_xstringer
, 8 + 1 },
5182 /* unaligned versions: */
5183 { "xdata2.ua", dot_xdata_ua
, 2 },
5184 { "xdata4.ua", dot_xdata_ua
, 4 },
5185 { "xdata8.ua", dot_xdata_ua
, 8 },
5186 { "xdata16.ua", dot_xdata_ua
, 16 },
5187 { "xreal4.ua", dot_xfloat_cons_ua
, 'f' },
5188 { "xreal8.ua", dot_xfloat_cons_ua
, 'd' },
5189 { "xreal10.ua", dot_xfloat_cons_ua
, 'x' },
5190 { "xreal16.ua", dot_xfloat_cons_ua
, 'X' },
5192 /* annotations/DV checking support */
5193 { "entry", dot_entry
, 0 },
5194 { "mem.offset", dot_mem_offset
, 0 },
5195 { "pred.rel", dot_pred_rel
, 0 },
5196 { "pred.rel.clear", dot_pred_rel
, 'c' },
5197 { "pred.rel.imply", dot_pred_rel
, 'i' },
5198 { "pred.rel.mutex", dot_pred_rel
, 'm' },
5199 { "pred.safe_across_calls", dot_pred_rel
, 's' },
5200 { "reg.val", dot_reg_val
, 0 },
5201 { "serialize.data", dot_serialize
, 0 },
5202 { "serialize.instruction", dot_serialize
, 1 },
5203 { "auto", dot_dv_mode
, 'a' },
5204 { "explicit", dot_dv_mode
, 'e' },
5205 { "default", dot_dv_mode
, 'd' },
5207 /* ??? These are needed to make gas/testsuite/gas/elf/ehopt.s work.
5208 IA-64 aligns data allocation pseudo-ops by default, so we have to
5209 tell it that these ones are supposed to be unaligned. Long term,
5210 should rewrite so that only IA-64 specific data allocation pseudo-ops
5211 are aligned by default. */
5212 {"2byte", stmt_cons_ua
, 2},
5213 {"4byte", stmt_cons_ua
, 4},
5214 {"8byte", stmt_cons_ua
, 8},
5219 static const struct pseudo_opcode
5222 void (*handler
) (int);
5227 /* these are more like pseudo-ops, but don't start with a dot */
5228 { "data1", cons
, 1 },
5229 { "data2", cons
, 2 },
5230 { "data4", cons
, 4 },
5231 { "data8", cons
, 8 },
5232 { "data16", cons
, 16 },
5233 { "real4", stmt_float_cons
, 'f' },
5234 { "real8", stmt_float_cons
, 'd' },
5235 { "real10", stmt_float_cons
, 'x' },
5236 { "real16", stmt_float_cons
, 'X' },
5237 { "string", stringer
, 8 + 0 },
5238 { "stringz", stringer
, 8 + 1 },
5240 /* unaligned versions: */
5241 { "data2.ua", stmt_cons_ua
, 2 },
5242 { "data4.ua", stmt_cons_ua
, 4 },
5243 { "data8.ua", stmt_cons_ua
, 8 },
5244 { "data16.ua", stmt_cons_ua
, 16 },
5245 { "real4.ua", float_cons
, 'f' },
5246 { "real8.ua", float_cons
, 'd' },
5247 { "real10.ua", float_cons
, 'x' },
5248 { "real16.ua", float_cons
, 'X' },
5251 /* Declare a register by creating a symbol for it and entering it in
5252 the symbol table. */
5255 declare_register (const char *name
, unsigned int regnum
)
5260 sym
= symbol_create (name
, reg_section
, regnum
, &zero_address_frag
);
5262 err
= hash_insert (md
.reg_hash
, S_GET_NAME (sym
), (void *) sym
);
5264 as_fatal ("Inserting \"%s\" into register table failed: %s",
5271 declare_register_set (const char *prefix
,
5272 unsigned int num_regs
,
5273 unsigned int base_regnum
)
5278 for (i
= 0; i
< num_regs
; ++i
)
5280 snprintf (name
, sizeof (name
), "%s%u", prefix
, i
);
5281 declare_register (name
, base_regnum
+ i
);
5286 operand_width (enum ia64_opnd opnd
)
5288 const struct ia64_operand
*odesc
= &elf64_ia64_operands
[opnd
];
5289 unsigned int bits
= 0;
5293 for (i
= 0; i
< NELEMS (odesc
->field
) && odesc
->field
[i
].bits
; ++i
)
5294 bits
+= odesc
->field
[i
].bits
;
5299 static enum operand_match_result
5300 operand_match (const struct ia64_opcode
*idesc
, int index
, expressionS
*e
)
5302 enum ia64_opnd opnd
= idesc
->operands
[index
];
5303 int bits
, relocatable
= 0;
5304 struct insn_fix
*fix
;
5311 case IA64_OPND_AR_CCV
:
5312 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 32)
5313 return OPERAND_MATCH
;
5316 case IA64_OPND_AR_CSD
:
5317 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 25)
5318 return OPERAND_MATCH
;
5321 case IA64_OPND_AR_PFS
:
5322 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 64)
5323 return OPERAND_MATCH
;
5327 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_GR
+ 0)
5328 return OPERAND_MATCH
;
5332 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_IP
)
5333 return OPERAND_MATCH
;
5337 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR
)
5338 return OPERAND_MATCH
;
5341 case IA64_OPND_PR_ROT
:
5342 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR_ROT
)
5343 return OPERAND_MATCH
;
5347 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR
)
5348 return OPERAND_MATCH
;
5351 case IA64_OPND_PSR_L
:
5352 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_L
)
5353 return OPERAND_MATCH
;
5356 case IA64_OPND_PSR_UM
:
5357 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_UM
)
5358 return OPERAND_MATCH
;
5362 if (e
->X_op
== O_constant
)
5364 if (e
->X_add_number
== 1)
5365 return OPERAND_MATCH
;
5367 return OPERAND_OUT_OF_RANGE
;
5372 if (e
->X_op
== O_constant
)
5374 if (e
->X_add_number
== 8)
5375 return OPERAND_MATCH
;
5377 return OPERAND_OUT_OF_RANGE
;
5382 if (e
->X_op
== O_constant
)
5384 if (e
->X_add_number
== 16)
5385 return OPERAND_MATCH
;
5387 return OPERAND_OUT_OF_RANGE
;
5391 /* register operands: */
5394 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_AR
5395 && e
->X_add_number
< REG_AR
+ 128)
5396 return OPERAND_MATCH
;
5401 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_BR
5402 && e
->X_add_number
< REG_BR
+ 8)
5403 return OPERAND_MATCH
;
5407 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_CR
5408 && e
->X_add_number
< REG_CR
+ 128)
5409 return OPERAND_MATCH
;
5416 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_FR
5417 && e
->X_add_number
< REG_FR
+ 128)
5418 return OPERAND_MATCH
;
5423 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_P
5424 && e
->X_add_number
< REG_P
+ 64)
5425 return OPERAND_MATCH
;
5431 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
5432 && e
->X_add_number
< REG_GR
+ 128)
5433 return OPERAND_MATCH
;
5436 case IA64_OPND_R3_2
:
5437 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
)
5439 if (e
->X_add_number
< REG_GR
+ 4)
5440 return OPERAND_MATCH
;
5441 else if (e
->X_add_number
< REG_GR
+ 128)
5442 return OPERAND_OUT_OF_RANGE
;
5446 /* indirect operands: */
5447 case IA64_OPND_CPUID_R3
:
5448 case IA64_OPND_DBR_R3
:
5449 case IA64_OPND_DTR_R3
:
5450 case IA64_OPND_ITR_R3
:
5451 case IA64_OPND_IBR_R3
:
5452 case IA64_OPND_MSR_R3
:
5453 case IA64_OPND_PKR_R3
:
5454 case IA64_OPND_PMC_R3
:
5455 case IA64_OPND_PMD_R3
:
5456 case IA64_OPND_RR_R3
:
5457 if (e
->X_op
== O_index
&& e
->X_op_symbol
5458 && (S_GET_VALUE (e
->X_op_symbol
) - IND_CPUID
5459 == opnd
- IA64_OPND_CPUID_R3
))
5460 return OPERAND_MATCH
;
5464 if (e
->X_op
== O_index
&& !e
->X_op_symbol
)
5465 return OPERAND_MATCH
;
5468 /* immediate operands: */
5469 case IA64_OPND_CNT2a
:
5470 case IA64_OPND_LEN4
:
5471 case IA64_OPND_LEN6
:
5472 bits
= operand_width (idesc
->operands
[index
]);
5473 if (e
->X_op
== O_constant
)
5475 if ((bfd_vma
) (e
->X_add_number
- 1) < ((bfd_vma
) 1 << bits
))
5476 return OPERAND_MATCH
;
5478 return OPERAND_OUT_OF_RANGE
;
5482 case IA64_OPND_CNT2b
:
5483 if (e
->X_op
== O_constant
)
5485 if ((bfd_vma
) (e
->X_add_number
- 1) < 3)
5486 return OPERAND_MATCH
;
5488 return OPERAND_OUT_OF_RANGE
;
5492 case IA64_OPND_CNT2c
:
5493 val
= e
->X_add_number
;
5494 if (e
->X_op
== O_constant
)
5496 if ((val
== 0 || val
== 7 || val
== 15 || val
== 16))
5497 return OPERAND_MATCH
;
5499 return OPERAND_OUT_OF_RANGE
;
5504 /* SOR must be an integer multiple of 8 */
5505 if (e
->X_op
== O_constant
&& e
->X_add_number
& 0x7)
5506 return OPERAND_OUT_OF_RANGE
;
5509 if (e
->X_op
== O_constant
)
5511 if ((bfd_vma
) e
->X_add_number
<= 96)
5512 return OPERAND_MATCH
;
5514 return OPERAND_OUT_OF_RANGE
;
5518 case IA64_OPND_IMMU62
:
5519 if (e
->X_op
== O_constant
)
5521 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 62))
5522 return OPERAND_MATCH
;
5524 return OPERAND_OUT_OF_RANGE
;
5528 /* FIXME -- need 62-bit relocation type */
5529 as_bad (_("62-bit relocation not yet implemented"));
5533 case IA64_OPND_IMMU64
:
5534 if (e
->X_op
== O_symbol
|| e
->X_op
== O_pseudo_fixup
5535 || e
->X_op
== O_subtract
)
5537 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5538 fix
->code
= BFD_RELOC_IA64_IMM64
;
5539 if (e
->X_op
!= O_subtract
)
5541 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5542 if (e
->X_op
== O_pseudo_fixup
)
5546 fix
->opnd
= idesc
->operands
[index
];
5549 ++CURR_SLOT
.num_fixups
;
5550 return OPERAND_MATCH
;
5552 else if (e
->X_op
== O_constant
)
5553 return OPERAND_MATCH
;
5556 case IA64_OPND_IMMU5b
:
5557 if (e
->X_op
== O_constant
)
5559 val
= e
->X_add_number
;
5560 if (val
>= 32 && val
<= 63)
5561 return OPERAND_MATCH
;
5563 return OPERAND_OUT_OF_RANGE
;
5567 case IA64_OPND_CCNT5
:
5568 case IA64_OPND_CNT5
:
5569 case IA64_OPND_CNT6
:
5570 case IA64_OPND_CPOS6a
:
5571 case IA64_OPND_CPOS6b
:
5572 case IA64_OPND_CPOS6c
:
5573 case IA64_OPND_IMMU2
:
5574 case IA64_OPND_IMMU7a
:
5575 case IA64_OPND_IMMU7b
:
5576 case IA64_OPND_IMMU21
:
5577 case IA64_OPND_IMMU24
:
5578 case IA64_OPND_MBTYPE4
:
5579 case IA64_OPND_MHTYPE8
:
5580 case IA64_OPND_POS6
:
5581 bits
= operand_width (idesc
->operands
[index
]);
5582 if (e
->X_op
== O_constant
)
5584 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5585 return OPERAND_MATCH
;
5587 return OPERAND_OUT_OF_RANGE
;
5591 case IA64_OPND_IMMU9
:
5592 bits
= operand_width (idesc
->operands
[index
]);
5593 if (e
->X_op
== O_constant
)
5595 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5597 int lobits
= e
->X_add_number
& 0x3;
5598 if (((bfd_vma
) e
->X_add_number
& 0x3C) != 0 && lobits
== 0)
5599 e
->X_add_number
|= (bfd_vma
) 0x3;
5600 return OPERAND_MATCH
;
5603 return OPERAND_OUT_OF_RANGE
;
5607 case IA64_OPND_IMM44
:
5608 /* least 16 bits must be zero */
5609 if ((e
->X_add_number
& 0xffff) != 0)
5610 /* XXX technically, this is wrong: we should not be issuing warning
5611 messages until we're sure this instruction pattern is going to
5613 as_warn (_("lower 16 bits of mask ignored"));
5615 if (e
->X_op
== O_constant
)
5617 if (((e
->X_add_number
>= 0
5618 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 44))
5619 || (e
->X_add_number
< 0
5620 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 44))))
5623 if (e
->X_add_number
>= 0
5624 && (e
->X_add_number
& ((bfd_vma
) 1 << 43)) != 0)
5626 e
->X_add_number
|= ~(((bfd_vma
) 1 << 44) - 1);
5628 return OPERAND_MATCH
;
5631 return OPERAND_OUT_OF_RANGE
;
5635 case IA64_OPND_IMM17
:
5636 /* bit 0 is a don't care (pr0 is hardwired to 1) */
5637 if (e
->X_op
== O_constant
)
5639 if (((e
->X_add_number
>= 0
5640 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 17))
5641 || (e
->X_add_number
< 0
5642 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 17))))
5645 if (e
->X_add_number
>= 0
5646 && (e
->X_add_number
& ((bfd_vma
) 1 << 16)) != 0)
5648 e
->X_add_number
|= ~(((bfd_vma
) 1 << 17) - 1);
5650 return OPERAND_MATCH
;
5653 return OPERAND_OUT_OF_RANGE
;
5657 case IA64_OPND_IMM14
:
5658 case IA64_OPND_IMM22
:
5660 case IA64_OPND_IMM1
:
5661 case IA64_OPND_IMM8
:
5662 case IA64_OPND_IMM8U4
:
5663 case IA64_OPND_IMM8M1
:
5664 case IA64_OPND_IMM8M1U4
:
5665 case IA64_OPND_IMM8M1U8
:
5666 case IA64_OPND_IMM9a
:
5667 case IA64_OPND_IMM9b
:
5668 bits
= operand_width (idesc
->operands
[index
]);
5669 if (relocatable
&& (e
->X_op
== O_symbol
5670 || e
->X_op
== O_subtract
5671 || e
->X_op
== O_pseudo_fixup
))
5673 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5675 if (idesc
->operands
[index
] == IA64_OPND_IMM14
)
5676 fix
->code
= BFD_RELOC_IA64_IMM14
;
5678 fix
->code
= BFD_RELOC_IA64_IMM22
;
5680 if (e
->X_op
!= O_subtract
)
5682 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5683 if (e
->X_op
== O_pseudo_fixup
)
5687 fix
->opnd
= idesc
->operands
[index
];
5690 ++CURR_SLOT
.num_fixups
;
5691 return OPERAND_MATCH
;
5693 else if (e
->X_op
!= O_constant
5694 && ! (e
->X_op
== O_big
&& opnd
== IA64_OPND_IMM8M1U8
))
5695 return OPERAND_MISMATCH
;
5697 if (opnd
== IA64_OPND_IMM8M1U4
)
5699 /* Zero is not valid for unsigned compares that take an adjusted
5700 constant immediate range. */
5701 if (e
->X_add_number
== 0)
5702 return OPERAND_OUT_OF_RANGE
;
5704 /* Sign-extend 32-bit unsigned numbers, so that the following range
5705 checks will work. */
5706 val
= e
->X_add_number
;
5707 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5708 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5709 val
= ((val
<< 32) >> 32);
5711 /* Check for 0x100000000. This is valid because
5712 0x100000000-1 is the same as ((uint32_t) -1). */
5713 if (val
== ((bfd_signed_vma
) 1 << 32))
5714 return OPERAND_MATCH
;
5718 else if (opnd
== IA64_OPND_IMM8M1U8
)
5720 /* Zero is not valid for unsigned compares that take an adjusted
5721 constant immediate range. */
5722 if (e
->X_add_number
== 0)
5723 return OPERAND_OUT_OF_RANGE
;
5725 /* Check for 0x10000000000000000. */
5726 if (e
->X_op
== O_big
)
5728 if (generic_bignum
[0] == 0
5729 && generic_bignum
[1] == 0
5730 && generic_bignum
[2] == 0
5731 && generic_bignum
[3] == 0
5732 && generic_bignum
[4] == 1)
5733 return OPERAND_MATCH
;
5735 return OPERAND_OUT_OF_RANGE
;
5738 val
= e
->X_add_number
- 1;
5740 else if (opnd
== IA64_OPND_IMM8M1
)
5741 val
= e
->X_add_number
- 1;
5742 else if (opnd
== IA64_OPND_IMM8U4
)
5744 /* Sign-extend 32-bit unsigned numbers, so that the following range
5745 checks will work. */
5746 val
= e
->X_add_number
;
5747 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5748 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5749 val
= ((val
<< 32) >> 32);
5752 val
= e
->X_add_number
;
5754 if ((val
>= 0 && (bfd_vma
) val
< ((bfd_vma
) 1 << (bits
- 1)))
5755 || (val
< 0 && (bfd_vma
) -val
<= ((bfd_vma
) 1 << (bits
- 1))))
5756 return OPERAND_MATCH
;
5758 return OPERAND_OUT_OF_RANGE
;
5760 case IA64_OPND_INC3
:
5761 /* +/- 1, 4, 8, 16 */
5762 val
= e
->X_add_number
;
5765 if (e
->X_op
== O_constant
)
5767 if ((val
== 1 || val
== 4 || val
== 8 || val
== 16))
5768 return OPERAND_MATCH
;
5770 return OPERAND_OUT_OF_RANGE
;
5774 case IA64_OPND_TGT25
:
5775 case IA64_OPND_TGT25b
:
5776 case IA64_OPND_TGT25c
:
5777 case IA64_OPND_TGT64
:
5778 if (e
->X_op
== O_symbol
)
5780 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5781 if (opnd
== IA64_OPND_TGT25
)
5782 fix
->code
= BFD_RELOC_IA64_PCREL21F
;
5783 else if (opnd
== IA64_OPND_TGT25b
)
5784 fix
->code
= BFD_RELOC_IA64_PCREL21M
;
5785 else if (opnd
== IA64_OPND_TGT25c
)
5786 fix
->code
= BFD_RELOC_IA64_PCREL21B
;
5787 else if (opnd
== IA64_OPND_TGT64
)
5788 fix
->code
= BFD_RELOC_IA64_PCREL60B
;
5792 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5793 fix
->opnd
= idesc
->operands
[index
];
5796 ++CURR_SLOT
.num_fixups
;
5797 return OPERAND_MATCH
;
5799 case IA64_OPND_TAG13
:
5800 case IA64_OPND_TAG13b
:
5804 return OPERAND_MATCH
;
5807 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5808 /* There are no external relocs for TAG13/TAG13b fields, so we
5809 create a dummy reloc. This will not live past md_apply_fix. */
5810 fix
->code
= BFD_RELOC_UNUSED
;
5811 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5812 fix
->opnd
= idesc
->operands
[index
];
5815 ++CURR_SLOT
.num_fixups
;
5816 return OPERAND_MATCH
;
5823 case IA64_OPND_LDXMOV
:
5824 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5825 fix
->code
= BFD_RELOC_IA64_LDXMOV
;
5826 fix
->opnd
= idesc
->operands
[index
];
5829 ++CURR_SLOT
.num_fixups
;
5830 return OPERAND_MATCH
;
5835 return OPERAND_MISMATCH
;
5839 parse_operand (expressionS
*e
, int more
)
5843 memset (e
, 0, sizeof (*e
));
5846 expression_and_evaluate (e
);
5847 sep
= *input_line_pointer
;
5848 if (more
&& (sep
== ',' || sep
== more
))
5849 ++input_line_pointer
;
5853 /* Returns the next entry in the opcode table that matches the one in
5854 IDESC, and frees the entry in IDESC. If no matching entry is
5855 found, NULL is returned instead. */
5857 static struct ia64_opcode
*
5858 get_next_opcode (struct ia64_opcode
*idesc
)
5860 struct ia64_opcode
*next
= ia64_find_next_opcode (idesc
);
5861 ia64_free_opcode (idesc
);
5865 /* Parse the operands for the opcode and find the opcode variant that
5866 matches the specified operands, or NULL if no match is possible. */
5868 static struct ia64_opcode
*
5869 parse_operands (struct ia64_opcode
*idesc
)
5871 int i
= 0, highest_unmatched_operand
, num_operands
= 0, num_outputs
= 0;
5872 int error_pos
, out_of_range_pos
, curr_out_of_range_pos
, sep
= 0;
5875 enum ia64_opnd expected_operand
= IA64_OPND_NIL
;
5876 enum operand_match_result result
;
5878 char *first_arg
= 0, *end
, *saved_input_pointer
;
5881 assert (strlen (idesc
->name
) <= 128);
5883 strcpy (mnemonic
, idesc
->name
);
5884 if (idesc
->operands
[2] == IA64_OPND_SOF
5885 || idesc
->operands
[1] == IA64_OPND_SOF
)
5887 /* To make the common idiom "alloc loc?=ar.pfs,0,1,0,0" work, we
5888 can't parse the first operand until we have parsed the
5889 remaining operands of the "alloc" instruction. */
5891 first_arg
= input_line_pointer
;
5892 end
= strchr (input_line_pointer
, '=');
5895 as_bad (_("Expected separator `='"));
5898 input_line_pointer
= end
+ 1;
5905 if (i
< NELEMS (CURR_SLOT
.opnd
))
5907 sep
= parse_operand (CURR_SLOT
.opnd
+ i
, '=');
5908 if (CURR_SLOT
.opnd
[i
].X_op
== O_absent
)
5915 sep
= parse_operand (&dummy
, '=');
5916 if (dummy
.X_op
== O_absent
)
5922 if (sep
!= '=' && sep
!= ',')
5927 if (num_outputs
> 0)
5928 as_bad (_("Duplicate equal sign (=) in instruction"));
5930 num_outputs
= i
+ 1;
5935 as_bad (_("Illegal operand separator `%c'"), sep
);
5939 if (idesc
->operands
[2] == IA64_OPND_SOF
5940 || idesc
->operands
[1] == IA64_OPND_SOF
)
5942 /* Map alloc r1=ar.pfs,i,l,o,r to alloc r1=ar.pfs,(i+l+o),(i+l),r.
5943 Note, however, that due to that mapping operand numbers in error
5944 messages for any of the constant operands will not be correct. */
5945 know (strcmp (idesc
->name
, "alloc") == 0);
5946 /* The first operand hasn't been parsed/initialized, yet (but
5947 num_operands intentionally doesn't account for that). */
5948 i
= num_operands
> 4 ? 2 : 1;
5949 #define FORCE_CONST(n) (CURR_SLOT.opnd[n].X_op == O_constant \
5950 ? CURR_SLOT.opnd[n].X_add_number \
5952 sof
= set_regstack (FORCE_CONST(i
),
5955 FORCE_CONST(i
+ 3));
5958 /* now we can parse the first arg: */
5959 saved_input_pointer
= input_line_pointer
;
5960 input_line_pointer
= first_arg
;
5961 sep
= parse_operand (CURR_SLOT
.opnd
+ 0, '=');
5963 --num_outputs
; /* force error */
5964 input_line_pointer
= saved_input_pointer
;
5966 CURR_SLOT
.opnd
[i
].X_add_number
= sof
;
5967 if (CURR_SLOT
.opnd
[i
+ 1].X_op
== O_constant
5968 && CURR_SLOT
.opnd
[i
+ 2].X_op
== O_constant
)
5969 CURR_SLOT
.opnd
[i
+ 1].X_add_number
5970 = sof
- CURR_SLOT
.opnd
[i
+ 2].X_add_number
;
5972 CURR_SLOT
.opnd
[i
+ 1].X_op
= O_illegal
;
5973 CURR_SLOT
.opnd
[i
+ 2] = CURR_SLOT
.opnd
[i
+ 3];
5976 highest_unmatched_operand
= -4;
5977 curr_out_of_range_pos
= -1;
5979 for (; idesc
; idesc
= get_next_opcode (idesc
))
5981 if (num_outputs
!= idesc
->num_outputs
)
5982 continue; /* mismatch in # of outputs */
5983 if (highest_unmatched_operand
< 0)
5984 highest_unmatched_operand
|= 1;
5985 if (num_operands
> NELEMS (idesc
->operands
)
5986 || (num_operands
< NELEMS (idesc
->operands
)
5987 && idesc
->operands
[num_operands
])
5988 || (num_operands
> 0 && !idesc
->operands
[num_operands
- 1]))
5989 continue; /* mismatch in number of arguments */
5990 if (highest_unmatched_operand
< 0)
5991 highest_unmatched_operand
|= 2;
5993 CURR_SLOT
.num_fixups
= 0;
5995 /* Try to match all operands. If we see an out-of-range operand,
5996 then continue trying to match the rest of the operands, since if
5997 the rest match, then this idesc will give the best error message. */
5999 out_of_range_pos
= -1;
6000 for (i
= 0; i
< num_operands
&& idesc
->operands
[i
]; ++i
)
6002 result
= operand_match (idesc
, i
, CURR_SLOT
.opnd
+ i
);
6003 if (result
!= OPERAND_MATCH
)
6005 if (result
!= OPERAND_OUT_OF_RANGE
)
6007 if (out_of_range_pos
< 0)
6008 /* remember position of the first out-of-range operand: */
6009 out_of_range_pos
= i
;
6013 /* If we did not match all operands, or if at least one operand was
6014 out-of-range, then this idesc does not match. Keep track of which
6015 idesc matched the most operands before failing. If we have two
6016 idescs that failed at the same position, and one had an out-of-range
6017 operand, then prefer the out-of-range operand. Thus if we have
6018 "add r0=0x1000000,r1" we get an error saying the constant is out
6019 of range instead of an error saying that the constant should have been
6022 if (i
!= num_operands
|| out_of_range_pos
>= 0)
6024 if (i
> highest_unmatched_operand
6025 || (i
== highest_unmatched_operand
6026 && out_of_range_pos
> curr_out_of_range_pos
))
6028 highest_unmatched_operand
= i
;
6029 if (out_of_range_pos
>= 0)
6031 expected_operand
= idesc
->operands
[out_of_range_pos
];
6032 error_pos
= out_of_range_pos
;
6036 expected_operand
= idesc
->operands
[i
];
6039 curr_out_of_range_pos
= out_of_range_pos
;
6048 if (expected_operand
)
6049 as_bad (_("Operand %u of `%s' should be %s"),
6050 error_pos
+ 1, mnemonic
,
6051 elf64_ia64_operands
[expected_operand
].desc
);
6052 else if (highest_unmatched_operand
< 0 && !(highest_unmatched_operand
& 1))
6053 as_bad (_("Wrong number of output operands"));
6054 else if (highest_unmatched_operand
< 0 && !(highest_unmatched_operand
& 2))
6055 as_bad (_("Wrong number of input operands"));
6057 as_bad (_("Operand mismatch"));
6061 /* Check that the instruction doesn't use
6062 - r0, f0, or f1 as output operands
6063 - the same predicate twice as output operands
6064 - r0 as address of a base update load or store
6065 - the same GR as output and address of a base update load
6066 - two even- or two odd-numbered FRs as output operands of a floating
6067 point parallel load.
6068 At most two (conflicting) output (or output-like) operands can exist,
6069 (floating point parallel loads have three outputs, but the base register,
6070 if updated, cannot conflict with the actual outputs). */
6072 for (i
= 0; i
< num_operands
; ++i
)
6077 switch (idesc
->operands
[i
])
6082 if (i
< num_outputs
)
6084 if (CURR_SLOT
.opnd
[i
].X_add_number
== REG_GR
)
6087 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6089 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6094 if (i
< num_outputs
)
6097 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6099 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6106 if (i
< num_outputs
)
6108 if (CURR_SLOT
.opnd
[i
].X_add_number
>= REG_FR
6109 && CURR_SLOT
.opnd
[i
].X_add_number
<= REG_FR
+ 1)
6112 regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
6115 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6117 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6121 if (idesc
->flags
& IA64_OPCODE_POSTINC
)
6123 if (CURR_SLOT
.opnd
[i
].X_add_number
== REG_GR
)
6126 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6128 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6139 as_warn (_("Invalid use of `%c%d' as output operand"), reg_class
, regno
);
6142 as_warn (_("Invalid use of `r%d' as base update address operand"), regno
);
6148 if (reg1
>= REG_GR
&& reg1
<= REG_GR
+ 127)
6153 else if (reg1
>= REG_P
&& reg1
<= REG_P
+ 63)
6158 else if (reg1
>= REG_FR
&& reg1
<= REG_FR
+ 127)
6166 as_warn (_("Invalid duplicate use of `%c%d'"), reg_class
, reg1
);
6168 else if (((reg1
>= REG_FR
&& reg1
<= REG_FR
+ 31
6169 && reg2
>= REG_FR
&& reg2
<= REG_FR
+ 31)
6170 || (reg1
>= REG_FR
+ 32 && reg1
<= REG_FR
+ 127
6171 && reg2
>= REG_FR
+ 32 && reg2
<= REG_FR
+ 127))
6172 && ! ((reg1
^ reg2
) & 1))
6173 as_warn (_("Invalid simultaneous use of `f%d' and `f%d'"),
6174 reg1
- REG_FR
, reg2
- REG_FR
);
6175 else if ((reg1
>= REG_FR
&& reg1
<= REG_FR
+ 31
6176 && reg2
>= REG_FR
+ 32 && reg2
<= REG_FR
+ 127)
6177 || (reg1
>= REG_FR
+ 32 && reg1
<= REG_FR
+ 127
6178 && reg2
>= REG_FR
&& reg2
<= REG_FR
+ 31))
6179 as_warn (_("Dangerous simultaneous use of `f%d' and `f%d'"),
6180 reg1
- REG_FR
, reg2
- REG_FR
);
6185 build_insn (struct slot
*slot
, bfd_vma
*insnp
)
6187 const struct ia64_operand
*odesc
, *o2desc
;
6188 struct ia64_opcode
*idesc
= slot
->idesc
;
6194 insn
= idesc
->opcode
| slot
->qp_regno
;
6196 for (i
= 0; i
< NELEMS (idesc
->operands
) && idesc
->operands
[i
]; ++i
)
6198 if (slot
->opnd
[i
].X_op
== O_register
6199 || slot
->opnd
[i
].X_op
== O_constant
6200 || slot
->opnd
[i
].X_op
== O_index
)
6201 val
= slot
->opnd
[i
].X_add_number
;
6202 else if (slot
->opnd
[i
].X_op
== O_big
)
6204 /* This must be the value 0x10000000000000000. */
6205 assert (idesc
->operands
[i
] == IA64_OPND_IMM8M1U8
);
6211 switch (idesc
->operands
[i
])
6213 case IA64_OPND_IMMU64
:
6214 *insnp
++ = (val
>> 22) & 0x1ffffffffffLL
;
6215 insn
|= (((val
& 0x7f) << 13) | (((val
>> 7) & 0x1ff) << 27)
6216 | (((val
>> 16) & 0x1f) << 22) | (((val
>> 21) & 0x1) << 21)
6217 | (((val
>> 63) & 0x1) << 36));
6220 case IA64_OPND_IMMU62
:
6221 val
&= 0x3fffffffffffffffULL
;
6222 if (val
!= slot
->opnd
[i
].X_add_number
)
6223 as_warn (_("Value truncated to 62 bits"));
6224 *insnp
++ = (val
>> 21) & 0x1ffffffffffLL
;
6225 insn
|= (((val
& 0xfffff) << 6) | (((val
>> 20) & 0x1) << 36));
6228 case IA64_OPND_TGT64
:
6230 *insnp
++ = ((val
>> 20) & 0x7fffffffffLL
) << 2;
6231 insn
|= ((((val
>> 59) & 0x1) << 36)
6232 | (((val
>> 0) & 0xfffff) << 13));
6263 case IA64_OPND_R3_2
:
6264 case IA64_OPND_CPUID_R3
:
6265 case IA64_OPND_DBR_R3
:
6266 case IA64_OPND_DTR_R3
:
6267 case IA64_OPND_ITR_R3
:
6268 case IA64_OPND_IBR_R3
:
6270 case IA64_OPND_MSR_R3
:
6271 case IA64_OPND_PKR_R3
:
6272 case IA64_OPND_PMC_R3
:
6273 case IA64_OPND_PMD_R3
:
6274 case IA64_OPND_RR_R3
:
6282 odesc
= elf64_ia64_operands
+ idesc
->operands
[i
];
6283 err
= (*odesc
->insert
) (odesc
, val
, &insn
);
6285 as_bad_where (slot
->src_file
, slot
->src_line
,
6286 _("Bad operand value: %s"), err
);
6287 if (idesc
->flags
& IA64_OPCODE_PSEUDO
)
6289 if ((idesc
->flags
& IA64_OPCODE_F2_EQ_F3
)
6290 && odesc
== elf64_ia64_operands
+ IA64_OPND_F3
)
6292 o2desc
= elf64_ia64_operands
+ IA64_OPND_F2
;
6293 (*o2desc
->insert
) (o2desc
, val
, &insn
);
6295 if ((idesc
->flags
& IA64_OPCODE_LEN_EQ_64MCNT
)
6296 && (odesc
== elf64_ia64_operands
+ IA64_OPND_CPOS6a
6297 || odesc
== elf64_ia64_operands
+ IA64_OPND_POS6
))
6299 o2desc
= elf64_ia64_operands
+ IA64_OPND_LEN6
;
6300 (*o2desc
->insert
) (o2desc
, 64 - val
, &insn
);
6308 emit_one_bundle (void)
6310 int manual_bundling_off
= 0, manual_bundling
= 0;
6311 enum ia64_unit required_unit
, insn_unit
= 0;
6312 enum ia64_insn_type type
[3], insn_type
;
6313 unsigned int template, orig_template
;
6314 bfd_vma insn
[3] = { -1, -1, -1 };
6315 struct ia64_opcode
*idesc
;
6316 int end_of_insn_group
= 0, user_template
= -1;
6317 int n
, i
, j
, first
, curr
, last_slot
;
6318 bfd_vma t0
= 0, t1
= 0;
6319 struct label_fix
*lfix
;
6320 bfd_boolean mark_label
;
6321 struct insn_fix
*ifix
;
6327 first
= (md
.curr_slot
+ NUM_SLOTS
- md
.num_slots_in_use
) % NUM_SLOTS
;
6328 know (first
>= 0 && first
< NUM_SLOTS
);
6329 n
= MIN (3, md
.num_slots_in_use
);
6331 /* Determine template: user user_template if specified, best match
6334 if (md
.slot
[first
].user_template
>= 0)
6335 user_template
= template = md
.slot
[first
].user_template
;
6338 /* Auto select appropriate template. */
6339 memset (type
, 0, sizeof (type
));
6341 for (i
= 0; i
< n
; ++i
)
6343 if (md
.slot
[curr
].label_fixups
&& i
!= 0)
6345 type
[i
] = md
.slot
[curr
].idesc
->type
;
6346 curr
= (curr
+ 1) % NUM_SLOTS
;
6348 template = best_template
[type
[0]][type
[1]][type
[2]];
6351 /* initialize instructions with appropriate nops: */
6352 for (i
= 0; i
< 3; ++i
)
6353 insn
[i
] = nop
[ia64_templ_desc
[template].exec_unit
[i
]];
6357 /* Check to see if this bundle is at an offset that is a multiple of 16-bytes
6358 from the start of the frag. */
6359 addr_mod
= frag_now_fix () & 15;
6360 if (frag_now
->has_code
&& frag_now
->insn_addr
!= addr_mod
)
6361 as_bad (_("instruction address is not a multiple of 16"));
6362 frag_now
->insn_addr
= addr_mod
;
6363 frag_now
->has_code
= 1;
6365 /* now fill in slots with as many insns as possible: */
6367 idesc
= md
.slot
[curr
].idesc
;
6368 end_of_insn_group
= 0;
6370 for (i
= 0; i
< 3 && md
.num_slots_in_use
> 0; ++i
)
6372 /* If we have unwind records, we may need to update some now. */
6373 unw_rec_list
*ptr
= md
.slot
[curr
].unwind_record
;
6374 unw_rec_list
*end_ptr
= NULL
;
6378 /* Find the last prologue/body record in the list for the current
6379 insn, and set the slot number for all records up to that point.
6380 This needs to be done now, because prologue/body records refer to
6381 the current point, not the point after the instruction has been
6382 issued. This matters because there may have been nops emitted
6383 meanwhile. Any non-prologue non-body record followed by a
6384 prologue/body record must also refer to the current point. */
6385 unw_rec_list
*last_ptr
;
6387 for (j
= 1; end_ptr
== NULL
&& j
< md
.num_slots_in_use
; ++j
)
6388 end_ptr
= md
.slot
[(curr
+ j
) % NUM_SLOTS
].unwind_record
;
6389 for (last_ptr
= NULL
; ptr
!= end_ptr
; ptr
= ptr
->next
)
6390 if (ptr
->r
.type
== prologue
|| ptr
->r
.type
== prologue_gr
6391 || ptr
->r
.type
== body
)
6395 /* Make last_ptr point one after the last prologue/body
6397 last_ptr
= last_ptr
->next
;
6398 for (ptr
= md
.slot
[curr
].unwind_record
; ptr
!= last_ptr
;
6401 ptr
->slot_number
= (unsigned long) f
+ i
;
6402 ptr
->slot_frag
= frag_now
;
6404 /* Remove the initialized records, so that we won't accidentally
6405 update them again if we insert a nop and continue. */
6406 md
.slot
[curr
].unwind_record
= last_ptr
;
6410 manual_bundling_off
= md
.slot
[curr
].manual_bundling_off
;
6411 if (md
.slot
[curr
].manual_bundling_on
)
6414 manual_bundling
= 1;
6416 break; /* Need to start a new bundle. */
6419 /* If this instruction specifies a template, then it must be the first
6420 instruction of a bundle. */
6421 if (curr
!= first
&& md
.slot
[curr
].user_template
>= 0)
6424 if (idesc
->flags
& IA64_OPCODE_SLOT2
)
6426 if (manual_bundling
&& !manual_bundling_off
)
6428 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6429 _("`%s' must be last in bundle"), idesc
->name
);
6431 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6435 if (idesc
->flags
& IA64_OPCODE_LAST
)
6438 unsigned int required_template
;
6440 /* If we need a stop bit after an M slot, our only choice is
6441 template 5 (M;;MI). If we need a stop bit after a B
6442 slot, our only choice is to place it at the end of the
6443 bundle, because the only available templates are MIB,
6444 MBB, BBB, MMB, and MFB. We don't handle anything other
6445 than M and B slots because these are the only kind of
6446 instructions that can have the IA64_OPCODE_LAST bit set. */
6447 required_template
= template;
6448 switch (idesc
->type
)
6452 required_template
= 5;
6460 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6461 _("Internal error: don't know how to force %s to end of instruction group"),
6467 && (i
> required_slot
6468 || (required_slot
== 2 && !manual_bundling_off
)
6469 || (user_template
>= 0
6470 /* Changing from MMI to M;MI is OK. */
6471 && (template ^ required_template
) > 1)))
6473 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6474 _("`%s' must be last in instruction group"),
6476 if (i
< 2 && required_slot
== 2 && !manual_bundling_off
)
6477 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6479 if (required_slot
< i
)
6480 /* Can't fit this instruction. */
6484 if (required_template
!= template)
6486 /* If we switch the template, we need to reset the NOPs
6487 after slot i. The slot-types of the instructions ahead
6488 of i never change, so we don't need to worry about
6489 changing NOPs in front of this slot. */
6490 for (j
= i
; j
< 3; ++j
)
6491 insn
[j
] = nop
[ia64_templ_desc
[required_template
].exec_unit
[j
]];
6493 /* We just picked a template that includes the stop bit in the
6494 middle, so we don't need another one emitted later. */
6495 md
.slot
[curr
].end_of_insn_group
= 0;
6497 template = required_template
;
6499 if (curr
!= first
&& md
.slot
[curr
].label_fixups
)
6501 if (manual_bundling
)
6503 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6504 _("Label must be first in a bundle"));
6505 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6507 /* This insn must go into the first slot of a bundle. */
6511 if (end_of_insn_group
&& md
.num_slots_in_use
>= 1)
6513 /* We need an instruction group boundary in the middle of a
6514 bundle. See if we can switch to an other template with
6515 an appropriate boundary. */
6517 orig_template
= template;
6518 if (i
== 1 && (user_template
== 4
6519 || (user_template
< 0
6520 && (ia64_templ_desc
[template].exec_unit
[0]
6524 end_of_insn_group
= 0;
6526 else if (i
== 2 && (user_template
== 0
6527 || (user_template
< 0
6528 && (ia64_templ_desc
[template].exec_unit
[1]
6530 /* This test makes sure we don't switch the template if
6531 the next instruction is one that needs to be first in
6532 an instruction group. Since all those instructions are
6533 in the M group, there is no way such an instruction can
6534 fit in this bundle even if we switch the template. The
6535 reason we have to check for this is that otherwise we
6536 may end up generating "MI;;I M.." which has the deadly
6537 effect that the second M instruction is no longer the
6538 first in the group! --davidm 99/12/16 */
6539 && (idesc
->flags
& IA64_OPCODE_FIRST
) == 0)
6542 end_of_insn_group
= 0;
6545 && user_template
== 0
6546 && !(idesc
->flags
& IA64_OPCODE_FIRST
))
6547 /* Use the next slot. */
6549 else if (curr
!= first
)
6550 /* can't fit this insn */
6553 if (template != orig_template
)
6554 /* if we switch the template, we need to reset the NOPs
6555 after slot i. The slot-types of the instructions ahead
6556 of i never change, so we don't need to worry about
6557 changing NOPs in front of this slot. */
6558 for (j
= i
; j
< 3; ++j
)
6559 insn
[j
] = nop
[ia64_templ_desc
[template].exec_unit
[j
]];
6561 required_unit
= ia64_templ_desc
[template].exec_unit
[i
];
6563 /* resolve dynamic opcodes such as "break", "hint", and "nop": */
6564 if (idesc
->type
== IA64_TYPE_DYN
)
6566 enum ia64_opnd opnd1
, opnd2
;
6568 if ((strcmp (idesc
->name
, "nop") == 0)
6569 || (strcmp (idesc
->name
, "break") == 0))
6570 insn_unit
= required_unit
;
6571 else if (strcmp (idesc
->name
, "hint") == 0)
6573 insn_unit
= required_unit
;
6574 if (required_unit
== IA64_UNIT_B
)
6580 case hint_b_warning
:
6581 as_warn (_("hint in B unit may be treated as nop"));
6584 /* When manual bundling is off and there is no
6585 user template, we choose a different unit so
6586 that hint won't go into the current slot. We
6587 will fill the current bundle with nops and
6588 try to put hint into the next bundle. */
6589 if (!manual_bundling
&& user_template
< 0)
6590 insn_unit
= IA64_UNIT_I
;
6592 as_bad (_("hint in B unit can't be used"));
6597 else if (strcmp (idesc
->name
, "chk.s") == 0
6598 || strcmp (idesc
->name
, "mov") == 0)
6600 insn_unit
= IA64_UNIT_M
;
6601 if (required_unit
== IA64_UNIT_I
6602 || (required_unit
== IA64_UNIT_F
&& template == 6))
6603 insn_unit
= IA64_UNIT_I
;
6606 as_fatal (_("emit_one_bundle: unexpected dynamic op"));
6608 snprintf (mnemonic
, sizeof (mnemonic
), "%s.%c",
6609 idesc
->name
, "?imbfxx"[insn_unit
]);
6610 opnd1
= idesc
->operands
[0];
6611 opnd2
= idesc
->operands
[1];
6612 ia64_free_opcode (idesc
);
6613 idesc
= ia64_find_opcode (mnemonic
);
6614 /* moves to/from ARs have collisions */
6615 if (opnd1
== IA64_OPND_AR3
|| opnd2
== IA64_OPND_AR3
)
6617 while (idesc
!= NULL
6618 && (idesc
->operands
[0] != opnd1
6619 || idesc
->operands
[1] != opnd2
))
6620 idesc
= get_next_opcode (idesc
);
6622 md
.slot
[curr
].idesc
= idesc
;
6626 insn_type
= idesc
->type
;
6627 insn_unit
= IA64_UNIT_NIL
;
6631 if (required_unit
== IA64_UNIT_I
|| required_unit
== IA64_UNIT_M
)
6632 insn_unit
= required_unit
;
6634 case IA64_TYPE_X
: insn_unit
= IA64_UNIT_L
; break;
6635 case IA64_TYPE_I
: insn_unit
= IA64_UNIT_I
; break;
6636 case IA64_TYPE_M
: insn_unit
= IA64_UNIT_M
; break;
6637 case IA64_TYPE_B
: insn_unit
= IA64_UNIT_B
; break;
6638 case IA64_TYPE_F
: insn_unit
= IA64_UNIT_F
; break;
6643 if (insn_unit
!= required_unit
)
6644 continue; /* Try next slot. */
6646 /* Now is a good time to fix up the labels for this insn. */
6648 for (lfix
= md
.slot
[curr
].label_fixups
; lfix
; lfix
= lfix
->next
)
6650 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16);
6651 symbol_set_frag (lfix
->sym
, frag_now
);
6652 mark_label
|= lfix
->dw2_mark_labels
;
6654 for (lfix
= md
.slot
[curr
].tag_fixups
; lfix
; lfix
= lfix
->next
)
6656 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16 + i
);
6657 symbol_set_frag (lfix
->sym
, frag_now
);
6660 if (debug_type
== DEBUG_DWARF2
6661 || md
.slot
[curr
].loc_directive_seen
6664 bfd_vma addr
= frag_now
->fr_address
+ frag_now_fix () - 16 + i
;
6666 md
.slot
[curr
].loc_directive_seen
= 0;
6668 md
.slot
[curr
].debug_line
.flags
|= DWARF2_FLAG_BASIC_BLOCK
;
6670 dwarf2_gen_line_info (addr
, &md
.slot
[curr
].debug_line
);
6673 build_insn (md
.slot
+ curr
, insn
+ i
);
6675 ptr
= md
.slot
[curr
].unwind_record
;
6678 /* Set slot numbers for all remaining unwind records belonging to the
6679 current insn. There can not be any prologue/body unwind records
6681 for (; ptr
!= end_ptr
; ptr
= ptr
->next
)
6683 ptr
->slot_number
= (unsigned long) f
+ i
;
6684 ptr
->slot_frag
= frag_now
;
6686 md
.slot
[curr
].unwind_record
= NULL
;
6689 if (required_unit
== IA64_UNIT_L
)
6692 /* skip one slot for long/X-unit instructions */
6695 --md
.num_slots_in_use
;
6698 for (j
= 0; j
< md
.slot
[curr
].num_fixups
; ++j
)
6700 ifix
= md
.slot
[curr
].fixup
+ j
;
6701 fix
= fix_new_exp (frag_now
, frag_now_fix () - 16 + i
, 8,
6702 &ifix
->expr
, ifix
->is_pcrel
, ifix
->code
);
6703 fix
->tc_fix_data
.opnd
= ifix
->opnd
;
6704 fix
->fx_file
= md
.slot
[curr
].src_file
;
6705 fix
->fx_line
= md
.slot
[curr
].src_line
;
6708 end_of_insn_group
= md
.slot
[curr
].end_of_insn_group
;
6711 ia64_free_opcode (md
.slot
[curr
].idesc
);
6712 memset (md
.slot
+ curr
, 0, sizeof (md
.slot
[curr
]));
6713 md
.slot
[curr
].user_template
= -1;
6715 if (manual_bundling_off
)
6717 manual_bundling
= 0;
6720 curr
= (curr
+ 1) % NUM_SLOTS
;
6721 idesc
= md
.slot
[curr
].idesc
;
6724 /* A user template was specified, but the first following instruction did
6725 not fit. This can happen with or without manual bundling. */
6726 if (md
.num_slots_in_use
> 0 && last_slot
< 0)
6728 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6729 _("`%s' does not fit into %s template"),
6730 idesc
->name
, ia64_templ_desc
[template].name
);
6731 /* Drop first insn so we don't livelock. */
6732 --md
.num_slots_in_use
;
6733 know (curr
== first
);
6734 ia64_free_opcode (md
.slot
[curr
].idesc
);
6735 memset (md
.slot
+ curr
, 0, sizeof (md
.slot
[curr
]));
6736 md
.slot
[curr
].user_template
= -1;
6738 else if (manual_bundling
> 0)
6740 if (md
.num_slots_in_use
> 0)
6743 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6744 _("`%s' does not fit into bundle"), idesc
->name
);
6751 else if (last_slot
== 0)
6752 where
= "slots 2 or 3";
6755 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6756 _("`%s' can't go in %s of %s template"),
6757 idesc
->name
, where
, ia64_templ_desc
[template].name
);
6761 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6762 _("Missing '}' at end of file"));
6765 know (md
.num_slots_in_use
< NUM_SLOTS
);
6767 t0
= end_of_insn_group
| (template << 1) | (insn
[0] << 5) | (insn
[1] << 46);
6768 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
6770 number_to_chars_littleendian (f
+ 0, t0
, 8);
6771 number_to_chars_littleendian (f
+ 8, t1
, 8);
6775 md_parse_option (int c
, char *arg
)
6780 /* Switches from the Intel assembler. */
6782 if (strcmp (arg
, "ilp64") == 0
6783 || strcmp (arg
, "lp64") == 0
6784 || strcmp (arg
, "p64") == 0)
6786 md
.flags
|= EF_IA_64_ABI64
;
6788 else if (strcmp (arg
, "ilp32") == 0)
6790 md
.flags
&= ~EF_IA_64_ABI64
;
6792 else if (strcmp (arg
, "le") == 0)
6794 md
.flags
&= ~EF_IA_64_BE
;
6795 default_big_endian
= 0;
6797 else if (strcmp (arg
, "be") == 0)
6799 md
.flags
|= EF_IA_64_BE
;
6800 default_big_endian
= 1;
6802 else if (strncmp (arg
, "unwind-check=", 13) == 0)
6805 if (strcmp (arg
, "warning") == 0)
6806 md
.unwind_check
= unwind_check_warning
;
6807 else if (strcmp (arg
, "error") == 0)
6808 md
.unwind_check
= unwind_check_error
;
6812 else if (strncmp (arg
, "hint.b=", 7) == 0)
6815 if (strcmp (arg
, "ok") == 0)
6816 md
.hint_b
= hint_b_ok
;
6817 else if (strcmp (arg
, "warning") == 0)
6818 md
.hint_b
= hint_b_warning
;
6819 else if (strcmp (arg
, "error") == 0)
6820 md
.hint_b
= hint_b_error
;
6824 else if (strncmp (arg
, "tune=", 5) == 0)
6827 if (strcmp (arg
, "itanium1") == 0)
6829 else if (strcmp (arg
, "itanium2") == 0)
6839 if (strcmp (arg
, "so") == 0)
6841 /* Suppress signon message. */
6843 else if (strcmp (arg
, "pi") == 0)
6845 /* Reject privileged instructions. FIXME */
6847 else if (strcmp (arg
, "us") == 0)
6849 /* Allow union of signed and unsigned range. FIXME */
6851 else if (strcmp (arg
, "close_fcalls") == 0)
6853 /* Do not resolve global function calls. */
6860 /* temp[="prefix"] Insert temporary labels into the object file
6861 symbol table prefixed by "prefix".
6862 Default prefix is ":temp:".
6867 /* indirect=<tgt> Assume unannotated indirect branches behavior
6868 according to <tgt> --
6869 exit: branch out from the current context (default)
6870 labels: all labels in context may be branch targets
6872 if (strncmp (arg
, "indirect=", 9) != 0)
6877 /* -X conflicts with an ignored option, use -x instead */
6879 if (!arg
|| strcmp (arg
, "explicit") == 0)
6881 /* set default mode to explicit */
6882 md
.default_explicit_mode
= 1;
6885 else if (strcmp (arg
, "auto") == 0)
6887 md
.default_explicit_mode
= 0;
6889 else if (strcmp (arg
, "none") == 0)
6893 else if (strcmp (arg
, "debug") == 0)
6897 else if (strcmp (arg
, "debugx") == 0)
6899 md
.default_explicit_mode
= 1;
6902 else if (strcmp (arg
, "debugn") == 0)
6909 as_bad (_("Unrecognized option '-x%s'"), arg
);
6914 /* nops Print nops statistics. */
6917 /* GNU specific switches for gcc. */
6918 case OPTION_MCONSTANT_GP
:
6919 md
.flags
|= EF_IA_64_CONS_GP
;
6922 case OPTION_MAUTO_PIC
:
6923 md
.flags
|= EF_IA_64_NOFUNCDESC_CONS_GP
;
6934 md_show_usage (FILE *stream
)
6938 --mconstant-gp mark output file as using the constant-GP model\n\
6939 (sets ELF header flag EF_IA_64_CONS_GP)\n\
6940 --mauto-pic mark output file as using the constant-GP model\n\
6941 without function descriptors (sets ELF header flag\n\
6942 EF_IA_64_NOFUNCDESC_CONS_GP)\n\
6943 -milp32|-milp64|-mlp64|-mp64 select data model (default -mlp64)\n\
6944 -mle | -mbe select little- or big-endian byte order (default -mle)\n\
6945 -mtune=[itanium1|itanium2]\n\
6946 tune for a specific CPU (default -mtune=itanium2)\n\
6947 -munwind-check=[warning|error]\n\
6948 unwind directive check (default -munwind-check=warning)\n\
6949 -mhint.b=[ok|warning|error]\n\
6950 hint.b check (default -mhint.b=error)\n\
6951 -x | -xexplicit turn on dependency violation checking\n\
6952 -xauto automagically remove dependency violations (default)\n\
6953 -xnone turn off dependency violation checking\n\
6954 -xdebug debug dependency violation checker\n\
6955 -xdebugn debug dependency violation checker but turn off\n\
6956 dependency violation checking\n\
6957 -xdebugx debug dependency violation checker and turn on\n\
6958 dependency violation checking\n"),
6963 ia64_after_parse_args (void)
6965 if (debug_type
== DEBUG_STABS
)
6966 as_fatal (_("--gstabs is not supported for ia64"));
6969 /* Return true if TYPE fits in TEMPL at SLOT. */
6972 match (int templ
, int type
, int slot
)
6974 enum ia64_unit unit
;
6977 unit
= ia64_templ_desc
[templ
].exec_unit
[slot
];
6980 case IA64_TYPE_DYN
: result
= 1; break; /* for nop and break */
6982 result
= (unit
== IA64_UNIT_I
|| unit
== IA64_UNIT_M
);
6984 case IA64_TYPE_X
: result
= (unit
== IA64_UNIT_L
); break;
6985 case IA64_TYPE_I
: result
= (unit
== IA64_UNIT_I
); break;
6986 case IA64_TYPE_M
: result
= (unit
== IA64_UNIT_M
); break;
6987 case IA64_TYPE_B
: result
= (unit
== IA64_UNIT_B
); break;
6988 case IA64_TYPE_F
: result
= (unit
== IA64_UNIT_F
); break;
6989 default: result
= 0; break;
6994 /* For Itanium 1, add a bit of extra goodness if a nop of type F or B would fit
6995 in TEMPL at SLOT. For Itanium 2, add a bit of extra goodness if a nop of
6996 type M or I would fit in TEMPL at SLOT. */
6999 extra_goodness (int templ
, int slot
)
7004 if (slot
== 1 && match (templ
, IA64_TYPE_F
, slot
))
7006 else if (slot
== 2 && match (templ
, IA64_TYPE_B
, slot
))
7012 if (match (templ
, IA64_TYPE_M
, slot
)
7013 || match (templ
, IA64_TYPE_I
, slot
))
7014 /* Favor M- and I-unit NOPs. We definitely want to avoid
7015 F-unit and B-unit may cause split-issue or less-than-optimal
7016 branch-prediction. */
7027 /* This function is called once, at assembler startup time. It sets
7028 up all the tables, etc. that the MD part of the assembler will need
7029 that can be determined before arguments are parsed. */
7033 int i
, j
, k
, t
, goodness
, best
, ok
;
7038 md
.explicit_mode
= md
.default_explicit_mode
;
7040 bfd_set_section_alignment (stdoutput
, text_section
, 4);
7042 /* Make sure function pointers get initialized. */
7043 target_big_endian
= -1;
7044 dot_byteorder (default_big_endian
);
7046 alias_hash
= hash_new ();
7047 alias_name_hash
= hash_new ();
7048 secalias_hash
= hash_new ();
7049 secalias_name_hash
= hash_new ();
7051 pseudo_func
[FUNC_DTP_MODULE
].u
.sym
=
7052 symbol_new (".<dtpmod>", undefined_section
, FUNC_DTP_MODULE
,
7053 &zero_address_frag
);
7055 pseudo_func
[FUNC_DTP_RELATIVE
].u
.sym
=
7056 symbol_new (".<dtprel>", undefined_section
, FUNC_DTP_RELATIVE
,
7057 &zero_address_frag
);
7059 pseudo_func
[FUNC_FPTR_RELATIVE
].u
.sym
=
7060 symbol_new (".<fptr>", undefined_section
, FUNC_FPTR_RELATIVE
,
7061 &zero_address_frag
);
7063 pseudo_func
[FUNC_GP_RELATIVE
].u
.sym
=
7064 symbol_new (".<gprel>", undefined_section
, FUNC_GP_RELATIVE
,
7065 &zero_address_frag
);
7067 pseudo_func
[FUNC_LT_RELATIVE
].u
.sym
=
7068 symbol_new (".<ltoff>", undefined_section
, FUNC_LT_RELATIVE
,
7069 &zero_address_frag
);
7071 pseudo_func
[FUNC_LT_RELATIVE_X
].u
.sym
=
7072 symbol_new (".<ltoffx>", undefined_section
, FUNC_LT_RELATIVE_X
,
7073 &zero_address_frag
);
7075 pseudo_func
[FUNC_PC_RELATIVE
].u
.sym
=
7076 symbol_new (".<pcrel>", undefined_section
, FUNC_PC_RELATIVE
,
7077 &zero_address_frag
);
7079 pseudo_func
[FUNC_PLT_RELATIVE
].u
.sym
=
7080 symbol_new (".<pltoff>", undefined_section
, FUNC_PLT_RELATIVE
,
7081 &zero_address_frag
);
7083 pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
=
7084 symbol_new (".<secrel>", undefined_section
, FUNC_SEC_RELATIVE
,
7085 &zero_address_frag
);
7087 pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
=
7088 symbol_new (".<segrel>", undefined_section
, FUNC_SEG_RELATIVE
,
7089 &zero_address_frag
);
7091 pseudo_func
[FUNC_TP_RELATIVE
].u
.sym
=
7092 symbol_new (".<tprel>", undefined_section
, FUNC_TP_RELATIVE
,
7093 &zero_address_frag
);
7095 pseudo_func
[FUNC_LTV_RELATIVE
].u
.sym
=
7096 symbol_new (".<ltv>", undefined_section
, FUNC_LTV_RELATIVE
,
7097 &zero_address_frag
);
7099 pseudo_func
[FUNC_LT_FPTR_RELATIVE
].u
.sym
=
7100 symbol_new (".<ltoff.fptr>", undefined_section
, FUNC_LT_FPTR_RELATIVE
,
7101 &zero_address_frag
);
7103 pseudo_func
[FUNC_LT_DTP_MODULE
].u
.sym
=
7104 symbol_new (".<ltoff.dtpmod>", undefined_section
, FUNC_LT_DTP_MODULE
,
7105 &zero_address_frag
);
7107 pseudo_func
[FUNC_LT_DTP_RELATIVE
].u
.sym
=
7108 symbol_new (".<ltoff.dptrel>", undefined_section
, FUNC_LT_DTP_RELATIVE
,
7109 &zero_address_frag
);
7111 pseudo_func
[FUNC_LT_TP_RELATIVE
].u
.sym
=
7112 symbol_new (".<ltoff.tprel>", undefined_section
, FUNC_LT_TP_RELATIVE
,
7113 &zero_address_frag
);
7115 pseudo_func
[FUNC_IPLT_RELOC
].u
.sym
=
7116 symbol_new (".<iplt>", undefined_section
, FUNC_IPLT_RELOC
,
7117 &zero_address_frag
);
7119 if (md
.tune
!= itanium1
)
7121 /* Convert MFI NOPs bundles into MMI NOPs bundles. */
7123 le_nop_stop
[0] = 0x9;
7126 /* Compute the table of best templates. We compute goodness as a
7127 base 4 value, in which each match counts for 3. Match-failures
7128 result in NOPs and we use extra_goodness() to pick the execution
7129 units that are best suited for issuing the NOP. */
7130 for (i
= 0; i
< IA64_NUM_TYPES
; ++i
)
7131 for (j
= 0; j
< IA64_NUM_TYPES
; ++j
)
7132 for (k
= 0; k
< IA64_NUM_TYPES
; ++k
)
7135 for (t
= 0; t
< NELEMS (ia64_templ_desc
); ++t
)
7138 if (match (t
, i
, 0))
7140 if (match (t
, j
, 1))
7142 if ((t
== 2 && j
== IA64_TYPE_X
) || match (t
, k
, 2))
7143 goodness
= 3 + 3 + 3;
7145 goodness
= 3 + 3 + extra_goodness (t
, 2);
7147 else if (match (t
, j
, 2))
7148 goodness
= 3 + 3 + extra_goodness (t
, 1);
7152 goodness
+= extra_goodness (t
, 1);
7153 goodness
+= extra_goodness (t
, 2);
7156 else if (match (t
, i
, 1))
7158 if ((t
== 2 && i
== IA64_TYPE_X
) || match (t
, j
, 2))
7161 goodness
= 3 + extra_goodness (t
, 2);
7163 else if (match (t
, i
, 2))
7164 goodness
= 3 + extra_goodness (t
, 1);
7166 if (goodness
> best
)
7169 best_template
[i
][j
][k
] = t
;
7174 #ifdef DEBUG_TEMPLATES
7175 /* For debugging changes to the best_template calculations. We don't care
7176 about combinations with invalid instructions, so start the loops at 1. */
7177 for (i
= 0; i
< IA64_NUM_TYPES
; ++i
)
7178 for (j
= 0; j
< IA64_NUM_TYPES
; ++j
)
7179 for (k
= 0; k
< IA64_NUM_TYPES
; ++k
)
7181 char type_letter
[IA64_NUM_TYPES
] = { 'n', 'a', 'i', 'm', 'b', 'f',
7183 fprintf (stderr
, "%c%c%c %s\n", type_letter
[i
], type_letter
[j
],
7185 ia64_templ_desc
[best_template
[i
][j
][k
]].name
);
7189 for (i
= 0; i
< NUM_SLOTS
; ++i
)
7190 md
.slot
[i
].user_template
= -1;
7192 md
.pseudo_hash
= hash_new ();
7193 for (i
= 0; i
< NELEMS (pseudo_opcode
); ++i
)
7195 err
= hash_insert (md
.pseudo_hash
, pseudo_opcode
[i
].name
,
7196 (void *) (pseudo_opcode
+ i
));
7198 as_fatal (_("ia64.md_begin: can't hash `%s': %s"),
7199 pseudo_opcode
[i
].name
, err
);
7202 md
.reg_hash
= hash_new ();
7203 md
.dynreg_hash
= hash_new ();
7204 md
.const_hash
= hash_new ();
7205 md
.entry_hash
= hash_new ();
7207 /* general registers: */
7208 declare_register_set ("r", 128, REG_GR
);
7209 declare_register ("gp", REG_GR
+ 1);
7210 declare_register ("sp", REG_GR
+ 12);
7211 declare_register ("tp", REG_GR
+ 13);
7212 declare_register_set ("ret", 4, REG_GR
+ 8);
7214 /* floating point registers: */
7215 declare_register_set ("f", 128, REG_FR
);
7216 declare_register_set ("farg", 8, REG_FR
+ 8);
7217 declare_register_set ("fret", 8, REG_FR
+ 8);
7219 /* branch registers: */
7220 declare_register_set ("b", 8, REG_BR
);
7221 declare_register ("rp", REG_BR
+ 0);
7223 /* predicate registers: */
7224 declare_register_set ("p", 64, REG_P
);
7225 declare_register ("pr", REG_PR
);
7226 declare_register ("pr.rot", REG_PR_ROT
);
7228 /* application registers: */
7229 declare_register_set ("ar", 128, REG_AR
);
7230 for (i
= 0; i
< NELEMS (ar
); ++i
)
7231 declare_register (ar
[i
].name
, REG_AR
+ ar
[i
].regnum
);
7233 /* control registers: */
7234 declare_register_set ("cr", 128, REG_CR
);
7235 for (i
= 0; i
< NELEMS (cr
); ++i
)
7236 declare_register (cr
[i
].name
, REG_CR
+ cr
[i
].regnum
);
7238 declare_register ("ip", REG_IP
);
7239 declare_register ("cfm", REG_CFM
);
7240 declare_register ("psr", REG_PSR
);
7241 declare_register ("psr.l", REG_PSR_L
);
7242 declare_register ("psr.um", REG_PSR_UM
);
7244 for (i
= 0; i
< NELEMS (indirect_reg
); ++i
)
7246 unsigned int regnum
= indirect_reg
[i
].regnum
;
7248 md
.indregsym
[regnum
- IND_CPUID
] = declare_register (indirect_reg
[i
].name
, regnum
);
7251 /* pseudo-registers used to specify unwind info: */
7252 declare_register ("psp", REG_PSP
);
7254 for (i
= 0; i
< NELEMS (const_bits
); ++i
)
7256 err
= hash_insert (md
.const_hash
, const_bits
[i
].name
,
7257 (void *) (const_bits
+ i
));
7259 as_fatal (_("Inserting \"%s\" into constant hash table failed: %s"),
7263 /* Set the architecture and machine depending on defaults and command line
7265 if (md
.flags
& EF_IA_64_ABI64
)
7266 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf64
);
7268 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf32
);
7271 as_warn (_("Could not set architecture and machine"));
7273 /* Set the pointer size and pointer shift size depending on md.flags */
7275 if (md
.flags
& EF_IA_64_ABI64
)
7277 md
.pointer_size
= 8; /* pointers are 8 bytes */
7278 md
.pointer_size_shift
= 3; /* alignment is 8 bytes = 2^2 */
7282 md
.pointer_size
= 4; /* pointers are 4 bytes */
7283 md
.pointer_size_shift
= 2; /* alignment is 4 bytes = 2^2 */
7286 md
.mem_offset
.hint
= 0;
7289 md
.entry_labels
= NULL
;
7292 /* Set the default options in md. Cannot do this in md_begin because
7293 that is called after md_parse_option which is where we set the
7294 options in md based on command line options. */
7297 ia64_init (int argc ATTRIBUTE_UNUSED
, char **argv ATTRIBUTE_UNUSED
)
7299 md
.flags
= MD_FLAGS_DEFAULT
;
7301 /* FIXME: We should change it to unwind_check_error someday. */
7302 md
.unwind_check
= unwind_check_warning
;
7303 md
.hint_b
= hint_b_error
;
7307 /* Return a string for the target object file format. */
7310 ia64_target_format (void)
7312 if (OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
7314 if (md
.flags
& EF_IA_64_BE
)
7316 if (md
.flags
& EF_IA_64_ABI64
)
7317 #if defined(TE_AIX50)
7318 return "elf64-ia64-aix-big";
7319 #elif defined(TE_HPUX)
7320 return "elf64-ia64-hpux-big";
7322 return "elf64-ia64-big";
7325 #if defined(TE_AIX50)
7326 return "elf32-ia64-aix-big";
7327 #elif defined(TE_HPUX)
7328 return "elf32-ia64-hpux-big";
7330 return "elf32-ia64-big";
7335 if (md
.flags
& EF_IA_64_ABI64
)
7337 return "elf64-ia64-aix-little";
7339 return "elf64-ia64-little";
7343 return "elf32-ia64-aix-little";
7345 return "elf32-ia64-little";
7350 return "unknown-format";
7354 ia64_end_of_source (void)
7356 /* terminate insn group upon reaching end of file: */
7357 insn_group_break (1, 0, 0);
7359 /* emits slots we haven't written yet: */
7360 ia64_flush_insns ();
7362 bfd_set_private_flags (stdoutput
, md
.flags
);
7364 md
.mem_offset
.hint
= 0;
7368 ia64_start_line (void)
7373 /* Make sure we don't reference input_line_pointer[-1] when that's
7379 if (md
.qp
.X_op
== O_register
)
7380 as_bad (_("qualifying predicate not followed by instruction"));
7381 md
.qp
.X_op
= O_absent
;
7383 if (ignore_input ())
7386 if (input_line_pointer
[0] == ';' && input_line_pointer
[-1] == ';')
7388 if (md
.detect_dv
&& !md
.explicit_mode
)
7395 as_warn (_("Explicit stops are ignored in auto mode"));
7399 insn_group_break (1, 0, 0);
7401 else if (input_line_pointer
[-1] == '{')
7403 if (md
.manual_bundling
)
7404 as_warn (_("Found '{' when manual bundling is already turned on"));
7406 CURR_SLOT
.manual_bundling_on
= 1;
7407 md
.manual_bundling
= 1;
7409 /* Bundling is only acceptable in explicit mode
7410 or when in default automatic mode. */
7411 if (md
.detect_dv
&& !md
.explicit_mode
)
7413 if (!md
.mode_explicitly_set
7414 && !md
.default_explicit_mode
)
7417 as_warn (_("Found '{' after explicit switch to automatic mode"));
7420 else if (input_line_pointer
[-1] == '}')
7422 if (!md
.manual_bundling
)
7423 as_warn (_("Found '}' when manual bundling is off"));
7425 PREV_SLOT
.manual_bundling_off
= 1;
7426 md
.manual_bundling
= 0;
7428 /* switch back to automatic mode, if applicable */
7431 && !md
.mode_explicitly_set
7432 && !md
.default_explicit_mode
)
7437 /* This is a hook for ia64_frob_label, so that it can distinguish tags from
7439 static int defining_tag
= 0;
7442 ia64_unrecognized_line (int ch
)
7447 expression_and_evaluate (&md
.qp
);
7448 if (*input_line_pointer
++ != ')')
7450 as_bad (_("Expected ')'"));
7453 if (md
.qp
.X_op
!= O_register
)
7455 as_bad (_("Qualifying predicate expected"));
7458 if (md
.qp
.X_add_number
< REG_P
|| md
.qp
.X_add_number
>= REG_P
+ 64)
7460 as_bad (_("Predicate register expected"));
7472 if (md
.qp
.X_op
== O_register
)
7474 as_bad (_("Tag must come before qualifying predicate."));
7478 /* This implements just enough of read_a_source_file in read.c to
7479 recognize labels. */
7480 if (is_name_beginner (*input_line_pointer
))
7482 s
= input_line_pointer
;
7483 c
= get_symbol_end ();
7485 else if (LOCAL_LABELS_FB
7486 && ISDIGIT (*input_line_pointer
))
7489 while (ISDIGIT (*input_line_pointer
))
7490 temp
= (temp
* 10) + *input_line_pointer
++ - '0';
7491 fb_label_instance_inc (temp
);
7492 s
= fb_label_name (temp
, 0);
7493 c
= *input_line_pointer
;
7502 /* Put ':' back for error messages' sake. */
7503 *input_line_pointer
++ = ':';
7504 as_bad (_("Expected ':'"));
7511 /* Put ':' back for error messages' sake. */
7512 *input_line_pointer
++ = ':';
7513 if (*input_line_pointer
++ != ']')
7515 as_bad (_("Expected ']'"));
7520 as_bad (_("Tag name expected"));
7530 /* Not a valid line. */
7535 ia64_frob_label (struct symbol
*sym
)
7537 struct label_fix
*fix
;
7539 /* Tags need special handling since they are not bundle breaks like
7543 fix
= obstack_alloc (¬es
, sizeof (*fix
));
7545 fix
->next
= CURR_SLOT
.tag_fixups
;
7546 fix
->dw2_mark_labels
= FALSE
;
7547 CURR_SLOT
.tag_fixups
= fix
;
7552 if (bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7554 md
.last_text_seg
= now_seg
;
7555 fix
= obstack_alloc (¬es
, sizeof (*fix
));
7557 fix
->next
= CURR_SLOT
.label_fixups
;
7558 fix
->dw2_mark_labels
= dwarf2_loc_mark_labels
;
7559 CURR_SLOT
.label_fixups
= fix
;
7561 /* Keep track of how many code entry points we've seen. */
7562 if (md
.path
== md
.maxpaths
)
7565 md
.entry_labels
= (const char **)
7566 xrealloc ((void *) md
.entry_labels
,
7567 md
.maxpaths
* sizeof (char *));
7569 md
.entry_labels
[md
.path
++] = S_GET_NAME (sym
);
7574 /* The HP-UX linker will give unresolved symbol errors for symbols
7575 that are declared but unused. This routine removes declared,
7576 unused symbols from an object. */
7578 ia64_frob_symbol (struct symbol
*sym
)
7580 if ((S_GET_SEGMENT (sym
) == &bfd_und_section
&& ! symbol_used_p (sym
) &&
7581 ELF_ST_VISIBILITY (S_GET_OTHER (sym
)) == STV_DEFAULT
)
7582 || (S_GET_SEGMENT (sym
) == &bfd_abs_section
7583 && ! S_IS_EXTERNAL (sym
)))
7590 ia64_flush_pending_output (void)
7592 if (!md
.keep_pending_output
7593 && bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7595 /* ??? This causes many unnecessary stop bits to be emitted.
7596 Unfortunately, it isn't clear if it is safe to remove this. */
7597 insn_group_break (1, 0, 0);
7598 ia64_flush_insns ();
7602 /* Do ia64-specific expression optimization. All that's done here is
7603 to transform index expressions that are either due to the indexing
7604 of rotating registers or due to the indexing of indirect register
7607 ia64_optimize_expr (expressionS
*l
, operatorT op
, expressionS
*r
)
7611 resolve_expression (l
);
7612 if (l
->X_op
== O_register
)
7614 unsigned num_regs
= l
->X_add_number
>> 16;
7616 resolve_expression (r
);
7619 /* Left side is a .rotX-allocated register. */
7620 if (r
->X_op
!= O_constant
)
7622 as_bad (_("Rotating register index must be a non-negative constant"));
7623 r
->X_add_number
= 0;
7625 else if ((valueT
) r
->X_add_number
>= num_regs
)
7627 as_bad (_("Index out of range 0..%u"), num_regs
- 1);
7628 r
->X_add_number
= 0;
7630 l
->X_add_number
= (l
->X_add_number
& 0xffff) + r
->X_add_number
;
7633 else if (l
->X_add_number
>= IND_CPUID
&& l
->X_add_number
<= IND_RR
)
7635 if (r
->X_op
!= O_register
7636 || r
->X_add_number
< REG_GR
7637 || r
->X_add_number
> REG_GR
+ 127)
7639 as_bad (_("Indirect register index must be a general register"));
7640 r
->X_add_number
= REG_GR
;
7643 l
->X_op_symbol
= md
.indregsym
[l
->X_add_number
- IND_CPUID
];
7644 l
->X_add_number
= r
->X_add_number
;
7648 as_bad (_("Index can only be applied to rotating or indirect registers"));
7649 /* Fall back to some register use of which has as little as possible
7650 side effects, to minimize subsequent error messages. */
7651 l
->X_op
= O_register
;
7652 l
->X_add_number
= REG_GR
+ 3;
7657 ia64_parse_name (char *name
, expressionS
*e
, char *nextcharP
)
7659 struct const_desc
*cdesc
;
7660 struct dynreg
*dr
= 0;
7667 enum pseudo_type pseudo_type
= PSEUDO_FUNC_NONE
;
7669 /* Find what relocation pseudo-function we're dealing with. */
7670 for (idx
= 0; idx
< NELEMS (pseudo_func
); ++idx
)
7671 if (pseudo_func
[idx
].name
7672 && pseudo_func
[idx
].name
[0] == name
[1]
7673 && strcmp (pseudo_func
[idx
].name
+ 1, name
+ 2) == 0)
7675 pseudo_type
= pseudo_func
[idx
].type
;
7678 switch (pseudo_type
)
7680 case PSEUDO_FUNC_RELOC
:
7681 end
= input_line_pointer
;
7682 if (*nextcharP
!= '(')
7684 as_bad (_("Expected '('"));
7688 ++input_line_pointer
;
7690 if (*input_line_pointer
!= ')')
7692 as_bad (_("Missing ')'"));
7696 ++input_line_pointer
;
7697 if (e
->X_op
!= O_symbol
)
7699 if (e
->X_op
!= O_pseudo_fixup
)
7701 as_bad (_("Not a symbolic expression"));
7704 if (idx
!= FUNC_LT_RELATIVE
)
7706 as_bad (_("Illegal combination of relocation functions"));
7709 switch (S_GET_VALUE (e
->X_op_symbol
))
7711 case FUNC_FPTR_RELATIVE
:
7712 idx
= FUNC_LT_FPTR_RELATIVE
; break;
7713 case FUNC_DTP_MODULE
:
7714 idx
= FUNC_LT_DTP_MODULE
; break;
7715 case FUNC_DTP_RELATIVE
:
7716 idx
= FUNC_LT_DTP_RELATIVE
; break;
7717 case FUNC_TP_RELATIVE
:
7718 idx
= FUNC_LT_TP_RELATIVE
; break;
7720 as_bad (_("Illegal combination of relocation functions"));
7724 /* Make sure gas doesn't get rid of local symbols that are used
7726 e
->X_op
= O_pseudo_fixup
;
7727 e
->X_op_symbol
= pseudo_func
[idx
].u
.sym
;
7729 *nextcharP
= *input_line_pointer
;
7732 case PSEUDO_FUNC_CONST
:
7733 e
->X_op
= O_constant
;
7734 e
->X_add_number
= pseudo_func
[idx
].u
.ival
;
7737 case PSEUDO_FUNC_REG
:
7738 e
->X_op
= O_register
;
7739 e
->X_add_number
= pseudo_func
[idx
].u
.ival
;
7748 /* first see if NAME is a known register name: */
7749 sym
= hash_find (md
.reg_hash
, name
);
7752 e
->X_op
= O_register
;
7753 e
->X_add_number
= S_GET_VALUE (sym
);
7757 cdesc
= hash_find (md
.const_hash
, name
);
7760 e
->X_op
= O_constant
;
7761 e
->X_add_number
= cdesc
->value
;
7765 /* check for inN, locN, or outN: */
7770 if (name
[1] == 'n' && ISDIGIT (name
[2]))
7778 if (name
[1] == 'o' && name
[2] == 'c' && ISDIGIT (name
[3]))
7786 if (name
[1] == 'u' && name
[2] == 't' && ISDIGIT (name
[3]))
7797 /* Ignore register numbers with leading zeroes, except zero itself. */
7798 if (dr
&& (name
[idx
] != '0' || name
[idx
+ 1] == '\0'))
7800 unsigned long regnum
;
7802 /* The name is inN, locN, or outN; parse the register number. */
7803 regnum
= strtoul (name
+ idx
, &end
, 10);
7804 if (end
> name
+ idx
&& *end
== '\0' && regnum
< 96)
7806 if (regnum
>= dr
->num_regs
)
7809 as_bad (_("No current frame"));
7811 as_bad (_("Register number out of range 0..%u"),
7815 e
->X_op
= O_register
;
7816 e
->X_add_number
= dr
->base
+ regnum
;
7821 end
= alloca (strlen (name
) + 1);
7823 name
= ia64_canonicalize_symbol_name (end
);
7824 if ((dr
= hash_find (md
.dynreg_hash
, name
)))
7826 /* We've got ourselves the name of a rotating register set.
7827 Store the base register number in the low 16 bits of
7828 X_add_number and the size of the register set in the top 16
7830 e
->X_op
= O_register
;
7831 e
->X_add_number
= dr
->base
| (dr
->num_regs
<< 16);
7837 /* Remove the '#' suffix that indicates a symbol as opposed to a register. */
7840 ia64_canonicalize_symbol_name (char *name
)
7842 size_t len
= strlen (name
), full
= len
;
7844 while (len
> 0 && name
[len
- 1] == '#')
7849 as_bad (_("Standalone `#' is illegal"));
7851 else if (len
< full
- 1)
7852 as_warn (_("Redundant `#' suffix operators"));
7857 /* Return true if idesc is a conditional branch instruction. This excludes
7858 the modulo scheduled branches, and br.ia. Mod-sched branches are excluded
7859 because they always read/write resources regardless of the value of the
7860 qualifying predicate. br.ia must always use p0, and hence is always
7861 taken. Thus this function returns true for branches which can fall
7862 through, and which use no resources if they do fall through. */
7865 is_conditional_branch (struct ia64_opcode
*idesc
)
7867 /* br is a conditional branch. Everything that starts with br. except
7868 br.ia, br.c{loop,top,exit}, and br.w{top,exit} is a conditional branch.
7869 Everything that starts with brl is a conditional branch. */
7870 return (idesc
->name
[0] == 'b' && idesc
->name
[1] == 'r'
7871 && (idesc
->name
[2] == '\0'
7872 || (idesc
->name
[2] == '.' && idesc
->name
[3] != 'i'
7873 && idesc
->name
[3] != 'c' && idesc
->name
[3] != 'w')
7874 || idesc
->name
[2] == 'l'
7875 /* br.cond, br.call, br.clr */
7876 || (idesc
->name
[2] == '.' && idesc
->name
[3] == 'c'
7877 && (idesc
->name
[4] == 'a' || idesc
->name
[4] == 'o'
7878 || (idesc
->name
[4] == 'l' && idesc
->name
[5] == 'r')))));
7881 /* Return whether the given opcode is a taken branch. If there's any doubt,
7885 is_taken_branch (struct ia64_opcode
*idesc
)
7887 return ((is_conditional_branch (idesc
) && CURR_SLOT
.qp_regno
== 0)
7888 || strncmp (idesc
->name
, "br.ia", 5) == 0);
7891 /* Return whether the given opcode is an interruption or rfi. If there's any
7892 doubt, returns zero. */
7895 is_interruption_or_rfi (struct ia64_opcode
*idesc
)
7897 if (strcmp (idesc
->name
, "rfi") == 0)
7902 /* Returns the index of the given dependency in the opcode's list of chks, or
7903 -1 if there is no dependency. */
7906 depends_on (int depind
, struct ia64_opcode
*idesc
)
7909 const struct ia64_opcode_dependency
*dep
= idesc
->dependencies
;
7910 for (i
= 0; i
< dep
->nchks
; i
++)
7912 if (depind
== DEP (dep
->chks
[i
]))
7918 /* Determine a set of specific resources used for a particular resource
7919 class. Returns the number of specific resources identified For those
7920 cases which are not determinable statically, the resource returned is
7923 Meanings of value in 'NOTE':
7924 1) only read/write when the register number is explicitly encoded in the
7926 2) only read CFM when accessing a rotating GR, FR, or PR. mov pr only
7927 accesses CFM when qualifying predicate is in the rotating region.
7928 3) general register value is used to specify an indirect register; not
7929 determinable statically.
7930 4) only read the given resource when bits 7:0 of the indirect index
7931 register value does not match the register number of the resource; not
7932 determinable statically.
7933 5) all rules are implementation specific.
7934 6) only when both the index specified by the reader and the index specified
7935 by the writer have the same value in bits 63:61; not determinable
7937 7) only access the specified resource when the corresponding mask bit is
7939 8) PSR.dfh is only read when these insns reference FR32-127. PSR.dfl is
7940 only read when these insns reference FR2-31
7941 9) PSR.mfl is only written when these insns write FR2-31. PSR.mfh is only
7942 written when these insns write FR32-127
7943 10) The PSR.bn bit is only accessed when one of GR16-31 is specified in the
7945 11) The target predicates are written independently of PR[qp], but source
7946 registers are only read if PR[qp] is true. Since the state of PR[qp]
7947 cannot statically be determined, all source registers are marked used.
7948 12) This insn only reads the specified predicate register when that
7949 register is the PR[qp].
7950 13) This reference to ld-c only applies to the GR whose value is loaded
7951 with data returned from memory, not the post-incremented address register.
7952 14) The RSE resource includes the implementation-specific RSE internal
7953 state resources. At least one (and possibly more) of these resources are
7954 read by each instruction listed in IC:rse-readers. At least one (and
7955 possibly more) of these resources are written by each insn listed in
7957 15+16) Represents reserved instructions, which the assembler does not
7959 17) CR[TPR] has a RAW dependency only between mov-to-CR-TPR and
7960 mov-to-PSR-l or ssm instructions that set PSR.i, PSR.pp or PSR.up.
7962 Memory resources (i.e. locations in memory) are *not* marked or tracked by
7963 this code; there are no dependency violations based on memory access.
7966 #define MAX_SPECS 256
7971 specify_resource (const struct ia64_dependency
*dep
,
7972 struct ia64_opcode
*idesc
,
7973 /* is this a DV chk or a DV reg? */
7975 /* returned specific resources */
7976 struct rsrc specs
[MAX_SPECS
],
7977 /* resource note for this insn's usage */
7979 /* which execution path to examine */
7987 if (dep
->mode
== IA64_DV_WAW
7988 || (dep
->mode
== IA64_DV_RAW
&& type
== DV_REG
)
7989 || (dep
->mode
== IA64_DV_WAR
&& type
== DV_CHK
))
7992 /* template for any resources we identify */
7993 tmpl
.dependency
= dep
;
7995 tmpl
.insn_srlz
= tmpl
.data_srlz
= 0;
7996 tmpl
.qp_regno
= CURR_SLOT
.qp_regno
;
7997 tmpl
.link_to_qp_branch
= 1;
7998 tmpl
.mem_offset
.hint
= 0;
7999 tmpl
.mem_offset
.offset
= 0;
8000 tmpl
.mem_offset
.base
= 0;
8003 tmpl
.cmp_type
= CMP_NONE
;
8010 as_warn (_("Unhandled dependency %s for %s (%s), note %d"), \
8011 dep->name, idesc->name, (rsrc_write?"write":"read"), note)
8012 #define KNOWN(REG) (gr_values[REG].known && gr_values[REG].path >= path)
8014 /* we don't need to track these */
8015 if (dep
->semantics
== IA64_DVS_NONE
)
8018 switch (dep
->specifier
)
8023 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8025 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8026 if (regno
>= 0 && regno
<= 7)
8028 specs
[count
] = tmpl
;
8029 specs
[count
++].index
= regno
;
8035 for (i
= 0; i
< 8; i
++)
8037 specs
[count
] = tmpl
;
8038 specs
[count
++].index
= i
;
8047 case IA64_RS_AR_UNAT
:
8048 /* This is a mov =AR or mov AR= instruction. */
8049 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8051 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8052 if (regno
== AR_UNAT
)
8054 specs
[count
++] = tmpl
;
8059 /* This is a spill/fill, or other instruction that modifies the
8062 /* Unless we can determine the specific bits used, mark the whole
8063 thing; bits 8:3 of the memory address indicate the bit used in
8064 UNAT. The .mem.offset hint may be used to eliminate a small
8065 subset of conflicts. */
8066 specs
[count
] = tmpl
;
8067 if (md
.mem_offset
.hint
)
8070 fprintf (stderr
, " Using hint for spill/fill\n");
8071 /* The index isn't actually used, just set it to something
8072 approximating the bit index. */
8073 specs
[count
].index
= (md
.mem_offset
.offset
>> 3) & 0x3F;
8074 specs
[count
].mem_offset
.hint
= 1;
8075 specs
[count
].mem_offset
.offset
= md
.mem_offset
.offset
;
8076 specs
[count
++].mem_offset
.base
= md
.mem_offset
.base
;
8080 specs
[count
++].specific
= 0;
8088 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8090 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8091 if ((regno
>= 8 && regno
<= 15)
8092 || (regno
>= 20 && regno
<= 23)
8093 || (regno
>= 31 && regno
<= 39)
8094 || (regno
>= 41 && regno
<= 47)
8095 || (regno
>= 67 && regno
<= 111))
8097 specs
[count
] = tmpl
;
8098 specs
[count
++].index
= regno
;
8111 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8113 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8114 if ((regno
>= 48 && regno
<= 63)
8115 || (regno
>= 112 && regno
<= 127))
8117 specs
[count
] = tmpl
;
8118 specs
[count
++].index
= regno
;
8124 for (i
= 48; i
< 64; i
++)
8126 specs
[count
] = tmpl
;
8127 specs
[count
++].index
= i
;
8129 for (i
= 112; i
< 128; i
++)
8131 specs
[count
] = tmpl
;
8132 specs
[count
++].index
= i
;
8150 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8151 if (idesc
->operands
[i
] == IA64_OPND_B1
8152 || idesc
->operands
[i
] == IA64_OPND_B2
)
8154 specs
[count
] = tmpl
;
8155 specs
[count
++].index
=
8156 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
8161 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
8162 if (idesc
->operands
[i
] == IA64_OPND_B1
8163 || idesc
->operands
[i
] == IA64_OPND_B2
)
8165 specs
[count
] = tmpl
;
8166 specs
[count
++].index
=
8167 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
8173 case IA64_RS_CPUID
: /* four or more registers */
8176 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CPUID_R3
)
8178 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8179 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8182 specs
[count
] = tmpl
;
8183 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8187 specs
[count
] = tmpl
;
8188 specs
[count
++].specific
= 0;
8198 case IA64_RS_DBR
: /* four or more registers */
8201 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_DBR_R3
)
8203 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8204 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8207 specs
[count
] = tmpl
;
8208 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8212 specs
[count
] = tmpl
;
8213 specs
[count
++].specific
= 0;
8217 else if (note
== 0 && !rsrc_write
)
8219 specs
[count
] = tmpl
;
8220 specs
[count
++].specific
= 0;
8228 case IA64_RS_IBR
: /* four or more registers */
8231 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_IBR_R3
)
8233 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8234 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8237 specs
[count
] = tmpl
;
8238 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8242 specs
[count
] = tmpl
;
8243 specs
[count
++].specific
= 0;
8256 /* These are implementation specific. Force all references to
8257 conflict with all other references. */
8258 specs
[count
] = tmpl
;
8259 specs
[count
++].specific
= 0;
8267 case IA64_RS_PKR
: /* 16 or more registers */
8268 if (note
== 3 || note
== 4)
8270 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PKR_R3
)
8272 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8273 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8278 specs
[count
] = tmpl
;
8279 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8282 for (i
= 0; i
< NELEMS (gr_values
); i
++)
8284 /* Uses all registers *except* the one in R3. */
8285 if ((unsigned)i
!= (gr_values
[regno
].value
& 0xFF))
8287 specs
[count
] = tmpl
;
8288 specs
[count
++].index
= i
;
8294 specs
[count
] = tmpl
;
8295 specs
[count
++].specific
= 0;
8302 specs
[count
] = tmpl
;
8303 specs
[count
++].specific
= 0;
8307 case IA64_RS_PMC
: /* four or more registers */
8310 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMC_R3
8311 || (!rsrc_write
&& idesc
->operands
[1] == IA64_OPND_PMD_R3
))
8314 int index
= ((idesc
->operands
[1] == IA64_OPND_R3
&& !rsrc_write
)
8316 int regno
= CURR_SLOT
.opnd
[index
].X_add_number
- REG_GR
;
8317 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8320 specs
[count
] = tmpl
;
8321 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8325 specs
[count
] = tmpl
;
8326 specs
[count
++].specific
= 0;
8336 case IA64_RS_PMD
: /* four or more registers */
8339 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMD_R3
)
8341 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8342 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8345 specs
[count
] = tmpl
;
8346 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8350 specs
[count
] = tmpl
;
8351 specs
[count
++].specific
= 0;
8361 case IA64_RS_RR
: /* eight registers */
8364 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_RR_R3
)
8366 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8367 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8370 specs
[count
] = tmpl
;
8371 specs
[count
++].index
= (gr_values
[regno
].value
>> 61) & 0x7;
8375 specs
[count
] = tmpl
;
8376 specs
[count
++].specific
= 0;
8380 else if (note
== 0 && !rsrc_write
)
8382 specs
[count
] = tmpl
;
8383 specs
[count
++].specific
= 0;
8391 case IA64_RS_CR_IRR
:
8394 /* handle mov-from-CR-IVR; it's a read that writes CR[IRR] */
8395 int regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
;
8397 && idesc
->operands
[1] == IA64_OPND_CR3
8400 for (i
= 0; i
< 4; i
++)
8402 specs
[count
] = tmpl
;
8403 specs
[count
++].index
= CR_IRR0
+ i
;
8409 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8410 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
8412 && regno
<= CR_IRR3
)
8414 specs
[count
] = tmpl
;
8415 specs
[count
++].index
= regno
;
8424 case IA64_RS_CR_IIB
:
8431 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8432 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
8433 && (regno
== CR_IIB0
|| regno
== CR_IIB1
))
8435 specs
[count
] = tmpl
;
8436 specs
[count
++].index
= regno
;
8441 case IA64_RS_CR_LRR
:
8448 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8449 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
8450 && (regno
== CR_LRR0
|| regno
== CR_LRR1
))
8452 specs
[count
] = tmpl
;
8453 specs
[count
++].index
= regno
;
8461 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
8463 specs
[count
] = tmpl
;
8464 specs
[count
++].index
=
8465 CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8480 else if (rsrc_write
)
8482 if (dep
->specifier
== IA64_RS_FRb
8483 && idesc
->operands
[0] == IA64_OPND_F1
)
8485 specs
[count
] = tmpl
;
8486 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_FR
;
8491 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
8493 if (idesc
->operands
[i
] == IA64_OPND_F2
8494 || idesc
->operands
[i
] == IA64_OPND_F3
8495 || idesc
->operands
[i
] == IA64_OPND_F4
)
8497 specs
[count
] = tmpl
;
8498 specs
[count
++].index
=
8499 CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8508 /* This reference applies only to the GR whose value is loaded with
8509 data returned from memory. */
8510 specs
[count
] = tmpl
;
8511 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
8517 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8518 if (idesc
->operands
[i
] == IA64_OPND_R1
8519 || idesc
->operands
[i
] == IA64_OPND_R2
8520 || idesc
->operands
[i
] == IA64_OPND_R3
)
8522 specs
[count
] = tmpl
;
8523 specs
[count
++].index
=
8524 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8526 if (idesc
->flags
& IA64_OPCODE_POSTINC
)
8527 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8528 if (idesc
->operands
[i
] == IA64_OPND_MR3
)
8530 specs
[count
] = tmpl
;
8531 specs
[count
++].index
=
8532 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8537 /* Look for anything that reads a GR. */
8538 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8540 if (idesc
->operands
[i
] == IA64_OPND_MR3
8541 || idesc
->operands
[i
] == IA64_OPND_CPUID_R3
8542 || idesc
->operands
[i
] == IA64_OPND_DBR_R3
8543 || idesc
->operands
[i
] == IA64_OPND_IBR_R3
8544 || idesc
->operands
[i
] == IA64_OPND_MSR_R3
8545 || idesc
->operands
[i
] == IA64_OPND_PKR_R3
8546 || idesc
->operands
[i
] == IA64_OPND_PMC_R3
8547 || idesc
->operands
[i
] == IA64_OPND_PMD_R3
8548 || idesc
->operands
[i
] == IA64_OPND_RR_R3
8549 || ((i
>= idesc
->num_outputs
)
8550 && (idesc
->operands
[i
] == IA64_OPND_R1
8551 || idesc
->operands
[i
] == IA64_OPND_R2
8552 || idesc
->operands
[i
] == IA64_OPND_R3
8553 /* addl source register. */
8554 || idesc
->operands
[i
] == IA64_OPND_R3_2
)))
8556 specs
[count
] = tmpl
;
8557 specs
[count
++].index
=
8558 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8569 /* This is the same as IA64_RS_PRr, except that the register range is
8570 from 1 - 15, and there are no rotating register reads/writes here. */
8574 for (i
= 1; i
< 16; i
++)
8576 specs
[count
] = tmpl
;
8577 specs
[count
++].index
= i
;
8583 /* Mark only those registers indicated by the mask. */
8586 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8587 for (i
= 1; i
< 16; i
++)
8588 if (mask
& ((valueT
) 1 << i
))
8590 specs
[count
] = tmpl
;
8591 specs
[count
++].index
= i
;
8599 else if (note
== 11) /* note 11 implies note 1 as well */
8603 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8605 if (idesc
->operands
[i
] == IA64_OPND_P1
8606 || idesc
->operands
[i
] == IA64_OPND_P2
)
8608 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8609 if (regno
>= 1 && regno
< 16)
8611 specs
[count
] = tmpl
;
8612 specs
[count
++].index
= regno
;
8622 else if (note
== 12)
8624 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
8626 specs
[count
] = tmpl
;
8627 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8634 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8635 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8636 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8637 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8639 if ((idesc
->operands
[0] == IA64_OPND_P1
8640 || idesc
->operands
[0] == IA64_OPND_P2
)
8641 && p1
>= 1 && p1
< 16)
8643 specs
[count
] = tmpl
;
8644 specs
[count
].cmp_type
=
8645 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8646 specs
[count
++].index
= p1
;
8648 if ((idesc
->operands
[1] == IA64_OPND_P1
8649 || idesc
->operands
[1] == IA64_OPND_P2
)
8650 && p2
>= 1 && p2
< 16)
8652 specs
[count
] = tmpl
;
8653 specs
[count
].cmp_type
=
8654 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8655 specs
[count
++].index
= p2
;
8660 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
8662 specs
[count
] = tmpl
;
8663 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8665 if (idesc
->operands
[1] == IA64_OPND_PR
)
8667 for (i
= 1; i
< 16; i
++)
8669 specs
[count
] = tmpl
;
8670 specs
[count
++].index
= i
;
8681 /* This is the general case for PRs. IA64_RS_PR and IA64_RS_PR63 are
8682 simplified cases of this. */
8686 for (i
= 16; i
< 63; i
++)
8688 specs
[count
] = tmpl
;
8689 specs
[count
++].index
= i
;
8695 /* Mark only those registers indicated by the mask. */
8697 && idesc
->operands
[0] == IA64_OPND_PR
)
8699 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8700 if (mask
& ((valueT
) 1 << 16))
8701 for (i
= 16; i
< 63; i
++)
8703 specs
[count
] = tmpl
;
8704 specs
[count
++].index
= i
;
8708 && idesc
->operands
[0] == IA64_OPND_PR_ROT
)
8710 for (i
= 16; i
< 63; i
++)
8712 specs
[count
] = tmpl
;
8713 specs
[count
++].index
= i
;
8721 else if (note
== 11) /* note 11 implies note 1 as well */
8725 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8727 if (idesc
->operands
[i
] == IA64_OPND_P1
8728 || idesc
->operands
[i
] == IA64_OPND_P2
)
8730 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8731 if (regno
>= 16 && regno
< 63)
8733 specs
[count
] = tmpl
;
8734 specs
[count
++].index
= regno
;
8744 else if (note
== 12)
8746 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8748 specs
[count
] = tmpl
;
8749 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8756 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8757 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8758 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8759 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8761 if ((idesc
->operands
[0] == IA64_OPND_P1
8762 || idesc
->operands
[0] == IA64_OPND_P2
)
8763 && p1
>= 16 && p1
< 63)
8765 specs
[count
] = tmpl
;
8766 specs
[count
].cmp_type
=
8767 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8768 specs
[count
++].index
= p1
;
8770 if ((idesc
->operands
[1] == IA64_OPND_P1
8771 || idesc
->operands
[1] == IA64_OPND_P2
)
8772 && p2
>= 16 && p2
< 63)
8774 specs
[count
] = tmpl
;
8775 specs
[count
].cmp_type
=
8776 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8777 specs
[count
++].index
= p2
;
8782 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8784 specs
[count
] = tmpl
;
8785 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8787 if (idesc
->operands
[1] == IA64_OPND_PR
)
8789 for (i
= 16; i
< 63; i
++)
8791 specs
[count
] = tmpl
;
8792 specs
[count
++].index
= i
;
8804 /* Verify that the instruction is using the PSR bit indicated in
8808 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_UM
)
8810 if (dep
->regindex
< 6)
8812 specs
[count
++] = tmpl
;
8815 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR
)
8817 if (dep
->regindex
< 32
8818 || dep
->regindex
== 35
8819 || dep
->regindex
== 36
8820 || (!rsrc_write
&& dep
->regindex
== PSR_CPL
))
8822 specs
[count
++] = tmpl
;
8825 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_L
)
8827 if (dep
->regindex
< 32
8828 || dep
->regindex
== 35
8829 || dep
->regindex
== 36
8830 || (rsrc_write
&& dep
->regindex
== PSR_CPL
))
8832 specs
[count
++] = tmpl
;
8837 /* Several PSR bits have very specific dependencies. */
8838 switch (dep
->regindex
)
8841 specs
[count
++] = tmpl
;
8846 specs
[count
++] = tmpl
;
8850 /* Only certain CR accesses use PSR.ic */
8851 if (idesc
->operands
[0] == IA64_OPND_CR3
8852 || idesc
->operands
[1] == IA64_OPND_CR3
)
8855 ((idesc
->operands
[0] == IA64_OPND_CR3
)
8858 CURR_SLOT
.opnd
[index
].X_add_number
- REG_CR
;
8875 specs
[count
++] = tmpl
;
8884 specs
[count
++] = tmpl
;
8888 /* Only some AR accesses use cpl */
8889 if (idesc
->operands
[0] == IA64_OPND_AR3
8890 || idesc
->operands
[1] == IA64_OPND_AR3
)
8893 ((idesc
->operands
[0] == IA64_OPND_AR3
)
8896 CURR_SLOT
.opnd
[index
].X_add_number
- REG_AR
;
8903 && regno
<= AR_K7
))))
8905 specs
[count
++] = tmpl
;
8910 specs
[count
++] = tmpl
;
8920 if (idesc
->operands
[0] == IA64_OPND_IMMU24
)
8922 mask
= CURR_SLOT
.opnd
[0].X_add_number
;
8928 if (mask
& ((valueT
) 1 << dep
->regindex
))
8930 specs
[count
++] = tmpl
;
8935 int min
= dep
->regindex
== PSR_DFL
? 2 : 32;
8936 int max
= dep
->regindex
== PSR_DFL
? 31 : 127;
8937 /* dfh is read on FR32-127; dfl is read on FR2-31 */
8938 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8940 if (idesc
->operands
[i
] == IA64_OPND_F1
8941 || idesc
->operands
[i
] == IA64_OPND_F2
8942 || idesc
->operands
[i
] == IA64_OPND_F3
8943 || idesc
->operands
[i
] == IA64_OPND_F4
)
8945 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8946 if (reg
>= min
&& reg
<= max
)
8948 specs
[count
++] = tmpl
;
8955 int min
= dep
->regindex
== PSR_MFL
? 2 : 32;
8956 int max
= dep
->regindex
== PSR_MFL
? 31 : 127;
8957 /* mfh is read on writes to FR32-127; mfl is read on writes to
8959 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8961 if (idesc
->operands
[i
] == IA64_OPND_F1
)
8963 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8964 if (reg
>= min
&& reg
<= max
)
8966 specs
[count
++] = tmpl
;
8971 else if (note
== 10)
8973 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8975 if (idesc
->operands
[i
] == IA64_OPND_R1
8976 || idesc
->operands
[i
] == IA64_OPND_R2
8977 || idesc
->operands
[i
] == IA64_OPND_R3
)
8979 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8980 if (regno
>= 16 && regno
<= 31)
8982 specs
[count
++] = tmpl
;
8993 case IA64_RS_AR_FPSR
:
8994 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8996 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8997 if (regno
== AR_FPSR
)
8999 specs
[count
++] = tmpl
;
9004 specs
[count
++] = tmpl
;
9009 /* Handle all AR[REG] resources */
9010 if (note
== 0 || note
== 1)
9012 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
9013 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
9014 && regno
== dep
->regindex
)
9016 specs
[count
++] = tmpl
;
9018 /* other AR[REG] resources may be affected by AR accesses */
9019 else if (idesc
->operands
[0] == IA64_OPND_AR3
)
9022 regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
;
9023 switch (dep
->regindex
)
9029 if (regno
== AR_BSPSTORE
)
9031 specs
[count
++] = tmpl
;
9035 (regno
== AR_BSPSTORE
9036 || regno
== AR_RNAT
))
9038 specs
[count
++] = tmpl
;
9043 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
9046 regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
;
9047 switch (dep
->regindex
)
9052 if (regno
== AR_BSPSTORE
|| regno
== AR_RNAT
)
9054 specs
[count
++] = tmpl
;
9061 specs
[count
++] = tmpl
;
9071 /* Handle all CR[REG] resources.
9072 ??? FIXME: The rule 17 isn't really handled correctly. */
9073 if (note
== 0 || note
== 1 || note
== 17)
9075 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
9077 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
9078 if (regno
== dep
->regindex
)
9080 specs
[count
++] = tmpl
;
9082 else if (!rsrc_write
)
9084 /* Reads from CR[IVR] affect other resources. */
9085 if (regno
== CR_IVR
)
9087 if ((dep
->regindex
>= CR_IRR0
9088 && dep
->regindex
<= CR_IRR3
)
9089 || dep
->regindex
== CR_TPR
)
9091 specs
[count
++] = tmpl
;
9098 specs
[count
++] = tmpl
;
9107 case IA64_RS_INSERVICE
:
9108 /* look for write of EOI (67) or read of IVR (65) */
9109 if ((idesc
->operands
[0] == IA64_OPND_CR3
9110 && CURR_SLOT
.opnd
[0].X_add_number
- REG_CR
== CR_EOI
)
9111 || (idesc
->operands
[1] == IA64_OPND_CR3
9112 && CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
== CR_IVR
))
9114 specs
[count
++] = tmpl
;
9121 specs
[count
++] = tmpl
;
9132 specs
[count
++] = tmpl
;
9136 /* Check if any of the registers accessed are in the rotating region.
9137 mov to/from pr accesses CFM only when qp_regno is in the rotating
9139 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
9141 if (idesc
->operands
[i
] == IA64_OPND_R1
9142 || idesc
->operands
[i
] == IA64_OPND_R2
9143 || idesc
->operands
[i
] == IA64_OPND_R3
)
9145 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9146 /* Assumes that md.rot.num_regs is always valid */
9147 if (md
.rot
.num_regs
> 0
9149 && num
< 31 + md
.rot
.num_regs
)
9151 specs
[count
] = tmpl
;
9152 specs
[count
++].specific
= 0;
9155 else if (idesc
->operands
[i
] == IA64_OPND_F1
9156 || idesc
->operands
[i
] == IA64_OPND_F2
9157 || idesc
->operands
[i
] == IA64_OPND_F3
9158 || idesc
->operands
[i
] == IA64_OPND_F4
)
9160 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
9163 specs
[count
] = tmpl
;
9164 specs
[count
++].specific
= 0;
9167 else if (idesc
->operands
[i
] == IA64_OPND_P1
9168 || idesc
->operands
[i
] == IA64_OPND_P2
)
9170 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
9173 specs
[count
] = tmpl
;
9174 specs
[count
++].specific
= 0;
9178 if (CURR_SLOT
.qp_regno
> 15)
9180 specs
[count
] = tmpl
;
9181 specs
[count
++].specific
= 0;
9186 /* This is the same as IA64_RS_PRr, except simplified to account for
9187 the fact that there is only one register. */
9191 specs
[count
++] = tmpl
;
9196 if (idesc
->operands
[2] == IA64_OPND_IMM17
)
9197 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
9198 if (mask
& ((valueT
) 1 << 63))
9199 specs
[count
++] = tmpl
;
9201 else if (note
== 11)
9203 if ((idesc
->operands
[0] == IA64_OPND_P1
9204 && CURR_SLOT
.opnd
[0].X_add_number
- REG_P
== 63)
9205 || (idesc
->operands
[1] == IA64_OPND_P2
9206 && CURR_SLOT
.opnd
[1].X_add_number
- REG_P
== 63))
9208 specs
[count
++] = tmpl
;
9211 else if (note
== 12)
9213 if (CURR_SLOT
.qp_regno
== 63)
9215 specs
[count
++] = tmpl
;
9222 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
9223 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
9224 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
9225 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
9228 && (idesc
->operands
[0] == IA64_OPND_P1
9229 || idesc
->operands
[0] == IA64_OPND_P2
))
9231 specs
[count
] = tmpl
;
9232 specs
[count
++].cmp_type
=
9233 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
9236 && (idesc
->operands
[1] == IA64_OPND_P1
9237 || idesc
->operands
[1] == IA64_OPND_P2
))
9239 specs
[count
] = tmpl
;
9240 specs
[count
++].cmp_type
=
9241 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
9246 if (CURR_SLOT
.qp_regno
== 63)
9248 specs
[count
++] = tmpl
;
9259 /* FIXME we can identify some individual RSE written resources, but RSE
9260 read resources have not yet been completely identified, so for now
9261 treat RSE as a single resource */
9262 if (strncmp (idesc
->name
, "mov", 3) == 0)
9266 if (idesc
->operands
[0] == IA64_OPND_AR3
9267 && CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
)
9269 specs
[count
++] = tmpl
;
9274 if (idesc
->operands
[0] == IA64_OPND_AR3
)
9276 if (CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
9277 || CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_RNAT
)
9279 specs
[count
++] = tmpl
;
9282 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
9284 if (CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSP
9285 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSPSTORE
9286 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_RNAT
)
9288 specs
[count
++] = tmpl
;
9295 specs
[count
++] = tmpl
;
9300 /* FIXME -- do any of these need to be non-specific? */
9301 specs
[count
++] = tmpl
;
9305 as_bad (_("Unrecognized dependency specifier %d\n"), dep
->specifier
);
9312 /* Clear branch flags on marked resources. This breaks the link between the
9313 QP of the marking instruction and a subsequent branch on the same QP. */
9316 clear_qp_branch_flag (valueT mask
)
9319 for (i
= 0; i
< regdepslen
; i
++)
9321 valueT bit
= ((valueT
) 1 << regdeps
[i
].qp_regno
);
9322 if ((bit
& mask
) != 0)
9324 regdeps
[i
].link_to_qp_branch
= 0;
9329 /* MASK contains 2 and only 2 PRs which are mutually exclusive. Remove
9330 any mutexes which contain one of the PRs and create new ones when
9334 update_qp_mutex (valueT mask
)
9340 while (i
< qp_mutexeslen
)
9342 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
9344 /* If it destroys and creates the same mutex, do nothing. */
9345 if (qp_mutexes
[i
].prmask
== mask
9346 && qp_mutexes
[i
].path
== md
.path
)
9357 fprintf (stderr
, " Clearing mutex relation");
9358 print_prmask (qp_mutexes
[i
].prmask
);
9359 fprintf (stderr
, "\n");
9362 /* Deal with the old mutex with more than 3+ PRs only if
9363 the new mutex on the same execution path with it.
9365 FIXME: The 3+ mutex support is incomplete.
9366 dot_pred_rel () may be a better place to fix it. */
9367 if (qp_mutexes
[i
].path
== md
.path
)
9369 /* If it is a proper subset of the mutex, create a
9372 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
9375 qp_mutexes
[i
].prmask
&= ~mask
;
9376 if (qp_mutexes
[i
].prmask
& (qp_mutexes
[i
].prmask
- 1))
9378 /* Modify the mutex if there are more than one
9386 /* Remove the mutex. */
9387 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
9395 add_qp_mutex (mask
);
9400 /* Remove any mutexes which contain any of the PRs indicated in the mask.
9402 Any changes to a PR clears the mutex relations which include that PR. */
9405 clear_qp_mutex (valueT mask
)
9410 while (i
< qp_mutexeslen
)
9412 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
9416 fprintf (stderr
, " Clearing mutex relation");
9417 print_prmask (qp_mutexes
[i
].prmask
);
9418 fprintf (stderr
, "\n");
9420 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
9427 /* Clear implies relations which contain PRs in the given masks.
9428 P1_MASK indicates the source of the implies relation, while P2_MASK
9429 indicates the implied PR. */
9432 clear_qp_implies (valueT p1_mask
, valueT p2_mask
)
9437 while (i
< qp_implieslen
)
9439 if ((((valueT
) 1 << qp_implies
[i
].p1
) & p1_mask
) != 0
9440 || (((valueT
) 1 << qp_implies
[i
].p2
) & p2_mask
) != 0)
9443 fprintf (stderr
, "Clearing implied relation PR%d->PR%d\n",
9444 qp_implies
[i
].p1
, qp_implies
[i
].p2
);
9445 qp_implies
[i
] = qp_implies
[--qp_implieslen
];
9452 /* Add the PRs specified to the list of implied relations. */
9455 add_qp_imply (int p1
, int p2
)
9461 /* p0 is not meaningful here. */
9462 if (p1
== 0 || p2
== 0)
9468 /* If it exists already, ignore it. */
9469 for (i
= 0; i
< qp_implieslen
; i
++)
9471 if (qp_implies
[i
].p1
== p1
9472 && qp_implies
[i
].p2
== p2
9473 && qp_implies
[i
].path
== md
.path
9474 && !qp_implies
[i
].p2_branched
)
9478 if (qp_implieslen
== qp_impliestotlen
)
9480 qp_impliestotlen
+= 20;
9481 qp_implies
= (struct qp_imply
*)
9482 xrealloc ((void *) qp_implies
,
9483 qp_impliestotlen
* sizeof (struct qp_imply
));
9486 fprintf (stderr
, " Registering PR%d implies PR%d\n", p1
, p2
);
9487 qp_implies
[qp_implieslen
].p1
= p1
;
9488 qp_implies
[qp_implieslen
].p2
= p2
;
9489 qp_implies
[qp_implieslen
].path
= md
.path
;
9490 qp_implies
[qp_implieslen
++].p2_branched
= 0;
9492 /* Add in the implied transitive relations; for everything that p2 implies,
9493 make p1 imply that, too; for everything that implies p1, make it imply p2
9495 for (i
= 0; i
< qp_implieslen
; i
++)
9497 if (qp_implies
[i
].p1
== p2
)
9498 add_qp_imply (p1
, qp_implies
[i
].p2
);
9499 if (qp_implies
[i
].p2
== p1
)
9500 add_qp_imply (qp_implies
[i
].p1
, p2
);
9502 /* Add in mutex relations implied by this implies relation; for each mutex
9503 relation containing p2, duplicate it and replace p2 with p1. */
9504 bit
= (valueT
) 1 << p1
;
9505 mask
= (valueT
) 1 << p2
;
9506 for (i
= 0; i
< qp_mutexeslen
; i
++)
9508 if (qp_mutexes
[i
].prmask
& mask
)
9509 add_qp_mutex ((qp_mutexes
[i
].prmask
& ~mask
) | bit
);
9513 /* Add the PRs specified in the mask to the mutex list; this means that only
9514 one of the PRs can be true at any time. PR0 should never be included in
9518 add_qp_mutex (valueT mask
)
9523 if (qp_mutexeslen
== qp_mutexestotlen
)
9525 qp_mutexestotlen
+= 20;
9526 qp_mutexes
= (struct qpmutex
*)
9527 xrealloc ((void *) qp_mutexes
,
9528 qp_mutexestotlen
* sizeof (struct qpmutex
));
9532 fprintf (stderr
, " Registering mutex on");
9533 print_prmask (mask
);
9534 fprintf (stderr
, "\n");
9536 qp_mutexes
[qp_mutexeslen
].path
= md
.path
;
9537 qp_mutexes
[qp_mutexeslen
++].prmask
= mask
;
9541 has_suffix_p (const char *name
, const char *suffix
)
9543 size_t namelen
= strlen (name
);
9544 size_t sufflen
= strlen (suffix
);
9546 if (namelen
<= sufflen
)
9548 return strcmp (name
+ namelen
- sufflen
, suffix
) == 0;
9552 clear_register_values (void)
9556 fprintf (stderr
, " Clearing register values\n");
9557 for (i
= 1; i
< NELEMS (gr_values
); i
++)
9558 gr_values
[i
].known
= 0;
9561 /* Keep track of register values/changes which affect DV tracking.
9563 optimization note: should add a flag to classes of insns where otherwise we
9564 have to examine a group of strings to identify them. */
9567 note_register_values (struct ia64_opcode
*idesc
)
9569 valueT qp_changemask
= 0;
9572 /* Invalidate values for registers being written to. */
9573 for (i
= 0; i
< idesc
->num_outputs
; i
++)
9575 if (idesc
->operands
[i
] == IA64_OPND_R1
9576 || idesc
->operands
[i
] == IA64_OPND_R2
9577 || idesc
->operands
[i
] == IA64_OPND_R3
)
9579 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9580 if (regno
> 0 && regno
< NELEMS (gr_values
))
9581 gr_values
[regno
].known
= 0;
9583 else if (idesc
->operands
[i
] == IA64_OPND_R3_2
)
9585 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9586 if (regno
> 0 && regno
< 4)
9587 gr_values
[regno
].known
= 0;
9589 else if (idesc
->operands
[i
] == IA64_OPND_P1
9590 || idesc
->operands
[i
] == IA64_OPND_P2
)
9592 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
9593 qp_changemask
|= (valueT
) 1 << regno
;
9595 else if (idesc
->operands
[i
] == IA64_OPND_PR
)
9597 if (idesc
->operands
[2] & (valueT
) 0x10000)
9598 qp_changemask
= ~(valueT
) 0x1FFFF | idesc
->operands
[2];
9600 qp_changemask
= idesc
->operands
[2];
9603 else if (idesc
->operands
[i
] == IA64_OPND_PR_ROT
)
9605 if (idesc
->operands
[1] & ((valueT
) 1 << 43))
9606 qp_changemask
= -((valueT
) 1 << 44) | idesc
->operands
[1];
9608 qp_changemask
= idesc
->operands
[1];
9609 qp_changemask
&= ~(valueT
) 0xFFFF;
9614 /* Always clear qp branch flags on any PR change. */
9615 /* FIXME there may be exceptions for certain compares. */
9616 clear_qp_branch_flag (qp_changemask
);
9618 /* Invalidate rotating registers on insns which affect RRBs in CFM. */
9619 if (idesc
->flags
& IA64_OPCODE_MOD_RRBS
)
9621 qp_changemask
|= ~(valueT
) 0xFFFF;
9622 if (strcmp (idesc
->name
, "clrrrb.pr") != 0)
9624 for (i
= 32; i
< 32 + md
.rot
.num_regs
; i
++)
9625 gr_values
[i
].known
= 0;
9627 clear_qp_mutex (qp_changemask
);
9628 clear_qp_implies (qp_changemask
, qp_changemask
);
9630 /* After a call, all register values are undefined, except those marked
9632 else if (strncmp (idesc
->name
, "br.call", 6) == 0
9633 || strncmp (idesc
->name
, "brl.call", 7) == 0)
9635 /* FIXME keep GR values which are marked as "safe_across_calls" */
9636 clear_register_values ();
9637 clear_qp_mutex (~qp_safe_across_calls
);
9638 clear_qp_implies (~qp_safe_across_calls
, ~qp_safe_across_calls
);
9639 clear_qp_branch_flag (~qp_safe_across_calls
);
9641 else if (is_interruption_or_rfi (idesc
)
9642 || is_taken_branch (idesc
))
9644 clear_register_values ();
9645 clear_qp_mutex (~(valueT
) 0);
9646 clear_qp_implies (~(valueT
) 0, ~(valueT
) 0);
9648 /* Look for mutex and implies relations. */
9649 else if ((idesc
->operands
[0] == IA64_OPND_P1
9650 || idesc
->operands
[0] == IA64_OPND_P2
)
9651 && (idesc
->operands
[1] == IA64_OPND_P1
9652 || idesc
->operands
[1] == IA64_OPND_P2
))
9654 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
9655 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
9656 valueT p1mask
= (p1
!= 0) ? (valueT
) 1 << p1
: 0;
9657 valueT p2mask
= (p2
!= 0) ? (valueT
) 1 << p2
: 0;
9659 /* If both PRs are PR0, we can't really do anything. */
9660 if (p1
== 0 && p2
== 0)
9663 fprintf (stderr
, " Ignoring PRs due to inclusion of p0\n");
9665 /* In general, clear mutexes and implies which include P1 or P2,
9666 with the following exceptions. */
9667 else if (has_suffix_p (idesc
->name
, ".or.andcm")
9668 || has_suffix_p (idesc
->name
, ".and.orcm"))
9670 clear_qp_implies (p2mask
, p1mask
);
9672 else if (has_suffix_p (idesc
->name
, ".andcm")
9673 || has_suffix_p (idesc
->name
, ".and"))
9675 clear_qp_implies (0, p1mask
| p2mask
);
9677 else if (has_suffix_p (idesc
->name
, ".orcm")
9678 || has_suffix_p (idesc
->name
, ".or"))
9680 clear_qp_mutex (p1mask
| p2mask
);
9681 clear_qp_implies (p1mask
| p2mask
, 0);
9687 clear_qp_implies (p1mask
| p2mask
, p1mask
| p2mask
);
9689 /* If one of the PRs is PR0, we call clear_qp_mutex. */
9690 if (p1
== 0 || p2
== 0)
9691 clear_qp_mutex (p1mask
| p2mask
);
9693 added
= update_qp_mutex (p1mask
| p2mask
);
9695 if (CURR_SLOT
.qp_regno
== 0
9696 || has_suffix_p (idesc
->name
, ".unc"))
9698 if (added
== 0 && p1
&& p2
)
9699 add_qp_mutex (p1mask
| p2mask
);
9700 if (CURR_SLOT
.qp_regno
!= 0)
9703 add_qp_imply (p1
, CURR_SLOT
.qp_regno
);
9705 add_qp_imply (p2
, CURR_SLOT
.qp_regno
);
9710 /* Look for mov imm insns into GRs. */
9711 else if (idesc
->operands
[0] == IA64_OPND_R1
9712 && (idesc
->operands
[1] == IA64_OPND_IMM22
9713 || idesc
->operands
[1] == IA64_OPND_IMMU64
)
9714 && CURR_SLOT
.opnd
[1].X_op
== O_constant
9715 && (strcmp (idesc
->name
, "mov") == 0
9716 || strcmp (idesc
->name
, "movl") == 0))
9718 int regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
9719 if (regno
> 0 && regno
< NELEMS (gr_values
))
9721 gr_values
[regno
].known
= 1;
9722 gr_values
[regno
].value
= CURR_SLOT
.opnd
[1].X_add_number
;
9723 gr_values
[regno
].path
= md
.path
;
9726 fprintf (stderr
, " Know gr%d = ", regno
);
9727 fprintf_vma (stderr
, gr_values
[regno
].value
);
9728 fputs ("\n", stderr
);
9732 /* Look for dep.z imm insns. */
9733 else if (idesc
->operands
[0] == IA64_OPND_R1
9734 && idesc
->operands
[1] == IA64_OPND_IMM8
9735 && strcmp (idesc
->name
, "dep.z") == 0)
9737 int regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
9738 if (regno
> 0 && regno
< NELEMS (gr_values
))
9740 valueT value
= CURR_SLOT
.opnd
[1].X_add_number
;
9742 if (CURR_SLOT
.opnd
[3].X_add_number
< 64)
9743 value
&= ((valueT
)1 << CURR_SLOT
.opnd
[3].X_add_number
) - 1;
9744 value
<<= CURR_SLOT
.opnd
[2].X_add_number
;
9745 gr_values
[regno
].known
= 1;
9746 gr_values
[regno
].value
= value
;
9747 gr_values
[regno
].path
= md
.path
;
9750 fprintf (stderr
, " Know gr%d = ", regno
);
9751 fprintf_vma (stderr
, gr_values
[regno
].value
);
9752 fputs ("\n", stderr
);
9758 clear_qp_mutex (qp_changemask
);
9759 clear_qp_implies (qp_changemask
, qp_changemask
);
9763 /* Return whether the given predicate registers are currently mutex. */
9766 qp_mutex (int p1
, int p2
, int path
)
9773 mask
= ((valueT
) 1 << p1
) | (valueT
) 1 << p2
;
9774 for (i
= 0; i
< qp_mutexeslen
; i
++)
9776 if (qp_mutexes
[i
].path
>= path
9777 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
9784 /* Return whether the given resource is in the given insn's list of chks
9785 Return 1 if the conflict is absolutely determined, 2 if it's a potential
9789 resources_match (struct rsrc
*rs
,
9790 struct ia64_opcode
*idesc
,
9795 struct rsrc specs
[MAX_SPECS
];
9798 /* If the marked resource's qp_regno and the given qp_regno are mutex,
9799 we don't need to check. One exception is note 11, which indicates that
9800 target predicates are written regardless of PR[qp]. */
9801 if (qp_mutex (rs
->qp_regno
, qp_regno
, path
)
9805 count
= specify_resource (rs
->dependency
, idesc
, DV_CHK
, specs
, note
, path
);
9808 /* UNAT checking is a bit more specific than other resources */
9809 if (rs
->dependency
->specifier
== IA64_RS_AR_UNAT
9810 && specs
[count
].mem_offset
.hint
9811 && rs
->mem_offset
.hint
)
9813 if (rs
->mem_offset
.base
== specs
[count
].mem_offset
.base
)
9815 if (((rs
->mem_offset
.offset
>> 3) & 0x3F) ==
9816 ((specs
[count
].mem_offset
.offset
>> 3) & 0x3F))
9823 /* Skip apparent PR write conflicts where both writes are an AND or both
9824 writes are an OR. */
9825 if (rs
->dependency
->specifier
== IA64_RS_PR
9826 || rs
->dependency
->specifier
== IA64_RS_PRr
9827 || rs
->dependency
->specifier
== IA64_RS_PR63
)
9829 if (specs
[count
].cmp_type
!= CMP_NONE
9830 && specs
[count
].cmp_type
== rs
->cmp_type
)
9833 fprintf (stderr
, " %s on parallel compare allowed (PR%d)\n",
9834 dv_mode
[rs
->dependency
->mode
],
9835 rs
->dependency
->specifier
!= IA64_RS_PR63
?
9836 specs
[count
].index
: 63);
9841 " %s on parallel compare conflict %s vs %s on PR%d\n",
9842 dv_mode
[rs
->dependency
->mode
],
9843 dv_cmp_type
[rs
->cmp_type
],
9844 dv_cmp_type
[specs
[count
].cmp_type
],
9845 rs
->dependency
->specifier
!= IA64_RS_PR63
?
9846 specs
[count
].index
: 63);
9850 /* If either resource is not specific, conservatively assume a conflict
9852 if (!specs
[count
].specific
|| !rs
->specific
)
9854 else if (specs
[count
].index
== rs
->index
)
9861 /* Indicate an instruction group break; if INSERT_STOP is non-zero, then
9862 insert a stop to create the break. Update all resource dependencies
9863 appropriately. If QP_REGNO is non-zero, only apply the break to resources
9864 which use the same QP_REGNO and have the link_to_qp_branch flag set.
9865 If SAVE_CURRENT is non-zero, don't affect resources marked by the current
9869 insn_group_break (int insert_stop
, int qp_regno
, int save_current
)
9873 if (insert_stop
&& md
.num_slots_in_use
> 0)
9874 PREV_SLOT
.end_of_insn_group
= 1;
9878 fprintf (stderr
, " Insn group break%s",
9879 (insert_stop
? " (w/stop)" : ""));
9881 fprintf (stderr
, " effective for QP=%d", qp_regno
);
9882 fprintf (stderr
, "\n");
9886 while (i
< regdepslen
)
9888 const struct ia64_dependency
*dep
= regdeps
[i
].dependency
;
9891 && regdeps
[i
].qp_regno
!= qp_regno
)
9898 && CURR_SLOT
.src_file
== regdeps
[i
].file
9899 && CURR_SLOT
.src_line
== regdeps
[i
].line
)
9905 /* clear dependencies which are automatically cleared by a stop, or
9906 those that have reached the appropriate state of insn serialization */
9907 if (dep
->semantics
== IA64_DVS_IMPLIED
9908 || dep
->semantics
== IA64_DVS_IMPLIEDF
9909 || regdeps
[i
].insn_srlz
== STATE_SRLZ
)
9911 print_dependency ("Removing", i
);
9912 regdeps
[i
] = regdeps
[--regdepslen
];
9916 if (dep
->semantics
== IA64_DVS_DATA
9917 || dep
->semantics
== IA64_DVS_INSTR
9918 || dep
->semantics
== IA64_DVS_SPECIFIC
)
9920 if (regdeps
[i
].insn_srlz
== STATE_NONE
)
9921 regdeps
[i
].insn_srlz
= STATE_STOP
;
9922 if (regdeps
[i
].data_srlz
== STATE_NONE
)
9923 regdeps
[i
].data_srlz
= STATE_STOP
;
9930 /* Add the given resource usage spec to the list of active dependencies. */
9933 mark_resource (struct ia64_opcode
*idesc ATTRIBUTE_UNUSED
,
9934 const struct ia64_dependency
*dep ATTRIBUTE_UNUSED
,
9939 if (regdepslen
== regdepstotlen
)
9941 regdepstotlen
+= 20;
9942 regdeps
= (struct rsrc
*)
9943 xrealloc ((void *) regdeps
,
9944 regdepstotlen
* sizeof (struct rsrc
));
9947 regdeps
[regdepslen
] = *spec
;
9948 regdeps
[regdepslen
].depind
= depind
;
9949 regdeps
[regdepslen
].path
= path
;
9950 regdeps
[regdepslen
].file
= CURR_SLOT
.src_file
;
9951 regdeps
[regdepslen
].line
= CURR_SLOT
.src_line
;
9953 print_dependency ("Adding", regdepslen
);
9959 print_dependency (const char *action
, int depind
)
9963 fprintf (stderr
, " %s %s '%s'",
9964 action
, dv_mode
[(regdeps
[depind
].dependency
)->mode
],
9965 (regdeps
[depind
].dependency
)->name
);
9966 if (regdeps
[depind
].specific
&& regdeps
[depind
].index
>= 0)
9967 fprintf (stderr
, " (%d)", regdeps
[depind
].index
);
9968 if (regdeps
[depind
].mem_offset
.hint
)
9970 fputs (" ", stderr
);
9971 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.base
);
9972 fputs ("+", stderr
);
9973 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.offset
);
9975 fprintf (stderr
, "\n");
9980 instruction_serialization (void)
9984 fprintf (stderr
, " Instruction serialization\n");
9985 for (i
= 0; i
< regdepslen
; i
++)
9986 if (regdeps
[i
].insn_srlz
== STATE_STOP
)
9987 regdeps
[i
].insn_srlz
= STATE_SRLZ
;
9991 data_serialization (void)
9995 fprintf (stderr
, " Data serialization\n");
9996 while (i
< regdepslen
)
9998 if (regdeps
[i
].data_srlz
== STATE_STOP
9999 /* Note: as of 991210, all "other" dependencies are cleared by a
10000 data serialization. This might change with new tables */
10001 || (regdeps
[i
].dependency
)->semantics
== IA64_DVS_OTHER
)
10003 print_dependency ("Removing", i
);
10004 regdeps
[i
] = regdeps
[--regdepslen
];
10011 /* Insert stops and serializations as needed to avoid DVs. */
10014 remove_marked_resource (struct rsrc
*rs
)
10016 switch (rs
->dependency
->semantics
)
10018 case IA64_DVS_SPECIFIC
:
10020 fprintf (stderr
, "Implementation-specific, assume worst case...\n");
10021 /* ...fall through... */
10022 case IA64_DVS_INSTR
:
10024 fprintf (stderr
, "Inserting instr serialization\n");
10025 if (rs
->insn_srlz
< STATE_STOP
)
10026 insn_group_break (1, 0, 0);
10027 if (rs
->insn_srlz
< STATE_SRLZ
)
10029 struct slot oldslot
= CURR_SLOT
;
10030 /* Manually jam a srlz.i insn into the stream */
10031 memset (&CURR_SLOT
, 0, sizeof (CURR_SLOT
));
10032 CURR_SLOT
.user_template
= -1;
10033 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.i");
10034 instruction_serialization ();
10035 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10036 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10037 emit_one_bundle ();
10038 CURR_SLOT
= oldslot
;
10040 insn_group_break (1, 0, 0);
10042 case IA64_DVS_OTHER
: /* as of rev2 (991220) of the DV tables, all
10043 "other" types of DV are eliminated
10044 by a data serialization */
10045 case IA64_DVS_DATA
:
10047 fprintf (stderr
, "Inserting data serialization\n");
10048 if (rs
->data_srlz
< STATE_STOP
)
10049 insn_group_break (1, 0, 0);
10051 struct slot oldslot
= CURR_SLOT
;
10052 /* Manually jam a srlz.d insn into the stream */
10053 memset (&CURR_SLOT
, 0, sizeof (CURR_SLOT
));
10054 CURR_SLOT
.user_template
= -1;
10055 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.d");
10056 data_serialization ();
10057 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10058 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10059 emit_one_bundle ();
10060 CURR_SLOT
= oldslot
;
10063 case IA64_DVS_IMPLIED
:
10064 case IA64_DVS_IMPLIEDF
:
10066 fprintf (stderr
, "Inserting stop\n");
10067 insn_group_break (1, 0, 0);
10074 /* Check the resources used by the given opcode against the current dependency
10077 The check is run once for each execution path encountered. In this case,
10078 a unique execution path is the sequence of instructions following a code
10079 entry point, e.g. the following has three execution paths, one starting
10080 at L0, one at L1, and one at L2.
10089 check_dependencies (struct ia64_opcode
*idesc
)
10091 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
10095 /* Note that the number of marked resources may change within the
10096 loop if in auto mode. */
10098 while (i
< regdepslen
)
10100 struct rsrc
*rs
= ®deps
[i
];
10101 const struct ia64_dependency
*dep
= rs
->dependency
;
10104 int start_over
= 0;
10106 if (dep
->semantics
== IA64_DVS_NONE
10107 || (chkind
= depends_on (rs
->depind
, idesc
)) == -1)
10113 note
= NOTE (opdeps
->chks
[chkind
]);
10115 /* Check this resource against each execution path seen thus far. */
10116 for (path
= 0; path
<= md
.path
; path
++)
10120 /* If the dependency wasn't on the path being checked, ignore it. */
10121 if (rs
->path
< path
)
10124 /* If the QP for this insn implies a QP which has branched, don't
10125 bother checking. Ed. NOTE: I don't think this check is terribly
10126 useful; what's the point of generating code which will only be
10127 reached if its QP is zero?
10128 This code was specifically inserted to handle the following code,
10129 based on notes from Intel's DV checking code, where p1 implies p2.
10135 if (CURR_SLOT
.qp_regno
!= 0)
10139 for (implies
= 0; implies
< qp_implieslen
; implies
++)
10141 if (qp_implies
[implies
].path
>= path
10142 && qp_implies
[implies
].p1
== CURR_SLOT
.qp_regno
10143 && qp_implies
[implies
].p2_branched
)
10153 if ((matchtype
= resources_match (rs
, idesc
, note
,
10154 CURR_SLOT
.qp_regno
, path
)) != 0)
10157 char pathmsg
[256] = "";
10158 char indexmsg
[256] = "";
10159 int certain
= (matchtype
== 1 && CURR_SLOT
.qp_regno
== 0);
10162 snprintf (pathmsg
, sizeof (pathmsg
),
10163 " when entry is at label '%s'",
10164 md
.entry_labels
[path
- 1]);
10165 if (matchtype
== 1 && rs
->index
>= 0)
10166 snprintf (indexmsg
, sizeof (indexmsg
),
10167 ", specific resource number is %d",
10169 snprintf (msg
, sizeof (msg
),
10170 "Use of '%s' %s %s dependency '%s' (%s)%s%s",
10172 (certain
? "violates" : "may violate"),
10173 dv_mode
[dep
->mode
], dep
->name
,
10174 dv_sem
[dep
->semantics
],
10175 pathmsg
, indexmsg
);
10177 if (md
.explicit_mode
)
10179 as_warn ("%s", msg
);
10180 if (path
< md
.path
)
10181 as_warn (_("Only the first path encountering the conflict is reported"));
10182 as_warn_where (rs
->file
, rs
->line
,
10183 _("This is the location of the conflicting usage"));
10184 /* Don't bother checking other paths, to avoid duplicating
10185 the same warning */
10191 fprintf (stderr
, "%s @ %s:%d\n", msg
, rs
->file
, rs
->line
);
10193 remove_marked_resource (rs
);
10195 /* since the set of dependencies has changed, start over */
10196 /* FIXME -- since we're removing dvs as we go, we
10197 probably don't really need to start over... */
10210 /* Register new dependencies based on the given opcode. */
10213 mark_resources (struct ia64_opcode
*idesc
)
10216 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
10217 int add_only_qp_reads
= 0;
10219 /* A conditional branch only uses its resources if it is taken; if it is
10220 taken, we stop following that path. The other branch types effectively
10221 *always* write their resources. If it's not taken, register only QP
10223 if (is_conditional_branch (idesc
) || is_interruption_or_rfi (idesc
))
10225 add_only_qp_reads
= 1;
10229 fprintf (stderr
, "Registering '%s' resource usage\n", idesc
->name
);
10231 for (i
= 0; i
< opdeps
->nregs
; i
++)
10233 const struct ia64_dependency
*dep
;
10234 struct rsrc specs
[MAX_SPECS
];
10239 dep
= ia64_find_dependency (opdeps
->regs
[i
]);
10240 note
= NOTE (opdeps
->regs
[i
]);
10242 if (add_only_qp_reads
10243 && !(dep
->mode
== IA64_DV_WAR
10244 && (dep
->specifier
== IA64_RS_PR
10245 || dep
->specifier
== IA64_RS_PRr
10246 || dep
->specifier
== IA64_RS_PR63
)))
10249 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, md
.path
);
10251 while (count
-- > 0)
10253 mark_resource (idesc
, dep
, &specs
[count
],
10254 DEP (opdeps
->regs
[i
]), md
.path
);
10257 /* The execution path may affect register values, which may in turn
10258 affect which indirect-access resources are accessed. */
10259 switch (dep
->specifier
)
10263 case IA64_RS_CPUID
:
10271 for (path
= 0; path
< md
.path
; path
++)
10273 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, path
);
10274 while (count
-- > 0)
10275 mark_resource (idesc
, dep
, &specs
[count
],
10276 DEP (opdeps
->regs
[i
]), path
);
10283 /* Remove dependencies when they no longer apply. */
10286 update_dependencies (struct ia64_opcode
*idesc
)
10290 if (strcmp (idesc
->name
, "srlz.i") == 0)
10292 instruction_serialization ();
10294 else if (strcmp (idesc
->name
, "srlz.d") == 0)
10296 data_serialization ();
10298 else if (is_interruption_or_rfi (idesc
)
10299 || is_taken_branch (idesc
))
10301 /* Although technically the taken branch doesn't clear dependencies
10302 which require a srlz.[id], we don't follow the branch; the next
10303 instruction is assumed to start with a clean slate. */
10307 else if (is_conditional_branch (idesc
)
10308 && CURR_SLOT
.qp_regno
!= 0)
10310 int is_call
= strstr (idesc
->name
, ".call") != NULL
;
10312 for (i
= 0; i
< qp_implieslen
; i
++)
10314 /* If the conditional branch's predicate is implied by the predicate
10315 in an existing dependency, remove that dependency. */
10316 if (qp_implies
[i
].p2
== CURR_SLOT
.qp_regno
)
10319 /* Note that this implied predicate takes a branch so that if
10320 a later insn generates a DV but its predicate implies this
10321 one, we can avoid the false DV warning. */
10322 qp_implies
[i
].p2_branched
= 1;
10323 while (depind
< regdepslen
)
10325 if (regdeps
[depind
].qp_regno
== qp_implies
[i
].p1
)
10327 print_dependency ("Removing", depind
);
10328 regdeps
[depind
] = regdeps
[--regdepslen
];
10335 /* Any marked resources which have this same predicate should be
10336 cleared, provided that the QP hasn't been modified between the
10337 marking instruction and the branch. */
10340 insn_group_break (0, CURR_SLOT
.qp_regno
, 1);
10345 while (i
< regdepslen
)
10347 if (regdeps
[i
].qp_regno
== CURR_SLOT
.qp_regno
10348 && regdeps
[i
].link_to_qp_branch
10349 && (regdeps
[i
].file
!= CURR_SLOT
.src_file
10350 || regdeps
[i
].line
!= CURR_SLOT
.src_line
))
10352 /* Treat like a taken branch */
10353 print_dependency ("Removing", i
);
10354 regdeps
[i
] = regdeps
[--regdepslen
];
10363 /* Examine the current instruction for dependency violations. */
10366 check_dv (struct ia64_opcode
*idesc
)
10370 fprintf (stderr
, "Checking %s for violations (line %d, %d/%d)\n",
10371 idesc
->name
, CURR_SLOT
.src_line
,
10372 idesc
->dependencies
->nchks
,
10373 idesc
->dependencies
->nregs
);
10376 /* Look through the list of currently marked resources; if the current
10377 instruction has the dependency in its chks list which uses that resource,
10378 check against the specific resources used. */
10379 check_dependencies (idesc
);
10381 /* Look up the instruction's regdeps (RAW writes, WAW writes, and WAR reads),
10382 then add them to the list of marked resources. */
10383 mark_resources (idesc
);
10385 /* There are several types of dependency semantics, and each has its own
10386 requirements for being cleared
10388 Instruction serialization (insns separated by interruption, rfi, or
10389 writer + srlz.i + reader, all in separate groups) clears DVS_INSTR.
10391 Data serialization (instruction serialization, or writer + srlz.d +
10392 reader, where writer and srlz.d are in separate groups) clears
10393 DVS_DATA. (This also clears DVS_OTHER, but that is not guaranteed to
10394 always be the case).
10396 Instruction group break (groups separated by stop, taken branch,
10397 interruption or rfi) clears DVS_IMPLIED and DVS_IMPLIEDF.
10399 update_dependencies (idesc
);
10401 /* Sometimes, knowing a register value allows us to avoid giving a false DV
10402 warning. Keep track of as many as possible that are useful. */
10403 note_register_values (idesc
);
10405 /* We don't need or want this anymore. */
10406 md
.mem_offset
.hint
= 0;
10411 /* Translate one line of assembly. Pseudo ops and labels do not show
10414 md_assemble (char *str
)
10416 char *saved_input_line_pointer
, *mnemonic
;
10417 const struct pseudo_opcode
*pdesc
;
10418 struct ia64_opcode
*idesc
;
10419 unsigned char qp_regno
;
10420 unsigned int flags
;
10423 saved_input_line_pointer
= input_line_pointer
;
10424 input_line_pointer
= str
;
10426 /* extract the opcode (mnemonic): */
10428 mnemonic
= input_line_pointer
;
10429 ch
= get_symbol_end ();
10430 pdesc
= (struct pseudo_opcode
*) hash_find (md
.pseudo_hash
, mnemonic
);
10433 *input_line_pointer
= ch
;
10434 (*pdesc
->handler
) (pdesc
->arg
);
10438 /* Find the instruction descriptor matching the arguments. */
10440 idesc
= ia64_find_opcode (mnemonic
);
10441 *input_line_pointer
= ch
;
10444 as_bad (_("Unknown opcode `%s'"), mnemonic
);
10448 idesc
= parse_operands (idesc
);
10452 /* Handle the dynamic ops we can handle now: */
10453 if (idesc
->type
== IA64_TYPE_DYN
)
10455 if (strcmp (idesc
->name
, "add") == 0)
10457 if (CURR_SLOT
.opnd
[2].X_op
== O_register
10458 && CURR_SLOT
.opnd
[2].X_add_number
< 4)
10462 ia64_free_opcode (idesc
);
10463 idesc
= ia64_find_opcode (mnemonic
);
10465 else if (strcmp (idesc
->name
, "mov") == 0)
10467 enum ia64_opnd opnd1
, opnd2
;
10470 opnd1
= idesc
->operands
[0];
10471 opnd2
= idesc
->operands
[1];
10472 if (opnd1
== IA64_OPND_AR3
)
10474 else if (opnd2
== IA64_OPND_AR3
)
10478 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
)
10480 if (ar_is_only_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10481 mnemonic
= "mov.i";
10482 else if (ar_is_only_in_memory_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10483 mnemonic
= "mov.m";
10491 ia64_free_opcode (idesc
);
10492 idesc
= ia64_find_opcode (mnemonic
);
10493 while (idesc
!= NULL
10494 && (idesc
->operands
[0] != opnd1
10495 || idesc
->operands
[1] != opnd2
))
10496 idesc
= get_next_opcode (idesc
);
10500 else if (strcmp (idesc
->name
, "mov.i") == 0
10501 || strcmp (idesc
->name
, "mov.m") == 0)
10503 enum ia64_opnd opnd1
, opnd2
;
10506 opnd1
= idesc
->operands
[0];
10507 opnd2
= idesc
->operands
[1];
10508 if (opnd1
== IA64_OPND_AR3
)
10510 else if (opnd2
== IA64_OPND_AR3
)
10514 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
)
10517 if (ar_is_only_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10519 else if (ar_is_only_in_memory_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10521 if (unit
!= 'a' && unit
!= idesc
->name
[4])
10522 as_bad (_("AR %d can only be accessed by %c-unit"),
10523 (int) (CURR_SLOT
.opnd
[rop
].X_add_number
- REG_AR
),
10527 else if (strcmp (idesc
->name
, "hint.b") == 0)
10533 case hint_b_warning
:
10534 as_warn (_("hint.b may be treated as nop"));
10537 as_bad (_("hint.b shouldn't be used"));
10543 if (md
.qp
.X_op
== O_register
)
10545 qp_regno
= md
.qp
.X_add_number
- REG_P
;
10546 md
.qp
.X_op
= O_absent
;
10549 flags
= idesc
->flags
;
10551 if ((flags
& IA64_OPCODE_FIRST
) != 0)
10553 /* The alignment frag has to end with a stop bit only if the
10554 next instruction after the alignment directive has to be
10555 the first instruction in an instruction group. */
10558 while (align_frag
->fr_type
!= rs_align_code
)
10560 align_frag
= align_frag
->fr_next
;
10564 /* align_frag can be NULL if there are directives in
10566 if (align_frag
&& align_frag
->fr_next
== frag_now
)
10567 align_frag
->tc_frag_data
= 1;
10570 insn_group_break (1, 0, 0);
10574 if ((flags
& IA64_OPCODE_NO_PRED
) != 0 && qp_regno
!= 0)
10576 as_bad (_("`%s' cannot be predicated"), idesc
->name
);
10580 /* Build the instruction. */
10581 CURR_SLOT
.qp_regno
= qp_regno
;
10582 CURR_SLOT
.idesc
= idesc
;
10583 as_where (&CURR_SLOT
.src_file
, &CURR_SLOT
.src_line
);
10584 dwarf2_where (&CURR_SLOT
.debug_line
);
10585 dwarf2_consume_line_info ();
10587 /* Add unwind entries, if there are any. */
10588 if (unwind
.current_entry
)
10590 CURR_SLOT
.unwind_record
= unwind
.current_entry
;
10591 unwind
.current_entry
= NULL
;
10593 if (unwind
.pending_saves
)
10595 if (unwind
.pending_saves
->next
)
10597 /* Attach the next pending save to the next slot so that its
10598 slot number will get set correctly. */
10599 add_unwind_entry (unwind
.pending_saves
->next
, NOT_A_CHAR
);
10600 unwind
.pending_saves
= &unwind
.pending_saves
->next
->r
.record
.p
;
10603 unwind
.pending_saves
= NULL
;
10605 if (unwind
.proc_pending
.sym
&& S_IS_DEFINED (unwind
.proc_pending
.sym
))
10608 /* Check for dependency violations. */
10612 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10613 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10614 emit_one_bundle ();
10616 if ((flags
& IA64_OPCODE_LAST
) != 0)
10617 insn_group_break (1, 0, 0);
10619 md
.last_text_seg
= now_seg
;
10622 input_line_pointer
= saved_input_line_pointer
;
10625 /* Called when symbol NAME cannot be found in the symbol table.
10626 Should be used for dynamic valued symbols only. */
10629 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
10634 /* Called for any expression that can not be recognized. When the
10635 function is called, `input_line_pointer' will point to the start of
10639 md_operand (expressionS
*e
)
10641 switch (*input_line_pointer
)
10644 ++input_line_pointer
;
10645 expression_and_evaluate (e
);
10646 if (*input_line_pointer
!= ']')
10648 as_bad (_("Closing bracket missing"));
10653 if (e
->X_op
!= O_register
10654 || e
->X_add_number
< REG_GR
10655 || e
->X_add_number
> REG_GR
+ 127)
10657 as_bad (_("Index must be a general register"));
10658 e
->X_add_number
= REG_GR
;
10661 ++input_line_pointer
;
10672 ignore_rest_of_line ();
10675 /* Return 1 if it's OK to adjust a reloc by replacing the symbol with
10676 a section symbol plus some offset. For relocs involving @fptr(),
10677 directives we don't want such adjustments since we need to have the
10678 original symbol's name in the reloc. */
10680 ia64_fix_adjustable (fixS
*fix
)
10682 /* Prevent all adjustments to global symbols */
10683 if (S_IS_EXTERNAL (fix
->fx_addsy
) || S_IS_WEAK (fix
->fx_addsy
))
10686 switch (fix
->fx_r_type
)
10688 case BFD_RELOC_IA64_FPTR64I
:
10689 case BFD_RELOC_IA64_FPTR32MSB
:
10690 case BFD_RELOC_IA64_FPTR32LSB
:
10691 case BFD_RELOC_IA64_FPTR64MSB
:
10692 case BFD_RELOC_IA64_FPTR64LSB
:
10693 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10694 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10704 ia64_force_relocation (fixS
*fix
)
10706 switch (fix
->fx_r_type
)
10708 case BFD_RELOC_IA64_FPTR64I
:
10709 case BFD_RELOC_IA64_FPTR32MSB
:
10710 case BFD_RELOC_IA64_FPTR32LSB
:
10711 case BFD_RELOC_IA64_FPTR64MSB
:
10712 case BFD_RELOC_IA64_FPTR64LSB
:
10714 case BFD_RELOC_IA64_LTOFF22
:
10715 case BFD_RELOC_IA64_LTOFF64I
:
10716 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10717 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10718 case BFD_RELOC_IA64_PLTOFF22
:
10719 case BFD_RELOC_IA64_PLTOFF64I
:
10720 case BFD_RELOC_IA64_PLTOFF64MSB
:
10721 case BFD_RELOC_IA64_PLTOFF64LSB
:
10723 case BFD_RELOC_IA64_LTOFF22X
:
10724 case BFD_RELOC_IA64_LDXMOV
:
10731 return generic_force_reloc (fix
);
10734 /* Decide from what point a pc-relative relocation is relative to,
10735 relative to the pc-relative fixup. Er, relatively speaking. */
10737 ia64_pcrel_from_section (fixS
*fix
, segT sec
)
10739 unsigned long off
= fix
->fx_frag
->fr_address
+ fix
->fx_where
;
10741 if (bfd_get_section_flags (stdoutput
, sec
) & SEC_CODE
)
10748 /* Used to emit section-relative relocs for the dwarf2 debug data. */
10750 ia64_dwarf2_emit_offset (symbolS
*symbol
, unsigned int size
)
10754 expr
.X_op
= O_pseudo_fixup
;
10755 expr
.X_op_symbol
= pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
;
10756 expr
.X_add_number
= 0;
10757 expr
.X_add_symbol
= symbol
;
10758 emit_expr (&expr
, size
);
10761 /* This is called whenever some data item (not an instruction) needs a
10762 fixup. We pick the right reloc code depending on the byteorder
10763 currently in effect. */
10765 ia64_cons_fix_new (fragS
*f
, int where
, int nbytes
, expressionS
*exp
)
10767 bfd_reloc_code_real_type code
;
10772 /* There are no reloc for 8 and 16 bit quantities, but we allow
10773 them here since they will work fine as long as the expression
10774 is fully defined at the end of the pass over the source file. */
10775 case 1: code
= BFD_RELOC_8
; break;
10776 case 2: code
= BFD_RELOC_16
; break;
10778 if (target_big_endian
)
10779 code
= BFD_RELOC_IA64_DIR32MSB
;
10781 code
= BFD_RELOC_IA64_DIR32LSB
;
10785 /* In 32-bit mode, data8 could mean function descriptors too. */
10786 if (exp
->X_op
== O_pseudo_fixup
10787 && exp
->X_op_symbol
10788 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
10789 && !(md
.flags
& EF_IA_64_ABI64
))
10791 if (target_big_endian
)
10792 code
= BFD_RELOC_IA64_IPLTMSB
;
10794 code
= BFD_RELOC_IA64_IPLTLSB
;
10795 exp
->X_op
= O_symbol
;
10800 if (target_big_endian
)
10801 code
= BFD_RELOC_IA64_DIR64MSB
;
10803 code
= BFD_RELOC_IA64_DIR64LSB
;
10808 if (exp
->X_op
== O_pseudo_fixup
10809 && exp
->X_op_symbol
10810 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
)
10812 if (target_big_endian
)
10813 code
= BFD_RELOC_IA64_IPLTMSB
;
10815 code
= BFD_RELOC_IA64_IPLTLSB
;
10816 exp
->X_op
= O_symbol
;
10822 as_bad (_("Unsupported fixup size %d"), nbytes
);
10823 ignore_rest_of_line ();
10827 if (exp
->X_op
== O_pseudo_fixup
)
10829 exp
->X_op
= O_symbol
;
10830 code
= ia64_gen_real_reloc_type (exp
->X_op_symbol
, code
);
10831 /* ??? If code unchanged, unsupported. */
10834 fix
= fix_new_exp (f
, where
, nbytes
, exp
, 0, code
);
10835 /* We need to store the byte order in effect in case we're going
10836 to fix an 8 or 16 bit relocation (for which there no real
10837 relocs available). See md_apply_fix(). */
10838 fix
->tc_fix_data
.bigendian
= target_big_endian
;
10841 /* Return the actual relocation we wish to associate with the pseudo
10842 reloc described by SYM and R_TYPE. SYM should be one of the
10843 symbols in the pseudo_func array, or NULL. */
10845 static bfd_reloc_code_real_type
10846 ia64_gen_real_reloc_type (struct symbol
*sym
, bfd_reloc_code_real_type r_type
)
10848 bfd_reloc_code_real_type
new = 0;
10849 const char *type
= NULL
, *suffix
= "";
10856 switch (S_GET_VALUE (sym
))
10858 case FUNC_FPTR_RELATIVE
:
10861 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_FPTR64I
; break;
10862 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_FPTR32MSB
; break;
10863 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_FPTR32LSB
; break;
10864 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_FPTR64MSB
; break;
10865 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_FPTR64LSB
; break;
10866 default: type
= "FPTR"; break;
10870 case FUNC_GP_RELATIVE
:
10873 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_GPREL22
; break;
10874 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_GPREL64I
; break;
10875 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_GPREL32MSB
; break;
10876 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_GPREL32LSB
; break;
10877 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_GPREL64MSB
; break;
10878 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_GPREL64LSB
; break;
10879 default: type
= "GPREL"; break;
10883 case FUNC_LT_RELATIVE
:
10886 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_LTOFF22
; break;
10887 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_LTOFF64I
; break;
10888 default: type
= "LTOFF"; break;
10892 case FUNC_LT_RELATIVE_X
:
10895 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_LTOFF22X
; break;
10896 default: type
= "LTOFF"; suffix
= "X"; break;
10900 case FUNC_PC_RELATIVE
:
10903 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PCREL22
; break;
10904 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PCREL64I
; break;
10905 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_PCREL32MSB
; break;
10906 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_PCREL32LSB
; break;
10907 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PCREL64MSB
; break;
10908 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PCREL64LSB
; break;
10909 default: type
= "PCREL"; break;
10913 case FUNC_PLT_RELATIVE
:
10916 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PLTOFF22
; break;
10917 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PLTOFF64I
; break;
10918 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PLTOFF64MSB
;break;
10919 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PLTOFF64LSB
;break;
10920 default: type
= "PLTOFF"; break;
10924 case FUNC_SEC_RELATIVE
:
10927 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SECREL32MSB
;break;
10928 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SECREL32LSB
;break;
10929 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SECREL64MSB
;break;
10930 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SECREL64LSB
;break;
10931 default: type
= "SECREL"; break;
10935 case FUNC_SEG_RELATIVE
:
10938 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SEGREL32MSB
;break;
10939 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SEGREL32LSB
;break;
10940 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SEGREL64MSB
;break;
10941 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SEGREL64LSB
;break;
10942 default: type
= "SEGREL"; break;
10946 case FUNC_LTV_RELATIVE
:
10949 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_LTV32MSB
; break;
10950 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_LTV32LSB
; break;
10951 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_LTV64MSB
; break;
10952 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_LTV64LSB
; break;
10953 default: type
= "LTV"; break;
10957 case FUNC_LT_FPTR_RELATIVE
:
10960 case BFD_RELOC_IA64_IMM22
:
10961 new = BFD_RELOC_IA64_LTOFF_FPTR22
; break;
10962 case BFD_RELOC_IA64_IMM64
:
10963 new = BFD_RELOC_IA64_LTOFF_FPTR64I
; break;
10964 case BFD_RELOC_IA64_DIR32MSB
:
10965 new = BFD_RELOC_IA64_LTOFF_FPTR32MSB
; break;
10966 case BFD_RELOC_IA64_DIR32LSB
:
10967 new = BFD_RELOC_IA64_LTOFF_FPTR32LSB
; break;
10968 case BFD_RELOC_IA64_DIR64MSB
:
10969 new = BFD_RELOC_IA64_LTOFF_FPTR64MSB
; break;
10970 case BFD_RELOC_IA64_DIR64LSB
:
10971 new = BFD_RELOC_IA64_LTOFF_FPTR64LSB
; break;
10973 type
= "LTOFF_FPTR"; break;
10977 case FUNC_TP_RELATIVE
:
10980 case BFD_RELOC_IA64_IMM14
: new = BFD_RELOC_IA64_TPREL14
; break;
10981 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_TPREL22
; break;
10982 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_TPREL64I
; break;
10983 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_TPREL64MSB
; break;
10984 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_TPREL64LSB
; break;
10985 default: type
= "TPREL"; break;
10989 case FUNC_LT_TP_RELATIVE
:
10992 case BFD_RELOC_IA64_IMM22
:
10993 new = BFD_RELOC_IA64_LTOFF_TPREL22
; break;
10995 type
= "LTOFF_TPREL"; break;
10999 case FUNC_DTP_MODULE
:
11002 case BFD_RELOC_IA64_DIR64MSB
:
11003 new = BFD_RELOC_IA64_DTPMOD64MSB
; break;
11004 case BFD_RELOC_IA64_DIR64LSB
:
11005 new = BFD_RELOC_IA64_DTPMOD64LSB
; break;
11007 type
= "DTPMOD"; break;
11011 case FUNC_LT_DTP_MODULE
:
11014 case BFD_RELOC_IA64_IMM22
:
11015 new = BFD_RELOC_IA64_LTOFF_DTPMOD22
; break;
11017 type
= "LTOFF_DTPMOD"; break;
11021 case FUNC_DTP_RELATIVE
:
11024 case BFD_RELOC_IA64_DIR32MSB
:
11025 new = BFD_RELOC_IA64_DTPREL32MSB
; break;
11026 case BFD_RELOC_IA64_DIR32LSB
:
11027 new = BFD_RELOC_IA64_DTPREL32LSB
; break;
11028 case BFD_RELOC_IA64_DIR64MSB
:
11029 new = BFD_RELOC_IA64_DTPREL64MSB
; break;
11030 case BFD_RELOC_IA64_DIR64LSB
:
11031 new = BFD_RELOC_IA64_DTPREL64LSB
; break;
11032 case BFD_RELOC_IA64_IMM14
:
11033 new = BFD_RELOC_IA64_DTPREL14
; break;
11034 case BFD_RELOC_IA64_IMM22
:
11035 new = BFD_RELOC_IA64_DTPREL22
; break;
11036 case BFD_RELOC_IA64_IMM64
:
11037 new = BFD_RELOC_IA64_DTPREL64I
; break;
11039 type
= "DTPREL"; break;
11043 case FUNC_LT_DTP_RELATIVE
:
11046 case BFD_RELOC_IA64_IMM22
:
11047 new = BFD_RELOC_IA64_LTOFF_DTPREL22
; break;
11049 type
= "LTOFF_DTPREL"; break;
11053 case FUNC_IPLT_RELOC
:
11056 case BFD_RELOC_IA64_IPLTMSB
: return r_type
;
11057 case BFD_RELOC_IA64_IPLTLSB
: return r_type
;
11058 default: type
= "IPLT"; break;
11076 case BFD_RELOC_IA64_DIR32MSB
: width
= 32; suffix
= "MSB"; break;
11077 case BFD_RELOC_IA64_DIR32LSB
: width
= 32; suffix
= "LSB"; break;
11078 case BFD_RELOC_IA64_DIR64MSB
: width
= 64; suffix
= "MSB"; break;
11079 case BFD_RELOC_IA64_DIR64LSB
: width
= 64; suffix
= "LSB"; break;
11080 case BFD_RELOC_UNUSED
: width
= 13; break;
11081 case BFD_RELOC_IA64_IMM14
: width
= 14; break;
11082 case BFD_RELOC_IA64_IMM22
: width
= 22; break;
11083 case BFD_RELOC_IA64_IMM64
: width
= 64; suffix
= "I"; break;
11087 /* This should be an error, but since previously there wasn't any
11088 diagnostic here, don't make it fail because of this for now. */
11089 as_warn (_("Cannot express %s%d%s relocation"), type
, width
, suffix
);
11094 /* Here is where generate the appropriate reloc for pseudo relocation
11097 ia64_validate_fix (fixS
*fix
)
11099 switch (fix
->fx_r_type
)
11101 case BFD_RELOC_IA64_FPTR64I
:
11102 case BFD_RELOC_IA64_FPTR32MSB
:
11103 case BFD_RELOC_IA64_FPTR64LSB
:
11104 case BFD_RELOC_IA64_LTOFF_FPTR22
:
11105 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
11106 if (fix
->fx_offset
!= 0)
11107 as_bad_where (fix
->fx_file
, fix
->fx_line
,
11108 _("No addend allowed in @fptr() relocation"));
11116 fix_insn (fixS
*fix
, const struct ia64_operand
*odesc
, valueT value
)
11118 bfd_vma insn
[3], t0
, t1
, control_bits
;
11123 slot
= fix
->fx_where
& 0x3;
11124 fixpos
= fix
->fx_frag
->fr_literal
+ (fix
->fx_where
- slot
);
11126 /* Bundles are always in little-endian byte order */
11127 t0
= bfd_getl64 (fixpos
);
11128 t1
= bfd_getl64 (fixpos
+ 8);
11129 control_bits
= t0
& 0x1f;
11130 insn
[0] = (t0
>> 5) & 0x1ffffffffffLL
;
11131 insn
[1] = ((t0
>> 46) & 0x3ffff) | ((t1
& 0x7fffff) << 18);
11132 insn
[2] = (t1
>> 23) & 0x1ffffffffffLL
;
11135 if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU64
)
11137 insn
[1] = (value
>> 22) & 0x1ffffffffffLL
;
11138 insn
[2] |= (((value
& 0x7f) << 13)
11139 | (((value
>> 7) & 0x1ff) << 27)
11140 | (((value
>> 16) & 0x1f) << 22)
11141 | (((value
>> 21) & 0x1) << 21)
11142 | (((value
>> 63) & 0x1) << 36));
11144 else if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU62
)
11146 if (value
& ~0x3fffffffffffffffULL
)
11147 err
= "integer operand out of range";
11148 insn
[1] = (value
>> 21) & 0x1ffffffffffLL
;
11149 insn
[2] |= (((value
& 0xfffff) << 6) | (((value
>> 20) & 0x1) << 36));
11151 else if (odesc
- elf64_ia64_operands
== IA64_OPND_TGT64
)
11154 insn
[1] = ((value
>> 20) & 0x7fffffffffLL
) << 2;
11155 insn
[2] |= ((((value
>> 59) & 0x1) << 36)
11156 | (((value
>> 0) & 0xfffff) << 13));
11159 err
= (*odesc
->insert
) (odesc
, value
, insn
+ slot
);
11162 as_bad_where (fix
->fx_file
, fix
->fx_line
, err
);
11164 t0
= control_bits
| (insn
[0] << 5) | (insn
[1] << 46);
11165 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
11166 number_to_chars_littleendian (fixpos
+ 0, t0
, 8);
11167 number_to_chars_littleendian (fixpos
+ 8, t1
, 8);
11170 /* Attempt to simplify or even eliminate a fixup. The return value is
11171 ignored; perhaps it was once meaningful, but now it is historical.
11172 To indicate that a fixup has been eliminated, set FIXP->FX_DONE.
11174 If fixp->fx_addsy is non-NULL, we'll have to generate a reloc entry
11178 md_apply_fix (fixS
*fix
, valueT
*valP
, segT seg ATTRIBUTE_UNUSED
)
11181 valueT value
= *valP
;
11183 fixpos
= fix
->fx_frag
->fr_literal
+ fix
->fx_where
;
11187 switch (fix
->fx_r_type
)
11189 case BFD_RELOC_IA64_PCREL21B
: break;
11190 case BFD_RELOC_IA64_PCREL21BI
: break;
11191 case BFD_RELOC_IA64_PCREL21F
: break;
11192 case BFD_RELOC_IA64_PCREL21M
: break;
11193 case BFD_RELOC_IA64_PCREL60B
: break;
11194 case BFD_RELOC_IA64_PCREL22
: break;
11195 case BFD_RELOC_IA64_PCREL64I
: break;
11196 case BFD_RELOC_IA64_PCREL32MSB
: break;
11197 case BFD_RELOC_IA64_PCREL32LSB
: break;
11198 case BFD_RELOC_IA64_PCREL64MSB
: break;
11199 case BFD_RELOC_IA64_PCREL64LSB
: break;
11201 fix
->fx_r_type
= ia64_gen_real_reloc_type (pseudo_func
[FUNC_PC_RELATIVE
].u
.sym
,
11208 switch (fix
->fx_r_type
)
11210 case BFD_RELOC_UNUSED
:
11211 /* This must be a TAG13 or TAG13b operand. There are no external
11212 relocs defined for them, so we must give an error. */
11213 as_bad_where (fix
->fx_file
, fix
->fx_line
,
11214 _("%s must have a constant value"),
11215 elf64_ia64_operands
[fix
->tc_fix_data
.opnd
].desc
);
11219 case BFD_RELOC_IA64_TPREL14
:
11220 case BFD_RELOC_IA64_TPREL22
:
11221 case BFD_RELOC_IA64_TPREL64I
:
11222 case BFD_RELOC_IA64_LTOFF_TPREL22
:
11223 case BFD_RELOC_IA64_LTOFF_DTPMOD22
:
11224 case BFD_RELOC_IA64_DTPREL14
:
11225 case BFD_RELOC_IA64_DTPREL22
:
11226 case BFD_RELOC_IA64_DTPREL64I
:
11227 case BFD_RELOC_IA64_LTOFF_DTPREL22
:
11228 S_SET_THREAD_LOCAL (fix
->fx_addsy
);
11235 else if (fix
->tc_fix_data
.opnd
== IA64_OPND_NIL
)
11237 if (fix
->tc_fix_data
.bigendian
)
11238 number_to_chars_bigendian (fixpos
, value
, fix
->fx_size
);
11240 number_to_chars_littleendian (fixpos
, value
, fix
->fx_size
);
11245 fix_insn (fix
, elf64_ia64_operands
+ fix
->tc_fix_data
.opnd
, value
);
11250 /* Generate the BFD reloc to be stuck in the object file from the
11251 fixup used internally in the assembler. */
11254 tc_gen_reloc (asection
*sec ATTRIBUTE_UNUSED
, fixS
*fixp
)
11258 reloc
= xmalloc (sizeof (*reloc
));
11259 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
11260 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
11261 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
11262 reloc
->addend
= fixp
->fx_offset
;
11263 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
11267 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
11268 _("Cannot represent %s relocation in object file"),
11269 bfd_get_reloc_code_name (fixp
->fx_r_type
));
11276 /* Turn a string in input_line_pointer into a floating point constant
11277 of type TYPE, and store the appropriate bytes in *LIT. The number
11278 of LITTLENUMS emitted is stored in *SIZE. An error message is
11279 returned, or NULL on OK. */
11281 #define MAX_LITTLENUMS 5
11284 md_atof (int type
, char *lit
, int *size
)
11286 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
11316 return _("Unrecognized or unsupported floating point constant");
11318 t
= atof_ieee (input_line_pointer
, type
, words
);
11320 input_line_pointer
= t
;
11322 (*ia64_float_to_chars
) (lit
, words
, prec
);
11326 /* It is 10 byte floating point with 6 byte padding. */
11327 memset (&lit
[10], 0, 6);
11328 *size
= 8 * sizeof (LITTLENUM_TYPE
);
11331 *size
= prec
* sizeof (LITTLENUM_TYPE
);
11336 /* Handle ia64 specific semantics of the align directive. */
11339 ia64_md_do_align (int n ATTRIBUTE_UNUSED
,
11340 const char *fill ATTRIBUTE_UNUSED
,
11341 int len ATTRIBUTE_UNUSED
,
11342 int max ATTRIBUTE_UNUSED
)
11344 if (subseg_text_p (now_seg
))
11345 ia64_flush_insns ();
11348 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
11349 of an rs_align_code fragment. */
11352 ia64_handle_align (fragS
*fragp
)
11356 const unsigned char *nop
;
11358 if (fragp
->fr_type
!= rs_align_code
)
11361 /* Check if this frag has to end with a stop bit. */
11362 nop
= fragp
->tc_frag_data
? le_nop_stop
: le_nop
;
11364 bytes
= fragp
->fr_next
->fr_address
- fragp
->fr_address
- fragp
->fr_fix
;
11365 p
= fragp
->fr_literal
+ fragp
->fr_fix
;
11367 /* If no paddings are needed, we check if we need a stop bit. */
11368 if (!bytes
&& fragp
->tc_frag_data
)
11370 if (fragp
->fr_fix
< 16)
11372 /* FIXME: It won't work with
11374 alloc r32=ar.pfs,1,2,4,0
11378 as_bad_where (fragp
->fr_file
, fragp
->fr_line
,
11379 _("Can't add stop bit to mark end of instruction group"));
11382 /* Bundles are always in little-endian byte order. Make sure
11383 the previous bundle has the stop bit. */
11387 /* Make sure we are on a 16-byte boundary, in case someone has been
11388 putting data into a text section. */
11391 int fix
= bytes
& 15;
11392 memset (p
, 0, fix
);
11395 fragp
->fr_fix
+= fix
;
11398 /* Instruction bundles are always little-endian. */
11399 memcpy (p
, nop
, 16);
11400 fragp
->fr_var
= 16;
11404 ia64_float_to_chars_bigendian (char *lit
, LITTLENUM_TYPE
*words
,
11409 number_to_chars_bigendian (lit
, (long) (*words
++),
11410 sizeof (LITTLENUM_TYPE
));
11411 lit
+= sizeof (LITTLENUM_TYPE
);
11416 ia64_float_to_chars_littleendian (char *lit
, LITTLENUM_TYPE
*words
,
11421 number_to_chars_littleendian (lit
, (long) (words
[prec
]),
11422 sizeof (LITTLENUM_TYPE
));
11423 lit
+= sizeof (LITTLENUM_TYPE
);
11428 ia64_elf_section_change_hook (void)
11430 if (elf_section_type (now_seg
) == SHT_IA_64_UNWIND
11431 && elf_linked_to_section (now_seg
) == NULL
)
11432 elf_linked_to_section (now_seg
) = text_section
;
11433 dot_byteorder (-1);
11436 /* Check if a label should be made global. */
11438 ia64_check_label (symbolS
*label
)
11440 if (*input_line_pointer
== ':')
11442 S_SET_EXTERNAL (label
);
11443 input_line_pointer
++;
11447 /* Used to remember where .alias and .secalias directives are seen. We
11448 will rename symbol and section names when we are about to output
11449 the relocatable file. */
11452 char *file
; /* The file where the directive is seen. */
11453 unsigned int line
; /* The line number the directive is at. */
11454 const char *name
; /* The original name of the symbol. */
11457 /* Called for .alias and .secalias directives. If SECTION is 1, it is
11458 .secalias. Otherwise, it is .alias. */
11460 dot_alias (int section
)
11462 char *name
, *alias
;
11466 const char *error_string
;
11469 struct hash_control
*ahash
, *nhash
;
11472 name
= input_line_pointer
;
11473 delim
= get_symbol_end ();
11474 end_name
= input_line_pointer
;
11477 if (name
== end_name
)
11479 as_bad (_("expected symbol name"));
11480 ignore_rest_of_line ();
11484 SKIP_WHITESPACE ();
11486 if (*input_line_pointer
!= ',')
11489 as_bad (_("expected comma after \"%s\""), name
);
11491 ignore_rest_of_line ();
11495 input_line_pointer
++;
11497 ia64_canonicalize_symbol_name (name
);
11499 /* We call demand_copy_C_string to check if alias string is valid.
11500 There should be a closing `"' and no `\0' in the string. */
11501 alias
= demand_copy_C_string (&len
);
11504 ignore_rest_of_line ();
11508 /* Make a copy of name string. */
11509 len
= strlen (name
) + 1;
11510 obstack_grow (¬es
, name
, len
);
11511 name
= obstack_finish (¬es
);
11516 ahash
= secalias_hash
;
11517 nhash
= secalias_name_hash
;
11522 ahash
= alias_hash
;
11523 nhash
= alias_name_hash
;
11526 /* Check if alias has been used before. */
11527 h
= (struct alias
*) hash_find (ahash
, alias
);
11530 if (strcmp (h
->name
, name
))
11531 as_bad (_("`%s' is already the alias of %s `%s'"),
11532 alias
, kind
, h
->name
);
11536 /* Check if name already has an alias. */
11537 a
= (const char *) hash_find (nhash
, name
);
11540 if (strcmp (a
, alias
))
11541 as_bad (_("%s `%s' already has an alias `%s'"), kind
, name
, a
);
11545 h
= (struct alias
*) xmalloc (sizeof (struct alias
));
11546 as_where (&h
->file
, &h
->line
);
11549 error_string
= hash_jam (ahash
, alias
, (void *) h
);
11552 as_fatal (_("inserting \"%s\" into %s alias hash table failed: %s"),
11553 alias
, kind
, error_string
);
11557 error_string
= hash_jam (nhash
, name
, (void *) alias
);
11560 as_fatal (_("inserting \"%s\" into %s name hash table failed: %s"),
11561 alias
, kind
, error_string
);
11563 obstack_free (¬es
, name
);
11564 obstack_free (¬es
, alias
);
11567 demand_empty_rest_of_line ();
11570 /* It renames the original symbol name to its alias. */
11572 do_alias (const char *alias
, void *value
)
11574 struct alias
*h
= (struct alias
*) value
;
11575 symbolS
*sym
= symbol_find (h
->name
);
11578 as_warn_where (h
->file
, h
->line
,
11579 _("symbol `%s' aliased to `%s' is not used"),
11582 S_SET_NAME (sym
, (char *) alias
);
11585 /* Called from write_object_file. */
11587 ia64_adjust_symtab (void)
11589 hash_traverse (alias_hash
, do_alias
);
11592 /* It renames the original section name to its alias. */
11594 do_secalias (const char *alias
, void *value
)
11596 struct alias
*h
= (struct alias
*) value
;
11597 segT sec
= bfd_get_section_by_name (stdoutput
, h
->name
);
11600 as_warn_where (h
->file
, h
->line
,
11601 _("section `%s' aliased to `%s' is not used"),
11607 /* Called from write_object_file. */
11609 ia64_frob_file (void)
11611 hash_traverse (secalias_hash
, do_secalias
);