[llvm] 2830d92 - [VP] Make getMaskParamPos/getVectorLengthParamPos return unsigned. Lowercase function names.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri May 28 11:43:50 PDT 2021
Author: Craig Topper
Date: 2021-05-28T11:28:47-07:00
New Revision: 2830d924b0873b33413320650806376dbf6ee9d1
URL: https://github.com/llvm/llvm-project/commit/2830d924b0873b33413320650806376dbf6ee9d1
DIFF: https://github.com/llvm/llvm-project/commit/2830d924b0873b33413320650806376dbf6ee9d1.diff
LOG: [VP] Make getMaskParamPos/getVectorLengthParamPos return unsigned. Lowercase function names.
Parameter positions seem like they should be unsigned.
While there, make function names lowercase per coding standards.
Reviewed By: frasercrmck
Differential Revision: https://reviews.llvm.org/D103224
Added:
Modified:
llvm/include/llvm/IR/IntrinsicInst.h
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/IntrinsicInst.cpp
llvm/unittests/IR/VPIntrinsicTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/IntrinsicInst.h b/llvm/include/llvm/IR/IntrinsicInst.h
index c3aed52c05f4c..338103a82ee87 100644
--- a/llvm/include/llvm/IR/IntrinsicInst.h
+++ b/llvm/include/llvm/IR/IntrinsicInst.h
@@ -389,14 +389,14 @@ class DbgLabelInst : public DbgInfoIntrinsic {
/// This is the common base class for vector predication intrinsics.
class VPIntrinsic : public IntrinsicInst {
public:
- static Optional<int> GetMaskParamPos(Intrinsic::ID IntrinsicID);
- static Optional<int> GetVectorLengthParamPos(Intrinsic::ID IntrinsicID);
+ static Optional<unsigned> getMaskParamPos(Intrinsic::ID IntrinsicID);
+ static Optional<unsigned> getVectorLengthParamPos(Intrinsic::ID IntrinsicID);
/// The llvm.vp.* intrinsics for this instruction Opcode
- static Intrinsic::ID GetForOpcode(unsigned OC);
+ static Intrinsic::ID getForOpcode(unsigned OC);
// Whether \p ID is a VP intrinsic ID.
- static bool IsVPIntrinsic(Intrinsic::ID);
+ static bool isVPIntrinsic(Intrinsic::ID);
/// \return the mask parameter or nullptr.
Value *getMaskParam() const;
@@ -415,7 +415,7 @@ class VPIntrinsic : public IntrinsicInst {
// Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const IntrinsicInst *I) {
- return IsVPIntrinsic(I->getIntrinsicID());
+ return isVPIntrinsic(I->getIntrinsicID());
}
static bool classof(const Value *V) {
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
@@ -423,11 +423,11 @@ class VPIntrinsic : public IntrinsicInst {
// Equivalent non-predicated opcode
Optional<unsigned> getFunctionalOpcode() const {
- return GetFunctionalOpcodeForVP(getIntrinsicID());
+ return getFunctionalOpcodeForVP(getIntrinsicID());
}
// Equivalent non-predicated opcode
- static Optional<unsigned> GetFunctionalOpcodeForVP(Intrinsic::ID ID);
+ static Optional<unsigned> getFunctionalOpcodeForVP(Intrinsic::ID ID);
};
/// This is the common base class for constrained floating point intrinsics.
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index ab77ef4a2d8be..3594756f433cb 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -7305,7 +7305,7 @@ void SelectionDAGBuilder::visitVectorPredicationIntrinsic(
SDVTList VTs = DAG.getVTList(ValueVTs);
auto EVLParamPos =
- VPIntrinsic::GetVectorLengthParamPos(VPIntrin.getIntrinsicID());
+ VPIntrinsic::getVectorLengthParamPos(VPIntrin.getIntrinsicID());
MVT EVLParamVT = TLI.getVPExplicitVectorLengthTy();
assert(EVLParamVT.isScalarInteger() && EVLParamVT.bitsGE(MVT::i32) &&
@@ -7313,7 +7313,7 @@ void SelectionDAGBuilder::visitVectorPredicationIntrinsic(
// Request operands.
SmallVector<SDValue, 7> OpValues;
- for (int I = 0; I < (int)VPIntrin.getNumArgOperands(); ++I) {
+ for (unsigned I = 0; I < VPIntrin.getNumArgOperands(); ++I) {
auto Op = getValue(VPIntrin.getArgOperand(I));
if (I == EVLParamPos)
Op = DAG.getNode(ISD::ZERO_EXTEND, DL, EVLParamVT, Op);
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index d54b169e1e86a..37ee2f34a4042 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -288,35 +288,34 @@ ElementCount VPIntrinsic::getStaticVectorLength() const {
return ElemCount;
};
- auto VPMask = getMaskParam();
+ Value *VPMask = getMaskParam();
+ assert(VPMask && "No mask param?");
return GetVectorLengthOfType(VPMask->getType());
}
Value *VPIntrinsic::getMaskParam() const {
- auto maskPos = GetMaskParamPos(getIntrinsicID());
- if (maskPos)
- return getArgOperand(maskPos.getValue());
+ if (auto MaskPos = getMaskParamPos(getIntrinsicID()))
+ return getArgOperand(MaskPos.getValue());
return nullptr;
}
void VPIntrinsic::setMaskParam(Value *NewMask) {
- auto MaskPos = GetMaskParamPos(getIntrinsicID());
+ auto MaskPos = getMaskParamPos(getIntrinsicID());
setArgOperand(*MaskPos, NewMask);
}
Value *VPIntrinsic::getVectorLengthParam() const {
- auto vlenPos = GetVectorLengthParamPos(getIntrinsicID());
- if (vlenPos)
- return getArgOperand(vlenPos.getValue());
+ if (auto EVLPos = getVectorLengthParamPos(getIntrinsicID()))
+ return getArgOperand(EVLPos.getValue());
return nullptr;
}
void VPIntrinsic::setVectorLengthParam(Value *NewEVL) {
- auto EVLPos = GetVectorLengthParamPos(getIntrinsicID());
+ auto EVLPos = getVectorLengthParamPos(getIntrinsicID());
setArgOperand(*EVLPos, NewEVL);
}
-Optional<int> VPIntrinsic::GetMaskParamPos(Intrinsic::ID IntrinsicID) {
+Optional<unsigned> VPIntrinsic::getMaskParamPos(Intrinsic::ID IntrinsicID) {
switch (IntrinsicID) {
default:
return None;
@@ -328,7 +327,8 @@ Optional<int> VPIntrinsic::GetMaskParamPos(Intrinsic::ID IntrinsicID) {
}
}
-Optional<int> VPIntrinsic::GetVectorLengthParamPos(Intrinsic::ID IntrinsicID) {
+Optional<unsigned>
+VPIntrinsic::getVectorLengthParamPos(Intrinsic::ID IntrinsicID) {
switch (IntrinsicID) {
default:
return None;
@@ -340,7 +340,7 @@ Optional<int> VPIntrinsic::GetVectorLengthParamPos(Intrinsic::ID IntrinsicID) {
}
}
-bool VPIntrinsic::IsVPIntrinsic(Intrinsic::ID ID) {
+bool VPIntrinsic::isVPIntrinsic(Intrinsic::ID ID) {
switch (ID) {
default:
return false;
@@ -354,7 +354,7 @@ bool VPIntrinsic::IsVPIntrinsic(Intrinsic::ID ID) {
}
// Equivalent non-predicated opcode
-Optional<unsigned> VPIntrinsic::GetFunctionalOpcodeForVP(Intrinsic::ID ID) {
+Optional<unsigned> VPIntrinsic::getFunctionalOpcodeForVP(Intrinsic::ID ID) {
Optional<unsigned> FunctionalOC;
switch (ID) {
default:
@@ -368,7 +368,7 @@ Optional<unsigned> VPIntrinsic::GetFunctionalOpcodeForVP(Intrinsic::ID ID) {
return FunctionalOC;
}
-Intrinsic::ID VPIntrinsic::GetForOpcode(unsigned IROPC) {
+Intrinsic::ID VPIntrinsic::getForOpcode(unsigned IROPC) {
switch (IROPC) {
default:
return Intrinsic::not_intrinsic;
diff --git a/llvm/unittests/IR/VPIntrinsicTest.cpp b/llvm/unittests/IR/VPIntrinsicTest.cpp
index cfa68c8c8e318..ce77fe437dcf8 100644
--- a/llvm/unittests/IR/VPIntrinsicTest.cpp
+++ b/llvm/unittests/IR/VPIntrinsicTest.cpp
@@ -81,7 +81,7 @@ TEST_F(VPIntrinsicTest, VPModuleComplete) {
std::set<Intrinsic::ID> SeenIDs;
for (const auto &VPDecl : *M) {
ASSERT_TRUE(VPDecl.isIntrinsic());
- ASSERT_TRUE(VPIntrinsic::IsVPIntrinsic(VPDecl.getIntrinsicID()));
+ ASSERT_TRUE(VPIntrinsic::isVPIntrinsic(VPDecl.getIntrinsicID()));
SeenIDs.insert(VPDecl.getIntrinsicID());
}
@@ -145,23 +145,23 @@ TEST_F(VPIntrinsicTest, CanIgnoreVectorLength) {
}
/// Check that the argument returned by
-/// VPIntrinsic::Get<X>ParamPos(Intrinsic::ID) has the expected type.
+/// VPIntrinsic::get<X>ParamPos(Intrinsic::ID) has the expected type.
TEST_F(VPIntrinsicTest, GetParamPos) {
std::unique_ptr<Module> M = CreateVPDeclarationModule();
assert(M);
for (Function &F : *M) {
ASSERT_TRUE(F.isIntrinsic());
- Optional<int> MaskParamPos =
- VPIntrinsic::GetMaskParamPos(F.getIntrinsicID());
+ Optional<unsigned> MaskParamPos =
+ VPIntrinsic::getMaskParamPos(F.getIntrinsicID());
if (MaskParamPos.hasValue()) {
Type *MaskParamType = F.getArg(MaskParamPos.getValue())->getType();
ASSERT_TRUE(MaskParamType->isVectorTy());
ASSERT_TRUE(cast<VectorType>(MaskParamType)->getElementType()->isIntegerTy(1));
}
- Optional<int> VecLenParamPos =
- VPIntrinsic::GetVectorLengthParamPos(F.getIntrinsicID());
+ Optional<unsigned> VecLenParamPos =
+ VPIntrinsic::getVectorLengthParamPos(F.getIntrinsicID());
if (VecLenParamPos.hasValue()) {
Type *VecLenParamType = F.getArg(VecLenParamPos.getValue())->getType();
ASSERT_TRUE(VecLenParamType->isIntegerTy(32));
@@ -182,13 +182,13 @@ TEST_F(VPIntrinsicTest, OpcodeRoundTrip) {
unsigned FullTripCounts = 0;
for (unsigned OC : Opcodes) {
- Intrinsic::ID VPID = VPIntrinsic::GetForOpcode(OC);
+ Intrinsic::ID VPID = VPIntrinsic::getForOpcode(OC);
// No equivalent VP intrinsic available.
if (VPID == Intrinsic::not_intrinsic)
continue;
Optional<unsigned> RoundTripOC =
- VPIntrinsic::GetFunctionalOpcodeForVP(VPID);
+ VPIntrinsic::getFunctionalOpcodeForVP(VPID);
// No equivalent Opcode available.
if (!RoundTripOC)
continue;
@@ -208,13 +208,13 @@ TEST_F(VPIntrinsicTest, IntrinsicIDRoundTrip) {
unsigned FullTripCounts = 0;
for (const auto &VPDecl : *M) {
auto VPID = VPDecl.getIntrinsicID();
- Optional<unsigned> OC = VPIntrinsic::GetFunctionalOpcodeForVP(VPID);
+ Optional<unsigned> OC = VPIntrinsic::getFunctionalOpcodeForVP(VPID);
// no equivalent Opcode available
if (!OC)
continue;
- Intrinsic::ID RoundTripVPID = VPIntrinsic::GetForOpcode(*OC);
+ Intrinsic::ID RoundTripVPID = VPIntrinsic::getForOpcode(*OC);
ASSERT_EQ(RoundTripVPID, VPID);
++FullTripCounts;
More information about the llvm-commits
mailing list