5c9a8cf37526789157336d8a593b9c9dec1ffa5a
[oota-llvm.git] / lib / Target / X86 / Utils / X86ShuffleDecode.h
1 //===-- X86ShuffleDecode.h - X86 shuffle decode logic -----------*-C++-*---===//\r
2 //\r
3 //                     The LLVM Compiler Infrastructure\r
4 //\r
5 // This file is distributed under the University of Illinois Open Source\r
6 // License. See LICENSE.TXT for details.\r
7 //\r
8 //===----------------------------------------------------------------------===//\r
9 //\r
10 // Define several functions to decode x86 specific shuffle semantics into a\r
11 // generic vector mask.\r
12 //\r
13 //===----------------------------------------------------------------------===//\r
14 \r
15 #ifndef LLVM_LIB_TARGET_X86_UTILS_X86SHUFFLEDECODE_H\r
16 #define LLVM_LIB_TARGET_X86_UTILS_X86SHUFFLEDECODE_H\r
17 \r
18 #include "llvm/ADT/SmallVector.h"\r
19 #include "llvm/ADT/ArrayRef.h"\r
20 \r
21 //===----------------------------------------------------------------------===//\r
22 //  Vector Mask Decoding\r
23 //===----------------------------------------------------------------------===//\r
24 \r
25 namespace llvm {\r
26 class Constant;\r
27 class MVT;\r
28 \r
29 enum { SM_SentinelUndef = -1, SM_SentinelZero = -2 };\r
30 \r
31 void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask);\r
32 \r
33 // <3,1> or <6,7,2,3>\r
34 void DecodeMOVHLPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask);\r
35 \r
36 // <0,2> or <0,1,4,5>\r
37 void DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask);\r
38 \r
39 void DecodeMOVSLDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);\r
40 \r
41 void DecodeMOVSHDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);\r
42 \r
43 void DecodeMOVDDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);\r
44 \r
45 void DecodePSLLDQMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);\r
46 \r
47 void DecodePSRLDQMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);\r
48 \r
49 void DecodePALIGNRMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);\r
50 \r
51 void DecodePSHUFMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);\r
52 \r
53 void DecodePSHUFHWMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);\r
54 \r
55 void DecodePSHUFLWMask(MVT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);\r
56 \r
57 /// DecodeSHUFPMask - This decodes the shuffle masks for shufp*. VT indicates\r
58 /// the type of the vector allowing it to handle different datatypes and vector\r
59 /// widths.\r
60 void DecodeSHUFPMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);\r
61 \r
62 /// DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd\r
63 /// and punpckh*. VT indicates the type of the vector allowing it to handle\r
64 /// different datatypes and vector widths.\r
65 void DecodeUNPCKHMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);\r
66 \r
67 /// DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd\r
68 /// and punpckl*. VT indicates the type of the vector allowing it to handle\r
69 /// different datatypes and vector widths.\r
70 void DecodeUNPCKLMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);\r
71 \r
72 /// \brief Decode a PSHUFB mask from an IR-level vector constant.\r
73 void DecodePSHUFBMask(const Constant *C, SmallVectorImpl<int> &ShuffleMask);\r
74 \r
75 /// \brief Decode a PSHUFB mask from a raw array of constants such as from\r
76 /// BUILD_VECTOR.\r
77 void DecodePSHUFBMask(ArrayRef<uint64_t> RawMask,\r
78                       SmallVectorImpl<int> &ShuffleMask);\r
79 \r
80 /// \brief Decode a BLEND immediate mask into a shuffle mask.\r
81 void DecodeBLENDMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);\r
82 \r
83 void DecodeVPERM2X128Mask(MVT VT, unsigned Imm,\r
84                           SmallVectorImpl<int> &ShuffleMask);\r
85 \r
86 /// DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.\r
87 /// No VT provided since it only works on 256-bit, 4 element vectors.\r
88 void DecodeVPERMMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask);\r
89 \r
90 /// \brief Decode a VPERMILP variable mask from an IR-level vector constant.\r
91 void DecodeVPERMILPMask(const Constant *C, SmallVectorImpl<int> &ShuffleMask);\r
92 \r
93 /// \brief Decode a zero extension instruction as a shuffle mask.\r
94 void DecodeZeroExtendMask(MVT SrcVT, MVT DstVT,\r
95                           SmallVectorImpl<int> &ShuffleMask);\r
96 \r
97 /// \brief Decode a move lower and zero upper instruction as a shuffle mask.\r
98 void DecodeZeroMoveLowMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);\r
99 \r
100 /// \brief Decode a scalar float move instruction as a shuffle mask.\r
101 void DecodeScalarMoveMask(MVT VT, bool IsLoad,\r
102                           SmallVectorImpl<int> &ShuffleMask);\r
103 } // llvm namespace\r
104 \r
105 #endif\r