X86ShuffleDecode.h revision 36b56886974eae4f9c5ebc96befd3e7bfe5de338
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
24namespace llvm {
25class MVT;
26
27enum {
28  SM_SentinelZero = -1
29};
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 DecodePALIGNRMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
40
41void DecodePSHUFMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
42
43void DecodePSHUFHWMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
44
45void DecodePSHUFLWMask(MVT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
46
47/// DecodeSHUFPMask - This decodes the shuffle masks for shufp*. VT indicates
48/// the type of the vector allowing it to handle different datatypes and vector
49/// widths.
50void DecodeSHUFPMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
51
52/// DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd
53/// and punpckh*. VT indicates the type of the vector allowing it to handle
54/// different datatypes and vector widths.
55void DecodeUNPCKHMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
56
57/// DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd
58/// and punpckl*. VT indicates the type of the vector allowing it to handle
59/// different datatypes and vector widths.
60void DecodeUNPCKLMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
61
62
63void DecodeVPERM2X128Mask(MVT VT, unsigned Imm,
64                          SmallVectorImpl<int> &ShuffleMask);
65
66/// DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.
67/// No VT provided since it only works on 256-bit, 4 element vectors.
68void DecodeVPERMMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
69
70} // llvm namespace
71
72#endif
73