diff --git a/asm/loong64_assemble.go b/asm/loong64_assemble.go index fbd1a75..5599b2c 100644 --- a/asm/loong64_assemble.go +++ b/asm/loong64_assemble.go @@ -1422,6 +1422,11 @@ func encodeLOONG64Mov(instr *ast.Instr, mnem string, fi loong64FrameInfo, relocs // Register-offset addressing: MOVx (rj)(rk), rd / MOVx rd, (rj)(rk). if src.Addr.Index != "" && !isMemOperand(dst) { + if src.Addr.HasOff { + // The toolchain rejects off(rj)(rk) with an illegal + // combination; the offset would be silently dropped here. + return nil, fmt.Errorf("%s: the register-indexed form takes no offset", mnem) + } rd := l64Reg(dst) rj, rk := loong64RegNum(src.Addr.Base), loong64RegNum(src.Addr.Index) if rd < 0 || rj < 0 || rk < 0 { @@ -1434,6 +1439,10 @@ func encodeLOONG64Mov(instr *ast.Instr, mnem string, fi loong64FrameInfo, relocs return l64wordLE(l64rrr(op.ld, rk, rj, rd)), nil } if dst.Addr.Index != "" && !isMemOperand(src) { + if dst.Addr.HasOff { + // The store twin of the load rejection above. + return nil, fmt.Errorf("%s: the register-indexed form takes no offset", mnem) + } rs := l64Reg(src) rj, rk := loong64RegNum(dst.Addr.Base), loong64RegNum(dst.Addr.Index) if rs < 0 || rj < 0 || rk < 0 {