[llvm] 3b78065 - [LoongArch] Handle out-fo-range uimm8 operands in LoongArchAsmParser
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 18 18:39:31 PDT 2023
Author: wanglei
Date: 2023-05-19T09:38:49+08:00
New Revision: 3b78065e3026de0d1ea4802cb6a4f35ebc687cdf
URL: https://github.com/llvm/llvm-project/commit/3b78065e3026de0d1ea4802cb6a4f35ebc687cdf
DIFF: https://github.com/llvm/llvm-project/commit/3b78065e3026de0d1ea4802cb6a4f35ebc687cdf.diff
LOG: [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.
Added:
Modified:
llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
llvm/test/MC/LoongArch/Basic/Privilege/invalid.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp b/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
index 164f8a2f7e648..a3ba9aab9e862 100644
--- a/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
+++ b/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
@@ -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);
diff --git a/llvm/test/MC/LoongArch/Basic/Privilege/invalid.s b/llvm/test/MC/LoongArch/Basic/Privilege/invalid.s
index 380b848a6af9b..80d7c304956c9 100644
--- a/llvm/test/MC/LoongArch/Basic/Privilege/invalid.s
+++ b/llvm/test/MC/LoongArch/Basic/Privilege/invalid.s
@@ -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]
More information about the llvm-commits
mailing list