[RISCV][MC][xthead] Wrong AsmParser error for `th.ldia`
Maybe I am missing something from the specs [1], but I think that the first assembly instruction in the test llvm/test/MC/RISCV/rv64xtheadmemidx-invalid.s should be reporting an error at column 10 (for 0(a0)) and not column 23 (the first immediate operand, 0):
th.ldia 0(a0), (a1), 0, 0 # CHECK: :[[@LINE]]:23: error: invalid operand for instruction
[1] Quoting https://github.com/T-head-Semi/thead-extension-spec/blob/master/xtheadmemidx/ldia.adoc
Mnemonic
th.ldia rd, (rs1), imm5, imm2
@llvm/issue-subscribers-backend-risc-v
Author: Francesco Petrogalli (fpetrogalli)
th.ldia 0(a0), (a1), 0, 0 # CHECK: :[[@<!-- -->LINE]]:23: error: invalid operand for instruction
[1] Quoting https://github.com/T-head-Semi/thead-extension-spec/blob/master/xtheadmemidx/ldia.adoc
Mnemonic
th.ldia rd, (rs1), imm5, imm2
The 0, ( and ) are parsed as operands and as a result we hit the following piece of code in MatchInstructionImpl in RISCVGenAsmMatcher.inc since Operands.size() is 9:
// Eliminate obvious mismatches.
if (Operands.size() > 8) {
ErrorInfo = 8;
return Match_InvalidOperand;
}
As you can see we return 8 for ErrorInfo and hence we set the error on the 8th operand which happens to be the first immediate operand 0.
I'm not saying this is correct. Just explaining what's happening.