Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1164)

Side by Side Diff: src/IceInstX8632.h

Issue 647223004: emitIAS for movsx and movzx. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/IceInstX8632.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceInstX8632.h - Low-level x86 instructions --*- C++ -*-===// 1 //===- subzero/src/IceInstX8632.h - Low-level x86 instructions --*- C++ -*-===//
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 declares the InstX8632 and OperandX8632 classes and 10 // This file declares the InstX8632 and OperandX8632 classes and
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 : InstX8632(Func, K, 1, llvm::dyn_cast<Variable>(SrcDest)) { 478 : InstX8632(Func, K, 1, llvm::dyn_cast<Variable>(SrcDest)) {
479 addSource(SrcDest); 479 addSource(SrcDest);
480 } 480 }
481 ~InstX8632InplaceopGPR() override {} 481 ~InstX8632InplaceopGPR() override {}
482 static const char *Opcode; 482 static const char *Opcode;
483 static const x86::AssemblerX86::GPREmitterOneOp Emitter; 483 static const x86::AssemblerX86::GPREmitterOneOp Emitter;
484 }; 484 };
485 485
486 // Emit a two-operand (GPR) instruction, where the dest operand is a 486 // Emit a two-operand (GPR) instruction, where the dest operand is a
487 // Variable that's guaranteed to be a register. 487 // Variable that's guaranteed to be a register.
488 template <bool VarCanBeByte = true, bool SrcCanBeByte = true>
488 void emitIASRegOpTyGPR(const Cfg *Func, Type Ty, const Variable *Dst, 489 void emitIASRegOpTyGPR(const Cfg *Func, Type Ty, const Variable *Dst,
489 const Operand *Src, 490 const Operand *Src,
490 const x86::AssemblerX86::GPREmitterRegOp &Emitter); 491 const x86::AssemblerX86::GPREmitterRegOp &Emitter);
491 492
492 // Instructions of the form x := op(y) 493 // Instructions of the form x := op(y).
493 template <InstX8632::InstKindX8632 K> 494 template <InstX8632::InstKindX8632 K>
494 class InstX8632UnaryopGPR : public InstX8632 { 495 class InstX8632UnaryopGPR : public InstX8632 {
495 InstX8632UnaryopGPR(const InstX8632UnaryopGPR &) = delete; 496 InstX8632UnaryopGPR(const InstX8632UnaryopGPR &) = delete;
496 InstX8632UnaryopGPR &operator=(const InstX8632UnaryopGPR &) = delete; 497 InstX8632UnaryopGPR &operator=(const InstX8632UnaryopGPR &) = delete;
497 498
498 public: 499 public:
499 static InstX8632UnaryopGPR *create(Cfg *Func, Variable *Dest, Operand *Src) { 500 static InstX8632UnaryopGPR *create(Cfg *Func, Variable *Dest, Operand *Src) {
500 return new (Func->allocate<InstX8632UnaryopGPR>()) 501 return new (Func->allocate<InstX8632UnaryopGPR>())
501 InstX8632UnaryopGPR(Func, Dest, Src); 502 InstX8632UnaryopGPR(Func, Dest, Src);
502 } 503 }
503 void emit(const Cfg *Func) const override { 504 void emit(const Cfg *Func) const override {
504 Ostream &Str = Func->getContext()->getStrEmit(); 505 Ostream &Str = Func->getContext()->getStrEmit();
505 assert(getSrcSize() == 1); 506 assert(getSrcSize() == 1);
506 Str << "\t" << Opcode << "\t"; 507 Str << "\t" << Opcode << "\t";
507 getDest()->emit(Func); 508 getDest()->emit(Func);
508 Str << ", "; 509 Str << ", ";
509 getSrc(0)->emit(Func); 510 getSrc(0)->emit(Func);
510 Str << "\n"; 511 Str << "\n";
511 } 512 }
512 void emitIAS(const Cfg *Func) const override { 513 void emitIAS(const Cfg *Func) const override {
513 assert(getSrcSize() == 1); 514 assert(getSrcSize() == 1);
514 const Variable *Var = getDest(); 515 const Variable *Var = getDest();
515 Type Ty = Var->getType(); 516 Type Ty = Var->getType();
516 const Operand *Src = getSrc(0); 517 const Operand *Src = getSrc(0);
517 emitIASRegOpTyGPR(Func, Ty, Var, Src, Emitter); 518 emitIASRegOpTyGPR(Func, Ty, Var, Src, Emitter);
518 } 519 }
519 void dump(const Cfg *Func) const override { 520 void dump(const Cfg *Func) const override {
520 Ostream &Str = Func->getContext()->getStrDump(); 521 Ostream &Str = Func->getContext()->getStrDump();
521 dumpDest(Func); 522 dumpDest(Func);
522 Str << " = " << Opcode << "." << getDest()->getType() << " "; 523 Str << " = " << Opcode << "." << getSrc(0)->getType() << " ";
523 dumpSources(Func); 524 dumpSources(Func);
524 } 525 }
525 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } 526 static bool classof(const Inst *Inst) { return isClassof(Inst, K); }
526 527
527 private: 528 private:
528 InstX8632UnaryopGPR(Cfg *Func, Variable *Dest, Operand *Src) 529 InstX8632UnaryopGPR(Cfg *Func, Variable *Dest, Operand *Src)
529 : InstX8632(Func, K, 1, Dest) { 530 : InstX8632(Func, K, 1, Dest) {
530 addSource(Src); 531 addSource(Src);
531 } 532 }
532 ~InstX8632UnaryopGPR() override {} 533 ~InstX8632UnaryopGPR() override {}
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 static const char *Opcode; 880 static const char *Opcode;
880 }; 881 };
881 882
882 typedef InstX8632InplaceopGPR<InstX8632::Bswap> InstX8632Bswap; 883 typedef InstX8632InplaceopGPR<InstX8632::Bswap> InstX8632Bswap;
883 typedef InstX8632InplaceopGPR<InstX8632::Neg> InstX8632Neg; 884 typedef InstX8632InplaceopGPR<InstX8632::Neg> InstX8632Neg;
884 typedef InstX8632UnaryopGPR<InstX8632::Bsf> InstX8632Bsf; 885 typedef InstX8632UnaryopGPR<InstX8632::Bsf> InstX8632Bsf;
885 typedef InstX8632UnaryopGPR<InstX8632::Bsr> InstX8632Bsr; 886 typedef InstX8632UnaryopGPR<InstX8632::Bsr> InstX8632Bsr;
886 typedef InstX8632UnaryopGPR<InstX8632::Lea> InstX8632Lea; 887 typedef InstX8632UnaryopGPR<InstX8632::Lea> InstX8632Lea;
887 // Cbwdq instruction - wrapper for cbw, cwd, and cdq 888 // Cbwdq instruction - wrapper for cbw, cwd, and cdq
888 typedef InstX8632UnaryopGPR<InstX8632::Cbwdq> InstX8632Cbwdq; 889 typedef InstX8632UnaryopGPR<InstX8632::Cbwdq> InstX8632Cbwdq;
890 typedef InstX8632UnaryopGPR<InstX8632::Movsx> InstX8632Movsx;
891 typedef InstX8632UnaryopGPR<InstX8632::Movzx> InstX8632Movzx;
889 typedef InstX8632UnaryopXmm<InstX8632::Movd> InstX8632Movd; 892 typedef InstX8632UnaryopXmm<InstX8632::Movd> InstX8632Movd;
890 typedef InstX8632UnaryopXmm<InstX8632::Sqrtss> InstX8632Sqrtss; 893 typedef InstX8632UnaryopXmm<InstX8632::Sqrtss> InstX8632Sqrtss;
891 // Move/assignment instruction - wrapper for mov/movss/movsd. 894 // Move/assignment instruction - wrapper for mov/movss/movsd.
892 typedef InstX8632Movlike<InstX8632::Mov> InstX8632Mov; 895 typedef InstX8632Movlike<InstX8632::Mov> InstX8632Mov;
893 // Move packed - copy 128 bit values between XMM registers, or mem128 896 // Move packed - copy 128 bit values between XMM registers, or mem128
894 // and XMM registers. 897 // and XMM registers.
895 typedef InstX8632Movlike<InstX8632::Movp> InstX8632Movp; 898 typedef InstX8632Movlike<InstX8632::Movp> InstX8632Movp;
896 // Movq - copy between XMM registers, or mem64 and XMM registers. 899 // Movq - copy between XMM registers, or mem64 and XMM registers.
897 typedef InstX8632Movlike<InstX8632::Movq> InstX8632Movq; 900 typedef InstX8632Movlike<InstX8632::Movq> InstX8632Movq;
898 typedef InstX8632BinopGPR<InstX8632::Add> InstX8632Add; 901 typedef InstX8632BinopGPR<InstX8632::Add> InstX8632Add;
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 void emit(const Cfg *Func) const override; 1319 void emit(const Cfg *Func) const override;
1317 void emitIAS(const Cfg *Func) const override; 1320 void emitIAS(const Cfg *Func) const override;
1318 void dump(const Cfg *Func) const override; 1321 void dump(const Cfg *Func) const override;
1319 static bool classof(const Inst *Inst) { return isClassof(Inst, StoreQ); } 1322 static bool classof(const Inst *Inst) { return isClassof(Inst, StoreQ); }
1320 1323
1321 private: 1324 private:
1322 InstX8632StoreQ(Cfg *Func, Variable *Value, OperandX8632Mem *Mem); 1325 InstX8632StoreQ(Cfg *Func, Variable *Value, OperandX8632Mem *Mem);
1323 ~InstX8632StoreQ() override {} 1326 ~InstX8632StoreQ() override {}
1324 }; 1327 };
1325 1328
1326 // Movsx - copy from a narrower integer type to a wider integer
1327 // type, with sign extension.
1328 class InstX8632Movsx : public InstX8632 {
1329 InstX8632Movsx(const InstX8632Movsx &) = delete;
1330 InstX8632Movsx &operator=(const InstX8632Movsx &) = delete;
1331
1332 public:
1333 static InstX8632Movsx *create(Cfg *Func, Variable *Dest, Operand *Source) {
1334 return new (Func->allocate<InstX8632Movsx>())
1335 InstX8632Movsx(Func, Dest, Source);
1336 }
1337 void emit(const Cfg *Func) const override;
1338 void dump(const Cfg *Func) const override;
1339 static bool classof(const Inst *Inst) { return isClassof(Inst, Movsx); }
1340
1341 private:
1342 InstX8632Movsx(Cfg *Func, Variable *Dest, Operand *Source);
1343 ~InstX8632Movsx() override {}
1344 };
1345
1346 // Movzx - copy from a narrower integer type to a wider integer
1347 // type, with zero extension.
1348 class InstX8632Movzx : public InstX8632 {
1349 InstX8632Movzx(const InstX8632Movzx &) = delete;
1350 InstX8632Movzx &operator=(const InstX8632Movzx &) = delete;
1351
1352 public:
1353 static InstX8632Movzx *create(Cfg *Func, Variable *Dest, Operand *Source) {
1354 return new (Func->allocate<InstX8632Movzx>())
1355 InstX8632Movzx(Func, Dest, Source);
1356 }
1357 void emit(const Cfg *Func) const override;
1358 void dump(const Cfg *Func) const override;
1359 static bool classof(const Inst *Inst) { return isClassof(Inst, Movzx); }
1360
1361 private:
1362 InstX8632Movzx(Cfg *Func, Variable *Dest, Operand *Source);
1363 ~InstX8632Movzx() override {}
1364 };
1365
1366 // Nop instructions of varying length 1329 // Nop instructions of varying length
1367 class InstX8632Nop : public InstX8632 { 1330 class InstX8632Nop : public InstX8632 {
1368 InstX8632Nop(const InstX8632Nop &) = delete; 1331 InstX8632Nop(const InstX8632Nop &) = delete;
1369 InstX8632Nop &operator=(const InstX8632Nop &) = delete; 1332 InstX8632Nop &operator=(const InstX8632Nop &) = delete;
1370 1333
1371 public: 1334 public:
1372 // TODO: Replace with enum. 1335 // TODO: Replace with enum.
1373 typedef unsigned NopVariant; 1336 typedef unsigned NopVariant;
1374 1337
1375 static InstX8632Nop *create(Cfg *Func, NopVariant Variant) { 1338 static InstX8632Nop *create(Cfg *Func, NopVariant Variant) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 template <> void InstX8632Cbwdq::emitIAS(const Cfg *Func) const; 1529 template <> void InstX8632Cbwdq::emitIAS(const Cfg *Func) const;
1567 template <> void InstX8632Div::emitIAS(const Cfg *Func) const; 1530 template <> void InstX8632Div::emitIAS(const Cfg *Func) const;
1568 template <> void InstX8632Idiv::emitIAS(const Cfg *Func) const; 1531 template <> void InstX8632Idiv::emitIAS(const Cfg *Func) const;
1569 template <> void InstX8632Imul::emitIAS(const Cfg *Func) const; 1532 template <> void InstX8632Imul::emitIAS(const Cfg *Func) const;
1570 template <> void InstX8632Insertps::emitIAS(const Cfg *Func) const; 1533 template <> void InstX8632Insertps::emitIAS(const Cfg *Func) const;
1571 template <> void InstX8632Movd::emitIAS(const Cfg *Func) const; 1534 template <> void InstX8632Movd::emitIAS(const Cfg *Func) const;
1572 template <> void InstX8632MovssRegs::emitIAS(const Cfg *Func) const; 1535 template <> void InstX8632MovssRegs::emitIAS(const Cfg *Func) const;
1573 template <> void InstX8632Pblendvb::emitIAS(const Cfg *Func) const; 1536 template <> void InstX8632Pblendvb::emitIAS(const Cfg *Func) const;
1574 template <> void InstX8632Pextr::emitIAS(const Cfg *Func) const; 1537 template <> void InstX8632Pextr::emitIAS(const Cfg *Func) const;
1575 template <> void InstX8632Pinsr::emitIAS(const Cfg *Func) const; 1538 template <> void InstX8632Pinsr::emitIAS(const Cfg *Func) const;
1539 template <> void InstX8632Movsx::emitIAS(const Cfg *Func) const;
1540 template <> void InstX8632Movzx::emitIAS(const Cfg *Func) const;
1576 template <> void InstX8632Pmull::emitIAS(const Cfg *Func) const; 1541 template <> void InstX8632Pmull::emitIAS(const Cfg *Func) const;
1577 template <> void InstX8632Pshufd::emitIAS(const Cfg *Func) const; 1542 template <> void InstX8632Pshufd::emitIAS(const Cfg *Func) const;
1578 template <> void InstX8632Shufps::emitIAS(const Cfg *Func) const; 1543 template <> void InstX8632Shufps::emitIAS(const Cfg *Func) const;
1579 1544
1580 } // end of namespace Ice 1545 } // end of namespace Ice
1581 1546
1582 #endif // SUBZERO_SRC_ICEINSTX8632_H 1547 #endif // SUBZERO_SRC_ICEINSTX8632_H
OLDNEW
« no previous file with comments | « no previous file | src/IceInstX8632.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698