1 /* tc-ia64.c -- Assembler for the HP/Intel IA-64 architecture.
2 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004
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 2, 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, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, 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"
54 #define NELEMS(a) ((int) (sizeof (a)/sizeof ((a)[0])))
55 #define MIN(a,b) ((a) < (b) ? (a) : (b))
58 #define PREV_SLOT md.slot[(md.curr_slot + NUM_SLOTS - 1) % NUM_SLOTS]
59 #define CURR_SLOT md.slot[md.curr_slot]
61 #define O_pseudo_fixup (O_max + 1)
65 /* IA-64 ABI section pseudo-ops. */
66 SPECIAL_SECTION_BSS
= 0,
68 SPECIAL_SECTION_SDATA
,
69 SPECIAL_SECTION_RODATA
,
70 SPECIAL_SECTION_COMMENT
,
71 SPECIAL_SECTION_UNWIND
,
72 SPECIAL_SECTION_UNWIND_INFO
,
73 /* HPUX specific section pseudo-ops. */
74 SPECIAL_SECTION_INIT_ARRAY
,
75 SPECIAL_SECTION_FINI_ARRAY
,
92 FUNC_LT_FPTR_RELATIVE
,
102 REG_FR
= (REG_GR
+ 128),
103 REG_AR
= (REG_FR
+ 128),
104 REG_CR
= (REG_AR
+ 128),
105 REG_P
= (REG_CR
+ 128),
106 REG_BR
= (REG_P
+ 64),
107 REG_IP
= (REG_BR
+ 8),
114 /* The following are pseudo-registers for use by gas only. */
126 /* The following pseudo-registers are used for unwind directives only: */
134 DYNREG_GR
= 0, /* dynamic general purpose register */
135 DYNREG_FR
, /* dynamic floating point register */
136 DYNREG_PR
, /* dynamic predicate register */
140 enum operand_match_result
143 OPERAND_OUT_OF_RANGE
,
147 /* On the ia64, we can't know the address of a text label until the
148 instructions are packed into a bundle. To handle this, we keep
149 track of the list of labels that appear in front of each
153 struct label_fix
*next
;
157 /* This is the endianness of the current section. */
158 extern int target_big_endian
;
160 /* This is the default endianness. */
161 static int default_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
163 void (*ia64_number_to_chars
) PARAMS ((char *, valueT
, int));
165 static void ia64_float_to_chars_bigendian
166 PARAMS ((char *, LITTLENUM_TYPE
*, int));
167 static void ia64_float_to_chars_littleendian
168 PARAMS ((char *, LITTLENUM_TYPE
*, int));
169 static void (*ia64_float_to_chars
)
170 PARAMS ((char *, LITTLENUM_TYPE
*, int));
172 static struct hash_control
*alias_hash
;
173 static struct hash_control
*alias_name_hash
;
174 static struct hash_control
*secalias_hash
;
175 static struct hash_control
*secalias_name_hash
;
177 /* Characters which always start a comment. */
178 const char comment_chars
[] = "";
180 /* Characters which start a comment at the beginning of a line. */
181 const char line_comment_chars
[] = "#";
183 /* Characters which may be used to separate multiple commands on a
185 const char line_separator_chars
[] = ";";
187 /* Characters which are used to indicate an exponent in a floating
189 const char EXP_CHARS
[] = "eE";
191 /* Characters which mean that a number is a floating point constant,
193 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
195 /* ia64-specific option processing: */
197 const char *md_shortopts
= "m:N:x::";
199 struct option md_longopts
[] =
201 #define OPTION_MCONSTANT_GP (OPTION_MD_BASE + 1)
202 {"mconstant-gp", no_argument
, NULL
, OPTION_MCONSTANT_GP
},
203 #define OPTION_MAUTO_PIC (OPTION_MD_BASE + 2)
204 {"mauto-pic", no_argument
, NULL
, OPTION_MAUTO_PIC
}
207 size_t md_longopts_size
= sizeof (md_longopts
);
211 struct hash_control
*pseudo_hash
; /* pseudo opcode hash table */
212 struct hash_control
*reg_hash
; /* register name hash table */
213 struct hash_control
*dynreg_hash
; /* dynamic register hash table */
214 struct hash_control
*const_hash
; /* constant hash table */
215 struct hash_control
*entry_hash
; /* code entry hint hash table */
217 symbolS
*regsym
[REG_NUM
];
219 /* If X_op is != O_absent, the registername for the instruction's
220 qualifying predicate. If NULL, p0 is assumed for instructions
221 that are predicatable. */
228 explicit_mode
: 1, /* which mode we're in */
229 default_explicit_mode
: 1, /* which mode is the default */
230 mode_explicitly_set
: 1, /* was the current mode explicitly set? */
232 keep_pending_output
: 1;
234 /* Each bundle consists of up to three instructions. We keep
235 track of four most recent instructions so we can correctly set
236 the end_of_insn_group for the last instruction in a bundle. */
238 int num_slots_in_use
;
242 end_of_insn_group
: 1,
243 manual_bundling_on
: 1,
244 manual_bundling_off
: 1;
245 signed char user_template
; /* user-selected template, if any */
246 unsigned char qp_regno
; /* qualifying predicate */
247 /* This duplicates a good fraction of "struct fix" but we
248 can't use a "struct fix" instead since we can't call
249 fix_new_exp() until we know the address of the instruction. */
253 bfd_reloc_code_real_type code
;
254 enum ia64_opnd opnd
; /* type of operand in need of fix */
255 unsigned int is_pcrel
: 1; /* is operand pc-relative? */
256 expressionS expr
; /* the value to be inserted */
258 fixup
[2]; /* at most two fixups per insn */
259 struct ia64_opcode
*idesc
;
260 struct label_fix
*label_fixups
;
261 struct label_fix
*tag_fixups
;
262 struct unw_rec_list
*unwind_record
; /* Unwind directive. */
265 unsigned int src_line
;
266 struct dwarf2_line_info debug_line
;
274 struct dynreg
*next
; /* next dynamic register */
276 unsigned short base
; /* the base register number */
277 unsigned short num_regs
; /* # of registers in this set */
279 *dynreg
[DYNREG_NUM_TYPES
], in
, loc
, out
, rot
;
281 flagword flags
; /* ELF-header flags */
284 unsigned hint
:1; /* is this hint currently valid? */
285 bfd_vma offset
; /* mem.offset offset */
286 bfd_vma base
; /* mem.offset base */
289 int path
; /* number of alt. entry points seen */
290 const char **entry_labels
; /* labels of all alternate paths in
291 the current DV-checking block. */
292 int maxpaths
; /* size currently allocated for
294 /* Support for hardware errata workarounds. */
296 /* Record data about the last three insn groups. */
299 /* B-step workaround.
300 For each predicate register, this is set if the corresponding insn
301 group conditionally sets this register with one of the affected
304 /* B-step workaround.
305 For each general register, this is set if the corresponding insn
306 a) is conditional one one of the predicate registers for which
307 P_REG_SET is 1 in the corresponding entry of the previous group,
308 b) sets this general register with one of the affected
310 int g_reg_set_conditionally
[128];
314 int pointer_size
; /* size in bytes of a pointer */
315 int pointer_size_shift
; /* shift size of a pointer for alignment */
319 /* application registers: */
325 #define AR_BSPSTORE 18
340 {"ar.k0", 0}, {"ar.k1", 1}, {"ar.k2", 2}, {"ar.k3", 3},
341 {"ar.k4", 4}, {"ar.k5", 5}, {"ar.k6", 6}, {"ar.k7", 7},
342 {"ar.rsc", 16}, {"ar.bsp", 17},
343 {"ar.bspstore", 18}, {"ar.rnat", 19},
344 {"ar.fcr", 21}, {"ar.eflag", 24},
345 {"ar.csd", 25}, {"ar.ssd", 26},
346 {"ar.cflg", 27}, {"ar.fsr", 28},
347 {"ar.fir", 29}, {"ar.fdr", 30},
348 {"ar.ccv", 32}, {"ar.unat", 36},
349 {"ar.fpsr", 40}, {"ar.itc", 44},
350 {"ar.pfs", 64}, {"ar.lc", 65},
371 /* control registers: */
413 static const struct const_desc
420 /* PSR constant masks: */
423 {"psr.be", ((valueT
) 1) << 1},
424 {"psr.up", ((valueT
) 1) << 2},
425 {"psr.ac", ((valueT
) 1) << 3},
426 {"psr.mfl", ((valueT
) 1) << 4},
427 {"psr.mfh", ((valueT
) 1) << 5},
429 {"psr.ic", ((valueT
) 1) << 13},
430 {"psr.i", ((valueT
) 1) << 14},
431 {"psr.pk", ((valueT
) 1) << 15},
433 {"psr.dt", ((valueT
) 1) << 17},
434 {"psr.dfl", ((valueT
) 1) << 18},
435 {"psr.dfh", ((valueT
) 1) << 19},
436 {"psr.sp", ((valueT
) 1) << 20},
437 {"psr.pp", ((valueT
) 1) << 21},
438 {"psr.di", ((valueT
) 1) << 22},
439 {"psr.si", ((valueT
) 1) << 23},
440 {"psr.db", ((valueT
) 1) << 24},
441 {"psr.lp", ((valueT
) 1) << 25},
442 {"psr.tb", ((valueT
) 1) << 26},
443 {"psr.rt", ((valueT
) 1) << 27},
444 /* 28-31: reserved */
445 /* 32-33: cpl (current privilege level) */
446 {"psr.is", ((valueT
) 1) << 34},
447 {"psr.mc", ((valueT
) 1) << 35},
448 {"psr.it", ((valueT
) 1) << 36},
449 {"psr.id", ((valueT
) 1) << 37},
450 {"psr.da", ((valueT
) 1) << 38},
451 {"psr.dd", ((valueT
) 1) << 39},
452 {"psr.ss", ((valueT
) 1) << 40},
453 /* 41-42: ri (restart instruction) */
454 {"psr.ed", ((valueT
) 1) << 43},
455 {"psr.bn", ((valueT
) 1) << 44},
458 /* indirect register-sets/memory: */
467 { "CPUID", IND_CPUID
},
468 { "cpuid", IND_CPUID
},
480 /* Pseudo functions used to indicate relocation types (these functions
481 start with an at sign (@). */
503 /* reloc pseudo functions (these must come first!): */
504 { "dtpmod", PSEUDO_FUNC_RELOC
, { 0 } },
505 { "dtprel", PSEUDO_FUNC_RELOC
, { 0 } },
506 { "fptr", PSEUDO_FUNC_RELOC
, { 0 } },
507 { "gprel", PSEUDO_FUNC_RELOC
, { 0 } },
508 { "ltoff", PSEUDO_FUNC_RELOC
, { 0 } },
509 { "ltoffx", PSEUDO_FUNC_RELOC
, { 0 } },
510 { "pcrel", PSEUDO_FUNC_RELOC
, { 0 } },
511 { "pltoff", PSEUDO_FUNC_RELOC
, { 0 } },
512 { "secrel", PSEUDO_FUNC_RELOC
, { 0 } },
513 { "segrel", PSEUDO_FUNC_RELOC
, { 0 } },
514 { "tprel", PSEUDO_FUNC_RELOC
, { 0 } },
515 { "ltv", PSEUDO_FUNC_RELOC
, { 0 } },
516 { "", 0, { 0 } }, /* placeholder for FUNC_LT_FPTR_RELATIVE */
517 { "", 0, { 0 } }, /* placeholder for FUNC_LT_DTP_MODULE */
518 { "", 0, { 0 } }, /* placeholder for FUNC_LT_DTP_RELATIVE */
519 { "", 0, { 0 } }, /* placeholder for FUNC_LT_TP_RELATIVE */
520 { "iplt", PSEUDO_FUNC_RELOC
, { 0 } },
522 /* mbtype4 constants: */
523 { "alt", PSEUDO_FUNC_CONST
, { 0xa } },
524 { "brcst", PSEUDO_FUNC_CONST
, { 0x0 } },
525 { "mix", PSEUDO_FUNC_CONST
, { 0x8 } },
526 { "rev", PSEUDO_FUNC_CONST
, { 0xb } },
527 { "shuf", PSEUDO_FUNC_CONST
, { 0x9 } },
529 /* fclass constants: */
530 { "nat", PSEUDO_FUNC_CONST
, { 0x100 } },
531 { "qnan", PSEUDO_FUNC_CONST
, { 0x080 } },
532 { "snan", PSEUDO_FUNC_CONST
, { 0x040 } },
533 { "pos", PSEUDO_FUNC_CONST
, { 0x001 } },
534 { "neg", PSEUDO_FUNC_CONST
, { 0x002 } },
535 { "zero", PSEUDO_FUNC_CONST
, { 0x004 } },
536 { "unorm", PSEUDO_FUNC_CONST
, { 0x008 } },
537 { "norm", PSEUDO_FUNC_CONST
, { 0x010 } },
538 { "inf", PSEUDO_FUNC_CONST
, { 0x020 } },
540 { "natval", PSEUDO_FUNC_CONST
, { 0x100 } }, /* old usage */
542 /* hint constants: */
543 { "pause", PSEUDO_FUNC_CONST
, { 0x0 } },
545 /* unwind-related constants: */
546 { "svr4", PSEUDO_FUNC_CONST
, { ELFOSABI_NONE
} },
547 { "hpux", PSEUDO_FUNC_CONST
, { ELFOSABI_HPUX
} },
548 { "nt", PSEUDO_FUNC_CONST
, { 2 } }, /* conflicts w/ELFOSABI_NETBSD */
549 { "linux", PSEUDO_FUNC_CONST
, { ELFOSABI_LINUX
} },
550 { "freebsd", PSEUDO_FUNC_CONST
, { ELFOSABI_FREEBSD
} },
551 { "openvms", PSEUDO_FUNC_CONST
, { ELFOSABI_OPENVMS
} },
552 { "nsk", PSEUDO_FUNC_CONST
, { ELFOSABI_NSK
} },
554 /* unwind-related registers: */
555 { "priunat",PSEUDO_FUNC_REG
, { REG_PRIUNAT
} }
558 /* 41-bit nop opcodes (one per unit): */
559 static const bfd_vma nop
[IA64_NUM_UNITS
] =
561 0x0000000000LL
, /* NIL => break 0 */
562 0x0008000000LL
, /* I-unit nop */
563 0x0008000000LL
, /* M-unit nop */
564 0x4000000000LL
, /* B-unit nop */
565 0x0008000000LL
, /* F-unit nop */
566 0x0008000000LL
, /* L-"unit" nop */
567 0x0008000000LL
, /* X-unit nop */
570 /* Can't be `const' as it's passed to input routines (which have the
571 habit of setting temporary sentinels. */
572 static char special_section_name
[][20] =
574 {".bss"}, {".sbss"}, {".sdata"}, {".rodata"}, {".comment"},
575 {".IA_64.unwind"}, {".IA_64.unwind_info"},
576 {".init_array"}, {".fini_array"}
579 /* The best template for a particular sequence of up to three
581 #define N IA64_NUM_TYPES
582 static unsigned char best_template
[N
][N
][N
];
585 /* Resource dependencies currently in effect */
587 int depind
; /* dependency index */
588 const struct ia64_dependency
*dependency
; /* actual dependency */
589 unsigned specific
:1, /* is this a specific bit/regno? */
590 link_to_qp_branch
:1; /* will a branch on the same QP clear it?*/
591 int index
; /* specific regno/bit within dependency */
592 int note
; /* optional qualifying note (0 if none) */
596 int insn_srlz
; /* current insn serialization state */
597 int data_srlz
; /* current data serialization state */
598 int qp_regno
; /* qualifying predicate for this usage */
599 char *file
; /* what file marked this dependency */
600 unsigned int line
; /* what line marked this dependency */
601 struct mem_offset mem_offset
; /* optional memory offset hint */
602 enum { CMP_NONE
, CMP_OR
, CMP_AND
} cmp_type
; /* OR or AND compare? */
603 int path
; /* corresponding code entry index */
605 static int regdepslen
= 0;
606 static int regdepstotlen
= 0;
607 static const char *dv_mode
[] = { "RAW", "WAW", "WAR" };
608 static const char *dv_sem
[] = { "none", "implied", "impliedf",
609 "data", "instr", "specific", "stop", "other" };
610 static const char *dv_cmp_type
[] = { "none", "OR", "AND" };
612 /* Current state of PR mutexation */
613 static struct qpmutex
{
616 } *qp_mutexes
= NULL
; /* QP mutex bitmasks */
617 static int qp_mutexeslen
= 0;
618 static int qp_mutexestotlen
= 0;
619 static valueT qp_safe_across_calls
= 0;
621 /* Current state of PR implications */
622 static struct qp_imply
{
625 unsigned p2_branched
:1;
627 } *qp_implies
= NULL
;
628 static int qp_implieslen
= 0;
629 static int qp_impliestotlen
= 0;
631 /* Keep track of static GR values so that indirect register usage can
632 sometimes be tracked. */
637 } gr_values
[128] = {{ 1, 0, 0 }};
639 /* Remember the alignment frag. */
640 static fragS
*align_frag
;
642 /* These are the routines required to output the various types of
645 /* A slot_number is a frag address plus the slot index (0-2). We use the
646 frag address here so that if there is a section switch in the middle of
647 a function, then instructions emitted to a different section are not
648 counted. Since there may be more than one frag for a function, this
649 means we also need to keep track of which frag this address belongs to
650 so we can compute inter-frag distances. This also nicely solves the
651 problem with nops emitted for align directives, which can't easily be
652 counted, but can easily be derived from frag sizes. */
654 typedef struct unw_rec_list
{
656 unsigned long slot_number
;
658 unsigned long next_slot_number
;
659 fragS
*next_slot_frag
;
660 struct unw_rec_list
*next
;
663 #define SLOT_NUM_NOT_SET (unsigned)-1
665 /* Linked list of saved prologue counts. A very poor
666 implementation of a map from label numbers to prologue counts. */
667 typedef struct label_prologue_count
669 struct label_prologue_count
*next
;
670 unsigned long label_number
;
671 unsigned int prologue_count
;
672 } label_prologue_count
;
676 /* Maintain a list of unwind entries for the current function. */
680 /* Any unwind entires that should be attached to the current slot
681 that an insn is being constructed for. */
682 unw_rec_list
*current_entry
;
684 /* These are used to create the unwind table entry for this function. */
687 symbolS
*info
; /* pointer to unwind info */
688 symbolS
*personality_routine
;
690 subsegT saved_text_subseg
;
691 unsigned int force_unwind_entry
: 1; /* force generation of unwind entry? */
693 /* TRUE if processing unwind directives in a prologue region. */
696 unsigned int prologue_count
; /* number of .prologues seen so far */
697 /* Prologue counts at previous .label_state directives. */
698 struct label_prologue_count
* saved_prologue_counts
;
701 typedef void (*vbyte_func
) PARAMS ((int, char *, char *));
703 /* Forward declarations: */
704 static void set_section
PARAMS ((char *name
));
705 static unsigned int set_regstack
PARAMS ((unsigned int, unsigned int,
706 unsigned int, unsigned int));
707 static void dot_align (int);
708 static void dot_radix
PARAMS ((int));
709 static void dot_special_section
PARAMS ((int));
710 static void dot_proc
PARAMS ((int));
711 static void dot_fframe
PARAMS ((int));
712 static void dot_vframe
PARAMS ((int));
713 static void dot_vframesp
PARAMS ((int));
714 static void dot_vframepsp
PARAMS ((int));
715 static void dot_save
PARAMS ((int));
716 static void dot_restore
PARAMS ((int));
717 static void dot_restorereg
PARAMS ((int));
718 static void dot_restorereg_p
PARAMS ((int));
719 static void dot_handlerdata
PARAMS ((int));
720 static void dot_unwentry
PARAMS ((int));
721 static void dot_altrp
PARAMS ((int));
722 static void dot_savemem
PARAMS ((int));
723 static void dot_saveg
PARAMS ((int));
724 static void dot_savef
PARAMS ((int));
725 static void dot_saveb
PARAMS ((int));
726 static void dot_savegf
PARAMS ((int));
727 static void dot_spill
PARAMS ((int));
728 static void dot_spillreg
PARAMS ((int));
729 static void dot_spillmem
PARAMS ((int));
730 static void dot_spillreg_p
PARAMS ((int));
731 static void dot_spillmem_p
PARAMS ((int));
732 static void dot_label_state
PARAMS ((int));
733 static void dot_copy_state
PARAMS ((int));
734 static void dot_unwabi
PARAMS ((int));
735 static void dot_personality
PARAMS ((int));
736 static void dot_body
PARAMS ((int));
737 static void dot_prologue
PARAMS ((int));
738 static void dot_endp
PARAMS ((int));
739 static void dot_template
PARAMS ((int));
740 static void dot_regstk
PARAMS ((int));
741 static void dot_rot
PARAMS ((int));
742 static void dot_byteorder
PARAMS ((int));
743 static void dot_psr
PARAMS ((int));
744 static void dot_alias
PARAMS ((int));
745 static void dot_ln
PARAMS ((int));
746 static char *parse_section_name
PARAMS ((void));
747 static void dot_xdata
PARAMS ((int));
748 static void stmt_float_cons
PARAMS ((int));
749 static void stmt_cons_ua
PARAMS ((int));
750 static void dot_xfloat_cons
PARAMS ((int));
751 static void dot_xstringer
PARAMS ((int));
752 static void dot_xdata_ua
PARAMS ((int));
753 static void dot_xfloat_cons_ua
PARAMS ((int));
754 static void print_prmask
PARAMS ((valueT mask
));
755 static void dot_pred_rel
PARAMS ((int));
756 static void dot_reg_val
PARAMS ((int));
757 static void dot_serialize
PARAMS ((int));
758 static void dot_dv_mode
PARAMS ((int));
759 static void dot_entry
PARAMS ((int));
760 static void dot_mem_offset
PARAMS ((int));
761 static void add_unwind_entry
PARAMS((unw_rec_list
*ptr
));
762 static symbolS
*declare_register
PARAMS ((const char *name
, int regnum
));
763 static void declare_register_set
PARAMS ((const char *, int, int));
764 static unsigned int operand_width
PARAMS ((enum ia64_opnd
));
765 static enum operand_match_result operand_match
PARAMS ((const struct ia64_opcode
*idesc
,
768 static int parse_operand
PARAMS ((expressionS
*e
));
769 static struct ia64_opcode
* parse_operands
PARAMS ((struct ia64_opcode
*));
770 static int errata_nop_necessary_p
PARAMS ((struct slot
*, enum ia64_unit
));
771 static void build_insn
PARAMS ((struct slot
*, bfd_vma
*));
772 static void emit_one_bundle
PARAMS ((void));
773 static void fix_insn
PARAMS ((fixS
*, const struct ia64_operand
*, valueT
));
774 static bfd_reloc_code_real_type ia64_gen_real_reloc_type
PARAMS ((struct symbol
*sym
,
775 bfd_reloc_code_real_type r_type
));
776 static void insn_group_break
PARAMS ((int, int, int));
777 static void mark_resource
PARAMS ((struct ia64_opcode
*, const struct ia64_dependency
*,
778 struct rsrc
*, int depind
, int path
));
779 static void add_qp_mutex
PARAMS((valueT mask
));
780 static void add_qp_imply
PARAMS((int p1
, int p2
));
781 static void clear_qp_branch_flag
PARAMS((valueT mask
));
782 static void clear_qp_mutex
PARAMS((valueT mask
));
783 static void clear_qp_implies
PARAMS((valueT p1_mask
, valueT p2_mask
));
784 static int has_suffix_p
PARAMS((const char *, const char *));
785 static void clear_register_values
PARAMS ((void));
786 static void print_dependency
PARAMS ((const char *action
, int depind
));
787 static void instruction_serialization
PARAMS ((void));
788 static void data_serialization
PARAMS ((void));
789 static void remove_marked_resource
PARAMS ((struct rsrc
*));
790 static int is_conditional_branch
PARAMS ((struct ia64_opcode
*));
791 static int is_taken_branch
PARAMS ((struct ia64_opcode
*));
792 static int is_interruption_or_rfi
PARAMS ((struct ia64_opcode
*));
793 static int depends_on
PARAMS ((int, struct ia64_opcode
*));
794 static int specify_resource
PARAMS ((const struct ia64_dependency
*,
795 struct ia64_opcode
*, int, struct rsrc
[], int, int));
796 static int check_dv
PARAMS((struct ia64_opcode
*idesc
));
797 static void check_dependencies
PARAMS((struct ia64_opcode
*));
798 static void mark_resources
PARAMS((struct ia64_opcode
*));
799 static void update_dependencies
PARAMS((struct ia64_opcode
*));
800 static void note_register_values
PARAMS((struct ia64_opcode
*));
801 static int qp_mutex
PARAMS ((int, int, int));
802 static int resources_match
PARAMS ((struct rsrc
*, struct ia64_opcode
*, int, int, int));
803 static void output_vbyte_mem
PARAMS ((int, char *, char *));
804 static void count_output
PARAMS ((int, char *, char *));
805 static void output_R1_format
PARAMS ((vbyte_func
, unw_record_type
, int));
806 static void output_R2_format
PARAMS ((vbyte_func
, int, int, unsigned long));
807 static void output_R3_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
808 static void output_P1_format
PARAMS ((vbyte_func
, int));
809 static void output_P2_format
PARAMS ((vbyte_func
, int, int));
810 static void output_P3_format
PARAMS ((vbyte_func
, unw_record_type
, int));
811 static void output_P4_format
PARAMS ((vbyte_func
, unsigned char *, unsigned long));
812 static void output_P5_format
PARAMS ((vbyte_func
, int, unsigned long));
813 static void output_P6_format
PARAMS ((vbyte_func
, unw_record_type
, int));
814 static void output_P7_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long, unsigned long));
815 static void output_P8_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
816 static void output_P9_format
PARAMS ((vbyte_func
, int, int));
817 static void output_P10_format
PARAMS ((vbyte_func
, int, int));
818 static void output_B1_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
819 static void output_B2_format
PARAMS ((vbyte_func
, unsigned long, unsigned long));
820 static void output_B3_format
PARAMS ((vbyte_func
, unsigned long, unsigned long));
821 static void output_B4_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
822 static char format_ab_reg
PARAMS ((int, int));
823 static void output_X1_format
PARAMS ((vbyte_func
, unw_record_type
, int, int, unsigned long,
825 static void output_X2_format
PARAMS ((vbyte_func
, int, int, int, int, int, unsigned long));
826 static void output_X3_format
PARAMS ((vbyte_func
, unw_record_type
, int, int, int, unsigned long,
828 static void output_X4_format
PARAMS ((vbyte_func
, int, int, int, int, int, int, unsigned long));
829 static unw_rec_list
*output_endp
PARAMS ((void));
830 static unw_rec_list
*output_prologue
PARAMS ((void));
831 static unw_rec_list
*output_prologue_gr
PARAMS ((unsigned int, unsigned int));
832 static unw_rec_list
*output_body
PARAMS ((void));
833 static unw_rec_list
*output_mem_stack_f
PARAMS ((unsigned int));
834 static unw_rec_list
*output_mem_stack_v
PARAMS ((void));
835 static unw_rec_list
*output_psp_gr
PARAMS ((unsigned int));
836 static unw_rec_list
*output_psp_sprel
PARAMS ((unsigned int));
837 static unw_rec_list
*output_rp_when
PARAMS ((void));
838 static unw_rec_list
*output_rp_gr
PARAMS ((unsigned int));
839 static unw_rec_list
*output_rp_br
PARAMS ((unsigned int));
840 static unw_rec_list
*output_rp_psprel
PARAMS ((unsigned int));
841 static unw_rec_list
*output_rp_sprel
PARAMS ((unsigned int));
842 static unw_rec_list
*output_pfs_when
PARAMS ((void));
843 static unw_rec_list
*output_pfs_gr
PARAMS ((unsigned int));
844 static unw_rec_list
*output_pfs_psprel
PARAMS ((unsigned int));
845 static unw_rec_list
*output_pfs_sprel
PARAMS ((unsigned int));
846 static unw_rec_list
*output_preds_when
PARAMS ((void));
847 static unw_rec_list
*output_preds_gr
PARAMS ((unsigned int));
848 static unw_rec_list
*output_preds_psprel
PARAMS ((unsigned int));
849 static unw_rec_list
*output_preds_sprel
PARAMS ((unsigned int));
850 static unw_rec_list
*output_fr_mem
PARAMS ((unsigned int));
851 static unw_rec_list
*output_frgr_mem
PARAMS ((unsigned int, unsigned int));
852 static unw_rec_list
*output_gr_gr
PARAMS ((unsigned int, unsigned int));
853 static unw_rec_list
*output_gr_mem
PARAMS ((unsigned int));
854 static unw_rec_list
*output_br_mem
PARAMS ((unsigned int));
855 static unw_rec_list
*output_br_gr
PARAMS ((unsigned int, unsigned int));
856 static unw_rec_list
*output_spill_base
PARAMS ((unsigned int));
857 static unw_rec_list
*output_unat_when
PARAMS ((void));
858 static unw_rec_list
*output_unat_gr
PARAMS ((unsigned int));
859 static unw_rec_list
*output_unat_psprel
PARAMS ((unsigned int));
860 static unw_rec_list
*output_unat_sprel
PARAMS ((unsigned int));
861 static unw_rec_list
*output_lc_when
PARAMS ((void));
862 static unw_rec_list
*output_lc_gr
PARAMS ((unsigned int));
863 static unw_rec_list
*output_lc_psprel
PARAMS ((unsigned int));
864 static unw_rec_list
*output_lc_sprel
PARAMS ((unsigned int));
865 static unw_rec_list
*output_fpsr_when
PARAMS ((void));
866 static unw_rec_list
*output_fpsr_gr
PARAMS ((unsigned int));
867 static unw_rec_list
*output_fpsr_psprel
PARAMS ((unsigned int));
868 static unw_rec_list
*output_fpsr_sprel
PARAMS ((unsigned int));
869 static unw_rec_list
*output_priunat_when_gr
PARAMS ((void));
870 static unw_rec_list
*output_priunat_when_mem
PARAMS ((void));
871 static unw_rec_list
*output_priunat_gr
PARAMS ((unsigned int));
872 static unw_rec_list
*output_priunat_psprel
PARAMS ((unsigned int));
873 static unw_rec_list
*output_priunat_sprel
PARAMS ((unsigned int));
874 static unw_rec_list
*output_bsp_when
PARAMS ((void));
875 static unw_rec_list
*output_bsp_gr
PARAMS ((unsigned int));
876 static unw_rec_list
*output_bsp_psprel
PARAMS ((unsigned int));
877 static unw_rec_list
*output_bsp_sprel
PARAMS ((unsigned int));
878 static unw_rec_list
*output_bspstore_when
PARAMS ((void));
879 static unw_rec_list
*output_bspstore_gr
PARAMS ((unsigned int));
880 static unw_rec_list
*output_bspstore_psprel
PARAMS ((unsigned int));
881 static unw_rec_list
*output_bspstore_sprel
PARAMS ((unsigned int));
882 static unw_rec_list
*output_rnat_when
PARAMS ((void));
883 static unw_rec_list
*output_rnat_gr
PARAMS ((unsigned int));
884 static unw_rec_list
*output_rnat_psprel
PARAMS ((unsigned int));
885 static unw_rec_list
*output_rnat_sprel
PARAMS ((unsigned int));
886 static unw_rec_list
*output_unwabi
PARAMS ((unsigned long, unsigned long));
887 static unw_rec_list
*output_epilogue
PARAMS ((unsigned long));
888 static unw_rec_list
*output_label_state
PARAMS ((unsigned long));
889 static unw_rec_list
*output_copy_state
PARAMS ((unsigned long));
890 static unw_rec_list
*output_spill_psprel
PARAMS ((unsigned int, unsigned int, unsigned int));
891 static unw_rec_list
*output_spill_sprel
PARAMS ((unsigned int, unsigned int, unsigned int));
892 static unw_rec_list
*output_spill_psprel_p
PARAMS ((unsigned int, unsigned int, unsigned int,
894 static unw_rec_list
*output_spill_sprel_p
PARAMS ((unsigned int, unsigned int, unsigned int,
896 static unw_rec_list
*output_spill_reg
PARAMS ((unsigned int, unsigned int, unsigned int,
898 static unw_rec_list
*output_spill_reg_p
PARAMS ((unsigned int, unsigned int, unsigned int,
899 unsigned int, unsigned int));
900 static void process_one_record
PARAMS ((unw_rec_list
*, vbyte_func
));
901 static void process_unw_records
PARAMS ((unw_rec_list
*, vbyte_func
));
902 static int calc_record_size
PARAMS ((unw_rec_list
*));
903 static void set_imask
PARAMS ((unw_rec_list
*, unsigned long, unsigned long, unsigned int));
904 static unsigned long slot_index
PARAMS ((unsigned long, fragS
*,
905 unsigned long, fragS
*,
907 static unw_rec_list
*optimize_unw_records
PARAMS ((unw_rec_list
*));
908 static void fixup_unw_records
PARAMS ((unw_rec_list
*, int));
909 static int convert_expr_to_ab_reg
PARAMS ((expressionS
*, unsigned int *, unsigned int *));
910 static int convert_expr_to_xy_reg
PARAMS ((expressionS
*, unsigned int *, unsigned int *));
911 static unsigned int get_saved_prologue_count
PARAMS ((unsigned long));
912 static void save_prologue_count
PARAMS ((unsigned long, unsigned int));
913 static void free_saved_prologue_counts
PARAMS ((void));
915 /* Determine if application register REGNUM resides only in the integer
916 unit (as opposed to the memory unit). */
918 ar_is_only_in_integer_unit (int reg
)
921 return reg
>= 64 && reg
<= 111;
924 /* Determine if application register REGNUM resides only in the memory
925 unit (as opposed to the integer unit). */
927 ar_is_only_in_memory_unit (int reg
)
930 return reg
>= 0 && reg
<= 47;
933 /* Switch to section NAME and create section if necessary. It's
934 rather ugly that we have to manipulate input_line_pointer but I
935 don't see any other way to accomplish the same thing without
936 changing obj-elf.c (which may be the Right Thing, in the end). */
941 char *saved_input_line_pointer
;
943 saved_input_line_pointer
= input_line_pointer
;
944 input_line_pointer
= name
;
946 input_line_pointer
= saved_input_line_pointer
;
949 /* Map 's' to SHF_IA_64_SHORT. */
952 ia64_elf_section_letter (letter
, ptr_msg
)
957 return SHF_IA_64_SHORT
;
958 else if (letter
== 'o')
959 return SHF_LINK_ORDER
;
961 *ptr_msg
= _("Bad .section directive: want a,o,s,w,x,M,S,G,T in string");
965 /* Map SHF_IA_64_SHORT to SEC_SMALL_DATA. */
968 ia64_elf_section_flags (flags
, attr
, type
)
970 int attr
, type ATTRIBUTE_UNUSED
;
972 if (attr
& SHF_IA_64_SHORT
)
973 flags
|= SEC_SMALL_DATA
;
978 ia64_elf_section_type (str
, len
)
982 #define STREQ(s) ((len == sizeof (s) - 1) && (strncmp (str, s, sizeof (s) - 1) == 0))
984 if (STREQ (ELF_STRING_ia64_unwind_info
))
987 if (STREQ (ELF_STRING_ia64_unwind_info_once
))
990 if (STREQ (ELF_STRING_ia64_unwind
))
991 return SHT_IA_64_UNWIND
;
993 if (STREQ (ELF_STRING_ia64_unwind_once
))
994 return SHT_IA_64_UNWIND
;
996 if (STREQ ("unwind"))
997 return SHT_IA_64_UNWIND
;
1004 set_regstack (ins
, locs
, outs
, rots
)
1005 unsigned int ins
, locs
, outs
, rots
;
1007 /* Size of frame. */
1010 sof
= ins
+ locs
+ outs
;
1013 as_bad ("Size of frame exceeds maximum of 96 registers");
1018 as_warn ("Size of rotating registers exceeds frame size");
1021 md
.in
.base
= REG_GR
+ 32;
1022 md
.loc
.base
= md
.in
.base
+ ins
;
1023 md
.out
.base
= md
.loc
.base
+ locs
;
1025 md
.in
.num_regs
= ins
;
1026 md
.loc
.num_regs
= locs
;
1027 md
.out
.num_regs
= outs
;
1028 md
.rot
.num_regs
= rots
;
1035 struct label_fix
*lfix
;
1037 subsegT saved_subseg
;
1040 if (!md
.last_text_seg
)
1043 saved_seg
= now_seg
;
1044 saved_subseg
= now_subseg
;
1046 subseg_set (md
.last_text_seg
, 0);
1048 while (md
.num_slots_in_use
> 0)
1049 emit_one_bundle (); /* force out queued instructions */
1051 /* In case there are labels following the last instruction, resolve
1053 for (lfix
= CURR_SLOT
.label_fixups
; lfix
; lfix
= lfix
->next
)
1055 S_SET_VALUE (lfix
->sym
, frag_now_fix ());
1056 symbol_set_frag (lfix
->sym
, frag_now
);
1058 CURR_SLOT
.label_fixups
= 0;
1059 for (lfix
= CURR_SLOT
.tag_fixups
; lfix
; lfix
= lfix
->next
)
1061 S_SET_VALUE (lfix
->sym
, frag_now_fix ());
1062 symbol_set_frag (lfix
->sym
, frag_now
);
1064 CURR_SLOT
.tag_fixups
= 0;
1066 /* In case there are unwind directives following the last instruction,
1067 resolve those now. We only handle prologue, body, and endp directives
1068 here. Give an error for others. */
1069 for (ptr
= unwind
.current_entry
; ptr
; ptr
= ptr
->next
)
1071 switch (ptr
->r
.type
)
1077 ptr
->slot_number
= (unsigned long) frag_more (0);
1078 ptr
->slot_frag
= frag_now
;
1081 /* Allow any record which doesn't have a "t" field (i.e.,
1082 doesn't relate to a particular instruction). */
1098 as_bad (_("Unwind directive not followed by an instruction."));
1102 unwind
.current_entry
= NULL
;
1104 subseg_set (saved_seg
, saved_subseg
);
1106 if (md
.qp
.X_op
== O_register
)
1107 as_bad ("qualifying predicate not followed by instruction");
1111 ia64_do_align (int nbytes
)
1113 char *saved_input_line_pointer
= input_line_pointer
;
1115 input_line_pointer
= "";
1116 s_align_bytes (nbytes
);
1117 input_line_pointer
= saved_input_line_pointer
;
1121 ia64_cons_align (nbytes
)
1126 char *saved_input_line_pointer
= input_line_pointer
;
1127 input_line_pointer
= "";
1128 s_align_bytes (nbytes
);
1129 input_line_pointer
= saved_input_line_pointer
;
1133 /* Output COUNT bytes to a memory location. */
1134 static unsigned char *vbyte_mem_ptr
= NULL
;
1137 output_vbyte_mem (count
, ptr
, comment
)
1140 char *comment ATTRIBUTE_UNUSED
;
1143 if (vbyte_mem_ptr
== NULL
)
1148 for (x
= 0; x
< count
; x
++)
1149 *(vbyte_mem_ptr
++) = ptr
[x
];
1152 /* Count the number of bytes required for records. */
1153 static int vbyte_count
= 0;
1155 count_output (count
, ptr
, comment
)
1157 char *ptr ATTRIBUTE_UNUSED
;
1158 char *comment ATTRIBUTE_UNUSED
;
1160 vbyte_count
+= count
;
1164 output_R1_format (f
, rtype
, rlen
)
1166 unw_record_type rtype
;
1173 output_R3_format (f
, rtype
, rlen
);
1179 else if (rtype
!= prologue
)
1180 as_bad ("record type is not valid");
1182 byte
= UNW_R1
| (r
<< 5) | (rlen
& 0x1f);
1183 (*f
) (1, &byte
, NULL
);
1187 output_R2_format (f
, mask
, grsave
, rlen
)
1194 mask
= (mask
& 0x0f);
1195 grsave
= (grsave
& 0x7f);
1197 bytes
[0] = (UNW_R2
| (mask
>> 1));
1198 bytes
[1] = (((mask
& 0x01) << 7) | grsave
);
1199 count
+= output_leb128 (bytes
+ 2, rlen
, 0);
1200 (*f
) (count
, bytes
, NULL
);
1204 output_R3_format (f
, rtype
, rlen
)
1206 unw_record_type rtype
;
1213 output_R1_format (f
, rtype
, rlen
);
1219 else if (rtype
!= prologue
)
1220 as_bad ("record type is not valid");
1221 bytes
[0] = (UNW_R3
| r
);
1222 count
= output_leb128 (bytes
+ 1, rlen
, 0);
1223 (*f
) (count
+ 1, bytes
, NULL
);
1227 output_P1_format (f
, brmask
)
1232 byte
= UNW_P1
| (brmask
& 0x1f);
1233 (*f
) (1, &byte
, NULL
);
1237 output_P2_format (f
, brmask
, gr
)
1243 brmask
= (brmask
& 0x1f);
1244 bytes
[0] = UNW_P2
| (brmask
>> 1);
1245 bytes
[1] = (((brmask
& 1) << 7) | gr
);
1246 (*f
) (2, bytes
, NULL
);
1250 output_P3_format (f
, rtype
, reg
)
1252 unw_record_type rtype
;
1297 as_bad ("Invalid record type for P3 format.");
1299 bytes
[0] = (UNW_P3
| (r
>> 1));
1300 bytes
[1] = (((r
& 1) << 7) | reg
);
1301 (*f
) (2, bytes
, NULL
);
1305 output_P4_format (f
, imask
, imask_size
)
1307 unsigned char *imask
;
1308 unsigned long imask_size
;
1311 (*f
) (imask_size
, imask
, NULL
);
1315 output_P5_format (f
, grmask
, frmask
)
1318 unsigned long frmask
;
1321 grmask
= (grmask
& 0x0f);
1324 bytes
[1] = ((grmask
<< 4) | ((frmask
& 0x000f0000) >> 16));
1325 bytes
[2] = ((frmask
& 0x0000ff00) >> 8);
1326 bytes
[3] = (frmask
& 0x000000ff);
1327 (*f
) (4, bytes
, NULL
);
1331 output_P6_format (f
, rtype
, rmask
)
1333 unw_record_type rtype
;
1339 if (rtype
== gr_mem
)
1341 else if (rtype
!= fr_mem
)
1342 as_bad ("Invalid record type for format P6");
1343 byte
= (UNW_P6
| (r
<< 4) | (rmask
& 0x0f));
1344 (*f
) (1, &byte
, NULL
);
1348 output_P7_format (f
, rtype
, w1
, w2
)
1350 unw_record_type rtype
;
1357 count
+= output_leb128 (bytes
+ 1, w1
, 0);
1362 count
+= output_leb128 (bytes
+ count
, w2
>> 4, 0);
1412 bytes
[0] = (UNW_P7
| r
);
1413 (*f
) (count
, bytes
, NULL
);
1417 output_P8_format (f
, rtype
, t
)
1419 unw_record_type rtype
;
1458 case bspstore_psprel
:
1461 case bspstore_sprel
:
1473 case priunat_when_gr
:
1476 case priunat_psprel
:
1482 case priunat_when_mem
:
1489 count
+= output_leb128 (bytes
+ 2, t
, 0);
1490 (*f
) (count
, bytes
, NULL
);
1494 output_P9_format (f
, grmask
, gr
)
1501 bytes
[1] = (grmask
& 0x0f);
1502 bytes
[2] = (gr
& 0x7f);
1503 (*f
) (3, bytes
, NULL
);
1507 output_P10_format (f
, abi
, context
)
1514 bytes
[1] = (abi
& 0xff);
1515 bytes
[2] = (context
& 0xff);
1516 (*f
) (3, bytes
, NULL
);
1520 output_B1_format (f
, rtype
, label
)
1522 unw_record_type rtype
;
1523 unsigned long label
;
1529 output_B4_format (f
, rtype
, label
);
1532 if (rtype
== copy_state
)
1534 else if (rtype
!= label_state
)
1535 as_bad ("Invalid record type for format B1");
1537 byte
= (UNW_B1
| (r
<< 5) | (label
& 0x1f));
1538 (*f
) (1, &byte
, NULL
);
1542 output_B2_format (f
, ecount
, t
)
1544 unsigned long ecount
;
1551 output_B3_format (f
, ecount
, t
);
1554 bytes
[0] = (UNW_B2
| (ecount
& 0x1f));
1555 count
+= output_leb128 (bytes
+ 1, t
, 0);
1556 (*f
) (count
, bytes
, NULL
);
1560 output_B3_format (f
, ecount
, t
)
1562 unsigned long ecount
;
1569 output_B2_format (f
, ecount
, t
);
1573 count
+= output_leb128 (bytes
+ 1, t
, 0);
1574 count
+= output_leb128 (bytes
+ count
, ecount
, 0);
1575 (*f
) (count
, bytes
, NULL
);
1579 output_B4_format (f
, rtype
, label
)
1581 unw_record_type rtype
;
1582 unsigned long label
;
1589 output_B1_format (f
, rtype
, label
);
1593 if (rtype
== copy_state
)
1595 else if (rtype
!= label_state
)
1596 as_bad ("Invalid record type for format B1");
1598 bytes
[0] = (UNW_B4
| (r
<< 3));
1599 count
+= output_leb128 (bytes
+ 1, label
, 0);
1600 (*f
) (count
, bytes
, NULL
);
1604 format_ab_reg (ab
, reg
)
1611 ret
= (ab
<< 5) | reg
;
1616 output_X1_format (f
, rtype
, ab
, reg
, t
, w1
)
1618 unw_record_type rtype
;
1628 if (rtype
== spill_sprel
)
1630 else if (rtype
!= spill_psprel
)
1631 as_bad ("Invalid record type for format X1");
1632 bytes
[1] = ((r
<< 7) | format_ab_reg (ab
, reg
));
1633 count
+= output_leb128 (bytes
+ 2, t
, 0);
1634 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1635 (*f
) (count
, bytes
, NULL
);
1639 output_X2_format (f
, ab
, reg
, x
, y
, treg
, t
)
1648 bytes
[1] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1649 bytes
[2] = (((y
& 1) << 7) | (treg
& 0x7f));
1650 count
+= output_leb128 (bytes
+ 3, t
, 0);
1651 (*f
) (count
, bytes
, NULL
);
1655 output_X3_format (f
, rtype
, qp
, ab
, reg
, t
, w1
)
1657 unw_record_type rtype
;
1668 if (rtype
== spill_sprel_p
)
1670 else if (rtype
!= spill_psprel_p
)
1671 as_bad ("Invalid record type for format X3");
1672 bytes
[1] = ((r
<< 7) | (qp
& 0x3f));
1673 bytes
[2] = format_ab_reg (ab
, reg
);
1674 count
+= output_leb128 (bytes
+ 3, t
, 0);
1675 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1676 (*f
) (count
, bytes
, NULL
);
1680 output_X4_format (f
, qp
, ab
, reg
, x
, y
, treg
, t
)
1690 bytes
[1] = (qp
& 0x3f);
1691 bytes
[2] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1692 bytes
[3] = (((y
& 1) << 7) | (treg
& 0x7f));
1693 count
+= output_leb128 (bytes
+ 4, t
, 0);
1694 (*f
) (count
, bytes
, NULL
);
1697 /* This function allocates a record list structure, and initializes fields. */
1699 static unw_rec_list
*
1700 alloc_record (unw_record_type t
)
1703 ptr
= xmalloc (sizeof (*ptr
));
1705 ptr
->slot_number
= SLOT_NUM_NOT_SET
;
1707 ptr
->next_slot_number
= 0;
1708 ptr
->next_slot_frag
= 0;
1712 /* Dummy unwind record used for calculating the length of the last prologue or
1715 static unw_rec_list
*
1718 unw_rec_list
*ptr
= alloc_record (endp
);
1722 static unw_rec_list
*
1725 unw_rec_list
*ptr
= alloc_record (prologue
);
1726 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1730 static unw_rec_list
*
1731 output_prologue_gr (saved_mask
, reg
)
1732 unsigned int saved_mask
;
1735 unw_rec_list
*ptr
= alloc_record (prologue_gr
);
1736 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1737 ptr
->r
.record
.r
.grmask
= saved_mask
;
1738 ptr
->r
.record
.r
.grsave
= reg
;
1742 static unw_rec_list
*
1745 unw_rec_list
*ptr
= alloc_record (body
);
1749 static unw_rec_list
*
1750 output_mem_stack_f (size
)
1753 unw_rec_list
*ptr
= alloc_record (mem_stack_f
);
1754 ptr
->r
.record
.p
.size
= size
;
1758 static unw_rec_list
*
1759 output_mem_stack_v ()
1761 unw_rec_list
*ptr
= alloc_record (mem_stack_v
);
1765 static unw_rec_list
*
1769 unw_rec_list
*ptr
= alloc_record (psp_gr
);
1770 ptr
->r
.record
.p
.gr
= gr
;
1774 static unw_rec_list
*
1775 output_psp_sprel (offset
)
1776 unsigned int offset
;
1778 unw_rec_list
*ptr
= alloc_record (psp_sprel
);
1779 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1783 static unw_rec_list
*
1786 unw_rec_list
*ptr
= alloc_record (rp_when
);
1790 static unw_rec_list
*
1794 unw_rec_list
*ptr
= alloc_record (rp_gr
);
1795 ptr
->r
.record
.p
.gr
= gr
;
1799 static unw_rec_list
*
1803 unw_rec_list
*ptr
= alloc_record (rp_br
);
1804 ptr
->r
.record
.p
.br
= br
;
1808 static unw_rec_list
*
1809 output_rp_psprel (offset
)
1810 unsigned int offset
;
1812 unw_rec_list
*ptr
= alloc_record (rp_psprel
);
1813 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1817 static unw_rec_list
*
1818 output_rp_sprel (offset
)
1819 unsigned int offset
;
1821 unw_rec_list
*ptr
= alloc_record (rp_sprel
);
1822 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1826 static unw_rec_list
*
1829 unw_rec_list
*ptr
= alloc_record (pfs_when
);
1833 static unw_rec_list
*
1837 unw_rec_list
*ptr
= alloc_record (pfs_gr
);
1838 ptr
->r
.record
.p
.gr
= gr
;
1842 static unw_rec_list
*
1843 output_pfs_psprel (offset
)
1844 unsigned int offset
;
1846 unw_rec_list
*ptr
= alloc_record (pfs_psprel
);
1847 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1851 static unw_rec_list
*
1852 output_pfs_sprel (offset
)
1853 unsigned int offset
;
1855 unw_rec_list
*ptr
= alloc_record (pfs_sprel
);
1856 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1860 static unw_rec_list
*
1861 output_preds_when ()
1863 unw_rec_list
*ptr
= alloc_record (preds_when
);
1867 static unw_rec_list
*
1868 output_preds_gr (gr
)
1871 unw_rec_list
*ptr
= alloc_record (preds_gr
);
1872 ptr
->r
.record
.p
.gr
= gr
;
1876 static unw_rec_list
*
1877 output_preds_psprel (offset
)
1878 unsigned int offset
;
1880 unw_rec_list
*ptr
= alloc_record (preds_psprel
);
1881 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1885 static unw_rec_list
*
1886 output_preds_sprel (offset
)
1887 unsigned int offset
;
1889 unw_rec_list
*ptr
= alloc_record (preds_sprel
);
1890 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1894 static unw_rec_list
*
1895 output_fr_mem (mask
)
1898 unw_rec_list
*ptr
= alloc_record (fr_mem
);
1899 ptr
->r
.record
.p
.rmask
= mask
;
1903 static unw_rec_list
*
1904 output_frgr_mem (gr_mask
, fr_mask
)
1905 unsigned int gr_mask
;
1906 unsigned int fr_mask
;
1908 unw_rec_list
*ptr
= alloc_record (frgr_mem
);
1909 ptr
->r
.record
.p
.grmask
= gr_mask
;
1910 ptr
->r
.record
.p
.frmask
= fr_mask
;
1914 static unw_rec_list
*
1915 output_gr_gr (mask
, reg
)
1919 unw_rec_list
*ptr
= alloc_record (gr_gr
);
1920 ptr
->r
.record
.p
.grmask
= mask
;
1921 ptr
->r
.record
.p
.gr
= reg
;
1925 static unw_rec_list
*
1926 output_gr_mem (mask
)
1929 unw_rec_list
*ptr
= alloc_record (gr_mem
);
1930 ptr
->r
.record
.p
.rmask
= mask
;
1934 static unw_rec_list
*
1935 output_br_mem (unsigned int mask
)
1937 unw_rec_list
*ptr
= alloc_record (br_mem
);
1938 ptr
->r
.record
.p
.brmask
= mask
;
1942 static unw_rec_list
*
1943 output_br_gr (save_mask
, reg
)
1944 unsigned int save_mask
;
1947 unw_rec_list
*ptr
= alloc_record (br_gr
);
1948 ptr
->r
.record
.p
.brmask
= save_mask
;
1949 ptr
->r
.record
.p
.gr
= reg
;
1953 static unw_rec_list
*
1954 output_spill_base (offset
)
1955 unsigned int offset
;
1957 unw_rec_list
*ptr
= alloc_record (spill_base
);
1958 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1962 static unw_rec_list
*
1965 unw_rec_list
*ptr
= alloc_record (unat_when
);
1969 static unw_rec_list
*
1973 unw_rec_list
*ptr
= alloc_record (unat_gr
);
1974 ptr
->r
.record
.p
.gr
= gr
;
1978 static unw_rec_list
*
1979 output_unat_psprel (offset
)
1980 unsigned int offset
;
1982 unw_rec_list
*ptr
= alloc_record (unat_psprel
);
1983 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1987 static unw_rec_list
*
1988 output_unat_sprel (offset
)
1989 unsigned int offset
;
1991 unw_rec_list
*ptr
= alloc_record (unat_sprel
);
1992 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1996 static unw_rec_list
*
1999 unw_rec_list
*ptr
= alloc_record (lc_when
);
2003 static unw_rec_list
*
2007 unw_rec_list
*ptr
= alloc_record (lc_gr
);
2008 ptr
->r
.record
.p
.gr
= gr
;
2012 static unw_rec_list
*
2013 output_lc_psprel (offset
)
2014 unsigned int offset
;
2016 unw_rec_list
*ptr
= alloc_record (lc_psprel
);
2017 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2021 static unw_rec_list
*
2022 output_lc_sprel (offset
)
2023 unsigned int offset
;
2025 unw_rec_list
*ptr
= alloc_record (lc_sprel
);
2026 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2030 static unw_rec_list
*
2033 unw_rec_list
*ptr
= alloc_record (fpsr_when
);
2037 static unw_rec_list
*
2041 unw_rec_list
*ptr
= alloc_record (fpsr_gr
);
2042 ptr
->r
.record
.p
.gr
= gr
;
2046 static unw_rec_list
*
2047 output_fpsr_psprel (offset
)
2048 unsigned int offset
;
2050 unw_rec_list
*ptr
= alloc_record (fpsr_psprel
);
2051 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2055 static unw_rec_list
*
2056 output_fpsr_sprel (offset
)
2057 unsigned int offset
;
2059 unw_rec_list
*ptr
= alloc_record (fpsr_sprel
);
2060 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2064 static unw_rec_list
*
2065 output_priunat_when_gr ()
2067 unw_rec_list
*ptr
= alloc_record (priunat_when_gr
);
2071 static unw_rec_list
*
2072 output_priunat_when_mem ()
2074 unw_rec_list
*ptr
= alloc_record (priunat_when_mem
);
2078 static unw_rec_list
*
2079 output_priunat_gr (gr
)
2082 unw_rec_list
*ptr
= alloc_record (priunat_gr
);
2083 ptr
->r
.record
.p
.gr
= gr
;
2087 static unw_rec_list
*
2088 output_priunat_psprel (offset
)
2089 unsigned int offset
;
2091 unw_rec_list
*ptr
= alloc_record (priunat_psprel
);
2092 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2096 static unw_rec_list
*
2097 output_priunat_sprel (offset
)
2098 unsigned int offset
;
2100 unw_rec_list
*ptr
= alloc_record (priunat_sprel
);
2101 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2105 static unw_rec_list
*
2108 unw_rec_list
*ptr
= alloc_record (bsp_when
);
2112 static unw_rec_list
*
2116 unw_rec_list
*ptr
= alloc_record (bsp_gr
);
2117 ptr
->r
.record
.p
.gr
= gr
;
2121 static unw_rec_list
*
2122 output_bsp_psprel (offset
)
2123 unsigned int offset
;
2125 unw_rec_list
*ptr
= alloc_record (bsp_psprel
);
2126 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2130 static unw_rec_list
*
2131 output_bsp_sprel (offset
)
2132 unsigned int offset
;
2134 unw_rec_list
*ptr
= alloc_record (bsp_sprel
);
2135 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2139 static unw_rec_list
*
2140 output_bspstore_when ()
2142 unw_rec_list
*ptr
= alloc_record (bspstore_when
);
2146 static unw_rec_list
*
2147 output_bspstore_gr (gr
)
2150 unw_rec_list
*ptr
= alloc_record (bspstore_gr
);
2151 ptr
->r
.record
.p
.gr
= gr
;
2155 static unw_rec_list
*
2156 output_bspstore_psprel (offset
)
2157 unsigned int offset
;
2159 unw_rec_list
*ptr
= alloc_record (bspstore_psprel
);
2160 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2164 static unw_rec_list
*
2165 output_bspstore_sprel (offset
)
2166 unsigned int offset
;
2168 unw_rec_list
*ptr
= alloc_record (bspstore_sprel
);
2169 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2173 static unw_rec_list
*
2176 unw_rec_list
*ptr
= alloc_record (rnat_when
);
2180 static unw_rec_list
*
2184 unw_rec_list
*ptr
= alloc_record (rnat_gr
);
2185 ptr
->r
.record
.p
.gr
= gr
;
2189 static unw_rec_list
*
2190 output_rnat_psprel (offset
)
2191 unsigned int offset
;
2193 unw_rec_list
*ptr
= alloc_record (rnat_psprel
);
2194 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2198 static unw_rec_list
*
2199 output_rnat_sprel (offset
)
2200 unsigned int offset
;
2202 unw_rec_list
*ptr
= alloc_record (rnat_sprel
);
2203 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2207 static unw_rec_list
*
2208 output_unwabi (abi
, context
)
2210 unsigned long context
;
2212 unw_rec_list
*ptr
= alloc_record (unwabi
);
2213 ptr
->r
.record
.p
.abi
= abi
;
2214 ptr
->r
.record
.p
.context
= context
;
2218 static unw_rec_list
*
2219 output_epilogue (unsigned long ecount
)
2221 unw_rec_list
*ptr
= alloc_record (epilogue
);
2222 ptr
->r
.record
.b
.ecount
= ecount
;
2226 static unw_rec_list
*
2227 output_label_state (unsigned long label
)
2229 unw_rec_list
*ptr
= alloc_record (label_state
);
2230 ptr
->r
.record
.b
.label
= label
;
2234 static unw_rec_list
*
2235 output_copy_state (unsigned long label
)
2237 unw_rec_list
*ptr
= alloc_record (copy_state
);
2238 ptr
->r
.record
.b
.label
= label
;
2242 static unw_rec_list
*
2243 output_spill_psprel (ab
, reg
, offset
)
2246 unsigned int offset
;
2248 unw_rec_list
*ptr
= alloc_record (spill_psprel
);
2249 ptr
->r
.record
.x
.ab
= ab
;
2250 ptr
->r
.record
.x
.reg
= reg
;
2251 ptr
->r
.record
.x
.pspoff
= offset
/ 4;
2255 static unw_rec_list
*
2256 output_spill_sprel (ab
, reg
, offset
)
2259 unsigned int offset
;
2261 unw_rec_list
*ptr
= alloc_record (spill_sprel
);
2262 ptr
->r
.record
.x
.ab
= ab
;
2263 ptr
->r
.record
.x
.reg
= reg
;
2264 ptr
->r
.record
.x
.spoff
= offset
/ 4;
2268 static unw_rec_list
*
2269 output_spill_psprel_p (ab
, reg
, offset
, predicate
)
2272 unsigned int offset
;
2273 unsigned int predicate
;
2275 unw_rec_list
*ptr
= alloc_record (spill_psprel_p
);
2276 ptr
->r
.record
.x
.ab
= ab
;
2277 ptr
->r
.record
.x
.reg
= reg
;
2278 ptr
->r
.record
.x
.pspoff
= offset
/ 4;
2279 ptr
->r
.record
.x
.qp
= predicate
;
2283 static unw_rec_list
*
2284 output_spill_sprel_p (ab
, reg
, offset
, predicate
)
2287 unsigned int offset
;
2288 unsigned int predicate
;
2290 unw_rec_list
*ptr
= alloc_record (spill_sprel_p
);
2291 ptr
->r
.record
.x
.ab
= ab
;
2292 ptr
->r
.record
.x
.reg
= reg
;
2293 ptr
->r
.record
.x
.spoff
= offset
/ 4;
2294 ptr
->r
.record
.x
.qp
= predicate
;
2298 static unw_rec_list
*
2299 output_spill_reg (ab
, reg
, targ_reg
, xy
)
2302 unsigned int targ_reg
;
2305 unw_rec_list
*ptr
= alloc_record (spill_reg
);
2306 ptr
->r
.record
.x
.ab
= ab
;
2307 ptr
->r
.record
.x
.reg
= reg
;
2308 ptr
->r
.record
.x
.treg
= targ_reg
;
2309 ptr
->r
.record
.x
.xy
= xy
;
2313 static unw_rec_list
*
2314 output_spill_reg_p (ab
, reg
, targ_reg
, xy
, predicate
)
2317 unsigned int targ_reg
;
2319 unsigned int predicate
;
2321 unw_rec_list
*ptr
= alloc_record (spill_reg_p
);
2322 ptr
->r
.record
.x
.ab
= ab
;
2323 ptr
->r
.record
.x
.reg
= reg
;
2324 ptr
->r
.record
.x
.treg
= targ_reg
;
2325 ptr
->r
.record
.x
.xy
= xy
;
2326 ptr
->r
.record
.x
.qp
= predicate
;
2330 /* Given a unw_rec_list process the correct format with the
2331 specified function. */
2334 process_one_record (ptr
, f
)
2338 unsigned long fr_mask
, gr_mask
;
2340 switch (ptr
->r
.type
)
2342 /* This is a dummy record that takes up no space in the output. */
2350 /* These are taken care of by prologue/prologue_gr. */
2355 if (ptr
->r
.type
== prologue_gr
)
2356 output_R2_format (f
, ptr
->r
.record
.r
.grmask
,
2357 ptr
->r
.record
.r
.grsave
, ptr
->r
.record
.r
.rlen
);
2359 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2361 /* Output descriptor(s) for union of register spills (if any). */
2362 gr_mask
= ptr
->r
.record
.r
.mask
.gr_mem
;
2363 fr_mask
= ptr
->r
.record
.r
.mask
.fr_mem
;
2366 if ((fr_mask
& ~0xfUL
) == 0)
2367 output_P6_format (f
, fr_mem
, fr_mask
);
2370 output_P5_format (f
, gr_mask
, fr_mask
);
2375 output_P6_format (f
, gr_mem
, gr_mask
);
2376 if (ptr
->r
.record
.r
.mask
.br_mem
)
2377 output_P1_format (f
, ptr
->r
.record
.r
.mask
.br_mem
);
2379 /* output imask descriptor if necessary: */
2380 if (ptr
->r
.record
.r
.mask
.i
)
2381 output_P4_format (f
, ptr
->r
.record
.r
.mask
.i
,
2382 ptr
->r
.record
.r
.imask_size
);
2386 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2390 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
,
2391 ptr
->r
.record
.p
.size
);
2404 output_P3_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.gr
);
2407 output_P3_format (f
, rp_br
, ptr
->r
.record
.p
.br
);
2410 output_P7_format (f
, psp_sprel
, ptr
->r
.record
.p
.spoff
, 0);
2418 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
, 0);
2427 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.pspoff
, 0);
2437 case bspstore_sprel
:
2439 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.spoff
);
2442 output_P9_format (f
, ptr
->r
.record
.p
.grmask
, ptr
->r
.record
.p
.gr
);
2445 output_P2_format (f
, ptr
->r
.record
.p
.brmask
, ptr
->r
.record
.p
.gr
);
2448 as_bad ("spill_mask record unimplemented.");
2450 case priunat_when_gr
:
2451 case priunat_when_mem
:
2455 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
);
2457 case priunat_psprel
:
2459 case bspstore_psprel
:
2461 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.pspoff
);
2464 output_P10_format (f
, ptr
->r
.record
.p
.abi
, ptr
->r
.record
.p
.context
);
2467 output_B3_format (f
, ptr
->r
.record
.b
.ecount
, ptr
->r
.record
.b
.t
);
2471 output_B4_format (f
, ptr
->r
.type
, ptr
->r
.record
.b
.label
);
2474 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2475 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2476 ptr
->r
.record
.x
.pspoff
);
2479 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2480 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2481 ptr
->r
.record
.x
.spoff
);
2484 output_X2_format (f
, ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2485 ptr
->r
.record
.x
.xy
>> 1, ptr
->r
.record
.x
.xy
,
2486 ptr
->r
.record
.x
.treg
, ptr
->r
.record
.x
.t
);
2488 case spill_psprel_p
:
2489 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2490 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2491 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.pspoff
);
2494 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2495 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2496 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.spoff
);
2499 output_X4_format (f
, ptr
->r
.record
.x
.qp
, ptr
->r
.record
.x
.ab
,
2500 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.xy
>> 1,
2501 ptr
->r
.record
.x
.xy
, ptr
->r
.record
.x
.treg
,
2505 as_bad ("record_type_not_valid");
2510 /* Given a unw_rec_list list, process all the records with
2511 the specified function. */
2513 process_unw_records (list
, f
)
2518 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2519 process_one_record (ptr
, f
);
2522 /* Determine the size of a record list in bytes. */
2524 calc_record_size (list
)
2528 process_unw_records (list
, count_output
);
2532 /* Update IMASK bitmask to reflect the fact that one or more registers
2533 of type TYPE are saved starting at instruction with index T. If N
2534 bits are set in REGMASK, it is assumed that instructions T through
2535 T+N-1 save these registers.
2539 1: instruction saves next fp reg
2540 2: instruction saves next general reg
2541 3: instruction saves next branch reg */
2543 set_imask (region
, regmask
, t
, type
)
2544 unw_rec_list
*region
;
2545 unsigned long regmask
;
2549 unsigned char *imask
;
2550 unsigned long imask_size
;
2554 imask
= region
->r
.record
.r
.mask
.i
;
2555 imask_size
= region
->r
.record
.r
.imask_size
;
2558 imask_size
= (region
->r
.record
.r
.rlen
* 2 + 7) / 8 + 1;
2559 imask
= xmalloc (imask_size
);
2560 memset (imask
, 0, imask_size
);
2562 region
->r
.record
.r
.imask_size
= imask_size
;
2563 region
->r
.record
.r
.mask
.i
= imask
;
2567 pos
= 2 * (3 - t
% 4);
2570 if (i
>= imask_size
)
2572 as_bad ("Ignoring attempt to spill beyond end of region");
2576 imask
[i
] |= (type
& 0x3) << pos
;
2578 regmask
&= (regmask
- 1);
2588 /* Return the number of instruction slots from FIRST_ADDR to SLOT_ADDR.
2589 SLOT_FRAG is the frag containing SLOT_ADDR, and FIRST_FRAG is the frag
2590 containing FIRST_ADDR. If BEFORE_RELAX, then we use worst-case estimates
2594 slot_index (slot_addr
, slot_frag
, first_addr
, first_frag
, before_relax
)
2595 unsigned long slot_addr
;
2597 unsigned long first_addr
;
2601 unsigned long index
= 0;
2603 /* First time we are called, the initial address and frag are invalid. */
2604 if (first_addr
== 0)
2607 /* If the two addresses are in different frags, then we need to add in
2608 the remaining size of this frag, and then the entire size of intermediate
2610 while (slot_frag
!= first_frag
)
2612 unsigned long start_addr
= (unsigned long) &first_frag
->fr_literal
;
2616 /* We can get the final addresses only during and after
2618 if (first_frag
->fr_next
&& first_frag
->fr_next
->fr_address
)
2619 index
+= 3 * ((first_frag
->fr_next
->fr_address
2620 - first_frag
->fr_address
2621 - first_frag
->fr_fix
) >> 4);
2624 /* We don't know what the final addresses will be. We try our
2625 best to estimate. */
2626 switch (first_frag
->fr_type
)
2632 as_fatal ("only constant space allocation is supported");
2638 /* Take alignment into account. Assume the worst case
2639 before relaxation. */
2640 index
+= 3 * ((1 << first_frag
->fr_offset
) >> 4);
2644 if (first_frag
->fr_symbol
)
2646 as_fatal ("only constant offsets are supported");
2650 index
+= 3 * (first_frag
->fr_offset
>> 4);
2654 /* Add in the full size of the frag converted to instruction slots. */
2655 index
+= 3 * (first_frag
->fr_fix
>> 4);
2656 /* Subtract away the initial part before first_addr. */
2657 index
-= (3 * ((first_addr
>> 4) - (start_addr
>> 4))
2658 + ((first_addr
& 0x3) - (start_addr
& 0x3)));
2660 /* Move to the beginning of the next frag. */
2661 first_frag
= first_frag
->fr_next
;
2662 first_addr
= (unsigned long) &first_frag
->fr_literal
;
2665 /* Add in the used part of the last frag. */
2666 index
+= (3 * ((slot_addr
>> 4) - (first_addr
>> 4))
2667 + ((slot_addr
& 0x3) - (first_addr
& 0x3)));
2671 /* Optimize unwind record directives. */
2673 static unw_rec_list
*
2674 optimize_unw_records (list
)
2680 /* If the only unwind record is ".prologue" or ".prologue" followed
2681 by ".body", then we can optimize the unwind directives away. */
2682 if (list
->r
.type
== prologue
2683 && (list
->next
->r
.type
== endp
2684 || (list
->next
->r
.type
== body
&& list
->next
->next
->r
.type
== endp
)))
2690 /* Given a complete record list, process any records which have
2691 unresolved fields, (ie length counts for a prologue). After
2692 this has been run, all necessary information should be available
2693 within each record to generate an image. */
2696 fixup_unw_records (list
, before_relax
)
2700 unw_rec_list
*ptr
, *region
= 0;
2701 unsigned long first_addr
= 0, rlen
= 0, t
;
2702 fragS
*first_frag
= 0;
2704 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2706 if (ptr
->slot_number
== SLOT_NUM_NOT_SET
)
2707 as_bad (" Insn slot not set in unwind record.");
2708 t
= slot_index (ptr
->slot_number
, ptr
->slot_frag
,
2709 first_addr
, first_frag
, before_relax
);
2710 switch (ptr
->r
.type
)
2718 unsigned long last_addr
= 0;
2719 fragS
*last_frag
= NULL
;
2721 first_addr
= ptr
->slot_number
;
2722 first_frag
= ptr
->slot_frag
;
2723 /* Find either the next body/prologue start, or the end of
2724 the function, and determine the size of the region. */
2725 for (last
= ptr
->next
; last
!= NULL
; last
= last
->next
)
2726 if (last
->r
.type
== prologue
|| last
->r
.type
== prologue_gr
2727 || last
->r
.type
== body
|| last
->r
.type
== endp
)
2729 last_addr
= last
->slot_number
;
2730 last_frag
= last
->slot_frag
;
2733 size
= slot_index (last_addr
, last_frag
, first_addr
, first_frag
,
2735 rlen
= ptr
->r
.record
.r
.rlen
= size
;
2736 if (ptr
->r
.type
== body
)
2737 /* End of region. */
2744 ptr
->r
.record
.b
.t
= rlen
- 1 - t
;
2755 case priunat_when_gr
:
2756 case priunat_when_mem
:
2760 ptr
->r
.record
.p
.t
= t
;
2768 case spill_psprel_p
:
2769 ptr
->r
.record
.x
.t
= t
;
2775 as_bad ("frgr_mem record before region record!\n");
2778 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.frmask
;
2779 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.grmask
;
2780 set_imask (region
, ptr
->r
.record
.p
.frmask
, t
, 1);
2781 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2786 as_bad ("fr_mem record before region record!\n");
2789 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.rmask
;
2790 set_imask (region
, ptr
->r
.record
.p
.rmask
, t
, 1);
2795 as_bad ("gr_mem record before region record!\n");
2798 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.rmask
;
2799 set_imask (region
, ptr
->r
.record
.p
.rmask
, t
, 2);
2804 as_bad ("br_mem record before region record!\n");
2807 region
->r
.record
.r
.mask
.br_mem
|= ptr
->r
.record
.p
.brmask
;
2808 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2814 as_bad ("gr_gr record before region record!\n");
2817 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2822 as_bad ("br_gr record before region record!\n");
2825 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2834 /* Estimate the size of a frag before relaxing. We only have one type of frag
2835 to handle here, which is the unwind info frag. */
2838 ia64_estimate_size_before_relax (fragS
*frag
,
2839 asection
*segtype ATTRIBUTE_UNUSED
)
2844 /* ??? This code is identical to the first part of ia64_convert_frag. */
2845 list
= (unw_rec_list
*) frag
->fr_opcode
;
2846 fixup_unw_records (list
, 0);
2848 len
= calc_record_size (list
);
2849 /* pad to pointer-size boundary. */
2850 pad
= len
% md
.pointer_size
;
2852 len
+= md
.pointer_size
- pad
;
2853 /* Add 8 for the header + a pointer for the personality offset. */
2854 size
= len
+ 8 + md
.pointer_size
;
2856 /* fr_var carries the max_chars that we created the fragment with.
2857 We must, of course, have allocated enough memory earlier. */
2858 assert (frag
->fr_var
>= size
);
2860 return frag
->fr_fix
+ size
;
2863 /* This function converts a rs_machine_dependent variant frag into a
2864 normal fill frag with the unwind image from the the record list. */
2866 ia64_convert_frag (fragS
*frag
)
2872 /* ??? This code is identical to ia64_estimate_size_before_relax. */
2873 list
= (unw_rec_list
*) frag
->fr_opcode
;
2874 fixup_unw_records (list
, 0);
2876 len
= calc_record_size (list
);
2877 /* pad to pointer-size boundary. */
2878 pad
= len
% md
.pointer_size
;
2880 len
+= md
.pointer_size
- pad
;
2881 /* Add 8 for the header + a pointer for the personality offset. */
2882 size
= len
+ 8 + md
.pointer_size
;
2884 /* fr_var carries the max_chars that we created the fragment with.
2885 We must, of course, have allocated enough memory earlier. */
2886 assert (frag
->fr_var
>= size
);
2888 /* Initialize the header area. fr_offset is initialized with
2889 unwind.personality_routine. */
2890 if (frag
->fr_offset
)
2892 if (md
.flags
& EF_IA_64_ABI64
)
2893 flag_value
= (bfd_vma
) 3 << 32;
2895 /* 32-bit unwind info block. */
2896 flag_value
= (bfd_vma
) 0x1003 << 32;
2901 md_number_to_chars (frag
->fr_literal
,
2902 (((bfd_vma
) 1 << 48) /* Version. */
2903 | flag_value
/* U & E handler flags. */
2904 | (len
/ md
.pointer_size
)), /* Length. */
2907 /* Skip the header. */
2908 vbyte_mem_ptr
= frag
->fr_literal
+ 8;
2909 process_unw_records (list
, output_vbyte_mem
);
2911 /* Fill the padding bytes with zeros. */
2913 md_number_to_chars (frag
->fr_literal
+ len
+ 8 - md
.pointer_size
+ pad
, 0,
2914 md
.pointer_size
- pad
);
2916 frag
->fr_fix
+= size
;
2917 frag
->fr_type
= rs_fill
;
2919 frag
->fr_offset
= 0;
2923 convert_expr_to_ab_reg (e
, ab
, regp
)
2930 if (e
->X_op
!= O_register
)
2933 reg
= e
->X_add_number
;
2934 if (reg
>= (REG_GR
+ 4) && reg
<= (REG_GR
+ 7))
2937 *regp
= reg
- REG_GR
;
2939 else if ((reg
>= (REG_FR
+ 2) && reg
<= (REG_FR
+ 5))
2940 || (reg
>= (REG_FR
+ 16) && reg
<= (REG_FR
+ 31)))
2943 *regp
= reg
- REG_FR
;
2945 else if (reg
>= (REG_BR
+ 1) && reg
<= (REG_BR
+ 5))
2948 *regp
= reg
- REG_BR
;
2955 case REG_PR
: *regp
= 0; break;
2956 case REG_PSP
: *regp
= 1; break;
2957 case REG_PRIUNAT
: *regp
= 2; break;
2958 case REG_BR
+ 0: *regp
= 3; break;
2959 case REG_AR
+ AR_BSP
: *regp
= 4; break;
2960 case REG_AR
+ AR_BSPSTORE
: *regp
= 5; break;
2961 case REG_AR
+ AR_RNAT
: *regp
= 6; break;
2962 case REG_AR
+ AR_UNAT
: *regp
= 7; break;
2963 case REG_AR
+ AR_FPSR
: *regp
= 8; break;
2964 case REG_AR
+ AR_PFS
: *regp
= 9; break;
2965 case REG_AR
+ AR_LC
: *regp
= 10; break;
2975 convert_expr_to_xy_reg (e
, xy
, regp
)
2982 if (e
->X_op
!= O_register
)
2985 reg
= e
->X_add_number
;
2987 if (/* reg >= REG_GR && */ reg
<= (REG_GR
+ 127))
2990 *regp
= reg
- REG_GR
;
2992 else if (reg
>= REG_FR
&& reg
<= (REG_FR
+ 127))
2995 *regp
= reg
- REG_FR
;
2997 else if (reg
>= REG_BR
&& reg
<= (REG_BR
+ 7))
3000 *regp
= reg
- REG_BR
;
3010 /* The current frag is an alignment frag. */
3011 align_frag
= frag_now
;
3012 s_align_bytes (arg
);
3017 int dummy ATTRIBUTE_UNUSED
;
3022 radix
= *input_line_pointer
++;
3024 if (radix
!= 'C' && !is_end_of_line
[(unsigned char) radix
])
3026 as_bad ("Radix `%c' unsupported", *input_line_pointer
);
3027 ignore_rest_of_line ();
3032 /* .sbss, .bss etc. are macros that expand into ".section SECNAME". */
3034 dot_special_section (which
)
3037 set_section ((char *) special_section_name
[which
]);
3041 add_unwind_entry (ptr
)
3045 unwind
.tail
->next
= ptr
;
3050 /* The current entry can in fact be a chain of unwind entries. */
3051 if (unwind
.current_entry
== NULL
)
3052 unwind
.current_entry
= ptr
;
3057 int dummy ATTRIBUTE_UNUSED
;
3063 if (e
.X_op
!= O_constant
)
3064 as_bad ("Operand to .fframe must be a constant");
3066 add_unwind_entry (output_mem_stack_f (e
.X_add_number
));
3071 int dummy ATTRIBUTE_UNUSED
;
3077 reg
= e
.X_add_number
- REG_GR
;
3078 if (e
.X_op
== O_register
&& reg
< 128)
3080 add_unwind_entry (output_mem_stack_v ());
3081 if (! (unwind
.prologue_mask
& 2))
3082 add_unwind_entry (output_psp_gr (reg
));
3085 as_bad ("First operand to .vframe must be a general register");
3089 dot_vframesp (dummy
)
3090 int dummy ATTRIBUTE_UNUSED
;
3095 if (e
.X_op
== O_constant
)
3097 add_unwind_entry (output_mem_stack_v ());
3098 add_unwind_entry (output_psp_sprel (e
.X_add_number
));
3101 as_bad ("Operand to .vframesp must be a constant (sp-relative offset)");
3105 dot_vframepsp (dummy
)
3106 int dummy ATTRIBUTE_UNUSED
;
3111 if (e
.X_op
== O_constant
)
3113 add_unwind_entry (output_mem_stack_v ());
3114 add_unwind_entry (output_psp_sprel (e
.X_add_number
));
3117 as_bad ("Operand to .vframepsp must be a constant (psp-relative offset)");
3122 int dummy ATTRIBUTE_UNUSED
;
3128 sep
= parse_operand (&e1
);
3130 as_bad ("No second operand to .save");
3131 sep
= parse_operand (&e2
);
3133 reg1
= e1
.X_add_number
;
3134 reg2
= e2
.X_add_number
- REG_GR
;
3136 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3137 if (e1
.X_op
== O_register
)
3139 if (e2
.X_op
== O_register
&& reg2
>= 0 && reg2
< 128)
3143 case REG_AR
+ AR_BSP
:
3144 add_unwind_entry (output_bsp_when ());
3145 add_unwind_entry (output_bsp_gr (reg2
));
3147 case REG_AR
+ AR_BSPSTORE
:
3148 add_unwind_entry (output_bspstore_when ());
3149 add_unwind_entry (output_bspstore_gr (reg2
));
3151 case REG_AR
+ AR_RNAT
:
3152 add_unwind_entry (output_rnat_when ());
3153 add_unwind_entry (output_rnat_gr (reg2
));
3155 case REG_AR
+ AR_UNAT
:
3156 add_unwind_entry (output_unat_when ());
3157 add_unwind_entry (output_unat_gr (reg2
));
3159 case REG_AR
+ AR_FPSR
:
3160 add_unwind_entry (output_fpsr_when ());
3161 add_unwind_entry (output_fpsr_gr (reg2
));
3163 case REG_AR
+ AR_PFS
:
3164 add_unwind_entry (output_pfs_when ());
3165 if (! (unwind
.prologue_mask
& 4))
3166 add_unwind_entry (output_pfs_gr (reg2
));
3168 case REG_AR
+ AR_LC
:
3169 add_unwind_entry (output_lc_when ());
3170 add_unwind_entry (output_lc_gr (reg2
));
3173 add_unwind_entry (output_rp_when ());
3174 if (! (unwind
.prologue_mask
& 8))
3175 add_unwind_entry (output_rp_gr (reg2
));
3178 add_unwind_entry (output_preds_when ());
3179 if (! (unwind
.prologue_mask
& 1))
3180 add_unwind_entry (output_preds_gr (reg2
));
3183 add_unwind_entry (output_priunat_when_gr ());
3184 add_unwind_entry (output_priunat_gr (reg2
));
3187 as_bad ("First operand not a valid register");
3191 as_bad (" Second operand not a valid register");
3194 as_bad ("First operand not a register");
3199 int dummy ATTRIBUTE_UNUSED
;
3202 unsigned long ecount
; /* # of _additional_ regions to pop */
3205 sep
= parse_operand (&e1
);
3206 if (e1
.X_op
!= O_register
|| e1
.X_add_number
!= REG_GR
+ 12)
3208 as_bad ("First operand to .restore must be stack pointer (sp)");
3214 parse_operand (&e2
);
3215 if (e2
.X_op
!= O_constant
|| e2
.X_add_number
< 0)
3217 as_bad ("Second operand to .restore must be a constant >= 0");
3220 ecount
= e2
.X_add_number
;
3223 ecount
= unwind
.prologue_count
- 1;
3225 if (ecount
>= unwind
.prologue_count
)
3227 as_bad ("Epilogue count of %lu exceeds number of nested prologues (%u)",
3228 ecount
+ 1, unwind
.prologue_count
);
3232 add_unwind_entry (output_epilogue (ecount
));
3234 if (ecount
< unwind
.prologue_count
)
3235 unwind
.prologue_count
-= ecount
+ 1;
3237 unwind
.prologue_count
= 0;
3241 dot_restorereg (dummy
)
3242 int dummy ATTRIBUTE_UNUSED
;
3244 unsigned int ab
, reg
;
3249 if (!convert_expr_to_ab_reg (&e
, &ab
, ®
))
3251 as_bad ("First operand to .restorereg must be a preserved register");
3254 add_unwind_entry (output_spill_reg (ab
, reg
, 0, 0));
3258 dot_restorereg_p (dummy
)
3259 int dummy ATTRIBUTE_UNUSED
;
3261 unsigned int qp
, ab
, reg
;
3265 sep
= parse_operand (&e1
);
3268 as_bad ("No second operand to .restorereg.p");
3272 parse_operand (&e2
);
3274 qp
= e1
.X_add_number
- REG_P
;
3275 if (e1
.X_op
!= O_register
|| qp
> 63)
3277 as_bad ("First operand to .restorereg.p must be a predicate");
3281 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
3283 as_bad ("Second operand to .restorereg.p must be a preserved register");
3286 add_unwind_entry (output_spill_reg_p (ab
, reg
, 0, 0, qp
));
3289 static char *special_linkonce_name
[] =
3291 ".gnu.linkonce.ia64unw.", ".gnu.linkonce.ia64unwi."
3295 start_unwind_section (const segT text_seg
, int sec_index
, int linkonce_empty
)
3298 Use a slightly ugly scheme to derive the unwind section names from
3299 the text section name:
3301 text sect. unwind table sect.
3302 name: name: comments:
3303 ---------- ----------------- --------------------------------
3305 .text.foo .IA_64.unwind.text.foo
3306 .foo .IA_64.unwind.foo
3308 .gnu.linkonce.ia64unw.foo
3309 _info .IA_64.unwind_info gas issues error message (ditto)
3310 _infoFOO .IA_64.unwind_infoFOO gas issues error message (ditto)
3312 This mapping is done so that:
3314 (a) An object file with unwind info only in .text will use
3315 unwind section names .IA_64.unwind and .IA_64.unwind_info.
3316 This follows the letter of the ABI and also ensures backwards
3317 compatibility with older toolchains.
3319 (b) An object file with unwind info in multiple text sections
3320 will use separate unwind sections for each text section.
3321 This allows us to properly set the "sh_info" and "sh_link"
3322 fields in SHT_IA_64_UNWIND as required by the ABI and also
3323 lets GNU ld support programs with multiple segments
3324 containing unwind info (as might be the case for certain
3325 embedded applications).
3327 (c) An error is issued if there would be a name clash.
3330 const char *text_name
, *sec_text_name
;
3332 const char *prefix
= special_section_name
[sec_index
];
3334 size_t prefix_len
, suffix_len
, sec_name_len
;
3336 sec_text_name
= segment_name (text_seg
);
3337 text_name
= sec_text_name
;
3338 if (strncmp (text_name
, "_info", 5) == 0)
3340 as_bad ("Illegal section name `%s' (causes unwind section name clash)",
3342 ignore_rest_of_line ();
3345 if (strcmp (text_name
, ".text") == 0)
3348 /* Build the unwind section name by appending the (possibly stripped)
3349 text section name to the unwind prefix. */
3351 if (strncmp (text_name
, ".gnu.linkonce.t.",
3352 sizeof (".gnu.linkonce.t.") - 1) == 0)
3354 prefix
= special_linkonce_name
[sec_index
- SPECIAL_SECTION_UNWIND
];
3355 suffix
+= sizeof (".gnu.linkonce.t.") - 1;
3357 else if (linkonce_empty
)
3360 prefix_len
= strlen (prefix
);
3361 suffix_len
= strlen (suffix
);
3362 sec_name_len
= prefix_len
+ suffix_len
;
3363 sec_name
= alloca (sec_name_len
+ 1);
3364 memcpy (sec_name
, prefix
, prefix_len
);
3365 memcpy (sec_name
+ prefix_len
, suffix
, suffix_len
);
3366 sec_name
[sec_name_len
] = '\0';
3368 /* Handle COMDAT group. */
3369 if (suffix
== text_name
&& (text_seg
->flags
& SEC_LINK_ONCE
) != 0)
3372 size_t len
, group_name_len
;
3373 const char *group_name
= elf_group_name (text_seg
);
3375 if (group_name
== NULL
)
3377 as_bad ("Group section `%s' has no group signature",
3379 ignore_rest_of_line ();
3382 /* We have to construct a fake section directive. */
3383 group_name_len
= strlen (group_name
);
3385 + 16 /* ,"aG",@progbits, */
3386 + group_name_len
/* ,group_name */
3389 section
= alloca (len
+ 1);
3390 memcpy (section
, sec_name
, sec_name_len
);
3391 memcpy (section
+ sec_name_len
, ",\"aG\",@progbits,", 16);
3392 memcpy (section
+ sec_name_len
+ 16, group_name
, group_name_len
);
3393 memcpy (section
+ len
- 7, ",comdat", 7);
3394 section
[len
] = '\0';
3395 set_section (section
);
3399 set_section (sec_name
);
3400 bfd_set_section_flags (stdoutput
, now_seg
,
3401 SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
);
3404 elf_linked_to_section (now_seg
) = text_seg
;
3408 generate_unwind_image (const segT text_seg
)
3413 /* Mark the end of the unwind info, so that we can compute the size of the
3414 last unwind region. */
3415 add_unwind_entry (output_endp ());
3417 /* Force out pending instructions, to make sure all unwind records have
3418 a valid slot_number field. */
3419 ia64_flush_insns ();
3421 /* Generate the unwind record. */
3422 list
= optimize_unw_records (unwind
.list
);
3423 fixup_unw_records (list
, 1);
3424 size
= calc_record_size (list
);
3426 if (size
> 0 || unwind
.force_unwind_entry
)
3428 unwind
.force_unwind_entry
= 0;
3429 /* pad to pointer-size boundary. */
3430 pad
= size
% md
.pointer_size
;
3432 size
+= md
.pointer_size
- pad
;
3433 /* Add 8 for the header + a pointer for the personality
3435 size
+= 8 + md
.pointer_size
;
3438 /* If there are unwind records, switch sections, and output the info. */
3442 bfd_reloc_code_real_type reloc
;
3444 start_unwind_section (text_seg
, SPECIAL_SECTION_UNWIND_INFO
, 0);
3446 /* Make sure the section has 4 byte alignment for ILP32 and
3447 8 byte alignment for LP64. */
3448 frag_align (md
.pointer_size_shift
, 0, 0);
3449 record_alignment (now_seg
, md
.pointer_size_shift
);
3451 /* Set expression which points to start of unwind descriptor area. */
3452 unwind
.info
= expr_build_dot ();
3454 frag_var (rs_machine_dependent
, size
, size
, 0, 0,
3455 (offsetT
) (long) unwind
.personality_routine
,
3458 /* Add the personality address to the image. */
3459 if (unwind
.personality_routine
!= 0)
3461 exp
.X_op
= O_symbol
;
3462 exp
.X_add_symbol
= unwind
.personality_routine
;
3463 exp
.X_add_number
= 0;
3465 if (md
.flags
& EF_IA_64_BE
)
3467 if (md
.flags
& EF_IA_64_ABI64
)
3468 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64MSB
;
3470 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32MSB
;
3474 if (md
.flags
& EF_IA_64_ABI64
)
3475 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64LSB
;
3477 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32LSB
;
3480 fix_new_exp (frag_now
, frag_now_fix () - md
.pointer_size
,
3481 md
.pointer_size
, &exp
, 0, reloc
);
3482 unwind
.personality_routine
= 0;
3486 start_unwind_section (text_seg
, SPECIAL_SECTION_UNWIND_INFO
, 1);
3488 free_saved_prologue_counts ();
3489 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
3493 dot_handlerdata (dummy
)
3494 int dummy ATTRIBUTE_UNUSED
;
3496 unwind
.force_unwind_entry
= 1;
3498 /* Remember which segment we're in so we can switch back after .endp */
3499 unwind
.saved_text_seg
= now_seg
;
3500 unwind
.saved_text_subseg
= now_subseg
;
3502 /* Generate unwind info into unwind-info section and then leave that
3503 section as the currently active one so dataXX directives go into
3504 the language specific data area of the unwind info block. */
3505 generate_unwind_image (now_seg
);
3506 demand_empty_rest_of_line ();
3510 dot_unwentry (dummy
)
3511 int dummy ATTRIBUTE_UNUSED
;
3513 unwind
.force_unwind_entry
= 1;
3514 demand_empty_rest_of_line ();
3519 int dummy ATTRIBUTE_UNUSED
;
3525 reg
= e
.X_add_number
- REG_BR
;
3526 if (e
.X_op
== O_register
&& reg
< 8)
3527 add_unwind_entry (output_rp_br (reg
));
3529 as_bad ("First operand not a valid branch register");
3533 dot_savemem (psprel
)
3540 sep
= parse_operand (&e1
);
3542 as_bad ("No second operand to .save%ssp", psprel
? "p" : "");
3543 sep
= parse_operand (&e2
);
3545 reg1
= e1
.X_add_number
;
3546 val
= e2
.X_add_number
;
3548 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3549 if (e1
.X_op
== O_register
)
3551 if (e2
.X_op
== O_constant
)
3555 case REG_AR
+ AR_BSP
:
3556 add_unwind_entry (output_bsp_when ());
3557 add_unwind_entry ((psprel
3559 : output_bsp_sprel
) (val
));
3561 case REG_AR
+ AR_BSPSTORE
:
3562 add_unwind_entry (output_bspstore_when ());
3563 add_unwind_entry ((psprel
3564 ? output_bspstore_psprel
3565 : output_bspstore_sprel
) (val
));
3567 case REG_AR
+ AR_RNAT
:
3568 add_unwind_entry (output_rnat_when ());
3569 add_unwind_entry ((psprel
3570 ? output_rnat_psprel
3571 : output_rnat_sprel
) (val
));
3573 case REG_AR
+ AR_UNAT
:
3574 add_unwind_entry (output_unat_when ());
3575 add_unwind_entry ((psprel
3576 ? output_unat_psprel
3577 : output_unat_sprel
) (val
));
3579 case REG_AR
+ AR_FPSR
:
3580 add_unwind_entry (output_fpsr_when ());
3581 add_unwind_entry ((psprel
3582 ? output_fpsr_psprel
3583 : output_fpsr_sprel
) (val
));
3585 case REG_AR
+ AR_PFS
:
3586 add_unwind_entry (output_pfs_when ());
3587 add_unwind_entry ((psprel
3589 : output_pfs_sprel
) (val
));
3591 case REG_AR
+ AR_LC
:
3592 add_unwind_entry (output_lc_when ());
3593 add_unwind_entry ((psprel
3595 : output_lc_sprel
) (val
));
3598 add_unwind_entry (output_rp_when ());
3599 add_unwind_entry ((psprel
3601 : output_rp_sprel
) (val
));
3604 add_unwind_entry (output_preds_when ());
3605 add_unwind_entry ((psprel
3606 ? output_preds_psprel
3607 : output_preds_sprel
) (val
));
3610 add_unwind_entry (output_priunat_when_mem ());
3611 add_unwind_entry ((psprel
3612 ? output_priunat_psprel
3613 : output_priunat_sprel
) (val
));
3616 as_bad ("First operand not a valid register");
3620 as_bad (" Second operand not a valid constant");
3623 as_bad ("First operand not a register");
3628 int dummy ATTRIBUTE_UNUSED
;
3632 sep
= parse_operand (&e1
);
3634 parse_operand (&e2
);
3636 if (e1
.X_op
!= O_constant
)
3637 as_bad ("First operand to .save.g must be a constant.");
3640 int grmask
= e1
.X_add_number
;
3642 add_unwind_entry (output_gr_mem (grmask
));
3645 int reg
= e2
.X_add_number
- REG_GR
;
3646 if (e2
.X_op
== O_register
&& reg
>= 0 && reg
< 128)
3647 add_unwind_entry (output_gr_gr (grmask
, reg
));
3649 as_bad ("Second operand is an invalid register.");
3656 int dummy ATTRIBUTE_UNUSED
;
3660 sep
= parse_operand (&e1
);
3662 if (e1
.X_op
!= O_constant
)
3663 as_bad ("Operand to .save.f must be a constant.");
3665 add_unwind_entry (output_fr_mem (e1
.X_add_number
));
3670 int dummy ATTRIBUTE_UNUSED
;
3677 sep
= parse_operand (&e1
);
3678 if (e1
.X_op
!= O_constant
)
3680 as_bad ("First operand to .save.b must be a constant.");
3683 brmask
= e1
.X_add_number
;
3687 sep
= parse_operand (&e2
);
3688 reg
= e2
.X_add_number
- REG_GR
;
3689 if (e2
.X_op
!= O_register
|| reg
> 127)
3691 as_bad ("Second operand to .save.b must be a general register.");
3694 add_unwind_entry (output_br_gr (brmask
, e2
.X_add_number
));
3697 add_unwind_entry (output_br_mem (brmask
));
3699 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3700 demand_empty_rest_of_line ();
3705 int dummy ATTRIBUTE_UNUSED
;
3709 sep
= parse_operand (&e1
);
3711 parse_operand (&e2
);
3713 if (e1
.X_op
!= O_constant
|| sep
!= ',' || e2
.X_op
!= O_constant
)
3714 as_bad ("Both operands of .save.gf must be constants.");
3717 int grmask
= e1
.X_add_number
;
3718 int frmask
= e2
.X_add_number
;
3719 add_unwind_entry (output_frgr_mem (grmask
, frmask
));
3725 int dummy ATTRIBUTE_UNUSED
;
3730 sep
= parse_operand (&e
);
3731 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3732 demand_empty_rest_of_line ();
3734 if (e
.X_op
!= O_constant
)
3735 as_bad ("Operand to .spill must be a constant");
3737 add_unwind_entry (output_spill_base (e
.X_add_number
));
3741 dot_spillreg (dummy
)
3742 int dummy ATTRIBUTE_UNUSED
;
3744 int sep
, ab
, xy
, reg
, treg
;
3747 sep
= parse_operand (&e1
);
3750 as_bad ("No second operand to .spillreg");
3754 parse_operand (&e2
);
3756 if (!convert_expr_to_ab_reg (&e1
, &ab
, ®
))
3758 as_bad ("First operand to .spillreg must be a preserved register");
3762 if (!convert_expr_to_xy_reg (&e2
, &xy
, &treg
))
3764 as_bad ("Second operand to .spillreg must be a register");
3768 add_unwind_entry (output_spill_reg (ab
, reg
, treg
, xy
));
3772 dot_spillmem (psprel
)
3778 sep
= parse_operand (&e1
);
3781 as_bad ("Second operand missing");
3785 parse_operand (&e2
);
3787 if (!convert_expr_to_ab_reg (&e1
, &ab
, ®
))
3789 as_bad ("First operand to .spill%s must be a preserved register",
3790 psprel
? "psp" : "sp");
3794 if (e2
.X_op
!= O_constant
)
3796 as_bad ("Second operand to .spill%s must be a constant",
3797 psprel
? "psp" : "sp");
3802 add_unwind_entry (output_spill_psprel (ab
, reg
, e2
.X_add_number
));
3804 add_unwind_entry (output_spill_sprel (ab
, reg
, e2
.X_add_number
));
3808 dot_spillreg_p (dummy
)
3809 int dummy ATTRIBUTE_UNUSED
;
3811 int sep
, ab
, xy
, reg
, treg
;
3812 expressionS e1
, e2
, e3
;
3815 sep
= parse_operand (&e1
);
3818 as_bad ("No second and third operand to .spillreg.p");
3822 sep
= parse_operand (&e2
);
3825 as_bad ("No third operand to .spillreg.p");
3829 parse_operand (&e3
);
3831 qp
= e1
.X_add_number
- REG_P
;
3833 if (e1
.X_op
!= O_register
|| qp
> 63)
3835 as_bad ("First operand to .spillreg.p must be a predicate");
3839 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
3841 as_bad ("Second operand to .spillreg.p must be a preserved register");
3845 if (!convert_expr_to_xy_reg (&e3
, &xy
, &treg
))
3847 as_bad ("Third operand to .spillreg.p must be a register");
3851 add_unwind_entry (output_spill_reg_p (ab
, reg
, treg
, xy
, qp
));
3855 dot_spillmem_p (psprel
)
3858 expressionS e1
, e2
, e3
;
3862 sep
= parse_operand (&e1
);
3865 as_bad ("Second operand missing");
3869 parse_operand (&e2
);
3872 as_bad ("Second operand missing");
3876 parse_operand (&e3
);
3878 qp
= e1
.X_add_number
- REG_P
;
3879 if (e1
.X_op
!= O_register
|| qp
> 63)
3881 as_bad ("First operand to .spill%s_p must be a predicate",
3882 psprel
? "psp" : "sp");
3886 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
3888 as_bad ("Second operand to .spill%s_p must be a preserved register",
3889 psprel
? "psp" : "sp");
3893 if (e3
.X_op
!= O_constant
)
3895 as_bad ("Third operand to .spill%s_p must be a constant",
3896 psprel
? "psp" : "sp");
3901 add_unwind_entry (output_spill_psprel_p (ab
, reg
, e3
.X_add_number
, qp
));
3903 add_unwind_entry (output_spill_sprel_p (ab
, reg
, e3
.X_add_number
, qp
));
3907 get_saved_prologue_count (lbl
)
3910 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3912 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
3916 return lpc
->prologue_count
;
3918 as_bad ("Missing .label_state %ld", lbl
);
3923 save_prologue_count (lbl
, count
)
3927 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3929 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
3933 lpc
->prologue_count
= count
;
3936 label_prologue_count
*new_lpc
= xmalloc (sizeof (* new_lpc
));
3938 new_lpc
->next
= unwind
.saved_prologue_counts
;
3939 new_lpc
->label_number
= lbl
;
3940 new_lpc
->prologue_count
= count
;
3941 unwind
.saved_prologue_counts
= new_lpc
;
3946 free_saved_prologue_counts ()
3948 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3949 label_prologue_count
*next
;
3958 unwind
.saved_prologue_counts
= NULL
;
3962 dot_label_state (dummy
)
3963 int dummy ATTRIBUTE_UNUSED
;
3968 if (e
.X_op
!= O_constant
)
3970 as_bad ("Operand to .label_state must be a constant");
3973 add_unwind_entry (output_label_state (e
.X_add_number
));
3974 save_prologue_count (e
.X_add_number
, unwind
.prologue_count
);
3978 dot_copy_state (dummy
)
3979 int dummy ATTRIBUTE_UNUSED
;
3984 if (e
.X_op
!= O_constant
)
3986 as_bad ("Operand to .copy_state must be a constant");
3989 add_unwind_entry (output_copy_state (e
.X_add_number
));
3990 unwind
.prologue_count
= get_saved_prologue_count (e
.X_add_number
);
3995 int dummy ATTRIBUTE_UNUSED
;
4000 sep
= parse_operand (&e1
);
4003 as_bad ("Second operand to .unwabi missing");
4006 sep
= parse_operand (&e2
);
4007 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
4008 demand_empty_rest_of_line ();
4010 if (e1
.X_op
!= O_constant
)
4012 as_bad ("First operand to .unwabi must be a constant");
4016 if (e2
.X_op
!= O_constant
)
4018 as_bad ("Second operand to .unwabi must be a constant");
4022 add_unwind_entry (output_unwabi (e1
.X_add_number
, e2
.X_add_number
));
4026 dot_personality (dummy
)
4027 int dummy ATTRIBUTE_UNUSED
;
4031 name
= input_line_pointer
;
4032 c
= get_symbol_end ();
4033 p
= input_line_pointer
;
4034 unwind
.personality_routine
= symbol_find_or_make (name
);
4035 unwind
.force_unwind_entry
= 1;
4038 demand_empty_rest_of_line ();
4043 int dummy ATTRIBUTE_UNUSED
;
4048 unwind
.proc_start
= expr_build_dot ();
4049 /* Parse names of main and alternate entry points and mark them as
4050 function symbols: */
4054 name
= input_line_pointer
;
4055 c
= get_symbol_end ();
4056 p
= input_line_pointer
;
4057 sym
= symbol_find_or_make (name
);
4058 if (unwind
.proc_start
== 0)
4060 unwind
.proc_start
= sym
;
4062 symbol_get_bfdsym (sym
)->flags
|= BSF_FUNCTION
;
4065 if (*input_line_pointer
!= ',')
4067 ++input_line_pointer
;
4069 demand_empty_rest_of_line ();
4072 unwind
.prologue_count
= 0;
4073 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
4074 unwind
.personality_routine
= 0;
4079 int dummy ATTRIBUTE_UNUSED
;
4081 unwind
.prologue
= 0;
4082 unwind
.prologue_mask
= 0;
4084 add_unwind_entry (output_body ());
4085 demand_empty_rest_of_line ();
4089 dot_prologue (dummy
)
4090 int dummy ATTRIBUTE_UNUSED
;
4093 int mask
= 0, grsave
= 0;
4095 if (!is_it_end_of_statement ())
4098 sep
= parse_operand (&e1
);
4100 as_bad ("No second operand to .prologue");
4101 sep
= parse_operand (&e2
);
4102 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
4103 demand_empty_rest_of_line ();
4105 if (e1
.X_op
== O_constant
)
4107 mask
= e1
.X_add_number
;
4109 if (e2
.X_op
== O_constant
)
4110 grsave
= e2
.X_add_number
;
4111 else if (e2
.X_op
== O_register
4112 && (grsave
= e2
.X_add_number
- REG_GR
) < 128)
4115 as_bad ("Second operand not a constant or general register");
4117 add_unwind_entry (output_prologue_gr (mask
, grsave
));
4120 as_bad ("First operand not a constant");
4123 add_unwind_entry (output_prologue ());
4125 unwind
.prologue
= 1;
4126 unwind
.prologue_mask
= mask
;
4127 ++unwind
.prologue_count
;
4132 int dummy ATTRIBUTE_UNUSED
;
4136 int bytes_per_address
;
4139 subsegT saved_subseg
;
4143 if (unwind
.saved_text_seg
)
4145 saved_seg
= unwind
.saved_text_seg
;
4146 saved_subseg
= unwind
.saved_text_subseg
;
4147 unwind
.saved_text_seg
= NULL
;
4151 saved_seg
= now_seg
;
4152 saved_subseg
= now_subseg
;
4155 insn_group_break (1, 0, 0);
4157 /* If there wasn't a .handlerdata, we haven't generated an image yet. */
4159 generate_unwind_image (saved_seg
);
4161 if (unwind
.info
|| unwind
.force_unwind_entry
)
4163 subseg_set (md
.last_text_seg
, 0);
4164 unwind
.proc_end
= expr_build_dot ();
4166 start_unwind_section (saved_seg
, SPECIAL_SECTION_UNWIND
, 0);
4168 /* Make sure that section has 4 byte alignment for ILP32 and
4169 8 byte alignment for LP64. */
4170 record_alignment (now_seg
, md
.pointer_size_shift
);
4172 /* Need space for 3 pointers for procedure start, procedure end,
4174 ptr
= frag_more (3 * md
.pointer_size
);
4175 where
= frag_now_fix () - (3 * md
.pointer_size
);
4176 bytes_per_address
= bfd_arch_bits_per_address (stdoutput
) / 8;
4178 /* Issue the values of a) Proc Begin, b) Proc End, c) Unwind Record. */
4179 e
.X_op
= O_pseudo_fixup
;
4180 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4182 e
.X_add_symbol
= unwind
.proc_start
;
4183 ia64_cons_fix_new (frag_now
, where
, bytes_per_address
, &e
);
4185 e
.X_op
= O_pseudo_fixup
;
4186 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4188 e
.X_add_symbol
= unwind
.proc_end
;
4189 ia64_cons_fix_new (frag_now
, where
+ bytes_per_address
,
4190 bytes_per_address
, &e
);
4194 e
.X_op
= O_pseudo_fixup
;
4195 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4197 e
.X_add_symbol
= unwind
.info
;
4198 ia64_cons_fix_new (frag_now
, where
+ (bytes_per_address
* 2),
4199 bytes_per_address
, &e
);
4202 md_number_to_chars (ptr
+ (bytes_per_address
* 2), 0,
4207 start_unwind_section (saved_seg
, SPECIAL_SECTION_UNWIND
, 1);
4209 subseg_set (saved_seg
, saved_subseg
);
4211 /* Parse names of main and alternate entry points and set symbol sizes. */
4215 name
= input_line_pointer
;
4216 c
= get_symbol_end ();
4217 p
= input_line_pointer
;
4218 sym
= symbol_find (name
);
4219 if (sym
&& unwind
.proc_start
4220 && (symbol_get_bfdsym (sym
)->flags
& BSF_FUNCTION
)
4221 && S_GET_SIZE (sym
) == 0 && symbol_get_obj (sym
)->size
== NULL
)
4223 fragS
*fr
= symbol_get_frag (unwind
.proc_start
);
4224 fragS
*frag
= symbol_get_frag (sym
);
4226 /* Check whether the function label is at or beyond last
4228 while (fr
&& fr
!= frag
)
4232 if (frag
== frag_now
&& SEG_NORMAL (now_seg
))
4233 S_SET_SIZE (sym
, frag_now_fix () - S_GET_VALUE (sym
));
4236 symbol_get_obj (sym
)->size
=
4237 (expressionS
*) xmalloc (sizeof (expressionS
));
4238 symbol_get_obj (sym
)->size
->X_op
= O_subtract
;
4239 symbol_get_obj (sym
)->size
->X_add_symbol
4240 = symbol_new (FAKE_LABEL_NAME
, now_seg
,
4241 frag_now_fix (), frag_now
);
4242 symbol_get_obj (sym
)->size
->X_op_symbol
= sym
;
4243 symbol_get_obj (sym
)->size
->X_add_number
= 0;
4249 if (*input_line_pointer
!= ',')
4251 ++input_line_pointer
;
4253 demand_empty_rest_of_line ();
4254 unwind
.proc_start
= unwind
.proc_end
= unwind
.info
= 0;
4258 dot_template (template)
4261 CURR_SLOT
.user_template
= template;
4266 int dummy ATTRIBUTE_UNUSED
;
4268 int ins
, locs
, outs
, rots
;
4270 if (is_it_end_of_statement ())
4271 ins
= locs
= outs
= rots
= 0;
4274 ins
= get_absolute_expression ();
4275 if (*input_line_pointer
++ != ',')
4277 locs
= get_absolute_expression ();
4278 if (*input_line_pointer
++ != ',')
4280 outs
= get_absolute_expression ();
4281 if (*input_line_pointer
++ != ',')
4283 rots
= get_absolute_expression ();
4285 set_regstack (ins
, locs
, outs
, rots
);
4289 as_bad ("Comma expected");
4290 ignore_rest_of_line ();
4297 unsigned num_regs
, num_alloced
= 0;
4298 struct dynreg
**drpp
, *dr
;
4299 int ch
, base_reg
= 0;
4305 case DYNREG_GR
: base_reg
= REG_GR
+ 32; break;
4306 case DYNREG_FR
: base_reg
= REG_FR
+ 32; break;
4307 case DYNREG_PR
: base_reg
= REG_P
+ 16; break;
4311 /* First, remove existing names from hash table. */
4312 for (dr
= md
.dynreg
[type
]; dr
&& dr
->num_regs
; dr
= dr
->next
)
4314 hash_delete (md
.dynreg_hash
, dr
->name
);
4318 drpp
= &md
.dynreg
[type
];
4321 start
= input_line_pointer
;
4322 ch
= get_symbol_end ();
4323 *input_line_pointer
= ch
;
4324 len
= (input_line_pointer
- start
);
4327 if (*input_line_pointer
!= '[')
4329 as_bad ("Expected '['");
4332 ++input_line_pointer
; /* skip '[' */
4334 num_regs
= get_absolute_expression ();
4336 if (*input_line_pointer
++ != ']')
4338 as_bad ("Expected ']'");
4343 num_alloced
+= num_regs
;
4347 if (num_alloced
> md
.rot
.num_regs
)
4349 as_bad ("Used more than the declared %d rotating registers",
4355 if (num_alloced
> 96)
4357 as_bad ("Used more than the available 96 rotating registers");
4362 if (num_alloced
> 48)
4364 as_bad ("Used more than the available 48 rotating registers");
4373 name
= obstack_alloc (¬es
, len
+ 1);
4374 memcpy (name
, start
, len
);
4379 *drpp
= obstack_alloc (¬es
, sizeof (*dr
));
4380 memset (*drpp
, 0, sizeof (*dr
));
4385 dr
->num_regs
= num_regs
;
4386 dr
->base
= base_reg
;
4388 base_reg
+= num_regs
;
4390 if (hash_insert (md
.dynreg_hash
, name
, dr
))
4392 as_bad ("Attempt to redefine register set `%s'", name
);
4396 if (*input_line_pointer
!= ',')
4398 ++input_line_pointer
; /* skip comma */
4401 demand_empty_rest_of_line ();
4405 ignore_rest_of_line ();
4409 dot_byteorder (byteorder
)
4412 segment_info_type
*seginfo
= seg_info (now_seg
);
4414 if (byteorder
== -1)
4416 if (seginfo
->tc_segment_info_data
.endian
== 0)
4417 seginfo
->tc_segment_info_data
.endian
= default_big_endian
? 1 : 2;
4418 byteorder
= seginfo
->tc_segment_info_data
.endian
== 1;
4421 seginfo
->tc_segment_info_data
.endian
= byteorder
? 1 : 2;
4423 if (target_big_endian
!= byteorder
)
4425 target_big_endian
= byteorder
;
4426 if (target_big_endian
)
4428 ia64_number_to_chars
= number_to_chars_bigendian
;
4429 ia64_float_to_chars
= ia64_float_to_chars_bigendian
;
4433 ia64_number_to_chars
= number_to_chars_littleendian
;
4434 ia64_float_to_chars
= ia64_float_to_chars_littleendian
;
4441 int dummy ATTRIBUTE_UNUSED
;
4448 option
= input_line_pointer
;
4449 ch
= get_symbol_end ();
4450 if (strcmp (option
, "lsb") == 0)
4451 md
.flags
&= ~EF_IA_64_BE
;
4452 else if (strcmp (option
, "msb") == 0)
4453 md
.flags
|= EF_IA_64_BE
;
4454 else if (strcmp (option
, "abi32") == 0)
4455 md
.flags
&= ~EF_IA_64_ABI64
;
4456 else if (strcmp (option
, "abi64") == 0)
4457 md
.flags
|= EF_IA_64_ABI64
;
4459 as_bad ("Unknown psr option `%s'", option
);
4460 *input_line_pointer
= ch
;
4463 if (*input_line_pointer
!= ',')
4466 ++input_line_pointer
;
4469 demand_empty_rest_of_line ();
4474 int dummy ATTRIBUTE_UNUSED
;
4476 new_logical_line (0, get_absolute_expression ());
4477 demand_empty_rest_of_line ();
4481 parse_section_name ()
4487 if (*input_line_pointer
!= '"')
4489 as_bad ("Missing section name");
4490 ignore_rest_of_line ();
4493 name
= demand_copy_C_string (&len
);
4496 ignore_rest_of_line ();
4500 if (*input_line_pointer
!= ',')
4502 as_bad ("Comma expected after section name");
4503 ignore_rest_of_line ();
4506 ++input_line_pointer
; /* skip comma */
4514 char *name
= parse_section_name ();
4518 md
.keep_pending_output
= 1;
4521 obj_elf_previous (0);
4522 md
.keep_pending_output
= 0;
4525 /* Why doesn't float_cons() call md_cons_align() the way cons() does? */
4528 stmt_float_cons (kind
)
4549 ia64_do_align (alignment
);
4557 int saved_auto_align
= md
.auto_align
;
4561 md
.auto_align
= saved_auto_align
;
4565 dot_xfloat_cons (kind
)
4568 char *name
= parse_section_name ();
4572 md
.keep_pending_output
= 1;
4574 stmt_float_cons (kind
);
4575 obj_elf_previous (0);
4576 md
.keep_pending_output
= 0;
4580 dot_xstringer (zero
)
4583 char *name
= parse_section_name ();
4587 md
.keep_pending_output
= 1;
4590 obj_elf_previous (0);
4591 md
.keep_pending_output
= 0;
4598 int saved_auto_align
= md
.auto_align
;
4599 char *name
= parse_section_name ();
4603 md
.keep_pending_output
= 1;
4607 md
.auto_align
= saved_auto_align
;
4608 obj_elf_previous (0);
4609 md
.keep_pending_output
= 0;
4613 dot_xfloat_cons_ua (kind
)
4616 int saved_auto_align
= md
.auto_align
;
4617 char *name
= parse_section_name ();
4621 md
.keep_pending_output
= 1;
4624 stmt_float_cons (kind
);
4625 md
.auto_align
= saved_auto_align
;
4626 obj_elf_previous (0);
4627 md
.keep_pending_output
= 0;
4630 /* .reg.val <regname>,value */
4634 int dummy ATTRIBUTE_UNUSED
;
4639 if (reg
.X_op
!= O_register
)
4641 as_bad (_("Register name expected"));
4642 ignore_rest_of_line ();
4644 else if (*input_line_pointer
++ != ',')
4646 as_bad (_("Comma expected"));
4647 ignore_rest_of_line ();
4651 valueT value
= get_absolute_expression ();
4652 int regno
= reg
.X_add_number
;
4653 if (regno
< REG_GR
|| regno
> REG_GR
+ 128)
4654 as_warn (_("Register value annotation ignored"));
4657 gr_values
[regno
- REG_GR
].known
= 1;
4658 gr_values
[regno
- REG_GR
].value
= value
;
4659 gr_values
[regno
- REG_GR
].path
= md
.path
;
4662 demand_empty_rest_of_line ();
4667 .serialize.instruction
4670 dot_serialize (type
)
4673 insn_group_break (0, 0, 0);
4675 instruction_serialization ();
4677 data_serialization ();
4678 insn_group_break (0, 0, 0);
4679 demand_empty_rest_of_line ();
4682 /* select dv checking mode
4687 A stop is inserted when changing modes
4694 if (md
.manual_bundling
)
4695 as_warn (_("Directive invalid within a bundle"));
4697 if (type
== 'E' || type
== 'A')
4698 md
.mode_explicitly_set
= 0;
4700 md
.mode_explicitly_set
= 1;
4707 if (md
.explicit_mode
)
4708 insn_group_break (1, 0, 0);
4709 md
.explicit_mode
= 0;
4713 if (!md
.explicit_mode
)
4714 insn_group_break (1, 0, 0);
4715 md
.explicit_mode
= 1;
4719 if (md
.explicit_mode
!= md
.default_explicit_mode
)
4720 insn_group_break (1, 0, 0);
4721 md
.explicit_mode
= md
.default_explicit_mode
;
4722 md
.mode_explicitly_set
= 0;
4733 for (regno
= 0; regno
< 64; regno
++)
4735 if (mask
& ((valueT
) 1 << regno
))
4737 fprintf (stderr
, "%s p%d", comma
, regno
);
4744 .pred.rel.clear [p1 [,p2 [,...]]] (also .pred.rel "clear")
4745 .pred.rel.imply p1, p2 (also .pred.rel "imply")
4746 .pred.rel.mutex p1, p2 [,...] (also .pred.rel "mutex")
4747 .pred.safe_across_calls p1 [, p2 [,...]]
4756 int p1
= -1, p2
= -1;
4760 if (*input_line_pointer
!= '"')
4762 as_bad (_("Missing predicate relation type"));
4763 ignore_rest_of_line ();
4769 char *form
= demand_copy_C_string (&len
);
4770 if (strcmp (form
, "mutex") == 0)
4772 else if (strcmp (form
, "clear") == 0)
4774 else if (strcmp (form
, "imply") == 0)
4778 as_bad (_("Unrecognized predicate relation type"));
4779 ignore_rest_of_line ();
4783 if (*input_line_pointer
== ',')
4784 ++input_line_pointer
;
4794 if (TOUPPER (*input_line_pointer
) != 'P'
4795 || (regno
= atoi (++input_line_pointer
)) < 0
4798 as_bad (_("Predicate register expected"));
4799 ignore_rest_of_line ();
4802 while (ISDIGIT (*input_line_pointer
))
4803 ++input_line_pointer
;
4810 as_warn (_("Duplicate predicate register ignored"));
4813 /* See if it's a range. */
4814 if (*input_line_pointer
== '-')
4817 ++input_line_pointer
;
4819 if (TOUPPER (*input_line_pointer
) != 'P'
4820 || (regno
= atoi (++input_line_pointer
)) < 0
4823 as_bad (_("Predicate register expected"));
4824 ignore_rest_of_line ();
4827 while (ISDIGIT (*input_line_pointer
))
4828 ++input_line_pointer
;
4832 as_bad (_("Bad register range"));
4833 ignore_rest_of_line ();
4844 if (*input_line_pointer
!= ',')
4846 ++input_line_pointer
;
4855 clear_qp_mutex (mask
);
4856 clear_qp_implies (mask
, (valueT
) 0);
4859 if (count
!= 2 || p1
== -1 || p2
== -1)
4860 as_bad (_("Predicate source and target required"));
4861 else if (p1
== 0 || p2
== 0)
4862 as_bad (_("Use of p0 is not valid in this context"));
4864 add_qp_imply (p1
, p2
);
4869 as_bad (_("At least two PR arguments expected"));
4874 as_bad (_("Use of p0 is not valid in this context"));
4877 add_qp_mutex (mask
);
4880 /* note that we don't override any existing relations */
4883 as_bad (_("At least one PR argument expected"));
4888 fprintf (stderr
, "Safe across calls: ");
4889 print_prmask (mask
);
4890 fprintf (stderr
, "\n");
4892 qp_safe_across_calls
= mask
;
4895 demand_empty_rest_of_line ();
4898 /* .entry label [, label [, ...]]
4899 Hint to DV code that the given labels are to be considered entry points.
4900 Otherwise, only global labels are considered entry points. */
4904 int dummy ATTRIBUTE_UNUSED
;
4913 name
= input_line_pointer
;
4914 c
= get_symbol_end ();
4915 symbolP
= symbol_find_or_make (name
);
4917 err
= hash_insert (md
.entry_hash
, S_GET_NAME (symbolP
), (PTR
) symbolP
);
4919 as_fatal (_("Inserting \"%s\" into entry hint table failed: %s"),
4922 *input_line_pointer
= c
;
4924 c
= *input_line_pointer
;
4927 input_line_pointer
++;
4929 if (*input_line_pointer
== '\n')
4935 demand_empty_rest_of_line ();
4938 /* .mem.offset offset, base
4939 "base" is used to distinguish between offsets from a different base. */
4942 dot_mem_offset (dummy
)
4943 int dummy ATTRIBUTE_UNUSED
;
4945 md
.mem_offset
.hint
= 1;
4946 md
.mem_offset
.offset
= get_absolute_expression ();
4947 if (*input_line_pointer
!= ',')
4949 as_bad (_("Comma expected"));
4950 ignore_rest_of_line ();
4953 ++input_line_pointer
;
4954 md
.mem_offset
.base
= get_absolute_expression ();
4955 demand_empty_rest_of_line ();
4958 /* ia64-specific pseudo-ops: */
4959 const pseudo_typeS md_pseudo_table
[] =
4961 { "radix", dot_radix
, 0 },
4962 { "lcomm", s_lcomm_bytes
, 1 },
4963 { "bss", dot_special_section
, SPECIAL_SECTION_BSS
},
4964 { "sbss", dot_special_section
, SPECIAL_SECTION_SBSS
},
4965 { "sdata", dot_special_section
, SPECIAL_SECTION_SDATA
},
4966 { "rodata", dot_special_section
, SPECIAL_SECTION_RODATA
},
4967 { "comment", dot_special_section
, SPECIAL_SECTION_COMMENT
},
4968 { "ia_64.unwind", dot_special_section
, SPECIAL_SECTION_UNWIND
},
4969 { "ia_64.unwind_info", dot_special_section
, SPECIAL_SECTION_UNWIND_INFO
},
4970 { "init_array", dot_special_section
, SPECIAL_SECTION_INIT_ARRAY
},
4971 { "fini_array", dot_special_section
, SPECIAL_SECTION_FINI_ARRAY
},
4972 { "proc", dot_proc
, 0 },
4973 { "body", dot_body
, 0 },
4974 { "prologue", dot_prologue
, 0 },
4975 { "endp", dot_endp
, 0 },
4977 { "fframe", dot_fframe
, 0 },
4978 { "vframe", dot_vframe
, 0 },
4979 { "vframesp", dot_vframesp
, 0 },
4980 { "vframepsp", dot_vframepsp
, 0 },
4981 { "save", dot_save
, 0 },
4982 { "restore", dot_restore
, 0 },
4983 { "restorereg", dot_restorereg
, 0 },
4984 { "restorereg.p", dot_restorereg_p
, 0 },
4985 { "handlerdata", dot_handlerdata
, 0 },
4986 { "unwentry", dot_unwentry
, 0 },
4987 { "altrp", dot_altrp
, 0 },
4988 { "savesp", dot_savemem
, 0 },
4989 { "savepsp", dot_savemem
, 1 },
4990 { "save.g", dot_saveg
, 0 },
4991 { "save.f", dot_savef
, 0 },
4992 { "save.b", dot_saveb
, 0 },
4993 { "save.gf", dot_savegf
, 0 },
4994 { "spill", dot_spill
, 0 },
4995 { "spillreg", dot_spillreg
, 0 },
4996 { "spillsp", dot_spillmem
, 0 },
4997 { "spillpsp", dot_spillmem
, 1 },
4998 { "spillreg.p", dot_spillreg_p
, 0 },
4999 { "spillsp.p", dot_spillmem_p
, 0 },
5000 { "spillpsp.p", dot_spillmem_p
, 1 },
5001 { "label_state", dot_label_state
, 0 },
5002 { "copy_state", dot_copy_state
, 0 },
5003 { "unwabi", dot_unwabi
, 0 },
5004 { "personality", dot_personality
, 0 },
5006 { "estate", dot_estate
, 0 },
5008 { "mii", dot_template
, 0x0 },
5009 { "mli", dot_template
, 0x2 }, /* old format, for compatibility */
5010 { "mlx", dot_template
, 0x2 },
5011 { "mmi", dot_template
, 0x4 },
5012 { "mfi", dot_template
, 0x6 },
5013 { "mmf", dot_template
, 0x7 },
5014 { "mib", dot_template
, 0x8 },
5015 { "mbb", dot_template
, 0x9 },
5016 { "bbb", dot_template
, 0xb },
5017 { "mmb", dot_template
, 0xc },
5018 { "mfb", dot_template
, 0xe },
5020 { "lb", dot_scope
, 0 },
5021 { "le", dot_scope
, 1 },
5023 { "align", dot_align
, 0 },
5024 { "regstk", dot_regstk
, 0 },
5025 { "rotr", dot_rot
, DYNREG_GR
},
5026 { "rotf", dot_rot
, DYNREG_FR
},
5027 { "rotp", dot_rot
, DYNREG_PR
},
5028 { "lsb", dot_byteorder
, 0 },
5029 { "msb", dot_byteorder
, 1 },
5030 { "psr", dot_psr
, 0 },
5031 { "alias", dot_alias
, 0 },
5032 { "secalias", dot_alias
, 1 },
5033 { "ln", dot_ln
, 0 }, /* source line info (for debugging) */
5035 { "xdata1", dot_xdata
, 1 },
5036 { "xdata2", dot_xdata
, 2 },
5037 { "xdata4", dot_xdata
, 4 },
5038 { "xdata8", dot_xdata
, 8 },
5039 { "xreal4", dot_xfloat_cons
, 'f' },
5040 { "xreal8", dot_xfloat_cons
, 'd' },
5041 { "xreal10", dot_xfloat_cons
, 'x' },
5042 { "xreal16", dot_xfloat_cons
, 'X' },
5043 { "xstring", dot_xstringer
, 0 },
5044 { "xstringz", dot_xstringer
, 1 },
5046 /* unaligned versions: */
5047 { "xdata2.ua", dot_xdata_ua
, 2 },
5048 { "xdata4.ua", dot_xdata_ua
, 4 },
5049 { "xdata8.ua", dot_xdata_ua
, 8 },
5050 { "xreal4.ua", dot_xfloat_cons_ua
, 'f' },
5051 { "xreal8.ua", dot_xfloat_cons_ua
, 'd' },
5052 { "xreal10.ua", dot_xfloat_cons_ua
, 'x' },
5053 { "xreal16.ua", dot_xfloat_cons_ua
, 'X' },
5055 /* annotations/DV checking support */
5056 { "entry", dot_entry
, 0 },
5057 { "mem.offset", dot_mem_offset
, 0 },
5058 { "pred.rel", dot_pred_rel
, 0 },
5059 { "pred.rel.clear", dot_pred_rel
, 'c' },
5060 { "pred.rel.imply", dot_pred_rel
, 'i' },
5061 { "pred.rel.mutex", dot_pred_rel
, 'm' },
5062 { "pred.safe_across_calls", dot_pred_rel
, 's' },
5063 { "reg.val", dot_reg_val
, 0 },
5064 { "serialize.data", dot_serialize
, 0 },
5065 { "serialize.instruction", dot_serialize
, 1 },
5066 { "auto", dot_dv_mode
, 'a' },
5067 { "explicit", dot_dv_mode
, 'e' },
5068 { "default", dot_dv_mode
, 'd' },
5070 /* ??? These are needed to make gas/testsuite/gas/elf/ehopt.s work.
5071 IA-64 aligns data allocation pseudo-ops by default, so we have to
5072 tell it that these ones are supposed to be unaligned. Long term,
5073 should rewrite so that only IA-64 specific data allocation pseudo-ops
5074 are aligned by default. */
5075 {"2byte", stmt_cons_ua
, 2},
5076 {"4byte", stmt_cons_ua
, 4},
5077 {"8byte", stmt_cons_ua
, 8},
5082 static const struct pseudo_opcode
5085 void (*handler
) (int);
5090 /* these are more like pseudo-ops, but don't start with a dot */
5091 { "data1", cons
, 1 },
5092 { "data2", cons
, 2 },
5093 { "data4", cons
, 4 },
5094 { "data8", cons
, 8 },
5095 { "data16", cons
, 16 },
5096 { "real4", stmt_float_cons
, 'f' },
5097 { "real8", stmt_float_cons
, 'd' },
5098 { "real10", stmt_float_cons
, 'x' },
5099 { "real16", stmt_float_cons
, 'X' },
5100 { "string", stringer
, 0 },
5101 { "stringz", stringer
, 1 },
5103 /* unaligned versions: */
5104 { "data2.ua", stmt_cons_ua
, 2 },
5105 { "data4.ua", stmt_cons_ua
, 4 },
5106 { "data8.ua", stmt_cons_ua
, 8 },
5107 { "data16.ua", stmt_cons_ua
, 16 },
5108 { "real4.ua", float_cons
, 'f' },
5109 { "real8.ua", float_cons
, 'd' },
5110 { "real10.ua", float_cons
, 'x' },
5111 { "real16.ua", float_cons
, 'X' },
5114 /* Declare a register by creating a symbol for it and entering it in
5115 the symbol table. */
5118 declare_register (name
, regnum
)
5125 sym
= symbol_new (name
, reg_section
, regnum
, &zero_address_frag
);
5127 err
= hash_insert (md
.reg_hash
, S_GET_NAME (sym
), (PTR
) sym
);
5129 as_fatal ("Inserting \"%s\" into register table failed: %s",
5136 declare_register_set (prefix
, num_regs
, base_regnum
)
5144 for (i
= 0; i
< num_regs
; ++i
)
5146 sprintf (name
, "%s%u", prefix
, i
);
5147 declare_register (name
, base_regnum
+ i
);
5152 operand_width (opnd
)
5153 enum ia64_opnd opnd
;
5155 const struct ia64_operand
*odesc
= &elf64_ia64_operands
[opnd
];
5156 unsigned int bits
= 0;
5160 for (i
= 0; i
< NELEMS (odesc
->field
) && odesc
->field
[i
].bits
; ++i
)
5161 bits
+= odesc
->field
[i
].bits
;
5166 static enum operand_match_result
5167 operand_match (idesc
, index
, e
)
5168 const struct ia64_opcode
*idesc
;
5172 enum ia64_opnd opnd
= idesc
->operands
[index
];
5173 int bits
, relocatable
= 0;
5174 struct insn_fix
*fix
;
5181 case IA64_OPND_AR_CCV
:
5182 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 32)
5183 return OPERAND_MATCH
;
5186 case IA64_OPND_AR_CSD
:
5187 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 25)
5188 return OPERAND_MATCH
;
5191 case IA64_OPND_AR_PFS
:
5192 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 64)
5193 return OPERAND_MATCH
;
5197 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_GR
+ 0)
5198 return OPERAND_MATCH
;
5202 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_IP
)
5203 return OPERAND_MATCH
;
5207 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR
)
5208 return OPERAND_MATCH
;
5211 case IA64_OPND_PR_ROT
:
5212 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR_ROT
)
5213 return OPERAND_MATCH
;
5217 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR
)
5218 return OPERAND_MATCH
;
5221 case IA64_OPND_PSR_L
:
5222 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_L
)
5223 return OPERAND_MATCH
;
5226 case IA64_OPND_PSR_UM
:
5227 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_UM
)
5228 return OPERAND_MATCH
;
5232 if (e
->X_op
== O_constant
)
5234 if (e
->X_add_number
== 1)
5235 return OPERAND_MATCH
;
5237 return OPERAND_OUT_OF_RANGE
;
5242 if (e
->X_op
== O_constant
)
5244 if (e
->X_add_number
== 8)
5245 return OPERAND_MATCH
;
5247 return OPERAND_OUT_OF_RANGE
;
5252 if (e
->X_op
== O_constant
)
5254 if (e
->X_add_number
== 16)
5255 return OPERAND_MATCH
;
5257 return OPERAND_OUT_OF_RANGE
;
5261 /* register operands: */
5264 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_AR
5265 && e
->X_add_number
< REG_AR
+ 128)
5266 return OPERAND_MATCH
;
5271 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_BR
5272 && e
->X_add_number
< REG_BR
+ 8)
5273 return OPERAND_MATCH
;
5277 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_CR
5278 && e
->X_add_number
< REG_CR
+ 128)
5279 return OPERAND_MATCH
;
5286 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_FR
5287 && e
->X_add_number
< REG_FR
+ 128)
5288 return OPERAND_MATCH
;
5293 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_P
5294 && e
->X_add_number
< REG_P
+ 64)
5295 return OPERAND_MATCH
;
5301 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
5302 && e
->X_add_number
< REG_GR
+ 128)
5303 return OPERAND_MATCH
;
5306 case IA64_OPND_R3_2
:
5307 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
)
5309 if (e
->X_add_number
< REG_GR
+ 4)
5310 return OPERAND_MATCH
;
5311 else if (e
->X_add_number
< REG_GR
+ 128)
5312 return OPERAND_OUT_OF_RANGE
;
5316 /* indirect operands: */
5317 case IA64_OPND_CPUID_R3
:
5318 case IA64_OPND_DBR_R3
:
5319 case IA64_OPND_DTR_R3
:
5320 case IA64_OPND_ITR_R3
:
5321 case IA64_OPND_IBR_R3
:
5322 case IA64_OPND_MSR_R3
:
5323 case IA64_OPND_PKR_R3
:
5324 case IA64_OPND_PMC_R3
:
5325 case IA64_OPND_PMD_R3
:
5326 case IA64_OPND_RR_R3
:
5327 if (e
->X_op
== O_index
&& e
->X_op_symbol
5328 && (S_GET_VALUE (e
->X_op_symbol
) - IND_CPUID
5329 == opnd
- IA64_OPND_CPUID_R3
))
5330 return OPERAND_MATCH
;
5334 if (e
->X_op
== O_index
&& !e
->X_op_symbol
)
5335 return OPERAND_MATCH
;
5338 /* immediate operands: */
5339 case IA64_OPND_CNT2a
:
5340 case IA64_OPND_LEN4
:
5341 case IA64_OPND_LEN6
:
5342 bits
= operand_width (idesc
->operands
[index
]);
5343 if (e
->X_op
== O_constant
)
5345 if ((bfd_vma
) (e
->X_add_number
- 1) < ((bfd_vma
) 1 << bits
))
5346 return OPERAND_MATCH
;
5348 return OPERAND_OUT_OF_RANGE
;
5352 case IA64_OPND_CNT2b
:
5353 if (e
->X_op
== O_constant
)
5355 if ((bfd_vma
) (e
->X_add_number
- 1) < 3)
5356 return OPERAND_MATCH
;
5358 return OPERAND_OUT_OF_RANGE
;
5362 case IA64_OPND_CNT2c
:
5363 val
= e
->X_add_number
;
5364 if (e
->X_op
== O_constant
)
5366 if ((val
== 0 || val
== 7 || val
== 15 || val
== 16))
5367 return OPERAND_MATCH
;
5369 return OPERAND_OUT_OF_RANGE
;
5374 /* SOR must be an integer multiple of 8 */
5375 if (e
->X_op
== O_constant
&& e
->X_add_number
& 0x7)
5376 return OPERAND_OUT_OF_RANGE
;
5379 if (e
->X_op
== O_constant
)
5381 if ((bfd_vma
) e
->X_add_number
<= 96)
5382 return OPERAND_MATCH
;
5384 return OPERAND_OUT_OF_RANGE
;
5388 case IA64_OPND_IMMU62
:
5389 if (e
->X_op
== O_constant
)
5391 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 62))
5392 return OPERAND_MATCH
;
5394 return OPERAND_OUT_OF_RANGE
;
5398 /* FIXME -- need 62-bit relocation type */
5399 as_bad (_("62-bit relocation not yet implemented"));
5403 case IA64_OPND_IMMU64
:
5404 if (e
->X_op
== O_symbol
|| e
->X_op
== O_pseudo_fixup
5405 || e
->X_op
== O_subtract
)
5407 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5408 fix
->code
= BFD_RELOC_IA64_IMM64
;
5409 if (e
->X_op
!= O_subtract
)
5411 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5412 if (e
->X_op
== O_pseudo_fixup
)
5416 fix
->opnd
= idesc
->operands
[index
];
5419 ++CURR_SLOT
.num_fixups
;
5420 return OPERAND_MATCH
;
5422 else if (e
->X_op
== O_constant
)
5423 return OPERAND_MATCH
;
5426 case IA64_OPND_CCNT5
:
5427 case IA64_OPND_CNT5
:
5428 case IA64_OPND_CNT6
:
5429 case IA64_OPND_CPOS6a
:
5430 case IA64_OPND_CPOS6b
:
5431 case IA64_OPND_CPOS6c
:
5432 case IA64_OPND_IMMU2
:
5433 case IA64_OPND_IMMU7a
:
5434 case IA64_OPND_IMMU7b
:
5435 case IA64_OPND_IMMU21
:
5436 case IA64_OPND_IMMU24
:
5437 case IA64_OPND_MBTYPE4
:
5438 case IA64_OPND_MHTYPE8
:
5439 case IA64_OPND_POS6
:
5440 bits
= operand_width (idesc
->operands
[index
]);
5441 if (e
->X_op
== O_constant
)
5443 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5444 return OPERAND_MATCH
;
5446 return OPERAND_OUT_OF_RANGE
;
5450 case IA64_OPND_IMMU9
:
5451 bits
= operand_width (idesc
->operands
[index
]);
5452 if (e
->X_op
== O_constant
)
5454 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5456 int lobits
= e
->X_add_number
& 0x3;
5457 if (((bfd_vma
) e
->X_add_number
& 0x3C) != 0 && lobits
== 0)
5458 e
->X_add_number
|= (bfd_vma
) 0x3;
5459 return OPERAND_MATCH
;
5462 return OPERAND_OUT_OF_RANGE
;
5466 case IA64_OPND_IMM44
:
5467 /* least 16 bits must be zero */
5468 if ((e
->X_add_number
& 0xffff) != 0)
5469 /* XXX technically, this is wrong: we should not be issuing warning
5470 messages until we're sure this instruction pattern is going to
5472 as_warn (_("lower 16 bits of mask ignored"));
5474 if (e
->X_op
== O_constant
)
5476 if (((e
->X_add_number
>= 0
5477 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 44))
5478 || (e
->X_add_number
< 0
5479 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 44))))
5482 if (e
->X_add_number
>= 0
5483 && (e
->X_add_number
& ((bfd_vma
) 1 << 43)) != 0)
5485 e
->X_add_number
|= ~(((bfd_vma
) 1 << 44) - 1);
5487 return OPERAND_MATCH
;
5490 return OPERAND_OUT_OF_RANGE
;
5494 case IA64_OPND_IMM17
:
5495 /* bit 0 is a don't care (pr0 is hardwired to 1) */
5496 if (e
->X_op
== O_constant
)
5498 if (((e
->X_add_number
>= 0
5499 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 17))
5500 || (e
->X_add_number
< 0
5501 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 17))))
5504 if (e
->X_add_number
>= 0
5505 && (e
->X_add_number
& ((bfd_vma
) 1 << 16)) != 0)
5507 e
->X_add_number
|= ~(((bfd_vma
) 1 << 17) - 1);
5509 return OPERAND_MATCH
;
5512 return OPERAND_OUT_OF_RANGE
;
5516 case IA64_OPND_IMM14
:
5517 case IA64_OPND_IMM22
:
5519 case IA64_OPND_IMM1
:
5520 case IA64_OPND_IMM8
:
5521 case IA64_OPND_IMM8U4
:
5522 case IA64_OPND_IMM8M1
:
5523 case IA64_OPND_IMM8M1U4
:
5524 case IA64_OPND_IMM8M1U8
:
5525 case IA64_OPND_IMM9a
:
5526 case IA64_OPND_IMM9b
:
5527 bits
= operand_width (idesc
->operands
[index
]);
5528 if (relocatable
&& (e
->X_op
== O_symbol
5529 || e
->X_op
== O_subtract
5530 || e
->X_op
== O_pseudo_fixup
))
5532 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5534 if (idesc
->operands
[index
] == IA64_OPND_IMM14
)
5535 fix
->code
= BFD_RELOC_IA64_IMM14
;
5537 fix
->code
= BFD_RELOC_IA64_IMM22
;
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 && ! (e
->X_op
== O_big
&& opnd
== IA64_OPND_IMM8M1U8
))
5554 return OPERAND_MISMATCH
;
5556 if (opnd
== IA64_OPND_IMM8M1U4
)
5558 /* Zero is not valid for unsigned compares that take an adjusted
5559 constant immediate range. */
5560 if (e
->X_add_number
== 0)
5561 return OPERAND_OUT_OF_RANGE
;
5563 /* Sign-extend 32-bit unsigned numbers, so that the following range
5564 checks will work. */
5565 val
= e
->X_add_number
;
5566 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5567 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5568 val
= ((val
<< 32) >> 32);
5570 /* Check for 0x100000000. This is valid because
5571 0x100000000-1 is the same as ((uint32_t) -1). */
5572 if (val
== ((bfd_signed_vma
) 1 << 32))
5573 return OPERAND_MATCH
;
5577 else if (opnd
== IA64_OPND_IMM8M1U8
)
5579 /* Zero is not valid for unsigned compares that take an adjusted
5580 constant immediate range. */
5581 if (e
->X_add_number
== 0)
5582 return OPERAND_OUT_OF_RANGE
;
5584 /* Check for 0x10000000000000000. */
5585 if (e
->X_op
== O_big
)
5587 if (generic_bignum
[0] == 0
5588 && generic_bignum
[1] == 0
5589 && generic_bignum
[2] == 0
5590 && generic_bignum
[3] == 0
5591 && generic_bignum
[4] == 1)
5592 return OPERAND_MATCH
;
5594 return OPERAND_OUT_OF_RANGE
;
5597 val
= e
->X_add_number
- 1;
5599 else if (opnd
== IA64_OPND_IMM8M1
)
5600 val
= e
->X_add_number
- 1;
5601 else if (opnd
== IA64_OPND_IMM8U4
)
5603 /* Sign-extend 32-bit unsigned numbers, so that the following range
5604 checks will work. */
5605 val
= e
->X_add_number
;
5606 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5607 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5608 val
= ((val
<< 32) >> 32);
5611 val
= e
->X_add_number
;
5613 if ((val
>= 0 && (bfd_vma
) val
< ((bfd_vma
) 1 << (bits
- 1)))
5614 || (val
< 0 && (bfd_vma
) -val
<= ((bfd_vma
) 1 << (bits
- 1))))
5615 return OPERAND_MATCH
;
5617 return OPERAND_OUT_OF_RANGE
;
5619 case IA64_OPND_INC3
:
5620 /* +/- 1, 4, 8, 16 */
5621 val
= e
->X_add_number
;
5624 if (e
->X_op
== O_constant
)
5626 if ((val
== 1 || val
== 4 || val
== 8 || val
== 16))
5627 return OPERAND_MATCH
;
5629 return OPERAND_OUT_OF_RANGE
;
5633 case IA64_OPND_TGT25
:
5634 case IA64_OPND_TGT25b
:
5635 case IA64_OPND_TGT25c
:
5636 case IA64_OPND_TGT64
:
5637 if (e
->X_op
== O_symbol
)
5639 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5640 if (opnd
== IA64_OPND_TGT25
)
5641 fix
->code
= BFD_RELOC_IA64_PCREL21F
;
5642 else if (opnd
== IA64_OPND_TGT25b
)
5643 fix
->code
= BFD_RELOC_IA64_PCREL21M
;
5644 else if (opnd
== IA64_OPND_TGT25c
)
5645 fix
->code
= BFD_RELOC_IA64_PCREL21B
;
5646 else if (opnd
== IA64_OPND_TGT64
)
5647 fix
->code
= BFD_RELOC_IA64_PCREL60B
;
5651 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5652 fix
->opnd
= idesc
->operands
[index
];
5655 ++CURR_SLOT
.num_fixups
;
5656 return OPERAND_MATCH
;
5658 case IA64_OPND_TAG13
:
5659 case IA64_OPND_TAG13b
:
5663 return OPERAND_MATCH
;
5666 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5667 /* There are no external relocs for TAG13/TAG13b fields, so we
5668 create a dummy reloc. This will not live past md_apply_fix3. */
5669 fix
->code
= BFD_RELOC_UNUSED
;
5670 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5671 fix
->opnd
= idesc
->operands
[index
];
5674 ++CURR_SLOT
.num_fixups
;
5675 return OPERAND_MATCH
;
5682 case IA64_OPND_LDXMOV
:
5683 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5684 fix
->code
= BFD_RELOC_IA64_LDXMOV
;
5685 fix
->opnd
= idesc
->operands
[index
];
5688 ++CURR_SLOT
.num_fixups
;
5689 return OPERAND_MATCH
;
5694 return OPERAND_MISMATCH
;
5703 memset (e
, 0, sizeof (*e
));
5706 if (*input_line_pointer
!= '}')
5708 sep
= *input_line_pointer
++;
5712 if (!md
.manual_bundling
)
5713 as_warn ("Found '}' when manual bundling is off");
5715 CURR_SLOT
.manual_bundling_off
= 1;
5716 md
.manual_bundling
= 0;
5722 /* Returns the next entry in the opcode table that matches the one in
5723 IDESC, and frees the entry in IDESC. If no matching entry is
5724 found, NULL is returned instead. */
5726 static struct ia64_opcode
*
5727 get_next_opcode (struct ia64_opcode
*idesc
)
5729 struct ia64_opcode
*next
= ia64_find_next_opcode (idesc
);
5730 ia64_free_opcode (idesc
);
5734 /* Parse the operands for the opcode and find the opcode variant that
5735 matches the specified operands, or NULL if no match is possible. */
5737 static struct ia64_opcode
*
5738 parse_operands (idesc
)
5739 struct ia64_opcode
*idesc
;
5741 int i
= 0, highest_unmatched_operand
, num_operands
= 0, num_outputs
= 0;
5742 int error_pos
, out_of_range_pos
, curr_out_of_range_pos
, sep
= 0;
5743 enum ia64_opnd expected_operand
= IA64_OPND_NIL
;
5744 enum operand_match_result result
;
5746 char *first_arg
= 0, *end
, *saved_input_pointer
;
5749 assert (strlen (idesc
->name
) <= 128);
5751 strcpy (mnemonic
, idesc
->name
);
5752 if (idesc
->operands
[2] == IA64_OPND_SOF
)
5754 /* To make the common idiom "alloc loc?=ar.pfs,0,1,0,0" work, we
5755 can't parse the first operand until we have parsed the
5756 remaining operands of the "alloc" instruction. */
5758 first_arg
= input_line_pointer
;
5759 end
= strchr (input_line_pointer
, '=');
5762 as_bad ("Expected separator `='");
5765 input_line_pointer
= end
+ 1;
5770 for (; i
< NELEMS (CURR_SLOT
.opnd
); ++i
)
5772 sep
= parse_operand (CURR_SLOT
.opnd
+ i
);
5773 if (CURR_SLOT
.opnd
[i
].X_op
== O_absent
)
5778 if (sep
!= '=' && sep
!= ',')
5783 if (num_outputs
> 0)
5784 as_bad ("Duplicate equal sign (=) in instruction");
5786 num_outputs
= i
+ 1;
5791 as_bad ("Illegal operand separator `%c'", sep
);
5795 if (idesc
->operands
[2] == IA64_OPND_SOF
)
5797 /* map alloc r1=ar.pfs,i,l,o,r to alloc r1=ar.pfs,(i+l+o),(i+l),r */
5798 know (strcmp (idesc
->name
, "alloc") == 0);
5799 if (num_operands
== 5 /* first_arg not included in this count! */
5800 && CURR_SLOT
.opnd
[2].X_op
== O_constant
5801 && CURR_SLOT
.opnd
[3].X_op
== O_constant
5802 && CURR_SLOT
.opnd
[4].X_op
== O_constant
5803 && CURR_SLOT
.opnd
[5].X_op
== O_constant
)
5805 sof
= set_regstack (CURR_SLOT
.opnd
[2].X_add_number
,
5806 CURR_SLOT
.opnd
[3].X_add_number
,
5807 CURR_SLOT
.opnd
[4].X_add_number
,
5808 CURR_SLOT
.opnd
[5].X_add_number
);
5810 /* now we can parse the first arg: */
5811 saved_input_pointer
= input_line_pointer
;
5812 input_line_pointer
= first_arg
;
5813 sep
= parse_operand (CURR_SLOT
.opnd
+ 0);
5815 --num_outputs
; /* force error */
5816 input_line_pointer
= saved_input_pointer
;
5818 CURR_SLOT
.opnd
[2].X_add_number
= sof
;
5819 CURR_SLOT
.opnd
[3].X_add_number
5820 = sof
- CURR_SLOT
.opnd
[4].X_add_number
;
5821 CURR_SLOT
.opnd
[4] = CURR_SLOT
.opnd
[5];
5825 highest_unmatched_operand
= 0;
5826 curr_out_of_range_pos
= -1;
5828 expected_operand
= idesc
->operands
[0];
5829 for (; idesc
; idesc
= get_next_opcode (idesc
))
5831 if (num_outputs
!= idesc
->num_outputs
)
5832 continue; /* mismatch in # of outputs */
5834 CURR_SLOT
.num_fixups
= 0;
5836 /* Try to match all operands. If we see an out-of-range operand,
5837 then continue trying to match the rest of the operands, since if
5838 the rest match, then this idesc will give the best error message. */
5840 out_of_range_pos
= -1;
5841 for (i
= 0; i
< num_operands
&& idesc
->operands
[i
]; ++i
)
5843 result
= operand_match (idesc
, i
, CURR_SLOT
.opnd
+ i
);
5844 if (result
!= OPERAND_MATCH
)
5846 if (result
!= OPERAND_OUT_OF_RANGE
)
5848 if (out_of_range_pos
< 0)
5849 /* remember position of the first out-of-range operand: */
5850 out_of_range_pos
= i
;
5854 /* If we did not match all operands, or if at least one operand was
5855 out-of-range, then this idesc does not match. Keep track of which
5856 idesc matched the most operands before failing. If we have two
5857 idescs that failed at the same position, and one had an out-of-range
5858 operand, then prefer the out-of-range operand. Thus if we have
5859 "add r0=0x1000000,r1" we get an error saying the constant is out
5860 of range instead of an error saying that the constant should have been
5863 if (i
!= num_operands
|| out_of_range_pos
>= 0)
5865 if (i
> highest_unmatched_operand
5866 || (i
== highest_unmatched_operand
5867 && out_of_range_pos
> curr_out_of_range_pos
))
5869 highest_unmatched_operand
= i
;
5870 if (out_of_range_pos
>= 0)
5872 expected_operand
= idesc
->operands
[out_of_range_pos
];
5873 error_pos
= out_of_range_pos
;
5877 expected_operand
= idesc
->operands
[i
];
5880 curr_out_of_range_pos
= out_of_range_pos
;
5885 if (num_operands
< NELEMS (idesc
->operands
)
5886 && idesc
->operands
[num_operands
])
5887 continue; /* mismatch in number of arguments */
5893 if (expected_operand
)
5894 as_bad ("Operand %u of `%s' should be %s",
5895 error_pos
+ 1, mnemonic
,
5896 elf64_ia64_operands
[expected_operand
].desc
);
5898 as_bad ("Operand mismatch");
5904 /* Keep track of state necessary to determine whether a NOP is necessary
5905 to avoid an erratum in A and B step Itanium chips, and return 1 if we
5906 detect a case where additional NOPs may be necessary. */
5908 errata_nop_necessary_p (slot
, insn_unit
)
5910 enum ia64_unit insn_unit
;
5913 struct group
*this_group
= md
.last_groups
+ md
.group_idx
;
5914 struct group
*prev_group
= md
.last_groups
+ (md
.group_idx
+ 2) % 3;
5915 struct ia64_opcode
*idesc
= slot
->idesc
;
5917 /* Test whether this could be the first insn in a problematic sequence. */
5918 if (insn_unit
== IA64_UNIT_F
)
5920 for (i
= 0; i
< idesc
->num_outputs
; i
++)
5921 if (idesc
->operands
[i
] == IA64_OPND_P1
5922 || idesc
->operands
[i
] == IA64_OPND_P2
)
5924 int regno
= slot
->opnd
[i
].X_add_number
- REG_P
;
5925 /* Ignore invalid operands; they generate errors elsewhere. */
5928 this_group
->p_reg_set
[regno
] = 1;
5932 /* Test whether this could be the second insn in a problematic sequence. */
5933 if (insn_unit
== IA64_UNIT_M
&& slot
->qp_regno
> 0
5934 && prev_group
->p_reg_set
[slot
->qp_regno
])
5936 for (i
= 0; i
< idesc
->num_outputs
; i
++)
5937 if (idesc
->operands
[i
] == IA64_OPND_R1
5938 || idesc
->operands
[i
] == IA64_OPND_R2
5939 || idesc
->operands
[i
] == IA64_OPND_R3
)
5941 int regno
= slot
->opnd
[i
].X_add_number
- REG_GR
;
5942 /* Ignore invalid operands; they generate errors elsewhere. */
5945 if (strncmp (idesc
->name
, "add", 3) != 0
5946 && strncmp (idesc
->name
, "sub", 3) != 0
5947 && strncmp (idesc
->name
, "shladd", 6) != 0
5948 && (idesc
->flags
& IA64_OPCODE_POSTINC
) == 0)
5949 this_group
->g_reg_set_conditionally
[regno
] = 1;
5953 /* Test whether this could be the third insn in a problematic sequence. */
5954 for (i
= 0; i
< NELEMS (idesc
->operands
) && idesc
->operands
[i
]; i
++)
5956 if (/* For fc, ptc, ptr, tak, thash, tpa, ttag, probe, ptr, ptc. */
5957 idesc
->operands
[i
] == IA64_OPND_R3
5958 /* For mov indirect. */
5959 || idesc
->operands
[i
] == IA64_OPND_RR_R3
5960 || idesc
->operands
[i
] == IA64_OPND_DBR_R3
5961 || idesc
->operands
[i
] == IA64_OPND_IBR_R3
5962 || idesc
->operands
[i
] == IA64_OPND_PKR_R3
5963 || idesc
->operands
[i
] == IA64_OPND_PMC_R3
5964 || idesc
->operands
[i
] == IA64_OPND_PMD_R3
5965 || idesc
->operands
[i
] == IA64_OPND_MSR_R3
5966 || idesc
->operands
[i
] == IA64_OPND_CPUID_R3
5968 || idesc
->operands
[i
] == IA64_OPND_ITR_R3
5969 || idesc
->operands
[i
] == IA64_OPND_DTR_R3
5970 /* Normal memory addresses (load, store, xchg, cmpxchg, etc.). */
5971 || idesc
->operands
[i
] == IA64_OPND_MR3
)
5973 int regno
= slot
->opnd
[i
].X_add_number
- REG_GR
;
5974 /* Ignore invalid operands; they generate errors elsewhere. */
5977 if (idesc
->operands
[i
] == IA64_OPND_R3
)
5979 if (strcmp (idesc
->name
, "fc") != 0
5980 && strcmp (idesc
->name
, "tak") != 0
5981 && strcmp (idesc
->name
, "thash") != 0
5982 && strcmp (idesc
->name
, "tpa") != 0
5983 && strcmp (idesc
->name
, "ttag") != 0
5984 && strncmp (idesc
->name
, "ptr", 3) != 0
5985 && strncmp (idesc
->name
, "ptc", 3) != 0
5986 && strncmp (idesc
->name
, "probe", 5) != 0)
5989 if (prev_group
->g_reg_set_conditionally
[regno
])
5997 build_insn (slot
, insnp
)
6001 const struct ia64_operand
*odesc
, *o2desc
;
6002 struct ia64_opcode
*idesc
= slot
->idesc
;
6003 bfd_signed_vma insn
, val
;
6007 insn
= idesc
->opcode
| slot
->qp_regno
;
6009 for (i
= 0; i
< NELEMS (idesc
->operands
) && idesc
->operands
[i
]; ++i
)
6011 if (slot
->opnd
[i
].X_op
== O_register
6012 || slot
->opnd
[i
].X_op
== O_constant
6013 || slot
->opnd
[i
].X_op
== O_index
)
6014 val
= slot
->opnd
[i
].X_add_number
;
6015 else if (slot
->opnd
[i
].X_op
== O_big
)
6017 /* This must be the value 0x10000000000000000. */
6018 assert (idesc
->operands
[i
] == IA64_OPND_IMM8M1U8
);
6024 switch (idesc
->operands
[i
])
6026 case IA64_OPND_IMMU64
:
6027 *insnp
++ = (val
>> 22) & 0x1ffffffffffLL
;
6028 insn
|= (((val
& 0x7f) << 13) | (((val
>> 7) & 0x1ff) << 27)
6029 | (((val
>> 16) & 0x1f) << 22) | (((val
>> 21) & 0x1) << 21)
6030 | (((val
>> 63) & 0x1) << 36));
6033 case IA64_OPND_IMMU62
:
6034 val
&= 0x3fffffffffffffffULL
;
6035 if (val
!= slot
->opnd
[i
].X_add_number
)
6036 as_warn (_("Value truncated to 62 bits"));
6037 *insnp
++ = (val
>> 21) & 0x1ffffffffffLL
;
6038 insn
|= (((val
& 0xfffff) << 6) | (((val
>> 20) & 0x1) << 36));
6041 case IA64_OPND_TGT64
:
6043 *insnp
++ = ((val
>> 20) & 0x7fffffffffLL
) << 2;
6044 insn
|= ((((val
>> 59) & 0x1) << 36)
6045 | (((val
>> 0) & 0xfffff) << 13));
6076 case IA64_OPND_R3_2
:
6077 case IA64_OPND_CPUID_R3
:
6078 case IA64_OPND_DBR_R3
:
6079 case IA64_OPND_DTR_R3
:
6080 case IA64_OPND_ITR_R3
:
6081 case IA64_OPND_IBR_R3
:
6083 case IA64_OPND_MSR_R3
:
6084 case IA64_OPND_PKR_R3
:
6085 case IA64_OPND_PMC_R3
:
6086 case IA64_OPND_PMD_R3
:
6087 case IA64_OPND_RR_R3
:
6095 odesc
= elf64_ia64_operands
+ idesc
->operands
[i
];
6096 err
= (*odesc
->insert
) (odesc
, val
, &insn
);
6098 as_bad_where (slot
->src_file
, slot
->src_line
,
6099 "Bad operand value: %s", err
);
6100 if (idesc
->flags
& IA64_OPCODE_PSEUDO
)
6102 if ((idesc
->flags
& IA64_OPCODE_F2_EQ_F3
)
6103 && odesc
== elf64_ia64_operands
+ IA64_OPND_F3
)
6105 o2desc
= elf64_ia64_operands
+ IA64_OPND_F2
;
6106 (*o2desc
->insert
) (o2desc
, val
, &insn
);
6108 if ((idesc
->flags
& IA64_OPCODE_LEN_EQ_64MCNT
)
6109 && (odesc
== elf64_ia64_operands
+ IA64_OPND_CPOS6a
6110 || odesc
== elf64_ia64_operands
+ IA64_OPND_POS6
))
6112 o2desc
= elf64_ia64_operands
+ IA64_OPND_LEN6
;
6113 (*o2desc
->insert
) (o2desc
, 64 - val
, &insn
);
6123 unsigned int manual_bundling_on
= 0, manual_bundling_off
= 0;
6124 unsigned int manual_bundling
= 0;
6125 enum ia64_unit required_unit
, insn_unit
= 0;
6126 enum ia64_insn_type type
[3], insn_type
;
6127 unsigned int template, orig_template
;
6128 bfd_vma insn
[3] = { -1, -1, -1 };
6129 struct ia64_opcode
*idesc
;
6130 int end_of_insn_group
= 0, user_template
= -1;
6131 int n
, i
, j
, first
, curr
;
6132 unw_rec_list
*ptr
, *last_ptr
, *end_ptr
;
6133 bfd_vma t0
= 0, t1
= 0;
6134 struct label_fix
*lfix
;
6135 struct insn_fix
*ifix
;
6141 first
= (md
.curr_slot
+ NUM_SLOTS
- md
.num_slots_in_use
) % NUM_SLOTS
;
6142 know (first
>= 0 & first
< NUM_SLOTS
);
6143 n
= MIN (3, md
.num_slots_in_use
);
6145 /* Determine template: user user_template if specified, best match
6148 if (md
.slot
[first
].user_template
>= 0)
6149 user_template
= template = md
.slot
[first
].user_template
;
6152 /* Auto select appropriate template. */
6153 memset (type
, 0, sizeof (type
));
6155 for (i
= 0; i
< n
; ++i
)
6157 if (md
.slot
[curr
].label_fixups
&& i
!= 0)
6159 type
[i
] = md
.slot
[curr
].idesc
->type
;
6160 curr
= (curr
+ 1) % NUM_SLOTS
;
6162 template = best_template
[type
[0]][type
[1]][type
[2]];
6165 /* initialize instructions with appropriate nops: */
6166 for (i
= 0; i
< 3; ++i
)
6167 insn
[i
] = nop
[ia64_templ_desc
[template].exec_unit
[i
]];
6171 /* Check to see if this bundle is at an offset that is a multiple of 16-bytes
6172 from the start of the frag. */
6173 addr_mod
= frag_now_fix () & 15;
6174 if (frag_now
->has_code
&& frag_now
->insn_addr
!= addr_mod
)
6175 as_bad (_("instruction address is not a multiple of 16"));
6176 frag_now
->insn_addr
= addr_mod
;
6177 frag_now
->has_code
= 1;
6179 /* now fill in slots with as many insns as possible: */
6181 idesc
= md
.slot
[curr
].idesc
;
6182 end_of_insn_group
= 0;
6183 for (i
= 0; i
< 3 && md
.num_slots_in_use
> 0; ++i
)
6185 /* If we have unwind records, we may need to update some now. */
6186 ptr
= md
.slot
[curr
].unwind_record
;
6189 /* Find the last prologue/body record in the list for the current
6190 insn, and set the slot number for all records up to that point.
6191 This needs to be done now, because prologue/body records refer to
6192 the current point, not the point after the instruction has been
6193 issued. This matters because there may have been nops emitted
6194 meanwhile. Any non-prologue non-body record followed by a
6195 prologue/body record must also refer to the current point. */
6197 end_ptr
= md
.slot
[(curr
+ 1) % NUM_SLOTS
].unwind_record
;
6198 for (; ptr
!= end_ptr
; ptr
= ptr
->next
)
6199 if (ptr
->r
.type
== prologue
|| ptr
->r
.type
== prologue_gr
6200 || ptr
->r
.type
== body
)
6204 /* Make last_ptr point one after the last prologue/body
6206 last_ptr
= last_ptr
->next
;
6207 for (ptr
= md
.slot
[curr
].unwind_record
; ptr
!= last_ptr
;
6210 ptr
->slot_number
= (unsigned long) f
+ i
;
6211 ptr
->slot_frag
= frag_now
;
6213 /* Remove the initialized records, so that we won't accidentally
6214 update them again if we insert a nop and continue. */
6215 md
.slot
[curr
].unwind_record
= last_ptr
;
6219 if (idesc
->flags
& IA64_OPCODE_SLOT2
)
6221 if (manual_bundling
&& i
!= 2)
6222 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6223 "`%s' must be last in bundle", idesc
->name
);
6227 if (idesc
->flags
& IA64_OPCODE_LAST
)
6230 unsigned int required_template
;
6232 /* If we need a stop bit after an M slot, our only choice is
6233 template 5 (M;;MI). If we need a stop bit after a B
6234 slot, our only choice is to place it at the end of the
6235 bundle, because the only available templates are MIB,
6236 MBB, BBB, MMB, and MFB. We don't handle anything other
6237 than M and B slots because these are the only kind of
6238 instructions that can have the IA64_OPCODE_LAST bit set. */
6239 required_template
= template;
6240 switch (idesc
->type
)
6244 required_template
= 5;
6252 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6253 "Internal error: don't know how to force %s to end"
6254 "of instruction group", idesc
->name
);
6258 if (manual_bundling
&& i
!= required_slot
)
6259 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6260 "`%s' must be last in instruction group",
6262 if (required_slot
< i
)
6263 /* Can't fit this instruction. */
6267 if (required_template
!= template)
6269 /* If we switch the template, we need to reset the NOPs
6270 after slot i. The slot-types of the instructions ahead
6271 of i never change, so we don't need to worry about
6272 changing NOPs in front of this slot. */
6273 for (j
= i
; j
< 3; ++j
)
6274 insn
[j
] = nop
[ia64_templ_desc
[required_template
].exec_unit
[j
]];
6276 template = required_template
;
6278 if (curr
!= first
&& md
.slot
[curr
].label_fixups
)
6280 if (manual_bundling_on
)
6281 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6282 "Label must be first in a bundle");
6283 /* This insn must go into the first slot of a bundle. */
6287 manual_bundling_on
= md
.slot
[curr
].manual_bundling_on
;
6288 manual_bundling_off
= md
.slot
[curr
].manual_bundling_off
;
6290 if (manual_bundling_on
)
6293 manual_bundling
= 1;
6295 break; /* need to start a new bundle */
6298 if (end_of_insn_group
&& md
.num_slots_in_use
>= 1)
6300 /* We need an instruction group boundary in the middle of a
6301 bundle. See if we can switch to an other template with
6302 an appropriate boundary. */
6304 orig_template
= template;
6305 if (i
== 1 && (user_template
== 4
6306 || (user_template
< 0
6307 && (ia64_templ_desc
[template].exec_unit
[0]
6311 end_of_insn_group
= 0;
6313 else if (i
== 2 && (user_template
== 0
6314 || (user_template
< 0
6315 && (ia64_templ_desc
[template].exec_unit
[1]
6317 /* This test makes sure we don't switch the template if
6318 the next instruction is one that needs to be first in
6319 an instruction group. Since all those instructions are
6320 in the M group, there is no way such an instruction can
6321 fit in this bundle even if we switch the template. The
6322 reason we have to check for this is that otherwise we
6323 may end up generating "MI;;I M.." which has the deadly
6324 effect that the second M instruction is no longer the
6325 first in the bundle! --davidm 99/12/16 */
6326 && (idesc
->flags
& IA64_OPCODE_FIRST
) == 0)
6329 end_of_insn_group
= 0;
6331 else if (curr
!= first
)
6332 /* can't fit this insn */
6335 if (template != orig_template
)
6336 /* if we switch the template, we need to reset the NOPs
6337 after slot i. The slot-types of the instructions ahead
6338 of i never change, so we don't need to worry about
6339 changing NOPs in front of this slot. */
6340 for (j
= i
; j
< 3; ++j
)
6341 insn
[j
] = nop
[ia64_templ_desc
[template].exec_unit
[j
]];
6343 required_unit
= ia64_templ_desc
[template].exec_unit
[i
];
6345 /* resolve dynamic opcodes such as "break", "hint", and "nop": */
6346 if (idesc
->type
== IA64_TYPE_DYN
)
6348 if ((strcmp (idesc
->name
, "nop") == 0)
6349 || (strcmp (idesc
->name
, "hint") == 0)
6350 || (strcmp (idesc
->name
, "break") == 0))
6351 insn_unit
= required_unit
;
6352 else if (strcmp (idesc
->name
, "chk.s") == 0)
6354 insn_unit
= IA64_UNIT_M
;
6355 if (required_unit
== IA64_UNIT_I
)
6356 insn_unit
= IA64_UNIT_I
;
6359 as_fatal ("emit_one_bundle: unexpected dynamic op");
6361 sprintf (mnemonic
, "%s.%c", idesc
->name
, "?imbf??"[insn_unit
]);
6362 ia64_free_opcode (idesc
);
6363 md
.slot
[curr
].idesc
= idesc
= ia64_find_opcode (mnemonic
);
6365 know (!idesc
->next
); /* no resolved dynamic ops have collisions */
6370 insn_type
= idesc
->type
;
6371 insn_unit
= IA64_UNIT_NIL
;
6375 if (required_unit
== IA64_UNIT_I
|| required_unit
== IA64_UNIT_M
)
6376 insn_unit
= required_unit
;
6378 case IA64_TYPE_X
: insn_unit
= IA64_UNIT_L
; break;
6379 case IA64_TYPE_I
: insn_unit
= IA64_UNIT_I
; break;
6380 case IA64_TYPE_M
: insn_unit
= IA64_UNIT_M
; break;
6381 case IA64_TYPE_B
: insn_unit
= IA64_UNIT_B
; break;
6382 case IA64_TYPE_F
: insn_unit
= IA64_UNIT_F
; break;
6387 if (insn_unit
!= required_unit
)
6389 if (required_unit
== IA64_UNIT_L
6390 && insn_unit
== IA64_UNIT_I
6391 && !(idesc
->flags
& IA64_OPCODE_X_IN_MLX
))
6393 /* we got ourselves an MLX template but the current
6394 instruction isn't an X-unit, or an I-unit instruction
6395 that can go into the X slot of an MLX template. Duh. */
6396 if (md
.num_slots_in_use
>= NUM_SLOTS
)
6398 as_bad_where (md
.slot
[curr
].src_file
,
6399 md
.slot
[curr
].src_line
,
6400 "`%s' can't go in X slot of "
6401 "MLX template", idesc
->name
);
6402 /* drop this insn so we don't livelock: */
6403 --md
.num_slots_in_use
;
6407 continue; /* try next slot */
6413 addr
= frag_now
->fr_address
+ frag_now_fix () - 16 + i
;
6414 dwarf2_gen_line_info (addr
, &md
.slot
[curr
].debug_line
);
6417 if (errata_nop_necessary_p (md
.slot
+ curr
, insn_unit
))
6418 as_warn (_("Additional NOP may be necessary to workaround Itanium processor A/B step errata"));
6420 build_insn (md
.slot
+ curr
, insn
+ i
);
6422 ptr
= md
.slot
[curr
].unwind_record
;
6425 /* Set slot numbers for all remaining unwind records belonging to the
6426 current insn. There can not be any prologue/body unwind records
6428 end_ptr
= md
.slot
[(curr
+ 1) % NUM_SLOTS
].unwind_record
;
6429 for (; ptr
!= end_ptr
; ptr
= ptr
->next
)
6431 ptr
->slot_number
= (unsigned long) f
+ i
;
6432 ptr
->slot_frag
= frag_now
;
6434 md
.slot
[curr
].unwind_record
= NULL
;
6437 if (required_unit
== IA64_UNIT_L
)
6440 /* skip one slot for long/X-unit instructions */
6443 --md
.num_slots_in_use
;
6445 /* now is a good time to fix up the labels for this insn: */
6446 for (lfix
= md
.slot
[curr
].label_fixups
; lfix
; lfix
= lfix
->next
)
6448 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16);
6449 symbol_set_frag (lfix
->sym
, frag_now
);
6451 /* and fix up the tags also. */
6452 for (lfix
= md
.slot
[curr
].tag_fixups
; lfix
; lfix
= lfix
->next
)
6454 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16 + i
);
6455 symbol_set_frag (lfix
->sym
, frag_now
);
6458 for (j
= 0; j
< md
.slot
[curr
].num_fixups
; ++j
)
6460 ifix
= md
.slot
[curr
].fixup
+ j
;
6461 fix
= fix_new_exp (frag_now
, frag_now_fix () - 16 + i
, 8,
6462 &ifix
->expr
, ifix
->is_pcrel
, ifix
->code
);
6463 fix
->tc_fix_data
.opnd
= ifix
->opnd
;
6464 fix
->fx_plt
= (fix
->fx_r_type
== BFD_RELOC_IA64_PLTOFF22
);
6465 fix
->fx_file
= md
.slot
[curr
].src_file
;
6466 fix
->fx_line
= md
.slot
[curr
].src_line
;
6469 end_of_insn_group
= md
.slot
[curr
].end_of_insn_group
;
6471 if (end_of_insn_group
)
6473 md
.group_idx
= (md
.group_idx
+ 1) % 3;
6474 memset (md
.last_groups
+ md
.group_idx
, 0, sizeof md
.last_groups
[0]);
6478 ia64_free_opcode (md
.slot
[curr
].idesc
);
6479 memset (md
.slot
+ curr
, 0, sizeof (md
.slot
[curr
]));
6480 md
.slot
[curr
].user_template
= -1;
6482 if (manual_bundling_off
)
6484 manual_bundling
= 0;
6487 curr
= (curr
+ 1) % NUM_SLOTS
;
6488 idesc
= md
.slot
[curr
].idesc
;
6490 if (manual_bundling
)
6492 if (md
.num_slots_in_use
> 0)
6493 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6494 "`%s' does not fit into %s template",
6495 idesc
->name
, ia64_templ_desc
[template].name
);
6497 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6498 "Missing '}' at end of file");
6500 know (md
.num_slots_in_use
< NUM_SLOTS
);
6502 t0
= end_of_insn_group
| (template << 1) | (insn
[0] << 5) | (insn
[1] << 46);
6503 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
6505 number_to_chars_littleendian (f
+ 0, t0
, 8);
6506 number_to_chars_littleendian (f
+ 8, t1
, 8);
6510 unwind
.list
->next_slot_number
= (unsigned long) f
+ 16;
6511 unwind
.list
->next_slot_frag
= frag_now
;
6516 md_parse_option (c
, arg
)
6523 /* Switches from the Intel assembler. */
6525 if (strcmp (arg
, "ilp64") == 0
6526 || strcmp (arg
, "lp64") == 0
6527 || strcmp (arg
, "p64") == 0)
6529 md
.flags
|= EF_IA_64_ABI64
;
6531 else if (strcmp (arg
, "ilp32") == 0)
6533 md
.flags
&= ~EF_IA_64_ABI64
;
6535 else if (strcmp (arg
, "le") == 0)
6537 md
.flags
&= ~EF_IA_64_BE
;
6538 default_big_endian
= 0;
6540 else if (strcmp (arg
, "be") == 0)
6542 md
.flags
|= EF_IA_64_BE
;
6543 default_big_endian
= 1;
6550 if (strcmp (arg
, "so") == 0)
6552 /* Suppress signon message. */
6554 else if (strcmp (arg
, "pi") == 0)
6556 /* Reject privileged instructions. FIXME */
6558 else if (strcmp (arg
, "us") == 0)
6560 /* Allow union of signed and unsigned range. FIXME */
6562 else if (strcmp (arg
, "close_fcalls") == 0)
6564 /* Do not resolve global function calls. */
6571 /* temp[="prefix"] Insert temporary labels into the object file
6572 symbol table prefixed by "prefix".
6573 Default prefix is ":temp:".
6578 /* indirect=<tgt> Assume unannotated indirect branches behavior
6579 according to <tgt> --
6580 exit: branch out from the current context (default)
6581 labels: all labels in context may be branch targets
6583 if (strncmp (arg
, "indirect=", 9) != 0)
6588 /* -X conflicts with an ignored option, use -x instead */
6590 if (!arg
|| strcmp (arg
, "explicit") == 0)
6592 /* set default mode to explicit */
6593 md
.default_explicit_mode
= 1;
6596 else if (strcmp (arg
, "auto") == 0)
6598 md
.default_explicit_mode
= 0;
6600 else if (strcmp (arg
, "debug") == 0)
6604 else if (strcmp (arg
, "debugx") == 0)
6606 md
.default_explicit_mode
= 1;
6611 as_bad (_("Unrecognized option '-x%s'"), arg
);
6616 /* nops Print nops statistics. */
6619 /* GNU specific switches for gcc. */
6620 case OPTION_MCONSTANT_GP
:
6621 md
.flags
|= EF_IA_64_CONS_GP
;
6624 case OPTION_MAUTO_PIC
:
6625 md
.flags
|= EF_IA_64_NOFUNCDESC_CONS_GP
;
6636 md_show_usage (stream
)
6641 --mconstant-gp mark output file as using the constant-GP model\n\
6642 (sets ELF header flag EF_IA_64_CONS_GP)\n\
6643 --mauto-pic mark output file as using the constant-GP model\n\
6644 without function descriptors (sets ELF header flag\n\
6645 EF_IA_64_NOFUNCDESC_CONS_GP)\n\
6646 -milp32|-milp64|-mlp64|-mp64 select data model (default -mlp64)\n\
6647 -mle | -mbe select little- or big-endian byte order (default -mle)\n\
6648 -x | -xexplicit turn on dependency violation checking (default)\n\
6649 -xauto automagically remove dependency violations\n\
6650 -xdebug debug dependency violation checker\n"),
6655 ia64_after_parse_args ()
6657 if (debug_type
== DEBUG_STABS
)
6658 as_fatal (_("--gstabs is not supported for ia64"));
6661 /* Return true if TYPE fits in TEMPL at SLOT. */
6664 match (int templ
, int type
, int slot
)
6666 enum ia64_unit unit
;
6669 unit
= ia64_templ_desc
[templ
].exec_unit
[slot
];
6672 case IA64_TYPE_DYN
: result
= 1; break; /* for nop and break */
6674 result
= (unit
== IA64_UNIT_I
|| unit
== IA64_UNIT_M
);
6676 case IA64_TYPE_X
: result
= (unit
== IA64_UNIT_L
); break;
6677 case IA64_TYPE_I
: result
= (unit
== IA64_UNIT_I
); break;
6678 case IA64_TYPE_M
: result
= (unit
== IA64_UNIT_M
); break;
6679 case IA64_TYPE_B
: result
= (unit
== IA64_UNIT_B
); break;
6680 case IA64_TYPE_F
: result
= (unit
== IA64_UNIT_F
); break;
6681 default: result
= 0; break;
6686 /* Add a bit of extra goodness if a nop of type F or B would fit
6687 in TEMPL at SLOT. */
6690 extra_goodness (int templ
, int slot
)
6692 if (slot
== 1 && match (templ
, IA64_TYPE_F
, slot
))
6694 if (slot
== 2 && match (templ
, IA64_TYPE_B
, slot
))
6699 /* This function is called once, at assembler startup time. It sets
6700 up all the tables, etc. that the MD part of the assembler will need
6701 that can be determined before arguments are parsed. */
6705 int i
, j
, k
, t
, total
, ar_base
, cr_base
, goodness
, best
, regnum
, ok
;
6710 md
.explicit_mode
= md
.default_explicit_mode
;
6712 bfd_set_section_alignment (stdoutput
, text_section
, 4);
6714 /* Make sure function pointers get initialized. */
6715 target_big_endian
= -1;
6716 dot_byteorder (default_big_endian
);
6718 alias_hash
= hash_new ();
6719 alias_name_hash
= hash_new ();
6720 secalias_hash
= hash_new ();
6721 secalias_name_hash
= hash_new ();
6723 pseudo_func
[FUNC_DTP_MODULE
].u
.sym
=
6724 symbol_new (".<dtpmod>", undefined_section
, FUNC_DTP_MODULE
,
6725 &zero_address_frag
);
6727 pseudo_func
[FUNC_DTP_RELATIVE
].u
.sym
=
6728 symbol_new (".<dtprel>", undefined_section
, FUNC_DTP_RELATIVE
,
6729 &zero_address_frag
);
6731 pseudo_func
[FUNC_FPTR_RELATIVE
].u
.sym
=
6732 symbol_new (".<fptr>", undefined_section
, FUNC_FPTR_RELATIVE
,
6733 &zero_address_frag
);
6735 pseudo_func
[FUNC_GP_RELATIVE
].u
.sym
=
6736 symbol_new (".<gprel>", undefined_section
, FUNC_GP_RELATIVE
,
6737 &zero_address_frag
);
6739 pseudo_func
[FUNC_LT_RELATIVE
].u
.sym
=
6740 symbol_new (".<ltoff>", undefined_section
, FUNC_LT_RELATIVE
,
6741 &zero_address_frag
);
6743 pseudo_func
[FUNC_LT_RELATIVE_X
].u
.sym
=
6744 symbol_new (".<ltoffx>", undefined_section
, FUNC_LT_RELATIVE_X
,
6745 &zero_address_frag
);
6747 pseudo_func
[FUNC_PC_RELATIVE
].u
.sym
=
6748 symbol_new (".<pcrel>", undefined_section
, FUNC_PC_RELATIVE
,
6749 &zero_address_frag
);
6751 pseudo_func
[FUNC_PLT_RELATIVE
].u
.sym
=
6752 symbol_new (".<pltoff>", undefined_section
, FUNC_PLT_RELATIVE
,
6753 &zero_address_frag
);
6755 pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
=
6756 symbol_new (".<secrel>", undefined_section
, FUNC_SEC_RELATIVE
,
6757 &zero_address_frag
);
6759 pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
=
6760 symbol_new (".<segrel>", undefined_section
, FUNC_SEG_RELATIVE
,
6761 &zero_address_frag
);
6763 pseudo_func
[FUNC_TP_RELATIVE
].u
.sym
=
6764 symbol_new (".<tprel>", undefined_section
, FUNC_TP_RELATIVE
,
6765 &zero_address_frag
);
6767 pseudo_func
[FUNC_LTV_RELATIVE
].u
.sym
=
6768 symbol_new (".<ltv>", undefined_section
, FUNC_LTV_RELATIVE
,
6769 &zero_address_frag
);
6771 pseudo_func
[FUNC_LT_FPTR_RELATIVE
].u
.sym
=
6772 symbol_new (".<ltoff.fptr>", undefined_section
, FUNC_LT_FPTR_RELATIVE
,
6773 &zero_address_frag
);
6775 pseudo_func
[FUNC_LT_DTP_MODULE
].u
.sym
=
6776 symbol_new (".<ltoff.dtpmod>", undefined_section
, FUNC_LT_DTP_MODULE
,
6777 &zero_address_frag
);
6779 pseudo_func
[FUNC_LT_DTP_RELATIVE
].u
.sym
=
6780 symbol_new (".<ltoff.dptrel>", undefined_section
, FUNC_LT_DTP_RELATIVE
,
6781 &zero_address_frag
);
6783 pseudo_func
[FUNC_LT_TP_RELATIVE
].u
.sym
=
6784 symbol_new (".<ltoff.tprel>", undefined_section
, FUNC_LT_TP_RELATIVE
,
6785 &zero_address_frag
);
6787 pseudo_func
[FUNC_IPLT_RELOC
].u
.sym
=
6788 symbol_new (".<iplt>", undefined_section
, FUNC_IPLT_RELOC
,
6789 &zero_address_frag
);
6791 /* Compute the table of best templates. We compute goodness as a
6792 base 4 value, in which each match counts for 3, each F counts
6793 for 2, each B counts for 1. This should maximize the number of
6794 F and B nops in the chosen bundles, which is good because these
6795 pipelines are least likely to be overcommitted. */
6796 for (i
= 0; i
< IA64_NUM_TYPES
; ++i
)
6797 for (j
= 0; j
< IA64_NUM_TYPES
; ++j
)
6798 for (k
= 0; k
< IA64_NUM_TYPES
; ++k
)
6801 for (t
= 0; t
< NELEMS (ia64_templ_desc
); ++t
)
6804 if (match (t
, i
, 0))
6806 if (match (t
, j
, 1))
6808 if (match (t
, k
, 2))
6809 goodness
= 3 + 3 + 3;
6811 goodness
= 3 + 3 + extra_goodness (t
, 2);
6813 else if (match (t
, j
, 2))
6814 goodness
= 3 + 3 + extra_goodness (t
, 1);
6818 goodness
+= extra_goodness (t
, 1);
6819 goodness
+= extra_goodness (t
, 2);
6822 else if (match (t
, i
, 1))
6824 if (match (t
, j
, 2))
6827 goodness
= 3 + extra_goodness (t
, 2);
6829 else if (match (t
, i
, 2))
6830 goodness
= 3 + extra_goodness (t
, 1);
6832 if (goodness
> best
)
6835 best_template
[i
][j
][k
] = t
;
6840 for (i
= 0; i
< NUM_SLOTS
; ++i
)
6841 md
.slot
[i
].user_template
= -1;
6843 md
.pseudo_hash
= hash_new ();
6844 for (i
= 0; i
< NELEMS (pseudo_opcode
); ++i
)
6846 err
= hash_insert (md
.pseudo_hash
, pseudo_opcode
[i
].name
,
6847 (void *) (pseudo_opcode
+ i
));
6849 as_fatal ("ia64.md_begin: can't hash `%s': %s",
6850 pseudo_opcode
[i
].name
, err
);
6853 md
.reg_hash
= hash_new ();
6854 md
.dynreg_hash
= hash_new ();
6855 md
.const_hash
= hash_new ();
6856 md
.entry_hash
= hash_new ();
6858 /* general registers: */
6861 for (i
= 0; i
< total
; ++i
)
6863 sprintf (name
, "r%d", i
- REG_GR
);
6864 md
.regsym
[i
] = declare_register (name
, i
);
6867 /* floating point registers: */
6869 for (; i
< total
; ++i
)
6871 sprintf (name
, "f%d", i
- REG_FR
);
6872 md
.regsym
[i
] = declare_register (name
, i
);
6875 /* application registers: */
6878 for (; i
< total
; ++i
)
6880 sprintf (name
, "ar%d", i
- REG_AR
);
6881 md
.regsym
[i
] = declare_register (name
, i
);
6884 /* control registers: */
6887 for (; i
< total
; ++i
)
6889 sprintf (name
, "cr%d", i
- REG_CR
);
6890 md
.regsym
[i
] = declare_register (name
, i
);
6893 /* predicate registers: */
6895 for (; i
< total
; ++i
)
6897 sprintf (name
, "p%d", i
- REG_P
);
6898 md
.regsym
[i
] = declare_register (name
, i
);
6901 /* branch registers: */
6903 for (; i
< total
; ++i
)
6905 sprintf (name
, "b%d", i
- REG_BR
);
6906 md
.regsym
[i
] = declare_register (name
, i
);
6909 md
.regsym
[REG_IP
] = declare_register ("ip", REG_IP
);
6910 md
.regsym
[REG_CFM
] = declare_register ("cfm", REG_CFM
);
6911 md
.regsym
[REG_PR
] = declare_register ("pr", REG_PR
);
6912 md
.regsym
[REG_PR_ROT
] = declare_register ("pr.rot", REG_PR_ROT
);
6913 md
.regsym
[REG_PSR
] = declare_register ("psr", REG_PSR
);
6914 md
.regsym
[REG_PSR_L
] = declare_register ("psr.l", REG_PSR_L
);
6915 md
.regsym
[REG_PSR_UM
] = declare_register ("psr.um", REG_PSR_UM
);
6917 for (i
= 0; i
< NELEMS (indirect_reg
); ++i
)
6919 regnum
= indirect_reg
[i
].regnum
;
6920 md
.regsym
[regnum
] = declare_register (indirect_reg
[i
].name
, regnum
);
6923 /* define synonyms for application registers: */
6924 for (i
= REG_AR
; i
< REG_AR
+ NELEMS (ar
); ++i
)
6925 md
.regsym
[i
] = declare_register (ar
[i
- REG_AR
].name
,
6926 REG_AR
+ ar
[i
- REG_AR
].regnum
);
6928 /* define synonyms for control registers: */
6929 for (i
= REG_CR
; i
< REG_CR
+ NELEMS (cr
); ++i
)
6930 md
.regsym
[i
] = declare_register (cr
[i
- REG_CR
].name
,
6931 REG_CR
+ cr
[i
- REG_CR
].regnum
);
6933 declare_register ("gp", REG_GR
+ 1);
6934 declare_register ("sp", REG_GR
+ 12);
6935 declare_register ("rp", REG_BR
+ 0);
6937 /* pseudo-registers used to specify unwind info: */
6938 declare_register ("psp", REG_PSP
);
6940 declare_register_set ("ret", 4, REG_GR
+ 8);
6941 declare_register_set ("farg", 8, REG_FR
+ 8);
6942 declare_register_set ("fret", 8, REG_FR
+ 8);
6944 for (i
= 0; i
< NELEMS (const_bits
); ++i
)
6946 err
= hash_insert (md
.const_hash
, const_bits
[i
].name
,
6947 (PTR
) (const_bits
+ i
));
6949 as_fatal ("Inserting \"%s\" into constant hash table failed: %s",
6953 /* Set the architecture and machine depending on defaults and command line
6955 if (md
.flags
& EF_IA_64_ABI64
)
6956 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf64
);
6958 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf32
);
6961 as_warn (_("Could not set architecture and machine"));
6963 /* Set the pointer size and pointer shift size depending on md.flags */
6965 if (md
.flags
& EF_IA_64_ABI64
)
6967 md
.pointer_size
= 8; /* pointers are 8 bytes */
6968 md
.pointer_size_shift
= 3; /* alignment is 8 bytes = 2^2 */
6972 md
.pointer_size
= 4; /* pointers are 4 bytes */
6973 md
.pointer_size_shift
= 2; /* alignment is 4 bytes = 2^2 */
6976 md
.mem_offset
.hint
= 0;
6979 md
.entry_labels
= NULL
;
6982 /* Set the elf type to 64 bit ABI by default. Cannot do this in md_begin
6983 because that is called after md_parse_option which is where we do the
6984 dynamic changing of md.flags based on -mlp64 or -milp32. Also, set the
6985 default endianness. */
6988 ia64_init (argc
, argv
)
6989 int argc ATTRIBUTE_UNUSED
;
6990 char **argv ATTRIBUTE_UNUSED
;
6992 md
.flags
= MD_FLAGS_DEFAULT
;
6995 /* Return a string for the target object file format. */
6998 ia64_target_format ()
7000 if (OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
7002 if (md
.flags
& EF_IA_64_BE
)
7004 if (md
.flags
& EF_IA_64_ABI64
)
7005 #if defined(TE_AIX50)
7006 return "elf64-ia64-aix-big";
7007 #elif defined(TE_HPUX)
7008 return "elf64-ia64-hpux-big";
7010 return "elf64-ia64-big";
7013 #if defined(TE_AIX50)
7014 return "elf32-ia64-aix-big";
7015 #elif defined(TE_HPUX)
7016 return "elf32-ia64-hpux-big";
7018 return "elf32-ia64-big";
7023 if (md
.flags
& EF_IA_64_ABI64
)
7025 return "elf64-ia64-aix-little";
7027 return "elf64-ia64-little";
7031 return "elf32-ia64-aix-little";
7033 return "elf32-ia64-little";
7038 return "unknown-format";
7042 ia64_end_of_source ()
7044 /* terminate insn group upon reaching end of file: */
7045 insn_group_break (1, 0, 0);
7047 /* emits slots we haven't written yet: */
7048 ia64_flush_insns ();
7050 bfd_set_private_flags (stdoutput
, md
.flags
);
7052 md
.mem_offset
.hint
= 0;
7058 if (md
.qp
.X_op
== O_register
)
7059 as_bad ("qualifying predicate not followed by instruction");
7060 md
.qp
.X_op
= O_absent
;
7062 if (ignore_input ())
7065 if (input_line_pointer
[0] == ';' && input_line_pointer
[-1] == ';')
7067 if (md
.detect_dv
&& !md
.explicit_mode
)
7068 as_warn (_("Explicit stops are ignored in auto mode"));
7070 insn_group_break (1, 0, 0);
7074 /* This is a hook for ia64_frob_label, so that it can distinguish tags from
7076 static int defining_tag
= 0;
7079 ia64_unrecognized_line (ch
)
7085 expression (&md
.qp
);
7086 if (*input_line_pointer
++ != ')')
7088 as_bad ("Expected ')'");
7091 if (md
.qp
.X_op
!= O_register
)
7093 as_bad ("Qualifying predicate expected");
7096 if (md
.qp
.X_add_number
< REG_P
|| md
.qp
.X_add_number
>= REG_P
+ 64)
7098 as_bad ("Predicate register expected");
7104 if (md
.manual_bundling
)
7105 as_warn ("Found '{' when manual bundling is already turned on");
7107 CURR_SLOT
.manual_bundling_on
= 1;
7108 md
.manual_bundling
= 1;
7110 /* Bundling is only acceptable in explicit mode
7111 or when in default automatic mode. */
7112 if (md
.detect_dv
&& !md
.explicit_mode
)
7114 if (!md
.mode_explicitly_set
7115 && !md
.default_explicit_mode
)
7118 as_warn (_("Found '{' after explicit switch to automatic mode"));
7123 if (!md
.manual_bundling
)
7124 as_warn ("Found '}' when manual bundling is off");
7126 PREV_SLOT
.manual_bundling_off
= 1;
7127 md
.manual_bundling
= 0;
7129 /* switch back to automatic mode, if applicable */
7132 && !md
.mode_explicitly_set
7133 && !md
.default_explicit_mode
)
7136 /* Allow '{' to follow on the same line. We also allow ";;", but that
7137 happens automatically because ';' is an end of line marker. */
7139 if (input_line_pointer
[0] == '{')
7141 input_line_pointer
++;
7142 return ia64_unrecognized_line ('{');
7145 demand_empty_rest_of_line ();
7155 if (md
.qp
.X_op
== O_register
)
7157 as_bad ("Tag must come before qualifying predicate.");
7161 /* This implements just enough of read_a_source_file in read.c to
7162 recognize labels. */
7163 if (is_name_beginner (*input_line_pointer
))
7165 s
= input_line_pointer
;
7166 c
= get_symbol_end ();
7168 else if (LOCAL_LABELS_FB
7169 && ISDIGIT (*input_line_pointer
))
7172 while (ISDIGIT (*input_line_pointer
))
7173 temp
= (temp
* 10) + *input_line_pointer
++ - '0';
7174 fb_label_instance_inc (temp
);
7175 s
= fb_label_name (temp
, 0);
7176 c
= *input_line_pointer
;
7185 /* Put ':' back for error messages' sake. */
7186 *input_line_pointer
++ = ':';
7187 as_bad ("Expected ':'");
7194 /* Put ':' back for error messages' sake. */
7195 *input_line_pointer
++ = ':';
7196 if (*input_line_pointer
++ != ']')
7198 as_bad ("Expected ']'");
7203 as_bad ("Tag name expected");
7213 /* Not a valid line. */
7218 ia64_frob_label (sym
)
7221 struct label_fix
*fix
;
7223 /* Tags need special handling since they are not bundle breaks like
7227 fix
= obstack_alloc (¬es
, sizeof (*fix
));
7229 fix
->next
= CURR_SLOT
.tag_fixups
;
7230 CURR_SLOT
.tag_fixups
= fix
;
7235 if (bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7237 md
.last_text_seg
= now_seg
;
7238 fix
= obstack_alloc (¬es
, sizeof (*fix
));
7240 fix
->next
= CURR_SLOT
.label_fixups
;
7241 CURR_SLOT
.label_fixups
= fix
;
7243 /* Keep track of how many code entry points we've seen. */
7244 if (md
.path
== md
.maxpaths
)
7247 md
.entry_labels
= (const char **)
7248 xrealloc ((void *) md
.entry_labels
,
7249 md
.maxpaths
* sizeof (char *));
7251 md
.entry_labels
[md
.path
++] = S_GET_NAME (sym
);
7256 /* The HP-UX linker will give unresolved symbol errors for symbols
7257 that are declared but unused. This routine removes declared,
7258 unused symbols from an object. */
7260 ia64_frob_symbol (sym
)
7263 if ((S_GET_SEGMENT (sym
) == &bfd_und_section
&& ! symbol_used_p (sym
) &&
7264 ELF_ST_VISIBILITY (S_GET_OTHER (sym
)) == STV_DEFAULT
)
7265 || (S_GET_SEGMENT (sym
) == &bfd_abs_section
7266 && ! S_IS_EXTERNAL (sym
)))
7273 ia64_flush_pending_output ()
7275 if (!md
.keep_pending_output
7276 && bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7278 /* ??? This causes many unnecessary stop bits to be emitted.
7279 Unfortunately, it isn't clear if it is safe to remove this. */
7280 insn_group_break (1, 0, 0);
7281 ia64_flush_insns ();
7285 /* Do ia64-specific expression optimization. All that's done here is
7286 to transform index expressions that are either due to the indexing
7287 of rotating registers or due to the indexing of indirect register
7290 ia64_optimize_expr (l
, op
, r
)
7299 if (l
->X_op
== O_register
&& r
->X_op
== O_constant
)
7301 num_regs
= (l
->X_add_number
>> 16);
7302 if ((unsigned) r
->X_add_number
>= num_regs
)
7305 as_bad ("No current frame");
7307 as_bad ("Index out of range 0..%u", num_regs
- 1);
7308 r
->X_add_number
= 0;
7310 l
->X_add_number
= (l
->X_add_number
& 0xffff) + r
->X_add_number
;
7313 else if (l
->X_op
== O_register
&& r
->X_op
== O_register
)
7315 if (l
->X_add_number
< IND_CPUID
|| l
->X_add_number
> IND_RR
7316 || l
->X_add_number
== IND_MEM
)
7318 as_bad ("Indirect register set name expected");
7319 l
->X_add_number
= IND_CPUID
;
7322 l
->X_op_symbol
= md
.regsym
[l
->X_add_number
];
7323 l
->X_add_number
= r
->X_add_number
;
7331 ia64_parse_name (name
, e
)
7335 struct const_desc
*cdesc
;
7336 struct dynreg
*dr
= 0;
7337 unsigned int regnum
;
7341 /* first see if NAME is a known register name: */
7342 sym
= hash_find (md
.reg_hash
, name
);
7345 e
->X_op
= O_register
;
7346 e
->X_add_number
= S_GET_VALUE (sym
);
7350 cdesc
= hash_find (md
.const_hash
, name
);
7353 e
->X_op
= O_constant
;
7354 e
->X_add_number
= cdesc
->value
;
7358 /* check for inN, locN, or outN: */
7362 if (name
[1] == 'n' && ISDIGIT (name
[2]))
7370 if (name
[1] == 'o' && name
[2] == 'c' && ISDIGIT (name
[3]))
7378 if (name
[1] == 'u' && name
[2] == 't' && ISDIGIT (name
[3]))
7391 /* The name is inN, locN, or outN; parse the register number. */
7392 regnum
= strtoul (name
, &end
, 10);
7393 if (end
> name
&& *end
== '\0')
7395 if ((unsigned) regnum
>= dr
->num_regs
)
7398 as_bad ("No current frame");
7400 as_bad ("Register number out of range 0..%u",
7404 e
->X_op
= O_register
;
7405 e
->X_add_number
= dr
->base
+ regnum
;
7410 if ((dr
= hash_find (md
.dynreg_hash
, name
)))
7412 /* We've got ourselves the name of a rotating register set.
7413 Store the base register number in the low 16 bits of
7414 X_add_number and the size of the register set in the top 16
7416 e
->X_op
= O_register
;
7417 e
->X_add_number
= dr
->base
| (dr
->num_regs
<< 16);
7423 /* Remove the '#' suffix that indicates a symbol as opposed to a register. */
7426 ia64_canonicalize_symbol_name (name
)
7429 size_t len
= strlen (name
);
7430 if (len
> 1 && name
[len
- 1] == '#')
7431 name
[len
- 1] = '\0';
7435 /* Return true if idesc is a conditional branch instruction. This excludes
7436 the modulo scheduled branches, and br.ia. Mod-sched branches are excluded
7437 because they always read/write resources regardless of the value of the
7438 qualifying predicate. br.ia must always use p0, and hence is always
7439 taken. Thus this function returns true for branches which can fall
7440 through, and which use no resources if they do fall through. */
7443 is_conditional_branch (idesc
)
7444 struct ia64_opcode
*idesc
;
7446 /* br is a conditional branch. Everything that starts with br. except
7447 br.ia, br.c{loop,top,exit}, and br.w{top,exit} is a conditional branch.
7448 Everything that starts with brl is a conditional branch. */
7449 return (idesc
->name
[0] == 'b' && idesc
->name
[1] == 'r'
7450 && (idesc
->name
[2] == '\0'
7451 || (idesc
->name
[2] == '.' && idesc
->name
[3] != 'i'
7452 && idesc
->name
[3] != 'c' && idesc
->name
[3] != 'w')
7453 || idesc
->name
[2] == 'l'
7454 /* br.cond, br.call, br.clr */
7455 || (idesc
->name
[2] == '.' && idesc
->name
[3] == 'c'
7456 && (idesc
->name
[4] == 'a' || idesc
->name
[4] == 'o'
7457 || (idesc
->name
[4] == 'l' && idesc
->name
[5] == 'r')))));
7460 /* Return whether the given opcode is a taken branch. If there's any doubt,
7464 is_taken_branch (idesc
)
7465 struct ia64_opcode
*idesc
;
7467 return ((is_conditional_branch (idesc
) && CURR_SLOT
.qp_regno
== 0)
7468 || strncmp (idesc
->name
, "br.ia", 5) == 0);
7471 /* Return whether the given opcode is an interruption or rfi. If there's any
7472 doubt, returns zero. */
7475 is_interruption_or_rfi (idesc
)
7476 struct ia64_opcode
*idesc
;
7478 if (strcmp (idesc
->name
, "rfi") == 0)
7483 /* Returns the index of the given dependency in the opcode's list of chks, or
7484 -1 if there is no dependency. */
7487 depends_on (depind
, idesc
)
7489 struct ia64_opcode
*idesc
;
7492 const struct ia64_opcode_dependency
*dep
= idesc
->dependencies
;
7493 for (i
= 0; i
< dep
->nchks
; i
++)
7495 if (depind
== DEP (dep
->chks
[i
]))
7501 /* Determine a set of specific resources used for a particular resource
7502 class. Returns the number of specific resources identified For those
7503 cases which are not determinable statically, the resource returned is
7506 Meanings of value in 'NOTE':
7507 1) only read/write when the register number is explicitly encoded in the
7509 2) only read CFM when accessing a rotating GR, FR, or PR. mov pr only
7510 accesses CFM when qualifying predicate is in the rotating region.
7511 3) general register value is used to specify an indirect register; not
7512 determinable statically.
7513 4) only read the given resource when bits 7:0 of the indirect index
7514 register value does not match the register number of the resource; not
7515 determinable statically.
7516 5) all rules are implementation specific.
7517 6) only when both the index specified by the reader and the index specified
7518 by the writer have the same value in bits 63:61; not determinable
7520 7) only access the specified resource when the corresponding mask bit is
7522 8) PSR.dfh is only read when these insns reference FR32-127. PSR.dfl is
7523 only read when these insns reference FR2-31
7524 9) PSR.mfl is only written when these insns write FR2-31. PSR.mfh is only
7525 written when these insns write FR32-127
7526 10) The PSR.bn bit is only accessed when one of GR16-31 is specified in the
7528 11) The target predicates are written independently of PR[qp], but source
7529 registers are only read if PR[qp] is true. Since the state of PR[qp]
7530 cannot statically be determined, all source registers are marked used.
7531 12) This insn only reads the specified predicate register when that
7532 register is the PR[qp].
7533 13) This reference to ld-c only applies to teh GR whose value is loaded
7534 with data returned from memory, not the post-incremented address register.
7535 14) The RSE resource includes the implementation-specific RSE internal
7536 state resources. At least one (and possibly more) of these resources are
7537 read by each instruction listed in IC:rse-readers. At least one (and
7538 possibly more) of these resources are written by each insn listed in
7540 15+16) Represents reserved instructions, which the assembler does not
7543 Memory resources (i.e. locations in memory) are *not* marked or tracked by
7544 this code; there are no dependency violations based on memory access.
7547 #define MAX_SPECS 256
7552 specify_resource (dep
, idesc
, type
, specs
, note
, path
)
7553 const struct ia64_dependency
*dep
;
7554 struct ia64_opcode
*idesc
;
7555 int type
; /* is this a DV chk or a DV reg? */
7556 struct rsrc specs
[MAX_SPECS
]; /* returned specific resources */
7557 int note
; /* resource note for this insn's usage */
7558 int path
; /* which execution path to examine */
7565 if (dep
->mode
== IA64_DV_WAW
7566 || (dep
->mode
== IA64_DV_RAW
&& type
== DV_REG
)
7567 || (dep
->mode
== IA64_DV_WAR
&& type
== DV_CHK
))
7570 /* template for any resources we identify */
7571 tmpl
.dependency
= dep
;
7573 tmpl
.insn_srlz
= tmpl
.data_srlz
= 0;
7574 tmpl
.qp_regno
= CURR_SLOT
.qp_regno
;
7575 tmpl
.link_to_qp_branch
= 1;
7576 tmpl
.mem_offset
.hint
= 0;
7579 tmpl
.cmp_type
= CMP_NONE
;
7582 as_warn (_("Unhandled dependency %s for %s (%s), note %d"), \
7583 dep->name, idesc->name, (rsrc_write?"write":"read"), note)
7584 #define KNOWN(REG) (gr_values[REG].known && gr_values[REG].path >= path)
7586 /* we don't need to track these */
7587 if (dep
->semantics
== IA64_DVS_NONE
)
7590 switch (dep
->specifier
)
7595 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
7597 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
7598 if (regno
>= 0 && regno
<= 7)
7600 specs
[count
] = tmpl
;
7601 specs
[count
++].index
= regno
;
7607 for (i
= 0; i
< 8; i
++)
7609 specs
[count
] = tmpl
;
7610 specs
[count
++].index
= i
;
7619 case IA64_RS_AR_UNAT
:
7620 /* This is a mov =AR or mov AR= instruction. */
7621 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
7623 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
7624 if (regno
== AR_UNAT
)
7626 specs
[count
++] = tmpl
;
7631 /* This is a spill/fill, or other instruction that modifies the
7634 /* Unless we can determine the specific bits used, mark the whole
7635 thing; bits 8:3 of the memory address indicate the bit used in
7636 UNAT. The .mem.offset hint may be used to eliminate a small
7637 subset of conflicts. */
7638 specs
[count
] = tmpl
;
7639 if (md
.mem_offset
.hint
)
7642 fprintf (stderr
, " Using hint for spill/fill\n");
7643 /* The index isn't actually used, just set it to something
7644 approximating the bit index. */
7645 specs
[count
].index
= (md
.mem_offset
.offset
>> 3) & 0x3F;
7646 specs
[count
].mem_offset
.hint
= 1;
7647 specs
[count
].mem_offset
.offset
= md
.mem_offset
.offset
;
7648 specs
[count
++].mem_offset
.base
= md
.mem_offset
.base
;
7652 specs
[count
++].specific
= 0;
7660 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
7662 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
7663 if ((regno
>= 8 && regno
<= 15)
7664 || (regno
>= 20 && regno
<= 23)
7665 || (regno
>= 31 && regno
<= 39)
7666 || (regno
>= 41 && regno
<= 47)
7667 || (regno
>= 67 && regno
<= 111))
7669 specs
[count
] = tmpl
;
7670 specs
[count
++].index
= regno
;
7683 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
7685 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
7686 if ((regno
>= 48 && regno
<= 63)
7687 || (regno
>= 112 && regno
<= 127))
7689 specs
[count
] = tmpl
;
7690 specs
[count
++].index
= regno
;
7696 for (i
= 48; i
< 64; i
++)
7698 specs
[count
] = tmpl
;
7699 specs
[count
++].index
= i
;
7701 for (i
= 112; i
< 128; i
++)
7703 specs
[count
] = tmpl
;
7704 specs
[count
++].index
= i
;
7722 for (i
= 0; i
< idesc
->num_outputs
; i
++)
7723 if (idesc
->operands
[i
] == IA64_OPND_B1
7724 || idesc
->operands
[i
] == IA64_OPND_B2
)
7726 specs
[count
] = tmpl
;
7727 specs
[count
++].index
=
7728 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
7733 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
7734 if (idesc
->operands
[i
] == IA64_OPND_B1
7735 || idesc
->operands
[i
] == IA64_OPND_B2
)
7737 specs
[count
] = tmpl
;
7738 specs
[count
++].index
=
7739 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
7745 case IA64_RS_CPUID
: /* four or more registers */
7748 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CPUID_R3
)
7750 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7751 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7754 specs
[count
] = tmpl
;
7755 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7759 specs
[count
] = tmpl
;
7760 specs
[count
++].specific
= 0;
7770 case IA64_RS_DBR
: /* four or more registers */
7773 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_DBR_R3
)
7775 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7776 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7779 specs
[count
] = tmpl
;
7780 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7784 specs
[count
] = tmpl
;
7785 specs
[count
++].specific
= 0;
7789 else if (note
== 0 && !rsrc_write
)
7791 specs
[count
] = tmpl
;
7792 specs
[count
++].specific
= 0;
7800 case IA64_RS_IBR
: /* four or more registers */
7803 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_IBR_R3
)
7805 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7806 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7809 specs
[count
] = tmpl
;
7810 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7814 specs
[count
] = tmpl
;
7815 specs
[count
++].specific
= 0;
7828 /* These are implementation specific. Force all references to
7829 conflict with all other references. */
7830 specs
[count
] = tmpl
;
7831 specs
[count
++].specific
= 0;
7839 case IA64_RS_PKR
: /* 16 or more registers */
7840 if (note
== 3 || note
== 4)
7842 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PKR_R3
)
7844 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7845 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7850 specs
[count
] = tmpl
;
7851 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7854 for (i
= 0; i
< NELEMS (gr_values
); i
++)
7856 /* Uses all registers *except* the one in R3. */
7857 if ((unsigned)i
!= (gr_values
[regno
].value
& 0xFF))
7859 specs
[count
] = tmpl
;
7860 specs
[count
++].index
= i
;
7866 specs
[count
] = tmpl
;
7867 specs
[count
++].specific
= 0;
7874 specs
[count
] = tmpl
;
7875 specs
[count
++].specific
= 0;
7879 case IA64_RS_PMC
: /* four or more registers */
7882 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMC_R3
7883 || (!rsrc_write
&& idesc
->operands
[1] == IA64_OPND_PMD_R3
))
7886 int index
= ((idesc
->operands
[1] == IA64_OPND_R3
&& !rsrc_write
)
7888 int regno
= CURR_SLOT
.opnd
[index
].X_add_number
- REG_GR
;
7889 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7892 specs
[count
] = tmpl
;
7893 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7897 specs
[count
] = tmpl
;
7898 specs
[count
++].specific
= 0;
7908 case IA64_RS_PMD
: /* four or more registers */
7911 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMD_R3
)
7913 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7914 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7917 specs
[count
] = tmpl
;
7918 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7922 specs
[count
] = tmpl
;
7923 specs
[count
++].specific
= 0;
7933 case IA64_RS_RR
: /* eight registers */
7936 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_RR_R3
)
7938 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7939 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7942 specs
[count
] = tmpl
;
7943 specs
[count
++].index
= (gr_values
[regno
].value
>> 61) & 0x7;
7947 specs
[count
] = tmpl
;
7948 specs
[count
++].specific
= 0;
7952 else if (note
== 0 && !rsrc_write
)
7954 specs
[count
] = tmpl
;
7955 specs
[count
++].specific
= 0;
7963 case IA64_RS_CR_IRR
:
7966 /* handle mov-from-CR-IVR; it's a read that writes CR[IRR] */
7967 int regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
;
7969 && idesc
->operands
[1] == IA64_OPND_CR3
7972 for (i
= 0; i
< 4; i
++)
7974 specs
[count
] = tmpl
;
7975 specs
[count
++].index
= CR_IRR0
+ i
;
7981 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
7982 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
7984 && regno
<= CR_IRR3
)
7986 specs
[count
] = tmpl
;
7987 specs
[count
++].index
= regno
;
7996 case IA64_RS_CR_LRR
:
8003 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8004 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
8005 && (regno
== CR_LRR0
|| regno
== CR_LRR1
))
8007 specs
[count
] = tmpl
;
8008 specs
[count
++].index
= regno
;
8016 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
8018 specs
[count
] = tmpl
;
8019 specs
[count
++].index
=
8020 CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8035 else if (rsrc_write
)
8037 if (dep
->specifier
== IA64_RS_FRb
8038 && idesc
->operands
[0] == IA64_OPND_F1
)
8040 specs
[count
] = tmpl
;
8041 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_FR
;
8046 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
8048 if (idesc
->operands
[i
] == IA64_OPND_F2
8049 || idesc
->operands
[i
] == IA64_OPND_F3
8050 || idesc
->operands
[i
] == IA64_OPND_F4
)
8052 specs
[count
] = tmpl
;
8053 specs
[count
++].index
=
8054 CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8063 /* This reference applies only to the GR whose value is loaded with
8064 data returned from memory. */
8065 specs
[count
] = tmpl
;
8066 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
8072 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8073 if (idesc
->operands
[i
] == IA64_OPND_R1
8074 || idesc
->operands
[i
] == IA64_OPND_R2
8075 || idesc
->operands
[i
] == IA64_OPND_R3
)
8077 specs
[count
] = tmpl
;
8078 specs
[count
++].index
=
8079 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8081 if (idesc
->flags
& IA64_OPCODE_POSTINC
)
8082 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8083 if (idesc
->operands
[i
] == IA64_OPND_MR3
)
8085 specs
[count
] = tmpl
;
8086 specs
[count
++].index
=
8087 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8092 /* Look for anything that reads a GR. */
8093 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8095 if (idesc
->operands
[i
] == IA64_OPND_MR3
8096 || idesc
->operands
[i
] == IA64_OPND_CPUID_R3
8097 || idesc
->operands
[i
] == IA64_OPND_DBR_R3
8098 || idesc
->operands
[i
] == IA64_OPND_IBR_R3
8099 || idesc
->operands
[i
] == IA64_OPND_MSR_R3
8100 || idesc
->operands
[i
] == IA64_OPND_PKR_R3
8101 || idesc
->operands
[i
] == IA64_OPND_PMC_R3
8102 || idesc
->operands
[i
] == IA64_OPND_PMD_R3
8103 || idesc
->operands
[i
] == IA64_OPND_RR_R3
8104 || ((i
>= idesc
->num_outputs
)
8105 && (idesc
->operands
[i
] == IA64_OPND_R1
8106 || idesc
->operands
[i
] == IA64_OPND_R2
8107 || idesc
->operands
[i
] == IA64_OPND_R3
8108 /* addl source register. */
8109 || idesc
->operands
[i
] == IA64_OPND_R3_2
)))
8111 specs
[count
] = tmpl
;
8112 specs
[count
++].index
=
8113 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8124 /* This is the same as IA64_RS_PRr, except that the register range is
8125 from 1 - 15, and there are no rotating register reads/writes here. */
8129 for (i
= 1; i
< 16; i
++)
8131 specs
[count
] = tmpl
;
8132 specs
[count
++].index
= i
;
8138 /* Mark only those registers indicated by the mask. */
8141 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8142 for (i
= 1; i
< 16; i
++)
8143 if (mask
& ((valueT
) 1 << i
))
8145 specs
[count
] = tmpl
;
8146 specs
[count
++].index
= i
;
8154 else if (note
== 11) /* note 11 implies note 1 as well */
8158 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8160 if (idesc
->operands
[i
] == IA64_OPND_P1
8161 || idesc
->operands
[i
] == IA64_OPND_P2
)
8163 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8164 if (regno
>= 1 && regno
< 16)
8166 specs
[count
] = tmpl
;
8167 specs
[count
++].index
= regno
;
8177 else if (note
== 12)
8179 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
8181 specs
[count
] = tmpl
;
8182 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8189 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8190 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8191 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8192 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8194 if ((idesc
->operands
[0] == IA64_OPND_P1
8195 || idesc
->operands
[0] == IA64_OPND_P2
)
8196 && p1
>= 1 && p1
< 16)
8198 specs
[count
] = tmpl
;
8199 specs
[count
].cmp_type
=
8200 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8201 specs
[count
++].index
= p1
;
8203 if ((idesc
->operands
[1] == IA64_OPND_P1
8204 || idesc
->operands
[1] == IA64_OPND_P2
)
8205 && p2
>= 1 && p2
< 16)
8207 specs
[count
] = tmpl
;
8208 specs
[count
].cmp_type
=
8209 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8210 specs
[count
++].index
= p2
;
8215 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
8217 specs
[count
] = tmpl
;
8218 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8220 if (idesc
->operands
[1] == IA64_OPND_PR
)
8222 for (i
= 1; i
< 16; i
++)
8224 specs
[count
] = tmpl
;
8225 specs
[count
++].index
= i
;
8236 /* This is the general case for PRs. IA64_RS_PR and IA64_RS_PR63 are
8237 simplified cases of this. */
8241 for (i
= 16; i
< 63; i
++)
8243 specs
[count
] = tmpl
;
8244 specs
[count
++].index
= i
;
8250 /* Mark only those registers indicated by the mask. */
8252 && idesc
->operands
[0] == IA64_OPND_PR
)
8254 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8255 if (mask
& ((valueT
) 1 << 16))
8256 for (i
= 16; i
< 63; i
++)
8258 specs
[count
] = tmpl
;
8259 specs
[count
++].index
= i
;
8263 && idesc
->operands
[0] == IA64_OPND_PR_ROT
)
8265 for (i
= 16; i
< 63; i
++)
8267 specs
[count
] = tmpl
;
8268 specs
[count
++].index
= i
;
8276 else if (note
== 11) /* note 11 implies note 1 as well */
8280 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8282 if (idesc
->operands
[i
] == IA64_OPND_P1
8283 || idesc
->operands
[i
] == IA64_OPND_P2
)
8285 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8286 if (regno
>= 16 && regno
< 63)
8288 specs
[count
] = tmpl
;
8289 specs
[count
++].index
= regno
;
8299 else if (note
== 12)
8301 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8303 specs
[count
] = tmpl
;
8304 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8311 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8312 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8313 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8314 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8316 if ((idesc
->operands
[0] == IA64_OPND_P1
8317 || idesc
->operands
[0] == IA64_OPND_P2
)
8318 && p1
>= 16 && p1
< 63)
8320 specs
[count
] = tmpl
;
8321 specs
[count
].cmp_type
=
8322 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8323 specs
[count
++].index
= p1
;
8325 if ((idesc
->operands
[1] == IA64_OPND_P1
8326 || idesc
->operands
[1] == IA64_OPND_P2
)
8327 && p2
>= 16 && p2
< 63)
8329 specs
[count
] = tmpl
;
8330 specs
[count
].cmp_type
=
8331 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8332 specs
[count
++].index
= p2
;
8337 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8339 specs
[count
] = tmpl
;
8340 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8342 if (idesc
->operands
[1] == IA64_OPND_PR
)
8344 for (i
= 16; i
< 63; i
++)
8346 specs
[count
] = tmpl
;
8347 specs
[count
++].index
= i
;
8359 /* Verify that the instruction is using the PSR bit indicated in
8363 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_UM
)
8365 if (dep
->regindex
< 6)
8367 specs
[count
++] = tmpl
;
8370 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR
)
8372 if (dep
->regindex
< 32
8373 || dep
->regindex
== 35
8374 || dep
->regindex
== 36
8375 || (!rsrc_write
&& dep
->regindex
== PSR_CPL
))
8377 specs
[count
++] = tmpl
;
8380 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_L
)
8382 if (dep
->regindex
< 32
8383 || dep
->regindex
== 35
8384 || dep
->regindex
== 36
8385 || (rsrc_write
&& dep
->regindex
== PSR_CPL
))
8387 specs
[count
++] = tmpl
;
8392 /* Several PSR bits have very specific dependencies. */
8393 switch (dep
->regindex
)
8396 specs
[count
++] = tmpl
;
8401 specs
[count
++] = tmpl
;
8405 /* Only certain CR accesses use PSR.ic */
8406 if (idesc
->operands
[0] == IA64_OPND_CR3
8407 || idesc
->operands
[1] == IA64_OPND_CR3
)
8410 ((idesc
->operands
[0] == IA64_OPND_CR3
)
8413 CURR_SLOT
.opnd
[index
].X_add_number
- REG_CR
;
8428 specs
[count
++] = tmpl
;
8437 specs
[count
++] = tmpl
;
8441 /* Only some AR accesses use cpl */
8442 if (idesc
->operands
[0] == IA64_OPND_AR3
8443 || idesc
->operands
[1] == IA64_OPND_AR3
)
8446 ((idesc
->operands
[0] == IA64_OPND_AR3
)
8449 CURR_SLOT
.opnd
[index
].X_add_number
- REG_AR
;
8456 && regno
<= AR_K7
))))
8458 specs
[count
++] = tmpl
;
8463 specs
[count
++] = tmpl
;
8473 if (idesc
->operands
[0] == IA64_OPND_IMMU24
)
8475 mask
= CURR_SLOT
.opnd
[0].X_add_number
;
8481 if (mask
& ((valueT
) 1 << dep
->regindex
))
8483 specs
[count
++] = tmpl
;
8488 int min
= dep
->regindex
== PSR_DFL
? 2 : 32;
8489 int max
= dep
->regindex
== PSR_DFL
? 31 : 127;
8490 /* dfh is read on FR32-127; dfl is read on FR2-31 */
8491 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8493 if (idesc
->operands
[i
] == IA64_OPND_F1
8494 || idesc
->operands
[i
] == IA64_OPND_F2
8495 || idesc
->operands
[i
] == IA64_OPND_F3
8496 || idesc
->operands
[i
] == IA64_OPND_F4
)
8498 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8499 if (reg
>= min
&& reg
<= max
)
8501 specs
[count
++] = tmpl
;
8508 int min
= dep
->regindex
== PSR_MFL
? 2 : 32;
8509 int max
= dep
->regindex
== PSR_MFL
? 31 : 127;
8510 /* mfh is read on writes to FR32-127; mfl is read on writes to
8512 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8514 if (idesc
->operands
[i
] == IA64_OPND_F1
)
8516 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8517 if (reg
>= min
&& reg
<= max
)
8519 specs
[count
++] = tmpl
;
8524 else if (note
== 10)
8526 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8528 if (idesc
->operands
[i
] == IA64_OPND_R1
8529 || idesc
->operands
[i
] == IA64_OPND_R2
8530 || idesc
->operands
[i
] == IA64_OPND_R3
)
8532 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8533 if (regno
>= 16 && regno
<= 31)
8535 specs
[count
++] = tmpl
;
8546 case IA64_RS_AR_FPSR
:
8547 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8549 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8550 if (regno
== AR_FPSR
)
8552 specs
[count
++] = tmpl
;
8557 specs
[count
++] = tmpl
;
8562 /* Handle all AR[REG] resources */
8563 if (note
== 0 || note
== 1)
8565 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8566 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
8567 && regno
== dep
->regindex
)
8569 specs
[count
++] = tmpl
;
8571 /* other AR[REG] resources may be affected by AR accesses */
8572 else if (idesc
->operands
[0] == IA64_OPND_AR3
)
8575 regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
;
8576 switch (dep
->regindex
)
8582 if (regno
== AR_BSPSTORE
)
8584 specs
[count
++] = tmpl
;
8588 (regno
== AR_BSPSTORE
8589 || regno
== AR_RNAT
))
8591 specs
[count
++] = tmpl
;
8596 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
8599 regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
;
8600 switch (dep
->regindex
)
8605 if (regno
== AR_BSPSTORE
|| regno
== AR_RNAT
)
8607 specs
[count
++] = tmpl
;
8614 specs
[count
++] = tmpl
;
8624 /* Handle all CR[REG] resources */
8625 if (note
== 0 || note
== 1)
8627 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
8629 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8630 if (regno
== dep
->regindex
)
8632 specs
[count
++] = tmpl
;
8634 else if (!rsrc_write
)
8636 /* Reads from CR[IVR] affect other resources. */
8637 if (regno
== CR_IVR
)
8639 if ((dep
->regindex
>= CR_IRR0
8640 && dep
->regindex
<= CR_IRR3
)
8641 || dep
->regindex
== CR_TPR
)
8643 specs
[count
++] = tmpl
;
8650 specs
[count
++] = tmpl
;
8659 case IA64_RS_INSERVICE
:
8660 /* look for write of EOI (67) or read of IVR (65) */
8661 if ((idesc
->operands
[0] == IA64_OPND_CR3
8662 && CURR_SLOT
.opnd
[0].X_add_number
- REG_CR
== CR_EOI
)
8663 || (idesc
->operands
[1] == IA64_OPND_CR3
8664 && CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
== CR_IVR
))
8666 specs
[count
++] = tmpl
;
8673 specs
[count
++] = tmpl
;
8684 specs
[count
++] = tmpl
;
8688 /* Check if any of the registers accessed are in the rotating region.
8689 mov to/from pr accesses CFM only when qp_regno is in the rotating
8691 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8693 if (idesc
->operands
[i
] == IA64_OPND_R1
8694 || idesc
->operands
[i
] == IA64_OPND_R2
8695 || idesc
->operands
[i
] == IA64_OPND_R3
)
8697 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8698 /* Assumes that md.rot.num_regs is always valid */
8699 if (md
.rot
.num_regs
> 0
8701 && num
< 31 + md
.rot
.num_regs
)
8703 specs
[count
] = tmpl
;
8704 specs
[count
++].specific
= 0;
8707 else if (idesc
->operands
[i
] == IA64_OPND_F1
8708 || idesc
->operands
[i
] == IA64_OPND_F2
8709 || idesc
->operands
[i
] == IA64_OPND_F3
8710 || idesc
->operands
[i
] == IA64_OPND_F4
)
8712 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8715 specs
[count
] = tmpl
;
8716 specs
[count
++].specific
= 0;
8719 else if (idesc
->operands
[i
] == IA64_OPND_P1
8720 || idesc
->operands
[i
] == IA64_OPND_P2
)
8722 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8725 specs
[count
] = tmpl
;
8726 specs
[count
++].specific
= 0;
8730 if (CURR_SLOT
.qp_regno
> 15)
8732 specs
[count
] = tmpl
;
8733 specs
[count
++].specific
= 0;
8738 /* This is the same as IA64_RS_PRr, except simplified to account for
8739 the fact that there is only one register. */
8743 specs
[count
++] = tmpl
;
8748 if (idesc
->operands
[2] == IA64_OPND_IMM17
)
8749 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8750 if (mask
& ((valueT
) 1 << 63))
8751 specs
[count
++] = tmpl
;
8753 else if (note
== 11)
8755 if ((idesc
->operands
[0] == IA64_OPND_P1
8756 && CURR_SLOT
.opnd
[0].X_add_number
- REG_P
== 63)
8757 || (idesc
->operands
[1] == IA64_OPND_P2
8758 && CURR_SLOT
.opnd
[1].X_add_number
- REG_P
== 63))
8760 specs
[count
++] = tmpl
;
8763 else if (note
== 12)
8765 if (CURR_SLOT
.qp_regno
== 63)
8767 specs
[count
++] = tmpl
;
8774 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8775 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8776 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8777 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8780 && (idesc
->operands
[0] == IA64_OPND_P1
8781 || idesc
->operands
[0] == IA64_OPND_P2
))
8783 specs
[count
] = tmpl
;
8784 specs
[count
++].cmp_type
=
8785 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8788 && (idesc
->operands
[1] == IA64_OPND_P1
8789 || idesc
->operands
[1] == IA64_OPND_P2
))
8791 specs
[count
] = tmpl
;
8792 specs
[count
++].cmp_type
=
8793 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8798 if (CURR_SLOT
.qp_regno
== 63)
8800 specs
[count
++] = tmpl
;
8811 /* FIXME we can identify some individual RSE written resources, but RSE
8812 read resources have not yet been completely identified, so for now
8813 treat RSE as a single resource */
8814 if (strncmp (idesc
->name
, "mov", 3) == 0)
8818 if (idesc
->operands
[0] == IA64_OPND_AR3
8819 && CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
)
8821 specs
[count
] = tmpl
;
8822 specs
[count
++].index
= 0; /* IA64_RSE_BSPLOAD/RNATBITINDEX */
8827 if (idesc
->operands
[0] == IA64_OPND_AR3
)
8829 if (CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
8830 || CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_RNAT
)
8832 specs
[count
++] = tmpl
;
8835 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
8837 if (CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSP
8838 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSPSTORE
8839 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_RNAT
)
8841 specs
[count
++] = tmpl
;
8848 specs
[count
++] = tmpl
;
8853 /* FIXME -- do any of these need to be non-specific? */
8854 specs
[count
++] = tmpl
;
8858 as_bad (_("Unrecognized dependency specifier %d\n"), dep
->specifier
);
8865 /* Clear branch flags on marked resources. This breaks the link between the
8866 QP of the marking instruction and a subsequent branch on the same QP. */
8869 clear_qp_branch_flag (mask
)
8873 for (i
= 0; i
< regdepslen
; i
++)
8875 valueT bit
= ((valueT
) 1 << regdeps
[i
].qp_regno
);
8876 if ((bit
& mask
) != 0)
8878 regdeps
[i
].link_to_qp_branch
= 0;
8883 /* MASK contains 2 and only 2 PRs which are mutually exclusive. Remove
8884 any mutexes which contain one of the PRs and create new ones when
8888 update_qp_mutex (valueT mask
)
8894 while (i
< qp_mutexeslen
)
8896 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
8898 /* If it destroys and creates the same mutex, do nothing. */
8899 if (qp_mutexes
[i
].prmask
== mask
8900 && qp_mutexes
[i
].path
== md
.path
)
8911 fprintf (stderr
, " Clearing mutex relation");
8912 print_prmask (qp_mutexes
[i
].prmask
);
8913 fprintf (stderr
, "\n");
8916 /* Deal with the old mutex with more than 3+ PRs only if
8917 the new mutex on the same execution path with it.
8919 FIXME: The 3+ mutex support is incomplete.
8920 dot_pred_rel () may be a better place to fix it. */
8921 if (qp_mutexes
[i
].path
== md
.path
)
8923 /* If it is a proper subset of the mutex, create a
8926 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
8929 qp_mutexes
[i
].prmask
&= ~mask
;
8930 if (qp_mutexes
[i
].prmask
& (qp_mutexes
[i
].prmask
- 1))
8932 /* Modify the mutex if there are more than one
8940 /* Remove the mutex. */
8941 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
8949 add_qp_mutex (mask
);
8954 /* Remove any mutexes which contain any of the PRs indicated in the mask.
8956 Any changes to a PR clears the mutex relations which include that PR. */
8959 clear_qp_mutex (mask
)
8965 while (i
< qp_mutexeslen
)
8967 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
8971 fprintf (stderr
, " Clearing mutex relation");
8972 print_prmask (qp_mutexes
[i
].prmask
);
8973 fprintf (stderr
, "\n");
8975 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
8982 /* Clear implies relations which contain PRs in the given masks.
8983 P1_MASK indicates the source of the implies relation, while P2_MASK
8984 indicates the implied PR. */
8987 clear_qp_implies (p1_mask
, p2_mask
)
8994 while (i
< qp_implieslen
)
8996 if ((((valueT
) 1 << qp_implies
[i
].p1
) & p1_mask
) != 0
8997 || (((valueT
) 1 << qp_implies
[i
].p2
) & p2_mask
) != 0)
9000 fprintf (stderr
, "Clearing implied relation PR%d->PR%d\n",
9001 qp_implies
[i
].p1
, qp_implies
[i
].p2
);
9002 qp_implies
[i
] = qp_implies
[--qp_implieslen
];
9009 /* Add the PRs specified to the list of implied relations. */
9012 add_qp_imply (p1
, p2
)
9019 /* p0 is not meaningful here. */
9020 if (p1
== 0 || p2
== 0)
9026 /* If it exists already, ignore it. */
9027 for (i
= 0; i
< qp_implieslen
; i
++)
9029 if (qp_implies
[i
].p1
== p1
9030 && qp_implies
[i
].p2
== p2
9031 && qp_implies
[i
].path
== md
.path
9032 && !qp_implies
[i
].p2_branched
)
9036 if (qp_implieslen
== qp_impliestotlen
)
9038 qp_impliestotlen
+= 20;
9039 qp_implies
= (struct qp_imply
*)
9040 xrealloc ((void *) qp_implies
,
9041 qp_impliestotlen
* sizeof (struct qp_imply
));
9044 fprintf (stderr
, " Registering PR%d implies PR%d\n", p1
, p2
);
9045 qp_implies
[qp_implieslen
].p1
= p1
;
9046 qp_implies
[qp_implieslen
].p2
= p2
;
9047 qp_implies
[qp_implieslen
].path
= md
.path
;
9048 qp_implies
[qp_implieslen
++].p2_branched
= 0;
9050 /* Add in the implied transitive relations; for everything that p2 implies,
9051 make p1 imply that, too; for everything that implies p1, make it imply p2
9053 for (i
= 0; i
< qp_implieslen
; i
++)
9055 if (qp_implies
[i
].p1
== p2
)
9056 add_qp_imply (p1
, qp_implies
[i
].p2
);
9057 if (qp_implies
[i
].p2
== p1
)
9058 add_qp_imply (qp_implies
[i
].p1
, p2
);
9060 /* Add in mutex relations implied by this implies relation; for each mutex
9061 relation containing p2, duplicate it and replace p2 with p1. */
9062 bit
= (valueT
) 1 << p1
;
9063 mask
= (valueT
) 1 << p2
;
9064 for (i
= 0; i
< qp_mutexeslen
; i
++)
9066 if (qp_mutexes
[i
].prmask
& mask
)
9067 add_qp_mutex ((qp_mutexes
[i
].prmask
& ~mask
) | bit
);
9071 /* Add the PRs specified in the mask to the mutex list; this means that only
9072 one of the PRs can be true at any time. PR0 should never be included in
9082 if (qp_mutexeslen
== qp_mutexestotlen
)
9084 qp_mutexestotlen
+= 20;
9085 qp_mutexes
= (struct qpmutex
*)
9086 xrealloc ((void *) qp_mutexes
,
9087 qp_mutexestotlen
* sizeof (struct qpmutex
));
9091 fprintf (stderr
, " Registering mutex on");
9092 print_prmask (mask
);
9093 fprintf (stderr
, "\n");
9095 qp_mutexes
[qp_mutexeslen
].path
= md
.path
;
9096 qp_mutexes
[qp_mutexeslen
++].prmask
= mask
;
9100 has_suffix_p (name
, suffix
)
9104 size_t namelen
= strlen (name
);
9105 size_t sufflen
= strlen (suffix
);
9107 if (namelen
<= sufflen
)
9109 return strcmp (name
+ namelen
- sufflen
, suffix
) == 0;
9113 clear_register_values ()
9117 fprintf (stderr
, " Clearing register values\n");
9118 for (i
= 1; i
< NELEMS (gr_values
); i
++)
9119 gr_values
[i
].known
= 0;
9122 /* Keep track of register values/changes which affect DV tracking.
9124 optimization note: should add a flag to classes of insns where otherwise we
9125 have to examine a group of strings to identify them. */
9128 note_register_values (idesc
)
9129 struct ia64_opcode
*idesc
;
9131 valueT qp_changemask
= 0;
9134 /* Invalidate values for registers being written to. */
9135 for (i
= 0; i
< idesc
->num_outputs
; i
++)
9137 if (idesc
->operands
[i
] == IA64_OPND_R1
9138 || idesc
->operands
[i
] == IA64_OPND_R2
9139 || idesc
->operands
[i
] == IA64_OPND_R3
)
9141 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9142 if (regno
> 0 && regno
< NELEMS (gr_values
))
9143 gr_values
[regno
].known
= 0;
9145 else if (idesc
->operands
[i
] == IA64_OPND_R3_2
)
9147 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9148 if (regno
> 0 && regno
< 4)
9149 gr_values
[regno
].known
= 0;
9151 else if (idesc
->operands
[i
] == IA64_OPND_P1
9152 || idesc
->operands
[i
] == IA64_OPND_P2
)
9154 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
9155 qp_changemask
|= (valueT
) 1 << regno
;
9157 else if (idesc
->operands
[i
] == IA64_OPND_PR
)
9159 if (idesc
->operands
[2] & (valueT
) 0x10000)
9160 qp_changemask
= ~(valueT
) 0x1FFFF | idesc
->operands
[2];
9162 qp_changemask
= idesc
->operands
[2];
9165 else if (idesc
->operands
[i
] == IA64_OPND_PR_ROT
)
9167 if (idesc
->operands
[1] & ((valueT
) 1 << 43))
9168 qp_changemask
= -((valueT
) 1 << 44) | idesc
->operands
[1];
9170 qp_changemask
= idesc
->operands
[1];
9171 qp_changemask
&= ~(valueT
) 0xFFFF;
9176 /* Always clear qp branch flags on any PR change. */
9177 /* FIXME there may be exceptions for certain compares. */
9178 clear_qp_branch_flag (qp_changemask
);
9180 /* Invalidate rotating registers on insns which affect RRBs in CFM. */
9181 if (idesc
->flags
& IA64_OPCODE_MOD_RRBS
)
9183 qp_changemask
|= ~(valueT
) 0xFFFF;
9184 if (strcmp (idesc
->name
, "clrrrb.pr") != 0)
9186 for (i
= 32; i
< 32 + md
.rot
.num_regs
; i
++)
9187 gr_values
[i
].known
= 0;
9189 clear_qp_mutex (qp_changemask
);
9190 clear_qp_implies (qp_changemask
, qp_changemask
);
9192 /* After a call, all register values are undefined, except those marked
9194 else if (strncmp (idesc
->name
, "br.call", 6) == 0
9195 || strncmp (idesc
->name
, "brl.call", 7) == 0)
9197 /* FIXME keep GR values which are marked as "safe_across_calls" */
9198 clear_register_values ();
9199 clear_qp_mutex (~qp_safe_across_calls
);
9200 clear_qp_implies (~qp_safe_across_calls
, ~qp_safe_across_calls
);
9201 clear_qp_branch_flag (~qp_safe_across_calls
);
9203 else if (is_interruption_or_rfi (idesc
)
9204 || is_taken_branch (idesc
))
9206 clear_register_values ();
9207 clear_qp_mutex (~(valueT
) 0);
9208 clear_qp_implies (~(valueT
) 0, ~(valueT
) 0);
9210 /* Look for mutex and implies relations. */
9211 else if ((idesc
->operands
[0] == IA64_OPND_P1
9212 || idesc
->operands
[0] == IA64_OPND_P2
)
9213 && (idesc
->operands
[1] == IA64_OPND_P1
9214 || idesc
->operands
[1] == IA64_OPND_P2
))
9216 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
9217 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
9218 valueT p1mask
= (p1
!= 0) ? (valueT
) 1 << p1
: 0;
9219 valueT p2mask
= (p2
!= 0) ? (valueT
) 1 << p2
: 0;
9221 /* If both PRs are PR0, we can't really do anything. */
9222 if (p1
== 0 && p2
== 0)
9225 fprintf (stderr
, " Ignoring PRs due to inclusion of p0\n");
9227 /* In general, clear mutexes and implies which include P1 or P2,
9228 with the following exceptions. */
9229 else if (has_suffix_p (idesc
->name
, ".or.andcm")
9230 || has_suffix_p (idesc
->name
, ".and.orcm"))
9232 clear_qp_implies (p2mask
, p1mask
);
9234 else if (has_suffix_p (idesc
->name
, ".andcm")
9235 || has_suffix_p (idesc
->name
, ".and"))
9237 clear_qp_implies (0, p1mask
| p2mask
);
9239 else if (has_suffix_p (idesc
->name
, ".orcm")
9240 || has_suffix_p (idesc
->name
, ".or"))
9242 clear_qp_mutex (p1mask
| p2mask
);
9243 clear_qp_implies (p1mask
| p2mask
, 0);
9249 clear_qp_implies (p1mask
| p2mask
, p1mask
| p2mask
);
9251 /* If one of the PRs is PR0, we call clear_qp_mutex. */
9252 if (p1
== 0 || p2
== 0)
9253 clear_qp_mutex (p1mask
| p2mask
);
9255 added
= update_qp_mutex (p1mask
| p2mask
);
9257 if (CURR_SLOT
.qp_regno
== 0
9258 || has_suffix_p (idesc
->name
, ".unc"))
9260 if (added
== 0 && p1
&& p2
)
9261 add_qp_mutex (p1mask
| p2mask
);
9262 if (CURR_SLOT
.qp_regno
!= 0)
9265 add_qp_imply (p1
, CURR_SLOT
.qp_regno
);
9267 add_qp_imply (p2
, CURR_SLOT
.qp_regno
);
9272 /* Look for mov imm insns into GRs. */
9273 else if (idesc
->operands
[0] == IA64_OPND_R1
9274 && (idesc
->operands
[1] == IA64_OPND_IMM22
9275 || idesc
->operands
[1] == IA64_OPND_IMMU64
)
9276 && (strcmp (idesc
->name
, "mov") == 0
9277 || strcmp (idesc
->name
, "movl") == 0))
9279 int regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
9280 if (regno
> 0 && regno
< NELEMS (gr_values
))
9282 gr_values
[regno
].known
= 1;
9283 gr_values
[regno
].value
= CURR_SLOT
.opnd
[1].X_add_number
;
9284 gr_values
[regno
].path
= md
.path
;
9287 fprintf (stderr
, " Know gr%d = ", regno
);
9288 fprintf_vma (stderr
, gr_values
[regno
].value
);
9289 fputs ("\n", stderr
);
9295 clear_qp_mutex (qp_changemask
);
9296 clear_qp_implies (qp_changemask
, qp_changemask
);
9300 /* Return whether the given predicate registers are currently mutex. */
9303 qp_mutex (p1
, p2
, path
)
9313 mask
= ((valueT
) 1 << p1
) | (valueT
) 1 << p2
;
9314 for (i
= 0; i
< qp_mutexeslen
; i
++)
9316 if (qp_mutexes
[i
].path
>= path
9317 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
9324 /* Return whether the given resource is in the given insn's list of chks
9325 Return 1 if the conflict is absolutely determined, 2 if it's a potential
9329 resources_match (rs
, idesc
, note
, qp_regno
, path
)
9331 struct ia64_opcode
*idesc
;
9336 struct rsrc specs
[MAX_SPECS
];
9339 /* If the marked resource's qp_regno and the given qp_regno are mutex,
9340 we don't need to check. One exception is note 11, which indicates that
9341 target predicates are written regardless of PR[qp]. */
9342 if (qp_mutex (rs
->qp_regno
, qp_regno
, path
)
9346 count
= specify_resource (rs
->dependency
, idesc
, DV_CHK
, specs
, note
, path
);
9349 /* UNAT checking is a bit more specific than other resources */
9350 if (rs
->dependency
->specifier
== IA64_RS_AR_UNAT
9351 && specs
[count
].mem_offset
.hint
9352 && rs
->mem_offset
.hint
)
9354 if (rs
->mem_offset
.base
== specs
[count
].mem_offset
.base
)
9356 if (((rs
->mem_offset
.offset
>> 3) & 0x3F) ==
9357 ((specs
[count
].mem_offset
.offset
>> 3) & 0x3F))
9364 /* Skip apparent PR write conflicts where both writes are an AND or both
9365 writes are an OR. */
9366 if (rs
->dependency
->specifier
== IA64_RS_PR
9367 || rs
->dependency
->specifier
== IA64_RS_PRr
9368 || rs
->dependency
->specifier
== IA64_RS_PR63
)
9370 if (specs
[count
].cmp_type
!= CMP_NONE
9371 && specs
[count
].cmp_type
== rs
->cmp_type
)
9374 fprintf (stderr
, " %s on parallel compare allowed (PR%d)\n",
9375 dv_mode
[rs
->dependency
->mode
],
9376 rs
->dependency
->specifier
!= IA64_RS_PR63
?
9377 specs
[count
].index
: 63);
9382 " %s on parallel compare conflict %s vs %s on PR%d\n",
9383 dv_mode
[rs
->dependency
->mode
],
9384 dv_cmp_type
[rs
->cmp_type
],
9385 dv_cmp_type
[specs
[count
].cmp_type
],
9386 rs
->dependency
->specifier
!= IA64_RS_PR63
?
9387 specs
[count
].index
: 63);
9391 /* If either resource is not specific, conservatively assume a conflict
9393 if (!specs
[count
].specific
|| !rs
->specific
)
9395 else if (specs
[count
].index
== rs
->index
)
9400 fprintf (stderr
, " No %s conflicts\n", rs
->dependency
->name
);
9406 /* Indicate an instruction group break; if INSERT_STOP is non-zero, then
9407 insert a stop to create the break. Update all resource dependencies
9408 appropriately. If QP_REGNO is non-zero, only apply the break to resources
9409 which use the same QP_REGNO and have the link_to_qp_branch flag set.
9410 If SAVE_CURRENT is non-zero, don't affect resources marked by the current
9414 insn_group_break (insert_stop
, qp_regno
, save_current
)
9421 if (insert_stop
&& md
.num_slots_in_use
> 0)
9422 PREV_SLOT
.end_of_insn_group
= 1;
9426 fprintf (stderr
, " Insn group break%s",
9427 (insert_stop
? " (w/stop)" : ""));
9429 fprintf (stderr
, " effective for QP=%d", qp_regno
);
9430 fprintf (stderr
, "\n");
9434 while (i
< regdepslen
)
9436 const struct ia64_dependency
*dep
= regdeps
[i
].dependency
;
9439 && regdeps
[i
].qp_regno
!= qp_regno
)
9446 && CURR_SLOT
.src_file
== regdeps
[i
].file
9447 && CURR_SLOT
.src_line
== regdeps
[i
].line
)
9453 /* clear dependencies which are automatically cleared by a stop, or
9454 those that have reached the appropriate state of insn serialization */
9455 if (dep
->semantics
== IA64_DVS_IMPLIED
9456 || dep
->semantics
== IA64_DVS_IMPLIEDF
9457 || regdeps
[i
].insn_srlz
== STATE_SRLZ
)
9459 print_dependency ("Removing", i
);
9460 regdeps
[i
] = regdeps
[--regdepslen
];
9464 if (dep
->semantics
== IA64_DVS_DATA
9465 || dep
->semantics
== IA64_DVS_INSTR
9466 || dep
->semantics
== IA64_DVS_SPECIFIC
)
9468 if (regdeps
[i
].insn_srlz
== STATE_NONE
)
9469 regdeps
[i
].insn_srlz
= STATE_STOP
;
9470 if (regdeps
[i
].data_srlz
== STATE_NONE
)
9471 regdeps
[i
].data_srlz
= STATE_STOP
;
9478 /* Add the given resource usage spec to the list of active dependencies. */
9481 mark_resource (idesc
, dep
, spec
, depind
, path
)
9482 struct ia64_opcode
*idesc ATTRIBUTE_UNUSED
;
9483 const struct ia64_dependency
*dep ATTRIBUTE_UNUSED
;
9488 if (regdepslen
== regdepstotlen
)
9490 regdepstotlen
+= 20;
9491 regdeps
= (struct rsrc
*)
9492 xrealloc ((void *) regdeps
,
9493 regdepstotlen
* sizeof (struct rsrc
));
9496 regdeps
[regdepslen
] = *spec
;
9497 regdeps
[regdepslen
].depind
= depind
;
9498 regdeps
[regdepslen
].path
= path
;
9499 regdeps
[regdepslen
].file
= CURR_SLOT
.src_file
;
9500 regdeps
[regdepslen
].line
= CURR_SLOT
.src_line
;
9502 print_dependency ("Adding", regdepslen
);
9508 print_dependency (action
, depind
)
9514 fprintf (stderr
, " %s %s '%s'",
9515 action
, dv_mode
[(regdeps
[depind
].dependency
)->mode
],
9516 (regdeps
[depind
].dependency
)->name
);
9517 if (regdeps
[depind
].specific
&& regdeps
[depind
].index
!= 0)
9518 fprintf (stderr
, " (%d)", regdeps
[depind
].index
);
9519 if (regdeps
[depind
].mem_offset
.hint
)
9521 fputs (" ", stderr
);
9522 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.base
);
9523 fputs ("+", stderr
);
9524 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.offset
);
9526 fprintf (stderr
, "\n");
9531 instruction_serialization ()
9535 fprintf (stderr
, " Instruction serialization\n");
9536 for (i
= 0; i
< regdepslen
; i
++)
9537 if (regdeps
[i
].insn_srlz
== STATE_STOP
)
9538 regdeps
[i
].insn_srlz
= STATE_SRLZ
;
9542 data_serialization ()
9546 fprintf (stderr
, " Data serialization\n");
9547 while (i
< regdepslen
)
9549 if (regdeps
[i
].data_srlz
== STATE_STOP
9550 /* Note: as of 991210, all "other" dependencies are cleared by a
9551 data serialization. This might change with new tables */
9552 || (regdeps
[i
].dependency
)->semantics
== IA64_DVS_OTHER
)
9554 print_dependency ("Removing", i
);
9555 regdeps
[i
] = regdeps
[--regdepslen
];
9562 /* Insert stops and serializations as needed to avoid DVs. */
9565 remove_marked_resource (rs
)
9568 switch (rs
->dependency
->semantics
)
9570 case IA64_DVS_SPECIFIC
:
9572 fprintf (stderr
, "Implementation-specific, assume worst case...\n");
9573 /* ...fall through... */
9574 case IA64_DVS_INSTR
:
9576 fprintf (stderr
, "Inserting instr serialization\n");
9577 if (rs
->insn_srlz
< STATE_STOP
)
9578 insn_group_break (1, 0, 0);
9579 if (rs
->insn_srlz
< STATE_SRLZ
)
9581 struct slot oldslot
= CURR_SLOT
;
9582 /* Manually jam a srlz.i insn into the stream */
9583 memset (&CURR_SLOT
, 0, sizeof (CURR_SLOT
));
9584 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.i");
9585 instruction_serialization ();
9586 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
9587 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
9589 CURR_SLOT
= oldslot
;
9591 insn_group_break (1, 0, 0);
9593 case IA64_DVS_OTHER
: /* as of rev2 (991220) of the DV tables, all
9594 "other" types of DV are eliminated
9595 by a data serialization */
9598 fprintf (stderr
, "Inserting data serialization\n");
9599 if (rs
->data_srlz
< STATE_STOP
)
9600 insn_group_break (1, 0, 0);
9602 struct slot oldslot
= CURR_SLOT
;
9603 /* Manually jam a srlz.d insn into the stream */
9604 memset (&CURR_SLOT
, 0, sizeof (CURR_SLOT
));
9605 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.d");
9606 data_serialization ();
9607 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
9608 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
9610 CURR_SLOT
= oldslot
;
9613 case IA64_DVS_IMPLIED
:
9614 case IA64_DVS_IMPLIEDF
:
9616 fprintf (stderr
, "Inserting stop\n");
9617 insn_group_break (1, 0, 0);
9624 /* Check the resources used by the given opcode against the current dependency
9627 The check is run once for each execution path encountered. In this case,
9628 a unique execution path is the sequence of instructions following a code
9629 entry point, e.g. the following has three execution paths, one starting
9630 at L0, one at L1, and one at L2.
9639 check_dependencies (idesc
)
9640 struct ia64_opcode
*idesc
;
9642 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
9646 /* Note that the number of marked resources may change within the
9647 loop if in auto mode. */
9649 while (i
< regdepslen
)
9651 struct rsrc
*rs
= ®deps
[i
];
9652 const struct ia64_dependency
*dep
= rs
->dependency
;
9657 if (dep
->semantics
== IA64_DVS_NONE
9658 || (chkind
= depends_on (rs
->depind
, idesc
)) == -1)
9664 note
= NOTE (opdeps
->chks
[chkind
]);
9666 /* Check this resource against each execution path seen thus far. */
9667 for (path
= 0; path
<= md
.path
; path
++)
9671 /* If the dependency wasn't on the path being checked, ignore it. */
9672 if (rs
->path
< path
)
9675 /* If the QP for this insn implies a QP which has branched, don't
9676 bother checking. Ed. NOTE: I don't think this check is terribly
9677 useful; what's the point of generating code which will only be
9678 reached if its QP is zero?
9679 This code was specifically inserted to handle the following code,
9680 based on notes from Intel's DV checking code, where p1 implies p2.
9686 if (CURR_SLOT
.qp_regno
!= 0)
9690 for (implies
= 0; implies
< qp_implieslen
; implies
++)
9692 if (qp_implies
[implies
].path
>= path
9693 && qp_implies
[implies
].p1
== CURR_SLOT
.qp_regno
9694 && qp_implies
[implies
].p2_branched
)
9704 if ((matchtype
= resources_match (rs
, idesc
, note
,
9705 CURR_SLOT
.qp_regno
, path
)) != 0)
9708 char pathmsg
[256] = "";
9709 char indexmsg
[256] = "";
9710 int certain
= (matchtype
== 1 && CURR_SLOT
.qp_regno
== 0);
9713 sprintf (pathmsg
, " when entry is at label '%s'",
9714 md
.entry_labels
[path
- 1]);
9715 if (rs
->specific
&& rs
->index
!= 0)
9716 sprintf (indexmsg
, ", specific resource number is %d",
9718 sprintf (msg
, "Use of '%s' %s %s dependency '%s' (%s)%s%s",
9720 (certain
? "violates" : "may violate"),
9721 dv_mode
[dep
->mode
], dep
->name
,
9722 dv_sem
[dep
->semantics
],
9725 if (md
.explicit_mode
)
9727 as_warn ("%s", msg
);
9729 as_warn (_("Only the first path encountering the conflict "
9731 as_warn_where (rs
->file
, rs
->line
,
9732 _("This is the location of the "
9733 "conflicting usage"));
9734 /* Don't bother checking other paths, to avoid duplicating
9741 fprintf (stderr
, "%s @ %s:%d\n", msg
, rs
->file
, rs
->line
);
9743 remove_marked_resource (rs
);
9745 /* since the set of dependencies has changed, start over */
9746 /* FIXME -- since we're removing dvs as we go, we
9747 probably don't really need to start over... */
9760 /* Register new dependencies based on the given opcode. */
9763 mark_resources (idesc
)
9764 struct ia64_opcode
*idesc
;
9767 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
9768 int add_only_qp_reads
= 0;
9770 /* A conditional branch only uses its resources if it is taken; if it is
9771 taken, we stop following that path. The other branch types effectively
9772 *always* write their resources. If it's not taken, register only QP
9774 if (is_conditional_branch (idesc
) || is_interruption_or_rfi (idesc
))
9776 add_only_qp_reads
= 1;
9780 fprintf (stderr
, "Registering '%s' resource usage\n", idesc
->name
);
9782 for (i
= 0; i
< opdeps
->nregs
; i
++)
9784 const struct ia64_dependency
*dep
;
9785 struct rsrc specs
[MAX_SPECS
];
9790 dep
= ia64_find_dependency (opdeps
->regs
[i
]);
9791 note
= NOTE (opdeps
->regs
[i
]);
9793 if (add_only_qp_reads
9794 && !(dep
->mode
== IA64_DV_WAR
9795 && (dep
->specifier
== IA64_RS_PR
9796 || dep
->specifier
== IA64_RS_PRr
9797 || dep
->specifier
== IA64_RS_PR63
)))
9800 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, md
.path
);
9803 if (md
.debug_dv
&& !count
)
9804 fprintf (stderr
, " No %s %s usage found (path %d)\n",
9805 dv_mode
[dep
->mode
], dep
->name
, md
.path
);
9810 mark_resource (idesc
, dep
, &specs
[count
],
9811 DEP (opdeps
->regs
[i
]), md
.path
);
9814 /* The execution path may affect register values, which may in turn
9815 affect which indirect-access resources are accessed. */
9816 switch (dep
->specifier
)
9828 for (path
= 0; path
< md
.path
; path
++)
9830 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, path
);
9832 mark_resource (idesc
, dep
, &specs
[count
],
9833 DEP (opdeps
->regs
[i
]), path
);
9840 /* Remove dependencies when they no longer apply. */
9843 update_dependencies (idesc
)
9844 struct ia64_opcode
*idesc
;
9848 if (strcmp (idesc
->name
, "srlz.i") == 0)
9850 instruction_serialization ();
9852 else if (strcmp (idesc
->name
, "srlz.d") == 0)
9854 data_serialization ();
9856 else if (is_interruption_or_rfi (idesc
)
9857 || is_taken_branch (idesc
))
9859 /* Although technically the taken branch doesn't clear dependencies
9860 which require a srlz.[id], we don't follow the branch; the next
9861 instruction is assumed to start with a clean slate. */
9865 else if (is_conditional_branch (idesc
)
9866 && CURR_SLOT
.qp_regno
!= 0)
9868 int is_call
= strstr (idesc
->name
, ".call") != NULL
;
9870 for (i
= 0; i
< qp_implieslen
; i
++)
9872 /* If the conditional branch's predicate is implied by the predicate
9873 in an existing dependency, remove that dependency. */
9874 if (qp_implies
[i
].p2
== CURR_SLOT
.qp_regno
)
9877 /* Note that this implied predicate takes a branch so that if
9878 a later insn generates a DV but its predicate implies this
9879 one, we can avoid the false DV warning. */
9880 qp_implies
[i
].p2_branched
= 1;
9881 while (depind
< regdepslen
)
9883 if (regdeps
[depind
].qp_regno
== qp_implies
[i
].p1
)
9885 print_dependency ("Removing", depind
);
9886 regdeps
[depind
] = regdeps
[--regdepslen
];
9893 /* Any marked resources which have this same predicate should be
9894 cleared, provided that the QP hasn't been modified between the
9895 marking instruction and the branch. */
9898 insn_group_break (0, CURR_SLOT
.qp_regno
, 1);
9903 while (i
< regdepslen
)
9905 if (regdeps
[i
].qp_regno
== CURR_SLOT
.qp_regno
9906 && regdeps
[i
].link_to_qp_branch
9907 && (regdeps
[i
].file
!= CURR_SLOT
.src_file
9908 || regdeps
[i
].line
!= CURR_SLOT
.src_line
))
9910 /* Treat like a taken branch */
9911 print_dependency ("Removing", i
);
9912 regdeps
[i
] = regdeps
[--regdepslen
];
9921 /* Examine the current instruction for dependency violations. */
9925 struct ia64_opcode
*idesc
;
9929 fprintf (stderr
, "Checking %s for violations (line %d, %d/%d)\n",
9930 idesc
->name
, CURR_SLOT
.src_line
,
9931 idesc
->dependencies
->nchks
,
9932 idesc
->dependencies
->nregs
);
9935 /* Look through the list of currently marked resources; if the current
9936 instruction has the dependency in its chks list which uses that resource,
9937 check against the specific resources used. */
9938 check_dependencies (idesc
);
9940 /* Look up the instruction's regdeps (RAW writes, WAW writes, and WAR reads),
9941 then add them to the list of marked resources. */
9942 mark_resources (idesc
);
9944 /* There are several types of dependency semantics, and each has its own
9945 requirements for being cleared
9947 Instruction serialization (insns separated by interruption, rfi, or
9948 writer + srlz.i + reader, all in separate groups) clears DVS_INSTR.
9950 Data serialization (instruction serialization, or writer + srlz.d +
9951 reader, where writer and srlz.d are in separate groups) clears
9952 DVS_DATA. (This also clears DVS_OTHER, but that is not guaranteed to
9953 always be the case).
9955 Instruction group break (groups separated by stop, taken branch,
9956 interruption or rfi) clears DVS_IMPLIED and DVS_IMPLIEDF.
9958 update_dependencies (idesc
);
9960 /* Sometimes, knowing a register value allows us to avoid giving a false DV
9961 warning. Keep track of as many as possible that are useful. */
9962 note_register_values (idesc
);
9964 /* We don't need or want this anymore. */
9965 md
.mem_offset
.hint
= 0;
9970 /* Translate one line of assembly. Pseudo ops and labels do not show
9976 char *saved_input_line_pointer
, *mnemonic
;
9977 const struct pseudo_opcode
*pdesc
;
9978 struct ia64_opcode
*idesc
;
9979 unsigned char qp_regno
;
9983 saved_input_line_pointer
= input_line_pointer
;
9984 input_line_pointer
= str
;
9986 /* extract the opcode (mnemonic): */
9988 mnemonic
= input_line_pointer
;
9989 ch
= get_symbol_end ();
9990 pdesc
= (struct pseudo_opcode
*) hash_find (md
.pseudo_hash
, mnemonic
);
9993 *input_line_pointer
= ch
;
9994 (*pdesc
->handler
) (pdesc
->arg
);
9998 /* Find the instruction descriptor matching the arguments. */
10000 idesc
= ia64_find_opcode (mnemonic
);
10001 *input_line_pointer
= ch
;
10004 as_bad ("Unknown opcode `%s'", mnemonic
);
10008 idesc
= parse_operands (idesc
);
10012 /* Handle the dynamic ops we can handle now: */
10013 if (idesc
->type
== IA64_TYPE_DYN
)
10015 if (strcmp (idesc
->name
, "add") == 0)
10017 if (CURR_SLOT
.opnd
[2].X_op
== O_register
10018 && CURR_SLOT
.opnd
[2].X_add_number
< 4)
10022 ia64_free_opcode (idesc
);
10023 idesc
= ia64_find_opcode (mnemonic
);
10025 know (!idesc
->next
);
10028 else if (strcmp (idesc
->name
, "mov") == 0)
10030 enum ia64_opnd opnd1
, opnd2
;
10033 opnd1
= idesc
->operands
[0];
10034 opnd2
= idesc
->operands
[1];
10035 if (opnd1
== IA64_OPND_AR3
)
10037 else if (opnd2
== IA64_OPND_AR3
)
10041 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
)
10043 if (ar_is_only_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10044 mnemonic
= "mov.i";
10046 mnemonic
= "mov.m";
10050 ia64_free_opcode (idesc
);
10051 idesc
= ia64_find_opcode (mnemonic
);
10052 while (idesc
!= NULL
10053 && (idesc
->operands
[0] != opnd1
10054 || idesc
->operands
[1] != opnd2
))
10055 idesc
= get_next_opcode (idesc
);
10058 else if (strcmp (idesc
->name
, "mov.i") == 0
10059 || strcmp (idesc
->name
, "mov.m") == 0)
10061 enum ia64_opnd opnd1
, opnd2
;
10064 opnd1
= idesc
->operands
[0];
10065 opnd2
= idesc
->operands
[1];
10066 if (opnd1
== IA64_OPND_AR3
)
10068 else if (opnd2
== IA64_OPND_AR3
)
10072 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
)
10075 if (ar_is_only_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10077 else if (ar_is_only_in_memory_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10079 if (unit
!= 'a' && unit
!= idesc
->name
[4])
10080 as_bad ("AR %d cannot be accessed by %c-unit",
10081 (int) (CURR_SLOT
.opnd
[rop
].X_add_number
- REG_AR
),
10087 if (md
.qp
.X_op
== O_register
)
10089 qp_regno
= md
.qp
.X_add_number
- REG_P
;
10090 md
.qp
.X_op
= O_absent
;
10093 flags
= idesc
->flags
;
10095 if ((flags
& IA64_OPCODE_FIRST
) != 0)
10097 /* The alignment frag has to end with a stop bit only if the
10098 next instruction after the alignment directive has to be
10099 the first instruction in an instruction group. */
10102 while (align_frag
->fr_type
!= rs_align_code
)
10104 align_frag
= align_frag
->fr_next
;
10108 /* align_frag can be NULL if there are directives in
10110 if (align_frag
&& align_frag
->fr_next
== frag_now
)
10111 align_frag
->tc_frag_data
= 1;
10114 insn_group_break (1, 0, 0);
10118 if ((flags
& IA64_OPCODE_NO_PRED
) != 0 && qp_regno
!= 0)
10120 as_bad ("`%s' cannot be predicated", idesc
->name
);
10124 /* Build the instruction. */
10125 CURR_SLOT
.qp_regno
= qp_regno
;
10126 CURR_SLOT
.idesc
= idesc
;
10127 as_where (&CURR_SLOT
.src_file
, &CURR_SLOT
.src_line
);
10128 dwarf2_where (&CURR_SLOT
.debug_line
);
10130 /* Add unwind entry, if there is one. */
10131 if (unwind
.current_entry
)
10133 CURR_SLOT
.unwind_record
= unwind
.current_entry
;
10134 unwind
.current_entry
= NULL
;
10137 /* Check for dependency violations. */
10141 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10142 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10143 emit_one_bundle ();
10145 if ((flags
& IA64_OPCODE_LAST
) != 0)
10146 insn_group_break (1, 0, 0);
10148 md
.last_text_seg
= now_seg
;
10151 input_line_pointer
= saved_input_line_pointer
;
10154 /* Called when symbol NAME cannot be found in the symbol table.
10155 Should be used for dynamic valued symbols only. */
10158 md_undefined_symbol (name
)
10159 char *name ATTRIBUTE_UNUSED
;
10164 /* Called for any expression that can not be recognized. When the
10165 function is called, `input_line_pointer' will point to the start of
10172 enum pseudo_type pseudo_type
;
10177 switch (*input_line_pointer
)
10180 /* Find what relocation pseudo-function we're dealing with. */
10182 ch
= *++input_line_pointer
;
10183 for (i
= 0; i
< NELEMS (pseudo_func
); ++i
)
10184 if (pseudo_func
[i
].name
&& pseudo_func
[i
].name
[0] == ch
)
10186 len
= strlen (pseudo_func
[i
].name
);
10187 if (strncmp (pseudo_func
[i
].name
+ 1,
10188 input_line_pointer
+ 1, len
- 1) == 0
10189 && !is_part_of_name (input_line_pointer
[len
]))
10191 input_line_pointer
+= len
;
10192 pseudo_type
= pseudo_func
[i
].type
;
10196 switch (pseudo_type
)
10198 case PSEUDO_FUNC_RELOC
:
10199 SKIP_WHITESPACE ();
10200 if (*input_line_pointer
!= '(')
10202 as_bad ("Expected '('");
10206 ++input_line_pointer
;
10208 if (*input_line_pointer
++ != ')')
10210 as_bad ("Missing ')'");
10213 if (e
->X_op
!= O_symbol
)
10215 if (e
->X_op
!= O_pseudo_fixup
)
10217 as_bad ("Not a symbolic expression");
10220 if (i
!= FUNC_LT_RELATIVE
)
10222 as_bad ("Illegal combination of relocation functions");
10225 switch (S_GET_VALUE (e
->X_op_symbol
))
10227 case FUNC_FPTR_RELATIVE
:
10228 i
= FUNC_LT_FPTR_RELATIVE
; break;
10229 case FUNC_DTP_MODULE
:
10230 i
= FUNC_LT_DTP_MODULE
; break;
10231 case FUNC_DTP_RELATIVE
:
10232 i
= FUNC_LT_DTP_RELATIVE
; break;
10233 case FUNC_TP_RELATIVE
:
10234 i
= FUNC_LT_TP_RELATIVE
; break;
10236 as_bad ("Illegal combination of relocation functions");
10240 /* Make sure gas doesn't get rid of local symbols that are used
10242 e
->X_op
= O_pseudo_fixup
;
10243 e
->X_op_symbol
= pseudo_func
[i
].u
.sym
;
10246 case PSEUDO_FUNC_CONST
:
10247 e
->X_op
= O_constant
;
10248 e
->X_add_number
= pseudo_func
[i
].u
.ival
;
10251 case PSEUDO_FUNC_REG
:
10252 e
->X_op
= O_register
;
10253 e
->X_add_number
= pseudo_func
[i
].u
.ival
;
10257 name
= input_line_pointer
- 1;
10259 as_bad ("Unknown pseudo function `%s'", name
);
10265 ++input_line_pointer
;
10267 if (*input_line_pointer
!= ']')
10269 as_bad ("Closing bracket misssing");
10274 if (e
->X_op
!= O_register
)
10275 as_bad ("Register expected as index");
10277 ++input_line_pointer
;
10288 ignore_rest_of_line ();
10291 /* Return 1 if it's OK to adjust a reloc by replacing the symbol with
10292 a section symbol plus some offset. For relocs involving @fptr(),
10293 directives we don't want such adjustments since we need to have the
10294 original symbol's name in the reloc. */
10296 ia64_fix_adjustable (fix
)
10299 /* Prevent all adjustments to global symbols */
10300 if (S_IS_EXTERN (fix
->fx_addsy
) || S_IS_WEAK (fix
->fx_addsy
))
10303 switch (fix
->fx_r_type
)
10305 case BFD_RELOC_IA64_FPTR64I
:
10306 case BFD_RELOC_IA64_FPTR32MSB
:
10307 case BFD_RELOC_IA64_FPTR32LSB
:
10308 case BFD_RELOC_IA64_FPTR64MSB
:
10309 case BFD_RELOC_IA64_FPTR64LSB
:
10310 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10311 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10321 ia64_force_relocation (fix
)
10324 switch (fix
->fx_r_type
)
10326 case BFD_RELOC_IA64_FPTR64I
:
10327 case BFD_RELOC_IA64_FPTR32MSB
:
10328 case BFD_RELOC_IA64_FPTR32LSB
:
10329 case BFD_RELOC_IA64_FPTR64MSB
:
10330 case BFD_RELOC_IA64_FPTR64LSB
:
10332 case BFD_RELOC_IA64_LTOFF22
:
10333 case BFD_RELOC_IA64_LTOFF64I
:
10334 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10335 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10336 case BFD_RELOC_IA64_PLTOFF22
:
10337 case BFD_RELOC_IA64_PLTOFF64I
:
10338 case BFD_RELOC_IA64_PLTOFF64MSB
:
10339 case BFD_RELOC_IA64_PLTOFF64LSB
:
10341 case BFD_RELOC_IA64_LTOFF22X
:
10342 case BFD_RELOC_IA64_LDXMOV
:
10349 return generic_force_reloc (fix
);
10352 /* Decide from what point a pc-relative relocation is relative to,
10353 relative to the pc-relative fixup. Er, relatively speaking. */
10355 ia64_pcrel_from_section (fix
, sec
)
10359 unsigned long off
= fix
->fx_frag
->fr_address
+ fix
->fx_where
;
10361 if (bfd_get_section_flags (stdoutput
, sec
) & SEC_CODE
)
10368 /* Used to emit section-relative relocs for the dwarf2 debug data. */
10370 ia64_dwarf2_emit_offset (symbolS
*symbol
, unsigned int size
)
10374 expr
.X_op
= O_pseudo_fixup
;
10375 expr
.X_op_symbol
= pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
;
10376 expr
.X_add_number
= 0;
10377 expr
.X_add_symbol
= symbol
;
10378 emit_expr (&expr
, size
);
10381 /* This is called whenever some data item (not an instruction) needs a
10382 fixup. We pick the right reloc code depending on the byteorder
10383 currently in effect. */
10385 ia64_cons_fix_new (f
, where
, nbytes
, exp
)
10391 bfd_reloc_code_real_type code
;
10396 /* There are no reloc for 8 and 16 bit quantities, but we allow
10397 them here since they will work fine as long as the expression
10398 is fully defined at the end of the pass over the source file. */
10399 case 1: code
= BFD_RELOC_8
; break;
10400 case 2: code
= BFD_RELOC_16
; break;
10402 if (target_big_endian
)
10403 code
= BFD_RELOC_IA64_DIR32MSB
;
10405 code
= BFD_RELOC_IA64_DIR32LSB
;
10409 /* In 32-bit mode, data8 could mean function descriptors too. */
10410 if (exp
->X_op
== O_pseudo_fixup
10411 && exp
->X_op_symbol
10412 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
10413 && !(md
.flags
& EF_IA_64_ABI64
))
10415 if (target_big_endian
)
10416 code
= BFD_RELOC_IA64_IPLTMSB
;
10418 code
= BFD_RELOC_IA64_IPLTLSB
;
10419 exp
->X_op
= O_symbol
;
10424 if (target_big_endian
)
10425 code
= BFD_RELOC_IA64_DIR64MSB
;
10427 code
= BFD_RELOC_IA64_DIR64LSB
;
10432 if (exp
->X_op
== O_pseudo_fixup
10433 && exp
->X_op_symbol
10434 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
)
10436 if (target_big_endian
)
10437 code
= BFD_RELOC_IA64_IPLTMSB
;
10439 code
= BFD_RELOC_IA64_IPLTLSB
;
10440 exp
->X_op
= O_symbol
;
10446 as_bad ("Unsupported fixup size %d", nbytes
);
10447 ignore_rest_of_line ();
10451 if (exp
->X_op
== O_pseudo_fixup
)
10453 exp
->X_op
= O_symbol
;
10454 code
= ia64_gen_real_reloc_type (exp
->X_op_symbol
, code
);
10455 /* ??? If code unchanged, unsupported. */
10458 fix
= fix_new_exp (f
, where
, nbytes
, exp
, 0, code
);
10459 /* We need to store the byte order in effect in case we're going
10460 to fix an 8 or 16 bit relocation (for which there no real
10461 relocs available). See md_apply_fix3(). */
10462 fix
->tc_fix_data
.bigendian
= target_big_endian
;
10465 /* Return the actual relocation we wish to associate with the pseudo
10466 reloc described by SYM and R_TYPE. SYM should be one of the
10467 symbols in the pseudo_func array, or NULL. */
10469 static bfd_reloc_code_real_type
10470 ia64_gen_real_reloc_type (sym
, r_type
)
10471 struct symbol
*sym
;
10472 bfd_reloc_code_real_type r_type
;
10474 bfd_reloc_code_real_type
new = 0;
10481 switch (S_GET_VALUE (sym
))
10483 case FUNC_FPTR_RELATIVE
:
10486 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_FPTR64I
; break;
10487 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_FPTR32MSB
; break;
10488 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_FPTR32LSB
; break;
10489 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_FPTR64MSB
; break;
10490 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_FPTR64LSB
; break;
10495 case FUNC_GP_RELATIVE
:
10498 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_GPREL22
; break;
10499 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_GPREL64I
; break;
10500 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_GPREL32MSB
; break;
10501 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_GPREL32LSB
; break;
10502 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_GPREL64MSB
; break;
10503 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_GPREL64LSB
; break;
10508 case FUNC_LT_RELATIVE
:
10511 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_LTOFF22
; break;
10512 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_LTOFF64I
; break;
10517 case FUNC_LT_RELATIVE_X
:
10520 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_LTOFF22X
; break;
10525 case FUNC_PC_RELATIVE
:
10528 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PCREL22
; break;
10529 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PCREL64I
; break;
10530 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_PCREL32MSB
; break;
10531 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_PCREL32LSB
; break;
10532 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PCREL64MSB
; break;
10533 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PCREL64LSB
; break;
10538 case FUNC_PLT_RELATIVE
:
10541 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PLTOFF22
; break;
10542 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PLTOFF64I
; break;
10543 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PLTOFF64MSB
;break;
10544 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PLTOFF64LSB
;break;
10549 case FUNC_SEC_RELATIVE
:
10552 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SECREL32MSB
;break;
10553 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SECREL32LSB
;break;
10554 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SECREL64MSB
;break;
10555 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SECREL64LSB
;break;
10560 case FUNC_SEG_RELATIVE
:
10563 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SEGREL32MSB
;break;
10564 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SEGREL32LSB
;break;
10565 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SEGREL64MSB
;break;
10566 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SEGREL64LSB
;break;
10571 case FUNC_LTV_RELATIVE
:
10574 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_LTV32MSB
; break;
10575 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_LTV32LSB
; break;
10576 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_LTV64MSB
; break;
10577 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_LTV64LSB
; break;
10582 case FUNC_LT_FPTR_RELATIVE
:
10585 case BFD_RELOC_IA64_IMM22
:
10586 new = BFD_RELOC_IA64_LTOFF_FPTR22
; break;
10587 case BFD_RELOC_IA64_IMM64
:
10588 new = BFD_RELOC_IA64_LTOFF_FPTR64I
; break;
10594 case FUNC_TP_RELATIVE
:
10597 case BFD_RELOC_IA64_IMM14
:
10598 new = BFD_RELOC_IA64_TPREL14
; break;
10599 case BFD_RELOC_IA64_IMM22
:
10600 new = BFD_RELOC_IA64_TPREL22
; break;
10601 case BFD_RELOC_IA64_IMM64
:
10602 new = BFD_RELOC_IA64_TPREL64I
; break;
10608 case FUNC_LT_TP_RELATIVE
:
10611 case BFD_RELOC_IA64_IMM22
:
10612 new = BFD_RELOC_IA64_LTOFF_TPREL22
; break;
10618 case FUNC_LT_DTP_MODULE
:
10621 case BFD_RELOC_IA64_IMM22
:
10622 new = BFD_RELOC_IA64_LTOFF_DTPMOD22
; break;
10628 case FUNC_DTP_RELATIVE
:
10631 case BFD_RELOC_IA64_DIR64MSB
:
10632 new = BFD_RELOC_IA64_DTPREL64MSB
; break;
10633 case BFD_RELOC_IA64_DIR64LSB
:
10634 new = BFD_RELOC_IA64_DTPREL64LSB
; break;
10635 case BFD_RELOC_IA64_IMM14
:
10636 new = BFD_RELOC_IA64_DTPREL14
; break;
10637 case BFD_RELOC_IA64_IMM22
:
10638 new = BFD_RELOC_IA64_DTPREL22
; break;
10639 case BFD_RELOC_IA64_IMM64
:
10640 new = BFD_RELOC_IA64_DTPREL64I
; break;
10646 case FUNC_LT_DTP_RELATIVE
:
10649 case BFD_RELOC_IA64_IMM22
:
10650 new = BFD_RELOC_IA64_LTOFF_DTPREL22
; break;
10656 case FUNC_IPLT_RELOC
:
10663 /* Hmmmm. Should this ever occur? */
10670 /* Here is where generate the appropriate reloc for pseudo relocation
10673 ia64_validate_fix (fix
)
10676 switch (fix
->fx_r_type
)
10678 case BFD_RELOC_IA64_FPTR64I
:
10679 case BFD_RELOC_IA64_FPTR32MSB
:
10680 case BFD_RELOC_IA64_FPTR64LSB
:
10681 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10682 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10683 if (fix
->fx_offset
!= 0)
10684 as_bad_where (fix
->fx_file
, fix
->fx_line
,
10685 "No addend allowed in @fptr() relocation");
10693 fix_insn (fix
, odesc
, value
)
10695 const struct ia64_operand
*odesc
;
10698 bfd_vma insn
[3], t0
, t1
, control_bits
;
10703 slot
= fix
->fx_where
& 0x3;
10704 fixpos
= fix
->fx_frag
->fr_literal
+ (fix
->fx_where
- slot
);
10706 /* Bundles are always in little-endian byte order */
10707 t0
= bfd_getl64 (fixpos
);
10708 t1
= bfd_getl64 (fixpos
+ 8);
10709 control_bits
= t0
& 0x1f;
10710 insn
[0] = (t0
>> 5) & 0x1ffffffffffLL
;
10711 insn
[1] = ((t0
>> 46) & 0x3ffff) | ((t1
& 0x7fffff) << 18);
10712 insn
[2] = (t1
>> 23) & 0x1ffffffffffLL
;
10715 if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU64
)
10717 insn
[1] = (value
>> 22) & 0x1ffffffffffLL
;
10718 insn
[2] |= (((value
& 0x7f) << 13)
10719 | (((value
>> 7) & 0x1ff) << 27)
10720 | (((value
>> 16) & 0x1f) << 22)
10721 | (((value
>> 21) & 0x1) << 21)
10722 | (((value
>> 63) & 0x1) << 36));
10724 else if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU62
)
10726 if (value
& ~0x3fffffffffffffffULL
)
10727 err
= "integer operand out of range";
10728 insn
[1] = (value
>> 21) & 0x1ffffffffffLL
;
10729 insn
[2] |= (((value
& 0xfffff) << 6) | (((value
>> 20) & 0x1) << 36));
10731 else if (odesc
- elf64_ia64_operands
== IA64_OPND_TGT64
)
10734 insn
[1] = ((value
>> 20) & 0x7fffffffffLL
) << 2;
10735 insn
[2] |= ((((value
>> 59) & 0x1) << 36)
10736 | (((value
>> 0) & 0xfffff) << 13));
10739 err
= (*odesc
->insert
) (odesc
, value
, insn
+ slot
);
10742 as_bad_where (fix
->fx_file
, fix
->fx_line
, err
);
10744 t0
= control_bits
| (insn
[0] << 5) | (insn
[1] << 46);
10745 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
10746 number_to_chars_littleendian (fixpos
+ 0, t0
, 8);
10747 number_to_chars_littleendian (fixpos
+ 8, t1
, 8);
10750 /* Attempt to simplify or even eliminate a fixup. The return value is
10751 ignored; perhaps it was once meaningful, but now it is historical.
10752 To indicate that a fixup has been eliminated, set FIXP->FX_DONE.
10754 If fixp->fx_addsy is non-NULL, we'll have to generate a reloc entry
10758 md_apply_fix3 (fix
, valP
, seg
)
10761 segT seg ATTRIBUTE_UNUSED
;
10764 valueT value
= *valP
;
10766 fixpos
= fix
->fx_frag
->fr_literal
+ fix
->fx_where
;
10770 switch (fix
->fx_r_type
)
10772 case BFD_RELOC_IA64_DIR32MSB
:
10773 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL32MSB
;
10776 case BFD_RELOC_IA64_DIR32LSB
:
10777 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL32LSB
;
10780 case BFD_RELOC_IA64_DIR64MSB
:
10781 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL64MSB
;
10784 case BFD_RELOC_IA64_DIR64LSB
:
10785 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL64LSB
;
10794 switch (fix
->fx_r_type
)
10796 case BFD_RELOC_UNUSED
:
10797 /* This must be a TAG13 or TAG13b operand. There are no external
10798 relocs defined for them, so we must give an error. */
10799 as_bad_where (fix
->fx_file
, fix
->fx_line
,
10800 "%s must have a constant value",
10801 elf64_ia64_operands
[fix
->tc_fix_data
.opnd
].desc
);
10805 case BFD_RELOC_IA64_TPREL14
:
10806 case BFD_RELOC_IA64_TPREL22
:
10807 case BFD_RELOC_IA64_TPREL64I
:
10808 case BFD_RELOC_IA64_LTOFF_TPREL22
:
10809 case BFD_RELOC_IA64_LTOFF_DTPMOD22
:
10810 case BFD_RELOC_IA64_DTPREL14
:
10811 case BFD_RELOC_IA64_DTPREL22
:
10812 case BFD_RELOC_IA64_DTPREL64I
:
10813 case BFD_RELOC_IA64_LTOFF_DTPREL22
:
10814 S_SET_THREAD_LOCAL (fix
->fx_addsy
);
10821 else if (fix
->tc_fix_data
.opnd
== IA64_OPND_NIL
)
10823 if (fix
->tc_fix_data
.bigendian
)
10824 number_to_chars_bigendian (fixpos
, value
, fix
->fx_size
);
10826 number_to_chars_littleendian (fixpos
, value
, fix
->fx_size
);
10831 fix_insn (fix
, elf64_ia64_operands
+ fix
->tc_fix_data
.opnd
, value
);
10836 /* Generate the BFD reloc to be stuck in the object file from the
10837 fixup used internally in the assembler. */
10840 tc_gen_reloc (sec
, fixp
)
10841 asection
*sec ATTRIBUTE_UNUSED
;
10846 reloc
= xmalloc (sizeof (*reloc
));
10847 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
10848 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
10849 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
10850 reloc
->addend
= fixp
->fx_offset
;
10851 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
10855 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
10856 "Cannot represent %s relocation in object file",
10857 bfd_get_reloc_code_name (fixp
->fx_r_type
));
10862 /* Turn a string in input_line_pointer into a floating point constant
10863 of type TYPE, and store the appropriate bytes in *LIT. The number
10864 of LITTLENUMS emitted is stored in *SIZE. An error message is
10865 returned, or NULL on OK. */
10867 #define MAX_LITTLENUMS 5
10870 md_atof (type
, lit
, size
)
10875 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
10905 return "Bad call to MD_ATOF()";
10907 t
= atof_ieee (input_line_pointer
, type
, words
);
10909 input_line_pointer
= t
;
10911 (*ia64_float_to_chars
) (lit
, words
, prec
);
10915 /* It is 10 byte floating point with 6 byte padding. */
10916 memset (&lit
[10], 0, 6);
10917 *size
= 8 * sizeof (LITTLENUM_TYPE
);
10920 *size
= prec
* sizeof (LITTLENUM_TYPE
);
10925 /* Handle ia64 specific semantics of the align directive. */
10928 ia64_md_do_align (n
, fill
, len
, max
)
10929 int n ATTRIBUTE_UNUSED
;
10930 const char *fill ATTRIBUTE_UNUSED
;
10931 int len ATTRIBUTE_UNUSED
;
10932 int max ATTRIBUTE_UNUSED
;
10934 if (subseg_text_p (now_seg
))
10935 ia64_flush_insns ();
10938 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
10939 of an rs_align_code fragment. */
10942 ia64_handle_align (fragp
)
10945 /* Use mfi bundle of nops with no stop bits. */
10946 static const unsigned char le_nop
[]
10947 = { 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10948 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00};
10949 static const unsigned char le_nop_stop
[]
10950 = { 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10951 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00};
10955 const unsigned char *nop
;
10957 if (fragp
->fr_type
!= rs_align_code
)
10960 /* Check if this frag has to end with a stop bit. */
10961 nop
= fragp
->tc_frag_data
? le_nop_stop
: le_nop
;
10963 bytes
= fragp
->fr_next
->fr_address
- fragp
->fr_address
- fragp
->fr_fix
;
10964 p
= fragp
->fr_literal
+ fragp
->fr_fix
;
10966 /* If no paddings are needed, we check if we need a stop bit. */
10967 if (!bytes
&& fragp
->tc_frag_data
)
10969 if (fragp
->fr_fix
< 16)
10971 /* FIXME: It won't work with
10973 alloc r32=ar.pfs,1,2,4,0
10977 as_bad_where (fragp
->fr_file
, fragp
->fr_line
,
10978 _("Can't add stop bit to mark end of instruction group"));
10981 /* Bundles are always in little-endian byte order. Make sure
10982 the previous bundle has the stop bit. */
10986 /* Make sure we are on a 16-byte boundary, in case someone has been
10987 putting data into a text section. */
10990 int fix
= bytes
& 15;
10991 memset (p
, 0, fix
);
10994 fragp
->fr_fix
+= fix
;
10997 /* Instruction bundles are always little-endian. */
10998 memcpy (p
, nop
, 16);
10999 fragp
->fr_var
= 16;
11003 ia64_float_to_chars_bigendian (char *lit
, LITTLENUM_TYPE
*words
,
11008 number_to_chars_bigendian (lit
, (long) (*words
++),
11009 sizeof (LITTLENUM_TYPE
));
11010 lit
+= sizeof (LITTLENUM_TYPE
);
11015 ia64_float_to_chars_littleendian (char *lit
, LITTLENUM_TYPE
*words
,
11020 number_to_chars_littleendian (lit
, (long) (words
[prec
]),
11021 sizeof (LITTLENUM_TYPE
));
11022 lit
+= sizeof (LITTLENUM_TYPE
);
11027 ia64_elf_section_change_hook (void)
11029 if (elf_section_type (now_seg
) == SHT_IA_64_UNWIND
11030 && elf_linked_to_section (now_seg
) == NULL
)
11031 elf_linked_to_section (now_seg
) = text_section
;
11032 dot_byteorder (-1);
11035 /* Check if a label should be made global. */
11037 ia64_check_label (symbolS
*label
)
11039 if (*input_line_pointer
== ':')
11041 S_SET_EXTERNAL (label
);
11042 input_line_pointer
++;
11046 /* Used to remember where .alias and .secalias directives are seen. We
11047 will rename symbol and section names when we are about to output
11048 the relocatable file. */
11051 char *file
; /* The file where the directive is seen. */
11052 unsigned int line
; /* The line number the directive is at. */
11053 const char *name
; /* The orignale name of the symbol. */
11056 /* Called for .alias and .secalias directives. If SECTION is 1, it is
11057 .secalias. Otherwise, it is .alias. */
11059 dot_alias (int section
)
11061 char *name
, *alias
;
11065 const char *error_string
;
11068 struct hash_control
*ahash
, *nhash
;
11071 name
= input_line_pointer
;
11072 delim
= get_symbol_end ();
11073 end_name
= input_line_pointer
;
11076 if (name
== end_name
)
11078 as_bad (_("expected symbol name"));
11079 discard_rest_of_line ();
11083 SKIP_WHITESPACE ();
11085 if (*input_line_pointer
!= ',')
11088 as_bad (_("expected comma after \"%s\""), name
);
11090 ignore_rest_of_line ();
11094 input_line_pointer
++;
11097 /* We call demand_copy_C_string to check if alias string is valid.
11098 There should be a closing `"' and no `\0' in the string. */
11099 alias
= demand_copy_C_string (&len
);
11102 ignore_rest_of_line ();
11106 /* Make a copy of name string. */
11107 len
= strlen (name
) + 1;
11108 obstack_grow (¬es
, name
, len
);
11109 name
= obstack_finish (¬es
);
11114 ahash
= secalias_hash
;
11115 nhash
= secalias_name_hash
;
11120 ahash
= alias_hash
;
11121 nhash
= alias_name_hash
;
11124 /* Check if alias has been used before. */
11125 h
= (struct alias
*) hash_find (ahash
, alias
);
11128 if (strcmp (h
->name
, name
))
11129 as_bad (_("`%s' is already the alias of %s `%s'"),
11130 alias
, kind
, h
->name
);
11134 /* Check if name already has an alias. */
11135 a
= (const char *) hash_find (nhash
, name
);
11138 if (strcmp (a
, alias
))
11139 as_bad (_("%s `%s' already has an alias `%s'"), kind
, name
, a
);
11143 h
= (struct alias
*) xmalloc (sizeof (struct alias
));
11144 as_where (&h
->file
, &h
->line
);
11147 error_string
= hash_jam (ahash
, alias
, (PTR
) h
);
11150 as_fatal (_("inserting \"%s\" into %s alias hash table failed: %s"),
11151 alias
, kind
, error_string
);
11155 error_string
= hash_jam (nhash
, name
, (PTR
) alias
);
11158 as_fatal (_("inserting \"%s\" into %s name hash table failed: %s"),
11159 alias
, kind
, error_string
);
11161 obstack_free (¬es
, name
);
11162 obstack_free (¬es
, alias
);
11165 demand_empty_rest_of_line ();
11168 /* It renames the original symbol name to its alias. */
11170 do_alias (const char *alias
, PTR value
)
11172 struct alias
*h
= (struct alias
*) value
;
11173 symbolS
*sym
= symbol_find (h
->name
);
11176 as_warn_where (h
->file
, h
->line
,
11177 _("symbol `%s' aliased to `%s' is not used"),
11180 S_SET_NAME (sym
, (char *) alias
);
11183 /* Called from write_object_file. */
11185 ia64_adjust_symtab (void)
11187 hash_traverse (alias_hash
, do_alias
);
11190 /* It renames the original section name to its alias. */
11192 do_secalias (const char *alias
, PTR value
)
11194 struct alias
*h
= (struct alias
*) value
;
11195 segT sec
= bfd_get_section_by_name (stdoutput
, h
->name
);
11198 as_warn_where (h
->file
, h
->line
,
11199 _("section `%s' aliased to `%s' is not used"),
11205 /* Called from write_object_file. */
11207 ia64_frob_file (void)
11209 hash_traverse (secalias_hash
, do_secalias
);