llvm.org GIT mirror llvm / d978c54
Use MVT instead of EVT as the argument to all the shuffle decode functions. Simplify some of the decode functions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156268 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 8 years ago
3 changed file(s) with 33 addition(s) and 35 deletion(s). Raw diff Collapse all Expand all
6363 /// DecodePSHUFMask - This decodes the shuffle masks for pshufd, and vpermilp*.
6464 /// VT indicates the type of the vector allowing it to handle different
6565 /// datatypes and vector widths.
66 void DecodePSHUFMask(EVT VT, unsigned Imm, SmallVectorImpl &ShuffleMask) {
66 void DecodePSHUFMask(MVT VT, unsigned Imm, SmallVectorImpl &ShuffleMask) {
6767 unsigned NumElts = VT.getVectorNumElements();
6868
6969 unsigned NumLanes = VT.getSizeInBits() / 128;
7979 }
8080 }
8181
82 void DecodePSHUFHWMask(EVT VT, unsigned Imm,
82 void DecodePSHUFHWMask(MVT VT, unsigned Imm,
8383 SmallVectorImpl &ShuffleMask) {
8484 unsigned NumElts = VT.getVectorNumElements();
8585
9595 }
9696 }
9797
98 void DecodePSHUFLWMask(EVT VT, unsigned Imm,
98 void DecodePSHUFLWMask(MVT VT, unsigned Imm,
9999 SmallVectorImpl &ShuffleMask) {
100100 unsigned NumElts = VT.getVectorNumElements();
101101
114114 /// DecodeSHUFPMask - This decodes the shuffle masks for shufp*. VT indicates
115115 /// the type of the vector allowing it to handle different datatypes and vector
116116 /// widths.
117 void DecodeSHUFPMask(EVT VT, unsigned Imm, SmallVectorImpl &ShuffleMask) {
117 void DecodeSHUFPMask(MVT VT, unsigned Imm, SmallVectorImpl &ShuffleMask) {
118118 unsigned NumElts = VT.getVectorNumElements();
119119
120120 unsigned NumLanes = VT.getSizeInBits() / 128;
122122
123123 unsigned NewImm = Imm;
124124 for (unsigned l = 0; l != NumElts; l += NumLaneElts) {
125 // Part that reads from dest.
126 for (unsigned i = 0; i != NumLaneElts/2; ++i) {
127 ShuffleMask.push_back(NewImm % NumLaneElts + l);
128 NewImm /= NumLaneElts;
129 }
130 // Part that reads from src.
131 for (unsigned i = 0; i != NumLaneElts/2; ++i) {
132 ShuffleMask.push_back(NewImm % NumLaneElts + NumElts + l);
133 NewImm /= NumLaneElts;
125 // each half of a lane comes from different source
126 for (unsigned s = 0; s != NumElts*2; s += NumElts) {
127 for (unsigned i = 0; i != NumLaneElts/2; ++i) {
128 ShuffleMask.push_back(NewImm % NumLaneElts + s + l);
129 NewImm /= NumLaneElts;
130 }
134131 }
135132 if (NumLaneElts == 4) NewImm = Imm; // reload imm
136133 }
139136 /// DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd
140137 /// and punpckh*. VT indicates the type of the vector allowing it to handle
141138 /// different datatypes and vector widths.
142 void DecodeUNPCKHMask(EVT VT, SmallVectorImpl &ShuffleMask) {
139 void DecodeUNPCKHMask(MVT VT, SmallVectorImpl &ShuffleMask) {
143140 unsigned NumElts = VT.getVectorNumElements();
144141
145142 // Handle 128 and 256-bit vector lengths. AVX defines UNPCK* to operate
159156 /// DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd
160157 /// and punpckl*. VT indicates the type of the vector allowing it to handle
161158 /// different datatypes and vector widths.
162 void DecodeUNPCKLMask(EVT VT, SmallVectorImpl &ShuffleMask) {
159 void DecodeUNPCKLMask(MVT VT, SmallVectorImpl &ShuffleMask) {
163160 unsigned NumElts = VT.getVectorNumElements();
164161
165162 // Handle 128 and 256-bit vector lengths. AVX defines UNPCK* to operate
176173 }
177174 }
178175
179 void DecodeVPERM2X128Mask(EVT VT, unsigned Imm,
176 void DecodeVPERM2X128Mask(MVT VT, unsigned Imm,
180177 SmallVectorImpl &ShuffleMask) {
181178 if (Imm & 0x88)
182179 return; // Not a shuffle
183180
184181 unsigned HalfSize = VT.getVectorNumElements()/2;
185 unsigned FstHalfBegin = (Imm & 0x3) * HalfSize;
186 unsigned SndHalfBegin = ((Imm >> 4) & 0x3) * HalfSize;
187182
188 for (unsigned i = FstHalfBegin, e = FstHalfBegin+HalfSize; i != e; ++i)
189 ShuffleMask.push_back(i);
190 for (unsigned i = SndHalfBegin, e = SndHalfBegin+HalfSize; i != e; ++i)
191 ShuffleMask.push_back(i);
183 for (unsigned l = 0; l != 2; ++l) {
184 unsigned HalfBegin = ((Imm >> (l*4)) & 0x3) * HalfSize;
185 for (unsigned i = HalfBegin, e = HalfBegin+HalfSize; i != e; ++i)
186 ShuffleMask.push_back(i);
187 }
192188 }
193189
194190 /// DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.
3434 // <0,2> or <0,1,4,5>
3535 void DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl &ShuffleMask);
3636
37 void DecodePSHUFMask(EVT VT, unsigned Imm, SmallVectorImpl &ShuffleMask);
37 void DecodePSHUFMask(MVT VT, unsigned Imm, SmallVectorImpl &ShuffleMask);
3838
39 void DecodePSHUFHWMask(EVT VT, unsigned Imm, SmallVectorImpl &ShuffleMask);
39 void DecodePSHUFHWMask(MVT VT, unsigned Imm, SmallVectorImpl &ShuffleMask);
4040
41 void DecodePSHUFLWMask(EVT, unsigned Imm, SmallVectorImpl &ShuffleMask);
41 void DecodePSHUFLWMask(MVT, unsigned Imm, SmallVectorImpl &ShuffleMask);
4242
4343 /// DecodeSHUFPMask - This decodes the shuffle masks for shufp*. VT indicates
4444 /// the type of the vector allowing it to handle different datatypes and vector
4545 /// widths.
46 void DecodeSHUFPMask(EVT VT, unsigned Imm, SmallVectorImpl &ShuffleMask);
46 void DecodeSHUFPMask(MVT VT, unsigned Imm, SmallVectorImpl &ShuffleMask);
4747
4848 /// DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd
4949 /// and punpckh*. VT indicates the type of the vector allowing it to handle
5050 /// different datatypes and vector widths.
51 void DecodeUNPCKHMask(EVT VT, SmallVectorImpl &ShuffleMask);
51 void DecodeUNPCKHMask(MVT VT, SmallVectorImpl &ShuffleMask);
5252
5353 /// DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd
5454 /// and punpckl*. VT indicates the type of the vector allowing it to handle
5555 /// different datatypes and vector widths.
56 void DecodeUNPCKLMask(EVT VT, SmallVectorImpl &ShuffleMask);
56 void DecodeUNPCKLMask(MVT VT, SmallVectorImpl &ShuffleMask);
5757
5858
59 void DecodeVPERM2X128Mask(EVT VT, unsigned Imm,
59 void DecodeVPERM2X128Mask(MVT VT, unsigned Imm,
6060 SmallVectorImpl &ShuffleMask);
6161
6262 /// DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.
44164416 /// getTargetShuffleMask - Calculates the shuffle mask corresponding to the
44174417 /// target specific opcode. Returns true if the Mask could be calculated.
44184418 /// Sets IsUnary to true if only uses one source.
4419 static bool getTargetShuffleMask(SDNode *N, EVT VT,
4419 static bool getTargetShuffleMask(SDNode *N, MVT VT,
44204420 SmallVectorImpl &Mask, bool &IsUnary) {
44214421 unsigned NumElems = VT.getVectorNumElements();
44224422 SDValue ImmN;
45174517
45184518 // Recurse into target specific vector shuffles to find scalars.
45194519 if (isTargetShuffle(Opcode)) {
4520 unsigned NumElems = VT.getVectorNumElements();
4520 MVT ShufVT = V.getValueType().getSimpleVT();
4521 unsigned NumElems = ShufVT.getVectorNumElements();
45214522 SmallVector ShuffleMask;
45224523 SDValue ImmN;
45234524 bool IsUnary;
45244525
4525 if (!getTargetShuffleMask(N, VT, ShuffleMask, IsUnary))
4526 if (!getTargetShuffleMask(N, ShufVT, ShuffleMask, IsUnary))
45264527 return SDValue();
45274528
45284529 int Elt = ShuffleMask[Index];
45294530 if (Elt < 0)
4530 return DAG.getUNDEF(VT.getVectorElementType());
4531 return DAG.getUNDEF(ShufVT.getVectorElementType());
45314532
45324533 SDValue NewV = (Elt < (int)NumElems) ? N->getOperand(0)
4533 : N->getOperand(1);
4534 : N->getOperand(1);
45344535 return getShuffleScalarElt(NewV.getNode(), Elt % NumElems, DAG,
45354536 Depth+1);
45364537 }
1326513266
1326613267 SmallVector ShuffleMask;
1326713268 bool UnaryShuffle;
13268 if (!getTargetShuffleMask(InVec.getNode(), VT, ShuffleMask, UnaryShuffle))
13269 if (!getTargetShuffleMask(InVec.getNode(), VT.getSimpleVT(), ShuffleMask,
13270 UnaryShuffle))
1326913271 return SDValue();
1327013272
1327113273 // Select the input vector, guarding against out of range extract vector.