Skip to content

Commit 3b78065

Browse files
committed
[LoongArch] Handle out-fo-range uimm8 operands in LoongArchAsmParser
With this fix, when encountering an out-of-range uimm8 operand, the code now triggers an appropriate error message, clearly indicating that the immediate value must be an integer within the range of 0 to 255.
1 parent b4fbc4b commit 3b78065

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,9 @@ bool LoongArchAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
13351335
case Match_InvalidUImm6:
13361336
return generateImmOutOfRangeError(Operands, ErrorInfo, /*Lower=*/0,
13371337
/*Upper=*/(1 << 6) - 1);
1338+
case Match_InvalidUImm8:
1339+
return generateImmOutOfRangeError(Operands, ErrorInfo, /*Lower=*/0,
1340+
/*Upper=*/(1 << 8) - 1);
13381341
case Match_InvalidUImm12:
13391342
return generateImmOutOfRangeError(Operands, ErrorInfo, /*Lower=*/0,
13401343
/*Upper=*/(1 << 12) - 1);

llvm/test/MC/LoongArch/Basic/Privilege/invalid.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ iocsrrd.d $a0, $a1
1212
# ERR32: :[[#@LINE-1]]:1: error: instruction requires the following: LA64 Basic Integer and Privilege Instruction Set
1313
iocsrwr.d $a0, $a1
1414
# ERR32: :[[#@LINE-1]]:1: error: instruction requires the following: LA64 Basic Integer and Privilege Instruction Set
15+
16+
## uimm8
17+
lddir $a0, $a0, 0x1ff
18+
# CHECK: :[[#@LINE-1]]:17: error: immediate must be an integer in the range [0, 255]

0 commit comments

Comments
 (0)