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

Side by Side Diff: src/IceInstX8632.h

Issue 401523003: Lower insertelement and extractelement. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Rebase Created 6 years, 5 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 | « src/IceInst.cpp ('k') | 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 Cvt, 149 Cvt,
150 Div, 150 Div,
151 Divps, 151 Divps,
152 Divss, 152 Divss,
153 Fld, 153 Fld,
154 Fstp, 154 Fstp,
155 Icmp, 155 Icmp,
156 Idiv, 156 Idiv,
157 Imul, 157 Imul,
158 Label, 158 Label,
159 Lea,
159 Load, 160 Load,
160 Mfence, 161 Mfence,
161 Mov, 162 Mov,
163 Movd,
162 Movp, 164 Movp,
163 Movq, 165 Movq,
166 Movss,
164 Movsx, 167 Movsx,
165 Movzx, 168 Movzx,
166 Mul, 169 Mul,
167 Mulps, 170 Mulps,
168 Mulss, 171 Mulss,
169 Neg, 172 Neg,
170 Or, 173 Or,
171 Padd, 174 Padd,
172 Pand, 175 Pand,
173 Pcmpeq, 176 Pcmpeq,
174 Pcmpgt, 177 Pcmpgt,
178 Pextrw,
179 Pinsrw,
175 Pmullw, 180 Pmullw,
176 Pmuludq, 181 Pmuludq,
177 Pop, 182 Pop,
178 Por, 183 Por,
179 Pshufd, 184 Pshufd,
180 Psll, 185 Psll,
181 Psra, 186 Psra,
182 Psub, 187 Psub,
183 Push, 188 Push,
184 Pxor, 189 Pxor,
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 // Create a ternary-op instruction like div or idiv. 428 // Create a ternary-op instruction like div or idiv.
424 static InstX8632Ternop *create(Cfg *Func, Variable *Dest, Operand *Source1, 429 static InstX8632Ternop *create(Cfg *Func, Variable *Dest, Operand *Source1,
425 Operand *Source2) { 430 Operand *Source2) {
426 return new (Func->allocate<InstX8632Ternop>()) 431 return new (Func->allocate<InstX8632Ternop>())
427 InstX8632Ternop(Func, Dest, Source1, Source2); 432 InstX8632Ternop(Func, Dest, Source1, Source2);
428 } 433 }
429 virtual void emit(const Cfg *Func) const { 434 virtual void emit(const Cfg *Func) const {
430 Ostream &Str = Func->getContext()->getStrEmit(); 435 Ostream &Str = Func->getContext()->getStrEmit();
431 assert(getSrcSize() == 3); 436 assert(getSrcSize() == 3);
432 Str << "\t" << Opcode << "\t"; 437 Str << "\t" << Opcode << "\t";
438 getDest()->emit(Func);
439 Str << ", ";
433 getSrc(1)->emit(Func); 440 getSrc(1)->emit(Func);
441 Str << ", ";
442 getSrc(2)->emit(Func);
434 Str << "\n"; 443 Str << "\n";
435 } 444 }
436 virtual void dump(const Cfg *Func) const { 445 virtual void dump(const Cfg *Func) const {
437 Ostream &Str = Func->getContext()->getStrDump(); 446 Ostream &Str = Func->getContext()->getStrDump();
438 dumpDest(Func); 447 dumpDest(Func);
439 Str << " = " << Opcode << "." << getDest()->getType() << " "; 448 Str << " = " << Opcode << "." << getDest()->getType() << " ";
440 dumpSources(Func); 449 dumpSources(Func);
441 } 450 }
442 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } 451 static bool classof(const Inst *Inst) { return isClassof(Inst, K); }
443 452
444 private: 453 private:
445 InstX8632Ternop(Cfg *Func, Variable *Dest, Operand *Source1, Operand *Source2) 454 InstX8632Ternop(Cfg *Func, Variable *Dest, Operand *Source1, Operand *Source2)
446 : InstX8632(Func, K, 3, Dest) { 455 : InstX8632(Func, K, 3, Dest) {
447 addSource(Dest); 456 addSource(Dest);
448 addSource(Source1); 457 addSource(Source1);
449 addSource(Source2); 458 addSource(Source2);
450 } 459 }
451 InstX8632Ternop(const InstX8632Ternop &) LLVM_DELETED_FUNCTION; 460 InstX8632Ternop(const InstX8632Ternop &) LLVM_DELETED_FUNCTION;
452 InstX8632Ternop &operator=(const InstX8632Ternop &) LLVM_DELETED_FUNCTION; 461 InstX8632Ternop &operator=(const InstX8632Ternop &) LLVM_DELETED_FUNCTION;
453 virtual ~InstX8632Ternop() {} 462 virtual ~InstX8632Ternop() {}
454 static const char *Opcode; 463 static const char *Opcode;
455 }; 464 };
456 465
466 // Instructions of the form x := y op z
467 template <InstX8632::InstKindX8632 K>
468 class InstX8632ThreeAddressop : public InstX8632 {
469 public:
470 static InstX8632ThreeAddressop *create(Cfg *Func, Variable *Dest,
471 Operand *Source0, Operand *Source1) {
472 return new (Func->allocate<InstX8632ThreeAddressop>())
473 InstX8632ThreeAddressop(Func, Dest, Source0, Source1);
474 }
475 virtual void emit(const Cfg *Func) const {
476 Ostream &Str = Func->getContext()->getStrEmit();
477 assert(getSrcSize() == 2);
478 Str << "\t" << Opcode << "\t";
479 getDest()->emit(Func);
480 Str << ", ";
481 getSrc(0)->emit(Func);
482 Str << ", ";
483 getSrc(1)->emit(Func);
484 Str << "\n";
485 }
486 virtual void dump(const Cfg *Func) const {
487 Ostream &Str = Func->getContext()->getStrDump();
488 dumpDest(Func);
489 Str << " = " << Opcode << "." << getDest()->getType() << " ";
490 dumpSources(Func);
491 }
492 static bool classof(const Inst *Inst) { return isClassof(Inst, K); }
493
494 private:
495 InstX8632ThreeAddressop(Cfg *Func, Variable *Dest, Operand *Source0,
496 Operand *Source1)
497 : InstX8632(Func, K, 2, Dest) {
498 addSource(Source0);
499 addSource(Source1);
500 }
501 InstX8632ThreeAddressop(const InstX8632ThreeAddressop &)
502 LLVM_DELETED_FUNCTION;
503 InstX8632ThreeAddressop &
504 operator=(const InstX8632ThreeAddressop &) LLVM_DELETED_FUNCTION;
505 virtual ~InstX8632ThreeAddressop() {}
506 static const char *Opcode;
507 };
508
457 typedef InstX8632Unaryop<InstX8632::Bsf> InstX8632Bsf; 509 typedef InstX8632Unaryop<InstX8632::Bsf> InstX8632Bsf;
458 typedef InstX8632Unaryop<InstX8632::Bsr> InstX8632Bsr; 510 typedef InstX8632Unaryop<InstX8632::Bsr> InstX8632Bsr;
511 typedef InstX8632Unaryop<InstX8632::Lea> InstX8632Lea;
512 typedef InstX8632Unaryop<InstX8632::Movd> InstX8632Movd;
513 typedef InstX8632Unaryop<InstX8632::Movss> InstX8632Movss;
459 typedef InstX8632Unaryop<InstX8632::Sqrtss> InstX8632Sqrtss; 514 typedef InstX8632Unaryop<InstX8632::Sqrtss> InstX8632Sqrtss;
460 typedef InstX8632Binop<InstX8632::Add> InstX8632Add; 515 typedef InstX8632Binop<InstX8632::Add> InstX8632Add;
461 typedef InstX8632Binop<InstX8632::Addps> InstX8632Addps; 516 typedef InstX8632Binop<InstX8632::Addps> InstX8632Addps;
462 typedef InstX8632Binop<InstX8632::Adc> InstX8632Adc; 517 typedef InstX8632Binop<InstX8632::Adc> InstX8632Adc;
463 typedef InstX8632Binop<InstX8632::Addss> InstX8632Addss; 518 typedef InstX8632Binop<InstX8632::Addss> InstX8632Addss;
464 typedef InstX8632Binop<InstX8632::Padd> InstX8632Padd; 519 typedef InstX8632Binop<InstX8632::Padd> InstX8632Padd;
465 typedef InstX8632Binop<InstX8632::Sub> InstX8632Sub; 520 typedef InstX8632Binop<InstX8632::Sub> InstX8632Sub;
466 typedef InstX8632Binop<InstX8632::Subps> InstX8632Subps; 521 typedef InstX8632Binop<InstX8632::Subps> InstX8632Subps;
467 typedef InstX8632Binop<InstX8632::Subss> InstX8632Subss; 522 typedef InstX8632Binop<InstX8632::Subss> InstX8632Subss;
468 typedef InstX8632Binop<InstX8632::Sbb> InstX8632Sbb; 523 typedef InstX8632Binop<InstX8632::Sbb> InstX8632Sbb;
(...skipping 13 matching lines...) Expand all
482 typedef InstX8632Binop<InstX8632::Divss> InstX8632Divss; 537 typedef InstX8632Binop<InstX8632::Divss> InstX8632Divss;
483 typedef InstX8632Binop<InstX8632::Shl, true> InstX8632Shl; 538 typedef InstX8632Binop<InstX8632::Shl, true> InstX8632Shl;
484 typedef InstX8632Binop<InstX8632::Psll> InstX8632Psll; 539 typedef InstX8632Binop<InstX8632::Psll> InstX8632Psll;
485 typedef InstX8632Binop<InstX8632::Shr, true> InstX8632Shr; 540 typedef InstX8632Binop<InstX8632::Shr, true> InstX8632Shr;
486 typedef InstX8632Binop<InstX8632::Sar, true> InstX8632Sar; 541 typedef InstX8632Binop<InstX8632::Sar, true> InstX8632Sar;
487 typedef InstX8632Binop<InstX8632::Psra> InstX8632Psra; 542 typedef InstX8632Binop<InstX8632::Psra> InstX8632Psra;
488 typedef InstX8632Binop<InstX8632::Pcmpeq> InstX8632Pcmpeq; 543 typedef InstX8632Binop<InstX8632::Pcmpeq> InstX8632Pcmpeq;
489 typedef InstX8632Binop<InstX8632::Pcmpgt> InstX8632Pcmpgt; 544 typedef InstX8632Binop<InstX8632::Pcmpgt> InstX8632Pcmpgt;
490 typedef InstX8632Ternop<InstX8632::Idiv> InstX8632Idiv; 545 typedef InstX8632Ternop<InstX8632::Idiv> InstX8632Idiv;
491 typedef InstX8632Ternop<InstX8632::Div> InstX8632Div; 546 typedef InstX8632Ternop<InstX8632::Div> InstX8632Div;
547 typedef InstX8632Ternop<InstX8632::Pinsrw> InstX8632Pinsrw;
548 typedef InstX8632Ternop<InstX8632::Shufps> InstX8632Shufps;
549 typedef InstX8632ThreeAddressop<InstX8632::Pextrw> InstX8632Pextrw;
550 typedef InstX8632ThreeAddressop<InstX8632::Pshufd> InstX8632Pshufd;
492 551
493 // Base class for a lockable x86-32 instruction (emits a locked prefix). 552 // Base class for a lockable x86-32 instruction (emits a locked prefix).
494 class InstX8632Lockable : public InstX8632 { 553 class InstX8632Lockable : public InstX8632 {
495 public: 554 public:
496 virtual void emit(const Cfg *Func) const = 0; 555 virtual void emit(const Cfg *Func) const = 0;
497 virtual void dump(const Cfg *Func) const; 556 virtual void dump(const Cfg *Func) const;
498 557
499 protected: 558 protected:
500 bool Locked; 559 bool Locked;
501 560
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 static bool classof(const Inst *Inst) { return isClassof(Inst, Push); } 1046 static bool classof(const Inst *Inst) { return isClassof(Inst, Push); }
988 1047
989 private: 1048 private:
990 InstX8632Push(Cfg *Func, Operand *Source, bool SuppressStackAdjustment); 1049 InstX8632Push(Cfg *Func, Operand *Source, bool SuppressStackAdjustment);
991 InstX8632Push(const InstX8632Push &) LLVM_DELETED_FUNCTION; 1050 InstX8632Push(const InstX8632Push &) LLVM_DELETED_FUNCTION;
992 InstX8632Push &operator=(const InstX8632Push &) LLVM_DELETED_FUNCTION; 1051 InstX8632Push &operator=(const InstX8632Push &) LLVM_DELETED_FUNCTION;
993 bool SuppressStackAdjustment; 1052 bool SuppressStackAdjustment;
994 virtual ~InstX8632Push() {} 1053 virtual ~InstX8632Push() {}
995 }; 1054 };
996 1055
997 // Pshufd - shuffle a vector of doublewords
998 class InstX8632Pshufd : public InstX8632 {
999 public:
1000 static InstX8632Pshufd *create(Cfg *Func, Variable *Dest, Operand *Source1,
1001 Operand *Source2) {
1002 return new (Func->allocate<InstX8632Pshufd>())
1003 InstX8632Pshufd(Func, Dest, Source1, Source2);
1004 }
1005 virtual void emit(const Cfg *Func) const;
1006 virtual void dump(const Cfg *Func) const;
1007 static bool classof(const Inst *Inst) { return isClassof(Inst, Pshufd); }
1008
1009 private:
1010 InstX8632Pshufd(Cfg *Func, Variable *Dest, Operand *Source1,
1011 Operand *Source2);
1012 InstX8632Pshufd(const InstX8632Pshufd &) LLVM_DELETED_FUNCTION;
1013 InstX8632Pshufd &operator=(const InstX8632Pshufd &) LLVM_DELETED_FUNCTION;
1014 virtual ~InstX8632Pshufd() {}
1015 static const char *Opcode;
1016 };
1017
1018 // Ret instruction. Currently only supports the "ret" version that 1056 // Ret instruction. Currently only supports the "ret" version that
1019 // does not pop arguments. This instruction takes a Source operand 1057 // does not pop arguments. This instruction takes a Source operand
1020 // (for non-void returning functions) for liveness analysis, though 1058 // (for non-void returning functions) for liveness analysis, though
1021 // a FakeUse before the ret would do just as well. 1059 // a FakeUse before the ret would do just as well.
1022 class InstX8632Ret : public InstX8632 { 1060 class InstX8632Ret : public InstX8632 {
1023 public: 1061 public:
1024 static InstX8632Ret *create(Cfg *Func, Variable *Source = NULL) { 1062 static InstX8632Ret *create(Cfg *Func, Variable *Source = NULL) {
1025 return new (Func->allocate<InstX8632Ret>()) InstX8632Ret(Func, Source); 1063 return new (Func->allocate<InstX8632Ret>()) InstX8632Ret(Func, Source);
1026 } 1064 }
1027 virtual void emit(const Cfg *Func) const; 1065 virtual void emit(const Cfg *Func) const;
1028 virtual void dump(const Cfg *Func) const; 1066 virtual void dump(const Cfg *Func) const;
1029 static bool classof(const Inst *Inst) { return isClassof(Inst, Ret); } 1067 static bool classof(const Inst *Inst) { return isClassof(Inst, Ret); }
1030 1068
1031 private: 1069 private:
1032 InstX8632Ret(Cfg *Func, Variable *Source); 1070 InstX8632Ret(Cfg *Func, Variable *Source);
1033 InstX8632Ret(const InstX8632Ret &) LLVM_DELETED_FUNCTION; 1071 InstX8632Ret(const InstX8632Ret &) LLVM_DELETED_FUNCTION;
1034 InstX8632Ret &operator=(const InstX8632Ret &) LLVM_DELETED_FUNCTION; 1072 InstX8632Ret &operator=(const InstX8632Ret &) LLVM_DELETED_FUNCTION;
1035 virtual ~InstX8632Ret() {} 1073 virtual ~InstX8632Ret() {}
1036 }; 1074 };
1037 1075
1038 // Shufps - select from two vectors of floating point values
1039 class InstX8632Shufps : public InstX8632 {
1040 public:
1041 static InstX8632Shufps *create(Cfg *Func, Variable *Dest, Operand *Source1,
1042 Operand *Source2) {
1043 return new (Func->allocate<InstX8632Shufps>())
1044 InstX8632Shufps(Func, Dest, Source1, Source2);
1045 }
1046 virtual void emit(const Cfg *Func) const;
1047 virtual void dump(const Cfg *Func) const;
1048 static bool classof(const Inst *Inst) { return isClassof(Inst, Shufps); }
1049
1050 private:
1051 InstX8632Shufps(Cfg *Func, Variable *Dest, Operand *Source1,
1052 Operand *Source2);
1053 InstX8632Shufps(const InstX8632Shufps &) LLVM_DELETED_FUNCTION;
1054 InstX8632Shufps &operator=(const InstX8632Shufps &) LLVM_DELETED_FUNCTION;
1055 virtual ~InstX8632Shufps() {}
1056 static const char *Opcode;
1057 };
1058
1059 // Exchanging Add instruction. Exchanges the first operand (destination 1076 // Exchanging Add instruction. Exchanges the first operand (destination
1060 // operand) with the second operand (source operand), then loads the sum 1077 // operand) with the second operand (source operand), then loads the sum
1061 // of the two values into the destination operand. The destination may be 1078 // of the two values into the destination operand. The destination may be
1062 // a register or memory, while the source must be a register. 1079 // a register or memory, while the source must be a register.
1063 // 1080 //
1064 // Both the dest and source are updated. The caller should then insert a 1081 // Both the dest and source are updated. The caller should then insert a
1065 // FakeDef to reflect the second udpate. 1082 // FakeDef to reflect the second udpate.
1066 class InstX8632Xadd : public InstX8632Lockable { 1083 class InstX8632Xadd : public InstX8632Lockable {
1067 public: 1084 public:
1068 static InstX8632Xadd *create(Cfg *Func, Operand *Dest, Variable *Source, 1085 static InstX8632Xadd *create(Cfg *Func, Operand *Dest, Variable *Source,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 private: 1117 private:
1101 InstX8632Xchg(Cfg *Func, Operand *Dest, Variable *Source); 1118 InstX8632Xchg(Cfg *Func, Operand *Dest, Variable *Source);
1102 InstX8632Xchg(const InstX8632Xchg &) LLVM_DELETED_FUNCTION; 1119 InstX8632Xchg(const InstX8632Xchg &) LLVM_DELETED_FUNCTION;
1103 InstX8632Xchg &operator=(const InstX8632Xchg &) LLVM_DELETED_FUNCTION; 1120 InstX8632Xchg &operator=(const InstX8632Xchg &) LLVM_DELETED_FUNCTION;
1104 virtual ~InstX8632Xchg() {} 1121 virtual ~InstX8632Xchg() {}
1105 }; 1122 };
1106 1123
1107 } // end of namespace Ice 1124 } // end of namespace Ice
1108 1125
1109 #endif // SUBZERO_SRC_ICEINSTX8632_H 1126 #endif // SUBZERO_SRC_ICEINSTX8632_H
OLDNEW
« no previous file with comments | « src/IceInst.cpp ('k') | src/IceInstX8632.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698