blob: 888240fdf1d9db0a99706703343a2da2860d2dd5 [file] [log] [blame]
NAKAMURA Takumifb3bd712015-05-25 01:43:23 +00001//===-- 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 {
NAKAMURA Takumifb3bd712015-05-25 01:43:23 +000026class MVT;
27
28enum { SM_SentinelUndef = -1, SM_SentinelZero = -2 };
29
30void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
31
Simon Pilgrima3d67442016-02-07 15:39:22 +000032// Insert the bottom Len elements from a second source into a vector starting at
33// element Idx.
34void DecodeInsertElementMask(MVT VT, unsigned Idx, unsigned Len,
35 SmallVectorImpl<int> &ShuffleMask);
36
NAKAMURA Takumifb3bd712015-05-25 01:43:23 +000037// <3,1> or <6,7,2,3>
38void DecodeMOVHLPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask);
39
40// <0,2> or <0,1,4,5>
41void DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask);
42
43void DecodeMOVSLDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
44
45void DecodeMOVSHDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
46
47void DecodeMOVDDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
48
49void DecodePSLLDQMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
50
51void DecodePSRLDQMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
52
53void DecodePALIGNRMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
54
55void DecodePSHUFMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
56
57void DecodePSHUFHWMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
58
59void DecodePSHUFLWMask(MVT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
60
Simon Pilgrimf8f86ab2015-09-13 11:28:45 +000061/// \brief Decodes a PSWAPD 3DNow! instruction.
62void DecodePSWAPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
63
NAKAMURA Takumifb3bd712015-05-25 01:43:23 +000064/// DecodeSHUFPMask - This decodes the shuffle masks for shufp*. VT indicates
65/// the type of the vector allowing it to handle different datatypes and vector
66/// widths.
67void DecodeSHUFPMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
68
69/// DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd
70/// and punpckh*. VT indicates the type of the vector allowing it to handle
71/// different datatypes and vector widths.
72void DecodeUNPCKHMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
73
74/// DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd
75/// and punpckl*. VT indicates the type of the vector allowing it to handle
76/// different datatypes and vector widths.
77void DecodeUNPCKLMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
78
NAKAMURA Takumifb3bd712015-05-25 01:43:23 +000079/// \brief Decode a PSHUFB mask from a raw array of constants such as from
80/// BUILD_VECTOR.
81void DecodePSHUFBMask(ArrayRef<uint64_t> RawMask,
82 SmallVectorImpl<int> &ShuffleMask);
83
84/// \brief Decode a BLEND immediate mask into a shuffle mask.
85void DecodeBLENDMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
86
87void DecodeVPERM2X128Mask(MVT VT, unsigned Imm,
88 SmallVectorImpl<int> &ShuffleMask);
89
Igor Bregerd7bae452015-10-15 13:29:07 +000090/// \brief Decode a shuffle packed values at 128-bit granularity
91/// immediate mask into a shuffle mask.
92void decodeVSHUF64x2FamilyMask(MVT VT, unsigned Imm,
93 SmallVectorImpl<int> &ShuffleMask);
94
NAKAMURA Takumifb3bd712015-05-25 01:43:23 +000095/// DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.
96/// No VT provided since it only works on 256-bit, 4 element vectors.
97void DecodeVPERMMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask);
98
NAKAMURA Takumifb3bd712015-05-25 01:43:23 +000099/// \brief Decode a zero extension instruction as a shuffle mask.
Simon Pilgrime1b6db92016-02-06 16:33:42 +0000100void DecodeZeroExtendMask(MVT SrcScalarVT, MVT DstVT,
NAKAMURA Takumifb3bd712015-05-25 01:43:23 +0000101 SmallVectorImpl<int> &ShuffleMask);
102
103/// \brief Decode a move lower and zero upper instruction as a shuffle mask.
104void DecodeZeroMoveLowMask(MVT VT, SmallVectorImpl<int> &ShuffleMask);
105
106/// \brief Decode a scalar float move instruction as a shuffle mask.
107void DecodeScalarMoveMask(MVT VT, bool IsLoad,
108 SmallVectorImpl<int> &ShuffleMask);
Simon Pilgrimd85cae32015-07-06 20:46:41 +0000109
110/// \brief Decode a SSE4A EXTRQ instruction as a v16i8 shuffle mask.
111void DecodeEXTRQIMask(int Len, int Idx,
112 SmallVectorImpl<int> &ShuffleMask);
113
114/// \brief Decode a SSE4A INSERTQ instruction as a v16i8 shuffle mask.
115void DecodeINSERTQIMask(int Len, int Idx,
116 SmallVectorImpl<int> &ShuffleMask);
Elena Demikhovskye88038f2015-09-08 06:38:21 +0000117
Simon Pilgrim40e1a712016-03-05 22:53:31 +0000118/// \brief Decode a VPERMILPD/VPERMILPS variable mask from a raw
119/// array of constants.
120void DecodeVPERMILPMask(MVT VT, ArrayRef<uint64_t> RawMask,
121 SmallVectorImpl<int> &ShuffleMask);
122
Elena Demikhovskye88038f2015-09-08 06:38:21 +0000123/// \brief Decode a VPERM W/D/Q/PS/PD mask from a raw array of constants.
124void DecodeVPERMVMask(ArrayRef<uint64_t> RawMask,
125 SmallVectorImpl<int> &ShuffleMask);
126
Elena Demikhovskye88038f2015-09-08 06:38:21 +0000127/// \brief Decode a VPERMT2 W/D/Q/PS/PD mask from a raw array of constants.
128void DecodeVPERMV3Mask(ArrayRef<uint64_t> RawMask,
129 SmallVectorImpl<int> &ShuffleMask);
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000130} // llvm namespace
NAKAMURA Takumifb3bd712015-05-25 01:43:23 +0000131
132#endif