binutils Newspaper
NOVEMBER 30, 2026
mips — Committed

MIPS: Correct Toshiba TX39 MADD/MADDU HI/LO instruction flags

Fixes instruction flags for MIPS multiply-add instructions on Toshiba TX39 to correctly handle pipeline hazards with HI/LO registers.

This patch corrects the instruction flags in GAS for Toshiba TX39’s MADD and MADDU instructions. These instructions, when reading from HI/LO registers, have a pipeline hazard with subsequent DIV or DIVU instructions. Previously, GAS did not recognize this hazard for MADD/MADDU due to missing INSN_READ_HI/INSN_READ_LO flags. By adding these flags, GAS will now correctly emit NOP instructions to separate hazardous instruction sequences, ensuring proper operation and passing test cases.

In Details

The insns_between logic in GAS for MIPS handles pipeline hazards by checking instruction flags. For MIPS multiply-add instructions (MADD, MADDU) on the Toshiba TX39, a hazard exists if they are followed by DIV or DIVU. This is because MADD/MADDU *read* the HI/LO registers, which DIV/DIVU modify. The patch adds the INSN_READ_HI and INSN_READ_LO flags to these instructions in opcodes/mips-opc.c so insns_between can correctly identify and mitigate this hazard by inserting NOPs.

For Context
GAS
GNU Assembler, part of the GNU Binutils package, responsible for translating assembly language code into machine code.
MADD
MIPS multiply-add instruction.
MADDU
MIPS unsigned multiply-add instruction.
HI/LO registers
Special-purpose registers on MIPS processors that store the high and low parts of multiplication or division results.
DIV/DIVU
MIPS division instructions.
pipeline hazard
A situation in a CPU's instruction pipeline where the next instruction cannot execute because it depends on the result of a previous instruction that has not yet completed.
Toshiba TX39
A specific MIPS processor that has particular pipeline constraints related to the HI and LO registers, especially concerning division and multiply-add instructions.
Filed Under: mipsgaspipelinehazardarchitecture