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

Side by Side Diff: src/IceInstX8632.cpp

Issue 383303003: Lower casting operations that involve vector types. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Fix formatting changes 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
OLDNEW
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 21 matching lines...) Expand all
32 , 32 ,
33 ICEINSTX8632BR_TABLE 33 ICEINSTX8632BR_TABLE
34 #undef X 34 #undef X
35 }; 35 };
36 const size_t InstX8632BrAttributesSize = 36 const size_t InstX8632BrAttributesSize =
37 llvm::array_lengthof(InstX8632BrAttributes); 37 llvm::array_lengthof(InstX8632BrAttributes);
38 38
39 const struct TypeX8632Attributes_ { 39 const struct TypeX8632Attributes_ {
40 const char *CvtString; // i (integer), s (single FP), d (double FP) 40 const char *CvtString; // i (integer), s (single FP), d (double FP)
41 const char *SdSsString; // ss, sd, or <blank> 41 const char *SdSsString; // ss, sd, or <blank>
42 const char *PackString; // b, w, d, or <blank>
42 const char *WidthString; // {byte,word,dword,qword} ptr 43 const char *WidthString; // {byte,word,dword,qword} ptr
43 } TypeX8632Attributes[] = { 44 } TypeX8632Attributes[] = {
44 #define X(tag, cvt, sdss, width) \ 45 #define X(tag, cvt, sdss, pack, width) \
45 { cvt, "" sdss, width } \ 46 { cvt, "" sdss, pack, width } \
46 , 47 ,
47 ICETYPEX8632_TABLE 48 ICETYPEX8632_TABLE
48 #undef X 49 #undef X
49 }; 50 };
50 const size_t TypeX8632AttributesSize = 51 const size_t TypeX8632AttributesSize =
51 llvm::array_lengthof(TypeX8632Attributes); 52 llvm::array_lengthof(TypeX8632Attributes);
52 53
53 const char *InstX8632SegmentRegNames[] = { 54 const char *InstX8632SegmentRegNames[] = {
54 #define X(val, name) \ 55 #define X(val, name) \
55 name, 56 name,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 return false; 265 return false;
265 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { 266 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) {
266 return true; 267 return true;
267 } 268 }
268 if (!getDest()->hasReg() && !Src->hasReg() && 269 if (!getDest()->hasReg() && !Src->hasReg() &&
269 Dest->getStackOffset() == Src->getStackOffset()) 270 Dest->getStackOffset() == Src->getStackOffset())
270 return true; 271 return true;
271 return false; 272 return false;
272 } 273 }
273 274
274 InstX8632Sqrtss::InstX8632Sqrtss(Cfg *Func, Variable *Dest, Operand *Source)
275 : InstX8632(Func, InstX8632::Sqrtss, 1, Dest) {
276 addSource(Source);
277 }
278
279 InstX8632Ret::InstX8632Ret(Cfg *Func, Variable *Source) 275 InstX8632Ret::InstX8632Ret(Cfg *Func, Variable *Source)
280 : InstX8632(Func, InstX8632::Ret, Source ? 1 : 0, NULL) { 276 : InstX8632(Func, InstX8632::Ret, Source ? 1 : 0, NULL) {
281 if (Source) 277 if (Source)
282 addSource(Source); 278 addSource(Source);
283 } 279 }
284 280
281 InstX8632Sqrtss::InstX8632Sqrtss(Cfg *Func, Variable *Dest, Operand *Source)
282 : InstX8632(Func, InstX8632::Sqrtss, 1, Dest) {
283 addSource(Source);
284 }
285
285 InstX8632Xadd::InstX8632Xadd(Cfg *Func, Operand *Dest, Variable *Source, 286 InstX8632Xadd::InstX8632Xadd(Cfg *Func, Operand *Dest, Variable *Source,
286 bool Locked) 287 bool Locked)
287 : InstX8632(Func, InstX8632::Xadd, 2, llvm::dyn_cast<Variable>(Dest)), 288 : InstX8632(Func, InstX8632::Xadd, 2, llvm::dyn_cast<Variable>(Dest)),
288 Locked(Locked) { 289 Locked(Locked) {
289 HasSideEffects = Locked; 290 HasSideEffects = Locked;
290 addSource(Dest); 291 addSource(Dest);
291 addSource(Source); 292 addSource(Source);
292 } 293 }
293 294
294 // ======================== Dump routines ======================== // 295 // ======================== Dump routines ======================== //
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 if (!EmittedSrc1) 397 if (!EmittedSrc1)
397 Inst->getSrc(1)->emit(Func); 398 Inst->getSrc(1)->emit(Func);
398 Str << "\n"; 399 Str << "\n";
399 } 400 }
400 401
401 template <> const char *InstX8632Add::Opcode = "add"; 402 template <> const char *InstX8632Add::Opcode = "add";
402 template <> const char *InstX8632Adc::Opcode = "adc"; 403 template <> const char *InstX8632Adc::Opcode = "adc";
403 template <> const char *InstX8632Addss::Opcode = "addss"; 404 template <> const char *InstX8632Addss::Opcode = "addss";
404 template <> const char *InstX8632Sub::Opcode = "sub"; 405 template <> const char *InstX8632Sub::Opcode = "sub";
405 template <> const char *InstX8632Subss::Opcode = "subss"; 406 template <> const char *InstX8632Subss::Opcode = "subss";
407 template <> const char *InstX8632Psub::Opcode = "psub";
406 template <> const char *InstX8632Sbb::Opcode = "sbb"; 408 template <> const char *InstX8632Sbb::Opcode = "sbb";
407 template <> const char *InstX8632And::Opcode = "and"; 409 template <> const char *InstX8632And::Opcode = "and";
410 template <> const char *InstX8632Pand::Opcode = "pand";
408 template <> const char *InstX8632Or::Opcode = "or"; 411 template <> const char *InstX8632Or::Opcode = "or";
409 template <> const char *InstX8632Xor::Opcode = "xor"; 412 template <> const char *InstX8632Xor::Opcode = "xor";
410 template <> const char *InstX8632Pxor::Opcode = "pxor"; 413 template <> const char *InstX8632Pxor::Opcode = "pxor";
411 template <> const char *InstX8632Imul::Opcode = "imul"; 414 template <> const char *InstX8632Imul::Opcode = "imul";
412 template <> const char *InstX8632Mulss::Opcode = "mulss"; 415 template <> const char *InstX8632Mulss::Opcode = "mulss";
413 template <> const char *InstX8632Div::Opcode = "div"; 416 template <> const char *InstX8632Div::Opcode = "div";
414 template <> const char *InstX8632Idiv::Opcode = "idiv"; 417 template <> const char *InstX8632Idiv::Opcode = "idiv";
415 template <> const char *InstX8632Divss::Opcode = "divss"; 418 template <> const char *InstX8632Divss::Opcode = "divss";
416 template <> const char *InstX8632Shl::Opcode = "shl"; 419 template <> const char *InstX8632Shl::Opcode = "shl";
420 template <> const char *InstX8632Psll::Opcode = "psll";
417 template <> const char *InstX8632Shr::Opcode = "shr"; 421 template <> const char *InstX8632Shr::Opcode = "shr";
418 template <> const char *InstX8632Sar::Opcode = "sar"; 422 template <> const char *InstX8632Sar::Opcode = "sar";
423 template <> const char *InstX8632Psra::Opcode = "psra";
424 template <> const char *InstX8632Pcmpeq::Opcode = "pcmpeq";
425 template <> const char *InstX8632Pcmpgt::Opcode = "pcmpgt";
419 426
420 template <> void InstX8632Addss::emit(const Cfg *Func) const { 427 template <> void InstX8632Addss::emit(const Cfg *Func) const {
421 char buf[30]; 428 char buf[30];
422 snprintf(buf, llvm::array_lengthof(buf), "add%s", 429 snprintf(buf, llvm::array_lengthof(buf), "add%s",
423 TypeX8632Attributes[getDest()->getType()].SdSsString); 430 TypeX8632Attributes[getDest()->getType()].SdSsString);
424 emitTwoAddress(buf, this, Func); 431 emitTwoAddress(buf, this, Func);
425 } 432 }
426 433
427 template <> void InstX8632Subss::emit(const Cfg *Func) const { 434 template <> void InstX8632Subss::emit(const Cfg *Func) const {
428 char buf[30]; 435 char buf[30];
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 void InstX8632Cdq::dump(const Cfg *Func) const { 553 void InstX8632Cdq::dump(const Cfg *Func) const {
547 Ostream &Str = Func->getContext()->getStrDump(); 554 Ostream &Str = Func->getContext()->getStrDump();
548 dumpDest(Func); 555 dumpDest(Func);
549 Str << " = cdq." << getSrc(0)->getType() << " "; 556 Str << " = cdq." << getSrc(0)->getType() << " ";
550 dumpSources(Func); 557 dumpSources(Func);
551 } 558 }
552 559
553 void InstX8632Cvt::emit(const Cfg *Func) const { 560 void InstX8632Cvt::emit(const Cfg *Func) const {
554 Ostream &Str = Func->getContext()->getStrEmit(); 561 Ostream &Str = Func->getContext()->getStrEmit();
555 assert(getSrcSize() == 1); 562 assert(getSrcSize() == 1);
556 Str << "\tcvts" << TypeX8632Attributes[getSrc(0)->getType()].CvtString << "2s" 563 Str << "\tcvt" << TypeX8632Attributes[getSrc(0)->getType()].CvtString << "2"
557 << TypeX8632Attributes[getDest()->getType()].CvtString << "\t"; 564 << TypeX8632Attributes[getDest()->getType()].CvtString << "\t";
558 getDest()->emit(Func); 565 getDest()->emit(Func);
559 Str << ", "; 566 Str << ", ";
560 getSrc(0)->emit(Func); 567 getSrc(0)->emit(Func);
561 Str << "\n"; 568 Str << "\n";
562 } 569 }
563 570
564 void InstX8632Cvt::dump(const Cfg *Func) const { 571 void InstX8632Cvt::dump(const Cfg *Func) const {
565 Ostream &Str = Func->getContext()->getStrDump(); 572 Ostream &Str = Func->getContext()->getStrDump();
566 dumpDest(Func); 573 dumpDest(Func);
567 Str << " = cvts" << TypeX8632Attributes[getSrc(0)->getType()].CvtString 574 Str << " = cvt" << TypeX8632Attributes[getSrc(0)->getType()].CvtString
568 << "2s" << TypeX8632Attributes[getDest()->getType()].CvtString << " "; 575 << "2" << TypeX8632Attributes[getDest()->getType()].CvtString << " ";
569 dumpSources(Func); 576 dumpSources(Func);
570 } 577 }
571 578
572 void InstX8632Icmp::emit(const Cfg *Func) const { 579 void InstX8632Icmp::emit(const Cfg *Func) const {
573 Ostream &Str = Func->getContext()->getStrEmit(); 580 Ostream &Str = Func->getContext()->getStrEmit();
574 assert(getSrcSize() == 2); 581 assert(getSrcSize() == 2);
575 Str << "\tcmp\t"; 582 Str << "\tcmp\t";
576 getSrc(0)->emit(Func); 583 getSrc(0)->emit(Func);
577 Str << ", "; 584 Str << ", ";
578 getSrc(1)->emit(Func); 585 getSrc(1)->emit(Func);
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 Str << "\tadd\tesp, " << Width << "\n"; 863 Str << "\tadd\tesp, " << Width << "\n";
857 } 864 }
858 865
859 void InstX8632Fstp::dump(const Cfg *Func) const { 866 void InstX8632Fstp::dump(const Cfg *Func) const {
860 Ostream &Str = Func->getContext()->getStrDump(); 867 Ostream &Str = Func->getContext()->getStrDump();
861 dumpDest(Func); 868 dumpDest(Func);
862 Str << " = fstp." << getDest()->getType() << ", st(0)"; 869 Str << " = fstp." << getDest()->getType() << ", st(0)";
863 Str << "\n"; 870 Str << "\n";
864 } 871 }
865 872
873 template <> void InstX8632Pcmpeq::emit(const Cfg *Func) const {
874 char buf[30];
875 snprintf(buf, llvm::array_lengthof(buf), "pcmpeq%s",
876 TypeX8632Attributes[getDest()->getType()].PackString);
877 emitTwoAddress(buf, this, Func);
878 }
879
880 template <> void InstX8632Pcmpgt::emit(const Cfg *Func) const {
881 char buf[30];
882 snprintf(buf, llvm::array_lengthof(buf), "pcmpgt%s",
883 TypeX8632Attributes[getDest()->getType()].PackString);
884 emitTwoAddress(buf, this, Func);
885 }
886
866 void InstX8632Pop::emit(const Cfg *Func) const { 887 void InstX8632Pop::emit(const Cfg *Func) const {
867 Ostream &Str = Func->getContext()->getStrEmit(); 888 Ostream &Str = Func->getContext()->getStrEmit();
868 assert(getSrcSize() == 0); 889 assert(getSrcSize() == 0);
869 Str << "\tpop\t"; 890 Str << "\tpop\t";
870 getDest()->emit(Func); 891 getDest()->emit(Func);
871 Str << "\n"; 892 Str << "\n";
872 } 893 }
873 894
874 void InstX8632Pop::dump(const Cfg *Func) const { 895 void InstX8632Pop::dump(const Cfg *Func) const {
875 Ostream &Str = Func->getContext()->getStrDump(); 896 Ostream &Str = Func->getContext()->getStrDump();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 Func->getTarget()->updateStackAdjustment(4); 931 Func->getTarget()->updateStackAdjustment(4);
911 } 932 }
912 } 933 }
913 934
914 void InstX8632Push::dump(const Cfg *Func) const { 935 void InstX8632Push::dump(const Cfg *Func) const {
915 Ostream &Str = Func->getContext()->getStrDump(); 936 Ostream &Str = Func->getContext()->getStrDump();
916 Str << "push." << getSrc(0)->getType() << " "; 937 Str << "push." << getSrc(0)->getType() << " ";
917 dumpSources(Func); 938 dumpSources(Func);
918 } 939 }
919 940
941 template <> void InstX8632Psll::emit(const Cfg *Func) const {
942 assert(getDest()->getType() == IceType_v8i16 ||
943 getDest()->getType() == IceType_v4i32);
944 char buf[30];
945 snprintf(buf, llvm::array_lengthof(buf), "psll%s",
946 TypeX8632Attributes[getDest()->getType()].PackString);
947 emitTwoAddress(buf, this, Func);
948 }
949
950 template <> void InstX8632Psra::emit(const Cfg *Func) const {
951 assert(getDest()->getType() == IceType_v8i16 ||
952 getDest()->getType() == IceType_v4i32);
953 char buf[30];
954 snprintf(buf, llvm::array_lengthof(buf), "psra%s",
955 TypeX8632Attributes[getDest()->getType()].PackString);
956 emitTwoAddress(buf, this, Func);
957 }
958
959 template <> void InstX8632Psub::emit(const Cfg *Func) const {
960 char buf[30];
961 snprintf(buf, llvm::array_lengthof(buf), "psub%s",
962 TypeX8632Attributes[getDest()->getType()].PackString);
963 emitTwoAddress(buf, this, Func);
964 }
965
920 void InstX8632Ret::emit(const Cfg *Func) const { 966 void InstX8632Ret::emit(const Cfg *Func) const {
921 Ostream &Str = Func->getContext()->getStrEmit(); 967 Ostream &Str = Func->getContext()->getStrEmit();
922 Str << "\tret\n"; 968 Str << "\tret\n";
923 } 969 }
924 970
925 void InstX8632Ret::dump(const Cfg *Func) const { 971 void InstX8632Ret::dump(const Cfg *Func) const {
926 Ostream &Str = Func->getContext()->getStrDump(); 972 Ostream &Str = Func->getContext()->getStrDump();
927 Type Ty = (getSrcSize() == 0 ? IceType_void : getSrc(0)->getType()); 973 Type Ty = (getSrcSize() == 0 ? IceType_void : getSrc(0)->getType());
928 Str << "ret." << Ty << " "; 974 Str << "ret." << Ty << " ";
929 dumpSources(Func); 975 dumpSources(Func);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 default: 1143 default:
1098 Str << "???"; 1144 Str << "???";
1099 break; 1145 break;
1100 } 1146 }
1101 Str << "("; 1147 Str << "(";
1102 Var->dump(Func); 1148 Var->dump(Func);
1103 Str << ")"; 1149 Str << ")";
1104 } 1150 }
1105 1151
1106 } // end of namespace Ice 1152 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInstX8632.h ('k') | src/IceInstX8632.def » ('j') | src/IceTargetLoweringX8632.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698