Fix issues in shuffle decoding around VPERM* instructions. Fix shuffle decoding for...
[oota-llvm.git] / 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 X86_SHUFFLE_DECODE_H
16 #define X86_SHUFFLE_DECODE_H
17
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/CodeGen/ValueTypes.h"
20
21 //===----------------------------------------------------------------------===//
22 //  Vector Mask Decoding
23 //===----------------------------------------------------------------------===//
24
25 namespace llvm {
26 enum {
27   SM_SentinelZero = ~0U
28 };
29
30 void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl<unsigned> &ShuffleMask);
31
32 // <3,1> or <6,7,2,3>
33 void DecodeMOVHLPSMask(unsigned NElts,
34                        SmallVectorImpl<unsigned> &ShuffleMask);
35
36 // <0,2> or <0,1,4,5>
37 void DecodeMOVLHPSMask(unsigned NElts,
38                        SmallVectorImpl<unsigned> &ShuffleMask);
39
40 void DecodePSHUFMask(unsigned NElts, unsigned Imm,
41                      SmallVectorImpl<unsigned> &ShuffleMask);
42
43 void DecodePSHUFHWMask(unsigned Imm,
44                        SmallVectorImpl<unsigned> &ShuffleMask);
45
46 void DecodePSHUFLWMask(unsigned Imm,
47                        SmallVectorImpl<unsigned> &ShuffleMask);
48
49 void DecodePUNPCKLBWMask(unsigned NElts,
50                          SmallVectorImpl<unsigned> &ShuffleMask);
51
52 void DecodePUNPCKLWDMask(unsigned NElts,
53                          SmallVectorImpl<unsigned> &ShuffleMask);
54
55 void DecodePUNPCKLDQMask(unsigned NElts,
56                          SmallVectorImpl<unsigned> &ShuffleMask);
57
58 void DecodePUNPCKLQDQMask(unsigned NElts,
59                           SmallVectorImpl<unsigned> &ShuffleMask);
60
61 void DecodePUNPCKLMask(EVT VT,
62                        SmallVectorImpl<unsigned> &ShuffleMask);
63
64 void DecodePUNPCKHMask(unsigned NElts,
65                        SmallVectorImpl<unsigned> &ShuffleMask);
66
67 void DecodeSHUFPMask(EVT VT, unsigned Imm,
68                      SmallVectorImpl<unsigned> &ShuffleMask);
69
70 /// DecodeUNPCKHPMask - This decodes the shuffle masks for unpckhps/unpckhpd
71 /// etc.  VT indicates the type of the vector allowing it to handle different
72 /// datatypes and vector widths.
73 void DecodeUNPCKHPMask(EVT VT, SmallVectorImpl<unsigned> &ShuffleMask);
74
75 /// DecodeUNPCKLPMask - This decodes the shuffle masks for unpcklps/unpcklpd
76 /// etc.  VT indicates the type of the vector allowing it to handle different
77 /// datatypes and vector widths.
78 void DecodeUNPCKLPMask(EVT VT, SmallVectorImpl<unsigned> &ShuffleMask);
79
80
81 // DecodeVPERMILPSMask - Decodes VPERMILPS permutes for any 128-bit 32-bit
82 // elements. For 256-bit vectors, it's considered as two 128 lanes, the
83 // referenced elements can't cross lanes and the mask of the first lane must
84 // be the same of the second.
85 void DecodeVPERMILPSMask(unsigned NElts, unsigned Imm,
86                         SmallVectorImpl<unsigned> &ShuffleMask);
87
88 // DecodeVPERMILPDMask - Decodes VPERMILPD permutes for any 128-bit 64-bit
89 // elements. For 256-bit vectors, it's considered as two 128 lanes, the
90 // referenced elements can't cross lanes but the mask of the first lane can
91 // be the different of the second (not like VPERMILPS).
92 void DecodeVPERMILPDMask(unsigned NElts, unsigned Imm,
93                         SmallVectorImpl<unsigned> &ShuffleMask);
94
95 void DecodeVPERM2F128Mask(unsigned Imm,
96                           SmallVectorImpl<unsigned> &ShuffleMask);
97 void DecodeVPERM2F128Mask(EVT VT, unsigned Imm,
98                           SmallVectorImpl<unsigned> &ShuffleMask);
99
100 } // llvm namespace
101
102 #endif