-#define INSN_ERET 0x42000018
-#define INSN_DERET 0x4200001f
-
-/* Implement the ERET/DERET Errata for MIPS 24k.
-
- If an ERET/DERET is encountered in a noreorder block,
- warn if the ERET/DERET is followed by a branch instruction.
- Also warn if the ERET/DERET is the last instruction in the
- noreorder block.
-
- IF an ERET/DERET is in a reorder block and is followed by a
- branch instruction, insert a nop. */
-
-static void
-check_for_24k_errata (struct mips_cl_insn *insn, int eret_ndx)
-{
- bfd_boolean next_insn_is_branch = FALSE;
-
- /* eret_ndx will be -1 for the last instruction in a section
- and the ERET/DERET will be in insn, not history. */
- if (insn
- && eret_ndx == -1
- && (insn->insn_opcode == INSN_ERET
- || insn->insn_opcode == INSN_DERET)
- && insn->noreorder_p)
- {
- as_warn (_("ERET and DERET must be followed by a NOP on the 24K."));
- return;
- }
-
- if (history[eret_ndx].insn_opcode != INSN_ERET
- && history[eret_ndx].insn_opcode != INSN_DERET)
- return;
-
- if (!insn)
- {
- if (history[eret_ndx].noreorder_p)
- as_warn (_("ERET and DERET must be followed by a NOP on the 24K."));
- return;
- }
-
- next_insn_is_branch = ((insn->insn_opcode == INSN_ERET)
- || (insn->insn_opcode == INSN_DERET)
- || (insn->insn_mo->pinfo
- & (INSN_UNCOND_BRANCH_DELAY
- | INSN_COND_BRANCH_DELAY
- | INSN_COND_BRANCH_LIKELY)));
-
- if (next_insn_is_branch && history[eret_ndx].noreorder_p)
- {
- as_warn (_("ERET and DERET must be followed by a NOP on the 24K."));
- return;
- }
-
- /* Emit nop if the next instruction is a branch. */
- if (next_insn_is_branch)
- {
- long nop_where, br_where;
- struct frag *nop_frag, *br_frag;
- struct mips_cl_insn br_insn, nop_insn;
-
- emit_nop ();
-
- nop_insn = history[eret_ndx - 1];
- nop_frag = history[eret_ndx - 1].frag;
- nop_where = history[eret_ndx - 1].where;
-
- br_insn = history[eret_ndx];
- br_frag = history[eret_ndx].frag;
- br_where = history[eret_ndx].where;
-
- move_insn (&nop_insn, br_frag, br_where);
- move_insn (&br_insn, nop_frag, nop_where);
-
- history[eret_ndx-1] = br_insn;
- history[eret_ndx] = nop_insn;
- }
-}
-