[x86] Teach the instruction printer to decode immediate operands to
[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 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 ConstantDataSequential;
27 class MVT;
28
29 enum {
30   SM_SentinelZero = -1
31 };
32
33 void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
34
35 // <3,1> or <6,7,2,3>
36 void DecodeMOVHLPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask);
37
38 // <0,2> or <0,1,4,5>
39 void DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask);
40
41 void DecodePALIGNRMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
42
43 void DecodePSHUFMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
44
45 void DecodePSHUFHWMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
46
47 void DecodePSHUFLWMask(MVT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
48
49 /// DecodeSHUFPMask - This decodes the shuffle masks for shufp*. VT indicates
50 /// the type of the vector allowing it to handle different datatypes and vector
51 /// widths.
52 void DecodeSHUFPMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
53
54 /// DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd
55 /// and punpckh*. VT indicates the type of the vector allowing it to handle
56 /// different datatypes and vector widths.
57 void DecodeUNPCKHMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
58
59 /// DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd
60 /// and punpckl*. VT indicates the type of the vector allowing it to handle
61 /// different datatypes and vector widths.
62 void DecodeUNPCKLMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
63
64 /// \brief Decode a PSHUFB mask from an IR-level vector constant.
65 void DecodePSHUFBMask(const ConstantDataSequential *C,
66                       SmallVectorImpl<int> &ShuffleMask);
67
68 /// \brief Decode a PSHUFB mask from a raw array of constants such as from
69 /// BUILD_VECTOR.
70 void DecodePSHUFBMask(ArrayRef<uint64_t> RawMask,
71                       SmallVectorImpl<int> &ShuffleMask);
72
73 /// \brief Decode a BLEND immediate mask into a shuffle mask.
74 void DecodeBLENDMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
75
76 void DecodeVPERM2X128Mask(MVT VT, unsigned Imm,
77                           SmallVectorImpl<int> &ShuffleMask);
78
79 /// DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.
80 /// No VT provided since it only works on 256-bit, 4 element vectors.
81 void DecodeVPERMMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
82
83 } // llvm namespace
84
85 #endif