1 /* tc-ia64.c -- Assembler for the HP/Intel IA-64 architecture.
2 Copyright (C) 1998, 1999, 2000 Free Software Foundation.
3 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
35 - labels are wrong if automatic alignment is introduced
36 (e.g., checkout the second real10 definition in test-data.s)
38 <reg>.safe_across_calls and any other DV-related directives I don't
39 have documentation for.
40 verify mod-sched-brs reads/writes are checked/marked (and other
46 #include "dwarf2dbg.h"
49 #include "opcode/ia64.h"
53 #define NELEMS(a) ((int) (sizeof (a)/sizeof ((a)[0])))
54 #define MIN(a,b) ((a) < (b) ? (a) : (b))
57 #define PREV_SLOT md.slot[(md.curr_slot + NUM_SLOTS - 1) % NUM_SLOTS]
58 #define CURR_SLOT md.slot[md.curr_slot]
60 #define O_pseudo_fixup (O_max + 1)
64 SPECIAL_SECTION_BSS
= 0,
66 SPECIAL_SECTION_SDATA
,
67 SPECIAL_SECTION_RODATA
,
68 SPECIAL_SECTION_COMMENT
,
69 SPECIAL_SECTION_UNWIND
,
70 SPECIAL_SECTION_UNWIND_INFO
83 FUNC_LT_FPTR_RELATIVE
,
89 REG_FR
= (REG_GR
+ 128),
90 REG_AR
= (REG_FR
+ 128),
91 REG_CR
= (REG_AR
+ 128),
92 REG_P
= (REG_CR
+ 128),
93 REG_BR
= (REG_P
+ 64),
94 REG_IP
= (REG_BR
+ 8),
101 /* The following are pseudo-registers for use by gas only. */
113 /* The following pseudo-registers are used for unwind directives only: */
121 DYNREG_GR
= 0, /* dynamic general purpose register */
122 DYNREG_FR
, /* dynamic floating point register */
123 DYNREG_PR
, /* dynamic predicate register */
127 /* On the ia64, we can't know the address of a text label until the
128 instructions are packed into a bundle. To handle this, we keep
129 track of the list of labels that appear in front of each
133 struct label_fix
*next
;
137 extern int target_big_endian
;
139 /* Characters which always start a comment. */
140 const char comment_chars
[] = "";
142 /* Characters which start a comment at the beginning of a line. */
143 const char line_comment_chars
[] = "#";
145 /* Characters which may be used to separate multiple commands on a
147 const char line_separator_chars
[] = ";";
149 /* Characters which are used to indicate an exponent in a floating
151 const char EXP_CHARS
[] = "eE";
153 /* Characters which mean that a number is a floating point constant,
155 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
157 /* ia64-specific option processing: */
159 const char *md_shortopts
= "M:N:x::";
161 struct option md_longopts
[] =
163 #define OPTION_MCONSTANT_GP (OPTION_MD_BASE + 1)
164 {"mconstant-gp", no_argument
, NULL
, OPTION_MCONSTANT_GP
},
165 #define OPTION_MAUTO_PIC (OPTION_MD_BASE + 2)
166 {"mauto-pic", no_argument
, NULL
, OPTION_MAUTO_PIC
}
169 size_t md_longopts_size
= sizeof (md_longopts
);
173 struct hash_control
*pseudo_hash
; /* pseudo opcode hash table */
174 struct hash_control
*reg_hash
; /* register name hash table */
175 struct hash_control
*dynreg_hash
; /* dynamic register hash table */
176 struct hash_control
*const_hash
; /* constant hash table */
177 struct hash_control
*entry_hash
; /* code entry hint hash table */
179 symbolS
*regsym
[REG_NUM
];
181 /* If X_op is != O_absent, the registername for the instruction's
182 qualifying predicate. If NULL, p0 is assumed for instructions
183 that are predicatable. */
190 explicit_mode
: 1, /* which mode we're in */
191 default_explicit_mode
: 1, /* which mode is the default */
192 mode_explicitly_set
: 1, /* was the current mode explicitly set? */
195 /* Each bundle consists of up to three instructions. We keep
196 track of four most recent instructions so we can correctly set
197 the end_of_insn_group for the last instruction in a bundle. */
199 int num_slots_in_use
;
203 end_of_insn_group
: 1,
204 manual_bundling_on
: 1,
205 manual_bundling_off
: 1;
206 signed char user_template
; /* user-selected template, if any */
207 unsigned char qp_regno
; /* qualifying predicate */
208 /* This duplicates a good fraction of "struct fix" but we
209 can't use a "struct fix" instead since we can't call
210 fix_new_exp() until we know the address of the instruction. */
214 bfd_reloc_code_real_type code
;
215 enum ia64_opnd opnd
; /* type of operand in need of fix */
216 unsigned int is_pcrel
: 1; /* is operand pc-relative? */
217 expressionS expr
; /* the value to be inserted */
219 fixup
[2]; /* at most two fixups per insn */
220 struct ia64_opcode
*idesc
;
221 struct label_fix
*label_fixups
;
222 struct unw_rec_list
*unwind_record
; /* Unwind directive. */
225 unsigned int src_line
;
226 struct dwarf2_line_info debug_line
;
234 struct dynreg
*next
; /* next dynamic register */
236 unsigned short base
; /* the base register number */
237 unsigned short num_regs
; /* # of registers in this set */
239 *dynreg
[DYNREG_NUM_TYPES
], in
, loc
, out
, rot
;
241 flagword flags
; /* ELF-header flags */
244 unsigned hint
:1; /* is this hint currently valid? */
245 bfd_vma offset
; /* mem.offset offset */
246 bfd_vma base
; /* mem.offset base */
249 int path
; /* number of alt. entry points seen */
250 const char **entry_labels
; /* labels of all alternate paths in
251 the current DV-checking block. */
252 int maxpaths
; /* size currently allocated for
257 /* application registers: */
263 #define AR_BSPSTORE 18
278 {"ar.k0", 0}, {"ar.k1", 1}, {"ar.k2", 2}, {"ar.k3", 3},
279 {"ar.k4", 4}, {"ar.k5", 5}, {"ar.k6", 6}, {"ar.k7", 7},
280 {"ar.rsc", 16}, {"ar.bsp", 17},
281 {"ar.bspstore", 18}, {"ar.rnat", 19},
282 {"ar.fcr", 21}, {"ar.eflag", 24},
283 {"ar.csd", 25}, {"ar.ssd", 26},
284 {"ar.cflg", 27}, {"ar.fsr", 28},
285 {"ar.fir", 29}, {"ar.fdr", 30},
286 {"ar.ccv", 32}, {"ar.unat", 36},
287 {"ar.fpsr", 40}, {"ar.itc", 44},
288 {"ar.pfs", 64}, {"ar.lc", 65},
309 /* control registers: */
351 static const struct const_desc
358 /* PSR constant masks: */
361 {"psr.be", ((valueT
) 1) << 1},
362 {"psr.up", ((valueT
) 1) << 2},
363 {"psr.ac", ((valueT
) 1) << 3},
364 {"psr.mfl", ((valueT
) 1) << 4},
365 {"psr.mfh", ((valueT
) 1) << 5},
367 {"psr.ic", ((valueT
) 1) << 13},
368 {"psr.i", ((valueT
) 1) << 14},
369 {"psr.pk", ((valueT
) 1) << 15},
371 {"psr.dt", ((valueT
) 1) << 17},
372 {"psr.dfl", ((valueT
) 1) << 18},
373 {"psr.dfh", ((valueT
) 1) << 19},
374 {"psr.sp", ((valueT
) 1) << 20},
375 {"psr.pp", ((valueT
) 1) << 21},
376 {"psr.di", ((valueT
) 1) << 22},
377 {"psr.si", ((valueT
) 1) << 23},
378 {"psr.db", ((valueT
) 1) << 24},
379 {"psr.lp", ((valueT
) 1) << 25},
380 {"psr.tb", ((valueT
) 1) << 26},
381 {"psr.rt", ((valueT
) 1) << 27},
382 /* 28-31: reserved */
383 /* 32-33: cpl (current privilege level) */
384 {"psr.is", ((valueT
) 1) << 34},
385 {"psr.mc", ((valueT
) 1) << 35},
386 {"psr.it", ((valueT
) 1) << 36},
387 {"psr.id", ((valueT
) 1) << 37},
388 {"psr.da", ((valueT
) 1) << 38},
389 {"psr.dd", ((valueT
) 1) << 39},
390 {"psr.ss", ((valueT
) 1) << 40},
391 /* 41-42: ri (restart instruction) */
392 {"psr.ed", ((valueT
) 1) << 43},
393 {"psr.bn", ((valueT
) 1) << 44},
396 /* indirect register-sets/memory: */
405 { "CPUID", IND_CPUID
},
406 { "cpuid", IND_CPUID
},
418 /* Pseudo functions used to indicate relocation types (these functions
419 start with an at sign (@). */
441 /* reloc pseudo functions (these must come first!): */
442 { "fptr", PSEUDO_FUNC_RELOC
},
443 { "gprel", PSEUDO_FUNC_RELOC
},
444 { "ltoff", PSEUDO_FUNC_RELOC
},
445 { "pcrel", PSEUDO_FUNC_RELOC
},
446 { "pltoff", PSEUDO_FUNC_RELOC
},
447 { "secrel", PSEUDO_FUNC_RELOC
},
448 { "segrel", PSEUDO_FUNC_RELOC
},
449 { "ltv", PSEUDO_FUNC_RELOC
},
450 { 0, }, /* placeholder for FUNC_LT_FPTR_RELATIVE */
452 /* mbtype4 constants: */
453 { "alt", PSEUDO_FUNC_CONST
, { 0xa } },
454 { "brcst", PSEUDO_FUNC_CONST
, { 0x0 } },
455 { "mix", PSEUDO_FUNC_CONST
, { 0x8 } },
456 { "rev", PSEUDO_FUNC_CONST
, { 0xb } },
457 { "shuf", PSEUDO_FUNC_CONST
, { 0x9 } },
459 /* fclass constants: */
460 { "nat", PSEUDO_FUNC_CONST
, { 0x100 } },
461 { "qnan", PSEUDO_FUNC_CONST
, { 0x080 } },
462 { "snan", PSEUDO_FUNC_CONST
, { 0x040 } },
463 { "pos", PSEUDO_FUNC_CONST
, { 0x001 } },
464 { "neg", PSEUDO_FUNC_CONST
, { 0x002 } },
465 { "zero", PSEUDO_FUNC_CONST
, { 0x004 } },
466 { "unorm", PSEUDO_FUNC_CONST
, { 0x008 } },
467 { "norm", PSEUDO_FUNC_CONST
, { 0x010 } },
468 { "inf", PSEUDO_FUNC_CONST
, { 0x020 } },
470 { "natval", PSEUDO_FUNC_CONST
, { 0x100 } }, /* old usage */
472 /* unwind-related constants: */
473 { "svr4", PSEUDO_FUNC_CONST
, { 0 } },
474 { "hpux", PSEUDO_FUNC_CONST
, { 1 } },
475 { "nt", PSEUDO_FUNC_CONST
, { 2 } },
477 /* unwind-related registers: */
478 { "priunat",PSEUDO_FUNC_REG
, { REG_PRIUNAT
} }
481 /* 41-bit nop opcodes (one per unit): */
482 static const bfd_vma nop
[IA64_NUM_UNITS
] =
484 0x0000000000LL
, /* NIL => break 0 */
485 0x0008000000LL
, /* I-unit nop */
486 0x0008000000LL
, /* M-unit nop */
487 0x4000000000LL
, /* B-unit nop */
488 0x0008000000LL
, /* F-unit nop */
489 0x0008000000LL
, /* L-"unit" nop */
490 0x0008000000LL
, /* X-unit nop */
493 /* Can't be `const' as it's passed to input routines (which have the
494 habit of setting temporary sentinels. */
495 static char special_section_name
[][20] =
497 {".bss"}, {".sbss"}, {".sdata"}, {".rodata"}, {".comment"},
498 {".IA_64.unwind"}, {".IA_64.unwind_info"}
501 /* The best template for a particular sequence of up to three
503 #define N IA64_NUM_TYPES
504 static unsigned char best_template
[N
][N
][N
];
507 /* Resource dependencies currently in effect */
509 int depind
; /* dependency index */
510 const struct ia64_dependency
*dependency
; /* actual dependency */
511 unsigned specific
:1, /* is this a specific bit/regno? */
512 link_to_qp_branch
:1; /* will a branch on the same QP clear it?*/
513 int index
; /* specific regno/bit within dependency */
514 int note
; /* optional qualifying note (0 if none) */
518 int insn_srlz
; /* current insn serialization state */
519 int data_srlz
; /* current data serialization state */
520 int qp_regno
; /* qualifying predicate for this usage */
521 char *file
; /* what file marked this dependency */
522 int line
; /* what line marked this dependency */
523 struct mem_offset mem_offset
; /* optional memory offset hint */
524 int path
; /* corresponding code entry index */
526 static int regdepslen
= 0;
527 static int regdepstotlen
= 0;
528 static const char *dv_mode
[] = { "RAW", "WAW", "WAR" };
529 static const char *dv_sem
[] = { "none", "implied", "impliedf",
530 "data", "instr", "specific", "other" };
532 /* Current state of PR mutexation */
533 static struct qpmutex
{
536 } *qp_mutexes
= NULL
; /* QP mutex bitmasks */
537 static int qp_mutexeslen
= 0;
538 static int qp_mutexestotlen
= 0;
539 static valueT qp_safe_across_calls
= 0;
541 /* Current state of PR implications */
542 static struct qp_imply
{
545 unsigned p2_branched
:1;
547 } *qp_implies
= NULL
;
548 static int qp_implieslen
= 0;
549 static int qp_impliestotlen
= 0;
551 /* Keep track of static GR values so that indirect register usage can
552 sometimes be tracked. */
557 } gr_values
[128] = {{ 1, 0 }};
559 /* These are the routines required to output the various types of
562 typedef struct unw_rec_list
{
564 unsigned long slot_number
;
565 struct unw_rec_list
*next
;
568 #define SLOT_NUM_NOT_SET -1
572 unsigned long next_slot_number
;
574 /* Maintain a list of unwind entries for the current function. */
578 /* Any unwind entires that should be attached to the current slot
579 that an insn is being constructed for. */
580 unw_rec_list
*current_entry
;
582 /* These are used to create the unwind table entry for this function. */
585 symbolS
*info
; /* pointer to unwind info */
586 symbolS
*personality_routine
;
588 /* TRUE if processing unwind directives in a prologue region. */
593 typedef void (*vbyte_func
) PARAMS ((int, char *, char *));
595 /* Forward delarations: */
596 static int ar_is_in_integer_unit
PARAMS ((int regnum
));
597 static void set_section
PARAMS ((char *name
));
598 static unsigned int set_regstack
PARAMS ((unsigned int, unsigned int,
599 unsigned int, unsigned int));
600 static void dot_radix
PARAMS ((int));
601 static void dot_special_section
PARAMS ((int));
602 static void dot_proc
PARAMS ((int));
603 static void dot_fframe
PARAMS ((int));
604 static void dot_vframe
PARAMS ((int));
605 static void dot_vframesp
PARAMS ((int));
606 static void dot_vframepsp
PARAMS ((int));
607 static void dot_save
PARAMS ((int));
608 static void dot_restore
PARAMS ((int));
609 static void dot_restorereg
PARAMS ((int));
610 static void dot_restorereg_p
PARAMS ((int));
611 static void dot_handlerdata
PARAMS ((int));
612 static void dot_unwentry
PARAMS ((int));
613 static void dot_altrp
PARAMS ((int));
614 static void dot_savemem
PARAMS ((int));
615 static void dot_saveg
PARAMS ((int));
616 static void dot_savef
PARAMS ((int));
617 static void dot_saveb
PARAMS ((int));
618 static void dot_savegf
PARAMS ((int));
619 static void dot_spill
PARAMS ((int));
620 static void dot_spillreg
PARAMS ((int));
621 static void dot_spillmem
PARAMS ((int));
622 static void dot_spillreg_p
PARAMS ((int));
623 static void dot_spillmem_p
PARAMS ((int));
624 static void dot_label_state
PARAMS ((int));
625 static void dot_copy_state
PARAMS ((int));
626 static void dot_unwabi
PARAMS ((int));
627 static void dot_personality
PARAMS ((int));
628 static void dot_body
PARAMS ((int));
629 static void dot_prologue
PARAMS ((int));
630 static void dot_endp
PARAMS ((int));
631 static void dot_template
PARAMS ((int));
632 static void dot_regstk
PARAMS ((int));
633 static void dot_rot
PARAMS ((int));
634 static void dot_byteorder
PARAMS ((int));
635 static void dot_psr
PARAMS ((int));
636 static void dot_alias
PARAMS ((int));
637 static void dot_ln
PARAMS ((int));
638 static char *parse_section_name
PARAMS ((void));
639 static void dot_xdata
PARAMS ((int));
640 static void stmt_float_cons
PARAMS ((int));
641 static void stmt_cons_ua
PARAMS ((int));
642 static void dot_xfloat_cons
PARAMS ((int));
643 static void dot_xstringer
PARAMS ((int));
644 static void dot_xdata_ua
PARAMS ((int));
645 static void dot_xfloat_cons_ua
PARAMS ((int));
646 static void print_prmask
PARAMS ((valueT mask
));
647 static void dot_pred_rel
PARAMS ((int));
648 static void dot_reg_val
PARAMS ((int));
649 static void dot_dv_mode
PARAMS ((int));
650 static void dot_entry
PARAMS ((int));
651 static void dot_mem_offset
PARAMS ((int));
652 static void add_unwind_entry
PARAMS((unw_rec_list
*ptr
));
653 static symbolS
* declare_register
PARAMS ((const char *name
, int regnum
));
654 static void declare_register_set
PARAMS ((const char *, int, int));
655 static unsigned int operand_width
PARAMS ((enum ia64_opnd
));
656 static int operand_match
PARAMS ((const struct ia64_opcode
*idesc
,
657 int index
, expressionS
*e
));
658 static int parse_operand
PARAMS ((expressionS
*e
));
659 static struct ia64_opcode
* parse_operands
PARAMS ((struct ia64_opcode
*));
660 static void build_insn
PARAMS ((struct slot
*, bfd_vma
*));
661 static void emit_one_bundle
PARAMS ((void));
662 static void fix_insn
PARAMS ((fixS
*, const struct ia64_operand
*, valueT
));
663 static bfd_reloc_code_real_type ia64_gen_real_reloc_type
PARAMS ((struct symbol
*sym
,
664 bfd_reloc_code_real_type r_type
));
665 static void insn_group_break
PARAMS ((int, int, int));
666 static void mark_resource
PARAMS ((struct ia64_opcode
*, const struct ia64_dependency
*,
667 struct rsrc
*, int depind
, int path
));
668 static void add_qp_mutex
PARAMS((valueT mask
));
669 static void add_qp_imply
PARAMS((int p1
, int p2
));
670 static void clear_qp_branch_flag
PARAMS((valueT mask
));
671 static void clear_qp_mutex
PARAMS((valueT mask
));
672 static void clear_qp_implies
PARAMS((valueT p1_mask
, valueT p2_mask
));
673 static void clear_register_values
PARAMS ((void));
674 static void print_dependency
PARAMS ((const char *action
, int depind
));
675 static void instruction_serialization
PARAMS ((void));
676 static void data_serialization
PARAMS ((void));
677 static void remove_marked_resource
PARAMS ((struct rsrc
*));
678 static int is_conditional_branch
PARAMS ((struct ia64_opcode
*));
679 static int is_taken_branch
PARAMS ((struct ia64_opcode
*));
680 static int is_interruption_or_rfi
PARAMS ((struct ia64_opcode
*));
681 static int depends_on
PARAMS ((int, struct ia64_opcode
*));
682 static int specify_resource
PARAMS ((const struct ia64_dependency
*,
683 struct ia64_opcode
*, int, struct rsrc
[], int, int));
684 static int check_dv
PARAMS((struct ia64_opcode
*idesc
));
685 static void check_dependencies
PARAMS((struct ia64_opcode
*));
686 static void mark_resources
PARAMS((struct ia64_opcode
*));
687 static void update_dependencies
PARAMS((struct ia64_opcode
*));
688 static void note_register_values
PARAMS((struct ia64_opcode
*));
689 static int qp_mutex
PARAMS ((int, int, int));
690 static int resources_match
PARAMS ((struct rsrc
*, struct ia64_opcode
*, int, int, int));
691 static void output_vbyte_mem
PARAMS ((int, char *, char *));
692 static void count_output
PARAMS ((int, char *, char *));
693 static void output_R1_format
PARAMS ((vbyte_func
, unw_record_type
, int));
694 static void output_R2_format
PARAMS ((vbyte_func
, int, int, unsigned long));
695 static void output_R3_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
696 static void output_P1_format
PARAMS ((vbyte_func
, int));
697 static void output_P2_format
PARAMS ((vbyte_func
, int, int));
698 static void output_P3_format
PARAMS ((vbyte_func
, unw_record_type
, int));
699 static void output_P4_format
PARAMS ((vbyte_func
, unsigned char *, unsigned long));
700 static void output_P5_format
PARAMS ((vbyte_func
, int, unsigned long));
701 static void output_P6_format
PARAMS ((vbyte_func
, unw_record_type
, int));
702 static void output_P7_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long, unsigned long));
703 static void output_P8_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
704 static void output_P9_format
PARAMS ((vbyte_func
, int, int));
705 static void output_P10_format
PARAMS ((vbyte_func
, int, int));
706 static void output_B1_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
707 static void output_B2_format
PARAMS ((vbyte_func
, unsigned long, unsigned long));
708 static void output_B3_format
PARAMS ((vbyte_func
, unsigned long, unsigned long));
709 static void output_B4_format
PARAMS ((vbyte_func
, unw_record_type
, unsigned long));
710 static char format_ab_reg
PARAMS ((int, int));
711 static void output_X1_format
PARAMS ((vbyte_func
, unw_record_type
, int, int, unsigned long,
713 static void output_X2_format
PARAMS ((vbyte_func
, int, int, int, int, int, unsigned long));
714 static void output_X3_format
PARAMS ((vbyte_func
, unw_record_type
, int, int, int, unsigned long,
716 static void output_X4_format
PARAMS ((vbyte_func
, int, int, int, int, int, int, unsigned long));
717 static void free_list_records
PARAMS ((unw_rec_list
*));
718 static unw_rec_list
*output_prologue
PARAMS ((void));
719 static unw_rec_list
*output_prologue_gr
PARAMS ((unsigned int, unsigned int));
720 static unw_rec_list
*output_body
PARAMS ((void));
721 static unw_rec_list
*output_mem_stack_f
PARAMS ((unsigned int));
722 static unw_rec_list
*output_mem_stack_v
PARAMS ((void));
723 static unw_rec_list
*output_psp_gr
PARAMS ((unsigned int));
724 static unw_rec_list
*output_psp_sprel
PARAMS ((unsigned int));
725 static unw_rec_list
*output_rp_when
PARAMS ((void));
726 static unw_rec_list
*output_rp_gr
PARAMS ((unsigned int));
727 static unw_rec_list
*output_rp_br
PARAMS ((unsigned int));
728 static unw_rec_list
*output_rp_psprel
PARAMS ((unsigned int));
729 static unw_rec_list
*output_rp_sprel
PARAMS ((unsigned int));
730 static unw_rec_list
*output_pfs_when
PARAMS ((void));
731 static unw_rec_list
*output_pfs_gr
PARAMS ((unsigned int));
732 static unw_rec_list
*output_pfs_psprel
PARAMS ((unsigned int));
733 static unw_rec_list
*output_pfs_sprel
PARAMS ((unsigned int));
734 static unw_rec_list
*output_preds_when
PARAMS ((void));
735 static unw_rec_list
*output_preds_gr
PARAMS ((unsigned int));
736 static unw_rec_list
*output_preds_psprel
PARAMS ((unsigned int));
737 static unw_rec_list
*output_preds_sprel
PARAMS ((unsigned int));
738 static unw_rec_list
*output_fr_mem
PARAMS ((unsigned int));
739 static unw_rec_list
*output_frgr_mem
PARAMS ((unsigned int, unsigned int));
740 static unw_rec_list
*output_gr_gr
PARAMS ((unsigned int, unsigned int));
741 static unw_rec_list
*output_gr_mem
PARAMS ((unsigned int));
742 static unw_rec_list
*output_br_mem
PARAMS ((unsigned int));
743 static unw_rec_list
*output_br_gr
PARAMS ((unsigned int, unsigned int));
744 static unw_rec_list
*output_spill_base
PARAMS ((unsigned int));
745 static unw_rec_list
*output_unat_when
PARAMS ((void));
746 static unw_rec_list
*output_unat_gr
PARAMS ((unsigned int));
747 static unw_rec_list
*output_unat_psprel
PARAMS ((unsigned int));
748 static unw_rec_list
*output_unat_sprel
PARAMS ((unsigned int));
749 static unw_rec_list
*output_lc_when
PARAMS ((void));
750 static unw_rec_list
*output_lc_gr
PARAMS ((unsigned int));
751 static unw_rec_list
*output_lc_psprel
PARAMS ((unsigned int));
752 static unw_rec_list
*output_lc_sprel
PARAMS ((unsigned int));
753 static unw_rec_list
*output_fpsr_when
PARAMS ((void));
754 static unw_rec_list
*output_fpsr_gr
PARAMS ((unsigned int));
755 static unw_rec_list
*output_fpsr_psprel
PARAMS ((unsigned int));
756 static unw_rec_list
*output_fpsr_sprel
PARAMS ((unsigned int));
757 static unw_rec_list
*output_priunat_when_gr
PARAMS ((void));
758 static unw_rec_list
*output_priunat_when_mem
PARAMS ((void));
759 static unw_rec_list
*output_priunat_gr
PARAMS ((unsigned int));
760 static unw_rec_list
*output_priunat_psprel
PARAMS ((unsigned int));
761 static unw_rec_list
*output_priunat_sprel
PARAMS ((unsigned int));
762 static unw_rec_list
*output_bsp_when
PARAMS ((void));
763 static unw_rec_list
*output_bsp_gr
PARAMS ((unsigned int));
764 static unw_rec_list
*output_bsp_psprel
PARAMS ((unsigned int));
765 static unw_rec_list
*output_bsp_sprel
PARAMS ((unsigned int));
766 static unw_rec_list
*output_bspstore_when
PARAMS ((void));
767 static unw_rec_list
*output_bspstore_gr
PARAMS ((unsigned int));
768 static unw_rec_list
*output_bspstore_psprel
PARAMS ((unsigned int));
769 static unw_rec_list
*output_bspstore_sprel
PARAMS ((unsigned int));
770 static unw_rec_list
*output_rnat_when
PARAMS ((void));
771 static unw_rec_list
*output_rnat_gr
PARAMS ((unsigned int));
772 static unw_rec_list
*output_rnat_psprel
PARAMS ((unsigned int));
773 static unw_rec_list
*output_rnat_sprel
PARAMS ((unsigned int));
774 static unw_rec_list
*output_unwabi
PARAMS ((unsigned long, unsigned long));
775 static unw_rec_list
*output_epilogue
PARAMS ((unsigned long));
776 static unw_rec_list
*output_label_state
PARAMS ((unsigned long));
777 static unw_rec_list
*output_copy_state
PARAMS ((unsigned long));
778 static unw_rec_list
*output_spill_psprel
PARAMS ((unsigned int, unsigned int, unsigned int));
779 static unw_rec_list
*output_spill_sprel
PARAMS ((unsigned int, unsigned int, unsigned int));
780 static unw_rec_list
*output_spill_psprel_p
PARAMS ((unsigned int, unsigned int, unsigned int,
782 static unw_rec_list
*output_spill_sprel_p
PARAMS ((unsigned int, unsigned int, unsigned int,
784 static unw_rec_list
*output_spill_reg
PARAMS ((unsigned int, unsigned int, unsigned int,
786 static unw_rec_list
*output_spill_reg_p
PARAMS ((unsigned int, unsigned int, unsigned int,
787 unsigned int, unsigned int));
788 static void process_one_record
PARAMS ((unw_rec_list
*, vbyte_func
));
789 static void process_unw_records
PARAMS ((unw_rec_list
*, vbyte_func
));
790 static int calc_record_size
PARAMS ((unw_rec_list
*));
791 static void set_imask
PARAMS ((unw_rec_list
*, unsigned long, unsigned long, unsigned int));
792 static int count_bits
PARAMS ((unsigned long));
793 static unsigned long slot_index
PARAMS ((unsigned long, unsigned long));
794 static void fixup_unw_records
PARAMS ((unw_rec_list
*));
795 static int output_unw_records
PARAMS ((unw_rec_list
*, void **));
796 static int convert_expr_to_ab_reg
PARAMS ((expressionS
*, unsigned int *, unsigned int *));
797 static int convert_expr_to_xy_reg
PARAMS ((expressionS
*, unsigned int *, unsigned int *));
798 static int generate_unwind_image
PARAMS ((void));
800 /* Determine if application register REGNUM resides in the integer
801 unit (as opposed to the memory unit). */
803 ar_is_in_integer_unit (reg
)
808 return (reg
== 64 /* pfs */
809 || reg
== 65 /* lc */
810 || reg
== 66 /* ec */
811 /* ??? ias accepts and puts these in the integer unit. */
812 || (reg
>= 112 && reg
<= 127));
815 /* Switch to section NAME and create section if necessary. It's
816 rather ugly that we have to manipulate input_line_pointer but I
817 don't see any other way to accomplish the same thing without
818 changing obj-elf.c (which may be the Right Thing, in the end). */
823 char *saved_input_line_pointer
;
825 saved_input_line_pointer
= input_line_pointer
;
826 input_line_pointer
= name
;
828 input_line_pointer
= saved_input_line_pointer
;
831 /* Map SHF_IA_64_SHORT to SEC_SMALL_DATA. */
834 ia64_elf_section_flags (flags
, attr
, type
)
838 if (attr
& SHF_IA_64_SHORT
)
839 flags
|= SEC_SMALL_DATA
;
844 set_regstack (ins
, locs
, outs
, rots
)
845 unsigned int ins
, locs
, outs
, rots
;
847 unsigned int sof
; /* size of frame */
849 sof
= ins
+ locs
+ outs
;
852 as_bad ("Size of frame exceeds maximum of 96 registers");
857 as_warn ("Size of rotating registers exceeds frame size");
860 md
.in
.base
= REG_GR
+ 32;
861 md
.loc
.base
= md
.in
.base
+ ins
;
862 md
.out
.base
= md
.loc
.base
+ locs
;
864 md
.in
.num_regs
= ins
;
865 md
.loc
.num_regs
= locs
;
866 md
.out
.num_regs
= outs
;
867 md
.rot
.num_regs
= rots
;
874 struct label_fix
*lfix
;
876 subsegT saved_subseg
;
878 if (!md
.last_text_seg
)
882 saved_subseg
= now_subseg
;
884 subseg_set (md
.last_text_seg
, 0);
886 while (md
.num_slots_in_use
> 0)
887 emit_one_bundle (); /* force out queued instructions */
889 /* In case there are labels following the last instruction, resolve
891 for (lfix
= CURR_SLOT
.label_fixups
; lfix
; lfix
= lfix
->next
)
893 S_SET_VALUE (lfix
->sym
, frag_now_fix ());
894 symbol_set_frag (lfix
->sym
, frag_now
);
896 CURR_SLOT
.label_fixups
= 0;
898 subseg_set (saved_seg
, saved_subseg
);
902 ia64_do_align (nbytes
)
905 char *saved_input_line_pointer
= input_line_pointer
;
907 input_line_pointer
= "";
908 s_align_bytes (nbytes
);
909 input_line_pointer
= saved_input_line_pointer
;
913 ia64_cons_align (nbytes
)
918 char *saved_input_line_pointer
= input_line_pointer
;
919 input_line_pointer
= "";
920 s_align_bytes (nbytes
);
921 input_line_pointer
= saved_input_line_pointer
;
925 /* Output COUNT bytes to a memory location. */
926 static unsigned char *vbyte_mem_ptr
= NULL
;
929 output_vbyte_mem (count
, ptr
, comment
)
935 if (vbyte_mem_ptr
== NULL
)
940 for (x
= 0; x
< count
; x
++)
941 *(vbyte_mem_ptr
++) = ptr
[x
];
944 /* Count the number of bytes required for records. */
945 static int vbyte_count
= 0;
947 count_output (count
, ptr
, comment
)
952 vbyte_count
+= count
;
956 output_R1_format (f
, rtype
, rlen
)
958 unw_record_type rtype
;
965 output_R3_format (f
, rtype
, rlen
);
971 else if (rtype
!= prologue
)
972 as_bad ("record type is not valid");
974 byte
= UNW_R1
| (r
<< 5) | (rlen
& 0x1f);
975 (*f
) (1, &byte
, NULL
);
979 output_R2_format (f
, mask
, grsave
, rlen
)
986 mask
= (mask
& 0x0f);
987 grsave
= (grsave
& 0x7f);
989 bytes
[0] = (UNW_R2
| (mask
>> 1));
990 bytes
[1] = (((mask
& 0x01) << 7) | grsave
);
991 count
+= output_leb128 (bytes
+ 2, rlen
, 0);
992 (*f
) (count
, bytes
, NULL
);
996 output_R3_format (f
, rtype
, rlen
)
998 unw_record_type rtype
;
1005 output_R1_format (f
, rtype
, rlen
);
1011 else if (rtype
!= prologue
)
1012 as_bad ("record type is not valid");
1013 bytes
[0] = (UNW_R3
| r
);
1014 count
= output_leb128 (bytes
+ 1, rlen
, 0);
1015 (*f
) (count
+ 1, bytes
, NULL
);
1019 output_P1_format (f
, brmask
)
1024 byte
= UNW_P1
| (brmask
& 0x1f);
1025 (*f
) (1, &byte
, NULL
);
1029 output_P2_format (f
, brmask
, gr
)
1035 brmask
= (brmask
& 0x1f);
1036 bytes
[0] = UNW_P2
| (brmask
>> 1);
1037 bytes
[1] = (((brmask
& 1) << 7) | gr
);
1038 (*f
) (2, bytes
, NULL
);
1042 output_P3_format (f
, rtype
, reg
)
1044 unw_record_type rtype
;
1089 as_bad ("Invalid record type for P3 format.");
1091 bytes
[0] = (UNW_P3
| (r
>> 1));
1092 bytes
[1] = (((r
& 1) << 7) | reg
);
1093 (*f
) (2, bytes
, NULL
);
1098 output_P4_format (f
, imask
, imask_size
)
1100 unsigned char *imask
;
1101 unsigned long imask_size
;
1104 (*f
) (imask_size
, imask
, NULL
);
1108 output_P5_format (f
, grmask
, frmask
)
1111 unsigned long frmask
;
1114 grmask
= (grmask
& 0x0f);
1117 bytes
[1] = ((grmask
<< 4) | ((frmask
& 0x000f0000) >> 16));
1118 bytes
[2] = ((frmask
& 0x0000ff00) >> 8);
1119 bytes
[3] = (frmask
& 0x000000ff);
1120 (*f
) (4, bytes
, NULL
);
1124 output_P6_format (f
, rtype
, rmask
)
1126 unw_record_type rtype
;
1132 if (rtype
== gr_mem
)
1134 else if (rtype
!= fr_mem
)
1135 as_bad ("Invalid record type for format P6");
1136 byte
= (UNW_P6
| (r
<< 4) | (rmask
& 0x0f));
1137 (*f
) (1, &byte
, NULL
);
1141 output_P7_format (f
, rtype
, w1
, w2
)
1143 unw_record_type rtype
;
1150 count
+= output_leb128 (bytes
+ 1, w1
, 0);
1155 count
+= output_leb128 (bytes
+ count
, w2
>> 4, 0);
1205 bytes
[0] = (UNW_P7
| r
);
1206 (*f
) (count
, bytes
, NULL
);
1210 output_P8_format (f
, rtype
, t
)
1212 unw_record_type rtype
;
1251 case bspstore_psprel
:
1254 case bspstore_sprel
:
1266 case priunat_when_gr
:
1269 case priunat_psprel
:
1275 case priunat_when_mem
:
1282 count
+= output_leb128 (bytes
+ 2, t
, 0);
1283 (*f
) (count
, bytes
, NULL
);
1287 output_P9_format (f
, grmask
, gr
)
1294 bytes
[1] = (grmask
& 0x0f);
1295 bytes
[2] = (gr
& 0x7f);
1296 (*f
) (3, bytes
, NULL
);
1300 output_P10_format (f
, abi
, context
)
1307 bytes
[1] = (abi
& 0xff);
1308 bytes
[2] = (context
& 0xff);
1309 (*f
) (3, bytes
, NULL
);
1313 output_B1_format (f
, rtype
, label
)
1315 unw_record_type rtype
;
1316 unsigned long label
;
1322 output_B4_format (f
, rtype
, label
);
1325 if (rtype
== copy_state
)
1327 else if (rtype
!= label_state
)
1328 as_bad ("Invalid record type for format B1");
1330 byte
= (UNW_B1
| (r
<< 5) | (label
& 0x1f));
1331 (*f
) (1, &byte
, NULL
);
1335 output_B2_format (f
, ecount
, t
)
1337 unsigned long ecount
;
1344 output_B3_format (f
, ecount
, t
);
1347 bytes
[0] = (UNW_B2
| (ecount
& 0x1f));
1348 count
+= output_leb128 (bytes
+ 1, t
, 0);
1349 (*f
) (count
, bytes
, NULL
);
1353 output_B3_format (f
, ecount
, t
)
1355 unsigned long ecount
;
1362 output_B2_format (f
, ecount
, t
);
1366 count
+= output_leb128 (bytes
+ 1, t
, 0);
1367 count
+= output_leb128 (bytes
+ count
, ecount
, 0);
1368 (*f
) (count
, bytes
, NULL
);
1372 output_B4_format (f
, rtype
, label
)
1374 unw_record_type rtype
;
1375 unsigned long label
;
1382 output_B1_format (f
, rtype
, label
);
1386 if (rtype
== copy_state
)
1388 else if (rtype
!= label_state
)
1389 as_bad ("Invalid record type for format B1");
1391 bytes
[0] = (UNW_B4
| (r
<< 3));
1392 count
+= output_leb128 (bytes
+ 1, label
, 0);
1393 (*f
) (count
, bytes
, NULL
);
1397 format_ab_reg (ab
, reg
)
1404 ret
= (ab
<< 5) | reg
;
1409 output_X1_format (f
, rtype
, ab
, reg
, t
, w1
)
1411 unw_record_type rtype
;
1421 if (rtype
== spill_sprel
)
1423 else if (rtype
!= spill_psprel
)
1424 as_bad ("Invalid record type for format X1");
1425 bytes
[1] = ((r
<< 7) | format_ab_reg (ab
, reg
));
1426 count
+= output_leb128 (bytes
+ 2, t
, 0);
1427 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1428 (*f
) (count
, bytes
, NULL
);
1432 output_X2_format (f
, ab
, reg
, x
, y
, treg
, t
)
1441 bytes
[1] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1442 bytes
[2] = (((y
& 1) << 7) | (treg
& 0x7f));
1443 count
+= output_leb128 (bytes
+ 3, t
, 0);
1444 (*f
) (count
, bytes
, NULL
);
1448 output_X3_format (f
, rtype
, qp
, ab
, reg
, t
, w1
)
1450 unw_record_type rtype
;
1461 if (rtype
== spill_sprel_p
)
1463 else if (rtype
!= spill_psprel_p
)
1464 as_bad ("Invalid record type for format X3");
1465 bytes
[1] = ((r
<< 7) | (qp
& 0x3f));
1466 bytes
[2] = format_ab_reg (ab
, reg
);
1467 count
+= output_leb128 (bytes
+ 3, t
, 0);
1468 count
+= output_leb128 (bytes
+ count
, w1
, 0);
1469 (*f
) (count
, bytes
, NULL
);
1473 output_X4_format (f
, qp
, ab
, reg
, x
, y
, treg
, t
)
1483 bytes
[1] = (qp
& 0x3f);
1484 bytes
[2] = (((x
& 1) << 7) | format_ab_reg (ab
, reg
));
1485 bytes
[3] = (((y
& 1) << 7) | (treg
& 0x7f));
1486 count
+= output_leb128 (bytes
+ 4, t
, 0);
1487 (*f
) (count
, bytes
, NULL
);
1490 /* This function allocates a record list structure, and initializes fields. */
1491 static unw_rec_list
*
1492 alloc_record (unw_record_type t
)
1495 ptr
= xmalloc (sizeof (*ptr
));
1497 ptr
->slot_number
= SLOT_NUM_NOT_SET
;
1502 /* This function frees an entire list of record structures. */
1504 free_list_records (unw_rec_list
*first
)
1507 for (ptr
= first
; ptr
!= NULL
; )
1509 unw_rec_list
*tmp
= ptr
;
1511 if ((tmp
->r
.type
== prologue
|| tmp
->r
.type
== prologue_gr
)
1512 && tmp
->r
.record
.r
.mask
.i
)
1513 free (tmp
->r
.record
.r
.mask
.i
);
1520 static unw_rec_list
*
1523 unw_rec_list
*ptr
= alloc_record (prologue
);
1524 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1528 static unw_rec_list
*
1529 output_prologue_gr (saved_mask
, reg
)
1530 unsigned int saved_mask
;
1533 unw_rec_list
*ptr
= alloc_record (prologue_gr
);
1534 memset (&ptr
->r
.record
.r
.mask
, 0, sizeof (ptr
->r
.record
.r
.mask
));
1535 ptr
->r
.record
.r
.grmask
= saved_mask
;
1536 ptr
->r
.record
.r
.grsave
= reg
;
1540 static unw_rec_list
*
1543 unw_rec_list
*ptr
= alloc_record (body
);
1547 static unw_rec_list
*
1548 output_mem_stack_f (size
)
1551 unw_rec_list
*ptr
= alloc_record (mem_stack_f
);
1552 ptr
->r
.record
.p
.size
= size
;
1556 static unw_rec_list
*
1557 output_mem_stack_v ()
1559 unw_rec_list
*ptr
= alloc_record (mem_stack_v
);
1563 static unw_rec_list
*
1567 unw_rec_list
*ptr
= alloc_record (psp_gr
);
1568 ptr
->r
.record
.p
.gr
= gr
;
1572 static unw_rec_list
*
1573 output_psp_sprel (offset
)
1574 unsigned int offset
;
1576 unw_rec_list
*ptr
= alloc_record (psp_sprel
);
1577 ptr
->r
.record
.p
.spoff
= offset
/4;
1581 static unw_rec_list
*
1584 unw_rec_list
*ptr
= alloc_record (rp_when
);
1588 static unw_rec_list
*
1592 unw_rec_list
*ptr
= alloc_record (rp_gr
);
1593 ptr
->r
.record
.p
.gr
= gr
;
1597 static unw_rec_list
*
1601 unw_rec_list
*ptr
= alloc_record (rp_br
);
1602 ptr
->r
.record
.p
.br
= br
;
1606 static unw_rec_list
*
1607 output_rp_psprel (offset
)
1608 unsigned int offset
;
1610 unw_rec_list
*ptr
= alloc_record (rp_psprel
);
1611 ptr
->r
.record
.p
.pspoff
= offset
/4;
1615 static unw_rec_list
*
1616 output_rp_sprel (offset
)
1617 unsigned int offset
;
1619 unw_rec_list
*ptr
= alloc_record (rp_sprel
);
1620 ptr
->r
.record
.p
.spoff
= offset
/4;
1624 static unw_rec_list
*
1627 unw_rec_list
*ptr
= alloc_record (pfs_when
);
1631 static unw_rec_list
*
1635 unw_rec_list
*ptr
= alloc_record (pfs_gr
);
1636 ptr
->r
.record
.p
.gr
= gr
;
1640 static unw_rec_list
*
1641 output_pfs_psprel (offset
)
1642 unsigned int offset
;
1644 unw_rec_list
*ptr
= alloc_record (pfs_psprel
);
1645 ptr
->r
.record
.p
.pspoff
= offset
/4;
1649 static unw_rec_list
*
1650 output_pfs_sprel (offset
)
1651 unsigned int offset
;
1653 unw_rec_list
*ptr
= alloc_record (pfs_sprel
);
1654 ptr
->r
.record
.p
.spoff
= offset
/4;
1658 static unw_rec_list
*
1659 output_preds_when ()
1661 unw_rec_list
*ptr
= alloc_record (preds_when
);
1665 static unw_rec_list
*
1666 output_preds_gr (gr
)
1669 unw_rec_list
*ptr
= alloc_record (preds_gr
);
1670 ptr
->r
.record
.p
.gr
= gr
;
1674 static unw_rec_list
*
1675 output_preds_psprel (offset
)
1676 unsigned int offset
;
1678 unw_rec_list
*ptr
= alloc_record (preds_psprel
);
1679 ptr
->r
.record
.p
.pspoff
= offset
/4;
1683 static unw_rec_list
*
1684 output_preds_sprel (offset
)
1685 unsigned int offset
;
1687 unw_rec_list
*ptr
= alloc_record (preds_sprel
);
1688 ptr
->r
.record
.p
.spoff
= offset
/4;
1692 static unw_rec_list
*
1693 output_fr_mem (mask
)
1696 unw_rec_list
*ptr
= alloc_record (fr_mem
);
1697 ptr
->r
.record
.p
.rmask
= mask
;
1701 static unw_rec_list
*
1702 output_frgr_mem (gr_mask
, fr_mask
)
1703 unsigned int gr_mask
;
1704 unsigned int fr_mask
;
1706 unw_rec_list
*ptr
= alloc_record (frgr_mem
);
1707 ptr
->r
.record
.p
.grmask
= gr_mask
;
1708 ptr
->r
.record
.p
.frmask
= fr_mask
;
1712 static unw_rec_list
*
1713 output_gr_gr (mask
, reg
)
1717 unw_rec_list
*ptr
= alloc_record (gr_gr
);
1718 ptr
->r
.record
.p
.grmask
= mask
;
1719 ptr
->r
.record
.p
.gr
= reg
;
1723 static unw_rec_list
*
1724 output_gr_mem (mask
)
1727 unw_rec_list
*ptr
= alloc_record (gr_mem
);
1728 ptr
->r
.record
.p
.rmask
= mask
;
1732 static unw_rec_list
*
1733 output_br_mem (unsigned int mask
)
1735 unw_rec_list
*ptr
= alloc_record (br_mem
);
1736 ptr
->r
.record
.p
.brmask
= mask
;
1740 static unw_rec_list
*
1741 output_br_gr (save_mask
, reg
)
1742 unsigned int save_mask
;
1745 unw_rec_list
*ptr
= alloc_record (br_gr
);
1746 ptr
->r
.record
.p
.brmask
= save_mask
;
1747 ptr
->r
.record
.p
.gr
= reg
;
1751 static unw_rec_list
*
1752 output_spill_base (offset
)
1753 unsigned int offset
;
1755 unw_rec_list
*ptr
= alloc_record (spill_base
);
1756 ptr
->r
.record
.p
.pspoff
= offset
/4;
1760 static unw_rec_list
*
1763 unw_rec_list
*ptr
= alloc_record (unat_when
);
1767 static unw_rec_list
*
1771 unw_rec_list
*ptr
= alloc_record (unat_gr
);
1772 ptr
->r
.record
.p
.gr
= gr
;
1776 static unw_rec_list
*
1777 output_unat_psprel (offset
)
1778 unsigned int offset
;
1780 unw_rec_list
*ptr
= alloc_record (unat_psprel
);
1781 ptr
->r
.record
.p
.pspoff
= offset
/4;
1785 static unw_rec_list
*
1786 output_unat_sprel (offset
)
1787 unsigned int offset
;
1789 unw_rec_list
*ptr
= alloc_record (unat_sprel
);
1790 ptr
->r
.record
.p
.spoff
= offset
/4;
1794 static unw_rec_list
*
1797 unw_rec_list
*ptr
= alloc_record (lc_when
);
1801 static unw_rec_list
*
1805 unw_rec_list
*ptr
= alloc_record (lc_gr
);
1806 ptr
->r
.record
.p
.gr
= gr
;
1810 static unw_rec_list
*
1811 output_lc_psprel (offset
)
1812 unsigned int offset
;
1814 unw_rec_list
*ptr
= alloc_record (lc_psprel
);
1815 ptr
->r
.record
.p
.pspoff
= offset
/4;
1819 static unw_rec_list
*
1820 output_lc_sprel (offset
)
1821 unsigned int offset
;
1823 unw_rec_list
*ptr
= alloc_record (lc_sprel
);
1824 ptr
->r
.record
.p
.spoff
= offset
/4;
1828 static unw_rec_list
*
1831 unw_rec_list
*ptr
= alloc_record (fpsr_when
);
1835 static unw_rec_list
*
1839 unw_rec_list
*ptr
= alloc_record (fpsr_gr
);
1840 ptr
->r
.record
.p
.gr
= gr
;
1844 static unw_rec_list
*
1845 output_fpsr_psprel (offset
)
1846 unsigned int offset
;
1848 unw_rec_list
*ptr
= alloc_record (fpsr_psprel
);
1849 ptr
->r
.record
.p
.pspoff
= offset
/4;
1853 static unw_rec_list
*
1854 output_fpsr_sprel (offset
)
1855 unsigned int offset
;
1857 unw_rec_list
*ptr
= alloc_record (fpsr_sprel
);
1858 ptr
->r
.record
.p
.spoff
= offset
/4;
1862 static unw_rec_list
*
1863 output_priunat_when_gr ()
1865 unw_rec_list
*ptr
= alloc_record (priunat_when_gr
);
1869 static unw_rec_list
*
1870 output_priunat_when_mem ()
1872 unw_rec_list
*ptr
= alloc_record (priunat_when_mem
);
1876 static unw_rec_list
*
1877 output_priunat_gr (gr
)
1880 unw_rec_list
*ptr
= alloc_record (priunat_gr
);
1881 ptr
->r
.record
.p
.gr
= gr
;
1885 static unw_rec_list
*
1886 output_priunat_psprel (offset
)
1887 unsigned int offset
;
1889 unw_rec_list
*ptr
= alloc_record (priunat_psprel
);
1890 ptr
->r
.record
.p
.pspoff
= offset
/4;
1894 static unw_rec_list
*
1895 output_priunat_sprel (offset
)
1896 unsigned int offset
;
1898 unw_rec_list
*ptr
= alloc_record (priunat_sprel
);
1899 ptr
->r
.record
.p
.spoff
= offset
/4;
1903 static unw_rec_list
*
1906 unw_rec_list
*ptr
= alloc_record (bsp_when
);
1910 static unw_rec_list
*
1914 unw_rec_list
*ptr
= alloc_record (bsp_gr
);
1915 ptr
->r
.record
.p
.gr
= gr
;
1919 static unw_rec_list
*
1920 output_bsp_psprel (offset
)
1921 unsigned int offset
;
1923 unw_rec_list
*ptr
= alloc_record (bsp_psprel
);
1924 ptr
->r
.record
.p
.pspoff
= offset
/4;
1928 static unw_rec_list
*
1929 output_bsp_sprel (offset
)
1930 unsigned int offset
;
1932 unw_rec_list
*ptr
= alloc_record (bsp_sprel
);
1933 ptr
->r
.record
.p
.spoff
= offset
/4;
1937 static unw_rec_list
*
1938 output_bspstore_when ()
1940 unw_rec_list
*ptr
= alloc_record (bspstore_when
);
1944 static unw_rec_list
*
1945 output_bspstore_gr (gr
)
1948 unw_rec_list
*ptr
= alloc_record (bspstore_gr
);
1949 ptr
->r
.record
.p
.gr
= gr
;
1953 static unw_rec_list
*
1954 output_bspstore_psprel (offset
)
1955 unsigned int offset
;
1957 unw_rec_list
*ptr
= alloc_record (bspstore_psprel
);
1958 ptr
->r
.record
.p
.pspoff
= offset
/4;
1962 static unw_rec_list
*
1963 output_bspstore_sprel (offset
)
1964 unsigned int offset
;
1966 unw_rec_list
*ptr
= alloc_record (bspstore_sprel
);
1967 ptr
->r
.record
.p
.spoff
= offset
/4;
1971 static unw_rec_list
*
1974 unw_rec_list
*ptr
= alloc_record (rnat_when
);
1978 static unw_rec_list
*
1982 unw_rec_list
*ptr
= alloc_record (rnat_gr
);
1983 ptr
->r
.record
.p
.gr
= gr
;
1987 static unw_rec_list
*
1988 output_rnat_psprel (offset
)
1989 unsigned int offset
;
1991 unw_rec_list
*ptr
= alloc_record (rnat_psprel
);
1992 ptr
->r
.record
.p
.pspoff
= offset
/4;
1996 static unw_rec_list
*
1997 output_rnat_sprel (offset
)
1998 unsigned int offset
;
2000 unw_rec_list
*ptr
= alloc_record (rnat_sprel
);
2001 ptr
->r
.record
.p
.spoff
= offset
/4;
2005 static unw_rec_list
*
2006 output_unwabi (abi
, context
)
2008 unsigned long context
;
2010 unw_rec_list
*ptr
= alloc_record (unwabi
);
2011 ptr
->r
.record
.p
.abi
= abi
;
2012 ptr
->r
.record
.p
.context
= context
;
2016 static unw_rec_list
*
2017 output_epilogue (unsigned long ecount
)
2019 unw_rec_list
*ptr
= alloc_record (epilogue
);
2020 ptr
->r
.record
.b
.ecount
= ecount
;
2024 static unw_rec_list
*
2025 output_label_state (unsigned long label
)
2027 unw_rec_list
*ptr
= alloc_record (label_state
);
2028 ptr
->r
.record
.b
.label
= label
;
2032 static unw_rec_list
*
2033 output_copy_state (unsigned long label
)
2035 unw_rec_list
*ptr
= alloc_record (copy_state
);
2036 ptr
->r
.record
.b
.label
= label
;
2040 static unw_rec_list
*
2041 output_spill_psprel (ab
, reg
, offset
)
2044 unsigned int offset
;
2046 unw_rec_list
*ptr
= alloc_record (spill_psprel
);
2047 ptr
->r
.record
.x
.ab
= ab
;
2048 ptr
->r
.record
.x
.reg
= reg
;
2049 ptr
->r
.record
.x
.pspoff
= offset
/4;
2053 static unw_rec_list
*
2054 output_spill_sprel (ab
, reg
, offset
)
2057 unsigned int offset
;
2059 unw_rec_list
*ptr
= alloc_record (spill_sprel
);
2060 ptr
->r
.record
.x
.ab
= ab
;
2061 ptr
->r
.record
.x
.reg
= reg
;
2062 ptr
->r
.record
.x
.spoff
= offset
/4;
2066 static unw_rec_list
*
2067 output_spill_psprel_p (ab
, reg
, offset
, predicate
)
2070 unsigned int offset
;
2071 unsigned int predicate
;
2073 unw_rec_list
*ptr
= alloc_record (spill_psprel_p
);
2074 ptr
->r
.record
.x
.ab
= ab
;
2075 ptr
->r
.record
.x
.reg
= reg
;
2076 ptr
->r
.record
.x
.pspoff
= offset
/4;
2077 ptr
->r
.record
.x
.qp
= predicate
;
2081 static unw_rec_list
*
2082 output_spill_sprel_p (ab
, reg
, offset
, predicate
)
2085 unsigned int offset
;
2086 unsigned int predicate
;
2088 unw_rec_list
*ptr
= alloc_record (spill_sprel_p
);
2089 ptr
->r
.record
.x
.ab
= ab
;
2090 ptr
->r
.record
.x
.reg
= reg
;
2091 ptr
->r
.record
.x
.spoff
= offset
/4;
2092 ptr
->r
.record
.x
.qp
= predicate
;
2096 static unw_rec_list
*
2097 output_spill_reg (ab
, reg
, targ_reg
, xy
)
2100 unsigned int targ_reg
;
2103 unw_rec_list
*ptr
= alloc_record (spill_reg
);
2104 ptr
->r
.record
.x
.ab
= ab
;
2105 ptr
->r
.record
.x
.reg
= reg
;
2106 ptr
->r
.record
.x
.treg
= targ_reg
;
2107 ptr
->r
.record
.x
.xy
= xy
;
2111 static unw_rec_list
*
2112 output_spill_reg_p (ab
, reg
, targ_reg
, xy
, predicate
)
2115 unsigned int targ_reg
;
2117 unsigned int predicate
;
2119 unw_rec_list
*ptr
= alloc_record (spill_reg_p
);
2120 ptr
->r
.record
.x
.ab
= ab
;
2121 ptr
->r
.record
.x
.reg
= reg
;
2122 ptr
->r
.record
.x
.treg
= targ_reg
;
2123 ptr
->r
.record
.x
.xy
= xy
;
2124 ptr
->r
.record
.x
.qp
= predicate
;
2128 /* Given a unw_rec_list process the correct format with the
2129 specified function. */
2131 process_one_record (ptr
, f
)
2135 unsigned long fr_mask
, gr_mask
;
2137 switch (ptr
->r
.type
)
2143 /* these are taken care of by prologue/prologue_gr */
2148 if (ptr
->r
.type
== prologue_gr
)
2149 output_R2_format (f
, ptr
->r
.record
.r
.grmask
,
2150 ptr
->r
.record
.r
.grsave
, ptr
->r
.record
.r
.rlen
);
2152 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2154 /* output descriptor(s) for union of register spills (if any): */
2155 gr_mask
= ptr
->r
.record
.r
.mask
.gr_mem
;
2156 fr_mask
= ptr
->r
.record
.r
.mask
.fr_mem
;
2159 if ((fr_mask
& ~0xfUL
) == 0)
2160 output_P6_format (f
, fr_mem
, fr_mask
);
2163 output_P5_format (f
, gr_mask
, fr_mask
);
2168 output_P6_format (f
, gr_mem
, gr_mask
);
2169 if (ptr
->r
.record
.r
.mask
.br_mem
)
2170 output_P1_format (f
, ptr
->r
.record
.r
.mask
.br_mem
);
2172 /* output imask descriptor if necessary: */
2173 if (ptr
->r
.record
.r
.mask
.i
)
2174 output_P4_format (f
, ptr
->r
.record
.r
.mask
.i
,
2175 ptr
->r
.record
.r
.imask_size
);
2179 output_R1_format (f
, ptr
->r
.type
, ptr
->r
.record
.r
.rlen
);
2183 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
,
2184 ptr
->r
.record
.p
.size
);
2197 output_P3_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.gr
);
2200 output_P3_format (f
, rp_br
, ptr
->r
.record
.p
.br
);
2203 output_P7_format (f
, psp_sprel
, ptr
->r
.record
.p
.spoff
, 0);
2211 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
, 0);
2220 output_P7_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.pspoff
, 0);
2230 case bspstore_sprel
:
2232 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.spoff
);
2235 output_P9_format (f
, ptr
->r
.record
.p
.grmask
, ptr
->r
.record
.p
.gr
);
2238 output_P2_format (f
, ptr
->r
.record
.p
.brmask
, ptr
->r
.record
.p
.gr
);
2241 as_bad ("spill_mask record unimplemented.");
2243 case priunat_when_gr
:
2244 case priunat_when_mem
:
2248 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.t
);
2250 case priunat_psprel
:
2252 case bspstore_psprel
:
2254 output_P8_format (f
, ptr
->r
.type
, ptr
->r
.record
.p
.pspoff
);
2257 output_P10_format (f
, ptr
->r
.record
.p
.abi
, ptr
->r
.record
.p
.context
);
2260 output_B3_format (f
, ptr
->r
.record
.b
.ecount
, ptr
->r
.record
.b
.t
);
2264 output_B4_format (f
, ptr
->r
.type
, ptr
->r
.record
.b
.label
);
2267 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2268 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2269 ptr
->r
.record
.x
.pspoff
);
2272 output_X1_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.ab
,
2273 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.t
,
2274 ptr
->r
.record
.x
.spoff
);
2277 output_X2_format (f
, ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2278 ptr
->r
.record
.x
.xy
>> 1, ptr
->r
.record
.x
.xy
,
2279 ptr
->r
.record
.x
.treg
, ptr
->r
.record
.x
.t
);
2281 case spill_psprel_p
:
2282 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2283 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2284 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.pspoff
);
2287 output_X3_format (f
, ptr
->r
.type
, ptr
->r
.record
.x
.qp
,
2288 ptr
->r
.record
.x
.ab
, ptr
->r
.record
.x
.reg
,
2289 ptr
->r
.record
.x
.t
, ptr
->r
.record
.x
.spoff
);
2292 output_X4_format (f
, ptr
->r
.record
.x
.qp
, ptr
->r
.record
.x
.ab
,
2293 ptr
->r
.record
.x
.reg
, ptr
->r
.record
.x
.xy
>> 1,
2294 ptr
->r
.record
.x
.xy
, ptr
->r
.record
.x
.treg
,
2298 as_bad ("record_type_not_valid");
2303 /* Given a unw_rec_list list, process all the records with
2304 the specified function. */
2306 process_unw_records (list
, f
)
2311 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2312 process_one_record (ptr
, f
);
2315 /* Determine the size of a record list in bytes. */
2317 calc_record_size (list
)
2321 process_unw_records (list
, count_output
);
2325 /* Update IMASK bitmask to reflect the fact that one or more registers
2326 of type TYPE are saved starting at instruction with index T. If N
2327 bits are set in REGMASK, it is assumed that instructions T through
2328 T+N-1 save these registers.
2332 1: instruction saves next fp reg
2333 2: instruction saves next general reg
2334 3: instruction saves next branch reg */
2336 set_imask (region
, regmask
, t
, type
)
2337 unw_rec_list
*region
;
2338 unsigned long regmask
;
2342 unsigned char *imask
;
2343 unsigned long imask_size
;
2347 imask
= region
->r
.record
.r
.mask
.i
;
2348 imask_size
= region
->r
.record
.r
.imask_size
;
2351 imask_size
= (region
->r
.record
.r
.rlen
*2 + 7)/8 + 1;
2352 imask
= xmalloc (imask_size
);
2353 memset (imask
, 0, imask_size
);
2355 region
->r
.record
.r
.imask_size
= imask_size
;
2356 region
->r
.record
.r
.mask
.i
= imask
;
2363 if (i
>= imask_size
)
2365 as_bad ("Ignoring attempt to spill beyond end of region");
2369 imask
[i
] |= (type
& 0x3) << pos
;
2371 regmask
&= (regmask
- 1);
2382 count_bits (unsigned long mask
)
2395 slot_index (unsigned long slot_addr
, unsigned long first_addr
)
2397 return (3*((slot_addr
>> 4) - (first_addr
>> 4))
2398 + ((slot_addr
& 0x3) - (first_addr
& 0x3)));
2401 /* Given a complete record list, process any records which have
2402 unresolved fields, (ie length counts for a prologue). After
2403 this has been run, all neccessary information should be available
2404 within each record to generate an image. */
2406 fixup_unw_records (list
)
2409 unw_rec_list
*ptr
, *region
= 0;
2410 unsigned long first_addr
= 0, rlen
= 0, t
;
2412 for (ptr
= list
; ptr
; ptr
= ptr
->next
)
2414 if (ptr
->slot_number
== SLOT_NUM_NOT_SET
)
2415 as_bad (" Insn slot not set in unwind record.");
2416 t
= slot_index (ptr
->slot_number
, first_addr
);
2417 switch (ptr
->r
.type
)
2424 int size
, dir_len
= 0;
2425 unsigned long last_addr
;
2427 first_addr
= ptr
->slot_number
;
2428 ptr
->slot_number
= 0;
2429 /* Find either the next body/prologue start, or the end of
2430 the list, and determine the size of the region. */
2431 last_addr
= unwind
.next_slot_number
;
2432 for (last
= ptr
->next
; last
!= NULL
; last
= last
->next
)
2433 if (last
->r
.type
== prologue
|| last
->r
.type
== prologue_gr
2434 || last
->r
.type
== body
)
2436 last_addr
= last
->slot_number
;
2439 else if (!last
->next
)
2441 /* In the absence of an explicit .body directive,
2442 the prologue ends after the last instruction
2443 covered by an unwind directive. */
2444 if (ptr
->r
.type
!= body
)
2446 last_addr
= last
->slot_number
;
2447 switch (last
->r
.type
)
2450 dir_len
= (count_bits (last
->r
.record
.p
.frmask
)
2451 + count_bits (last
->r
.record
.p
.grmask
));
2455 dir_len
+= count_bits (last
->r
.record
.p
.rmask
);
2459 dir_len
+= count_bits (last
->r
.record
.p
.brmask
);
2462 dir_len
+= count_bits (last
->r
.record
.p
.grmask
);
2471 size
= slot_index (last_addr
, first_addr
) + dir_len
;
2472 rlen
= ptr
->r
.record
.r
.rlen
= size
;
2477 ptr
->r
.record
.b
.t
= rlen
- 1 - t
;
2488 case priunat_when_gr
:
2489 case priunat_when_mem
:
2493 ptr
->r
.record
.p
.t
= t
;
2501 case spill_psprel_p
:
2502 ptr
->r
.record
.x
.t
= t
;
2508 as_bad ("frgr_mem record before region record!\n");
2511 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.frmask
;
2512 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.grmask
;
2513 set_imask (region
, ptr
->r
.record
.p
.frmask
, t
, 1);
2514 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2519 as_bad ("fr_mem record before region record!\n");
2522 region
->r
.record
.r
.mask
.fr_mem
|= ptr
->r
.record
.p
.rmask
;
2523 set_imask (region
, ptr
->r
.record
.p
.rmask
, t
, 1);
2528 as_bad ("gr_mem record before region record!\n");
2531 region
->r
.record
.r
.mask
.gr_mem
|= ptr
->r
.record
.p
.rmask
;
2532 set_imask (region
, ptr
->r
.record
.p
.rmask
, t
, 2);
2537 as_bad ("br_mem record before region record!\n");
2540 region
->r
.record
.r
.mask
.br_mem
|= ptr
->r
.record
.p
.brmask
;
2541 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2547 as_bad ("gr_gr record before region record!\n");
2550 set_imask (region
, ptr
->r
.record
.p
.grmask
, t
, 2);
2555 as_bad ("br_gr record before region record!\n");
2558 set_imask (region
, ptr
->r
.record
.p
.brmask
, t
, 3);
2567 /* Generate an unwind image from a record list. Returns the number of
2568 bytes in the resulting image. The memory image itselof is returned
2569 in the 'ptr' parameter. */
2571 output_unw_records (list
, ptr
)
2575 int size
, x
, extra
= 0;
2578 fixup_unw_records (list
);
2579 size
= calc_record_size (list
);
2581 /* pad to 8 byte boundry. */
2585 /* Add 8 for the header + 8 more bytes for the personality offset. */
2586 mem
= xmalloc (size
+ extra
+ 16);
2588 vbyte_mem_ptr
= mem
+ 8;
2589 /* Clear the padding area and personality. */
2590 memset (mem
+ 8 + size
, 0 , extra
+ 8);
2591 /* Initialize the header area. */
2592 md_number_to_chars (mem
, (((bfd_vma
) 1 << 48) /* version */
2593 | (unwind
.personality_routine
2594 ? ((bfd_vma
) 3 << 32) /* U & E handler flags */
2596 | ((size
+ extra
) / 8)), /* length (dwords) */
2599 process_unw_records (list
, output_vbyte_mem
);
2602 return size
+ extra
+ 16;
2606 convert_expr_to_ab_reg (e
, ab
, regp
)
2613 if (e
->X_op
!= O_register
)
2616 reg
= e
->X_add_number
;
2617 if (reg
>= REG_GR
+ 4 && reg
<= REG_GR
+ 7)
2620 *regp
= reg
- REG_GR
;
2622 else if ((reg
>= REG_FR
+ 2 && reg
<= REG_FR
+ 5)
2623 || (reg
>= REG_FR
+ 16 && reg
<= REG_FR
+ 31))
2626 *regp
= reg
- REG_FR
;
2628 else if (reg
>= REG_BR
+ 1 && reg
<= REG_BR
+ 5)
2631 *regp
= reg
- REG_BR
;
2638 case REG_PR
: *regp
= 0; break;
2639 case REG_PSP
: *regp
= 1; break;
2640 case REG_PRIUNAT
: *regp
= 2; break;
2641 case REG_BR
+ 0: *regp
= 3; break;
2642 case REG_AR
+ AR_BSP
: *regp
= 4; break;
2643 case REG_AR
+ AR_BSPSTORE
: *regp
= 5; break;
2644 case REG_AR
+ AR_RNAT
: *regp
= 6; break;
2645 case REG_AR
+ AR_UNAT
: *regp
= 7; break;
2646 case REG_AR
+ AR_FPSR
: *regp
= 8; break;
2647 case REG_AR
+ AR_PFS
: *regp
= 9; break;
2648 case REG_AR
+ AR_LC
: *regp
= 10; break;
2658 convert_expr_to_xy_reg (e
, xy
, regp
)
2665 if (e
->X_op
!= O_register
)
2668 reg
= e
->X_add_number
;
2670 if (reg
>= REG_GR
&& reg
<= REG_GR
+ 127)
2673 *regp
= reg
- REG_GR
;
2675 else if (reg
>= REG_FR
&& reg
<= REG_FR
+ 127)
2678 *regp
= reg
- REG_FR
;
2680 else if (reg
>= REG_BR
&& reg
<= REG_BR
+ 7)
2683 *regp
= reg
- REG_BR
;
2697 radix
= *input_line_pointer
++;
2699 if (radix
!= 'C' && !is_end_of_line
[(unsigned char) radix
])
2701 as_bad ("Radix `%c' unsupported", *input_line_pointer
);
2702 ignore_rest_of_line ();
2707 /* .sbss, .bss etc. are macros that expand into ".section SECNAME". */
2709 dot_special_section (which
)
2712 set_section ((char *) special_section_name
[which
]);
2716 add_unwind_entry (ptr
)
2720 unwind
.tail
->next
= ptr
;
2725 /* The current entry can in fact be a chain of unwind entries. */
2726 if (unwind
.current_entry
== NULL
)
2727 unwind
.current_entry
= ptr
;
2738 if (e
.X_op
!= O_constant
)
2739 as_bad ("Operand to .fframe must be a constant");
2741 add_unwind_entry (output_mem_stack_f (e
.X_add_number
));
2752 reg
= e
.X_add_number
- REG_GR
;
2753 if (e
.X_op
== O_register
&& reg
< 128)
2755 add_unwind_entry (output_mem_stack_v ());
2756 if (! (unwind
.prologue_mask
& 2))
2757 add_unwind_entry (output_psp_gr (reg
));
2760 as_bad ("First operand to .vframe must be a general register");
2764 dot_vframesp (dummy
)
2770 if (e
.X_op
== O_constant
)
2772 add_unwind_entry (output_mem_stack_v ());
2773 add_unwind_entry (output_psp_sprel (e
.X_add_number
));
2776 as_bad ("First operand to .vframesp must be a general register");
2780 dot_vframepsp (dummy
)
2786 if (e
.X_op
== O_constant
)
2788 add_unwind_entry (output_mem_stack_v ());
2789 add_unwind_entry (output_psp_sprel (e
.X_add_number
));
2792 as_bad ("First operand to .vframepsp must be a general register");
2803 sep
= parse_operand (&e1
);
2805 as_bad ("No second operand to .save");
2806 sep
= parse_operand (&e2
);
2808 reg1
= e1
.X_add_number
;
2809 reg2
= e2
.X_add_number
- REG_GR
;
2811 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
2812 if (e1
.X_op
== O_register
)
2814 if (e2
.X_op
== O_register
&& reg2
>=0 && reg2
< 128)
2818 case REG_AR
+ AR_BSP
:
2819 add_unwind_entry (output_bsp_when ());
2820 add_unwind_entry (output_bsp_gr (reg2
));
2822 case REG_AR
+ AR_BSPSTORE
:
2823 add_unwind_entry (output_bspstore_when ());
2824 add_unwind_entry (output_bspstore_gr (reg2
));
2826 case REG_AR
+ AR_RNAT
:
2827 add_unwind_entry (output_rnat_when ());
2828 add_unwind_entry (output_rnat_gr (reg2
));
2830 case REG_AR
+AR_UNAT
:
2831 add_unwind_entry (output_unat_when ());
2832 add_unwind_entry (output_unat_gr (reg2
));
2834 case REG_AR
+AR_FPSR
:
2835 add_unwind_entry (output_fpsr_when ());
2836 add_unwind_entry (output_fpsr_gr (reg2
));
2839 add_unwind_entry (output_pfs_when ());
2840 if (! (unwind
.prologue_mask
& 4))
2841 add_unwind_entry (output_pfs_gr (reg2
));
2844 add_unwind_entry (output_lc_when ());
2845 add_unwind_entry (output_lc_gr (reg2
));
2848 add_unwind_entry (output_rp_when ());
2849 if (! (unwind
.prologue_mask
& 8))
2850 add_unwind_entry (output_rp_gr (reg2
));
2853 add_unwind_entry (output_preds_when ());
2854 if (! (unwind
.prologue_mask
& 1))
2855 add_unwind_entry (output_preds_gr (reg2
));
2858 add_unwind_entry (output_priunat_when_gr ());
2859 add_unwind_entry (output_priunat_gr (reg2
));
2862 as_bad ("First operand not a valid register");
2866 as_bad (" Second operand not a valid register");
2869 as_bad ("First operand not a register");
2877 unsigned long ecount
= 0;
2880 sep
= parse_operand (&e1
);
2881 if (e1
.X_op
!= O_register
|| e1
.X_add_number
!= REG_GR
+ 12)
2883 as_bad ("First operand to .restore must be stack pointer (sp)");
2889 parse_operand (&e2
);
2890 if (e1
.X_op
!= O_constant
)
2892 as_bad ("Second operand to .restore must be constant");
2897 add_unwind_entry (output_epilogue (ecount
));
2901 dot_restorereg (dummy
)
2904 unsigned int ab
, reg
;
2909 if (!convert_expr_to_ab_reg (&e
, &ab
, ®
))
2911 as_bad ("First operand to .restorereg must be a preserved register");
2914 add_unwind_entry (output_spill_reg (ab
, reg
, 0, 0));
2918 dot_restorereg_p (dummy
)
2921 unsigned int qp
, ab
, reg
;
2925 sep
= parse_operand (&e1
);
2928 as_bad ("No second operand to .restorereg.p");
2932 parse_operand (&e2
);
2934 qp
= e1
.X_add_number
- REG_P
;
2935 if (e1
.X_op
!= O_register
|| qp
> 63)
2937 as_bad ("First operand to .restorereg.p must be a predicate");
2941 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
2943 as_bad ("Second operand to .restorereg.p must be a preserved register");
2946 add_unwind_entry (output_spill_reg_p (ab
, reg
, 0, 0, qp
));
2950 generate_unwind_image ()
2953 unsigned char *unw_rec
;
2955 /* Force out pending instructions, to make sure all unwind records have
2956 a valid slot_number field. */
2957 ia64_flush_insns ();
2959 /* Generate the unwind record. */
2960 size
= output_unw_records (unwind
.list
, (void **) &unw_rec
);
2962 as_bad ("Unwind record is not a multiple of 8 bytes.");
2964 /* If there are unwind records, switch sections, and output the info. */
2967 unsigned char *where
;
2969 set_section ((char *) special_section_name
[SPECIAL_SECTION_UNWIND_INFO
]);
2971 /* Set expression which points to start of unwind descriptor area. */
2972 unwind
.info
= expr_build_dot ();
2974 where
= (unsigned char *)frag_more (size
);
2976 /* Issue a label for this address, and keep track of it to put it
2977 in the unwind section. */
2979 /* Copy the information from the unwind record into this section. The
2980 data is already in the correct byte order. */
2981 memcpy (where
, unw_rec
, size
);
2982 /* Add the personality address to the image. */
2983 if (unwind
.personality_routine
!= 0)
2985 exp
.X_op
= O_symbol
;
2986 exp
.X_add_symbol
= unwind
.personality_routine
;
2987 exp
.X_add_number
= 0;
2988 fix_new_exp (frag_now
, frag_now_fix () - 8, 8,
2989 &exp
, 0, BFD_RELOC_IA64_LTOFF_FPTR64LSB
);
2990 unwind
.personality_routine
= 0;
2992 obj_elf_previous (0);
2995 free_list_records (unwind
.list
);
2996 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
3002 dot_handlerdata (dummy
)
3005 generate_unwind_image ();
3006 demand_empty_rest_of_line ();
3010 dot_unwentry (dummy
)
3013 demand_empty_rest_of_line ();
3024 reg
= e
.X_add_number
- REG_BR
;
3025 if (e
.X_op
== O_register
&& reg
< 8)
3026 add_unwind_entry (output_rp_br (reg
));
3028 as_bad ("First operand not a valid branch register");
3032 dot_savemem (psprel
)
3039 sep
= parse_operand (&e1
);
3041 as_bad ("No second operand to .save%ssp", psprel
? "p" : "");
3042 sep
= parse_operand (&e2
);
3044 reg1
= e1
.X_add_number
;
3045 val
= e2
.X_add_number
;
3047 /* Make sure its a valid ar.xxx reg, OR its br0, aka 'rp'. */
3048 if (e1
.X_op
== O_register
)
3050 if (e2
.X_op
== O_constant
)
3054 case REG_AR
+ AR_BSP
:
3055 add_unwind_entry (output_bsp_when ());
3056 add_unwind_entry ((psprel
3058 : output_bsp_sprel
) (val
));
3060 case REG_AR
+ AR_BSPSTORE
:
3061 add_unwind_entry (output_bspstore_when ());
3062 add_unwind_entry ((psprel
3063 ? output_bspstore_psprel
3064 : output_bspstore_sprel
) (val
));
3066 case REG_AR
+ AR_RNAT
:
3067 add_unwind_entry (output_rnat_when ());
3068 add_unwind_entry ((psprel
3069 ? output_rnat_psprel
3070 : output_rnat_sprel
) (val
));
3072 case REG_AR
+ AR_UNAT
:
3073 add_unwind_entry (output_unat_when ());
3074 add_unwind_entry ((psprel
3075 ? output_unat_psprel
3076 : output_unat_sprel
) (val
));
3078 case REG_AR
+ AR_FPSR
:
3079 add_unwind_entry (output_fpsr_when ());
3080 add_unwind_entry ((psprel
3081 ? output_fpsr_psprel
3082 : output_fpsr_sprel
) (val
));
3084 case REG_AR
+ AR_PFS
:
3085 add_unwind_entry (output_pfs_when ());
3086 add_unwind_entry ((psprel
3088 : output_pfs_sprel
) (val
));
3090 case REG_AR
+ AR_LC
:
3091 add_unwind_entry (output_lc_when ());
3092 add_unwind_entry ((psprel
3094 : output_lc_sprel
) (val
));
3097 add_unwind_entry (output_rp_when ());
3098 add_unwind_entry ((psprel
3100 : output_rp_sprel
) (val
));
3103 add_unwind_entry (output_preds_when ());
3104 add_unwind_entry ((psprel
3105 ? output_preds_psprel
3106 : output_preds_sprel
) (val
));
3109 add_unwind_entry (output_priunat_when_mem ());
3110 add_unwind_entry ((psprel
3111 ? output_priunat_psprel
3112 : output_priunat_sprel
) (val
));
3115 as_bad ("First operand not a valid register");
3119 as_bad (" Second operand not a valid constant");
3122 as_bad ("First operand not a register");
3131 sep
= parse_operand (&e1
);
3133 parse_operand (&e2
);
3135 if (e1
.X_op
!= O_constant
)
3136 as_bad ("First operand to .save.g must be a constant.");
3139 int grmask
= e1
.X_add_number
;
3141 add_unwind_entry (output_gr_mem (grmask
));
3144 int reg
= e2
.X_add_number
- REG_GR
;
3145 if (e2
.X_op
== O_register
&& reg
>=0 && reg
< 128)
3146 add_unwind_entry (output_gr_gr (grmask
, reg
));
3148 as_bad ("Second operand is an invalid register.");
3159 sep
= parse_operand (&e1
);
3161 if (e1
.X_op
!= O_constant
)
3162 as_bad ("Operand to .save.f must be a constant.");
3164 add_unwind_entry (output_fr_mem (e1
.X_add_number
));
3176 sep
= parse_operand (&e1
);
3177 if (e1
.X_op
!= O_constant
)
3179 as_bad ("First operand to .save.b must be a constant.");
3182 brmask
= e1
.X_add_number
;
3186 sep
= parse_operand (&e2
);
3187 reg
= e2
.X_add_number
- REG_GR
;
3188 if (e2
.X_op
!= O_register
|| reg
> 127)
3190 as_bad ("Second operand to .save.b must be a general register.");
3193 add_unwind_entry (output_br_gr (brmask
, e2
.X_add_number
));
3196 add_unwind_entry (output_br_mem (brmask
));
3198 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3199 ignore_rest_of_line ();
3208 sep
= parse_operand (&e1
);
3210 parse_operand (&e2
);
3212 if (e1
.X_op
!= O_constant
|| sep
!= ',' || e2
.X_op
!= O_constant
)
3213 as_bad ("Both operands of .save.gf must be constants.");
3216 int grmask
= e1
.X_add_number
;
3217 int frmask
= e2
.X_add_number
;
3218 add_unwind_entry (output_frgr_mem (grmask
, frmask
));
3229 sep
= parse_operand (&e
);
3230 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3231 ignore_rest_of_line ();
3233 if (e
.X_op
!= O_constant
)
3234 as_bad ("Operand to .spill must be a constant");
3236 add_unwind_entry (output_spill_base (e
.X_add_number
));
3240 dot_spillreg (dummy
)
3243 int sep
, ab
, xy
, reg
, treg
;
3246 sep
= parse_operand (&e1
);
3249 as_bad ("No second operand to .spillreg");
3253 parse_operand (&e2
);
3255 if (!convert_expr_to_ab_reg (&e1
, &ab
, ®
))
3257 as_bad ("First operand to .spillreg must be a preserved register");
3261 if (!convert_expr_to_xy_reg (&e2
, &xy
, &treg
))
3263 as_bad ("Second operand to .spillreg must be a register");
3267 add_unwind_entry (output_spill_reg (ab
, reg
, treg
, xy
));
3271 dot_spillmem (psprel
)
3277 sep
= parse_operand (&e1
);
3280 as_bad ("Second operand missing");
3284 parse_operand (&e2
);
3286 if (!convert_expr_to_ab_reg (&e1
, &ab
, ®
))
3288 as_bad ("First operand to .spill%s must be a preserved register",
3289 psprel
? "psp" : "sp");
3293 if (e2
.X_op
!= O_constant
)
3295 as_bad ("Second operand to .spill%s must be a constant",
3296 psprel
? "psp" : "sp");
3301 add_unwind_entry (output_spill_psprel (ab
, reg
, e2
.X_add_number
));
3303 add_unwind_entry (output_spill_sprel (ab
, reg
, e2
.X_add_number
));
3307 dot_spillreg_p (dummy
)
3310 int sep
, ab
, xy
, reg
, treg
;
3311 expressionS e1
, e2
, e3
;
3314 sep
= parse_operand (&e1
);
3317 as_bad ("No second and third operand to .spillreg.p");
3321 sep
= parse_operand (&e2
);
3324 as_bad ("No third operand to .spillreg.p");
3328 parse_operand (&e3
);
3330 qp
= e1
.X_add_number
- REG_P
;
3332 if (e1
.X_op
!= O_register
|| qp
> 63)
3334 as_bad ("First operand to .spillreg.p must be a predicate");
3338 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
3340 as_bad ("Second operand to .spillreg.p must be a preserved register");
3344 if (!convert_expr_to_xy_reg (&e3
, &xy
, &treg
))
3346 as_bad ("Third operand to .spillreg.p must be a register");
3350 add_unwind_entry (output_spill_reg_p (ab
, reg
, treg
, xy
, qp
));
3354 dot_spillmem_p (psprel
)
3357 expressionS e1
, e2
, e3
;
3361 sep
= parse_operand (&e1
);
3364 as_bad ("Second operand missing");
3368 parse_operand (&e2
);
3371 as_bad ("Second operand missing");
3375 parse_operand (&e3
);
3377 qp
= e1
.X_add_number
- REG_P
;
3378 if (e1
.X_op
!= O_register
|| qp
> 63)
3380 as_bad ("First operand to .spill%s_p must be a predicate",
3381 psprel
? "psp" : "sp");
3385 if (!convert_expr_to_ab_reg (&e2
, &ab
, ®
))
3387 as_bad ("Second operand to .spill%s_p must be a preserved register",
3388 psprel
? "psp" : "sp");
3392 if (e3
.X_op
!= O_constant
)
3394 as_bad ("Third operand to .spill%s_p must be a constant",
3395 psprel
? "psp" : "sp");
3400 add_unwind_entry (output_spill_psprel_p (qp
, ab
, reg
, e3
.X_add_number
));
3402 add_unwind_entry (output_spill_sprel_p (qp
, ab
, reg
, e3
.X_add_number
));
3406 dot_label_state (dummy
)
3412 if (e
.X_op
!= O_constant
)
3414 as_bad ("Operand to .label_state must be a constant");
3417 add_unwind_entry (output_label_state (e
.X_add_number
));
3421 dot_copy_state (dummy
)
3427 if (e
.X_op
!= O_constant
)
3429 as_bad ("Operand to .copy_state must be a constant");
3432 add_unwind_entry (output_copy_state (e
.X_add_number
));
3442 sep
= parse_operand (&e1
);
3445 as_bad ("Second operand to .unwabi missing");
3448 sep
= parse_operand (&e2
);
3449 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3450 ignore_rest_of_line ();
3452 if (e1
.X_op
!= O_constant
)
3454 as_bad ("First operand to .unwabi must be a constant");
3458 if (e2
.X_op
!= O_constant
)
3460 as_bad ("Second operand to .unwabi must be a constant");
3464 add_unwind_entry (output_unwabi (e1
.X_add_number
, e2
.X_add_number
));
3468 dot_personality (dummy
)
3473 name
= input_line_pointer
;
3474 c
= get_symbol_end ();
3475 p
= input_line_pointer
;
3476 unwind
.personality_routine
= symbol_find_or_make (name
);
3479 demand_empty_rest_of_line ();
3489 unwind
.proc_start
= expr_build_dot ();
3490 /* Parse names of main and alternate entry points and mark them as
3491 function symbols: */
3495 name
= input_line_pointer
;
3496 c
= get_symbol_end ();
3497 p
= input_line_pointer
;
3498 sym
= symbol_find_or_make (name
);
3499 if (unwind
.proc_start
== 0)
3501 unwind
.proc_start
= sym
;
3503 symbol_get_bfdsym (sym
)->flags
|= BSF_FUNCTION
;
3506 if (*input_line_pointer
!= ',')
3508 ++input_line_pointer
;
3510 demand_empty_rest_of_line ();
3513 unwind
.list
= unwind
.tail
= unwind
.current_entry
= NULL
;
3514 unwind
.personality_routine
= 0;
3521 unwind
.prologue
= 0;
3522 unwind
.prologue_mask
= 0;
3524 add_unwind_entry (output_body ());
3525 demand_empty_rest_of_line ();
3529 dot_prologue (dummy
)
3533 int mask
= 0, grsave
;
3535 if (!is_it_end_of_statement ())
3538 sep
= parse_operand (&e1
);
3540 as_bad ("No second operand to .prologue");
3541 sep
= parse_operand (&e2
);
3542 if (!is_end_of_line
[sep
] && !is_it_end_of_statement ())
3543 ignore_rest_of_line ();
3545 if (e1
.X_op
== O_constant
)
3547 mask
= e1
.X_add_number
;
3549 if (e2
.X_op
== O_constant
)
3550 grsave
= e2
.X_add_number
;
3551 else if (e2
.X_op
== O_register
3552 && (grsave
= e2
.X_add_number
- REG_GR
) < 128)
3555 as_bad ("Second operand not a constant or general register");
3557 add_unwind_entry (output_prologue_gr (mask
, grsave
));
3560 as_bad ("First operand not a constant");
3563 add_unwind_entry (output_prologue ());
3565 unwind
.prologue
= 1;
3566 unwind
.prologue_mask
= mask
;
3577 subsegT saved_subseg
;
3579 saved_seg
= now_seg
;
3580 saved_subseg
= now_subseg
;
3583 demand_empty_rest_of_line ();
3585 insn_group_break (1, 0, 0);
3587 /* If there was a .handlerdata, we haven't generated an image yet. */
3588 if (unwind
.info
== 0)
3590 generate_unwind_image ();
3593 subseg_set (md
.last_text_seg
, 0);
3594 unwind
.proc_end
= expr_build_dot ();
3596 set_section ((char *) special_section_name
[SPECIAL_SECTION_UNWIND
]);
3597 ptr
= frag_more (24);
3598 where
= frag_now_fix () - 24;
3600 /* Issue the values of a) Proc Begin, b) Proc End, c) Unwind Record. */
3601 e
.X_op
= O_pseudo_fixup
;
3602 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
3604 e
.X_add_symbol
= unwind
.proc_start
;
3605 ia64_cons_fix_new (frag_now
, where
, 8, &e
);
3607 e
.X_op
= O_pseudo_fixup
;
3608 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
3610 e
.X_add_symbol
= unwind
.proc_end
;
3611 ia64_cons_fix_new (frag_now
, where
+ 8, 8, &e
);
3613 if (unwind
.info
!= 0)
3615 e
.X_op
= O_pseudo_fixup
;
3616 e
.X_op_symbol
= pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
;
3618 e
.X_add_symbol
= unwind
.info
;
3619 ia64_cons_fix_new (frag_now
, where
+ 16, 8, &e
);
3622 md_number_to_chars (ptr
+ 16, 0, 8);
3624 subseg_set (saved_seg
, saved_subseg
);
3625 unwind
.proc_start
= unwind
.proc_end
= unwind
.info
= 0;
3629 dot_template (template)
3632 CURR_SLOT
.user_template
= template;
3639 int ins
, locs
, outs
, rots
;
3641 if (is_it_end_of_statement ())
3642 ins
= locs
= outs
= rots
= 0;
3645 ins
= get_absolute_expression ();
3646 if (*input_line_pointer
++ != ',')
3648 locs
= get_absolute_expression ();
3649 if (*input_line_pointer
++ != ',')
3651 outs
= get_absolute_expression ();
3652 if (*input_line_pointer
++ != ',')
3654 rots
= get_absolute_expression ();
3656 set_regstack (ins
, locs
, outs
, rots
);
3660 as_bad ("Comma expected");
3661 ignore_rest_of_line ();
3668 unsigned num_regs
, num_alloced
= 0;
3669 struct dynreg
**drpp
, *dr
;
3670 int ch
, base_reg
= 0;
3676 case DYNREG_GR
: base_reg
= REG_GR
+ 32; break;
3677 case DYNREG_FR
: base_reg
= REG_FR
+ 32; break;
3678 case DYNREG_PR
: base_reg
= REG_P
+ 16; break;
3682 /* first, remove existing names from hash table: */
3683 for (dr
= md
.dynreg
[type
]; dr
&& dr
->num_regs
; dr
= dr
->next
)
3685 hash_delete (md
.dynreg_hash
, dr
->name
);
3689 drpp
= &md
.dynreg
[type
];
3692 start
= input_line_pointer
;
3693 ch
= get_symbol_end ();
3694 *input_line_pointer
= ch
;
3695 len
= (input_line_pointer
- start
);
3698 if (*input_line_pointer
!= '[')
3700 as_bad ("Expected '['");
3703 ++input_line_pointer
; /* skip '[' */
3705 num_regs
= get_absolute_expression ();
3707 if (*input_line_pointer
++ != ']')
3709 as_bad ("Expected ']'");
3714 num_alloced
+= num_regs
;
3718 if (num_alloced
> md
.rot
.num_regs
)
3720 as_bad ("Used more than the declared %d rotating registers",
3726 if (num_alloced
> 96)
3728 as_bad ("Used more than the available 96 rotating registers");
3733 if (num_alloced
> 48)
3735 as_bad ("Used more than the available 48 rotating registers");
3744 name
= obstack_alloc (¬es
, len
+ 1);
3745 memcpy (name
, start
, len
);
3750 *drpp
= obstack_alloc (¬es
, sizeof (*dr
));
3751 memset (*drpp
, 0, sizeof (*dr
));
3756 dr
->num_regs
= num_regs
;
3757 dr
->base
= base_reg
;
3759 base_reg
+= num_regs
;
3761 if (hash_insert (md
.dynreg_hash
, name
, dr
))
3763 as_bad ("Attempt to redefine register set `%s'", name
);
3767 if (*input_line_pointer
!= ',')
3769 ++input_line_pointer
; /* skip comma */
3772 demand_empty_rest_of_line ();
3776 ignore_rest_of_line ();
3780 dot_byteorder (byteorder
)
3783 target_big_endian
= byteorder
;
3795 option
= input_line_pointer
;
3796 ch
= get_symbol_end ();
3797 if (strcmp (option
, "lsb") == 0)
3798 md
.flags
&= ~EF_IA_64_BE
;
3799 else if (strcmp (option
, "msb") == 0)
3800 md
.flags
|= EF_IA_64_BE
;
3801 else if (strcmp (option
, "abi32") == 0)
3802 md
.flags
&= ~EF_IA_64_ABI64
;
3803 else if (strcmp (option
, "abi64") == 0)
3804 md
.flags
|= EF_IA_64_ABI64
;
3806 as_bad ("Unknown psr option `%s'", option
);
3807 *input_line_pointer
= ch
;
3810 if (*input_line_pointer
!= ',')
3813 ++input_line_pointer
;
3816 demand_empty_rest_of_line ();
3823 as_bad (".alias not implemented yet");
3830 new_logical_line (0, get_absolute_expression ());
3831 demand_empty_rest_of_line ();
3835 parse_section_name ()
3841 if (*input_line_pointer
!= '"')
3843 as_bad ("Missing section name");
3844 ignore_rest_of_line ();
3847 name
= demand_copy_C_string (&len
);
3850 ignore_rest_of_line ();
3854 if (*input_line_pointer
!= ',')
3856 as_bad ("Comma expected after section name");
3857 ignore_rest_of_line ();
3860 ++input_line_pointer
; /* skip comma */
3868 char *name
= parse_section_name ();
3874 obj_elf_previous (0);
3877 /* Why doesn't float_cons() call md_cons_align() the way cons() does? */
3879 stmt_float_cons (kind
)
3886 case 'd': size
= 8; break;
3887 case 'x': size
= 10; break;
3894 ia64_do_align (size
);
3902 int saved_auto_align
= md
.auto_align
;
3906 md
.auto_align
= saved_auto_align
;
3910 dot_xfloat_cons (kind
)
3913 char *name
= parse_section_name ();
3918 stmt_float_cons (kind
);
3919 obj_elf_previous (0);
3923 dot_xstringer (zero
)
3926 char *name
= parse_section_name ();
3932 obj_elf_previous (0);
3939 int saved_auto_align
= md
.auto_align
;
3940 char *name
= parse_section_name ();
3947 md
.auto_align
= saved_auto_align
;
3948 obj_elf_previous (0);
3952 dot_xfloat_cons_ua (kind
)
3955 int saved_auto_align
= md
.auto_align
;
3956 char *name
= parse_section_name ();
3962 stmt_float_cons (kind
);
3963 md
.auto_align
= saved_auto_align
;
3964 obj_elf_previous (0);
3967 /* .reg.val <regname>,value */
3975 if (reg
.X_op
!= O_register
)
3977 as_bad (_("Register name expected"));
3978 ignore_rest_of_line ();
3980 else if (*input_line_pointer
++ != ',')
3982 as_bad (_("Comma expected"));
3983 ignore_rest_of_line ();
3987 valueT value
= get_absolute_expression ();
3988 int regno
= reg
.X_add_number
;
3989 if (regno
< REG_GR
|| regno
> REG_GR
+128)
3990 as_warn (_("Register value annotation ignored"));
3993 gr_values
[regno
-REG_GR
].known
= 1;
3994 gr_values
[regno
-REG_GR
].value
= value
;
3995 gr_values
[regno
-REG_GR
].path
= md
.path
;
3998 demand_empty_rest_of_line ();
4001 /* select dv checking mode
4006 A stop is inserted when changing modes
4012 if (md
.manual_bundling
)
4013 as_warn (_("Directive invalid within a bundle"));
4015 if (type
== 'E' || type
== 'A')
4016 md
.mode_explicitly_set
= 0;
4018 md
.mode_explicitly_set
= 1;
4025 if (md
.explicit_mode
)
4026 insn_group_break (1, 0, 0);
4027 md
.explicit_mode
= 0;
4031 if (!md
.explicit_mode
)
4032 insn_group_break (1, 0, 0);
4033 md
.explicit_mode
= 1;
4037 if (md
.explicit_mode
!= md
.default_explicit_mode
)
4038 insn_group_break (1, 0, 0);
4039 md
.explicit_mode
= md
.default_explicit_mode
;
4040 md
.mode_explicitly_set
= 0;
4051 for (regno
= 0;regno
< 64;regno
++)
4053 if (mask
& ((valueT
)1<<regno
))
4055 fprintf (stderr
, "%s p%d", comma
, regno
);
4062 .pred.rel.clear [p1 [,p2 [,...]]] (also .pred.rel "clear")
4063 .pred.rel.imply p1, p2 (also .pred.rel "imply")
4064 .pred.rel.mutex p1, p2 [,...] (also .pred.rel "mutex")
4065 .pred.safe_across_calls p1 [, p2 [,...]]
4073 int p1
= -1, p2
= -1;
4077 if (*input_line_pointer
!= '"')
4079 as_bad (_("Missing predicate relation type"));
4080 ignore_rest_of_line ();
4086 char *form
= demand_copy_C_string (&len
);
4087 if (strcmp (form
, "mutex") == 0)
4089 else if (strcmp (form
, "clear") == 0)
4091 else if (strcmp (form
, "imply") == 0)
4095 as_bad (_("Unrecognized predicate relation type"));
4096 ignore_rest_of_line ();
4100 if (*input_line_pointer
== ',')
4101 ++input_line_pointer
;
4111 if (toupper (*input_line_pointer
) != 'P'
4112 || (regno
= atoi (++input_line_pointer
)) < 0
4115 as_bad (_("Predicate register expected"));
4116 ignore_rest_of_line ();
4119 while (isdigit (*input_line_pointer
))
4120 ++input_line_pointer
;
4127 as_warn (_("Duplicate predicate register ignored"));
4128 mask
|= bit
; count
++;
4129 /* see if it's a range */
4130 if (*input_line_pointer
== '-')
4133 ++input_line_pointer
;
4135 if (toupper (*input_line_pointer
) != 'P'
4136 || (regno
= atoi (++input_line_pointer
)) < 0
4139 as_bad (_("Predicate register expected"));
4140 ignore_rest_of_line ();
4143 while (isdigit (*input_line_pointer
))
4144 ++input_line_pointer
;
4148 as_bad (_("Bad register range"));
4149 ignore_rest_of_line ();
4155 mask
|= bit
; count
++;
4159 if (*input_line_pointer
!= ',')
4161 ++input_line_pointer
;
4170 clear_qp_mutex (mask
);
4171 clear_qp_implies (mask
, (valueT
)0);
4174 if (count
!= 2 || p1
== -1 || p2
== -1)
4175 as_bad (_("Predicate source and target required"));
4176 else if (p1
== 0 || p2
== 0)
4177 as_bad (_("Use of p0 is not valid in this context"));
4179 add_qp_imply (p1
, p2
);
4184 as_bad (_("At least two PR arguments expected"));
4189 as_bad (_("Use of p0 is not valid in this context"));
4192 add_qp_mutex (mask
);
4195 /* note that we don't override any existing relations */
4198 as_bad (_("At least one PR argument expected"));
4203 fprintf (stderr
, "Safe across calls: ");
4204 print_prmask (mask
);
4205 fprintf (stderr
, "\n");
4207 qp_safe_across_calls
= mask
;
4210 demand_empty_rest_of_line ();
4213 /* .entry label [, label [, ...]]
4214 Hint to DV code that the given labels are to be considered entry points.
4215 Otherwise, only global labels are considered entry points.
4228 name
= input_line_pointer
;
4229 c
= get_symbol_end ();
4230 symbolP
= symbol_find_or_make (name
);
4232 err
= hash_insert (md
.entry_hash
, S_GET_NAME (symbolP
), (PTR
) symbolP
);
4234 as_fatal (_("Inserting \"%s\" into entry hint table failed: %s"),
4237 *input_line_pointer
= c
;
4239 c
= *input_line_pointer
;
4242 input_line_pointer
++;
4244 if (*input_line_pointer
== '\n')
4250 demand_empty_rest_of_line ();
4253 /* .mem.offset offset, base
4254 "base" is used to distinguish between offsets from a different base.
4257 dot_mem_offset (dummy
)
4260 md
.mem_offset
.hint
= 1;
4261 md
.mem_offset
.offset
= get_absolute_expression ();
4262 if (*input_line_pointer
!= ',')
4264 as_bad (_("Comma expected"));
4265 ignore_rest_of_line ();
4268 ++input_line_pointer
;
4269 md
.mem_offset
.base
= get_absolute_expression ();
4270 demand_empty_rest_of_line ();
4273 /* ia64-specific pseudo-ops: */
4274 const pseudo_typeS md_pseudo_table
[] =
4276 { "radix", dot_radix
, 0 },
4277 { "lcomm", s_lcomm_bytes
, 1 },
4278 { "bss", dot_special_section
, SPECIAL_SECTION_BSS
},
4279 { "sbss", dot_special_section
, SPECIAL_SECTION_SBSS
},
4280 { "sdata", dot_special_section
, SPECIAL_SECTION_SDATA
},
4281 { "rodata", dot_special_section
, SPECIAL_SECTION_RODATA
},
4282 { "comment", dot_special_section
, SPECIAL_SECTION_COMMENT
},
4283 { "ia_64.unwind", dot_special_section
, SPECIAL_SECTION_UNWIND
},
4284 { "ia_64.unwind_info", dot_special_section
, SPECIAL_SECTION_UNWIND_INFO
},
4285 { "proc", dot_proc
, 0 },
4286 { "body", dot_body
, 0 },
4287 { "prologue", dot_prologue
, 0 },
4288 { "endp", dot_endp
},
4289 { "file", dwarf2_directive_file
},
4290 { "loc", dwarf2_directive_loc
},
4292 { "fframe", dot_fframe
},
4293 { "vframe", dot_vframe
},
4294 { "vframesp", dot_vframesp
},
4295 { "vframepsp", dot_vframepsp
},
4296 { "save", dot_save
},
4297 { "restore", dot_restore
},
4298 { "restorereg", dot_restorereg
},
4299 { "restorereg.p", dot_restorereg_p
},
4300 { "handlerdata", dot_handlerdata
},
4301 { "unwentry", dot_unwentry
},
4302 { "altrp", dot_altrp
},
4303 { "savesp", dot_savemem
, 0 },
4304 { "savepsp", dot_savemem
, 1 },
4305 { "save.g", dot_saveg
},
4306 { "save.f", dot_savef
},
4307 { "save.b", dot_saveb
},
4308 { "save.gf", dot_savegf
},
4309 { "spill", dot_spill
},
4310 { "spillreg", dot_spillreg
},
4311 { "spillsp", dot_spillmem
, 0 },
4312 { "spillpsp", dot_spillmem
, 1 },
4313 { "spillreg.p", dot_spillreg_p
},
4314 { "spillsp.p", dot_spillmem_p
, 0 },
4315 { "spillpsp.p", dot_spillmem_p
, 1 },
4316 { "label_state", dot_label_state
},
4317 { "copy_state", dot_copy_state
},
4318 { "unwabi", dot_unwabi
},
4319 { "personality", dot_personality
},
4321 { "estate", dot_estate
},
4323 { "mii", dot_template
, 0x0 },
4324 { "mli", dot_template
, 0x2 }, /* old format, for compatibility */
4325 { "mlx", dot_template
, 0x2 },
4326 { "mmi", dot_template
, 0x4 },
4327 { "mfi", dot_template
, 0x6 },
4328 { "mmf", dot_template
, 0x7 },
4329 { "mib", dot_template
, 0x8 },
4330 { "mbb", dot_template
, 0x9 },
4331 { "bbb", dot_template
, 0xb },
4332 { "mmb", dot_template
, 0xc },
4333 { "mfb", dot_template
, 0xe },
4335 { "lb", dot_scope
, 0 },
4336 { "le", dot_scope
, 1 },
4338 { "align", s_align_bytes
, 0 },
4339 { "regstk", dot_regstk
, 0 },
4340 { "rotr", dot_rot
, DYNREG_GR
},
4341 { "rotf", dot_rot
, DYNREG_FR
},
4342 { "rotp", dot_rot
, DYNREG_PR
},
4343 { "lsb", dot_byteorder
, 0 },
4344 { "msb", dot_byteorder
, 1 },
4345 { "psr", dot_psr
, 0 },
4346 { "alias", dot_alias
, 0 },
4347 { "ln", dot_ln
, 0 }, /* source line info (for debugging) */
4349 { "xdata1", dot_xdata
, 1 },
4350 { "xdata2", dot_xdata
, 2 },
4351 { "xdata4", dot_xdata
, 4 },
4352 { "xdata8", dot_xdata
, 8 },
4353 { "xreal4", dot_xfloat_cons
, 'f' },
4354 { "xreal8", dot_xfloat_cons
, 'd' },
4355 { "xreal10", dot_xfloat_cons
, 'x' },
4356 { "xstring", dot_xstringer
, 0 },
4357 { "xstringz", dot_xstringer
, 1 },
4359 /* unaligned versions: */
4360 { "xdata2.ua", dot_xdata_ua
, 2 },
4361 { "xdata4.ua", dot_xdata_ua
, 4 },
4362 { "xdata8.ua", dot_xdata_ua
, 8 },
4363 { "xreal4.ua", dot_xfloat_cons_ua
, 'f' },
4364 { "xreal8.ua", dot_xfloat_cons_ua
, 'd' },
4365 { "xreal10.ua", dot_xfloat_cons_ua
, 'x' },
4367 /* annotations/DV checking support */
4368 { "entry", dot_entry
, 0 },
4369 { "mem.offset", dot_mem_offset
},
4370 { "pred.rel", dot_pred_rel
, 0 },
4371 { "pred.rel.clear", dot_pred_rel
, 'c' },
4372 { "pred.rel.imply", dot_pred_rel
, 'i' },
4373 { "pred.rel.mutex", dot_pred_rel
, 'm' },
4374 { "pred.safe_across_calls", dot_pred_rel
, 's' },
4375 { "reg.val", dot_reg_val
},
4376 { "auto", dot_dv_mode
, 'a' },
4377 { "explicit", dot_dv_mode
, 'e' },
4378 { "default", dot_dv_mode
, 'd' },
4383 static const struct pseudo_opcode
4386 void (*handler
) (int);
4391 /* these are more like pseudo-ops, but don't start with a dot */
4392 { "data1", cons
, 1 },
4393 { "data2", cons
, 2 },
4394 { "data4", cons
, 4 },
4395 { "data8", cons
, 8 },
4396 { "real4", stmt_float_cons
, 'f' },
4397 { "real8", stmt_float_cons
, 'd' },
4398 { "real10", stmt_float_cons
, 'x' },
4399 { "string", stringer
, 0 },
4400 { "stringz", stringer
, 1 },
4402 /* unaligned versions: */
4403 { "data2.ua", stmt_cons_ua
, 2 },
4404 { "data4.ua", stmt_cons_ua
, 4 },
4405 { "data8.ua", stmt_cons_ua
, 8 },
4406 { "real4.ua", float_cons
, 'f' },
4407 { "real8.ua", float_cons
, 'd' },
4408 { "real10.ua", float_cons
, 'x' },
4411 /* Declare a register by creating a symbol for it and entering it in
4412 the symbol table. */
4414 declare_register (name
, regnum
)
4421 sym
= symbol_new (name
, reg_section
, regnum
, &zero_address_frag
);
4423 err
= hash_insert (md
.reg_hash
, S_GET_NAME (sym
), (PTR
) sym
);
4425 as_fatal ("Inserting \"%s\" into register table failed: %s",
4432 declare_register_set (prefix
, num_regs
, base_regnum
)
4440 for (i
= 0; i
< num_regs
; ++i
)
4442 sprintf (name
, "%s%u", prefix
, i
);
4443 declare_register (name
, base_regnum
+ i
);
4448 operand_width (opnd
)
4449 enum ia64_opnd opnd
;
4451 const struct ia64_operand
*odesc
= &elf64_ia64_operands
[opnd
];
4452 unsigned int bits
= 0;
4456 for (i
= 0; i
< NELEMS (odesc
->field
) && odesc
->field
[i
].bits
; ++i
)
4457 bits
+= odesc
->field
[i
].bits
;
4463 operand_match (idesc
, index
, e
)
4464 const struct ia64_opcode
*idesc
;
4468 enum ia64_opnd opnd
= idesc
->operands
[index
];
4469 int bits
, relocatable
= 0;
4470 struct insn_fix
*fix
;
4477 case IA64_OPND_AR_CCV
:
4478 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 32)
4482 case IA64_OPND_AR_PFS
:
4483 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_AR
+ 64)
4488 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_GR
+ 0)
4493 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_IP
)
4498 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR
)
4502 case IA64_OPND_PR_ROT
:
4503 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PR_ROT
)
4508 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR
)
4512 case IA64_OPND_PSR_L
:
4513 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_L
)
4517 case IA64_OPND_PSR_UM
:
4518 if (e
->X_op
== O_register
&& e
->X_add_number
== REG_PSR_UM
)
4523 if (e
->X_op
== O_constant
&& e
->X_add_number
== 1)
4528 if (e
->X_op
== O_constant
&& e
->X_add_number
== 8)
4533 if (e
->X_op
== O_constant
&& e
->X_add_number
== 16)
4537 /* register operands: */
4540 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_AR
4541 && e
->X_add_number
< REG_AR
+ 128)
4547 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_BR
4548 && e
->X_add_number
< REG_BR
+ 8)
4553 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_CR
4554 && e
->X_add_number
< REG_CR
+ 128)
4562 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_FR
4563 && e
->X_add_number
< REG_FR
+ 128)
4569 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_P
4570 && e
->X_add_number
< REG_P
+ 64)
4577 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
4578 && e
->X_add_number
< REG_GR
+ 128)
4582 case IA64_OPND_R3_2
:
4583 if (e
->X_op
== O_register
&& e
->X_add_number
>= REG_GR
4584 && e
->X_add_number
< REG_GR
+ 4)
4588 /* indirect operands: */
4589 case IA64_OPND_CPUID_R3
:
4590 case IA64_OPND_DBR_R3
:
4591 case IA64_OPND_DTR_R3
:
4592 case IA64_OPND_ITR_R3
:
4593 case IA64_OPND_IBR_R3
:
4594 case IA64_OPND_MSR_R3
:
4595 case IA64_OPND_PKR_R3
:
4596 case IA64_OPND_PMC_R3
:
4597 case IA64_OPND_PMD_R3
:
4598 case IA64_OPND_RR_R3
:
4599 if (e
->X_op
== O_index
&& e
->X_op_symbol
4600 && (S_GET_VALUE (e
->X_op_symbol
) - IND_CPUID
4601 == opnd
- IA64_OPND_CPUID_R3
))
4606 if (e
->X_op
== O_index
&& !e
->X_op_symbol
)
4610 /* immediate operands: */
4611 case IA64_OPND_CNT2a
:
4612 case IA64_OPND_LEN4
:
4613 case IA64_OPND_LEN6
:
4614 bits
= operand_width (idesc
->operands
[index
]);
4615 if (e
->X_op
== O_constant
4616 && (bfd_vma
) (e
->X_add_number
- 1) < ((bfd_vma
) 1 << bits
))
4620 case IA64_OPND_CNT2b
:
4621 if (e
->X_op
== O_constant
4622 && (bfd_vma
) (e
->X_add_number
- 1) < 3)
4626 case IA64_OPND_CNT2c
:
4627 val
= e
->X_add_number
;
4628 if (e
->X_op
== O_constant
4629 && (val
== 0 || val
== 7 || val
== 15 || val
== 16))
4634 /* SOR must be an integer multiple of 8 */
4635 if (e
->X_add_number
& 0x7)
4639 if (e
->X_op
== O_constant
&&
4640 (bfd_vma
) e
->X_add_number
<= 96)
4644 case IA64_OPND_IMMU62
:
4645 if (e
->X_op
== O_constant
)
4647 if ((bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << 62))
4652 /* FIXME -- need 62-bit relocation type */
4653 as_bad (_("62-bit relocation not yet implemented"));
4657 case IA64_OPND_IMMU64
:
4658 if (e
->X_op
== O_symbol
|| e
->X_op
== O_pseudo_fixup
4659 || e
->X_op
== O_subtract
)
4661 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
4662 fix
->code
= BFD_RELOC_IA64_IMM64
;
4663 if (e
->X_op
!= O_subtract
)
4665 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
4666 if (e
->X_op
== O_pseudo_fixup
)
4670 fix
->opnd
= idesc
->operands
[index
];
4673 ++CURR_SLOT
.num_fixups
;
4676 else if (e
->X_op
== O_constant
)
4680 case IA64_OPND_CCNT5
:
4681 case IA64_OPND_CNT5
:
4682 case IA64_OPND_CNT6
:
4683 case IA64_OPND_CPOS6a
:
4684 case IA64_OPND_CPOS6b
:
4685 case IA64_OPND_CPOS6c
:
4686 case IA64_OPND_IMMU2
:
4687 case IA64_OPND_IMMU7a
:
4688 case IA64_OPND_IMMU7b
:
4689 case IA64_OPND_IMMU21
:
4690 case IA64_OPND_IMMU24
:
4691 case IA64_OPND_MBTYPE4
:
4692 case IA64_OPND_MHTYPE8
:
4693 case IA64_OPND_POS6
:
4694 bits
= operand_width (idesc
->operands
[index
]);
4695 if (e
->X_op
== O_constant
4696 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
4700 case IA64_OPND_IMMU9
:
4701 bits
= operand_width (idesc
->operands
[index
]);
4702 if (e
->X_op
== O_constant
4703 && (bfd_vma
) e
->X_add_number
< ((bfd_vma
) 1 << bits
))
4705 int lobits
= e
->X_add_number
& 0x3;
4706 if (((bfd_vma
) e
->X_add_number
& 0x3C) != 0 && lobits
== 0)
4707 e
->X_add_number
|= (bfd_vma
)0x3;
4712 case IA64_OPND_IMM44
:
4713 /* least 16 bits must be zero */
4714 if ((e
->X_add_number
& 0xffff) != 0)
4715 as_warn (_("lower 16 bits of mask ignored"));
4717 if (e
->X_op
== O_constant
4718 && ((e
->X_add_number
>= 0
4719 && e
->X_add_number
< ((bfd_vma
) 1 << 44))
4720 || (e
->X_add_number
< 0
4721 && -e
->X_add_number
<= ((bfd_vma
) 1 << 44))))
4724 if (e
->X_add_number
>= 0
4725 && (e
->X_add_number
& ((bfd_vma
) 1 << 43)) != 0)
4727 e
->X_add_number
|= ~(((bfd_vma
) 1 << 44) - 1);
4733 case IA64_OPND_IMM17
:
4734 /* bit 0 is a don't care (pr0 is hardwired to 1) */
4735 if (e
->X_op
== O_constant
4736 && ((e
->X_add_number
>= 0
4737 && e
->X_add_number
< ((bfd_vma
) 1 << 17))
4738 || (e
->X_add_number
< 0
4739 && -e
->X_add_number
<= ((bfd_vma
) 1 << 17))))
4742 if (e
->X_add_number
>= 0
4743 && (e
->X_add_number
& ((bfd_vma
) 1 << 16)) != 0)
4745 e
->X_add_number
|= ~(((bfd_vma
)1 << 17) - 1);
4751 case IA64_OPND_IMM14
:
4752 case IA64_OPND_IMM22
:
4754 case IA64_OPND_IMM1
:
4755 case IA64_OPND_IMM8
:
4756 case IA64_OPND_IMM8U4
:
4757 case IA64_OPND_IMM8M1
:
4758 case IA64_OPND_IMM8M1U4
:
4759 case IA64_OPND_IMM8M1U8
:
4760 case IA64_OPND_IMM9a
:
4761 case IA64_OPND_IMM9b
:
4762 bits
= operand_width (idesc
->operands
[index
]);
4763 if (relocatable
&& (e
->X_op
== O_symbol
4764 || e
->X_op
== O_subtract
4765 || e
->X_op
== O_pseudo_fixup
))
4767 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
4769 if (idesc
->operands
[index
] == IA64_OPND_IMM14
)
4770 fix
->code
= BFD_RELOC_IA64_IMM14
;
4772 fix
->code
= BFD_RELOC_IA64_IMM22
;
4774 if (e
->X_op
!= O_subtract
)
4776 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
4777 if (e
->X_op
== O_pseudo_fixup
)
4781 fix
->opnd
= idesc
->operands
[index
];
4784 ++CURR_SLOT
.num_fixups
;
4787 else if (e
->X_op
!= O_constant
4788 && ! (e
->X_op
== O_big
&& opnd
== IA64_OPND_IMM8M1U8
))
4791 if (opnd
== IA64_OPND_IMM8M1U4
)
4793 /* Zero is not valid for unsigned compares that take an adjusted
4794 constant immediate range. */
4795 if (e
->X_add_number
== 0)
4798 /* Sign-extend 32-bit unsigned numbers, so that the following range
4799 checks will work. */
4800 val
= e
->X_add_number
;
4801 if (((val
& (~(bfd_vma
)0 << 32)) == 0)
4802 && ((val
& ((bfd_vma
)1 << 31)) != 0))
4803 val
= ((val
<< 32) >> 32);
4805 /* Check for 0x100000000. This is valid because
4806 0x100000000-1 is the same as ((uint32_t) -1). */
4807 if (val
== ((bfd_signed_vma
) 1 << 32))
4812 else if (opnd
== IA64_OPND_IMM8M1U8
)
4814 /* Zero is not valid for unsigned compares that take an adjusted
4815 constant immediate range. */
4816 if (e
->X_add_number
== 0)
4819 /* Check for 0x10000000000000000. */
4820 if (e
->X_op
== O_big
)
4822 if (generic_bignum
[0] == 0
4823 && generic_bignum
[1] == 0
4824 && generic_bignum
[2] == 0
4825 && generic_bignum
[3] == 0
4826 && generic_bignum
[4] == 1)
4832 val
= e
->X_add_number
- 1;
4834 else if (opnd
== IA64_OPND_IMM8M1
)
4835 val
= e
->X_add_number
- 1;
4836 else if (opnd
== IA64_OPND_IMM8U4
)
4838 /* Sign-extend 32-bit unsigned numbers, so that the following range
4839 checks will work. */
4840 val
= e
->X_add_number
;
4841 if (((val
& (~(bfd_vma
)0 << 32)) == 0)
4842 && ((val
& ((bfd_vma
)1 << 31)) != 0))
4843 val
= ((val
<< 32) >> 32);
4846 val
= e
->X_add_number
;
4848 if ((val
>= 0 && val
< ((bfd_vma
) 1 << (bits
- 1)))
4849 || (val
< 0 && -val
<= ((bfd_vma
) 1 << (bits
- 1))))
4853 case IA64_OPND_INC3
:
4854 /* +/- 1, 4, 8, 16 */
4855 val
= e
->X_add_number
;
4858 if (e
->X_op
== O_constant
4859 && (val
== 1 || val
== 4 || val
== 8 || val
== 16))
4863 case IA64_OPND_TGT25
:
4864 case IA64_OPND_TGT25b
:
4865 case IA64_OPND_TGT25c
:
4866 case IA64_OPND_TGT64
:
4867 if (e
->X_op
== O_symbol
)
4869 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
4870 if (opnd
== IA64_OPND_TGT25
)
4871 fix
->code
= BFD_RELOC_IA64_PCREL21F
;
4872 else if (opnd
== IA64_OPND_TGT25b
)
4873 fix
->code
= BFD_RELOC_IA64_PCREL21M
;
4874 else if (opnd
== IA64_OPND_TGT25c
)
4875 fix
->code
= BFD_RELOC_IA64_PCREL21B
;
4876 else if (opnd
== IA64_OPND_TGT64
)
4877 fix
->code
= BFD_RELOC_IA64_PCREL60B
;
4881 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, fix
->code
);
4882 fix
->opnd
= idesc
->operands
[index
];
4885 ++CURR_SLOT
.num_fixups
;
4888 case IA64_OPND_TAG13
:
4889 case IA64_OPND_TAG13b
:
4896 fix
= CURR_SLOT
.fixup
+ CURR_SLOT
.num_fixups
;
4897 fix
->code
= ia64_gen_real_reloc_type (e
->X_op_symbol
, 0);
4898 fix
->opnd
= idesc
->operands
[index
];
4901 ++CURR_SLOT
.num_fixups
;
4921 memset (e
, 0, sizeof (*e
));
4924 if (*input_line_pointer
!= '}')
4926 sep
= *input_line_pointer
++;
4930 if (!md
.manual_bundling
)
4931 as_warn ("Found '}' when manual bundling is off");
4933 CURR_SLOT
.manual_bundling_off
= 1;
4934 md
.manual_bundling
= 0;
4940 /* Returns the next entry in the opcode table that matches the one in
4941 IDESC, and frees the entry in IDESC. If no matching entry is
4942 found, NULL is returned instead. */
4944 static struct ia64_opcode
*
4945 get_next_opcode (struct ia64_opcode
*idesc
)
4947 struct ia64_opcode
*next
= ia64_find_next_opcode (idesc
);
4948 ia64_free_opcode (idesc
);
4952 /* Parse the operands for the opcode and find the opcode variant that
4953 matches the specified operands, or NULL if no match is possible. */
4954 static struct ia64_opcode
*
4955 parse_operands (idesc
)
4956 struct ia64_opcode
*idesc
;
4958 int i
= 0, highest_unmatched_operand
, num_operands
= 0, num_outputs
= 0;
4960 enum ia64_opnd expected_operand
= IA64_OPND_NIL
;
4962 char *first_arg
= 0, *end
, *saved_input_pointer
;
4965 assert (strlen (idesc
->name
) <= 128);
4967 strcpy (mnemonic
, idesc
->name
);
4968 if (idesc
->operands
[2] == IA64_OPND_SOF
)
4970 /* To make the common idiom "alloc loc?=ar.pfs,0,1,0,0" work, we
4971 can't parse the first operand until we have parsed the
4972 remaining operands of the "alloc" instruction. */
4974 first_arg
= input_line_pointer
;
4975 end
= strchr (input_line_pointer
, '=');
4978 as_bad ("Expected separator `='");
4981 input_line_pointer
= end
+ 1;
4986 for (; i
< NELEMS (CURR_SLOT
.opnd
); ++i
)
4988 sep
= parse_operand (CURR_SLOT
.opnd
+ i
);
4989 if (CURR_SLOT
.opnd
[i
].X_op
== O_absent
)
4994 if (sep
!= '=' && sep
!= ',')
4999 if (num_outputs
> 0)
5000 as_bad ("Duplicate equal sign (=) in instruction");
5002 num_outputs
= i
+ 1;
5007 as_bad ("Illegal operand separator `%c'", sep
);
5011 if (idesc
->operands
[2] == IA64_OPND_SOF
)
5013 /* map alloc r1=ar.pfs,i,l,o,r to alloc r1=ar.pfs,(i+l+o),(i+l),r */
5014 know (strcmp (idesc
->name
, "alloc") == 0);
5015 if (num_operands
== 5 /* first_arg not included in this count! */
5016 && CURR_SLOT
.opnd
[2].X_op
== O_constant
5017 && CURR_SLOT
.opnd
[3].X_op
== O_constant
5018 && CURR_SLOT
.opnd
[4].X_op
== O_constant
5019 && CURR_SLOT
.opnd
[5].X_op
== O_constant
)
5021 sof
= set_regstack (CURR_SLOT
.opnd
[2].X_add_number
,
5022 CURR_SLOT
.opnd
[3].X_add_number
,
5023 CURR_SLOT
.opnd
[4].X_add_number
,
5024 CURR_SLOT
.opnd
[5].X_add_number
);
5026 /* now we can parse the first arg: */
5027 saved_input_pointer
= input_line_pointer
;
5028 input_line_pointer
= first_arg
;
5029 sep
= parse_operand (CURR_SLOT
.opnd
+ 0);
5031 --num_outputs
; /* force error */
5032 input_line_pointer
= saved_input_pointer
;
5034 CURR_SLOT
.opnd
[2].X_add_number
= sof
;
5035 CURR_SLOT
.opnd
[3].X_add_number
5036 = sof
- CURR_SLOT
.opnd
[4].X_add_number
;
5037 CURR_SLOT
.opnd
[4] = CURR_SLOT
.opnd
[5];
5041 highest_unmatched_operand
= 0;
5042 expected_operand
= idesc
->operands
[0];
5043 for (; idesc
; idesc
= get_next_opcode (idesc
))
5045 if (num_outputs
!= idesc
->num_outputs
)
5046 continue; /* mismatch in # of outputs */
5048 CURR_SLOT
.num_fixups
= 0;
5049 for (i
= 0; i
< num_operands
&& idesc
->operands
[i
]; ++i
)
5050 if (!operand_match (idesc
, i
, CURR_SLOT
.opnd
+ i
))
5053 if (i
!= num_operands
)
5055 if (i
> highest_unmatched_operand
)
5057 highest_unmatched_operand
= i
;
5058 expected_operand
= idesc
->operands
[i
];
5063 if (num_operands
< NELEMS (idesc
->operands
)
5064 && idesc
->operands
[num_operands
])
5065 continue; /* mismatch in number of arguments */
5071 if (expected_operand
)
5072 as_bad ("Operand %u of `%s' should be %s",
5073 highest_unmatched_operand
+ 1, mnemonic
,
5074 elf64_ia64_operands
[expected_operand
].desc
);
5076 as_bad ("Operand mismatch");
5083 build_insn (slot
, insnp
)
5087 const struct ia64_operand
*odesc
, *o2desc
;
5088 struct ia64_opcode
*idesc
= slot
->idesc
;
5089 bfd_signed_vma insn
, val
;
5093 insn
= idesc
->opcode
| slot
->qp_regno
;
5095 for (i
= 0; i
< NELEMS (idesc
->operands
) && idesc
->operands
[i
]; ++i
)
5097 if (slot
->opnd
[i
].X_op
== O_register
5098 || slot
->opnd
[i
].X_op
== O_constant
5099 || slot
->opnd
[i
].X_op
== O_index
)
5100 val
= slot
->opnd
[i
].X_add_number
;
5101 else if (slot
->opnd
[i
].X_op
== O_big
)
5103 /* This must be the value 0x10000000000000000. */
5104 assert (idesc
->operands
[i
] == IA64_OPND_IMM8M1U8
);
5110 switch (idesc
->operands
[i
])
5112 case IA64_OPND_IMMU64
:
5113 *insnp
++ = (val
>> 22) & 0x1ffffffffffLL
;
5114 insn
|= (((val
& 0x7f) << 13) | (((val
>> 7) & 0x1ff) << 27)
5115 | (((val
>> 16) & 0x1f) << 22) | (((val
>> 21) & 0x1) << 21)
5116 | (((val
>> 63) & 0x1) << 36));
5119 case IA64_OPND_IMMU62
:
5120 val
&= 0x3fffffffffffffffULL
;
5121 if (val
!= slot
->opnd
[i
].X_add_number
)
5122 as_warn (_("Value truncated to 62 bits"));
5123 *insnp
++ = (val
>> 21) & 0x1ffffffffffLL
;
5124 insn
|= (((val
& 0xfffff) << 6) | (((val
>> 20) & 0x1) << 36));
5127 case IA64_OPND_TGT64
:
5129 *insnp
++ = ((val
>> 20) & 0x7fffffffffLL
) << 2;
5130 insn
|= ((((val
>> 59) & 0x1) << 36)
5131 | (((val
>> 0) & 0xfffff) << 13));
5162 case IA64_OPND_R3_2
:
5163 case IA64_OPND_CPUID_R3
:
5164 case IA64_OPND_DBR_R3
:
5165 case IA64_OPND_DTR_R3
:
5166 case IA64_OPND_ITR_R3
:
5167 case IA64_OPND_IBR_R3
:
5169 case IA64_OPND_MSR_R3
:
5170 case IA64_OPND_PKR_R3
:
5171 case IA64_OPND_PMC_R3
:
5172 case IA64_OPND_PMD_R3
:
5173 case IA64_OPND_RR_R3
:
5181 odesc
= elf64_ia64_operands
+ idesc
->operands
[i
];
5182 err
= (*odesc
->insert
) (odesc
, val
, &insn
);
5184 as_bad_where (slot
->src_file
, slot
->src_line
,
5185 "Bad operand value: %s", err
);
5186 if (idesc
->flags
& IA64_OPCODE_PSEUDO
)
5188 if ((idesc
->flags
& IA64_OPCODE_F2_EQ_F3
)
5189 && odesc
== elf64_ia64_operands
+ IA64_OPND_F3
)
5191 o2desc
= elf64_ia64_operands
+ IA64_OPND_F2
;
5192 (*o2desc
->insert
) (o2desc
, val
, &insn
);
5194 if ((idesc
->flags
& IA64_OPCODE_LEN_EQ_64MCNT
)
5195 && (odesc
== elf64_ia64_operands
+ IA64_OPND_CPOS6a
5196 || odesc
== elf64_ia64_operands
+ IA64_OPND_POS6
))
5198 o2desc
= elf64_ia64_operands
+ IA64_OPND_LEN6
;
5199 (*o2desc
->insert
) (o2desc
, 64 - val
, &insn
);
5209 unsigned int manual_bundling_on
= 0, manual_bundling_off
= 0;
5210 unsigned int manual_bundling
= 0;
5211 enum ia64_unit required_unit
, insn_unit
= 0;
5212 enum ia64_insn_type type
[3], insn_type
;
5213 unsigned int template, orig_template
;
5214 bfd_vma insn
[3] = {-1, -1, -1};
5215 struct ia64_opcode
*idesc
;
5216 int end_of_insn_group
= 0, user_template
= -1;
5217 int n
, i
, j
, first
, curr
;
5218 unw_rec_list
*ptr
, *prev
;
5219 bfd_vma t0
= 0, t1
= 0;
5220 struct label_fix
*lfix
;
5221 struct insn_fix
*ifix
;
5226 first
= (md
.curr_slot
+ NUM_SLOTS
- md
.num_slots_in_use
) % NUM_SLOTS
;
5227 know (first
>= 0 & first
< NUM_SLOTS
);
5228 n
= MIN (3, md
.num_slots_in_use
);
5230 /* Determine template: user user_template if specified, best match
5233 if (md
.slot
[first
].user_template
>= 0)
5234 user_template
= template = md
.slot
[first
].user_template
;
5237 /* auto select appropriate template */
5238 memset (type
, 0, sizeof (type
));
5240 for (i
= 0; i
< n
; ++i
)
5242 type
[i
] = md
.slot
[curr
].idesc
->type
;
5243 curr
= (curr
+ 1) % NUM_SLOTS
;
5245 template = best_template
[type
[0]][type
[1]][type
[2]];
5248 /* initialize instructions with appropriate nops: */
5249 for (i
= 0; i
< 3; ++i
)
5250 insn
[i
] = nop
[ia64_templ_desc
[template].exec_unit
[i
]];
5254 /* now fill in slots with as many insns as possible: */
5256 idesc
= md
.slot
[curr
].idesc
;
5257 end_of_insn_group
= 0;
5258 for (i
= 0; i
< 3 && md
.num_slots_in_use
> 0; ++i
)
5260 /* Set the slot number for prologue/body records now as those
5261 refer to the current point, not the point after the
5262 instruction has been issued: */
5263 /* Don't try to delete prologue/body records here, as that will cause
5264 them to also be deleted from the master list of unwind records. */
5265 for (ptr
= md
.slot
[curr
].unwind_record
; ptr
; ptr
= ptr
->next
)
5266 if (ptr
->r
.type
== prologue
|| ptr
->r
.type
== prologue_gr
5267 || ptr
->r
.type
== body
)
5268 ptr
->slot_number
= (unsigned long) f
+ i
;
5270 if (idesc
->flags
& IA64_OPCODE_SLOT2
)
5272 if (manual_bundling
&& i
!= 2)
5273 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
5274 "`%s' must be last in bundle", idesc
->name
);
5278 if (idesc
->flags
& IA64_OPCODE_LAST
)
5280 int required_slot
, required_template
;
5282 /* If we need a stop bit after an M slot, our only choice is
5283 template 5 (M;;MI). If we need a stop bit after a B
5284 slot, our only choice is to place it at the end of the
5285 bundle, because the only available templates are MIB,
5286 MBB, BBB, MMB, and MFB. We don't handle anything other
5287 than M and B slots because these are the only kind of
5288 instructions that can have the IA64_OPCODE_LAST bit set. */
5289 required_template
= template;
5290 switch (idesc
->type
)
5294 required_template
= 5;
5302 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
5303 "Internal error: don't know how to force %s to end"
5304 "of instruction group", idesc
->name
);
5308 if (manual_bundling
&& i
!= required_slot
)
5309 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
5310 "`%s' must be last in instruction group",
5312 if (required_slot
< i
)
5313 /* Can't fit this instruction. */
5317 if (required_template
!= template)
5319 /* If we switch the template, we need to reset the NOPs
5320 after slot i. The slot-types of the instructions ahead
5321 of i never change, so we don't need to worry about
5322 changing NOPs in front of this slot. */
5323 for (j
= i
; j
< 3; ++j
)
5324 insn
[j
] = nop
[ia64_templ_desc
[required_template
].exec_unit
[j
]];
5326 template = required_template
;
5328 if (curr
!= first
&& md
.slot
[curr
].label_fixups
)
5330 if (manual_bundling_on
)
5331 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
5332 "Label must be first in a bundle");
5333 /* This insn must go into the first slot of a bundle. */
5337 manual_bundling_on
= md
.slot
[curr
].manual_bundling_on
;
5338 manual_bundling_off
= md
.slot
[curr
].manual_bundling_off
;
5340 if (manual_bundling_on
)
5343 manual_bundling
= 1;
5345 break; /* need to start a new bundle */
5348 if (end_of_insn_group
&& md
.num_slots_in_use
>= 1)
5350 /* We need an instruction group boundary in the middle of a
5351 bundle. See if we can switch to an other template with
5352 an appropriate boundary. */
5354 orig_template
= template;
5355 if (i
== 1 && (user_template
== 4
5356 || (user_template
< 0
5357 && (ia64_templ_desc
[template].exec_unit
[0]
5361 end_of_insn_group
= 0;
5363 else if (i
== 2 && (user_template
== 0
5364 || (user_template
< 0
5365 && (ia64_templ_desc
[template].exec_unit
[1]
5367 /* This test makes sure we don't switch the template if
5368 the next instruction is one that needs to be first in
5369 an instruction group. Since all those instructions are
5370 in the M group, there is no way such an instruction can
5371 fit in this bundle even if we switch the template. The
5372 reason we have to check for this is that otherwise we
5373 may end up generating "MI;;I M.." which has the deadly
5374 effect that the second M instruction is no longer the
5375 first in the bundle! --davidm 99/12/16 */
5376 && (idesc
->flags
& IA64_OPCODE_FIRST
) == 0)
5379 end_of_insn_group
= 0;
5381 else if (curr
!= first
)
5382 /* can't fit this insn */
5385 if (template != orig_template
)
5386 /* if we switch the template, we need to reset the NOPs
5387 after slot i. The slot-types of the instructions ahead
5388 of i never change, so we don't need to worry about
5389 changing NOPs in front of this slot. */
5390 for (j
= i
; j
< 3; ++j
)
5391 insn
[j
] = nop
[ia64_templ_desc
[template].exec_unit
[j
]];
5393 required_unit
= ia64_templ_desc
[template].exec_unit
[i
];
5395 /* resolve dynamic opcodes such as "break" and "nop": */
5396 if (idesc
->type
== IA64_TYPE_DYN
)
5398 if ((strcmp (idesc
->name
, "nop") == 0)
5399 || (strcmp (idesc
->name
, "break") == 0))
5400 insn_unit
= required_unit
;
5401 else if (strcmp (idesc
->name
, "chk.s") == 0)
5403 insn_unit
= IA64_UNIT_M
;
5404 if (required_unit
== IA64_UNIT_I
)
5405 insn_unit
= IA64_UNIT_I
;
5408 as_fatal ("emit_one_bundle: unexpected dynamic op");
5410 sprintf (mnemonic
, "%s.%c", idesc
->name
, "?imbf??"[insn_unit
]);
5411 ia64_free_opcode (idesc
);
5412 md
.slot
[curr
].idesc
= idesc
= ia64_find_opcode (mnemonic
);
5414 know (!idesc
->next
); /* no resolved dynamic ops have collisions */
5419 insn_type
= idesc
->type
;
5420 insn_unit
= IA64_UNIT_NIL
;
5424 if (required_unit
== IA64_UNIT_I
|| required_unit
== IA64_UNIT_M
)
5425 insn_unit
= required_unit
;
5427 case IA64_TYPE_X
: insn_unit
= IA64_UNIT_L
; break;
5428 case IA64_TYPE_I
: insn_unit
= IA64_UNIT_I
; break;
5429 case IA64_TYPE_M
: insn_unit
= IA64_UNIT_M
; break;
5430 case IA64_TYPE_B
: insn_unit
= IA64_UNIT_B
; break;
5431 case IA64_TYPE_F
: insn_unit
= IA64_UNIT_F
; break;
5436 if (insn_unit
!= required_unit
)
5438 if (required_unit
== IA64_UNIT_L
5439 && insn_unit
== IA64_UNIT_I
5440 && !(idesc
->flags
& IA64_OPCODE_X_IN_MLX
))
5442 /* we got ourselves an MLX template but the current
5443 instruction isn't an X-unit, or an I-unit instruction
5444 that can go into the X slot of an MLX template. Duh. */
5445 if (md
.num_slots_in_use
>= NUM_SLOTS
)
5447 as_bad_where (md
.slot
[curr
].src_file
,
5448 md
.slot
[curr
].src_line
,
5449 "`%s' can't go in X slot of "
5450 "MLX template", idesc
->name
);
5451 /* drop this insn so we don't livelock: */
5452 --md
.num_slots_in_use
;
5456 continue; /* try next slot */
5459 if (debug_type
== DEBUG_DWARF2
)
5463 addr
= frag_now
->fr_address
+ frag_now_fix () - 16 + 1*i
;
5464 dwarf2_gen_line_info (addr
, &md
.slot
[curr
].debug_line
);
5467 build_insn (md
.slot
+ curr
, insn
+ i
);
5469 /* Set slot counts for non prologue/body unwind records. */
5470 for (ptr
= md
.slot
[curr
].unwind_record
; ptr
; ptr
= ptr
->next
)
5471 if (ptr
->r
.type
!= prologue
&& ptr
->r
.type
!= prologue_gr
5472 && ptr
->r
.type
!= body
)
5473 ptr
->slot_number
= (unsigned long) f
+ i
;
5474 md
.slot
[curr
].unwind_record
= NULL
;
5475 unwind
.next_slot_number
= (unsigned long) f
+ i
+ ((i
== 2)?(0x10-2):1);
5477 if (required_unit
== IA64_UNIT_L
)
5480 /* skip one slot for long/X-unit instructions */
5483 --md
.num_slots_in_use
;
5485 /* now is a good time to fix up the labels for this insn: */
5486 for (lfix
= md
.slot
[curr
].label_fixups
; lfix
; lfix
= lfix
->next
)
5488 S_SET_VALUE (lfix
->sym
, frag_now_fix () - 16);
5489 symbol_set_frag (lfix
->sym
, frag_now
);
5492 for (j
= 0; j
< md
.slot
[curr
].num_fixups
; ++j
)
5494 ifix
= md
.slot
[curr
].fixup
+ j
;
5495 fix
= fix_new_exp (frag_now
, frag_now_fix () - 16 + i
, 4,
5496 &ifix
->expr
, ifix
->is_pcrel
, ifix
->code
);
5497 fix
->tc_fix_data
.opnd
= ifix
->opnd
;
5498 fix
->fx_plt
= (fix
->fx_r_type
== BFD_RELOC_IA64_PLTOFF22
);
5499 fix
->fx_file
= md
.slot
[curr
].src_file
;
5500 fix
->fx_line
= md
.slot
[curr
].src_line
;
5503 end_of_insn_group
= md
.slot
[curr
].end_of_insn_group
;
5506 ia64_free_opcode (md
.slot
[curr
].idesc
);
5507 memset (md
.slot
+ curr
, 0, sizeof (md
.slot
[curr
]));
5508 md
.slot
[curr
].user_template
= -1;
5510 if (manual_bundling_off
)
5512 manual_bundling
= 0;
5515 curr
= (curr
+ 1) % NUM_SLOTS
;
5516 idesc
= md
.slot
[curr
].idesc
;
5518 if (manual_bundling
)
5520 if (md
.num_slots_in_use
> 0)
5521 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
5522 "`%s' does not fit into %s template",
5523 idesc
->name
, ia64_templ_desc
[template].name
);
5525 as_bad_where (md
.slot
[curr
].src_file
, md
.slot
[curr
].src_line
,
5526 "Missing '}' at end of file");
5528 know (md
.num_slots_in_use
< NUM_SLOTS
);
5530 t0
= end_of_insn_group
| (template << 1) | (insn
[0] << 5) | (insn
[1] << 46);
5531 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
5533 md_number_to_chars (f
+ 0, t0
, 8);
5534 md_number_to_chars (f
+ 8, t1
, 8);
5538 md_parse_option (c
, arg
)
5544 /* Switches from the Intel assembler. */
5546 if (strcmp (arg
, "ilp64") == 0
5547 || strcmp (arg
, "lp64") == 0
5548 || strcmp (arg
, "p64") == 0)
5550 md
.flags
|= EF_IA_64_ABI64
;
5552 else if (strcmp (arg
, "ilp32") == 0)
5554 md
.flags
&= ~EF_IA_64_ABI64
;
5556 else if (strcmp (arg
, "le") == 0)
5558 md
.flags
&= ~EF_IA_64_BE
;
5560 else if (strcmp (arg
, "be") == 0)
5562 md
.flags
|= EF_IA_64_BE
;
5569 if (strcmp (arg
, "so") == 0)
5571 /* Suppress signon message. */
5573 else if (strcmp (arg
, "pi") == 0)
5575 /* Reject privileged instructions. FIXME */
5577 else if (strcmp (arg
, "us") == 0)
5579 /* Allow union of signed and unsigned range. FIXME */
5581 else if (strcmp (arg
, "close_fcalls") == 0)
5583 /* Do not resolve global function calls. */
5590 /* temp[="prefix"] Insert temporary labels into the object file
5591 symbol table prefixed by "prefix".
5592 Default prefix is ":temp:".
5597 /* ??? Conflicts with gas' listing option. */
5598 /* indirect=<tgt> Assume unannotated indirect branches behavior
5599 according to <tgt> --
5600 exit: branch out from the current context (default)
5601 labels: all labels in context may be branch targets
5606 /* -X conflicts with an ignored option, use -x instead */
5608 if (!arg
|| strcmp (arg
, "explicit") == 0)
5610 /* set default mode to explicit */
5611 md
.default_explicit_mode
= 1;
5614 else if (strcmp (arg
, "auto") == 0)
5616 md
.default_explicit_mode
= 0;
5618 else if (strcmp (arg
, "debug") == 0)
5622 else if (strcmp (arg
, "debugx") == 0)
5624 md
.default_explicit_mode
= 1;
5629 as_bad (_("Unrecognized option '-x%s'"), arg
);
5634 /* nops Print nops statistics. */
5637 /* GNU specific switches for gcc. */
5638 case OPTION_MCONSTANT_GP
:
5639 md
.flags
|= EF_IA_64_CONS_GP
;
5642 case OPTION_MAUTO_PIC
:
5643 md
.flags
|= EF_IA_64_NOFUNCDESC_CONS_GP
;
5654 md_show_usage (stream
)
5659 -Milp32|-Milp64|-Mlp64|-Mp64 select data model (default -Mlp64)\n\
5660 -Mle | -Mbe select little- or big-endian byte order (default -Mle)\n\
5661 -x | -xexplicit turn on dependency violation checking (default)\n\
5662 -xauto automagically remove dependency violations\n\
5663 -xdebug debug dependency violation checker\n"),
5668 match (int templ
, int type
, int slot
)
5670 enum ia64_unit unit
;
5673 unit
= ia64_templ_desc
[templ
].exec_unit
[slot
];
5676 case IA64_TYPE_DYN
: result
= 1; break; /* for nop and break */
5678 result
= (unit
== IA64_UNIT_I
|| unit
== IA64_UNIT_M
);
5680 case IA64_TYPE_X
: result
= (unit
== IA64_UNIT_L
); break;
5681 case IA64_TYPE_I
: result
= (unit
== IA64_UNIT_I
); break;
5682 case IA64_TYPE_M
: result
= (unit
== IA64_UNIT_M
); break;
5683 case IA64_TYPE_B
: result
= (unit
== IA64_UNIT_B
); break;
5684 case IA64_TYPE_F
: result
= (unit
== IA64_UNIT_F
); break;
5685 default: result
= 0; break;
5690 /* This function is called once, at assembler startup time. It sets
5691 up all the tables, etc. that the MD part of the assembler will need
5692 that can be determined before arguments are parsed. */
5696 int i
, j
, k
, t
, total
, ar_base
, cr_base
, goodness
, best
, regnum
;
5701 md
.explicit_mode
= md
.default_explicit_mode
;
5703 bfd_set_section_alignment (stdoutput
, text_section
, 4);
5705 target_big_endian
= 0;
5706 pseudo_func
[FUNC_FPTR_RELATIVE
].u
.sym
=
5707 symbol_new (".<fptr>", undefined_section
, FUNC_FPTR_RELATIVE
,
5708 &zero_address_frag
);
5710 pseudo_func
[FUNC_GP_RELATIVE
].u
.sym
=
5711 symbol_new (".<gprel>", undefined_section
, FUNC_GP_RELATIVE
,
5712 &zero_address_frag
);
5714 pseudo_func
[FUNC_LT_RELATIVE
].u
.sym
=
5715 symbol_new (".<ltoff>", undefined_section
, FUNC_LT_RELATIVE
,
5716 &zero_address_frag
);
5718 pseudo_func
[FUNC_PC_RELATIVE
].u
.sym
=
5719 symbol_new (".<pcrel>", undefined_section
, FUNC_PC_RELATIVE
,
5720 &zero_address_frag
);
5722 pseudo_func
[FUNC_PLT_RELATIVE
].u
.sym
=
5723 symbol_new (".<pltoff>", undefined_section
, FUNC_PLT_RELATIVE
,
5724 &zero_address_frag
);
5726 pseudo_func
[FUNC_SEC_RELATIVE
].u
.sym
=
5727 symbol_new (".<secrel>", undefined_section
, FUNC_SEC_RELATIVE
,
5728 &zero_address_frag
);
5730 pseudo_func
[FUNC_SEG_RELATIVE
].u
.sym
=
5731 symbol_new (".<segrel>", undefined_section
, FUNC_SEG_RELATIVE
,
5732 &zero_address_frag
);
5734 pseudo_func
[FUNC_LTV_RELATIVE
].u
.sym
=
5735 symbol_new (".<ltv>", undefined_section
, FUNC_LTV_RELATIVE
,
5736 &zero_address_frag
);
5738 pseudo_func
[FUNC_LT_FPTR_RELATIVE
].u
.sym
=
5739 symbol_new (".<ltoff.fptr>", undefined_section
, FUNC_LT_FPTR_RELATIVE
,
5740 &zero_address_frag
);
5742 /* compute the table of best templates: */
5743 for (i
= 0; i
< IA64_NUM_TYPES
; ++i
)
5744 for (j
= 0; j
< IA64_NUM_TYPES
; ++j
)
5745 for (k
= 0; k
< IA64_NUM_TYPES
; ++k
)
5748 for (t
= 0; t
< NELEMS (ia64_templ_desc
); ++t
)
5751 if (match (t
, i
, 0))
5753 if (match (t
, j
, 1))
5755 if (match (t
, k
, 2))
5760 else if (match (t
, j
, 2))
5765 else if (match (t
, i
, 1))
5767 if (match (t
, j
, 2))
5772 else if (match (t
, i
, 2))
5775 if (goodness
> best
)
5778 best_template
[i
][j
][k
] = t
;
5783 for (i
= 0; i
< NUM_SLOTS
; ++i
)
5784 md
.slot
[i
].user_template
= -1;
5786 md
.pseudo_hash
= hash_new ();
5787 for (i
= 0; i
< NELEMS (pseudo_opcode
); ++i
)
5789 err
= hash_insert (md
.pseudo_hash
, pseudo_opcode
[i
].name
,
5790 (void *) (pseudo_opcode
+ i
));
5792 as_fatal ("ia64.md_begin: can't hash `%s': %s",
5793 pseudo_opcode
[i
].name
, err
);
5796 md
.reg_hash
= hash_new ();
5797 md
.dynreg_hash
= hash_new ();
5798 md
.const_hash
= hash_new ();
5799 md
.entry_hash
= hash_new ();
5801 /* general registers: */
5804 for (i
= 0; i
< total
; ++i
)
5806 sprintf (name
, "r%d", i
- REG_GR
);
5807 md
.regsym
[i
] = declare_register (name
, i
);
5810 /* floating point registers: */
5812 for (; i
< total
; ++i
)
5814 sprintf (name
, "f%d", i
- REG_FR
);
5815 md
.regsym
[i
] = declare_register (name
, i
);
5818 /* application registers: */
5821 for (; i
< total
; ++i
)
5823 sprintf (name
, "ar%d", i
- REG_AR
);
5824 md
.regsym
[i
] = declare_register (name
, i
);
5827 /* control registers: */
5830 for (; i
< total
; ++i
)
5832 sprintf (name
, "cr%d", i
- REG_CR
);
5833 md
.regsym
[i
] = declare_register (name
, i
);
5836 /* predicate registers: */
5838 for (; i
< total
; ++i
)
5840 sprintf (name
, "p%d", i
- REG_P
);
5841 md
.regsym
[i
] = declare_register (name
, i
);
5844 /* branch registers: */
5846 for (; i
< total
; ++i
)
5848 sprintf (name
, "b%d", i
- REG_BR
);
5849 md
.regsym
[i
] = declare_register (name
, i
);
5852 md
.regsym
[REG_IP
] = declare_register ("ip", REG_IP
);
5853 md
.regsym
[REG_CFM
] = declare_register ("cfm", REG_CFM
);
5854 md
.regsym
[REG_PR
] = declare_register ("pr", REG_PR
);
5855 md
.regsym
[REG_PR_ROT
] = declare_register ("pr.rot", REG_PR_ROT
);
5856 md
.regsym
[REG_PSR
] = declare_register ("psr", REG_PSR
);
5857 md
.regsym
[REG_PSR_L
] = declare_register ("psr.l", REG_PSR_L
);
5858 md
.regsym
[REG_PSR_UM
] = declare_register ("psr.um", REG_PSR_UM
);
5860 for (i
= 0; i
< NELEMS (indirect_reg
); ++i
)
5862 regnum
= indirect_reg
[i
].regnum
;
5863 md
.regsym
[regnum
] = declare_register (indirect_reg
[i
].name
, regnum
);
5866 /* define synonyms for application registers: */
5867 for (i
= REG_AR
; i
< REG_AR
+ NELEMS (ar
); ++i
)
5868 md
.regsym
[i
] = declare_register (ar
[i
- REG_AR
].name
,
5869 REG_AR
+ ar
[i
- REG_AR
].regnum
);
5871 /* define synonyms for control registers: */
5872 for (i
= REG_CR
; i
< REG_CR
+ NELEMS (cr
); ++i
)
5873 md
.regsym
[i
] = declare_register (cr
[i
- REG_CR
].name
,
5874 REG_CR
+ cr
[i
- REG_CR
].regnum
);
5876 declare_register ("gp", REG_GR
+ 1);
5877 declare_register ("sp", REG_GR
+ 12);
5878 declare_register ("rp", REG_BR
+ 0);
5880 /* pseudo-registers used to specify unwind info: */
5881 declare_register ("psp", REG_PSP
);
5883 declare_register_set ("ret", 4, REG_GR
+ 8);
5884 declare_register_set ("farg", 8, REG_FR
+ 8);
5885 declare_register_set ("fret", 8, REG_FR
+ 8);
5887 for (i
= 0; i
< NELEMS (const_bits
); ++i
)
5889 err
= hash_insert (md
.const_hash
, const_bits
[i
].name
,
5890 (PTR
) (const_bits
+ i
));
5892 as_fatal ("Inserting \"%s\" into constant hash table failed: %s",
5896 /* Default to 64-bit mode. */
5897 /* ??? This overrides the -M options, but they aren't working anyways. */
5898 md
.flags
|= EF_IA_64_ABI64
;
5900 md
.mem_offset
.hint
= 0;
5903 md
.entry_labels
= NULL
;
5907 ia64_end_of_source ()
5909 /* terminate insn group upon reaching end of file: */
5910 insn_group_break (1, 0, 0);
5912 /* emits slots we haven't written yet: */
5913 ia64_flush_insns ();
5915 bfd_set_private_flags (stdoutput
, md
.flags
);
5917 if (debug_type
== DEBUG_DWARF2
)
5920 md
.mem_offset
.hint
= 0;
5926 md
.qp
.X_op
= O_absent
;
5928 if (ignore_input ())
5931 if (input_line_pointer
[0] == ';' && input_line_pointer
[-1] == ';')
5933 if (md
.detect_dv
&& !md
.explicit_mode
)
5934 as_warn (_("Explicit stops are ignored in auto mode"));
5936 insn_group_break (1, 0, 0);
5941 ia64_unrecognized_line (ch
)
5947 expression (&md
.qp
);
5948 if (*input_line_pointer
++ != ')')
5950 as_bad ("Expected ')'");
5953 if (md
.qp
.X_op
!= O_register
)
5955 as_bad ("Qualifying predicate expected");
5958 if (md
.qp
.X_add_number
< REG_P
|| md
.qp
.X_add_number
>= REG_P
+ 64)
5960 as_bad ("Predicate register expected");
5966 if (md
.manual_bundling
)
5967 as_warn ("Found '{' when manual bundling is already turned on");
5969 CURR_SLOT
.manual_bundling_on
= 1;
5970 md
.manual_bundling
= 1;
5972 /* bundling is only acceptable in explicit mode
5973 or when in default automatic mode */
5974 if (md
.detect_dv
&& !md
.explicit_mode
)
5976 if (!md
.mode_explicitly_set
5977 && !md
.default_explicit_mode
)
5980 as_warn (_("Found '{' after explicit switch to automatic mode"));
5985 if (!md
.manual_bundling
)
5986 as_warn ("Found '}' when manual bundling is off");
5988 PREV_SLOT
.manual_bundling_off
= 1;
5989 md
.manual_bundling
= 0;
5991 /* switch back to automatic mode, if applicable */
5994 && !md
.mode_explicitly_set
5995 && !md
.default_explicit_mode
)
5998 /* Allow '{' to follow on the same line. We also allow ";;", but that
5999 happens automatically because ';' is an end of line marker. */
6001 if (input_line_pointer
[0] == '{')
6003 input_line_pointer
++;
6004 return ia64_unrecognized_line ('{');
6007 demand_empty_rest_of_line ();
6013 return 0; /* not a valid line */
6017 ia64_frob_label (sym
)
6020 struct label_fix
*fix
;
6022 if (bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
6024 md
.last_text_seg
= now_seg
;
6025 fix
= obstack_alloc (¬es
, sizeof (*fix
));
6027 fix
->next
= CURR_SLOT
.label_fixups
;
6028 CURR_SLOT
.label_fixups
= fix
;
6030 /* keep track of how many code entry points we've seen */
6031 if (md
.path
== md
.maxpaths
)
6034 md
.entry_labels
= (const char **)
6035 xrealloc ((void *)md
.entry_labels
, md
.maxpaths
* sizeof (char *));
6037 md
.entry_labels
[md
.path
++] = S_GET_NAME (sym
);
6042 ia64_flush_pending_output ()
6044 if (bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
6046 /* ??? This causes many unnecessary stop bits to be emitted.
6047 Unfortunately, it isn't clear if it is safe to remove this. */
6048 insn_group_break (1, 0, 0);
6049 ia64_flush_insns ();
6053 /* Do ia64-specific expression optimization. All that's done here is
6054 to transform index expressions that are either due to the indexing
6055 of rotating registers or due to the indexing of indirect register
6058 ia64_optimize_expr (l
, op
, r
)
6067 if (l
->X_op
== O_register
&& r
->X_op
== O_constant
)
6069 num_regs
= (l
->X_add_number
>> 16);
6070 if ((unsigned) r
->X_add_number
>= num_regs
)
6073 as_bad ("No current frame");
6075 as_bad ("Index out of range 0..%u", num_regs
- 1);
6076 r
->X_add_number
= 0;
6078 l
->X_add_number
= (l
->X_add_number
& 0xffff) + r
->X_add_number
;
6081 else if (l
->X_op
== O_register
&& r
->X_op
== O_register
)
6083 if (l
->X_add_number
< IND_CPUID
|| l
->X_add_number
> IND_RR
6084 || l
->X_add_number
== IND_MEM
)
6086 as_bad ("Indirect register set name expected");
6087 l
->X_add_number
= IND_CPUID
;
6090 l
->X_op_symbol
= md
.regsym
[l
->X_add_number
];
6091 l
->X_add_number
= r
->X_add_number
;
6099 ia64_parse_name (name
, e
)
6103 struct const_desc
*cdesc
;
6104 struct dynreg
*dr
= 0;
6105 unsigned int regnum
;
6109 /* first see if NAME is a known register name: */
6110 sym
= hash_find (md
.reg_hash
, name
);
6113 e
->X_op
= O_register
;
6114 e
->X_add_number
= S_GET_VALUE (sym
);
6118 cdesc
= hash_find (md
.const_hash
, name
);
6121 e
->X_op
= O_constant
;
6122 e
->X_add_number
= cdesc
->value
;
6126 /* check for inN, locN, or outN: */
6130 if (name
[1] == 'n' && isdigit (name
[2]))
6138 if (name
[1] == 'o' && name
[2] == 'c' && isdigit (name
[3]))
6146 if (name
[1] == 'u' && name
[2] == 't' && isdigit (name
[3]))
6159 /* the name is inN, locN, or outN; parse the register number: */
6160 regnum
= strtoul (name
, &end
, 10);
6161 if (end
> name
&& *end
== '\0')
6163 if ((unsigned) regnum
>= dr
->num_regs
)
6166 as_bad ("No current frame");
6168 as_bad ("Register number out of range 0..%u", dr
->num_regs
-1);
6171 e
->X_op
= O_register
;
6172 e
->X_add_number
= dr
->base
+ regnum
;
6177 if ((dr
= hash_find (md
.dynreg_hash
, name
)))
6179 /* We've got ourselves the name of a rotating register set.
6180 Store the base register number in the low 16 bits of
6181 X_add_number and the size of the register set in the top 16
6183 e
->X_op
= O_register
;
6184 e
->X_add_number
= dr
->base
| (dr
->num_regs
<< 16);
6190 /* Remove the '#' suffix that indicates a symbol as opposed to a register. */
6193 ia64_canonicalize_symbol_name (name
)
6196 size_t len
= strlen(name
);
6197 if (len
> 1 && name
[len
-1] == '#')
6203 is_conditional_branch (idesc
)
6204 struct ia64_opcode
*idesc
;
6206 return (strncmp (idesc
->name
, "br", 2) == 0
6207 && (strcmp (idesc
->name
, "br") == 0
6208 || strncmp (idesc
->name
, "br.cond", 7) == 0
6209 || strncmp (idesc
->name
, "br.call", 7) == 0
6210 || strncmp (idesc
->name
, "br.ret", 6) == 0
6211 || strcmp (idesc
->name
, "brl") == 0
6212 || strncmp (idesc
->name
, "brl.cond", 7) == 0
6213 || strncmp (idesc
->name
, "brl.call", 7) == 0
6214 || strncmp (idesc
->name
, "brl.ret", 6) == 0));
6217 /* Return whether the given opcode is a taken branch. If there's any doubt,
6220 is_taken_branch (idesc
)
6221 struct ia64_opcode
*idesc
;
6223 return ((is_conditional_branch (idesc
) && CURR_SLOT
.qp_regno
== 0)
6224 || strncmp (idesc
->name
, "br.ia", 5) == 0);
6227 /* Return whether the given opcode is an interruption or rfi. If there's any
6228 doubt, returns zero */
6230 is_interruption_or_rfi (idesc
)
6231 struct ia64_opcode
*idesc
;
6233 if (strcmp (idesc
->name
, "rfi") == 0)
6238 /* Returns the index of the given dependency in the opcode's list of chks, or
6239 -1 if there is no dependency. */
6241 depends_on (depind
, idesc
)
6243 struct ia64_opcode
*idesc
;
6246 const struct ia64_opcode_dependency
*dep
= idesc
->dependencies
;
6247 for (i
= 0;i
< dep
->nchks
; i
++)
6249 if (depind
== DEP(dep
->chks
[i
]))
6255 /* Determine a set of specific resources used for a particular resource
6256 class. Returns the number of specific resources identified For those
6257 cases which are not determinable statically, the resource returned is
6260 Meanings of value in 'NOTE':
6261 1) only read/write when the register number is explicitly encoded in the
6263 2) only read CFM when accessing a rotating GR, FR, or PR. mov pr only
6264 accesses CFM when qualifying predicate is in the rotating region.
6265 3) general register value is used to specify an indirect register; not
6266 determinable statically.
6267 4) only read the given resource when bits 7:0 of the indirect index
6268 register value does not match the register number of the resource; not
6269 determinable statically.
6270 5) all rules are implementation specific.
6271 6) only when both the index specified by the reader and the index specified
6272 by the writer have the same value in bits 63:61; not determinable
6274 7) only access the specified resource when the corresponding mask bit is
6276 8) PSR.dfh is only read when these insns reference FR32-127. PSR.dfl is
6277 only read when these insns reference FR2-31
6278 9) PSR.mfl is only written when these insns write FR2-31. PSR.mfh is only
6279 written when these insns write FR32-127
6280 10) The PSR.bn bit is only accessed when one of GR16-31 is specified in the
6282 11) The target predicates are written independently of PR[qp], but source
6283 registers are only read if PR[qp] is true. Since the state of PR[qp]
6284 cannot statically be determined, all source registers are marked used.
6285 12) This insn only reads the specified predicate register when that
6286 register is the PR[qp].
6287 13) This reference to ld-c only applies to teh GR whose value is loaded
6288 with data returned from memory, not the post-incremented address register.
6289 14) The RSE resource includes the implementation-specific RSE internal
6290 state resources. At least one (and possibly more) of these resources are
6291 read by each instruction listed in IC:rse-readers. At least one (and
6292 possibly more) of these resources are written by each insn listed in
6294 15+16) Represents reserved instructions, which the assembler does not
6297 Memory resources (i.e. locations in memory) are *not* marked or tracked by
6298 this code; there are no dependency violations based on memory access.
6302 #define MAX_SPECS 256
6307 specify_resource (dep
, idesc
, type
, specs
, note
, path
)
6308 const struct ia64_dependency
*dep
;
6309 struct ia64_opcode
*idesc
;
6310 int type
; /* is this a DV chk or a DV reg? */
6311 struct rsrc specs
[MAX_SPECS
]; /* returned specific resources */
6312 int note
; /* resource note for this insn's usage */
6313 int path
; /* which execution path to examine */
6320 if (dep
->mode
== IA64_DV_WAW
6321 || (dep
->mode
== IA64_DV_RAW
&& type
== DV_REG
)
6322 || (dep
->mode
== IA64_DV_WAR
&& type
== DV_CHK
))
6325 /* template for any resources we identify */
6326 tmpl
.dependency
= dep
;
6328 tmpl
.insn_srlz
= tmpl
.data_srlz
= 0;
6329 tmpl
.qp_regno
= CURR_SLOT
.qp_regno
;
6330 tmpl
.link_to_qp_branch
= 1;
6331 tmpl
.mem_offset
.hint
= 0;
6336 as_warn (_("Unhandled dependency %s for %s (%s), note %d"), \
6337 dep->name, idesc->name, (rsrc_write?"write":"read"), note)
6338 #define KNOWN(REG) (gr_values[REG].known && gr_values[REG].path >= path)
6340 /* we don't need to track these */
6341 if (dep
->semantics
== IA64_DVS_NONE
)
6344 switch (dep
->specifier
)
6349 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
6351 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
6352 if (regno
>= 0 && regno
<= 7)
6354 specs
[count
] = tmpl
;
6355 specs
[count
++].index
= regno
;
6363 specs
[count
] = tmpl
;
6364 specs
[count
++].index
= i
;
6373 case IA64_RS_AR_UNAT
:
6374 /* This is a mov =AR or mov AR= instruction. */
6375 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
6377 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
6378 if (regno
== AR_UNAT
)
6380 specs
[count
++] = tmpl
;
6385 /* This is a spill/fill, or other instruction that modifies the
6388 /* Unless we can determine the specific bits used, mark the whole
6389 thing; bits 8:3 of the memory address indicate the bit used in
6390 UNAT. The .mem.offset hint may be used to eliminate a small
6391 subset of conflicts. */
6392 specs
[count
] = tmpl
;
6393 if (md
.mem_offset
.hint
)
6396 fprintf (stderr
, " Using hint for spill/fill\n");
6397 /* the index isn't actually used, just set it to something
6398 approximating the bit index */
6399 specs
[count
].index
= (md
.mem_offset
.offset
>> 3) & 0x3F;
6400 specs
[count
].mem_offset
.hint
= 1;
6401 specs
[count
].mem_offset
.offset
= md
.mem_offset
.offset
;
6402 specs
[count
++].mem_offset
.base
= md
.mem_offset
.base
;
6406 specs
[count
++].specific
= 0;
6414 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
6416 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
6417 if ((regno
>= 8 && regno
<= 15)
6418 || (regno
>= 20 && regno
<= 23)
6419 || (regno
>= 31 && regno
<= 39)
6420 || (regno
>= 41 && regno
<= 47)
6421 || (regno
>= 67 && regno
<= 111))
6423 specs
[count
] = tmpl
;
6424 specs
[count
++].index
= regno
;
6437 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
6439 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
6440 if ((regno
>= 48 && regno
<= 63)
6441 || (regno
>= 112 && regno
<= 127))
6443 specs
[count
] = tmpl
;
6444 specs
[count
++].index
= regno
;
6450 for (i
=48;i
< 64;i
++)
6452 specs
[count
] = tmpl
;
6453 specs
[count
++].index
= i
;
6455 for (i
=112;i
< 128;i
++)
6457 specs
[count
] = tmpl
;
6458 specs
[count
++].index
= i
;
6476 for (i
=0;i
< idesc
->num_outputs
;i
++)
6477 if (idesc
->operands
[i
] == IA64_OPND_B1
6478 || idesc
->operands
[i
] == IA64_OPND_B2
)
6480 specs
[count
] = tmpl
;
6481 specs
[count
++].index
=
6482 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
6487 for (i
= idesc
->num_outputs
;i
< NELEMS(idesc
->operands
);i
++)
6488 if (idesc
->operands
[i
] == IA64_OPND_B1
6489 || idesc
->operands
[i
] == IA64_OPND_B2
)
6491 specs
[count
] = tmpl
;
6492 specs
[count
++].index
=
6493 CURR_SLOT
.opnd
[i
].X_add_number
- REG_BR
;
6499 case IA64_RS_CPUID
: /* four or more registers */
6502 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CPUID_R3
)
6504 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
6505 if (regno
>= 0 && regno
< NELEMS(gr_values
)
6508 specs
[count
] = tmpl
;
6509 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
6513 specs
[count
] = tmpl
;
6514 specs
[count
++].specific
= 0;
6524 case IA64_RS_DBR
: /* four or more registers */
6527 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_DBR_R3
)
6529 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
6530 if (regno
>= 0 && regno
< NELEMS(gr_values
)
6533 specs
[count
] = tmpl
;
6534 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
6538 specs
[count
] = tmpl
;
6539 specs
[count
++].specific
= 0;
6543 else if (note
== 0 && !rsrc_write
)
6545 specs
[count
] = tmpl
;
6546 specs
[count
++].specific
= 0;
6554 case IA64_RS_IBR
: /* four or more registers */
6557 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_IBR_R3
)
6559 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
6560 if (regno
>= 0 && regno
< NELEMS(gr_values
)
6563 specs
[count
] = tmpl
;
6564 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
6568 specs
[count
] = tmpl
;
6569 specs
[count
++].specific
= 0;
6582 /* These are implementation specific. Force all references to
6583 conflict with all other references. */
6584 specs
[count
] = tmpl
;
6585 specs
[count
++].specific
= 0;
6593 case IA64_RS_PKR
: /* 16 or more registers */
6594 if (note
== 3 || note
== 4)
6596 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PKR_R3
)
6598 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
6599 if (regno
>= 0 && regno
< NELEMS(gr_values
)
6604 specs
[count
] = tmpl
;
6605 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
6607 else for (i
=0;i
< NELEMS(gr_values
);i
++)
6609 /* uses all registers *except* the one in R3 */
6610 if (i
!= (gr_values
[regno
].value
& 0xFF))
6612 specs
[count
] = tmpl
;
6613 specs
[count
++].index
= i
;
6619 specs
[count
] = tmpl
;
6620 specs
[count
++].specific
= 0;
6627 specs
[count
] = tmpl
;
6628 specs
[count
++].specific
= 0;
6632 case IA64_RS_PMC
: /* four or more registers */
6635 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMC_R3
6636 || (!rsrc_write
&& idesc
->operands
[1] == IA64_OPND_PMD_R3
))
6639 int index
= ((idesc
->operands
[1] == IA64_OPND_R3
&& !rsrc_write
)
6641 int regno
= CURR_SLOT
.opnd
[index
].X_add_number
- REG_GR
;
6642 if (regno
>= 0 && regno
< NELEMS(gr_values
)
6645 specs
[count
] = tmpl
;
6646 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
6650 specs
[count
] = tmpl
;
6651 specs
[count
++].specific
= 0;
6661 case IA64_RS_PMD
: /* four or more registers */
6664 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PMD_R3
)
6666 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
6667 if (regno
>= 0 && regno
< NELEMS(gr_values
)
6670 specs
[count
] = tmpl
;
6671 specs
[count
++].index
= gr_values
[regno
].value
& 0xFF;
6675 specs
[count
] = tmpl
;
6676 specs
[count
++].specific
= 0;
6686 case IA64_RS_RR
: /* eight registers */
6689 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_RR_R3
)
6691 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_GR
;
6692 if (regno
>= 0 && regno
< NELEMS(gr_values
)
6695 specs
[count
] = tmpl
;
6696 specs
[count
++].index
= (gr_values
[regno
].value
>> 61) & 0x7;
6700 specs
[count
] = tmpl
;
6701 specs
[count
++].specific
= 0;
6705 else if (note
== 0 && !rsrc_write
)
6707 specs
[count
] = tmpl
;
6708 specs
[count
++].specific
= 0;
6716 case IA64_RS_CR_IRR
:
6719 /* handle mov-from-CR-IVR; it's a read that writes CR[IRR] */
6720 int regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
;
6722 && idesc
->operands
[1] == IA64_OPND_CR3
6727 specs
[count
] = tmpl
;
6728 specs
[count
++].index
= CR_IRR0
+ i
;
6734 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
6735 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
6737 && regno
<= CR_IRR3
)
6739 specs
[count
] = tmpl
;
6740 specs
[count
++].index
= regno
;
6749 case IA64_RS_CR_LRR
:
6756 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
6757 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
6758 && (regno
== CR_LRR0
|| regno
== CR_LRR1
))
6760 specs
[count
] = tmpl
;
6761 specs
[count
++].index
= regno
;
6769 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
6771 specs
[count
] = tmpl
;
6772 specs
[count
++].index
=
6773 CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
6788 else if (rsrc_write
)
6790 if (dep
->specifier
== IA64_RS_FRb
6791 && idesc
->operands
[0] == IA64_OPND_F1
)
6793 specs
[count
] = tmpl
;
6794 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_FR
;
6799 for (i
=idesc
->num_outputs
;i
< NELEMS(idesc
->operands
);i
++)
6801 if (idesc
->operands
[i
] == IA64_OPND_F2
6802 || idesc
->operands
[i
] == IA64_OPND_F3
6803 || idesc
->operands
[i
] == IA64_OPND_F4
)
6805 specs
[count
] = tmpl
;
6806 specs
[count
++].index
=
6807 CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
6816 /* This reference applies only to the GR whose value is loaded with
6817 data returned from memory */
6818 specs
[count
] = tmpl
;
6819 specs
[count
++].index
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
6825 for (i
= 0; i
< idesc
->num_outputs
; i
++)
6826 if (idesc
->operands
[i
] == IA64_OPND_R1
6827 || idesc
->operands
[i
] == IA64_OPND_R2
6828 || idesc
->operands
[i
] == IA64_OPND_R3
)
6830 specs
[count
] = tmpl
;
6831 specs
[count
++].index
=
6832 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
6834 if (idesc
->flags
& IA64_OPCODE_POSTINC
)
6835 for (i
= 0; i
< NELEMS (idesc
->operands
); i
++)
6836 if (idesc
->operands
[i
] == IA64_OPND_MR3
)
6838 specs
[count
] = tmpl
;
6839 specs
[count
++].index
=
6840 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
6845 /* Look for anything that reads a GR */
6846 for (i
=0;i
< NELEMS(idesc
->operands
);i
++)
6848 if (idesc
->operands
[i
] == IA64_OPND_MR3
6849 || idesc
->operands
[i
] == IA64_OPND_CPUID_R3
6850 || idesc
->operands
[i
] == IA64_OPND_DBR_R3
6851 || idesc
->operands
[i
] == IA64_OPND_IBR_R3
6852 || idesc
->operands
[i
] == IA64_OPND_MSR_R3
6853 || idesc
->operands
[i
] == IA64_OPND_PKR_R3
6854 || idesc
->operands
[i
] == IA64_OPND_PMC_R3
6855 || idesc
->operands
[i
] == IA64_OPND_PMD_R3
6856 || idesc
->operands
[i
] == IA64_OPND_RR_R3
6857 || ((i
>= idesc
->num_outputs
)
6858 && (idesc
->operands
[i
] == IA64_OPND_R1
6859 || idesc
->operands
[i
] == IA64_OPND_R2
6860 || idesc
->operands
[i
] == IA64_OPND_R3
6861 /* addl source register. */
6862 || idesc
->operands
[i
] == IA64_OPND_R3_2
)))
6864 specs
[count
] = tmpl
;
6865 specs
[count
++].index
=
6866 CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
6880 if (idesc
->operands
[0] == IA64_OPND_PR_ROT
)
6882 for (i
=16;i
< 63;i
++)
6884 specs
[count
] = tmpl
;
6885 specs
[count
++].index
= i
;
6890 for (i
=1;i
< 63;i
++)
6892 specs
[count
] = tmpl
;
6893 specs
[count
++].index
= i
;
6900 /* mark only those registers indicated by the mask */
6902 && idesc
->operands
[0] == IA64_OPND_PR
)
6904 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
6905 if (mask
& ((valueT
)1<<16))
6906 mask
|= ~(valueT
)0xffff;
6907 for (i
=1;i
< 63;i
++)
6909 if (mask
& ((valueT
)1<<i
))
6911 specs
[count
] = tmpl
;
6912 specs
[count
++].index
= i
;
6917 && idesc
->operands
[0] == IA64_OPND_PR_ROT
)
6919 for (i
=16;i
< 63;i
++)
6921 specs
[count
] = tmpl
;
6922 specs
[count
++].index
= i
;
6930 else if (note
== 11) /* note 11 implies note 1 as well */
6934 for (i
=0;i
< idesc
->num_outputs
;i
++)
6936 if (idesc
->operands
[i
] == IA64_OPND_P1
6937 || idesc
->operands
[i
] == IA64_OPND_P2
)
6939 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
6942 specs
[count
] = tmpl
;
6943 specs
[count
++].index
= regno
;
6953 else if (note
== 12)
6955 if (CURR_SLOT
.qp_regno
!= 0)
6957 specs
[count
] = tmpl
;
6958 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
6965 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
6966 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
6967 if ((idesc
->operands
[0] == IA64_OPND_P1
6968 || idesc
->operands
[0] == IA64_OPND_P2
)
6969 && p1
!= 0 && p1
!= 63)
6971 specs
[count
] = tmpl
;
6972 specs
[count
++].index
= p1
;
6974 if ((idesc
->operands
[1] == IA64_OPND_P1
6975 || idesc
->operands
[1] == IA64_OPND_P2
)
6976 && p2
!= 0 && p2
!= 63)
6978 specs
[count
] = tmpl
;
6979 specs
[count
++].index
= p2
;
6984 if (CURR_SLOT
.qp_regno
!= 0)
6986 specs
[count
] = tmpl
;
6987 specs
[count
++].index
= CURR_SLOT
.qp_regno
;
6989 if (idesc
->operands
[1] == IA64_OPND_PR
)
6991 for (i
=1;i
< 63;i
++)
6993 specs
[count
] = tmpl
;
6994 specs
[count
++].index
= i
;
7006 /* Verify that the instruction is using the PSR bit indicated in
7010 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_UM
)
7012 if (dep
->regindex
< 6)
7014 specs
[count
++] = tmpl
;
7017 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR
)
7019 if (dep
->regindex
< 32
7020 || dep
->regindex
== 35
7021 || dep
->regindex
== 36
7022 || (!rsrc_write
&& dep
->regindex
== PSR_CPL
))
7024 specs
[count
++] = tmpl
;
7027 else if (idesc
->operands
[!rsrc_write
] == IA64_OPND_PSR_L
)
7029 if (dep
->regindex
< 32
7030 || dep
->regindex
== 35
7031 || dep
->regindex
== 36
7032 || (rsrc_write
&& dep
->regindex
== PSR_CPL
))
7034 specs
[count
++] = tmpl
;
7039 /* Several PSR bits have very specific dependencies. */
7040 switch (dep
->regindex
)
7043 specs
[count
++] = tmpl
;
7048 specs
[count
++] = tmpl
;
7052 /* Only certain CR accesses use PSR.ic */
7053 if (idesc
->operands
[0] == IA64_OPND_CR3
7054 || idesc
->operands
[1] == IA64_OPND_CR3
)
7057 ((idesc
->operands
[0] == IA64_OPND_CR3
)
7060 CURR_SLOT
.opnd
[index
].X_add_number
- REG_CR
;
7075 specs
[count
++] = tmpl
;
7084 specs
[count
++] = tmpl
;
7088 /* Only some AR accesses use cpl */
7089 if (idesc
->operands
[0] == IA64_OPND_AR3
7090 || idesc
->operands
[1] == IA64_OPND_AR3
)
7093 ((idesc
->operands
[0] == IA64_OPND_AR3
)
7096 CURR_SLOT
.opnd
[index
].X_add_number
- REG_AR
;
7103 && regno
<= AR_K7
))))
7105 specs
[count
++] = tmpl
;
7110 specs
[count
++] = tmpl
;
7120 if (idesc
->operands
[0] == IA64_OPND_IMMU24
)
7122 mask
= CURR_SLOT
.opnd
[0].X_add_number
;
7128 if (mask
& ((valueT
)1<<dep
->regindex
))
7130 specs
[count
++] = tmpl
;
7135 int min
= dep
->regindex
== PSR_DFL
? 2 : 32;
7136 int max
= dep
->regindex
== PSR_DFL
? 31 : 127;
7137 /* dfh is read on FR32-127; dfl is read on FR2-31 */
7138 for (i
=0;i
< NELEMS(idesc
->operands
);i
++)
7140 if (idesc
->operands
[i
] == IA64_OPND_F1
7141 || idesc
->operands
[i
] == IA64_OPND_F2
7142 || idesc
->operands
[i
] == IA64_OPND_F3
7143 || idesc
->operands
[i
] == IA64_OPND_F4
)
7145 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
7146 if (reg
>= min
&& reg
<= max
)
7148 specs
[count
++] = tmpl
;
7155 int min
= dep
->regindex
== PSR_MFL
? 2 : 32;
7156 int max
= dep
->regindex
== PSR_MFL
? 31 : 127;
7157 /* mfh is read on writes to FR32-127; mfl is read on writes to
7159 for (i
=0;i
< idesc
->num_outputs
;i
++)
7161 if (idesc
->operands
[i
] == IA64_OPND_F1
)
7163 int reg
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
7164 if (reg
>= min
&& reg
<= max
)
7166 specs
[count
++] = tmpl
;
7171 else if (note
== 10)
7173 for (i
=0;i
< NELEMS(idesc
->operands
);i
++)
7175 if (idesc
->operands
[i
] == IA64_OPND_R1
7176 || idesc
->operands
[i
] == IA64_OPND_R2
7177 || idesc
->operands
[i
] == IA64_OPND_R3
)
7179 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
7180 if (regno
>= 16 && regno
<= 31)
7182 specs
[count
++] = tmpl
;
7193 case IA64_RS_AR_FPSR
:
7194 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
)
7196 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
7197 if (regno
== AR_FPSR
)
7199 specs
[count
++] = tmpl
;
7204 specs
[count
++] = tmpl
;
7209 /* Handle all AR[REG] resources */
7210 if (note
== 0 || note
== 1)
7212 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_AR
;
7213 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_AR3
7214 && regno
== dep
->regindex
)
7216 specs
[count
++] = tmpl
;
7218 /* other AR[REG] resources may be affected by AR accesses */
7219 else if (idesc
->operands
[0] == IA64_OPND_AR3
)
7222 regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
;
7223 switch (dep
->regindex
)
7229 if (regno
== AR_BSPSTORE
)
7231 specs
[count
++] = tmpl
;
7235 (regno
== AR_BSPSTORE
7236 || regno
== AR_RNAT
))
7238 specs
[count
++] = tmpl
;
7243 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
7246 regno
= CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
;
7247 switch (dep
->regindex
)
7252 if (regno
== AR_BSPSTORE
|| regno
== AR_RNAT
)
7254 specs
[count
++] = tmpl
;
7261 specs
[count
++] = tmpl
;
7271 /* Handle all CR[REG] resources */
7272 if (note
== 0 || note
== 1)
7274 if (idesc
->operands
[!rsrc_write
] == IA64_OPND_CR3
)
7276 int regno
= CURR_SLOT
.opnd
[!rsrc_write
].X_add_number
- REG_CR
;
7277 if (regno
== dep
->regindex
)
7279 specs
[count
++] = tmpl
;
7281 else if (!rsrc_write
)
7283 /* Reads from CR[IVR] affect other resources. */
7284 if (regno
== CR_IVR
)
7286 if ((dep
->regindex
>= CR_IRR0
7287 && dep
->regindex
<= CR_IRR3
)
7288 || dep
->regindex
== CR_TPR
)
7290 specs
[count
++] = tmpl
;
7297 specs
[count
++] = tmpl
;
7306 case IA64_RS_INSERVICE
:
7307 /* look for write of EOI (67) or read of IVR (65) */
7308 if ((idesc
->operands
[0] == IA64_OPND_CR3
7309 && CURR_SLOT
.opnd
[0].X_add_number
- REG_CR
== CR_EOI
)
7310 || (idesc
->operands
[1] == IA64_OPND_CR3
7311 && CURR_SLOT
.opnd
[1].X_add_number
- REG_CR
== CR_IVR
))
7313 specs
[count
++] = tmpl
;
7320 specs
[count
++] = tmpl
;
7331 specs
[count
++] = tmpl
;
7335 /* Check if any of the registers accessed are in the rotating region.
7336 mov to/from pr accesses CFM only when qp_regno is in the rotating
7338 for (i
=0;i
< NELEMS(idesc
->operands
);i
++)
7340 if (idesc
->operands
[i
] == IA64_OPND_R1
7341 || idesc
->operands
[i
] == IA64_OPND_R2
7342 || idesc
->operands
[i
] == IA64_OPND_R3
)
7344 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
7345 /* Assumes that md.rot.num_regs is always valid */
7346 if (md
.rot
.num_regs
> 0
7348 && num
< 31 + md
.rot
.num_regs
)
7350 specs
[count
] = tmpl
;
7351 specs
[count
++].specific
= 0;
7354 else if (idesc
->operands
[i
] == IA64_OPND_F1
7355 || idesc
->operands
[i
] == IA64_OPND_F2
7356 || idesc
->operands
[i
] == IA64_OPND_F3
7357 || idesc
->operands
[i
] == IA64_OPND_F4
)
7359 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_FR
;
7362 specs
[count
] = tmpl
;
7363 specs
[count
++].specific
= 0;
7366 else if (idesc
->operands
[i
] == IA64_OPND_P1
7367 || idesc
->operands
[i
] == IA64_OPND_P2
)
7369 int num
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
7372 specs
[count
] = tmpl
;
7373 specs
[count
++].specific
= 0;
7377 if (CURR_SLOT
.qp_regno
> 15)
7379 specs
[count
] = tmpl
;
7380 specs
[count
++].specific
= 0;
7388 specs
[count
++] = tmpl
;
7390 else if (note
== 11)
7392 if ((idesc
->operands
[0] == IA64_OPND_P1
7393 && CURR_SLOT
.opnd
[0].X_add_number
- REG_P
== 63)
7394 || (idesc
->operands
[1] == IA64_OPND_P2
7395 && CURR_SLOT
.opnd
[1].X_add_number
- REG_P
== 63))
7397 specs
[count
++] = tmpl
;
7400 else if (note
== 12)
7402 if (CURR_SLOT
.qp_regno
== 63)
7404 specs
[count
++] = tmpl
;
7410 if (idesc
->operands
[2] == IA64_OPND_IMM17
)
7411 mask
= CURR_SLOT
.opnd
[2].X_add_number
;
7412 if (mask
& ((valueT
)1<<63))
7414 specs
[count
++] = tmpl
;
7421 for (i
=0;i
< idesc
->num_outputs
;i
++)
7422 if ((idesc
->operands
[i
] == IA64_OPND_P1
7423 || idesc
->operands
[i
] == IA64_OPND_P2
)
7424 && CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
== 63)
7426 specs
[count
++] = tmpl
;
7431 if (CURR_SLOT
.qp_regno
== 63)
7433 specs
[count
++] = tmpl
;
7444 /* FIXME we can identify some individual RSE written resources, but RSE
7445 read resources have not yet been completely identified, so for now
7446 treat RSE as a single resource */
7447 if (strncmp (idesc
->name
, "mov", 3) == 0)
7451 if (idesc
->operands
[0] == IA64_OPND_AR3
7452 && CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
)
7454 specs
[count
] = tmpl
;
7455 specs
[count
++].index
= 0; /* IA64_RSE_BSPLOAD/RNATBITINDEX */
7460 if (idesc
->operands
[0] == IA64_OPND_AR3
)
7462 if (CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_BSPSTORE
7463 || CURR_SLOT
.opnd
[0].X_add_number
- REG_AR
== AR_RNAT
)
7465 specs
[count
++] = tmpl
;
7468 else if (idesc
->operands
[1] == IA64_OPND_AR3
)
7470 if (CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSP
7471 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_BSPSTORE
7472 || CURR_SLOT
.opnd
[1].X_add_number
- REG_AR
== AR_RNAT
)
7474 specs
[count
++] = tmpl
;
7481 specs
[count
++] = tmpl
;
7486 /* FIXME -- do any of these need to be non-specific? */
7487 specs
[count
++] = tmpl
;
7491 as_bad (_("Unrecognized dependency specifier %d\n"), dep
->specifier
);
7498 /* Clear branch flags on marked resources. This breaks the link between the
7499 QP of the marking instruction and a subsequent branch on the same QP.
7502 clear_qp_branch_flag (mask
)
7506 for (i
= 0;i
< regdepslen
;i
++)
7508 valueT bit
= ((valueT
)1 << regdeps
[i
].qp_regno
);
7509 if ((bit
& mask
) != 0)
7511 regdeps
[i
].link_to_qp_branch
= 0;
7516 /* Remove any mutexes which contain any of the PRs indicated in the mask.
7518 Any changes to a PR clears the mutex relations which include that PR.
7521 clear_qp_mutex (mask
)
7527 while (i
< qp_mutexeslen
)
7529 if ((qp_mutexes
[i
].prmask
& mask
) != 0)
7533 fprintf (stderr
, " Clearing mutex relation");
7534 print_prmask (qp_mutexes
[i
].prmask
);
7535 fprintf (stderr
, "\n");
7537 qp_mutexes
[i
] = qp_mutexes
[--qp_mutexeslen
];
7544 /* Clear implies relations which contain PRs in the given masks.
7545 P1_MASK indicates the source of the implies relation, while P2_MASK
7546 indicates the implied PR.
7549 clear_qp_implies (p1_mask
, p2_mask
)
7556 while (i
< qp_implieslen
)
7558 if ((((valueT
)1 << qp_implies
[i
].p1
) & p1_mask
) != 0
7559 || (((valueT
)1 << qp_implies
[i
].p2
) & p2_mask
) != 0)
7562 fprintf (stderr
, "Clearing implied relation PR%d->PR%d\n",
7563 qp_implies
[i
].p1
, qp_implies
[i
].p2
);
7564 qp_implies
[i
] = qp_implies
[--qp_implieslen
];
7571 /* add the PRs specified to the list of implied relations */
7573 add_qp_imply (p1
, p2
)
7580 /* p0 is not meaningful here */
7581 if (p1
== 0 || p2
== 0)
7587 /* if it exists already, ignore it */
7588 for (i
=0;i
< qp_implieslen
;i
++)
7590 if (qp_implies
[i
].p1
== p1
7591 && qp_implies
[i
].p2
== p2
7592 && qp_implies
[i
].path
== md
.path
7593 && !qp_implies
[i
].p2_branched
)
7597 if (qp_implieslen
== qp_impliestotlen
)
7599 qp_impliestotlen
+= 20;
7600 qp_implies
= (struct qp_imply
*)
7601 xrealloc ((void *)qp_implies
,
7602 qp_impliestotlen
* sizeof (struct qp_imply
));
7605 fprintf (stderr
, " Registering PR%d implies PR%d\n", p1
, p2
);
7606 qp_implies
[qp_implieslen
].p1
= p1
;
7607 qp_implies
[qp_implieslen
].p2
= p2
;
7608 qp_implies
[qp_implieslen
].path
= md
.path
;
7609 qp_implies
[qp_implieslen
++].p2_branched
= 0;
7611 /* Add in the implied transitive relations; for everything that p2 implies,
7612 make p1 imply that, too; for everything that implies p1, make it imply p2
7614 for (i
=0;i
< qp_implieslen
;i
++)
7616 if (qp_implies
[i
].p1
== p2
)
7617 add_qp_imply (p1
, qp_implies
[i
].p2
);
7618 if (qp_implies
[i
].p2
== p1
)
7619 add_qp_imply (qp_implies
[i
].p1
, p2
);
7621 /* Add in mutex relations implied by this implies relation; for each mutex
7622 relation containing p2, duplicate it and replace p2 with p1. */
7623 bit
= (valueT
)1 << p1
;
7624 mask
= (valueT
)1 << p2
;
7625 for (i
=0;i
< qp_mutexeslen
;i
++)
7627 if (qp_mutexes
[i
].prmask
& mask
)
7628 add_qp_mutex ((qp_mutexes
[i
].prmask
& ~mask
) | bit
);
7633 /* Add the PRs specified in the mask to the mutex list; this means that only
7634 one of the PRs can be true at any time. PR0 should never be included in
7643 if (qp_mutexeslen
== qp_mutexestotlen
)
7645 qp_mutexestotlen
+= 20;
7646 qp_mutexes
= (struct qpmutex
*)
7647 xrealloc ((void *)qp_mutexes
,
7648 qp_mutexestotlen
* sizeof (struct qpmutex
));
7652 fprintf (stderr
, " Registering mutex on");
7653 print_prmask (mask
);
7654 fprintf (stderr
, "\n");
7656 qp_mutexes
[qp_mutexeslen
].path
= md
.path
;
7657 qp_mutexes
[qp_mutexeslen
++].prmask
= mask
;
7661 clear_register_values ()
7665 fprintf (stderr
, " Clearing register values\n");
7666 for (i
=1;i
< NELEMS(gr_values
);i
++)
7667 gr_values
[i
].known
= 0;
7670 /* Keep track of register values/changes which affect DV tracking.
7672 optimization note: should add a flag to classes of insns where otherwise we
7673 have to examine a group of strings to identify them.
7677 note_register_values (idesc
)
7678 struct ia64_opcode
*idesc
;
7680 valueT qp_changemask
= 0;
7683 /* invalidate values for registers being written to */
7684 for (i
=0;i
< idesc
->num_outputs
;i
++)
7686 if (idesc
->operands
[i
] == IA64_OPND_R1
7687 || idesc
->operands
[i
] == IA64_OPND_R2
7688 || idesc
->operands
[i
] == IA64_OPND_R3
)
7690 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
7691 if (regno
> 0 && regno
< NELEMS(gr_values
))
7692 gr_values
[regno
].known
= 0;
7694 else if (idesc
->operands
[i
] == IA64_OPND_R3_2
)
7696 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_GR
;
7697 if (regno
> 0 && regno
< 4)
7698 gr_values
[regno
].known
= 0;
7700 else if (idesc
->operands
[i
] == IA64_OPND_P1
7701 || idesc
->operands
[i
] == IA64_OPND_P2
)
7703 int regno
= CURR_SLOT
.opnd
[i
].X_add_number
- REG_P
;
7704 qp_changemask
|= (valueT
)1 << regno
;
7706 else if (idesc
->operands
[i
] == IA64_OPND_PR
)
7708 if (idesc
->operands
[2] & (valueT
)0x10000)
7709 qp_changemask
= ~(valueT
)0x1FFFF | idesc
->operands
[2];
7711 qp_changemask
= idesc
->operands
[2];
7714 else if (idesc
->operands
[i
] == IA64_OPND_PR_ROT
)
7716 if (idesc
->operands
[1] & ((valueT
)1 << 43))
7717 qp_changemask
= ~(valueT
)0xFFFFFFFFFFF | idesc
->operands
[1];
7719 qp_changemask
= idesc
->operands
[1];
7720 qp_changemask
&= ~(valueT
)0xFFFF;
7725 /* Always clear qp branch flags on any PR change */
7726 /* FIXME there may be exceptions for certain compares */
7727 clear_qp_branch_flag (qp_changemask
);
7729 /* invalidate rotating registers on insns which affect RRBs in CFM */
7730 if (idesc
->flags
& IA64_OPCODE_MOD_RRBS
)
7732 qp_changemask
|= ~(valueT
)0xFFFF;
7733 if (strcmp (idesc
->name
, "clrrrb.pr") != 0)
7735 for (i
=32;i
< 32+md
.rot
.num_regs
;i
++)
7736 gr_values
[i
].known
= 0;
7738 clear_qp_mutex (qp_changemask
);
7739 clear_qp_implies (qp_changemask
, qp_changemask
);
7741 /* after a call, all register values are undefined, except those marked
7743 else if (strncmp (idesc
->name
, "br.call", 6) == 0
7744 || strncmp (idesc
->name
, "brl.call", 7) == 0)
7746 // FIXME keep GR values which are marked as "safe_across_calls"
7747 clear_register_values ();
7748 clear_qp_mutex (~qp_safe_across_calls
);
7749 clear_qp_implies (~qp_safe_across_calls
, ~qp_safe_across_calls
);
7750 clear_qp_branch_flag (~qp_safe_across_calls
);
7752 else if (is_interruption_or_rfi (idesc
)
7753 || is_taken_branch (idesc
))
7755 clear_register_values ();
7756 clear_qp_mutex (~(valueT
)0);
7757 clear_qp_implies (~(valueT
)0, ~(valueT
)0);
7759 /* Look for mutex and implies relations */
7760 else if ((idesc
->operands
[0] == IA64_OPND_P1
7761 || idesc
->operands
[0] == IA64_OPND_P2
)
7762 && (idesc
->operands
[1] == IA64_OPND_P1
7763 || idesc
->operands
[1] == IA64_OPND_P2
))
7765 int p1
= CURR_SLOT
.opnd
[0].X_add_number
- REG_P
;
7766 int p2
= CURR_SLOT
.opnd
[1].X_add_number
- REG_P
;
7767 valueT p1mask
= (valueT
)1 << p1
;
7768 valueT p2mask
= (valueT
)1 << p2
;
7770 /* if one of the PRs is PR0, we can't really do anything */
7771 if (p1
== 0 || p2
== 0)
7774 fprintf (stderr
, " Ignoring PRs due to inclusion of p0\n");
7776 /* In general, clear mutexes and implies which include P1 or P2,
7777 with the following exceptions */
7778 else if (strstr (idesc
->name
, ".or.andcm") != NULL
)
7780 add_qp_mutex (p1mask
| p2mask
);
7781 clear_qp_implies (p2mask
, p1mask
);
7783 else if (strstr (idesc
->name
, ".and.orcm") != NULL
)
7785 add_qp_mutex (p1mask
| p2mask
);
7786 clear_qp_implies (p1mask
, p2mask
);
7788 else if (strstr (idesc
->name
, ".and") != NULL
)
7790 clear_qp_implies (0, p1mask
| p2mask
);
7792 else if (strstr (idesc
->name
, ".or") != NULL
)
7794 clear_qp_mutex (p1mask
| p2mask
);
7795 clear_qp_implies (p1mask
| p2mask
, 0);
7799 clear_qp_implies (p1mask
| p2mask
, p1mask
| p2mask
);
7800 if (strstr (idesc
->name
, ".unc") != NULL
)
7802 add_qp_mutex (p1mask
| p2mask
);
7803 if (CURR_SLOT
.qp_regno
!= 0)
7805 add_qp_imply (CURR_SLOT
.opnd
[0].X_add_number
- REG_P
,
7806 CURR_SLOT
.qp_regno
);
7807 add_qp_imply (CURR_SLOT
.opnd
[1].X_add_number
- REG_P
,
7808 CURR_SLOT
.qp_regno
);
7811 else if (CURR_SLOT
.qp_regno
== 0)
7813 add_qp_mutex (p1mask
| p2mask
);
7817 clear_qp_mutex (p1mask
| p2mask
);
7821 /* Look for mov imm insns into GRs */
7822 else if (idesc
->operands
[0] == IA64_OPND_R1
7823 && (idesc
->operands
[1] == IA64_OPND_IMM22
7824 || idesc
->operands
[1] == IA64_OPND_IMMU64
)
7825 && (strcmp(idesc
->name
, "mov") == 0
7826 || strcmp(idesc
->name
, "movl") == 0))
7828 int regno
= CURR_SLOT
.opnd
[0].X_add_number
- REG_GR
;
7829 if (regno
> 0 && regno
< NELEMS(gr_values
))
7831 gr_values
[regno
].known
= 1;
7832 gr_values
[regno
].value
= CURR_SLOT
.opnd
[1].X_add_number
;
7833 gr_values
[regno
].path
= md
.path
;
7835 fprintf (stderr
, " Know gr%d = 0x%llx\n",
7836 regno
, gr_values
[regno
].value
);
7841 clear_qp_mutex (qp_changemask
);
7842 clear_qp_implies (qp_changemask
, qp_changemask
);
7846 /* Return whether the given predicate registers are currently mutex */
7848 qp_mutex (p1
, p2
, path
)
7858 mask
= ((valueT
)1<<p1
) | (valueT
)1<<p2
;
7859 for (i
=0;i
< qp_mutexeslen
;i
++)
7861 if (qp_mutexes
[i
].path
>= path
7862 && (qp_mutexes
[i
].prmask
& mask
) == mask
)
7869 /* Return whether the given resource is in the given insn's list of chks
7870 Return 1 if the conflict is absolutely determined, 2 if it's a potential
7874 resources_match (rs
, idesc
, note
, qp_regno
, path
)
7876 struct ia64_opcode
*idesc
;
7881 struct rsrc specs
[MAX_SPECS
];
7884 /* If the marked resource's qp_regno and the given qp_regno are mutex,
7885 we don't need to check. One exception is note 11, which indicates that
7886 target predicates are written regardless of PR[qp]. */
7887 if (qp_mutex (rs
->qp_regno
, qp_regno
, path
)
7891 count
= specify_resource (rs
->dependency
, idesc
, DV_CHK
, specs
, note
, path
);
7894 /* UNAT checking is a bit more specific than other resources */
7895 if (rs
->dependency
->specifier
== IA64_RS_AR_UNAT
7896 && specs
[count
].mem_offset
.hint
7897 && rs
->mem_offset
.hint
)
7899 if (rs
->mem_offset
.base
== specs
[count
].mem_offset
.base
)
7901 if (((rs
->mem_offset
.offset
>> 3) & 0x3F) ==
7902 ((specs
[count
].mem_offset
.offset
>> 3) & 0x3F))
7909 /* If either resource is not specific, conservatively assume a conflict
7911 if (!specs
[count
].specific
|| !rs
->specific
)
7913 else if (specs
[count
].index
== rs
->index
)
7918 fprintf (stderr
, " No %s conflicts\n", rs
->dependency
->name
);
7924 /* Indicate an instruction group break; if INSERT_STOP is non-zero, then
7925 insert a stop to create the break. Update all resource dependencies
7926 appropriately. If QP_REGNO is non-zero, only apply the break to resources
7927 which use the same QP_REGNO and have the link_to_qp_branch flag set.
7928 If SAVE_CURRENT is non-zero, don't affect resources marked by the current
7933 insn_group_break (insert_stop
, qp_regno
, save_current
)
7940 if (insert_stop
&& md
.num_slots_in_use
> 0)
7941 PREV_SLOT
.end_of_insn_group
= 1;
7945 fprintf (stderr
, " Insn group break%s",
7946 (insert_stop
? " (w/stop)" : ""));
7948 fprintf (stderr
, " effective for QP=%d", qp_regno
);
7949 fprintf (stderr
, "\n");
7953 while (i
< regdepslen
)
7955 const struct ia64_dependency
*dep
= regdeps
[i
].dependency
;
7958 && regdeps
[i
].qp_regno
!= qp_regno
)
7965 && CURR_SLOT
.src_file
== regdeps
[i
].file
7966 && CURR_SLOT
.src_line
== regdeps
[i
].line
)
7972 /* clear dependencies which are automatically cleared by a stop, or
7973 those that have reached the appropriate state of insn serialization */
7974 if (dep
->semantics
== IA64_DVS_IMPLIED
7975 || dep
->semantics
== IA64_DVS_IMPLIEDF
7976 || regdeps
[i
].insn_srlz
== STATE_SRLZ
)
7978 print_dependency ("Removing", i
);
7979 regdeps
[i
] = regdeps
[--regdepslen
];
7983 if (dep
->semantics
== IA64_DVS_DATA
7984 || dep
->semantics
== IA64_DVS_INSTR
7985 || dep
->semantics
== IA64_DVS_SPECIFIC
)
7987 if (regdeps
[i
].insn_srlz
== STATE_NONE
)
7988 regdeps
[i
].insn_srlz
= STATE_STOP
;
7989 if (regdeps
[i
].data_srlz
== STATE_NONE
)
7990 regdeps
[i
].data_srlz
= STATE_STOP
;
7997 /* Add the given resource usage spec to the list of active dependencies */
7999 mark_resource (idesc
, dep
, spec
, depind
, path
)
8000 struct ia64_opcode
*idesc
;
8001 const struct ia64_dependency
*dep
;
8006 if (regdepslen
== regdepstotlen
)
8008 regdepstotlen
+= 20;
8009 regdeps
= (struct rsrc
*)
8010 xrealloc ((void *)regdeps
,
8011 regdepstotlen
* sizeof(struct rsrc
));
8014 regdeps
[regdepslen
] = *spec
;
8015 regdeps
[regdepslen
].depind
= depind
;
8016 regdeps
[regdepslen
].path
= path
;
8017 regdeps
[regdepslen
].file
= CURR_SLOT
.src_file
;
8018 regdeps
[regdepslen
].line
= CURR_SLOT
.src_line
;
8020 print_dependency ("Adding", regdepslen
);
8026 print_dependency (action
, depind
)
8032 fprintf (stderr
, " %s %s '%s'",
8033 action
, dv_mode
[(regdeps
[depind
].dependency
)->mode
],
8034 (regdeps
[depind
].dependency
)->name
);
8035 if (regdeps
[depind
].specific
&& regdeps
[depind
].index
!= 0)
8036 fprintf (stderr
, " (%d)", regdeps
[depind
].index
);
8037 if (regdeps
[depind
].mem_offset
.hint
)
8038 fprintf (stderr
, " 0x%llx+0x%llx",
8039 regdeps
[depind
].mem_offset
.base
,
8040 regdeps
[depind
].mem_offset
.offset
);
8041 fprintf (stderr
, "\n");
8046 instruction_serialization ()
8050 fprintf (stderr
, " Instruction serialization\n");
8051 for (i
=0;i
< regdepslen
;i
++)
8052 if (regdeps
[i
].insn_srlz
== STATE_STOP
)
8053 regdeps
[i
].insn_srlz
= STATE_SRLZ
;
8057 data_serialization ()
8061 fprintf (stderr
, " Data serialization\n");
8062 while (i
< regdepslen
)
8064 if (regdeps
[i
].data_srlz
== STATE_STOP
8065 /* Note: as of 991210, all "other" dependencies are cleared by a
8066 data serialization. This might change with new tables */
8067 || (regdeps
[i
].dependency
)->semantics
== IA64_DVS_OTHER
)
8069 print_dependency ("Removing", i
);
8070 regdeps
[i
] = regdeps
[--regdepslen
];
8077 /* Insert stops and serializations as needed to avoid DVs */
8079 remove_marked_resource (rs
)
8082 switch (rs
->dependency
->semantics
)
8084 case IA64_DVS_SPECIFIC
:
8086 fprintf (stderr
, "Implementation-specific, assume worst case...\n");
8087 /* ...fall through... */
8088 case IA64_DVS_INSTR
:
8090 fprintf (stderr
, "Inserting instr serialization\n");
8091 if (rs
->insn_srlz
< STATE_STOP
)
8092 insn_group_break (1, 0, 0);
8093 if (rs
->insn_srlz
< STATE_SRLZ
)
8095 int oldqp
= CURR_SLOT
.qp_regno
;
8096 struct ia64_opcode
*oldidesc
= CURR_SLOT
.idesc
;
8097 /* Manually jam a srlz.i insn into the stream */
8098 CURR_SLOT
.qp_regno
= 0;
8099 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.i");
8100 instruction_serialization ();
8101 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
8102 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
8104 CURR_SLOT
.qp_regno
= oldqp
;
8105 CURR_SLOT
.idesc
= oldidesc
;
8107 insn_group_break (1, 0, 0);
8109 case IA64_DVS_OTHER
: /* as of rev2 (991220) of the DV tables, all
8110 "other" types of DV are eliminated
8111 by a data serialization */
8114 fprintf (stderr
, "Inserting data serialization\n");
8115 if (rs
->data_srlz
< STATE_STOP
)
8116 insn_group_break (1, 0, 0);
8118 int oldqp
= CURR_SLOT
.qp_regno
;
8119 struct ia64_opcode
*oldidesc
= CURR_SLOT
.idesc
;
8120 /* Manually jam a srlz.d insn into the stream */
8121 CURR_SLOT
.qp_regno
= 0;
8122 CURR_SLOT
.idesc
= ia64_find_opcode ("srlz.d");
8123 data_serialization ();
8124 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
8125 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
8127 CURR_SLOT
.qp_regno
= oldqp
;
8128 CURR_SLOT
.idesc
= oldidesc
;
8131 case IA64_DVS_IMPLIED
:
8132 case IA64_DVS_IMPLIEDF
:
8134 fprintf (stderr
, "Inserting stop\n");
8135 insn_group_break (1, 0, 0);
8142 /* Check the resources used by the given opcode against the current dependency
8145 The check is run once for each execution path encountered. In this case,
8146 a unique execution path is the sequence of instructions following a code
8147 entry point, e.g. the following has three execution paths, one starting
8148 at L0, one at L1, and one at L2.
8156 check_dependencies (idesc
)
8157 struct ia64_opcode
*idesc
;
8159 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
8163 /* Note that the number of marked resources may change within the
8164 loop if in auto mode. */
8166 while (i
< regdepslen
)
8168 struct rsrc
*rs
= ®deps
[i
];
8169 const struct ia64_dependency
*dep
= rs
->dependency
;
8174 if (dep
->semantics
== IA64_DVS_NONE
8175 || (chkind
= depends_on (rs
->depind
, idesc
)) == -1)
8180 note
= NOTE(opdeps
->chks
[chkind
]);
8182 /* Check this resource against each execution path seen thus far */
8183 for (path
=0;path
<= md
.path
;path
++)
8187 /* If the dependency wasn't on the path being checked, ignore it */
8188 if (rs
->path
< path
)
8191 /* If the QP for this insn implies a QP which has branched, don't
8192 bother checking. Ed. NOTE: I don't think this check is terribly
8193 useful; what's the point of generating code which will only be
8194 reached if its QP is zero?
8195 This code was specifically inserted to handle the following code,
8196 based on notes from Intel's DV checking code, where p1 implies p2.
8203 if (CURR_SLOT
.qp_regno
!= 0)
8207 for (implies
=0;implies
< qp_implieslen
;implies
++)
8209 if (qp_implies
[implies
].path
>= path
8210 && qp_implies
[implies
].p1
== CURR_SLOT
.qp_regno
8211 && qp_implies
[implies
].p2_branched
)
8221 if ((matchtype
= resources_match (rs
, idesc
, note
,
8222 CURR_SLOT
.qp_regno
, path
)) != 0)
8225 char pathmsg
[256] = "";
8226 char indexmsg
[256] = "";
8227 int certain
= (matchtype
== 1 && CURR_SLOT
.qp_regno
== 0);
8230 sprintf (pathmsg
, " when entry is at label '%s'",
8231 md
.entry_labels
[path
-1]);
8232 if (rs
->specific
&& rs
->index
!= 0)
8233 sprintf (indexmsg
, ", specific resource number is %d",
8235 sprintf (msg
, "Use of '%s' %s %s dependency '%s' (%s)%s%s",
8237 (certain
? "violates" : "may violate"),
8238 dv_mode
[dep
->mode
], dep
->name
,
8239 dv_sem
[dep
->semantics
],
8242 if (md
.explicit_mode
)
8244 as_warn ("%s", msg
);
8246 as_warn (_("Only the first path encountering the conflict "
8248 as_warn_where (rs
->file
, rs
->line
,
8249 _("This is the location of the "
8250 "conflicting usage"));
8251 /* Don't bother checking other paths, to avoid duplicating
8258 fprintf(stderr
, "%s @ %s:%d\n", msg
, rs
->file
, rs
->line
);
8260 remove_marked_resource (rs
);
8262 /* since the set of dependencies has changed, start over */
8263 /* FIXME -- since we're removing dvs as we go, we
8264 probably don't really need to start over... */
8277 /* register new dependencies based on the given opcode */
8279 mark_resources (idesc
)
8280 struct ia64_opcode
*idesc
;
8283 const struct ia64_opcode_dependency
*opdeps
= idesc
->dependencies
;
8284 int add_only_qp_reads
= 0;
8286 /* A conditional branch only uses its resources if it is taken; if it is
8287 taken, we stop following that path. The other branch types effectively
8288 *always* write their resources. If it's not taken, register only QP
8290 if (is_conditional_branch (idesc
) || is_interruption_or_rfi (idesc
))
8292 add_only_qp_reads
= 1;
8296 fprintf (stderr
, "Registering '%s' resource usage\n", idesc
->name
);
8298 for (i
=0;i
< opdeps
->nregs
;i
++)
8300 const struct ia64_dependency
*dep
;
8301 struct rsrc specs
[MAX_SPECS
];
8306 dep
= ia64_find_dependency (opdeps
->regs
[i
]);
8307 note
= NOTE(opdeps
->regs
[i
]);
8309 if (add_only_qp_reads
8310 && !(dep
->mode
== IA64_DV_WAR
8311 && (dep
->specifier
== IA64_RS_PR
8312 || dep
->specifier
== IA64_RS_PR63
)))
8315 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, md
.path
);
8318 if (md
.debug_dv
&& !count
)
8319 fprintf (stderr
, " No %s %s usage found (path %d)\n",
8320 dv_mode
[dep
->mode
], dep
->name
, md
.path
);
8325 mark_resource (idesc
, dep
, &specs
[count
],
8326 DEP(opdeps
->regs
[i
]), md
.path
);
8329 /* The execution path may affect register values, which may in turn
8330 affect which indirect-access resources are accessed. */
8331 switch (dep
->specifier
)
8343 for (path
=0;path
< md
.path
;path
++)
8345 count
= specify_resource (dep
, idesc
, DV_REG
, specs
, note
, path
);
8347 mark_resource (idesc
, dep
, &specs
[count
],
8348 DEP(opdeps
->regs
[i
]), path
);
8355 /* remove dependencies when they no longer apply */
8357 update_dependencies (idesc
)
8358 struct ia64_opcode
*idesc
;
8362 if (strcmp (idesc
->name
, "srlz.i") == 0)
8364 instruction_serialization ();
8366 else if (strcmp (idesc
->name
, "srlz.d") == 0)
8368 data_serialization ();
8370 else if (is_interruption_or_rfi (idesc
)
8371 || is_taken_branch (idesc
))
8373 /* although technically the taken branch doesn't clear dependencies
8374 which require a srlz.[id], we don't follow the branch; the next
8375 instruction is assumed to start with a clean slate */
8379 else if (is_conditional_branch (idesc
)
8380 && CURR_SLOT
.qp_regno
!= 0)
8382 int is_call
= strstr (idesc
->name
, ".call") != NULL
;
8384 for (i
=0;i
< qp_implieslen
;i
++)
8386 /* if the conditional branch's predicate is implied by the predicate
8387 in an existing dependency, remove that dependency */
8388 if (qp_implies
[i
].p2
== CURR_SLOT
.qp_regno
)
8391 /* note that this implied predicate takes a branch so that if
8392 a later insn generates a DV but its predicate implies this
8393 one, we can avoid the false DV warning */
8394 qp_implies
[i
].p2_branched
= 1;
8395 while (depind
< regdepslen
)
8397 if (regdeps
[depind
].qp_regno
== qp_implies
[i
].p1
)
8399 print_dependency ("Removing", depind
);
8400 regdeps
[depind
] = regdeps
[--regdepslen
];
8407 /* Any marked resources which have this same predicate should be
8408 cleared, provided that the QP hasn't been modified between the
8409 marking instruction and the branch.
8413 insn_group_break (0, CURR_SLOT
.qp_regno
, 1);
8418 while (i
< regdepslen
)
8420 if (regdeps
[i
].qp_regno
== CURR_SLOT
.qp_regno
8421 && regdeps
[i
].link_to_qp_branch
8422 && (regdeps
[i
].file
!= CURR_SLOT
.src_file
8423 || regdeps
[i
].line
!= CURR_SLOT
.src_line
))
8425 /* Treat like a taken branch */
8426 print_dependency ("Removing", i
);
8427 regdeps
[i
] = regdeps
[--regdepslen
];
8436 /* Examine the current instruction for dependency violations. */
8439 struct ia64_opcode
*idesc
;
8443 fprintf (stderr
, "Checking %s for violations (line %d, %d/%d)\n",
8444 idesc
->name
, CURR_SLOT
.src_line
,
8445 idesc
->dependencies
->nchks
,
8446 idesc
->dependencies
->nregs
);
8449 /* Look through the list of currently marked resources; if the current
8450 instruction has the dependency in its chks list which uses that resource,
8451 check against the specific resources used.
8453 check_dependencies (idesc
);
8456 Look up the instruction's regdeps (RAW writes, WAW writes, and WAR reads),
8457 then add them to the list of marked resources.
8459 mark_resources (idesc
);
8461 /* There are several types of dependency semantics, and each has its own
8462 requirements for being cleared
8464 Instruction serialization (insns separated by interruption, rfi, or
8465 writer + srlz.i + reader, all in separate groups) clears DVS_INSTR.
8467 Data serialization (instruction serialization, or writer + srlz.d +
8468 reader, where writer and srlz.d are in separate groups) clears
8469 DVS_DATA. (This also clears DVS_OTHER, but that is not guaranteed to
8470 always be the case).
8472 Instruction group break (groups separated by stop, taken branch,
8473 interruption or rfi) clears DVS_IMPLIED and DVS_IMPLIEDF.
8475 update_dependencies (idesc
);
8477 /* Sometimes, knowing a register value allows us to avoid giving a false DV
8478 warning. Keep track of as many as possible that are useful. */
8479 note_register_values (idesc
);
8481 /* We don't need or want this anymore. */
8482 md
.mem_offset
.hint
= 0;
8487 /* Translate one line of assembly. Pseudo ops and labels do not show
8493 char *saved_input_line_pointer
, *mnemonic
;
8494 const struct pseudo_opcode
*pdesc
;
8495 struct ia64_opcode
*idesc
;
8496 unsigned char qp_regno
;
8500 saved_input_line_pointer
= input_line_pointer
;
8501 input_line_pointer
= str
;
8503 /* extract the opcode (mnemonic): */
8505 mnemonic
= input_line_pointer
;
8506 ch
= get_symbol_end ();
8507 pdesc
= (struct pseudo_opcode
*) hash_find (md
.pseudo_hash
, mnemonic
);
8510 *input_line_pointer
= ch
;
8511 (*pdesc
->handler
) (pdesc
->arg
);
8515 /* find the instruction descriptor matching the arguments: */
8517 idesc
= ia64_find_opcode (mnemonic
);
8518 *input_line_pointer
= ch
;
8521 as_bad ("Unknown opcode `%s'", mnemonic
);
8525 idesc
= parse_operands (idesc
);
8529 /* Handle the dynamic ops we can handle now: */
8530 if (idesc
->type
== IA64_TYPE_DYN
)
8532 if (strcmp (idesc
->name
, "add") == 0)
8534 if (CURR_SLOT
.opnd
[2].X_op
== O_register
8535 && CURR_SLOT
.opnd
[2].X_add_number
< 4)
8539 ia64_free_opcode (idesc
);
8540 idesc
= ia64_find_opcode (mnemonic
);
8542 know (!idesc
->next
);
8545 else if (strcmp (idesc
->name
, "mov") == 0)
8547 enum ia64_opnd opnd1
, opnd2
;
8550 opnd1
= idesc
->operands
[0];
8551 opnd2
= idesc
->operands
[1];
8552 if (opnd1
== IA64_OPND_AR3
)
8554 else if (opnd2
== IA64_OPND_AR3
)
8558 if (CURR_SLOT
.opnd
[rop
].X_op
== O_register
8559 && ar_is_in_integer_unit (CURR_SLOT
.opnd
[rop
].X_add_number
))
8563 ia64_free_opcode (idesc
);
8564 idesc
= ia64_find_opcode (mnemonic
);
8565 while (idesc
!= NULL
8566 && (idesc
->operands
[0] != opnd1
8567 || idesc
->operands
[1] != opnd2
))
8568 idesc
= get_next_opcode (idesc
);
8573 if (md
.qp
.X_op
== O_register
)
8574 qp_regno
= md
.qp
.X_add_number
- REG_P
;
8576 flags
= idesc
->flags
;
8578 if ((flags
& IA64_OPCODE_FIRST
) != 0)
8579 insn_group_break (1, 0, 0);
8581 if ((flags
& IA64_OPCODE_NO_PRED
) != 0 && qp_regno
!= 0)
8583 as_bad ("`%s' cannot be predicated", idesc
->name
);
8587 /* build the instruction: */
8588 CURR_SLOT
.qp_regno
= qp_regno
;
8589 CURR_SLOT
.idesc
= idesc
;
8590 as_where (&CURR_SLOT
.src_file
, &CURR_SLOT
.src_line
);
8591 if (debug_type
== DEBUG_DWARF2
)
8592 dwarf2_where (&CURR_SLOT
.debug_line
);
8594 /* Add unwind entry, if there is one. */
8595 if (unwind
.current_entry
)
8597 CURR_SLOT
.unwind_record
= unwind
.current_entry
;
8598 unwind
.current_entry
= NULL
;
8601 /* check for dependency violations */
8605 md
.curr_slot
= (md
.curr_slot
+ 1) % NUM_SLOTS
;
8606 if (++md
.num_slots_in_use
>= NUM_SLOTS
)
8609 if ((flags
& IA64_OPCODE_LAST
) != 0)
8610 insn_group_break (1, 0, 0);
8612 md
.last_text_seg
= now_seg
;
8615 input_line_pointer
= saved_input_line_pointer
;
8618 /* Called when symbol NAME cannot be found in the symbol table.
8619 Should be used for dynamic valued symbols only. */
8621 md_undefined_symbol (name
)
8627 /* Called for any expression that can not be recognized. When the
8628 function is called, `input_line_pointer' will point to the start of
8634 enum pseudo_type pseudo_type
;
8639 switch (*input_line_pointer
)
8642 /* find what relocation pseudo-function we're dealing with: */
8644 ch
= *++input_line_pointer
;
8645 for (i
= 0; i
< NELEMS (pseudo_func
); ++i
)
8646 if (pseudo_func
[i
].name
&& pseudo_func
[i
].name
[0] == ch
)
8648 len
= strlen (pseudo_func
[i
].name
);
8649 if (strncmp (pseudo_func
[i
].name
+ 1,
8650 input_line_pointer
+ 1, len
- 1) == 0
8651 && !is_part_of_name (input_line_pointer
[len
]))
8653 input_line_pointer
+= len
;
8654 pseudo_type
= pseudo_func
[i
].type
;
8658 switch (pseudo_type
)
8660 case PSEUDO_FUNC_RELOC
:
8662 if (*input_line_pointer
!= '(')
8664 as_bad ("Expected '('");
8667 ++input_line_pointer
; /* skip '(' */
8669 if (*input_line_pointer
++ != ')')
8671 as_bad ("Missing ')'");
8674 if (e
->X_op
!= O_symbol
)
8676 if (e
->X_op
!= O_pseudo_fixup
)
8678 as_bad ("Not a symbolic expression");
8681 if (S_GET_VALUE (e
->X_op_symbol
) == FUNC_FPTR_RELATIVE
8682 && i
== FUNC_LT_RELATIVE
)
8683 i
= FUNC_LT_FPTR_RELATIVE
;
8686 as_bad ("Illegal combination of relocation functions");
8690 /* make sure gas doesn't get rid of local symbols that are used
8692 e
->X_op
= O_pseudo_fixup
;
8693 e
->X_op_symbol
= pseudo_func
[i
].u
.sym
;
8696 case PSEUDO_FUNC_CONST
:
8697 e
->X_op
= O_constant
;
8698 e
->X_add_number
= pseudo_func
[i
].u
.ival
;
8701 case PSEUDO_FUNC_REG
:
8702 e
->X_op
= O_register
;
8703 e
->X_add_number
= pseudo_func
[i
].u
.ival
;
8707 name
= input_line_pointer
- 1;
8709 as_bad ("Unknown pseudo function `%s'", name
);
8715 ++input_line_pointer
;
8717 if (*input_line_pointer
!= ']')
8719 as_bad ("Closing bracket misssing");
8724 if (e
->X_op
!= O_register
)
8725 as_bad ("Register expected as index");
8727 ++input_line_pointer
;
8738 ignore_rest_of_line ();
8741 /* Return 1 if it's OK to adjust a reloc by replacing the symbol with
8742 a section symbol plus some offset. For relocs involving @fptr(),
8743 directives we don't want such adjustments since we need to have the
8744 original symbol's name in the reloc. */
8746 ia64_fix_adjustable (fix
)
8749 /* Prevent all adjustments to global symbols */
8750 if (S_IS_EXTERN (fix
->fx_addsy
) || S_IS_WEAK (fix
->fx_addsy
))
8753 switch (fix
->fx_r_type
)
8755 case BFD_RELOC_IA64_FPTR64I
:
8756 case BFD_RELOC_IA64_FPTR32MSB
:
8757 case BFD_RELOC_IA64_FPTR32LSB
:
8758 case BFD_RELOC_IA64_FPTR64MSB
:
8759 case BFD_RELOC_IA64_FPTR64LSB
:
8760 case BFD_RELOC_IA64_LTOFF_FPTR22
:
8761 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
8771 ia64_force_relocation (fix
)
8774 switch (fix
->fx_r_type
)
8776 case BFD_RELOC_IA64_FPTR64I
:
8777 case BFD_RELOC_IA64_FPTR32MSB
:
8778 case BFD_RELOC_IA64_FPTR32LSB
:
8779 case BFD_RELOC_IA64_FPTR64MSB
:
8780 case BFD_RELOC_IA64_FPTR64LSB
:
8782 case BFD_RELOC_IA64_LTOFF22
:
8783 case BFD_RELOC_IA64_LTOFF64I
:
8784 case BFD_RELOC_IA64_LTOFF_FPTR22
:
8785 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
8786 case BFD_RELOC_IA64_PLTOFF22
:
8787 case BFD_RELOC_IA64_PLTOFF64I
:
8788 case BFD_RELOC_IA64_PLTOFF64MSB
:
8789 case BFD_RELOC_IA64_PLTOFF64LSB
:
8798 /* Decide from what point a pc-relative relocation is relative to,
8799 relative to the pc-relative fixup. Er, relatively speaking. */
8801 ia64_pcrel_from_section (fix
, sec
)
8805 unsigned long off
= fix
->fx_frag
->fr_address
+ fix
->fx_where
;
8807 if (bfd_get_section_flags (stdoutput
, sec
) & SEC_CODE
)
8813 /* This is called whenever some data item (not an instruction) needs a
8814 fixup. We pick the right reloc code depending on the byteorder
8815 currently in effect. */
8817 ia64_cons_fix_new (f
, where
, nbytes
, exp
)
8823 bfd_reloc_code_real_type code
;
8828 /* There are no reloc for 8 and 16 bit quantities, but we allow
8829 them here since they will work fine as long as the expression
8830 is fully defined at the end of the pass over the source file. */
8831 case 1: code
= BFD_RELOC_8
; break;
8832 case 2: code
= BFD_RELOC_16
; break;
8834 if (target_big_endian
)
8835 code
= BFD_RELOC_IA64_DIR32MSB
;
8837 code
= BFD_RELOC_IA64_DIR32LSB
;
8841 if (target_big_endian
)
8842 code
= BFD_RELOC_IA64_DIR64MSB
;
8844 code
= BFD_RELOC_IA64_DIR64LSB
;
8848 as_bad ("Unsupported fixup size %d", nbytes
);
8849 ignore_rest_of_line ();
8852 if (exp
->X_op
== O_pseudo_fixup
)
8855 exp
->X_op
= O_symbol
;
8856 code
= ia64_gen_real_reloc_type (exp
->X_op_symbol
, code
);
8858 fix
= fix_new_exp (f
, where
, nbytes
, exp
, 0, code
);
8859 /* We need to store the byte order in effect in case we're going
8860 to fix an 8 or 16 bit relocation (for which there no real
8861 relocs available). See md_apply_fix(). */
8862 fix
->tc_fix_data
.bigendian
= target_big_endian
;
8865 /* Return the actual relocation we wish to associate with the pseudo
8866 reloc described by SYM and R_TYPE. SYM should be one of the
8867 symbols in the pseudo_func array, or NULL. */
8869 static bfd_reloc_code_real_type
8870 ia64_gen_real_reloc_type (sym
, r_type
)
8872 bfd_reloc_code_real_type r_type
;
8874 bfd_reloc_code_real_type
new = 0;
8881 switch (S_GET_VALUE (sym
))
8883 case FUNC_FPTR_RELATIVE
:
8886 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_FPTR64I
; break;
8887 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_FPTR32MSB
; break;
8888 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_FPTR32LSB
; break;
8889 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_FPTR64MSB
; break;
8890 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_FPTR64LSB
; break;
8895 case FUNC_GP_RELATIVE
:
8898 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_GPREL22
; break;
8899 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_GPREL64I
; break;
8900 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_GPREL32MSB
; break;
8901 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_GPREL32LSB
; break;
8902 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_GPREL64MSB
; break;
8903 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_GPREL64LSB
; break;
8908 case FUNC_LT_RELATIVE
:
8911 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_LTOFF22
; break;
8912 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_LTOFF64I
; break;
8917 case FUNC_PC_RELATIVE
:
8920 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PCREL22
; break;
8921 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PCREL64I
; break;
8922 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_PCREL32MSB
; break;
8923 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_PCREL32LSB
; break;
8924 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PCREL64MSB
; break;
8925 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PCREL64LSB
; break;
8930 case FUNC_PLT_RELATIVE
:
8933 case BFD_RELOC_IA64_IMM22
: new = BFD_RELOC_IA64_PLTOFF22
; break;
8934 case BFD_RELOC_IA64_IMM64
: new = BFD_RELOC_IA64_PLTOFF64I
; break;
8935 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_PLTOFF64MSB
;break;
8936 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_PLTOFF64LSB
;break;
8941 case FUNC_SEC_RELATIVE
:
8944 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SECREL32MSB
;break;
8945 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SECREL32LSB
;break;
8946 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SECREL64MSB
;break;
8947 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SECREL64LSB
;break;
8952 case FUNC_SEG_RELATIVE
:
8955 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_SEGREL32MSB
;break;
8956 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_SEGREL32LSB
;break;
8957 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_SEGREL64MSB
;break;
8958 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_SEGREL64LSB
;break;
8963 case FUNC_LTV_RELATIVE
:
8966 case BFD_RELOC_IA64_DIR32MSB
: new = BFD_RELOC_IA64_LTV32MSB
; break;
8967 case BFD_RELOC_IA64_DIR32LSB
: new = BFD_RELOC_IA64_LTV32LSB
; break;
8968 case BFD_RELOC_IA64_DIR64MSB
: new = BFD_RELOC_IA64_LTV64MSB
; break;
8969 case BFD_RELOC_IA64_DIR64LSB
: new = BFD_RELOC_IA64_LTV64LSB
; break;
8974 case FUNC_LT_FPTR_RELATIVE
:
8977 case BFD_RELOC_IA64_IMM22
:
8978 new = BFD_RELOC_IA64_LTOFF_FPTR22
; break;
8979 case BFD_RELOC_IA64_IMM64
:
8980 new = BFD_RELOC_IA64_LTOFF_FPTR64I
; break;
8988 /* Hmmmm. Should this ever occur? */
8995 /* Here is where generate the appropriate reloc for pseudo relocation
8998 ia64_validate_fix (fix
)
9001 switch (fix
->fx_r_type
)
9003 case BFD_RELOC_IA64_FPTR64I
:
9004 case BFD_RELOC_IA64_FPTR32MSB
:
9005 case BFD_RELOC_IA64_FPTR64LSB
:
9006 case BFD_RELOC_IA64_LTOFF_FPTR22
:
9007 case BFD_RELOC_IA64_LTOFF_FPTR64I
:
9008 if (fix
->fx_offset
!= 0)
9009 as_bad_where (fix
->fx_file
, fix
->fx_line
,
9010 "No addend allowed in @fptr() relocation");
9020 fix_insn (fix
, odesc
, value
)
9022 const struct ia64_operand
*odesc
;
9025 bfd_vma insn
[3], t0
, t1
, control_bits
;
9030 slot
= fix
->fx_where
& 0x3;
9031 fixpos
= fix
->fx_frag
->fr_literal
+ (fix
->fx_where
- slot
);
9033 /* Bundles are always in little-endian byte order */
9034 t0
= bfd_getl64 (fixpos
);
9035 t1
= bfd_getl64 (fixpos
+ 8);
9036 control_bits
= t0
& 0x1f;
9037 insn
[0] = (t0
>> 5) & 0x1ffffffffffLL
;
9038 insn
[1] = ((t0
>> 46) & 0x3ffff) | ((t1
& 0x7fffff) << 18);
9039 insn
[2] = (t1
>> 23) & 0x1ffffffffffLL
;
9042 if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU64
)
9044 insn
[1] = (value
>> 22) & 0x1ffffffffffLL
;
9045 insn
[2] |= (((value
& 0x7f) << 13)
9046 | (((value
>> 7) & 0x1ff) << 27)
9047 | (((value
>> 16) & 0x1f) << 22)
9048 | (((value
>> 21) & 0x1) << 21)
9049 | (((value
>> 63) & 0x1) << 36));
9051 else if (odesc
- elf64_ia64_operands
== IA64_OPND_IMMU62
)
9053 if (value
& ~0x3fffffffffffffffULL
)
9054 err
= "integer operand out of range";
9055 insn
[1] = (value
>> 21) & 0x1ffffffffffLL
;
9056 insn
[2] |= (((value
& 0xfffff) << 6) | (((value
>> 20) & 0x1) << 36));
9058 else if (odesc
- elf64_ia64_operands
== IA64_OPND_TGT64
)
9061 insn
[1] = ((value
>> 20) & 0x7fffffffffLL
) << 2;
9062 insn
[2] |= ((((value
>> 59) & 0x1) << 36)
9063 | (((value
>> 0) & 0xfffff) << 13));
9066 err
= (*odesc
->insert
) (odesc
, value
, insn
+ slot
);
9069 as_bad_where (fix
->fx_file
, fix
->fx_line
, err
);
9071 t0
= control_bits
| (insn
[0] << 5) | (insn
[1] << 46);
9072 t1
= ((insn
[1] >> 18) & 0x7fffff) | (insn
[2] << 23);
9073 md_number_to_chars (fixpos
+ 0, t0
, 8);
9074 md_number_to_chars (fixpos
+ 8, t1
, 8);
9077 /* Attempt to simplify or even eliminate a fixup. The return value is
9078 ignored; perhaps it was once meaningful, but now it is historical.
9079 To indicate that a fixup has been eliminated, set FIXP->FX_DONE.
9081 If fixp->fx_addsy is non-NULL, we'll have to generate a reloc entry
9084 md_apply_fix3 (fix
, valuep
, seg
)
9090 valueT value
= *valuep
;
9093 fixpos
= fix
->fx_frag
->fr_literal
+ fix
->fx_where
;
9097 switch (fix
->fx_r_type
)
9099 case BFD_RELOC_IA64_DIR32MSB
:
9100 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL32MSB
;
9104 case BFD_RELOC_IA64_DIR32LSB
:
9105 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL32LSB
;
9109 case BFD_RELOC_IA64_DIR64MSB
:
9110 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL64MSB
;
9114 case BFD_RELOC_IA64_DIR64LSB
:
9115 fix
->fx_r_type
= BFD_RELOC_IA64_PCREL64LSB
;
9125 switch (fix
->fx_r_type
)
9128 as_bad_where (fix
->fx_file
, fix
->fx_line
,
9129 "%s must have a constant value",
9130 elf64_ia64_operands
[fix
->tc_fix_data
.opnd
].desc
);
9137 /* ??? This is a hack copied from tc-i386.c to make PCREL relocs
9138 work. There should be a better way to handle this. */
9140 fix
->fx_offset
+= fix
->fx_where
+ fix
->fx_frag
->fr_address
;
9142 else if (fix
->tc_fix_data
.opnd
== IA64_OPND_NIL
)
9144 if (fix
->tc_fix_data
.bigendian
)
9145 number_to_chars_bigendian (fixpos
, value
, fix
->fx_size
);
9147 number_to_chars_littleendian (fixpos
, value
, fix
->fx_size
);
9153 fix_insn (fix
, elf64_ia64_operands
+ fix
->tc_fix_data
.opnd
, value
);
9160 /* Generate the BFD reloc to be stuck in the object file from the
9161 fixup used internally in the assembler. */
9163 tc_gen_reloc (sec
, fixp
)
9169 reloc
= xmalloc (sizeof (*reloc
));
9170 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
9171 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
9172 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
9173 reloc
->addend
= fixp
->fx_offset
;
9174 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
9178 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
9179 "Cannot represent %s relocation in object file",
9180 bfd_get_reloc_code_name (fixp
->fx_r_type
));
9185 /* Turn a string in input_line_pointer into a floating point constant
9186 of type TYPE, and store the appropriate bytes in *LIT. The number
9187 of LITTLENUMS emitted is stored in *SIZE. An error message is
9188 returned, or NULL on OK. */
9190 #define MAX_LITTLENUMS 5
9193 md_atof (type
, lit
, size
)
9198 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
9199 LITTLENUM_TYPE
*word
;
9229 return "Bad call to MD_ATOF()";
9231 t
= atof_ieee (input_line_pointer
, type
, words
);
9233 input_line_pointer
= t
;
9234 *size
= prec
* sizeof (LITTLENUM_TYPE
);
9236 for (word
= words
+ prec
- 1; prec
--;)
9238 md_number_to_chars (lit
, (long) (*word
--), sizeof (LITTLENUM_TYPE
));
9239 lit
+= sizeof (LITTLENUM_TYPE
);
9244 /* Round up a section's size to the appropriate boundary. */
9246 md_section_align (seg
, size
)
9250 int align
= bfd_get_section_alignment (stdoutput
, seg
);
9251 valueT mask
= ((valueT
)1 << align
) - 1;
9253 return (size
+ mask
) & ~mask
;
9256 /* Handle ia64 specific semantics of the align directive. */
9259 ia64_md_do_align (n
, fill
, len
, max
)
9265 /* Fill any pending bundle with nops. */
9266 if (bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
)
9267 ia64_flush_insns ();
9269 /* When we align code in a text section, emit a bundle of 3 nops instead of
9270 zero bytes. We can only do this if a multiple of 16 bytes was requested.
9271 N is log base 2 of the requested alignment. */
9273 && bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
9276 /* Use mfi bundle of nops with no stop bits. */
9277 static const unsigned char be_nop
[]
9278 = { 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
9279 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c};
9280 static const unsigned char le_nop
[]
9281 = { 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
9282 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00};
9284 /* Make sure we are on a 16-byte boundary, in case someone has been
9285 putting data into a text section. */
9286 frag_align (4, 0, 0);
9288 if (target_big_endian
)
9289 frag_align_pattern (n
, be_nop
, 16, max
);
9291 frag_align_pattern (n
, le_nop
, 16, max
);