1 /* tc-ia64.c -- Assembler for the HP/Intel IA-64 architecture.
2 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
3 2008, 2009 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"
60 #define NELEMS(a) ((int) (sizeof (a)/sizeof ((a)[0])))
62 /* Some systems define MIN in, e.g., param.h. */
64 #define MIN(a,b) ((a) < (b) ? (a) : (b))
67 #define PREV_SLOT md.slot[(md.curr_slot + NUM_SLOTS - 1) % NUM_SLOTS]
68 #define CURR_SLOT md.slot[md.curr_slot]
70 #define O_pseudo_fixup (O_max + 1)
74 /* IA-64 ABI section pseudo-ops. */
75 SPECIAL_SECTION_BSS
= 0,
77 SPECIAL_SECTION_SDATA
,
78 SPECIAL_SECTION_RODATA
,
79 SPECIAL_SECTION_COMMENT
,
80 SPECIAL_SECTION_UNWIND
,
81 SPECIAL_SECTION_UNWIND_INFO
,
82 /* HPUX specific section pseudo-ops. */
83 SPECIAL_SECTION_INIT_ARRAY
,
84 SPECIAL_SECTION_FINI_ARRAY
,
101 FUNC_LT_FPTR_RELATIVE
,
103 FUNC_LT_DTP_RELATIVE
,
107 FUNC_SLOTCOUNT_RELOC
,
114 REG_FR
= (REG_GR
+ 128),
115 REG_AR
= (REG_FR
+ 128),
116 REG_CR
= (REG_AR
+ 128),
117 REG_P
= (REG_CR
+ 128),
118 REG_BR
= (REG_P
+ 64),
119 REG_IP
= (REG_BR
+ 8),
126 /* The following are pseudo-registers for use by gas only. */
137 /* The following pseudo-registers are used for unwind directives only: */
145 DYNREG_GR
= 0, /* dynamic general purpose register */
146 DYNREG_FR
, /* dynamic floating point register */
147 DYNREG_PR
, /* dynamic predicate register */
151 enum operand_match_result
154 OPERAND_OUT_OF_RANGE
,
158 /* On the ia64, we can't know the address of a text label until the
159 instructions are packed into a bundle. To handle this, we keep
160 track of the list of labels that appear in front of each
164 struct label_fix
*next
;
166 bfd_boolean dw2_mark_labels
;
170 /* An internally used relocation. */
171 #define DUMMY_RELOC_IA64_SLOTCOUNT (BFD_RELOC_UNUSED + 1)
174 /* This is the endianness of the current section. */
175 extern int target_big_endian
;
177 /* This is the default endianness. */
178 static int default_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
180 void (*ia64_number_to_chars
) (char *, valueT
, int);
182 static void ia64_float_to_chars_bigendian (char *, LITTLENUM_TYPE
*, int);
183 static void ia64_float_to_chars_littleendian (char *, LITTLENUM_TYPE
*, int);
185 static void (*ia64_float_to_chars
) (char *, LITTLENUM_TYPE
*, int);
187 static struct hash_control
*alias_hash
;
188 static struct hash_control
*alias_name_hash
;
189 static struct hash_control
*secalias_hash
;
190 static struct hash_control
*secalias_name_hash
;
192 /* List of chars besides those in app.c:symbol_chars that can start an
193 operand. Used to prevent the scrubber eating vital white-space. */
194 const char ia64_symbol_chars
[] = "@?";
196 /* Characters which always start a comment. */
197 const char comment_chars
[] = "";
199 /* Characters which start a comment at the beginning of a line. */
200 const char line_comment_chars
[] = "#";
202 /* Characters which may be used to separate multiple commands on a
204 const char line_separator_chars
[] = ";{}";
206 /* Characters which are used to indicate an exponent in a floating
208 const char EXP_CHARS
[] = "eE";
210 /* Characters which mean that a number is a floating point constant,
212 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
214 /* ia64-specific option processing: */
216 const char *md_shortopts
= "m:N:x::";
218 struct option md_longopts
[] =
220 #define OPTION_MCONSTANT_GP (OPTION_MD_BASE + 1)
221 {"mconstant-gp", no_argument
, NULL
, OPTION_MCONSTANT_GP
},
222 #define OPTION_MAUTO_PIC (OPTION_MD_BASE + 2)
223 {"mauto-pic", no_argument
, NULL
, OPTION_MAUTO_PIC
}
226 size_t md_longopts_size
= sizeof (md_longopts
);
230 struct hash_control
*pseudo_hash
; /* pseudo opcode hash table */
231 struct hash_control
*reg_hash
; /* register name hash table */
232 struct hash_control
*dynreg_hash
; /* dynamic register hash table */
233 struct hash_control
*const_hash
; /* constant hash table */
234 struct hash_control
*entry_hash
; /* code entry hint hash table */
236 /* If X_op is != O_absent, the registername for the instruction's
237 qualifying predicate. If NULL, p0 is assumed for instructions
238 that are predictable. */
241 /* Optimize for which CPU. */
248 /* What to do when hint.b is used. */
260 explicit_mode
: 1, /* which mode we're in */
261 default_explicit_mode
: 1, /* which mode is the default */
262 mode_explicitly_set
: 1, /* was the current mode explicitly set? */
264 keep_pending_output
: 1;
266 /* What to do when something is wrong with unwind directives. */
269 unwind_check_warning
,
273 /* Each bundle consists of up to three instructions. We keep
274 track of four most recent instructions so we can correctly set
275 the end_of_insn_group for the last instruction in a bundle. */
277 int num_slots_in_use
;
281 end_of_insn_group
: 1,
282 manual_bundling_on
: 1,
283 manual_bundling_off
: 1,
284 loc_directive_seen
: 1;
285 signed char user_template
; /* user-selected template, if any */
286 unsigned char qp_regno
; /* qualifying predicate */
287 /* This duplicates a good fraction of "struct fix" but we
288 can't use a "struct fix" instead since we can't call
289 fix_new_exp() until we know the address of the instruction. */
293 bfd_reloc_code_real_type code
;
294 enum ia64_opnd opnd
; /* type of operand in need of fix */
295 unsigned int is_pcrel
: 1; /* is operand pc-relative? */
296 expressionS expr
; /* the value to be inserted */
298 fixup
[2]; /* at most two fixups per insn */
299 struct ia64_opcode
*idesc
;
300 struct label_fix
*label_fixups
;
301 struct label_fix
*tag_fixups
;
302 struct unw_rec_list
*unwind_record
; /* Unwind directive. */
305 unsigned int src_line
;
306 struct dwarf2_line_info debug_line
;
314 struct dynreg
*next
; /* next dynamic register */
316 unsigned short base
; /* the base register number */
317 unsigned short num_regs
; /* # of registers in this set */
319 *dynreg
[DYNREG_NUM_TYPES
], in
, loc
, out
, rot
;
321 flagword flags
; /* ELF-header flags */
324 unsigned hint
:1; /* is this hint currently valid? */
325 bfd_vma offset
; /* mem.offset offset */
326 bfd_vma base
; /* mem.offset base */
329 int path
; /* number of alt. entry points seen */
330 const char **entry_labels
; /* labels of all alternate paths in
331 the current DV-checking block. */
332 int maxpaths
; /* size currently allocated for
335 int pointer_size
; /* size in bytes of a pointer */
336 int pointer_size_shift
; /* shift size of a pointer for alignment */
338 symbolS
*indregsym
[IND_RR
- IND_CPUID
+ 1];
342 /* These are not const, because they are modified to MMI for non-itanium1
344 /* MFI bundle of nops. */
345 static unsigned char le_nop
[16] =
347 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
348 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00
350 /* MFI bundle of nops with stop-bit. */
351 static unsigned char le_nop_stop
[16] =
353 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
354 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00
357 /* application registers: */
363 #define AR_BSPSTORE 18
389 {"ar.k0", AR_K0
}, {"ar.k1", AR_K0
+ 1},
390 {"ar.k2", AR_K0
+ 2}, {"ar.k3", AR_K0
+ 3},
391 {"ar.k4", AR_K0
+ 4}, {"ar.k5", AR_K0
+ 5},
392 {"ar.k6", AR_K0
+ 6}, {"ar.k7", AR_K7
},
393 {"ar.rsc", AR_RSC
}, {"ar.bsp", AR_BSP
},
394 {"ar.bspstore", AR_BSPSTORE
}, {"ar.rnat", AR_RNAT
},
395 {"ar.fcr", AR_FCR
}, {"ar.eflag", AR_EFLAG
},
396 {"ar.csd", AR_CSD
}, {"ar.ssd", AR_SSD
},
397 {"ar.cflg", AR_CFLG
}, {"ar.fsr", AR_FSR
},
398 {"ar.fir", AR_FIR
}, {"ar.fdr", AR_FDR
},
399 {"ar.ccv", AR_CCV
}, {"ar.unat", AR_UNAT
},
400 {"ar.fpsr", AR_FPSR
}, {"ar.itc", AR_ITC
},
401 {"ar.ruc", AR_RUC
}, {"ar.pfs", AR_PFS
},
402 {"ar.lc", AR_LC
}, {"ar.ec", AR_EC
},
405 /* control registers: */
446 {"cr.gpta", CR_GPTA
},
447 {"cr.ipsr", CR_IPSR
},
451 {"cr.itir", CR_ITIR
},
452 {"cr.iipa", CR_IIPA
},
456 {"cr.iib0", CR_IIB0
},
457 {"cr.iib1", CR_IIB1
},
462 {"cr.irr0", CR_IRR0
},
463 {"cr.irr1", CR_IRR0
+ 1},
464 {"cr.irr2", CR_IRR0
+ 2},
465 {"cr.irr3", CR_IRR3
},
468 {"cr.cmcv", CR_CMCV
},
469 {"cr.lrr0", CR_LRR0
},
478 static const struct const_desc
485 /* PSR constant masks: */
488 {"psr.be", ((valueT
) 1) << 1},
489 {"psr.up", ((valueT
) 1) << 2},
490 {"psr.ac", ((valueT
) 1) << 3},
491 {"psr.mfl", ((valueT
) 1) << 4},
492 {"psr.mfh", ((valueT
) 1) << 5},
494 {"psr.ic", ((valueT
) 1) << 13},
495 {"psr.i", ((valueT
) 1) << 14},
496 {"psr.pk", ((valueT
) 1) << 15},
498 {"psr.dt", ((valueT
) 1) << 17},
499 {"psr.dfl", ((valueT
) 1) << 18},
500 {"psr.dfh", ((valueT
) 1) << 19},
501 {"psr.sp", ((valueT
) 1) << 20},
502 {"psr.pp", ((valueT
) 1) << 21},
503 {"psr.di", ((valueT
) 1) << 22},
504 {"psr.si", ((valueT
) 1) << 23},
505 {"psr.db", ((valueT
) 1) << 24},
506 {"psr.lp", ((valueT
) 1) << 25},
507 {"psr.tb", ((valueT
) 1) << 26},
508 {"psr.rt", ((valueT
) 1) << 27},
509 /* 28-31: reserved */
510 /* 32-33: cpl (current privilege level) */
511 {"psr.is", ((valueT
) 1) << 34},
512 {"psr.mc", ((valueT
) 1) << 35},
513 {"psr.it", ((valueT
) 1) << 36},
514 {"psr.id", ((valueT
) 1) << 37},
515 {"psr.da", ((valueT
) 1) << 38},
516 {"psr.dd", ((valueT
) 1) << 39},
517 {"psr.ss", ((valueT
) 1) << 40},
518 /* 41-42: ri (restart instruction) */
519 {"psr.ed", ((valueT
) 1) << 43},
520 {"psr.bn", ((valueT
) 1) << 44},
523 /* indirect register-sets/memory: */
532 { "CPUID", IND_CPUID
},
533 { "cpuid", IND_CPUID
},
545 /* Pseudo functions used to indicate relocation types (these functions
546 start with an at sign (@). */
568 /* reloc pseudo functions (these must come first!): */
569 { "dtpmod", PSEUDO_FUNC_RELOC
, { 0 } },
570 { "dtprel", PSEUDO_FUNC_RELOC
, { 0 } },
571 { "fptr", PSEUDO_FUNC_RELOC
, { 0 } },
572 { "gprel", PSEUDO_FUNC_RELOC
, { 0 } },
573 { "ltoff", PSEUDO_FUNC_RELOC
, { 0 } },
574 { "ltoffx", PSEUDO_FUNC_RELOC
, { 0 } },
575 { "pcrel", PSEUDO_FUNC_RELOC
, { 0 } },
576 { "pltoff", PSEUDO_FUNC_RELOC
, { 0 } },
577 { "secrel", PSEUDO_FUNC_RELOC
, { 0 } },
578 { "segrel", PSEUDO_FUNC_RELOC
, { 0 } },
579 { "tprel", PSEUDO_FUNC_RELOC
, { 0 } },
580 { "ltv", PSEUDO_FUNC_RELOC
, { 0 } },
581 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_FPTR_RELATIVE */
582 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_DTP_MODULE */
583 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_DTP_RELATIVE */
584 { NULL
, 0, { 0 } }, /* placeholder for FUNC_LT_TP_RELATIVE */
585 { "iplt", PSEUDO_FUNC_RELOC
, { 0 } },
587 { "slotcount", PSEUDO_FUNC_RELOC
, { 0 } },
590 /* mbtype4 constants: */
591 { "alt", PSEUDO_FUNC_CONST
, { 0xa } },
592 { "brcst", PSEUDO_FUNC_CONST
, { 0x0 } },
593 { "mix", PSEUDO_FUNC_CONST
, { 0x8 } },
594 { "rev", PSEUDO_FUNC_CONST
, { 0xb } },
595 { "shuf", PSEUDO_FUNC_CONST
, { 0x9 } },
597 /* fclass constants: */
598 { "nat", PSEUDO_FUNC_CONST
, { 0x100 } },
599 { "qnan", PSEUDO_FUNC_CONST
, { 0x080 } },
600 { "snan", PSEUDO_FUNC_CONST
, { 0x040 } },
601 { "pos", PSEUDO_FUNC_CONST
, { 0x001 } },
602 { "neg", PSEUDO_FUNC_CONST
, { 0x002 } },
603 { "zero", PSEUDO_FUNC_CONST
, { 0x004 } },
604 { "unorm", PSEUDO_FUNC_CONST
, { 0x008 } },
605 { "norm", PSEUDO_FUNC_CONST
, { 0x010 } },
606 { "inf", PSEUDO_FUNC_CONST
, { 0x020 } },
608 { "natval", PSEUDO_FUNC_CONST
, { 0x100 } }, /* old usage */
610 /* hint constants: */
611 { "pause", PSEUDO_FUNC_CONST
, { 0x0 } },
613 /* unwind-related constants: */
614 { "svr4", PSEUDO_FUNC_CONST
, { ELFOSABI_NONE
} },
615 { "hpux", PSEUDO_FUNC_CONST
, { ELFOSABI_HPUX
} },
616 { "nt", PSEUDO_FUNC_CONST
, { 2 } }, /* conflicts w/ELFOSABI_NETBSD */
617 { "linux", PSEUDO_FUNC_CONST
, { ELFOSABI_LINUX
} },
618 { "freebsd", PSEUDO_FUNC_CONST
, { ELFOSABI_FREEBSD
} },
619 { "openvms", PSEUDO_FUNC_CONST
, { ELFOSABI_OPENVMS
} },
620 { "nsk", PSEUDO_FUNC_CONST
, { ELFOSABI_NSK
} },
622 /* unwind-related registers: */
623 { "priunat",PSEUDO_FUNC_REG
, { REG_PRIUNAT
} }
626 /* 41-bit nop opcodes (one per unit): */
627 static const bfd_vma nop
[IA64_NUM_UNITS
] =
629 0x0000000000LL
, /* NIL => break 0 */
630 0x0008000000LL
, /* I-unit nop */
631 0x0008000000LL
, /* M-unit nop */
632 0x4000000000LL
, /* B-unit nop */
633 0x0008000000LL
, /* F-unit nop */
634 0x0000000000LL
, /* L-"unit" nop immediate */
635 0x0008000000LL
, /* X-unit nop */
638 /* Can't be `const' as it's passed to input routines (which have the
639 habit of setting temporary sentinels. */
640 static char special_section_name
[][20] =
642 {".bss"}, {".sbss"}, {".sdata"}, {".rodata"}, {".comment"},
643 {".IA_64.unwind"}, {".IA_64.unwind_info"},
644 {".init_array"}, {".fini_array"}
647 /* The best template for a particular sequence of up to three
649 #define N IA64_NUM_TYPES
650 static unsigned char best_template
[N
][N
][N
];
653 /* Resource dependencies currently in effect */
655 int depind
; /* dependency index */
656 const struct ia64_dependency
*dependency
; /* actual dependency */
657 unsigned specific
:1, /* is this a specific bit/regno? */
658 link_to_qp_branch
:1; /* will a branch on the same QP clear it?*/
659 int index
; /* specific regno/bit within dependency */
660 int note
; /* optional qualifying note (0 if none) */
664 int insn_srlz
; /* current insn serialization state */
665 int data_srlz
; /* current data serialization state */
666 int qp_regno
; /* qualifying predicate for this usage */
667 char *file
; /* what file marked this dependency */
668 unsigned int line
; /* what line marked this dependency */
669 struct mem_offset mem_offset
; /* optional memory offset hint */
670 enum { CMP_NONE
, CMP_OR
, CMP_AND
} cmp_type
; /* OR or AND compare? */
671 int path
; /* corresponding code entry index */
673 static int regdepslen
= 0;
674 static int regdepstotlen
= 0;
675 static const char *dv_mode
[] = { "RAW", "WAW", "WAR" };
676 static const char *dv_sem
[] = { "none", "implied", "impliedf",
677 "data", "instr", "specific", "stop", "other" };
678 static const char *dv_cmp_type
[] = { "none", "OR", "AND" };
680 /* Current state of PR mutexation */
681 static struct qpmutex
{
684 } *qp_mutexes
= NULL
; /* QP mutex bitmasks */
685 static int qp_mutexeslen
= 0;
686 static int qp_mutexestotlen
= 0;
687 static valueT qp_safe_across_calls
= 0;
689 /* Current state of PR implications */
690 static struct qp_imply
{
693 unsigned p2_branched
:1;
695 } *qp_implies
= NULL
;
696 static int qp_implieslen
= 0;
697 static int qp_impliestotlen
= 0;
699 /* Keep track of static GR values so that indirect register usage can
700 sometimes be tracked. */
711 (((1 << (8 * sizeof(gr_values
->path
) - 2)) - 1) << 1) + 1,
717 /* Remember the alignment frag. */
718 static fragS
*align_frag
;
720 /* These are the routines required to output the various types of
723 /* A slot_number is a frag address plus the slot index (0-2). We use the
724 frag address here so that if there is a section switch in the middle of
725 a function, then instructions emitted to a different section are not
726 counted. Since there may be more than one frag for a function, this
727 means we also need to keep track of which frag this address belongs to
728 so we can compute inter-frag distances. This also nicely solves the
729 problem with nops emitted for align directives, which can't easily be
730 counted, but can easily be derived from frag sizes. */
732 typedef struct unw_rec_list
{
734 unsigned long slot_number
;
736 struct unw_rec_list
*next
;
739 #define SLOT_NUM_NOT_SET (unsigned)-1
741 /* Linked list of saved prologue counts. A very poor
742 implementation of a map from label numbers to prologue counts. */
743 typedef struct label_prologue_count
745 struct label_prologue_count
*next
;
746 unsigned long label_number
;
747 unsigned int prologue_count
;
748 } label_prologue_count
;
750 typedef struct proc_pending
753 struct proc_pending
*next
;
758 /* Maintain a list of unwind entries for the current function. */
762 /* Any unwind entries that should be attached to the current slot
763 that an insn is being constructed for. */
764 unw_rec_list
*current_entry
;
766 /* These are used to create the unwind table entry for this function. */
767 proc_pending proc_pending
;
768 symbolS
*info
; /* pointer to unwind info */
769 symbolS
*personality_routine
;
771 subsegT saved_text_subseg
;
772 unsigned int force_unwind_entry
: 1; /* force generation of unwind entry? */
774 /* TRUE if processing unwind directives in a prologue region. */
775 unsigned int prologue
: 1;
776 unsigned int prologue_mask
: 4;
777 unsigned int prologue_gr
: 7;
778 unsigned int body
: 1;
779 unsigned int insn
: 1;
780 unsigned int prologue_count
; /* number of .prologues seen so far */
781 /* Prologue counts at previous .label_state directives. */
782 struct label_prologue_count
* saved_prologue_counts
;
784 /* List of split up .save-s. */
785 unw_p_record
*pending_saves
;
788 /* The input value is a negated offset from psp, and specifies an address
789 psp - offset. The encoded value is psp + 16 - (4 * offset). Thus we
790 must add 16 and divide by 4 to get the encoded value. */
792 #define ENCODED_PSP_OFFSET(OFFSET) (((OFFSET) + 16) / 4)
794 typedef void (*vbyte_func
) (int, char *, char *);
796 /* Forward declarations: */
797 static void dot_alias (int);
798 static int parse_operand_and_eval (expressionS
*, int);
799 static void emit_one_bundle (void);
800 static bfd_reloc_code_real_type
ia64_gen_real_reloc_type (struct symbol
*,
801 bfd_reloc_code_real_type
);
802 static void insn_group_break (int, int, int);
803 static void add_qp_mutex (valueT
);
804 static void add_qp_imply (int, int);
805 static void clear_qp_mutex (valueT
);
806 static void clear_qp_implies (valueT
, valueT
);
807 static void print_dependency (const char *, int);
808 static void instruction_serialization (void);
809 static void data_serialization (void);
810 static void output_R3_format (vbyte_func
, unw_record_type
, unsigned long);
811 static void output_B3_format (vbyte_func
, unsigned long, unsigned long);
812 static void output_B4_format (vbyte_func
, unw_record_type
, unsigned long);
813 static void free_saved_prologue_counts (void);
815 /* Determine if application register REGNUM resides only in the integer
816 unit (as opposed to the memory unit). */
818 ar_is_only_in_integer_unit (int reg
)
821 return reg
>= 64 && reg
<= 111;
824 /* Determine if application register REGNUM resides only in the memory
825 unit (as opposed to the integer unit). */
827 ar_is_only_in_memory_unit (int reg
)
830 return reg
>= 0 && reg
<= 47;
833 /* Switch to section NAME and create section if necessary. It's
834 rather ugly that we have to manipulate input_line_pointer but I
835 don't see any other way to accomplish the same thing without
836 changing obj-elf.c (which may be the Right Thing, in the end). */
838 set_section (char *name
)
840 char *saved_input_line_pointer
;
842 saved_input_line_pointer
= input_line_pointer
;
843 input_line_pointer
= name
;
845 input_line_pointer
= saved_input_line_pointer
;
848 /* Map 's' to SHF_IA_64_SHORT. */
851 ia64_elf_section_letter (int letter
, char **ptr_msg
)
854 return SHF_IA_64_SHORT
;
855 else if (letter
== 'o')
856 return SHF_LINK_ORDER
;
858 else if (letter
== 'O')
859 return SHF_IA_64_VMS_OVERLAID
;
860 else if (letter
== 'g')
861 return SHF_IA_64_VMS_GLOBAL
;
864 *ptr_msg
= _("Bad .section directive: want a,o,s,w,x,M,S,G,T in string");
868 /* Map SHF_IA_64_SHORT to SEC_SMALL_DATA. */
871 ia64_elf_section_flags (flagword flags
,
873 int type ATTRIBUTE_UNUSED
)
875 if (attr
& SHF_IA_64_SHORT
)
876 flags
|= SEC_SMALL_DATA
;
881 ia64_elf_section_type (const char *str
, size_t len
)
883 #define STREQ(s) ((len == sizeof (s) - 1) && (strncmp (str, s, sizeof (s) - 1) == 0))
885 if (STREQ (ELF_STRING_ia64_unwind_info
))
888 if (STREQ (ELF_STRING_ia64_unwind_info_once
))
891 if (STREQ (ELF_STRING_ia64_unwind
))
892 return SHT_IA_64_UNWIND
;
894 if (STREQ (ELF_STRING_ia64_unwind_once
))
895 return SHT_IA_64_UNWIND
;
897 if (STREQ ("unwind"))
898 return SHT_IA_64_UNWIND
;
905 set_regstack (unsigned int ins
,
913 sof
= ins
+ locs
+ outs
;
916 as_bad (_("Size of frame exceeds maximum of 96 registers"));
921 as_warn (_("Size of rotating registers exceeds frame size"));
924 md
.in
.base
= REG_GR
+ 32;
925 md
.loc
.base
= md
.in
.base
+ ins
;
926 md
.out
.base
= md
.loc
.base
+ locs
;
928 md
.in
.num_regs
= ins
;
929 md
.loc
.num_regs
= locs
;
930 md
.out
.num_regs
= outs
;
931 md
.rot
.num_regs
= rots
;
936 ia64_flush_insns (void)
938 struct label_fix
*lfix
;
940 subsegT saved_subseg
;
944 if (!md
.last_text_seg
)
948 saved_subseg
= now_subseg
;
950 subseg_set (md
.last_text_seg
, 0);
952 while (md
.num_slots_in_use
> 0)
953 emit_one_bundle (); /* force out queued instructions */
955 /* In case there are labels following the last instruction, resolve
958 for (lfix
= CURR_SLOT
.label_fixups
; lfix
; lfix
= lfix
->next
)
960 symbol_set_value_now (lfix
->sym
);
961 mark
|= lfix
->dw2_mark_labels
;
965 dwarf2_where (&CURR_SLOT
.debug_line
);
966 CURR_SLOT
.debug_line
.flags
|= DWARF2_FLAG_BASIC_BLOCK
;
967 dwarf2_gen_line_info (frag_now_fix (), &CURR_SLOT
.debug_line
);
968 dwarf2_consume_line_info ();
970 CURR_SLOT
.label_fixups
= 0;
972 for (lfix
= CURR_SLOT
.tag_fixups
; lfix
; lfix
= lfix
->next
)
973 symbol_set_value_now (lfix
->sym
);
974 CURR_SLOT
.tag_fixups
= 0;
976 /* In case there are unwind directives following the last instruction,
977 resolve those now. We only handle prologue, body, and endp directives
978 here. Give an error for others. */
979 for (ptr
= unwind
.current_entry
; ptr
; ptr
= ptr
->next
)
987 ptr
->slot_number
= (unsigned long) frag_more (0);
988 ptr
->slot_frag
= frag_now
;
991 /* Allow any record which doesn't have a "t" field (i.e.,
992 doesn't relate to a particular instruction). */
1008 as_bad (_("Unwind directive not followed by an instruction."));
1012 unwind
.current_entry
= NULL
;
1014 subseg_set (saved_seg
, saved_subseg
);
1016 if (md
.qp
.X_op
== O_register
)
1017 as_bad (_("qualifying predicate not followed by instruction"));
1021 ia64_do_align (int nbytes
)
1023 char *saved_input_line_pointer
= input_line_pointer
;
1025 input_line_pointer
= "";
1026 s_align_bytes (nbytes
);
1027 input_line_pointer
= saved_input_line_pointer
;
1031 ia64_cons_align (int nbytes
)
1035 char *saved_input_line_pointer
= input_line_pointer
;
1036 input_line_pointer
= "";
1037 s_align_bytes (nbytes
);
1038 input_line_pointer
= saved_input_line_pointer
;
1042 /* Output COUNT bytes to a memory location. */
1043 static char *vbyte_mem_ptr
= NULL
;
1046 output_vbyte_mem (int count
, char *ptr
, char *comment ATTRIBUTE_UNUSED
)
1049 if (vbyte_mem_ptr
== NULL
)
1054 for (x
= 0; x
< count
; x
++)
1055 *(vbyte_mem_ptr
++) = ptr
[x
];
1058 /* Count the number of bytes required for records. */
1059 static int vbyte_count
= 0;
1061 count_output (int count
,
1062 char *ptr ATTRIBUTE_UNUSED
,
1063 char *comment ATTRIBUTE_UNUSED
)
1065 vbyte_count
+= count
;
1069 output_R1_format (vbyte_func f
, unw_record_type rtype
, int rlen
)
1075 output_R3_format (f
, rtype
, rlen
);
1081 else if (rtype
!= prologue
)
1082 as_bad (_("record type is not valid"));
1084 byte
= UNW_R1
| (r
<< 5) | (rlen
& 0x1f);
1085 (*f
) (1, &byte
, NULL
);
1089 output_R2_format (vbyte_func f
, int mask
, int grsave
, unsigned long rlen
)
1093 mask
= (mask
& 0x0f);
1094 grsave
= (grsave
& 0x7f);
1096 bytes
[0] = (UNW_R2
| (mask
>> 1));
1097 bytes
[1] = (((mask
& 0x01) << 7) | grsave
);
1098 count
+= output_leb128 (bytes
+ 2, rlen
, 0);
1099 (*f
) (count
, bytes
, NULL
);
1103 output_R3_format (vbyte_func f
, unw_record_type rtype
, unsigned long rlen
)
1109 output_R1_format (f
, rtype
, rlen
);
1115 else if (rtype
!= prologue
)
1116 as_bad (_("record type is not valid"));
1117 bytes
[0] = (UNW_R3
| r
);
1118 count
= output_leb128 (bytes
+ 1, rlen
, 0);
1119 (*f
) (count
+ 1, bytes
, NULL
);
1123 output_P1_format (vbyte_func f
, int brmask
)
1126 byte
= UNW_P1
| (brmask
& 0x1f);
1127 (*f
) (1, &byte
, NULL
);
1131 output_P2_format (vbyte_func f
, int brmask
, int gr
)
1134 brmask
= (brmask
& 0x1f);
1135 bytes
[0] = UNW_P2
| (brmask
>> 1);
1136 bytes
[1] = (((brmask
& 1) << 7) | gr
);
1137 (*f
) (2, bytes
, NULL
);
1141 output_P3_format (vbyte_func f
, unw_record_type rtype
, int reg
)
1185 as_bad (_("Invalid record type for P3 format."));
1187 bytes
[0] = (UNW_P3
| (r
>> 1));
1188 bytes
[1] = (((r
& 1) << 7) | reg
);
1189 (*f
) (2, bytes
, NULL
);
1193 output_P4_format (vbyte_func f
, unsigned char *imask
, unsigned long imask_size
)
1196 (*f
) (imask_size
, (char *) imask
, NULL
);
1200 output_P5_format (vbyte_func f
, int grmask
, unsigned long frmask
)
1203 grmask
= (grmask
& 0x0f);
1206 bytes
[1] = ((grmask
<< 4) | ((frmask
& 0x000f0000) >> 16));
1207 bytes
[2] = ((frmask
& 0x0000ff00) >> 8);
1208 bytes
[3] = (frmask
& 0x000000ff);
1209 (*f
) (4, bytes
, NULL
);
1213 output_P6_format (vbyte_func f
, unw_record_type rtype
, int rmask
)
1218 if (rtype
== gr_mem
)
1220 else if (rtype
!= fr_mem
)
1221 as_bad (_("Invalid record type for format P6"));
1222 byte
= (UNW_P6
| (r
<< 4) | (rmask
& 0x0f));
1223 (*f
) (1, &byte
, NULL
);
1227 output_P7_format (vbyte_func f
,
1228 unw_record_type rtype
,
1235 count
+= output_leb128 (bytes
+ 1, w1
, 0);
1240 count
+= output_leb128 (bytes
+ count
, w2
>> 4, 0);
1290 bytes
[0] = (UNW_P7
| r
);
1291 (*f
) (count
, bytes
, NULL
);
1295 output_P8_format (vbyte_func f
, unw_record_type rtype
, unsigned long t
)
1333 case bspstore_psprel
:
1336 case bspstore_sprel
:
1348 case priunat_when_gr
:
1351 case priunat_psprel
:
1357 case priunat_when_mem
:
1364 count
+= output_leb128 (bytes
+ 2, t
, 0);
1365 (*f
) (count
, bytes
, NULL
);
1369 output_P9_format (vbyte_func f
, int grmask
, int gr
)
1373 bytes
[1] = (grmask
& 0x0f);
1374 bytes
[2] = (gr
& 0x7f);
1375 (*f
) (3, bytes
, NULL
);
1379 output_P10_format (vbyte_func f
, int abi
, int context
)
1383 bytes
[1] = (abi
& 0xff);
1384 bytes
[2] = (context
& 0xff);
1385 (*f
) (3, bytes
, NULL
);
1389 output_B1_format (vbyte_func f
, unw_record_type rtype
, unsigned long label
)
1395 output_B4_format (f
, rtype
, label
);
1398 if (rtype
== copy_state
)
1400 else if (rtype
!= label_state
)
1401 as_bad (_("Invalid record type for format B1"));
1403 byte
= (UNW_B1
| (r
<< 5) | (label
& 0x1f));
1404 (*f
) (1, &byte
, NULL
);
1408 output_B2_format (vbyte_func f
, unsigned long ecount
, unsigned long t
)
1414 output_B3_format (f
, ecount
, t
);
1417 bytes
[0] = (UNW_B2
| (ecount
& 0x1f));
1418 count
+= output_leb128 (bytes
+ 1, t
, 0);
1419 (*f
) (count
, bytes
, NULL
);
1423 output_B3_format (vbyte_func f
, unsigned long ecount
, unsigned long t
)
1429 output_B2_format (f
, ecount
, t
);
1433 count
+= output_leb128 (bytes
+ 1, t
, 0);
1434 count
+= output_leb128 (bytes
+ count
, ecount
, 0);
1435 (*f
) (count
, bytes
, NULL
);
1439 output_B4_format (vbyte_func f
, unw_record_type rtype
, unsigned long label
)
1446 output_B1_format (f
, rtype
, label
);
1450 if (rtype
== copy_state
)
1452 else if (rtype
!= label_state
)
1453 as_bad (_("Invalid record type for format B1"));
1455 bytes
[0] = (UNW_B4
| (r
<< 3));
1456 count
+= output_leb128 (bytes
+ 1, label
, 0);
1457 (*f
) (count
, bytes
, NULL
);
1461 format_ab_reg (int ab
, int reg
)
1466 ret
= (ab
<< 5) | reg
;
1471 output_X1_format (vbyte_func f
,
1472 unw_record_type rtype
,
1483 if (rtype
== spill_sprel
)
1485 else if (rtype
!= spill_psprel
)
1486 as_bad (_("Invalid record type for format X1"));
1487 bytes
[1] = ((r
<< 7) | format_ab_reg (ab
, reg
));
1488 count
+= output_leb128 (bytes
+ 2, t
, 0);
1489 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1490 (*f
) (count
, bytes
, NULL
);
1494 output_X2_format (vbyte_func f
,
1505 bytes
[1] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1506 bytes
[2] = (((y
& 1) << 7) | (treg
& 0x7f));
1507 count
+= output_leb128 (bytes
+ 3, t
, 0);
1508 (*f
) (count
, bytes
, NULL
);
1512 output_X3_format (vbyte_func f
,
1513 unw_record_type rtype
,
1525 if (rtype
== spill_sprel_p
)
1527 else if (rtype
!= spill_psprel_p
)
1528 as_bad (_("Invalid record type for format X3"));
1529 bytes
[1] = ((r
<< 7) | (qp
& 0x3f));
1530 bytes
[2] = format_ab_reg (ab
, reg
);
1531 count
+= output_leb128 (bytes
+ 3, t
, 0);
1532 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1533 (*f
) (count
, bytes
, NULL
);
1537 output_X4_format (vbyte_func f
,
1549 bytes
[1] = (qp
& 0x3f);
1550 bytes
[2] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1551 bytes
[3] = (((y
& 1) << 7) | (treg
& 0x7f));
1552 count
+= output_leb128 (bytes
+ 4, t
, 0);
1553 (*f
) (count
, bytes
, NULL
);
1556 /* This function checks whether there are any outstanding .save-s and
1557 discards them if so. */
1560 check_pending_save (void)
1562 if (unwind
.pending_saves
)
1564 unw_rec_list
*cur
, *prev
;
1566 as_warn (_("Previous .save incomplete"));
1567 for (cur
= unwind
.list
, prev
= NULL
; cur
; )
1568 if (&cur
->r
.record
.p
== unwind
.pending_saves
)
1571 prev
->next
= cur
->next
;
1573 unwind
.list
= cur
->next
;
1574 if (cur
== unwind
.tail
)
1576 if (cur
== unwind
.current_entry
)
1577 unwind
.current_entry
= cur
->next
;
1578 /* Don't free the first discarded record, it's being used as
1579 terminator for (currently) br_gr and gr_gr processing, and
1580 also prevents leaving a dangling pointer to it in its
1582 cur
->r
.record
.p
.grmask
= 0;
1583 cur
->r
.record
.p
.brmask
= 0;
1584 cur
->r
.record
.p
.frmask
= 0;
1585 prev
= cur
->r
.record
.p
.next
;
1586 cur
->r
.record
.p
.next
= NULL
;
1598 cur
= cur
->r
.record
.p
.next
;
1601 unwind
.pending_saves
= NULL
;
1605 /* This function allocates a record list structure, and initializes fields. */
1607 static unw_rec_list
*
1608 alloc_record (unw_record_type t
)
1611 ptr
= xmalloc (sizeof (*ptr
));
1612 memset (ptr
, 0, sizeof (*ptr
));
1613 ptr
->slot_number
= SLOT_NUM_NOT_SET
;
1618 /* Dummy unwind record used for calculating the length of the last prologue or
1621 static unw_rec_list
*
1624 unw_rec_list
*ptr
= alloc_record (endp
);
1628 static unw_rec_list
*
1629 output_prologue (void)
1631 unw_rec_list
*ptr
= alloc_record (prologue
);
1632 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1636 static unw_rec_list
*
1637 output_prologue_gr (unsigned int saved_mask
, unsigned int reg
)
1639 unw_rec_list
*ptr
= alloc_record (prologue_gr
);
1640 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1641 ptr
->r
.record
.r
.grmask
= saved_mask
;
1642 ptr
->r
.record
.r
.grsave
= reg
;
1646 static unw_rec_list
*
1649 unw_rec_list
*ptr
= alloc_record (body
);
1653 static unw_rec_list
*
1654 output_mem_stack_f (unsigned int size
)
1656 unw_rec_list
*ptr
= alloc_record (mem_stack_f
);
1657 ptr
->r
.record
.p
.size
= size
;
1661 static unw_rec_list
*
1662 output_mem_stack_v (void)
1664 unw_rec_list
*ptr
= alloc_record (mem_stack_v
);
1668 static unw_rec_list
*
1669 output_psp_gr (unsigned int gr
)
1671 unw_rec_list
*ptr
= alloc_record (psp_gr
);
1672 ptr
->r
.record
.p
.r
.gr
= gr
;
1676 static unw_rec_list
*
1677 output_psp_sprel (unsigned int offset
)
1679 unw_rec_list
*ptr
= alloc_record (psp_sprel
);
1680 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1684 static unw_rec_list
*
1685 output_rp_when (void)
1687 unw_rec_list
*ptr
= alloc_record (rp_when
);
1691 static unw_rec_list
*
1692 output_rp_gr (unsigned int gr
)
1694 unw_rec_list
*ptr
= alloc_record (rp_gr
);
1695 ptr
->r
.record
.p
.r
.gr
= gr
;
1699 static unw_rec_list
*
1700 output_rp_br (unsigned int br
)
1702 unw_rec_list
*ptr
= alloc_record (rp_br
);
1703 ptr
->r
.record
.p
.r
.br
= br
;
1707 static unw_rec_list
*
1708 output_rp_psprel (unsigned int offset
)
1710 unw_rec_list
*ptr
= alloc_record (rp_psprel
);
1711 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1715 static unw_rec_list
*
1716 output_rp_sprel (unsigned int offset
)
1718 unw_rec_list
*ptr
= alloc_record (rp_sprel
);
1719 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1723 static unw_rec_list
*
1724 output_pfs_when (void)
1726 unw_rec_list
*ptr
= alloc_record (pfs_when
);
1730 static unw_rec_list
*
1731 output_pfs_gr (unsigned int gr
)
1733 unw_rec_list
*ptr
= alloc_record (pfs_gr
);
1734 ptr
->r
.record
.p
.r
.gr
= gr
;
1738 static unw_rec_list
*
1739 output_pfs_psprel (unsigned int offset
)
1741 unw_rec_list
*ptr
= alloc_record (pfs_psprel
);
1742 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1746 static unw_rec_list
*
1747 output_pfs_sprel (unsigned int offset
)
1749 unw_rec_list
*ptr
= alloc_record (pfs_sprel
);
1750 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1754 static unw_rec_list
*
1755 output_preds_when (void)
1757 unw_rec_list
*ptr
= alloc_record (preds_when
);
1761 static unw_rec_list
*
1762 output_preds_gr (unsigned int gr
)
1764 unw_rec_list
*ptr
= alloc_record (preds_gr
);
1765 ptr
->r
.record
.p
.r
.gr
= gr
;
1769 static unw_rec_list
*
1770 output_preds_psprel (unsigned int offset
)
1772 unw_rec_list
*ptr
= alloc_record (preds_psprel
);
1773 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1777 static unw_rec_list
*
1778 output_preds_sprel (unsigned int offset
)
1780 unw_rec_list
*ptr
= alloc_record (preds_sprel
);
1781 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1785 static unw_rec_list
*
1786 output_fr_mem (unsigned int mask
)
1788 unw_rec_list
*ptr
= alloc_record (fr_mem
);
1789 unw_rec_list
*cur
= ptr
;
1791 ptr
->r
.record
.p
.frmask
= mask
;
1792 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1795 unw_rec_list
*prev
= cur
;
1797 /* Clear least significant set bit. */
1798 mask
&= ~(mask
& (~mask
+ 1));
1801 cur
= alloc_record (fr_mem
);
1802 cur
->r
.record
.p
.frmask
= mask
;
1803 /* Retain only least significant bit. */
1804 prev
->r
.record
.p
.frmask
^= mask
;
1805 prev
->r
.record
.p
.next
= cur
;
1809 static unw_rec_list
*
1810 output_frgr_mem (unsigned int gr_mask
, unsigned int fr_mask
)
1812 unw_rec_list
*ptr
= alloc_record (frgr_mem
);
1813 unw_rec_list
*cur
= ptr
;
1815 unwind
.pending_saves
= &cur
->r
.record
.p
;
1816 cur
->r
.record
.p
.frmask
= fr_mask
;
1819 unw_rec_list
*prev
= cur
;
1821 /* Clear least significant set bit. */
1822 fr_mask
&= ~(fr_mask
& (~fr_mask
+ 1));
1823 if (!gr_mask
&& !fr_mask
)
1825 cur
= alloc_record (frgr_mem
);
1826 cur
->r
.record
.p
.frmask
= fr_mask
;
1827 /* Retain only least significant bit. */
1828 prev
->r
.record
.p
.frmask
^= fr_mask
;
1829 prev
->r
.record
.p
.next
= cur
;
1831 cur
->r
.record
.p
.grmask
= gr_mask
;
1834 unw_rec_list
*prev
= cur
;
1836 /* Clear least significant set bit. */
1837 gr_mask
&= ~(gr_mask
& (~gr_mask
+ 1));
1840 cur
= alloc_record (frgr_mem
);
1841 cur
->r
.record
.p
.grmask
= gr_mask
;
1842 /* Retain only least significant bit. */
1843 prev
->r
.record
.p
.grmask
^= gr_mask
;
1844 prev
->r
.record
.p
.next
= cur
;
1848 static unw_rec_list
*
1849 output_gr_gr (unsigned int mask
, unsigned int reg
)
1851 unw_rec_list
*ptr
= alloc_record (gr_gr
);
1852 unw_rec_list
*cur
= ptr
;
1854 ptr
->r
.record
.p
.grmask
= mask
;
1855 ptr
->r
.record
.p
.r
.gr
= reg
;
1856 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1859 unw_rec_list
*prev
= cur
;
1861 /* Clear least significant set bit. */
1862 mask
&= ~(mask
& (~mask
+ 1));
1865 cur
= alloc_record (gr_gr
);
1866 cur
->r
.record
.p
.grmask
= mask
;
1867 /* Indicate this record shouldn't be output. */
1868 cur
->r
.record
.p
.r
.gr
= REG_NUM
;
1869 /* Retain only least significant bit. */
1870 prev
->r
.record
.p
.grmask
^= mask
;
1871 prev
->r
.record
.p
.next
= cur
;
1875 static unw_rec_list
*
1876 output_gr_mem (unsigned int mask
)
1878 unw_rec_list
*ptr
= alloc_record (gr_mem
);
1879 unw_rec_list
*cur
= ptr
;
1881 ptr
->r
.record
.p
.grmask
= mask
;
1882 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1885 unw_rec_list
*prev
= cur
;
1887 /* Clear least significant set bit. */
1888 mask
&= ~(mask
& (~mask
+ 1));
1891 cur
= alloc_record (gr_mem
);
1892 cur
->r
.record
.p
.grmask
= mask
;
1893 /* Retain only least significant bit. */
1894 prev
->r
.record
.p
.grmask
^= mask
;
1895 prev
->r
.record
.p
.next
= cur
;
1899 static unw_rec_list
*
1900 output_br_mem (unsigned int mask
)
1902 unw_rec_list
*ptr
= alloc_record (br_mem
);
1903 unw_rec_list
*cur
= ptr
;
1905 ptr
->r
.record
.p
.brmask
= mask
;
1906 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1909 unw_rec_list
*prev
= cur
;
1911 /* Clear least significant set bit. */
1912 mask
&= ~(mask
& (~mask
+ 1));
1915 cur
= alloc_record (br_mem
);
1916 cur
->r
.record
.p
.brmask
= mask
;
1917 /* Retain only least significant bit. */
1918 prev
->r
.record
.p
.brmask
^= mask
;
1919 prev
->r
.record
.p
.next
= cur
;
1923 static unw_rec_list
*
1924 output_br_gr (unsigned int mask
, unsigned int reg
)
1926 unw_rec_list
*ptr
= alloc_record (br_gr
);
1927 unw_rec_list
*cur
= ptr
;
1929 ptr
->r
.record
.p
.brmask
= mask
;
1930 ptr
->r
.record
.p
.r
.gr
= reg
;
1931 unwind
.pending_saves
= &ptr
->r
.record
.p
;
1934 unw_rec_list
*prev
= cur
;
1936 /* Clear least significant set bit. */
1937 mask
&= ~(mask
& (~mask
+ 1));
1940 cur
= alloc_record (br_gr
);
1941 cur
->r
.record
.p
.brmask
= mask
;
1942 /* Indicate this record shouldn't be output. */
1943 cur
->r
.record
.p
.r
.gr
= REG_NUM
;
1944 /* Retain only least significant bit. */
1945 prev
->r
.record
.p
.brmask
^= mask
;
1946 prev
->r
.record
.p
.next
= cur
;
1950 static unw_rec_list
*
1951 output_spill_base (unsigned int offset
)
1953 unw_rec_list
*ptr
= alloc_record (spill_base
);
1954 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1958 static unw_rec_list
*
1959 output_unat_when (void)
1961 unw_rec_list
*ptr
= alloc_record (unat_when
);
1965 static unw_rec_list
*
1966 output_unat_gr (unsigned int gr
)
1968 unw_rec_list
*ptr
= alloc_record (unat_gr
);
1969 ptr
->r
.record
.p
.r
.gr
= gr
;
1973 static unw_rec_list
*
1974 output_unat_psprel (unsigned int offset
)
1976 unw_rec_list
*ptr
= alloc_record (unat_psprel
);
1977 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
1981 static unw_rec_list
*
1982 output_unat_sprel (unsigned int offset
)
1984 unw_rec_list
*ptr
= alloc_record (unat_sprel
);
1985 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
1989 static unw_rec_list
*
1990 output_lc_when (void)
1992 unw_rec_list
*ptr
= alloc_record (lc_when
);
1996 static unw_rec_list
*
1997 output_lc_gr (unsigned int gr
)
1999 unw_rec_list
*ptr
= alloc_record (lc_gr
);
2000 ptr
->r
.record
.p
.r
.gr
= gr
;
2004 static unw_rec_list
*
2005 output_lc_psprel (unsigned int offset
)
2007 unw_rec_list
*ptr
= alloc_record (lc_psprel
);
2008 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2012 static unw_rec_list
*
2013 output_lc_sprel (unsigned int offset
)
2015 unw_rec_list
*ptr
= alloc_record (lc_sprel
);
2016 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2020 static unw_rec_list
*
2021 output_fpsr_when (void)
2023 unw_rec_list
*ptr
= alloc_record (fpsr_when
);
2027 static unw_rec_list
*
2028 output_fpsr_gr (unsigned int gr
)
2030 unw_rec_list
*ptr
= alloc_record (fpsr_gr
);
2031 ptr
->r
.record
.p
.r
.gr
= gr
;
2035 static unw_rec_list
*
2036 output_fpsr_psprel (unsigned int offset
)
2038 unw_rec_list
*ptr
= alloc_record (fpsr_psprel
);
2039 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2043 static unw_rec_list
*
2044 output_fpsr_sprel (unsigned int offset
)
2046 unw_rec_list
*ptr
= alloc_record (fpsr_sprel
);
2047 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2051 static unw_rec_list
*
2052 output_priunat_when_gr (void)
2054 unw_rec_list
*ptr
= alloc_record (priunat_when_gr
);
2058 static unw_rec_list
*
2059 output_priunat_when_mem (void)
2061 unw_rec_list
*ptr
= alloc_record (priunat_when_mem
);
2065 static unw_rec_list
*
2066 output_priunat_gr (unsigned int gr
)
2068 unw_rec_list
*ptr
= alloc_record (priunat_gr
);
2069 ptr
->r
.record
.p
.r
.gr
= gr
;
2073 static unw_rec_list
*
2074 output_priunat_psprel (unsigned int offset
)
2076 unw_rec_list
*ptr
= alloc_record (priunat_psprel
);
2077 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2081 static unw_rec_list
*
2082 output_priunat_sprel (unsigned int offset
)
2084 unw_rec_list
*ptr
= alloc_record (priunat_sprel
);
2085 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2089 static unw_rec_list
*
2090 output_bsp_when (void)
2092 unw_rec_list
*ptr
= alloc_record (bsp_when
);
2096 static unw_rec_list
*
2097 output_bsp_gr (unsigned int gr
)
2099 unw_rec_list
*ptr
= alloc_record (bsp_gr
);
2100 ptr
->r
.record
.p
.r
.gr
= gr
;
2104 static unw_rec_list
*
2105 output_bsp_psprel (unsigned int offset
)
2107 unw_rec_list
*ptr
= alloc_record (bsp_psprel
);
2108 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2112 static unw_rec_list
*
2113 output_bsp_sprel (unsigned int offset
)
2115 unw_rec_list
*ptr
= alloc_record (bsp_sprel
);
2116 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2120 static unw_rec_list
*
2121 output_bspstore_when (void)
2123 unw_rec_list
*ptr
= alloc_record (bspstore_when
);
2127 static unw_rec_list
*
2128 output_bspstore_gr (unsigned int gr
)
2130 unw_rec_list
*ptr
= alloc_record (bspstore_gr
);
2131 ptr
->r
.record
.p
.r
.gr
= gr
;
2135 static unw_rec_list
*
2136 output_bspstore_psprel (unsigned int offset
)
2138 unw_rec_list
*ptr
= alloc_record (bspstore_psprel
);
2139 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2143 static unw_rec_list
*
2144 output_bspstore_sprel (unsigned int offset
)
2146 unw_rec_list
*ptr
= alloc_record (bspstore_sprel
);
2147 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2151 static unw_rec_list
*
2152 output_rnat_when (void)
2154 unw_rec_list
*ptr
= alloc_record (rnat_when
);
2158 static unw_rec_list
*
2159 output_rnat_gr (unsigned int gr
)
2161 unw_rec_list
*ptr
= alloc_record (rnat_gr
);
2162 ptr
->r
.record
.p
.r
.gr
= gr
;
2166 static unw_rec_list
*
2167 output_rnat_psprel (unsigned int offset
)
2169 unw_rec_list
*ptr
= alloc_record (rnat_psprel
);
2170 ptr
->r
.record
.p
.off
.psp
= ENCODED_PSP_OFFSET (offset
);
2174 static unw_rec_list
*
2175 output_rnat_sprel (unsigned int offset
)
2177 unw_rec_list
*ptr
= alloc_record (rnat_sprel
);
2178 ptr
->r
.record
.p
.off
.sp
= offset
/ 4;
2182 static unw_rec_list
*
2183 output_unwabi (unsigned long abi
, unsigned long context
)
2185 unw_rec_list
*ptr
= alloc_record (unwabi
);
2186 ptr
->r
.record
.p
.abi
= abi
;
2187 ptr
->r
.record
.p
.context
= context
;
2191 static unw_rec_list
*
2192 output_epilogue (unsigned long ecount
)
2194 unw_rec_list
*ptr
= alloc_record (epilogue
);
2195 ptr
->r
.record
.b
.ecount
= ecount
;
2199 static unw_rec_list
*
2200 output_label_state (unsigned long label
)
2202 unw_rec_list
*ptr
= alloc_record (label_state
);
2203 ptr
->r
.record
.b
.label
= label
;
2207 static unw_rec_list
*
2208 output_copy_state (unsigned long label
)
2210 unw_rec_list
*ptr
= alloc_record (copy_state
);
2211 ptr
->r
.record
.b
.label
= label
;
2215 static unw_rec_list
*
2216 output_spill_psprel (unsigned int ab
,
2218 unsigned int offset
,
2219 unsigned int predicate
)
2221 unw_rec_list
*ptr
= alloc_record (predicate
? spill_psprel_p
: spill_psprel
);
2222 ptr
->r
.record
.x
.ab
= ab
;
2223 ptr
->r
.record
.x
.reg
= reg
;
2224 ptr
->r
.record
.x
.where
.pspoff
= ENCODED_PSP_OFFSET (offset
);
2225 ptr
->r
.record
.x
.qp
= predicate
;
2229 static unw_rec_list
*
2230 output_spill_sprel (unsigned int ab
,
2232 unsigned int offset
,
2233 unsigned int predicate
)
2235 unw_rec_list
*ptr
= alloc_record (predicate
? spill_sprel_p
: spill_sprel
);
2236 ptr
->r
.record
.x
.ab
= ab
;
2237 ptr
->r
.record
.x
.reg
= reg
;
2238 ptr
->r
.record
.x
.where
.spoff
= offset
/ 4;
2239 ptr
->r
.record
.x
.qp
= predicate
;
2243 static unw_rec_list
*
2244 output_spill_reg (unsigned int ab
,
2246 unsigned int targ_reg
,
2248 unsigned int predicate
)
2250 unw_rec_list
*ptr
= alloc_record (predicate
? spill_reg_p
: spill_reg
);
2251 ptr
->r
.record
.x
.ab
= ab
;
2252 ptr
->r
.record
.x
.reg
= reg
;
2253 ptr
->r
.record
.x
.where
.reg
= targ_reg
;
2254 ptr
->r
.record
.x
.xy
= xy
;
2255 ptr
->r
.record
.x
.qp
= predicate
;
2259 /* Given a unw_rec_list process the correct format with the
2260 specified function. */
2263 process_one_record (unw_rec_list
*ptr
, vbyte_func f
)
2265 unsigned int fr_mask
, gr_mask
;
2267 switch (ptr
->r
.type
)
2269 /* This is a dummy record that takes up no space in the output. */
2277 /* These are taken care of by prologue/prologue_gr. */
2282 if (ptr
->r
.type
== prologue_gr
)
2283 output_R2_format (f
, ptr
->r
.record
.r
.grmask
,
2284 ptr
->r
.record
.r
.grsave
, ptr
->r
.record
.r
.rlen
);
2286 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2288 /* Output descriptor(s) for union of register spills (if any). */
2289 gr_mask
= ptr
->r
.record
.r
.mask
.gr_mem
;
2290 fr_mask
= ptr
->r
.record
.r
.mask
.fr_mem
;
2293 if ((fr_mask
& ~0xfUL
) == 0)
2294 output_P6_format (f
, fr_mem
, fr_mask
);
2297 output_P5_format (f
, gr_mask
, fr_mask
);
2302 output_P6_format (f
, gr_mem
, gr_mask
);
2303 if (ptr
->r
.record
.r
.mask
.br_mem
)
2304 output_P1_format (f
, ptr
->r
.record
.r
.mask
.br_mem
);
2306 /* output imask descriptor if necessary: */
2307 if (ptr
->r
.record
.r
.mask
.i
)
2308 output_P4_format (f
, ptr
->r
.record
.r
.mask
.i
,
2309 ptr
->r
.record
.r
.imask_size
);
2313 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2317 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
,
2318 ptr
->r
.record
.p
.size
);
2331 output_P3_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.r
.gr
);
2334 output_P3_format (f
, rp_br
, ptr
->r
.record
.p
.r
.br
);
2337 output_P7_format (f
, psp_sprel
, ptr
->r
.record
.p
.off
.sp
, 0);
2345 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
, 0);
2354 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.off
.psp
, 0);
2364 case bspstore_sprel
:
2366 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.off
.sp
);
2369 if (ptr
->r
.record
.p
.r
.gr
< REG_NUM
)
2371 const unw_rec_list
*cur
= ptr
;
2373 gr_mask
= cur
->r
.record
.p
.grmask
;
2374 while ((cur
= cur
->r
.record
.p
.next
) != NULL
)
2375 gr_mask
|= cur
->r
.record
.p
.grmask
;
2376 output_P9_format (f
, gr_mask
, ptr
->r
.record
.p
.r
.gr
);
2380 if (ptr
->r
.record
.p
.r
.gr
< REG_NUM
)
2382 const unw_rec_list
*cur
= ptr
;
2384 gr_mask
= cur
->r
.record
.p
.brmask
;
2385 while ((cur
= cur
->r
.record
.p
.next
) != NULL
)
2386 gr_mask
|= cur
->r
.record
.p
.brmask
;
2387 output_P2_format (f
, gr_mask
, ptr
->r
.record
.p
.r
.gr
);
2391 as_bad (_("spill_mask record unimplemented."));
2393 case priunat_when_gr
:
2394 case priunat_when_mem
:
2398 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
);
2400 case priunat_psprel
:
2402 case bspstore_psprel
:
2404 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.off
.psp
);
2407 output_P10_format (f
, ptr
->r
.record
.p
.abi
, ptr
->r
.record
.p
.context
);
2410 output_B3_format (f
, ptr
->r
.record
.b
.ecount
, ptr
->r
.record
.b
.t
);
2414 output_B4_format (f
, ptr
->r
.type
, ptr
->r
.record
.b
.label
);
2417 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2418 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2419 ptr
->r
.record
.x
.where
.pspoff
);
2422 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2423 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2424 ptr
->r
.record
.x
.where
.spoff
);
2427 output_X2_format (f
, ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2428 ptr
->r
.record
.x
.xy
>> 1, ptr
->r
.record
.x
.xy
,
2429 ptr
->r
.record
.x
.where
.reg
, ptr
->r
.record
.x
.t
);
2431 case spill_psprel_p
:
2432 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2433 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2434 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.where
.pspoff
);
2437 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2438 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2439 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.where
.spoff
);
2442 output_X4_format (f
, ptr
->r
.record
.x
.qp
, ptr
->r
.record
.x
.ab
,
2443 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.xy
>> 1,
2444 ptr
->r
.record
.x
.xy
, ptr
->r
.record
.x
.where
.reg
,
2448 as_bad (_("record_type_not_valid"));
2453 /* Given a unw_rec_list list, process all the records with
2454 the specified function. */
2456 process_unw_records (unw_rec_list
*list
, vbyte_func f
)
2459 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2460 process_one_record (ptr
, f
);
2463 /* Determine the size of a record list in bytes. */
2465 calc_record_size (unw_rec_list
*list
)
2468 process_unw_records (list
, count_output
);
2472 /* Return the number of bits set in the input value.
2473 Perhaps this has a better place... */
2474 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
2475 # define popcount __builtin_popcount
2478 popcount (unsigned x
)
2480 static const unsigned char popcnt
[16] =
2488 if (x
< NELEMS (popcnt
))
2490 return popcnt
[x
% NELEMS (popcnt
)] + popcount (x
/ NELEMS (popcnt
));
2494 /* Update IMASK bitmask to reflect the fact that one or more registers
2495 of type TYPE are saved starting at instruction with index T. If N
2496 bits are set in REGMASK, it is assumed that instructions T through
2497 T+N-1 save these registers.
2501 1: instruction saves next fp reg
2502 2: instruction saves next general reg
2503 3: instruction saves next branch reg */
2505 set_imask (unw_rec_list
*region
,
2506 unsigned long regmask
,
2510 unsigned char *imask
;
2511 unsigned long imask_size
;
2515 imask
= region
->r
.record
.r
.mask
.i
;
2516 imask_size
= region
->r
.record
.r
.imask_size
;
2519 imask_size
= (region
->r
.record
.r
.rlen
* 2 + 7) / 8 + 1;
2520 imask
= xmalloc (imask_size
);
2521 memset (imask
, 0, imask_size
);
2523 region
->r
.record
.r
.imask_size
= imask_size
;
2524 region
->r
.record
.r
.mask
.i
= imask
;
2528 pos
= 2 * (3 - t
% 4);
2531 if (i
>= imask_size
)
2533 as_bad (_("Ignoring attempt to spill beyond end of region"));
2537 imask
[i
] |= (type
& 0x3) << pos
;
2539 regmask
&= (regmask
- 1);
2549 /* Return the number of instruction slots from FIRST_ADDR to SLOT_ADDR.
2550 SLOT_FRAG is the frag containing SLOT_ADDR, and FIRST_FRAG is the frag
2551 containing FIRST_ADDR. If BEFORE_RELAX, then we use worst-case estimates
2554 static unsigned long
2555 slot_index (unsigned long slot_addr
,
2557 unsigned long first_addr
,
2561 unsigned long s_index
= 0;
2563 /* First time we are called, the initial address and frag are invalid. */
2564 if (first_addr
== 0)
2567 /* If the two addresses are in different frags, then we need to add in
2568 the remaining size of this frag, and then the entire size of intermediate
2570 while (slot_frag
!= first_frag
)
2572 unsigned long start_addr
= (unsigned long) &first_frag
->fr_literal
;
2576 /* We can get the final addresses only during and after
2578 if (first_frag
->fr_next
&& first_frag
->fr_next
->fr_address
)
2579 s_index
+= 3 * ((first_frag
->fr_next
->fr_address
2580 - first_frag
->fr_address
2581 - first_frag
->fr_fix
) >> 4);
2584 /* We don't know what the final addresses will be. We try our
2585 best to estimate. */
2586 switch (first_frag
->fr_type
)
2592 as_fatal (_("Only constant space allocation is supported"));
2598 /* Take alignment into account. Assume the worst case
2599 before relaxation. */
2600 s_index
+= 3 * ((1 << first_frag
->fr_offset
) >> 4);
2604 if (first_frag
->fr_symbol
)
2606 as_fatal (_("Only constant offsets are supported"));
2610 s_index
+= 3 * (first_frag
->fr_offset
>> 4);
2614 /* Add in the full size of the frag converted to instruction slots. */
2615 s_index
+= 3 * (first_frag
->fr_fix
>> 4);
2616 /* Subtract away the initial part before first_addr. */
2617 s_index
-= (3 * ((first_addr
>> 4) - (start_addr
>> 4))
2618 + ((first_addr
& 0x3) - (start_addr
& 0x3)));
2620 /* Move to the beginning of the next frag. */
2621 first_frag
= first_frag
->fr_next
;
2622 first_addr
= (unsigned long) &first_frag
->fr_literal
;
2624 /* This can happen if there is section switching in the middle of a
2625 function, causing the frag chain for the function to be broken.
2626 It is too difficult to recover safely from this problem, so we just
2627 exit with an error. */
2628 if (first_frag
== NULL
)
2629 as_fatal (_("Section switching in code is not supported."));
2632 /* Add in the used part of the last frag. */
2633 s_index
+= (3 * ((slot_addr
>> 4) - (first_addr
>> 4))
2634 + ((slot_addr
& 0x3) - (first_addr
& 0x3)));
2638 /* Optimize unwind record directives. */
2640 static unw_rec_list
*
2641 optimize_unw_records (unw_rec_list
*list
)
2646 /* If the only unwind record is ".prologue" or ".prologue" followed
2647 by ".body", then we can optimize the unwind directives away. */
2648 if (list
->r
.type
== prologue
2649 && (list
->next
->r
.type
== endp
2650 || (list
->next
->r
.type
== body
&& list
->next
->next
->r
.type
== endp
)))
2656 /* Given a complete record list, process any records which have
2657 unresolved fields, (ie length counts for a prologue). After
2658 this has been run, all necessary information should be available
2659 within each record to generate an image. */
2662 fixup_unw_records (unw_rec_list
*list
, int before_relax
)
2664 unw_rec_list
*ptr
, *region
= 0;
2665 unsigned long first_addr
= 0, rlen
= 0, t
;
2666 fragS
*first_frag
= 0;
2668 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2670 if (ptr
->slot_number
== SLOT_NUM_NOT_SET
)
2671 as_bad (_(" Insn slot not set in unwind record."));
2672 t
= slot_index (ptr
->slot_number
, ptr
->slot_frag
,
2673 first_addr
, first_frag
, before_relax
);
2674 switch (ptr
->r
.type
)
2682 unsigned long last_addr
= 0;
2683 fragS
*last_frag
= NULL
;
2685 first_addr
= ptr
->slot_number
;
2686 first_frag
= ptr
->slot_frag
;
2687 /* Find either the next body/prologue start, or the end of
2688 the function, and determine the size of the region. */
2689 for (last
= ptr
->next
; last
!= NULL
; last
= last
->next
)
2690 if (last
->r
.type
== prologue
|| last
->r
.type
== prologue_gr
2691 || last
->r
.type
== body
|| last
->r
.type
== endp
)
2693 last_addr
= last
->slot_number
;
2694 last_frag
= last
->slot_frag
;
2697 size
= slot_index (last_addr
, last_frag
, first_addr
, first_frag
,
2699 rlen
= ptr
->r
.record
.r
.rlen
= size
;
2700 if (ptr
->r
.type
== body
)
2701 /* End of region. */
2709 ptr
->r
.record
.b
.t
= rlen
- 1 - t
;
2711 /* This happens when a memory-stack-less procedure uses a
2712 ".restore sp" directive at the end of a region to pop
2714 ptr
->r
.record
.b
.t
= 0;
2725 case priunat_when_gr
:
2726 case priunat_when_mem
:
2730 ptr
->r
.record
.p
.t
= t
;
2738 case spill_psprel_p
:
2739 ptr
->r
.record
.x
.t
= t
;
2745 as_bad (_("frgr_mem record before region record!"));
2748 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.frmask
;
2749 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.grmask
;
2750 set_imask (region
, ptr
->r
.record
.p
.frmask
, t
, 1);
2751 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2756 as_bad (_("fr_mem record before region record!"));
2759 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.frmask
;
2760 set_imask (region
, ptr
->r
.record
.p
.frmask
, t
, 1);
2765 as_bad (_("gr_mem record before region record!"));
2768 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.grmask
;
2769 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2774 as_bad (_("br_mem record before region record!"));
2777 region
->r
.record
.r
.mask
.br_mem
|= ptr
->r
.record
.p
.brmask
;
2778 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2784 as_bad (_("gr_gr record before region record!"));
2787 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2792 as_bad (_("br_gr record before region record!"));
2795 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2804 /* Estimate the size of a frag before relaxing. We only have one type of frag
2805 to handle here, which is the unwind info frag. */
2808 ia64_estimate_size_before_relax (fragS
*frag
,
2809 asection
*segtype ATTRIBUTE_UNUSED
)
2814 /* ??? This code is identical to the first part of ia64_convert_frag. */
2815 list
= (unw_rec_list
*) frag
->fr_opcode
;
2816 fixup_unw_records (list
, 0);
2818 len
= calc_record_size (list
);
2819 /* pad to pointer-size boundary. */
2820 pad
= len
% md
.pointer_size
;
2822 len
+= md
.pointer_size
- pad
;
2823 /* Add 8 for the header. */
2825 /* Add a pointer for the personality offset. */
2826 if (frag
->fr_offset
)
2827 size
+= md
.pointer_size
;
2829 /* fr_var carries the max_chars that we created the fragment with.
2830 We must, of course, have allocated enough memory earlier. */
2831 gas_assert (frag
->fr_var
>= size
);
2833 return frag
->fr_fix
+ size
;
2836 /* This function converts a rs_machine_dependent variant frag into a
2837 normal fill frag with the unwind image from the the record list. */
2839 ia64_convert_frag (fragS
*frag
)
2845 /* ??? This code is identical to ia64_estimate_size_before_relax. */
2846 list
= (unw_rec_list
*) frag
->fr_opcode
;
2847 fixup_unw_records (list
, 0);
2849 len
= calc_record_size (list
);
2850 /* pad to pointer-size boundary. */
2851 pad
= len
% md
.pointer_size
;
2853 len
+= md
.pointer_size
- pad
;
2854 /* Add 8 for the header. */
2856 /* Add a pointer for the personality offset. */
2857 if (frag
->fr_offset
)
2858 size
+= md
.pointer_size
;
2860 /* fr_var carries the max_chars that we created the fragment with.
2861 We must, of course, have allocated enough memory earlier. */
2862 gas_assert (frag
->fr_var
>= size
);
2864 /* Initialize the header area. fr_offset is initialized with
2865 unwind.personality_routine. */
2866 if (frag
->fr_offset
)
2868 if (md
.flags
& EF_IA_64_ABI64
)
2869 flag_value
= (bfd_vma
) 3 << 32;
2871 /* 32-bit unwind info block. */
2872 flag_value
= (bfd_vma
) 0x1003 << 32;
2877 md_number_to_chars (frag
->fr_literal
,
2878 (((bfd_vma
) 1 << 48) /* Version. */
2879 | flag_value
/* U & E handler flags. */
2880 | (len
/ md
.pointer_size
)), /* Length. */
2883 /* Skip the header. */
2884 vbyte_mem_ptr
= frag
->fr_literal
+ 8;
2885 process_unw_records (list
, output_vbyte_mem
);
2887 /* Fill the padding bytes with zeros. */
2889 md_number_to_chars (frag
->fr_literal
+ len
+ 8 - md
.pointer_size
+ pad
, 0,
2890 md
.pointer_size
- pad
);
2891 /* Fill the unwind personality with zeros. */
2892 if (frag
->fr_offset
)
2893 md_number_to_chars (frag
->fr_literal
+ size
- md
.pointer_size
, 0,
2896 frag
->fr_fix
+= size
;
2897 frag
->fr_type
= rs_fill
;
2899 frag
->fr_offset
= 0;
2903 parse_predicate_and_operand (expressionS
*e
, unsigned *qp
, const char *po
)
2905 int sep
= parse_operand_and_eval (e
, ',');
2907 *qp
= e
->X_add_number
- REG_P
;
2908 if (e
->X_op
!= O_register
|| *qp
> 63)
2910 as_bad (_("First operand to .%s must be a predicate"), po
);
2914 as_warn (_("Pointless use of p0 as first operand to .%s"), po
);
2916 sep
= parse_operand_and_eval (e
, ',');
2923 convert_expr_to_ab_reg (const expressionS
*e
,
2929 unsigned int reg
= e
->X_add_number
;
2931 *ab
= *regp
= 0; /* Anything valid is good here. */
2933 if (e
->X_op
!= O_register
)
2934 reg
= REG_GR
; /* Anything invalid is good here. */
2936 if (reg
>= (REG_GR
+ 4) && reg
<= (REG_GR
+ 7))
2939 *regp
= reg
- REG_GR
;
2941 else if ((reg
>= (REG_FR
+ 2) && reg
<= (REG_FR
+ 5))
2942 || (reg
>= (REG_FR
+ 16) && reg
<= (REG_FR
+ 31)))
2945 *regp
= reg
- REG_FR
;
2947 else if (reg
>= (REG_BR
+ 1) && reg
<= (REG_BR
+ 5))
2950 *regp
= reg
- REG_BR
;
2957 case REG_PR
: *regp
= 0; break;
2958 case REG_PSP
: *regp
= 1; break;
2959 case REG_PRIUNAT
: *regp
= 2; break;
2960 case REG_BR
+ 0: *regp
= 3; break;
2961 case REG_AR
+ AR_BSP
: *regp
= 4; break;
2962 case REG_AR
+ AR_BSPSTORE
: *regp
= 5; break;
2963 case REG_AR
+ AR_RNAT
: *regp
= 6; break;
2964 case REG_AR
+ AR_UNAT
: *regp
= 7; break;
2965 case REG_AR
+ AR_FPSR
: *regp
= 8; break;
2966 case REG_AR
+ AR_PFS
: *regp
= 9; break;
2967 case REG_AR
+ AR_LC
: *regp
= 10; break;
2970 as_bad (_("Operand %d to .%s must be a preserved register"), n
, po
);
2977 convert_expr_to_xy_reg (const expressionS
*e
,
2983 unsigned int reg
= e
->X_add_number
;
2985 *xy
= *regp
= 0; /* Anything valid is good here. */
2987 if (e
->X_op
!= O_register
)
2988 reg
= REG_GR
; /* Anything invalid is good here. */
2990 if (reg
>= (REG_GR
+ 1) && reg
<= (REG_GR
+ 127))
2993 *regp
= reg
- REG_GR
;
2995 else if (reg
>= (REG_FR
+ 2) && reg
<= (REG_FR
+ 127))
2998 *regp
= reg
- REG_FR
;
3000 else if (reg
>= REG_BR
&& reg
<= (REG_BR
+ 7))
3003 *regp
= reg
- REG_BR
;
3006 as_bad (_("Operand %d to .%s must be a writable register"), n
, po
);
3012 /* The current frag is an alignment frag. */
3013 align_frag
= frag_now
;
3014 s_align_bytes (arg
);
3018 dot_radix (int dummy ATTRIBUTE_UNUSED
)
3025 if (is_it_end_of_statement ())
3027 radix
= input_line_pointer
;
3028 ch
= get_symbol_end ();
3029 ia64_canonicalize_symbol_name (radix
);
3030 if (strcasecmp (radix
, "C"))
3031 as_bad (_("Radix `%s' unsupported or invalid"), radix
);
3032 *input_line_pointer
= ch
;
3033 demand_empty_rest_of_line ();
3036 /* Helper function for .loc directives. If the assembler is not generating
3037 line number info, then we need to remember which instructions have a .loc
3038 directive, and only call dwarf2_gen_line_info for those instructions. */
3043 CURR_SLOT
.loc_directive_seen
= 1;
3044 dwarf2_directive_loc (x
);
3047 /* .sbss, .bss etc. are macros that expand into ".section SECNAME". */
3049 dot_special_section (int which
)
3051 set_section ((char *) special_section_name
[which
]);
3054 /* Return -1 for warning and 0 for error. */
3057 unwind_diagnostic (const char * region
, const char *directive
)
3059 if (md
.unwind_check
== unwind_check_warning
)
3061 as_warn (_(".%s outside of %s"), directive
, region
);
3066 as_bad (_(".%s outside of %s"), directive
, region
);
3067 ignore_rest_of_line ();
3072 /* Return 1 if a directive is in a procedure, -1 if a directive isn't in
3073 a procedure but the unwind directive check is set to warning, 0 if
3074 a directive isn't in a procedure and the unwind directive check is set
3078 in_procedure (const char *directive
)
3080 if (unwind
.proc_pending
.sym
3081 && (!unwind
.saved_text_seg
|| strcmp (directive
, "endp") == 0))
3083 return unwind_diagnostic ("procedure", directive
);
3086 /* Return 1 if a directive is in a prologue, -1 if a directive isn't in
3087 a prologue but the unwind directive check is set to warning, 0 if
3088 a directive isn't in a prologue and the unwind directive check is set
3092 in_prologue (const char *directive
)
3094 int in
= in_procedure (directive
);
3096 if (in
> 0 && !unwind
.prologue
)
3097 in
= unwind_diagnostic ("prologue", directive
);
3098 check_pending_save ();
3102 /* Return 1 if a directive is in a body, -1 if a directive isn't in
3103 a body but the unwind directive check is set to warning, 0 if
3104 a directive isn't in a body and the unwind directive check is set
3108 in_body (const char *directive
)
3110 int in
= in_procedure (directive
);
3112 if (in
> 0 && !unwind
.body
)
3113 in
= unwind_diagnostic ("body region", directive
);
3118 add_unwind_entry (unw_rec_list
*ptr
, int sep
)
3123 unwind
.tail
->next
= ptr
;
3128 /* The current entry can in fact be a chain of unwind entries. */
3129 if (unwind
.current_entry
== NULL
)
3130 unwind
.current_entry
= ptr
;
3133 /* The current entry can in fact be a chain of unwind entries. */
3134 if (unwind
.current_entry
== NULL
)
3135 unwind
.current_entry
= ptr
;
3139 /* Parse a tag permitted for the current directive. */
3143 ch
= get_symbol_end ();
3144 /* FIXME: For now, just issue a warning that this isn't implemented. */
3151 as_warn (_("Tags on unwind pseudo-ops aren't supported, yet"));
3154 *input_line_pointer
= ch
;
3156 if (sep
!= NOT_A_CHAR
)
3157 demand_empty_rest_of_line ();
3161 dot_fframe (int dummy ATTRIBUTE_UNUSED
)
3166 if (!in_prologue ("fframe"))
3169 sep
= parse_operand_and_eval (&e
, ',');
3171 if (e
.X_op
!= O_constant
)
3173 as_bad (_("First operand to .fframe must be a constant"));
3176 add_unwind_entry (output_mem_stack_f (e
.X_add_number
), sep
);
3180 dot_vframe (int dummy ATTRIBUTE_UNUSED
)
3186 if (!in_prologue ("vframe"))
3189 sep
= parse_operand_and_eval (&e
, ',');
3190 reg
= e
.X_add_number
- REG_GR
;
3191 if (e
.X_op
!= O_register
|| reg
> 127)
3193 as_bad (_("First operand to .vframe must be a general register"));
3196 add_unwind_entry (output_mem_stack_v (), sep
);
3197 if (! (unwind
.prologue_mask
& 2))
3198 add_unwind_entry (output_psp_gr (reg
), NOT_A_CHAR
);
3199 else if (reg
!= unwind
.prologue_gr
3200 + (unsigned) popcount (unwind
.prologue_mask
& (-2 << 1)))
3201 as_warn (_("Operand of .vframe contradicts .prologue"));
3205 dot_vframesp (int psp
)
3211 as_warn (_(".vframepsp is meaningless, assuming .vframesp was meant"));
3213 if (!in_prologue ("vframesp"))
3216 sep
= parse_operand_and_eval (&e
, ',');
3217 if (e
.X_op
!= O_constant
)
3219 as_bad (_("Operand to .vframesp must be a constant (sp-relative offset)"));
3222 add_unwind_entry (output_mem_stack_v (), sep
);
3223 add_unwind_entry (output_psp_sprel (e
.X_add_number
), NOT_A_CHAR
);
3227 dot_save (int dummy ATTRIBUTE_UNUSED
)
3230 unsigned reg1
, reg2
;
3233 if (!in_prologue ("save"))
3236 sep
= parse_operand_and_eval (&e1
, ',');
3238 sep
= parse_operand_and_eval (&e2
, ',');
3242 reg1
= e1
.X_add_number
;
3243 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3244 if (e1
.X_op
!= O_register
)
3246 as_bad (_("First operand to .save not a register"));
3247 reg1
= REG_PR
; /* Anything valid is good here. */
3249 reg2
= e2
.X_add_number
- REG_GR
;
3250 if (e2
.X_op
!= O_register
|| reg2
> 127)
3252 as_bad (_("Second operand to .save not a valid register"));
3257 case REG_AR
+ AR_BSP
:
3258 add_unwind_entry (output_bsp_when (), sep
);
3259 add_unwind_entry (output_bsp_gr (reg2
), NOT_A_CHAR
);
3261 case REG_AR
+ AR_BSPSTORE
:
3262 add_unwind_entry (output_bspstore_when (), sep
);
3263 add_unwind_entry (output_bspstore_gr (reg2
), NOT_A_CHAR
);
3265 case REG_AR
+ AR_RNAT
:
3266 add_unwind_entry (output_rnat_when (), sep
);
3267 add_unwind_entry (output_rnat_gr (reg2
), NOT_A_CHAR
);
3269 case REG_AR
+ AR_UNAT
:
3270 add_unwind_entry (output_unat_when (), sep
);
3271 add_unwind_entry (output_unat_gr (reg2
), NOT_A_CHAR
);
3273 case REG_AR
+ AR_FPSR
:
3274 add_unwind_entry (output_fpsr_when (), sep
);
3275 add_unwind_entry (output_fpsr_gr (reg2
), NOT_A_CHAR
);
3277 case REG_AR
+ AR_PFS
:
3278 add_unwind_entry (output_pfs_when (), sep
);
3279 if (! (unwind
.prologue_mask
& 4))
3280 add_unwind_entry (output_pfs_gr (reg2
), NOT_A_CHAR
);
3281 else if (reg2
!= unwind
.prologue_gr
3282 + (unsigned) popcount (unwind
.prologue_mask
& (-4 << 1)))
3283 as_warn (_("Second operand of .save contradicts .prologue"));
3285 case REG_AR
+ AR_LC
:
3286 add_unwind_entry (output_lc_when (), sep
);
3287 add_unwind_entry (output_lc_gr (reg2
), NOT_A_CHAR
);
3290 add_unwind_entry (output_rp_when (), sep
);
3291 if (! (unwind
.prologue_mask
& 8))
3292 add_unwind_entry (output_rp_gr (reg2
), NOT_A_CHAR
);
3293 else if (reg2
!= unwind
.prologue_gr
)
3294 as_warn (_("Second operand of .save contradicts .prologue"));
3297 add_unwind_entry (output_preds_when (), sep
);
3298 if (! (unwind
.prologue_mask
& 1))
3299 add_unwind_entry (output_preds_gr (reg2
), NOT_A_CHAR
);
3300 else if (reg2
!= unwind
.prologue_gr
3301 + (unsigned) popcount (unwind
.prologue_mask
& (-1 << 1)))
3302 as_warn (_("Second operand of .save contradicts .prologue"));
3305 add_unwind_entry (output_priunat_when_gr (), sep
);
3306 add_unwind_entry (output_priunat_gr (reg2
), NOT_A_CHAR
);
3309 as_bad (_("First operand to .save not a valid register"));
3310 add_unwind_entry (NULL
, sep
);
3316 dot_restore (int dummy ATTRIBUTE_UNUSED
)
3319 unsigned long ecount
; /* # of _additional_ regions to pop */
3322 if (!in_body ("restore"))
3325 sep
= parse_operand_and_eval (&e1
, ',');
3326 if (e1
.X_op
!= O_register
|| e1
.X_add_number
!= REG_GR
+ 12)
3327 as_bad (_("First operand to .restore must be stack pointer (sp)"));
3333 sep
= parse_operand_and_eval (&e2
, ',');
3334 if (e2
.X_op
!= O_constant
|| e2
.X_add_number
< 0)
3336 as_bad (_("Second operand to .restore must be a constant >= 0"));
3337 e2
.X_add_number
= 0;
3339 ecount
= e2
.X_add_number
;
3342 ecount
= unwind
.prologue_count
- 1;
3344 if (ecount
>= unwind
.prologue_count
)
3346 as_bad (_("Epilogue count of %lu exceeds number of nested prologues (%u)"),
3347 ecount
+ 1, unwind
.prologue_count
);
3351 add_unwind_entry (output_epilogue (ecount
), sep
);
3353 if (ecount
< unwind
.prologue_count
)
3354 unwind
.prologue_count
-= ecount
+ 1;
3356 unwind
.prologue_count
= 0;
3360 dot_restorereg (int pred
)
3362 unsigned int qp
, ab
, reg
;
3365 const char * const po
= pred
? "restorereg.p" : "restorereg";
3367 if (!in_procedure (po
))
3371 sep
= parse_predicate_and_operand (&e
, &qp
, po
);
3374 sep
= parse_operand_and_eval (&e
, ',');
3377 convert_expr_to_ab_reg (&e
, &ab
, ®
, po
, 1 + pred
);
3379 add_unwind_entry (output_spill_reg (ab
, reg
, 0, 0, qp
), sep
);
3382 static char *special_linkonce_name
[] =
3384 ".gnu.linkonce.ia64unw.", ".gnu.linkonce.ia64unwi."
3388 start_unwind_section (const segT text_seg
, int sec_index
)
3391 Use a slightly ugly scheme to derive the unwind section names from
3392 the text section name:
3394 text sect. unwind table sect.
3395 name: name: comments:
3396 ---------- ----------------- --------------------------------
3398 .text.foo .IA_64.unwind.text.foo
3399 .foo .IA_64.unwind.foo
3401 .gnu.linkonce.ia64unw.foo
3402 _info .IA_64.unwind_info gas issues error message (ditto)
3403 _infoFOO .IA_64.unwind_infoFOO gas issues error message (ditto)
3405 This mapping is done so that:
3407 (a) An object file with unwind info only in .text will use
3408 unwind section names .IA_64.unwind and .IA_64.unwind_info.
3409 This follows the letter of the ABI and also ensures backwards
3410 compatibility with older toolchains.
3412 (b) An object file with unwind info in multiple text sections
3413 will use separate unwind sections for each text section.
3414 This allows us to properly set the "sh_info" and "sh_link"
3415 fields in SHT_IA_64_UNWIND as required by the ABI and also
3416 lets GNU ld support programs with multiple segments
3417 containing unwind info (as might be the case for certain
3418 embedded applications).
3420 (c) An error is issued if there would be a name clash.
3423 const char *text_name
, *sec_text_name
;
3425 const char *prefix
= special_section_name
[sec_index
];
3427 size_t prefix_len
, suffix_len
, sec_name_len
;
3429 sec_text_name
= segment_name (text_seg
);
3430 text_name
= sec_text_name
;
3431 if (strncmp (text_name
, "_info", 5) == 0)
3433 as_bad (_("Illegal section name `%s' (causes unwind section name clash)"),
3435 ignore_rest_of_line ();
3438 if (strcmp (text_name
, ".text") == 0)
3441 /* Build the unwind section name by appending the (possibly stripped)
3442 text section name to the unwind prefix. */
3444 if (strncmp (text_name
, ".gnu.linkonce.t.",
3445 sizeof (".gnu.linkonce.t.") - 1) == 0)
3447 prefix
= special_linkonce_name
[sec_index
- SPECIAL_SECTION_UNWIND
];
3448 suffix
+= sizeof (".gnu.linkonce.t.") - 1;
3451 prefix_len
= strlen (prefix
);
3452 suffix_len
= strlen (suffix
);
3453 sec_name_len
= prefix_len
+ suffix_len
;
3454 sec_name
= alloca (sec_name_len
+ 1);
3455 memcpy (sec_name
, prefix
, prefix_len
);
3456 memcpy (sec_name
+ prefix_len
, suffix
, suffix_len
);
3457 sec_name
[sec_name_len
] = '\0';
3459 /* Handle COMDAT group. */
3460 if ((text_seg
->flags
& SEC_LINK_ONCE
) != 0
3461 && (elf_section_flags (text_seg
) & SHF_GROUP
) != 0)
3464 size_t len
, group_name_len
;
3465 const char *group_name
= elf_group_name (text_seg
);
3467 if (group_name
== NULL
)
3469 as_bad (_("Group section `%s' has no group signature"),
3471 ignore_rest_of_line ();
3474 /* We have to construct a fake section directive. */
3475 group_name_len
= strlen (group_name
);
3477 + 16 /* ,"aG",@progbits, */
3478 + group_name_len
/* ,group_name */
3481 section
= alloca (len
+ 1);
3482 memcpy (section
, sec_name
, sec_name_len
);
3483 memcpy (section
+ sec_name_len
, ",\"aG\",@progbits,", 16);
3484 memcpy (section
+ sec_name_len
+ 16, group_name
, group_name_len
);
3485 memcpy (section
+ len
- 7, ",comdat", 7);
3486 section
[len
] = '\0';
3487 set_section (section
);
3491 set_section (sec_name
);
3492 bfd_set_section_flags (stdoutput
, now_seg
,
3493 SEC_LOAD
| SEC_ALLOC
| SEC_READONLY
);
3496 elf_linked_to_section (now_seg
) = text_seg
;
3500 generate_unwind_image (const segT text_seg
)
3505 /* Mark the end of the unwind info, so that we can compute the size of the
3506 last unwind region. */
3507 add_unwind_entry (output_endp (), NOT_A_CHAR
);
3509 /* Force out pending instructions, to make sure all unwind records have
3510 a valid slot_number field. */
3511 ia64_flush_insns ();
3513 /* Generate the unwind record. */
3514 list
= optimize_unw_records (unwind
.list
);
3515 fixup_unw_records (list
, 1);
3516 size
= calc_record_size (list
);
3518 if (size
> 0 || unwind
.force_unwind_entry
)
3520 unwind
.force_unwind_entry
= 0;
3521 /* pad to pointer-size boundary. */
3522 pad
= size
% md
.pointer_size
;
3524 size
+= md
.pointer_size
- pad
;
3525 /* Add 8 for the header. */
3527 /* Add a pointer for the personality offset. */
3528 if (unwind
.personality_routine
)
3529 size
+= md
.pointer_size
;
3532 /* If there are unwind records, switch sections, and output the info. */
3536 bfd_reloc_code_real_type reloc
;
3538 start_unwind_section (text_seg
, SPECIAL_SECTION_UNWIND_INFO
);
3540 /* Make sure the section has 4 byte alignment for ILP32 and
3541 8 byte alignment for LP64. */
3542 frag_align (md
.pointer_size_shift
, 0, 0);
3543 record_alignment (now_seg
, md
.pointer_size_shift
);
3545 /* Set expression which points to start of unwind descriptor area. */
3546 unwind
.info
= expr_build_dot ();
3548 frag_var (rs_machine_dependent
, size
, size
, 0, 0,
3549 (offsetT
) (long) unwind
.personality_routine
,
3552 /* Add the personality address to the image. */
3553 if (unwind
.personality_routine
!= 0)
3555 exp
.X_op
= O_symbol
;
3556 exp
.X_add_symbol
= unwind
.personality_routine
;
3557 exp
.X_add_number
= 0;
3559 if (md
.flags
& EF_IA_64_BE
)
3561 if (md
.flags
& EF_IA_64_ABI64
)
3562 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64MSB
;
3564 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32MSB
;
3568 if (md
.flags
& EF_IA_64_ABI64
)
3569 reloc
= BFD_RELOC_IA64_LTOFF_FPTR64LSB
;
3571 reloc
= BFD_RELOC_IA64_LTOFF_FPTR32LSB
;
3574 fix_new_exp (frag_now
, frag_now_fix () - md
.pointer_size
,
3575 md
.pointer_size
, &exp
, 0, reloc
);
3576 unwind
.personality_routine
= 0;
3580 free_saved_prologue_counts ();
3581 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
3585 dot_handlerdata (int dummy ATTRIBUTE_UNUSED
)
3587 if (!in_procedure ("handlerdata"))
3589 unwind
.force_unwind_entry
= 1;
3591 /* Remember which segment we're in so we can switch back after .endp */
3592 unwind
.saved_text_seg
= now_seg
;
3593 unwind
.saved_text_subseg
= now_subseg
;
3595 /* Generate unwind info into unwind-info section and then leave that
3596 section as the currently active one so dataXX directives go into
3597 the language specific data area of the unwind info block. */
3598 generate_unwind_image (now_seg
);
3599 demand_empty_rest_of_line ();
3603 dot_unwentry (int dummy ATTRIBUTE_UNUSED
)
3605 if (!in_procedure ("unwentry"))
3607 unwind
.force_unwind_entry
= 1;
3608 demand_empty_rest_of_line ();
3612 dot_altrp (int dummy ATTRIBUTE_UNUSED
)
3617 if (!in_prologue ("altrp"))
3620 parse_operand_and_eval (&e
, 0);
3621 reg
= e
.X_add_number
- REG_BR
;
3622 if (e
.X_op
!= O_register
|| reg
> 7)
3624 as_bad (_("First operand to .altrp not a valid branch register"));
3627 add_unwind_entry (output_rp_br (reg
), 0);
3631 dot_savemem (int psprel
)
3636 const char * const po
= psprel
? "savepsp" : "savesp";
3638 if (!in_prologue (po
))
3641 sep
= parse_operand_and_eval (&e1
, ',');
3643 sep
= parse_operand_and_eval (&e2
, ',');
3647 reg1
= e1
.X_add_number
;
3648 val
= e2
.X_add_number
;
3650 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3651 if (e1
.X_op
!= O_register
)
3653 as_bad (_("First operand to .%s not a register"), po
);
3654 reg1
= REG_PR
; /* Anything valid is good here. */
3656 if (e2
.X_op
!= O_constant
)
3658 as_bad (_("Second operand to .%s not a constant"), po
);
3664 case REG_AR
+ AR_BSP
:
3665 add_unwind_entry (output_bsp_when (), sep
);
3666 add_unwind_entry ((psprel
3668 : output_bsp_sprel
) (val
), NOT_A_CHAR
);
3670 case REG_AR
+ AR_BSPSTORE
:
3671 add_unwind_entry (output_bspstore_when (), sep
);
3672 add_unwind_entry ((psprel
3673 ? output_bspstore_psprel
3674 : output_bspstore_sprel
) (val
), NOT_A_CHAR
);
3676 case REG_AR
+ AR_RNAT
:
3677 add_unwind_entry (output_rnat_when (), sep
);
3678 add_unwind_entry ((psprel
3679 ? output_rnat_psprel
3680 : output_rnat_sprel
) (val
), NOT_A_CHAR
);
3682 case REG_AR
+ AR_UNAT
:
3683 add_unwind_entry (output_unat_when (), sep
);
3684 add_unwind_entry ((psprel
3685 ? output_unat_psprel
3686 : output_unat_sprel
) (val
), NOT_A_CHAR
);
3688 case REG_AR
+ AR_FPSR
:
3689 add_unwind_entry (output_fpsr_when (), sep
);
3690 add_unwind_entry ((psprel
3691 ? output_fpsr_psprel
3692 : output_fpsr_sprel
) (val
), NOT_A_CHAR
);
3694 case REG_AR
+ AR_PFS
:
3695 add_unwind_entry (output_pfs_when (), sep
);
3696 add_unwind_entry ((psprel
3698 : output_pfs_sprel
) (val
), NOT_A_CHAR
);
3700 case REG_AR
+ AR_LC
:
3701 add_unwind_entry (output_lc_when (), sep
);
3702 add_unwind_entry ((psprel
3704 : output_lc_sprel
) (val
), NOT_A_CHAR
);
3707 add_unwind_entry (output_rp_when (), sep
);
3708 add_unwind_entry ((psprel
3710 : output_rp_sprel
) (val
), NOT_A_CHAR
);
3713 add_unwind_entry (output_preds_when (), sep
);
3714 add_unwind_entry ((psprel
3715 ? output_preds_psprel
3716 : output_preds_sprel
) (val
), NOT_A_CHAR
);
3719 add_unwind_entry (output_priunat_when_mem (), sep
);
3720 add_unwind_entry ((psprel
3721 ? output_priunat_psprel
3722 : output_priunat_sprel
) (val
), NOT_A_CHAR
);
3725 as_bad (_("First operand to .%s not a valid register"), po
);
3726 add_unwind_entry (NULL
, sep
);
3732 dot_saveg (int dummy ATTRIBUTE_UNUSED
)
3738 if (!in_prologue ("save.g"))
3741 sep
= parse_operand_and_eval (&e
, ',');
3743 grmask
= e
.X_add_number
;
3744 if (e
.X_op
!= O_constant
3745 || e
.X_add_number
<= 0
3746 || e
.X_add_number
> 0xf)
3748 as_bad (_("First operand to .save.g must be a positive 4-bit constant"));
3755 int n
= popcount (grmask
);
3757 parse_operand_and_eval (&e
, 0);
3758 reg
= e
.X_add_number
- REG_GR
;
3759 if (e
.X_op
!= O_register
|| reg
> 127)
3761 as_bad (_("Second operand to .save.g must be a general register"));
3764 else if (reg
> 128U - n
)
3766 as_bad (_("Second operand to .save.g must be the first of %d general registers"), n
);
3769 add_unwind_entry (output_gr_gr (grmask
, reg
), 0);
3772 add_unwind_entry (output_gr_mem (grmask
), 0);
3776 dot_savef (int dummy ATTRIBUTE_UNUSED
)
3780 if (!in_prologue ("save.f"))
3783 parse_operand_and_eval (&e
, 0);
3785 if (e
.X_op
!= O_constant
3786 || e
.X_add_number
<= 0
3787 || e
.X_add_number
> 0xfffff)
3789 as_bad (_("Operand to .save.f must be a positive 20-bit constant"));
3792 add_unwind_entry (output_fr_mem (e
.X_add_number
), 0);
3796 dot_saveb (int dummy ATTRIBUTE_UNUSED
)
3802 if (!in_prologue ("save.b"))
3805 sep
= parse_operand_and_eval (&e
, ',');
3807 brmask
= e
.X_add_number
;
3808 if (e
.X_op
!= O_constant
3809 || e
.X_add_number
<= 0
3810 || e
.X_add_number
> 0x1f)
3812 as_bad (_("First operand to .save.b must be a positive 5-bit constant"));
3819 int n
= popcount (brmask
);
3821 parse_operand_and_eval (&e
, 0);
3822 reg
= e
.X_add_number
- REG_GR
;
3823 if (e
.X_op
!= O_register
|| reg
> 127)
3825 as_bad (_("Second operand to .save.b must be a general register"));
3828 else if (reg
> 128U - n
)
3830 as_bad (_("Second operand to .save.b must be the first of %d general registers"), n
);
3833 add_unwind_entry (output_br_gr (brmask
, reg
), 0);
3836 add_unwind_entry (output_br_mem (brmask
), 0);
3840 dot_savegf (int dummy ATTRIBUTE_UNUSED
)
3844 if (!in_prologue ("save.gf"))
3847 if (parse_operand_and_eval (&e1
, ',') == ',')
3848 parse_operand_and_eval (&e2
, 0);
3852 if (e1
.X_op
!= O_constant
3853 || e1
.X_add_number
< 0
3854 || e1
.X_add_number
> 0xf)
3856 as_bad (_("First operand to .save.gf must be a non-negative 4-bit constant"));
3858 e1
.X_add_number
= 0;
3860 if (e2
.X_op
!= O_constant
3861 || e2
.X_add_number
< 0
3862 || e2
.X_add_number
> 0xfffff)
3864 as_bad (_("Second operand to .save.gf must be a non-negative 20-bit constant"));
3866 e2
.X_add_number
= 0;
3868 if (e1
.X_op
== O_constant
3869 && e2
.X_op
== O_constant
3870 && e1
.X_add_number
== 0
3871 && e2
.X_add_number
== 0)
3872 as_bad (_("Operands to .save.gf may not be both zero"));
3874 add_unwind_entry (output_frgr_mem (e1
.X_add_number
, e2
.X_add_number
), 0);
3878 dot_spill (int dummy ATTRIBUTE_UNUSED
)
3882 if (!in_prologue ("spill"))
3885 parse_operand_and_eval (&e
, 0);
3887 if (e
.X_op
!= O_constant
)
3889 as_bad (_("Operand to .spill must be a constant"));
3892 add_unwind_entry (output_spill_base (e
.X_add_number
), 0);
3896 dot_spillreg (int pred
)
3899 unsigned int qp
, ab
, xy
, reg
, treg
;
3901 const char * const po
= pred
? "spillreg.p" : "spillreg";
3903 if (!in_procedure (po
))
3907 sep
= parse_predicate_and_operand (&e
, &qp
, po
);
3910 sep
= parse_operand_and_eval (&e
, ',');
3913 convert_expr_to_ab_reg (&e
, &ab
, ®
, po
, 1 + pred
);
3916 sep
= parse_operand_and_eval (&e
, ',');
3919 convert_expr_to_xy_reg (&e
, &xy
, &treg
, po
, 2 + pred
);
3921 add_unwind_entry (output_spill_reg (ab
, reg
, treg
, xy
, qp
), sep
);
3925 dot_spillmem (int psprel
)
3928 int pred
= (psprel
< 0), sep
;
3929 unsigned int qp
, ab
, reg
;
3935 po
= psprel
? "spillpsp.p" : "spillsp.p";
3938 po
= psprel
? "spillpsp" : "spillsp";
3940 if (!in_procedure (po
))
3944 sep
= parse_predicate_and_operand (&e
, &qp
, po
);
3947 sep
= parse_operand_and_eval (&e
, ',');
3950 convert_expr_to_ab_reg (&e
, &ab
, ®
, po
, 1 + pred
);
3953 sep
= parse_operand_and_eval (&e
, ',');
3956 if (e
.X_op
!= O_constant
)
3958 as_bad (_("Operand %d to .%s must be a constant"), 2 + pred
, po
);
3963 add_unwind_entry (output_spill_psprel (ab
, reg
, e
.X_add_number
, qp
), sep
);
3965 add_unwind_entry (output_spill_sprel (ab
, reg
, e
.X_add_number
, qp
), sep
);
3969 get_saved_prologue_count (unsigned long lbl
)
3971 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3973 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
3977 return lpc
->prologue_count
;
3979 as_bad (_("Missing .label_state %ld"), lbl
);
3984 save_prologue_count (unsigned long lbl
, unsigned int count
)
3986 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
3988 while (lpc
!= NULL
&& lpc
->label_number
!= lbl
)
3992 lpc
->prologue_count
= count
;
3995 label_prologue_count
*new_lpc
= xmalloc (sizeof (* new_lpc
));
3997 new_lpc
->next
= unwind
.saved_prologue_counts
;
3998 new_lpc
->label_number
= lbl
;
3999 new_lpc
->prologue_count
= count
;
4000 unwind
.saved_prologue_counts
= new_lpc
;
4005 free_saved_prologue_counts ()
4007 label_prologue_count
*lpc
= unwind
.saved_prologue_counts
;
4008 label_prologue_count
*next
;
4017 unwind
.saved_prologue_counts
= NULL
;
4021 dot_label_state (int dummy ATTRIBUTE_UNUSED
)
4025 if (!in_body ("label_state"))
4028 parse_operand_and_eval (&e
, 0);
4029 if (e
.X_op
== O_constant
)
4030 save_prologue_count (e
.X_add_number
, unwind
.prologue_count
);
4033 as_bad (_("Operand to .label_state must be a constant"));
4036 add_unwind_entry (output_label_state (e
.X_add_number
), 0);
4040 dot_copy_state (int dummy ATTRIBUTE_UNUSED
)
4044 if (!in_body ("copy_state"))
4047 parse_operand_and_eval (&e
, 0);
4048 if (e
.X_op
== O_constant
)
4049 unwind
.prologue_count
= get_saved_prologue_count (e
.X_add_number
);
4052 as_bad (_("Operand to .copy_state must be a constant"));
4055 add_unwind_entry (output_copy_state (e
.X_add_number
), 0);
4059 dot_unwabi (int dummy ATTRIBUTE_UNUSED
)
4064 if (!in_prologue ("unwabi"))
4067 sep
= parse_operand_and_eval (&e1
, ',');
4069 parse_operand_and_eval (&e2
, 0);
4073 if (e1
.X_op
!= O_constant
)
4075 as_bad (_("First operand to .unwabi must be a constant"));
4076 e1
.X_add_number
= 0;
4079 if (e2
.X_op
!= O_constant
)
4081 as_bad (_("Second operand to .unwabi must be a constant"));
4082 e2
.X_add_number
= 0;
4085 add_unwind_entry (output_unwabi (e1
.X_add_number
, e2
.X_add_number
), 0);
4089 dot_personality (int dummy ATTRIBUTE_UNUSED
)
4092 if (!in_procedure ("personality"))
4095 name
= input_line_pointer
;
4096 c
= get_symbol_end ();
4097 p
= input_line_pointer
;
4098 unwind
.personality_routine
= symbol_find_or_make (name
);
4099 unwind
.force_unwind_entry
= 1;
4102 demand_empty_rest_of_line ();
4106 dot_proc (int dummy ATTRIBUTE_UNUSED
)
4110 proc_pending
*pending
, *last_pending
;
4112 if (unwind
.proc_pending
.sym
)
4114 (md
.unwind_check
== unwind_check_warning
4116 : as_bad
) (_("Missing .endp after previous .proc"));
4117 while (unwind
.proc_pending
.next
)
4119 pending
= unwind
.proc_pending
.next
;
4120 unwind
.proc_pending
.next
= pending
->next
;
4124 last_pending
= NULL
;
4126 /* Parse names of main and alternate entry points and mark them as
4127 function symbols: */
4131 name
= input_line_pointer
;
4132 c
= get_symbol_end ();
4133 p
= input_line_pointer
;
4135 as_bad (_("Empty argument of .proc"));
4138 sym
= symbol_find_or_make (name
);
4139 if (S_IS_DEFINED (sym
))
4140 as_bad (_("`%s' was already defined"), name
);
4141 else if (!last_pending
)
4143 unwind
.proc_pending
.sym
= sym
;
4144 last_pending
= &unwind
.proc_pending
;
4148 pending
= xmalloc (sizeof (*pending
));
4150 last_pending
= last_pending
->next
= pending
;
4152 symbol_get_bfdsym (sym
)->flags
|= BSF_FUNCTION
;
4156 if (*input_line_pointer
!= ',')
4158 ++input_line_pointer
;
4162 unwind
.proc_pending
.sym
= expr_build_dot ();
4163 last_pending
= &unwind
.proc_pending
;
4165 last_pending
->next
= NULL
;
4166 demand_empty_rest_of_line ();
4169 unwind
.prologue
= 0;
4170 unwind
.prologue_count
= 0;
4173 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
4174 unwind
.personality_routine
= 0;
4178 dot_body (int dummy ATTRIBUTE_UNUSED
)
4180 if (!in_procedure ("body"))
4182 if (!unwind
.prologue
&& !unwind
.body
&& unwind
.insn
)
4183 as_warn (_("Initial .body should precede any instructions"));
4184 check_pending_save ();
4186 unwind
.prologue
= 0;
4187 unwind
.prologue_mask
= 0;
4190 add_unwind_entry (output_body (), 0);
4194 dot_prologue (int dummy ATTRIBUTE_UNUSED
)
4196 unsigned mask
= 0, grsave
= 0;
4198 if (!in_procedure ("prologue"))
4200 if (unwind
.prologue
)
4202 as_bad (_(".prologue within prologue"));
4203 ignore_rest_of_line ();
4206 if (!unwind
.body
&& unwind
.insn
)
4207 as_warn (_("Initial .prologue should precede any instructions"));
4209 if (!is_it_end_of_statement ())
4212 int n
, sep
= parse_operand_and_eval (&e
, ',');
4214 if (e
.X_op
!= O_constant
4215 || e
.X_add_number
< 0
4216 || e
.X_add_number
> 0xf)
4217 as_bad (_("First operand to .prologue must be a positive 4-bit constant"));
4218 else if (e
.X_add_number
== 0)
4219 as_warn (_("Pointless use of zero first operand to .prologue"));
4221 mask
= e
.X_add_number
;
4222 n
= popcount (mask
);
4225 parse_operand_and_eval (&e
, 0);
4228 if (e
.X_op
== O_constant
4229 && e
.X_add_number
>= 0
4230 && e
.X_add_number
< 128)
4232 if (md
.unwind_check
== unwind_check_error
)
4233 as_warn (_("Using a constant as second operand to .prologue is deprecated"));
4234 grsave
= e
.X_add_number
;
4236 else if (e
.X_op
!= O_register
4237 || (grsave
= e
.X_add_number
- REG_GR
) > 127)
4239 as_bad (_("Second operand to .prologue must be a general register"));
4242 else if (grsave
> 128U - n
)
4244 as_bad (_("Second operand to .prologue must be the first of %d general registers"), n
);
4251 add_unwind_entry (output_prologue_gr (mask
, grsave
), 0);
4253 add_unwind_entry (output_prologue (), 0);
4255 unwind
.prologue
= 1;
4256 unwind
.prologue_mask
= mask
;
4257 unwind
.prologue_gr
= grsave
;
4259 ++unwind
.prologue_count
;
4263 dot_endp (int dummy ATTRIBUTE_UNUSED
)
4266 int bytes_per_address
;
4269 subsegT saved_subseg
;
4270 proc_pending
*pending
;
4271 int unwind_check
= md
.unwind_check
;
4273 md
.unwind_check
= unwind_check_error
;
4274 if (!in_procedure ("endp"))
4276 md
.unwind_check
= unwind_check
;
4278 if (unwind
.saved_text_seg
)
4280 saved_seg
= unwind
.saved_text_seg
;
4281 saved_subseg
= unwind
.saved_text_subseg
;
4282 unwind
.saved_text_seg
= NULL
;
4286 saved_seg
= now_seg
;
4287 saved_subseg
= now_subseg
;
4290 insn_group_break (1, 0, 0);
4292 /* If there wasn't a .handlerdata, we haven't generated an image yet. */
4294 generate_unwind_image (saved_seg
);
4296 if (unwind
.info
|| unwind
.force_unwind_entry
)
4300 subseg_set (md
.last_text_seg
, 0);
4301 proc_end
= expr_build_dot ();
4303 start_unwind_section (saved_seg
, SPECIAL_SECTION_UNWIND
);
4305 /* Make sure that section has 4 byte alignment for ILP32 and
4306 8 byte alignment for LP64. */
4307 record_alignment (now_seg
, md
.pointer_size_shift
);
4309 /* Need space for 3 pointers for procedure start, procedure end,
4311 memset (frag_more (3 * md
.pointer_size
), 0, 3 * md
.pointer_size
);
4312 where
= frag_now_fix () - (3 * md
.pointer_size
);
4313 bytes_per_address
= bfd_arch_bits_per_address (stdoutput
) / 8;
4315 /* Issue the values of a) Proc Begin, b) Proc End, c) Unwind Record. */
4316 e
.X_op
= O_pseudo_fixup
;
4317 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4319 if (!S_IS_LOCAL (unwind
.proc_pending
.sym
)
4320 && S_IS_DEFINED (unwind
.proc_pending
.sym
))
4321 e
.X_add_symbol
= symbol_temp_new (S_GET_SEGMENT (unwind
.proc_pending
.sym
),
4322 S_GET_VALUE (unwind
.proc_pending
.sym
),
4323 symbol_get_frag (unwind
.proc_pending
.sym
));
4325 e
.X_add_symbol
= unwind
.proc_pending
.sym
;
4326 ia64_cons_fix_new (frag_now
, where
, bytes_per_address
, &e
);
4328 e
.X_op
= O_pseudo_fixup
;
4329 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4331 e
.X_add_symbol
= proc_end
;
4332 ia64_cons_fix_new (frag_now
, where
+ bytes_per_address
,
4333 bytes_per_address
, &e
);
4337 e
.X_op
= O_pseudo_fixup
;
4338 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
4340 e
.X_add_symbol
= unwind
.info
;
4341 ia64_cons_fix_new (frag_now
, where
+ (bytes_per_address
* 2),
4342 bytes_per_address
, &e
);
4345 subseg_set (saved_seg
, saved_subseg
);
4347 /* Set symbol sizes. */
4348 pending
= &unwind
.proc_pending
;
4349 if (S_GET_NAME (pending
->sym
))
4353 symbolS
*sym
= pending
->sym
;
4355 if (!S_IS_DEFINED (sym
))
4356 as_bad (_("`%s' was not defined within procedure"), S_GET_NAME (sym
));
4357 else if (S_GET_SIZE (sym
) == 0
4358 && symbol_get_obj (sym
)->size
== NULL
)
4360 fragS
*frag
= symbol_get_frag (sym
);
4364 if (frag
== frag_now
&& SEG_NORMAL (now_seg
))
4365 S_SET_SIZE (sym
, frag_now_fix () - S_GET_VALUE (sym
));
4368 symbol_get_obj (sym
)->size
=
4369 (expressionS
*) xmalloc (sizeof (expressionS
));
4370 symbol_get_obj (sym
)->size
->X_op
= O_subtract
;
4371 symbol_get_obj (sym
)->size
->X_add_symbol
4372 = symbol_new (FAKE_LABEL_NAME
, now_seg
,
4373 frag_now_fix (), frag_now
);
4374 symbol_get_obj (sym
)->size
->X_op_symbol
= sym
;
4375 symbol_get_obj (sym
)->size
->X_add_number
= 0;
4379 } while ((pending
= pending
->next
) != NULL
);
4382 /* Parse names of main and alternate entry points. */
4388 name
= input_line_pointer
;
4389 c
= get_symbol_end ();
4390 p
= input_line_pointer
;
4392 (md
.unwind_check
== unwind_check_warning
4394 : as_bad
) (_("Empty argument of .endp"));
4397 symbolS
*sym
= symbol_find (name
);
4399 for (pending
= &unwind
.proc_pending
; pending
; pending
= pending
->next
)
4401 if (sym
== pending
->sym
)
4403 pending
->sym
= NULL
;
4407 if (!sym
|| !pending
)
4408 as_warn (_("`%s' was not specified with previous .proc"), name
);
4412 if (*input_line_pointer
!= ',')
4414 ++input_line_pointer
;
4416 demand_empty_rest_of_line ();
4418 /* Deliberately only checking for the main entry point here; the
4419 language spec even says all arguments to .endp are ignored. */
4420 if (unwind
.proc_pending
.sym
4421 && S_GET_NAME (unwind
.proc_pending
.sym
)
4422 && strcmp (S_GET_NAME (unwind
.proc_pending
.sym
), FAKE_LABEL_NAME
))
4423 as_warn (_("`%s' should be an operand to this .endp"),
4424 S_GET_NAME (unwind
.proc_pending
.sym
));
4425 while (unwind
.proc_pending
.next
)
4427 pending
= unwind
.proc_pending
.next
;
4428 unwind
.proc_pending
.next
= pending
->next
;
4431 unwind
.proc_pending
.sym
= unwind
.info
= NULL
;
4435 dot_template (int template_val
)
4437 CURR_SLOT
.user_template
= template_val
;
4441 dot_regstk (int dummy ATTRIBUTE_UNUSED
)
4443 int ins
, locs
, outs
, rots
;
4445 if (is_it_end_of_statement ())
4446 ins
= locs
= outs
= rots
= 0;
4449 ins
= get_absolute_expression ();
4450 if (*input_line_pointer
++ != ',')
4452 locs
= get_absolute_expression ();
4453 if (*input_line_pointer
++ != ',')
4455 outs
= get_absolute_expression ();
4456 if (*input_line_pointer
++ != ',')
4458 rots
= get_absolute_expression ();
4460 set_regstack (ins
, locs
, outs
, rots
);
4464 as_bad (_("Comma expected"));
4465 ignore_rest_of_line ();
4472 valueT num_alloced
= 0;
4473 struct dynreg
**drpp
, *dr
;
4474 int ch
, base_reg
= 0;
4480 case DYNREG_GR
: base_reg
= REG_GR
+ 32; break;
4481 case DYNREG_FR
: base_reg
= REG_FR
+ 32; break;
4482 case DYNREG_PR
: base_reg
= REG_P
+ 16; break;
4486 /* First, remove existing names from hash table. */
4487 for (dr
= md
.dynreg
[type
]; dr
&& dr
->num_regs
; dr
= dr
->next
)
4489 hash_delete (md
.dynreg_hash
, dr
->name
, FALSE
);
4490 /* FIXME: Free dr->name. */
4494 drpp
= &md
.dynreg
[type
];
4497 start
= input_line_pointer
;
4498 ch
= get_symbol_end ();
4499 len
= strlen (ia64_canonicalize_symbol_name (start
));
4500 *input_line_pointer
= ch
;
4503 if (*input_line_pointer
!= '[')
4505 as_bad (_("Expected '['"));
4508 ++input_line_pointer
; /* skip '[' */
4510 num_regs
= get_absolute_expression ();
4512 if (*input_line_pointer
++ != ']')
4514 as_bad (_("Expected ']'"));
4519 as_bad (_("Number of elements must be positive"));
4524 num_alloced
+= num_regs
;
4528 if (num_alloced
> md
.rot
.num_regs
)
4530 as_bad (_("Used more than the declared %d rotating registers"),
4536 if (num_alloced
> 96)
4538 as_bad (_("Used more than the available 96 rotating registers"));
4543 if (num_alloced
> 48)
4545 as_bad (_("Used more than the available 48 rotating registers"));
4556 *drpp
= obstack_alloc (¬es
, sizeof (*dr
));
4557 memset (*drpp
, 0, sizeof (*dr
));
4560 name
= obstack_alloc (¬es
, len
+ 1);
4561 memcpy (name
, start
, len
);
4566 dr
->num_regs
= num_regs
;
4567 dr
->base
= base_reg
;
4569 base_reg
+= num_regs
;
4571 if (hash_insert (md
.dynreg_hash
, name
, dr
))
4573 as_bad (_("Attempt to redefine register set `%s'"), name
);
4574 obstack_free (¬es
, name
);
4578 if (*input_line_pointer
!= ',')
4580 ++input_line_pointer
; /* skip comma */
4583 demand_empty_rest_of_line ();
4587 ignore_rest_of_line ();
4591 dot_byteorder (int byteorder
)
4593 segment_info_type
*seginfo
= seg_info (now_seg
);
4595 if (byteorder
== -1)
4597 if (seginfo
->tc_segment_info_data
.endian
== 0)
4598 seginfo
->tc_segment_info_data
.endian
= default_big_endian
? 1 : 2;
4599 byteorder
= seginfo
->tc_segment_info_data
.endian
== 1;
4602 seginfo
->tc_segment_info_data
.endian
= byteorder
? 1 : 2;
4604 if (target_big_endian
!= byteorder
)
4606 target_big_endian
= byteorder
;
4607 if (target_big_endian
)
4609 ia64_number_to_chars
= number_to_chars_bigendian
;
4610 ia64_float_to_chars
= ia64_float_to_chars_bigendian
;
4614 ia64_number_to_chars
= number_to_chars_littleendian
;
4615 ia64_float_to_chars
= ia64_float_to_chars_littleendian
;
4621 dot_psr (int dummy ATTRIBUTE_UNUSED
)
4628 option
= input_line_pointer
;
4629 ch
= get_symbol_end ();
4630 if (strcmp (option
, "lsb") == 0)
4631 md
.flags
&= ~EF_IA_64_BE
;
4632 else if (strcmp (option
, "msb") == 0)
4633 md
.flags
|= EF_IA_64_BE
;
4634 else if (strcmp (option
, "abi32") == 0)
4635 md
.flags
&= ~EF_IA_64_ABI64
;
4636 else if (strcmp (option
, "abi64") == 0)
4637 md
.flags
|= EF_IA_64_ABI64
;
4639 as_bad (_("Unknown psr option `%s'"), option
);
4640 *input_line_pointer
= ch
;
4643 if (*input_line_pointer
!= ',')
4646 ++input_line_pointer
;
4649 demand_empty_rest_of_line ();
4653 dot_ln (int dummy ATTRIBUTE_UNUSED
)
4655 new_logical_line (0, get_absolute_expression ());
4656 demand_empty_rest_of_line ();
4660 cross_section (int ref
, void (*builder
) (int), int ua
)
4663 int saved_auto_align
;
4664 unsigned int section_count
;
4667 start
= input_line_pointer
;
4673 name
= demand_copy_C_string (&len
);
4674 obstack_free(¬es
, name
);
4677 ignore_rest_of_line ();
4683 char c
= get_symbol_end ();
4685 if (input_line_pointer
== start
)
4687 as_bad (_("Missing section name"));
4688 ignore_rest_of_line ();
4691 *input_line_pointer
= c
;
4693 end
= input_line_pointer
;
4695 if (*input_line_pointer
!= ',')
4697 as_bad (_("Comma expected after section name"));
4698 ignore_rest_of_line ();
4702 end
= input_line_pointer
+ 1; /* skip comma */
4703 input_line_pointer
= start
;
4704 md
.keep_pending_output
= 1;
4705 section_count
= bfd_count_sections (stdoutput
);
4706 obj_elf_section (0);
4707 if (section_count
!= bfd_count_sections (stdoutput
))
4708 as_warn (_("Creating sections with .xdataN/.xrealN/.xstringZ is deprecated."));
4709 input_line_pointer
= end
;
4710 saved_auto_align
= md
.auto_align
;
4715 md
.auto_align
= saved_auto_align
;
4716 obj_elf_previous (0);
4717 md
.keep_pending_output
= 0;
4721 dot_xdata (int size
)
4723 cross_section (size
, cons
, 0);
4726 /* Why doesn't float_cons() call md_cons_align() the way cons() does? */
4729 stmt_float_cons (int kind
)
4749 ia64_do_align (alignment
);
4754 stmt_cons_ua (int size
)
4756 int saved_auto_align
= md
.auto_align
;
4760 md
.auto_align
= saved_auto_align
;
4764 dot_xfloat_cons (int kind
)
4766 cross_section (kind
, stmt_float_cons
, 0);
4770 dot_xstringer (int zero
)
4772 cross_section (zero
, stringer
, 0);
4776 dot_xdata_ua (int size
)
4778 cross_section (size
, cons
, 1);
4782 dot_xfloat_cons_ua (int kind
)
4784 cross_section (kind
, float_cons
, 1);
4787 /* .reg.val <regname>,value */
4790 dot_reg_val (int dummy ATTRIBUTE_UNUSED
)
4794 expression_and_evaluate (®
);
4795 if (reg
.X_op
!= O_register
)
4797 as_bad (_("Register name expected"));
4798 ignore_rest_of_line ();
4800 else if (*input_line_pointer
++ != ',')
4802 as_bad (_("Comma expected"));
4803 ignore_rest_of_line ();
4807 valueT value
= get_absolute_expression ();
4808 int regno
= reg
.X_add_number
;
4809 if (regno
<= REG_GR
|| regno
> REG_GR
+ 127)
4810 as_warn (_("Register value annotation ignored"));
4813 gr_values
[regno
- REG_GR
].known
= 1;
4814 gr_values
[regno
- REG_GR
].value
= value
;
4815 gr_values
[regno
- REG_GR
].path
= md
.path
;
4818 demand_empty_rest_of_line ();
4823 .serialize.instruction
4826 dot_serialize (int type
)
4828 insn_group_break (0, 0, 0);
4830 instruction_serialization ();
4832 data_serialization ();
4833 insn_group_break (0, 0, 0);
4834 demand_empty_rest_of_line ();
4837 /* select dv checking mode
4842 A stop is inserted when changing modes
4846 dot_dv_mode (int type
)
4848 if (md
.manual_bundling
)
4849 as_warn (_("Directive invalid within a bundle"));
4851 if (type
== 'E' || type
== 'A')
4852 md
.mode_explicitly_set
= 0;
4854 md
.mode_explicitly_set
= 1;
4861 if (md
.explicit_mode
)
4862 insn_group_break (1, 0, 0);
4863 md
.explicit_mode
= 0;
4867 if (!md
.explicit_mode
)
4868 insn_group_break (1, 0, 0);
4869 md
.explicit_mode
= 1;
4873 if (md
.explicit_mode
!= md
.default_explicit_mode
)
4874 insn_group_break (1, 0, 0);
4875 md
.explicit_mode
= md
.default_explicit_mode
;
4876 md
.mode_explicitly_set
= 0;
4882 print_prmask (valueT mask
)
4886 for (regno
= 0; regno
< 64; regno
++)
4888 if (mask
& ((valueT
) 1 << regno
))
4890 fprintf (stderr
, "%s p%d", comma
, regno
);
4897 .pred.rel.clear [p1 [,p2 [,...]]] (also .pred.rel "clear" or @clear)
4898 .pred.rel.imply p1, p2 (also .pred.rel "imply" or @imply)
4899 .pred.rel.mutex p1, p2 [,...] (also .pred.rel "mutex" or @mutex)
4900 .pred.safe_across_calls p1 [, p2 [,...]]
4904 dot_pred_rel (int type
)
4908 int p1
= -1, p2
= -1;
4912 if (*input_line_pointer
== '"')
4915 char *form
= demand_copy_C_string (&len
);
4917 if (strcmp (form
, "mutex") == 0)
4919 else if (strcmp (form
, "clear") == 0)
4921 else if (strcmp (form
, "imply") == 0)
4923 obstack_free (¬es
, form
);
4925 else if (*input_line_pointer
== '@')
4927 char *form
= ++input_line_pointer
;
4928 char c
= get_symbol_end();
4930 if (strcmp (form
, "mutex") == 0)
4932 else if (strcmp (form
, "clear") == 0)
4934 else if (strcmp (form
, "imply") == 0)
4936 *input_line_pointer
= c
;
4940 as_bad (_("Missing predicate relation type"));
4941 ignore_rest_of_line ();
4946 as_bad (_("Unrecognized predicate relation type"));
4947 ignore_rest_of_line ();
4950 if (*input_line_pointer
== ',')
4951 ++input_line_pointer
;
4959 expressionS pr
, *pr1
, *pr2
;
4961 sep
= parse_operand_and_eval (&pr
, ',');
4962 if (pr
.X_op
== O_register
4963 && pr
.X_add_number
>= REG_P
4964 && pr
.X_add_number
<= REG_P
+ 63)
4966 regno
= pr
.X_add_number
- REG_P
;
4974 else if (type
!= 'i'
4975 && pr
.X_op
== O_subtract
4976 && (pr1
= symbol_get_value_expression (pr
.X_add_symbol
))
4977 && pr1
->X_op
== O_register
4978 && pr1
->X_add_number
>= REG_P
4979 && pr1
->X_add_number
<= REG_P
+ 63
4980 && (pr2
= symbol_get_value_expression (pr
.X_op_symbol
))
4981 && pr2
->X_op
== O_register
4982 && pr2
->X_add_number
>= REG_P
4983 && pr2
->X_add_number
<= REG_P
+ 63)
4988 regno
= pr1
->X_add_number
- REG_P
;
4989 stop
= pr2
->X_add_number
- REG_P
;
4992 as_bad (_("Bad register range"));
4993 ignore_rest_of_line ();
4996 bits
= ((bits
<< stop
) << 1) - (bits
<< regno
);
4997 count
+= stop
- regno
+ 1;
5001 as_bad (_("Predicate register expected"));
5002 ignore_rest_of_line ();
5006 as_warn (_("Duplicate predicate register ignored"));
5017 clear_qp_mutex (mask
);
5018 clear_qp_implies (mask
, (valueT
) 0);
5021 if (count
!= 2 || p1
== -1 || p2
== -1)
5022 as_bad (_("Predicate source and target required"));
5023 else if (p1
== 0 || p2
== 0)
5024 as_bad (_("Use of p0 is not valid in this context"));
5026 add_qp_imply (p1
, p2
);
5031 as_bad (_("At least two PR arguments expected"));
5036 as_bad (_("Use of p0 is not valid in this context"));
5039 add_qp_mutex (mask
);
5042 /* note that we don't override any existing relations */
5045 as_bad (_("At least one PR argument expected"));
5050 fprintf (stderr
, "Safe across calls: ");
5051 print_prmask (mask
);
5052 fprintf (stderr
, "\n");
5054 qp_safe_across_calls
= mask
;
5057 demand_empty_rest_of_line ();
5060 /* .entry label [, label [, ...]]
5061 Hint to DV code that the given labels are to be considered entry points.
5062 Otherwise, only global labels are considered entry points. */
5065 dot_entry (int dummy ATTRIBUTE_UNUSED
)
5074 name
= input_line_pointer
;
5075 c
= get_symbol_end ();
5076 symbolP
= symbol_find_or_make (name
);
5078 err
= hash_insert (md
.entry_hash
, S_GET_NAME (symbolP
), (void *) symbolP
);
5080 as_fatal (_("Inserting \"%s\" into entry hint table failed: %s"),
5083 *input_line_pointer
= c
;
5085 c
= *input_line_pointer
;
5088 input_line_pointer
++;
5090 if (*input_line_pointer
== '\n')
5096 demand_empty_rest_of_line ();
5099 /* .mem.offset offset, base
5100 "base" is used to distinguish between offsets from a different base. */
5103 dot_mem_offset (int dummy ATTRIBUTE_UNUSED
)
5105 md
.mem_offset
.hint
= 1;
5106 md
.mem_offset
.offset
= get_absolute_expression ();
5107 if (*input_line_pointer
!= ',')
5109 as_bad (_("Comma expected"));
5110 ignore_rest_of_line ();
5113 ++input_line_pointer
;
5114 md
.mem_offset
.base
= get_absolute_expression ();
5115 demand_empty_rest_of_line ();
5118 /* ia64-specific pseudo-ops: */
5119 const pseudo_typeS md_pseudo_table
[] =
5121 { "radix", dot_radix
, 0 },
5122 { "lcomm", s_lcomm_bytes
, 1 },
5123 { "loc", dot_loc
, 0 },
5124 { "bss", dot_special_section
, SPECIAL_SECTION_BSS
},
5125 { "sbss", dot_special_section
, SPECIAL_SECTION_SBSS
},
5126 { "sdata", dot_special_section
, SPECIAL_SECTION_SDATA
},
5127 { "rodata", dot_special_section
, SPECIAL_SECTION_RODATA
},
5128 { "comment", dot_special_section
, SPECIAL_SECTION_COMMENT
},
5129 { "ia_64.unwind", dot_special_section
, SPECIAL_SECTION_UNWIND
},
5130 { "ia_64.unwind_info", dot_special_section
, SPECIAL_SECTION_UNWIND_INFO
},
5131 { "init_array", dot_special_section
, SPECIAL_SECTION_INIT_ARRAY
},
5132 { "fini_array", dot_special_section
, SPECIAL_SECTION_FINI_ARRAY
},
5133 { "proc", dot_proc
, 0 },
5134 { "body", dot_body
, 0 },
5135 { "prologue", dot_prologue
, 0 },
5136 { "endp", dot_endp
, 0 },
5138 { "fframe", dot_fframe
, 0 },
5139 { "vframe", dot_vframe
, 0 },
5140 { "vframesp", dot_vframesp
, 0 },
5141 { "vframepsp", dot_vframesp
, 1 },
5142 { "save", dot_save
, 0 },
5143 { "restore", dot_restore
, 0 },
5144 { "restorereg", dot_restorereg
, 0 },
5145 { "restorereg.p", dot_restorereg
, 1 },
5146 { "handlerdata", dot_handlerdata
, 0 },
5147 { "unwentry", dot_unwentry
, 0 },
5148 { "altrp", dot_altrp
, 0 },
5149 { "savesp", dot_savemem
, 0 },
5150 { "savepsp", dot_savemem
, 1 },
5151 { "save.g", dot_saveg
, 0 },
5152 { "save.f", dot_savef
, 0 },
5153 { "save.b", dot_saveb
, 0 },
5154 { "save.gf", dot_savegf
, 0 },
5155 { "spill", dot_spill
, 0 },
5156 { "spillreg", dot_spillreg
, 0 },
5157 { "spillsp", dot_spillmem
, 0 },
5158 { "spillpsp", dot_spillmem
, 1 },
5159 { "spillreg.p", dot_spillreg
, 1 },
5160 { "spillsp.p", dot_spillmem
, ~0 },
5161 { "spillpsp.p", dot_spillmem
, ~1 },
5162 { "label_state", dot_label_state
, 0 },
5163 { "copy_state", dot_copy_state
, 0 },
5164 { "unwabi", dot_unwabi
, 0 },
5165 { "personality", dot_personality
, 0 },
5166 { "mii", dot_template
, 0x0 },
5167 { "mli", dot_template
, 0x2 }, /* old format, for compatibility */
5168 { "mlx", dot_template
, 0x2 },
5169 { "mmi", dot_template
, 0x4 },
5170 { "mfi", dot_template
, 0x6 },
5171 { "mmf", dot_template
, 0x7 },
5172 { "mib", dot_template
, 0x8 },
5173 { "mbb", dot_template
, 0x9 },
5174 { "bbb", dot_template
, 0xb },
5175 { "mmb", dot_template
, 0xc },
5176 { "mfb", dot_template
, 0xe },
5177 { "align", dot_align
, 0 },
5178 { "regstk", dot_regstk
, 0 },
5179 { "rotr", dot_rot
, DYNREG_GR
},
5180 { "rotf", dot_rot
, DYNREG_FR
},
5181 { "rotp", dot_rot
, DYNREG_PR
},
5182 { "lsb", dot_byteorder
, 0 },
5183 { "msb", dot_byteorder
, 1 },
5184 { "psr", dot_psr
, 0 },
5185 { "alias", dot_alias
, 0 },
5186 { "secalias", dot_alias
, 1 },
5187 { "ln", dot_ln
, 0 }, /* source line info (for debugging) */
5189 { "xdata1", dot_xdata
, 1 },
5190 { "xdata2", dot_xdata
, 2 },
5191 { "xdata4", dot_xdata
, 4 },
5192 { "xdata8", dot_xdata
, 8 },
5193 { "xdata16", dot_xdata
, 16 },
5194 { "xreal4", dot_xfloat_cons
, 'f' },
5195 { "xreal8", dot_xfloat_cons
, 'd' },
5196 { "xreal10", dot_xfloat_cons
, 'x' },
5197 { "xreal16", dot_xfloat_cons
, 'X' },
5198 { "xstring", dot_xstringer
, 8 + 0 },
5199 { "xstringz", dot_xstringer
, 8 + 1 },
5201 /* unaligned versions: */
5202 { "xdata2.ua", dot_xdata_ua
, 2 },
5203 { "xdata4.ua", dot_xdata_ua
, 4 },
5204 { "xdata8.ua", dot_xdata_ua
, 8 },
5205 { "xdata16.ua", dot_xdata_ua
, 16 },
5206 { "xreal4.ua", dot_xfloat_cons_ua
, 'f' },
5207 { "xreal8.ua", dot_xfloat_cons_ua
, 'd' },
5208 { "xreal10.ua", dot_xfloat_cons_ua
, 'x' },
5209 { "xreal16.ua", dot_xfloat_cons_ua
, 'X' },
5211 /* annotations/DV checking support */
5212 { "entry", dot_entry
, 0 },
5213 { "mem.offset", dot_mem_offset
, 0 },
5214 { "pred.rel", dot_pred_rel
, 0 },
5215 { "pred.rel.clear", dot_pred_rel
, 'c' },
5216 { "pred.rel.imply", dot_pred_rel
, 'i' },
5217 { "pred.rel.mutex", dot_pred_rel
, 'm' },
5218 { "pred.safe_across_calls", dot_pred_rel
, 's' },
5219 { "reg.val", dot_reg_val
, 0 },
5220 { "serialize.data", dot_serialize
, 0 },
5221 { "serialize.instruction", dot_serialize
, 1 },
5222 { "auto", dot_dv_mode
, 'a' },
5223 { "explicit", dot_dv_mode
, 'e' },
5224 { "default", dot_dv_mode
, 'd' },
5226 /* ??? These are needed to make gas/testsuite/gas/elf/ehopt.s work.
5227 IA-64 aligns data allocation pseudo-ops by default, so we have to
5228 tell it that these ones are supposed to be unaligned. Long term,
5229 should rewrite so that only IA-64 specific data allocation pseudo-ops
5230 are aligned by default. */
5231 {"2byte", stmt_cons_ua
, 2},
5232 {"4byte", stmt_cons_ua
, 4},
5233 {"8byte", stmt_cons_ua
, 8},
5238 static const struct pseudo_opcode
5241 void (*handler
) (int);
5246 /* these are more like pseudo-ops, but don't start with a dot */
5247 { "data1", cons
, 1 },
5248 { "data2", cons
, 2 },
5249 { "data4", cons
, 4 },
5250 { "data8", cons
, 8 },
5251 { "data16", cons
, 16 },
5252 { "real4", stmt_float_cons
, 'f' },
5253 { "real8", stmt_float_cons
, 'd' },
5254 { "real10", stmt_float_cons
, 'x' },
5255 { "real16", stmt_float_cons
, 'X' },
5256 { "string", stringer
, 8 + 0 },
5257 { "stringz", stringer
, 8 + 1 },
5259 /* unaligned versions: */
5260 { "data2.ua", stmt_cons_ua
, 2 },
5261 { "data4.ua", stmt_cons_ua
, 4 },
5262 { "data8.ua", stmt_cons_ua
, 8 },
5263 { "data16.ua", stmt_cons_ua
, 16 },
5264 { "real4.ua", float_cons
, 'f' },
5265 { "real8.ua", float_cons
, 'd' },
5266 { "real10.ua", float_cons
, 'x' },
5267 { "real16.ua", float_cons
, 'X' },
5270 /* Declare a register by creating a symbol for it and entering it in
5271 the symbol table. */
5274 declare_register (const char *name
, unsigned int regnum
)
5279 sym
= symbol_create (name
, reg_section
, regnum
, &zero_address_frag
);
5281 err
= hash_insert (md
.reg_hash
, S_GET_NAME (sym
), (void *) sym
);
5283 as_fatal ("Inserting \"%s\" into register table failed: %s",
5290 declare_register_set (const char *prefix
,
5291 unsigned int num_regs
,
5292 unsigned int base_regnum
)
5297 for (i
= 0; i
< num_regs
; ++i
)
5299 snprintf (name
, sizeof (name
), "%s%u", prefix
, i
);
5300 declare_register (name
, base_regnum
+ i
);
5305 operand_width (enum ia64_opnd opnd
)
5307 const struct ia64_operand
*odesc
= &elf64_ia64_operands
[opnd
];
5308 unsigned int bits
= 0;
5312 for (i
= 0; i
< NELEMS (odesc
->field
) && odesc
->field
[i
].bits
; ++i
)
5313 bits
+= odesc
->field
[i
].bits
;
5318 static enum operand_match_result
5319 operand_match (const struct ia64_opcode
*idesc
, int res_index
, expressionS
*e
)
5321 enum ia64_opnd opnd
= idesc
->operands
[res_index
];
5322 int bits
, relocatable
= 0;
5323 struct insn_fix
*fix
;
5330 case IA64_OPND_AR_CCV
:
5331 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 32)
5332 return OPERAND_MATCH
;
5335 case IA64_OPND_AR_CSD
:
5336 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 25)
5337 return OPERAND_MATCH
;
5340 case IA64_OPND_AR_PFS
:
5341 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 64)
5342 return OPERAND_MATCH
;
5346 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_GR
+ 0)
5347 return OPERAND_MATCH
;
5351 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_IP
)
5352 return OPERAND_MATCH
;
5356 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR
)
5357 return OPERAND_MATCH
;
5360 case IA64_OPND_PR_ROT
:
5361 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR_ROT
)
5362 return OPERAND_MATCH
;
5366 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR
)
5367 return OPERAND_MATCH
;
5370 case IA64_OPND_PSR_L
:
5371 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_L
)
5372 return OPERAND_MATCH
;
5375 case IA64_OPND_PSR_UM
:
5376 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_UM
)
5377 return OPERAND_MATCH
;
5381 if (e
->X_op
== O_constant
)
5383 if (e
->X_add_number
== 1)
5384 return OPERAND_MATCH
;
5386 return OPERAND_OUT_OF_RANGE
;
5391 if (e
->X_op
== O_constant
)
5393 if (e
->X_add_number
== 8)
5394 return OPERAND_MATCH
;
5396 return OPERAND_OUT_OF_RANGE
;
5401 if (e
->X_op
== O_constant
)
5403 if (e
->X_add_number
== 16)
5404 return OPERAND_MATCH
;
5406 return OPERAND_OUT_OF_RANGE
;
5410 /* register operands: */
5413 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_AR
5414 && e
->X_add_number
< REG_AR
+ 128)
5415 return OPERAND_MATCH
;
5420 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_BR
5421 && e
->X_add_number
< REG_BR
+ 8)
5422 return OPERAND_MATCH
;
5426 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_CR
5427 && e
->X_add_number
< REG_CR
+ 128)
5428 return OPERAND_MATCH
;
5435 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_FR
5436 && e
->X_add_number
< REG_FR
+ 128)
5437 return OPERAND_MATCH
;
5442 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_P
5443 && e
->X_add_number
< REG_P
+ 64)
5444 return OPERAND_MATCH
;
5450 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
5451 && e
->X_add_number
< REG_GR
+ 128)
5452 return OPERAND_MATCH
;
5455 case IA64_OPND_R3_2
:
5456 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
)
5458 if (e
->X_add_number
< REG_GR
+ 4)
5459 return OPERAND_MATCH
;
5460 else if (e
->X_add_number
< REG_GR
+ 128)
5461 return OPERAND_OUT_OF_RANGE
;
5465 /* indirect operands: */
5466 case IA64_OPND_CPUID_R3
:
5467 case IA64_OPND_DBR_R3
:
5468 case IA64_OPND_DTR_R3
:
5469 case IA64_OPND_ITR_R3
:
5470 case IA64_OPND_IBR_R3
:
5471 case IA64_OPND_MSR_R3
:
5472 case IA64_OPND_PKR_R3
:
5473 case IA64_OPND_PMC_R3
:
5474 case IA64_OPND_PMD_R3
:
5475 case IA64_OPND_RR_R3
:
5476 if (e
->X_op
== O_index
&& e
->X_op_symbol
5477 && (S_GET_VALUE (e
->X_op_symbol
) - IND_CPUID
5478 == opnd
- IA64_OPND_CPUID_R3
))
5479 return OPERAND_MATCH
;
5483 if (e
->X_op
== O_index
&& !e
->X_op_symbol
)
5484 return OPERAND_MATCH
;
5487 /* immediate operands: */
5488 case IA64_OPND_CNT2a
:
5489 case IA64_OPND_LEN4
:
5490 case IA64_OPND_LEN6
:
5491 bits
= operand_width (idesc
->operands
[res_index
]);
5492 if (e
->X_op
== O_constant
)
5494 if ((bfd_vma
) (e
->X_add_number
- 1) < ((bfd_vma
) 1 << bits
))
5495 return OPERAND_MATCH
;
5497 return OPERAND_OUT_OF_RANGE
;
5501 case IA64_OPND_CNT2b
:
5502 if (e
->X_op
== O_constant
)
5504 if ((bfd_vma
) (e
->X_add_number
- 1) < 3)
5505 return OPERAND_MATCH
;
5507 return OPERAND_OUT_OF_RANGE
;
5511 case IA64_OPND_CNT2c
:
5512 val
= e
->X_add_number
;
5513 if (e
->X_op
== O_constant
)
5515 if ((val
== 0 || val
== 7 || val
== 15 || val
== 16))
5516 return OPERAND_MATCH
;
5518 return OPERAND_OUT_OF_RANGE
;
5523 /* SOR must be an integer multiple of 8 */
5524 if (e
->X_op
== O_constant
&& e
->X_add_number
& 0x7)
5525 return OPERAND_OUT_OF_RANGE
;
5528 if (e
->X_op
== O_constant
)
5530 if ((bfd_vma
) e
->X_add_number
<= 96)
5531 return OPERAND_MATCH
;
5533 return OPERAND_OUT_OF_RANGE
;
5537 case IA64_OPND_IMMU62
:
5538 if (e
->X_op
== O_constant
)
5540 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 62))
5541 return OPERAND_MATCH
;
5543 return OPERAND_OUT_OF_RANGE
;
5547 /* FIXME -- need 62-bit relocation type */
5548 as_bad (_("62-bit relocation not yet implemented"));
5552 case IA64_OPND_IMMU64
:
5553 if (e
->X_op
== O_symbol
|| e
->X_op
== O_pseudo_fixup
5554 || e
->X_op
== O_subtract
)
5556 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5557 fix
->code
= BFD_RELOC_IA64_IMM64
;
5558 if (e
->X_op
!= O_subtract
)
5560 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5561 if (e
->X_op
== O_pseudo_fixup
)
5565 fix
->opnd
= idesc
->operands
[res_index
];
5568 ++CURR_SLOT
.num_fixups
;
5569 return OPERAND_MATCH
;
5571 else if (e
->X_op
== O_constant
)
5572 return OPERAND_MATCH
;
5575 case IA64_OPND_IMMU5b
:
5576 if (e
->X_op
== O_constant
)
5578 val
= e
->X_add_number
;
5579 if (val
>= 32 && val
<= 63)
5580 return OPERAND_MATCH
;
5582 return OPERAND_OUT_OF_RANGE
;
5586 case IA64_OPND_CCNT5
:
5587 case IA64_OPND_CNT5
:
5588 case IA64_OPND_CNT6
:
5589 case IA64_OPND_CPOS6a
:
5590 case IA64_OPND_CPOS6b
:
5591 case IA64_OPND_CPOS6c
:
5592 case IA64_OPND_IMMU2
:
5593 case IA64_OPND_IMMU7a
:
5594 case IA64_OPND_IMMU7b
:
5595 case IA64_OPND_IMMU21
:
5596 case IA64_OPND_IMMU24
:
5597 case IA64_OPND_MBTYPE4
:
5598 case IA64_OPND_MHTYPE8
:
5599 case IA64_OPND_POS6
:
5600 bits
= operand_width (idesc
->operands
[res_index
]);
5601 if (e
->X_op
== O_constant
)
5603 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5604 return OPERAND_MATCH
;
5606 return OPERAND_OUT_OF_RANGE
;
5610 case IA64_OPND_IMMU9
:
5611 bits
= operand_width (idesc
->operands
[res_index
]);
5612 if (e
->X_op
== O_constant
)
5614 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
5616 int lobits
= e
->X_add_number
& 0x3;
5617 if (((bfd_vma
) e
->X_add_number
& 0x3C) != 0 && lobits
== 0)
5618 e
->X_add_number
|= (bfd_vma
) 0x3;
5619 return OPERAND_MATCH
;
5622 return OPERAND_OUT_OF_RANGE
;
5626 case IA64_OPND_IMM44
:
5627 /* least 16 bits must be zero */
5628 if ((e
->X_add_number
& 0xffff) != 0)
5629 /* XXX technically, this is wrong: we should not be issuing warning
5630 messages until we're sure this instruction pattern is going to
5632 as_warn (_("lower 16 bits of mask ignored"));
5634 if (e
->X_op
== O_constant
)
5636 if (((e
->X_add_number
>= 0
5637 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 44))
5638 || (e
->X_add_number
< 0
5639 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 44))))
5642 if (e
->X_add_number
>= 0
5643 && (e
->X_add_number
& ((bfd_vma
) 1 << 43)) != 0)
5645 e
->X_add_number
|= ~(((bfd_vma
) 1 << 44) - 1);
5647 return OPERAND_MATCH
;
5650 return OPERAND_OUT_OF_RANGE
;
5654 case IA64_OPND_IMM17
:
5655 /* bit 0 is a don't care (pr0 is hardwired to 1) */
5656 if (e
->X_op
== O_constant
)
5658 if (((e
->X_add_number
>= 0
5659 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 17))
5660 || (e
->X_add_number
< 0
5661 && (bfd_vma
) -e
->X_add_number
<= ((bfd_vma
) 1 << 17))))
5664 if (e
->X_add_number
>= 0
5665 && (e
->X_add_number
& ((bfd_vma
) 1 << 16)) != 0)
5667 e
->X_add_number
|= ~(((bfd_vma
) 1 << 17) - 1);
5669 return OPERAND_MATCH
;
5672 return OPERAND_OUT_OF_RANGE
;
5676 case IA64_OPND_IMM14
:
5677 case IA64_OPND_IMM22
:
5679 case IA64_OPND_IMM1
:
5680 case IA64_OPND_IMM8
:
5681 case IA64_OPND_IMM8U4
:
5682 case IA64_OPND_IMM8M1
:
5683 case IA64_OPND_IMM8M1U4
:
5684 case IA64_OPND_IMM8M1U8
:
5685 case IA64_OPND_IMM9a
:
5686 case IA64_OPND_IMM9b
:
5687 bits
= operand_width (idesc
->operands
[res_index
]);
5688 if (relocatable
&& (e
->X_op
== O_symbol
5689 || e
->X_op
== O_subtract
5690 || e
->X_op
== O_pseudo_fixup
))
5692 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5694 if (idesc
->operands
[res_index
] == IA64_OPND_IMM14
)
5695 fix
->code
= BFD_RELOC_IA64_IMM14
;
5697 fix
->code
= BFD_RELOC_IA64_IMM22
;
5699 if (e
->X_op
!= O_subtract
)
5701 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5702 if (e
->X_op
== O_pseudo_fixup
)
5706 fix
->opnd
= idesc
->operands
[res_index
];
5709 ++CURR_SLOT
.num_fixups
;
5710 return OPERAND_MATCH
;
5712 else if (e
->X_op
!= O_constant
5713 && ! (e
->X_op
== O_big
&& opnd
== IA64_OPND_IMM8M1U8
))
5714 return OPERAND_MISMATCH
;
5716 if (opnd
== IA64_OPND_IMM8M1U4
)
5718 /* Zero is not valid for unsigned compares that take an adjusted
5719 constant immediate range. */
5720 if (e
->X_add_number
== 0)
5721 return OPERAND_OUT_OF_RANGE
;
5723 /* Sign-extend 32-bit unsigned numbers, so that the following range
5724 checks will work. */
5725 val
= e
->X_add_number
;
5726 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5727 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5728 val
= ((val
<< 32) >> 32);
5730 /* Check for 0x100000000. This is valid because
5731 0x100000000-1 is the same as ((uint32_t) -1). */
5732 if (val
== ((bfd_signed_vma
) 1 << 32))
5733 return OPERAND_MATCH
;
5737 else if (opnd
== IA64_OPND_IMM8M1U8
)
5739 /* Zero is not valid for unsigned compares that take an adjusted
5740 constant immediate range. */
5741 if (e
->X_add_number
== 0)
5742 return OPERAND_OUT_OF_RANGE
;
5744 /* Check for 0x10000000000000000. */
5745 if (e
->X_op
== O_big
)
5747 if (generic_bignum
[0] == 0
5748 && generic_bignum
[1] == 0
5749 && generic_bignum
[2] == 0
5750 && generic_bignum
[3] == 0
5751 && generic_bignum
[4] == 1)
5752 return OPERAND_MATCH
;
5754 return OPERAND_OUT_OF_RANGE
;
5757 val
= e
->X_add_number
- 1;
5759 else if (opnd
== IA64_OPND_IMM8M1
)
5760 val
= e
->X_add_number
- 1;
5761 else if (opnd
== IA64_OPND_IMM8U4
)
5763 /* Sign-extend 32-bit unsigned numbers, so that the following range
5764 checks will work. */
5765 val
= e
->X_add_number
;
5766 if (((val
& (~(bfd_vma
) 0 << 32)) == 0)
5767 && ((val
& ((bfd_vma
) 1 << 31)) != 0))
5768 val
= ((val
<< 32) >> 32);
5771 val
= e
->X_add_number
;
5773 if ((val
>= 0 && (bfd_vma
) val
< ((bfd_vma
) 1 << (bits
- 1)))
5774 || (val
< 0 && (bfd_vma
) -val
<= ((bfd_vma
) 1 << (bits
- 1))))
5775 return OPERAND_MATCH
;
5777 return OPERAND_OUT_OF_RANGE
;
5779 case IA64_OPND_INC3
:
5780 /* +/- 1, 4, 8, 16 */
5781 val
= e
->X_add_number
;
5784 if (e
->X_op
== O_constant
)
5786 if ((val
== 1 || val
== 4 || val
== 8 || val
== 16))
5787 return OPERAND_MATCH
;
5789 return OPERAND_OUT_OF_RANGE
;
5793 case IA64_OPND_TGT25
:
5794 case IA64_OPND_TGT25b
:
5795 case IA64_OPND_TGT25c
:
5796 case IA64_OPND_TGT64
:
5797 if (e
->X_op
== O_symbol
)
5799 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5800 if (opnd
== IA64_OPND_TGT25
)
5801 fix
->code
= BFD_RELOC_IA64_PCREL21F
;
5802 else if (opnd
== IA64_OPND_TGT25b
)
5803 fix
->code
= BFD_RELOC_IA64_PCREL21M
;
5804 else if (opnd
== IA64_OPND_TGT25c
)
5805 fix
->code
= BFD_RELOC_IA64_PCREL21B
;
5806 else if (opnd
== IA64_OPND_TGT64
)
5807 fix
->code
= BFD_RELOC_IA64_PCREL60B
;
5811 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5812 fix
->opnd
= idesc
->operands
[res_index
];
5815 ++CURR_SLOT
.num_fixups
;
5816 return OPERAND_MATCH
;
5818 case IA64_OPND_TAG13
:
5819 case IA64_OPND_TAG13b
:
5823 return OPERAND_MATCH
;
5826 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5827 /* There are no external relocs for TAG13/TAG13b fields, so we
5828 create a dummy reloc. This will not live past md_apply_fix. */
5829 fix
->code
= BFD_RELOC_UNUSED
;
5830 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
5831 fix
->opnd
= idesc
->operands
[res_index
];
5834 ++CURR_SLOT
.num_fixups
;
5835 return OPERAND_MATCH
;
5842 case IA64_OPND_LDXMOV
:
5843 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
5844 fix
->code
= BFD_RELOC_IA64_LDXMOV
;
5845 fix
->opnd
= idesc
->operands
[res_index
];
5848 ++CURR_SLOT
.num_fixups
;
5849 return OPERAND_MATCH
;
5854 return OPERAND_MISMATCH
;
5858 parse_operand (expressionS
*e
, int more
)
5862 memset (e
, 0, sizeof (*e
));
5866 sep
= *input_line_pointer
;
5867 if (more
&& (sep
== ',' || sep
== more
))
5868 ++input_line_pointer
;
5873 parse_operand_and_eval (expressionS
*e
, int more
)
5875 int sep
= parse_operand (e
, more
);
5876 resolve_expression (e
);
5881 parse_operand_maybe_eval (expressionS
*e
, int more
, enum ia64_opnd op
)
5883 int sep
= parse_operand (e
, more
);
5886 case IA64_OPND_IMM14
:
5887 case IA64_OPND_IMM22
:
5888 case IA64_OPND_IMMU64
:
5889 case IA64_OPND_TGT25
:
5890 case IA64_OPND_TGT25b
:
5891 case IA64_OPND_TGT25c
:
5892 case IA64_OPND_TGT64
:
5893 case IA64_OPND_TAG13
:
5894 case IA64_OPND_TAG13b
:
5895 case IA64_OPND_LDXMOV
:
5898 resolve_expression (e
);
5904 /* Returns the next entry in the opcode table that matches the one in
5905 IDESC, and frees the entry in IDESC. If no matching entry is
5906 found, NULL is returned instead. */
5908 static struct ia64_opcode
*
5909 get_next_opcode (struct ia64_opcode
*idesc
)
5911 struct ia64_opcode
*next
= ia64_find_next_opcode (idesc
);
5912 ia64_free_opcode (idesc
);
5916 /* Parse the operands for the opcode and find the opcode variant that
5917 matches the specified operands, or NULL if no match is possible. */
5919 static struct ia64_opcode
*
5920 parse_operands (struct ia64_opcode
*idesc
)
5922 int i
= 0, highest_unmatched_operand
, num_operands
= 0, num_outputs
= 0;
5923 int error_pos
, out_of_range_pos
, curr_out_of_range_pos
, sep
= 0;
5926 enum ia64_opnd expected_operand
= IA64_OPND_NIL
;
5927 enum operand_match_result result
;
5929 char *first_arg
= 0, *end
, *saved_input_pointer
;
5932 gas_assert (strlen (idesc
->name
) <= 128);
5934 strcpy (mnemonic
, idesc
->name
);
5935 if (idesc
->operands
[2] == IA64_OPND_SOF
5936 || idesc
->operands
[1] == IA64_OPND_SOF
)
5938 /* To make the common idiom "alloc loc?=ar.pfs,0,1,0,0" work, we
5939 can't parse the first operand until we have parsed the
5940 remaining operands of the "alloc" instruction. */
5942 first_arg
= input_line_pointer
;
5943 end
= strchr (input_line_pointer
, '=');
5946 as_bad (_("Expected separator `='"));
5949 input_line_pointer
= end
+ 1;
5956 if (i
< NELEMS (CURR_SLOT
.opnd
))
5958 sep
= parse_operand_maybe_eval (CURR_SLOT
.opnd
+ i
, '=',
5959 idesc
->operands
[i
]);
5960 if (CURR_SLOT
.opnd
[i
].X_op
== O_absent
)
5967 sep
= parse_operand (&dummy
, '=');
5968 if (dummy
.X_op
== O_absent
)
5974 if (sep
!= '=' && sep
!= ',')
5979 if (num_outputs
> 0)
5980 as_bad (_("Duplicate equal sign (=) in instruction"));
5982 num_outputs
= i
+ 1;
5987 as_bad (_("Illegal operand separator `%c'"), sep
);
5991 if (idesc
->operands
[2] == IA64_OPND_SOF
5992 || idesc
->operands
[1] == IA64_OPND_SOF
)
5994 /* Map alloc r1=ar.pfs,i,l,o,r to alloc r1=ar.pfs,(i+l+o),(i+l),r.
5995 Note, however, that due to that mapping operand numbers in error
5996 messages for any of the constant operands will not be correct. */
5997 know (strcmp (idesc
->name
, "alloc") == 0);
5998 /* The first operand hasn't been parsed/initialized, yet (but
5999 num_operands intentionally doesn't account for that). */
6000 i
= num_operands
> 4 ? 2 : 1;
6001 #define FORCE_CONST(n) (CURR_SLOT.opnd[n].X_op == O_constant \
6002 ? CURR_SLOT.opnd[n].X_add_number \
6004 sof
= set_regstack (FORCE_CONST(i
),
6007 FORCE_CONST(i
+ 3));
6010 /* now we can parse the first arg: */
6011 saved_input_pointer
= input_line_pointer
;
6012 input_line_pointer
= first_arg
;
6013 sep
= parse_operand_maybe_eval (CURR_SLOT
.opnd
+ 0, '=',
6014 idesc
->operands
[0]);
6016 --num_outputs
; /* force error */
6017 input_line_pointer
= saved_input_pointer
;
6019 CURR_SLOT
.opnd
[i
].X_add_number
= sof
;
6020 if (CURR_SLOT
.opnd
[i
+ 1].X_op
== O_constant
6021 && CURR_SLOT
.opnd
[i
+ 2].X_op
== O_constant
)
6022 CURR_SLOT
.opnd
[i
+ 1].X_add_number
6023 = sof
- CURR_SLOT
.opnd
[i
+ 2].X_add_number
;
6025 CURR_SLOT
.opnd
[i
+ 1].X_op
= O_illegal
;
6026 CURR_SLOT
.opnd
[i
+ 2] = CURR_SLOT
.opnd
[i
+ 3];
6029 highest_unmatched_operand
= -4;
6030 curr_out_of_range_pos
= -1;
6032 for (; idesc
; idesc
= get_next_opcode (idesc
))
6034 if (num_outputs
!= idesc
->num_outputs
)
6035 continue; /* mismatch in # of outputs */
6036 if (highest_unmatched_operand
< 0)
6037 highest_unmatched_operand
|= 1;
6038 if (num_operands
> NELEMS (idesc
->operands
)
6039 || (num_operands
< NELEMS (idesc
->operands
)
6040 && idesc
->operands
[num_operands
])
6041 || (num_operands
> 0 && !idesc
->operands
[num_operands
- 1]))
6042 continue; /* mismatch in number of arguments */
6043 if (highest_unmatched_operand
< 0)
6044 highest_unmatched_operand
|= 2;
6046 CURR_SLOT
.num_fixups
= 0;
6048 /* Try to match all operands. If we see an out-of-range operand,
6049 then continue trying to match the rest of the operands, since if
6050 the rest match, then this idesc will give the best error message. */
6052 out_of_range_pos
= -1;
6053 for (i
= 0; i
< num_operands
&& idesc
->operands
[i
]; ++i
)
6055 result
= operand_match (idesc
, i
, CURR_SLOT
.opnd
+ i
);
6056 if (result
!= OPERAND_MATCH
)
6058 if (result
!= OPERAND_OUT_OF_RANGE
)
6060 if (out_of_range_pos
< 0)
6061 /* remember position of the first out-of-range operand: */
6062 out_of_range_pos
= i
;
6066 /* If we did not match all operands, or if at least one operand was
6067 out-of-range, then this idesc does not match. Keep track of which
6068 idesc matched the most operands before failing. If we have two
6069 idescs that failed at the same position, and one had an out-of-range
6070 operand, then prefer the out-of-range operand. Thus if we have
6071 "add r0=0x1000000,r1" we get an error saying the constant is out
6072 of range instead of an error saying that the constant should have been
6075 if (i
!= num_operands
|| out_of_range_pos
>= 0)
6077 if (i
> highest_unmatched_operand
6078 || (i
== highest_unmatched_operand
6079 && out_of_range_pos
> curr_out_of_range_pos
))
6081 highest_unmatched_operand
= i
;
6082 if (out_of_range_pos
>= 0)
6084 expected_operand
= idesc
->operands
[out_of_range_pos
];
6085 error_pos
= out_of_range_pos
;
6089 expected_operand
= idesc
->operands
[i
];
6092 curr_out_of_range_pos
= out_of_range_pos
;
6101 if (expected_operand
)
6102 as_bad (_("Operand %u of `%s' should be %s"),
6103 error_pos
+ 1, mnemonic
,
6104 elf64_ia64_operands
[expected_operand
].desc
);
6105 else if (highest_unmatched_operand
< 0 && !(highest_unmatched_operand
& 1))
6106 as_bad (_("Wrong number of output operands"));
6107 else if (highest_unmatched_operand
< 0 && !(highest_unmatched_operand
& 2))
6108 as_bad (_("Wrong number of input operands"));
6110 as_bad (_("Operand mismatch"));
6114 /* Check that the instruction doesn't use
6115 - r0, f0, or f1 as output operands
6116 - the same predicate twice as output operands
6117 - r0 as address of a base update load or store
6118 - the same GR as output and address of a base update load
6119 - two even- or two odd-numbered FRs as output operands of a floating
6120 point parallel load.
6121 At most two (conflicting) output (or output-like) operands can exist,
6122 (floating point parallel loads have three outputs, but the base register,
6123 if updated, cannot conflict with the actual outputs). */
6125 for (i
= 0; i
< num_operands
; ++i
)
6130 switch (idesc
->operands
[i
])
6135 if (i
< num_outputs
)
6137 if (CURR_SLOT
.opnd
[i
].X_add_number
== REG_GR
)
6140 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6142 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6147 if (i
< num_outputs
)
6150 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6152 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6159 if (i
< num_outputs
)
6161 if (CURR_SLOT
.opnd
[i
].X_add_number
>= REG_FR
6162 && CURR_SLOT
.opnd
[i
].X_add_number
<= REG_FR
+ 1)
6165 regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
6168 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6170 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6174 if (idesc
->flags
& IA64_OPCODE_POSTINC
)
6176 if (CURR_SLOT
.opnd
[i
].X_add_number
== REG_GR
)
6179 reg1
= CURR_SLOT
.opnd
[i
].X_add_number
;
6181 reg2
= CURR_SLOT
.opnd
[i
].X_add_number
;
6192 as_warn (_("Invalid use of `%c%d' as output operand"), reg_class
, regno
);
6195 as_warn (_("Invalid use of `r%d' as base update address operand"), regno
);
6201 if (reg1
>= REG_GR
&& reg1
<= REG_GR
+ 127)
6206 else if (reg1
>= REG_P
&& reg1
<= REG_P
+ 63)
6211 else if (reg1
>= REG_FR
&& reg1
<= REG_FR
+ 127)
6219 as_warn (_("Invalid duplicate use of `%c%d'"), reg_class
, reg1
);
6221 else if (((reg1
>= REG_FR
&& reg1
<= REG_FR
+ 31
6222 && reg2
>= REG_FR
&& reg2
<= REG_FR
+ 31)
6223 || (reg1
>= REG_FR
+ 32 && reg1
<= REG_FR
+ 127
6224 && reg2
>= REG_FR
+ 32 && reg2
<= REG_FR
+ 127))
6225 && ! ((reg1
^ reg2
) & 1))
6226 as_warn (_("Invalid simultaneous use of `f%d' and `f%d'"),
6227 reg1
- REG_FR
, reg2
- REG_FR
);
6228 else if ((reg1
>= REG_FR
&& reg1
<= REG_FR
+ 31
6229 && reg2
>= REG_FR
+ 32 && reg2
<= REG_FR
+ 127)
6230 || (reg1
>= REG_FR
+ 32 && reg1
<= REG_FR
+ 127
6231 && reg2
>= REG_FR
&& reg2
<= REG_FR
+ 31))
6232 as_warn (_("Dangerous simultaneous use of `f%d' and `f%d'"),
6233 reg1
- REG_FR
, reg2
- REG_FR
);
6238 build_insn (struct slot
*slot
, bfd_vma
*insnp
)
6240 const struct ia64_operand
*odesc
, *o2desc
;
6241 struct ia64_opcode
*idesc
= slot
->idesc
;
6247 insn
= idesc
->opcode
| slot
->qp_regno
;
6249 for (i
= 0; i
< NELEMS (idesc
->operands
) && idesc
->operands
[i
]; ++i
)
6251 if (slot
->opnd
[i
].X_op
== O_register
6252 || slot
->opnd
[i
].X_op
== O_constant
6253 || slot
->opnd
[i
].X_op
== O_index
)
6254 val
= slot
->opnd
[i
].X_add_number
;
6255 else if (slot
->opnd
[i
].X_op
== O_big
)
6257 /* This must be the value 0x10000000000000000. */
6258 gas_assert (idesc
->operands
[i
] == IA64_OPND_IMM8M1U8
);
6264 switch (idesc
->operands
[i
])
6266 case IA64_OPND_IMMU64
:
6267 *insnp
++ = (val
>> 22) & 0x1ffffffffffLL
;
6268 insn
|= (((val
& 0x7f) << 13) | (((val
>> 7) & 0x1ff) << 27)
6269 | (((val
>> 16) & 0x1f) << 22) | (((val
>> 21) & 0x1) << 21)
6270 | (((val
>> 63) & 0x1) << 36));
6273 case IA64_OPND_IMMU62
:
6274 val
&= 0x3fffffffffffffffULL
;
6275 if (val
!= slot
->opnd
[i
].X_add_number
)
6276 as_warn (_("Value truncated to 62 bits"));
6277 *insnp
++ = (val
>> 21) & 0x1ffffffffffLL
;
6278 insn
|= (((val
& 0xfffff) << 6) | (((val
>> 20) & 0x1) << 36));
6281 case IA64_OPND_TGT64
:
6283 *insnp
++ = ((val
>> 20) & 0x7fffffffffLL
) << 2;
6284 insn
|= ((((val
>> 59) & 0x1) << 36)
6285 | (((val
>> 0) & 0xfffff) << 13));
6316 case IA64_OPND_R3_2
:
6317 case IA64_OPND_CPUID_R3
:
6318 case IA64_OPND_DBR_R3
:
6319 case IA64_OPND_DTR_R3
:
6320 case IA64_OPND_ITR_R3
:
6321 case IA64_OPND_IBR_R3
:
6323 case IA64_OPND_MSR_R3
:
6324 case IA64_OPND_PKR_R3
:
6325 case IA64_OPND_PMC_R3
:
6326 case IA64_OPND_PMD_R3
:
6327 case IA64_OPND_RR_R3
:
6335 odesc
= elf64_ia64_operands
+ idesc
->operands
[i
];
6336 err
= (*odesc
->insert
) (odesc
, val
, &insn
);
6338 as_bad_where (slot
->src_file
, slot
->src_line
,
6339 _("Bad operand value: %s"), err
);
6340 if (idesc
->flags
& IA64_OPCODE_PSEUDO
)
6342 if ((idesc
->flags
& IA64_OPCODE_F2_EQ_F3
)
6343 && odesc
== elf64_ia64_operands
+ IA64_OPND_F3
)
6345 o2desc
= elf64_ia64_operands
+ IA64_OPND_F2
;
6346 (*o2desc
->insert
) (o2desc
, val
, &insn
);
6348 if ((idesc
->flags
& IA64_OPCODE_LEN_EQ_64MCNT
)
6349 && (odesc
== elf64_ia64_operands
+ IA64_OPND_CPOS6a
6350 || odesc
== elf64_ia64_operands
+ IA64_OPND_POS6
))
6352 o2desc
= elf64_ia64_operands
+ IA64_OPND_LEN6
;
6353 (*o2desc
->insert
) (o2desc
, 64 - val
, &insn
);
6361 emit_one_bundle (void)
6363 int manual_bundling_off
= 0, manual_bundling
= 0;
6364 enum ia64_unit required_unit
, insn_unit
= 0;
6365 enum ia64_insn_type type
[3], insn_type
;
6366 unsigned int template_val
, orig_template
;
6367 bfd_vma insn
[3] = { -1, -1, -1 };
6368 struct ia64_opcode
*idesc
;
6369 int end_of_insn_group
= 0, user_template
= -1;
6370 int n
, i
, j
, first
, curr
, last_slot
;
6371 bfd_vma t0
= 0, t1
= 0;
6372 struct label_fix
*lfix
;
6373 bfd_boolean mark_label
;
6374 struct insn_fix
*ifix
;
6380 first
= (md
.curr_slot
+ NUM_SLOTS
- md
.num_slots_in_use
) % NUM_SLOTS
;
6381 know (first
>= 0 && first
< NUM_SLOTS
);
6382 n
= MIN (3, md
.num_slots_in_use
);
6384 /* Determine template: user user_template if specified, best match
6387 if (md
.slot
[first
].user_template
>= 0)
6388 user_template
= template_val
= md
.slot
[first
].user_template
;
6391 /* Auto select appropriate template. */
6392 memset (type
, 0, sizeof (type
));
6394 for (i
= 0; i
< n
; ++i
)
6396 if (md
.slot
[curr
].label_fixups
&& i
!= 0)
6398 type
[i
] = md
.slot
[curr
].idesc
->type
;
6399 curr
= (curr
+ 1) % NUM_SLOTS
;
6401 template_val
= best_template
[type
[0]][type
[1]][type
[2]];
6404 /* initialize instructions with appropriate nops: */
6405 for (i
= 0; i
< 3; ++i
)
6406 insn
[i
] = nop
[ia64_templ_desc
[template_val
].exec_unit
[i
]];
6410 /* Check to see if this bundle is at an offset that is a multiple of 16-bytes
6411 from the start of the frag. */
6412 addr_mod
= frag_now_fix () & 15;
6413 if (frag_now
->has_code
&& frag_now
->insn_addr
!= addr_mod
)
6414 as_bad (_("instruction address is not a multiple of 16"));
6415 frag_now
->insn_addr
= addr_mod
;
6416 frag_now
->has_code
= 1;
6418 /* now fill in slots with as many insns as possible: */
6420 idesc
= md
.slot
[curr
].idesc
;
6421 end_of_insn_group
= 0;
6423 for (i
= 0; i
< 3 && md
.num_slots_in_use
> 0; ++i
)
6425 /* If we have unwind records, we may need to update some now. */
6426 unw_rec_list
*ptr
= md
.slot
[curr
].unwind_record
;
6427 unw_rec_list
*end_ptr
= NULL
;
6431 /* Find the last prologue/body record in the list for the current
6432 insn, and set the slot number for all records up to that point.
6433 This needs to be done now, because prologue/body records refer to
6434 the current point, not the point after the instruction has been
6435 issued. This matters because there may have been nops emitted
6436 meanwhile. Any non-prologue non-body record followed by a
6437 prologue/body record must also refer to the current point. */
6438 unw_rec_list
*last_ptr
;
6440 for (j
= 1; end_ptr
== NULL
&& j
< md
.num_slots_in_use
; ++j
)
6441 end_ptr
= md
.slot
[(curr
+ j
) % NUM_SLOTS
].unwind_record
;
6442 for (last_ptr
= NULL
; ptr
!= end_ptr
; ptr
= ptr
->next
)
6443 if (ptr
->r
.type
== prologue
|| ptr
->r
.type
== prologue_gr
6444 || ptr
->r
.type
== body
)
6448 /* Make last_ptr point one after the last prologue/body
6450 last_ptr
= last_ptr
->next
;
6451 for (ptr
= md
.slot
[curr
].unwind_record
; ptr
!= last_ptr
;
6454 ptr
->slot_number
= (unsigned long) f
+ i
;
6455 ptr
->slot_frag
= frag_now
;
6457 /* Remove the initialized records, so that we won't accidentally
6458 update them again if we insert a nop and continue. */
6459 md
.slot
[curr
].unwind_record
= last_ptr
;
6463 manual_bundling_off
= md
.slot
[curr
].manual_bundling_off
;
6464 if (md
.slot
[curr
].manual_bundling_on
)
6467 manual_bundling
= 1;
6469 break; /* Need to start a new bundle. */
6472 /* If this instruction specifies a template, then it must be the first
6473 instruction of a bundle. */
6474 if (curr
!= first
&& md
.slot
[curr
].user_template
>= 0)
6477 if (idesc
->flags
& IA64_OPCODE_SLOT2
)
6479 if (manual_bundling
&& !manual_bundling_off
)
6481 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6482 _("`%s' must be last in bundle"), idesc
->name
);
6484 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6488 if (idesc
->flags
& IA64_OPCODE_LAST
)
6491 unsigned int required_template
;
6493 /* If we need a stop bit after an M slot, our only choice is
6494 template 5 (M;;MI). If we need a stop bit after a B
6495 slot, our only choice is to place it at the end of the
6496 bundle, because the only available templates are MIB,
6497 MBB, BBB, MMB, and MFB. We don't handle anything other
6498 than M and B slots because these are the only kind of
6499 instructions that can have the IA64_OPCODE_LAST bit set. */
6500 required_template
= template_val
;
6501 switch (idesc
->type
)
6505 required_template
= 5;
6513 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6514 _("Internal error: don't know how to force %s to end of instruction group"),
6520 && (i
> required_slot
6521 || (required_slot
== 2 && !manual_bundling_off
)
6522 || (user_template
>= 0
6523 /* Changing from MMI to M;MI is OK. */
6524 && (template_val
^ required_template
) > 1)))
6526 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6527 _("`%s' must be last in instruction group"),
6529 if (i
< 2 && required_slot
== 2 && !manual_bundling_off
)
6530 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6532 if (required_slot
< i
)
6533 /* Can't fit this instruction. */
6537 if (required_template
!= template_val
)
6539 /* If we switch the template, we need to reset the NOPs
6540 after slot i. The slot-types of the instructions ahead
6541 of i never change, so we don't need to worry about
6542 changing NOPs in front of this slot. */
6543 for (j
= i
; j
< 3; ++j
)
6544 insn
[j
] = nop
[ia64_templ_desc
[required_template
].exec_unit
[j
]];
6546 /* We just picked a template that includes the stop bit in the
6547 middle, so we don't need another one emitted later. */
6548 md
.slot
[curr
].end_of_insn_group
= 0;
6550 template_val
= required_template
;
6552 if (curr
!= first
&& md
.slot
[curr
].label_fixups
)
6554 if (manual_bundling
)
6556 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6557 _("Label must be first in a bundle"));
6558 manual_bundling
= -1; /* Suppress meaningless post-loop errors. */
6560 /* This insn must go into the first slot of a bundle. */
6564 if (end_of_insn_group
&& md
.num_slots_in_use
>= 1)
6566 /* We need an instruction group boundary in the middle of a
6567 bundle. See if we can switch to an other template with
6568 an appropriate boundary. */
6570 orig_template
= template_val
;
6571 if (i
== 1 && (user_template
== 4
6572 || (user_template
< 0
6573 && (ia64_templ_desc
[template_val
].exec_unit
[0]
6577 end_of_insn_group
= 0;
6579 else if (i
== 2 && (user_template
== 0
6580 || (user_template
< 0
6581 && (ia64_templ_desc
[template_val
].exec_unit
[1]
6583 /* This test makes sure we don't switch the template if
6584 the next instruction is one that needs to be first in
6585 an instruction group. Since all those instructions are
6586 in the M group, there is no way such an instruction can
6587 fit in this bundle even if we switch the template. The
6588 reason we have to check for this is that otherwise we
6589 may end up generating "MI;;I M.." which has the deadly
6590 effect that the second M instruction is no longer the
6591 first in the group! --davidm 99/12/16 */
6592 && (idesc
->flags
& IA64_OPCODE_FIRST
) == 0)
6595 end_of_insn_group
= 0;
6598 && user_template
== 0
6599 && !(idesc
->flags
& IA64_OPCODE_FIRST
))
6600 /* Use the next slot. */
6602 else if (curr
!= first
)
6603 /* can't fit this insn */
6606 if (template_val
!= orig_template
)
6607 /* if we switch the template, we need to reset the NOPs
6608 after slot i. The slot-types of the instructions ahead
6609 of i never change, so we don't need to worry about
6610 changing NOPs in front of this slot. */
6611 for (j
= i
; j
< 3; ++j
)
6612 insn
[j
] = nop
[ia64_templ_desc
[template_val
].exec_unit
[j
]];
6614 required_unit
= ia64_templ_desc
[template_val
].exec_unit
[i
];
6616 /* resolve dynamic opcodes such as "break", "hint", and "nop": */
6617 if (idesc
->type
== IA64_TYPE_DYN
)
6619 enum ia64_opnd opnd1
, opnd2
;
6621 if ((strcmp (idesc
->name
, "nop") == 0)
6622 || (strcmp (idesc
->name
, "break") == 0))
6623 insn_unit
= required_unit
;
6624 else if (strcmp (idesc
->name
, "hint") == 0)
6626 insn_unit
= required_unit
;
6627 if (required_unit
== IA64_UNIT_B
)
6633 case hint_b_warning
:
6634 as_warn (_("hint in B unit may be treated as nop"));
6637 /* When manual bundling is off and there is no
6638 user template, we choose a different unit so
6639 that hint won't go into the current slot. We
6640 will fill the current bundle with nops and
6641 try to put hint into the next bundle. */
6642 if (!manual_bundling
&& user_template
< 0)
6643 insn_unit
= IA64_UNIT_I
;
6645 as_bad (_("hint in B unit can't be used"));
6650 else if (strcmp (idesc
->name
, "chk.s") == 0
6651 || strcmp (idesc
->name
, "mov") == 0)
6653 insn_unit
= IA64_UNIT_M
;
6654 if (required_unit
== IA64_UNIT_I
6655 || (required_unit
== IA64_UNIT_F
&& template_val
== 6))
6656 insn_unit
= IA64_UNIT_I
;
6659 as_fatal (_("emit_one_bundle: unexpected dynamic op"));
6661 snprintf (mnemonic
, sizeof (mnemonic
), "%s.%c",
6662 idesc
->name
, "?imbfxx"[insn_unit
]);
6663 opnd1
= idesc
->operands
[0];
6664 opnd2
= idesc
->operands
[1];
6665 ia64_free_opcode (idesc
);
6666 idesc
= ia64_find_opcode (mnemonic
);
6667 /* moves to/from ARs have collisions */
6668 if (opnd1
== IA64_OPND_AR3
|| opnd2
== IA64_OPND_AR3
)
6670 while (idesc
!= NULL
6671 && (idesc
->operands
[0] != opnd1
6672 || idesc
->operands
[1] != opnd2
))
6673 idesc
= get_next_opcode (idesc
);
6675 md
.slot
[curr
].idesc
= idesc
;
6679 insn_type
= idesc
->type
;
6680 insn_unit
= IA64_UNIT_NIL
;
6684 if (required_unit
== IA64_UNIT_I
|| required_unit
== IA64_UNIT_M
)
6685 insn_unit
= required_unit
;
6687 case IA64_TYPE_X
: insn_unit
= IA64_UNIT_L
; break;
6688 case IA64_TYPE_I
: insn_unit
= IA64_UNIT_I
; break;
6689 case IA64_TYPE_M
: insn_unit
= IA64_UNIT_M
; break;
6690 case IA64_TYPE_B
: insn_unit
= IA64_UNIT_B
; break;
6691 case IA64_TYPE_F
: insn_unit
= IA64_UNIT_F
; break;
6696 if (insn_unit
!= required_unit
)
6697 continue; /* Try next slot. */
6699 /* Now is a good time to fix up the labels for this insn. */
6701 for (lfix
= md
.slot
[curr
].label_fixups
; lfix
; lfix
= lfix
->next
)
6703 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16);
6704 symbol_set_frag (lfix
->sym
, frag_now
);
6705 mark_label
|= lfix
->dw2_mark_labels
;
6707 for (lfix
= md
.slot
[curr
].tag_fixups
; lfix
; lfix
= lfix
->next
)
6709 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16 + i
);
6710 symbol_set_frag (lfix
->sym
, frag_now
);
6713 if (debug_type
== DEBUG_DWARF2
6714 || md
.slot
[curr
].loc_directive_seen
6717 bfd_vma addr
= frag_now
->fr_address
+ frag_now_fix () - 16 + i
;
6719 md
.slot
[curr
].loc_directive_seen
= 0;
6721 md
.slot
[curr
].debug_line
.flags
|= DWARF2_FLAG_BASIC_BLOCK
;
6723 dwarf2_gen_line_info (addr
, &md
.slot
[curr
].debug_line
);
6726 build_insn (md
.slot
+ curr
, insn
+ i
);
6728 ptr
= md
.slot
[curr
].unwind_record
;
6731 /* Set slot numbers for all remaining unwind records belonging to the
6732 current insn. There can not be any prologue/body unwind records
6734 for (; ptr
!= end_ptr
; ptr
= ptr
->next
)
6736 ptr
->slot_number
= (unsigned long) f
+ i
;
6737 ptr
->slot_frag
= frag_now
;
6739 md
.slot
[curr
].unwind_record
= NULL
;
6742 if (required_unit
== IA64_UNIT_L
)
6745 /* skip one slot for long/X-unit instructions */
6748 --md
.num_slots_in_use
;
6751 for (j
= 0; j
< md
.slot
[curr
].num_fixups
; ++j
)
6753 ifix
= md
.slot
[curr
].fixup
+ j
;
6754 fix
= fix_new_exp (frag_now
, frag_now_fix () - 16 + i
, 8,
6755 &ifix
->expr
, ifix
->is_pcrel
, ifix
->code
);
6756 fix
->tc_fix_data
.opnd
= ifix
->opnd
;
6757 fix
->fx_file
= md
.slot
[curr
].src_file
;
6758 fix
->fx_line
= md
.slot
[curr
].src_line
;
6761 end_of_insn_group
= md
.slot
[curr
].end_of_insn_group
;
6764 ia64_free_opcode (md
.slot
[curr
].idesc
);
6765 memset (md
.slot
+ curr
, 0, sizeof (md
.slot
[curr
]));
6766 md
.slot
[curr
].user_template
= -1;
6768 if (manual_bundling_off
)
6770 manual_bundling
= 0;
6773 curr
= (curr
+ 1) % NUM_SLOTS
;
6774 idesc
= md
.slot
[curr
].idesc
;
6777 /* A user template was specified, but the first following instruction did
6778 not fit. This can happen with or without manual bundling. */
6779 if (md
.num_slots_in_use
> 0 && last_slot
< 0)
6781 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6782 _("`%s' does not fit into %s template"),
6783 idesc
->name
, ia64_templ_desc
[template_val
].name
);
6784 /* Drop first insn so we don't livelock. */
6785 --md
.num_slots_in_use
;
6786 know (curr
== first
);
6787 ia64_free_opcode (md
.slot
[curr
].idesc
);
6788 memset (md
.slot
+ curr
, 0, sizeof (md
.slot
[curr
]));
6789 md
.slot
[curr
].user_template
= -1;
6791 else if (manual_bundling
> 0)
6793 if (md
.num_slots_in_use
> 0)
6796 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6797 _("`%s' does not fit into bundle"), idesc
->name
);
6802 if (template_val
== 2)
6804 else if (last_slot
== 0)
6805 where
= "slots 2 or 3";
6808 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6809 _("`%s' can't go in %s of %s template"),
6810 idesc
->name
, where
, ia64_templ_desc
[template_val
].name
);
6814 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
6815 _("Missing '}' at end of file"));
6818 know (md
.num_slots_in_use
< NUM_SLOTS
);
6820 t0
= end_of_insn_group
| (template_val
<< 1) | (insn
[0] << 5) | (insn
[1] << 46);
6821 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
6823 number_to_chars_littleendian (f
+ 0, t0
, 8);
6824 number_to_chars_littleendian (f
+ 8, t1
, 8);
6828 md_parse_option (int c
, char *arg
)
6833 /* Switches from the Intel assembler. */
6835 if (strcmp (arg
, "ilp64") == 0
6836 || strcmp (arg
, "lp64") == 0
6837 || strcmp (arg
, "p64") == 0)
6839 md
.flags
|= EF_IA_64_ABI64
;
6841 else if (strcmp (arg
, "ilp32") == 0)
6843 md
.flags
&= ~EF_IA_64_ABI64
;
6845 else if (strcmp (arg
, "le") == 0)
6847 md
.flags
&= ~EF_IA_64_BE
;
6848 default_big_endian
= 0;
6850 else if (strcmp (arg
, "be") == 0)
6852 md
.flags
|= EF_IA_64_BE
;
6853 default_big_endian
= 1;
6855 else if (strncmp (arg
, "unwind-check=", 13) == 0)
6858 if (strcmp (arg
, "warning") == 0)
6859 md
.unwind_check
= unwind_check_warning
;
6860 else if (strcmp (arg
, "error") == 0)
6861 md
.unwind_check
= unwind_check_error
;
6865 else if (strncmp (arg
, "hint.b=", 7) == 0)
6868 if (strcmp (arg
, "ok") == 0)
6869 md
.hint_b
= hint_b_ok
;
6870 else if (strcmp (arg
, "warning") == 0)
6871 md
.hint_b
= hint_b_warning
;
6872 else if (strcmp (arg
, "error") == 0)
6873 md
.hint_b
= hint_b_error
;
6877 else if (strncmp (arg
, "tune=", 5) == 0)
6880 if (strcmp (arg
, "itanium1") == 0)
6882 else if (strcmp (arg
, "itanium2") == 0)
6892 if (strcmp (arg
, "so") == 0)
6894 /* Suppress signon message. */
6896 else if (strcmp (arg
, "pi") == 0)
6898 /* Reject privileged instructions. FIXME */
6900 else if (strcmp (arg
, "us") == 0)
6902 /* Allow union of signed and unsigned range. FIXME */
6904 else if (strcmp (arg
, "close_fcalls") == 0)
6906 /* Do not resolve global function calls. */
6913 /* temp[="prefix"] Insert temporary labels into the object file
6914 symbol table prefixed by "prefix".
6915 Default prefix is ":temp:".
6920 /* indirect=<tgt> Assume unannotated indirect branches behavior
6921 according to <tgt> --
6922 exit: branch out from the current context (default)
6923 labels: all labels in context may be branch targets
6925 if (strncmp (arg
, "indirect=", 9) != 0)
6930 /* -X conflicts with an ignored option, use -x instead */
6932 if (!arg
|| strcmp (arg
, "explicit") == 0)
6934 /* set default mode to explicit */
6935 md
.default_explicit_mode
= 1;
6938 else if (strcmp (arg
, "auto") == 0)
6940 md
.default_explicit_mode
= 0;
6942 else if (strcmp (arg
, "none") == 0)
6946 else if (strcmp (arg
, "debug") == 0)
6950 else if (strcmp (arg
, "debugx") == 0)
6952 md
.default_explicit_mode
= 1;
6955 else if (strcmp (arg
, "debugn") == 0)
6962 as_bad (_("Unrecognized option '-x%s'"), arg
);
6967 /* nops Print nops statistics. */
6970 /* GNU specific switches for gcc. */
6971 case OPTION_MCONSTANT_GP
:
6972 md
.flags
|= EF_IA_64_CONS_GP
;
6975 case OPTION_MAUTO_PIC
:
6976 md
.flags
|= EF_IA_64_NOFUNCDESC_CONS_GP
;
6987 md_show_usage (FILE *stream
)
6991 --mconstant-gp mark output file as using the constant-GP model\n\
6992 (sets ELF header flag EF_IA_64_CONS_GP)\n\
6993 --mauto-pic mark output file as using the constant-GP model\n\
6994 without function descriptors (sets ELF header flag\n\
6995 EF_IA_64_NOFUNCDESC_CONS_GP)\n\
6996 -milp32|-milp64|-mlp64|-mp64 select data model (default -mlp64)\n\
6997 -mle | -mbe select little- or big-endian byte order (default -mle)\n\
6998 -mtune=[itanium1|itanium2]\n\
6999 tune for a specific CPU (default -mtune=itanium2)\n\
7000 -munwind-check=[warning|error]\n\
7001 unwind directive check (default -munwind-check=warning)\n\
7002 -mhint.b=[ok|warning|error]\n\
7003 hint.b check (default -mhint.b=error)\n\
7004 -x | -xexplicit turn on dependency violation checking\n\
7005 -xauto automagically remove dependency violations (default)\n\
7006 -xnone turn off dependency violation checking\n\
7007 -xdebug debug dependency violation checker\n\
7008 -xdebugn debug dependency violation checker but turn off\n\
7009 dependency violation checking\n\
7010 -xdebugx debug dependency violation checker and turn on\n\
7011 dependency violation checking\n"),
7016 ia64_after_parse_args (void)
7018 if (debug_type
== DEBUG_STABS
)
7019 as_fatal (_("--gstabs is not supported for ia64"));
7022 /* Return true if TYPE fits in TEMPL at SLOT. */
7025 match (int templ
, int type
, int slot
)
7027 enum ia64_unit unit
;
7030 unit
= ia64_templ_desc
[templ
].exec_unit
[slot
];
7033 case IA64_TYPE_DYN
: result
= 1; break; /* for nop and break */
7035 result
= (unit
== IA64_UNIT_I
|| unit
== IA64_UNIT_M
);
7037 case IA64_TYPE_X
: result
= (unit
== IA64_UNIT_L
); break;
7038 case IA64_TYPE_I
: result
= (unit
== IA64_UNIT_I
); break;
7039 case IA64_TYPE_M
: result
= (unit
== IA64_UNIT_M
); break;
7040 case IA64_TYPE_B
: result
= (unit
== IA64_UNIT_B
); break;
7041 case IA64_TYPE_F
: result
= (unit
== IA64_UNIT_F
); break;
7042 default: result
= 0; break;
7047 /* For Itanium 1, add a bit of extra goodness if a nop of type F or B would fit
7048 in TEMPL at SLOT. For Itanium 2, add a bit of extra goodness if a nop of
7049 type M or I would fit in TEMPL at SLOT. */
7052 extra_goodness (int templ
, int slot
)
7057 if (slot
== 1 && match (templ
, IA64_TYPE_F
, slot
))
7059 else if (slot
== 2 && match (templ
, IA64_TYPE_B
, slot
))
7065 if (match (templ
, IA64_TYPE_M
, slot
)
7066 || match (templ
, IA64_TYPE_I
, slot
))
7067 /* Favor M- and I-unit NOPs. We definitely want to avoid
7068 F-unit and B-unit may cause split-issue or less-than-optimal
7069 branch-prediction. */
7080 /* This function is called once, at assembler startup time. It sets
7081 up all the tables, etc. that the MD part of the assembler will need
7082 that can be determined before arguments are parsed. */
7086 int i
, j
, k
, t
, goodness
, best
, ok
;
7091 md
.explicit_mode
= md
.default_explicit_mode
;
7093 bfd_set_section_alignment (stdoutput
, text_section
, 4);
7095 /* Make sure function pointers get initialized. */
7096 target_big_endian
= -1;
7097 dot_byteorder (default_big_endian
);
7099 alias_hash
= hash_new ();
7100 alias_name_hash
= hash_new ();
7101 secalias_hash
= hash_new ();
7102 secalias_name_hash
= hash_new ();
7104 pseudo_func
[FUNC_DTP_MODULE
].u
.sym
=
7105 symbol_new (".<dtpmod>", undefined_section
, FUNC_DTP_MODULE
,
7106 &zero_address_frag
);
7108 pseudo_func
[FUNC_DTP_RELATIVE
].u
.sym
=
7109 symbol_new (".<dtprel>", undefined_section
, FUNC_DTP_RELATIVE
,
7110 &zero_address_frag
);
7112 pseudo_func
[FUNC_FPTR_RELATIVE
].u
.sym
=
7113 symbol_new (".<fptr>", undefined_section
, FUNC_FPTR_RELATIVE
,
7114 &zero_address_frag
);
7116 pseudo_func
[FUNC_GP_RELATIVE
].u
.sym
=
7117 symbol_new (".<gprel>", undefined_section
, FUNC_GP_RELATIVE
,
7118 &zero_address_frag
);
7120 pseudo_func
[FUNC_LT_RELATIVE
].u
.sym
=
7121 symbol_new (".<ltoff>", undefined_section
, FUNC_LT_RELATIVE
,
7122 &zero_address_frag
);
7124 pseudo_func
[FUNC_LT_RELATIVE_X
].u
.sym
=
7125 symbol_new (".<ltoffx>", undefined_section
, FUNC_LT_RELATIVE_X
,
7126 &zero_address_frag
);
7128 pseudo_func
[FUNC_PC_RELATIVE
].u
.sym
=
7129 symbol_new (".<pcrel>", undefined_section
, FUNC_PC_RELATIVE
,
7130 &zero_address_frag
);
7132 pseudo_func
[FUNC_PLT_RELATIVE
].u
.sym
=
7133 symbol_new (".<pltoff>", undefined_section
, FUNC_PLT_RELATIVE
,
7134 &zero_address_frag
);
7136 pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
=
7137 symbol_new (".<secrel>", undefined_section
, FUNC_SEC_RELATIVE
,
7138 &zero_address_frag
);
7140 pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
=
7141 symbol_new (".<segrel>", undefined_section
, FUNC_SEG_RELATIVE
,
7142 &zero_address_frag
);
7144 pseudo_func
[FUNC_TP_RELATIVE
].u
.sym
=
7145 symbol_new (".<tprel>", undefined_section
, FUNC_TP_RELATIVE
,
7146 &zero_address_frag
);
7148 pseudo_func
[FUNC_LTV_RELATIVE
].u
.sym
=
7149 symbol_new (".<ltv>", undefined_section
, FUNC_LTV_RELATIVE
,
7150 &zero_address_frag
);
7152 pseudo_func
[FUNC_LT_FPTR_RELATIVE
].u
.sym
=
7153 symbol_new (".<ltoff.fptr>", undefined_section
, FUNC_LT_FPTR_RELATIVE
,
7154 &zero_address_frag
);
7156 pseudo_func
[FUNC_LT_DTP_MODULE
].u
.sym
=
7157 symbol_new (".<ltoff.dtpmod>", undefined_section
, FUNC_LT_DTP_MODULE
,
7158 &zero_address_frag
);
7160 pseudo_func
[FUNC_LT_DTP_RELATIVE
].u
.sym
=
7161 symbol_new (".<ltoff.dptrel>", undefined_section
, FUNC_LT_DTP_RELATIVE
,
7162 &zero_address_frag
);
7164 pseudo_func
[FUNC_LT_TP_RELATIVE
].u
.sym
=
7165 symbol_new (".<ltoff.tprel>", undefined_section
, FUNC_LT_TP_RELATIVE
,
7166 &zero_address_frag
);
7168 pseudo_func
[FUNC_IPLT_RELOC
].u
.sym
=
7169 symbol_new (".<iplt>", undefined_section
, FUNC_IPLT_RELOC
,
7170 &zero_address_frag
);
7173 pseudo_func
[FUNC_SLOTCOUNT_RELOC
].u
.sym
=
7174 symbol_new (".<slotcount>", undefined_section
, FUNC_SLOTCOUNT_RELOC
,
7175 &zero_address_frag
);
7178 if (md
.tune
!= itanium1
)
7180 /* Convert MFI NOPs bundles into MMI NOPs bundles. */
7182 le_nop_stop
[0] = 0x9;
7185 /* Compute the table of best templates. We compute goodness as a
7186 base 4 value, in which each match counts for 3. Match-failures
7187 result in NOPs and we use extra_goodness() to pick the execution
7188 units that are best suited for issuing the NOP. */
7189 for (i
= 0; i
< IA64_NUM_TYPES
; ++i
)
7190 for (j
= 0; j
< IA64_NUM_TYPES
; ++j
)
7191 for (k
= 0; k
< IA64_NUM_TYPES
; ++k
)
7194 for (t
= 0; t
< NELEMS (ia64_templ_desc
); ++t
)
7197 if (match (t
, i
, 0))
7199 if (match (t
, j
, 1))
7201 if ((t
== 2 && j
== IA64_TYPE_X
) || match (t
, k
, 2))
7202 goodness
= 3 + 3 + 3;
7204 goodness
= 3 + 3 + extra_goodness (t
, 2);
7206 else if (match (t
, j
, 2))
7207 goodness
= 3 + 3 + extra_goodness (t
, 1);
7211 goodness
+= extra_goodness (t
, 1);
7212 goodness
+= extra_goodness (t
, 2);
7215 else if (match (t
, i
, 1))
7217 if ((t
== 2 && i
== IA64_TYPE_X
) || match (t
, j
, 2))
7220 goodness
= 3 + extra_goodness (t
, 2);
7222 else if (match (t
, i
, 2))
7223 goodness
= 3 + extra_goodness (t
, 1);
7225 if (goodness
> best
)
7228 best_template
[i
][j
][k
] = t
;
7233 #ifdef DEBUG_TEMPLATES
7234 /* For debugging changes to the best_template calculations. We don't care
7235 about combinations with invalid instructions, so start the loops at 1. */
7236 for (i
= 0; i
< IA64_NUM_TYPES
; ++i
)
7237 for (j
= 0; j
< IA64_NUM_TYPES
; ++j
)
7238 for (k
= 0; k
< IA64_NUM_TYPES
; ++k
)
7240 char type_letter
[IA64_NUM_TYPES
] = { 'n', 'a', 'i', 'm', 'b', 'f',
7242 fprintf (stderr
, "%c%c%c %s\n", type_letter
[i
], type_letter
[j
],
7244 ia64_templ_desc
[best_template
[i
][j
][k
]].name
);
7248 for (i
= 0; i
< NUM_SLOTS
; ++i
)
7249 md
.slot
[i
].user_template
= -1;
7251 md
.pseudo_hash
= hash_new ();
7252 for (i
= 0; i
< NELEMS (pseudo_opcode
); ++i
)
7254 err
= hash_insert (md
.pseudo_hash
, pseudo_opcode
[i
].name
,
7255 (void *) (pseudo_opcode
+ i
));
7257 as_fatal (_("ia64.md_begin: can't hash `%s': %s"),
7258 pseudo_opcode
[i
].name
, err
);
7261 md
.reg_hash
= hash_new ();
7262 md
.dynreg_hash
= hash_new ();
7263 md
.const_hash
= hash_new ();
7264 md
.entry_hash
= hash_new ();
7266 /* general registers: */
7267 declare_register_set ("r", 128, REG_GR
);
7268 declare_register ("gp", REG_GR
+ 1);
7269 declare_register ("sp", REG_GR
+ 12);
7270 declare_register ("tp", REG_GR
+ 13);
7271 declare_register_set ("ret", 4, REG_GR
+ 8);
7273 /* floating point registers: */
7274 declare_register_set ("f", 128, REG_FR
);
7275 declare_register_set ("farg", 8, REG_FR
+ 8);
7276 declare_register_set ("fret", 8, REG_FR
+ 8);
7278 /* branch registers: */
7279 declare_register_set ("b", 8, REG_BR
);
7280 declare_register ("rp", REG_BR
+ 0);
7282 /* predicate registers: */
7283 declare_register_set ("p", 64, REG_P
);
7284 declare_register ("pr", REG_PR
);
7285 declare_register ("pr.rot", REG_PR_ROT
);
7287 /* application registers: */
7288 declare_register_set ("ar", 128, REG_AR
);
7289 for (i
= 0; i
< NELEMS (ar
); ++i
)
7290 declare_register (ar
[i
].name
, REG_AR
+ ar
[i
].regnum
);
7292 /* control registers: */
7293 declare_register_set ("cr", 128, REG_CR
);
7294 for (i
= 0; i
< NELEMS (cr
); ++i
)
7295 declare_register (cr
[i
].name
, REG_CR
+ cr
[i
].regnum
);
7297 declare_register ("ip", REG_IP
);
7298 declare_register ("cfm", REG_CFM
);
7299 declare_register ("psr", REG_PSR
);
7300 declare_register ("psr.l", REG_PSR_L
);
7301 declare_register ("psr.um", REG_PSR_UM
);
7303 for (i
= 0; i
< NELEMS (indirect_reg
); ++i
)
7305 unsigned int regnum
= indirect_reg
[i
].regnum
;
7307 md
.indregsym
[regnum
- IND_CPUID
] = declare_register (indirect_reg
[i
].name
, regnum
);
7310 /* pseudo-registers used to specify unwind info: */
7311 declare_register ("psp", REG_PSP
);
7313 for (i
= 0; i
< NELEMS (const_bits
); ++i
)
7315 err
= hash_insert (md
.const_hash
, const_bits
[i
].name
,
7316 (void *) (const_bits
+ i
));
7318 as_fatal (_("Inserting \"%s\" into constant hash table failed: %s"),
7322 /* Set the architecture and machine depending on defaults and command line
7324 if (md
.flags
& EF_IA_64_ABI64
)
7325 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf64
);
7327 ok
= bfd_set_arch_mach (stdoutput
, bfd_arch_ia64
, bfd_mach_ia64_elf32
);
7330 as_warn (_("Could not set architecture and machine"));
7332 /* Set the pointer size and pointer shift size depending on md.flags */
7334 if (md
.flags
& EF_IA_64_ABI64
)
7336 md
.pointer_size
= 8; /* pointers are 8 bytes */
7337 md
.pointer_size_shift
= 3; /* alignment is 8 bytes = 2^2 */
7341 md
.pointer_size
= 4; /* pointers are 4 bytes */
7342 md
.pointer_size_shift
= 2; /* alignment is 4 bytes = 2^2 */
7345 md
.mem_offset
.hint
= 0;
7348 md
.entry_labels
= NULL
;
7351 /* Set the default options in md. Cannot do this in md_begin because
7352 that is called after md_parse_option which is where we set the
7353 options in md based on command line options. */
7356 ia64_init (int argc ATTRIBUTE_UNUSED
, char **argv ATTRIBUTE_UNUSED
)
7358 md
.flags
= MD_FLAGS_DEFAULT
;
7360 /* Don't turn on dependency checking for VMS, doesn't work. */
7363 /* FIXME: We should change it to unwind_check_error someday. */
7364 md
.unwind_check
= unwind_check_warning
;
7365 md
.hint_b
= hint_b_error
;
7369 /* Return a string for the target object file format. */
7372 ia64_target_format (void)
7374 if (OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
7376 if (md
.flags
& EF_IA_64_BE
)
7378 if (md
.flags
& EF_IA_64_ABI64
)
7379 #if defined(TE_AIX50)
7380 return "elf64-ia64-aix-big";
7381 #elif defined(TE_HPUX)
7382 return "elf64-ia64-hpux-big";
7384 return "elf64-ia64-big";
7387 #if defined(TE_AIX50)
7388 return "elf32-ia64-aix-big";
7389 #elif defined(TE_HPUX)
7390 return "elf32-ia64-hpux-big";
7392 return "elf32-ia64-big";
7397 if (md
.flags
& EF_IA_64_ABI64
)
7398 #if defined (TE_AIX50)
7399 return "elf64-ia64-aix-little";
7400 #elif defined (TE_VMS)
7402 md
.flags
|= EF_IA_64_ARCHVER_1
;
7403 return "elf64-ia64-vms";
7406 return "elf64-ia64-little";
7410 return "elf32-ia64-aix-little";
7412 return "elf32-ia64-little";
7417 return "unknown-format";
7421 ia64_end_of_source (void)
7423 /* terminate insn group upon reaching end of file: */
7424 insn_group_break (1, 0, 0);
7426 /* emits slots we haven't written yet: */
7427 ia64_flush_insns ();
7429 bfd_set_private_flags (stdoutput
, md
.flags
);
7431 md
.mem_offset
.hint
= 0;
7435 ia64_start_line (void)
7440 /* Make sure we don't reference input_line_pointer[-1] when that's
7446 if (md
.qp
.X_op
== O_register
)
7447 as_bad (_("qualifying predicate not followed by instruction"));
7448 md
.qp
.X_op
= O_absent
;
7450 if (ignore_input ())
7453 if (input_line_pointer
[0] == ';' && input_line_pointer
[-1] == ';')
7455 if (md
.detect_dv
&& !md
.explicit_mode
)
7462 as_warn (_("Explicit stops are ignored in auto mode"));
7466 insn_group_break (1, 0, 0);
7468 else if (input_line_pointer
[-1] == '{')
7470 if (md
.manual_bundling
)
7471 as_warn (_("Found '{' when manual bundling is already turned on"));
7473 CURR_SLOT
.manual_bundling_on
= 1;
7474 md
.manual_bundling
= 1;
7476 /* Bundling is only acceptable in explicit mode
7477 or when in default automatic mode. */
7478 if (md
.detect_dv
&& !md
.explicit_mode
)
7480 if (!md
.mode_explicitly_set
7481 && !md
.default_explicit_mode
)
7484 as_warn (_("Found '{' after explicit switch to automatic mode"));
7487 else if (input_line_pointer
[-1] == '}')
7489 if (!md
.manual_bundling
)
7490 as_warn (_("Found '}' when manual bundling is off"));
7492 PREV_SLOT
.manual_bundling_off
= 1;
7493 md
.manual_bundling
= 0;
7495 /* switch back to automatic mode, if applicable */
7498 && !md
.mode_explicitly_set
7499 && !md
.default_explicit_mode
)
7504 /* This is a hook for ia64_frob_label, so that it can distinguish tags from
7506 static int defining_tag
= 0;
7509 ia64_unrecognized_line (int ch
)
7514 expression_and_evaluate (&md
.qp
);
7515 if (*input_line_pointer
++ != ')')
7517 as_bad (_("Expected ')'"));
7520 if (md
.qp
.X_op
!= O_register
)
7522 as_bad (_("Qualifying predicate expected"));
7525 if (md
.qp
.X_add_number
< REG_P
|| md
.qp
.X_add_number
>= REG_P
+ 64)
7527 as_bad (_("Predicate register expected"));
7539 if (md
.qp
.X_op
== O_register
)
7541 as_bad (_("Tag must come before qualifying predicate."));
7545 /* This implements just enough of read_a_source_file in read.c to
7546 recognize labels. */
7547 if (is_name_beginner (*input_line_pointer
))
7549 s
= input_line_pointer
;
7550 c
= get_symbol_end ();
7552 else if (LOCAL_LABELS_FB
7553 && ISDIGIT (*input_line_pointer
))
7556 while (ISDIGIT (*input_line_pointer
))
7557 temp
= (temp
* 10) + *input_line_pointer
++ - '0';
7558 fb_label_instance_inc (temp
);
7559 s
= fb_label_name (temp
, 0);
7560 c
= *input_line_pointer
;
7569 /* Put ':' back for error messages' sake. */
7570 *input_line_pointer
++ = ':';
7571 as_bad (_("Expected ':'"));
7578 /* Put ':' back for error messages' sake. */
7579 *input_line_pointer
++ = ':';
7580 if (*input_line_pointer
++ != ']')
7582 as_bad (_("Expected ']'"));
7587 as_bad (_("Tag name expected"));
7597 /* Not a valid line. */
7602 ia64_frob_label (struct symbol
*sym
)
7604 struct label_fix
*fix
;
7606 /* Tags need special handling since they are not bundle breaks like
7610 fix
= obstack_alloc (¬es
, sizeof (*fix
));
7612 fix
->next
= CURR_SLOT
.tag_fixups
;
7613 fix
->dw2_mark_labels
= FALSE
;
7614 CURR_SLOT
.tag_fixups
= fix
;
7619 if (bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7621 md
.last_text_seg
= now_seg
;
7622 fix
= obstack_alloc (¬es
, sizeof (*fix
));
7624 fix
->next
= CURR_SLOT
.label_fixups
;
7625 fix
->dw2_mark_labels
= dwarf2_loc_mark_labels
;
7626 CURR_SLOT
.label_fixups
= fix
;
7628 /* Keep track of how many code entry points we've seen. */
7629 if (md
.path
== md
.maxpaths
)
7632 md
.entry_labels
= (const char **)
7633 xrealloc ((void *) md
.entry_labels
,
7634 md
.maxpaths
* sizeof (char *));
7636 md
.entry_labels
[md
.path
++] = S_GET_NAME (sym
);
7641 /* The HP-UX linker will give unresolved symbol errors for symbols
7642 that are declared but unused. This routine removes declared,
7643 unused symbols from an object. */
7645 ia64_frob_symbol (struct symbol
*sym
)
7647 if ((S_GET_SEGMENT (sym
) == &bfd_und_section
&& ! symbol_used_p (sym
) &&
7648 ELF_ST_VISIBILITY (S_GET_OTHER (sym
)) == STV_DEFAULT
)
7649 || (S_GET_SEGMENT (sym
) == &bfd_abs_section
7650 && ! S_IS_EXTERNAL (sym
)))
7657 ia64_flush_pending_output (void)
7659 if (!md
.keep_pending_output
7660 && bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
7662 /* ??? This causes many unnecessary stop bits to be emitted.
7663 Unfortunately, it isn't clear if it is safe to remove this. */
7664 insn_group_break (1, 0, 0);
7665 ia64_flush_insns ();
7669 /* Do ia64-specific expression optimization. All that's done here is
7670 to transform index expressions that are either due to the indexing
7671 of rotating registers or due to the indexing of indirect register
7674 ia64_optimize_expr (expressionS
*l
, operatorT op
, expressionS
*r
)
7678 resolve_expression (l
);
7679 if (l
->X_op
== O_register
)
7681 unsigned num_regs
= l
->X_add_number
>> 16;
7683 resolve_expression (r
);
7686 /* Left side is a .rotX-allocated register. */
7687 if (r
->X_op
!= O_constant
)
7689 as_bad (_("Rotating register index must be a non-negative constant"));
7690 r
->X_add_number
= 0;
7692 else if ((valueT
) r
->X_add_number
>= num_regs
)
7694 as_bad (_("Index out of range 0..%u"), num_regs
- 1);
7695 r
->X_add_number
= 0;
7697 l
->X_add_number
= (l
->X_add_number
& 0xffff) + r
->X_add_number
;
7700 else if (l
->X_add_number
>= IND_CPUID
&& l
->X_add_number
<= IND_RR
)
7702 if (r
->X_op
!= O_register
7703 || r
->X_add_number
< REG_GR
7704 || r
->X_add_number
> REG_GR
+ 127)
7706 as_bad (_("Indirect register index must be a general register"));
7707 r
->X_add_number
= REG_GR
;
7710 l
->X_op_symbol
= md
.indregsym
[l
->X_add_number
- IND_CPUID
];
7711 l
->X_add_number
= r
->X_add_number
;
7715 as_bad (_("Index can only be applied to rotating or indirect registers"));
7716 /* Fall back to some register use of which has as little as possible
7717 side effects, to minimize subsequent error messages. */
7718 l
->X_op
= O_register
;
7719 l
->X_add_number
= REG_GR
+ 3;
7724 ia64_parse_name (char *name
, expressionS
*e
, char *nextcharP
)
7726 struct const_desc
*cdesc
;
7727 struct dynreg
*dr
= 0;
7734 enum pseudo_type pseudo_type
= PSEUDO_FUNC_NONE
;
7736 /* Find what relocation pseudo-function we're dealing with. */
7737 for (idx
= 0; idx
< NELEMS (pseudo_func
); ++idx
)
7738 if (pseudo_func
[idx
].name
7739 && pseudo_func
[idx
].name
[0] == name
[1]
7740 && strcmp (pseudo_func
[idx
].name
+ 1, name
+ 2) == 0)
7742 pseudo_type
= pseudo_func
[idx
].type
;
7745 switch (pseudo_type
)
7747 case PSEUDO_FUNC_RELOC
:
7748 end
= input_line_pointer
;
7749 if (*nextcharP
!= '(')
7751 as_bad (_("Expected '('"));
7755 ++input_line_pointer
;
7757 if (*input_line_pointer
!= ')')
7759 as_bad (_("Missing ')'"));
7763 ++input_line_pointer
;
7765 if (idx
== FUNC_SLOTCOUNT_RELOC
)
7767 /* @slotcount can accept any expression. Canonicalize. */
7768 e
->X_add_symbol
= make_expr_symbol (e
);
7770 e
->X_add_number
= 0;
7773 if (e
->X_op
!= O_symbol
)
7775 if (e
->X_op
!= O_pseudo_fixup
)
7777 as_bad (_("Not a symbolic expression"));
7780 if (idx
!= FUNC_LT_RELATIVE
)
7782 as_bad (_("Illegal combination of relocation functions"));
7785 switch (S_GET_VALUE (e
->X_op_symbol
))
7787 case FUNC_FPTR_RELATIVE
:
7788 idx
= FUNC_LT_FPTR_RELATIVE
; break;
7789 case FUNC_DTP_MODULE
:
7790 idx
= FUNC_LT_DTP_MODULE
; break;
7791 case FUNC_DTP_RELATIVE
:
7792 idx
= FUNC_LT_DTP_RELATIVE
; break;
7793 case FUNC_TP_RELATIVE
:
7794 idx
= FUNC_LT_TP_RELATIVE
; break;
7796 as_bad (_("Illegal combination of relocation functions"));
7800 /* Make sure gas doesn't get rid of local symbols that are used
7802 e
->X_op
= O_pseudo_fixup
;
7803 e
->X_op_symbol
= pseudo_func
[idx
].u
.sym
;
7805 *nextcharP
= *input_line_pointer
;
7808 case PSEUDO_FUNC_CONST
:
7809 e
->X_op
= O_constant
;
7810 e
->X_add_number
= pseudo_func
[idx
].u
.ival
;
7813 case PSEUDO_FUNC_REG
:
7814 e
->X_op
= O_register
;
7815 e
->X_add_number
= pseudo_func
[idx
].u
.ival
;
7824 /* first see if NAME is a known register name: */
7825 sym
= hash_find (md
.reg_hash
, name
);
7828 e
->X_op
= O_register
;
7829 e
->X_add_number
= S_GET_VALUE (sym
);
7833 cdesc
= hash_find (md
.const_hash
, name
);
7836 e
->X_op
= O_constant
;
7837 e
->X_add_number
= cdesc
->value
;
7841 /* check for inN, locN, or outN: */
7846 if (name
[1] == 'n' && ISDIGIT (name
[2]))
7854 if (name
[1] == 'o' && name
[2] == 'c' && ISDIGIT (name
[3]))
7862 if (name
[1] == 'u' && name
[2] == 't' && ISDIGIT (name
[3]))
7873 /* Ignore register numbers with leading zeroes, except zero itself. */
7874 if (dr
&& (name
[idx
] != '0' || name
[idx
+ 1] == '\0'))
7876 unsigned long regnum
;
7878 /* The name is inN, locN, or outN; parse the register number. */
7879 regnum
= strtoul (name
+ idx
, &end
, 10);
7880 if (end
> name
+ idx
&& *end
== '\0' && regnum
< 96)
7882 if (regnum
>= dr
->num_regs
)
7885 as_bad (_("No current frame"));
7887 as_bad (_("Register number out of range 0..%u"),
7891 e
->X_op
= O_register
;
7892 e
->X_add_number
= dr
->base
+ regnum
;
7897 end
= alloca (strlen (name
) + 1);
7899 name
= ia64_canonicalize_symbol_name (end
);
7900 if ((dr
= hash_find (md
.dynreg_hash
, name
)))
7902 /* We've got ourselves the name of a rotating register set.
7903 Store the base register number in the low 16 bits of
7904 X_add_number and the size of the register set in the top 16
7906 e
->X_op
= O_register
;
7907 e
->X_add_number
= dr
->base
| (dr
->num_regs
<< 16);
7913 /* Remove the '#' suffix that indicates a symbol as opposed to a register. */
7916 ia64_canonicalize_symbol_name (char *name
)
7918 size_t len
= strlen (name
), full
= len
;
7920 while (len
> 0 && name
[len
- 1] == '#')
7925 as_bad (_("Standalone `#' is illegal"));
7927 else if (len
< full
- 1)
7928 as_warn (_("Redundant `#' suffix operators"));
7933 /* Return true if idesc is a conditional branch instruction. This excludes
7934 the modulo scheduled branches, and br.ia. Mod-sched branches are excluded
7935 because they always read/write resources regardless of the value of the
7936 qualifying predicate. br.ia must always use p0, and hence is always
7937 taken. Thus this function returns true for branches which can fall
7938 through, and which use no resources if they do fall through. */
7941 is_conditional_branch (struct ia64_opcode
*idesc
)
7943 /* br is a conditional branch. Everything that starts with br. except
7944 br.ia, br.c{loop,top,exit}, and br.w{top,exit} is a conditional branch.
7945 Everything that starts with brl is a conditional branch. */
7946 return (idesc
->name
[0] == 'b' && idesc
->name
[1] == 'r'
7947 && (idesc
->name
[2] == '\0'
7948 || (idesc
->name
[2] == '.' && idesc
->name
[3] != 'i'
7949 && idesc
->name
[3] != 'c' && idesc
->name
[3] != 'w')
7950 || idesc
->name
[2] == 'l'
7951 /* br.cond, br.call, br.clr */
7952 || (idesc
->name
[2] == '.' && idesc
->name
[3] == 'c'
7953 && (idesc
->name
[4] == 'a' || idesc
->name
[4] == 'o'
7954 || (idesc
->name
[4] == 'l' && idesc
->name
[5] == 'r')))));
7957 /* Return whether the given opcode is a taken branch. If there's any doubt,
7961 is_taken_branch (struct ia64_opcode
*idesc
)
7963 return ((is_conditional_branch (idesc
) && CURR_SLOT
.qp_regno
== 0)
7964 || strncmp (idesc
->name
, "br.ia", 5) == 0);
7967 /* Return whether the given opcode is an interruption or rfi. If there's any
7968 doubt, returns zero. */
7971 is_interruption_or_rfi (struct ia64_opcode
*idesc
)
7973 if (strcmp (idesc
->name
, "rfi") == 0)
7978 /* Returns the index of the given dependency in the opcode's list of chks, or
7979 -1 if there is no dependency. */
7982 depends_on (int depind
, struct ia64_opcode
*idesc
)
7985 const struct ia64_opcode_dependency
*dep
= idesc
->dependencies
;
7986 for (i
= 0; i
< dep
->nchks
; i
++)
7988 if (depind
== DEP (dep
->chks
[i
]))
7994 /* Determine a set of specific resources used for a particular resource
7995 class. Returns the number of specific resources identified For those
7996 cases which are not determinable statically, the resource returned is
7999 Meanings of value in 'NOTE':
8000 1) only read/write when the register number is explicitly encoded in the
8002 2) only read CFM when accessing a rotating GR, FR, or PR. mov pr only
8003 accesses CFM when qualifying predicate is in the rotating region.
8004 3) general register value is used to specify an indirect register; not
8005 determinable statically.
8006 4) only read the given resource when bits 7:0 of the indirect index
8007 register value does not match the register number of the resource; not
8008 determinable statically.
8009 5) all rules are implementation specific.
8010 6) only when both the index specified by the reader and the index specified
8011 by the writer have the same value in bits 63:61; not determinable
8013 7) only access the specified resource when the corresponding mask bit is
8015 8) PSR.dfh is only read when these insns reference FR32-127. PSR.dfl is
8016 only read when these insns reference FR2-31
8017 9) PSR.mfl is only written when these insns write FR2-31. PSR.mfh is only
8018 written when these insns write FR32-127
8019 10) The PSR.bn bit is only accessed when one of GR16-31 is specified in the
8021 11) The target predicates are written independently of PR[qp], but source
8022 registers are only read if PR[qp] is true. Since the state of PR[qp]
8023 cannot statically be determined, all source registers are marked used.
8024 12) This insn only reads the specified predicate register when that
8025 register is the PR[qp].
8026 13) This reference to ld-c only applies to the GR whose value is loaded
8027 with data returned from memory, not the post-incremented address register.
8028 14) The RSE resource includes the implementation-specific RSE internal
8029 state resources. At least one (and possibly more) of these resources are
8030 read by each instruction listed in IC:rse-readers. At least one (and
8031 possibly more) of these resources are written by each insn listed in
8033 15+16) Represents reserved instructions, which the assembler does not
8035 17) CR[TPR] has a RAW dependency only between mov-to-CR-TPR and
8036 mov-to-PSR-l or ssm instructions that set PSR.i, PSR.pp or PSR.up.
8038 Memory resources (i.e. locations in memory) are *not* marked or tracked by
8039 this code; there are no dependency violations based on memory access.
8042 #define MAX_SPECS 256
8047 specify_resource (const struct ia64_dependency
*dep
,
8048 struct ia64_opcode
*idesc
,
8049 /* is this a DV chk or a DV reg? */
8051 /* returned specific resources */
8052 struct rsrc specs
[MAX_SPECS
],
8053 /* resource note for this insn's usage */
8055 /* which execution path to examine */
8063 if (dep
->mode
== IA64_DV_WAW
8064 || (dep
->mode
== IA64_DV_RAW
&& type
== DV_REG
)
8065 || (dep
->mode
== IA64_DV_WAR
&& type
== DV_CHK
))
8068 /* template for any resources we identify */
8069 tmpl
.dependency
= dep
;
8071 tmpl
.insn_srlz
= tmpl
.data_srlz
= 0;
8072 tmpl
.qp_regno
= CURR_SLOT
.qp_regno
;
8073 tmpl
.link_to_qp_branch
= 1;
8074 tmpl
.mem_offset
.hint
= 0;
8075 tmpl
.mem_offset
.offset
= 0;
8076 tmpl
.mem_offset
.base
= 0;
8079 tmpl
.cmp_type
= CMP_NONE
;
8086 as_warn (_("Unhandled dependency %s for %s (%s), note %d"), \
8087 dep->name, idesc->name, (rsrc_write?"write":"read"), note)
8088 #define KNOWN(REG) (gr_values[REG].known && gr_values[REG].path >= path)
8090 /* we don't need to track these */
8091 if (dep
->semantics
== IA64_DVS_NONE
)
8094 switch (dep
->specifier
)
8099 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8101 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8102 if (regno
>= 0 && regno
<= 7)
8104 specs
[count
] = tmpl
;
8105 specs
[count
++].index
= regno
;
8111 for (i
= 0; i
< 8; i
++)
8113 specs
[count
] = tmpl
;
8114 specs
[count
++].index
= i
;
8123 case IA64_RS_AR_UNAT
:
8124 /* This is a mov =AR or mov AR= instruction. */
8125 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8127 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8128 if (regno
== AR_UNAT
)
8130 specs
[count
++] = tmpl
;
8135 /* This is a spill/fill, or other instruction that modifies the
8138 /* Unless we can determine the specific bits used, mark the whole
8139 thing; bits 8:3 of the memory address indicate the bit used in
8140 UNAT. The .mem.offset hint may be used to eliminate a small
8141 subset of conflicts. */
8142 specs
[count
] = tmpl
;
8143 if (md
.mem_offset
.hint
)
8146 fprintf (stderr
, " Using hint for spill/fill\n");
8147 /* The index isn't actually used, just set it to something
8148 approximating the bit index. */
8149 specs
[count
].index
= (md
.mem_offset
.offset
>> 3) & 0x3F;
8150 specs
[count
].mem_offset
.hint
= 1;
8151 specs
[count
].mem_offset
.offset
= md
.mem_offset
.offset
;
8152 specs
[count
++].mem_offset
.base
= md
.mem_offset
.base
;
8156 specs
[count
++].specific
= 0;
8164 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8166 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8167 if ((regno
>= 8 && regno
<= 15)
8168 || (regno
>= 20 && regno
<= 23)
8169 || (regno
>= 31 && regno
<= 39)
8170 || (regno
>= 41 && regno
<= 47)
8171 || (regno
>= 67 && regno
<= 111))
8173 specs
[count
] = tmpl
;
8174 specs
[count
++].index
= regno
;
8187 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
8189 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
8190 if ((regno
>= 48 && regno
<= 63)
8191 || (regno
>= 112 && regno
<= 127))
8193 specs
[count
] = tmpl
;
8194 specs
[count
++].index
= regno
;
8200 for (i
= 48; i
< 64; i
++)
8202 specs
[count
] = tmpl
;
8203 specs
[count
++].index
= i
;
8205 for (i
= 112; i
< 128; i
++)
8207 specs
[count
] = tmpl
;
8208 specs
[count
++].index
= i
;
8226 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8227 if (idesc
->operands
[i
] == IA64_OPND_B1
8228 || idesc
->operands
[i
] == IA64_OPND_B2
)
8230 specs
[count
] = tmpl
;
8231 specs
[count
++].index
=
8232 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
8237 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
8238 if (idesc
->operands
[i
] == IA64_OPND_B1
8239 || idesc
->operands
[i
] == IA64_OPND_B2
)
8241 specs
[count
] = tmpl
;
8242 specs
[count
++].index
=
8243 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
8249 case IA64_RS_CPUID
: /* four or more registers */
8252 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CPUID_R3
)
8254 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8255 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8258 specs
[count
] = tmpl
;
8259 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8263 specs
[count
] = tmpl
;
8264 specs
[count
++].specific
= 0;
8274 case IA64_RS_DBR
: /* four or more registers */
8277 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_DBR_R3
)
8279 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8280 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8283 specs
[count
] = tmpl
;
8284 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8288 specs
[count
] = tmpl
;
8289 specs
[count
++].specific
= 0;
8293 else if (note
== 0 && !rsrc_write
)
8295 specs
[count
] = tmpl
;
8296 specs
[count
++].specific
= 0;
8304 case IA64_RS_IBR
: /* four or more registers */
8307 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_IBR_R3
)
8309 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8310 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8313 specs
[count
] = tmpl
;
8314 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8318 specs
[count
] = tmpl
;
8319 specs
[count
++].specific
= 0;
8332 /* These are implementation specific. Force all references to
8333 conflict with all other references. */
8334 specs
[count
] = tmpl
;
8335 specs
[count
++].specific
= 0;
8343 case IA64_RS_PKR
: /* 16 or more registers */
8344 if (note
== 3 || note
== 4)
8346 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PKR_R3
)
8348 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8349 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8354 specs
[count
] = tmpl
;
8355 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8358 for (i
= 0; i
< NELEMS (gr_values
); i
++)
8360 /* Uses all registers *except* the one in R3. */
8361 if ((unsigned)i
!= (gr_values
[regno
].value
& 0xFF))
8363 specs
[count
] = tmpl
;
8364 specs
[count
++].index
= i
;
8370 specs
[count
] = tmpl
;
8371 specs
[count
++].specific
= 0;
8378 specs
[count
] = tmpl
;
8379 specs
[count
++].specific
= 0;
8383 case IA64_RS_PMC
: /* four or more registers */
8386 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMC_R3
8387 || (!rsrc_write
&& idesc
->operands
[1] == IA64_OPND_PMD_R3
))
8390 int reg_index
= ((idesc
->operands
[1] == IA64_OPND_R3
&& !rsrc_write
)
8392 int regno
= CURR_SLOT
.opnd
[reg_index
].X_add_number
- REG_GR
;
8393 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8396 specs
[count
] = tmpl
;
8397 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8401 specs
[count
] = tmpl
;
8402 specs
[count
++].specific
= 0;
8412 case IA64_RS_PMD
: /* four or more registers */
8415 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMD_R3
)
8417 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8418 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8421 specs
[count
] = tmpl
;
8422 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
8426 specs
[count
] = tmpl
;
8427 specs
[count
++].specific
= 0;
8437 case IA64_RS_RR
: /* eight registers */
8440 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_RR_R3
)
8442 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
8443 if (regno
>= 0 && regno
< NELEMS (gr_values
)
8446 specs
[count
] = tmpl
;
8447 specs
[count
++].index
= (gr_values
[regno
].value
>> 61) & 0x7;
8451 specs
[count
] = tmpl
;
8452 specs
[count
++].specific
= 0;
8456 else if (note
== 0 && !rsrc_write
)
8458 specs
[count
] = tmpl
;
8459 specs
[count
++].specific
= 0;
8467 case IA64_RS_CR_IRR
:
8470 /* handle mov-from-CR-IVR; it's a read that writes CR[IRR] */
8471 int regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
;
8473 && idesc
->operands
[1] == IA64_OPND_CR3
8476 for (i
= 0; i
< 4; i
++)
8478 specs
[count
] = tmpl
;
8479 specs
[count
++].index
= CR_IRR0
+ i
;
8485 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8486 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
8488 && regno
<= CR_IRR3
)
8490 specs
[count
] = tmpl
;
8491 specs
[count
++].index
= regno
;
8500 case IA64_RS_CR_IIB
:
8507 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8508 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
8509 && (regno
== CR_IIB0
|| regno
== CR_IIB1
))
8511 specs
[count
] = tmpl
;
8512 specs
[count
++].index
= regno
;
8517 case IA64_RS_CR_LRR
:
8524 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8525 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
8526 && (regno
== CR_LRR0
|| regno
== CR_LRR1
))
8528 specs
[count
] = tmpl
;
8529 specs
[count
++].index
= regno
;
8537 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
8539 specs
[count
] = tmpl
;
8540 specs
[count
++].index
=
8541 CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
8556 else if (rsrc_write
)
8558 if (dep
->specifier
== IA64_RS_FRb
8559 && idesc
->operands
[0] == IA64_OPND_F1
)
8561 specs
[count
] = tmpl
;
8562 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_FR
;
8567 for (i
= idesc
->num_outputs
; i
< NELEMS (idesc
->operands
); i
++)
8569 if (idesc
->operands
[i
] == IA64_OPND_F2
8570 || idesc
->operands
[i
] == IA64_OPND_F3
8571 || idesc
->operands
[i
] == IA64_OPND_F4
)
8573 specs
[count
] = tmpl
;
8574 specs
[count
++].index
=
8575 CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
8584 /* This reference applies only to the GR whose value is loaded with
8585 data returned from memory. */
8586 specs
[count
] = tmpl
;
8587 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
8593 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8594 if (idesc
->operands
[i
] == IA64_OPND_R1
8595 || idesc
->operands
[i
] == IA64_OPND_R2
8596 || idesc
->operands
[i
] == IA64_OPND_R3
)
8598 specs
[count
] = tmpl
;
8599 specs
[count
++].index
=
8600 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8602 if (idesc
->flags
& IA64_OPCODE_POSTINC
)
8603 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8604 if (idesc
->operands
[i
] == IA64_OPND_MR3
)
8606 specs
[count
] = tmpl
;
8607 specs
[count
++].index
=
8608 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8613 /* Look for anything that reads a GR. */
8614 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
8616 if (idesc
->operands
[i
] == IA64_OPND_MR3
8617 || idesc
->operands
[i
] == IA64_OPND_CPUID_R3
8618 || idesc
->operands
[i
] == IA64_OPND_DBR_R3
8619 || idesc
->operands
[i
] == IA64_OPND_IBR_R3
8620 || idesc
->operands
[i
] == IA64_OPND_MSR_R3
8621 || idesc
->operands
[i
] == IA64_OPND_PKR_R3
8622 || idesc
->operands
[i
] == IA64_OPND_PMC_R3
8623 || idesc
->operands
[i
] == IA64_OPND_PMD_R3
8624 || idesc
->operands
[i
] == IA64_OPND_RR_R3
8625 || ((i
>= idesc
->num_outputs
)
8626 && (idesc
->operands
[i
] == IA64_OPND_R1
8627 || idesc
->operands
[i
] == IA64_OPND_R2
8628 || idesc
->operands
[i
] == IA64_OPND_R3
8629 /* addl source register. */
8630 || idesc
->operands
[i
] == IA64_OPND_R3_2
)))
8632 specs
[count
] = tmpl
;
8633 specs
[count
++].index
=
8634 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
8645 /* This is the same as IA64_RS_PRr, except that the register range is
8646 from 1 - 15, and there are no rotating register reads/writes here. */
8650 for (i
= 1; i
< 16; i
++)
8652 specs
[count
] = tmpl
;
8653 specs
[count
++].index
= i
;
8659 /* Mark only those registers indicated by the mask. */
8662 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8663 for (i
= 1; i
< 16; i
++)
8664 if (mask
& ((valueT
) 1 << i
))
8666 specs
[count
] = tmpl
;
8667 specs
[count
++].index
= i
;
8675 else if (note
== 11) /* note 11 implies note 1 as well */
8679 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8681 if (idesc
->operands
[i
] == IA64_OPND_P1
8682 || idesc
->operands
[i
] == IA64_OPND_P2
)
8684 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8685 if (regno
>= 1 && regno
< 16)
8687 specs
[count
] = tmpl
;
8688 specs
[count
++].index
= regno
;
8698 else if (note
== 12)
8700 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
8702 specs
[count
] = tmpl
;
8703 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8710 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8711 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8712 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8713 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8715 if ((idesc
->operands
[0] == IA64_OPND_P1
8716 || idesc
->operands
[0] == IA64_OPND_P2
)
8717 && p1
>= 1 && p1
< 16)
8719 specs
[count
] = tmpl
;
8720 specs
[count
].cmp_type
=
8721 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8722 specs
[count
++].index
= p1
;
8724 if ((idesc
->operands
[1] == IA64_OPND_P1
8725 || idesc
->operands
[1] == IA64_OPND_P2
)
8726 && p2
>= 1 && p2
< 16)
8728 specs
[count
] = tmpl
;
8729 specs
[count
].cmp_type
=
8730 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8731 specs
[count
++].index
= p2
;
8736 if (CURR_SLOT
.qp_regno
>= 1 && CURR_SLOT
.qp_regno
< 16)
8738 specs
[count
] = tmpl
;
8739 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8741 if (idesc
->operands
[1] == IA64_OPND_PR
)
8743 for (i
= 1; i
< 16; i
++)
8745 specs
[count
] = tmpl
;
8746 specs
[count
++].index
= i
;
8757 /* This is the general case for PRs. IA64_RS_PR and IA64_RS_PR63 are
8758 simplified cases of this. */
8762 for (i
= 16; i
< 63; i
++)
8764 specs
[count
] = tmpl
;
8765 specs
[count
++].index
= i
;
8771 /* Mark only those registers indicated by the mask. */
8773 && idesc
->operands
[0] == IA64_OPND_PR
)
8775 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
8776 if (mask
& ((valueT
) 1 << 16))
8777 for (i
= 16; i
< 63; i
++)
8779 specs
[count
] = tmpl
;
8780 specs
[count
++].index
= i
;
8784 && idesc
->operands
[0] == IA64_OPND_PR_ROT
)
8786 for (i
= 16; i
< 63; i
++)
8788 specs
[count
] = tmpl
;
8789 specs
[count
++].index
= i
;
8797 else if (note
== 11) /* note 11 implies note 1 as well */
8801 for (i
= 0; i
< idesc
->num_outputs
; i
++)
8803 if (idesc
->operands
[i
] == IA64_OPND_P1
8804 || idesc
->operands
[i
] == IA64_OPND_P2
)
8806 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
8807 if (regno
>= 16 && regno
< 63)
8809 specs
[count
] = tmpl
;
8810 specs
[count
++].index
= regno
;
8820 else if (note
== 12)
8822 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8824 specs
[count
] = tmpl
;
8825 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8832 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
8833 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
8834 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
8835 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
8837 if ((idesc
->operands
[0] == IA64_OPND_P1
8838 || idesc
->operands
[0] == IA64_OPND_P2
)
8839 && p1
>= 16 && p1
< 63)
8841 specs
[count
] = tmpl
;
8842 specs
[count
].cmp_type
=
8843 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
8844 specs
[count
++].index
= p1
;
8846 if ((idesc
->operands
[1] == IA64_OPND_P1
8847 || idesc
->operands
[1] == IA64_OPND_P2
)
8848 && p2
>= 16 && p2
< 63)
8850 specs
[count
] = tmpl
;
8851 specs
[count
].cmp_type
=
8852 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
8853 specs
[count
++].index
= p2
;
8858 if (CURR_SLOT
.qp_regno
>= 16 && CURR_SLOT
.qp_regno
< 63)
8860 specs
[count
] = tmpl
;
8861 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
8863 if (idesc
->operands
[1] == IA64_OPND_PR
)
8865 for (i
= 16; i
< 63; i
++)
8867 specs
[count
] = tmpl
;
8868 specs
[count
++].index
= i
;
8880 /* Verify that the instruction is using the PSR bit indicated in
8884 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_UM
)
8886 if (dep
->regindex
< 6)
8888 specs
[count
++] = tmpl
;
8891 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR
)
8893 if (dep
->regindex
< 32
8894 || dep
->regindex
== 35
8895 || dep
->regindex
== 36
8896 || (!rsrc_write
&& dep
->regindex
== PSR_CPL
))
8898 specs
[count
++] = tmpl
;
8901 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_L
)
8903 if (dep
->regindex
< 32
8904 || dep
->regindex
== 35
8905 || dep
->regindex
== 36
8906 || (rsrc_write
&& dep
->regindex
== PSR_CPL
))
8908 specs
[count
++] = tmpl
;
8913 /* Several PSR bits have very specific dependencies. */
8914 switch (dep
->regindex
)
8917 specs
[count
++] = tmpl
;
8922 specs
[count
++] = tmpl
;
8926 /* Only certain CR accesses use PSR.ic */
8927 if (idesc
->operands
[0] == IA64_OPND_CR3
8928 || idesc
->operands
[1] == IA64_OPND_CR3
)
8931 ((idesc
->operands
[0] == IA64_OPND_CR3
)
8934 CURR_SLOT
.opnd
[reg_index
].X_add_number
- REG_CR
;
8951 specs
[count
++] = tmpl
;
8960 specs
[count
++] = tmpl
;
8964 /* Only some AR accesses use cpl */
8965 if (idesc
->operands
[0] == IA64_OPND_AR3
8966 || idesc
->operands
[1] == IA64_OPND_AR3
)
8969 ((idesc
->operands
[0] == IA64_OPND_AR3
)
8972 CURR_SLOT
.opnd
[reg_index
].X_add_number
- REG_AR
;
8979 && regno
<= AR_K7
))))
8981 specs
[count
++] = tmpl
;
8986 specs
[count
++] = tmpl
;
8996 if (idesc
->operands
[0] == IA64_OPND_IMMU24
)
8998 mask
= CURR_SLOT
.opnd
[0].X_add_number
;
9004 if (mask
& ((valueT
) 1 << dep
->regindex
))
9006 specs
[count
++] = tmpl
;
9011 int min
= dep
->regindex
== PSR_DFL
? 2 : 32;
9012 int max
= dep
->regindex
== PSR_DFL
? 31 : 127;
9013 /* dfh is read on FR32-127; dfl is read on FR2-31 */
9014 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
9016 if (idesc
->operands
[i
] == IA64_OPND_F1
9017 || idesc
->operands
[i
] == IA64_OPND_F2
9018 || idesc
->operands
[i
] == IA64_OPND_F3
9019 || idesc
->operands
[i
] == IA64_OPND_F4
)
9021 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
9022 if (reg
>= min
&& reg
<= max
)
9024 specs
[count
++] = tmpl
;
9031 int min
= dep
->regindex
== PSR_MFL
? 2 : 32;
9032 int max
= dep
->regindex
== PSR_MFL
? 31 : 127;
9033 /* mfh is read on writes to FR32-127; mfl is read on writes to
9035 for (i
= 0; i
< idesc
->num_outputs
; i
++)
9037 if (idesc
->operands
[i
] == IA64_OPND_F1
)
9039 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
9040 if (reg
>= min
&& reg
<= max
)
9042 specs
[count
++] = tmpl
;
9047 else if (note
== 10)
9049 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
9051 if (idesc
->operands
[i
] == IA64_OPND_R1
9052 || idesc
->operands
[i
] == IA64_OPND_R2
9053 || idesc
->operands
[i
] == IA64_OPND_R3
)
9055 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9056 if (regno
>= 16 && regno
<= 31)
9058 specs
[count
++] = tmpl
;
9069 case IA64_RS_AR_FPSR
:
9070 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
9072 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
9073 if (regno
== AR_FPSR
)
9075 specs
[count
++] = tmpl
;
9080 specs
[count
++] = tmpl
;
9085 /* Handle all AR[REG] resources */
9086 if (note
== 0 || note
== 1)
9088 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
9089 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
9090 && regno
== dep
->regindex
)
9092 specs
[count
++] = tmpl
;
9094 /* other AR[REG] resources may be affected by AR accesses */
9095 else if (idesc
->operands
[0] == IA64_OPND_AR3
)
9098 regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
;
9099 switch (dep
->regindex
)
9105 if (regno
== AR_BSPSTORE
)
9107 specs
[count
++] = tmpl
;
9111 (regno
== AR_BSPSTORE
9112 || regno
== AR_RNAT
))
9114 specs
[count
++] = tmpl
;
9119 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
9122 regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
;
9123 switch (dep
->regindex
)
9128 if (regno
== AR_BSPSTORE
|| regno
== AR_RNAT
)
9130 specs
[count
++] = tmpl
;
9137 specs
[count
++] = tmpl
;
9147 /* Handle all CR[REG] resources.
9148 ??? FIXME: The rule 17 isn't really handled correctly. */
9149 if (note
== 0 || note
== 1 || note
== 17)
9151 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
9153 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
9154 if (regno
== dep
->regindex
)
9156 specs
[count
++] = tmpl
;
9158 else if (!rsrc_write
)
9160 /* Reads from CR[IVR] affect other resources. */
9161 if (regno
== CR_IVR
)
9163 if ((dep
->regindex
>= CR_IRR0
9164 && dep
->regindex
<= CR_IRR3
)
9165 || dep
->regindex
== CR_TPR
)
9167 specs
[count
++] = tmpl
;
9174 specs
[count
++] = tmpl
;
9183 case IA64_RS_INSERVICE
:
9184 /* look for write of EOI (67) or read of IVR (65) */
9185 if ((idesc
->operands
[0] == IA64_OPND_CR3
9186 && CURR_SLOT
.opnd
[0].X_add_number
- REG_CR
== CR_EOI
)
9187 || (idesc
->operands
[1] == IA64_OPND_CR3
9188 && CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
== CR_IVR
))
9190 specs
[count
++] = tmpl
;
9197 specs
[count
++] = tmpl
;
9208 specs
[count
++] = tmpl
;
9212 /* Check if any of the registers accessed are in the rotating region.
9213 mov to/from pr accesses CFM only when qp_regno is in the rotating
9215 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
9217 if (idesc
->operands
[i
] == IA64_OPND_R1
9218 || idesc
->operands
[i
] == IA64_OPND_R2
9219 || idesc
->operands
[i
] == IA64_OPND_R3
)
9221 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9222 /* Assumes that md.rot.num_regs is always valid */
9223 if (md
.rot
.num_regs
> 0
9225 && num
< 31 + md
.rot
.num_regs
)
9227 specs
[count
] = tmpl
;
9228 specs
[count
++].specific
= 0;
9231 else if (idesc
->operands
[i
] == IA64_OPND_F1
9232 || idesc
->operands
[i
] == IA64_OPND_F2
9233 || idesc
->operands
[i
] == IA64_OPND_F3
9234 || idesc
->operands
[i
] == IA64_OPND_F4
)
9236 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
9239 specs
[count
] = tmpl
;
9240 specs
[count
++].specific
= 0;
9243 else if (idesc
->operands
[i
] == IA64_OPND_P1
9244 || idesc
->operands
[i
] == IA64_OPND_P2
)
9246 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
9249 specs
[count
] = tmpl
;
9250 specs
[count
++].specific
= 0;
9254 if (CURR_SLOT
.qp_regno
> 15)
9256 specs
[count
] = tmpl
;
9257 specs
[count
++].specific
= 0;
9262 /* This is the same as IA64_RS_PRr, except simplified to account for
9263 the fact that there is only one register. */
9267 specs
[count
++] = tmpl
;
9272 if (idesc
->operands
[2] == IA64_OPND_IMM17
)
9273 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
9274 if (mask
& ((valueT
) 1 << 63))
9275 specs
[count
++] = tmpl
;
9277 else if (note
== 11)
9279 if ((idesc
->operands
[0] == IA64_OPND_P1
9280 && CURR_SLOT
.opnd
[0].X_add_number
- REG_P
== 63)
9281 || (idesc
->operands
[1] == IA64_OPND_P2
9282 && CURR_SLOT
.opnd
[1].X_add_number
- REG_P
== 63))
9284 specs
[count
++] = tmpl
;
9287 else if (note
== 12)
9289 if (CURR_SLOT
.qp_regno
== 63)
9291 specs
[count
++] = tmpl
;
9298 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
9299 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
9300 int or_andcm
= strstr (idesc
->name
, "or.andcm") != NULL
;
9301 int and_orcm
= strstr (idesc
->name
, "and.orcm") != NULL
;
9304 && (idesc
->operands
[0] == IA64_OPND_P1
9305 || idesc
->operands
[0] == IA64_OPND_P2
))
9307 specs
[count
] = tmpl
;
9308 specs
[count
++].cmp_type
=
9309 (or_andcm
? CMP_OR
: (and_orcm
? CMP_AND
: CMP_NONE
));
9312 && (idesc
->operands
[1] == IA64_OPND_P1
9313 || idesc
->operands
[1] == IA64_OPND_P2
))
9315 specs
[count
] = tmpl
;
9316 specs
[count
++].cmp_type
=
9317 (or_andcm
? CMP_AND
: (and_orcm
? CMP_OR
: CMP_NONE
));
9322 if (CURR_SLOT
.qp_regno
== 63)
9324 specs
[count
++] = tmpl
;
9335 /* FIXME we can identify some individual RSE written resources, but RSE
9336 read resources have not yet been completely identified, so for now
9337 treat RSE as a single resource */
9338 if (strncmp (idesc
->name
, "mov", 3) == 0)
9342 if (idesc
->operands
[0] == IA64_OPND_AR3
9343 && CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
)
9345 specs
[count
++] = tmpl
;
9350 if (idesc
->operands
[0] == IA64_OPND_AR3
)
9352 if (CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
9353 || CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_RNAT
)
9355 specs
[count
++] = tmpl
;
9358 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
9360 if (CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSP
9361 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSPSTORE
9362 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_RNAT
)
9364 specs
[count
++] = tmpl
;
9371 specs
[count
++] = tmpl
;
9376 /* FIXME -- do any of these need to be non-specific? */
9377 specs
[count
++] = tmpl
;
9381 as_bad (_("Unrecognized dependency specifier %d\n"), dep
->specifier
);
9388 /* Clear branch flags on marked resources. This breaks the link between the
9389 QP of the marking instruction and a subsequent branch on the same QP. */
9392 clear_qp_branch_flag (valueT mask
)
9395 for (i
= 0; i
< regdepslen
; i
++)
9397 valueT bit
= ((valueT
) 1 << regdeps
[i
].qp_regno
);
9398 if ((bit
& mask
) != 0)
9400 regdeps
[i
].link_to_qp_branch
= 0;
9405 /* MASK contains 2 and only 2 PRs which are mutually exclusive. Remove
9406 any mutexes which contain one of the PRs and create new ones when
9410 update_qp_mutex (valueT mask
)
9416 while (i
< qp_mutexeslen
)
9418 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
9420 /* If it destroys and creates the same mutex, do nothing. */
9421 if (qp_mutexes
[i
].prmask
== mask
9422 && qp_mutexes
[i
].path
== md
.path
)
9433 fprintf (stderr
, " Clearing mutex relation");
9434 print_prmask (qp_mutexes
[i
].prmask
);
9435 fprintf (stderr
, "\n");
9438 /* Deal with the old mutex with more than 3+ PRs only if
9439 the new mutex on the same execution path with it.
9441 FIXME: The 3+ mutex support is incomplete.
9442 dot_pred_rel () may be a better place to fix it. */
9443 if (qp_mutexes
[i
].path
== md
.path
)
9445 /* If it is a proper subset of the mutex, create a
9448 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
9451 qp_mutexes
[i
].prmask
&= ~mask
;
9452 if (qp_mutexes
[i
].prmask
& (qp_mutexes
[i
].prmask
- 1))
9454 /* Modify the mutex if there are more than one
9462 /* Remove the mutex. */
9463 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
9471 add_qp_mutex (mask
);
9476 /* Remove any mutexes which contain any of the PRs indicated in the mask.
9478 Any changes to a PR clears the mutex relations which include that PR. */
9481 clear_qp_mutex (valueT mask
)
9486 while (i
< qp_mutexeslen
)
9488 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
9492 fprintf (stderr
, " Clearing mutex relation");
9493 print_prmask (qp_mutexes
[i
].prmask
);
9494 fprintf (stderr
, "\n");
9496 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
9503 /* Clear implies relations which contain PRs in the given masks.
9504 P1_MASK indicates the source of the implies relation, while P2_MASK
9505 indicates the implied PR. */
9508 clear_qp_implies (valueT p1_mask
, valueT p2_mask
)
9513 while (i
< qp_implieslen
)
9515 if ((((valueT
) 1 << qp_implies
[i
].p1
) & p1_mask
) != 0
9516 || (((valueT
) 1 << qp_implies
[i
].p2
) & p2_mask
) != 0)
9519 fprintf (stderr
, "Clearing implied relation PR%d->PR%d\n",
9520 qp_implies
[i
].p1
, qp_implies
[i
].p2
);
9521 qp_implies
[i
] = qp_implies
[--qp_implieslen
];
9528 /* Add the PRs specified to the list of implied relations. */
9531 add_qp_imply (int p1
, int p2
)
9537 /* p0 is not meaningful here. */
9538 if (p1
== 0 || p2
== 0)
9544 /* If it exists already, ignore it. */
9545 for (i
= 0; i
< qp_implieslen
; i
++)
9547 if (qp_implies
[i
].p1
== p1
9548 && qp_implies
[i
].p2
== p2
9549 && qp_implies
[i
].path
== md
.path
9550 && !qp_implies
[i
].p2_branched
)
9554 if (qp_implieslen
== qp_impliestotlen
)
9556 qp_impliestotlen
+= 20;
9557 qp_implies
= (struct qp_imply
*)
9558 xrealloc ((void *) qp_implies
,
9559 qp_impliestotlen
* sizeof (struct qp_imply
));
9562 fprintf (stderr
, " Registering PR%d implies PR%d\n", p1
, p2
);
9563 qp_implies
[qp_implieslen
].p1
= p1
;
9564 qp_implies
[qp_implieslen
].p2
= p2
;
9565 qp_implies
[qp_implieslen
].path
= md
.path
;
9566 qp_implies
[qp_implieslen
++].p2_branched
= 0;
9568 /* Add in the implied transitive relations; for everything that p2 implies,
9569 make p1 imply that, too; for everything that implies p1, make it imply p2
9571 for (i
= 0; i
< qp_implieslen
; i
++)
9573 if (qp_implies
[i
].p1
== p2
)
9574 add_qp_imply (p1
, qp_implies
[i
].p2
);
9575 if (qp_implies
[i
].p2
== p1
)
9576 add_qp_imply (qp_implies
[i
].p1
, p2
);
9578 /* Add in mutex relations implied by this implies relation; for each mutex
9579 relation containing p2, duplicate it and replace p2 with p1. */
9580 bit
= (valueT
) 1 << p1
;
9581 mask
= (valueT
) 1 << p2
;
9582 for (i
= 0; i
< qp_mutexeslen
; i
++)
9584 if (qp_mutexes
[i
].prmask
& mask
)
9585 add_qp_mutex ((qp_mutexes
[i
].prmask
& ~mask
) | bit
);
9589 /* Add the PRs specified in the mask to the mutex list; this means that only
9590 one of the PRs can be true at any time. PR0 should never be included in
9594 add_qp_mutex (valueT mask
)
9599 if (qp_mutexeslen
== qp_mutexestotlen
)
9601 qp_mutexestotlen
+= 20;
9602 qp_mutexes
= (struct qpmutex
*)
9603 xrealloc ((void *) qp_mutexes
,
9604 qp_mutexestotlen
* sizeof (struct qpmutex
));
9608 fprintf (stderr
, " Registering mutex on");
9609 print_prmask (mask
);
9610 fprintf (stderr
, "\n");
9612 qp_mutexes
[qp_mutexeslen
].path
= md
.path
;
9613 qp_mutexes
[qp_mutexeslen
++].prmask
= mask
;
9617 has_suffix_p (const char *name
, const char *suffix
)
9619 size_t namelen
= strlen (name
);
9620 size_t sufflen
= strlen (suffix
);
9622 if (namelen
<= sufflen
)
9624 return strcmp (name
+ namelen
- sufflen
, suffix
) == 0;
9628 clear_register_values (void)
9632 fprintf (stderr
, " Clearing register values\n");
9633 for (i
= 1; i
< NELEMS (gr_values
); i
++)
9634 gr_values
[i
].known
= 0;
9637 /* Keep track of register values/changes which affect DV tracking.
9639 optimization note: should add a flag to classes of insns where otherwise we
9640 have to examine a group of strings to identify them. */
9643 note_register_values (struct ia64_opcode
*idesc
)
9645 valueT qp_changemask
= 0;
9648 /* Invalidate values for registers being written to. */
9649 for (i
= 0; i
< idesc
->num_outputs
; i
++)
9651 if (idesc
->operands
[i
] == IA64_OPND_R1
9652 || idesc
->operands
[i
] == IA64_OPND_R2
9653 || idesc
->operands
[i
] == IA64_OPND_R3
)
9655 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9656 if (regno
> 0 && regno
< NELEMS (gr_values
))
9657 gr_values
[regno
].known
= 0;
9659 else if (idesc
->operands
[i
] == IA64_OPND_R3_2
)
9661 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
9662 if (regno
> 0 && regno
< 4)
9663 gr_values
[regno
].known
= 0;
9665 else if (idesc
->operands
[i
] == IA64_OPND_P1
9666 || idesc
->operands
[i
] == IA64_OPND_P2
)
9668 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
9669 qp_changemask
|= (valueT
) 1 << regno
;
9671 else if (idesc
->operands
[i
] == IA64_OPND_PR
)
9673 if (idesc
->operands
[2] & (valueT
) 0x10000)
9674 qp_changemask
= ~(valueT
) 0x1FFFF | idesc
->operands
[2];
9676 qp_changemask
= idesc
->operands
[2];
9679 else if (idesc
->operands
[i
] == IA64_OPND_PR_ROT
)
9681 if (idesc
->operands
[1] & ((valueT
) 1 << 43))
9682 qp_changemask
= -((valueT
) 1 << 44) | idesc
->operands
[1];
9684 qp_changemask
= idesc
->operands
[1];
9685 qp_changemask
&= ~(valueT
) 0xFFFF;
9690 /* Always clear qp branch flags on any PR change. */
9691 /* FIXME there may be exceptions for certain compares. */
9692 clear_qp_branch_flag (qp_changemask
);
9694 /* Invalidate rotating registers on insns which affect RRBs in CFM. */
9695 if (idesc
->flags
& IA64_OPCODE_MOD_RRBS
)
9697 qp_changemask
|= ~(valueT
) 0xFFFF;
9698 if (strcmp (idesc
->name
, "clrrrb.pr") != 0)
9700 for (i
= 32; i
< 32 + md
.rot
.num_regs
; i
++)
9701 gr_values
[i
].known
= 0;
9703 clear_qp_mutex (qp_changemask
);
9704 clear_qp_implies (qp_changemask
, qp_changemask
);
9706 /* After a call, all register values are undefined, except those marked
9708 else if (strncmp (idesc
->name
, "br.call", 6) == 0
9709 || strncmp (idesc
->name
, "brl.call", 7) == 0)
9711 /* FIXME keep GR values which are marked as "safe_across_calls" */
9712 clear_register_values ();
9713 clear_qp_mutex (~qp_safe_across_calls
);
9714 clear_qp_implies (~qp_safe_across_calls
, ~qp_safe_across_calls
);
9715 clear_qp_branch_flag (~qp_safe_across_calls
);
9717 else if (is_interruption_or_rfi (idesc
)
9718 || is_taken_branch (idesc
))
9720 clear_register_values ();
9721 clear_qp_mutex (~(valueT
) 0);
9722 clear_qp_implies (~(valueT
) 0, ~(valueT
) 0);
9724 /* Look for mutex and implies relations. */
9725 else if ((idesc
->operands
[0] == IA64_OPND_P1
9726 || idesc
->operands
[0] == IA64_OPND_P2
)
9727 && (idesc
->operands
[1] == IA64_OPND_P1
9728 || idesc
->operands
[1] == IA64_OPND_P2
))
9730 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
9731 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
9732 valueT p1mask
= (p1
!= 0) ? (valueT
) 1 << p1
: 0;
9733 valueT p2mask
= (p2
!= 0) ? (valueT
) 1 << p2
: 0;
9735 /* If both PRs are PR0, we can't really do anything. */
9736 if (p1
== 0 && p2
== 0)
9739 fprintf (stderr
, " Ignoring PRs due to inclusion of p0\n");
9741 /* In general, clear mutexes and implies which include P1 or P2,
9742 with the following exceptions. */
9743 else if (has_suffix_p (idesc
->name
, ".or.andcm")
9744 || has_suffix_p (idesc
->name
, ".and.orcm"))
9746 clear_qp_implies (p2mask
, p1mask
);
9748 else if (has_suffix_p (idesc
->name
, ".andcm")
9749 || has_suffix_p (idesc
->name
, ".and"))
9751 clear_qp_implies (0, p1mask
| p2mask
);
9753 else if (has_suffix_p (idesc
->name
, ".orcm")
9754 || has_suffix_p (idesc
->name
, ".or"))
9756 clear_qp_mutex (p1mask
| p2mask
);
9757 clear_qp_implies (p1mask
| p2mask
, 0);
9763 clear_qp_implies (p1mask
| p2mask
, p1mask
| p2mask
);
9765 /* If one of the PRs is PR0, we call clear_qp_mutex. */
9766 if (p1
== 0 || p2
== 0)
9767 clear_qp_mutex (p1mask
| p2mask
);
9769 added
= update_qp_mutex (p1mask
| p2mask
);
9771 if (CURR_SLOT
.qp_regno
== 0
9772 || has_suffix_p (idesc
->name
, ".unc"))
9774 if (added
== 0 && p1
&& p2
)
9775 add_qp_mutex (p1mask
| p2mask
);
9776 if (CURR_SLOT
.qp_regno
!= 0)
9779 add_qp_imply (p1
, CURR_SLOT
.qp_regno
);
9781 add_qp_imply (p2
, CURR_SLOT
.qp_regno
);
9786 /* Look for mov imm insns into GRs. */
9787 else if (idesc
->operands
[0] == IA64_OPND_R1
9788 && (idesc
->operands
[1] == IA64_OPND_IMM22
9789 || idesc
->operands
[1] == IA64_OPND_IMMU64
)
9790 && CURR_SLOT
.opnd
[1].X_op
== O_constant
9791 && (strcmp (idesc
->name
, "mov") == 0
9792 || strcmp (idesc
->name
, "movl") == 0))
9794 int regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
9795 if (regno
> 0 && regno
< NELEMS (gr_values
))
9797 gr_values
[regno
].known
= 1;
9798 gr_values
[regno
].value
= CURR_SLOT
.opnd
[1].X_add_number
;
9799 gr_values
[regno
].path
= md
.path
;
9802 fprintf (stderr
, " Know gr%d = ", regno
);
9803 fprintf_vma (stderr
, gr_values
[regno
].value
);
9804 fputs ("\n", stderr
);
9808 /* Look for dep.z imm insns. */
9809 else if (idesc
->operands
[0] == IA64_OPND_R1
9810 && idesc
->operands
[1] == IA64_OPND_IMM8
9811 && strcmp (idesc
->name
, "dep.z") == 0)
9813 int regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
9814 if (regno
> 0 && regno
< NELEMS (gr_values
))
9816 valueT value
= CURR_SLOT
.opnd
[1].X_add_number
;
9818 if (CURR_SLOT
.opnd
[3].X_add_number
< 64)
9819 value
&= ((valueT
)1 << CURR_SLOT
.opnd
[3].X_add_number
) - 1;
9820 value
<<= CURR_SLOT
.opnd
[2].X_add_number
;
9821 gr_values
[regno
].known
= 1;
9822 gr_values
[regno
].value
= value
;
9823 gr_values
[regno
].path
= md
.path
;
9826 fprintf (stderr
, " Know gr%d = ", regno
);
9827 fprintf_vma (stderr
, gr_values
[regno
].value
);
9828 fputs ("\n", stderr
);
9834 clear_qp_mutex (qp_changemask
);
9835 clear_qp_implies (qp_changemask
, qp_changemask
);
9839 /* Return whether the given predicate registers are currently mutex. */
9842 qp_mutex (int p1
, int p2
, int path
)
9849 mask
= ((valueT
) 1 << p1
) | (valueT
) 1 << p2
;
9850 for (i
= 0; i
< qp_mutexeslen
; i
++)
9852 if (qp_mutexes
[i
].path
>= path
9853 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
9860 /* Return whether the given resource is in the given insn's list of chks
9861 Return 1 if the conflict is absolutely determined, 2 if it's a potential
9865 resources_match (struct rsrc
*rs
,
9866 struct ia64_opcode
*idesc
,
9871 struct rsrc specs
[MAX_SPECS
];
9874 /* If the marked resource's qp_regno and the given qp_regno are mutex,
9875 we don't need to check. One exception is note 11, which indicates that
9876 target predicates are written regardless of PR[qp]. */
9877 if (qp_mutex (rs
->qp_regno
, qp_regno
, path
)
9881 count
= specify_resource (rs
->dependency
, idesc
, DV_CHK
, specs
, note
, path
);
9884 /* UNAT checking is a bit more specific than other resources */
9885 if (rs
->dependency
->specifier
== IA64_RS_AR_UNAT
9886 && specs
[count
].mem_offset
.hint
9887 && rs
->mem_offset
.hint
)
9889 if (rs
->mem_offset
.base
== specs
[count
].mem_offset
.base
)
9891 if (((rs
->mem_offset
.offset
>> 3) & 0x3F) ==
9892 ((specs
[count
].mem_offset
.offset
>> 3) & 0x3F))
9899 /* Skip apparent PR write conflicts where both writes are an AND or both
9900 writes are an OR. */
9901 if (rs
->dependency
->specifier
== IA64_RS_PR
9902 || rs
->dependency
->specifier
== IA64_RS_PRr
9903 || rs
->dependency
->specifier
== IA64_RS_PR63
)
9905 if (specs
[count
].cmp_type
!= CMP_NONE
9906 && specs
[count
].cmp_type
== rs
->cmp_type
)
9909 fprintf (stderr
, " %s on parallel compare allowed (PR%d)\n",
9910 dv_mode
[rs
->dependency
->mode
],
9911 rs
->dependency
->specifier
!= IA64_RS_PR63
?
9912 specs
[count
].index
: 63);
9917 " %s on parallel compare conflict %s vs %s on PR%d\n",
9918 dv_mode
[rs
->dependency
->mode
],
9919 dv_cmp_type
[rs
->cmp_type
],
9920 dv_cmp_type
[specs
[count
].cmp_type
],
9921 rs
->dependency
->specifier
!= IA64_RS_PR63
?
9922 specs
[count
].index
: 63);
9926 /* If either resource is not specific, conservatively assume a conflict
9928 if (!specs
[count
].specific
|| !rs
->specific
)
9930 else if (specs
[count
].index
== rs
->index
)
9937 /* Indicate an instruction group break; if INSERT_STOP is non-zero, then
9938 insert a stop to create the break. Update all resource dependencies
9939 appropriately. If QP_REGNO is non-zero, only apply the break to resources
9940 which use the same QP_REGNO and have the link_to_qp_branch flag set.
9941 If SAVE_CURRENT is non-zero, don't affect resources marked by the current
9945 insn_group_break (int insert_stop
, int qp_regno
, int save_current
)
9949 if (insert_stop
&& md
.num_slots_in_use
> 0)
9950 PREV_SLOT
.end_of_insn_group
= 1;
9954 fprintf (stderr
, " Insn group break%s",
9955 (insert_stop
? " (w/stop)" : ""));
9957 fprintf (stderr
, " effective for QP=%d", qp_regno
);
9958 fprintf (stderr
, "\n");
9962 while (i
< regdepslen
)
9964 const struct ia64_dependency
*dep
= regdeps
[i
].dependency
;
9967 && regdeps
[i
].qp_regno
!= qp_regno
)
9974 && CURR_SLOT
.src_file
== regdeps
[i
].file
9975 && CURR_SLOT
.src_line
== regdeps
[i
].line
)
9981 /* clear dependencies which are automatically cleared by a stop, or
9982 those that have reached the appropriate state of insn serialization */
9983 if (dep
->semantics
== IA64_DVS_IMPLIED
9984 || dep
->semantics
== IA64_DVS_IMPLIEDF
9985 || regdeps
[i
].insn_srlz
== STATE_SRLZ
)
9987 print_dependency ("Removing", i
);
9988 regdeps
[i
] = regdeps
[--regdepslen
];
9992 if (dep
->semantics
== IA64_DVS_DATA
9993 || dep
->semantics
== IA64_DVS_INSTR
9994 || dep
->semantics
== IA64_DVS_SPECIFIC
)
9996 if (regdeps
[i
].insn_srlz
== STATE_NONE
)
9997 regdeps
[i
].insn_srlz
= STATE_STOP
;
9998 if (regdeps
[i
].data_srlz
== STATE_NONE
)
9999 regdeps
[i
].data_srlz
= STATE_STOP
;
10006 /* Add the given resource usage spec to the list of active dependencies. */
10009 mark_resource (struct ia64_opcode
*idesc ATTRIBUTE_UNUSED
,
10010 const struct ia64_dependency
*dep ATTRIBUTE_UNUSED
,
10015 if (regdepslen
== regdepstotlen
)
10017 regdepstotlen
+= 20;
10018 regdeps
= (struct rsrc
*)
10019 xrealloc ((void *) regdeps
,
10020 regdepstotlen
* sizeof (struct rsrc
));
10023 regdeps
[regdepslen
] = *spec
;
10024 regdeps
[regdepslen
].depind
= depind
;
10025 regdeps
[regdepslen
].path
= path
;
10026 regdeps
[regdepslen
].file
= CURR_SLOT
.src_file
;
10027 regdeps
[regdepslen
].line
= CURR_SLOT
.src_line
;
10029 print_dependency ("Adding", regdepslen
);
10035 print_dependency (const char *action
, int depind
)
10039 fprintf (stderr
, " %s %s '%s'",
10040 action
, dv_mode
[(regdeps
[depind
].dependency
)->mode
],
10041 (regdeps
[depind
].dependency
)->name
);
10042 if (regdeps
[depind
].specific
&& regdeps
[depind
].index
>= 0)
10043 fprintf (stderr
, " (%d)", regdeps
[depind
].index
);
10044 if (regdeps
[depind
].mem_offset
.hint
)
10046 fputs (" ", stderr
);
10047 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.base
);
10048 fputs ("+", stderr
);
10049 fprintf_vma (stderr
, regdeps
[depind
].mem_offset
.offset
);
10051 fprintf (stderr
, "\n");
10056 instruction_serialization (void)
10060 fprintf (stderr
, " Instruction serialization\n");
10061 for (i
= 0; i
< regdepslen
; i
++)
10062 if (regdeps
[i
].insn_srlz
== STATE_STOP
)
10063 regdeps
[i
].insn_srlz
= STATE_SRLZ
;
10067 data_serialization (void)
10071 fprintf (stderr
, " Data serialization\n");
10072 while (i
< regdepslen
)
10074 if (regdeps
[i
].data_srlz
== STATE_STOP
10075 /* Note: as of 991210, all "other" dependencies are cleared by a
10076 data serialization. This might change with new tables */
10077 || (regdeps
[i
].dependency
)->semantics
== IA64_DVS_OTHER
)
10079 print_dependency ("Removing", i
);
10080 regdeps
[i
] = regdeps
[--regdepslen
];
10087 /* Insert stops and serializations as needed to avoid DVs. */
10090 remove_marked_resource (struct rsrc
*rs
)
10092 switch (rs
->dependency
->semantics
)
10094 case IA64_DVS_SPECIFIC
:
10096 fprintf (stderr
, "Implementation-specific, assume worst case...\n");
10097 /* ...fall through... */
10098 case IA64_DVS_INSTR
:
10100 fprintf (stderr
, "Inserting instr serialization\n");
10101 if (rs
->insn_srlz
< STATE_STOP
)
10102 insn_group_break (1, 0, 0);
10103 if (rs
->insn_srlz
< STATE_SRLZ
)
10105 struct slot oldslot
= CURR_SLOT
;
10106 /* Manually jam a srlz.i insn into the stream */
10107 memset (&CURR_SLOT
, 0, sizeof (CURR_SLOT
));
10108 CURR_SLOT
.user_template
= -1;
10109 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.i");
10110 instruction_serialization ();
10111 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10112 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10113 emit_one_bundle ();
10114 CURR_SLOT
= oldslot
;
10116 insn_group_break (1, 0, 0);
10118 case IA64_DVS_OTHER
: /* as of rev2 (991220) of the DV tables, all
10119 "other" types of DV are eliminated
10120 by a data serialization */
10121 case IA64_DVS_DATA
:
10123 fprintf (stderr
, "Inserting data serialization\n");
10124 if (rs
->data_srlz
< STATE_STOP
)
10125 insn_group_break (1, 0, 0);
10127 struct slot oldslot
= CURR_SLOT
;
10128 /* Manually jam a srlz.d insn into the stream */
10129 memset (&CURR_SLOT
, 0, sizeof (CURR_SLOT
));
10130 CURR_SLOT
.user_template
= -1;
10131 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.d");
10132 data_serialization ();
10133 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10134 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10135 emit_one_bundle ();
10136 CURR_SLOT
= oldslot
;
10139 case IA64_DVS_IMPLIED
:
10140 case IA64_DVS_IMPLIEDF
:
10142 fprintf (stderr
, "Inserting stop\n");
10143 insn_group_break (1, 0, 0);
10150 /* Check the resources used by the given opcode against the current dependency
10153 The check is run once for each execution path encountered. In this case,
10154 a unique execution path is the sequence of instructions following a code
10155 entry point, e.g. the following has three execution paths, one starting
10156 at L0, one at L1, and one at L2.
10165 check_dependencies (struct ia64_opcode
*idesc
)
10167 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
10171 /* Note that the number of marked resources may change within the
10172 loop if in auto mode. */
10174 while (i
< regdepslen
)
10176 struct rsrc
*rs
= ®deps
[i
];
10177 const struct ia64_dependency
*dep
= rs
->dependency
;
10180 int start_over
= 0;
10182 if (dep
->semantics
== IA64_DVS_NONE
10183 || (chkind
= depends_on (rs
->depind
, idesc
)) == -1)
10189 note
= NOTE (opdeps
->chks
[chkind
]);
10191 /* Check this resource against each execution path seen thus far. */
10192 for (path
= 0; path
<= md
.path
; path
++)
10196 /* If the dependency wasn't on the path being checked, ignore it. */
10197 if (rs
->path
< path
)
10200 /* If the QP for this insn implies a QP which has branched, don't
10201 bother checking. Ed. NOTE: I don't think this check is terribly
10202 useful; what's the point of generating code which will only be
10203 reached if its QP is zero?
10204 This code was specifically inserted to handle the following code,
10205 based on notes from Intel's DV checking code, where p1 implies p2.
10211 if (CURR_SLOT
.qp_regno
!= 0)
10215 for (implies
= 0; implies
< qp_implieslen
; implies
++)
10217 if (qp_implies
[implies
].path
>= path
10218 && qp_implies
[implies
].p1
== CURR_SLOT
.qp_regno
10219 && qp_implies
[implies
].p2_branched
)
10229 if ((matchtype
= resources_match (rs
, idesc
, note
,
10230 CURR_SLOT
.qp_regno
, path
)) != 0)
10233 char pathmsg
[256] = "";
10234 char indexmsg
[256] = "";
10235 int certain
= (matchtype
== 1 && CURR_SLOT
.qp_regno
== 0);
10238 snprintf (pathmsg
, sizeof (pathmsg
),
10239 " when entry is at label '%s'",
10240 md
.entry_labels
[path
- 1]);
10241 if (matchtype
== 1 && rs
->index
>= 0)
10242 snprintf (indexmsg
, sizeof (indexmsg
),
10243 ", specific resource number is %d",
10245 snprintf (msg
, sizeof (msg
),
10246 "Use of '%s' %s %s dependency '%s' (%s)%s%s",
10248 (certain
? "violates" : "may violate"),
10249 dv_mode
[dep
->mode
], dep
->name
,
10250 dv_sem
[dep
->semantics
],
10251 pathmsg
, indexmsg
);
10253 if (md
.explicit_mode
)
10255 as_warn ("%s", msg
);
10256 if (path
< md
.path
)
10257 as_warn (_("Only the first path encountering the conflict is reported"));
10258 as_warn_where (rs
->file
, rs
->line
,
10259 _("This is the location of the conflicting usage"));
10260 /* Don't bother checking other paths, to avoid duplicating
10261 the same warning */
10267 fprintf (stderr
, "%s @ %s:%d\n", msg
, rs
->file
, rs
->line
);
10269 remove_marked_resource (rs
);
10271 /* since the set of dependencies has changed, start over */
10272 /* FIXME -- since we're removing dvs as we go, we
10273 probably don't really need to start over... */
10286 /* Register new dependencies based on the given opcode. */
10289 mark_resources (struct ia64_opcode
*idesc
)
10292 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
10293 int add_only_qp_reads
= 0;
10295 /* A conditional branch only uses its resources if it is taken; if it is
10296 taken, we stop following that path. The other branch types effectively
10297 *always* write their resources. If it's not taken, register only QP
10299 if (is_conditional_branch (idesc
) || is_interruption_or_rfi (idesc
))
10301 add_only_qp_reads
= 1;
10305 fprintf (stderr
, "Registering '%s' resource usage\n", idesc
->name
);
10307 for (i
= 0; i
< opdeps
->nregs
; i
++)
10309 const struct ia64_dependency
*dep
;
10310 struct rsrc specs
[MAX_SPECS
];
10315 dep
= ia64_find_dependency (opdeps
->regs
[i
]);
10316 note
= NOTE (opdeps
->regs
[i
]);
10318 if (add_only_qp_reads
10319 && !(dep
->mode
== IA64_DV_WAR
10320 && (dep
->specifier
== IA64_RS_PR
10321 || dep
->specifier
== IA64_RS_PRr
10322 || dep
->specifier
== IA64_RS_PR63
)))
10325 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, md
.path
);
10327 while (count
-- > 0)
10329 mark_resource (idesc
, dep
, &specs
[count
],
10330 DEP (opdeps
->regs
[i
]), md
.path
);
10333 /* The execution path may affect register values, which may in turn
10334 affect which indirect-access resources are accessed. */
10335 switch (dep
->specifier
)
10339 case IA64_RS_CPUID
:
10347 for (path
= 0; path
< md
.path
; path
++)
10349 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, path
);
10350 while (count
-- > 0)
10351 mark_resource (idesc
, dep
, &specs
[count
],
10352 DEP (opdeps
->regs
[i
]), path
);
10359 /* Remove dependencies when they no longer apply. */
10362 update_dependencies (struct ia64_opcode
*idesc
)
10366 if (strcmp (idesc
->name
, "srlz.i") == 0)
10368 instruction_serialization ();
10370 else if (strcmp (idesc
->name
, "srlz.d") == 0)
10372 data_serialization ();
10374 else if (is_interruption_or_rfi (idesc
)
10375 || is_taken_branch (idesc
))
10377 /* Although technically the taken branch doesn't clear dependencies
10378 which require a srlz.[id], we don't follow the branch; the next
10379 instruction is assumed to start with a clean slate. */
10383 else if (is_conditional_branch (idesc
)
10384 && CURR_SLOT
.qp_regno
!= 0)
10386 int is_call
= strstr (idesc
->name
, ".call") != NULL
;
10388 for (i
= 0; i
< qp_implieslen
; i
++)
10390 /* If the conditional branch's predicate is implied by the predicate
10391 in an existing dependency, remove that dependency. */
10392 if (qp_implies
[i
].p2
== CURR_SLOT
.qp_regno
)
10395 /* Note that this implied predicate takes a branch so that if
10396 a later insn generates a DV but its predicate implies this
10397 one, we can avoid the false DV warning. */
10398 qp_implies
[i
].p2_branched
= 1;
10399 while (depind
< regdepslen
)
10401 if (regdeps
[depind
].qp_regno
== qp_implies
[i
].p1
)
10403 print_dependency ("Removing", depind
);
10404 regdeps
[depind
] = regdeps
[--regdepslen
];
10411 /* Any marked resources which have this same predicate should be
10412 cleared, provided that the QP hasn't been modified between the
10413 marking instruction and the branch. */
10416 insn_group_break (0, CURR_SLOT
.qp_regno
, 1);
10421 while (i
< regdepslen
)
10423 if (regdeps
[i
].qp_regno
== CURR_SLOT
.qp_regno
10424 && regdeps
[i
].link_to_qp_branch
10425 && (regdeps
[i
].file
!= CURR_SLOT
.src_file
10426 || regdeps
[i
].line
!= CURR_SLOT
.src_line
))
10428 /* Treat like a taken branch */
10429 print_dependency ("Removing", i
);
10430 regdeps
[i
] = regdeps
[--regdepslen
];
10439 /* Examine the current instruction for dependency violations. */
10442 check_dv (struct ia64_opcode
*idesc
)
10446 fprintf (stderr
, "Checking %s for violations (line %d, %d/%d)\n",
10447 idesc
->name
, CURR_SLOT
.src_line
,
10448 idesc
->dependencies
->nchks
,
10449 idesc
->dependencies
->nregs
);
10452 /* Look through the list of currently marked resources; if the current
10453 instruction has the dependency in its chks list which uses that resource,
10454 check against the specific resources used. */
10455 check_dependencies (idesc
);
10457 /* Look up the instruction's regdeps (RAW writes, WAW writes, and WAR reads),
10458 then add them to the list of marked resources. */
10459 mark_resources (idesc
);
10461 /* There are several types of dependency semantics, and each has its own
10462 requirements for being cleared
10464 Instruction serialization (insns separated by interruption, rfi, or
10465 writer + srlz.i + reader, all in separate groups) clears DVS_INSTR.
10467 Data serialization (instruction serialization, or writer + srlz.d +
10468 reader, where writer and srlz.d are in separate groups) clears
10469 DVS_DATA. (This also clears DVS_OTHER, but that is not guaranteed to
10470 always be the case).
10472 Instruction group break (groups separated by stop, taken branch,
10473 interruption or rfi) clears DVS_IMPLIED and DVS_IMPLIEDF.
10475 update_dependencies (idesc
);
10477 /* Sometimes, knowing a register value allows us to avoid giving a false DV
10478 warning. Keep track of as many as possible that are useful. */
10479 note_register_values (idesc
);
10481 /* We don't need or want this anymore. */
10482 md
.mem_offset
.hint
= 0;
10487 /* Translate one line of assembly. Pseudo ops and labels do not show
10490 md_assemble (char *str
)
10492 char *saved_input_line_pointer
, *mnemonic
;
10493 const struct pseudo_opcode
*pdesc
;
10494 struct ia64_opcode
*idesc
;
10495 unsigned char qp_regno
;
10496 unsigned int flags
;
10499 saved_input_line_pointer
= input_line_pointer
;
10500 input_line_pointer
= str
;
10502 /* extract the opcode (mnemonic): */
10504 mnemonic
= input_line_pointer
;
10505 ch
= get_symbol_end ();
10506 pdesc
= (struct pseudo_opcode
*) hash_find (md
.pseudo_hash
, mnemonic
);
10509 *input_line_pointer
= ch
;
10510 (*pdesc
->handler
) (pdesc
->arg
);
10514 /* Find the instruction descriptor matching the arguments. */
10516 idesc
= ia64_find_opcode (mnemonic
);
10517 *input_line_pointer
= ch
;
10520 as_bad (_("Unknown opcode `%s'"), mnemonic
);
10524 idesc
= parse_operands (idesc
);
10528 /* Handle the dynamic ops we can handle now: */
10529 if (idesc
->type
== IA64_TYPE_DYN
)
10531 if (strcmp (idesc
->name
, "add") == 0)
10533 if (CURR_SLOT
.opnd
[2].X_op
== O_register
10534 && CURR_SLOT
.opnd
[2].X_add_number
< 4)
10538 ia64_free_opcode (idesc
);
10539 idesc
= ia64_find_opcode (mnemonic
);
10541 else if (strcmp (idesc
->name
, "mov") == 0)
10543 enum ia64_opnd opnd1
, opnd2
;
10546 opnd1
= idesc
->operands
[0];
10547 opnd2
= idesc
->operands
[1];
10548 if (opnd1
== IA64_OPND_AR3
)
10550 else if (opnd2
== IA64_OPND_AR3
)
10554 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
)
10556 if (ar_is_only_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10557 mnemonic
= "mov.i";
10558 else if (ar_is_only_in_memory_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10559 mnemonic
= "mov.m";
10567 ia64_free_opcode (idesc
);
10568 idesc
= ia64_find_opcode (mnemonic
);
10569 while (idesc
!= NULL
10570 && (idesc
->operands
[0] != opnd1
10571 || idesc
->operands
[1] != opnd2
))
10572 idesc
= get_next_opcode (idesc
);
10576 else if (strcmp (idesc
->name
, "mov.i") == 0
10577 || strcmp (idesc
->name
, "mov.m") == 0)
10579 enum ia64_opnd opnd1
, opnd2
;
10582 opnd1
= idesc
->operands
[0];
10583 opnd2
= idesc
->operands
[1];
10584 if (opnd1
== IA64_OPND_AR3
)
10586 else if (opnd2
== IA64_OPND_AR3
)
10590 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
)
10593 if (ar_is_only_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10595 else if (ar_is_only_in_memory_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
10597 if (unit
!= 'a' && unit
!= idesc
->name
[4])
10598 as_bad (_("AR %d can only be accessed by %c-unit"),
10599 (int) (CURR_SLOT
.opnd
[rop
].X_add_number
- REG_AR
),
10603 else if (strcmp (idesc
->name
, "hint.b") == 0)
10609 case hint_b_warning
:
10610 as_warn (_("hint.b may be treated as nop"));
10613 as_bad (_("hint.b shouldn't be used"));
10619 if (md
.qp
.X_op
== O_register
)
10621 qp_regno
= md
.qp
.X_add_number
- REG_P
;
10622 md
.qp
.X_op
= O_absent
;
10625 flags
= idesc
->flags
;
10627 if ((flags
& IA64_OPCODE_FIRST
) != 0)
10629 /* The alignment frag has to end with a stop bit only if the
10630 next instruction after the alignment directive has to be
10631 the first instruction in an instruction group. */
10634 while (align_frag
->fr_type
!= rs_align_code
)
10636 align_frag
= align_frag
->fr_next
;
10640 /* align_frag can be NULL if there are directives in
10642 if (align_frag
&& align_frag
->fr_next
== frag_now
)
10643 align_frag
->tc_frag_data
= 1;
10646 insn_group_break (1, 0, 0);
10650 if ((flags
& IA64_OPCODE_NO_PRED
) != 0 && qp_regno
!= 0)
10652 as_bad (_("`%s' cannot be predicated"), idesc
->name
);
10656 /* Build the instruction. */
10657 CURR_SLOT
.qp_regno
= qp_regno
;
10658 CURR_SLOT
.idesc
= idesc
;
10659 as_where (&CURR_SLOT
.src_file
, &CURR_SLOT
.src_line
);
10660 dwarf2_where (&CURR_SLOT
.debug_line
);
10661 dwarf2_consume_line_info ();
10663 /* Add unwind entries, if there are any. */
10664 if (unwind
.current_entry
)
10666 CURR_SLOT
.unwind_record
= unwind
.current_entry
;
10667 unwind
.current_entry
= NULL
;
10669 if (unwind
.pending_saves
)
10671 if (unwind
.pending_saves
->next
)
10673 /* Attach the next pending save to the next slot so that its
10674 slot number will get set correctly. */
10675 add_unwind_entry (unwind
.pending_saves
->next
, NOT_A_CHAR
);
10676 unwind
.pending_saves
= &unwind
.pending_saves
->next
->r
.record
.p
;
10679 unwind
.pending_saves
= NULL
;
10681 if (unwind
.proc_pending
.sym
&& S_IS_DEFINED (unwind
.proc_pending
.sym
))
10684 /* Check for dependency violations. */
10688 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
10689 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
10690 emit_one_bundle ();
10692 if ((flags
& IA64_OPCODE_LAST
) != 0)
10693 insn_group_break (1, 0, 0);
10695 md
.last_text_seg
= now_seg
;
10698 input_line_pointer
= saved_input_line_pointer
;
10701 /* Called when symbol NAME cannot be found in the symbol table.
10702 Should be used for dynamic valued symbols only. */
10705 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
10710 /* Called for any expression that can not be recognized. When the
10711 function is called, `input_line_pointer' will point to the start of
10715 md_operand (expressionS
*e
)
10717 switch (*input_line_pointer
)
10720 ++input_line_pointer
;
10721 expression_and_evaluate (e
);
10722 if (*input_line_pointer
!= ']')
10724 as_bad (_("Closing bracket missing"));
10729 if (e
->X_op
!= O_register
10730 || e
->X_add_number
< REG_GR
10731 || e
->X_add_number
> REG_GR
+ 127)
10733 as_bad (_("Index must be a general register"));
10734 e
->X_add_number
= REG_GR
;
10737 ++input_line_pointer
;
10748 ignore_rest_of_line ();
10751 /* Return 1 if it's OK to adjust a reloc by replacing the symbol with
10752 a section symbol plus some offset. For relocs involving @fptr(),
10753 directives we don't want such adjustments since we need to have the
10754 original symbol's name in the reloc. */
10756 ia64_fix_adjustable (fixS
*fix
)
10758 /* Prevent all adjustments to global symbols */
10759 if (S_IS_EXTERNAL (fix
->fx_addsy
) || S_IS_WEAK (fix
->fx_addsy
))
10762 switch (fix
->fx_r_type
)
10764 case BFD_RELOC_IA64_FPTR64I
:
10765 case BFD_RELOC_IA64_FPTR32MSB
:
10766 case BFD_RELOC_IA64_FPTR32LSB
:
10767 case BFD_RELOC_IA64_FPTR64MSB
:
10768 case BFD_RELOC_IA64_FPTR64LSB
:
10769 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10770 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10780 ia64_force_relocation (fixS
*fix
)
10782 switch (fix
->fx_r_type
)
10784 case BFD_RELOC_IA64_FPTR64I
:
10785 case BFD_RELOC_IA64_FPTR32MSB
:
10786 case BFD_RELOC_IA64_FPTR32LSB
:
10787 case BFD_RELOC_IA64_FPTR64MSB
:
10788 case BFD_RELOC_IA64_FPTR64LSB
:
10790 case BFD_RELOC_IA64_LTOFF22
:
10791 case BFD_RELOC_IA64_LTOFF64I
:
10792 case BFD_RELOC_IA64_LTOFF_FPTR22
:
10793 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
10794 case BFD_RELOC_IA64_PLTOFF22
:
10795 case BFD_RELOC_IA64_PLTOFF64I
:
10796 case BFD_RELOC_IA64_PLTOFF64MSB
:
10797 case BFD_RELOC_IA64_PLTOFF64LSB
:
10799 case BFD_RELOC_IA64_LTOFF22X
:
10800 case BFD_RELOC_IA64_LDXMOV
:
10807 return generic_force_reloc (fix
);
10810 /* Decide from what point a pc-relative relocation is relative to,
10811 relative to the pc-relative fixup. Er, relatively speaking. */
10813 ia64_pcrel_from_section (fixS
*fix
, segT sec
)
10815 unsigned long off
= fix
->fx_frag
->fr_address
+ fix
->fx_where
;
10817 if (bfd_get_section_flags (stdoutput
, sec
) & SEC_CODE
)
10824 /* Used to emit section-relative relocs for the dwarf2 debug data. */
10826 ia64_dwarf2_emit_offset (symbolS
*symbol
, unsigned int size
)
10830 exp
.X_op
= O_pseudo_fixup
;
10831 exp
.X_op_symbol
= pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
;
10832 exp
.X_add_number
= 0;
10833 exp
.X_add_symbol
= symbol
;
10834 emit_expr (&exp
, size
);
10837 /* This is called whenever some data item (not an instruction) needs a
10838 fixup. We pick the right reloc code depending on the byteorder
10839 currently in effect. */
10841 ia64_cons_fix_new (fragS
*f
, int where
, int nbytes
, expressionS
*exp
)
10843 bfd_reloc_code_real_type code
;
10848 /* There are no reloc for 8 and 16 bit quantities, but we allow
10849 them here since they will work fine as long as the expression
10850 is fully defined at the end of the pass over the source file. */
10851 case 1: code
= BFD_RELOC_8
; break;
10852 case 2: code
= BFD_RELOC_16
; break;
10854 if (target_big_endian
)
10855 code
= BFD_RELOC_IA64_DIR32MSB
;
10857 code
= BFD_RELOC_IA64_DIR32LSB
;
10861 /* In 32-bit mode, data8 could mean function descriptors too. */
10862 if (exp
->X_op
== O_pseudo_fixup
10863 && exp
->X_op_symbol
10864 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
10865 && !(md
.flags
& EF_IA_64_ABI64
))
10867 if (target_big_endian
)
10868 code
= BFD_RELOC_IA64_IPLTMSB
;
10870 code
= BFD_RELOC_IA64_IPLTLSB
;
10871 exp
->X_op
= O_symbol
;
10876 if (target_big_endian
)
10877 code
= BFD_RELOC_IA64_DIR64MSB
;
10879 code
= BFD_RELOC_IA64_DIR64LSB
;
10884 if (exp
->X_op
== O_pseudo_fixup
10885 && exp
->X_op_symbol
10886 && S_GET_VALUE (exp
->X_op_symbol
) == FUNC_IPLT_RELOC
)
10888 if (target_big_endian
)
10889 code
= BFD_RELOC_IA64_IPLTMSB
;
10891 code
= BFD_RELOC_IA64_IPLTLSB
;
10892 exp
->X_op
= O_symbol
;
10898 as_bad (_("Unsupported fixup size %d"), nbytes
);
10899 ignore_rest_of_line ();
10903 if (exp
->X_op
== O_pseudo_fixup
)
10905 exp
->X_op
= O_symbol
;
10906 code
= ia64_gen_real_reloc_type (exp
->X_op_symbol
, code
);
10907 /* ??? If code unchanged, unsupported. */
10910 fix
= fix_new_exp (f
, where
, nbytes
, exp
, 0, code
);
10911 /* We need to store the byte order in effect in case we're going
10912 to fix an 8 or 16 bit relocation (for which there no real
10913 relocs available). See md_apply_fix(). */
10914 fix
->tc_fix_data
.bigendian
= target_big_endian
;
10917 /* Return the actual relocation we wish to associate with the pseudo
10918 reloc described by SYM and R_TYPE. SYM should be one of the
10919 symbols in the pseudo_func array, or NULL. */
10921 static bfd_reloc_code_real_type
10922 ia64_gen_real_reloc_type (struct symbol
*sym
, bfd_reloc_code_real_type r_type
)
10924 bfd_reloc_code_real_type newr
= 0;
10925 const char *type
= NULL
, *suffix
= "";
10932 switch (S_GET_VALUE (sym
))
10934 case FUNC_FPTR_RELATIVE
:
10937 case BFD_RELOC_IA64_IMM64
: newr
= BFD_RELOC_IA64_FPTR64I
; break;
10938 case BFD_RELOC_IA64_DIR32MSB
: newr
= BFD_RELOC_IA64_FPTR32MSB
; break;
10939 case BFD_RELOC_IA64_DIR32LSB
: newr
= BFD_RELOC_IA64_FPTR32LSB
; break;
10940 case BFD_RELOC_IA64_DIR64MSB
: newr
= BFD_RELOC_IA64_FPTR64MSB
; break;
10941 case BFD_RELOC_IA64_DIR64LSB
: newr
= BFD_RELOC_IA64_FPTR64LSB
; break;
10942 default: type
= "FPTR"; break;
10946 case FUNC_GP_RELATIVE
:
10949 case BFD_RELOC_IA64_IMM22
: newr
= BFD_RELOC_IA64_GPREL22
; break;
10950 case BFD_RELOC_IA64_IMM64
: newr
= BFD_RELOC_IA64_GPREL64I
; break;
10951 case BFD_RELOC_IA64_DIR32MSB
: newr
= BFD_RELOC_IA64_GPREL32MSB
; break;
10952 case BFD_RELOC_IA64_DIR32LSB
: newr
= BFD_RELOC_IA64_GPREL32LSB
; break;
10953 case BFD_RELOC_IA64_DIR64MSB
: newr
= BFD_RELOC_IA64_GPREL64MSB
; break;
10954 case BFD_RELOC_IA64_DIR64LSB
: newr
= BFD_RELOC_IA64_GPREL64LSB
; break;
10955 default: type
= "GPREL"; break;
10959 case FUNC_LT_RELATIVE
:
10962 case BFD_RELOC_IA64_IMM22
: newr
= BFD_RELOC_IA64_LTOFF22
; break;
10963 case BFD_RELOC_IA64_IMM64
: newr
= BFD_RELOC_IA64_LTOFF64I
; break;
10964 default: type
= "LTOFF"; break;
10968 case FUNC_LT_RELATIVE_X
:
10971 case BFD_RELOC_IA64_IMM22
: newr
= BFD_RELOC_IA64_LTOFF22X
; break;
10972 default: type
= "LTOFF"; suffix
= "X"; break;
10976 case FUNC_PC_RELATIVE
:
10979 case BFD_RELOC_IA64_IMM22
: newr
= BFD_RELOC_IA64_PCREL22
; break;
10980 case BFD_RELOC_IA64_IMM64
: newr
= BFD_RELOC_IA64_PCREL64I
; break;
10981 case BFD_RELOC_IA64_DIR32MSB
: newr
= BFD_RELOC_IA64_PCREL32MSB
; break;
10982 case BFD_RELOC_IA64_DIR32LSB
: newr
= BFD_RELOC_IA64_PCREL32LSB
; break;
10983 case BFD_RELOC_IA64_DIR64MSB
: newr
= BFD_RELOC_IA64_PCREL64MSB
; break;
10984 case BFD_RELOC_IA64_DIR64LSB
: newr
= BFD_RELOC_IA64_PCREL64LSB
; break;
10985 default: type
= "PCREL"; break;
10989 case FUNC_PLT_RELATIVE
:
10992 case BFD_RELOC_IA64_IMM22
: newr
= BFD_RELOC_IA64_PLTOFF22
; break;
10993 case BFD_RELOC_IA64_IMM64
: newr
= BFD_RELOC_IA64_PLTOFF64I
; break;
10994 case BFD_RELOC_IA64_DIR64MSB
: newr
= BFD_RELOC_IA64_PLTOFF64MSB
;break;
10995 case BFD_RELOC_IA64_DIR64LSB
: newr
= BFD_RELOC_IA64_PLTOFF64LSB
;break;
10996 default: type
= "PLTOFF"; break;
11000 case FUNC_SEC_RELATIVE
:
11003 case BFD_RELOC_IA64_DIR32MSB
: newr
= BFD_RELOC_IA64_SECREL32MSB
;break;
11004 case BFD_RELOC_IA64_DIR32LSB
: newr
= BFD_RELOC_IA64_SECREL32LSB
;break;
11005 case BFD_RELOC_IA64_DIR64MSB
: newr
= BFD_RELOC_IA64_SECREL64MSB
;break;
11006 case BFD_RELOC_IA64_DIR64LSB
: newr
= BFD_RELOC_IA64_SECREL64LSB
;break;
11007 default: type
= "SECREL"; break;
11011 case FUNC_SEG_RELATIVE
:
11014 case BFD_RELOC_IA64_DIR32MSB
: newr
= BFD_RELOC_IA64_SEGREL32MSB
;break;
11015 case BFD_RELOC_IA64_DIR32LSB
: newr
= BFD_RELOC_IA64_SEGREL32LSB
;break;
11016 case BFD_RELOC_IA64_DIR64MSB
: newr
= BFD_RELOC_IA64_SEGREL64MSB
;break;
11017 case BFD_RELOC_IA64_DIR64LSB
: newr
= BFD_RELOC_IA64_SEGREL64LSB
;break;
11018 default: type
= "SEGREL"; break;
11022 case FUNC_LTV_RELATIVE
:
11025 case BFD_RELOC_IA64_DIR32MSB
: newr
= BFD_RELOC_IA64_LTV32MSB
; break;
11026 case BFD_RELOC_IA64_DIR32LSB
: newr
= BFD_RELOC_IA64_LTV32LSB
; break;
11027 case BFD_RELOC_IA64_DIR64MSB
: newr
= BFD_RELOC_IA64_LTV64MSB
; break;
11028 case BFD_RELOC_IA64_DIR64LSB
: newr
= BFD_RELOC_IA64_LTV64LSB
; break;
11029 default: type
= "LTV"; break;
11033 case FUNC_LT_FPTR_RELATIVE
:
11036 case BFD_RELOC_IA64_IMM22
:
11037 newr
= BFD_RELOC_IA64_LTOFF_FPTR22
; break;
11038 case BFD_RELOC_IA64_IMM64
:
11039 newr
= BFD_RELOC_IA64_LTOFF_FPTR64I
; break;
11040 case BFD_RELOC_IA64_DIR32MSB
:
11041 newr
= BFD_RELOC_IA64_LTOFF_FPTR32MSB
; break;
11042 case BFD_RELOC_IA64_DIR32LSB
:
11043 newr
= BFD_RELOC_IA64_LTOFF_FPTR32LSB
; break;
11044 case BFD_RELOC_IA64_DIR64MSB
:
11045 newr
= BFD_RELOC_IA64_LTOFF_FPTR64MSB
; break;
11046 case BFD_RELOC_IA64_DIR64LSB
:
11047 newr
= BFD_RELOC_IA64_LTOFF_FPTR64LSB
; break;
11049 type
= "LTOFF_FPTR"; break;
11053 case FUNC_TP_RELATIVE
:
11056 case BFD_RELOC_IA64_IMM14
: newr
= BFD_RELOC_IA64_TPREL14
; break;
11057 case BFD_RELOC_IA64_IMM22
: newr
= BFD_RELOC_IA64_TPREL22
; break;
11058 case BFD_RELOC_IA64_IMM64
: newr
= BFD_RELOC_IA64_TPREL64I
; break;
11059 case BFD_RELOC_IA64_DIR64MSB
: newr
= BFD_RELOC_IA64_TPREL64MSB
; break;
11060 case BFD_RELOC_IA64_DIR64LSB
: newr
= BFD_RELOC_IA64_TPREL64LSB
; break;
11061 default: type
= "TPREL"; break;
11065 case FUNC_LT_TP_RELATIVE
:
11068 case BFD_RELOC_IA64_IMM22
:
11069 newr
= BFD_RELOC_IA64_LTOFF_TPREL22
; break;
11071 type
= "LTOFF_TPREL"; break;
11075 case FUNC_DTP_MODULE
:
11078 case BFD_RELOC_IA64_DIR64MSB
:
11079 newr
= BFD_RELOC_IA64_DTPMOD64MSB
; break;
11080 case BFD_RELOC_IA64_DIR64LSB
:
11081 newr
= BFD_RELOC_IA64_DTPMOD64LSB
; break;
11083 type
= "DTPMOD"; break;
11087 case FUNC_LT_DTP_MODULE
:
11090 case BFD_RELOC_IA64_IMM22
:
11091 newr
= BFD_RELOC_IA64_LTOFF_DTPMOD22
; break;
11093 type
= "LTOFF_DTPMOD"; break;
11097 case FUNC_DTP_RELATIVE
:
11100 case BFD_RELOC_IA64_DIR32MSB
:
11101 newr
= BFD_RELOC_IA64_DTPREL32MSB
; break;
11102 case BFD_RELOC_IA64_DIR32LSB
:
11103 newr
= BFD_RELOC_IA64_DTPREL32LSB
; break;
11104 case BFD_RELOC_IA64_DIR64MSB
:
11105 newr
= BFD_RELOC_IA64_DTPREL64MSB
; break;
11106 case BFD_RELOC_IA64_DIR64LSB
:
11107 newr
= BFD_RELOC_IA64_DTPREL64LSB
; break;
11108 case BFD_RELOC_IA64_IMM14
:
11109 newr
= BFD_RELOC_IA64_DTPREL14
; break;
11110 case BFD_RELOC_IA64_IMM22
:
11111 newr
= BFD_RELOC_IA64_DTPREL22
; break;
11112 case BFD_RELOC_IA64_IMM64
:
11113 newr
= BFD_RELOC_IA64_DTPREL64I
; break;
11115 type
= "DTPREL"; break;
11119 case FUNC_LT_DTP_RELATIVE
:
11122 case BFD_RELOC_IA64_IMM22
:
11123 newr
= BFD_RELOC_IA64_LTOFF_DTPREL22
; break;
11125 type
= "LTOFF_DTPREL"; break;
11129 case FUNC_IPLT_RELOC
:
11132 case BFD_RELOC_IA64_IPLTMSB
: return r_type
;
11133 case BFD_RELOC_IA64_IPLTLSB
: return r_type
;
11134 default: type
= "IPLT"; break;
11139 case FUNC_SLOTCOUNT_RELOC
:
11140 return DUMMY_RELOC_IA64_SLOTCOUNT
;
11157 case BFD_RELOC_IA64_DIR32MSB
: width
= 32; suffix
= "MSB"; break;
11158 case BFD_RELOC_IA64_DIR32LSB
: width
= 32; suffix
= "LSB"; break;
11159 case BFD_RELOC_IA64_DIR64MSB
: width
= 64; suffix
= "MSB"; break;
11160 case BFD_RELOC_IA64_DIR64LSB
: width
= 64; suffix
= "LSB"; break;
11161 case BFD_RELOC_UNUSED
: width
= 13; break;
11162 case BFD_RELOC_IA64_IMM14
: width
= 14; break;
11163 case BFD_RELOC_IA64_IMM22
: width
= 22; break;
11164 case BFD_RELOC_IA64_IMM64
: width
= 64; suffix
= "I"; break;
11168 /* This should be an error, but since previously there wasn't any
11169 diagnostic here, don't make it fail because of this for now. */
11170 as_warn (_("Cannot express %s%d%s relocation"), type
, width
, suffix
);
11175 /* Here is where generate the appropriate reloc for pseudo relocation
11178 ia64_validate_fix (fixS
*fix
)
11180 switch (fix
->fx_r_type
)
11182 case BFD_RELOC_IA64_FPTR64I
:
11183 case BFD_RELOC_IA64_FPTR32MSB
:
11184 case BFD_RELOC_IA64_FPTR64LSB
:
11185 case BFD_RELOC_IA64_LTOFF_FPTR22
:
11186 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
11187 if (fix
->fx_offset
!= 0)
11188 as_bad_where (fix
->fx_file
, fix
->fx_line
,
11189 _("No addend allowed in @fptr() relocation"));
11197 fix_insn (fixS
*fix
, const struct ia64_operand
*odesc
, valueT value
)
11199 bfd_vma insn
[3], t0
, t1
, control_bits
;
11204 slot
= fix
->fx_where
& 0x3;
11205 fixpos
= fix
->fx_frag
->fr_literal
+ (fix
->fx_where
- slot
);
11207 /* Bundles are always in little-endian byte order */
11208 t0
= bfd_getl64 (fixpos
);
11209 t1
= bfd_getl64 (fixpos
+ 8);
11210 control_bits
= t0
& 0x1f;
11211 insn
[0] = (t0
>> 5) & 0x1ffffffffffLL
;
11212 insn
[1] = ((t0
>> 46) & 0x3ffff) | ((t1
& 0x7fffff) << 18);
11213 insn
[2] = (t1
>> 23) & 0x1ffffffffffLL
;
11216 if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU64
)
11218 insn
[1] = (value
>> 22) & 0x1ffffffffffLL
;
11219 insn
[2] |= (((value
& 0x7f) << 13)
11220 | (((value
>> 7) & 0x1ff) << 27)
11221 | (((value
>> 16) & 0x1f) << 22)
11222 | (((value
>> 21) & 0x1) << 21)
11223 | (((value
>> 63) & 0x1) << 36));
11225 else if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU62
)
11227 if (value
& ~0x3fffffffffffffffULL
)
11228 err
= _("integer operand out of range");
11229 insn
[1] = (value
>> 21) & 0x1ffffffffffLL
;
11230 insn
[2] |= (((value
& 0xfffff) << 6) | (((value
>> 20) & 0x1) << 36));
11232 else if (odesc
- elf64_ia64_operands
== IA64_OPND_TGT64
)
11235 insn
[1] = ((value
>> 20) & 0x7fffffffffLL
) << 2;
11236 insn
[2] |= ((((value
>> 59) & 0x1) << 36)
11237 | (((value
>> 0) & 0xfffff) << 13));
11240 err
= (*odesc
->insert
) (odesc
, value
, insn
+ slot
);
11243 as_bad_where (fix
->fx_file
, fix
->fx_line
, "%s", err
);
11245 t0
= control_bits
| (insn
[0] << 5) | (insn
[1] << 46);
11246 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
11247 number_to_chars_littleendian (fixpos
+ 0, t0
, 8);
11248 number_to_chars_littleendian (fixpos
+ 8, t1
, 8);
11251 /* Attempt to simplify or even eliminate a fixup. The return value is
11252 ignored; perhaps it was once meaningful, but now it is historical.
11253 To indicate that a fixup has been eliminated, set FIXP->FX_DONE.
11255 If fixp->fx_addsy is non-NULL, we'll have to generate a reloc entry
11259 md_apply_fix (fixS
*fix
, valueT
*valP
, segT seg ATTRIBUTE_UNUSED
)
11262 valueT value
= *valP
;
11264 fixpos
= fix
->fx_frag
->fr_literal
+ fix
->fx_where
;
11268 switch (fix
->fx_r_type
)
11270 case BFD_RELOC_IA64_PCREL21B
: break;
11271 case BFD_RELOC_IA64_PCREL21BI
: break;
11272 case BFD_RELOC_IA64_PCREL21F
: break;
11273 case BFD_RELOC_IA64_PCREL21M
: break;
11274 case BFD_RELOC_IA64_PCREL60B
: break;
11275 case BFD_RELOC_IA64_PCREL22
: break;
11276 case BFD_RELOC_IA64_PCREL64I
: break;
11277 case BFD_RELOC_IA64_PCREL32MSB
: break;
11278 case BFD_RELOC_IA64_PCREL32LSB
: break;
11279 case BFD_RELOC_IA64_PCREL64MSB
: break;
11280 case BFD_RELOC_IA64_PCREL64LSB
: break;
11282 fix
->fx_r_type
= ia64_gen_real_reloc_type (pseudo_func
[FUNC_PC_RELATIVE
].u
.sym
,
11289 switch (fix
->fx_r_type
)
11291 case BFD_RELOC_UNUSED
:
11292 /* This must be a TAG13 or TAG13b operand. There are no external
11293 relocs defined for them, so we must give an error. */
11294 as_bad_where (fix
->fx_file
, fix
->fx_line
,
11295 _("%s must have a constant value"),
11296 elf64_ia64_operands
[fix
->tc_fix_data
.opnd
].desc
);
11300 case BFD_RELOC_IA64_TPREL14
:
11301 case BFD_RELOC_IA64_TPREL22
:
11302 case BFD_RELOC_IA64_TPREL64I
:
11303 case BFD_RELOC_IA64_LTOFF_TPREL22
:
11304 case BFD_RELOC_IA64_LTOFF_DTPMOD22
:
11305 case BFD_RELOC_IA64_DTPREL14
:
11306 case BFD_RELOC_IA64_DTPREL22
:
11307 case BFD_RELOC_IA64_DTPREL64I
:
11308 case BFD_RELOC_IA64_LTOFF_DTPREL22
:
11309 S_SET_THREAD_LOCAL (fix
->fx_addsy
);
11313 case DUMMY_RELOC_IA64_SLOTCOUNT
:
11314 as_bad_where (fix
->fx_file
, fix
->fx_line
,
11315 _("cannot resolve @slotcount parameter"));
11324 else if (fix
->tc_fix_data
.opnd
== IA64_OPND_NIL
)
11327 if (fix
->fx_r_type
== DUMMY_RELOC_IA64_SLOTCOUNT
)
11329 /* For @slotcount, convert an addresses difference to a slots
11333 v
= (value
>> 4) * 3;
11334 switch (value
& 0x0f)
11348 as_bad (_("invalid @slotcount value"));
11354 if (fix
->tc_fix_data
.bigendian
)
11355 number_to_chars_bigendian (fixpos
, value
, fix
->fx_size
);
11357 number_to_chars_littleendian (fixpos
, value
, fix
->fx_size
);
11362 fix_insn (fix
, elf64_ia64_operands
+ fix
->tc_fix_data
.opnd
, value
);
11367 /* Generate the BFD reloc to be stuck in the object file from the
11368 fixup used internally in the assembler. */
11371 tc_gen_reloc (asection
*sec ATTRIBUTE_UNUSED
, fixS
*fixp
)
11375 reloc
= xmalloc (sizeof (*reloc
));
11376 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
11377 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
11378 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
11379 reloc
->addend
= fixp
->fx_offset
;
11380 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
11384 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
11385 _("Cannot represent %s relocation in object file"),
11386 bfd_get_reloc_code_name (fixp
->fx_r_type
));
11393 /* Turn a string in input_line_pointer into a floating point constant
11394 of type TYPE, and store the appropriate bytes in *LIT. The number
11395 of LITTLENUMS emitted is stored in *SIZE. An error message is
11396 returned, or NULL on OK. */
11398 #define MAX_LITTLENUMS 5
11401 md_atof (int type
, char *lit
, int *size
)
11403 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
11433 return _("Unrecognized or unsupported floating point constant");
11435 t
= atof_ieee (input_line_pointer
, type
, words
);
11437 input_line_pointer
= t
;
11439 (*ia64_float_to_chars
) (lit
, words
, prec
);
11443 /* It is 10 byte floating point with 6 byte padding. */
11444 memset (&lit
[10], 0, 6);
11445 *size
= 8 * sizeof (LITTLENUM_TYPE
);
11448 *size
= prec
* sizeof (LITTLENUM_TYPE
);
11453 /* Handle ia64 specific semantics of the align directive. */
11456 ia64_md_do_align (int n ATTRIBUTE_UNUSED
,
11457 const char *fill ATTRIBUTE_UNUSED
,
11458 int len ATTRIBUTE_UNUSED
,
11459 int max ATTRIBUTE_UNUSED
)
11461 if (subseg_text_p (now_seg
))
11462 ia64_flush_insns ();
11465 /* This is called from HANDLE_ALIGN in write.c. Fill in the contents
11466 of an rs_align_code fragment. */
11469 ia64_handle_align (fragS
*fragp
)
11473 const unsigned char *nop_type
;
11475 if (fragp
->fr_type
!= rs_align_code
)
11478 /* Check if this frag has to end with a stop bit. */
11479 nop_type
= fragp
->tc_frag_data
? le_nop_stop
: le_nop
;
11481 bytes
= fragp
->fr_next
->fr_address
- fragp
->fr_address
- fragp
->fr_fix
;
11482 p
= fragp
->fr_literal
+ fragp
->fr_fix
;
11484 /* If no paddings are needed, we check if we need a stop bit. */
11485 if (!bytes
&& fragp
->tc_frag_data
)
11487 if (fragp
->fr_fix
< 16)
11489 /* FIXME: It won't work with
11491 alloc r32=ar.pfs,1,2,4,0
11495 as_bad_where (fragp
->fr_file
, fragp
->fr_line
,
11496 _("Can't add stop bit to mark end of instruction group"));
11499 /* Bundles are always in little-endian byte order. Make sure
11500 the previous bundle has the stop bit. */
11504 /* Make sure we are on a 16-byte boundary, in case someone has been
11505 putting data into a text section. */
11508 int fix
= bytes
& 15;
11509 memset (p
, 0, fix
);
11512 fragp
->fr_fix
+= fix
;
11515 /* Instruction bundles are always little-endian. */
11516 memcpy (p
, nop_type
, 16);
11517 fragp
->fr_var
= 16;
11521 ia64_float_to_chars_bigendian (char *lit
, LITTLENUM_TYPE
*words
,
11526 number_to_chars_bigendian (lit
, (long) (*words
++),
11527 sizeof (LITTLENUM_TYPE
));
11528 lit
+= sizeof (LITTLENUM_TYPE
);
11533 ia64_float_to_chars_littleendian (char *lit
, LITTLENUM_TYPE
*words
,
11538 number_to_chars_littleendian (lit
, (long) (words
[prec
]),
11539 sizeof (LITTLENUM_TYPE
));
11540 lit
+= sizeof (LITTLENUM_TYPE
);
11545 ia64_elf_section_change_hook (void)
11547 if (elf_section_type (now_seg
) == SHT_IA_64_UNWIND
11548 && elf_linked_to_section (now_seg
) == NULL
)
11549 elf_linked_to_section (now_seg
) = text_section
;
11550 dot_byteorder (-1);
11553 /* Check if a label should be made global. */
11555 ia64_check_label (symbolS
*label
)
11557 if (*input_line_pointer
== ':')
11559 S_SET_EXTERNAL (label
);
11560 input_line_pointer
++;
11564 /* Used to remember where .alias and .secalias directives are seen. We
11565 will rename symbol and section names when we are about to output
11566 the relocatable file. */
11569 char *file
; /* The file where the directive is seen. */
11570 unsigned int line
; /* The line number the directive is at. */
11571 const char *name
; /* The original name of the symbol. */
11574 /* Called for .alias and .secalias directives. If SECTION is 1, it is
11575 .secalias. Otherwise, it is .alias. */
11577 dot_alias (int section
)
11579 char *name
, *alias
;
11583 const char *error_string
;
11586 struct hash_control
*ahash
, *nhash
;
11589 name
= input_line_pointer
;
11590 delim
= get_symbol_end ();
11591 end_name
= input_line_pointer
;
11594 if (name
== end_name
)
11596 as_bad (_("expected symbol name"));
11597 ignore_rest_of_line ();
11601 SKIP_WHITESPACE ();
11603 if (*input_line_pointer
!= ',')
11606 as_bad (_("expected comma after \"%s\""), name
);
11608 ignore_rest_of_line ();
11612 input_line_pointer
++;
11614 ia64_canonicalize_symbol_name (name
);
11616 /* We call demand_copy_C_string to check if alias string is valid.
11617 There should be a closing `"' and no `\0' in the string. */
11618 alias
= demand_copy_C_string (&len
);
11621 ignore_rest_of_line ();
11625 /* Make a copy of name string. */
11626 len
= strlen (name
) + 1;
11627 obstack_grow (¬es
, name
, len
);
11628 name
= obstack_finish (¬es
);
11633 ahash
= secalias_hash
;
11634 nhash
= secalias_name_hash
;
11639 ahash
= alias_hash
;
11640 nhash
= alias_name_hash
;
11643 /* Check if alias has been used before. */
11644 h
= (struct alias
*) hash_find (ahash
, alias
);
11647 if (strcmp (h
->name
, name
))
11648 as_bad (_("`%s' is already the alias of %s `%s'"),
11649 alias
, kind
, h
->name
);
11653 /* Check if name already has an alias. */
11654 a
= (const char *) hash_find (nhash
, name
);
11657 if (strcmp (a
, alias
))
11658 as_bad (_("%s `%s' already has an alias `%s'"), kind
, name
, a
);
11662 h
= (struct alias
*) xmalloc (sizeof (struct alias
));
11663 as_where (&h
->file
, &h
->line
);
11666 error_string
= hash_jam (ahash
, alias
, (void *) h
);
11669 as_fatal (_("inserting \"%s\" into %s alias hash table failed: %s"),
11670 alias
, kind
, error_string
);
11674 error_string
= hash_jam (nhash
, name
, (void *) alias
);
11677 as_fatal (_("inserting \"%s\" into %s name hash table failed: %s"),
11678 alias
, kind
, error_string
);
11680 obstack_free (¬es
, name
);
11681 obstack_free (¬es
, alias
);
11684 demand_empty_rest_of_line ();
11687 /* It renames the original symbol name to its alias. */
11689 do_alias (const char *alias
, void *value
)
11691 struct alias
*h
= (struct alias
*) value
;
11692 symbolS
*sym
= symbol_find (h
->name
);
11697 /* Uses .alias extensively to alias CRTL functions to same with
11698 decc$ prefix. Sometimes function gets optimized away and a
11699 warning results, which should be suppressed. */
11700 if (strncmp (alias
, "decc$", 5) != 0)
11702 as_warn_where (h
->file
, h
->line
,
11703 _("symbol `%s' aliased to `%s' is not used"),
11707 S_SET_NAME (sym
, (char *) alias
);
11710 /* Called from write_object_file. */
11712 ia64_adjust_symtab (void)
11714 hash_traverse (alias_hash
, do_alias
);
11717 /* It renames the original section name to its alias. */
11719 do_secalias (const char *alias
, void *value
)
11721 struct alias
*h
= (struct alias
*) value
;
11722 segT sec
= bfd_get_section_by_name (stdoutput
, h
->name
);
11725 as_warn_where (h
->file
, h
->line
,
11726 _("section `%s' aliased to `%s' is not used"),
11732 /* Called from write_object_file. */
11734 ia64_frob_file (void)
11736 hash_traverse (secalias_hash
, do_secalias
);
11740 #define NT_VMS_MHD 1
11741 #define NT_VMS_LNM 2
11743 /* Integrity VMS 8.x identifies it's ELF modules with a standard ELF
11746 /* Manufacture a VMS-like time string. */
11748 get_vms_time (char *Now
)
11754 pnt
= ctime (&timeb
);
11760 sprintf (Now
, "%2s-%3s-%s %s", pnt
+ 8, pnt
+ 4, pnt
+ 20, pnt
+ 11);
11764 ia64_vms_note (void)
11767 asection
*seg
= now_seg
;
11768 subsegT subseg
= now_subseg
;
11769 asection
*secp
= NULL
;
11774 /* Create the .note section. */
11776 secp
= subseg_new (".note", 0);
11777 bfd_set_section_flags (stdoutput
,
11779 SEC_HAS_CONTENTS
| SEC_READONLY
);
11781 /* Module header note (MHD). */
11782 bname
= xstrdup (lbasename (out_file_name
));
11783 if ((p
= strrchr (bname
, '.')))
11786 /* VMS note header is 24 bytes long. */
11787 p
= frag_more (8 + 8 + 8);
11788 number_to_chars_littleendian (p
+ 0, 8, 8);
11789 number_to_chars_littleendian (p
+ 8, 40 + strlen (bname
), 8);
11790 number_to_chars_littleendian (p
+ 16, NT_VMS_MHD
, 8);
11793 strcpy (p
, "IPF/VMS");
11795 p
= frag_more (17 + 17 + strlen (bname
) + 1 + 5);
11797 strcpy (p
+ 17, "24-FEB-2005 15:00");
11800 p
+= strlen (bname
) + 1;
11802 strcpy (p
, "V1.0");
11804 frag_align (3, 0, 0);
11806 /* Language processor name note. */
11807 sprintf (buf
, "GNU assembler version %s (%s) using BFD version %s",
11808 VERSION
, TARGET_ALIAS
, BFD_VERSION_STRING
);
11810 p
= frag_more (8 + 8 + 8);
11811 number_to_chars_littleendian (p
+ 0, 8, 8);
11812 number_to_chars_littleendian (p
+ 8, strlen (buf
) + 1, 8);
11813 number_to_chars_littleendian (p
+ 16, NT_VMS_LNM
, 8);
11816 strcpy (p
, "IPF/VMS");
11818 p
= frag_more (strlen (buf
) + 1);
11821 frag_align (3, 0, 0);
11823 secp
= subseg_new (".vms_display_name_info", 0);
11824 bfd_set_section_flags (stdoutput
,
11826 SEC_HAS_CONTENTS
| SEC_READONLY
);
11828 /* This symbol should be passed on the command line and be variable
11829 according to language. */
11830 sym
= symbol_new ("__gnat_vms_display_name@gnat_demangler_rtl",
11831 absolute_section
, 0, &zero_address_frag
);
11832 symbol_table_insert (sym
);
11833 symbol_get_bfdsym (sym
)->flags
|= BSF_DEBUGGING
| BSF_DYNAMIC
;
11836 /* Format 3 of VMS demangler Spec. */
11837 number_to_chars_littleendian (p
, 3, 4);
11840 /* Place holder for symbol table index of above symbol. */
11841 number_to_chars_littleendian (p
, -1, 4);
11843 frag_align (3, 0, 0);
11845 /* We probably can't restore the current segment, for there likely
11846 isn't one yet... */
11848 subseg_set (seg
, subseg
);
11851 #endif /* TE_VMS */