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

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: Rebase and make bitcast 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
« no previous file with comments | « src/IceInstX8632.h ('k') | src/IceInstX8632.def » ('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.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) name, 55 #define X(val, name) name,
55 SEG_REGX8632_TABLE 56 SEG_REGX8632_TABLE
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 template <> const char *InstX8632Bsf::Opcode = "bsf"; 442 template <> const char *InstX8632Bsf::Opcode = "bsf";
442 template <> const char *InstX8632Bsr::Opcode = "bsr"; 443 template <> const char *InstX8632Bsr::Opcode = "bsr";
443 template <> const char *InstX8632Sqrtss::Opcode = "sqrtss"; 444 template <> const char *InstX8632Sqrtss::Opcode = "sqrtss";
444 template <> const char *InstX8632Add::Opcode = "add"; 445 template <> const char *InstX8632Add::Opcode = "add";
445 template <> const char *InstX8632Addps::Opcode = "addps"; 446 template <> const char *InstX8632Addps::Opcode = "addps";
446 template <> const char *InstX8632Adc::Opcode = "adc"; 447 template <> const char *InstX8632Adc::Opcode = "adc";
447 template <> const char *InstX8632Addss::Opcode = "addss"; 448 template <> const char *InstX8632Addss::Opcode = "addss";
448 template <> const char *InstX8632Sub::Opcode = "sub"; 449 template <> const char *InstX8632Sub::Opcode = "sub";
449 template <> const char *InstX8632Subps::Opcode = "subps"; 450 template <> const char *InstX8632Subps::Opcode = "subps";
450 template <> const char *InstX8632Subss::Opcode = "subss"; 451 template <> const char *InstX8632Subss::Opcode = "subss";
452 template <> const char *InstX8632Psub::Opcode = "psub";
451 template <> const char *InstX8632Sbb::Opcode = "sbb"; 453 template <> const char *InstX8632Sbb::Opcode = "sbb";
452 template <> const char *InstX8632And::Opcode = "and"; 454 template <> const char *InstX8632And::Opcode = "and";
455 template <> const char *InstX8632Pand::Opcode = "pand";
453 template <> const char *InstX8632Or::Opcode = "or"; 456 template <> const char *InstX8632Or::Opcode = "or";
454 template <> const char *InstX8632Xor::Opcode = "xor"; 457 template <> const char *InstX8632Xor::Opcode = "xor";
455 template <> const char *InstX8632Pxor::Opcode = "pxor"; 458 template <> const char *InstX8632Pxor::Opcode = "pxor";
456 template <> const char *InstX8632Imul::Opcode = "imul"; 459 template <> const char *InstX8632Imul::Opcode = "imul";
457 template <> const char *InstX8632Mulps::Opcode = "mulps"; 460 template <> const char *InstX8632Mulps::Opcode = "mulps";
458 template <> const char *InstX8632Mulss::Opcode = "mulss"; 461 template <> const char *InstX8632Mulss::Opcode = "mulss";
459 template <> const char *InstX8632Div::Opcode = "div"; 462 template <> const char *InstX8632Div::Opcode = "div";
460 template <> const char *InstX8632Divps::Opcode = "divps"; 463 template <> const char *InstX8632Divps::Opcode = "divps";
461 template <> const char *InstX8632Idiv::Opcode = "idiv"; 464 template <> const char *InstX8632Idiv::Opcode = "idiv";
462 template <> const char *InstX8632Divss::Opcode = "divss"; 465 template <> const char *InstX8632Divss::Opcode = "divss";
463 template <> const char *InstX8632Shl::Opcode = "shl"; 466 template <> const char *InstX8632Shl::Opcode = "shl";
467 template <> const char *InstX8632Psll::Opcode = "psll";
464 template <> const char *InstX8632Shr::Opcode = "shr"; 468 template <> const char *InstX8632Shr::Opcode = "shr";
465 template <> const char *InstX8632Sar::Opcode = "sar"; 469 template <> const char *InstX8632Sar::Opcode = "sar";
470 template <> const char *InstX8632Psra::Opcode = "psra";
471 template <> const char *InstX8632Pcmpeq::Opcode = "pcmpeq";
472 template <> const char *InstX8632Pcmpgt::Opcode = "pcmpgt";
466 473
467 template <> void InstX8632Sqrtss::emit(const Cfg *Func) const { 474 template <> void InstX8632Sqrtss::emit(const Cfg *Func) const {
468 Ostream &Str = Func->getContext()->getStrEmit(); 475 Ostream &Str = Func->getContext()->getStrEmit();
469 assert(getSrcSize() == 1); 476 assert(getSrcSize() == 1);
470 Type Ty = getSrc(0)->getType(); 477 Type Ty = getSrc(0)->getType();
471 assert(Ty == IceType_f32 || Ty == IceType_f64); 478 assert(Ty == IceType_f32 || Ty == IceType_f64);
472 Str << "\tsqrt" << TypeX8632Attributes[Ty].SdSsString << "\t"; 479 Str << "\tsqrt" << TypeX8632Attributes[Ty].SdSsString << "\t";
473 getDest()->emit(Func); 480 getDest()->emit(Func);
474 Str << ", "; 481 Str << ", ";
475 getSrc(0)->emit(Func); 482 getSrc(0)->emit(Func);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 if (Locked) { 690 if (Locked) {
684 Str << "lock "; 691 Str << "lock ";
685 } 692 }
686 Str << "cmpxchg8b "; 693 Str << "cmpxchg8b ";
687 dumpSources(Func); 694 dumpSources(Func);
688 } 695 }
689 696
690 void InstX8632Cvt::emit(const Cfg *Func) const { 697 void InstX8632Cvt::emit(const Cfg *Func) const {
691 Ostream &Str = Func->getContext()->getStrEmit(); 698 Ostream &Str = Func->getContext()->getStrEmit();
692 assert(getSrcSize() == 1); 699 assert(getSrcSize() == 1);
693 Str << "\tcvts" << TypeX8632Attributes[getSrc(0)->getType()].CvtString << "2s" 700 Str << "\tcvt" << TypeX8632Attributes[getSrc(0)->getType()].CvtString << "2"
694 << TypeX8632Attributes[getDest()->getType()].CvtString << "\t"; 701 << TypeX8632Attributes[getDest()->getType()].CvtString << "\t";
695 getDest()->emit(Func); 702 getDest()->emit(Func);
696 Str << ", "; 703 Str << ", ";
697 getSrc(0)->emit(Func); 704 getSrc(0)->emit(Func);
698 Str << "\n"; 705 Str << "\n";
699 } 706 }
700 707
701 void InstX8632Cvt::dump(const Cfg *Func) const { 708 void InstX8632Cvt::dump(const Cfg *Func) const {
702 Ostream &Str = Func->getContext()->getStrDump(); 709 Ostream &Str = Func->getContext()->getStrDump();
703 dumpDest(Func); 710 dumpDest(Func);
704 Str << " = cvts" << TypeX8632Attributes[getSrc(0)->getType()].CvtString 711 Str << " = cvt" << TypeX8632Attributes[getSrc(0)->getType()].CvtString
705 << "2s" << TypeX8632Attributes[getDest()->getType()].CvtString << " "; 712 << "2" << TypeX8632Attributes[getDest()->getType()].CvtString << " ";
706 dumpSources(Func); 713 dumpSources(Func);
707 } 714 }
708 715
709 void InstX8632Icmp::emit(const Cfg *Func) const { 716 void InstX8632Icmp::emit(const Cfg *Func) const {
710 Ostream &Str = Func->getContext()->getStrEmit(); 717 Ostream &Str = Func->getContext()->getStrEmit();
711 assert(getSrcSize() == 2); 718 assert(getSrcSize() == 2);
712 Str << "\tcmp\t"; 719 Str << "\tcmp\t";
713 getSrc(0)->emit(Func); 720 getSrc(0)->emit(Func);
714 Str << ", "; 721 Str << ", ";
715 getSrc(1)->emit(Func); 722 getSrc(1)->emit(Func);
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 Str << "\tadd\tesp, " << Width << "\n"; 1000 Str << "\tadd\tesp, " << Width << "\n";
994 } 1001 }
995 1002
996 void InstX8632Fstp::dump(const Cfg *Func) const { 1003 void InstX8632Fstp::dump(const Cfg *Func) const {
997 Ostream &Str = Func->getContext()->getStrDump(); 1004 Ostream &Str = Func->getContext()->getStrDump();
998 dumpDest(Func); 1005 dumpDest(Func);
999 Str << " = fstp." << getDest()->getType() << ", st(0)"; 1006 Str << " = fstp." << getDest()->getType() << ", st(0)";
1000 Str << "\n"; 1007 Str << "\n";
1001 } 1008 }
1002 1009
1010 template <> void InstX8632Pcmpeq::emit(const Cfg *Func) const {
1011 char buf[30];
1012 snprintf(buf, llvm::array_lengthof(buf), "pcmpeq%s",
1013 TypeX8632Attributes[getDest()->getType()].PackString);
1014 emitTwoAddress(buf, this, Func);
1015 }
1016
1017 template <> void InstX8632Pcmpgt::emit(const Cfg *Func) const {
1018 char buf[30];
1019 snprintf(buf, llvm::array_lengthof(buf), "pcmpgt%s",
1020 TypeX8632Attributes[getDest()->getType()].PackString);
1021 emitTwoAddress(buf, this, Func);
1022 }
1023
1003 void InstX8632Pop::emit(const Cfg *Func) const { 1024 void InstX8632Pop::emit(const Cfg *Func) const {
1004 Ostream &Str = Func->getContext()->getStrEmit(); 1025 Ostream &Str = Func->getContext()->getStrEmit();
1005 assert(getSrcSize() == 0); 1026 assert(getSrcSize() == 0);
1006 Str << "\tpop\t"; 1027 Str << "\tpop\t";
1007 getDest()->emit(Func); 1028 getDest()->emit(Func);
1008 Str << "\n"; 1029 Str << "\n";
1009 } 1030 }
1010 1031
1011 void InstX8632Pop::dump(const Cfg *Func) const { 1032 void InstX8632Pop::dump(const Cfg *Func) const {
1012 Ostream &Str = Func->getContext()->getStrDump(); 1033 Ostream &Str = Func->getContext()->getStrDump();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 Func->getTarget()->updateStackAdjustment(4); 1068 Func->getTarget()->updateStackAdjustment(4);
1048 } 1069 }
1049 } 1070 }
1050 1071
1051 void InstX8632Push::dump(const Cfg *Func) const { 1072 void InstX8632Push::dump(const Cfg *Func) const {
1052 Ostream &Str = Func->getContext()->getStrDump(); 1073 Ostream &Str = Func->getContext()->getStrDump();
1053 Str << "push." << getSrc(0)->getType() << " "; 1074 Str << "push." << getSrc(0)->getType() << " ";
1054 dumpSources(Func); 1075 dumpSources(Func);
1055 } 1076 }
1056 1077
1078 template <> void InstX8632Psll::emit(const Cfg *Func) const {
1079 assert(getDest()->getType() == IceType_v8i16 ||
1080 getDest()->getType() == IceType_v4i32);
1081 char buf[30];
1082 snprintf(buf, llvm::array_lengthof(buf), "psll%s",
1083 TypeX8632Attributes[getDest()->getType()].PackString);
1084 emitTwoAddress(buf, this, Func);
1085 }
1086
1087 template <> void InstX8632Psra::emit(const Cfg *Func) const {
1088 assert(getDest()->getType() == IceType_v8i16 ||
1089 getDest()->getType() == IceType_v4i32);
1090 char buf[30];
1091 snprintf(buf, llvm::array_lengthof(buf), "psra%s",
1092 TypeX8632Attributes[getDest()->getType()].PackString);
1093 emitTwoAddress(buf, this, Func);
1094 }
1095
1096 template <> void InstX8632Psub::emit(const Cfg *Func) const {
1097 char buf[30];
1098 snprintf(buf, llvm::array_lengthof(buf), "psub%s",
1099 TypeX8632Attributes[getDest()->getType()].PackString);
1100 emitTwoAddress(buf, this, Func);
1101 }
1102
1057 void InstX8632Ret::emit(const Cfg *Func) const { 1103 void InstX8632Ret::emit(const Cfg *Func) const {
1058 Ostream &Str = Func->getContext()->getStrEmit(); 1104 Ostream &Str = Func->getContext()->getStrEmit();
1059 Str << "\tret\n"; 1105 Str << "\tret\n";
1060 } 1106 }
1061 1107
1062 void InstX8632Ret::dump(const Cfg *Func) const { 1108 void InstX8632Ret::dump(const Cfg *Func) const {
1063 Ostream &Str = Func->getContext()->getStrDump(); 1109 Ostream &Str = Func->getContext()->getStrDump();
1064 Type Ty = (getSrcSize() == 0 ? IceType_void : getSrc(0)->getType()); 1110 Type Ty = (getSrcSize() == 0 ? IceType_void : getSrc(0)->getType());
1065 Str << "ret." << Ty << " "; 1111 Str << "ret." << Ty << " ";
1066 dumpSources(Func); 1112 dumpSources(Func);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 default: 1276 default:
1231 Str << "???"; 1277 Str << "???";
1232 break; 1278 break;
1233 } 1279 }
1234 Str << "("; 1280 Str << "(";
1235 Var->dump(Func); 1281 Var->dump(Func);
1236 Str << ")"; 1282 Str << ")";
1237 } 1283 }
1238 1284
1239 } // end of namespace Ice 1285 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInstX8632.h ('k') | src/IceInstX8632.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698