1 /* tc-ia64.c -- Assembler for the HP/Intel IA-64 architecture.
2 Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
3 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
35 - labels are wrong if automatic alignment is introduced
36 (e.g., checkout the second real10 definition in test-data.s)
38 <reg>.safe_across_calls and any other DV-related directives I don't
39 have documentation for.
40 verify mod-sched-brs reads/writes are checked/marked (and other
46 #include "safe-ctype.h"
47 #include "dwarf2dbg.h"
50 #include "opcode/ia64.h"
54 #define NELEMS(a) ((int) (sizeof (a)/sizeof ((a)[0])))
55 #define MIN(a,b) ((a) < (b) ? (a) : (b))
58 #define PREV_SLOT md.slot[(md.curr_slot + NUM_SLOTS - 1) % NUM_SLOTS]
59 #define CURR_SLOT md.slot[md.curr_slot]
61 #define O_pseudo_fixup (O_max + 1)
65 /* IA-64 ABI section pseudo-ops. */
66 SPECIAL_SECTION_BSS
= 0,
68 SPECIAL_SECTION_SDATA
,
69 SPECIAL_SECTION_RODATA
,
70 SPECIAL_SECTION_COMMENT
,
71 SPECIAL_SECTION_UNWIND
,
72 SPECIAL_SECTION_UNWIND_INFO
,
73 /* HPUX specific section pseudo-ops. */
74 SPECIAL_SECTION_INIT_ARRAY
,
75 SPECIAL_SECTION_FINI_ARRAY
,
88 FUNC_LT_FPTR_RELATIVE
,
95 REG_FR
= (REG_GR
+ 128),
96 REG_AR
= (REG_FR
+ 128),
97 REG_CR
= (REG_AR
+ 128),
98 REG_P
= (REG_CR
+ 128),
99 REG_BR
= (REG_P
+ 64),
100 REG_IP
= (REG_BR
+ 8),
107 /* The following are pseudo-registers for use by gas only. */
119 /* The following pseudo-registers are used for unwind directives only: */
127 DYNREG_GR
= 0, /* dynamic general purpose register */
128 DYNREG_FR
, /* dynamic floating point register */
129 DYNREG_PR
, /* dynamic predicate register */
133 enum operand_match_result
136 OPERAND_OUT_OF_RANGE
,
140 /* On the ia64, we can't know the address of a text label until the
141 instructions are packed into a bundle. To handle this, we keep
142 track of the list of labels that appear in front of each
146 struct label_fix
*next
;
150 extern int target_big_endian
;
152 /* Characters which always start a comment. */
153 const char comment_chars
[] = "";
155 /* Characters which start a comment at the beginning of a line. */
156 const char line_comment_chars
[] = "#";
158 /* Characters which may be used to separate multiple commands on a
160 const char line_separator_chars
[] = ";";
162 /* Characters which are used to indicate an exponent in a floating
164 const char EXP_CHARS
[] = "eE";
166 /* Characters which mean that a number is a floating point constant,
168 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
170 /* ia64-specific option processing: */
172 const char *md_shortopts
= "m:N:x::";
174 struct option md_longopts
[] =
176 #define OPTION_MCONSTANT_GP (OPTION_MD_BASE + 1)
177 {"mconstant-gp", no_argument
, NULL
, OPTION_MCONSTANT_GP
},
178 #define OPTION_MAUTO_PIC (OPTION_MD_BASE + 2)
179 {"mauto-pic", no_argument
, NULL
, OPTION_MAUTO_PIC
}
182 size_t md_longopts_size
= sizeof (md_longopts
);
186 struct hash_control
*pseudo_hash
; /* pseudo opcode hash table */
187 struct hash_control
*reg_hash
; /* register name hash table */
188 struct hash_control
*dynreg_hash
; /* dynamic register hash table */
189 struct hash_control
*const_hash
; /* constant hash table */
190 struct hash_control
*entry_hash
; /* code entry hint hash table */
192 symbolS
*regsym
[REG_NUM
];
194 /* If X_op is != O_absent, the registername for the instruction's
195 qualifying predicate. If NULL, p0 is assumed for instructions
196 that are predicatable. */
203 explicit_mode
: 1, /* which mode we're in */
204 default_explicit_mode
: 1, /* which mode is the default */
205 mode_explicitly_set
: 1, /* was the current mode explicitly set? */
207 keep_pending_output
: 1;
209 /* Each bundle consists of up to three instructions. We keep
210 track of four most recent instructions so we can correctly set
211 the end_of_insn_group for the last instruction in a bundle. */
213 int num_slots_in_use
;
217 end_of_insn_group
: 1,
218 manual_bundling_on
: 1,
219 manual_bundling_off
: 1;
220 signed char user_template
; /* user-selected template, if any */
221 unsigned char qp_regno
; /* qualifying predicate */
222 /* This duplicates a good fraction of "struct fix" but we
223 can't use a "struct fix" instead since we can't call
224 fix_new_exp() until we know the address of the instruction. */
228 bfd_reloc_code_real_type code
;
229 enum ia64_opnd opnd
; /* type of operand in need of fix */
230 unsigned int is_pcrel
: 1; /* is operand pc-relative? */
231 expressionS expr
; /* the value to be inserted */
233 fixup
[2]; /* at most two fixups per insn */
234 struct ia64_opcode
*idesc
;
235 struct label_fix
*label_fixups
;
236 struct label_fix
*tag_fixups
;
237 struct unw_rec_list
*unwind_record
; /* Unwind directive. */
240 unsigned int src_line
;
241 struct dwarf2_line_info debug_line
;
249 struct dynreg
*next
; /* next dynamic register */
251 unsigned short base
; /* the base register number */
252 unsigned short num_regs
; /* # of registers in this set */
254 *dynreg
[DYNREG_NUM_TYPES
], in
, loc
, out
, rot
;
256 flagword flags
; /* ELF-header flags */
259 unsigned hint
:1; /* is this hint currently valid? */
260 bfd_vma offset
; /* mem.offset offset */
261 bfd_vma base
; /* mem.offset base */
264 int path
; /* number of alt. entry points seen */
265 const char **entry_labels
; /* labels of all alternate paths in
266 the current DV-checking block. */
267 int maxpaths
; /* size currently allocated for
269 /* Support for hardware errata workarounds. */
271 /* Record data about the last three insn groups. */
274 /* B-step workaround.
275 For each predicate register, this is set if the corresponding insn
276 group conditionally sets this register with one of the affected
279 /* B-step workaround.
280 For each general register, this is set if the corresponding insn
281 a) is conditional one one of the predicate registers for which
282 P_REG_SET is 1 in the corresponding entry of the previous group,
283 b) sets this general register with one of the affected
285 int g_reg_set_conditionally
[128];
289 int pointer_size
; /* size in bytes of a pointer */
290 int pointer_size_shift
; /* shift size of a pointer for alignment */
294 /* application registers: */
300 #define AR_BSPSTORE 18
315 {"ar.k0", 0}, {"ar.k1", 1}, {"ar.k2", 2}, {"ar.k3", 3},
316 {"ar.k4", 4}, {"ar.k5", 5}, {"ar.k6", 6}, {"ar.k7", 7},
317 {"ar.rsc", 16}, {"ar.bsp", 17},
318 {"ar.bspstore", 18}, {"ar.rnat", 19},
319 {"ar.fcr", 21}, {"ar.eflag", 24},
320 {"ar.csd", 25}, {"ar.ssd", 26},
321 {"ar.cflg", 27}, {"ar.fsr", 28},
322 {"ar.fir", 29}, {"ar.fdr", 30},
323 {"ar.ccv", 32}, {"ar.unat", 36},
324 {"ar.fpsr", 40}, {"ar.itc", 44},
325 {"ar.pfs", 64}, {"ar.lc", 65},
346 /* control registers: */
388 static const struct const_desc
395 /* PSR constant masks: */
398 {"psr.be", ((valueT
) 1) << 1},
399 {"psr.up", ((valueT
) 1) << 2},
400 {"psr.ac", ((valueT
) 1) << 3},
401 {"psr.mfl", ((valueT
) 1) << 4},
402 {"psr.mfh", ((valueT
) 1) << 5},
404 {"psr.ic", ((valueT
) 1) << 13},
405 {"psr.i", ((valueT
) 1) << 14},
406 {"psr.pk", ((valueT
) 1) << 15},
408 {"psr.dt", ((valueT
) 1) << 17},
409 {"psr.dfl", ((valueT
) 1) << 18},
410 {"psr.dfh", ((valueT
) 1) << 19},
411 {"psr.sp", ((valueT
) 1) << 20},
412 {"psr.pp", ((valueT
) 1) << 21},
413 {"psr.di", ((valueT
) 1) << 22},
414 {"psr.si", ((valueT
) 1) << 23},
415 {"psr.db", ((valueT
) 1) << 24},
416 {"psr.lp", ((valueT
) 1) << 25},
417 {"psr.tb", ((valueT
) 1) << 26},
418 {"psr.rt", ((valueT
) 1) << 27},
419 /* 28-31: reserved */
420 /* 32-33: cpl (current privilege level) */
421 {"psr.is", ((valueT
) 1) << 34},
422 {"psr.mc", ((valueT
) 1) << 35},
423 {"psr.it", ((valueT
) 1) << 36},
424 {"psr.id", ((valueT
) 1) << 37},
425 {"psr.da", ((valueT
) 1) << 38},
426 {"psr.dd", ((valueT
) 1) << 39},
427 {"psr.ss", ((valueT
) 1) << 40},
428 /* 41-42: ri (restart instruction) */
429 {"psr.ed", ((valueT
) 1) << 43},
430 {"psr.bn", ((valueT
) 1) << 44},
433 /* indirect register-sets/memory: */
442 { "CPUID", IND_CPUID
},
443 { "cpuid", IND_CPUID
},
455 /* Pseudo functions used to indicate relocation types (these functions
456 start with an at sign (@). */
478 /* reloc pseudo functions (these must come first!): */
479 { "fptr", PSEUDO_FUNC_RELOC
, { 0 } },
480 { "gprel", PSEUDO_FUNC_RELOC
, { 0 } },
481 { "ltoff", PSEUDO_FUNC_RELOC
, { 0 } },
482 { "pcrel", PSEUDO_FUNC_RELOC
, { 0 } },
483 { "pltoff", PSEUDO_FUNC_RELOC
, { 0 } },
484 { "secrel", PSEUDO_FUNC_RELOC
, { 0 } },
485 { "segrel", PSEUDO_FUNC_RELOC
, { 0 } },
486 { "ltv", PSEUDO_FUNC_RELOC
, { 0 } },
487 { "", 0, { 0 } }, /* placeholder for FUNC_LT_FPTR_RELATIVE */
488 { "iplt", PSEUDO_FUNC_RELOC
, { 0 } },
490 /* mbtype4 constants: */
491 { "alt", PSEUDO_FUNC_CONST
, { 0xa } },
492 { "brcst", PSEUDO_FUNC_CONST
, { 0x0 } },
493 { "mix", PSEUDO_FUNC_CONST
, { 0x8 } },
494 { "rev", PSEUDO_FUNC_CONST
, { 0xb } },
495 { "shuf", PSEUDO_FUNC_CONST
, { 0x9 } },
497 /* fclass constants: */
498 { "nat", PSEUDO_FUNC_CONST
, { 0x100 } },
499 { "qnan", PSEUDO_FUNC_CONST
, { 0x080 } },
500 { "snan", PSEUDO_FUNC_CONST
, { 0x040 } },
501 { "pos", PSEUDO_FUNC_CONST
, { 0x001 } },
502 { "neg", PSEUDO_FUNC_CONST
, { 0x002 } },
503 { "zero", PSEUDO_FUNC_CONST
, { 0x004 } },
504 { "unorm", PSEUDO_FUNC_CONST
, { 0x008 } },
505 { "norm", PSEUDO_FUNC_CONST
, { 0x010 } },
506 { "inf", PSEUDO_FUNC_CONST
, { 0x020 } },
508 { "natval", PSEUDO_FUNC_CONST
, { 0x100 } }, /* old usage */
510 /* unwind-related constants: */
511 { "svr4", PSEUDO_FUNC_CONST
, { 0 } },
512 { "hpux", PSEUDO_FUNC_CONST
, { 1 } },
513 { "nt", PSEUDO_FUNC_CONST
, { 2 } },
515 /* unwind-related registers: */
516 { "priunat",PSEUDO_FUNC_REG
, { REG_PRIUNAT
} }
519 /* 41-bit nop opcodes (one per unit): */
520 static const bfd_vma nop
[IA64_NUM_UNITS
] =
522 0x0000000000LL
, /* NIL => break 0 */
523 0x0008000000LL
, /* I-unit nop */
524 0x0008000000LL
, /* M-unit nop */
525 0x4000000000LL
, /* B-unit nop */
526 0x0008000000LL
, /* F-unit nop */
527 0x0008000000LL
, /* L-"unit" nop */
528 0x0008000000LL
, /* X-unit nop */
531 /* Can't be `const' as it's passed to input routines (which have the
532 habit of setting temporary sentinels. */
533 static char special_section_name
[][20] =
535 {".bss"}, {".sbss"}, {".sdata"}, {".rodata"}, {".comment"},
536 {".IA_64.unwind"}, {".IA_64.unwind_info"},
537 {".init_array"}, {".fini_array"}
540 static char *special_linkonce_name
[] =
542 ".gnu.linkonce.ia64unw.", ".gnu.linkonce.ia64unwi."
545 /* The best template for a particular sequence of up to three
547 #define N IA64_NUM_TYPES
548 static unsigned char best_template
[N
][N
][N
];
551 /* Resource dependencies currently in effect */
553 int depind
; /* dependency index */
554 const struct ia64_dependency
*dependency
; /* actual dependency */
555 unsigned specific
:1, /* is this a specific bit/regno? */
556 link_to_qp_branch
:1; /* will a branch on the same QP clear it?*/
557 int index
; /* specific regno/bit within dependency */
558 int note
; /* optional qualifying note (0 if none) */
562 int insn_srlz
; /* current insn serialization state */
563 int data_srlz
; /* current data serialization state */
564 int qp_regno
; /* qualifying predicate for this usage */
565 char *file
; /* what file marked this dependency */
566 unsigned int line
; /* what line marked this dependency */
567 struct mem_offset mem_offset
; /* optional memory offset hint */
568 enum { CMP_NONE
, CMP_OR
, CMP_AND
} cmp_type
; /* OR or AND compare? */
569 int path
; /* corresponding code entry index */
571 static int regdepslen
= 0;
572 static int regdepstotlen
= 0;
573 static const char *dv_mode
[] = { "RAW", "WAW", "WAR" };
574 static const char *dv_sem
[] = { "none", "implied", "impliedf",
575 "data", "instr", "specific", "stop", "other" };
576 static const char *dv_cmp_type
[] = { "none", "OR", "AND" };
578 /* Current state of PR mutexation */
579 static struct qpmutex
{
582 } *qp_mutexes
= NULL
; /* QP mutex bitmasks */
583 static int qp_mutexeslen
= 0;
584 static int qp_mutexestotlen
= 0;
585 static valueT qp_safe_across_calls
= 0;
587 /* Current state of PR implications */
588 static struct qp_imply
{
591 unsigned p2_branched
:1;
593 } *qp_implies
= NULL
;
594 static int qp_implieslen
= 0;
595 static int qp_impliestotlen
= 0;
597 /* Keep track of static GR values so that indirect register usage can
598 sometimes be tracked. */
603 } gr_values
[128] = {{ 1, 0, 0 }};
605 /* These are the routines required to output the various types of
608 /* A slot_number is a frag address plus the slot index (0-2). We use the
609 frag address here so that if there is a section switch in the middle of
610 a function, then instructions emitted to a different section are not
611 counted. Since there may be more than one frag for a function, this
612 means we also need to keep track of which frag this address belongs to
613 so we can compute inter-frag distances. This also nicely solves the
614 problem with nops emitted for align directives, which can't easily be
615 counted, but can easily be derived from frag sizes. */
617 typedef struct unw_rec_list
{
619 unsigned long slot_number
;
621 struct unw_rec_list
*next
;
624 #define SLOT_NUM_NOT_SET (unsigned)-1
626 /* Linked list of saved prologue counts. A very poor
627 implementation of a map from label numbers to prologue counts. */
628 typedef struct label_prologue_count
630 struct label_prologue_count
*next
;
631 unsigned long label_number
;
632 unsigned int prologue_count
;
633 } label_prologue_count
;
637 unsigned long next_slot_number
;
638 fragS
*next_slot_frag
;
640 /* Maintain a list of unwind entries for the current function. */
644 /* Any unwind entires that should be attached to the current slot
645 that an insn is being constructed for. */
646 unw_rec_list
*current_entry
;
648 /* These are used to create the unwind table entry for this function. */
651 symbolS
*info
; /* pointer to unwind info */
652 symbolS
*personality_routine
;
654 subsegT saved_text_subseg
;
655 unsigned int force_unwind_entry
: 1; /* force generation of unwind entry? */
657 /* TRUE if processing unwind directives in a prologue region. */
660 unsigned int prologue_count
; /* number of .prologues seen so far */
661 /* Prologue counts at previous .label_state directives. */
662 struct label_prologue_count
* saved_prologue_counts
;
665 typedef void (*vbyte_func
) PARAMS ((int, char *, char *));
667 /* Forward delarations: */
668 static int ar_is_in_integer_unit
PARAMS ((int regnum
));
669 static void set_section
PARAMS ((char *name
));
670 static unsigned int set_regstack
PARAMS ((unsigned int, unsigned int,
671 unsigned int, unsigned int));
672 static void dot_radix
PARAMS ((int));
673 static void dot_special_section
PARAMS ((int));
674 static void dot_proc
PARAMS ((int));
675 static void dot_fframe
PARAMS ((int));
676 static void dot_vframe
PARAMS ((int));
677 static void dot_vframesp
PARAMS ((int));
678 static void dot_vframepsp
PARAMS ((int));
679 static void dot_save
PARAMS ((int));
680 static void dot_restore
PARAMS ((int));
681 static void dot_restorereg
PARAMS ((int));
682 static void dot_restorereg_p
PARAMS ((int));
683 static void dot_handlerdata
PARAMS ((int));
684 static void dot_unwentry
PARAMS ((int));
685 static void dot_altrp
PARAMS ((int));
686 static void dot_savemem
PARAMS ((int));
687 static void dot_saveg
PARAMS ((int));
688 static void dot_savef
PARAMS ((int));
689 static void dot_saveb
PARAMS ((int));
690 static void dot_savegf
PARAMS ((int));
691 static void dot_spill
PARAMS ((int));
692 static void dot_spillreg
PARAMS ((int));
693 static void dot_spillmem
PARAMS ((int));
694 static void dot_spillreg_p
PARAMS ((int));
695 static void dot_spillmem_p
PARAMS ((int));
696 static void dot_label_state
PARAMS ((int));
697 static void dot_copy_state
PARAMS ((int));
698 static void dot_unwabi
PARAMS ((int));
699 static void dot_personality
PARAMS ((int));
700 static void dot_body
PARAMS ((int));
701 static void dot_prologue
PARAMS ((int));
702 static void dot_endp
PARAMS ((int));
703 static void dot_template
PARAMS ((int));
704 static void dot_regstk
PARAMS ((int));
705 static void dot_rot
PARAMS ((int));
706 static void dot_byteorder
PARAMS ((int));
707 static void dot_psr
PARAMS ((int));
708 static void dot_alias
PARAMS ((int));
709 static void dot_ln
PARAMS ((int));
710 static char *parse_section_name
PARAMS ((void));
711 static void dot_xdata
PARAMS ((int));
712 static void stmt_float_cons
PARAMS ((int));
713 static void stmt_cons_ua
PARAMS ((int));
714 static void dot_xfloat_cons
PARAMS ((int));
715 static void dot_xstringer
PARAMS ((int));
716 static void dot_xdata_ua
PARAMS ((int));
717 static void dot_xfloat_cons_ua
PARAMS ((int));
718 static void print_prmask
PARAMS ((valueT mask
));
719 static void dot_pred_rel
PARAMS ((int));
720 static void dot_reg_val
PARAMS ((int));
721 static void dot_dv_mode
PARAMS ((int));
722 static void dot_entry
PARAMS ((int));
723 static void dot_mem_offset
PARAMS ((int));
724 static void add_unwind_entry
PARAMS((unw_rec_list
*ptr
));
725 static symbolS
*declare_register
PARAMS ((const char *name
, int regnum
));
726 static void declare_register_set
PARAMS ((const char *, int, int));
727 static unsigned int operand_width
PARAMS ((enum ia64_opnd
));
728 static enum operand_match_result operand_match
PARAMS ((const struct ia64_opcode
*idesc
,
731 static int parse_operand
PARAMS ((expressionS
*e
));
732 static struct ia64_opcode
* parse_operands
PARAMS ((struct ia64_opcode
*));
733 static int errata_nop_necessary_p
PARAMS ((struct slot
*, enum ia64_unit
));
734 static void build_insn
PARAMS ((struct slot
*, bfd_vma
*));
735 static void emit_one_bundle
PARAMS ((void));
736 static void fix_insn
PARAMS ((fixS
*, const struct ia64_operand
*, valueT
));
737 static bfd_reloc_code_real_type ia64_gen_real_reloc_type
PARAMS ((struct symbol
*sym
,
738 bfd_reloc_code_real_type r_type
));
739 static void insn_group_break
PARAMS ((int, int, int));
740 static void mark_resource
PARAMS ((struct ia64_opcode
*, const struct ia64_dependency
*,
741 struct rsrc
*, int depind
, int path
));
742 static void add_qp_mutex
PARAMS((valueT mask
));
743 static void add_qp_imply
PARAMS((int p1
, int p2
));
744 static void clear_qp_branch_flag
PARAMS((valueT mask
));
745 static void clear_qp_mutex
PARAMS((valueT mask
));
746 static void clear_qp_implies
PARAMS((valueT p1_mask
, valueT p2_mask
));
747 static int has_suffix_p
PARAMS((const char *, const char *));
748 static void clear_register_values
PARAMS ((void));
749 static void print_dependency
PARAMS ((const char *action
, int depind
));
750 static void instruction_serialization
PARAMS ((void));
751 static void data_serialization
PARAMS ((void));
752 static void remove_marked_resource
PARAMS ((struct rsrc
*));
753 static int is_conditional_branch
PARAMS ((struct ia64_opcode
*));
754 static int is_taken_branch
PARAMS ((struct ia64_opcode
*));
755 static int is_interruption_or_rfi
PARAMS ((struct ia64_opcode
*));
756 static int depends_on
PARAMS ((int, struct ia64_opcode
*));
757 static int specify_resource
PARAMS ((const struct ia64_dependency
*,
758 struct ia64_opcode
*, int, struct rsrc
[], int, int));
759 static int check_dv
PARAMS((struct ia64_opcode
*idesc
));
760 static void check_dependencies
PARAMS((struct ia64_opcode
*));
761 static void mark_resources
PARAMS((struct ia64_opcode
*));
762 static void update_dependencies
PARAMS((struct ia64_opcode
*));
763 static void note_register_values
PARAMS((struct ia64_opcode
*));
764 static int qp_mutex
PARAMS ((int, int, int));
765 static int resources_match
PARAMS ((struct rsrc
*, struct ia64_opcode
*, int, int, int));
766 static void output_vbyte_mem
PARAMS ((int, char *, char *));
767 static void count_output
PARAMS ((int, char *, char *));
768 static void output_R1_format
PARAMS ((vbyte_func
, unw_record_type
, int));
769 static void output_R2_format
PARAMS ((vbyte_func
, int, int, unsigned long));
770 static void output_R3_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
771 static void output_P1_format
PARAMS ((vbyte_func
, int));
772 static void output_P2_format
PARAMS ((vbyte_func
, int, int));
773 static void output_P3_format
PARAMS ((vbyte_func
, unw_record_type
, int));
774 static void output_P4_format
PARAMS ((vbyte_func
, unsigned char *, unsigned long));
775 static void output_P5_format
PARAMS ((vbyte_func
, int, unsigned long));
776 static void output_P6_format
PARAMS ((vbyte_func
, unw_record_type
, int));
777 static void output_P7_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long, unsigned long));
778 static void output_P8_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
779 static void output_P9_format
PARAMS ((vbyte_func
, int, int));
780 static void output_P10_format
PARAMS ((vbyte_func
, int, int));
781 static void output_B1_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
782 static void output_B2_format
PARAMS ((vbyte_func
, unsigned long, unsigned long));
783 static void output_B3_format
PARAMS ((vbyte_func
, unsigned long, unsigned long));
784 static void output_B4_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
785 static char format_ab_reg
PARAMS ((int, int));
786 static void output_X1_format
PARAMS ((vbyte_func
, unw_record_type
, int, int, unsigned long,
788 static void output_X2_format
PARAMS ((vbyte_func
, int, int, int, int, int, unsigned long));
789 static void output_X3_format
PARAMS ((vbyte_func
, unw_record_type
, int, int, int, unsigned long,
791 static void output_X4_format
PARAMS ((vbyte_func
, int, int, int, int, int, int, unsigned long));
792 static void free_list_records
PARAMS ((unw_rec_list
*));
793 static unw_rec_list
*output_prologue
PARAMS ((void));
794 static unw_rec_list
*output_prologue_gr
PARAMS ((unsigned int, unsigned int));
795 static unw_rec_list
*output_body
PARAMS ((void));
796 static unw_rec_list
*output_mem_stack_f
PARAMS ((unsigned int));
797 static unw_rec_list
*output_mem_stack_v
PARAMS ((void));
798 static unw_rec_list
*output_psp_gr
PARAMS ((unsigned int));
799 static unw_rec_list
*output_psp_sprel
PARAMS ((unsigned int));
800 static unw_rec_list
*output_rp_when
PARAMS ((void));
801 static unw_rec_list
*output_rp_gr
PARAMS ((unsigned int));
802 static unw_rec_list
*output_rp_br
PARAMS ((unsigned int));
803 static unw_rec_list
*output_rp_psprel
PARAMS ((unsigned int));
804 static unw_rec_list
*output_rp_sprel
PARAMS ((unsigned int));
805 static unw_rec_list
*output_pfs_when
PARAMS ((void));
806 static unw_rec_list
*output_pfs_gr
PARAMS ((unsigned int));
807 static unw_rec_list
*output_pfs_psprel
PARAMS ((unsigned int));
808 static unw_rec_list
*output_pfs_sprel
PARAMS ((unsigned int));
809 static unw_rec_list
*output_preds_when
PARAMS ((void));
810 static unw_rec_list
*output_preds_gr
PARAMS ((unsigned int));
811 static unw_rec_list
*output_preds_psprel
PARAMS ((unsigned int));
812 static unw_rec_list
*output_preds_sprel
PARAMS ((unsigned int));
813 static unw_rec_list
*output_fr_mem
PARAMS ((unsigned int));
814 static unw_rec_list
*output_frgr_mem
PARAMS ((unsigned int, unsigned int));
815 static unw_rec_list
*output_gr_gr
PARAMS ((unsigned int, unsigned int));
816 static unw_rec_list
*output_gr_mem
PARAMS ((unsigned int));
817 static unw_rec_list
*output_br_mem
PARAMS ((unsigned int));
818 static unw_rec_list
*output_br_gr
PARAMS ((unsigned int, unsigned int));
819 static unw_rec_list
*output_spill_base
PARAMS ((unsigned int));
820 static unw_rec_list
*output_unat_when
PARAMS ((void));
821 static unw_rec_list
*output_unat_gr
PARAMS ((unsigned int));
822 static unw_rec_list
*output_unat_psprel
PARAMS ((unsigned int));
823 static unw_rec_list
*output_unat_sprel
PARAMS ((unsigned int));
824 static unw_rec_list
*output_lc_when
PARAMS ((void));
825 static unw_rec_list
*output_lc_gr
PARAMS ((unsigned int));
826 static unw_rec_list
*output_lc_psprel
PARAMS ((unsigned int));
827 static unw_rec_list
*output_lc_sprel
PARAMS ((unsigned int));
828 static unw_rec_list
*output_fpsr_when
PARAMS ((void));
829 static unw_rec_list
*output_fpsr_gr
PARAMS ((unsigned int));
830 static unw_rec_list
*output_fpsr_psprel
PARAMS ((unsigned int));
831 static unw_rec_list
*output_fpsr_sprel
PARAMS ((unsigned int));
832 static unw_rec_list
*output_priunat_when_gr
PARAMS ((void));
833 static unw_rec_list
*output_priunat_when_mem
PARAMS ((void));
834 static unw_rec_list
*output_priunat_gr
PARAMS ((unsigned int));
835 static unw_rec_list
*output_priunat_psprel
PARAMS ((unsigned int));
836 static unw_rec_list
*output_priunat_sprel
PARAMS ((unsigned int));
837 static unw_rec_list
*output_bsp_when
PARAMS ((void));
838 static unw_rec_list
*output_bsp_gr
PARAMS ((unsigned int));
839 static unw_rec_list
*output_bsp_psprel
PARAMS ((unsigned int));
840 static unw_rec_list
*output_bsp_sprel
PARAMS ((unsigned int));
841 static unw_rec_list
*output_bspstore_when
PARAMS ((void));
842 static unw_rec_list
*output_bspstore_gr
PARAMS ((unsigned int));
843 static unw_rec_list
*output_bspstore_psprel
PARAMS ((unsigned int));
844 static unw_rec_list
*output_bspstore_sprel
PARAMS ((unsigned int));
845 static unw_rec_list
*output_rnat_when
PARAMS ((void));
846 static unw_rec_list
*output_rnat_gr
PARAMS ((unsigned int));
847 static unw_rec_list
*output_rnat_psprel
PARAMS ((unsigned int));
848 static unw_rec_list
*output_rnat_sprel
PARAMS ((unsigned int));
849 static unw_rec_list
*output_unwabi
PARAMS ((unsigned long, unsigned long));
850 static unw_rec_list
*output_epilogue
PARAMS ((unsigned long));
851 static unw_rec_list
*output_label_state
PARAMS ((unsigned long));
852 static unw_rec_list
*output_copy_state
PARAMS ((unsigned long));
853 static unw_rec_list
*output_spill_psprel
PARAMS ((unsigned int, unsigned int, unsigned int));
854 static unw_rec_list
*output_spill_sprel
PARAMS ((unsigned int, unsigned int, unsigned int));
855 static unw_rec_list
*output_spill_psprel_p
PARAMS ((unsigned int, unsigned int, unsigned int,
857 static unw_rec_list
*output_spill_sprel_p
PARAMS ((unsigned int, unsigned int, unsigned int,
859 static unw_rec_list
*output_spill_reg
PARAMS ((unsigned int, unsigned int, unsigned int,
861 static unw_rec_list
*output_spill_reg_p
PARAMS ((unsigned int, unsigned int, unsigned int,
862 unsigned int, unsigned int));
863 static void process_one_record
PARAMS ((unw_rec_list
*, vbyte_func
));
864 static void process_unw_records
PARAMS ((unw_rec_list
*, vbyte_func
));
865 static int calc_record_size
PARAMS ((unw_rec_list
*));
866 static void set_imask
PARAMS ((unw_rec_list
*, unsigned long, unsigned long, unsigned int));
867 static int count_bits
PARAMS ((unsigned long));
868 static unsigned long slot_index
PARAMS ((unsigned long, fragS
*,
869 unsigned long, fragS
*));
870 static unw_rec_list
*optimize_unw_records
PARAMS ((unw_rec_list
*));
871 static void fixup_unw_records
PARAMS ((unw_rec_list
*));
872 static int output_unw_records
PARAMS ((unw_rec_list
*, void **));
873 static int convert_expr_to_ab_reg
PARAMS ((expressionS
*, unsigned int *, unsigned int *));
874 static int convert_expr_to_xy_reg
PARAMS ((expressionS
*, unsigned int *, unsigned int *));
875 static int generate_unwind_image
PARAMS ((const char *));
876 static unsigned int get_saved_prologue_count
PARAMS ((unsigned long));
877 static void save_prologue_count
PARAMS ((unsigned long, unsigned int));
878 static void free_saved_prologue_counts
PARAMS ((void));
880 /* Build the unwind section name by appending the (possibly stripped)
881 text section NAME to the unwind PREFIX. The resulting string
882 pointer is assigned to RESULT. The string is allocated on the
883 stack, so this must be a macro... */
884 #define make_unw_section_name(special, text_name, result) \
886 const char *_prefix = special_section_name[special]; \
887 const char *_suffix = text_name; \
888 size_t _prefix_len, _suffix_len; \
890 if (strncmp (text_name, ".gnu.linkonce.t.", \
891 sizeof (".gnu.linkonce.t.") - 1) == 0) \
893 _prefix = special_linkonce_name[special - SPECIAL_SECTION_UNWIND]; \
894 _suffix += sizeof (".gnu.linkonce.t.") - 1; \
896 _prefix_len = strlen (_prefix), _suffix_len = strlen (_suffix); \
897 _result = alloca (_prefix_len + _suffix_len + 1); \
898 memcpy (_result, _prefix, _prefix_len); \
899 memcpy (_result + _prefix_len, _suffix, _suffix_len); \
900 _result[_prefix_len + _suffix_len] = '\0'; \
905 /* Determine if application register REGNUM resides in the integer
906 unit (as opposed to the memory unit). */
908 ar_is_in_integer_unit (reg
)
913 return (reg
== 64 /* pfs */
914 || reg
== 65 /* lc */
915 || reg
== 66 /* ec */
916 /* ??? ias accepts and puts these in the integer unit. */
917 || (reg
>= 112 && reg
<= 127));
920 /* Switch to section NAME and create section if necessary. It's
921 rather ugly that we have to manipulate input_line_pointer but I
922 don't see any other way to accomplish the same thing without
923 changing obj-elf.c (which may be the Right Thing, in the end). */
928 char *saved_input_line_pointer
;
930 saved_input_line_pointer
= input_line_pointer
;
931 input_line_pointer
= name
;
933 input_line_pointer
= saved_input_line_pointer
;
936 /* Map 's' to SHF_IA_64_SHORT. */
939 ia64_elf_section_letter (letter
, ptr_msg
)
944 return SHF_IA_64_SHORT
;
946 *ptr_msg
= _("Bad .section directive: want a,s,w,x,M,S in string");
950 /* Map SHF_IA_64_SHORT to SEC_SMALL_DATA. */
953 ia64_elf_section_flags (flags
, attr
, type
)
955 int attr
, type ATTRIBUTE_UNUSED
;
957 if (attr
& SHF_IA_64_SHORT
)
958 flags
|= SEC_SMALL_DATA
;
963 ia64_elf_section_type (str
, len
)
967 #define STREQ(s) ((len == sizeof (s) - 1) && (strncmp (str, s, sizeof (s) - 1) == 0))
969 if (STREQ (ELF_STRING_ia64_unwind_info
))
972 if (STREQ (ELF_STRING_ia64_unwind_info_once
))
975 if (STREQ (ELF_STRING_ia64_unwind
))
976 return SHT_IA_64_UNWIND
;
978 if (STREQ (ELF_STRING_ia64_unwind_once
))
979 return SHT_IA_64_UNWIND
;
981 if (STREQ ("init_array"))
982 return SHT_INIT_ARRAY
;
984 if (STREQ ("fini_array"))
985 return SHT_FINI_ARRAY
;
992 set_regstack (ins
, locs
, outs
, rots
)
993 unsigned int ins
, locs
, outs
, rots
;
998 sof
= ins
+ locs
+ outs
;
1001 as_bad ("Size of frame exceeds maximum of 96 registers");
1006 as_warn ("Size of rotating registers exceeds frame size");
1009 md
.in
.base
= REG_GR
+ 32;
1010 md
.loc
.base
= md
.in
.base
+ ins
;
1011 md
.out
.base
= md
.loc
.base
+ locs
;
1013 md
.in
.num_regs
= ins
;
1014 md
.loc
.num_regs
= locs
;
1015 md
.out
.num_regs
= outs
;
1016 md
.rot
.num_regs
= rots
;
1023 struct label_fix
*lfix
;
1025 subsegT saved_subseg
;
1028 if (!md
.last_text_seg
)
1031 saved_seg
= now_seg
;
1032 saved_subseg
= now_subseg
;
1034 subseg_set (md
.last_text_seg
, 0);
1036 while (md
.num_slots_in_use
> 0)
1037 emit_one_bundle (); /* force out queued instructions */
1039 /* In case there are labels following the last instruction, resolve
1041 for (lfix
= CURR_SLOT
.label_fixups
; lfix
; lfix
= lfix
->next
)
1043 S_SET_VALUE (lfix
->sym
, frag_now_fix ());
1044 symbol_set_frag (lfix
->sym
, frag_now
);
1046 CURR_SLOT
.label_fixups
= 0;
1047 for (lfix
= CURR_SLOT
.tag_fixups
; lfix
; lfix
= lfix
->next
)
1049 S_SET_VALUE (lfix
->sym
, frag_now_fix ());
1050 symbol_set_frag (lfix
->sym
, frag_now
);
1052 CURR_SLOT
.tag_fixups
= 0;
1054 /* In case there are unwind directives following the last instruction,
1055 resolve those now. We only handle body and prologue directives here.
1056 Give an error for others. */
1057 for (ptr
= unwind
.current_entry
; ptr
; ptr
= ptr
->next
)
1059 if (ptr
->r
.type
== prologue
|| ptr
->r
.type
== prologue_gr
1060 || ptr
->r
.type
== body
)
1062 ptr
->slot_number
= (unsigned long) frag_more (0);
1063 ptr
->slot_frag
= frag_now
;
1066 as_bad (_("Unwind directive not followed by an instruction."));
1068 unwind
.current_entry
= NULL
;
1070 subseg_set (saved_seg
, saved_subseg
);
1072 if (md
.qp
.X_op
== O_register
)
1073 as_bad ("qualifying predicate not followed by instruction");
1077 ia64_do_align (nbytes
)
1080 char *saved_input_line_pointer
= input_line_pointer
;
1082 input_line_pointer
= "";
1083 s_align_bytes (nbytes
);
1084 input_line_pointer
= saved_input_line_pointer
;
1088 ia64_cons_align (nbytes
)
1093 char *saved_input_line_pointer
= input_line_pointer
;
1094 input_line_pointer
= "";
1095 s_align_bytes (nbytes
);
1096 input_line_pointer
= saved_input_line_pointer
;
1100 /* Output COUNT bytes to a memory location. */
1101 static unsigned char *vbyte_mem_ptr
= NULL
;
1104 output_vbyte_mem (count
, ptr
, comment
)
1107 char *comment ATTRIBUTE_UNUSED
;
1110 if (vbyte_mem_ptr
== NULL
)
1115 for (x
= 0; x
< count
; x
++)
1116 *(vbyte_mem_ptr
++) = ptr
[x
];
1119 /* Count the number of bytes required for records. */
1120 static int vbyte_count
= 0;
1122 count_output (count
, ptr
, comment
)
1124 char *ptr ATTRIBUTE_UNUSED
;
1125 char *comment ATTRIBUTE_UNUSED
;
1127 vbyte_count
+= count
;
1131 output_R1_format (f
, rtype
, rlen
)
1133 unw_record_type rtype
;
1140 output_R3_format (f
, rtype
, rlen
);
1146 else if (rtype
!= prologue
)
1147 as_bad ("record type is not valid");
1149 byte
= UNW_R1
| (r
<< 5) | (rlen
& 0x1f);
1150 (*f
) (1, &byte
, NULL
);
1154 output_R2_format (f
, mask
, grsave
, rlen
)
1161 mask
= (mask
& 0x0f);
1162 grsave
= (grsave
& 0x7f);
1164 bytes
[0] = (UNW_R2
| (mask
>> 1));
1165 bytes
[1] = (((mask
& 0x01) << 7) | grsave
);
1166 count
+= output_leb128 (bytes
+ 2, rlen
, 0);
1167 (*f
) (count
, bytes
, NULL
);
1171 output_R3_format (f
, rtype
, rlen
)
1173 unw_record_type rtype
;
1180 output_R1_format (f
, rtype
, rlen
);
1186 else if (rtype
!= prologue
)
1187 as_bad ("record type is not valid");
1188 bytes
[0] = (UNW_R3
| r
);
1189 count
= output_leb128 (bytes
+ 1, rlen
, 0);
1190 (*f
) (count
+ 1, bytes
, NULL
);
1194 output_P1_format (f
, brmask
)
1199 byte
= UNW_P1
| (brmask
& 0x1f);
1200 (*f
) (1, &byte
, NULL
);
1204 output_P2_format (f
, brmask
, gr
)
1210 brmask
= (brmask
& 0x1f);
1211 bytes
[0] = UNW_P2
| (brmask
>> 1);
1212 bytes
[1] = (((brmask
& 1) << 7) | gr
);
1213 (*f
) (2, bytes
, NULL
);
1217 output_P3_format (f
, rtype
, reg
)
1219 unw_record_type rtype
;
1264 as_bad ("Invalid record type for P3 format.");
1266 bytes
[0] = (UNW_P3
| (r
>> 1));
1267 bytes
[1] = (((r
& 1) << 7) | reg
);
1268 (*f
) (2, bytes
, NULL
);
1272 output_P4_format (f
, imask
, imask_size
)
1274 unsigned char *imask
;
1275 unsigned long imask_size
;
1278 (*f
) (imask_size
, imask
, NULL
);
1282 output_P5_format (f
, grmask
, frmask
)
1285 unsigned long frmask
;
1288 grmask
= (grmask
& 0x0f);
1291 bytes
[1] = ((grmask
<< 4) | ((frmask
& 0x000f0000) >> 16));
1292 bytes
[2] = ((frmask
& 0x0000ff00) >> 8);
1293 bytes
[3] = (frmask
& 0x000000ff);
1294 (*f
) (4, bytes
, NULL
);
1298 output_P6_format (f
, rtype
, rmask
)
1300 unw_record_type rtype
;
1306 if (rtype
== gr_mem
)
1308 else if (rtype
!= fr_mem
)
1309 as_bad ("Invalid record type for format P6");
1310 byte
= (UNW_P6
| (r
<< 4) | (rmask
& 0x0f));
1311 (*f
) (1, &byte
, NULL
);
1315 output_P7_format (f
, rtype
, w1
, w2
)
1317 unw_record_type rtype
;
1324 count
+= output_leb128 (bytes
+ 1, w1
, 0);
1329 count
+= output_leb128 (bytes
+ count
, w2
>> 4, 0);
1379 bytes
[0] = (UNW_P7
| r
);
1380 (*f
) (count
, bytes
, NULL
);
1384 output_P8_format (f
, rtype
, t
)
1386 unw_record_type rtype
;
1425 case bspstore_psprel
:
1428 case bspstore_sprel
:
1440 case priunat_when_gr
:
1443 case priunat_psprel
:
1449 case priunat_when_mem
:
1456 count
+= output_leb128 (bytes
+ 2, t
, 0);
1457 (*f
) (count
, bytes
, NULL
);
1461 output_P9_format (f
, grmask
, gr
)
1468 bytes
[1] = (grmask
& 0x0f);
1469 bytes
[2] = (gr
& 0x7f);
1470 (*f
) (3, bytes
, NULL
);
1474 output_P10_format (f
, abi
, context
)
1481 bytes
[1] = (abi
& 0xff);
1482 bytes
[2] = (context
& 0xff);
1483 (*f
) (3, bytes
, NULL
);
1487 output_B1_format (f
, rtype
, label
)
1489 unw_record_type rtype
;
1490 unsigned long label
;
1496 output_B4_format (f
, rtype
, label
);
1499 if (rtype
== copy_state
)
1501 else if (rtype
!= label_state
)
1502 as_bad ("Invalid record type for format B1");
1504 byte
= (UNW_B1
| (r
<< 5) | (label
& 0x1f));
1505 (*f
) (1, &byte
, NULL
);
1509 output_B2_format (f
, ecount
, t
)
1511 unsigned long ecount
;
1518 output_B3_format (f
, ecount
, t
);
1521 bytes
[0] = (UNW_B2
| (ecount
& 0x1f));
1522 count
+= output_leb128 (bytes
+ 1, t
, 0);
1523 (*f
) (count
, bytes
, NULL
);
1527 output_B3_format (f
, ecount
, t
)
1529 unsigned long ecount
;
1536 output_B2_format (f
, ecount
, t
);
1540 count
+= output_leb128 (bytes
+ 1, t
, 0);
1541 count
+= output_leb128 (bytes
+ count
, ecount
, 0);
1542 (*f
) (count
, bytes
, NULL
);
1546 output_B4_format (f
, rtype
, label
)
1548 unw_record_type rtype
;
1549 unsigned long label
;
1556 output_B1_format (f
, rtype
, label
);
1560 if (rtype
== copy_state
)
1562 else if (rtype
!= label_state
)
1563 as_bad ("Invalid record type for format B1");
1565 bytes
[0] = (UNW_B4
| (r
<< 3));
1566 count
+= output_leb128 (bytes
+ 1, label
, 0);
1567 (*f
) (count
, bytes
, NULL
);
1571 format_ab_reg (ab
, reg
)
1578 ret
= (ab
<< 5) | reg
;
1583 output_X1_format (f
, rtype
, ab
, reg
, t
, w1
)
1585 unw_record_type rtype
;
1595 if (rtype
== spill_sprel
)
1597 else if (rtype
!= spill_psprel
)
1598 as_bad ("Invalid record type for format X1");
1599 bytes
[1] = ((r
<< 7) | format_ab_reg (ab
, reg
));
1600 count
+= output_leb128 (bytes
+ 2, t
, 0);
1601 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1602 (*f
) (count
, bytes
, NULL
);
1606 output_X2_format (f
, ab
, reg
, x
, y
, treg
, t
)
1615 bytes
[1] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1616 bytes
[2] = (((y
& 1) << 7) | (treg
& 0x7f));
1617 count
+= output_leb128 (bytes
+ 3, t
, 0);
1618 (*f
) (count
, bytes
, NULL
);
1622 output_X3_format (f
, rtype
, qp
, ab
, reg
, t
, w1
)
1624 unw_record_type rtype
;
1635 if (rtype
== spill_sprel_p
)
1637 else if (rtype
!= spill_psprel_p
)
1638 as_bad ("Invalid record type for format X3");
1639 bytes
[1] = ((r
<< 7) | (qp
& 0x3f));
1640 bytes
[2] = format_ab_reg (ab
, reg
);
1641 count
+= output_leb128 (bytes
+ 3, t
, 0);
1642 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1643 (*f
) (count
, bytes
, NULL
);
1647 output_X4_format (f
, qp
, ab
, reg
, x
, y
, treg
, t
)
1657 bytes
[1] = (qp
& 0x3f);
1658 bytes
[2] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1659 bytes
[3] = (((y
& 1) << 7) | (treg
& 0x7f));
1660 count
+= output_leb128 (bytes
+ 4, t
, 0);
1661 (*f
) (count
, bytes
, NULL
);
1664 /* This function allocates a record list structure, and initializes fields. */
1666 static unw_rec_list
*
1667 alloc_record (unw_record_type t
)
1670 ptr
= xmalloc (sizeof (*ptr
));
1672 ptr
->slot_number
= SLOT_NUM_NOT_SET
;
1677 /* This function frees an entire list of record structures. */
1680 free_list_records (unw_rec_list
*first
)
1683 for (ptr
= first
; ptr
!= NULL
;)
1685 unw_rec_list
*tmp
= ptr
;
1687 if ((tmp
->r
.type
== prologue
|| tmp
->r
.type
== prologue_gr
)
1688 && tmp
->r
.record
.r
.mask
.i
)
1689 free (tmp
->r
.record
.r
.mask
.i
);
1696 static unw_rec_list
*
1699 unw_rec_list
*ptr
= alloc_record (prologue
);
1700 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1704 static unw_rec_list
*
1705 output_prologue_gr (saved_mask
, reg
)
1706 unsigned int saved_mask
;
1709 unw_rec_list
*ptr
= alloc_record (prologue_gr
);
1710 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1711 ptr
->r
.record
.r
.grmask
= saved_mask
;
1712 ptr
->r
.record
.r
.grsave
= reg
;
1716 static unw_rec_list
*
1719 unw_rec_list
*ptr
= alloc_record (body
);
1723 static unw_rec_list
*
1724 output_mem_stack_f (size
)
1727 unw_rec_list
*ptr
= alloc_record (mem_stack_f
);
1728 ptr
->r
.record
.p
.size
= size
;
1732 static unw_rec_list
*
1733 output_mem_stack_v ()
1735 unw_rec_list
*ptr
= alloc_record (mem_stack_v
);
1739 static unw_rec_list
*
1743 unw_rec_list
*ptr
= alloc_record (psp_gr
);
1744 ptr
->r
.record
.p
.gr
= gr
;
1748 static unw_rec_list
*
1749 output_psp_sprel (offset
)
1750 unsigned int offset
;
1752 unw_rec_list
*ptr
= alloc_record (psp_sprel
);
1753 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1757 static unw_rec_list
*
1760 unw_rec_list
*ptr
= alloc_record (rp_when
);
1764 static unw_rec_list
*
1768 unw_rec_list
*ptr
= alloc_record (rp_gr
);
1769 ptr
->r
.record
.p
.gr
= gr
;
1773 static unw_rec_list
*
1777 unw_rec_list
*ptr
= alloc_record (rp_br
);
1778 ptr
->r
.record
.p
.br
= br
;
1782 static unw_rec_list
*
1783 output_rp_psprel (offset
)
1784 unsigned int offset
;
1786 unw_rec_list
*ptr
= alloc_record (rp_psprel
);
1787 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1791 static unw_rec_list
*
1792 output_rp_sprel (offset
)
1793 unsigned int offset
;
1795 unw_rec_list
*ptr
= alloc_record (rp_sprel
);
1796 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1800 static unw_rec_list
*
1803 unw_rec_list
*ptr
= alloc_record (pfs_when
);
1807 static unw_rec_list
*
1811 unw_rec_list
*ptr
= alloc_record (pfs_gr
);
1812 ptr
->r
.record
.p
.gr
= gr
;
1816 static unw_rec_list
*
1817 output_pfs_psprel (offset
)
1818 unsigned int offset
;
1820 unw_rec_list
*ptr
= alloc_record (pfs_psprel
);
1821 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1825 static unw_rec_list
*
1826 output_pfs_sprel (offset
)
1827 unsigned int offset
;
1829 unw_rec_list
*ptr
= alloc_record (pfs_sprel
);
1830 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1834 static unw_rec_list
*
1835 output_preds_when ()
1837 unw_rec_list
*ptr
= alloc_record (preds_when
);
1841 static unw_rec_list
*
1842 output_preds_gr (gr
)
1845 unw_rec_list
*ptr
= alloc_record (preds_gr
);
1846 ptr
->r
.record
.p
.gr
= gr
;
1850 static unw_rec_list
*
1851 output_preds_psprel (offset
)
1852 unsigned int offset
;
1854 unw_rec_list
*ptr
= alloc_record (preds_psprel
);
1855 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1859 static unw_rec_list
*
1860 output_preds_sprel (offset
)
1861 unsigned int offset
;
1863 unw_rec_list
*ptr
= alloc_record (preds_sprel
);
1864 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1868 static unw_rec_list
*
1869 output_fr_mem (mask
)
1872 unw_rec_list
*ptr
= alloc_record (fr_mem
);
1873 ptr
->r
.record
.p
.rmask
= mask
;
1877 static unw_rec_list
*
1878 output_frgr_mem (gr_mask
, fr_mask
)
1879 unsigned int gr_mask
;
1880 unsigned int fr_mask
;
1882 unw_rec_list
*ptr
= alloc_record (frgr_mem
);
1883 ptr
->r
.record
.p
.grmask
= gr_mask
;
1884 ptr
->r
.record
.p
.frmask
= fr_mask
;
1888 static unw_rec_list
*
1889 output_gr_gr (mask
, reg
)
1893 unw_rec_list
*ptr
= alloc_record (gr_gr
);
1894 ptr
->r
.record
.p
.grmask
= mask
;
1895 ptr
->r
.record
.p
.gr
= reg
;
1899 static unw_rec_list
*
1900 output_gr_mem (mask
)
1903 unw_rec_list
*ptr
= alloc_record (gr_mem
);
1904 ptr
->r
.record
.p
.rmask
= mask
;
1908 static unw_rec_list
*
1909 output_br_mem (unsigned int mask
)
1911 unw_rec_list
*ptr
= alloc_record (br_mem
);
1912 ptr
->r
.record
.p
.brmask
= mask
;
1916 static unw_rec_list
*
1917 output_br_gr (save_mask
, reg
)
1918 unsigned int save_mask
;
1921 unw_rec_list
*ptr
= alloc_record (br_gr
);
1922 ptr
->r
.record
.p
.brmask
= save_mask
;
1923 ptr
->r
.record
.p
.gr
= reg
;
1927 static unw_rec_list
*
1928 output_spill_base (offset
)
1929 unsigned int offset
;
1931 unw_rec_list
*ptr
= alloc_record (spill_base
);
1932 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1936 static unw_rec_list
*
1939 unw_rec_list
*ptr
= alloc_record (unat_when
);
1943 static unw_rec_list
*
1947 unw_rec_list
*ptr
= alloc_record (unat_gr
);
1948 ptr
->r
.record
.p
.gr
= gr
;
1952 static unw_rec_list
*
1953 output_unat_psprel (offset
)
1954 unsigned int offset
;
1956 unw_rec_list
*ptr
= alloc_record (unat_psprel
);
1957 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1961 static unw_rec_list
*
1962 output_unat_sprel (offset
)
1963 unsigned int offset
;
1965 unw_rec_list
*ptr
= alloc_record (unat_sprel
);
1966 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1970 static unw_rec_list
*
1973 unw_rec_list
*ptr
= alloc_record (lc_when
);
1977 static unw_rec_list
*
1981 unw_rec_list
*ptr
= alloc_record (lc_gr
);
1982 ptr
->r
.record
.p
.gr
= gr
;
1986 static unw_rec_list
*
1987 output_lc_psprel (offset
)
1988 unsigned int offset
;
1990 unw_rec_list
*ptr
= alloc_record (lc_psprel
);
1991 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1995 static unw_rec_list
*
1996 output_lc_sprel (offset
)
1997 unsigned int offset
;
1999 unw_rec_list
*ptr
= alloc_record (lc_sprel
);
2000 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2004 static unw_rec_list
*
2007 unw_rec_list
*ptr
= alloc_record (fpsr_when
);
2011 static unw_rec_list
*
2015 unw_rec_list
*ptr
= alloc_record (fpsr_gr
);
2016 ptr
->r
.record
.p
.gr
= gr
;
2020 static unw_rec_list
*
2021 output_fpsr_psprel (offset
)
2022 unsigned int offset
;
2024 unw_rec_list
*ptr
= alloc_record (fpsr_psprel
);
2025 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2029 static unw_rec_list
*
2030 output_fpsr_sprel (offset
)
2031 unsigned int offset
;
2033 unw_rec_list
*ptr
= alloc_record (fpsr_sprel
);
2034 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2038 static unw_rec_list
*
2039 output_priunat_when_gr ()
2041 unw_rec_list
*ptr
= alloc_record (priunat_when_gr
);
2045 static unw_rec_list
*
2046 output_priunat_when_mem ()
2048 unw_rec_list
*ptr
= alloc_record (priunat_when_mem
);
2052 static unw_rec_list
*
2053 output_priunat_gr (gr
)
2056 unw_rec_list
*ptr
= alloc_record (priunat_gr
);
2057 ptr
->r
.record
.p
.gr
= gr
;
2061 static unw_rec_list
*
2062 output_priunat_psprel (offset
)
2063 unsigned int offset
;
2065 unw_rec_list
*ptr
= alloc_record (priunat_psprel
);
2066 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2070 static unw_rec_list
*
2071 output_priunat_sprel (offset
)
2072 unsigned int offset
;
2074 unw_rec_list
*ptr
= alloc_record (priunat_sprel
);
2075 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2079 static unw_rec_list
*
2082 unw_rec_list
*ptr
= alloc_record (bsp_when
);
2086 static unw_rec_list
*
2090 unw_rec_list
*ptr
= alloc_record (bsp_gr
);
2091 ptr
->r
.record
.p
.gr
= gr
;
2095 static unw_rec_list
*
2096 output_bsp_psprel (offset
)
2097 unsigned int offset
;
2099 unw_rec_list
*ptr
= alloc_record (bsp_psprel
);
2100 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2104 static unw_rec_list
*
2105 output_bsp_sprel (offset
)
2106 unsigned int offset
;
2108 unw_rec_list
*ptr
= alloc_record (bsp_sprel
);
2109 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2113 static unw_rec_list
*
2114 output_bspstore_when ()
2116 unw_rec_list
*ptr
= alloc_record (bspstore_when
);
2120 static unw_rec_list
*
2121 output_bspstore_gr (gr
)
2124 unw_rec_list
*ptr
= alloc_record (bspstore_gr
);
2125 ptr
->r
.record
.p
.gr
= gr
;
2129 static unw_rec_list
*
2130 output_bspstore_psprel (offset
)
2131 unsigned int offset
;
2133 unw_rec_list
*ptr
= alloc_record (bspstore_psprel
);
2134 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2138 static unw_rec_list
*
2139 output_bspstore_sprel (offset
)
2140 unsigned int offset
;
2142 unw_rec_list
*ptr
= alloc_record (bspstore_sprel
);
2143 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2147 static unw_rec_list
*
2150 unw_rec_list
*ptr
= alloc_record (rnat_when
);
2154 static unw_rec_list
*
2158 unw_rec_list
*ptr
= alloc_record (rnat_gr
);
2159 ptr
->r
.record
.p
.gr
= gr
;
2163 static unw_rec_list
*
2164 output_rnat_psprel (offset
)
2165 unsigned int offset
;
2167 unw_rec_list
*ptr
= alloc_record (rnat_psprel
);
2168 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2172 static unw_rec_list
*
2173 output_rnat_sprel (offset
)
2174 unsigned int offset
;
2176 unw_rec_list
*ptr
= alloc_record (rnat_sprel
);
2177 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2181 static unw_rec_list
*
2182 output_unwabi (abi
, context
)
2184 unsigned long context
;
2186 unw_rec_list
*ptr
= alloc_record (unwabi
);
2187 ptr
->r
.record
.p
.abi
= abi
;
2188 ptr
->r
.record
.p
.context
= context
;
2192 static unw_rec_list
*
2193 output_epilogue (unsigned long ecount
)
2195 unw_rec_list
*ptr
= alloc_record (epilogue
);
2196 ptr
->r
.record
.b
.ecount
= ecount
;
2200 static unw_rec_list
*
2201 output_label_state (unsigned long label
)
2203 unw_rec_list
*ptr
= alloc_record (label_state
);
2204 ptr
->r
.record
.b
.label
= label
;
2208 static unw_rec_list
*
2209 output_copy_state (unsigned long label
)
2211 unw_rec_list
*ptr
= alloc_record (copy_state
);
2212 ptr
->r
.record
.b
.label
= label
;
2216 static unw_rec_list
*
2217 output_spill_psprel (ab
, reg
, offset
)
2220 unsigned int offset
;
2222 unw_rec_list
*ptr
= alloc_record (spill_psprel
);
2223 ptr
->r
.record
.x
.ab
= ab
;
2224 ptr
->r
.record
.x
.reg
= reg
;
2225 ptr
->r
.record
.x
.pspoff
= offset
/ 4;
2229 static unw_rec_list
*
2230 output_spill_sprel (ab
, reg
, offset
)
2233 unsigned int offset
;
2235 unw_rec_list
*ptr
= alloc_record (spill_sprel
);
2236 ptr
->r
.record
.x
.ab
= ab
;
2237 ptr
->r
.record
.x
.reg
= reg
;
2238 ptr
->r
.record
.x
.spoff
= offset
/ 4;
2242 static unw_rec_list
*
2243 output_spill_psprel_p (ab
, reg
, offset
, predicate
)
2246 unsigned int offset
;
2247 unsigned int predicate
;
2249 unw_rec_list
*ptr
= alloc_record (spill_psprel_p
);
2250 ptr
->r
.record
.x
.ab
= ab
;
2251 ptr
->r
.record
.x
.reg
= reg
;
2252 ptr
->r
.record
.x
.pspoff
= offset
/ 4;
2253 ptr
->r
.record
.x
.qp
= predicate
;
2257 static unw_rec_list
*
2258 output_spill_sprel_p (ab
, reg
, offset
, predicate
)
2261 unsigned int offset
;
2262 unsigned int predicate
;
2264 unw_rec_list
*ptr
= alloc_record (spill_sprel_p
);
2265 ptr
->r
.record
.x
.ab
= ab
;
2266 ptr
->r
.record
.x
.reg
= reg
;
2267 ptr
->r
.record
.x
.spoff
= offset
/ 4;
2268 ptr
->r
.record
.x
.qp
= predicate
;
2272 static unw_rec_list
*
2273 output_spill_reg (ab
, reg
, targ_reg
, xy
)
2276 unsigned int targ_reg
;
2279 unw_rec_list
*ptr
= alloc_record (spill_reg
);
2280 ptr
->r
.record
.x
.ab
= ab
;
2281 ptr
->r
.record
.x
.reg
= reg
;
2282 ptr
->r
.record
.x
.treg
= targ_reg
;
2283 ptr
->r
.record
.x
.xy
= xy
;
2287 static unw_rec_list
*
2288 output_spill_reg_p (ab
, reg
, targ_reg
, xy
, predicate
)
2291 unsigned int targ_reg
;
2293 unsigned int predicate
;
2295 unw_rec_list
*ptr
= alloc_record (spill_reg_p
);
2296 ptr
->r
.record
.x
.ab
= ab
;
2297 ptr
->r
.record
.x
.reg
= reg
;
2298 ptr
->r
.record
.x
.treg
= targ_reg
;
2299 ptr
->r
.record
.x
.xy
= xy
;
2300 ptr
->r
.record
.x
.qp
= predicate
;
2304 /* Given a unw_rec_list process the correct format with the
2305 specified function. */
2308 process_one_record (ptr
, f
)
2312 unsigned long fr_mask
, gr_mask
;
2314 switch (ptr
->r
.type
)
2320 /* These are taken care of by prologue/prologue_gr. */
2325 if (ptr
->r
.type
== prologue_gr
)
2326 output_R2_format (f
, ptr
->r
.record
.r
.grmask
,
2327 ptr
->r
.record
.r
.grsave
, ptr
->r
.record
.r
.rlen
);
2329 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2331 /* Output descriptor(s) for union of register spills (if any). */
2332 gr_mask
= ptr
->r
.record
.r
.mask
.gr_mem
;
2333 fr_mask
= ptr
->r
.record
.r
.mask
.fr_mem
;
2336 if ((fr_mask
& ~0xfUL
) == 0)
2337 output_P6_format (f
, fr_mem
, fr_mask
);
2340 output_P5_format (f
, gr_mask
, fr_mask
);
2345 output_P6_format (f
, gr_mem
, gr_mask
);
2346 if (ptr
->r
.record
.r
.mask
.br_mem
)
2347 output_P1_format (f
, ptr
->r
.record
.r
.mask
.br_mem
);
2349 /* output imask descriptor if necessary: */
2350 if (ptr
->r
.record
.r
.mask
.i
)
2351 output_P4_format (f
, ptr
->r
.record
.r
.mask
.i
,
2352 ptr
->r
.record
.r
.imask_size
);
2356 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2360 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
,
2361 ptr
->r
.record
.p
.size
);
2374 output_P3_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.gr
);
2377 output_P3_format (f
, rp_br
, ptr
->r
.record
.p
.br
);
2380 output_P7_format (f
, psp_sprel
, ptr
->r
.record
.p
.spoff
, 0);
2388 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
, 0);
2397 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.pspoff
, 0);
2407 case bspstore_sprel
:
2409 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.spoff
);
2412 output_P9_format (f
, ptr
->r
.record
.p
.grmask
, ptr
->r
.record
.p
.gr
);
2415 output_P2_format (f
, ptr
->r
.record
.p
.brmask
, ptr
->r
.record
.p
.gr
);
2418 as_bad ("spill_mask record unimplemented.");
2420 case priunat_when_gr
:
2421 case priunat_when_mem
:
2425 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
);
2427 case priunat_psprel
:
2429 case bspstore_psprel
:
2431 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.pspoff
);
2434 output_P10_format (f
, ptr
->r
.record
.p
.abi
, ptr
->r
.record
.p
.context
);
2437 output_B3_format (f
, ptr
->r
.record
.b
.ecount
, ptr
->r
.record
.b
.t
);
2441 output_B4_format (f
, ptr
->r
.type
, ptr
->r
.record
.b
.label
);
2444 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2445 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2446 ptr
->r
.record
.x
.pspoff
);
2449 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2450 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2451 ptr
->r
.record
.x
.spoff
);
2454 output_X2_format (f
, ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2455 ptr
->r
.record
.x
.xy
>> 1, ptr
->r
.record
.x
.xy
,
2456 ptr
->r
.record
.x
.treg
, ptr
->r
.record
.x
.t
);
2458 case spill_psprel_p
:
2459 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2460 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2461 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.pspoff
);
2464 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2465 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2466 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.spoff
);
2469 output_X4_format (f
, ptr
->r
.record
.x
.qp
, ptr
->r
.record
.x
.ab
,
2470 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.xy
>> 1,
2471 ptr
->r
.record
.x
.xy
, ptr
->r
.record
.x
.treg
,
2475 as_bad ("record_type_not_valid");
2480 /* Given a unw_rec_list list, process all the records with
2481 the specified function. */
2483 process_unw_records (list
, f
)
2488 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2489 process_one_record (ptr
, f
);
2492 /* Determine the size of a record list in bytes. */
2494 calc_record_size (list
)
2498 process_unw_records (list
, count_output
);
2502 /* Update IMASK bitmask to reflect the fact that one or more registers
2503 of type TYPE are saved starting at instruction with index T. If N
2504 bits are set in REGMASK, it is assumed that instructions T through
2505 T+N-1 save these registers.
2509 1: instruction saves next fp reg
2510 2: instruction saves next general reg
2511 3: instruction saves next branch reg */
2513 set_imask (region
, regmask
, t
, type
)
2514 unw_rec_list
*region
;
2515 unsigned long regmask
;
2519 unsigned char *imask
;
2520 unsigned long imask_size
;
2524 imask
= region
->r
.record
.r
.mask
.i
;
2525 imask_size
= region
->r
.record
.r
.imask_size
;
2528 imask_size
= (region
->r
.record
.r
.rlen
* 2 + 7) / 8 + 1;
2529 imask
= xmalloc (imask_size
);
2530 memset (imask
, 0, imask_size
);
2532 region
->r
.record
.r
.imask_size
= imask_size
;
2533 region
->r
.record
.r
.mask
.i
= imask
;
2537 pos
= 2 * (3 - t
% 4);
2540 if (i
>= imask_size
)
2542 as_bad ("Ignoring attempt to spill beyond end of region");
2546 imask
[i
] |= (type
& 0x3) << pos
;
2548 regmask
&= (regmask
- 1);
2559 count_bits (unsigned long mask
)
2571 /* Return the number of instruction slots from FIRST_ADDR to SLOT_ADDR.
2572 SLOT_FRAG is the frag containing SLOT_ADDR, and FIRST_FRAG is the frag
2573 containing FIRST_ADDR. */
2576 slot_index (slot_addr
, slot_frag
, first_addr
, first_frag
)
2577 unsigned long slot_addr
;
2579 unsigned long first_addr
;
2582 unsigned long index
= 0;
2584 /* First time we are called, the initial address and frag are invalid. */
2585 if (first_addr
== 0)
2588 /* If the two addresses are in different frags, then we need to add in
2589 the remaining size of this frag, and then the entire size of intermediate
2591 while (slot_frag
!= first_frag
)
2593 unsigned long start_addr
= (unsigned long) &first_frag
->fr_literal
;
2595 /* Add in the full size of the frag converted to instruction slots. */
2596 index
+= 3 * (first_frag
->fr_fix
>> 4);
2597 /* Subtract away the initial part before first_addr. */
2598 index
-= (3 * ((first_addr
>> 4) - (start_addr
>> 4))
2599 + ((first_addr
& 0x3) - (start_addr
& 0x3)));
2601 /* Move to the beginning of the next frag. */
2602 first_frag
= first_frag
->fr_next
;
2603 first_addr
= (unsigned long) &first_frag
->fr_literal
;
2606 /* Add in the used part of the last frag. */
2607 index
+= (3 * ((slot_addr
>> 4) - (first_addr
>> 4))
2608 + ((slot_addr
& 0x3) - (first_addr
& 0x3)));
2612 /* Optimize unwind record directives. */
2614 static unw_rec_list
*
2615 optimize_unw_records (list
)
2621 /* If the only unwind record is ".prologue" or ".prologue" followed
2622 by ".body", then we can optimize the unwind directives away. */
2623 if (list
->r
.type
== prologue
2624 && (list
->next
== NULL
2625 || (list
->next
->r
.type
== body
&& list
->next
->next
== NULL
)))
2631 /* Given a complete record list, process any records which have
2632 unresolved fields, (ie length counts for a prologue). After
2633 this has been run, all neccessary information should be available
2634 within each record to generate an image. */
2637 fixup_unw_records (list
)
2640 unw_rec_list
*ptr
, *region
= 0;
2641 unsigned long first_addr
= 0, rlen
= 0, t
;
2642 fragS
*first_frag
= 0;
2644 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2646 if (ptr
->slot_number
== SLOT_NUM_NOT_SET
)
2647 as_bad (" Insn slot not set in unwind record.");
2648 t
= slot_index (ptr
->slot_number
, ptr
->slot_frag
,
2649 first_addr
, first_frag
);
2650 switch (ptr
->r
.type
)
2657 int size
, dir_len
= 0;
2658 unsigned long last_addr
;
2661 first_addr
= ptr
->slot_number
;
2662 first_frag
= ptr
->slot_frag
;
2663 ptr
->slot_number
= 0;
2664 /* Find either the next body/prologue start, or the end of
2665 the list, and determine the size of the region. */
2666 last_addr
= unwind
.next_slot_number
;
2667 last_frag
= unwind
.next_slot_frag
;
2668 for (last
= ptr
->next
; last
!= NULL
; last
= last
->next
)
2669 if (last
->r
.type
== prologue
|| last
->r
.type
== prologue_gr
2670 || last
->r
.type
== body
)
2672 last_addr
= last
->slot_number
;
2673 last_frag
= last
->slot_frag
;
2676 else if (!last
->next
)
2678 /* In the absence of an explicit .body directive,
2679 the prologue ends after the last instruction
2680 covered by an unwind directive. */
2681 if (ptr
->r
.type
!= body
)
2683 last_addr
= last
->slot_number
;
2684 last_frag
= last
->slot_frag
;
2685 switch (last
->r
.type
)
2688 dir_len
= (count_bits (last
->r
.record
.p
.frmask
)
2689 + count_bits (last
->r
.record
.p
.grmask
));
2693 dir_len
+= count_bits (last
->r
.record
.p
.rmask
);
2697 dir_len
+= count_bits (last
->r
.record
.p
.brmask
);
2700 dir_len
+= count_bits (last
->r
.record
.p
.grmask
);
2709 size
= (slot_index (last_addr
, last_frag
, first_addr
, first_frag
)
2711 rlen
= ptr
->r
.record
.r
.rlen
= size
;
2712 if (ptr
->r
.type
== body
)
2713 /* End of region. */
2720 ptr
->r
.record
.b
.t
= rlen
- 1 - t
;
2731 case priunat_when_gr
:
2732 case priunat_when_mem
:
2736 ptr
->r
.record
.p
.t
= t
;
2744 case spill_psprel_p
:
2745 ptr
->r
.record
.x
.t
= t
;
2751 as_bad ("frgr_mem record before region record!\n");
2754 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.frmask
;
2755 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.grmask
;
2756 set_imask (region
, ptr
->r
.record
.p
.frmask
, t
, 1);
2757 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2762 as_bad ("fr_mem record before region record!\n");
2765 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.rmask
;
2766 set_imask (region
, ptr
->r
.record
.p
.rmask
, t
, 1);
2771 as_bad ("gr_mem record before region record!\n");
2774 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.rmask
;
2775 set_imask (region
, ptr
->r
.record
.p
.rmask
, t
, 2);
2780 as_bad ("br_mem record before region record!\n");
2783 region
->r
.record
.r
.mask
.br_mem
|= ptr
->r
.record
.p
.brmask
;
2784 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2790 as_bad ("gr_gr record before region record!\n");
2793 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2798 as_bad ("br_gr record before region record!\n");
2801 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2810 /* Helper routine for output_unw_records. Emits the header for the unwind
2814 setup_unwind_header (int size
, unsigned char **mem
)
2819 /* pad to pointer-size boundry. */
2820 x
= size
% md
.pointer_size
;
2822 extra
= md
.pointer_size
- x
;
2824 /* Add 8 for the header + a pointer for the
2825 personality offset. */
2826 *mem
= xmalloc (size
+ extra
+ 8 + md
.pointer_size
);
2828 /* Clear the padding area and personality. */
2829 memset (*mem
+ 8 + size
, 0 , extra
+ md
.pointer_size
);
2831 /* Initialize the header area. */
2832 if (unwind
.personality_routine
)
2834 if (md
.flags
& EF_IA_64_ABI64
)
2835 flag_value
= (bfd_vma
) 3 << 32;
2837 /* 32-bit unwind info block. */
2838 flag_value
= (bfd_vma
) 0x1003 << 32;
2843 md_number_to_chars (*mem
, (((bfd_vma
) 1 << 48) /* Version. */
2844 | flag_value
/* U & E handler flags. */
2845 | ((size
+ extra
) / md
.pointer_size
)), /* Length. */
2851 /* Generate an unwind image from a record list. Returns the number of
2852 bytes in the resulting image. The memory image itselof is returned
2853 in the 'ptr' parameter. */
2855 output_unw_records (list
, ptr
)
2864 list
= optimize_unw_records (list
);
2865 fixup_unw_records (list
);
2866 size
= calc_record_size (list
);
2868 if (size
> 0 || unwind
.force_unwind_entry
)
2870 unwind
.force_unwind_entry
= 0;
2871 extra
= setup_unwind_header (size
, &mem
);
2873 vbyte_mem_ptr
= mem
+ 8;
2874 process_unw_records (list
, output_vbyte_mem
);
2878 size
+= extra
+ 8 + md
.pointer_size
;
2884 convert_expr_to_ab_reg (e
, ab
, regp
)
2891 if (e
->X_op
!= O_register
)
2894 reg
= e
->X_add_number
;
2895 if (reg
>= (REG_GR
+ 4) && reg
<= (REG_GR
+ 7))
2898 *regp
= reg
- REG_GR
;
2900 else if ((reg
>= (REG_FR
+ 2) && reg
<= (REG_FR
+ 5))
2901 || (reg
>= (REG_FR
+ 16) && reg
<= (REG_FR
+ 31)))
2904 *regp
= reg
- REG_FR
;
2906 else if (reg
>= (REG_BR
+ 1) && reg
<= (REG_BR
+ 5))
2909 *regp
= reg
- REG_BR
;
2916 case REG_PR
: *regp
= 0; break;
2917 case REG_PSP
: *regp
= 1; break;
2918 case REG_PRIUNAT
: *regp
= 2; break;
2919 case REG_BR
+ 0: *regp
= 3; break;
2920 case REG_AR
+ AR_BSP
: *regp
= 4; break;
2921 case REG_AR
+ AR_BSPSTORE
: *regp
= 5; break;
2922 case REG_AR
+ AR_RNAT
: *regp
= 6; break;
2923 case REG_AR
+ AR_UNAT
: *regp
= 7; break;
2924 case REG_AR
+ AR_FPSR
: *regp
= 8; break;
2925 case REG_AR
+ AR_PFS
: *regp
= 9; break;
2926 case REG_AR
+ AR_LC
: *regp
= 10; break;
2936 convert_expr_to_xy_reg (e
, xy
, regp
)
2943 if (e
->X_op
!= O_register
)
2946 reg
= e
->X_add_number
;
2948 if (/* reg >= REG_GR && */ reg
<= (REG_GR
+ 127))
2951 *regp
= reg
- REG_GR
;
2953 else if (reg
>= REG_FR
&& reg
<= (REG_FR
+ 127))
2956 *regp
= reg
- REG_FR
;
2958 else if (reg
>= REG_BR
&& reg
<= (REG_BR
+ 7))
2961 *regp
= reg
- REG_BR
;
2970 int dummy ATTRIBUTE_UNUSED
;
2975 radix
= *input_line_pointer
++;
2977 if (radix
!= 'C' && !is_end_of_line
[(unsigned char) radix
])
2979 as_bad ("Radix `%c' unsupported", *input_line_pointer
);
2980 ignore_rest_of_line ();
2985 /* .sbss, .bss etc. are macros that expand into ".section SECNAME". */
2987 dot_special_section (which
)
2990 set_section ((char *) special_section_name
[which
]);
2994 add_unwind_entry (ptr
)
2998 unwind
.tail
->next
= ptr
;
3003 /* The current entry can in fact be a chain of unwind entries. */
3004 if (unwind
.current_entry
== NULL
)
3005 unwind
.current_entry
= ptr
;
3010 int dummy ATTRIBUTE_UNUSED
;
3016 if (e
.X_op
!= O_constant
)
3017 as_bad ("Operand to .fframe must be a constant");
3019 add_unwind_entry (output_mem_stack_f (e
.X_add_number
));
3024 int dummy ATTRIBUTE_UNUSED
;
3030 reg
= e
.X_add_number
- REG_GR
;
3031 if (e
.X_op
== O_register
&& reg
< 128)
3033 add_unwind_entry (output_mem_stack_v ());
3034 if (! (unwind
.prologue_mask
& 2))
3035 add_unwind_entry (output_psp_gr (reg
));
3038 as_bad ("First operand to .vframe must be a general register");
3042 dot_vframesp (dummy
)
3043 int dummy ATTRIBUTE_UNUSED
;
3048 if (e
.X_op
== O_constant
)
3050 add_unwind_entry (output_mem_stack_v ());
3051 add_unwind_entry (output_psp_sprel (e
.X_add_number
));
3054 as_bad ("First operand to .vframesp must be a general register");
3058 dot_vframepsp (dummy
)
3059 int dummy ATTRIBUTE_UNUSED
;
3064 if (e
.X_op
== O_constant
)
3066 add_unwind_entry (output_mem_stack_v ());
3067 add_unwind_entry (output_psp_sprel (e
.X_add_number
));
3070 as_bad ("First operand to .vframepsp must be a general register");
3075 int dummy ATTRIBUTE_UNUSED
;
3081 sep
= parse_operand (&e1
);
3083 as_bad ("No second operand to .save");
3084 sep
= parse_operand (&e2
);
3086 reg1
= e1
.X_add_number
;
3087 reg2
= e2
.X_add_number
- REG_GR
;
3089 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3090 if (e1
.X_op
== O_register
)
3092 if (e2
.X_op
== O_register
&& reg2
>= 0 && reg2
< 128)
3096 case REG_AR
+ AR_BSP
:
3097 add_unwind_entry (output_bsp_when ());
3098 add_unwind_entry (output_bsp_gr (reg2
));
3100 case REG_AR
+ AR_BSPSTORE
:
3101 add_unwind_entry (output_bspstore_when ());
3102 add_unwind_entry (output_bspstore_gr (reg2
));
3104 case REG_AR
+ AR_RNAT
:
3105 add_unwind_entry (output_rnat_when ());
3106 add_unwind_entry (output_rnat_gr (reg2
));
3108 case REG_AR
+ AR_UNAT
:
3109 add_unwind_entry (output_unat_when ());
3110 add_unwind_entry (output_unat_gr (reg2
));
3112 case REG_AR
+ AR_FPSR
:
3113 add_unwind_entry (output_fpsr_when ());
3114 add_unwind_entry (output_fpsr_gr (reg2
));
3116 case REG_AR
+ AR_PFS
:
3117 add_unwind_entry (output_pfs_when ());
3118 if (! (unwind
.prologue_mask
& 4))
3119 add_unwind_entry (output_pfs_gr (reg2
));
3121 case REG_AR
+ AR_LC
:
3122 add_unwind_entry (output_lc_when ());
3123 add_unwind_entry (output_lc_gr (reg2
));
3126 add_unwind_entry (output_rp_when ());
3127 if (! (unwind
.prologue_mask
& 8))
3128 add_unwind_entry (output_rp_gr (reg2
));
3131 add_unwind_entry (output_preds_when ());
3132 if (! (unwind
.prologue_mask
& 1))
3133 add_unwind_entry (output_preds_gr (reg2
));
3136 add_unwind_entry (output_priunat_when_gr ());
3137 add_unwind_entry (output_priunat_gr (reg2
));
3140 as_bad ("First operand not a valid register");
3144 as_bad (" Second operand not a valid register");
3147 as_bad ("First operand not a register");
3152 int dummy ATTRIBUTE_UNUSED
;
3155 unsigned long ecount
; /* # of _additional_ regions to pop */
3158 sep
= parse_operand (&e1
);
3159 if (e1
.X_op
!= O_register
|| e1
.X_add_number
!= REG_GR
+ 12)
3161 as_bad ("First operand to .restore must be stack pointer (sp)");
3167 parse_operand (&e2
);
3168 if (e2
.X_op
!= O_constant
|| e2
.X_add_number
< 0)
3170 as_bad ("Second operand to .restore must be a constant >= 0");
3173 ecount
= e2
.X_add_number
;
3176 ecount
= unwind
.prologue_count
- 1;
3178 if (ecount
>= unwind
.prologue_count
)
3180 as_bad ("Epilogue count of %lu exceeds number of nested prologues (%u)",
3181 ecount
+ 1, unwind
.prologue_count
);
3185 add_unwind_entry (output_epilogue (ecount
));
3187 if (ecount
< unwind
.prologue_count
)
3188 unwind
.prologue_count
-= ecount
+ 1;
3190 unwind
.prologue_count
= 0;
3194 dot_restorereg (dummy
)
3195 int dummy ATTRIBUTE_UNUSED
;
3197 unsigned int ab
, reg
;
3202 if (!convert_expr_to_ab_reg (&e
, &ab
, ®
))
3204 as_bad ("First operand to .restorereg must be a preserved register");
3207 add_unwind_entry (output_spill_reg (ab
, reg
, 0, 0));
3211 dot_restorereg_p (dummy
)
3212 int dummy ATTRIBUTE_UNUSED
;
3214 unsigned int qp
, ab
, reg
;
3218 sep
= parse_operand (&e1
);
3221 as_bad ("No second operand to .restorereg.p");
3225 parse_operand (&e2
);
3227 qp
= e1
.X_add_number
- REG_P
;
3228 if (e1
.X_op
!= O_register
|| qp
> 63)
3230 as_bad ("First operand to .restorereg.p must be a predicate");
3234 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
3236 as_bad ("Second operand to .restorereg.p must be a preserved register");
3239 add_unwind_entry (output_spill_reg_p (ab
, reg
, 0, 0, qp
));
3243 generate_unwind_image (text_name
)
3244 const char *text_name
;
3247 unsigned char *unw_rec
;
3249 /* Force out pending instructions, to make sure all unwind records have
3250 a valid slot_number field. */
3251 ia64_flush_insns ();
3253 /* Generate the unwind record. */
3254 size
= output_unw_records (unwind
.list
, (void **) &unw_rec
);
3255 if (size
% md
.pointer_size
!= 0)
3256 as_bad ("Unwind record is not a multiple of %d bytes.", md
.pointer_size
);
3258 /* If there are unwind records, switch sections, and output the info. */
3261 unsigned char *where
;
3264 bfd_reloc_code_real_type reloc
;
3266 make_unw_section_name (SPECIAL_SECTION_UNWIND_INFO
, text_name
, sec_name
);
3267 set_section (sec_name
);
3268 bfd_set_section_flags (stdoutput
, now_seg
,
3269 SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
);
3271 /* Make sure the section has 4 byte alignment for ILP32 and
3272 8 byte alignment for LP64. */
3273 frag_align (md
.pointer_size_shift
, 0, 0);
3274 record_alignment (now_seg
, md
.pointer_size_shift
);
3276 /* Set expression which points to start of unwind descriptor area. */
3277 unwind
.info
= expr_build_dot ();
3279 where
= (unsigned char *) frag_more (size
);
3281 /* Issue a label for this address, and keep track of it to put it
3282 in the unwind section. */
3284 /* Copy the information from the unwind record into this section. The
3285 data is already in the correct byte order. */
3286 memcpy (where
, unw_rec
, size
);
3288 /* Add the personality address to the image. */
3289 if (unwind
.personality_routine
!= 0)
3291 exp
.X_op
= O_symbol
;
3292 exp
.X_add_symbol
= unwind
.personality_routine
;
3293 exp
.X_add_number
= 0;
3295 if (md
.flags
& EF_IA_64_BE
)
3297 if (md
.flags
& EF_IA_64_ABI64
)
3298 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64MSB
;
3300 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32MSB
;
3304 if (md
.flags
& EF_IA_64_ABI64
)
3305 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64LSB
;
3307 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32LSB
;
3310 fix_new_exp (frag_now
, frag_now_fix () - md
.pointer_size
,
3311 md
.pointer_size
, & exp
, 0, reloc
);
3312 unwind
.personality_routine
= 0;
3316 free_list_records (unwind
.list
);
3317 free_saved_prologue_counts ();
3318 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
3324 dot_handlerdata (dummy
)
3325 int dummy ATTRIBUTE_UNUSED
;
3327 const char *text_name
= segment_name (now_seg
);
3329 /* If text section name starts with ".text" (which it should),
3330 strip this prefix off. */
3331 if (strcmp (text_name
, ".text") == 0)
3334 unwind
.force_unwind_entry
= 1;
3336 /* Remember which segment we're in so we can switch back after .endp */
3337 unwind
.saved_text_seg
= now_seg
;
3338 unwind
.saved_text_subseg
= now_subseg
;
3340 /* Generate unwind info into unwind-info section and then leave that
3341 section as the currently active one so dataXX directives go into
3342 the language specific data area of the unwind info block. */
3343 generate_unwind_image (text_name
);
3344 demand_empty_rest_of_line ();
3348 dot_unwentry (dummy
)
3349 int dummy ATTRIBUTE_UNUSED
;
3351 unwind
.force_unwind_entry
= 1;
3352 demand_empty_rest_of_line ();
3357 int dummy ATTRIBUTE_UNUSED
;
3363 reg
= e
.X_add_number
- REG_BR
;
3364 if (e
.X_op
== O_register
&& reg
< 8)
3365 add_unwind_entry (output_rp_br (reg
));
3367 as_bad ("First operand not a valid branch register");
3371 dot_savemem (psprel
)
3378 sep
= parse_operand (&e1
);
3380 as_bad ("No second operand to .save%ssp", psprel
? "p" : "");
3381 sep
= parse_operand (&e2
);
3383 reg1
= e1
.X_add_number
;
3384 val
= e2
.X_add_number
;
3386 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3387 if (e1
.X_op
== O_register
)
3389 if (e2
.X_op
== O_constant
)
3393 case REG_AR
+ AR_BSP
:
3394 add_unwind_entry (output_bsp_when ());
3395 add_unwind_entry ((psprel
3397 : output_bsp_sprel
) (val
));
3399 case REG_AR
+ AR_BSPSTORE
:
3400 add_unwind_entry (output_bspstore_when ());
3401 add_unwind_entry ((psprel
3402 ? output_bspstore_psprel
3403 : output_bspstore_sprel
) (val
));
3405 case REG_AR
+ AR_RNAT
:
3406 add_unwind_entry (output_rnat_when ());
3407 add_unwind_entry ((psprel
3408 ? output_rnat_psprel
3409 : output_rnat_sprel
) (val
));
3411 case REG_AR
+ AR_UNAT
:
3412 add_unwind_entry (output_unat_when ());
3413 add_unwind_entry ((psprel
3414 ? output_unat_psprel
3415 : output_unat_sprel
) (val
));
3417 case REG_AR
+ AR_FPSR
:
3418 add_unwind_entry (output_fpsr_when ());
3419 add_unwind_entry ((psprel
3420 ? output_fpsr_psprel
3421 : output_fpsr_sprel
) (val
));
3423 case REG_AR
+ AR_PFS
:
3424 add_unwind_entry (output_pfs_when ());
3425 add_unwind_entry ((psprel
3427 : output_pfs_sprel
) (val
));
3429 case REG_AR
+ AR_LC
:
3430 add_unwind_entry (output_lc_when ());
3431 add_unwind_entry ((psprel
3433 : output_lc_sprel
) (val
));
3436 add_unwind_entry (output_rp_when ());
3437 add_unwind_entry ((psprel
3439 : output_rp_sprel
) (val
));
3442 add_unwind_entry (output_preds_when ());
3443 add_unwind_entry ((psprel
3444 ? output_preds_psprel
3445 : output_preds_sprel
) (val
));
3448 add_unwind_entry (output_priunat_when_mem ());
3449 add_unwind_entry ((psprel
3450 ? output_priunat_psprel
3451 : output_priunat_sprel
) (val
));
3454 as_bad ("First operand not a valid register");
3458 as_bad (" Second operand not a valid constant");
3461 as_bad ("First operand not a register");
3466 int dummy ATTRIBUTE_UNUSED
;
3470 sep
= parse_operand (&e1
);
3472 parse_operand (&e2
);
3474 if (e1
.X_op
!= O_constant
)
3475 as_bad ("First operand to .save.g must be a constant.");
3478 int grmask
= e1
.X_add_number
;
3480 add_unwind_entry (output_gr_mem (grmask
));
3483 int reg
= e2
.X_add_number
- REG_GR
;
3484 if (e2
.X_op
== O_register
&& reg
>= 0 && reg
< 128)
3485 add_unwind_entry (output_gr_gr (grmask
, reg
));
3487 as_bad ("Second operand is an invalid register.");
3494 int dummy ATTRIBUTE_UNUSED
;
3498 sep
= parse_operand (&e1
);
3500 if (e1
.X_op
!= O_constant
)
3501 as_bad ("Operand to .save.f must be a constant.");
3503 add_unwind_entry (output_fr_mem (e1
.X_add_number
));
3508 int dummy ATTRIBUTE_UNUSED
;
3515 sep
= parse_operand (&e1
);
3516 if (e1
.X_op
!= O_constant
)
3518 as_bad ("First operand to .save.b must be a constant.");
3521 brmask
= e1
.X_add_number
;
3525 sep
= parse_operand (&e2
);
3526 reg
= e2
.X_add_number
- REG_GR
;
3527 if (e2
.X_op
!= O_register
|| reg
> 127)
3529 as_bad ("Second operand to .save.b must be a general register.");
3532 add_unwind_entry (output_br_gr (brmask
, e2
.X_add_number
));
3535 add_unwind_entry (output_br_mem (brmask
));
3537 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3538 ignore_rest_of_line ();
3543 int dummy ATTRIBUTE_UNUSED
;
3547 sep
= parse_operand (&e1
);
3549 parse_operand (&e2
);
3551 if (e1
.X_op
!= O_constant
|| sep
!= ',' || e2
.X_op
!= O_constant
)
3552 as_bad ("Both operands of .save.gf must be constants.");
3555 int grmask
= e1
.X_add_number
;
3556 int frmask
= e2
.X_add_number
;
3557 add_unwind_entry (output_frgr_mem (grmask
, frmask
));
3563 int dummy ATTRIBUTE_UNUSED
;
3568 sep
= parse_operand (&e
);
3569 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3570 ignore_rest_of_line ();
3572 if (e
.X_op
!= O_constant
)
3573 as_bad ("Operand to .spill must be a constant");
3575 add_unwind_entry (output_spill_base (e
.X_add_number
));
3579 dot_spillreg (dummy
)
3580 int dummy ATTRIBUTE_UNUSED
;
3582 int sep
, ab
, xy
, reg
, treg
;
3585 sep
= parse_operand (&e1
);
3588 as_bad ("No second operand to .spillreg");
3592 parse_operand (&e2
);
3594 if (!convert_expr_to_ab_reg (&e1
, &ab
, ®
))
3596 as_bad ("First operand to .spillreg must be a preserved register");
3600 if (!convert_expr_to_xy_reg (&e2
, &xy
, &treg
))
3602 as_bad ("Second operand to .spillreg must be a register");
3606 add_unwind_entry (output_spill_reg (ab
, reg
, treg
, xy
));
3610 dot_spillmem (psprel
)
3616 sep
= parse_operand (&e1
);
3619 as_bad ("Second operand missing");
3623 parse_operand (&e2
);
3625 if (!convert_expr_to_ab_reg (&e1
, &ab
, ®
))
3627 as_bad ("First operand to .spill%s must be a preserved register",
3628 psprel
? "psp" : "sp");
3632 if (e2
.X_op
!= O_constant
)
3634 as_bad ("Second operand to .spill%s must be a constant",
3635 psprel
? "psp" : "sp");
3640 add_unwind_entry (output_spill_psprel (ab
, reg
, e2
.X_add_number
));
3642 add_unwind_entry (output_spill_sprel (ab
, reg
, e2
.X_add_number
));
3646 dot_spillreg_p (dummy
)
3647 int dummy ATTRIBUTE_UNUSED
;
3649 int sep
, ab
, xy
, reg
, treg
;
3650 expressionS e1
, e2
, e3
;
3653 sep
= parse_operand (&e1
);
3656 as_bad ("No second and third operand to .spillreg.p");
3660 sep
= parse_operand (&e2
);
3663 as_bad ("No third operand to .spillreg.p");
3667 parse_operand (&e3
);
3669 qp
= e1
.X_add_number
- REG_P
;
3671 if (e1
.X_op
!= O_register
|| qp
> 63)
3673 as_bad ("First operand to .spillreg.p must be a predicate");
3677 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
3679 as_bad ("Second operand to .spillreg.p must be a preserved register");
3683 if (!convert_expr_to_xy_reg (&e3
, &xy
, &treg
))
3685 as_bad ("Third operand to .spillreg.p must be a register");
3689 add_unwind_entry (output_spill_reg_p (ab
, reg
, treg
, xy
, qp
));
3693 dot_spillmem_p (psprel
)
3696 expressionS e1
, e2
, e3
;
3700 sep
= parse_operand (&e1
);
3703 as_bad ("Second operand missing");
3707 parse_operand (&e2
);
3710 as_bad ("Second operand missing");
3714 parse_operand (&e3
);
3716 qp
= e1
.X_add_number
- REG_P
;
3717 if (e1
.X_op
!= O_register
|| qp
> 63)
3719 as_bad ("First operand to .spill%s_p must be a predicate",
3720 psprel
? "psp" : "sp");
3724 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
3726 as_bad ("Second operand to .spill%s_p must be a preserved register",
3727 psprel
? "psp" : "sp");
3731 if (e3
.X_op
!= O_constant
)
3733 as_bad ("Third operand to .spill%s_p must be a constant",
3734 psprel
? "psp" : "sp");
3739 add_unwind_entry (output_spill_psprel_p (ab
, reg
, e3
.X_add_number
, qp
));
3741 add_unwind_entry (output_spill_sprel_p (ab
, reg
, e3
.X_add_number
, qp
));
3745 get_saved_prologue_count (lbl
)
3748 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3750 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
3754 return lpc
->prologue_count
;
3756 as_bad ("Missing .label_state %ld", lbl
);
3761 save_prologue_count (lbl
, count
)
3765 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3767 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
3771 lpc
->prologue_count
= count
;
3774 label_prologue_count
* new_lpc
= xmalloc (sizeof (* new_lpc
));
3776 new_lpc
->next
= unwind
.saved_prologue_counts
;
3777 new_lpc
->label_number
= lbl
;
3778 new_lpc
->prologue_count
= count
;
3779 unwind
.saved_prologue_counts
= new_lpc
;
3784 free_saved_prologue_counts ()
3786 label_prologue_count
* lpc
= unwind
.saved_prologue_counts
;
3787 label_prologue_count
* next
;
3796 unwind
.saved_prologue_counts
= NULL
;
3800 dot_label_state (dummy
)
3801 int dummy ATTRIBUTE_UNUSED
;
3806 if (e
.X_op
!= O_constant
)
3808 as_bad ("Operand to .label_state must be a constant");
3811 add_unwind_entry (output_label_state (e
.X_add_number
));
3812 save_prologue_count (e
.X_add_number
, unwind
.prologue_count
);
3816 dot_copy_state (dummy
)
3817 int dummy ATTRIBUTE_UNUSED
;
3822 if (e
.X_op
!= O_constant
)
3824 as_bad ("Operand to .copy_state must be a constant");
3827 add_unwind_entry (output_copy_state (e
.X_add_number
));
3828 unwind
.prologue_count
= get_saved_prologue_count (e
.X_add_number
);
3833 int dummy ATTRIBUTE_UNUSED
;
3838 sep
= parse_operand (&e1
);
3841 as_bad ("Second operand to .unwabi missing");
3844 sep
= parse_operand (&e2
);
3845 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3846 ignore_rest_of_line ();
3848 if (e1
.X_op
!= O_constant
)
3850 as_bad ("First operand to .unwabi must be a constant");
3854 if (e2
.X_op
!= O_constant
)
3856 as_bad ("Second operand to .unwabi must be a constant");
3860 add_unwind_entry (output_unwabi (e1
.X_add_number
, e2
.X_add_number
));
3864 dot_personality (dummy
)
3865 int dummy ATTRIBUTE_UNUSED
;
3869 name
= input_line_pointer
;
3870 c
= get_symbol_end ();
3871 p
= input_line_pointer
;
3872 unwind
.personality_routine
= symbol_find_or_make (name
);
3873 unwind
.force_unwind_entry
= 1;
3876 demand_empty_rest_of_line ();
3881 int dummy ATTRIBUTE_UNUSED
;
3886 unwind
.proc_start
= expr_build_dot ();
3887 /* Parse names of main and alternate entry points and mark them as
3888 function symbols: */
3892 name
= input_line_pointer
;
3893 c
= get_symbol_end ();
3894 p
= input_line_pointer
;
3895 sym
= symbol_find_or_make (name
);
3896 if (unwind
.proc_start
== 0)
3898 unwind
.proc_start
= sym
;
3900 symbol_get_bfdsym (sym
)->flags
|= BSF_FUNCTION
;
3903 if (*input_line_pointer
!= ',')
3905 ++input_line_pointer
;
3907 demand_empty_rest_of_line ();
3910 unwind
.prologue_count
= 0;
3911 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
3912 unwind
.personality_routine
= 0;
3917 int dummy ATTRIBUTE_UNUSED
;
3919 unwind
.prologue
= 0;
3920 unwind
.prologue_mask
= 0;
3922 add_unwind_entry (output_body ());
3923 demand_empty_rest_of_line ();
3927 dot_prologue (dummy
)
3928 int dummy ATTRIBUTE_UNUSED
;
3931 int mask
= 0, grsave
= 0;
3933 if (!is_it_end_of_statement ())
3936 sep
= parse_operand (&e1
);
3938 as_bad ("No second operand to .prologue");
3939 sep
= parse_operand (&e2
);
3940 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3941 ignore_rest_of_line ();
3943 if (e1
.X_op
== O_constant
)
3945 mask
= e1
.X_add_number
;
3947 if (e2
.X_op
== O_constant
)
3948 grsave
= e2
.X_add_number
;
3949 else if (e2
.X_op
== O_register
3950 && (grsave
= e2
.X_add_number
- REG_GR
) < 128)
3953 as_bad ("Second operand not a constant or general register");
3955 add_unwind_entry (output_prologue_gr (mask
, grsave
));
3958 as_bad ("First operand not a constant");
3961 add_unwind_entry (output_prologue ());
3963 unwind
.prologue
= 1;
3964 unwind
.prologue_mask
= mask
;
3965 ++unwind
.prologue_count
;
3970 int dummy ATTRIBUTE_UNUSED
;
3974 int bytes_per_address
;
3977 subsegT saved_subseg
;
3978 const char *sec_name
, *text_name
;
3982 if (unwind
.saved_text_seg
)
3984 saved_seg
= unwind
.saved_text_seg
;
3985 saved_subseg
= unwind
.saved_text_subseg
;
3986 unwind
.saved_text_seg
= NULL
;
3990 saved_seg
= now_seg
;
3991 saved_subseg
= now_subseg
;
3995 Use a slightly ugly scheme to derive the unwind section names from
3996 the text section name:
3998 text sect. unwind table sect.
3999 name: name: comments:
4000 ---------- ----------------- --------------------------------
4002 .text.foo .IA_64.unwind.text.foo
4003 .foo .IA_64.unwind.foo
4005 .gnu.linkonce.ia64unw.foo
4006 _info .IA_64.unwind_info gas issues error message (ditto)
4007 _infoFOO .IA_64.unwind_infoFOO gas issues error message (ditto)
4009 This mapping is done so that:
4011 (a) An object file with unwind info only in .text will use
4012 unwind section names .IA_64.unwind and .IA_64.unwind_info.
4013 This follows the letter of the ABI and also ensures backwards
4014 compatibility with older toolchains.
4016 (b) An object file with unwind info in multiple text sections
4017 will use separate unwind sections for each text section.
4018 This allows us to properly set the "sh_info" and "sh_link"
4019 fields in SHT_IA_64_UNWIND as required by the ABI and also
4020 lets GNU ld support programs with multiple segments
4021 containing unwind info (as might be the case for certain
4022 embedded applications).
4024 (c) An error is issued if there would be a name clash.
4026 text_name
= segment_name (saved_seg
);
4027 if (strncmp (text_name
, "_info", 5) == 0)
4029 as_bad ("Illegal section name `%s' (causes unwind section name clash)",
4031 ignore_rest_of_line ();
4034 if (strcmp (text_name
, ".text") == 0)
4037 insn_group_break (1, 0, 0);
4039 /* If there wasn't a .handlerdata, we haven't generated an image yet. */
4041 generate_unwind_image (text_name
);
4043 if (unwind
.info
|| unwind
.force_unwind_entry
)
4045 subseg_set (md
.last_text_seg
, 0);
4046 unwind
.proc_end
= expr_build_dot ();
4048 make_unw_section_name (SPECIAL_SECTION_UNWIND
, text_name
, sec_name
);
4049 set_section ((char *) sec_name
);
4050 bfd_set_section_flags (stdoutput
, now_seg
,
4051 SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
);
4053 /* Make sure that section has 4 byte alignment for ILP32 and
4054 8 byte alignment for LP64. */
4055 record_alignment (now_seg
, md
.pointer_size_shift
);
4057 /* Need space for 3 pointers for procedure start, procedure end,
4059 ptr
= frag_more (3 * md
.pointer_size
);
4060 where
= frag_now_fix () - (3 * md
.pointer_size
);
4061 bytes_per_address
= bfd_arch_bits_per_address (stdoutput
) / 8;
4063 /* Issue the values of a) Proc Begin, b) Proc End, c) Unwind Record. */
4064 e
.X_op
= O_pseudo_fixup
;
4065 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4067 e
.X_add_symbol
= unwind
.proc_start
;
4068 ia64_cons_fix_new (frag_now
, where
, bytes_per_address
, &e
);
4070 e
.X_op
= O_pseudo_fixup
;
4071 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4073 e
.X_add_symbol
= unwind
.proc_end
;
4074 ia64_cons_fix_new (frag_now
, where
+ bytes_per_address
,
4075 bytes_per_address
, &e
);
4079 e
.X_op
= O_pseudo_fixup
;
4080 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4082 e
.X_add_symbol
= unwind
.info
;
4083 ia64_cons_fix_new (frag_now
, where
+ (bytes_per_address
* 2),
4084 bytes_per_address
, &e
);
4087 md_number_to_chars (ptr
+ (bytes_per_address
* 2), 0,
4091 subseg_set (saved_seg
, saved_subseg
);
4093 /* Parse names of main and alternate entry points and set symbol sizes. */
4097 name
= input_line_pointer
;
4098 c
= get_symbol_end ();
4099 p
= input_line_pointer
;
4100 sym
= symbol_find (name
);
4101 if (sym
&& unwind
.proc_start
4102 && (symbol_get_bfdsym (sym
)->flags
& BSF_FUNCTION
)
4103 && S_GET_SIZE (sym
) == 0 && symbol_get_obj (sym
)->size
== NULL
)
4105 fragS
*fr
= symbol_get_frag (unwind
.proc_start
);
4106 fragS
*frag
= symbol_get_frag (sym
);
4108 /* Check whether the function label is at or beyond last
4110 while (fr
&& fr
!= frag
)
4114 if (frag
== frag_now
&& SEG_NORMAL (now_seg
))
4115 S_SET_SIZE (sym
, frag_now_fix () - S_GET_VALUE (sym
));
4118 symbol_get_obj (sym
)->size
=
4119 (expressionS
*) xmalloc (sizeof (expressionS
));
4120 symbol_get_obj (sym
)->size
->X_op
= O_subtract
;
4121 symbol_get_obj (sym
)->size
->X_add_symbol
4122 = symbol_new (FAKE_LABEL_NAME
, now_seg
,
4123 frag_now_fix (), frag_now
);
4124 symbol_get_obj (sym
)->size
->X_op_symbol
= sym
;
4125 symbol_get_obj (sym
)->size
->X_add_number
= 0;
4131 if (*input_line_pointer
!= ',')
4133 ++input_line_pointer
;
4135 demand_empty_rest_of_line ();
4136 unwind
.proc_start
= unwind
.proc_end
= unwind
.info
= 0;
4140 dot_template (template)
4143 CURR_SLOT
.user_template
= template;
4148 int dummy ATTRIBUTE_UNUSED
;
4150 int ins
, locs
, outs
, rots
;
4152 if (is_it_end_of_statement ())
4153 ins
= locs
= outs
= rots
= 0;
4156 ins
= get_absolute_expression ();
4157 if (*input_line_pointer
++ != ',')
4159 locs
= get_absolute_expression ();
4160 if (*input_line_pointer
++ != ',')
4162 outs
= get_absolute_expression ();
4163 if (*input_line_pointer
++ != ',')
4165 rots
= get_absolute_expression ();
4167 set_regstack (ins
, locs
, outs
, rots
);
4171 as_bad ("Comma expected");
4172 ignore_rest_of_line ();
4179 unsigned num_regs
, num_alloced
= 0;
4180 struct dynreg
**drpp
, *dr
;
4181 int ch
, base_reg
= 0;
4187 case DYNREG_GR
: base_reg
= REG_GR
+ 32; break;
4188 case DYNREG_FR
: base_reg
= REG_FR
+ 32; break;
4189 case DYNREG_PR
: base_reg
= REG_P
+ 16; break;
4193 /* First, remove existing names from hash table. */
4194 for (dr
= md
.dynreg
[type
]; dr
&& dr
->num_regs
; dr
= dr
->next
)
4196 hash_delete (md
.dynreg_hash
, dr
->name
);
4200 drpp
= &md
.dynreg
[type
];
4203 start
= input_line_pointer
;
4204 ch
= get_symbol_end ();
4205 *input_line_pointer
= ch
;
4206 len
= (input_line_pointer
- start
);
4209 if (*input_line_pointer
!= '[')
4211 as_bad ("Expected '['");
4214 ++input_line_pointer
; /* skip '[' */
4216 num_regs
= get_absolute_expression ();
4218 if (*input_line_pointer
++ != ']')
4220 as_bad ("Expected ']'");
4225 num_alloced
+= num_regs
;
4229 if (num_alloced
> md
.rot
.num_regs
)
4231 as_bad ("Used more than the declared %d rotating registers",
4237 if (num_alloced
> 96)
4239 as_bad ("Used more than the available 96 rotating registers");
4244 if (num_alloced
> 48)
4246 as_bad ("Used more than the available 48 rotating registers");
4255 name
= obstack_alloc (¬es
, len
+ 1);
4256 memcpy (name
, start
, len
);
4261 *drpp
= obstack_alloc (¬es
, sizeof (*dr
));
4262 memset (*drpp
, 0, sizeof (*dr
));
4267 dr
->num_regs
= num_regs
;
4268 dr
->base
= base_reg
;
4270 base_reg
+= num_regs
;
4272 if (hash_insert (md
.dynreg_hash
, name
, dr
))
4274 as_bad ("Attempt to redefine register set `%s'", name
);
4278 if (*input_line_pointer
!= ',')
4280 ++input_line_pointer
; /* skip comma */
4283 demand_empty_rest_of_line ();
4287 ignore_rest_of_line ();
4291 dot_byteorder (byteorder
)
4294 target_big_endian
= byteorder
;
4299 int dummy ATTRIBUTE_UNUSED
;
4306 option
= input_line_pointer
;
4307 ch
= get_symbol_end ();
4308 if (strcmp (option
, "lsb") == 0)
4309 md
.flags
&= ~EF_IA_64_BE
;
4310 else if (strcmp (option
, "msb") == 0)
4311 md
.flags
|= EF_IA_64_BE
;
4312 else if (strcmp (option
, "abi32") == 0)
4313 md
.flags
&= ~EF_IA_64_ABI64
;
4314 else if (strcmp (option
, "abi64") == 0)
4315 md
.flags
|= EF_IA_64_ABI64
;
4317 as_bad ("Unknown psr option `%s'", option
);
4318 *input_line_pointer
= ch
;
4321 if (*input_line_pointer
!= ',')
4324 ++input_line_pointer
;
4327 demand_empty_rest_of_line ();
4332 int dummy ATTRIBUTE_UNUSED
;
4334 as_bad (".alias not implemented yet");
4339 int dummy ATTRIBUTE_UNUSED
;
4341 new_logical_line (0, get_absolute_expression ());
4342 demand_empty_rest_of_line ();
4346 parse_section_name ()
4352 if (*input_line_pointer
!= '"')
4354 as_bad ("Missing section name");
4355 ignore_rest_of_line ();
4358 name
= demand_copy_C_string (&len
);
4361 ignore_rest_of_line ();
4365 if (*input_line_pointer
!= ',')
4367 as_bad ("Comma expected after section name");
4368 ignore_rest_of_line ();
4371 ++input_line_pointer
; /* skip comma */
4379 char *name
= parse_section_name ();
4383 md
.keep_pending_output
= 1;
4386 obj_elf_previous (0);
4387 md
.keep_pending_output
= 0;
4390 /* Why doesn't float_cons() call md_cons_align() the way cons() does? */
4393 stmt_float_cons (kind
)
4400 case 'd': size
= 8; break;
4401 case 'x': size
= 10; break;
4408 ia64_do_align (size
);
4416 int saved_auto_align
= md
.auto_align
;
4420 md
.auto_align
= saved_auto_align
;
4424 dot_xfloat_cons (kind
)
4427 char *name
= parse_section_name ();
4431 md
.keep_pending_output
= 1;
4433 stmt_float_cons (kind
);
4434 obj_elf_previous (0);
4435 md
.keep_pending_output
= 0;
4439 dot_xstringer (zero
)
4442 char *name
= parse_section_name ();
4446 md
.keep_pending_output
= 1;
4449 obj_elf_previous (0);
4450 md
.keep_pending_output
= 0;
4457 int saved_auto_align
= md
.auto_align
;
4458 char *name
= parse_section_name ();
4462 md
.keep_pending_output
= 1;
4466 md
.auto_align
= saved_auto_align
;
4467 obj_elf_previous (0);
4468 md
.keep_pending_output
= 0;
4472 dot_xfloat_cons_ua (kind
)
4475 int saved_auto_align
= md
.auto_align
;
4476 char *name
= parse_section_name ();
4480 md
.keep_pending_output
= 1;
4483 stmt_float_cons (kind
);
4484 md
.auto_align
= saved_auto_align
;
4485 obj_elf_previous (0);
4486 md
.keep_pending_output
= 0;
4489 /* .reg.val <regname>,value */
4493 int dummy ATTRIBUTE_UNUSED
;
4498 if (reg
.X_op
!= O_register
)
4500 as_bad (_("Register name expected"));
4501 ignore_rest_of_line ();
4503 else if (*input_line_pointer
++ != ',')
4505 as_bad (_("Comma expected"));
4506 ignore_rest_of_line ();
4510 valueT value
= get_absolute_expression ();
4511 int regno
= reg
.X_add_number
;
4512 if (regno
< REG_GR
|| regno
> REG_GR
+ 128)
4513 as_warn (_("Register value annotation ignored"));
4516 gr_values
[regno
- REG_GR
].known
= 1;
4517 gr_values
[regno
- REG_GR
].value
= value
;
4518 gr_values
[regno
- REG_GR
].path
= md
.path
;
4521 demand_empty_rest_of_line ();
4524 /* select dv checking mode
4529 A stop is inserted when changing modes
4536 if (md
.manual_bundling
)
4537 as_warn (_("Directive invalid within a bundle"));
4539 if (type
== 'E' || type
== 'A')
4540 md
.mode_explicitly_set
= 0;
4542 md
.mode_explicitly_set
= 1;
4549 if (md
.explicit_mode
)
4550 insn_group_break (1, 0, 0);
4551 md
.explicit_mode
= 0;
4555 if (!md
.explicit_mode
)
4556 insn_group_break (1, 0, 0);
4557 md
.explicit_mode
= 1;
4561 if (md
.explicit_mode
!= md
.default_explicit_mode
)
4562 insn_group_break (1, 0, 0);
4563 md
.explicit_mode
= md
.default_explicit_mode
;
4564 md
.mode_explicitly_set
= 0;
4575 for (regno
= 0; regno
< 64; regno
++)
4577 if (mask
& ((valueT
) 1 << regno
))
4579 fprintf (stderr
, "%s p%d", comma
, regno
);
4586 .pred.rel.clear [p1 [,p2 [,...]]] (also .pred.rel "clear")
4587 .pred.rel.imply p1, p2 (also .pred.rel "imply")
4588 .pred.rel.mutex p1, p2 [,...] (also .pred.rel "mutex")
4589 .pred.safe_across_calls p1 [, p2 [,...]]
4598 int p1
= -1, p2
= -1;
4602 if (*input_line_pointer
!= '"')
4604 as_bad (_("Missing predicate relation type"));
4605 ignore_rest_of_line ();
4611 char *form
= demand_copy_C_string (&len
);
4612 if (strcmp (form
, "mutex") == 0)
4614 else if (strcmp (form
, "clear") == 0)
4616 else if (strcmp (form
, "imply") == 0)
4620 as_bad (_("Unrecognized predicate relation type"));
4621 ignore_rest_of_line ();
4625 if (*input_line_pointer
== ',')
4626 ++input_line_pointer
;
4636 if (TOUPPER (*input_line_pointer
) != 'P'
4637 || (regno
= atoi (++input_line_pointer
)) < 0
4640 as_bad (_("Predicate register expected"));
4641 ignore_rest_of_line ();
4644 while (ISDIGIT (*input_line_pointer
))
4645 ++input_line_pointer
;
4652 as_warn (_("Duplicate predicate register ignored"));
4655 /* See if it's a range. */
4656 if (*input_line_pointer
== '-')
4659 ++input_line_pointer
;
4661 if (TOUPPER (*input_line_pointer
) != 'P'
4662 || (regno
= atoi (++input_line_pointer
)) < 0
4665 as_bad (_("Predicate register expected"));
4666 ignore_rest_of_line ();
4669 while (ISDIGIT (*input_line_pointer
))
4670 ++input_line_pointer
;
4674 as_bad (_("Bad register range"));
4675 ignore_rest_of_line ();
4686 if (*input_line_pointer
!= ',')
4688 ++input_line_pointer
;
4697 clear_qp_mutex (mask
);
4698 clear_qp_implies (mask
, (valueT
) 0);
4701 if (count
!= 2 || p1
== -1 || p2
== -1)
4702 as_bad (_("Predicate source and target required"));
4703 else if (p1
== 0 || p2
== 0)
4704 as_bad (_("Use of p0 is not valid in this context"));
4706 add_qp_imply (p1
, p2
);
4711 as_bad (_("At least two PR arguments expected"));
4716 as_bad (_("Use of p0 is not valid in this context"));
4719 add_qp_mutex (mask
);
4722 /* note that we don't override any existing relations */
4725 as_bad (_("At least one PR argument expected"));
4730 fprintf (stderr
, "Safe across calls: ");
4731 print_prmask (mask
);
4732 fprintf (stderr
, "\n");
4734 qp_safe_across_calls
= mask
;
4737 demand_empty_rest_of_line ();
4740 /* .entry label [, label [, ...]]
4741 Hint to DV code that the given labels are to be considered entry points.
4742 Otherwise, only global labels are considered entry points. */
4746 int dummy ATTRIBUTE_UNUSED
;
4755 name
= input_line_pointer
;
4756 c
= get_symbol_end ();
4757 symbolP
= symbol_find_or_make (name
);
4759 err
= hash_insert (md
.entry_hash
, S_GET_NAME (symbolP
), (PTR
) symbolP
);
4761 as_fatal (_("Inserting \"%s\" into entry hint table failed: %s"),
4764 *input_line_pointer
= c
;
4766 c
= *input_line_pointer
;
4769 input_line_pointer
++;
4771 if (*input_line_pointer
== '\n')
4777 demand_empty_rest_of_line ();
4780 /* .mem.offset offset, base
4781 "base" is used to distinguish between offsets from a different base. */
4784 dot_mem_offset (dummy
)
4785 int dummy ATTRIBUTE_UNUSED
;
4787 md
.mem_offset
.hint
= 1;
4788 md
.mem_offset
.offset
= get_absolute_expression ();
4789 if (*input_line_pointer
!= ',')
4791 as_bad (_("Comma expected"));
4792 ignore_rest_of_line ();
4795 ++input_line_pointer
;
4796 md
.mem_offset
.base
= get_absolute_expression ();
4797 demand_empty_rest_of_line ();
4800 /* ia64-specific pseudo-ops: */
4801 const pseudo_typeS md_pseudo_table
[] =
4803 { "radix", dot_radix
, 0 },
4804 { "lcomm", s_lcomm_bytes
, 1 },
4805 { "bss", dot_special_section
, SPECIAL_SECTION_BSS
},
4806 { "sbss", dot_special_section
, SPECIAL_SECTION_SBSS
},
4807 { "sdata", dot_special_section
, SPECIAL_SECTION_SDATA
},
4808 { "rodata", dot_special_section
, SPECIAL_SECTION_RODATA
},
4809 { "comment", dot_special_section
, SPECIAL_SECTION_COMMENT
},
4810 { "ia_64.unwind", dot_special_section
, SPECIAL_SECTION_UNWIND
},
4811 { "ia_64.unwind_info", dot_special_section
, SPECIAL_SECTION_UNWIND_INFO
},
4812 { "init_array", dot_special_section
, SPECIAL_SECTION_INIT_ARRAY
},
4813 { "fini_array", dot_special_section
, SPECIAL_SECTION_FINI_ARRAY
},
4814 { "proc", dot_proc
, 0 },
4815 { "body", dot_body
, 0 },
4816 { "prologue", dot_prologue
, 0 },
4817 { "endp", dot_endp
, 0 },
4818 { "file", dwarf2_directive_file
, 0 },
4819 { "loc", dwarf2_directive_loc
, 0 },
4821 { "fframe", dot_fframe
, 0 },
4822 { "vframe", dot_vframe
, 0 },
4823 { "vframesp", dot_vframesp
, 0 },
4824 { "vframepsp", dot_vframepsp
, 0 },
4825 { "save", dot_save
, 0 },
4826 { "restore", dot_restore
, 0 },
4827 { "restorereg", dot_restorereg
, 0 },
4828 { "restorereg.p", dot_restorereg_p
, 0 },
4829 { "handlerdata", dot_handlerdata
, 0 },
4830 { "unwentry", dot_unwentry
, 0 },
4831 { "altrp", dot_altrp
, 0 },
4832 { "savesp", dot_savemem
, 0 },
4833 { "savepsp", dot_savemem
, 1 },
4834 { "save.g", dot_saveg
, 0 },
4835 { "save.f", dot_savef
, 0 },
4836 { "save.b", dot_saveb
, 0 },
4837 { "save.gf", dot_savegf
, 0 },
4838 { "spill", dot_spill
, 0 },
4839 { "spillreg", dot_spillreg
, 0 },
4840 { "spillsp", dot_spillmem
, 0 },
4841 { "spillpsp", dot_spillmem
, 1 },
4842 { "spillreg.p", dot_spillreg_p
, 0 },
4843 { "spillsp.p", dot_spillmem_p
, 0 },
4844 { "spillpsp.p", dot_spillmem_p
, 1 },
4845 { "label_state", dot_label_state
, 0 },
4846 { "copy_state", dot_copy_state
, 0 },
4847 { "unwabi", dot_unwabi
, 0 },
4848 { "personality", dot_personality
, 0 },
4850 { "estate", dot_estate
, 0 },
4852 { "mii", dot_template
, 0x0 },
4853 { "mli", dot_template
, 0x2 }, /* old format, for compatibility */
4854 { "mlx", dot_template
, 0x2 },
4855 { "mmi", dot_template
, 0x4 },
4856 { "mfi", dot_template
, 0x6 },
4857 { "mmf", dot_template
, 0x7 },
4858 { "mib", dot_template
, 0x8 },
4859 { "mbb", dot_template
, 0x9 },
4860 { "bbb", dot_template
, 0xb },
4861 { "mmb", dot_template
, 0xc },
4862 { "mfb", dot_template
, 0xe },
4864 { "lb", dot_scope
, 0 },
4865 { "le", dot_scope
, 1 },
4867 { "align", s_align_bytes
, 0 },
4868 { "regstk", dot_regstk
, 0 },
4869 { "rotr", dot_rot
, DYNREG_GR
},
4870 { "rotf", dot_rot
, DYNREG_FR
},
4871 { "rotp", dot_rot
, DYNREG_PR
},
4872 { "lsb", dot_byteorder
, 0 },
4873 { "msb", dot_byteorder
, 1 },
4874 { "psr", dot_psr
, 0 },
4875 { "alias", dot_alias
, 0 },
4876 { "ln", dot_ln
, 0 }, /* source line info (for debugging) */
4878 { "xdata1", dot_xdata
, 1 },
4879 { "xdata2", dot_xdata
, 2 },
4880 { "xdata4", dot_xdata
, 4 },
4881 { "xdata8", dot_xdata
, 8 },
4882 { "xreal4", dot_xfloat_cons
, 'f' },
4883 { "xreal8", dot_xfloat_cons
, 'd' },
4884 { "xreal10", dot_xfloat_cons
, 'x' },
4885 { "xstring", dot_xstringer
, 0 },
4886 { "xstringz", dot_xstringer
, 1 },
4888 /* unaligned versions: */
4889 { "xdata2.ua", dot_xdata_ua
, 2 },
4890 { "xdata4.ua", dot_xdata_ua
, 4 },
4891 { "xdata8.ua", dot_xdata_ua
, 8 },
4892 { "xreal4.ua", dot_xfloat_cons_ua
, 'f' },
4893 { "xreal8.ua", dot_xfloat_cons_ua
, 'd' },
4894 { "xreal10.ua", dot_xfloat_cons_ua
, 'x' },
4896 /* annotations/DV checking support */
4897 { "entry", dot_entry
, 0 },
4898 { "mem.offset", dot_mem_offset
, 0 },
4899 { "pred.rel", dot_pred_rel
, 0 },
4900 { "pred.rel.clear", dot_pred_rel
, 'c' },
4901 { "pred.rel.imply", dot_pred_rel
, 'i' },
4902 { "pred.rel.mutex", dot_pred_rel
, 'm' },
4903 { "pred.safe_across_calls", dot_pred_rel
, 's' },
4904 { "reg.val", dot_reg_val
, 0 },
4905 { "auto", dot_dv_mode
, 'a' },
4906 { "explicit", dot_dv_mode
, 'e' },
4907 { "default", dot_dv_mode
, 'd' },
4909 /* ??? These are needed to make gas/testsuite/gas/elf/ehopt.s work.
4910 IA-64 aligns data allocation pseudo-ops by default, so we have to
4911 tell it that these ones are supposed to be unaligned. Long term,
4912 should rewrite so that only IA-64 specific data allocation pseudo-ops
4913 are aligned by default. */
4914 {"2byte", stmt_cons_ua
, 2},
4915 {"4byte", stmt_cons_ua
, 4},
4916 {"8byte", stmt_cons_ua
, 8},
4921 static const struct pseudo_opcode
4924 void (*handler
) (int);
4929 /* these are more like pseudo-ops, but don't start with a dot */
4930 { "data1", cons
, 1 },
4931 { "data2", cons
, 2 },
4932 { "data4", cons
, 4 },
4933 { "data8", cons
, 8 },
4934 { "data16", cons
, 16 },
4935 { "real4", stmt_float_cons
, 'f' },
4936 { "real8", stmt_float_cons
, 'd' },
4937 { "real10", stmt_float_cons
, 'x' },
4938 { "string", stringer
, 0 },
4939 { "stringz", stringer
, 1 },
4941 /* unaligned versions: */
4942 { "data2.ua", stmt_cons_ua
, 2 },
4943 { "data4.ua", stmt_cons_ua
, 4 },
4944 { "data8.ua", stmt_cons_ua
, 8 },
4945 { "data16.ua", stmt_cons_ua
, 16 },
4946 { "real4.ua", float_cons
, 'f' },
4947 { "real8.ua", float_cons
, 'd' },
4948 { "real10.ua", float_cons
, 'x' },
4951 /* Declare a register by creating a symbol for it and entering it in
4952 the symbol table. */
4955 declare_register (name
, regnum
)
4962 sym
= symbol_new (name
, reg_section
, regnum
, &zero_address_frag
);
4964 err
= hash_insert (md
.reg_hash
, S_GET_NAME (sym
), (PTR
) sym
);
4966 as_fatal ("Inserting \"%s\" into register table failed: %s",
4973 declare_register_set (prefix
, num_regs
, base_regnum
)
4981 for (i
= 0; i
< num_regs
; ++i
)
4983 sprintf (name
, "%s%u", prefix
, i
);
4984 declare_register (name
, base_regnum
+ i
);
4989 operand_width (opnd
)
4990 enum ia64_opnd opnd
;
4992 const struct ia64_operand
*odesc
= &elf64_ia64_operands
[opnd
];
4993 unsigned int bits
= 0;
4997 for (i
= 0; i
< NELEMS (odesc
->field
) && odesc
->field
[i
].bits
; ++i
)
4998 bits
+= odesc
->field
[i
].bits
;
5003 static enum operand_match_result
5004 operand_match (idesc
, index
, e
)
5005 const struct ia64_opcode
*idesc
;
5009 enum ia64_opnd opnd
= idesc
->operands
[index
];
5010 int bits
, relocatable
= 0;
5011 struct insn_fix
*fix
;
5018 case IA64_OPND_AR_CCV
:
5019 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 32)
5020 return OPERAND_MATCH
;
5023 case IA64_OPND_AR_PFS
:
5024 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 64)
5025 return OPERAND_MATCH
;
5029 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_GR
+ 0)
5030 return OPERAND_MATCH
;
5034 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_IP
)
5035 return OPERAND_MATCH
;
5039 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR
)
5040 return OPERAND_MATCH
;
5043 case IA64_OPND_PR_ROT
:
5044 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR_ROT
)
5045 return OPERAND_MATCH
;
5049 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR
)
5050 return OPERAND_MATCH
;
5053 case IA64_OPND_PSR_L
:
5054 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_L
)
5055 return OPERAND_MATCH
;
5058 case IA64_OPND_PSR_UM
:
5059 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_UM
)
5060 return OPERAND_MATCH
;
5064 if (e
->X_op
== O_constant
)
5066 if (e
->X_add_number
== 1)
5067 return OPERAND_MATCH
;
5069 return OPERAND_OUT_OF_RANGE
;
5074 if (e
->X_op
== O_constant
)
5076 if (e
->X_add_number
== 8)
5077 return OPERAND_MATCH
;
5079 return OPERAND_OUT_OF_RANGE
;
5084 if (e
->X_op
== O_constant
)
5086 if (e
->X_add_number
== 16)
5087 return OPERAND_MATCH
;
5089 return OPERAND_OUT_OF_RANGE
;
5093 /* register operands: */
5096 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_AR
5097 && e
->X_add_number
< REG_AR
+ 128)
5098 return OPERAND_MATCH
;
5103 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_BR
5104 && e
->X_add_number
< REG_BR
+ 8)
5105 return OPERAND_MATCH
;
5109 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_CR
5110 && e
->X_add_number
< REG_CR
+ 128)
5111 return OPERAND_MATCH
;
5118 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_FR
5119 && e
->X_add_number
< REG_FR
+ 128)
5120 return OPERAND_MATCH
;
5125 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_P
5126 && e
->X_add_number
< REG_P
+ 64)
5127 return OPERAND_MATCH
;
5133 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
5134 && e
->X_add_number
< REG_GR
+ 128)
5135 return OPERAND_MATCH
;
5138 case IA64_OPND_R3_2
:
5139 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
)
5141 if (e
->X_add_number
< REG_GR
+ 4)
5142 return OPERAND_MATCH
;
5143 else if (e
->X_add_number
< REG_GR
+ 128)
5144 return OPERAND_OUT_OF_RANGE
;
5148 /* indirect operands: */
5149 case IA64_OPND_CPUID_R3
:
5150 case IA64_OPND_DBR_R3
:
5151 case IA64_OPND_DTR_R3
:
5152 case IA64_OPND_ITR_R3
:
5153 case IA64_OPND_IBR_R3
:
5154 case IA64_OPND_MSR_R3
:
5155 case IA64_OPND_PKR_R3
:
5156 case IA64_OPND_PMC_R3
:
5157 case IA64_OPND_PMD_R3
:
5158 case IA64_OPND_RR_R3
:
5159 if (e
->X_op
== O_index
&& e
->X_op_symbol
5160 && (S_GET_VALUE (e
->X_op_symbol
) - IND_CPUID
5161 == opnd
- IA64_OPND_CPUID_R3
))
5162 return OPERAND_MATCH
;
5166 if (e
->X_op
== O_index
&& !e
->X_op_symbol
)
5167 return OPERAND_MATCH
;
5170 /* immediate operands: */
5171 case IA64_OPND_CNT2a
:
5172 case IA64_OPND_LEN4
:
5173 case IA64_OPND_LEN6
:
5174 bits
= operand_width (idesc
->operands
[index
]);
5175 if (e
->X_op
== O_constant
)
5177 if ((bfd_vma
) (e
->X_add_number
- 1) < ((bfd_vma
) 1 << bits
))
5178 return OPERAND_MATCH
;
5180 return OPERAND_OUT_OF_RANGE
;
5184 case IA64_OPND_CNT2b
:
5185 if (e
->X_op
== O_constant
)
5187 if ((bfd_vma
) (e
->X_add_number
- 1) < 3)
5188 return OPERAND_MATCH
;
5190 return OPERAND_OUT_OF_RANGE
;
5194 case IA64_OPND_CNT2c
:
5195 val
= e
->X_add_number
;
5196 if (e
->X_op
== O_constant
)
5198 if ((val
== 0 || val
== 7 || val
== 15 || val
== 16))
5199 return OPERAND_MATCH
;
5201 return OPERAND_OUT_OF_RANGE
;
5206 /* SOR must be an integer multiple of 8 */
5207 if (e
->X_op
== O_constant
&& e
->X_add_number
& 0x7)
5208 return OPERAND_OUT_OF_RANGE
;
5211 if (e
->X_op
== O_constant
)
5213 if ((bfd_vma
) e
->X_add_number
<= 96)
5214 return OPERAND_MATCH
;
5216 return OPERAND_OUT_OF_RANGE
;
5220 case IA64_OPND_IMMU62
:
5221 if (e
->X_op
== O_constant
)
5223 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 62))
5224 return OPERAND_MATCH
;
5226 return OPERAND_OUT_OF_RANGE
;
5230 /* FIXME -- need 62-bit relocation type */
5231 as_bad (_("62-bit relocation not yet implemented"));
5235 case IA64_OPND_IMMU64
:
5236 if (e
->X_op
== O_symbol
|| e
->X_op
== O_pseudo_fixup
5237 || e
->X_op
== O_subtract
)
5239 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5240 fix
->code
= BFD_RELOC_IA64_IMM64
;
5241 if (e
->X_op
!= O_subtract
)
5243 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5244 if (e
->X_op
== O_pseudo_fixup
)
5248 fix
->opnd
= idesc
->operands
[index
];
5251 ++CURR_SLOT
.num_fixups
;
5252 return OPERAND_MATCH
;
5254 else if (e
->X_op
== O_constant
)
5255 return OPERAND_MATCH
;
5258 case IA64_OPND_CCNT5
:
5259 case IA64_OPND_CNT5
:
5260 case IA64_OPND_CNT6
:
5261 case IA64_OPND_CPOS6a
:
5262 case IA64_OPND_CPOS6b
:
5263 case IA64_OPND_CPOS6c
:
5264 case IA64_OPND_IMMU2
:
5265 case IA64_OPND_IMMU7a
:
5266 case IA64_OPND_IMMU7b
:
5267 case IA64_OPND_IMMU21
:
5268 case IA64_OPND_IMMU24
:
5269 case IA64_OPND_MBTYPE4
:
5270 case IA64_OPND_MHTYPE8
:
5271 case IA64_OPND_POS6
:
5272 bits
= operand_width (idesc
->operands
[index
]);
5273 if (e
->X_op
== O_constant
)
5275 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5276 return OPERAND_MATCH
;
5278 return OPERAND_OUT_OF_RANGE
;
5282 case IA64_OPND_IMMU9
:
5283 bits
= operand_width (idesc
->operands
[index
]);
5284 if (e
->X_op
== O_constant
)
5286 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5288 int lobits
= e
->X_add_number
& 0x3;
5289 if (((bfd_vma
) e
->X_add_number
& 0x3C) != 0 && lobits
== 0)
5290 e
->X_add_number
|= (bfd_vma
) 0x3;
5291 return OPERAND_MATCH
;
5294 return OPERAND_OUT_OF_RANGE
;
5298 case IA64_OPND_IMM44
:
5299 /* least 16 bits must be zero */
5300 if ((e
->X_add_number
& 0xffff) != 0)
5301 /* XXX technically, this is wrong: we should not be issuing warning
5302 messages until we're sure this instruction pattern is going to
5304 as_warn (_("lower 16 bits of mask ignored"));
5306 if (e
->X_op
== O_constant
)
5308 if (((e
->X_add_number
>= 0
5309 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 44))
5310 || (e
->X_add_number
< 0
5311 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 44))))
5314 if (e
->X_add_number
>= 0
5315 && (e
->X_add_number
& ((bfd_vma
) 1 << 43)) != 0)
5317 e
->X_add_number
|= ~(((bfd_vma
) 1 << 44) - 1);
5319 return OPERAND_MATCH
;
5322 return OPERAND_OUT_OF_RANGE
;
5326 case IA64_OPND_IMM17
:
5327 /* bit 0 is a don't care (pr0 is hardwired to 1) */
5328 if (e
->X_op
== O_constant
)
5330 if (((e
->X_add_number
>= 0
5331 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 17))
5332 || (e
->X_add_number
< 0
5333 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 17))))
5336 if (e
->X_add_number
>= 0
5337 && (e
->X_add_number
& ((bfd_vma
) 1 << 16)) != 0)
5339 e
->X_add_number
|= ~(((bfd_vma
) 1 << 17) - 1);
5341 return OPERAND_MATCH
;
5344 return OPERAND_OUT_OF_RANGE
;
5348 case IA64_OPND_IMM14
:
5349 case IA64_OPND_IMM22
:
5351 case IA64_OPND_IMM1
:
5352 case IA64_OPND_IMM8
:
5353 case IA64_OPND_IMM8U4
:
5354 case IA64_OPND_IMM8M1
:
5355 case IA64_OPND_IMM8M1U4
:
5356 case IA64_OPND_IMM8M1U8
:
5357 case IA64_OPND_IMM9a
:
5358 case IA64_OPND_IMM9b
:
5359 bits
= operand_width (idesc
->operands
[index
]);
5360 if (relocatable
&& (e
->X_op
== O_symbol
5361 || e
->X_op
== O_subtract
5362 || e
->X_op
== O_pseudo_fixup
))
5364 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5366 if (idesc
->operands
[index
] == IA64_OPND_IMM14
)
5367 fix
->code
= BFD_RELOC_IA64_IMM14
;
5369 fix
->code
= BFD_RELOC_IA64_IMM22
;
5371 if (e
->X_op
!= O_subtract
)
5373 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5374 if (e
->X_op
== O_pseudo_fixup
)
5378 fix
->opnd
= idesc
->operands
[index
];
5381 ++CURR_SLOT
.num_fixups
;
5382 return OPERAND_MATCH
;
5384 else if (e
->X_op
!= O_constant
5385 && ! (e
->X_op
== O_big
&& opnd
== IA64_OPND_IMM8M1U8
))
5386 return OPERAND_MISMATCH
;
5388 if (opnd
== IA64_OPND_IMM8M1U4
)
5390 /* Zero is not valid for unsigned compares that take an adjusted
5391 constant immediate range. */
5392 if (e
->X_add_number
== 0)
5393 return OPERAND_OUT_OF_RANGE
;
5395 /* Sign-extend 32-bit unsigned numbers, so that the following range
5396 checks will work. */
5397 val
= e
->X_add_number
;
5398 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5399 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5400 val
= ((val
<< 32) >> 32);
5402 /* Check for 0x100000000. This is valid because
5403 0x100000000-1 is the same as ((uint32_t) -1). */
5404 if (val
== ((bfd_signed_vma
) 1 << 32))
5405 return OPERAND_MATCH
;
5409 else if (opnd
== IA64_OPND_IMM8M1U8
)
5411 /* Zero is not valid for unsigned compares that take an adjusted
5412 constant immediate range. */
5413 if (e
->X_add_number
== 0)
5414 return OPERAND_OUT_OF_RANGE
;
5416 /* Check for 0x10000000000000000. */
5417 if (e
->X_op
== O_big
)
5419 if (generic_bignum
[0] == 0
5420 && generic_bignum
[1] == 0
5421 && generic_bignum
[2] == 0
5422 && generic_bignum
[3] == 0
5423 && generic_bignum
[4] == 1)
5424 return OPERAND_MATCH
;
5426 return OPERAND_OUT_OF_RANGE
;
5429 val
= e
->X_add_number
- 1;
5431 else if (opnd
== IA64_OPND_IMM8M1
)
5432 val
= e
->X_add_number
- 1;
5433 else if (opnd
== IA64_OPND_IMM8U4
)
5435 /* Sign-extend 32-bit unsigned numbers, so that the following range
5436 checks will work. */
5437 val
= e
->X_add_number
;
5438 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5439 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5440 val
= ((val
<< 32) >> 32);
5443 val
= e
->X_add_number
;
5445 if ((val
>= 0 && (bfd_vma
) val
< ((bfd_vma
) 1 << (bits
- 1)))
5446 || (val
< 0 && (bfd_vma
) -val
<= ((bfd_vma
) 1 << (bits
- 1))))
5447 return OPERAND_MATCH
;
5449 return OPERAND_OUT_OF_RANGE
;
5451 case IA64_OPND_INC3
:
5452 /* +/- 1, 4, 8, 16 */
5453 val
= e
->X_add_number
;
5456 if (e
->X_op
== O_constant
)
5458 if ((val
== 1 || val
== 4 || val
== 8 || val
== 16))
5459 return OPERAND_MATCH
;
5461 return OPERAND_OUT_OF_RANGE
;
5465 case IA64_OPND_TGT25
:
5466 case IA64_OPND_TGT25b
:
5467 case IA64_OPND_TGT25c
:
5468 case IA64_OPND_TGT64
:
5469 if (e
->X_op
== O_symbol
)
5471 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5472 if (opnd
== IA64_OPND_TGT25
)
5473 fix
->code
= BFD_RELOC_IA64_PCREL21F
;
5474 else if (opnd
== IA64_OPND_TGT25b
)
5475 fix
->code
= BFD_RELOC_IA64_PCREL21M
;
5476 else if (opnd
== IA64_OPND_TGT25c
)
5477 fix
->code
= BFD_RELOC_IA64_PCREL21B
;
5478 else if (opnd
== IA64_OPND_TGT64
)
5479 fix
->code
= BFD_RELOC_IA64_PCREL60B
;
5483 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5484 fix
->opnd
= idesc
->operands
[index
];
5487 ++CURR_SLOT
.num_fixups
;
5488 return OPERAND_MATCH
;
5490 case IA64_OPND_TAG13
:
5491 case IA64_OPND_TAG13b
:
5495 return OPERAND_MATCH
;
5498 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5499 /* There are no external relocs for TAG13/TAG13b fields, so we
5500 create a dummy reloc. This will not live past md_apply_fix3. */
5501 fix
->code
= BFD_RELOC_UNUSED
;
5502 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5503 fix
->opnd
= idesc
->operands
[index
];
5506 ++CURR_SLOT
.num_fixups
;
5507 return OPERAND_MATCH
;
5517 return OPERAND_MISMATCH
;
5526 memset (e
, 0, sizeof (*e
));
5529 if (*input_line_pointer
!= '}')
5531 sep
= *input_line_pointer
++;
5535 if (!md
.manual_bundling
)
5536 as_warn ("Found '}' when manual bundling is off");
5538 CURR_SLOT
.manual_bundling_off
= 1;
5539 md
.manual_bundling
= 0;
5545 /* Returns the next entry in the opcode table that matches the one in
5546 IDESC, and frees the entry in IDESC. If no matching entry is
5547 found, NULL is returned instead. */
5549 static struct ia64_opcode
*
5550 get_next_opcode (struct ia64_opcode
*idesc
)
5552 struct ia64_opcode
*next
= ia64_find_next_opcode (idesc
);
5553 ia64_free_opcode (idesc
);
5557 /* Parse the operands for the opcode and find the opcode variant that
5558 matches the specified operands, or NULL if no match is possible. */
5560 static struct ia64_opcode
*
5561 parse_operands (idesc
)
5562 struct ia64_opcode
*idesc
;
5564 int i
= 0, highest_unmatched_operand
, num_operands
= 0, num_outputs
= 0;
5565 int error_pos
, out_of_range_pos
, curr_out_of_range_pos
, sep
= 0;
5566 enum ia64_opnd expected_operand
= IA64_OPND_NIL
;
5567 enum operand_match_result result
;
5569 char *first_arg
= 0, *end
, *saved_input_pointer
;
5572 assert (strlen (idesc
->name
) <= 128);
5574 strcpy (mnemonic
, idesc
->name
);
5575 if (idesc
->operands
[2] == IA64_OPND_SOF
)
5577 /* To make the common idiom "alloc loc?=ar.pfs,0,1,0,0" work, we
5578 can't parse the first operand until we have parsed the
5579 remaining operands of the "alloc" instruction. */
5581 first_arg
= input_line_pointer
;
5582 end
= strchr (input_line_pointer
, '=');
5585 as_bad ("Expected separator `='");
5588 input_line_pointer
= end
+ 1;
5593 for (; i
< NELEMS (CURR_SLOT
.opnd
); ++i
)
5595 sep
= parse_operand (CURR_SLOT
.opnd
+ i
);
5596 if (CURR_SLOT
.opnd
[i
].X_op
== O_absent
)
5601 if (sep
!= '=' && sep
!= ',')
5606 if (num_outputs
> 0)
5607 as_bad ("Duplicate equal sign (=) in instruction");
5609 num_outputs
= i
+ 1;
5614 as_bad ("Illegal operand separator `%c'", sep
);
5618 if (idesc
->operands
[2] == IA64_OPND_SOF
)
5620 /* map alloc r1=ar.pfs,i,l,o,r to alloc r1=ar.pfs,(i+l+o),(i+l),r */
5621 know (strcmp (idesc
->name
, "alloc") == 0);
5622 if (num_operands
== 5 /* first_arg not included in this count! */
5623 && CURR_SLOT
.opnd
[2].X_op
== O_constant
5624 && CURR_SLOT
.opnd
[3].X_op
== O_constant
5625 && CURR_SLOT
.opnd
[4].X_op
== O_constant
5626 && CURR_SLOT
.opnd
[5].X_op
== O_constant
)
5628 sof
= set_regstack (CURR_SLOT
.opnd
[2].X_add_number
,
5629 CURR_SLOT
.opnd
[3].X_add_number
,
5630 CURR_SLOT
.opnd
[4].X_add_number
,
5631 CURR_SLOT
.opnd
[5].X_add_number
);
5633 /* now we can parse the first arg: */
5634 saved_input_pointer
= input_line_pointer
;
5635 input_line_pointer
= first_arg
;
5636 sep
= parse_operand (CURR_SLOT
.opnd
+ 0);
5638 --num_outputs
; /* force error */
5639 input_line_pointer
= saved_input_pointer
;
5641 CURR_SLOT
.opnd
[2].X_add_number
= sof
;
5642 CURR_SLOT
.opnd
[3].X_add_number
5643 = sof
- CURR_SLOT
.opnd
[4].X_add_number
;
5644 CURR_SLOT
.opnd
[4] = CURR_SLOT
.opnd
[5];
5648 highest_unmatched_operand
= 0;
5649 curr_out_of_range_pos
= -1;
5651 expected_operand
= idesc
->operands
[0];
5652 for (; idesc
; idesc
= get_next_opcode (idesc
))
5654 if (num_outputs
!= idesc
->num_outputs
)
5655 continue; /* mismatch in # of outputs */
5657 CURR_SLOT
.num_fixups
= 0;
5659 /* Try to match all operands. If we see an out-of-range operand,
5660 then continue trying to match the rest of the operands, since if
5661 the rest match, then this idesc will give the best error message. */
5663 out_of_range_pos
= -1;
5664 for (i
= 0; i
< num_operands
&& idesc
->operands
[i
]; ++i
)
5666 result
= operand_match (idesc
, i
, CURR_SLOT
.opnd
+ i
);
5667 if (result
!= OPERAND_MATCH
)
5669 if (result
!= OPERAND_OUT_OF_RANGE
)
5671 if (out_of_range_pos
< 0)
5672 /* remember position of the first out-of-range operand: */
5673 out_of_range_pos
= i
;
5677 /* If we did not match all operands, or if at least one operand was
5678 out-of-range, then this idesc does not match. Keep track of which
5679 idesc matched the most operands before failing. If we have two
5680 idescs that failed at the same position, and one had an out-of-range
5681 operand, then prefer the out-of-range operand. Thus if we have
5682 "add r0=0x1000000,r1" we get an error saying the constant is out
5683 of range instead of an error saying that the constant should have been
5686 if (i
!= num_operands
|| out_of_range_pos
>= 0)
5688 if (i
> highest_unmatched_operand
5689 || (i
== highest_unmatched_operand
5690 && out_of_range_pos
> curr_out_of_range_pos
))
5692 highest_unmatched_operand
= i
;
5693 if (out_of_range_pos
>= 0)
5695 expected_operand
= idesc
->operands
[out_of_range_pos
];
5696 error_pos
= out_of_range_pos
;
5700 expected_operand
= idesc
->operands
[i
];
5703 curr_out_of_range_pos
= out_of_range_pos
;
5708 if (num_operands
< NELEMS (idesc
->operands
)
5709 && idesc
->operands
[num_operands
])
5710 continue; /* mismatch in number of arguments */
5716 if (expected_operand
)
5717 as_bad ("Operand %u of `%s' should be %s",
5718 error_pos
+ 1, mnemonic
,
5719 elf64_ia64_operands
[expected_operand
].desc
);
5721 as_bad ("Operand mismatch");
5727 /* Keep track of state necessary to determine whether a NOP is necessary
5728 to avoid an erratum in A and B step Itanium chips, and return 1 if we
5729 detect a case where additional NOPs may be necessary. */
5731 errata_nop_necessary_p (slot
, insn_unit
)
5733 enum ia64_unit insn_unit
;
5736 struct group
*this_group
= md
.last_groups
+ md
.group_idx
;
5737 struct group
*prev_group
= md
.last_groups
+ (md
.group_idx
+ 2) % 3;
5738 struct ia64_opcode
*idesc
= slot
->idesc
;
5740 /* Test whether this could be the first insn in a problematic sequence. */
5741 if (insn_unit
== IA64_UNIT_F
)
5743 for (i
= 0; i
< idesc
->num_outputs
; i
++)
5744 if (idesc
->operands
[i
] == IA64_OPND_P1
5745 || idesc
->operands
[i
] == IA64_OPND_P2
)
5747 int regno
= slot
->opnd
[i
].X_add_number
- REG_P
;
5748 /* Ignore invalid operands; they generate errors elsewhere. */
5751 this_group
->p_reg_set
[regno
] = 1;
5755 /* Test whether this could be the second insn in a problematic sequence. */
5756 if (insn_unit
== IA64_UNIT_M
&& slot
->qp_regno
> 0
5757 && prev_group
->p_reg_set
[slot
->qp_regno
])
5759 for (i
= 0; i
< idesc
->num_outputs
; i
++)
5760 if (idesc
->operands
[i
] == IA64_OPND_R1
5761 || idesc
->operands
[i
] == IA64_OPND_R2
5762 || idesc
->operands
[i
] == IA64_OPND_R3
)
5764 int regno
= slot
->opnd
[i
].X_add_number
- REG_GR
;
5765 /* Ignore invalid operands; they generate errors elsewhere. */
5768 if (strncmp (idesc
->name
, "add", 3) != 0
5769 && strncmp (idesc
->name
, "sub", 3) != 0
5770 && strncmp (idesc
->name
, "shladd", 6) != 0
5771 && (idesc
->flags
& IA64_OPCODE_POSTINC
) == 0)
5772 this_group
->g_reg_set_conditionally
[regno
] = 1;
5776 /* Test whether this could be the third insn in a problematic sequence. */
5777 for (i
= 0; i
< NELEMS (idesc
->operands
) && idesc
->operands
[i
]; i
++)
5779 if (/* For fc, ptc, ptr, tak, thash, tpa, ttag, probe, ptr, ptc. */
5780 idesc
->operands
[i
] == IA64_OPND_R3
5781 /* For mov indirect. */
5782 || idesc
->operands
[i
] == IA64_OPND_RR_R3
5783 || idesc
->operands
[i
] == IA64_OPND_DBR_R3
5784 || idesc
->operands
[i
] == IA64_OPND_IBR_R3
5785 || idesc
->operands
[i
] == IA64_OPND_PKR_R3
5786 || idesc
->operands
[i
] == IA64_OPND_PMC_R3
5787 || idesc
->operands
[i
] == IA64_OPND_PMD_R3
5788 || idesc
->operands
[i
] == IA64_OPND_MSR_R3
5789 || idesc
->operands
[i
] == IA64_OPND_CPUID_R3
5791 || idesc
->operands
[i
] == IA64_OPND_ITR_R3
5792 || idesc
->operands
[i
] == IA64_OPND_DTR_R3
5793 /* Normal memory addresses (load, store, xchg, cmpxchg, etc.). */
5794 || idesc
->operands
[i
] == IA64_OPND_MR3
)
5796 int regno
= slot
->opnd
[i
].X_add_number
- REG_GR
;
5797 /* Ignore invalid operands; they generate errors elsewhere. */
5800 if (idesc
->operands
[i
] == IA64_OPND_R3
)
5802 if (strcmp (idesc
->name
, "fc") != 0
5803 && strcmp (idesc
->name
, "tak") != 0
5804 && strcmp (idesc
->name
, "thash") != 0
5805 && strcmp (idesc
->name
, "tpa") != 0
5806 && strcmp (idesc
->name
, "ttag") != 0
5807 && strncmp (idesc
->name
, "ptr", 3) != 0
5808 && strncmp (idesc
->name
, "ptc", 3) != 0
5809 && strncmp (idesc
->name
, "probe", 5) != 0)
5812 if (prev_group
->g_reg_set_conditionally
[regno
])
5820 build_insn (slot
, insnp
)
5824 const struct ia64_operand
*odesc
, *o2desc
;
5825 struct ia64_opcode
*idesc
= slot
->idesc
;
5826 bfd_signed_vma insn
, val
;
5830 insn
= idesc
->opcode
| slot
->qp_regno
;
5832 for (i
= 0; i
< NELEMS (idesc
->operands
) && idesc
->operands
[i
]; ++i
)
5834 if (slot
->opnd
[i
].X_op
== O_register
5835 || slot
->opnd
[i
].X_op
== O_constant
5836 || slot
->opnd
[i
].X_op
== O_index
)
5837 val
= slot
->opnd
[i
].X_add_number
;
5838 else if (slot
->opnd
[i
].X_op
== O_big
)
5840 /* This must be the value 0x10000000000000000. */
5841 assert (idesc
->operands
[i
] == IA64_OPND_IMM8M1U8
);
5847 switch (idesc
->operands
[i
])
5849 case IA64_OPND_IMMU64
:
5850 *insnp
++ = (val
>> 22) & 0x1ffffffffffLL
;
5851 insn
|= (((val
& 0x7f) << 13) | (((val
>> 7) & 0x1ff) << 27)
5852 | (((val
>> 16) & 0x1f) << 22) | (((val
>> 21) & 0x1) << 21)
5853 | (((val
>> 63) & 0x1) << 36));
5856 case IA64_OPND_IMMU62
:
5857 val
&= 0x3fffffffffffffffULL
;
5858 if (val
!= slot
->opnd
[i
].X_add_number
)
5859 as_warn (_("Value truncated to 62 bits"));
5860 *insnp
++ = (val
>> 21) & 0x1ffffffffffLL
;
5861 insn
|= (((val
& 0xfffff) << 6) | (((val
>> 20) & 0x1) << 36));
5864 case IA64_OPND_TGT64
:
5866 *insnp
++ = ((val
>> 20) & 0x7fffffffffLL
) << 2;
5867 insn
|= ((((val
>> 59) & 0x1) << 36)
5868 | (((val
>> 0) & 0xfffff) << 13));
5899 case IA64_OPND_R3_2
:
5900 case IA64_OPND_CPUID_R3
:
5901 case IA64_OPND_DBR_R3
:
5902 case IA64_OPND_DTR_R3
:
5903 case IA64_OPND_ITR_R3
:
5904 case IA64_OPND_IBR_R3
:
5906 case IA64_OPND_MSR_R3
:
5907 case IA64_OPND_PKR_R3
:
5908 case IA64_OPND_PMC_R3
:
5909 case IA64_OPND_PMD_R3
:
5910 case IA64_OPND_RR_R3
:
5918 odesc
= elf64_ia64_operands
+ idesc
->operands
[i
];
5919 err
= (*odesc
->insert
) (odesc
, val
, &insn
);
5921 as_bad_where (slot
->src_file
, slot
->src_line
,
5922 "Bad operand value: %s", err
);
5923 if (idesc
->flags
& IA64_OPCODE_PSEUDO
)
5925 if ((idesc
->flags
& IA64_OPCODE_F2_EQ_F3
)
5926 && odesc
== elf64_ia64_operands
+ IA64_OPND_F3
)
5928 o2desc
= elf64_ia64_operands
+ IA64_OPND_F2
;
5929 (*o2desc
->insert
) (o2desc
, val
, &insn
);
5931 if ((idesc
->flags
& IA64_OPCODE_LEN_EQ_64MCNT
)
5932 && (odesc
== elf64_ia64_operands
+ IA64_OPND_CPOS6a
5933 || odesc
== elf64_ia64_operands
+ IA64_OPND_POS6
))
5935 o2desc
= elf64_ia64_operands
+ IA64_OPND_LEN6
;
5936 (*o2desc
->insert
) (o2desc
, 64 - val
, &insn
);
5946 unsigned int manual_bundling_on
= 0, manual_bundling_off
= 0;
5947 unsigned int manual_bundling
= 0;
5948 enum ia64_unit required_unit
, insn_unit
= 0;
5949 enum ia64_insn_type type
[3], insn_type
;
5950 unsigned int template, orig_template
;
5951 bfd_vma insn
[3] = { -1, -1, -1 };
5952 struct ia64_opcode
*idesc
;
5953 int end_of_insn_group
= 0, user_template
= -1;
5954 int n
, i
, j
, first
, curr
;
5956 bfd_vma t0
= 0, t1
= 0;
5957 struct label_fix
*lfix
;
5958 struct insn_fix
*ifix
;
5963 first
= (md
.curr_slot
+ NUM_SLOTS
- md
.num_slots_in_use
) % NUM_SLOTS
;
5964 know (first
>= 0 & first
< NUM_SLOTS
);
5965 n
= MIN (3, md
.num_slots_in_use
);
5967 /* Determine template: user user_template if specified, best match
5970 if (md
.slot
[first
].user_template
>= 0)
5971 user_template
= template = md
.slot
[first
].user_template
;
5974 /* Auto select appropriate template. */
5975 memset (type
, 0, sizeof (type
));
5977 for (i
= 0; i
< n
; ++i
)
5979 if (md
.slot
[curr
].label_fixups
&& i
!= 0)
5981 type
[i
] = md
.slot
[curr
].idesc
->type
;
5982 curr
= (curr
+ 1) % NUM_SLOTS
;
5984 template = best_template
[type
[0]][type
[1]][type
[2]];
5987 /* initialize instructions with appropriate nops: */
5988 for (i
= 0; i
< 3; ++i
)
5989 insn
[i
] = nop
[ia64_templ_desc
[template].exec_unit
[i
]];
5993 /* now fill in slots with as many insns as possible: */
5995 idesc
= md
.slot
[curr
].idesc
;
5996 end_of_insn_group
= 0;
5997 for (i
= 0; i
< 3 && md
.num_slots_in_use
> 0; ++i
)
5999 /* Set the slot number for prologue/body records now as those
6000 refer to the current point, not the point after the
6001 instruction has been issued: */
6002 /* Don't try to delete prologue/body records here, as that will cause
6003 them to also be deleted from the master list of unwind records. */
6004 for (ptr
= md
.slot
[curr
].unwind_record
; ptr
; ptr
= ptr
->next
)
6005 if (ptr
->r
.type
== prologue
|| ptr
->r
.type
== prologue_gr
6006 || ptr
->r
.type
== body
)
6008 ptr
->slot_number
= (unsigned long) f
+ i
;
6009 ptr
->slot_frag
= frag_now
;
6012 if (idesc
->flags
& IA64_OPCODE_SLOT2
)
6014 if (manual_bundling
&& i
!= 2)
6015 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6016 "`%s' must be last in bundle", idesc
->name
);
6020 if (idesc
->flags
& IA64_OPCODE_LAST
)
6023 unsigned int required_template
;
6025 /* If we need a stop bit after an M slot, our only choice is
6026 template 5 (M;;MI). If we need a stop bit after a B
6027 slot, our only choice is to place it at the end of the
6028 bundle, because the only available templates are MIB,
6029 MBB, BBB, MMB, and MFB. We don't handle anything other
6030 than M and B slots because these are the only kind of
6031 instructions that can have the IA64_OPCODE_LAST bit set. */
6032 required_template
= template;
6033 switch (idesc
->type
)
6037 required_template
= 5;
6045 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6046 "Internal error: don't know how to force %s to end"
6047 "of instruction group", idesc
->name
);
6051 if (manual_bundling
&& i
!= required_slot
)
6052 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6053 "`%s' must be last in instruction group",
6055 if (required_slot
< i
)
6056 /* Can't fit this instruction. */
6060 if (required_template
!= template)
6062 /* If we switch the template, we need to reset the NOPs
6063 after slot i. The slot-types of the instructions ahead
6064 of i never change, so we don't need to worry about
6065 changing NOPs in front of this slot. */
6066 for (j
= i
; j
< 3; ++j
)
6067 insn
[j
] = nop
[ia64_templ_desc
[required_template
].exec_unit
[j
]];
6069 template = required_template
;
6071 if (curr
!= first
&& md
.slot
[curr
].label_fixups
)
6073 if (manual_bundling_on
)
6074 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6075 "Label must be first in a bundle");
6076 /* This insn must go into the first slot of a bundle. */
6080 manual_bundling_on
= md
.slot
[curr
].manual_bundling_on
;
6081 manual_bundling_off
= md
.slot
[curr
].manual_bundling_off
;
6083 if (manual_bundling_on
)
6086 manual_bundling
= 1;
6088 break; /* need to start a new bundle */
6091 if (end_of_insn_group
&& md
.num_slots_in_use
>= 1)
6093 /* We need an instruction group boundary in the middle of a
6094 bundle. See if we can switch to an other template with
6095 an appropriate boundary. */
6097 orig_template
= template;
6098 if (i
== 1 && (user_template
== 4
6099 || (user_template
< 0
6100 && (ia64_templ_desc
[template].exec_unit
[0]
6104 end_of_insn_group
= 0;
6106 else if (i
== 2 && (user_template
== 0
6107 || (user_template
< 0
6108 && (ia64_templ_desc
[template].exec_unit
[1]
6110 /* This test makes sure we don't switch the template if
6111 the next instruction is one that needs to be first in
6112 an instruction group. Since all those instructions are
6113 in the M group, there is no way such an instruction can
6114 fit in this bundle even if we switch the template. The
6115 reason we have to check for this is that otherwise we
6116 may end up generating "MI;;I M.." which has the deadly
6117 effect that the second M instruction is no longer the
6118 first in the bundle! --davidm 99/12/16 */
6119 && (idesc
->flags
& IA64_OPCODE_FIRST
) == 0)
6122 end_of_insn_group
= 0;
6124 else if (curr
!= first
)
6125 /* can't fit this insn */
6128 if (template != orig_template
)
6129 /* if we switch the template, we need to reset the NOPs
6130 after slot i. The slot-types of the instructions ahead
6131 of i never change, so we don't need to worry about
6132 changing NOPs in front of this slot. */
6133 for (j
= i
; j
< 3; ++j
)
6134 insn
[j
] = nop
[ia64_templ_desc
[template].exec_unit
[j
]];
6136 required_unit
= ia64_templ_desc
[template].exec_unit
[i
];
6138 /* resolve dynamic opcodes such as "break" and "nop": */
6139 if (idesc
->type
== IA64_TYPE_DYN
)
6141 if ((strcmp (idesc
->name
, "nop") == 0)
6142 || (strcmp (idesc
->name
, "break") == 0))
6143 insn_unit
= required_unit
;
6144 else if (strcmp (idesc
->name
, "chk.s") == 0)
6146 insn_unit
= IA64_UNIT_M
;
6147 if (required_unit
== IA64_UNIT_I
)
6148 insn_unit
= IA64_UNIT_I
;
6151 as_fatal ("emit_one_bundle: unexpected dynamic op");
6153 sprintf (mnemonic
, "%s.%c", idesc
->name
, "?imbf??"[insn_unit
]);
6154 ia64_free_opcode (idesc
);
6155 md
.slot
[curr
].idesc
= idesc
= ia64_find_opcode (mnemonic
);
6157 know (!idesc
->next
); /* no resolved dynamic ops have collisions */
6162 insn_type
= idesc
->type
;
6163 insn_unit
= IA64_UNIT_NIL
;
6167 if (required_unit
== IA64_UNIT_I
|| required_unit
== IA64_UNIT_M
)
6168 insn_unit
= required_unit
;
6170 case IA64_TYPE_X
: insn_unit
= IA64_UNIT_L
; break;
6171 case IA64_TYPE_I
: insn_unit
= IA64_UNIT_I
; break;
6172 case IA64_TYPE_M
: insn_unit
= IA64_UNIT_M
; break;
6173 case IA64_TYPE_B
: insn_unit
= IA64_UNIT_B
; break;
6174 case IA64_TYPE_F
: insn_unit
= IA64_UNIT_F
; break;
6179 if (insn_unit
!= required_unit
)
6181 if (required_unit
== IA64_UNIT_L
6182 && insn_unit
== IA64_UNIT_I
6183 && !(idesc
->flags
& IA64_OPCODE_X_IN_MLX
))
6185 /* we got ourselves an MLX template but the current
6186 instruction isn't an X-unit, or an I-unit instruction
6187 that can go into the X slot of an MLX template. Duh. */
6188 if (md
.num_slots_in_use
>= NUM_SLOTS
)
6190 as_bad_where (md
.slot
[curr
].src_file
,
6191 md
.slot
[curr
].src_line
,
6192 "`%s' can't go in X slot of "
6193 "MLX template", idesc
->name
);
6194 /* drop this insn so we don't livelock: */
6195 --md
.num_slots_in_use
;
6199 continue; /* try next slot */
6205 addr
= frag_now
->fr_address
+ frag_now_fix () - 16 + i
;
6206 dwarf2_gen_line_info (addr
, &md
.slot
[curr
].debug_line
);
6209 if (errata_nop_necessary_p (md
.slot
+ curr
, insn_unit
))
6210 as_warn (_("Additional NOP may be necessary to workaround Itanium processor A/B step errata"));
6212 build_insn (md
.slot
+ curr
, insn
+ i
);
6214 /* Set slot counts for non prologue/body unwind records. */
6215 for (ptr
= md
.slot
[curr
].unwind_record
; ptr
; ptr
= ptr
->next
)
6216 if (ptr
->r
.type
!= prologue
&& ptr
->r
.type
!= prologue_gr
6217 && ptr
->r
.type
!= body
)
6219 ptr
->slot_number
= (unsigned long) f
+ i
;
6220 ptr
->slot_frag
= frag_now
;
6222 md
.slot
[curr
].unwind_record
= NULL
;
6224 if (required_unit
== IA64_UNIT_L
)
6227 /* skip one slot for long/X-unit instructions */
6230 --md
.num_slots_in_use
;
6232 /* now is a good time to fix up the labels for this insn: */
6233 for (lfix
= md
.slot
[curr
].label_fixups
; lfix
; lfix
= lfix
->next
)
6235 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16);
6236 symbol_set_frag (lfix
->sym
, frag_now
);
6238 /* and fix up the tags also. */
6239 for (lfix
= md
.slot
[curr
].tag_fixups
; lfix
; lfix
= lfix
->next
)
6241 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16 + i
);
6242 symbol_set_frag (lfix
->sym
, frag_now
);
6245 for (j
= 0; j
< md
.slot
[curr
].num_fixups
; ++j
)
6247 ifix
= md
.slot
[curr
].fixup
+ j
;
6248 fix
= fix_new_exp (frag_now
, frag_now_fix () - 16 + i
, 8,
6249 &ifix
->expr
, ifix
->is_pcrel
, ifix
->code
);
6250 fix
->tc_fix_data
.opnd
= ifix
->opnd
;
6251 fix
->fx_plt
= (fix
->fx_r_type
== BFD_RELOC_IA64_PLTOFF22
);
6252 fix
->fx_file
= md
.slot
[curr
].src_file
;
6253 fix
->fx_line
= md
.slot
[curr
].src_line
;
6256 end_of_insn_group
= md
.slot
[curr
].end_of_insn_group
;
6258 if (end_of_insn_group
)
6260 md
.group_idx
= (md
.group_idx
+ 1) % 3;
6261 memset (md
.last_groups
+ md
.group_idx
, 0, sizeof md
.last_groups
[0]);
6265 ia64_free_opcode (md
.slot
[curr
].idesc
);
6266 memset (md
.slot
+ curr
, 0, sizeof (md
.slot
[curr
]));
6267 md
.slot
[curr
].user_template
= -1;
6269 if (manual_bundling_off
)
6271 manual_bundling
= 0;
6274 curr
= (curr
+ 1) % NUM_SLOTS
;
6275 idesc
= md
.slot
[curr
].idesc
;
6277 if (manual_bundling
)
6279 if (md
.num_slots_in_use
> 0)
6280 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6281 "`%s' does not fit into %s template",
6282 idesc
->name
, ia64_templ_desc
[template].name
);
6284 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6285 "Missing '}' at end of file");
6287 know (md
.num_slots_in_use
< NUM_SLOTS
);
6289 t0
= end_of_insn_group
| (template << 1) | (insn
[0] << 5) | (insn
[1] << 46);
6290 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
6292 number_to_chars_littleendian (f
+ 0, t0
, 8);
6293 number_to_chars_littleendian (f
+ 8, t1
, 8);
6295 unwind
.next_slot_number
= (unsigned long) f
+ 16;
6296 unwind
.next_slot_frag
= frag_now
;
6300 md_parse_option (c
, arg
)
6307 /* Switches from the Intel assembler. */
6309 if (strcmp (arg
, "ilp64") == 0
6310 || strcmp (arg
, "lp64") == 0
6311 || strcmp (arg
, "p64") == 0)
6313 md
.flags
|= EF_IA_64_ABI64
;
6315 else if (strcmp (arg
, "ilp32") == 0)
6317 md
.flags
&= ~EF_IA_64_ABI64
;
6319 else if (strcmp (arg
, "le") == 0)
6321 md
.flags
&= ~EF_IA_64_BE
;
6323 else if (strcmp (arg
, "be") == 0)
6325 md
.flags
|= EF_IA_64_BE
;
6332 if (strcmp (arg
, "so") == 0)
6334 /* Suppress signon message. */
6336 else if (strcmp (arg
, "pi") == 0)
6338 /* Reject privileged instructions. FIXME */
6340 else if (strcmp (arg
, "us") == 0)
6342 /* Allow union of signed and unsigned range. FIXME */
6344 else if (strcmp (arg
, "close_fcalls") == 0)
6346 /* Do not resolve global function calls. */
6353 /* temp[="prefix"] Insert temporary labels into the object file
6354 symbol table prefixed by "prefix".
6355 Default prefix is ":temp:".
6360 /* indirect=<tgt> Assume unannotated indirect branches behavior
6361 according to <tgt> --
6362 exit: branch out from the current context (default)
6363 labels: all labels in context may be branch targets
6365 if (strncmp (arg
, "indirect=", 9) != 0)
6370 /* -X conflicts with an ignored option, use -x instead */
6372 if (!arg
|| strcmp (arg
, "explicit") == 0)
6374 /* set default mode to explicit */
6375 md
.default_explicit_mode
= 1;
6378 else if (strcmp (arg
, "auto") == 0)
6380 md
.default_explicit_mode
= 0;
6382 else if (strcmp (arg
, "debug") == 0)
6386 else if (strcmp (arg
, "debugx") == 0)
6388 md
.default_explicit_mode
= 1;
6393 as_bad (_("Unrecognized option '-x%s'"), arg
);
6398 /* nops Print nops statistics. */
6401 /* GNU specific switches for gcc. */
6402 case OPTION_MCONSTANT_GP
:
6403 md
.flags
|= EF_IA_64_CONS_GP
;
6406 case OPTION_MAUTO_PIC
:
6407 md
.flags
|= EF_IA_64_NOFUNCDESC_CONS_GP
;
6418 md_show_usage (stream
)
6423 --mconstant-gp mark output file as using the constant-GP model\n\
6424 (sets ELF header flag EF_IA_64_CONS_GP)\n\
6425 --mauto-pic mark output file as using the constant-GP model\n\
6426 without function descriptors (sets ELF header flag\n\
6427 EF_IA_64_NOFUNCDESC_CONS_GP)\n\
6428 -milp32|-milp64|-mlp64|-mp64 select data model (default -mlp64)\n\
6429 -mle | -mbe select little- or big-endian byte order (default -mle)\n\
6430 -x | -xexplicit turn on dependency violation checking (default)\n\
6431 -xauto automagically remove dependency violations\n\
6432 -xdebug debug dependency violation checker\n"),
6437 ia64_after_parse_args ()
6439 if (debug_type
== DEBUG_STABS
)
6440 as_fatal (_("--gstabs is not supported for ia64"));
6443 /* Return true if TYPE fits in TEMPL at SLOT. */
6446 match (int templ
, int type
, int slot
)
6448 enum ia64_unit unit
;
6451 unit
= ia64_templ_desc
[templ
].exec_unit
[slot
];
6454 case IA64_TYPE_DYN
: result
= 1; break; /* for nop and break */
6456 result
= (unit
== IA64_UNIT_I
|| unit
== IA64_UNIT_M
);
6458 case IA64_TYPE_X
: result
= (unit
== IA64_UNIT_L
); break;
6459 case IA64_TYPE_I
: result
= (unit
== IA64_UNIT_I
); break;
6460 case IA64_TYPE_M
: result
= (unit
== IA64_UNIT_M
); break;
6461 case IA64_TYPE_B
: result
= (unit
== IA64_UNIT_B
); break;
6462 case IA64_TYPE_F
: result
= (unit
== IA64_UNIT_F
); break;
6463 default: result
= 0; break;
6468 /* Add a bit of extra goodness if a nop of type F or B would fit
6469 in TEMPL at SLOT. */
6472 extra_goodness (int templ
, int slot
)
6474 if (slot
== 1 && match (templ
, IA64_TYPE_F
, slot
))
6476 if (slot
== 2 && match (templ
, IA64_TYPE_B
, slot
))
6481 /* This function is called once, at assembler startup time. It sets
6482 up all the tables, etc. that the MD part of the assembler will need
6483 that can be determined before arguments are parsed. */
6487 int i
, j
, k
, t
, total
, ar_base
, cr_base
, goodness
, best
, regnum
, ok
;
6492 md
.explicit_mode
= md
.default_explicit_mode
;
6494 bfd_set_section_alignment (stdoutput
, text_section
, 4);
6496 target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
6497 pseudo_func
[FUNC_FPTR_RELATIVE
].u
.sym
=
6498 symbol_new (".<fptr>", undefined_section
, FUNC_FPTR_RELATIVE
,
6499 &zero_address_frag
);
6501 pseudo_func
[FUNC_GP_RELATIVE
].u
.sym
=
6502 symbol_new (".<gprel>", undefined_section
, FUNC_GP_RELATIVE
,
6503 &zero_address_frag
);
6505 pseudo_func
[FUNC_LT_RELATIVE
].u
.sym
=
6506 symbol_new (".<ltoff>", undefined_section
, FUNC_LT_RELATIVE
,
6507 &zero_address_frag
);
6509 pseudo_func
[FUNC_PC_RELATIVE
].u
.sym
=
6510 symbol_new (".<pcrel>", undefined_section
, FUNC_PC_RELATIVE
,
6511 &zero_address_frag
);
6513 pseudo_func
[FUNC_PLT_RELATIVE
].u
.sym
=
6514 symbol_new (".<pltoff>", undefined_section
, FUNC_PLT_RELATIVE
,
6515 &zero_address_frag
);
6517 pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
=
6518 symbol_new (".<secrel>", undefined_section
, FUNC_SEC_RELATIVE
,
6519 &zero_address_frag
);
6521 pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
=
6522 symbol_new (".<segrel>", undefined_section
, FUNC_SEG_RELATIVE
,
6523 &zero_address_frag
);
6525 pseudo_func
[FUNC_LTV_RELATIVE
].u
.sym
=
6526 symbol_new (".<ltv>", undefined_section
, FUNC_LTV_RELATIVE
,
6527 &zero_address_frag
);
6529 pseudo_func
[FUNC_LT_FPTR_RELATIVE
].u
.sym
=
6530 symbol_new (".<ltoff.fptr>", undefined_section
, FUNC_LT_FPTR_RELATIVE
,
6531 &zero_address_frag
);
6533 pseudo_func
[FUNC_IPLT_RELOC
].u
.sym
=
6534 symbol_new (".<iplt>", undefined_section
, FUNC_IPLT_RELOC
,
6535 &zero_address_frag
);
6537 /* Compute the table of best templates. We compute goodness as a
6538 base 4 value, in which each match counts for 3, each F counts
6539 for 2, each B counts for 1. This should maximize the number of
6540 F and B nops in the chosen bundles, which is good because these
6541 pipelines are least likely to be overcommitted. */
6542 for (i
= 0; i
< IA64_NUM_TYPES
; ++i
)
6543 for (j
= 0; j
< IA64_NUM_TYPES
; ++j
)
6544 for (k
= 0; k
< IA64_NUM_TYPES
; ++k
)
6547 for (t
= 0; t
< NELEMS (ia64_templ_desc
); ++t
)
6550 if (match (t
, i
, 0))
6552 if (match (t
, j
, 1))
6554 if (match (t
, k
, 2))
6555 goodness
= 3 + 3 + 3;
6557 goodness
= 3 + 3 + extra_goodness (t
, 2);
6559 else if (match (t
, j
, 2))
6560 goodness
= 3 + 3 + extra_goodness (t
, 1);
6564 goodness
+= extra_goodness (t
, 1);
6565 goodness
+= extra_goodness (t
, 2);
6568 else if (match (t
, i
, 1))
6570 if (match (t
, j
, 2))
6573 goodness
= 3 + extra_goodness (t
, 2);
6575 else if (match (t
, i
, 2))
6576 goodness
= 3 + extra_goodness (t
, 1);
6578 if (goodness
> best
)
6581 best_template
[i
][j
][k
] = t
;
6586 for (i
= 0; i
< NUM_SLOTS
; ++i
)
6587 md
.slot
[i
].user_template
= -1;
6589 md
.pseudo_hash
= hash_new ();
6590 for (i
= 0; i
< NELEMS (pseudo_opcode
); ++i
)
6592 err
= hash_insert (md
.pseudo_hash
, pseudo_opcode
[i
].name
,
6593 (void *) (pseudo_opcode
+ i
));
6595 as_fatal ("ia64.md_begin: can't hash `%s': %s",
6596 pseudo_opcode
[i
].name
, err
);
6599 md
.reg_hash
= hash_new ();
6600 md
.dynreg_hash
= hash_new ();
6601 md
.const_hash
= hash_new ();
6602 md
.entry_hash
= hash_new ();
6604 /* general registers: */
6607 for (i
= 0; i
< total
; ++i
)
6609 sprintf (name
, "r%d", i
- REG_GR
);
6610 md
.regsym
[i
] = declare_register (name
, i
);
6613 /* floating point registers: */
6615 for (; i
< total
; ++i
)
6617 sprintf (name
, "f%d", i
- REG_FR
);
6618 md
.regsym
[i
] = declare_register (name
, i
);
6621 /* application registers: */
6624 for (; i
< total
; ++i
)
6626 sprintf (name
, "ar%d", i
- REG_AR
);
6627 md
.regsym
[i
] = declare_register (name
, i
);
6630 /* control registers: */
6633 for (; i
< total
; ++i
)
6635 sprintf (name
, "cr%d", i
- REG_CR
);
6636 md
.regsym
[i
] = declare_register (name
, i
);
6639 /* predicate registers: */
6641 for (; i
< total
; ++i
)
6643 sprintf (name
, "p%d", i
- REG_P
);
6644 md
.regsym
[i
] = declare_register (name
, i
);
6647 /* branch registers: */
6649 for (; i
< total
; ++i
)
6651 sprintf (name
, "b%d", i
- REG_BR
);
6652 md
.regsym
[i
] = declare_register (name
, i
);
6655 md
.regsym
[REG_IP
] = declare_register ("ip", REG_IP
);
6656 md
.regsym
[REG_CFM
] = declare_register ("cfm", REG_CFM
);
6657 md
.regsym
[REG_PR
] = declare_register ("pr", REG_PR
);
6658 md
.regsym
[REG_PR_ROT
] = declare_register ("pr.rot", REG_PR_ROT
);
6659 md
.regsym
[REG_PSR
] = declare_register ("psr", REG_PSR
);
6660 md
.regsym
[REG_PSR_L
] = declare_register ("psr.l", REG_PSR_L
);
6661 md
.regsym
[REG_PSR_UM
] = declare_register ("psr.um", REG_PSR_UM
);
6663 for (i
= 0; i
< NELEMS (indirect_reg
); ++i
)
6665 regnum
= indirect_reg
[i
].regnum
;
6666 md
.regsym
[regnum
] = declare_register (indirect_reg
[i
].name
, regnum
);
6669 /* define synonyms for application registers: */
6670 for (i
= REG_AR
; i
< REG_AR
+ NELEMS (ar
); ++i
)
6671 md
.regsym
[i
] = declare_register (ar
[i
- REG_AR
].name
,
6672 REG_AR
+ ar
[i
- REG_AR
].regnum
);
6674 /* define synonyms for control registers: */
6675 for (i
= REG_CR
; i
< REG_CR
+ NELEMS (cr
); ++i
)
6676 md
.regsym
[i
] = declare_register (cr
[i
- REG_CR
].name
,
6677 REG_CR
+ cr
[i
- REG_CR
].regnum
);
6679 declare_register ("gp", REG_GR
+ 1);
6680 declare_register ("sp", REG_GR
+ 12);
6681 declare_register ("rp", REG_BR
+ 0);
6683 /* pseudo-registers used to specify unwind info: */
6684 declare_register ("psp", REG_PSP
);
6686 declare_register_set ("ret", 4, REG_GR
+ 8);
6687 declare_register_set ("farg", 8, REG_FR
+ 8);
6688 declare_register_set ("fret", 8, REG_FR
+ 8);
6690 for (i
= 0; i
< NELEMS (const_bits
); ++i
)
6692 err
= hash_insert (md
.const_hash
, const_bits
[i
].name
,
6693 (PTR
) (const_bits
+ i
));
6695 as_fatal ("Inserting \"%s\" into constant hash table failed: %s",
6699 /* Set the architecture and machine depending on defaults and command line
6701 if (md
.flags
& EF_IA_64_ABI64
)
6702 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf64
);
6704 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf32
);
6707 as_warn (_("Could not set architecture and machine"));
6709 /* Set the pointer size and pointer shift size depending on md.flags */
6711 if (md
.flags
& EF_IA_64_ABI64
)
6713 md
.pointer_size
= 8; /* pointers are 8 bytes */
6714 md
.pointer_size_shift
= 3; /* alignment is 8 bytes = 2^2 */
6718 md
.pointer_size
= 4; /* pointers are 4 bytes */
6719 md
.pointer_size_shift
= 2; /* alignment is 4 bytes = 2^2 */
6722 md
.mem_offset
.hint
= 0;
6725 md
.entry_labels
= NULL
;
6728 /* Set the elf type to 64 bit ABI by default. Cannot do this in md_begin
6729 because that is called after md_parse_option which is where we do the
6730 dynamic changing of md.flags based on -mlp64 or -milp32. Also, set the
6731 default endianness. */
6734 ia64_init (argc
, argv
)
6735 int argc ATTRIBUTE_UNUSED
;
6736 char **argv ATTRIBUTE_UNUSED
;
6738 md
.flags
= MD_FLAGS_DEFAULT
;
6741 /* Return a string for the target object file format. */
6744 ia64_target_format ()
6746 if (OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
6748 if (md
.flags
& EF_IA_64_BE
)
6750 if (md
.flags
& EF_IA_64_ABI64
)
6751 #if defined(TE_AIX50)
6752 return "elf64-ia64-aix-big";
6753 #elif defined(TE_HPUX)
6754 return "elf64-ia64-hpux-big";
6756 return "elf64-ia64-big";
6759 #if defined(TE_AIX50)
6760 return "elf32-ia64-aix-big";
6761 #elif defined(TE_HPUX)
6762 return "elf32-ia64-hpux-big";
6764 return "elf32-ia64-big";
6769 if (md
.flags
& EF_IA_64_ABI64
)
6771 return "elf64-ia64-aix-little";
6773 return "elf64-ia64-little";
6777 return "elf32-ia64-aix-little";
6779 return "elf32-ia64-little";
6784 return "unknown-format";
6788 ia64_end_of_source ()
6790 /* terminate insn group upon reaching end of file: */
6791 insn_group_break (1, 0, 0);
6793 /* emits slots we haven't written yet: */
6794 ia64_flush_insns ();
6796 bfd_set_private_flags (stdoutput
, md
.flags
);
6798 md
.mem_offset
.hint
= 0;
6804 if (md
.qp
.X_op
== O_register
)
6805 as_bad ("qualifying predicate not followed by instruction");
6806 md
.qp
.X_op
= O_absent
;
6808 if (ignore_input ())
6811 if (input_line_pointer
[0] == ';' && input_line_pointer
[-1] == ';')
6813 if (md
.detect_dv
&& !md
.explicit_mode
)
6814 as_warn (_("Explicit stops are ignored in auto mode"));
6816 insn_group_break (1, 0, 0);
6820 /* This is a hook for ia64_frob_label, so that it can distinguish tags from
6822 static int defining_tag
= 0;
6825 ia64_unrecognized_line (ch
)
6831 expression (&md
.qp
);
6832 if (*input_line_pointer
++ != ')')
6834 as_bad ("Expected ')'");
6837 if (md
.qp
.X_op
!= O_register
)
6839 as_bad ("Qualifying predicate expected");
6842 if (md
.qp
.X_add_number
< REG_P
|| md
.qp
.X_add_number
>= REG_P
+ 64)
6844 as_bad ("Predicate register expected");
6850 if (md
.manual_bundling
)
6851 as_warn ("Found '{' when manual bundling is already turned on");
6853 CURR_SLOT
.manual_bundling_on
= 1;
6854 md
.manual_bundling
= 1;
6856 /* Bundling is only acceptable in explicit mode
6857 or when in default automatic mode. */
6858 if (md
.detect_dv
&& !md
.explicit_mode
)
6860 if (!md
.mode_explicitly_set
6861 && !md
.default_explicit_mode
)
6864 as_warn (_("Found '{' after explicit switch to automatic mode"));
6869 if (!md
.manual_bundling
)
6870 as_warn ("Found '}' when manual bundling is off");
6872 PREV_SLOT
.manual_bundling_off
= 1;
6873 md
.manual_bundling
= 0;
6875 /* switch back to automatic mode, if applicable */
6878 && !md
.mode_explicitly_set
6879 && !md
.default_explicit_mode
)
6882 /* Allow '{' to follow on the same line. We also allow ";;", but that
6883 happens automatically because ';' is an end of line marker. */
6885 if (input_line_pointer
[0] == '{')
6887 input_line_pointer
++;
6888 return ia64_unrecognized_line ('{');
6891 demand_empty_rest_of_line ();
6901 if (md
.qp
.X_op
== O_register
)
6903 as_bad ("Tag must come before qualifying predicate.");
6907 /* This implements just enough of read_a_source_file in read.c to
6908 recognize labels. */
6909 if (is_name_beginner (*input_line_pointer
))
6911 s
= input_line_pointer
;
6912 c
= get_symbol_end ();
6914 else if (LOCAL_LABELS_FB
6915 && ISDIGIT (*input_line_pointer
))
6918 while (ISDIGIT (*input_line_pointer
))
6919 temp
= (temp
* 10) + *input_line_pointer
++ - '0';
6920 fb_label_instance_inc (temp
);
6921 s
= fb_label_name (temp
, 0);
6922 c
= *input_line_pointer
;
6931 /* Put ':' back for error messages' sake. */
6932 *input_line_pointer
++ = ':';
6933 as_bad ("Expected ':'");
6940 /* Put ':' back for error messages' sake. */
6941 *input_line_pointer
++ = ':';
6942 if (*input_line_pointer
++ != ']')
6944 as_bad ("Expected ']'");
6949 as_bad ("Tag name expected");
6959 /* Not a valid line. */
6964 ia64_frob_label (sym
)
6967 struct label_fix
*fix
;
6969 /* Tags need special handling since they are not bundle breaks like
6973 fix
= obstack_alloc (¬es
, sizeof (*fix
));
6975 fix
->next
= CURR_SLOT
.tag_fixups
;
6976 CURR_SLOT
.tag_fixups
= fix
;
6981 if (bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
6983 md
.last_text_seg
= now_seg
;
6984 fix
= obstack_alloc (¬es
, sizeof (*fix
));
6986 fix
->next
= CURR_SLOT
.label_fixups
;
6987 CURR_SLOT
.label_fixups
= fix
;
6989 /* Keep track of how many code entry points we've seen. */
6990 if (md
.path
== md
.maxpaths
)
6993 md
.entry_labels
= (const char **)
6994 xrealloc ((void *) md
.entry_labels
,
6995 md
.maxpaths
* sizeof (char *));
6997 md
.entry_labels
[md
.path
++] = S_GET_NAME (sym
);
7002 ia64_flush_pending_output ()
7004 if (!md
.keep_pending_output
7005 && bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7007 /* ??? This causes many unnecessary stop bits to be emitted.
7008 Unfortunately, it isn't clear if it is safe to remove this. */
7009 insn_group_break (1, 0, 0);
7010 ia64_flush_insns ();
7014 /* Do ia64-specific expression optimization. All that's done here is
7015 to transform index expressions that are either due to the indexing
7016 of rotating registers or due to the indexing of indirect register
7019 ia64_optimize_expr (l
, op
, r
)
7028 if (l
->X_op
== O_register
&& r
->X_op
== O_constant
)
7030 num_regs
= (l
->X_add_number
>> 16);
7031 if ((unsigned) r
->X_add_number
>= num_regs
)
7034 as_bad ("No current frame");
7036 as_bad ("Index out of range 0..%u", num_regs
- 1);
7037 r
->X_add_number
= 0;
7039 l
->X_add_number
= (l
->X_add_number
& 0xffff) + r
->X_add_number
;
7042 else if (l
->X_op
== O_register
&& r
->X_op
== O_register
)
7044 if (l
->X_add_number
< IND_CPUID
|| l
->X_add_number
> IND_RR
7045 || l
->X_add_number
== IND_MEM
)
7047 as_bad ("Indirect register set name expected");
7048 l
->X_add_number
= IND_CPUID
;
7051 l
->X_op_symbol
= md
.regsym
[l
->X_add_number
];
7052 l
->X_add_number
= r
->X_add_number
;
7060 ia64_parse_name (name
, e
)
7064 struct const_desc
*cdesc
;
7065 struct dynreg
*dr
= 0;
7066 unsigned int regnum
;
7070 /* first see if NAME is a known register name: */
7071 sym
= hash_find (md
.reg_hash
, name
);
7074 e
->X_op
= O_register
;
7075 e
->X_add_number
= S_GET_VALUE (sym
);
7079 cdesc
= hash_find (md
.const_hash
, name
);
7082 e
->X_op
= O_constant
;
7083 e
->X_add_number
= cdesc
->value
;
7087 /* check for inN, locN, or outN: */
7091 if (name
[1] == 'n' && ISDIGIT (name
[2]))
7099 if (name
[1] == 'o' && name
[2] == 'c' && ISDIGIT (name
[3]))
7107 if (name
[1] == 'u' && name
[2] == 't' && ISDIGIT (name
[3]))
7120 /* The name is inN, locN, or outN; parse the register number. */
7121 regnum
= strtoul (name
, &end
, 10);
7122 if (end
> name
&& *end
== '\0')
7124 if ((unsigned) regnum
>= dr
->num_regs
)
7127 as_bad ("No current frame");
7129 as_bad ("Register number out of range 0..%u",
7133 e
->X_op
= O_register
;
7134 e
->X_add_number
= dr
->base
+ regnum
;
7139 if ((dr
= hash_find (md
.dynreg_hash
, name
)))
7141 /* We've got ourselves the name of a rotating register set.
7142 Store the base register number in the low 16 bits of
7143 X_add_number and the size of the register set in the top 16
7145 e
->X_op
= O_register
;
7146 e
->X_add_number
= dr
->base
| (dr
->num_regs
<< 16);
7152 /* Remove the '#' suffix that indicates a symbol as opposed to a register. */
7155 ia64_canonicalize_symbol_name (name
)
7158 size_t len
= strlen (name
);
7159 if (len
> 1 && name
[len
- 1] == '#')
7160 name
[len
- 1] = '\0';
7164 /* Return true if idesc is a conditional branch instruction. This excludes
7165 the modulo scheduled branches, and br.ia. Mod-sched branches are excluded
7166 because they always read/write resources regardless of the value of the
7167 qualifying predicate. br.ia must always use p0, and hence is always
7168 taken. Thus this function returns true for branches which can fall
7169 through, and which use no resources if they do fall through. */
7172 is_conditional_branch (idesc
)
7173 struct ia64_opcode
*idesc
;
7175 /* br is a conditional branch. Everything that starts with br. except
7176 br.ia, br.c{loop,top,exit}, and br.w{top,exit} is a conditional branch.
7177 Everything that starts with brl is a conditional branch. */
7178 return (idesc
->name
[0] == 'b' && idesc
->name
[1] == 'r'
7179 && (idesc
->name
[2] == '\0'
7180 || (idesc
->name
[2] == '.' && idesc
->name
[3] != 'i'
7181 && idesc
->name
[3] != 'c' && idesc
->name
[3] != 'w')
7182 || idesc
->name
[2] == 'l'
7183 /* br.cond, br.call, br.clr */
7184 || (idesc
->name
[2] == '.' && idesc
->name
[3] == 'c'
7185 && (idesc
->name
[4] == 'a' || idesc
->name
[4] == 'o'
7186 || (idesc
->name
[4] == 'l' && idesc
->name
[5] == 'r')))));
7189 /* Return whether the given opcode is a taken branch. If there's any doubt,
7193 is_taken_branch (idesc
)
7194 struct ia64_opcode
*idesc
;
7196 return ((is_conditional_branch (idesc
) && CURR_SLOT
.qp_regno
== 0)
7197 || strncmp (idesc
->name
, "br.ia", 5) == 0);
7200 /* Return whether the given opcode is an interruption or rfi. If there's any
7201 doubt, returns zero. */
7204 is_interruption_or_rfi (idesc
)
7205 struct ia64_opcode
*idesc
;
7207 if (strcmp (idesc
->name
, "rfi") == 0)
7212 /* Returns the index of the given dependency in the opcode's list of chks, or
7213 -1 if there is no dependency. */
7216 depends_on (depind
, idesc
)
7218 struct ia64_opcode
*idesc
;
7221 const struct ia64_opcode_dependency
*dep
= idesc
->dependencies
;
7222 for (i
= 0; i
< dep
->nchks
; i
++)
7224 if (depind
== DEP (dep
->chks
[i
]))
7230 /* Determine a set of specific resources used for a particular resource
7231 class. Returns the number of specific resources identified For those
7232 cases which are not determinable statically, the resource returned is
7235 Meanings of value in 'NOTE':
7236 1) only read/write when the register number is explicitly encoded in the
7238 2) only read CFM when accessing a rotating GR, FR, or PR. mov pr only
7239 accesses CFM when qualifying predicate is in the rotating region.
7240 3) general register value is used to specify an indirect register; not
7241 determinable statically.
7242 4) only read the given resource when bits 7:0 of the indirect index
7243 register value does not match the register number of the resource; not
7244 determinable statically.
7245 5) all rules are implementation specific.
7246 6) only when both the index specified by the reader and the index specified
7247 by the writer have the same value in bits 63:61; not determinable
7249 7) only access the specified resource when the corresponding mask bit is
7251 8) PSR.dfh is only read when these insns reference FR32-127. PSR.dfl is
7252 only read when these insns reference FR2-31
7253 9) PSR.mfl is only written when these insns write FR2-31. PSR.mfh is only
7254 written when these insns write FR32-127
7255 10) The PSR.bn bit is only accessed when one of GR16-31 is specified in the
7257 11) The target predicates are written independently of PR[qp], but source
7258 registers are only read if PR[qp] is true. Since the state of PR[qp]
7259 cannot statically be determined, all source registers are marked used.
7260 12) This insn only reads the specified predicate register when that
7261 register is the PR[qp].
7262 13) This reference to ld-c only applies to teh GR whose value is loaded
7263 with data returned from memory, not the post-incremented address register.
7264 14) The RSE resource includes the implementation-specific RSE internal
7265 state resources. At least one (and possibly more) of these resources are
7266 read by each instruction listed in IC:rse-readers. At least one (and
7267 possibly more) of these resources are written by each insn listed in
7269 15+16) Represents reserved instructions, which the assembler does not
7272 Memory resources (i.e. locations in memory) are *not* marked or tracked by
7273 this code; there are no dependency violations based on memory access.
7276 #define MAX_SPECS 256
7281 specify_resource (dep
, idesc
, type
, specs
, note
, path
)
7282 const struct ia64_dependency
*dep
;
7283 struct ia64_opcode
*idesc
;
7284 int type
; /* is this a DV chk or a DV reg? */
7285 struct rsrc specs
[MAX_SPECS
]; /* returned specific resources */
7286 int note
; /* resource note for this insn's usage */
7287 int path
; /* which execution path to examine */
7294 if (dep
->mode
== IA64_DV_WAW
7295 || (dep
->mode
== IA64_DV_RAW
&& type
== DV_REG
)
7296 || (dep
->mode
== IA64_DV_WAR
&& type
== DV_CHK
))
7299 /* template for any resources we identify */
7300 tmpl
.dependency
= dep
;
7302 tmpl
.insn_srlz
= tmpl
.data_srlz
= 0;
7303 tmpl
.qp_regno
= CURR_SLOT
.qp_regno
;
7304 tmpl
.link_to_qp_branch
= 1;
7305 tmpl
.mem_offset
.hint
= 0;
7308 tmpl
.cmp_type
= CMP_NONE
;
7311 as_warn (_("Unhandled dependency %s for %s (%s), note %d"), \
7312 dep->name, idesc->name, (rsrc_write?"write":"read"), note)
7313 #define KNOWN(REG) (gr_values[REG].known && gr_values[REG].path >= path)
7315 /* we don't need to track these */
7316 if (dep
->semantics
== IA64_DVS_NONE
)
7319 switch (dep
->specifier
)
7324 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
7326 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
7327 if (regno
>= 0 && regno
<= 7)
7329 specs
[count
] = tmpl
;
7330 specs
[count
++].index
= regno
;
7336 for (i
= 0; i
< 8; i
++)
7338 specs
[count
] = tmpl
;
7339 specs
[count
++].index
= i
;
7348 case IA64_RS_AR_UNAT
:
7349 /* This is a mov =AR or mov AR= instruction. */
7350 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
7352 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
7353 if (regno
== AR_UNAT
)
7355 specs
[count
++] = tmpl
;
7360 /* This is a spill/fill, or other instruction that modifies the
7363 /* Unless we can determine the specific bits used, mark the whole
7364 thing; bits 8:3 of the memory address indicate the bit used in
7365 UNAT. The .mem.offset hint may be used to eliminate a small
7366 subset of conflicts. */
7367 specs
[count
] = tmpl
;
7368 if (md
.mem_offset
.hint
)
7371 fprintf (stderr
, " Using hint for spill/fill\n");
7372 /* The index isn't actually used, just set it to something
7373 approximating the bit index. */
7374 specs
[count
].index
= (md
.mem_offset
.offset
>> 3) & 0x3F;
7375 specs
[count
].mem_offset
.hint
= 1;
7376 specs
[count
].mem_offset
.offset
= md
.mem_offset
.offset
;
7377 specs
[count
++].mem_offset
.base
= md
.mem_offset
.base
;
7381 specs
[count
++].specific
= 0;
7389 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
7391 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
7392 if ((regno
>= 8 && regno
<= 15)
7393 || (regno
>= 20 && regno
<= 23)
7394 || (regno
>= 31 && regno
<= 39)
7395 || (regno
>= 41 && regno
<= 47)
7396 || (regno
>= 67 && regno
<= 111))
7398 specs
[count
] = tmpl
;
7399 specs
[count
++].index
= regno
;
7412 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
7414 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
7415 if ((regno
>= 48 && regno
<= 63)
7416 || (regno
>= 112 && regno
<= 127))
7418 specs
[count
] = tmpl
;
7419 specs
[count
++].index
= regno
;
7425 for (i
= 48; i
< 64; i
++)
7427 specs
[count
] = tmpl
;
7428 specs
[count
++].index
= i
;
7430 for (i
= 112; i
< 128; i
++)
7432 specs
[count
] = tmpl
;
7433 specs
[count
++].index
= i
;
7451 for (i
= 0; i
< idesc
->num_outputs
; i
++)
7452 if (idesc
->operands
[i
] == IA64_OPND_B1
7453 || idesc
->operands
[i
] == IA64_OPND_B2
)
7455 specs
[count
] = tmpl
;
7456 specs
[count
++].index
=
7457 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
7462 for (i
= idesc
->num_outputs
;i
< NELEMS (idesc
->operands
); i
++)
7463 if (idesc
->operands
[i
] == IA64_OPND_B1
7464 || idesc
->operands
[i
] == IA64_OPND_B2
)
7466 specs
[count
] = tmpl
;
7467 specs
[count
++].index
=
7468 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
7474 case IA64_RS_CPUID
: /* four or more registers */
7477 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CPUID_R3
)
7479 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7480 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7483 specs
[count
] = tmpl
;
7484 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7488 specs
[count
] = tmpl
;
7489 specs
[count
++].specific
= 0;
7499 case IA64_RS_DBR
: /* four or more registers */
7502 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_DBR_R3
)
7504 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7505 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7508 specs
[count
] = tmpl
;
7509 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7513 specs
[count
] = tmpl
;
7514 specs
[count
++].specific
= 0;
7518 else if (note
== 0 && !rsrc_write
)
7520 specs
[count
] = tmpl
;
7521 specs
[count
++].specific
= 0;
7529 case IA64_RS_IBR
: /* four or more registers */
7532 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_IBR_R3
)
7534 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7535 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7538 specs
[count
] = tmpl
;
7539 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7543 specs
[count
] = tmpl
;
7544 specs
[count
++].specific
= 0;
7557 /* These are implementation specific. Force all references to
7558 conflict with all other references. */
7559 specs
[count
] = tmpl
;
7560 specs
[count
++].specific
= 0;
7568 case IA64_RS_PKR
: /* 16 or more registers */
7569 if (note
== 3 || note
== 4)
7571 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PKR_R3
)
7573 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7574 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7579 specs
[count
] = tmpl
;
7580 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7583 for (i
= 0; i
< NELEMS (gr_values
); i
++)
7585 /* Uses all registers *except* the one in R3. */
7586 if ((unsigned)i
!= (gr_values
[regno
].value
& 0xFF))
7588 specs
[count
] = tmpl
;
7589 specs
[count
++].index
= i
;
7595 specs
[count
] = tmpl
;
7596 specs
[count
++].specific
= 0;
7603 specs
[count
] = tmpl
;
7604 specs
[count
++].specific
= 0;
7608 case IA64_RS_PMC
: /* four or more registers */
7611 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMC_R3
7612 || (!rsrc_write
&& idesc
->operands
[1] == IA64_OPND_PMD_R3
))
7615 int index
= ((idesc
->operands
[1] == IA64_OPND_R3
&& !rsrc_write
)
7617 int regno
= CURR_SLOT
.opnd
[index
].X_add_number
- REG_GR
;
7618 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7621 specs
[count
] = tmpl
;
7622 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7626 specs
[count
] = tmpl
;
7627 specs
[count
++].specific
= 0;
7637 case IA64_RS_PMD
: /* four or more registers */
7640 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMD_R3
)
7642 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7643 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7646 specs
[count
] = tmpl
;
7647 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7651 specs
[count
] = tmpl
;
7652 specs
[count
++].specific
= 0;
7662 case IA64_RS_RR
: /* eight registers */
7665 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_RR_R3
)
7667 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7668 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7671 specs
[count
] = tmpl
;
7672 specs
[count
++].index
= (gr_values
[regno
].value
>> 61) & 0x7;
7676 specs
[count
] = tmpl
;
7677 specs
[count
++].specific
= 0;
7681 else if (note
== 0 && !rsrc_write
)
7683 specs
[count
] = tmpl
;
7684 specs
[count
++].specific
= 0;
7692 case IA64_RS_CR_IRR
:
7695 /* handle mov-from-CR-IVR; it's a read that writes CR[IRR] */
7696 int regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
;
7698 && idesc
->operands
[1] == IA64_OPND_CR3
7701 for (i
= 0; i
< 4; i
++)
7703 specs
[count
] = tmpl
;
7704 specs
[count
++].index
= CR_IRR0
+ i
;
7710 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
7711 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
7713 && regno
<= CR_IRR3
)
7715 specs
[count
] = tmpl
;
7716 specs
[count
++].index
= regno
;
7725 case IA64_RS_CR_LRR
:
7732 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
7733 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
7734 && (regno
== CR_LRR0
|| regno
== CR_LRR1
))
7736 specs
[count
] = tmpl
;
7737 specs
[count
++].index
= regno
;
7745 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
7747 specs
[count
] = tmpl
;
7748 specs
[count
++].index
=
7749 CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
7764 else if (rsrc_write
)
7766 if (dep
->specifier
== IA64_RS_FRb
7767 && idesc
->operands
[0] == IA64_OPND_F1
)
7769 specs
[count
] = tmpl
;
7770 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_FR
;
7775 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
7777 if (idesc
->operands
[i
] == IA64_OPND_F2
7778 || idesc
->operands
[i
] == IA64_OPND_F3
7779 || idesc
->operands
[i
] == IA64_OPND_F4
)
7781 specs
[count
] = tmpl
;
7782 specs
[count
++].index
=
7783 CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
7792 /* This reference applies only to the GR whose value is loaded with
7793 data returned from memory. */
7794 specs
[count
] = tmpl
;
7795 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
7801 for (i
= 0; i
< idesc
->num_outputs
; i
++)
7802 if (idesc
->operands
[i
] == IA64_OPND_R1
7803 || idesc
->operands
[i
] == IA64_OPND_R2
7804 || idesc
->operands
[i
] == IA64_OPND_R3
)
7806 specs
[count
] = tmpl
;
7807 specs
[count
++].index
=
7808 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
7810 if (idesc
->flags
& IA64_OPCODE_POSTINC
)
7811 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
7812 if (idesc
->operands
[i
] == IA64_OPND_MR3
)
7814 specs
[count
] = tmpl
;
7815 specs
[count
++].index
=
7816 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
7821 /* Look for anything that reads a GR. */
7822 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
7824 if (idesc
->operands
[i
] == IA64_OPND_MR3
7825 || idesc
->operands
[i
] == IA64_OPND_CPUID_R3
7826 || idesc
->operands
[i
] == IA64_OPND_DBR_R3
7827 || idesc
->operands
[i
] == IA64_OPND_IBR_R3
7828 || idesc
->operands
[i
] == IA64_OPND_MSR_R3
7829 || idesc
->operands
[i
] == IA64_OPND_PKR_R3
7830 || idesc
->operands
[i
] == IA64_OPND_PMC_R3
7831 || idesc
->operands
[i
] == IA64_OPND_PMD_R3
7832 || idesc
->operands
[i
] == IA64_OPND_RR_R3
7833 || ((i
>= idesc
->num_outputs
)
7834 && (idesc
->operands
[i
] == IA64_OPND_R1
7835 || idesc
->operands
[i
] == IA64_OPND_R2
7836 || idesc
->operands
[i
] == IA64_OPND_R3
7837 /* addl source register. */
7838 || idesc
->operands
[i
] == IA64_OPND_R3_2
)))
7840 specs
[count
] = tmpl
;
7841 specs
[count
++].index
=
7842 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
7853 /* This is the same as IA64_RS_PRr, except that the register range is
7854 from 1 - 15, and there are no rotating register reads/writes here. */
7858 for (i
= 1; i
< 16; i
++)
7860 specs
[count
] = tmpl
;
7861 specs
[count
++].index
= i
;
7867 /* Mark only those registers indicated by the mask. */
7870 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
7871 for (i
= 1; i
< 16; i
++)
7872 if (mask
& ((valueT
) 1 << i
))
7874 specs
[count
] = tmpl
;
7875 specs
[count
++].index
= i
;
7883 else if (note
== 11) /* note 11 implies note 1 as well */
7887 for (i
= 0; i
< idesc
->num_outputs
; i
++)
7889 if (idesc
->operands
[i
] == IA64_OPND_P1
7890 || idesc
->operands
[i
] == IA64_OPND_P2
)
7892 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
7893 if (regno
>= 1 && regno
< 16)
7895 specs
[count
] = tmpl
;
7896 specs
[count
++].index
= regno
;
7906 else if (note
== 12)
7908 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
7910 specs
[count
] = tmpl
;
7911 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
7918 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
7919 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
7920 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
7921 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
7923 if ((idesc
->operands
[0] == IA64_OPND_P1
7924 || idesc
->operands
[0] == IA64_OPND_P2
)
7925 && p1
>= 1 && p1
< 16)
7927 specs
[count
] = tmpl
;
7928 specs
[count
].cmp_type
=
7929 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
7930 specs
[count
++].index
= p1
;
7932 if ((idesc
->operands
[1] == IA64_OPND_P1
7933 || idesc
->operands
[1] == IA64_OPND_P2
)
7934 && p2
>= 1 && p2
< 16)
7936 specs
[count
] = tmpl
;
7937 specs
[count
].cmp_type
=
7938 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
7939 specs
[count
++].index
= p2
;
7944 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
7946 specs
[count
] = tmpl
;
7947 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
7949 if (idesc
->operands
[1] == IA64_OPND_PR
)
7951 for (i
= 1; i
< 16; i
++)
7953 specs
[count
] = tmpl
;
7954 specs
[count
++].index
= i
;
7965 /* This is the general case for PRs. IA64_RS_PR and IA64_RS_PR63 are
7966 simplified cases of this. */
7970 for (i
= 16; i
< 63; i
++)
7972 specs
[count
] = tmpl
;
7973 specs
[count
++].index
= i
;
7979 /* Mark only those registers indicated by the mask. */
7981 && idesc
->operands
[0] == IA64_OPND_PR
)
7983 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
7984 if (mask
& ((valueT
) 1<<16))
7985 for (i
= 16; i
< 63; i
++)
7987 specs
[count
] = tmpl
;
7988 specs
[count
++].index
= i
;
7992 && idesc
->operands
[0] == IA64_OPND_PR_ROT
)
7994 for (i
= 16; i
< 63; i
++)
7996 specs
[count
] = tmpl
;
7997 specs
[count
++].index
= i
;
8005 else if (note
== 11) /* note 11 implies note 1 as well */
8009 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8011 if (idesc
->operands
[i
] == IA64_OPND_P1
8012 || idesc
->operands
[i
] == IA64_OPND_P2
)
8014 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8015 if (regno
>= 16 && regno
< 63)
8017 specs
[count
] = tmpl
;
8018 specs
[count
++].index
= regno
;
8028 else if (note
== 12)
8030 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8032 specs
[count
] = tmpl
;
8033 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8040 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8041 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8042 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8043 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8045 if ((idesc
->operands
[0] == IA64_OPND_P1
8046 || idesc
->operands
[0] == IA64_OPND_P2
)
8047 && p1
>= 16 && p1
< 63)
8049 specs
[count
] = tmpl
;
8050 specs
[count
].cmp_type
=
8051 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8052 specs
[count
++].index
= p1
;
8054 if ((idesc
->operands
[1] == IA64_OPND_P1
8055 || idesc
->operands
[1] == IA64_OPND_P2
)
8056 && p2
>= 16 && p2
< 63)
8058 specs
[count
] = tmpl
;
8059 specs
[count
].cmp_type
=
8060 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8061 specs
[count
++].index
= p2
;
8066 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8068 specs
[count
] = tmpl
;
8069 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8071 if (idesc
->operands
[1] == IA64_OPND_PR
)
8073 for (i
= 16; i
< 63; i
++)
8075 specs
[count
] = tmpl
;
8076 specs
[count
++].index
= i
;
8088 /* Verify that the instruction is using the PSR bit indicated in
8092 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_UM
)
8094 if (dep
->regindex
< 6)
8096 specs
[count
++] = tmpl
;
8099 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR
)
8101 if (dep
->regindex
< 32
8102 || dep
->regindex
== 35
8103 || dep
->regindex
== 36
8104 || (!rsrc_write
&& dep
->regindex
== PSR_CPL
))
8106 specs
[count
++] = tmpl
;
8109 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_L
)
8111 if (dep
->regindex
< 32
8112 || dep
->regindex
== 35
8113 || dep
->regindex
== 36
8114 || (rsrc_write
&& dep
->regindex
== PSR_CPL
))
8116 specs
[count
++] = tmpl
;
8121 /* Several PSR bits have very specific dependencies. */
8122 switch (dep
->regindex
)
8125 specs
[count
++] = tmpl
;
8130 specs
[count
++] = tmpl
;
8134 /* Only certain CR accesses use PSR.ic */
8135 if (idesc
->operands
[0] == IA64_OPND_CR3
8136 || idesc
->operands
[1] == IA64_OPND_CR3
)
8139 ((idesc
->operands
[0] == IA64_OPND_CR3
)
8142 CURR_SLOT
.opnd
[index
].X_add_number
- REG_CR
;
8157 specs
[count
++] = tmpl
;
8166 specs
[count
++] = tmpl
;
8170 /* Only some AR accesses use cpl */
8171 if (idesc
->operands
[0] == IA64_OPND_AR3
8172 || idesc
->operands
[1] == IA64_OPND_AR3
)
8175 ((idesc
->operands
[0] == IA64_OPND_AR3
)
8178 CURR_SLOT
.opnd
[index
].X_add_number
- REG_AR
;
8185 && regno
<= AR_K7
))))
8187 specs
[count
++] = tmpl
;
8192 specs
[count
++] = tmpl
;
8202 if (idesc
->operands
[0] == IA64_OPND_IMMU24
)
8204 mask
= CURR_SLOT
.opnd
[0].X_add_number
;
8210 if (mask
& ((valueT
) 1 << dep
->regindex
))
8212 specs
[count
++] = tmpl
;
8217 int min
= dep
->regindex
== PSR_DFL
? 2 : 32;
8218 int max
= dep
->regindex
== PSR_DFL
? 31 : 127;
8219 /* dfh is read on FR32-127; dfl is read on FR2-31 */
8220 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8222 if (idesc
->operands
[i
] == IA64_OPND_F1
8223 || idesc
->operands
[i
] == IA64_OPND_F2
8224 || idesc
->operands
[i
] == IA64_OPND_F3
8225 || idesc
->operands
[i
] == IA64_OPND_F4
)
8227 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8228 if (reg
>= min
&& reg
<= max
)
8230 specs
[count
++] = tmpl
;
8237 int min
= dep
->regindex
== PSR_MFL
? 2 : 32;
8238 int max
= dep
->regindex
== PSR_MFL
? 31 : 127;
8239 /* mfh is read on writes to FR32-127; mfl is read on writes to
8241 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8243 if (idesc
->operands
[i
] == IA64_OPND_F1
)
8245 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8246 if (reg
>= min
&& reg
<= max
)
8248 specs
[count
++] = tmpl
;
8253 else if (note
== 10)
8255 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8257 if (idesc
->operands
[i
] == IA64_OPND_R1
8258 || idesc
->operands
[i
] == IA64_OPND_R2
8259 || idesc
->operands
[i
] == IA64_OPND_R3
)
8261 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8262 if (regno
>= 16 && regno
<= 31)
8264 specs
[count
++] = tmpl
;
8275 case IA64_RS_AR_FPSR
:
8276 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8278 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8279 if (regno
== AR_FPSR
)
8281 specs
[count
++] = tmpl
;
8286 specs
[count
++] = tmpl
;
8291 /* Handle all AR[REG] resources */
8292 if (note
== 0 || note
== 1)
8294 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8295 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
8296 && regno
== dep
->regindex
)
8298 specs
[count
++] = tmpl
;
8300 /* other AR[REG] resources may be affected by AR accesses */
8301 else if (idesc
->operands
[0] == IA64_OPND_AR3
)
8304 regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
;
8305 switch (dep
->regindex
)
8311 if (regno
== AR_BSPSTORE
)
8313 specs
[count
++] = tmpl
;
8317 (regno
== AR_BSPSTORE
8318 || regno
== AR_RNAT
))
8320 specs
[count
++] = tmpl
;
8325 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
8328 regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
;
8329 switch (dep
->regindex
)
8334 if (regno
== AR_BSPSTORE
|| regno
== AR_RNAT
)
8336 specs
[count
++] = tmpl
;
8343 specs
[count
++] = tmpl
;
8353 /* Handle all CR[REG] resources */
8354 if (note
== 0 || note
== 1)
8356 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
8358 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8359 if (regno
== dep
->regindex
)
8361 specs
[count
++] = tmpl
;
8363 else if (!rsrc_write
)
8365 /* Reads from CR[IVR] affect other resources. */
8366 if (regno
== CR_IVR
)
8368 if ((dep
->regindex
>= CR_IRR0
8369 && dep
->regindex
<= CR_IRR3
)
8370 || dep
->regindex
== CR_TPR
)
8372 specs
[count
++] = tmpl
;
8379 specs
[count
++] = tmpl
;
8388 case IA64_RS_INSERVICE
:
8389 /* look for write of EOI (67) or read of IVR (65) */
8390 if ((idesc
->operands
[0] == IA64_OPND_CR3
8391 && CURR_SLOT
.opnd
[0].X_add_number
- REG_CR
== CR_EOI
)
8392 || (idesc
->operands
[1] == IA64_OPND_CR3
8393 && CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
== CR_IVR
))
8395 specs
[count
++] = tmpl
;
8402 specs
[count
++] = tmpl
;
8413 specs
[count
++] = tmpl
;
8417 /* Check if any of the registers accessed are in the rotating region.
8418 mov to/from pr accesses CFM only when qp_regno is in the rotating
8420 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8422 if (idesc
->operands
[i
] == IA64_OPND_R1
8423 || idesc
->operands
[i
] == IA64_OPND_R2
8424 || idesc
->operands
[i
] == IA64_OPND_R3
)
8426 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8427 /* Assumes that md.rot.num_regs is always valid */
8428 if (md
.rot
.num_regs
> 0
8430 && num
< 31 + md
.rot
.num_regs
)
8432 specs
[count
] = tmpl
;
8433 specs
[count
++].specific
= 0;
8436 else if (idesc
->operands
[i
] == IA64_OPND_F1
8437 || idesc
->operands
[i
] == IA64_OPND_F2
8438 || idesc
->operands
[i
] == IA64_OPND_F3
8439 || idesc
->operands
[i
] == IA64_OPND_F4
)
8441 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8444 specs
[count
] = tmpl
;
8445 specs
[count
++].specific
= 0;
8448 else if (idesc
->operands
[i
] == IA64_OPND_P1
8449 || idesc
->operands
[i
] == IA64_OPND_P2
)
8451 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8454 specs
[count
] = tmpl
;
8455 specs
[count
++].specific
= 0;
8459 if (CURR_SLOT
.qp_regno
> 15)
8461 specs
[count
] = tmpl
;
8462 specs
[count
++].specific
= 0;
8467 /* This is the same as IA64_RS_PRr, except simplified to account for
8468 the fact that there is only one register. */
8472 specs
[count
++] = tmpl
;
8477 if (idesc
->operands
[2] == IA64_OPND_IMM17
)
8478 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8479 if (mask
& ((valueT
) 1 << 63))
8480 specs
[count
++] = tmpl
;
8482 else if (note
== 11)
8484 if ((idesc
->operands
[0] == IA64_OPND_P1
8485 && CURR_SLOT
.opnd
[0].X_add_number
- REG_P
== 63)
8486 || (idesc
->operands
[1] == IA64_OPND_P2
8487 && CURR_SLOT
.opnd
[1].X_add_number
- REG_P
== 63))
8489 specs
[count
++] = tmpl
;
8492 else if (note
== 12)
8494 if (CURR_SLOT
.qp_regno
== 63)
8496 specs
[count
++] = tmpl
;
8503 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8504 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8505 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8506 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8509 && (idesc
->operands
[0] == IA64_OPND_P1
8510 || idesc
->operands
[0] == IA64_OPND_P2
))
8512 specs
[count
] = tmpl
;
8513 specs
[count
++].cmp_type
=
8514 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8517 && (idesc
->operands
[1] == IA64_OPND_P1
8518 || idesc
->operands
[1] == IA64_OPND_P2
))
8520 specs
[count
] = tmpl
;
8521 specs
[count
++].cmp_type
=
8522 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8527 if (CURR_SLOT
.qp_regno
== 63)
8529 specs
[count
++] = tmpl
;
8540 /* FIXME we can identify some individual RSE written resources, but RSE
8541 read resources have not yet been completely identified, so for now
8542 treat RSE as a single resource */
8543 if (strncmp (idesc
->name
, "mov", 3) == 0)
8547 if (idesc
->operands
[0] == IA64_OPND_AR3
8548 && CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
)
8550 specs
[count
] = tmpl
;
8551 specs
[count
++].index
= 0; /* IA64_RSE_BSPLOAD/RNATBITINDEX */
8556 if (idesc
->operands
[0] == IA64_OPND_AR3
)
8558 if (CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
8559 || CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_RNAT
)
8561 specs
[count
++] = tmpl
;
8564 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
8566 if (CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSP
8567 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSPSTORE
8568 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_RNAT
)
8570 specs
[count
++] = tmpl
;
8577 specs
[count
++] = tmpl
;
8582 /* FIXME -- do any of these need to be non-specific? */
8583 specs
[count
++] = tmpl
;
8587 as_bad (_("Unrecognized dependency specifier %d\n"), dep
->specifier
);
8594 /* Clear branch flags on marked resources. This breaks the link between the
8595 QP of the marking instruction and a subsequent branch on the same QP. */
8598 clear_qp_branch_flag (mask
)
8602 for (i
= 0; i
< regdepslen
; i
++)
8604 valueT bit
= ((valueT
) 1 << regdeps
[i
].qp_regno
);
8605 if ((bit
& mask
) != 0)
8607 regdeps
[i
].link_to_qp_branch
= 0;
8612 /* Remove any mutexes which contain any of the PRs indicated in the mask.
8614 Any changes to a PR clears the mutex relations which include that PR. */
8617 clear_qp_mutex (mask
)
8623 while (i
< qp_mutexeslen
)
8625 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
8629 fprintf (stderr
, " Clearing mutex relation");
8630 print_prmask (qp_mutexes
[i
].prmask
);
8631 fprintf (stderr
, "\n");
8633 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
8640 /* Clear implies relations which contain PRs in the given masks.
8641 P1_MASK indicates the source of the implies relation, while P2_MASK
8642 indicates the implied PR. */
8645 clear_qp_implies (p1_mask
, p2_mask
)
8652 while (i
< qp_implieslen
)
8654 if ((((valueT
) 1 << qp_implies
[i
].p1
) & p1_mask
) != 0
8655 || (((valueT
) 1 << qp_implies
[i
].p2
) & p2_mask
) != 0)
8658 fprintf (stderr
, "Clearing implied relation PR%d->PR%d\n",
8659 qp_implies
[i
].p1
, qp_implies
[i
].p2
);
8660 qp_implies
[i
] = qp_implies
[--qp_implieslen
];
8667 /* Add the PRs specified to the list of implied relations. */
8670 add_qp_imply (p1
, p2
)
8677 /* p0 is not meaningful here. */
8678 if (p1
== 0 || p2
== 0)
8684 /* If it exists already, ignore it. */
8685 for (i
= 0; i
< qp_implieslen
; i
++)
8687 if (qp_implies
[i
].p1
== p1
8688 && qp_implies
[i
].p2
== p2
8689 && qp_implies
[i
].path
== md
.path
8690 && !qp_implies
[i
].p2_branched
)
8694 if (qp_implieslen
== qp_impliestotlen
)
8696 qp_impliestotlen
+= 20;
8697 qp_implies
= (struct qp_imply
*)
8698 xrealloc ((void *) qp_implies
,
8699 qp_impliestotlen
* sizeof (struct qp_imply
));
8702 fprintf (stderr
, " Registering PR%d implies PR%d\n", p1
, p2
);
8703 qp_implies
[qp_implieslen
].p1
= p1
;
8704 qp_implies
[qp_implieslen
].p2
= p2
;
8705 qp_implies
[qp_implieslen
].path
= md
.path
;
8706 qp_implies
[qp_implieslen
++].p2_branched
= 0;
8708 /* Add in the implied transitive relations; for everything that p2 implies,
8709 make p1 imply that, too; for everything that implies p1, make it imply p2
8711 for (i
= 0; i
< qp_implieslen
; i
++)
8713 if (qp_implies
[i
].p1
== p2
)
8714 add_qp_imply (p1
, qp_implies
[i
].p2
);
8715 if (qp_implies
[i
].p2
== p1
)
8716 add_qp_imply (qp_implies
[i
].p1
, p2
);
8718 /* Add in mutex relations implied by this implies relation; for each mutex
8719 relation containing p2, duplicate it and replace p2 with p1. */
8720 bit
= (valueT
) 1 << p1
;
8721 mask
= (valueT
) 1 << p2
;
8722 for (i
= 0; i
< qp_mutexeslen
; i
++)
8724 if (qp_mutexes
[i
].prmask
& mask
)
8725 add_qp_mutex ((qp_mutexes
[i
].prmask
& ~mask
) | bit
);
8729 /* Add the PRs specified in the mask to the mutex list; this means that only
8730 one of the PRs can be true at any time. PR0 should never be included in
8740 if (qp_mutexeslen
== qp_mutexestotlen
)
8742 qp_mutexestotlen
+= 20;
8743 qp_mutexes
= (struct qpmutex
*)
8744 xrealloc ((void *) qp_mutexes
,
8745 qp_mutexestotlen
* sizeof (struct qpmutex
));
8749 fprintf (stderr
, " Registering mutex on");
8750 print_prmask (mask
);
8751 fprintf (stderr
, "\n");
8753 qp_mutexes
[qp_mutexeslen
].path
= md
.path
;
8754 qp_mutexes
[qp_mutexeslen
++].prmask
= mask
;
8758 has_suffix_p (name
, suffix
)
8762 size_t namelen
= strlen (name
);
8763 size_t sufflen
= strlen (suffix
);
8765 if (namelen
<= sufflen
)
8767 return strcmp (name
+ namelen
- sufflen
, suffix
) == 0;
8771 clear_register_values ()
8775 fprintf (stderr
, " Clearing register values\n");
8776 for (i
= 1; i
< NELEMS (gr_values
); i
++)
8777 gr_values
[i
].known
= 0;
8780 /* Keep track of register values/changes which affect DV tracking.
8782 optimization note: should add a flag to classes of insns where otherwise we
8783 have to examine a group of strings to identify them. */
8786 note_register_values (idesc
)
8787 struct ia64_opcode
*idesc
;
8789 valueT qp_changemask
= 0;
8792 /* Invalidate values for registers being written to. */
8793 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8795 if (idesc
->operands
[i
] == IA64_OPND_R1
8796 || idesc
->operands
[i
] == IA64_OPND_R2
8797 || idesc
->operands
[i
] == IA64_OPND_R3
)
8799 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8800 if (regno
> 0 && regno
< NELEMS (gr_values
))
8801 gr_values
[regno
].known
= 0;
8803 else if (idesc
->operands
[i
] == IA64_OPND_R3_2
)
8805 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8806 if (regno
> 0 && regno
< 4)
8807 gr_values
[regno
].known
= 0;
8809 else if (idesc
->operands
[i
] == IA64_OPND_P1
8810 || idesc
->operands
[i
] == IA64_OPND_P2
)
8812 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8813 qp_changemask
|= (valueT
) 1 << regno
;
8815 else if (idesc
->operands
[i
] == IA64_OPND_PR
)
8817 if (idesc
->operands
[2] & (valueT
) 0x10000)
8818 qp_changemask
= ~(valueT
) 0x1FFFF | idesc
->operands
[2];
8820 qp_changemask
= idesc
->operands
[2];
8823 else if (idesc
->operands
[i
] == IA64_OPND_PR_ROT
)
8825 if (idesc
->operands
[1] & ((valueT
) 1 << 43))
8826 qp_changemask
= ~(valueT
) 0xFFFFFFFFFFF | idesc
->operands
[1];
8828 qp_changemask
= idesc
->operands
[1];
8829 qp_changemask
&= ~(valueT
) 0xFFFF;
8834 /* Always clear qp branch flags on any PR change. */
8835 /* FIXME there may be exceptions for certain compares. */
8836 clear_qp_branch_flag (qp_changemask
);
8838 /* Invalidate rotating registers on insns which affect RRBs in CFM. */
8839 if (idesc
->flags
& IA64_OPCODE_MOD_RRBS
)
8841 qp_changemask
|= ~(valueT
) 0xFFFF;
8842 if (strcmp (idesc
->name
, "clrrrb.pr") != 0)
8844 for (i
= 32; i
< 32 + md
.rot
.num_regs
; i
++)
8845 gr_values
[i
].known
= 0;
8847 clear_qp_mutex (qp_changemask
);
8848 clear_qp_implies (qp_changemask
, qp_changemask
);
8850 /* After a call, all register values are undefined, except those marked
8852 else if (strncmp (idesc
->name
, "br.call", 6) == 0
8853 || strncmp (idesc
->name
, "brl.call", 7) == 0)
8855 /* FIXME keep GR values which are marked as "safe_across_calls" */
8856 clear_register_values ();
8857 clear_qp_mutex (~qp_safe_across_calls
);
8858 clear_qp_implies (~qp_safe_across_calls
, ~qp_safe_across_calls
);
8859 clear_qp_branch_flag (~qp_safe_across_calls
);
8861 else if (is_interruption_or_rfi (idesc
)
8862 || is_taken_branch (idesc
))
8864 clear_register_values ();
8865 clear_qp_mutex (~(valueT
) 0);
8866 clear_qp_implies (~(valueT
) 0, ~(valueT
) 0);
8868 /* Look for mutex and implies relations. */
8869 else if ((idesc
->operands
[0] == IA64_OPND_P1
8870 || idesc
->operands
[0] == IA64_OPND_P2
)
8871 && (idesc
->operands
[1] == IA64_OPND_P1
8872 || idesc
->operands
[1] == IA64_OPND_P2
))
8874 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8875 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8876 valueT p1mask
= (valueT
) 1 << p1
;
8877 valueT p2mask
= (valueT
) 1 << p2
;
8879 /* If one of the PRs is PR0, we can't really do anything. */
8880 if (p1
== 0 || p2
== 0)
8883 fprintf (stderr
, " Ignoring PRs due to inclusion of p0\n");
8885 /* In general, clear mutexes and implies which include P1 or P2,
8886 with the following exceptions. */
8887 else if (has_suffix_p (idesc
->name
, ".or.andcm")
8888 || has_suffix_p (idesc
->name
, ".and.orcm"))
8890 add_qp_mutex (p1mask
| p2mask
);
8891 clear_qp_implies (p2mask
, p1mask
);
8893 else if (has_suffix_p (idesc
->name
, ".andcm")
8894 || has_suffix_p (idesc
->name
, ".and"))
8896 clear_qp_implies (0, p1mask
| p2mask
);
8898 else if (has_suffix_p (idesc
->name
, ".orcm")
8899 || has_suffix_p (idesc
->name
, ".or"))
8901 clear_qp_mutex (p1mask
| p2mask
);
8902 clear_qp_implies (p1mask
| p2mask
, 0);
8906 clear_qp_implies (p1mask
| p2mask
, p1mask
| p2mask
);
8907 if (has_suffix_p (idesc
->name
, ".unc"))
8909 add_qp_mutex (p1mask
| p2mask
);
8910 if (CURR_SLOT
.qp_regno
!= 0)
8912 add_qp_imply (CURR_SLOT
.opnd
[0].X_add_number
- REG_P
,
8913 CURR_SLOT
.qp_regno
);
8914 add_qp_imply (CURR_SLOT
.opnd
[1].X_add_number
- REG_P
,
8915 CURR_SLOT
.qp_regno
);
8918 else if (CURR_SLOT
.qp_regno
== 0)
8920 add_qp_mutex (p1mask
| p2mask
);
8924 clear_qp_mutex (p1mask
| p2mask
);
8928 /* Look for mov imm insns into GRs. */
8929 else if (idesc
->operands
[0] == IA64_OPND_R1
8930 && (idesc
->operands
[1] == IA64_OPND_IMM22
8931 || idesc
->operands
[1] == IA64_OPND_IMMU64
)
8932 && (strcmp (idesc
->name
, "mov") == 0
8933 || strcmp (idesc
->name
, "movl") == 0))
8935 int regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
8936 if (regno
> 0 && regno
< NELEMS (gr_values
))
8938 gr_values
[regno
].known
= 1;
8939 gr_values
[regno
].value
= CURR_SLOT
.opnd
[1].X_add_number
;
8940 gr_values
[regno
].path
= md
.path
;
8943 fprintf (stderr
, " Know gr%d = ", regno
);
8944 fprintf_vma (stderr
, gr_values
[regno
].value
);
8945 fputs ("\n", stderr
);
8951 clear_qp_mutex (qp_changemask
);
8952 clear_qp_implies (qp_changemask
, qp_changemask
);
8956 /* Return whether the given predicate registers are currently mutex. */
8959 qp_mutex (p1
, p2
, path
)
8969 mask
= ((valueT
) 1 << p1
) | (valueT
) 1 << p2
;
8970 for (i
= 0; i
< qp_mutexeslen
; i
++)
8972 if (qp_mutexes
[i
].path
>= path
8973 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
8980 /* Return whether the given resource is in the given insn's list of chks
8981 Return 1 if the conflict is absolutely determined, 2 if it's a potential
8985 resources_match (rs
, idesc
, note
, qp_regno
, path
)
8987 struct ia64_opcode
*idesc
;
8992 struct rsrc specs
[MAX_SPECS
];
8995 /* If the marked resource's qp_regno and the given qp_regno are mutex,
8996 we don't need to check. One exception is note 11, which indicates that
8997 target predicates are written regardless of PR[qp]. */
8998 if (qp_mutex (rs
->qp_regno
, qp_regno
, path
)
9002 count
= specify_resource (rs
->dependency
, idesc
, DV_CHK
, specs
, note
, path
);
9005 /* UNAT checking is a bit more specific than other resources */
9006 if (rs
->dependency
->specifier
== IA64_RS_AR_UNAT
9007 && specs
[count
].mem_offset
.hint
9008 && rs
->mem_offset
.hint
)
9010 if (rs
->mem_offset
.base
== specs
[count
].mem_offset
.base
)
9012 if (((rs
->mem_offset
.offset
>> 3) & 0x3F) ==
9013 ((specs
[count
].mem_offset
.offset
>> 3) & 0x3F))
9020 /* Skip apparent PR write conflicts where both writes are an AND or both
9021 writes are an OR. */
9022 if (rs
->dependency
->specifier
== IA64_RS_PR
9023 || rs
->dependency
->specifier
== IA64_RS_PRr
9024 || rs
->dependency
->specifier
== IA64_RS_PR63
)
9026 if (specs
[count
].cmp_type
!= CMP_NONE
9027 && specs
[count
].cmp_type
== rs
->cmp_type
)
9030 fprintf (stderr
, " %s on parallel compare allowed (PR%d)\n",
9031 dv_mode
[rs
->dependency
->mode
],
9032 rs
->dependency
->specifier
!= IA64_RS_PR63
?
9033 specs
[count
].index
: 63);
9038 " %s on parallel compare conflict %s vs %s on PR%d\n",
9039 dv_mode
[rs
->dependency
->mode
],
9040 dv_cmp_type
[rs
->cmp_type
],
9041 dv_cmp_type
[specs
[count
].cmp_type
],
9042 rs
->dependency
->specifier
!= IA64_RS_PR63
?
9043 specs
[count
].index
: 63);
9047 /* If either resource is not specific, conservatively assume a conflict
9049 if (!specs
[count
].specific
|| !rs
->specific
)
9051 else if (specs
[count
].index
== rs
->index
)
9056 fprintf (stderr
, " No %s conflicts\n", rs
->dependency
->name
);
9062 /* Indicate an instruction group break; if INSERT_STOP is non-zero, then
9063 insert a stop to create the break. Update all resource dependencies
9064 appropriately. If QP_REGNO is non-zero, only apply the break to resources
9065 which use the same QP_REGNO and have the link_to_qp_branch flag set.
9066 If SAVE_CURRENT is non-zero, don't affect resources marked by the current
9070 insn_group_break (insert_stop
, qp_regno
, save_current
)
9077 if (insert_stop
&& md
.num_slots_in_use
> 0)
9078 PREV_SLOT
.end_of_insn_group
= 1;
9082 fprintf (stderr
, " Insn group break%s",
9083 (insert_stop
? " (w/stop)" : ""));
9085 fprintf (stderr
, " effective for QP=%d", qp_regno
);
9086 fprintf (stderr
, "\n");
9090 while (i
< regdepslen
)
9092 const struct ia64_dependency
*dep
= regdeps
[i
].dependency
;
9095 && regdeps
[i
].qp_regno
!= qp_regno
)
9102 && CURR_SLOT
.src_file
== regdeps
[i
].file
9103 && CURR_SLOT
.src_line
== regdeps
[i
].line
)
9109 /* clear dependencies which are automatically cleared by a stop, or
9110 those that have reached the appropriate state of insn serialization */
9111 if (dep
->semantics
== IA64_DVS_IMPLIED
9112 || dep
->semantics
== IA64_DVS_IMPLIEDF
9113 || regdeps
[i
].insn_srlz
== STATE_SRLZ
)
9115 print_dependency ("Removing", i
);
9116 regdeps
[i
] = regdeps
[--regdepslen
];
9120 if (dep
->semantics
== IA64_DVS_DATA
9121 || dep
->semantics
== IA64_DVS_INSTR
9122 || dep
->semantics
== IA64_DVS_SPECIFIC
)
9124 if (regdeps
[i
].insn_srlz
== STATE_NONE
)
9125 regdeps
[i
].insn_srlz
= STATE_STOP
;
9126 if (regdeps
[i
].data_srlz
== STATE_NONE
)
9127 regdeps
[i
].data_srlz
= STATE_STOP
;
9134 /* Add the given resource usage spec to the list of active dependencies. */
9137 mark_resource (idesc
, dep
, spec
, depind
, path
)
9138 struct ia64_opcode
*idesc ATTRIBUTE_UNUSED
;
9139 const struct ia64_dependency
*dep ATTRIBUTE_UNUSED
;
9144 if (regdepslen
== regdepstotlen
)
9146 regdepstotlen
+= 20;
9147 regdeps
= (struct rsrc
*)
9148 xrealloc ((void *) regdeps
,
9149 regdepstotlen
* sizeof (struct rsrc
));
9152 regdeps
[regdepslen
] = *spec
;
9153 regdeps
[regdepslen
].depind
= depind
;
9154 regdeps
[regdepslen
].path
= path
;
9155 regdeps
[regdepslen
].file
= CURR_SLOT
.src_file
;
9156 regdeps
[regdepslen
].line
= CURR_SLOT
.src_line
;
9158 print_dependency ("Adding", regdepslen
);
9164 print_dependency (action
, depind
)
9170 fprintf (stderr
, " %s %s '%s'",
9171 action
, dv_mode
[(regdeps
[depind
].dependency
)->mode
],
9172 (regdeps
[depind
].dependency
)->name
);
9173 if (regdeps
[depind
].specific
&& regdeps
[depind
].index
!= 0)
9174 fprintf (stderr
, " (%d)", regdeps
[depind
].index
);
9175 if (regdeps
[depind
].mem_offset
.hint
)
9177 fputs (" ", stderr
);
9178 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.base
);
9179 fputs ("+", stderr
);
9180 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.offset
);
9182 fprintf (stderr
, "\n");
9187 instruction_serialization ()
9191 fprintf (stderr
, " Instruction serialization\n");
9192 for (i
= 0; i
< regdepslen
; i
++)
9193 if (regdeps
[i
].insn_srlz
== STATE_STOP
)
9194 regdeps
[i
].insn_srlz
= STATE_SRLZ
;
9198 data_serialization ()
9202 fprintf (stderr
, " Data serialization\n");
9203 while (i
< regdepslen
)
9205 if (regdeps
[i
].data_srlz
== STATE_STOP
9206 /* Note: as of 991210, all "other" dependencies are cleared by a
9207 data serialization. This might change with new tables */
9208 || (regdeps
[i
].dependency
)->semantics
== IA64_DVS_OTHER
)
9210 print_dependency ("Removing", i
);
9211 regdeps
[i
] = regdeps
[--regdepslen
];
9218 /* Insert stops and serializations as needed to avoid DVs. */
9221 remove_marked_resource (rs
)
9224 switch (rs
->dependency
->semantics
)
9226 case IA64_DVS_SPECIFIC
:
9228 fprintf (stderr
, "Implementation-specific, assume worst case...\n");
9229 /* ...fall through... */
9230 case IA64_DVS_INSTR
:
9232 fprintf (stderr
, "Inserting instr serialization\n");
9233 if (rs
->insn_srlz
< STATE_STOP
)
9234 insn_group_break (1, 0, 0);
9235 if (rs
->insn_srlz
< STATE_SRLZ
)
9237 int oldqp
= CURR_SLOT
.qp_regno
;
9238 struct ia64_opcode
*oldidesc
= CURR_SLOT
.idesc
;
9239 /* Manually jam a srlz.i insn into the stream */
9240 CURR_SLOT
.qp_regno
= 0;
9241 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.i");
9242 instruction_serialization ();
9243 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
9244 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
9246 CURR_SLOT
.qp_regno
= oldqp
;
9247 CURR_SLOT
.idesc
= oldidesc
;
9249 insn_group_break (1, 0, 0);
9251 case IA64_DVS_OTHER
: /* as of rev2 (991220) of the DV tables, all
9252 "other" types of DV are eliminated
9253 by a data serialization */
9256 fprintf (stderr
, "Inserting data serialization\n");
9257 if (rs
->data_srlz
< STATE_STOP
)
9258 insn_group_break (1, 0, 0);
9260 int oldqp
= CURR_SLOT
.qp_regno
;
9261 struct ia64_opcode
*oldidesc
= CURR_SLOT
.idesc
;
9262 /* Manually jam a srlz.d insn into the stream */
9263 CURR_SLOT
.qp_regno
= 0;
9264 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.d");
9265 data_serialization ();
9266 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
9267 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
9269 CURR_SLOT
.qp_regno
= oldqp
;
9270 CURR_SLOT
.idesc
= oldidesc
;
9273 case IA64_DVS_IMPLIED
:
9274 case IA64_DVS_IMPLIEDF
:
9276 fprintf (stderr
, "Inserting stop\n");
9277 insn_group_break (1, 0, 0);
9284 /* Check the resources used by the given opcode against the current dependency
9287 The check is run once for each execution path encountered. In this case,
9288 a unique execution path is the sequence of instructions following a code
9289 entry point, e.g. the following has three execution paths, one starting
9290 at L0, one at L1, and one at L2.
9299 check_dependencies (idesc
)
9300 struct ia64_opcode
*idesc
;
9302 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
9306 /* Note that the number of marked resources may change within the
9307 loop if in auto mode. */
9309 while (i
< regdepslen
)
9311 struct rsrc
*rs
= ®deps
[i
];
9312 const struct ia64_dependency
*dep
= rs
->dependency
;
9317 if (dep
->semantics
== IA64_DVS_NONE
9318 || (chkind
= depends_on (rs
->depind
, idesc
)) == -1)
9324 note
= NOTE (opdeps
->chks
[chkind
]);
9326 /* Check this resource against each execution path seen thus far. */
9327 for (path
= 0; path
<= md
.path
; path
++)
9331 /* If the dependency wasn't on the path being checked, ignore it. */
9332 if (rs
->path
< path
)
9335 /* If the QP for this insn implies a QP which has branched, don't
9336 bother checking. Ed. NOTE: I don't think this check is terribly
9337 useful; what's the point of generating code which will only be
9338 reached if its QP is zero?
9339 This code was specifically inserted to handle the following code,
9340 based on notes from Intel's DV checking code, where p1 implies p2.
9346 if (CURR_SLOT
.qp_regno
!= 0)
9350 for (implies
= 0; implies
< qp_implieslen
; implies
++)
9352 if (qp_implies
[implies
].path
>= path
9353 && qp_implies
[implies
].p1
== CURR_SLOT
.qp_regno
9354 && qp_implies
[implies
].p2_branched
)
9364 if ((matchtype
= resources_match (rs
, idesc
, note
,
9365 CURR_SLOT
.qp_regno
, path
)) != 0)
9368 char pathmsg
[256] = "";
9369 char indexmsg
[256] = "";
9370 int certain
= (matchtype
== 1 && CURR_SLOT
.qp_regno
== 0);
9373 sprintf (pathmsg
, " when entry is at label '%s'",
9374 md
.entry_labels
[path
- 1]);
9375 if (rs
->specific
&& rs
->index
!= 0)
9376 sprintf (indexmsg
, ", specific resource number is %d",
9378 sprintf (msg
, "Use of '%s' %s %s dependency '%s' (%s)%s%s",
9380 (certain
? "violates" : "may violate"),
9381 dv_mode
[dep
->mode
], dep
->name
,
9382 dv_sem
[dep
->semantics
],
9385 if (md
.explicit_mode
)
9387 as_warn ("%s", msg
);
9389 as_warn (_("Only the first path encountering the conflict "
9391 as_warn_where (rs
->file
, rs
->line
,
9392 _("This is the location of the "
9393 "conflicting usage"));
9394 /* Don't bother checking other paths, to avoid duplicating
9401 fprintf (stderr
, "%s @ %s:%d\n", msg
, rs
->file
, rs
->line
);
9403 remove_marked_resource (rs
);
9405 /* since the set of dependencies has changed, start over */
9406 /* FIXME -- since we're removing dvs as we go, we
9407 probably don't really need to start over... */
9420 /* Register new dependencies based on the given opcode. */
9423 mark_resources (idesc
)
9424 struct ia64_opcode
*idesc
;
9427 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
9428 int add_only_qp_reads
= 0;
9430 /* A conditional branch only uses its resources if it is taken; if it is
9431 taken, we stop following that path. The other branch types effectively
9432 *always* write their resources. If it's not taken, register only QP
9434 if (is_conditional_branch (idesc
) || is_interruption_or_rfi (idesc
))
9436 add_only_qp_reads
= 1;
9440 fprintf (stderr
, "Registering '%s' resource usage\n", idesc
->name
);
9442 for (i
= 0; i
< opdeps
->nregs
; i
++)
9444 const struct ia64_dependency
*dep
;
9445 struct rsrc specs
[MAX_SPECS
];
9450 dep
= ia64_find_dependency (opdeps
->regs
[i
]);
9451 note
= NOTE (opdeps
->regs
[i
]);
9453 if (add_only_qp_reads
9454 && !(dep
->mode
== IA64_DV_WAR
9455 && (dep
->specifier
== IA64_RS_PR
9456 || dep
->specifier
== IA64_RS_PRr
9457 || dep
->specifier
== IA64_RS_PR63
)))
9460 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, md
.path
);
9463 if (md
.debug_dv
&& !count
)
9464 fprintf (stderr
, " No %s %s usage found (path %d)\n",
9465 dv_mode
[dep
->mode
], dep
->name
, md
.path
);
9470 mark_resource (idesc
, dep
, &specs
[count
],
9471 DEP (opdeps
->regs
[i
]), md
.path
);
9474 /* The execution path may affect register values, which may in turn
9475 affect which indirect-access resources are accessed. */
9476 switch (dep
->specifier
)
9488 for (path
= 0; path
< md
.path
; path
++)
9490 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, path
);
9492 mark_resource (idesc
, dep
, &specs
[count
],
9493 DEP (opdeps
->regs
[i
]), path
);
9500 /* Remove dependencies when they no longer apply. */
9503 update_dependencies (idesc
)
9504 struct ia64_opcode
*idesc
;
9508 if (strcmp (idesc
->name
, "srlz.i") == 0)
9510 instruction_serialization ();
9512 else if (strcmp (idesc
->name
, "srlz.d") == 0)
9514 data_serialization ();
9516 else if (is_interruption_or_rfi (idesc
)
9517 || is_taken_branch (idesc
))
9519 /* Although technically the taken branch doesn't clear dependencies
9520 which require a srlz.[id], we don't follow the branch; the next
9521 instruction is assumed to start with a clean slate. */
9525 else if (is_conditional_branch (idesc
)
9526 && CURR_SLOT
.qp_regno
!= 0)
9528 int is_call
= strstr (idesc
->name
, ".call") != NULL
;
9530 for (i
= 0; i
< qp_implieslen
; i
++)
9532 /* If the conditional branch's predicate is implied by the predicate
9533 in an existing dependency, remove that dependency. */
9534 if (qp_implies
[i
].p2
== CURR_SLOT
.qp_regno
)
9537 /* Note that this implied predicate takes a branch so that if
9538 a later insn generates a DV but its predicate implies this
9539 one, we can avoid the false DV warning. */
9540 qp_implies
[i
].p2_branched
= 1;
9541 while (depind
< regdepslen
)
9543 if (regdeps
[depind
].qp_regno
== qp_implies
[i
].p1
)
9545 print_dependency ("Removing", depind
);
9546 regdeps
[depind
] = regdeps
[--regdepslen
];
9553 /* Any marked resources which have this same predicate should be
9554 cleared, provided that the QP hasn't been modified between the
9555 marking instruction and the branch. */
9558 insn_group_break (0, CURR_SLOT
.qp_regno
, 1);
9563 while (i
< regdepslen
)
9565 if (regdeps
[i
].qp_regno
== CURR_SLOT
.qp_regno
9566 && regdeps
[i
].link_to_qp_branch
9567 && (regdeps
[i
].file
!= CURR_SLOT
.src_file
9568 || regdeps
[i
].line
!= CURR_SLOT
.src_line
))
9570 /* Treat like a taken branch */
9571 print_dependency ("Removing", i
);
9572 regdeps
[i
] = regdeps
[--regdepslen
];
9581 /* Examine the current instruction for dependency violations. */
9585 struct ia64_opcode
*idesc
;
9589 fprintf (stderr
, "Checking %s for violations (line %d, %d/%d)\n",
9590 idesc
->name
, CURR_SLOT
.src_line
,
9591 idesc
->dependencies
->nchks
,
9592 idesc
->dependencies
->nregs
);
9595 /* Look through the list of currently marked resources; if the current
9596 instruction has the dependency in its chks list which uses that resource,
9597 check against the specific resources used. */
9598 check_dependencies (idesc
);
9600 /* Look up the instruction's regdeps (RAW writes, WAW writes, and WAR reads),
9601 then add them to the list of marked resources. */
9602 mark_resources (idesc
);
9604 /* There are several types of dependency semantics, and each has its own
9605 requirements for being cleared
9607 Instruction serialization (insns separated by interruption, rfi, or
9608 writer + srlz.i + reader, all in separate groups) clears DVS_INSTR.
9610 Data serialization (instruction serialization, or writer + srlz.d +
9611 reader, where writer and srlz.d are in separate groups) clears
9612 DVS_DATA. (This also clears DVS_OTHER, but that is not guaranteed to
9613 always be the case).
9615 Instruction group break (groups separated by stop, taken branch,
9616 interruption or rfi) clears DVS_IMPLIED and DVS_IMPLIEDF.
9618 update_dependencies (idesc
);
9620 /* Sometimes, knowing a register value allows us to avoid giving a false DV
9621 warning. Keep track of as many as possible that are useful. */
9622 note_register_values (idesc
);
9624 /* We don't need or want this anymore. */
9625 md
.mem_offset
.hint
= 0;
9630 /* Translate one line of assembly. Pseudo ops and labels do not show
9636 char *saved_input_line_pointer
, *mnemonic
;
9637 const struct pseudo_opcode
*pdesc
;
9638 struct ia64_opcode
*idesc
;
9639 unsigned char qp_regno
;
9643 saved_input_line_pointer
= input_line_pointer
;
9644 input_line_pointer
= str
;
9646 /* extract the opcode (mnemonic): */
9648 mnemonic
= input_line_pointer
;
9649 ch
= get_symbol_end ();
9650 pdesc
= (struct pseudo_opcode
*) hash_find (md
.pseudo_hash
, mnemonic
);
9653 *input_line_pointer
= ch
;
9654 (*pdesc
->handler
) (pdesc
->arg
);
9658 /* Find the instruction descriptor matching the arguments. */
9660 idesc
= ia64_find_opcode (mnemonic
);
9661 *input_line_pointer
= ch
;
9664 as_bad ("Unknown opcode `%s'", mnemonic
);
9668 idesc
= parse_operands (idesc
);
9672 /* Handle the dynamic ops we can handle now: */
9673 if (idesc
->type
== IA64_TYPE_DYN
)
9675 if (strcmp (idesc
->name
, "add") == 0)
9677 if (CURR_SLOT
.opnd
[2].X_op
== O_register
9678 && CURR_SLOT
.opnd
[2].X_add_number
< 4)
9682 ia64_free_opcode (idesc
);
9683 idesc
= ia64_find_opcode (mnemonic
);
9685 know (!idesc
->next
);
9688 else if (strcmp (idesc
->name
, "mov") == 0)
9690 enum ia64_opnd opnd1
, opnd2
;
9693 opnd1
= idesc
->operands
[0];
9694 opnd2
= idesc
->operands
[1];
9695 if (opnd1
== IA64_OPND_AR3
)
9697 else if (opnd2
== IA64_OPND_AR3
)
9701 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
9702 && ar_is_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
9706 ia64_free_opcode (idesc
);
9707 idesc
= ia64_find_opcode (mnemonic
);
9708 while (idesc
!= NULL
9709 && (idesc
->operands
[0] != opnd1
9710 || idesc
->operands
[1] != opnd2
))
9711 idesc
= get_next_opcode (idesc
);
9716 if (md
.qp
.X_op
== O_register
)
9718 qp_regno
= md
.qp
.X_add_number
- REG_P
;
9719 md
.qp
.X_op
= O_absent
;
9722 flags
= idesc
->flags
;
9724 if ((flags
& IA64_OPCODE_FIRST
) != 0)
9725 insn_group_break (1, 0, 0);
9727 if ((flags
& IA64_OPCODE_NO_PRED
) != 0 && qp_regno
!= 0)
9729 as_bad ("`%s' cannot be predicated", idesc
->name
);
9733 /* Build the instruction. */
9734 CURR_SLOT
.qp_regno
= qp_regno
;
9735 CURR_SLOT
.idesc
= idesc
;
9736 as_where (&CURR_SLOT
.src_file
, &CURR_SLOT
.src_line
);
9737 dwarf2_where (&CURR_SLOT
.debug_line
);
9739 /* Add unwind entry, if there is one. */
9740 if (unwind
.current_entry
)
9742 CURR_SLOT
.unwind_record
= unwind
.current_entry
;
9743 unwind
.current_entry
= NULL
;
9746 /* Check for dependency violations. */
9750 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
9751 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
9754 if ((flags
& IA64_OPCODE_LAST
) != 0)
9755 insn_group_break (1, 0, 0);
9757 md
.last_text_seg
= now_seg
;
9760 input_line_pointer
= saved_input_line_pointer
;
9763 /* Called when symbol NAME cannot be found in the symbol table.
9764 Should be used for dynamic valued symbols only. */
9767 md_undefined_symbol (name
)
9768 char *name ATTRIBUTE_UNUSED
;
9773 /* Called for any expression that can not be recognized. When the
9774 function is called, `input_line_pointer' will point to the start of
9781 enum pseudo_type pseudo_type
;
9786 switch (*input_line_pointer
)
9789 /* Find what relocation pseudo-function we're dealing with. */
9791 ch
= *++input_line_pointer
;
9792 for (i
= 0; i
< NELEMS (pseudo_func
); ++i
)
9793 if (pseudo_func
[i
].name
&& pseudo_func
[i
].name
[0] == ch
)
9795 len
= strlen (pseudo_func
[i
].name
);
9796 if (strncmp (pseudo_func
[i
].name
+ 1,
9797 input_line_pointer
+ 1, len
- 1) == 0
9798 && !is_part_of_name (input_line_pointer
[len
]))
9800 input_line_pointer
+= len
;
9801 pseudo_type
= pseudo_func
[i
].type
;
9805 switch (pseudo_type
)
9807 case PSEUDO_FUNC_RELOC
:
9809 if (*input_line_pointer
!= '(')
9811 as_bad ("Expected '('");
9815 ++input_line_pointer
;
9817 if (*input_line_pointer
++ != ')')
9819 as_bad ("Missing ')'");
9822 if (e
->X_op
!= O_symbol
)
9824 if (e
->X_op
!= O_pseudo_fixup
)
9826 as_bad ("Not a symbolic expression");
9829 if (S_GET_VALUE (e
->X_op_symbol
) == FUNC_FPTR_RELATIVE
9830 && i
== FUNC_LT_RELATIVE
)
9831 i
= FUNC_LT_FPTR_RELATIVE
;
9834 as_bad ("Illegal combination of relocation functions");
9838 /* Make sure gas doesn't get rid of local symbols that are used
9840 e
->X_op
= O_pseudo_fixup
;
9841 e
->X_op_symbol
= pseudo_func
[i
].u
.sym
;
9844 case PSEUDO_FUNC_CONST
:
9845 e
->X_op
= O_constant
;
9846 e
->X_add_number
= pseudo_func
[i
].u
.ival
;
9849 case PSEUDO_FUNC_REG
:
9850 e
->X_op
= O_register
;
9851 e
->X_add_number
= pseudo_func
[i
].u
.ival
;
9855 name
= input_line_pointer
- 1;
9857 as_bad ("Unknown pseudo function `%s'", name
);
9863 ++input_line_pointer
;
9865 if (*input_line_pointer
!= ']')
9867 as_bad ("Closing bracket misssing");
9872 if (e
->X_op
!= O_register
)
9873 as_bad ("Register expected as index");
9875 ++input_line_pointer
;
9886 ignore_rest_of_line ();
9889 /* Return 1 if it's OK to adjust a reloc by replacing the symbol with
9890 a section symbol plus some offset. For relocs involving @fptr(),
9891 directives we don't want such adjustments since we need to have the
9892 original symbol's name in the reloc. */
9894 ia64_fix_adjustable (fix
)
9897 /* Prevent all adjustments to global symbols */
9898 if (S_IS_EXTERN (fix
->fx_addsy
) || S_IS_WEAK (fix
->fx_addsy
))
9901 switch (fix
->fx_r_type
)
9903 case BFD_RELOC_IA64_FPTR64I
:
9904 case BFD_RELOC_IA64_FPTR32MSB
:
9905 case BFD_RELOC_IA64_FPTR32LSB
:
9906 case BFD_RELOC_IA64_FPTR64MSB
:
9907 case BFD_RELOC_IA64_FPTR64LSB
:
9908 case BFD_RELOC_IA64_LTOFF_FPTR22
:
9909 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
9919 ia64_force_relocation (fix
)
9922 switch (fix
->fx_r_type
)
9924 case BFD_RELOC_IA64_FPTR64I
:
9925 case BFD_RELOC_IA64_FPTR32MSB
:
9926 case BFD_RELOC_IA64_FPTR32LSB
:
9927 case BFD_RELOC_IA64_FPTR64MSB
:
9928 case BFD_RELOC_IA64_FPTR64LSB
:
9930 case BFD_RELOC_IA64_LTOFF22
:
9931 case BFD_RELOC_IA64_LTOFF64I
:
9932 case BFD_RELOC_IA64_LTOFF_FPTR22
:
9933 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
9934 case BFD_RELOC_IA64_PLTOFF22
:
9935 case BFD_RELOC_IA64_PLTOFF64I
:
9936 case BFD_RELOC_IA64_PLTOFF64MSB
:
9937 case BFD_RELOC_IA64_PLTOFF64LSB
:
9946 /* Decide from what point a pc-relative relocation is relative to,
9947 relative to the pc-relative fixup. Er, relatively speaking. */
9949 ia64_pcrel_from_section (fix
, sec
)
9953 unsigned long off
= fix
->fx_frag
->fr_address
+ fix
->fx_where
;
9955 if (bfd_get_section_flags (stdoutput
, sec
) & SEC_CODE
)
9961 /* This is called whenever some data item (not an instruction) needs a
9962 fixup. We pick the right reloc code depending on the byteorder
9963 currently in effect. */
9965 ia64_cons_fix_new (f
, where
, nbytes
, exp
)
9971 bfd_reloc_code_real_type code
;
9976 /* There are no reloc for 8 and 16 bit quantities, but we allow
9977 them here since they will work fine as long as the expression
9978 is fully defined at the end of the pass over the source file. */
9979 case 1: code
= BFD_RELOC_8
; break;
9980 case 2: code
= BFD_RELOC_16
; break;
9982 if (target_big_endian
)
9983 code
= BFD_RELOC_IA64_DIR32MSB
;
9985 code
= BFD_RELOC_IA64_DIR32LSB
;
9989 /* In 32-bit mode, data8 could mean function descriptors too. */
9990 if (exp
->X_op
== O_pseudo_fixup
9992 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
9993 && !(md
.flags
& EF_IA_64_ABI64
))
9995 if (target_big_endian
)
9996 code
= BFD_RELOC_IA64_IPLTMSB
;
9998 code
= BFD_RELOC_IA64_IPLTLSB
;
9999 exp
->X_op
= O_symbol
;
10003 if (target_big_endian
)
10004 code
= BFD_RELOC_IA64_DIR64MSB
;
10006 code
= BFD_RELOC_IA64_DIR64LSB
;
10011 if (exp
->X_op
== O_pseudo_fixup
10012 && exp
->X_op_symbol
10013 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
)
10015 if (target_big_endian
)
10016 code
= BFD_RELOC_IA64_IPLTMSB
;
10018 code
= BFD_RELOC_IA64_IPLTLSB
;
10020 exp
->X_op
= O_symbol
;
10026 as_bad ("Unsupported fixup size %d", nbytes
);
10027 ignore_rest_of_line ();
10030 if (exp
->X_op
== O_pseudo_fixup
)
10033 exp
->X_op
= O_symbol
;
10034 code
= ia64_gen_real_reloc_type (exp
->X_op_symbol
, code
);
10037 fix
= fix_new_exp (f
, where
, nbytes
, exp
, 0, code
);
10038 /* We need to store the byte order in effect in case we're going
10039 to fix an 8 or 16 bit relocation (for which there no real
10040 relocs available). See md_apply_fix3(). */
10041 fix
->tc_fix_data
.bigendian
= target_big_endian
;
10044 /* Return the actual relocation we wish to associate with the pseudo
10045 reloc described by SYM and R_TYPE. SYM should be one of the
10046 symbols in the pseudo_func array, or NULL. */
10048 static bfd_reloc_code_real_type
10049 ia64_gen_real_reloc_type (sym
, r_type
)
10050 struct symbol
*sym
;
10051 bfd_reloc_code_real_type r_type
;
10053 bfd_reloc_code_real_type
new = 0;
10060 switch (S_GET_VALUE (sym
))
10062 case FUNC_FPTR_RELATIVE
:
10065 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_FPTR64I
; break;
10066 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_FPTR32MSB
; break;
10067 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_FPTR32LSB
; break;
10068 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_FPTR64MSB
; break;
10069 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_FPTR64LSB
; break;
10074 case FUNC_GP_RELATIVE
:
10077 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_GPREL22
; break;
10078 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_GPREL64I
; break;
10079 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_GPREL32MSB
; break;
10080 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_GPREL32LSB
; break;
10081 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_GPREL64MSB
; break;
10082 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_GPREL64LSB
; break;
10087 case FUNC_LT_RELATIVE
:
10090 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_LTOFF22
; break;
10091 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_LTOFF64I
; break;
10096 case FUNC_PC_RELATIVE
:
10099 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PCREL22
; break;
10100 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PCREL64I
; break;
10101 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_PCREL32MSB
; break;
10102 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_PCREL32LSB
; break;
10103 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PCREL64MSB
; break;
10104 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PCREL64LSB
; break;
10109 case FUNC_PLT_RELATIVE
:
10112 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PLTOFF22
; break;
10113 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PLTOFF64I
; break;
10114 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PLTOFF64MSB
;break;
10115 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PLTOFF64LSB
;break;
10120 case FUNC_SEC_RELATIVE
:
10123 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SECREL32MSB
;break;
10124 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SECREL32LSB
;break;
10125 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SECREL64MSB
;break;
10126 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SECREL64LSB
;break;
10131 case FUNC_SEG_RELATIVE
:
10134 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SEGREL32MSB
;break;
10135 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SEGREL32LSB
;break;
10136 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SEGREL64MSB
;break;
10137 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SEGREL64LSB
;break;
10142 case FUNC_LTV_RELATIVE
:
10145 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_LTV32MSB
; break;
10146 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_LTV32LSB
; break;
10147 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_LTV64MSB
; break;
10148 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_LTV64LSB
; break;
10153 case FUNC_LT_FPTR_RELATIVE
:
10156 case BFD_RELOC_IA64_IMM22
:
10157 new = BFD_RELOC_IA64_LTOFF_FPTR22
; break;
10158 case BFD_RELOC_IA64_IMM64
:
10159 new = BFD_RELOC_IA64_LTOFF_FPTR64I
; break;
10165 case FUNC_IPLT_RELOC
:
10171 /* Hmmmm. Should this ever occur? */
10178 /* Here is where generate the appropriate reloc for pseudo relocation
10181 ia64_validate_fix (fix
)
10184 switch (fix
->fx_r_type
)
10186 case BFD_RELOC_IA64_FPTR64I
:
10187 case BFD_RELOC_IA64_FPTR32MSB
:
10188 case BFD_RELOC_IA64_FPTR64LSB
:
10189 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10190 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10191 if (fix
->fx_offset
!= 0)
10192 as_bad_where (fix
->fx_file
, fix
->fx_line
,
10193 "No addend allowed in @fptr() relocation");
10203 fix_insn (fix
, odesc
, value
)
10205 const struct ia64_operand
*odesc
;
10208 bfd_vma insn
[3], t0
, t1
, control_bits
;
10213 slot
= fix
->fx_where
& 0x3;
10214 fixpos
= fix
->fx_frag
->fr_literal
+ (fix
->fx_where
- slot
);
10216 /* Bundles are always in little-endian byte order */
10217 t0
= bfd_getl64 (fixpos
);
10218 t1
= bfd_getl64 (fixpos
+ 8);
10219 control_bits
= t0
& 0x1f;
10220 insn
[0] = (t0
>> 5) & 0x1ffffffffffLL
;
10221 insn
[1] = ((t0
>> 46) & 0x3ffff) | ((t1
& 0x7fffff) << 18);
10222 insn
[2] = (t1
>> 23) & 0x1ffffffffffLL
;
10225 if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU64
)
10227 insn
[1] = (value
>> 22) & 0x1ffffffffffLL
;
10228 insn
[2] |= (((value
& 0x7f) << 13)
10229 | (((value
>> 7) & 0x1ff) << 27)
10230 | (((value
>> 16) & 0x1f) << 22)
10231 | (((value
>> 21) & 0x1) << 21)
10232 | (((value
>> 63) & 0x1) << 36));
10234 else if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU62
)
10236 if (value
& ~0x3fffffffffffffffULL
)
10237 err
= "integer operand out of range";
10238 insn
[1] = (value
>> 21) & 0x1ffffffffffLL
;
10239 insn
[2] |= (((value
& 0xfffff) << 6) | (((value
>> 20) & 0x1) << 36));
10241 else if (odesc
- elf64_ia64_operands
== IA64_OPND_TGT64
)
10244 insn
[1] = ((value
>> 20) & 0x7fffffffffLL
) << 2;
10245 insn
[2] |= ((((value
>> 59) & 0x1) << 36)
10246 | (((value
>> 0) & 0xfffff) << 13));
10249 err
= (*odesc
->insert
) (odesc
, value
, insn
+ slot
);
10252 as_bad_where (fix
->fx_file
, fix
->fx_line
, err
);
10254 t0
= control_bits
| (insn
[0] << 5) | (insn
[1] << 46);
10255 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
10256 number_to_chars_littleendian (fixpos
+ 0, t0
, 8);
10257 number_to_chars_littleendian (fixpos
+ 8, t1
, 8);
10260 /* Attempt to simplify or even eliminate a fixup. The return value is
10261 ignored; perhaps it was once meaningful, but now it is historical.
10262 To indicate that a fixup has been eliminated, set FIXP->FX_DONE.
10264 If fixp->fx_addsy is non-NULL, we'll have to generate a reloc entry
10268 md_apply_fix3 (fix
, valP
, seg
)
10271 segT seg ATTRIBUTE_UNUSED
;
10274 valueT value
= * valP
;
10277 fixpos
= fix
->fx_frag
->fr_literal
+ fix
->fx_where
;
10281 switch (fix
->fx_r_type
)
10283 case BFD_RELOC_IA64_DIR32MSB
:
10284 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL32MSB
;
10288 case BFD_RELOC_IA64_DIR32LSB
:
10289 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL32LSB
;
10293 case BFD_RELOC_IA64_DIR64MSB
:
10294 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL64MSB
;
10298 case BFD_RELOC_IA64_DIR64LSB
:
10299 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL64LSB
;
10309 if (fix
->fx_r_type
== (int) BFD_RELOC_UNUSED
)
10311 /* This must be a TAG13 or TAG13b operand. There are no external
10312 relocs defined for them, so we must give an error. */
10313 as_bad_where (fix
->fx_file
, fix
->fx_line
,
10314 "%s must have a constant value",
10315 elf64_ia64_operands
[fix
->tc_fix_data
.opnd
].desc
);
10320 /* ??? This is a hack copied from tc-i386.c to make PCREL relocs
10321 work. There should be a better way to handle this. */
10323 fix
->fx_offset
+= fix
->fx_where
+ fix
->fx_frag
->fr_address
;
10325 else if (fix
->tc_fix_data
.opnd
== IA64_OPND_NIL
)
10327 if (fix
->tc_fix_data
.bigendian
)
10328 number_to_chars_bigendian (fixpos
, value
, fix
->fx_size
);
10330 number_to_chars_littleendian (fixpos
, value
, fix
->fx_size
);
10335 fix_insn (fix
, elf64_ia64_operands
+ fix
->tc_fix_data
.opnd
, value
);
10340 /* Generate the BFD reloc to be stuck in the object file from the
10341 fixup used internally in the assembler. */
10344 tc_gen_reloc (sec
, fixp
)
10345 asection
*sec ATTRIBUTE_UNUSED
;
10350 reloc
= xmalloc (sizeof (*reloc
));
10351 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
10352 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
10353 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
10354 reloc
->addend
= fixp
->fx_offset
;
10355 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
10359 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
10360 "Cannot represent %s relocation in object file",
10361 bfd_get_reloc_code_name (fixp
->fx_r_type
));
10366 /* Turn a string in input_line_pointer into a floating point constant
10367 of type TYPE, and store the appropriate bytes in *LIT. The number
10368 of LITTLENUMS emitted is stored in *SIZE. An error message is
10369 returned, or NULL on OK. */
10371 #define MAX_LITTLENUMS 5
10374 md_atof (type
, lit
, size
)
10379 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
10380 LITTLENUM_TYPE
*word
;
10410 return "Bad call to MD_ATOF()";
10412 t
= atof_ieee (input_line_pointer
, type
, words
);
10414 input_line_pointer
= t
;
10415 *size
= prec
* sizeof (LITTLENUM_TYPE
);
10417 for (word
= words
+ prec
- 1; prec
--;)
10419 md_number_to_chars (lit
, (long) (*word
--), sizeof (LITTLENUM_TYPE
));
10420 lit
+= sizeof (LITTLENUM_TYPE
);
10425 /* Round up a section's size to the appropriate boundary. */
10427 md_section_align (seg
, size
)
10431 int align
= bfd_get_section_alignment (stdoutput
, seg
);
10432 valueT mask
= ((valueT
) 1 << align
) - 1;
10434 return (size
+ mask
) & ~mask
;
10437 /* Handle ia64 specific semantics of the align directive. */
10440 ia64_md_do_align (n
, fill
, len
, max
)
10441 int n ATTRIBUTE_UNUSED
;
10442 const char *fill ATTRIBUTE_UNUSED
;
10443 int len ATTRIBUTE_UNUSED
;
10444 int max ATTRIBUTE_UNUSED
;
10446 if (subseg_text_p (now_seg
))
10447 ia64_flush_insns ();
10450 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
10451 of an rs_align_code fragment. */
10454 ia64_handle_align (fragp
)
10457 /* Use mfi bundle of nops with no stop bits. */
10458 static const unsigned char be_nop
[]
10459 = { 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
10460 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c};
10461 static const unsigned char le_nop
[]
10462 = { 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10463 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00};
10468 if (fragp
->fr_type
!= rs_align_code
)
10471 bytes
= fragp
->fr_next
->fr_address
- fragp
->fr_address
- fragp
->fr_fix
;
10472 p
= fragp
->fr_literal
+ fragp
->fr_fix
;
10474 /* Make sure we are on a 16-byte boundary, in case someone has been
10475 putting data into a text section. */
10478 int fix
= bytes
& 15;
10479 memset (p
, 0, fix
);
10482 fragp
->fr_fix
+= fix
;
10485 memcpy (p
, (target_big_endian
? be_nop
: le_nop
), 16);
10486 fragp
->fr_var
= 16;