1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[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
This commit is contained in:
Craig Topper 2021-05-28 11:28:45 -07:00
parent 7d56e782b7
commit 22fc6f8fbe
4 changed files with 33 additions and 33 deletions

View File

@ -389,14 +389,14 @@ public:
/// 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 @@ public:
// 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 @@ public:
// 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.

View File

@ -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);

View File

@ -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;

View File

@ -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;