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
,
91 FUNC_LT_FPTR_RELATIVE
,
101 REG_FR
= (REG_GR
+ 128),
102 REG_AR
= (REG_FR
+ 128),
103 REG_CR
= (REG_AR
+ 128),
104 REG_P
= (REG_CR
+ 128),
105 REG_BR
= (REG_P
+ 64),
106 REG_IP
= (REG_BR
+ 8),
113 /* The following are pseudo-registers for use by gas only. */
125 /* The following pseudo-registers are used for unwind directives only: */
133 DYNREG_GR
= 0, /* dynamic general purpose register */
134 DYNREG_FR
, /* dynamic floating point register */
135 DYNREG_PR
, /* dynamic predicate register */
139 enum operand_match_result
142 OPERAND_OUT_OF_RANGE
,
146 /* On the ia64, we can't know the address of a text label until the
147 instructions are packed into a bundle. To handle this, we keep
148 track of the list of labels that appear in front of each
152 struct label_fix
*next
;
156 extern int target_big_endian
;
158 /* Characters which always start a comment. */
159 const char comment_chars
[] = "";
161 /* Characters which start a comment at the beginning of a line. */
162 const char line_comment_chars
[] = "#";
164 /* Characters which may be used to separate multiple commands on a
166 const char line_separator_chars
[] = ";";
168 /* Characters which are used to indicate an exponent in a floating
170 const char EXP_CHARS
[] = "eE";
172 /* Characters which mean that a number is a floating point constant,
174 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
176 /* ia64-specific option processing: */
178 const char *md_shortopts
= "m:N:x::";
180 struct option md_longopts
[] =
182 #define OPTION_MCONSTANT_GP (OPTION_MD_BASE + 1)
183 {"mconstant-gp", no_argument
, NULL
, OPTION_MCONSTANT_GP
},
184 #define OPTION_MAUTO_PIC (OPTION_MD_BASE + 2)
185 {"mauto-pic", no_argument
, NULL
, OPTION_MAUTO_PIC
}
188 size_t md_longopts_size
= sizeof (md_longopts
);
192 struct hash_control
*pseudo_hash
; /* pseudo opcode hash table */
193 struct hash_control
*reg_hash
; /* register name hash table */
194 struct hash_control
*dynreg_hash
; /* dynamic register hash table */
195 struct hash_control
*const_hash
; /* constant hash table */
196 struct hash_control
*entry_hash
; /* code entry hint hash table */
198 symbolS
*regsym
[REG_NUM
];
200 /* If X_op is != O_absent, the registername for the instruction's
201 qualifying predicate. If NULL, p0 is assumed for instructions
202 that are predicatable. */
209 explicit_mode
: 1, /* which mode we're in */
210 default_explicit_mode
: 1, /* which mode is the default */
211 mode_explicitly_set
: 1, /* was the current mode explicitly set? */
213 keep_pending_output
: 1;
215 /* Each bundle consists of up to three instructions. We keep
216 track of four most recent instructions so we can correctly set
217 the end_of_insn_group for the last instruction in a bundle. */
219 int num_slots_in_use
;
223 end_of_insn_group
: 1,
224 manual_bundling_on
: 1,
225 manual_bundling_off
: 1;
226 signed char user_template
; /* user-selected template, if any */
227 unsigned char qp_regno
; /* qualifying predicate */
228 /* This duplicates a good fraction of "struct fix" but we
229 can't use a "struct fix" instead since we can't call
230 fix_new_exp() until we know the address of the instruction. */
234 bfd_reloc_code_real_type code
;
235 enum ia64_opnd opnd
; /* type of operand in need of fix */
236 unsigned int is_pcrel
: 1; /* is operand pc-relative? */
237 expressionS expr
; /* the value to be inserted */
239 fixup
[2]; /* at most two fixups per insn */
240 struct ia64_opcode
*idesc
;
241 struct label_fix
*label_fixups
;
242 struct label_fix
*tag_fixups
;
243 struct unw_rec_list
*unwind_record
; /* Unwind directive. */
246 unsigned int src_line
;
247 struct dwarf2_line_info debug_line
;
255 struct dynreg
*next
; /* next dynamic register */
257 unsigned short base
; /* the base register number */
258 unsigned short num_regs
; /* # of registers in this set */
260 *dynreg
[DYNREG_NUM_TYPES
], in
, loc
, out
, rot
;
262 flagword flags
; /* ELF-header flags */
265 unsigned hint
:1; /* is this hint currently valid? */
266 bfd_vma offset
; /* mem.offset offset */
267 bfd_vma base
; /* mem.offset base */
270 int path
; /* number of alt. entry points seen */
271 const char **entry_labels
; /* labels of all alternate paths in
272 the current DV-checking block. */
273 int maxpaths
; /* size currently allocated for
275 /* Support for hardware errata workarounds. */
277 /* Record data about the last three insn groups. */
280 /* B-step workaround.
281 For each predicate register, this is set if the corresponding insn
282 group conditionally sets this register with one of the affected
285 /* B-step workaround.
286 For each general register, this is set if the corresponding insn
287 a) is conditional one one of the predicate registers for which
288 P_REG_SET is 1 in the corresponding entry of the previous group,
289 b) sets this general register with one of the affected
291 int g_reg_set_conditionally
[128];
295 int pointer_size
; /* size in bytes of a pointer */
296 int pointer_size_shift
; /* shift size of a pointer for alignment */
300 /* application registers: */
306 #define AR_BSPSTORE 18
321 {"ar.k0", 0}, {"ar.k1", 1}, {"ar.k2", 2}, {"ar.k3", 3},
322 {"ar.k4", 4}, {"ar.k5", 5}, {"ar.k6", 6}, {"ar.k7", 7},
323 {"ar.rsc", 16}, {"ar.bsp", 17},
324 {"ar.bspstore", 18}, {"ar.rnat", 19},
325 {"ar.fcr", 21}, {"ar.eflag", 24},
326 {"ar.csd", 25}, {"ar.ssd", 26},
327 {"ar.cflg", 27}, {"ar.fsr", 28},
328 {"ar.fir", 29}, {"ar.fdr", 30},
329 {"ar.ccv", 32}, {"ar.unat", 36},
330 {"ar.fpsr", 40}, {"ar.itc", 44},
331 {"ar.pfs", 64}, {"ar.lc", 65},
352 /* control registers: */
394 static const struct const_desc
401 /* PSR constant masks: */
404 {"psr.be", ((valueT
) 1) << 1},
405 {"psr.up", ((valueT
) 1) << 2},
406 {"psr.ac", ((valueT
) 1) << 3},
407 {"psr.mfl", ((valueT
) 1) << 4},
408 {"psr.mfh", ((valueT
) 1) << 5},
410 {"psr.ic", ((valueT
) 1) << 13},
411 {"psr.i", ((valueT
) 1) << 14},
412 {"psr.pk", ((valueT
) 1) << 15},
414 {"psr.dt", ((valueT
) 1) << 17},
415 {"psr.dfl", ((valueT
) 1) << 18},
416 {"psr.dfh", ((valueT
) 1) << 19},
417 {"psr.sp", ((valueT
) 1) << 20},
418 {"psr.pp", ((valueT
) 1) << 21},
419 {"psr.di", ((valueT
) 1) << 22},
420 {"psr.si", ((valueT
) 1) << 23},
421 {"psr.db", ((valueT
) 1) << 24},
422 {"psr.lp", ((valueT
) 1) << 25},
423 {"psr.tb", ((valueT
) 1) << 26},
424 {"psr.rt", ((valueT
) 1) << 27},
425 /* 28-31: reserved */
426 /* 32-33: cpl (current privilege level) */
427 {"psr.is", ((valueT
) 1) << 34},
428 {"psr.mc", ((valueT
) 1) << 35},
429 {"psr.it", ((valueT
) 1) << 36},
430 {"psr.id", ((valueT
) 1) << 37},
431 {"psr.da", ((valueT
) 1) << 38},
432 {"psr.dd", ((valueT
) 1) << 39},
433 {"psr.ss", ((valueT
) 1) << 40},
434 /* 41-42: ri (restart instruction) */
435 {"psr.ed", ((valueT
) 1) << 43},
436 {"psr.bn", ((valueT
) 1) << 44},
439 /* indirect register-sets/memory: */
448 { "CPUID", IND_CPUID
},
449 { "cpuid", IND_CPUID
},
461 /* Pseudo functions used to indicate relocation types (these functions
462 start with an at sign (@). */
484 /* reloc pseudo functions (these must come first!): */
485 { "dtpmod", PSEUDO_FUNC_RELOC
, { 0 } },
486 { "dtprel", PSEUDO_FUNC_RELOC
, { 0 } },
487 { "fptr", PSEUDO_FUNC_RELOC
, { 0 } },
488 { "gprel", PSEUDO_FUNC_RELOC
, { 0 } },
489 { "ltoff", PSEUDO_FUNC_RELOC
, { 0 } },
490 { "pcrel", PSEUDO_FUNC_RELOC
, { 0 } },
491 { "pltoff", PSEUDO_FUNC_RELOC
, { 0 } },
492 { "secrel", PSEUDO_FUNC_RELOC
, { 0 } },
493 { "segrel", PSEUDO_FUNC_RELOC
, { 0 } },
494 { "tprel", PSEUDO_FUNC_RELOC
, { 0 } },
495 { "ltv", PSEUDO_FUNC_RELOC
, { 0 } },
496 { "", 0, { 0 } }, /* placeholder for FUNC_LT_FPTR_RELATIVE */
497 { "", 0, { 0 } }, /* placeholder for FUNC_LT_DTP_MODULE */
498 { "", 0, { 0 } }, /* placeholder for FUNC_LT_DTP_RELATIVE */
499 { "", 0, { 0 } }, /* placeholder for FUNC_LT_TP_RELATIVE */
500 { "iplt", PSEUDO_FUNC_RELOC
, { 0 } },
502 /* mbtype4 constants: */
503 { "alt", PSEUDO_FUNC_CONST
, { 0xa } },
504 { "brcst", PSEUDO_FUNC_CONST
, { 0x0 } },
505 { "mix", PSEUDO_FUNC_CONST
, { 0x8 } },
506 { "rev", PSEUDO_FUNC_CONST
, { 0xb } },
507 { "shuf", PSEUDO_FUNC_CONST
, { 0x9 } },
509 /* fclass constants: */
510 { "nat", PSEUDO_FUNC_CONST
, { 0x100 } },
511 { "qnan", PSEUDO_FUNC_CONST
, { 0x080 } },
512 { "snan", PSEUDO_FUNC_CONST
, { 0x040 } },
513 { "pos", PSEUDO_FUNC_CONST
, { 0x001 } },
514 { "neg", PSEUDO_FUNC_CONST
, { 0x002 } },
515 { "zero", PSEUDO_FUNC_CONST
, { 0x004 } },
516 { "unorm", PSEUDO_FUNC_CONST
, { 0x008 } },
517 { "norm", PSEUDO_FUNC_CONST
, { 0x010 } },
518 { "inf", PSEUDO_FUNC_CONST
, { 0x020 } },
520 { "natval", PSEUDO_FUNC_CONST
, { 0x100 } }, /* old usage */
522 /* unwind-related constants: */
523 { "svr4", PSEUDO_FUNC_CONST
, { 0 } },
524 { "hpux", PSEUDO_FUNC_CONST
, { 1 } },
525 { "nt", PSEUDO_FUNC_CONST
, { 2 } },
527 /* unwind-related registers: */
528 { "priunat",PSEUDO_FUNC_REG
, { REG_PRIUNAT
} }
531 /* 41-bit nop opcodes (one per unit): */
532 static const bfd_vma nop
[IA64_NUM_UNITS
] =
534 0x0000000000LL
, /* NIL => break 0 */
535 0x0008000000LL
, /* I-unit nop */
536 0x0008000000LL
, /* M-unit nop */
537 0x4000000000LL
, /* B-unit nop */
538 0x0008000000LL
, /* F-unit nop */
539 0x0008000000LL
, /* L-"unit" nop */
540 0x0008000000LL
, /* X-unit nop */
543 /* Can't be `const' as it's passed to input routines (which have the
544 habit of setting temporary sentinels. */
545 static char special_section_name
[][20] =
547 {".bss"}, {".sbss"}, {".sdata"}, {".rodata"}, {".comment"},
548 {".IA_64.unwind"}, {".IA_64.unwind_info"},
549 {".init_array"}, {".fini_array"}
552 static char *special_linkonce_name
[] =
554 ".gnu.linkonce.ia64unw.", ".gnu.linkonce.ia64unwi."
557 /* The best template for a particular sequence of up to three
559 #define N IA64_NUM_TYPES
560 static unsigned char best_template
[N
][N
][N
];
563 /* Resource dependencies currently in effect */
565 int depind
; /* dependency index */
566 const struct ia64_dependency
*dependency
; /* actual dependency */
567 unsigned specific
:1, /* is this a specific bit/regno? */
568 link_to_qp_branch
:1; /* will a branch on the same QP clear it?*/
569 int index
; /* specific regno/bit within dependency */
570 int note
; /* optional qualifying note (0 if none) */
574 int insn_srlz
; /* current insn serialization state */
575 int data_srlz
; /* current data serialization state */
576 int qp_regno
; /* qualifying predicate for this usage */
577 char *file
; /* what file marked this dependency */
578 unsigned int line
; /* what line marked this dependency */
579 struct mem_offset mem_offset
; /* optional memory offset hint */
580 enum { CMP_NONE
, CMP_OR
, CMP_AND
} cmp_type
; /* OR or AND compare? */
581 int path
; /* corresponding code entry index */
583 static int regdepslen
= 0;
584 static int regdepstotlen
= 0;
585 static const char *dv_mode
[] = { "RAW", "WAW", "WAR" };
586 static const char *dv_sem
[] = { "none", "implied", "impliedf",
587 "data", "instr", "specific", "stop", "other" };
588 static const char *dv_cmp_type
[] = { "none", "OR", "AND" };
590 /* Current state of PR mutexation */
591 static struct qpmutex
{
594 } *qp_mutexes
= NULL
; /* QP mutex bitmasks */
595 static int qp_mutexeslen
= 0;
596 static int qp_mutexestotlen
= 0;
597 static valueT qp_safe_across_calls
= 0;
599 /* Current state of PR implications */
600 static struct qp_imply
{
603 unsigned p2_branched
:1;
605 } *qp_implies
= NULL
;
606 static int qp_implieslen
= 0;
607 static int qp_impliestotlen
= 0;
609 /* Keep track of static GR values so that indirect register usage can
610 sometimes be tracked. */
615 } gr_values
[128] = {{ 1, 0, 0 }};
617 /* These are the routines required to output the various types of
620 /* A slot_number is a frag address plus the slot index (0-2). We use the
621 frag address here so that if there is a section switch in the middle of
622 a function, then instructions emitted to a different section are not
623 counted. Since there may be more than one frag for a function, this
624 means we also need to keep track of which frag this address belongs to
625 so we can compute inter-frag distances. This also nicely solves the
626 problem with nops emitted for align directives, which can't easily be
627 counted, but can easily be derived from frag sizes. */
629 typedef struct unw_rec_list
{
631 unsigned long slot_number
;
633 struct unw_rec_list
*next
;
636 #define SLOT_NUM_NOT_SET (unsigned)-1
638 /* Linked list of saved prologue counts. A very poor
639 implementation of a map from label numbers to prologue counts. */
640 typedef struct label_prologue_count
642 struct label_prologue_count
*next
;
643 unsigned long label_number
;
644 unsigned int prologue_count
;
645 } label_prologue_count
;
649 unsigned long next_slot_number
;
650 fragS
*next_slot_frag
;
652 /* Maintain a list of unwind entries for the current function. */
656 /* Any unwind entires that should be attached to the current slot
657 that an insn is being constructed for. */
658 unw_rec_list
*current_entry
;
660 /* These are used to create the unwind table entry for this function. */
663 symbolS
*info
; /* pointer to unwind info */
664 symbolS
*personality_routine
;
666 subsegT saved_text_subseg
;
667 unsigned int force_unwind_entry
: 1; /* force generation of unwind entry? */
669 /* TRUE if processing unwind directives in a prologue region. */
672 unsigned int prologue_count
; /* number of .prologues seen so far */
673 /* Prologue counts at previous .label_state directives. */
674 struct label_prologue_count
* saved_prologue_counts
;
677 typedef void (*vbyte_func
) PARAMS ((int, char *, char *));
679 /* Forward delarations: */
680 static int ar_is_in_integer_unit
PARAMS ((int regnum
));
681 static void set_section
PARAMS ((char *name
));
682 static unsigned int set_regstack
PARAMS ((unsigned int, unsigned int,
683 unsigned int, unsigned int));
684 static void dot_radix
PARAMS ((int));
685 static void dot_special_section
PARAMS ((int));
686 static void dot_proc
PARAMS ((int));
687 static void dot_fframe
PARAMS ((int));
688 static void dot_vframe
PARAMS ((int));
689 static void dot_vframesp
PARAMS ((int));
690 static void dot_vframepsp
PARAMS ((int));
691 static void dot_save
PARAMS ((int));
692 static void dot_restore
PARAMS ((int));
693 static void dot_restorereg
PARAMS ((int));
694 static void dot_restorereg_p
PARAMS ((int));
695 static void dot_handlerdata
PARAMS ((int));
696 static void dot_unwentry
PARAMS ((int));
697 static void dot_altrp
PARAMS ((int));
698 static void dot_savemem
PARAMS ((int));
699 static void dot_saveg
PARAMS ((int));
700 static void dot_savef
PARAMS ((int));
701 static void dot_saveb
PARAMS ((int));
702 static void dot_savegf
PARAMS ((int));
703 static void dot_spill
PARAMS ((int));
704 static void dot_spillreg
PARAMS ((int));
705 static void dot_spillmem
PARAMS ((int));
706 static void dot_spillreg_p
PARAMS ((int));
707 static void dot_spillmem_p
PARAMS ((int));
708 static void dot_label_state
PARAMS ((int));
709 static void dot_copy_state
PARAMS ((int));
710 static void dot_unwabi
PARAMS ((int));
711 static void dot_personality
PARAMS ((int));
712 static void dot_body
PARAMS ((int));
713 static void dot_prologue
PARAMS ((int));
714 static void dot_endp
PARAMS ((int));
715 static void dot_template
PARAMS ((int));
716 static void dot_regstk
PARAMS ((int));
717 static void dot_rot
PARAMS ((int));
718 static void dot_byteorder
PARAMS ((int));
719 static void dot_psr
PARAMS ((int));
720 static void dot_alias
PARAMS ((int));
721 static void dot_ln
PARAMS ((int));
722 static char *parse_section_name
PARAMS ((void));
723 static void dot_xdata
PARAMS ((int));
724 static void stmt_float_cons
PARAMS ((int));
725 static void stmt_cons_ua
PARAMS ((int));
726 static void dot_xfloat_cons
PARAMS ((int));
727 static void dot_xstringer
PARAMS ((int));
728 static void dot_xdata_ua
PARAMS ((int));
729 static void dot_xfloat_cons_ua
PARAMS ((int));
730 static void print_prmask
PARAMS ((valueT mask
));
731 static void dot_pred_rel
PARAMS ((int));
732 static void dot_reg_val
PARAMS ((int));
733 static void dot_dv_mode
PARAMS ((int));
734 static void dot_entry
PARAMS ((int));
735 static void dot_mem_offset
PARAMS ((int));
736 static void add_unwind_entry
PARAMS((unw_rec_list
*ptr
));
737 static symbolS
*declare_register
PARAMS ((const char *name
, int regnum
));
738 static void declare_register_set
PARAMS ((const char *, int, int));
739 static unsigned int operand_width
PARAMS ((enum ia64_opnd
));
740 static enum operand_match_result operand_match
PARAMS ((const struct ia64_opcode
*idesc
,
743 static int parse_operand
PARAMS ((expressionS
*e
));
744 static struct ia64_opcode
* parse_operands
PARAMS ((struct ia64_opcode
*));
745 static int errata_nop_necessary_p
PARAMS ((struct slot
*, enum ia64_unit
));
746 static void build_insn
PARAMS ((struct slot
*, bfd_vma
*));
747 static void emit_one_bundle
PARAMS ((void));
748 static void fix_insn
PARAMS ((fixS
*, const struct ia64_operand
*, valueT
));
749 static bfd_reloc_code_real_type ia64_gen_real_reloc_type
PARAMS ((struct symbol
*sym
,
750 bfd_reloc_code_real_type r_type
));
751 static void insn_group_break
PARAMS ((int, int, int));
752 static void mark_resource
PARAMS ((struct ia64_opcode
*, const struct ia64_dependency
*,
753 struct rsrc
*, int depind
, int path
));
754 static void add_qp_mutex
PARAMS((valueT mask
));
755 static void add_qp_imply
PARAMS((int p1
, int p2
));
756 static void clear_qp_branch_flag
PARAMS((valueT mask
));
757 static void clear_qp_mutex
PARAMS((valueT mask
));
758 static void clear_qp_implies
PARAMS((valueT p1_mask
, valueT p2_mask
));
759 static int has_suffix_p
PARAMS((const char *, const char *));
760 static void clear_register_values
PARAMS ((void));
761 static void print_dependency
PARAMS ((const char *action
, int depind
));
762 static void instruction_serialization
PARAMS ((void));
763 static void data_serialization
PARAMS ((void));
764 static void remove_marked_resource
PARAMS ((struct rsrc
*));
765 static int is_conditional_branch
PARAMS ((struct ia64_opcode
*));
766 static int is_taken_branch
PARAMS ((struct ia64_opcode
*));
767 static int is_interruption_or_rfi
PARAMS ((struct ia64_opcode
*));
768 static int depends_on
PARAMS ((int, struct ia64_opcode
*));
769 static int specify_resource
PARAMS ((const struct ia64_dependency
*,
770 struct ia64_opcode
*, int, struct rsrc
[], int, int));
771 static int check_dv
PARAMS((struct ia64_opcode
*idesc
));
772 static void check_dependencies
PARAMS((struct ia64_opcode
*));
773 static void mark_resources
PARAMS((struct ia64_opcode
*));
774 static void update_dependencies
PARAMS((struct ia64_opcode
*));
775 static void note_register_values
PARAMS((struct ia64_opcode
*));
776 static int qp_mutex
PARAMS ((int, int, int));
777 static int resources_match
PARAMS ((struct rsrc
*, struct ia64_opcode
*, int, int, int));
778 static void output_vbyte_mem
PARAMS ((int, char *, char *));
779 static void count_output
PARAMS ((int, char *, char *));
780 static void output_R1_format
PARAMS ((vbyte_func
, unw_record_type
, int));
781 static void output_R2_format
PARAMS ((vbyte_func
, int, int, unsigned long));
782 static void output_R3_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
783 static void output_P1_format
PARAMS ((vbyte_func
, int));
784 static void output_P2_format
PARAMS ((vbyte_func
, int, int));
785 static void output_P3_format
PARAMS ((vbyte_func
, unw_record_type
, int));
786 static void output_P4_format
PARAMS ((vbyte_func
, unsigned char *, unsigned long));
787 static void output_P5_format
PARAMS ((vbyte_func
, int, unsigned long));
788 static void output_P6_format
PARAMS ((vbyte_func
, unw_record_type
, int));
789 static void output_P7_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long, unsigned long));
790 static void output_P8_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
791 static void output_P9_format
PARAMS ((vbyte_func
, int, int));
792 static void output_P10_format
PARAMS ((vbyte_func
, int, int));
793 static void output_B1_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
794 static void output_B2_format
PARAMS ((vbyte_func
, unsigned long, unsigned long));
795 static void output_B3_format
PARAMS ((vbyte_func
, unsigned long, unsigned long));
796 static void output_B4_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
797 static char format_ab_reg
PARAMS ((int, int));
798 static void output_X1_format
PARAMS ((vbyte_func
, unw_record_type
, int, int, unsigned long,
800 static void output_X2_format
PARAMS ((vbyte_func
, int, int, int, int, int, unsigned long));
801 static void output_X3_format
PARAMS ((vbyte_func
, unw_record_type
, int, int, int, unsigned long,
803 static void output_X4_format
PARAMS ((vbyte_func
, int, int, int, int, int, int, unsigned long));
804 static void free_list_records
PARAMS ((unw_rec_list
*));
805 static unw_rec_list
*output_prologue
PARAMS ((void));
806 static unw_rec_list
*output_prologue_gr
PARAMS ((unsigned int, unsigned int));
807 static unw_rec_list
*output_body
PARAMS ((void));
808 static unw_rec_list
*output_mem_stack_f
PARAMS ((unsigned int));
809 static unw_rec_list
*output_mem_stack_v
PARAMS ((void));
810 static unw_rec_list
*output_psp_gr
PARAMS ((unsigned int));
811 static unw_rec_list
*output_psp_sprel
PARAMS ((unsigned int));
812 static unw_rec_list
*output_rp_when
PARAMS ((void));
813 static unw_rec_list
*output_rp_gr
PARAMS ((unsigned int));
814 static unw_rec_list
*output_rp_br
PARAMS ((unsigned int));
815 static unw_rec_list
*output_rp_psprel
PARAMS ((unsigned int));
816 static unw_rec_list
*output_rp_sprel
PARAMS ((unsigned int));
817 static unw_rec_list
*output_pfs_when
PARAMS ((void));
818 static unw_rec_list
*output_pfs_gr
PARAMS ((unsigned int));
819 static unw_rec_list
*output_pfs_psprel
PARAMS ((unsigned int));
820 static unw_rec_list
*output_pfs_sprel
PARAMS ((unsigned int));
821 static unw_rec_list
*output_preds_when
PARAMS ((void));
822 static unw_rec_list
*output_preds_gr
PARAMS ((unsigned int));
823 static unw_rec_list
*output_preds_psprel
PARAMS ((unsigned int));
824 static unw_rec_list
*output_preds_sprel
PARAMS ((unsigned int));
825 static unw_rec_list
*output_fr_mem
PARAMS ((unsigned int));
826 static unw_rec_list
*output_frgr_mem
PARAMS ((unsigned int, unsigned int));
827 static unw_rec_list
*output_gr_gr
PARAMS ((unsigned int, unsigned int));
828 static unw_rec_list
*output_gr_mem
PARAMS ((unsigned int));
829 static unw_rec_list
*output_br_mem
PARAMS ((unsigned int));
830 static unw_rec_list
*output_br_gr
PARAMS ((unsigned int, unsigned int));
831 static unw_rec_list
*output_spill_base
PARAMS ((unsigned int));
832 static unw_rec_list
*output_unat_when
PARAMS ((void));
833 static unw_rec_list
*output_unat_gr
PARAMS ((unsigned int));
834 static unw_rec_list
*output_unat_psprel
PARAMS ((unsigned int));
835 static unw_rec_list
*output_unat_sprel
PARAMS ((unsigned int));
836 static unw_rec_list
*output_lc_when
PARAMS ((void));
837 static unw_rec_list
*output_lc_gr
PARAMS ((unsigned int));
838 static unw_rec_list
*output_lc_psprel
PARAMS ((unsigned int));
839 static unw_rec_list
*output_lc_sprel
PARAMS ((unsigned int));
840 static unw_rec_list
*output_fpsr_when
PARAMS ((void));
841 static unw_rec_list
*output_fpsr_gr
PARAMS ((unsigned int));
842 static unw_rec_list
*output_fpsr_psprel
PARAMS ((unsigned int));
843 static unw_rec_list
*output_fpsr_sprel
PARAMS ((unsigned int));
844 static unw_rec_list
*output_priunat_when_gr
PARAMS ((void));
845 static unw_rec_list
*output_priunat_when_mem
PARAMS ((void));
846 static unw_rec_list
*output_priunat_gr
PARAMS ((unsigned int));
847 static unw_rec_list
*output_priunat_psprel
PARAMS ((unsigned int));
848 static unw_rec_list
*output_priunat_sprel
PARAMS ((unsigned int));
849 static unw_rec_list
*output_bsp_when
PARAMS ((void));
850 static unw_rec_list
*output_bsp_gr
PARAMS ((unsigned int));
851 static unw_rec_list
*output_bsp_psprel
PARAMS ((unsigned int));
852 static unw_rec_list
*output_bsp_sprel
PARAMS ((unsigned int));
853 static unw_rec_list
*output_bspstore_when
PARAMS ((void));
854 static unw_rec_list
*output_bspstore_gr
PARAMS ((unsigned int));
855 static unw_rec_list
*output_bspstore_psprel
PARAMS ((unsigned int));
856 static unw_rec_list
*output_bspstore_sprel
PARAMS ((unsigned int));
857 static unw_rec_list
*output_rnat_when
PARAMS ((void));
858 static unw_rec_list
*output_rnat_gr
PARAMS ((unsigned int));
859 static unw_rec_list
*output_rnat_psprel
PARAMS ((unsigned int));
860 static unw_rec_list
*output_rnat_sprel
PARAMS ((unsigned int));
861 static unw_rec_list
*output_unwabi
PARAMS ((unsigned long, unsigned long));
862 static unw_rec_list
*output_epilogue
PARAMS ((unsigned long));
863 static unw_rec_list
*output_label_state
PARAMS ((unsigned long));
864 static unw_rec_list
*output_copy_state
PARAMS ((unsigned long));
865 static unw_rec_list
*output_spill_psprel
PARAMS ((unsigned int, unsigned int, unsigned int));
866 static unw_rec_list
*output_spill_sprel
PARAMS ((unsigned int, unsigned int, unsigned int));
867 static unw_rec_list
*output_spill_psprel_p
PARAMS ((unsigned int, unsigned int, unsigned int,
869 static unw_rec_list
*output_spill_sprel_p
PARAMS ((unsigned int, unsigned int, unsigned int,
871 static unw_rec_list
*output_spill_reg
PARAMS ((unsigned int, unsigned int, unsigned int,
873 static unw_rec_list
*output_spill_reg_p
PARAMS ((unsigned int, unsigned int, unsigned int,
874 unsigned int, unsigned int));
875 static void process_one_record
PARAMS ((unw_rec_list
*, vbyte_func
));
876 static void process_unw_records
PARAMS ((unw_rec_list
*, vbyte_func
));
877 static int calc_record_size
PARAMS ((unw_rec_list
*));
878 static void set_imask
PARAMS ((unw_rec_list
*, unsigned long, unsigned long, unsigned int));
879 static int count_bits
PARAMS ((unsigned long));
880 static unsigned long slot_index
PARAMS ((unsigned long, fragS
*,
881 unsigned long, fragS
*));
882 static unw_rec_list
*optimize_unw_records
PARAMS ((unw_rec_list
*));
883 static void fixup_unw_records
PARAMS ((unw_rec_list
*));
884 static int output_unw_records
PARAMS ((unw_rec_list
*, void **));
885 static int convert_expr_to_ab_reg
PARAMS ((expressionS
*, unsigned int *, unsigned int *));
886 static int convert_expr_to_xy_reg
PARAMS ((expressionS
*, unsigned int *, unsigned int *));
887 static int generate_unwind_image
PARAMS ((const char *));
888 static unsigned int get_saved_prologue_count
PARAMS ((unsigned long));
889 static void save_prologue_count
PARAMS ((unsigned long, unsigned int));
890 static void free_saved_prologue_counts
PARAMS ((void));
892 /* Build the unwind section name by appending the (possibly stripped)
893 text section NAME to the unwind PREFIX. The resulting string
894 pointer is assigned to RESULT. The string is allocated on the
895 stack, so this must be a macro... */
896 #define make_unw_section_name(special, text_name, result) \
898 const char *_prefix = special_section_name[special]; \
899 const char *_suffix = text_name; \
900 size_t _prefix_len, _suffix_len; \
902 if (strncmp (text_name, ".gnu.linkonce.t.", \
903 sizeof (".gnu.linkonce.t.") - 1) == 0) \
905 _prefix = special_linkonce_name[special - SPECIAL_SECTION_UNWIND]; \
906 _suffix += sizeof (".gnu.linkonce.t.") - 1; \
908 _prefix_len = strlen (_prefix), _suffix_len = strlen (_suffix); \
909 _result = alloca (_prefix_len + _suffix_len + 1); \
910 memcpy (_result, _prefix, _prefix_len); \
911 memcpy (_result + _prefix_len, _suffix, _suffix_len); \
912 _result[_prefix_len + _suffix_len] = '\0'; \
917 /* Determine if application register REGNUM resides in the integer
918 unit (as opposed to the memory unit). */
920 ar_is_in_integer_unit (reg
)
925 return (reg
== 64 /* pfs */
926 || reg
== 65 /* lc */
927 || reg
== 66 /* ec */
928 /* ??? ias accepts and puts these in the integer unit. */
929 || (reg
>= 112 && reg
<= 127));
932 /* Switch to section NAME and create section if necessary. It's
933 rather ugly that we have to manipulate input_line_pointer but I
934 don't see any other way to accomplish the same thing without
935 changing obj-elf.c (which may be the Right Thing, in the end). */
940 char *saved_input_line_pointer
;
942 saved_input_line_pointer
= input_line_pointer
;
943 input_line_pointer
= name
;
945 input_line_pointer
= saved_input_line_pointer
;
948 /* Map 's' to SHF_IA_64_SHORT. */
951 ia64_elf_section_letter (letter
, ptr_msg
)
956 return SHF_IA_64_SHORT
;
958 *ptr_msg
= _("Bad .section directive: want a,s,w,x,M,S,G,T in string");
962 /* Map SHF_IA_64_SHORT to SEC_SMALL_DATA. */
965 ia64_elf_section_flags (flags
, attr
, type
)
967 int attr
, type ATTRIBUTE_UNUSED
;
969 if (attr
& SHF_IA_64_SHORT
)
970 flags
|= SEC_SMALL_DATA
;
975 ia64_elf_section_type (str
, len
)
979 #define STREQ(s) ((len == sizeof (s) - 1) && (strncmp (str, s, sizeof (s) - 1) == 0))
981 if (STREQ (ELF_STRING_ia64_unwind_info
))
984 if (STREQ (ELF_STRING_ia64_unwind_info_once
))
987 if (STREQ (ELF_STRING_ia64_unwind
))
988 return SHT_IA_64_UNWIND
;
990 if (STREQ (ELF_STRING_ia64_unwind_once
))
991 return SHT_IA_64_UNWIND
;
993 if (STREQ ("init_array"))
994 return SHT_INIT_ARRAY
;
996 if (STREQ ("fini_array"))
997 return SHT_FINI_ARRAY
;
1004 set_regstack (ins
, locs
, outs
, rots
)
1005 unsigned int ins
, locs
, outs
, rots
;
1007 /* Size of frame. */
1010 sof
= ins
+ locs
+ outs
;
1013 as_bad ("Size of frame exceeds maximum of 96 registers");
1018 as_warn ("Size of rotating registers exceeds frame size");
1021 md
.in
.base
= REG_GR
+ 32;
1022 md
.loc
.base
= md
.in
.base
+ ins
;
1023 md
.out
.base
= md
.loc
.base
+ locs
;
1025 md
.in
.num_regs
= ins
;
1026 md
.loc
.num_regs
= locs
;
1027 md
.out
.num_regs
= outs
;
1028 md
.rot
.num_regs
= rots
;
1035 struct label_fix
*lfix
;
1037 subsegT saved_subseg
;
1040 if (!md
.last_text_seg
)
1043 saved_seg
= now_seg
;
1044 saved_subseg
= now_subseg
;
1046 subseg_set (md
.last_text_seg
, 0);
1048 while (md
.num_slots_in_use
> 0)
1049 emit_one_bundle (); /* force out queued instructions */
1051 /* In case there are labels following the last instruction, resolve
1053 for (lfix
= CURR_SLOT
.label_fixups
; lfix
; lfix
= lfix
->next
)
1055 S_SET_VALUE (lfix
->sym
, frag_now_fix ());
1056 symbol_set_frag (lfix
->sym
, frag_now
);
1058 CURR_SLOT
.label_fixups
= 0;
1059 for (lfix
= CURR_SLOT
.tag_fixups
; lfix
; lfix
= lfix
->next
)
1061 S_SET_VALUE (lfix
->sym
, frag_now_fix ());
1062 symbol_set_frag (lfix
->sym
, frag_now
);
1064 CURR_SLOT
.tag_fixups
= 0;
1066 /* In case there are unwind directives following the last instruction,
1067 resolve those now. We only handle body and prologue directives here.
1068 Give an error for others. */
1069 for (ptr
= unwind
.current_entry
; ptr
; ptr
= ptr
->next
)
1071 if (ptr
->r
.type
== prologue
|| ptr
->r
.type
== prologue_gr
1072 || ptr
->r
.type
== body
)
1074 ptr
->slot_number
= (unsigned long) frag_more (0);
1075 ptr
->slot_frag
= frag_now
;
1078 as_bad (_("Unwind directive not followed by an instruction."));
1080 unwind
.current_entry
= NULL
;
1082 subseg_set (saved_seg
, saved_subseg
);
1084 if (md
.qp
.X_op
== O_register
)
1085 as_bad ("qualifying predicate not followed by instruction");
1089 ia64_do_align (nbytes
)
1092 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 ia64_cons_align (nbytes
)
1105 char *saved_input_line_pointer
= input_line_pointer
;
1106 input_line_pointer
= "";
1107 s_align_bytes (nbytes
);
1108 input_line_pointer
= saved_input_line_pointer
;
1112 /* Output COUNT bytes to a memory location. */
1113 static unsigned char *vbyte_mem_ptr
= NULL
;
1116 output_vbyte_mem (count
, ptr
, comment
)
1119 char *comment ATTRIBUTE_UNUSED
;
1122 if (vbyte_mem_ptr
== NULL
)
1127 for (x
= 0; x
< count
; x
++)
1128 *(vbyte_mem_ptr
++) = ptr
[x
];
1131 /* Count the number of bytes required for records. */
1132 static int vbyte_count
= 0;
1134 count_output (count
, ptr
, comment
)
1136 char *ptr ATTRIBUTE_UNUSED
;
1137 char *comment ATTRIBUTE_UNUSED
;
1139 vbyte_count
+= count
;
1143 output_R1_format (f
, rtype
, rlen
)
1145 unw_record_type rtype
;
1152 output_R3_format (f
, rtype
, rlen
);
1158 else if (rtype
!= prologue
)
1159 as_bad ("record type is not valid");
1161 byte
= UNW_R1
| (r
<< 5) | (rlen
& 0x1f);
1162 (*f
) (1, &byte
, NULL
);
1166 output_R2_format (f
, mask
, grsave
, rlen
)
1173 mask
= (mask
& 0x0f);
1174 grsave
= (grsave
& 0x7f);
1176 bytes
[0] = (UNW_R2
| (mask
>> 1));
1177 bytes
[1] = (((mask
& 0x01) << 7) | grsave
);
1178 count
+= output_leb128 (bytes
+ 2, rlen
, 0);
1179 (*f
) (count
, bytes
, NULL
);
1183 output_R3_format (f
, rtype
, rlen
)
1185 unw_record_type rtype
;
1192 output_R1_format (f
, rtype
, rlen
);
1198 else if (rtype
!= prologue
)
1199 as_bad ("record type is not valid");
1200 bytes
[0] = (UNW_R3
| r
);
1201 count
= output_leb128 (bytes
+ 1, rlen
, 0);
1202 (*f
) (count
+ 1, bytes
, NULL
);
1206 output_P1_format (f
, brmask
)
1211 byte
= UNW_P1
| (brmask
& 0x1f);
1212 (*f
) (1, &byte
, NULL
);
1216 output_P2_format (f
, brmask
, gr
)
1222 brmask
= (brmask
& 0x1f);
1223 bytes
[0] = UNW_P2
| (brmask
>> 1);
1224 bytes
[1] = (((brmask
& 1) << 7) | gr
);
1225 (*f
) (2, bytes
, NULL
);
1229 output_P3_format (f
, rtype
, reg
)
1231 unw_record_type rtype
;
1276 as_bad ("Invalid record type for P3 format.");
1278 bytes
[0] = (UNW_P3
| (r
>> 1));
1279 bytes
[1] = (((r
& 1) << 7) | reg
);
1280 (*f
) (2, bytes
, NULL
);
1284 output_P4_format (f
, imask
, imask_size
)
1286 unsigned char *imask
;
1287 unsigned long imask_size
;
1290 (*f
) (imask_size
, imask
, NULL
);
1294 output_P5_format (f
, grmask
, frmask
)
1297 unsigned long frmask
;
1300 grmask
= (grmask
& 0x0f);
1303 bytes
[1] = ((grmask
<< 4) | ((frmask
& 0x000f0000) >> 16));
1304 bytes
[2] = ((frmask
& 0x0000ff00) >> 8);
1305 bytes
[3] = (frmask
& 0x000000ff);
1306 (*f
) (4, bytes
, NULL
);
1310 output_P6_format (f
, rtype
, rmask
)
1312 unw_record_type rtype
;
1318 if (rtype
== gr_mem
)
1320 else if (rtype
!= fr_mem
)
1321 as_bad ("Invalid record type for format P6");
1322 byte
= (UNW_P6
| (r
<< 4) | (rmask
& 0x0f));
1323 (*f
) (1, &byte
, NULL
);
1327 output_P7_format (f
, rtype
, w1
, w2
)
1329 unw_record_type rtype
;
1336 count
+= output_leb128 (bytes
+ 1, w1
, 0);
1341 count
+= output_leb128 (bytes
+ count
, w2
>> 4, 0);
1391 bytes
[0] = (UNW_P7
| r
);
1392 (*f
) (count
, bytes
, NULL
);
1396 output_P8_format (f
, rtype
, t
)
1398 unw_record_type rtype
;
1437 case bspstore_psprel
:
1440 case bspstore_sprel
:
1452 case priunat_when_gr
:
1455 case priunat_psprel
:
1461 case priunat_when_mem
:
1468 count
+= output_leb128 (bytes
+ 2, t
, 0);
1469 (*f
) (count
, bytes
, NULL
);
1473 output_P9_format (f
, grmask
, gr
)
1480 bytes
[1] = (grmask
& 0x0f);
1481 bytes
[2] = (gr
& 0x7f);
1482 (*f
) (3, bytes
, NULL
);
1486 output_P10_format (f
, abi
, context
)
1493 bytes
[1] = (abi
& 0xff);
1494 bytes
[2] = (context
& 0xff);
1495 (*f
) (3, bytes
, NULL
);
1499 output_B1_format (f
, rtype
, label
)
1501 unw_record_type rtype
;
1502 unsigned long label
;
1508 output_B4_format (f
, rtype
, label
);
1511 if (rtype
== copy_state
)
1513 else if (rtype
!= label_state
)
1514 as_bad ("Invalid record type for format B1");
1516 byte
= (UNW_B1
| (r
<< 5) | (label
& 0x1f));
1517 (*f
) (1, &byte
, NULL
);
1521 output_B2_format (f
, ecount
, t
)
1523 unsigned long ecount
;
1530 output_B3_format (f
, ecount
, t
);
1533 bytes
[0] = (UNW_B2
| (ecount
& 0x1f));
1534 count
+= output_leb128 (bytes
+ 1, t
, 0);
1535 (*f
) (count
, bytes
, NULL
);
1539 output_B3_format (f
, ecount
, t
)
1541 unsigned long ecount
;
1548 output_B2_format (f
, ecount
, t
);
1552 count
+= output_leb128 (bytes
+ 1, t
, 0);
1553 count
+= output_leb128 (bytes
+ count
, ecount
, 0);
1554 (*f
) (count
, bytes
, NULL
);
1558 output_B4_format (f
, rtype
, label
)
1560 unw_record_type rtype
;
1561 unsigned long label
;
1568 output_B1_format (f
, rtype
, label
);
1572 if (rtype
== copy_state
)
1574 else if (rtype
!= label_state
)
1575 as_bad ("Invalid record type for format B1");
1577 bytes
[0] = (UNW_B4
| (r
<< 3));
1578 count
+= output_leb128 (bytes
+ 1, label
, 0);
1579 (*f
) (count
, bytes
, NULL
);
1583 format_ab_reg (ab
, reg
)
1590 ret
= (ab
<< 5) | reg
;
1595 output_X1_format (f
, rtype
, ab
, reg
, t
, w1
)
1597 unw_record_type rtype
;
1607 if (rtype
== spill_sprel
)
1609 else if (rtype
!= spill_psprel
)
1610 as_bad ("Invalid record type for format X1");
1611 bytes
[1] = ((r
<< 7) | format_ab_reg (ab
, reg
));
1612 count
+= output_leb128 (bytes
+ 2, t
, 0);
1613 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1614 (*f
) (count
, bytes
, NULL
);
1618 output_X2_format (f
, ab
, reg
, x
, y
, treg
, t
)
1627 bytes
[1] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1628 bytes
[2] = (((y
& 1) << 7) | (treg
& 0x7f));
1629 count
+= output_leb128 (bytes
+ 3, t
, 0);
1630 (*f
) (count
, bytes
, NULL
);
1634 output_X3_format (f
, rtype
, qp
, ab
, reg
, t
, w1
)
1636 unw_record_type rtype
;
1647 if (rtype
== spill_sprel_p
)
1649 else if (rtype
!= spill_psprel_p
)
1650 as_bad ("Invalid record type for format X3");
1651 bytes
[1] = ((r
<< 7) | (qp
& 0x3f));
1652 bytes
[2] = format_ab_reg (ab
, reg
);
1653 count
+= output_leb128 (bytes
+ 3, t
, 0);
1654 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1655 (*f
) (count
, bytes
, NULL
);
1659 output_X4_format (f
, qp
, ab
, reg
, x
, y
, treg
, t
)
1669 bytes
[1] = (qp
& 0x3f);
1670 bytes
[2] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1671 bytes
[3] = (((y
& 1) << 7) | (treg
& 0x7f));
1672 count
+= output_leb128 (bytes
+ 4, t
, 0);
1673 (*f
) (count
, bytes
, NULL
);
1676 /* This function allocates a record list structure, and initializes fields. */
1678 static unw_rec_list
*
1679 alloc_record (unw_record_type t
)
1682 ptr
= xmalloc (sizeof (*ptr
));
1684 ptr
->slot_number
= SLOT_NUM_NOT_SET
;
1689 /* This function frees an entire list of record structures. */
1692 free_list_records (unw_rec_list
*first
)
1695 for (ptr
= first
; ptr
!= NULL
;)
1697 unw_rec_list
*tmp
= ptr
;
1699 if ((tmp
->r
.type
== prologue
|| tmp
->r
.type
== prologue_gr
)
1700 && tmp
->r
.record
.r
.mask
.i
)
1701 free (tmp
->r
.record
.r
.mask
.i
);
1708 static unw_rec_list
*
1711 unw_rec_list
*ptr
= alloc_record (prologue
);
1712 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1716 static unw_rec_list
*
1717 output_prologue_gr (saved_mask
, reg
)
1718 unsigned int saved_mask
;
1721 unw_rec_list
*ptr
= alloc_record (prologue_gr
);
1722 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1723 ptr
->r
.record
.r
.grmask
= saved_mask
;
1724 ptr
->r
.record
.r
.grsave
= reg
;
1728 static unw_rec_list
*
1731 unw_rec_list
*ptr
= alloc_record (body
);
1735 static unw_rec_list
*
1736 output_mem_stack_f (size
)
1739 unw_rec_list
*ptr
= alloc_record (mem_stack_f
);
1740 ptr
->r
.record
.p
.size
= size
;
1744 static unw_rec_list
*
1745 output_mem_stack_v ()
1747 unw_rec_list
*ptr
= alloc_record (mem_stack_v
);
1751 static unw_rec_list
*
1755 unw_rec_list
*ptr
= alloc_record (psp_gr
);
1756 ptr
->r
.record
.p
.gr
= gr
;
1760 static unw_rec_list
*
1761 output_psp_sprel (offset
)
1762 unsigned int offset
;
1764 unw_rec_list
*ptr
= alloc_record (psp_sprel
);
1765 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1769 static unw_rec_list
*
1772 unw_rec_list
*ptr
= alloc_record (rp_when
);
1776 static unw_rec_list
*
1780 unw_rec_list
*ptr
= alloc_record (rp_gr
);
1781 ptr
->r
.record
.p
.gr
= gr
;
1785 static unw_rec_list
*
1789 unw_rec_list
*ptr
= alloc_record (rp_br
);
1790 ptr
->r
.record
.p
.br
= br
;
1794 static unw_rec_list
*
1795 output_rp_psprel (offset
)
1796 unsigned int offset
;
1798 unw_rec_list
*ptr
= alloc_record (rp_psprel
);
1799 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1803 static unw_rec_list
*
1804 output_rp_sprel (offset
)
1805 unsigned int offset
;
1807 unw_rec_list
*ptr
= alloc_record (rp_sprel
);
1808 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1812 static unw_rec_list
*
1815 unw_rec_list
*ptr
= alloc_record (pfs_when
);
1819 static unw_rec_list
*
1823 unw_rec_list
*ptr
= alloc_record (pfs_gr
);
1824 ptr
->r
.record
.p
.gr
= gr
;
1828 static unw_rec_list
*
1829 output_pfs_psprel (offset
)
1830 unsigned int offset
;
1832 unw_rec_list
*ptr
= alloc_record (pfs_psprel
);
1833 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1837 static unw_rec_list
*
1838 output_pfs_sprel (offset
)
1839 unsigned int offset
;
1841 unw_rec_list
*ptr
= alloc_record (pfs_sprel
);
1842 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1846 static unw_rec_list
*
1847 output_preds_when ()
1849 unw_rec_list
*ptr
= alloc_record (preds_when
);
1853 static unw_rec_list
*
1854 output_preds_gr (gr
)
1857 unw_rec_list
*ptr
= alloc_record (preds_gr
);
1858 ptr
->r
.record
.p
.gr
= gr
;
1862 static unw_rec_list
*
1863 output_preds_psprel (offset
)
1864 unsigned int offset
;
1866 unw_rec_list
*ptr
= alloc_record (preds_psprel
);
1867 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1871 static unw_rec_list
*
1872 output_preds_sprel (offset
)
1873 unsigned int offset
;
1875 unw_rec_list
*ptr
= alloc_record (preds_sprel
);
1876 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1880 static unw_rec_list
*
1881 output_fr_mem (mask
)
1884 unw_rec_list
*ptr
= alloc_record (fr_mem
);
1885 ptr
->r
.record
.p
.rmask
= mask
;
1889 static unw_rec_list
*
1890 output_frgr_mem (gr_mask
, fr_mask
)
1891 unsigned int gr_mask
;
1892 unsigned int fr_mask
;
1894 unw_rec_list
*ptr
= alloc_record (frgr_mem
);
1895 ptr
->r
.record
.p
.grmask
= gr_mask
;
1896 ptr
->r
.record
.p
.frmask
= fr_mask
;
1900 static unw_rec_list
*
1901 output_gr_gr (mask
, reg
)
1905 unw_rec_list
*ptr
= alloc_record (gr_gr
);
1906 ptr
->r
.record
.p
.grmask
= mask
;
1907 ptr
->r
.record
.p
.gr
= reg
;
1911 static unw_rec_list
*
1912 output_gr_mem (mask
)
1915 unw_rec_list
*ptr
= alloc_record (gr_mem
);
1916 ptr
->r
.record
.p
.rmask
= mask
;
1920 static unw_rec_list
*
1921 output_br_mem (unsigned int mask
)
1923 unw_rec_list
*ptr
= alloc_record (br_mem
);
1924 ptr
->r
.record
.p
.brmask
= mask
;
1928 static unw_rec_list
*
1929 output_br_gr (save_mask
, reg
)
1930 unsigned int save_mask
;
1933 unw_rec_list
*ptr
= alloc_record (br_gr
);
1934 ptr
->r
.record
.p
.brmask
= save_mask
;
1935 ptr
->r
.record
.p
.gr
= reg
;
1939 static unw_rec_list
*
1940 output_spill_base (offset
)
1941 unsigned int offset
;
1943 unw_rec_list
*ptr
= alloc_record (spill_base
);
1944 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1948 static unw_rec_list
*
1951 unw_rec_list
*ptr
= alloc_record (unat_when
);
1955 static unw_rec_list
*
1959 unw_rec_list
*ptr
= alloc_record (unat_gr
);
1960 ptr
->r
.record
.p
.gr
= gr
;
1964 static unw_rec_list
*
1965 output_unat_psprel (offset
)
1966 unsigned int offset
;
1968 unw_rec_list
*ptr
= alloc_record (unat_psprel
);
1969 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
1973 static unw_rec_list
*
1974 output_unat_sprel (offset
)
1975 unsigned int offset
;
1977 unw_rec_list
*ptr
= alloc_record (unat_sprel
);
1978 ptr
->r
.record
.p
.spoff
= offset
/ 4;
1982 static unw_rec_list
*
1985 unw_rec_list
*ptr
= alloc_record (lc_when
);
1989 static unw_rec_list
*
1993 unw_rec_list
*ptr
= alloc_record (lc_gr
);
1994 ptr
->r
.record
.p
.gr
= gr
;
1998 static unw_rec_list
*
1999 output_lc_psprel (offset
)
2000 unsigned int offset
;
2002 unw_rec_list
*ptr
= alloc_record (lc_psprel
);
2003 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2007 static unw_rec_list
*
2008 output_lc_sprel (offset
)
2009 unsigned int offset
;
2011 unw_rec_list
*ptr
= alloc_record (lc_sprel
);
2012 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2016 static unw_rec_list
*
2019 unw_rec_list
*ptr
= alloc_record (fpsr_when
);
2023 static unw_rec_list
*
2027 unw_rec_list
*ptr
= alloc_record (fpsr_gr
);
2028 ptr
->r
.record
.p
.gr
= gr
;
2032 static unw_rec_list
*
2033 output_fpsr_psprel (offset
)
2034 unsigned int offset
;
2036 unw_rec_list
*ptr
= alloc_record (fpsr_psprel
);
2037 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2041 static unw_rec_list
*
2042 output_fpsr_sprel (offset
)
2043 unsigned int offset
;
2045 unw_rec_list
*ptr
= alloc_record (fpsr_sprel
);
2046 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2050 static unw_rec_list
*
2051 output_priunat_when_gr ()
2053 unw_rec_list
*ptr
= alloc_record (priunat_when_gr
);
2057 static unw_rec_list
*
2058 output_priunat_when_mem ()
2060 unw_rec_list
*ptr
= alloc_record (priunat_when_mem
);
2064 static unw_rec_list
*
2065 output_priunat_gr (gr
)
2068 unw_rec_list
*ptr
= alloc_record (priunat_gr
);
2069 ptr
->r
.record
.p
.gr
= gr
;
2073 static unw_rec_list
*
2074 output_priunat_psprel (offset
)
2075 unsigned int offset
;
2077 unw_rec_list
*ptr
= alloc_record (priunat_psprel
);
2078 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2082 static unw_rec_list
*
2083 output_priunat_sprel (offset
)
2084 unsigned int offset
;
2086 unw_rec_list
*ptr
= alloc_record (priunat_sprel
);
2087 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2091 static unw_rec_list
*
2094 unw_rec_list
*ptr
= alloc_record (bsp_when
);
2098 static unw_rec_list
*
2102 unw_rec_list
*ptr
= alloc_record (bsp_gr
);
2103 ptr
->r
.record
.p
.gr
= gr
;
2107 static unw_rec_list
*
2108 output_bsp_psprel (offset
)
2109 unsigned int offset
;
2111 unw_rec_list
*ptr
= alloc_record (bsp_psprel
);
2112 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2116 static unw_rec_list
*
2117 output_bsp_sprel (offset
)
2118 unsigned int offset
;
2120 unw_rec_list
*ptr
= alloc_record (bsp_sprel
);
2121 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2125 static unw_rec_list
*
2126 output_bspstore_when ()
2128 unw_rec_list
*ptr
= alloc_record (bspstore_when
);
2132 static unw_rec_list
*
2133 output_bspstore_gr (gr
)
2136 unw_rec_list
*ptr
= alloc_record (bspstore_gr
);
2137 ptr
->r
.record
.p
.gr
= gr
;
2141 static unw_rec_list
*
2142 output_bspstore_psprel (offset
)
2143 unsigned int offset
;
2145 unw_rec_list
*ptr
= alloc_record (bspstore_psprel
);
2146 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2150 static unw_rec_list
*
2151 output_bspstore_sprel (offset
)
2152 unsigned int offset
;
2154 unw_rec_list
*ptr
= alloc_record (bspstore_sprel
);
2155 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2159 static unw_rec_list
*
2162 unw_rec_list
*ptr
= alloc_record (rnat_when
);
2166 static unw_rec_list
*
2170 unw_rec_list
*ptr
= alloc_record (rnat_gr
);
2171 ptr
->r
.record
.p
.gr
= gr
;
2175 static unw_rec_list
*
2176 output_rnat_psprel (offset
)
2177 unsigned int offset
;
2179 unw_rec_list
*ptr
= alloc_record (rnat_psprel
);
2180 ptr
->r
.record
.p
.pspoff
= offset
/ 4;
2184 static unw_rec_list
*
2185 output_rnat_sprel (offset
)
2186 unsigned int offset
;
2188 unw_rec_list
*ptr
= alloc_record (rnat_sprel
);
2189 ptr
->r
.record
.p
.spoff
= offset
/ 4;
2193 static unw_rec_list
*
2194 output_unwabi (abi
, context
)
2196 unsigned long context
;
2198 unw_rec_list
*ptr
= alloc_record (unwabi
);
2199 ptr
->r
.record
.p
.abi
= abi
;
2200 ptr
->r
.record
.p
.context
= context
;
2204 static unw_rec_list
*
2205 output_epilogue (unsigned long ecount
)
2207 unw_rec_list
*ptr
= alloc_record (epilogue
);
2208 ptr
->r
.record
.b
.ecount
= ecount
;
2212 static unw_rec_list
*
2213 output_label_state (unsigned long label
)
2215 unw_rec_list
*ptr
= alloc_record (label_state
);
2216 ptr
->r
.record
.b
.label
= label
;
2220 static unw_rec_list
*
2221 output_copy_state (unsigned long label
)
2223 unw_rec_list
*ptr
= alloc_record (copy_state
);
2224 ptr
->r
.record
.b
.label
= label
;
2228 static unw_rec_list
*
2229 output_spill_psprel (ab
, reg
, offset
)
2232 unsigned int offset
;
2234 unw_rec_list
*ptr
= alloc_record (spill_psprel
);
2235 ptr
->r
.record
.x
.ab
= ab
;
2236 ptr
->r
.record
.x
.reg
= reg
;
2237 ptr
->r
.record
.x
.pspoff
= offset
/ 4;
2241 static unw_rec_list
*
2242 output_spill_sprel (ab
, reg
, offset
)
2245 unsigned int offset
;
2247 unw_rec_list
*ptr
= alloc_record (spill_sprel
);
2248 ptr
->r
.record
.x
.ab
= ab
;
2249 ptr
->r
.record
.x
.reg
= reg
;
2250 ptr
->r
.record
.x
.spoff
= offset
/ 4;
2254 static unw_rec_list
*
2255 output_spill_psprel_p (ab
, reg
, offset
, predicate
)
2258 unsigned int offset
;
2259 unsigned int predicate
;
2261 unw_rec_list
*ptr
= alloc_record (spill_psprel_p
);
2262 ptr
->r
.record
.x
.ab
= ab
;
2263 ptr
->r
.record
.x
.reg
= reg
;
2264 ptr
->r
.record
.x
.pspoff
= offset
/ 4;
2265 ptr
->r
.record
.x
.qp
= predicate
;
2269 static unw_rec_list
*
2270 output_spill_sprel_p (ab
, reg
, offset
, predicate
)
2273 unsigned int offset
;
2274 unsigned int predicate
;
2276 unw_rec_list
*ptr
= alloc_record (spill_sprel_p
);
2277 ptr
->r
.record
.x
.ab
= ab
;
2278 ptr
->r
.record
.x
.reg
= reg
;
2279 ptr
->r
.record
.x
.spoff
= offset
/ 4;
2280 ptr
->r
.record
.x
.qp
= predicate
;
2284 static unw_rec_list
*
2285 output_spill_reg (ab
, reg
, targ_reg
, xy
)
2288 unsigned int targ_reg
;
2291 unw_rec_list
*ptr
= alloc_record (spill_reg
);
2292 ptr
->r
.record
.x
.ab
= ab
;
2293 ptr
->r
.record
.x
.reg
= reg
;
2294 ptr
->r
.record
.x
.treg
= targ_reg
;
2295 ptr
->r
.record
.x
.xy
= xy
;
2299 static unw_rec_list
*
2300 output_spill_reg_p (ab
, reg
, targ_reg
, xy
, predicate
)
2303 unsigned int targ_reg
;
2305 unsigned int predicate
;
2307 unw_rec_list
*ptr
= alloc_record (spill_reg_p
);
2308 ptr
->r
.record
.x
.ab
= ab
;
2309 ptr
->r
.record
.x
.reg
= reg
;
2310 ptr
->r
.record
.x
.treg
= targ_reg
;
2311 ptr
->r
.record
.x
.xy
= xy
;
2312 ptr
->r
.record
.x
.qp
= predicate
;
2316 /* Given a unw_rec_list process the correct format with the
2317 specified function. */
2320 process_one_record (ptr
, f
)
2324 unsigned long fr_mask
, gr_mask
;
2326 switch (ptr
->r
.type
)
2332 /* These are taken care of by prologue/prologue_gr. */
2337 if (ptr
->r
.type
== prologue_gr
)
2338 output_R2_format (f
, ptr
->r
.record
.r
.grmask
,
2339 ptr
->r
.record
.r
.grsave
, ptr
->r
.record
.r
.rlen
);
2341 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2343 /* Output descriptor(s) for union of register spills (if any). */
2344 gr_mask
= ptr
->r
.record
.r
.mask
.gr_mem
;
2345 fr_mask
= ptr
->r
.record
.r
.mask
.fr_mem
;
2348 if ((fr_mask
& ~0xfUL
) == 0)
2349 output_P6_format (f
, fr_mem
, fr_mask
);
2352 output_P5_format (f
, gr_mask
, fr_mask
);
2357 output_P6_format (f
, gr_mem
, gr_mask
);
2358 if (ptr
->r
.record
.r
.mask
.br_mem
)
2359 output_P1_format (f
, ptr
->r
.record
.r
.mask
.br_mem
);
2361 /* output imask descriptor if necessary: */
2362 if (ptr
->r
.record
.r
.mask
.i
)
2363 output_P4_format (f
, ptr
->r
.record
.r
.mask
.i
,
2364 ptr
->r
.record
.r
.imask_size
);
2368 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2372 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
,
2373 ptr
->r
.record
.p
.size
);
2386 output_P3_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.gr
);
2389 output_P3_format (f
, rp_br
, ptr
->r
.record
.p
.br
);
2392 output_P7_format (f
, psp_sprel
, ptr
->r
.record
.p
.spoff
, 0);
2400 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
, 0);
2409 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.pspoff
, 0);
2419 case bspstore_sprel
:
2421 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.spoff
);
2424 output_P9_format (f
, ptr
->r
.record
.p
.grmask
, ptr
->r
.record
.p
.gr
);
2427 output_P2_format (f
, ptr
->r
.record
.p
.brmask
, ptr
->r
.record
.p
.gr
);
2430 as_bad ("spill_mask record unimplemented.");
2432 case priunat_when_gr
:
2433 case priunat_when_mem
:
2437 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
);
2439 case priunat_psprel
:
2441 case bspstore_psprel
:
2443 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.pspoff
);
2446 output_P10_format (f
, ptr
->r
.record
.p
.abi
, ptr
->r
.record
.p
.context
);
2449 output_B3_format (f
, ptr
->r
.record
.b
.ecount
, ptr
->r
.record
.b
.t
);
2453 output_B4_format (f
, ptr
->r
.type
, ptr
->r
.record
.b
.label
);
2456 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2457 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2458 ptr
->r
.record
.x
.pspoff
);
2461 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2462 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2463 ptr
->r
.record
.x
.spoff
);
2466 output_X2_format (f
, ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2467 ptr
->r
.record
.x
.xy
>> 1, ptr
->r
.record
.x
.xy
,
2468 ptr
->r
.record
.x
.treg
, ptr
->r
.record
.x
.t
);
2470 case spill_psprel_p
:
2471 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2472 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2473 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.pspoff
);
2476 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2477 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2478 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.spoff
);
2481 output_X4_format (f
, ptr
->r
.record
.x
.qp
, ptr
->r
.record
.x
.ab
,
2482 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.xy
>> 1,
2483 ptr
->r
.record
.x
.xy
, ptr
->r
.record
.x
.treg
,
2487 as_bad ("record_type_not_valid");
2492 /* Given a unw_rec_list list, process all the records with
2493 the specified function. */
2495 process_unw_records (list
, f
)
2500 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2501 process_one_record (ptr
, f
);
2504 /* Determine the size of a record list in bytes. */
2506 calc_record_size (list
)
2510 process_unw_records (list
, count_output
);
2514 /* Update IMASK bitmask to reflect the fact that one or more registers
2515 of type TYPE are saved starting at instruction with index T. If N
2516 bits are set in REGMASK, it is assumed that instructions T through
2517 T+N-1 save these registers.
2521 1: instruction saves next fp reg
2522 2: instruction saves next general reg
2523 3: instruction saves next branch reg */
2525 set_imask (region
, regmask
, t
, type
)
2526 unw_rec_list
*region
;
2527 unsigned long regmask
;
2531 unsigned char *imask
;
2532 unsigned long imask_size
;
2536 imask
= region
->r
.record
.r
.mask
.i
;
2537 imask_size
= region
->r
.record
.r
.imask_size
;
2540 imask_size
= (region
->r
.record
.r
.rlen
* 2 + 7) / 8 + 1;
2541 imask
= xmalloc (imask_size
);
2542 memset (imask
, 0, imask_size
);
2544 region
->r
.record
.r
.imask_size
= imask_size
;
2545 region
->r
.record
.r
.mask
.i
= imask
;
2549 pos
= 2 * (3 - t
% 4);
2552 if (i
>= imask_size
)
2554 as_bad ("Ignoring attempt to spill beyond end of region");
2558 imask
[i
] |= (type
& 0x3) << pos
;
2560 regmask
&= (regmask
- 1);
2571 count_bits (unsigned long mask
)
2583 /* Return the number of instruction slots from FIRST_ADDR to SLOT_ADDR.
2584 SLOT_FRAG is the frag containing SLOT_ADDR, and FIRST_FRAG is the frag
2585 containing FIRST_ADDR. */
2588 slot_index (slot_addr
, slot_frag
, first_addr
, first_frag
)
2589 unsigned long slot_addr
;
2591 unsigned long first_addr
;
2594 unsigned long index
= 0;
2596 /* First time we are called, the initial address and frag are invalid. */
2597 if (first_addr
== 0)
2600 /* If the two addresses are in different frags, then we need to add in
2601 the remaining size of this frag, and then the entire size of intermediate
2603 while (slot_frag
!= first_frag
)
2605 unsigned long start_addr
= (unsigned long) &first_frag
->fr_literal
;
2607 /* Add in the full size of the frag converted to instruction slots. */
2608 index
+= 3 * (first_frag
->fr_fix
>> 4);
2609 /* Subtract away the initial part before first_addr. */
2610 index
-= (3 * ((first_addr
>> 4) - (start_addr
>> 4))
2611 + ((first_addr
& 0x3) - (start_addr
& 0x3)));
2613 /* Move to the beginning of the next frag. */
2614 first_frag
= first_frag
->fr_next
;
2615 first_addr
= (unsigned long) &first_frag
->fr_literal
;
2618 /* Add in the used part of the last frag. */
2619 index
+= (3 * ((slot_addr
>> 4) - (first_addr
>> 4))
2620 + ((slot_addr
& 0x3) - (first_addr
& 0x3)));
2624 /* Optimize unwind record directives. */
2626 static unw_rec_list
*
2627 optimize_unw_records (list
)
2633 /* If the only unwind record is ".prologue" or ".prologue" followed
2634 by ".body", then we can optimize the unwind directives away. */
2635 if (list
->r
.type
== prologue
2636 && (list
->next
== NULL
2637 || (list
->next
->r
.type
== body
&& list
->next
->next
== NULL
)))
2643 /* Given a complete record list, process any records which have
2644 unresolved fields, (ie length counts for a prologue). After
2645 this has been run, all neccessary information should be available
2646 within each record to generate an image. */
2649 fixup_unw_records (list
)
2652 unw_rec_list
*ptr
, *region
= 0;
2653 unsigned long first_addr
= 0, rlen
= 0, t
;
2654 fragS
*first_frag
= 0;
2656 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2658 if (ptr
->slot_number
== SLOT_NUM_NOT_SET
)
2659 as_bad (" Insn slot not set in unwind record.");
2660 t
= slot_index (ptr
->slot_number
, ptr
->slot_frag
,
2661 first_addr
, first_frag
);
2662 switch (ptr
->r
.type
)
2669 int size
, dir_len
= 0;
2670 unsigned long last_addr
;
2673 first_addr
= ptr
->slot_number
;
2674 first_frag
= ptr
->slot_frag
;
2675 ptr
->slot_number
= 0;
2676 /* Find either the next body/prologue start, or the end of
2677 the list, and determine the size of the region. */
2678 last_addr
= unwind
.next_slot_number
;
2679 last_frag
= unwind
.next_slot_frag
;
2680 for (last
= ptr
->next
; last
!= NULL
; last
= last
->next
)
2681 if (last
->r
.type
== prologue
|| last
->r
.type
== prologue_gr
2682 || last
->r
.type
== body
)
2684 last_addr
= last
->slot_number
;
2685 last_frag
= last
->slot_frag
;
2688 else if (!last
->next
)
2690 /* In the absence of an explicit .body directive,
2691 the prologue ends after the last instruction
2692 covered by an unwind directive. */
2693 if (ptr
->r
.type
!= body
)
2695 last_addr
= last
->slot_number
;
2696 last_frag
= last
->slot_frag
;
2697 switch (last
->r
.type
)
2700 dir_len
= (count_bits (last
->r
.record
.p
.frmask
)
2701 + count_bits (last
->r
.record
.p
.grmask
));
2705 dir_len
+= count_bits (last
->r
.record
.p
.rmask
);
2709 dir_len
+= count_bits (last
->r
.record
.p
.brmask
);
2712 dir_len
+= count_bits (last
->r
.record
.p
.grmask
);
2721 size
= (slot_index (last_addr
, last_frag
, first_addr
, first_frag
)
2723 rlen
= ptr
->r
.record
.r
.rlen
= size
;
2724 if (ptr
->r
.type
== body
)
2725 /* End of region. */
2732 ptr
->r
.record
.b
.t
= rlen
- 1 - t
;
2743 case priunat_when_gr
:
2744 case priunat_when_mem
:
2748 ptr
->r
.record
.p
.t
= t
;
2756 case spill_psprel_p
:
2757 ptr
->r
.record
.x
.t
= t
;
2763 as_bad ("frgr_mem record before region record!\n");
2766 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.frmask
;
2767 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.grmask
;
2768 set_imask (region
, ptr
->r
.record
.p
.frmask
, t
, 1);
2769 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2774 as_bad ("fr_mem record before region record!\n");
2777 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.rmask
;
2778 set_imask (region
, ptr
->r
.record
.p
.rmask
, t
, 1);
2783 as_bad ("gr_mem record before region record!\n");
2786 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.rmask
;
2787 set_imask (region
, ptr
->r
.record
.p
.rmask
, t
, 2);
2792 as_bad ("br_mem record before region record!\n");
2795 region
->r
.record
.r
.mask
.br_mem
|= ptr
->r
.record
.p
.brmask
;
2796 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2802 as_bad ("gr_gr record before region record!\n");
2805 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2810 as_bad ("br_gr record before region record!\n");
2813 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2822 /* Helper routine for output_unw_records. Emits the header for the unwind
2826 setup_unwind_header (int size
, unsigned char **mem
)
2831 /* pad to pointer-size boundry. */
2832 x
= size
% md
.pointer_size
;
2834 extra
= md
.pointer_size
- x
;
2836 /* Add 8 for the header + a pointer for the
2837 personality offset. */
2838 *mem
= xmalloc (size
+ extra
+ 8 + md
.pointer_size
);
2840 /* Clear the padding area and personality. */
2841 memset (*mem
+ 8 + size
, 0, extra
+ md
.pointer_size
);
2843 /* Initialize the header area. */
2844 if (unwind
.personality_routine
)
2846 if (md
.flags
& EF_IA_64_ABI64
)
2847 flag_value
= (bfd_vma
) 3 << 32;
2849 /* 32-bit unwind info block. */
2850 flag_value
= (bfd_vma
) 0x1003 << 32;
2855 md_number_to_chars (*mem
, (((bfd_vma
) 1 << 48) /* Version. */
2856 | flag_value
/* U & E handler flags. */
2857 | ((size
+ extra
) / md
.pointer_size
)), /* Length. */
2863 /* Generate an unwind image from a record list. Returns the number of
2864 bytes in the resulting image. The memory image itselof is returned
2865 in the 'ptr' parameter. */
2867 output_unw_records (list
, ptr
)
2876 list
= optimize_unw_records (list
);
2877 fixup_unw_records (list
);
2878 size
= calc_record_size (list
);
2880 if (size
> 0 || unwind
.force_unwind_entry
)
2882 unwind
.force_unwind_entry
= 0;
2883 extra
= setup_unwind_header (size
, &mem
);
2885 vbyte_mem_ptr
= mem
+ 8;
2886 process_unw_records (list
, output_vbyte_mem
);
2890 size
+= extra
+ 8 + md
.pointer_size
;
2896 convert_expr_to_ab_reg (e
, ab
, regp
)
2903 if (e
->X_op
!= O_register
)
2906 reg
= e
->X_add_number
;
2907 if (reg
>= (REG_GR
+ 4) && reg
<= (REG_GR
+ 7))
2910 *regp
= reg
- REG_GR
;
2912 else if ((reg
>= (REG_FR
+ 2) && reg
<= (REG_FR
+ 5))
2913 || (reg
>= (REG_FR
+ 16) && reg
<= (REG_FR
+ 31)))
2916 *regp
= reg
- REG_FR
;
2918 else if (reg
>= (REG_BR
+ 1) && reg
<= (REG_BR
+ 5))
2921 *regp
= reg
- REG_BR
;
2928 case REG_PR
: *regp
= 0; break;
2929 case REG_PSP
: *regp
= 1; break;
2930 case REG_PRIUNAT
: *regp
= 2; break;
2931 case REG_BR
+ 0: *regp
= 3; break;
2932 case REG_AR
+ AR_BSP
: *regp
= 4; break;
2933 case REG_AR
+ AR_BSPSTORE
: *regp
= 5; break;
2934 case REG_AR
+ AR_RNAT
: *regp
= 6; break;
2935 case REG_AR
+ AR_UNAT
: *regp
= 7; break;
2936 case REG_AR
+ AR_FPSR
: *regp
= 8; break;
2937 case REG_AR
+ AR_PFS
: *regp
= 9; break;
2938 case REG_AR
+ AR_LC
: *regp
= 10; break;
2948 convert_expr_to_xy_reg (e
, xy
, regp
)
2955 if (e
->X_op
!= O_register
)
2958 reg
= e
->X_add_number
;
2960 if (/* reg >= REG_GR && */ reg
<= (REG_GR
+ 127))
2963 *regp
= reg
- REG_GR
;
2965 else if (reg
>= REG_FR
&& reg
<= (REG_FR
+ 127))
2968 *regp
= reg
- REG_FR
;
2970 else if (reg
>= REG_BR
&& reg
<= (REG_BR
+ 7))
2973 *regp
= reg
- REG_BR
;
2982 int dummy ATTRIBUTE_UNUSED
;
2987 radix
= *input_line_pointer
++;
2989 if (radix
!= 'C' && !is_end_of_line
[(unsigned char) radix
])
2991 as_bad ("Radix `%c' unsupported", *input_line_pointer
);
2992 ignore_rest_of_line ();
2997 /* .sbss, .bss etc. are macros that expand into ".section SECNAME". */
2999 dot_special_section (which
)
3002 set_section ((char *) special_section_name
[which
]);
3006 add_unwind_entry (ptr
)
3010 unwind
.tail
->next
= ptr
;
3015 /* The current entry can in fact be a chain of unwind entries. */
3016 if (unwind
.current_entry
== NULL
)
3017 unwind
.current_entry
= ptr
;
3022 int dummy ATTRIBUTE_UNUSED
;
3028 if (e
.X_op
!= O_constant
)
3029 as_bad ("Operand to .fframe must be a constant");
3031 add_unwind_entry (output_mem_stack_f (e
.X_add_number
));
3036 int dummy ATTRIBUTE_UNUSED
;
3042 reg
= e
.X_add_number
- REG_GR
;
3043 if (e
.X_op
== O_register
&& reg
< 128)
3045 add_unwind_entry (output_mem_stack_v ());
3046 if (! (unwind
.prologue_mask
& 2))
3047 add_unwind_entry (output_psp_gr (reg
));
3050 as_bad ("First operand to .vframe must be a general register");
3054 dot_vframesp (dummy
)
3055 int dummy ATTRIBUTE_UNUSED
;
3060 if (e
.X_op
== O_constant
)
3062 add_unwind_entry (output_mem_stack_v ());
3063 add_unwind_entry (output_psp_sprel (e
.X_add_number
));
3066 as_bad ("First operand to .vframesp must be a general register");
3070 dot_vframepsp (dummy
)
3071 int dummy ATTRIBUTE_UNUSED
;
3076 if (e
.X_op
== O_constant
)
3078 add_unwind_entry (output_mem_stack_v ());
3079 add_unwind_entry (output_psp_sprel (e
.X_add_number
));
3082 as_bad ("First operand to .vframepsp must be a general register");
3087 int dummy ATTRIBUTE_UNUSED
;
3093 sep
= parse_operand (&e1
);
3095 as_bad ("No second operand to .save");
3096 sep
= parse_operand (&e2
);
3098 reg1
= e1
.X_add_number
;
3099 reg2
= e2
.X_add_number
- REG_GR
;
3101 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3102 if (e1
.X_op
== O_register
)
3104 if (e2
.X_op
== O_register
&& reg2
>= 0 && reg2
< 128)
3108 case REG_AR
+ AR_BSP
:
3109 add_unwind_entry (output_bsp_when ());
3110 add_unwind_entry (output_bsp_gr (reg2
));
3112 case REG_AR
+ AR_BSPSTORE
:
3113 add_unwind_entry (output_bspstore_when ());
3114 add_unwind_entry (output_bspstore_gr (reg2
));
3116 case REG_AR
+ AR_RNAT
:
3117 add_unwind_entry (output_rnat_when ());
3118 add_unwind_entry (output_rnat_gr (reg2
));
3120 case REG_AR
+ AR_UNAT
:
3121 add_unwind_entry (output_unat_when ());
3122 add_unwind_entry (output_unat_gr (reg2
));
3124 case REG_AR
+ AR_FPSR
:
3125 add_unwind_entry (output_fpsr_when ());
3126 add_unwind_entry (output_fpsr_gr (reg2
));
3128 case REG_AR
+ AR_PFS
:
3129 add_unwind_entry (output_pfs_when ());
3130 if (! (unwind
.prologue_mask
& 4))
3131 add_unwind_entry (output_pfs_gr (reg2
));
3133 case REG_AR
+ AR_LC
:
3134 add_unwind_entry (output_lc_when ());
3135 add_unwind_entry (output_lc_gr (reg2
));
3138 add_unwind_entry (output_rp_when ());
3139 if (! (unwind
.prologue_mask
& 8))
3140 add_unwind_entry (output_rp_gr (reg2
));
3143 add_unwind_entry (output_preds_when ());
3144 if (! (unwind
.prologue_mask
& 1))
3145 add_unwind_entry (output_preds_gr (reg2
));
3148 add_unwind_entry (output_priunat_when_gr ());
3149 add_unwind_entry (output_priunat_gr (reg2
));
3152 as_bad ("First operand not a valid register");
3156 as_bad (" Second operand not a valid register");
3159 as_bad ("First operand not a register");
3164 int dummy ATTRIBUTE_UNUSED
;
3167 unsigned long ecount
; /* # of _additional_ regions to pop */
3170 sep
= parse_operand (&e1
);
3171 if (e1
.X_op
!= O_register
|| e1
.X_add_number
!= REG_GR
+ 12)
3173 as_bad ("First operand to .restore must be stack pointer (sp)");
3179 parse_operand (&e2
);
3180 if (e2
.X_op
!= O_constant
|| e2
.X_add_number
< 0)
3182 as_bad ("Second operand to .restore must be a constant >= 0");
3185 ecount
= e2
.X_add_number
;
3188 ecount
= unwind
.prologue_count
- 1;
3190 if (ecount
>= unwind
.prologue_count
)
3192 as_bad ("Epilogue count of %lu exceeds number of nested prologues (%u)",
3193 ecount
+ 1, unwind
.prologue_count
);
3197 add_unwind_entry (output_epilogue (ecount
));
3199 if (ecount
< unwind
.prologue_count
)
3200 unwind
.prologue_count
-= ecount
+ 1;
3202 unwind
.prologue_count
= 0;
3206 dot_restorereg (dummy
)
3207 int dummy ATTRIBUTE_UNUSED
;
3209 unsigned int ab
, reg
;
3214 if (!convert_expr_to_ab_reg (&e
, &ab
, ®
))
3216 as_bad ("First operand to .restorereg must be a preserved register");
3219 add_unwind_entry (output_spill_reg (ab
, reg
, 0, 0));
3223 dot_restorereg_p (dummy
)
3224 int dummy ATTRIBUTE_UNUSED
;
3226 unsigned int qp
, ab
, reg
;
3230 sep
= parse_operand (&e1
);
3233 as_bad ("No second operand to .restorereg.p");
3237 parse_operand (&e2
);
3239 qp
= e1
.X_add_number
- REG_P
;
3240 if (e1
.X_op
!= O_register
|| qp
> 63)
3242 as_bad ("First operand to .restorereg.p must be a predicate");
3246 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
3248 as_bad ("Second operand to .restorereg.p must be a preserved register");
3251 add_unwind_entry (output_spill_reg_p (ab
, reg
, 0, 0, qp
));
3255 generate_unwind_image (text_name
)
3256 const char *text_name
;
3259 unsigned char *unw_rec
;
3261 /* Force out pending instructions, to make sure all unwind records have
3262 a valid slot_number field. */
3263 ia64_flush_insns ();
3265 /* Generate the unwind record. */
3266 size
= output_unw_records (unwind
.list
, (void **) &unw_rec
);
3267 if (size
% md
.pointer_size
!= 0)
3268 as_bad ("Unwind record is not a multiple of %d bytes.", md
.pointer_size
);
3270 /* If there are unwind records, switch sections, and output the info. */
3273 unsigned char *where
;
3276 bfd_reloc_code_real_type reloc
;
3278 make_unw_section_name (SPECIAL_SECTION_UNWIND_INFO
, text_name
, sec_name
);
3279 set_section (sec_name
);
3280 bfd_set_section_flags (stdoutput
, now_seg
,
3281 SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
);
3283 /* Make sure the section has 4 byte alignment for ILP32 and
3284 8 byte alignment for LP64. */
3285 frag_align (md
.pointer_size_shift
, 0, 0);
3286 record_alignment (now_seg
, md
.pointer_size_shift
);
3288 /* Set expression which points to start of unwind descriptor area. */
3289 unwind
.info
= expr_build_dot ();
3291 where
= (unsigned char *) frag_more (size
);
3293 /* Issue a label for this address, and keep track of it to put it
3294 in the unwind section. */
3296 /* Copy the information from the unwind record into this section. The
3297 data is already in the correct byte order. */
3298 memcpy (where
, unw_rec
, size
);
3300 /* Add the personality address to the image. */
3301 if (unwind
.personality_routine
!= 0)
3303 exp
.X_op
= O_symbol
;
3304 exp
.X_add_symbol
= unwind
.personality_routine
;
3305 exp
.X_add_number
= 0;
3307 if (md
.flags
& EF_IA_64_BE
)
3309 if (md
.flags
& EF_IA_64_ABI64
)
3310 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64MSB
;
3312 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32MSB
;
3316 if (md
.flags
& EF_IA_64_ABI64
)
3317 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64LSB
;
3319 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32LSB
;
3322 fix_new_exp (frag_now
, frag_now_fix () - md
.pointer_size
,
3323 md
.pointer_size
, &exp
, 0, reloc
);
3324 unwind
.personality_routine
= 0;
3328 free_list_records (unwind
.list
);
3329 free_saved_prologue_counts ();
3330 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
3336 dot_handlerdata (dummy
)
3337 int dummy ATTRIBUTE_UNUSED
;
3339 const char *text_name
= segment_name (now_seg
);
3341 /* If text section name starts with ".text" (which it should),
3342 strip this prefix off. */
3343 if (strcmp (text_name
, ".text") == 0)
3346 unwind
.force_unwind_entry
= 1;
3348 /* Remember which segment we're in so we can switch back after .endp */
3349 unwind
.saved_text_seg
= now_seg
;
3350 unwind
.saved_text_subseg
= now_subseg
;
3352 /* Generate unwind info into unwind-info section and then leave that
3353 section as the currently active one so dataXX directives go into
3354 the language specific data area of the unwind info block. */
3355 generate_unwind_image (text_name
);
3356 demand_empty_rest_of_line ();
3360 dot_unwentry (dummy
)
3361 int dummy ATTRIBUTE_UNUSED
;
3363 unwind
.force_unwind_entry
= 1;
3364 demand_empty_rest_of_line ();
3369 int dummy ATTRIBUTE_UNUSED
;
3375 reg
= e
.X_add_number
- REG_BR
;
3376 if (e
.X_op
== O_register
&& reg
< 8)
3377 add_unwind_entry (output_rp_br (reg
));
3379 as_bad ("First operand not a valid branch register");
3383 dot_savemem (psprel
)
3390 sep
= parse_operand (&e1
);
3392 as_bad ("No second operand to .save%ssp", psprel
? "p" : "");
3393 sep
= parse_operand (&e2
);
3395 reg1
= e1
.X_add_number
;
3396 val
= e2
.X_add_number
;
3398 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3399 if (e1
.X_op
== O_register
)
3401 if (e2
.X_op
== O_constant
)
3405 case REG_AR
+ AR_BSP
:
3406 add_unwind_entry (output_bsp_when ());
3407 add_unwind_entry ((psprel
3409 : output_bsp_sprel
) (val
));
3411 case REG_AR
+ AR_BSPSTORE
:
3412 add_unwind_entry (output_bspstore_when ());
3413 add_unwind_entry ((psprel
3414 ? output_bspstore_psprel
3415 : output_bspstore_sprel
) (val
));
3417 case REG_AR
+ AR_RNAT
:
3418 add_unwind_entry (output_rnat_when ());
3419 add_unwind_entry ((psprel
3420 ? output_rnat_psprel
3421 : output_rnat_sprel
) (val
));
3423 case REG_AR
+ AR_UNAT
:
3424 add_unwind_entry (output_unat_when ());
3425 add_unwind_entry ((psprel
3426 ? output_unat_psprel
3427 : output_unat_sprel
) (val
));
3429 case REG_AR
+ AR_FPSR
:
3430 add_unwind_entry (output_fpsr_when ());
3431 add_unwind_entry ((psprel
3432 ? output_fpsr_psprel
3433 : output_fpsr_sprel
) (val
));
3435 case REG_AR
+ AR_PFS
:
3436 add_unwind_entry (output_pfs_when ());
3437 add_unwind_entry ((psprel
3439 : output_pfs_sprel
) (val
));
3441 case REG_AR
+ AR_LC
:
3442 add_unwind_entry (output_lc_when ());
3443 add_unwind_entry ((psprel
3445 : output_lc_sprel
) (val
));
3448 add_unwind_entry (output_rp_when ());
3449 add_unwind_entry ((psprel
3451 : output_rp_sprel
) (val
));
3454 add_unwind_entry (output_preds_when ());
3455 add_unwind_entry ((psprel
3456 ? output_preds_psprel
3457 : output_preds_sprel
) (val
));
3460 add_unwind_entry (output_priunat_when_mem ());
3461 add_unwind_entry ((psprel
3462 ? output_priunat_psprel
3463 : output_priunat_sprel
) (val
));
3466 as_bad ("First operand not a valid register");
3470 as_bad (" Second operand not a valid constant");
3473 as_bad ("First operand not a register");
3478 int dummy ATTRIBUTE_UNUSED
;
3482 sep
= parse_operand (&e1
);
3484 parse_operand (&e2
);
3486 if (e1
.X_op
!= O_constant
)
3487 as_bad ("First operand to .save.g must be a constant.");
3490 int grmask
= e1
.X_add_number
;
3492 add_unwind_entry (output_gr_mem (grmask
));
3495 int reg
= e2
.X_add_number
- REG_GR
;
3496 if (e2
.X_op
== O_register
&& reg
>= 0 && reg
< 128)
3497 add_unwind_entry (output_gr_gr (grmask
, reg
));
3499 as_bad ("Second operand is an invalid register.");
3506 int dummy ATTRIBUTE_UNUSED
;
3510 sep
= parse_operand (&e1
);
3512 if (e1
.X_op
!= O_constant
)
3513 as_bad ("Operand to .save.f must be a constant.");
3515 add_unwind_entry (output_fr_mem (e1
.X_add_number
));
3520 int dummy ATTRIBUTE_UNUSED
;
3527 sep
= parse_operand (&e1
);
3528 if (e1
.X_op
!= O_constant
)
3530 as_bad ("First operand to .save.b must be a constant.");
3533 brmask
= e1
.X_add_number
;
3537 sep
= parse_operand (&e2
);
3538 reg
= e2
.X_add_number
- REG_GR
;
3539 if (e2
.X_op
!= O_register
|| reg
> 127)
3541 as_bad ("Second operand to .save.b must be a general register.");
3544 add_unwind_entry (output_br_gr (brmask
, e2
.X_add_number
));
3547 add_unwind_entry (output_br_mem (brmask
));
3549 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3550 ignore_rest_of_line ();
3555 int dummy ATTRIBUTE_UNUSED
;
3559 sep
= parse_operand (&e1
);
3561 parse_operand (&e2
);
3563 if (e1
.X_op
!= O_constant
|| sep
!= ',' || e2
.X_op
!= O_constant
)
3564 as_bad ("Both operands of .save.gf must be constants.");
3567 int grmask
= e1
.X_add_number
;
3568 int frmask
= e2
.X_add_number
;
3569 add_unwind_entry (output_frgr_mem (grmask
, frmask
));
3575 int dummy ATTRIBUTE_UNUSED
;
3580 sep
= parse_operand (&e
);
3581 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3582 ignore_rest_of_line ();
3584 if (e
.X_op
!= O_constant
)
3585 as_bad ("Operand to .spill must be a constant");
3587 add_unwind_entry (output_spill_base (e
.X_add_number
));
3591 dot_spillreg (dummy
)
3592 int dummy ATTRIBUTE_UNUSED
;
3594 int sep
, ab
, xy
, reg
, treg
;
3597 sep
= parse_operand (&e1
);
3600 as_bad ("No second operand to .spillreg");
3604 parse_operand (&e2
);
3606 if (!convert_expr_to_ab_reg (&e1
, &ab
, ®
))
3608 as_bad ("First operand to .spillreg must be a preserved register");
3612 if (!convert_expr_to_xy_reg (&e2
, &xy
, &treg
))
3614 as_bad ("Second operand to .spillreg must be a register");
3618 add_unwind_entry (output_spill_reg (ab
, reg
, treg
, xy
));
3622 dot_spillmem (psprel
)
3628 sep
= parse_operand (&e1
);
3631 as_bad ("Second operand missing");
3635 parse_operand (&e2
);
3637 if (!convert_expr_to_ab_reg (&e1
, &ab
, ®
))
3639 as_bad ("First operand to .spill%s must be a preserved register",
3640 psprel
? "psp" : "sp");
3644 if (e2
.X_op
!= O_constant
)
3646 as_bad ("Second operand to .spill%s must be a constant",
3647 psprel
? "psp" : "sp");
3652 add_unwind_entry (output_spill_psprel (ab
, reg
, e2
.X_add_number
));
3654 add_unwind_entry (output_spill_sprel (ab
, reg
, e2
.X_add_number
));
3658 dot_spillreg_p (dummy
)
3659 int dummy ATTRIBUTE_UNUSED
;
3661 int sep
, ab
, xy
, reg
, treg
;
3662 expressionS e1
, e2
, e3
;
3665 sep
= parse_operand (&e1
);
3668 as_bad ("No second and third operand to .spillreg.p");
3672 sep
= parse_operand (&e2
);
3675 as_bad ("No third operand to .spillreg.p");
3679 parse_operand (&e3
);
3681 qp
= e1
.X_add_number
- REG_P
;
3683 if (e1
.X_op
!= O_register
|| qp
> 63)
3685 as_bad ("First operand to .spillreg.p must be a predicate");
3689 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
3691 as_bad ("Second operand to .spillreg.p must be a preserved register");
3695 if (!convert_expr_to_xy_reg (&e3
, &xy
, &treg
))
3697 as_bad ("Third operand to .spillreg.p must be a register");
3701 add_unwind_entry (output_spill_reg_p (ab
, reg
, treg
, xy
, qp
));
3705 dot_spillmem_p (psprel
)
3708 expressionS e1
, e2
, e3
;
3712 sep
= parse_operand (&e1
);
3715 as_bad ("Second operand missing");
3719 parse_operand (&e2
);
3722 as_bad ("Second operand missing");
3726 parse_operand (&e3
);
3728 qp
= e1
.X_add_number
- REG_P
;
3729 if (e1
.X_op
!= O_register
|| qp
> 63)
3731 as_bad ("First operand to .spill%s_p must be a predicate",
3732 psprel
? "psp" : "sp");
3736 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
3738 as_bad ("Second operand to .spill%s_p must be a preserved register",
3739 psprel
? "psp" : "sp");
3743 if (e3
.X_op
!= O_constant
)
3745 as_bad ("Third operand to .spill%s_p must be a constant",
3746 psprel
? "psp" : "sp");
3751 add_unwind_entry (output_spill_psprel_p (ab
, reg
, e3
.X_add_number
, qp
));
3753 add_unwind_entry (output_spill_sprel_p (ab
, reg
, e3
.X_add_number
, qp
));
3757 get_saved_prologue_count (lbl
)
3760 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3762 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
3766 return lpc
->prologue_count
;
3768 as_bad ("Missing .label_state %ld", lbl
);
3773 save_prologue_count (lbl
, count
)
3777 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3779 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
3783 lpc
->prologue_count
= count
;
3786 label_prologue_count
*new_lpc
= xmalloc (sizeof (* new_lpc
));
3788 new_lpc
->next
= unwind
.saved_prologue_counts
;
3789 new_lpc
->label_number
= lbl
;
3790 new_lpc
->prologue_count
= count
;
3791 unwind
.saved_prologue_counts
= new_lpc
;
3796 free_saved_prologue_counts ()
3798 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3799 label_prologue_count
*next
;
3808 unwind
.saved_prologue_counts
= NULL
;
3812 dot_label_state (dummy
)
3813 int dummy ATTRIBUTE_UNUSED
;
3818 if (e
.X_op
!= O_constant
)
3820 as_bad ("Operand to .label_state must be a constant");
3823 add_unwind_entry (output_label_state (e
.X_add_number
));
3824 save_prologue_count (e
.X_add_number
, unwind
.prologue_count
);
3828 dot_copy_state (dummy
)
3829 int dummy ATTRIBUTE_UNUSED
;
3834 if (e
.X_op
!= O_constant
)
3836 as_bad ("Operand to .copy_state must be a constant");
3839 add_unwind_entry (output_copy_state (e
.X_add_number
));
3840 unwind
.prologue_count
= get_saved_prologue_count (e
.X_add_number
);
3845 int dummy ATTRIBUTE_UNUSED
;
3850 sep
= parse_operand (&e1
);
3853 as_bad ("Second operand to .unwabi missing");
3856 sep
= parse_operand (&e2
);
3857 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3858 ignore_rest_of_line ();
3860 if (e1
.X_op
!= O_constant
)
3862 as_bad ("First operand to .unwabi must be a constant");
3866 if (e2
.X_op
!= O_constant
)
3868 as_bad ("Second operand to .unwabi must be a constant");
3872 add_unwind_entry (output_unwabi (e1
.X_add_number
, e2
.X_add_number
));
3876 dot_personality (dummy
)
3877 int dummy ATTRIBUTE_UNUSED
;
3881 name
= input_line_pointer
;
3882 c
= get_symbol_end ();
3883 p
= input_line_pointer
;
3884 unwind
.personality_routine
= symbol_find_or_make (name
);
3885 unwind
.force_unwind_entry
= 1;
3888 demand_empty_rest_of_line ();
3893 int dummy ATTRIBUTE_UNUSED
;
3898 unwind
.proc_start
= expr_build_dot ();
3899 /* Parse names of main and alternate entry points and mark them as
3900 function symbols: */
3904 name
= input_line_pointer
;
3905 c
= get_symbol_end ();
3906 p
= input_line_pointer
;
3907 sym
= symbol_find_or_make (name
);
3908 if (unwind
.proc_start
== 0)
3910 unwind
.proc_start
= sym
;
3912 symbol_get_bfdsym (sym
)->flags
|= BSF_FUNCTION
;
3915 if (*input_line_pointer
!= ',')
3917 ++input_line_pointer
;
3919 demand_empty_rest_of_line ();
3922 unwind
.prologue_count
= 0;
3923 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
3924 unwind
.personality_routine
= 0;
3929 int dummy ATTRIBUTE_UNUSED
;
3931 unwind
.prologue
= 0;
3932 unwind
.prologue_mask
= 0;
3934 add_unwind_entry (output_body ());
3935 demand_empty_rest_of_line ();
3939 dot_prologue (dummy
)
3940 int dummy ATTRIBUTE_UNUSED
;
3943 int mask
= 0, grsave
= 0;
3945 if (!is_it_end_of_statement ())
3948 sep
= parse_operand (&e1
);
3950 as_bad ("No second operand to .prologue");
3951 sep
= parse_operand (&e2
);
3952 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3953 ignore_rest_of_line ();
3955 if (e1
.X_op
== O_constant
)
3957 mask
= e1
.X_add_number
;
3959 if (e2
.X_op
== O_constant
)
3960 grsave
= e2
.X_add_number
;
3961 else if (e2
.X_op
== O_register
3962 && (grsave
= e2
.X_add_number
- REG_GR
) < 128)
3965 as_bad ("Second operand not a constant or general register");
3967 add_unwind_entry (output_prologue_gr (mask
, grsave
));
3970 as_bad ("First operand not a constant");
3973 add_unwind_entry (output_prologue ());
3975 unwind
.prologue
= 1;
3976 unwind
.prologue_mask
= mask
;
3977 ++unwind
.prologue_count
;
3982 int dummy ATTRIBUTE_UNUSED
;
3986 int bytes_per_address
;
3989 subsegT saved_subseg
;
3990 const char *sec_name
, *text_name
;
3994 if (unwind
.saved_text_seg
)
3996 saved_seg
= unwind
.saved_text_seg
;
3997 saved_subseg
= unwind
.saved_text_subseg
;
3998 unwind
.saved_text_seg
= NULL
;
4002 saved_seg
= now_seg
;
4003 saved_subseg
= now_subseg
;
4007 Use a slightly ugly scheme to derive the unwind section names from
4008 the text section name:
4010 text sect. unwind table sect.
4011 name: name: comments:
4012 ---------- ----------------- --------------------------------
4014 .text.foo .IA_64.unwind.text.foo
4015 .foo .IA_64.unwind.foo
4017 .gnu.linkonce.ia64unw.foo
4018 _info .IA_64.unwind_info gas issues error message (ditto)
4019 _infoFOO .IA_64.unwind_infoFOO gas issues error message (ditto)
4021 This mapping is done so that:
4023 (a) An object file with unwind info only in .text will use
4024 unwind section names .IA_64.unwind and .IA_64.unwind_info.
4025 This follows the letter of the ABI and also ensures backwards
4026 compatibility with older toolchains.
4028 (b) An object file with unwind info in multiple text sections
4029 will use separate unwind sections for each text section.
4030 This allows us to properly set the "sh_info" and "sh_link"
4031 fields in SHT_IA_64_UNWIND as required by the ABI and also
4032 lets GNU ld support programs with multiple segments
4033 containing unwind info (as might be the case for certain
4034 embedded applications).
4036 (c) An error is issued if there would be a name clash.
4038 text_name
= segment_name (saved_seg
);
4039 if (strncmp (text_name
, "_info", 5) == 0)
4041 as_bad ("Illegal section name `%s' (causes unwind section name clash)",
4043 ignore_rest_of_line ();
4046 if (strcmp (text_name
, ".text") == 0)
4049 insn_group_break (1, 0, 0);
4051 /* If there wasn't a .handlerdata, we haven't generated an image yet. */
4053 generate_unwind_image (text_name
);
4055 if (unwind
.info
|| unwind
.force_unwind_entry
)
4057 subseg_set (md
.last_text_seg
, 0);
4058 unwind
.proc_end
= expr_build_dot ();
4060 make_unw_section_name (SPECIAL_SECTION_UNWIND
, text_name
, sec_name
);
4061 set_section ((char *) sec_name
);
4062 bfd_set_section_flags (stdoutput
, now_seg
,
4063 SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
);
4065 /* Make sure that section has 4 byte alignment for ILP32 and
4066 8 byte alignment for LP64. */
4067 record_alignment (now_seg
, md
.pointer_size_shift
);
4069 /* Need space for 3 pointers for procedure start, procedure end,
4071 ptr
= frag_more (3 * md
.pointer_size
);
4072 where
= frag_now_fix () - (3 * md
.pointer_size
);
4073 bytes_per_address
= bfd_arch_bits_per_address (stdoutput
) / 8;
4075 /* Issue the values of a) Proc Begin, b) Proc End, c) Unwind Record. */
4076 e
.X_op
= O_pseudo_fixup
;
4077 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4079 e
.X_add_symbol
= unwind
.proc_start
;
4080 ia64_cons_fix_new (frag_now
, where
, bytes_per_address
, &e
);
4082 e
.X_op
= O_pseudo_fixup
;
4083 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4085 e
.X_add_symbol
= unwind
.proc_end
;
4086 ia64_cons_fix_new (frag_now
, where
+ bytes_per_address
,
4087 bytes_per_address
, &e
);
4091 e
.X_op
= O_pseudo_fixup
;
4092 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4094 e
.X_add_symbol
= unwind
.info
;
4095 ia64_cons_fix_new (frag_now
, where
+ (bytes_per_address
* 2),
4096 bytes_per_address
, &e
);
4099 md_number_to_chars (ptr
+ (bytes_per_address
* 2), 0,
4103 subseg_set (saved_seg
, saved_subseg
);
4105 /* Parse names of main and alternate entry points and set symbol sizes. */
4109 name
= input_line_pointer
;
4110 c
= get_symbol_end ();
4111 p
= input_line_pointer
;
4112 sym
= symbol_find (name
);
4113 if (sym
&& unwind
.proc_start
4114 && (symbol_get_bfdsym (sym
)->flags
& BSF_FUNCTION
)
4115 && S_GET_SIZE (sym
) == 0 && symbol_get_obj (sym
)->size
== NULL
)
4117 fragS
*fr
= symbol_get_frag (unwind
.proc_start
);
4118 fragS
*frag
= symbol_get_frag (sym
);
4120 /* Check whether the function label is at or beyond last
4122 while (fr
&& fr
!= frag
)
4126 if (frag
== frag_now
&& SEG_NORMAL (now_seg
))
4127 S_SET_SIZE (sym
, frag_now_fix () - S_GET_VALUE (sym
));
4130 symbol_get_obj (sym
)->size
=
4131 (expressionS
*) xmalloc (sizeof (expressionS
));
4132 symbol_get_obj (sym
)->size
->X_op
= O_subtract
;
4133 symbol_get_obj (sym
)->size
->X_add_symbol
4134 = symbol_new (FAKE_LABEL_NAME
, now_seg
,
4135 frag_now_fix (), frag_now
);
4136 symbol_get_obj (sym
)->size
->X_op_symbol
= sym
;
4137 symbol_get_obj (sym
)->size
->X_add_number
= 0;
4143 if (*input_line_pointer
!= ',')
4145 ++input_line_pointer
;
4147 demand_empty_rest_of_line ();
4148 unwind
.proc_start
= unwind
.proc_end
= unwind
.info
= 0;
4152 dot_template (template)
4155 CURR_SLOT
.user_template
= template;
4160 int dummy ATTRIBUTE_UNUSED
;
4162 int ins
, locs
, outs
, rots
;
4164 if (is_it_end_of_statement ())
4165 ins
= locs
= outs
= rots
= 0;
4168 ins
= get_absolute_expression ();
4169 if (*input_line_pointer
++ != ',')
4171 locs
= get_absolute_expression ();
4172 if (*input_line_pointer
++ != ',')
4174 outs
= get_absolute_expression ();
4175 if (*input_line_pointer
++ != ',')
4177 rots
= get_absolute_expression ();
4179 set_regstack (ins
, locs
, outs
, rots
);
4183 as_bad ("Comma expected");
4184 ignore_rest_of_line ();
4191 unsigned num_regs
, num_alloced
= 0;
4192 struct dynreg
**drpp
, *dr
;
4193 int ch
, base_reg
= 0;
4199 case DYNREG_GR
: base_reg
= REG_GR
+ 32; break;
4200 case DYNREG_FR
: base_reg
= REG_FR
+ 32; break;
4201 case DYNREG_PR
: base_reg
= REG_P
+ 16; break;
4205 /* First, remove existing names from hash table. */
4206 for (dr
= md
.dynreg
[type
]; dr
&& dr
->num_regs
; dr
= dr
->next
)
4208 hash_delete (md
.dynreg_hash
, dr
->name
);
4212 drpp
= &md
.dynreg
[type
];
4215 start
= input_line_pointer
;
4216 ch
= get_symbol_end ();
4217 *input_line_pointer
= ch
;
4218 len
= (input_line_pointer
- start
);
4221 if (*input_line_pointer
!= '[')
4223 as_bad ("Expected '['");
4226 ++input_line_pointer
; /* skip '[' */
4228 num_regs
= get_absolute_expression ();
4230 if (*input_line_pointer
++ != ']')
4232 as_bad ("Expected ']'");
4237 num_alloced
+= num_regs
;
4241 if (num_alloced
> md
.rot
.num_regs
)
4243 as_bad ("Used more than the declared %d rotating registers",
4249 if (num_alloced
> 96)
4251 as_bad ("Used more than the available 96 rotating registers");
4256 if (num_alloced
> 48)
4258 as_bad ("Used more than the available 48 rotating registers");
4267 name
= obstack_alloc (¬es
, len
+ 1);
4268 memcpy (name
, start
, len
);
4273 *drpp
= obstack_alloc (¬es
, sizeof (*dr
));
4274 memset (*drpp
, 0, sizeof (*dr
));
4279 dr
->num_regs
= num_regs
;
4280 dr
->base
= base_reg
;
4282 base_reg
+= num_regs
;
4284 if (hash_insert (md
.dynreg_hash
, name
, dr
))
4286 as_bad ("Attempt to redefine register set `%s'", name
);
4290 if (*input_line_pointer
!= ',')
4292 ++input_line_pointer
; /* skip comma */
4295 demand_empty_rest_of_line ();
4299 ignore_rest_of_line ();
4303 dot_byteorder (byteorder
)
4306 target_big_endian
= byteorder
;
4311 int dummy ATTRIBUTE_UNUSED
;
4318 option
= input_line_pointer
;
4319 ch
= get_symbol_end ();
4320 if (strcmp (option
, "lsb") == 0)
4321 md
.flags
&= ~EF_IA_64_BE
;
4322 else if (strcmp (option
, "msb") == 0)
4323 md
.flags
|= EF_IA_64_BE
;
4324 else if (strcmp (option
, "abi32") == 0)
4325 md
.flags
&= ~EF_IA_64_ABI64
;
4326 else if (strcmp (option
, "abi64") == 0)
4327 md
.flags
|= EF_IA_64_ABI64
;
4329 as_bad ("Unknown psr option `%s'", option
);
4330 *input_line_pointer
= ch
;
4333 if (*input_line_pointer
!= ',')
4336 ++input_line_pointer
;
4339 demand_empty_rest_of_line ();
4344 int dummy ATTRIBUTE_UNUSED
;
4346 as_bad (".alias not implemented yet");
4351 int dummy ATTRIBUTE_UNUSED
;
4353 new_logical_line (0, get_absolute_expression ());
4354 demand_empty_rest_of_line ();
4358 parse_section_name ()
4364 if (*input_line_pointer
!= '"')
4366 as_bad ("Missing section name");
4367 ignore_rest_of_line ();
4370 name
= demand_copy_C_string (&len
);
4373 ignore_rest_of_line ();
4377 if (*input_line_pointer
!= ',')
4379 as_bad ("Comma expected after section name");
4380 ignore_rest_of_line ();
4383 ++input_line_pointer
; /* skip comma */
4391 char *name
= parse_section_name ();
4395 md
.keep_pending_output
= 1;
4398 obj_elf_previous (0);
4399 md
.keep_pending_output
= 0;
4402 /* Why doesn't float_cons() call md_cons_align() the way cons() does? */
4405 stmt_float_cons (kind
)
4412 case 'd': size
= 8; break;
4413 case 'x': size
= 10; break;
4420 ia64_do_align (size
);
4428 int saved_auto_align
= md
.auto_align
;
4432 md
.auto_align
= saved_auto_align
;
4436 dot_xfloat_cons (kind
)
4439 char *name
= parse_section_name ();
4443 md
.keep_pending_output
= 1;
4445 stmt_float_cons (kind
);
4446 obj_elf_previous (0);
4447 md
.keep_pending_output
= 0;
4451 dot_xstringer (zero
)
4454 char *name
= parse_section_name ();
4458 md
.keep_pending_output
= 1;
4461 obj_elf_previous (0);
4462 md
.keep_pending_output
= 0;
4469 int saved_auto_align
= md
.auto_align
;
4470 char *name
= parse_section_name ();
4474 md
.keep_pending_output
= 1;
4478 md
.auto_align
= saved_auto_align
;
4479 obj_elf_previous (0);
4480 md
.keep_pending_output
= 0;
4484 dot_xfloat_cons_ua (kind
)
4487 int saved_auto_align
= md
.auto_align
;
4488 char *name
= parse_section_name ();
4492 md
.keep_pending_output
= 1;
4495 stmt_float_cons (kind
);
4496 md
.auto_align
= saved_auto_align
;
4497 obj_elf_previous (0);
4498 md
.keep_pending_output
= 0;
4501 /* .reg.val <regname>,value */
4505 int dummy ATTRIBUTE_UNUSED
;
4510 if (reg
.X_op
!= O_register
)
4512 as_bad (_("Register name expected"));
4513 ignore_rest_of_line ();
4515 else if (*input_line_pointer
++ != ',')
4517 as_bad (_("Comma expected"));
4518 ignore_rest_of_line ();
4522 valueT value
= get_absolute_expression ();
4523 int regno
= reg
.X_add_number
;
4524 if (regno
< REG_GR
|| regno
> REG_GR
+ 128)
4525 as_warn (_("Register value annotation ignored"));
4528 gr_values
[regno
- REG_GR
].known
= 1;
4529 gr_values
[regno
- REG_GR
].value
= value
;
4530 gr_values
[regno
- REG_GR
].path
= md
.path
;
4533 demand_empty_rest_of_line ();
4536 /* select dv checking mode
4541 A stop is inserted when changing modes
4548 if (md
.manual_bundling
)
4549 as_warn (_("Directive invalid within a bundle"));
4551 if (type
== 'E' || type
== 'A')
4552 md
.mode_explicitly_set
= 0;
4554 md
.mode_explicitly_set
= 1;
4561 if (md
.explicit_mode
)
4562 insn_group_break (1, 0, 0);
4563 md
.explicit_mode
= 0;
4567 if (!md
.explicit_mode
)
4568 insn_group_break (1, 0, 0);
4569 md
.explicit_mode
= 1;
4573 if (md
.explicit_mode
!= md
.default_explicit_mode
)
4574 insn_group_break (1, 0, 0);
4575 md
.explicit_mode
= md
.default_explicit_mode
;
4576 md
.mode_explicitly_set
= 0;
4587 for (regno
= 0; regno
< 64; regno
++)
4589 if (mask
& ((valueT
) 1 << regno
))
4591 fprintf (stderr
, "%s p%d", comma
, regno
);
4598 .pred.rel.clear [p1 [,p2 [,...]]] (also .pred.rel "clear")
4599 .pred.rel.imply p1, p2 (also .pred.rel "imply")
4600 .pred.rel.mutex p1, p2 [,...] (also .pred.rel "mutex")
4601 .pred.safe_across_calls p1 [, p2 [,...]]
4610 int p1
= -1, p2
= -1;
4614 if (*input_line_pointer
!= '"')
4616 as_bad (_("Missing predicate relation type"));
4617 ignore_rest_of_line ();
4623 char *form
= demand_copy_C_string (&len
);
4624 if (strcmp (form
, "mutex") == 0)
4626 else if (strcmp (form
, "clear") == 0)
4628 else if (strcmp (form
, "imply") == 0)
4632 as_bad (_("Unrecognized predicate relation type"));
4633 ignore_rest_of_line ();
4637 if (*input_line_pointer
== ',')
4638 ++input_line_pointer
;
4648 if (TOUPPER (*input_line_pointer
) != 'P'
4649 || (regno
= atoi (++input_line_pointer
)) < 0
4652 as_bad (_("Predicate register expected"));
4653 ignore_rest_of_line ();
4656 while (ISDIGIT (*input_line_pointer
))
4657 ++input_line_pointer
;
4664 as_warn (_("Duplicate predicate register ignored"));
4667 /* See if it's a range. */
4668 if (*input_line_pointer
== '-')
4671 ++input_line_pointer
;
4673 if (TOUPPER (*input_line_pointer
) != 'P'
4674 || (regno
= atoi (++input_line_pointer
)) < 0
4677 as_bad (_("Predicate register expected"));
4678 ignore_rest_of_line ();
4681 while (ISDIGIT (*input_line_pointer
))
4682 ++input_line_pointer
;
4686 as_bad (_("Bad register range"));
4687 ignore_rest_of_line ();
4698 if (*input_line_pointer
!= ',')
4700 ++input_line_pointer
;
4709 clear_qp_mutex (mask
);
4710 clear_qp_implies (mask
, (valueT
) 0);
4713 if (count
!= 2 || p1
== -1 || p2
== -1)
4714 as_bad (_("Predicate source and target required"));
4715 else if (p1
== 0 || p2
== 0)
4716 as_bad (_("Use of p0 is not valid in this context"));
4718 add_qp_imply (p1
, p2
);
4723 as_bad (_("At least two PR arguments expected"));
4728 as_bad (_("Use of p0 is not valid in this context"));
4731 add_qp_mutex (mask
);
4734 /* note that we don't override any existing relations */
4737 as_bad (_("At least one PR argument expected"));
4742 fprintf (stderr
, "Safe across calls: ");
4743 print_prmask (mask
);
4744 fprintf (stderr
, "\n");
4746 qp_safe_across_calls
= mask
;
4749 demand_empty_rest_of_line ();
4752 /* .entry label [, label [, ...]]
4753 Hint to DV code that the given labels are to be considered entry points.
4754 Otherwise, only global labels are considered entry points. */
4758 int dummy ATTRIBUTE_UNUSED
;
4767 name
= input_line_pointer
;
4768 c
= get_symbol_end ();
4769 symbolP
= symbol_find_or_make (name
);
4771 err
= hash_insert (md
.entry_hash
, S_GET_NAME (symbolP
), (PTR
) symbolP
);
4773 as_fatal (_("Inserting \"%s\" into entry hint table failed: %s"),
4776 *input_line_pointer
= c
;
4778 c
= *input_line_pointer
;
4781 input_line_pointer
++;
4783 if (*input_line_pointer
== '\n')
4789 demand_empty_rest_of_line ();
4792 /* .mem.offset offset, base
4793 "base" is used to distinguish between offsets from a different base. */
4796 dot_mem_offset (dummy
)
4797 int dummy ATTRIBUTE_UNUSED
;
4799 md
.mem_offset
.hint
= 1;
4800 md
.mem_offset
.offset
= get_absolute_expression ();
4801 if (*input_line_pointer
!= ',')
4803 as_bad (_("Comma expected"));
4804 ignore_rest_of_line ();
4807 ++input_line_pointer
;
4808 md
.mem_offset
.base
= get_absolute_expression ();
4809 demand_empty_rest_of_line ();
4812 /* ia64-specific pseudo-ops: */
4813 const pseudo_typeS md_pseudo_table
[] =
4815 { "radix", dot_radix
, 0 },
4816 { "lcomm", s_lcomm_bytes
, 1 },
4817 { "bss", dot_special_section
, SPECIAL_SECTION_BSS
},
4818 { "sbss", dot_special_section
, SPECIAL_SECTION_SBSS
},
4819 { "sdata", dot_special_section
, SPECIAL_SECTION_SDATA
},
4820 { "rodata", dot_special_section
, SPECIAL_SECTION_RODATA
},
4821 { "comment", dot_special_section
, SPECIAL_SECTION_COMMENT
},
4822 { "ia_64.unwind", dot_special_section
, SPECIAL_SECTION_UNWIND
},
4823 { "ia_64.unwind_info", dot_special_section
, SPECIAL_SECTION_UNWIND_INFO
},
4824 { "init_array", dot_special_section
, SPECIAL_SECTION_INIT_ARRAY
},
4825 { "fini_array", dot_special_section
, SPECIAL_SECTION_FINI_ARRAY
},
4826 { "proc", dot_proc
, 0 },
4827 { "body", dot_body
, 0 },
4828 { "prologue", dot_prologue
, 0 },
4829 { "endp", dot_endp
, 0 },
4830 { "file", (void (*) PARAMS ((int))) dwarf2_directive_file
, 0 },
4831 { "loc", dwarf2_directive_loc
, 0 },
4833 { "fframe", dot_fframe
, 0 },
4834 { "vframe", dot_vframe
, 0 },
4835 { "vframesp", dot_vframesp
, 0 },
4836 { "vframepsp", dot_vframepsp
, 0 },
4837 { "save", dot_save
, 0 },
4838 { "restore", dot_restore
, 0 },
4839 { "restorereg", dot_restorereg
, 0 },
4840 { "restorereg.p", dot_restorereg_p
, 0 },
4841 { "handlerdata", dot_handlerdata
, 0 },
4842 { "unwentry", dot_unwentry
, 0 },
4843 { "altrp", dot_altrp
, 0 },
4844 { "savesp", dot_savemem
, 0 },
4845 { "savepsp", dot_savemem
, 1 },
4846 { "save.g", dot_saveg
, 0 },
4847 { "save.f", dot_savef
, 0 },
4848 { "save.b", dot_saveb
, 0 },
4849 { "save.gf", dot_savegf
, 0 },
4850 { "spill", dot_spill
, 0 },
4851 { "spillreg", dot_spillreg
, 0 },
4852 { "spillsp", dot_spillmem
, 0 },
4853 { "spillpsp", dot_spillmem
, 1 },
4854 { "spillreg.p", dot_spillreg_p
, 0 },
4855 { "spillsp.p", dot_spillmem_p
, 0 },
4856 { "spillpsp.p", dot_spillmem_p
, 1 },
4857 { "label_state", dot_label_state
, 0 },
4858 { "copy_state", dot_copy_state
, 0 },
4859 { "unwabi", dot_unwabi
, 0 },
4860 { "personality", dot_personality
, 0 },
4862 { "estate", dot_estate
, 0 },
4864 { "mii", dot_template
, 0x0 },
4865 { "mli", dot_template
, 0x2 }, /* old format, for compatibility */
4866 { "mlx", dot_template
, 0x2 },
4867 { "mmi", dot_template
, 0x4 },
4868 { "mfi", dot_template
, 0x6 },
4869 { "mmf", dot_template
, 0x7 },
4870 { "mib", dot_template
, 0x8 },
4871 { "mbb", dot_template
, 0x9 },
4872 { "bbb", dot_template
, 0xb },
4873 { "mmb", dot_template
, 0xc },
4874 { "mfb", dot_template
, 0xe },
4876 { "lb", dot_scope
, 0 },
4877 { "le", dot_scope
, 1 },
4879 { "align", s_align_bytes
, 0 },
4880 { "regstk", dot_regstk
, 0 },
4881 { "rotr", dot_rot
, DYNREG_GR
},
4882 { "rotf", dot_rot
, DYNREG_FR
},
4883 { "rotp", dot_rot
, DYNREG_PR
},
4884 { "lsb", dot_byteorder
, 0 },
4885 { "msb", dot_byteorder
, 1 },
4886 { "psr", dot_psr
, 0 },
4887 { "alias", dot_alias
, 0 },
4888 { "ln", dot_ln
, 0 }, /* source line info (for debugging) */
4890 { "xdata1", dot_xdata
, 1 },
4891 { "xdata2", dot_xdata
, 2 },
4892 { "xdata4", dot_xdata
, 4 },
4893 { "xdata8", dot_xdata
, 8 },
4894 { "xreal4", dot_xfloat_cons
, 'f' },
4895 { "xreal8", dot_xfloat_cons
, 'd' },
4896 { "xreal10", dot_xfloat_cons
, 'x' },
4897 { "xstring", dot_xstringer
, 0 },
4898 { "xstringz", dot_xstringer
, 1 },
4900 /* unaligned versions: */
4901 { "xdata2.ua", dot_xdata_ua
, 2 },
4902 { "xdata4.ua", dot_xdata_ua
, 4 },
4903 { "xdata8.ua", dot_xdata_ua
, 8 },
4904 { "xreal4.ua", dot_xfloat_cons_ua
, 'f' },
4905 { "xreal8.ua", dot_xfloat_cons_ua
, 'd' },
4906 { "xreal10.ua", dot_xfloat_cons_ua
, 'x' },
4908 /* annotations/DV checking support */
4909 { "entry", dot_entry
, 0 },
4910 { "mem.offset", dot_mem_offset
, 0 },
4911 { "pred.rel", dot_pred_rel
, 0 },
4912 { "pred.rel.clear", dot_pred_rel
, 'c' },
4913 { "pred.rel.imply", dot_pred_rel
, 'i' },
4914 { "pred.rel.mutex", dot_pred_rel
, 'm' },
4915 { "pred.safe_across_calls", dot_pred_rel
, 's' },
4916 { "reg.val", dot_reg_val
, 0 },
4917 { "auto", dot_dv_mode
, 'a' },
4918 { "explicit", dot_dv_mode
, 'e' },
4919 { "default", dot_dv_mode
, 'd' },
4921 /* ??? These are needed to make gas/testsuite/gas/elf/ehopt.s work.
4922 IA-64 aligns data allocation pseudo-ops by default, so we have to
4923 tell it that these ones are supposed to be unaligned. Long term,
4924 should rewrite so that only IA-64 specific data allocation pseudo-ops
4925 are aligned by default. */
4926 {"2byte", stmt_cons_ua
, 2},
4927 {"4byte", stmt_cons_ua
, 4},
4928 {"8byte", stmt_cons_ua
, 8},
4933 static const struct pseudo_opcode
4936 void (*handler
) (int);
4941 /* these are more like pseudo-ops, but don't start with a dot */
4942 { "data1", cons
, 1 },
4943 { "data2", cons
, 2 },
4944 { "data4", cons
, 4 },
4945 { "data8", cons
, 8 },
4946 { "data16", cons
, 16 },
4947 { "real4", stmt_float_cons
, 'f' },
4948 { "real8", stmt_float_cons
, 'd' },
4949 { "real10", stmt_float_cons
, 'x' },
4950 { "string", stringer
, 0 },
4951 { "stringz", stringer
, 1 },
4953 /* unaligned versions: */
4954 { "data2.ua", stmt_cons_ua
, 2 },
4955 { "data4.ua", stmt_cons_ua
, 4 },
4956 { "data8.ua", stmt_cons_ua
, 8 },
4957 { "data16.ua", stmt_cons_ua
, 16 },
4958 { "real4.ua", float_cons
, 'f' },
4959 { "real8.ua", float_cons
, 'd' },
4960 { "real10.ua", float_cons
, 'x' },
4963 /* Declare a register by creating a symbol for it and entering it in
4964 the symbol table. */
4967 declare_register (name
, regnum
)
4974 sym
= symbol_new (name
, reg_section
, regnum
, &zero_address_frag
);
4976 err
= hash_insert (md
.reg_hash
, S_GET_NAME (sym
), (PTR
) sym
);
4978 as_fatal ("Inserting \"%s\" into register table failed: %s",
4985 declare_register_set (prefix
, num_regs
, base_regnum
)
4993 for (i
= 0; i
< num_regs
; ++i
)
4995 sprintf (name
, "%s%u", prefix
, i
);
4996 declare_register (name
, base_regnum
+ i
);
5001 operand_width (opnd
)
5002 enum ia64_opnd opnd
;
5004 const struct ia64_operand
*odesc
= &elf64_ia64_operands
[opnd
];
5005 unsigned int bits
= 0;
5009 for (i
= 0; i
< NELEMS (odesc
->field
) && odesc
->field
[i
].bits
; ++i
)
5010 bits
+= odesc
->field
[i
].bits
;
5015 static enum operand_match_result
5016 operand_match (idesc
, index
, e
)
5017 const struct ia64_opcode
*idesc
;
5021 enum ia64_opnd opnd
= idesc
->operands
[index
];
5022 int bits
, relocatable
= 0;
5023 struct insn_fix
*fix
;
5030 case IA64_OPND_AR_CCV
:
5031 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 32)
5032 return OPERAND_MATCH
;
5035 case IA64_OPND_AR_PFS
:
5036 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 64)
5037 return OPERAND_MATCH
;
5041 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_GR
+ 0)
5042 return OPERAND_MATCH
;
5046 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_IP
)
5047 return OPERAND_MATCH
;
5051 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR
)
5052 return OPERAND_MATCH
;
5055 case IA64_OPND_PR_ROT
:
5056 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR_ROT
)
5057 return OPERAND_MATCH
;
5061 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR
)
5062 return OPERAND_MATCH
;
5065 case IA64_OPND_PSR_L
:
5066 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_L
)
5067 return OPERAND_MATCH
;
5070 case IA64_OPND_PSR_UM
:
5071 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_UM
)
5072 return OPERAND_MATCH
;
5076 if (e
->X_op
== O_constant
)
5078 if (e
->X_add_number
== 1)
5079 return OPERAND_MATCH
;
5081 return OPERAND_OUT_OF_RANGE
;
5086 if (e
->X_op
== O_constant
)
5088 if (e
->X_add_number
== 8)
5089 return OPERAND_MATCH
;
5091 return OPERAND_OUT_OF_RANGE
;
5096 if (e
->X_op
== O_constant
)
5098 if (e
->X_add_number
== 16)
5099 return OPERAND_MATCH
;
5101 return OPERAND_OUT_OF_RANGE
;
5105 /* register operands: */
5108 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_AR
5109 && e
->X_add_number
< REG_AR
+ 128)
5110 return OPERAND_MATCH
;
5115 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_BR
5116 && e
->X_add_number
< REG_BR
+ 8)
5117 return OPERAND_MATCH
;
5121 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_CR
5122 && e
->X_add_number
< REG_CR
+ 128)
5123 return OPERAND_MATCH
;
5130 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_FR
5131 && e
->X_add_number
< REG_FR
+ 128)
5132 return OPERAND_MATCH
;
5137 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_P
5138 && e
->X_add_number
< REG_P
+ 64)
5139 return OPERAND_MATCH
;
5145 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
5146 && e
->X_add_number
< REG_GR
+ 128)
5147 return OPERAND_MATCH
;
5150 case IA64_OPND_R3_2
:
5151 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
)
5153 if (e
->X_add_number
< REG_GR
+ 4)
5154 return OPERAND_MATCH
;
5155 else if (e
->X_add_number
< REG_GR
+ 128)
5156 return OPERAND_OUT_OF_RANGE
;
5160 /* indirect operands: */
5161 case IA64_OPND_CPUID_R3
:
5162 case IA64_OPND_DBR_R3
:
5163 case IA64_OPND_DTR_R3
:
5164 case IA64_OPND_ITR_R3
:
5165 case IA64_OPND_IBR_R3
:
5166 case IA64_OPND_MSR_R3
:
5167 case IA64_OPND_PKR_R3
:
5168 case IA64_OPND_PMC_R3
:
5169 case IA64_OPND_PMD_R3
:
5170 case IA64_OPND_RR_R3
:
5171 if (e
->X_op
== O_index
&& e
->X_op_symbol
5172 && (S_GET_VALUE (e
->X_op_symbol
) - IND_CPUID
5173 == opnd
- IA64_OPND_CPUID_R3
))
5174 return OPERAND_MATCH
;
5178 if (e
->X_op
== O_index
&& !e
->X_op_symbol
)
5179 return OPERAND_MATCH
;
5182 /* immediate operands: */
5183 case IA64_OPND_CNT2a
:
5184 case IA64_OPND_LEN4
:
5185 case IA64_OPND_LEN6
:
5186 bits
= operand_width (idesc
->operands
[index
]);
5187 if (e
->X_op
== O_constant
)
5189 if ((bfd_vma
) (e
->X_add_number
- 1) < ((bfd_vma
) 1 << bits
))
5190 return OPERAND_MATCH
;
5192 return OPERAND_OUT_OF_RANGE
;
5196 case IA64_OPND_CNT2b
:
5197 if (e
->X_op
== O_constant
)
5199 if ((bfd_vma
) (e
->X_add_number
- 1) < 3)
5200 return OPERAND_MATCH
;
5202 return OPERAND_OUT_OF_RANGE
;
5206 case IA64_OPND_CNT2c
:
5207 val
= e
->X_add_number
;
5208 if (e
->X_op
== O_constant
)
5210 if ((val
== 0 || val
== 7 || val
== 15 || val
== 16))
5211 return OPERAND_MATCH
;
5213 return OPERAND_OUT_OF_RANGE
;
5218 /* SOR must be an integer multiple of 8 */
5219 if (e
->X_op
== O_constant
&& e
->X_add_number
& 0x7)
5220 return OPERAND_OUT_OF_RANGE
;
5223 if (e
->X_op
== O_constant
)
5225 if ((bfd_vma
) e
->X_add_number
<= 96)
5226 return OPERAND_MATCH
;
5228 return OPERAND_OUT_OF_RANGE
;
5232 case IA64_OPND_IMMU62
:
5233 if (e
->X_op
== O_constant
)
5235 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 62))
5236 return OPERAND_MATCH
;
5238 return OPERAND_OUT_OF_RANGE
;
5242 /* FIXME -- need 62-bit relocation type */
5243 as_bad (_("62-bit relocation not yet implemented"));
5247 case IA64_OPND_IMMU64
:
5248 if (e
->X_op
== O_symbol
|| e
->X_op
== O_pseudo_fixup
5249 || e
->X_op
== O_subtract
)
5251 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5252 fix
->code
= BFD_RELOC_IA64_IMM64
;
5253 if (e
->X_op
!= O_subtract
)
5255 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5256 if (e
->X_op
== O_pseudo_fixup
)
5260 fix
->opnd
= idesc
->operands
[index
];
5263 ++CURR_SLOT
.num_fixups
;
5264 return OPERAND_MATCH
;
5266 else if (e
->X_op
== O_constant
)
5267 return OPERAND_MATCH
;
5270 case IA64_OPND_CCNT5
:
5271 case IA64_OPND_CNT5
:
5272 case IA64_OPND_CNT6
:
5273 case IA64_OPND_CPOS6a
:
5274 case IA64_OPND_CPOS6b
:
5275 case IA64_OPND_CPOS6c
:
5276 case IA64_OPND_IMMU2
:
5277 case IA64_OPND_IMMU7a
:
5278 case IA64_OPND_IMMU7b
:
5279 case IA64_OPND_IMMU21
:
5280 case IA64_OPND_IMMU24
:
5281 case IA64_OPND_MBTYPE4
:
5282 case IA64_OPND_MHTYPE8
:
5283 case IA64_OPND_POS6
:
5284 bits
= operand_width (idesc
->operands
[index
]);
5285 if (e
->X_op
== O_constant
)
5287 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5288 return OPERAND_MATCH
;
5290 return OPERAND_OUT_OF_RANGE
;
5294 case IA64_OPND_IMMU9
:
5295 bits
= operand_width (idesc
->operands
[index
]);
5296 if (e
->X_op
== O_constant
)
5298 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5300 int lobits
= e
->X_add_number
& 0x3;
5301 if (((bfd_vma
) e
->X_add_number
& 0x3C) != 0 && lobits
== 0)
5302 e
->X_add_number
|= (bfd_vma
) 0x3;
5303 return OPERAND_MATCH
;
5306 return OPERAND_OUT_OF_RANGE
;
5310 case IA64_OPND_IMM44
:
5311 /* least 16 bits must be zero */
5312 if ((e
->X_add_number
& 0xffff) != 0)
5313 /* XXX technically, this is wrong: we should not be issuing warning
5314 messages until we're sure this instruction pattern is going to
5316 as_warn (_("lower 16 bits of mask ignored"));
5318 if (e
->X_op
== O_constant
)
5320 if (((e
->X_add_number
>= 0
5321 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 44))
5322 || (e
->X_add_number
< 0
5323 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 44))))
5326 if (e
->X_add_number
>= 0
5327 && (e
->X_add_number
& ((bfd_vma
) 1 << 43)) != 0)
5329 e
->X_add_number
|= ~(((bfd_vma
) 1 << 44) - 1);
5331 return OPERAND_MATCH
;
5334 return OPERAND_OUT_OF_RANGE
;
5338 case IA64_OPND_IMM17
:
5339 /* bit 0 is a don't care (pr0 is hardwired to 1) */
5340 if (e
->X_op
== O_constant
)
5342 if (((e
->X_add_number
>= 0
5343 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 17))
5344 || (e
->X_add_number
< 0
5345 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 17))))
5348 if (e
->X_add_number
>= 0
5349 && (e
->X_add_number
& ((bfd_vma
) 1 << 16)) != 0)
5351 e
->X_add_number
|= ~(((bfd_vma
) 1 << 17) - 1);
5353 return OPERAND_MATCH
;
5356 return OPERAND_OUT_OF_RANGE
;
5360 case IA64_OPND_IMM14
:
5361 case IA64_OPND_IMM22
:
5363 case IA64_OPND_IMM1
:
5364 case IA64_OPND_IMM8
:
5365 case IA64_OPND_IMM8U4
:
5366 case IA64_OPND_IMM8M1
:
5367 case IA64_OPND_IMM8M1U4
:
5368 case IA64_OPND_IMM8M1U8
:
5369 case IA64_OPND_IMM9a
:
5370 case IA64_OPND_IMM9b
:
5371 bits
= operand_width (idesc
->operands
[index
]);
5372 if (relocatable
&& (e
->X_op
== O_symbol
5373 || e
->X_op
== O_subtract
5374 || e
->X_op
== O_pseudo_fixup
))
5376 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5378 if (idesc
->operands
[index
] == IA64_OPND_IMM14
)
5379 fix
->code
= BFD_RELOC_IA64_IMM14
;
5381 fix
->code
= BFD_RELOC_IA64_IMM22
;
5383 if (e
->X_op
!= O_subtract
)
5385 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5386 if (e
->X_op
== O_pseudo_fixup
)
5390 fix
->opnd
= idesc
->operands
[index
];
5393 ++CURR_SLOT
.num_fixups
;
5394 return OPERAND_MATCH
;
5396 else if (e
->X_op
!= O_constant
5397 && ! (e
->X_op
== O_big
&& opnd
== IA64_OPND_IMM8M1U8
))
5398 return OPERAND_MISMATCH
;
5400 if (opnd
== IA64_OPND_IMM8M1U4
)
5402 /* Zero is not valid for unsigned compares that take an adjusted
5403 constant immediate range. */
5404 if (e
->X_add_number
== 0)
5405 return OPERAND_OUT_OF_RANGE
;
5407 /* Sign-extend 32-bit unsigned numbers, so that the following range
5408 checks will work. */
5409 val
= e
->X_add_number
;
5410 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5411 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5412 val
= ((val
<< 32) >> 32);
5414 /* Check for 0x100000000. This is valid because
5415 0x100000000-1 is the same as ((uint32_t) -1). */
5416 if (val
== ((bfd_signed_vma
) 1 << 32))
5417 return OPERAND_MATCH
;
5421 else if (opnd
== IA64_OPND_IMM8M1U8
)
5423 /* Zero is not valid for unsigned compares that take an adjusted
5424 constant immediate range. */
5425 if (e
->X_add_number
== 0)
5426 return OPERAND_OUT_OF_RANGE
;
5428 /* Check for 0x10000000000000000. */
5429 if (e
->X_op
== O_big
)
5431 if (generic_bignum
[0] == 0
5432 && generic_bignum
[1] == 0
5433 && generic_bignum
[2] == 0
5434 && generic_bignum
[3] == 0
5435 && generic_bignum
[4] == 1)
5436 return OPERAND_MATCH
;
5438 return OPERAND_OUT_OF_RANGE
;
5441 val
= e
->X_add_number
- 1;
5443 else if (opnd
== IA64_OPND_IMM8M1
)
5444 val
= e
->X_add_number
- 1;
5445 else if (opnd
== IA64_OPND_IMM8U4
)
5447 /* Sign-extend 32-bit unsigned numbers, so that the following range
5448 checks will work. */
5449 val
= e
->X_add_number
;
5450 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5451 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5452 val
= ((val
<< 32) >> 32);
5455 val
= e
->X_add_number
;
5457 if ((val
>= 0 && (bfd_vma
) val
< ((bfd_vma
) 1 << (bits
- 1)))
5458 || (val
< 0 && (bfd_vma
) -val
<= ((bfd_vma
) 1 << (bits
- 1))))
5459 return OPERAND_MATCH
;
5461 return OPERAND_OUT_OF_RANGE
;
5463 case IA64_OPND_INC3
:
5464 /* +/- 1, 4, 8, 16 */
5465 val
= e
->X_add_number
;
5468 if (e
->X_op
== O_constant
)
5470 if ((val
== 1 || val
== 4 || val
== 8 || val
== 16))
5471 return OPERAND_MATCH
;
5473 return OPERAND_OUT_OF_RANGE
;
5477 case IA64_OPND_TGT25
:
5478 case IA64_OPND_TGT25b
:
5479 case IA64_OPND_TGT25c
:
5480 case IA64_OPND_TGT64
:
5481 if (e
->X_op
== O_symbol
)
5483 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5484 if (opnd
== IA64_OPND_TGT25
)
5485 fix
->code
= BFD_RELOC_IA64_PCREL21F
;
5486 else if (opnd
== IA64_OPND_TGT25b
)
5487 fix
->code
= BFD_RELOC_IA64_PCREL21M
;
5488 else if (opnd
== IA64_OPND_TGT25c
)
5489 fix
->code
= BFD_RELOC_IA64_PCREL21B
;
5490 else if (opnd
== IA64_OPND_TGT64
)
5491 fix
->code
= BFD_RELOC_IA64_PCREL60B
;
5495 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5496 fix
->opnd
= idesc
->operands
[index
];
5499 ++CURR_SLOT
.num_fixups
;
5500 return OPERAND_MATCH
;
5502 case IA64_OPND_TAG13
:
5503 case IA64_OPND_TAG13b
:
5507 return OPERAND_MATCH
;
5510 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5511 /* There are no external relocs for TAG13/TAG13b fields, so we
5512 create a dummy reloc. This will not live past md_apply_fix3. */
5513 fix
->code
= BFD_RELOC_UNUSED
;
5514 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5515 fix
->opnd
= idesc
->operands
[index
];
5518 ++CURR_SLOT
.num_fixups
;
5519 return OPERAND_MATCH
;
5529 return OPERAND_MISMATCH
;
5538 memset (e
, 0, sizeof (*e
));
5541 if (*input_line_pointer
!= '}')
5543 sep
= *input_line_pointer
++;
5547 if (!md
.manual_bundling
)
5548 as_warn ("Found '}' when manual bundling is off");
5550 CURR_SLOT
.manual_bundling_off
= 1;
5551 md
.manual_bundling
= 0;
5557 /* Returns the next entry in the opcode table that matches the one in
5558 IDESC, and frees the entry in IDESC. If no matching entry is
5559 found, NULL is returned instead. */
5561 static struct ia64_opcode
*
5562 get_next_opcode (struct ia64_opcode
*idesc
)
5564 struct ia64_opcode
*next
= ia64_find_next_opcode (idesc
);
5565 ia64_free_opcode (idesc
);
5569 /* Parse the operands for the opcode and find the opcode variant that
5570 matches the specified operands, or NULL if no match is possible. */
5572 static struct ia64_opcode
*
5573 parse_operands (idesc
)
5574 struct ia64_opcode
*idesc
;
5576 int i
= 0, highest_unmatched_operand
, num_operands
= 0, num_outputs
= 0;
5577 int error_pos
, out_of_range_pos
, curr_out_of_range_pos
, sep
= 0;
5578 enum ia64_opnd expected_operand
= IA64_OPND_NIL
;
5579 enum operand_match_result result
;
5581 char *first_arg
= 0, *end
, *saved_input_pointer
;
5584 assert (strlen (idesc
->name
) <= 128);
5586 strcpy (mnemonic
, idesc
->name
);
5587 if (idesc
->operands
[2] == IA64_OPND_SOF
)
5589 /* To make the common idiom "alloc loc?=ar.pfs,0,1,0,0" work, we
5590 can't parse the first operand until we have parsed the
5591 remaining operands of the "alloc" instruction. */
5593 first_arg
= input_line_pointer
;
5594 end
= strchr (input_line_pointer
, '=');
5597 as_bad ("Expected separator `='");
5600 input_line_pointer
= end
+ 1;
5605 for (; i
< NELEMS (CURR_SLOT
.opnd
); ++i
)
5607 sep
= parse_operand (CURR_SLOT
.opnd
+ i
);
5608 if (CURR_SLOT
.opnd
[i
].X_op
== O_absent
)
5613 if (sep
!= '=' && sep
!= ',')
5618 if (num_outputs
> 0)
5619 as_bad ("Duplicate equal sign (=) in instruction");
5621 num_outputs
= i
+ 1;
5626 as_bad ("Illegal operand separator `%c'", sep
);
5630 if (idesc
->operands
[2] == IA64_OPND_SOF
)
5632 /* map alloc r1=ar.pfs,i,l,o,r to alloc r1=ar.pfs,(i+l+o),(i+l),r */
5633 know (strcmp (idesc
->name
, "alloc") == 0);
5634 if (num_operands
== 5 /* first_arg not included in this count! */
5635 && CURR_SLOT
.opnd
[2].X_op
== O_constant
5636 && CURR_SLOT
.opnd
[3].X_op
== O_constant
5637 && CURR_SLOT
.opnd
[4].X_op
== O_constant
5638 && CURR_SLOT
.opnd
[5].X_op
== O_constant
)
5640 sof
= set_regstack (CURR_SLOT
.opnd
[2].X_add_number
,
5641 CURR_SLOT
.opnd
[3].X_add_number
,
5642 CURR_SLOT
.opnd
[4].X_add_number
,
5643 CURR_SLOT
.opnd
[5].X_add_number
);
5645 /* now we can parse the first arg: */
5646 saved_input_pointer
= input_line_pointer
;
5647 input_line_pointer
= first_arg
;
5648 sep
= parse_operand (CURR_SLOT
.opnd
+ 0);
5650 --num_outputs
; /* force error */
5651 input_line_pointer
= saved_input_pointer
;
5653 CURR_SLOT
.opnd
[2].X_add_number
= sof
;
5654 CURR_SLOT
.opnd
[3].X_add_number
5655 = sof
- CURR_SLOT
.opnd
[4].X_add_number
;
5656 CURR_SLOT
.opnd
[4] = CURR_SLOT
.opnd
[5];
5660 highest_unmatched_operand
= 0;
5661 curr_out_of_range_pos
= -1;
5663 expected_operand
= idesc
->operands
[0];
5664 for (; idesc
; idesc
= get_next_opcode (idesc
))
5666 if (num_outputs
!= idesc
->num_outputs
)
5667 continue; /* mismatch in # of outputs */
5669 CURR_SLOT
.num_fixups
= 0;
5671 /* Try to match all operands. If we see an out-of-range operand,
5672 then continue trying to match the rest of the operands, since if
5673 the rest match, then this idesc will give the best error message. */
5675 out_of_range_pos
= -1;
5676 for (i
= 0; i
< num_operands
&& idesc
->operands
[i
]; ++i
)
5678 result
= operand_match (idesc
, i
, CURR_SLOT
.opnd
+ i
);
5679 if (result
!= OPERAND_MATCH
)
5681 if (result
!= OPERAND_OUT_OF_RANGE
)
5683 if (out_of_range_pos
< 0)
5684 /* remember position of the first out-of-range operand: */
5685 out_of_range_pos
= i
;
5689 /* If we did not match all operands, or if at least one operand was
5690 out-of-range, then this idesc does not match. Keep track of which
5691 idesc matched the most operands before failing. If we have two
5692 idescs that failed at the same position, and one had an out-of-range
5693 operand, then prefer the out-of-range operand. Thus if we have
5694 "add r0=0x1000000,r1" we get an error saying the constant is out
5695 of range instead of an error saying that the constant should have been
5698 if (i
!= num_operands
|| out_of_range_pos
>= 0)
5700 if (i
> highest_unmatched_operand
5701 || (i
== highest_unmatched_operand
5702 && out_of_range_pos
> curr_out_of_range_pos
))
5704 highest_unmatched_operand
= i
;
5705 if (out_of_range_pos
>= 0)
5707 expected_operand
= idesc
->operands
[out_of_range_pos
];
5708 error_pos
= out_of_range_pos
;
5712 expected_operand
= idesc
->operands
[i
];
5715 curr_out_of_range_pos
= out_of_range_pos
;
5720 if (num_operands
< NELEMS (idesc
->operands
)
5721 && idesc
->operands
[num_operands
])
5722 continue; /* mismatch in number of arguments */
5728 if (expected_operand
)
5729 as_bad ("Operand %u of `%s' should be %s",
5730 error_pos
+ 1, mnemonic
,
5731 elf64_ia64_operands
[expected_operand
].desc
);
5733 as_bad ("Operand mismatch");
5739 /* Keep track of state necessary to determine whether a NOP is necessary
5740 to avoid an erratum in A and B step Itanium chips, and return 1 if we
5741 detect a case where additional NOPs may be necessary. */
5743 errata_nop_necessary_p (slot
, insn_unit
)
5745 enum ia64_unit insn_unit
;
5748 struct group
*this_group
= md
.last_groups
+ md
.group_idx
;
5749 struct group
*prev_group
= md
.last_groups
+ (md
.group_idx
+ 2) % 3;
5750 struct ia64_opcode
*idesc
= slot
->idesc
;
5752 /* Test whether this could be the first insn in a problematic sequence. */
5753 if (insn_unit
== IA64_UNIT_F
)
5755 for (i
= 0; i
< idesc
->num_outputs
; i
++)
5756 if (idesc
->operands
[i
] == IA64_OPND_P1
5757 || idesc
->operands
[i
] == IA64_OPND_P2
)
5759 int regno
= slot
->opnd
[i
].X_add_number
- REG_P
;
5760 /* Ignore invalid operands; they generate errors elsewhere. */
5763 this_group
->p_reg_set
[regno
] = 1;
5767 /* Test whether this could be the second insn in a problematic sequence. */
5768 if (insn_unit
== IA64_UNIT_M
&& slot
->qp_regno
> 0
5769 && prev_group
->p_reg_set
[slot
->qp_regno
])
5771 for (i
= 0; i
< idesc
->num_outputs
; i
++)
5772 if (idesc
->operands
[i
] == IA64_OPND_R1
5773 || idesc
->operands
[i
] == IA64_OPND_R2
5774 || idesc
->operands
[i
] == IA64_OPND_R3
)
5776 int regno
= slot
->opnd
[i
].X_add_number
- REG_GR
;
5777 /* Ignore invalid operands; they generate errors elsewhere. */
5780 if (strncmp (idesc
->name
, "add", 3) != 0
5781 && strncmp (idesc
->name
, "sub", 3) != 0
5782 && strncmp (idesc
->name
, "shladd", 6) != 0
5783 && (idesc
->flags
& IA64_OPCODE_POSTINC
) == 0)
5784 this_group
->g_reg_set_conditionally
[regno
] = 1;
5788 /* Test whether this could be the third insn in a problematic sequence. */
5789 for (i
= 0; i
< NELEMS (idesc
->operands
) && idesc
->operands
[i
]; i
++)
5791 if (/* For fc, ptc, ptr, tak, thash, tpa, ttag, probe, ptr, ptc. */
5792 idesc
->operands
[i
] == IA64_OPND_R3
5793 /* For mov indirect. */
5794 || idesc
->operands
[i
] == IA64_OPND_RR_R3
5795 || idesc
->operands
[i
] == IA64_OPND_DBR_R3
5796 || idesc
->operands
[i
] == IA64_OPND_IBR_R3
5797 || idesc
->operands
[i
] == IA64_OPND_PKR_R3
5798 || idesc
->operands
[i
] == IA64_OPND_PMC_R3
5799 || idesc
->operands
[i
] == IA64_OPND_PMD_R3
5800 || idesc
->operands
[i
] == IA64_OPND_MSR_R3
5801 || idesc
->operands
[i
] == IA64_OPND_CPUID_R3
5803 || idesc
->operands
[i
] == IA64_OPND_ITR_R3
5804 || idesc
->operands
[i
] == IA64_OPND_DTR_R3
5805 /* Normal memory addresses (load, store, xchg, cmpxchg, etc.). */
5806 || idesc
->operands
[i
] == IA64_OPND_MR3
)
5808 int regno
= slot
->opnd
[i
].X_add_number
- REG_GR
;
5809 /* Ignore invalid operands; they generate errors elsewhere. */
5812 if (idesc
->operands
[i
] == IA64_OPND_R3
)
5814 if (strcmp (idesc
->name
, "fc") != 0
5815 && strcmp (idesc
->name
, "tak") != 0
5816 && strcmp (idesc
->name
, "thash") != 0
5817 && strcmp (idesc
->name
, "tpa") != 0
5818 && strcmp (idesc
->name
, "ttag") != 0
5819 && strncmp (idesc
->name
, "ptr", 3) != 0
5820 && strncmp (idesc
->name
, "ptc", 3) != 0
5821 && strncmp (idesc
->name
, "probe", 5) != 0)
5824 if (prev_group
->g_reg_set_conditionally
[regno
])
5832 build_insn (slot
, insnp
)
5836 const struct ia64_operand
*odesc
, *o2desc
;
5837 struct ia64_opcode
*idesc
= slot
->idesc
;
5838 bfd_signed_vma insn
, val
;
5842 insn
= idesc
->opcode
| slot
->qp_regno
;
5844 for (i
= 0; i
< NELEMS (idesc
->operands
) && idesc
->operands
[i
]; ++i
)
5846 if (slot
->opnd
[i
].X_op
== O_register
5847 || slot
->opnd
[i
].X_op
== O_constant
5848 || slot
->opnd
[i
].X_op
== O_index
)
5849 val
= slot
->opnd
[i
].X_add_number
;
5850 else if (slot
->opnd
[i
].X_op
== O_big
)
5852 /* This must be the value 0x10000000000000000. */
5853 assert (idesc
->operands
[i
] == IA64_OPND_IMM8M1U8
);
5859 switch (idesc
->operands
[i
])
5861 case IA64_OPND_IMMU64
:
5862 *insnp
++ = (val
>> 22) & 0x1ffffffffffLL
;
5863 insn
|= (((val
& 0x7f) << 13) | (((val
>> 7) & 0x1ff) << 27)
5864 | (((val
>> 16) & 0x1f) << 22) | (((val
>> 21) & 0x1) << 21)
5865 | (((val
>> 63) & 0x1) << 36));
5868 case IA64_OPND_IMMU62
:
5869 val
&= 0x3fffffffffffffffULL
;
5870 if (val
!= slot
->opnd
[i
].X_add_number
)
5871 as_warn (_("Value truncated to 62 bits"));
5872 *insnp
++ = (val
>> 21) & 0x1ffffffffffLL
;
5873 insn
|= (((val
& 0xfffff) << 6) | (((val
>> 20) & 0x1) << 36));
5876 case IA64_OPND_TGT64
:
5878 *insnp
++ = ((val
>> 20) & 0x7fffffffffLL
) << 2;
5879 insn
|= ((((val
>> 59) & 0x1) << 36)
5880 | (((val
>> 0) & 0xfffff) << 13));
5911 case IA64_OPND_R3_2
:
5912 case IA64_OPND_CPUID_R3
:
5913 case IA64_OPND_DBR_R3
:
5914 case IA64_OPND_DTR_R3
:
5915 case IA64_OPND_ITR_R3
:
5916 case IA64_OPND_IBR_R3
:
5918 case IA64_OPND_MSR_R3
:
5919 case IA64_OPND_PKR_R3
:
5920 case IA64_OPND_PMC_R3
:
5921 case IA64_OPND_PMD_R3
:
5922 case IA64_OPND_RR_R3
:
5930 odesc
= elf64_ia64_operands
+ idesc
->operands
[i
];
5931 err
= (*odesc
->insert
) (odesc
, val
, &insn
);
5933 as_bad_where (slot
->src_file
, slot
->src_line
,
5934 "Bad operand value: %s", err
);
5935 if (idesc
->flags
& IA64_OPCODE_PSEUDO
)
5937 if ((idesc
->flags
& IA64_OPCODE_F2_EQ_F3
)
5938 && odesc
== elf64_ia64_operands
+ IA64_OPND_F3
)
5940 o2desc
= elf64_ia64_operands
+ IA64_OPND_F2
;
5941 (*o2desc
->insert
) (o2desc
, val
, &insn
);
5943 if ((idesc
->flags
& IA64_OPCODE_LEN_EQ_64MCNT
)
5944 && (odesc
== elf64_ia64_operands
+ IA64_OPND_CPOS6a
5945 || odesc
== elf64_ia64_operands
+ IA64_OPND_POS6
))
5947 o2desc
= elf64_ia64_operands
+ IA64_OPND_LEN6
;
5948 (*o2desc
->insert
) (o2desc
, 64 - val
, &insn
);
5958 unsigned int manual_bundling_on
= 0, manual_bundling_off
= 0;
5959 unsigned int manual_bundling
= 0;
5960 enum ia64_unit required_unit
, insn_unit
= 0;
5961 enum ia64_insn_type type
[3], insn_type
;
5962 unsigned int template, orig_template
;
5963 bfd_vma insn
[3] = { -1, -1, -1 };
5964 struct ia64_opcode
*idesc
;
5965 int end_of_insn_group
= 0, user_template
= -1;
5966 int n
, i
, j
, first
, curr
;
5968 bfd_vma t0
= 0, t1
= 0;
5969 struct label_fix
*lfix
;
5970 struct insn_fix
*ifix
;
5975 first
= (md
.curr_slot
+ NUM_SLOTS
- md
.num_slots_in_use
) % NUM_SLOTS
;
5976 know (first
>= 0 & first
< NUM_SLOTS
);
5977 n
= MIN (3, md
.num_slots_in_use
);
5979 /* Determine template: user user_template if specified, best match
5982 if (md
.slot
[first
].user_template
>= 0)
5983 user_template
= template = md
.slot
[first
].user_template
;
5986 /* Auto select appropriate template. */
5987 memset (type
, 0, sizeof (type
));
5989 for (i
= 0; i
< n
; ++i
)
5991 if (md
.slot
[curr
].label_fixups
&& i
!= 0)
5993 type
[i
] = md
.slot
[curr
].idesc
->type
;
5994 curr
= (curr
+ 1) % NUM_SLOTS
;
5996 template = best_template
[type
[0]][type
[1]][type
[2]];
5999 /* initialize instructions with appropriate nops: */
6000 for (i
= 0; i
< 3; ++i
)
6001 insn
[i
] = nop
[ia64_templ_desc
[template].exec_unit
[i
]];
6005 /* now fill in slots with as many insns as possible: */
6007 idesc
= md
.slot
[curr
].idesc
;
6008 end_of_insn_group
= 0;
6009 for (i
= 0; i
< 3 && md
.num_slots_in_use
> 0; ++i
)
6011 /* Set the slot number for prologue/body records now as those
6012 refer to the current point, not the point after the
6013 instruction has been issued: */
6014 /* Don't try to delete prologue/body records here, as that will cause
6015 them to also be deleted from the master list of unwind records. */
6016 for (ptr
= md
.slot
[curr
].unwind_record
; ptr
; ptr
= ptr
->next
)
6017 if (ptr
->r
.type
== prologue
|| ptr
->r
.type
== prologue_gr
6018 || ptr
->r
.type
== body
)
6020 ptr
->slot_number
= (unsigned long) f
+ i
;
6021 ptr
->slot_frag
= frag_now
;
6024 if (idesc
->flags
& IA64_OPCODE_SLOT2
)
6026 if (manual_bundling
&& i
!= 2)
6027 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6028 "`%s' must be last in bundle", idesc
->name
);
6032 if (idesc
->flags
& IA64_OPCODE_LAST
)
6035 unsigned int required_template
;
6037 /* If we need a stop bit after an M slot, our only choice is
6038 template 5 (M;;MI). If we need a stop bit after a B
6039 slot, our only choice is to place it at the end of the
6040 bundle, because the only available templates are MIB,
6041 MBB, BBB, MMB, and MFB. We don't handle anything other
6042 than M and B slots because these are the only kind of
6043 instructions that can have the IA64_OPCODE_LAST bit set. */
6044 required_template
= template;
6045 switch (idesc
->type
)
6049 required_template
= 5;
6057 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6058 "Internal error: don't know how to force %s to end"
6059 "of instruction group", idesc
->name
);
6063 if (manual_bundling
&& i
!= required_slot
)
6064 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6065 "`%s' must be last in instruction group",
6067 if (required_slot
< i
)
6068 /* Can't fit this instruction. */
6072 if (required_template
!= template)
6074 /* If we switch the template, we need to reset the NOPs
6075 after slot i. The slot-types of the instructions ahead
6076 of i never change, so we don't need to worry about
6077 changing NOPs in front of this slot. */
6078 for (j
= i
; j
< 3; ++j
)
6079 insn
[j
] = nop
[ia64_templ_desc
[required_template
].exec_unit
[j
]];
6081 template = required_template
;
6083 if (curr
!= first
&& md
.slot
[curr
].label_fixups
)
6085 if (manual_bundling_on
)
6086 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6087 "Label must be first in a bundle");
6088 /* This insn must go into the first slot of a bundle. */
6092 manual_bundling_on
= md
.slot
[curr
].manual_bundling_on
;
6093 manual_bundling_off
= md
.slot
[curr
].manual_bundling_off
;
6095 if (manual_bundling_on
)
6098 manual_bundling
= 1;
6100 break; /* need to start a new bundle */
6103 if (end_of_insn_group
&& md
.num_slots_in_use
>= 1)
6105 /* We need an instruction group boundary in the middle of a
6106 bundle. See if we can switch to an other template with
6107 an appropriate boundary. */
6109 orig_template
= template;
6110 if (i
== 1 && (user_template
== 4
6111 || (user_template
< 0
6112 && (ia64_templ_desc
[template].exec_unit
[0]
6116 end_of_insn_group
= 0;
6118 else if (i
== 2 && (user_template
== 0
6119 || (user_template
< 0
6120 && (ia64_templ_desc
[template].exec_unit
[1]
6122 /* This test makes sure we don't switch the template if
6123 the next instruction is one that needs to be first in
6124 an instruction group. Since all those instructions are
6125 in the M group, there is no way such an instruction can
6126 fit in this bundle even if we switch the template. The
6127 reason we have to check for this is that otherwise we
6128 may end up generating "MI;;I M.." which has the deadly
6129 effect that the second M instruction is no longer the
6130 first in the bundle! --davidm 99/12/16 */
6131 && (idesc
->flags
& IA64_OPCODE_FIRST
) == 0)
6134 end_of_insn_group
= 0;
6136 else if (curr
!= first
)
6137 /* can't fit this insn */
6140 if (template != orig_template
)
6141 /* if we switch the template, we need to reset the NOPs
6142 after slot i. The slot-types of the instructions ahead
6143 of i never change, so we don't need to worry about
6144 changing NOPs in front of this slot. */
6145 for (j
= i
; j
< 3; ++j
)
6146 insn
[j
] = nop
[ia64_templ_desc
[template].exec_unit
[j
]];
6148 required_unit
= ia64_templ_desc
[template].exec_unit
[i
];
6150 /* resolve dynamic opcodes such as "break" and "nop": */
6151 if (idesc
->type
== IA64_TYPE_DYN
)
6153 if ((strcmp (idesc
->name
, "nop") == 0)
6154 || (strcmp (idesc
->name
, "break") == 0))
6155 insn_unit
= required_unit
;
6156 else if (strcmp (idesc
->name
, "chk.s") == 0)
6158 insn_unit
= IA64_UNIT_M
;
6159 if (required_unit
== IA64_UNIT_I
)
6160 insn_unit
= IA64_UNIT_I
;
6163 as_fatal ("emit_one_bundle: unexpected dynamic op");
6165 sprintf (mnemonic
, "%s.%c", idesc
->name
, "?imbf??"[insn_unit
]);
6166 ia64_free_opcode (idesc
);
6167 md
.slot
[curr
].idesc
= idesc
= ia64_find_opcode (mnemonic
);
6169 know (!idesc
->next
); /* no resolved dynamic ops have collisions */
6174 insn_type
= idesc
->type
;
6175 insn_unit
= IA64_UNIT_NIL
;
6179 if (required_unit
== IA64_UNIT_I
|| required_unit
== IA64_UNIT_M
)
6180 insn_unit
= required_unit
;
6182 case IA64_TYPE_X
: insn_unit
= IA64_UNIT_L
; break;
6183 case IA64_TYPE_I
: insn_unit
= IA64_UNIT_I
; break;
6184 case IA64_TYPE_M
: insn_unit
= IA64_UNIT_M
; break;
6185 case IA64_TYPE_B
: insn_unit
= IA64_UNIT_B
; break;
6186 case IA64_TYPE_F
: insn_unit
= IA64_UNIT_F
; break;
6191 if (insn_unit
!= required_unit
)
6193 if (required_unit
== IA64_UNIT_L
6194 && insn_unit
== IA64_UNIT_I
6195 && !(idesc
->flags
& IA64_OPCODE_X_IN_MLX
))
6197 /* we got ourselves an MLX template but the current
6198 instruction isn't an X-unit, or an I-unit instruction
6199 that can go into the X slot of an MLX template. Duh. */
6200 if (md
.num_slots_in_use
>= NUM_SLOTS
)
6202 as_bad_where (md
.slot
[curr
].src_file
,
6203 md
.slot
[curr
].src_line
,
6204 "`%s' can't go in X slot of "
6205 "MLX template", idesc
->name
);
6206 /* drop this insn so we don't livelock: */
6207 --md
.num_slots_in_use
;
6211 continue; /* try next slot */
6217 addr
= frag_now
->fr_address
+ frag_now_fix () - 16 + i
;
6218 dwarf2_gen_line_info (addr
, &md
.slot
[curr
].debug_line
);
6221 if (errata_nop_necessary_p (md
.slot
+ curr
, insn_unit
))
6222 as_warn (_("Additional NOP may be necessary to workaround Itanium processor A/B step errata"));
6224 build_insn (md
.slot
+ curr
, insn
+ i
);
6226 /* Set slot counts for non prologue/body unwind records. */
6227 for (ptr
= md
.slot
[curr
].unwind_record
; ptr
; ptr
= ptr
->next
)
6228 if (ptr
->r
.type
!= prologue
&& ptr
->r
.type
!= prologue_gr
6229 && ptr
->r
.type
!= body
)
6231 ptr
->slot_number
= (unsigned long) f
+ i
;
6232 ptr
->slot_frag
= frag_now
;
6234 md
.slot
[curr
].unwind_record
= NULL
;
6236 if (required_unit
== IA64_UNIT_L
)
6239 /* skip one slot for long/X-unit instructions */
6242 --md
.num_slots_in_use
;
6244 /* now is a good time to fix up the labels for this insn: */
6245 for (lfix
= md
.slot
[curr
].label_fixups
; lfix
; lfix
= lfix
->next
)
6247 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16);
6248 symbol_set_frag (lfix
->sym
, frag_now
);
6250 /* and fix up the tags also. */
6251 for (lfix
= md
.slot
[curr
].tag_fixups
; lfix
; lfix
= lfix
->next
)
6253 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16 + i
);
6254 symbol_set_frag (lfix
->sym
, frag_now
);
6257 for (j
= 0; j
< md
.slot
[curr
].num_fixups
; ++j
)
6259 ifix
= md
.slot
[curr
].fixup
+ j
;
6260 fix
= fix_new_exp (frag_now
, frag_now_fix () - 16 + i
, 8,
6261 &ifix
->expr
, ifix
->is_pcrel
, ifix
->code
);
6262 fix
->tc_fix_data
.opnd
= ifix
->opnd
;
6263 fix
->fx_plt
= (fix
->fx_r_type
== BFD_RELOC_IA64_PLTOFF22
);
6264 fix
->fx_file
= md
.slot
[curr
].src_file
;
6265 fix
->fx_line
= md
.slot
[curr
].src_line
;
6268 end_of_insn_group
= md
.slot
[curr
].end_of_insn_group
;
6270 if (end_of_insn_group
)
6272 md
.group_idx
= (md
.group_idx
+ 1) % 3;
6273 memset (md
.last_groups
+ md
.group_idx
, 0, sizeof md
.last_groups
[0]);
6277 ia64_free_opcode (md
.slot
[curr
].idesc
);
6278 memset (md
.slot
+ curr
, 0, sizeof (md
.slot
[curr
]));
6279 md
.slot
[curr
].user_template
= -1;
6281 if (manual_bundling_off
)
6283 manual_bundling
= 0;
6286 curr
= (curr
+ 1) % NUM_SLOTS
;
6287 idesc
= md
.slot
[curr
].idesc
;
6289 if (manual_bundling
)
6291 if (md
.num_slots_in_use
> 0)
6292 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6293 "`%s' does not fit into %s template",
6294 idesc
->name
, ia64_templ_desc
[template].name
);
6296 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6297 "Missing '}' at end of file");
6299 know (md
.num_slots_in_use
< NUM_SLOTS
);
6301 t0
= end_of_insn_group
| (template << 1) | (insn
[0] << 5) | (insn
[1] << 46);
6302 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
6304 number_to_chars_littleendian (f
+ 0, t0
, 8);
6305 number_to_chars_littleendian (f
+ 8, t1
, 8);
6307 unwind
.next_slot_number
= (unsigned long) f
+ 16;
6308 unwind
.next_slot_frag
= frag_now
;
6312 md_parse_option (c
, arg
)
6319 /* Switches from the Intel assembler. */
6321 if (strcmp (arg
, "ilp64") == 0
6322 || strcmp (arg
, "lp64") == 0
6323 || strcmp (arg
, "p64") == 0)
6325 md
.flags
|= EF_IA_64_ABI64
;
6327 else if (strcmp (arg
, "ilp32") == 0)
6329 md
.flags
&= ~EF_IA_64_ABI64
;
6331 else if (strcmp (arg
, "le") == 0)
6333 md
.flags
&= ~EF_IA_64_BE
;
6335 else if (strcmp (arg
, "be") == 0)
6337 md
.flags
|= EF_IA_64_BE
;
6344 if (strcmp (arg
, "so") == 0)
6346 /* Suppress signon message. */
6348 else if (strcmp (arg
, "pi") == 0)
6350 /* Reject privileged instructions. FIXME */
6352 else if (strcmp (arg
, "us") == 0)
6354 /* Allow union of signed and unsigned range. FIXME */
6356 else if (strcmp (arg
, "close_fcalls") == 0)
6358 /* Do not resolve global function calls. */
6365 /* temp[="prefix"] Insert temporary labels into the object file
6366 symbol table prefixed by "prefix".
6367 Default prefix is ":temp:".
6372 /* indirect=<tgt> Assume unannotated indirect branches behavior
6373 according to <tgt> --
6374 exit: branch out from the current context (default)
6375 labels: all labels in context may be branch targets
6377 if (strncmp (arg
, "indirect=", 9) != 0)
6382 /* -X conflicts with an ignored option, use -x instead */
6384 if (!arg
|| strcmp (arg
, "explicit") == 0)
6386 /* set default mode to explicit */
6387 md
.default_explicit_mode
= 1;
6390 else if (strcmp (arg
, "auto") == 0)
6392 md
.default_explicit_mode
= 0;
6394 else if (strcmp (arg
, "debug") == 0)
6398 else if (strcmp (arg
, "debugx") == 0)
6400 md
.default_explicit_mode
= 1;
6405 as_bad (_("Unrecognized option '-x%s'"), arg
);
6410 /* nops Print nops statistics. */
6413 /* GNU specific switches for gcc. */
6414 case OPTION_MCONSTANT_GP
:
6415 md
.flags
|= EF_IA_64_CONS_GP
;
6418 case OPTION_MAUTO_PIC
:
6419 md
.flags
|= EF_IA_64_NOFUNCDESC_CONS_GP
;
6430 md_show_usage (stream
)
6435 --mconstant-gp mark output file as using the constant-GP model\n\
6436 (sets ELF header flag EF_IA_64_CONS_GP)\n\
6437 --mauto-pic mark output file as using the constant-GP model\n\
6438 without function descriptors (sets ELF header flag\n\
6439 EF_IA_64_NOFUNCDESC_CONS_GP)\n\
6440 -milp32|-milp64|-mlp64|-mp64 select data model (default -mlp64)\n\
6441 -mle | -mbe select little- or big-endian byte order (default -mle)\n\
6442 -x | -xexplicit turn on dependency violation checking (default)\n\
6443 -xauto automagically remove dependency violations\n\
6444 -xdebug debug dependency violation checker\n"),
6449 ia64_after_parse_args ()
6451 if (debug_type
== DEBUG_STABS
)
6452 as_fatal (_("--gstabs is not supported for ia64"));
6455 /* Return true if TYPE fits in TEMPL at SLOT. */
6458 match (int templ
, int type
, int slot
)
6460 enum ia64_unit unit
;
6463 unit
= ia64_templ_desc
[templ
].exec_unit
[slot
];
6466 case IA64_TYPE_DYN
: result
= 1; break; /* for nop and break */
6468 result
= (unit
== IA64_UNIT_I
|| unit
== IA64_UNIT_M
);
6470 case IA64_TYPE_X
: result
= (unit
== IA64_UNIT_L
); break;
6471 case IA64_TYPE_I
: result
= (unit
== IA64_UNIT_I
); break;
6472 case IA64_TYPE_M
: result
= (unit
== IA64_UNIT_M
); break;
6473 case IA64_TYPE_B
: result
= (unit
== IA64_UNIT_B
); break;
6474 case IA64_TYPE_F
: result
= (unit
== IA64_UNIT_F
); break;
6475 default: result
= 0; break;
6480 /* Add a bit of extra goodness if a nop of type F or B would fit
6481 in TEMPL at SLOT. */
6484 extra_goodness (int templ
, int slot
)
6486 if (slot
== 1 && match (templ
, IA64_TYPE_F
, slot
))
6488 if (slot
== 2 && match (templ
, IA64_TYPE_B
, slot
))
6493 /* This function is called once, at assembler startup time. It sets
6494 up all the tables, etc. that the MD part of the assembler will need
6495 that can be determined before arguments are parsed. */
6499 int i
, j
, k
, t
, total
, ar_base
, cr_base
, goodness
, best
, regnum
, ok
;
6504 md
.explicit_mode
= md
.default_explicit_mode
;
6506 bfd_set_section_alignment (stdoutput
, text_section
, 4);
6508 target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
6509 pseudo_func
[FUNC_DTP_MODULE
].u
.sym
=
6510 symbol_new (".<dtpmod>", undefined_section
, FUNC_DTP_MODULE
,
6511 &zero_address_frag
);
6513 pseudo_func
[FUNC_DTP_RELATIVE
].u
.sym
=
6514 symbol_new (".<dtprel>", undefined_section
, FUNC_DTP_RELATIVE
,
6515 &zero_address_frag
);
6517 pseudo_func
[FUNC_FPTR_RELATIVE
].u
.sym
=
6518 symbol_new (".<fptr>", undefined_section
, FUNC_FPTR_RELATIVE
,
6519 &zero_address_frag
);
6521 pseudo_func
[FUNC_GP_RELATIVE
].u
.sym
=
6522 symbol_new (".<gprel>", undefined_section
, FUNC_GP_RELATIVE
,
6523 &zero_address_frag
);
6525 pseudo_func
[FUNC_LT_RELATIVE
].u
.sym
=
6526 symbol_new (".<ltoff>", undefined_section
, FUNC_LT_RELATIVE
,
6527 &zero_address_frag
);
6529 pseudo_func
[FUNC_PC_RELATIVE
].u
.sym
=
6530 symbol_new (".<pcrel>", undefined_section
, FUNC_PC_RELATIVE
,
6531 &zero_address_frag
);
6533 pseudo_func
[FUNC_PLT_RELATIVE
].u
.sym
=
6534 symbol_new (".<pltoff>", undefined_section
, FUNC_PLT_RELATIVE
,
6535 &zero_address_frag
);
6537 pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
=
6538 symbol_new (".<secrel>", undefined_section
, FUNC_SEC_RELATIVE
,
6539 &zero_address_frag
);
6541 pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
=
6542 symbol_new (".<segrel>", undefined_section
, FUNC_SEG_RELATIVE
,
6543 &zero_address_frag
);
6545 pseudo_func
[FUNC_TP_RELATIVE
].u
.sym
=
6546 symbol_new (".<tprel>", undefined_section
, FUNC_TP_RELATIVE
,
6547 &zero_address_frag
);
6549 pseudo_func
[FUNC_LTV_RELATIVE
].u
.sym
=
6550 symbol_new (".<ltv>", undefined_section
, FUNC_LTV_RELATIVE
,
6551 &zero_address_frag
);
6553 pseudo_func
[FUNC_LT_FPTR_RELATIVE
].u
.sym
=
6554 symbol_new (".<ltoff.fptr>", undefined_section
, FUNC_LT_FPTR_RELATIVE
,
6555 &zero_address_frag
);
6557 pseudo_func
[FUNC_LT_DTP_MODULE
].u
.sym
=
6558 symbol_new (".<ltoff.dtpmod>", undefined_section
, FUNC_LT_DTP_MODULE
,
6559 &zero_address_frag
);
6561 pseudo_func
[FUNC_LT_DTP_RELATIVE
].u
.sym
=
6562 symbol_new (".<ltoff.dptrel>", undefined_section
, FUNC_LT_DTP_RELATIVE
,
6563 &zero_address_frag
);
6565 pseudo_func
[FUNC_LT_TP_RELATIVE
].u
.sym
=
6566 symbol_new (".<ltoff.tprel>", undefined_section
, FUNC_LT_TP_RELATIVE
,
6567 &zero_address_frag
);
6569 pseudo_func
[FUNC_IPLT_RELOC
].u
.sym
=
6570 symbol_new (".<iplt>", undefined_section
, FUNC_IPLT_RELOC
,
6571 &zero_address_frag
);
6573 /* Compute the table of best templates. We compute goodness as a
6574 base 4 value, in which each match counts for 3, each F counts
6575 for 2, each B counts for 1. This should maximize the number of
6576 F and B nops in the chosen bundles, which is good because these
6577 pipelines are least likely to be overcommitted. */
6578 for (i
= 0; i
< IA64_NUM_TYPES
; ++i
)
6579 for (j
= 0; j
< IA64_NUM_TYPES
; ++j
)
6580 for (k
= 0; k
< IA64_NUM_TYPES
; ++k
)
6583 for (t
= 0; t
< NELEMS (ia64_templ_desc
); ++t
)
6586 if (match (t
, i
, 0))
6588 if (match (t
, j
, 1))
6590 if (match (t
, k
, 2))
6591 goodness
= 3 + 3 + 3;
6593 goodness
= 3 + 3 + extra_goodness (t
, 2);
6595 else if (match (t
, j
, 2))
6596 goodness
= 3 + 3 + extra_goodness (t
, 1);
6600 goodness
+= extra_goodness (t
, 1);
6601 goodness
+= extra_goodness (t
, 2);
6604 else if (match (t
, i
, 1))
6606 if (match (t
, j
, 2))
6609 goodness
= 3 + extra_goodness (t
, 2);
6611 else if (match (t
, i
, 2))
6612 goodness
= 3 + extra_goodness (t
, 1);
6614 if (goodness
> best
)
6617 best_template
[i
][j
][k
] = t
;
6622 for (i
= 0; i
< NUM_SLOTS
; ++i
)
6623 md
.slot
[i
].user_template
= -1;
6625 md
.pseudo_hash
= hash_new ();
6626 for (i
= 0; i
< NELEMS (pseudo_opcode
); ++i
)
6628 err
= hash_insert (md
.pseudo_hash
, pseudo_opcode
[i
].name
,
6629 (void *) (pseudo_opcode
+ i
));
6631 as_fatal ("ia64.md_begin: can't hash `%s': %s",
6632 pseudo_opcode
[i
].name
, err
);
6635 md
.reg_hash
= hash_new ();
6636 md
.dynreg_hash
= hash_new ();
6637 md
.const_hash
= hash_new ();
6638 md
.entry_hash
= hash_new ();
6640 /* general registers: */
6643 for (i
= 0; i
< total
; ++i
)
6645 sprintf (name
, "r%d", i
- REG_GR
);
6646 md
.regsym
[i
] = declare_register (name
, i
);
6649 /* floating point registers: */
6651 for (; i
< total
; ++i
)
6653 sprintf (name
, "f%d", i
- REG_FR
);
6654 md
.regsym
[i
] = declare_register (name
, i
);
6657 /* application registers: */
6660 for (; i
< total
; ++i
)
6662 sprintf (name
, "ar%d", i
- REG_AR
);
6663 md
.regsym
[i
] = declare_register (name
, i
);
6666 /* control registers: */
6669 for (; i
< total
; ++i
)
6671 sprintf (name
, "cr%d", i
- REG_CR
);
6672 md
.regsym
[i
] = declare_register (name
, i
);
6675 /* predicate registers: */
6677 for (; i
< total
; ++i
)
6679 sprintf (name
, "p%d", i
- REG_P
);
6680 md
.regsym
[i
] = declare_register (name
, i
);
6683 /* branch registers: */
6685 for (; i
< total
; ++i
)
6687 sprintf (name
, "b%d", i
- REG_BR
);
6688 md
.regsym
[i
] = declare_register (name
, i
);
6691 md
.regsym
[REG_IP
] = declare_register ("ip", REG_IP
);
6692 md
.regsym
[REG_CFM
] = declare_register ("cfm", REG_CFM
);
6693 md
.regsym
[REG_PR
] = declare_register ("pr", REG_PR
);
6694 md
.regsym
[REG_PR_ROT
] = declare_register ("pr.rot", REG_PR_ROT
);
6695 md
.regsym
[REG_PSR
] = declare_register ("psr", REG_PSR
);
6696 md
.regsym
[REG_PSR_L
] = declare_register ("psr.l", REG_PSR_L
);
6697 md
.regsym
[REG_PSR_UM
] = declare_register ("psr.um", REG_PSR_UM
);
6699 for (i
= 0; i
< NELEMS (indirect_reg
); ++i
)
6701 regnum
= indirect_reg
[i
].regnum
;
6702 md
.regsym
[regnum
] = declare_register (indirect_reg
[i
].name
, regnum
);
6705 /* define synonyms for application registers: */
6706 for (i
= REG_AR
; i
< REG_AR
+ NELEMS (ar
); ++i
)
6707 md
.regsym
[i
] = declare_register (ar
[i
- REG_AR
].name
,
6708 REG_AR
+ ar
[i
- REG_AR
].regnum
);
6710 /* define synonyms for control registers: */
6711 for (i
= REG_CR
; i
< REG_CR
+ NELEMS (cr
); ++i
)
6712 md
.regsym
[i
] = declare_register (cr
[i
- REG_CR
].name
,
6713 REG_CR
+ cr
[i
- REG_CR
].regnum
);
6715 declare_register ("gp", REG_GR
+ 1);
6716 declare_register ("sp", REG_GR
+ 12);
6717 declare_register ("rp", REG_BR
+ 0);
6719 /* pseudo-registers used to specify unwind info: */
6720 declare_register ("psp", REG_PSP
);
6722 declare_register_set ("ret", 4, REG_GR
+ 8);
6723 declare_register_set ("farg", 8, REG_FR
+ 8);
6724 declare_register_set ("fret", 8, REG_FR
+ 8);
6726 for (i
= 0; i
< NELEMS (const_bits
); ++i
)
6728 err
= hash_insert (md
.const_hash
, const_bits
[i
].name
,
6729 (PTR
) (const_bits
+ i
));
6731 as_fatal ("Inserting \"%s\" into constant hash table failed: %s",
6735 /* Set the architecture and machine depending on defaults and command line
6737 if (md
.flags
& EF_IA_64_ABI64
)
6738 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf64
);
6740 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf32
);
6743 as_warn (_("Could not set architecture and machine"));
6745 /* Set the pointer size and pointer shift size depending on md.flags */
6747 if (md
.flags
& EF_IA_64_ABI64
)
6749 md
.pointer_size
= 8; /* pointers are 8 bytes */
6750 md
.pointer_size_shift
= 3; /* alignment is 8 bytes = 2^2 */
6754 md
.pointer_size
= 4; /* pointers are 4 bytes */
6755 md
.pointer_size_shift
= 2; /* alignment is 4 bytes = 2^2 */
6758 md
.mem_offset
.hint
= 0;
6761 md
.entry_labels
= NULL
;
6764 /* Set the elf type to 64 bit ABI by default. Cannot do this in md_begin
6765 because that is called after md_parse_option which is where we do the
6766 dynamic changing of md.flags based on -mlp64 or -milp32. Also, set the
6767 default endianness. */
6770 ia64_init (argc
, argv
)
6771 int argc ATTRIBUTE_UNUSED
;
6772 char **argv ATTRIBUTE_UNUSED
;
6774 md
.flags
= MD_FLAGS_DEFAULT
;
6777 /* Return a string for the target object file format. */
6780 ia64_target_format ()
6782 if (OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
6784 if (md
.flags
& EF_IA_64_BE
)
6786 if (md
.flags
& EF_IA_64_ABI64
)
6787 #if defined(TE_AIX50)
6788 return "elf64-ia64-aix-big";
6789 #elif defined(TE_HPUX)
6790 return "elf64-ia64-hpux-big";
6792 return "elf64-ia64-big";
6795 #if defined(TE_AIX50)
6796 return "elf32-ia64-aix-big";
6797 #elif defined(TE_HPUX)
6798 return "elf32-ia64-hpux-big";
6800 return "elf32-ia64-big";
6805 if (md
.flags
& EF_IA_64_ABI64
)
6807 return "elf64-ia64-aix-little";
6809 return "elf64-ia64-little";
6813 return "elf32-ia64-aix-little";
6815 return "elf32-ia64-little";
6820 return "unknown-format";
6824 ia64_end_of_source ()
6826 /* terminate insn group upon reaching end of file: */
6827 insn_group_break (1, 0, 0);
6829 /* emits slots we haven't written yet: */
6830 ia64_flush_insns ();
6832 bfd_set_private_flags (stdoutput
, md
.flags
);
6834 md
.mem_offset
.hint
= 0;
6840 if (md
.qp
.X_op
== O_register
)
6841 as_bad ("qualifying predicate not followed by instruction");
6842 md
.qp
.X_op
= O_absent
;
6844 if (ignore_input ())
6847 if (input_line_pointer
[0] == ';' && input_line_pointer
[-1] == ';')
6849 if (md
.detect_dv
&& !md
.explicit_mode
)
6850 as_warn (_("Explicit stops are ignored in auto mode"));
6852 insn_group_break (1, 0, 0);
6856 /* This is a hook for ia64_frob_label, so that it can distinguish tags from
6858 static int defining_tag
= 0;
6861 ia64_unrecognized_line (ch
)
6867 expression (&md
.qp
);
6868 if (*input_line_pointer
++ != ')')
6870 as_bad ("Expected ')'");
6873 if (md
.qp
.X_op
!= O_register
)
6875 as_bad ("Qualifying predicate expected");
6878 if (md
.qp
.X_add_number
< REG_P
|| md
.qp
.X_add_number
>= REG_P
+ 64)
6880 as_bad ("Predicate register expected");
6886 if (md
.manual_bundling
)
6887 as_warn ("Found '{' when manual bundling is already turned on");
6889 CURR_SLOT
.manual_bundling_on
= 1;
6890 md
.manual_bundling
= 1;
6892 /* Bundling is only acceptable in explicit mode
6893 or when in default automatic mode. */
6894 if (md
.detect_dv
&& !md
.explicit_mode
)
6896 if (!md
.mode_explicitly_set
6897 && !md
.default_explicit_mode
)
6900 as_warn (_("Found '{' after explicit switch to automatic mode"));
6905 if (!md
.manual_bundling
)
6906 as_warn ("Found '}' when manual bundling is off");
6908 PREV_SLOT
.manual_bundling_off
= 1;
6909 md
.manual_bundling
= 0;
6911 /* switch back to automatic mode, if applicable */
6914 && !md
.mode_explicitly_set
6915 && !md
.default_explicit_mode
)
6918 /* Allow '{' to follow on the same line. We also allow ";;", but that
6919 happens automatically because ';' is an end of line marker. */
6921 if (input_line_pointer
[0] == '{')
6923 input_line_pointer
++;
6924 return ia64_unrecognized_line ('{');
6927 demand_empty_rest_of_line ();
6937 if (md
.qp
.X_op
== O_register
)
6939 as_bad ("Tag must come before qualifying predicate.");
6943 /* This implements just enough of read_a_source_file in read.c to
6944 recognize labels. */
6945 if (is_name_beginner (*input_line_pointer
))
6947 s
= input_line_pointer
;
6948 c
= get_symbol_end ();
6950 else if (LOCAL_LABELS_FB
6951 && ISDIGIT (*input_line_pointer
))
6954 while (ISDIGIT (*input_line_pointer
))
6955 temp
= (temp
* 10) + *input_line_pointer
++ - '0';
6956 fb_label_instance_inc (temp
);
6957 s
= fb_label_name (temp
, 0);
6958 c
= *input_line_pointer
;
6967 /* Put ':' back for error messages' sake. */
6968 *input_line_pointer
++ = ':';
6969 as_bad ("Expected ':'");
6976 /* Put ':' back for error messages' sake. */
6977 *input_line_pointer
++ = ':';
6978 if (*input_line_pointer
++ != ']')
6980 as_bad ("Expected ']'");
6985 as_bad ("Tag name expected");
6995 /* Not a valid line. */
7000 ia64_frob_label (sym
)
7003 struct label_fix
*fix
;
7005 /* Tags need special handling since they are not bundle breaks like
7009 fix
= obstack_alloc (¬es
, sizeof (*fix
));
7011 fix
->next
= CURR_SLOT
.tag_fixups
;
7012 CURR_SLOT
.tag_fixups
= fix
;
7017 if (bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7019 md
.last_text_seg
= now_seg
;
7020 fix
= obstack_alloc (¬es
, sizeof (*fix
));
7022 fix
->next
= CURR_SLOT
.label_fixups
;
7023 CURR_SLOT
.label_fixups
= fix
;
7025 /* Keep track of how many code entry points we've seen. */
7026 if (md
.path
== md
.maxpaths
)
7029 md
.entry_labels
= (const char **)
7030 xrealloc ((void *) md
.entry_labels
,
7031 md
.maxpaths
* sizeof (char *));
7033 md
.entry_labels
[md
.path
++] = S_GET_NAME (sym
);
7038 ia64_flush_pending_output ()
7040 if (!md
.keep_pending_output
7041 && bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7043 /* ??? This causes many unnecessary stop bits to be emitted.
7044 Unfortunately, it isn't clear if it is safe to remove this. */
7045 insn_group_break (1, 0, 0);
7046 ia64_flush_insns ();
7050 /* Do ia64-specific expression optimization. All that's done here is
7051 to transform index expressions that are either due to the indexing
7052 of rotating registers or due to the indexing of indirect register
7055 ia64_optimize_expr (l
, op
, r
)
7064 if (l
->X_op
== O_register
&& r
->X_op
== O_constant
)
7066 num_regs
= (l
->X_add_number
>> 16);
7067 if ((unsigned) r
->X_add_number
>= num_regs
)
7070 as_bad ("No current frame");
7072 as_bad ("Index out of range 0..%u", num_regs
- 1);
7073 r
->X_add_number
= 0;
7075 l
->X_add_number
= (l
->X_add_number
& 0xffff) + r
->X_add_number
;
7078 else if (l
->X_op
== O_register
&& r
->X_op
== O_register
)
7080 if (l
->X_add_number
< IND_CPUID
|| l
->X_add_number
> IND_RR
7081 || l
->X_add_number
== IND_MEM
)
7083 as_bad ("Indirect register set name expected");
7084 l
->X_add_number
= IND_CPUID
;
7087 l
->X_op_symbol
= md
.regsym
[l
->X_add_number
];
7088 l
->X_add_number
= r
->X_add_number
;
7096 ia64_parse_name (name
, e
)
7100 struct const_desc
*cdesc
;
7101 struct dynreg
*dr
= 0;
7102 unsigned int regnum
;
7106 /* first see if NAME is a known register name: */
7107 sym
= hash_find (md
.reg_hash
, name
);
7110 e
->X_op
= O_register
;
7111 e
->X_add_number
= S_GET_VALUE (sym
);
7115 cdesc
= hash_find (md
.const_hash
, name
);
7118 e
->X_op
= O_constant
;
7119 e
->X_add_number
= cdesc
->value
;
7123 /* check for inN, locN, or outN: */
7127 if (name
[1] == 'n' && ISDIGIT (name
[2]))
7135 if (name
[1] == 'o' && name
[2] == 'c' && ISDIGIT (name
[3]))
7143 if (name
[1] == 'u' && name
[2] == 't' && ISDIGIT (name
[3]))
7156 /* The name is inN, locN, or outN; parse the register number. */
7157 regnum
= strtoul (name
, &end
, 10);
7158 if (end
> name
&& *end
== '\0')
7160 if ((unsigned) regnum
>= dr
->num_regs
)
7163 as_bad ("No current frame");
7165 as_bad ("Register number out of range 0..%u",
7169 e
->X_op
= O_register
;
7170 e
->X_add_number
= dr
->base
+ regnum
;
7175 if ((dr
= hash_find (md
.dynreg_hash
, name
)))
7177 /* We've got ourselves the name of a rotating register set.
7178 Store the base register number in the low 16 bits of
7179 X_add_number and the size of the register set in the top 16
7181 e
->X_op
= O_register
;
7182 e
->X_add_number
= dr
->base
| (dr
->num_regs
<< 16);
7188 /* Remove the '#' suffix that indicates a symbol as opposed to a register. */
7191 ia64_canonicalize_symbol_name (name
)
7194 size_t len
= strlen (name
);
7195 if (len
> 1 && name
[len
- 1] == '#')
7196 name
[len
- 1] = '\0';
7200 /* Return true if idesc is a conditional branch instruction. This excludes
7201 the modulo scheduled branches, and br.ia. Mod-sched branches are excluded
7202 because they always read/write resources regardless of the value of the
7203 qualifying predicate. br.ia must always use p0, and hence is always
7204 taken. Thus this function returns true for branches which can fall
7205 through, and which use no resources if they do fall through. */
7208 is_conditional_branch (idesc
)
7209 struct ia64_opcode
*idesc
;
7211 /* br is a conditional branch. Everything that starts with br. except
7212 br.ia, br.c{loop,top,exit}, and br.w{top,exit} is a conditional branch.
7213 Everything that starts with brl is a conditional branch. */
7214 return (idesc
->name
[0] == 'b' && idesc
->name
[1] == 'r'
7215 && (idesc
->name
[2] == '\0'
7216 || (idesc
->name
[2] == '.' && idesc
->name
[3] != 'i'
7217 && idesc
->name
[3] != 'c' && idesc
->name
[3] != 'w')
7218 || idesc
->name
[2] == 'l'
7219 /* br.cond, br.call, br.clr */
7220 || (idesc
->name
[2] == '.' && idesc
->name
[3] == 'c'
7221 && (idesc
->name
[4] == 'a' || idesc
->name
[4] == 'o'
7222 || (idesc
->name
[4] == 'l' && idesc
->name
[5] == 'r')))));
7225 /* Return whether the given opcode is a taken branch. If there's any doubt,
7229 is_taken_branch (idesc
)
7230 struct ia64_opcode
*idesc
;
7232 return ((is_conditional_branch (idesc
) && CURR_SLOT
.qp_regno
== 0)
7233 || strncmp (idesc
->name
, "br.ia", 5) == 0);
7236 /* Return whether the given opcode is an interruption or rfi. If there's any
7237 doubt, returns zero. */
7240 is_interruption_or_rfi (idesc
)
7241 struct ia64_opcode
*idesc
;
7243 if (strcmp (idesc
->name
, "rfi") == 0)
7248 /* Returns the index of the given dependency in the opcode's list of chks, or
7249 -1 if there is no dependency. */
7252 depends_on (depind
, idesc
)
7254 struct ia64_opcode
*idesc
;
7257 const struct ia64_opcode_dependency
*dep
= idesc
->dependencies
;
7258 for (i
= 0; i
< dep
->nchks
; i
++)
7260 if (depind
== DEP (dep
->chks
[i
]))
7266 /* Determine a set of specific resources used for a particular resource
7267 class. Returns the number of specific resources identified For those
7268 cases which are not determinable statically, the resource returned is
7271 Meanings of value in 'NOTE':
7272 1) only read/write when the register number is explicitly encoded in the
7274 2) only read CFM when accessing a rotating GR, FR, or PR. mov pr only
7275 accesses CFM when qualifying predicate is in the rotating region.
7276 3) general register value is used to specify an indirect register; not
7277 determinable statically.
7278 4) only read the given resource when bits 7:0 of the indirect index
7279 register value does not match the register number of the resource; not
7280 determinable statically.
7281 5) all rules are implementation specific.
7282 6) only when both the index specified by the reader and the index specified
7283 by the writer have the same value in bits 63:61; not determinable
7285 7) only access the specified resource when the corresponding mask bit is
7287 8) PSR.dfh is only read when these insns reference FR32-127. PSR.dfl is
7288 only read when these insns reference FR2-31
7289 9) PSR.mfl is only written when these insns write FR2-31. PSR.mfh is only
7290 written when these insns write FR32-127
7291 10) The PSR.bn bit is only accessed when one of GR16-31 is specified in the
7293 11) The target predicates are written independently of PR[qp], but source
7294 registers are only read if PR[qp] is true. Since the state of PR[qp]
7295 cannot statically be determined, all source registers are marked used.
7296 12) This insn only reads the specified predicate register when that
7297 register is the PR[qp].
7298 13) This reference to ld-c only applies to teh GR whose value is loaded
7299 with data returned from memory, not the post-incremented address register.
7300 14) The RSE resource includes the implementation-specific RSE internal
7301 state resources. At least one (and possibly more) of these resources are
7302 read by each instruction listed in IC:rse-readers. At least one (and
7303 possibly more) of these resources are written by each insn listed in
7305 15+16) Represents reserved instructions, which the assembler does not
7308 Memory resources (i.e. locations in memory) are *not* marked or tracked by
7309 this code; there are no dependency violations based on memory access.
7312 #define MAX_SPECS 256
7317 specify_resource (dep
, idesc
, type
, specs
, note
, path
)
7318 const struct ia64_dependency
*dep
;
7319 struct ia64_opcode
*idesc
;
7320 int type
; /* is this a DV chk or a DV reg? */
7321 struct rsrc specs
[MAX_SPECS
]; /* returned specific resources */
7322 int note
; /* resource note for this insn's usage */
7323 int path
; /* which execution path to examine */
7330 if (dep
->mode
== IA64_DV_WAW
7331 || (dep
->mode
== IA64_DV_RAW
&& type
== DV_REG
)
7332 || (dep
->mode
== IA64_DV_WAR
&& type
== DV_CHK
))
7335 /* template for any resources we identify */
7336 tmpl
.dependency
= dep
;
7338 tmpl
.insn_srlz
= tmpl
.data_srlz
= 0;
7339 tmpl
.qp_regno
= CURR_SLOT
.qp_regno
;
7340 tmpl
.link_to_qp_branch
= 1;
7341 tmpl
.mem_offset
.hint
= 0;
7344 tmpl
.cmp_type
= CMP_NONE
;
7347 as_warn (_("Unhandled dependency %s for %s (%s), note %d"), \
7348 dep->name, idesc->name, (rsrc_write?"write":"read"), note)
7349 #define KNOWN(REG) (gr_values[REG].known && gr_values[REG].path >= path)
7351 /* we don't need to track these */
7352 if (dep
->semantics
== IA64_DVS_NONE
)
7355 switch (dep
->specifier
)
7360 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
7362 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
7363 if (regno
>= 0 && regno
<= 7)
7365 specs
[count
] = tmpl
;
7366 specs
[count
++].index
= regno
;
7372 for (i
= 0; i
< 8; i
++)
7374 specs
[count
] = tmpl
;
7375 specs
[count
++].index
= i
;
7384 case IA64_RS_AR_UNAT
:
7385 /* This is a mov =AR or mov AR= instruction. */
7386 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
7388 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
7389 if (regno
== AR_UNAT
)
7391 specs
[count
++] = tmpl
;
7396 /* This is a spill/fill, or other instruction that modifies the
7399 /* Unless we can determine the specific bits used, mark the whole
7400 thing; bits 8:3 of the memory address indicate the bit used in
7401 UNAT. The .mem.offset hint may be used to eliminate a small
7402 subset of conflicts. */
7403 specs
[count
] = tmpl
;
7404 if (md
.mem_offset
.hint
)
7407 fprintf (stderr
, " Using hint for spill/fill\n");
7408 /* The index isn't actually used, just set it to something
7409 approximating the bit index. */
7410 specs
[count
].index
= (md
.mem_offset
.offset
>> 3) & 0x3F;
7411 specs
[count
].mem_offset
.hint
= 1;
7412 specs
[count
].mem_offset
.offset
= md
.mem_offset
.offset
;
7413 specs
[count
++].mem_offset
.base
= md
.mem_offset
.base
;
7417 specs
[count
++].specific
= 0;
7425 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
7427 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
7428 if ((regno
>= 8 && regno
<= 15)
7429 || (regno
>= 20 && regno
<= 23)
7430 || (regno
>= 31 && regno
<= 39)
7431 || (regno
>= 41 && regno
<= 47)
7432 || (regno
>= 67 && regno
<= 111))
7434 specs
[count
] = tmpl
;
7435 specs
[count
++].index
= regno
;
7448 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
7450 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
7451 if ((regno
>= 48 && regno
<= 63)
7452 || (regno
>= 112 && regno
<= 127))
7454 specs
[count
] = tmpl
;
7455 specs
[count
++].index
= regno
;
7461 for (i
= 48; i
< 64; i
++)
7463 specs
[count
] = tmpl
;
7464 specs
[count
++].index
= i
;
7466 for (i
= 112; i
< 128; i
++)
7468 specs
[count
] = tmpl
;
7469 specs
[count
++].index
= i
;
7487 for (i
= 0; i
< idesc
->num_outputs
; i
++)
7488 if (idesc
->operands
[i
] == IA64_OPND_B1
7489 || idesc
->operands
[i
] == IA64_OPND_B2
)
7491 specs
[count
] = tmpl
;
7492 specs
[count
++].index
=
7493 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
7498 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
7499 if (idesc
->operands
[i
] == IA64_OPND_B1
7500 || idesc
->operands
[i
] == IA64_OPND_B2
)
7502 specs
[count
] = tmpl
;
7503 specs
[count
++].index
=
7504 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
7510 case IA64_RS_CPUID
: /* four or more registers */
7513 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CPUID_R3
)
7515 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7516 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7519 specs
[count
] = tmpl
;
7520 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7524 specs
[count
] = tmpl
;
7525 specs
[count
++].specific
= 0;
7535 case IA64_RS_DBR
: /* four or more registers */
7538 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_DBR_R3
)
7540 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7541 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7544 specs
[count
] = tmpl
;
7545 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7549 specs
[count
] = tmpl
;
7550 specs
[count
++].specific
= 0;
7554 else if (note
== 0 && !rsrc_write
)
7556 specs
[count
] = tmpl
;
7557 specs
[count
++].specific
= 0;
7565 case IA64_RS_IBR
: /* four or more registers */
7568 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_IBR_R3
)
7570 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7571 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7574 specs
[count
] = tmpl
;
7575 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7579 specs
[count
] = tmpl
;
7580 specs
[count
++].specific
= 0;
7593 /* These are implementation specific. Force all references to
7594 conflict with all other references. */
7595 specs
[count
] = tmpl
;
7596 specs
[count
++].specific
= 0;
7604 case IA64_RS_PKR
: /* 16 or more registers */
7605 if (note
== 3 || note
== 4)
7607 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PKR_R3
)
7609 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7610 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7615 specs
[count
] = tmpl
;
7616 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7619 for (i
= 0; i
< NELEMS (gr_values
); i
++)
7621 /* Uses all registers *except* the one in R3. */
7622 if ((unsigned)i
!= (gr_values
[regno
].value
& 0xFF))
7624 specs
[count
] = tmpl
;
7625 specs
[count
++].index
= i
;
7631 specs
[count
] = tmpl
;
7632 specs
[count
++].specific
= 0;
7639 specs
[count
] = tmpl
;
7640 specs
[count
++].specific
= 0;
7644 case IA64_RS_PMC
: /* four or more registers */
7647 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMC_R3
7648 || (!rsrc_write
&& idesc
->operands
[1] == IA64_OPND_PMD_R3
))
7651 int index
= ((idesc
->operands
[1] == IA64_OPND_R3
&& !rsrc_write
)
7653 int regno
= CURR_SLOT
.opnd
[index
].X_add_number
- REG_GR
;
7654 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7657 specs
[count
] = tmpl
;
7658 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7662 specs
[count
] = tmpl
;
7663 specs
[count
++].specific
= 0;
7673 case IA64_RS_PMD
: /* four or more registers */
7676 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMD_R3
)
7678 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7679 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7682 specs
[count
] = tmpl
;
7683 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
7687 specs
[count
] = tmpl
;
7688 specs
[count
++].specific
= 0;
7698 case IA64_RS_RR
: /* eight registers */
7701 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_RR_R3
)
7703 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
7704 if (regno
>= 0 && regno
< NELEMS (gr_values
)
7707 specs
[count
] = tmpl
;
7708 specs
[count
++].index
= (gr_values
[regno
].value
>> 61) & 0x7;
7712 specs
[count
] = tmpl
;
7713 specs
[count
++].specific
= 0;
7717 else if (note
== 0 && !rsrc_write
)
7719 specs
[count
] = tmpl
;
7720 specs
[count
++].specific
= 0;
7728 case IA64_RS_CR_IRR
:
7731 /* handle mov-from-CR-IVR; it's a read that writes CR[IRR] */
7732 int regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
;
7734 && idesc
->operands
[1] == IA64_OPND_CR3
7737 for (i
= 0; i
< 4; i
++)
7739 specs
[count
] = tmpl
;
7740 specs
[count
++].index
= CR_IRR0
+ i
;
7746 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
7747 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
7749 && regno
<= CR_IRR3
)
7751 specs
[count
] = tmpl
;
7752 specs
[count
++].index
= regno
;
7761 case IA64_RS_CR_LRR
:
7768 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
7769 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
7770 && (regno
== CR_LRR0
|| regno
== CR_LRR1
))
7772 specs
[count
] = tmpl
;
7773 specs
[count
++].index
= regno
;
7781 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
7783 specs
[count
] = tmpl
;
7784 specs
[count
++].index
=
7785 CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
7800 else if (rsrc_write
)
7802 if (dep
->specifier
== IA64_RS_FRb
7803 && idesc
->operands
[0] == IA64_OPND_F1
)
7805 specs
[count
] = tmpl
;
7806 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_FR
;
7811 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
7813 if (idesc
->operands
[i
] == IA64_OPND_F2
7814 || idesc
->operands
[i
] == IA64_OPND_F3
7815 || idesc
->operands
[i
] == IA64_OPND_F4
)
7817 specs
[count
] = tmpl
;
7818 specs
[count
++].index
=
7819 CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
7828 /* This reference applies only to the GR whose value is loaded with
7829 data returned from memory. */
7830 specs
[count
] = tmpl
;
7831 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
7837 for (i
= 0; i
< idesc
->num_outputs
; i
++)
7838 if (idesc
->operands
[i
] == IA64_OPND_R1
7839 || idesc
->operands
[i
] == IA64_OPND_R2
7840 || idesc
->operands
[i
] == IA64_OPND_R3
)
7842 specs
[count
] = tmpl
;
7843 specs
[count
++].index
=
7844 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
7846 if (idesc
->flags
& IA64_OPCODE_POSTINC
)
7847 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
7848 if (idesc
->operands
[i
] == IA64_OPND_MR3
)
7850 specs
[count
] = tmpl
;
7851 specs
[count
++].index
=
7852 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
7857 /* Look for anything that reads a GR. */
7858 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
7860 if (idesc
->operands
[i
] == IA64_OPND_MR3
7861 || idesc
->operands
[i
] == IA64_OPND_CPUID_R3
7862 || idesc
->operands
[i
] == IA64_OPND_DBR_R3
7863 || idesc
->operands
[i
] == IA64_OPND_IBR_R3
7864 || idesc
->operands
[i
] == IA64_OPND_MSR_R3
7865 || idesc
->operands
[i
] == IA64_OPND_PKR_R3
7866 || idesc
->operands
[i
] == IA64_OPND_PMC_R3
7867 || idesc
->operands
[i
] == IA64_OPND_PMD_R3
7868 || idesc
->operands
[i
] == IA64_OPND_RR_R3
7869 || ((i
>= idesc
->num_outputs
)
7870 && (idesc
->operands
[i
] == IA64_OPND_R1
7871 || idesc
->operands
[i
] == IA64_OPND_R2
7872 || idesc
->operands
[i
] == IA64_OPND_R3
7873 /* addl source register. */
7874 || idesc
->operands
[i
] == IA64_OPND_R3_2
)))
7876 specs
[count
] = tmpl
;
7877 specs
[count
++].index
=
7878 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
7889 /* This is the same as IA64_RS_PRr, except that the register range is
7890 from 1 - 15, and there are no rotating register reads/writes here. */
7894 for (i
= 1; i
< 16; i
++)
7896 specs
[count
] = tmpl
;
7897 specs
[count
++].index
= i
;
7903 /* Mark only those registers indicated by the mask. */
7906 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
7907 for (i
= 1; i
< 16; i
++)
7908 if (mask
& ((valueT
) 1 << i
))
7910 specs
[count
] = tmpl
;
7911 specs
[count
++].index
= i
;
7919 else if (note
== 11) /* note 11 implies note 1 as well */
7923 for (i
= 0; i
< idesc
->num_outputs
; i
++)
7925 if (idesc
->operands
[i
] == IA64_OPND_P1
7926 || idesc
->operands
[i
] == IA64_OPND_P2
)
7928 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
7929 if (regno
>= 1 && regno
< 16)
7931 specs
[count
] = tmpl
;
7932 specs
[count
++].index
= regno
;
7942 else if (note
== 12)
7944 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
7946 specs
[count
] = tmpl
;
7947 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
7954 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
7955 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
7956 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
7957 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
7959 if ((idesc
->operands
[0] == IA64_OPND_P1
7960 || idesc
->operands
[0] == IA64_OPND_P2
)
7961 && p1
>= 1 && p1
< 16)
7963 specs
[count
] = tmpl
;
7964 specs
[count
].cmp_type
=
7965 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
7966 specs
[count
++].index
= p1
;
7968 if ((idesc
->operands
[1] == IA64_OPND_P1
7969 || idesc
->operands
[1] == IA64_OPND_P2
)
7970 && p2
>= 1 && p2
< 16)
7972 specs
[count
] = tmpl
;
7973 specs
[count
].cmp_type
=
7974 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
7975 specs
[count
++].index
= p2
;
7980 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
7982 specs
[count
] = tmpl
;
7983 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
7985 if (idesc
->operands
[1] == IA64_OPND_PR
)
7987 for (i
= 1; i
< 16; i
++)
7989 specs
[count
] = tmpl
;
7990 specs
[count
++].index
= i
;
8001 /* This is the general case for PRs. IA64_RS_PR and IA64_RS_PR63 are
8002 simplified cases of this. */
8006 for (i
= 16; i
< 63; i
++)
8008 specs
[count
] = tmpl
;
8009 specs
[count
++].index
= i
;
8015 /* Mark only those registers indicated by the mask. */
8017 && idesc
->operands
[0] == IA64_OPND_PR
)
8019 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8020 if (mask
& ((valueT
) 1 << 16))
8021 for (i
= 16; i
< 63; i
++)
8023 specs
[count
] = tmpl
;
8024 specs
[count
++].index
= i
;
8028 && idesc
->operands
[0] == IA64_OPND_PR_ROT
)
8030 for (i
= 16; i
< 63; i
++)
8032 specs
[count
] = tmpl
;
8033 specs
[count
++].index
= i
;
8041 else if (note
== 11) /* note 11 implies note 1 as well */
8045 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8047 if (idesc
->operands
[i
] == IA64_OPND_P1
8048 || idesc
->operands
[i
] == IA64_OPND_P2
)
8050 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8051 if (regno
>= 16 && regno
< 63)
8053 specs
[count
] = tmpl
;
8054 specs
[count
++].index
= regno
;
8064 else if (note
== 12)
8066 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8068 specs
[count
] = tmpl
;
8069 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8076 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8077 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8078 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8079 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8081 if ((idesc
->operands
[0] == IA64_OPND_P1
8082 || idesc
->operands
[0] == IA64_OPND_P2
)
8083 && p1
>= 16 && p1
< 63)
8085 specs
[count
] = tmpl
;
8086 specs
[count
].cmp_type
=
8087 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8088 specs
[count
++].index
= p1
;
8090 if ((idesc
->operands
[1] == IA64_OPND_P1
8091 || idesc
->operands
[1] == IA64_OPND_P2
)
8092 && p2
>= 16 && p2
< 63)
8094 specs
[count
] = tmpl
;
8095 specs
[count
].cmp_type
=
8096 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8097 specs
[count
++].index
= p2
;
8102 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8104 specs
[count
] = tmpl
;
8105 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8107 if (idesc
->operands
[1] == IA64_OPND_PR
)
8109 for (i
= 16; i
< 63; i
++)
8111 specs
[count
] = tmpl
;
8112 specs
[count
++].index
= i
;
8124 /* Verify that the instruction is using the PSR bit indicated in
8128 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_UM
)
8130 if (dep
->regindex
< 6)
8132 specs
[count
++] = tmpl
;
8135 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR
)
8137 if (dep
->regindex
< 32
8138 || dep
->regindex
== 35
8139 || dep
->regindex
== 36
8140 || (!rsrc_write
&& dep
->regindex
== PSR_CPL
))
8142 specs
[count
++] = tmpl
;
8145 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_L
)
8147 if (dep
->regindex
< 32
8148 || dep
->regindex
== 35
8149 || dep
->regindex
== 36
8150 || (rsrc_write
&& dep
->regindex
== PSR_CPL
))
8152 specs
[count
++] = tmpl
;
8157 /* Several PSR bits have very specific dependencies. */
8158 switch (dep
->regindex
)
8161 specs
[count
++] = tmpl
;
8166 specs
[count
++] = tmpl
;
8170 /* Only certain CR accesses use PSR.ic */
8171 if (idesc
->operands
[0] == IA64_OPND_CR3
8172 || idesc
->operands
[1] == IA64_OPND_CR3
)
8175 ((idesc
->operands
[0] == IA64_OPND_CR3
)
8178 CURR_SLOT
.opnd
[index
].X_add_number
- REG_CR
;
8193 specs
[count
++] = tmpl
;
8202 specs
[count
++] = tmpl
;
8206 /* Only some AR accesses use cpl */
8207 if (idesc
->operands
[0] == IA64_OPND_AR3
8208 || idesc
->operands
[1] == IA64_OPND_AR3
)
8211 ((idesc
->operands
[0] == IA64_OPND_AR3
)
8214 CURR_SLOT
.opnd
[index
].X_add_number
- REG_AR
;
8221 && regno
<= AR_K7
))))
8223 specs
[count
++] = tmpl
;
8228 specs
[count
++] = tmpl
;
8238 if (idesc
->operands
[0] == IA64_OPND_IMMU24
)
8240 mask
= CURR_SLOT
.opnd
[0].X_add_number
;
8246 if (mask
& ((valueT
) 1 << dep
->regindex
))
8248 specs
[count
++] = tmpl
;
8253 int min
= dep
->regindex
== PSR_DFL
? 2 : 32;
8254 int max
= dep
->regindex
== PSR_DFL
? 31 : 127;
8255 /* dfh is read on FR32-127; dfl is read on FR2-31 */
8256 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8258 if (idesc
->operands
[i
] == IA64_OPND_F1
8259 || idesc
->operands
[i
] == IA64_OPND_F2
8260 || idesc
->operands
[i
] == IA64_OPND_F3
8261 || idesc
->operands
[i
] == IA64_OPND_F4
)
8263 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8264 if (reg
>= min
&& reg
<= max
)
8266 specs
[count
++] = tmpl
;
8273 int min
= dep
->regindex
== PSR_MFL
? 2 : 32;
8274 int max
= dep
->regindex
== PSR_MFL
? 31 : 127;
8275 /* mfh is read on writes to FR32-127; mfl is read on writes to
8277 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8279 if (idesc
->operands
[i
] == IA64_OPND_F1
)
8281 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8282 if (reg
>= min
&& reg
<= max
)
8284 specs
[count
++] = tmpl
;
8289 else if (note
== 10)
8291 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8293 if (idesc
->operands
[i
] == IA64_OPND_R1
8294 || idesc
->operands
[i
] == IA64_OPND_R2
8295 || idesc
->operands
[i
] == IA64_OPND_R3
)
8297 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8298 if (regno
>= 16 && regno
<= 31)
8300 specs
[count
++] = tmpl
;
8311 case IA64_RS_AR_FPSR
:
8312 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8314 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8315 if (regno
== AR_FPSR
)
8317 specs
[count
++] = tmpl
;
8322 specs
[count
++] = tmpl
;
8327 /* Handle all AR[REG] resources */
8328 if (note
== 0 || note
== 1)
8330 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8331 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
8332 && regno
== dep
->regindex
)
8334 specs
[count
++] = tmpl
;
8336 /* other AR[REG] resources may be affected by AR accesses */
8337 else if (idesc
->operands
[0] == IA64_OPND_AR3
)
8340 regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
;
8341 switch (dep
->regindex
)
8347 if (regno
== AR_BSPSTORE
)
8349 specs
[count
++] = tmpl
;
8353 (regno
== AR_BSPSTORE
8354 || regno
== AR_RNAT
))
8356 specs
[count
++] = tmpl
;
8361 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
8364 regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
;
8365 switch (dep
->regindex
)
8370 if (regno
== AR_BSPSTORE
|| regno
== AR_RNAT
)
8372 specs
[count
++] = tmpl
;
8379 specs
[count
++] = tmpl
;
8389 /* Handle all CR[REG] resources */
8390 if (note
== 0 || note
== 1)
8392 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
8394 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8395 if (regno
== dep
->regindex
)
8397 specs
[count
++] = tmpl
;
8399 else if (!rsrc_write
)
8401 /* Reads from CR[IVR] affect other resources. */
8402 if (regno
== CR_IVR
)
8404 if ((dep
->regindex
>= CR_IRR0
8405 && dep
->regindex
<= CR_IRR3
)
8406 || dep
->regindex
== CR_TPR
)
8408 specs
[count
++] = tmpl
;
8415 specs
[count
++] = tmpl
;
8424 case IA64_RS_INSERVICE
:
8425 /* look for write of EOI (67) or read of IVR (65) */
8426 if ((idesc
->operands
[0] == IA64_OPND_CR3
8427 && CURR_SLOT
.opnd
[0].X_add_number
- REG_CR
== CR_EOI
)
8428 || (idesc
->operands
[1] == IA64_OPND_CR3
8429 && CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
== CR_IVR
))
8431 specs
[count
++] = tmpl
;
8438 specs
[count
++] = tmpl
;
8449 specs
[count
++] = tmpl
;
8453 /* Check if any of the registers accessed are in the rotating region.
8454 mov to/from pr accesses CFM only when qp_regno is in the rotating
8456 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8458 if (idesc
->operands
[i
] == IA64_OPND_R1
8459 || idesc
->operands
[i
] == IA64_OPND_R2
8460 || idesc
->operands
[i
] == IA64_OPND_R3
)
8462 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8463 /* Assumes that md.rot.num_regs is always valid */
8464 if (md
.rot
.num_regs
> 0
8466 && num
< 31 + md
.rot
.num_regs
)
8468 specs
[count
] = tmpl
;
8469 specs
[count
++].specific
= 0;
8472 else if (idesc
->operands
[i
] == IA64_OPND_F1
8473 || idesc
->operands
[i
] == IA64_OPND_F2
8474 || idesc
->operands
[i
] == IA64_OPND_F3
8475 || idesc
->operands
[i
] == IA64_OPND_F4
)
8477 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8480 specs
[count
] = tmpl
;
8481 specs
[count
++].specific
= 0;
8484 else if (idesc
->operands
[i
] == IA64_OPND_P1
8485 || idesc
->operands
[i
] == IA64_OPND_P2
)
8487 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8490 specs
[count
] = tmpl
;
8491 specs
[count
++].specific
= 0;
8495 if (CURR_SLOT
.qp_regno
> 15)
8497 specs
[count
] = tmpl
;
8498 specs
[count
++].specific
= 0;
8503 /* This is the same as IA64_RS_PRr, except simplified to account for
8504 the fact that there is only one register. */
8508 specs
[count
++] = tmpl
;
8513 if (idesc
->operands
[2] == IA64_OPND_IMM17
)
8514 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8515 if (mask
& ((valueT
) 1 << 63))
8516 specs
[count
++] = tmpl
;
8518 else if (note
== 11)
8520 if ((idesc
->operands
[0] == IA64_OPND_P1
8521 && CURR_SLOT
.opnd
[0].X_add_number
- REG_P
== 63)
8522 || (idesc
->operands
[1] == IA64_OPND_P2
8523 && CURR_SLOT
.opnd
[1].X_add_number
- REG_P
== 63))
8525 specs
[count
++] = tmpl
;
8528 else if (note
== 12)
8530 if (CURR_SLOT
.qp_regno
== 63)
8532 specs
[count
++] = tmpl
;
8539 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8540 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8541 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8542 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8545 && (idesc
->operands
[0] == IA64_OPND_P1
8546 || idesc
->operands
[0] == IA64_OPND_P2
))
8548 specs
[count
] = tmpl
;
8549 specs
[count
++].cmp_type
=
8550 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8553 && (idesc
->operands
[1] == IA64_OPND_P1
8554 || idesc
->operands
[1] == IA64_OPND_P2
))
8556 specs
[count
] = tmpl
;
8557 specs
[count
++].cmp_type
=
8558 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8563 if (CURR_SLOT
.qp_regno
== 63)
8565 specs
[count
++] = tmpl
;
8576 /* FIXME we can identify some individual RSE written resources, but RSE
8577 read resources have not yet been completely identified, so for now
8578 treat RSE as a single resource */
8579 if (strncmp (idesc
->name
, "mov", 3) == 0)
8583 if (idesc
->operands
[0] == IA64_OPND_AR3
8584 && CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
)
8586 specs
[count
] = tmpl
;
8587 specs
[count
++].index
= 0; /* IA64_RSE_BSPLOAD/RNATBITINDEX */
8592 if (idesc
->operands
[0] == IA64_OPND_AR3
)
8594 if (CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
8595 || CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_RNAT
)
8597 specs
[count
++] = tmpl
;
8600 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
8602 if (CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSP
8603 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSPSTORE
8604 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_RNAT
)
8606 specs
[count
++] = tmpl
;
8613 specs
[count
++] = tmpl
;
8618 /* FIXME -- do any of these need to be non-specific? */
8619 specs
[count
++] = tmpl
;
8623 as_bad (_("Unrecognized dependency specifier %d\n"), dep
->specifier
);
8630 /* Clear branch flags on marked resources. This breaks the link between the
8631 QP of the marking instruction and a subsequent branch on the same QP. */
8634 clear_qp_branch_flag (mask
)
8638 for (i
= 0; i
< regdepslen
; i
++)
8640 valueT bit
= ((valueT
) 1 << regdeps
[i
].qp_regno
);
8641 if ((bit
& mask
) != 0)
8643 regdeps
[i
].link_to_qp_branch
= 0;
8648 /* Remove any mutexes which contain any of the PRs indicated in the mask.
8650 Any changes to a PR clears the mutex relations which include that PR. */
8653 clear_qp_mutex (mask
)
8659 while (i
< qp_mutexeslen
)
8661 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
8665 fprintf (stderr
, " Clearing mutex relation");
8666 print_prmask (qp_mutexes
[i
].prmask
);
8667 fprintf (stderr
, "\n");
8669 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
8676 /* Clear implies relations which contain PRs in the given masks.
8677 P1_MASK indicates the source of the implies relation, while P2_MASK
8678 indicates the implied PR. */
8681 clear_qp_implies (p1_mask
, p2_mask
)
8688 while (i
< qp_implieslen
)
8690 if ((((valueT
) 1 << qp_implies
[i
].p1
) & p1_mask
) != 0
8691 || (((valueT
) 1 << qp_implies
[i
].p2
) & p2_mask
) != 0)
8694 fprintf (stderr
, "Clearing implied relation PR%d->PR%d\n",
8695 qp_implies
[i
].p1
, qp_implies
[i
].p2
);
8696 qp_implies
[i
] = qp_implies
[--qp_implieslen
];
8703 /* Add the PRs specified to the list of implied relations. */
8706 add_qp_imply (p1
, p2
)
8713 /* p0 is not meaningful here. */
8714 if (p1
== 0 || p2
== 0)
8720 /* If it exists already, ignore it. */
8721 for (i
= 0; i
< qp_implieslen
; i
++)
8723 if (qp_implies
[i
].p1
== p1
8724 && qp_implies
[i
].p2
== p2
8725 && qp_implies
[i
].path
== md
.path
8726 && !qp_implies
[i
].p2_branched
)
8730 if (qp_implieslen
== qp_impliestotlen
)
8732 qp_impliestotlen
+= 20;
8733 qp_implies
= (struct qp_imply
*)
8734 xrealloc ((void *) qp_implies
,
8735 qp_impliestotlen
* sizeof (struct qp_imply
));
8738 fprintf (stderr
, " Registering PR%d implies PR%d\n", p1
, p2
);
8739 qp_implies
[qp_implieslen
].p1
= p1
;
8740 qp_implies
[qp_implieslen
].p2
= p2
;
8741 qp_implies
[qp_implieslen
].path
= md
.path
;
8742 qp_implies
[qp_implieslen
++].p2_branched
= 0;
8744 /* Add in the implied transitive relations; for everything that p2 implies,
8745 make p1 imply that, too; for everything that implies p1, make it imply p2
8747 for (i
= 0; i
< qp_implieslen
; i
++)
8749 if (qp_implies
[i
].p1
== p2
)
8750 add_qp_imply (p1
, qp_implies
[i
].p2
);
8751 if (qp_implies
[i
].p2
== p1
)
8752 add_qp_imply (qp_implies
[i
].p1
, p2
);
8754 /* Add in mutex relations implied by this implies relation; for each mutex
8755 relation containing p2, duplicate it and replace p2 with p1. */
8756 bit
= (valueT
) 1 << p1
;
8757 mask
= (valueT
) 1 << p2
;
8758 for (i
= 0; i
< qp_mutexeslen
; i
++)
8760 if (qp_mutexes
[i
].prmask
& mask
)
8761 add_qp_mutex ((qp_mutexes
[i
].prmask
& ~mask
) | bit
);
8765 /* Add the PRs specified in the mask to the mutex list; this means that only
8766 one of the PRs can be true at any time. PR0 should never be included in
8776 if (qp_mutexeslen
== qp_mutexestotlen
)
8778 qp_mutexestotlen
+= 20;
8779 qp_mutexes
= (struct qpmutex
*)
8780 xrealloc ((void *) qp_mutexes
,
8781 qp_mutexestotlen
* sizeof (struct qpmutex
));
8785 fprintf (stderr
, " Registering mutex on");
8786 print_prmask (mask
);
8787 fprintf (stderr
, "\n");
8789 qp_mutexes
[qp_mutexeslen
].path
= md
.path
;
8790 qp_mutexes
[qp_mutexeslen
++].prmask
= mask
;
8794 has_suffix_p (name
, suffix
)
8798 size_t namelen
= strlen (name
);
8799 size_t sufflen
= strlen (suffix
);
8801 if (namelen
<= sufflen
)
8803 return strcmp (name
+ namelen
- sufflen
, suffix
) == 0;
8807 clear_register_values ()
8811 fprintf (stderr
, " Clearing register values\n");
8812 for (i
= 1; i
< NELEMS (gr_values
); i
++)
8813 gr_values
[i
].known
= 0;
8816 /* Keep track of register values/changes which affect DV tracking.
8818 optimization note: should add a flag to classes of insns where otherwise we
8819 have to examine a group of strings to identify them. */
8822 note_register_values (idesc
)
8823 struct ia64_opcode
*idesc
;
8825 valueT qp_changemask
= 0;
8828 /* Invalidate values for registers being written to. */
8829 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8831 if (idesc
->operands
[i
] == IA64_OPND_R1
8832 || idesc
->operands
[i
] == IA64_OPND_R2
8833 || idesc
->operands
[i
] == IA64_OPND_R3
)
8835 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8836 if (regno
> 0 && regno
< NELEMS (gr_values
))
8837 gr_values
[regno
].known
= 0;
8839 else if (idesc
->operands
[i
] == IA64_OPND_R3_2
)
8841 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8842 if (regno
> 0 && regno
< 4)
8843 gr_values
[regno
].known
= 0;
8845 else if (idesc
->operands
[i
] == IA64_OPND_P1
8846 || idesc
->operands
[i
] == IA64_OPND_P2
)
8848 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8849 qp_changemask
|= (valueT
) 1 << regno
;
8851 else if (idesc
->operands
[i
] == IA64_OPND_PR
)
8853 if (idesc
->operands
[2] & (valueT
) 0x10000)
8854 qp_changemask
= ~(valueT
) 0x1FFFF | idesc
->operands
[2];
8856 qp_changemask
= idesc
->operands
[2];
8859 else if (idesc
->operands
[i
] == IA64_OPND_PR_ROT
)
8861 if (idesc
->operands
[1] & ((valueT
) 1 << 43))
8862 qp_changemask
= ~(valueT
) 0xFFFFFFFFFFF | idesc
->operands
[1];
8864 qp_changemask
= idesc
->operands
[1];
8865 qp_changemask
&= ~(valueT
) 0xFFFF;
8870 /* Always clear qp branch flags on any PR change. */
8871 /* FIXME there may be exceptions for certain compares. */
8872 clear_qp_branch_flag (qp_changemask
);
8874 /* Invalidate rotating registers on insns which affect RRBs in CFM. */
8875 if (idesc
->flags
& IA64_OPCODE_MOD_RRBS
)
8877 qp_changemask
|= ~(valueT
) 0xFFFF;
8878 if (strcmp (idesc
->name
, "clrrrb.pr") != 0)
8880 for (i
= 32; i
< 32 + md
.rot
.num_regs
; i
++)
8881 gr_values
[i
].known
= 0;
8883 clear_qp_mutex (qp_changemask
);
8884 clear_qp_implies (qp_changemask
, qp_changemask
);
8886 /* After a call, all register values are undefined, except those marked
8888 else if (strncmp (idesc
->name
, "br.call", 6) == 0
8889 || strncmp (idesc
->name
, "brl.call", 7) == 0)
8891 /* FIXME keep GR values which are marked as "safe_across_calls" */
8892 clear_register_values ();
8893 clear_qp_mutex (~qp_safe_across_calls
);
8894 clear_qp_implies (~qp_safe_across_calls
, ~qp_safe_across_calls
);
8895 clear_qp_branch_flag (~qp_safe_across_calls
);
8897 else if (is_interruption_or_rfi (idesc
)
8898 || is_taken_branch (idesc
))
8900 clear_register_values ();
8901 clear_qp_mutex (~(valueT
) 0);
8902 clear_qp_implies (~(valueT
) 0, ~(valueT
) 0);
8904 /* Look for mutex and implies relations. */
8905 else if ((idesc
->operands
[0] == IA64_OPND_P1
8906 || idesc
->operands
[0] == IA64_OPND_P2
)
8907 && (idesc
->operands
[1] == IA64_OPND_P1
8908 || idesc
->operands
[1] == IA64_OPND_P2
))
8910 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8911 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8912 valueT p1mask
= (valueT
) 1 << p1
;
8913 valueT p2mask
= (valueT
) 1 << p2
;
8915 /* If one of the PRs is PR0, we can't really do anything. */
8916 if (p1
== 0 || p2
== 0)
8919 fprintf (stderr
, " Ignoring PRs due to inclusion of p0\n");
8921 /* In general, clear mutexes and implies which include P1 or P2,
8922 with the following exceptions. */
8923 else if (has_suffix_p (idesc
->name
, ".or.andcm")
8924 || has_suffix_p (idesc
->name
, ".and.orcm"))
8926 add_qp_mutex (p1mask
| p2mask
);
8927 clear_qp_implies (p2mask
, p1mask
);
8929 else if (has_suffix_p (idesc
->name
, ".andcm")
8930 || has_suffix_p (idesc
->name
, ".and"))
8932 clear_qp_implies (0, p1mask
| p2mask
);
8934 else if (has_suffix_p (idesc
->name
, ".orcm")
8935 || has_suffix_p (idesc
->name
, ".or"))
8937 clear_qp_mutex (p1mask
| p2mask
);
8938 clear_qp_implies (p1mask
| p2mask
, 0);
8942 clear_qp_implies (p1mask
| p2mask
, p1mask
| p2mask
);
8943 if (has_suffix_p (idesc
->name
, ".unc"))
8945 add_qp_mutex (p1mask
| p2mask
);
8946 if (CURR_SLOT
.qp_regno
!= 0)
8948 add_qp_imply (CURR_SLOT
.opnd
[0].X_add_number
- REG_P
,
8949 CURR_SLOT
.qp_regno
);
8950 add_qp_imply (CURR_SLOT
.opnd
[1].X_add_number
- REG_P
,
8951 CURR_SLOT
.qp_regno
);
8954 else if (CURR_SLOT
.qp_regno
== 0)
8956 add_qp_mutex (p1mask
| p2mask
);
8960 clear_qp_mutex (p1mask
| p2mask
);
8964 /* Look for mov imm insns into GRs. */
8965 else if (idesc
->operands
[0] == IA64_OPND_R1
8966 && (idesc
->operands
[1] == IA64_OPND_IMM22
8967 || idesc
->operands
[1] == IA64_OPND_IMMU64
)
8968 && (strcmp (idesc
->name
, "mov") == 0
8969 || strcmp (idesc
->name
, "movl") == 0))
8971 int regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
8972 if (regno
> 0 && regno
< NELEMS (gr_values
))
8974 gr_values
[regno
].known
= 1;
8975 gr_values
[regno
].value
= CURR_SLOT
.opnd
[1].X_add_number
;
8976 gr_values
[regno
].path
= md
.path
;
8979 fprintf (stderr
, " Know gr%d = ", regno
);
8980 fprintf_vma (stderr
, gr_values
[regno
].value
);
8981 fputs ("\n", stderr
);
8987 clear_qp_mutex (qp_changemask
);
8988 clear_qp_implies (qp_changemask
, qp_changemask
);
8992 /* Return whether the given predicate registers are currently mutex. */
8995 qp_mutex (p1
, p2
, path
)
9005 mask
= ((valueT
) 1 << p1
) | (valueT
) 1 << p2
;
9006 for (i
= 0; i
< qp_mutexeslen
; i
++)
9008 if (qp_mutexes
[i
].path
>= path
9009 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
9016 /* Return whether the given resource is in the given insn's list of chks
9017 Return 1 if the conflict is absolutely determined, 2 if it's a potential
9021 resources_match (rs
, idesc
, note
, qp_regno
, path
)
9023 struct ia64_opcode
*idesc
;
9028 struct rsrc specs
[MAX_SPECS
];
9031 /* If the marked resource's qp_regno and the given qp_regno are mutex,
9032 we don't need to check. One exception is note 11, which indicates that
9033 target predicates are written regardless of PR[qp]. */
9034 if (qp_mutex (rs
->qp_regno
, qp_regno
, path
)
9038 count
= specify_resource (rs
->dependency
, idesc
, DV_CHK
, specs
, note
, path
);
9041 /* UNAT checking is a bit more specific than other resources */
9042 if (rs
->dependency
->specifier
== IA64_RS_AR_UNAT
9043 && specs
[count
].mem_offset
.hint
9044 && rs
->mem_offset
.hint
)
9046 if (rs
->mem_offset
.base
== specs
[count
].mem_offset
.base
)
9048 if (((rs
->mem_offset
.offset
>> 3) & 0x3F) ==
9049 ((specs
[count
].mem_offset
.offset
>> 3) & 0x3F))
9056 /* Skip apparent PR write conflicts where both writes are an AND or both
9057 writes are an OR. */
9058 if (rs
->dependency
->specifier
== IA64_RS_PR
9059 || rs
->dependency
->specifier
== IA64_RS_PRr
9060 || rs
->dependency
->specifier
== IA64_RS_PR63
)
9062 if (specs
[count
].cmp_type
!= CMP_NONE
9063 && specs
[count
].cmp_type
== rs
->cmp_type
)
9066 fprintf (stderr
, " %s on parallel compare allowed (PR%d)\n",
9067 dv_mode
[rs
->dependency
->mode
],
9068 rs
->dependency
->specifier
!= IA64_RS_PR63
?
9069 specs
[count
].index
: 63);
9074 " %s on parallel compare conflict %s vs %s on PR%d\n",
9075 dv_mode
[rs
->dependency
->mode
],
9076 dv_cmp_type
[rs
->cmp_type
],
9077 dv_cmp_type
[specs
[count
].cmp_type
],
9078 rs
->dependency
->specifier
!= IA64_RS_PR63
?
9079 specs
[count
].index
: 63);
9083 /* If either resource is not specific, conservatively assume a conflict
9085 if (!specs
[count
].specific
|| !rs
->specific
)
9087 else if (specs
[count
].index
== rs
->index
)
9092 fprintf (stderr
, " No %s conflicts\n", rs
->dependency
->name
);
9098 /* Indicate an instruction group break; if INSERT_STOP is non-zero, then
9099 insert a stop to create the break. Update all resource dependencies
9100 appropriately. If QP_REGNO is non-zero, only apply the break to resources
9101 which use the same QP_REGNO and have the link_to_qp_branch flag set.
9102 If SAVE_CURRENT is non-zero, don't affect resources marked by the current
9106 insn_group_break (insert_stop
, qp_regno
, save_current
)
9113 if (insert_stop
&& md
.num_slots_in_use
> 0)
9114 PREV_SLOT
.end_of_insn_group
= 1;
9118 fprintf (stderr
, " Insn group break%s",
9119 (insert_stop
? " (w/stop)" : ""));
9121 fprintf (stderr
, " effective for QP=%d", qp_regno
);
9122 fprintf (stderr
, "\n");
9126 while (i
< regdepslen
)
9128 const struct ia64_dependency
*dep
= regdeps
[i
].dependency
;
9131 && regdeps
[i
].qp_regno
!= qp_regno
)
9138 && CURR_SLOT
.src_file
== regdeps
[i
].file
9139 && CURR_SLOT
.src_line
== regdeps
[i
].line
)
9145 /* clear dependencies which are automatically cleared by a stop, or
9146 those that have reached the appropriate state of insn serialization */
9147 if (dep
->semantics
== IA64_DVS_IMPLIED
9148 || dep
->semantics
== IA64_DVS_IMPLIEDF
9149 || regdeps
[i
].insn_srlz
== STATE_SRLZ
)
9151 print_dependency ("Removing", i
);
9152 regdeps
[i
] = regdeps
[--regdepslen
];
9156 if (dep
->semantics
== IA64_DVS_DATA
9157 || dep
->semantics
== IA64_DVS_INSTR
9158 || dep
->semantics
== IA64_DVS_SPECIFIC
)
9160 if (regdeps
[i
].insn_srlz
== STATE_NONE
)
9161 regdeps
[i
].insn_srlz
= STATE_STOP
;
9162 if (regdeps
[i
].data_srlz
== STATE_NONE
)
9163 regdeps
[i
].data_srlz
= STATE_STOP
;
9170 /* Add the given resource usage spec to the list of active dependencies. */
9173 mark_resource (idesc
, dep
, spec
, depind
, path
)
9174 struct ia64_opcode
*idesc ATTRIBUTE_UNUSED
;
9175 const struct ia64_dependency
*dep ATTRIBUTE_UNUSED
;
9180 if (regdepslen
== regdepstotlen
)
9182 regdepstotlen
+= 20;
9183 regdeps
= (struct rsrc
*)
9184 xrealloc ((void *) regdeps
,
9185 regdepstotlen
* sizeof (struct rsrc
));
9188 regdeps
[regdepslen
] = *spec
;
9189 regdeps
[regdepslen
].depind
= depind
;
9190 regdeps
[regdepslen
].path
= path
;
9191 regdeps
[regdepslen
].file
= CURR_SLOT
.src_file
;
9192 regdeps
[regdepslen
].line
= CURR_SLOT
.src_line
;
9194 print_dependency ("Adding", regdepslen
);
9200 print_dependency (action
, depind
)
9206 fprintf (stderr
, " %s %s '%s'",
9207 action
, dv_mode
[(regdeps
[depind
].dependency
)->mode
],
9208 (regdeps
[depind
].dependency
)->name
);
9209 if (regdeps
[depind
].specific
&& regdeps
[depind
].index
!= 0)
9210 fprintf (stderr
, " (%d)", regdeps
[depind
].index
);
9211 if (regdeps
[depind
].mem_offset
.hint
)
9213 fputs (" ", stderr
);
9214 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.base
);
9215 fputs ("+", stderr
);
9216 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.offset
);
9218 fprintf (stderr
, "\n");
9223 instruction_serialization ()
9227 fprintf (stderr
, " Instruction serialization\n");
9228 for (i
= 0; i
< regdepslen
; i
++)
9229 if (regdeps
[i
].insn_srlz
== STATE_STOP
)
9230 regdeps
[i
].insn_srlz
= STATE_SRLZ
;
9234 data_serialization ()
9238 fprintf (stderr
, " Data serialization\n");
9239 while (i
< regdepslen
)
9241 if (regdeps
[i
].data_srlz
== STATE_STOP
9242 /* Note: as of 991210, all "other" dependencies are cleared by a
9243 data serialization. This might change with new tables */
9244 || (regdeps
[i
].dependency
)->semantics
== IA64_DVS_OTHER
)
9246 print_dependency ("Removing", i
);
9247 regdeps
[i
] = regdeps
[--regdepslen
];
9254 /* Insert stops and serializations as needed to avoid DVs. */
9257 remove_marked_resource (rs
)
9260 switch (rs
->dependency
->semantics
)
9262 case IA64_DVS_SPECIFIC
:
9264 fprintf (stderr
, "Implementation-specific, assume worst case...\n");
9265 /* ...fall through... */
9266 case IA64_DVS_INSTR
:
9268 fprintf (stderr
, "Inserting instr serialization\n");
9269 if (rs
->insn_srlz
< STATE_STOP
)
9270 insn_group_break (1, 0, 0);
9271 if (rs
->insn_srlz
< STATE_SRLZ
)
9273 int oldqp
= CURR_SLOT
.qp_regno
;
9274 struct ia64_opcode
*oldidesc
= CURR_SLOT
.idesc
;
9275 /* Manually jam a srlz.i insn into the stream */
9276 CURR_SLOT
.qp_regno
= 0;
9277 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.i");
9278 instruction_serialization ();
9279 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
9280 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
9282 CURR_SLOT
.qp_regno
= oldqp
;
9283 CURR_SLOT
.idesc
= oldidesc
;
9285 insn_group_break (1, 0, 0);
9287 case IA64_DVS_OTHER
: /* as of rev2 (991220) of the DV tables, all
9288 "other" types of DV are eliminated
9289 by a data serialization */
9292 fprintf (stderr
, "Inserting data serialization\n");
9293 if (rs
->data_srlz
< STATE_STOP
)
9294 insn_group_break (1, 0, 0);
9296 int oldqp
= CURR_SLOT
.qp_regno
;
9297 struct ia64_opcode
*oldidesc
= CURR_SLOT
.idesc
;
9298 /* Manually jam a srlz.d insn into the stream */
9299 CURR_SLOT
.qp_regno
= 0;
9300 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.d");
9301 data_serialization ();
9302 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
9303 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
9305 CURR_SLOT
.qp_regno
= oldqp
;
9306 CURR_SLOT
.idesc
= oldidesc
;
9309 case IA64_DVS_IMPLIED
:
9310 case IA64_DVS_IMPLIEDF
:
9312 fprintf (stderr
, "Inserting stop\n");
9313 insn_group_break (1, 0, 0);
9320 /* Check the resources used by the given opcode against the current dependency
9323 The check is run once for each execution path encountered. In this case,
9324 a unique execution path is the sequence of instructions following a code
9325 entry point, e.g. the following has three execution paths, one starting
9326 at L0, one at L1, and one at L2.
9335 check_dependencies (idesc
)
9336 struct ia64_opcode
*idesc
;
9338 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
9342 /* Note that the number of marked resources may change within the
9343 loop if in auto mode. */
9345 while (i
< regdepslen
)
9347 struct rsrc
*rs
= ®deps
[i
];
9348 const struct ia64_dependency
*dep
= rs
->dependency
;
9353 if (dep
->semantics
== IA64_DVS_NONE
9354 || (chkind
= depends_on (rs
->depind
, idesc
)) == -1)
9360 note
= NOTE (opdeps
->chks
[chkind
]);
9362 /* Check this resource against each execution path seen thus far. */
9363 for (path
= 0; path
<= md
.path
; path
++)
9367 /* If the dependency wasn't on the path being checked, ignore it. */
9368 if (rs
->path
< path
)
9371 /* If the QP for this insn implies a QP which has branched, don't
9372 bother checking. Ed. NOTE: I don't think this check is terribly
9373 useful; what's the point of generating code which will only be
9374 reached if its QP is zero?
9375 This code was specifically inserted to handle the following code,
9376 based on notes from Intel's DV checking code, where p1 implies p2.
9382 if (CURR_SLOT
.qp_regno
!= 0)
9386 for (implies
= 0; implies
< qp_implieslen
; implies
++)
9388 if (qp_implies
[implies
].path
>= path
9389 && qp_implies
[implies
].p1
== CURR_SLOT
.qp_regno
9390 && qp_implies
[implies
].p2_branched
)
9400 if ((matchtype
= resources_match (rs
, idesc
, note
,
9401 CURR_SLOT
.qp_regno
, path
)) != 0)
9404 char pathmsg
[256] = "";
9405 char indexmsg
[256] = "";
9406 int certain
= (matchtype
== 1 && CURR_SLOT
.qp_regno
== 0);
9409 sprintf (pathmsg
, " when entry is at label '%s'",
9410 md
.entry_labels
[path
- 1]);
9411 if (rs
->specific
&& rs
->index
!= 0)
9412 sprintf (indexmsg
, ", specific resource number is %d",
9414 sprintf (msg
, "Use of '%s' %s %s dependency '%s' (%s)%s%s",
9416 (certain
? "violates" : "may violate"),
9417 dv_mode
[dep
->mode
], dep
->name
,
9418 dv_sem
[dep
->semantics
],
9421 if (md
.explicit_mode
)
9423 as_warn ("%s", msg
);
9425 as_warn (_("Only the first path encountering the conflict "
9427 as_warn_where (rs
->file
, rs
->line
,
9428 _("This is the location of the "
9429 "conflicting usage"));
9430 /* Don't bother checking other paths, to avoid duplicating
9437 fprintf (stderr
, "%s @ %s:%d\n", msg
, rs
->file
, rs
->line
);
9439 remove_marked_resource (rs
);
9441 /* since the set of dependencies has changed, start over */
9442 /* FIXME -- since we're removing dvs as we go, we
9443 probably don't really need to start over... */
9456 /* Register new dependencies based on the given opcode. */
9459 mark_resources (idesc
)
9460 struct ia64_opcode
*idesc
;
9463 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
9464 int add_only_qp_reads
= 0;
9466 /* A conditional branch only uses its resources if it is taken; if it is
9467 taken, we stop following that path. The other branch types effectively
9468 *always* write their resources. If it's not taken, register only QP
9470 if (is_conditional_branch (idesc
) || is_interruption_or_rfi (idesc
))
9472 add_only_qp_reads
= 1;
9476 fprintf (stderr
, "Registering '%s' resource usage\n", idesc
->name
);
9478 for (i
= 0; i
< opdeps
->nregs
; i
++)
9480 const struct ia64_dependency
*dep
;
9481 struct rsrc specs
[MAX_SPECS
];
9486 dep
= ia64_find_dependency (opdeps
->regs
[i
]);
9487 note
= NOTE (opdeps
->regs
[i
]);
9489 if (add_only_qp_reads
9490 && !(dep
->mode
== IA64_DV_WAR
9491 && (dep
->specifier
== IA64_RS_PR
9492 || dep
->specifier
== IA64_RS_PRr
9493 || dep
->specifier
== IA64_RS_PR63
)))
9496 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, md
.path
);
9499 if (md
.debug_dv
&& !count
)
9500 fprintf (stderr
, " No %s %s usage found (path %d)\n",
9501 dv_mode
[dep
->mode
], dep
->name
, md
.path
);
9506 mark_resource (idesc
, dep
, &specs
[count
],
9507 DEP (opdeps
->regs
[i
]), md
.path
);
9510 /* The execution path may affect register values, which may in turn
9511 affect which indirect-access resources are accessed. */
9512 switch (dep
->specifier
)
9524 for (path
= 0; path
< md
.path
; path
++)
9526 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, path
);
9528 mark_resource (idesc
, dep
, &specs
[count
],
9529 DEP (opdeps
->regs
[i
]), path
);
9536 /* Remove dependencies when they no longer apply. */
9539 update_dependencies (idesc
)
9540 struct ia64_opcode
*idesc
;
9544 if (strcmp (idesc
->name
, "srlz.i") == 0)
9546 instruction_serialization ();
9548 else if (strcmp (idesc
->name
, "srlz.d") == 0)
9550 data_serialization ();
9552 else if (is_interruption_or_rfi (idesc
)
9553 || is_taken_branch (idesc
))
9555 /* Although technically the taken branch doesn't clear dependencies
9556 which require a srlz.[id], we don't follow the branch; the next
9557 instruction is assumed to start with a clean slate. */
9561 else if (is_conditional_branch (idesc
)
9562 && CURR_SLOT
.qp_regno
!= 0)
9564 int is_call
= strstr (idesc
->name
, ".call") != NULL
;
9566 for (i
= 0; i
< qp_implieslen
; i
++)
9568 /* If the conditional branch's predicate is implied by the predicate
9569 in an existing dependency, remove that dependency. */
9570 if (qp_implies
[i
].p2
== CURR_SLOT
.qp_regno
)
9573 /* Note that this implied predicate takes a branch so that if
9574 a later insn generates a DV but its predicate implies this
9575 one, we can avoid the false DV warning. */
9576 qp_implies
[i
].p2_branched
= 1;
9577 while (depind
< regdepslen
)
9579 if (regdeps
[depind
].qp_regno
== qp_implies
[i
].p1
)
9581 print_dependency ("Removing", depind
);
9582 regdeps
[depind
] = regdeps
[--regdepslen
];
9589 /* Any marked resources which have this same predicate should be
9590 cleared, provided that the QP hasn't been modified between the
9591 marking instruction and the branch. */
9594 insn_group_break (0, CURR_SLOT
.qp_regno
, 1);
9599 while (i
< regdepslen
)
9601 if (regdeps
[i
].qp_regno
== CURR_SLOT
.qp_regno
9602 && regdeps
[i
].link_to_qp_branch
9603 && (regdeps
[i
].file
!= CURR_SLOT
.src_file
9604 || regdeps
[i
].line
!= CURR_SLOT
.src_line
))
9606 /* Treat like a taken branch */
9607 print_dependency ("Removing", i
);
9608 regdeps
[i
] = regdeps
[--regdepslen
];
9617 /* Examine the current instruction for dependency violations. */
9621 struct ia64_opcode
*idesc
;
9625 fprintf (stderr
, "Checking %s for violations (line %d, %d/%d)\n",
9626 idesc
->name
, CURR_SLOT
.src_line
,
9627 idesc
->dependencies
->nchks
,
9628 idesc
->dependencies
->nregs
);
9631 /* Look through the list of currently marked resources; if the current
9632 instruction has the dependency in its chks list which uses that resource,
9633 check against the specific resources used. */
9634 check_dependencies (idesc
);
9636 /* Look up the instruction's regdeps (RAW writes, WAW writes, and WAR reads),
9637 then add them to the list of marked resources. */
9638 mark_resources (idesc
);
9640 /* There are several types of dependency semantics, and each has its own
9641 requirements for being cleared
9643 Instruction serialization (insns separated by interruption, rfi, or
9644 writer + srlz.i + reader, all in separate groups) clears DVS_INSTR.
9646 Data serialization (instruction serialization, or writer + srlz.d +
9647 reader, where writer and srlz.d are in separate groups) clears
9648 DVS_DATA. (This also clears DVS_OTHER, but that is not guaranteed to
9649 always be the case).
9651 Instruction group break (groups separated by stop, taken branch,
9652 interruption or rfi) clears DVS_IMPLIED and DVS_IMPLIEDF.
9654 update_dependencies (idesc
);
9656 /* Sometimes, knowing a register value allows us to avoid giving a false DV
9657 warning. Keep track of as many as possible that are useful. */
9658 note_register_values (idesc
);
9660 /* We don't need or want this anymore. */
9661 md
.mem_offset
.hint
= 0;
9666 /* Translate one line of assembly. Pseudo ops and labels do not show
9672 char *saved_input_line_pointer
, *mnemonic
;
9673 const struct pseudo_opcode
*pdesc
;
9674 struct ia64_opcode
*idesc
;
9675 unsigned char qp_regno
;
9679 saved_input_line_pointer
= input_line_pointer
;
9680 input_line_pointer
= str
;
9682 /* extract the opcode (mnemonic): */
9684 mnemonic
= input_line_pointer
;
9685 ch
= get_symbol_end ();
9686 pdesc
= (struct pseudo_opcode
*) hash_find (md
.pseudo_hash
, mnemonic
);
9689 *input_line_pointer
= ch
;
9690 (*pdesc
->handler
) (pdesc
->arg
);
9694 /* Find the instruction descriptor matching the arguments. */
9696 idesc
= ia64_find_opcode (mnemonic
);
9697 *input_line_pointer
= ch
;
9700 as_bad ("Unknown opcode `%s'", mnemonic
);
9704 idesc
= parse_operands (idesc
);
9708 /* Handle the dynamic ops we can handle now: */
9709 if (idesc
->type
== IA64_TYPE_DYN
)
9711 if (strcmp (idesc
->name
, "add") == 0)
9713 if (CURR_SLOT
.opnd
[2].X_op
== O_register
9714 && CURR_SLOT
.opnd
[2].X_add_number
< 4)
9718 ia64_free_opcode (idesc
);
9719 idesc
= ia64_find_opcode (mnemonic
);
9721 know (!idesc
->next
);
9724 else if (strcmp (idesc
->name
, "mov") == 0)
9726 enum ia64_opnd opnd1
, opnd2
;
9729 opnd1
= idesc
->operands
[0];
9730 opnd2
= idesc
->operands
[1];
9731 if (opnd1
== IA64_OPND_AR3
)
9733 else if (opnd2
== IA64_OPND_AR3
)
9737 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
9738 && ar_is_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
9742 ia64_free_opcode (idesc
);
9743 idesc
= ia64_find_opcode (mnemonic
);
9744 while (idesc
!= NULL
9745 && (idesc
->operands
[0] != opnd1
9746 || idesc
->operands
[1] != opnd2
))
9747 idesc
= get_next_opcode (idesc
);
9752 if (md
.qp
.X_op
== O_register
)
9754 qp_regno
= md
.qp
.X_add_number
- REG_P
;
9755 md
.qp
.X_op
= O_absent
;
9758 flags
= idesc
->flags
;
9760 if ((flags
& IA64_OPCODE_FIRST
) != 0)
9761 insn_group_break (1, 0, 0);
9763 if ((flags
& IA64_OPCODE_NO_PRED
) != 0 && qp_regno
!= 0)
9765 as_bad ("`%s' cannot be predicated", idesc
->name
);
9769 /* Build the instruction. */
9770 CURR_SLOT
.qp_regno
= qp_regno
;
9771 CURR_SLOT
.idesc
= idesc
;
9772 as_where (&CURR_SLOT
.src_file
, &CURR_SLOT
.src_line
);
9773 dwarf2_where (&CURR_SLOT
.debug_line
);
9775 /* Add unwind entry, if there is one. */
9776 if (unwind
.current_entry
)
9778 CURR_SLOT
.unwind_record
= unwind
.current_entry
;
9779 unwind
.current_entry
= NULL
;
9782 /* Check for dependency violations. */
9786 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
9787 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
9790 if ((flags
& IA64_OPCODE_LAST
) != 0)
9791 insn_group_break (1, 0, 0);
9793 md
.last_text_seg
= now_seg
;
9796 input_line_pointer
= saved_input_line_pointer
;
9799 /* Called when symbol NAME cannot be found in the symbol table.
9800 Should be used for dynamic valued symbols only. */
9803 md_undefined_symbol (name
)
9804 char *name ATTRIBUTE_UNUSED
;
9809 /* Called for any expression that can not be recognized. When the
9810 function is called, `input_line_pointer' will point to the start of
9817 enum pseudo_type pseudo_type
;
9822 switch (*input_line_pointer
)
9825 /* Find what relocation pseudo-function we're dealing with. */
9827 ch
= *++input_line_pointer
;
9828 for (i
= 0; i
< NELEMS (pseudo_func
); ++i
)
9829 if (pseudo_func
[i
].name
&& pseudo_func
[i
].name
[0] == ch
)
9831 len
= strlen (pseudo_func
[i
].name
);
9832 if (strncmp (pseudo_func
[i
].name
+ 1,
9833 input_line_pointer
+ 1, len
- 1) == 0
9834 && !is_part_of_name (input_line_pointer
[len
]))
9836 input_line_pointer
+= len
;
9837 pseudo_type
= pseudo_func
[i
].type
;
9841 switch (pseudo_type
)
9843 case PSEUDO_FUNC_RELOC
:
9845 if (*input_line_pointer
!= '(')
9847 as_bad ("Expected '('");
9851 ++input_line_pointer
;
9853 if (*input_line_pointer
++ != ')')
9855 as_bad ("Missing ')'");
9858 if (e
->X_op
!= O_symbol
)
9860 if (e
->X_op
!= O_pseudo_fixup
)
9862 as_bad ("Not a symbolic expression");
9865 if (i
!= FUNC_LT_RELATIVE
)
9867 as_bad ("Illegal combination of relocation functions");
9870 switch (S_GET_VALUE (e
->X_op_symbol
))
9872 case FUNC_FPTR_RELATIVE
:
9873 i
= FUNC_LT_FPTR_RELATIVE
; break;
9874 case FUNC_DTP_MODULE
:
9875 i
= FUNC_LT_DTP_MODULE
; break;
9876 case FUNC_DTP_RELATIVE
:
9877 i
= FUNC_LT_DTP_RELATIVE
; break;
9878 case FUNC_TP_RELATIVE
:
9879 i
= FUNC_LT_TP_RELATIVE
; break;
9881 as_bad ("Illegal combination of relocation functions");
9885 /* Make sure gas doesn't get rid of local symbols that are used
9887 e
->X_op
= O_pseudo_fixup
;
9888 e
->X_op_symbol
= pseudo_func
[i
].u
.sym
;
9891 case PSEUDO_FUNC_CONST
:
9892 e
->X_op
= O_constant
;
9893 e
->X_add_number
= pseudo_func
[i
].u
.ival
;
9896 case PSEUDO_FUNC_REG
:
9897 e
->X_op
= O_register
;
9898 e
->X_add_number
= pseudo_func
[i
].u
.ival
;
9902 name
= input_line_pointer
- 1;
9904 as_bad ("Unknown pseudo function `%s'", name
);
9910 ++input_line_pointer
;
9912 if (*input_line_pointer
!= ']')
9914 as_bad ("Closing bracket misssing");
9919 if (e
->X_op
!= O_register
)
9920 as_bad ("Register expected as index");
9922 ++input_line_pointer
;
9933 ignore_rest_of_line ();
9936 /* Return 1 if it's OK to adjust a reloc by replacing the symbol with
9937 a section symbol plus some offset. For relocs involving @fptr(),
9938 directives we don't want such adjustments since we need to have the
9939 original symbol's name in the reloc. */
9941 ia64_fix_adjustable (fix
)
9944 /* Prevent all adjustments to global symbols */
9945 if (S_IS_EXTERN (fix
->fx_addsy
) || S_IS_WEAK (fix
->fx_addsy
))
9948 switch (fix
->fx_r_type
)
9950 case BFD_RELOC_IA64_FPTR64I
:
9951 case BFD_RELOC_IA64_FPTR32MSB
:
9952 case BFD_RELOC_IA64_FPTR32LSB
:
9953 case BFD_RELOC_IA64_FPTR64MSB
:
9954 case BFD_RELOC_IA64_FPTR64LSB
:
9955 case BFD_RELOC_IA64_LTOFF_FPTR22
:
9956 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
9966 ia64_force_relocation (fix
)
9969 switch (fix
->fx_r_type
)
9971 case BFD_RELOC_IA64_FPTR64I
:
9972 case BFD_RELOC_IA64_FPTR32MSB
:
9973 case BFD_RELOC_IA64_FPTR32LSB
:
9974 case BFD_RELOC_IA64_FPTR64MSB
:
9975 case BFD_RELOC_IA64_FPTR64LSB
:
9977 case BFD_RELOC_IA64_LTOFF22
:
9978 case BFD_RELOC_IA64_LTOFF64I
:
9979 case BFD_RELOC_IA64_LTOFF_FPTR22
:
9980 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
9981 case BFD_RELOC_IA64_PLTOFF22
:
9982 case BFD_RELOC_IA64_PLTOFF64I
:
9983 case BFD_RELOC_IA64_PLTOFF64MSB
:
9984 case BFD_RELOC_IA64_PLTOFF64LSB
:
9991 return S_FORCE_RELOC (fix
->fx_addsy
);
9994 /* Decide from what point a pc-relative relocation is relative to,
9995 relative to the pc-relative fixup. Er, relatively speaking. */
9997 ia64_pcrel_from_section (fix
, sec
)
10001 unsigned long off
= fix
->fx_frag
->fr_address
+ fix
->fx_where
;
10003 if (bfd_get_section_flags (stdoutput
, sec
) & SEC_CODE
)
10009 /* This is called whenever some data item (not an instruction) needs a
10010 fixup. We pick the right reloc code depending on the byteorder
10011 currently in effect. */
10013 ia64_cons_fix_new (f
, where
, nbytes
, exp
)
10019 bfd_reloc_code_real_type code
;
10024 /* There are no reloc for 8 and 16 bit quantities, but we allow
10025 them here since they will work fine as long as the expression
10026 is fully defined at the end of the pass over the source file. */
10027 case 1: code
= BFD_RELOC_8
; break;
10028 case 2: code
= BFD_RELOC_16
; break;
10030 if (target_big_endian
)
10031 code
= BFD_RELOC_IA64_DIR32MSB
;
10033 code
= BFD_RELOC_IA64_DIR32LSB
;
10037 /* In 32-bit mode, data8 could mean function descriptors too. */
10038 if (exp
->X_op
== O_pseudo_fixup
10039 && exp
->X_op_symbol
10040 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
10041 && !(md
.flags
& EF_IA_64_ABI64
))
10043 if (target_big_endian
)
10044 code
= BFD_RELOC_IA64_IPLTMSB
;
10046 code
= BFD_RELOC_IA64_IPLTLSB
;
10047 exp
->X_op
= O_symbol
;
10052 if (target_big_endian
)
10053 code
= BFD_RELOC_IA64_DIR64MSB
;
10055 code
= BFD_RELOC_IA64_DIR64LSB
;
10060 if (exp
->X_op
== O_pseudo_fixup
10061 && exp
->X_op_symbol
10062 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
)
10064 if (target_big_endian
)
10065 code
= BFD_RELOC_IA64_IPLTMSB
;
10067 code
= BFD_RELOC_IA64_IPLTLSB
;
10069 exp
->X_op
= O_symbol
;
10075 as_bad ("Unsupported fixup size %d", nbytes
);
10076 ignore_rest_of_line ();
10079 if (exp
->X_op
== O_pseudo_fixup
)
10082 exp
->X_op
= O_symbol
;
10083 code
= ia64_gen_real_reloc_type (exp
->X_op_symbol
, code
);
10086 fix
= fix_new_exp (f
, where
, nbytes
, exp
, 0, code
);
10087 /* We need to store the byte order in effect in case we're going
10088 to fix an 8 or 16 bit relocation (for which there no real
10089 relocs available). See md_apply_fix3(). */
10090 fix
->tc_fix_data
.bigendian
= target_big_endian
;
10093 /* Return the actual relocation we wish to associate with the pseudo
10094 reloc described by SYM and R_TYPE. SYM should be one of the
10095 symbols in the pseudo_func array, or NULL. */
10097 static bfd_reloc_code_real_type
10098 ia64_gen_real_reloc_type (sym
, r_type
)
10099 struct symbol
*sym
;
10100 bfd_reloc_code_real_type r_type
;
10102 bfd_reloc_code_real_type
new = 0;
10109 switch (S_GET_VALUE (sym
))
10111 case FUNC_FPTR_RELATIVE
:
10114 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_FPTR64I
; break;
10115 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_FPTR32MSB
; break;
10116 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_FPTR32LSB
; break;
10117 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_FPTR64MSB
; break;
10118 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_FPTR64LSB
; break;
10123 case FUNC_GP_RELATIVE
:
10126 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_GPREL22
; break;
10127 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_GPREL64I
; break;
10128 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_GPREL32MSB
; break;
10129 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_GPREL32LSB
; break;
10130 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_GPREL64MSB
; break;
10131 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_GPREL64LSB
; break;
10136 case FUNC_LT_RELATIVE
:
10139 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_LTOFF22
; break;
10140 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_LTOFF64I
; break;
10145 case FUNC_PC_RELATIVE
:
10148 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PCREL22
; break;
10149 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PCREL64I
; break;
10150 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_PCREL32MSB
; break;
10151 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_PCREL32LSB
; break;
10152 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PCREL64MSB
; break;
10153 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PCREL64LSB
; break;
10158 case FUNC_PLT_RELATIVE
:
10161 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PLTOFF22
; break;
10162 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PLTOFF64I
; break;
10163 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PLTOFF64MSB
;break;
10164 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PLTOFF64LSB
;break;
10169 case FUNC_SEC_RELATIVE
:
10172 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SECREL32MSB
;break;
10173 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SECREL32LSB
;break;
10174 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SECREL64MSB
;break;
10175 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SECREL64LSB
;break;
10180 case FUNC_SEG_RELATIVE
:
10183 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SEGREL32MSB
;break;
10184 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SEGREL32LSB
;break;
10185 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SEGREL64MSB
;break;
10186 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SEGREL64LSB
;break;
10191 case FUNC_LTV_RELATIVE
:
10194 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_LTV32MSB
; break;
10195 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_LTV32LSB
; break;
10196 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_LTV64MSB
; break;
10197 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_LTV64LSB
; break;
10202 case FUNC_LT_FPTR_RELATIVE
:
10205 case BFD_RELOC_IA64_IMM22
:
10206 new = BFD_RELOC_IA64_LTOFF_FPTR22
; break;
10207 case BFD_RELOC_IA64_IMM64
:
10208 new = BFD_RELOC_IA64_LTOFF_FPTR64I
; break;
10214 case FUNC_TP_RELATIVE
:
10217 case BFD_RELOC_IA64_IMM14
:
10218 new = BFD_RELOC_IA64_TPREL14
; break;
10219 case BFD_RELOC_IA64_IMM22
:
10220 new = BFD_RELOC_IA64_TPREL22
; break;
10221 case BFD_RELOC_IA64_IMM64
:
10222 new = BFD_RELOC_IA64_TPREL64I
; break;
10228 case FUNC_LT_TP_RELATIVE
:
10231 case BFD_RELOC_IA64_IMM22
:
10232 new = BFD_RELOC_IA64_LTOFF_TPREL22
; break;
10238 case FUNC_LT_DTP_MODULE
:
10241 case BFD_RELOC_IA64_IMM22
:
10242 new = BFD_RELOC_IA64_LTOFF_DTPMOD22
; break;
10248 case FUNC_DTP_RELATIVE
:
10251 case BFD_RELOC_IA64_IMM14
:
10252 new = BFD_RELOC_IA64_DTPREL14
; break;
10253 case BFD_RELOC_IA64_IMM22
:
10254 new = BFD_RELOC_IA64_DTPREL22
; break;
10255 case BFD_RELOC_IA64_IMM64
:
10256 new = BFD_RELOC_IA64_DTPREL64I
; break;
10262 case FUNC_LT_DTP_RELATIVE
:
10265 case BFD_RELOC_IA64_IMM22
:
10266 new = BFD_RELOC_IA64_LTOFF_DTPREL22
; break;
10272 case FUNC_IPLT_RELOC
:
10278 /* Hmmmm. Should this ever occur? */
10285 /* Here is where generate the appropriate reloc for pseudo relocation
10288 ia64_validate_fix (fix
)
10291 switch (fix
->fx_r_type
)
10293 case BFD_RELOC_IA64_FPTR64I
:
10294 case BFD_RELOC_IA64_FPTR32MSB
:
10295 case BFD_RELOC_IA64_FPTR64LSB
:
10296 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10297 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10298 if (fix
->fx_offset
!= 0)
10299 as_bad_where (fix
->fx_file
, fix
->fx_line
,
10300 "No addend allowed in @fptr() relocation");
10310 fix_insn (fix
, odesc
, value
)
10312 const struct ia64_operand
*odesc
;
10315 bfd_vma insn
[3], t0
, t1
, control_bits
;
10320 slot
= fix
->fx_where
& 0x3;
10321 fixpos
= fix
->fx_frag
->fr_literal
+ (fix
->fx_where
- slot
);
10323 /* Bundles are always in little-endian byte order */
10324 t0
= bfd_getl64 (fixpos
);
10325 t1
= bfd_getl64 (fixpos
+ 8);
10326 control_bits
= t0
& 0x1f;
10327 insn
[0] = (t0
>> 5) & 0x1ffffffffffLL
;
10328 insn
[1] = ((t0
>> 46) & 0x3ffff) | ((t1
& 0x7fffff) << 18);
10329 insn
[2] = (t1
>> 23) & 0x1ffffffffffLL
;
10332 if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU64
)
10334 insn
[1] = (value
>> 22) & 0x1ffffffffffLL
;
10335 insn
[2] |= (((value
& 0x7f) << 13)
10336 | (((value
>> 7) & 0x1ff) << 27)
10337 | (((value
>> 16) & 0x1f) << 22)
10338 | (((value
>> 21) & 0x1) << 21)
10339 | (((value
>> 63) & 0x1) << 36));
10341 else if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU62
)
10343 if (value
& ~0x3fffffffffffffffULL
)
10344 err
= "integer operand out of range";
10345 insn
[1] = (value
>> 21) & 0x1ffffffffffLL
;
10346 insn
[2] |= (((value
& 0xfffff) << 6) | (((value
>> 20) & 0x1) << 36));
10348 else if (odesc
- elf64_ia64_operands
== IA64_OPND_TGT64
)
10351 insn
[1] = ((value
>> 20) & 0x7fffffffffLL
) << 2;
10352 insn
[2] |= ((((value
>> 59) & 0x1) << 36)
10353 | (((value
>> 0) & 0xfffff) << 13));
10356 err
= (*odesc
->insert
) (odesc
, value
, insn
+ slot
);
10359 as_bad_where (fix
->fx_file
, fix
->fx_line
, err
);
10361 t0
= control_bits
| (insn
[0] << 5) | (insn
[1] << 46);
10362 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
10363 number_to_chars_littleendian (fixpos
+ 0, t0
, 8);
10364 number_to_chars_littleendian (fixpos
+ 8, t1
, 8);
10367 /* Attempt to simplify or even eliminate a fixup. The return value is
10368 ignored; perhaps it was once meaningful, but now it is historical.
10369 To indicate that a fixup has been eliminated, set FIXP->FX_DONE.
10371 If fixp->fx_addsy is non-NULL, we'll have to generate a reloc entry
10375 md_apply_fix3 (fix
, valP
, seg
)
10378 segT seg ATTRIBUTE_UNUSED
;
10381 valueT value
= *valP
;
10384 fixpos
= fix
->fx_frag
->fr_literal
+ fix
->fx_where
;
10388 switch (fix
->fx_r_type
)
10390 case BFD_RELOC_IA64_DIR32MSB
:
10391 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL32MSB
;
10395 case BFD_RELOC_IA64_DIR32LSB
:
10396 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL32LSB
;
10400 case BFD_RELOC_IA64_DIR64MSB
:
10401 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL64MSB
;
10405 case BFD_RELOC_IA64_DIR64LSB
:
10406 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL64LSB
;
10416 if (fix
->fx_r_type
== (int) BFD_RELOC_UNUSED
)
10418 /* This must be a TAG13 or TAG13b operand. There are no external
10419 relocs defined for them, so we must give an error. */
10420 as_bad_where (fix
->fx_file
, fix
->fx_line
,
10421 "%s must have a constant value",
10422 elf64_ia64_operands
[fix
->tc_fix_data
.opnd
].desc
);
10427 /* ??? This is a hack copied from tc-i386.c to make PCREL relocs
10428 work. There should be a better way to handle this. */
10430 fix
->fx_offset
+= fix
->fx_where
+ fix
->fx_frag
->fr_address
;
10432 else if (fix
->tc_fix_data
.opnd
== IA64_OPND_NIL
)
10434 if (fix
->tc_fix_data
.bigendian
)
10435 number_to_chars_bigendian (fixpos
, value
, fix
->fx_size
);
10437 number_to_chars_littleendian (fixpos
, value
, fix
->fx_size
);
10442 fix_insn (fix
, elf64_ia64_operands
+ fix
->tc_fix_data
.opnd
, value
);
10447 /* Generate the BFD reloc to be stuck in the object file from the
10448 fixup used internally in the assembler. */
10451 tc_gen_reloc (sec
, fixp
)
10452 asection
*sec ATTRIBUTE_UNUSED
;
10457 reloc
= xmalloc (sizeof (*reloc
));
10458 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
10459 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
10460 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
10461 reloc
->addend
= fixp
->fx_offset
;
10462 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
10466 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
10467 "Cannot represent %s relocation in object file",
10468 bfd_get_reloc_code_name (fixp
->fx_r_type
));
10473 /* Turn a string in input_line_pointer into a floating point constant
10474 of type TYPE, and store the appropriate bytes in *LIT. The number
10475 of LITTLENUMS emitted is stored in *SIZE. An error message is
10476 returned, or NULL on OK. */
10478 #define MAX_LITTLENUMS 5
10481 md_atof (type
, lit
, size
)
10486 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
10487 LITTLENUM_TYPE
*word
;
10517 return "Bad call to MD_ATOF()";
10519 t
= atof_ieee (input_line_pointer
, type
, words
);
10521 input_line_pointer
= t
;
10522 *size
= prec
* sizeof (LITTLENUM_TYPE
);
10524 for (word
= words
+ prec
- 1; prec
--;)
10526 md_number_to_chars (lit
, (long) (*word
--), sizeof (LITTLENUM_TYPE
));
10527 lit
+= sizeof (LITTLENUM_TYPE
);
10532 /* Round up a section's size to the appropriate boundary. */
10534 md_section_align (seg
, size
)
10538 int align
= bfd_get_section_alignment (stdoutput
, seg
);
10539 valueT mask
= ((valueT
) 1 << align
) - 1;
10541 return (size
+ mask
) & ~mask
;
10544 /* Handle ia64 specific semantics of the align directive. */
10547 ia64_md_do_align (n
, fill
, len
, max
)
10548 int n ATTRIBUTE_UNUSED
;
10549 const char *fill ATTRIBUTE_UNUSED
;
10550 int len ATTRIBUTE_UNUSED
;
10551 int max ATTRIBUTE_UNUSED
;
10553 if (subseg_text_p (now_seg
))
10554 ia64_flush_insns ();
10557 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
10558 of an rs_align_code fragment. */
10561 ia64_handle_align (fragp
)
10564 /* Use mfi bundle of nops with no stop bits. */
10565 static const unsigned char be_nop
[]
10566 = { 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
10567 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c};
10568 static const unsigned char le_nop
[]
10569 = { 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
10570 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00};
10575 if (fragp
->fr_type
!= rs_align_code
)
10578 bytes
= fragp
->fr_next
->fr_address
- fragp
->fr_address
- fragp
->fr_fix
;
10579 p
= fragp
->fr_literal
+ fragp
->fr_fix
;
10581 /* Make sure we are on a 16-byte boundary, in case someone has been
10582 putting data into a text section. */
10585 int fix
= bytes
& 15;
10586 memset (p
, 0, fix
);
10589 fragp
->fr_fix
+= fix
;
10592 memcpy (p
, (target_big_endian
? be_nop
: le_nop
), 16);
10593 fragp
->fr_var
= 16;