/* tc-ia64.c -- Assembler for the HP/Intel IA-64 architecture.
- Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
#include "elf/ia64.h"
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
#define NELEMS(a) ((int) (sizeof (a)/sizeof ((a)[0])))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
static struct hash_control *secalias_hash;
static struct hash_control *secalias_name_hash;
+/* List of chars besides those in app.c:symbol_chars that can start an
+ operand. Used to prevent the scrubber eating vital white-space. */
+const char ia64_symbol_chars[] = "@?";
+
/* Characters which always start a comment. */
const char comment_chars[] = "";
that are predicatable. */
expressionS qp;
+ /* Optimize for which CPU. */
+ enum
+ {
+ itanium1,
+ itanium2
+ } tune;
+
+ /* What to do when hint.b is used. */
+ enum
+ {
+ hint_b_error,
+ hint_b_warning,
+ hint_b_ok
+ } hint_b;
+
unsigned int
manual_bundling : 1,
debug_dv: 1,
}
md;
+/* These are not const, because they are modified to MMI for non-itanium1
+ targets below. */
+/* MFI bundle of nops. */
+static unsigned char le_nop[16] =
+{
+ 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00
+};
+/* MFI bundle of nops with stop-bit. */
+static unsigned char le_nop_stop[16] =
+{
+ 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00
+};
+
/* application registers: */
#define AR_K0 0
unsigned known:1;
int path;
valueT value;
-} gr_values[128] = {{ 1, 0, 0 }};
+} gr_values[128] = {
+ {
+ 1,
+#ifdef INT_MAX
+ INT_MAX,
+#else
+ (((1 << (8 * sizeof(gr_values->path) - 2)) - 1) << 1) + 1,
+#endif
+ 0
+ }
+};
/* Remember the alignment frag. */
static fragS *align_frag;
static void dot_psr PARAMS ((int));
static void dot_alias PARAMS ((int));
static void dot_ln PARAMS ((int));
-static char *parse_section_name PARAMS ((void));
+static void cross_section PARAMS ((int ref, void (*cons) PARAMS((int)), int ua));
static void dot_xdata PARAMS ((int));
static void stmt_float_cons PARAMS ((int));
static void stmt_cons_ua PARAMS ((int));
}
/* Output COUNT bytes to a memory location. */
-static unsigned char *vbyte_mem_ptr = NULL;
+static char *vbyte_mem_ptr = NULL;
void
output_vbyte_mem (count, ptr, comment)
unsigned long imask_size;
{
imask[0] = UNW_P4;
- (*f) (imask_size, imask, NULL);
+ (*f) (imask_size, (char *) imask, NULL);
}
static void
};
static void
-start_unwind_section (const segT text_seg, int sec_index, int linkonce_empty)
+start_unwind_section (const segT text_seg, int sec_index)
{
/*
Use a slightly ugly scheme to derive the unwind section names from
prefix = special_linkonce_name [sec_index - SPECIAL_SECTION_UNWIND];
suffix += sizeof (".gnu.linkonce.t.") - 1;
}
- else if (linkonce_empty)
- return;
prefix_len = strlen (prefix);
suffix_len = strlen (suffix);
expressionS exp;
bfd_reloc_code_real_type reloc;
- start_unwind_section (text_seg, SPECIAL_SECTION_UNWIND_INFO, 0);
+ start_unwind_section (text_seg, SPECIAL_SECTION_UNWIND_INFO);
/* Make sure the section has 4 byte alignment for ILP32 and
8 byte alignment for LP64. */
unwind.personality_routine = 0;
}
}
- else
- start_unwind_section (text_seg, SPECIAL_SECTION_UNWIND_INFO, 1);
free_saved_prologue_counts ();
unwind.list = unwind.tail = unwind.current_entry = NULL;
dot_spillreg (dummy)
int dummy ATTRIBUTE_UNUSED;
{
- int sep, ab, xy, reg, treg;
+ int sep;
+ unsigned int ab, xy, reg, treg;
expressionS e1, e2;
if (!in_procedure ("spillreg"))
int psprel;
{
expressionS e1, e2;
- int sep, ab, reg;
+ int sep;
+ unsigned int ab, reg;
if (!in_procedure ("spillmem"))
return;
dot_spillreg_p (dummy)
int dummy ATTRIBUTE_UNUSED;
{
- int sep, ab, xy, reg, treg;
+ int sep;
+ unsigned int ab, xy, reg, treg;
expressionS e1, e2, e3;
unsigned int qp;
int psprel;
{
expressionS e1, e2, e3;
- int sep, ab, reg;
+ int sep;
+ unsigned int ab, reg;
unsigned int qp;
if (!in_procedure ("spillmem.p"))
int dummy ATTRIBUTE_UNUSED;
{
expressionS e;
- unsigned char *ptr;
+ char *ptr;
int bytes_per_address;
long where;
segT saved_seg;
subseg_set (md.last_text_seg, 0);
proc_end = expr_build_dot ();
- start_unwind_section (saved_seg, SPECIAL_SECTION_UNWIND, 0);
+ start_unwind_section (saved_seg, SPECIAL_SECTION_UNWIND);
/* Make sure that section has 4 byte alignment for ILP32 and
8 byte alignment for LP64. */
bytes_per_address);
}
- else
- start_unwind_section (saved_seg, SPECIAL_SECTION_UNWIND, 1);
-
subseg_set (saved_seg, saved_subseg);
if (unwind.proc_start)
for (dr = md.dynreg[type]; dr && dr->num_regs; dr = dr->next)
{
hash_delete (md.dynreg_hash, dr->name);
+ /* FIXME: Free dr->name. */
dr->num_regs = 0;
}
{
start = input_line_pointer;
ch = get_symbol_end ();
+ len = strlen (ia64_canonicalize_symbol_name (start));
*input_line_pointer = ch;
- len = (input_line_pointer - start);
SKIP_WHITESPACE ();
if (*input_line_pointer != '[')
break;
}
- name = obstack_alloc (¬es, len + 1);
- memcpy (name, start, len);
- name[len] = '\0';
-
if (!*drpp)
{
*drpp = obstack_alloc (¬es, sizeof (*dr));
memset (*drpp, 0, sizeof (*dr));
}
+ name = obstack_alloc (¬es, len + 1);
+ memcpy (name, start, len);
+ name[len] = '\0';
+
dr = *drpp;
dr->name = name;
dr->num_regs = num_regs;
if (hash_insert (md.dynreg_hash, name, dr))
{
as_bad ("Attempt to redefine register set `%s'", name);
+ obstack_free (¬es, name);
goto err;
}
demand_empty_rest_of_line ();
}
-static char *
-parse_section_name ()
+static void
+cross_section (ref, cons, ua)
+ int ref;
+ void (*cons) PARAMS((int));
+ int ua;
{
- char *name;
- int len;
+ char *start, *end;
+ int saved_auto_align;
+ unsigned int section_count;
SKIP_WHITESPACE ();
- if (*input_line_pointer == '"')
+ start = input_line_pointer;
+ if (*start == '"')
+ {
+ int len;
+ char *name;
+
name = demand_copy_C_string (&len);
+ obstack_free(¬es, name);
+ if (!name)
+ {
+ ignore_rest_of_line ();
+ return;
+ }
+ }
else
{
- char *start = input_line_pointer;
char c = get_symbol_end ();
if (input_line_pointer == start)
{
as_bad ("Missing section name");
ignore_rest_of_line ();
- return 0;
+ return;
}
- name = obstack_copy (¬es, start, input_line_pointer - start + 1);
*input_line_pointer = c;
}
- if (!name)
- {
- ignore_rest_of_line ();
- return 0;
- }
+ end = input_line_pointer;
SKIP_WHITESPACE ();
if (*input_line_pointer != ',')
{
as_bad ("Comma expected after section name");
ignore_rest_of_line ();
- return 0;
+ return;
}
- ++input_line_pointer; /* skip comma */
- return name;
+ *end = '\0';
+ end = input_line_pointer + 1; /* skip comma */
+ input_line_pointer = start;
+ md.keep_pending_output = 1;
+ section_count = bfd_count_sections(stdoutput);
+ obj_elf_section (0);
+ if (section_count != bfd_count_sections(stdoutput))
+ as_warn ("Creating sections with .xdataN/.xrealN/.xstringZ is deprecated.");
+ input_line_pointer = end;
+ saved_auto_align = md.auto_align;
+ if (ua)
+ md.auto_align = 0;
+ (*cons) (ref);
+ if (ua)
+ md.auto_align = saved_auto_align;
+ obj_elf_previous (0);
+ md.keep_pending_output = 0;
}
static void
dot_xdata (size)
int size;
{
- char *name = parse_section_name ();
- if (!name)
- return;
-
- md.keep_pending_output = 1;
- set_section (name);
- cons (size);
- obj_elf_previous (0);
- md.keep_pending_output = 0;
+ cross_section (size, cons, 0);
}
/* Why doesn't float_cons() call md_cons_align() the way cons() does? */
dot_xfloat_cons (kind)
int kind;
{
- char *name = parse_section_name ();
- if (!name)
- return;
-
- md.keep_pending_output = 1;
- set_section (name);
- stmt_float_cons (kind);
- obj_elf_previous (0);
- md.keep_pending_output = 0;
+ cross_section (kind, stmt_float_cons, 0);
}
static void
dot_xstringer (zero)
int zero;
{
- char *name = parse_section_name ();
- if (!name)
- return;
-
- md.keep_pending_output = 1;
- set_section (name);
- stringer (zero);
- obj_elf_previous (0);
- md.keep_pending_output = 0;
+ cross_section (zero, stringer, 0);
}
static void
dot_xdata_ua (size)
int size;
{
- int saved_auto_align = md.auto_align;
- char *name = parse_section_name ();
- if (!name)
- return;
-
- md.keep_pending_output = 1;
- set_section (name);
- md.auto_align = 0;
- cons (size);
- md.auto_align = saved_auto_align;
- obj_elf_previous (0);
- md.keep_pending_output = 0;
+ cross_section (size, cons, 1);
}
static void
dot_xfloat_cons_ua (kind)
int kind;
{
- int saved_auto_align = md.auto_align;
- char *name = parse_section_name ();
- if (!name)
- return;
-
- md.keep_pending_output = 1;
- set_section (name);
- md.auto_align = 0;
- stmt_float_cons (kind);
- md.auto_align = saved_auto_align;
- obj_elf_previous (0);
- md.keep_pending_output = 0;
+ cross_section (kind, float_cons, 1);
}
/* .reg.val <regname>,value */
{
valueT value = get_absolute_expression ();
int regno = reg.X_add_number;
- if (regno < REG_GR || regno > REG_GR + 128)
+ if (regno <= REG_GR || regno > REG_GR + 127)
as_warn (_("Register value annotation ignored"));
else
{
SKIP_WHITESPACE ();
while (1)
{
- valueT bit = 1;
+ valueT bits = 1;
int regno;
-
- if (TOUPPER (*input_line_pointer) != 'P'
- || (regno = atoi (++input_line_pointer)) < 0
- || regno > 63)
- {
- as_bad (_("Predicate register expected"));
- ignore_rest_of_line ();
- return;
- }
- while (ISDIGIT (*input_line_pointer))
- ++input_line_pointer;
- if (p1 == -1)
- p1 = regno;
- else if (p2 == -1)
- p2 = regno;
- bit <<= regno;
- if (mask & bit)
- as_warn (_("Duplicate predicate register ignored"));
- mask |= bit;
- count++;
- /* See if it's a range. */
- if (*input_line_pointer == '-')
- {
- valueT stop = 1;
- ++input_line_pointer;
-
- if (TOUPPER (*input_line_pointer) != 'P'
- || (regno = atoi (++input_line_pointer)) < 0
- || regno > 63)
- {
- as_bad (_("Predicate register expected"));
- ignore_rest_of_line ();
- return;
- }
- while (ISDIGIT (*input_line_pointer))
- ++input_line_pointer;
- stop <<= regno;
- if (bit >= stop)
+ expressionS pr, *pr1, *pr2;
+
+ expression (&pr);
+ if (pr.X_op == O_register
+ && pr.X_add_number >= REG_P
+ && pr.X_add_number <= REG_P + 63)
+ {
+ regno = pr.X_add_number - REG_P;
+ bits <<= regno;
+ count++;
+ if (p1 == -1)
+ p1 = regno;
+ else if (p2 == -1)
+ p2 = regno;
+ }
+ else if (type != 'i'
+ && pr.X_op == O_subtract
+ && (pr1 = symbol_get_value_expression (pr.X_add_symbol))
+ && pr1->X_op == O_register
+ && pr1->X_add_number >= REG_P
+ && pr1->X_add_number <= REG_P + 63
+ && (pr2 = symbol_get_value_expression (pr.X_op_symbol))
+ && pr2->X_op == O_register
+ && pr2->X_add_number >= REG_P
+ && pr2->X_add_number <= REG_P + 63)
+ {
+ /* It's a range. */
+ int stop;
+
+ regno = pr1->X_add_number - REG_P;
+ stop = pr2->X_add_number - REG_P;
+ if (regno >= stop)
{
as_bad (_("Bad register range"));
ignore_rest_of_line ();
return;
}
- while (bit < stop)
- {
- bit <<= 1;
- mask |= bit;
- count++;
- }
- SKIP_WHITESPACE ();
+ bits = ((bits << stop) << 1) - (bits << regno);
+ count += stop - regno + 1;
+ }
+ else
+ {
+ as_bad (_("Predicate register expected"));
+ ignore_rest_of_line ();
+ return;
}
+ if (mask & bits)
+ as_warn (_("Duplicate predicate register ignored"));
+ mask |= bits;
if (*input_line_pointer != ',')
break;
++input_line_pointer;
{
int i = 0, highest_unmatched_operand, num_operands = 0, num_outputs = 0;
int error_pos, out_of_range_pos, curr_out_of_range_pos, sep = 0;
+ int reg1, reg2;
+ char reg_class;
enum ia64_opnd expected_operand = IA64_OPND_NIL;
enum operand_match_result result;
char mnemonic[129];
as_bad ("Operand mismatch");
return 0;
}
+
+ /* Check that the instruction doesn't use
+ - r0, f0, or f1 as output operands
+ - the same predicate twice as output operands
+ - r0 as address of a base update load or store
+ - the same GR as output and address of a base update load
+ - two even- or two odd-numbered FRs as output operands of a floating
+ point parallel load.
+ At most two (conflicting) output (or output-like) operands can exist,
+ (floating point parallel loads have three outputs, but the base register,
+ if updated, cannot conflict with the actual outputs). */
+ reg2 = reg1 = -1;
+ for (i = 0; i < num_operands; ++i)
+ {
+ int regno = 0;
+
+ reg_class = 0;
+ switch (idesc->operands[i])
+ {
+ case IA64_OPND_R1:
+ case IA64_OPND_R2:
+ case IA64_OPND_R3:
+ if (i < num_outputs)
+ {
+ if (CURR_SLOT.opnd[i].X_add_number == REG_GR)
+ reg_class = 'r';
+ else if (reg1 < 0)
+ reg1 = CURR_SLOT.opnd[i].X_add_number;
+ else if (reg2 < 0)
+ reg2 = CURR_SLOT.opnd[i].X_add_number;
+ }
+ break;
+ case IA64_OPND_P1:
+ case IA64_OPND_P2:
+ if (i < num_outputs)
+ {
+ if (reg1 < 0)
+ reg1 = CURR_SLOT.opnd[i].X_add_number;
+ else if (reg2 < 0)
+ reg2 = CURR_SLOT.opnd[i].X_add_number;
+ }
+ break;
+ case IA64_OPND_F1:
+ case IA64_OPND_F2:
+ case IA64_OPND_F3:
+ case IA64_OPND_F4:
+ if (i < num_outputs)
+ {
+ if (CURR_SLOT.opnd[i].X_add_number >= REG_FR
+ && CURR_SLOT.opnd[i].X_add_number <= REG_FR + 1)
+ {
+ reg_class = 'f';
+ regno = CURR_SLOT.opnd[i].X_add_number - REG_FR;
+ }
+ else if (reg1 < 0)
+ reg1 = CURR_SLOT.opnd[i].X_add_number;
+ else if (reg2 < 0)
+ reg2 = CURR_SLOT.opnd[i].X_add_number;
+ }
+ break;
+ case IA64_OPND_MR3:
+ if (idesc->flags & IA64_OPCODE_POSTINC)
+ {
+ if (CURR_SLOT.opnd[i].X_add_number == REG_GR)
+ reg_class = 'm';
+ else if (reg1 < 0)
+ reg1 = CURR_SLOT.opnd[i].X_add_number;
+ else if (reg2 < 0)
+ reg2 = CURR_SLOT.opnd[i].X_add_number;
+ }
+ break;
+ default:
+ break;
+ }
+ switch (reg_class)
+ {
+ case 0:
+ break;
+ default:
+ as_warn ("Invalid use of `%c%d' as output operand", reg_class, regno);
+ break;
+ case 'm':
+ as_warn ("Invalid use of `r%d' as base update address operand", regno);
+ break;
+ }
+ }
+ if (reg1 == reg2)
+ {
+ if (reg1 >= REG_GR && reg1 <= REG_GR + 127)
+ {
+ reg1 -= REG_GR;
+ reg_class = 'r';
+ }
+ else if (reg1 >= REG_P && reg1 <= REG_P + 63)
+ {
+ reg1 -= REG_P;
+ reg_class = 'p';
+ }
+ else if (reg1 >= REG_FR && reg1 <= REG_FR + 127)
+ {
+ reg1 -= REG_FR;
+ reg_class = 'f';
+ }
+ else
+ reg_class = 0;
+ if (reg_class)
+ as_warn ("Invalid duplicate use of `%c%d'", reg_class, reg1);
+ }
+ else if (((reg1 >= REG_FR && reg1 <= REG_FR + 31
+ && reg2 >= REG_FR && reg2 <= REG_FR + 31)
+ || (reg1 >= REG_FR + 32 && reg1 <= REG_FR + 127
+ && reg2 >= REG_FR + 32 && reg2 <= REG_FR + 127))
+ && ! ((reg1 ^ reg2) & 1))
+ as_warn ("Invalid simultaneous use of `f%d' and `f%d'",
+ reg1 - REG_FR, reg2 - REG_FR);
+ else if ((reg1 >= REG_FR && reg1 <= REG_FR + 31
+ && reg2 >= REG_FR + 32 && reg2 <= REG_FR + 127)
+ || (reg1 >= REG_FR + 32 && reg1 <= REG_FR + 127
+ && reg2 >= REG_FR && reg2 <= REG_FR + 31))
+ as_warn ("Dangerous simultaneous use of `f%d' and `f%d'",
+ reg1 - REG_FR, reg2 - REG_FR);
return idesc;
}
{
const struct ia64_operand *odesc, *o2desc;
struct ia64_opcode *idesc = slot->idesc;
- bfd_signed_vma insn, val;
+ bfd_vma insn;
+ bfd_signed_vma val;
const char *err;
int i;
bfd_vma insn[3] = { -1, -1, -1 };
struct ia64_opcode *idesc;
int end_of_insn_group = 0, user_template = -1;
- int n, i, j, first, curr;
+ int n, i, j, first, curr, last_slot;
unw_rec_list *ptr, *last_ptr, *end_ptr;
bfd_vma t0 = 0, t1 = 0;
struct label_fix *lfix;
curr = first;
idesc = md.slot[curr].idesc;
end_of_insn_group = 0;
+ last_slot = -1;
for (i = 0; i < 3 && md.num_slots_in_use > 0; ++i)
{
/* If we have unwind records, we may need to update some now. */
break; /* Need to start a new bundle. */
}
+ /* If this instruction specifies a template, then it must be the first
+ instruction of a bundle. */
+ if (curr != first && md.slot[curr].user_template >= 0)
+ break;
+
if (idesc->flags & IA64_OPCODE_SLOT2)
{
if (manual_bundling && !manual_bundling_off)
enum ia64_opnd opnd1, opnd2;
if ((strcmp (idesc->name, "nop") == 0)
- || (strcmp (idesc->name, "hint") == 0)
|| (strcmp (idesc->name, "break") == 0))
insn_unit = required_unit;
+ else if (strcmp (idesc->name, "hint") == 0)
+ {
+ insn_unit = required_unit;
+ if (required_unit == IA64_UNIT_B)
+ {
+ switch (md.hint_b)
+ {
+ case hint_b_ok:
+ break;
+ case hint_b_warning:
+ as_warn ("hint in B unit may be treated as nop");
+ break;
+ case hint_b_error:
+ /* When manual bundling is off and there is no
+ user template, we choose a different unit so
+ that hint won't go into the current slot. We
+ will fill the current bundle with nops and
+ try to put hint into the next bundle. */
+ if (!manual_bundling && user_template < 0)
+ insn_unit = IA64_UNIT_I;
+ else
+ as_bad ("hint in B unit can't be used");
+ break;
+ }
+ }
+ }
else if (strcmp (idesc->name, "chk.s") == 0
|| strcmp (idesc->name, "mov") == 0)
{
}
if (insn_unit != required_unit)
- {
- if (required_unit == IA64_UNIT_L
- && insn_unit == IA64_UNIT_I
- && !(idesc->flags & IA64_OPCODE_X_IN_MLX))
- {
- /* we got ourselves an MLX template but the current
- instruction isn't an X-unit, or an I-unit instruction
- that can go into the X slot of an MLX template. Duh. */
- if (md.num_slots_in_use >= NUM_SLOTS)
- {
- as_bad_where (md.slot[curr].src_file,
- md.slot[curr].src_line,
- "`%s' can't go in X slot of "
- "MLX template", idesc->name);
- /* drop this insn so we don't livelock: */
- --md.num_slots_in_use;
- }
- break;
- }
- continue; /* try next slot */
- }
+ continue; /* Try next slot. */
if (debug_type == DEBUG_DWARF2 || md.slot[curr].loc_directive_seen)
{
++i;
}
--md.num_slots_in_use;
+ last_slot = i;
/* now is a good time to fix up the labels for this insn: */
for (lfix = md.slot[curr].label_fixups; lfix; lfix = lfix->next)
{
if (md.num_slots_in_use > 0)
{
- as_bad_where (md.slot[curr].src_file, md.slot[curr].src_line,
- "`%s' does not fit into %s template",
- idesc->name, ia64_templ_desc[template].name);
- --md.num_slots_in_use;
+ if (last_slot >= 2)
+ as_bad_where (md.slot[curr].src_file, md.slot[curr].src_line,
+ "`%s' does not fit into bundle", idesc->name);
+ else if (last_slot < 0)
+ {
+ as_bad_where (md.slot[curr].src_file, md.slot[curr].src_line,
+ "`%s' does not fit into %s template",
+ idesc->name, ia64_templ_desc[template].name);
+ /* Drop first insn so we don't livelock. */
+ --md.num_slots_in_use;
+ know (curr == first);
+ ia64_free_opcode (md.slot[curr].idesc);
+ memset (md.slot + curr, 0, sizeof (md.slot[curr]));
+ md.slot[curr].user_template = -1;
+ }
+ else
+ {
+ const char *where;
+
+ if (template == 2)
+ where = "X slot";
+ else if (last_slot == 0)
+ where = "slots 2 or 3";
+ else
+ where = "slot 3";
+ as_bad_where (md.slot[curr].src_file, md.slot[curr].src_line,
+ "`%s' can't go in %s of %s template",
+ idesc->name, where, ia64_templ_desc[template].name);
+ }
}
else
as_bad_where (md.slot[curr].src_file, md.slot[curr].src_line,
else
return 0;
}
+ else if (strncmp (arg, "hint.b=", 7) == 0)
+ {
+ arg += 7;
+ if (strcmp (arg, "ok") == 0)
+ md.hint_b = hint_b_ok;
+ else if (strcmp (arg, "warning") == 0)
+ md.hint_b = hint_b_warning;
+ else if (strcmp (arg, "error") == 0)
+ md.hint_b = hint_b_error;
+ else
+ return 0;
+ }
+ else if (strncmp (arg, "tune=", 5) == 0)
+ {
+ arg += 5;
+ if (strcmp (arg, "itanium1") == 0)
+ md.tune = itanium1;
+ else if (strcmp (arg, "itanium2") == 0)
+ md.tune = itanium2;
+ else
+ return 0;
+ }
else
return 0;
break;
{
md.default_explicit_mode = 0;
}
+ else if (strcmp (arg, "none") == 0)
+ {
+ md.detect_dv = 0;
+ }
else if (strcmp (arg, "debug") == 0)
{
md.debug_dv = 1;
md.default_explicit_mode = 1;
md.debug_dv = 1;
}
+ else if (strcmp (arg, "debugn") == 0)
+ {
+ md.debug_dv = 1;
+ md.detect_dv = 0;
+ }
else
{
as_bad (_("Unrecognized option '-x%s'"), arg);
EF_IA_64_NOFUNCDESC_CONS_GP)\n\
-milp32|-milp64|-mlp64|-mp64 select data model (default -mlp64)\n\
-mle | -mbe select little- or big-endian byte order (default -mle)\n\
+ -mtune=[itanium1|itanium2]\n\
+ tune for a specific CPU (default -mtune=itanium2)\n\
-munwind-check=[warning|error]\n\
unwind directive check (default -munwind-check=warning)\n\
- -x | -xexplicit turn on dependency violation checking (default)\n\
- -xauto automagically remove dependency violations\n\
- -xdebug debug dependency violation checker\n"),
+ -mhint.b=[ok|warning|error]\n\
+ hint.b check (default -mhint.b=error)\n\
+ -x | -xexplicit turn on dependency violation checking\n\
+ -xauto automagically remove dependency violations (default)\n\
+ -xnone turn off dependency violation checking\n\
+ -xdebug debug dependency violation checker\n\
+ -xdebugn debug dependency violation checker but turn off\n\
+ dependency violation checking\n\
+ -xdebugx debug dependency violation checker and turn on\n\
+ dependency violation checking\n"),
stream);
}
static inline int
extra_goodness (int templ, int slot)
{
- if (slot == 1 && match (templ, IA64_TYPE_F, slot))
- return 2;
- if (slot == 2 && match (templ, IA64_TYPE_B, slot))
- return 1;
- return 0;
+ switch (md.tune)
+ {
+ case itanium1:
+ if (slot == 1 && match (templ, IA64_TYPE_F, slot))
+ return 2;
+ else if (slot == 2 && match (templ, IA64_TYPE_B, slot))
+ return 1;
+ else
+ return 0;
+ break;
+ case itanium2:
+ if (match (templ, IA64_TYPE_M, slot)
+ || match (templ, IA64_TYPE_I, slot))
+ /* Favor M- and I-unit NOPs. We definitely want to avoid
+ F-unit and B-unit may cause split-issue or less-than-optimal
+ branch-prediction. */
+ return 2;
+ else
+ return 0;
+ break;
+ default:
+ abort ();
+ return 0;
+ }
}
/* This function is called once, at assembler startup time. It sets
symbol_new (".<iplt>", undefined_section, FUNC_IPLT_RELOC,
&zero_address_frag);
+ if (md.tune != itanium1)
+ {
+ /* Convert MFI NOPs bundles into MMI NOPs bundles. */
+ le_nop[0] = 0x8;
+ le_nop_stop[0] = 0x9;
+ }
+
/* Compute the table of best templates. We compute goodness as a
- base 4 value, in which each match counts for 3, each F counts
- for 2, each B counts for 1. This should maximize the number of
- F and B nops in the chosen bundles, which is good because these
- pipelines are least likely to be overcommitted. */
+ base 4 value, in which each match counts for 3. Match-failures
+ result in NOPs and we use extra_goodness() to pick the execution
+ units that are best suited for issuing the NOP. */
for (i = 0; i < IA64_NUM_TYPES; ++i)
for (j = 0; j < IA64_NUM_TYPES; ++j)
for (k = 0; k < IA64_NUM_TYPES; ++k)
char **argv ATTRIBUTE_UNUSED;
{
md.flags = MD_FLAGS_DEFAULT;
+ md.detect_dv = 1;
/* FIXME: We should change it to unwind_check_error someday. */
md.unwind_check = unwind_check_warning;
+ md.hint_b = hint_b_error;
+ md.tune = itanium2;
}
/* Return a string for the target object file format. */
if (input_line_pointer[0] == ';' && input_line_pointer[-1] == ';')
{
if (md.detect_dv && !md.explicit_mode)
- as_warn (_("Explicit stops are ignored in auto mode"));
+ {
+ static int warned;
+
+ if (!warned)
+ {
+ warned = 1;
+ as_warn (_("Explicit stops are ignored in auto mode"));
+ }
+ }
else
insn_group_break (1, 0, 0);
}
{
struct const_desc *cdesc;
struct dynreg *dr = 0;
- unsigned int regnum;
unsigned int idx;
struct symbol *sym;
char *end;
if (*nextcharP != '(')
{
as_bad ("Expected '('");
- goto done;
+ break;
}
/* Skip '('. */
++input_line_pointer;
in relocs. */
e->X_op = O_pseudo_fixup;
e->X_op_symbol = pseudo_func[idx].u.sym;
+ done:
+ *nextcharP = *input_line_pointer;
break;
case PSEUDO_FUNC_CONST:
default:
return 0;
}
- done:
- *nextcharP = *input_line_pointer;
return 1;
}
}
/* check for inN, locN, or outN: */
+ idx = 0;
switch (name[0])
{
case 'i':
if (name[1] == 'n' && ISDIGIT (name[2]))
{
dr = &md.in;
- name += 2;
+ idx = 2;
}
break;
if (name[1] == 'o' && name[2] == 'c' && ISDIGIT (name[3]))
{
dr = &md.loc;
- name += 3;
+ idx = 3;
}
break;
if (name[1] == 'u' && name[2] == 't' && ISDIGIT (name[3]))
{
dr = &md.out;
- name += 3;
+ idx = 3;
}
break;
break;
}
- if (dr)
+ /* Ignore register numbers with leading zeroes, except zero itself. */
+ if (dr && (name[idx] != '0' || name[idx + 1] == '\0'))
{
+ unsigned long regnum;
+
/* The name is inN, locN, or outN; parse the register number. */
- regnum = strtoul (name, &end, 10);
- if (end > name && *end == '\0')
+ regnum = strtoul (name + idx, &end, 10);
+ if (end > name + idx && *end == '\0' && regnum < 96)
{
- if ((unsigned) regnum >= dr->num_regs)
+ if (regnum >= dr->num_regs)
{
if (!dr->num_regs)
as_bad ("No current frame");
}
}
+ end = alloca (strlen (name) + 1);
+ strcpy (end, name);
+ name = ia64_canonicalize_symbol_name (end);
if ((dr = hash_find (md.dynreg_hash, name)))
{
/* We've got ourselves the name of a rotating register set.
ia64_canonicalize_symbol_name (name)
char *name;
{
- size_t len = strlen (name);
- if (len > 1 && name[len - 1] == '#')
- name[len - 1] = '\0';
+ size_t len = strlen (name), full = len;
+
+ while (len > 0 && name[len - 1] == '#')
+ --len;
+ if (len <= 0)
+ {
+ if (full > 0)
+ as_bad ("Standalone `#' is illegal");
+ }
+ else if (len < full - 1)
+ as_warn ("Redundant `#' suffix operators");
+ name[len] = '\0';
return name;
}
tmpl.link_to_qp_branch = 1;
tmpl.mem_offset.hint = 0;
tmpl.specific = 1;
- tmpl.index = 0;
+ tmpl.index = -1;
tmpl.cmp_type = CMP_NONE;
#define UNHANDLED \
if (idesc->operands[0] == IA64_OPND_AR3
&& CURR_SLOT.opnd[0].X_add_number - REG_AR == AR_BSPSTORE)
{
- specs[count] = tmpl;
- specs[count++].index = 0; /* IA64_RSE_BSPLOAD/RNATBITINDEX */
+ specs[count++] = tmpl;
}
}
else
else if (idesc->operands[0] == IA64_OPND_R1
&& (idesc->operands[1] == IA64_OPND_IMM22
|| idesc->operands[1] == IA64_OPND_IMMU64)
+ && CURR_SLOT.opnd[1].X_op == O_constant
&& (strcmp (idesc->name, "mov") == 0
|| strcmp (idesc->name, "movl") == 0))
{
}
}
}
+ /* Look for dep.z imm insns. */
+ else if (idesc->operands[0] == IA64_OPND_R1
+ && idesc->operands[1] == IA64_OPND_IMM8
+ && strcmp (idesc->name, "dep.z") == 0)
+ {
+ int regno = CURR_SLOT.opnd[0].X_add_number - REG_GR;
+ if (regno > 0 && regno < NELEMS (gr_values))
+ {
+ valueT value = CURR_SLOT.opnd[1].X_add_number;
+
+ if (CURR_SLOT.opnd[3].X_add_number < 64)
+ value &= ((valueT)1 << CURR_SLOT.opnd[3].X_add_number) - 1;
+ value <<= CURR_SLOT.opnd[2].X_add_number;
+ gr_values[regno].known = 1;
+ gr_values[regno].value = value;
+ gr_values[regno].path = md.path;
+ if (md.debug_dv)
+ {
+ fprintf (stderr, " Know gr%d = ", regno);
+ fprintf_vma (stderr, gr_values[regno].value);
+ fputs ("\n", stderr);
+ }
+ }
+ }
else
{
clear_qp_mutex (qp_changemask);
fprintf (stderr, " %s %s '%s'",
action, dv_mode[(regdeps[depind].dependency)->mode],
(regdeps[depind].dependency)->name);
- if (regdeps[depind].specific && regdeps[depind].index != 0)
+ if (regdeps[depind].specific && regdeps[depind].index >= 0)
fprintf (stderr, " (%d)", regdeps[depind].index);
if (regdeps[depind].mem_offset.hint)
{
struct slot oldslot = CURR_SLOT;
/* Manually jam a srlz.i insn into the stream */
memset (&CURR_SLOT, 0, sizeof (CURR_SLOT));
+ CURR_SLOT.user_template = -1;
CURR_SLOT.idesc = ia64_find_opcode ("srlz.i");
instruction_serialization ();
md.curr_slot = (md.curr_slot + 1) % NUM_SLOTS;
struct slot oldslot = CURR_SLOT;
/* Manually jam a srlz.d insn into the stream */
memset (&CURR_SLOT, 0, sizeof (CURR_SLOT));
+ CURR_SLOT.user_template = -1;
CURR_SLOT.idesc = ia64_find_opcode ("srlz.d");
data_serialization ();
md.curr_slot = (md.curr_slot + 1) % NUM_SLOTS;
if (path != 0)
sprintf (pathmsg, " when entry is at label '%s'",
md.entry_labels[path - 1]);
- if (rs->specific && rs->index != 0)
+ if (matchtype == 1 && rs->index >= 0)
sprintf (indexmsg, ", specific resource number is %d",
rs->index);
sprintf (msg, "Use of '%s' %s %s dependency '%s' (%s)%s%s",
TOUPPER (unit));
}
}
+ else if (strcmp (idesc->name, "hint.b") == 0)
+ {
+ switch (md.hint_b)
+ {
+ case hint_b_ok:
+ break;
+ case hint_b_warning:
+ as_warn ("hint.b may be treated as nop");
+ break;
+ case hint_b_error:
+ as_bad ("hint.b shouldn't be used");
+ break;
+ }
+ }
qp_regno = 0;
if (md.qp.X_op == O_register)
bfd_reloc_code_real_type r_type;
{
bfd_reloc_code_real_type new = 0;
+ const char *type = NULL, *suffix = "";
if (sym == NULL)
{
case BFD_RELOC_IA64_DIR32LSB: new = BFD_RELOC_IA64_FPTR32LSB; break;
case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_FPTR64MSB; break;
case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_FPTR64LSB; break;
- default: break;
+ default: type = "FPTR"; break;
}
break;
case BFD_RELOC_IA64_DIR32LSB: new = BFD_RELOC_IA64_GPREL32LSB; break;
case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_GPREL64MSB; break;
case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_GPREL64LSB; break;
- default: break;
+ default: type = "GPREL"; break;
}
break;
{
case BFD_RELOC_IA64_IMM22: new = BFD_RELOC_IA64_LTOFF22; break;
case BFD_RELOC_IA64_IMM64: new = BFD_RELOC_IA64_LTOFF64I; break;
- default: break;
+ default: type = "LTOFF"; break;
}
break;
switch (r_type)
{
case BFD_RELOC_IA64_IMM22: new = BFD_RELOC_IA64_LTOFF22X; break;
- default: break;
+ default: type = "LTOFF"; suffix = "X"; break;
}
break;
case BFD_RELOC_IA64_DIR32LSB: new = BFD_RELOC_IA64_PCREL32LSB; break;
case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_PCREL64MSB; break;
case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_PCREL64LSB; break;
- default: break;
+ default: type = "PCREL"; break;
}
break;
case BFD_RELOC_IA64_IMM64: new = BFD_RELOC_IA64_PLTOFF64I; break;
case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_PLTOFF64MSB;break;
case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_PLTOFF64LSB;break;
- default: break;
+ default: type = "PLTOFF"; break;
}
break;
case BFD_RELOC_IA64_DIR32LSB: new = BFD_RELOC_IA64_SECREL32LSB;break;
case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_SECREL64MSB;break;
case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_SECREL64LSB;break;
- default: break;
+ default: type = "SECREL"; break;
}
break;
case BFD_RELOC_IA64_DIR32LSB: new = BFD_RELOC_IA64_SEGREL32LSB;break;
case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_SEGREL64MSB;break;
case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_SEGREL64LSB;break;
- default: break;
+ default: type = "SEGREL"; break;
}
break;
case BFD_RELOC_IA64_DIR32LSB: new = BFD_RELOC_IA64_LTV32LSB; break;
case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_LTV64MSB; break;
case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_LTV64LSB; break;
- default: break;
+ default: type = "LTV"; break;
}
break;
new = BFD_RELOC_IA64_LTOFF_FPTR22; break;
case BFD_RELOC_IA64_IMM64:
new = BFD_RELOC_IA64_LTOFF_FPTR64I; break;
+ case BFD_RELOC_IA64_DIR32MSB:
+ new = BFD_RELOC_IA64_LTOFF_FPTR32MSB; break;
+ case BFD_RELOC_IA64_DIR32LSB:
+ new = BFD_RELOC_IA64_LTOFF_FPTR32LSB; break;
+ case BFD_RELOC_IA64_DIR64MSB:
+ new = BFD_RELOC_IA64_LTOFF_FPTR64MSB; break;
+ case BFD_RELOC_IA64_DIR64LSB:
+ new = BFD_RELOC_IA64_LTOFF_FPTR64LSB; break;
default:
- break;
+ type = "LTOFF_FPTR"; break;
}
break;
case FUNC_TP_RELATIVE:
switch (r_type)
{
- case BFD_RELOC_IA64_IMM14:
- new = BFD_RELOC_IA64_TPREL14; break;
- case BFD_RELOC_IA64_IMM22:
- new = BFD_RELOC_IA64_TPREL22; break;
- case BFD_RELOC_IA64_IMM64:
- new = BFD_RELOC_IA64_TPREL64I; break;
- default:
- break;
+ case BFD_RELOC_IA64_IMM14: new = BFD_RELOC_IA64_TPREL14; break;
+ case BFD_RELOC_IA64_IMM22: new = BFD_RELOC_IA64_TPREL22; break;
+ case BFD_RELOC_IA64_IMM64: new = BFD_RELOC_IA64_TPREL64I; break;
+ case BFD_RELOC_IA64_DIR64MSB: new = BFD_RELOC_IA64_TPREL64MSB; break;
+ case BFD_RELOC_IA64_DIR64LSB: new = BFD_RELOC_IA64_TPREL64LSB; break;
+ default: type = "TPREL"; break;
}
break;
case BFD_RELOC_IA64_IMM22:
new = BFD_RELOC_IA64_LTOFF_TPREL22; break;
default:
- break;
+ type = "LTOFF_TPREL"; break;
+ }
+ break;
+
+ case FUNC_DTP_MODULE:
+ switch (r_type)
+ {
+ case BFD_RELOC_IA64_DIR64MSB:
+ new = BFD_RELOC_IA64_DTPMOD64MSB; break;
+ case BFD_RELOC_IA64_DIR64LSB:
+ new = BFD_RELOC_IA64_DTPMOD64LSB; break;
+ default:
+ type = "DTPMOD"; break;
}
break;
case BFD_RELOC_IA64_IMM22:
new = BFD_RELOC_IA64_LTOFF_DTPMOD22; break;
default:
- break;
+ type = "LTOFF_DTPMOD"; break;
}
break;
case FUNC_DTP_RELATIVE:
switch (r_type)
{
+ case BFD_RELOC_IA64_DIR32MSB:
+ new = BFD_RELOC_IA64_DTPREL32MSB; break;
+ case BFD_RELOC_IA64_DIR32LSB:
+ new = BFD_RELOC_IA64_DTPREL32LSB; break;
case BFD_RELOC_IA64_DIR64MSB:
new = BFD_RELOC_IA64_DTPREL64MSB; break;
case BFD_RELOC_IA64_DIR64LSB:
case BFD_RELOC_IA64_IMM64:
new = BFD_RELOC_IA64_DTPREL64I; break;
default:
- break;
+ type = "DTPREL"; break;
}
break;
case BFD_RELOC_IA64_IMM22:
new = BFD_RELOC_IA64_LTOFF_DTPREL22; break;
default:
- break;
+ type = "LTOFF_DTPREL"; break;
}
break;
case FUNC_IPLT_RELOC:
+ switch (r_type)
+ {
+ case BFD_RELOC_IA64_IPLTMSB: return r_type;
+ case BFD_RELOC_IA64_IPLTLSB: return r_type;
+ default: type = "IPLT"; break;
+ }
break;
default:
abort ();
}
- /* Hmmmm. Should this ever occur? */
if (new)
return new;
else
- return r_type;
+ {
+ int width;
+
+ if (!type)
+ abort ();
+ switch (r_type)
+ {
+ case BFD_RELOC_IA64_DIR32MSB: width = 32; suffix = "MSB"; break;
+ case BFD_RELOC_IA64_DIR32LSB: width = 32; suffix = "LSB"; break;
+ case BFD_RELOC_IA64_DIR64MSB: width = 64; suffix = "MSB"; break;
+ case BFD_RELOC_IA64_DIR64LSB: width = 64; suffix = "LSB"; break;
+ case BFD_RELOC_IA64_IMM14: width = 14; break;
+ case BFD_RELOC_IA64_IMM22: width = 22; break;
+ case BFD_RELOC_IA64_IMM64: width = 64; suffix = "I"; break;
+ default: abort ();
+ }
+
+ /* This should be an error, but since previously there wasn't any
+ diagnostic here, dont't make it fail because of this for now. */
+ as_warn ("Cannot express %s%d%s relocation", type, width, suffix);
+ return r_type;
+ }
}
/* Here is where generate the appropriate reloc for pseudo relocation
if (fix->fx_pcrel)
{
- switch (fix->fx_r_type)
- {
- case BFD_RELOC_IA64_DIR32MSB:
- fix->fx_r_type = BFD_RELOC_IA64_PCREL32MSB;
- break;
-
- case BFD_RELOC_IA64_DIR32LSB:
- fix->fx_r_type = BFD_RELOC_IA64_PCREL32LSB;
- break;
-
- case BFD_RELOC_IA64_DIR64MSB:
- fix->fx_r_type = BFD_RELOC_IA64_PCREL64MSB;
- break;
-
- case BFD_RELOC_IA64_DIR64LSB:
- fix->fx_r_type = BFD_RELOC_IA64_PCREL64LSB;
- break;
-
- default:
- break;
- }
+ switch (fix->fx_r_type)
+ {
+ case BFD_RELOC_IA64_PCREL21B: break;
+ case BFD_RELOC_IA64_PCREL21BI: break;
+ case BFD_RELOC_IA64_PCREL21F: break;
+ case BFD_RELOC_IA64_PCREL21M: break;
+ case BFD_RELOC_IA64_PCREL60B: break;
+ case BFD_RELOC_IA64_PCREL22: break;
+ case BFD_RELOC_IA64_PCREL64I: break;
+ case BFD_RELOC_IA64_PCREL32MSB: break;
+ case BFD_RELOC_IA64_PCREL32LSB: break;
+ case BFD_RELOC_IA64_PCREL64MSB: break;
+ case BFD_RELOC_IA64_PCREL64LSB: break;
+ default:
+ fix->fx_r_type = ia64_gen_real_reloc_type (pseudo_func[FUNC_PC_RELATIVE].u.sym,
+ fix->fx_r_type);
+ break;
+ }
}
if (fix->fx_addsy)
{
ia64_handle_align (fragp)
fragS *fragp;
{
- /* Use mfi bundle of nops with no stop bits. */
- static const unsigned char le_nop[]
- = { 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00};
- static const unsigned char le_nop_stop[]
- = { 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00};
-
int bytes;
char *p;
const unsigned char *nop;
input_line_pointer++;
*end_name = 0;
+ ia64_canonicalize_symbol_name (name);
/* We call demand_copy_C_string to check if alias string is valid.
There should be a closing `"' and no `\0' in the string. */