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

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: format 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') | tests_lit/llvm2ice_tests/test_i1.ll » ('J')
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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 470 }
471 InstX8632InplaceopGPR(const InstX8632InplaceopGPR &) = delete; 471 InstX8632InplaceopGPR(const InstX8632InplaceopGPR &) = delete;
472 InstX8632InplaceopGPR &operator=(const InstX8632InplaceopGPR &) = delete; 472 InstX8632InplaceopGPR &operator=(const InstX8632InplaceopGPR &) = delete;
473 ~InstX8632InplaceopGPR() override {} 473 ~InstX8632InplaceopGPR() override {}
474 static const char *Opcode; 474 static const char *Opcode;
475 static const x86::AssemblerX86::GPREmitterOneOp Emitter; 475 static const x86::AssemblerX86::GPREmitterOneOp Emitter;
476 }; 476 };
477 477
478 // Emit a two-operand (GPR) instruction, where the dest operand is a 478 // Emit a two-operand (GPR) instruction, where the dest operand is a
479 // Variable that's guaranteed to be a register. 479 // Variable that's guaranteed to be a register.
480 template <bool VarCanBeByte = true, bool SrcCanBeByte = true>
480 void emitIASRegOpTyGPR(const Cfg *Func, Type Ty, const Variable *Dst, 481 void emitIASRegOpTyGPR(const Cfg *Func, Type Ty, const Variable *Dst,
481 const Operand *Src, 482 const Operand *Src,
482 const x86::AssemblerX86::GPREmitterRegOp &Emitter); 483 const x86::AssemblerX86::GPREmitterRegOp &Emitter);
483 484
484 // Instructions of the form x := op(y) 485 // Instructions of the form x := op(y).
485 template <InstX8632::InstKindX8632 K> 486 template <InstX8632::InstKindX8632 K>
486 class InstX8632UnaryopGPR : public InstX8632 { 487 class InstX8632UnaryopGPR : public InstX8632 {
487 public: 488 public:
488 static InstX8632UnaryopGPR *create(Cfg *Func, Variable *Dest, Operand *Src) { 489 static InstX8632UnaryopGPR *create(Cfg *Func, Variable *Dest, Operand *Src) {
489 return new (Func->allocate<InstX8632UnaryopGPR>()) 490 return new (Func->allocate<InstX8632UnaryopGPR>())
490 InstX8632UnaryopGPR(Func, Dest, Src); 491 InstX8632UnaryopGPR(Func, Dest, Src);
491 } 492 }
492 void emit(const Cfg *Func) const override { 493 void emit(const Cfg *Func) const override {
493 Ostream &Str = Func->getContext()->getStrEmit(); 494 Ostream &Str = Func->getContext()->getStrEmit();
494 assert(getSrcSize() == 1); 495 assert(getSrcSize() == 1);
495 Str << "\t" << Opcode << "\t"; 496 Str << "\t" << Opcode << "\t";
496 getDest()->emit(Func); 497 getDest()->emit(Func);
497 Str << ", "; 498 Str << ", ";
498 getSrc(0)->emit(Func); 499 getSrc(0)->emit(Func);
499 Str << "\n"; 500 Str << "\n";
500 } 501 }
501 void emitIAS(const Cfg *Func) const override { 502 void emitIAS(const Cfg *Func) const override {
502 assert(getSrcSize() == 1); 503 assert(getSrcSize() == 1);
503 const Variable *Var = getDest(); 504 const Variable *Var = getDest();
504 Type Ty = Var->getType(); 505 Type Ty = Var->getType();
505 const Operand *Src = getSrc(0); 506 const Operand *Src = getSrc(0);
506 emitIASRegOpTyGPR(Func, Ty, Var, Src, Emitter); 507 emitIASRegOpTyGPR(Func, Ty, Var, Src, Emitter);
507 } 508 }
508 void dump(const Cfg *Func) const override { 509 void dump(const Cfg *Func) const override {
509 Ostream &Str = Func->getContext()->getStrDump(); 510 Ostream &Str = Func->getContext()->getStrDump();
510 dumpDest(Func); 511 dumpDest(Func);
511 Str << " = " << Opcode << "." << getDest()->getType() << " "; 512 Str << " = " << Opcode << "." << getSrc(0)->getType() << " ";
512 dumpSources(Func); 513 dumpSources(Func);
513 } 514 }
514 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } 515 static bool classof(const Inst *Inst) { return isClassof(Inst, K); }
515 516
516 private: 517 private:
517 InstX8632UnaryopGPR(Cfg *Func, Variable *Dest, Operand *Src) 518 InstX8632UnaryopGPR(Cfg *Func, Variable *Dest, Operand *Src)
518 : InstX8632(Func, K, 1, Dest) { 519 : InstX8632(Func, K, 1, Dest) {
519 addSource(Src); 520 addSource(Src);
520 } 521 }
521 InstX8632UnaryopGPR(const InstX8632UnaryopGPR &) = delete; 522 InstX8632UnaryopGPR(const InstX8632UnaryopGPR &) = delete;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 static const char *Opcode; 863 static const char *Opcode;
863 }; 864 };
864 865
865 typedef InstX8632InplaceopGPR<InstX8632::Bswap> InstX8632Bswap; 866 typedef InstX8632InplaceopGPR<InstX8632::Bswap> InstX8632Bswap;
866 typedef InstX8632InplaceopGPR<InstX8632::Neg> InstX8632Neg; 867 typedef InstX8632InplaceopGPR<InstX8632::Neg> InstX8632Neg;
867 typedef InstX8632UnaryopGPR<InstX8632::Bsf> InstX8632Bsf; 868 typedef InstX8632UnaryopGPR<InstX8632::Bsf> InstX8632Bsf;
868 typedef InstX8632UnaryopGPR<InstX8632::Bsr> InstX8632Bsr; 869 typedef InstX8632UnaryopGPR<InstX8632::Bsr> InstX8632Bsr;
869 typedef InstX8632UnaryopGPR<InstX8632::Lea> InstX8632Lea; 870 typedef InstX8632UnaryopGPR<InstX8632::Lea> InstX8632Lea;
870 // Cbwdq instruction - wrapper for cbw, cwd, and cdq 871 // Cbwdq instruction - wrapper for cbw, cwd, and cdq
871 typedef InstX8632UnaryopGPR<InstX8632::Cbwdq> InstX8632Cbwdq; 872 typedef InstX8632UnaryopGPR<InstX8632::Cbwdq> InstX8632Cbwdq;
873 typedef InstX8632UnaryopGPR<InstX8632::Movsx> InstX8632Movsx;
874 typedef InstX8632UnaryopGPR<InstX8632::Movzx> InstX8632Movzx;
872 typedef InstX8632UnaryopXmm<InstX8632::Movd> InstX8632Movd; 875 typedef InstX8632UnaryopXmm<InstX8632::Movd> InstX8632Movd;
873 typedef InstX8632UnaryopXmm<InstX8632::Sqrtss> InstX8632Sqrtss; 876 typedef InstX8632UnaryopXmm<InstX8632::Sqrtss> InstX8632Sqrtss;
874 // Move/assignment instruction - wrapper for mov/movss/movsd. 877 // Move/assignment instruction - wrapper for mov/movss/movsd.
875 typedef InstX8632Movlike<InstX8632::Mov> InstX8632Mov; 878 typedef InstX8632Movlike<InstX8632::Mov> InstX8632Mov;
876 // Move packed - copy 128 bit values between XMM registers, or mem128 879 // Move packed - copy 128 bit values between XMM registers, or mem128
877 // and XMM registers. 880 // and XMM registers.
878 typedef InstX8632Movlike<InstX8632::Movp> InstX8632Movp; 881 typedef InstX8632Movlike<InstX8632::Movp> InstX8632Movp;
879 // Movq - copy between XMM registers, or mem64 and XMM registers. 882 // Movq - copy between XMM registers, or mem64 and XMM registers.
880 typedef InstX8632Movlike<InstX8632::Movq> InstX8632Movq; 883 typedef InstX8632Movlike<InstX8632::Movq> InstX8632Movq;
881 typedef InstX8632BinopGPR<InstX8632::Add> InstX8632Add; 884 typedef InstX8632BinopGPR<InstX8632::Add> InstX8632Add;
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 void dump(const Cfg *Func) const override; 1287 void dump(const Cfg *Func) const override;
1285 static bool classof(const Inst *Inst) { return isClassof(Inst, StoreQ); } 1288 static bool classof(const Inst *Inst) { return isClassof(Inst, StoreQ); }
1286 1289
1287 private: 1290 private:
1288 InstX8632StoreQ(Cfg *Func, Variable *Value, OperandX8632Mem *Mem); 1291 InstX8632StoreQ(Cfg *Func, Variable *Value, OperandX8632Mem *Mem);
1289 InstX8632StoreQ(const InstX8632StoreQ &) = delete; 1292 InstX8632StoreQ(const InstX8632StoreQ &) = delete;
1290 InstX8632StoreQ &operator=(const InstX8632StoreQ &) = delete; 1293 InstX8632StoreQ &operator=(const InstX8632StoreQ &) = delete;
1291 ~InstX8632StoreQ() override {} 1294 ~InstX8632StoreQ() override {}
1292 }; 1295 };
1293 1296
1294 // Movsx - copy from a narrower integer type to a wider integer
1295 // type, with sign extension.
1296 class InstX8632Movsx : public InstX8632 {
1297 public:
1298 static InstX8632Movsx *create(Cfg *Func, Variable *Dest, Operand *Source) {
1299 return new (Func->allocate<InstX8632Movsx>())
1300 InstX8632Movsx(Func, Dest, Source);
1301 }
1302 void emit(const Cfg *Func) const override;
1303 void dump(const Cfg *Func) const override;
1304 static bool classof(const Inst *Inst) { return isClassof(Inst, Movsx); }
1305
1306 private:
1307 InstX8632Movsx(Cfg *Func, Variable *Dest, Operand *Source);
1308 InstX8632Movsx(const InstX8632Movsx &) = delete;
1309 InstX8632Movsx &operator=(const InstX8632Movsx &) = delete;
1310 ~InstX8632Movsx() override {}
1311 };
1312
1313 // Movzx - copy from a narrower integer type to a wider integer
1314 // type, with zero extension.
1315 class InstX8632Movzx : public InstX8632 {
1316 public:
1317 static InstX8632Movzx *create(Cfg *Func, Variable *Dest, Operand *Source) {
1318 return new (Func->allocate<InstX8632Movzx>())
1319 InstX8632Movzx(Func, Dest, Source);
1320 }
1321 void emit(const Cfg *Func) const override;
1322 void dump(const Cfg *Func) const override;
1323 static bool classof(const Inst *Inst) { return isClassof(Inst, Movzx); }
1324
1325 private:
1326 InstX8632Movzx(Cfg *Func, Variable *Dest, Operand *Source);
1327 InstX8632Movzx(const InstX8632Movzx &) = delete;
1328 InstX8632Movzx &operator=(const InstX8632Movzx &) = delete;
1329 ~InstX8632Movzx() override {}
1330 };
1331
1332 // Nop instructions of varying length 1297 // Nop instructions of varying length
1333 class InstX8632Nop : public InstX8632 { 1298 class InstX8632Nop : public InstX8632 {
1334 public: 1299 public:
1335 // TODO: Replace with enum. 1300 // TODO: Replace with enum.
1336 typedef unsigned NopVariant; 1301 typedef unsigned NopVariant;
1337 1302
1338 static InstX8632Nop *create(Cfg *Func, NopVariant Variant) { 1303 static InstX8632Nop *create(Cfg *Func, NopVariant Variant) {
1339 return new (Func->allocate<InstX8632Nop>()) InstX8632Nop(Func, Variant); 1304 return new (Func->allocate<InstX8632Nop>()) InstX8632Nop(Func, Variant);
1340 } 1305 }
1341 void emit(const Cfg *Func) const override; 1306 void emit(const Cfg *Func) const override;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 template <> void InstX8632Cbwdq::emitIAS(const Cfg *Func) const; 1489 template <> void InstX8632Cbwdq::emitIAS(const Cfg *Func) const;
1525 template <> void InstX8632Div::emitIAS(const Cfg *Func) const; 1490 template <> void InstX8632Div::emitIAS(const Cfg *Func) const;
1526 template <> void InstX8632Idiv::emitIAS(const Cfg *Func) const; 1491 template <> void InstX8632Idiv::emitIAS(const Cfg *Func) const;
1527 template <> void InstX8632Imul::emitIAS(const Cfg *Func) const; 1492 template <> void InstX8632Imul::emitIAS(const Cfg *Func) const;
1528 template <> void InstX8632Insertps::emitIAS(const Cfg *Func) const; 1493 template <> void InstX8632Insertps::emitIAS(const Cfg *Func) const;
1529 template <> void InstX8632Movd::emitIAS(const Cfg *Func) const; 1494 template <> void InstX8632Movd::emitIAS(const Cfg *Func) const;
1530 template <> void InstX8632MovssRegs::emitIAS(const Cfg *Func) const; 1495 template <> void InstX8632MovssRegs::emitIAS(const Cfg *Func) const;
1531 template <> void InstX8632Pblendvb::emitIAS(const Cfg *Func) const; 1496 template <> void InstX8632Pblendvb::emitIAS(const Cfg *Func) const;
1532 template <> void InstX8632Pextr::emitIAS(const Cfg *Func) const; 1497 template <> void InstX8632Pextr::emitIAS(const Cfg *Func) const;
1533 template <> void InstX8632Pinsr::emitIAS(const Cfg *Func) const; 1498 template <> void InstX8632Pinsr::emitIAS(const Cfg *Func) const;
1499 template <> void InstX8632Movsx::emitIAS(const Cfg *Func) const;
1500 template <> void InstX8632Movzx::emitIAS(const Cfg *Func) const;
1534 template <> void InstX8632Pmull::emitIAS(const Cfg *Func) const; 1501 template <> void InstX8632Pmull::emitIAS(const Cfg *Func) const;
1535 template <> void InstX8632Pshufd::emitIAS(const Cfg *Func) const; 1502 template <> void InstX8632Pshufd::emitIAS(const Cfg *Func) const;
1536 template <> void InstX8632Shufps::emitIAS(const Cfg *Func) const; 1503 template <> void InstX8632Shufps::emitIAS(const Cfg *Func) const;
1537 1504
1538 } // end of namespace Ice 1505 } // end of namespace Ice
1539 1506
1540 #endif // SUBZERO_SRC_ICEINSTX8632_H 1507 #endif // SUBZERO_SRC_ICEINSTX8632_H
OLDNEW
« no previous file with comments | « no previous file | src/IceInstX8632.cpp » ('j') | tests_lit/llvm2ice_tests/test_i1.ll » ('J')

Powered by Google App Engine
This is Rietveld 408576698