test(asm): pin the ADDV16 immediate family the toolchain assembles

Assisted-by: GLM 5.3 Flash
This commit is contained in:
petrbalvin authored and Petr Balvín committed 2026-10-07 21:42:14 +02:00
1 parent a3eaa82f87
commit f661c2fc78
2 files changed
+49 -1

No files matched your search

+9 -1
View File
@@ -872,7 +872,10 @@ func encodeLOONG64Instr(instr *ast.Instr, pc int, offsets map[string]int, fi loo
case l64Firr16:
// ADDV16: INSTR $imm, rd or INSTR $imm, rj, rd; the immediate must be
// a multiple of 65536 and is shifted right by 16.
// a multiple of 65536 and is shifted right by 16. Both registers are
// general: the toolchain's class match refuses an F, V or X bank
// register here ("illegal combination ADDV16 ... FREG ..."), and the
// 5-bit numbering would otherwise encode it silently.
if len(ops) < 2 || !isImmOperand(ops[0]) {
return nil, fmt.Errorf("%s expects an immediate operand", mnem)
}
@@ -880,6 +883,11 @@ func encodeLOONG64Instr(instr *ast.Instr, pc int, offsets map[string]int, fi loo
if v&0xFFFF != 0 {
return nil, fmt.Errorf("%s: the constant must be a multiple of 65536", mnem)
}
for _, op := range ops[1:] {
if c := loong64RegClass(operandRegName(op)); c != l64ClsGR {
return nil, fmt.Errorf("%s: illegal combination: the registers must be general", mnem)
}
}
rd := l64Reg(ops[len(ops)-1])
rj := rd
if len(ops) == 3 {