X86ShuffleDecode.h revision 296417
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 MVT; 27 28enum { SM_SentinelUndef = -1, SM_SentinelZero = -2 }; 29 30void DecodeINSERTPSMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask); 31 32// <3,1> or <6,7,2,3> 33void DecodeMOVHLPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask); 34 35// <0,2> or <0,1,4,5> 36void DecodeMOVLHPSMask(unsigned NElts, SmallVectorImpl<int> &ShuffleMask); 37 38void DecodeMOVSLDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask); 39 40void DecodeMOVSHDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask); 41 42void DecodeMOVDDUPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask); 43 44void DecodePSLLDQMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask); 45 46void DecodePSRLDQMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask); 47 48void DecodePALIGNRMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask); 49 50void DecodePSHUFMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask); 51 52void DecodePSHUFHWMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask); 53 54void DecodePSHUFLWMask(MVT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask); 55 56/// \brief Decodes a PSWAPD 3DNow! instruction. 57void DecodePSWAPMask(MVT VT, SmallVectorImpl<int> &ShuffleMask); 58 59/// DecodeSHUFPMask - This decodes the shuffle masks for shufp*. VT indicates 60/// the type of the vector allowing it to handle different datatypes and vector 61/// widths. 62void DecodeSHUFPMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask); 63 64/// DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd 65/// and punpckh*. VT indicates the type of the vector allowing it to handle 66/// different datatypes and vector widths. 67void DecodeUNPCKHMask(MVT VT, SmallVectorImpl<int> &ShuffleMask); 68 69/// DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd 70/// and punpckl*. VT indicates the type of the vector allowing it to handle 71/// different datatypes and vector widths. 72void DecodeUNPCKLMask(MVT VT, SmallVectorImpl<int> &ShuffleMask); 73 74/// \brief Decode a PSHUFB mask from a raw array of constants such as from 75/// BUILD_VECTOR. 76void DecodePSHUFBMask(ArrayRef<uint64_t> RawMask, 77 SmallVectorImpl<int> &ShuffleMask); 78 79/// \brief Decode a BLEND immediate mask into a shuffle mask. 80void DecodeBLENDMask(MVT VT, unsigned Imm, SmallVectorImpl<int> &ShuffleMask); 81 82void DecodeVPERM2X128Mask(MVT VT, unsigned Imm, 83 SmallVectorImpl<int> &ShuffleMask); 84 85/// \brief Decode a shuffle packed values at 128-bit granularity 86/// immediate mask into a shuffle mask. 87void decodeVSHUF64x2FamilyMask(MVT VT, unsigned Imm, 88 SmallVectorImpl<int> &ShuffleMask); 89 90/// DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD. 91/// No VT provided since it only works on 256-bit, 4 element vectors. 92void DecodeVPERMMask(unsigned Imm, SmallVectorImpl<int> &ShuffleMask); 93 94/// \brief Decode a zero extension instruction as a shuffle mask. 95void DecodeZeroExtendMask(MVT SrcVT, MVT DstVT, 96 SmallVectorImpl<int> &ShuffleMask); 97 98/// \brief Decode a move lower and zero upper instruction as a shuffle mask. 99void DecodeZeroMoveLowMask(MVT VT, SmallVectorImpl<int> &ShuffleMask); 100 101/// \brief Decode a scalar float move instruction as a shuffle mask. 102void DecodeScalarMoveMask(MVT VT, bool IsLoad, 103 SmallVectorImpl<int> &ShuffleMask); 104 105/// \brief Decode a SSE4A EXTRQ instruction as a v16i8 shuffle mask. 106void DecodeEXTRQIMask(int Len, int Idx, 107 SmallVectorImpl<int> &ShuffleMask); 108 109/// \brief Decode a SSE4A INSERTQ instruction as a v16i8 shuffle mask. 110void DecodeINSERTQIMask(int Len, int Idx, 111 SmallVectorImpl<int> &ShuffleMask); 112 113/// \brief Decode a VPERM W/D/Q/PS/PD mask from a raw array of constants. 114void DecodeVPERMVMask(ArrayRef<uint64_t> RawMask, 115 SmallVectorImpl<int> &ShuffleMask); 116 117/// \brief Decode a VPERMT2 W/D/Q/PS/PD mask from a raw array of constants. 118void DecodeVPERMV3Mask(ArrayRef<uint64_t> RawMask, 119 SmallVectorImpl<int> &ShuffleMask); 120} // llvm namespace 121 122#endif 123