[llvm] r320559 - [RISCV][NFC] Put isSImm6 and simm6 td definition in correct sorted position
Alex Bradbury via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 13 01:41:22 PST 2017
Author: asb
Date: Wed Dec 13 01:41:21 2017
New Revision: 320559
URL: http://llvm.org/viewvc/llvm-project?rev=320559&view=rev
Log:
[RISCV][NFC] Put isSImm6 and simm6 td definition in correct sorted position
We sort these helper functions and td definitions by bit width. simm6 was
previously out-of-order with respect to the others.
Modified:
llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/trunk/lib/Target/RISCV/RISCVInstrInfoC.td
Modified: llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp?rev=320559&r1=320558&r2=320559&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp Wed Dec 13 01:41:21 2017
@@ -235,6 +235,19 @@ public:
VK == RISCVMCExpr::VK_RISCV_None;
}
+ bool isSImm6() const {
+ RISCVMCExpr::VariantKind VK;
+ int64_t Imm;
+ bool IsValid;
+ bool IsConstantImm = evaluateConstantImm(Imm, VK);
+ if (!IsConstantImm)
+ IsValid = RISCVAsmParser::classifySymbolRef(getImm(), VK, Imm);
+ else
+ IsValid = isInt<6>(Imm);
+ return IsValid &&
+ (VK == RISCVMCExpr::VK_RISCV_None || VK == RISCVMCExpr::VK_RISCV_LO);
+ }
+
bool isUImm6NonZero() const {
int64_t Imm;
RISCVMCExpr::VariantKind VK;
@@ -285,19 +298,6 @@ public:
VK == RISCVMCExpr::VK_RISCV_None;
}
- bool isSImm6() const {
- RISCVMCExpr::VariantKind VK;
- int64_t Imm;
- bool IsValid;
- bool IsConstantImm = evaluateConstantImm(Imm, VK);
- if (!IsConstantImm)
- IsValid = RISCVAsmParser::classifySymbolRef(getImm(), VK, Imm);
- else
- IsValid = isInt<6>(Imm);
- return IsValid &&
- (VK == RISCVMCExpr::VK_RISCV_None || VK == RISCVMCExpr::VK_RISCV_LO);
- }
-
bool isSImm12() const {
RISCVMCExpr::VariantKind VK;
int64_t Imm;
@@ -596,6 +596,9 @@ bool RISCVAsmParser::MatchAndEmitInstruc
return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 5) - 1);
case Match_InvalidUImm5NonZero:
return generateImmOutOfRangeError(Operands, ErrorInfo, 1, (1 << 5) - 1);
+ case Match_InvalidSImm6:
+ return generateImmOutOfRangeError(Operands, ErrorInfo, -(1 << 5),
+ (1 << 5) - 1);
case Match_InvalidUImm6NonZero:
return generateImmOutOfRangeError(Operands, ErrorInfo, 1, (1 << 6) - 1);
case Match_InvalidUImm7Lsb00:
@@ -622,9 +625,6 @@ bool RISCVAsmParser::MatchAndEmitInstruc
return generateImmOutOfRangeError(
Operands, ErrorInfo, 4, (1 << 10) - 4,
"immediate must be a multiple of 4 bytes in the range");
- case Match_InvalidSImm6:
- return generateImmOutOfRangeError(Operands, ErrorInfo, -(1 << 5),
- (1 << 5) - 1);
case Match_InvalidSImm10Lsb0000:
return generateImmOutOfRangeError(
Operands, ErrorInfo, -(1 << 9), (1 << 9) - 16,
Modified: llvm/trunk/lib/Target/RISCV/RISCVInstrInfoC.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/RISCVInstrInfoC.td?rev=320559&r1=320558&r2=320559&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/RISCVInstrInfoC.td (original)
+++ llvm/trunk/lib/Target/RISCV/RISCVInstrInfoC.td Wed Dec 13 01:41:21 2017
@@ -13,18 +13,18 @@ include "RISCVInstrFormatsC.td"
// Operand definitions.
//===----------------------------------------------------------------------===//
-def simm6 : Operand<XLenVT>, ImmLeaf<XLenVT, [{return isInt<6>(Imm);}]> {
- let ParserMatchClass = SImmAsmOperand<6>;
- let EncoderMethod = "getImmOpValue";
- let DecoderMethod = "decodeSImmOperand<6>";
-}
-
def uimm5nonzero : Operand<XLenVT>,
ImmLeaf<XLenVT, [{return isUInt<5>(Imm) && (Imm != 0);}]> {
let ParserMatchClass = UImmAsmOperand<5, "NonZero">;
let DecoderMethod = "decodeUImmOperand<5>";
}
+def simm6 : Operand<XLenVT>, ImmLeaf<XLenVT, [{return isInt<6>(Imm);}]> {
+ let ParserMatchClass = SImmAsmOperand<6>;
+ let EncoderMethod = "getImmOpValue";
+ let DecoderMethod = "decodeSImmOperand<6>";
+}
+
def uimm6nonzero : Operand<XLenVT>,
ImmLeaf<XLenVT, [{return isUInt<6>(Imm) && (Imm != 0);}]> {
let ParserMatchClass = UImmAsmOperand<6, "NonZero">;
More information about the llvm-commits
mailing list