LLVM API Documentation
00001 //===-- X86InstComments.cpp - Generate verbose-asm comments for instrs ----===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This defines functionality used to emit comments about X86 instructions to 00011 // an output stream for -fverbose-asm. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #include "X86InstComments.h" 00016 #include "MCTargetDesc/X86MCTargetDesc.h" 00017 #include "Utils/X86ShuffleDecode.h" 00018 #include "llvm/MC/MCInst.h" 00019 #include "llvm/CodeGen/MachineValueType.h" 00020 #include "llvm/Support/raw_ostream.h" 00021 00022 using namespace llvm; 00023 00024 //===----------------------------------------------------------------------===// 00025 // Top Level Entrypoint 00026 //===----------------------------------------------------------------------===// 00027 00028 /// EmitAnyX86InstComments - This function decodes x86 instructions and prints 00029 /// newline terminated strings to the specified string if desired. This 00030 /// information is shown in disassembly dumps when verbose assembly is enabled. 00031 bool llvm::EmitAnyX86InstComments(const MCInst *MI, raw_ostream &OS, 00032 const char *(*getRegName)(unsigned)) { 00033 // If this is a shuffle operation, the switch should fill in this state. 00034 SmallVector<int, 8> ShuffleMask; 00035 const char *DestName = nullptr, *Src1Name = nullptr, *Src2Name = nullptr; 00036 00037 switch (MI->getOpcode()) { 00038 default: 00039 // Not an instruction for which we can decode comments. 00040 return false; 00041 00042 case X86::BLENDPDrri: 00043 case X86::VBLENDPDrri: 00044 Src2Name = getRegName(MI->getOperand(2).getReg()); 00045 // FALL THROUGH. 00046 case X86::BLENDPDrmi: 00047 case X86::VBLENDPDrmi: 00048 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00049 DecodeBLENDMask(MVT::v2f64, 00050 MI->getOperand(MI->getNumOperands()-1).getImm(), 00051 ShuffleMask); 00052 Src1Name = getRegName(MI->getOperand(1).getReg()); 00053 DestName = getRegName(MI->getOperand(0).getReg()); 00054 break; 00055 case X86::VBLENDPDYrri: 00056 Src2Name = getRegName(MI->getOperand(2).getReg()); 00057 // FALL THROUGH. 00058 case X86::VBLENDPDYrmi: 00059 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00060 DecodeBLENDMask(MVT::v4f64, 00061 MI->getOperand(MI->getNumOperands()-1).getImm(), 00062 ShuffleMask); 00063 Src1Name = getRegName(MI->getOperand(1).getReg()); 00064 DestName = getRegName(MI->getOperand(0).getReg()); 00065 break; 00066 00067 case X86::BLENDPSrri: 00068 case X86::VBLENDPSrri: 00069 Src2Name = getRegName(MI->getOperand(2).getReg()); 00070 // FALL THROUGH. 00071 case X86::BLENDPSrmi: 00072 case X86::VBLENDPSrmi: 00073 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00074 DecodeBLENDMask(MVT::v4f32, 00075 MI->getOperand(MI->getNumOperands()-1).getImm(), 00076 ShuffleMask); 00077 Src1Name = getRegName(MI->getOperand(1).getReg()); 00078 DestName = getRegName(MI->getOperand(0).getReg()); 00079 break; 00080 case X86::VBLENDPSYrri: 00081 Src2Name = getRegName(MI->getOperand(2).getReg()); 00082 // FALL THROUGH. 00083 case X86::VBLENDPSYrmi: 00084 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00085 DecodeBLENDMask(MVT::v8f32, 00086 MI->getOperand(MI->getNumOperands()-1).getImm(), 00087 ShuffleMask); 00088 Src1Name = getRegName(MI->getOperand(1).getReg()); 00089 DestName = getRegName(MI->getOperand(0).getReg()); 00090 break; 00091 00092 case X86::PBLENDWrri: 00093 case X86::VPBLENDWrri: 00094 Src2Name = getRegName(MI->getOperand(2).getReg()); 00095 // FALL THROUGH. 00096 case X86::PBLENDWrmi: 00097 case X86::VPBLENDWrmi: 00098 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00099 DecodeBLENDMask(MVT::v8i16, 00100 MI->getOperand(MI->getNumOperands()-1).getImm(), 00101 ShuffleMask); 00102 Src1Name = getRegName(MI->getOperand(1).getReg()); 00103 DestName = getRegName(MI->getOperand(0).getReg()); 00104 break; 00105 00106 case X86::INSERTPSrr: 00107 case X86::VINSERTPSrr: 00108 DestName = getRegName(MI->getOperand(0).getReg()); 00109 Src1Name = getRegName(MI->getOperand(1).getReg()); 00110 Src2Name = getRegName(MI->getOperand(2).getReg()); 00111 if(MI->getOperand(3).isImm()) 00112 DecodeINSERTPSMask(MI->getOperand(3).getImm(), ShuffleMask); 00113 break; 00114 00115 case X86::MOVLHPSrr: 00116 case X86::VMOVLHPSrr: 00117 Src2Name = getRegName(MI->getOperand(2).getReg()); 00118 Src1Name = getRegName(MI->getOperand(1).getReg()); 00119 DestName = getRegName(MI->getOperand(0).getReg()); 00120 DecodeMOVLHPSMask(2, ShuffleMask); 00121 break; 00122 00123 case X86::MOVHLPSrr: 00124 case X86::VMOVHLPSrr: 00125 Src2Name = getRegName(MI->getOperand(2).getReg()); 00126 Src1Name = getRegName(MI->getOperand(1).getReg()); 00127 DestName = getRegName(MI->getOperand(0).getReg()); 00128 DecodeMOVHLPSMask(2, ShuffleMask); 00129 break; 00130 00131 case X86::MOVSLDUPrr: 00132 case X86::VMOVSLDUPrr: 00133 Src1Name = getRegName(MI->getOperand(1).getReg()); 00134 // FALL THROUGH. 00135 case X86::MOVSLDUPrm: 00136 case X86::VMOVSLDUPrm: 00137 DestName = getRegName(MI->getOperand(0).getReg()); 00138 DecodeMOVSLDUPMask(MVT::v4f32, ShuffleMask); 00139 break; 00140 00141 case X86::VMOVSHDUPYrr: 00142 Src1Name = getRegName(MI->getOperand(1).getReg()); 00143 // FALL THROUGH. 00144 case X86::VMOVSHDUPYrm: 00145 DestName = getRegName(MI->getOperand(0).getReg()); 00146 DecodeMOVSHDUPMask(MVT::v8f32, ShuffleMask); 00147 break; 00148 00149 case X86::VMOVSLDUPYrr: 00150 Src1Name = getRegName(MI->getOperand(1).getReg()); 00151 // FALL THROUGH. 00152 case X86::VMOVSLDUPYrm: 00153 DestName = getRegName(MI->getOperand(0).getReg()); 00154 DecodeMOVSLDUPMask(MVT::v8f32, ShuffleMask); 00155 break; 00156 00157 case X86::MOVSHDUPrr: 00158 case X86::VMOVSHDUPrr: 00159 Src1Name = getRegName(MI->getOperand(1).getReg()); 00160 // FALL THROUGH. 00161 case X86::MOVSHDUPrm: 00162 case X86::VMOVSHDUPrm: 00163 DestName = getRegName(MI->getOperand(0).getReg()); 00164 DecodeMOVSHDUPMask(MVT::v4f32, ShuffleMask); 00165 break; 00166 00167 case X86::PALIGNR128rr: 00168 case X86::VPALIGNR128rr: 00169 Src1Name = getRegName(MI->getOperand(2).getReg()); 00170 // FALL THROUGH. 00171 case X86::PALIGNR128rm: 00172 case X86::VPALIGNR128rm: 00173 Src2Name = getRegName(MI->getOperand(1).getReg()); 00174 DestName = getRegName(MI->getOperand(0).getReg()); 00175 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00176 DecodePALIGNRMask(MVT::v16i8, 00177 MI->getOperand(MI->getNumOperands()-1).getImm(), 00178 ShuffleMask); 00179 break; 00180 case X86::VPALIGNR256rr: 00181 Src1Name = getRegName(MI->getOperand(2).getReg()); 00182 // FALL THROUGH. 00183 case X86::VPALIGNR256rm: 00184 Src2Name = getRegName(MI->getOperand(1).getReg()); 00185 DestName = getRegName(MI->getOperand(0).getReg()); 00186 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00187 DecodePALIGNRMask(MVT::v32i8, 00188 MI->getOperand(MI->getNumOperands()-1).getImm(), 00189 ShuffleMask); 00190 break; 00191 00192 case X86::PSHUFDri: 00193 case X86::VPSHUFDri: 00194 Src1Name = getRegName(MI->getOperand(1).getReg()); 00195 // FALL THROUGH. 00196 case X86::PSHUFDmi: 00197 case X86::VPSHUFDmi: 00198 DestName = getRegName(MI->getOperand(0).getReg()); 00199 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00200 DecodePSHUFMask(MVT::v4i32, 00201 MI->getOperand(MI->getNumOperands()-1).getImm(), 00202 ShuffleMask); 00203 break; 00204 case X86::VPSHUFDYri: 00205 Src1Name = getRegName(MI->getOperand(1).getReg()); 00206 // FALL THROUGH. 00207 case X86::VPSHUFDYmi: 00208 DestName = getRegName(MI->getOperand(0).getReg()); 00209 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00210 DecodePSHUFMask(MVT::v8i32, 00211 MI->getOperand(MI->getNumOperands()-1).getImm(), 00212 ShuffleMask); 00213 break; 00214 00215 00216 case X86::PSHUFHWri: 00217 case X86::VPSHUFHWri: 00218 Src1Name = getRegName(MI->getOperand(1).getReg()); 00219 // FALL THROUGH. 00220 case X86::PSHUFHWmi: 00221 case X86::VPSHUFHWmi: 00222 DestName = getRegName(MI->getOperand(0).getReg()); 00223 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00224 DecodePSHUFHWMask(MVT::v8i16, 00225 MI->getOperand(MI->getNumOperands()-1).getImm(), 00226 ShuffleMask); 00227 break; 00228 case X86::VPSHUFHWYri: 00229 Src1Name = getRegName(MI->getOperand(1).getReg()); 00230 // FALL THROUGH. 00231 case X86::VPSHUFHWYmi: 00232 DestName = getRegName(MI->getOperand(0).getReg()); 00233 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00234 DecodePSHUFHWMask(MVT::v16i16, 00235 MI->getOperand(MI->getNumOperands()-1).getImm(), 00236 ShuffleMask); 00237 break; 00238 case X86::PSHUFLWri: 00239 case X86::VPSHUFLWri: 00240 Src1Name = getRegName(MI->getOperand(1).getReg()); 00241 // FALL THROUGH. 00242 case X86::PSHUFLWmi: 00243 case X86::VPSHUFLWmi: 00244 DestName = getRegName(MI->getOperand(0).getReg()); 00245 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00246 DecodePSHUFLWMask(MVT::v8i16, 00247 MI->getOperand(MI->getNumOperands()-1).getImm(), 00248 ShuffleMask); 00249 break; 00250 case X86::VPSHUFLWYri: 00251 Src1Name = getRegName(MI->getOperand(1).getReg()); 00252 // FALL THROUGH. 00253 case X86::VPSHUFLWYmi: 00254 DestName = getRegName(MI->getOperand(0).getReg()); 00255 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00256 DecodePSHUFLWMask(MVT::v16i16, 00257 MI->getOperand(MI->getNumOperands()-1).getImm(), 00258 ShuffleMask); 00259 break; 00260 00261 case X86::PUNPCKHBWrr: 00262 case X86::VPUNPCKHBWrr: 00263 Src2Name = getRegName(MI->getOperand(2).getReg()); 00264 // FALL THROUGH. 00265 case X86::PUNPCKHBWrm: 00266 case X86::VPUNPCKHBWrm: 00267 Src1Name = getRegName(MI->getOperand(1).getReg()); 00268 DestName = getRegName(MI->getOperand(0).getReg()); 00269 DecodeUNPCKHMask(MVT::v16i8, ShuffleMask); 00270 break; 00271 case X86::VPUNPCKHBWYrr: 00272 Src2Name = getRegName(MI->getOperand(2).getReg()); 00273 // FALL THROUGH. 00274 case X86::VPUNPCKHBWYrm: 00275 Src1Name = getRegName(MI->getOperand(1).getReg()); 00276 DestName = getRegName(MI->getOperand(0).getReg()); 00277 DecodeUNPCKHMask(MVT::v32i8, ShuffleMask); 00278 break; 00279 case X86::PUNPCKHWDrr: 00280 case X86::VPUNPCKHWDrr: 00281 Src2Name = getRegName(MI->getOperand(2).getReg()); 00282 // FALL THROUGH. 00283 case X86::PUNPCKHWDrm: 00284 case X86::VPUNPCKHWDrm: 00285 Src1Name = getRegName(MI->getOperand(1).getReg()); 00286 DestName = getRegName(MI->getOperand(0).getReg()); 00287 DecodeUNPCKHMask(MVT::v8i16, ShuffleMask); 00288 break; 00289 case X86::VPUNPCKHWDYrr: 00290 Src2Name = getRegName(MI->getOperand(2).getReg()); 00291 // FALL THROUGH. 00292 case X86::VPUNPCKHWDYrm: 00293 Src1Name = getRegName(MI->getOperand(1).getReg()); 00294 DestName = getRegName(MI->getOperand(0).getReg()); 00295 DecodeUNPCKHMask(MVT::v16i16, ShuffleMask); 00296 break; 00297 case X86::PUNPCKHDQrr: 00298 case X86::VPUNPCKHDQrr: 00299 Src2Name = getRegName(MI->getOperand(2).getReg()); 00300 // FALL THROUGH. 00301 case X86::PUNPCKHDQrm: 00302 case X86::VPUNPCKHDQrm: 00303 Src1Name = getRegName(MI->getOperand(1).getReg()); 00304 DestName = getRegName(MI->getOperand(0).getReg()); 00305 DecodeUNPCKHMask(MVT::v4i32, ShuffleMask); 00306 break; 00307 case X86::VPUNPCKHDQYrr: 00308 Src2Name = getRegName(MI->getOperand(2).getReg()); 00309 // FALL THROUGH. 00310 case X86::VPUNPCKHDQYrm: 00311 Src1Name = getRegName(MI->getOperand(1).getReg()); 00312 DestName = getRegName(MI->getOperand(0).getReg()); 00313 DecodeUNPCKHMask(MVT::v8i32, ShuffleMask); 00314 break; 00315 case X86::PUNPCKHQDQrr: 00316 case X86::VPUNPCKHQDQrr: 00317 Src2Name = getRegName(MI->getOperand(2).getReg()); 00318 // FALL THROUGH. 00319 case X86::PUNPCKHQDQrm: 00320 case X86::VPUNPCKHQDQrm: 00321 Src1Name = getRegName(MI->getOperand(1).getReg()); 00322 DestName = getRegName(MI->getOperand(0).getReg()); 00323 DecodeUNPCKHMask(MVT::v2i64, ShuffleMask); 00324 break; 00325 case X86::VPUNPCKHQDQYrr: 00326 Src2Name = getRegName(MI->getOperand(2).getReg()); 00327 // FALL THROUGH. 00328 case X86::VPUNPCKHQDQYrm: 00329 Src1Name = getRegName(MI->getOperand(1).getReg()); 00330 DestName = getRegName(MI->getOperand(0).getReg()); 00331 DecodeUNPCKHMask(MVT::v4i64, ShuffleMask); 00332 break; 00333 00334 case X86::PUNPCKLBWrr: 00335 case X86::VPUNPCKLBWrr: 00336 Src2Name = getRegName(MI->getOperand(2).getReg()); 00337 // FALL THROUGH. 00338 case X86::PUNPCKLBWrm: 00339 case X86::VPUNPCKLBWrm: 00340 Src1Name = getRegName(MI->getOperand(1).getReg()); 00341 DestName = getRegName(MI->getOperand(0).getReg()); 00342 DecodeUNPCKLMask(MVT::v16i8, ShuffleMask); 00343 break; 00344 case X86::VPUNPCKLBWYrr: 00345 Src2Name = getRegName(MI->getOperand(2).getReg()); 00346 // FALL THROUGH. 00347 case X86::VPUNPCKLBWYrm: 00348 Src1Name = getRegName(MI->getOperand(1).getReg()); 00349 DestName = getRegName(MI->getOperand(0).getReg()); 00350 DecodeUNPCKLMask(MVT::v32i8, ShuffleMask); 00351 break; 00352 case X86::PUNPCKLWDrr: 00353 case X86::VPUNPCKLWDrr: 00354 Src2Name = getRegName(MI->getOperand(2).getReg()); 00355 // FALL THROUGH. 00356 case X86::PUNPCKLWDrm: 00357 case X86::VPUNPCKLWDrm: 00358 Src1Name = getRegName(MI->getOperand(1).getReg()); 00359 DestName = getRegName(MI->getOperand(0).getReg()); 00360 DecodeUNPCKLMask(MVT::v8i16, ShuffleMask); 00361 break; 00362 case X86::VPUNPCKLWDYrr: 00363 Src2Name = getRegName(MI->getOperand(2).getReg()); 00364 // FALL THROUGH. 00365 case X86::VPUNPCKLWDYrm: 00366 Src1Name = getRegName(MI->getOperand(1).getReg()); 00367 DestName = getRegName(MI->getOperand(0).getReg()); 00368 DecodeUNPCKLMask(MVT::v16i16, ShuffleMask); 00369 break; 00370 case X86::PUNPCKLDQrr: 00371 case X86::VPUNPCKLDQrr: 00372 Src2Name = getRegName(MI->getOperand(2).getReg()); 00373 // FALL THROUGH. 00374 case X86::PUNPCKLDQrm: 00375 case X86::VPUNPCKLDQrm: 00376 Src1Name = getRegName(MI->getOperand(1).getReg()); 00377 DestName = getRegName(MI->getOperand(0).getReg()); 00378 DecodeUNPCKLMask(MVT::v4i32, ShuffleMask); 00379 break; 00380 case X86::VPUNPCKLDQYrr: 00381 Src2Name = getRegName(MI->getOperand(2).getReg()); 00382 // FALL THROUGH. 00383 case X86::VPUNPCKLDQYrm: 00384 Src1Name = getRegName(MI->getOperand(1).getReg()); 00385 DestName = getRegName(MI->getOperand(0).getReg()); 00386 DecodeUNPCKLMask(MVT::v8i32, ShuffleMask); 00387 break; 00388 case X86::PUNPCKLQDQrr: 00389 case X86::VPUNPCKLQDQrr: 00390 Src2Name = getRegName(MI->getOperand(2).getReg()); 00391 // FALL THROUGH. 00392 case X86::PUNPCKLQDQrm: 00393 case X86::VPUNPCKLQDQrm: 00394 Src1Name = getRegName(MI->getOperand(1).getReg()); 00395 DestName = getRegName(MI->getOperand(0).getReg()); 00396 DecodeUNPCKLMask(MVT::v2i64, ShuffleMask); 00397 break; 00398 case X86::VPUNPCKLQDQYrr: 00399 Src2Name = getRegName(MI->getOperand(2).getReg()); 00400 // FALL THROUGH. 00401 case X86::VPUNPCKLQDQYrm: 00402 Src1Name = getRegName(MI->getOperand(1).getReg()); 00403 DestName = getRegName(MI->getOperand(0).getReg()); 00404 DecodeUNPCKLMask(MVT::v4i64, ShuffleMask); 00405 break; 00406 00407 case X86::SHUFPDrri: 00408 case X86::VSHUFPDrri: 00409 Src2Name = getRegName(MI->getOperand(2).getReg()); 00410 // FALL THROUGH. 00411 case X86::SHUFPDrmi: 00412 case X86::VSHUFPDrmi: 00413 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00414 DecodeSHUFPMask(MVT::v2f64, 00415 MI->getOperand(MI->getNumOperands()-1).getImm(), 00416 ShuffleMask); 00417 Src1Name = getRegName(MI->getOperand(1).getReg()); 00418 DestName = getRegName(MI->getOperand(0).getReg()); 00419 break; 00420 case X86::VSHUFPDYrri: 00421 Src2Name = getRegName(MI->getOperand(2).getReg()); 00422 // FALL THROUGH. 00423 case X86::VSHUFPDYrmi: 00424 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00425 DecodeSHUFPMask(MVT::v4f64, 00426 MI->getOperand(MI->getNumOperands()-1).getImm(), 00427 ShuffleMask); 00428 Src1Name = getRegName(MI->getOperand(1).getReg()); 00429 DestName = getRegName(MI->getOperand(0).getReg()); 00430 break; 00431 00432 case X86::SHUFPSrri: 00433 case X86::VSHUFPSrri: 00434 Src2Name = getRegName(MI->getOperand(2).getReg()); 00435 // FALL THROUGH. 00436 case X86::SHUFPSrmi: 00437 case X86::VSHUFPSrmi: 00438 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00439 DecodeSHUFPMask(MVT::v4f32, 00440 MI->getOperand(MI->getNumOperands()-1).getImm(), 00441 ShuffleMask); 00442 Src1Name = getRegName(MI->getOperand(1).getReg()); 00443 DestName = getRegName(MI->getOperand(0).getReg()); 00444 break; 00445 case X86::VSHUFPSYrri: 00446 Src2Name = getRegName(MI->getOperand(2).getReg()); 00447 // FALL THROUGH. 00448 case X86::VSHUFPSYrmi: 00449 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00450 DecodeSHUFPMask(MVT::v8f32, 00451 MI->getOperand(MI->getNumOperands()-1).getImm(), 00452 ShuffleMask); 00453 Src1Name = getRegName(MI->getOperand(1).getReg()); 00454 DestName = getRegName(MI->getOperand(0).getReg()); 00455 break; 00456 00457 case X86::UNPCKLPDrr: 00458 case X86::VUNPCKLPDrr: 00459 Src2Name = getRegName(MI->getOperand(2).getReg()); 00460 // FALL THROUGH. 00461 case X86::UNPCKLPDrm: 00462 case X86::VUNPCKLPDrm: 00463 DecodeUNPCKLMask(MVT::v2f64, ShuffleMask); 00464 Src1Name = getRegName(MI->getOperand(1).getReg()); 00465 DestName = getRegName(MI->getOperand(0).getReg()); 00466 break; 00467 case X86::VUNPCKLPDYrr: 00468 Src2Name = getRegName(MI->getOperand(2).getReg()); 00469 // FALL THROUGH. 00470 case X86::VUNPCKLPDYrm: 00471 DecodeUNPCKLMask(MVT::v4f64, ShuffleMask); 00472 Src1Name = getRegName(MI->getOperand(1).getReg()); 00473 DestName = getRegName(MI->getOperand(0).getReg()); 00474 break; 00475 case X86::UNPCKLPSrr: 00476 case X86::VUNPCKLPSrr: 00477 Src2Name = getRegName(MI->getOperand(2).getReg()); 00478 // FALL THROUGH. 00479 case X86::UNPCKLPSrm: 00480 case X86::VUNPCKLPSrm: 00481 DecodeUNPCKLMask(MVT::v4f32, ShuffleMask); 00482 Src1Name = getRegName(MI->getOperand(1).getReg()); 00483 DestName = getRegName(MI->getOperand(0).getReg()); 00484 break; 00485 case X86::VUNPCKLPSYrr: 00486 Src2Name = getRegName(MI->getOperand(2).getReg()); 00487 // FALL THROUGH. 00488 case X86::VUNPCKLPSYrm: 00489 DecodeUNPCKLMask(MVT::v8f32, ShuffleMask); 00490 Src1Name = getRegName(MI->getOperand(1).getReg()); 00491 DestName = getRegName(MI->getOperand(0).getReg()); 00492 break; 00493 case X86::UNPCKHPDrr: 00494 case X86::VUNPCKHPDrr: 00495 Src2Name = getRegName(MI->getOperand(2).getReg()); 00496 // FALL THROUGH. 00497 case X86::UNPCKHPDrm: 00498 case X86::VUNPCKHPDrm: 00499 DecodeUNPCKHMask(MVT::v2f64, ShuffleMask); 00500 Src1Name = getRegName(MI->getOperand(1).getReg()); 00501 DestName = getRegName(MI->getOperand(0).getReg()); 00502 break; 00503 case X86::VUNPCKHPDYrr: 00504 Src2Name = getRegName(MI->getOperand(2).getReg()); 00505 // FALL THROUGH. 00506 case X86::VUNPCKHPDYrm: 00507 DecodeUNPCKHMask(MVT::v4f64, ShuffleMask); 00508 Src1Name = getRegName(MI->getOperand(1).getReg()); 00509 DestName = getRegName(MI->getOperand(0).getReg()); 00510 break; 00511 case X86::UNPCKHPSrr: 00512 case X86::VUNPCKHPSrr: 00513 Src2Name = getRegName(MI->getOperand(2).getReg()); 00514 // FALL THROUGH. 00515 case X86::UNPCKHPSrm: 00516 case X86::VUNPCKHPSrm: 00517 DecodeUNPCKHMask(MVT::v4f32, ShuffleMask); 00518 Src1Name = getRegName(MI->getOperand(1).getReg()); 00519 DestName = getRegName(MI->getOperand(0).getReg()); 00520 break; 00521 case X86::VUNPCKHPSYrr: 00522 Src2Name = getRegName(MI->getOperand(2).getReg()); 00523 // FALL THROUGH. 00524 case X86::VUNPCKHPSYrm: 00525 DecodeUNPCKHMask(MVT::v8f32, ShuffleMask); 00526 Src1Name = getRegName(MI->getOperand(1).getReg()); 00527 DestName = getRegName(MI->getOperand(0).getReg()); 00528 break; 00529 case X86::VPERMILPSri: 00530 Src1Name = getRegName(MI->getOperand(1).getReg()); 00531 // FALL THROUGH. 00532 case X86::VPERMILPSmi: 00533 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00534 DecodePSHUFMask(MVT::v4f32, 00535 MI->getOperand(MI->getNumOperands()-1).getImm(), 00536 ShuffleMask); 00537 DestName = getRegName(MI->getOperand(0).getReg()); 00538 break; 00539 case X86::VPERMILPSYri: 00540 Src1Name = getRegName(MI->getOperand(1).getReg()); 00541 // FALL THROUGH. 00542 case X86::VPERMILPSYmi: 00543 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00544 DecodePSHUFMask(MVT::v8f32, 00545 MI->getOperand(MI->getNumOperands()-1).getImm(), 00546 ShuffleMask); 00547 DestName = getRegName(MI->getOperand(0).getReg()); 00548 break; 00549 case X86::VPERMILPDri: 00550 Src1Name = getRegName(MI->getOperand(1).getReg()); 00551 // FALL THROUGH. 00552 case X86::VPERMILPDmi: 00553 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00554 DecodePSHUFMask(MVT::v2f64, 00555 MI->getOperand(MI->getNumOperands()-1).getImm(), 00556 ShuffleMask); 00557 DestName = getRegName(MI->getOperand(0).getReg()); 00558 break; 00559 case X86::VPERMILPDYri: 00560 Src1Name = getRegName(MI->getOperand(1).getReg()); 00561 // FALL THROUGH. 00562 case X86::VPERMILPDYmi: 00563 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00564 DecodePSHUFMask(MVT::v4f64, 00565 MI->getOperand(MI->getNumOperands()-1).getImm(), 00566 ShuffleMask); 00567 DestName = getRegName(MI->getOperand(0).getReg()); 00568 break; 00569 case X86::VPERM2F128rr: 00570 case X86::VPERM2I128rr: 00571 Src2Name = getRegName(MI->getOperand(2).getReg()); 00572 // FALL THROUGH. 00573 case X86::VPERM2F128rm: 00574 case X86::VPERM2I128rm: 00575 // For instruction comments purpose, assume the 256-bit vector is v4i64. 00576 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00577 DecodeVPERM2X128Mask(MVT::v4i64, 00578 MI->getOperand(MI->getNumOperands()-1).getImm(), 00579 ShuffleMask); 00580 Src1Name = getRegName(MI->getOperand(1).getReg()); 00581 DestName = getRegName(MI->getOperand(0).getReg()); 00582 break; 00583 case X86::VPERMQYri: 00584 case X86::VPERMPDYri: 00585 Src1Name = getRegName(MI->getOperand(1).getReg()); 00586 // FALL THROUGH. 00587 case X86::VPERMQYmi: 00588 case X86::VPERMPDYmi: 00589 if(MI->getOperand(MI->getNumOperands()-1).isImm()) 00590 DecodeVPERMMask(MI->getOperand(MI->getNumOperands()-1).getImm(), 00591 ShuffleMask); 00592 DestName = getRegName(MI->getOperand(0).getReg()); 00593 break; 00594 } 00595 00596 // The only comments we decode are shuffles, so give up if we were unable to 00597 // decode a shuffle mask. 00598 if (ShuffleMask.empty()) 00599 return false; 00600 00601 if (!DestName) DestName = Src1Name; 00602 OS << (DestName ? DestName : "mem") << " = "; 00603 00604 // If the two sources are the same, canonicalize the input elements to be 00605 // from the first src so that we get larger element spans. 00606 if (Src1Name == Src2Name) { 00607 for (unsigned i = 0, e = ShuffleMask.size(); i != e; ++i) { 00608 if ((int)ShuffleMask[i] >= 0 && // Not sentinel. 00609 ShuffleMask[i] >= (int)e) // From second mask. 00610 ShuffleMask[i] -= e; 00611 } 00612 } 00613 00614 // The shuffle mask specifies which elements of the src1/src2 fill in the 00615 // destination, with a few sentinel values. Loop through and print them 00616 // out. 00617 for (unsigned i = 0, e = ShuffleMask.size(); i != e; ++i) { 00618 if (i != 0) 00619 OS << ','; 00620 if (ShuffleMask[i] == SM_SentinelZero) { 00621 OS << "zero"; 00622 continue; 00623 } 00624 00625 // Otherwise, it must come from src1 or src2. Print the span of elements 00626 // that comes from this src. 00627 bool isSrc1 = ShuffleMask[i] < (int)ShuffleMask.size(); 00628 const char *SrcName = isSrc1 ? Src1Name : Src2Name; 00629 OS << (SrcName ? SrcName : "mem") << '['; 00630 bool IsFirst = true; 00631 while (i != e && 00632 (int)ShuffleMask[i] >= 0 && 00633 (ShuffleMask[i] < (int)ShuffleMask.size()) == isSrc1) { 00634 if (!IsFirst) 00635 OS << ','; 00636 else 00637 IsFirst = false; 00638 OS << ShuffleMask[i] % ShuffleMask.size(); 00639 ++i; 00640 } 00641 OS << ']'; 00642 --i; // For loop increments element #. 00643 } 00644 //MI->print(OS, 0); 00645 OS << "\n"; 00646 00647 // We successfully added a comment to this instruction. 00648 return true; 00649 }