[llvm] fdaa23a - [RISCV] Remove VConstraintType enum and getConstraint. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 20 00:24:23 PDT 2023
Author: Craig Topper
Date: 2023-04-20T00:21:24-07:00
New Revision: fdaa23a7bd4e500f72df1eb02c236f79084ac17a
URL: https://github.com/llvm/llvm-project/commit/fdaa23a7bd4e500f72df1eb02c236f79084ac17a
DIFF: https://github.com/llvm/llvm-project/commit/fdaa23a7bd4e500f72df1eb02c236f79084ac17a.diff
LOG: [RISCV] Remove VConstraintType enum and getConstraint. NFC
Fold the 3 flag defines into the enum that defines TSFlags. Then
we don't have to extract them we can just test the bits directly
in TSFlags.
Reviewed By: frasercrmck
Differential Revision: https://reviews.llvm.org/D148765
Added:
Modified:
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 4f6d6d206d602..e930bb6d21e41 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2932,8 +2932,7 @@ bool RISCVAsmParser::validateInstruction(MCInst &Inst,
}
const MCInstrDesc &MCID = MII.get(Opcode);
- RISCVII::VConstraintType Constraints = RISCVII::getConstraint(MCID.TSFlags);
- if (Constraints == RISCVII::NoConstraint)
+ if (!(MCID.TSFlags & RISCVII::ConstraintMask))
return false;
if (Opcode == RISCV::VC_V_XVW || Opcode == RISCV::VC_V_IVW ||
@@ -2941,13 +2940,13 @@ bool RISCVAsmParser::validateInstruction(MCInst &Inst,
// Operands Opcode, Dst, uimm, Dst, Rs2, Rs1 for VC_V_XVW.
unsigned VCIXDst = Inst.getOperand(0).getReg();
SMLoc VCIXDstLoc = Operands[2]->getStartLoc();
- if (Constraints & RISCVII::VS1Constraint) {
+ if (MCID.TSFlags & RISCVII::VS1Constraint) {
unsigned VCIXRs1 = Inst.getOperand(Inst.getNumOperands() - 1).getReg();
if (VCIXDst == VCIXRs1)
return Error(VCIXDstLoc, "The destination vector register group cannot"
" overlap the source vector register group.");
}
- if (Constraints & RISCVII::VS2Constraint) {
+ if (MCID.TSFlags & RISCVII::VS2Constraint) {
unsigned VCIXRs2 = Inst.getOperand(Inst.getNumOperands() - 2).getReg();
if (VCIXDst == VCIXRs2)
return Error(VCIXDstLoc, "The destination vector register group cannot"
@@ -2959,19 +2958,19 @@ bool RISCVAsmParser::validateInstruction(MCInst &Inst,
unsigned DestReg = Inst.getOperand(0).getReg();
// Operands[1] will be the first operand, DestReg.
SMLoc Loc = Operands[1]->getStartLoc();
- if (Constraints & RISCVII::VS2Constraint) {
+ if (MCID.TSFlags & RISCVII::VS2Constraint) {
unsigned CheckReg = Inst.getOperand(1).getReg();
if (DestReg == CheckReg)
return Error(Loc, "The destination vector register group cannot overlap"
" the source vector register group.");
}
- if ((Constraints & RISCVII::VS1Constraint) && (Inst.getOperand(2).isReg())) {
+ if ((MCID.TSFlags & RISCVII::VS1Constraint) && (Inst.getOperand(2).isReg())) {
unsigned CheckReg = Inst.getOperand(2).getReg();
if (DestReg == CheckReg)
return Error(Loc, "The destination vector register group cannot overlap"
" the source vector register group.");
}
- if ((Constraints & RISCVII::VMConstraint) && (DestReg == RISCV::V0)) {
+ if ((MCID.TSFlags & RISCVII::VMConstraint) && (DestReg == RISCV::V0)) {
// vadc, vsbc are special cases. These instructions have no mask register.
// The destination register could not be V0.
if (Opcode == RISCV::VADC_VVM || Opcode == RISCV::VADC_VXM ||
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
index a6aeb80643a6e..f60726ec69078 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
@@ -56,6 +56,9 @@ enum {
InstFormatShift = 0,
ConstraintShift = InstFormatShift + 5,
+ VS2Constraint = 0b001 << ConstraintShift,
+ VS1Constraint = 0b010 << ConstraintShift,
+ VMConstraint = 0b100 << ConstraintShift,
ConstraintMask = 0b111 << ConstraintShift,
VLMulShift = ConstraintShift + 3,
@@ -111,14 +114,6 @@ enum {
IsSignExtendingOpWMask = 1ULL << IsSignExtendingOpWShift,
};
-// Match with the definitions in RISCVInstrFormats.td
-enum VConstraintType {
- NoConstraint = 0,
- VS2Constraint = 0b001,
- VS1Constraint = 0b010,
- VMConstraint = 0b100,
-};
-
enum VLMUL : uint8_t {
LMUL_1 = 0,
LMUL_2,
@@ -141,11 +136,6 @@ enum {
static inline unsigned getFormat(uint64_t TSFlags) {
return (TSFlags & InstFormatMask) >> InstFormatShift;
}
-/// \returns the constraint for the instruction.
-static inline VConstraintType getConstraint(uint64_t TSFlags) {
- return static_cast<VConstraintType>((TSFlags & ConstraintMask) >>
- ConstraintShift);
-}
/// \returns the LMUL for the instruction.
static inline VLMUL getLMul(uint64_t TSFlags) {
return static_cast<VLMUL>((TSFlags & VLMulMask) >> VLMulShift);
More information about the llvm-commits
mailing list