/* Table of relaxations for Xtensa assembly.
- Copyright (C) 2003-2014 Free Software Foundation, Inc.
+ Copyright (C) 2003-2016 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
addi.n a4, 0x1010
=> addi a4, 0x1010
=> addmi a4, 0x1010
- => addmi a4, 0x1000, addi a4, 0x10.
+ => addmi a4, 0x1000, addi a4, 0x10.
See the comments in xg_assembly_relax for some important details
regarding how these chains must be built. */
out-of-range branch. Put the wide branch relaxations first in the
table since they are more efficient than the branch-around
relaxations. */
-
+
{"beqz %as,%label ? IsaUseWideBranches", "WIDE.beqz %as,%label"},
{"bnez %as,%label ? IsaUseWideBranches", "WIDE.bnez %as,%label"},
{"bgez %as,%label ? IsaUseWideBranches", "WIDE.bgez %as,%label"},
{"bnall %as,%at,%label ? IsaUseWideBranches", "WIDE.bnall %as,%at,%label"},
{"bbc %as,%at,%label ? IsaUseWideBranches", "WIDE.bbc %as,%at,%label"},
{"bbs %as,%at,%label ? IsaUseWideBranches", "WIDE.bbs %as,%at,%label"},
-
+
/* Widening branch comparisons eq/ne to zero. Prefer relaxing to narrow
branches if the density option is available. */
{"beqz %as,%label ? IsaUseDensityInstruction", "bnez.n %as,%LABEL;j %label;LABEL"},
TransitionRule *t,
transition_cmp_fn cmp)
{
- TransitionList *tl = (TransitionList *) xmalloc (sizeof (TransitionList));
+ TransitionList *tl = XNEW (TransitionList);
TransitionList *prev;
TransitionList **t_p;
gas_assert (tt != NULL);
static void
append_condition (TransitionRule *tr, Precondition *cond)
{
- PreconditionList *pl =
- (PreconditionList *) xmalloc (sizeof (PreconditionList));
+ PreconditionList *pl = XNEW (PreconditionList);
PreconditionList *prev = tr->conditions;
PreconditionList *nxt;
unsigned op1,
unsigned op2)
{
- Precondition *cond = (Precondition *) xmalloc (sizeof (Precondition));
+ Precondition *cond = XNEW (Precondition);
cond->cmp = cmp;
cond->op_num = op1;
unsigned op1,
unsigned cnst)
{
- Precondition *cond = (Precondition *) xmalloc (sizeof (Precondition));
+ Precondition *cond = XNEW (Precondition);
cond->cmp = cmp;
cond->op_num = op1;
static void
append_literal_op (BuildInstr *bi, unsigned op1, unsigned src_op)
{
- BuildOp *b_op = (BuildOp *) xmalloc (sizeof (BuildOp));
+ BuildOp *b_op = XNEW (BuildOp);
b_op->op_num = op1;
b_op->typ = OP_LITERAL;
static void
append_label_op (BuildInstr *bi, unsigned op1)
{
- BuildOp *b_op = (BuildOp *) xmalloc (sizeof (BuildOp));
+ BuildOp *b_op = XNEW (BuildOp);
b_op->op_num = op1;
b_op->typ = OP_LABEL;
static void
append_constant_op (BuildInstr *bi, unsigned op1, unsigned cnst)
{
- BuildOp *b_op = (BuildOp *) xmalloc (sizeof (BuildOp));
+ BuildOp *b_op = XNEW (BuildOp);
b_op->op_num = op1;
b_op->typ = OP_CONSTANT;
static void
append_field_op (BuildInstr *bi, unsigned op1, unsigned src_op)
{
- BuildOp *b_op = (BuildOp *) xmalloc (sizeof (BuildOp));
+ BuildOp *b_op = XNEW (BuildOp);
b_op->op_num = op1;
b_op->typ = OP_OPERAND;
OpType typ,
unsigned src_op)
{
- BuildOp *b_op = (BuildOp *) xmalloc (sizeof (BuildOp));
+ BuildOp *b_op = XNEW (BuildOp);
b_op->op_num = op1;
b_op->typ = typ;
&& strncmp (op->opname, name, len) == 0)
return op->opname;
}
- op = (opname_e *) xmalloc (sizeof (opname_e));
- op->opname = (char *) xmalloc (len + 1);
- strncpy (op->opname, name, len);
- op->opname[len] = '\0';
+ op = XNEW (opname_e);
+ op->opname = xmemdup0 (name, len);
return op->opname;
}
if (strcmp (op->opname, name) == 0)
return op->opname;
}
- op = (opname_e *) xmalloc (sizeof (opname_e));
+ op = XNEW (opname_e);
op->opname = xstrdup (name);
return op->opname;
}
static bfd_boolean
same_operand_name (const opname_map_e *m1, const opname_map_e *m2)
{
- if (m1->operand_name == NULL || m1->operand_name == NULL)
+ if (m1->operand_name == NULL || m2->operand_name == NULL)
return FALSE;
return (m1->operand_name == m2->operand_name);
}
const char **fn_name_p,
const char **arg_name_p)
{
- char *p_start;
+ const char *p_start;
const char *p_end;
p_start = strchr (name, '(');
if (rec->count == 0)
return;
- rec->vec = (char **) xmalloc (sizeof (char *) * cnt);
+ rec->vec = XNEWVEC (char *, cnt);
for (i = 0; i < cnt; i++)
rec->vec[i] = 0;
else
{
len = p - q;
- rec->vec[i] = (char *) xmalloc (sizeof (char) * (len + 1));
- strncpy (rec->vec[i], q, len);
- rec->vec[i][len] = '\0';
+ rec->vec[i] = xmemdup0 (q, len);
p++;
}
for (i = 0; i < oprec.count; i++)
{
const char *opname = oprec.vec[i];
- opname_map_e *e = (opname_map_e *) xmalloc (sizeof (opname_map_e));
+ opname_map_e *e = XNEW (opname_map_e);
e->next = NULL;
e->operand_name = NULL;
e->constant_value = 0;
if (req_or_option == NULL)
return NULL;
- new_req_or_option = (ReqOrOption *) xmalloc (sizeof (ReqOrOption));
+ new_req_or_option = XNEW (ReqOrOption);
new_req_or_option->option_name = xstrdup (req_or_option->option_name);
new_req_or_option->is_true = req_or_option->is_true;
new_req_or_option->next = NULL;
if (req_option == NULL)
return NULL;
- new_req_option = (ReqOption *) xmalloc (sizeof (ReqOption));
+ new_req_option = XNEW (ReqOption);
new_req_option->or_option_terms = NULL;
new_req_option->next = NULL;
new_req_option->or_option_terms =
else
option_name = xstrdup (option_name);
- req = (ReqOrOption *) xmalloc (sizeof (ReqOrOption));
+ req = XNEW (ReqOrOption);
req->option_name = option_name;
req->is_true = is_true;
req->next = NULL;
for (i = 1; i < rec.count; i++)
{
- precond_e *cond = (precond_e *) xmalloc (sizeof (precond_e));
+ precond_e *cond = XNEW (precond_e);
if (!parse_precond (rec.vec[i], cond))
{
{
/* Handle the option conditions. */
ReqOption **r_p;
- ReqOption *req_option = (ReqOption *) xmalloc (sizeof (ReqOption));
+ ReqOption *req_option = XNEW (ReqOption);
req_option->or_option_terms = NULL;
req_option->next = NULL;
for (i = 0; i < rec.count; i++)
{
- insn_repl_e *e = (insn_repl_e *) xmalloc (sizeof (insn_repl_e));
+ insn_repl_e *e = XNEW (insn_repl_e);
e->next = NULL;
else if (!strcmp (option_name, "Loops"))
option_available = (XCHAL_HAVE_LOOPS == 1);
else if (!strcmp (option_name, "WideBranches"))
- option_available
+ option_available
= (XCHAL_HAVE_WIDE_BRANCHES == 1 && produce_flix == FLIX_ALL);
else if (!strcmp (option_name, "PredictedBranches"))
option_available
static bfd_boolean
wide_branch_opcode (const char *opcode_name,
- char *suffix,
+ const char *suffix,
xtensa_opcode *popcode)
{
xtensa_isa isa = xtensa_default_isa;
precond_e *precond;
insn_repl_e *r;
- if (!wide_branch_opcode (initial_insn->t.opcode_name, ".w18", &opcode)
+ if (!wide_branch_opcode (initial_insn->t.opcode_name, ".w18", &opcode)
&& !wide_branch_opcode (initial_insn->t.opcode_name, ".w15", &opcode))
opcode = xtensa_opcode_lookup (isa, initial_insn->t.opcode_name);
return NULL;
}
- tr = (TransitionRule *) xmalloc (sizeof (TransitionRule));
+ tr = XNEW (TransitionRule);
tr->opcode = opcode;
tr->conditions = NULL;
tr->to_instr = NULL;
const char *fn_name;
const char *operand_arg_name;
- bi = (BuildInstr *) xmalloc (sizeof (BuildInstr));
+ bi = XNEW (BuildInstr);
append_build_insn (tr, bi);
bi->opcode = XTENSA_UNDEFINED;
return table;
/* Otherwise, build it now. */
- table = (TransitionTable *) xmalloc (sizeof (TransitionTable));
+ table = XNEW (TransitionTable);
table->num_opcodes = num_opcodes;
- table->table =
- (TransitionList **) xmalloc (sizeof (TransitionTable *) * num_opcodes);
+ table->table = XNEWVEC (TransitionList *, num_opcodes);
for (i = 0; i < num_opcodes; i++)
table->table[i] = NULL;