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