Skip to content

Commit 91085c6

Browse files
committed
Fixups
1 parent 54c6244 commit 91085c6

File tree

5 files changed

+44
-44
lines changed

5 files changed

+44
-44
lines changed

llvm/include/llvm/IR/StructWideningUtils.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- StructWideningUtils.h - Utils for widening/narrowing struct types ===//
1+
//===--- StructWideningUtils.h - Utils for vectorizing struct types -------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -19,15 +19,15 @@ inline bool isUnpackedStructLiteral(StructType *StructTy) {
1919

2020
/// A helper for converting structs of scalar types to structs of vector types.
2121
/// Note: Only unpacked literal struct types are supported.
22-
Type *toWideStructTy(StructType *StructTy, ElementCount EC);
22+
Type *toVectorizedStructTy(StructType *StructTy, ElementCount EC);
2323

2424
/// A helper for converting structs of vector types to structs of scalar types.
2525
/// Note: Only unpacked literal struct types are supported.
26-
Type *toNarrowStructTy(StructType *StructTy);
26+
Type *toScalarizedStructTy(StructType *StructTy);
2727

2828
/// Returns true if `StructTy` is an unpacked literal struct where all elements
2929
/// are vectors of matching element count. This does not include empty structs.
30-
bool isWideStructTy(StructType *StructTy);
30+
bool isVectorizedStructTy(StructType *StructTy);
3131

3232
} // namespace llvm
3333

llvm/include/llvm/IR/VectorUtils.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,31 @@ inline Type *ToVectorTy(Type *Scalar, unsigned VF) {
2727
return ToVectorTy(Scalar, ElementCount::getFixed(VF));
2828
}
2929

