LLVM  6.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 class MVT;
27 
28 enum { SM_SentinelUndef = -1, SM_SentinelZero = -2 };
29 
30 /// Decode a 128-bit INSERTPS instruction as a v4f32 shuffle mask.
32 
33 // Insert the bottom Len elements from a second source into a vector starting at
34 // element Idx.
35 void DecodeInsertElementMask(MVT VT, unsigned Idx, unsigned Len,
36  SmallVectorImpl<int> &ShuffleMask);
37 
38 /// Decode a MOVHLPS instruction as a v2f64/v4f32 shuffle mask.
39 /// i.e. <3,1> or <6,7,2,3>
40 void DecodeMOVHLPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask);
41 
42 /// Decode a MOVLHPS instruction as a v2f64/v4f32 shuffle mask.
43 /// i.e. <0,2> or <0,1,4,5>
44 void DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask);
45 
46 void DecodeMOVSLDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
47 
48 void DecodeMOVSHDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
49 
50 void DecodeMOVDDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
51 
52 void DecodePSLLDQMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
53 
54 void DecodePSRLDQMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
55 
56 void DecodePALIGNRMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
57 
58 void DecodeVALIGNMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
59 
60 /// Decodes the shuffle masks for pshufd/pshufw/vpermilpd/vpermilps.
61 /// VT indicates the type of the vector allowing it to handle different
62 /// datatypes and vector widths.
63 void DecodePSHUFMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
64 
65 /// Decodes the shuffle masks for pshufhw.
66 /// VT indicates the type of the vector allowing it to handle different
67 /// datatypes and vector widths.
68 void DecodePSHUFHWMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
69 
70 /// Decodes the shuffle masks for pshuflw.
71 /// VT indicates the type of the vector allowing it to handle different
72 /// datatypes and vector widths.
73 void DecodePSHUFLWMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
74 
75 /// Decodes a PSWAPD 3DNow! instruction.
76 void DecodePSWAPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
77 
78 /// Decodes the shuffle masks for shufp*.
79 /// VT indicates the type of the vector allowing it to handle different
80 /// datatypes and vector widths.
81 void DecodeSHUFPMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
82 
83 /// Decodes the shuffle masks for unpckhps/unpckhpd and punpckh*.
84 /// VT indicates the type of the vector allowing it to handle different
85 /// datatypes and vector widths.
86 void DecodeUNPCKHMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
87 
88 /// Decodes the shuffle masks for unpcklps/unpcklpd and punpckl*.
89 /// VT indicates the type of the vector allowing it to handle different
90 /// datatypes and vector widths.
91 void DecodeUNPCKLMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
92 
93 /// Decodes a broadcast of the first element of a vector.
94 void DecodeVectorBroadcast(MVT DstVT, SmallVectorImpl<int> &ShuffleMask);
95 
96 /// Decodes a broadcast of a subvector to a larger vector type.
97 void DecodeSubVectorBroadcast(MVT DstVT, MVT SrcVT,
98  SmallVectorImpl<int> &ShuffleMask);
99 
100 /// Decode a PSHUFB mask from a raw array of constants such as from
101 /// BUILD_VECTOR.
103  SmallVectorImpl<int> &ShuffleMask);
104 
105 /// Decode a BLEND immediate mask into a shuffle mask.
106 void DecodeBLENDMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
107 
108 void DecodeVPERM2X128Mask(MVT VT, unsigned Imm,
109  SmallVectorImpl<int> &ShuffleMask);
110 
111 /// Decode a shuffle packed values at 128-bit granularity
112 /// immediate mask into a shuffle mask.
113 void decodeVSHUF64x2FamilyMask(MVT VT, unsigned Imm,
114  SmallVectorImpl<int> &ShuffleMask);
115 
116 /// Decodes the shuffle masks for VPERMQ/VPERMPD.
117 void DecodeVPERMMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
118 
119 /// Decode a VPPERM mask from a raw array of constants such as from
120 /// BUILD_VECTOR.
121 /// This can only basic masks (permutes + zeros), not any of the other
122 /// operations that VPPERM can perform.
124  SmallVectorImpl<int> &ShuffleMask);
125 
126 /// Decode a zero extension instruction as a shuffle mask.
127 void DecodeZeroExtendMask(MVT SrcScalarVT, MVT DstVT,
128  SmallVectorImpl<int> &ShuffleMask);
129 
130 /// Decode a move lower and zero upper instruction as a shuffle mask.
131 void DecodeZeroMoveLowMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
132 
133 /// Decode a scalar float move instruction as a shuffle mask.
134 void DecodeScalarMoveMask(MVT VT, bool IsLoad,
135  SmallVectorImpl<int> &ShuffleMask);
136 
137 /// Decode a SSE4A EXTRQ instruction as a shuffle mask.
138 void DecodeEXTRQIMask(MVT VT, int Len, int Idx,
139  SmallVectorImpl<int> &ShuffleMask);
140 
141 /// Decode a SSE4A INSERTQ instruction as a shuffle mask.
142 void DecodeINSERTQIMask(MVT VT, int Len, int Idx,
143  SmallVectorImpl<int> &ShuffleMask);
144 
145 /// Decode a VPERMILPD/VPERMILPS variable mask from a raw array of constants.
146 void DecodeVPERMILPMask(MVT VT, ArrayRef<uint64_t> RawMask,
147  SmallVectorImpl<int> &ShuffleMask);
148 
149 /// Decode a VPERMIL2PD/VPERMIL2PS variable mask from a raw array of constants.
150 void DecodeVPERMIL2PMask(MVT VT, unsigned M2Z, ArrayRef<uint64_t> RawMask,
151  SmallVectorImpl<int> &ShuffleMask);
152 
153 /// Decode a VPERM W/D/Q/PS/PD mask from a raw array of constants.
155  SmallVectorImpl<int> &ShuffleMask);
156 
157 /// Decode a VPERMT2 W/D/Q/PS/PD mask from a raw array of constants.
159  SmallVectorImpl<int> &ShuffleMask);
160 } // llvm namespace
161 
162 #endif
void DecodeVPERMILPMask(MVT VT, 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 DecodePSLLDQMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeScalarMoveMask(MVT VT, bool IsLoad, SmallVectorImpl< int > &Mask)
Decode a scalar float move instruction as a shuffle mask.
void DecodePALIGNRMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeUNPCKLMask(MVT VT, SmallVectorImpl< int > &ShuffleMask)
DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd and punpckl*.
void DecodeINSERTQIMask(MVT VT, int Len, int Idx, SmallVectorImpl< int > &ShuffleMask)
Decode a SSE4A INSERTQ instruction as a shuffle mask.
void DecodeEXTRQIMask(MVT VT, int Len, int Idx, SmallVectorImpl< int > &ShuffleMask)
Decode a SSE4A EXTRQ instruction as a shuffle mask.
void DecodeMOVDDUPMask(MVT VT, SmallVectorImpl< int > &ShuffleMask)
void DecodeSubVectorBroadcast(MVT DstVT, MVT SrcVT, SmallVectorImpl< int > &ShuffleMask)
Decodes a broadcast of a subvector to a larger vector type.
void DecodeZeroMoveLowMask(MVT VT, SmallVectorImpl< int > &ShuffleMask)
Decode a move lower and zero upper instruction as a shuffle mask.
void DecodeBLENDMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decode a BLEND immediate mask into a shuffle mask.
void DecodeMOVSHDUPMask(MVT VT, SmallVectorImpl< int > &ShuffleMask)
void DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl< int > &ShuffleMask)
Decode a MOVLHPS instruction as a v2f64/v4f32 shuffle mask.
Machine Value Type.
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 DecodeSHUFPMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
DecodeSHUFPMask - This decodes the shuffle masks for shufp*.
void DecodePSHUFLWMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decodes the shuffle masks for pshuflw.
void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decode a 128-bit INSERTPS instruction as a v4f32 shuffle mask.
void DecodeZeroExtendMask(MVT SrcScalarVT, MVT DstVT, SmallVectorImpl< int > &Mask)
Decode a zero extension instruction as a shuffle mask.
void DecodeVectorBroadcast(MVT DstVT, SmallVectorImpl< int > &ShuffleMask)
Decodes a broadcast of the first element of a vector.
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 DecodeVPERMIL2PMask(MVT VT, unsigned M2Z, ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMIL2PD/VPERMIL2PS variable mask from a raw array of constants.
void DecodePSRLDQMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeMOVSLDUPMask(MVT VT, SmallVectorImpl< int > &ShuffleMask)
void DecodeVALIGNMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodePSHUFMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
DecodePSHUFMask - This decodes the shuffle masks for pshufw, pshufd, and vpermilp*.
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 DecodePSWAPMask(MVT VT, SmallVectorImpl< int > &ShuffleMask)
Decodes a PSWAPD 3DNow! instruction.
void DecodeUNPCKHMask(MVT VT, SmallVectorImpl< int > &ShuffleMask)
DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd and punpckh*.
void DecodeVPERM2X128Mask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
void DecodeInsertElementMask(MVT VT, unsigned Idx, unsigned Len, SmallVectorImpl< int > &ShuffleMask)
void decodeVSHUF64x2FamilyMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decode a shuffle packed values at 128-bit granularity (SHUFF32x4/SHUFF64x2/SHUFI32x4/SHUFI64x2) immed...
void DecodePSHUFHWMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
Decodes the shuffle masks for pshufhw.
void DecodeVPERMMask(MVT VT, unsigned Imm, SmallVectorImpl< int > &ShuffleMask)
DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.
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 DecodeMOVHLPSMask(unsigned NElts, SmallVectorImpl< int > &ShuffleMask)
Decode a MOVHLPS instruction as a v2f64/v4f32 shuffle mask.