1 /* tc-ia64.c -- Assembler for the HP/Intel IA-64 architecture.
2 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
3 Free Software Foundation, Inc.
4 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
6 This file is part of GAS, the GNU Assembler.
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GAS is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GAS; see the file COPYING. If not, write to
20 the Free Software Foundation, 51 Franklin Street - Fifth Floor,
21 Boston, MA 02110-1301, USA. */
35 - labels are wrong if automatic alignment is introduced
36 (e.g., checkout the second real10 definition in test-data.s)
38 <reg>.safe_across_calls and any other DV-related directives I don't
39 have documentation for.
40 verify mod-sched-brs reads/writes are checked/marked (and other
46 #include "safe-ctype.h"
47 #include "dwarf2dbg.h"
50 #include "opcode/ia64.h"
58 #define NELEMS(a) ((int) (sizeof (a)/sizeof ((a)[0])))
60 /* Some systems define MIN in, e.g., param.h. */
62 #define MIN(a,b) ((a) < (b) ? (a) : (b))
65 #define PREV_SLOT md.slot[(md.curr_slot + NUM_SLOTS - 1) % NUM_SLOTS]
66 #define CURR_SLOT md.slot[md.curr_slot]
68 #define O_pseudo_fixup (O_max + 1)
72 /* IA-64 ABI section pseudo-ops. */
73 SPECIAL_SECTION_BSS
= 0,
75 SPECIAL_SECTION_SDATA
,
76 SPECIAL_SECTION_RODATA
,
77 SPECIAL_SECTION_COMMENT
,
78 SPECIAL_SECTION_UNWIND
,
79 SPECIAL_SECTION_UNWIND_INFO
,
80 /* HPUX specific section pseudo-ops. */
81 SPECIAL_SECTION_INIT_ARRAY
,
82 SPECIAL_SECTION_FINI_ARRAY
,
99 FUNC_LT_FPTR_RELATIVE
,
101 FUNC_LT_DTP_RELATIVE
,
109 REG_FR
= (REG_GR
+ 128),
110 REG_AR
= (REG_FR
+ 128),
111 REG_CR
= (REG_AR
+ 128),
112 REG_P
= (REG_CR
+ 128),
113 REG_BR
= (REG_P
+ 64),
114 REG_IP
= (REG_BR
+ 8),
121 /* The following are pseudo-registers for use by gas only. */
132 /* The following pseudo-registers are used for unwind directives only: */
140 DYNREG_GR
= 0, /* dynamic general purpose register */
141 DYNREG_FR
, /* dynamic floating point register */
142 DYNREG_PR
, /* dynamic predicate register */
146 enum operand_match_result
149 OPERAND_OUT_OF_RANGE
,
153 /* On the ia64, we can't know the address of a text label until the
154 instructions are packed into a bundle. To handle this, we keep
155 track of the list of labels that appear in front of each
159 struct label_fix
*next
;
161 bfd_boolean dw2_mark_labels
;
164 /* This is the endianness of the current section. */
165 extern int target_big_endian
;
167 /* This is the default endianness. */
168 static int default_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
170 void (*ia64_number_to_chars
) (char *, valueT
, int);
172 static void ia64_float_to_chars_bigendian (char *, LITTLENUM_TYPE
*, int);
173 static void ia64_float_to_chars_littleendian (char *, LITTLENUM_TYPE
*, int);
175 static void (*ia64_float_to_chars
) (char *, LITTLENUM_TYPE
*, int);
177 static struct hash_control
*alias_hash
;
178 static struct hash_control
*alias_name_hash
;
179 static struct hash_control
*secalias_hash
;
180 static struct hash_control
*secalias_name_hash
;
182 /* List of chars besides those in app.c:symbol_chars that can start an
183 operand. Used to prevent the scrubber eating vital white-space. */
184 const char ia64_symbol_chars
[] = "@?";
186 /* Characters which always start a comment. */
187 const char comment_chars
[] = "";
189 /* Characters which start a comment at the beginning of a line. */
190 const char line_comment_chars
[] = "#";
192 /* Characters which may be used to separate multiple commands on a
194 const char line_separator_chars
[] = ";{}";
196 /* Characters which are used to indicate an exponent in a floating
198 const char EXP_CHARS
[] = "eE";
200 /* Characters which mean that a number is a floating point constant,
202 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
204 /* ia64-specific option processing: */
206 const char *md_shortopts
= "m:N:x::";
208 struct option md_longopts
[] =
210 #define OPTION_MCONSTANT_GP (OPTION_MD_BASE + 1)
211 {"mconstant-gp", no_argument
, NULL
, OPTION_MCONSTANT_GP
},
212 #define OPTION_MAUTO_PIC (OPTION_MD_BASE + 2)
213 {"mauto-pic", no_argument
, NULL
, OPTION_MAUTO_PIC
}
216 size_t md_longopts_size
= sizeof (md_longopts
);
220 struct hash_control
*pseudo_hash
; /* pseudo opcode hash table */
221 struct hash_control
*reg_hash
; /* register name hash table */
222 struct hash_control
*dynreg_hash
; /* dynamic register hash table */
223 struct hash_control
*const_hash
; /* constant hash table */
224 struct hash_control
*entry_hash
; /* code entry hint hash table */
226 /* If X_op is != O_absent, the registername for the instruction's
227 qualifying predicate. If NULL, p0 is assumed for instructions
228 that are predictable. */
231 /* Optimize for which CPU. */
238 /* What to do when hint.b is used. */
250 explicit_mode
: 1, /* which mode we're in */
251 default_explicit_mode
: 1, /* which mode is the default */
252 mode_explicitly_set
: 1, /* was the current mode explicitly set? */
254 keep_pending_output
: 1;
256 /* What to do when something is wrong with unwind directives. */
259 unwind_check_warning
,
263 /* Each bundle consists of up to three instructions. We keep
264 track of four most recent instructions so we can correctly set
265 the end_of_insn_group for the last instruction in a bundle. */
267 int num_slots_in_use
;
271 end_of_insn_group
: 1,
272 manual_bundling_on
: 1,
273 manual_bundling_off
: 1,
274 loc_directive_seen
: 1;
275 signed char user_template
; /* user-selected template, if any */
276 unsigned char qp_regno
; /* qualifying predicate */
277 /* This duplicates a good fraction of "struct fix" but we
278 can't use a "struct fix" instead since we can't call
279 fix_new_exp() until we know the address of the instruction. */
283 bfd_reloc_code_real_type code
;
284 enum ia64_opnd opnd
; /* type of operand in need of fix */
285 unsigned int is_pcrel
: 1; /* is operand pc-relative? */
286 expressionS expr
; /* the value to be inserted */
288 fixup
[2]; /* at most two fixups per insn */
289 struct ia64_opcode
*idesc
;
290 struct label_fix
*label_fixups
;
291 struct label_fix
*tag_fixups
;
292 struct unw_rec_list
*unwind_record
; /* Unwind directive. */
295 unsigned int src_line
;
296 struct dwarf2_line_info debug_line
;
304 struct dynreg
*next
; /* next dynamic register */
306 unsigned short base
; /* the base register number */
307 unsigned short num_regs
; /* # of registers in this set */
309 *dynreg
[DYNREG_NUM_TYPES
], in
, loc
, out
, rot
;
311 flagword flags
; /* ELF-header flags */
314 unsigned hint
:1; /* is this hint currently valid? */
315 bfd_vma offset
; /* mem.offset offset */
316 bfd_vma base
; /* mem.offset base */
319 int path
; /* number of alt. entry points seen */
320 const char **entry_labels
; /* labels of all alternate paths in
321 the current DV-checking block. */
322 int maxpaths
; /* size currently allocated for
325 int pointer_size
; /* size in bytes of a pointer */
326 int pointer_size_shift
; /* shift size of a pointer for alignment */
328 symbolS
*indregsym
[IND_RR
- IND_CPUID
+ 1];
332 /* These are not const, because they are modified to MMI for non-itanium1
334 /* MFI bundle of nops. */
335 static unsigned char le_nop
[16] =
337 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
338 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00
340 /* MFI bundle of nops with stop-bit. */
341 static unsigned char le_nop_stop
[16] =
343 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
344 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00
347 /* application registers: */
353 #define AR_BSPSTORE 18
379 {"ar.k0", AR_K0
}, {"ar.k1", AR_K0
+ 1},
380 {"ar.k2", AR_K0
+ 2}, {"ar.k3", AR_K0
+ 3},
381 {"ar.k4", AR_K0
+ 4}, {"ar.k5", AR_K0
+ 5},
382 {"ar.k6", AR_K0
+ 6}, {"ar.k7", AR_K7
},
383 {"ar.rsc", AR_RSC
}, {"ar.bsp", AR_BSP
},
384 {"ar.bspstore", AR_BSPSTORE
}, {"ar.rnat", AR_RNAT
},
385 {"ar.fcr", AR_FCR
}, {"ar.eflag", AR_EFLAG
},
386 {"ar.csd", AR_CSD
}, {"ar.ssd", AR_SSD
},
387 {"ar.cflg", AR_CFLG
}, {"ar.fsr", AR_FSR
},
388 {"ar.fir", AR_FIR
}, {"ar.fdr", AR_FDR
},
389 {"ar.ccv", AR_CCV
}, {"ar.unat", AR_UNAT
},
390 {"ar.fpsr", AR_FPSR
}, {"ar.itc", AR_ITC
},
391 {"ar.ruc", AR_RUC
}, {"ar.pfs", AR_PFS
},
392 {"ar.lc", AR_LC
}, {"ar.ec", AR_EC
},
395 /* control registers: */
434 {"cr.gpta", CR_GPTA
},
435 {"cr.ipsr", CR_IPSR
},
439 {"cr.itir", CR_ITIR
},
440 {"cr.iipa", CR_IIPA
},
448 {"cr.irr0", CR_IRR0
},
449 {"cr.irr1", CR_IRR0
+ 1},
450 {"cr.irr2", CR_IRR0
+ 2},
451 {"cr.irr3", CR_IRR3
},
454 {"cr.cmcv", CR_CMCV
},
455 {"cr.lrr0", CR_LRR0
},
464 static const struct const_desc
471 /* PSR constant masks: */
474 {"psr.be", ((valueT
) 1) << 1},
475 {"psr.up", ((valueT
) 1) << 2},
476 {"psr.ac", ((valueT
) 1) << 3},
477 {"psr.mfl", ((valueT
) 1) << 4},
478 {"psr.mfh", ((valueT
) 1) << 5},
480 {"psr.ic", ((valueT
) 1) << 13},
481 {"psr.i", ((valueT
) 1) << 14},
482 {"psr.pk", ((valueT
) 1) << 15},
484 {"psr.dt", ((valueT
) 1) << 17},
485 {"psr.dfl", ((valueT
) 1) << 18},
486 {"psr.dfh", ((valueT
) 1) << 19},
487 {"psr.sp", ((valueT
) 1) << 20},
488 {"psr.pp", ((valueT
) 1) << 21},
489 {"psr.di", ((valueT
) 1) << 22},
490 {"psr.si", ((valueT
) 1) << 23},
491 {"psr.db", ((valueT
) 1) << 24},
492 {"psr.lp", ((valueT
) 1) << 25},
493 {"psr.tb", ((valueT
) 1) << 26},
494 {"psr.rt", ((valueT
) 1) << 27},
495 /* 28-31: reserved */
496 /* 32-33: cpl (current privilege level) */
497 {"psr.is", ((valueT
) 1) << 34},
498 {"psr.mc", ((valueT
) 1) << 35},
499 {"psr.it", ((valueT
) 1) << 36},
500 {"psr.id", ((valueT
) 1) << 37},
501 {"psr.da", ((valueT
) 1) << 38},
502 {"psr.dd", ((valueT
) 1) << 39},
503 {"psr.ss", ((valueT
) 1) << 40},
504 /* 41-42: ri (restart instruction) */
505 {"psr.ed", ((valueT
) 1) << 43},
506 {"psr.bn", ((valueT
) 1) << 44},
509 /* indirect register-sets/memory: */
518 { "CPUID", IND_CPUID
},
519 { "cpuid", IND_CPUID
},
531 /* Pseudo functions used to indicate relocation types (these functions
532 start with an at sign (@). */
554 /* reloc pseudo functions (these must come first!): */
555 { "dtpmod", PSEUDO_FUNC_RELOC
, { 0 } },
556 { "dtprel", PSEUDO_FUNC_RELOC
, { 0 } },
557 { "fptr", PSEUDO_FUNC_RELOC
, { 0 } },
558 { "gprel", PSEUDO_FUNC_RELOC
, { 0 } },
559 { "ltoff", PSEUDO_FUNC_RELOC
, { 0 } },
560 { "ltoffx", PSEUDO_FUNC_RELOC
, { 0 } },
561 { "pcrel", PSEUDO_FUNC_RELOC
, { 0 } },
562 { "pltoff", PSEUDO_FUNC_RELOC
, { 0 } },
563 { "secrel", PSEUDO_FUNC_RELOC
, { 0 } },
564 { "segrel", PSEUDO_FUNC_RELOC
, { 0 } },
565 { "tprel", PSEUDO_FUNC_RELOC
, { 0 } },
566 { "ltv", PSEUDO_FUNC_RELOC
, { 0 } },
567 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_FPTR_RELATIVE */
568 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_DTP_MODULE */
569 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_DTP_RELATIVE */
570 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_TP_RELATIVE */
571 { "iplt", PSEUDO_FUNC_RELOC
, { 0 } },
573 /* mbtype4 constants: */
574 { "alt", PSEUDO_FUNC_CONST
, { 0xa } },
575 { "brcst", PSEUDO_FUNC_CONST
, { 0x0 } },
576 { "mix", PSEUDO_FUNC_CONST
, { 0x8 } },
577 { "rev", PSEUDO_FUNC_CONST
, { 0xb } },
578 { "shuf", PSEUDO_FUNC_CONST
, { 0x9 } },
580 /* fclass constants: */
581 { "nat", PSEUDO_FUNC_CONST
, { 0x100 } },
582 { "qnan", PSEUDO_FUNC_CONST
, { 0x080 } },
583 { "snan", PSEUDO_FUNC_CONST
, { 0x040 } },
584 { "pos", PSEUDO_FUNC_CONST
, { 0x001 } },
585 { "neg", PSEUDO_FUNC_CONST
, { 0x002 } },
586 { "zero", PSEUDO_FUNC_CONST
, { 0x004 } },
587 { "unorm", PSEUDO_FUNC_CONST
, { 0x008 } },
588 { "norm", PSEUDO_FUNC_CONST
, { 0x010 } },
589 { "inf", PSEUDO_FUNC_CONST
, { 0x020 } },
591 { "natval", PSEUDO_FUNC_CONST
, { 0x100 } }, /* old usage */
593 /* hint constants: */
594 { "pause", PSEUDO_FUNC_CONST
, { 0x0 } },
596 /* unwind-related constants: */
597 { "svr4", PSEUDO_FUNC_CONST
, { ELFOSABI_NONE
} },
598 { "hpux", PSEUDO_FUNC_CONST
, { ELFOSABI_HPUX
} },
599 { "nt", PSEUDO_FUNC_CONST
, { 2 } }, /* conflicts w/ELFOSABI_NETBSD */
600 { "linux", PSEUDO_FUNC_CONST
, { ELFOSABI_LINUX
} },
601 { "freebsd", PSEUDO_FUNC_CONST
, { ELFOSABI_FREEBSD
} },
602 { "openvms", PSEUDO_FUNC_CONST
, { ELFOSABI_OPENVMS
} },
603 { "nsk", PSEUDO_FUNC_CONST
, { ELFOSABI_NSK
} },
605 /* unwind-related registers: */
606 { "priunat",PSEUDO_FUNC_REG
, { REG_PRIUNAT
} }
609 /* 41-bit nop opcodes (one per unit): */
610 static const bfd_vma nop
[IA64_NUM_UNITS
] =
612 0x0000000000LL
, /* NIL => break 0 */
613 0x0008000000LL
, /* I-unit nop */
614 0x0008000000LL
, /* M-unit nop */
615 0x4000000000LL
, /* B-unit nop */
616 0x0008000000LL
, /* F-unit nop */
617 0x0000000000LL
, /* L-"unit" nop immediate */
618 0x0008000000LL
, /* X-unit nop */
621 /* Can't be `const' as it's passed to input routines (which have the
622 habit of setting temporary sentinels. */
623 static char special_section_name
[][20] =
625 {".bss"}, {".sbss"}, {".sdata"}, {".rodata"}, {".comment"},
626 {".IA_64.unwind"}, {".IA_64.unwind_info"},
627 {".init_array"}, {".fini_array"}
630 /* The best template for a particular sequence of up to three
632 #define N IA64_NUM_TYPES
633 static unsigned char best_template
[N
][N
][N
];
636 /* Resource dependencies currently in effect */
638 int depind
; /* dependency index */
639 const struct ia64_dependency
*dependency
; /* actual dependency */
640 unsigned specific
:1, /* is this a specific bit/regno? */
641 link_to_qp_branch
:1; /* will a branch on the same QP clear it?*/
642 int index
; /* specific regno/bit within dependency */
643 int note
; /* optional qualifying note (0 if none) */
647 int insn_srlz
; /* current insn serialization state */
648 int data_srlz
; /* current data serialization state */
649 int qp_regno
; /* qualifying predicate for this usage */
650 char *file
; /* what file marked this dependency */
651 unsigned int line
; /* what line marked this dependency */
652 struct mem_offset mem_offset
; /* optional memory offset hint */
653 enum { CMP_NONE
, CMP_OR
, CMP_AND
} cmp_type
; /* OR or AND compare? */
654 int path
; /* corresponding code entry index */
656 static int regdepslen
= 0;
657 static int regdepstotlen
= 0;
658 static const char *dv_mode
[] = { "RAW", "WAW", "WAR" };
659 static const char *dv_sem
[] = { "none", "implied", "impliedf",
660 "data", "instr", "specific", "stop", "other" };
661 static const char *dv_cmp_type
[] = { "none", "OR", "AND" };
663 /* Current state of PR mutexation */
664 static struct qpmutex
{
667 } *qp_mutexes
= NULL
; /* QP mutex bitmasks */
668 static int qp_mutexeslen
= 0;
669 static int qp_mutexestotlen
= 0;
670 static valueT qp_safe_across_calls
= 0;
672 /* Current state of PR implications */
673 static struct qp_imply
{
676 unsigned p2_branched
:1;
678 } *qp_implies
= NULL
;
679 static int qp_implieslen
= 0;
680 static int qp_impliestotlen
= 0;
682 /* Keep track of static GR values so that indirect register usage can
683 sometimes be tracked. */
694 (((1 << (8 * sizeof(gr_values
->path
) - 2)) - 1) << 1) + 1,
700 /* Remember the alignment frag. */
701 static fragS
*align_frag
;
703 /* These are the routines required to output the various types of
706 /* A slot_number is a frag address plus the slot index (0-2). We use the
707 frag address here so that if there is a section switch in the middle of
708 a function, then instructions emitted to a different section are not
709 counted. Since there may be more than one frag for a function, this
710 means we also need to keep track of which frag this address belongs to
711 so we can compute inter-frag distances. This also nicely solves the
712 problem with nops emitted for align directives, which can't easily be
713 counted, but can easily be derived from frag sizes. */
715 typedef struct unw_rec_list
{
717 unsigned long slot_number
;
719 struct unw_rec_list
*next
;
722 #define SLOT_NUM_NOT_SET (unsigned)-1
724 /* Linked list of saved prologue counts. A very poor
725 implementation of a map from label numbers to prologue counts. */
726 typedef struct label_prologue_count
728 struct label_prologue_count
*next
;
729 unsigned long label_number
;
730 unsigned int prologue_count
;
731 } label_prologue_count
;
733 typedef struct proc_pending
736 struct proc_pending
*next
;
741 /* Maintain a list of unwind entries for the current function. */
745 /* Any unwind entries that should be attached to the current slot
746 that an insn is being constructed for. */
747 unw_rec_list
*current_entry
;
749 /* These are used to create the unwind table entry for this function. */
750 proc_pending proc_pending
;
751 symbolS
*info
; /* pointer to unwind info */
752 symbolS
*personality_routine
;
754 subsegT saved_text_subseg
;
755 unsigned int force_unwind_entry
: 1; /* force generation of unwind entry? */
757 /* TRUE if processing unwind directives in a prologue region. */
758 unsigned int prologue
: 1;
759 unsigned int prologue_mask
: 4;
760 unsigned int prologue_gr
: 7;
761 unsigned int body
: 1;
762 unsigned int insn
: 1;
763 unsigned int prologue_count
; /* number of .prologues seen so far */
764 /* Prologue counts at previous .label_state directives. */
765 struct label_prologue_count
* saved_prologue_counts
;
767 /* List of split up .save-s. */
768 unw_p_record
*pending_saves
;
771 /* The input value is a negated offset from psp, and specifies an address
772 psp - offset. The encoded value is psp + 16 - (4 * offset). Thus we
773 must add 16 and divide by 4 to get the encoded value. */
775 #define ENCODED_PSP_OFFSET(OFFSET) (((OFFSET) + 16) / 4)
777 typedef void (*vbyte_func
) (int, char *, char *);
779 /* Forward declarations: */
780 static void dot_alias (int);
781 static int parse_operand (expressionS
*, int);
782 static void emit_one_bundle (void);
783 static bfd_reloc_code_real_type
ia64_gen_real_reloc_type (struct symbol
*,
784 bfd_reloc_code_real_type
);
785 static void insn_group_break (int, int, int);
786 static void add_qp_mutex (valueT
);
787 static void add_qp_imply (int, int);
788 static void clear_qp_mutex (valueT
);
789 static void clear_qp_implies (valueT
, valueT
);
790 static void print_dependency (const char *, int);
791 static void instruction_serialization (void);
792 static void data_serialization (void);
793 static void output_R3_format (vbyte_func
, unw_record_type
, unsigned long);
794 static void output_B3_format (vbyte_func
, unsigned long, unsigned long);
795 static void output_B4_format (vbyte_func
, unw_record_type
, unsigned long);
796 static void free_saved_prologue_counts (void);
798 /* Determine if application register REGNUM resides only in the integer
799 unit (as opposed to the memory unit). */
801 ar_is_only_in_integer_unit (int reg
)
804 return reg
>= 64 && reg
<= 111;
807 /* Determine if application register REGNUM resides only in the memory
808 unit (as opposed to the integer unit). */
810 ar_is_only_in_memory_unit (int reg
)
813 return reg
>= 0 && reg
<= 47;
816 /* Switch to section NAME and create section if necessary. It's
817 rather ugly that we have to manipulate input_line_pointer but I
818 don't see any other way to accomplish the same thing without
819 changing obj-elf.c (which may be the Right Thing, in the end). */
821 set_section (char *name
)
823 char *saved_input_line_pointer
;
825 saved_input_line_pointer
= input_line_pointer
;
826 input_line_pointer
= name
;
828 input_line_pointer
= saved_input_line_pointer
;
831 /* Map 's' to SHF_IA_64_SHORT. */
834 ia64_elf_section_letter (int letter
, char **ptr_msg
)
837 return SHF_IA_64_SHORT
;
838 else if (letter
== 'o')
839 return SHF_LINK_ORDER
;
841 *ptr_msg
= _("Bad .section directive: want a,o,s,w,x,M,S,G,T in string");
845 /* Map SHF_IA_64_SHORT to SEC_SMALL_DATA. */
848 ia64_elf_section_flags (flagword flags
,
850 int type ATTRIBUTE_UNUSED
)
852 if (attr
& SHF_IA_64_SHORT
)
853 flags
|= SEC_SMALL_DATA
;
858 ia64_elf_section_type (const char *str
, size_t len
)
860 #define STREQ(s) ((len == sizeof (s) - 1) && (strncmp (str, s, sizeof (s) - 1) == 0))
862 if (STREQ (ELF_STRING_ia64_unwind_info
))
865 if (STREQ (ELF_STRING_ia64_unwind_info_once
))
868 if (STREQ (ELF_STRING_ia64_unwind
))
869 return SHT_IA_64_UNWIND
;
871 if (STREQ (ELF_STRING_ia64_unwind_once
))
872 return SHT_IA_64_UNWIND
;
874 if (STREQ ("unwind"))
875 return SHT_IA_64_UNWIND
;
882 set_regstack (unsigned int ins
,
890 sof
= ins
+ locs
+ outs
;
893 as_bad (_("Size of frame exceeds maximum of 96 registers"));
898 as_warn (_("Size of rotating registers exceeds frame size"));
901 md
.in
.base
= REG_GR
+ 32;
902 md
.loc
.base
= md
.in
.base
+ ins
;
903 md
.out
.base
= md
.loc
.base
+ locs
;
905 md
.in
.num_regs
= ins
;
906 md
.loc
.num_regs
= locs
;
907 md
.out
.num_regs
= outs
;
908 md
.rot
.num_regs
= rots
;
913 ia64_flush_insns (void)
915 struct label_fix
*lfix
;
917 subsegT saved_subseg
;
921 if (!md
.last_text_seg
)
925 saved_subseg
= now_subseg
;
927 subseg_set (md
.last_text_seg
, 0);
929 while (md
.num_slots_in_use
> 0)
930 emit_one_bundle (); /* force out queued instructions */
932 /* In case there are labels following the last instruction, resolve
935 for (lfix
= CURR_SLOT
.label_fixups
; lfix
; lfix
= lfix
->next
)
937 symbol_set_value_now (lfix
->sym
);
938 mark
|= lfix
->dw2_mark_labels
;
942 dwarf2_where (&CURR_SLOT
.debug_line
);
943 CURR_SLOT
.debug_line
.flags
|= DWARF2_FLAG_BASIC_BLOCK
;
944 dwarf2_gen_line_info (frag_now_fix (), &CURR_SLOT
.debug_line
);
945 dwarf2_consume_line_info ();
947 CURR_SLOT
.label_fixups
= 0;
949 for (lfix
= CURR_SLOT
.tag_fixups
; lfix
; lfix
= lfix
->next
)
950 symbol_set_value_now (lfix
->sym
);
951 CURR_SLOT
.tag_fixups
= 0;
953 /* In case there are unwind directives following the last instruction,
954 resolve those now. We only handle prologue, body, and endp directives
955 here. Give an error for others. */
956 for (ptr
= unwind
.current_entry
; ptr
; ptr
= ptr
->next
)
964 ptr
->slot_number
= (unsigned long) frag_more (0);
965 ptr
->slot_frag
= frag_now
;
968 /* Allow any record which doesn't have a "t" field (i.e.,
969 doesn't relate to a particular instruction). */
985 as_bad (_("Unwind directive not followed by an instruction."));
989 unwind
.current_entry
= NULL
;
991 subseg_set (saved_seg
, saved_subseg
);
993 if (md
.qp
.X_op
== O_register
)
994 as_bad (_("qualifying predicate not followed by instruction"));
998 ia64_do_align (int nbytes
)
1000 char *saved_input_line_pointer
= input_line_pointer
;
1002 input_line_pointer
= "";
1003 s_align_bytes (nbytes
);
1004 input_line_pointer
= saved_input_line_pointer
;
1008 ia64_cons_align (int nbytes
)
1012 char *saved_input_line_pointer
= input_line_pointer
;
1013 input_line_pointer
= "";
1014 s_align_bytes (nbytes
);
1015 input_line_pointer
= saved_input_line_pointer
;
1019 /* Output COUNT bytes to a memory location. */
1020 static char *vbyte_mem_ptr
= NULL
;
1023 output_vbyte_mem (int count
, char *ptr
, char *comment ATTRIBUTE_UNUSED
)
1026 if (vbyte_mem_ptr
== NULL
)
1031 for (x
= 0; x
< count
; x
++)
1032 *(vbyte_mem_ptr
++) = ptr
[x
];
1035 /* Count the number of bytes required for records. */
1036 static int vbyte_count
= 0;
1038 count_output (int count
,
1039 char *ptr ATTRIBUTE_UNUSED
,
1040 char *comment ATTRIBUTE_UNUSED
)
1042 vbyte_count
+= count
;
1046 output_R1_format (vbyte_func f
, unw_record_type rtype
, int rlen
)
1052 output_R3_format (f
, rtype
, rlen
);
1058 else if (rtype
!= prologue
)
1059 as_bad (_("record type is not valid"));
1061 byte
= UNW_R1
| (r
<< 5) | (rlen
& 0x1f);
1062 (*f
) (1, &byte
, NULL
);
1066 output_R2_format (vbyte_func f
, int mask
, int grsave
, unsigned long rlen
)
1070 mask
= (mask
& 0x0f);
1071 grsave
= (grsave
& 0x7f);
1073 bytes
[0] = (UNW_R2
| (mask
>> 1));
1074 bytes
[1] = (((mask
& 0x01) << 7) | grsave
);
1075 count
+= output_leb128 (bytes
+ 2, rlen
, 0);
1076 (*f
) (count
, bytes
, NULL
);
1080 output_R3_format (vbyte_func f
, unw_record_type rtype
, unsigned long rlen
)
1086 output_R1_format (f
, rtype
, rlen
);
1092 else if (rtype
!= prologue
)
1093 as_bad (_("record type is not valid"));
1094 bytes
[0] = (UNW_R3
| r
);
1095 count
= output_leb128 (bytes
+ 1, rlen
, 0);
1096 (*f
) (count
+ 1, bytes
, NULL
);
1100 output_P1_format (vbyte_func f
, int brmask
)
1103 byte
= UNW_P1
| (brmask
& 0x1f);
1104 (*f
) (1, &byte
, NULL
);
1108 output_P2_format (vbyte_func f
, int brmask
, int gr
)
1111 brmask
= (brmask
& 0x1f);
1112 bytes
[0] = UNW_P2
| (brmask
>> 1);
1113 bytes
[1] = (((brmask
& 1) << 7) | gr
);
1114 (*f
) (2, bytes
, NULL
);
1118 output_P3_format (vbyte_func f
, unw_record_type rtype
, int reg
)
1162 as_bad (_("Invalid record type for P3 format."));
1164 bytes
[0] = (UNW_P3
| (r
>> 1));
1165 bytes
[1] = (((r
& 1) << 7) | reg
);
1166 (*f
) (2, bytes
, NULL
);
1170 output_P4_format (vbyte_func f
, unsigned char *imask
, unsigned long imask_size
)
1173 (*f
) (imask_size
, (char *) imask
, NULL
);
1177 output_P5_format (vbyte_func f
, int grmask
, unsigned long frmask
)
1180 grmask
= (grmask
& 0x0f);
1183 bytes
[1] = ((grmask
<< 4) | ((frmask
& 0x000f0000) >> 16));
1184 bytes
[2] = ((frmask
& 0x0000ff00) >> 8);
1185 bytes
[3] = (frmask
& 0x000000ff);
1186 (*f
) (4, bytes
, NULL
);
1190 output_P6_format (vbyte_func f
, unw_record_type rtype
, int rmask
)
1195 if (rtype
== gr_mem
)
1197 else if (rtype
!= fr_mem
)
1198 as_bad (_("Invalid record type for format P6"));
1199 byte
= (UNW_P6
| (r
<< 4) | (rmask
& 0x0f));
1200 (*f
) (1, &byte
, NULL
);
1204 output_P7_format (vbyte_func f
,
1205 unw_record_type rtype
,
1212 count
+= output_leb128 (bytes
+ 1, w1
, 0);
1217 count
+= output_leb128 (bytes
+ count
, w2
>> 4, 0);
1267 bytes
[0] = (UNW_P7
| r
);
1268 (*f
) (count
, bytes
, NULL
);
1272 output_P8_format (vbyte_func f
, unw_record_type rtype
, unsigned long t
)
1310 case bspstore_psprel
:
1313 case bspstore_sprel
:
1325 case priunat_when_gr
:
1328 case priunat_psprel
:
1334 case priunat_when_mem
:
1341 count
+= output_leb128 (bytes
+ 2, t
, 0);
1342 (*f
) (count
, bytes
, NULL
);
1346 output_P9_format (vbyte_func f
, int grmask
, int gr
)
1350 bytes
[1] = (grmask
& 0x0f);
1351 bytes
[2] = (gr
& 0x7f);
1352 (*f
) (3, bytes
, NULL
);
1356 output_P10_format (vbyte_func f
, int abi
, int context
)
1360 bytes
[1] = (abi
& 0xff);
1361 bytes
[2] = (context
& 0xff);
1362 (*f
) (3, bytes
, NULL
);
1366 output_B1_format (vbyte_func f
, unw_record_type rtype
, unsigned long label
)
1372 output_B4_format (f
, rtype
, label
);
1375 if (rtype
== copy_state
)
1377 else if (rtype
!= label_state
)
1378 as_bad (_("Invalid record type for format B1"));
1380 byte
= (UNW_B1
| (r
<< 5) | (label
& 0x1f));
1381 (*f
) (1, &byte
, NULL
);
1385 output_B2_format (vbyte_func f
, unsigned long ecount
, unsigned long t
)
1391 output_B3_format (f
, ecount
, t
);
1394 bytes
[0] = (UNW_B2
| (ecount
& 0x1f));
1395 count
+= output_leb128 (bytes
+ 1, t
, 0);
1396 (*f
) (count
, bytes
, NULL
);
1400 output_B3_format (vbyte_func f
, unsigned long ecount
, unsigned long t
)
1406 output_B2_format (f
, ecount
, t
);
1410 count
+= output_leb128 (bytes
+ 1, t
, 0);
1411 count
+= output_leb128 (bytes
+ count
, ecount
, 0);
1412 (*f
) (count
, bytes
, NULL
);
1416 output_B4_format (vbyte_func f
, unw_record_type rtype
, unsigned long label
)
1423 output_B1_format (f
, rtype
, label
);
1427 if (rtype
== copy_state
)
1429 else if (rtype
!= label_state
)
1430 as_bad (_("Invalid record type for format B1"));
1432 bytes
[0] = (UNW_B4
| (r
<< 3));
1433 count
+= output_leb128 (bytes
+ 1, label
, 0);
1434 (*f
) (count
, bytes
, NULL
);
1438 format_ab_reg (int ab
, int reg
)
1443 ret
= (ab
<< 5) | reg
;
1448 output_X1_format (vbyte_func f
,
1449 unw_record_type rtype
,
1460 if (rtype
== spill_sprel
)
1462 else if (rtype
!= spill_psprel
)
1463 as_bad (_("Invalid record type for format X1"));
1464 bytes
[1] = ((r
<< 7) | format_ab_reg (ab
, reg
));
1465 count
+= output_leb128 (bytes
+ 2, t
, 0);
1466 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1467 (*f
) (count
, bytes
, NULL
);
1471 output_X2_format (vbyte_func f
,
1482 bytes
[1] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1483 bytes
[2] = (((y
& 1) << 7) | (treg
& 0x7f));
1484 count
+= output_leb128 (bytes
+ 3, t
, 0);
1485 (*f
) (count
, bytes
, NULL
);
1489 output_X3_format (vbyte_func f
,
1490 unw_record_type rtype
,
1502 if (rtype
== spill_sprel_p
)
1504 else if (rtype
!= spill_psprel_p
)
1505 as_bad (_("Invalid record type for format X3"));
1506 bytes
[1] = ((r
<< 7) | (qp
& 0x3f));
1507 bytes
[2] = format_ab_reg (ab
, reg
);
1508 count
+= output_leb128 (bytes
+ 3, t
, 0);
1509 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1510 (*f
) (count
, bytes
, NULL
);
1514 output_X4_format (vbyte_func f
,
1526 bytes
[1] = (qp
& 0x3f);
1527 bytes
[2] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1528 bytes
[3] = (((y
& 1) << 7) | (treg
& 0x7f));
1529 count
+= output_leb128 (bytes
+ 4, t
, 0);
1530 (*f
) (count
, bytes
, NULL
);
1533 /* This function checks whether there are any outstanding .save-s and
1534 discards them if so. */
1537 check_pending_save (void)
1539 if (unwind
.pending_saves
)
1541 unw_rec_list
*cur
, *prev
;
1543 as_warn (_("Previous .save incomplete"));
1544 for (cur
= unwind
.list
, prev
= NULL
; cur
; )
1545 if (&cur
->r
.record
.p
== unwind
.pending_saves
)
1548 prev
->next
= cur
->next
;
1550 unwind
.list
= cur
->next
;
1551 if (cur
== unwind
.tail
)
1553 if (cur
== unwind
.current_entry
)
1554 unwind
.current_entry
= cur
->next
;
1555 /* Don't free the first discarded record, it's being used as
1556 terminator for (currently) br_gr and gr_gr processing, and
1557 also prevents leaving a dangling pointer to it in its
1559 cur
->r
.record
.p
.grmask
= 0;
1560 cur
->r
.record
.p
.brmask
= 0;
1561 cur
->r
.record
.p
.frmask
= 0;
1562 prev
= cur
->r
.record
.p
.next
;
1563 cur
->r
.record
.p
.next
= NULL
;
1575 cur
= cur
->r
.record
.p
.next
;
1578 unwind
.pending_saves
= NULL
;
1582 /* This function allocates a record list structure, and initializes fields. */
1584 static unw_rec_list
*
1585 alloc_record (unw_record_type t
)
1588 ptr
= xmalloc (sizeof (*ptr
));
1589 memset (ptr
, 0, sizeof (*ptr
));
1590 ptr
->slot_number
= SLOT_NUM_NOT_SET
;
1595 /* Dummy unwind record used for calculating the length of the last prologue or
1598 static unw_rec_list
*
1601 unw_rec_list
*ptr
= alloc_record (endp
);
1605 static unw_rec_list
*
1606 output_prologue (void)
1608 unw_rec_list
*ptr
= alloc_record (prologue
);
1609 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1613 static unw_rec_list
*
1614 output_prologue_gr (unsigned int saved_mask
, unsigned int reg
)
1616 unw_rec_list
*ptr
= alloc_record (prologue_gr
);
1617 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1618 ptr
->r
.record
.r
.grmask
= saved_mask
;
1619 ptr
->r
.record
.r
.grsave
= reg
;
1623 static unw_rec_list
*
1626 unw_rec_list
*ptr
= alloc_record (body
);
1630 static unw_rec_list
*
1631 output_mem_stack_f (unsigned int size
)
1633 unw_rec_list
*ptr
= alloc_record (mem_stack_f
);
1634 ptr
->r
.record
.p
.size
= size
;
1638 static unw_rec_list
*
1639 output_mem_stack_v (void)
1641 unw_rec_list
*ptr
= alloc_record (mem_stack_v
);
1645 static unw_rec_list
*
1646 output_psp_gr (unsigned int gr
)
1648 unw_rec_list
*ptr
= alloc_record (psp_gr
);
1649 ptr
->r
.record
.p
.r
.gr
= gr
;
1653 static unw_rec_list
*
1654 output_psp_sprel (unsigned int offset
)
1656 unw_rec_list
*ptr
= alloc_record (psp_sprel
);
1657 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1661 static unw_rec_list
*
1662 output_rp_when (void)
1664 unw_rec_list
*ptr
= alloc_record (rp_when
);
1668 static unw_rec_list
*
1669 output_rp_gr (unsigned int gr
)
1671 unw_rec_list
*ptr
= alloc_record (rp_gr
);
1672 ptr
->r
.record
.p
.r
.gr
= gr
;
1676 static unw_rec_list
*
1677 output_rp_br (unsigned int br
)
1679 unw_rec_list
*ptr
= alloc_record (rp_br
);
1680 ptr
->r
.record
.p
.r
.br
= br
;
1684 static unw_rec_list
*
1685 output_rp_psprel (unsigned int offset
)
1687 unw_rec_list
*ptr
= alloc_record (rp_psprel
);
1688 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1692 static unw_rec_list
*
1693 output_rp_sprel (unsigned int offset
)
1695 unw_rec_list
*ptr
= alloc_record (rp_sprel
);
1696 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1700 static unw_rec_list
*
1701 output_pfs_when (void)
1703 unw_rec_list
*ptr
= alloc_record (pfs_when
);
1707 static unw_rec_list
*
1708 output_pfs_gr (unsigned int gr
)
1710 unw_rec_list
*ptr
= alloc_record (pfs_gr
);
1711 ptr
->r
.record
.p
.r
.gr
= gr
;
1715 static unw_rec_list
*
1716 output_pfs_psprel (unsigned int offset
)
1718 unw_rec_list
*ptr
= alloc_record (pfs_psprel
);
1719 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1723 static unw_rec_list
*
1724 output_pfs_sprel (unsigned int offset
)
1726 unw_rec_list
*ptr
= alloc_record (pfs_sprel
);
1727 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1731 static unw_rec_list
*
1732 output_preds_when (void)
1734 unw_rec_list
*ptr
= alloc_record (preds_when
);
1738 static unw_rec_list
*
1739 output_preds_gr (unsigned int gr
)
1741 unw_rec_list
*ptr
= alloc_record (preds_gr
);
1742 ptr
->r
.record
.p
.r
.gr
= gr
;
1746 static unw_rec_list
*
1747 output_preds_psprel (unsigned int offset
)
1749 unw_rec_list
*ptr
= alloc_record (preds_psprel
);
1750 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1754 static unw_rec_list
*
1755 output_preds_sprel (unsigned int offset
)
1757 unw_rec_list
*ptr
= alloc_record (preds_sprel
);
1758 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1762 static unw_rec_list
*
1763 output_fr_mem (unsigned int mask
)
1765 unw_rec_list
*ptr
= alloc_record (fr_mem
);
1766 unw_rec_list
*cur
= ptr
;
1768 ptr
->r
.record
.p
.frmask
= mask
;
1769 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1772 unw_rec_list
*prev
= cur
;
1774 /* Clear least significant set bit. */
1775 mask
&= ~(mask
& (~mask
+ 1));
1778 cur
= alloc_record (fr_mem
);
1779 cur
->r
.record
.p
.frmask
= mask
;
1780 /* Retain only least significant bit. */
1781 prev
->r
.record
.p
.frmask
^= mask
;
1782 prev
->r
.record
.p
.next
= cur
;
1786 static unw_rec_list
*
1787 output_frgr_mem (unsigned int gr_mask
, unsigned int fr_mask
)
1789 unw_rec_list
*ptr
= alloc_record (frgr_mem
);
1790 unw_rec_list
*cur
= ptr
;
1792 unwind
.pending_saves
= &cur
->r
.record
.p
;
1793 cur
->r
.record
.p
.frmask
= fr_mask
;
1796 unw_rec_list
*prev
= cur
;
1798 /* Clear least significant set bit. */
1799 fr_mask
&= ~(fr_mask
& (~fr_mask
+ 1));
1800 if (!gr_mask
&& !fr_mask
)
1802 cur
= alloc_record (frgr_mem
);
1803 cur
->r
.record
.p
.frmask
= fr_mask
;
1804 /* Retain only least significant bit. */
1805 prev
->r
.record
.p
.frmask
^= fr_mask
;
1806 prev
->r
.record
.p
.next
= cur
;
1808 cur
->r
.record
.p
.grmask
= gr_mask
;
1811 unw_rec_list
*prev
= cur
;
1813 /* Clear least significant set bit. */
1814 gr_mask
&= ~(gr_mask
& (~gr_mask
+ 1));
1817 cur
= alloc_record (frgr_mem
);
1818 cur
->r
.record
.p
.grmask
= gr_mask
;
1819 /* Retain only least significant bit. */
1820 prev
->r
.record
.p
.grmask
^= gr_mask
;
1821 prev
->r
.record
.p
.next
= cur
;
1825 static unw_rec_list
*
1826 output_gr_gr (unsigned int mask
, unsigned int reg
)
1828 unw_rec_list
*ptr
= alloc_record (gr_gr
);
1829 unw_rec_list
*cur
= ptr
;
1831 ptr
->r
.record
.p
.grmask
= mask
;
1832 ptr
->r
.record
.p
.r
.gr
= reg
;
1833 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1836 unw_rec_list
*prev
= cur
;
1838 /* Clear least significant set bit. */
1839 mask
&= ~(mask
& (~mask
+ 1));
1842 cur
= alloc_record (gr_gr
);
1843 cur
->r
.record
.p
.grmask
= mask
;
1844 /* Indicate this record shouldn't be output. */
1845 cur
->r
.record
.p
.r
.gr
= REG_NUM
;
1846 /* Retain only least significant bit. */
1847 prev
->r
.record
.p
.grmask
^= mask
;
1848 prev
->r
.record
.p
.next
= cur
;
1852 static unw_rec_list
*
1853 output_gr_mem (unsigned int mask
)
1855 unw_rec_list
*ptr
= alloc_record (gr_mem
);
1856 unw_rec_list
*cur
= ptr
;
1858 ptr
->r
.record
.p
.grmask
= mask
;
1859 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1862 unw_rec_list
*prev
= cur
;
1864 /* Clear least significant set bit. */
1865 mask
&= ~(mask
& (~mask
+ 1));
1868 cur
= alloc_record (gr_mem
);
1869 cur
->r
.record
.p
.grmask
= mask
;
1870 /* Retain only least significant bit. */
1871 prev
->r
.record
.p
.grmask
^= mask
;
1872 prev
->r
.record
.p
.next
= cur
;
1876 static unw_rec_list
*
1877 output_br_mem (unsigned int mask
)
1879 unw_rec_list
*ptr
= alloc_record (br_mem
);
1880 unw_rec_list
*cur
= ptr
;
1882 ptr
->r
.record
.p
.brmask
= mask
;
1883 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1886 unw_rec_list
*prev
= cur
;
1888 /* Clear least significant set bit. */
1889 mask
&= ~(mask
& (~mask
+ 1));
1892 cur
= alloc_record (br_mem
);
1893 cur
->r
.record
.p
.brmask
= mask
;
1894 /* Retain only least significant bit. */
1895 prev
->r
.record
.p
.brmask
^= mask
;
1896 prev
->r
.record
.p
.next
= cur
;
1900 static unw_rec_list
*
1901 output_br_gr (unsigned int mask
, unsigned int reg
)
1903 unw_rec_list
*ptr
= alloc_record (br_gr
);
1904 unw_rec_list
*cur
= ptr
;
1906 ptr
->r
.record
.p
.brmask
= mask
;
1907 ptr
->r
.record
.p
.r
.gr
= reg
;
1908 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1911 unw_rec_list
*prev
= cur
;
1913 /* Clear least significant set bit. */
1914 mask
&= ~(mask
& (~mask
+ 1));
1917 cur
= alloc_record (br_gr
);
1918 cur
->r
.record
.p
.brmask
= mask
;
1919 /* Indicate this record shouldn't be output. */
1920 cur
->r
.record
.p
.r
.gr
= REG_NUM
;
1921 /* Retain only least significant bit. */
1922 prev
->r
.record
.p
.brmask
^= mask
;
1923 prev
->r
.record
.p
.next
= cur
;
1927 static unw_rec_list
*
1928 output_spill_base (unsigned int offset
)
1930 unw_rec_list
*ptr
= alloc_record (spill_base
);
1931 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1935 static unw_rec_list
*
1936 output_unat_when (void)
1938 unw_rec_list
*ptr
= alloc_record (unat_when
);
1942 static unw_rec_list
*
1943 output_unat_gr (unsigned int gr
)
1945 unw_rec_list
*ptr
= alloc_record (unat_gr
);
1946 ptr
->r
.record
.p
.r
.gr
= gr
;
1950 static unw_rec_list
*
1951 output_unat_psprel (unsigned int offset
)
1953 unw_rec_list
*ptr
= alloc_record (unat_psprel
);
1954 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1958 static unw_rec_list
*
1959 output_unat_sprel (unsigned int offset
)
1961 unw_rec_list
*ptr
= alloc_record (unat_sprel
);
1962 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1966 static unw_rec_list
*
1967 output_lc_when (void)
1969 unw_rec_list
*ptr
= alloc_record (lc_when
);
1973 static unw_rec_list
*
1974 output_lc_gr (unsigned int gr
)
1976 unw_rec_list
*ptr
= alloc_record (lc_gr
);
1977 ptr
->r
.record
.p
.r
.gr
= gr
;
1981 static unw_rec_list
*
1982 output_lc_psprel (unsigned int offset
)
1984 unw_rec_list
*ptr
= alloc_record (lc_psprel
);
1985 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1989 static unw_rec_list
*
1990 output_lc_sprel (unsigned int offset
)
1992 unw_rec_list
*ptr
= alloc_record (lc_sprel
);
1993 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1997 static unw_rec_list
*
1998 output_fpsr_when (void)
2000 unw_rec_list
*ptr
= alloc_record (fpsr_when
);
2004 static unw_rec_list
*
2005 output_fpsr_gr (unsigned int gr
)
2007 unw_rec_list
*ptr
= alloc_record (fpsr_gr
);
2008 ptr
->r
.record
.p
.r
.gr
= gr
;
2012 static unw_rec_list
*
2013 output_fpsr_psprel (unsigned int offset
)
2015 unw_rec_list
*ptr
= alloc_record (fpsr_psprel
);
2016 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2020 static unw_rec_list
*
2021 output_fpsr_sprel (unsigned int offset
)
2023 unw_rec_list
*ptr
= alloc_record (fpsr_sprel
);
2024 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2028 static unw_rec_list
*
2029 output_priunat_when_gr (void)
2031 unw_rec_list
*ptr
= alloc_record (priunat_when_gr
);
2035 static unw_rec_list
*
2036 output_priunat_when_mem (void)
2038 unw_rec_list
*ptr
= alloc_record (priunat_when_mem
);
2042 static unw_rec_list
*
2043 output_priunat_gr (unsigned int gr
)
2045 unw_rec_list
*ptr
= alloc_record (priunat_gr
);
2046 ptr
->r
.record
.p
.r
.gr
= gr
;
2050 static unw_rec_list
*
2051 output_priunat_psprel (unsigned int offset
)
2053 unw_rec_list
*ptr
= alloc_record (priunat_psprel
);
2054 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2058 static unw_rec_list
*
2059 output_priunat_sprel (unsigned int offset
)
2061 unw_rec_list
*ptr
= alloc_record (priunat_sprel
);
2062 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2066 static unw_rec_list
*
2067 output_bsp_when (void)
2069 unw_rec_list
*ptr
= alloc_record (bsp_when
);
2073 static unw_rec_list
*
2074 output_bsp_gr (unsigned int gr
)
2076 unw_rec_list
*ptr
= alloc_record (bsp_gr
);
2077 ptr
->r
.record
.p
.r
.gr
= gr
;
2081 static unw_rec_list
*
2082 output_bsp_psprel (unsigned int offset
)
2084 unw_rec_list
*ptr
= alloc_record (bsp_psprel
);
2085 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2089 static unw_rec_list
*
2090 output_bsp_sprel (unsigned int offset
)
2092 unw_rec_list
*ptr
= alloc_record (bsp_sprel
);
2093 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2097 static unw_rec_list
*
2098 output_bspstore_when (void)
2100 unw_rec_list
*ptr
= alloc_record (bspstore_when
);
2104 static unw_rec_list
*
2105 output_bspstore_gr (unsigned int gr
)
2107 unw_rec_list
*ptr
= alloc_record (bspstore_gr
);
2108 ptr
->r
.record
.p
.r
.gr
= gr
;
2112 static unw_rec_list
*
2113 output_bspstore_psprel (unsigned int offset
)
2115 unw_rec_list
*ptr
= alloc_record (bspstore_psprel
);
2116 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2120 static unw_rec_list
*
2121 output_bspstore_sprel (unsigned int offset
)
2123 unw_rec_list
*ptr
= alloc_record (bspstore_sprel
);
2124 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2128 static unw_rec_list
*
2129 output_rnat_when (void)
2131 unw_rec_list
*ptr
= alloc_record (rnat_when
);
2135 static unw_rec_list
*
2136 output_rnat_gr (unsigned int gr
)
2138 unw_rec_list
*ptr
= alloc_record (rnat_gr
);
2139 ptr
->r
.record
.p
.r
.gr
= gr
;
2143 static unw_rec_list
*
2144 output_rnat_psprel (unsigned int offset
)
2146 unw_rec_list
*ptr
= alloc_record (rnat_psprel
);
2147 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2151 static unw_rec_list
*
2152 output_rnat_sprel (unsigned int offset
)
2154 unw_rec_list
*ptr
= alloc_record (rnat_sprel
);
2155 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2159 static unw_rec_list
*
2160 output_unwabi (unsigned long abi
, unsigned long context
)
2162 unw_rec_list
*ptr
= alloc_record (unwabi
);
2163 ptr
->r
.record
.p
.abi
= abi
;
2164 ptr
->r
.record
.p
.context
= context
;
2168 static unw_rec_list
*
2169 output_epilogue (unsigned long ecount
)
2171 unw_rec_list
*ptr
= alloc_record (epilogue
);
2172 ptr
->r
.record
.b
.ecount
= ecount
;
2176 static unw_rec_list
*
2177 output_label_state (unsigned long label
)
2179 unw_rec_list
*ptr
= alloc_record (label_state
);
2180 ptr
->r
.record
.b
.label
= label
;
2184 static unw_rec_list
*
2185 output_copy_state (unsigned long label
)
2187 unw_rec_list
*ptr
= alloc_record (copy_state
);
2188 ptr
->r
.record
.b
.label
= label
;
2192 static unw_rec_list
*
2193 output_spill_psprel (unsigned int ab
,
2195 unsigned int offset
,
2196 unsigned int predicate
)
2198 unw_rec_list
*ptr
= alloc_record (predicate
? spill_psprel_p
: spill_psprel
);
2199 ptr
->r
.record
.x
.ab
= ab
;
2200 ptr
->r
.record
.x
.reg
= reg
;
2201 ptr
->r
.record
.x
.where
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2202 ptr
->r
.record
.x
.qp
= predicate
;
2206 static unw_rec_list
*
2207 output_spill_sprel (unsigned int ab
,
2209 unsigned int offset
,
2210 unsigned int predicate
)
2212 unw_rec_list
*ptr
= alloc_record (predicate
? spill_sprel_p
: spill_sprel
);
2213 ptr
->r
.record
.x
.ab
= ab
;
2214 ptr
->r
.record
.x
.reg
= reg
;
2215 ptr
->r
.record
.x
.where
.spoff
= offset
/ 4;
2216 ptr
->r
.record
.x
.qp
= predicate
;
2220 static unw_rec_list
*
2221 output_spill_reg (unsigned int ab
,
2223 unsigned int targ_reg
,
2225 unsigned int predicate
)
2227 unw_rec_list
*ptr
= alloc_record (predicate
? spill_reg_p
: spill_reg
);
2228 ptr
->r
.record
.x
.ab
= ab
;
2229 ptr
->r
.record
.x
.reg
= reg
;
2230 ptr
->r
.record
.x
.where
.reg
= targ_reg
;
2231 ptr
->r
.record
.x
.xy
= xy
;
2232 ptr
->r
.record
.x
.qp
= predicate
;
2236 /* Given a unw_rec_list process the correct format with the
2237 specified function. */
2240 process_one_record (unw_rec_list
*ptr
, vbyte_func f
)
2242 unsigned int fr_mask
, gr_mask
;
2244 switch (ptr
->r
.type
)
2246 /* This is a dummy record that takes up no space in the output. */
2254 /* These are taken care of by prologue/prologue_gr. */
2259 if (ptr
->r
.type
== prologue_gr
)
2260 output_R2_format (f
, ptr
->r
.record
.r
.grmask
,
2261 ptr
->r
.record
.r
.grsave
, ptr
->r
.record
.r
.rlen
);
2263 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2265 /* Output descriptor(s) for union of register spills (if any). */
2266 gr_mask
= ptr
->r
.record
.r
.mask
.gr_mem
;
2267 fr_mask
= ptr
->r
.record
.r
.mask
.fr_mem
;
2270 if ((fr_mask
& ~0xfUL
) == 0)
2271 output_P6_format (f
, fr_mem
, fr_mask
);
2274 output_P5_format (f
, gr_mask
, fr_mask
);
2279 output_P6_format (f
, gr_mem
, gr_mask
);
2280 if (ptr
->r
.record
.r
.mask
.br_mem
)
2281 output_P1_format (f
, ptr
->r
.record
.r
.mask
.br_mem
);
2283 /* output imask descriptor if necessary: */
2284 if (ptr
->r
.record
.r
.mask
.i
)
2285 output_P4_format (f
, ptr
->r
.record
.r
.mask
.i
,
2286 ptr
->r
.record
.r
.imask_size
);
2290 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2294 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
,
2295 ptr
->r
.record
.p
.size
);
2308 output_P3_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.r
.gr
);
2311 output_P3_format (f
, rp_br
, ptr
->r
.record
.p
.r
.br
);
2314 output_P7_format (f
, psp_sprel
, ptr
->r
.record
.p
.off
.sp
, 0);
2322 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
, 0);
2331 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.off
.psp
, 0);
2341 case bspstore_sprel
:
2343 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.off
.sp
);
2346 if (ptr
->r
.record
.p
.r
.gr
< REG_NUM
)
2348 const unw_rec_list
*cur
= ptr
;
2350 gr_mask
= cur
->r
.record
.p
.grmask
;
2351 while ((cur
= cur
->r
.record
.p
.next
) != NULL
)
2352 gr_mask
|= cur
->r
.record
.p
.grmask
;
2353 output_P9_format (f
, gr_mask
, ptr
->r
.record
.p
.r
.gr
);
2357 if (ptr
->r
.record
.p
.r
.gr
< REG_NUM
)
2359 const unw_rec_list
*cur
= ptr
;
2361 gr_mask
= cur
->r
.record
.p
.brmask
;
2362 while ((cur
= cur
->r
.record
.p
.next
) != NULL
)
2363 gr_mask
|= cur
->r
.record
.p
.brmask
;
2364 output_P2_format (f
, gr_mask
, ptr
->r
.record
.p
.r
.gr
);
2368 as_bad (_("spill_mask record unimplemented."));
2370 case priunat_when_gr
:
2371 case priunat_when_mem
:
2375 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
);
2377 case priunat_psprel
:
2379 case bspstore_psprel
:
2381 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.off
.psp
);
2384 output_P10_format (f
, ptr
->r
.record
.p
.abi
, ptr
->r
.record
.p
.context
);
2387 output_B3_format (f
, ptr
->r
.record
.b
.ecount
, ptr
->r
.record
.b
.t
);
2391 output_B4_format (f
, ptr
->r
.type
, ptr
->r
.record
.b
.label
);
2394 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2395 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2396 ptr
->r
.record
.x
.where
.pspoff
);
2399 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2400 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2401 ptr
->r
.record
.x
.where
.spoff
);
2404 output_X2_format (f
, ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2405 ptr
->r
.record
.x
.xy
>> 1, ptr
->r
.record
.x
.xy
,
2406 ptr
->r
.record
.x
.where
.reg
, ptr
->r
.record
.x
.t
);
2408 case spill_psprel_p
:
2409 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2410 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2411 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.where
.pspoff
);
2414 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2415 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2416 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.where
.spoff
);
2419 output_X4_format (f
, ptr
->r
.record
.x
.qp
, ptr
->r
.record
.x
.ab
,
2420 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.xy
>> 1,
2421 ptr
->r
.record
.x
.xy
, ptr
->r
.record
.x
.where
.reg
,
2425 as_bad (_("record_type_not_valid"));
2430 /* Given a unw_rec_list list, process all the records with
2431 the specified function. */
2433 process_unw_records (unw_rec_list
*list
, vbyte_func f
)
2436 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2437 process_one_record (ptr
, f
);
2440 /* Determine the size of a record list in bytes. */
2442 calc_record_size (unw_rec_list
*list
)
2445 process_unw_records (list
, count_output
);
2449 /* Return the number of bits set in the input value.
2450 Perhaps this has a better place... */
2451 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
2452 # define popcount __builtin_popcount
2455 popcount (unsigned x
)
2457 static const unsigned char popcnt
[16] =
2465 if (x
< NELEMS (popcnt
))
2467 return popcnt
[x
% NELEMS (popcnt
)] + popcount (x
/ NELEMS (popcnt
));
2471 /* Update IMASK bitmask to reflect the fact that one or more registers
2472 of type TYPE are saved starting at instruction with index T. If N
2473 bits are set in REGMASK, it is assumed that instructions T through
2474 T+N-1 save these registers.
2478 1: instruction saves next fp reg
2479 2: instruction saves next general reg
2480 3: instruction saves next branch reg */
2482 set_imask (unw_rec_list
*region
,
2483 unsigned long regmask
,
2487 unsigned char *imask
;
2488 unsigned long imask_size
;
2492 imask
= region
->r
.record
.r
.mask
.i
;
2493 imask_size
= region
->r
.record
.r
.imask_size
;
2496 imask_size
= (region
->r
.record
.r
.rlen
* 2 + 7) / 8 + 1;
2497 imask
= xmalloc (imask_size
);
2498 memset (imask
, 0, imask_size
);
2500 region
->r
.record
.r
.imask_size
= imask_size
;
2501 region
->r
.record
.r
.mask
.i
= imask
;
2505 pos
= 2 * (3 - t
% 4);
2508 if (i
>= imask_size
)
2510 as_bad (_("Ignoring attempt to spill beyond end of region"));
2514 imask
[i
] |= (type
& 0x3) << pos
;
2516 regmask
&= (regmask
- 1);
2526 /* Return the number of instruction slots from FIRST_ADDR to SLOT_ADDR.
2527 SLOT_FRAG is the frag containing SLOT_ADDR, and FIRST_FRAG is the frag
2528 containing FIRST_ADDR. If BEFORE_RELAX, then we use worst-case estimates
2531 static unsigned long
2532 slot_index (unsigned long slot_addr
,
2534 unsigned long first_addr
,
2538 unsigned long index
= 0;
2540 /* First time we are called, the initial address and frag are invalid. */
2541 if (first_addr
== 0)
2544 /* If the two addresses are in different frags, then we need to add in
2545 the remaining size of this frag, and then the entire size of intermediate
2547 while (slot_frag
!= first_frag
)
2549 unsigned long start_addr
= (unsigned long) &first_frag
->fr_literal
;
2553 /* We can get the final addresses only during and after
2555 if (first_frag
->fr_next
&& first_frag
->fr_next
->fr_address
)
2556 index
+= 3 * ((first_frag
->fr_next
->fr_address
2557 - first_frag
->fr_address
2558 - first_frag
->fr_fix
) >> 4);
2561 /* We don't know what the final addresses will be. We try our
2562 best to estimate. */
2563 switch (first_frag
->fr_type
)
2569 as_fatal (_("Only constant space allocation is supported"));
2575 /* Take alignment into account. Assume the worst case
2576 before relaxation. */
2577 index
+= 3 * ((1 << first_frag
->fr_offset
) >> 4);
2581 if (first_frag
->fr_symbol
)
2583 as_fatal (_("Only constant offsets are supported"));
2587 index
+= 3 * (first_frag
->fr_offset
>> 4);
2591 /* Add in the full size of the frag converted to instruction slots. */
2592 index
+= 3 * (first_frag
->fr_fix
>> 4);
2593 /* Subtract away the initial part before first_addr. */
2594 index
-= (3 * ((first_addr
>> 4) - (start_addr
>> 4))
2595 + ((first_addr
& 0x3) - (start_addr
& 0x3)));
2597 /* Move to the beginning of the next frag. */
2598 first_frag
= first_frag
->fr_next
;
2599 first_addr
= (unsigned long) &first_frag
->fr_literal
;
2601 /* This can happen if there is section switching in the middle of a
2602 function, causing the frag chain for the function to be broken.
2603 It is too difficult to recover safely from this problem, so we just
2604 exit with an error. */
2605 if (first_frag
== NULL
)
2606 as_fatal (_("Section switching in code is not supported."));
2609 /* Add in the used part of the last frag. */
2610 index
+= (3 * ((slot_addr
>> 4) - (first_addr
>> 4))
2611 + ((slot_addr
& 0x3) - (first_addr
& 0x3)));
2615 /* Optimize unwind record directives. */
2617 static unw_rec_list
*
2618 optimize_unw_records (unw_rec_list
*list
)
2623 /* If the only unwind record is ".prologue" or ".prologue" followed
2624 by ".body", then we can optimize the unwind directives away. */
2625 if (list
->r
.type
== prologue
2626 && (list
->next
->r
.type
== endp
2627 || (list
->next
->r
.type
== body
&& list
->next
->next
->r
.type
== endp
)))
2633 /* Given a complete record list, process any records which have
2634 unresolved fields, (ie length counts for a prologue). After
2635 this has been run, all necessary information should be available
2636 within each record to generate an image. */
2639 fixup_unw_records (unw_rec_list
*list
, int before_relax
)
2641 unw_rec_list
*ptr
, *region
= 0;
2642 unsigned long first_addr
= 0, rlen
= 0, t
;
2643 fragS
*first_frag
= 0;
2645 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2647 if (ptr
->slot_number
== SLOT_NUM_NOT_SET
)
2648 as_bad (_(" Insn slot not set in unwind record."));
2649 t
= slot_index (ptr
->slot_number
, ptr
->slot_frag
,
2650 first_addr
, first_frag
, before_relax
);
2651 switch (ptr
->r
.type
)
2659 unsigned long last_addr
= 0;
2660 fragS
*last_frag
= NULL
;
2662 first_addr
= ptr
->slot_number
;
2663 first_frag
= ptr
->slot_frag
;
2664 /* Find either the next body/prologue start, or the end of
2665 the function, and determine the size of the region. */
2666 for (last
= ptr
->next
; last
!= NULL
; last
= last
->next
)
2667 if (last
->r
.type
== prologue
|| last
->r
.type
== prologue_gr
2668 || last
->r
.type
== body
|| last
->r
.type
== endp
)
2670 last_addr
= last
->slot_number
;
2671 last_frag
= last
->slot_frag
;
2674 size
= slot_index (last_addr
, last_frag
, first_addr
, first_frag
,
2676 rlen
= ptr
->r
.record
.r
.rlen
= size
;
2677 if (ptr
->r
.type
== body
)
2678 /* End of region. */
2686 ptr
->r
.record
.b
.t
= rlen
- 1 - t
;
2688 /* This happens when a memory-stack-less procedure uses a
2689 ".restore sp" directive at the end of a region to pop
2691 ptr
->r
.record
.b
.t
= 0;
2702 case priunat_when_gr
:
2703 case priunat_when_mem
:
2707 ptr
->r
.record
.p
.t
= t
;
2715 case spill_psprel_p
:
2716 ptr
->r
.record
.x
.t
= t
;
2722 as_bad (_("frgr_mem record before region record!"));
2725 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.frmask
;
2726 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.grmask
;
2727 set_imask (region
, ptr
->r
.record
.p
.frmask
, t
, 1);
2728 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2733 as_bad (_("fr_mem record before region record!"));
2736 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.frmask
;
2737 set_imask (region
, ptr
->r
.record
.p
.frmask
, t
, 1);
2742 as_bad (_("gr_mem record before region record!"));
2745 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.grmask
;
2746 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2751 as_bad (_("br_mem record before region record!"));
2754 region
->r
.record
.r
.mask
.br_mem
|= ptr
->r
.record
.p
.brmask
;
2755 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2761 as_bad (_("gr_gr record before region record!"));
2764 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2769 as_bad (_("br_gr record before region record!"));
2772 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2781 /* Estimate the size of a frag before relaxing. We only have one type of frag
2782 to handle here, which is the unwind info frag. */
2785 ia64_estimate_size_before_relax (fragS
*frag
,
2786 asection
*segtype ATTRIBUTE_UNUSED
)
2791 /* ??? This code is identical to the first part of ia64_convert_frag. */
2792 list
= (unw_rec_list
*) frag
->fr_opcode
;
2793 fixup_unw_records (list
, 0);
2795 len
= calc_record_size (list
);
2796 /* pad to pointer-size boundary. */
2797 pad
= len
% md
.pointer_size
;
2799 len
+= md
.pointer_size
- pad
;
2800 /* Add 8 for the header. */
2802 /* Add a pointer for the personality offset. */
2803 if (frag
->fr_offset
)
2804 size
+= md
.pointer_size
;
2806 /* fr_var carries the max_chars that we created the fragment with.
2807 We must, of course, have allocated enough memory earlier. */
2808 assert (frag
->fr_var
>= size
);
2810 return frag
->fr_fix
+ size
;
2813 /* This function converts a rs_machine_dependent variant frag into a
2814 normal fill frag with the unwind image from the the record list. */
2816 ia64_convert_frag (fragS
*frag
)
2822 /* ??? This code is identical to ia64_estimate_size_before_relax. */
2823 list
= (unw_rec_list
*) frag
->fr_opcode
;
2824 fixup_unw_records (list
, 0);
2826 len
= calc_record_size (list
);
2827 /* pad to pointer-size boundary. */
2828 pad
= len
% md
.pointer_size
;
2830 len
+= md
.pointer_size
- pad
;
2831 /* Add 8 for the header. */
2833 /* Add a pointer for the personality offset. */
2834 if (frag
->fr_offset
)
2835 size
+= md
.pointer_size
;
2837 /* fr_var carries the max_chars that we created the fragment with.
2838 We must, of course, have allocated enough memory earlier. */
2839 assert (frag
->fr_var
>= size
);
2841 /* Initialize the header area. fr_offset is initialized with
2842 unwind.personality_routine. */
2843 if (frag
->fr_offset
)
2845 if (md
.flags
& EF_IA_64_ABI64
)
2846 flag_value
= (bfd_vma
) 3 << 32;
2848 /* 32-bit unwind info block. */
2849 flag_value
= (bfd_vma
) 0x1003 << 32;
2854 md_number_to_chars (frag
->fr_literal
,
2855 (((bfd_vma
) 1 << 48) /* Version. */
2856 | flag_value
/* U & E handler flags. */
2857 | (len
/ md
.pointer_size
)), /* Length. */
2860 /* Skip the header. */
2861 vbyte_mem_ptr
= frag
->fr_literal
+ 8;
2862 process_unw_records (list
, output_vbyte_mem
);
2864 /* Fill the padding bytes with zeros. */
2866 md_number_to_chars (frag
->fr_literal
+ len
+ 8 - md
.pointer_size
+ pad
, 0,
2867 md
.pointer_size
- pad
);
2868 /* Fill the unwind personality with zeros. */
2869 if (frag
->fr_offset
)
2870 md_number_to_chars (frag
->fr_literal
+ size
- md
.pointer_size
, 0,
2873 frag
->fr_fix
+= size
;
2874 frag
->fr_type
= rs_fill
;
2876 frag
->fr_offset
= 0;
2880 parse_predicate_and_operand (expressionS
*e
, unsigned *qp
, const char *po
)
2882 int sep
= parse_operand (e
, ',');
2884 *qp
= e
->X_add_number
- REG_P
;
2885 if (e
->X_op
!= O_register
|| *qp
> 63)
2887 as_bad (_("First operand to .%s must be a predicate"), po
);
2891 as_warn (_("Pointless use of p0 as first operand to .%s"), po
);
2893 sep
= parse_operand (e
, ',');
2900 convert_expr_to_ab_reg (const expressionS
*e
,
2906 unsigned int reg
= e
->X_add_number
;
2908 *ab
= *regp
= 0; /* Anything valid is good here. */
2910 if (e
->X_op
!= O_register
)
2911 reg
= REG_GR
; /* Anything invalid is good here. */
2913 if (reg
>= (REG_GR
+ 4) && reg
<= (REG_GR
+ 7))
2916 *regp
= reg
- REG_GR
;
2918 else if ((reg
>= (REG_FR
+ 2) && reg
<= (REG_FR
+ 5))
2919 || (reg
>= (REG_FR
+ 16) && reg
<= (REG_FR
+ 31)))
2922 *regp
= reg
- REG_FR
;
2924 else if (reg
>= (REG_BR
+ 1) && reg
<= (REG_BR
+ 5))
2927 *regp
= reg
- REG_BR
;
2934 case REG_PR
: *regp
= 0; break;
2935 case REG_PSP
: *regp
= 1; break;
2936 case REG_PRIUNAT
: *regp
= 2; break;
2937 case REG_BR
+ 0: *regp
= 3; break;
2938 case REG_AR
+ AR_BSP
: *regp
= 4; break;
2939 case REG_AR
+ AR_BSPSTORE
: *regp
= 5; break;
2940 case REG_AR
+ AR_RNAT
: *regp
= 6; break;
2941 case REG_AR
+ AR_UNAT
: *regp
= 7; break;
2942 case REG_AR
+ AR_FPSR
: *regp
= 8; break;
2943 case REG_AR
+ AR_PFS
: *regp
= 9; break;
2944 case REG_AR
+ AR_LC
: *regp
= 10; break;
2947 as_bad (_("Operand %d to .%s must be a preserved register"), n
, po
);
2954 convert_expr_to_xy_reg (const expressionS
*e
,
2960 unsigned int reg
= e
->X_add_number
;
2962 *xy
= *regp
= 0; /* Anything valid is good here. */
2964 if (e
->X_op
!= O_register
)
2965 reg
= REG_GR
; /* Anything invalid is good here. */
2967 if (reg
>= (REG_GR
+ 1) && reg
<= (REG_GR
+ 127))
2970 *regp
= reg
- REG_GR
;
2972 else if (reg
>= (REG_FR
+ 2) && reg
<= (REG_FR
+ 127))
2975 *regp
= reg
- REG_FR
;
2977 else if (reg
>= REG_BR
&& reg
<= (REG_BR
+ 7))
2980 *regp
= reg
- REG_BR
;
2983 as_bad (_("Operand %d to .%s must be a writable register"), n
, po
);
2989 /* The current frag is an alignment frag. */
2990 align_frag
= frag_now
;
2991 s_align_bytes (arg
);
2995 dot_radix (int dummy ATTRIBUTE_UNUSED
)
3002 if (is_it_end_of_statement ())
3004 radix
= input_line_pointer
;
3005 ch
= get_symbol_end ();
3006 ia64_canonicalize_symbol_name (radix
);
3007 if (strcasecmp (radix
, "C"))
3008 as_bad (_("Radix `%s' unsupported or invalid"), radix
);
3009 *input_line_pointer
= ch
;
3010 demand_empty_rest_of_line ();
3013 /* Helper function for .loc directives. If the assembler is not generating
3014 line number info, then we need to remember which instructions have a .loc
3015 directive, and only call dwarf2_gen_line_info for those instructions. */
3020 CURR_SLOT
.loc_directive_seen
= 1;
3021 dwarf2_directive_loc (x
);
3024 /* .sbss, .bss etc. are macros that expand into ".section SECNAME". */
3026 dot_special_section (int which
)
3028 set_section ((char *) special_section_name
[which
]);
3031 /* Return -1 for warning and 0 for error. */
3034 unwind_diagnostic (const char * region
, const char *directive
)
3036 if (md
.unwind_check
== unwind_check_warning
)
3038 as_warn (_(".%s outside of %s"), directive
, region
);
3043 as_bad (_(".%s outside of %s"), directive
, region
);
3044 ignore_rest_of_line ();
3049 /* Return 1 if a directive is in a procedure, -1 if a directive isn't in
3050 a procedure but the unwind directive check is set to warning, 0 if
3051 a directive isn't in a procedure and the unwind directive check is set
3055 in_procedure (const char *directive
)
3057 if (unwind
.proc_pending
.sym
3058 && (!unwind
.saved_text_seg
|| strcmp (directive
, "endp") == 0))
3060 return unwind_diagnostic ("procedure", directive
);
3063 /* Return 1 if a directive is in a prologue, -1 if a directive isn't in
3064 a prologue but the unwind directive check is set to warning, 0 if
3065 a directive isn't in a prologue and the unwind directive check is set
3069 in_prologue (const char *directive
)
3071 int in
= in_procedure (directive
);
3073 if (in
> 0 && !unwind
.prologue
)
3074 in
= unwind_diagnostic ("prologue", directive
);
3075 check_pending_save ();
3079 /* Return 1 if a directive is in a body, -1 if a directive isn't in
3080 a body but the unwind directive check is set to warning, 0 if
3081 a directive isn't in a body and the unwind directive check is set
3085 in_body (const char *directive
)
3087 int in
= in_procedure (directive
);
3089 if (in
> 0 && !unwind
.body
)
3090 in
= unwind_diagnostic ("body region", directive
);
3095 add_unwind_entry (unw_rec_list
*ptr
, int sep
)
3100 unwind
.tail
->next
= ptr
;
3105 /* The current entry can in fact be a chain of unwind entries. */
3106 if (unwind
.current_entry
== NULL
)
3107 unwind
.current_entry
= ptr
;
3110 /* The current entry can in fact be a chain of unwind entries. */
3111 if (unwind
.current_entry
== NULL
)
3112 unwind
.current_entry
= ptr
;
3116 /* Parse a tag permitted for the current directive. */
3120 ch
= get_symbol_end ();
3121 /* FIXME: For now, just issue a warning that this isn't implemented. */
3128 as_warn (_("Tags on unwind pseudo-ops aren't supported, yet"));
3131 *input_line_pointer
= ch
;
3133 if (sep
!= NOT_A_CHAR
)
3134 demand_empty_rest_of_line ();
3138 dot_fframe (int dummy ATTRIBUTE_UNUSED
)
3143 if (!in_prologue ("fframe"))
3146 sep
= parse_operand (&e
, ',');
3148 if (e
.X_op
!= O_constant
)
3150 as_bad (_("First operand to .fframe must be a constant"));
3153 add_unwind_entry (output_mem_stack_f (e
.X_add_number
), sep
);
3157 dot_vframe (int dummy ATTRIBUTE_UNUSED
)
3163 if (!in_prologue ("vframe"))
3166 sep
= parse_operand (&e
, ',');
3167 reg
= e
.X_add_number
- REG_GR
;
3168 if (e
.X_op
!= O_register
|| reg
> 127)
3170 as_bad (_("First operand to .vframe must be a general register"));
3173 add_unwind_entry (output_mem_stack_v (), sep
);
3174 if (! (unwind
.prologue_mask
& 2))
3175 add_unwind_entry (output_psp_gr (reg
), NOT_A_CHAR
);
3176 else if (reg
!= unwind
.prologue_gr
3177 + (unsigned) popcount (unwind
.prologue_mask
& (-2 << 1)))
3178 as_warn (_("Operand of .vframe contradicts .prologue"));
3182 dot_vframesp (int psp
)
3188 as_warn (_(".vframepsp is meaningless, assuming .vframesp was meant"));
3190 if (!in_prologue ("vframesp"))
3193 sep
= parse_operand (&e
, ',');
3194 if (e
.X_op
!= O_constant
)
3196 as_bad (_("Operand to .vframesp must be a constant (sp-relative offset)"));
3199 add_unwind_entry (output_mem_stack_v (), sep
);
3200 add_unwind_entry (output_psp_sprel (e
.X_add_number
), NOT_A_CHAR
);
3204 dot_save (int dummy ATTRIBUTE_UNUSED
)
3207 unsigned reg1
, reg2
;
3210 if (!in_prologue ("save"))
3213 sep
= parse_operand (&e1
, ',');
3215 sep
= parse_operand (&e2
, ',');
3219 reg1
= e1
.X_add_number
;
3220 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3221 if (e1
.X_op
!= O_register
)
3223 as_bad (_("First operand to .save not a register"));
3224 reg1
= REG_PR
; /* Anything valid is good here. */
3226 reg2
= e2
.X_add_number
- REG_GR
;
3227 if (e2
.X_op
!= O_register
|| reg2
> 127)
3229 as_bad (_("Second operand to .save not a valid register"));
3234 case REG_AR
+ AR_BSP
:
3235 add_unwind_entry (output_bsp_when (), sep
);
3236 add_unwind_entry (output_bsp_gr (reg2
), NOT_A_CHAR
);
3238 case REG_AR
+ AR_BSPSTORE
:
3239 add_unwind_entry (output_bspstore_when (), sep
);
3240 add_unwind_entry (output_bspstore_gr (reg2
), NOT_A_CHAR
);
3242 case REG_AR
+ AR_RNAT
:
3243 add_unwind_entry (output_rnat_when (), sep
);
3244 add_unwind_entry (output_rnat_gr (reg2
), NOT_A_CHAR
);
3246 case REG_AR
+ AR_UNAT
:
3247 add_unwind_entry (output_unat_when (), sep
);
3248 add_unwind_entry (output_unat_gr (reg2
), NOT_A_CHAR
);
3250 case REG_AR
+ AR_FPSR
:
3251 add_unwind_entry (output_fpsr_when (), sep
);
3252 add_unwind_entry (output_fpsr_gr (reg2
), NOT_A_CHAR
);
3254 case REG_AR
+ AR_PFS
:
3255 add_unwind_entry (output_pfs_when (), sep
);
3256 if (! (unwind
.prologue_mask
& 4))
3257 add_unwind_entry (output_pfs_gr (reg2
), NOT_A_CHAR
);
3258 else if (reg2
!= unwind
.prologue_gr
3259 + (unsigned) popcount (unwind
.prologue_mask
& (-4 << 1)))
3260 as_warn (_("Second operand of .save contradicts .prologue"));
3262 case REG_AR
+ AR_LC
:
3263 add_unwind_entry (output_lc_when (), sep
);
3264 add_unwind_entry (output_lc_gr (reg2
), NOT_A_CHAR
);
3267 add_unwind_entry (output_rp_when (), sep
);
3268 if (! (unwind
.prologue_mask
& 8))
3269 add_unwind_entry (output_rp_gr (reg2
), NOT_A_CHAR
);
3270 else if (reg2
!= unwind
.prologue_gr
)
3271 as_warn (_("Second operand of .save contradicts .prologue"));
3274 add_unwind_entry (output_preds_when (), sep
);
3275 if (! (unwind
.prologue_mask
& 1))
3276 add_unwind_entry (output_preds_gr (reg2
), NOT_A_CHAR
);
3277 else if (reg2
!= unwind
.prologue_gr
3278 + (unsigned) popcount (unwind
.prologue_mask
& (-1 << 1)))
3279 as_warn (_("Second operand of .save contradicts .prologue"));
3282 add_unwind_entry (output_priunat_when_gr (), sep
);
3283 add_unwind_entry (output_priunat_gr (reg2
), NOT_A_CHAR
);
3286 as_bad (_("First operand to .save not a valid register"));
3287 add_unwind_entry (NULL
, sep
);
3293 dot_restore (int dummy ATTRIBUTE_UNUSED
)
3296 unsigned long ecount
; /* # of _additional_ regions to pop */
3299 if (!in_body ("restore"))
3302 sep
= parse_operand (&e1
, ',');
3303 if (e1
.X_op
!= O_register
|| e1
.X_add_number
!= REG_GR
+ 12)
3304 as_bad (_("First operand to .restore must be stack pointer (sp)"));
3310 sep
= parse_operand (&e2
, ',');
3311 if (e2
.X_op
!= O_constant
|| e2
.X_add_number
< 0)
3313 as_bad (_("Second operand to .restore must be a constant >= 0"));
3314 e2
.X_add_number
= 0;
3316 ecount
= e2
.X_add_number
;
3319 ecount
= unwind
.prologue_count
- 1;
3321 if (ecount
>= unwind
.prologue_count
)
3323 as_bad (_("Epilogue count of %lu exceeds number of nested prologues (%u)"),
3324 ecount
+ 1, unwind
.prologue_count
);
3328 add_unwind_entry (output_epilogue (ecount
), sep
);
3330 if (ecount
< unwind
.prologue_count
)
3331 unwind
.prologue_count
-= ecount
+ 1;
3333 unwind
.prologue_count
= 0;
3337 dot_restorereg (int pred
)
3339 unsigned int qp
, ab
, reg
;
3342 const char * const po
= pred
? "restorereg.p" : "restorereg";
3344 if (!in_procedure (po
))
3348 sep
= parse_predicate_and_operand (&e
, &qp
, po
);
3351 sep
= parse_operand (&e
, ',');
3354 convert_expr_to_ab_reg (&e
, &ab
, ®
, po
, 1 + pred
);
3356 add_unwind_entry (output_spill_reg (ab
, reg
, 0, 0, qp
), sep
);
3359 static char *special_linkonce_name
[] =
3361 ".gnu.linkonce.ia64unw.", ".gnu.linkonce.ia64unwi."
3365 start_unwind_section (const segT text_seg
, int sec_index
)
3368 Use a slightly ugly scheme to derive the unwind section names from
3369 the text section name:
3371 text sect. unwind table sect.
3372 name: name: comments:
3373 ---------- ----------------- --------------------------------
3375 .text.foo .IA_64.unwind.text.foo
3376 .foo .IA_64.unwind.foo
3378 .gnu.linkonce.ia64unw.foo
3379 _info .IA_64.unwind_info gas issues error message (ditto)
3380 _infoFOO .IA_64.unwind_infoFOO gas issues error message (ditto)
3382 This mapping is done so that:
3384 (a) An object file with unwind info only in .text will use
3385 unwind section names .IA_64.unwind and .IA_64.unwind_info.
3386 This follows the letter of the ABI and also ensures backwards
3387 compatibility with older toolchains.
3389 (b) An object file with unwind info in multiple text sections
3390 will use separate unwind sections for each text section.
3391 This allows us to properly set the "sh_info" and "sh_link"
3392 fields in SHT_IA_64_UNWIND as required by the ABI and also
3393 lets GNU ld support programs with multiple segments
3394 containing unwind info (as might be the case for certain
3395 embedded applications).
3397 (c) An error is issued if there would be a name clash.
3400 const char *text_name
, *sec_text_name
;
3402 const char *prefix
= special_section_name
[sec_index
];
3404 size_t prefix_len
, suffix_len
, sec_name_len
;
3406 sec_text_name
= segment_name (text_seg
);
3407 text_name
= sec_text_name
;
3408 if (strncmp (text_name
, "_info", 5) == 0)
3410 as_bad (_("Illegal section name `%s' (causes unwind section name clash)"),
3412 ignore_rest_of_line ();
3415 if (strcmp (text_name
, ".text") == 0)
3418 /* Build the unwind section name by appending the (possibly stripped)
3419 text section name to the unwind prefix. */
3421 if (strncmp (text_name
, ".gnu.linkonce.t.",
3422 sizeof (".gnu.linkonce.t.") - 1) == 0)
3424 prefix
= special_linkonce_name
[sec_index
- SPECIAL_SECTION_UNWIND
];
3425 suffix
+= sizeof (".gnu.linkonce.t.") - 1;
3428 prefix_len
= strlen (prefix
);
3429 suffix_len
= strlen (suffix
);
3430 sec_name_len
= prefix_len
+ suffix_len
;
3431 sec_name
= alloca (sec_name_len
+ 1);
3432 memcpy (sec_name
, prefix
, prefix_len
);
3433 memcpy (sec_name
+ prefix_len
, suffix
, suffix_len
);
3434 sec_name
[sec_name_len
] = '\0';
3436 /* Handle COMDAT group. */
3437 if ((text_seg
->flags
& SEC_LINK_ONCE
) != 0
3438 && (elf_section_flags (text_seg
) & SHF_GROUP
) != 0)
3441 size_t len
, group_name_len
;
3442 const char *group_name
= elf_group_name (text_seg
);
3444 if (group_name
== NULL
)
3446 as_bad (_("Group section `%s' has no group signature"),
3448 ignore_rest_of_line ();
3451 /* We have to construct a fake section directive. */
3452 group_name_len
= strlen (group_name
);
3454 + 16 /* ,"aG",@progbits, */
3455 + group_name_len
/* ,group_name */
3458 section
= alloca (len
+ 1);
3459 memcpy (section
, sec_name
, sec_name_len
);
3460 memcpy (section
+ sec_name_len
, ",\"aG\",@progbits,", 16);
3461 memcpy (section
+ sec_name_len
+ 16, group_name
, group_name_len
);
3462 memcpy (section
+ len
- 7, ",comdat", 7);
3463 section
[len
] = '\0';
3464 set_section (section
);
3468 set_section (sec_name
);
3469 bfd_set_section_flags (stdoutput
, now_seg
,
3470 SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
);
3473 elf_linked_to_section (now_seg
) = text_seg
;
3477 generate_unwind_image (const segT text_seg
)
3482 /* Mark the end of the unwind info, so that we can compute the size of the
3483 last unwind region. */
3484 add_unwind_entry (output_endp (), NOT_A_CHAR
);
3486 /* Force out pending instructions, to make sure all unwind records have
3487 a valid slot_number field. */
3488 ia64_flush_insns ();
3490 /* Generate the unwind record. */
3491 list
= optimize_unw_records (unwind
.list
);
3492 fixup_unw_records (list
, 1);
3493 size
= calc_record_size (list
);
3495 if (size
> 0 || unwind
.force_unwind_entry
)
3497 unwind
.force_unwind_entry
= 0;
3498 /* pad to pointer-size boundary. */
3499 pad
= size
% md
.pointer_size
;
3501 size
+= md
.pointer_size
- pad
;
3502 /* Add 8 for the header. */
3504 /* Add a pointer for the personality offset. */
3505 if (unwind
.personality_routine
)
3506 size
+= md
.pointer_size
;
3509 /* If there are unwind records, switch sections, and output the info. */
3513 bfd_reloc_code_real_type reloc
;
3515 start_unwind_section (text_seg
, SPECIAL_SECTION_UNWIND_INFO
);
3517 /* Make sure the section has 4 byte alignment for ILP32 and
3518 8 byte alignment for LP64. */
3519 frag_align (md
.pointer_size_shift
, 0, 0);
3520 record_alignment (now_seg
, md
.pointer_size_shift
);
3522 /* Set expression which points to start of unwind descriptor area. */
3523 unwind
.info
= expr_build_dot ();
3525 frag_var (rs_machine_dependent
, size
, size
, 0, 0,
3526 (offsetT
) (long) unwind
.personality_routine
,
3529 /* Add the personality address to the image. */
3530 if (unwind
.personality_routine
!= 0)
3532 exp
.X_op
= O_symbol
;
3533 exp
.X_add_symbol
= unwind
.personality_routine
;
3534 exp
.X_add_number
= 0;
3536 if (md
.flags
& EF_IA_64_BE
)
3538 if (md
.flags
& EF_IA_64_ABI64
)
3539 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64MSB
;
3541 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32MSB
;
3545 if (md
.flags
& EF_IA_64_ABI64
)
3546 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64LSB
;
3548 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32LSB
;
3551 fix_new_exp (frag_now
, frag_now_fix () - md
.pointer_size
,
3552 md
.pointer_size
, &exp
, 0, reloc
);
3553 unwind
.personality_routine
= 0;
3557 free_saved_prologue_counts ();
3558 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
3562 dot_handlerdata (int dummy ATTRIBUTE_UNUSED
)
3564 if (!in_procedure ("handlerdata"))
3566 unwind
.force_unwind_entry
= 1;
3568 /* Remember which segment we're in so we can switch back after .endp */
3569 unwind
.saved_text_seg
= now_seg
;
3570 unwind
.saved_text_subseg
= now_subseg
;
3572 /* Generate unwind info into unwind-info section and then leave that
3573 section as the currently active one so dataXX directives go into
3574 the language specific data area of the unwind info block. */
3575 generate_unwind_image (now_seg
);
3576 demand_empty_rest_of_line ();
3580 dot_unwentry (int dummy ATTRIBUTE_UNUSED
)
3582 if (!in_procedure ("unwentry"))
3584 unwind
.force_unwind_entry
= 1;
3585 demand_empty_rest_of_line ();
3589 dot_altrp (int dummy ATTRIBUTE_UNUSED
)
3594 if (!in_prologue ("altrp"))
3597 parse_operand (&e
, 0);
3598 reg
= e
.X_add_number
- REG_BR
;
3599 if (e
.X_op
!= O_register
|| reg
> 7)
3601 as_bad (_("First operand to .altrp not a valid branch register"));
3604 add_unwind_entry (output_rp_br (reg
), 0);
3608 dot_savemem (int psprel
)
3613 const char * const po
= psprel
? "savepsp" : "savesp";
3615 if (!in_prologue (po
))
3618 sep
= parse_operand (&e1
, ',');
3620 sep
= parse_operand (&e2
, ',');
3624 reg1
= e1
.X_add_number
;
3625 val
= e2
.X_add_number
;
3627 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3628 if (e1
.X_op
!= O_register
)
3630 as_bad (_("First operand to .%s not a register"), po
);
3631 reg1
= REG_PR
; /* Anything valid is good here. */
3633 if (e2
.X_op
!= O_constant
)
3635 as_bad (_("Second operand to .%s not a constant"), po
);
3641 case REG_AR
+ AR_BSP
:
3642 add_unwind_entry (output_bsp_when (), sep
);
3643 add_unwind_entry ((psprel
3645 : output_bsp_sprel
) (val
), NOT_A_CHAR
);
3647 case REG_AR
+ AR_BSPSTORE
:
3648 add_unwind_entry (output_bspstore_when (), sep
);
3649 add_unwind_entry ((psprel
3650 ? output_bspstore_psprel
3651 : output_bspstore_sprel
) (val
), NOT_A_CHAR
);
3653 case REG_AR
+ AR_RNAT
:
3654 add_unwind_entry (output_rnat_when (), sep
);
3655 add_unwind_entry ((psprel
3656 ? output_rnat_psprel
3657 : output_rnat_sprel
) (val
), NOT_A_CHAR
);
3659 case REG_AR
+ AR_UNAT
:
3660 add_unwind_entry (output_unat_when (), sep
);
3661 add_unwind_entry ((psprel
3662 ? output_unat_psprel
3663 : output_unat_sprel
) (val
), NOT_A_CHAR
);
3665 case REG_AR
+ AR_FPSR
:
3666 add_unwind_entry (output_fpsr_when (), sep
);
3667 add_unwind_entry ((psprel
3668 ? output_fpsr_psprel
3669 : output_fpsr_sprel
) (val
), NOT_A_CHAR
);
3671 case REG_AR
+ AR_PFS
:
3672 add_unwind_entry (output_pfs_when (), sep
);
3673 add_unwind_entry ((psprel
3675 : output_pfs_sprel
) (val
), NOT_A_CHAR
);
3677 case REG_AR
+ AR_LC
:
3678 add_unwind_entry (output_lc_when (), sep
);
3679 add_unwind_entry ((psprel
3681 : output_lc_sprel
) (val
), NOT_A_CHAR
);
3684 add_unwind_entry (output_rp_when (), sep
);
3685 add_unwind_entry ((psprel
3687 : output_rp_sprel
) (val
), NOT_A_CHAR
);
3690 add_unwind_entry (output_preds_when (), sep
);
3691 add_unwind_entry ((psprel
3692 ? output_preds_psprel
3693 : output_preds_sprel
) (val
), NOT_A_CHAR
);
3696 add_unwind_entry (output_priunat_when_mem (), sep
);
3697 add_unwind_entry ((psprel
3698 ? output_priunat_psprel
3699 : output_priunat_sprel
) (val
), NOT_A_CHAR
);
3702 as_bad (_("First operand to .%s not a valid register"), po
);
3703 add_unwind_entry (NULL
, sep
);
3709 dot_saveg (int dummy ATTRIBUTE_UNUSED
)
3715 if (!in_prologue ("save.g"))
3718 sep
= parse_operand (&e
, ',');
3720 grmask
= e
.X_add_number
;
3721 if (e
.X_op
!= O_constant
3722 || e
.X_add_number
<= 0
3723 || e
.X_add_number
> 0xf)
3725 as_bad (_("First operand to .save.g must be a positive 4-bit constant"));
3732 int n
= popcount (grmask
);
3734 parse_operand (&e
, 0);
3735 reg
= e
.X_add_number
- REG_GR
;
3736 if (e
.X_op
!= O_register
|| reg
> 127)
3738 as_bad (_("Second operand to .save.g must be a general register"));
3741 else if (reg
> 128U - n
)
3743 as_bad (_("Second operand to .save.g must be the first of %d general registers"), n
);
3746 add_unwind_entry (output_gr_gr (grmask
, reg
), 0);
3749 add_unwind_entry (output_gr_mem (grmask
), 0);
3753 dot_savef (int dummy ATTRIBUTE_UNUSED
)
3757 if (!in_prologue ("save.f"))
3760 parse_operand (&e
, 0);
3762 if (e
.X_op
!= O_constant
3763 || e
.X_add_number
<= 0
3764 || e
.X_add_number
> 0xfffff)
3766 as_bad (_("Operand to .save.f must be a positive 20-bit constant"));
3769 add_unwind_entry (output_fr_mem (e
.X_add_number
), 0);
3773 dot_saveb (int dummy ATTRIBUTE_UNUSED
)
3779 if (!in_prologue ("save.b"))
3782 sep
= parse_operand (&e
, ',');
3784 brmask
= e
.X_add_number
;
3785 if (e
.X_op
!= O_constant
3786 || e
.X_add_number
<= 0
3787 || e
.X_add_number
> 0x1f)
3789 as_bad (_("First operand to .save.b must be a positive 5-bit constant"));
3796 int n
= popcount (brmask
);
3798 parse_operand (&e
, 0);
3799 reg
= e
.X_add_number
- REG_GR
;
3800 if (e
.X_op
!= O_register
|| reg
> 127)
3802 as_bad (_("Second operand to .save.b must be a general register"));
3805 else if (reg
> 128U - n
)
3807 as_bad (_("Second operand to .save.b must be the first of %d general registers"), n
);
3810 add_unwind_entry (output_br_gr (brmask
, reg
), 0);
3813 add_unwind_entry (output_br_mem (brmask
), 0);
3817 dot_savegf (int dummy ATTRIBUTE_UNUSED
)
3821 if (!in_prologue ("save.gf"))
3824 if (parse_operand (&e1
, ',') == ',')
3825 parse_operand (&e2
, 0);
3829 if (e1
.X_op
!= O_constant
3830 || e1
.X_add_number
< 0
3831 || e1
.X_add_number
> 0xf)
3833 as_bad (_("First operand to .save.gf must be a non-negative 4-bit constant"));
3835 e1
.X_add_number
= 0;
3837 if (e2
.X_op
!= O_constant
3838 || e2
.X_add_number
< 0
3839 || e2
.X_add_number
> 0xfffff)
3841 as_bad (_("Second operand to .save.gf must be a non-negative 20-bit constant"));
3843 e2
.X_add_number
= 0;
3845 if (e1
.X_op
== O_constant
3846 && e2
.X_op
== O_constant
3847 && e1
.X_add_number
== 0
3848 && e2
.X_add_number
== 0)
3849 as_bad (_("Operands to .save.gf may not be both zero"));
3851 add_unwind_entry (output_frgr_mem (e1
.X_add_number
, e2
.X_add_number
), 0);
3855 dot_spill (int dummy ATTRIBUTE_UNUSED
)
3859 if (!in_prologue ("spill"))
3862 parse_operand (&e
, 0);
3864 if (e
.X_op
!= O_constant
)
3866 as_bad (_("Operand to .spill must be a constant"));
3869 add_unwind_entry (output_spill_base (e
.X_add_number
), 0);
3873 dot_spillreg (int pred
)
3876 unsigned int qp
, ab
, xy
, reg
, treg
;
3878 const char * const po
= pred
? "spillreg.p" : "spillreg";
3880 if (!in_procedure (po
))
3884 sep
= parse_predicate_and_operand (&e
, &qp
, po
);
3887 sep
= parse_operand (&e
, ',');
3890 convert_expr_to_ab_reg (&e
, &ab
, ®
, po
, 1 + pred
);
3893 sep
= parse_operand (&e
, ',');
3896 convert_expr_to_xy_reg (&e
, &xy
, &treg
, po
, 2 + pred
);
3898 add_unwind_entry (output_spill_reg (ab
, reg
, treg
, xy
, qp
), sep
);
3902 dot_spillmem (int psprel
)
3905 int pred
= (psprel
< 0), sep
;
3906 unsigned int qp
, ab
, reg
;
3912 po
= psprel
? "spillpsp.p" : "spillsp.p";
3915 po
= psprel
? "spillpsp" : "spillsp";
3917 if (!in_procedure (po
))
3921 sep
= parse_predicate_and_operand (&e
, &qp
, po
);
3924 sep
= parse_operand (&e
, ',');
3927 convert_expr_to_ab_reg (&e
, &ab
, ®
, po
, 1 + pred
);
3930 sep
= parse_operand (&e
, ',');
3933 if (e
.X_op
!= O_constant
)
3935 as_bad (_("Operand %d to .%s must be a constant"), 2 + pred
, po
);
3940 add_unwind_entry (output_spill_psprel (ab
, reg
, e
.X_add_number
, qp
), sep
);
3942 add_unwind_entry (output_spill_sprel (ab
, reg
, e
.X_add_number
, qp
), sep
);
3946 get_saved_prologue_count (unsigned long lbl
)
3948 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3950 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
3954 return lpc
->prologue_count
;
3956 as_bad (_("Missing .label_state %ld"), lbl
);
3961 save_prologue_count (unsigned long lbl
, unsigned int count
)
3963 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3965 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
3969 lpc
->prologue_count
= count
;
3972 label_prologue_count
*new_lpc
= xmalloc (sizeof (* new_lpc
));
3974 new_lpc
->next
= unwind
.saved_prologue_counts
;
3975 new_lpc
->label_number
= lbl
;
3976 new_lpc
->prologue_count
= count
;
3977 unwind
.saved_prologue_counts
= new_lpc
;
3982 free_saved_prologue_counts ()
3984 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3985 label_prologue_count
*next
;
3994 unwind
.saved_prologue_counts
= NULL
;
3998 dot_label_state (int dummy ATTRIBUTE_UNUSED
)
4002 if (!in_body ("label_state"))
4005 parse_operand (&e
, 0);
4006 if (e
.X_op
== O_constant
)
4007 save_prologue_count (e
.X_add_number
, unwind
.prologue_count
);
4010 as_bad (_("Operand to .label_state must be a constant"));
4013 add_unwind_entry (output_label_state (e
.X_add_number
), 0);
4017 dot_copy_state (int dummy ATTRIBUTE_UNUSED
)
4021 if (!in_body ("copy_state"))
4024 parse_operand (&e
, 0);
4025 if (e
.X_op
== O_constant
)
4026 unwind
.prologue_count
= get_saved_prologue_count (e
.X_add_number
);
4029 as_bad (_("Operand to .copy_state must be a constant"));
4032 add_unwind_entry (output_copy_state (e
.X_add_number
), 0);
4036 dot_unwabi (int dummy ATTRIBUTE_UNUSED
)
4041 if (!in_prologue ("unwabi"))
4044 sep
= parse_operand (&e1
, ',');
4046 parse_operand (&e2
, 0);
4050 if (e1
.X_op
!= O_constant
)
4052 as_bad (_("First operand to .unwabi must be a constant"));
4053 e1
.X_add_number
= 0;
4056 if (e2
.X_op
!= O_constant
)
4058 as_bad (_("Second operand to .unwabi must be a constant"));
4059 e2
.X_add_number
= 0;
4062 add_unwind_entry (output_unwabi (e1
.X_add_number
, e2
.X_add_number
), 0);
4066 dot_personality (int dummy ATTRIBUTE_UNUSED
)
4069 if (!in_procedure ("personality"))
4072 name
= input_line_pointer
;
4073 c
= get_symbol_end ();
4074 p
= input_line_pointer
;
4075 unwind
.personality_routine
= symbol_find_or_make (name
);
4076 unwind
.force_unwind_entry
= 1;
4079 demand_empty_rest_of_line ();
4083 dot_proc (int dummy ATTRIBUTE_UNUSED
)
4087 proc_pending
*pending
, *last_pending
;
4089 if (unwind
.proc_pending
.sym
)
4091 (md
.unwind_check
== unwind_check_warning
4093 : as_bad
) (_("Missing .endp after previous .proc"));
4094 while (unwind
.proc_pending
.next
)
4096 pending
= unwind
.proc_pending
.next
;
4097 unwind
.proc_pending
.next
= pending
->next
;
4101 last_pending
= NULL
;
4103 /* Parse names of main and alternate entry points and mark them as
4104 function symbols: */
4108 name
= input_line_pointer
;
4109 c
= get_symbol_end ();
4110 p
= input_line_pointer
;
4112 as_bad (_("Empty argument of .proc"));
4115 sym
= symbol_find_or_make (name
);
4116 if (S_IS_DEFINED (sym
))
4117 as_bad (_("`%s' was already defined"), name
);
4118 else if (!last_pending
)
4120 unwind
.proc_pending
.sym
= sym
;
4121 last_pending
= &unwind
.proc_pending
;
4125 pending
= xmalloc (sizeof (*pending
));
4127 last_pending
= last_pending
->next
= pending
;
4129 symbol_get_bfdsym (sym
)->flags
|= BSF_FUNCTION
;
4133 if (*input_line_pointer
!= ',')
4135 ++input_line_pointer
;
4139 unwind
.proc_pending
.sym
= expr_build_dot ();
4140 last_pending
= &unwind
.proc_pending
;
4142 last_pending
->next
= NULL
;
4143 demand_empty_rest_of_line ();
4146 unwind
.prologue
= 0;
4147 unwind
.prologue_count
= 0;
4150 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
4151 unwind
.personality_routine
= 0;
4155 dot_body (int dummy ATTRIBUTE_UNUSED
)
4157 if (!in_procedure ("body"))
4159 if (!unwind
.prologue
&& !unwind
.body
&& unwind
.insn
)
4160 as_warn (_("Initial .body should precede any instructions"));
4161 check_pending_save ();
4163 unwind
.prologue
= 0;
4164 unwind
.prologue_mask
= 0;
4167 add_unwind_entry (output_body (), 0);
4171 dot_prologue (int dummy ATTRIBUTE_UNUSED
)
4173 unsigned mask
= 0, grsave
= 0;
4175 if (!in_procedure ("prologue"))
4177 if (unwind
.prologue
)
4179 as_bad (_(".prologue within prologue"));
4180 ignore_rest_of_line ();
4183 if (!unwind
.body
&& unwind
.insn
)
4184 as_warn (_("Initial .prologue should precede any instructions"));
4186 if (!is_it_end_of_statement ())
4189 int n
, sep
= parse_operand (&e
, ',');
4191 if (e
.X_op
!= O_constant
4192 || e
.X_add_number
< 0
4193 || e
.X_add_number
> 0xf)
4194 as_bad (_("First operand to .prologue must be a positive 4-bit constant"));
4195 else if (e
.X_add_number
== 0)
4196 as_warn (_("Pointless use of zero first operand to .prologue"));
4198 mask
= e
.X_add_number
;
4199 n
= popcount (mask
);
4202 parse_operand (&e
, 0);
4205 if (e
.X_op
== O_constant
4206 && e
.X_add_number
>= 0
4207 && e
.X_add_number
< 128)
4209 if (md
.unwind_check
== unwind_check_error
)
4210 as_warn (_("Using a constant as second operand to .prologue is deprecated"));
4211 grsave
= e
.X_add_number
;
4213 else if (e
.X_op
!= O_register
4214 || (grsave
= e
.X_add_number
- REG_GR
) > 127)
4216 as_bad (_("Second operand to .prologue must be a general register"));
4219 else if (grsave
> 128U - n
)
4221 as_bad (_("Second operand to .prologue must be the first of %d general registers"), n
);
4228 add_unwind_entry (output_prologue_gr (mask
, grsave
), 0);
4230 add_unwind_entry (output_prologue (), 0);
4232 unwind
.prologue
= 1;
4233 unwind
.prologue_mask
= mask
;
4234 unwind
.prologue_gr
= grsave
;
4236 ++unwind
.prologue_count
;
4240 dot_endp (int dummy ATTRIBUTE_UNUSED
)
4243 int bytes_per_address
;
4246 subsegT saved_subseg
;
4247 proc_pending
*pending
;
4248 int unwind_check
= md
.unwind_check
;
4250 md
.unwind_check
= unwind_check_error
;
4251 if (!in_procedure ("endp"))
4253 md
.unwind_check
= unwind_check
;
4255 if (unwind
.saved_text_seg
)
4257 saved_seg
= unwind
.saved_text_seg
;
4258 saved_subseg
= unwind
.saved_text_subseg
;
4259 unwind
.saved_text_seg
= NULL
;
4263 saved_seg
= now_seg
;
4264 saved_subseg
= now_subseg
;
4267 insn_group_break (1, 0, 0);
4269 /* If there wasn't a .handlerdata, we haven't generated an image yet. */
4271 generate_unwind_image (saved_seg
);
4273 if (unwind
.info
|| unwind
.force_unwind_entry
)
4277 subseg_set (md
.last_text_seg
, 0);
4278 proc_end
= expr_build_dot ();
4280 start_unwind_section (saved_seg
, SPECIAL_SECTION_UNWIND
);
4282 /* Make sure that section has 4 byte alignment for ILP32 and
4283 8 byte alignment for LP64. */
4284 record_alignment (now_seg
, md
.pointer_size_shift
);
4286 /* Need space for 3 pointers for procedure start, procedure end,
4288 memset (frag_more (3 * md
.pointer_size
), 0, 3 * md
.pointer_size
);
4289 where
= frag_now_fix () - (3 * md
.pointer_size
);
4290 bytes_per_address
= bfd_arch_bits_per_address (stdoutput
) / 8;
4292 /* Issue the values of a) Proc Begin, b) Proc End, c) Unwind Record. */
4293 e
.X_op
= O_pseudo_fixup
;
4294 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4296 if (!S_IS_LOCAL (unwind
.proc_pending
.sym
)
4297 && S_IS_DEFINED (unwind
.proc_pending
.sym
))
4298 e
.X_add_symbol
= symbol_temp_new (S_GET_SEGMENT (unwind
.proc_pending
.sym
),
4299 S_GET_VALUE (unwind
.proc_pending
.sym
),
4300 symbol_get_frag (unwind
.proc_pending
.sym
));
4302 e
.X_add_symbol
= unwind
.proc_pending
.sym
;
4303 ia64_cons_fix_new (frag_now
, where
, bytes_per_address
, &e
);
4305 e
.X_op
= O_pseudo_fixup
;
4306 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4308 e
.X_add_symbol
= proc_end
;
4309 ia64_cons_fix_new (frag_now
, where
+ bytes_per_address
,
4310 bytes_per_address
, &e
);
4314 e
.X_op
= O_pseudo_fixup
;
4315 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4317 e
.X_add_symbol
= unwind
.info
;
4318 ia64_cons_fix_new (frag_now
, where
+ (bytes_per_address
* 2),
4319 bytes_per_address
, &e
);
4322 subseg_set (saved_seg
, saved_subseg
);
4324 /* Set symbol sizes. */
4325 pending
= &unwind
.proc_pending
;
4326 if (S_GET_NAME (pending
->sym
))
4330 symbolS
*sym
= pending
->sym
;
4332 if (!S_IS_DEFINED (sym
))
4333 as_bad (_("`%s' was not defined within procedure"), S_GET_NAME (sym
));
4334 else if (S_GET_SIZE (sym
) == 0
4335 && symbol_get_obj (sym
)->size
== NULL
)
4337 fragS
*frag
= symbol_get_frag (sym
);
4341 if (frag
== frag_now
&& SEG_NORMAL (now_seg
))
4342 S_SET_SIZE (sym
, frag_now_fix () - S_GET_VALUE (sym
));
4345 symbol_get_obj (sym
)->size
=
4346 (expressionS
*) xmalloc (sizeof (expressionS
));
4347 symbol_get_obj (sym
)->size
->X_op
= O_subtract
;
4348 symbol_get_obj (sym
)->size
->X_add_symbol
4349 = symbol_new (FAKE_LABEL_NAME
, now_seg
,
4350 frag_now_fix (), frag_now
);
4351 symbol_get_obj (sym
)->size
->X_op_symbol
= sym
;
4352 symbol_get_obj (sym
)->size
->X_add_number
= 0;
4356 } while ((pending
= pending
->next
) != NULL
);
4359 /* Parse names of main and alternate entry points. */
4365 name
= input_line_pointer
;
4366 c
= get_symbol_end ();
4367 p
= input_line_pointer
;
4369 (md
.unwind_check
== unwind_check_warning
4371 : as_bad
) (_("Empty argument of .endp"));
4374 symbolS
*sym
= symbol_find (name
);
4376 for (pending
= &unwind
.proc_pending
; pending
; pending
= pending
->next
)
4378 if (sym
== pending
->sym
)
4380 pending
->sym
= NULL
;
4384 if (!sym
|| !pending
)
4385 as_warn (_("`%s' was not specified with previous .proc"), name
);
4389 if (*input_line_pointer
!= ',')
4391 ++input_line_pointer
;
4393 demand_empty_rest_of_line ();
4395 /* Deliberately only checking for the main entry point here; the
4396 language spec even says all arguments to .endp are ignored. */
4397 if (unwind
.proc_pending
.sym
4398 && S_GET_NAME (unwind
.proc_pending
.sym
)
4399 && strcmp (S_GET_NAME (unwind
.proc_pending
.sym
), FAKE_LABEL_NAME
))
4400 as_warn (_("`%s' should be an operand to this .endp"),
4401 S_GET_NAME (unwind
.proc_pending
.sym
));
4402 while (unwind
.proc_pending
.next
)
4404 pending
= unwind
.proc_pending
.next
;
4405 unwind
.proc_pending
.next
= pending
->next
;
4408 unwind
.proc_pending
.sym
= unwind
.info
= NULL
;
4412 dot_template (int template)
4414 CURR_SLOT
.user_template
= template;
4418 dot_regstk (int dummy ATTRIBUTE_UNUSED
)
4420 int ins
, locs
, outs
, rots
;
4422 if (is_it_end_of_statement ())
4423 ins
= locs
= outs
= rots
= 0;
4426 ins
= get_absolute_expression ();
4427 if (*input_line_pointer
++ != ',')
4429 locs
= get_absolute_expression ();
4430 if (*input_line_pointer
++ != ',')
4432 outs
= get_absolute_expression ();
4433 if (*input_line_pointer
++ != ',')
4435 rots
= get_absolute_expression ();
4437 set_regstack (ins
, locs
, outs
, rots
);
4441 as_bad (_("Comma expected"));
4442 ignore_rest_of_line ();
4449 valueT num_alloced
= 0;
4450 struct dynreg
**drpp
, *dr
;
4451 int ch
, base_reg
= 0;
4457 case DYNREG_GR
: base_reg
= REG_GR
+ 32; break;
4458 case DYNREG_FR
: base_reg
= REG_FR
+ 32; break;
4459 case DYNREG_PR
: base_reg
= REG_P
+ 16; break;
4463 /* First, remove existing names from hash table. */
4464 for (dr
= md
.dynreg
[type
]; dr
&& dr
->num_regs
; dr
= dr
->next
)
4466 hash_delete (md
.dynreg_hash
, dr
->name
, FALSE
);
4467 /* FIXME: Free dr->name. */
4471 drpp
= &md
.dynreg
[type
];
4474 start
= input_line_pointer
;
4475 ch
= get_symbol_end ();
4476 len
= strlen (ia64_canonicalize_symbol_name (start
));
4477 *input_line_pointer
= ch
;
4480 if (*input_line_pointer
!= '[')
4482 as_bad (_("Expected '['"));
4485 ++input_line_pointer
; /* skip '[' */
4487 num_regs
= get_absolute_expression ();
4489 if (*input_line_pointer
++ != ']')
4491 as_bad (_("Expected ']'"));
4496 as_bad (_("Number of elements must be positive"));
4501 num_alloced
+= num_regs
;
4505 if (num_alloced
> md
.rot
.num_regs
)
4507 as_bad (_("Used more than the declared %d rotating registers"),
4513 if (num_alloced
> 96)
4515 as_bad (_("Used more than the available 96 rotating registers"));
4520 if (num_alloced
> 48)
4522 as_bad (_("Used more than the available 48 rotating registers"));
4533 *drpp
= obstack_alloc (¬es
, sizeof (*dr
));
4534 memset (*drpp
, 0, sizeof (*dr
));
4537 name
= obstack_alloc (¬es
, len
+ 1);
4538 memcpy (name
, start
, len
);
4543 dr
->num_regs
= num_regs
;
4544 dr
->base
= base_reg
;
4546 base_reg
+= num_regs
;
4548 if (hash_insert (md
.dynreg_hash
, name
, dr
))
4550 as_bad (_("Attempt to redefine register set `%s'"), name
);
4551 obstack_free (¬es
, name
);
4555 if (*input_line_pointer
!= ',')
4557 ++input_line_pointer
; /* skip comma */
4560 demand_empty_rest_of_line ();
4564 ignore_rest_of_line ();
4568 dot_byteorder (int byteorder
)
4570 segment_info_type
*seginfo
= seg_info (now_seg
);
4572 if (byteorder
== -1)
4574 if (seginfo
->tc_segment_info_data
.endian
== 0)
4575 seginfo
->tc_segment_info_data
.endian
= default_big_endian
? 1 : 2;
4576 byteorder
= seginfo
->tc_segment_info_data
.endian
== 1;
4579 seginfo
->tc_segment_info_data
.endian
= byteorder
? 1 : 2;
4581 if (target_big_endian
!= byteorder
)
4583 target_big_endian
= byteorder
;
4584 if (target_big_endian
)
4586 ia64_number_to_chars
= number_to_chars_bigendian
;
4587 ia64_float_to_chars
= ia64_float_to_chars_bigendian
;
4591 ia64_number_to_chars
= number_to_chars_littleendian
;
4592 ia64_float_to_chars
= ia64_float_to_chars_littleendian
;
4598 dot_psr (int dummy ATTRIBUTE_UNUSED
)
4605 option
= input_line_pointer
;
4606 ch
= get_symbol_end ();
4607 if (strcmp (option
, "lsb") == 0)
4608 md
.flags
&= ~EF_IA_64_BE
;
4609 else if (strcmp (option
, "msb") == 0)
4610 md
.flags
|= EF_IA_64_BE
;
4611 else if (strcmp (option
, "abi32") == 0)
4612 md
.flags
&= ~EF_IA_64_ABI64
;
4613 else if (strcmp (option
, "abi64") == 0)
4614 md
.flags
|= EF_IA_64_ABI64
;
4616 as_bad (_("Unknown psr option `%s'"), option
);
4617 *input_line_pointer
= ch
;
4620 if (*input_line_pointer
!= ',')
4623 ++input_line_pointer
;
4626 demand_empty_rest_of_line ();
4630 dot_ln (int dummy ATTRIBUTE_UNUSED
)
4632 new_logical_line (0, get_absolute_expression ());
4633 demand_empty_rest_of_line ();
4637 cross_section (int ref
, void (*cons
) (int), int ua
)
4640 int saved_auto_align
;
4641 unsigned int section_count
;
4644 start
= input_line_pointer
;
4650 name
= demand_copy_C_string (&len
);
4651 obstack_free(¬es
, name
);
4654 ignore_rest_of_line ();
4660 char c
= get_symbol_end ();
4662 if (input_line_pointer
== start
)
4664 as_bad (_("Missing section name"));
4665 ignore_rest_of_line ();
4668 *input_line_pointer
= c
;
4670 end
= input_line_pointer
;
4672 if (*input_line_pointer
!= ',')
4674 as_bad (_("Comma expected after section name"));
4675 ignore_rest_of_line ();
4679 end
= input_line_pointer
+ 1; /* skip comma */
4680 input_line_pointer
= start
;
4681 md
.keep_pending_output
= 1;
4682 section_count
= bfd_count_sections(stdoutput
);
4683 obj_elf_section (0);
4684 if (section_count
!= bfd_count_sections(stdoutput
))
4685 as_warn (_("Creating sections with .xdataN/.xrealN/.xstringZ is deprecated."));
4686 input_line_pointer
= end
;
4687 saved_auto_align
= md
.auto_align
;
4692 md
.auto_align
= saved_auto_align
;
4693 obj_elf_previous (0);
4694 md
.keep_pending_output
= 0;
4698 dot_xdata (int size
)
4700 cross_section (size
, cons
, 0);
4703 /* Why doesn't float_cons() call md_cons_align() the way cons() does? */
4706 stmt_float_cons (int kind
)
4726 ia64_do_align (alignment
);
4731 stmt_cons_ua (int size
)
4733 int saved_auto_align
= md
.auto_align
;
4737 md
.auto_align
= saved_auto_align
;
4741 dot_xfloat_cons (int kind
)
4743 cross_section (kind
, stmt_float_cons
, 0);
4747 dot_xstringer (int zero
)
4749 cross_section (zero
, stringer
, 0);
4753 dot_xdata_ua (int size
)
4755 cross_section (size
, cons
, 1);
4759 dot_xfloat_cons_ua (int kind
)
4761 cross_section (kind
, float_cons
, 1);
4764 /* .reg.val <regname>,value */
4767 dot_reg_val (int dummy ATTRIBUTE_UNUSED
)
4771 expression_and_evaluate (®
);
4772 if (reg
.X_op
!= O_register
)
4774 as_bad (_("Register name expected"));
4775 ignore_rest_of_line ();
4777 else if (*input_line_pointer
++ != ',')
4779 as_bad (_("Comma expected"));
4780 ignore_rest_of_line ();
4784 valueT value
= get_absolute_expression ();
4785 int regno
= reg
.X_add_number
;
4786 if (regno
<= REG_GR
|| regno
> REG_GR
+ 127)
4787 as_warn (_("Register value annotation ignored"));
4790 gr_values
[regno
- REG_GR
].known
= 1;
4791 gr_values
[regno
- REG_GR
].value
= value
;
4792 gr_values
[regno
- REG_GR
].path
= md
.path
;
4795 demand_empty_rest_of_line ();
4800 .serialize.instruction
4803 dot_serialize (int type
)
4805 insn_group_break (0, 0, 0);
4807 instruction_serialization ();
4809 data_serialization ();
4810 insn_group_break (0, 0, 0);
4811 demand_empty_rest_of_line ();
4814 /* select dv checking mode
4819 A stop is inserted when changing modes
4823 dot_dv_mode (int type
)
4825 if (md
.manual_bundling
)
4826 as_warn (_("Directive invalid within a bundle"));
4828 if (type
== 'E' || type
== 'A')
4829 md
.mode_explicitly_set
= 0;
4831 md
.mode_explicitly_set
= 1;
4838 if (md
.explicit_mode
)
4839 insn_group_break (1, 0, 0);
4840 md
.explicit_mode
= 0;
4844 if (!md
.explicit_mode
)
4845 insn_group_break (1, 0, 0);
4846 md
.explicit_mode
= 1;
4850 if (md
.explicit_mode
!= md
.default_explicit_mode
)
4851 insn_group_break (1, 0, 0);
4852 md
.explicit_mode
= md
.default_explicit_mode
;
4853 md
.mode_explicitly_set
= 0;
4859 print_prmask (valueT mask
)
4863 for (regno
= 0; regno
< 64; regno
++)
4865 if (mask
& ((valueT
) 1 << regno
))
4867 fprintf (stderr
, "%s p%d", comma
, regno
);
4874 .pred.rel.clear [p1 [,p2 [,...]]] (also .pred.rel "clear" or @clear)
4875 .pred.rel.imply p1, p2 (also .pred.rel "imply" or @imply)
4876 .pred.rel.mutex p1, p2 [,...] (also .pred.rel "mutex" or @mutex)
4877 .pred.safe_across_calls p1 [, p2 [,...]]
4881 dot_pred_rel (int type
)
4885 int p1
= -1, p2
= -1;
4889 if (*input_line_pointer
== '"')
4892 char *form
= demand_copy_C_string (&len
);
4894 if (strcmp (form
, "mutex") == 0)
4896 else if (strcmp (form
, "clear") == 0)
4898 else if (strcmp (form
, "imply") == 0)
4900 obstack_free (¬es
, form
);
4902 else if (*input_line_pointer
== '@')
4904 char *form
= ++input_line_pointer
;
4905 char c
= get_symbol_end();
4907 if (strcmp (form
, "mutex") == 0)
4909 else if (strcmp (form
, "clear") == 0)
4911 else if (strcmp (form
, "imply") == 0)
4913 *input_line_pointer
= c
;
4917 as_bad (_("Missing predicate relation type"));
4918 ignore_rest_of_line ();
4923 as_bad (_("Unrecognized predicate relation type"));
4924 ignore_rest_of_line ();
4927 if (*input_line_pointer
== ',')
4928 ++input_line_pointer
;
4936 expressionS pr
, *pr1
, *pr2
;
4938 sep
= parse_operand (&pr
, ',');
4939 if (pr
.X_op
== O_register
4940 && pr
.X_add_number
>= REG_P
4941 && pr
.X_add_number
<= REG_P
+ 63)
4943 regno
= pr
.X_add_number
- REG_P
;
4951 else if (type
!= 'i'
4952 && pr
.X_op
== O_subtract
4953 && (pr1
= symbol_get_value_expression (pr
.X_add_symbol
))
4954 && pr1
->X_op
== O_register
4955 && pr1
->X_add_number
>= REG_P
4956 && pr1
->X_add_number
<= REG_P
+ 63
4957 && (pr2
= symbol_get_value_expression (pr
.X_op_symbol
))
4958 && pr2
->X_op
== O_register
4959 && pr2
->X_add_number
>= REG_P
4960 && pr2
->X_add_number
<= REG_P
+ 63)
4965 regno
= pr1
->X_add_number
- REG_P
;
4966 stop
= pr2
->X_add_number
- REG_P
;
4969 as_bad (_("Bad register range"));
4970 ignore_rest_of_line ();
4973 bits
= ((bits
<< stop
) << 1) - (bits
<< regno
);
4974 count
+= stop
- regno
+ 1;
4978 as_bad (_("Predicate register expected"));
4979 ignore_rest_of_line ();
4983 as_warn (_("Duplicate predicate register ignored"));
4994 clear_qp_mutex (mask
);
4995 clear_qp_implies (mask
, (valueT
) 0);
4998 if (count
!= 2 || p1
== -1 || p2
== -1)
4999 as_bad (_("Predicate source and target required"));
5000 else if (p1
== 0 || p2
== 0)
5001 as_bad (_("Use of p0 is not valid in this context"));
5003 add_qp_imply (p1
, p2
);
5008 as_bad (_("At least two PR arguments expected"));
5013 as_bad (_("Use of p0 is not valid in this context"));
5016 add_qp_mutex (mask
);
5019 /* note that we don't override any existing relations */
5022 as_bad (_("At least one PR argument expected"));
5027 fprintf (stderr
, "Safe across calls: ");
5028 print_prmask (mask
);
5029 fprintf (stderr
, "\n");
5031 qp_safe_across_calls
= mask
;
5034 demand_empty_rest_of_line ();
5037 /* .entry label [, label [, ...]]
5038 Hint to DV code that the given labels are to be considered entry points.
5039 Otherwise, only global labels are considered entry points. */
5042 dot_entry (int dummy ATTRIBUTE_UNUSED
)
5051 name
= input_line_pointer
;
5052 c
= get_symbol_end ();
5053 symbolP
= symbol_find_or_make (name
);
5055 err
= hash_insert (md
.entry_hash
, S_GET_NAME (symbolP
), (void *) symbolP
);
5057 as_fatal (_("Inserting \"%s\" into entry hint table failed: %s"),
5060 *input_line_pointer
= c
;
5062 c
= *input_line_pointer
;
5065 input_line_pointer
++;
5067 if (*input_line_pointer
== '\n')
5073 demand_empty_rest_of_line ();
5076 /* .mem.offset offset, base
5077 "base" is used to distinguish between offsets from a different base. */
5080 dot_mem_offset (int dummy ATTRIBUTE_UNUSED
)
5082 md
.mem_offset
.hint
= 1;
5083 md
.mem_offset
.offset
= get_absolute_expression ();
5084 if (*input_line_pointer
!= ',')
5086 as_bad (_("Comma expected"));
5087 ignore_rest_of_line ();
5090 ++input_line_pointer
;
5091 md
.mem_offset
.base
= get_absolute_expression ();
5092 demand_empty_rest_of_line ();
5095 /* ia64-specific pseudo-ops: */
5096 const pseudo_typeS md_pseudo_table
[] =
5098 { "radix", dot_radix
, 0 },
5099 { "lcomm", s_lcomm_bytes
, 1 },
5100 { "loc", dot_loc
, 0 },
5101 { "bss", dot_special_section
, SPECIAL_SECTION_BSS
},
5102 { "sbss", dot_special_section
, SPECIAL_SECTION_SBSS
},
5103 { "sdata", dot_special_section
, SPECIAL_SECTION_SDATA
},
5104 { "rodata", dot_special_section
, SPECIAL_SECTION_RODATA
},
5105 { "comment", dot_special_section
, SPECIAL_SECTION_COMMENT
},
5106 { "ia_64.unwind", dot_special_section
, SPECIAL_SECTION_UNWIND
},
5107 { "ia_64.unwind_info", dot_special_section
, SPECIAL_SECTION_UNWIND_INFO
},
5108 { "init_array", dot_special_section
, SPECIAL_SECTION_INIT_ARRAY
},
5109 { "fini_array", dot_special_section
, SPECIAL_SECTION_FINI_ARRAY
},
5110 { "proc", dot_proc
, 0 },
5111 { "body", dot_body
, 0 },
5112 { "prologue", dot_prologue
, 0 },
5113 { "endp", dot_endp
, 0 },
5115 { "fframe", dot_fframe
, 0 },
5116 { "vframe", dot_vframe
, 0 },
5117 { "vframesp", dot_vframesp
, 0 },
5118 { "vframepsp", dot_vframesp
, 1 },
5119 { "save", dot_save
, 0 },
5120 { "restore", dot_restore
, 0 },
5121 { "restorereg", dot_restorereg
, 0 },
5122 { "restorereg.p", dot_restorereg
, 1 },
5123 { "handlerdata", dot_handlerdata
, 0 },
5124 { "unwentry", dot_unwentry
, 0 },
5125 { "altrp", dot_altrp
, 0 },
5126 { "savesp", dot_savemem
, 0 },
5127 { "savepsp", dot_savemem
, 1 },
5128 { "save.g", dot_saveg
, 0 },
5129 { "save.f", dot_savef
, 0 },
5130 { "save.b", dot_saveb
, 0 },
5131 { "save.gf", dot_savegf
, 0 },
5132 { "spill", dot_spill
, 0 },
5133 { "spillreg", dot_spillreg
, 0 },
5134 { "spillsp", dot_spillmem
, 0 },
5135 { "spillpsp", dot_spillmem
, 1 },
5136 { "spillreg.p", dot_spillreg
, 1 },
5137 { "spillsp.p", dot_spillmem
, ~0 },
5138 { "spillpsp.p", dot_spillmem
, ~1 },
5139 { "label_state", dot_label_state
, 0 },
5140 { "copy_state", dot_copy_state
, 0 },
5141 { "unwabi", dot_unwabi
, 0 },
5142 { "personality", dot_personality
, 0 },
5143 { "mii", dot_template
, 0x0 },
5144 { "mli", dot_template
, 0x2 }, /* old format, for compatibility */
5145 { "mlx", dot_template
, 0x2 },
5146 { "mmi", dot_template
, 0x4 },
5147 { "mfi", dot_template
, 0x6 },
5148 { "mmf", dot_template
, 0x7 },
5149 { "mib", dot_template
, 0x8 },
5150 { "mbb", dot_template
, 0x9 },
5151 { "bbb", dot_template
, 0xb },
5152 { "mmb", dot_template
, 0xc },
5153 { "mfb", dot_template
, 0xe },
5154 { "align", dot_align
, 0 },
5155 { "regstk", dot_regstk
, 0 },
5156 { "rotr", dot_rot
, DYNREG_GR
},
5157 { "rotf", dot_rot
, DYNREG_FR
},
5158 { "rotp", dot_rot
, DYNREG_PR
},
5159 { "lsb", dot_byteorder
, 0 },
5160 { "msb", dot_byteorder
, 1 },
5161 { "psr", dot_psr
, 0 },
5162 { "alias", dot_alias
, 0 },
5163 { "secalias", dot_alias
, 1 },
5164 { "ln", dot_ln
, 0 }, /* source line info (for debugging) */
5166 { "xdata1", dot_xdata
, 1 },
5167 { "xdata2", dot_xdata
, 2 },
5168 { "xdata4", dot_xdata
, 4 },
5169 { "xdata8", dot_xdata
, 8 },
5170 { "xdata16", dot_xdata
, 16 },
5171 { "xreal4", dot_xfloat_cons
, 'f' },
5172 { "xreal8", dot_xfloat_cons
, 'd' },
5173 { "xreal10", dot_xfloat_cons
, 'x' },
5174 { "xreal16", dot_xfloat_cons
, 'X' },
5175 { "xstring", dot_xstringer
, 8 + 0 },
5176 { "xstringz", dot_xstringer
, 8 + 1 },
5178 /* unaligned versions: */
5179 { "xdata2.ua", dot_xdata_ua
, 2 },
5180 { "xdata4.ua", dot_xdata_ua
, 4 },
5181 { "xdata8.ua", dot_xdata_ua
, 8 },
5182 { "xdata16.ua", dot_xdata_ua
, 16 },
5183 { "xreal4.ua", dot_xfloat_cons_ua
, 'f' },
5184 { "xreal8.ua", dot_xfloat_cons_ua
, 'd' },
5185 { "xreal10.ua", dot_xfloat_cons_ua
, 'x' },
5186 { "xreal16.ua", dot_xfloat_cons_ua
, 'X' },
5188 /* annotations/DV checking support */
5189 { "entry", dot_entry
, 0 },
5190 { "mem.offset", dot_mem_offset
, 0 },
5191 { "pred.rel", dot_pred_rel
, 0 },
5192 { "pred.rel.clear", dot_pred_rel
, 'c' },
5193 { "pred.rel.imply", dot_pred_rel
, 'i' },
5194 { "pred.rel.mutex", dot_pred_rel
, 'm' },
5195 { "pred.safe_across_calls", dot_pred_rel
, 's' },
5196 { "reg.val", dot_reg_val
, 0 },
5197 { "serialize.data", dot_serialize
, 0 },
5198 { "serialize.instruction", dot_serialize
, 1 },
5199 { "auto", dot_dv_mode
, 'a' },
5200 { "explicit", dot_dv_mode
, 'e' },
5201 { "default", dot_dv_mode
, 'd' },
5203 /* ??? These are needed to make gas/testsuite/gas/elf/ehopt.s work.
5204 IA-64 aligns data allocation pseudo-ops by default, so we have to
5205 tell it that these ones are supposed to be unaligned. Long term,
5206 should rewrite so that only IA-64 specific data allocation pseudo-ops
5207 are aligned by default. */
5208 {"2byte", stmt_cons_ua
, 2},
5209 {"4byte", stmt_cons_ua
, 4},
5210 {"8byte", stmt_cons_ua
, 8},
5215 static const struct pseudo_opcode
5218 void (*handler
) (int);
5223 /* these are more like pseudo-ops, but don't start with a dot */
5224 { "data1", cons
, 1 },
5225 { "data2", cons
, 2 },
5226 { "data4", cons
, 4 },
5227 { "data8", cons
, 8 },
5228 { "data16", cons
, 16 },
5229 { "real4", stmt_float_cons
, 'f' },
5230 { "real8", stmt_float_cons
, 'd' },
5231 { "real10", stmt_float_cons
, 'x' },
5232 { "real16", stmt_float_cons
, 'X' },
5233 { "string", stringer
, 8 + 0 },
5234 { "stringz", stringer
, 8 + 1 },
5236 /* unaligned versions: */
5237 { "data2.ua", stmt_cons_ua
, 2 },
5238 { "data4.ua", stmt_cons_ua
, 4 },
5239 { "data8.ua", stmt_cons_ua
, 8 },
5240 { "data16.ua", stmt_cons_ua
, 16 },
5241 { "real4.ua", float_cons
, 'f' },
5242 { "real8.ua", float_cons
, 'd' },
5243 { "real10.ua", float_cons
, 'x' },
5244 { "real16.ua", float_cons
, 'X' },
5247 /* Declare a register by creating a symbol for it and entering it in
5248 the symbol table. */
5251 declare_register (const char *name
, unsigned int regnum
)
5256 sym
= symbol_create (name
, reg_section
, regnum
, &zero_address_frag
);
5258 err
= hash_insert (md
.reg_hash
, S_GET_NAME (sym
), (void *) sym
);
5260 as_fatal ("Inserting \"%s\" into register table failed: %s",
5267 declare_register_set (const char *prefix
,
5268 unsigned int num_regs
,
5269 unsigned int base_regnum
)
5274 for (i
= 0; i
< num_regs
; ++i
)
5276 snprintf (name
, sizeof (name
), "%s%u", prefix
, i
);
5277 declare_register (name
, base_regnum
+ i
);
5282 operand_width (enum ia64_opnd opnd
)
5284 const struct ia64_operand
*odesc
= &elf64_ia64_operands
[opnd
];
5285 unsigned int bits
= 0;
5289 for (i
= 0; i
< NELEMS (odesc
->field
) && odesc
->field
[i
].bits
; ++i
)
5290 bits
+= odesc
->field
[i
].bits
;
5295 static enum operand_match_result
5296 operand_match (const struct ia64_opcode
*idesc
, int index
, expressionS
*e
)
5298 enum ia64_opnd opnd
= idesc
->operands
[index
];
5299 int bits
, relocatable
= 0;
5300 struct insn_fix
*fix
;
5307 case IA64_OPND_AR_CCV
:
5308 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 32)
5309 return OPERAND_MATCH
;
5312 case IA64_OPND_AR_CSD
:
5313 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 25)
5314 return OPERAND_MATCH
;
5317 case IA64_OPND_AR_PFS
:
5318 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 64)
5319 return OPERAND_MATCH
;
5323 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_GR
+ 0)
5324 return OPERAND_MATCH
;
5328 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_IP
)
5329 return OPERAND_MATCH
;
5333 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR
)
5334 return OPERAND_MATCH
;
5337 case IA64_OPND_PR_ROT
:
5338 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR_ROT
)
5339 return OPERAND_MATCH
;
5343 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR
)
5344 return OPERAND_MATCH
;
5347 case IA64_OPND_PSR_L
:
5348 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_L
)
5349 return OPERAND_MATCH
;
5352 case IA64_OPND_PSR_UM
:
5353 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_UM
)
5354 return OPERAND_MATCH
;
5358 if (e
->X_op
== O_constant
)
5360 if (e
->X_add_number
== 1)
5361 return OPERAND_MATCH
;
5363 return OPERAND_OUT_OF_RANGE
;
5368 if (e
->X_op
== O_constant
)
5370 if (e
->X_add_number
== 8)
5371 return OPERAND_MATCH
;
5373 return OPERAND_OUT_OF_RANGE
;
5378 if (e
->X_op
== O_constant
)
5380 if (e
->X_add_number
== 16)
5381 return OPERAND_MATCH
;
5383 return OPERAND_OUT_OF_RANGE
;
5387 /* register operands: */
5390 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_AR
5391 && e
->X_add_number
< REG_AR
+ 128)
5392 return OPERAND_MATCH
;
5397 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_BR
5398 && e
->X_add_number
< REG_BR
+ 8)
5399 return OPERAND_MATCH
;
5403 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_CR
5404 && e
->X_add_number
< REG_CR
+ 128)
5405 return OPERAND_MATCH
;
5412 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_FR
5413 && e
->X_add_number
< REG_FR
+ 128)
5414 return OPERAND_MATCH
;
5419 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_P
5420 && e
->X_add_number
< REG_P
+ 64)
5421 return OPERAND_MATCH
;
5427 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
5428 && e
->X_add_number
< REG_GR
+ 128)
5429 return OPERAND_MATCH
;
5432 case IA64_OPND_R3_2
:
5433 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
)
5435 if (e
->X_add_number
< REG_GR
+ 4)
5436 return OPERAND_MATCH
;
5437 else if (e
->X_add_number
< REG_GR
+ 128)
5438 return OPERAND_OUT_OF_RANGE
;
5442 /* indirect operands: */
5443 case IA64_OPND_CPUID_R3
:
5444 case IA64_OPND_DBR_R3
:
5445 case IA64_OPND_DTR_R3
:
5446 case IA64_OPND_ITR_R3
:
5447 case IA64_OPND_IBR_R3
:
5448 case IA64_OPND_MSR_R3
:
5449 case IA64_OPND_PKR_R3
:
5450 case IA64_OPND_PMC_R3
:
5451 case IA64_OPND_PMD_R3
:
5452 case IA64_OPND_RR_R3
:
5453 if (e
->X_op
== O_index
&& e
->X_op_symbol
5454 && (S_GET_VALUE (e
->X_op_symbol
) - IND_CPUID
5455 == opnd
- IA64_OPND_CPUID_R3
))
5456 return OPERAND_MATCH
;
5460 if (e
->X_op
== O_index
&& !e
->X_op_symbol
)
5461 return OPERAND_MATCH
;
5464 /* immediate operands: */
5465 case IA64_OPND_CNT2a
:
5466 case IA64_OPND_LEN4
:
5467 case IA64_OPND_LEN6
:
5468 bits
= operand_width (idesc
->operands
[index
]);
5469 if (e
->X_op
== O_constant
)
5471 if ((bfd_vma
) (e
->X_add_number
- 1) < ((bfd_vma
) 1 << bits
))
5472 return OPERAND_MATCH
;
5474 return OPERAND_OUT_OF_RANGE
;
5478 case IA64_OPND_CNT2b
:
5479 if (e
->X_op
== O_constant
)
5481 if ((bfd_vma
) (e
->X_add_number
- 1) < 3)
5482 return OPERAND_MATCH
;
5484 return OPERAND_OUT_OF_RANGE
;
5488 case IA64_OPND_CNT2c
:
5489 val
= e
->X_add_number
;
5490 if (e
->X_op
== O_constant
)
5492 if ((val
== 0 || val
== 7 || val
== 15 || val
== 16))
5493 return OPERAND_MATCH
;
5495 return OPERAND_OUT_OF_RANGE
;
5500 /* SOR must be an integer multiple of 8 */
5501 if (e
->X_op
== O_constant
&& e
->X_add_number
& 0x7)
5502 return OPERAND_OUT_OF_RANGE
;
5505 if (e
->X_op
== O_constant
)
5507 if ((bfd_vma
) e
->X_add_number
<= 96)
5508 return OPERAND_MATCH
;
5510 return OPERAND_OUT_OF_RANGE
;
5514 case IA64_OPND_IMMU62
:
5515 if (e
->X_op
== O_constant
)
5517 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 62))
5518 return OPERAND_MATCH
;
5520 return OPERAND_OUT_OF_RANGE
;
5524 /* FIXME -- need 62-bit relocation type */
5525 as_bad (_("62-bit relocation not yet implemented"));
5529 case IA64_OPND_IMMU64
:
5530 if (e
->X_op
== O_symbol
|| e
->X_op
== O_pseudo_fixup
5531 || e
->X_op
== O_subtract
)
5533 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5534 fix
->code
= BFD_RELOC_IA64_IMM64
;
5535 if (e
->X_op
!= O_subtract
)
5537 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5538 if (e
->X_op
== O_pseudo_fixup
)
5542 fix
->opnd
= idesc
->operands
[index
];
5545 ++CURR_SLOT
.num_fixups
;
5546 return OPERAND_MATCH
;
5548 else if (e
->X_op
== O_constant
)
5549 return OPERAND_MATCH
;
5552 case IA64_OPND_IMMU5b
:
5553 if (e
->X_op
== O_constant
)
5555 val
= e
->X_add_number
;
5556 if (val
>= 32 && val
<= 63)
5557 return OPERAND_MATCH
;
5559 return OPERAND_OUT_OF_RANGE
;
5563 case IA64_OPND_CCNT5
:
5564 case IA64_OPND_CNT5
:
5565 case IA64_OPND_CNT6
:
5566 case IA64_OPND_CPOS6a
:
5567 case IA64_OPND_CPOS6b
:
5568 case IA64_OPND_CPOS6c
:
5569 case IA64_OPND_IMMU2
:
5570 case IA64_OPND_IMMU7a
:
5571 case IA64_OPND_IMMU7b
:
5572 case IA64_OPND_IMMU21
:
5573 case IA64_OPND_IMMU24
:
5574 case IA64_OPND_MBTYPE4
:
5575 case IA64_OPND_MHTYPE8
:
5576 case IA64_OPND_POS6
:
5577 bits
= operand_width (idesc
->operands
[index
]);
5578 if (e
->X_op
== O_constant
)
5580 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5581 return OPERAND_MATCH
;
5583 return OPERAND_OUT_OF_RANGE
;
5587 case IA64_OPND_IMMU9
:
5588 bits
= operand_width (idesc
->operands
[index
]);
5589 if (e
->X_op
== O_constant
)
5591 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5593 int lobits
= e
->X_add_number
& 0x3;
5594 if (((bfd_vma
) e
->X_add_number
& 0x3C) != 0 && lobits
== 0)
5595 e
->X_add_number
|= (bfd_vma
) 0x3;
5596 return OPERAND_MATCH
;
5599 return OPERAND_OUT_OF_RANGE
;
5603 case IA64_OPND_IMM44
:
5604 /* least 16 bits must be zero */
5605 if ((e
->X_add_number
& 0xffff) != 0)
5606 /* XXX technically, this is wrong: we should not be issuing warning
5607 messages until we're sure this instruction pattern is going to
5609 as_warn (_("lower 16 bits of mask ignored"));
5611 if (e
->X_op
== O_constant
)
5613 if (((e
->X_add_number
>= 0
5614 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 44))
5615 || (e
->X_add_number
< 0
5616 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 44))))
5619 if (e
->X_add_number
>= 0
5620 && (e
->X_add_number
& ((bfd_vma
) 1 << 43)) != 0)
5622 e
->X_add_number
|= ~(((bfd_vma
) 1 << 44) - 1);
5624 return OPERAND_MATCH
;
5627 return OPERAND_OUT_OF_RANGE
;
5631 case IA64_OPND_IMM17
:
5632 /* bit 0 is a don't care (pr0 is hardwired to 1) */
5633 if (e
->X_op
== O_constant
)
5635 if (((e
->X_add_number
>= 0
5636 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 17))
5637 || (e
->X_add_number
< 0
5638 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 17))))
5641 if (e
->X_add_number
>= 0
5642 && (e
->X_add_number
& ((bfd_vma
) 1 << 16)) != 0)
5644 e
->X_add_number
|= ~(((bfd_vma
) 1 << 17) - 1);
5646 return OPERAND_MATCH
;
5649 return OPERAND_OUT_OF_RANGE
;
5653 case IA64_OPND_IMM14
:
5654 case IA64_OPND_IMM22
:
5656 case IA64_OPND_IMM1
:
5657 case IA64_OPND_IMM8
:
5658 case IA64_OPND_IMM8U4
:
5659 case IA64_OPND_IMM8M1
:
5660 case IA64_OPND_IMM8M1U4
:
5661 case IA64_OPND_IMM8M1U8
:
5662 case IA64_OPND_IMM9a
:
5663 case IA64_OPND_IMM9b
:
5664 bits
= operand_width (idesc
->operands
[index
]);
5665 if (relocatable
&& (e
->X_op
== O_symbol
5666 || e
->X_op
== O_subtract
5667 || e
->X_op
== O_pseudo_fixup
))
5669 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5671 if (idesc
->operands
[index
] == IA64_OPND_IMM14
)
5672 fix
->code
= BFD_RELOC_IA64_IMM14
;
5674 fix
->code
= BFD_RELOC_IA64_IMM22
;
5676 if (e
->X_op
!= O_subtract
)
5678 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5679 if (e
->X_op
== O_pseudo_fixup
)
5683 fix
->opnd
= idesc
->operands
[index
];
5686 ++CURR_SLOT
.num_fixups
;
5687 return OPERAND_MATCH
;
5689 else if (e
->X_op
!= O_constant
5690 && ! (e
->X_op
== O_big
&& opnd
== IA64_OPND_IMM8M1U8
))
5691 return OPERAND_MISMATCH
;
5693 if (opnd
== IA64_OPND_IMM8M1U4
)
5695 /* Zero is not valid for unsigned compares that take an adjusted
5696 constant immediate range. */
5697 if (e
->X_add_number
== 0)
5698 return OPERAND_OUT_OF_RANGE
;
5700 /* Sign-extend 32-bit unsigned numbers, so that the following range
5701 checks will work. */
5702 val
= e
->X_add_number
;
5703 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5704 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5705 val
= ((val
<< 32) >> 32);
5707 /* Check for 0x100000000. This is valid because
5708 0x100000000-1 is the same as ((uint32_t) -1). */
5709 if (val
== ((bfd_signed_vma
) 1 << 32))
5710 return OPERAND_MATCH
;
5714 else if (opnd
== IA64_OPND_IMM8M1U8
)
5716 /* Zero is not valid for unsigned compares that take an adjusted
5717 constant immediate range. */
5718 if (e
->X_add_number
== 0)
5719 return OPERAND_OUT_OF_RANGE
;
5721 /* Check for 0x10000000000000000. */
5722 if (e
->X_op
== O_big
)
5724 if (generic_bignum
[0] == 0
5725 && generic_bignum
[1] == 0
5726 && generic_bignum
[2] == 0
5727 && generic_bignum
[3] == 0
5728 && generic_bignum
[4] == 1)
5729 return OPERAND_MATCH
;
5731 return OPERAND_OUT_OF_RANGE
;
5734 val
= e
->X_add_number
- 1;
5736 else if (opnd
== IA64_OPND_IMM8M1
)
5737 val
= e
->X_add_number
- 1;
5738 else if (opnd
== IA64_OPND_IMM8U4
)
5740 /* Sign-extend 32-bit unsigned numbers, so that the following range
5741 checks will work. */
5742 val
= e
->X_add_number
;
5743 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5744 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5745 val
= ((val
<< 32) >> 32);
5748 val
= e
->X_add_number
;
5750 if ((val
>= 0 && (bfd_vma
) val
< ((bfd_vma
) 1 << (bits
- 1)))
5751 || (val
< 0 && (bfd_vma
) -val
<= ((bfd_vma
) 1 << (bits
- 1))))
5752 return OPERAND_MATCH
;
5754 return OPERAND_OUT_OF_RANGE
;
5756 case IA64_OPND_INC3
:
5757 /* +/- 1, 4, 8, 16 */
5758 val
= e
->X_add_number
;
5761 if (e
->X_op
== O_constant
)
5763 if ((val
== 1 || val
== 4 || val
== 8 || val
== 16))
5764 return OPERAND_MATCH
;
5766 return OPERAND_OUT_OF_RANGE
;
5770 case IA64_OPND_TGT25
:
5771 case IA64_OPND_TGT25b
:
5772 case IA64_OPND_TGT25c
:
5773 case IA64_OPND_TGT64
:
5774 if (e
->X_op
== O_symbol
)
5776 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5777 if (opnd
== IA64_OPND_TGT25
)
5778 fix
->code
= BFD_RELOC_IA64_PCREL21F
;
5779 else if (opnd
== IA64_OPND_TGT25b
)
5780 fix
->code
= BFD_RELOC_IA64_PCREL21M
;
5781 else if (opnd
== IA64_OPND_TGT25c
)
5782 fix
->code
= BFD_RELOC_IA64_PCREL21B
;
5783 else if (opnd
== IA64_OPND_TGT64
)
5784 fix
->code
= BFD_RELOC_IA64_PCREL60B
;
5788 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5789 fix
->opnd
= idesc
->operands
[index
];
5792 ++CURR_SLOT
.num_fixups
;
5793 return OPERAND_MATCH
;
5795 case IA64_OPND_TAG13
:
5796 case IA64_OPND_TAG13b
:
5800 return OPERAND_MATCH
;
5803 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5804 /* There are no external relocs for TAG13/TAG13b fields, so we
5805 create a dummy reloc. This will not live past md_apply_fix. */
5806 fix
->code
= BFD_RELOC_UNUSED
;
5807 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5808 fix
->opnd
= idesc
->operands
[index
];
5811 ++CURR_SLOT
.num_fixups
;
5812 return OPERAND_MATCH
;
5819 case IA64_OPND_LDXMOV
:
5820 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5821 fix
->code
= BFD_RELOC_IA64_LDXMOV
;
5822 fix
->opnd
= idesc
->operands
[index
];
5825 ++CURR_SLOT
.num_fixups
;
5826 return OPERAND_MATCH
;
5831 return OPERAND_MISMATCH
;
5835 parse_operand (expressionS
*e
, int more
)
5839 memset (e
, 0, sizeof (*e
));
5842 expression_and_evaluate (e
);
5843 sep
= *input_line_pointer
;
5844 if (more
&& (sep
== ',' || sep
== more
))
5845 ++input_line_pointer
;
5849 /* Returns the next entry in the opcode table that matches the one in
5850 IDESC, and frees the entry in IDESC. If no matching entry is
5851 found, NULL is returned instead. */
5853 static struct ia64_opcode
*
5854 get_next_opcode (struct ia64_opcode
*idesc
)
5856 struct ia64_opcode
*next
= ia64_find_next_opcode (idesc
);
5857 ia64_free_opcode (idesc
);
5861 /* Parse the operands for the opcode and find the opcode variant that
5862 matches the specified operands, or NULL if no match is possible. */
5864 static struct ia64_opcode
*
5865 parse_operands (struct ia64_opcode
*idesc
)
5867 int i
= 0, highest_unmatched_operand
, num_operands
= 0, num_outputs
= 0;
5868 int error_pos
, out_of_range_pos
, curr_out_of_range_pos
, sep
= 0;
5871 enum ia64_opnd expected_operand
= IA64_OPND_NIL
;
5872 enum operand_match_result result
;
5874 char *first_arg
= 0, *end
, *saved_input_pointer
;
5877 assert (strlen (idesc
->name
) <= 128);
5879 strcpy (mnemonic
, idesc
->name
);
5880 if (idesc
->operands
[2] == IA64_OPND_SOF
5881 || idesc
->operands
[1] == IA64_OPND_SOF
)
5883 /* To make the common idiom "alloc loc?=ar.pfs,0,1,0,0" work, we
5884 can't parse the first operand until we have parsed the
5885 remaining operands of the "alloc" instruction. */
5887 first_arg
= input_line_pointer
;
5888 end
= strchr (input_line_pointer
, '=');
5891 as_bad (_("Expected separator `='"));
5894 input_line_pointer
= end
+ 1;
5901 if (i
< NELEMS (CURR_SLOT
.opnd
))
5903 sep
= parse_operand (CURR_SLOT
.opnd
+ i
, '=');
5904 if (CURR_SLOT
.opnd
[i
].X_op
== O_absent
)
5911 sep
= parse_operand (&dummy
, '=');
5912 if (dummy
.X_op
== O_absent
)
5918 if (sep
!= '=' && sep
!= ',')
5923 if (num_outputs
> 0)
5924 as_bad (_("Duplicate equal sign (=) in instruction"));
5926 num_outputs
= i
+ 1;
5931 as_bad (_("Illegal operand separator `%c'"), sep
);
5935 if (idesc
->operands
[2] == IA64_OPND_SOF
5936 || idesc
->operands
[1] == IA64_OPND_SOF
)
5938 /* Map alloc r1=ar.pfs,i,l,o,r to alloc r1=ar.pfs,(i+l+o),(i+l),r.
5939 Note, however, that due to that mapping operand numbers in error
5940 messages for any of the constant operands will not be correct. */
5941 know (strcmp (idesc
->name
, "alloc") == 0);
5942 /* The first operand hasn't been parsed/initialized, yet (but
5943 num_operands intentionally doesn't account for that). */
5944 i
= num_operands
> 4 ? 2 : 1;
5945 #define FORCE_CONST(n) (CURR_SLOT.opnd[n].X_op == O_constant \
5946 ? CURR_SLOT.opnd[n].X_add_number \
5948 sof
= set_regstack (FORCE_CONST(i
),
5951 FORCE_CONST(i
+ 3));
5954 /* now we can parse the first arg: */
5955 saved_input_pointer
= input_line_pointer
;
5956 input_line_pointer
= first_arg
;
5957 sep
= parse_operand (CURR_SLOT
.opnd
+ 0, '=');
5959 --num_outputs
; /* force error */
5960 input_line_pointer
= saved_input_pointer
;
5962 CURR_SLOT
.opnd
[i
].X_add_number
= sof
;
5963 if (CURR_SLOT
.opnd
[i
+ 1].X_op
== O_constant
5964 && CURR_SLOT
.opnd
[i
+ 2].X_op
== O_constant
)
5965 CURR_SLOT
.opnd
[i
+ 1].X_add_number
5966 = sof
- CURR_SLOT
.opnd
[i
+ 2].X_add_number
;
5968 CURR_SLOT
.opnd
[i
+ 1].X_op
= O_illegal
;
5969 CURR_SLOT
.opnd
[i
+ 2] = CURR_SLOT
.opnd
[i
+ 3];
5972 highest_unmatched_operand
= -4;
5973 curr_out_of_range_pos
= -1;
5975 for (; idesc
; idesc
= get_next_opcode (idesc
))
5977 if (num_outputs
!= idesc
->num_outputs
)
5978 continue; /* mismatch in # of outputs */
5979 if (highest_unmatched_operand
< 0)
5980 highest_unmatched_operand
|= 1;
5981 if (num_operands
> NELEMS (idesc
->operands
)
5982 || (num_operands
< NELEMS (idesc
->operands
)
5983 && idesc
->operands
[num_operands
])
5984 || (num_operands
> 0 && !idesc
->operands
[num_operands
- 1]))
5985 continue; /* mismatch in number of arguments */
5986 if (highest_unmatched_operand
< 0)
5987 highest_unmatched_operand
|= 2;
5989 CURR_SLOT
.num_fixups
= 0;
5991 /* Try to match all operands. If we see an out-of-range operand,
5992 then continue trying to match the rest of the operands, since if
5993 the rest match, then this idesc will give the best error message. */
5995 out_of_range_pos
= -1;
5996 for (i
= 0; i
< num_operands
&& idesc
->operands
[i
]; ++i
)
5998 result
= operand_match (idesc
, i
, CURR_SLOT
.opnd
+ i
);
5999 if (result
!= OPERAND_MATCH
)
6001 if (result
!= OPERAND_OUT_OF_RANGE
)
6003 if (out_of_range_pos
< 0)
6004 /* remember position of the first out-of-range operand: */
6005 out_of_range_pos
= i
;
6009 /* If we did not match all operands, or if at least one operand was
6010 out-of-range, then this idesc does not match. Keep track of which
6011 idesc matched the most operands before failing. If we have two
6012 idescs that failed at the same position, and one had an out-of-range
6013 operand, then prefer the out-of-range operand. Thus if we have
6014 "add r0=0x1000000,r1" we get an error saying the constant is out
6015 of range instead of an error saying that the constant should have been
6018 if (i
!= num_operands
|| out_of_range_pos
>= 0)
6020 if (i
> highest_unmatched_operand
6021 || (i
== highest_unmatched_operand
6022 && out_of_range_pos
> curr_out_of_range_pos
))
6024 highest_unmatched_operand
= i
;
6025 if (out_of_range_pos
>= 0)
6027 expected_operand
= idesc
->operands
[out_of_range_pos
];
6028 error_pos
= out_of_range_pos
;
6032 expected_operand
= idesc
->operands
[i
];
6035 curr_out_of_range_pos
= out_of_range_pos
;
6044 if (expected_operand
)
6045 as_bad (_("Operand %u of `%s' should be %s"),
6046 error_pos
+ 1, mnemonic
,
6047 elf64_ia64_operands
[expected_operand
].desc
);
6048 else if (highest_unmatched_operand
< 0 && !(highest_unmatched_operand
& 1))
6049 as_bad (_("Wrong number of output operands"));
6050 else if (highest_unmatched_operand
< 0 && !(highest_unmatched_operand
& 2))
6051 as_bad (_("Wrong number of input operands"));
6053 as_bad (_("Operand mismatch"));
6057 /* Check that the instruction doesn't use
6058 - r0, f0, or f1 as output operands
6059 - the same predicate twice as output operands
6060 - r0 as address of a base update load or store
6061 - the same GR as output and address of a base update load
6062 - two even- or two odd-numbered FRs as output operands of a floating
6063 point parallel load.
6064 At most two (conflicting) output (or output-like) operands can exist,
6065 (floating point parallel loads have three outputs, but the base register,
6066 if updated, cannot conflict with the actual outputs). */
6068 for (i
= 0; i
< num_operands
; ++i
)
6073 switch (idesc
->operands
[i
])
6078 if (i
< num_outputs
)
6080 if (CURR_SLOT
.opnd
[i
].X_add_number
== REG_GR
)
6083 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6085 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6090 if (i
< num_outputs
)
6093 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6095 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6102 if (i
< num_outputs
)
6104 if (CURR_SLOT
.opnd
[i
].X_add_number
>= REG_FR
6105 && CURR_SLOT
.opnd
[i
].X_add_number
<= REG_FR
+ 1)
6108 regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
6111 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6113 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6117 if (idesc
->flags
& IA64_OPCODE_POSTINC
)
6119 if (CURR_SLOT
.opnd
[i
].X_add_number
== REG_GR
)
6122 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6124 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6135 as_warn (_("Invalid use of `%c%d' as output operand"), reg_class
, regno
);
6138 as_warn (_("Invalid use of `r%d' as base update address operand"), regno
);
6144 if (reg1
>= REG_GR
&& reg1
<= REG_GR
+ 127)
6149 else if (reg1
>= REG_P
&& reg1
<= REG_P
+ 63)
6154 else if (reg1
>= REG_FR
&& reg1
<= REG_FR
+ 127)
6162 as_warn (_("Invalid duplicate use of `%c%d'"), reg_class
, reg1
);
6164 else if (((reg1
>= REG_FR
&& reg1
<= REG_FR
+ 31
6165 && reg2
>= REG_FR
&& reg2
<= REG_FR
+ 31)
6166 || (reg1
>= REG_FR
+ 32 && reg1
<= REG_FR
+ 127
6167 && reg2
>= REG_FR
+ 32 && reg2
<= REG_FR
+ 127))
6168 && ! ((reg1
^ reg2
) & 1))
6169 as_warn (_("Invalid simultaneous use of `f%d' and `f%d'"),
6170 reg1
- REG_FR
, reg2
- REG_FR
);
6171 else if ((reg1
>= REG_FR
&& reg1
<= REG_FR
+ 31
6172 && reg2
>= REG_FR
+ 32 && reg2
<= REG_FR
+ 127)
6173 || (reg1
>= REG_FR
+ 32 && reg1
<= REG_FR
+ 127
6174 && reg2
>= REG_FR
&& reg2
<= REG_FR
+ 31))
6175 as_warn (_("Dangerous simultaneous use of `f%d' and `f%d'"),
6176 reg1
- REG_FR
, reg2
- REG_FR
);
6181 build_insn (struct slot
*slot
, bfd_vma
*insnp
)
6183 const struct ia64_operand
*odesc
, *o2desc
;
6184 struct ia64_opcode
*idesc
= slot
->idesc
;
6190 insn
= idesc
->opcode
| slot
->qp_regno
;
6192 for (i
= 0; i
< NELEMS (idesc
->operands
) && idesc
->operands
[i
]; ++i
)
6194 if (slot
->opnd
[i
].X_op
== O_register
6195 || slot
->opnd
[i
].X_op
== O_constant
6196 || slot
->opnd
[i
].X_op
== O_index
)
6197 val
= slot
->opnd
[i
].X_add_number
;
6198 else if (slot
->opnd
[i
].X_op
== O_big
)
6200 /* This must be the value 0x10000000000000000. */
6201 assert (idesc
->operands
[i
] == IA64_OPND_IMM8M1U8
);
6207 switch (idesc
->operands
[i
])
6209 case IA64_OPND_IMMU64
:
6210 *insnp
++ = (val
>> 22) & 0x1ffffffffffLL
;
6211 insn
|= (((val
& 0x7f) << 13) | (((val
>> 7) & 0x1ff) << 27)
6212 | (((val
>> 16) & 0x1f) << 22) | (((val
>> 21) & 0x1) << 21)
6213 | (((val
>> 63) & 0x1) << 36));
6216 case IA64_OPND_IMMU62
:
6217 val
&= 0x3fffffffffffffffULL
;
6218 if (val
!= slot
->opnd
[i
].X_add_number
)
6219 as_warn (_("Value truncated to 62 bits"));
6220 *insnp
++ = (val
>> 21) & 0x1ffffffffffLL
;
6221 insn
|= (((val
& 0xfffff) << 6) | (((val
>> 20) & 0x1) << 36));
6224 case IA64_OPND_TGT64
:
6226 *insnp
++ = ((val
>> 20) & 0x7fffffffffLL
) << 2;
6227 insn
|= ((((val
>> 59) & 0x1) << 36)
6228 | (((val
>> 0) & 0xfffff) << 13));
6259 case IA64_OPND_R3_2
:
6260 case IA64_OPND_CPUID_R3
:
6261 case IA64_OPND_DBR_R3
:
6262 case IA64_OPND_DTR_R3
:
6263 case IA64_OPND_ITR_R3
:
6264 case IA64_OPND_IBR_R3
:
6266 case IA64_OPND_MSR_R3
:
6267 case IA64_OPND_PKR_R3
:
6268 case IA64_OPND_PMC_R3
:
6269 case IA64_OPND_PMD_R3
:
6270 case IA64_OPND_RR_R3
:
6278 odesc
= elf64_ia64_operands
+ idesc
->operands
[i
];
6279 err
= (*odesc
->insert
) (odesc
, val
, &insn
);
6281 as_bad_where (slot
->src_file
, slot
->src_line
,
6282 _("Bad operand value: %s"), err
);
6283 if (idesc
->flags
& IA64_OPCODE_PSEUDO
)
6285 if ((idesc
->flags
& IA64_OPCODE_F2_EQ_F3
)
6286 && odesc
== elf64_ia64_operands
+ IA64_OPND_F3
)
6288 o2desc
= elf64_ia64_operands
+ IA64_OPND_F2
;
6289 (*o2desc
->insert
) (o2desc
, val
, &insn
);
6291 if ((idesc
->flags
& IA64_OPCODE_LEN_EQ_64MCNT
)
6292 && (odesc
== elf64_ia64_operands
+ IA64_OPND_CPOS6a
6293 || odesc
== elf64_ia64_operands
+ IA64_OPND_POS6
))
6295 o2desc
= elf64_ia64_operands
+ IA64_OPND_LEN6
;
6296 (*o2desc
->insert
) (o2desc
, 64 - val
, &insn
);
6304 emit_one_bundle (void)
6306 int manual_bundling_off
= 0, manual_bundling
= 0;
6307 enum ia64_unit required_unit
, insn_unit
= 0;
6308 enum ia64_insn_type type
[3], insn_type
;
6309 unsigned int template, orig_template
;
6310 bfd_vma insn
[3] = { -1, -1, -1 };
6311 struct ia64_opcode
*idesc
;
6312 int end_of_insn_group
= 0, user_template
= -1;
6313 int n
, i
, j
, first
, curr
, last_slot
;
6314 bfd_vma t0
= 0, t1
= 0;
6315 struct label_fix
*lfix
;
6316 bfd_boolean mark_label
;
6317 struct insn_fix
*ifix
;
6323 first
= (md
.curr_slot
+ NUM_SLOTS
- md
.num_slots_in_use
) % NUM_SLOTS
;
6324 know (first
>= 0 && first
< NUM_SLOTS
);
6325 n
= MIN (3, md
.num_slots_in_use
);
6327 /* Determine template: user user_template if specified, best match
6330 if (md
.slot
[first
].user_template
>= 0)
6331 user_template
= template = md
.slot
[first
].user_template
;
6334 /* Auto select appropriate template. */
6335 memset (type
, 0, sizeof (type
));
6337 for (i
= 0; i
< n
; ++i
)
6339 if (md
.slot
[curr
].label_fixups
&& i
!= 0)
6341 type
[i
] = md
.slot
[curr
].idesc
->type
;
6342 curr
= (curr
+ 1) % NUM_SLOTS
;
6344 template = best_template
[type
[0]][type
[1]][type
[2]];
6347 /* initialize instructions with appropriate nops: */
6348 for (i
= 0; i
< 3; ++i
)
6349 insn
[i
] = nop
[ia64_templ_desc
[template].exec_unit
[i
]];
6353 /* Check to see if this bundle is at an offset that is a multiple of 16-bytes
6354 from the start of the frag. */
6355 addr_mod
= frag_now_fix () & 15;
6356 if (frag_now
->has_code
&& frag_now
->insn_addr
!= addr_mod
)
6357 as_bad (_("instruction address is not a multiple of 16"));
6358 frag_now
->insn_addr
= addr_mod
;
6359 frag_now
->has_code
= 1;
6361 /* now fill in slots with as many insns as possible: */
6363 idesc
= md
.slot
[curr
].idesc
;
6364 end_of_insn_group
= 0;
6366 for (i
= 0; i
< 3 && md
.num_slots_in_use
> 0; ++i
)
6368 /* If we have unwind records, we may need to update some now. */
6369 unw_rec_list
*ptr
= md
.slot
[curr
].unwind_record
;
6370 unw_rec_list
*end_ptr
= NULL
;
6374 /* Find the last prologue/body record in the list for the current
6375 insn, and set the slot number for all records up to that point.
6376 This needs to be done now, because prologue/body records refer to
6377 the current point, not the point after the instruction has been
6378 issued. This matters because there may have been nops emitted
6379 meanwhile. Any non-prologue non-body record followed by a
6380 prologue/body record must also refer to the current point. */
6381 unw_rec_list
*last_ptr
;
6383 for (j
= 1; end_ptr
== NULL
&& j
< md
.num_slots_in_use
; ++j
)
6384 end_ptr
= md
.slot
[(curr
+ j
) % NUM_SLOTS
].unwind_record
;
6385 for (last_ptr
= NULL
; ptr
!= end_ptr
; ptr
= ptr
->next
)
6386 if (ptr
->r
.type
== prologue
|| ptr
->r
.type
== prologue_gr
6387 || ptr
->r
.type
== body
)
6391 /* Make last_ptr point one after the last prologue/body
6393 last_ptr
= last_ptr
->next
;
6394 for (ptr
= md
.slot
[curr
].unwind_record
; ptr
!= last_ptr
;
6397 ptr
->slot_number
= (unsigned long) f
+ i
;
6398 ptr
->slot_frag
= frag_now
;
6400 /* Remove the initialized records, so that we won't accidentally
6401 update them again if we insert a nop and continue. */
6402 md
.slot
[curr
].unwind_record
= last_ptr
;
6406 manual_bundling_off
= md
.slot
[curr
].manual_bundling_off
;
6407 if (md
.slot
[curr
].manual_bundling_on
)
6410 manual_bundling
= 1;
6412 break; /* Need to start a new bundle. */
6415 /* If this instruction specifies a template, then it must be the first
6416 instruction of a bundle. */
6417 if (curr
!= first
&& md
.slot
[curr
].user_template
>= 0)
6420 if (idesc
->flags
& IA64_OPCODE_SLOT2
)
6422 if (manual_bundling
&& !manual_bundling_off
)
6424 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6425 _("`%s' must be last in bundle"), idesc
->name
);
6427 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6431 if (idesc
->flags
& IA64_OPCODE_LAST
)
6434 unsigned int required_template
;
6436 /* If we need a stop bit after an M slot, our only choice is
6437 template 5 (M;;MI). If we need a stop bit after a B
6438 slot, our only choice is to place it at the end of the
6439 bundle, because the only available templates are MIB,
6440 MBB, BBB, MMB, and MFB. We don't handle anything other
6441 than M and B slots because these are the only kind of
6442 instructions that can have the IA64_OPCODE_LAST bit set. */
6443 required_template
= template;
6444 switch (idesc
->type
)
6448 required_template
= 5;
6456 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6457 _("Internal error: don't know how to force %s to end of instruction group"),
6463 && (i
> required_slot
6464 || (required_slot
== 2 && !manual_bundling_off
)
6465 || (user_template
>= 0
6466 /* Changing from MMI to M;MI is OK. */
6467 && (template ^ required_template
) > 1)))
6469 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6470 _("`%s' must be last in instruction group"),
6472 if (i
< 2 && required_slot
== 2 && !manual_bundling_off
)
6473 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6475 if (required_slot
< i
)
6476 /* Can't fit this instruction. */
6480 if (required_template
!= template)
6482 /* If we switch the template, we need to reset the NOPs
6483 after slot i. The slot-types of the instructions ahead
6484 of i never change, so we don't need to worry about
6485 changing NOPs in front of this slot. */
6486 for (j
= i
; j
< 3; ++j
)
6487 insn
[j
] = nop
[ia64_templ_desc
[required_template
].exec_unit
[j
]];
6489 /* We just picked a template that includes the stop bit in the
6490 middle, so we don't need another one emitted later. */
6491 md
.slot
[curr
].end_of_insn_group
= 0;
6493 template = required_template
;
6495 if (curr
!= first
&& md
.slot
[curr
].label_fixups
)
6497 if (manual_bundling
)
6499 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6500 _("Label must be first in a bundle"));
6501 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6503 /* This insn must go into the first slot of a bundle. */
6507 if (end_of_insn_group
&& md
.num_slots_in_use
>= 1)
6509 /* We need an instruction group boundary in the middle of a
6510 bundle. See if we can switch to an other template with
6511 an appropriate boundary. */
6513 orig_template
= template;
6514 if (i
== 1 && (user_template
== 4
6515 || (user_template
< 0
6516 && (ia64_templ_desc
[template].exec_unit
[0]
6520 end_of_insn_group
= 0;
6522 else if (i
== 2 && (user_template
== 0
6523 || (user_template
< 0
6524 && (ia64_templ_desc
[template].exec_unit
[1]
6526 /* This test makes sure we don't switch the template if
6527 the next instruction is one that needs to be first in
6528 an instruction group. Since all those instructions are
6529 in the M group, there is no way such an instruction can
6530 fit in this bundle even if we switch the template. The
6531 reason we have to check for this is that otherwise we
6532 may end up generating "MI;;I M.." which has the deadly
6533 effect that the second M instruction is no longer the
6534 first in the group! --davidm 99/12/16 */
6535 && (idesc
->flags
& IA64_OPCODE_FIRST
) == 0)
6538 end_of_insn_group
= 0;
6541 && user_template
== 0
6542 && !(idesc
->flags
& IA64_OPCODE_FIRST
))
6543 /* Use the next slot. */
6545 else if (curr
!= first
)
6546 /* can't fit this insn */
6549 if (template != orig_template
)
6550 /* if we switch the template, we need to reset the NOPs
6551 after slot i. The slot-types of the instructions ahead
6552 of i never change, so we don't need to worry about
6553 changing NOPs in front of this slot. */
6554 for (j
= i
; j
< 3; ++j
)
6555 insn
[j
] = nop
[ia64_templ_desc
[template].exec_unit
[j
]];
6557 required_unit
= ia64_templ_desc
[template].exec_unit
[i
];
6559 /* resolve dynamic opcodes such as "break", "hint", and "nop": */
6560 if (idesc
->type
== IA64_TYPE_DYN
)
6562 enum ia64_opnd opnd1
, opnd2
;
6564 if ((strcmp (idesc
->name
, "nop") == 0)
6565 || (strcmp (idesc
->name
, "break") == 0))
6566 insn_unit
= required_unit
;
6567 else if (strcmp (idesc
->name
, "hint") == 0)
6569 insn_unit
= required_unit
;
6570 if (required_unit
== IA64_UNIT_B
)
6576 case hint_b_warning
:
6577 as_warn (_("hint in B unit may be treated as nop"));
6580 /* When manual bundling is off and there is no
6581 user template, we choose a different unit so
6582 that hint won't go into the current slot. We
6583 will fill the current bundle with nops and
6584 try to put hint into the next bundle. */
6585 if (!manual_bundling
&& user_template
< 0)
6586 insn_unit
= IA64_UNIT_I
;
6588 as_bad (_("hint in B unit can't be used"));
6593 else if (strcmp (idesc
->name
, "chk.s") == 0
6594 || strcmp (idesc
->name
, "mov") == 0)
6596 insn_unit
= IA64_UNIT_M
;
6597 if (required_unit
== IA64_UNIT_I
6598 || (required_unit
== IA64_UNIT_F
&& template == 6))
6599 insn_unit
= IA64_UNIT_I
;
6602 as_fatal (_("emit_one_bundle: unexpected dynamic op"));
6604 snprintf (mnemonic
, sizeof (mnemonic
), "%s.%c",
6605 idesc
->name
, "?imbfxx"[insn_unit
]);
6606 opnd1
= idesc
->operands
[0];
6607 opnd2
= idesc
->operands
[1];
6608 ia64_free_opcode (idesc
);
6609 idesc
= ia64_find_opcode (mnemonic
);
6610 /* moves to/from ARs have collisions */
6611 if (opnd1
== IA64_OPND_AR3
|| opnd2
== IA64_OPND_AR3
)
6613 while (idesc
!= NULL
6614 && (idesc
->operands
[0] != opnd1
6615 || idesc
->operands
[1] != opnd2
))
6616 idesc
= get_next_opcode (idesc
);
6618 md
.slot
[curr
].idesc
= idesc
;
6622 insn_type
= idesc
->type
;
6623 insn_unit
= IA64_UNIT_NIL
;
6627 if (required_unit
== IA64_UNIT_I
|| required_unit
== IA64_UNIT_M
)
6628 insn_unit
= required_unit
;
6630 case IA64_TYPE_X
: insn_unit
= IA64_UNIT_L
; break;
6631 case IA64_TYPE_I
: insn_unit
= IA64_UNIT_I
; break;
6632 case IA64_TYPE_M
: insn_unit
= IA64_UNIT_M
; break;
6633 case IA64_TYPE_B
: insn_unit
= IA64_UNIT_B
; break;
6634 case IA64_TYPE_F
: insn_unit
= IA64_UNIT_F
; break;
6639 if (insn_unit
!= required_unit
)
6640 continue; /* Try next slot. */
6642 /* Now is a good time to fix up the labels for this insn. */
6644 for (lfix
= md
.slot
[curr
].label_fixups
; lfix
; lfix
= lfix
->next
)
6646 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16);
6647 symbol_set_frag (lfix
->sym
, frag_now
);
6648 mark_label
|= lfix
->dw2_mark_labels
;
6650 for (lfix
= md
.slot
[curr
].tag_fixups
; lfix
; lfix
= lfix
->next
)
6652 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16 + i
);
6653 symbol_set_frag (lfix
->sym
, frag_now
);
6656 if (debug_type
== DEBUG_DWARF2
6657 || md
.slot
[curr
].loc_directive_seen
6660 bfd_vma addr
= frag_now
->fr_address
+ frag_now_fix () - 16 + i
;
6662 md
.slot
[curr
].loc_directive_seen
= 0;
6664 md
.slot
[curr
].debug_line
.flags
|= DWARF2_FLAG_BASIC_BLOCK
;
6666 dwarf2_gen_line_info (addr
, &md
.slot
[curr
].debug_line
);
6669 build_insn (md
.slot
+ curr
, insn
+ i
);
6671 ptr
= md
.slot
[curr
].unwind_record
;
6674 /* Set slot numbers for all remaining unwind records belonging to the
6675 current insn. There can not be any prologue/body unwind records
6677 for (; ptr
!= end_ptr
; ptr
= ptr
->next
)
6679 ptr
->slot_number
= (unsigned long) f
+ i
;
6680 ptr
->slot_frag
= frag_now
;
6682 md
.slot
[curr
].unwind_record
= NULL
;
6685 if (required_unit
== IA64_UNIT_L
)
6688 /* skip one slot for long/X-unit instructions */
6691 --md
.num_slots_in_use
;
6694 for (j
= 0; j
< md
.slot
[curr
].num_fixups
; ++j
)
6696 ifix
= md
.slot
[curr
].fixup
+ j
;
6697 fix
= fix_new_exp (frag_now
, frag_now_fix () - 16 + i
, 8,
6698 &ifix
->expr
, ifix
->is_pcrel
, ifix
->code
);
6699 fix
->tc_fix_data
.opnd
= ifix
->opnd
;
6700 fix
->fx_file
= md
.slot
[curr
].src_file
;
6701 fix
->fx_line
= md
.slot
[curr
].src_line
;
6704 end_of_insn_group
= md
.slot
[curr
].end_of_insn_group
;
6707 ia64_free_opcode (md
.slot
[curr
].idesc
);
6708 memset (md
.slot
+ curr
, 0, sizeof (md
.slot
[curr
]));
6709 md
.slot
[curr
].user_template
= -1;
6711 if (manual_bundling_off
)
6713 manual_bundling
= 0;
6716 curr
= (curr
+ 1) % NUM_SLOTS
;
6717 idesc
= md
.slot
[curr
].idesc
;
6720 /* A user template was specified, but the first following instruction did
6721 not fit. This can happen with or without manual bundling. */
6722 if (md
.num_slots_in_use
> 0 && last_slot
< 0)
6724 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6725 _("`%s' does not fit into %s template"),
6726 idesc
->name
, ia64_templ_desc
[template].name
);
6727 /* Drop first insn so we don't livelock. */
6728 --md
.num_slots_in_use
;
6729 know (curr
== first
);
6730 ia64_free_opcode (md
.slot
[curr
].idesc
);
6731 memset (md
.slot
+ curr
, 0, sizeof (md
.slot
[curr
]));
6732 md
.slot
[curr
].user_template
= -1;
6734 else if (manual_bundling
> 0)
6736 if (md
.num_slots_in_use
> 0)
6739 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6740 _("`%s' does not fit into bundle"), idesc
->name
);
6747 else if (last_slot
== 0)
6748 where
= "slots 2 or 3";
6751 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6752 _("`%s' can't go in %s of %s template"),
6753 idesc
->name
, where
, ia64_templ_desc
[template].name
);
6757 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6758 _("Missing '}' at end of file"));
6761 know (md
.num_slots_in_use
< NUM_SLOTS
);
6763 t0
= end_of_insn_group
| (template << 1) | (insn
[0] << 5) | (insn
[1] << 46);
6764 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
6766 number_to_chars_littleendian (f
+ 0, t0
, 8);
6767 number_to_chars_littleendian (f
+ 8, t1
, 8);
6771 md_parse_option (int c
, char *arg
)
6776 /* Switches from the Intel assembler. */
6778 if (strcmp (arg
, "ilp64") == 0
6779 || strcmp (arg
, "lp64") == 0
6780 || strcmp (arg
, "p64") == 0)
6782 md
.flags
|= EF_IA_64_ABI64
;
6784 else if (strcmp (arg
, "ilp32") == 0)
6786 md
.flags
&= ~EF_IA_64_ABI64
;
6788 else if (strcmp (arg
, "le") == 0)
6790 md
.flags
&= ~EF_IA_64_BE
;
6791 default_big_endian
= 0;
6793 else if (strcmp (arg
, "be") == 0)
6795 md
.flags
|= EF_IA_64_BE
;
6796 default_big_endian
= 1;
6798 else if (strncmp (arg
, "unwind-check=", 13) == 0)
6801 if (strcmp (arg
, "warning") == 0)
6802 md
.unwind_check
= unwind_check_warning
;
6803 else if (strcmp (arg
, "error") == 0)
6804 md
.unwind_check
= unwind_check_error
;
6808 else if (strncmp (arg
, "hint.b=", 7) == 0)
6811 if (strcmp (arg
, "ok") == 0)
6812 md
.hint_b
= hint_b_ok
;
6813 else if (strcmp (arg
, "warning") == 0)
6814 md
.hint_b
= hint_b_warning
;
6815 else if (strcmp (arg
, "error") == 0)
6816 md
.hint_b
= hint_b_error
;
6820 else if (strncmp (arg
, "tune=", 5) == 0)
6823 if (strcmp (arg
, "itanium1") == 0)
6825 else if (strcmp (arg
, "itanium2") == 0)
6835 if (strcmp (arg
, "so") == 0)
6837 /* Suppress signon message. */
6839 else if (strcmp (arg
, "pi") == 0)
6841 /* Reject privileged instructions. FIXME */
6843 else if (strcmp (arg
, "us") == 0)
6845 /* Allow union of signed and unsigned range. FIXME */
6847 else if (strcmp (arg
, "close_fcalls") == 0)
6849 /* Do not resolve global function calls. */
6856 /* temp[="prefix"] Insert temporary labels into the object file
6857 symbol table prefixed by "prefix".
6858 Default prefix is ":temp:".
6863 /* indirect=<tgt> Assume unannotated indirect branches behavior
6864 according to <tgt> --
6865 exit: branch out from the current context (default)
6866 labels: all labels in context may be branch targets
6868 if (strncmp (arg
, "indirect=", 9) != 0)
6873 /* -X conflicts with an ignored option, use -x instead */
6875 if (!arg
|| strcmp (arg
, "explicit") == 0)
6877 /* set default mode to explicit */
6878 md
.default_explicit_mode
= 1;
6881 else if (strcmp (arg
, "auto") == 0)
6883 md
.default_explicit_mode
= 0;
6885 else if (strcmp (arg
, "none") == 0)
6889 else if (strcmp (arg
, "debug") == 0)
6893 else if (strcmp (arg
, "debugx") == 0)
6895 md
.default_explicit_mode
= 1;
6898 else if (strcmp (arg
, "debugn") == 0)
6905 as_bad (_("Unrecognized option '-x%s'"), arg
);
6910 /* nops Print nops statistics. */
6913 /* GNU specific switches for gcc. */
6914 case OPTION_MCONSTANT_GP
:
6915 md
.flags
|= EF_IA_64_CONS_GP
;
6918 case OPTION_MAUTO_PIC
:
6919 md
.flags
|= EF_IA_64_NOFUNCDESC_CONS_GP
;
6930 md_show_usage (FILE *stream
)
6934 --mconstant-gp mark output file as using the constant-GP model\n\
6935 (sets ELF header flag EF_IA_64_CONS_GP)\n\
6936 --mauto-pic mark output file as using the constant-GP model\n\
6937 without function descriptors (sets ELF header flag\n\
6938 EF_IA_64_NOFUNCDESC_CONS_GP)\n\
6939 -milp32|-milp64|-mlp64|-mp64 select data model (default -mlp64)\n\
6940 -mle | -mbe select little- or big-endian byte order (default -mle)\n\
6941 -mtune=[itanium1|itanium2]\n\
6942 tune for a specific CPU (default -mtune=itanium2)\n\
6943 -munwind-check=[warning|error]\n\
6944 unwind directive check (default -munwind-check=warning)\n\
6945 -mhint.b=[ok|warning|error]\n\
6946 hint.b check (default -mhint.b=error)\n\
6947 -x | -xexplicit turn on dependency violation checking\n\
6948 -xauto automagically remove dependency violations (default)\n\
6949 -xnone turn off dependency violation checking\n\
6950 -xdebug debug dependency violation checker\n\
6951 -xdebugn debug dependency violation checker but turn off\n\
6952 dependency violation checking\n\
6953 -xdebugx debug dependency violation checker and turn on\n\
6954 dependency violation checking\n"),
6959 ia64_after_parse_args (void)
6961 if (debug_type
== DEBUG_STABS
)
6962 as_fatal (_("--gstabs is not supported for ia64"));
6965 /* Return true if TYPE fits in TEMPL at SLOT. */
6968 match (int templ
, int type
, int slot
)
6970 enum ia64_unit unit
;
6973 unit
= ia64_templ_desc
[templ
].exec_unit
[slot
];
6976 case IA64_TYPE_DYN
: result
= 1; break; /* for nop and break */
6978 result
= (unit
== IA64_UNIT_I
|| unit
== IA64_UNIT_M
);
6980 case IA64_TYPE_X
: result
= (unit
== IA64_UNIT_L
); break;
6981 case IA64_TYPE_I
: result
= (unit
== IA64_UNIT_I
); break;
6982 case IA64_TYPE_M
: result
= (unit
== IA64_UNIT_M
); break;
6983 case IA64_TYPE_B
: result
= (unit
== IA64_UNIT_B
); break;
6984 case IA64_TYPE_F
: result
= (unit
== IA64_UNIT_F
); break;
6985 default: result
= 0; break;
6990 /* For Itanium 1, add a bit of extra goodness if a nop of type F or B would fit
6991 in TEMPL at SLOT. For Itanium 2, add a bit of extra goodness if a nop of
6992 type M or I would fit in TEMPL at SLOT. */
6995 extra_goodness (int templ
, int slot
)
7000 if (slot
== 1 && match (templ
, IA64_TYPE_F
, slot
))
7002 else if (slot
== 2 && match (templ
, IA64_TYPE_B
, slot
))
7008 if (match (templ
, IA64_TYPE_M
, slot
)
7009 || match (templ
, IA64_TYPE_I
, slot
))
7010 /* Favor M- and I-unit NOPs. We definitely want to avoid
7011 F-unit and B-unit may cause split-issue or less-than-optimal
7012 branch-prediction. */
7023 /* This function is called once, at assembler startup time. It sets
7024 up all the tables, etc. that the MD part of the assembler will need
7025 that can be determined before arguments are parsed. */
7029 int i
, j
, k
, t
, goodness
, best
, ok
;
7034 md
.explicit_mode
= md
.default_explicit_mode
;
7036 bfd_set_section_alignment (stdoutput
, text_section
, 4);
7038 /* Make sure function pointers get initialized. */
7039 target_big_endian
= -1;
7040 dot_byteorder (default_big_endian
);
7042 alias_hash
= hash_new ();
7043 alias_name_hash
= hash_new ();
7044 secalias_hash
= hash_new ();
7045 secalias_name_hash
= hash_new ();
7047 pseudo_func
[FUNC_DTP_MODULE
].u
.sym
=
7048 symbol_new (".<dtpmod>", undefined_section
, FUNC_DTP_MODULE
,
7049 &zero_address_frag
);
7051 pseudo_func
[FUNC_DTP_RELATIVE
].u
.sym
=
7052 symbol_new (".<dtprel>", undefined_section
, FUNC_DTP_RELATIVE
,
7053 &zero_address_frag
);
7055 pseudo_func
[FUNC_FPTR_RELATIVE
].u
.sym
=
7056 symbol_new (".<fptr>", undefined_section
, FUNC_FPTR_RELATIVE
,
7057 &zero_address_frag
);
7059 pseudo_func
[FUNC_GP_RELATIVE
].u
.sym
=
7060 symbol_new (".<gprel>", undefined_section
, FUNC_GP_RELATIVE
,
7061 &zero_address_frag
);
7063 pseudo_func
[FUNC_LT_RELATIVE
].u
.sym
=
7064 symbol_new (".<ltoff>", undefined_section
, FUNC_LT_RELATIVE
,
7065 &zero_address_frag
);
7067 pseudo_func
[FUNC_LT_RELATIVE_X
].u
.sym
=
7068 symbol_new (".<ltoffx>", undefined_section
, FUNC_LT_RELATIVE_X
,
7069 &zero_address_frag
);
7071 pseudo_func
[FUNC_PC_RELATIVE
].u
.sym
=
7072 symbol_new (".<pcrel>", undefined_section
, FUNC_PC_RELATIVE
,
7073 &zero_address_frag
);
7075 pseudo_func
[FUNC_PLT_RELATIVE
].u
.sym
=
7076 symbol_new (".<pltoff>", undefined_section
, FUNC_PLT_RELATIVE
,
7077 &zero_address_frag
);
7079 pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
=
7080 symbol_new (".<secrel>", undefined_section
, FUNC_SEC_RELATIVE
,
7081 &zero_address_frag
);
7083 pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
=
7084 symbol_new (".<segrel>", undefined_section
, FUNC_SEG_RELATIVE
,
7085 &zero_address_frag
);
7087 pseudo_func
[FUNC_TP_RELATIVE
].u
.sym
=
7088 symbol_new (".<tprel>", undefined_section
, FUNC_TP_RELATIVE
,
7089 &zero_address_frag
);
7091 pseudo_func
[FUNC_LTV_RELATIVE
].u
.sym
=
7092 symbol_new (".<ltv>", undefined_section
, FUNC_LTV_RELATIVE
,
7093 &zero_address_frag
);
7095 pseudo_func
[FUNC_LT_FPTR_RELATIVE
].u
.sym
=
7096 symbol_new (".<ltoff.fptr>", undefined_section
, FUNC_LT_FPTR_RELATIVE
,
7097 &zero_address_frag
);
7099 pseudo_func
[FUNC_LT_DTP_MODULE
].u
.sym
=
7100 symbol_new (".<ltoff.dtpmod>", undefined_section
, FUNC_LT_DTP_MODULE
,
7101 &zero_address_frag
);
7103 pseudo_func
[FUNC_LT_DTP_RELATIVE
].u
.sym
=
7104 symbol_new (".<ltoff.dptrel>", undefined_section
, FUNC_LT_DTP_RELATIVE
,
7105 &zero_address_frag
);
7107 pseudo_func
[FUNC_LT_TP_RELATIVE
].u
.sym
=
7108 symbol_new (".<ltoff.tprel>", undefined_section
, FUNC_LT_TP_RELATIVE
,
7109 &zero_address_frag
);
7111 pseudo_func
[FUNC_IPLT_RELOC
].u
.sym
=
7112 symbol_new (".<iplt>", undefined_section
, FUNC_IPLT_RELOC
,
7113 &zero_address_frag
);
7115 if (md
.tune
!= itanium1
)
7117 /* Convert MFI NOPs bundles into MMI NOPs bundles. */
7119 le_nop_stop
[0] = 0x9;
7122 /* Compute the table of best templates. We compute goodness as a
7123 base 4 value, in which each match counts for 3. Match-failures
7124 result in NOPs and we use extra_goodness() to pick the execution
7125 units that are best suited for issuing the NOP. */
7126 for (i
= 0; i
< IA64_NUM_TYPES
; ++i
)
7127 for (j
= 0; j
< IA64_NUM_TYPES
; ++j
)
7128 for (k
= 0; k
< IA64_NUM_TYPES
; ++k
)
7131 for (t
= 0; t
< NELEMS (ia64_templ_desc
); ++t
)
7134 if (match (t
, i
, 0))
7136 if (match (t
, j
, 1))
7138 if ((t
== 2 && j
== IA64_TYPE_X
) || match (t
, k
, 2))
7139 goodness
= 3 + 3 + 3;
7141 goodness
= 3 + 3 + extra_goodness (t
, 2);
7143 else if (match (t
, j
, 2))
7144 goodness
= 3 + 3 + extra_goodness (t
, 1);
7148 goodness
+= extra_goodness (t
, 1);
7149 goodness
+= extra_goodness (t
, 2);
7152 else if (match (t
, i
, 1))
7154 if ((t
== 2 && i
== IA64_TYPE_X
) || match (t
, j
, 2))
7157 goodness
= 3 + extra_goodness (t
, 2);
7159 else if (match (t
, i
, 2))
7160 goodness
= 3 + extra_goodness (t
, 1);
7162 if (goodness
> best
)
7165 best_template
[i
][j
][k
] = t
;
7170 #ifdef DEBUG_TEMPLATES
7171 /* For debugging changes to the best_template calculations. We don't care
7172 about combinations with invalid instructions, so start the loops at 1. */
7173 for (i
= 0; i
< IA64_NUM_TYPES
; ++i
)
7174 for (j
= 0; j
< IA64_NUM_TYPES
; ++j
)
7175 for (k
= 0; k
< IA64_NUM_TYPES
; ++k
)
7177 char type_letter
[IA64_NUM_TYPES
] = { 'n', 'a', 'i', 'm', 'b', 'f',
7179 fprintf (stderr
, "%c%c%c %s\n", type_letter
[i
], type_letter
[j
],
7181 ia64_templ_desc
[best_template
[i
][j
][k
]].name
);
7185 for (i
= 0; i
< NUM_SLOTS
; ++i
)
7186 md
.slot
[i
].user_template
= -1;
7188 md
.pseudo_hash
= hash_new ();
7189 for (i
= 0; i
< NELEMS (pseudo_opcode
); ++i
)
7191 err
= hash_insert (md
.pseudo_hash
, pseudo_opcode
[i
].name
,
7192 (void *) (pseudo_opcode
+ i
));
7194 as_fatal (_("ia64.md_begin: can't hash `%s': %s"),
7195 pseudo_opcode
[i
].name
, err
);
7198 md
.reg_hash
= hash_new ();
7199 md
.dynreg_hash
= hash_new ();
7200 md
.const_hash
= hash_new ();
7201 md
.entry_hash
= hash_new ();
7203 /* general registers: */
7204 declare_register_set ("r", 128, REG_GR
);
7205 declare_register ("gp", REG_GR
+ 1);
7206 declare_register ("sp", REG_GR
+ 12);
7207 declare_register ("tp", REG_GR
+ 13);
7208 declare_register_set ("ret", 4, REG_GR
+ 8);
7210 /* floating point registers: */
7211 declare_register_set ("f", 128, REG_FR
);
7212 declare_register_set ("farg", 8, REG_FR
+ 8);
7213 declare_register_set ("fret", 8, REG_FR
+ 8);
7215 /* branch registers: */
7216 declare_register_set ("b", 8, REG_BR
);
7217 declare_register ("rp", REG_BR
+ 0);
7219 /* predicate registers: */
7220 declare_register_set ("p", 64, REG_P
);
7221 declare_register ("pr", REG_PR
);
7222 declare_register ("pr.rot", REG_PR_ROT
);
7224 /* application registers: */
7225 declare_register_set ("ar", 128, REG_AR
);
7226 for (i
= 0; i
< NELEMS (ar
); ++i
)
7227 declare_register (ar
[i
].name
, REG_AR
+ ar
[i
].regnum
);
7229 /* control registers: */
7230 declare_register_set ("cr", 128, REG_CR
);
7231 for (i
= 0; i
< NELEMS (cr
); ++i
)
7232 declare_register (cr
[i
].name
, REG_CR
+ cr
[i
].regnum
);
7234 declare_register ("ip", REG_IP
);
7235 declare_register ("cfm", REG_CFM
);
7236 declare_register ("psr", REG_PSR
);
7237 declare_register ("psr.l", REG_PSR_L
);
7238 declare_register ("psr.um", REG_PSR_UM
);
7240 for (i
= 0; i
< NELEMS (indirect_reg
); ++i
)
7242 unsigned int regnum
= indirect_reg
[i
].regnum
;
7244 md
.indregsym
[regnum
- IND_CPUID
] = declare_register (indirect_reg
[i
].name
, regnum
);
7247 /* pseudo-registers used to specify unwind info: */
7248 declare_register ("psp", REG_PSP
);
7250 for (i
= 0; i
< NELEMS (const_bits
); ++i
)
7252 err
= hash_insert (md
.const_hash
, const_bits
[i
].name
,
7253 (void *) (const_bits
+ i
));
7255 as_fatal (_("Inserting \"%s\" into constant hash table failed: %s"),
7259 /* Set the architecture and machine depending on defaults and command line
7261 if (md
.flags
& EF_IA_64_ABI64
)
7262 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf64
);
7264 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf32
);
7267 as_warn (_("Could not set architecture and machine"));
7269 /* Set the pointer size and pointer shift size depending on md.flags */
7271 if (md
.flags
& EF_IA_64_ABI64
)
7273 md
.pointer_size
= 8; /* pointers are 8 bytes */
7274 md
.pointer_size_shift
= 3; /* alignment is 8 bytes = 2^2 */
7278 md
.pointer_size
= 4; /* pointers are 4 bytes */
7279 md
.pointer_size_shift
= 2; /* alignment is 4 bytes = 2^2 */
7282 md
.mem_offset
.hint
= 0;
7285 md
.entry_labels
= NULL
;
7288 /* Set the default options in md. Cannot do this in md_begin because
7289 that is called after md_parse_option which is where we set the
7290 options in md based on command line options. */
7293 ia64_init (int argc ATTRIBUTE_UNUSED
, char **argv ATTRIBUTE_UNUSED
)
7295 md
.flags
= MD_FLAGS_DEFAULT
;
7297 /* FIXME: We should change it to unwind_check_error someday. */
7298 md
.unwind_check
= unwind_check_warning
;
7299 md
.hint_b
= hint_b_error
;
7303 /* Return a string for the target object file format. */
7306 ia64_target_format (void)
7308 if (OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
7310 if (md
.flags
& EF_IA_64_BE
)
7312 if (md
.flags
& EF_IA_64_ABI64
)
7313 #if defined(TE_AIX50)
7314 return "elf64-ia64-aix-big";
7315 #elif defined(TE_HPUX)
7316 return "elf64-ia64-hpux-big";
7318 return "elf64-ia64-big";
7321 #if defined(TE_AIX50)
7322 return "elf32-ia64-aix-big";
7323 #elif defined(TE_HPUX)
7324 return "elf32-ia64-hpux-big";
7326 return "elf32-ia64-big";
7331 if (md
.flags
& EF_IA_64_ABI64
)
7333 return "elf64-ia64-aix-little";
7335 return "elf64-ia64-little";
7339 return "elf32-ia64-aix-little";
7341 return "elf32-ia64-little";
7346 return "unknown-format";
7350 ia64_end_of_source (void)
7352 /* terminate insn group upon reaching end of file: */
7353 insn_group_break (1, 0, 0);
7355 /* emits slots we haven't written yet: */
7356 ia64_flush_insns ();
7358 bfd_set_private_flags (stdoutput
, md
.flags
);
7360 md
.mem_offset
.hint
= 0;
7364 ia64_start_line (void)
7369 /* Make sure we don't reference input_line_pointer[-1] when that's
7375 if (md
.qp
.X_op
== O_register
)
7376 as_bad (_("qualifying predicate not followed by instruction"));
7377 md
.qp
.X_op
= O_absent
;
7379 if (ignore_input ())
7382 if (input_line_pointer
[0] == ';' && input_line_pointer
[-1] == ';')
7384 if (md
.detect_dv
&& !md
.explicit_mode
)
7391 as_warn (_("Explicit stops are ignored in auto mode"));
7395 insn_group_break (1, 0, 0);
7397 else if (input_line_pointer
[-1] == '{')
7399 if (md
.manual_bundling
)
7400 as_warn (_("Found '{' when manual bundling is already turned on"));
7402 CURR_SLOT
.manual_bundling_on
= 1;
7403 md
.manual_bundling
= 1;
7405 /* Bundling is only acceptable in explicit mode
7406 or when in default automatic mode. */
7407 if (md
.detect_dv
&& !md
.explicit_mode
)
7409 if (!md
.mode_explicitly_set
7410 && !md
.default_explicit_mode
)
7413 as_warn (_("Found '{' after explicit switch to automatic mode"));
7416 else if (input_line_pointer
[-1] == '}')
7418 if (!md
.manual_bundling
)
7419 as_warn (_("Found '}' when manual bundling is off"));
7421 PREV_SLOT
.manual_bundling_off
= 1;
7422 md
.manual_bundling
= 0;
7424 /* switch back to automatic mode, if applicable */
7427 && !md
.mode_explicitly_set
7428 && !md
.default_explicit_mode
)
7433 /* This is a hook for ia64_frob_label, so that it can distinguish tags from
7435 static int defining_tag
= 0;
7438 ia64_unrecognized_line (int ch
)
7443 expression_and_evaluate (&md
.qp
);
7444 if (*input_line_pointer
++ != ')')
7446 as_bad (_("Expected ')'"));
7449 if (md
.qp
.X_op
!= O_register
)
7451 as_bad (_("Qualifying predicate expected"));
7454 if (md
.qp
.X_add_number
< REG_P
|| md
.qp
.X_add_number
>= REG_P
+ 64)
7456 as_bad (_("Predicate register expected"));
7468 if (md
.qp
.X_op
== O_register
)
7470 as_bad (_("Tag must come before qualifying predicate."));
7474 /* This implements just enough of read_a_source_file in read.c to
7475 recognize labels. */
7476 if (is_name_beginner (*input_line_pointer
))
7478 s
= input_line_pointer
;
7479 c
= get_symbol_end ();
7481 else if (LOCAL_LABELS_FB
7482 && ISDIGIT (*input_line_pointer
))
7485 while (ISDIGIT (*input_line_pointer
))
7486 temp
= (temp
* 10) + *input_line_pointer
++ - '0';
7487 fb_label_instance_inc (temp
);
7488 s
= fb_label_name (temp
, 0);
7489 c
= *input_line_pointer
;
7498 /* Put ':' back for error messages' sake. */
7499 *input_line_pointer
++ = ':';
7500 as_bad (_("Expected ':'"));
7507 /* Put ':' back for error messages' sake. */
7508 *input_line_pointer
++ = ':';
7509 if (*input_line_pointer
++ != ']')
7511 as_bad (_("Expected ']'"));
7516 as_bad (_("Tag name expected"));
7526 /* Not a valid line. */
7531 ia64_frob_label (struct symbol
*sym
)
7533 struct label_fix
*fix
;
7535 /* Tags need special handling since they are not bundle breaks like
7539 fix
= obstack_alloc (¬es
, sizeof (*fix
));
7541 fix
->next
= CURR_SLOT
.tag_fixups
;
7542 fix
->dw2_mark_labels
= FALSE
;
7543 CURR_SLOT
.tag_fixups
= fix
;
7548 if (bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7550 md
.last_text_seg
= now_seg
;
7551 fix
= obstack_alloc (¬es
, sizeof (*fix
));
7553 fix
->next
= CURR_SLOT
.label_fixups
;
7554 fix
->dw2_mark_labels
= dwarf2_loc_mark_labels
;
7555 CURR_SLOT
.label_fixups
= fix
;
7557 /* Keep track of how many code entry points we've seen. */
7558 if (md
.path
== md
.maxpaths
)
7561 md
.entry_labels
= (const char **)
7562 xrealloc ((void *) md
.entry_labels
,
7563 md
.maxpaths
* sizeof (char *));
7565 md
.entry_labels
[md
.path
++] = S_GET_NAME (sym
);
7570 /* The HP-UX linker will give unresolved symbol errors for symbols
7571 that are declared but unused. This routine removes declared,
7572 unused symbols from an object. */
7574 ia64_frob_symbol (struct symbol
*sym
)
7576 if ((S_GET_SEGMENT (sym
) == &bfd_und_section
&& ! symbol_used_p (sym
) &&
7577 ELF_ST_VISIBILITY (S_GET_OTHER (sym
)) == STV_DEFAULT
)
7578 || (S_GET_SEGMENT (sym
) == &bfd_abs_section
7579 && ! S_IS_EXTERNAL (sym
)))
7586 ia64_flush_pending_output (void)
7588 if (!md
.keep_pending_output
7589 && bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7591 /* ??? This causes many unnecessary stop bits to be emitted.
7592 Unfortunately, it isn't clear if it is safe to remove this. */
7593 insn_group_break (1, 0, 0);
7594 ia64_flush_insns ();
7598 /* Do ia64-specific expression optimization. All that's done here is
7599 to transform index expressions that are either due to the indexing
7600 of rotating registers or due to the indexing of indirect register
7603 ia64_optimize_expr (expressionS
*l
, operatorT op
, expressionS
*r
)
7607 resolve_expression (l
);
7608 if (l
->X_op
== O_register
)
7610 unsigned num_regs
= l
->X_add_number
>> 16;
7612 resolve_expression (r
);
7615 /* Left side is a .rotX-allocated register. */
7616 if (r
->X_op
!= O_constant
)
7618 as_bad (_("Rotating register index must be a non-negative constant"));
7619 r
->X_add_number
= 0;
7621 else if ((valueT
) r
->X_add_number
>= num_regs
)
7623 as_bad (_("Index out of range 0..%u"), num_regs
- 1);
7624 r
->X_add_number
= 0;
7626 l
->X_add_number
= (l
->X_add_number
& 0xffff) + r
->X_add_number
;
7629 else if (l
->X_add_number
>= IND_CPUID
&& l
->X_add_number
<= IND_RR
)
7631 if (r
->X_op
!= O_register
7632 || r
->X_add_number
< REG_GR
7633 || r
->X_add_number
> REG_GR
+ 127)
7635 as_bad (_("Indirect register index must be a general register"));
7636 r
->X_add_number
= REG_GR
;
7639 l
->X_op_symbol
= md
.indregsym
[l
->X_add_number
- IND_CPUID
];
7640 l
->X_add_number
= r
->X_add_number
;
7644 as_bad (_("Index can only be applied to rotating or indirect registers"));
7645 /* Fall back to some register use of which has as little as possible
7646 side effects, to minimize subsequent error messages. */
7647 l
->X_op
= O_register
;
7648 l
->X_add_number
= REG_GR
+ 3;
7653 ia64_parse_name (char *name
, expressionS
*e
, char *nextcharP
)
7655 struct const_desc
*cdesc
;
7656 struct dynreg
*dr
= 0;
7663 enum pseudo_type pseudo_type
= PSEUDO_FUNC_NONE
;
7665 /* Find what relocation pseudo-function we're dealing with. */
7666 for (idx
= 0; idx
< NELEMS (pseudo_func
); ++idx
)
7667 if (pseudo_func
[idx
].name
7668 && pseudo_func
[idx
].name
[0] == name
[1]
7669 && strcmp (pseudo_func
[idx
].name
+ 1, name
+ 2) == 0)
7671 pseudo_type
= pseudo_func
[idx
].type
;
7674 switch (pseudo_type
)
7676 case PSEUDO_FUNC_RELOC
:
7677 end
= input_line_pointer
;
7678 if (*nextcharP
!= '(')
7680 as_bad (_("Expected '('"));
7684 ++input_line_pointer
;
7686 if (*input_line_pointer
!= ')')
7688 as_bad (_("Missing ')'"));
7692 ++input_line_pointer
;
7693 if (e
->X_op
!= O_symbol
)
7695 if (e
->X_op
!= O_pseudo_fixup
)
7697 as_bad (_("Not a symbolic expression"));
7700 if (idx
!= FUNC_LT_RELATIVE
)
7702 as_bad (_("Illegal combination of relocation functions"));
7705 switch (S_GET_VALUE (e
->X_op_symbol
))
7707 case FUNC_FPTR_RELATIVE
:
7708 idx
= FUNC_LT_FPTR_RELATIVE
; break;
7709 case FUNC_DTP_MODULE
:
7710 idx
= FUNC_LT_DTP_MODULE
; break;
7711 case FUNC_DTP_RELATIVE
:
7712 idx
= FUNC_LT_DTP_RELATIVE
; break;
7713 case FUNC_TP_RELATIVE
:
7714 idx
= FUNC_LT_TP_RELATIVE
; break;
7716 as_bad (_("Illegal combination of relocation functions"));
7720 /* Make sure gas doesn't get rid of local symbols that are used
7722 e
->X_op
= O_pseudo_fixup
;
7723 e
->X_op_symbol
= pseudo_func
[idx
].u
.sym
;
7725 *nextcharP
= *input_line_pointer
;
7728 case PSEUDO_FUNC_CONST
:
7729 e
->X_op
= O_constant
;
7730 e
->X_add_number
= pseudo_func
[idx
].u
.ival
;
7733 case PSEUDO_FUNC_REG
:
7734 e
->X_op
= O_register
;
7735 e
->X_add_number
= pseudo_func
[idx
].u
.ival
;
7744 /* first see if NAME is a known register name: */
7745 sym
= hash_find (md
.reg_hash
, name
);
7748 e
->X_op
= O_register
;
7749 e
->X_add_number
= S_GET_VALUE (sym
);
7753 cdesc
= hash_find (md
.const_hash
, name
);
7756 e
->X_op
= O_constant
;
7757 e
->X_add_number
= cdesc
->value
;
7761 /* check for inN, locN, or outN: */
7766 if (name
[1] == 'n' && ISDIGIT (name
[2]))
7774 if (name
[1] == 'o' && name
[2] == 'c' && ISDIGIT (name
[3]))
7782 if (name
[1] == 'u' && name
[2] == 't' && ISDIGIT (name
[3]))
7793 /* Ignore register numbers with leading zeroes, except zero itself. */
7794 if (dr
&& (name
[idx
] != '0' || name
[idx
+ 1] == '\0'))
7796 unsigned long regnum
;
7798 /* The name is inN, locN, or outN; parse the register number. */
7799 regnum
= strtoul (name
+ idx
, &end
, 10);
7800 if (end
> name
+ idx
&& *end
== '\0' && regnum
< 96)
7802 if (regnum
>= dr
->num_regs
)
7805 as_bad (_("No current frame"));
7807 as_bad (_("Register number out of range 0..%u"),
7811 e
->X_op
= O_register
;
7812 e
->X_add_number
= dr
->base
+ regnum
;
7817 end
= alloca (strlen (name
) + 1);
7819 name
= ia64_canonicalize_symbol_name (end
);
7820 if ((dr
= hash_find (md
.dynreg_hash
, name
)))
7822 /* We've got ourselves the name of a rotating register set.
7823 Store the base register number in the low 16 bits of
7824 X_add_number and the size of the register set in the top 16
7826 e
->X_op
= O_register
;
7827 e
->X_add_number
= dr
->base
| (dr
->num_regs
<< 16);
7833 /* Remove the '#' suffix that indicates a symbol as opposed to a register. */
7836 ia64_canonicalize_symbol_name (char *name
)
7838 size_t len
= strlen (name
), full
= len
;
7840 while (len
> 0 && name
[len
- 1] == '#')
7845 as_bad (_("Standalone `#' is illegal"));
7847 else if (len
< full
- 1)
7848 as_warn (_("Redundant `#' suffix operators"));
7853 /* Return true if idesc is a conditional branch instruction. This excludes
7854 the modulo scheduled branches, and br.ia. Mod-sched branches are excluded
7855 because they always read/write resources regardless of the value of the
7856 qualifying predicate. br.ia must always use p0, and hence is always
7857 taken. Thus this function returns true for branches which can fall
7858 through, and which use no resources if they do fall through. */
7861 is_conditional_branch (struct ia64_opcode
*idesc
)
7863 /* br is a conditional branch. Everything that starts with br. except
7864 br.ia, br.c{loop,top,exit}, and br.w{top,exit} is a conditional branch.
7865 Everything that starts with brl is a conditional branch. */
7866 return (idesc
->name
[0] == 'b' && idesc
->name
[1] == 'r'
7867 && (idesc
->name
[2] == '\0'
7868 || (idesc
->name
[2] == '.' && idesc
->name
[3] != 'i'
7869 && idesc
->name
[3] != 'c' && idesc
->name
[3] != 'w')
7870 || idesc
->name
[2] == 'l'
7871 /* br.cond, br.call, br.clr */
7872 || (idesc
->name
[2] == '.' && idesc
->name
[3] == 'c'
7873 && (idesc
->name
[4] == 'a' || idesc
->name
[4] == 'o'
7874 || (idesc
->name
[4] == 'l' && idesc
->name
[5] == 'r')))));
7877 /* Return whether the given opcode is a taken branch. If there's any doubt,
7881 is_taken_branch (struct ia64_opcode
*idesc
)
7883 return ((is_conditional_branch (idesc
) && CURR_SLOT
.qp_regno
== 0)
7884 || strncmp (idesc
->name
, "br.ia", 5) == 0);
7887 /* Return whether the given opcode is an interruption or rfi. If there's any
7888 doubt, returns zero. */
7891 is_interruption_or_rfi (struct ia64_opcode
*idesc
)
7893 if (strcmp (idesc
->name
, "rfi") == 0)
7898 /* Returns the index of the given dependency in the opcode's list of chks, or
7899 -1 if there is no dependency. */
7902 depends_on (int depind
, struct ia64_opcode
*idesc
)
7905 const struct ia64_opcode_dependency
*dep
= idesc
->dependencies
;
7906 for (i
= 0; i
< dep
->nchks
; i
++)
7908 if (depind
== DEP (dep
->chks
[i
]))
7914 /* Determine a set of specific resources used for a particular resource
7915 class. Returns the number of specific resources identified For those
7916 cases which are not determinable statically, the resource returned is
7919 Meanings of value in 'NOTE':
7920 1) only read/write when the register number is explicitly encoded in the
7922 2) only read CFM when accessing a rotating GR, FR, or PR. mov pr only
7923 accesses CFM when qualifying predicate is in the rotating region.
7924 3) general register value is used to specify an indirect register; not
7925 determinable statically.
7926 4) only read the given resource when bits 7:0 of the indirect index
7927 register value does not match the register number of the resource; not
7928 determinable statically.
7929 5) all rules are implementation specific.
7930 6) only when both the index specified by the reader and the index specified
7931 by the writer have the same value in bits 63:61; not determinable
7933 7) only access the specified resource when the corresponding mask bit is
7935 8) PSR.dfh is only read when these insns reference FR32-127. PSR.dfl is
7936 only read when these insns reference FR2-31
7937 9) PSR.mfl is only written when these insns write FR2-31. PSR.mfh is only
7938 written when these insns write FR32-127
7939 10) The PSR.bn bit is only accessed when one of GR16-31 is specified in the
7941 11) The target predicates are written independently of PR[qp], but source
7942 registers are only read if PR[qp] is true. Since the state of PR[qp]
7943 cannot statically be determined, all source registers are marked used.
7944 12) This insn only reads the specified predicate register when that
7945 register is the PR[qp].
7946 13) This reference to ld-c only applies to the GR whose value is loaded
7947 with data returned from memory, not the post-incremented address register.
7948 14) The RSE resource includes the implementation-specific RSE internal
7949 state resources. At least one (and possibly more) of these resources are
7950 read by each instruction listed in IC:rse-readers. At least one (and
7951 possibly more) of these resources are written by each insn listed in
7953 15+16) Represents reserved instructions, which the assembler does not
7955 17) CR[TPR] has a RAW dependency only between mov-to-CR-TPR and
7956 mov-to-PSR-l or ssm instructions that set PSR.i, PSR.pp or PSR.up.
7958 Memory resources (i.e. locations in memory) are *not* marked or tracked by
7959 this code; there are no dependency violations based on memory access.
7962 #define MAX_SPECS 256
7967 specify_resource (const struct ia64_dependency
*dep
,
7968 struct ia64_opcode
*idesc
,
7969 /* is this a DV chk or a DV reg? */
7971 /* returned specific resources */
7972 struct rsrc specs
[MAX_SPECS
],
7973 /* resource note for this insn's usage */
7975 /* which execution path to examine */
7983 if (dep
->mode
== IA64_DV_WAW
7984 || (dep
->mode
== IA64_DV_RAW
&& type
== DV_REG
)
7985 || (dep
->mode
== IA64_DV_WAR
&& type
== DV_CHK
))
7988 /* template for any resources we identify */
7989 tmpl
.dependency
= dep
;
7991 tmpl
.insn_srlz
= tmpl
.data_srlz
= 0;
7992 tmpl
.qp_regno
= CURR_SLOT
.qp_regno
;
7993 tmpl
.link_to_qp_branch
= 1;
7994 tmpl
.mem_offset
.hint
= 0;
7995 tmpl
.mem_offset
.offset
= 0;
7996 tmpl
.mem_offset
.base
= 0;
7999 tmpl
.cmp_type
= CMP_NONE
;
8006 as_warn (_("Unhandled dependency %s for %s (%s), note %d"), \
8007 dep->name, idesc->name, (rsrc_write?"write":"read"), note)
8008 #define KNOWN(REG) (gr_values[REG].known && gr_values[REG].path >= path)
8010 /* we don't need to track these */
8011 if (dep
->semantics
== IA64_DVS_NONE
)
8014 switch (dep
->specifier
)
8019 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8021 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8022 if (regno
>= 0 && regno
<= 7)
8024 specs
[count
] = tmpl
;
8025 specs
[count
++].index
= regno
;
8031 for (i
= 0; i
< 8; i
++)
8033 specs
[count
] = tmpl
;
8034 specs
[count
++].index
= i
;
8043 case IA64_RS_AR_UNAT
:
8044 /* This is a mov =AR or mov AR= instruction. */
8045 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8047 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8048 if (regno
== AR_UNAT
)
8050 specs
[count
++] = tmpl
;
8055 /* This is a spill/fill, or other instruction that modifies the
8058 /* Unless we can determine the specific bits used, mark the whole
8059 thing; bits 8:3 of the memory address indicate the bit used in
8060 UNAT. The .mem.offset hint may be used to eliminate a small
8061 subset of conflicts. */
8062 specs
[count
] = tmpl
;
8063 if (md
.mem_offset
.hint
)
8066 fprintf (stderr
, " Using hint for spill/fill\n");
8067 /* The index isn't actually used, just set it to something
8068 approximating the bit index. */
8069 specs
[count
].index
= (md
.mem_offset
.offset
>> 3) & 0x3F;
8070 specs
[count
].mem_offset
.hint
= 1;
8071 specs
[count
].mem_offset
.offset
= md
.mem_offset
.offset
;
8072 specs
[count
++].mem_offset
.base
= md
.mem_offset
.base
;
8076 specs
[count
++].specific
= 0;
8084 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8086 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8087 if ((regno
>= 8 && regno
<= 15)
8088 || (regno
>= 20 && regno
<= 23)
8089 || (regno
>= 31 && regno
<= 39)
8090 || (regno
>= 41 && regno
<= 47)
8091 || (regno
>= 67 && regno
<= 111))
8093 specs
[count
] = tmpl
;
8094 specs
[count
++].index
= regno
;
8107 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8109 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8110 if ((regno
>= 48 && regno
<= 63)
8111 || (regno
>= 112 && regno
<= 127))
8113 specs
[count
] = tmpl
;
8114 specs
[count
++].index
= regno
;
8120 for (i
= 48; i
< 64; i
++)
8122 specs
[count
] = tmpl
;
8123 specs
[count
++].index
= i
;
8125 for (i
= 112; i
< 128; i
++)
8127 specs
[count
] = tmpl
;
8128 specs
[count
++].index
= i
;
8146 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8147 if (idesc
->operands
[i
] == IA64_OPND_B1
8148 || idesc
->operands
[i
] == IA64_OPND_B2
)
8150 specs
[count
] = tmpl
;
8151 specs
[count
++].index
=
8152 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
8157 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
8158 if (idesc
->operands
[i
] == IA64_OPND_B1
8159 || idesc
->operands
[i
] == IA64_OPND_B2
)
8161 specs
[count
] = tmpl
;
8162 specs
[count
++].index
=
8163 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
8169 case IA64_RS_CPUID
: /* four or more registers */
8172 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CPUID_R3
)
8174 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8175 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8178 specs
[count
] = tmpl
;
8179 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8183 specs
[count
] = tmpl
;
8184 specs
[count
++].specific
= 0;
8194 case IA64_RS_DBR
: /* four or more registers */
8197 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_DBR_R3
)
8199 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8200 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8203 specs
[count
] = tmpl
;
8204 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8208 specs
[count
] = tmpl
;
8209 specs
[count
++].specific
= 0;
8213 else if (note
== 0 && !rsrc_write
)
8215 specs
[count
] = tmpl
;
8216 specs
[count
++].specific
= 0;
8224 case IA64_RS_IBR
: /* four or more registers */
8227 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_IBR_R3
)
8229 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8230 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8233 specs
[count
] = tmpl
;
8234 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8238 specs
[count
] = tmpl
;
8239 specs
[count
++].specific
= 0;
8252 /* These are implementation specific. Force all references to
8253 conflict with all other references. */
8254 specs
[count
] = tmpl
;
8255 specs
[count
++].specific
= 0;
8263 case IA64_RS_PKR
: /* 16 or more registers */
8264 if (note
== 3 || note
== 4)
8266 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PKR_R3
)
8268 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8269 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8274 specs
[count
] = tmpl
;
8275 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8278 for (i
= 0; i
< NELEMS (gr_values
); i
++)
8280 /* Uses all registers *except* the one in R3. */
8281 if ((unsigned)i
!= (gr_values
[regno
].value
& 0xFF))
8283 specs
[count
] = tmpl
;
8284 specs
[count
++].index
= i
;
8290 specs
[count
] = tmpl
;
8291 specs
[count
++].specific
= 0;
8298 specs
[count
] = tmpl
;
8299 specs
[count
++].specific
= 0;
8303 case IA64_RS_PMC
: /* four or more registers */
8306 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMC_R3
8307 || (!rsrc_write
&& idesc
->operands
[1] == IA64_OPND_PMD_R3
))
8310 int index
= ((idesc
->operands
[1] == IA64_OPND_R3
&& !rsrc_write
)
8312 int regno
= CURR_SLOT
.opnd
[index
].X_add_number
- REG_GR
;
8313 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8316 specs
[count
] = tmpl
;
8317 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8321 specs
[count
] = tmpl
;
8322 specs
[count
++].specific
= 0;
8332 case IA64_RS_PMD
: /* four or more registers */
8335 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMD_R3
)
8337 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8338 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8341 specs
[count
] = tmpl
;
8342 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8346 specs
[count
] = tmpl
;
8347 specs
[count
++].specific
= 0;
8357 case IA64_RS_RR
: /* eight registers */
8360 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_RR_R3
)
8362 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8363 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8366 specs
[count
] = tmpl
;
8367 specs
[count
++].index
= (gr_values
[regno
].value
>> 61) & 0x7;
8371 specs
[count
] = tmpl
;
8372 specs
[count
++].specific
= 0;
8376 else if (note
== 0 && !rsrc_write
)
8378 specs
[count
] = tmpl
;
8379 specs
[count
++].specific
= 0;
8387 case IA64_RS_CR_IRR
:
8390 /* handle mov-from-CR-IVR; it's a read that writes CR[IRR] */
8391 int regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
;
8393 && idesc
->operands
[1] == IA64_OPND_CR3
8396 for (i
= 0; i
< 4; i
++)
8398 specs
[count
] = tmpl
;
8399 specs
[count
++].index
= CR_IRR0
+ i
;
8405 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8406 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
8408 && regno
<= CR_IRR3
)
8410 specs
[count
] = tmpl
;
8411 specs
[count
++].index
= regno
;
8420 case IA64_RS_CR_LRR
:
8427 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8428 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
8429 && (regno
== CR_LRR0
|| regno
== CR_LRR1
))
8431 specs
[count
] = tmpl
;
8432 specs
[count
++].index
= regno
;
8440 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
8442 specs
[count
] = tmpl
;
8443 specs
[count
++].index
=
8444 CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8459 else if (rsrc_write
)
8461 if (dep
->specifier
== IA64_RS_FRb
8462 && idesc
->operands
[0] == IA64_OPND_F1
)
8464 specs
[count
] = tmpl
;
8465 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_FR
;
8470 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
8472 if (idesc
->operands
[i
] == IA64_OPND_F2
8473 || idesc
->operands
[i
] == IA64_OPND_F3
8474 || idesc
->operands
[i
] == IA64_OPND_F4
)
8476 specs
[count
] = tmpl
;
8477 specs
[count
++].index
=
8478 CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8487 /* This reference applies only to the GR whose value is loaded with
8488 data returned from memory. */
8489 specs
[count
] = tmpl
;
8490 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
8496 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8497 if (idesc
->operands
[i
] == IA64_OPND_R1
8498 || idesc
->operands
[i
] == IA64_OPND_R2
8499 || idesc
->operands
[i
] == IA64_OPND_R3
)
8501 specs
[count
] = tmpl
;
8502 specs
[count
++].index
=
8503 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8505 if (idesc
->flags
& IA64_OPCODE_POSTINC
)
8506 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8507 if (idesc
->operands
[i
] == IA64_OPND_MR3
)
8509 specs
[count
] = tmpl
;
8510 specs
[count
++].index
=
8511 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8516 /* Look for anything that reads a GR. */
8517 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8519 if (idesc
->operands
[i
] == IA64_OPND_MR3
8520 || idesc
->operands
[i
] == IA64_OPND_CPUID_R3
8521 || idesc
->operands
[i
] == IA64_OPND_DBR_R3
8522 || idesc
->operands
[i
] == IA64_OPND_IBR_R3
8523 || idesc
->operands
[i
] == IA64_OPND_MSR_R3
8524 || idesc
->operands
[i
] == IA64_OPND_PKR_R3
8525 || idesc
->operands
[i
] == IA64_OPND_PMC_R3
8526 || idesc
->operands
[i
] == IA64_OPND_PMD_R3
8527 || idesc
->operands
[i
] == IA64_OPND_RR_R3
8528 || ((i
>= idesc
->num_outputs
)
8529 && (idesc
->operands
[i
] == IA64_OPND_R1
8530 || idesc
->operands
[i
] == IA64_OPND_R2
8531 || idesc
->operands
[i
] == IA64_OPND_R3
8532 /* addl source register. */
8533 || idesc
->operands
[i
] == IA64_OPND_R3_2
)))
8535 specs
[count
] = tmpl
;
8536 specs
[count
++].index
=
8537 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8548 /* This is the same as IA64_RS_PRr, except that the register range is
8549 from 1 - 15, and there are no rotating register reads/writes here. */
8553 for (i
= 1; i
< 16; i
++)
8555 specs
[count
] = tmpl
;
8556 specs
[count
++].index
= i
;
8562 /* Mark only those registers indicated by the mask. */
8565 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8566 for (i
= 1; i
< 16; i
++)
8567 if (mask
& ((valueT
) 1 << i
))
8569 specs
[count
] = tmpl
;
8570 specs
[count
++].index
= i
;
8578 else if (note
== 11) /* note 11 implies note 1 as well */
8582 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8584 if (idesc
->operands
[i
] == IA64_OPND_P1
8585 || idesc
->operands
[i
] == IA64_OPND_P2
)
8587 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8588 if (regno
>= 1 && regno
< 16)
8590 specs
[count
] = tmpl
;
8591 specs
[count
++].index
= regno
;
8601 else if (note
== 12)
8603 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
8605 specs
[count
] = tmpl
;
8606 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8613 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8614 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8615 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8616 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8618 if ((idesc
->operands
[0] == IA64_OPND_P1
8619 || idesc
->operands
[0] == IA64_OPND_P2
)
8620 && p1
>= 1 && p1
< 16)
8622 specs
[count
] = tmpl
;
8623 specs
[count
].cmp_type
=
8624 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8625 specs
[count
++].index
= p1
;
8627 if ((idesc
->operands
[1] == IA64_OPND_P1
8628 || idesc
->operands
[1] == IA64_OPND_P2
)
8629 && p2
>= 1 && p2
< 16)
8631 specs
[count
] = tmpl
;
8632 specs
[count
].cmp_type
=
8633 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8634 specs
[count
++].index
= p2
;
8639 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
8641 specs
[count
] = tmpl
;
8642 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8644 if (idesc
->operands
[1] == IA64_OPND_PR
)
8646 for (i
= 1; i
< 16; i
++)
8648 specs
[count
] = tmpl
;
8649 specs
[count
++].index
= i
;
8660 /* This is the general case for PRs. IA64_RS_PR and IA64_RS_PR63 are
8661 simplified cases of this. */
8665 for (i
= 16; i
< 63; i
++)
8667 specs
[count
] = tmpl
;
8668 specs
[count
++].index
= i
;
8674 /* Mark only those registers indicated by the mask. */
8676 && idesc
->operands
[0] == IA64_OPND_PR
)
8678 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8679 if (mask
& ((valueT
) 1 << 16))
8680 for (i
= 16; i
< 63; i
++)
8682 specs
[count
] = tmpl
;
8683 specs
[count
++].index
= i
;
8687 && idesc
->operands
[0] == IA64_OPND_PR_ROT
)
8689 for (i
= 16; i
< 63; i
++)
8691 specs
[count
] = tmpl
;
8692 specs
[count
++].index
= i
;
8700 else if (note
== 11) /* note 11 implies note 1 as well */
8704 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8706 if (idesc
->operands
[i
] == IA64_OPND_P1
8707 || idesc
->operands
[i
] == IA64_OPND_P2
)
8709 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8710 if (regno
>= 16 && regno
< 63)
8712 specs
[count
] = tmpl
;
8713 specs
[count
++].index
= regno
;
8723 else if (note
== 12)
8725 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8727 specs
[count
] = tmpl
;
8728 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8735 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8736 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8737 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8738 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8740 if ((idesc
->operands
[0] == IA64_OPND_P1
8741 || idesc
->operands
[0] == IA64_OPND_P2
)
8742 && p1
>= 16 && p1
< 63)
8744 specs
[count
] = tmpl
;
8745 specs
[count
].cmp_type
=
8746 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8747 specs
[count
++].index
= p1
;
8749 if ((idesc
->operands
[1] == IA64_OPND_P1
8750 || idesc
->operands
[1] == IA64_OPND_P2
)
8751 && p2
>= 16 && p2
< 63)
8753 specs
[count
] = tmpl
;
8754 specs
[count
].cmp_type
=
8755 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8756 specs
[count
++].index
= p2
;
8761 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8763 specs
[count
] = tmpl
;
8764 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8766 if (idesc
->operands
[1] == IA64_OPND_PR
)
8768 for (i
= 16; i
< 63; i
++)
8770 specs
[count
] = tmpl
;
8771 specs
[count
++].index
= i
;
8783 /* Verify that the instruction is using the PSR bit indicated in
8787 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_UM
)
8789 if (dep
->regindex
< 6)
8791 specs
[count
++] = tmpl
;
8794 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR
)
8796 if (dep
->regindex
< 32
8797 || dep
->regindex
== 35
8798 || dep
->regindex
== 36
8799 || (!rsrc_write
&& dep
->regindex
== PSR_CPL
))
8801 specs
[count
++] = tmpl
;
8804 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_L
)
8806 if (dep
->regindex
< 32
8807 || dep
->regindex
== 35
8808 || dep
->regindex
== 36
8809 || (rsrc_write
&& dep
->regindex
== PSR_CPL
))
8811 specs
[count
++] = tmpl
;
8816 /* Several PSR bits have very specific dependencies. */
8817 switch (dep
->regindex
)
8820 specs
[count
++] = tmpl
;
8825 specs
[count
++] = tmpl
;
8829 /* Only certain CR accesses use PSR.ic */
8830 if (idesc
->operands
[0] == IA64_OPND_CR3
8831 || idesc
->operands
[1] == IA64_OPND_CR3
)
8834 ((idesc
->operands
[0] == IA64_OPND_CR3
)
8837 CURR_SLOT
.opnd
[index
].X_add_number
- REG_CR
;
8852 specs
[count
++] = tmpl
;
8861 specs
[count
++] = tmpl
;
8865 /* Only some AR accesses use cpl */
8866 if (idesc
->operands
[0] == IA64_OPND_AR3
8867 || idesc
->operands
[1] == IA64_OPND_AR3
)
8870 ((idesc
->operands
[0] == IA64_OPND_AR3
)
8873 CURR_SLOT
.opnd
[index
].X_add_number
- REG_AR
;
8880 && regno
<= AR_K7
))))
8882 specs
[count
++] = tmpl
;
8887 specs
[count
++] = tmpl
;
8897 if (idesc
->operands
[0] == IA64_OPND_IMMU24
)
8899 mask
= CURR_SLOT
.opnd
[0].X_add_number
;
8905 if (mask
& ((valueT
) 1 << dep
->regindex
))
8907 specs
[count
++] = tmpl
;
8912 int min
= dep
->regindex
== PSR_DFL
? 2 : 32;
8913 int max
= dep
->regindex
== PSR_DFL
? 31 : 127;
8914 /* dfh is read on FR32-127; dfl is read on FR2-31 */
8915 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8917 if (idesc
->operands
[i
] == IA64_OPND_F1
8918 || idesc
->operands
[i
] == IA64_OPND_F2
8919 || idesc
->operands
[i
] == IA64_OPND_F3
8920 || idesc
->operands
[i
] == IA64_OPND_F4
)
8922 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8923 if (reg
>= min
&& reg
<= max
)
8925 specs
[count
++] = tmpl
;
8932 int min
= dep
->regindex
== PSR_MFL
? 2 : 32;
8933 int max
= dep
->regindex
== PSR_MFL
? 31 : 127;
8934 /* mfh is read on writes to FR32-127; mfl is read on writes to
8936 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8938 if (idesc
->operands
[i
] == IA64_OPND_F1
)
8940 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8941 if (reg
>= min
&& reg
<= max
)
8943 specs
[count
++] = tmpl
;
8948 else if (note
== 10)
8950 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8952 if (idesc
->operands
[i
] == IA64_OPND_R1
8953 || idesc
->operands
[i
] == IA64_OPND_R2
8954 || idesc
->operands
[i
] == IA64_OPND_R3
)
8956 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8957 if (regno
>= 16 && regno
<= 31)
8959 specs
[count
++] = tmpl
;
8970 case IA64_RS_AR_FPSR
:
8971 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8973 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8974 if (regno
== AR_FPSR
)
8976 specs
[count
++] = tmpl
;
8981 specs
[count
++] = tmpl
;
8986 /* Handle all AR[REG] resources */
8987 if (note
== 0 || note
== 1)
8989 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8990 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
8991 && regno
== dep
->regindex
)
8993 specs
[count
++] = tmpl
;
8995 /* other AR[REG] resources may be affected by AR accesses */
8996 else if (idesc
->operands
[0] == IA64_OPND_AR3
)
8999 regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
;
9000 switch (dep
->regindex
)
9006 if (regno
== AR_BSPSTORE
)
9008 specs
[count
++] = tmpl
;
9012 (regno
== AR_BSPSTORE
9013 || regno
== AR_RNAT
))
9015 specs
[count
++] = tmpl
;
9020 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
9023 regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
;
9024 switch (dep
->regindex
)
9029 if (regno
== AR_BSPSTORE
|| regno
== AR_RNAT
)
9031 specs
[count
++] = tmpl
;
9038 specs
[count
++] = tmpl
;
9048 /* Handle all CR[REG] resources.
9049 ??? FIXME: The rule 17 isn't really handled correctly. */
9050 if (note
== 0 || note
== 1 || note
== 17)
9052 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
9054 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
9055 if (regno
== dep
->regindex
)
9057 specs
[count
++] = tmpl
;
9059 else if (!rsrc_write
)
9061 /* Reads from CR[IVR] affect other resources. */
9062 if (regno
== CR_IVR
)
9064 if ((dep
->regindex
>= CR_IRR0
9065 && dep
->regindex
<= CR_IRR3
)
9066 || dep
->regindex
== CR_TPR
)
9068 specs
[count
++] = tmpl
;
9075 specs
[count
++] = tmpl
;
9084 case IA64_RS_INSERVICE
:
9085 /* look for write of EOI (67) or read of IVR (65) */
9086 if ((idesc
->operands
[0] == IA64_OPND_CR3
9087 && CURR_SLOT
.opnd
[0].X_add_number
- REG_CR
== CR_EOI
)
9088 || (idesc
->operands
[1] == IA64_OPND_CR3
9089 && CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
== CR_IVR
))
9091 specs
[count
++] = tmpl
;
9098 specs
[count
++] = tmpl
;
9109 specs
[count
++] = tmpl
;
9113 /* Check if any of the registers accessed are in the rotating region.
9114 mov to/from pr accesses CFM only when qp_regno is in the rotating
9116 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
9118 if (idesc
->operands
[i
] == IA64_OPND_R1
9119 || idesc
->operands
[i
] == IA64_OPND_R2
9120 || idesc
->operands
[i
] == IA64_OPND_R3
)
9122 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9123 /* Assumes that md.rot.num_regs is always valid */
9124 if (md
.rot
.num_regs
> 0
9126 && num
< 31 + md
.rot
.num_regs
)
9128 specs
[count
] = tmpl
;
9129 specs
[count
++].specific
= 0;
9132 else if (idesc
->operands
[i
] == IA64_OPND_F1
9133 || idesc
->operands
[i
] == IA64_OPND_F2
9134 || idesc
->operands
[i
] == IA64_OPND_F3
9135 || idesc
->operands
[i
] == IA64_OPND_F4
)
9137 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
9140 specs
[count
] = tmpl
;
9141 specs
[count
++].specific
= 0;
9144 else if (idesc
->operands
[i
] == IA64_OPND_P1
9145 || idesc
->operands
[i
] == IA64_OPND_P2
)
9147 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
9150 specs
[count
] = tmpl
;
9151 specs
[count
++].specific
= 0;
9155 if (CURR_SLOT
.qp_regno
> 15)
9157 specs
[count
] = tmpl
;
9158 specs
[count
++].specific
= 0;
9163 /* This is the same as IA64_RS_PRr, except simplified to account for
9164 the fact that there is only one register. */
9168 specs
[count
++] = tmpl
;
9173 if (idesc
->operands
[2] == IA64_OPND_IMM17
)
9174 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
9175 if (mask
& ((valueT
) 1 << 63))
9176 specs
[count
++] = tmpl
;
9178 else if (note
== 11)
9180 if ((idesc
->operands
[0] == IA64_OPND_P1
9181 && CURR_SLOT
.opnd
[0].X_add_number
- REG_P
== 63)
9182 || (idesc
->operands
[1] == IA64_OPND_P2
9183 && CURR_SLOT
.opnd
[1].X_add_number
- REG_P
== 63))
9185 specs
[count
++] = tmpl
;
9188 else if (note
== 12)
9190 if (CURR_SLOT
.qp_regno
== 63)
9192 specs
[count
++] = tmpl
;
9199 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
9200 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
9201 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
9202 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
9205 && (idesc
->operands
[0] == IA64_OPND_P1
9206 || idesc
->operands
[0] == IA64_OPND_P2
))
9208 specs
[count
] = tmpl
;
9209 specs
[count
++].cmp_type
=
9210 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
9213 && (idesc
->operands
[1] == IA64_OPND_P1
9214 || idesc
->operands
[1] == IA64_OPND_P2
))
9216 specs
[count
] = tmpl
;
9217 specs
[count
++].cmp_type
=
9218 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
9223 if (CURR_SLOT
.qp_regno
== 63)
9225 specs
[count
++] = tmpl
;
9236 /* FIXME we can identify some individual RSE written resources, but RSE
9237 read resources have not yet been completely identified, so for now
9238 treat RSE as a single resource */
9239 if (strncmp (idesc
->name
, "mov", 3) == 0)
9243 if (idesc
->operands
[0] == IA64_OPND_AR3
9244 && CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
)
9246 specs
[count
++] = tmpl
;
9251 if (idesc
->operands
[0] == IA64_OPND_AR3
)
9253 if (CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
9254 || CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_RNAT
)
9256 specs
[count
++] = tmpl
;
9259 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
9261 if (CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSP
9262 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSPSTORE
9263 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_RNAT
)
9265 specs
[count
++] = tmpl
;
9272 specs
[count
++] = tmpl
;
9277 /* FIXME -- do any of these need to be non-specific? */
9278 specs
[count
++] = tmpl
;
9282 as_bad (_("Unrecognized dependency specifier %d\n"), dep
->specifier
);
9289 /* Clear branch flags on marked resources. This breaks the link between the
9290 QP of the marking instruction and a subsequent branch on the same QP. */
9293 clear_qp_branch_flag (valueT mask
)
9296 for (i
= 0; i
< regdepslen
; i
++)
9298 valueT bit
= ((valueT
) 1 << regdeps
[i
].qp_regno
);
9299 if ((bit
& mask
) != 0)
9301 regdeps
[i
].link_to_qp_branch
= 0;
9306 /* MASK contains 2 and only 2 PRs which are mutually exclusive. Remove
9307 any mutexes which contain one of the PRs and create new ones when
9311 update_qp_mutex (valueT mask
)
9317 while (i
< qp_mutexeslen
)
9319 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
9321 /* If it destroys and creates the same mutex, do nothing. */
9322 if (qp_mutexes
[i
].prmask
== mask
9323 && qp_mutexes
[i
].path
== md
.path
)
9334 fprintf (stderr
, " Clearing mutex relation");
9335 print_prmask (qp_mutexes
[i
].prmask
);
9336 fprintf (stderr
, "\n");
9339 /* Deal with the old mutex with more than 3+ PRs only if
9340 the new mutex on the same execution path with it.
9342 FIXME: The 3+ mutex support is incomplete.
9343 dot_pred_rel () may be a better place to fix it. */
9344 if (qp_mutexes
[i
].path
== md
.path
)
9346 /* If it is a proper subset of the mutex, create a
9349 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
9352 qp_mutexes
[i
].prmask
&= ~mask
;
9353 if (qp_mutexes
[i
].prmask
& (qp_mutexes
[i
].prmask
- 1))
9355 /* Modify the mutex if there are more than one
9363 /* Remove the mutex. */
9364 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
9372 add_qp_mutex (mask
);
9377 /* Remove any mutexes which contain any of the PRs indicated in the mask.
9379 Any changes to a PR clears the mutex relations which include that PR. */
9382 clear_qp_mutex (valueT mask
)
9387 while (i
< qp_mutexeslen
)
9389 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
9393 fprintf (stderr
, " Clearing mutex relation");
9394 print_prmask (qp_mutexes
[i
].prmask
);
9395 fprintf (stderr
, "\n");
9397 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
9404 /* Clear implies relations which contain PRs in the given masks.
9405 P1_MASK indicates the source of the implies relation, while P2_MASK
9406 indicates the implied PR. */
9409 clear_qp_implies (valueT p1_mask
, valueT p2_mask
)
9414 while (i
< qp_implieslen
)
9416 if ((((valueT
) 1 << qp_implies
[i
].p1
) & p1_mask
) != 0
9417 || (((valueT
) 1 << qp_implies
[i
].p2
) & p2_mask
) != 0)
9420 fprintf (stderr
, "Clearing implied relation PR%d->PR%d\n",
9421 qp_implies
[i
].p1
, qp_implies
[i
].p2
);
9422 qp_implies
[i
] = qp_implies
[--qp_implieslen
];
9429 /* Add the PRs specified to the list of implied relations. */
9432 add_qp_imply (int p1
, int p2
)
9438 /* p0 is not meaningful here. */
9439 if (p1
== 0 || p2
== 0)
9445 /* If it exists already, ignore it. */
9446 for (i
= 0; i
< qp_implieslen
; i
++)
9448 if (qp_implies
[i
].p1
== p1
9449 && qp_implies
[i
].p2
== p2
9450 && qp_implies
[i
].path
== md
.path
9451 && !qp_implies
[i
].p2_branched
)
9455 if (qp_implieslen
== qp_impliestotlen
)
9457 qp_impliestotlen
+= 20;
9458 qp_implies
= (struct qp_imply
*)
9459 xrealloc ((void *) qp_implies
,
9460 qp_impliestotlen
* sizeof (struct qp_imply
));
9463 fprintf (stderr
, " Registering PR%d implies PR%d\n", p1
, p2
);
9464 qp_implies
[qp_implieslen
].p1
= p1
;
9465 qp_implies
[qp_implieslen
].p2
= p2
;
9466 qp_implies
[qp_implieslen
].path
= md
.path
;
9467 qp_implies
[qp_implieslen
++].p2_branched
= 0;
9469 /* Add in the implied transitive relations; for everything that p2 implies,
9470 make p1 imply that, too; for everything that implies p1, make it imply p2
9472 for (i
= 0; i
< qp_implieslen
; i
++)
9474 if (qp_implies
[i
].p1
== p2
)
9475 add_qp_imply (p1
, qp_implies
[i
].p2
);
9476 if (qp_implies
[i
].p2
== p1
)
9477 add_qp_imply (qp_implies
[i
].p1
, p2
);
9479 /* Add in mutex relations implied by this implies relation; for each mutex
9480 relation containing p2, duplicate it and replace p2 with p1. */
9481 bit
= (valueT
) 1 << p1
;
9482 mask
= (valueT
) 1 << p2
;
9483 for (i
= 0; i
< qp_mutexeslen
; i
++)
9485 if (qp_mutexes
[i
].prmask
& mask
)
9486 add_qp_mutex ((qp_mutexes
[i
].prmask
& ~mask
) | bit
);
9490 /* Add the PRs specified in the mask to the mutex list; this means that only
9491 one of the PRs can be true at any time. PR0 should never be included in
9495 add_qp_mutex (valueT mask
)
9500 if (qp_mutexeslen
== qp_mutexestotlen
)
9502 qp_mutexestotlen
+= 20;
9503 qp_mutexes
= (struct qpmutex
*)
9504 xrealloc ((void *) qp_mutexes
,
9505 qp_mutexestotlen
* sizeof (struct qpmutex
));
9509 fprintf (stderr
, " Registering mutex on");
9510 print_prmask (mask
);
9511 fprintf (stderr
, "\n");
9513 qp_mutexes
[qp_mutexeslen
].path
= md
.path
;
9514 qp_mutexes
[qp_mutexeslen
++].prmask
= mask
;
9518 has_suffix_p (const char *name
, const char *suffix
)
9520 size_t namelen
= strlen (name
);
9521 size_t sufflen
= strlen (suffix
);
9523 if (namelen
<= sufflen
)
9525 return strcmp (name
+ namelen
- sufflen
, suffix
) == 0;
9529 clear_register_values (void)
9533 fprintf (stderr
, " Clearing register values\n");
9534 for (i
= 1; i
< NELEMS (gr_values
); i
++)
9535 gr_values
[i
].known
= 0;
9538 /* Keep track of register values/changes which affect DV tracking.
9540 optimization note: should add a flag to classes of insns where otherwise we
9541 have to examine a group of strings to identify them. */
9544 note_register_values (struct ia64_opcode
*idesc
)
9546 valueT qp_changemask
= 0;
9549 /* Invalidate values for registers being written to. */
9550 for (i
= 0; i
< idesc
->num_outputs
; i
++)
9552 if (idesc
->operands
[i
] == IA64_OPND_R1
9553 || idesc
->operands
[i
] == IA64_OPND_R2
9554 || idesc
->operands
[i
] == IA64_OPND_R3
)
9556 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9557 if (regno
> 0 && regno
< NELEMS (gr_values
))
9558 gr_values
[regno
].known
= 0;
9560 else if (idesc
->operands
[i
] == IA64_OPND_R3_2
)
9562 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9563 if (regno
> 0 && regno
< 4)
9564 gr_values
[regno
].known
= 0;
9566 else if (idesc
->operands
[i
] == IA64_OPND_P1
9567 || idesc
->operands
[i
] == IA64_OPND_P2
)
9569 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
9570 qp_changemask
|= (valueT
) 1 << regno
;
9572 else if (idesc
->operands
[i
] == IA64_OPND_PR
)
9574 if (idesc
->operands
[2] & (valueT
) 0x10000)
9575 qp_changemask
= ~(valueT
) 0x1FFFF | idesc
->operands
[2];
9577 qp_changemask
= idesc
->operands
[2];
9580 else if (idesc
->operands
[i
] == IA64_OPND_PR_ROT
)
9582 if (idesc
->operands
[1] & ((valueT
) 1 << 43))
9583 qp_changemask
= -((valueT
) 1 << 44) | idesc
->operands
[1];
9585 qp_changemask
= idesc
->operands
[1];
9586 qp_changemask
&= ~(valueT
) 0xFFFF;
9591 /* Always clear qp branch flags on any PR change. */
9592 /* FIXME there may be exceptions for certain compares. */
9593 clear_qp_branch_flag (qp_changemask
);
9595 /* Invalidate rotating registers on insns which affect RRBs in CFM. */
9596 if (idesc
->flags
& IA64_OPCODE_MOD_RRBS
)
9598 qp_changemask
|= ~(valueT
) 0xFFFF;
9599 if (strcmp (idesc
->name
, "clrrrb.pr") != 0)
9601 for (i
= 32; i
< 32 + md
.rot
.num_regs
; i
++)
9602 gr_values
[i
].known
= 0;
9604 clear_qp_mutex (qp_changemask
);
9605 clear_qp_implies (qp_changemask
, qp_changemask
);
9607 /* After a call, all register values are undefined, except those marked
9609 else if (strncmp (idesc
->name
, "br.call", 6) == 0
9610 || strncmp (idesc
->name
, "brl.call", 7) == 0)
9612 /* FIXME keep GR values which are marked as "safe_across_calls" */
9613 clear_register_values ();
9614 clear_qp_mutex (~qp_safe_across_calls
);
9615 clear_qp_implies (~qp_safe_across_calls
, ~qp_safe_across_calls
);
9616 clear_qp_branch_flag (~qp_safe_across_calls
);
9618 else if (is_interruption_or_rfi (idesc
)
9619 || is_taken_branch (idesc
))
9621 clear_register_values ();
9622 clear_qp_mutex (~(valueT
) 0);
9623 clear_qp_implies (~(valueT
) 0, ~(valueT
) 0);
9625 /* Look for mutex and implies relations. */
9626 else if ((idesc
->operands
[0] == IA64_OPND_P1
9627 || idesc
->operands
[0] == IA64_OPND_P2
)
9628 && (idesc
->operands
[1] == IA64_OPND_P1
9629 || idesc
->operands
[1] == IA64_OPND_P2
))
9631 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
9632 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
9633 valueT p1mask
= (p1
!= 0) ? (valueT
) 1 << p1
: 0;
9634 valueT p2mask
= (p2
!= 0) ? (valueT
) 1 << p2
: 0;
9636 /* If both PRs are PR0, we can't really do anything. */
9637 if (p1
== 0 && p2
== 0)
9640 fprintf (stderr
, " Ignoring PRs due to inclusion of p0\n");
9642 /* In general, clear mutexes and implies which include P1 or P2,
9643 with the following exceptions. */
9644 else if (has_suffix_p (idesc
->name
, ".or.andcm")
9645 || has_suffix_p (idesc
->name
, ".and.orcm"))
9647 clear_qp_implies (p2mask
, p1mask
);
9649 else if (has_suffix_p (idesc
->name
, ".andcm")
9650 || has_suffix_p (idesc
->name
, ".and"))
9652 clear_qp_implies (0, p1mask
| p2mask
);
9654 else if (has_suffix_p (idesc
->name
, ".orcm")
9655 || has_suffix_p (idesc
->name
, ".or"))
9657 clear_qp_mutex (p1mask
| p2mask
);
9658 clear_qp_implies (p1mask
| p2mask
, 0);
9664 clear_qp_implies (p1mask
| p2mask
, p1mask
| p2mask
);
9666 /* If one of the PRs is PR0, we call clear_qp_mutex. */
9667 if (p1
== 0 || p2
== 0)
9668 clear_qp_mutex (p1mask
| p2mask
);
9670 added
= update_qp_mutex (p1mask
| p2mask
);
9672 if (CURR_SLOT
.qp_regno
== 0
9673 || has_suffix_p (idesc
->name
, ".unc"))
9675 if (added
== 0 && p1
&& p2
)
9676 add_qp_mutex (p1mask
| p2mask
);
9677 if (CURR_SLOT
.qp_regno
!= 0)
9680 add_qp_imply (p1
, CURR_SLOT
.qp_regno
);
9682 add_qp_imply (p2
, CURR_SLOT
.qp_regno
);
9687 /* Look for mov imm insns into GRs. */
9688 else if (idesc
->operands
[0] == IA64_OPND_R1
9689 && (idesc
->operands
[1] == IA64_OPND_IMM22
9690 || idesc
->operands
[1] == IA64_OPND_IMMU64
)
9691 && CURR_SLOT
.opnd
[1].X_op
== O_constant
9692 && (strcmp (idesc
->name
, "mov") == 0
9693 || strcmp (idesc
->name
, "movl") == 0))
9695 int regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
9696 if (regno
> 0 && regno
< NELEMS (gr_values
))
9698 gr_values
[regno
].known
= 1;
9699 gr_values
[regno
].value
= CURR_SLOT
.opnd
[1].X_add_number
;
9700 gr_values
[regno
].path
= md
.path
;
9703 fprintf (stderr
, " Know gr%d = ", regno
);
9704 fprintf_vma (stderr
, gr_values
[regno
].value
);
9705 fputs ("\n", stderr
);
9709 /* Look for dep.z imm insns. */
9710 else if (idesc
->operands
[0] == IA64_OPND_R1
9711 && idesc
->operands
[1] == IA64_OPND_IMM8
9712 && strcmp (idesc
->name
, "dep.z") == 0)
9714 int regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
9715 if (regno
> 0 && regno
< NELEMS (gr_values
))
9717 valueT value
= CURR_SLOT
.opnd
[1].X_add_number
;
9719 if (CURR_SLOT
.opnd
[3].X_add_number
< 64)
9720 value
&= ((valueT
)1 << CURR_SLOT
.opnd
[3].X_add_number
) - 1;
9721 value
<<= CURR_SLOT
.opnd
[2].X_add_number
;
9722 gr_values
[regno
].known
= 1;
9723 gr_values
[regno
].value
= value
;
9724 gr_values
[regno
].path
= md
.path
;
9727 fprintf (stderr
, " Know gr%d = ", regno
);
9728 fprintf_vma (stderr
, gr_values
[regno
].value
);
9729 fputs ("\n", stderr
);
9735 clear_qp_mutex (qp_changemask
);
9736 clear_qp_implies (qp_changemask
, qp_changemask
);
9740 /* Return whether the given predicate registers are currently mutex. */
9743 qp_mutex (int p1
, int p2
, int path
)
9750 mask
= ((valueT
) 1 << p1
) | (valueT
) 1 << p2
;
9751 for (i
= 0; i
< qp_mutexeslen
; i
++)
9753 if (qp_mutexes
[i
].path
>= path
9754 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
9761 /* Return whether the given resource is in the given insn's list of chks
9762 Return 1 if the conflict is absolutely determined, 2 if it's a potential
9766 resources_match (struct rsrc
*rs
,
9767 struct ia64_opcode
*idesc
,
9772 struct rsrc specs
[MAX_SPECS
];
9775 /* If the marked resource's qp_regno and the given qp_regno are mutex,
9776 we don't need to check. One exception is note 11, which indicates that
9777 target predicates are written regardless of PR[qp]. */
9778 if (qp_mutex (rs
->qp_regno
, qp_regno
, path
)
9782 count
= specify_resource (rs
->dependency
, idesc
, DV_CHK
, specs
, note
, path
);
9785 /* UNAT checking is a bit more specific than other resources */
9786 if (rs
->dependency
->specifier
== IA64_RS_AR_UNAT
9787 && specs
[count
].mem_offset
.hint
9788 && rs
->mem_offset
.hint
)
9790 if (rs
->mem_offset
.base
== specs
[count
].mem_offset
.base
)
9792 if (((rs
->mem_offset
.offset
>> 3) & 0x3F) ==
9793 ((specs
[count
].mem_offset
.offset
>> 3) & 0x3F))
9800 /* Skip apparent PR write conflicts where both writes are an AND or both
9801 writes are an OR. */
9802 if (rs
->dependency
->specifier
== IA64_RS_PR
9803 || rs
->dependency
->specifier
== IA64_RS_PRr
9804 || rs
->dependency
->specifier
== IA64_RS_PR63
)
9806 if (specs
[count
].cmp_type
!= CMP_NONE
9807 && specs
[count
].cmp_type
== rs
->cmp_type
)
9810 fprintf (stderr
, " %s on parallel compare allowed (PR%d)\n",
9811 dv_mode
[rs
->dependency
->mode
],
9812 rs
->dependency
->specifier
!= IA64_RS_PR63
?
9813 specs
[count
].index
: 63);
9818 " %s on parallel compare conflict %s vs %s on PR%d\n",
9819 dv_mode
[rs
->dependency
->mode
],
9820 dv_cmp_type
[rs
->cmp_type
],
9821 dv_cmp_type
[specs
[count
].cmp_type
],
9822 rs
->dependency
->specifier
!= IA64_RS_PR63
?
9823 specs
[count
].index
: 63);
9827 /* If either resource is not specific, conservatively assume a conflict
9829 if (!specs
[count
].specific
|| !rs
->specific
)
9831 else if (specs
[count
].index
== rs
->index
)
9838 /* Indicate an instruction group break; if INSERT_STOP is non-zero, then
9839 insert a stop to create the break. Update all resource dependencies
9840 appropriately. If QP_REGNO is non-zero, only apply the break to resources
9841 which use the same QP_REGNO and have the link_to_qp_branch flag set.
9842 If SAVE_CURRENT is non-zero, don't affect resources marked by the current
9846 insn_group_break (int insert_stop
, int qp_regno
, int save_current
)
9850 if (insert_stop
&& md
.num_slots_in_use
> 0)
9851 PREV_SLOT
.end_of_insn_group
= 1;
9855 fprintf (stderr
, " Insn group break%s",
9856 (insert_stop
? " (w/stop)" : ""));
9858 fprintf (stderr
, " effective for QP=%d", qp_regno
);
9859 fprintf (stderr
, "\n");
9863 while (i
< regdepslen
)
9865 const struct ia64_dependency
*dep
= regdeps
[i
].dependency
;
9868 && regdeps
[i
].qp_regno
!= qp_regno
)
9875 && CURR_SLOT
.src_file
== regdeps
[i
].file
9876 && CURR_SLOT
.src_line
== regdeps
[i
].line
)
9882 /* clear dependencies which are automatically cleared by a stop, or
9883 those that have reached the appropriate state of insn serialization */
9884 if (dep
->semantics
== IA64_DVS_IMPLIED
9885 || dep
->semantics
== IA64_DVS_IMPLIEDF
9886 || regdeps
[i
].insn_srlz
== STATE_SRLZ
)
9888 print_dependency ("Removing", i
);
9889 regdeps
[i
] = regdeps
[--regdepslen
];
9893 if (dep
->semantics
== IA64_DVS_DATA
9894 || dep
->semantics
== IA64_DVS_INSTR
9895 || dep
->semantics
== IA64_DVS_SPECIFIC
)
9897 if (regdeps
[i
].insn_srlz
== STATE_NONE
)
9898 regdeps
[i
].insn_srlz
= STATE_STOP
;
9899 if (regdeps
[i
].data_srlz
== STATE_NONE
)
9900 regdeps
[i
].data_srlz
= STATE_STOP
;
9907 /* Add the given resource usage spec to the list of active dependencies. */
9910 mark_resource (struct ia64_opcode
*idesc ATTRIBUTE_UNUSED
,
9911 const struct ia64_dependency
*dep ATTRIBUTE_UNUSED
,
9916 if (regdepslen
== regdepstotlen
)
9918 regdepstotlen
+= 20;
9919 regdeps
= (struct rsrc
*)
9920 xrealloc ((void *) regdeps
,
9921 regdepstotlen
* sizeof (struct rsrc
));
9924 regdeps
[regdepslen
] = *spec
;
9925 regdeps
[regdepslen
].depind
= depind
;
9926 regdeps
[regdepslen
].path
= path
;
9927 regdeps
[regdepslen
].file
= CURR_SLOT
.src_file
;
9928 regdeps
[regdepslen
].line
= CURR_SLOT
.src_line
;
9930 print_dependency ("Adding", regdepslen
);
9936 print_dependency (const char *action
, int depind
)
9940 fprintf (stderr
, " %s %s '%s'",
9941 action
, dv_mode
[(regdeps
[depind
].dependency
)->mode
],
9942 (regdeps
[depind
].dependency
)->name
);
9943 if (regdeps
[depind
].specific
&& regdeps
[depind
].index
>= 0)
9944 fprintf (stderr
, " (%d)", regdeps
[depind
].index
);
9945 if (regdeps
[depind
].mem_offset
.hint
)
9947 fputs (" ", stderr
);
9948 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.base
);
9949 fputs ("+", stderr
);
9950 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.offset
);
9952 fprintf (stderr
, "\n");
9957 instruction_serialization (void)
9961 fprintf (stderr
, " Instruction serialization\n");
9962 for (i
= 0; i
< regdepslen
; i
++)
9963 if (regdeps
[i
].insn_srlz
== STATE_STOP
)
9964 regdeps
[i
].insn_srlz
= STATE_SRLZ
;
9968 data_serialization (void)
9972 fprintf (stderr
, " Data serialization\n");
9973 while (i
< regdepslen
)
9975 if (regdeps
[i
].data_srlz
== STATE_STOP
9976 /* Note: as of 991210, all "other" dependencies are cleared by a
9977 data serialization. This might change with new tables */
9978 || (regdeps
[i
].dependency
)->semantics
== IA64_DVS_OTHER
)
9980 print_dependency ("Removing", i
);
9981 regdeps
[i
] = regdeps
[--regdepslen
];
9988 /* Insert stops and serializations as needed to avoid DVs. */
9991 remove_marked_resource (struct rsrc
*rs
)
9993 switch (rs
->dependency
->semantics
)
9995 case IA64_DVS_SPECIFIC
:
9997 fprintf (stderr
, "Implementation-specific, assume worst case...\n");
9998 /* ...fall through... */
9999 case IA64_DVS_INSTR
:
10001 fprintf (stderr
, "Inserting instr serialization\n");
10002 if (rs
->insn_srlz
< STATE_STOP
)
10003 insn_group_break (1, 0, 0);
10004 if (rs
->insn_srlz
< STATE_SRLZ
)
10006 struct slot oldslot
= CURR_SLOT
;
10007 /* Manually jam a srlz.i insn into the stream */
10008 memset (&CURR_SLOT
, 0, sizeof (CURR_SLOT
));
10009 CURR_SLOT
.user_template
= -1;
10010 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.i");
10011 instruction_serialization ();
10012 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10013 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10014 emit_one_bundle ();
10015 CURR_SLOT
= oldslot
;
10017 insn_group_break (1, 0, 0);
10019 case IA64_DVS_OTHER
: /* as of rev2 (991220) of the DV tables, all
10020 "other" types of DV are eliminated
10021 by a data serialization */
10022 case IA64_DVS_DATA
:
10024 fprintf (stderr
, "Inserting data serialization\n");
10025 if (rs
->data_srlz
< STATE_STOP
)
10026 insn_group_break (1, 0, 0);
10028 struct slot oldslot
= CURR_SLOT
;
10029 /* Manually jam a srlz.d insn into the stream */
10030 memset (&CURR_SLOT
, 0, sizeof (CURR_SLOT
));
10031 CURR_SLOT
.user_template
= -1;
10032 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.d");
10033 data_serialization ();
10034 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10035 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10036 emit_one_bundle ();
10037 CURR_SLOT
= oldslot
;
10040 case IA64_DVS_IMPLIED
:
10041 case IA64_DVS_IMPLIEDF
:
10043 fprintf (stderr
, "Inserting stop\n");
10044 insn_group_break (1, 0, 0);
10051 /* Check the resources used by the given opcode against the current dependency
10054 The check is run once for each execution path encountered. In this case,
10055 a unique execution path is the sequence of instructions following a code
10056 entry point, e.g. the following has three execution paths, one starting
10057 at L0, one at L1, and one at L2.
10066 check_dependencies (struct ia64_opcode
*idesc
)
10068 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
10072 /* Note that the number of marked resources may change within the
10073 loop if in auto mode. */
10075 while (i
< regdepslen
)
10077 struct rsrc
*rs
= ®deps
[i
];
10078 const struct ia64_dependency
*dep
= rs
->dependency
;
10081 int start_over
= 0;
10083 if (dep
->semantics
== IA64_DVS_NONE
10084 || (chkind
= depends_on (rs
->depind
, idesc
)) == -1)
10090 note
= NOTE (opdeps
->chks
[chkind
]);
10092 /* Check this resource against each execution path seen thus far. */
10093 for (path
= 0; path
<= md
.path
; path
++)
10097 /* If the dependency wasn't on the path being checked, ignore it. */
10098 if (rs
->path
< path
)
10101 /* If the QP for this insn implies a QP which has branched, don't
10102 bother checking. Ed. NOTE: I don't think this check is terribly
10103 useful; what's the point of generating code which will only be
10104 reached if its QP is zero?
10105 This code was specifically inserted to handle the following code,
10106 based on notes from Intel's DV checking code, where p1 implies p2.
10112 if (CURR_SLOT
.qp_regno
!= 0)
10116 for (implies
= 0; implies
< qp_implieslen
; implies
++)
10118 if (qp_implies
[implies
].path
>= path
10119 && qp_implies
[implies
].p1
== CURR_SLOT
.qp_regno
10120 && qp_implies
[implies
].p2_branched
)
10130 if ((matchtype
= resources_match (rs
, idesc
, note
,
10131 CURR_SLOT
.qp_regno
, path
)) != 0)
10134 char pathmsg
[256] = "";
10135 char indexmsg
[256] = "";
10136 int certain
= (matchtype
== 1 && CURR_SLOT
.qp_regno
== 0);
10139 snprintf (pathmsg
, sizeof (pathmsg
),
10140 " when entry is at label '%s'",
10141 md
.entry_labels
[path
- 1]);
10142 if (matchtype
== 1 && rs
->index
>= 0)
10143 snprintf (indexmsg
, sizeof (indexmsg
),
10144 ", specific resource number is %d",
10146 snprintf (msg
, sizeof (msg
),
10147 "Use of '%s' %s %s dependency '%s' (%s)%s%s",
10149 (certain
? "violates" : "may violate"),
10150 dv_mode
[dep
->mode
], dep
->name
,
10151 dv_sem
[dep
->semantics
],
10152 pathmsg
, indexmsg
);
10154 if (md
.explicit_mode
)
10156 as_warn ("%s", msg
);
10157 if (path
< md
.path
)
10158 as_warn (_("Only the first path encountering the conflict is reported"));
10159 as_warn_where (rs
->file
, rs
->line
,
10160 _("This is the location of the conflicting usage"));
10161 /* Don't bother checking other paths, to avoid duplicating
10162 the same warning */
10168 fprintf (stderr
, "%s @ %s:%d\n", msg
, rs
->file
, rs
->line
);
10170 remove_marked_resource (rs
);
10172 /* since the set of dependencies has changed, start over */
10173 /* FIXME -- since we're removing dvs as we go, we
10174 probably don't really need to start over... */
10187 /* Register new dependencies based on the given opcode. */
10190 mark_resources (struct ia64_opcode
*idesc
)
10193 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
10194 int add_only_qp_reads
= 0;
10196 /* A conditional branch only uses its resources if it is taken; if it is
10197 taken, we stop following that path. The other branch types effectively
10198 *always* write their resources. If it's not taken, register only QP
10200 if (is_conditional_branch (idesc
) || is_interruption_or_rfi (idesc
))
10202 add_only_qp_reads
= 1;
10206 fprintf (stderr
, "Registering '%s' resource usage\n", idesc
->name
);
10208 for (i
= 0; i
< opdeps
->nregs
; i
++)
10210 const struct ia64_dependency
*dep
;
10211 struct rsrc specs
[MAX_SPECS
];
10216 dep
= ia64_find_dependency (opdeps
->regs
[i
]);
10217 note
= NOTE (opdeps
->regs
[i
]);
10219 if (add_only_qp_reads
10220 && !(dep
->mode
== IA64_DV_WAR
10221 && (dep
->specifier
== IA64_RS_PR
10222 || dep
->specifier
== IA64_RS_PRr
10223 || dep
->specifier
== IA64_RS_PR63
)))
10226 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, md
.path
);
10228 while (count
-- > 0)
10230 mark_resource (idesc
, dep
, &specs
[count
],
10231 DEP (opdeps
->regs
[i
]), md
.path
);
10234 /* The execution path may affect register values, which may in turn
10235 affect which indirect-access resources are accessed. */
10236 switch (dep
->specifier
)
10240 case IA64_RS_CPUID
:
10248 for (path
= 0; path
< md
.path
; path
++)
10250 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, path
);
10251 while (count
-- > 0)
10252 mark_resource (idesc
, dep
, &specs
[count
],
10253 DEP (opdeps
->regs
[i
]), path
);
10260 /* Remove dependencies when they no longer apply. */
10263 update_dependencies (struct ia64_opcode
*idesc
)
10267 if (strcmp (idesc
->name
, "srlz.i") == 0)
10269 instruction_serialization ();
10271 else if (strcmp (idesc
->name
, "srlz.d") == 0)
10273 data_serialization ();
10275 else if (is_interruption_or_rfi (idesc
)
10276 || is_taken_branch (idesc
))
10278 /* Although technically the taken branch doesn't clear dependencies
10279 which require a srlz.[id], we don't follow the branch; the next
10280 instruction is assumed to start with a clean slate. */
10284 else if (is_conditional_branch (idesc
)
10285 && CURR_SLOT
.qp_regno
!= 0)
10287 int is_call
= strstr (idesc
->name
, ".call") != NULL
;
10289 for (i
= 0; i
< qp_implieslen
; i
++)
10291 /* If the conditional branch's predicate is implied by the predicate
10292 in an existing dependency, remove that dependency. */
10293 if (qp_implies
[i
].p2
== CURR_SLOT
.qp_regno
)
10296 /* Note that this implied predicate takes a branch so that if
10297 a later insn generates a DV but its predicate implies this
10298 one, we can avoid the false DV warning. */
10299 qp_implies
[i
].p2_branched
= 1;
10300 while (depind
< regdepslen
)
10302 if (regdeps
[depind
].qp_regno
== qp_implies
[i
].p1
)
10304 print_dependency ("Removing", depind
);
10305 regdeps
[depind
] = regdeps
[--regdepslen
];
10312 /* Any marked resources which have this same predicate should be
10313 cleared, provided that the QP hasn't been modified between the
10314 marking instruction and the branch. */
10317 insn_group_break (0, CURR_SLOT
.qp_regno
, 1);
10322 while (i
< regdepslen
)
10324 if (regdeps
[i
].qp_regno
== CURR_SLOT
.qp_regno
10325 && regdeps
[i
].link_to_qp_branch
10326 && (regdeps
[i
].file
!= CURR_SLOT
.src_file
10327 || regdeps
[i
].line
!= CURR_SLOT
.src_line
))
10329 /* Treat like a taken branch */
10330 print_dependency ("Removing", i
);
10331 regdeps
[i
] = regdeps
[--regdepslen
];
10340 /* Examine the current instruction for dependency violations. */
10343 check_dv (struct ia64_opcode
*idesc
)
10347 fprintf (stderr
, "Checking %s for violations (line %d, %d/%d)\n",
10348 idesc
->name
, CURR_SLOT
.src_line
,
10349 idesc
->dependencies
->nchks
,
10350 idesc
->dependencies
->nregs
);
10353 /* Look through the list of currently marked resources; if the current
10354 instruction has the dependency in its chks list which uses that resource,
10355 check against the specific resources used. */
10356 check_dependencies (idesc
);
10358 /* Look up the instruction's regdeps (RAW writes, WAW writes, and WAR reads),
10359 then add them to the list of marked resources. */
10360 mark_resources (idesc
);
10362 /* There are several types of dependency semantics, and each has its own
10363 requirements for being cleared
10365 Instruction serialization (insns separated by interruption, rfi, or
10366 writer + srlz.i + reader, all in separate groups) clears DVS_INSTR.
10368 Data serialization (instruction serialization, or writer + srlz.d +
10369 reader, where writer and srlz.d are in separate groups) clears
10370 DVS_DATA. (This also clears DVS_OTHER, but that is not guaranteed to
10371 always be the case).
10373 Instruction group break (groups separated by stop, taken branch,
10374 interruption or rfi) clears DVS_IMPLIED and DVS_IMPLIEDF.
10376 update_dependencies (idesc
);
10378 /* Sometimes, knowing a register value allows us to avoid giving a false DV
10379 warning. Keep track of as many as possible that are useful. */
10380 note_register_values (idesc
);
10382 /* We don't need or want this anymore. */
10383 md
.mem_offset
.hint
= 0;
10388 /* Translate one line of assembly. Pseudo ops and labels do not show
10391 md_assemble (char *str
)
10393 char *saved_input_line_pointer
, *mnemonic
;
10394 const struct pseudo_opcode
*pdesc
;
10395 struct ia64_opcode
*idesc
;
10396 unsigned char qp_regno
;
10397 unsigned int flags
;
10400 saved_input_line_pointer
= input_line_pointer
;
10401 input_line_pointer
= str
;
10403 /* extract the opcode (mnemonic): */
10405 mnemonic
= input_line_pointer
;
10406 ch
= get_symbol_end ();
10407 pdesc
= (struct pseudo_opcode
*) hash_find (md
.pseudo_hash
, mnemonic
);
10410 *input_line_pointer
= ch
;
10411 (*pdesc
->handler
) (pdesc
->arg
);
10415 /* Find the instruction descriptor matching the arguments. */
10417 idesc
= ia64_find_opcode (mnemonic
);
10418 *input_line_pointer
= ch
;
10421 as_bad (_("Unknown opcode `%s'"), mnemonic
);
10425 idesc
= parse_operands (idesc
);
10429 /* Handle the dynamic ops we can handle now: */
10430 if (idesc
->type
== IA64_TYPE_DYN
)
10432 if (strcmp (idesc
->name
, "add") == 0)
10434 if (CURR_SLOT
.opnd
[2].X_op
== O_register
10435 && CURR_SLOT
.opnd
[2].X_add_number
< 4)
10439 ia64_free_opcode (idesc
);
10440 idesc
= ia64_find_opcode (mnemonic
);
10442 else if (strcmp (idesc
->name
, "mov") == 0)
10444 enum ia64_opnd opnd1
, opnd2
;
10447 opnd1
= idesc
->operands
[0];
10448 opnd2
= idesc
->operands
[1];
10449 if (opnd1
== IA64_OPND_AR3
)
10451 else if (opnd2
== IA64_OPND_AR3
)
10455 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
)
10457 if (ar_is_only_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10458 mnemonic
= "mov.i";
10459 else if (ar_is_only_in_memory_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10460 mnemonic
= "mov.m";
10468 ia64_free_opcode (idesc
);
10469 idesc
= ia64_find_opcode (mnemonic
);
10470 while (idesc
!= NULL
10471 && (idesc
->operands
[0] != opnd1
10472 || idesc
->operands
[1] != opnd2
))
10473 idesc
= get_next_opcode (idesc
);
10477 else if (strcmp (idesc
->name
, "mov.i") == 0
10478 || strcmp (idesc
->name
, "mov.m") == 0)
10480 enum ia64_opnd opnd1
, opnd2
;
10483 opnd1
= idesc
->operands
[0];
10484 opnd2
= idesc
->operands
[1];
10485 if (opnd1
== IA64_OPND_AR3
)
10487 else if (opnd2
== IA64_OPND_AR3
)
10491 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
)
10494 if (ar_is_only_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10496 else if (ar_is_only_in_memory_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10498 if (unit
!= 'a' && unit
!= idesc
->name
[4])
10499 as_bad (_("AR %d can only be accessed by %c-unit"),
10500 (int) (CURR_SLOT
.opnd
[rop
].X_add_number
- REG_AR
),
10504 else if (strcmp (idesc
->name
, "hint.b") == 0)
10510 case hint_b_warning
:
10511 as_warn (_("hint.b may be treated as nop"));
10514 as_bad (_("hint.b shouldn't be used"));
10520 if (md
.qp
.X_op
== O_register
)
10522 qp_regno
= md
.qp
.X_add_number
- REG_P
;
10523 md
.qp
.X_op
= O_absent
;
10526 flags
= idesc
->flags
;
10528 if ((flags
& IA64_OPCODE_FIRST
) != 0)
10530 /* The alignment frag has to end with a stop bit only if the
10531 next instruction after the alignment directive has to be
10532 the first instruction in an instruction group. */
10535 while (align_frag
->fr_type
!= rs_align_code
)
10537 align_frag
= align_frag
->fr_next
;
10541 /* align_frag can be NULL if there are directives in
10543 if (align_frag
&& align_frag
->fr_next
== frag_now
)
10544 align_frag
->tc_frag_data
= 1;
10547 insn_group_break (1, 0, 0);
10551 if ((flags
& IA64_OPCODE_NO_PRED
) != 0 && qp_regno
!= 0)
10553 as_bad (_("`%s' cannot be predicated"), idesc
->name
);
10557 /* Build the instruction. */
10558 CURR_SLOT
.qp_regno
= qp_regno
;
10559 CURR_SLOT
.idesc
= idesc
;
10560 as_where (&CURR_SLOT
.src_file
, &CURR_SLOT
.src_line
);
10561 dwarf2_where (&CURR_SLOT
.debug_line
);
10562 dwarf2_consume_line_info ();
10564 /* Add unwind entries, if there are any. */
10565 if (unwind
.current_entry
)
10567 CURR_SLOT
.unwind_record
= unwind
.current_entry
;
10568 unwind
.current_entry
= NULL
;
10570 if (unwind
.pending_saves
)
10572 if (unwind
.pending_saves
->next
)
10574 /* Attach the next pending save to the next slot so that its
10575 slot number will get set correctly. */
10576 add_unwind_entry (unwind
.pending_saves
->next
, NOT_A_CHAR
);
10577 unwind
.pending_saves
= &unwind
.pending_saves
->next
->r
.record
.p
;
10580 unwind
.pending_saves
= NULL
;
10582 if (unwind
.proc_pending
.sym
&& S_IS_DEFINED (unwind
.proc_pending
.sym
))
10585 /* Check for dependency violations. */
10589 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10590 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10591 emit_one_bundle ();
10593 if ((flags
& IA64_OPCODE_LAST
) != 0)
10594 insn_group_break (1, 0, 0);
10596 md
.last_text_seg
= now_seg
;
10599 input_line_pointer
= saved_input_line_pointer
;
10602 /* Called when symbol NAME cannot be found in the symbol table.
10603 Should be used for dynamic valued symbols only. */
10606 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
10611 /* Called for any expression that can not be recognized. When the
10612 function is called, `input_line_pointer' will point to the start of
10616 md_operand (expressionS
*e
)
10618 switch (*input_line_pointer
)
10621 ++input_line_pointer
;
10622 expression_and_evaluate (e
);
10623 if (*input_line_pointer
!= ']')
10625 as_bad (_("Closing bracket missing"));
10630 if (e
->X_op
!= O_register
10631 || e
->X_add_number
< REG_GR
10632 || e
->X_add_number
> REG_GR
+ 127)
10634 as_bad (_("Index must be a general register"));
10635 e
->X_add_number
= REG_GR
;
10638 ++input_line_pointer
;
10649 ignore_rest_of_line ();
10652 /* Return 1 if it's OK to adjust a reloc by replacing the symbol with
10653 a section symbol plus some offset. For relocs involving @fptr(),
10654 directives we don't want such adjustments since we need to have the
10655 original symbol's name in the reloc. */
10657 ia64_fix_adjustable (fixS
*fix
)
10659 /* Prevent all adjustments to global symbols */
10660 if (S_IS_EXTERNAL (fix
->fx_addsy
) || S_IS_WEAK (fix
->fx_addsy
))
10663 switch (fix
->fx_r_type
)
10665 case BFD_RELOC_IA64_FPTR64I
:
10666 case BFD_RELOC_IA64_FPTR32MSB
:
10667 case BFD_RELOC_IA64_FPTR32LSB
:
10668 case BFD_RELOC_IA64_FPTR64MSB
:
10669 case BFD_RELOC_IA64_FPTR64LSB
:
10670 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10671 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10681 ia64_force_relocation (fixS
*fix
)
10683 switch (fix
->fx_r_type
)
10685 case BFD_RELOC_IA64_FPTR64I
:
10686 case BFD_RELOC_IA64_FPTR32MSB
:
10687 case BFD_RELOC_IA64_FPTR32LSB
:
10688 case BFD_RELOC_IA64_FPTR64MSB
:
10689 case BFD_RELOC_IA64_FPTR64LSB
:
10691 case BFD_RELOC_IA64_LTOFF22
:
10692 case BFD_RELOC_IA64_LTOFF64I
:
10693 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10694 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10695 case BFD_RELOC_IA64_PLTOFF22
:
10696 case BFD_RELOC_IA64_PLTOFF64I
:
10697 case BFD_RELOC_IA64_PLTOFF64MSB
:
10698 case BFD_RELOC_IA64_PLTOFF64LSB
:
10700 case BFD_RELOC_IA64_LTOFF22X
:
10701 case BFD_RELOC_IA64_LDXMOV
:
10708 return generic_force_reloc (fix
);
10711 /* Decide from what point a pc-relative relocation is relative to,
10712 relative to the pc-relative fixup. Er, relatively speaking. */
10714 ia64_pcrel_from_section (fixS
*fix
, segT sec
)
10716 unsigned long off
= fix
->fx_frag
->fr_address
+ fix
->fx_where
;
10718 if (bfd_get_section_flags (stdoutput
, sec
) & SEC_CODE
)
10725 /* Used to emit section-relative relocs for the dwarf2 debug data. */
10727 ia64_dwarf2_emit_offset (symbolS
*symbol
, unsigned int size
)
10731 expr
.X_op
= O_pseudo_fixup
;
10732 expr
.X_op_symbol
= pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
;
10733 expr
.X_add_number
= 0;
10734 expr
.X_add_symbol
= symbol
;
10735 emit_expr (&expr
, size
);
10738 /* This is called whenever some data item (not an instruction) needs a
10739 fixup. We pick the right reloc code depending on the byteorder
10740 currently in effect. */
10742 ia64_cons_fix_new (fragS
*f
, int where
, int nbytes
, expressionS
*exp
)
10744 bfd_reloc_code_real_type code
;
10749 /* There are no reloc for 8 and 16 bit quantities, but we allow
10750 them here since they will work fine as long as the expression
10751 is fully defined at the end of the pass over the source file. */
10752 case 1: code
= BFD_RELOC_8
; break;
10753 case 2: code
= BFD_RELOC_16
; break;
10755 if (target_big_endian
)
10756 code
= BFD_RELOC_IA64_DIR32MSB
;
10758 code
= BFD_RELOC_IA64_DIR32LSB
;
10762 /* In 32-bit mode, data8 could mean function descriptors too. */
10763 if (exp
->X_op
== O_pseudo_fixup
10764 && exp
->X_op_symbol
10765 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
10766 && !(md
.flags
& EF_IA_64_ABI64
))
10768 if (target_big_endian
)
10769 code
= BFD_RELOC_IA64_IPLTMSB
;
10771 code
= BFD_RELOC_IA64_IPLTLSB
;
10772 exp
->X_op
= O_symbol
;
10777 if (target_big_endian
)
10778 code
= BFD_RELOC_IA64_DIR64MSB
;
10780 code
= BFD_RELOC_IA64_DIR64LSB
;
10785 if (exp
->X_op
== O_pseudo_fixup
10786 && exp
->X_op_symbol
10787 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
)
10789 if (target_big_endian
)
10790 code
= BFD_RELOC_IA64_IPLTMSB
;
10792 code
= BFD_RELOC_IA64_IPLTLSB
;
10793 exp
->X_op
= O_symbol
;
10799 as_bad (_("Unsupported fixup size %d"), nbytes
);
10800 ignore_rest_of_line ();
10804 if (exp
->X_op
== O_pseudo_fixup
)
10806 exp
->X_op
= O_symbol
;
10807 code
= ia64_gen_real_reloc_type (exp
->X_op_symbol
, code
);
10808 /* ??? If code unchanged, unsupported. */
10811 fix
= fix_new_exp (f
, where
, nbytes
, exp
, 0, code
);
10812 /* We need to store the byte order in effect in case we're going
10813 to fix an 8 or 16 bit relocation (for which there no real
10814 relocs available). See md_apply_fix(). */
10815 fix
->tc_fix_data
.bigendian
= target_big_endian
;
10818 /* Return the actual relocation we wish to associate with the pseudo
10819 reloc described by SYM and R_TYPE. SYM should be one of the
10820 symbols in the pseudo_func array, or NULL. */
10822 static bfd_reloc_code_real_type
10823 ia64_gen_real_reloc_type (struct symbol
*sym
, bfd_reloc_code_real_type r_type
)
10825 bfd_reloc_code_real_type
new = 0;
10826 const char *type
= NULL
, *suffix
= "";
10833 switch (S_GET_VALUE (sym
))
10835 case FUNC_FPTR_RELATIVE
:
10838 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_FPTR64I
; break;
10839 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_FPTR32MSB
; break;
10840 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_FPTR32LSB
; break;
10841 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_FPTR64MSB
; break;
10842 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_FPTR64LSB
; break;
10843 default: type
= "FPTR"; break;
10847 case FUNC_GP_RELATIVE
:
10850 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_GPREL22
; break;
10851 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_GPREL64I
; break;
10852 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_GPREL32MSB
; break;
10853 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_GPREL32LSB
; break;
10854 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_GPREL64MSB
; break;
10855 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_GPREL64LSB
; break;
10856 default: type
= "GPREL"; break;
10860 case FUNC_LT_RELATIVE
:
10863 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_LTOFF22
; break;
10864 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_LTOFF64I
; break;
10865 default: type
= "LTOFF"; break;
10869 case FUNC_LT_RELATIVE_X
:
10872 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_LTOFF22X
; break;
10873 default: type
= "LTOFF"; suffix
= "X"; break;
10877 case FUNC_PC_RELATIVE
:
10880 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PCREL22
; break;
10881 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PCREL64I
; break;
10882 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_PCREL32MSB
; break;
10883 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_PCREL32LSB
; break;
10884 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PCREL64MSB
; break;
10885 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PCREL64LSB
; break;
10886 default: type
= "PCREL"; break;
10890 case FUNC_PLT_RELATIVE
:
10893 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PLTOFF22
; break;
10894 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PLTOFF64I
; break;
10895 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PLTOFF64MSB
;break;
10896 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PLTOFF64LSB
;break;
10897 default: type
= "PLTOFF"; break;
10901 case FUNC_SEC_RELATIVE
:
10904 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SECREL32MSB
;break;
10905 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SECREL32LSB
;break;
10906 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SECREL64MSB
;break;
10907 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SECREL64LSB
;break;
10908 default: type
= "SECREL"; break;
10912 case FUNC_SEG_RELATIVE
:
10915 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SEGREL32MSB
;break;
10916 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SEGREL32LSB
;break;
10917 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SEGREL64MSB
;break;
10918 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SEGREL64LSB
;break;
10919 default: type
= "SEGREL"; break;
10923 case FUNC_LTV_RELATIVE
:
10926 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_LTV32MSB
; break;
10927 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_LTV32LSB
; break;
10928 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_LTV64MSB
; break;
10929 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_LTV64LSB
; break;
10930 default: type
= "LTV"; break;
10934 case FUNC_LT_FPTR_RELATIVE
:
10937 case BFD_RELOC_IA64_IMM22
:
10938 new = BFD_RELOC_IA64_LTOFF_FPTR22
; break;
10939 case BFD_RELOC_IA64_IMM64
:
10940 new = BFD_RELOC_IA64_LTOFF_FPTR64I
; break;
10941 case BFD_RELOC_IA64_DIR32MSB
:
10942 new = BFD_RELOC_IA64_LTOFF_FPTR32MSB
; break;
10943 case BFD_RELOC_IA64_DIR32LSB
:
10944 new = BFD_RELOC_IA64_LTOFF_FPTR32LSB
; break;
10945 case BFD_RELOC_IA64_DIR64MSB
:
10946 new = BFD_RELOC_IA64_LTOFF_FPTR64MSB
; break;
10947 case BFD_RELOC_IA64_DIR64LSB
:
10948 new = BFD_RELOC_IA64_LTOFF_FPTR64LSB
; break;
10950 type
= "LTOFF_FPTR"; break;
10954 case FUNC_TP_RELATIVE
:
10957 case BFD_RELOC_IA64_IMM14
: new = BFD_RELOC_IA64_TPREL14
; break;
10958 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_TPREL22
; break;
10959 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_TPREL64I
; break;
10960 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_TPREL64MSB
; break;
10961 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_TPREL64LSB
; break;
10962 default: type
= "TPREL"; break;
10966 case FUNC_LT_TP_RELATIVE
:
10969 case BFD_RELOC_IA64_IMM22
:
10970 new = BFD_RELOC_IA64_LTOFF_TPREL22
; break;
10972 type
= "LTOFF_TPREL"; break;
10976 case FUNC_DTP_MODULE
:
10979 case BFD_RELOC_IA64_DIR64MSB
:
10980 new = BFD_RELOC_IA64_DTPMOD64MSB
; break;
10981 case BFD_RELOC_IA64_DIR64LSB
:
10982 new = BFD_RELOC_IA64_DTPMOD64LSB
; break;
10984 type
= "DTPMOD"; break;
10988 case FUNC_LT_DTP_MODULE
:
10991 case BFD_RELOC_IA64_IMM22
:
10992 new = BFD_RELOC_IA64_LTOFF_DTPMOD22
; break;
10994 type
= "LTOFF_DTPMOD"; break;
10998 case FUNC_DTP_RELATIVE
:
11001 case BFD_RELOC_IA64_DIR32MSB
:
11002 new = BFD_RELOC_IA64_DTPREL32MSB
; break;
11003 case BFD_RELOC_IA64_DIR32LSB
:
11004 new = BFD_RELOC_IA64_DTPREL32LSB
; break;
11005 case BFD_RELOC_IA64_DIR64MSB
:
11006 new = BFD_RELOC_IA64_DTPREL64MSB
; break;
11007 case BFD_RELOC_IA64_DIR64LSB
:
11008 new = BFD_RELOC_IA64_DTPREL64LSB
; break;
11009 case BFD_RELOC_IA64_IMM14
:
11010 new = BFD_RELOC_IA64_DTPREL14
; break;
11011 case BFD_RELOC_IA64_IMM22
:
11012 new = BFD_RELOC_IA64_DTPREL22
; break;
11013 case BFD_RELOC_IA64_IMM64
:
11014 new = BFD_RELOC_IA64_DTPREL64I
; break;
11016 type
= "DTPREL"; break;
11020 case FUNC_LT_DTP_RELATIVE
:
11023 case BFD_RELOC_IA64_IMM22
:
11024 new = BFD_RELOC_IA64_LTOFF_DTPREL22
; break;
11026 type
= "LTOFF_DTPREL"; break;
11030 case FUNC_IPLT_RELOC
:
11033 case BFD_RELOC_IA64_IPLTMSB
: return r_type
;
11034 case BFD_RELOC_IA64_IPLTLSB
: return r_type
;
11035 default: type
= "IPLT"; break;
11053 case BFD_RELOC_IA64_DIR32MSB
: width
= 32; suffix
= "MSB"; break;
11054 case BFD_RELOC_IA64_DIR32LSB
: width
= 32; suffix
= "LSB"; break;
11055 case BFD_RELOC_IA64_DIR64MSB
: width
= 64; suffix
= "MSB"; break;
11056 case BFD_RELOC_IA64_DIR64LSB
: width
= 64; suffix
= "LSB"; break;
11057 case BFD_RELOC_UNUSED
: width
= 13; break;
11058 case BFD_RELOC_IA64_IMM14
: width
= 14; break;
11059 case BFD_RELOC_IA64_IMM22
: width
= 22; break;
11060 case BFD_RELOC_IA64_IMM64
: width
= 64; suffix
= "I"; break;
11064 /* This should be an error, but since previously there wasn't any
11065 diagnostic here, don't make it fail because of this for now. */
11066 as_warn (_("Cannot express %s%d%s relocation"), type
, width
, suffix
);
11071 /* Here is where generate the appropriate reloc for pseudo relocation
11074 ia64_validate_fix (fixS
*fix
)
11076 switch (fix
->fx_r_type
)
11078 case BFD_RELOC_IA64_FPTR64I
:
11079 case BFD_RELOC_IA64_FPTR32MSB
:
11080 case BFD_RELOC_IA64_FPTR64LSB
:
11081 case BFD_RELOC_IA64_LTOFF_FPTR22
:
11082 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
11083 if (fix
->fx_offset
!= 0)
11084 as_bad_where (fix
->fx_file
, fix
->fx_line
,
11085 _("No addend allowed in @fptr() relocation"));
11093 fix_insn (fixS
*fix
, const struct ia64_operand
*odesc
, valueT value
)
11095 bfd_vma insn
[3], t0
, t1
, control_bits
;
11100 slot
= fix
->fx_where
& 0x3;
11101 fixpos
= fix
->fx_frag
->fr_literal
+ (fix
->fx_where
- slot
);
11103 /* Bundles are always in little-endian byte order */
11104 t0
= bfd_getl64 (fixpos
);
11105 t1
= bfd_getl64 (fixpos
+ 8);
11106 control_bits
= t0
& 0x1f;
11107 insn
[0] = (t0
>> 5) & 0x1ffffffffffLL
;
11108 insn
[1] = ((t0
>> 46) & 0x3ffff) | ((t1
& 0x7fffff) << 18);
11109 insn
[2] = (t1
>> 23) & 0x1ffffffffffLL
;
11112 if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU64
)
11114 insn
[1] = (value
>> 22) & 0x1ffffffffffLL
;
11115 insn
[2] |= (((value
& 0x7f) << 13)
11116 | (((value
>> 7) & 0x1ff) << 27)
11117 | (((value
>> 16) & 0x1f) << 22)
11118 | (((value
>> 21) & 0x1) << 21)
11119 | (((value
>> 63) & 0x1) << 36));
11121 else if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU62
)
11123 if (value
& ~0x3fffffffffffffffULL
)
11124 err
= "integer operand out of range";
11125 insn
[1] = (value
>> 21) & 0x1ffffffffffLL
;
11126 insn
[2] |= (((value
& 0xfffff) << 6) | (((value
>> 20) & 0x1) << 36));
11128 else if (odesc
- elf64_ia64_operands
== IA64_OPND_TGT64
)
11131 insn
[1] = ((value
>> 20) & 0x7fffffffffLL
) << 2;
11132 insn
[2] |= ((((value
>> 59) & 0x1) << 36)
11133 | (((value
>> 0) & 0xfffff) << 13));
11136 err
= (*odesc
->insert
) (odesc
, value
, insn
+ slot
);
11139 as_bad_where (fix
->fx_file
, fix
->fx_line
, err
);
11141 t0
= control_bits
| (insn
[0] << 5) | (insn
[1] << 46);
11142 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
11143 number_to_chars_littleendian (fixpos
+ 0, t0
, 8);
11144 number_to_chars_littleendian (fixpos
+ 8, t1
, 8);
11147 /* Attempt to simplify or even eliminate a fixup. The return value is
11148 ignored; perhaps it was once meaningful, but now it is historical.
11149 To indicate that a fixup has been eliminated, set FIXP->FX_DONE.
11151 If fixp->fx_addsy is non-NULL, we'll have to generate a reloc entry
11155 md_apply_fix (fixS
*fix
, valueT
*valP
, segT seg ATTRIBUTE_UNUSED
)
11158 valueT value
= *valP
;
11160 fixpos
= fix
->fx_frag
->fr_literal
+ fix
->fx_where
;
11164 switch (fix
->fx_r_type
)
11166 case BFD_RELOC_IA64_PCREL21B
: break;
11167 case BFD_RELOC_IA64_PCREL21BI
: break;
11168 case BFD_RELOC_IA64_PCREL21F
: break;
11169 case BFD_RELOC_IA64_PCREL21M
: break;
11170 case BFD_RELOC_IA64_PCREL60B
: break;
11171 case BFD_RELOC_IA64_PCREL22
: break;
11172 case BFD_RELOC_IA64_PCREL64I
: break;
11173 case BFD_RELOC_IA64_PCREL32MSB
: break;
11174 case BFD_RELOC_IA64_PCREL32LSB
: break;
11175 case BFD_RELOC_IA64_PCREL64MSB
: break;
11176 case BFD_RELOC_IA64_PCREL64LSB
: break;
11178 fix
->fx_r_type
= ia64_gen_real_reloc_type (pseudo_func
[FUNC_PC_RELATIVE
].u
.sym
,
11185 switch (fix
->fx_r_type
)
11187 case BFD_RELOC_UNUSED
:
11188 /* This must be a TAG13 or TAG13b operand. There are no external
11189 relocs defined for them, so we must give an error. */
11190 as_bad_where (fix
->fx_file
, fix
->fx_line
,
11191 _("%s must have a constant value"),
11192 elf64_ia64_operands
[fix
->tc_fix_data
.opnd
].desc
);
11196 case BFD_RELOC_IA64_TPREL14
:
11197 case BFD_RELOC_IA64_TPREL22
:
11198 case BFD_RELOC_IA64_TPREL64I
:
11199 case BFD_RELOC_IA64_LTOFF_TPREL22
:
11200 case BFD_RELOC_IA64_LTOFF_DTPMOD22
:
11201 case BFD_RELOC_IA64_DTPREL14
:
11202 case BFD_RELOC_IA64_DTPREL22
:
11203 case BFD_RELOC_IA64_DTPREL64I
:
11204 case BFD_RELOC_IA64_LTOFF_DTPREL22
:
11205 S_SET_THREAD_LOCAL (fix
->fx_addsy
);
11212 else if (fix
->tc_fix_data
.opnd
== IA64_OPND_NIL
)
11214 if (fix
->tc_fix_data
.bigendian
)
11215 number_to_chars_bigendian (fixpos
, value
, fix
->fx_size
);
11217 number_to_chars_littleendian (fixpos
, value
, fix
->fx_size
);
11222 fix_insn (fix
, elf64_ia64_operands
+ fix
->tc_fix_data
.opnd
, value
);
11227 /* Generate the BFD reloc to be stuck in the object file from the
11228 fixup used internally in the assembler. */
11231 tc_gen_reloc (asection
*sec ATTRIBUTE_UNUSED
, fixS
*fixp
)
11235 reloc
= xmalloc (sizeof (*reloc
));
11236 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
11237 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
11238 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
11239 reloc
->addend
= fixp
->fx_offset
;
11240 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
11244 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
11245 _("Cannot represent %s relocation in object file"),
11246 bfd_get_reloc_code_name (fixp
->fx_r_type
));
11253 /* Turn a string in input_line_pointer into a floating point constant
11254 of type TYPE, and store the appropriate bytes in *LIT. The number
11255 of LITTLENUMS emitted is stored in *SIZE. An error message is
11256 returned, or NULL on OK. */
11258 #define MAX_LITTLENUMS 5
11261 md_atof (int type
, char *lit
, int *size
)
11263 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
11293 return _("Unrecognized or unsupported floating point constant");
11295 t
= atof_ieee (input_line_pointer
, type
, words
);
11297 input_line_pointer
= t
;
11299 (*ia64_float_to_chars
) (lit
, words
, prec
);
11303 /* It is 10 byte floating point with 6 byte padding. */
11304 memset (&lit
[10], 0, 6);
11305 *size
= 8 * sizeof (LITTLENUM_TYPE
);
11308 *size
= prec
* sizeof (LITTLENUM_TYPE
);
11313 /* Handle ia64 specific semantics of the align directive. */
11316 ia64_md_do_align (int n ATTRIBUTE_UNUSED
,
11317 const char *fill ATTRIBUTE_UNUSED
,
11318 int len ATTRIBUTE_UNUSED
,
11319 int max ATTRIBUTE_UNUSED
)
11321 if (subseg_text_p (now_seg
))
11322 ia64_flush_insns ();
11325 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
11326 of an rs_align_code fragment. */
11329 ia64_handle_align (fragS
*fragp
)
11333 const unsigned char *nop
;
11335 if (fragp
->fr_type
!= rs_align_code
)
11338 /* Check if this frag has to end with a stop bit. */
11339 nop
= fragp
->tc_frag_data
? le_nop_stop
: le_nop
;
11341 bytes
= fragp
->fr_next
->fr_address
- fragp
->fr_address
- fragp
->fr_fix
;
11342 p
= fragp
->fr_literal
+ fragp
->fr_fix
;
11344 /* If no paddings are needed, we check if we need a stop bit. */
11345 if (!bytes
&& fragp
->tc_frag_data
)
11347 if (fragp
->fr_fix
< 16)
11349 /* FIXME: It won't work with
11351 alloc r32=ar.pfs,1,2,4,0
11355 as_bad_where (fragp
->fr_file
, fragp
->fr_line
,
11356 _("Can't add stop bit to mark end of instruction group"));
11359 /* Bundles are always in little-endian byte order. Make sure
11360 the previous bundle has the stop bit. */
11364 /* Make sure we are on a 16-byte boundary, in case someone has been
11365 putting data into a text section. */
11368 int fix
= bytes
& 15;
11369 memset (p
, 0, fix
);
11372 fragp
->fr_fix
+= fix
;
11375 /* Instruction bundles are always little-endian. */
11376 memcpy (p
, nop
, 16);
11377 fragp
->fr_var
= 16;
11381 ia64_float_to_chars_bigendian (char *lit
, LITTLENUM_TYPE
*words
,
11386 number_to_chars_bigendian (lit
, (long) (*words
++),
11387 sizeof (LITTLENUM_TYPE
));
11388 lit
+= sizeof (LITTLENUM_TYPE
);
11393 ia64_float_to_chars_littleendian (char *lit
, LITTLENUM_TYPE
*words
,
11398 number_to_chars_littleendian (lit
, (long) (words
[prec
]),
11399 sizeof (LITTLENUM_TYPE
));
11400 lit
+= sizeof (LITTLENUM_TYPE
);
11405 ia64_elf_section_change_hook (void)
11407 if (elf_section_type (now_seg
) == SHT_IA_64_UNWIND
11408 && elf_linked_to_section (now_seg
) == NULL
)
11409 elf_linked_to_section (now_seg
) = text_section
;
11410 dot_byteorder (-1);
11413 /* Check if a label should be made global. */
11415 ia64_check_label (symbolS
*label
)
11417 if (*input_line_pointer
== ':')
11419 S_SET_EXTERNAL (label
);
11420 input_line_pointer
++;
11424 /* Used to remember where .alias and .secalias directives are seen. We
11425 will rename symbol and section names when we are about to output
11426 the relocatable file. */
11429 char *file
; /* The file where the directive is seen. */
11430 unsigned int line
; /* The line number the directive is at. */
11431 const char *name
; /* The original name of the symbol. */
11434 /* Called for .alias and .secalias directives. If SECTION is 1, it is
11435 .secalias. Otherwise, it is .alias. */
11437 dot_alias (int section
)
11439 char *name
, *alias
;
11443 const char *error_string
;
11446 struct hash_control
*ahash
, *nhash
;
11449 name
= input_line_pointer
;
11450 delim
= get_symbol_end ();
11451 end_name
= input_line_pointer
;
11454 if (name
== end_name
)
11456 as_bad (_("expected symbol name"));
11457 ignore_rest_of_line ();
11461 SKIP_WHITESPACE ();
11463 if (*input_line_pointer
!= ',')
11466 as_bad (_("expected comma after \"%s\""), name
);
11468 ignore_rest_of_line ();
11472 input_line_pointer
++;
11474 ia64_canonicalize_symbol_name (name
);
11476 /* We call demand_copy_C_string to check if alias string is valid.
11477 There should be a closing `"' and no `\0' in the string. */
11478 alias
= demand_copy_C_string (&len
);
11481 ignore_rest_of_line ();
11485 /* Make a copy of name string. */
11486 len
= strlen (name
) + 1;
11487 obstack_grow (¬es
, name
, len
);
11488 name
= obstack_finish (¬es
);
11493 ahash
= secalias_hash
;
11494 nhash
= secalias_name_hash
;
11499 ahash
= alias_hash
;
11500 nhash
= alias_name_hash
;
11503 /* Check if alias has been used before. */
11504 h
= (struct alias
*) hash_find (ahash
, alias
);
11507 if (strcmp (h
->name
, name
))
11508 as_bad (_("`%s' is already the alias of %s `%s'"),
11509 alias
, kind
, h
->name
);
11513 /* Check if name already has an alias. */
11514 a
= (const char *) hash_find (nhash
, name
);
11517 if (strcmp (a
, alias
))
11518 as_bad (_("%s `%s' already has an alias `%s'"), kind
, name
, a
);
11522 h
= (struct alias
*) xmalloc (sizeof (struct alias
));
11523 as_where (&h
->file
, &h
->line
);
11526 error_string
= hash_jam (ahash
, alias
, (void *) h
);
11529 as_fatal (_("inserting \"%s\" into %s alias hash table failed: %s"),
11530 alias
, kind
, error_string
);
11534 error_string
= hash_jam (nhash
, name
, (void *) alias
);
11537 as_fatal (_("inserting \"%s\" into %s name hash table failed: %s"),
11538 alias
, kind
, error_string
);
11540 obstack_free (¬es
, name
);
11541 obstack_free (¬es
, alias
);
11544 demand_empty_rest_of_line ();
11547 /* It renames the original symbol name to its alias. */
11549 do_alias (const char *alias
, void *value
)
11551 struct alias
*h
= (struct alias
*) value
;
11552 symbolS
*sym
= symbol_find (h
->name
);
11555 as_warn_where (h
->file
, h
->line
,
11556 _("symbol `%s' aliased to `%s' is not used"),
11559 S_SET_NAME (sym
, (char *) alias
);
11562 /* Called from write_object_file. */
11564 ia64_adjust_symtab (void)
11566 hash_traverse (alias_hash
, do_alias
);
11569 /* It renames the original section name to its alias. */
11571 do_secalias (const char *alias
, void *value
)
11573 struct alias
*h
= (struct alias
*) value
;
11574 segT sec
= bfd_get_section_by_name (stdoutput
, h
->name
);
11577 as_warn_where (h
->file
, h
->line
,
11578 _("section `%s' aliased to `%s' is not used"),
11584 /* Called from write_object_file. */
11586 ia64_frob_file (void)
11588 hash_traverse (secalias_hash
, do_secalias
);