Skip to content

Commit ffed176

Browse files
committed
[RISCV] Correct the error location for the X26 check in parseRegListCommon.
We should point to the start of the reglist not the closing parenthesis. I also moved the check after we finishing parsing the closing brace. The diagnostic mentions '{ra, s0-s10} or {x1, x8-x9, x18-x26}' so we should be sure that's what we parsed.
1 parent be3abfc commit ffed176

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,13 +2655,13 @@ ParseStatus RISCVAsmParser::parseRegListCommon(OperandVector &Operands,
26552655
}
26562656
}
26572657

2658-
if (RegEnd == RISCV::X26)
2659-
return Error(getLoc(), "invalid register list, {ra, s0-s10} or {x1, x8-x9, "
2660-
"x18-x26} is not supported");
2661-
26622658
if (parseToken(AsmToken::RCurly, "register list must end with '}'"))
26632659
return ParseStatus::Failure;
26642660

2661+
if (RegEnd == RISCV::X26)
2662+
return Error(S, "invalid register list, {ra, s0-s10} or {x1, x8-x9, "
2663+
"x18-x26} is not supported");
2664+
26652665
auto Encode = RISCVZC::encodeRlist(RegEnd, IsRVE);
26662666
assert(Encode != RISCVZC::INVALID_RLIST);
26672667
if (MustIncludeS0)

llvm/test/MC/RISCV/rv32xqccmp-invalid.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ qc.cm.mvsa01 s0, s0
1010
# CHECK-ERROR: :[[@LINE+1]]:14: error: invalid operand for instruction
1111
qc.cm.mva01s a1, a2
1212

13-
# CHECK-ERROR: :[[@LINE+1]]:26: error: invalid register list, {ra, s0-s10} or {x1, x8-x9, x18-x26} is not supported
13+
# CHECK-ERROR: :[[@LINE+1]]:15: error: invalid register list, {ra, s0-s10} or {x1, x8-x9, x18-x26} is not supported
1414
qc.cm.popretz {ra, s0-s10}, 112
1515

1616
# CHECK-ERROR: :[[@LINE+1]]:28: error: stack adjustment for register list must be a multiple of 16 bytes in the range [16, 64]

llvm/test/MC/RISCV/rv32zcmp-invalid.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cm.mvsa01 s0, s0
1010
# CHECK-ERROR: :[[@LINE+1]]:11: error: invalid operand for instruction
1111
cm.mva01s a1, a2
1212

13-
# CHECK-ERROR: :[[@LINE+1]]:23: error: invalid register list, {ra, s0-s10} or {x1, x8-x9, x18-x26} is not supported
13+
# CHECK-ERROR: :[[@LINE+1]]:12: error: invalid register list, {ra, s0-s10} or {x1, x8-x9, x18-x26} is not supported
1414
cm.popretz {ra, s0-s10}, 112
1515

1616
# CHECK-ERROR: :[[@LINE+1]]:25: error: stack adjustment for register list must be a multiple of 16 bytes in the range [16, 64]

llvm/test/MC/RISCV/rv64xqccmp-invalid.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ qc.cm.mvsa01 s0, s0
1010
# CHECK-ERROR: :[[@LINE+1]]:14: error: invalid operand for instruction
1111
qc.cm.mva01s a1, a2
1212

13-
# CHECK-ERROR: :[[@LINE+1]]:26: error: invalid register list, {ra, s0-s10} or {x1, x8-x9, x18-x26} is not supported
13+
# CHECK-ERROR: :[[@LINE+1]]:15: error: invalid register list, {ra, s0-s10} or {x1, x8-x9, x18-x26} is not supported
1414
qc.cm.popretz {ra, s0-s10}, 112
1515

1616
# CHECK-ERROR: :[[@LINE+1]]:28: error: stack adjustment for register list must be a multiple of 16 bytes in the range [32, 80]

llvm/test/MC/RISCV/rv64zcmp-invalid.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cm.mvsa01 s0, s0
1010
# CHECK-ERROR: :[[@LINE+1]]:11: error: invalid operand for instruction
1111
cm.mva01s a1, a2
1212

13-
# CHECK-ERROR: :[[@LINE+1]]:23: error: invalid register list, {ra, s0-s10} or {x1, x8-x9, x18-x26} is not supported
13+
# CHECK-ERROR: :[[@LINE+1]]:12: error: invalid register list, {ra, s0-s10} or {x1, x8-x9, x18-x26} is not supported
1414
cm.popretz {ra, s0-s10}, 112
1515

1616
# CHECK-ERROR: :[[@LINE+1]]:25: error: stack adjustment for register list must be a multiple of 16 bytes in the range [32, 80]

0 commit comments

Comments
 (0)