Commit 3b78065e authored by wanglei's avatar wanglei
Browse files

[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.
parent b4fbc4bd
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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);
+4 −0
Original line number Diff line number Diff line
@@ -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]