]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/X86/Utils/X86ShuffleDecode.h
Merge ^/head r293036 through r293174.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / X86 / Utils / X86ShuffleDecode.h
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 #include "llvm/ADT/ArrayRef.h"
20
21 //===----------------------------------------------------------------------===//
22 //  Vector Mask Decoding
23 //===----------------------------------------------------------------------===//
24
25 namespace llvm {
26 class Constant;
27 class MVT;
28
29 enum { SM_SentinelUndef = -1, SM_SentinelZero = -2 };
30
31 void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
32
33 // <3,1> or <6,7,2,3>
34 void DecodeMOVHLPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask);
35
36 // <0,2> or <0,1,4,5>
37 void DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask);
38
39 void DecodeMOVSLDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
40
41 void DecodeMOVSHDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
42
43 void DecodeMOVDDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
44
45 void DecodePSLLDQMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
46
47 void DecodePSRLDQMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
48
49 void DecodePALIGNRMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
50
51 void DecodePSHUFMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
52
53 void DecodePSHUFHWMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
54
55 void DecodePSHUFLWMask(MVT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
56
57 /// \brief Decodes a PSWAPD 3DNow! instruction.
58 void DecodePSWAPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
59
60 /// DecodeSHUFPMask - This decodes the shuffle masks for shufp*. VT indicates
61 /// the type of the vector allowing it to handle different datatypes and vector
62 /// widths.
63 void DecodeSHUFPMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
64
65 /// DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd
66 /// and punpckh*. VT indicates the type of the vector allowing it to handle
67 /// different datatypes and vector widths.
68 void DecodeUNPCKHMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
69
70 /// DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd
71 /// and punpckl*. VT indicates the type of the vector allowing it to handle
72 /// different datatypes and vector widths.
73 void DecodeUNPCKLMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
74
75 /// \brief Decode a PSHUFB mask from an IR-level vector constant.
76 void DecodePSHUFBMask(const Constant *C, SmallVectorImpl<int> &ShuffleMask);
77
78 /// \brief Decode a PSHUFB mask from a raw array of constants such as from
79 /// BUILD_VECTOR.
80 void DecodePSHUFBMask(ArrayRef<uint64_t> RawMask,
81                       SmallVectorImpl<int> &ShuffleMask);
82
83 /// \brief Decode a BLEND immediate mask into a shuffle mask.
84 void DecodeBLENDMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
85
86 void DecodeVPERM2X128Mask(MVT VT, unsigned Imm,
87                           SmallVectorImpl<int> &ShuffleMask);
88
89 /// \brief Decode a shuffle packed values at 128-bit granularity
90 /// immediate mask into a shuffle mask.
91 void decodeVSHUF64x2FamilyMask(MVT VT, unsigned Imm,
92                                SmallVectorImpl<int> &ShuffleMask);
93
94 /// DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.
95 /// No VT provided since it only works on 256-bit, 4 element vectors.
96 void DecodeVPERMMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
97
98 /// \brief Decode a VPERMILP variable mask from an IR-level vector constant.
99 void DecodeVPERMILPMask(const Constant *C, unsigned ElSize,
100                         SmallVectorImpl<int> &ShuffleMask);
101
102 /// \brief Decode a zero extension instruction as a shuffle mask.
103 void DecodeZeroExtendMask(MVT SrcVT, MVT DstVT,
104                           SmallVectorImpl<int> &ShuffleMask);
105
106 /// \brief Decode a move lower and zero upper instruction as a shuffle mask.
107 void DecodeZeroMoveLowMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
108
109 /// \brief Decode a scalar float move instruction as a shuffle mask.
110 void DecodeScalarMoveMask(MVT VT, bool IsLoad,
111                           SmallVectorImpl<int> &ShuffleMask);
112
113 /// \brief Decode a SSE4A EXTRQ instruction as a v16i8 shuffle mask.
114 void DecodeEXTRQIMask(int Len, int Idx,
115                       SmallVectorImpl<int> &ShuffleMask);
116
117 /// \brief Decode a SSE4A INSERTQ instruction as a v16i8 shuffle mask.
118 void DecodeINSERTQIMask(int Len, int Idx,
119                         SmallVectorImpl<int> &ShuffleMask);
120
121 /// \brief Decode a VPERM W/D/Q/PS/PD mask from an IR-level vector constant.
122 void DecodeVPERMVMask(const Constant *C, MVT VT,
123                       SmallVectorImpl<int> &ShuffleMask);
124
125 /// \brief Decode a VPERM W/D/Q/PS/PD mask from a raw array of constants.
126 void DecodeVPERMVMask(ArrayRef<uint64_t> RawMask,
127                       SmallVectorImpl<int> &ShuffleMask);
128
129 /// \brief Decode a VPERMT2 W/D/Q/PS/PD mask from an IR-level vector constant.
130 void DecodeVPERMV3Mask(const Constant *C, MVT VT,
131                       SmallVectorImpl<int> &ShuffleMask);
132
133 /// \brief Decode a VPERMT2 W/D/Q/PS/PD mask from a raw array of constants.
134 void DecodeVPERMV3Mask(ArrayRef<uint64_t> RawMask,
135                       SmallVectorImpl<int> &ShuffleMask);
136 } // llvm namespace
137
138 #endif