1 /* tc-ia64.c -- Assembler for the HP/Intel IA-64 architecture.
2 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
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"
58 #define NELEMS(a) ((int) (sizeof (a)/sizeof ((a)[0])))
59 #define MIN(a,b) ((a) < (b) ? (a) : (b))
62 #define PREV_SLOT md.slot[(md.curr_slot + NUM_SLOTS - 1) % NUM_SLOTS]
63 #define CURR_SLOT md.slot[md.curr_slot]
65 #define O_pseudo_fixup (O_max + 1)
69 /* IA-64 ABI section pseudo-ops. */
70 SPECIAL_SECTION_BSS
= 0,
72 SPECIAL_SECTION_SDATA
,
73 SPECIAL_SECTION_RODATA
,
74 SPECIAL_SECTION_COMMENT
,
75 SPECIAL_SECTION_UNWIND
,
76 SPECIAL_SECTION_UNWIND_INFO
,
77 /* HPUX specific section pseudo-ops. */
78 SPECIAL_SECTION_INIT_ARRAY
,
79 SPECIAL_SECTION_FINI_ARRAY
,
96 FUNC_LT_FPTR_RELATIVE
,
106 REG_FR
= (REG_GR
+ 128),
107 REG_AR
= (REG_FR
+ 128),
108 REG_CR
= (REG_AR
+ 128),
109 REG_P
= (REG_CR
+ 128),
110 REG_BR
= (REG_P
+ 64),
111 REG_IP
= (REG_BR
+ 8),
118 /* The following are pseudo-registers for use by gas only. */
130 /* The following pseudo-registers are used for unwind directives only: */
138 DYNREG_GR
= 0, /* dynamic general purpose register */
139 DYNREG_FR
, /* dynamic floating point register */
140 DYNREG_PR
, /* dynamic predicate register */
144 enum operand_match_result
147 OPERAND_OUT_OF_RANGE
,
151 /* On the ia64, we can't know the address of a text label until the
152 instructions are packed into a bundle. To handle this, we keep
153 track of the list of labels that appear in front of each
157 struct label_fix
*next
;
161 /* This is the endianness of the current section. */
162 extern int target_big_endian
;
164 /* This is the default endianness. */
165 static int default_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
167 void (*ia64_number_to_chars
) PARAMS ((char *, valueT
, int));
169 static void ia64_float_to_chars_bigendian
170 PARAMS ((char *, LITTLENUM_TYPE
*, int));
171 static void ia64_float_to_chars_littleendian
172 PARAMS ((char *, LITTLENUM_TYPE
*, int));
173 static void (*ia64_float_to_chars
)
174 PARAMS ((char *, LITTLENUM_TYPE
*, int));
176 static struct hash_control
*alias_hash
;
177 static struct hash_control
*alias_name_hash
;
178 static struct hash_control
*secalias_hash
;
179 static struct hash_control
*secalias_name_hash
;
181 /* List of chars besides those in app.c:symbol_chars that can start an
182 operand. Used to prevent the scrubber eating vital white-space. */
183 const char ia64_symbol_chars
[] = "@?";
185 /* Characters which always start a comment. */
186 const char comment_chars
[] = "";
188 /* Characters which start a comment at the beginning of a line. */
189 const char line_comment_chars
[] = "#";
191 /* Characters which may be used to separate multiple commands on a
193 const char line_separator_chars
[] = ";";
195 /* Characters which are used to indicate an exponent in a floating
197 const char EXP_CHARS
[] = "eE";
199 /* Characters which mean that a number is a floating point constant,
201 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
203 /* ia64-specific option processing: */
205 const char *md_shortopts
= "m:N:x::";
207 struct option md_longopts
[] =
209 #define OPTION_MCONSTANT_GP (OPTION_MD_BASE + 1)
210 {"mconstant-gp", no_argument
, NULL
, OPTION_MCONSTANT_GP
},
211 #define OPTION_MAUTO_PIC (OPTION_MD_BASE + 2)
212 {"mauto-pic", no_argument
, NULL
, OPTION_MAUTO_PIC
}
215 size_t md_longopts_size
= sizeof (md_longopts
);
219 struct hash_control
*pseudo_hash
; /* pseudo opcode hash table */
220 struct hash_control
*reg_hash
; /* register name hash table */
221 struct hash_control
*dynreg_hash
; /* dynamic register hash table */
222 struct hash_control
*const_hash
; /* constant hash table */
223 struct hash_control
*entry_hash
; /* code entry hint hash table */
225 symbolS
*regsym
[REG_NUM
];
227 /* If X_op is != O_absent, the registername for the instruction's
228 qualifying predicate. If NULL, p0 is assumed for instructions
229 that are predicatable. */
232 /* Optimize for which CPU. */
239 /* What to do when hint.b is used. */
251 explicit_mode
: 1, /* which mode we're in */
252 default_explicit_mode
: 1, /* which mode is the default */
253 mode_explicitly_set
: 1, /* was the current mode explicitly set? */
255 keep_pending_output
: 1;
257 /* What to do when something is wrong with unwind directives. */
260 unwind_check_warning
,
264 /* Each bundle consists of up to three instructions. We keep
265 track of four most recent instructions so we can correctly set
266 the end_of_insn_group for the last instruction in a bundle. */
268 int num_slots_in_use
;
272 end_of_insn_group
: 1,
273 manual_bundling_on
: 1,
274 manual_bundling_off
: 1,
275 loc_directive_seen
: 1;
276 signed char user_template
; /* user-selected template, if any */
277 unsigned char qp_regno
; /* qualifying predicate */
278 /* This duplicates a good fraction of "struct fix" but we
279 can't use a "struct fix" instead since we can't call
280 fix_new_exp() until we know the address of the instruction. */
284 bfd_reloc_code_real_type code
;
285 enum ia64_opnd opnd
; /* type of operand in need of fix */
286 unsigned int is_pcrel
: 1; /* is operand pc-relative? */
287 expressionS expr
; /* the value to be inserted */
289 fixup
[2]; /* at most two fixups per insn */
290 struct ia64_opcode
*idesc
;
291 struct label_fix
*label_fixups
;
292 struct label_fix
*tag_fixups
;
293 struct unw_rec_list
*unwind_record
; /* Unwind directive. */
296 unsigned int src_line
;
297 struct dwarf2_line_info debug_line
;
305 struct dynreg
*next
; /* next dynamic register */
307 unsigned short base
; /* the base register number */
308 unsigned short num_regs
; /* # of registers in this set */
310 *dynreg
[DYNREG_NUM_TYPES
], in
, loc
, out
, rot
;
312 flagword flags
; /* ELF-header flags */
315 unsigned hint
:1; /* is this hint currently valid? */
316 bfd_vma offset
; /* mem.offset offset */
317 bfd_vma base
; /* mem.offset base */
320 int path
; /* number of alt. entry points seen */
321 const char **entry_labels
; /* labels of all alternate paths in
322 the current DV-checking block. */
323 int maxpaths
; /* size currently allocated for
326 int pointer_size
; /* size in bytes of a pointer */
327 int pointer_size_shift
; /* shift size of a pointer for alignment */
331 /* application registers: */
337 #define AR_BSPSTORE 18
352 {"ar.k0", 0}, {"ar.k1", 1}, {"ar.k2", 2}, {"ar.k3", 3},
353 {"ar.k4", 4}, {"ar.k5", 5}, {"ar.k6", 6}, {"ar.k7", 7},
354 {"ar.rsc", 16}, {"ar.bsp", 17},
355 {"ar.bspstore", 18}, {"ar.rnat", 19},
356 {"ar.fcr", 21}, {"ar.eflag", 24},
357 {"ar.csd", 25}, {"ar.ssd", 26},
358 {"ar.cflg", 27}, {"ar.fsr", 28},
359 {"ar.fir", 29}, {"ar.fdr", 30},
360 {"ar.ccv", 32}, {"ar.unat", 36},
361 {"ar.fpsr", 40}, {"ar.itc", 44},
362 {"ar.pfs", 64}, {"ar.lc", 65},
383 /* control registers: */
425 static const struct const_desc
432 /* PSR constant masks: */
435 {"psr.be", ((valueT
) 1) << 1},
436 {"psr.up", ((valueT
) 1) << 2},
437 {"psr.ac", ((valueT
) 1) << 3},
438 {"psr.mfl", ((valueT
) 1) << 4},
439 {"psr.mfh", ((valueT
) 1) << 5},
441 {"psr.ic", ((valueT
) 1) << 13},
442 {"psr.i", ((valueT
) 1) << 14},
443 {"psr.pk", ((valueT
) 1) << 15},
445 {"psr.dt", ((valueT
) 1) << 17},
446 {"psr.dfl", ((valueT
) 1) << 18},
447 {"psr.dfh", ((valueT
) 1) << 19},
448 {"psr.sp", ((valueT
) 1) << 20},
449 {"psr.pp", ((valueT
) 1) << 21},
450 {"psr.di", ((valueT
) 1) << 22},
451 {"psr.si", ((valueT
) 1) << 23},
452 {"psr.db", ((valueT
) 1) << 24},
453 {"psr.lp", ((valueT
) 1) << 25},
454 {"psr.tb", ((valueT
) 1) << 26},
455 {"psr.rt", ((valueT
) 1) << 27},
456 /* 28-31: reserved */
457 /* 32-33: cpl (current privilege level) */
458 {"psr.is", ((valueT
) 1) << 34},
459 {"psr.mc", ((valueT
) 1) << 35},
460 {"psr.it", ((valueT
) 1) << 36},
461 {"psr.id", ((valueT
) 1) << 37},
462 {"psr.da", ((valueT
) 1) << 38},
463 {"psr.dd", ((valueT
) 1) << 39},
464 {"psr.ss", ((valueT
) 1) << 40},
465 /* 41-42: ri (restart instruction) */
466 {"psr.ed", ((valueT
) 1) << 43},
467 {"psr.bn", ((valueT
) 1) << 44},
470 /* indirect register-sets/memory: */
479 { "CPUID", IND_CPUID
},
480 { "cpuid", IND_CPUID
},
492 /* Pseudo functions used to indicate relocation types (these functions
493 start with an at sign (@). */
515 /* reloc pseudo functions (these must come first!): */
516 { "dtpmod", PSEUDO_FUNC_RELOC
, { 0 } },
517 { "dtprel", PSEUDO_FUNC_RELOC
, { 0 } },
518 { "fptr", PSEUDO_FUNC_RELOC
, { 0 } },
519 { "gprel", PSEUDO_FUNC_RELOC
, { 0 } },
520 { "ltoff", PSEUDO_FUNC_RELOC
, { 0 } },
521 { "ltoffx", PSEUDO_FUNC_RELOC
, { 0 } },
522 { "pcrel", PSEUDO_FUNC_RELOC
, { 0 } },
523 { "pltoff", PSEUDO_FUNC_RELOC
, { 0 } },
524 { "secrel", PSEUDO_FUNC_RELOC
, { 0 } },
525 { "segrel", PSEUDO_FUNC_RELOC
, { 0 } },
526 { "tprel", PSEUDO_FUNC_RELOC
, { 0 } },
527 { "ltv", PSEUDO_FUNC_RELOC
, { 0 } },
528 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_FPTR_RELATIVE */
529 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_DTP_MODULE */
530 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_DTP_RELATIVE */
531 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_TP_RELATIVE */
532 { "iplt", PSEUDO_FUNC_RELOC
, { 0 } },
534 /* mbtype4 constants: */
535 { "alt", PSEUDO_FUNC_CONST
, { 0xa } },
536 { "brcst", PSEUDO_FUNC_CONST
, { 0x0 } },
537 { "mix", PSEUDO_FUNC_CONST
, { 0x8 } },
538 { "rev", PSEUDO_FUNC_CONST
, { 0xb } },
539 { "shuf", PSEUDO_FUNC_CONST
, { 0x9 } },
541 /* fclass constants: */
542 { "nat", PSEUDO_FUNC_CONST
, { 0x100 } },
543 { "qnan", PSEUDO_FUNC_CONST
, { 0x080 } },
544 { "snan", PSEUDO_FUNC_CONST
, { 0x040 } },
545 { "pos", PSEUDO_FUNC_CONST
, { 0x001 } },
546 { "neg", PSEUDO_FUNC_CONST
, { 0x002 } },
547 { "zero", PSEUDO_FUNC_CONST
, { 0x004 } },
548 { "unorm", PSEUDO_FUNC_CONST
, { 0x008 } },
549 { "norm", PSEUDO_FUNC_CONST
, { 0x010 } },
550 { "inf", PSEUDO_FUNC_CONST
, { 0x020 } },
552 { "natval", PSEUDO_FUNC_CONST
, { 0x100 } }, /* old usage */
554 /* hint constants: */
555 { "pause", PSEUDO_FUNC_CONST
, { 0x0 } },
557 /* unwind-related constants: */
558 { "svr4", PSEUDO_FUNC_CONST
, { ELFOSABI_NONE
} },
559 { "hpux", PSEUDO_FUNC_CONST
, { ELFOSABI_HPUX
} },
560 { "nt", PSEUDO_FUNC_CONST
, { 2 } }, /* conflicts w/ELFOSABI_NETBSD */
561 { "linux", PSEUDO_FUNC_CONST
, { ELFOSABI_LINUX
} },
562 { "freebsd", PSEUDO_FUNC_CONST
, { ELFOSABI_FREEBSD
} },
563 { "openvms", PSEUDO_FUNC_CONST
, { ELFOSABI_OPENVMS
} },
564 { "nsk", PSEUDO_FUNC_CONST
, { ELFOSABI_NSK
} },
566 /* unwind-related registers: */
567 { "priunat",PSEUDO_FUNC_REG
, { REG_PRIUNAT
} }
570 /* 41-bit nop opcodes (one per unit): */
571 static const bfd_vma nop
[IA64_NUM_UNITS
] =
573 0x0000000000LL
, /* NIL => break 0 */
574 0x0008000000LL
, /* I-unit nop */
575 0x0008000000LL
, /* M-unit nop */
576 0x4000000000LL
, /* B-unit nop */
577 0x0008000000LL
, /* F-unit nop */
578 0x0008000000LL
, /* L-"unit" nop */
579 0x0008000000LL
, /* X-unit nop */
582 /* Can't be `const' as it's passed to input routines (which have the
583 habit of setting temporary sentinels. */
584 static char special_section_name
[][20] =
586 {".bss"}, {".sbss"}, {".sdata"}, {".rodata"}, {".comment"},
587 {".IA_64.unwind"}, {".IA_64.unwind_info"},
588 {".init_array"}, {".fini_array"}
591 /* The best template for a particular sequence of up to three
593 #define N IA64_NUM_TYPES
594 static unsigned char best_template
[N
][N
][N
];
597 /* Resource dependencies currently in effect */
599 int depind
; /* dependency index */
600 const struct ia64_dependency
*dependency
; /* actual dependency */
601 unsigned specific
:1, /* is this a specific bit/regno? */
602 link_to_qp_branch
:1; /* will a branch on the same QP clear it?*/
603 int index
; /* specific regno/bit within dependency */
604 int note
; /* optional qualifying note (0 if none) */
608 int insn_srlz
; /* current insn serialization state */
609 int data_srlz
; /* current data serialization state */
610 int qp_regno
; /* qualifying predicate for this usage */
611 char *file
; /* what file marked this dependency */
612 unsigned int line
; /* what line marked this dependency */
613 struct mem_offset mem_offset
; /* optional memory offset hint */
614 enum { CMP_NONE
, CMP_OR
, CMP_AND
} cmp_type
; /* OR or AND compare? */
615 int path
; /* corresponding code entry index */
617 static int regdepslen
= 0;
618 static int regdepstotlen
= 0;
619 static const char *dv_mode
[] = { "RAW", "WAW", "WAR" };
620 static const char *dv_sem
[] = { "none", "implied", "impliedf",
621 "data", "instr", "specific", "stop", "other" };
622 static const char *dv_cmp_type
[] = { "none", "OR", "AND" };
624 /* Current state of PR mutexation */
625 static struct qpmutex
{
628 } *qp_mutexes
= NULL
; /* QP mutex bitmasks */
629 static int qp_mutexeslen
= 0;
630 static int qp_mutexestotlen
= 0;
631 static valueT qp_safe_across_calls
= 0;
633 /* Current state of PR implications */
634 static struct qp_imply
{
637 unsigned p2_branched
:1;
639 } *qp_implies
= NULL
;
640 static int qp_implieslen
= 0;
641 static int qp_impliestotlen
= 0;
643 /* Keep track of static GR values so that indirect register usage can
644 sometimes be tracked. */
655 (((1 << (8 * sizeof(gr_values
->path
) - 2)) - 1) << 1) + 1,
661 /* Remember the alignment frag. */
662 static fragS
*align_frag
;
664 /* These are the routines required to output the various types of
667 /* A slot_number is a frag address plus the slot index (0-2). We use the
668 frag address here so that if there is a section switch in the middle of
669 a function, then instructions emitted to a different section are not
670 counted. Since there may be more than one frag for a function, this
671 means we also need to keep track of which frag this address belongs to
672 so we can compute inter-frag distances. This also nicely solves the
673 problem with nops emitted for align directives, which can't easily be
674 counted, but can easily be derived from frag sizes. */
676 typedef struct unw_rec_list
{
678 unsigned long slot_number
;
680 unsigned long next_slot_number
;
681 fragS
*next_slot_frag
;
682 struct unw_rec_list
*next
;
685 #define SLOT_NUM_NOT_SET (unsigned)-1
687 /* Linked list of saved prologue counts. A very poor
688 implementation of a map from label numbers to prologue counts. */
689 typedef struct label_prologue_count
691 struct label_prologue_count
*next
;
692 unsigned long label_number
;
693 unsigned int prologue_count
;
694 } label_prologue_count
;
698 /* Maintain a list of unwind entries for the current function. */
702 /* Any unwind entires that should be attached to the current slot
703 that an insn is being constructed for. */
704 unw_rec_list
*current_entry
;
706 /* These are used to create the unwind table entry for this function. */
708 symbolS
*info
; /* pointer to unwind info */
709 symbolS
*personality_routine
;
711 subsegT saved_text_subseg
;
712 unsigned int force_unwind_entry
: 1; /* force generation of unwind entry? */
714 /* TRUE if processing unwind directives in a prologue region. */
715 unsigned int prologue
: 1;
716 unsigned int prologue_mask
: 4;
717 unsigned int body
: 1;
718 unsigned int insn
: 1;
719 unsigned int prologue_count
; /* number of .prologues seen so far */
720 /* Prologue counts at previous .label_state directives. */
721 struct label_prologue_count
* saved_prologue_counts
;
724 /* The input value is a negated offset from psp, and specifies an address
725 psp - offset. The encoded value is psp + 16 - (4 * offset). Thus we
726 must add 16 and divide by 4 to get the encoded value. */
728 #define ENCODED_PSP_OFFSET(OFFSET) (((OFFSET) + 16) / 4)
730 typedef void (*vbyte_func
) PARAMS ((int, char *, char *));
732 /* Forward declarations: */
733 static void set_section
PARAMS ((char *name
));
734 static unsigned int set_regstack
PARAMS ((unsigned int, unsigned int,
735 unsigned int, unsigned int));
736 static void dot_align (int);
737 static void dot_radix
PARAMS ((int));
738 static void dot_special_section
PARAMS ((int));
739 static void dot_proc
PARAMS ((int));
740 static void dot_fframe
PARAMS ((int));
741 static void dot_vframe
PARAMS ((int));
742 static void dot_vframesp
PARAMS ((int));
743 static void dot_vframepsp
PARAMS ((int));
744 static void dot_save
PARAMS ((int));
745 static void dot_restore
PARAMS ((int));
746 static void dot_restorereg
PARAMS ((int));
747 static void dot_restorereg_p
PARAMS ((int));
748 static void dot_handlerdata
PARAMS ((int));
749 static void dot_unwentry
PARAMS ((int));
750 static void dot_altrp
PARAMS ((int));
751 static void dot_savemem
PARAMS ((int));
752 static void dot_saveg
PARAMS ((int));
753 static void dot_savef
PARAMS ((int));
754 static void dot_saveb
PARAMS ((int));
755 static void dot_savegf
PARAMS ((int));
756 static void dot_spill
PARAMS ((int));
757 static void dot_spillreg
PARAMS ((int));
758 static void dot_spillmem
PARAMS ((int));
759 static void dot_spillreg_p
PARAMS ((int));
760 static void dot_spillmem_p
PARAMS ((int));
761 static void dot_label_state
PARAMS ((int));
762 static void dot_copy_state
PARAMS ((int));
763 static void dot_unwabi
PARAMS ((int));
764 static void dot_personality
PARAMS ((int));
765 static void dot_body
PARAMS ((int));
766 static void dot_prologue
PARAMS ((int));
767 static void dot_endp
PARAMS ((int));
768 static void dot_template
PARAMS ((int));
769 static void dot_regstk
PARAMS ((int));
770 static void dot_rot
PARAMS ((int));
771 static void dot_byteorder
PARAMS ((int));
772 static void dot_psr
PARAMS ((int));
773 static void dot_alias
PARAMS ((int));
774 static void dot_ln
PARAMS ((int));
775 static void cross_section
PARAMS ((int ref
, void (*cons
) PARAMS((int)), int ua
));
776 static void dot_xdata
PARAMS ((int));
777 static void stmt_float_cons
PARAMS ((int));
778 static void stmt_cons_ua
PARAMS ((int));
779 static void dot_xfloat_cons
PARAMS ((int));
780 static void dot_xstringer
PARAMS ((int));
781 static void dot_xdata_ua
PARAMS ((int));
782 static void dot_xfloat_cons_ua
PARAMS ((int));
783 static void print_prmask
PARAMS ((valueT mask
));
784 static void dot_pred_rel
PARAMS ((int));
785 static void dot_reg_val
PARAMS ((int));
786 static void dot_serialize
PARAMS ((int));
787 static void dot_dv_mode
PARAMS ((int));
788 static void dot_entry
PARAMS ((int));
789 static void dot_mem_offset
PARAMS ((int));
790 static void add_unwind_entry
PARAMS((unw_rec_list
*ptr
));
791 static symbolS
*declare_register
PARAMS ((const char *name
, int regnum
));
792 static void declare_register_set
PARAMS ((const char *, int, int));
793 static unsigned int operand_width
PARAMS ((enum ia64_opnd
));
794 static enum operand_match_result operand_match
PARAMS ((const struct ia64_opcode
*idesc
,
797 static int parse_operand
PARAMS ((expressionS
*e
));
798 static struct ia64_opcode
* parse_operands
PARAMS ((struct ia64_opcode
*));
799 static void build_insn
PARAMS ((struct slot
*, bfd_vma
*));
800 static void emit_one_bundle
PARAMS ((void));
801 static void fix_insn
PARAMS ((fixS
*, const struct ia64_operand
*, valueT
));
802 static bfd_reloc_code_real_type ia64_gen_real_reloc_type
PARAMS ((struct symbol
*sym
,
803 bfd_reloc_code_real_type r_type
));
804 static void insn_group_break
PARAMS ((int, int, int));
805 static void mark_resource
PARAMS ((struct ia64_opcode
*, const struct ia64_dependency
*,
806 struct rsrc
*, int depind
, int path
));
807 static void add_qp_mutex
PARAMS((valueT mask
));
808 static void add_qp_imply
PARAMS((int p1
, int p2
));
809 static void clear_qp_branch_flag
PARAMS((valueT mask
));
810 static void clear_qp_mutex
PARAMS((valueT mask
));
811 static void clear_qp_implies
PARAMS((valueT p1_mask
, valueT p2_mask
));
812 static int has_suffix_p
PARAMS((const char *, const char *));
813 static void clear_register_values
PARAMS ((void));
814 static void print_dependency
PARAMS ((const char *action
, int depind
));
815 static void instruction_serialization
PARAMS ((void));
816 static void data_serialization
PARAMS ((void));
817 static void remove_marked_resource
PARAMS ((struct rsrc
*));
818 static int is_conditional_branch
PARAMS ((struct ia64_opcode
*));
819 static int is_taken_branch
PARAMS ((struct ia64_opcode
*));
820 static int is_interruption_or_rfi
PARAMS ((struct ia64_opcode
*));
821 static int depends_on
PARAMS ((int, struct ia64_opcode
*));
822 static int specify_resource
PARAMS ((const struct ia64_dependency
*,
823 struct ia64_opcode
*, int, struct rsrc
[], int, int));
824 static int check_dv
PARAMS((struct ia64_opcode
*idesc
));
825 static void check_dependencies
PARAMS((struct ia64_opcode
*));
826 static void mark_resources
PARAMS((struct ia64_opcode
*));
827 static void update_dependencies
PARAMS((struct ia64_opcode
*));
828 static void note_register_values
PARAMS((struct ia64_opcode
*));
829 static int qp_mutex
PARAMS ((int, int, int));
830 static int resources_match
PARAMS ((struct rsrc
*, struct ia64_opcode
*, int, int, int));
831 static void output_vbyte_mem
PARAMS ((int, char *, char *));
832 static void count_output
PARAMS ((int, char *, char *));
833 static void output_R1_format
PARAMS ((vbyte_func
, unw_record_type
, int));
834 static void output_R2_format
PARAMS ((vbyte_func
, int, int, unsigned long));
835 static void output_R3_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
836 static void output_P1_format
PARAMS ((vbyte_func
, int));
837 static void output_P2_format
PARAMS ((vbyte_func
, int, int));
838 static void output_P3_format
PARAMS ((vbyte_func
, unw_record_type
, int));
839 static void output_P4_format
PARAMS ((vbyte_func
, unsigned char *, unsigned long));
840 static void output_P5_format
PARAMS ((vbyte_func
, int, unsigned long));
841 static void output_P6_format
PARAMS ((vbyte_func
, unw_record_type
, int));
842 static void output_P7_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long, unsigned long));
843 static void output_P8_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
844 static void output_P9_format
PARAMS ((vbyte_func
, int, int));
845 static void output_P10_format
PARAMS ((vbyte_func
, int, int));
846 static void output_B1_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
847 static void output_B2_format
PARAMS ((vbyte_func
, unsigned long, unsigned long));
848 static void output_B3_format
PARAMS ((vbyte_func
, unsigned long, unsigned long));
849 static void output_B4_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
850 static char format_ab_reg
PARAMS ((int, int));
851 static void output_X1_format
PARAMS ((vbyte_func
, unw_record_type
, int, int, unsigned long,
853 static void output_X2_format
PARAMS ((vbyte_func
, int, int, int, int, int, unsigned long));
854 static void output_X3_format
PARAMS ((vbyte_func
, unw_record_type
, int, int, int, unsigned long,
856 static void output_X4_format
PARAMS ((vbyte_func
, int, int, int, int, int, int, unsigned long));
857 static unw_rec_list
*output_endp
PARAMS ((void));
858 static unw_rec_list
*output_prologue
PARAMS ((void));
859 static unw_rec_list
*output_prologue_gr
PARAMS ((unsigned int, unsigned int));
860 static unw_rec_list
*output_body
PARAMS ((void));
861 static unw_rec_list
*output_mem_stack_f
PARAMS ((unsigned int));
862 static unw_rec_list
*output_mem_stack_v
PARAMS ((void));
863 static unw_rec_list
*output_psp_gr
PARAMS ((unsigned int));
864 static unw_rec_list
*output_psp_sprel
PARAMS ((unsigned int));
865 static unw_rec_list
*output_rp_when
PARAMS ((void));
866 static unw_rec_list
*output_rp_gr
PARAMS ((unsigned int));
867 static unw_rec_list
*output_rp_br
PARAMS ((unsigned int));
868 static unw_rec_list
*output_rp_psprel
PARAMS ((unsigned int));
869 static unw_rec_list
*output_rp_sprel
PARAMS ((unsigned int));
870 static unw_rec_list
*output_pfs_when
PARAMS ((void));
871 static unw_rec_list
*output_pfs_gr
PARAMS ((unsigned int));
872 static unw_rec_list
*output_pfs_psprel
PARAMS ((unsigned int));
873 static unw_rec_list
*output_pfs_sprel
PARAMS ((unsigned int));
874 static unw_rec_list
*output_preds_when
PARAMS ((void));
875 static unw_rec_list
*output_preds_gr
PARAMS ((unsigned int));
876 static unw_rec_list
*output_preds_psprel
PARAMS ((unsigned int));
877 static unw_rec_list
*output_preds_sprel
PARAMS ((unsigned int));
878 static unw_rec_list
*output_fr_mem
PARAMS ((unsigned int));
879 static unw_rec_list
*output_frgr_mem
PARAMS ((unsigned int, unsigned int));
880 static unw_rec_list
*output_gr_gr
PARAMS ((unsigned int, unsigned int));
881 static unw_rec_list
*output_gr_mem
PARAMS ((unsigned int));
882 static unw_rec_list
*output_br_mem
PARAMS ((unsigned int));
883 static unw_rec_list
*output_br_gr
PARAMS ((unsigned int, unsigned int));
884 static unw_rec_list
*output_spill_base
PARAMS ((unsigned int));
885 static unw_rec_list
*output_unat_when
PARAMS ((void));
886 static unw_rec_list
*output_unat_gr
PARAMS ((unsigned int));
887 static unw_rec_list
*output_unat_psprel
PARAMS ((unsigned int));
888 static unw_rec_list
*output_unat_sprel
PARAMS ((unsigned int));
889 static unw_rec_list
*output_lc_when
PARAMS ((void));
890 static unw_rec_list
*output_lc_gr
PARAMS ((unsigned int));
891 static unw_rec_list
*output_lc_psprel
PARAMS ((unsigned int));
892 static unw_rec_list
*output_lc_sprel
PARAMS ((unsigned int));
893 static unw_rec_list
*output_fpsr_when
PARAMS ((void));
894 static unw_rec_list
*output_fpsr_gr
PARAMS ((unsigned int));
895 static unw_rec_list
*output_fpsr_psprel
PARAMS ((unsigned int));
896 static unw_rec_list
*output_fpsr_sprel
PARAMS ((unsigned int));
897 static unw_rec_list
*output_priunat_when_gr
PARAMS ((void));
898 static unw_rec_list
*output_priunat_when_mem
PARAMS ((void));
899 static unw_rec_list
*output_priunat_gr
PARAMS ((unsigned int));
900 static unw_rec_list
*output_priunat_psprel
PARAMS ((unsigned int));
901 static unw_rec_list
*output_priunat_sprel
PARAMS ((unsigned int));
902 static unw_rec_list
*output_bsp_when
PARAMS ((void));
903 static unw_rec_list
*output_bsp_gr
PARAMS ((unsigned int));
904 static unw_rec_list
*output_bsp_psprel
PARAMS ((unsigned int));
905 static unw_rec_list
*output_bsp_sprel
PARAMS ((unsigned int));
906 static unw_rec_list
*output_bspstore_when
PARAMS ((void));
907 static unw_rec_list
*output_bspstore_gr
PARAMS ((unsigned int));
908 static unw_rec_list
*output_bspstore_psprel
PARAMS ((unsigned int));
909 static unw_rec_list
*output_bspstore_sprel
PARAMS ((unsigned int));
910 static unw_rec_list
*output_rnat_when
PARAMS ((void));
911 static unw_rec_list
*output_rnat_gr
PARAMS ((unsigned int));
912 static unw_rec_list
*output_rnat_psprel
PARAMS ((unsigned int));
913 static unw_rec_list
*output_rnat_sprel
PARAMS ((unsigned int));
914 static unw_rec_list
*output_unwabi
PARAMS ((unsigned long, unsigned long));
915 static unw_rec_list
*output_epilogue
PARAMS ((unsigned long));
916 static unw_rec_list
*output_label_state
PARAMS ((unsigned long));
917 static unw_rec_list
*output_copy_state
PARAMS ((unsigned long));
918 static unw_rec_list
*output_spill_psprel
PARAMS ((unsigned int, unsigned int, unsigned int));
919 static unw_rec_list
*output_spill_sprel
PARAMS ((unsigned int, unsigned int, unsigned int));
920 static unw_rec_list
*output_spill_psprel_p
PARAMS ((unsigned int, unsigned int, unsigned int,
922 static unw_rec_list
*output_spill_sprel_p
PARAMS ((unsigned int, unsigned int, unsigned int,
924 static unw_rec_list
*output_spill_reg
PARAMS ((unsigned int, unsigned int, unsigned int,
926 static unw_rec_list
*output_spill_reg_p
PARAMS ((unsigned int, unsigned int, unsigned int,
927 unsigned int, unsigned int));
928 static void process_one_record
PARAMS ((unw_rec_list
*, vbyte_func
));
929 static void process_unw_records
PARAMS ((unw_rec_list
*, vbyte_func
));
930 static int calc_record_size
PARAMS ((unw_rec_list
*));
931 static void set_imask
PARAMS ((unw_rec_list
*, unsigned long, unsigned long, unsigned int));
932 static unsigned long slot_index
PARAMS ((unsigned long, fragS
*,
933 unsigned long, fragS
*,
935 static unw_rec_list
*optimize_unw_records
PARAMS ((unw_rec_list
*));
936 static void fixup_unw_records
PARAMS ((unw_rec_list
*, int));
937 static int convert_expr_to_ab_reg
PARAMS ((expressionS
*, unsigned int *, unsigned int *));
938 static int convert_expr_to_xy_reg
PARAMS ((expressionS
*, unsigned int *, unsigned int *));
939 static unsigned int get_saved_prologue_count
PARAMS ((unsigned long));
940 static void save_prologue_count
PARAMS ((unsigned long, unsigned int));
941 static void free_saved_prologue_counts
PARAMS ((void));
943 /* Determine if application register REGNUM resides only in the integer
944 unit (as opposed to the memory unit). */
946 ar_is_only_in_integer_unit (int reg
)
949 return reg
>= 64 && reg
<= 111;
952 /* Determine if application register REGNUM resides only in the memory
953 unit (as opposed to the integer unit). */
955 ar_is_only_in_memory_unit (int reg
)
958 return reg
>= 0 && reg
<= 47;
961 /* Switch to section NAME and create section if necessary. It's
962 rather ugly that we have to manipulate input_line_pointer but I
963 don't see any other way to accomplish the same thing without
964 changing obj-elf.c (which may be the Right Thing, in the end). */
969 char *saved_input_line_pointer
;
971 saved_input_line_pointer
= input_line_pointer
;
972 input_line_pointer
= name
;
974 input_line_pointer
= saved_input_line_pointer
;
977 /* Map 's' to SHF_IA_64_SHORT. */
980 ia64_elf_section_letter (letter
, ptr_msg
)
985 return SHF_IA_64_SHORT
;
986 else if (letter
== 'o')
987 return SHF_LINK_ORDER
;
989 *ptr_msg
= _("Bad .section directive: want a,o,s,w,x,M,S,G,T in string");
993 /* Map SHF_IA_64_SHORT to SEC_SMALL_DATA. */
996 ia64_elf_section_flags (flags
, attr
, type
)
998 int attr
, type ATTRIBUTE_UNUSED
;
1000 if (attr
& SHF_IA_64_SHORT
)
1001 flags
|= SEC_SMALL_DATA
;
1006 ia64_elf_section_type (str
, len
)
1010 #define STREQ(s) ((len == sizeof (s) - 1) && (strncmp (str, s, sizeof (s) - 1) == 0))
1012 if (STREQ (ELF_STRING_ia64_unwind_info
))
1013 return SHT_PROGBITS
;
1015 if (STREQ (ELF_STRING_ia64_unwind_info_once
))
1016 return SHT_PROGBITS
;
1018 if (STREQ (ELF_STRING_ia64_unwind
))
1019 return SHT_IA_64_UNWIND
;
1021 if (STREQ (ELF_STRING_ia64_unwind_once
))
1022 return SHT_IA_64_UNWIND
;
1024 if (STREQ ("unwind"))
1025 return SHT_IA_64_UNWIND
;
1032 set_regstack (ins
, locs
, outs
, rots
)
1033 unsigned int ins
, locs
, outs
, rots
;
1035 /* Size of frame. */
1038 sof
= ins
+ locs
+ outs
;
1041 as_bad ("Size of frame exceeds maximum of 96 registers");
1046 as_warn ("Size of rotating registers exceeds frame size");
1049 md
.in
.base
= REG_GR
+ 32;
1050 md
.loc
.base
= md
.in
.base
+ ins
;
1051 md
.out
.base
= md
.loc
.base
+ locs
;
1053 md
.in
.num_regs
= ins
;
1054 md
.loc
.num_regs
= locs
;
1055 md
.out
.num_regs
= outs
;
1056 md
.rot
.num_regs
= rots
;
1063 struct label_fix
*lfix
;
1065 subsegT saved_subseg
;
1068 if (!md
.last_text_seg
)
1071 saved_seg
= now_seg
;
1072 saved_subseg
= now_subseg
;
1074 subseg_set (md
.last_text_seg
, 0);
1076 while (md
.num_slots_in_use
> 0)
1077 emit_one_bundle (); /* force out queued instructions */
1079 /* In case there are labels following the last instruction, resolve
1081 for (lfix
= CURR_SLOT
.label_fixups
; lfix
; lfix
= lfix
->next
)
1083 S_SET_VALUE (lfix
->sym
, frag_now_fix ());
1084 symbol_set_frag (lfix
->sym
, frag_now
);
1086 CURR_SLOT
.label_fixups
= 0;
1087 for (lfix
= CURR_SLOT
.tag_fixups
; lfix
; lfix
= lfix
->next
)
1089 S_SET_VALUE (lfix
->sym
, frag_now_fix ());
1090 symbol_set_frag (lfix
->sym
, frag_now
);
1092 CURR_SLOT
.tag_fixups
= 0;
1094 /* In case there are unwind directives following the last instruction,
1095 resolve those now. We only handle prologue, body, and endp directives
1096 here. Give an error for others. */
1097 for (ptr
= unwind
.current_entry
; ptr
; ptr
= ptr
->next
)
1099 switch (ptr
->r
.type
)
1105 ptr
->slot_number
= (unsigned long) frag_more (0);
1106 ptr
->slot_frag
= frag_now
;
1109 /* Allow any record which doesn't have a "t" field (i.e.,
1110 doesn't relate to a particular instruction). */
1126 as_bad (_("Unwind directive not followed by an instruction."));
1130 unwind
.current_entry
= NULL
;
1132 subseg_set (saved_seg
, saved_subseg
);
1134 if (md
.qp
.X_op
== O_register
)
1135 as_bad ("qualifying predicate not followed by instruction");
1139 ia64_do_align (int nbytes
)
1141 char *saved_input_line_pointer
= input_line_pointer
;
1143 input_line_pointer
= "";
1144 s_align_bytes (nbytes
);
1145 input_line_pointer
= saved_input_line_pointer
;
1149 ia64_cons_align (nbytes
)
1154 char *saved_input_line_pointer
= input_line_pointer
;
1155 input_line_pointer
= "";
1156 s_align_bytes (nbytes
);
1157 input_line_pointer
= saved_input_line_pointer
;
1161 /* Output COUNT bytes to a memory location. */
1162 static char *vbyte_mem_ptr
= NULL
;
1165 output_vbyte_mem (count
, ptr
, comment
)
1168 char *comment ATTRIBUTE_UNUSED
;
1171 if (vbyte_mem_ptr
== NULL
)
1176 for (x
= 0; x
< count
; x
++)
1177 *(vbyte_mem_ptr
++) = ptr
[x
];
1180 /* Count the number of bytes required for records. */
1181 static int vbyte_count
= 0;
1183 count_output (count
, ptr
, comment
)
1185 char *ptr ATTRIBUTE_UNUSED
;
1186 char *comment ATTRIBUTE_UNUSED
;
1188 vbyte_count
+= count
;
1192 output_R1_format (f
, rtype
, rlen
)
1194 unw_record_type rtype
;
1201 output_R3_format (f
, rtype
, rlen
);
1207 else if (rtype
!= prologue
)
1208 as_bad ("record type is not valid");
1210 byte
= UNW_R1
| (r
<< 5) | (rlen
& 0x1f);
1211 (*f
) (1, &byte
, NULL
);
1215 output_R2_format (f
, mask
, grsave
, rlen
)
1222 mask
= (mask
& 0x0f);
1223 grsave
= (grsave
& 0x7f);
1225 bytes
[0] = (UNW_R2
| (mask
>> 1));
1226 bytes
[1] = (((mask
& 0x01) << 7) | grsave
);
1227 count
+= output_leb128 (bytes
+ 2, rlen
, 0);
1228 (*f
) (count
, bytes
, NULL
);
1232 output_R3_format (f
, rtype
, rlen
)
1234 unw_record_type rtype
;
1241 output_R1_format (f
, rtype
, rlen
);
1247 else if (rtype
!= prologue
)
1248 as_bad ("record type is not valid");
1249 bytes
[0] = (UNW_R3
| r
);
1250 count
= output_leb128 (bytes
+ 1, rlen
, 0);
1251 (*f
) (count
+ 1, bytes
, NULL
);
1255 output_P1_format (f
, brmask
)
1260 byte
= UNW_P1
| (brmask
& 0x1f);
1261 (*f
) (1, &byte
, NULL
);
1265 output_P2_format (f
, brmask
, gr
)
1271 brmask
= (brmask
& 0x1f);
1272 bytes
[0] = UNW_P2
| (brmask
>> 1);
1273 bytes
[1] = (((brmask
& 1) << 7) | gr
);
1274 (*f
) (2, bytes
, NULL
);
1278 output_P3_format (f
, rtype
, reg
)
1280 unw_record_type rtype
;
1325 as_bad ("Invalid record type for P3 format.");
1327 bytes
[0] = (UNW_P3
| (r
>> 1));
1328 bytes
[1] = (((r
& 1) << 7) | reg
);
1329 (*f
) (2, bytes
, NULL
);
1333 output_P4_format (f
, imask
, imask_size
)
1335 unsigned char *imask
;
1336 unsigned long imask_size
;
1339 (*f
) (imask_size
, (char *) imask
, NULL
);
1343 output_P5_format (f
, grmask
, frmask
)
1346 unsigned long frmask
;
1349 grmask
= (grmask
& 0x0f);
1352 bytes
[1] = ((grmask
<< 4) | ((frmask
& 0x000f0000) >> 16));
1353 bytes
[2] = ((frmask
& 0x0000ff00) >> 8);
1354 bytes
[3] = (frmask
& 0x000000ff);
1355 (*f
) (4, bytes
, NULL
);
1359 output_P6_format (f
, rtype
, rmask
)
1361 unw_record_type rtype
;
1367 if (rtype
== gr_mem
)
1369 else if (rtype
!= fr_mem
)
1370 as_bad ("Invalid record type for format P6");
1371 byte
= (UNW_P6
| (r
<< 4) | (rmask
& 0x0f));
1372 (*f
) (1, &byte
, NULL
);
1376 output_P7_format (f
, rtype
, w1
, w2
)
1378 unw_record_type rtype
;
1385 count
+= output_leb128 (bytes
+ 1, w1
, 0);
1390 count
+= output_leb128 (bytes
+ count
, w2
>> 4, 0);
1440 bytes
[0] = (UNW_P7
| r
);
1441 (*f
) (count
, bytes
, NULL
);
1445 output_P8_format (f
, rtype
, t
)
1447 unw_record_type rtype
;
1486 case bspstore_psprel
:
1489 case bspstore_sprel
:
1501 case priunat_when_gr
:
1504 case priunat_psprel
:
1510 case priunat_when_mem
:
1517 count
+= output_leb128 (bytes
+ 2, t
, 0);
1518 (*f
) (count
, bytes
, NULL
);
1522 output_P9_format (f
, grmask
, gr
)
1529 bytes
[1] = (grmask
& 0x0f);
1530 bytes
[2] = (gr
& 0x7f);
1531 (*f
) (3, bytes
, NULL
);
1535 output_P10_format (f
, abi
, context
)
1542 bytes
[1] = (abi
& 0xff);
1543 bytes
[2] = (context
& 0xff);
1544 (*f
) (3, bytes
, NULL
);
1548 output_B1_format (f
, rtype
, label
)
1550 unw_record_type rtype
;
1551 unsigned long label
;
1557 output_B4_format (f
, rtype
, label
);
1560 if (rtype
== copy_state
)
1562 else if (rtype
!= label_state
)
1563 as_bad ("Invalid record type for format B1");
1565 byte
= (UNW_B1
| (r
<< 5) | (label
& 0x1f));
1566 (*f
) (1, &byte
, NULL
);
1570 output_B2_format (f
, ecount
, t
)
1572 unsigned long ecount
;
1579 output_B3_format (f
, ecount
, t
);
1582 bytes
[0] = (UNW_B2
| (ecount
& 0x1f));
1583 count
+= output_leb128 (bytes
+ 1, t
, 0);
1584 (*f
) (count
, bytes
, NULL
);
1588 output_B3_format (f
, ecount
, t
)
1590 unsigned long ecount
;
1597 output_B2_format (f
, ecount
, t
);
1601 count
+= output_leb128 (bytes
+ 1, t
, 0);
1602 count
+= output_leb128 (bytes
+ count
, ecount
, 0);
1603 (*f
) (count
, bytes
, NULL
);
1607 output_B4_format (f
, rtype
, label
)
1609 unw_record_type rtype
;
1610 unsigned long label
;
1617 output_B1_format (f
, rtype
, label
);
1621 if (rtype
== copy_state
)
1623 else if (rtype
!= label_state
)
1624 as_bad ("Invalid record type for format B1");
1626 bytes
[0] = (UNW_B4
| (r
<< 3));
1627 count
+= output_leb128 (bytes
+ 1, label
, 0);
1628 (*f
) (count
, bytes
, NULL
);
1632 format_ab_reg (ab
, reg
)
1639 ret
= (ab
<< 5) | reg
;
1644 output_X1_format (f
, rtype
, ab
, reg
, t
, w1
)
1646 unw_record_type rtype
;
1656 if (rtype
== spill_sprel
)
1658 else if (rtype
!= spill_psprel
)
1659 as_bad ("Invalid record type for format X1");
1660 bytes
[1] = ((r
<< 7) | format_ab_reg (ab
, reg
));
1661 count
+= output_leb128 (bytes
+ 2, t
, 0);
1662 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1663 (*f
) (count
, bytes
, NULL
);
1667 output_X2_format (f
, ab
, reg
, x
, y
, treg
, t
)
1676 bytes
[1] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1677 bytes
[2] = (((y
& 1) << 7) | (treg
& 0x7f));
1678 count
+= output_leb128 (bytes
+ 3, t
, 0);
1679 (*f
) (count
, bytes
, NULL
);
1683 output_X3_format (f
, rtype
, qp
, ab
, reg
, t
, w1
)
1685 unw_record_type rtype
;
1696 if (rtype
== spill_sprel_p
)
1698 else if (rtype
!= spill_psprel_p
)
1699 as_bad ("Invalid record type for format X3");
1700 bytes
[1] = ((r
<< 7) | (qp
& 0x3f));
1701 bytes
[2] = format_ab_reg (ab
, reg
);
1702 count
+= output_leb128 (bytes
+ 3, t
, 0);
1703 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1704 (*f
) (count
, bytes
, NULL
);
1708 output_X4_format (f
, qp
, ab
, reg
, x
, y
, treg
, t
)
1718 bytes
[1] = (qp
& 0x3f);
1719 bytes
[2] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1720 bytes
[3] = (((y
& 1) << 7) | (treg
& 0x7f));
1721 count
+= output_leb128 (bytes
+ 4, t
, 0);
1722 (*f
) (count
, bytes
, NULL
);
1725 /* This function allocates a record list structure, and initializes fields. */
1727 static unw_rec_list
*
1728 alloc_record (unw_record_type t
)
1731 ptr
= xmalloc (sizeof (*ptr
));
1733 ptr
->slot_number
= SLOT_NUM_NOT_SET
;
1735 ptr
->next_slot_number
= 0;
1736 ptr
->next_slot_frag
= 0;
1740 /* Dummy unwind record used for calculating the length of the last prologue or
1743 static unw_rec_list
*
1746 unw_rec_list
*ptr
= alloc_record (endp
);
1750 static unw_rec_list
*
1753 unw_rec_list
*ptr
= alloc_record (prologue
);
1754 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1758 static unw_rec_list
*
1759 output_prologue_gr (saved_mask
, reg
)
1760 unsigned int saved_mask
;
1763 unw_rec_list
*ptr
= alloc_record (prologue_gr
);
1764 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1765 ptr
->r
.record
.r
.grmask
= saved_mask
;
1766 ptr
->r
.record
.r
.grsave
= reg
;
1770 static unw_rec_list
*
1773 unw_rec_list
*ptr
= alloc_record (body
);
1777 static unw_rec_list
*
1778 output_mem_stack_f (size
)
1781 unw_rec_list
*ptr
= alloc_record (mem_stack_f
);
1782 ptr
->r
.record
.p
.size
= size
;
1786 static unw_rec_list
*
1787 output_mem_stack_v ()
1789 unw_rec_list
*ptr
= alloc_record (mem_stack_v
);
1793 static unw_rec_list
*
1797 unw_rec_list
*ptr
= alloc_record (psp_gr
);
1798 ptr
->r
.record
.p
.gr
= gr
;
1802 static unw_rec_list
*
1803 output_psp_sprel (offset
)
1804 unsigned int offset
;
1806 unw_rec_list
*ptr
= alloc_record (psp_sprel
);
1807 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1811 static unw_rec_list
*
1814 unw_rec_list
*ptr
= alloc_record (rp_when
);
1818 static unw_rec_list
*
1822 unw_rec_list
*ptr
= alloc_record (rp_gr
);
1823 ptr
->r
.record
.p
.gr
= gr
;
1827 static unw_rec_list
*
1831 unw_rec_list
*ptr
= alloc_record (rp_br
);
1832 ptr
->r
.record
.p
.br
= br
;
1836 static unw_rec_list
*
1837 output_rp_psprel (offset
)
1838 unsigned int offset
;
1840 unw_rec_list
*ptr
= alloc_record (rp_psprel
);
1841 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
1845 static unw_rec_list
*
1846 output_rp_sprel (offset
)
1847 unsigned int offset
;
1849 unw_rec_list
*ptr
= alloc_record (rp_sprel
);
1850 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1854 static unw_rec_list
*
1857 unw_rec_list
*ptr
= alloc_record (pfs_when
);
1861 static unw_rec_list
*
1865 unw_rec_list
*ptr
= alloc_record (pfs_gr
);
1866 ptr
->r
.record
.p
.gr
= gr
;
1870 static unw_rec_list
*
1871 output_pfs_psprel (offset
)
1872 unsigned int offset
;
1874 unw_rec_list
*ptr
= alloc_record (pfs_psprel
);
1875 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
1879 static unw_rec_list
*
1880 output_pfs_sprel (offset
)
1881 unsigned int offset
;
1883 unw_rec_list
*ptr
= alloc_record (pfs_sprel
);
1884 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1888 static unw_rec_list
*
1889 output_preds_when ()
1891 unw_rec_list
*ptr
= alloc_record (preds_when
);
1895 static unw_rec_list
*
1896 output_preds_gr (gr
)
1899 unw_rec_list
*ptr
= alloc_record (preds_gr
);
1900 ptr
->r
.record
.p
.gr
= gr
;
1904 static unw_rec_list
*
1905 output_preds_psprel (offset
)
1906 unsigned int offset
;
1908 unw_rec_list
*ptr
= alloc_record (preds_psprel
);
1909 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
1913 static unw_rec_list
*
1914 output_preds_sprel (offset
)
1915 unsigned int offset
;
1917 unw_rec_list
*ptr
= alloc_record (preds_sprel
);
1918 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1922 static unw_rec_list
*
1923 output_fr_mem (mask
)
1926 unw_rec_list
*ptr
= alloc_record (fr_mem
);
1927 ptr
->r
.record
.p
.rmask
= mask
;
1931 static unw_rec_list
*
1932 output_frgr_mem (gr_mask
, fr_mask
)
1933 unsigned int gr_mask
;
1934 unsigned int fr_mask
;
1936 unw_rec_list
*ptr
= alloc_record (frgr_mem
);
1937 ptr
->r
.record
.p
.grmask
= gr_mask
;
1938 ptr
->r
.record
.p
.frmask
= fr_mask
;
1942 static unw_rec_list
*
1943 output_gr_gr (mask
, reg
)
1947 unw_rec_list
*ptr
= alloc_record (gr_gr
);
1948 ptr
->r
.record
.p
.grmask
= mask
;
1949 ptr
->r
.record
.p
.gr
= reg
;
1953 static unw_rec_list
*
1954 output_gr_mem (mask
)
1957 unw_rec_list
*ptr
= alloc_record (gr_mem
);
1958 ptr
->r
.record
.p
.rmask
= mask
;
1962 static unw_rec_list
*
1963 output_br_mem (unsigned int mask
)
1965 unw_rec_list
*ptr
= alloc_record (br_mem
);
1966 ptr
->r
.record
.p
.brmask
= mask
;
1970 static unw_rec_list
*
1971 output_br_gr (save_mask
, reg
)
1972 unsigned int save_mask
;
1975 unw_rec_list
*ptr
= alloc_record (br_gr
);
1976 ptr
->r
.record
.p
.brmask
= save_mask
;
1977 ptr
->r
.record
.p
.gr
= reg
;
1981 static unw_rec_list
*
1982 output_spill_base (offset
)
1983 unsigned int offset
;
1985 unw_rec_list
*ptr
= alloc_record (spill_base
);
1986 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
1990 static unw_rec_list
*
1993 unw_rec_list
*ptr
= alloc_record (unat_when
);
1997 static unw_rec_list
*
2001 unw_rec_list
*ptr
= alloc_record (unat_gr
);
2002 ptr
->r
.record
.p
.gr
= gr
;
2006 static unw_rec_list
*
2007 output_unat_psprel (offset
)
2008 unsigned int offset
;
2010 unw_rec_list
*ptr
= alloc_record (unat_psprel
);
2011 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2015 static unw_rec_list
*
2016 output_unat_sprel (offset
)
2017 unsigned int offset
;
2019 unw_rec_list
*ptr
= alloc_record (unat_sprel
);
2020 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2024 static unw_rec_list
*
2027 unw_rec_list
*ptr
= alloc_record (lc_when
);
2031 static unw_rec_list
*
2035 unw_rec_list
*ptr
= alloc_record (lc_gr
);
2036 ptr
->r
.record
.p
.gr
= gr
;
2040 static unw_rec_list
*
2041 output_lc_psprel (offset
)
2042 unsigned int offset
;
2044 unw_rec_list
*ptr
= alloc_record (lc_psprel
);
2045 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2049 static unw_rec_list
*
2050 output_lc_sprel (offset
)
2051 unsigned int offset
;
2053 unw_rec_list
*ptr
= alloc_record (lc_sprel
);
2054 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2058 static unw_rec_list
*
2061 unw_rec_list
*ptr
= alloc_record (fpsr_when
);
2065 static unw_rec_list
*
2069 unw_rec_list
*ptr
= alloc_record (fpsr_gr
);
2070 ptr
->r
.record
.p
.gr
= gr
;
2074 static unw_rec_list
*
2075 output_fpsr_psprel (offset
)
2076 unsigned int offset
;
2078 unw_rec_list
*ptr
= alloc_record (fpsr_psprel
);
2079 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2083 static unw_rec_list
*
2084 output_fpsr_sprel (offset
)
2085 unsigned int offset
;
2087 unw_rec_list
*ptr
= alloc_record (fpsr_sprel
);
2088 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2092 static unw_rec_list
*
2093 output_priunat_when_gr ()
2095 unw_rec_list
*ptr
= alloc_record (priunat_when_gr
);
2099 static unw_rec_list
*
2100 output_priunat_when_mem ()
2102 unw_rec_list
*ptr
= alloc_record (priunat_when_mem
);
2106 static unw_rec_list
*
2107 output_priunat_gr (gr
)
2110 unw_rec_list
*ptr
= alloc_record (priunat_gr
);
2111 ptr
->r
.record
.p
.gr
= gr
;
2115 static unw_rec_list
*
2116 output_priunat_psprel (offset
)
2117 unsigned int offset
;
2119 unw_rec_list
*ptr
= alloc_record (priunat_psprel
);
2120 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2124 static unw_rec_list
*
2125 output_priunat_sprel (offset
)
2126 unsigned int offset
;
2128 unw_rec_list
*ptr
= alloc_record (priunat_sprel
);
2129 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2133 static unw_rec_list
*
2136 unw_rec_list
*ptr
= alloc_record (bsp_when
);
2140 static unw_rec_list
*
2144 unw_rec_list
*ptr
= alloc_record (bsp_gr
);
2145 ptr
->r
.record
.p
.gr
= gr
;
2149 static unw_rec_list
*
2150 output_bsp_psprel (offset
)
2151 unsigned int offset
;
2153 unw_rec_list
*ptr
= alloc_record (bsp_psprel
);
2154 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2158 static unw_rec_list
*
2159 output_bsp_sprel (offset
)
2160 unsigned int offset
;
2162 unw_rec_list
*ptr
= alloc_record (bsp_sprel
);
2163 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2167 static unw_rec_list
*
2168 output_bspstore_when ()
2170 unw_rec_list
*ptr
= alloc_record (bspstore_when
);
2174 static unw_rec_list
*
2175 output_bspstore_gr (gr
)
2178 unw_rec_list
*ptr
= alloc_record (bspstore_gr
);
2179 ptr
->r
.record
.p
.gr
= gr
;
2183 static unw_rec_list
*
2184 output_bspstore_psprel (offset
)
2185 unsigned int offset
;
2187 unw_rec_list
*ptr
= alloc_record (bspstore_psprel
);
2188 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2192 static unw_rec_list
*
2193 output_bspstore_sprel (offset
)
2194 unsigned int offset
;
2196 unw_rec_list
*ptr
= alloc_record (bspstore_sprel
);
2197 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2201 static unw_rec_list
*
2204 unw_rec_list
*ptr
= alloc_record (rnat_when
);
2208 static unw_rec_list
*
2212 unw_rec_list
*ptr
= alloc_record (rnat_gr
);
2213 ptr
->r
.record
.p
.gr
= gr
;
2217 static unw_rec_list
*
2218 output_rnat_psprel (offset
)
2219 unsigned int offset
;
2221 unw_rec_list
*ptr
= alloc_record (rnat_psprel
);
2222 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2226 static unw_rec_list
*
2227 output_rnat_sprel (offset
)
2228 unsigned int offset
;
2230 unw_rec_list
*ptr
= alloc_record (rnat_sprel
);
2231 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2235 static unw_rec_list
*
2236 output_unwabi (abi
, context
)
2238 unsigned long context
;
2240 unw_rec_list
*ptr
= alloc_record (unwabi
);
2241 ptr
->r
.record
.p
.abi
= abi
;
2242 ptr
->r
.record
.p
.context
= context
;
2246 static unw_rec_list
*
2247 output_epilogue (unsigned long ecount
)
2249 unw_rec_list
*ptr
= alloc_record (epilogue
);
2250 ptr
->r
.record
.b
.ecount
= ecount
;
2254 static unw_rec_list
*
2255 output_label_state (unsigned long label
)
2257 unw_rec_list
*ptr
= alloc_record (label_state
);
2258 ptr
->r
.record
.b
.label
= label
;
2262 static unw_rec_list
*
2263 output_copy_state (unsigned long label
)
2265 unw_rec_list
*ptr
= alloc_record (copy_state
);
2266 ptr
->r
.record
.b
.label
= label
;
2270 static unw_rec_list
*
2271 output_spill_psprel (ab
, reg
, offset
)
2274 unsigned int offset
;
2276 unw_rec_list
*ptr
= alloc_record (spill_psprel
);
2277 ptr
->r
.record
.x
.ab
= ab
;
2278 ptr
->r
.record
.x
.reg
= reg
;
2279 ptr
->r
.record
.x
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2283 static unw_rec_list
*
2284 output_spill_sprel (ab
, reg
, offset
)
2287 unsigned int offset
;
2289 unw_rec_list
*ptr
= alloc_record (spill_sprel
);
2290 ptr
->r
.record
.x
.ab
= ab
;
2291 ptr
->r
.record
.x
.reg
= reg
;
2292 ptr
->r
.record
.x
.spoff
= offset
/ 4;
2296 static unw_rec_list
*
2297 output_spill_psprel_p (ab
, reg
, offset
, predicate
)
2300 unsigned int offset
;
2301 unsigned int predicate
;
2303 unw_rec_list
*ptr
= alloc_record (spill_psprel_p
);
2304 ptr
->r
.record
.x
.ab
= ab
;
2305 ptr
->r
.record
.x
.reg
= reg
;
2306 ptr
->r
.record
.x
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2307 ptr
->r
.record
.x
.qp
= predicate
;
2311 static unw_rec_list
*
2312 output_spill_sprel_p (ab
, reg
, offset
, predicate
)
2315 unsigned int offset
;
2316 unsigned int predicate
;
2318 unw_rec_list
*ptr
= alloc_record (spill_sprel_p
);
2319 ptr
->r
.record
.x
.ab
= ab
;
2320 ptr
->r
.record
.x
.reg
= reg
;
2321 ptr
->r
.record
.x
.spoff
= offset
/ 4;
2322 ptr
->r
.record
.x
.qp
= predicate
;
2326 static unw_rec_list
*
2327 output_spill_reg (ab
, reg
, targ_reg
, xy
)
2330 unsigned int targ_reg
;
2333 unw_rec_list
*ptr
= alloc_record (spill_reg
);
2334 ptr
->r
.record
.x
.ab
= ab
;
2335 ptr
->r
.record
.x
.reg
= reg
;
2336 ptr
->r
.record
.x
.treg
= targ_reg
;
2337 ptr
->r
.record
.x
.xy
= xy
;
2341 static unw_rec_list
*
2342 output_spill_reg_p (ab
, reg
, targ_reg
, xy
, predicate
)
2345 unsigned int targ_reg
;
2347 unsigned int predicate
;
2349 unw_rec_list
*ptr
= alloc_record (spill_reg_p
);
2350 ptr
->r
.record
.x
.ab
= ab
;
2351 ptr
->r
.record
.x
.reg
= reg
;
2352 ptr
->r
.record
.x
.treg
= targ_reg
;
2353 ptr
->r
.record
.x
.xy
= xy
;
2354 ptr
->r
.record
.x
.qp
= predicate
;
2358 /* Given a unw_rec_list process the correct format with the
2359 specified function. */
2362 process_one_record (ptr
, f
)
2366 unsigned long fr_mask
, gr_mask
;
2368 switch (ptr
->r
.type
)
2370 /* This is a dummy record that takes up no space in the output. */
2378 /* These are taken care of by prologue/prologue_gr. */
2383 if (ptr
->r
.type
== prologue_gr
)
2384 output_R2_format (f
, ptr
->r
.record
.r
.grmask
,
2385 ptr
->r
.record
.r
.grsave
, ptr
->r
.record
.r
.rlen
);
2387 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2389 /* Output descriptor(s) for union of register spills (if any). */
2390 gr_mask
= ptr
->r
.record
.r
.mask
.gr_mem
;
2391 fr_mask
= ptr
->r
.record
.r
.mask
.fr_mem
;
2394 if ((fr_mask
& ~0xfUL
) == 0)
2395 output_P6_format (f
, fr_mem
, fr_mask
);
2398 output_P5_format (f
, gr_mask
, fr_mask
);
2403 output_P6_format (f
, gr_mem
, gr_mask
);
2404 if (ptr
->r
.record
.r
.mask
.br_mem
)
2405 output_P1_format (f
, ptr
->r
.record
.r
.mask
.br_mem
);
2407 /* output imask descriptor if necessary: */
2408 if (ptr
->r
.record
.r
.mask
.i
)
2409 output_P4_format (f
, ptr
->r
.record
.r
.mask
.i
,
2410 ptr
->r
.record
.r
.imask_size
);
2414 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2418 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
,
2419 ptr
->r
.record
.p
.size
);
2432 output_P3_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.gr
);
2435 output_P3_format (f
, rp_br
, ptr
->r
.record
.p
.br
);
2438 output_P7_format (f
, psp_sprel
, ptr
->r
.record
.p
.spoff
, 0);
2446 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
, 0);
2455 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.pspoff
, 0);
2465 case bspstore_sprel
:
2467 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.spoff
);
2470 output_P9_format (f
, ptr
->r
.record
.p
.grmask
, ptr
->r
.record
.p
.gr
);
2473 output_P2_format (f
, ptr
->r
.record
.p
.brmask
, ptr
->r
.record
.p
.gr
);
2476 as_bad ("spill_mask record unimplemented.");
2478 case priunat_when_gr
:
2479 case priunat_when_mem
:
2483 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
);
2485 case priunat_psprel
:
2487 case bspstore_psprel
:
2489 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.pspoff
);
2492 output_P10_format (f
, ptr
->r
.record
.p
.abi
, ptr
->r
.record
.p
.context
);
2495 output_B3_format (f
, ptr
->r
.record
.b
.ecount
, ptr
->r
.record
.b
.t
);
2499 output_B4_format (f
, ptr
->r
.type
, ptr
->r
.record
.b
.label
);
2502 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2503 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2504 ptr
->r
.record
.x
.pspoff
);
2507 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2508 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2509 ptr
->r
.record
.x
.spoff
);
2512 output_X2_format (f
, ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2513 ptr
->r
.record
.x
.xy
>> 1, ptr
->r
.record
.x
.xy
,
2514 ptr
->r
.record
.x
.treg
, ptr
->r
.record
.x
.t
);
2516 case spill_psprel_p
:
2517 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2518 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2519 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.pspoff
);
2522 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2523 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2524 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.spoff
);
2527 output_X4_format (f
, ptr
->r
.record
.x
.qp
, ptr
->r
.record
.x
.ab
,
2528 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.xy
>> 1,
2529 ptr
->r
.record
.x
.xy
, ptr
->r
.record
.x
.treg
,
2533 as_bad ("record_type_not_valid");
2538 /* Given a unw_rec_list list, process all the records with
2539 the specified function. */
2541 process_unw_records (list
, f
)
2546 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2547 process_one_record (ptr
, f
);
2550 /* Determine the size of a record list in bytes. */
2552 calc_record_size (list
)
2556 process_unw_records (list
, count_output
);
2560 /* Update IMASK bitmask to reflect the fact that one or more registers
2561 of type TYPE are saved starting at instruction with index T. If N
2562 bits are set in REGMASK, it is assumed that instructions T through
2563 T+N-1 save these registers.
2567 1: instruction saves next fp reg
2568 2: instruction saves next general reg
2569 3: instruction saves next branch reg */
2571 set_imask (region
, regmask
, t
, type
)
2572 unw_rec_list
*region
;
2573 unsigned long regmask
;
2577 unsigned char *imask
;
2578 unsigned long imask_size
;
2582 imask
= region
->r
.record
.r
.mask
.i
;
2583 imask_size
= region
->r
.record
.r
.imask_size
;
2586 imask_size
= (region
->r
.record
.r
.rlen
* 2 + 7) / 8 + 1;
2587 imask
= xmalloc (imask_size
);
2588 memset (imask
, 0, imask_size
);
2590 region
->r
.record
.r
.imask_size
= imask_size
;
2591 region
->r
.record
.r
.mask
.i
= imask
;
2595 pos
= 2 * (3 - t
% 4);
2598 if (i
>= imask_size
)
2600 as_bad ("Ignoring attempt to spill beyond end of region");
2604 imask
[i
] |= (type
& 0x3) << pos
;
2606 regmask
&= (regmask
- 1);
2616 /* Return the number of instruction slots from FIRST_ADDR to SLOT_ADDR.
2617 SLOT_FRAG is the frag containing SLOT_ADDR, and FIRST_FRAG is the frag
2618 containing FIRST_ADDR. If BEFORE_RELAX, then we use worst-case estimates
2622 slot_index (slot_addr
, slot_frag
, first_addr
, first_frag
, before_relax
)
2623 unsigned long slot_addr
;
2625 unsigned long first_addr
;
2629 unsigned long index
= 0;
2631 /* First time we are called, the initial address and frag are invalid. */
2632 if (first_addr
== 0)
2635 /* If the two addresses are in different frags, then we need to add in
2636 the remaining size of this frag, and then the entire size of intermediate
2638 while (slot_frag
!= first_frag
)
2640 unsigned long start_addr
= (unsigned long) &first_frag
->fr_literal
;
2644 /* We can get the final addresses only during and after
2646 if (first_frag
->fr_next
&& first_frag
->fr_next
->fr_address
)
2647 index
+= 3 * ((first_frag
->fr_next
->fr_address
2648 - first_frag
->fr_address
2649 - first_frag
->fr_fix
) >> 4);
2652 /* We don't know what the final addresses will be. We try our
2653 best to estimate. */
2654 switch (first_frag
->fr_type
)
2660 as_fatal ("only constant space allocation is supported");
2666 /* Take alignment into account. Assume the worst case
2667 before relaxation. */
2668 index
+= 3 * ((1 << first_frag
->fr_offset
) >> 4);
2672 if (first_frag
->fr_symbol
)
2674 as_fatal ("only constant offsets are supported");
2678 index
+= 3 * (first_frag
->fr_offset
>> 4);
2682 /* Add in the full size of the frag converted to instruction slots. */
2683 index
+= 3 * (first_frag
->fr_fix
>> 4);
2684 /* Subtract away the initial part before first_addr. */
2685 index
-= (3 * ((first_addr
>> 4) - (start_addr
>> 4))
2686 + ((first_addr
& 0x3) - (start_addr
& 0x3)));
2688 /* Move to the beginning of the next frag. */
2689 first_frag
= first_frag
->fr_next
;
2690 first_addr
= (unsigned long) &first_frag
->fr_literal
;
2693 /* Add in the used part of the last frag. */
2694 index
+= (3 * ((slot_addr
>> 4) - (first_addr
>> 4))
2695 + ((slot_addr
& 0x3) - (first_addr
& 0x3)));
2699 /* Optimize unwind record directives. */
2701 static unw_rec_list
*
2702 optimize_unw_records (list
)
2708 /* If the only unwind record is ".prologue" or ".prologue" followed
2709 by ".body", then we can optimize the unwind directives away. */
2710 if (list
->r
.type
== prologue
2711 && (list
->next
->r
.type
== endp
2712 || (list
->next
->r
.type
== body
&& list
->next
->next
->r
.type
== endp
)))
2718 /* Given a complete record list, process any records which have
2719 unresolved fields, (ie length counts for a prologue). After
2720 this has been run, all necessary information should be available
2721 within each record to generate an image. */
2724 fixup_unw_records (list
, before_relax
)
2728 unw_rec_list
*ptr
, *region
= 0;
2729 unsigned long first_addr
= 0, rlen
= 0, t
;
2730 fragS
*first_frag
= 0;
2732 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2734 if (ptr
->slot_number
== SLOT_NUM_NOT_SET
)
2735 as_bad (" Insn slot not set in unwind record.");
2736 t
= slot_index (ptr
->slot_number
, ptr
->slot_frag
,
2737 first_addr
, first_frag
, before_relax
);
2738 switch (ptr
->r
.type
)
2746 unsigned long last_addr
= 0;
2747 fragS
*last_frag
= NULL
;
2749 first_addr
= ptr
->slot_number
;
2750 first_frag
= ptr
->slot_frag
;
2751 /* Find either the next body/prologue start, or the end of
2752 the function, and determine the size of the region. */
2753 for (last
= ptr
->next
; last
!= NULL
; last
= last
->next
)
2754 if (last
->r
.type
== prologue
|| last
->r
.type
== prologue_gr
2755 || last
->r
.type
== body
|| last
->r
.type
== endp
)
2757 last_addr
= last
->slot_number
;
2758 last_frag
= last
->slot_frag
;
2761 size
= slot_index (last_addr
, last_frag
, first_addr
, first_frag
,
2763 rlen
= ptr
->r
.record
.r
.rlen
= size
;
2764 if (ptr
->r
.type
== body
)
2765 /* End of region. */
2773 ptr
->r
.record
.b
.t
= rlen
- 1 - t
;
2775 /* This happens when a memory-stack-less procedure uses a
2776 ".restore sp" directive at the end of a region to pop
2778 ptr
->r
.record
.b
.t
= 0;
2789 case priunat_when_gr
:
2790 case priunat_when_mem
:
2794 ptr
->r
.record
.p
.t
= t
;
2802 case spill_psprel_p
:
2803 ptr
->r
.record
.x
.t
= t
;
2809 as_bad ("frgr_mem record before region record!");
2812 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.frmask
;
2813 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.grmask
;
2814 set_imask (region
, ptr
->r
.record
.p
.frmask
, t
, 1);
2815 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2820 as_bad ("fr_mem record before region record!");
2823 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.rmask
;
2824 set_imask (region
, ptr
->r
.record
.p
.rmask
, t
, 1);
2829 as_bad ("gr_mem record before region record!");
2832 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.rmask
;
2833 set_imask (region
, ptr
->r
.record
.p
.rmask
, t
, 2);
2838 as_bad ("br_mem record before region record!");
2841 region
->r
.record
.r
.mask
.br_mem
|= ptr
->r
.record
.p
.brmask
;
2842 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2848 as_bad ("gr_gr record before region record!");
2851 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2856 as_bad ("br_gr record before region record!");
2859 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2868 /* Estimate the size of a frag before relaxing. We only have one type of frag
2869 to handle here, which is the unwind info frag. */
2872 ia64_estimate_size_before_relax (fragS
*frag
,
2873 asection
*segtype ATTRIBUTE_UNUSED
)
2878 /* ??? This code is identical to the first part of ia64_convert_frag. */
2879 list
= (unw_rec_list
*) frag
->fr_opcode
;
2880 fixup_unw_records (list
, 0);
2882 len
= calc_record_size (list
);
2883 /* pad to pointer-size boundary. */
2884 pad
= len
% md
.pointer_size
;
2886 len
+= md
.pointer_size
- pad
;
2887 /* Add 8 for the header. */
2889 /* Add a pointer for the personality offset. */
2890 if (frag
->fr_offset
)
2891 size
+= md
.pointer_size
;
2893 /* fr_var carries the max_chars that we created the fragment with.
2894 We must, of course, have allocated enough memory earlier. */
2895 assert (frag
->fr_var
>= size
);
2897 return frag
->fr_fix
+ size
;
2900 /* This function converts a rs_machine_dependent variant frag into a
2901 normal fill frag with the unwind image from the the record list. */
2903 ia64_convert_frag (fragS
*frag
)
2909 /* ??? This code is identical to ia64_estimate_size_before_relax. */
2910 list
= (unw_rec_list
*) frag
->fr_opcode
;
2911 fixup_unw_records (list
, 0);
2913 len
= calc_record_size (list
);
2914 /* pad to pointer-size boundary. */
2915 pad
= len
% md
.pointer_size
;
2917 len
+= md
.pointer_size
- pad
;
2918 /* Add 8 for the header. */
2920 /* Add a pointer for the personality offset. */
2921 if (frag
->fr_offset
)
2922 size
+= md
.pointer_size
;
2924 /* fr_var carries the max_chars that we created the fragment with.
2925 We must, of course, have allocated enough memory earlier. */
2926 assert (frag
->fr_var
>= size
);
2928 /* Initialize the header area. fr_offset is initialized with
2929 unwind.personality_routine. */
2930 if (frag
->fr_offset
)
2932 if (md
.flags
& EF_IA_64_ABI64
)
2933 flag_value
= (bfd_vma
) 3 << 32;
2935 /* 32-bit unwind info block. */
2936 flag_value
= (bfd_vma
) 0x1003 << 32;
2941 md_number_to_chars (frag
->fr_literal
,
2942 (((bfd_vma
) 1 << 48) /* Version. */
2943 | flag_value
/* U & E handler flags. */
2944 | (len
/ md
.pointer_size
)), /* Length. */
2947 /* Skip the header. */
2948 vbyte_mem_ptr
= frag
->fr_literal
+ 8;
2949 process_unw_records (list
, output_vbyte_mem
);
2951 /* Fill the padding bytes with zeros. */
2953 md_number_to_chars (frag
->fr_literal
+ len
+ 8 - md
.pointer_size
+ pad
, 0,
2954 md
.pointer_size
- pad
);
2956 frag
->fr_fix
+= size
;
2957 frag
->fr_type
= rs_fill
;
2959 frag
->fr_offset
= 0;
2963 convert_expr_to_ab_reg (e
, ab
, regp
)
2970 if (e
->X_op
!= O_register
)
2973 reg
= e
->X_add_number
;
2974 if (reg
>= (REG_GR
+ 4) && reg
<= (REG_GR
+ 7))
2977 *regp
= reg
- REG_GR
;
2979 else if ((reg
>= (REG_FR
+ 2) && reg
<= (REG_FR
+ 5))
2980 || (reg
>= (REG_FR
+ 16) && reg
<= (REG_FR
+ 31)))
2983 *regp
= reg
- REG_FR
;
2985 else if (reg
>= (REG_BR
+ 1) && reg
<= (REG_BR
+ 5))
2988 *regp
= reg
- REG_BR
;
2995 case REG_PR
: *regp
= 0; break;
2996 case REG_PSP
: *regp
= 1; break;
2997 case REG_PRIUNAT
: *regp
= 2; break;
2998 case REG_BR
+ 0: *regp
= 3; break;
2999 case REG_AR
+ AR_BSP
: *regp
= 4; break;
3000 case REG_AR
+ AR_BSPSTORE
: *regp
= 5; break;
3001 case REG_AR
+ AR_RNAT
: *regp
= 6; break;
3002 case REG_AR
+ AR_UNAT
: *regp
= 7; break;
3003 case REG_AR
+ AR_FPSR
: *regp
= 8; break;
3004 case REG_AR
+ AR_PFS
: *regp
= 9; break;
3005 case REG_AR
+ AR_LC
: *regp
= 10; break;
3015 convert_expr_to_xy_reg (e
, xy
, regp
)
3022 if (e
->X_op
!= O_register
)
3025 reg
= e
->X_add_number
;
3027 if (/* reg >= REG_GR && */ reg
<= (REG_GR
+ 127))
3030 *regp
= reg
- REG_GR
;
3032 else if (reg
>= REG_FR
&& reg
<= (REG_FR
+ 127))
3035 *regp
= reg
- REG_FR
;
3037 else if (reg
>= REG_BR
&& reg
<= (REG_BR
+ 7))
3040 *regp
= reg
- REG_BR
;
3050 /* The current frag is an alignment frag. */
3051 align_frag
= frag_now
;
3052 s_align_bytes (arg
);
3057 int dummy ATTRIBUTE_UNUSED
;
3062 radix
= *input_line_pointer
++;
3064 if (radix
!= 'C' && !is_end_of_line
[(unsigned char) radix
])
3066 as_bad ("Radix `%c' unsupported", *input_line_pointer
);
3067 ignore_rest_of_line ();
3072 /* Helper function for .loc directives. If the assembler is not generating
3073 line number info, then we need to remember which instructions have a .loc
3074 directive, and only call dwarf2_gen_line_info for those instructions. */
3079 CURR_SLOT
.loc_directive_seen
= 1;
3080 dwarf2_directive_loc (x
);
3083 /* .sbss, .bss etc. are macros that expand into ".section SECNAME". */
3085 dot_special_section (which
)
3088 set_section ((char *) special_section_name
[which
]);
3091 /* Return -1 for warning and 0 for error. */
3094 unwind_diagnostic (const char * region
, const char *directive
)
3096 if (md
.unwind_check
== unwind_check_warning
)
3098 as_warn (".%s outside of %s", directive
, region
);
3103 as_bad (".%s outside of %s", directive
, region
);
3104 ignore_rest_of_line ();
3109 /* Return 1 if a directive is in a procedure, -1 if a directive isn't in
3110 a procedure but the unwind directive check is set to warning, 0 if
3111 a directive isn't in a procedure and the unwind directive check is set
3115 in_procedure (const char *directive
)
3117 if (unwind
.proc_start
3118 && (!unwind
.saved_text_seg
|| strcmp (directive
, "endp") == 0))
3120 return unwind_diagnostic ("procedure", directive
);
3123 /* Return 1 if a directive is in a prologue, -1 if a directive isn't in
3124 a prologue but the unwind directive check is set to warning, 0 if
3125 a directive isn't in a prologue and the unwind directive check is set
3129 in_prologue (const char *directive
)
3131 int in
= in_procedure (directive
);
3134 /* We are in a procedure. Check if we are in a prologue. */
3135 if (unwind
.prologue
)
3137 /* We only want to issue one message. */
3139 return unwind_diagnostic ("prologue", directive
);
3146 /* Return 1 if a directive is in a body, -1 if a directive isn't in
3147 a body but the unwind directive check is set to warning, 0 if
3148 a directive isn't in a body and the unwind directive check is set
3152 in_body (const char *directive
)
3154 int in
= in_procedure (directive
);
3157 /* We are in a procedure. Check if we are in a body. */
3160 /* We only want to issue one message. */
3162 return unwind_diagnostic ("body region", directive
);
3170 add_unwind_entry (ptr
)
3174 unwind
.tail
->next
= ptr
;
3179 /* The current entry can in fact be a chain of unwind entries. */
3180 if (unwind
.current_entry
== NULL
)
3181 unwind
.current_entry
= ptr
;
3186 int dummy ATTRIBUTE_UNUSED
;
3190 if (!in_prologue ("fframe"))
3195 if (e
.X_op
!= O_constant
)
3196 as_bad ("Operand to .fframe must be a constant");
3198 add_unwind_entry (output_mem_stack_f (e
.X_add_number
));
3203 int dummy ATTRIBUTE_UNUSED
;
3208 if (!in_prologue ("vframe"))
3212 reg
= e
.X_add_number
- REG_GR
;
3213 if (e
.X_op
== O_register
&& reg
< 128)
3215 add_unwind_entry (output_mem_stack_v ());
3216 if (! (unwind
.prologue_mask
& 2))
3217 add_unwind_entry (output_psp_gr (reg
));
3220 as_bad ("First operand to .vframe must be a general register");
3224 dot_vframesp (dummy
)
3225 int dummy ATTRIBUTE_UNUSED
;
3229 if (!in_prologue ("vframesp"))
3233 if (e
.X_op
== O_constant
)
3235 add_unwind_entry (output_mem_stack_v ());
3236 add_unwind_entry (output_psp_sprel (e
.X_add_number
));
3239 as_bad ("Operand to .vframesp must be a constant (sp-relative offset)");
3243 dot_vframepsp (dummy
)
3244 int dummy ATTRIBUTE_UNUSED
;
3248 if (!in_prologue ("vframepsp"))
3252 if (e
.X_op
== O_constant
)
3254 add_unwind_entry (output_mem_stack_v ());
3255 add_unwind_entry (output_psp_sprel (e
.X_add_number
));
3258 as_bad ("Operand to .vframepsp must be a constant (psp-relative offset)");
3263 int dummy ATTRIBUTE_UNUSED
;
3269 if (!in_prologue ("save"))
3272 sep
= parse_operand (&e1
);
3274 as_bad ("No second operand to .save");
3275 sep
= parse_operand (&e2
);
3277 reg1
= e1
.X_add_number
;
3278 reg2
= e2
.X_add_number
- REG_GR
;
3280 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3281 if (e1
.X_op
== O_register
)
3283 if (e2
.X_op
== O_register
&& reg2
>= 0 && reg2
< 128)
3287 case REG_AR
+ AR_BSP
:
3288 add_unwind_entry (output_bsp_when ());
3289 add_unwind_entry (output_bsp_gr (reg2
));
3291 case REG_AR
+ AR_BSPSTORE
:
3292 add_unwind_entry (output_bspstore_when ());
3293 add_unwind_entry (output_bspstore_gr (reg2
));
3295 case REG_AR
+ AR_RNAT
:
3296 add_unwind_entry (output_rnat_when ());
3297 add_unwind_entry (output_rnat_gr (reg2
));
3299 case REG_AR
+ AR_UNAT
:
3300 add_unwind_entry (output_unat_when ());
3301 add_unwind_entry (output_unat_gr (reg2
));
3303 case REG_AR
+ AR_FPSR
:
3304 add_unwind_entry (output_fpsr_when ());
3305 add_unwind_entry (output_fpsr_gr (reg2
));
3307 case REG_AR
+ AR_PFS
:
3308 add_unwind_entry (output_pfs_when ());
3309 if (! (unwind
.prologue_mask
& 4))
3310 add_unwind_entry (output_pfs_gr (reg2
));
3312 case REG_AR
+ AR_LC
:
3313 add_unwind_entry (output_lc_when ());
3314 add_unwind_entry (output_lc_gr (reg2
));
3317 add_unwind_entry (output_rp_when ());
3318 if (! (unwind
.prologue_mask
& 8))
3319 add_unwind_entry (output_rp_gr (reg2
));
3322 add_unwind_entry (output_preds_when ());
3323 if (! (unwind
.prologue_mask
& 1))
3324 add_unwind_entry (output_preds_gr (reg2
));
3327 add_unwind_entry (output_priunat_when_gr ());
3328 add_unwind_entry (output_priunat_gr (reg2
));
3331 as_bad ("First operand not a valid register");
3335 as_bad (" Second operand not a valid register");
3338 as_bad ("First operand not a register");
3343 int dummy ATTRIBUTE_UNUSED
;
3346 unsigned long ecount
; /* # of _additional_ regions to pop */
3349 if (!in_body ("restore"))
3352 sep
= parse_operand (&e1
);
3353 if (e1
.X_op
!= O_register
|| e1
.X_add_number
!= REG_GR
+ 12)
3355 as_bad ("First operand to .restore must be stack pointer (sp)");
3361 parse_operand (&e2
);
3362 if (e2
.X_op
!= O_constant
|| e2
.X_add_number
< 0)
3364 as_bad ("Second operand to .restore must be a constant >= 0");
3367 ecount
= e2
.X_add_number
;
3370 ecount
= unwind
.prologue_count
- 1;
3372 if (ecount
>= unwind
.prologue_count
)
3374 as_bad ("Epilogue count of %lu exceeds number of nested prologues (%u)",
3375 ecount
+ 1, unwind
.prologue_count
);
3379 add_unwind_entry (output_epilogue (ecount
));
3381 if (ecount
< unwind
.prologue_count
)
3382 unwind
.prologue_count
-= ecount
+ 1;
3384 unwind
.prologue_count
= 0;
3388 dot_restorereg (dummy
)
3389 int dummy ATTRIBUTE_UNUSED
;
3391 unsigned int ab
, reg
;
3394 if (!in_procedure ("restorereg"))
3399 if (!convert_expr_to_ab_reg (&e
, &ab
, ®
))
3401 as_bad ("First operand to .restorereg must be a preserved register");
3404 add_unwind_entry (output_spill_reg (ab
, reg
, 0, 0));
3408 dot_restorereg_p (dummy
)
3409 int dummy ATTRIBUTE_UNUSED
;
3411 unsigned int qp
, ab
, reg
;
3415 if (!in_procedure ("restorereg.p"))
3418 sep
= parse_operand (&e1
);
3421 as_bad ("No second operand to .restorereg.p");
3425 parse_operand (&e2
);
3427 qp
= e1
.X_add_number
- REG_P
;
3428 if (e1
.X_op
!= O_register
|| qp
> 63)
3430 as_bad ("First operand to .restorereg.p must be a predicate");
3434 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
3436 as_bad ("Second operand to .restorereg.p must be a preserved register");
3439 add_unwind_entry (output_spill_reg_p (ab
, reg
, 0, 0, qp
));
3442 static char *special_linkonce_name
[] =
3444 ".gnu.linkonce.ia64unw.", ".gnu.linkonce.ia64unwi."
3448 start_unwind_section (const segT text_seg
, int sec_index
, int linkonce_empty
)
3451 Use a slightly ugly scheme to derive the unwind section names from
3452 the text section name:
3454 text sect. unwind table sect.
3455 name: name: comments:
3456 ---------- ----------------- --------------------------------
3458 .text.foo .IA_64.unwind.text.foo
3459 .foo .IA_64.unwind.foo
3461 .gnu.linkonce.ia64unw.foo
3462 _info .IA_64.unwind_info gas issues error message (ditto)
3463 _infoFOO .IA_64.unwind_infoFOO gas issues error message (ditto)
3465 This mapping is done so that:
3467 (a) An object file with unwind info only in .text will use
3468 unwind section names .IA_64.unwind and .IA_64.unwind_info.
3469 This follows the letter of the ABI and also ensures backwards
3470 compatibility with older toolchains.
3472 (b) An object file with unwind info in multiple text sections
3473 will use separate unwind sections for each text section.
3474 This allows us to properly set the "sh_info" and "sh_link"
3475 fields in SHT_IA_64_UNWIND as required by the ABI and also
3476 lets GNU ld support programs with multiple segments
3477 containing unwind info (as might be the case for certain
3478 embedded applications).
3480 (c) An error is issued if there would be a name clash.
3483 const char *text_name
, *sec_text_name
;
3485 const char *prefix
= special_section_name
[sec_index
];
3487 size_t prefix_len
, suffix_len
, sec_name_len
;
3489 sec_text_name
= segment_name (text_seg
);
3490 text_name
= sec_text_name
;
3491 if (strncmp (text_name
, "_info", 5) == 0)
3493 as_bad ("Illegal section name `%s' (causes unwind section name clash)",
3495 ignore_rest_of_line ();
3498 if (strcmp (text_name
, ".text") == 0)
3501 /* Build the unwind section name by appending the (possibly stripped)
3502 text section name to the unwind prefix. */
3504 if (strncmp (text_name
, ".gnu.linkonce.t.",
3505 sizeof (".gnu.linkonce.t.") - 1) == 0)
3507 prefix
= special_linkonce_name
[sec_index
- SPECIAL_SECTION_UNWIND
];
3508 suffix
+= sizeof (".gnu.linkonce.t.") - 1;
3510 else if (linkonce_empty
)
3513 prefix_len
= strlen (prefix
);
3514 suffix_len
= strlen (suffix
);
3515 sec_name_len
= prefix_len
+ suffix_len
;
3516 sec_name
= alloca (sec_name_len
+ 1);
3517 memcpy (sec_name
, prefix
, prefix_len
);
3518 memcpy (sec_name
+ prefix_len
, suffix
, suffix_len
);
3519 sec_name
[sec_name_len
] = '\0';
3521 /* Handle COMDAT group. */
3522 if (suffix
== text_name
&& (text_seg
->flags
& SEC_LINK_ONCE
) != 0)
3525 size_t len
, group_name_len
;
3526 const char *group_name
= elf_group_name (text_seg
);
3528 if (group_name
== NULL
)
3530 as_bad ("Group section `%s' has no group signature",
3532 ignore_rest_of_line ();
3535 /* We have to construct a fake section directive. */
3536 group_name_len
= strlen (group_name
);
3538 + 16 /* ,"aG",@progbits, */
3539 + group_name_len
/* ,group_name */
3542 section
= alloca (len
+ 1);
3543 memcpy (section
, sec_name
, sec_name_len
);
3544 memcpy (section
+ sec_name_len
, ",\"aG\",@progbits,", 16);
3545 memcpy (section
+ sec_name_len
+ 16, group_name
, group_name_len
);
3546 memcpy (section
+ len
- 7, ",comdat", 7);
3547 section
[len
] = '\0';
3548 set_section (section
);
3552 set_section (sec_name
);
3553 bfd_set_section_flags (stdoutput
, now_seg
,
3554 SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
);
3557 elf_linked_to_section (now_seg
) = text_seg
;
3561 generate_unwind_image (const segT text_seg
)
3566 /* Mark the end of the unwind info, so that we can compute the size of the
3567 last unwind region. */
3568 add_unwind_entry (output_endp ());
3570 /* Force out pending instructions, to make sure all unwind records have
3571 a valid slot_number field. */
3572 ia64_flush_insns ();
3574 /* Generate the unwind record. */
3575 list
= optimize_unw_records (unwind
.list
);
3576 fixup_unw_records (list
, 1);
3577 size
= calc_record_size (list
);
3579 if (size
> 0 || unwind
.force_unwind_entry
)
3581 unwind
.force_unwind_entry
= 0;
3582 /* pad to pointer-size boundary. */
3583 pad
= size
% md
.pointer_size
;
3585 size
+= md
.pointer_size
- pad
;
3586 /* Add 8 for the header. */
3588 /* Add a pointer for the personality offset. */
3589 if (unwind
.personality_routine
)
3590 size
+= md
.pointer_size
;
3593 /* If there are unwind records, switch sections, and output the info. */
3597 bfd_reloc_code_real_type reloc
;
3599 start_unwind_section (text_seg
, SPECIAL_SECTION_UNWIND_INFO
, 0);
3601 /* Make sure the section has 4 byte alignment for ILP32 and
3602 8 byte alignment for LP64. */
3603 frag_align (md
.pointer_size_shift
, 0, 0);
3604 record_alignment (now_seg
, md
.pointer_size_shift
);
3606 /* Set expression which points to start of unwind descriptor area. */
3607 unwind
.info
= expr_build_dot ();
3609 frag_var (rs_machine_dependent
, size
, size
, 0, 0,
3610 (offsetT
) (long) unwind
.personality_routine
,
3613 /* Add the personality address to the image. */
3614 if (unwind
.personality_routine
!= 0)
3616 exp
.X_op
= O_symbol
;
3617 exp
.X_add_symbol
= unwind
.personality_routine
;
3618 exp
.X_add_number
= 0;
3620 if (md
.flags
& EF_IA_64_BE
)
3622 if (md
.flags
& EF_IA_64_ABI64
)
3623 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64MSB
;
3625 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32MSB
;
3629 if (md
.flags
& EF_IA_64_ABI64
)
3630 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64LSB
;
3632 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32LSB
;
3635 fix_new_exp (frag_now
, frag_now_fix () - md
.pointer_size
,
3636 md
.pointer_size
, &exp
, 0, reloc
);
3637 unwind
.personality_routine
= 0;
3641 start_unwind_section (text_seg
, SPECIAL_SECTION_UNWIND_INFO
, 1);
3643 free_saved_prologue_counts ();
3644 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
3648 dot_handlerdata (dummy
)
3649 int dummy ATTRIBUTE_UNUSED
;
3651 if (!in_procedure ("handlerdata"))
3653 unwind
.force_unwind_entry
= 1;
3655 /* Remember which segment we're in so we can switch back after .endp */
3656 unwind
.saved_text_seg
= now_seg
;
3657 unwind
.saved_text_subseg
= now_subseg
;
3659 /* Generate unwind info into unwind-info section and then leave that
3660 section as the currently active one so dataXX directives go into
3661 the language specific data area of the unwind info block. */
3662 generate_unwind_image (now_seg
);
3663 demand_empty_rest_of_line ();
3667 dot_unwentry (dummy
)
3668 int dummy ATTRIBUTE_UNUSED
;
3670 if (!in_procedure ("unwentry"))
3672 unwind
.force_unwind_entry
= 1;
3673 demand_empty_rest_of_line ();
3678 int dummy ATTRIBUTE_UNUSED
;
3683 if (!in_prologue ("altrp"))
3687 reg
= e
.X_add_number
- REG_BR
;
3688 if (e
.X_op
== O_register
&& reg
< 8)
3689 add_unwind_entry (output_rp_br (reg
));
3691 as_bad ("First operand not a valid branch register");
3695 dot_savemem (psprel
)
3702 if (!in_prologue (psprel
? "savepsp" : "savesp"))
3705 sep
= parse_operand (&e1
);
3707 as_bad ("No second operand to .save%ssp", psprel
? "p" : "");
3708 sep
= parse_operand (&e2
);
3710 reg1
= e1
.X_add_number
;
3711 val
= e2
.X_add_number
;
3713 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3714 if (e1
.X_op
== O_register
)
3716 if (e2
.X_op
== O_constant
)
3720 case REG_AR
+ AR_BSP
:
3721 add_unwind_entry (output_bsp_when ());
3722 add_unwind_entry ((psprel
3724 : output_bsp_sprel
) (val
));
3726 case REG_AR
+ AR_BSPSTORE
:
3727 add_unwind_entry (output_bspstore_when ());
3728 add_unwind_entry ((psprel
3729 ? output_bspstore_psprel
3730 : output_bspstore_sprel
) (val
));
3732 case REG_AR
+ AR_RNAT
:
3733 add_unwind_entry (output_rnat_when ());
3734 add_unwind_entry ((psprel
3735 ? output_rnat_psprel
3736 : output_rnat_sprel
) (val
));
3738 case REG_AR
+ AR_UNAT
:
3739 add_unwind_entry (output_unat_when ());
3740 add_unwind_entry ((psprel
3741 ? output_unat_psprel
3742 : output_unat_sprel
) (val
));
3744 case REG_AR
+ AR_FPSR
:
3745 add_unwind_entry (output_fpsr_when ());
3746 add_unwind_entry ((psprel
3747 ? output_fpsr_psprel
3748 : output_fpsr_sprel
) (val
));
3750 case REG_AR
+ AR_PFS
:
3751 add_unwind_entry (output_pfs_when ());
3752 add_unwind_entry ((psprel
3754 : output_pfs_sprel
) (val
));
3756 case REG_AR
+ AR_LC
:
3757 add_unwind_entry (output_lc_when ());
3758 add_unwind_entry ((psprel
3760 : output_lc_sprel
) (val
));
3763 add_unwind_entry (output_rp_when ());
3764 add_unwind_entry ((psprel
3766 : output_rp_sprel
) (val
));
3769 add_unwind_entry (output_preds_when ());
3770 add_unwind_entry ((psprel
3771 ? output_preds_psprel
3772 : output_preds_sprel
) (val
));
3775 add_unwind_entry (output_priunat_when_mem ());
3776 add_unwind_entry ((psprel
3777 ? output_priunat_psprel
3778 : output_priunat_sprel
) (val
));
3781 as_bad ("First operand not a valid register");
3785 as_bad (" Second operand not a valid constant");
3788 as_bad ("First operand not a register");
3793 int dummy ATTRIBUTE_UNUSED
;
3798 if (!in_prologue ("save.g"))
3801 sep
= parse_operand (&e1
);
3803 parse_operand (&e2
);
3805 if (e1
.X_op
!= O_constant
)
3806 as_bad ("First operand to .save.g must be a constant.");
3809 int grmask
= e1
.X_add_number
;
3811 add_unwind_entry (output_gr_mem (grmask
));
3814 int reg
= e2
.X_add_number
- REG_GR
;
3815 if (e2
.X_op
== O_register
&& reg
>= 0 && reg
< 128)
3816 add_unwind_entry (output_gr_gr (grmask
, reg
));
3818 as_bad ("Second operand is an invalid register.");
3825 int dummy ATTRIBUTE_UNUSED
;
3830 if (!in_prologue ("save.f"))
3833 sep
= parse_operand (&e1
);
3835 if (e1
.X_op
!= O_constant
)
3836 as_bad ("Operand to .save.f must be a constant.");
3838 add_unwind_entry (output_fr_mem (e1
.X_add_number
));
3843 int dummy ATTRIBUTE_UNUSED
;
3850 if (!in_prologue ("save.b"))
3853 sep
= parse_operand (&e1
);
3854 if (e1
.X_op
!= O_constant
)
3856 as_bad ("First operand to .save.b must be a constant.");
3859 brmask
= e1
.X_add_number
;
3863 sep
= parse_operand (&e2
);
3864 reg
= e2
.X_add_number
- REG_GR
;
3865 if (e2
.X_op
!= O_register
|| reg
> 127)
3867 as_bad ("Second operand to .save.b must be a general register.");
3870 add_unwind_entry (output_br_gr (brmask
, e2
.X_add_number
));
3873 add_unwind_entry (output_br_mem (brmask
));
3875 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3876 demand_empty_rest_of_line ();
3881 int dummy ATTRIBUTE_UNUSED
;
3886 if (!in_prologue ("save.gf"))
3889 sep
= parse_operand (&e1
);
3891 parse_operand (&e2
);
3893 if (e1
.X_op
!= O_constant
|| sep
!= ',' || e2
.X_op
!= O_constant
)
3894 as_bad ("Both operands of .save.gf must be constants.");
3897 int grmask
= e1
.X_add_number
;
3898 int frmask
= e2
.X_add_number
;
3899 add_unwind_entry (output_frgr_mem (grmask
, frmask
));
3905 int dummy ATTRIBUTE_UNUSED
;
3910 if (!in_prologue ("spill"))
3913 sep
= parse_operand (&e
);
3914 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3915 demand_empty_rest_of_line ();
3917 if (e
.X_op
!= O_constant
)
3918 as_bad ("Operand to .spill must be a constant");
3920 add_unwind_entry (output_spill_base (e
.X_add_number
));
3924 dot_spillreg (dummy
)
3925 int dummy ATTRIBUTE_UNUSED
;
3928 unsigned int ab
, xy
, reg
, treg
;
3931 if (!in_procedure ("spillreg"))
3934 sep
= parse_operand (&e1
);
3937 as_bad ("No second operand to .spillreg");
3941 parse_operand (&e2
);
3943 if (!convert_expr_to_ab_reg (&e1
, &ab
, ®
))
3945 as_bad ("First operand to .spillreg must be a preserved register");
3949 if (!convert_expr_to_xy_reg (&e2
, &xy
, &treg
))
3951 as_bad ("Second operand to .spillreg must be a register");
3955 add_unwind_entry (output_spill_reg (ab
, reg
, treg
, xy
));
3959 dot_spillmem (psprel
)
3964 unsigned int ab
, reg
;
3966 if (!in_procedure ("spillmem"))
3969 sep
= parse_operand (&e1
);
3972 as_bad ("Second operand missing");
3976 parse_operand (&e2
);
3978 if (!convert_expr_to_ab_reg (&e1
, &ab
, ®
))
3980 as_bad ("First operand to .spill%s must be a preserved register",
3981 psprel
? "psp" : "sp");
3985 if (e2
.X_op
!= O_constant
)
3987 as_bad ("Second operand to .spill%s must be a constant",
3988 psprel
? "psp" : "sp");
3993 add_unwind_entry (output_spill_psprel (ab
, reg
, e2
.X_add_number
));
3995 add_unwind_entry (output_spill_sprel (ab
, reg
, e2
.X_add_number
));
3999 dot_spillreg_p (dummy
)
4000 int dummy ATTRIBUTE_UNUSED
;
4003 unsigned int ab
, xy
, reg
, treg
;
4004 expressionS e1
, e2
, e3
;
4007 if (!in_procedure ("spillreg.p"))
4010 sep
= parse_operand (&e1
);
4013 as_bad ("No second and third operand to .spillreg.p");
4017 sep
= parse_operand (&e2
);
4020 as_bad ("No third operand to .spillreg.p");
4024 parse_operand (&e3
);
4026 qp
= e1
.X_add_number
- REG_P
;
4028 if (e1
.X_op
!= O_register
|| qp
> 63)
4030 as_bad ("First operand to .spillreg.p must be a predicate");
4034 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
4036 as_bad ("Second operand to .spillreg.p must be a preserved register");
4040 if (!convert_expr_to_xy_reg (&e3
, &xy
, &treg
))
4042 as_bad ("Third operand to .spillreg.p must be a register");
4046 add_unwind_entry (output_spill_reg_p (ab
, reg
, treg
, xy
, qp
));
4050 dot_spillmem_p (psprel
)
4053 expressionS e1
, e2
, e3
;
4055 unsigned int ab
, reg
;
4058 if (!in_procedure ("spillmem.p"))
4061 sep
= parse_operand (&e1
);
4064 as_bad ("Second operand missing");
4068 parse_operand (&e2
);
4071 as_bad ("Second operand missing");
4075 parse_operand (&e3
);
4077 qp
= e1
.X_add_number
- REG_P
;
4078 if (e1
.X_op
!= O_register
|| qp
> 63)
4080 as_bad ("First operand to .spill%s_p must be a predicate",
4081 psprel
? "psp" : "sp");
4085 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
4087 as_bad ("Second operand to .spill%s_p must be a preserved register",
4088 psprel
? "psp" : "sp");
4092 if (e3
.X_op
!= O_constant
)
4094 as_bad ("Third operand to .spill%s_p must be a constant",
4095 psprel
? "psp" : "sp");
4100 add_unwind_entry (output_spill_psprel_p (ab
, reg
, e3
.X_add_number
, qp
));
4102 add_unwind_entry (output_spill_sprel_p (ab
, reg
, e3
.X_add_number
, qp
));
4106 get_saved_prologue_count (lbl
)
4109 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
4111 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
4115 return lpc
->prologue_count
;
4117 as_bad ("Missing .label_state %ld", lbl
);
4122 save_prologue_count (lbl
, count
)
4126 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
4128 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
4132 lpc
->prologue_count
= count
;
4135 label_prologue_count
*new_lpc
= xmalloc (sizeof (* new_lpc
));
4137 new_lpc
->next
= unwind
.saved_prologue_counts
;
4138 new_lpc
->label_number
= lbl
;
4139 new_lpc
->prologue_count
= count
;
4140 unwind
.saved_prologue_counts
= new_lpc
;
4145 free_saved_prologue_counts ()
4147 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
4148 label_prologue_count
*next
;
4157 unwind
.saved_prologue_counts
= NULL
;
4161 dot_label_state (dummy
)
4162 int dummy ATTRIBUTE_UNUSED
;
4166 if (!in_body ("label_state"))
4170 if (e
.X_op
!= O_constant
)
4172 as_bad ("Operand to .label_state must be a constant");
4175 add_unwind_entry (output_label_state (e
.X_add_number
));
4176 save_prologue_count (e
.X_add_number
, unwind
.prologue_count
);
4180 dot_copy_state (dummy
)
4181 int dummy ATTRIBUTE_UNUSED
;
4185 if (!in_body ("copy_state"))
4189 if (e
.X_op
!= O_constant
)
4191 as_bad ("Operand to .copy_state must be a constant");
4194 add_unwind_entry (output_copy_state (e
.X_add_number
));
4195 unwind
.prologue_count
= get_saved_prologue_count (e
.X_add_number
);
4200 int dummy ATTRIBUTE_UNUSED
;
4205 if (!in_procedure ("unwabi"))
4208 sep
= parse_operand (&e1
);
4211 as_bad ("Second operand to .unwabi missing");
4214 sep
= parse_operand (&e2
);
4215 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
4216 demand_empty_rest_of_line ();
4218 if (e1
.X_op
!= O_constant
)
4220 as_bad ("First operand to .unwabi must be a constant");
4224 if (e2
.X_op
!= O_constant
)
4226 as_bad ("Second operand to .unwabi must be a constant");
4230 add_unwind_entry (output_unwabi (e1
.X_add_number
, e2
.X_add_number
));
4234 dot_personality (dummy
)
4235 int dummy ATTRIBUTE_UNUSED
;
4238 if (!in_procedure ("personality"))
4241 name
= input_line_pointer
;
4242 c
= get_symbol_end ();
4243 p
= input_line_pointer
;
4244 unwind
.personality_routine
= symbol_find_or_make (name
);
4245 unwind
.force_unwind_entry
= 1;
4248 demand_empty_rest_of_line ();
4253 int dummy ATTRIBUTE_UNUSED
;
4258 unwind
.proc_start
= 0;
4259 /* Parse names of main and alternate entry points and mark them as
4260 function symbols: */
4264 name
= input_line_pointer
;
4265 c
= get_symbol_end ();
4266 p
= input_line_pointer
;
4268 as_bad ("Empty argument of .proc");
4271 sym
= symbol_find_or_make (name
);
4272 if (S_IS_DEFINED (sym
))
4273 as_bad ("`%s' was already defined", name
);
4274 else if (unwind
.proc_start
== 0)
4276 unwind
.proc_start
= sym
;
4278 symbol_get_bfdsym (sym
)->flags
|= BSF_FUNCTION
;
4282 if (*input_line_pointer
!= ',')
4284 ++input_line_pointer
;
4286 if (unwind
.proc_start
== 0)
4287 unwind
.proc_start
= expr_build_dot ();
4288 demand_empty_rest_of_line ();
4291 unwind
.prologue
= 0;
4292 unwind
.prologue_count
= 0;
4295 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
4296 unwind
.personality_routine
= 0;
4301 int dummy ATTRIBUTE_UNUSED
;
4303 if (!in_procedure ("body"))
4305 if (!unwind
.prologue
&& !unwind
.body
&& unwind
.insn
)
4306 as_warn ("Initial .body should precede any instructions");
4308 unwind
.prologue
= 0;
4309 unwind
.prologue_mask
= 0;
4312 add_unwind_entry (output_body ());
4313 demand_empty_rest_of_line ();
4317 dot_prologue (dummy
)
4318 int dummy ATTRIBUTE_UNUSED
;
4321 int mask
= 0, grsave
= 0;
4323 if (!in_procedure ("prologue"))
4325 if (unwind
.prologue
)
4327 as_bad (".prologue within prologue");
4328 ignore_rest_of_line ();
4331 if (!unwind
.body
&& unwind
.insn
)
4332 as_warn ("Initial .prologue should precede any instructions");
4334 if (!is_it_end_of_statement ())
4337 sep
= parse_operand (&e1
);
4339 as_bad ("No second operand to .prologue");
4340 sep
= parse_operand (&e2
);
4341 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
4342 demand_empty_rest_of_line ();
4344 if (e1
.X_op
== O_constant
)
4346 mask
= e1
.X_add_number
;
4348 if (e2
.X_op
== O_constant
)
4349 grsave
= e2
.X_add_number
;
4350 else if (e2
.X_op
== O_register
4351 && (grsave
= e2
.X_add_number
- REG_GR
) < 128)
4354 as_bad ("Second operand not a constant or general register");
4356 add_unwind_entry (output_prologue_gr (mask
, grsave
));
4359 as_bad ("First operand not a constant");
4362 add_unwind_entry (output_prologue ());
4364 unwind
.prologue
= 1;
4365 unwind
.prologue_mask
= mask
;
4367 ++unwind
.prologue_count
;
4372 int dummy ATTRIBUTE_UNUSED
;
4376 int bytes_per_address
;
4379 subsegT saved_subseg
;
4380 char *name
, *default_name
, *p
, c
;
4382 int unwind_check
= md
.unwind_check
;
4384 md
.unwind_check
= unwind_check_error
;
4385 if (!in_procedure ("endp"))
4387 md
.unwind_check
= unwind_check
;
4389 if (unwind
.saved_text_seg
)
4391 saved_seg
= unwind
.saved_text_seg
;
4392 saved_subseg
= unwind
.saved_text_subseg
;
4393 unwind
.saved_text_seg
= NULL
;
4397 saved_seg
= now_seg
;
4398 saved_subseg
= now_subseg
;
4401 insn_group_break (1, 0, 0);
4403 /* If there wasn't a .handlerdata, we haven't generated an image yet. */
4405 generate_unwind_image (saved_seg
);
4407 if (unwind
.info
|| unwind
.force_unwind_entry
)
4411 subseg_set (md
.last_text_seg
, 0);
4412 proc_end
= expr_build_dot ();
4414 start_unwind_section (saved_seg
, SPECIAL_SECTION_UNWIND
, 0);
4416 /* Make sure that section has 4 byte alignment for ILP32 and
4417 8 byte alignment for LP64. */
4418 record_alignment (now_seg
, md
.pointer_size_shift
);
4420 /* Need space for 3 pointers for procedure start, procedure end,
4422 ptr
= frag_more (3 * md
.pointer_size
);
4423 where
= frag_now_fix () - (3 * md
.pointer_size
);
4424 bytes_per_address
= bfd_arch_bits_per_address (stdoutput
) / 8;
4426 /* Issue the values of a) Proc Begin, b) Proc End, c) Unwind Record. */
4427 e
.X_op
= O_pseudo_fixup
;
4428 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4430 e
.X_add_symbol
= unwind
.proc_start
;
4431 ia64_cons_fix_new (frag_now
, where
, bytes_per_address
, &e
);
4433 e
.X_op
= O_pseudo_fixup
;
4434 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4436 e
.X_add_symbol
= proc_end
;
4437 ia64_cons_fix_new (frag_now
, where
+ bytes_per_address
,
4438 bytes_per_address
, &e
);
4442 e
.X_op
= O_pseudo_fixup
;
4443 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4445 e
.X_add_symbol
= unwind
.info
;
4446 ia64_cons_fix_new (frag_now
, where
+ (bytes_per_address
* 2),
4447 bytes_per_address
, &e
);
4450 md_number_to_chars (ptr
+ (bytes_per_address
* 2), 0,
4455 start_unwind_section (saved_seg
, SPECIAL_SECTION_UNWIND
, 1);
4457 subseg_set (saved_seg
, saved_subseg
);
4459 if (unwind
.proc_start
)
4460 default_name
= (char *) S_GET_NAME (unwind
.proc_start
);
4462 default_name
= NULL
;
4464 /* Parse names of main and alternate entry points and set symbol sizes. */
4468 name
= input_line_pointer
;
4469 c
= get_symbol_end ();
4470 p
= input_line_pointer
;
4473 if (md
.unwind_check
== unwind_check_warning
)
4477 as_warn ("Empty argument of .endp. Use the default name `%s'",
4479 name
= default_name
;
4482 as_warn ("Empty argument of .endp");
4485 as_bad ("Empty argument of .endp");
4489 sym
= symbol_find (name
);
4491 && md
.unwind_check
== unwind_check_warning
4493 && default_name
!= name
)
4495 /* We have a bad name. Try the default one if needed. */
4496 as_warn ("`%s' was not defined within procedure. Use the default name `%s'",
4497 name
, default_name
);
4498 name
= default_name
;
4499 sym
= symbol_find (name
);
4501 if (!sym
|| !S_IS_DEFINED (sym
))
4502 as_bad ("`%s' was not defined within procedure", name
);
4503 else if (unwind
.proc_start
4504 && (symbol_get_bfdsym (sym
)->flags
& BSF_FUNCTION
)
4505 && S_GET_SIZE (sym
) == 0 && symbol_get_obj (sym
)->size
== NULL
)
4507 fragS
*fr
= symbol_get_frag (unwind
.proc_start
);
4508 fragS
*frag
= symbol_get_frag (sym
);
4510 /* Check whether the function label is at or beyond last
4512 while (fr
&& fr
!= frag
)
4516 if (frag
== frag_now
&& SEG_NORMAL (now_seg
))
4517 S_SET_SIZE (sym
, frag_now_fix () - S_GET_VALUE (sym
));
4520 symbol_get_obj (sym
)->size
=
4521 (expressionS
*) xmalloc (sizeof (expressionS
));
4522 symbol_get_obj (sym
)->size
->X_op
= O_subtract
;
4523 symbol_get_obj (sym
)->size
->X_add_symbol
4524 = symbol_new (FAKE_LABEL_NAME
, now_seg
,
4525 frag_now_fix (), frag_now
);
4526 symbol_get_obj (sym
)->size
->X_op_symbol
= sym
;
4527 symbol_get_obj (sym
)->size
->X_add_number
= 0;
4534 if (*input_line_pointer
!= ',')
4536 ++input_line_pointer
;
4538 demand_empty_rest_of_line ();
4539 unwind
.proc_start
= unwind
.info
= 0;
4543 dot_template (template)
4546 CURR_SLOT
.user_template
= template;
4551 int dummy ATTRIBUTE_UNUSED
;
4553 int ins
, locs
, outs
, rots
;
4555 if (is_it_end_of_statement ())
4556 ins
= locs
= outs
= rots
= 0;
4559 ins
= get_absolute_expression ();
4560 if (*input_line_pointer
++ != ',')
4562 locs
= get_absolute_expression ();
4563 if (*input_line_pointer
++ != ',')
4565 outs
= get_absolute_expression ();
4566 if (*input_line_pointer
++ != ',')
4568 rots
= get_absolute_expression ();
4570 set_regstack (ins
, locs
, outs
, rots
);
4574 as_bad ("Comma expected");
4575 ignore_rest_of_line ();
4582 unsigned num_regs
, num_alloced
= 0;
4583 struct dynreg
**drpp
, *dr
;
4584 int ch
, base_reg
= 0;
4590 case DYNREG_GR
: base_reg
= REG_GR
+ 32; break;
4591 case DYNREG_FR
: base_reg
= REG_FR
+ 32; break;
4592 case DYNREG_PR
: base_reg
= REG_P
+ 16; break;
4596 /* First, remove existing names from hash table. */
4597 for (dr
= md
.dynreg
[type
]; dr
&& dr
->num_regs
; dr
= dr
->next
)
4599 hash_delete (md
.dynreg_hash
, dr
->name
);
4600 /* FIXME: Free dr->name. */
4604 drpp
= &md
.dynreg
[type
];
4607 start
= input_line_pointer
;
4608 ch
= get_symbol_end ();
4609 len
= strlen (ia64_canonicalize_symbol_name (start
));
4610 *input_line_pointer
= ch
;
4613 if (*input_line_pointer
!= '[')
4615 as_bad ("Expected '['");
4618 ++input_line_pointer
; /* skip '[' */
4620 num_regs
= get_absolute_expression ();
4622 if (*input_line_pointer
++ != ']')
4624 as_bad ("Expected ']'");
4629 num_alloced
+= num_regs
;
4633 if (num_alloced
> md
.rot
.num_regs
)
4635 as_bad ("Used more than the declared %d rotating registers",
4641 if (num_alloced
> 96)
4643 as_bad ("Used more than the available 96 rotating registers");
4648 if (num_alloced
> 48)
4650 as_bad ("Used more than the available 48 rotating registers");
4661 *drpp
= obstack_alloc (¬es
, sizeof (*dr
));
4662 memset (*drpp
, 0, sizeof (*dr
));
4665 name
= obstack_alloc (¬es
, len
+ 1);
4666 memcpy (name
, start
, len
);
4671 dr
->num_regs
= num_regs
;
4672 dr
->base
= base_reg
;
4674 base_reg
+= num_regs
;
4676 if (hash_insert (md
.dynreg_hash
, name
, dr
))
4678 as_bad ("Attempt to redefine register set `%s'", name
);
4679 obstack_free (¬es
, name
);
4683 if (*input_line_pointer
!= ',')
4685 ++input_line_pointer
; /* skip comma */
4688 demand_empty_rest_of_line ();
4692 ignore_rest_of_line ();
4696 dot_byteorder (byteorder
)
4699 segment_info_type
*seginfo
= seg_info (now_seg
);
4701 if (byteorder
== -1)
4703 if (seginfo
->tc_segment_info_data
.endian
== 0)
4704 seginfo
->tc_segment_info_data
.endian
= default_big_endian
? 1 : 2;
4705 byteorder
= seginfo
->tc_segment_info_data
.endian
== 1;
4708 seginfo
->tc_segment_info_data
.endian
= byteorder
? 1 : 2;
4710 if (target_big_endian
!= byteorder
)
4712 target_big_endian
= byteorder
;
4713 if (target_big_endian
)
4715 ia64_number_to_chars
= number_to_chars_bigendian
;
4716 ia64_float_to_chars
= ia64_float_to_chars_bigendian
;
4720 ia64_number_to_chars
= number_to_chars_littleendian
;
4721 ia64_float_to_chars
= ia64_float_to_chars_littleendian
;
4728 int dummy ATTRIBUTE_UNUSED
;
4735 option
= input_line_pointer
;
4736 ch
= get_symbol_end ();
4737 if (strcmp (option
, "lsb") == 0)
4738 md
.flags
&= ~EF_IA_64_BE
;
4739 else if (strcmp (option
, "msb") == 0)
4740 md
.flags
|= EF_IA_64_BE
;
4741 else if (strcmp (option
, "abi32") == 0)
4742 md
.flags
&= ~EF_IA_64_ABI64
;
4743 else if (strcmp (option
, "abi64") == 0)
4744 md
.flags
|= EF_IA_64_ABI64
;
4746 as_bad ("Unknown psr option `%s'", option
);
4747 *input_line_pointer
= ch
;
4750 if (*input_line_pointer
!= ',')
4753 ++input_line_pointer
;
4756 demand_empty_rest_of_line ();
4761 int dummy ATTRIBUTE_UNUSED
;
4763 new_logical_line (0, get_absolute_expression ());
4764 demand_empty_rest_of_line ();
4768 cross_section (ref
, cons
, ua
)
4770 void (*cons
) PARAMS((int));
4774 int saved_auto_align
;
4775 unsigned int section_count
;
4778 start
= input_line_pointer
;
4784 name
= demand_copy_C_string (&len
);
4785 obstack_free(¬es
, name
);
4788 ignore_rest_of_line ();
4794 char c
= get_symbol_end ();
4796 if (input_line_pointer
== start
)
4798 as_bad ("Missing section name");
4799 ignore_rest_of_line ();
4802 *input_line_pointer
= c
;
4804 end
= input_line_pointer
;
4806 if (*input_line_pointer
!= ',')
4808 as_bad ("Comma expected after section name");
4809 ignore_rest_of_line ();
4813 end
= input_line_pointer
+ 1; /* skip comma */
4814 input_line_pointer
= start
;
4815 md
.keep_pending_output
= 1;
4816 section_count
= bfd_count_sections(stdoutput
);
4817 obj_elf_section (0);
4818 if (section_count
!= bfd_count_sections(stdoutput
))
4819 as_warn ("Creating sections with .xdataN/.xrealN/.xstringZ is deprecated.");
4820 input_line_pointer
= end
;
4821 saved_auto_align
= md
.auto_align
;
4826 md
.auto_align
= saved_auto_align
;
4827 obj_elf_previous (0);
4828 md
.keep_pending_output
= 0;
4835 cross_section (size
, cons
, 0);
4838 /* Why doesn't float_cons() call md_cons_align() the way cons() does? */
4841 stmt_float_cons (kind
)
4862 ia64_do_align (alignment
);
4870 int saved_auto_align
= md
.auto_align
;
4874 md
.auto_align
= saved_auto_align
;
4878 dot_xfloat_cons (kind
)
4881 cross_section (kind
, stmt_float_cons
, 0);
4885 dot_xstringer (zero
)
4888 cross_section (zero
, stringer
, 0);
4895 cross_section (size
, cons
, 1);
4899 dot_xfloat_cons_ua (kind
)
4902 cross_section (kind
, float_cons
, 1);
4905 /* .reg.val <regname>,value */
4909 int dummy ATTRIBUTE_UNUSED
;
4914 if (reg
.X_op
!= O_register
)
4916 as_bad (_("Register name expected"));
4917 ignore_rest_of_line ();
4919 else if (*input_line_pointer
++ != ',')
4921 as_bad (_("Comma expected"));
4922 ignore_rest_of_line ();
4926 valueT value
= get_absolute_expression ();
4927 int regno
= reg
.X_add_number
;
4928 if (regno
<= REG_GR
|| regno
> REG_GR
+ 127)
4929 as_warn (_("Register value annotation ignored"));
4932 gr_values
[regno
- REG_GR
].known
= 1;
4933 gr_values
[regno
- REG_GR
].value
= value
;
4934 gr_values
[regno
- REG_GR
].path
= md
.path
;
4937 demand_empty_rest_of_line ();
4942 .serialize.instruction
4945 dot_serialize (type
)
4948 insn_group_break (0, 0, 0);
4950 instruction_serialization ();
4952 data_serialization ();
4953 insn_group_break (0, 0, 0);
4954 demand_empty_rest_of_line ();
4957 /* select dv checking mode
4962 A stop is inserted when changing modes
4969 if (md
.manual_bundling
)
4970 as_warn (_("Directive invalid within a bundle"));
4972 if (type
== 'E' || type
== 'A')
4973 md
.mode_explicitly_set
= 0;
4975 md
.mode_explicitly_set
= 1;
4982 if (md
.explicit_mode
)
4983 insn_group_break (1, 0, 0);
4984 md
.explicit_mode
= 0;
4988 if (!md
.explicit_mode
)
4989 insn_group_break (1, 0, 0);
4990 md
.explicit_mode
= 1;
4994 if (md
.explicit_mode
!= md
.default_explicit_mode
)
4995 insn_group_break (1, 0, 0);
4996 md
.explicit_mode
= md
.default_explicit_mode
;
4997 md
.mode_explicitly_set
= 0;
5008 for (regno
= 0; regno
< 64; regno
++)
5010 if (mask
& ((valueT
) 1 << regno
))
5012 fprintf (stderr
, "%s p%d", comma
, regno
);
5019 .pred.rel.clear [p1 [,p2 [,...]]] (also .pred.rel "clear" or @clear)
5020 .pred.rel.imply p1, p2 (also .pred.rel "imply" or @imply)
5021 .pred.rel.mutex p1, p2 [,...] (also .pred.rel "mutex" or @mutex)
5022 .pred.safe_across_calls p1 [, p2 [,...]]
5031 int p1
= -1, p2
= -1;
5035 if (*input_line_pointer
== '"')
5038 char *form
= demand_copy_C_string (&len
);
5040 if (strcmp (form
, "mutex") == 0)
5042 else if (strcmp (form
, "clear") == 0)
5044 else if (strcmp (form
, "imply") == 0)
5046 obstack_free (¬es
, form
);
5048 else if (*input_line_pointer
== '@')
5050 char *form
= ++input_line_pointer
;
5051 char c
= get_symbol_end();
5053 if (strcmp (form
, "mutex") == 0)
5055 else if (strcmp (form
, "clear") == 0)
5057 else if (strcmp (form
, "imply") == 0)
5059 *input_line_pointer
= c
;
5063 as_bad (_("Missing predicate relation type"));
5064 ignore_rest_of_line ();
5069 as_bad (_("Unrecognized predicate relation type"));
5070 ignore_rest_of_line ();
5073 if (*input_line_pointer
== ',')
5074 ++input_line_pointer
;
5083 expressionS pr
, *pr1
, *pr2
;
5086 if (pr
.X_op
== O_register
5087 && pr
.X_add_number
>= REG_P
5088 && pr
.X_add_number
<= REG_P
+ 63)
5090 regno
= pr
.X_add_number
- REG_P
;
5098 else if (type
!= 'i'
5099 && pr
.X_op
== O_subtract
5100 && (pr1
= symbol_get_value_expression (pr
.X_add_symbol
))
5101 && pr1
->X_op
== O_register
5102 && pr1
->X_add_number
>= REG_P
5103 && pr1
->X_add_number
<= REG_P
+ 63
5104 && (pr2
= symbol_get_value_expression (pr
.X_op_symbol
))
5105 && pr2
->X_op
== O_register
5106 && pr2
->X_add_number
>= REG_P
5107 && pr2
->X_add_number
<= REG_P
+ 63)
5112 regno
= pr1
->X_add_number
- REG_P
;
5113 stop
= pr2
->X_add_number
- REG_P
;
5116 as_bad (_("Bad register range"));
5117 ignore_rest_of_line ();
5120 bits
= ((bits
<< stop
) << 1) - (bits
<< regno
);
5121 count
+= stop
- regno
+ 1;
5125 as_bad (_("Predicate register expected"));
5126 ignore_rest_of_line ();
5130 as_warn (_("Duplicate predicate register ignored"));
5132 if (*input_line_pointer
!= ',')
5134 ++input_line_pointer
;
5143 clear_qp_mutex (mask
);
5144 clear_qp_implies (mask
, (valueT
) 0);
5147 if (count
!= 2 || p1
== -1 || p2
== -1)
5148 as_bad (_("Predicate source and target required"));
5149 else if (p1
== 0 || p2
== 0)
5150 as_bad (_("Use of p0 is not valid in this context"));
5152 add_qp_imply (p1
, p2
);
5157 as_bad (_("At least two PR arguments expected"));
5162 as_bad (_("Use of p0 is not valid in this context"));
5165 add_qp_mutex (mask
);
5168 /* note that we don't override any existing relations */
5171 as_bad (_("At least one PR argument expected"));
5176 fprintf (stderr
, "Safe across calls: ");
5177 print_prmask (mask
);
5178 fprintf (stderr
, "\n");
5180 qp_safe_across_calls
= mask
;
5183 demand_empty_rest_of_line ();
5186 /* .entry label [, label [, ...]]
5187 Hint to DV code that the given labels are to be considered entry points.
5188 Otherwise, only global labels are considered entry points. */
5192 int dummy ATTRIBUTE_UNUSED
;
5201 name
= input_line_pointer
;
5202 c
= get_symbol_end ();
5203 symbolP
= symbol_find_or_make (name
);
5205 err
= hash_insert (md
.entry_hash
, S_GET_NAME (symbolP
), (PTR
) symbolP
);
5207 as_fatal (_("Inserting \"%s\" into entry hint table failed: %s"),
5210 *input_line_pointer
= c
;
5212 c
= *input_line_pointer
;
5215 input_line_pointer
++;
5217 if (*input_line_pointer
== '\n')
5223 demand_empty_rest_of_line ();
5226 /* .mem.offset offset, base
5227 "base" is used to distinguish between offsets from a different base. */
5230 dot_mem_offset (dummy
)
5231 int dummy ATTRIBUTE_UNUSED
;
5233 md
.mem_offset
.hint
= 1;
5234 md
.mem_offset
.offset
= get_absolute_expression ();
5235 if (*input_line_pointer
!= ',')
5237 as_bad (_("Comma expected"));
5238 ignore_rest_of_line ();
5241 ++input_line_pointer
;
5242 md
.mem_offset
.base
= get_absolute_expression ();
5243 demand_empty_rest_of_line ();
5246 /* ia64-specific pseudo-ops: */
5247 const pseudo_typeS md_pseudo_table
[] =
5249 { "radix", dot_radix
, 0 },
5250 { "lcomm", s_lcomm_bytes
, 1 },
5251 { "loc", dot_loc
, 0 },
5252 { "bss", dot_special_section
, SPECIAL_SECTION_BSS
},
5253 { "sbss", dot_special_section
, SPECIAL_SECTION_SBSS
},
5254 { "sdata", dot_special_section
, SPECIAL_SECTION_SDATA
},
5255 { "rodata", dot_special_section
, SPECIAL_SECTION_RODATA
},
5256 { "comment", dot_special_section
, SPECIAL_SECTION_COMMENT
},
5257 { "ia_64.unwind", dot_special_section
, SPECIAL_SECTION_UNWIND
},
5258 { "ia_64.unwind_info", dot_special_section
, SPECIAL_SECTION_UNWIND_INFO
},
5259 { "init_array", dot_special_section
, SPECIAL_SECTION_INIT_ARRAY
},
5260 { "fini_array", dot_special_section
, SPECIAL_SECTION_FINI_ARRAY
},
5261 { "proc", dot_proc
, 0 },
5262 { "body", dot_body
, 0 },
5263 { "prologue", dot_prologue
, 0 },
5264 { "endp", dot_endp
, 0 },
5266 { "fframe", dot_fframe
, 0 },
5267 { "vframe", dot_vframe
, 0 },
5268 { "vframesp", dot_vframesp
, 0 },
5269 { "vframepsp", dot_vframepsp
, 0 },
5270 { "save", dot_save
, 0 },
5271 { "restore", dot_restore
, 0 },
5272 { "restorereg", dot_restorereg
, 0 },
5273 { "restorereg.p", dot_restorereg_p
, 0 },
5274 { "handlerdata", dot_handlerdata
, 0 },
5275 { "unwentry", dot_unwentry
, 0 },
5276 { "altrp", dot_altrp
, 0 },
5277 { "savesp", dot_savemem
, 0 },
5278 { "savepsp", dot_savemem
, 1 },
5279 { "save.g", dot_saveg
, 0 },
5280 { "save.f", dot_savef
, 0 },
5281 { "save.b", dot_saveb
, 0 },
5282 { "save.gf", dot_savegf
, 0 },
5283 { "spill", dot_spill
, 0 },
5284 { "spillreg", dot_spillreg
, 0 },
5285 { "spillsp", dot_spillmem
, 0 },
5286 { "spillpsp", dot_spillmem
, 1 },
5287 { "spillreg.p", dot_spillreg_p
, 0 },
5288 { "spillsp.p", dot_spillmem_p
, 0 },
5289 { "spillpsp.p", dot_spillmem_p
, 1 },
5290 { "label_state", dot_label_state
, 0 },
5291 { "copy_state", dot_copy_state
, 0 },
5292 { "unwabi", dot_unwabi
, 0 },
5293 { "personality", dot_personality
, 0 },
5294 { "mii", dot_template
, 0x0 },
5295 { "mli", dot_template
, 0x2 }, /* old format, for compatibility */
5296 { "mlx", dot_template
, 0x2 },
5297 { "mmi", dot_template
, 0x4 },
5298 { "mfi", dot_template
, 0x6 },
5299 { "mmf", dot_template
, 0x7 },
5300 { "mib", dot_template
, 0x8 },
5301 { "mbb", dot_template
, 0x9 },
5302 { "bbb", dot_template
, 0xb },
5303 { "mmb", dot_template
, 0xc },
5304 { "mfb", dot_template
, 0xe },
5305 { "align", dot_align
, 0 },
5306 { "regstk", dot_regstk
, 0 },
5307 { "rotr", dot_rot
, DYNREG_GR
},
5308 { "rotf", dot_rot
, DYNREG_FR
},
5309 { "rotp", dot_rot
, DYNREG_PR
},
5310 { "lsb", dot_byteorder
, 0 },
5311 { "msb", dot_byteorder
, 1 },
5312 { "psr", dot_psr
, 0 },
5313 { "alias", dot_alias
, 0 },
5314 { "secalias", dot_alias
, 1 },
5315 { "ln", dot_ln
, 0 }, /* source line info (for debugging) */
5317 { "xdata1", dot_xdata
, 1 },
5318 { "xdata2", dot_xdata
, 2 },
5319 { "xdata4", dot_xdata
, 4 },
5320 { "xdata8", dot_xdata
, 8 },
5321 { "xdata16", dot_xdata
, 16 },
5322 { "xreal4", dot_xfloat_cons
, 'f' },
5323 { "xreal8", dot_xfloat_cons
, 'd' },
5324 { "xreal10", dot_xfloat_cons
, 'x' },
5325 { "xreal16", dot_xfloat_cons
, 'X' },
5326 { "xstring", dot_xstringer
, 0 },
5327 { "xstringz", dot_xstringer
, 1 },
5329 /* unaligned versions: */
5330 { "xdata2.ua", dot_xdata_ua
, 2 },
5331 { "xdata4.ua", dot_xdata_ua
, 4 },
5332 { "xdata8.ua", dot_xdata_ua
, 8 },
5333 { "xdata16.ua", dot_xdata_ua
, 16 },
5334 { "xreal4.ua", dot_xfloat_cons_ua
, 'f' },
5335 { "xreal8.ua", dot_xfloat_cons_ua
, 'd' },
5336 { "xreal10.ua", dot_xfloat_cons_ua
, 'x' },
5337 { "xreal16.ua", dot_xfloat_cons_ua
, 'X' },
5339 /* annotations/DV checking support */
5340 { "entry", dot_entry
, 0 },
5341 { "mem.offset", dot_mem_offset
, 0 },
5342 { "pred.rel", dot_pred_rel
, 0 },
5343 { "pred.rel.clear", dot_pred_rel
, 'c' },
5344 { "pred.rel.imply", dot_pred_rel
, 'i' },
5345 { "pred.rel.mutex", dot_pred_rel
, 'm' },
5346 { "pred.safe_across_calls", dot_pred_rel
, 's' },
5347 { "reg.val", dot_reg_val
, 0 },
5348 { "serialize.data", dot_serialize
, 0 },
5349 { "serialize.instruction", dot_serialize
, 1 },
5350 { "auto", dot_dv_mode
, 'a' },
5351 { "explicit", dot_dv_mode
, 'e' },
5352 { "default", dot_dv_mode
, 'd' },
5354 /* ??? These are needed to make gas/testsuite/gas/elf/ehopt.s work.
5355 IA-64 aligns data allocation pseudo-ops by default, so we have to
5356 tell it that these ones are supposed to be unaligned. Long term,
5357 should rewrite so that only IA-64 specific data allocation pseudo-ops
5358 are aligned by default. */
5359 {"2byte", stmt_cons_ua
, 2},
5360 {"4byte", stmt_cons_ua
, 4},
5361 {"8byte", stmt_cons_ua
, 8},
5366 static const struct pseudo_opcode
5369 void (*handler
) (int);
5374 /* these are more like pseudo-ops, but don't start with a dot */
5375 { "data1", cons
, 1 },
5376 { "data2", cons
, 2 },
5377 { "data4", cons
, 4 },
5378 { "data8", cons
, 8 },
5379 { "data16", cons
, 16 },
5380 { "real4", stmt_float_cons
, 'f' },
5381 { "real8", stmt_float_cons
, 'd' },
5382 { "real10", stmt_float_cons
, 'x' },
5383 { "real16", stmt_float_cons
, 'X' },
5384 { "string", stringer
, 0 },
5385 { "stringz", stringer
, 1 },
5387 /* unaligned versions: */
5388 { "data2.ua", stmt_cons_ua
, 2 },
5389 { "data4.ua", stmt_cons_ua
, 4 },
5390 { "data8.ua", stmt_cons_ua
, 8 },
5391 { "data16.ua", stmt_cons_ua
, 16 },
5392 { "real4.ua", float_cons
, 'f' },
5393 { "real8.ua", float_cons
, 'd' },
5394 { "real10.ua", float_cons
, 'x' },
5395 { "real16.ua", float_cons
, 'X' },
5398 /* Declare a register by creating a symbol for it and entering it in
5399 the symbol table. */
5402 declare_register (name
, regnum
)
5409 sym
= symbol_new (name
, reg_section
, regnum
, &zero_address_frag
);
5411 err
= hash_insert (md
.reg_hash
, S_GET_NAME (sym
), (PTR
) sym
);
5413 as_fatal ("Inserting \"%s\" into register table failed: %s",
5420 declare_register_set (prefix
, num_regs
, base_regnum
)
5428 for (i
= 0; i
< num_regs
; ++i
)
5430 sprintf (name
, "%s%u", prefix
, i
);
5431 declare_register (name
, base_regnum
+ i
);
5436 operand_width (opnd
)
5437 enum ia64_opnd opnd
;
5439 const struct ia64_operand
*odesc
= &elf64_ia64_operands
[opnd
];
5440 unsigned int bits
= 0;
5444 for (i
= 0; i
< NELEMS (odesc
->field
) && odesc
->field
[i
].bits
; ++i
)
5445 bits
+= odesc
->field
[i
].bits
;
5450 static enum operand_match_result
5451 operand_match (idesc
, index
, e
)
5452 const struct ia64_opcode
*idesc
;
5456 enum ia64_opnd opnd
= idesc
->operands
[index
];
5457 int bits
, relocatable
= 0;
5458 struct insn_fix
*fix
;
5465 case IA64_OPND_AR_CCV
:
5466 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 32)
5467 return OPERAND_MATCH
;
5470 case IA64_OPND_AR_CSD
:
5471 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 25)
5472 return OPERAND_MATCH
;
5475 case IA64_OPND_AR_PFS
:
5476 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 64)
5477 return OPERAND_MATCH
;
5481 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_GR
+ 0)
5482 return OPERAND_MATCH
;
5486 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_IP
)
5487 return OPERAND_MATCH
;
5491 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR
)
5492 return OPERAND_MATCH
;
5495 case IA64_OPND_PR_ROT
:
5496 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR_ROT
)
5497 return OPERAND_MATCH
;
5501 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR
)
5502 return OPERAND_MATCH
;
5505 case IA64_OPND_PSR_L
:
5506 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_L
)
5507 return OPERAND_MATCH
;
5510 case IA64_OPND_PSR_UM
:
5511 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_UM
)
5512 return OPERAND_MATCH
;
5516 if (e
->X_op
== O_constant
)
5518 if (e
->X_add_number
== 1)
5519 return OPERAND_MATCH
;
5521 return OPERAND_OUT_OF_RANGE
;
5526 if (e
->X_op
== O_constant
)
5528 if (e
->X_add_number
== 8)
5529 return OPERAND_MATCH
;
5531 return OPERAND_OUT_OF_RANGE
;
5536 if (e
->X_op
== O_constant
)
5538 if (e
->X_add_number
== 16)
5539 return OPERAND_MATCH
;
5541 return OPERAND_OUT_OF_RANGE
;
5545 /* register operands: */
5548 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_AR
5549 && e
->X_add_number
< REG_AR
+ 128)
5550 return OPERAND_MATCH
;
5555 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_BR
5556 && e
->X_add_number
< REG_BR
+ 8)
5557 return OPERAND_MATCH
;
5561 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_CR
5562 && e
->X_add_number
< REG_CR
+ 128)
5563 return OPERAND_MATCH
;
5570 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_FR
5571 && e
->X_add_number
< REG_FR
+ 128)
5572 return OPERAND_MATCH
;
5577 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_P
5578 && e
->X_add_number
< REG_P
+ 64)
5579 return OPERAND_MATCH
;
5585 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
5586 && e
->X_add_number
< REG_GR
+ 128)
5587 return OPERAND_MATCH
;
5590 case IA64_OPND_R3_2
:
5591 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
)
5593 if (e
->X_add_number
< REG_GR
+ 4)
5594 return OPERAND_MATCH
;
5595 else if (e
->X_add_number
< REG_GR
+ 128)
5596 return OPERAND_OUT_OF_RANGE
;
5600 /* indirect operands: */
5601 case IA64_OPND_CPUID_R3
:
5602 case IA64_OPND_DBR_R3
:
5603 case IA64_OPND_DTR_R3
:
5604 case IA64_OPND_ITR_R3
:
5605 case IA64_OPND_IBR_R3
:
5606 case IA64_OPND_MSR_R3
:
5607 case IA64_OPND_PKR_R3
:
5608 case IA64_OPND_PMC_R3
:
5609 case IA64_OPND_PMD_R3
:
5610 case IA64_OPND_RR_R3
:
5611 if (e
->X_op
== O_index
&& e
->X_op_symbol
5612 && (S_GET_VALUE (e
->X_op_symbol
) - IND_CPUID
5613 == opnd
- IA64_OPND_CPUID_R3
))
5614 return OPERAND_MATCH
;
5618 if (e
->X_op
== O_index
&& !e
->X_op_symbol
)
5619 return OPERAND_MATCH
;
5622 /* immediate operands: */
5623 case IA64_OPND_CNT2a
:
5624 case IA64_OPND_LEN4
:
5625 case IA64_OPND_LEN6
:
5626 bits
= operand_width (idesc
->operands
[index
]);
5627 if (e
->X_op
== O_constant
)
5629 if ((bfd_vma
) (e
->X_add_number
- 1) < ((bfd_vma
) 1 << bits
))
5630 return OPERAND_MATCH
;
5632 return OPERAND_OUT_OF_RANGE
;
5636 case IA64_OPND_CNT2b
:
5637 if (e
->X_op
== O_constant
)
5639 if ((bfd_vma
) (e
->X_add_number
- 1) < 3)
5640 return OPERAND_MATCH
;
5642 return OPERAND_OUT_OF_RANGE
;
5646 case IA64_OPND_CNT2c
:
5647 val
= e
->X_add_number
;
5648 if (e
->X_op
== O_constant
)
5650 if ((val
== 0 || val
== 7 || val
== 15 || val
== 16))
5651 return OPERAND_MATCH
;
5653 return OPERAND_OUT_OF_RANGE
;
5658 /* SOR must be an integer multiple of 8 */
5659 if (e
->X_op
== O_constant
&& e
->X_add_number
& 0x7)
5660 return OPERAND_OUT_OF_RANGE
;
5663 if (e
->X_op
== O_constant
)
5665 if ((bfd_vma
) e
->X_add_number
<= 96)
5666 return OPERAND_MATCH
;
5668 return OPERAND_OUT_OF_RANGE
;
5672 case IA64_OPND_IMMU62
:
5673 if (e
->X_op
== O_constant
)
5675 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 62))
5676 return OPERAND_MATCH
;
5678 return OPERAND_OUT_OF_RANGE
;
5682 /* FIXME -- need 62-bit relocation type */
5683 as_bad (_("62-bit relocation not yet implemented"));
5687 case IA64_OPND_IMMU64
:
5688 if (e
->X_op
== O_symbol
|| e
->X_op
== O_pseudo_fixup
5689 || e
->X_op
== O_subtract
)
5691 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5692 fix
->code
= BFD_RELOC_IA64_IMM64
;
5693 if (e
->X_op
!= O_subtract
)
5695 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5696 if (e
->X_op
== O_pseudo_fixup
)
5700 fix
->opnd
= idesc
->operands
[index
];
5703 ++CURR_SLOT
.num_fixups
;
5704 return OPERAND_MATCH
;
5706 else if (e
->X_op
== O_constant
)
5707 return OPERAND_MATCH
;
5710 case IA64_OPND_CCNT5
:
5711 case IA64_OPND_CNT5
:
5712 case IA64_OPND_CNT6
:
5713 case IA64_OPND_CPOS6a
:
5714 case IA64_OPND_CPOS6b
:
5715 case IA64_OPND_CPOS6c
:
5716 case IA64_OPND_IMMU2
:
5717 case IA64_OPND_IMMU7a
:
5718 case IA64_OPND_IMMU7b
:
5719 case IA64_OPND_IMMU21
:
5720 case IA64_OPND_IMMU24
:
5721 case IA64_OPND_MBTYPE4
:
5722 case IA64_OPND_MHTYPE8
:
5723 case IA64_OPND_POS6
:
5724 bits
= operand_width (idesc
->operands
[index
]);
5725 if (e
->X_op
== O_constant
)
5727 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5728 return OPERAND_MATCH
;
5730 return OPERAND_OUT_OF_RANGE
;
5734 case IA64_OPND_IMMU9
:
5735 bits
= operand_width (idesc
->operands
[index
]);
5736 if (e
->X_op
== O_constant
)
5738 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5740 int lobits
= e
->X_add_number
& 0x3;
5741 if (((bfd_vma
) e
->X_add_number
& 0x3C) != 0 && lobits
== 0)
5742 e
->X_add_number
|= (bfd_vma
) 0x3;
5743 return OPERAND_MATCH
;
5746 return OPERAND_OUT_OF_RANGE
;
5750 case IA64_OPND_IMM44
:
5751 /* least 16 bits must be zero */
5752 if ((e
->X_add_number
& 0xffff) != 0)
5753 /* XXX technically, this is wrong: we should not be issuing warning
5754 messages until we're sure this instruction pattern is going to
5756 as_warn (_("lower 16 bits of mask ignored"));
5758 if (e
->X_op
== O_constant
)
5760 if (((e
->X_add_number
>= 0
5761 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 44))
5762 || (e
->X_add_number
< 0
5763 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 44))))
5766 if (e
->X_add_number
>= 0
5767 && (e
->X_add_number
& ((bfd_vma
) 1 << 43)) != 0)
5769 e
->X_add_number
|= ~(((bfd_vma
) 1 << 44) - 1);
5771 return OPERAND_MATCH
;
5774 return OPERAND_OUT_OF_RANGE
;
5778 case IA64_OPND_IMM17
:
5779 /* bit 0 is a don't care (pr0 is hardwired to 1) */
5780 if (e
->X_op
== O_constant
)
5782 if (((e
->X_add_number
>= 0
5783 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 17))
5784 || (e
->X_add_number
< 0
5785 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 17))))
5788 if (e
->X_add_number
>= 0
5789 && (e
->X_add_number
& ((bfd_vma
) 1 << 16)) != 0)
5791 e
->X_add_number
|= ~(((bfd_vma
) 1 << 17) - 1);
5793 return OPERAND_MATCH
;
5796 return OPERAND_OUT_OF_RANGE
;
5800 case IA64_OPND_IMM14
:
5801 case IA64_OPND_IMM22
:
5803 case IA64_OPND_IMM1
:
5804 case IA64_OPND_IMM8
:
5805 case IA64_OPND_IMM8U4
:
5806 case IA64_OPND_IMM8M1
:
5807 case IA64_OPND_IMM8M1U4
:
5808 case IA64_OPND_IMM8M1U8
:
5809 case IA64_OPND_IMM9a
:
5810 case IA64_OPND_IMM9b
:
5811 bits
= operand_width (idesc
->operands
[index
]);
5812 if (relocatable
&& (e
->X_op
== O_symbol
5813 || e
->X_op
== O_subtract
5814 || e
->X_op
== O_pseudo_fixup
))
5816 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5818 if (idesc
->operands
[index
] == IA64_OPND_IMM14
)
5819 fix
->code
= BFD_RELOC_IA64_IMM14
;
5821 fix
->code
= BFD_RELOC_IA64_IMM22
;
5823 if (e
->X_op
!= O_subtract
)
5825 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5826 if (e
->X_op
== O_pseudo_fixup
)
5830 fix
->opnd
= idesc
->operands
[index
];
5833 ++CURR_SLOT
.num_fixups
;
5834 return OPERAND_MATCH
;
5836 else if (e
->X_op
!= O_constant
5837 && ! (e
->X_op
== O_big
&& opnd
== IA64_OPND_IMM8M1U8
))
5838 return OPERAND_MISMATCH
;
5840 if (opnd
== IA64_OPND_IMM8M1U4
)
5842 /* Zero is not valid for unsigned compares that take an adjusted
5843 constant immediate range. */
5844 if (e
->X_add_number
== 0)
5845 return OPERAND_OUT_OF_RANGE
;
5847 /* Sign-extend 32-bit unsigned numbers, so that the following range
5848 checks will work. */
5849 val
= e
->X_add_number
;
5850 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5851 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5852 val
= ((val
<< 32) >> 32);
5854 /* Check for 0x100000000. This is valid because
5855 0x100000000-1 is the same as ((uint32_t) -1). */
5856 if (val
== ((bfd_signed_vma
) 1 << 32))
5857 return OPERAND_MATCH
;
5861 else if (opnd
== IA64_OPND_IMM8M1U8
)
5863 /* Zero is not valid for unsigned compares that take an adjusted
5864 constant immediate range. */
5865 if (e
->X_add_number
== 0)
5866 return OPERAND_OUT_OF_RANGE
;
5868 /* Check for 0x10000000000000000. */
5869 if (e
->X_op
== O_big
)
5871 if (generic_bignum
[0] == 0
5872 && generic_bignum
[1] == 0
5873 && generic_bignum
[2] == 0
5874 && generic_bignum
[3] == 0
5875 && generic_bignum
[4] == 1)
5876 return OPERAND_MATCH
;
5878 return OPERAND_OUT_OF_RANGE
;
5881 val
= e
->X_add_number
- 1;
5883 else if (opnd
== IA64_OPND_IMM8M1
)
5884 val
= e
->X_add_number
- 1;
5885 else if (opnd
== IA64_OPND_IMM8U4
)
5887 /* Sign-extend 32-bit unsigned numbers, so that the following range
5888 checks will work. */
5889 val
= e
->X_add_number
;
5890 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5891 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5892 val
= ((val
<< 32) >> 32);
5895 val
= e
->X_add_number
;
5897 if ((val
>= 0 && (bfd_vma
) val
< ((bfd_vma
) 1 << (bits
- 1)))
5898 || (val
< 0 && (bfd_vma
) -val
<= ((bfd_vma
) 1 << (bits
- 1))))
5899 return OPERAND_MATCH
;
5901 return OPERAND_OUT_OF_RANGE
;
5903 case IA64_OPND_INC3
:
5904 /* +/- 1, 4, 8, 16 */
5905 val
= e
->X_add_number
;
5908 if (e
->X_op
== O_constant
)
5910 if ((val
== 1 || val
== 4 || val
== 8 || val
== 16))
5911 return OPERAND_MATCH
;
5913 return OPERAND_OUT_OF_RANGE
;
5917 case IA64_OPND_TGT25
:
5918 case IA64_OPND_TGT25b
:
5919 case IA64_OPND_TGT25c
:
5920 case IA64_OPND_TGT64
:
5921 if (e
->X_op
== O_symbol
)
5923 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5924 if (opnd
== IA64_OPND_TGT25
)
5925 fix
->code
= BFD_RELOC_IA64_PCREL21F
;
5926 else if (opnd
== IA64_OPND_TGT25b
)
5927 fix
->code
= BFD_RELOC_IA64_PCREL21M
;
5928 else if (opnd
== IA64_OPND_TGT25c
)
5929 fix
->code
= BFD_RELOC_IA64_PCREL21B
;
5930 else if (opnd
== IA64_OPND_TGT64
)
5931 fix
->code
= BFD_RELOC_IA64_PCREL60B
;
5935 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5936 fix
->opnd
= idesc
->operands
[index
];
5939 ++CURR_SLOT
.num_fixups
;
5940 return OPERAND_MATCH
;
5942 case IA64_OPND_TAG13
:
5943 case IA64_OPND_TAG13b
:
5947 return OPERAND_MATCH
;
5950 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5951 /* There are no external relocs for TAG13/TAG13b fields, so we
5952 create a dummy reloc. This will not live past md_apply_fix3. */
5953 fix
->code
= BFD_RELOC_UNUSED
;
5954 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5955 fix
->opnd
= idesc
->operands
[index
];
5958 ++CURR_SLOT
.num_fixups
;
5959 return OPERAND_MATCH
;
5966 case IA64_OPND_LDXMOV
:
5967 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5968 fix
->code
= BFD_RELOC_IA64_LDXMOV
;
5969 fix
->opnd
= idesc
->operands
[index
];
5972 ++CURR_SLOT
.num_fixups
;
5973 return OPERAND_MATCH
;
5978 return OPERAND_MISMATCH
;
5987 memset (e
, 0, sizeof (*e
));
5990 if (*input_line_pointer
!= '}')
5992 sep
= *input_line_pointer
++;
5996 if (!md
.manual_bundling
)
5997 as_warn ("Found '}' when manual bundling is off");
5999 CURR_SLOT
.manual_bundling_off
= 1;
6000 md
.manual_bundling
= 0;
6006 /* Returns the next entry in the opcode table that matches the one in
6007 IDESC, and frees the entry in IDESC. If no matching entry is
6008 found, NULL is returned instead. */
6010 static struct ia64_opcode
*
6011 get_next_opcode (struct ia64_opcode
*idesc
)
6013 struct ia64_opcode
*next
= ia64_find_next_opcode (idesc
);
6014 ia64_free_opcode (idesc
);
6018 /* Parse the operands for the opcode and find the opcode variant that
6019 matches the specified operands, or NULL if no match is possible. */
6021 static struct ia64_opcode
*
6022 parse_operands (idesc
)
6023 struct ia64_opcode
*idesc
;
6025 int i
= 0, highest_unmatched_operand
, num_operands
= 0, num_outputs
= 0;
6026 int error_pos
, out_of_range_pos
, curr_out_of_range_pos
, sep
= 0;
6029 enum ia64_opnd expected_operand
= IA64_OPND_NIL
;
6030 enum operand_match_result result
;
6032 char *first_arg
= 0, *end
, *saved_input_pointer
;
6035 assert (strlen (idesc
->name
) <= 128);
6037 strcpy (mnemonic
, idesc
->name
);
6038 if (idesc
->operands
[2] == IA64_OPND_SOF
6039 || idesc
->operands
[1] == IA64_OPND_SOF
)
6041 /* To make the common idiom "alloc loc?=ar.pfs,0,1,0,0" work, we
6042 can't parse the first operand until we have parsed the
6043 remaining operands of the "alloc" instruction. */
6045 first_arg
= input_line_pointer
;
6046 end
= strchr (input_line_pointer
, '=');
6049 as_bad ("Expected separator `='");
6052 input_line_pointer
= end
+ 1;
6059 if (i
< NELEMS (CURR_SLOT
.opnd
))
6061 sep
= parse_operand (CURR_SLOT
.opnd
+ i
);
6062 if (CURR_SLOT
.opnd
[i
].X_op
== O_absent
)
6069 sep
= parse_operand (&dummy
);
6070 if (dummy
.X_op
== O_absent
)
6076 if (sep
!= '=' && sep
!= ',')
6081 if (num_outputs
> 0)
6082 as_bad ("Duplicate equal sign (=) in instruction");
6084 num_outputs
= i
+ 1;
6089 as_bad ("Illegal operand separator `%c'", sep
);
6093 if (idesc
->operands
[2] == IA64_OPND_SOF
6094 || idesc
->operands
[1] == IA64_OPND_SOF
)
6096 /* map alloc r1=ar.pfs,i,l,o,r to alloc r1=ar.pfs,(i+l+o),(i+l),r */
6097 know (strcmp (idesc
->name
, "alloc") == 0);
6098 i
= (CURR_SLOT
.opnd
[1].X_op
== O_register
6099 && CURR_SLOT
.opnd
[1].X_add_number
== REG_AR
+ AR_PFS
) ? 2 : 1;
6100 if (num_operands
== i
+ 3 /* first_arg not included in this count! */
6101 && CURR_SLOT
.opnd
[i
].X_op
== O_constant
6102 && CURR_SLOT
.opnd
[i
+ 1].X_op
== O_constant
6103 && CURR_SLOT
.opnd
[i
+ 2].X_op
== O_constant
6104 && CURR_SLOT
.opnd
[i
+ 3].X_op
== O_constant
)
6106 sof
= set_regstack (CURR_SLOT
.opnd
[i
].X_add_number
,
6107 CURR_SLOT
.opnd
[i
+ 1].X_add_number
,
6108 CURR_SLOT
.opnd
[i
+ 2].X_add_number
,
6109 CURR_SLOT
.opnd
[i
+ 3].X_add_number
);
6111 /* now we can parse the first arg: */
6112 saved_input_pointer
= input_line_pointer
;
6113 input_line_pointer
= first_arg
;
6114 sep
= parse_operand (CURR_SLOT
.opnd
+ 0);
6116 --num_outputs
; /* force error */
6117 input_line_pointer
= saved_input_pointer
;
6119 CURR_SLOT
.opnd
[i
].X_add_number
= sof
;
6120 CURR_SLOT
.opnd
[i
+ 1].X_add_number
6121 = sof
- CURR_SLOT
.opnd
[i
+ 2].X_add_number
;
6122 CURR_SLOT
.opnd
[i
+ 2] = CURR_SLOT
.opnd
[i
+ 3];
6126 highest_unmatched_operand
= -4;
6127 curr_out_of_range_pos
= -1;
6129 for (; idesc
; idesc
= get_next_opcode (idesc
))
6131 if (num_outputs
!= idesc
->num_outputs
)
6132 continue; /* mismatch in # of outputs */
6133 if (highest_unmatched_operand
< 0)
6134 highest_unmatched_operand
|= 1;
6135 if (num_operands
> NELEMS (idesc
->operands
)
6136 || (num_operands
< NELEMS (idesc
->operands
)
6137 && idesc
->operands
[num_operands
])
6138 || (num_operands
> 0 && !idesc
->operands
[num_operands
- 1]))
6139 continue; /* mismatch in number of arguments */
6140 if (highest_unmatched_operand
< 0)
6141 highest_unmatched_operand
|= 2;
6143 CURR_SLOT
.num_fixups
= 0;
6145 /* Try to match all operands. If we see an out-of-range operand,
6146 then continue trying to match the rest of the operands, since if
6147 the rest match, then this idesc will give the best error message. */
6149 out_of_range_pos
= -1;
6150 for (i
= 0; i
< num_operands
&& idesc
->operands
[i
]; ++i
)
6152 result
= operand_match (idesc
, i
, CURR_SLOT
.opnd
+ i
);
6153 if (result
!= OPERAND_MATCH
)
6155 if (result
!= OPERAND_OUT_OF_RANGE
)
6157 if (out_of_range_pos
< 0)
6158 /* remember position of the first out-of-range operand: */
6159 out_of_range_pos
= i
;
6163 /* If we did not match all operands, or if at least one operand was
6164 out-of-range, then this idesc does not match. Keep track of which
6165 idesc matched the most operands before failing. If we have two
6166 idescs that failed at the same position, and one had an out-of-range
6167 operand, then prefer the out-of-range operand. Thus if we have
6168 "add r0=0x1000000,r1" we get an error saying the constant is out
6169 of range instead of an error saying that the constant should have been
6172 if (i
!= num_operands
|| out_of_range_pos
>= 0)
6174 if (i
> highest_unmatched_operand
6175 || (i
== highest_unmatched_operand
6176 && out_of_range_pos
> curr_out_of_range_pos
))
6178 highest_unmatched_operand
= i
;
6179 if (out_of_range_pos
>= 0)
6181 expected_operand
= idesc
->operands
[out_of_range_pos
];
6182 error_pos
= out_of_range_pos
;
6186 expected_operand
= idesc
->operands
[i
];
6189 curr_out_of_range_pos
= out_of_range_pos
;
6198 if (expected_operand
)
6199 as_bad ("Operand %u of `%s' should be %s",
6200 error_pos
+ 1, mnemonic
,
6201 elf64_ia64_operands
[expected_operand
].desc
);
6202 else if (highest_unmatched_operand
< 0 && !(highest_unmatched_operand
& 1))
6203 as_bad ("Wrong number of output operands");
6204 else if (highest_unmatched_operand
< 0 && !(highest_unmatched_operand
& 2))
6205 as_bad ("Wrong number of input operands");
6207 as_bad ("Operand mismatch");
6211 /* Check that the instruction doesn't use
6212 - r0, f0, or f1 as output operands
6213 - the same predicate twice as output operands
6214 - r0 as address of a base update load or store
6215 - the same GR as output and address of a base update load
6216 - two even- or two odd-numbered FRs as output operands of a floating
6217 point parallel load.
6218 At most two (conflicting) output (or output-like) operands can exist,
6219 (floating point parallel loads have three outputs, but the base register,
6220 if updated, cannot conflict with the actual outputs). */
6222 for (i
= 0; i
< num_operands
; ++i
)
6227 switch (idesc
->operands
[i
])
6232 if (i
< num_outputs
)
6234 if (CURR_SLOT
.opnd
[i
].X_add_number
== REG_GR
)
6237 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6239 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6244 if (i
< num_outputs
)
6247 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6249 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6256 if (i
< num_outputs
)
6258 if (CURR_SLOT
.opnd
[i
].X_add_number
>= REG_FR
6259 && CURR_SLOT
.opnd
[i
].X_add_number
<= REG_FR
+ 1)
6262 regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
6265 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6267 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6271 if (idesc
->flags
& IA64_OPCODE_POSTINC
)
6273 if (CURR_SLOT
.opnd
[i
].X_add_number
== REG_GR
)
6276 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6278 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6289 as_warn ("Invalid use of `%c%d' as output operand", reg_class
, regno
);
6292 as_warn ("Invalid use of `r%d' as base update address operand", regno
);
6298 if (reg1
>= REG_GR
&& reg1
<= REG_GR
+ 127)
6303 else if (reg1
>= REG_P
&& reg1
<= REG_P
+ 63)
6308 else if (reg1
>= REG_FR
&& reg1
<= REG_FR
+ 127)
6316 as_warn ("Invalid duplicate use of `%c%d'", reg_class
, reg1
);
6318 else if (((reg1
>= REG_FR
&& reg1
<= REG_FR
+ 31
6319 && reg2
>= REG_FR
&& reg2
<= REG_FR
+ 31)
6320 || (reg1
>= REG_FR
+ 32 && reg1
<= REG_FR
+ 127
6321 && reg2
>= REG_FR
+ 32 && reg2
<= REG_FR
+ 127))
6322 && ! ((reg1
^ reg2
) & 1))
6323 as_warn ("Invalid simultaneous use of `f%d' and `f%d'",
6324 reg1
- REG_FR
, reg2
- REG_FR
);
6325 else if ((reg1
>= REG_FR
&& reg1
<= REG_FR
+ 31
6326 && reg2
>= REG_FR
+ 32 && reg2
<= REG_FR
+ 127)
6327 || (reg1
>= REG_FR
+ 32 && reg1
<= REG_FR
+ 127
6328 && reg2
>= REG_FR
&& reg2
<= REG_FR
+ 31))
6329 as_warn ("Dangerous simultaneous use of `f%d' and `f%d'",
6330 reg1
- REG_FR
, reg2
- REG_FR
);
6335 build_insn (slot
, insnp
)
6339 const struct ia64_operand
*odesc
, *o2desc
;
6340 struct ia64_opcode
*idesc
= slot
->idesc
;
6346 insn
= idesc
->opcode
| slot
->qp_regno
;
6348 for (i
= 0; i
< NELEMS (idesc
->operands
) && idesc
->operands
[i
]; ++i
)
6350 if (slot
->opnd
[i
].X_op
== O_register
6351 || slot
->opnd
[i
].X_op
== O_constant
6352 || slot
->opnd
[i
].X_op
== O_index
)
6353 val
= slot
->opnd
[i
].X_add_number
;
6354 else if (slot
->opnd
[i
].X_op
== O_big
)
6356 /* This must be the value 0x10000000000000000. */
6357 assert (idesc
->operands
[i
] == IA64_OPND_IMM8M1U8
);
6363 switch (idesc
->operands
[i
])
6365 case IA64_OPND_IMMU64
:
6366 *insnp
++ = (val
>> 22) & 0x1ffffffffffLL
;
6367 insn
|= (((val
& 0x7f) << 13) | (((val
>> 7) & 0x1ff) << 27)
6368 | (((val
>> 16) & 0x1f) << 22) | (((val
>> 21) & 0x1) << 21)
6369 | (((val
>> 63) & 0x1) << 36));
6372 case IA64_OPND_IMMU62
:
6373 val
&= 0x3fffffffffffffffULL
;
6374 if (val
!= slot
->opnd
[i
].X_add_number
)
6375 as_warn (_("Value truncated to 62 bits"));
6376 *insnp
++ = (val
>> 21) & 0x1ffffffffffLL
;
6377 insn
|= (((val
& 0xfffff) << 6) | (((val
>> 20) & 0x1) << 36));
6380 case IA64_OPND_TGT64
:
6382 *insnp
++ = ((val
>> 20) & 0x7fffffffffLL
) << 2;
6383 insn
|= ((((val
>> 59) & 0x1) << 36)
6384 | (((val
>> 0) & 0xfffff) << 13));
6415 case IA64_OPND_R3_2
:
6416 case IA64_OPND_CPUID_R3
:
6417 case IA64_OPND_DBR_R3
:
6418 case IA64_OPND_DTR_R3
:
6419 case IA64_OPND_ITR_R3
:
6420 case IA64_OPND_IBR_R3
:
6422 case IA64_OPND_MSR_R3
:
6423 case IA64_OPND_PKR_R3
:
6424 case IA64_OPND_PMC_R3
:
6425 case IA64_OPND_PMD_R3
:
6426 case IA64_OPND_RR_R3
:
6434 odesc
= elf64_ia64_operands
+ idesc
->operands
[i
];
6435 err
= (*odesc
->insert
) (odesc
, val
, &insn
);
6437 as_bad_where (slot
->src_file
, slot
->src_line
,
6438 "Bad operand value: %s", err
);
6439 if (idesc
->flags
& IA64_OPCODE_PSEUDO
)
6441 if ((idesc
->flags
& IA64_OPCODE_F2_EQ_F3
)
6442 && odesc
== elf64_ia64_operands
+ IA64_OPND_F3
)
6444 o2desc
= elf64_ia64_operands
+ IA64_OPND_F2
;
6445 (*o2desc
->insert
) (o2desc
, val
, &insn
);
6447 if ((idesc
->flags
& IA64_OPCODE_LEN_EQ_64MCNT
)
6448 && (odesc
== elf64_ia64_operands
+ IA64_OPND_CPOS6a
6449 || odesc
== elf64_ia64_operands
+ IA64_OPND_POS6
))
6451 o2desc
= elf64_ia64_operands
+ IA64_OPND_LEN6
;
6452 (*o2desc
->insert
) (o2desc
, 64 - val
, &insn
);
6462 int manual_bundling_off
= 0, manual_bundling
= 0;
6463 enum ia64_unit required_unit
, insn_unit
= 0;
6464 enum ia64_insn_type type
[3], insn_type
;
6465 unsigned int template, orig_template
;
6466 bfd_vma insn
[3] = { -1, -1, -1 };
6467 struct ia64_opcode
*idesc
;
6468 int end_of_insn_group
= 0, user_template
= -1;
6469 int n
, i
, j
, first
, curr
, last_slot
;
6470 unw_rec_list
*ptr
, *last_ptr
, *end_ptr
;
6471 bfd_vma t0
= 0, t1
= 0;
6472 struct label_fix
*lfix
;
6473 struct insn_fix
*ifix
;
6479 first
= (md
.curr_slot
+ NUM_SLOTS
- md
.num_slots_in_use
) % NUM_SLOTS
;
6480 know (first
>= 0 & first
< NUM_SLOTS
);
6481 n
= MIN (3, md
.num_slots_in_use
);
6483 /* Determine template: user user_template if specified, best match
6486 if (md
.slot
[first
].user_template
>= 0)
6487 user_template
= template = md
.slot
[first
].user_template
;
6490 /* Auto select appropriate template. */
6491 memset (type
, 0, sizeof (type
));
6493 for (i
= 0; i
< n
; ++i
)
6495 if (md
.slot
[curr
].label_fixups
&& i
!= 0)
6497 type
[i
] = md
.slot
[curr
].idesc
->type
;
6498 curr
= (curr
+ 1) % NUM_SLOTS
;
6500 template = best_template
[type
[0]][type
[1]][type
[2]];
6503 /* initialize instructions with appropriate nops: */
6504 for (i
= 0; i
< 3; ++i
)
6505 insn
[i
] = nop
[ia64_templ_desc
[template].exec_unit
[i
]];
6509 /* Check to see if this bundle is at an offset that is a multiple of 16-bytes
6510 from the start of the frag. */
6511 addr_mod
= frag_now_fix () & 15;
6512 if (frag_now
->has_code
&& frag_now
->insn_addr
!= addr_mod
)
6513 as_bad (_("instruction address is not a multiple of 16"));
6514 frag_now
->insn_addr
= addr_mod
;
6515 frag_now
->has_code
= 1;
6517 /* now fill in slots with as many insns as possible: */
6519 idesc
= md
.slot
[curr
].idesc
;
6520 end_of_insn_group
= 0;
6522 for (i
= 0; i
< 3 && md
.num_slots_in_use
> 0; ++i
)
6524 /* If we have unwind records, we may need to update some now. */
6525 ptr
= md
.slot
[curr
].unwind_record
;
6528 /* Find the last prologue/body record in the list for the current
6529 insn, and set the slot number for all records up to that point.
6530 This needs to be done now, because prologue/body records refer to
6531 the current point, not the point after the instruction has been
6532 issued. This matters because there may have been nops emitted
6533 meanwhile. Any non-prologue non-body record followed by a
6534 prologue/body record must also refer to the current point. */
6536 end_ptr
= md
.slot
[(curr
+ 1) % NUM_SLOTS
].unwind_record
;
6537 for (; ptr
!= end_ptr
; ptr
= ptr
->next
)
6538 if (ptr
->r
.type
== prologue
|| ptr
->r
.type
== prologue_gr
6539 || ptr
->r
.type
== body
)
6543 /* Make last_ptr point one after the last prologue/body
6545 last_ptr
= last_ptr
->next
;
6546 for (ptr
= md
.slot
[curr
].unwind_record
; ptr
!= last_ptr
;
6549 ptr
->slot_number
= (unsigned long) f
+ i
;
6550 ptr
->slot_frag
= frag_now
;
6552 /* Remove the initialized records, so that we won't accidentally
6553 update them again if we insert a nop and continue. */
6554 md
.slot
[curr
].unwind_record
= last_ptr
;
6558 manual_bundling_off
= md
.slot
[curr
].manual_bundling_off
;
6559 if (md
.slot
[curr
].manual_bundling_on
)
6562 manual_bundling
= 1;
6564 break; /* Need to start a new bundle. */
6567 /* If this instruction specifies a template, then it must be the first
6568 instruction of a bundle. */
6569 if (curr
!= first
&& md
.slot
[curr
].user_template
>= 0)
6572 if (idesc
->flags
& IA64_OPCODE_SLOT2
)
6574 if (manual_bundling
&& !manual_bundling_off
)
6576 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6577 "`%s' must be last in bundle", idesc
->name
);
6579 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6583 if (idesc
->flags
& IA64_OPCODE_LAST
)
6586 unsigned int required_template
;
6588 /* If we need a stop bit after an M slot, our only choice is
6589 template 5 (M;;MI). If we need a stop bit after a B
6590 slot, our only choice is to place it at the end of the
6591 bundle, because the only available templates are MIB,
6592 MBB, BBB, MMB, and MFB. We don't handle anything other
6593 than M and B slots because these are the only kind of
6594 instructions that can have the IA64_OPCODE_LAST bit set. */
6595 required_template
= template;
6596 switch (idesc
->type
)
6600 required_template
= 5;
6608 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6609 "Internal error: don't know how to force %s to end"
6610 "of instruction group", idesc
->name
);
6615 && (i
> required_slot
6616 || (required_slot
== 2 && !manual_bundling_off
)
6617 || (user_template
>= 0
6618 /* Changing from MMI to M;MI is OK. */
6619 && (template ^ required_template
) > 1)))
6621 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6622 "`%s' must be last in instruction group",
6624 if (i
< 2 && required_slot
== 2 && !manual_bundling_off
)
6625 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6627 if (required_slot
< i
)
6628 /* Can't fit this instruction. */
6632 if (required_template
!= template)
6634 /* If we switch the template, we need to reset the NOPs
6635 after slot i. The slot-types of the instructions ahead
6636 of i never change, so we don't need to worry about
6637 changing NOPs in front of this slot. */
6638 for (j
= i
; j
< 3; ++j
)
6639 insn
[j
] = nop
[ia64_templ_desc
[required_template
].exec_unit
[j
]];
6641 template = required_template
;
6643 if (curr
!= first
&& md
.slot
[curr
].label_fixups
)
6645 if (manual_bundling
)
6647 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6648 "Label must be first in a bundle");
6649 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6651 /* This insn must go into the first slot of a bundle. */
6655 if (end_of_insn_group
&& md
.num_slots_in_use
>= 1)
6657 /* We need an instruction group boundary in the middle of a
6658 bundle. See if we can switch to an other template with
6659 an appropriate boundary. */
6661 orig_template
= template;
6662 if (i
== 1 && (user_template
== 4
6663 || (user_template
< 0
6664 && (ia64_templ_desc
[template].exec_unit
[0]
6668 end_of_insn_group
= 0;
6670 else if (i
== 2 && (user_template
== 0
6671 || (user_template
< 0
6672 && (ia64_templ_desc
[template].exec_unit
[1]
6674 /* This test makes sure we don't switch the template if
6675 the next instruction is one that needs to be first in
6676 an instruction group. Since all those instructions are
6677 in the M group, there is no way such an instruction can
6678 fit in this bundle even if we switch the template. The
6679 reason we have to check for this is that otherwise we
6680 may end up generating "MI;;I M.." which has the deadly
6681 effect that the second M instruction is no longer the
6682 first in the group! --davidm 99/12/16 */
6683 && (idesc
->flags
& IA64_OPCODE_FIRST
) == 0)
6686 end_of_insn_group
= 0;
6689 && user_template
== 0
6690 && !(idesc
->flags
& IA64_OPCODE_FIRST
))
6691 /* Use the next slot. */
6693 else if (curr
!= first
)
6694 /* can't fit this insn */
6697 if (template != orig_template
)
6698 /* if we switch the template, we need to reset the NOPs
6699 after slot i. The slot-types of the instructions ahead
6700 of i never change, so we don't need to worry about
6701 changing NOPs in front of this slot. */
6702 for (j
= i
; j
< 3; ++j
)
6703 insn
[j
] = nop
[ia64_templ_desc
[template].exec_unit
[j
]];
6705 required_unit
= ia64_templ_desc
[template].exec_unit
[i
];
6707 /* resolve dynamic opcodes such as "break", "hint", and "nop": */
6708 if (idesc
->type
== IA64_TYPE_DYN
)
6710 enum ia64_opnd opnd1
, opnd2
;
6712 if ((strcmp (idesc
->name
, "nop") == 0)
6713 || (strcmp (idesc
->name
, "break") == 0))
6714 insn_unit
= required_unit
;
6715 else if (strcmp (idesc
->name
, "hint") == 0)
6717 insn_unit
= required_unit
;
6718 if (required_unit
== IA64_UNIT_B
)
6724 case hint_b_warning
:
6725 as_warn ("hint in B unit may be treated as nop");
6728 /* When manual bundling is off and there is no
6729 user template, we choose a different unit so
6730 that hint won't go into the current slot. We
6731 will fill the current bundle with nops and
6732 try to put hint into the next bundle. */
6733 if (!manual_bundling
&& user_template
< 0)
6734 insn_unit
= IA64_UNIT_I
;
6736 as_bad ("hint in B unit can't be used");
6741 else if (strcmp (idesc
->name
, "chk.s") == 0
6742 || strcmp (idesc
->name
, "mov") == 0)
6744 insn_unit
= IA64_UNIT_M
;
6745 if (required_unit
== IA64_UNIT_I
6746 || (required_unit
== IA64_UNIT_F
&& template == 6))
6747 insn_unit
= IA64_UNIT_I
;
6750 as_fatal ("emit_one_bundle: unexpected dynamic op");
6752 sprintf (mnemonic
, "%s.%c", idesc
->name
, "?imbfxx"[insn_unit
]);
6753 opnd1
= idesc
->operands
[0];
6754 opnd2
= idesc
->operands
[1];
6755 ia64_free_opcode (idesc
);
6756 idesc
= ia64_find_opcode (mnemonic
);
6757 /* moves to/from ARs have collisions */
6758 if (opnd1
== IA64_OPND_AR3
|| opnd2
== IA64_OPND_AR3
)
6760 while (idesc
!= NULL
6761 && (idesc
->operands
[0] != opnd1
6762 || idesc
->operands
[1] != opnd2
))
6763 idesc
= get_next_opcode (idesc
);
6765 md
.slot
[curr
].idesc
= idesc
;
6769 insn_type
= idesc
->type
;
6770 insn_unit
= IA64_UNIT_NIL
;
6774 if (required_unit
== IA64_UNIT_I
|| required_unit
== IA64_UNIT_M
)
6775 insn_unit
= required_unit
;
6777 case IA64_TYPE_X
: insn_unit
= IA64_UNIT_L
; break;
6778 case IA64_TYPE_I
: insn_unit
= IA64_UNIT_I
; break;
6779 case IA64_TYPE_M
: insn_unit
= IA64_UNIT_M
; break;
6780 case IA64_TYPE_B
: insn_unit
= IA64_UNIT_B
; break;
6781 case IA64_TYPE_F
: insn_unit
= IA64_UNIT_F
; break;
6786 if (insn_unit
!= required_unit
)
6787 continue; /* Try next slot. */
6789 if (debug_type
== DEBUG_DWARF2
|| md
.slot
[curr
].loc_directive_seen
)
6791 bfd_vma addr
= frag_now
->fr_address
+ frag_now_fix () - 16 + i
;
6793 md
.slot
[curr
].loc_directive_seen
= 0;
6794 dwarf2_gen_line_info (addr
, &md
.slot
[curr
].debug_line
);
6797 build_insn (md
.slot
+ curr
, insn
+ i
);
6799 ptr
= md
.slot
[curr
].unwind_record
;
6802 /* Set slot numbers for all remaining unwind records belonging to the
6803 current insn. There can not be any prologue/body unwind records
6805 end_ptr
= md
.slot
[(curr
+ 1) % NUM_SLOTS
].unwind_record
;
6806 for (; ptr
!= end_ptr
; ptr
= ptr
->next
)
6808 ptr
->slot_number
= (unsigned long) f
+ i
;
6809 ptr
->slot_frag
= frag_now
;
6811 md
.slot
[curr
].unwind_record
= NULL
;
6814 if (required_unit
== IA64_UNIT_L
)
6817 /* skip one slot for long/X-unit instructions */
6820 --md
.num_slots_in_use
;
6823 /* now is a good time to fix up the labels for this insn: */
6824 for (lfix
= md
.slot
[curr
].label_fixups
; lfix
; lfix
= lfix
->next
)
6826 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16);
6827 symbol_set_frag (lfix
->sym
, frag_now
);
6829 /* and fix up the tags also. */
6830 for (lfix
= md
.slot
[curr
].tag_fixups
; lfix
; lfix
= lfix
->next
)
6832 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16 + i
);
6833 symbol_set_frag (lfix
->sym
, frag_now
);
6836 for (j
= 0; j
< md
.slot
[curr
].num_fixups
; ++j
)
6838 ifix
= md
.slot
[curr
].fixup
+ j
;
6839 fix
= fix_new_exp (frag_now
, frag_now_fix () - 16 + i
, 8,
6840 &ifix
->expr
, ifix
->is_pcrel
, ifix
->code
);
6841 fix
->tc_fix_data
.opnd
= ifix
->opnd
;
6842 fix
->fx_plt
= (fix
->fx_r_type
== BFD_RELOC_IA64_PLTOFF22
);
6843 fix
->fx_file
= md
.slot
[curr
].src_file
;
6844 fix
->fx_line
= md
.slot
[curr
].src_line
;
6847 end_of_insn_group
= md
.slot
[curr
].end_of_insn_group
;
6850 ia64_free_opcode (md
.slot
[curr
].idesc
);
6851 memset (md
.slot
+ curr
, 0, sizeof (md
.slot
[curr
]));
6852 md
.slot
[curr
].user_template
= -1;
6854 if (manual_bundling_off
)
6856 manual_bundling
= 0;
6859 curr
= (curr
+ 1) % NUM_SLOTS
;
6860 idesc
= md
.slot
[curr
].idesc
;
6862 if (manual_bundling
> 0)
6864 if (md
.num_slots_in_use
> 0)
6867 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6868 "`%s' does not fit into bundle", idesc
->name
);
6869 else if (last_slot
< 0)
6871 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6872 "`%s' does not fit into %s template",
6873 idesc
->name
, ia64_templ_desc
[template].name
);
6874 /* Drop first insn so we don't livelock. */
6875 --md
.num_slots_in_use
;
6876 know (curr
== first
);
6877 ia64_free_opcode (md
.slot
[curr
].idesc
);
6878 memset (md
.slot
+ curr
, 0, sizeof (md
.slot
[curr
]));
6879 md
.slot
[curr
].user_template
= -1;
6887 else if (last_slot
== 0)
6888 where
= "slots 2 or 3";
6891 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6892 "`%s' can't go in %s of %s template",
6893 idesc
->name
, where
, ia64_templ_desc
[template].name
);
6897 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6898 "Missing '}' at end of file");
6900 know (md
.num_slots_in_use
< NUM_SLOTS
);
6902 t0
= end_of_insn_group
| (template << 1) | (insn
[0] << 5) | (insn
[1] << 46);
6903 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
6905 number_to_chars_littleendian (f
+ 0, t0
, 8);
6906 number_to_chars_littleendian (f
+ 8, t1
, 8);
6910 unwind
.list
->next_slot_number
= (unsigned long) f
+ 16;
6911 unwind
.list
->next_slot_frag
= frag_now
;
6916 md_parse_option (c
, arg
)
6923 /* Switches from the Intel assembler. */
6925 if (strcmp (arg
, "ilp64") == 0
6926 || strcmp (arg
, "lp64") == 0
6927 || strcmp (arg
, "p64") == 0)
6929 md
.flags
|= EF_IA_64_ABI64
;
6931 else if (strcmp (arg
, "ilp32") == 0)
6933 md
.flags
&= ~EF_IA_64_ABI64
;
6935 else if (strcmp (arg
, "le") == 0)
6937 md
.flags
&= ~EF_IA_64_BE
;
6938 default_big_endian
= 0;
6940 else if (strcmp (arg
, "be") == 0)
6942 md
.flags
|= EF_IA_64_BE
;
6943 default_big_endian
= 1;
6945 else if (strncmp (arg
, "unwind-check=", 13) == 0)
6948 if (strcmp (arg
, "warning") == 0)
6949 md
.unwind_check
= unwind_check_warning
;
6950 else if (strcmp (arg
, "error") == 0)
6951 md
.unwind_check
= unwind_check_error
;
6955 else if (strncmp (arg
, "hint.b=", 7) == 0)
6958 if (strcmp (arg
, "ok") == 0)
6959 md
.hint_b
= hint_b_ok
;
6960 else if (strcmp (arg
, "warning") == 0)
6961 md
.hint_b
= hint_b_warning
;
6962 else if (strcmp (arg
, "error") == 0)
6963 md
.hint_b
= hint_b_error
;
6967 else if (strncmp (arg
, "tune=", 5) == 0)
6970 if (strcmp (arg
, "itanium1") == 0)
6972 else if (strcmp (arg
, "itanium2") == 0)
6982 if (strcmp (arg
, "so") == 0)
6984 /* Suppress signon message. */
6986 else if (strcmp (arg
, "pi") == 0)
6988 /* Reject privileged instructions. FIXME */
6990 else if (strcmp (arg
, "us") == 0)
6992 /* Allow union of signed and unsigned range. FIXME */
6994 else if (strcmp (arg
, "close_fcalls") == 0)
6996 /* Do not resolve global function calls. */
7003 /* temp[="prefix"] Insert temporary labels into the object file
7004 symbol table prefixed by "prefix".
7005 Default prefix is ":temp:".
7010 /* indirect=<tgt> Assume unannotated indirect branches behavior
7011 according to <tgt> --
7012 exit: branch out from the current context (default)
7013 labels: all labels in context may be branch targets
7015 if (strncmp (arg
, "indirect=", 9) != 0)
7020 /* -X conflicts with an ignored option, use -x instead */
7022 if (!arg
|| strcmp (arg
, "explicit") == 0)
7024 /* set default mode to explicit */
7025 md
.default_explicit_mode
= 1;
7028 else if (strcmp (arg
, "auto") == 0)
7030 md
.default_explicit_mode
= 0;
7032 else if (strcmp (arg
, "none") == 0)
7036 else if (strcmp (arg
, "debug") == 0)
7040 else if (strcmp (arg
, "debugx") == 0)
7042 md
.default_explicit_mode
= 1;
7045 else if (strcmp (arg
, "debugn") == 0)
7052 as_bad (_("Unrecognized option '-x%s'"), arg
);
7057 /* nops Print nops statistics. */
7060 /* GNU specific switches for gcc. */
7061 case OPTION_MCONSTANT_GP
:
7062 md
.flags
|= EF_IA_64_CONS_GP
;
7065 case OPTION_MAUTO_PIC
:
7066 md
.flags
|= EF_IA_64_NOFUNCDESC_CONS_GP
;
7077 md_show_usage (stream
)
7082 --mconstant-gp mark output file as using the constant-GP model\n\
7083 (sets ELF header flag EF_IA_64_CONS_GP)\n\
7084 --mauto-pic mark output file as using the constant-GP model\n\
7085 without function descriptors (sets ELF header flag\n\
7086 EF_IA_64_NOFUNCDESC_CONS_GP)\n\
7087 -milp32|-milp64|-mlp64|-mp64 select data model (default -mlp64)\n\
7088 -mle | -mbe select little- or big-endian byte order (default -mle)\n\
7089 -mtune=[itanium1|itanium2]\n\
7090 tune for a specific CPU (default -mtune=itanium2)\n\
7091 -munwind-check=[warning|error]\n\
7092 unwind directive check (default -munwind-check=warning)\n\
7093 -mhint.b=[ok|warning|error]\n\
7094 hint.b check (default -mhint.b=error)\n\
7095 -x | -xexplicit turn on dependency violation checking\n\
7096 -xauto automagically remove dependency violations (default)\n\
7097 -xnone turn off dependency violation checking\n\
7098 -xdebug debug dependency violation checker\n\
7099 -xdebugn debug dependency violation checker but turn off\n\
7100 dependency violation checking\n\
7101 -xdebugx debug dependency violation checker and turn on\n\
7102 dependency violation checking\n"),
7107 ia64_after_parse_args ()
7109 if (debug_type
== DEBUG_STABS
)
7110 as_fatal (_("--gstabs is not supported for ia64"));
7113 /* Return true if TYPE fits in TEMPL at SLOT. */
7116 match (int templ
, int type
, int slot
)
7118 enum ia64_unit unit
;
7121 unit
= ia64_templ_desc
[templ
].exec_unit
[slot
];
7124 case IA64_TYPE_DYN
: result
= 1; break; /* for nop and break */
7126 result
= (unit
== IA64_UNIT_I
|| unit
== IA64_UNIT_M
);
7128 case IA64_TYPE_X
: result
= (unit
== IA64_UNIT_L
); break;
7129 case IA64_TYPE_I
: result
= (unit
== IA64_UNIT_I
); break;
7130 case IA64_TYPE_M
: result
= (unit
== IA64_UNIT_M
); break;
7131 case IA64_TYPE_B
: result
= (unit
== IA64_UNIT_B
); break;
7132 case IA64_TYPE_F
: result
= (unit
== IA64_UNIT_F
); break;
7133 default: result
= 0; break;
7138 /* Add a bit of extra goodness if a nop of type F or B would fit
7139 in TEMPL at SLOT. */
7142 extra_goodness (int templ
, int slot
)
7147 if (slot
== 1 && match (templ
, IA64_TYPE_F
, slot
))
7149 else if (slot
== 2 && match (templ
, IA64_TYPE_B
, slot
))
7155 if (match (templ
, IA64_TYPE_M
, slot
)
7156 || match (templ
, IA64_TYPE_I
, slot
))
7157 /* Favor M- and I-unit NOPs. We definitely want to avoid
7158 F-unit and B-unit may cause split-issue or less-than-optimal
7159 branch-prediction. */
7170 /* This function is called once, at assembler startup time. It sets
7171 up all the tables, etc. that the MD part of the assembler will need
7172 that can be determined before arguments are parsed. */
7176 int i
, j
, k
, t
, total
, ar_base
, cr_base
, goodness
, best
, regnum
, ok
;
7181 md
.explicit_mode
= md
.default_explicit_mode
;
7183 bfd_set_section_alignment (stdoutput
, text_section
, 4);
7185 /* Make sure function pointers get initialized. */
7186 target_big_endian
= -1;
7187 dot_byteorder (default_big_endian
);
7189 alias_hash
= hash_new ();
7190 alias_name_hash
= hash_new ();
7191 secalias_hash
= hash_new ();
7192 secalias_name_hash
= hash_new ();
7194 pseudo_func
[FUNC_DTP_MODULE
].u
.sym
=
7195 symbol_new (".<dtpmod>", undefined_section
, FUNC_DTP_MODULE
,
7196 &zero_address_frag
);
7198 pseudo_func
[FUNC_DTP_RELATIVE
].u
.sym
=
7199 symbol_new (".<dtprel>", undefined_section
, FUNC_DTP_RELATIVE
,
7200 &zero_address_frag
);
7202 pseudo_func
[FUNC_FPTR_RELATIVE
].u
.sym
=
7203 symbol_new (".<fptr>", undefined_section
, FUNC_FPTR_RELATIVE
,
7204 &zero_address_frag
);
7206 pseudo_func
[FUNC_GP_RELATIVE
].u
.sym
=
7207 symbol_new (".<gprel>", undefined_section
, FUNC_GP_RELATIVE
,
7208 &zero_address_frag
);
7210 pseudo_func
[FUNC_LT_RELATIVE
].u
.sym
=
7211 symbol_new (".<ltoff>", undefined_section
, FUNC_LT_RELATIVE
,
7212 &zero_address_frag
);
7214 pseudo_func
[FUNC_LT_RELATIVE_X
].u
.sym
=
7215 symbol_new (".<ltoffx>", undefined_section
, FUNC_LT_RELATIVE_X
,
7216 &zero_address_frag
);
7218 pseudo_func
[FUNC_PC_RELATIVE
].u
.sym
=
7219 symbol_new (".<pcrel>", undefined_section
, FUNC_PC_RELATIVE
,
7220 &zero_address_frag
);
7222 pseudo_func
[FUNC_PLT_RELATIVE
].u
.sym
=
7223 symbol_new (".<pltoff>", undefined_section
, FUNC_PLT_RELATIVE
,
7224 &zero_address_frag
);
7226 pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
=
7227 symbol_new (".<secrel>", undefined_section
, FUNC_SEC_RELATIVE
,
7228 &zero_address_frag
);
7230 pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
=
7231 symbol_new (".<segrel>", undefined_section
, FUNC_SEG_RELATIVE
,
7232 &zero_address_frag
);
7234 pseudo_func
[FUNC_TP_RELATIVE
].u
.sym
=
7235 symbol_new (".<tprel>", undefined_section
, FUNC_TP_RELATIVE
,
7236 &zero_address_frag
);
7238 pseudo_func
[FUNC_LTV_RELATIVE
].u
.sym
=
7239 symbol_new (".<ltv>", undefined_section
, FUNC_LTV_RELATIVE
,
7240 &zero_address_frag
);
7242 pseudo_func
[FUNC_LT_FPTR_RELATIVE
].u
.sym
=
7243 symbol_new (".<ltoff.fptr>", undefined_section
, FUNC_LT_FPTR_RELATIVE
,
7244 &zero_address_frag
);
7246 pseudo_func
[FUNC_LT_DTP_MODULE
].u
.sym
=
7247 symbol_new (".<ltoff.dtpmod>", undefined_section
, FUNC_LT_DTP_MODULE
,
7248 &zero_address_frag
);
7250 pseudo_func
[FUNC_LT_DTP_RELATIVE
].u
.sym
=
7251 symbol_new (".<ltoff.dptrel>", undefined_section
, FUNC_LT_DTP_RELATIVE
,
7252 &zero_address_frag
);
7254 pseudo_func
[FUNC_LT_TP_RELATIVE
].u
.sym
=
7255 symbol_new (".<ltoff.tprel>", undefined_section
, FUNC_LT_TP_RELATIVE
,
7256 &zero_address_frag
);
7258 pseudo_func
[FUNC_IPLT_RELOC
].u
.sym
=
7259 symbol_new (".<iplt>", undefined_section
, FUNC_IPLT_RELOC
,
7260 &zero_address_frag
);
7262 /* Compute the table of best templates. We compute goodness as a
7263 base 4 value, in which each match counts for 3. Match-failures
7264 result in NOPs and we use extra_goodness() to pick the execution
7265 units that are best suited for issuing the NOP. */
7266 for (i
= 0; i
< IA64_NUM_TYPES
; ++i
)
7267 for (j
= 0; j
< IA64_NUM_TYPES
; ++j
)
7268 for (k
= 0; k
< IA64_NUM_TYPES
; ++k
)
7271 for (t
= 0; t
< NELEMS (ia64_templ_desc
); ++t
)
7274 if (match (t
, i
, 0))
7276 if (match (t
, j
, 1))
7278 if (match (t
, k
, 2))
7279 goodness
= 3 + 3 + 3;
7281 goodness
= 3 + 3 + extra_goodness (t
, 2);
7283 else if (match (t
, j
, 2))
7284 goodness
= 3 + 3 + extra_goodness (t
, 1);
7288 goodness
+= extra_goodness (t
, 1);
7289 goodness
+= extra_goodness (t
, 2);
7292 else if (match (t
, i
, 1))
7294 if (match (t
, j
, 2))
7297 goodness
= 3 + extra_goodness (t
, 2);
7299 else if (match (t
, i
, 2))
7300 goodness
= 3 + extra_goodness (t
, 1);
7302 if (goodness
> best
)
7305 best_template
[i
][j
][k
] = t
;
7310 for (i
= 0; i
< NUM_SLOTS
; ++i
)
7311 md
.slot
[i
].user_template
= -1;
7313 md
.pseudo_hash
= hash_new ();
7314 for (i
= 0; i
< NELEMS (pseudo_opcode
); ++i
)
7316 err
= hash_insert (md
.pseudo_hash
, pseudo_opcode
[i
].name
,
7317 (void *) (pseudo_opcode
+ i
));
7319 as_fatal ("ia64.md_begin: can't hash `%s': %s",
7320 pseudo_opcode
[i
].name
, err
);
7323 md
.reg_hash
= hash_new ();
7324 md
.dynreg_hash
= hash_new ();
7325 md
.const_hash
= hash_new ();
7326 md
.entry_hash
= hash_new ();
7328 /* general registers: */
7331 for (i
= 0; i
< total
; ++i
)
7333 sprintf (name
, "r%d", i
- REG_GR
);
7334 md
.regsym
[i
] = declare_register (name
, i
);
7337 /* floating point registers: */
7339 for (; i
< total
; ++i
)
7341 sprintf (name
, "f%d", i
- REG_FR
);
7342 md
.regsym
[i
] = declare_register (name
, i
);
7345 /* application registers: */
7348 for (; i
< total
; ++i
)
7350 sprintf (name
, "ar%d", i
- REG_AR
);
7351 md
.regsym
[i
] = declare_register (name
, i
);
7354 /* control registers: */
7357 for (; i
< total
; ++i
)
7359 sprintf (name
, "cr%d", i
- REG_CR
);
7360 md
.regsym
[i
] = declare_register (name
, i
);
7363 /* predicate registers: */
7365 for (; i
< total
; ++i
)
7367 sprintf (name
, "p%d", i
- REG_P
);
7368 md
.regsym
[i
] = declare_register (name
, i
);
7371 /* branch registers: */
7373 for (; i
< total
; ++i
)
7375 sprintf (name
, "b%d", i
- REG_BR
);
7376 md
.regsym
[i
] = declare_register (name
, i
);
7379 md
.regsym
[REG_IP
] = declare_register ("ip", REG_IP
);
7380 md
.regsym
[REG_CFM
] = declare_register ("cfm", REG_CFM
);
7381 md
.regsym
[REG_PR
] = declare_register ("pr", REG_PR
);
7382 md
.regsym
[REG_PR_ROT
] = declare_register ("pr.rot", REG_PR_ROT
);
7383 md
.regsym
[REG_PSR
] = declare_register ("psr", REG_PSR
);
7384 md
.regsym
[REG_PSR_L
] = declare_register ("psr.l", REG_PSR_L
);
7385 md
.regsym
[REG_PSR_UM
] = declare_register ("psr.um", REG_PSR_UM
);
7387 for (i
= 0; i
< NELEMS (indirect_reg
); ++i
)
7389 regnum
= indirect_reg
[i
].regnum
;
7390 md
.regsym
[regnum
] = declare_register (indirect_reg
[i
].name
, regnum
);
7393 /* define synonyms for application registers: */
7394 for (i
= REG_AR
; i
< REG_AR
+ NELEMS (ar
); ++i
)
7395 md
.regsym
[i
] = declare_register (ar
[i
- REG_AR
].name
,
7396 REG_AR
+ ar
[i
- REG_AR
].regnum
);
7398 /* define synonyms for control registers: */
7399 for (i
= REG_CR
; i
< REG_CR
+ NELEMS (cr
); ++i
)
7400 md
.regsym
[i
] = declare_register (cr
[i
- REG_CR
].name
,
7401 REG_CR
+ cr
[i
- REG_CR
].regnum
);
7403 declare_register ("gp", REG_GR
+ 1);
7404 declare_register ("sp", REG_GR
+ 12);
7405 declare_register ("rp", REG_BR
+ 0);
7407 /* pseudo-registers used to specify unwind info: */
7408 declare_register ("psp", REG_PSP
);
7410 declare_register_set ("ret", 4, REG_GR
+ 8);
7411 declare_register_set ("farg", 8, REG_FR
+ 8);
7412 declare_register_set ("fret", 8, REG_FR
+ 8);
7414 for (i
= 0; i
< NELEMS (const_bits
); ++i
)
7416 err
= hash_insert (md
.const_hash
, const_bits
[i
].name
,
7417 (PTR
) (const_bits
+ i
));
7419 as_fatal ("Inserting \"%s\" into constant hash table failed: %s",
7423 /* Set the architecture and machine depending on defaults and command line
7425 if (md
.flags
& EF_IA_64_ABI64
)
7426 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf64
);
7428 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf32
);
7431 as_warn (_("Could not set architecture and machine"));
7433 /* Set the pointer size and pointer shift size depending on md.flags */
7435 if (md
.flags
& EF_IA_64_ABI64
)
7437 md
.pointer_size
= 8; /* pointers are 8 bytes */
7438 md
.pointer_size_shift
= 3; /* alignment is 8 bytes = 2^2 */
7442 md
.pointer_size
= 4; /* pointers are 4 bytes */
7443 md
.pointer_size_shift
= 2; /* alignment is 4 bytes = 2^2 */
7446 md
.mem_offset
.hint
= 0;
7449 md
.entry_labels
= NULL
;
7452 /* Set the default options in md. Cannot do this in md_begin because
7453 that is called after md_parse_option which is where we set the
7454 options in md based on command line options. */
7457 ia64_init (argc
, argv
)
7458 int argc ATTRIBUTE_UNUSED
;
7459 char **argv ATTRIBUTE_UNUSED
;
7461 md
.flags
= MD_FLAGS_DEFAULT
;
7463 /* FIXME: We should change it to unwind_check_error someday. */
7464 md
.unwind_check
= unwind_check_warning
;
7465 md
.hint_b
= hint_b_error
;
7469 /* Return a string for the target object file format. */
7472 ia64_target_format ()
7474 if (OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
7476 if (md
.flags
& EF_IA_64_BE
)
7478 if (md
.flags
& EF_IA_64_ABI64
)
7479 #if defined(TE_AIX50)
7480 return "elf64-ia64-aix-big";
7481 #elif defined(TE_HPUX)
7482 return "elf64-ia64-hpux-big";
7484 return "elf64-ia64-big";
7487 #if defined(TE_AIX50)
7488 return "elf32-ia64-aix-big";
7489 #elif defined(TE_HPUX)
7490 return "elf32-ia64-hpux-big";
7492 return "elf32-ia64-big";
7497 if (md
.flags
& EF_IA_64_ABI64
)
7499 return "elf64-ia64-aix-little";
7501 return "elf64-ia64-little";
7505 return "elf32-ia64-aix-little";
7507 return "elf32-ia64-little";
7512 return "unknown-format";
7516 ia64_end_of_source ()
7518 /* terminate insn group upon reaching end of file: */
7519 insn_group_break (1, 0, 0);
7521 /* emits slots we haven't written yet: */
7522 ia64_flush_insns ();
7524 bfd_set_private_flags (stdoutput
, md
.flags
);
7526 md
.mem_offset
.hint
= 0;
7532 if (md
.qp
.X_op
== O_register
)
7533 as_bad ("qualifying predicate not followed by instruction");
7534 md
.qp
.X_op
= O_absent
;
7536 if (ignore_input ())
7539 if (input_line_pointer
[0] == ';' && input_line_pointer
[-1] == ';')
7541 if (md
.detect_dv
&& !md
.explicit_mode
)
7548 as_warn (_("Explicit stops are ignored in auto mode"));
7552 insn_group_break (1, 0, 0);
7556 /* This is a hook for ia64_frob_label, so that it can distinguish tags from
7558 static int defining_tag
= 0;
7561 ia64_unrecognized_line (ch
)
7567 expression (&md
.qp
);
7568 if (*input_line_pointer
++ != ')')
7570 as_bad ("Expected ')'");
7573 if (md
.qp
.X_op
!= O_register
)
7575 as_bad ("Qualifying predicate expected");
7578 if (md
.qp
.X_add_number
< REG_P
|| md
.qp
.X_add_number
>= REG_P
+ 64)
7580 as_bad ("Predicate register expected");
7586 if (md
.manual_bundling
)
7587 as_warn ("Found '{' when manual bundling is already turned on");
7589 CURR_SLOT
.manual_bundling_on
= 1;
7590 md
.manual_bundling
= 1;
7592 /* Bundling is only acceptable in explicit mode
7593 or when in default automatic mode. */
7594 if (md
.detect_dv
&& !md
.explicit_mode
)
7596 if (!md
.mode_explicitly_set
7597 && !md
.default_explicit_mode
)
7600 as_warn (_("Found '{' after explicit switch to automatic mode"));
7605 if (!md
.manual_bundling
)
7606 as_warn ("Found '}' when manual bundling is off");
7608 PREV_SLOT
.manual_bundling_off
= 1;
7609 md
.manual_bundling
= 0;
7611 /* switch back to automatic mode, if applicable */
7614 && !md
.mode_explicitly_set
7615 && !md
.default_explicit_mode
)
7618 /* Allow '{' to follow on the same line. We also allow ";;", but that
7619 happens automatically because ';' is an end of line marker. */
7621 if (input_line_pointer
[0] == '{')
7623 input_line_pointer
++;
7624 return ia64_unrecognized_line ('{');
7627 demand_empty_rest_of_line ();
7637 if (md
.qp
.X_op
== O_register
)
7639 as_bad ("Tag must come before qualifying predicate.");
7643 /* This implements just enough of read_a_source_file in read.c to
7644 recognize labels. */
7645 if (is_name_beginner (*input_line_pointer
))
7647 s
= input_line_pointer
;
7648 c
= get_symbol_end ();
7650 else if (LOCAL_LABELS_FB
7651 && ISDIGIT (*input_line_pointer
))
7654 while (ISDIGIT (*input_line_pointer
))
7655 temp
= (temp
* 10) + *input_line_pointer
++ - '0';
7656 fb_label_instance_inc (temp
);
7657 s
= fb_label_name (temp
, 0);
7658 c
= *input_line_pointer
;
7667 /* Put ':' back for error messages' sake. */
7668 *input_line_pointer
++ = ':';
7669 as_bad ("Expected ':'");
7676 /* Put ':' back for error messages' sake. */
7677 *input_line_pointer
++ = ':';
7678 if (*input_line_pointer
++ != ']')
7680 as_bad ("Expected ']'");
7685 as_bad ("Tag name expected");
7695 /* Not a valid line. */
7700 ia64_frob_label (sym
)
7703 struct label_fix
*fix
;
7705 /* Tags need special handling since they are not bundle breaks like
7709 fix
= obstack_alloc (¬es
, sizeof (*fix
));
7711 fix
->next
= CURR_SLOT
.tag_fixups
;
7712 CURR_SLOT
.tag_fixups
= fix
;
7717 if (bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7719 md
.last_text_seg
= now_seg
;
7720 fix
= obstack_alloc (¬es
, sizeof (*fix
));
7722 fix
->next
= CURR_SLOT
.label_fixups
;
7723 CURR_SLOT
.label_fixups
= fix
;
7725 /* Keep track of how many code entry points we've seen. */
7726 if (md
.path
== md
.maxpaths
)
7729 md
.entry_labels
= (const char **)
7730 xrealloc ((void *) md
.entry_labels
,
7731 md
.maxpaths
* sizeof (char *));
7733 md
.entry_labels
[md
.path
++] = S_GET_NAME (sym
);
7738 /* The HP-UX linker will give unresolved symbol errors for symbols
7739 that are declared but unused. This routine removes declared,
7740 unused symbols from an object. */
7742 ia64_frob_symbol (sym
)
7745 if ((S_GET_SEGMENT (sym
) == &bfd_und_section
&& ! symbol_used_p (sym
) &&
7746 ELF_ST_VISIBILITY (S_GET_OTHER (sym
)) == STV_DEFAULT
)
7747 || (S_GET_SEGMENT (sym
) == &bfd_abs_section
7748 && ! S_IS_EXTERNAL (sym
)))
7755 ia64_flush_pending_output ()
7757 if (!md
.keep_pending_output
7758 && bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7760 /* ??? This causes many unnecessary stop bits to be emitted.
7761 Unfortunately, it isn't clear if it is safe to remove this. */
7762 insn_group_break (1, 0, 0);
7763 ia64_flush_insns ();
7767 /* Do ia64-specific expression optimization. All that's done here is
7768 to transform index expressions that are either due to the indexing
7769 of rotating registers or due to the indexing of indirect register
7772 ia64_optimize_expr (l
, op
, r
)
7781 if (l
->X_op
== O_register
&& r
->X_op
== O_constant
)
7783 num_regs
= (l
->X_add_number
>> 16);
7784 if ((unsigned) r
->X_add_number
>= num_regs
)
7787 as_bad ("No current frame");
7789 as_bad ("Index out of range 0..%u", num_regs
- 1);
7790 r
->X_add_number
= 0;
7792 l
->X_add_number
= (l
->X_add_number
& 0xffff) + r
->X_add_number
;
7795 else if (l
->X_op
== O_register
&& r
->X_op
== O_register
)
7797 if (l
->X_add_number
< IND_CPUID
|| l
->X_add_number
> IND_RR
7798 || l
->X_add_number
== IND_MEM
)
7800 as_bad ("Indirect register set name expected");
7801 l
->X_add_number
= IND_CPUID
;
7804 l
->X_op_symbol
= md
.regsym
[l
->X_add_number
];
7805 l
->X_add_number
= r
->X_add_number
;
7813 ia64_parse_name (name
, e
, nextcharP
)
7818 struct const_desc
*cdesc
;
7819 struct dynreg
*dr
= 0;
7826 enum pseudo_type pseudo_type
= PSEUDO_FUNC_NONE
;
7828 /* Find what relocation pseudo-function we're dealing with. */
7829 for (idx
= 0; idx
< NELEMS (pseudo_func
); ++idx
)
7830 if (pseudo_func
[idx
].name
7831 && pseudo_func
[idx
].name
[0] == name
[1]
7832 && strcmp (pseudo_func
[idx
].name
+ 1, name
+ 2) == 0)
7834 pseudo_type
= pseudo_func
[idx
].type
;
7837 switch (pseudo_type
)
7839 case PSEUDO_FUNC_RELOC
:
7840 end
= input_line_pointer
;
7841 if (*nextcharP
!= '(')
7843 as_bad ("Expected '('");
7847 ++input_line_pointer
;
7849 if (*input_line_pointer
!= ')')
7851 as_bad ("Missing ')'");
7855 ++input_line_pointer
;
7856 if (e
->X_op
!= O_symbol
)
7858 if (e
->X_op
!= O_pseudo_fixup
)
7860 as_bad ("Not a symbolic expression");
7863 if (idx
!= FUNC_LT_RELATIVE
)
7865 as_bad ("Illegal combination of relocation functions");
7868 switch (S_GET_VALUE (e
->X_op_symbol
))
7870 case FUNC_FPTR_RELATIVE
:
7871 idx
= FUNC_LT_FPTR_RELATIVE
; break;
7872 case FUNC_DTP_MODULE
:
7873 idx
= FUNC_LT_DTP_MODULE
; break;
7874 case FUNC_DTP_RELATIVE
:
7875 idx
= FUNC_LT_DTP_RELATIVE
; break;
7876 case FUNC_TP_RELATIVE
:
7877 idx
= FUNC_LT_TP_RELATIVE
; break;
7879 as_bad ("Illegal combination of relocation functions");
7883 /* Make sure gas doesn't get rid of local symbols that are used
7885 e
->X_op
= O_pseudo_fixup
;
7886 e
->X_op_symbol
= pseudo_func
[idx
].u
.sym
;
7888 *nextcharP
= *input_line_pointer
;
7891 case PSEUDO_FUNC_CONST
:
7892 e
->X_op
= O_constant
;
7893 e
->X_add_number
= pseudo_func
[idx
].u
.ival
;
7896 case PSEUDO_FUNC_REG
:
7897 e
->X_op
= O_register
;
7898 e
->X_add_number
= pseudo_func
[idx
].u
.ival
;
7907 /* first see if NAME is a known register name: */
7908 sym
= hash_find (md
.reg_hash
, name
);
7911 e
->X_op
= O_register
;
7912 e
->X_add_number
= S_GET_VALUE (sym
);
7916 cdesc
= hash_find (md
.const_hash
, name
);
7919 e
->X_op
= O_constant
;
7920 e
->X_add_number
= cdesc
->value
;
7924 /* check for inN, locN, or outN: */
7929 if (name
[1] == 'n' && ISDIGIT (name
[2]))
7937 if (name
[1] == 'o' && name
[2] == 'c' && ISDIGIT (name
[3]))
7945 if (name
[1] == 'u' && name
[2] == 't' && ISDIGIT (name
[3]))
7956 /* Ignore register numbers with leading zeroes, except zero itself. */
7957 if (dr
&& (name
[idx
] != '0' || name
[idx
+ 1] == '\0'))
7959 unsigned long regnum
;
7961 /* The name is inN, locN, or outN; parse the register number. */
7962 regnum
= strtoul (name
+ idx
, &end
, 10);
7963 if (end
> name
+ idx
&& *end
== '\0' && regnum
< 96)
7965 if (regnum
>= dr
->num_regs
)
7968 as_bad ("No current frame");
7970 as_bad ("Register number out of range 0..%u",
7974 e
->X_op
= O_register
;
7975 e
->X_add_number
= dr
->base
+ regnum
;
7980 end
= alloca (strlen (name
) + 1);
7982 name
= ia64_canonicalize_symbol_name (end
);
7983 if ((dr
= hash_find (md
.dynreg_hash
, name
)))
7985 /* We've got ourselves the name of a rotating register set.
7986 Store the base register number in the low 16 bits of
7987 X_add_number and the size of the register set in the top 16
7989 e
->X_op
= O_register
;
7990 e
->X_add_number
= dr
->base
| (dr
->num_regs
<< 16);
7996 /* Remove the '#' suffix that indicates a symbol as opposed to a register. */
7999 ia64_canonicalize_symbol_name (name
)
8002 size_t len
= strlen (name
), full
= len
;
8004 while (len
> 0 && name
[len
- 1] == '#')
8009 as_bad ("Standalone `#' is illegal");
8011 as_bad ("Zero-length symbol is illegal");
8013 else if (len
< full
- 1)
8014 as_warn ("Redundant `#' suffix operators");
8019 /* Return true if idesc is a conditional branch instruction. This excludes
8020 the modulo scheduled branches, and br.ia. Mod-sched branches are excluded
8021 because they always read/write resources regardless of the value of the
8022 qualifying predicate. br.ia must always use p0, and hence is always
8023 taken. Thus this function returns true for branches which can fall
8024 through, and which use no resources if they do fall through. */
8027 is_conditional_branch (idesc
)
8028 struct ia64_opcode
*idesc
;
8030 /* br is a conditional branch. Everything that starts with br. except
8031 br.ia, br.c{loop,top,exit}, and br.w{top,exit} is a conditional branch.
8032 Everything that starts with brl is a conditional branch. */
8033 return (idesc
->name
[0] == 'b' && idesc
->name
[1] == 'r'
8034 && (idesc
->name
[2] == '\0'
8035 || (idesc
->name
[2] == '.' && idesc
->name
[3] != 'i'
8036 && idesc
->name
[3] != 'c' && idesc
->name
[3] != 'w')
8037 || idesc
->name
[2] == 'l'
8038 /* br.cond, br.call, br.clr */
8039 || (idesc
->name
[2] == '.' && idesc
->name
[3] == 'c'
8040 && (idesc
->name
[4] == 'a' || idesc
->name
[4] == 'o'
8041 || (idesc
->name
[4] == 'l' && idesc
->name
[5] == 'r')))));
8044 /* Return whether the given opcode is a taken branch. If there's any doubt,
8048 is_taken_branch (idesc
)
8049 struct ia64_opcode
*idesc
;
8051 return ((is_conditional_branch (idesc
) && CURR_SLOT
.qp_regno
== 0)
8052 || strncmp (idesc
->name
, "br.ia", 5) == 0);
8055 /* Return whether the given opcode is an interruption or rfi. If there's any
8056 doubt, returns zero. */
8059 is_interruption_or_rfi (idesc
)
8060 struct ia64_opcode
*idesc
;
8062 if (strcmp (idesc
->name
, "rfi") == 0)
8067 /* Returns the index of the given dependency in the opcode's list of chks, or
8068 -1 if there is no dependency. */
8071 depends_on (depind
, idesc
)
8073 struct ia64_opcode
*idesc
;
8076 const struct ia64_opcode_dependency
*dep
= idesc
->dependencies
;
8077 for (i
= 0; i
< dep
->nchks
; i
++)
8079 if (depind
== DEP (dep
->chks
[i
]))
8085 /* Determine a set of specific resources used for a particular resource
8086 class. Returns the number of specific resources identified For those
8087 cases which are not determinable statically, the resource returned is
8090 Meanings of value in 'NOTE':
8091 1) only read/write when the register number is explicitly encoded in the
8093 2) only read CFM when accessing a rotating GR, FR, or PR. mov pr only
8094 accesses CFM when qualifying predicate is in the rotating region.
8095 3) general register value is used to specify an indirect register; not
8096 determinable statically.
8097 4) only read the given resource when bits 7:0 of the indirect index
8098 register value does not match the register number of the resource; not
8099 determinable statically.
8100 5) all rules are implementation specific.
8101 6) only when both the index specified by the reader and the index specified
8102 by the writer have the same value in bits 63:61; not determinable
8104 7) only access the specified resource when the corresponding mask bit is
8106 8) PSR.dfh is only read when these insns reference FR32-127. PSR.dfl is
8107 only read when these insns reference FR2-31
8108 9) PSR.mfl is only written when these insns write FR2-31. PSR.mfh is only
8109 written when these insns write FR32-127
8110 10) The PSR.bn bit is only accessed when one of GR16-31 is specified in the
8112 11) The target predicates are written independently of PR[qp], but source
8113 registers are only read if PR[qp] is true. Since the state of PR[qp]
8114 cannot statically be determined, all source registers are marked used.
8115 12) This insn only reads the specified predicate register when that
8116 register is the PR[qp].
8117 13) This reference to ld-c only applies to teh GR whose value is loaded
8118 with data returned from memory, not the post-incremented address register.
8119 14) The RSE resource includes the implementation-specific RSE internal
8120 state resources. At least one (and possibly more) of these resources are
8121 read by each instruction listed in IC:rse-readers. At least one (and
8122 possibly more) of these resources are written by each insn listed in
8124 15+16) Represents reserved instructions, which the assembler does not
8127 Memory resources (i.e. locations in memory) are *not* marked or tracked by
8128 this code; there are no dependency violations based on memory access.
8131 #define MAX_SPECS 256
8136 specify_resource (dep
, idesc
, type
, specs
, note
, path
)
8137 const struct ia64_dependency
*dep
;
8138 struct ia64_opcode
*idesc
;
8139 int type
; /* is this a DV chk or a DV reg? */
8140 struct rsrc specs
[MAX_SPECS
]; /* returned specific resources */
8141 int note
; /* resource note for this insn's usage */
8142 int path
; /* which execution path to examine */
8149 if (dep
->mode
== IA64_DV_WAW
8150 || (dep
->mode
== IA64_DV_RAW
&& type
== DV_REG
)
8151 || (dep
->mode
== IA64_DV_WAR
&& type
== DV_CHK
))
8154 /* template for any resources we identify */
8155 tmpl
.dependency
= dep
;
8157 tmpl
.insn_srlz
= tmpl
.data_srlz
= 0;
8158 tmpl
.qp_regno
= CURR_SLOT
.qp_regno
;
8159 tmpl
.link_to_qp_branch
= 1;
8160 tmpl
.mem_offset
.hint
= 0;
8163 tmpl
.cmp_type
= CMP_NONE
;
8166 as_warn (_("Unhandled dependency %s for %s (%s), note %d"), \
8167 dep->name, idesc->name, (rsrc_write?"write":"read"), note)
8168 #define KNOWN(REG) (gr_values[REG].known && gr_values[REG].path >= path)
8170 /* we don't need to track these */
8171 if (dep
->semantics
== IA64_DVS_NONE
)
8174 switch (dep
->specifier
)
8179 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8181 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8182 if (regno
>= 0 && regno
<= 7)
8184 specs
[count
] = tmpl
;
8185 specs
[count
++].index
= regno
;
8191 for (i
= 0; i
< 8; i
++)
8193 specs
[count
] = tmpl
;
8194 specs
[count
++].index
= i
;
8203 case IA64_RS_AR_UNAT
:
8204 /* This is a mov =AR or mov AR= instruction. */
8205 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8207 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8208 if (regno
== AR_UNAT
)
8210 specs
[count
++] = tmpl
;
8215 /* This is a spill/fill, or other instruction that modifies the
8218 /* Unless we can determine the specific bits used, mark the whole
8219 thing; bits 8:3 of the memory address indicate the bit used in
8220 UNAT. The .mem.offset hint may be used to eliminate a small
8221 subset of conflicts. */
8222 specs
[count
] = tmpl
;
8223 if (md
.mem_offset
.hint
)
8226 fprintf (stderr
, " Using hint for spill/fill\n");
8227 /* The index isn't actually used, just set it to something
8228 approximating the bit index. */
8229 specs
[count
].index
= (md
.mem_offset
.offset
>> 3) & 0x3F;
8230 specs
[count
].mem_offset
.hint
= 1;
8231 specs
[count
].mem_offset
.offset
= md
.mem_offset
.offset
;
8232 specs
[count
++].mem_offset
.base
= md
.mem_offset
.base
;
8236 specs
[count
++].specific
= 0;
8244 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8246 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8247 if ((regno
>= 8 && regno
<= 15)
8248 || (regno
>= 20 && regno
<= 23)
8249 || (regno
>= 31 && regno
<= 39)
8250 || (regno
>= 41 && regno
<= 47)
8251 || (regno
>= 67 && regno
<= 111))
8253 specs
[count
] = tmpl
;
8254 specs
[count
++].index
= regno
;
8267 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8269 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8270 if ((regno
>= 48 && regno
<= 63)
8271 || (regno
>= 112 && regno
<= 127))
8273 specs
[count
] = tmpl
;
8274 specs
[count
++].index
= regno
;
8280 for (i
= 48; i
< 64; i
++)
8282 specs
[count
] = tmpl
;
8283 specs
[count
++].index
= i
;
8285 for (i
= 112; i
< 128; i
++)
8287 specs
[count
] = tmpl
;
8288 specs
[count
++].index
= i
;
8306 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8307 if (idesc
->operands
[i
] == IA64_OPND_B1
8308 || idesc
->operands
[i
] == IA64_OPND_B2
)
8310 specs
[count
] = tmpl
;
8311 specs
[count
++].index
=
8312 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
8317 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
8318 if (idesc
->operands
[i
] == IA64_OPND_B1
8319 || idesc
->operands
[i
] == IA64_OPND_B2
)
8321 specs
[count
] = tmpl
;
8322 specs
[count
++].index
=
8323 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
8329 case IA64_RS_CPUID
: /* four or more registers */
8332 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CPUID_R3
)
8334 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8335 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8338 specs
[count
] = tmpl
;
8339 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8343 specs
[count
] = tmpl
;
8344 specs
[count
++].specific
= 0;
8354 case IA64_RS_DBR
: /* four or more registers */
8357 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_DBR_R3
)
8359 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8360 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8363 specs
[count
] = tmpl
;
8364 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8368 specs
[count
] = tmpl
;
8369 specs
[count
++].specific
= 0;
8373 else if (note
== 0 && !rsrc_write
)
8375 specs
[count
] = tmpl
;
8376 specs
[count
++].specific
= 0;
8384 case IA64_RS_IBR
: /* four or more registers */
8387 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_IBR_R3
)
8389 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8390 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8393 specs
[count
] = tmpl
;
8394 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8398 specs
[count
] = tmpl
;
8399 specs
[count
++].specific
= 0;
8412 /* These are implementation specific. Force all references to
8413 conflict with all other references. */
8414 specs
[count
] = tmpl
;
8415 specs
[count
++].specific
= 0;
8423 case IA64_RS_PKR
: /* 16 or more registers */
8424 if (note
== 3 || note
== 4)
8426 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PKR_R3
)
8428 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8429 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8434 specs
[count
] = tmpl
;
8435 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8438 for (i
= 0; i
< NELEMS (gr_values
); i
++)
8440 /* Uses all registers *except* the one in R3. */
8441 if ((unsigned)i
!= (gr_values
[regno
].value
& 0xFF))
8443 specs
[count
] = tmpl
;
8444 specs
[count
++].index
= i
;
8450 specs
[count
] = tmpl
;
8451 specs
[count
++].specific
= 0;
8458 specs
[count
] = tmpl
;
8459 specs
[count
++].specific
= 0;
8463 case IA64_RS_PMC
: /* four or more registers */
8466 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMC_R3
8467 || (!rsrc_write
&& idesc
->operands
[1] == IA64_OPND_PMD_R3
))
8470 int index
= ((idesc
->operands
[1] == IA64_OPND_R3
&& !rsrc_write
)
8472 int regno
= CURR_SLOT
.opnd
[index
].X_add_number
- REG_GR
;
8473 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8476 specs
[count
] = tmpl
;
8477 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8481 specs
[count
] = tmpl
;
8482 specs
[count
++].specific
= 0;
8492 case IA64_RS_PMD
: /* four or more registers */
8495 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMD_R3
)
8497 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8498 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8501 specs
[count
] = tmpl
;
8502 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8506 specs
[count
] = tmpl
;
8507 specs
[count
++].specific
= 0;
8517 case IA64_RS_RR
: /* eight registers */
8520 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_RR_R3
)
8522 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8523 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8526 specs
[count
] = tmpl
;
8527 specs
[count
++].index
= (gr_values
[regno
].value
>> 61) & 0x7;
8531 specs
[count
] = tmpl
;
8532 specs
[count
++].specific
= 0;
8536 else if (note
== 0 && !rsrc_write
)
8538 specs
[count
] = tmpl
;
8539 specs
[count
++].specific
= 0;
8547 case IA64_RS_CR_IRR
:
8550 /* handle mov-from-CR-IVR; it's a read that writes CR[IRR] */
8551 int regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
;
8553 && idesc
->operands
[1] == IA64_OPND_CR3
8556 for (i
= 0; i
< 4; i
++)
8558 specs
[count
] = tmpl
;
8559 specs
[count
++].index
= CR_IRR0
+ i
;
8565 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8566 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
8568 && regno
<= CR_IRR3
)
8570 specs
[count
] = tmpl
;
8571 specs
[count
++].index
= regno
;
8580 case IA64_RS_CR_LRR
:
8587 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8588 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
8589 && (regno
== CR_LRR0
|| regno
== CR_LRR1
))
8591 specs
[count
] = tmpl
;
8592 specs
[count
++].index
= regno
;
8600 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
8602 specs
[count
] = tmpl
;
8603 specs
[count
++].index
=
8604 CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8619 else if (rsrc_write
)
8621 if (dep
->specifier
== IA64_RS_FRb
8622 && idesc
->operands
[0] == IA64_OPND_F1
)
8624 specs
[count
] = tmpl
;
8625 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_FR
;
8630 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
8632 if (idesc
->operands
[i
] == IA64_OPND_F2
8633 || idesc
->operands
[i
] == IA64_OPND_F3
8634 || idesc
->operands
[i
] == IA64_OPND_F4
)
8636 specs
[count
] = tmpl
;
8637 specs
[count
++].index
=
8638 CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8647 /* This reference applies only to the GR whose value is loaded with
8648 data returned from memory. */
8649 specs
[count
] = tmpl
;
8650 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
8656 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8657 if (idesc
->operands
[i
] == IA64_OPND_R1
8658 || idesc
->operands
[i
] == IA64_OPND_R2
8659 || idesc
->operands
[i
] == IA64_OPND_R3
)
8661 specs
[count
] = tmpl
;
8662 specs
[count
++].index
=
8663 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8665 if (idesc
->flags
& IA64_OPCODE_POSTINC
)
8666 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8667 if (idesc
->operands
[i
] == IA64_OPND_MR3
)
8669 specs
[count
] = tmpl
;
8670 specs
[count
++].index
=
8671 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8676 /* Look for anything that reads a GR. */
8677 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8679 if (idesc
->operands
[i
] == IA64_OPND_MR3
8680 || idesc
->operands
[i
] == IA64_OPND_CPUID_R3
8681 || idesc
->operands
[i
] == IA64_OPND_DBR_R3
8682 || idesc
->operands
[i
] == IA64_OPND_IBR_R3
8683 || idesc
->operands
[i
] == IA64_OPND_MSR_R3
8684 || idesc
->operands
[i
] == IA64_OPND_PKR_R3
8685 || idesc
->operands
[i
] == IA64_OPND_PMC_R3
8686 || idesc
->operands
[i
] == IA64_OPND_PMD_R3
8687 || idesc
->operands
[i
] == IA64_OPND_RR_R3
8688 || ((i
>= idesc
->num_outputs
)
8689 && (idesc
->operands
[i
] == IA64_OPND_R1
8690 || idesc
->operands
[i
] == IA64_OPND_R2
8691 || idesc
->operands
[i
] == IA64_OPND_R3
8692 /* addl source register. */
8693 || idesc
->operands
[i
] == IA64_OPND_R3_2
)))
8695 specs
[count
] = tmpl
;
8696 specs
[count
++].index
=
8697 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8708 /* This is the same as IA64_RS_PRr, except that the register range is
8709 from 1 - 15, and there are no rotating register reads/writes here. */
8713 for (i
= 1; i
< 16; i
++)
8715 specs
[count
] = tmpl
;
8716 specs
[count
++].index
= i
;
8722 /* Mark only those registers indicated by the mask. */
8725 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8726 for (i
= 1; i
< 16; i
++)
8727 if (mask
& ((valueT
) 1 << i
))
8729 specs
[count
] = tmpl
;
8730 specs
[count
++].index
= i
;
8738 else if (note
== 11) /* note 11 implies note 1 as well */
8742 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8744 if (idesc
->operands
[i
] == IA64_OPND_P1
8745 || idesc
->operands
[i
] == IA64_OPND_P2
)
8747 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8748 if (regno
>= 1 && regno
< 16)
8750 specs
[count
] = tmpl
;
8751 specs
[count
++].index
= regno
;
8761 else if (note
== 12)
8763 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
8765 specs
[count
] = tmpl
;
8766 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8773 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8774 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8775 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8776 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8778 if ((idesc
->operands
[0] == IA64_OPND_P1
8779 || idesc
->operands
[0] == IA64_OPND_P2
)
8780 && p1
>= 1 && p1
< 16)
8782 specs
[count
] = tmpl
;
8783 specs
[count
].cmp_type
=
8784 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8785 specs
[count
++].index
= p1
;
8787 if ((idesc
->operands
[1] == IA64_OPND_P1
8788 || idesc
->operands
[1] == IA64_OPND_P2
)
8789 && p2
>= 1 && p2
< 16)
8791 specs
[count
] = tmpl
;
8792 specs
[count
].cmp_type
=
8793 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8794 specs
[count
++].index
= p2
;
8799 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
8801 specs
[count
] = tmpl
;
8802 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8804 if (idesc
->operands
[1] == IA64_OPND_PR
)
8806 for (i
= 1; i
< 16; i
++)
8808 specs
[count
] = tmpl
;
8809 specs
[count
++].index
= i
;
8820 /* This is the general case for PRs. IA64_RS_PR and IA64_RS_PR63 are
8821 simplified cases of this. */
8825 for (i
= 16; i
< 63; i
++)
8827 specs
[count
] = tmpl
;
8828 specs
[count
++].index
= i
;
8834 /* Mark only those registers indicated by the mask. */
8836 && idesc
->operands
[0] == IA64_OPND_PR
)
8838 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8839 if (mask
& ((valueT
) 1 << 16))
8840 for (i
= 16; i
< 63; i
++)
8842 specs
[count
] = tmpl
;
8843 specs
[count
++].index
= i
;
8847 && idesc
->operands
[0] == IA64_OPND_PR_ROT
)
8849 for (i
= 16; i
< 63; i
++)
8851 specs
[count
] = tmpl
;
8852 specs
[count
++].index
= i
;
8860 else if (note
== 11) /* note 11 implies note 1 as well */
8864 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8866 if (idesc
->operands
[i
] == IA64_OPND_P1
8867 || idesc
->operands
[i
] == IA64_OPND_P2
)
8869 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8870 if (regno
>= 16 && regno
< 63)
8872 specs
[count
] = tmpl
;
8873 specs
[count
++].index
= regno
;
8883 else if (note
== 12)
8885 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8887 specs
[count
] = tmpl
;
8888 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8895 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8896 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8897 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8898 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8900 if ((idesc
->operands
[0] == IA64_OPND_P1
8901 || idesc
->operands
[0] == IA64_OPND_P2
)
8902 && p1
>= 16 && p1
< 63)
8904 specs
[count
] = tmpl
;
8905 specs
[count
].cmp_type
=
8906 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8907 specs
[count
++].index
= p1
;
8909 if ((idesc
->operands
[1] == IA64_OPND_P1
8910 || idesc
->operands
[1] == IA64_OPND_P2
)
8911 && p2
>= 16 && p2
< 63)
8913 specs
[count
] = tmpl
;
8914 specs
[count
].cmp_type
=
8915 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8916 specs
[count
++].index
= p2
;
8921 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8923 specs
[count
] = tmpl
;
8924 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8926 if (idesc
->operands
[1] == IA64_OPND_PR
)
8928 for (i
= 16; i
< 63; i
++)
8930 specs
[count
] = tmpl
;
8931 specs
[count
++].index
= i
;
8943 /* Verify that the instruction is using the PSR bit indicated in
8947 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_UM
)
8949 if (dep
->regindex
< 6)
8951 specs
[count
++] = tmpl
;
8954 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR
)
8956 if (dep
->regindex
< 32
8957 || dep
->regindex
== 35
8958 || dep
->regindex
== 36
8959 || (!rsrc_write
&& dep
->regindex
== PSR_CPL
))
8961 specs
[count
++] = tmpl
;
8964 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_L
)
8966 if (dep
->regindex
< 32
8967 || dep
->regindex
== 35
8968 || dep
->regindex
== 36
8969 || (rsrc_write
&& dep
->regindex
== PSR_CPL
))
8971 specs
[count
++] = tmpl
;
8976 /* Several PSR bits have very specific dependencies. */
8977 switch (dep
->regindex
)
8980 specs
[count
++] = tmpl
;
8985 specs
[count
++] = tmpl
;
8989 /* Only certain CR accesses use PSR.ic */
8990 if (idesc
->operands
[0] == IA64_OPND_CR3
8991 || idesc
->operands
[1] == IA64_OPND_CR3
)
8994 ((idesc
->operands
[0] == IA64_OPND_CR3
)
8997 CURR_SLOT
.opnd
[index
].X_add_number
- REG_CR
;
9012 specs
[count
++] = tmpl
;
9021 specs
[count
++] = tmpl
;
9025 /* Only some AR accesses use cpl */
9026 if (idesc
->operands
[0] == IA64_OPND_AR3
9027 || idesc
->operands
[1] == IA64_OPND_AR3
)
9030 ((idesc
->operands
[0] == IA64_OPND_AR3
)
9033 CURR_SLOT
.opnd
[index
].X_add_number
- REG_AR
;
9040 && regno
<= AR_K7
))))
9042 specs
[count
++] = tmpl
;
9047 specs
[count
++] = tmpl
;
9057 if (idesc
->operands
[0] == IA64_OPND_IMMU24
)
9059 mask
= CURR_SLOT
.opnd
[0].X_add_number
;
9065 if (mask
& ((valueT
) 1 << dep
->regindex
))
9067 specs
[count
++] = tmpl
;
9072 int min
= dep
->regindex
== PSR_DFL
? 2 : 32;
9073 int max
= dep
->regindex
== PSR_DFL
? 31 : 127;
9074 /* dfh is read on FR32-127; dfl is read on FR2-31 */
9075 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
9077 if (idesc
->operands
[i
] == IA64_OPND_F1
9078 || idesc
->operands
[i
] == IA64_OPND_F2
9079 || idesc
->operands
[i
] == IA64_OPND_F3
9080 || idesc
->operands
[i
] == IA64_OPND_F4
)
9082 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
9083 if (reg
>= min
&& reg
<= max
)
9085 specs
[count
++] = tmpl
;
9092 int min
= dep
->regindex
== PSR_MFL
? 2 : 32;
9093 int max
= dep
->regindex
== PSR_MFL
? 31 : 127;
9094 /* mfh is read on writes to FR32-127; mfl is read on writes to
9096 for (i
= 0; i
< idesc
->num_outputs
; i
++)
9098 if (idesc
->operands
[i
] == IA64_OPND_F1
)
9100 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
9101 if (reg
>= min
&& reg
<= max
)
9103 specs
[count
++] = tmpl
;
9108 else if (note
== 10)
9110 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
9112 if (idesc
->operands
[i
] == IA64_OPND_R1
9113 || idesc
->operands
[i
] == IA64_OPND_R2
9114 || idesc
->operands
[i
] == IA64_OPND_R3
)
9116 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9117 if (regno
>= 16 && regno
<= 31)
9119 specs
[count
++] = tmpl
;
9130 case IA64_RS_AR_FPSR
:
9131 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
9133 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
9134 if (regno
== AR_FPSR
)
9136 specs
[count
++] = tmpl
;
9141 specs
[count
++] = tmpl
;
9146 /* Handle all AR[REG] resources */
9147 if (note
== 0 || note
== 1)
9149 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
9150 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
9151 && regno
== dep
->regindex
)
9153 specs
[count
++] = tmpl
;
9155 /* other AR[REG] resources may be affected by AR accesses */
9156 else if (idesc
->operands
[0] == IA64_OPND_AR3
)
9159 regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
;
9160 switch (dep
->regindex
)
9166 if (regno
== AR_BSPSTORE
)
9168 specs
[count
++] = tmpl
;
9172 (regno
== AR_BSPSTORE
9173 || regno
== AR_RNAT
))
9175 specs
[count
++] = tmpl
;
9180 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
9183 regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
;
9184 switch (dep
->regindex
)
9189 if (regno
== AR_BSPSTORE
|| regno
== AR_RNAT
)
9191 specs
[count
++] = tmpl
;
9198 specs
[count
++] = tmpl
;
9208 /* Handle all CR[REG] resources */
9209 if (note
== 0 || note
== 1)
9211 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
9213 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
9214 if (regno
== dep
->regindex
)
9216 specs
[count
++] = tmpl
;
9218 else if (!rsrc_write
)
9220 /* Reads from CR[IVR] affect other resources. */
9221 if (regno
== CR_IVR
)
9223 if ((dep
->regindex
>= CR_IRR0
9224 && dep
->regindex
<= CR_IRR3
)
9225 || dep
->regindex
== CR_TPR
)
9227 specs
[count
++] = tmpl
;
9234 specs
[count
++] = tmpl
;
9243 case IA64_RS_INSERVICE
:
9244 /* look for write of EOI (67) or read of IVR (65) */
9245 if ((idesc
->operands
[0] == IA64_OPND_CR3
9246 && CURR_SLOT
.opnd
[0].X_add_number
- REG_CR
== CR_EOI
)
9247 || (idesc
->operands
[1] == IA64_OPND_CR3
9248 && CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
== CR_IVR
))
9250 specs
[count
++] = tmpl
;
9257 specs
[count
++] = tmpl
;
9268 specs
[count
++] = tmpl
;
9272 /* Check if any of the registers accessed are in the rotating region.
9273 mov to/from pr accesses CFM only when qp_regno is in the rotating
9275 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
9277 if (idesc
->operands
[i
] == IA64_OPND_R1
9278 || idesc
->operands
[i
] == IA64_OPND_R2
9279 || idesc
->operands
[i
] == IA64_OPND_R3
)
9281 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9282 /* Assumes that md.rot.num_regs is always valid */
9283 if (md
.rot
.num_regs
> 0
9285 && num
< 31 + md
.rot
.num_regs
)
9287 specs
[count
] = tmpl
;
9288 specs
[count
++].specific
= 0;
9291 else if (idesc
->operands
[i
] == IA64_OPND_F1
9292 || idesc
->operands
[i
] == IA64_OPND_F2
9293 || idesc
->operands
[i
] == IA64_OPND_F3
9294 || idesc
->operands
[i
] == IA64_OPND_F4
)
9296 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
9299 specs
[count
] = tmpl
;
9300 specs
[count
++].specific
= 0;
9303 else if (idesc
->operands
[i
] == IA64_OPND_P1
9304 || idesc
->operands
[i
] == IA64_OPND_P2
)
9306 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
9309 specs
[count
] = tmpl
;
9310 specs
[count
++].specific
= 0;
9314 if (CURR_SLOT
.qp_regno
> 15)
9316 specs
[count
] = tmpl
;
9317 specs
[count
++].specific
= 0;
9322 /* This is the same as IA64_RS_PRr, except simplified to account for
9323 the fact that there is only one register. */
9327 specs
[count
++] = tmpl
;
9332 if (idesc
->operands
[2] == IA64_OPND_IMM17
)
9333 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
9334 if (mask
& ((valueT
) 1 << 63))
9335 specs
[count
++] = tmpl
;
9337 else if (note
== 11)
9339 if ((idesc
->operands
[0] == IA64_OPND_P1
9340 && CURR_SLOT
.opnd
[0].X_add_number
- REG_P
== 63)
9341 || (idesc
->operands
[1] == IA64_OPND_P2
9342 && CURR_SLOT
.opnd
[1].X_add_number
- REG_P
== 63))
9344 specs
[count
++] = tmpl
;
9347 else if (note
== 12)
9349 if (CURR_SLOT
.qp_regno
== 63)
9351 specs
[count
++] = tmpl
;
9358 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
9359 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
9360 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
9361 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
9364 && (idesc
->operands
[0] == IA64_OPND_P1
9365 || idesc
->operands
[0] == IA64_OPND_P2
))
9367 specs
[count
] = tmpl
;
9368 specs
[count
++].cmp_type
=
9369 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
9372 && (idesc
->operands
[1] == IA64_OPND_P1
9373 || idesc
->operands
[1] == IA64_OPND_P2
))
9375 specs
[count
] = tmpl
;
9376 specs
[count
++].cmp_type
=
9377 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
9382 if (CURR_SLOT
.qp_regno
== 63)
9384 specs
[count
++] = tmpl
;
9395 /* FIXME we can identify some individual RSE written resources, but RSE
9396 read resources have not yet been completely identified, so for now
9397 treat RSE as a single resource */
9398 if (strncmp (idesc
->name
, "mov", 3) == 0)
9402 if (idesc
->operands
[0] == IA64_OPND_AR3
9403 && CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
)
9405 specs
[count
++] = tmpl
;
9410 if (idesc
->operands
[0] == IA64_OPND_AR3
)
9412 if (CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
9413 || CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_RNAT
)
9415 specs
[count
++] = tmpl
;
9418 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
9420 if (CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSP
9421 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSPSTORE
9422 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_RNAT
)
9424 specs
[count
++] = tmpl
;
9431 specs
[count
++] = tmpl
;
9436 /* FIXME -- do any of these need to be non-specific? */
9437 specs
[count
++] = tmpl
;
9441 as_bad (_("Unrecognized dependency specifier %d\n"), dep
->specifier
);
9448 /* Clear branch flags on marked resources. This breaks the link between the
9449 QP of the marking instruction and a subsequent branch on the same QP. */
9452 clear_qp_branch_flag (mask
)
9456 for (i
= 0; i
< regdepslen
; i
++)
9458 valueT bit
= ((valueT
) 1 << regdeps
[i
].qp_regno
);
9459 if ((bit
& mask
) != 0)
9461 regdeps
[i
].link_to_qp_branch
= 0;
9466 /* MASK contains 2 and only 2 PRs which are mutually exclusive. Remove
9467 any mutexes which contain one of the PRs and create new ones when
9471 update_qp_mutex (valueT mask
)
9477 while (i
< qp_mutexeslen
)
9479 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
9481 /* If it destroys and creates the same mutex, do nothing. */
9482 if (qp_mutexes
[i
].prmask
== mask
9483 && qp_mutexes
[i
].path
== md
.path
)
9494 fprintf (stderr
, " Clearing mutex relation");
9495 print_prmask (qp_mutexes
[i
].prmask
);
9496 fprintf (stderr
, "\n");
9499 /* Deal with the old mutex with more than 3+ PRs only if
9500 the new mutex on the same execution path with it.
9502 FIXME: The 3+ mutex support is incomplete.
9503 dot_pred_rel () may be a better place to fix it. */
9504 if (qp_mutexes
[i
].path
== md
.path
)
9506 /* If it is a proper subset of the mutex, create a
9509 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
9512 qp_mutexes
[i
].prmask
&= ~mask
;
9513 if (qp_mutexes
[i
].prmask
& (qp_mutexes
[i
].prmask
- 1))
9515 /* Modify the mutex if there are more than one
9523 /* Remove the mutex. */
9524 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
9532 add_qp_mutex (mask
);
9537 /* Remove any mutexes which contain any of the PRs indicated in the mask.
9539 Any changes to a PR clears the mutex relations which include that PR. */
9542 clear_qp_mutex (mask
)
9548 while (i
< qp_mutexeslen
)
9550 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
9554 fprintf (stderr
, " Clearing mutex relation");
9555 print_prmask (qp_mutexes
[i
].prmask
);
9556 fprintf (stderr
, "\n");
9558 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
9565 /* Clear implies relations which contain PRs in the given masks.
9566 P1_MASK indicates the source of the implies relation, while P2_MASK
9567 indicates the implied PR. */
9570 clear_qp_implies (p1_mask
, p2_mask
)
9577 while (i
< qp_implieslen
)
9579 if ((((valueT
) 1 << qp_implies
[i
].p1
) & p1_mask
) != 0
9580 || (((valueT
) 1 << qp_implies
[i
].p2
) & p2_mask
) != 0)
9583 fprintf (stderr
, "Clearing implied relation PR%d->PR%d\n",
9584 qp_implies
[i
].p1
, qp_implies
[i
].p2
);
9585 qp_implies
[i
] = qp_implies
[--qp_implieslen
];
9592 /* Add the PRs specified to the list of implied relations. */
9595 add_qp_imply (p1
, p2
)
9602 /* p0 is not meaningful here. */
9603 if (p1
== 0 || p2
== 0)
9609 /* If it exists already, ignore it. */
9610 for (i
= 0; i
< qp_implieslen
; i
++)
9612 if (qp_implies
[i
].p1
== p1
9613 && qp_implies
[i
].p2
== p2
9614 && qp_implies
[i
].path
== md
.path
9615 && !qp_implies
[i
].p2_branched
)
9619 if (qp_implieslen
== qp_impliestotlen
)
9621 qp_impliestotlen
+= 20;
9622 qp_implies
= (struct qp_imply
*)
9623 xrealloc ((void *) qp_implies
,
9624 qp_impliestotlen
* sizeof (struct qp_imply
));
9627 fprintf (stderr
, " Registering PR%d implies PR%d\n", p1
, p2
);
9628 qp_implies
[qp_implieslen
].p1
= p1
;
9629 qp_implies
[qp_implieslen
].p2
= p2
;
9630 qp_implies
[qp_implieslen
].path
= md
.path
;
9631 qp_implies
[qp_implieslen
++].p2_branched
= 0;
9633 /* Add in the implied transitive relations; for everything that p2 implies,
9634 make p1 imply that, too; for everything that implies p1, make it imply p2
9636 for (i
= 0; i
< qp_implieslen
; i
++)
9638 if (qp_implies
[i
].p1
== p2
)
9639 add_qp_imply (p1
, qp_implies
[i
].p2
);
9640 if (qp_implies
[i
].p2
== p1
)
9641 add_qp_imply (qp_implies
[i
].p1
, p2
);
9643 /* Add in mutex relations implied by this implies relation; for each mutex
9644 relation containing p2, duplicate it and replace p2 with p1. */
9645 bit
= (valueT
) 1 << p1
;
9646 mask
= (valueT
) 1 << p2
;
9647 for (i
= 0; i
< qp_mutexeslen
; i
++)
9649 if (qp_mutexes
[i
].prmask
& mask
)
9650 add_qp_mutex ((qp_mutexes
[i
].prmask
& ~mask
) | bit
);
9654 /* Add the PRs specified in the mask to the mutex list; this means that only
9655 one of the PRs can be true at any time. PR0 should never be included in
9665 if (qp_mutexeslen
== qp_mutexestotlen
)
9667 qp_mutexestotlen
+= 20;
9668 qp_mutexes
= (struct qpmutex
*)
9669 xrealloc ((void *) qp_mutexes
,
9670 qp_mutexestotlen
* sizeof (struct qpmutex
));
9674 fprintf (stderr
, " Registering mutex on");
9675 print_prmask (mask
);
9676 fprintf (stderr
, "\n");
9678 qp_mutexes
[qp_mutexeslen
].path
= md
.path
;
9679 qp_mutexes
[qp_mutexeslen
++].prmask
= mask
;
9683 has_suffix_p (name
, suffix
)
9687 size_t namelen
= strlen (name
);
9688 size_t sufflen
= strlen (suffix
);
9690 if (namelen
<= sufflen
)
9692 return strcmp (name
+ namelen
- sufflen
, suffix
) == 0;
9696 clear_register_values ()
9700 fprintf (stderr
, " Clearing register values\n");
9701 for (i
= 1; i
< NELEMS (gr_values
); i
++)
9702 gr_values
[i
].known
= 0;
9705 /* Keep track of register values/changes which affect DV tracking.
9707 optimization note: should add a flag to classes of insns where otherwise we
9708 have to examine a group of strings to identify them. */
9711 note_register_values (idesc
)
9712 struct ia64_opcode
*idesc
;
9714 valueT qp_changemask
= 0;
9717 /* Invalidate values for registers being written to. */
9718 for (i
= 0; i
< idesc
->num_outputs
; i
++)
9720 if (idesc
->operands
[i
] == IA64_OPND_R1
9721 || idesc
->operands
[i
] == IA64_OPND_R2
9722 || idesc
->operands
[i
] == IA64_OPND_R3
)
9724 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9725 if (regno
> 0 && regno
< NELEMS (gr_values
))
9726 gr_values
[regno
].known
= 0;
9728 else if (idesc
->operands
[i
] == IA64_OPND_R3_2
)
9730 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9731 if (regno
> 0 && regno
< 4)
9732 gr_values
[regno
].known
= 0;
9734 else if (idesc
->operands
[i
] == IA64_OPND_P1
9735 || idesc
->operands
[i
] == IA64_OPND_P2
)
9737 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
9738 qp_changemask
|= (valueT
) 1 << regno
;
9740 else if (idesc
->operands
[i
] == IA64_OPND_PR
)
9742 if (idesc
->operands
[2] & (valueT
) 0x10000)
9743 qp_changemask
= ~(valueT
) 0x1FFFF | idesc
->operands
[2];
9745 qp_changemask
= idesc
->operands
[2];
9748 else if (idesc
->operands
[i
] == IA64_OPND_PR_ROT
)
9750 if (idesc
->operands
[1] & ((valueT
) 1 << 43))
9751 qp_changemask
= -((valueT
) 1 << 44) | idesc
->operands
[1];
9753 qp_changemask
= idesc
->operands
[1];
9754 qp_changemask
&= ~(valueT
) 0xFFFF;
9759 /* Always clear qp branch flags on any PR change. */
9760 /* FIXME there may be exceptions for certain compares. */
9761 clear_qp_branch_flag (qp_changemask
);
9763 /* Invalidate rotating registers on insns which affect RRBs in CFM. */
9764 if (idesc
->flags
& IA64_OPCODE_MOD_RRBS
)
9766 qp_changemask
|= ~(valueT
) 0xFFFF;
9767 if (strcmp (idesc
->name
, "clrrrb.pr") != 0)
9769 for (i
= 32; i
< 32 + md
.rot
.num_regs
; i
++)
9770 gr_values
[i
].known
= 0;
9772 clear_qp_mutex (qp_changemask
);
9773 clear_qp_implies (qp_changemask
, qp_changemask
);
9775 /* After a call, all register values are undefined, except those marked
9777 else if (strncmp (idesc
->name
, "br.call", 6) == 0
9778 || strncmp (idesc
->name
, "brl.call", 7) == 0)
9780 /* FIXME keep GR values which are marked as "safe_across_calls" */
9781 clear_register_values ();
9782 clear_qp_mutex (~qp_safe_across_calls
);
9783 clear_qp_implies (~qp_safe_across_calls
, ~qp_safe_across_calls
);
9784 clear_qp_branch_flag (~qp_safe_across_calls
);
9786 else if (is_interruption_or_rfi (idesc
)
9787 || is_taken_branch (idesc
))
9789 clear_register_values ();
9790 clear_qp_mutex (~(valueT
) 0);
9791 clear_qp_implies (~(valueT
) 0, ~(valueT
) 0);
9793 /* Look for mutex and implies relations. */
9794 else if ((idesc
->operands
[0] == IA64_OPND_P1
9795 || idesc
->operands
[0] == IA64_OPND_P2
)
9796 && (idesc
->operands
[1] == IA64_OPND_P1
9797 || idesc
->operands
[1] == IA64_OPND_P2
))
9799 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
9800 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
9801 valueT p1mask
= (p1
!= 0) ? (valueT
) 1 << p1
: 0;
9802 valueT p2mask
= (p2
!= 0) ? (valueT
) 1 << p2
: 0;
9804 /* If both PRs are PR0, we can't really do anything. */
9805 if (p1
== 0 && p2
== 0)
9808 fprintf (stderr
, " Ignoring PRs due to inclusion of p0\n");
9810 /* In general, clear mutexes and implies which include P1 or P2,
9811 with the following exceptions. */
9812 else if (has_suffix_p (idesc
->name
, ".or.andcm")
9813 || has_suffix_p (idesc
->name
, ".and.orcm"))
9815 clear_qp_implies (p2mask
, p1mask
);
9817 else if (has_suffix_p (idesc
->name
, ".andcm")
9818 || has_suffix_p (idesc
->name
, ".and"))
9820 clear_qp_implies (0, p1mask
| p2mask
);
9822 else if (has_suffix_p (idesc
->name
, ".orcm")
9823 || has_suffix_p (idesc
->name
, ".or"))
9825 clear_qp_mutex (p1mask
| p2mask
);
9826 clear_qp_implies (p1mask
| p2mask
, 0);
9832 clear_qp_implies (p1mask
| p2mask
, p1mask
| p2mask
);
9834 /* If one of the PRs is PR0, we call clear_qp_mutex. */
9835 if (p1
== 0 || p2
== 0)
9836 clear_qp_mutex (p1mask
| p2mask
);
9838 added
= update_qp_mutex (p1mask
| p2mask
);
9840 if (CURR_SLOT
.qp_regno
== 0
9841 || has_suffix_p (idesc
->name
, ".unc"))
9843 if (added
== 0 && p1
&& p2
)
9844 add_qp_mutex (p1mask
| p2mask
);
9845 if (CURR_SLOT
.qp_regno
!= 0)
9848 add_qp_imply (p1
, CURR_SLOT
.qp_regno
);
9850 add_qp_imply (p2
, CURR_SLOT
.qp_regno
);
9855 /* Look for mov imm insns into GRs. */
9856 else if (idesc
->operands
[0] == IA64_OPND_R1
9857 && (idesc
->operands
[1] == IA64_OPND_IMM22
9858 || idesc
->operands
[1] == IA64_OPND_IMMU64
)
9859 && CURR_SLOT
.opnd
[1].X_op
== O_constant
9860 && (strcmp (idesc
->name
, "mov") == 0
9861 || strcmp (idesc
->name
, "movl") == 0))
9863 int regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
9864 if (regno
> 0 && regno
< NELEMS (gr_values
))
9866 gr_values
[regno
].known
= 1;
9867 gr_values
[regno
].value
= CURR_SLOT
.opnd
[1].X_add_number
;
9868 gr_values
[regno
].path
= md
.path
;
9871 fprintf (stderr
, " Know gr%d = ", regno
);
9872 fprintf_vma (stderr
, gr_values
[regno
].value
);
9873 fputs ("\n", stderr
);
9877 /* Look for dep.z imm insns. */
9878 else if (idesc
->operands
[0] == IA64_OPND_R1
9879 && idesc
->operands
[1] == IA64_OPND_IMM8
9880 && strcmp (idesc
->name
, "dep.z") == 0)
9882 int regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
9883 if (regno
> 0 && regno
< NELEMS (gr_values
))
9885 valueT value
= CURR_SLOT
.opnd
[1].X_add_number
;
9887 if (CURR_SLOT
.opnd
[3].X_add_number
< 64)
9888 value
&= ((valueT
)1 << CURR_SLOT
.opnd
[3].X_add_number
) - 1;
9889 value
<<= CURR_SLOT
.opnd
[2].X_add_number
;
9890 gr_values
[regno
].known
= 1;
9891 gr_values
[regno
].value
= value
;
9892 gr_values
[regno
].path
= md
.path
;
9895 fprintf (stderr
, " Know gr%d = ", regno
);
9896 fprintf_vma (stderr
, gr_values
[regno
].value
);
9897 fputs ("\n", stderr
);
9903 clear_qp_mutex (qp_changemask
);
9904 clear_qp_implies (qp_changemask
, qp_changemask
);
9908 /* Return whether the given predicate registers are currently mutex. */
9911 qp_mutex (p1
, p2
, path
)
9921 mask
= ((valueT
) 1 << p1
) | (valueT
) 1 << p2
;
9922 for (i
= 0; i
< qp_mutexeslen
; i
++)
9924 if (qp_mutexes
[i
].path
>= path
9925 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
9932 /* Return whether the given resource is in the given insn's list of chks
9933 Return 1 if the conflict is absolutely determined, 2 if it's a potential
9937 resources_match (rs
, idesc
, note
, qp_regno
, path
)
9939 struct ia64_opcode
*idesc
;
9944 struct rsrc specs
[MAX_SPECS
];
9947 /* If the marked resource's qp_regno and the given qp_regno are mutex,
9948 we don't need to check. One exception is note 11, which indicates that
9949 target predicates are written regardless of PR[qp]. */
9950 if (qp_mutex (rs
->qp_regno
, qp_regno
, path
)
9954 count
= specify_resource (rs
->dependency
, idesc
, DV_CHK
, specs
, note
, path
);
9957 /* UNAT checking is a bit more specific than other resources */
9958 if (rs
->dependency
->specifier
== IA64_RS_AR_UNAT
9959 && specs
[count
].mem_offset
.hint
9960 && rs
->mem_offset
.hint
)
9962 if (rs
->mem_offset
.base
== specs
[count
].mem_offset
.base
)
9964 if (((rs
->mem_offset
.offset
>> 3) & 0x3F) ==
9965 ((specs
[count
].mem_offset
.offset
>> 3) & 0x3F))
9972 /* Skip apparent PR write conflicts where both writes are an AND or both
9973 writes are an OR. */
9974 if (rs
->dependency
->specifier
== IA64_RS_PR
9975 || rs
->dependency
->specifier
== IA64_RS_PRr
9976 || rs
->dependency
->specifier
== IA64_RS_PR63
)
9978 if (specs
[count
].cmp_type
!= CMP_NONE
9979 && specs
[count
].cmp_type
== rs
->cmp_type
)
9982 fprintf (stderr
, " %s on parallel compare allowed (PR%d)\n",
9983 dv_mode
[rs
->dependency
->mode
],
9984 rs
->dependency
->specifier
!= IA64_RS_PR63
?
9985 specs
[count
].index
: 63);
9990 " %s on parallel compare conflict %s vs %s on PR%d\n",
9991 dv_mode
[rs
->dependency
->mode
],
9992 dv_cmp_type
[rs
->cmp_type
],
9993 dv_cmp_type
[specs
[count
].cmp_type
],
9994 rs
->dependency
->specifier
!= IA64_RS_PR63
?
9995 specs
[count
].index
: 63);
9999 /* If either resource is not specific, conservatively assume a conflict
10001 if (!specs
[count
].specific
|| !rs
->specific
)
10003 else if (specs
[count
].index
== rs
->index
)
10010 /* Indicate an instruction group break; if INSERT_STOP is non-zero, then
10011 insert a stop to create the break. Update all resource dependencies
10012 appropriately. If QP_REGNO is non-zero, only apply the break to resources
10013 which use the same QP_REGNO and have the link_to_qp_branch flag set.
10014 If SAVE_CURRENT is non-zero, don't affect resources marked by the current
10018 insn_group_break (insert_stop
, qp_regno
, save_current
)
10025 if (insert_stop
&& md
.num_slots_in_use
> 0)
10026 PREV_SLOT
.end_of_insn_group
= 1;
10030 fprintf (stderr
, " Insn group break%s",
10031 (insert_stop
? " (w/stop)" : ""));
10033 fprintf (stderr
, " effective for QP=%d", qp_regno
);
10034 fprintf (stderr
, "\n");
10038 while (i
< regdepslen
)
10040 const struct ia64_dependency
*dep
= regdeps
[i
].dependency
;
10043 && regdeps
[i
].qp_regno
!= qp_regno
)
10050 && CURR_SLOT
.src_file
== regdeps
[i
].file
10051 && CURR_SLOT
.src_line
== regdeps
[i
].line
)
10057 /* clear dependencies which are automatically cleared by a stop, or
10058 those that have reached the appropriate state of insn serialization */
10059 if (dep
->semantics
== IA64_DVS_IMPLIED
10060 || dep
->semantics
== IA64_DVS_IMPLIEDF
10061 || regdeps
[i
].insn_srlz
== STATE_SRLZ
)
10063 print_dependency ("Removing", i
);
10064 regdeps
[i
] = regdeps
[--regdepslen
];
10068 if (dep
->semantics
== IA64_DVS_DATA
10069 || dep
->semantics
== IA64_DVS_INSTR
10070 || dep
->semantics
== IA64_DVS_SPECIFIC
)
10072 if (regdeps
[i
].insn_srlz
== STATE_NONE
)
10073 regdeps
[i
].insn_srlz
= STATE_STOP
;
10074 if (regdeps
[i
].data_srlz
== STATE_NONE
)
10075 regdeps
[i
].data_srlz
= STATE_STOP
;
10082 /* Add the given resource usage spec to the list of active dependencies. */
10085 mark_resource (idesc
, dep
, spec
, depind
, path
)
10086 struct ia64_opcode
*idesc ATTRIBUTE_UNUSED
;
10087 const struct ia64_dependency
*dep ATTRIBUTE_UNUSED
;
10092 if (regdepslen
== regdepstotlen
)
10094 regdepstotlen
+= 20;
10095 regdeps
= (struct rsrc
*)
10096 xrealloc ((void *) regdeps
,
10097 regdepstotlen
* sizeof (struct rsrc
));
10100 regdeps
[regdepslen
] = *spec
;
10101 regdeps
[regdepslen
].depind
= depind
;
10102 regdeps
[regdepslen
].path
= path
;
10103 regdeps
[regdepslen
].file
= CURR_SLOT
.src_file
;
10104 regdeps
[regdepslen
].line
= CURR_SLOT
.src_line
;
10106 print_dependency ("Adding", regdepslen
);
10112 print_dependency (action
, depind
)
10113 const char *action
;
10118 fprintf (stderr
, " %s %s '%s'",
10119 action
, dv_mode
[(regdeps
[depind
].dependency
)->mode
],
10120 (regdeps
[depind
].dependency
)->name
);
10121 if (regdeps
[depind
].specific
&& regdeps
[depind
].index
>= 0)
10122 fprintf (stderr
, " (%d)", regdeps
[depind
].index
);
10123 if (regdeps
[depind
].mem_offset
.hint
)
10125 fputs (" ", stderr
);
10126 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.base
);
10127 fputs ("+", stderr
);
10128 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.offset
);
10130 fprintf (stderr
, "\n");
10135 instruction_serialization ()
10139 fprintf (stderr
, " Instruction serialization\n");
10140 for (i
= 0; i
< regdepslen
; i
++)
10141 if (regdeps
[i
].insn_srlz
== STATE_STOP
)
10142 regdeps
[i
].insn_srlz
= STATE_SRLZ
;
10146 data_serialization ()
10150 fprintf (stderr
, " Data serialization\n");
10151 while (i
< regdepslen
)
10153 if (regdeps
[i
].data_srlz
== STATE_STOP
10154 /* Note: as of 991210, all "other" dependencies are cleared by a
10155 data serialization. This might change with new tables */
10156 || (regdeps
[i
].dependency
)->semantics
== IA64_DVS_OTHER
)
10158 print_dependency ("Removing", i
);
10159 regdeps
[i
] = regdeps
[--regdepslen
];
10166 /* Insert stops and serializations as needed to avoid DVs. */
10169 remove_marked_resource (rs
)
10172 switch (rs
->dependency
->semantics
)
10174 case IA64_DVS_SPECIFIC
:
10176 fprintf (stderr
, "Implementation-specific, assume worst case...\n");
10177 /* ...fall through... */
10178 case IA64_DVS_INSTR
:
10180 fprintf (stderr
, "Inserting instr serialization\n");
10181 if (rs
->insn_srlz
< STATE_STOP
)
10182 insn_group_break (1, 0, 0);
10183 if (rs
->insn_srlz
< STATE_SRLZ
)
10185 struct slot oldslot
= CURR_SLOT
;
10186 /* Manually jam a srlz.i insn into the stream */
10187 memset (&CURR_SLOT
, 0, sizeof (CURR_SLOT
));
10188 CURR_SLOT
.user_template
= -1;
10189 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.i");
10190 instruction_serialization ();
10191 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10192 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10193 emit_one_bundle ();
10194 CURR_SLOT
= oldslot
;
10196 insn_group_break (1, 0, 0);
10198 case IA64_DVS_OTHER
: /* as of rev2 (991220) of the DV tables, all
10199 "other" types of DV are eliminated
10200 by a data serialization */
10201 case IA64_DVS_DATA
:
10203 fprintf (stderr
, "Inserting data serialization\n");
10204 if (rs
->data_srlz
< STATE_STOP
)
10205 insn_group_break (1, 0, 0);
10207 struct slot oldslot
= CURR_SLOT
;
10208 /* Manually jam a srlz.d insn into the stream */
10209 memset (&CURR_SLOT
, 0, sizeof (CURR_SLOT
));
10210 CURR_SLOT
.user_template
= -1;
10211 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.d");
10212 data_serialization ();
10213 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10214 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10215 emit_one_bundle ();
10216 CURR_SLOT
= oldslot
;
10219 case IA64_DVS_IMPLIED
:
10220 case IA64_DVS_IMPLIEDF
:
10222 fprintf (stderr
, "Inserting stop\n");
10223 insn_group_break (1, 0, 0);
10230 /* Check the resources used by the given opcode against the current dependency
10233 The check is run once for each execution path encountered. In this case,
10234 a unique execution path is the sequence of instructions following a code
10235 entry point, e.g. the following has three execution paths, one starting
10236 at L0, one at L1, and one at L2.
10245 check_dependencies (idesc
)
10246 struct ia64_opcode
*idesc
;
10248 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
10252 /* Note that the number of marked resources may change within the
10253 loop if in auto mode. */
10255 while (i
< regdepslen
)
10257 struct rsrc
*rs
= ®deps
[i
];
10258 const struct ia64_dependency
*dep
= rs
->dependency
;
10261 int start_over
= 0;
10263 if (dep
->semantics
== IA64_DVS_NONE
10264 || (chkind
= depends_on (rs
->depind
, idesc
)) == -1)
10270 note
= NOTE (opdeps
->chks
[chkind
]);
10272 /* Check this resource against each execution path seen thus far. */
10273 for (path
= 0; path
<= md
.path
; path
++)
10277 /* If the dependency wasn't on the path being checked, ignore it. */
10278 if (rs
->path
< path
)
10281 /* If the QP for this insn implies a QP which has branched, don't
10282 bother checking. Ed. NOTE: I don't think this check is terribly
10283 useful; what's the point of generating code which will only be
10284 reached if its QP is zero?
10285 This code was specifically inserted to handle the following code,
10286 based on notes from Intel's DV checking code, where p1 implies p2.
10292 if (CURR_SLOT
.qp_regno
!= 0)
10296 for (implies
= 0; implies
< qp_implieslen
; implies
++)
10298 if (qp_implies
[implies
].path
>= path
10299 && qp_implies
[implies
].p1
== CURR_SLOT
.qp_regno
10300 && qp_implies
[implies
].p2_branched
)
10310 if ((matchtype
= resources_match (rs
, idesc
, note
,
10311 CURR_SLOT
.qp_regno
, path
)) != 0)
10314 char pathmsg
[256] = "";
10315 char indexmsg
[256] = "";
10316 int certain
= (matchtype
== 1 && CURR_SLOT
.qp_regno
== 0);
10319 sprintf (pathmsg
, " when entry is at label '%s'",
10320 md
.entry_labels
[path
- 1]);
10321 if (matchtype
== 1 && rs
->index
>= 0)
10322 sprintf (indexmsg
, ", specific resource number is %d",
10324 sprintf (msg
, "Use of '%s' %s %s dependency '%s' (%s)%s%s",
10326 (certain
? "violates" : "may violate"),
10327 dv_mode
[dep
->mode
], dep
->name
,
10328 dv_sem
[dep
->semantics
],
10329 pathmsg
, indexmsg
);
10331 if (md
.explicit_mode
)
10333 as_warn ("%s", msg
);
10334 if (path
< md
.path
)
10335 as_warn (_("Only the first path encountering the conflict "
10337 as_warn_where (rs
->file
, rs
->line
,
10338 _("This is the location of the "
10339 "conflicting usage"));
10340 /* Don't bother checking other paths, to avoid duplicating
10341 the same warning */
10347 fprintf (stderr
, "%s @ %s:%d\n", msg
, rs
->file
, rs
->line
);
10349 remove_marked_resource (rs
);
10351 /* since the set of dependencies has changed, start over */
10352 /* FIXME -- since we're removing dvs as we go, we
10353 probably don't really need to start over... */
10366 /* Register new dependencies based on the given opcode. */
10369 mark_resources (idesc
)
10370 struct ia64_opcode
*idesc
;
10373 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
10374 int add_only_qp_reads
= 0;
10376 /* A conditional branch only uses its resources if it is taken; if it is
10377 taken, we stop following that path. The other branch types effectively
10378 *always* write their resources. If it's not taken, register only QP
10380 if (is_conditional_branch (idesc
) || is_interruption_or_rfi (idesc
))
10382 add_only_qp_reads
= 1;
10386 fprintf (stderr
, "Registering '%s' resource usage\n", idesc
->name
);
10388 for (i
= 0; i
< opdeps
->nregs
; i
++)
10390 const struct ia64_dependency
*dep
;
10391 struct rsrc specs
[MAX_SPECS
];
10396 dep
= ia64_find_dependency (opdeps
->regs
[i
]);
10397 note
= NOTE (opdeps
->regs
[i
]);
10399 if (add_only_qp_reads
10400 && !(dep
->mode
== IA64_DV_WAR
10401 && (dep
->specifier
== IA64_RS_PR
10402 || dep
->specifier
== IA64_RS_PRr
10403 || dep
->specifier
== IA64_RS_PR63
)))
10406 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, md
.path
);
10408 while (count
-- > 0)
10410 mark_resource (idesc
, dep
, &specs
[count
],
10411 DEP (opdeps
->regs
[i
]), md
.path
);
10414 /* The execution path may affect register values, which may in turn
10415 affect which indirect-access resources are accessed. */
10416 switch (dep
->specifier
)
10420 case IA64_RS_CPUID
:
10428 for (path
= 0; path
< md
.path
; path
++)
10430 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, path
);
10431 while (count
-- > 0)
10432 mark_resource (idesc
, dep
, &specs
[count
],
10433 DEP (opdeps
->regs
[i
]), path
);
10440 /* Remove dependencies when they no longer apply. */
10443 update_dependencies (idesc
)
10444 struct ia64_opcode
*idesc
;
10448 if (strcmp (idesc
->name
, "srlz.i") == 0)
10450 instruction_serialization ();
10452 else if (strcmp (idesc
->name
, "srlz.d") == 0)
10454 data_serialization ();
10456 else if (is_interruption_or_rfi (idesc
)
10457 || is_taken_branch (idesc
))
10459 /* Although technically the taken branch doesn't clear dependencies
10460 which require a srlz.[id], we don't follow the branch; the next
10461 instruction is assumed to start with a clean slate. */
10465 else if (is_conditional_branch (idesc
)
10466 && CURR_SLOT
.qp_regno
!= 0)
10468 int is_call
= strstr (idesc
->name
, ".call") != NULL
;
10470 for (i
= 0; i
< qp_implieslen
; i
++)
10472 /* If the conditional branch's predicate is implied by the predicate
10473 in an existing dependency, remove that dependency. */
10474 if (qp_implies
[i
].p2
== CURR_SLOT
.qp_regno
)
10477 /* Note that this implied predicate takes a branch so that if
10478 a later insn generates a DV but its predicate implies this
10479 one, we can avoid the false DV warning. */
10480 qp_implies
[i
].p2_branched
= 1;
10481 while (depind
< regdepslen
)
10483 if (regdeps
[depind
].qp_regno
== qp_implies
[i
].p1
)
10485 print_dependency ("Removing", depind
);
10486 regdeps
[depind
] = regdeps
[--regdepslen
];
10493 /* Any marked resources which have this same predicate should be
10494 cleared, provided that the QP hasn't been modified between the
10495 marking instruction and the branch. */
10498 insn_group_break (0, CURR_SLOT
.qp_regno
, 1);
10503 while (i
< regdepslen
)
10505 if (regdeps
[i
].qp_regno
== CURR_SLOT
.qp_regno
10506 && regdeps
[i
].link_to_qp_branch
10507 && (regdeps
[i
].file
!= CURR_SLOT
.src_file
10508 || regdeps
[i
].line
!= CURR_SLOT
.src_line
))
10510 /* Treat like a taken branch */
10511 print_dependency ("Removing", i
);
10512 regdeps
[i
] = regdeps
[--regdepslen
];
10521 /* Examine the current instruction for dependency violations. */
10525 struct ia64_opcode
*idesc
;
10529 fprintf (stderr
, "Checking %s for violations (line %d, %d/%d)\n",
10530 idesc
->name
, CURR_SLOT
.src_line
,
10531 idesc
->dependencies
->nchks
,
10532 idesc
->dependencies
->nregs
);
10535 /* Look through the list of currently marked resources; if the current
10536 instruction has the dependency in its chks list which uses that resource,
10537 check against the specific resources used. */
10538 check_dependencies (idesc
);
10540 /* Look up the instruction's regdeps (RAW writes, WAW writes, and WAR reads),
10541 then add them to the list of marked resources. */
10542 mark_resources (idesc
);
10544 /* There are several types of dependency semantics, and each has its own
10545 requirements for being cleared
10547 Instruction serialization (insns separated by interruption, rfi, or
10548 writer + srlz.i + reader, all in separate groups) clears DVS_INSTR.
10550 Data serialization (instruction serialization, or writer + srlz.d +
10551 reader, where writer and srlz.d are in separate groups) clears
10552 DVS_DATA. (This also clears DVS_OTHER, but that is not guaranteed to
10553 always be the case).
10555 Instruction group break (groups separated by stop, taken branch,
10556 interruption or rfi) clears DVS_IMPLIED and DVS_IMPLIEDF.
10558 update_dependencies (idesc
);
10560 /* Sometimes, knowing a register value allows us to avoid giving a false DV
10561 warning. Keep track of as many as possible that are useful. */
10562 note_register_values (idesc
);
10564 /* We don't need or want this anymore. */
10565 md
.mem_offset
.hint
= 0;
10570 /* Translate one line of assembly. Pseudo ops and labels do not show
10576 char *saved_input_line_pointer
, *mnemonic
;
10577 const struct pseudo_opcode
*pdesc
;
10578 struct ia64_opcode
*idesc
;
10579 unsigned char qp_regno
;
10580 unsigned int flags
;
10583 saved_input_line_pointer
= input_line_pointer
;
10584 input_line_pointer
= str
;
10586 /* extract the opcode (mnemonic): */
10588 mnemonic
= input_line_pointer
;
10589 ch
= get_symbol_end ();
10590 pdesc
= (struct pseudo_opcode
*) hash_find (md
.pseudo_hash
, mnemonic
);
10593 *input_line_pointer
= ch
;
10594 (*pdesc
->handler
) (pdesc
->arg
);
10598 /* Find the instruction descriptor matching the arguments. */
10600 idesc
= ia64_find_opcode (mnemonic
);
10601 *input_line_pointer
= ch
;
10604 as_bad ("Unknown opcode `%s'", mnemonic
);
10608 idesc
= parse_operands (idesc
);
10612 /* Handle the dynamic ops we can handle now: */
10613 if (idesc
->type
== IA64_TYPE_DYN
)
10615 if (strcmp (idesc
->name
, "add") == 0)
10617 if (CURR_SLOT
.opnd
[2].X_op
== O_register
10618 && CURR_SLOT
.opnd
[2].X_add_number
< 4)
10622 ia64_free_opcode (idesc
);
10623 idesc
= ia64_find_opcode (mnemonic
);
10625 else if (strcmp (idesc
->name
, "mov") == 0)
10627 enum ia64_opnd opnd1
, opnd2
;
10630 opnd1
= idesc
->operands
[0];
10631 opnd2
= idesc
->operands
[1];
10632 if (opnd1
== IA64_OPND_AR3
)
10634 else if (opnd2
== IA64_OPND_AR3
)
10638 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
)
10640 if (ar_is_only_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10641 mnemonic
= "mov.i";
10642 else if (ar_is_only_in_memory_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10643 mnemonic
= "mov.m";
10651 ia64_free_opcode (idesc
);
10652 idesc
= ia64_find_opcode (mnemonic
);
10653 while (idesc
!= NULL
10654 && (idesc
->operands
[0] != opnd1
10655 || idesc
->operands
[1] != opnd2
))
10656 idesc
= get_next_opcode (idesc
);
10660 else if (strcmp (idesc
->name
, "mov.i") == 0
10661 || strcmp (idesc
->name
, "mov.m") == 0)
10663 enum ia64_opnd opnd1
, opnd2
;
10666 opnd1
= idesc
->operands
[0];
10667 opnd2
= idesc
->operands
[1];
10668 if (opnd1
== IA64_OPND_AR3
)
10670 else if (opnd2
== IA64_OPND_AR3
)
10674 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
)
10677 if (ar_is_only_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10679 else if (ar_is_only_in_memory_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10681 if (unit
!= 'a' && unit
!= idesc
->name
[4])
10682 as_bad ("AR %d cannot be accessed by %c-unit",
10683 (int) (CURR_SLOT
.opnd
[rop
].X_add_number
- REG_AR
),
10687 else if (strcmp (idesc
->name
, "hint.b") == 0)
10693 case hint_b_warning
:
10694 as_warn ("hint.b may be treated as nop");
10697 as_bad ("hint.b shouldn't be used");
10703 if (md
.qp
.X_op
== O_register
)
10705 qp_regno
= md
.qp
.X_add_number
- REG_P
;
10706 md
.qp
.X_op
= O_absent
;
10709 flags
= idesc
->flags
;
10711 if ((flags
& IA64_OPCODE_FIRST
) != 0)
10713 /* The alignment frag has to end with a stop bit only if the
10714 next instruction after the alignment directive has to be
10715 the first instruction in an instruction group. */
10718 while (align_frag
->fr_type
!= rs_align_code
)
10720 align_frag
= align_frag
->fr_next
;
10724 /* align_frag can be NULL if there are directives in
10726 if (align_frag
&& align_frag
->fr_next
== frag_now
)
10727 align_frag
->tc_frag_data
= 1;
10730 insn_group_break (1, 0, 0);
10734 if ((flags
& IA64_OPCODE_NO_PRED
) != 0 && qp_regno
!= 0)
10736 as_bad ("`%s' cannot be predicated", idesc
->name
);
10740 /* Build the instruction. */
10741 CURR_SLOT
.qp_regno
= qp_regno
;
10742 CURR_SLOT
.idesc
= idesc
;
10743 as_where (&CURR_SLOT
.src_file
, &CURR_SLOT
.src_line
);
10744 dwarf2_where (&CURR_SLOT
.debug_line
);
10746 /* Add unwind entry, if there is one. */
10747 if (unwind
.current_entry
)
10749 CURR_SLOT
.unwind_record
= unwind
.current_entry
;
10750 unwind
.current_entry
= NULL
;
10752 if (unwind
.proc_start
&& S_IS_DEFINED (unwind
.proc_start
))
10755 /* Check for dependency violations. */
10759 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10760 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10761 emit_one_bundle ();
10763 if ((flags
& IA64_OPCODE_LAST
) != 0)
10764 insn_group_break (1, 0, 0);
10766 md
.last_text_seg
= now_seg
;
10769 input_line_pointer
= saved_input_line_pointer
;
10772 /* Called when symbol NAME cannot be found in the symbol table.
10773 Should be used for dynamic valued symbols only. */
10776 md_undefined_symbol (name
)
10777 char *name ATTRIBUTE_UNUSED
;
10782 /* Called for any expression that can not be recognized. When the
10783 function is called, `input_line_pointer' will point to the start of
10790 switch (*input_line_pointer
)
10793 ++input_line_pointer
;
10795 if (*input_line_pointer
!= ']')
10797 as_bad ("Closing bracket missing");
10802 if (e
->X_op
!= O_register
)
10803 as_bad ("Register expected as index");
10805 ++input_line_pointer
;
10816 ignore_rest_of_line ();
10819 /* Return 1 if it's OK to adjust a reloc by replacing the symbol with
10820 a section symbol plus some offset. For relocs involving @fptr(),
10821 directives we don't want such adjustments since we need to have the
10822 original symbol's name in the reloc. */
10824 ia64_fix_adjustable (fix
)
10827 /* Prevent all adjustments to global symbols */
10828 if (S_IS_EXTERN (fix
->fx_addsy
) || S_IS_WEAK (fix
->fx_addsy
))
10831 switch (fix
->fx_r_type
)
10833 case BFD_RELOC_IA64_FPTR64I
:
10834 case BFD_RELOC_IA64_FPTR32MSB
:
10835 case BFD_RELOC_IA64_FPTR32LSB
:
10836 case BFD_RELOC_IA64_FPTR64MSB
:
10837 case BFD_RELOC_IA64_FPTR64LSB
:
10838 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10839 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10849 ia64_force_relocation (fix
)
10852 switch (fix
->fx_r_type
)
10854 case BFD_RELOC_IA64_FPTR64I
:
10855 case BFD_RELOC_IA64_FPTR32MSB
:
10856 case BFD_RELOC_IA64_FPTR32LSB
:
10857 case BFD_RELOC_IA64_FPTR64MSB
:
10858 case BFD_RELOC_IA64_FPTR64LSB
:
10860 case BFD_RELOC_IA64_LTOFF22
:
10861 case BFD_RELOC_IA64_LTOFF64I
:
10862 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10863 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10864 case BFD_RELOC_IA64_PLTOFF22
:
10865 case BFD_RELOC_IA64_PLTOFF64I
:
10866 case BFD_RELOC_IA64_PLTOFF64MSB
:
10867 case BFD_RELOC_IA64_PLTOFF64LSB
:
10869 case BFD_RELOC_IA64_LTOFF22X
:
10870 case BFD_RELOC_IA64_LDXMOV
:
10877 return generic_force_reloc (fix
);
10880 /* Decide from what point a pc-relative relocation is relative to,
10881 relative to the pc-relative fixup. Er, relatively speaking. */
10883 ia64_pcrel_from_section (fix
, sec
)
10887 unsigned long off
= fix
->fx_frag
->fr_address
+ fix
->fx_where
;
10889 if (bfd_get_section_flags (stdoutput
, sec
) & SEC_CODE
)
10896 /* Used to emit section-relative relocs for the dwarf2 debug data. */
10898 ia64_dwarf2_emit_offset (symbolS
*symbol
, unsigned int size
)
10902 expr
.X_op
= O_pseudo_fixup
;
10903 expr
.X_op_symbol
= pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
;
10904 expr
.X_add_number
= 0;
10905 expr
.X_add_symbol
= symbol
;
10906 emit_expr (&expr
, size
);
10909 /* This is called whenever some data item (not an instruction) needs a
10910 fixup. We pick the right reloc code depending on the byteorder
10911 currently in effect. */
10913 ia64_cons_fix_new (f
, where
, nbytes
, exp
)
10919 bfd_reloc_code_real_type code
;
10924 /* There are no reloc for 8 and 16 bit quantities, but we allow
10925 them here since they will work fine as long as the expression
10926 is fully defined at the end of the pass over the source file. */
10927 case 1: code
= BFD_RELOC_8
; break;
10928 case 2: code
= BFD_RELOC_16
; break;
10930 if (target_big_endian
)
10931 code
= BFD_RELOC_IA64_DIR32MSB
;
10933 code
= BFD_RELOC_IA64_DIR32LSB
;
10937 /* In 32-bit mode, data8 could mean function descriptors too. */
10938 if (exp
->X_op
== O_pseudo_fixup
10939 && exp
->X_op_symbol
10940 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
10941 && !(md
.flags
& EF_IA_64_ABI64
))
10943 if (target_big_endian
)
10944 code
= BFD_RELOC_IA64_IPLTMSB
;
10946 code
= BFD_RELOC_IA64_IPLTLSB
;
10947 exp
->X_op
= O_symbol
;
10952 if (target_big_endian
)
10953 code
= BFD_RELOC_IA64_DIR64MSB
;
10955 code
= BFD_RELOC_IA64_DIR64LSB
;
10960 if (exp
->X_op
== O_pseudo_fixup
10961 && exp
->X_op_symbol
10962 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
)
10964 if (target_big_endian
)
10965 code
= BFD_RELOC_IA64_IPLTMSB
;
10967 code
= BFD_RELOC_IA64_IPLTLSB
;
10968 exp
->X_op
= O_symbol
;
10974 as_bad ("Unsupported fixup size %d", nbytes
);
10975 ignore_rest_of_line ();
10979 if (exp
->X_op
== O_pseudo_fixup
)
10981 exp
->X_op
= O_symbol
;
10982 code
= ia64_gen_real_reloc_type (exp
->X_op_symbol
, code
);
10983 /* ??? If code unchanged, unsupported. */
10986 fix
= fix_new_exp (f
, where
, nbytes
, exp
, 0, code
);
10987 /* We need to store the byte order in effect in case we're going
10988 to fix an 8 or 16 bit relocation (for which there no real
10989 relocs available). See md_apply_fix3(). */
10990 fix
->tc_fix_data
.bigendian
= target_big_endian
;
10993 /* Return the actual relocation we wish to associate with the pseudo
10994 reloc described by SYM and R_TYPE. SYM should be one of the
10995 symbols in the pseudo_func array, or NULL. */
10997 static bfd_reloc_code_real_type
10998 ia64_gen_real_reloc_type (sym
, r_type
)
10999 struct symbol
*sym
;
11000 bfd_reloc_code_real_type r_type
;
11002 bfd_reloc_code_real_type
new = 0;
11003 const char *type
= NULL
, *suffix
= "";
11010 switch (S_GET_VALUE (sym
))
11012 case FUNC_FPTR_RELATIVE
:
11015 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_FPTR64I
; break;
11016 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_FPTR32MSB
; break;
11017 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_FPTR32LSB
; break;
11018 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_FPTR64MSB
; break;
11019 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_FPTR64LSB
; break;
11020 default: type
= "FPTR"; break;
11024 case FUNC_GP_RELATIVE
:
11027 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_GPREL22
; break;
11028 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_GPREL64I
; break;
11029 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_GPREL32MSB
; break;
11030 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_GPREL32LSB
; break;
11031 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_GPREL64MSB
; break;
11032 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_GPREL64LSB
; break;
11033 default: type
= "GPREL"; break;
11037 case FUNC_LT_RELATIVE
:
11040 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_LTOFF22
; break;
11041 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_LTOFF64I
; break;
11042 default: type
= "LTOFF"; break;
11046 case FUNC_LT_RELATIVE_X
:
11049 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_LTOFF22X
; break;
11050 default: type
= "LTOFF"; suffix
= "X"; break;
11054 case FUNC_PC_RELATIVE
:
11057 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PCREL22
; break;
11058 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PCREL64I
; break;
11059 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_PCREL32MSB
; break;
11060 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_PCREL32LSB
; break;
11061 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PCREL64MSB
; break;
11062 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PCREL64LSB
; break;
11063 default: type
= "PCREL"; break;
11067 case FUNC_PLT_RELATIVE
:
11070 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PLTOFF22
; break;
11071 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PLTOFF64I
; break;
11072 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PLTOFF64MSB
;break;
11073 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PLTOFF64LSB
;break;
11074 default: type
= "PLTOFF"; break;
11078 case FUNC_SEC_RELATIVE
:
11081 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SECREL32MSB
;break;
11082 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SECREL32LSB
;break;
11083 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SECREL64MSB
;break;
11084 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SECREL64LSB
;break;
11085 default: type
= "SECREL"; break;
11089 case FUNC_SEG_RELATIVE
:
11092 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SEGREL32MSB
;break;
11093 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SEGREL32LSB
;break;
11094 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SEGREL64MSB
;break;
11095 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SEGREL64LSB
;break;
11096 default: type
= "SEGREL"; break;
11100 case FUNC_LTV_RELATIVE
:
11103 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_LTV32MSB
; break;
11104 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_LTV32LSB
; break;
11105 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_LTV64MSB
; break;
11106 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_LTV64LSB
; break;
11107 default: type
= "LTV"; break;
11111 case FUNC_LT_FPTR_RELATIVE
:
11114 case BFD_RELOC_IA64_IMM22
:
11115 new = BFD_RELOC_IA64_LTOFF_FPTR22
; break;
11116 case BFD_RELOC_IA64_IMM64
:
11117 new = BFD_RELOC_IA64_LTOFF_FPTR64I
; break;
11118 case BFD_RELOC_IA64_DIR32MSB
:
11119 new = BFD_RELOC_IA64_LTOFF_FPTR32MSB
; break;
11120 case BFD_RELOC_IA64_DIR32LSB
:
11121 new = BFD_RELOC_IA64_LTOFF_FPTR32LSB
; break;
11122 case BFD_RELOC_IA64_DIR64MSB
:
11123 new = BFD_RELOC_IA64_LTOFF_FPTR64MSB
; break;
11124 case BFD_RELOC_IA64_DIR64LSB
:
11125 new = BFD_RELOC_IA64_LTOFF_FPTR64LSB
; break;
11127 type
= "LTOFF_FPTR"; break;
11131 case FUNC_TP_RELATIVE
:
11134 case BFD_RELOC_IA64_IMM14
: new = BFD_RELOC_IA64_TPREL14
; break;
11135 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_TPREL22
; break;
11136 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_TPREL64I
; break;
11137 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_TPREL64MSB
; break;
11138 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_TPREL64LSB
; break;
11139 default: type
= "TPREL"; break;
11143 case FUNC_LT_TP_RELATIVE
:
11146 case BFD_RELOC_IA64_IMM22
:
11147 new = BFD_RELOC_IA64_LTOFF_TPREL22
; break;
11149 type
= "LTOFF_TPREL"; break;
11153 case FUNC_DTP_MODULE
:
11156 case BFD_RELOC_IA64_DIR64MSB
:
11157 new = BFD_RELOC_IA64_DTPMOD64MSB
; break;
11158 case BFD_RELOC_IA64_DIR64LSB
:
11159 new = BFD_RELOC_IA64_DTPMOD64LSB
; break;
11161 type
= "DTPMOD"; break;
11165 case FUNC_LT_DTP_MODULE
:
11168 case BFD_RELOC_IA64_IMM22
:
11169 new = BFD_RELOC_IA64_LTOFF_DTPMOD22
; break;
11171 type
= "LTOFF_DTPMOD"; break;
11175 case FUNC_DTP_RELATIVE
:
11178 case BFD_RELOC_IA64_DIR32MSB
:
11179 new = BFD_RELOC_IA64_DTPREL32MSB
; break;
11180 case BFD_RELOC_IA64_DIR32LSB
:
11181 new = BFD_RELOC_IA64_DTPREL32LSB
; break;
11182 case BFD_RELOC_IA64_DIR64MSB
:
11183 new = BFD_RELOC_IA64_DTPREL64MSB
; break;
11184 case BFD_RELOC_IA64_DIR64LSB
:
11185 new = BFD_RELOC_IA64_DTPREL64LSB
; break;
11186 case BFD_RELOC_IA64_IMM14
:
11187 new = BFD_RELOC_IA64_DTPREL14
; break;
11188 case BFD_RELOC_IA64_IMM22
:
11189 new = BFD_RELOC_IA64_DTPREL22
; break;
11190 case BFD_RELOC_IA64_IMM64
:
11191 new = BFD_RELOC_IA64_DTPREL64I
; break;
11193 type
= "DTPREL"; break;
11197 case FUNC_LT_DTP_RELATIVE
:
11200 case BFD_RELOC_IA64_IMM22
:
11201 new = BFD_RELOC_IA64_LTOFF_DTPREL22
; break;
11203 type
= "LTOFF_DTPREL"; break;
11207 case FUNC_IPLT_RELOC
:
11210 case BFD_RELOC_IA64_IPLTMSB
: return r_type
;
11211 case BFD_RELOC_IA64_IPLTLSB
: return r_type
;
11212 default: type
= "IPLT"; break;
11230 case BFD_RELOC_IA64_DIR32MSB
: width
= 32; suffix
= "MSB"; break;
11231 case BFD_RELOC_IA64_DIR32LSB
: width
= 32; suffix
= "LSB"; break;
11232 case BFD_RELOC_IA64_DIR64MSB
: width
= 64; suffix
= "MSB"; break;
11233 case BFD_RELOC_IA64_DIR64LSB
: width
= 64; suffix
= "LSB"; break;
11234 case BFD_RELOC_IA64_IMM14
: width
= 14; break;
11235 case BFD_RELOC_IA64_IMM22
: width
= 22; break;
11236 case BFD_RELOC_IA64_IMM64
: width
= 64; suffix
= "I"; break;
11240 /* This should be an error, but since previously there wasn't any
11241 diagnostic here, dont't make it fail because of this for now. */
11242 as_warn ("Cannot express %s%d%s relocation", type
, width
, suffix
);
11247 /* Here is where generate the appropriate reloc for pseudo relocation
11250 ia64_validate_fix (fix
)
11253 switch (fix
->fx_r_type
)
11255 case BFD_RELOC_IA64_FPTR64I
:
11256 case BFD_RELOC_IA64_FPTR32MSB
:
11257 case BFD_RELOC_IA64_FPTR64LSB
:
11258 case BFD_RELOC_IA64_LTOFF_FPTR22
:
11259 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
11260 if (fix
->fx_offset
!= 0)
11261 as_bad_where (fix
->fx_file
, fix
->fx_line
,
11262 "No addend allowed in @fptr() relocation");
11270 fix_insn (fix
, odesc
, value
)
11272 const struct ia64_operand
*odesc
;
11275 bfd_vma insn
[3], t0
, t1
, control_bits
;
11280 slot
= fix
->fx_where
& 0x3;
11281 fixpos
= fix
->fx_frag
->fr_literal
+ (fix
->fx_where
- slot
);
11283 /* Bundles are always in little-endian byte order */
11284 t0
= bfd_getl64 (fixpos
);
11285 t1
= bfd_getl64 (fixpos
+ 8);
11286 control_bits
= t0
& 0x1f;
11287 insn
[0] = (t0
>> 5) & 0x1ffffffffffLL
;
11288 insn
[1] = ((t0
>> 46) & 0x3ffff) | ((t1
& 0x7fffff) << 18);
11289 insn
[2] = (t1
>> 23) & 0x1ffffffffffLL
;
11292 if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU64
)
11294 insn
[1] = (value
>> 22) & 0x1ffffffffffLL
;
11295 insn
[2] |= (((value
& 0x7f) << 13)
11296 | (((value
>> 7) & 0x1ff) << 27)
11297 | (((value
>> 16) & 0x1f) << 22)
11298 | (((value
>> 21) & 0x1) << 21)
11299 | (((value
>> 63) & 0x1) << 36));
11301 else if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU62
)
11303 if (value
& ~0x3fffffffffffffffULL
)
11304 err
= "integer operand out of range";
11305 insn
[1] = (value
>> 21) & 0x1ffffffffffLL
;
11306 insn
[2] |= (((value
& 0xfffff) << 6) | (((value
>> 20) & 0x1) << 36));
11308 else if (odesc
- elf64_ia64_operands
== IA64_OPND_TGT64
)
11311 insn
[1] = ((value
>> 20) & 0x7fffffffffLL
) << 2;
11312 insn
[2] |= ((((value
>> 59) & 0x1) << 36)
11313 | (((value
>> 0) & 0xfffff) << 13));
11316 err
= (*odesc
->insert
) (odesc
, value
, insn
+ slot
);
11319 as_bad_where (fix
->fx_file
, fix
->fx_line
, err
);
11321 t0
= control_bits
| (insn
[0] << 5) | (insn
[1] << 46);
11322 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
11323 number_to_chars_littleendian (fixpos
+ 0, t0
, 8);
11324 number_to_chars_littleendian (fixpos
+ 8, t1
, 8);
11327 /* Attempt to simplify or even eliminate a fixup. The return value is
11328 ignored; perhaps it was once meaningful, but now it is historical.
11329 To indicate that a fixup has been eliminated, set FIXP->FX_DONE.
11331 If fixp->fx_addsy is non-NULL, we'll have to generate a reloc entry
11335 md_apply_fix3 (fix
, valP
, seg
)
11338 segT seg ATTRIBUTE_UNUSED
;
11341 valueT value
= *valP
;
11343 fixpos
= fix
->fx_frag
->fr_literal
+ fix
->fx_where
;
11347 switch (fix
->fx_r_type
)
11349 case BFD_RELOC_IA64_PCREL21B
: break;
11350 case BFD_RELOC_IA64_PCREL21BI
: break;
11351 case BFD_RELOC_IA64_PCREL21F
: break;
11352 case BFD_RELOC_IA64_PCREL21M
: break;
11353 case BFD_RELOC_IA64_PCREL60B
: break;
11354 case BFD_RELOC_IA64_PCREL22
: break;
11355 case BFD_RELOC_IA64_PCREL64I
: break;
11356 case BFD_RELOC_IA64_PCREL32MSB
: break;
11357 case BFD_RELOC_IA64_PCREL32LSB
: break;
11358 case BFD_RELOC_IA64_PCREL64MSB
: break;
11359 case BFD_RELOC_IA64_PCREL64LSB
: break;
11361 fix
->fx_r_type
= ia64_gen_real_reloc_type (pseudo_func
[FUNC_PC_RELATIVE
].u
.sym
,
11368 switch (fix
->fx_r_type
)
11370 case BFD_RELOC_UNUSED
:
11371 /* This must be a TAG13 or TAG13b operand. There are no external
11372 relocs defined for them, so we must give an error. */
11373 as_bad_where (fix
->fx_file
, fix
->fx_line
,
11374 "%s must have a constant value",
11375 elf64_ia64_operands
[fix
->tc_fix_data
.opnd
].desc
);
11379 case BFD_RELOC_IA64_TPREL14
:
11380 case BFD_RELOC_IA64_TPREL22
:
11381 case BFD_RELOC_IA64_TPREL64I
:
11382 case BFD_RELOC_IA64_LTOFF_TPREL22
:
11383 case BFD_RELOC_IA64_LTOFF_DTPMOD22
:
11384 case BFD_RELOC_IA64_DTPREL14
:
11385 case BFD_RELOC_IA64_DTPREL22
:
11386 case BFD_RELOC_IA64_DTPREL64I
:
11387 case BFD_RELOC_IA64_LTOFF_DTPREL22
:
11388 S_SET_THREAD_LOCAL (fix
->fx_addsy
);
11395 else if (fix
->tc_fix_data
.opnd
== IA64_OPND_NIL
)
11397 if (fix
->tc_fix_data
.bigendian
)
11398 number_to_chars_bigendian (fixpos
, value
, fix
->fx_size
);
11400 number_to_chars_littleendian (fixpos
, value
, fix
->fx_size
);
11405 fix_insn (fix
, elf64_ia64_operands
+ fix
->tc_fix_data
.opnd
, value
);
11410 /* Generate the BFD reloc to be stuck in the object file from the
11411 fixup used internally in the assembler. */
11414 tc_gen_reloc (sec
, fixp
)
11415 asection
*sec ATTRIBUTE_UNUSED
;
11420 reloc
= xmalloc (sizeof (*reloc
));
11421 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
11422 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
11423 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
11424 reloc
->addend
= fixp
->fx_offset
;
11425 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
11429 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
11430 "Cannot represent %s relocation in object file",
11431 bfd_get_reloc_code_name (fixp
->fx_r_type
));
11436 /* Turn a string in input_line_pointer into a floating point constant
11437 of type TYPE, and store the appropriate bytes in *LIT. The number
11438 of LITTLENUMS emitted is stored in *SIZE. An error message is
11439 returned, or NULL on OK. */
11441 #define MAX_LITTLENUMS 5
11444 md_atof (type
, lit
, size
)
11449 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
11479 return "Bad call to MD_ATOF()";
11481 t
= atof_ieee (input_line_pointer
, type
, words
);
11483 input_line_pointer
= t
;
11485 (*ia64_float_to_chars
) (lit
, words
, prec
);
11489 /* It is 10 byte floating point with 6 byte padding. */
11490 memset (&lit
[10], 0, 6);
11491 *size
= 8 * sizeof (LITTLENUM_TYPE
);
11494 *size
= prec
* sizeof (LITTLENUM_TYPE
);
11499 /* Handle ia64 specific semantics of the align directive. */
11502 ia64_md_do_align (n
, fill
, len
, max
)
11503 int n ATTRIBUTE_UNUSED
;
11504 const char *fill ATTRIBUTE_UNUSED
;
11505 int len ATTRIBUTE_UNUSED
;
11506 int max ATTRIBUTE_UNUSED
;
11508 if (subseg_text_p (now_seg
))
11509 ia64_flush_insns ();
11512 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
11513 of an rs_align_code fragment. */
11516 ia64_handle_align (fragp
)
11519 /* Use mfi bundle of nops with no stop bits. */
11520 static const unsigned char le_nop
[]
11521 = { 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11522 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00};
11523 static const unsigned char le_nop_stop
[]
11524 = { 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11525 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00};
11529 const unsigned char *nop
;
11531 if (fragp
->fr_type
!= rs_align_code
)
11534 /* Check if this frag has to end with a stop bit. */
11535 nop
= fragp
->tc_frag_data
? le_nop_stop
: le_nop
;
11537 bytes
= fragp
->fr_next
->fr_address
- fragp
->fr_address
- fragp
->fr_fix
;
11538 p
= fragp
->fr_literal
+ fragp
->fr_fix
;
11540 /* If no paddings are needed, we check if we need a stop bit. */
11541 if (!bytes
&& fragp
->tc_frag_data
)
11543 if (fragp
->fr_fix
< 16)
11545 /* FIXME: It won't work with
11547 alloc r32=ar.pfs,1,2,4,0
11551 as_bad_where (fragp
->fr_file
, fragp
->fr_line
,
11552 _("Can't add stop bit to mark end of instruction group"));
11555 /* Bundles are always in little-endian byte order. Make sure
11556 the previous bundle has the stop bit. */
11560 /* Make sure we are on a 16-byte boundary, in case someone has been
11561 putting data into a text section. */
11564 int fix
= bytes
& 15;
11565 memset (p
, 0, fix
);
11568 fragp
->fr_fix
+= fix
;
11571 /* Instruction bundles are always little-endian. */
11572 memcpy (p
, nop
, 16);
11573 fragp
->fr_var
= 16;
11577 ia64_float_to_chars_bigendian (char *lit
, LITTLENUM_TYPE
*words
,
11582 number_to_chars_bigendian (lit
, (long) (*words
++),
11583 sizeof (LITTLENUM_TYPE
));
11584 lit
+= sizeof (LITTLENUM_TYPE
);
11589 ia64_float_to_chars_littleendian (char *lit
, LITTLENUM_TYPE
*words
,
11594 number_to_chars_littleendian (lit
, (long) (words
[prec
]),
11595 sizeof (LITTLENUM_TYPE
));
11596 lit
+= sizeof (LITTLENUM_TYPE
);
11601 ia64_elf_section_change_hook (void)
11603 if (elf_section_type (now_seg
) == SHT_IA_64_UNWIND
11604 && elf_linked_to_section (now_seg
) == NULL
)
11605 elf_linked_to_section (now_seg
) = text_section
;
11606 dot_byteorder (-1);
11609 /* Check if a label should be made global. */
11611 ia64_check_label (symbolS
*label
)
11613 if (*input_line_pointer
== ':')
11615 S_SET_EXTERNAL (label
);
11616 input_line_pointer
++;
11620 /* Used to remember where .alias and .secalias directives are seen. We
11621 will rename symbol and section names when we are about to output
11622 the relocatable file. */
11625 char *file
; /* The file where the directive is seen. */
11626 unsigned int line
; /* The line number the directive is at. */
11627 const char *name
; /* The orignale name of the symbol. */
11630 /* Called for .alias and .secalias directives. If SECTION is 1, it is
11631 .secalias. Otherwise, it is .alias. */
11633 dot_alias (int section
)
11635 char *name
, *alias
;
11639 const char *error_string
;
11642 struct hash_control
*ahash
, *nhash
;
11645 name
= input_line_pointer
;
11646 delim
= get_symbol_end ();
11647 end_name
= input_line_pointer
;
11650 if (name
== end_name
)
11652 as_bad (_("expected symbol name"));
11653 discard_rest_of_line ();
11657 SKIP_WHITESPACE ();
11659 if (*input_line_pointer
!= ',')
11662 as_bad (_("expected comma after \"%s\""), name
);
11664 ignore_rest_of_line ();
11668 input_line_pointer
++;
11670 ia64_canonicalize_symbol_name (name
);
11672 /* We call demand_copy_C_string to check if alias string is valid.
11673 There should be a closing `"' and no `\0' in the string. */
11674 alias
= demand_copy_C_string (&len
);
11677 ignore_rest_of_line ();
11681 /* Make a copy of name string. */
11682 len
= strlen (name
) + 1;
11683 obstack_grow (¬es
, name
, len
);
11684 name
= obstack_finish (¬es
);
11689 ahash
= secalias_hash
;
11690 nhash
= secalias_name_hash
;
11695 ahash
= alias_hash
;
11696 nhash
= alias_name_hash
;
11699 /* Check if alias has been used before. */
11700 h
= (struct alias
*) hash_find (ahash
, alias
);
11703 if (strcmp (h
->name
, name
))
11704 as_bad (_("`%s' is already the alias of %s `%s'"),
11705 alias
, kind
, h
->name
);
11709 /* Check if name already has an alias. */
11710 a
= (const char *) hash_find (nhash
, name
);
11713 if (strcmp (a
, alias
))
11714 as_bad (_("%s `%s' already has an alias `%s'"), kind
, name
, a
);
11718 h
= (struct alias
*) xmalloc (sizeof (struct alias
));
11719 as_where (&h
->file
, &h
->line
);
11722 error_string
= hash_jam (ahash
, alias
, (PTR
) h
);
11725 as_fatal (_("inserting \"%s\" into %s alias hash table failed: %s"),
11726 alias
, kind
, error_string
);
11730 error_string
= hash_jam (nhash
, name
, (PTR
) alias
);
11733 as_fatal (_("inserting \"%s\" into %s name hash table failed: %s"),
11734 alias
, kind
, error_string
);
11736 obstack_free (¬es
, name
);
11737 obstack_free (¬es
, alias
);
11740 demand_empty_rest_of_line ();
11743 /* It renames the original symbol name to its alias. */
11745 do_alias (const char *alias
, PTR value
)
11747 struct alias
*h
= (struct alias
*) value
;
11748 symbolS
*sym
= symbol_find (h
->name
);
11751 as_warn_where (h
->file
, h
->line
,
11752 _("symbol `%s' aliased to `%s' is not used"),
11755 S_SET_NAME (sym
, (char *) alias
);
11758 /* Called from write_object_file. */
11760 ia64_adjust_symtab (void)
11762 hash_traverse (alias_hash
, do_alias
);
11765 /* It renames the original section name to its alias. */
11767 do_secalias (const char *alias
, PTR value
)
11769 struct alias
*h
= (struct alias
*) value
;
11770 segT sec
= bfd_get_section_by_name (stdoutput
, h
->name
);
11773 as_warn_where (h
->file
, h
->line
,
11774 _("section `%s' aliased to `%s' is not used"),
11780 /* Called from write_object_file. */
11782 ia64_frob_file (void)
11784 hash_traverse (secalias_hash
, do_secalias
);