| OLD | NEW |
| 1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===// | 1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This file implements the InstX8632 and OperandX8632 classes, | 10 // This file implements the InstX8632 and OperandX8632 classes, |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 return false; | 305 return false; |
| 306 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { | 306 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { |
| 307 return true; | 307 return true; |
| 308 } | 308 } |
| 309 if (!getDest()->hasReg() && !Src->hasReg() && | 309 if (!getDest()->hasReg() && !Src->hasReg() && |
| 310 Dest->getStackOffset() == Src->getStackOffset()) | 310 Dest->getStackOffset() == Src->getStackOffset()) |
| 311 return true; | 311 return true; |
| 312 return false; | 312 return false; |
| 313 } | 313 } |
| 314 | 314 |
| 315 InstX8632Pshufd::InstX8632Pshufd(Cfg *Func, Variable *Dest, Operand *Source1, |
| 316 Operand *Source2) |
| 317 : InstX8632(Func, InstX8632::Pshufd, 2, Dest) { |
| 318 addSource(Source1); |
| 319 addSource(Source2); |
| 320 } |
| 321 |
| 322 InstX8632Shufps::InstX8632Shufps(Cfg *Func, Variable *Dest, Operand *Source1, |
| 323 Operand *Source2) |
| 324 : InstX8632(Func, InstX8632::Shufps, 3, Dest) { |
| 325 addSource(Dest); |
| 326 addSource(Source1); |
| 327 addSource(Source2); |
| 328 } |
| 329 |
| 315 InstX8632Ret::InstX8632Ret(Cfg *Func, Variable *Source) | 330 InstX8632Ret::InstX8632Ret(Cfg *Func, Variable *Source) |
| 316 : InstX8632(Func, InstX8632::Ret, Source ? 1 : 0, NULL) { | 331 : InstX8632(Func, InstX8632::Ret, Source ? 1 : 0, NULL) { |
| 317 if (Source) | 332 if (Source) |
| 318 addSource(Source); | 333 addSource(Source); |
| 319 } | 334 } |
| 320 | 335 |
| 321 InstX8632Xadd::InstX8632Xadd(Cfg *Func, Operand *Dest, Variable *Source, | 336 InstX8632Xadd::InstX8632Xadd(Cfg *Func, Operand *Dest, Variable *Source, |
| 322 bool Locked) | 337 bool Locked) |
| 323 : InstX8632Lockable(Func, InstX8632::Xadd, 2, | 338 : InstX8632Lockable(Func, InstX8632::Xadd, 2, |
| 324 llvm::dyn_cast<Variable>(Dest), Locked) { | 339 llvm::dyn_cast<Variable>(Dest), Locked) { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 Str << "\n"; | 454 Str << "\n"; |
| 440 } | 455 } |
| 441 | 456 |
| 442 template <> const char *InstX8632Bsf::Opcode = "bsf"; | 457 template <> const char *InstX8632Bsf::Opcode = "bsf"; |
| 443 template <> const char *InstX8632Bsr::Opcode = "bsr"; | 458 template <> const char *InstX8632Bsr::Opcode = "bsr"; |
| 444 template <> const char *InstX8632Sqrtss::Opcode = "sqrtss"; | 459 template <> const char *InstX8632Sqrtss::Opcode = "sqrtss"; |
| 445 template <> const char *InstX8632Add::Opcode = "add"; | 460 template <> const char *InstX8632Add::Opcode = "add"; |
| 446 template <> const char *InstX8632Addps::Opcode = "addps"; | 461 template <> const char *InstX8632Addps::Opcode = "addps"; |
| 447 template <> const char *InstX8632Adc::Opcode = "adc"; | 462 template <> const char *InstX8632Adc::Opcode = "adc"; |
| 448 template <> const char *InstX8632Addss::Opcode = "addss"; | 463 template <> const char *InstX8632Addss::Opcode = "addss"; |
| 464 template <> const char *InstX8632Padd::Opcode = "padd"; |
| 449 template <> const char *InstX8632Sub::Opcode = "sub"; | 465 template <> const char *InstX8632Sub::Opcode = "sub"; |
| 450 template <> const char *InstX8632Subps::Opcode = "subps"; | 466 template <> const char *InstX8632Subps::Opcode = "subps"; |
| 451 template <> const char *InstX8632Subss::Opcode = "subss"; | 467 template <> const char *InstX8632Subss::Opcode = "subss"; |
| 468 template <> const char *InstX8632Sbb::Opcode = "sbb"; |
| 452 template <> const char *InstX8632Psub::Opcode = "psub"; | 469 template <> const char *InstX8632Psub::Opcode = "psub"; |
| 453 template <> const char *InstX8632Sbb::Opcode = "sbb"; | |
| 454 template <> const char *InstX8632And::Opcode = "and"; | 470 template <> const char *InstX8632And::Opcode = "and"; |
| 455 template <> const char *InstX8632Pand::Opcode = "pand"; | 471 template <> const char *InstX8632Pand::Opcode = "pand"; |
| 456 template <> const char *InstX8632Or::Opcode = "or"; | 472 template <> const char *InstX8632Or::Opcode = "or"; |
| 473 template <> const char *InstX8632Por::Opcode = "por"; |
| 457 template <> const char *InstX8632Xor::Opcode = "xor"; | 474 template <> const char *InstX8632Xor::Opcode = "xor"; |
| 458 template <> const char *InstX8632Pxor::Opcode = "pxor"; | 475 template <> const char *InstX8632Pxor::Opcode = "pxor"; |
| 459 template <> const char *InstX8632Imul::Opcode = "imul"; | 476 template <> const char *InstX8632Imul::Opcode = "imul"; |
| 460 template <> const char *InstX8632Mulps::Opcode = "mulps"; | 477 template <> const char *InstX8632Mulps::Opcode = "mulps"; |
| 461 template <> const char *InstX8632Mulss::Opcode = "mulss"; | 478 template <> const char *InstX8632Mulss::Opcode = "mulss"; |
| 479 template <> const char *InstX8632Pmullw::Opcode = "pmullw"; |
| 480 template <> const char *InstX8632Pmuludq::Opcode = "pmuludq"; |
| 462 template <> const char *InstX8632Div::Opcode = "div"; | 481 template <> const char *InstX8632Div::Opcode = "div"; |
| 463 template <> const char *InstX8632Divps::Opcode = "divps"; | 482 template <> const char *InstX8632Divps::Opcode = "divps"; |
| 464 template <> const char *InstX8632Idiv::Opcode = "idiv"; | 483 template <> const char *InstX8632Idiv::Opcode = "idiv"; |
| 465 template <> const char *InstX8632Divss::Opcode = "divss"; | 484 template <> const char *InstX8632Divss::Opcode = "divss"; |
| 466 template <> const char *InstX8632Shl::Opcode = "shl"; | 485 template <> const char *InstX8632Shl::Opcode = "shl"; |
| 467 template <> const char *InstX8632Psll::Opcode = "psll"; | 486 template <> const char *InstX8632Psll::Opcode = "psll"; |
| 468 template <> const char *InstX8632Shr::Opcode = "shr"; | 487 template <> const char *InstX8632Shr::Opcode = "shr"; |
| 469 template <> const char *InstX8632Sar::Opcode = "sar"; | 488 template <> const char *InstX8632Sar::Opcode = "sar"; |
| 470 template <> const char *InstX8632Psra::Opcode = "psra"; | 489 template <> const char *InstX8632Psra::Opcode = "psra"; |
| 471 template <> const char *InstX8632Pcmpeq::Opcode = "pcmpeq"; | 490 template <> const char *InstX8632Pcmpeq::Opcode = "pcmpeq"; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 483 Str << "\n"; | 502 Str << "\n"; |
| 484 } | 503 } |
| 485 | 504 |
| 486 template <> void InstX8632Addss::emit(const Cfg *Func) const { | 505 template <> void InstX8632Addss::emit(const Cfg *Func) const { |
| 487 char buf[30]; | 506 char buf[30]; |
| 488 snprintf(buf, llvm::array_lengthof(buf), "add%s", | 507 snprintf(buf, llvm::array_lengthof(buf), "add%s", |
| 489 TypeX8632Attributes[getDest()->getType()].SdSsString); | 508 TypeX8632Attributes[getDest()->getType()].SdSsString); |
| 490 emitTwoAddress(buf, this, Func); | 509 emitTwoAddress(buf, this, Func); |
| 491 } | 510 } |
| 492 | 511 |
| 512 template <> void InstX8632Padd::emit(const Cfg *Func) const { |
| 513 char buf[30]; |
| 514 snprintf(buf, llvm::array_lengthof(buf), "padd%s", |
| 515 TypeX8632Attributes[getDest()->getType()].PackString); |
| 516 emitTwoAddress(buf, this, Func); |
| 517 } |
| 518 |
| 493 template <> void InstX8632Subss::emit(const Cfg *Func) const { | 519 template <> void InstX8632Subss::emit(const Cfg *Func) const { |
| 494 char buf[30]; | 520 char buf[30]; |
| 495 snprintf(buf, llvm::array_lengthof(buf), "sub%s", | 521 snprintf(buf, llvm::array_lengthof(buf), "sub%s", |
| 496 TypeX8632Attributes[getDest()->getType()].SdSsString); | 522 TypeX8632Attributes[getDest()->getType()].SdSsString); |
| 497 emitTwoAddress(buf, this, Func); | 523 emitTwoAddress(buf, this, Func); |
| 498 } | 524 } |
| 499 | 525 |
| 526 template <> void InstX8632Psub::emit(const Cfg *Func) const { |
| 527 char buf[30]; |
| 528 snprintf(buf, llvm::array_lengthof(buf), "psub%s", |
| 529 TypeX8632Attributes[getDest()->getType()].PackString); |
| 530 emitTwoAddress(buf, this, Func); |
| 531 } |
| 532 |
| 500 template <> void InstX8632Mulss::emit(const Cfg *Func) const { | 533 template <> void InstX8632Mulss::emit(const Cfg *Func) const { |
| 501 char buf[30]; | 534 char buf[30]; |
| 502 snprintf(buf, llvm::array_lengthof(buf), "mul%s", | 535 snprintf(buf, llvm::array_lengthof(buf), "mul%s", |
| 503 TypeX8632Attributes[getDest()->getType()].SdSsString); | 536 TypeX8632Attributes[getDest()->getType()].SdSsString); |
| 504 emitTwoAddress(buf, this, Func); | 537 emitTwoAddress(buf, this, Func); |
| 505 } | 538 } |
| 506 | 539 |
| 540 template <> void InstX8632Pmullw::emit(const Cfg *Func) const { |
| 541 assert(getSrc(0)->getType() == IceType_v8i16 && |
| 542 getSrc(1)->getType() == IceType_v8i16); |
| 543 emitTwoAddress(Opcode, this, Func); |
| 544 } |
| 545 |
| 546 template <> void InstX8632Pmuludq::emit(const Cfg *Func) const { |
| 547 assert(getSrc(0)->getType() == IceType_v4i32 && |
| 548 getSrc(1)->getType() == IceType_v4i32); |
| 549 emitTwoAddress(Opcode, this, Func); |
| 550 } |
| 551 |
| 507 template <> void InstX8632Divss::emit(const Cfg *Func) const { | 552 template <> void InstX8632Divss::emit(const Cfg *Func) const { |
| 508 char buf[30]; | 553 char buf[30]; |
| 509 snprintf(buf, llvm::array_lengthof(buf), "div%s", | 554 snprintf(buf, llvm::array_lengthof(buf), "div%s", |
| 510 TypeX8632Attributes[getDest()->getType()].SdSsString); | 555 TypeX8632Attributes[getDest()->getType()].SdSsString); |
| 511 emitTwoAddress(buf, this, Func); | 556 emitTwoAddress(buf, this, Func); |
| 512 } | 557 } |
| 513 | 558 |
| 514 template <> void InstX8632Imul::emit(const Cfg *Func) const { | 559 template <> void InstX8632Imul::emit(const Cfg *Func) const { |
| 515 Ostream &Str = Func->getContext()->getStrEmit(); | 560 Ostream &Str = Func->getContext()->getStrEmit(); |
| 516 assert(getSrcSize() == 2); | 561 assert(getSrcSize() == 2); |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 | 1131 |
| 1087 template <> void InstX8632Psra::emit(const Cfg *Func) const { | 1132 template <> void InstX8632Psra::emit(const Cfg *Func) const { |
| 1088 assert(getDest()->getType() == IceType_v8i16 || | 1133 assert(getDest()->getType() == IceType_v8i16 || |
| 1089 getDest()->getType() == IceType_v4i32); | 1134 getDest()->getType() == IceType_v4i32); |
| 1090 char buf[30]; | 1135 char buf[30]; |
| 1091 snprintf(buf, llvm::array_lengthof(buf), "psra%s", | 1136 snprintf(buf, llvm::array_lengthof(buf), "psra%s", |
| 1092 TypeX8632Attributes[getDest()->getType()].PackString); | 1137 TypeX8632Attributes[getDest()->getType()].PackString); |
| 1093 emitTwoAddress(buf, this, Func); | 1138 emitTwoAddress(buf, this, Func); |
| 1094 } | 1139 } |
| 1095 | 1140 |
| 1096 template <> void InstX8632Psub::emit(const Cfg *Func) const { | 1141 void InstX8632Pshufd::emit(const Cfg *Func) const { |
| 1097 char buf[30]; | 1142 Ostream &Str = Func->getContext()->getStrEmit(); |
| 1098 snprintf(buf, llvm::array_lengthof(buf), "psub%s", | 1143 assert(getSrcSize() == 2); |
| 1099 TypeX8632Attributes[getDest()->getType()].PackString); | 1144 Str << "\tpshufd\t"; |
| 1100 emitTwoAddress(buf, this, Func); | 1145 getDest()->emit(Func); |
| 1146 Str << ", "; |
| 1147 getSrc(0)->emit(Func); |
| 1148 Str << ", "; |
| 1149 getSrc(1)->emit(Func); |
| 1150 Str << "\n"; |
| 1151 } |
| 1152 |
| 1153 void InstX8632Pshufd::dump(const Cfg *Func) const { |
| 1154 Ostream &Str = Func->getContext()->getStrDump(); |
| 1155 dumpDest(Func); |
| 1156 Str << " = pshufd." << getDest()->getType() << " "; |
| 1157 dumpSources(Func); |
| 1101 } | 1158 } |
| 1102 | 1159 |
| 1103 void InstX8632Ret::emit(const Cfg *Func) const { | 1160 void InstX8632Ret::emit(const Cfg *Func) const { |
| 1104 Ostream &Str = Func->getContext()->getStrEmit(); | 1161 Ostream &Str = Func->getContext()->getStrEmit(); |
| 1105 Str << "\tret\n"; | 1162 Str << "\tret\n"; |
| 1106 } | 1163 } |
| 1107 | 1164 |
| 1108 void InstX8632Ret::dump(const Cfg *Func) const { | 1165 void InstX8632Ret::dump(const Cfg *Func) const { |
| 1109 Ostream &Str = Func->getContext()->getStrDump(); | 1166 Ostream &Str = Func->getContext()->getStrDump(); |
| 1110 Type Ty = (getSrcSize() == 0 ? IceType_void : getSrc(0)->getType()); | 1167 Type Ty = (getSrcSize() == 0 ? IceType_void : getSrc(0)->getType()); |
| 1111 Str << "ret." << Ty << " "; | 1168 Str << "ret." << Ty << " "; |
| 1112 dumpSources(Func); | 1169 dumpSources(Func); |
| 1113 } | 1170 } |
| 1114 | 1171 |
| 1172 void InstX8632Shufps::emit(const Cfg *Func) const { |
| 1173 Ostream &Str = Func->getContext()->getStrEmit(); |
| 1174 assert(getSrcSize() == 3); |
| 1175 Str << "\tshufps\t"; |
| 1176 getDest()->emit(Func); |
| 1177 Str << ", "; |
| 1178 getSrc(1)->emit(Func); |
| 1179 Str << ", "; |
| 1180 getSrc(2)->emit(Func); |
| 1181 Str << "\n"; |
| 1182 } |
| 1183 |
| 1184 void InstX8632Shufps::dump(const Cfg *Func) const { |
| 1185 Ostream &Str = Func->getContext()->getStrDump(); |
| 1186 dumpDest(Func); |
| 1187 Str << " = shufps." << getDest()->getType() << " "; |
| 1188 dumpSources(Func); |
| 1189 } |
| 1190 |
| 1115 void InstX8632Xadd::emit(const Cfg *Func) const { | 1191 void InstX8632Xadd::emit(const Cfg *Func) const { |
| 1116 Ostream &Str = Func->getContext()->getStrEmit(); | 1192 Ostream &Str = Func->getContext()->getStrEmit(); |
| 1117 if (Locked) { | 1193 if (Locked) { |
| 1118 Str << "\tlock"; | 1194 Str << "\tlock"; |
| 1119 } | 1195 } |
| 1120 Str << "\txadd\t"; | 1196 Str << "\txadd\t"; |
| 1121 getSrc(0)->emit(Func); | 1197 getSrc(0)->emit(Func); |
| 1122 Str << ", "; | 1198 Str << ", "; |
| 1123 getSrc(1)->emit(Func); | 1199 getSrc(1)->emit(Func); |
| 1124 Str << "\n"; | 1200 Str << "\n"; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 default: | 1352 default: |
| 1277 Str << "???"; | 1353 Str << "???"; |
| 1278 break; | 1354 break; |
| 1279 } | 1355 } |
| 1280 Str << "("; | 1356 Str << "("; |
| 1281 Var->dump(Func); | 1357 Var->dump(Func); |
| 1282 Str << ")"; | 1358 Str << ")"; |
| 1283 } | 1359 } |
| 1284 | 1360 |
| 1285 } // end of namespace Ice | 1361 } // end of namespace Ice |
| OLD | NEW |