[llvm] 09f48c6 - [RISCV] Move implementation of getVLOpNum and getSEWOpNum from RISCVInsertVSETVLI to RISCVBaseInfo.h. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed May 11 11:19:48 PDT 2022
Author: Craig Topper
Date: 2022-05-11T11:14:58-07:00
New Revision: 09f48c6b80a44f91cc8acae1406ce4224e0bfe42
URL: https://github.com/llvm/llvm-project/commit/09f48c6b80a44f91cc8acae1406ce4224e0bfe42
DIFF: https://github.com/llvm/llvm-project/commit/09f48c6b80a44f91cc8acae1406ce4224e0bfe42.diff
LOG: [RISCV] Move implementation of getVLOpNum and getSEWOpNum from RISCVInsertVSETVLI to RISCVBaseInfo.h. NFC
We should consolidate the operand counting and ordering into
RISCVBaseInfo.h and stop spreading it around.
Reviewed By: asb
Differential Revision: https://reviews.llvm.org/D125344
Added:
Modified:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
index 56c217eb77e66..b0b3dc4fe7df0 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
@@ -164,10 +164,30 @@ static inline bool isRVVWideningReduction(uint64_t TSFlags) {
return TSFlags & IsRVVWideningReductionMask;
}
/// \returns true if mask policy is valid for the instruction.
-static inline bool UsesMaskPolicy(uint64_t TSFlags) {
+static inline bool usesMaskPolicy(uint64_t TSFlags) {
return TSFlags & UsesMaskPolicyMask;
}
+static inline unsigned getVLOpNum(const MCInstrDesc &Desc) {
+ const uint64_t TSFlags = Desc.TSFlags;
+ // This method is only called if we expect to have a VL operand, and all
+ // instructions with VL also have SEW.
+ assert(hasSEWOp(TSFlags) && hasVLOp(TSFlags));
+ unsigned Offset = 2;
+ if (hasVecPolicyOp(TSFlags))
+ Offset = 3;
+ return Desc.getNumOperands() - Offset;
+}
+
+static inline unsigned getSEWOpNum(const MCInstrDesc &Desc) {
+ const uint64_t TSFlags = Desc.TSFlags;
+ assert(hasSEWOp(TSFlags));
+ unsigned Offset = 1;
+ if (hasVecPolicyOp(TSFlags))
+ Offset = 2;
+ return Desc.getNumOperands() - Offset;
+}
+
// RISC-V Specific Machine Operand Flags
enum {
MO_None = 0,
diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index b0b911572506f..085ba3fd6c477 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -544,23 +544,11 @@ static bool isScalarMoveInstr(const MachineInstr &MI) {
}
static unsigned getVLOpNum(const MachineInstr &MI) {
- const uint64_t TSFlags = MI.getDesc().TSFlags;
- // This method is only called if we expect to have a VL operand, and all
- // instructions with VL also have SEW.
- assert(RISCVII::hasSEWOp(TSFlags) && RISCVII::hasVLOp(TSFlags));
- unsigned Offset = 2;
- if (RISCVII::hasVecPolicyOp(TSFlags))
- Offset = 3;
- return MI.getNumExplicitOperands() - Offset;
+ return RISCVII::getVLOpNum(MI.getDesc());
}
static unsigned getSEWOpNum(const MachineInstr &MI) {
- const uint64_t TSFlags = MI.getDesc().TSFlags;
- assert(RISCVII::hasSEWOp(TSFlags));
- unsigned Offset = 1;
- if (RISCVII::hasVecPolicyOp(TSFlags))
- Offset = 2;
- return MI.getNumExplicitOperands() - Offset;
+ return RISCVII::getSEWOpNum(MI.getDesc());
}
static VSETVLIInfo computeInfoForInstr(const MachineInstr &MI, uint64_t TSFlags,
@@ -572,7 +560,7 @@ static VSETVLIInfo computeInfoForInstr(const MachineInstr &MI, uint64_t TSFlags,
// destination is tied to a source. Unless the source is undef. In that case
// the user would have some control over the policy values.
bool TailAgnostic = true;
- bool UsesMaskPolicy = RISCVII::UsesMaskPolicy(TSFlags);
+ bool UsesMaskPolicy = RISCVII::usesMaskPolicy(TSFlags);
// FIXME: Could we look at the above or below instructions to choose the
// matched mask policy to reduce vsetvli instructions? Default mask policy is
// agnostic if instructions use mask policy, otherwise is undisturbed. Because
More information about the llvm-commits
mailing list