Skip to content

Commit 26852e9

Browse files
committed
Merge pull request '[VE][nfci] Internalize CustomDAG helper functions' (#656) from feature/cleanup into develop
2 parents 43184b3 + 4bfb2ef commit 26852e9

File tree

2 files changed

+98
-75
lines changed

2 files changed

+98
-75
lines changed

llvm/lib/Target/VE/CustomDAG.cpp

Lines changed: 83 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,98 @@
2525

2626
namespace llvm {
2727

28+
2829
/// Packing {
2930

31+
bool isPackedMaskType(EVT SomeVT) {
32+
return isPackedType(SomeVT) && isMaskType(SomeVT);
33+
}
3034
template <> Packing getPackingForMaskBits(const LaneBits MB) {
3135
return Packing::Normal;
3236
}
3337
template <> Packing getPackingForMaskBits(const PackedLaneBits MB) {
3438
return Packing::Dense;
3539
}
3640

41+
PackElem getPartForLane(unsigned ElemIdx) {
42+
return (ElemIdx % 2 == 0) ? PackElem::Hi : PackElem::Lo;
43+
}
44+
45+
PackElem getOtherPart(PackElem Part) {
46+
return Part == PackElem::Lo ? PackElem::Hi : PackElem::Lo;
47+
}
48+
49+
unsigned getOverPackedSubRegIdx(PackElem Part) {
50+
return Part == PackElem::Lo ? VE::sub_pack_lo : VE::sub_pack_hi;
51+
}
52+
53+
unsigned getPackedMaskSubRegIdx(PackElem Part) {
54+
return Part == PackElem::Lo ? VE::sub_vm_lo : VE::sub_vm_hi;
55+
}
56+
57+
MVT getMaskVT(Packing P) {
58+
return P == Packing::Normal ? MVT::v256i1 : MVT::v512i1;
59+
}
60+
61+
PackElem getPackElemForVT(EVT VT) {
62+
if (VT.isFloatingPoint())
63+
return PackElem::Hi;
64+
if (VT.isVector())
65+
return getPackElemForVT(VT.getVectorElementType());
66+
return PackElem::Lo;
67+
}
68+
69+
// The subregister VT an unpack of part \p Elem from \p VT would source its
70+
// result from.
71+
MVT getUnpackSourceType(EVT VT, PackElem Elem) {
72+
if (!VT.isVector())
73+
return Elem == PackElem::Hi ? MVT::f32 : MVT::i32;
74+
75+
EVT ElemVT = VT.getVectorElementType();
76+
if (isMaskType(VT))
77+
return MVT::v256i1;
78+
if (isOverPackedType(VT))
79+
return ElemVT.isFloatingPoint() ? MVT::v256f64 : MVT::v256i64;
80+
return ElemVT.isFloatingPoint() ? MVT::v256f32 : MVT::v256i32;
81+
}
82+
83+
Packing getPackingForVT(EVT VT) {
84+
assert(VT.isVector());
85+
return isPackedType(VT) ? Packing::Dense : Packing::Normal;
86+
}
87+
88+
// True, iff this is a VEC_UNPACK_LO/HI, VEC_SWAP or VEC_PACK.
89+
bool isPackingSupportOpcode(unsigned Opcode) {
90+
switch (Opcode) {
91+
case VEISD::VEC_UNPACK_LO:
92+
case VEISD::VEC_UNPACK_HI:
93+
case VEISD::VEC_PACK:
94+
case VEISD::VEC_SWAP:
95+
return true;
96+
}
97+
return false;
98+
}
99+
100+
bool isUnpackOp(unsigned OPC) {
101+
return (OPC == VEISD::VEC_UNPACK_LO) || (OPC == VEISD::VEC_UNPACK_HI);
102+
}
103+
104+
PackElem getPartForUnpackOpcode(unsigned OPC) {
105+
if (OPC == VEISD::VEC_UNPACK_LO)
106+
return PackElem::Lo;
107+
if (OPC == VEISD::VEC_UNPACK_HI)
108+
return PackElem::Hi;
109+
llvm_unreachable("Not an unpack opcode!");
110+
}
111+
112+
unsigned getUnpackOpcodeForPart(PackElem Part) {
113+
return (Part == PackElem::Lo) ? VEISD::VEC_UNPACK_LO : VEISD::VEC_UNPACK_HI;
114+
}
115+
116+
SDValue getUnpackPackOperand(SDValue N) { return N->getOperand(0); }
117+
118+
SDValue getUnpackAVL(SDValue N) { return N->getOperand(1); }
119+
37120
/// } Packing
38121

39122
/// Node Properties {
@@ -264,16 +347,6 @@ Optional<int> getAVLPos(unsigned Opc) {
264347
return None;
265348
}
266349

267-
static SDValue getLoadStoreMask(SDValue Op) {
268-
if (auto *MaskedN = dyn_cast<MaskedLoadStoreSDNode>(Op.getNode())) {
269-
return MaskedN->getMask();
270-
}
271-
if (auto *VPLoadN = dyn_cast<VPLoadStoreSDNode>(Op.getNode())) {
272-
return VPLoadN->getMask();
273-
}
274-
return SDValue();
275-
}
276-
277350
// Return the mask operand position for this VVP or VEC op.
278351
Optional<int> getMaskPos(unsigned Opc) {
279352
// VP opcode.

llvm/lib/Target/VE/CustomDAG.h

Lines changed: 15 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ EVT splitType(EVT);
9191
// (requiring a packed VL param..)
9292
bool isPackedType(EVT SomeVT);
9393
bool isMaskType(EVT VT);
94-
static inline bool isPackedMaskType(EVT SomeVT) {
95-
return isPackedType(SomeVT) && isMaskType(SomeVT);
96-
}
94+
bool isPackedMaskType(EVT SomeVT);
9795
bool isOverPackedType(EVT VT);
9896

9997
// whether this VVP operation has no mask argument
@@ -159,86 +157,38 @@ enum class PackElem : int8_t {
159157
Hi = 1 // float (32, 0]
160158
};
161159

162-
static PackElem getPartForLane(unsigned ElemIdx) {
163-
return (ElemIdx % 2 == 0) ? PackElem::Hi : PackElem::Lo;
164-
}
160+
PackElem getPartForLane(unsigned ElemIdx);
165161

166-
static PackElem getOtherPart(PackElem Part) {
167-
return Part == PackElem::Lo ? PackElem::Hi : PackElem::Lo;
168-
}
162+
PackElem getOtherPart(PackElem Part);
169163

170-
static unsigned getOverPackedSubRegIdx(PackElem Part) {
171-
return Part == PackElem::Lo ? VE::sub_pack_lo : VE::sub_pack_hi;
172-
}
164+
unsigned getOverPackedSubRegIdx(PackElem Part);
173165

174-
static unsigned getPackedMaskSubRegIdx(PackElem Part) {
175-
return Part == PackElem::Lo ? VE::sub_vm_lo : VE::sub_vm_hi;
176-
}
166+
unsigned getPackedMaskSubRegIdx(PackElem Part);
177167

178-
static inline MVT getMaskVT(Packing P) {
179-
return P == Packing::Normal ? MVT::v256i1 : MVT::v512i1;
180-
}
168+
MVT getMaskVT(Packing P);
181169

182-
static PackElem getPackElemForVT(EVT VT) {
183-
if (VT.isFloatingPoint())
184-
return PackElem::Hi;
185-
if (VT.isVector())
186-
return getPackElemForVT(VT.getVectorElementType());
187-
return PackElem::Lo;
188-
}
170+
PackElem getPackElemForVT(EVT VT);
189171

190172
// The subregister VT an unpack of part \p Elem from \p VT would source its
191173
// result from.
192-
static MVT getUnpackSourceType(EVT VT, PackElem Elem) {
193-
if (!VT.isVector())
194-
return Elem == PackElem::Hi ? MVT::f32 : MVT::i32;
195-
196-
EVT ElemVT = VT.getVectorElementType();
197-
if (isMaskType(VT))
198-
return MVT::v256i1;
199-
if (isOverPackedType(VT))
200-
return ElemVT.isFloatingPoint() ? MVT::v256f64 : MVT::v256i64;
201-
return ElemVT.isFloatingPoint() ? MVT::v256f32 : MVT::v256i32;
202-
}
174+
MVT getUnpackSourceType(EVT VT, PackElem Elem);
203175

204-
static inline Packing getPackingForVT(EVT VT) {
205-
assert(VT.isVector());
206-
return isPackedType(VT) ? Packing::Dense : Packing::Normal;
207-
}
176+
Packing getPackingForVT(EVT VT);
208177

209178
template <typename MaskBits> Packing getPackingForMaskBits(const MaskBits MB);
210179

211180
// True, iff this is a VEC_UNPACK_LO/HI, VEC_SWAP or VEC_PACK.
212-
static inline bool isPackingSupportOpcode(unsigned Opcode) {
213-
switch (Opcode) {
214-
case VEISD::VEC_UNPACK_LO:
215-
case VEISD::VEC_UNPACK_HI:
216-
case VEISD::VEC_PACK:
217-
case VEISD::VEC_SWAP:
218-
return true;
219-
}
220-
return false;
221-
}
181+
bool isPackingSupportOpcode(unsigned Opcode);
222182

223-
static bool isUnpackOp(unsigned OPC) {
224-
return (OPC == VEISD::VEC_UNPACK_LO) || (OPC == VEISD::VEC_UNPACK_HI);
225-
}
183+
bool isUnpackOp(unsigned OPC);
226184

227-
static PackElem getPartForUnpackOpcode(unsigned OPC) {
228-
if (OPC == VEISD::VEC_UNPACK_LO)
229-
return PackElem::Lo;
230-
if (OPC == VEISD::VEC_UNPACK_HI)
231-
return PackElem::Hi;
232-
llvm_unreachable("Not an unpack opcode!");
233-
}
185+
PackElem getPartForUnpackOpcode(unsigned OPC);
234186

235-
static unsigned getUnpackOpcodeForPart(PackElem Part) {
236-
return (Part == PackElem::Lo) ? VEISD::VEC_UNPACK_LO : VEISD::VEC_UNPACK_HI;
237-
}
187+
unsigned getUnpackOpcodeForPart(PackElem Part);
238188

239-
static SDValue getUnpackPackOperand(SDValue N) { return N->getOperand(0); }
189+
SDValue getUnpackPackOperand(SDValue N);
240190

241-
static SDValue getUnpackAVL(SDValue N) { return N->getOperand(1); }
191+
SDValue getUnpackAVL(SDValue N);
242192

243193
/// } Packing
244194

0 commit comments

Comments
 (0)