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

Side by Side Diff: src/IceInstX86BaseImpl.h

Issue 1497033002: Fuse icmp/fcmp with select (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes. Created 5 years 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/IceInstX86BaseImpl.h - Generic X86 instructions -*- C++ -*=// 1 //===- subzero/src/IceInstX86BaseImpl.h - Generic 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 /// \file 10 /// \file
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 return; 1098 return;
1099 char buf[30]; 1099 char buf[30];
1100 snprintf( 1100 snprintf(
1101 buf, llvm::array_lengthof(buf), "mul%s", 1101 buf, llvm::array_lengthof(buf), "mul%s",
1102 InstX86Base<Machine>::Traits::TypeAttributes[this->getDest()->getType()] 1102 InstX86Base<Machine>::Traits::TypeAttributes[this->getDest()->getType()]
1103 .SdSsString); 1103 .SdSsString);
1104 this->emitTwoAddress(buf, this, Func); 1104 this->emitTwoAddress(buf, this, Func);
1105 } 1105 }
1106 1106
1107 template <class Machine> 1107 template <class Machine>
1108 void InstX86Andnps<Machine>::emit(const Cfg *Func) const {
1109 if (!BuildDefs::dump())
1110 return;
1111
1112 char buf[30];
1113 snprintf(
1114 buf, llvm::array_lengthof(buf), "andn%s",
Jim Stichnoth 2015/12/16 01:00:37 Instead of: "andn%s", Can you use: "%s%s", Opc
sehr 2015/12/16 01:34:04 Done.
1115 InstX86Base<Machine>::Traits::TypeAttributes[this->getDest()->getType()]
1116 .PdPsString);
1117 this->emitTwoAddress(buf, this, Func);
1118 }
1119
1120 template <class Machine>
1121 void InstX86Andps<Machine>::emit(const Cfg *Func) const {
1122 if (!BuildDefs::dump())
1123 return;
1124
1125 char buf[30];
1126 snprintf(
1127 buf, llvm::array_lengthof(buf), "and%s",
1128 InstX86Base<Machine>::Traits::TypeAttributes[this->getDest()->getType()]
1129 .PdPsString);
1130 this->emitTwoAddress(buf, this, Func);
1131 }
1132
1133 template <class Machine>
1134 void InstX86Maxss<Machine>::emit(const Cfg *Func) const {
1135 if (!BuildDefs::dump())
1136 return;
1137
1138 char buf[30];
1139 snprintf(
1140 buf, llvm::array_lengthof(buf), "max%s",
1141 InstX86Base<Machine>::Traits::TypeAttributes[this->getDest()->getType()]
1142 .SdSsString);
1143 this->emitTwoAddress(buf, this, Func);
1144 }
1145
1146 template <class Machine>
1147 void InstX86Minss<Machine>::emit(const Cfg *Func) const {
1148 if (!BuildDefs::dump())
1149 return;
1150
1151 char buf[30];
1152 snprintf(
1153 buf, llvm::array_lengthof(buf), "min%s",
1154 InstX86Base<Machine>::Traits::TypeAttributes[this->getDest()->getType()]
1155 .SdSsString);
1156 this->emitTwoAddress(buf, this, Func);
1157 }
1158
1159 template <class Machine>
1160 void InstX86Orps<Machine>::emit(const Cfg *Func) const {
1161 if (!BuildDefs::dump())
1162 return;
1163
1164 char buf[30];
1165 snprintf(
1166 buf, llvm::array_lengthof(buf), "or%s",
1167 InstX86Base<Machine>::Traits::TypeAttributes[this->getDest()->getType()]
1168 .PdPsString);
1169 this->emitTwoAddress(buf, this, Func);
1170 }
1171
1172 template <class Machine>
1173 void InstX86Xorps<Machine>::emit(const Cfg *Func) const {
1174 if (!BuildDefs::dump())
1175 return;
1176
1177 char buf[30];
1178 snprintf(
1179 buf, llvm::array_lengthof(buf), "xor%s",
1180 InstX86Base<Machine>::Traits::TypeAttributes[this->getDest()->getType()]
1181 .PdPsString);
1182 this->emitTwoAddress(buf, this, Func);
1183 }
1184
1185 template <class Machine>
1108 void InstX86Pmuludq<Machine>::emit(const Cfg *Func) const { 1186 void InstX86Pmuludq<Machine>::emit(const Cfg *Func) const {
1109 if (!BuildDefs::dump()) 1187 if (!BuildDefs::dump())
1110 return; 1188 return;
1111 assert(this->getSrc(0)->getType() == IceType_v4i32 && 1189 assert(this->getSrc(0)->getType() == IceType_v4i32 &&
1112 this->getSrc(1)->getType() == IceType_v4i32); 1190 this->getSrc(1)->getType() == IceType_v4i32);
1113 this->emitTwoAddress(this->Opcode, this, Func); 1191 this->emitTwoAddress(this->Opcode, this, Func);
1114 } 1192 }
1115 1193
1116 template <class Machine> 1194 template <class Machine>
1117 void InstX86Divss<Machine>::emit(const Cfg *Func) const { 1195 void InstX86Divss<Machine>::emit(const Cfg *Func) const {
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 this->dumpSources(Func); 1695 this->dumpSources(Func);
1618 } 1696 }
1619 1697
1620 template <class Machine> 1698 template <class Machine>
1621 void InstX86Cmpps<Machine>::emit(const Cfg *Func) const { 1699 void InstX86Cmpps<Machine>::emit(const Cfg *Func) const {
1622 if (!BuildDefs::dump()) 1700 if (!BuildDefs::dump())
1623 return; 1701 return;
1624 Ostream &Str = Func->getContext()->getStrEmit(); 1702 Ostream &Str = Func->getContext()->getStrEmit();
1625 assert(this->getSrcSize() == 2); 1703 assert(this->getSrcSize() == 2);
1626 assert(Condition < InstX86Base<Machine>::Traits::Cond::Cmpps_Invalid); 1704 assert(Condition < InstX86Base<Machine>::Traits::Cond::Cmpps_Invalid);
1705 Type DestTy = this->Dest->getType();
1627 Str << "\t"; 1706 Str << "\t";
1628 Str << "cmp" 1707 Str << "cmp"
1629 << InstX86Base<Machine>::Traits::InstCmppsAttributes[Condition].EmitString 1708 << InstX86Base<Machine>::Traits::InstCmppsAttributes[Condition].EmitString
1630 << "ps" 1709 << InstX86Base<Machine>::Traits::TypeAttributes[DestTy].PdPsString
1631 << "\t"; 1710 << "\t";
1632 this->getSrc(1)->emit(Func); 1711 this->getSrc(1)->emit(Func);
1633 Str << ", "; 1712 Str << ", ";
1634 this->getDest()->emit(Func); 1713 this->getDest()->emit(Func);
1635 } 1714 }
1636 1715
1637 template <class Machine> 1716 template <class Machine>
1638 void InstX86Cmpps<Machine>::emitIAS(const Cfg *Func) const { 1717 void InstX86Cmpps<Machine>::emitIAS(const Cfg *Func) const {
1639 typename InstX86Base<Machine>::Traits::Assembler *Asm = 1718 typename InstX86Base<Machine>::Traits::Assembler *Asm =
1640 Func->getAssembler<typename InstX86Base<Machine>::Traits::Assembler>(); 1719 Func->getAssembler<typename InstX86Base<Machine>::Traits::Assembler>();
1641 assert(this->getSrcSize() == 2); 1720 assert(this->getSrcSize() == 2);
1642 assert(Condition < InstX86Base<Machine>::Traits::Cond::Cmpps_Invalid); 1721 assert(Condition < InstX86Base<Machine>::Traits::Cond::Cmpps_Invalid);
1643 // Assuming there isn't any load folding for cmpps, and vector constants are 1722 // Assuming there isn't any load folding for cmpps, and vector constants are
1644 // not allowed in PNaCl. 1723 // not allowed in PNaCl.
1645 assert(llvm::isa<Variable>(this->getSrc(1))); 1724 assert(llvm::isa<Variable>(this->getSrc(1)));
1646 auto *Target = InstX86Base<Machine>::getTarget(Func); 1725 auto *Target = InstX86Base<Machine>::getTarget(Func);
1647 const auto *SrcVar = llvm::cast<Variable>(this->getSrc(1)); 1726 const auto *SrcVar = llvm::cast<Variable>(this->getSrc(1));
1648 if (SrcVar->hasReg()) { 1727 if (SrcVar->hasReg()) {
1649 Asm->cmpps(InstX86Base<Machine>::Traits::getEncodedXmm( 1728 Asm->cmpps(this->getDest()->getType(),
1729 InstX86Base<Machine>::Traits::getEncodedXmm(
1650 this->getDest()->getRegNum()), 1730 this->getDest()->getRegNum()),
1651 InstX86Base<Machine>::Traits::getEncodedXmm(SrcVar->getRegNum()), 1731 InstX86Base<Machine>::Traits::getEncodedXmm(SrcVar->getRegNum()),
1652 Condition); 1732 Condition);
1653 } else { 1733 } else {
1654 typename InstX86Base<Machine>::Traits::Address SrcStackAddr = 1734 typename InstX86Base<Machine>::Traits::Address SrcStackAddr =
1655 Target->stackVarToAsmOperand(SrcVar); 1735 Target->stackVarToAsmOperand(SrcVar);
1656 Asm->cmpps(InstX86Base<Machine>::Traits::getEncodedXmm( 1736 Asm->cmpps(this->getDest()->getType(),
1737 InstX86Base<Machine>::Traits::getEncodedXmm(
1657 this->getDest()->getRegNum()), 1738 this->getDest()->getRegNum()),
1658 SrcStackAddr, Condition); 1739 SrcStackAddr, Condition);
1659 } 1740 }
1660 } 1741 }
1661 1742
1662 template <class Machine> 1743 template <class Machine>
1663 void InstX86Cmpps<Machine>::dump(const Cfg *Func) const { 1744 void InstX86Cmpps<Machine>::dump(const Cfg *Func) const {
1664 if (!BuildDefs::dump()) 1745 if (!BuildDefs::dump())
1665 return; 1746 return;
1666 Ostream &Str = Func->getContext()->getStrDump(); 1747 Ostream &Str = Func->getContext()->getStrDump();
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after
3186 return; 3267 return;
3187 Ostream &Str = Func->getContext()->getStrDump(); 3268 Ostream &Str = Func->getContext()->getStrDump();
3188 Str << "IACA_END"; 3269 Str << "IACA_END";
3189 } 3270 }
3190 3271
3191 } // end of namespace X86Internal 3272 } // end of namespace X86Internal
3192 3273
3193 } // end of namespace Ice 3274 } // end of namespace Ice
3194 3275
3195 #endif // SUBZERO_SRC_ICEINSTX86BASEIMPL_H 3276 #endif // SUBZERO_SRC_ICEINSTX86BASEIMPL_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698