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, 51 Franklin Street - Fifth Floor,
21 Boston, MA 02110-1301, USA. */
35 - labels are wrong if automatic alignment is introduced
36 (e.g., checkout the second real10 definition in test-data.s)
38 <reg>.safe_across_calls and any other DV-related directives I don't
39 have documentation for.
40 verify mod-sched-brs reads/writes are checked/marked (and other
46 #include "safe-ctype.h"
47 #include "dwarf2dbg.h"
50 #include "opcode/ia64.h"
58 #define NELEMS(a) ((int) (sizeof (a)/sizeof ((a)[0])))
60 /* Some systems define MIN in, e.g., param.h. */
62 #define MIN(a,b) ((a) < (b) ? (a) : (b))
65 #define PREV_SLOT md.slot[(md.curr_slot + NUM_SLOTS - 1) % NUM_SLOTS]
66 #define CURR_SLOT md.slot[md.curr_slot]
68 #define O_pseudo_fixup (O_max + 1)
72 /* IA-64 ABI section pseudo-ops. */
73 SPECIAL_SECTION_BSS
= 0,
75 SPECIAL_SECTION_SDATA
,
76 SPECIAL_SECTION_RODATA
,
77 SPECIAL_SECTION_COMMENT
,
78 SPECIAL_SECTION_UNWIND
,
79 SPECIAL_SECTION_UNWIND_INFO
,
80 /* HPUX specific section pseudo-ops. */
81 SPECIAL_SECTION_INIT_ARRAY
,
82 SPECIAL_SECTION_FINI_ARRAY
,
99 FUNC_LT_FPTR_RELATIVE
,
101 FUNC_LT_DTP_RELATIVE
,
109 REG_FR
= (REG_GR
+ 128),
110 REG_AR
= (REG_FR
+ 128),
111 REG_CR
= (REG_AR
+ 128),
112 REG_P
= (REG_CR
+ 128),
113 REG_BR
= (REG_P
+ 64),
114 REG_IP
= (REG_BR
+ 8),
121 /* The following are pseudo-registers for use by gas only. */
133 /* The following pseudo-registers are used for unwind directives only: */
141 DYNREG_GR
= 0, /* dynamic general purpose register */
142 DYNREG_FR
, /* dynamic floating point register */
143 DYNREG_PR
, /* dynamic predicate register */
147 enum operand_match_result
150 OPERAND_OUT_OF_RANGE
,
154 /* On the ia64, we can't know the address of a text label until the
155 instructions are packed into a bundle. To handle this, we keep
156 track of the list of labels that appear in front of each
160 struct label_fix
*next
;
164 /* This is the endianness of the current section. */
165 extern int target_big_endian
;
167 /* This is the default endianness. */
168 static int default_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
170 void (*ia64_number_to_chars
) PARAMS ((char *, valueT
, int));
172 static void ia64_float_to_chars_bigendian
173 PARAMS ((char *, LITTLENUM_TYPE
*, int));
174 static void ia64_float_to_chars_littleendian
175 PARAMS ((char *, LITTLENUM_TYPE
*, int));
176 static void (*ia64_float_to_chars
)
177 PARAMS ((char *, LITTLENUM_TYPE
*, int));
179 static struct hash_control
*alias_hash
;
180 static struct hash_control
*alias_name_hash
;
181 static struct hash_control
*secalias_hash
;
182 static struct hash_control
*secalias_name_hash
;
184 /* List of chars besides those in app.c:symbol_chars that can start an
185 operand. Used to prevent the scrubber eating vital white-space. */
186 const char ia64_symbol_chars
[] = "@?";
188 /* Characters which always start a comment. */
189 const char comment_chars
[] = "";
191 /* Characters which start a comment at the beginning of a line. */
192 const char line_comment_chars
[] = "#";
194 /* Characters which may be used to separate multiple commands on a
196 const char line_separator_chars
[] = ";";
198 /* Characters which are used to indicate an exponent in a floating
200 const char EXP_CHARS
[] = "eE";
202 /* Characters which mean that a number is a floating point constant,
204 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
206 /* ia64-specific option processing: */
208 const char *md_shortopts
= "m:N:x::";
210 struct option md_longopts
[] =
212 #define OPTION_MCONSTANT_GP (OPTION_MD_BASE + 1)
213 {"mconstant-gp", no_argument
, NULL
, OPTION_MCONSTANT_GP
},
214 #define OPTION_MAUTO_PIC (OPTION_MD_BASE + 2)
215 {"mauto-pic", no_argument
, NULL
, OPTION_MAUTO_PIC
}
218 size_t md_longopts_size
= sizeof (md_longopts
);
222 struct hash_control
*pseudo_hash
; /* pseudo opcode hash table */
223 struct hash_control
*reg_hash
; /* register name hash table */
224 struct hash_control
*dynreg_hash
; /* dynamic register hash table */
225 struct hash_control
*const_hash
; /* constant hash table */
226 struct hash_control
*entry_hash
; /* code entry hint hash table */
228 symbolS
*regsym
[REG_NUM
];
230 /* If X_op is != O_absent, the registername for the instruction's
231 qualifying predicate. If NULL, p0 is assumed for instructions
232 that are predicatable. */
235 /* Optimize for which CPU. */
242 /* What to do when hint.b is used. */
254 explicit_mode
: 1, /* which mode we're in */
255 default_explicit_mode
: 1, /* which mode is the default */
256 mode_explicitly_set
: 1, /* was the current mode explicitly set? */
258 keep_pending_output
: 1;
260 /* What to do when something is wrong with unwind directives. */
263 unwind_check_warning
,
267 /* Each bundle consists of up to three instructions. We keep
268 track of four most recent instructions so we can correctly set
269 the end_of_insn_group for the last instruction in a bundle. */
271 int num_slots_in_use
;
275 end_of_insn_group
: 1,
276 manual_bundling_on
: 1,
277 manual_bundling_off
: 1,
278 loc_directive_seen
: 1;
279 signed char user_template
; /* user-selected template, if any */
280 unsigned char qp_regno
; /* qualifying predicate */
281 /* This duplicates a good fraction of "struct fix" but we
282 can't use a "struct fix" instead since we can't call
283 fix_new_exp() until we know the address of the instruction. */
287 bfd_reloc_code_real_type code
;
288 enum ia64_opnd opnd
; /* type of operand in need of fix */
289 unsigned int is_pcrel
: 1; /* is operand pc-relative? */
290 expressionS expr
; /* the value to be inserted */
292 fixup
[2]; /* at most two fixups per insn */
293 struct ia64_opcode
*idesc
;
294 struct label_fix
*label_fixups
;
295 struct label_fix
*tag_fixups
;
296 struct unw_rec_list
*unwind_record
; /* Unwind directive. */
299 unsigned int src_line
;
300 struct dwarf2_line_info debug_line
;
308 struct dynreg
*next
; /* next dynamic register */
310 unsigned short base
; /* the base register number */
311 unsigned short num_regs
; /* # of registers in this set */
313 *dynreg
[DYNREG_NUM_TYPES
], in
, loc
, out
, rot
;
315 flagword flags
; /* ELF-header flags */
318 unsigned hint
:1; /* is this hint currently valid? */
319 bfd_vma offset
; /* mem.offset offset */
320 bfd_vma base
; /* mem.offset base */
323 int path
; /* number of alt. entry points seen */
324 const char **entry_labels
; /* labels of all alternate paths in
325 the current DV-checking block. */
326 int maxpaths
; /* size currently allocated for
329 int pointer_size
; /* size in bytes of a pointer */
330 int pointer_size_shift
; /* shift size of a pointer for alignment */
334 /* These are not const, because they are modified to MMI for non-itanium1
336 /* MFI bundle of nops. */
337 static unsigned char le_nop
[16] =
339 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
340 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00
342 /* MFI bundle of nops with stop-bit. */
343 static unsigned char le_nop_stop
[16] =
345 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
346 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00
349 /* application registers: */
355 #define AR_BSPSTORE 18
370 {"ar.k0", 0}, {"ar.k1", 1}, {"ar.k2", 2}, {"ar.k3", 3},
371 {"ar.k4", 4}, {"ar.k5", 5}, {"ar.k6", 6}, {"ar.k7", 7},
372 {"ar.rsc", 16}, {"ar.bsp", 17},
373 {"ar.bspstore", 18}, {"ar.rnat", 19},
374 {"ar.fcr", 21}, {"ar.eflag", 24},
375 {"ar.csd", 25}, {"ar.ssd", 26},
376 {"ar.cflg", 27}, {"ar.fsr", 28},
377 {"ar.fir", 29}, {"ar.fdr", 30},
378 {"ar.ccv", 32}, {"ar.unat", 36},
379 {"ar.fpsr", 40}, {"ar.itc", 44},
380 {"ar.pfs", 64}, {"ar.lc", 65},
401 /* control registers: */
443 static const struct const_desc
450 /* PSR constant masks: */
453 {"psr.be", ((valueT
) 1) << 1},
454 {"psr.up", ((valueT
) 1) << 2},
455 {"psr.ac", ((valueT
) 1) << 3},
456 {"psr.mfl", ((valueT
) 1) << 4},
457 {"psr.mfh", ((valueT
) 1) << 5},
459 {"psr.ic", ((valueT
) 1) << 13},
460 {"psr.i", ((valueT
) 1) << 14},
461 {"psr.pk", ((valueT
) 1) << 15},
463 {"psr.dt", ((valueT
) 1) << 17},
464 {"psr.dfl", ((valueT
) 1) << 18},
465 {"psr.dfh", ((valueT
) 1) << 19},
466 {"psr.sp", ((valueT
) 1) << 20},
467 {"psr.pp", ((valueT
) 1) << 21},
468 {"psr.di", ((valueT
) 1) << 22},
469 {"psr.si", ((valueT
) 1) << 23},
470 {"psr.db", ((valueT
) 1) << 24},
471 {"psr.lp", ((valueT
) 1) << 25},
472 {"psr.tb", ((valueT
) 1) << 26},
473 {"psr.rt", ((valueT
) 1) << 27},
474 /* 28-31: reserved */
475 /* 32-33: cpl (current privilege level) */
476 {"psr.is", ((valueT
) 1) << 34},
477 {"psr.mc", ((valueT
) 1) << 35},
478 {"psr.it", ((valueT
) 1) << 36},
479 {"psr.id", ((valueT
) 1) << 37},
480 {"psr.da", ((valueT
) 1) << 38},
481 {"psr.dd", ((valueT
) 1) << 39},
482 {"psr.ss", ((valueT
) 1) << 40},
483 /* 41-42: ri (restart instruction) */
484 {"psr.ed", ((valueT
) 1) << 43},
485 {"psr.bn", ((valueT
) 1) << 44},
488 /* indirect register-sets/memory: */
497 { "CPUID", IND_CPUID
},
498 { "cpuid", IND_CPUID
},
510 /* Pseudo functions used to indicate relocation types (these functions
511 start with an at sign (@). */
533 /* reloc pseudo functions (these must come first!): */
534 { "dtpmod", PSEUDO_FUNC_RELOC
, { 0 } },
535 { "dtprel", PSEUDO_FUNC_RELOC
, { 0 } },
536 { "fptr", PSEUDO_FUNC_RELOC
, { 0 } },
537 { "gprel", PSEUDO_FUNC_RELOC
, { 0 } },
538 { "ltoff", PSEUDO_FUNC_RELOC
, { 0 } },
539 { "ltoffx", PSEUDO_FUNC_RELOC
, { 0 } },
540 { "pcrel", PSEUDO_FUNC_RELOC
, { 0 } },
541 { "pltoff", PSEUDO_FUNC_RELOC
, { 0 } },
542 { "secrel", PSEUDO_FUNC_RELOC
, { 0 } },
543 { "segrel", PSEUDO_FUNC_RELOC
, { 0 } },
544 { "tprel", PSEUDO_FUNC_RELOC
, { 0 } },
545 { "ltv", PSEUDO_FUNC_RELOC
, { 0 } },
546 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_FPTR_RELATIVE */
547 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_DTP_MODULE */
548 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_DTP_RELATIVE */
549 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_TP_RELATIVE */
550 { "iplt", PSEUDO_FUNC_RELOC
, { 0 } },
552 /* mbtype4 constants: */
553 { "alt", PSEUDO_FUNC_CONST
, { 0xa } },
554 { "brcst", PSEUDO_FUNC_CONST
, { 0x0 } },
555 { "mix", PSEUDO_FUNC_CONST
, { 0x8 } },
556 { "rev", PSEUDO_FUNC_CONST
, { 0xb } },
557 { "shuf", PSEUDO_FUNC_CONST
, { 0x9 } },
559 /* fclass constants: */
560 { "nat", PSEUDO_FUNC_CONST
, { 0x100 } },
561 { "qnan", PSEUDO_FUNC_CONST
, { 0x080 } },
562 { "snan", PSEUDO_FUNC_CONST
, { 0x040 } },
563 { "pos", PSEUDO_FUNC_CONST
, { 0x001 } },
564 { "neg", PSEUDO_FUNC_CONST
, { 0x002 } },
565 { "zero", PSEUDO_FUNC_CONST
, { 0x004 } },
566 { "unorm", PSEUDO_FUNC_CONST
, { 0x008 } },
567 { "norm", PSEUDO_FUNC_CONST
, { 0x010 } },
568 { "inf", PSEUDO_FUNC_CONST
, { 0x020 } },
570 { "natval", PSEUDO_FUNC_CONST
, { 0x100 } }, /* old usage */
572 /* hint constants: */
573 { "pause", PSEUDO_FUNC_CONST
, { 0x0 } },
575 /* unwind-related constants: */
576 { "svr4", PSEUDO_FUNC_CONST
, { ELFOSABI_NONE
} },
577 { "hpux", PSEUDO_FUNC_CONST
, { ELFOSABI_HPUX
} },
578 { "nt", PSEUDO_FUNC_CONST
, { 2 } }, /* conflicts w/ELFOSABI_NETBSD */
579 { "linux", PSEUDO_FUNC_CONST
, { ELFOSABI_LINUX
} },
580 { "freebsd", PSEUDO_FUNC_CONST
, { ELFOSABI_FREEBSD
} },
581 { "openvms", PSEUDO_FUNC_CONST
, { ELFOSABI_OPENVMS
} },
582 { "nsk", PSEUDO_FUNC_CONST
, { ELFOSABI_NSK
} },
584 /* unwind-related registers: */
585 { "priunat",PSEUDO_FUNC_REG
, { REG_PRIUNAT
} }
588 /* 41-bit nop opcodes (one per unit): */
589 static const bfd_vma nop
[IA64_NUM_UNITS
] =
591 0x0000000000LL
, /* NIL => break 0 */
592 0x0008000000LL
, /* I-unit nop */
593 0x0008000000LL
, /* M-unit nop */
594 0x4000000000LL
, /* B-unit nop */
595 0x0008000000LL
, /* F-unit nop */
596 0x0008000000LL
, /* L-"unit" nop */
597 0x0008000000LL
, /* X-unit nop */
600 /* Can't be `const' as it's passed to input routines (which have the
601 habit of setting temporary sentinels. */
602 static char special_section_name
[][20] =
604 {".bss"}, {".sbss"}, {".sdata"}, {".rodata"}, {".comment"},
605 {".IA_64.unwind"}, {".IA_64.unwind_info"},
606 {".init_array"}, {".fini_array"}
609 /* The best template for a particular sequence of up to three
611 #define N IA64_NUM_TYPES
612 static unsigned char best_template
[N
][N
][N
];
615 /* Resource dependencies currently in effect */
617 int depind
; /* dependency index */
618 const struct ia64_dependency
*dependency
; /* actual dependency */
619 unsigned specific
:1, /* is this a specific bit/regno? */
620 link_to_qp_branch
:1; /* will a branch on the same QP clear it?*/
621 int index
; /* specific regno/bit within dependency */
622 int note
; /* optional qualifying note (0 if none) */
626 int insn_srlz
; /* current insn serialization state */
627 int data_srlz
; /* current data serialization state */
628 int qp_regno
; /* qualifying predicate for this usage */
629 char *file
; /* what file marked this dependency */
630 unsigned int line
; /* what line marked this dependency */
631 struct mem_offset mem_offset
; /* optional memory offset hint */
632 enum { CMP_NONE
, CMP_OR
, CMP_AND
} cmp_type
; /* OR or AND compare? */
633 int path
; /* corresponding code entry index */
635 static int regdepslen
= 0;
636 static int regdepstotlen
= 0;
637 static const char *dv_mode
[] = { "RAW", "WAW", "WAR" };
638 static const char *dv_sem
[] = { "none", "implied", "impliedf",
639 "data", "instr", "specific", "stop", "other" };
640 static const char *dv_cmp_type
[] = { "none", "OR", "AND" };
642 /* Current state of PR mutexation */
643 static struct qpmutex
{
646 } *qp_mutexes
= NULL
; /* QP mutex bitmasks */
647 static int qp_mutexeslen
= 0;
648 static int qp_mutexestotlen
= 0;
649 static valueT qp_safe_across_calls
= 0;
651 /* Current state of PR implications */
652 static struct qp_imply
{
655 unsigned p2_branched
:1;
657 } *qp_implies
= NULL
;
658 static int qp_implieslen
= 0;
659 static int qp_impliestotlen
= 0;
661 /* Keep track of static GR values so that indirect register usage can
662 sometimes be tracked. */
673 (((1 << (8 * sizeof(gr_values
->path
) - 2)) - 1) << 1) + 1,
679 /* Remember the alignment frag. */
680 static fragS
*align_frag
;
682 /* These are the routines required to output the various types of
685 /* A slot_number is a frag address plus the slot index (0-2). We use the
686 frag address here so that if there is a section switch in the middle of
687 a function, then instructions emitted to a different section are not
688 counted. Since there may be more than one frag for a function, this
689 means we also need to keep track of which frag this address belongs to
690 so we can compute inter-frag distances. This also nicely solves the
691 problem with nops emitted for align directives, which can't easily be
692 counted, but can easily be derived from frag sizes. */
694 typedef struct unw_rec_list
{
696 unsigned long slot_number
;
698 struct unw_rec_list
*next
;
701 #define SLOT_NUM_NOT_SET (unsigned)-1
703 /* Linked list of saved prologue counts. A very poor
704 implementation of a map from label numbers to prologue counts. */
705 typedef struct label_prologue_count
707 struct label_prologue_count
*next
;
708 unsigned long label_number
;
709 unsigned int prologue_count
;
710 } label_prologue_count
;
714 /* Maintain a list of unwind entries for the current function. */
718 /* Any unwind entires that should be attached to the current slot
719 that an insn is being constructed for. */
720 unw_rec_list
*current_entry
;
722 /* These are used to create the unwind table entry for this function. */
724 symbolS
*info
; /* pointer to unwind info */
725 symbolS
*personality_routine
;
727 subsegT saved_text_subseg
;
728 unsigned int force_unwind_entry
: 1; /* force generation of unwind entry? */
730 /* TRUE if processing unwind directives in a prologue region. */
731 unsigned int prologue
: 1;
732 unsigned int prologue_mask
: 4;
733 unsigned int body
: 1;
734 unsigned int insn
: 1;
735 unsigned int prologue_count
; /* number of .prologues seen so far */
736 /* Prologue counts at previous .label_state directives. */
737 struct label_prologue_count
* saved_prologue_counts
;
740 /* The input value is a negated offset from psp, and specifies an address
741 psp - offset. The encoded value is psp + 16 - (4 * offset). Thus we
742 must add 16 and divide by 4 to get the encoded value. */
744 #define ENCODED_PSP_OFFSET(OFFSET) (((OFFSET) + 16) / 4)
746 typedef void (*vbyte_func
) PARAMS ((int, char *, char *));
748 /* Forward declarations: */
749 static void set_section
PARAMS ((char *name
));
750 static unsigned int set_regstack
PARAMS ((unsigned int, unsigned int,
751 unsigned int, unsigned int));
752 static void dot_align (int);
753 static void dot_radix
PARAMS ((int));
754 static void dot_special_section
PARAMS ((int));
755 static void dot_proc
PARAMS ((int));
756 static void dot_fframe
PARAMS ((int));
757 static void dot_vframe
PARAMS ((int));
758 static void dot_vframesp
PARAMS ((int));
759 static void dot_vframepsp
PARAMS ((int));
760 static void dot_save
PARAMS ((int));
761 static void dot_restore
PARAMS ((int));
762 static void dot_restorereg
PARAMS ((int));
763 static void dot_restorereg_p
PARAMS ((int));
764 static void dot_handlerdata
PARAMS ((int));
765 static void dot_unwentry
PARAMS ((int));
766 static void dot_altrp
PARAMS ((int));
767 static void dot_savemem
PARAMS ((int));
768 static void dot_saveg
PARAMS ((int));
769 static void dot_savef
PARAMS ((int));
770 static void dot_saveb
PARAMS ((int));
771 static void dot_savegf
PARAMS ((int));
772 static void dot_spill
PARAMS ((int));
773 static void dot_spillreg
PARAMS ((int));
774 static void dot_spillmem
PARAMS ((int));
775 static void dot_spillreg_p
PARAMS ((int));
776 static void dot_spillmem_p
PARAMS ((int));
777 static void dot_label_state
PARAMS ((int));
778 static void dot_copy_state
PARAMS ((int));
779 static void dot_unwabi
PARAMS ((int));
780 static void dot_personality
PARAMS ((int));
781 static void dot_body
PARAMS ((int));
782 static void dot_prologue
PARAMS ((int));
783 static void dot_endp
PARAMS ((int));
784 static void dot_template
PARAMS ((int));
785 static void dot_regstk
PARAMS ((int));
786 static void dot_rot
PARAMS ((int));
787 static void dot_byteorder
PARAMS ((int));
788 static void dot_psr
PARAMS ((int));
789 static void dot_alias
PARAMS ((int));
790 static void dot_ln
PARAMS ((int));
791 static void cross_section
PARAMS ((int ref
, void (*cons
) PARAMS((int)), int ua
));
792 static void dot_xdata
PARAMS ((int));
793 static void stmt_float_cons
PARAMS ((int));
794 static void stmt_cons_ua
PARAMS ((int));
795 static void dot_xfloat_cons
PARAMS ((int));
796 static void dot_xstringer
PARAMS ((int));
797 static void dot_xdata_ua
PARAMS ((int));
798 static void dot_xfloat_cons_ua
PARAMS ((int));
799 static void print_prmask
PARAMS ((valueT mask
));
800 static void dot_pred_rel
PARAMS ((int));
801 static void dot_reg_val
PARAMS ((int));
802 static void dot_serialize
PARAMS ((int));
803 static void dot_dv_mode
PARAMS ((int));
804 static void dot_entry
PARAMS ((int));
805 static void dot_mem_offset
PARAMS ((int));
806 static void add_unwind_entry
PARAMS((unw_rec_list
*ptr
));
807 static symbolS
*declare_register
PARAMS ((const char *name
, int regnum
));
808 static void declare_register_set
PARAMS ((const char *, int, int));
809 static unsigned int operand_width
PARAMS ((enum ia64_opnd
));
810 static enum operand_match_result operand_match
PARAMS ((const struct ia64_opcode
*idesc
,
813 static int parse_operand
PARAMS ((expressionS
*e
));
814 static struct ia64_opcode
* parse_operands
PARAMS ((struct ia64_opcode
*));
815 static void build_insn
PARAMS ((struct slot
*, bfd_vma
*));
816 static void emit_one_bundle
PARAMS ((void));
817 static void fix_insn
PARAMS ((fixS
*, const struct ia64_operand
*, valueT
));
818 static bfd_reloc_code_real_type ia64_gen_real_reloc_type
PARAMS ((struct symbol
*sym
,
819 bfd_reloc_code_real_type r_type
));
820 static void insn_group_break
PARAMS ((int, int, int));
821 static void mark_resource
PARAMS ((struct ia64_opcode
*, const struct ia64_dependency
*,
822 struct rsrc
*, int depind
, int path
));
823 static void add_qp_mutex
PARAMS((valueT mask
));
824 static void add_qp_imply
PARAMS((int p1
, int p2
));
825 static void clear_qp_branch_flag
PARAMS((valueT mask
));
826 static void clear_qp_mutex
PARAMS((valueT mask
));
827 static void clear_qp_implies
PARAMS((valueT p1_mask
, valueT p2_mask
));
828 static int has_suffix_p
PARAMS((const char *, const char *));
829 static void clear_register_values
PARAMS ((void));
830 static void print_dependency
PARAMS ((const char *action
, int depind
));
831 static void instruction_serialization
PARAMS ((void));
832 static void data_serialization
PARAMS ((void));
833 static void remove_marked_resource
PARAMS ((struct rsrc
*));
834 static int is_conditional_branch
PARAMS ((struct ia64_opcode
*));
835 static int is_taken_branch
PARAMS ((struct ia64_opcode
*));
836 static int is_interruption_or_rfi
PARAMS ((struct ia64_opcode
*));
837 static int depends_on
PARAMS ((int, struct ia64_opcode
*));
838 static int specify_resource
PARAMS ((const struct ia64_dependency
*,
839 struct ia64_opcode
*, int, struct rsrc
[], int, int));
840 static int check_dv
PARAMS((struct ia64_opcode
*idesc
));
841 static void check_dependencies
PARAMS((struct ia64_opcode
*));
842 static void mark_resources
PARAMS((struct ia64_opcode
*));
843 static void update_dependencies
PARAMS((struct ia64_opcode
*));
844 static void note_register_values
PARAMS((struct ia64_opcode
*));
845 static int qp_mutex
PARAMS ((int, int, int));
846 static int resources_match
PARAMS ((struct rsrc
*, struct ia64_opcode
*, int, int, int));
847 static void output_vbyte_mem
PARAMS ((int, char *, char *));
848 static void count_output
PARAMS ((int, char *, char *));
849 static void output_R1_format
PARAMS ((vbyte_func
, unw_record_type
, int));
850 static void output_R2_format
PARAMS ((vbyte_func
, int, int, unsigned long));
851 static void output_R3_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
852 static void output_P1_format
PARAMS ((vbyte_func
, int));
853 static void output_P2_format
PARAMS ((vbyte_func
, int, int));
854 static void output_P3_format
PARAMS ((vbyte_func
, unw_record_type
, int));
855 static void output_P4_format
PARAMS ((vbyte_func
, unsigned char *, unsigned long));
856 static void output_P5_format
PARAMS ((vbyte_func
, int, unsigned long));
857 static void output_P6_format
PARAMS ((vbyte_func
, unw_record_type
, int));
858 static void output_P7_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long, unsigned long));
859 static void output_P8_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
860 static void output_P9_format
PARAMS ((vbyte_func
, int, int));
861 static void output_P10_format
PARAMS ((vbyte_func
, int, int));
862 static void output_B1_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
863 static void output_B2_format
PARAMS ((vbyte_func
, unsigned long, unsigned long));
864 static void output_B3_format
PARAMS ((vbyte_func
, unsigned long, unsigned long));
865 static void output_B4_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
866 static char format_ab_reg
PARAMS ((int, int));
867 static void output_X1_format
PARAMS ((vbyte_func
, unw_record_type
, int, int, unsigned long,
869 static void output_X2_format
PARAMS ((vbyte_func
, int, int, int, int, int, unsigned long));
870 static void output_X3_format
PARAMS ((vbyte_func
, unw_record_type
, int, int, int, unsigned long,
872 static void output_X4_format
PARAMS ((vbyte_func
, int, int, int, int, int, int, unsigned long));
873 static unw_rec_list
*output_endp
PARAMS ((void));
874 static unw_rec_list
*output_prologue
PARAMS ((void));
875 static unw_rec_list
*output_prologue_gr
PARAMS ((unsigned int, unsigned int));
876 static unw_rec_list
*output_body
PARAMS ((void));
877 static unw_rec_list
*output_mem_stack_f
PARAMS ((unsigned int));
878 static unw_rec_list
*output_mem_stack_v
PARAMS ((void));
879 static unw_rec_list
*output_psp_gr
PARAMS ((unsigned int));
880 static unw_rec_list
*output_psp_sprel
PARAMS ((unsigned int));
881 static unw_rec_list
*output_rp_when
PARAMS ((void));
882 static unw_rec_list
*output_rp_gr
PARAMS ((unsigned int));
883 static unw_rec_list
*output_rp_br
PARAMS ((unsigned int));
884 static unw_rec_list
*output_rp_psprel
PARAMS ((unsigned int));
885 static unw_rec_list
*output_rp_sprel
PARAMS ((unsigned int));
886 static unw_rec_list
*output_pfs_when
PARAMS ((void));
887 static unw_rec_list
*output_pfs_gr
PARAMS ((unsigned int));
888 static unw_rec_list
*output_pfs_psprel
PARAMS ((unsigned int));
889 static unw_rec_list
*output_pfs_sprel
PARAMS ((unsigned int));
890 static unw_rec_list
*output_preds_when
PARAMS ((void));
891 static unw_rec_list
*output_preds_gr
PARAMS ((unsigned int));
892 static unw_rec_list
*output_preds_psprel
PARAMS ((unsigned int));
893 static unw_rec_list
*output_preds_sprel
PARAMS ((unsigned int));
894 static unw_rec_list
*output_fr_mem
PARAMS ((unsigned int));
895 static unw_rec_list
*output_frgr_mem
PARAMS ((unsigned int, unsigned int));
896 static unw_rec_list
*output_gr_gr
PARAMS ((unsigned int, unsigned int));
897 static unw_rec_list
*output_gr_mem
PARAMS ((unsigned int));
898 static unw_rec_list
*output_br_mem
PARAMS ((unsigned int));
899 static unw_rec_list
*output_br_gr
PARAMS ((unsigned int, unsigned int));
900 static unw_rec_list
*output_spill_base
PARAMS ((unsigned int));
901 static unw_rec_list
*output_unat_when
PARAMS ((void));
902 static unw_rec_list
*output_unat_gr
PARAMS ((unsigned int));
903 static unw_rec_list
*output_unat_psprel
PARAMS ((unsigned int));
904 static unw_rec_list
*output_unat_sprel
PARAMS ((unsigned int));
905 static unw_rec_list
*output_lc_when
PARAMS ((void));
906 static unw_rec_list
*output_lc_gr
PARAMS ((unsigned int));
907 static unw_rec_list
*output_lc_psprel
PARAMS ((unsigned int));
908 static unw_rec_list
*output_lc_sprel
PARAMS ((unsigned int));
909 static unw_rec_list
*output_fpsr_when
PARAMS ((void));
910 static unw_rec_list
*output_fpsr_gr
PARAMS ((unsigned int));
911 static unw_rec_list
*output_fpsr_psprel
PARAMS ((unsigned int));
912 static unw_rec_list
*output_fpsr_sprel
PARAMS ((unsigned int));
913 static unw_rec_list
*output_priunat_when_gr
PARAMS ((void));
914 static unw_rec_list
*output_priunat_when_mem
PARAMS ((void));
915 static unw_rec_list
*output_priunat_gr
PARAMS ((unsigned int));
916 static unw_rec_list
*output_priunat_psprel
PARAMS ((unsigned int));
917 static unw_rec_list
*output_priunat_sprel
PARAMS ((unsigned int));
918 static unw_rec_list
*output_bsp_when
PARAMS ((void));
919 static unw_rec_list
*output_bsp_gr
PARAMS ((unsigned int));
920 static unw_rec_list
*output_bsp_psprel
PARAMS ((unsigned int));
921 static unw_rec_list
*output_bsp_sprel
PARAMS ((unsigned int));
922 static unw_rec_list
*output_bspstore_when
PARAMS ((void));
923 static unw_rec_list
*output_bspstore_gr
PARAMS ((unsigned int));
924 static unw_rec_list
*output_bspstore_psprel
PARAMS ((unsigned int));
925 static unw_rec_list
*output_bspstore_sprel
PARAMS ((unsigned int));
926 static unw_rec_list
*output_rnat_when
PARAMS ((void));
927 static unw_rec_list
*output_rnat_gr
PARAMS ((unsigned int));
928 static unw_rec_list
*output_rnat_psprel
PARAMS ((unsigned int));
929 static unw_rec_list
*output_rnat_sprel
PARAMS ((unsigned int));
930 static unw_rec_list
*output_unwabi
PARAMS ((unsigned long, unsigned long));
931 static unw_rec_list
*output_epilogue
PARAMS ((unsigned long));
932 static unw_rec_list
*output_label_state
PARAMS ((unsigned long));
933 static unw_rec_list
*output_copy_state
PARAMS ((unsigned long));
934 static unw_rec_list
*output_spill_psprel
PARAMS ((unsigned int, unsigned int, unsigned int));
935 static unw_rec_list
*output_spill_sprel
PARAMS ((unsigned int, unsigned int, unsigned int));
936 static unw_rec_list
*output_spill_psprel_p
PARAMS ((unsigned int, unsigned int, unsigned int,
938 static unw_rec_list
*output_spill_sprel_p
PARAMS ((unsigned int, unsigned int, unsigned int,
940 static unw_rec_list
*output_spill_reg
PARAMS ((unsigned int, unsigned int, unsigned int,
942 static unw_rec_list
*output_spill_reg_p
PARAMS ((unsigned int, unsigned int, unsigned int,
943 unsigned int, unsigned int));
944 static void process_one_record
PARAMS ((unw_rec_list
*, vbyte_func
));
945 static void process_unw_records
PARAMS ((unw_rec_list
*, vbyte_func
));
946 static int calc_record_size
PARAMS ((unw_rec_list
*));
947 static void set_imask
PARAMS ((unw_rec_list
*, unsigned long, unsigned long, unsigned int));
948 static unsigned long slot_index
PARAMS ((unsigned long, fragS
*,
949 unsigned long, fragS
*,
951 static unw_rec_list
*optimize_unw_records
PARAMS ((unw_rec_list
*));
952 static void fixup_unw_records
PARAMS ((unw_rec_list
*, int));
953 static int convert_expr_to_ab_reg
PARAMS ((expressionS
*, unsigned int *, unsigned int *));
954 static int convert_expr_to_xy_reg
PARAMS ((expressionS
*, unsigned int *, unsigned int *));
955 static unsigned int get_saved_prologue_count
PARAMS ((unsigned long));
956 static void save_prologue_count
PARAMS ((unsigned long, unsigned int));
957 static void free_saved_prologue_counts
PARAMS ((void));
959 /* Determine if application register REGNUM resides only in the integer
960 unit (as opposed to the memory unit). */
962 ar_is_only_in_integer_unit (int reg
)
965 return reg
>= 64 && reg
<= 111;
968 /* Determine if application register REGNUM resides only in the memory
969 unit (as opposed to the integer unit). */
971 ar_is_only_in_memory_unit (int reg
)
974 return reg
>= 0 && reg
<= 47;
977 /* Switch to section NAME and create section if necessary. It's
978 rather ugly that we have to manipulate input_line_pointer but I
979 don't see any other way to accomplish the same thing without
980 changing obj-elf.c (which may be the Right Thing, in the end). */
985 char *saved_input_line_pointer
;
987 saved_input_line_pointer
= input_line_pointer
;
988 input_line_pointer
= name
;
990 input_line_pointer
= saved_input_line_pointer
;
993 /* Map 's' to SHF_IA_64_SHORT. */
996 ia64_elf_section_letter (letter
, ptr_msg
)
1001 return SHF_IA_64_SHORT
;
1002 else if (letter
== 'o')
1003 return SHF_LINK_ORDER
;
1005 *ptr_msg
= _("Bad .section directive: want a,o,s,w,x,M,S,G,T in string");
1009 /* Map SHF_IA_64_SHORT to SEC_SMALL_DATA. */
1012 ia64_elf_section_flags (flags
, attr
, type
)
1014 int attr
, type ATTRIBUTE_UNUSED
;
1016 if (attr
& SHF_IA_64_SHORT
)
1017 flags
|= SEC_SMALL_DATA
;
1022 ia64_elf_section_type (str
, len
)
1026 #define STREQ(s) ((len == sizeof (s) - 1) && (strncmp (str, s, sizeof (s) - 1) == 0))
1028 if (STREQ (ELF_STRING_ia64_unwind_info
))
1029 return SHT_PROGBITS
;
1031 if (STREQ (ELF_STRING_ia64_unwind_info_once
))
1032 return SHT_PROGBITS
;
1034 if (STREQ (ELF_STRING_ia64_unwind
))
1035 return SHT_IA_64_UNWIND
;
1037 if (STREQ (ELF_STRING_ia64_unwind_once
))
1038 return SHT_IA_64_UNWIND
;
1040 if (STREQ ("unwind"))
1041 return SHT_IA_64_UNWIND
;
1048 set_regstack (ins
, locs
, outs
, rots
)
1049 unsigned int ins
, locs
, outs
, rots
;
1051 /* Size of frame. */
1054 sof
= ins
+ locs
+ outs
;
1057 as_bad ("Size of frame exceeds maximum of 96 registers");
1062 as_warn ("Size of rotating registers exceeds frame size");
1065 md
.in
.base
= REG_GR
+ 32;
1066 md
.loc
.base
= md
.in
.base
+ ins
;
1067 md
.out
.base
= md
.loc
.base
+ locs
;
1069 md
.in
.num_regs
= ins
;
1070 md
.loc
.num_regs
= locs
;
1071 md
.out
.num_regs
= outs
;
1072 md
.rot
.num_regs
= rots
;
1079 struct label_fix
*lfix
;
1081 subsegT saved_subseg
;
1084 if (!md
.last_text_seg
)
1087 saved_seg
= now_seg
;
1088 saved_subseg
= now_subseg
;
1090 subseg_set (md
.last_text_seg
, 0);
1092 while (md
.num_slots_in_use
> 0)
1093 emit_one_bundle (); /* force out queued instructions */
1095 /* In case there are labels following the last instruction, resolve
1097 for (lfix
= CURR_SLOT
.label_fixups
; lfix
; lfix
= lfix
->next
)
1099 S_SET_VALUE (lfix
->sym
, frag_now_fix ());
1100 symbol_set_frag (lfix
->sym
, frag_now
);
1102 CURR_SLOT
.label_fixups
= 0;
1103 for (lfix
= CURR_SLOT
.tag_fixups
; lfix
; lfix
= lfix
->next
)
1105 S_SET_VALUE (lfix
->sym
, frag_now_fix ());
1106 symbol_set_frag (lfix
->sym
, frag_now
);
1108 CURR_SLOT
.tag_fixups
= 0;
1110 /* In case there are unwind directives following the last instruction,
1111 resolve those now. We only handle prologue, body, and endp directives
1112 here. Give an error for others. */
1113 for (ptr
= unwind
.current_entry
; ptr
; ptr
= ptr
->next
)
1115 switch (ptr
->r
.type
)
1121 ptr
->slot_number
= (unsigned long) frag_more (0);
1122 ptr
->slot_frag
= frag_now
;
1125 /* Allow any record which doesn't have a "t" field (i.e.,
1126 doesn't relate to a particular instruction). */
1142 as_bad (_("Unwind directive not followed by an instruction."));
1146 unwind
.current_entry
= NULL
;
1148 subseg_set (saved_seg
, saved_subseg
);
1150 if (md
.qp
.X_op
== O_register
)
1151 as_bad ("qualifying predicate not followed by instruction");
1155 ia64_do_align (int nbytes
)
1157 char *saved_input_line_pointer
= input_line_pointer
;
1159 input_line_pointer
= "";
1160 s_align_bytes (nbytes
);
1161 input_line_pointer
= saved_input_line_pointer
;
1165 ia64_cons_align (nbytes
)
1170 char *saved_input_line_pointer
= input_line_pointer
;
1171 input_line_pointer
= "";
1172 s_align_bytes (nbytes
);
1173 input_line_pointer
= saved_input_line_pointer
;
1177 /* Output COUNT bytes to a memory location. */
1178 static char *vbyte_mem_ptr
= NULL
;
1181 output_vbyte_mem (count
, ptr
, comment
)
1184 char *comment ATTRIBUTE_UNUSED
;
1187 if (vbyte_mem_ptr
== NULL
)
1192 for (x
= 0; x
< count
; x
++)
1193 *(vbyte_mem_ptr
++) = ptr
[x
];
1196 /* Count the number of bytes required for records. */
1197 static int vbyte_count
= 0;
1199 count_output (count
, ptr
, comment
)
1201 char *ptr ATTRIBUTE_UNUSED
;
1202 char *comment ATTRIBUTE_UNUSED
;
1204 vbyte_count
+= count
;
1208 output_R1_format (f
, rtype
, rlen
)
1210 unw_record_type rtype
;
1217 output_R3_format (f
, rtype
, rlen
);
1223 else if (rtype
!= prologue
)
1224 as_bad ("record type is not valid");
1226 byte
= UNW_R1
| (r
<< 5) | (rlen
& 0x1f);
1227 (*f
) (1, &byte
, NULL
);
1231 output_R2_format (f
, mask
, grsave
, rlen
)
1238 mask
= (mask
& 0x0f);
1239 grsave
= (grsave
& 0x7f);
1241 bytes
[0] = (UNW_R2
| (mask
>> 1));
1242 bytes
[1] = (((mask
& 0x01) << 7) | grsave
);
1243 count
+= output_leb128 (bytes
+ 2, rlen
, 0);
1244 (*f
) (count
, bytes
, NULL
);
1248 output_R3_format (f
, rtype
, rlen
)
1250 unw_record_type rtype
;
1257 output_R1_format (f
, rtype
, rlen
);
1263 else if (rtype
!= prologue
)
1264 as_bad ("record type is not valid");
1265 bytes
[0] = (UNW_R3
| r
);
1266 count
= output_leb128 (bytes
+ 1, rlen
, 0);
1267 (*f
) (count
+ 1, bytes
, NULL
);
1271 output_P1_format (f
, brmask
)
1276 byte
= UNW_P1
| (brmask
& 0x1f);
1277 (*f
) (1, &byte
, NULL
);
1281 output_P2_format (f
, brmask
, gr
)
1287 brmask
= (brmask
& 0x1f);
1288 bytes
[0] = UNW_P2
| (brmask
>> 1);
1289 bytes
[1] = (((brmask
& 1) << 7) | gr
);
1290 (*f
) (2, bytes
, NULL
);
1294 output_P3_format (f
, rtype
, reg
)
1296 unw_record_type rtype
;
1341 as_bad ("Invalid record type for P3 format.");
1343 bytes
[0] = (UNW_P3
| (r
>> 1));
1344 bytes
[1] = (((r
& 1) << 7) | reg
);
1345 (*f
) (2, bytes
, NULL
);
1349 output_P4_format (f
, imask
, imask_size
)
1351 unsigned char *imask
;
1352 unsigned long imask_size
;
1355 (*f
) (imask_size
, (char *) imask
, NULL
);
1359 output_P5_format (f
, grmask
, frmask
)
1362 unsigned long frmask
;
1365 grmask
= (grmask
& 0x0f);
1368 bytes
[1] = ((grmask
<< 4) | ((frmask
& 0x000f0000) >> 16));
1369 bytes
[2] = ((frmask
& 0x0000ff00) >> 8);
1370 bytes
[3] = (frmask
& 0x000000ff);
1371 (*f
) (4, bytes
, NULL
);
1375 output_P6_format (f
, rtype
, rmask
)
1377 unw_record_type rtype
;
1383 if (rtype
== gr_mem
)
1385 else if (rtype
!= fr_mem
)
1386 as_bad ("Invalid record type for format P6");
1387 byte
= (UNW_P6
| (r
<< 4) | (rmask
& 0x0f));
1388 (*f
) (1, &byte
, NULL
);
1392 output_P7_format (f
, rtype
, w1
, w2
)
1394 unw_record_type rtype
;
1401 count
+= output_leb128 (bytes
+ 1, w1
, 0);
1406 count
+= output_leb128 (bytes
+ count
, w2
>> 4, 0);
1456 bytes
[0] = (UNW_P7
| r
);
1457 (*f
) (count
, bytes
, NULL
);
1461 output_P8_format (f
, rtype
, t
)
1463 unw_record_type rtype
;
1502 case bspstore_psprel
:
1505 case bspstore_sprel
:
1517 case priunat_when_gr
:
1520 case priunat_psprel
:
1526 case priunat_when_mem
:
1533 count
+= output_leb128 (bytes
+ 2, t
, 0);
1534 (*f
) (count
, bytes
, NULL
);
1538 output_P9_format (f
, grmask
, gr
)
1545 bytes
[1] = (grmask
& 0x0f);
1546 bytes
[2] = (gr
& 0x7f);
1547 (*f
) (3, bytes
, NULL
);
1551 output_P10_format (f
, abi
, context
)
1558 bytes
[1] = (abi
& 0xff);
1559 bytes
[2] = (context
& 0xff);
1560 (*f
) (3, bytes
, NULL
);
1564 output_B1_format (f
, rtype
, label
)
1566 unw_record_type rtype
;
1567 unsigned long label
;
1573 output_B4_format (f
, rtype
, label
);
1576 if (rtype
== copy_state
)
1578 else if (rtype
!= label_state
)
1579 as_bad ("Invalid record type for format B1");
1581 byte
= (UNW_B1
| (r
<< 5) | (label
& 0x1f));
1582 (*f
) (1, &byte
, NULL
);
1586 output_B2_format (f
, ecount
, t
)
1588 unsigned long ecount
;
1595 output_B3_format (f
, ecount
, t
);
1598 bytes
[0] = (UNW_B2
| (ecount
& 0x1f));
1599 count
+= output_leb128 (bytes
+ 1, t
, 0);
1600 (*f
) (count
, bytes
, NULL
);
1604 output_B3_format (f
, ecount
, t
)
1606 unsigned long ecount
;
1613 output_B2_format (f
, ecount
, t
);
1617 count
+= output_leb128 (bytes
+ 1, t
, 0);
1618 count
+= output_leb128 (bytes
+ count
, ecount
, 0);
1619 (*f
) (count
, bytes
, NULL
);
1623 output_B4_format (f
, rtype
, label
)
1625 unw_record_type rtype
;
1626 unsigned long label
;
1633 output_B1_format (f
, rtype
, label
);
1637 if (rtype
== copy_state
)
1639 else if (rtype
!= label_state
)
1640 as_bad ("Invalid record type for format B1");
1642 bytes
[0] = (UNW_B4
| (r
<< 3));
1643 count
+= output_leb128 (bytes
+ 1, label
, 0);
1644 (*f
) (count
, bytes
, NULL
);
1648 format_ab_reg (ab
, reg
)
1655 ret
= (ab
<< 5) | reg
;
1660 output_X1_format (f
, rtype
, ab
, reg
, t
, w1
)
1662 unw_record_type rtype
;
1672 if (rtype
== spill_sprel
)
1674 else if (rtype
!= spill_psprel
)
1675 as_bad ("Invalid record type for format X1");
1676 bytes
[1] = ((r
<< 7) | format_ab_reg (ab
, reg
));
1677 count
+= output_leb128 (bytes
+ 2, t
, 0);
1678 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1679 (*f
) (count
, bytes
, NULL
);
1683 output_X2_format (f
, ab
, reg
, x
, y
, treg
, t
)
1692 bytes
[1] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1693 bytes
[2] = (((y
& 1) << 7) | (treg
& 0x7f));
1694 count
+= output_leb128 (bytes
+ 3, t
, 0);
1695 (*f
) (count
, bytes
, NULL
);
1699 output_X3_format (f
, rtype
, qp
, ab
, reg
, t
, w1
)
1701 unw_record_type rtype
;
1712 if (rtype
== spill_sprel_p
)
1714 else if (rtype
!= spill_psprel_p
)
1715 as_bad ("Invalid record type for format X3");
1716 bytes
[1] = ((r
<< 7) | (qp
& 0x3f));
1717 bytes
[2] = format_ab_reg (ab
, reg
);
1718 count
+= output_leb128 (bytes
+ 3, t
, 0);
1719 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1720 (*f
) (count
, bytes
, NULL
);
1724 output_X4_format (f
, qp
, ab
, reg
, x
, y
, treg
, t
)
1734 bytes
[1] = (qp
& 0x3f);
1735 bytes
[2] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1736 bytes
[3] = (((y
& 1) << 7) | (treg
& 0x7f));
1737 count
+= output_leb128 (bytes
+ 4, t
, 0);
1738 (*f
) (count
, bytes
, NULL
);
1741 /* This function allocates a record list structure, and initializes fields. */
1743 static unw_rec_list
*
1744 alloc_record (unw_record_type t
)
1747 ptr
= xmalloc (sizeof (*ptr
));
1749 ptr
->slot_number
= SLOT_NUM_NOT_SET
;
1754 /* Dummy unwind record used for calculating the length of the last prologue or
1757 static unw_rec_list
*
1760 unw_rec_list
*ptr
= alloc_record (endp
);
1764 static unw_rec_list
*
1767 unw_rec_list
*ptr
= alloc_record (prologue
);
1768 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1772 static unw_rec_list
*
1773 output_prologue_gr (saved_mask
, reg
)
1774 unsigned int saved_mask
;
1777 unw_rec_list
*ptr
= alloc_record (prologue_gr
);
1778 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1779 ptr
->r
.record
.r
.grmask
= saved_mask
;
1780 ptr
->r
.record
.r
.grsave
= reg
;
1784 static unw_rec_list
*
1787 unw_rec_list
*ptr
= alloc_record (body
);
1791 static unw_rec_list
*
1792 output_mem_stack_f (size
)
1795 unw_rec_list
*ptr
= alloc_record (mem_stack_f
);
1796 ptr
->r
.record
.p
.size
= size
;
1800 static unw_rec_list
*
1801 output_mem_stack_v ()
1803 unw_rec_list
*ptr
= alloc_record (mem_stack_v
);
1807 static unw_rec_list
*
1811 unw_rec_list
*ptr
= alloc_record (psp_gr
);
1812 ptr
->r
.record
.p
.gr
= gr
;
1816 static unw_rec_list
*
1817 output_psp_sprel (offset
)
1818 unsigned int offset
;
1820 unw_rec_list
*ptr
= alloc_record (psp_sprel
);
1821 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1825 static unw_rec_list
*
1828 unw_rec_list
*ptr
= alloc_record (rp_when
);
1832 static unw_rec_list
*
1836 unw_rec_list
*ptr
= alloc_record (rp_gr
);
1837 ptr
->r
.record
.p
.gr
= gr
;
1841 static unw_rec_list
*
1845 unw_rec_list
*ptr
= alloc_record (rp_br
);
1846 ptr
->r
.record
.p
.br
= br
;
1850 static unw_rec_list
*
1851 output_rp_psprel (offset
)
1852 unsigned int offset
;
1854 unw_rec_list
*ptr
= alloc_record (rp_psprel
);
1855 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
1859 static unw_rec_list
*
1860 output_rp_sprel (offset
)
1861 unsigned int offset
;
1863 unw_rec_list
*ptr
= alloc_record (rp_sprel
);
1864 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1868 static unw_rec_list
*
1871 unw_rec_list
*ptr
= alloc_record (pfs_when
);
1875 static unw_rec_list
*
1879 unw_rec_list
*ptr
= alloc_record (pfs_gr
);
1880 ptr
->r
.record
.p
.gr
= gr
;
1884 static unw_rec_list
*
1885 output_pfs_psprel (offset
)
1886 unsigned int offset
;
1888 unw_rec_list
*ptr
= alloc_record (pfs_psprel
);
1889 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
1893 static unw_rec_list
*
1894 output_pfs_sprel (offset
)
1895 unsigned int offset
;
1897 unw_rec_list
*ptr
= alloc_record (pfs_sprel
);
1898 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1902 static unw_rec_list
*
1903 output_preds_when ()
1905 unw_rec_list
*ptr
= alloc_record (preds_when
);
1909 static unw_rec_list
*
1910 output_preds_gr (gr
)
1913 unw_rec_list
*ptr
= alloc_record (preds_gr
);
1914 ptr
->r
.record
.p
.gr
= gr
;
1918 static unw_rec_list
*
1919 output_preds_psprel (offset
)
1920 unsigned int offset
;
1922 unw_rec_list
*ptr
= alloc_record (preds_psprel
);
1923 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
1927 static unw_rec_list
*
1928 output_preds_sprel (offset
)
1929 unsigned int offset
;
1931 unw_rec_list
*ptr
= alloc_record (preds_sprel
);
1932 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1936 static unw_rec_list
*
1937 output_fr_mem (mask
)
1940 unw_rec_list
*ptr
= alloc_record (fr_mem
);
1941 ptr
->r
.record
.p
.rmask
= mask
;
1945 static unw_rec_list
*
1946 output_frgr_mem (gr_mask
, fr_mask
)
1947 unsigned int gr_mask
;
1948 unsigned int fr_mask
;
1950 unw_rec_list
*ptr
= alloc_record (frgr_mem
);
1951 ptr
->r
.record
.p
.grmask
= gr_mask
;
1952 ptr
->r
.record
.p
.frmask
= fr_mask
;
1956 static unw_rec_list
*
1957 output_gr_gr (mask
, reg
)
1961 unw_rec_list
*ptr
= alloc_record (gr_gr
);
1962 ptr
->r
.record
.p
.grmask
= mask
;
1963 ptr
->r
.record
.p
.gr
= reg
;
1967 static unw_rec_list
*
1968 output_gr_mem (mask
)
1971 unw_rec_list
*ptr
= alloc_record (gr_mem
);
1972 ptr
->r
.record
.p
.rmask
= mask
;
1976 static unw_rec_list
*
1977 output_br_mem (unsigned int mask
)
1979 unw_rec_list
*ptr
= alloc_record (br_mem
);
1980 ptr
->r
.record
.p
.brmask
= mask
;
1984 static unw_rec_list
*
1985 output_br_gr (save_mask
, reg
)
1986 unsigned int save_mask
;
1989 unw_rec_list
*ptr
= alloc_record (br_gr
);
1990 ptr
->r
.record
.p
.brmask
= save_mask
;
1991 ptr
->r
.record
.p
.gr
= reg
;
1995 static unw_rec_list
*
1996 output_spill_base (offset
)
1997 unsigned int offset
;
1999 unw_rec_list
*ptr
= alloc_record (spill_base
);
2000 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2004 static unw_rec_list
*
2007 unw_rec_list
*ptr
= alloc_record (unat_when
);
2011 static unw_rec_list
*
2015 unw_rec_list
*ptr
= alloc_record (unat_gr
);
2016 ptr
->r
.record
.p
.gr
= gr
;
2020 static unw_rec_list
*
2021 output_unat_psprel (offset
)
2022 unsigned int offset
;
2024 unw_rec_list
*ptr
= alloc_record (unat_psprel
);
2025 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2029 static unw_rec_list
*
2030 output_unat_sprel (offset
)
2031 unsigned int offset
;
2033 unw_rec_list
*ptr
= alloc_record (unat_sprel
);
2034 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2038 static unw_rec_list
*
2041 unw_rec_list
*ptr
= alloc_record (lc_when
);
2045 static unw_rec_list
*
2049 unw_rec_list
*ptr
= alloc_record (lc_gr
);
2050 ptr
->r
.record
.p
.gr
= gr
;
2054 static unw_rec_list
*
2055 output_lc_psprel (offset
)
2056 unsigned int offset
;
2058 unw_rec_list
*ptr
= alloc_record (lc_psprel
);
2059 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2063 static unw_rec_list
*
2064 output_lc_sprel (offset
)
2065 unsigned int offset
;
2067 unw_rec_list
*ptr
= alloc_record (lc_sprel
);
2068 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2072 static unw_rec_list
*
2075 unw_rec_list
*ptr
= alloc_record (fpsr_when
);
2079 static unw_rec_list
*
2083 unw_rec_list
*ptr
= alloc_record (fpsr_gr
);
2084 ptr
->r
.record
.p
.gr
= gr
;
2088 static unw_rec_list
*
2089 output_fpsr_psprel (offset
)
2090 unsigned int offset
;
2092 unw_rec_list
*ptr
= alloc_record (fpsr_psprel
);
2093 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2097 static unw_rec_list
*
2098 output_fpsr_sprel (offset
)
2099 unsigned int offset
;
2101 unw_rec_list
*ptr
= alloc_record (fpsr_sprel
);
2102 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2106 static unw_rec_list
*
2107 output_priunat_when_gr ()
2109 unw_rec_list
*ptr
= alloc_record (priunat_when_gr
);
2113 static unw_rec_list
*
2114 output_priunat_when_mem ()
2116 unw_rec_list
*ptr
= alloc_record (priunat_when_mem
);
2120 static unw_rec_list
*
2121 output_priunat_gr (gr
)
2124 unw_rec_list
*ptr
= alloc_record (priunat_gr
);
2125 ptr
->r
.record
.p
.gr
= gr
;
2129 static unw_rec_list
*
2130 output_priunat_psprel (offset
)
2131 unsigned int offset
;
2133 unw_rec_list
*ptr
= alloc_record (priunat_psprel
);
2134 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2138 static unw_rec_list
*
2139 output_priunat_sprel (offset
)
2140 unsigned int offset
;
2142 unw_rec_list
*ptr
= alloc_record (priunat_sprel
);
2143 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2147 static unw_rec_list
*
2150 unw_rec_list
*ptr
= alloc_record (bsp_when
);
2154 static unw_rec_list
*
2158 unw_rec_list
*ptr
= alloc_record (bsp_gr
);
2159 ptr
->r
.record
.p
.gr
= gr
;
2163 static unw_rec_list
*
2164 output_bsp_psprel (offset
)
2165 unsigned int offset
;
2167 unw_rec_list
*ptr
= alloc_record (bsp_psprel
);
2168 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2172 static unw_rec_list
*
2173 output_bsp_sprel (offset
)
2174 unsigned int offset
;
2176 unw_rec_list
*ptr
= alloc_record (bsp_sprel
);
2177 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2181 static unw_rec_list
*
2182 output_bspstore_when ()
2184 unw_rec_list
*ptr
= alloc_record (bspstore_when
);
2188 static unw_rec_list
*
2189 output_bspstore_gr (gr
)
2192 unw_rec_list
*ptr
= alloc_record (bspstore_gr
);
2193 ptr
->r
.record
.p
.gr
= gr
;
2197 static unw_rec_list
*
2198 output_bspstore_psprel (offset
)
2199 unsigned int offset
;
2201 unw_rec_list
*ptr
= alloc_record (bspstore_psprel
);
2202 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2206 static unw_rec_list
*
2207 output_bspstore_sprel (offset
)
2208 unsigned int offset
;
2210 unw_rec_list
*ptr
= alloc_record (bspstore_sprel
);
2211 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2215 static unw_rec_list
*
2218 unw_rec_list
*ptr
= alloc_record (rnat_when
);
2222 static unw_rec_list
*
2226 unw_rec_list
*ptr
= alloc_record (rnat_gr
);
2227 ptr
->r
.record
.p
.gr
= gr
;
2231 static unw_rec_list
*
2232 output_rnat_psprel (offset
)
2233 unsigned int offset
;
2235 unw_rec_list
*ptr
= alloc_record (rnat_psprel
);
2236 ptr
->r
.record
.p
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2240 static unw_rec_list
*
2241 output_rnat_sprel (offset
)
2242 unsigned int offset
;
2244 unw_rec_list
*ptr
= alloc_record (rnat_sprel
);
2245 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2249 static unw_rec_list
*
2250 output_unwabi (abi
, context
)
2252 unsigned long context
;
2254 unw_rec_list
*ptr
= alloc_record (unwabi
);
2255 ptr
->r
.record
.p
.abi
= abi
;
2256 ptr
->r
.record
.p
.context
= context
;
2260 static unw_rec_list
*
2261 output_epilogue (unsigned long ecount
)
2263 unw_rec_list
*ptr
= alloc_record (epilogue
);
2264 ptr
->r
.record
.b
.ecount
= ecount
;
2268 static unw_rec_list
*
2269 output_label_state (unsigned long label
)
2271 unw_rec_list
*ptr
= alloc_record (label_state
);
2272 ptr
->r
.record
.b
.label
= label
;
2276 static unw_rec_list
*
2277 output_copy_state (unsigned long label
)
2279 unw_rec_list
*ptr
= alloc_record (copy_state
);
2280 ptr
->r
.record
.b
.label
= label
;
2284 static unw_rec_list
*
2285 output_spill_psprel (ab
, reg
, offset
)
2288 unsigned int offset
;
2290 unw_rec_list
*ptr
= alloc_record (spill_psprel
);
2291 ptr
->r
.record
.x
.ab
= ab
;
2292 ptr
->r
.record
.x
.reg
= reg
;
2293 ptr
->r
.record
.x
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2297 static unw_rec_list
*
2298 output_spill_sprel (ab
, reg
, offset
)
2301 unsigned int offset
;
2303 unw_rec_list
*ptr
= alloc_record (spill_sprel
);
2304 ptr
->r
.record
.x
.ab
= ab
;
2305 ptr
->r
.record
.x
.reg
= reg
;
2306 ptr
->r
.record
.x
.spoff
= offset
/ 4;
2310 static unw_rec_list
*
2311 output_spill_psprel_p (ab
, reg
, offset
, predicate
)
2314 unsigned int offset
;
2315 unsigned int predicate
;
2317 unw_rec_list
*ptr
= alloc_record (spill_psprel_p
);
2318 ptr
->r
.record
.x
.ab
= ab
;
2319 ptr
->r
.record
.x
.reg
= reg
;
2320 ptr
->r
.record
.x
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2321 ptr
->r
.record
.x
.qp
= predicate
;
2325 static unw_rec_list
*
2326 output_spill_sprel_p (ab
, reg
, offset
, predicate
)
2329 unsigned int offset
;
2330 unsigned int predicate
;
2332 unw_rec_list
*ptr
= alloc_record (spill_sprel_p
);
2333 ptr
->r
.record
.x
.ab
= ab
;
2334 ptr
->r
.record
.x
.reg
= reg
;
2335 ptr
->r
.record
.x
.spoff
= offset
/ 4;
2336 ptr
->r
.record
.x
.qp
= predicate
;
2340 static unw_rec_list
*
2341 output_spill_reg (ab
, reg
, targ_reg
, xy
)
2344 unsigned int targ_reg
;
2347 unw_rec_list
*ptr
= alloc_record (spill_reg
);
2348 ptr
->r
.record
.x
.ab
= ab
;
2349 ptr
->r
.record
.x
.reg
= reg
;
2350 ptr
->r
.record
.x
.treg
= targ_reg
;
2351 ptr
->r
.record
.x
.xy
= xy
;
2355 static unw_rec_list
*
2356 output_spill_reg_p (ab
, reg
, targ_reg
, xy
, predicate
)
2359 unsigned int targ_reg
;
2361 unsigned int predicate
;
2363 unw_rec_list
*ptr
= alloc_record (spill_reg_p
);
2364 ptr
->r
.record
.x
.ab
= ab
;
2365 ptr
->r
.record
.x
.reg
= reg
;
2366 ptr
->r
.record
.x
.treg
= targ_reg
;
2367 ptr
->r
.record
.x
.xy
= xy
;
2368 ptr
->r
.record
.x
.qp
= predicate
;
2372 /* Given a unw_rec_list process the correct format with the
2373 specified function. */
2376 process_one_record (ptr
, f
)
2380 unsigned long fr_mask
, gr_mask
;
2382 switch (ptr
->r
.type
)
2384 /* This is a dummy record that takes up no space in the output. */
2392 /* These are taken care of by prologue/prologue_gr. */
2397 if (ptr
->r
.type
== prologue_gr
)
2398 output_R2_format (f
, ptr
->r
.record
.r
.grmask
,
2399 ptr
->r
.record
.r
.grsave
, ptr
->r
.record
.r
.rlen
);
2401 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2403 /* Output descriptor(s) for union of register spills (if any). */
2404 gr_mask
= ptr
->r
.record
.r
.mask
.gr_mem
;
2405 fr_mask
= ptr
->r
.record
.r
.mask
.fr_mem
;
2408 if ((fr_mask
& ~0xfUL
) == 0)
2409 output_P6_format (f
, fr_mem
, fr_mask
);
2412 output_P5_format (f
, gr_mask
, fr_mask
);
2417 output_P6_format (f
, gr_mem
, gr_mask
);
2418 if (ptr
->r
.record
.r
.mask
.br_mem
)
2419 output_P1_format (f
, ptr
->r
.record
.r
.mask
.br_mem
);
2421 /* output imask descriptor if necessary: */
2422 if (ptr
->r
.record
.r
.mask
.i
)
2423 output_P4_format (f
, ptr
->r
.record
.r
.mask
.i
,
2424 ptr
->r
.record
.r
.imask_size
);
2428 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2432 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
,
2433 ptr
->r
.record
.p
.size
);
2446 output_P3_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.gr
);
2449 output_P3_format (f
, rp_br
, ptr
->r
.record
.p
.br
);
2452 output_P7_format (f
, psp_sprel
, ptr
->r
.record
.p
.spoff
, 0);
2460 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
, 0);
2469 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.pspoff
, 0);
2479 case bspstore_sprel
:
2481 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.spoff
);
2484 output_P9_format (f
, ptr
->r
.record
.p
.grmask
, ptr
->r
.record
.p
.gr
);
2487 output_P2_format (f
, ptr
->r
.record
.p
.brmask
, ptr
->r
.record
.p
.gr
);
2490 as_bad ("spill_mask record unimplemented.");
2492 case priunat_when_gr
:
2493 case priunat_when_mem
:
2497 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
);
2499 case priunat_psprel
:
2501 case bspstore_psprel
:
2503 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.pspoff
);
2506 output_P10_format (f
, ptr
->r
.record
.p
.abi
, ptr
->r
.record
.p
.context
);
2509 output_B3_format (f
, ptr
->r
.record
.b
.ecount
, ptr
->r
.record
.b
.t
);
2513 output_B4_format (f
, ptr
->r
.type
, ptr
->r
.record
.b
.label
);
2516 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2517 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2518 ptr
->r
.record
.x
.pspoff
);
2521 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2522 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2523 ptr
->r
.record
.x
.spoff
);
2526 output_X2_format (f
, ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2527 ptr
->r
.record
.x
.xy
>> 1, ptr
->r
.record
.x
.xy
,
2528 ptr
->r
.record
.x
.treg
, ptr
->r
.record
.x
.t
);
2530 case spill_psprel_p
:
2531 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2532 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2533 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.pspoff
);
2536 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2537 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2538 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.spoff
);
2541 output_X4_format (f
, ptr
->r
.record
.x
.qp
, ptr
->r
.record
.x
.ab
,
2542 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.xy
>> 1,
2543 ptr
->r
.record
.x
.xy
, ptr
->r
.record
.x
.treg
,
2547 as_bad ("record_type_not_valid");
2552 /* Given a unw_rec_list list, process all the records with
2553 the specified function. */
2555 process_unw_records (list
, f
)
2560 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2561 process_one_record (ptr
, f
);
2564 /* Determine the size of a record list in bytes. */
2566 calc_record_size (list
)
2570 process_unw_records (list
, count_output
);
2574 /* Update IMASK bitmask to reflect the fact that one or more registers
2575 of type TYPE are saved starting at instruction with index T. If N
2576 bits are set in REGMASK, it is assumed that instructions T through
2577 T+N-1 save these registers.
2581 1: instruction saves next fp reg
2582 2: instruction saves next general reg
2583 3: instruction saves next branch reg */
2585 set_imask (region
, regmask
, t
, type
)
2586 unw_rec_list
*region
;
2587 unsigned long regmask
;
2591 unsigned char *imask
;
2592 unsigned long imask_size
;
2596 imask
= region
->r
.record
.r
.mask
.i
;
2597 imask_size
= region
->r
.record
.r
.imask_size
;
2600 imask_size
= (region
->r
.record
.r
.rlen
* 2 + 7) / 8 + 1;
2601 imask
= xmalloc (imask_size
);
2602 memset (imask
, 0, imask_size
);
2604 region
->r
.record
.r
.imask_size
= imask_size
;
2605 region
->r
.record
.r
.mask
.i
= imask
;
2609 pos
= 2 * (3 - t
% 4);
2612 if (i
>= imask_size
)
2614 as_bad ("Ignoring attempt to spill beyond end of region");
2618 imask
[i
] |= (type
& 0x3) << pos
;
2620 regmask
&= (regmask
- 1);
2630 /* Return the number of instruction slots from FIRST_ADDR to SLOT_ADDR.
2631 SLOT_FRAG is the frag containing SLOT_ADDR, and FIRST_FRAG is the frag
2632 containing FIRST_ADDR. If BEFORE_RELAX, then we use worst-case estimates
2636 slot_index (slot_addr
, slot_frag
, first_addr
, first_frag
, before_relax
)
2637 unsigned long slot_addr
;
2639 unsigned long first_addr
;
2643 unsigned long index
= 0;
2645 /* First time we are called, the initial address and frag are invalid. */
2646 if (first_addr
== 0)
2649 /* If the two addresses are in different frags, then we need to add in
2650 the remaining size of this frag, and then the entire size of intermediate
2652 while (slot_frag
!= first_frag
)
2654 unsigned long start_addr
= (unsigned long) &first_frag
->fr_literal
;
2658 /* We can get the final addresses only during and after
2660 if (first_frag
->fr_next
&& first_frag
->fr_next
->fr_address
)
2661 index
+= 3 * ((first_frag
->fr_next
->fr_address
2662 - first_frag
->fr_address
2663 - first_frag
->fr_fix
) >> 4);
2666 /* We don't know what the final addresses will be. We try our
2667 best to estimate. */
2668 switch (first_frag
->fr_type
)
2674 as_fatal ("only constant space allocation is supported");
2680 /* Take alignment into account. Assume the worst case
2681 before relaxation. */
2682 index
+= 3 * ((1 << first_frag
->fr_offset
) >> 4);
2686 if (first_frag
->fr_symbol
)
2688 as_fatal ("only constant offsets are supported");
2692 index
+= 3 * (first_frag
->fr_offset
>> 4);
2696 /* Add in the full size of the frag converted to instruction slots. */
2697 index
+= 3 * (first_frag
->fr_fix
>> 4);
2698 /* Subtract away the initial part before first_addr. */
2699 index
-= (3 * ((first_addr
>> 4) - (start_addr
>> 4))
2700 + ((first_addr
& 0x3) - (start_addr
& 0x3)));
2702 /* Move to the beginning of the next frag. */
2703 first_frag
= first_frag
->fr_next
;
2704 first_addr
= (unsigned long) &first_frag
->fr_literal
;
2707 /* Add in the used part of the last frag. */
2708 index
+= (3 * ((slot_addr
>> 4) - (first_addr
>> 4))
2709 + ((slot_addr
& 0x3) - (first_addr
& 0x3)));
2713 /* Optimize unwind record directives. */
2715 static unw_rec_list
*
2716 optimize_unw_records (list
)
2722 /* If the only unwind record is ".prologue" or ".prologue" followed
2723 by ".body", then we can optimize the unwind directives away. */
2724 if (list
->r
.type
== prologue
2725 && (list
->next
->r
.type
== endp
2726 || (list
->next
->r
.type
== body
&& list
->next
->next
->r
.type
== endp
)))
2732 /* Given a complete record list, process any records which have
2733 unresolved fields, (ie length counts for a prologue). After
2734 this has been run, all necessary information should be available
2735 within each record to generate an image. */
2738 fixup_unw_records (list
, before_relax
)
2742 unw_rec_list
*ptr
, *region
= 0;
2743 unsigned long first_addr
= 0, rlen
= 0, t
;
2744 fragS
*first_frag
= 0;
2746 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2748 if (ptr
->slot_number
== SLOT_NUM_NOT_SET
)
2749 as_bad (" Insn slot not set in unwind record.");
2750 t
= slot_index (ptr
->slot_number
, ptr
->slot_frag
,
2751 first_addr
, first_frag
, before_relax
);
2752 switch (ptr
->r
.type
)
2760 unsigned long last_addr
= 0;
2761 fragS
*last_frag
= NULL
;
2763 first_addr
= ptr
->slot_number
;
2764 first_frag
= ptr
->slot_frag
;
2765 /* Find either the next body/prologue start, or the end of
2766 the function, and determine the size of the region. */
2767 for (last
= ptr
->next
; last
!= NULL
; last
= last
->next
)
2768 if (last
->r
.type
== prologue
|| last
->r
.type
== prologue_gr
2769 || last
->r
.type
== body
|| last
->r
.type
== endp
)
2771 last_addr
= last
->slot_number
;
2772 last_frag
= last
->slot_frag
;
2775 size
= slot_index (last_addr
, last_frag
, first_addr
, first_frag
,
2777 rlen
= ptr
->r
.record
.r
.rlen
= size
;
2778 if (ptr
->r
.type
== body
)
2779 /* End of region. */
2787 ptr
->r
.record
.b
.t
= rlen
- 1 - t
;
2789 /* This happens when a memory-stack-less procedure uses a
2790 ".restore sp" directive at the end of a region to pop
2792 ptr
->r
.record
.b
.t
= 0;
2803 case priunat_when_gr
:
2804 case priunat_when_mem
:
2808 ptr
->r
.record
.p
.t
= t
;
2816 case spill_psprel_p
:
2817 ptr
->r
.record
.x
.t
= t
;
2823 as_bad ("frgr_mem record before region record!");
2826 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.frmask
;
2827 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.grmask
;
2828 set_imask (region
, ptr
->r
.record
.p
.frmask
, t
, 1);
2829 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2834 as_bad ("fr_mem record before region record!");
2837 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.rmask
;
2838 set_imask (region
, ptr
->r
.record
.p
.rmask
, t
, 1);
2843 as_bad ("gr_mem record before region record!");
2846 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.rmask
;
2847 set_imask (region
, ptr
->r
.record
.p
.rmask
, t
, 2);
2852 as_bad ("br_mem record before region record!");
2855 region
->r
.record
.r
.mask
.br_mem
|= ptr
->r
.record
.p
.brmask
;
2856 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2862 as_bad ("gr_gr record before region record!");
2865 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2870 as_bad ("br_gr record before region record!");
2873 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2882 /* Estimate the size of a frag before relaxing. We only have one type of frag
2883 to handle here, which is the unwind info frag. */
2886 ia64_estimate_size_before_relax (fragS
*frag
,
2887 asection
*segtype ATTRIBUTE_UNUSED
)
2892 /* ??? This code is identical to the first part of ia64_convert_frag. */
2893 list
= (unw_rec_list
*) frag
->fr_opcode
;
2894 fixup_unw_records (list
, 0);
2896 len
= calc_record_size (list
);
2897 /* pad to pointer-size boundary. */
2898 pad
= len
% md
.pointer_size
;
2900 len
+= md
.pointer_size
- pad
;
2901 /* Add 8 for the header. */
2903 /* Add a pointer for the personality offset. */
2904 if (frag
->fr_offset
)
2905 size
+= md
.pointer_size
;
2907 /* fr_var carries the max_chars that we created the fragment with.
2908 We must, of course, have allocated enough memory earlier. */
2909 assert (frag
->fr_var
>= size
);
2911 return frag
->fr_fix
+ size
;
2914 /* This function converts a rs_machine_dependent variant frag into a
2915 normal fill frag with the unwind image from the the record list. */
2917 ia64_convert_frag (fragS
*frag
)
2923 /* ??? This code is identical to ia64_estimate_size_before_relax. */
2924 list
= (unw_rec_list
*) frag
->fr_opcode
;
2925 fixup_unw_records (list
, 0);
2927 len
= calc_record_size (list
);
2928 /* pad to pointer-size boundary. */
2929 pad
= len
% md
.pointer_size
;
2931 len
+= md
.pointer_size
- pad
;
2932 /* Add 8 for the header. */
2934 /* Add a pointer for the personality offset. */
2935 if (frag
->fr_offset
)
2936 size
+= md
.pointer_size
;
2938 /* fr_var carries the max_chars that we created the fragment with.
2939 We must, of course, have allocated enough memory earlier. */
2940 assert (frag
->fr_var
>= size
);
2942 /* Initialize the header area. fr_offset is initialized with
2943 unwind.personality_routine. */
2944 if (frag
->fr_offset
)
2946 if (md
.flags
& EF_IA_64_ABI64
)
2947 flag_value
= (bfd_vma
) 3 << 32;
2949 /* 32-bit unwind info block. */
2950 flag_value
= (bfd_vma
) 0x1003 << 32;
2955 md_number_to_chars (frag
->fr_literal
,
2956 (((bfd_vma
) 1 << 48) /* Version. */
2957 | flag_value
/* U & E handler flags. */
2958 | (len
/ md
.pointer_size
)), /* Length. */
2961 /* Skip the header. */
2962 vbyte_mem_ptr
= frag
->fr_literal
+ 8;
2963 process_unw_records (list
, output_vbyte_mem
);
2965 /* Fill the padding bytes with zeros. */
2967 md_number_to_chars (frag
->fr_literal
+ len
+ 8 - md
.pointer_size
+ pad
, 0,
2968 md
.pointer_size
- pad
);
2970 frag
->fr_fix
+= size
;
2971 frag
->fr_type
= rs_fill
;
2973 frag
->fr_offset
= 0;
2977 convert_expr_to_ab_reg (e
, ab
, regp
)
2984 if (e
->X_op
!= O_register
)
2987 reg
= e
->X_add_number
;
2988 if (reg
>= (REG_GR
+ 4) && reg
<= (REG_GR
+ 7))
2991 *regp
= reg
- REG_GR
;
2993 else if ((reg
>= (REG_FR
+ 2) && reg
<= (REG_FR
+ 5))
2994 || (reg
>= (REG_FR
+ 16) && reg
<= (REG_FR
+ 31)))
2997 *regp
= reg
- REG_FR
;
2999 else if (reg
>= (REG_BR
+ 1) && reg
<= (REG_BR
+ 5))
3002 *regp
= reg
- REG_BR
;
3009 case REG_PR
: *regp
= 0; break;
3010 case REG_PSP
: *regp
= 1; break;
3011 case REG_PRIUNAT
: *regp
= 2; break;
3012 case REG_BR
+ 0: *regp
= 3; break;
3013 case REG_AR
+ AR_BSP
: *regp
= 4; break;
3014 case REG_AR
+ AR_BSPSTORE
: *regp
= 5; break;
3015 case REG_AR
+ AR_RNAT
: *regp
= 6; break;
3016 case REG_AR
+ AR_UNAT
: *regp
= 7; break;
3017 case REG_AR
+ AR_FPSR
: *regp
= 8; break;
3018 case REG_AR
+ AR_PFS
: *regp
= 9; break;
3019 case REG_AR
+ AR_LC
: *regp
= 10; break;
3029 convert_expr_to_xy_reg (e
, xy
, regp
)
3036 if (e
->X_op
!= O_register
)
3039 reg
= e
->X_add_number
;
3041 if (/* reg >= REG_GR && */ reg
<= (REG_GR
+ 127))
3044 *regp
= reg
- REG_GR
;
3046 else if (reg
>= REG_FR
&& reg
<= (REG_FR
+ 127))
3049 *regp
= reg
- REG_FR
;
3051 else if (reg
>= REG_BR
&& reg
<= (REG_BR
+ 7))
3054 *regp
= reg
- REG_BR
;
3064 /* The current frag is an alignment frag. */
3065 align_frag
= frag_now
;
3066 s_align_bytes (arg
);
3071 int dummy ATTRIBUTE_UNUSED
;
3078 if (is_it_end_of_statement ())
3080 radix
= input_line_pointer
;
3081 ch
= get_symbol_end ();
3082 ia64_canonicalize_symbol_name (radix
);
3083 if (strcasecmp (radix
, "C"))
3084 as_bad ("Radix `%s' unsupported or invalid", radix
);
3085 *input_line_pointer
= ch
;
3086 demand_empty_rest_of_line ();
3089 /* Helper function for .loc directives. If the assembler is not generating
3090 line number info, then we need to remember which instructions have a .loc
3091 directive, and only call dwarf2_gen_line_info for those instructions. */
3096 CURR_SLOT
.loc_directive_seen
= 1;
3097 dwarf2_directive_loc (x
);
3100 /* .sbss, .bss etc. are macros that expand into ".section SECNAME". */
3102 dot_special_section (which
)
3105 set_section ((char *) special_section_name
[which
]);
3108 /* Return -1 for warning and 0 for error. */
3111 unwind_diagnostic (const char * region
, const char *directive
)
3113 if (md
.unwind_check
== unwind_check_warning
)
3115 as_warn (".%s outside of %s", directive
, region
);
3120 as_bad (".%s outside of %s", directive
, region
);
3121 ignore_rest_of_line ();
3126 /* Return 1 if a directive is in a procedure, -1 if a directive isn't in
3127 a procedure but the unwind directive check is set to warning, 0 if
3128 a directive isn't in a procedure and the unwind directive check is set
3132 in_procedure (const char *directive
)
3134 if (unwind
.proc_start
3135 && (!unwind
.saved_text_seg
|| strcmp (directive
, "endp") == 0))
3137 return unwind_diagnostic ("procedure", directive
);
3140 /* Return 1 if a directive is in a prologue, -1 if a directive isn't in
3141 a prologue but the unwind directive check is set to warning, 0 if
3142 a directive isn't in a prologue and the unwind directive check is set
3146 in_prologue (const char *directive
)
3148 int in
= in_procedure (directive
);
3151 /* We are in a procedure. Check if we are in a prologue. */
3152 if (unwind
.prologue
)
3154 /* We only want to issue one message. */
3156 return unwind_diagnostic ("prologue", directive
);
3163 /* Return 1 if a directive is in a body, -1 if a directive isn't in
3164 a body but the unwind directive check is set to warning, 0 if
3165 a directive isn't in a body and the unwind directive check is set
3169 in_body (const char *directive
)
3171 int in
= in_procedure (directive
);
3174 /* We are in a procedure. Check if we are in a body. */
3177 /* We only want to issue one message. */
3179 return unwind_diagnostic ("body region", directive
);
3187 add_unwind_entry (ptr
)
3191 unwind
.tail
->next
= ptr
;
3196 /* The current entry can in fact be a chain of unwind entries. */
3197 if (unwind
.current_entry
== NULL
)
3198 unwind
.current_entry
= ptr
;
3203 int dummy ATTRIBUTE_UNUSED
;
3207 if (!in_prologue ("fframe"))
3212 if (e
.X_op
!= O_constant
)
3213 as_bad ("Operand to .fframe must be a constant");
3215 add_unwind_entry (output_mem_stack_f (e
.X_add_number
));
3220 int dummy ATTRIBUTE_UNUSED
;
3225 if (!in_prologue ("vframe"))
3229 reg
= e
.X_add_number
- REG_GR
;
3230 if (e
.X_op
== O_register
&& reg
< 128)
3232 add_unwind_entry (output_mem_stack_v ());
3233 if (! (unwind
.prologue_mask
& 2))
3234 add_unwind_entry (output_psp_gr (reg
));
3237 as_bad ("First operand to .vframe must be a general register");
3241 dot_vframesp (dummy
)
3242 int dummy ATTRIBUTE_UNUSED
;
3246 if (!in_prologue ("vframesp"))
3250 if (e
.X_op
== O_constant
)
3252 add_unwind_entry (output_mem_stack_v ());
3253 add_unwind_entry (output_psp_sprel (e
.X_add_number
));
3256 as_bad ("Operand to .vframesp must be a constant (sp-relative offset)");
3260 dot_vframepsp (dummy
)
3261 int dummy ATTRIBUTE_UNUSED
;
3265 if (!in_prologue ("vframepsp"))
3269 if (e
.X_op
== O_constant
)
3271 add_unwind_entry (output_mem_stack_v ());
3272 add_unwind_entry (output_psp_sprel (e
.X_add_number
));
3275 as_bad ("Operand to .vframepsp must be a constant (psp-relative offset)");
3280 int dummy ATTRIBUTE_UNUSED
;
3286 if (!in_prologue ("save"))
3289 sep
= parse_operand (&e1
);
3291 as_bad ("No second operand to .save");
3292 sep
= parse_operand (&e2
);
3294 reg1
= e1
.X_add_number
;
3295 reg2
= e2
.X_add_number
- REG_GR
;
3297 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3298 if (e1
.X_op
== O_register
)
3300 if (e2
.X_op
== O_register
&& reg2
>= 0 && reg2
< 128)
3304 case REG_AR
+ AR_BSP
:
3305 add_unwind_entry (output_bsp_when ());
3306 add_unwind_entry (output_bsp_gr (reg2
));
3308 case REG_AR
+ AR_BSPSTORE
:
3309 add_unwind_entry (output_bspstore_when ());
3310 add_unwind_entry (output_bspstore_gr (reg2
));
3312 case REG_AR
+ AR_RNAT
:
3313 add_unwind_entry (output_rnat_when ());
3314 add_unwind_entry (output_rnat_gr (reg2
));
3316 case REG_AR
+ AR_UNAT
:
3317 add_unwind_entry (output_unat_when ());
3318 add_unwind_entry (output_unat_gr (reg2
));
3320 case REG_AR
+ AR_FPSR
:
3321 add_unwind_entry (output_fpsr_when ());
3322 add_unwind_entry (output_fpsr_gr (reg2
));
3324 case REG_AR
+ AR_PFS
:
3325 add_unwind_entry (output_pfs_when ());
3326 if (! (unwind
.prologue_mask
& 4))
3327 add_unwind_entry (output_pfs_gr (reg2
));
3329 case REG_AR
+ AR_LC
:
3330 add_unwind_entry (output_lc_when ());
3331 add_unwind_entry (output_lc_gr (reg2
));
3334 add_unwind_entry (output_rp_when ());
3335 if (! (unwind
.prologue_mask
& 8))
3336 add_unwind_entry (output_rp_gr (reg2
));
3339 add_unwind_entry (output_preds_when ());
3340 if (! (unwind
.prologue_mask
& 1))
3341 add_unwind_entry (output_preds_gr (reg2
));
3344 add_unwind_entry (output_priunat_when_gr ());
3345 add_unwind_entry (output_priunat_gr (reg2
));
3348 as_bad ("First operand not a valid register");
3352 as_bad (" Second operand not a valid register");
3355 as_bad ("First operand not a register");
3360 int dummy ATTRIBUTE_UNUSED
;
3363 unsigned long ecount
; /* # of _additional_ regions to pop */
3366 if (!in_body ("restore"))
3369 sep
= parse_operand (&e1
);
3370 if (e1
.X_op
!= O_register
|| e1
.X_add_number
!= REG_GR
+ 12)
3372 as_bad ("First operand to .restore must be stack pointer (sp)");
3378 parse_operand (&e2
);
3379 if (e2
.X_op
!= O_constant
|| e2
.X_add_number
< 0)
3381 as_bad ("Second operand to .restore must be a constant >= 0");
3384 ecount
= e2
.X_add_number
;
3387 ecount
= unwind
.prologue_count
- 1;
3389 if (ecount
>= unwind
.prologue_count
)
3391 as_bad ("Epilogue count of %lu exceeds number of nested prologues (%u)",
3392 ecount
+ 1, unwind
.prologue_count
);
3396 add_unwind_entry (output_epilogue (ecount
));
3398 if (ecount
< unwind
.prologue_count
)
3399 unwind
.prologue_count
-= ecount
+ 1;
3401 unwind
.prologue_count
= 0;
3405 dot_restorereg (dummy
)
3406 int dummy ATTRIBUTE_UNUSED
;
3408 unsigned int ab
, reg
;
3411 if (!in_procedure ("restorereg"))
3416 if (!convert_expr_to_ab_reg (&e
, &ab
, ®
))
3418 as_bad ("First operand to .restorereg must be a preserved register");
3421 add_unwind_entry (output_spill_reg (ab
, reg
, 0, 0));
3425 dot_restorereg_p (dummy
)
3426 int dummy ATTRIBUTE_UNUSED
;
3428 unsigned int qp
, ab
, reg
;
3432 if (!in_procedure ("restorereg.p"))
3435 sep
= parse_operand (&e1
);
3438 as_bad ("No second operand to .restorereg.p");
3442 parse_operand (&e2
);
3444 qp
= e1
.X_add_number
- REG_P
;
3445 if (e1
.X_op
!= O_register
|| qp
> 63)
3447 as_bad ("First operand to .restorereg.p must be a predicate");
3451 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
3453 as_bad ("Second operand to .restorereg.p must be a preserved register");
3456 add_unwind_entry (output_spill_reg_p (ab
, reg
, 0, 0, qp
));
3459 static char *special_linkonce_name
[] =
3461 ".gnu.linkonce.ia64unw.", ".gnu.linkonce.ia64unwi."
3465 start_unwind_section (const segT text_seg
, int sec_index
)
3468 Use a slightly ugly scheme to derive the unwind section names from
3469 the text section name:
3471 text sect. unwind table sect.
3472 name: name: comments:
3473 ---------- ----------------- --------------------------------
3475 .text.foo .IA_64.unwind.text.foo
3476 .foo .IA_64.unwind.foo
3478 .gnu.linkonce.ia64unw.foo
3479 _info .IA_64.unwind_info gas issues error message (ditto)
3480 _infoFOO .IA_64.unwind_infoFOO gas issues error message (ditto)
3482 This mapping is done so that:
3484 (a) An object file with unwind info only in .text will use
3485 unwind section names .IA_64.unwind and .IA_64.unwind_info.
3486 This follows the letter of the ABI and also ensures backwards
3487 compatibility with older toolchains.
3489 (b) An object file with unwind info in multiple text sections
3490 will use separate unwind sections for each text section.
3491 This allows us to properly set the "sh_info" and "sh_link"
3492 fields in SHT_IA_64_UNWIND as required by the ABI and also
3493 lets GNU ld support programs with multiple segments
3494 containing unwind info (as might be the case for certain
3495 embedded applications).
3497 (c) An error is issued if there would be a name clash.
3500 const char *text_name
, *sec_text_name
;
3502 const char *prefix
= special_section_name
[sec_index
];
3504 size_t prefix_len
, suffix_len
, sec_name_len
;
3506 sec_text_name
= segment_name (text_seg
);
3507 text_name
= sec_text_name
;
3508 if (strncmp (text_name
, "_info", 5) == 0)
3510 as_bad ("Illegal section name `%s' (causes unwind section name clash)",
3512 ignore_rest_of_line ();
3515 if (strcmp (text_name
, ".text") == 0)
3518 /* Build the unwind section name by appending the (possibly stripped)
3519 text section name to the unwind prefix. */
3521 if (strncmp (text_name
, ".gnu.linkonce.t.",
3522 sizeof (".gnu.linkonce.t.") - 1) == 0)
3524 prefix
= special_linkonce_name
[sec_index
- SPECIAL_SECTION_UNWIND
];
3525 suffix
+= sizeof (".gnu.linkonce.t.") - 1;
3528 prefix_len
= strlen (prefix
);
3529 suffix_len
= strlen (suffix
);
3530 sec_name_len
= prefix_len
+ suffix_len
;
3531 sec_name
= alloca (sec_name_len
+ 1);
3532 memcpy (sec_name
, prefix
, prefix_len
);
3533 memcpy (sec_name
+ prefix_len
, suffix
, suffix_len
);
3534 sec_name
[sec_name_len
] = '\0';
3536 /* Handle COMDAT group. */
3537 if ((text_seg
->flags
& SEC_LINK_ONCE
) != 0
3538 && (elf_section_flags (text_seg
) & SHF_GROUP
) != 0)
3541 size_t len
, group_name_len
;
3542 const char *group_name
= elf_group_name (text_seg
);
3544 if (group_name
== NULL
)
3546 as_bad ("Group section `%s' has no group signature",
3548 ignore_rest_of_line ();
3551 /* We have to construct a fake section directive. */
3552 group_name_len
= strlen (group_name
);
3554 + 16 /* ,"aG",@progbits, */
3555 + group_name_len
/* ,group_name */
3558 section
= alloca (len
+ 1);
3559 memcpy (section
, sec_name
, sec_name_len
);
3560 memcpy (section
+ sec_name_len
, ",\"aG\",@progbits,", 16);
3561 memcpy (section
+ sec_name_len
+ 16, group_name
, group_name_len
);
3562 memcpy (section
+ len
- 7, ",comdat", 7);
3563 section
[len
] = '\0';
3564 set_section (section
);
3568 set_section (sec_name
);
3569 bfd_set_section_flags (stdoutput
, now_seg
,
3570 SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
);
3573 elf_linked_to_section (now_seg
) = text_seg
;
3577 generate_unwind_image (const segT text_seg
)
3582 /* Mark the end of the unwind info, so that we can compute the size of the
3583 last unwind region. */
3584 add_unwind_entry (output_endp ());
3586 /* Force out pending instructions, to make sure all unwind records have
3587 a valid slot_number field. */
3588 ia64_flush_insns ();
3590 /* Generate the unwind record. */
3591 list
= optimize_unw_records (unwind
.list
);
3592 fixup_unw_records (list
, 1);
3593 size
= calc_record_size (list
);
3595 if (size
> 0 || unwind
.force_unwind_entry
)
3597 unwind
.force_unwind_entry
= 0;
3598 /* pad to pointer-size boundary. */
3599 pad
= size
% md
.pointer_size
;
3601 size
+= md
.pointer_size
- pad
;
3602 /* Add 8 for the header. */
3604 /* Add a pointer for the personality offset. */
3605 if (unwind
.personality_routine
)
3606 size
+= md
.pointer_size
;
3609 /* If there are unwind records, switch sections, and output the info. */
3613 bfd_reloc_code_real_type reloc
;
3615 start_unwind_section (text_seg
, SPECIAL_SECTION_UNWIND_INFO
);
3617 /* Make sure the section has 4 byte alignment for ILP32 and
3618 8 byte alignment for LP64. */
3619 frag_align (md
.pointer_size_shift
, 0, 0);
3620 record_alignment (now_seg
, md
.pointer_size_shift
);
3622 /* Set expression which points to start of unwind descriptor area. */
3623 unwind
.info
= expr_build_dot ();
3625 frag_var (rs_machine_dependent
, size
, size
, 0, 0,
3626 (offsetT
) (long) unwind
.personality_routine
,
3629 /* Add the personality address to the image. */
3630 if (unwind
.personality_routine
!= 0)
3632 exp
.X_op
= O_symbol
;
3633 exp
.X_add_symbol
= unwind
.personality_routine
;
3634 exp
.X_add_number
= 0;
3636 if (md
.flags
& EF_IA_64_BE
)
3638 if (md
.flags
& EF_IA_64_ABI64
)
3639 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64MSB
;
3641 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32MSB
;
3645 if (md
.flags
& EF_IA_64_ABI64
)
3646 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64LSB
;
3648 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32LSB
;
3651 fix_new_exp (frag_now
, frag_now_fix () - md
.pointer_size
,
3652 md
.pointer_size
, &exp
, 0, reloc
);
3653 unwind
.personality_routine
= 0;
3657 free_saved_prologue_counts ();
3658 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
3662 dot_handlerdata (dummy
)
3663 int dummy ATTRIBUTE_UNUSED
;
3665 if (!in_procedure ("handlerdata"))
3667 unwind
.force_unwind_entry
= 1;
3669 /* Remember which segment we're in so we can switch back after .endp */
3670 unwind
.saved_text_seg
= now_seg
;
3671 unwind
.saved_text_subseg
= now_subseg
;
3673 /* Generate unwind info into unwind-info section and then leave that
3674 section as the currently active one so dataXX directives go into
3675 the language specific data area of the unwind info block. */
3676 generate_unwind_image (now_seg
);
3677 demand_empty_rest_of_line ();
3681 dot_unwentry (dummy
)
3682 int dummy ATTRIBUTE_UNUSED
;
3684 if (!in_procedure ("unwentry"))
3686 unwind
.force_unwind_entry
= 1;
3687 demand_empty_rest_of_line ();
3692 int dummy ATTRIBUTE_UNUSED
;
3697 if (!in_prologue ("altrp"))
3701 reg
= e
.X_add_number
- REG_BR
;
3702 if (e
.X_op
== O_register
&& reg
< 8)
3703 add_unwind_entry (output_rp_br (reg
));
3705 as_bad ("First operand not a valid branch register");
3709 dot_savemem (psprel
)
3716 if (!in_prologue (psprel
? "savepsp" : "savesp"))
3719 sep
= parse_operand (&e1
);
3721 as_bad ("No second operand to .save%ssp", psprel
? "p" : "");
3722 sep
= parse_operand (&e2
);
3724 reg1
= e1
.X_add_number
;
3725 val
= e2
.X_add_number
;
3727 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3728 if (e1
.X_op
== O_register
)
3730 if (e2
.X_op
== O_constant
)
3734 case REG_AR
+ AR_BSP
:
3735 add_unwind_entry (output_bsp_when ());
3736 add_unwind_entry ((psprel
3738 : output_bsp_sprel
) (val
));
3740 case REG_AR
+ AR_BSPSTORE
:
3741 add_unwind_entry (output_bspstore_when ());
3742 add_unwind_entry ((psprel
3743 ? output_bspstore_psprel
3744 : output_bspstore_sprel
) (val
));
3746 case REG_AR
+ AR_RNAT
:
3747 add_unwind_entry (output_rnat_when ());
3748 add_unwind_entry ((psprel
3749 ? output_rnat_psprel
3750 : output_rnat_sprel
) (val
));
3752 case REG_AR
+ AR_UNAT
:
3753 add_unwind_entry (output_unat_when ());
3754 add_unwind_entry ((psprel
3755 ? output_unat_psprel
3756 : output_unat_sprel
) (val
));
3758 case REG_AR
+ AR_FPSR
:
3759 add_unwind_entry (output_fpsr_when ());
3760 add_unwind_entry ((psprel
3761 ? output_fpsr_psprel
3762 : output_fpsr_sprel
) (val
));
3764 case REG_AR
+ AR_PFS
:
3765 add_unwind_entry (output_pfs_when ());
3766 add_unwind_entry ((psprel
3768 : output_pfs_sprel
) (val
));
3770 case REG_AR
+ AR_LC
:
3771 add_unwind_entry (output_lc_when ());
3772 add_unwind_entry ((psprel
3774 : output_lc_sprel
) (val
));
3777 add_unwind_entry (output_rp_when ());
3778 add_unwind_entry ((psprel
3780 : output_rp_sprel
) (val
));
3783 add_unwind_entry (output_preds_when ());
3784 add_unwind_entry ((psprel
3785 ? output_preds_psprel
3786 : output_preds_sprel
) (val
));
3789 add_unwind_entry (output_priunat_when_mem ());
3790 add_unwind_entry ((psprel
3791 ? output_priunat_psprel
3792 : output_priunat_sprel
) (val
));
3795 as_bad ("First operand not a valid register");
3799 as_bad (" Second operand not a valid constant");
3802 as_bad ("First operand not a register");
3807 int dummy ATTRIBUTE_UNUSED
;
3812 if (!in_prologue ("save.g"))
3815 sep
= parse_operand (&e1
);
3817 parse_operand (&e2
);
3819 if (e1
.X_op
!= O_constant
)
3820 as_bad ("First operand to .save.g must be a constant.");
3823 int grmask
= e1
.X_add_number
;
3825 add_unwind_entry (output_gr_mem (grmask
));
3828 int reg
= e2
.X_add_number
- REG_GR
;
3829 if (e2
.X_op
== O_register
&& reg
>= 0 && reg
< 128)
3830 add_unwind_entry (output_gr_gr (grmask
, reg
));
3832 as_bad ("Second operand is an invalid register.");
3839 int dummy ATTRIBUTE_UNUSED
;
3844 if (!in_prologue ("save.f"))
3847 sep
= parse_operand (&e1
);
3849 if (e1
.X_op
!= O_constant
)
3850 as_bad ("Operand to .save.f must be a constant.");
3852 add_unwind_entry (output_fr_mem (e1
.X_add_number
));
3857 int dummy ATTRIBUTE_UNUSED
;
3864 if (!in_prologue ("save.b"))
3867 sep
= parse_operand (&e1
);
3868 if (e1
.X_op
!= O_constant
)
3870 as_bad ("First operand to .save.b must be a constant.");
3873 brmask
= e1
.X_add_number
;
3877 sep
= parse_operand (&e2
);
3878 reg
= e2
.X_add_number
- REG_GR
;
3879 if (e2
.X_op
!= O_register
|| reg
> 127)
3881 as_bad ("Second operand to .save.b must be a general register.");
3884 add_unwind_entry (output_br_gr (brmask
, e2
.X_add_number
));
3887 add_unwind_entry (output_br_mem (brmask
));
3889 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3890 demand_empty_rest_of_line ();
3895 int dummy ATTRIBUTE_UNUSED
;
3900 if (!in_prologue ("save.gf"))
3903 sep
= parse_operand (&e1
);
3905 parse_operand (&e2
);
3907 if (e1
.X_op
!= O_constant
|| sep
!= ',' || e2
.X_op
!= O_constant
)
3908 as_bad ("Both operands of .save.gf must be constants.");
3911 int grmask
= e1
.X_add_number
;
3912 int frmask
= e2
.X_add_number
;
3913 add_unwind_entry (output_frgr_mem (grmask
, frmask
));
3919 int dummy ATTRIBUTE_UNUSED
;
3924 if (!in_prologue ("spill"))
3927 sep
= parse_operand (&e
);
3928 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3929 demand_empty_rest_of_line ();
3931 if (e
.X_op
!= O_constant
)
3932 as_bad ("Operand to .spill must be a constant");
3934 add_unwind_entry (output_spill_base (e
.X_add_number
));
3938 dot_spillreg (dummy
)
3939 int dummy ATTRIBUTE_UNUSED
;
3942 unsigned int ab
, xy
, reg
, treg
;
3945 if (!in_procedure ("spillreg"))
3948 sep
= parse_operand (&e1
);
3951 as_bad ("No second operand to .spillreg");
3955 parse_operand (&e2
);
3957 if (!convert_expr_to_ab_reg (&e1
, &ab
, ®
))
3959 as_bad ("First operand to .spillreg must be a preserved register");
3963 if (!convert_expr_to_xy_reg (&e2
, &xy
, &treg
))
3965 as_bad ("Second operand to .spillreg must be a register");
3969 add_unwind_entry (output_spill_reg (ab
, reg
, treg
, xy
));
3973 dot_spillmem (psprel
)
3978 unsigned int ab
, reg
;
3980 if (!in_procedure ("spillmem"))
3983 sep
= parse_operand (&e1
);
3986 as_bad ("Second operand missing");
3990 parse_operand (&e2
);
3992 if (!convert_expr_to_ab_reg (&e1
, &ab
, ®
))
3994 as_bad ("First operand to .spill%s must be a preserved register",
3995 psprel
? "psp" : "sp");
3999 if (e2
.X_op
!= O_constant
)
4001 as_bad ("Second operand to .spill%s must be a constant",
4002 psprel
? "psp" : "sp");
4007 add_unwind_entry (output_spill_psprel (ab
, reg
, e2
.X_add_number
));
4009 add_unwind_entry (output_spill_sprel (ab
, reg
, e2
.X_add_number
));
4013 dot_spillreg_p (dummy
)
4014 int dummy ATTRIBUTE_UNUSED
;
4017 unsigned int ab
, xy
, reg
, treg
;
4018 expressionS e1
, e2
, e3
;
4021 if (!in_procedure ("spillreg.p"))
4024 sep
= parse_operand (&e1
);
4027 as_bad ("No second and third operand to .spillreg.p");
4031 sep
= parse_operand (&e2
);
4034 as_bad ("No third operand to .spillreg.p");
4038 parse_operand (&e3
);
4040 qp
= e1
.X_add_number
- REG_P
;
4042 if (e1
.X_op
!= O_register
|| qp
> 63)
4044 as_bad ("First operand to .spillreg.p must be a predicate");
4048 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
4050 as_bad ("Second operand to .spillreg.p must be a preserved register");
4054 if (!convert_expr_to_xy_reg (&e3
, &xy
, &treg
))
4056 as_bad ("Third operand to .spillreg.p must be a register");
4060 add_unwind_entry (output_spill_reg_p (ab
, reg
, treg
, xy
, qp
));
4064 dot_spillmem_p (psprel
)
4067 expressionS e1
, e2
, e3
;
4069 unsigned int ab
, reg
;
4072 if (!in_procedure ("spillmem.p"))
4075 sep
= parse_operand (&e1
);
4078 as_bad ("Second operand missing");
4082 parse_operand (&e2
);
4085 as_bad ("Second operand missing");
4089 parse_operand (&e3
);
4091 qp
= e1
.X_add_number
- REG_P
;
4092 if (e1
.X_op
!= O_register
|| qp
> 63)
4094 as_bad ("First operand to .spill%s_p must be a predicate",
4095 psprel
? "psp" : "sp");
4099 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
4101 as_bad ("Second operand to .spill%s_p must be a preserved register",
4102 psprel
? "psp" : "sp");
4106 if (e3
.X_op
!= O_constant
)
4108 as_bad ("Third operand to .spill%s_p must be a constant",
4109 psprel
? "psp" : "sp");
4114 add_unwind_entry (output_spill_psprel_p (ab
, reg
, e3
.X_add_number
, qp
));
4116 add_unwind_entry (output_spill_sprel_p (ab
, reg
, e3
.X_add_number
, qp
));
4120 get_saved_prologue_count (lbl
)
4123 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
4125 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
4129 return lpc
->prologue_count
;
4131 as_bad ("Missing .label_state %ld", lbl
);
4136 save_prologue_count (lbl
, count
)
4140 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
4142 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
4146 lpc
->prologue_count
= count
;
4149 label_prologue_count
*new_lpc
= xmalloc (sizeof (* new_lpc
));
4151 new_lpc
->next
= unwind
.saved_prologue_counts
;
4152 new_lpc
->label_number
= lbl
;
4153 new_lpc
->prologue_count
= count
;
4154 unwind
.saved_prologue_counts
= new_lpc
;
4159 free_saved_prologue_counts ()
4161 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
4162 label_prologue_count
*next
;
4171 unwind
.saved_prologue_counts
= NULL
;
4175 dot_label_state (dummy
)
4176 int dummy ATTRIBUTE_UNUSED
;
4180 if (!in_body ("label_state"))
4184 if (e
.X_op
!= O_constant
)
4186 as_bad ("Operand to .label_state must be a constant");
4189 add_unwind_entry (output_label_state (e
.X_add_number
));
4190 save_prologue_count (e
.X_add_number
, unwind
.prologue_count
);
4194 dot_copy_state (dummy
)
4195 int dummy ATTRIBUTE_UNUSED
;
4199 if (!in_body ("copy_state"))
4203 if (e
.X_op
!= O_constant
)
4205 as_bad ("Operand to .copy_state must be a constant");
4208 add_unwind_entry (output_copy_state (e
.X_add_number
));
4209 unwind
.prologue_count
= get_saved_prologue_count (e
.X_add_number
);
4214 int dummy ATTRIBUTE_UNUSED
;
4219 if (!in_procedure ("unwabi"))
4222 sep
= parse_operand (&e1
);
4225 as_bad ("Second operand to .unwabi missing");
4228 sep
= parse_operand (&e2
);
4229 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
4230 demand_empty_rest_of_line ();
4232 if (e1
.X_op
!= O_constant
)
4234 as_bad ("First operand to .unwabi must be a constant");
4238 if (e2
.X_op
!= O_constant
)
4240 as_bad ("Second operand to .unwabi must be a constant");
4244 add_unwind_entry (output_unwabi (e1
.X_add_number
, e2
.X_add_number
));
4248 dot_personality (dummy
)
4249 int dummy ATTRIBUTE_UNUSED
;
4252 if (!in_procedure ("personality"))
4255 name
= input_line_pointer
;
4256 c
= get_symbol_end ();
4257 p
= input_line_pointer
;
4258 unwind
.personality_routine
= symbol_find_or_make (name
);
4259 unwind
.force_unwind_entry
= 1;
4262 demand_empty_rest_of_line ();
4267 int dummy ATTRIBUTE_UNUSED
;
4272 unwind
.proc_start
= 0;
4273 /* Parse names of main and alternate entry points and mark them as
4274 function symbols: */
4278 name
= input_line_pointer
;
4279 c
= get_symbol_end ();
4280 p
= input_line_pointer
;
4282 as_bad ("Empty argument of .proc");
4285 sym
= symbol_find_or_make (name
);
4286 if (S_IS_DEFINED (sym
))
4287 as_bad ("`%s' was already defined", name
);
4288 else if (unwind
.proc_start
== 0)
4290 unwind
.proc_start
= sym
;
4292 symbol_get_bfdsym (sym
)->flags
|= BSF_FUNCTION
;
4296 if (*input_line_pointer
!= ',')
4298 ++input_line_pointer
;
4300 if (unwind
.proc_start
== 0)
4301 unwind
.proc_start
= expr_build_dot ();
4302 demand_empty_rest_of_line ();
4305 unwind
.prologue
= 0;
4306 unwind
.prologue_count
= 0;
4309 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
4310 unwind
.personality_routine
= 0;
4315 int dummy ATTRIBUTE_UNUSED
;
4317 if (!in_procedure ("body"))
4319 if (!unwind
.prologue
&& !unwind
.body
&& unwind
.insn
)
4320 as_warn ("Initial .body should precede any instructions");
4322 unwind
.prologue
= 0;
4323 unwind
.prologue_mask
= 0;
4326 add_unwind_entry (output_body ());
4327 demand_empty_rest_of_line ();
4331 dot_prologue (dummy
)
4332 int dummy ATTRIBUTE_UNUSED
;
4335 int mask
= 0, grsave
= 0;
4337 if (!in_procedure ("prologue"))
4339 if (unwind
.prologue
)
4341 as_bad (".prologue within prologue");
4342 ignore_rest_of_line ();
4345 if (!unwind
.body
&& unwind
.insn
)
4346 as_warn ("Initial .prologue should precede any instructions");
4348 if (!is_it_end_of_statement ())
4351 sep
= parse_operand (&e1
);
4353 as_bad ("No second operand to .prologue");
4354 sep
= parse_operand (&e2
);
4355 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
4356 demand_empty_rest_of_line ();
4358 if (e1
.X_op
== O_constant
)
4360 mask
= e1
.X_add_number
;
4362 if (e2
.X_op
== O_constant
)
4363 grsave
= e2
.X_add_number
;
4364 else if (e2
.X_op
== O_register
4365 && (grsave
= e2
.X_add_number
- REG_GR
) < 128)
4368 as_bad ("Second operand not a constant or general register");
4370 add_unwind_entry (output_prologue_gr (mask
, grsave
));
4373 as_bad ("First operand not a constant");
4376 add_unwind_entry (output_prologue ());
4378 unwind
.prologue
= 1;
4379 unwind
.prologue_mask
= mask
;
4381 ++unwind
.prologue_count
;
4386 int dummy ATTRIBUTE_UNUSED
;
4389 int bytes_per_address
;
4392 subsegT saved_subseg
;
4393 char *name
, *default_name
, *p
, c
;
4395 int unwind_check
= md
.unwind_check
;
4397 md
.unwind_check
= unwind_check_error
;
4398 if (!in_procedure ("endp"))
4400 md
.unwind_check
= unwind_check
;
4402 if (unwind
.saved_text_seg
)
4404 saved_seg
= unwind
.saved_text_seg
;
4405 saved_subseg
= unwind
.saved_text_subseg
;
4406 unwind
.saved_text_seg
= NULL
;
4410 saved_seg
= now_seg
;
4411 saved_subseg
= now_subseg
;
4414 insn_group_break (1, 0, 0);
4416 /* If there wasn't a .handlerdata, we haven't generated an image yet. */
4418 generate_unwind_image (saved_seg
);
4420 if (unwind
.info
|| unwind
.force_unwind_entry
)
4424 subseg_set (md
.last_text_seg
, 0);
4425 proc_end
= expr_build_dot ();
4427 start_unwind_section (saved_seg
, SPECIAL_SECTION_UNWIND
);
4429 /* Make sure that section has 4 byte alignment for ILP32 and
4430 8 byte alignment for LP64. */
4431 record_alignment (now_seg
, md
.pointer_size_shift
);
4433 /* Need space for 3 pointers for procedure start, procedure end,
4435 memset (frag_more (3 * md
.pointer_size
), 0, 3 * md
.pointer_size
);
4436 where
= frag_now_fix () - (3 * md
.pointer_size
);
4437 bytes_per_address
= bfd_arch_bits_per_address (stdoutput
) / 8;
4439 /* Issue the values of a) Proc Begin, b) Proc End, c) Unwind Record. */
4440 e
.X_op
= O_pseudo_fixup
;
4441 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4443 if (!S_IS_LOCAL (unwind
.proc_start
)
4444 && S_IS_DEFINED (unwind
.proc_start
))
4445 e
.X_add_symbol
= symbol_temp_new (S_GET_SEGMENT (unwind
.proc_start
),
4446 S_GET_VALUE (unwind
.proc_start
),
4447 symbol_get_frag (unwind
.proc_start
));
4449 e
.X_add_symbol
= unwind
.proc_start
;
4450 ia64_cons_fix_new (frag_now
, where
, bytes_per_address
, &e
);
4452 e
.X_op
= O_pseudo_fixup
;
4453 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4455 e
.X_add_symbol
= proc_end
;
4456 ia64_cons_fix_new (frag_now
, where
+ bytes_per_address
,
4457 bytes_per_address
, &e
);
4461 e
.X_op
= O_pseudo_fixup
;
4462 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4464 e
.X_add_symbol
= unwind
.info
;
4465 ia64_cons_fix_new (frag_now
, where
+ (bytes_per_address
* 2),
4466 bytes_per_address
, &e
);
4469 subseg_set (saved_seg
, saved_subseg
);
4471 if (unwind
.proc_start
)
4472 default_name
= (char *) S_GET_NAME (unwind
.proc_start
);
4474 default_name
= NULL
;
4476 /* Parse names of main and alternate entry points and set symbol sizes. */
4480 name
= input_line_pointer
;
4481 c
= get_symbol_end ();
4482 p
= input_line_pointer
;
4485 if (md
.unwind_check
== unwind_check_warning
)
4489 as_warn ("Empty argument of .endp. Use the default name `%s'",
4491 name
= default_name
;
4494 as_warn ("Empty argument of .endp");
4497 as_bad ("Empty argument of .endp");
4501 sym
= symbol_find (name
);
4503 && md
.unwind_check
== unwind_check_warning
4505 && default_name
!= name
)
4507 /* We have a bad name. Try the default one if needed. */
4508 as_warn ("`%s' was not defined within procedure. Use the default name `%s'",
4509 name
, default_name
);
4510 name
= default_name
;
4511 sym
= symbol_find (name
);
4513 if (!sym
|| !S_IS_DEFINED (sym
))
4514 as_bad ("`%s' was not defined within procedure", name
);
4515 else if (unwind
.proc_start
4516 && (symbol_get_bfdsym (sym
)->flags
& BSF_FUNCTION
)
4517 && S_GET_SIZE (sym
) == 0 && symbol_get_obj (sym
)->size
== NULL
)
4519 fragS
*fr
= symbol_get_frag (unwind
.proc_start
);
4520 fragS
*frag
= symbol_get_frag (sym
);
4522 /* Check whether the function label is at or beyond last
4524 while (fr
&& fr
!= frag
)
4528 if (frag
== frag_now
&& SEG_NORMAL (now_seg
))
4529 S_SET_SIZE (sym
, frag_now_fix () - S_GET_VALUE (sym
));
4532 symbol_get_obj (sym
)->size
=
4533 (expressionS
*) xmalloc (sizeof (expressionS
));
4534 symbol_get_obj (sym
)->size
->X_op
= O_subtract
;
4535 symbol_get_obj (sym
)->size
->X_add_symbol
4536 = symbol_new (FAKE_LABEL_NAME
, now_seg
,
4537 frag_now_fix (), frag_now
);
4538 symbol_get_obj (sym
)->size
->X_op_symbol
= sym
;
4539 symbol_get_obj (sym
)->size
->X_add_number
= 0;
4546 if (*input_line_pointer
!= ',')
4548 ++input_line_pointer
;
4550 demand_empty_rest_of_line ();
4551 unwind
.proc_start
= unwind
.info
= 0;
4555 dot_template (template)
4558 CURR_SLOT
.user_template
= template;
4563 int dummy ATTRIBUTE_UNUSED
;
4565 int ins
, locs
, outs
, rots
;
4567 if (is_it_end_of_statement ())
4568 ins
= locs
= outs
= rots
= 0;
4571 ins
= get_absolute_expression ();
4572 if (*input_line_pointer
++ != ',')
4574 locs
= get_absolute_expression ();
4575 if (*input_line_pointer
++ != ',')
4577 outs
= get_absolute_expression ();
4578 if (*input_line_pointer
++ != ',')
4580 rots
= get_absolute_expression ();
4582 set_regstack (ins
, locs
, outs
, rots
);
4586 as_bad ("Comma expected");
4587 ignore_rest_of_line ();
4594 unsigned num_regs
, num_alloced
= 0;
4595 struct dynreg
**drpp
, *dr
;
4596 int ch
, base_reg
= 0;
4602 case DYNREG_GR
: base_reg
= REG_GR
+ 32; break;
4603 case DYNREG_FR
: base_reg
= REG_FR
+ 32; break;
4604 case DYNREG_PR
: base_reg
= REG_P
+ 16; break;
4608 /* First, remove existing names from hash table. */
4609 for (dr
= md
.dynreg
[type
]; dr
&& dr
->num_regs
; dr
= dr
->next
)
4611 hash_delete (md
.dynreg_hash
, dr
->name
);
4612 /* FIXME: Free dr->name. */
4616 drpp
= &md
.dynreg
[type
];
4619 start
= input_line_pointer
;
4620 ch
= get_symbol_end ();
4621 len
= strlen (ia64_canonicalize_symbol_name (start
));
4622 *input_line_pointer
= ch
;
4625 if (*input_line_pointer
!= '[')
4627 as_bad ("Expected '['");
4630 ++input_line_pointer
; /* skip '[' */
4632 num_regs
= get_absolute_expression ();
4634 if (*input_line_pointer
++ != ']')
4636 as_bad ("Expected ']'");
4641 num_alloced
+= num_regs
;
4645 if (num_alloced
> md
.rot
.num_regs
)
4647 as_bad ("Used more than the declared %d rotating registers",
4653 if (num_alloced
> 96)
4655 as_bad ("Used more than the available 96 rotating registers");
4660 if (num_alloced
> 48)
4662 as_bad ("Used more than the available 48 rotating registers");
4673 *drpp
= obstack_alloc (¬es
, sizeof (*dr
));
4674 memset (*drpp
, 0, sizeof (*dr
));
4677 name
= obstack_alloc (¬es
, len
+ 1);
4678 memcpy (name
, start
, len
);
4683 dr
->num_regs
= num_regs
;
4684 dr
->base
= base_reg
;
4686 base_reg
+= num_regs
;
4688 if (hash_insert (md
.dynreg_hash
, name
, dr
))
4690 as_bad ("Attempt to redefine register set `%s'", name
);
4691 obstack_free (¬es
, name
);
4695 if (*input_line_pointer
!= ',')
4697 ++input_line_pointer
; /* skip comma */
4700 demand_empty_rest_of_line ();
4704 ignore_rest_of_line ();
4708 dot_byteorder (byteorder
)
4711 segment_info_type
*seginfo
= seg_info (now_seg
);
4713 if (byteorder
== -1)
4715 if (seginfo
->tc_segment_info_data
.endian
== 0)
4716 seginfo
->tc_segment_info_data
.endian
= default_big_endian
? 1 : 2;
4717 byteorder
= seginfo
->tc_segment_info_data
.endian
== 1;
4720 seginfo
->tc_segment_info_data
.endian
= byteorder
? 1 : 2;
4722 if (target_big_endian
!= byteorder
)
4724 target_big_endian
= byteorder
;
4725 if (target_big_endian
)
4727 ia64_number_to_chars
= number_to_chars_bigendian
;
4728 ia64_float_to_chars
= ia64_float_to_chars_bigendian
;
4732 ia64_number_to_chars
= number_to_chars_littleendian
;
4733 ia64_float_to_chars
= ia64_float_to_chars_littleendian
;
4740 int dummy ATTRIBUTE_UNUSED
;
4747 option
= input_line_pointer
;
4748 ch
= get_symbol_end ();
4749 if (strcmp (option
, "lsb") == 0)
4750 md
.flags
&= ~EF_IA_64_BE
;
4751 else if (strcmp (option
, "msb") == 0)
4752 md
.flags
|= EF_IA_64_BE
;
4753 else if (strcmp (option
, "abi32") == 0)
4754 md
.flags
&= ~EF_IA_64_ABI64
;
4755 else if (strcmp (option
, "abi64") == 0)
4756 md
.flags
|= EF_IA_64_ABI64
;
4758 as_bad ("Unknown psr option `%s'", option
);
4759 *input_line_pointer
= ch
;
4762 if (*input_line_pointer
!= ',')
4765 ++input_line_pointer
;
4768 demand_empty_rest_of_line ();
4773 int dummy ATTRIBUTE_UNUSED
;
4775 new_logical_line (0, get_absolute_expression ());
4776 demand_empty_rest_of_line ();
4780 cross_section (ref
, cons
, ua
)
4782 void (*cons
) PARAMS((int));
4786 int saved_auto_align
;
4787 unsigned int section_count
;
4790 start
= input_line_pointer
;
4796 name
= demand_copy_C_string (&len
);
4797 obstack_free(¬es
, name
);
4800 ignore_rest_of_line ();
4806 char c
= get_symbol_end ();
4808 if (input_line_pointer
== start
)
4810 as_bad ("Missing section name");
4811 ignore_rest_of_line ();
4814 *input_line_pointer
= c
;
4816 end
= input_line_pointer
;
4818 if (*input_line_pointer
!= ',')
4820 as_bad ("Comma expected after section name");
4821 ignore_rest_of_line ();
4825 end
= input_line_pointer
+ 1; /* skip comma */
4826 input_line_pointer
= start
;
4827 md
.keep_pending_output
= 1;
4828 section_count
= bfd_count_sections(stdoutput
);
4829 obj_elf_section (0);
4830 if (section_count
!= bfd_count_sections(stdoutput
))
4831 as_warn ("Creating sections with .xdataN/.xrealN/.xstringZ is deprecated.");
4832 input_line_pointer
= end
;
4833 saved_auto_align
= md
.auto_align
;
4838 md
.auto_align
= saved_auto_align
;
4839 obj_elf_previous (0);
4840 md
.keep_pending_output
= 0;
4847 cross_section (size
, cons
, 0);
4850 /* Why doesn't float_cons() call md_cons_align() the way cons() does? */
4853 stmt_float_cons (kind
)
4874 ia64_do_align (alignment
);
4882 int saved_auto_align
= md
.auto_align
;
4886 md
.auto_align
= saved_auto_align
;
4890 dot_xfloat_cons (kind
)
4893 cross_section (kind
, stmt_float_cons
, 0);
4897 dot_xstringer (zero
)
4900 cross_section (zero
, stringer
, 0);
4907 cross_section (size
, cons
, 1);
4911 dot_xfloat_cons_ua (kind
)
4914 cross_section (kind
, float_cons
, 1);
4917 /* .reg.val <regname>,value */
4921 int dummy ATTRIBUTE_UNUSED
;
4926 if (reg
.X_op
!= O_register
)
4928 as_bad (_("Register name expected"));
4929 ignore_rest_of_line ();
4931 else if (*input_line_pointer
++ != ',')
4933 as_bad (_("Comma expected"));
4934 ignore_rest_of_line ();
4938 valueT value
= get_absolute_expression ();
4939 int regno
= reg
.X_add_number
;
4940 if (regno
<= REG_GR
|| regno
> REG_GR
+ 127)
4941 as_warn (_("Register value annotation ignored"));
4944 gr_values
[regno
- REG_GR
].known
= 1;
4945 gr_values
[regno
- REG_GR
].value
= value
;
4946 gr_values
[regno
- REG_GR
].path
= md
.path
;
4949 demand_empty_rest_of_line ();
4954 .serialize.instruction
4957 dot_serialize (type
)
4960 insn_group_break (0, 0, 0);
4962 instruction_serialization ();
4964 data_serialization ();
4965 insn_group_break (0, 0, 0);
4966 demand_empty_rest_of_line ();
4969 /* select dv checking mode
4974 A stop is inserted when changing modes
4981 if (md
.manual_bundling
)
4982 as_warn (_("Directive invalid within a bundle"));
4984 if (type
== 'E' || type
== 'A')
4985 md
.mode_explicitly_set
= 0;
4987 md
.mode_explicitly_set
= 1;
4994 if (md
.explicit_mode
)
4995 insn_group_break (1, 0, 0);
4996 md
.explicit_mode
= 0;
5000 if (!md
.explicit_mode
)
5001 insn_group_break (1, 0, 0);
5002 md
.explicit_mode
= 1;
5006 if (md
.explicit_mode
!= md
.default_explicit_mode
)
5007 insn_group_break (1, 0, 0);
5008 md
.explicit_mode
= md
.default_explicit_mode
;
5009 md
.mode_explicitly_set
= 0;
5020 for (regno
= 0; regno
< 64; regno
++)
5022 if (mask
& ((valueT
) 1 << regno
))
5024 fprintf (stderr
, "%s p%d", comma
, regno
);
5031 .pred.rel.clear [p1 [,p2 [,...]]] (also .pred.rel "clear" or @clear)
5032 .pred.rel.imply p1, p2 (also .pred.rel "imply" or @imply)
5033 .pred.rel.mutex p1, p2 [,...] (also .pred.rel "mutex" or @mutex)
5034 .pred.safe_across_calls p1 [, p2 [,...]]
5043 int p1
= -1, p2
= -1;
5047 if (*input_line_pointer
== '"')
5050 char *form
= demand_copy_C_string (&len
);
5052 if (strcmp (form
, "mutex") == 0)
5054 else if (strcmp (form
, "clear") == 0)
5056 else if (strcmp (form
, "imply") == 0)
5058 obstack_free (¬es
, form
);
5060 else if (*input_line_pointer
== '@')
5062 char *form
= ++input_line_pointer
;
5063 char c
= get_symbol_end();
5065 if (strcmp (form
, "mutex") == 0)
5067 else if (strcmp (form
, "clear") == 0)
5069 else if (strcmp (form
, "imply") == 0)
5071 *input_line_pointer
= c
;
5075 as_bad (_("Missing predicate relation type"));
5076 ignore_rest_of_line ();
5081 as_bad (_("Unrecognized predicate relation type"));
5082 ignore_rest_of_line ();
5085 if (*input_line_pointer
== ',')
5086 ++input_line_pointer
;
5095 expressionS pr
, *pr1
, *pr2
;
5098 if (pr
.X_op
== O_register
5099 && pr
.X_add_number
>= REG_P
5100 && pr
.X_add_number
<= REG_P
+ 63)
5102 regno
= pr
.X_add_number
- REG_P
;
5110 else if (type
!= 'i'
5111 && pr
.X_op
== O_subtract
5112 && (pr1
= symbol_get_value_expression (pr
.X_add_symbol
))
5113 && pr1
->X_op
== O_register
5114 && pr1
->X_add_number
>= REG_P
5115 && pr1
->X_add_number
<= REG_P
+ 63
5116 && (pr2
= symbol_get_value_expression (pr
.X_op_symbol
))
5117 && pr2
->X_op
== O_register
5118 && pr2
->X_add_number
>= REG_P
5119 && pr2
->X_add_number
<= REG_P
+ 63)
5124 regno
= pr1
->X_add_number
- REG_P
;
5125 stop
= pr2
->X_add_number
- REG_P
;
5128 as_bad (_("Bad register range"));
5129 ignore_rest_of_line ();
5132 bits
= ((bits
<< stop
) << 1) - (bits
<< regno
);
5133 count
+= stop
- regno
+ 1;
5137 as_bad (_("Predicate register expected"));
5138 ignore_rest_of_line ();
5142 as_warn (_("Duplicate predicate register ignored"));
5144 if (*input_line_pointer
!= ',')
5146 ++input_line_pointer
;
5155 clear_qp_mutex (mask
);
5156 clear_qp_implies (mask
, (valueT
) 0);
5159 if (count
!= 2 || p1
== -1 || p2
== -1)
5160 as_bad (_("Predicate source and target required"));
5161 else if (p1
== 0 || p2
== 0)
5162 as_bad (_("Use of p0 is not valid in this context"));
5164 add_qp_imply (p1
, p2
);
5169 as_bad (_("At least two PR arguments expected"));
5174 as_bad (_("Use of p0 is not valid in this context"));
5177 add_qp_mutex (mask
);
5180 /* note that we don't override any existing relations */
5183 as_bad (_("At least one PR argument expected"));
5188 fprintf (stderr
, "Safe across calls: ");
5189 print_prmask (mask
);
5190 fprintf (stderr
, "\n");
5192 qp_safe_across_calls
= mask
;
5195 demand_empty_rest_of_line ();
5198 /* .entry label [, label [, ...]]
5199 Hint to DV code that the given labels are to be considered entry points.
5200 Otherwise, only global labels are considered entry points. */
5204 int dummy ATTRIBUTE_UNUSED
;
5213 name
= input_line_pointer
;
5214 c
= get_symbol_end ();
5215 symbolP
= symbol_find_or_make (name
);
5217 err
= hash_insert (md
.entry_hash
, S_GET_NAME (symbolP
), (PTR
) symbolP
);
5219 as_fatal (_("Inserting \"%s\" into entry hint table failed: %s"),
5222 *input_line_pointer
= c
;
5224 c
= *input_line_pointer
;
5227 input_line_pointer
++;
5229 if (*input_line_pointer
== '\n')
5235 demand_empty_rest_of_line ();
5238 /* .mem.offset offset, base
5239 "base" is used to distinguish between offsets from a different base. */
5242 dot_mem_offset (dummy
)
5243 int dummy ATTRIBUTE_UNUSED
;
5245 md
.mem_offset
.hint
= 1;
5246 md
.mem_offset
.offset
= get_absolute_expression ();
5247 if (*input_line_pointer
!= ',')
5249 as_bad (_("Comma expected"));
5250 ignore_rest_of_line ();
5253 ++input_line_pointer
;
5254 md
.mem_offset
.base
= get_absolute_expression ();
5255 demand_empty_rest_of_line ();
5258 /* ia64-specific pseudo-ops: */
5259 const pseudo_typeS md_pseudo_table
[] =
5261 { "radix", dot_radix
, 0 },
5262 { "lcomm", s_lcomm_bytes
, 1 },
5263 { "loc", dot_loc
, 0 },
5264 { "bss", dot_special_section
, SPECIAL_SECTION_BSS
},
5265 { "sbss", dot_special_section
, SPECIAL_SECTION_SBSS
},
5266 { "sdata", dot_special_section
, SPECIAL_SECTION_SDATA
},
5267 { "rodata", dot_special_section
, SPECIAL_SECTION_RODATA
},
5268 { "comment", dot_special_section
, SPECIAL_SECTION_COMMENT
},
5269 { "ia_64.unwind", dot_special_section
, SPECIAL_SECTION_UNWIND
},
5270 { "ia_64.unwind_info", dot_special_section
, SPECIAL_SECTION_UNWIND_INFO
},
5271 { "init_array", dot_special_section
, SPECIAL_SECTION_INIT_ARRAY
},
5272 { "fini_array", dot_special_section
, SPECIAL_SECTION_FINI_ARRAY
},
5273 { "proc", dot_proc
, 0 },
5274 { "body", dot_body
, 0 },
5275 { "prologue", dot_prologue
, 0 },
5276 { "endp", dot_endp
, 0 },
5278 { "fframe", dot_fframe
, 0 },
5279 { "vframe", dot_vframe
, 0 },
5280 { "vframesp", dot_vframesp
, 0 },
5281 { "vframepsp", dot_vframepsp
, 0 },
5282 { "save", dot_save
, 0 },
5283 { "restore", dot_restore
, 0 },
5284 { "restorereg", dot_restorereg
, 0 },
5285 { "restorereg.p", dot_restorereg_p
, 0 },
5286 { "handlerdata", dot_handlerdata
, 0 },
5287 { "unwentry", dot_unwentry
, 0 },
5288 { "altrp", dot_altrp
, 0 },
5289 { "savesp", dot_savemem
, 0 },
5290 { "savepsp", dot_savemem
, 1 },
5291 { "save.g", dot_saveg
, 0 },
5292 { "save.f", dot_savef
, 0 },
5293 { "save.b", dot_saveb
, 0 },
5294 { "save.gf", dot_savegf
, 0 },
5295 { "spill", dot_spill
, 0 },
5296 { "spillreg", dot_spillreg
, 0 },
5297 { "spillsp", dot_spillmem
, 0 },
5298 { "spillpsp", dot_spillmem
, 1 },
5299 { "spillreg.p", dot_spillreg_p
, 0 },
5300 { "spillsp.p", dot_spillmem_p
, 0 },
5301 { "spillpsp.p", dot_spillmem_p
, 1 },
5302 { "label_state", dot_label_state
, 0 },
5303 { "copy_state", dot_copy_state
, 0 },
5304 { "unwabi", dot_unwabi
, 0 },
5305 { "personality", dot_personality
, 0 },
5306 { "mii", dot_template
, 0x0 },
5307 { "mli", dot_template
, 0x2 }, /* old format, for compatibility */
5308 { "mlx", dot_template
, 0x2 },
5309 { "mmi", dot_template
, 0x4 },
5310 { "mfi", dot_template
, 0x6 },
5311 { "mmf", dot_template
, 0x7 },
5312 { "mib", dot_template
, 0x8 },
5313 { "mbb", dot_template
, 0x9 },
5314 { "bbb", dot_template
, 0xb },
5315 { "mmb", dot_template
, 0xc },
5316 { "mfb", dot_template
, 0xe },
5317 { "align", dot_align
, 0 },
5318 { "regstk", dot_regstk
, 0 },
5319 { "rotr", dot_rot
, DYNREG_GR
},
5320 { "rotf", dot_rot
, DYNREG_FR
},
5321 { "rotp", dot_rot
, DYNREG_PR
},
5322 { "lsb", dot_byteorder
, 0 },
5323 { "msb", dot_byteorder
, 1 },
5324 { "psr", dot_psr
, 0 },
5325 { "alias", dot_alias
, 0 },
5326 { "secalias", dot_alias
, 1 },
5327 { "ln", dot_ln
, 0 }, /* source line info (for debugging) */
5329 { "xdata1", dot_xdata
, 1 },
5330 { "xdata2", dot_xdata
, 2 },
5331 { "xdata4", dot_xdata
, 4 },
5332 { "xdata8", dot_xdata
, 8 },
5333 { "xdata16", dot_xdata
, 16 },
5334 { "xreal4", dot_xfloat_cons
, 'f' },
5335 { "xreal8", dot_xfloat_cons
, 'd' },
5336 { "xreal10", dot_xfloat_cons
, 'x' },
5337 { "xreal16", dot_xfloat_cons
, 'X' },
5338 { "xstring", dot_xstringer
, 0 },
5339 { "xstringz", dot_xstringer
, 1 },
5341 /* unaligned versions: */
5342 { "xdata2.ua", dot_xdata_ua
, 2 },
5343 { "xdata4.ua", dot_xdata_ua
, 4 },
5344 { "xdata8.ua", dot_xdata_ua
, 8 },
5345 { "xdata16.ua", dot_xdata_ua
, 16 },
5346 { "xreal4.ua", dot_xfloat_cons_ua
, 'f' },
5347 { "xreal8.ua", dot_xfloat_cons_ua
, 'd' },
5348 { "xreal10.ua", dot_xfloat_cons_ua
, 'x' },
5349 { "xreal16.ua", dot_xfloat_cons_ua
, 'X' },
5351 /* annotations/DV checking support */
5352 { "entry", dot_entry
, 0 },
5353 { "mem.offset", dot_mem_offset
, 0 },
5354 { "pred.rel", dot_pred_rel
, 0 },
5355 { "pred.rel.clear", dot_pred_rel
, 'c' },
5356 { "pred.rel.imply", dot_pred_rel
, 'i' },
5357 { "pred.rel.mutex", dot_pred_rel
, 'm' },
5358 { "pred.safe_across_calls", dot_pred_rel
, 's' },
5359 { "reg.val", dot_reg_val
, 0 },
5360 { "serialize.data", dot_serialize
, 0 },
5361 { "serialize.instruction", dot_serialize
, 1 },
5362 { "auto", dot_dv_mode
, 'a' },
5363 { "explicit", dot_dv_mode
, 'e' },
5364 { "default", dot_dv_mode
, 'd' },
5366 /* ??? These are needed to make gas/testsuite/gas/elf/ehopt.s work.
5367 IA-64 aligns data allocation pseudo-ops by default, so we have to
5368 tell it that these ones are supposed to be unaligned. Long term,
5369 should rewrite so that only IA-64 specific data allocation pseudo-ops
5370 are aligned by default. */
5371 {"2byte", stmt_cons_ua
, 2},
5372 {"4byte", stmt_cons_ua
, 4},
5373 {"8byte", stmt_cons_ua
, 8},
5378 static const struct pseudo_opcode
5381 void (*handler
) (int);
5386 /* these are more like pseudo-ops, but don't start with a dot */
5387 { "data1", cons
, 1 },
5388 { "data2", cons
, 2 },
5389 { "data4", cons
, 4 },
5390 { "data8", cons
, 8 },
5391 { "data16", cons
, 16 },
5392 { "real4", stmt_float_cons
, 'f' },
5393 { "real8", stmt_float_cons
, 'd' },
5394 { "real10", stmt_float_cons
, 'x' },
5395 { "real16", stmt_float_cons
, 'X' },
5396 { "string", stringer
, 0 },
5397 { "stringz", stringer
, 1 },
5399 /* unaligned versions: */
5400 { "data2.ua", stmt_cons_ua
, 2 },
5401 { "data4.ua", stmt_cons_ua
, 4 },
5402 { "data8.ua", stmt_cons_ua
, 8 },
5403 { "data16.ua", stmt_cons_ua
, 16 },
5404 { "real4.ua", float_cons
, 'f' },
5405 { "real8.ua", float_cons
, 'd' },
5406 { "real10.ua", float_cons
, 'x' },
5407 { "real16.ua", float_cons
, 'X' },
5410 /* Declare a register by creating a symbol for it and entering it in
5411 the symbol table. */
5414 declare_register (name
, regnum
)
5421 sym
= symbol_new (name
, reg_section
, regnum
, &zero_address_frag
);
5423 err
= hash_insert (md
.reg_hash
, S_GET_NAME (sym
), (PTR
) sym
);
5425 as_fatal ("Inserting \"%s\" into register table failed: %s",
5432 declare_register_set (prefix
, num_regs
, base_regnum
)
5440 for (i
= 0; i
< num_regs
; ++i
)
5442 sprintf (name
, "%s%u", prefix
, i
);
5443 declare_register (name
, base_regnum
+ i
);
5448 operand_width (opnd
)
5449 enum ia64_opnd opnd
;
5451 const struct ia64_operand
*odesc
= &elf64_ia64_operands
[opnd
];
5452 unsigned int bits
= 0;
5456 for (i
= 0; i
< NELEMS (odesc
->field
) && odesc
->field
[i
].bits
; ++i
)
5457 bits
+= odesc
->field
[i
].bits
;
5462 static enum operand_match_result
5463 operand_match (idesc
, index
, e
)
5464 const struct ia64_opcode
*idesc
;
5468 enum ia64_opnd opnd
= idesc
->operands
[index
];
5469 int bits
, relocatable
= 0;
5470 struct insn_fix
*fix
;
5477 case IA64_OPND_AR_CCV
:
5478 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 32)
5479 return OPERAND_MATCH
;
5482 case IA64_OPND_AR_CSD
:
5483 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 25)
5484 return OPERAND_MATCH
;
5487 case IA64_OPND_AR_PFS
:
5488 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 64)
5489 return OPERAND_MATCH
;
5493 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_GR
+ 0)
5494 return OPERAND_MATCH
;
5498 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_IP
)
5499 return OPERAND_MATCH
;
5503 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR
)
5504 return OPERAND_MATCH
;
5507 case IA64_OPND_PR_ROT
:
5508 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR_ROT
)
5509 return OPERAND_MATCH
;
5513 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR
)
5514 return OPERAND_MATCH
;
5517 case IA64_OPND_PSR_L
:
5518 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_L
)
5519 return OPERAND_MATCH
;
5522 case IA64_OPND_PSR_UM
:
5523 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_UM
)
5524 return OPERAND_MATCH
;
5528 if (e
->X_op
== O_constant
)
5530 if (e
->X_add_number
== 1)
5531 return OPERAND_MATCH
;
5533 return OPERAND_OUT_OF_RANGE
;
5538 if (e
->X_op
== O_constant
)
5540 if (e
->X_add_number
== 8)
5541 return OPERAND_MATCH
;
5543 return OPERAND_OUT_OF_RANGE
;
5548 if (e
->X_op
== O_constant
)
5550 if (e
->X_add_number
== 16)
5551 return OPERAND_MATCH
;
5553 return OPERAND_OUT_OF_RANGE
;
5557 /* register operands: */
5560 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_AR
5561 && e
->X_add_number
< REG_AR
+ 128)
5562 return OPERAND_MATCH
;
5567 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_BR
5568 && e
->X_add_number
< REG_BR
+ 8)
5569 return OPERAND_MATCH
;
5573 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_CR
5574 && e
->X_add_number
< REG_CR
+ 128)
5575 return OPERAND_MATCH
;
5582 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_FR
5583 && e
->X_add_number
< REG_FR
+ 128)
5584 return OPERAND_MATCH
;
5589 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_P
5590 && e
->X_add_number
< REG_P
+ 64)
5591 return OPERAND_MATCH
;
5597 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
5598 && e
->X_add_number
< REG_GR
+ 128)
5599 return OPERAND_MATCH
;
5602 case IA64_OPND_R3_2
:
5603 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
)
5605 if (e
->X_add_number
< REG_GR
+ 4)
5606 return OPERAND_MATCH
;
5607 else if (e
->X_add_number
< REG_GR
+ 128)
5608 return OPERAND_OUT_OF_RANGE
;
5612 /* indirect operands: */
5613 case IA64_OPND_CPUID_R3
:
5614 case IA64_OPND_DBR_R3
:
5615 case IA64_OPND_DTR_R3
:
5616 case IA64_OPND_ITR_R3
:
5617 case IA64_OPND_IBR_R3
:
5618 case IA64_OPND_MSR_R3
:
5619 case IA64_OPND_PKR_R3
:
5620 case IA64_OPND_PMC_R3
:
5621 case IA64_OPND_PMD_R3
:
5622 case IA64_OPND_RR_R3
:
5623 if (e
->X_op
== O_index
&& e
->X_op_symbol
5624 && (S_GET_VALUE (e
->X_op_symbol
) - IND_CPUID
5625 == opnd
- IA64_OPND_CPUID_R3
))
5626 return OPERAND_MATCH
;
5630 if (e
->X_op
== O_index
&& !e
->X_op_symbol
)
5631 return OPERAND_MATCH
;
5634 /* immediate operands: */
5635 case IA64_OPND_CNT2a
:
5636 case IA64_OPND_LEN4
:
5637 case IA64_OPND_LEN6
:
5638 bits
= operand_width (idesc
->operands
[index
]);
5639 if (e
->X_op
== O_constant
)
5641 if ((bfd_vma
) (e
->X_add_number
- 1) < ((bfd_vma
) 1 << bits
))
5642 return OPERAND_MATCH
;
5644 return OPERAND_OUT_OF_RANGE
;
5648 case IA64_OPND_CNT2b
:
5649 if (e
->X_op
== O_constant
)
5651 if ((bfd_vma
) (e
->X_add_number
- 1) < 3)
5652 return OPERAND_MATCH
;
5654 return OPERAND_OUT_OF_RANGE
;
5658 case IA64_OPND_CNT2c
:
5659 val
= e
->X_add_number
;
5660 if (e
->X_op
== O_constant
)
5662 if ((val
== 0 || val
== 7 || val
== 15 || val
== 16))
5663 return OPERAND_MATCH
;
5665 return OPERAND_OUT_OF_RANGE
;
5670 /* SOR must be an integer multiple of 8 */
5671 if (e
->X_op
== O_constant
&& e
->X_add_number
& 0x7)
5672 return OPERAND_OUT_OF_RANGE
;
5675 if (e
->X_op
== O_constant
)
5677 if ((bfd_vma
) e
->X_add_number
<= 96)
5678 return OPERAND_MATCH
;
5680 return OPERAND_OUT_OF_RANGE
;
5684 case IA64_OPND_IMMU62
:
5685 if (e
->X_op
== O_constant
)
5687 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 62))
5688 return OPERAND_MATCH
;
5690 return OPERAND_OUT_OF_RANGE
;
5694 /* FIXME -- need 62-bit relocation type */
5695 as_bad (_("62-bit relocation not yet implemented"));
5699 case IA64_OPND_IMMU64
:
5700 if (e
->X_op
== O_symbol
|| e
->X_op
== O_pseudo_fixup
5701 || e
->X_op
== O_subtract
)
5703 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5704 fix
->code
= BFD_RELOC_IA64_IMM64
;
5705 if (e
->X_op
!= O_subtract
)
5707 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5708 if (e
->X_op
== O_pseudo_fixup
)
5712 fix
->opnd
= idesc
->operands
[index
];
5715 ++CURR_SLOT
.num_fixups
;
5716 return OPERAND_MATCH
;
5718 else if (e
->X_op
== O_constant
)
5719 return OPERAND_MATCH
;
5722 case IA64_OPND_CCNT5
:
5723 case IA64_OPND_CNT5
:
5724 case IA64_OPND_CNT6
:
5725 case IA64_OPND_CPOS6a
:
5726 case IA64_OPND_CPOS6b
:
5727 case IA64_OPND_CPOS6c
:
5728 case IA64_OPND_IMMU2
:
5729 case IA64_OPND_IMMU7a
:
5730 case IA64_OPND_IMMU7b
:
5731 case IA64_OPND_IMMU21
:
5732 case IA64_OPND_IMMU24
:
5733 case IA64_OPND_MBTYPE4
:
5734 case IA64_OPND_MHTYPE8
:
5735 case IA64_OPND_POS6
:
5736 bits
= operand_width (idesc
->operands
[index
]);
5737 if (e
->X_op
== O_constant
)
5739 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5740 return OPERAND_MATCH
;
5742 return OPERAND_OUT_OF_RANGE
;
5746 case IA64_OPND_IMMU9
:
5747 bits
= operand_width (idesc
->operands
[index
]);
5748 if (e
->X_op
== O_constant
)
5750 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5752 int lobits
= e
->X_add_number
& 0x3;
5753 if (((bfd_vma
) e
->X_add_number
& 0x3C) != 0 && lobits
== 0)
5754 e
->X_add_number
|= (bfd_vma
) 0x3;
5755 return OPERAND_MATCH
;
5758 return OPERAND_OUT_OF_RANGE
;
5762 case IA64_OPND_IMM44
:
5763 /* least 16 bits must be zero */
5764 if ((e
->X_add_number
& 0xffff) != 0)
5765 /* XXX technically, this is wrong: we should not be issuing warning
5766 messages until we're sure this instruction pattern is going to
5768 as_warn (_("lower 16 bits of mask ignored"));
5770 if (e
->X_op
== O_constant
)
5772 if (((e
->X_add_number
>= 0
5773 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 44))
5774 || (e
->X_add_number
< 0
5775 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 44))))
5778 if (e
->X_add_number
>= 0
5779 && (e
->X_add_number
& ((bfd_vma
) 1 << 43)) != 0)
5781 e
->X_add_number
|= ~(((bfd_vma
) 1 << 44) - 1);
5783 return OPERAND_MATCH
;
5786 return OPERAND_OUT_OF_RANGE
;
5790 case IA64_OPND_IMM17
:
5791 /* bit 0 is a don't care (pr0 is hardwired to 1) */
5792 if (e
->X_op
== O_constant
)
5794 if (((e
->X_add_number
>= 0
5795 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 17))
5796 || (e
->X_add_number
< 0
5797 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 17))))
5800 if (e
->X_add_number
>= 0
5801 && (e
->X_add_number
& ((bfd_vma
) 1 << 16)) != 0)
5803 e
->X_add_number
|= ~(((bfd_vma
) 1 << 17) - 1);
5805 return OPERAND_MATCH
;
5808 return OPERAND_OUT_OF_RANGE
;
5812 case IA64_OPND_IMM14
:
5813 case IA64_OPND_IMM22
:
5815 case IA64_OPND_IMM1
:
5816 case IA64_OPND_IMM8
:
5817 case IA64_OPND_IMM8U4
:
5818 case IA64_OPND_IMM8M1
:
5819 case IA64_OPND_IMM8M1U4
:
5820 case IA64_OPND_IMM8M1U8
:
5821 case IA64_OPND_IMM9a
:
5822 case IA64_OPND_IMM9b
:
5823 bits
= operand_width (idesc
->operands
[index
]);
5824 if (relocatable
&& (e
->X_op
== O_symbol
5825 || e
->X_op
== O_subtract
5826 || e
->X_op
== O_pseudo_fixup
))
5828 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5830 if (idesc
->operands
[index
] == IA64_OPND_IMM14
)
5831 fix
->code
= BFD_RELOC_IA64_IMM14
;
5833 fix
->code
= BFD_RELOC_IA64_IMM22
;
5835 if (e
->X_op
!= O_subtract
)
5837 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5838 if (e
->X_op
== O_pseudo_fixup
)
5842 fix
->opnd
= idesc
->operands
[index
];
5845 ++CURR_SLOT
.num_fixups
;
5846 return OPERAND_MATCH
;
5848 else if (e
->X_op
!= O_constant
5849 && ! (e
->X_op
== O_big
&& opnd
== IA64_OPND_IMM8M1U8
))
5850 return OPERAND_MISMATCH
;
5852 if (opnd
== IA64_OPND_IMM8M1U4
)
5854 /* Zero is not valid for unsigned compares that take an adjusted
5855 constant immediate range. */
5856 if (e
->X_add_number
== 0)
5857 return OPERAND_OUT_OF_RANGE
;
5859 /* Sign-extend 32-bit unsigned numbers, so that the following range
5860 checks will work. */
5861 val
= e
->X_add_number
;
5862 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5863 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5864 val
= ((val
<< 32) >> 32);
5866 /* Check for 0x100000000. This is valid because
5867 0x100000000-1 is the same as ((uint32_t) -1). */
5868 if (val
== ((bfd_signed_vma
) 1 << 32))
5869 return OPERAND_MATCH
;
5873 else if (opnd
== IA64_OPND_IMM8M1U8
)
5875 /* Zero is not valid for unsigned compares that take an adjusted
5876 constant immediate range. */
5877 if (e
->X_add_number
== 0)
5878 return OPERAND_OUT_OF_RANGE
;
5880 /* Check for 0x10000000000000000. */
5881 if (e
->X_op
== O_big
)
5883 if (generic_bignum
[0] == 0
5884 && generic_bignum
[1] == 0
5885 && generic_bignum
[2] == 0
5886 && generic_bignum
[3] == 0
5887 && generic_bignum
[4] == 1)
5888 return OPERAND_MATCH
;
5890 return OPERAND_OUT_OF_RANGE
;
5893 val
= e
->X_add_number
- 1;
5895 else if (opnd
== IA64_OPND_IMM8M1
)
5896 val
= e
->X_add_number
- 1;
5897 else if (opnd
== IA64_OPND_IMM8U4
)
5899 /* Sign-extend 32-bit unsigned numbers, so that the following range
5900 checks will work. */
5901 val
= e
->X_add_number
;
5902 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5903 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5904 val
= ((val
<< 32) >> 32);
5907 val
= e
->X_add_number
;
5909 if ((val
>= 0 && (bfd_vma
) val
< ((bfd_vma
) 1 << (bits
- 1)))
5910 || (val
< 0 && (bfd_vma
) -val
<= ((bfd_vma
) 1 << (bits
- 1))))
5911 return OPERAND_MATCH
;
5913 return OPERAND_OUT_OF_RANGE
;
5915 case IA64_OPND_INC3
:
5916 /* +/- 1, 4, 8, 16 */
5917 val
= e
->X_add_number
;
5920 if (e
->X_op
== O_constant
)
5922 if ((val
== 1 || val
== 4 || val
== 8 || val
== 16))
5923 return OPERAND_MATCH
;
5925 return OPERAND_OUT_OF_RANGE
;
5929 case IA64_OPND_TGT25
:
5930 case IA64_OPND_TGT25b
:
5931 case IA64_OPND_TGT25c
:
5932 case IA64_OPND_TGT64
:
5933 if (e
->X_op
== O_symbol
)
5935 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5936 if (opnd
== IA64_OPND_TGT25
)
5937 fix
->code
= BFD_RELOC_IA64_PCREL21F
;
5938 else if (opnd
== IA64_OPND_TGT25b
)
5939 fix
->code
= BFD_RELOC_IA64_PCREL21M
;
5940 else if (opnd
== IA64_OPND_TGT25c
)
5941 fix
->code
= BFD_RELOC_IA64_PCREL21B
;
5942 else if (opnd
== IA64_OPND_TGT64
)
5943 fix
->code
= BFD_RELOC_IA64_PCREL60B
;
5947 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5948 fix
->opnd
= idesc
->operands
[index
];
5951 ++CURR_SLOT
.num_fixups
;
5952 return OPERAND_MATCH
;
5954 case IA64_OPND_TAG13
:
5955 case IA64_OPND_TAG13b
:
5959 return OPERAND_MATCH
;
5962 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5963 /* There are no external relocs for TAG13/TAG13b fields, so we
5964 create a dummy reloc. This will not live past md_apply_fix3. */
5965 fix
->code
= BFD_RELOC_UNUSED
;
5966 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5967 fix
->opnd
= idesc
->operands
[index
];
5970 ++CURR_SLOT
.num_fixups
;
5971 return OPERAND_MATCH
;
5978 case IA64_OPND_LDXMOV
:
5979 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5980 fix
->code
= BFD_RELOC_IA64_LDXMOV
;
5981 fix
->opnd
= idesc
->operands
[index
];
5984 ++CURR_SLOT
.num_fixups
;
5985 return OPERAND_MATCH
;
5990 return OPERAND_MISMATCH
;
5999 memset (e
, 0, sizeof (*e
));
6002 if (*input_line_pointer
!= '}')
6004 sep
= *input_line_pointer
++;
6008 if (!md
.manual_bundling
)
6009 as_warn ("Found '}' when manual bundling is off");
6011 CURR_SLOT
.manual_bundling_off
= 1;
6012 md
.manual_bundling
= 0;
6018 /* Returns the next entry in the opcode table that matches the one in
6019 IDESC, and frees the entry in IDESC. If no matching entry is
6020 found, NULL is returned instead. */
6022 static struct ia64_opcode
*
6023 get_next_opcode (struct ia64_opcode
*idesc
)
6025 struct ia64_opcode
*next
= ia64_find_next_opcode (idesc
);
6026 ia64_free_opcode (idesc
);
6030 /* Parse the operands for the opcode and find the opcode variant that
6031 matches the specified operands, or NULL if no match is possible. */
6033 static struct ia64_opcode
*
6034 parse_operands (idesc
)
6035 struct ia64_opcode
*idesc
;
6037 int i
= 0, highest_unmatched_operand
, num_operands
= 0, num_outputs
= 0;
6038 int error_pos
, out_of_range_pos
, curr_out_of_range_pos
, sep
= 0;
6041 enum ia64_opnd expected_operand
= IA64_OPND_NIL
;
6042 enum operand_match_result result
;
6044 char *first_arg
= 0, *end
, *saved_input_pointer
;
6047 assert (strlen (idesc
->name
) <= 128);
6049 strcpy (mnemonic
, idesc
->name
);
6050 if (idesc
->operands
[2] == IA64_OPND_SOF
6051 || idesc
->operands
[1] == IA64_OPND_SOF
)
6053 /* To make the common idiom "alloc loc?=ar.pfs,0,1,0,0" work, we
6054 can't parse the first operand until we have parsed the
6055 remaining operands of the "alloc" instruction. */
6057 first_arg
= input_line_pointer
;
6058 end
= strchr (input_line_pointer
, '=');
6061 as_bad ("Expected separator `='");
6064 input_line_pointer
= end
+ 1;
6071 if (i
< NELEMS (CURR_SLOT
.opnd
))
6073 sep
= parse_operand (CURR_SLOT
.opnd
+ i
);
6074 if (CURR_SLOT
.opnd
[i
].X_op
== O_absent
)
6081 sep
= parse_operand (&dummy
);
6082 if (dummy
.X_op
== O_absent
)
6088 if (sep
!= '=' && sep
!= ',')
6093 if (num_outputs
> 0)
6094 as_bad ("Duplicate equal sign (=) in instruction");
6096 num_outputs
= i
+ 1;
6101 as_bad ("Illegal operand separator `%c'", sep
);
6105 if (idesc
->operands
[2] == IA64_OPND_SOF
6106 || idesc
->operands
[1] == IA64_OPND_SOF
)
6108 /* map alloc r1=ar.pfs,i,l,o,r to alloc r1=ar.pfs,(i+l+o),(i+l),r */
6109 know (strcmp (idesc
->name
, "alloc") == 0);
6110 i
= (CURR_SLOT
.opnd
[1].X_op
== O_register
6111 && CURR_SLOT
.opnd
[1].X_add_number
== REG_AR
+ AR_PFS
) ? 2 : 1;
6112 if (num_operands
== i
+ 3 /* first_arg not included in this count! */
6113 && CURR_SLOT
.opnd
[i
].X_op
== O_constant
6114 && CURR_SLOT
.opnd
[i
+ 1].X_op
== O_constant
6115 && CURR_SLOT
.opnd
[i
+ 2].X_op
== O_constant
6116 && CURR_SLOT
.opnd
[i
+ 3].X_op
== O_constant
)
6118 sof
= set_regstack (CURR_SLOT
.opnd
[i
].X_add_number
,
6119 CURR_SLOT
.opnd
[i
+ 1].X_add_number
,
6120 CURR_SLOT
.opnd
[i
+ 2].X_add_number
,
6121 CURR_SLOT
.opnd
[i
+ 3].X_add_number
);
6123 /* now we can parse the first arg: */
6124 saved_input_pointer
= input_line_pointer
;
6125 input_line_pointer
= first_arg
;
6126 sep
= parse_operand (CURR_SLOT
.opnd
+ 0);
6128 --num_outputs
; /* force error */
6129 input_line_pointer
= saved_input_pointer
;
6131 CURR_SLOT
.opnd
[i
].X_add_number
= sof
;
6132 CURR_SLOT
.opnd
[i
+ 1].X_add_number
6133 = sof
- CURR_SLOT
.opnd
[i
+ 2].X_add_number
;
6134 CURR_SLOT
.opnd
[i
+ 2] = CURR_SLOT
.opnd
[i
+ 3];
6138 highest_unmatched_operand
= -4;
6139 curr_out_of_range_pos
= -1;
6141 for (; idesc
; idesc
= get_next_opcode (idesc
))
6143 if (num_outputs
!= idesc
->num_outputs
)
6144 continue; /* mismatch in # of outputs */
6145 if (highest_unmatched_operand
< 0)
6146 highest_unmatched_operand
|= 1;
6147 if (num_operands
> NELEMS (idesc
->operands
)
6148 || (num_operands
< NELEMS (idesc
->operands
)
6149 && idesc
->operands
[num_operands
])
6150 || (num_operands
> 0 && !idesc
->operands
[num_operands
- 1]))
6151 continue; /* mismatch in number of arguments */
6152 if (highest_unmatched_operand
< 0)
6153 highest_unmatched_operand
|= 2;
6155 CURR_SLOT
.num_fixups
= 0;
6157 /* Try to match all operands. If we see an out-of-range operand,
6158 then continue trying to match the rest of the operands, since if
6159 the rest match, then this idesc will give the best error message. */
6161 out_of_range_pos
= -1;
6162 for (i
= 0; i
< num_operands
&& idesc
->operands
[i
]; ++i
)
6164 result
= operand_match (idesc
, i
, CURR_SLOT
.opnd
+ i
);
6165 if (result
!= OPERAND_MATCH
)
6167 if (result
!= OPERAND_OUT_OF_RANGE
)
6169 if (out_of_range_pos
< 0)
6170 /* remember position of the first out-of-range operand: */
6171 out_of_range_pos
= i
;
6175 /* If we did not match all operands, or if at least one operand was
6176 out-of-range, then this idesc does not match. Keep track of which
6177 idesc matched the most operands before failing. If we have two
6178 idescs that failed at the same position, and one had an out-of-range
6179 operand, then prefer the out-of-range operand. Thus if we have
6180 "add r0=0x1000000,r1" we get an error saying the constant is out
6181 of range instead of an error saying that the constant should have been
6184 if (i
!= num_operands
|| out_of_range_pos
>= 0)
6186 if (i
> highest_unmatched_operand
6187 || (i
== highest_unmatched_operand
6188 && out_of_range_pos
> curr_out_of_range_pos
))
6190 highest_unmatched_operand
= i
;
6191 if (out_of_range_pos
>= 0)
6193 expected_operand
= idesc
->operands
[out_of_range_pos
];
6194 error_pos
= out_of_range_pos
;
6198 expected_operand
= idesc
->operands
[i
];
6201 curr_out_of_range_pos
= out_of_range_pos
;
6210 if (expected_operand
)
6211 as_bad ("Operand %u of `%s' should be %s",
6212 error_pos
+ 1, mnemonic
,
6213 elf64_ia64_operands
[expected_operand
].desc
);
6214 else if (highest_unmatched_operand
< 0 && !(highest_unmatched_operand
& 1))
6215 as_bad ("Wrong number of output operands");
6216 else if (highest_unmatched_operand
< 0 && !(highest_unmatched_operand
& 2))
6217 as_bad ("Wrong number of input operands");
6219 as_bad ("Operand mismatch");
6223 /* Check that the instruction doesn't use
6224 - r0, f0, or f1 as output operands
6225 - the same predicate twice as output operands
6226 - r0 as address of a base update load or store
6227 - the same GR as output and address of a base update load
6228 - two even- or two odd-numbered FRs as output operands of a floating
6229 point parallel load.
6230 At most two (conflicting) output (or output-like) operands can exist,
6231 (floating point parallel loads have three outputs, but the base register,
6232 if updated, cannot conflict with the actual outputs). */
6234 for (i
= 0; i
< num_operands
; ++i
)
6239 switch (idesc
->operands
[i
])
6244 if (i
< num_outputs
)
6246 if (CURR_SLOT
.opnd
[i
].X_add_number
== REG_GR
)
6249 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6251 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6256 if (i
< num_outputs
)
6259 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6261 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6268 if (i
< num_outputs
)
6270 if (CURR_SLOT
.opnd
[i
].X_add_number
>= REG_FR
6271 && CURR_SLOT
.opnd
[i
].X_add_number
<= REG_FR
+ 1)
6274 regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
6277 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6279 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6283 if (idesc
->flags
& IA64_OPCODE_POSTINC
)
6285 if (CURR_SLOT
.opnd
[i
].X_add_number
== REG_GR
)
6288 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6290 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6301 as_warn ("Invalid use of `%c%d' as output operand", reg_class
, regno
);
6304 as_warn ("Invalid use of `r%d' as base update address operand", regno
);
6310 if (reg1
>= REG_GR
&& reg1
<= REG_GR
+ 127)
6315 else if (reg1
>= REG_P
&& reg1
<= REG_P
+ 63)
6320 else if (reg1
>= REG_FR
&& reg1
<= REG_FR
+ 127)
6328 as_warn ("Invalid duplicate use of `%c%d'", reg_class
, reg1
);
6330 else if (((reg1
>= REG_FR
&& reg1
<= REG_FR
+ 31
6331 && reg2
>= REG_FR
&& reg2
<= REG_FR
+ 31)
6332 || (reg1
>= REG_FR
+ 32 && reg1
<= REG_FR
+ 127
6333 && reg2
>= REG_FR
+ 32 && reg2
<= REG_FR
+ 127))
6334 && ! ((reg1
^ reg2
) & 1))
6335 as_warn ("Invalid simultaneous use of `f%d' and `f%d'",
6336 reg1
- REG_FR
, reg2
- REG_FR
);
6337 else if ((reg1
>= REG_FR
&& reg1
<= REG_FR
+ 31
6338 && reg2
>= REG_FR
+ 32 && reg2
<= REG_FR
+ 127)
6339 || (reg1
>= REG_FR
+ 32 && reg1
<= REG_FR
+ 127
6340 && reg2
>= REG_FR
&& reg2
<= REG_FR
+ 31))
6341 as_warn ("Dangerous simultaneous use of `f%d' and `f%d'",
6342 reg1
- REG_FR
, reg2
- REG_FR
);
6347 build_insn (slot
, insnp
)
6351 const struct ia64_operand
*odesc
, *o2desc
;
6352 struct ia64_opcode
*idesc
= slot
->idesc
;
6358 insn
= idesc
->opcode
| slot
->qp_regno
;
6360 for (i
= 0; i
< NELEMS (idesc
->operands
) && idesc
->operands
[i
]; ++i
)
6362 if (slot
->opnd
[i
].X_op
== O_register
6363 || slot
->opnd
[i
].X_op
== O_constant
6364 || slot
->opnd
[i
].X_op
== O_index
)
6365 val
= slot
->opnd
[i
].X_add_number
;
6366 else if (slot
->opnd
[i
].X_op
== O_big
)
6368 /* This must be the value 0x10000000000000000. */
6369 assert (idesc
->operands
[i
] == IA64_OPND_IMM8M1U8
);
6375 switch (idesc
->operands
[i
])
6377 case IA64_OPND_IMMU64
:
6378 *insnp
++ = (val
>> 22) & 0x1ffffffffffLL
;
6379 insn
|= (((val
& 0x7f) << 13) | (((val
>> 7) & 0x1ff) << 27)
6380 | (((val
>> 16) & 0x1f) << 22) | (((val
>> 21) & 0x1) << 21)
6381 | (((val
>> 63) & 0x1) << 36));
6384 case IA64_OPND_IMMU62
:
6385 val
&= 0x3fffffffffffffffULL
;
6386 if (val
!= slot
->opnd
[i
].X_add_number
)
6387 as_warn (_("Value truncated to 62 bits"));
6388 *insnp
++ = (val
>> 21) & 0x1ffffffffffLL
;
6389 insn
|= (((val
& 0xfffff) << 6) | (((val
>> 20) & 0x1) << 36));
6392 case IA64_OPND_TGT64
:
6394 *insnp
++ = ((val
>> 20) & 0x7fffffffffLL
) << 2;
6395 insn
|= ((((val
>> 59) & 0x1) << 36)
6396 | (((val
>> 0) & 0xfffff) << 13));
6427 case IA64_OPND_R3_2
:
6428 case IA64_OPND_CPUID_R3
:
6429 case IA64_OPND_DBR_R3
:
6430 case IA64_OPND_DTR_R3
:
6431 case IA64_OPND_ITR_R3
:
6432 case IA64_OPND_IBR_R3
:
6434 case IA64_OPND_MSR_R3
:
6435 case IA64_OPND_PKR_R3
:
6436 case IA64_OPND_PMC_R3
:
6437 case IA64_OPND_PMD_R3
:
6438 case IA64_OPND_RR_R3
:
6446 odesc
= elf64_ia64_operands
+ idesc
->operands
[i
];
6447 err
= (*odesc
->insert
) (odesc
, val
, &insn
);
6449 as_bad_where (slot
->src_file
, slot
->src_line
,
6450 "Bad operand value: %s", err
);
6451 if (idesc
->flags
& IA64_OPCODE_PSEUDO
)
6453 if ((idesc
->flags
& IA64_OPCODE_F2_EQ_F3
)
6454 && odesc
== elf64_ia64_operands
+ IA64_OPND_F3
)
6456 o2desc
= elf64_ia64_operands
+ IA64_OPND_F2
;
6457 (*o2desc
->insert
) (o2desc
, val
, &insn
);
6459 if ((idesc
->flags
& IA64_OPCODE_LEN_EQ_64MCNT
)
6460 && (odesc
== elf64_ia64_operands
+ IA64_OPND_CPOS6a
6461 || odesc
== elf64_ia64_operands
+ IA64_OPND_POS6
))
6463 o2desc
= elf64_ia64_operands
+ IA64_OPND_LEN6
;
6464 (*o2desc
->insert
) (o2desc
, 64 - val
, &insn
);
6474 int manual_bundling_off
= 0, manual_bundling
= 0;
6475 enum ia64_unit required_unit
, insn_unit
= 0;
6476 enum ia64_insn_type type
[3], insn_type
;
6477 unsigned int template, orig_template
;
6478 bfd_vma insn
[3] = { -1, -1, -1 };
6479 struct ia64_opcode
*idesc
;
6480 int end_of_insn_group
= 0, user_template
= -1;
6481 int n
, i
, j
, first
, curr
, last_slot
;
6482 unw_rec_list
*ptr
, *last_ptr
, *end_ptr
;
6483 bfd_vma t0
= 0, t1
= 0;
6484 struct label_fix
*lfix
;
6485 struct insn_fix
*ifix
;
6491 first
= (md
.curr_slot
+ NUM_SLOTS
- md
.num_slots_in_use
) % NUM_SLOTS
;
6492 know (first
>= 0 & first
< NUM_SLOTS
);
6493 n
= MIN (3, md
.num_slots_in_use
);
6495 /* Determine template: user user_template if specified, best match
6498 if (md
.slot
[first
].user_template
>= 0)
6499 user_template
= template = md
.slot
[first
].user_template
;
6502 /* Auto select appropriate template. */
6503 memset (type
, 0, sizeof (type
));
6505 for (i
= 0; i
< n
; ++i
)
6507 if (md
.slot
[curr
].label_fixups
&& i
!= 0)
6509 type
[i
] = md
.slot
[curr
].idesc
->type
;
6510 curr
= (curr
+ 1) % NUM_SLOTS
;
6512 template = best_template
[type
[0]][type
[1]][type
[2]];
6515 /* initialize instructions with appropriate nops: */
6516 for (i
= 0; i
< 3; ++i
)
6517 insn
[i
] = nop
[ia64_templ_desc
[template].exec_unit
[i
]];
6521 /* Check to see if this bundle is at an offset that is a multiple of 16-bytes
6522 from the start of the frag. */
6523 addr_mod
= frag_now_fix () & 15;
6524 if (frag_now
->has_code
&& frag_now
->insn_addr
!= addr_mod
)
6525 as_bad (_("instruction address is not a multiple of 16"));
6526 frag_now
->insn_addr
= addr_mod
;
6527 frag_now
->has_code
= 1;
6529 /* now fill in slots with as many insns as possible: */
6531 idesc
= md
.slot
[curr
].idesc
;
6532 end_of_insn_group
= 0;
6534 for (i
= 0; i
< 3 && md
.num_slots_in_use
> 0; ++i
)
6536 /* If we have unwind records, we may need to update some now. */
6537 ptr
= md
.slot
[curr
].unwind_record
;
6540 /* Find the last prologue/body record in the list for the current
6541 insn, and set the slot number for all records up to that point.
6542 This needs to be done now, because prologue/body records refer to
6543 the current point, not the point after the instruction has been
6544 issued. This matters because there may have been nops emitted
6545 meanwhile. Any non-prologue non-body record followed by a
6546 prologue/body record must also refer to the current point. */
6548 end_ptr
= md
.slot
[(curr
+ 1) % NUM_SLOTS
].unwind_record
;
6549 for (; ptr
!= end_ptr
; ptr
= ptr
->next
)
6550 if (ptr
->r
.type
== prologue
|| ptr
->r
.type
== prologue_gr
6551 || ptr
->r
.type
== body
)
6555 /* Make last_ptr point one after the last prologue/body
6557 last_ptr
= last_ptr
->next
;
6558 for (ptr
= md
.slot
[curr
].unwind_record
; ptr
!= last_ptr
;
6561 ptr
->slot_number
= (unsigned long) f
+ i
;
6562 ptr
->slot_frag
= frag_now
;
6564 /* Remove the initialized records, so that we won't accidentally
6565 update them again if we insert a nop and continue. */
6566 md
.slot
[curr
].unwind_record
= last_ptr
;
6570 manual_bundling_off
= md
.slot
[curr
].manual_bundling_off
;
6571 if (md
.slot
[curr
].manual_bundling_on
)
6574 manual_bundling
= 1;
6576 break; /* Need to start a new bundle. */
6579 /* If this instruction specifies a template, then it must be the first
6580 instruction of a bundle. */
6581 if (curr
!= first
&& md
.slot
[curr
].user_template
>= 0)
6584 if (idesc
->flags
& IA64_OPCODE_SLOT2
)
6586 if (manual_bundling
&& !manual_bundling_off
)
6588 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6589 "`%s' must be last in bundle", idesc
->name
);
6591 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6595 if (idesc
->flags
& IA64_OPCODE_LAST
)
6598 unsigned int required_template
;
6600 /* If we need a stop bit after an M slot, our only choice is
6601 template 5 (M;;MI). If we need a stop bit after a B
6602 slot, our only choice is to place it at the end of the
6603 bundle, because the only available templates are MIB,
6604 MBB, BBB, MMB, and MFB. We don't handle anything other
6605 than M and B slots because these are the only kind of
6606 instructions that can have the IA64_OPCODE_LAST bit set. */
6607 required_template
= template;
6608 switch (idesc
->type
)
6612 required_template
= 5;
6620 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6621 "Internal error: don't know how to force %s to end"
6622 "of instruction group", idesc
->name
);
6627 && (i
> required_slot
6628 || (required_slot
== 2 && !manual_bundling_off
)
6629 || (user_template
>= 0
6630 /* Changing from MMI to M;MI is OK. */
6631 && (template ^ required_template
) > 1)))
6633 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6634 "`%s' must be last in instruction group",
6636 if (i
< 2 && required_slot
== 2 && !manual_bundling_off
)
6637 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6639 if (required_slot
< i
)
6640 /* Can't fit this instruction. */
6644 if (required_template
!= template)
6646 /* If we switch the template, we need to reset the NOPs
6647 after slot i. The slot-types of the instructions ahead
6648 of i never change, so we don't need to worry about
6649 changing NOPs in front of this slot. */
6650 for (j
= i
; j
< 3; ++j
)
6651 insn
[j
] = nop
[ia64_templ_desc
[required_template
].exec_unit
[j
]];
6653 template = required_template
;
6655 if (curr
!= first
&& md
.slot
[curr
].label_fixups
)
6657 if (manual_bundling
)
6659 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6660 "Label must be first in a bundle");
6661 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6663 /* This insn must go into the first slot of a bundle. */
6667 if (end_of_insn_group
&& md
.num_slots_in_use
>= 1)
6669 /* We need an instruction group boundary in the middle of a
6670 bundle. See if we can switch to an other template with
6671 an appropriate boundary. */
6673 orig_template
= template;
6674 if (i
== 1 && (user_template
== 4
6675 || (user_template
< 0
6676 && (ia64_templ_desc
[template].exec_unit
[0]
6680 end_of_insn_group
= 0;
6682 else if (i
== 2 && (user_template
== 0
6683 || (user_template
< 0
6684 && (ia64_templ_desc
[template].exec_unit
[1]
6686 /* This test makes sure we don't switch the template if
6687 the next instruction is one that needs to be first in
6688 an instruction group. Since all those instructions are
6689 in the M group, there is no way such an instruction can
6690 fit in this bundle even if we switch the template. The
6691 reason we have to check for this is that otherwise we
6692 may end up generating "MI;;I M.." which has the deadly
6693 effect that the second M instruction is no longer the
6694 first in the group! --davidm 99/12/16 */
6695 && (idesc
->flags
& IA64_OPCODE_FIRST
) == 0)
6698 end_of_insn_group
= 0;
6701 && user_template
== 0
6702 && !(idesc
->flags
& IA64_OPCODE_FIRST
))
6703 /* Use the next slot. */
6705 else if (curr
!= first
)
6706 /* can't fit this insn */
6709 if (template != orig_template
)
6710 /* if we switch the template, we need to reset the NOPs
6711 after slot i. The slot-types of the instructions ahead
6712 of i never change, so we don't need to worry about
6713 changing NOPs in front of this slot. */
6714 for (j
= i
; j
< 3; ++j
)
6715 insn
[j
] = nop
[ia64_templ_desc
[template].exec_unit
[j
]];
6717 required_unit
= ia64_templ_desc
[template].exec_unit
[i
];
6719 /* resolve dynamic opcodes such as "break", "hint", and "nop": */
6720 if (idesc
->type
== IA64_TYPE_DYN
)
6722 enum ia64_opnd opnd1
, opnd2
;
6724 if ((strcmp (idesc
->name
, "nop") == 0)
6725 || (strcmp (idesc
->name
, "break") == 0))
6726 insn_unit
= required_unit
;
6727 else if (strcmp (idesc
->name
, "hint") == 0)
6729 insn_unit
= required_unit
;
6730 if (required_unit
== IA64_UNIT_B
)
6736 case hint_b_warning
:
6737 as_warn ("hint in B unit may be treated as nop");
6740 /* When manual bundling is off and there is no
6741 user template, we choose a different unit so
6742 that hint won't go into the current slot. We
6743 will fill the current bundle with nops and
6744 try to put hint into the next bundle. */
6745 if (!manual_bundling
&& user_template
< 0)
6746 insn_unit
= IA64_UNIT_I
;
6748 as_bad ("hint in B unit can't be used");
6753 else if (strcmp (idesc
->name
, "chk.s") == 0
6754 || strcmp (idesc
->name
, "mov") == 0)
6756 insn_unit
= IA64_UNIT_M
;
6757 if (required_unit
== IA64_UNIT_I
6758 || (required_unit
== IA64_UNIT_F
&& template == 6))
6759 insn_unit
= IA64_UNIT_I
;
6762 as_fatal ("emit_one_bundle: unexpected dynamic op");
6764 sprintf (mnemonic
, "%s.%c", idesc
->name
, "?imbfxx"[insn_unit
]);
6765 opnd1
= idesc
->operands
[0];
6766 opnd2
= idesc
->operands
[1];
6767 ia64_free_opcode (idesc
);
6768 idesc
= ia64_find_opcode (mnemonic
);
6769 /* moves to/from ARs have collisions */
6770 if (opnd1
== IA64_OPND_AR3
|| opnd2
== IA64_OPND_AR3
)
6772 while (idesc
!= NULL
6773 && (idesc
->operands
[0] != opnd1
6774 || idesc
->operands
[1] != opnd2
))
6775 idesc
= get_next_opcode (idesc
);
6777 md
.slot
[curr
].idesc
= idesc
;
6781 insn_type
= idesc
->type
;
6782 insn_unit
= IA64_UNIT_NIL
;
6786 if (required_unit
== IA64_UNIT_I
|| required_unit
== IA64_UNIT_M
)
6787 insn_unit
= required_unit
;
6789 case IA64_TYPE_X
: insn_unit
= IA64_UNIT_L
; break;
6790 case IA64_TYPE_I
: insn_unit
= IA64_UNIT_I
; break;
6791 case IA64_TYPE_M
: insn_unit
= IA64_UNIT_M
; break;
6792 case IA64_TYPE_B
: insn_unit
= IA64_UNIT_B
; break;
6793 case IA64_TYPE_F
: insn_unit
= IA64_UNIT_F
; break;
6798 if (insn_unit
!= required_unit
)
6799 continue; /* Try next slot. */
6801 if (debug_type
== DEBUG_DWARF2
|| md
.slot
[curr
].loc_directive_seen
)
6803 bfd_vma addr
= frag_now
->fr_address
+ frag_now_fix () - 16 + i
;
6805 md
.slot
[curr
].loc_directive_seen
= 0;
6806 dwarf2_gen_line_info (addr
, &md
.slot
[curr
].debug_line
);
6809 build_insn (md
.slot
+ curr
, insn
+ i
);
6811 ptr
= md
.slot
[curr
].unwind_record
;
6814 /* Set slot numbers for all remaining unwind records belonging to the
6815 current insn. There can not be any prologue/body unwind records
6817 end_ptr
= md
.slot
[(curr
+ 1) % NUM_SLOTS
].unwind_record
;
6818 for (; ptr
!= end_ptr
; ptr
= ptr
->next
)
6820 ptr
->slot_number
= (unsigned long) f
+ i
;
6821 ptr
->slot_frag
= frag_now
;
6823 md
.slot
[curr
].unwind_record
= NULL
;
6826 if (required_unit
== IA64_UNIT_L
)
6829 /* skip one slot for long/X-unit instructions */
6832 --md
.num_slots_in_use
;
6835 /* now is a good time to fix up the labels for this insn: */
6836 for (lfix
= md
.slot
[curr
].label_fixups
; lfix
; lfix
= lfix
->next
)
6838 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16);
6839 symbol_set_frag (lfix
->sym
, frag_now
);
6841 /* and fix up the tags also. */
6842 for (lfix
= md
.slot
[curr
].tag_fixups
; lfix
; lfix
= lfix
->next
)
6844 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16 + i
);
6845 symbol_set_frag (lfix
->sym
, frag_now
);
6848 for (j
= 0; j
< md
.slot
[curr
].num_fixups
; ++j
)
6850 ifix
= md
.slot
[curr
].fixup
+ j
;
6851 fix
= fix_new_exp (frag_now
, frag_now_fix () - 16 + i
, 8,
6852 &ifix
->expr
, ifix
->is_pcrel
, ifix
->code
);
6853 fix
->tc_fix_data
.opnd
= ifix
->opnd
;
6854 fix
->fx_plt
= (fix
->fx_r_type
== BFD_RELOC_IA64_PLTOFF22
);
6855 fix
->fx_file
= md
.slot
[curr
].src_file
;
6856 fix
->fx_line
= md
.slot
[curr
].src_line
;
6859 end_of_insn_group
= md
.slot
[curr
].end_of_insn_group
;
6862 ia64_free_opcode (md
.slot
[curr
].idesc
);
6863 memset (md
.slot
+ curr
, 0, sizeof (md
.slot
[curr
]));
6864 md
.slot
[curr
].user_template
= -1;
6866 if (manual_bundling_off
)
6868 manual_bundling
= 0;
6871 curr
= (curr
+ 1) % NUM_SLOTS
;
6872 idesc
= md
.slot
[curr
].idesc
;
6874 if (manual_bundling
> 0)
6876 if (md
.num_slots_in_use
> 0)
6879 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6880 "`%s' does not fit into bundle", idesc
->name
);
6881 else if (last_slot
< 0)
6883 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6884 "`%s' does not fit into %s template",
6885 idesc
->name
, ia64_templ_desc
[template].name
);
6886 /* Drop first insn so we don't livelock. */
6887 --md
.num_slots_in_use
;
6888 know (curr
== first
);
6889 ia64_free_opcode (md
.slot
[curr
].idesc
);
6890 memset (md
.slot
+ curr
, 0, sizeof (md
.slot
[curr
]));
6891 md
.slot
[curr
].user_template
= -1;
6899 else if (last_slot
== 0)
6900 where
= "slots 2 or 3";
6903 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6904 "`%s' can't go in %s of %s template",
6905 idesc
->name
, where
, ia64_templ_desc
[template].name
);
6909 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6910 "Missing '}' at end of file");
6912 know (md
.num_slots_in_use
< NUM_SLOTS
);
6914 t0
= end_of_insn_group
| (template << 1) | (insn
[0] << 5) | (insn
[1] << 46);
6915 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
6917 number_to_chars_littleendian (f
+ 0, t0
, 8);
6918 number_to_chars_littleendian (f
+ 8, t1
, 8);
6922 md_parse_option (c
, arg
)
6929 /* Switches from the Intel assembler. */
6931 if (strcmp (arg
, "ilp64") == 0
6932 || strcmp (arg
, "lp64") == 0
6933 || strcmp (arg
, "p64") == 0)
6935 md
.flags
|= EF_IA_64_ABI64
;
6937 else if (strcmp (arg
, "ilp32") == 0)
6939 md
.flags
&= ~EF_IA_64_ABI64
;
6941 else if (strcmp (arg
, "le") == 0)
6943 md
.flags
&= ~EF_IA_64_BE
;
6944 default_big_endian
= 0;
6946 else if (strcmp (arg
, "be") == 0)
6948 md
.flags
|= EF_IA_64_BE
;
6949 default_big_endian
= 1;
6951 else if (strncmp (arg
, "unwind-check=", 13) == 0)
6954 if (strcmp (arg
, "warning") == 0)
6955 md
.unwind_check
= unwind_check_warning
;
6956 else if (strcmp (arg
, "error") == 0)
6957 md
.unwind_check
= unwind_check_error
;
6961 else if (strncmp (arg
, "hint.b=", 7) == 0)
6964 if (strcmp (arg
, "ok") == 0)
6965 md
.hint_b
= hint_b_ok
;
6966 else if (strcmp (arg
, "warning") == 0)
6967 md
.hint_b
= hint_b_warning
;
6968 else if (strcmp (arg
, "error") == 0)
6969 md
.hint_b
= hint_b_error
;
6973 else if (strncmp (arg
, "tune=", 5) == 0)
6976 if (strcmp (arg
, "itanium1") == 0)
6978 else if (strcmp (arg
, "itanium2") == 0)
6988 if (strcmp (arg
, "so") == 0)
6990 /* Suppress signon message. */
6992 else if (strcmp (arg
, "pi") == 0)
6994 /* Reject privileged instructions. FIXME */
6996 else if (strcmp (arg
, "us") == 0)
6998 /* Allow union of signed and unsigned range. FIXME */
7000 else if (strcmp (arg
, "close_fcalls") == 0)
7002 /* Do not resolve global function calls. */
7009 /* temp[="prefix"] Insert temporary labels into the object file
7010 symbol table prefixed by "prefix".
7011 Default prefix is ":temp:".
7016 /* indirect=<tgt> Assume unannotated indirect branches behavior
7017 according to <tgt> --
7018 exit: branch out from the current context (default)
7019 labels: all labels in context may be branch targets
7021 if (strncmp (arg
, "indirect=", 9) != 0)
7026 /* -X conflicts with an ignored option, use -x instead */
7028 if (!arg
|| strcmp (arg
, "explicit") == 0)
7030 /* set default mode to explicit */
7031 md
.default_explicit_mode
= 1;
7034 else if (strcmp (arg
, "auto") == 0)
7036 md
.default_explicit_mode
= 0;
7038 else if (strcmp (arg
, "none") == 0)
7042 else if (strcmp (arg
, "debug") == 0)
7046 else if (strcmp (arg
, "debugx") == 0)
7048 md
.default_explicit_mode
= 1;
7051 else if (strcmp (arg
, "debugn") == 0)
7058 as_bad (_("Unrecognized option '-x%s'"), arg
);
7063 /* nops Print nops statistics. */
7066 /* GNU specific switches for gcc. */
7067 case OPTION_MCONSTANT_GP
:
7068 md
.flags
|= EF_IA_64_CONS_GP
;
7071 case OPTION_MAUTO_PIC
:
7072 md
.flags
|= EF_IA_64_NOFUNCDESC_CONS_GP
;
7083 md_show_usage (stream
)
7088 --mconstant-gp mark output file as using the constant-GP model\n\
7089 (sets ELF header flag EF_IA_64_CONS_GP)\n\
7090 --mauto-pic mark output file as using the constant-GP model\n\
7091 without function descriptors (sets ELF header flag\n\
7092 EF_IA_64_NOFUNCDESC_CONS_GP)\n\
7093 -milp32|-milp64|-mlp64|-mp64 select data model (default -mlp64)\n\
7094 -mle | -mbe select little- or big-endian byte order (default -mle)\n\
7095 -mtune=[itanium1|itanium2]\n\
7096 tune for a specific CPU (default -mtune=itanium2)\n\
7097 -munwind-check=[warning|error]\n\
7098 unwind directive check (default -munwind-check=warning)\n\
7099 -mhint.b=[ok|warning|error]\n\
7100 hint.b check (default -mhint.b=error)\n\
7101 -x | -xexplicit turn on dependency violation checking\n\
7102 -xauto automagically remove dependency violations (default)\n\
7103 -xnone turn off dependency violation checking\n\
7104 -xdebug debug dependency violation checker\n\
7105 -xdebugn debug dependency violation checker but turn off\n\
7106 dependency violation checking\n\
7107 -xdebugx debug dependency violation checker and turn on\n\
7108 dependency violation checking\n"),
7113 ia64_after_parse_args ()
7115 if (debug_type
== DEBUG_STABS
)
7116 as_fatal (_("--gstabs is not supported for ia64"));
7119 /* Return true if TYPE fits in TEMPL at SLOT. */
7122 match (int templ
, int type
, int slot
)
7124 enum ia64_unit unit
;
7127 unit
= ia64_templ_desc
[templ
].exec_unit
[slot
];
7130 case IA64_TYPE_DYN
: result
= 1; break; /* for nop and break */
7132 result
= (unit
== IA64_UNIT_I
|| unit
== IA64_UNIT_M
);
7134 case IA64_TYPE_X
: result
= (unit
== IA64_UNIT_L
); break;
7135 case IA64_TYPE_I
: result
= (unit
== IA64_UNIT_I
); break;
7136 case IA64_TYPE_M
: result
= (unit
== IA64_UNIT_M
); break;
7137 case IA64_TYPE_B
: result
= (unit
== IA64_UNIT_B
); break;
7138 case IA64_TYPE_F
: result
= (unit
== IA64_UNIT_F
); break;
7139 default: result
= 0; break;
7144 /* Add a bit of extra goodness if a nop of type F or B would fit
7145 in TEMPL at SLOT. */
7148 extra_goodness (int templ
, int slot
)
7153 if (slot
== 1 && match (templ
, IA64_TYPE_F
, slot
))
7155 else if (slot
== 2 && match (templ
, IA64_TYPE_B
, slot
))
7161 if (match (templ
, IA64_TYPE_M
, slot
)
7162 || match (templ
, IA64_TYPE_I
, slot
))
7163 /* Favor M- and I-unit NOPs. We definitely want to avoid
7164 F-unit and B-unit may cause split-issue or less-than-optimal
7165 branch-prediction. */
7176 /* This function is called once, at assembler startup time. It sets
7177 up all the tables, etc. that the MD part of the assembler will need
7178 that can be determined before arguments are parsed. */
7182 int i
, j
, k
, t
, total
, ar_base
, cr_base
, goodness
, best
, regnum
, ok
;
7187 md
.explicit_mode
= md
.default_explicit_mode
;
7189 bfd_set_section_alignment (stdoutput
, text_section
, 4);
7191 /* Make sure function pointers get initialized. */
7192 target_big_endian
= -1;
7193 dot_byteorder (default_big_endian
);
7195 alias_hash
= hash_new ();
7196 alias_name_hash
= hash_new ();
7197 secalias_hash
= hash_new ();
7198 secalias_name_hash
= hash_new ();
7200 pseudo_func
[FUNC_DTP_MODULE
].u
.sym
=
7201 symbol_new (".<dtpmod>", undefined_section
, FUNC_DTP_MODULE
,
7202 &zero_address_frag
);
7204 pseudo_func
[FUNC_DTP_RELATIVE
].u
.sym
=
7205 symbol_new (".<dtprel>", undefined_section
, FUNC_DTP_RELATIVE
,
7206 &zero_address_frag
);
7208 pseudo_func
[FUNC_FPTR_RELATIVE
].u
.sym
=
7209 symbol_new (".<fptr>", undefined_section
, FUNC_FPTR_RELATIVE
,
7210 &zero_address_frag
);
7212 pseudo_func
[FUNC_GP_RELATIVE
].u
.sym
=
7213 symbol_new (".<gprel>", undefined_section
, FUNC_GP_RELATIVE
,
7214 &zero_address_frag
);
7216 pseudo_func
[FUNC_LT_RELATIVE
].u
.sym
=
7217 symbol_new (".<ltoff>", undefined_section
, FUNC_LT_RELATIVE
,
7218 &zero_address_frag
);
7220 pseudo_func
[FUNC_LT_RELATIVE_X
].u
.sym
=
7221 symbol_new (".<ltoffx>", undefined_section
, FUNC_LT_RELATIVE_X
,
7222 &zero_address_frag
);
7224 pseudo_func
[FUNC_PC_RELATIVE
].u
.sym
=
7225 symbol_new (".<pcrel>", undefined_section
, FUNC_PC_RELATIVE
,
7226 &zero_address_frag
);
7228 pseudo_func
[FUNC_PLT_RELATIVE
].u
.sym
=
7229 symbol_new (".<pltoff>", undefined_section
, FUNC_PLT_RELATIVE
,
7230 &zero_address_frag
);
7232 pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
=
7233 symbol_new (".<secrel>", undefined_section
, FUNC_SEC_RELATIVE
,
7234 &zero_address_frag
);
7236 pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
=
7237 symbol_new (".<segrel>", undefined_section
, FUNC_SEG_RELATIVE
,
7238 &zero_address_frag
);
7240 pseudo_func
[FUNC_TP_RELATIVE
].u
.sym
=
7241 symbol_new (".<tprel>", undefined_section
, FUNC_TP_RELATIVE
,
7242 &zero_address_frag
);
7244 pseudo_func
[FUNC_LTV_RELATIVE
].u
.sym
=
7245 symbol_new (".<ltv>", undefined_section
, FUNC_LTV_RELATIVE
,
7246 &zero_address_frag
);
7248 pseudo_func
[FUNC_LT_FPTR_RELATIVE
].u
.sym
=
7249 symbol_new (".<ltoff.fptr>", undefined_section
, FUNC_LT_FPTR_RELATIVE
,
7250 &zero_address_frag
);
7252 pseudo_func
[FUNC_LT_DTP_MODULE
].u
.sym
=
7253 symbol_new (".<ltoff.dtpmod>", undefined_section
, FUNC_LT_DTP_MODULE
,
7254 &zero_address_frag
);
7256 pseudo_func
[FUNC_LT_DTP_RELATIVE
].u
.sym
=
7257 symbol_new (".<ltoff.dptrel>", undefined_section
, FUNC_LT_DTP_RELATIVE
,
7258 &zero_address_frag
);
7260 pseudo_func
[FUNC_LT_TP_RELATIVE
].u
.sym
=
7261 symbol_new (".<ltoff.tprel>", undefined_section
, FUNC_LT_TP_RELATIVE
,
7262 &zero_address_frag
);
7264 pseudo_func
[FUNC_IPLT_RELOC
].u
.sym
=
7265 symbol_new (".<iplt>", undefined_section
, FUNC_IPLT_RELOC
,
7266 &zero_address_frag
);
7268 if (md
.tune
!= itanium1
)
7270 /* Convert MFI NOPs bundles into MMI NOPs bundles. */
7272 le_nop_stop
[0] = 0x9;
7275 /* Compute the table of best templates. We compute goodness as a
7276 base 4 value, in which each match counts for 3. Match-failures
7277 result in NOPs and we use extra_goodness() to pick the execution
7278 units that are best suited for issuing the NOP. */
7279 for (i
= 0; i
< IA64_NUM_TYPES
; ++i
)
7280 for (j
= 0; j
< IA64_NUM_TYPES
; ++j
)
7281 for (k
= 0; k
< IA64_NUM_TYPES
; ++k
)
7284 for (t
= 0; t
< NELEMS (ia64_templ_desc
); ++t
)
7287 if (match (t
, i
, 0))
7289 if (match (t
, j
, 1))
7291 if (match (t
, k
, 2))
7292 goodness
= 3 + 3 + 3;
7294 goodness
= 3 + 3 + extra_goodness (t
, 2);
7296 else if (match (t
, j
, 2))
7297 goodness
= 3 + 3 + extra_goodness (t
, 1);
7301 goodness
+= extra_goodness (t
, 1);
7302 goodness
+= extra_goodness (t
, 2);
7305 else if (match (t
, i
, 1))
7307 if (match (t
, j
, 2))
7310 goodness
= 3 + extra_goodness (t
, 2);
7312 else if (match (t
, i
, 2))
7313 goodness
= 3 + extra_goodness (t
, 1);
7315 if (goodness
> best
)
7318 best_template
[i
][j
][k
] = t
;
7323 for (i
= 0; i
< NUM_SLOTS
; ++i
)
7324 md
.slot
[i
].user_template
= -1;
7326 md
.pseudo_hash
= hash_new ();
7327 for (i
= 0; i
< NELEMS (pseudo_opcode
); ++i
)
7329 err
= hash_insert (md
.pseudo_hash
, pseudo_opcode
[i
].name
,
7330 (void *) (pseudo_opcode
+ i
));
7332 as_fatal ("ia64.md_begin: can't hash `%s': %s",
7333 pseudo_opcode
[i
].name
, err
);
7336 md
.reg_hash
= hash_new ();
7337 md
.dynreg_hash
= hash_new ();
7338 md
.const_hash
= hash_new ();
7339 md
.entry_hash
= hash_new ();
7341 /* general registers: */
7344 for (i
= 0; i
< total
; ++i
)
7346 sprintf (name
, "r%d", i
- REG_GR
);
7347 md
.regsym
[i
] = declare_register (name
, i
);
7350 /* floating point registers: */
7352 for (; i
< total
; ++i
)
7354 sprintf (name
, "f%d", i
- REG_FR
);
7355 md
.regsym
[i
] = declare_register (name
, i
);
7358 /* application registers: */
7361 for (; i
< total
; ++i
)
7363 sprintf (name
, "ar%d", i
- REG_AR
);
7364 md
.regsym
[i
] = declare_register (name
, i
);
7367 /* control registers: */
7370 for (; i
< total
; ++i
)
7372 sprintf (name
, "cr%d", i
- REG_CR
);
7373 md
.regsym
[i
] = declare_register (name
, i
);
7376 /* predicate registers: */
7378 for (; i
< total
; ++i
)
7380 sprintf (name
, "p%d", i
- REG_P
);
7381 md
.regsym
[i
] = declare_register (name
, i
);
7384 /* branch registers: */
7386 for (; i
< total
; ++i
)
7388 sprintf (name
, "b%d", i
- REG_BR
);
7389 md
.regsym
[i
] = declare_register (name
, i
);
7392 md
.regsym
[REG_IP
] = declare_register ("ip", REG_IP
);
7393 md
.regsym
[REG_CFM
] = declare_register ("cfm", REG_CFM
);
7394 md
.regsym
[REG_PR
] = declare_register ("pr", REG_PR
);
7395 md
.regsym
[REG_PR_ROT
] = declare_register ("pr.rot", REG_PR_ROT
);
7396 md
.regsym
[REG_PSR
] = declare_register ("psr", REG_PSR
);
7397 md
.regsym
[REG_PSR_L
] = declare_register ("psr.l", REG_PSR_L
);
7398 md
.regsym
[REG_PSR_UM
] = declare_register ("psr.um", REG_PSR_UM
);
7400 for (i
= 0; i
< NELEMS (indirect_reg
); ++i
)
7402 regnum
= indirect_reg
[i
].regnum
;
7403 md
.regsym
[regnum
] = declare_register (indirect_reg
[i
].name
, regnum
);
7406 /* define synonyms for application registers: */
7407 for (i
= REG_AR
; i
< REG_AR
+ NELEMS (ar
); ++i
)
7408 md
.regsym
[i
] = declare_register (ar
[i
- REG_AR
].name
,
7409 REG_AR
+ ar
[i
- REG_AR
].regnum
);
7411 /* define synonyms for control registers: */
7412 for (i
= REG_CR
; i
< REG_CR
+ NELEMS (cr
); ++i
)
7413 md
.regsym
[i
] = declare_register (cr
[i
- REG_CR
].name
,
7414 REG_CR
+ cr
[i
- REG_CR
].regnum
);
7416 declare_register ("gp", REG_GR
+ 1);
7417 declare_register ("sp", REG_GR
+ 12);
7418 declare_register ("rp", REG_BR
+ 0);
7420 /* pseudo-registers used to specify unwind info: */
7421 declare_register ("psp", REG_PSP
);
7423 declare_register_set ("ret", 4, REG_GR
+ 8);
7424 declare_register_set ("farg", 8, REG_FR
+ 8);
7425 declare_register_set ("fret", 8, REG_FR
+ 8);
7427 for (i
= 0; i
< NELEMS (const_bits
); ++i
)
7429 err
= hash_insert (md
.const_hash
, const_bits
[i
].name
,
7430 (PTR
) (const_bits
+ i
));
7432 as_fatal ("Inserting \"%s\" into constant hash table failed: %s",
7436 /* Set the architecture and machine depending on defaults and command line
7438 if (md
.flags
& EF_IA_64_ABI64
)
7439 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf64
);
7441 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf32
);
7444 as_warn (_("Could not set architecture and machine"));
7446 /* Set the pointer size and pointer shift size depending on md.flags */
7448 if (md
.flags
& EF_IA_64_ABI64
)
7450 md
.pointer_size
= 8; /* pointers are 8 bytes */
7451 md
.pointer_size_shift
= 3; /* alignment is 8 bytes = 2^2 */
7455 md
.pointer_size
= 4; /* pointers are 4 bytes */
7456 md
.pointer_size_shift
= 2; /* alignment is 4 bytes = 2^2 */
7459 md
.mem_offset
.hint
= 0;
7462 md
.entry_labels
= NULL
;
7465 /* Set the default options in md. Cannot do this in md_begin because
7466 that is called after md_parse_option which is where we set the
7467 options in md based on command line options. */
7470 ia64_init (argc
, argv
)
7471 int argc ATTRIBUTE_UNUSED
;
7472 char **argv ATTRIBUTE_UNUSED
;
7474 md
.flags
= MD_FLAGS_DEFAULT
;
7476 /* FIXME: We should change it to unwind_check_error someday. */
7477 md
.unwind_check
= unwind_check_warning
;
7478 md
.hint_b
= hint_b_error
;
7482 /* Return a string for the target object file format. */
7485 ia64_target_format ()
7487 if (OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
7489 if (md
.flags
& EF_IA_64_BE
)
7491 if (md
.flags
& EF_IA_64_ABI64
)
7492 #if defined(TE_AIX50)
7493 return "elf64-ia64-aix-big";
7494 #elif defined(TE_HPUX)
7495 return "elf64-ia64-hpux-big";
7497 return "elf64-ia64-big";
7500 #if defined(TE_AIX50)
7501 return "elf32-ia64-aix-big";
7502 #elif defined(TE_HPUX)
7503 return "elf32-ia64-hpux-big";
7505 return "elf32-ia64-big";
7510 if (md
.flags
& EF_IA_64_ABI64
)
7512 return "elf64-ia64-aix-little";
7514 return "elf64-ia64-little";
7518 return "elf32-ia64-aix-little";
7520 return "elf32-ia64-little";
7525 return "unknown-format";
7529 ia64_end_of_source ()
7531 /* terminate insn group upon reaching end of file: */
7532 insn_group_break (1, 0, 0);
7534 /* emits slots we haven't written yet: */
7535 ia64_flush_insns ();
7537 bfd_set_private_flags (stdoutput
, md
.flags
);
7539 md
.mem_offset
.hint
= 0;
7545 if (md
.qp
.X_op
== O_register
)
7546 as_bad ("qualifying predicate not followed by instruction");
7547 md
.qp
.X_op
= O_absent
;
7549 if (ignore_input ())
7552 if (input_line_pointer
[0] == ';' && input_line_pointer
[-1] == ';')
7554 if (md
.detect_dv
&& !md
.explicit_mode
)
7561 as_warn (_("Explicit stops are ignored in auto mode"));
7565 insn_group_break (1, 0, 0);
7569 /* This is a hook for ia64_frob_label, so that it can distinguish tags from
7571 static int defining_tag
= 0;
7574 ia64_unrecognized_line (ch
)
7580 expression (&md
.qp
);
7581 if (*input_line_pointer
++ != ')')
7583 as_bad ("Expected ')'");
7586 if (md
.qp
.X_op
!= O_register
)
7588 as_bad ("Qualifying predicate expected");
7591 if (md
.qp
.X_add_number
< REG_P
|| md
.qp
.X_add_number
>= REG_P
+ 64)
7593 as_bad ("Predicate register expected");
7599 if (md
.manual_bundling
)
7600 as_warn ("Found '{' when manual bundling is already turned on");
7602 CURR_SLOT
.manual_bundling_on
= 1;
7603 md
.manual_bundling
= 1;
7605 /* Bundling is only acceptable in explicit mode
7606 or when in default automatic mode. */
7607 if (md
.detect_dv
&& !md
.explicit_mode
)
7609 if (!md
.mode_explicitly_set
7610 && !md
.default_explicit_mode
)
7613 as_warn (_("Found '{' after explicit switch to automatic mode"));
7618 if (!md
.manual_bundling
)
7619 as_warn ("Found '}' when manual bundling is off");
7621 PREV_SLOT
.manual_bundling_off
= 1;
7622 md
.manual_bundling
= 0;
7624 /* switch back to automatic mode, if applicable */
7627 && !md
.mode_explicitly_set
7628 && !md
.default_explicit_mode
)
7631 /* Allow '{' to follow on the same line. We also allow ";;", but that
7632 happens automatically because ';' is an end of line marker. */
7634 if (input_line_pointer
[0] == '{')
7636 input_line_pointer
++;
7637 return ia64_unrecognized_line ('{');
7640 demand_empty_rest_of_line ();
7650 if (md
.qp
.X_op
== O_register
)
7652 as_bad ("Tag must come before qualifying predicate.");
7656 /* This implements just enough of read_a_source_file in read.c to
7657 recognize labels. */
7658 if (is_name_beginner (*input_line_pointer
))
7660 s
= input_line_pointer
;
7661 c
= get_symbol_end ();
7663 else if (LOCAL_LABELS_FB
7664 && ISDIGIT (*input_line_pointer
))
7667 while (ISDIGIT (*input_line_pointer
))
7668 temp
= (temp
* 10) + *input_line_pointer
++ - '0';
7669 fb_label_instance_inc (temp
);
7670 s
= fb_label_name (temp
, 0);
7671 c
= *input_line_pointer
;
7680 /* Put ':' back for error messages' sake. */
7681 *input_line_pointer
++ = ':';
7682 as_bad ("Expected ':'");
7689 /* Put ':' back for error messages' sake. */
7690 *input_line_pointer
++ = ':';
7691 if (*input_line_pointer
++ != ']')
7693 as_bad ("Expected ']'");
7698 as_bad ("Tag name expected");
7708 /* Not a valid line. */
7713 ia64_frob_label (sym
)
7716 struct label_fix
*fix
;
7718 /* Tags need special handling since they are not bundle breaks like
7722 fix
= obstack_alloc (¬es
, sizeof (*fix
));
7724 fix
->next
= CURR_SLOT
.tag_fixups
;
7725 CURR_SLOT
.tag_fixups
= fix
;
7730 if (bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7732 md
.last_text_seg
= now_seg
;
7733 fix
= obstack_alloc (¬es
, sizeof (*fix
));
7735 fix
->next
= CURR_SLOT
.label_fixups
;
7736 CURR_SLOT
.label_fixups
= fix
;
7738 /* Keep track of how many code entry points we've seen. */
7739 if (md
.path
== md
.maxpaths
)
7742 md
.entry_labels
= (const char **)
7743 xrealloc ((void *) md
.entry_labels
,
7744 md
.maxpaths
* sizeof (char *));
7746 md
.entry_labels
[md
.path
++] = S_GET_NAME (sym
);
7751 /* The HP-UX linker will give unresolved symbol errors for symbols
7752 that are declared but unused. This routine removes declared,
7753 unused symbols from an object. */
7755 ia64_frob_symbol (sym
)
7758 if ((S_GET_SEGMENT (sym
) == &bfd_und_section
&& ! symbol_used_p (sym
) &&
7759 ELF_ST_VISIBILITY (S_GET_OTHER (sym
)) == STV_DEFAULT
)
7760 || (S_GET_SEGMENT (sym
) == &bfd_abs_section
7761 && ! S_IS_EXTERNAL (sym
)))
7768 ia64_flush_pending_output ()
7770 if (!md
.keep_pending_output
7771 && bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7773 /* ??? This causes many unnecessary stop bits to be emitted.
7774 Unfortunately, it isn't clear if it is safe to remove this. */
7775 insn_group_break (1, 0, 0);
7776 ia64_flush_insns ();
7780 /* Do ia64-specific expression optimization. All that's done here is
7781 to transform index expressions that are either due to the indexing
7782 of rotating registers or due to the indexing of indirect register
7785 ia64_optimize_expr (l
, op
, r
)
7794 if (l
->X_op
== O_register
&& r
->X_op
== O_constant
)
7796 num_regs
= (l
->X_add_number
>> 16);
7797 if ((unsigned) r
->X_add_number
>= num_regs
)
7800 as_bad ("No current frame");
7802 as_bad ("Index out of range 0..%u", num_regs
- 1);
7803 r
->X_add_number
= 0;
7805 l
->X_add_number
= (l
->X_add_number
& 0xffff) + r
->X_add_number
;
7808 else if (l
->X_op
== O_register
&& r
->X_op
== O_register
)
7810 if (l
->X_add_number
< IND_CPUID
|| l
->X_add_number
> IND_RR
7811 || l
->X_add_number
== IND_MEM
)
7813 as_bad ("Indirect register set name expected");
7814 l
->X_add_number
= IND_CPUID
;
7817 l
->X_op_symbol
= md
.regsym
[l
->X_add_number
];
7818 l
->X_add_number
= r
->X_add_number
;
7826 ia64_parse_name (name
, e
, nextcharP
)
7831 struct const_desc
*cdesc
;
7832 struct dynreg
*dr
= 0;
7839 enum pseudo_type pseudo_type
= PSEUDO_FUNC_NONE
;
7841 /* Find what relocation pseudo-function we're dealing with. */
7842 for (idx
= 0; idx
< NELEMS (pseudo_func
); ++idx
)
7843 if (pseudo_func
[idx
].name
7844 && pseudo_func
[idx
].name
[0] == name
[1]
7845 && strcmp (pseudo_func
[idx
].name
+ 1, name
+ 2) == 0)
7847 pseudo_type
= pseudo_func
[idx
].type
;
7850 switch (pseudo_type
)
7852 case PSEUDO_FUNC_RELOC
:
7853 end
= input_line_pointer
;
7854 if (*nextcharP
!= '(')
7856 as_bad ("Expected '('");
7860 ++input_line_pointer
;
7862 if (*input_line_pointer
!= ')')
7864 as_bad ("Missing ')'");
7868 ++input_line_pointer
;
7869 if (e
->X_op
!= O_symbol
)
7871 if (e
->X_op
!= O_pseudo_fixup
)
7873 as_bad ("Not a symbolic expression");
7876 if (idx
!= FUNC_LT_RELATIVE
)
7878 as_bad ("Illegal combination of relocation functions");
7881 switch (S_GET_VALUE (e
->X_op_symbol
))
7883 case FUNC_FPTR_RELATIVE
:
7884 idx
= FUNC_LT_FPTR_RELATIVE
; break;
7885 case FUNC_DTP_MODULE
:
7886 idx
= FUNC_LT_DTP_MODULE
; break;
7887 case FUNC_DTP_RELATIVE
:
7888 idx
= FUNC_LT_DTP_RELATIVE
; break;
7889 case FUNC_TP_RELATIVE
:
7890 idx
= FUNC_LT_TP_RELATIVE
; break;
7892 as_bad ("Illegal combination of relocation functions");
7896 /* Make sure gas doesn't get rid of local symbols that are used
7898 e
->X_op
= O_pseudo_fixup
;
7899 e
->X_op_symbol
= pseudo_func
[idx
].u
.sym
;
7901 *nextcharP
= *input_line_pointer
;
7904 case PSEUDO_FUNC_CONST
:
7905 e
->X_op
= O_constant
;
7906 e
->X_add_number
= pseudo_func
[idx
].u
.ival
;
7909 case PSEUDO_FUNC_REG
:
7910 e
->X_op
= O_register
;
7911 e
->X_add_number
= pseudo_func
[idx
].u
.ival
;
7920 /* first see if NAME is a known register name: */
7921 sym
= hash_find (md
.reg_hash
, name
);
7924 e
->X_op
= O_register
;
7925 e
->X_add_number
= S_GET_VALUE (sym
);
7929 cdesc
= hash_find (md
.const_hash
, name
);
7932 e
->X_op
= O_constant
;
7933 e
->X_add_number
= cdesc
->value
;
7937 /* check for inN, locN, or outN: */
7942 if (name
[1] == 'n' && ISDIGIT (name
[2]))
7950 if (name
[1] == 'o' && name
[2] == 'c' && ISDIGIT (name
[3]))
7958 if (name
[1] == 'u' && name
[2] == 't' && ISDIGIT (name
[3]))
7969 /* Ignore register numbers with leading zeroes, except zero itself. */
7970 if (dr
&& (name
[idx
] != '0' || name
[idx
+ 1] == '\0'))
7972 unsigned long regnum
;
7974 /* The name is inN, locN, or outN; parse the register number. */
7975 regnum
= strtoul (name
+ idx
, &end
, 10);
7976 if (end
> name
+ idx
&& *end
== '\0' && regnum
< 96)
7978 if (regnum
>= dr
->num_regs
)
7981 as_bad ("No current frame");
7983 as_bad ("Register number out of range 0..%u",
7987 e
->X_op
= O_register
;
7988 e
->X_add_number
= dr
->base
+ regnum
;
7993 end
= alloca (strlen (name
) + 1);
7995 name
= ia64_canonicalize_symbol_name (end
);
7996 if ((dr
= hash_find (md
.dynreg_hash
, name
)))
7998 /* We've got ourselves the name of a rotating register set.
7999 Store the base register number in the low 16 bits of
8000 X_add_number and the size of the register set in the top 16
8002 e
->X_op
= O_register
;
8003 e
->X_add_number
= dr
->base
| (dr
->num_regs
<< 16);
8009 /* Remove the '#' suffix that indicates a symbol as opposed to a register. */
8012 ia64_canonicalize_symbol_name (name
)
8015 size_t len
= strlen (name
), full
= len
;
8017 while (len
> 0 && name
[len
- 1] == '#')
8022 as_bad ("Standalone `#' is illegal");
8024 else if (len
< full
- 1)
8025 as_warn ("Redundant `#' suffix operators");
8030 /* Return true if idesc is a conditional branch instruction. This excludes
8031 the modulo scheduled branches, and br.ia. Mod-sched branches are excluded
8032 because they always read/write resources regardless of the value of the
8033 qualifying predicate. br.ia must always use p0, and hence is always
8034 taken. Thus this function returns true for branches which can fall
8035 through, and which use no resources if they do fall through. */
8038 is_conditional_branch (idesc
)
8039 struct ia64_opcode
*idesc
;
8041 /* br is a conditional branch. Everything that starts with br. except
8042 br.ia, br.c{loop,top,exit}, and br.w{top,exit} is a conditional branch.
8043 Everything that starts with brl is a conditional branch. */
8044 return (idesc
->name
[0] == 'b' && idesc
->name
[1] == 'r'
8045 && (idesc
->name
[2] == '\0'
8046 || (idesc
->name
[2] == '.' && idesc
->name
[3] != 'i'
8047 && idesc
->name
[3] != 'c' && idesc
->name
[3] != 'w')
8048 || idesc
->name
[2] == 'l'
8049 /* br.cond, br.call, br.clr */
8050 || (idesc
->name
[2] == '.' && idesc
->name
[3] == 'c'
8051 && (idesc
->name
[4] == 'a' || idesc
->name
[4] == 'o'
8052 || (idesc
->name
[4] == 'l' && idesc
->name
[5] == 'r')))));
8055 /* Return whether the given opcode is a taken branch. If there's any doubt,
8059 is_taken_branch (idesc
)
8060 struct ia64_opcode
*idesc
;
8062 return ((is_conditional_branch (idesc
) && CURR_SLOT
.qp_regno
== 0)
8063 || strncmp (idesc
->name
, "br.ia", 5) == 0);
8066 /* Return whether the given opcode is an interruption or rfi. If there's any
8067 doubt, returns zero. */
8070 is_interruption_or_rfi (idesc
)
8071 struct ia64_opcode
*idesc
;
8073 if (strcmp (idesc
->name
, "rfi") == 0)
8078 /* Returns the index of the given dependency in the opcode's list of chks, or
8079 -1 if there is no dependency. */
8082 depends_on (depind
, idesc
)
8084 struct ia64_opcode
*idesc
;
8087 const struct ia64_opcode_dependency
*dep
= idesc
->dependencies
;
8088 for (i
= 0; i
< dep
->nchks
; i
++)
8090 if (depind
== DEP (dep
->chks
[i
]))
8096 /* Determine a set of specific resources used for a particular resource
8097 class. Returns the number of specific resources identified For those
8098 cases which are not determinable statically, the resource returned is
8101 Meanings of value in 'NOTE':
8102 1) only read/write when the register number is explicitly encoded in the
8104 2) only read CFM when accessing a rotating GR, FR, or PR. mov pr only
8105 accesses CFM when qualifying predicate is in the rotating region.
8106 3) general register value is used to specify an indirect register; not
8107 determinable statically.
8108 4) only read the given resource when bits 7:0 of the indirect index
8109 register value does not match the register number of the resource; not
8110 determinable statically.
8111 5) all rules are implementation specific.
8112 6) only when both the index specified by the reader and the index specified
8113 by the writer have the same value in bits 63:61; not determinable
8115 7) only access the specified resource when the corresponding mask bit is
8117 8) PSR.dfh is only read when these insns reference FR32-127. PSR.dfl is
8118 only read when these insns reference FR2-31
8119 9) PSR.mfl is only written when these insns write FR2-31. PSR.mfh is only
8120 written when these insns write FR32-127
8121 10) The PSR.bn bit is only accessed when one of GR16-31 is specified in the
8123 11) The target predicates are written independently of PR[qp], but source
8124 registers are only read if PR[qp] is true. Since the state of PR[qp]
8125 cannot statically be determined, all source registers are marked used.
8126 12) This insn only reads the specified predicate register when that
8127 register is the PR[qp].
8128 13) This reference to ld-c only applies to teh GR whose value is loaded
8129 with data returned from memory, not the post-incremented address register.
8130 14) The RSE resource includes the implementation-specific RSE internal
8131 state resources. At least one (and possibly more) of these resources are
8132 read by each instruction listed in IC:rse-readers. At least one (and
8133 possibly more) of these resources are written by each insn listed in
8135 15+16) Represents reserved instructions, which the assembler does not
8138 Memory resources (i.e. locations in memory) are *not* marked or tracked by
8139 this code; there are no dependency violations based on memory access.
8142 #define MAX_SPECS 256
8147 specify_resource (dep
, idesc
, type
, specs
, note
, path
)
8148 const struct ia64_dependency
*dep
;
8149 struct ia64_opcode
*idesc
;
8150 int type
; /* is this a DV chk or a DV reg? */
8151 struct rsrc specs
[MAX_SPECS
]; /* returned specific resources */
8152 int note
; /* resource note for this insn's usage */
8153 int path
; /* which execution path to examine */
8160 if (dep
->mode
== IA64_DV_WAW
8161 || (dep
->mode
== IA64_DV_RAW
&& type
== DV_REG
)
8162 || (dep
->mode
== IA64_DV_WAR
&& type
== DV_CHK
))
8165 /* template for any resources we identify */
8166 tmpl
.dependency
= dep
;
8168 tmpl
.insn_srlz
= tmpl
.data_srlz
= 0;
8169 tmpl
.qp_regno
= CURR_SLOT
.qp_regno
;
8170 tmpl
.link_to_qp_branch
= 1;
8171 tmpl
.mem_offset
.hint
= 0;
8172 tmpl
.mem_offset
.offset
= 0;
8173 tmpl
.mem_offset
.base
= 0;
8176 tmpl
.cmp_type
= CMP_NONE
;
8183 as_warn (_("Unhandled dependency %s for %s (%s), note %d"), \
8184 dep->name, idesc->name, (rsrc_write?"write":"read"), note)
8185 #define KNOWN(REG) (gr_values[REG].known && gr_values[REG].path >= path)
8187 /* we don't need to track these */
8188 if (dep
->semantics
== IA64_DVS_NONE
)
8191 switch (dep
->specifier
)
8196 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8198 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8199 if (regno
>= 0 && regno
<= 7)
8201 specs
[count
] = tmpl
;
8202 specs
[count
++].index
= regno
;
8208 for (i
= 0; i
< 8; i
++)
8210 specs
[count
] = tmpl
;
8211 specs
[count
++].index
= i
;
8220 case IA64_RS_AR_UNAT
:
8221 /* This is a mov =AR or mov AR= instruction. */
8222 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8224 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8225 if (regno
== AR_UNAT
)
8227 specs
[count
++] = tmpl
;
8232 /* This is a spill/fill, or other instruction that modifies the
8235 /* Unless we can determine the specific bits used, mark the whole
8236 thing; bits 8:3 of the memory address indicate the bit used in
8237 UNAT. The .mem.offset hint may be used to eliminate a small
8238 subset of conflicts. */
8239 specs
[count
] = tmpl
;
8240 if (md
.mem_offset
.hint
)
8243 fprintf (stderr
, " Using hint for spill/fill\n");
8244 /* The index isn't actually used, just set it to something
8245 approximating the bit index. */
8246 specs
[count
].index
= (md
.mem_offset
.offset
>> 3) & 0x3F;
8247 specs
[count
].mem_offset
.hint
= 1;
8248 specs
[count
].mem_offset
.offset
= md
.mem_offset
.offset
;
8249 specs
[count
++].mem_offset
.base
= md
.mem_offset
.base
;
8253 specs
[count
++].specific
= 0;
8261 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8263 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8264 if ((regno
>= 8 && regno
<= 15)
8265 || (regno
>= 20 && regno
<= 23)
8266 || (regno
>= 31 && regno
<= 39)
8267 || (regno
>= 41 && regno
<= 47)
8268 || (regno
>= 67 && regno
<= 111))
8270 specs
[count
] = tmpl
;
8271 specs
[count
++].index
= regno
;
8284 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8286 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8287 if ((regno
>= 48 && regno
<= 63)
8288 || (regno
>= 112 && regno
<= 127))
8290 specs
[count
] = tmpl
;
8291 specs
[count
++].index
= regno
;
8297 for (i
= 48; i
< 64; i
++)
8299 specs
[count
] = tmpl
;
8300 specs
[count
++].index
= i
;
8302 for (i
= 112; i
< 128; i
++)
8304 specs
[count
] = tmpl
;
8305 specs
[count
++].index
= i
;
8323 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8324 if (idesc
->operands
[i
] == IA64_OPND_B1
8325 || idesc
->operands
[i
] == IA64_OPND_B2
)
8327 specs
[count
] = tmpl
;
8328 specs
[count
++].index
=
8329 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
8334 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
8335 if (idesc
->operands
[i
] == IA64_OPND_B1
8336 || idesc
->operands
[i
] == IA64_OPND_B2
)
8338 specs
[count
] = tmpl
;
8339 specs
[count
++].index
=
8340 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
8346 case IA64_RS_CPUID
: /* four or more registers */
8349 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CPUID_R3
)
8351 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8352 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8355 specs
[count
] = tmpl
;
8356 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8360 specs
[count
] = tmpl
;
8361 specs
[count
++].specific
= 0;
8371 case IA64_RS_DBR
: /* four or more registers */
8374 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_DBR_R3
)
8376 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8377 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8380 specs
[count
] = tmpl
;
8381 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8385 specs
[count
] = tmpl
;
8386 specs
[count
++].specific
= 0;
8390 else if (note
== 0 && !rsrc_write
)
8392 specs
[count
] = tmpl
;
8393 specs
[count
++].specific
= 0;
8401 case IA64_RS_IBR
: /* four or more registers */
8404 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_IBR_R3
)
8406 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8407 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8410 specs
[count
] = tmpl
;
8411 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8415 specs
[count
] = tmpl
;
8416 specs
[count
++].specific
= 0;
8429 /* These are implementation specific. Force all references to
8430 conflict with all other references. */
8431 specs
[count
] = tmpl
;
8432 specs
[count
++].specific
= 0;
8440 case IA64_RS_PKR
: /* 16 or more registers */
8441 if (note
== 3 || note
== 4)
8443 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PKR_R3
)
8445 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8446 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8451 specs
[count
] = tmpl
;
8452 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8455 for (i
= 0; i
< NELEMS (gr_values
); i
++)
8457 /* Uses all registers *except* the one in R3. */
8458 if ((unsigned)i
!= (gr_values
[regno
].value
& 0xFF))
8460 specs
[count
] = tmpl
;
8461 specs
[count
++].index
= i
;
8467 specs
[count
] = tmpl
;
8468 specs
[count
++].specific
= 0;
8475 specs
[count
] = tmpl
;
8476 specs
[count
++].specific
= 0;
8480 case IA64_RS_PMC
: /* four or more registers */
8483 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMC_R3
8484 || (!rsrc_write
&& idesc
->operands
[1] == IA64_OPND_PMD_R3
))
8487 int index
= ((idesc
->operands
[1] == IA64_OPND_R3
&& !rsrc_write
)
8489 int regno
= CURR_SLOT
.opnd
[index
].X_add_number
- REG_GR
;
8490 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8493 specs
[count
] = tmpl
;
8494 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8498 specs
[count
] = tmpl
;
8499 specs
[count
++].specific
= 0;
8509 case IA64_RS_PMD
: /* four or more registers */
8512 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMD_R3
)
8514 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8515 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8518 specs
[count
] = tmpl
;
8519 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8523 specs
[count
] = tmpl
;
8524 specs
[count
++].specific
= 0;
8534 case IA64_RS_RR
: /* eight registers */
8537 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_RR_R3
)
8539 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8540 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8543 specs
[count
] = tmpl
;
8544 specs
[count
++].index
= (gr_values
[regno
].value
>> 61) & 0x7;
8548 specs
[count
] = tmpl
;
8549 specs
[count
++].specific
= 0;
8553 else if (note
== 0 && !rsrc_write
)
8555 specs
[count
] = tmpl
;
8556 specs
[count
++].specific
= 0;
8564 case IA64_RS_CR_IRR
:
8567 /* handle mov-from-CR-IVR; it's a read that writes CR[IRR] */
8568 int regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
;
8570 && idesc
->operands
[1] == IA64_OPND_CR3
8573 for (i
= 0; i
< 4; i
++)
8575 specs
[count
] = tmpl
;
8576 specs
[count
++].index
= CR_IRR0
+ i
;
8582 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8583 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
8585 && regno
<= CR_IRR3
)
8587 specs
[count
] = tmpl
;
8588 specs
[count
++].index
= regno
;
8597 case IA64_RS_CR_LRR
:
8604 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8605 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
8606 && (regno
== CR_LRR0
|| regno
== CR_LRR1
))
8608 specs
[count
] = tmpl
;
8609 specs
[count
++].index
= regno
;
8617 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
8619 specs
[count
] = tmpl
;
8620 specs
[count
++].index
=
8621 CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8636 else if (rsrc_write
)
8638 if (dep
->specifier
== IA64_RS_FRb
8639 && idesc
->operands
[0] == IA64_OPND_F1
)
8641 specs
[count
] = tmpl
;
8642 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_FR
;
8647 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
8649 if (idesc
->operands
[i
] == IA64_OPND_F2
8650 || idesc
->operands
[i
] == IA64_OPND_F3
8651 || idesc
->operands
[i
] == IA64_OPND_F4
)
8653 specs
[count
] = tmpl
;
8654 specs
[count
++].index
=
8655 CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8664 /* This reference applies only to the GR whose value is loaded with
8665 data returned from memory. */
8666 specs
[count
] = tmpl
;
8667 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
8673 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8674 if (idesc
->operands
[i
] == IA64_OPND_R1
8675 || idesc
->operands
[i
] == IA64_OPND_R2
8676 || idesc
->operands
[i
] == IA64_OPND_R3
)
8678 specs
[count
] = tmpl
;
8679 specs
[count
++].index
=
8680 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8682 if (idesc
->flags
& IA64_OPCODE_POSTINC
)
8683 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8684 if (idesc
->operands
[i
] == IA64_OPND_MR3
)
8686 specs
[count
] = tmpl
;
8687 specs
[count
++].index
=
8688 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8693 /* Look for anything that reads a GR. */
8694 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8696 if (idesc
->operands
[i
] == IA64_OPND_MR3
8697 || idesc
->operands
[i
] == IA64_OPND_CPUID_R3
8698 || idesc
->operands
[i
] == IA64_OPND_DBR_R3
8699 || idesc
->operands
[i
] == IA64_OPND_IBR_R3
8700 || idesc
->operands
[i
] == IA64_OPND_MSR_R3
8701 || idesc
->operands
[i
] == IA64_OPND_PKR_R3
8702 || idesc
->operands
[i
] == IA64_OPND_PMC_R3
8703 || idesc
->operands
[i
] == IA64_OPND_PMD_R3
8704 || idesc
->operands
[i
] == IA64_OPND_RR_R3
8705 || ((i
>= idesc
->num_outputs
)
8706 && (idesc
->operands
[i
] == IA64_OPND_R1
8707 || idesc
->operands
[i
] == IA64_OPND_R2
8708 || idesc
->operands
[i
] == IA64_OPND_R3
8709 /* addl source register. */
8710 || idesc
->operands
[i
] == IA64_OPND_R3_2
)))
8712 specs
[count
] = tmpl
;
8713 specs
[count
++].index
=
8714 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8725 /* This is the same as IA64_RS_PRr, except that the register range is
8726 from 1 - 15, and there are no rotating register reads/writes here. */
8730 for (i
= 1; i
< 16; i
++)
8732 specs
[count
] = tmpl
;
8733 specs
[count
++].index
= i
;
8739 /* Mark only those registers indicated by the mask. */
8742 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8743 for (i
= 1; i
< 16; i
++)
8744 if (mask
& ((valueT
) 1 << i
))
8746 specs
[count
] = tmpl
;
8747 specs
[count
++].index
= i
;
8755 else if (note
== 11) /* note 11 implies note 1 as well */
8759 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8761 if (idesc
->operands
[i
] == IA64_OPND_P1
8762 || idesc
->operands
[i
] == IA64_OPND_P2
)
8764 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8765 if (regno
>= 1 && regno
< 16)
8767 specs
[count
] = tmpl
;
8768 specs
[count
++].index
= regno
;
8778 else if (note
== 12)
8780 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
8782 specs
[count
] = tmpl
;
8783 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8790 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8791 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8792 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8793 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8795 if ((idesc
->operands
[0] == IA64_OPND_P1
8796 || idesc
->operands
[0] == IA64_OPND_P2
)
8797 && p1
>= 1 && p1
< 16)
8799 specs
[count
] = tmpl
;
8800 specs
[count
].cmp_type
=
8801 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8802 specs
[count
++].index
= p1
;
8804 if ((idesc
->operands
[1] == IA64_OPND_P1
8805 || idesc
->operands
[1] == IA64_OPND_P2
)
8806 && p2
>= 1 && p2
< 16)
8808 specs
[count
] = tmpl
;
8809 specs
[count
].cmp_type
=
8810 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8811 specs
[count
++].index
= p2
;
8816 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
8818 specs
[count
] = tmpl
;
8819 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8821 if (idesc
->operands
[1] == IA64_OPND_PR
)
8823 for (i
= 1; i
< 16; i
++)
8825 specs
[count
] = tmpl
;
8826 specs
[count
++].index
= i
;
8837 /* This is the general case for PRs. IA64_RS_PR and IA64_RS_PR63 are
8838 simplified cases of this. */
8842 for (i
= 16; i
< 63; i
++)
8844 specs
[count
] = tmpl
;
8845 specs
[count
++].index
= i
;
8851 /* Mark only those registers indicated by the mask. */
8853 && idesc
->operands
[0] == IA64_OPND_PR
)
8855 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8856 if (mask
& ((valueT
) 1 << 16))
8857 for (i
= 16; i
< 63; i
++)
8859 specs
[count
] = tmpl
;
8860 specs
[count
++].index
= i
;
8864 && idesc
->operands
[0] == IA64_OPND_PR_ROT
)
8866 for (i
= 16; i
< 63; i
++)
8868 specs
[count
] = tmpl
;
8869 specs
[count
++].index
= i
;
8877 else if (note
== 11) /* note 11 implies note 1 as well */
8881 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8883 if (idesc
->operands
[i
] == IA64_OPND_P1
8884 || idesc
->operands
[i
] == IA64_OPND_P2
)
8886 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8887 if (regno
>= 16 && regno
< 63)
8889 specs
[count
] = tmpl
;
8890 specs
[count
++].index
= regno
;
8900 else if (note
== 12)
8902 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8904 specs
[count
] = tmpl
;
8905 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8912 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8913 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8914 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8915 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8917 if ((idesc
->operands
[0] == IA64_OPND_P1
8918 || idesc
->operands
[0] == IA64_OPND_P2
)
8919 && p1
>= 16 && p1
< 63)
8921 specs
[count
] = tmpl
;
8922 specs
[count
].cmp_type
=
8923 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8924 specs
[count
++].index
= p1
;
8926 if ((idesc
->operands
[1] == IA64_OPND_P1
8927 || idesc
->operands
[1] == IA64_OPND_P2
)
8928 && p2
>= 16 && p2
< 63)
8930 specs
[count
] = tmpl
;
8931 specs
[count
].cmp_type
=
8932 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8933 specs
[count
++].index
= p2
;
8938 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8940 specs
[count
] = tmpl
;
8941 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8943 if (idesc
->operands
[1] == IA64_OPND_PR
)
8945 for (i
= 16; i
< 63; i
++)
8947 specs
[count
] = tmpl
;
8948 specs
[count
++].index
= i
;
8960 /* Verify that the instruction is using the PSR bit indicated in
8964 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_UM
)
8966 if (dep
->regindex
< 6)
8968 specs
[count
++] = tmpl
;
8971 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR
)
8973 if (dep
->regindex
< 32
8974 || dep
->regindex
== 35
8975 || dep
->regindex
== 36
8976 || (!rsrc_write
&& dep
->regindex
== PSR_CPL
))
8978 specs
[count
++] = tmpl
;
8981 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_L
)
8983 if (dep
->regindex
< 32
8984 || dep
->regindex
== 35
8985 || dep
->regindex
== 36
8986 || (rsrc_write
&& dep
->regindex
== PSR_CPL
))
8988 specs
[count
++] = tmpl
;
8993 /* Several PSR bits have very specific dependencies. */
8994 switch (dep
->regindex
)
8997 specs
[count
++] = tmpl
;
9002 specs
[count
++] = tmpl
;
9006 /* Only certain CR accesses use PSR.ic */
9007 if (idesc
->operands
[0] == IA64_OPND_CR3
9008 || idesc
->operands
[1] == IA64_OPND_CR3
)
9011 ((idesc
->operands
[0] == IA64_OPND_CR3
)
9014 CURR_SLOT
.opnd
[index
].X_add_number
- REG_CR
;
9029 specs
[count
++] = tmpl
;
9038 specs
[count
++] = tmpl
;
9042 /* Only some AR accesses use cpl */
9043 if (idesc
->operands
[0] == IA64_OPND_AR3
9044 || idesc
->operands
[1] == IA64_OPND_AR3
)
9047 ((idesc
->operands
[0] == IA64_OPND_AR3
)
9050 CURR_SLOT
.opnd
[index
].X_add_number
- REG_AR
;
9057 && regno
<= AR_K7
))))
9059 specs
[count
++] = tmpl
;
9064 specs
[count
++] = tmpl
;
9074 if (idesc
->operands
[0] == IA64_OPND_IMMU24
)
9076 mask
= CURR_SLOT
.opnd
[0].X_add_number
;
9082 if (mask
& ((valueT
) 1 << dep
->regindex
))
9084 specs
[count
++] = tmpl
;
9089 int min
= dep
->regindex
== PSR_DFL
? 2 : 32;
9090 int max
= dep
->regindex
== PSR_DFL
? 31 : 127;
9091 /* dfh is read on FR32-127; dfl is read on FR2-31 */
9092 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
9094 if (idesc
->operands
[i
] == IA64_OPND_F1
9095 || idesc
->operands
[i
] == IA64_OPND_F2
9096 || idesc
->operands
[i
] == IA64_OPND_F3
9097 || idesc
->operands
[i
] == IA64_OPND_F4
)
9099 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
9100 if (reg
>= min
&& reg
<= max
)
9102 specs
[count
++] = tmpl
;
9109 int min
= dep
->regindex
== PSR_MFL
? 2 : 32;
9110 int max
= dep
->regindex
== PSR_MFL
? 31 : 127;
9111 /* mfh is read on writes to FR32-127; mfl is read on writes to
9113 for (i
= 0; i
< idesc
->num_outputs
; i
++)
9115 if (idesc
->operands
[i
] == IA64_OPND_F1
)
9117 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
9118 if (reg
>= min
&& reg
<= max
)
9120 specs
[count
++] = tmpl
;
9125 else if (note
== 10)
9127 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
9129 if (idesc
->operands
[i
] == IA64_OPND_R1
9130 || idesc
->operands
[i
] == IA64_OPND_R2
9131 || idesc
->operands
[i
] == IA64_OPND_R3
)
9133 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9134 if (regno
>= 16 && regno
<= 31)
9136 specs
[count
++] = tmpl
;
9147 case IA64_RS_AR_FPSR
:
9148 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
9150 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
9151 if (regno
== AR_FPSR
)
9153 specs
[count
++] = tmpl
;
9158 specs
[count
++] = tmpl
;
9163 /* Handle all AR[REG] resources */
9164 if (note
== 0 || note
== 1)
9166 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
9167 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
9168 && regno
== dep
->regindex
)
9170 specs
[count
++] = tmpl
;
9172 /* other AR[REG] resources may be affected by AR accesses */
9173 else if (idesc
->operands
[0] == IA64_OPND_AR3
)
9176 regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
;
9177 switch (dep
->regindex
)
9183 if (regno
== AR_BSPSTORE
)
9185 specs
[count
++] = tmpl
;
9189 (regno
== AR_BSPSTORE
9190 || regno
== AR_RNAT
))
9192 specs
[count
++] = tmpl
;
9197 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
9200 regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
;
9201 switch (dep
->regindex
)
9206 if (regno
== AR_BSPSTORE
|| regno
== AR_RNAT
)
9208 specs
[count
++] = tmpl
;
9215 specs
[count
++] = tmpl
;
9225 /* Handle all CR[REG] resources */
9226 if (note
== 0 || note
== 1)
9228 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
9230 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
9231 if (regno
== dep
->regindex
)
9233 specs
[count
++] = tmpl
;
9235 else if (!rsrc_write
)
9237 /* Reads from CR[IVR] affect other resources. */
9238 if (regno
== CR_IVR
)
9240 if ((dep
->regindex
>= CR_IRR0
9241 && dep
->regindex
<= CR_IRR3
)
9242 || dep
->regindex
== CR_TPR
)
9244 specs
[count
++] = tmpl
;
9251 specs
[count
++] = tmpl
;
9260 case IA64_RS_INSERVICE
:
9261 /* look for write of EOI (67) or read of IVR (65) */
9262 if ((idesc
->operands
[0] == IA64_OPND_CR3
9263 && CURR_SLOT
.opnd
[0].X_add_number
- REG_CR
== CR_EOI
)
9264 || (idesc
->operands
[1] == IA64_OPND_CR3
9265 && CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
== CR_IVR
))
9267 specs
[count
++] = tmpl
;
9274 specs
[count
++] = tmpl
;
9285 specs
[count
++] = tmpl
;
9289 /* Check if any of the registers accessed are in the rotating region.
9290 mov to/from pr accesses CFM only when qp_regno is in the rotating
9292 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
9294 if (idesc
->operands
[i
] == IA64_OPND_R1
9295 || idesc
->operands
[i
] == IA64_OPND_R2
9296 || idesc
->operands
[i
] == IA64_OPND_R3
)
9298 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9299 /* Assumes that md.rot.num_regs is always valid */
9300 if (md
.rot
.num_regs
> 0
9302 && num
< 31 + md
.rot
.num_regs
)
9304 specs
[count
] = tmpl
;
9305 specs
[count
++].specific
= 0;
9308 else if (idesc
->operands
[i
] == IA64_OPND_F1
9309 || idesc
->operands
[i
] == IA64_OPND_F2
9310 || idesc
->operands
[i
] == IA64_OPND_F3
9311 || idesc
->operands
[i
] == IA64_OPND_F4
)
9313 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
9316 specs
[count
] = tmpl
;
9317 specs
[count
++].specific
= 0;
9320 else if (idesc
->operands
[i
] == IA64_OPND_P1
9321 || idesc
->operands
[i
] == IA64_OPND_P2
)
9323 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
9326 specs
[count
] = tmpl
;
9327 specs
[count
++].specific
= 0;
9331 if (CURR_SLOT
.qp_regno
> 15)
9333 specs
[count
] = tmpl
;
9334 specs
[count
++].specific
= 0;
9339 /* This is the same as IA64_RS_PRr, except simplified to account for
9340 the fact that there is only one register. */
9344 specs
[count
++] = tmpl
;
9349 if (idesc
->operands
[2] == IA64_OPND_IMM17
)
9350 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
9351 if (mask
& ((valueT
) 1 << 63))
9352 specs
[count
++] = tmpl
;
9354 else if (note
== 11)
9356 if ((idesc
->operands
[0] == IA64_OPND_P1
9357 && CURR_SLOT
.opnd
[0].X_add_number
- REG_P
== 63)
9358 || (idesc
->operands
[1] == IA64_OPND_P2
9359 && CURR_SLOT
.opnd
[1].X_add_number
- REG_P
== 63))
9361 specs
[count
++] = tmpl
;
9364 else if (note
== 12)
9366 if (CURR_SLOT
.qp_regno
== 63)
9368 specs
[count
++] = tmpl
;
9375 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
9376 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
9377 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
9378 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
9381 && (idesc
->operands
[0] == IA64_OPND_P1
9382 || idesc
->operands
[0] == IA64_OPND_P2
))
9384 specs
[count
] = tmpl
;
9385 specs
[count
++].cmp_type
=
9386 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
9389 && (idesc
->operands
[1] == IA64_OPND_P1
9390 || idesc
->operands
[1] == IA64_OPND_P2
))
9392 specs
[count
] = tmpl
;
9393 specs
[count
++].cmp_type
=
9394 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
9399 if (CURR_SLOT
.qp_regno
== 63)
9401 specs
[count
++] = tmpl
;
9412 /* FIXME we can identify some individual RSE written resources, but RSE
9413 read resources have not yet been completely identified, so for now
9414 treat RSE as a single resource */
9415 if (strncmp (idesc
->name
, "mov", 3) == 0)
9419 if (idesc
->operands
[0] == IA64_OPND_AR3
9420 && CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
)
9422 specs
[count
++] = tmpl
;
9427 if (idesc
->operands
[0] == IA64_OPND_AR3
)
9429 if (CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
9430 || CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_RNAT
)
9432 specs
[count
++] = tmpl
;
9435 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
9437 if (CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSP
9438 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSPSTORE
9439 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_RNAT
)
9441 specs
[count
++] = tmpl
;
9448 specs
[count
++] = tmpl
;
9453 /* FIXME -- do any of these need to be non-specific? */
9454 specs
[count
++] = tmpl
;
9458 as_bad (_("Unrecognized dependency specifier %d\n"), dep
->specifier
);
9465 /* Clear branch flags on marked resources. This breaks the link between the
9466 QP of the marking instruction and a subsequent branch on the same QP. */
9469 clear_qp_branch_flag (mask
)
9473 for (i
= 0; i
< regdepslen
; i
++)
9475 valueT bit
= ((valueT
) 1 << regdeps
[i
].qp_regno
);
9476 if ((bit
& mask
) != 0)
9478 regdeps
[i
].link_to_qp_branch
= 0;
9483 /* MASK contains 2 and only 2 PRs which are mutually exclusive. Remove
9484 any mutexes which contain one of the PRs and create new ones when
9488 update_qp_mutex (valueT mask
)
9494 while (i
< qp_mutexeslen
)
9496 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
9498 /* If it destroys and creates the same mutex, do nothing. */
9499 if (qp_mutexes
[i
].prmask
== mask
9500 && qp_mutexes
[i
].path
== md
.path
)
9511 fprintf (stderr
, " Clearing mutex relation");
9512 print_prmask (qp_mutexes
[i
].prmask
);
9513 fprintf (stderr
, "\n");
9516 /* Deal with the old mutex with more than 3+ PRs only if
9517 the new mutex on the same execution path with it.
9519 FIXME: The 3+ mutex support is incomplete.
9520 dot_pred_rel () may be a better place to fix it. */
9521 if (qp_mutexes
[i
].path
== md
.path
)
9523 /* If it is a proper subset of the mutex, create a
9526 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
9529 qp_mutexes
[i
].prmask
&= ~mask
;
9530 if (qp_mutexes
[i
].prmask
& (qp_mutexes
[i
].prmask
- 1))
9532 /* Modify the mutex if there are more than one
9540 /* Remove the mutex. */
9541 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
9549 add_qp_mutex (mask
);
9554 /* Remove any mutexes which contain any of the PRs indicated in the mask.
9556 Any changes to a PR clears the mutex relations which include that PR. */
9559 clear_qp_mutex (mask
)
9565 while (i
< qp_mutexeslen
)
9567 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
9571 fprintf (stderr
, " Clearing mutex relation");
9572 print_prmask (qp_mutexes
[i
].prmask
);
9573 fprintf (stderr
, "\n");
9575 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
9582 /* Clear implies relations which contain PRs in the given masks.
9583 P1_MASK indicates the source of the implies relation, while P2_MASK
9584 indicates the implied PR. */
9587 clear_qp_implies (p1_mask
, p2_mask
)
9594 while (i
< qp_implieslen
)
9596 if ((((valueT
) 1 << qp_implies
[i
].p1
) & p1_mask
) != 0
9597 || (((valueT
) 1 << qp_implies
[i
].p2
) & p2_mask
) != 0)
9600 fprintf (stderr
, "Clearing implied relation PR%d->PR%d\n",
9601 qp_implies
[i
].p1
, qp_implies
[i
].p2
);
9602 qp_implies
[i
] = qp_implies
[--qp_implieslen
];
9609 /* Add the PRs specified to the list of implied relations. */
9612 add_qp_imply (p1
, p2
)
9619 /* p0 is not meaningful here. */
9620 if (p1
== 0 || p2
== 0)
9626 /* If it exists already, ignore it. */
9627 for (i
= 0; i
< qp_implieslen
; i
++)
9629 if (qp_implies
[i
].p1
== p1
9630 && qp_implies
[i
].p2
== p2
9631 && qp_implies
[i
].path
== md
.path
9632 && !qp_implies
[i
].p2_branched
)
9636 if (qp_implieslen
== qp_impliestotlen
)
9638 qp_impliestotlen
+= 20;
9639 qp_implies
= (struct qp_imply
*)
9640 xrealloc ((void *) qp_implies
,
9641 qp_impliestotlen
* sizeof (struct qp_imply
));
9644 fprintf (stderr
, " Registering PR%d implies PR%d\n", p1
, p2
);
9645 qp_implies
[qp_implieslen
].p1
= p1
;
9646 qp_implies
[qp_implieslen
].p2
= p2
;
9647 qp_implies
[qp_implieslen
].path
= md
.path
;
9648 qp_implies
[qp_implieslen
++].p2_branched
= 0;
9650 /* Add in the implied transitive relations; for everything that p2 implies,
9651 make p1 imply that, too; for everything that implies p1, make it imply p2
9653 for (i
= 0; i
< qp_implieslen
; i
++)
9655 if (qp_implies
[i
].p1
== p2
)
9656 add_qp_imply (p1
, qp_implies
[i
].p2
);
9657 if (qp_implies
[i
].p2
== p1
)
9658 add_qp_imply (qp_implies
[i
].p1
, p2
);
9660 /* Add in mutex relations implied by this implies relation; for each mutex
9661 relation containing p2, duplicate it and replace p2 with p1. */
9662 bit
= (valueT
) 1 << p1
;
9663 mask
= (valueT
) 1 << p2
;
9664 for (i
= 0; i
< qp_mutexeslen
; i
++)
9666 if (qp_mutexes
[i
].prmask
& mask
)
9667 add_qp_mutex ((qp_mutexes
[i
].prmask
& ~mask
) | bit
);
9671 /* Add the PRs specified in the mask to the mutex list; this means that only
9672 one of the PRs can be true at any time. PR0 should never be included in
9682 if (qp_mutexeslen
== qp_mutexestotlen
)
9684 qp_mutexestotlen
+= 20;
9685 qp_mutexes
= (struct qpmutex
*)
9686 xrealloc ((void *) qp_mutexes
,
9687 qp_mutexestotlen
* sizeof (struct qpmutex
));
9691 fprintf (stderr
, " Registering mutex on");
9692 print_prmask (mask
);
9693 fprintf (stderr
, "\n");
9695 qp_mutexes
[qp_mutexeslen
].path
= md
.path
;
9696 qp_mutexes
[qp_mutexeslen
++].prmask
= mask
;
9700 has_suffix_p (name
, suffix
)
9704 size_t namelen
= strlen (name
);
9705 size_t sufflen
= strlen (suffix
);
9707 if (namelen
<= sufflen
)
9709 return strcmp (name
+ namelen
- sufflen
, suffix
) == 0;
9713 clear_register_values ()
9717 fprintf (stderr
, " Clearing register values\n");
9718 for (i
= 1; i
< NELEMS (gr_values
); i
++)
9719 gr_values
[i
].known
= 0;
9722 /* Keep track of register values/changes which affect DV tracking.
9724 optimization note: should add a flag to classes of insns where otherwise we
9725 have to examine a group of strings to identify them. */
9728 note_register_values (idesc
)
9729 struct ia64_opcode
*idesc
;
9731 valueT qp_changemask
= 0;
9734 /* Invalidate values for registers being written to. */
9735 for (i
= 0; i
< idesc
->num_outputs
; i
++)
9737 if (idesc
->operands
[i
] == IA64_OPND_R1
9738 || idesc
->operands
[i
] == IA64_OPND_R2
9739 || idesc
->operands
[i
] == IA64_OPND_R3
)
9741 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9742 if (regno
> 0 && regno
< NELEMS (gr_values
))
9743 gr_values
[regno
].known
= 0;
9745 else if (idesc
->operands
[i
] == IA64_OPND_R3_2
)
9747 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9748 if (regno
> 0 && regno
< 4)
9749 gr_values
[regno
].known
= 0;
9751 else if (idesc
->operands
[i
] == IA64_OPND_P1
9752 || idesc
->operands
[i
] == IA64_OPND_P2
)
9754 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
9755 qp_changemask
|= (valueT
) 1 << regno
;
9757 else if (idesc
->operands
[i
] == IA64_OPND_PR
)
9759 if (idesc
->operands
[2] & (valueT
) 0x10000)
9760 qp_changemask
= ~(valueT
) 0x1FFFF | idesc
->operands
[2];
9762 qp_changemask
= idesc
->operands
[2];
9765 else if (idesc
->operands
[i
] == IA64_OPND_PR_ROT
)
9767 if (idesc
->operands
[1] & ((valueT
) 1 << 43))
9768 qp_changemask
= -((valueT
) 1 << 44) | idesc
->operands
[1];
9770 qp_changemask
= idesc
->operands
[1];
9771 qp_changemask
&= ~(valueT
) 0xFFFF;
9776 /* Always clear qp branch flags on any PR change. */
9777 /* FIXME there may be exceptions for certain compares. */
9778 clear_qp_branch_flag (qp_changemask
);
9780 /* Invalidate rotating registers on insns which affect RRBs in CFM. */
9781 if (idesc
->flags
& IA64_OPCODE_MOD_RRBS
)
9783 qp_changemask
|= ~(valueT
) 0xFFFF;
9784 if (strcmp (idesc
->name
, "clrrrb.pr") != 0)
9786 for (i
= 32; i
< 32 + md
.rot
.num_regs
; i
++)
9787 gr_values
[i
].known
= 0;
9789 clear_qp_mutex (qp_changemask
);
9790 clear_qp_implies (qp_changemask
, qp_changemask
);
9792 /* After a call, all register values are undefined, except those marked
9794 else if (strncmp (idesc
->name
, "br.call", 6) == 0
9795 || strncmp (idesc
->name
, "brl.call", 7) == 0)
9797 /* FIXME keep GR values which are marked as "safe_across_calls" */
9798 clear_register_values ();
9799 clear_qp_mutex (~qp_safe_across_calls
);
9800 clear_qp_implies (~qp_safe_across_calls
, ~qp_safe_across_calls
);
9801 clear_qp_branch_flag (~qp_safe_across_calls
);
9803 else if (is_interruption_or_rfi (idesc
)
9804 || is_taken_branch (idesc
))
9806 clear_register_values ();
9807 clear_qp_mutex (~(valueT
) 0);
9808 clear_qp_implies (~(valueT
) 0, ~(valueT
) 0);
9810 /* Look for mutex and implies relations. */
9811 else if ((idesc
->operands
[0] == IA64_OPND_P1
9812 || idesc
->operands
[0] == IA64_OPND_P2
)
9813 && (idesc
->operands
[1] == IA64_OPND_P1
9814 || idesc
->operands
[1] == IA64_OPND_P2
))
9816 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
9817 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
9818 valueT p1mask
= (p1
!= 0) ? (valueT
) 1 << p1
: 0;
9819 valueT p2mask
= (p2
!= 0) ? (valueT
) 1 << p2
: 0;
9821 /* If both PRs are PR0, we can't really do anything. */
9822 if (p1
== 0 && p2
== 0)
9825 fprintf (stderr
, " Ignoring PRs due to inclusion of p0\n");
9827 /* In general, clear mutexes and implies which include P1 or P2,
9828 with the following exceptions. */
9829 else if (has_suffix_p (idesc
->name
, ".or.andcm")
9830 || has_suffix_p (idesc
->name
, ".and.orcm"))
9832 clear_qp_implies (p2mask
, p1mask
);
9834 else if (has_suffix_p (idesc
->name
, ".andcm")
9835 || has_suffix_p (idesc
->name
, ".and"))
9837 clear_qp_implies (0, p1mask
| p2mask
);
9839 else if (has_suffix_p (idesc
->name
, ".orcm")
9840 || has_suffix_p (idesc
->name
, ".or"))
9842 clear_qp_mutex (p1mask
| p2mask
);
9843 clear_qp_implies (p1mask
| p2mask
, 0);
9849 clear_qp_implies (p1mask
| p2mask
, p1mask
| p2mask
);
9851 /* If one of the PRs is PR0, we call clear_qp_mutex. */
9852 if (p1
== 0 || p2
== 0)
9853 clear_qp_mutex (p1mask
| p2mask
);
9855 added
= update_qp_mutex (p1mask
| p2mask
);
9857 if (CURR_SLOT
.qp_regno
== 0
9858 || has_suffix_p (idesc
->name
, ".unc"))
9860 if (added
== 0 && p1
&& p2
)
9861 add_qp_mutex (p1mask
| p2mask
);
9862 if (CURR_SLOT
.qp_regno
!= 0)
9865 add_qp_imply (p1
, CURR_SLOT
.qp_regno
);
9867 add_qp_imply (p2
, CURR_SLOT
.qp_regno
);
9872 /* Look for mov imm insns into GRs. */
9873 else if (idesc
->operands
[0] == IA64_OPND_R1
9874 && (idesc
->operands
[1] == IA64_OPND_IMM22
9875 || idesc
->operands
[1] == IA64_OPND_IMMU64
)
9876 && CURR_SLOT
.opnd
[1].X_op
== O_constant
9877 && (strcmp (idesc
->name
, "mov") == 0
9878 || strcmp (idesc
->name
, "movl") == 0))
9880 int regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
9881 if (regno
> 0 && regno
< NELEMS (gr_values
))
9883 gr_values
[regno
].known
= 1;
9884 gr_values
[regno
].value
= CURR_SLOT
.opnd
[1].X_add_number
;
9885 gr_values
[regno
].path
= md
.path
;
9888 fprintf (stderr
, " Know gr%d = ", regno
);
9889 fprintf_vma (stderr
, gr_values
[regno
].value
);
9890 fputs ("\n", stderr
);
9894 /* Look for dep.z imm insns. */
9895 else if (idesc
->operands
[0] == IA64_OPND_R1
9896 && idesc
->operands
[1] == IA64_OPND_IMM8
9897 && strcmp (idesc
->name
, "dep.z") == 0)
9899 int regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
9900 if (regno
> 0 && regno
< NELEMS (gr_values
))
9902 valueT value
= CURR_SLOT
.opnd
[1].X_add_number
;
9904 if (CURR_SLOT
.opnd
[3].X_add_number
< 64)
9905 value
&= ((valueT
)1 << CURR_SLOT
.opnd
[3].X_add_number
) - 1;
9906 value
<<= CURR_SLOT
.opnd
[2].X_add_number
;
9907 gr_values
[regno
].known
= 1;
9908 gr_values
[regno
].value
= value
;
9909 gr_values
[regno
].path
= md
.path
;
9912 fprintf (stderr
, " Know gr%d = ", regno
);
9913 fprintf_vma (stderr
, gr_values
[regno
].value
);
9914 fputs ("\n", stderr
);
9920 clear_qp_mutex (qp_changemask
);
9921 clear_qp_implies (qp_changemask
, qp_changemask
);
9925 /* Return whether the given predicate registers are currently mutex. */
9928 qp_mutex (p1
, p2
, path
)
9938 mask
= ((valueT
) 1 << p1
) | (valueT
) 1 << p2
;
9939 for (i
= 0; i
< qp_mutexeslen
; i
++)
9941 if (qp_mutexes
[i
].path
>= path
9942 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
9949 /* Return whether the given resource is in the given insn's list of chks
9950 Return 1 if the conflict is absolutely determined, 2 if it's a potential
9954 resources_match (rs
, idesc
, note
, qp_regno
, path
)
9956 struct ia64_opcode
*idesc
;
9961 struct rsrc specs
[MAX_SPECS
];
9964 /* If the marked resource's qp_regno and the given qp_regno are mutex,
9965 we don't need to check. One exception is note 11, which indicates that
9966 target predicates are written regardless of PR[qp]. */
9967 if (qp_mutex (rs
->qp_regno
, qp_regno
, path
)
9971 count
= specify_resource (rs
->dependency
, idesc
, DV_CHK
, specs
, note
, path
);
9974 /* UNAT checking is a bit more specific than other resources */
9975 if (rs
->dependency
->specifier
== IA64_RS_AR_UNAT
9976 && specs
[count
].mem_offset
.hint
9977 && rs
->mem_offset
.hint
)
9979 if (rs
->mem_offset
.base
== specs
[count
].mem_offset
.base
)
9981 if (((rs
->mem_offset
.offset
>> 3) & 0x3F) ==
9982 ((specs
[count
].mem_offset
.offset
>> 3) & 0x3F))
9989 /* Skip apparent PR write conflicts where both writes are an AND or both
9990 writes are an OR. */
9991 if (rs
->dependency
->specifier
== IA64_RS_PR
9992 || rs
->dependency
->specifier
== IA64_RS_PRr
9993 || rs
->dependency
->specifier
== IA64_RS_PR63
)
9995 if (specs
[count
].cmp_type
!= CMP_NONE
9996 && specs
[count
].cmp_type
== rs
->cmp_type
)
9999 fprintf (stderr
, " %s on parallel compare allowed (PR%d)\n",
10000 dv_mode
[rs
->dependency
->mode
],
10001 rs
->dependency
->specifier
!= IA64_RS_PR63
?
10002 specs
[count
].index
: 63);
10007 " %s on parallel compare conflict %s vs %s on PR%d\n",
10008 dv_mode
[rs
->dependency
->mode
],
10009 dv_cmp_type
[rs
->cmp_type
],
10010 dv_cmp_type
[specs
[count
].cmp_type
],
10011 rs
->dependency
->specifier
!= IA64_RS_PR63
?
10012 specs
[count
].index
: 63);
10016 /* If either resource is not specific, conservatively assume a conflict
10018 if (!specs
[count
].specific
|| !rs
->specific
)
10020 else if (specs
[count
].index
== rs
->index
)
10027 /* Indicate an instruction group break; if INSERT_STOP is non-zero, then
10028 insert a stop to create the break. Update all resource dependencies
10029 appropriately. If QP_REGNO is non-zero, only apply the break to resources
10030 which use the same QP_REGNO and have the link_to_qp_branch flag set.
10031 If SAVE_CURRENT is non-zero, don't affect resources marked by the current
10035 insn_group_break (insert_stop
, qp_regno
, save_current
)
10042 if (insert_stop
&& md
.num_slots_in_use
> 0)
10043 PREV_SLOT
.end_of_insn_group
= 1;
10047 fprintf (stderr
, " Insn group break%s",
10048 (insert_stop
? " (w/stop)" : ""));
10050 fprintf (stderr
, " effective for QP=%d", qp_regno
);
10051 fprintf (stderr
, "\n");
10055 while (i
< regdepslen
)
10057 const struct ia64_dependency
*dep
= regdeps
[i
].dependency
;
10060 && regdeps
[i
].qp_regno
!= qp_regno
)
10067 && CURR_SLOT
.src_file
== regdeps
[i
].file
10068 && CURR_SLOT
.src_line
== regdeps
[i
].line
)
10074 /* clear dependencies which are automatically cleared by a stop, or
10075 those that have reached the appropriate state of insn serialization */
10076 if (dep
->semantics
== IA64_DVS_IMPLIED
10077 || dep
->semantics
== IA64_DVS_IMPLIEDF
10078 || regdeps
[i
].insn_srlz
== STATE_SRLZ
)
10080 print_dependency ("Removing", i
);
10081 regdeps
[i
] = regdeps
[--regdepslen
];
10085 if (dep
->semantics
== IA64_DVS_DATA
10086 || dep
->semantics
== IA64_DVS_INSTR
10087 || dep
->semantics
== IA64_DVS_SPECIFIC
)
10089 if (regdeps
[i
].insn_srlz
== STATE_NONE
)
10090 regdeps
[i
].insn_srlz
= STATE_STOP
;
10091 if (regdeps
[i
].data_srlz
== STATE_NONE
)
10092 regdeps
[i
].data_srlz
= STATE_STOP
;
10099 /* Add the given resource usage spec to the list of active dependencies. */
10102 mark_resource (idesc
, dep
, spec
, depind
, path
)
10103 struct ia64_opcode
*idesc ATTRIBUTE_UNUSED
;
10104 const struct ia64_dependency
*dep ATTRIBUTE_UNUSED
;
10109 if (regdepslen
== regdepstotlen
)
10111 regdepstotlen
+= 20;
10112 regdeps
= (struct rsrc
*)
10113 xrealloc ((void *) regdeps
,
10114 regdepstotlen
* sizeof (struct rsrc
));
10117 regdeps
[regdepslen
] = *spec
;
10118 regdeps
[regdepslen
].depind
= depind
;
10119 regdeps
[regdepslen
].path
= path
;
10120 regdeps
[regdepslen
].file
= CURR_SLOT
.src_file
;
10121 regdeps
[regdepslen
].line
= CURR_SLOT
.src_line
;
10123 print_dependency ("Adding", regdepslen
);
10129 print_dependency (action
, depind
)
10130 const char *action
;
10135 fprintf (stderr
, " %s %s '%s'",
10136 action
, dv_mode
[(regdeps
[depind
].dependency
)->mode
],
10137 (regdeps
[depind
].dependency
)->name
);
10138 if (regdeps
[depind
].specific
&& regdeps
[depind
].index
>= 0)
10139 fprintf (stderr
, " (%d)", regdeps
[depind
].index
);
10140 if (regdeps
[depind
].mem_offset
.hint
)
10142 fputs (" ", stderr
);
10143 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.base
);
10144 fputs ("+", stderr
);
10145 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.offset
);
10147 fprintf (stderr
, "\n");
10152 instruction_serialization ()
10156 fprintf (stderr
, " Instruction serialization\n");
10157 for (i
= 0; i
< regdepslen
; i
++)
10158 if (regdeps
[i
].insn_srlz
== STATE_STOP
)
10159 regdeps
[i
].insn_srlz
= STATE_SRLZ
;
10163 data_serialization ()
10167 fprintf (stderr
, " Data serialization\n");
10168 while (i
< regdepslen
)
10170 if (regdeps
[i
].data_srlz
== STATE_STOP
10171 /* Note: as of 991210, all "other" dependencies are cleared by a
10172 data serialization. This might change with new tables */
10173 || (regdeps
[i
].dependency
)->semantics
== IA64_DVS_OTHER
)
10175 print_dependency ("Removing", i
);
10176 regdeps
[i
] = regdeps
[--regdepslen
];
10183 /* Insert stops and serializations as needed to avoid DVs. */
10186 remove_marked_resource (rs
)
10189 switch (rs
->dependency
->semantics
)
10191 case IA64_DVS_SPECIFIC
:
10193 fprintf (stderr
, "Implementation-specific, assume worst case...\n");
10194 /* ...fall through... */
10195 case IA64_DVS_INSTR
:
10197 fprintf (stderr
, "Inserting instr serialization\n");
10198 if (rs
->insn_srlz
< STATE_STOP
)
10199 insn_group_break (1, 0, 0);
10200 if (rs
->insn_srlz
< STATE_SRLZ
)
10202 struct slot oldslot
= CURR_SLOT
;
10203 /* Manually jam a srlz.i insn into the stream */
10204 memset (&CURR_SLOT
, 0, sizeof (CURR_SLOT
));
10205 CURR_SLOT
.user_template
= -1;
10206 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.i");
10207 instruction_serialization ();
10208 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10209 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10210 emit_one_bundle ();
10211 CURR_SLOT
= oldslot
;
10213 insn_group_break (1, 0, 0);
10215 case IA64_DVS_OTHER
: /* as of rev2 (991220) of the DV tables, all
10216 "other" types of DV are eliminated
10217 by a data serialization */
10218 case IA64_DVS_DATA
:
10220 fprintf (stderr
, "Inserting data serialization\n");
10221 if (rs
->data_srlz
< STATE_STOP
)
10222 insn_group_break (1, 0, 0);
10224 struct slot oldslot
= CURR_SLOT
;
10225 /* Manually jam a srlz.d insn into the stream */
10226 memset (&CURR_SLOT
, 0, sizeof (CURR_SLOT
));
10227 CURR_SLOT
.user_template
= -1;
10228 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.d");
10229 data_serialization ();
10230 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10231 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10232 emit_one_bundle ();
10233 CURR_SLOT
= oldslot
;
10236 case IA64_DVS_IMPLIED
:
10237 case IA64_DVS_IMPLIEDF
:
10239 fprintf (stderr
, "Inserting stop\n");
10240 insn_group_break (1, 0, 0);
10247 /* Check the resources used by the given opcode against the current dependency
10250 The check is run once for each execution path encountered. In this case,
10251 a unique execution path is the sequence of instructions following a code
10252 entry point, e.g. the following has three execution paths, one starting
10253 at L0, one at L1, and one at L2.
10262 check_dependencies (idesc
)
10263 struct ia64_opcode
*idesc
;
10265 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
10269 /* Note that the number of marked resources may change within the
10270 loop if in auto mode. */
10272 while (i
< regdepslen
)
10274 struct rsrc
*rs
= ®deps
[i
];
10275 const struct ia64_dependency
*dep
= rs
->dependency
;
10278 int start_over
= 0;
10280 if (dep
->semantics
== IA64_DVS_NONE
10281 || (chkind
= depends_on (rs
->depind
, idesc
)) == -1)
10287 note
= NOTE (opdeps
->chks
[chkind
]);
10289 /* Check this resource against each execution path seen thus far. */
10290 for (path
= 0; path
<= md
.path
; path
++)
10294 /* If the dependency wasn't on the path being checked, ignore it. */
10295 if (rs
->path
< path
)
10298 /* If the QP for this insn implies a QP which has branched, don't
10299 bother checking. Ed. NOTE: I don't think this check is terribly
10300 useful; what's the point of generating code which will only be
10301 reached if its QP is zero?
10302 This code was specifically inserted to handle the following code,
10303 based on notes from Intel's DV checking code, where p1 implies p2.
10309 if (CURR_SLOT
.qp_regno
!= 0)
10313 for (implies
= 0; implies
< qp_implieslen
; implies
++)
10315 if (qp_implies
[implies
].path
>= path
10316 && qp_implies
[implies
].p1
== CURR_SLOT
.qp_regno
10317 && qp_implies
[implies
].p2_branched
)
10327 if ((matchtype
= resources_match (rs
, idesc
, note
,
10328 CURR_SLOT
.qp_regno
, path
)) != 0)
10331 char pathmsg
[256] = "";
10332 char indexmsg
[256] = "";
10333 int certain
= (matchtype
== 1 && CURR_SLOT
.qp_regno
== 0);
10336 sprintf (pathmsg
, " when entry is at label '%s'",
10337 md
.entry_labels
[path
- 1]);
10338 if (matchtype
== 1 && rs
->index
>= 0)
10339 sprintf (indexmsg
, ", specific resource number is %d",
10341 sprintf (msg
, "Use of '%s' %s %s dependency '%s' (%s)%s%s",
10343 (certain
? "violates" : "may violate"),
10344 dv_mode
[dep
->mode
], dep
->name
,
10345 dv_sem
[dep
->semantics
],
10346 pathmsg
, indexmsg
);
10348 if (md
.explicit_mode
)
10350 as_warn ("%s", msg
);
10351 if (path
< md
.path
)
10352 as_warn (_("Only the first path encountering the conflict "
10354 as_warn_where (rs
->file
, rs
->line
,
10355 _("This is the location of the "
10356 "conflicting usage"));
10357 /* Don't bother checking other paths, to avoid duplicating
10358 the same warning */
10364 fprintf (stderr
, "%s @ %s:%d\n", msg
, rs
->file
, rs
->line
);
10366 remove_marked_resource (rs
);
10368 /* since the set of dependencies has changed, start over */
10369 /* FIXME -- since we're removing dvs as we go, we
10370 probably don't really need to start over... */
10383 /* Register new dependencies based on the given opcode. */
10386 mark_resources (idesc
)
10387 struct ia64_opcode
*idesc
;
10390 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
10391 int add_only_qp_reads
= 0;
10393 /* A conditional branch only uses its resources if it is taken; if it is
10394 taken, we stop following that path. The other branch types effectively
10395 *always* write their resources. If it's not taken, register only QP
10397 if (is_conditional_branch (idesc
) || is_interruption_or_rfi (idesc
))
10399 add_only_qp_reads
= 1;
10403 fprintf (stderr
, "Registering '%s' resource usage\n", idesc
->name
);
10405 for (i
= 0; i
< opdeps
->nregs
; i
++)
10407 const struct ia64_dependency
*dep
;
10408 struct rsrc specs
[MAX_SPECS
];
10413 dep
= ia64_find_dependency (opdeps
->regs
[i
]);
10414 note
= NOTE (opdeps
->regs
[i
]);
10416 if (add_only_qp_reads
10417 && !(dep
->mode
== IA64_DV_WAR
10418 && (dep
->specifier
== IA64_RS_PR
10419 || dep
->specifier
== IA64_RS_PRr
10420 || dep
->specifier
== IA64_RS_PR63
)))
10423 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, md
.path
);
10425 while (count
-- > 0)
10427 mark_resource (idesc
, dep
, &specs
[count
],
10428 DEP (opdeps
->regs
[i
]), md
.path
);
10431 /* The execution path may affect register values, which may in turn
10432 affect which indirect-access resources are accessed. */
10433 switch (dep
->specifier
)
10437 case IA64_RS_CPUID
:
10445 for (path
= 0; path
< md
.path
; path
++)
10447 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, path
);
10448 while (count
-- > 0)
10449 mark_resource (idesc
, dep
, &specs
[count
],
10450 DEP (opdeps
->regs
[i
]), path
);
10457 /* Remove dependencies when they no longer apply. */
10460 update_dependencies (idesc
)
10461 struct ia64_opcode
*idesc
;
10465 if (strcmp (idesc
->name
, "srlz.i") == 0)
10467 instruction_serialization ();
10469 else if (strcmp (idesc
->name
, "srlz.d") == 0)
10471 data_serialization ();
10473 else if (is_interruption_or_rfi (idesc
)
10474 || is_taken_branch (idesc
))
10476 /* Although technically the taken branch doesn't clear dependencies
10477 which require a srlz.[id], we don't follow the branch; the next
10478 instruction is assumed to start with a clean slate. */
10482 else if (is_conditional_branch (idesc
)
10483 && CURR_SLOT
.qp_regno
!= 0)
10485 int is_call
= strstr (idesc
->name
, ".call") != NULL
;
10487 for (i
= 0; i
< qp_implieslen
; i
++)
10489 /* If the conditional branch's predicate is implied by the predicate
10490 in an existing dependency, remove that dependency. */
10491 if (qp_implies
[i
].p2
== CURR_SLOT
.qp_regno
)
10494 /* Note that this implied predicate takes a branch so that if
10495 a later insn generates a DV but its predicate implies this
10496 one, we can avoid the false DV warning. */
10497 qp_implies
[i
].p2_branched
= 1;
10498 while (depind
< regdepslen
)
10500 if (regdeps
[depind
].qp_regno
== qp_implies
[i
].p1
)
10502 print_dependency ("Removing", depind
);
10503 regdeps
[depind
] = regdeps
[--regdepslen
];
10510 /* Any marked resources which have this same predicate should be
10511 cleared, provided that the QP hasn't been modified between the
10512 marking instruction and the branch. */
10515 insn_group_break (0, CURR_SLOT
.qp_regno
, 1);
10520 while (i
< regdepslen
)
10522 if (regdeps
[i
].qp_regno
== CURR_SLOT
.qp_regno
10523 && regdeps
[i
].link_to_qp_branch
10524 && (regdeps
[i
].file
!= CURR_SLOT
.src_file
10525 || regdeps
[i
].line
!= CURR_SLOT
.src_line
))
10527 /* Treat like a taken branch */
10528 print_dependency ("Removing", i
);
10529 regdeps
[i
] = regdeps
[--regdepslen
];
10538 /* Examine the current instruction for dependency violations. */
10542 struct ia64_opcode
*idesc
;
10546 fprintf (stderr
, "Checking %s for violations (line %d, %d/%d)\n",
10547 idesc
->name
, CURR_SLOT
.src_line
,
10548 idesc
->dependencies
->nchks
,
10549 idesc
->dependencies
->nregs
);
10552 /* Look through the list of currently marked resources; if the current
10553 instruction has the dependency in its chks list which uses that resource,
10554 check against the specific resources used. */
10555 check_dependencies (idesc
);
10557 /* Look up the instruction's regdeps (RAW writes, WAW writes, and WAR reads),
10558 then add them to the list of marked resources. */
10559 mark_resources (idesc
);
10561 /* There are several types of dependency semantics, and each has its own
10562 requirements for being cleared
10564 Instruction serialization (insns separated by interruption, rfi, or
10565 writer + srlz.i + reader, all in separate groups) clears DVS_INSTR.
10567 Data serialization (instruction serialization, or writer + srlz.d +
10568 reader, where writer and srlz.d are in separate groups) clears
10569 DVS_DATA. (This also clears DVS_OTHER, but that is not guaranteed to
10570 always be the case).
10572 Instruction group break (groups separated by stop, taken branch,
10573 interruption or rfi) clears DVS_IMPLIED and DVS_IMPLIEDF.
10575 update_dependencies (idesc
);
10577 /* Sometimes, knowing a register value allows us to avoid giving a false DV
10578 warning. Keep track of as many as possible that are useful. */
10579 note_register_values (idesc
);
10581 /* We don't need or want this anymore. */
10582 md
.mem_offset
.hint
= 0;
10587 /* Translate one line of assembly. Pseudo ops and labels do not show
10593 char *saved_input_line_pointer
, *mnemonic
;
10594 const struct pseudo_opcode
*pdesc
;
10595 struct ia64_opcode
*idesc
;
10596 unsigned char qp_regno
;
10597 unsigned int flags
;
10600 saved_input_line_pointer
= input_line_pointer
;
10601 input_line_pointer
= str
;
10603 /* extract the opcode (mnemonic): */
10605 mnemonic
= input_line_pointer
;
10606 ch
= get_symbol_end ();
10607 pdesc
= (struct pseudo_opcode
*) hash_find (md
.pseudo_hash
, mnemonic
);
10610 *input_line_pointer
= ch
;
10611 (*pdesc
->handler
) (pdesc
->arg
);
10615 /* Find the instruction descriptor matching the arguments. */
10617 idesc
= ia64_find_opcode (mnemonic
);
10618 *input_line_pointer
= ch
;
10621 as_bad ("Unknown opcode `%s'", mnemonic
);
10625 idesc
= parse_operands (idesc
);
10629 /* Handle the dynamic ops we can handle now: */
10630 if (idesc
->type
== IA64_TYPE_DYN
)
10632 if (strcmp (idesc
->name
, "add") == 0)
10634 if (CURR_SLOT
.opnd
[2].X_op
== O_register
10635 && CURR_SLOT
.opnd
[2].X_add_number
< 4)
10639 ia64_free_opcode (idesc
);
10640 idesc
= ia64_find_opcode (mnemonic
);
10642 else if (strcmp (idesc
->name
, "mov") == 0)
10644 enum ia64_opnd opnd1
, opnd2
;
10647 opnd1
= idesc
->operands
[0];
10648 opnd2
= idesc
->operands
[1];
10649 if (opnd1
== IA64_OPND_AR3
)
10651 else if (opnd2
== IA64_OPND_AR3
)
10655 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
)
10657 if (ar_is_only_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10658 mnemonic
= "mov.i";
10659 else if (ar_is_only_in_memory_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10660 mnemonic
= "mov.m";
10668 ia64_free_opcode (idesc
);
10669 idesc
= ia64_find_opcode (mnemonic
);
10670 while (idesc
!= NULL
10671 && (idesc
->operands
[0] != opnd1
10672 || idesc
->operands
[1] != opnd2
))
10673 idesc
= get_next_opcode (idesc
);
10677 else if (strcmp (idesc
->name
, "mov.i") == 0
10678 || strcmp (idesc
->name
, "mov.m") == 0)
10680 enum ia64_opnd opnd1
, opnd2
;
10683 opnd1
= idesc
->operands
[0];
10684 opnd2
= idesc
->operands
[1];
10685 if (opnd1
== IA64_OPND_AR3
)
10687 else if (opnd2
== IA64_OPND_AR3
)
10691 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
)
10694 if (ar_is_only_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10696 else if (ar_is_only_in_memory_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10698 if (unit
!= 'a' && unit
!= idesc
->name
[4])
10699 as_bad ("AR %d can only be accessed by %c-unit",
10700 (int) (CURR_SLOT
.opnd
[rop
].X_add_number
- REG_AR
),
10704 else if (strcmp (idesc
->name
, "hint.b") == 0)
10710 case hint_b_warning
:
10711 as_warn ("hint.b may be treated as nop");
10714 as_bad ("hint.b shouldn't be used");
10720 if (md
.qp
.X_op
== O_register
)
10722 qp_regno
= md
.qp
.X_add_number
- REG_P
;
10723 md
.qp
.X_op
= O_absent
;
10726 flags
= idesc
->flags
;
10728 if ((flags
& IA64_OPCODE_FIRST
) != 0)
10730 /* The alignment frag has to end with a stop bit only if the
10731 next instruction after the alignment directive has to be
10732 the first instruction in an instruction group. */
10735 while (align_frag
->fr_type
!= rs_align_code
)
10737 align_frag
= align_frag
->fr_next
;
10741 /* align_frag can be NULL if there are directives in
10743 if (align_frag
&& align_frag
->fr_next
== frag_now
)
10744 align_frag
->tc_frag_data
= 1;
10747 insn_group_break (1, 0, 0);
10751 if ((flags
& IA64_OPCODE_NO_PRED
) != 0 && qp_regno
!= 0)
10753 as_bad ("`%s' cannot be predicated", idesc
->name
);
10757 /* Build the instruction. */
10758 CURR_SLOT
.qp_regno
= qp_regno
;
10759 CURR_SLOT
.idesc
= idesc
;
10760 as_where (&CURR_SLOT
.src_file
, &CURR_SLOT
.src_line
);
10761 dwarf2_where (&CURR_SLOT
.debug_line
);
10763 /* Add unwind entry, if there is one. */
10764 if (unwind
.current_entry
)
10766 CURR_SLOT
.unwind_record
= unwind
.current_entry
;
10767 unwind
.current_entry
= NULL
;
10769 if (unwind
.proc_start
&& S_IS_DEFINED (unwind
.proc_start
))
10772 /* Check for dependency violations. */
10776 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10777 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10778 emit_one_bundle ();
10780 if ((flags
& IA64_OPCODE_LAST
) != 0)
10781 insn_group_break (1, 0, 0);
10783 md
.last_text_seg
= now_seg
;
10786 input_line_pointer
= saved_input_line_pointer
;
10789 /* Called when symbol NAME cannot be found in the symbol table.
10790 Should be used for dynamic valued symbols only. */
10793 md_undefined_symbol (name
)
10794 char *name ATTRIBUTE_UNUSED
;
10799 /* Called for any expression that can not be recognized. When the
10800 function is called, `input_line_pointer' will point to the start of
10807 switch (*input_line_pointer
)
10810 ++input_line_pointer
;
10812 if (*input_line_pointer
!= ']')
10814 as_bad ("Closing bracket missing");
10819 if (e
->X_op
!= O_register
)
10820 as_bad ("Register expected as index");
10822 ++input_line_pointer
;
10833 ignore_rest_of_line ();
10836 /* Return 1 if it's OK to adjust a reloc by replacing the symbol with
10837 a section symbol plus some offset. For relocs involving @fptr(),
10838 directives we don't want such adjustments since we need to have the
10839 original symbol's name in the reloc. */
10841 ia64_fix_adjustable (fix
)
10844 /* Prevent all adjustments to global symbols */
10845 if (S_IS_EXTERNAL (fix
->fx_addsy
) || S_IS_WEAK (fix
->fx_addsy
))
10848 switch (fix
->fx_r_type
)
10850 case BFD_RELOC_IA64_FPTR64I
:
10851 case BFD_RELOC_IA64_FPTR32MSB
:
10852 case BFD_RELOC_IA64_FPTR32LSB
:
10853 case BFD_RELOC_IA64_FPTR64MSB
:
10854 case BFD_RELOC_IA64_FPTR64LSB
:
10855 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10856 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10866 ia64_force_relocation (fix
)
10869 switch (fix
->fx_r_type
)
10871 case BFD_RELOC_IA64_FPTR64I
:
10872 case BFD_RELOC_IA64_FPTR32MSB
:
10873 case BFD_RELOC_IA64_FPTR32LSB
:
10874 case BFD_RELOC_IA64_FPTR64MSB
:
10875 case BFD_RELOC_IA64_FPTR64LSB
:
10877 case BFD_RELOC_IA64_LTOFF22
:
10878 case BFD_RELOC_IA64_LTOFF64I
:
10879 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10880 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10881 case BFD_RELOC_IA64_PLTOFF22
:
10882 case BFD_RELOC_IA64_PLTOFF64I
:
10883 case BFD_RELOC_IA64_PLTOFF64MSB
:
10884 case BFD_RELOC_IA64_PLTOFF64LSB
:
10886 case BFD_RELOC_IA64_LTOFF22X
:
10887 case BFD_RELOC_IA64_LDXMOV
:
10894 return generic_force_reloc (fix
);
10897 /* Decide from what point a pc-relative relocation is relative to,
10898 relative to the pc-relative fixup. Er, relatively speaking. */
10900 ia64_pcrel_from_section (fix
, sec
)
10904 unsigned long off
= fix
->fx_frag
->fr_address
+ fix
->fx_where
;
10906 if (bfd_get_section_flags (stdoutput
, sec
) & SEC_CODE
)
10913 /* Used to emit section-relative relocs for the dwarf2 debug data. */
10915 ia64_dwarf2_emit_offset (symbolS
*symbol
, unsigned int size
)
10919 expr
.X_op
= O_pseudo_fixup
;
10920 expr
.X_op_symbol
= pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
;
10921 expr
.X_add_number
= 0;
10922 expr
.X_add_symbol
= symbol
;
10923 emit_expr (&expr
, size
);
10926 /* This is called whenever some data item (not an instruction) needs a
10927 fixup. We pick the right reloc code depending on the byteorder
10928 currently in effect. */
10930 ia64_cons_fix_new (f
, where
, nbytes
, exp
)
10936 bfd_reloc_code_real_type code
;
10941 /* There are no reloc for 8 and 16 bit quantities, but we allow
10942 them here since they will work fine as long as the expression
10943 is fully defined at the end of the pass over the source file. */
10944 case 1: code
= BFD_RELOC_8
; break;
10945 case 2: code
= BFD_RELOC_16
; break;
10947 if (target_big_endian
)
10948 code
= BFD_RELOC_IA64_DIR32MSB
;
10950 code
= BFD_RELOC_IA64_DIR32LSB
;
10954 /* In 32-bit mode, data8 could mean function descriptors too. */
10955 if (exp
->X_op
== O_pseudo_fixup
10956 && exp
->X_op_symbol
10957 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
10958 && !(md
.flags
& EF_IA_64_ABI64
))
10960 if (target_big_endian
)
10961 code
= BFD_RELOC_IA64_IPLTMSB
;
10963 code
= BFD_RELOC_IA64_IPLTLSB
;
10964 exp
->X_op
= O_symbol
;
10969 if (target_big_endian
)
10970 code
= BFD_RELOC_IA64_DIR64MSB
;
10972 code
= BFD_RELOC_IA64_DIR64LSB
;
10977 if (exp
->X_op
== O_pseudo_fixup
10978 && exp
->X_op_symbol
10979 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
)
10981 if (target_big_endian
)
10982 code
= BFD_RELOC_IA64_IPLTMSB
;
10984 code
= BFD_RELOC_IA64_IPLTLSB
;
10985 exp
->X_op
= O_symbol
;
10991 as_bad ("Unsupported fixup size %d", nbytes
);
10992 ignore_rest_of_line ();
10996 if (exp
->X_op
== O_pseudo_fixup
)
10998 exp
->X_op
= O_symbol
;
10999 code
= ia64_gen_real_reloc_type (exp
->X_op_symbol
, code
);
11000 /* ??? If code unchanged, unsupported. */
11003 fix
= fix_new_exp (f
, where
, nbytes
, exp
, 0, code
);
11004 /* We need to store the byte order in effect in case we're going
11005 to fix an 8 or 16 bit relocation (for which there no real
11006 relocs available). See md_apply_fix3(). */
11007 fix
->tc_fix_data
.bigendian
= target_big_endian
;
11010 /* Return the actual relocation we wish to associate with the pseudo
11011 reloc described by SYM and R_TYPE. SYM should be one of the
11012 symbols in the pseudo_func array, or NULL. */
11014 static bfd_reloc_code_real_type
11015 ia64_gen_real_reloc_type (sym
, r_type
)
11016 struct symbol
*sym
;
11017 bfd_reloc_code_real_type r_type
;
11019 bfd_reloc_code_real_type
new = 0;
11020 const char *type
= NULL
, *suffix
= "";
11027 switch (S_GET_VALUE (sym
))
11029 case FUNC_FPTR_RELATIVE
:
11032 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_FPTR64I
; break;
11033 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_FPTR32MSB
; break;
11034 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_FPTR32LSB
; break;
11035 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_FPTR64MSB
; break;
11036 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_FPTR64LSB
; break;
11037 default: type
= "FPTR"; break;
11041 case FUNC_GP_RELATIVE
:
11044 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_GPREL22
; break;
11045 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_GPREL64I
; break;
11046 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_GPREL32MSB
; break;
11047 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_GPREL32LSB
; break;
11048 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_GPREL64MSB
; break;
11049 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_GPREL64LSB
; break;
11050 default: type
= "GPREL"; break;
11054 case FUNC_LT_RELATIVE
:
11057 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_LTOFF22
; break;
11058 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_LTOFF64I
; break;
11059 default: type
= "LTOFF"; break;
11063 case FUNC_LT_RELATIVE_X
:
11066 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_LTOFF22X
; break;
11067 default: type
= "LTOFF"; suffix
= "X"; break;
11071 case FUNC_PC_RELATIVE
:
11074 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PCREL22
; break;
11075 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PCREL64I
; break;
11076 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_PCREL32MSB
; break;
11077 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_PCREL32LSB
; break;
11078 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PCREL64MSB
; break;
11079 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PCREL64LSB
; break;
11080 default: type
= "PCREL"; break;
11084 case FUNC_PLT_RELATIVE
:
11087 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PLTOFF22
; break;
11088 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PLTOFF64I
; break;
11089 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PLTOFF64MSB
;break;
11090 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PLTOFF64LSB
;break;
11091 default: type
= "PLTOFF"; break;
11095 case FUNC_SEC_RELATIVE
:
11098 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SECREL32MSB
;break;
11099 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SECREL32LSB
;break;
11100 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SECREL64MSB
;break;
11101 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SECREL64LSB
;break;
11102 default: type
= "SECREL"; break;
11106 case FUNC_SEG_RELATIVE
:
11109 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SEGREL32MSB
;break;
11110 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SEGREL32LSB
;break;
11111 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SEGREL64MSB
;break;
11112 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SEGREL64LSB
;break;
11113 default: type
= "SEGREL"; break;
11117 case FUNC_LTV_RELATIVE
:
11120 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_LTV32MSB
; break;
11121 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_LTV32LSB
; break;
11122 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_LTV64MSB
; break;
11123 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_LTV64LSB
; break;
11124 default: type
= "LTV"; break;
11128 case FUNC_LT_FPTR_RELATIVE
:
11131 case BFD_RELOC_IA64_IMM22
:
11132 new = BFD_RELOC_IA64_LTOFF_FPTR22
; break;
11133 case BFD_RELOC_IA64_IMM64
:
11134 new = BFD_RELOC_IA64_LTOFF_FPTR64I
; break;
11135 case BFD_RELOC_IA64_DIR32MSB
:
11136 new = BFD_RELOC_IA64_LTOFF_FPTR32MSB
; break;
11137 case BFD_RELOC_IA64_DIR32LSB
:
11138 new = BFD_RELOC_IA64_LTOFF_FPTR32LSB
; break;
11139 case BFD_RELOC_IA64_DIR64MSB
:
11140 new = BFD_RELOC_IA64_LTOFF_FPTR64MSB
; break;
11141 case BFD_RELOC_IA64_DIR64LSB
:
11142 new = BFD_RELOC_IA64_LTOFF_FPTR64LSB
; break;
11144 type
= "LTOFF_FPTR"; break;
11148 case FUNC_TP_RELATIVE
:
11151 case BFD_RELOC_IA64_IMM14
: new = BFD_RELOC_IA64_TPREL14
; break;
11152 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_TPREL22
; break;
11153 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_TPREL64I
; break;
11154 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_TPREL64MSB
; break;
11155 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_TPREL64LSB
; break;
11156 default: type
= "TPREL"; break;
11160 case FUNC_LT_TP_RELATIVE
:
11163 case BFD_RELOC_IA64_IMM22
:
11164 new = BFD_RELOC_IA64_LTOFF_TPREL22
; break;
11166 type
= "LTOFF_TPREL"; break;
11170 case FUNC_DTP_MODULE
:
11173 case BFD_RELOC_IA64_DIR64MSB
:
11174 new = BFD_RELOC_IA64_DTPMOD64MSB
; break;
11175 case BFD_RELOC_IA64_DIR64LSB
:
11176 new = BFD_RELOC_IA64_DTPMOD64LSB
; break;
11178 type
= "DTPMOD"; break;
11182 case FUNC_LT_DTP_MODULE
:
11185 case BFD_RELOC_IA64_IMM22
:
11186 new = BFD_RELOC_IA64_LTOFF_DTPMOD22
; break;
11188 type
= "LTOFF_DTPMOD"; break;
11192 case FUNC_DTP_RELATIVE
:
11195 case BFD_RELOC_IA64_DIR32MSB
:
11196 new = BFD_RELOC_IA64_DTPREL32MSB
; break;
11197 case BFD_RELOC_IA64_DIR32LSB
:
11198 new = BFD_RELOC_IA64_DTPREL32LSB
; break;
11199 case BFD_RELOC_IA64_DIR64MSB
:
11200 new = BFD_RELOC_IA64_DTPREL64MSB
; break;
11201 case BFD_RELOC_IA64_DIR64LSB
:
11202 new = BFD_RELOC_IA64_DTPREL64LSB
; break;
11203 case BFD_RELOC_IA64_IMM14
:
11204 new = BFD_RELOC_IA64_DTPREL14
; break;
11205 case BFD_RELOC_IA64_IMM22
:
11206 new = BFD_RELOC_IA64_DTPREL22
; break;
11207 case BFD_RELOC_IA64_IMM64
:
11208 new = BFD_RELOC_IA64_DTPREL64I
; break;
11210 type
= "DTPREL"; break;
11214 case FUNC_LT_DTP_RELATIVE
:
11217 case BFD_RELOC_IA64_IMM22
:
11218 new = BFD_RELOC_IA64_LTOFF_DTPREL22
; break;
11220 type
= "LTOFF_DTPREL"; break;
11224 case FUNC_IPLT_RELOC
:
11227 case BFD_RELOC_IA64_IPLTMSB
: return r_type
;
11228 case BFD_RELOC_IA64_IPLTLSB
: return r_type
;
11229 default: type
= "IPLT"; break;
11247 case BFD_RELOC_IA64_DIR32MSB
: width
= 32; suffix
= "MSB"; break;
11248 case BFD_RELOC_IA64_DIR32LSB
: width
= 32; suffix
= "LSB"; break;
11249 case BFD_RELOC_IA64_DIR64MSB
: width
= 64; suffix
= "MSB"; break;
11250 case BFD_RELOC_IA64_DIR64LSB
: width
= 64; suffix
= "LSB"; break;
11251 case BFD_RELOC_UNUSED
: width
= 13; break;
11252 case BFD_RELOC_IA64_IMM14
: width
= 14; break;
11253 case BFD_RELOC_IA64_IMM22
: width
= 22; break;
11254 case BFD_RELOC_IA64_IMM64
: width
= 64; suffix
= "I"; break;
11258 /* This should be an error, but since previously there wasn't any
11259 diagnostic here, dont't make it fail because of this for now. */
11260 as_warn ("Cannot express %s%d%s relocation", type
, width
, suffix
);
11265 /* Here is where generate the appropriate reloc for pseudo relocation
11268 ia64_validate_fix (fix
)
11271 switch (fix
->fx_r_type
)
11273 case BFD_RELOC_IA64_FPTR64I
:
11274 case BFD_RELOC_IA64_FPTR32MSB
:
11275 case BFD_RELOC_IA64_FPTR64LSB
:
11276 case BFD_RELOC_IA64_LTOFF_FPTR22
:
11277 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
11278 if (fix
->fx_offset
!= 0)
11279 as_bad_where (fix
->fx_file
, fix
->fx_line
,
11280 "No addend allowed in @fptr() relocation");
11288 fix_insn (fix
, odesc
, value
)
11290 const struct ia64_operand
*odesc
;
11293 bfd_vma insn
[3], t0
, t1
, control_bits
;
11298 slot
= fix
->fx_where
& 0x3;
11299 fixpos
= fix
->fx_frag
->fr_literal
+ (fix
->fx_where
- slot
);
11301 /* Bundles are always in little-endian byte order */
11302 t0
= bfd_getl64 (fixpos
);
11303 t1
= bfd_getl64 (fixpos
+ 8);
11304 control_bits
= t0
& 0x1f;
11305 insn
[0] = (t0
>> 5) & 0x1ffffffffffLL
;
11306 insn
[1] = ((t0
>> 46) & 0x3ffff) | ((t1
& 0x7fffff) << 18);
11307 insn
[2] = (t1
>> 23) & 0x1ffffffffffLL
;
11310 if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU64
)
11312 insn
[1] = (value
>> 22) & 0x1ffffffffffLL
;
11313 insn
[2] |= (((value
& 0x7f) << 13)
11314 | (((value
>> 7) & 0x1ff) << 27)
11315 | (((value
>> 16) & 0x1f) << 22)
11316 | (((value
>> 21) & 0x1) << 21)
11317 | (((value
>> 63) & 0x1) << 36));
11319 else if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU62
)
11321 if (value
& ~0x3fffffffffffffffULL
)
11322 err
= "integer operand out of range";
11323 insn
[1] = (value
>> 21) & 0x1ffffffffffLL
;
11324 insn
[2] |= (((value
& 0xfffff) << 6) | (((value
>> 20) & 0x1) << 36));
11326 else if (odesc
- elf64_ia64_operands
== IA64_OPND_TGT64
)
11329 insn
[1] = ((value
>> 20) & 0x7fffffffffLL
) << 2;
11330 insn
[2] |= ((((value
>> 59) & 0x1) << 36)
11331 | (((value
>> 0) & 0xfffff) << 13));
11334 err
= (*odesc
->insert
) (odesc
, value
, insn
+ slot
);
11337 as_bad_where (fix
->fx_file
, fix
->fx_line
, err
);
11339 t0
= control_bits
| (insn
[0] << 5) | (insn
[1] << 46);
11340 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
11341 number_to_chars_littleendian (fixpos
+ 0, t0
, 8);
11342 number_to_chars_littleendian (fixpos
+ 8, t1
, 8);
11345 /* Attempt to simplify or even eliminate a fixup. The return value is
11346 ignored; perhaps it was once meaningful, but now it is historical.
11347 To indicate that a fixup has been eliminated, set FIXP->FX_DONE.
11349 If fixp->fx_addsy is non-NULL, we'll have to generate a reloc entry
11353 md_apply_fix3 (fix
, valP
, seg
)
11356 segT seg ATTRIBUTE_UNUSED
;
11359 valueT value
= *valP
;
11361 fixpos
= fix
->fx_frag
->fr_literal
+ fix
->fx_where
;
11365 switch (fix
->fx_r_type
)
11367 case BFD_RELOC_IA64_PCREL21B
: break;
11368 case BFD_RELOC_IA64_PCREL21BI
: break;
11369 case BFD_RELOC_IA64_PCREL21F
: break;
11370 case BFD_RELOC_IA64_PCREL21M
: break;
11371 case BFD_RELOC_IA64_PCREL60B
: break;
11372 case BFD_RELOC_IA64_PCREL22
: break;
11373 case BFD_RELOC_IA64_PCREL64I
: break;
11374 case BFD_RELOC_IA64_PCREL32MSB
: break;
11375 case BFD_RELOC_IA64_PCREL32LSB
: break;
11376 case BFD_RELOC_IA64_PCREL64MSB
: break;
11377 case BFD_RELOC_IA64_PCREL64LSB
: break;
11379 fix
->fx_r_type
= ia64_gen_real_reloc_type (pseudo_func
[FUNC_PC_RELATIVE
].u
.sym
,
11386 switch (fix
->fx_r_type
)
11388 case BFD_RELOC_UNUSED
:
11389 /* This must be a TAG13 or TAG13b operand. There are no external
11390 relocs defined for them, so we must give an error. */
11391 as_bad_where (fix
->fx_file
, fix
->fx_line
,
11392 "%s must have a constant value",
11393 elf64_ia64_operands
[fix
->tc_fix_data
.opnd
].desc
);
11397 case BFD_RELOC_IA64_TPREL14
:
11398 case BFD_RELOC_IA64_TPREL22
:
11399 case BFD_RELOC_IA64_TPREL64I
:
11400 case BFD_RELOC_IA64_LTOFF_TPREL22
:
11401 case BFD_RELOC_IA64_LTOFF_DTPMOD22
:
11402 case BFD_RELOC_IA64_DTPREL14
:
11403 case BFD_RELOC_IA64_DTPREL22
:
11404 case BFD_RELOC_IA64_DTPREL64I
:
11405 case BFD_RELOC_IA64_LTOFF_DTPREL22
:
11406 S_SET_THREAD_LOCAL (fix
->fx_addsy
);
11413 else if (fix
->tc_fix_data
.opnd
== IA64_OPND_NIL
)
11415 if (fix
->tc_fix_data
.bigendian
)
11416 number_to_chars_bigendian (fixpos
, value
, fix
->fx_size
);
11418 number_to_chars_littleendian (fixpos
, value
, fix
->fx_size
);
11423 fix_insn (fix
, elf64_ia64_operands
+ fix
->tc_fix_data
.opnd
, value
);
11428 /* Generate the BFD reloc to be stuck in the object file from the
11429 fixup used internally in the assembler. */
11432 tc_gen_reloc (sec
, fixp
)
11433 asection
*sec ATTRIBUTE_UNUSED
;
11438 reloc
= xmalloc (sizeof (*reloc
));
11439 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
11440 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
11441 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
11442 reloc
->addend
= fixp
->fx_offset
;
11443 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
11447 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
11448 "Cannot represent %s relocation in object file",
11449 bfd_get_reloc_code_name (fixp
->fx_r_type
));
11454 /* Turn a string in input_line_pointer into a floating point constant
11455 of type TYPE, and store the appropriate bytes in *LIT. The number
11456 of LITTLENUMS emitted is stored in *SIZE. An error message is
11457 returned, or NULL on OK. */
11459 #define MAX_LITTLENUMS 5
11462 md_atof (type
, lit
, size
)
11467 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
11497 return "Bad call to MD_ATOF()";
11499 t
= atof_ieee (input_line_pointer
, type
, words
);
11501 input_line_pointer
= t
;
11503 (*ia64_float_to_chars
) (lit
, words
, prec
);
11507 /* It is 10 byte floating point with 6 byte padding. */
11508 memset (&lit
[10], 0, 6);
11509 *size
= 8 * sizeof (LITTLENUM_TYPE
);
11512 *size
= prec
* sizeof (LITTLENUM_TYPE
);
11517 /* Handle ia64 specific semantics of the align directive. */
11520 ia64_md_do_align (n
, fill
, len
, max
)
11521 int n ATTRIBUTE_UNUSED
;
11522 const char *fill ATTRIBUTE_UNUSED
;
11523 int len ATTRIBUTE_UNUSED
;
11524 int max ATTRIBUTE_UNUSED
;
11526 if (subseg_text_p (now_seg
))
11527 ia64_flush_insns ();
11530 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
11531 of an rs_align_code fragment. */
11534 ia64_handle_align (fragp
)
11539 const unsigned char *nop
;
11541 if (fragp
->fr_type
!= rs_align_code
)
11544 /* Check if this frag has to end with a stop bit. */
11545 nop
= fragp
->tc_frag_data
? le_nop_stop
: le_nop
;
11547 bytes
= fragp
->fr_next
->fr_address
- fragp
->fr_address
- fragp
->fr_fix
;
11548 p
= fragp
->fr_literal
+ fragp
->fr_fix
;
11550 /* If no paddings are needed, we check if we need a stop bit. */
11551 if (!bytes
&& fragp
->tc_frag_data
)
11553 if (fragp
->fr_fix
< 16)
11555 /* FIXME: It won't work with
11557 alloc r32=ar.pfs,1,2,4,0
11561 as_bad_where (fragp
->fr_file
, fragp
->fr_line
,
11562 _("Can't add stop bit to mark end of instruction group"));
11565 /* Bundles are always in little-endian byte order. Make sure
11566 the previous bundle has the stop bit. */
11570 /* Make sure we are on a 16-byte boundary, in case someone has been
11571 putting data into a text section. */
11574 int fix
= bytes
& 15;
11575 memset (p
, 0, fix
);
11578 fragp
->fr_fix
+= fix
;
11581 /* Instruction bundles are always little-endian. */
11582 memcpy (p
, nop
, 16);
11583 fragp
->fr_var
= 16;
11587 ia64_float_to_chars_bigendian (char *lit
, LITTLENUM_TYPE
*words
,
11592 number_to_chars_bigendian (lit
, (long) (*words
++),
11593 sizeof (LITTLENUM_TYPE
));
11594 lit
+= sizeof (LITTLENUM_TYPE
);
11599 ia64_float_to_chars_littleendian (char *lit
, LITTLENUM_TYPE
*words
,
11604 number_to_chars_littleendian (lit
, (long) (words
[prec
]),
11605 sizeof (LITTLENUM_TYPE
));
11606 lit
+= sizeof (LITTLENUM_TYPE
);
11611 ia64_elf_section_change_hook (void)
11613 if (elf_section_type (now_seg
) == SHT_IA_64_UNWIND
11614 && elf_linked_to_section (now_seg
) == NULL
)
11615 elf_linked_to_section (now_seg
) = text_section
;
11616 dot_byteorder (-1);
11619 /* Check if a label should be made global. */
11621 ia64_check_label (symbolS
*label
)
11623 if (*input_line_pointer
== ':')
11625 S_SET_EXTERNAL (label
);
11626 input_line_pointer
++;
11630 /* Used to remember where .alias and .secalias directives are seen. We
11631 will rename symbol and section names when we are about to output
11632 the relocatable file. */
11635 char *file
; /* The file where the directive is seen. */
11636 unsigned int line
; /* The line number the directive is at. */
11637 const char *name
; /* The orignale name of the symbol. */
11640 /* Called for .alias and .secalias directives. If SECTION is 1, it is
11641 .secalias. Otherwise, it is .alias. */
11643 dot_alias (int section
)
11645 char *name
, *alias
;
11649 const char *error_string
;
11652 struct hash_control
*ahash
, *nhash
;
11655 name
= input_line_pointer
;
11656 delim
= get_symbol_end ();
11657 end_name
= input_line_pointer
;
11660 if (name
== end_name
)
11662 as_bad (_("expected symbol name"));
11663 discard_rest_of_line ();
11667 SKIP_WHITESPACE ();
11669 if (*input_line_pointer
!= ',')
11672 as_bad (_("expected comma after \"%s\""), name
);
11674 ignore_rest_of_line ();
11678 input_line_pointer
++;
11680 ia64_canonicalize_symbol_name (name
);
11682 /* We call demand_copy_C_string to check if alias string is valid.
11683 There should be a closing `"' and no `\0' in the string. */
11684 alias
= demand_copy_C_string (&len
);
11687 ignore_rest_of_line ();
11691 /* Make a copy of name string. */
11692 len
= strlen (name
) + 1;
11693 obstack_grow (¬es
, name
, len
);
11694 name
= obstack_finish (¬es
);
11699 ahash
= secalias_hash
;
11700 nhash
= secalias_name_hash
;
11705 ahash
= alias_hash
;
11706 nhash
= alias_name_hash
;
11709 /* Check if alias has been used before. */
11710 h
= (struct alias
*) hash_find (ahash
, alias
);
11713 if (strcmp (h
->name
, name
))
11714 as_bad (_("`%s' is already the alias of %s `%s'"),
11715 alias
, kind
, h
->name
);
11719 /* Check if name already has an alias. */
11720 a
= (const char *) hash_find (nhash
, name
);
11723 if (strcmp (a
, alias
))
11724 as_bad (_("%s `%s' already has an alias `%s'"), kind
, name
, a
);
11728 h
= (struct alias
*) xmalloc (sizeof (struct alias
));
11729 as_where (&h
->file
, &h
->line
);
11732 error_string
= hash_jam (ahash
, alias
, (PTR
) h
);
11735 as_fatal (_("inserting \"%s\" into %s alias hash table failed: %s"),
11736 alias
, kind
, error_string
);
11740 error_string
= hash_jam (nhash
, name
, (PTR
) alias
);
11743 as_fatal (_("inserting \"%s\" into %s name hash table failed: %s"),
11744 alias
, kind
, error_string
);
11746 obstack_free (¬es
, name
);
11747 obstack_free (¬es
, alias
);
11750 demand_empty_rest_of_line ();
11753 /* It renames the original symbol name to its alias. */
11755 do_alias (const char *alias
, PTR value
)
11757 struct alias
*h
= (struct alias
*) value
;
11758 symbolS
*sym
= symbol_find (h
->name
);
11761 as_warn_where (h
->file
, h
->line
,
11762 _("symbol `%s' aliased to `%s' is not used"),
11765 S_SET_NAME (sym
, (char *) alias
);
11768 /* Called from write_object_file. */
11770 ia64_adjust_symtab (void)
11772 hash_traverse (alias_hash
, do_alias
);
11775 /* It renames the original section name to its alias. */
11777 do_secalias (const char *alias
, PTR value
)
11779 struct alias
*h
= (struct alias
*) value
;
11780 segT sec
= bfd_get_section_by_name (stdoutput
, h
->name
);
11783 as_warn_where (h
->file
, h
->line
,
11784 _("section `%s' aliased to `%s' is not used"),
11790 /* Called from write_object_file. */
11792 ia64_frob_file (void)
11794 hash_traverse (secalias_hash
, do_secalias
);