LLVM  7.0.0svn
X86ShuffleDecode.h
Go to the documentation of this file.
1 //===-- X86ShuffleDecode.h - X86 shuffle decode logic -----------*-C++-*---===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Define several functions to decode x86 specific shuffle semantics into a
11 // generic vector mask.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_TARGET_X86_UTILS_X86SHUFFLEDECODE_H
16 #define LLVM_LIB_TARGET_X86_UTILS_X86SHUFFLEDECODE_H
17 
18 #include "llvm/ADT/SmallVector.h"
19 
20 //===----------------------------------------------------------------------===//
21 // Vector Mask Decoding
22 //===----------------------------------------------------------------------===//
23 
24 namespace llvm {
25 template <typename T> class ArrayRef;
26 
27 enum { SM_SentinelUndef = -1, SM_SentinelZero = -2 };
28 
29 /// Decode a 128-bit INSERTPS instruction as a v4f32 shuffle mask.
30 void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
31 
32 // Insert the bottom Len elements from a second source into a vector starting at
33 // element Idx.
34 void DecodeInsertElementMask(unsigned NumElts, unsigned Idx, unsigned Len,
35  SmallVectorImpl<int> &ShuffleMask);
36 
37 /// Decode a MOVHLPS instruction as a v2f64/v4f32 shuffle mask.
38 /// i.e. <3,1> or <6,7,2,3>
39 void DecodeMOVHLPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask);
40 
41 /// Decode a MOVLHPS instruction as a v2f64/v4f32 shuffle mask.
42 /// i.e. <0,2> or <0,1,4,5>
43 void DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask);
44 
45 void DecodeMOVSLDUPMask(unsigned NumElts, SmallVectorImpl<int> &ShuffleMask);
46 
47 void DecodeMOVSHDUPMask(unsigned NumElts, SmallVectorImpl<int> &ShuffleMask);
48 
49 void DecodeMOVDDUPMask(unsigned NumElts, SmallVectorImpl<int> &ShuffleMask);
50 
51 void DecodePSLLDQMask(unsigned NumElts, unsigned Imm,
52  SmallVectorImpl<int> &ShuffleMask);
53 
54 void DecodePSRLDQMask(unsigned NumElts, unsigned Imm,
55  SmallVectorImpl<int> &ShuffleMask);
56 
57 void DecodePALIGNRMask(unsigned NumElts, unsigned Imm,
58  SmallVectorImpl<int> &ShuffleMask);
59 
60 void DecodeVALIGNMask(unsigned NumElts, unsigned Imm,
61  SmallVectorImpl<int> &ShuffleMask);
62 
63 /// Decodes the shuffle masks for pshufd/pshufw/vpermilpd/vpermilps.
64 /// VT indicates the type of the vector allowing it to handle different
65 /// datatypes and vector widths.
66 void DecodePSHUFMask(unsigned NumElts, unsigned ScalarBits, unsigned Imm,
67  SmallVectorImpl<int> &ShuffleMask);
68 
69 /// Decodes the shuffle masks for pshufhw.
70 /// VT indicates the type of the vector allowing it to handle different
71 /// datatypes and vector widths.
72 void DecodePSHUFHWMask(unsigned NumElts, unsigned Imm,
73  SmallVectorImpl<int> &ShuffleMask);
74 
75 /// Decodes the shuffle masks for pshuflw.
76 /// VT indicates the type of the vector allowing it to handle different
77 /// datatypes and vector widths.
78 void DecodePSHUFLWMask(unsigned NumElts, unsigned Imm,
79  SmallVectorImpl<int> &ShuffleMask);
80 
81 /// Decodes a PSWAPD 3DNow! instruction.
82 void DecodePSWAPMask(unsigned NumElts, SmallVectorImpl<int> &ShuffleMask);
83 
84 /// Decodes the shuffle masks for shufp*.
85 /// VT indicates the type of the vector allowing it to handle different
86 /// datatypes and vector widths.
87 void DecodeSHUFPMask(unsigned NumElts, unsigned ScalarBits, unsigned Imm,
88  SmallVectorImpl<int> &ShuffleMask);
89 
90 /// Decodes the shuffle masks for unpckhps/unpckhpd and punpckh*.
91 /// VT indicates the type of the vector allowing it to handle different
92 /// datatypes and vector widths.
93 void DecodeUNPCKHMask(unsigned NumElts, unsigned ScalarBits,
94  SmallVectorImpl<int> &ShuffleMask);
95 
96 /// Decodes the shuffle masks for unpcklps/unpcklpd and punpckl*.
97 /// VT indicates the type of the vector allowing it to handle different
98 /// datatypes and vector widths.
99 void DecodeUNPCKLMask(unsigned NumElts, unsigned ScalarBits,
100  SmallVectorImpl<int> &ShuffleMask);
101 
102 /// Decodes a broadcast of the first element of a vector.
103 void DecodeVectorBroadcast(unsigned NumElts, SmallVectorImpl<int> &ShuffleMask);
104 
105 /// Decodes a broadcast of a subvector to a larger vector type.
106 void DecodeSubVectorBroadcast(unsigned DstNumElts, unsigned SrcNumElts,
107  SmallVectorImpl<int> &ShuffleMask);
108 
109 /// Decode a PSHUFB mask from a raw array of constants such as from
110 /// BUILD_VECTOR.
112  SmallVectorImpl<int> &ShuffleMask);
113 
114 /// Decode a BLEND immediate mask into a shuffle mask.
115 void DecodeBLENDMask(unsigned NumElts, unsigned Imm,
116  SmallVectorImpl<int> &ShuffleMask);
117 
118 void DecodeVPERM2X128Mask(unsigned NumElts, unsigned Imm,
119  SmallVectorImpl<int> &ShuffleMask);
120 
121 /// Decode a shuffle packed values at 128-bit granularity
122 /// immediate mask into a shuffle mask.
123 void decodeVSHUF64x2FamilyMask(unsigned NumElts, unsigned ScalarSize,
124  unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
125 
126 /// Decodes the shuffle masks for VPERMQ/VPERMPD.
127 void DecodeVPERMMask(unsigned NumElts, unsigned Imm,
128  SmallVectorImpl<int> &ShuffleMask);
129 
130 /// Decode a VPPERM mask from a raw array of constants such as from
131 /// BUILD_VECTOR.
132 /// This can only basic masks (permutes + zeros), not any of the other
133 /// operations that VPPERM can perform.
135  SmallVectorImpl<int> &ShuffleMask);
136 
137 /// Decode a zero extension instruction as a shuffle mask.
138 void DecodeZeroExtendMask(unsigned SrcScalarBits, unsigned DstScalarBits,
139  unsigned NumDstElts,
140  SmallVectorImpl<int> &ShuffleMask);
141 
142 /// Decode a move lower and zero upper instruction as a shuffle mask.
143 void DecodeZeroMoveLowMask(unsigned NumElts, SmallVectorImpl<int> &ShuffleMask);
144 
145 /// Decode a scalar float move instruction as a shuffle mask.
146 void DecodeScalarMoveMask(unsigned NumElts, bool IsLoad,
147  SmallVectorImpl<int> &ShuffleMask);
148 
149 /// Decode a SSE4A EXTRQ instruction as a shuffle mask.
150 void DecodeEXTRQIMask(unsigned NumElts, unsigned EltSize, int Len, int Idx,
151  SmallVectorImpl<int> &ShuffleMask);
152 
153 /// Decode a SSE4A INSERTQ instruction as a shuffle mask.
154 void DecodeINSERTQIMask(unsigned NumElts, unsigned EltSize, int Len, int Idx,
155  SmallVectorImpl<int> &ShuffleMask);
156 
157 /// Decode a VPERMILPD/VPERMILPS variable mask from a raw array of constants.
158 void DecodeVPERMILPMask(unsigned NumElts, unsigned ScalarBits,
159  ArrayRef<uint64_t> RawMask,
160  SmallVectorImpl<int> &ShuffleMask);
161 
162 /// Decode a VPERMIL2PD/VPERMIL2PS variable mask from a raw array of constants.
163 void DecodeVPERMIL2PMask(unsigned NumElts, unsigned ScalarBits, unsigned M2Z,
164  ArrayRef<uint64_t> RawMask,
165  SmallVectorImpl<int> &ShuffleMask);
166 
167 /// Decode a VPERM W/D/Q/PS/PD mask from a raw array of constants.
169  SmallVectorImpl<int> &ShuffleMask);
170 
171 /// Decode a VPERMT2 W/D/Q/PS/PD mask from a raw array of constants.
173  SmallVectorImpl<int> &ShuffleMask);
174 } // llvm namespace
175 
176 #endif
void DecodeVPERMILPMask(unsigned NumElts, unsigned ScalarBits, ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMILPD/VPERMILPS variable mask from a raw array of constants.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
void DecodeVectorBroadcast(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
Decodes a broadcast of the first element of a vector.
void DecodePSLLDQMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodePSHUFMask(unsigned NumElts, unsigned ScalarBits, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
DecodePSHUFMask - This decodes the shuffle masks for pshufw, pshufd, and vpermilp*.
void DecodeZeroMoveLowMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
Decode a move lower and zero upper instruction as a shuffle mask.
void DecodeUNPCKHMask(unsigned NumElts, unsigned ScalarBits, SmallVectorImpl< int > &ShuffleMask)
DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd and punpckh*.
void DecodeMOVDDUPMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
void DecodeVPERM2X128Mask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeEXTRQIMask(unsigned NumElts, unsigned EltSize, int Len, int Idx, SmallVectorImpl< int > &ShuffleMask)
Decode a SSE4A EXTRQ instruction as a shuffle mask.
void DecodeMOVSHDUPMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
void DecodeVALIGNMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodePSHUFLWMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decodes the shuffle masks for pshuflw.
void DecodeUNPCKLMask(unsigned NumElts, unsigned ScalarBits, SmallVectorImpl< int > &ShuffleMask)
DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd and punpckl*.
void DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl< int > &ShuffleMask)
Decode a MOVLHPS instruction as a v2f64/v4f32 shuffle mask.
void DecodeZeroExtendMask(unsigned SrcScalarBits, unsigned DstScalarBits, unsigned NumDstElts, SmallVectorImpl< int > &Mask)
Decode a zero extension instruction as a shuffle mask.
void DecodeVPPERMMask(ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPPERM mask from a raw array of constants such as from BUILD_VECTOR.
void DecodeVPERMIL2PMask(unsigned NumElts, unsigned ScalarBits, unsigned M2Z, ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMIL2PD/VPERMIL2PS variable mask from a raw array of constants.
void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decode a 128-bit INSERTPS instruction as a v4f32 shuffle mask.
void DecodeBLENDMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decode a BLEND immediate mask into a shuffle mask.
void decodeVSHUF64x2FamilyMask(unsigned NumElts, unsigned ScalarSize, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decode a shuffle packed values at 128-bit granularity (SHUFF32x4/SHUFF64x2/SHUFI32x4/SHUFI64x2) immed...
void DecodeVPERMVMask(ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERM W/D/Q/PS/PD mask from a raw array of constants.
void DecodeMOVSLDUPMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
void DecodeINSERTQIMask(unsigned NumElts, unsigned EltSize, int Len, int Idx, SmallVectorImpl< int > &ShuffleMask)
Decode a SSE4A INSERTQ instruction as a shuffle mask.
void DecodeVPERMV3Mask(ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMT2 W/D/Q/PS/PD mask from a raw array of constants.
void DecodeVPERMMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.
void DecodePSHUFHWMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decodes the shuffle masks for pshufhw.
void DecodeScalarMoveMask(unsigned NumElts, bool IsLoad, SmallVectorImpl< int > &Mask)
Decode a scalar float move instruction as a shuffle mask.
void DecodePSRLDQMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeSHUFPMask(unsigned NumElts, unsigned ScalarBits, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
DecodeSHUFPMask - This decodes the shuffle masks for shufp*.
void DecodeInsertElementMask(unsigned NumElts, unsigned Idx, unsigned Len, SmallVectorImpl< int > &ShuffleMask)
void DecodePSHUFBMask(ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a PSHUFB mask from a raw array of constants such as from BUILD_VECTOR.
void DecodePSWAPMask(unsigned NumElts, SmallVectorImpl< int > &ShuffleMask)
Decodes a PSWAPD 3DNow! instruction.
void DecodeSubVectorBroadcast(unsigned DstNumElts, unsigned SrcNumElts, SmallVectorImpl< int > &ShuffleMask)
Decodes a broadcast of a subvector to a larger vector type.
void DecodePALIGNRMask(unsigned NumElts, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeMOVHLPSMask(unsigned NElts, SmallVectorImpl< int > &ShuffleMask)
Decode a MOVHLPS instruction as a v2f64/v4f32 shuffle mask.