30-
/// A helper for converting to wider (vector) types. For scalar types, this is
30+
/// A helper for converting to vectorized types. For scalar types, this is
3131
/// equivalent to calling `ToVectorTy`. For struct types, this returns a new
3232
/// struct where each element type has been widened to a vector type. Note: Only
3333
/// unpacked literal struct types are supported.
34-
inline Type *ToWideTy(Type *Ty, ElementCount EC) {
34+
inline Type *toVectorizedTy(Type *Ty, ElementCount EC) {
3535
if (StructType *StructTy = dyn_cast<StructType>(Ty))
36-
return toWideStructTy(StructTy, EC);
36+
return toVectorizedStructTy(StructTy, EC);
3737
return ToVectorTy(Ty, EC);
3838
}
3939

40-
/// A helper for converting wide types to narrow (non-vector) types. For vector
41-
/// types, this is equivalent to calling .getScalarType(). For struct types,
42-
/// this returns a new struct where each element type has been converted to a
43-
/// scalar type. Note: Only unpacked literal struct types are supported.
44-
inline Type *ToNarrowTy(Type *Ty) {
40+
/// A helper for converting vectorized types to scalarized (non-vector) types.
41+
/// For vector types, this is equivalent to calling .getScalarType(). For struct
42+
/// types, this returns a new struct where each element type has been converted
43+
/// to a scalar type. Note: Only unpacked literal struct types are supported.
44+
inline Type *toScalarizedTy(Type *Ty) {
4545
if (StructType *StructTy = dyn_cast<StructType>(Ty))
46-
return toNarrowStructTy(StructTy);
46+
return toScalarizedStructTy(StructTy);
4747
return Ty->getScalarType();
4848
}
4949

5050
/// Returns true if `Ty` is a vector type or a struct of vector types where all
5151
/// vector types share the same VF.
52-
inline bool isWideTy(Type *Ty) {
52+
inline bool isVectorizedTy(Type *Ty) {
5353
if (StructType *StructTy = dyn_cast<StructType>(Ty))
54-
return isWideStructTy(StructTy);
54+
return isVectorizedStructTy(StructTy);
5555
return Ty->isVectorTy();
5656
}
5757

@@ -63,9 +63,9 @@ inline ArrayRef<Type *> getContainedTypes(Type *const &Ty) {
6363
return ArrayRef<Type *>(&Ty, 1);
6464
}
6565

66-
/// Returns the number of vector elements for a widened type.
67-
inline ElementCount getWideTypeVF(Type *Ty) {
68-
assert(isWideTy(Ty) && "expected widened type");
66+
/// Returns the number of vector elements for a vectorized type.
67+
inline ElementCount getVectorizedTypeVF(Type *Ty) {
68+
assert(isVectorizedTy(Ty) && "expected widened type");
6969
return cast<VectorType>(getContainedTypes(Ty).front())->getElementCount();
7070
}
7171

llvm/lib/IR/StructWideningUtils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- StructWideningUtils.cpp - Utils for widening/narrowing struct types ===//
1+
//===- StructWideningUtils.cpp - Utils for vectorizing struct types------- ===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,7 +14,7 @@ using namespace llvm;
1414

1515
/// A helper for converting structs of scalar types to structs of vector types.
1616
/// Note: Only unpacked literal struct types are supported.
17-
Type *llvm::toWideStructTy(StructType *StructTy, ElementCount EC) {
17+
Type *llvm::toVectorizedStructTy(StructType *StructTy, ElementCount EC) {
1818
if (EC.isScalar())
1919
return StructTy;
2020
assert(isUnpackedStructLiteral(StructTy) &&
@@ -30,7 +30,7 @@ Type *llvm::toWideStructTy(StructType *StructTy, ElementCount EC) {
3030

3131
/// A helper for converting structs of vector types to structs of scalar types.
3232
/// Note: Only unpacked literal struct types are supported.
33-
Type *llvm::toNarrowStructTy(StructType *StructTy) {
33+
Type *llvm::toScalarizedStructTy(StructType *StructTy) {
3434
assert(isUnpackedStructLiteral(StructTy) &&
3535
"expected unpacked struct literal");
3636
return StructType::get(
@@ -42,7 +42,7 @@ Type *llvm::toNarrowStructTy(StructType *StructTy) {
4242

4343
/// Returns true if `StructTy` is an unpacked literal struct where all elements
4444
/// are vectors of matching element count. This does not include empty structs.
45-
bool llvm::isWideStructTy(StructType *StructTy) {
45+
bool llvm::isVectorizedStructTy(StructType *StructTy) {
4646
if (!isUnpackedStructLiteral(StructTy))
4747
return false;
4848
auto ElemTys = StructTy->elements();

llvm/lib/IR/VFABIDemangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ FunctionType *VFABI::createFunctionType(const VFInfo &Info,
575575

576576
auto *RetTy = ScalarFTy->getReturnType();
577577
if (!RetTy->isVoidTy())
578-
RetTy = ToWideTy(RetTy, VF);
578+
RetTy = toVectorizedTy(RetTy, VF);
579579
return FunctionType::get(RetTy, VecTypes, false);
580580
}
581581

llvm/unittests/IR/VectorUtilsTest.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace {
1717

1818
class VectorUtilsTest : public ::testing::Test {};
1919

20-
TEST(VectorUtilsTest, TestToWideTy) {
20+
TEST(VectorUtilsTest, TestToVectorizedTy) {
2121
LLVMContext C;
2222

2323
Type *ITy = Type::getInt32Ty(C);
@@ -28,15 +28,15 @@ TEST(VectorUtilsTest, TestToWideTy) {
2828

2929
for (ElementCount VF :
3030
{ElementCount::getFixed(4), ElementCount::getScalable(2)}) {
31-
Type *IntVec = ToWideTy(ITy, VF);
31+
Type *IntVec = toVectorizedTy(ITy, VF);
3232
EXPECT_TRUE(isa<VectorType>(IntVec));
3333
EXPECT_EQ(IntVec, VectorType::get(ITy, VF));
3434

35-
Type *FloatVec = ToWideTy(FTy, VF);
35+
Type *FloatVec = toVectorizedTy(FTy, VF);
3636
EXPECT_TRUE(isa<VectorType>(FloatVec));
3737
EXPECT_EQ(FloatVec, VectorType::get(FTy, VF));
3838

39-
Type *WideHomogeneousStructTy = ToWideTy(HomogeneousStructTy, VF);
39+
Type *WideHomogeneousStructTy = toVectorizedTy(HomogeneousStructTy, VF);
4040
EXPECT_TRUE(isa<StructType>(WideHomogeneousStructTy));
4141
EXPECT_TRUE(
4242
cast<StructType>(WideHomogeneousStructTy)->containsHomogeneousTypes());
@@ -45,24 +45,24 @@ TEST(VectorUtilsTest, TestToWideTy) {
4545
EXPECT_TRUE(cast<StructType>(WideHomogeneousStructTy)->getElementType(0) ==
4646
VectorType::get(FTy, VF));
4747

48-
Type *WideMixedStructTy = ToWideTy(MixedStructTy, VF);
48+
Type *WideMixedStructTy = toVectorizedTy(MixedStructTy, VF);
4949
EXPECT_TRUE(isa<StructType>(WideMixedStructTy));
5050
EXPECT_TRUE(cast<StructType>(WideMixedStructTy)->getNumElements() == 2);
5151
EXPECT_TRUE(cast<StructType>(WideMixedStructTy)->getElementType(0) ==
5252
VectorType::get(FTy, VF));
5353
EXPECT_TRUE(cast<StructType>(WideMixedStructTy)->getElementType(1) ==
5454
VectorType::get(ITy, VF));
5555

56-
EXPECT_EQ(ToWideTy(VoidTy, VF), VoidTy);
56+
EXPECT_EQ(toVectorizedTy(VoidTy, VF), VoidTy);
5757
}
5858

5959
ElementCount ScalarVF = ElementCount::getFixed(1);
6060
for (Type *Ty : {ITy, FTy, HomogeneousStructTy, MixedStructTy, VoidTy}) {
61-
EXPECT_EQ(ToWideTy(Ty, ScalarVF), Ty);
61+
EXPECT_EQ(toVectorizedTy(Ty, ScalarVF), Ty);
6262
}
6363
}
6464

65-
TEST(VectorUtilsTest, TestToNarrowTy) {
65+
TEST(VectorUtilsTest, TestToScalarizedTy) {
6666
LLVMContext C;
6767

6868
Type *ITy = Type::getInt32Ty(C);
@@ -74,8 +74,8 @@ TEST(VectorUtilsTest, TestToNarrowTy) {
7474
for (ElementCount VF : {ElementCount::getFixed(1), ElementCount::getFixed(4),
7575
ElementCount::getScalable(2)}) {
7676
for (Type *Ty : {ITy, FTy, HomogeneousStructTy, MixedStructTy, VoidTy}) {
77-
// ToNarrowTy should be the inverse of ToWideTy.
78-
EXPECT_EQ(ToNarrowTy(ToWideTy(Ty, VF)), Ty);
77+
// toScalarizedTy should be the inverse of toVectorizedTy.
78+
EXPECT_EQ(toScalarizedTy(toVectorizedTy(Ty, VF)), Ty);
7979
};
8080
}
8181
}
@@ -97,40 +97,40 @@ TEST(VectorUtilsTest, TestGetContainedTypes) {
9797
EXPECT_EQ(getContainedTypes(MixedStructTy), ArrayRef<Type *>({FTy, ITy}));
9898
}
9999

100-
TEST(VectorUtilsTest, TestIsWideTy) {
100+
TEST(VectorUtilsTest, TestIsVectorizedTy) {
101101
LLVMContext C;
102102

103103
Type *ITy = Type::getInt32Ty(C);
104104
Type *FTy = Type::getFloatTy(C);
105105
Type *NarrowStruct = StructType::get(FTy, ITy);
106106
Type *VoidTy = Type::getVoidTy(C);
107107

108-
EXPECT_FALSE(isWideTy(ITy));
109-
EXPECT_FALSE(isWideTy(NarrowStruct));
110-
EXPECT_FALSE(isWideTy(VoidTy));
108+
EXPECT_FALSE(isVectorizedTy(ITy));
109+
EXPECT_FALSE(isVectorizedTy(NarrowStruct));
110+
EXPECT_FALSE(isVectorizedTy(VoidTy));
111111

112112
ElementCount VF = ElementCount::getFixed(4);
113-
EXPECT_TRUE(isWideTy(ToWideTy(ITy, VF)));
114-
EXPECT_TRUE(isWideTy(ToWideTy(NarrowStruct, VF)));
113+
EXPECT_TRUE(isVectorizedTy(toVectorizedTy(ITy, VF)));
114+
EXPECT_TRUE(isVectorizedTy(toVectorizedTy(NarrowStruct, VF)));
115115

116116
Type *MixedVFStruct =
117117
StructType::get(VectorType::get(ITy, ElementCount::getFixed(2)),
118118
VectorType::get(ITy, ElementCount::getFixed(4)));
119-
EXPECT_FALSE(isWideTy(MixedVFStruct));
119+
EXPECT_FALSE(isVectorizedTy(MixedVFStruct));
120120

121121
// Currently only literals types are considered wide.
122122
Type *NamedWideStruct = StructType::create("Named", VectorType::get(ITy, VF),
123123
VectorType::get(ITy, VF));
124-
EXPECT_FALSE(isWideTy(NamedWideStruct));
124+
EXPECT_FALSE(isVectorizedTy(NamedWideStruct));
125125

126126
// Currently only unpacked types are considered wide.
127127
Type *PackedWideStruct = StructType::get(
128128
C, ArrayRef<Type *>{VectorType::get(ITy, VF), VectorType::get(ITy, VF)},
129129
/*isPacked=*/true);
130-
EXPECT_FALSE(isWideTy(PackedWideStruct));
130+
EXPECT_FALSE(isVectorizedTy(PackedWideStruct));
131131
}
132132

133-
TEST(VectorUtilsTest, TestGetWideTypeVF) {
133+
TEST(VectorUtilsTest, TestGetVectorizedTypeVF) {
134134
LLVMContext C;
135135

136136
Type *ITy = Type::getInt32Ty(C);
@@ -141,7 +141,7 @@ TEST(VectorUtilsTest, TestGetWideTypeVF) {
141141
for (ElementCount VF :
142142
{ElementCount::getFixed(4), ElementCount::getScalable(2)}) {
143143
for (Type *Ty : {ITy, FTy, HomogeneousStructTy, MixedStructTy}) {
144-
EXPECT_EQ(getWideTypeVF(ToWideTy(Ty, VF)), VF);
144+
EXPECT_EQ(getVectorizedTypeVF(toVectorizedTy(Ty, VF)), VF);
145145
};
146146
}
147147
}

0 commit comments

Comments
 (0)