Skip to content

Commit

Permalink
[LoongArch] Handle out-fo-range uimm8 operands in LoongArchAsmParser
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wangleiat committed May 19, 2023
1 parent b4fbc4b commit 3b78065
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,9 @@ bool LoongArchAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
case Match_InvalidUImm6:
return generateImmOutOfRangeError(Operands, ErrorInfo, /*Lower=*/0,
/*Upper=*/(1 << 6) - 1);
case Match_InvalidUImm8:
return generateImmOutOfRangeError(Operands, ErrorInfo, /*Lower=*/0,
/*Upper=*/(1 << 8) - 1);
case Match_InvalidUImm12:
return generateImmOutOfRangeError(Operands, ErrorInfo, /*Lower=*/0,
/*Upper=*/(1 << 12) - 1);
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/MC/LoongArch/Basic/Privilege/invalid.s
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ iocsrrd.d $a0, $a1
# ERR32: :[[#@LINE-1]]:1: error: instruction requires the following: LA64 Basic Integer and Privilege Instruction Set
iocsrwr.d $a0, $a1
# ERR32: :[[#@LINE-1]]:1: error: instruction requires the following: LA64 Basic Integer and Privilege Instruction Set

## uimm8
lddir $a0, $a0, 0x1ff
# CHECK: :[[#@LINE-1]]:17: error: immediate must be an integer in the range [0, 255]

0 comments on commit 3b78065

Please sign in to comment.