diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2011-07-29 01:31:11 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2011-07-29 01:31:11 +0000 |
commit | 795f558532f01176dc3c138bc64015b9ec1bbfc0 (patch) | |
tree | 06738e2155ef04773020769ccb31cb7a5466d189 /llvm/lib/Target/X86/Utils | |
parent | d23709b18caaefbf3ab37c116be6c00fb0420f35 (diff) | |
download | bcm5719-llvm-795f558532f01176dc3c138bc64015b9ec1bbfc0.tar.gz bcm5719-llvm-795f558532f01176dc3c138bc64015b9ec1bbfc0.zip |
Add DecodeShuffle shuffle support for VPERMIPD variantes
llvm-svn: 136452
Diffstat (limited to 'llvm/lib/Target/X86/Utils')
-rw-r--r-- | llvm/lib/Target/X86/Utils/X86ShuffleDecode.cpp | 45 | ||||
-rw-r--r-- | llvm/lib/Target/X86/Utils/X86ShuffleDecode.h | 15 |
2 files changed, 34 insertions, 26 deletions
diff --git a/llvm/lib/Target/X86/Utils/X86ShuffleDecode.cpp b/llvm/lib/Target/X86/Utils/X86ShuffleDecode.cpp index 2c8a9e4abc6..fe0b3a20c1f 100644 --- a/llvm/lib/Target/X86/Utils/X86ShuffleDecode.cpp +++ b/llvm/lib/Target/X86/Utils/X86ShuffleDecode.cpp @@ -186,29 +186,36 @@ void DecodeUNPCKLPMask(EVT VT, } } -void DecodeVPERMILPSMask(unsigned NElts, unsigned Imm, - SmallVectorImpl<unsigned> &ShuffleMask) { - DecodeVPERMILMask(MVT::getVectorVT(MVT::i32, NElts), Imm, ShuffleMask); -} +// DecodeVPERMILPSMask - Decodes VPERMILPS permutes for any 128-bit 32-bit +// elements. For 256-bit vectors, it's considered as two 128 lanes, the +// referenced elements can't cross lanes and the mask of the first lane must +// be the same of the second. +void DecodeVPERMILPSMask(unsigned NumElts, unsigned Imm, + SmallVectorImpl<unsigned> &ShuffleMask) { + unsigned NumLanes = (NumElts*32)/128; + unsigned LaneSize = NumElts/NumLanes; -void DecodeVPERMILPDMask(unsigned NElts, unsigned Imm, - SmallVectorImpl<unsigned> &ShuffleMask) { - DecodeVPERMILMask(MVT::getVectorVT(MVT::i64, NElts), Imm, ShuffleMask); + for (unsigned l = 0; l != NumLanes; ++l) { + for (unsigned i = 0; i != LaneSize; ++i) { + unsigned Idx = (Imm >> (i*2)) & 0x3 ; + ShuffleMask.push_back(Idx+(l*LaneSize)); + } + } } -// DecodeVPERMILMask - Decodes VPERMIL permutes for any 128-bit -// with 32/64-bit elements. For 256-bit vectors, it's considered -// as two 128 lanes and the mask of the first lane should be -// identical of the second one. -void DecodeVPERMILMask(EVT VT, unsigned Imm, - SmallVectorImpl<unsigned> &ShuffleMask) { - unsigned NumElts = VT.getVectorNumElements(); - unsigned NumLanes = VT.getSizeInBits()/128; +// DecodeVPERMILPDMask - Decodes VPERMILPD permutes for any 128-bit 64-bit +// elements. For 256-bit vectors, it's considered as two 128 lanes, the +// referenced elements can't cross lanes but the mask of the first lane can +// be the different of the second (not like VPERMILPS). +void DecodeVPERMILPDMask(unsigned NumElts, unsigned Imm, + SmallVectorImpl<unsigned> &ShuffleMask) { + unsigned NumLanes = (NumElts*64)/128; + unsigned LaneSize = NumElts/NumLanes; - for (unsigned l = 0; l != NumLanes; ++l) { - for (unsigned i = 0; i != NumElts/NumLanes; ++i) { - unsigned Idx = (Imm >> (i*2)) & 0x3 ; - ShuffleMask.push_back(Idx+(l*NumElts/NumLanes)); + for (unsigned l = 0; l < NumLanes; ++l) { + for (unsigned i = l*LaneSize; i < LaneSize*(l+1); ++i) { + unsigned Idx = (Imm >> i) & 0x1; + ShuffleMask.push_back(Idx+(l*LaneSize)); } } } diff --git a/llvm/lib/Target/X86/Utils/X86ShuffleDecode.h b/llvm/lib/Target/X86/Utils/X86ShuffleDecode.h index 4a5214028fa..1b11c6e3c26 100644 --- a/llvm/lib/Target/X86/Utils/X86ShuffleDecode.h +++ b/llvm/lib/Target/X86/Utils/X86ShuffleDecode.h @@ -83,19 +83,20 @@ void DecodeUNPCKLPMask(EVT VT, SmallVectorImpl<unsigned> &ShuffleMask); +// DecodeVPERMILPSMask - Decodes VPERMILPS permutes for any 128-bit 32-bit +// elements. For 256-bit vectors, it's considered as two 128 lanes, the +// referenced elements can't cross lanes and the mask of the first lane must +// be the same of the second. void DecodeVPERMILPSMask(unsigned NElts, unsigned Imm, SmallVectorImpl<unsigned> &ShuffleMask); +// DecodeVPERMILPDMask - Decodes VPERMILPD permutes for any 128-bit 64-bit +// elements. For 256-bit vectors, it's considered as two 128 lanes, the +// referenced elements can't cross lanes but the mask of the first lane can +// be the different of the second (not like VPERMILPS). void DecodeVPERMILPDMask(unsigned NElts, unsigned Imm, SmallVectorImpl<unsigned> &ShuffleMask); -// DecodeVPERMILMask - Decodes VPERMIL permutes for any 128-bit -// with 32/64-bit elements. For 256-bit vectors, it's considered -// as two 128 lanes and the mask of the first lane should be -// identical of the second one. -void DecodeVPERMILMask(EVT VT, unsigned Imm, - SmallVectorImpl<unsigned> &ShuffleMask); - } // llvm namespace #endif |