3ac0afe1e349fc5fd12b21f7a8e3759f89928900
[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
20 //===----------------------------------------------------------------------===//
21 //  Vector Mask Decoding
22 //===----------------------------------------------------------------------===//
23
24 namespace llvm {
25 class ConstantDataSequential;
26 class MVT;
27
28 enum {
29   SM_SentinelZero = -1
30 };
31
32 void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
33
34 // <3,1> or <6,7,2,3>
35 void DecodeMOVHLPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask);
36
37 // <0,2> or <0,1,4,5>
38 void DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask);
39
40 void DecodePALIGNRMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
41
42 void DecodePSHUFMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
43
44 void DecodePSHUFHWMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
45
46 void DecodePSHUFLWMask(MVT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
47
48 /// DecodeSHUFPMask - This decodes the shuffle masks for shufp*. VT indicates
49 /// the type of the vector allowing it to handle different datatypes and vector
50 /// widths.
51 void DecodeSHUFPMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
52
53 /// DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd
54 /// and punpckh*. VT indicates the type of the vector allowing it to handle
55 /// different datatypes and vector widths.
56 void DecodeUNPCKHMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
57
58 /// DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd
59 /// and punpckl*. VT indicates the type of the vector allowing it to handle
60 /// different datatypes and vector widths.
61 void DecodeUNPCKLMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
62
63 void DecodePSHUFBMask(const ConstantDataSequential *C,
64                       SmallVectorImpl<int> &ShuffleMask);
65
66 void DecodeVPERM2X128Mask(MVT VT, unsigned Imm,
67                           SmallVectorImpl<int> &ShuffleMask);
68
69 /// DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.
70 /// No VT provided since it only works on 256-bit, 4 element vectors.
71 void DecodeVPERMMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
72
73 } // llvm namespace
74
75 #endif