blob: 58193e6a4688714f2366e67dea9a65688aab0d1e [file] [log] [blame]
David Greene3a2b5082011-02-17 19:18:59 +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 X86_SHUFFLE_DECODE_H
16#define X86_SHUFFLE_DECODE_H
17
18#include "llvm/ADT/SmallVector.h"
David Greene20a1cbe2011-02-28 19:06:56 +000019#include "llvm/CodeGen/ValueTypes.h"
David Greene3a2b5082011-02-17 19:18:59 +000020
21//===----------------------------------------------------------------------===//
22// Vector Mask Decoding
23//===----------------------------------------------------------------------===//
24
25namespace llvm {
26enum {
27 SM_SentinelZero = ~0U
28};
29
30void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl<unsigned> &ShuffleMask);
31
32// <3,1> or <6,7,2,3>
33void DecodeMOVHLPSMask(unsigned NElts,
34 SmallVectorImpl<unsigned> &ShuffleMask);
35
36// <0,2> or <0,1,4,5>
37void DecodeMOVLHPSMask(unsigned NElts,
38 SmallVectorImpl<unsigned> &ShuffleMask);
39
40void DecodePSHUFMask(unsigned NElts, unsigned Imm,
41 SmallVectorImpl<unsigned> &ShuffleMask);
42
43void DecodePSHUFHWMask(unsigned Imm,
44 SmallVectorImpl<unsigned> &ShuffleMask);
45
46void DecodePSHUFLWMask(unsigned Imm,
47 SmallVectorImpl<unsigned> &ShuffleMask);
48
David Greene20a1cbe2011-02-28 19:06:56 +000049void DecodePUNPCKLBWMask(unsigned NElts,
50 SmallVectorImpl<unsigned> &ShuffleMask);
51
52void DecodePUNPCKLWDMask(unsigned NElts,
53 SmallVectorImpl<unsigned> &ShuffleMask);
54
55void DecodePUNPCKLDQMask(unsigned NElts,
56 SmallVectorImpl<unsigned> &ShuffleMask);
57
58void DecodePUNPCKLQDQMask(unsigned NElts,
59 SmallVectorImpl<unsigned> &ShuffleMask);
60
61void DecodePUNPCKLMask(EVT VT,
David Greene3a2b5082011-02-17 19:18:59 +000062 SmallVectorImpl<unsigned> &ShuffleMask);
63
64void DecodePUNPCKHMask(unsigned NElts,
65 SmallVectorImpl<unsigned> &ShuffleMask);
66
67void DecodeSHUFPSMask(unsigned NElts, unsigned Imm,
68 SmallVectorImpl<unsigned> &ShuffleMask);
69
70void DecodeUNPCKHPMask(unsigned NElts,
71 SmallVectorImpl<unsigned> &ShuffleMask);
72
David Greene20a1cbe2011-02-28 19:06:56 +000073void DecodeUNPCKLPSMask(unsigned NElts,
74 SmallVectorImpl<unsigned> &ShuffleMask);
75
76void DecodeUNPCKLPDMask(unsigned NElts,
77 SmallVectorImpl<unsigned> &ShuffleMask);
David Greene3a2b5082011-02-17 19:18:59 +000078
79/// DecodeUNPCKLPMask - This decodes the shuffle masks for unpcklps/unpcklpd
David Greene20a1cbe2011-02-28 19:06:56 +000080/// etc. VT indicates the type of the vector allowing it to handle different
81/// datatypes and vector widths.
82void DecodeUNPCKLPMask(EVT VT,
David Greene3a2b5082011-02-17 19:18:59 +000083 SmallVectorImpl<unsigned> &ShuffleMask);
84
Bruno Cardoso Lopesb878caa2011-07-21 01:55:47 +000085
Bruno Cardoso Lopes795f5582011-07-29 01:31:11 +000086// DecodeVPERMILPSMask - Decodes VPERMILPS permutes for any 128-bit 32-bit
87// elements. For 256-bit vectors, it's considered as two 128 lanes, the
88// referenced elements can't cross lanes and the mask of the first lane must
89// be the same of the second.
Bruno Cardoso Lopesb878caa2011-07-21 01:55:47 +000090void DecodeVPERMILPSMask(unsigned NElts, unsigned Imm,
91 SmallVectorImpl<unsigned> &ShuffleMask);
92
Bruno Cardoso Lopes795f5582011-07-29 01:31:11 +000093// DecodeVPERMILPDMask - Decodes VPERMILPD permutes for any 128-bit 64-bit
94// elements. For 256-bit vectors, it's considered as two 128 lanes, the
95// referenced elements can't cross lanes but the mask of the first lane can
96// be the different of the second (not like VPERMILPS).
Bruno Cardoso Lopesb878caa2011-07-21 01:55:47 +000097void DecodeVPERMILPDMask(unsigned NElts, unsigned Imm,
98 SmallVectorImpl<unsigned> &ShuffleMask);
99
Bruno Cardoso Lopesf15dfe52011-08-12 21:48:26 +0000100void DecodeVPERM2F128Mask(unsigned Imm,
101 SmallVectorImpl<unsigned> &ShuffleMask);
102void DecodeVPERM2F128Mask(EVT VT, unsigned Imm,
103 SmallVectorImpl<unsigned> &ShuffleMask);
104
David Greene3a2b5082011-02-17 19:18:59 +0000105} // llvm namespace
106
107#endif