blob: 243728f81e3e23102d37c25d4efa8ee636c50378 [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
Craig Topperc16db842011-11-29 07:49:05 +000049void DecodeSHUFPMask(EVT VT, unsigned Imm,
50 SmallVectorImpl<unsigned> &ShuffleMask);
David Greene3a2b5082011-02-17 19:18:59 +000051
Craig Topper3cb802c2011-12-06 05:31:16 +000052/// DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd
Craig Topperccb70972011-11-22 01:57:35 +000053/// etc. VT indicates the type of the vector allowing it to handle different
54/// datatypes and vector widths.
Craig Topper3cb802c2011-12-06 05:31:16 +000055void DecodeUNPCKHMask(EVT VT, SmallVectorImpl<unsigned> &ShuffleMask);
David Greene3a2b5082011-02-17 19:18:59 +000056
Craig Topper3cb802c2011-12-06 05:31:16 +000057/// DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd
David Greene20a1cbe2011-02-28 19:06:56 +000058/// etc. VT indicates the type of the vector allowing it to handle different
59/// datatypes and vector widths.
Craig Topper3cb802c2011-12-06 05:31:16 +000060void DecodeUNPCKLMask(EVT VT, SmallVectorImpl<unsigned> &ShuffleMask);
David Greene3a2b5082011-02-17 19:18:59 +000061
Bruno Cardoso Lopesb878caa2011-07-21 01:55:47 +000062
Craig Topperbafd2242011-11-30 06:25:25 +000063// DecodeVPERMILPMask - Decodes VPERMILPS/ VPERMILPD permutes for any 128-bit
64// 32-bit or 64-bit elements. For 256-bit vectors, it's considered as two 128
65// lanes. For VPERMILPS, referenced elements can't cross lanes and the mask of
66// the first lane must be the same of the second.
67void DecodeVPERMILPMask(EVT VT, unsigned Imm,
Bruno Cardoso Lopesb878caa2011-07-21 01:55:47 +000068 SmallVectorImpl<unsigned> &ShuffleMask);
69
Bruno Cardoso Lopesf15dfe52011-08-12 21:48:26 +000070void DecodeVPERM2F128Mask(unsigned Imm,
71 SmallVectorImpl<unsigned> &ShuffleMask);
72void DecodeVPERM2F128Mask(EVT VT, unsigned Imm,
73 SmallVectorImpl<unsigned> &ShuffleMask);
74
David Greene3a2b5082011-02-17 19:18:59 +000075} // llvm namespace
76
77#endif