• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
31 void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
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 /// Decodes the shuffle masks for pshufd/pshufw/vpermilpd/vpermilps.
59 /// VT indicates the type of the vector allowing it to handle different
60 /// datatypes and vector widths.
61 void DecodePSHUFMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
62 
63 /// Decodes the shuffle masks for pshufhw.
64 /// VT indicates the type of the vector allowing it to handle different
65 /// datatypes and vector widths.
66 void DecodePSHUFHWMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
67 
68 /// Decodes the shuffle masks for pshuflw.
69 /// VT indicates the type of the vector allowing it to handle different
70 /// datatypes and vector widths.
71 void DecodePSHUFLWMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
72 
73 /// Decodes a PSWAPD 3DNow! instruction.
74 void DecodePSWAPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
75 
76 /// Decodes the shuffle masks for shufp*.
77 /// VT indicates the type of the vector allowing it to handle different
78 /// datatypes and vector widths.
79 void DecodeSHUFPMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
80 
81 /// Decodes the shuffle masks for unpckhps/unpckhpd and punpckh*.
82 /// VT indicates the type of the vector allowing it to handle different
83 /// datatypes and vector widths.
84 void DecodeUNPCKHMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
85 
86 /// Decodes the shuffle masks for unpcklps/unpcklpd and punpckl*.
87 /// VT indicates the type of the vector allowing it to handle different
88 /// datatypes and vector widths.
89 void DecodeUNPCKLMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
90 
91 /// Decodes a broadcast of a subvector to a larger vector type.
92 void DecodeSubVectorBroadcast(MVT DstVT, MVT SrcVT,
93                               SmallVectorImpl<int> &ShuffleMask);
94 
95 /// Decode a PSHUFB mask from a raw array of constants such as from
96 /// BUILD_VECTOR.
97 void DecodePSHUFBMask(ArrayRef<uint64_t> RawMask,
98                       SmallVectorImpl<int> &ShuffleMask);
99 
100 /// Decode a BLEND immediate mask into a shuffle mask.
101 void DecodeBLENDMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
102 
103 void DecodeVPERM2X128Mask(MVT VT, unsigned Imm,
104                           SmallVectorImpl<int> &ShuffleMask);
105 
106 /// Decode a shuffle packed values at 128-bit granularity
107 /// immediate mask into a shuffle mask.
108 void decodeVSHUF64x2FamilyMask(MVT VT, unsigned Imm,
109                                SmallVectorImpl<int> &ShuffleMask);
110 
111 /// Decodes the shuffle masks for VPERMQ/VPERMPD.
112 void DecodeVPERMMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
113 
114 /// Decode a VPPERM mask from a raw array of constants such as from
115 /// BUILD_VECTOR.
116 /// This can only basic masks (permutes + zeros), not any of the other
117 /// operations that VPPERM can perform.
118 void DecodeVPPERMMask(ArrayRef<uint64_t> RawMask,
119                       SmallVectorImpl<int> &ShuffleMask);
120 
121 /// Decode a zero extension instruction as a shuffle mask.
122 void DecodeZeroExtendMask(MVT SrcScalarVT, MVT DstVT,
123                           SmallVectorImpl<int> &ShuffleMask);
124 
125 /// Decode a move lower and zero upper instruction as a shuffle mask.
126 void DecodeZeroMoveLowMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
127 
128 /// Decode a scalar float move instruction as a shuffle mask.
129 void DecodeScalarMoveMask(MVT VT, bool IsLoad,
130                           SmallVectorImpl<int> &ShuffleMask);
131 
132 /// Decode a SSE4A EXTRQ instruction as a v16i8 shuffle mask.
133 void DecodeEXTRQIMask(int Len, int Idx,
134                       SmallVectorImpl<int> &ShuffleMask);
135 
136 /// Decode a SSE4A INSERTQ instruction as a v16i8 shuffle mask.
137 void DecodeINSERTQIMask(int Len, int Idx,
138                         SmallVectorImpl<int> &ShuffleMask);
139 
140 /// Decode a VPERMILPD/VPERMILPS variable mask from a raw array of constants.
141 void DecodeVPERMILPMask(MVT VT, ArrayRef<uint64_t> RawMask,
142                         SmallVectorImpl<int> &ShuffleMask);
143 
144 /// Decode a VPERMIL2PD/VPERMIL2PS variable mask from a raw array of constants.
145 void DecodeVPERMIL2PMask(MVT VT, unsigned M2Z, ArrayRef<uint64_t> RawMask,
146                          SmallVectorImpl<int> &ShuffleMask);
147 
148 /// Decode a VPERM W/D/Q/PS/PD mask from a raw array of constants.
149 void DecodeVPERMVMask(ArrayRef<uint64_t> RawMask,
150                       SmallVectorImpl<int> &ShuffleMask);
151 
152 /// Decode a VPERMT2 W/D/Q/PS/PD mask from a raw array of constants.
153 void DecodeVPERMV3Mask(ArrayRef<uint64_t> RawMask,
154                       SmallVectorImpl<int> &ShuffleMask);
155 } // llvm namespace
156 
157 #endif
158