llvm.org GIT mirror llvm / d996c5b
[x86] Teach the instruction printer to decode immediate operands to BLENDPS, BLENDPD, and PBLENDW instructions into pretty shuffle comments. These will be used in my next commit as part of test cases for AVX shuffles which can directly use blend in more places. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215701 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 6 years ago
3 changed file(s) with 74 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
3434 const char *DestName = nullptr, *Src1Name = nullptr, *Src2Name = nullptr;
3535
3636 switch (MI->getOpcode()) {
37 case X86::BLENDPDrri:
38 case X86::VBLENDPDrri:
39 Src2Name = getRegName(MI->getOperand(2).getReg());
40 // FALL THROUGH.
41 case X86::BLENDPDrmi:
42 case X86::VBLENDPDrmi:
43 if(MI->getOperand(MI->getNumOperands()-1).isImm())
44 DecodeBLENDMask(MVT::v2f64,
45 MI->getOperand(MI->getNumOperands()-1).getImm(),
46 ShuffleMask);
47 Src1Name = getRegName(MI->getOperand(1).getReg());
48 DestName = getRegName(MI->getOperand(0).getReg());
49 break;
50 case X86::VBLENDPDYrri:
51 Src2Name = getRegName(MI->getOperand(2).getReg());
52 // FALL THROUGH.
53 case X86::VBLENDPDYrmi:
54 if(MI->getOperand(MI->getNumOperands()-1).isImm())
55 DecodeBLENDMask(MVT::v4f64,
56 MI->getOperand(MI->getNumOperands()-1).getImm(),
57 ShuffleMask);
58 Src1Name = getRegName(MI->getOperand(1).getReg());
59 DestName = getRegName(MI->getOperand(0).getReg());
60 break;
61
62 case X86::BLENDPSrri:
63 case X86::VBLENDPSrri:
64 Src2Name = getRegName(MI->getOperand(2).getReg());
65 // FALL THROUGH.
66 case X86::BLENDPSrmi:
67 case X86::VBLENDPSrmi:
68 if(MI->getOperand(MI->getNumOperands()-1).isImm())
69 DecodeBLENDMask(MVT::v4f32,
70 MI->getOperand(MI->getNumOperands()-1).getImm(),
71 ShuffleMask);
72 Src1Name = getRegName(MI->getOperand(1).getReg());
73 DestName = getRegName(MI->getOperand(0).getReg());
74 break;
75 case X86::VBLENDPSYrri:
76 Src2Name = getRegName(MI->getOperand(2).getReg());
77 // FALL THROUGH.
78 case X86::VBLENDPSYrmi:
79 if(MI->getOperand(MI->getNumOperands()-1).isImm())
80 DecodeBLENDMask(MVT::v8f32,
81 MI->getOperand(MI->getNumOperands()-1).getImm(),
82 ShuffleMask);
83 Src1Name = getRegName(MI->getOperand(1).getReg());
84 DestName = getRegName(MI->getOperand(0).getReg());
85 break;
86
87 case X86::PBLENDWrri:
88 case X86::VPBLENDWrri:
89 Src2Name = getRegName(MI->getOperand(2).getReg());
90 // FALL THROUGH.
91 case X86::PBLENDWrmi:
92 case X86::VPBLENDWrmi:
93 if(MI->getOperand(MI->getNumOperands()-1).isImm())
94 DecodeBLENDMask(MVT::v8i16,
95 MI->getOperand(MI->getNumOperands()-1).getImm(),
96 ShuffleMask);
97 Src1Name = getRegName(MI->getOperand(1).getReg());
98 DestName = getRegName(MI->getOperand(0).getReg());
99 break;
100
37101 case X86::INSERTPSrr:
38102 case X86::VINSERTPSrr:
39103 DestName = getRegName(MI->getOperand(0).getReg());
257257 }
258258 }
259259
260 void DecodeBLENDMask(MVT VT, unsigned Imm,
261 SmallVectorImpl &ShuffleMask) {
262 int NumElements = VT.getVectorNumElements();
263 for (int i = 0; i < NumElements; ++i)
264 ShuffleMask.push_back(((Imm >> i) & 1) ? NumElements + i : i);
265 }
266
260267 /// DecodeVPERMMask - this decodes the shuffle masks for VPERMQ/VPERMPD.
261268 /// No VT provided since it only works on 256-bit, 4 element vectors.
262269 void DecodeVPERMMask(unsigned Imm, SmallVectorImpl &ShuffleMask) {
6969 void DecodePSHUFBMask(ArrayRef RawMask,
7070 SmallVectorImpl &ShuffleMask);
7171
72 /// \brief Decode a BLEND immediate mask into a shuffle mask.
73 void DecodeBLENDMask(MVT VT, unsigned Imm, SmallVectorImpl &ShuffleMask);
74
7275 void DecodeVPERM2X128Mask(MVT VT, unsigned Imm,
7376 SmallVectorImpl &ShuffleMask);
7477