Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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]; | |
|
Jim Stichnoth
2015/12/08 18:55:59
This style of generating the opcode string bothers
sehr
2015/12/15 20:45:44
OK, I think there's a larger commonality to the SS
| |
| 1113 const char *suffix = (this->getDest()->getType() == IceType_f64) ? "d" : "s"; | |
| 1114 snprintf(buf, llvm::array_lengthof(buf), "andnp%s", suffix); | |
| 1115 this->emitTwoAddress(buf, this, Func); | |
| 1116 } | |
| 1117 | |
| 1118 template <class Machine> | |
| 1119 void InstX86Andps<Machine>::emit(const Cfg *Func) const { | |
| 1120 if (!BuildDefs::dump()) | |
| 1121 return; | |
| 1122 | |
| 1123 char buf[30]; | |
| 1124 const char *suffix = (this->getDest()->getType() == IceType_f64) ? "d" : "s"; | |
| 1125 snprintf(buf, llvm::array_lengthof(buf), "andp%s", suffix); | |
| 1126 this->emitTwoAddress(buf, this, Func); | |
| 1127 } | |
| 1128 | |
| 1129 template <class Machine> | |
| 1130 void InstX86Maxss<Machine>::emit(const Cfg *Func) const { | |
| 1131 if (!BuildDefs::dump()) | |
| 1132 return; | |
| 1133 | |
| 1134 char buf[30]; | |
| 1135 const char *suffix = (this->getDest()->getType() == IceType_f64) ? "d" : "s"; | |
| 1136 snprintf(buf, llvm::array_lengthof(buf), "maxs%s", suffix); | |
| 1137 this->emitTwoAddress(buf, this, Func); | |
| 1138 } | |
| 1139 | |
| 1140 template <class Machine> | |
| 1141 void InstX86Minss<Machine>::emit(const Cfg *Func) const { | |
| 1142 if (!BuildDefs::dump()) | |
| 1143 return; | |
| 1144 | |
| 1145 char buf[30]; | |
| 1146 const char *suffix = (this->getDest()->getType() == IceType_f64) ? "d" : "s"; | |
| 1147 snprintf(buf, llvm::array_lengthof(buf), "mins%s", suffix); | |
| 1148 this->emitTwoAddress(buf, this, Func); | |
| 1149 } | |
| 1150 | |
| 1151 template <class Machine> | |
| 1152 void InstX86Orps<Machine>::emit(const Cfg *Func) const { | |
| 1153 if (!BuildDefs::dump()) | |
| 1154 return; | |
| 1155 | |
| 1156 char buf[30]; | |
| 1157 const char *suffix = (this->getDest()->getType() == IceType_f64) ? "d" : "s"; | |
| 1158 snprintf(buf, llvm::array_lengthof(buf), "orp%s", suffix); | |
| 1159 this->emitTwoAddress(buf, this, Func); | |
| 1160 } | |
| 1161 | |
| 1162 template <class Machine> | |
| 1163 void InstX86Xorps<Machine>::emit(const Cfg *Func) const { | |
| 1164 if (!BuildDefs::dump()) | |
| 1165 return; | |
| 1166 | |
| 1167 char buf[30]; | |
| 1168 const char *suffix = (this->getDest()->getType() == IceType_f64) ? "d" : "s"; | |
| 1169 snprintf(buf, llvm::array_lengthof(buf), "xorp%s", suffix); | |
| 1170 this->emitTwoAddress(buf, this, Func); | |
| 1171 } | |
| 1172 | |
| 1173 template <class Machine> | |
| 1108 void InstX86Pmuludq<Machine>::emit(const Cfg *Func) const { | 1174 void InstX86Pmuludq<Machine>::emit(const Cfg *Func) const { |
| 1109 if (!BuildDefs::dump()) | 1175 if (!BuildDefs::dump()) |
| 1110 return; | 1176 return; |
| 1111 assert(this->getSrc(0)->getType() == IceType_v4i32 && | 1177 assert(this->getSrc(0)->getType() == IceType_v4i32 && |
| 1112 this->getSrc(1)->getType() == IceType_v4i32); | 1178 this->getSrc(1)->getType() == IceType_v4i32); |
| 1113 this->emitTwoAddress(this->Opcode, this, Func); | 1179 this->emitTwoAddress(this->Opcode, this, Func); |
| 1114 } | 1180 } |
| 1115 | 1181 |
| 1116 template <class Machine> | 1182 template <class Machine> |
| 1117 void InstX86Divss<Machine>::emit(const Cfg *Func) const { | 1183 void InstX86Divss<Machine>::emit(const Cfg *Func) const { |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1620 template <class Machine> | 1686 template <class Machine> |
| 1621 void InstX86Cmpps<Machine>::emit(const Cfg *Func) const { | 1687 void InstX86Cmpps<Machine>::emit(const Cfg *Func) const { |
| 1622 if (!BuildDefs::dump()) | 1688 if (!BuildDefs::dump()) |
| 1623 return; | 1689 return; |
| 1624 Ostream &Str = Func->getContext()->getStrEmit(); | 1690 Ostream &Str = Func->getContext()->getStrEmit(); |
| 1625 assert(this->getSrcSize() == 2); | 1691 assert(this->getSrcSize() == 2); |
| 1626 assert(Condition < InstX86Base<Machine>::Traits::Cond::Cmpps_Invalid); | 1692 assert(Condition < InstX86Base<Machine>::Traits::Cond::Cmpps_Invalid); |
| 1627 Str << "\t"; | 1693 Str << "\t"; |
| 1628 Str << "cmp" | 1694 Str << "cmp" |
| 1629 << InstX86Base<Machine>::Traits::InstCmppsAttributes[Condition].EmitString | 1695 << InstX86Base<Machine>::Traits::InstCmppsAttributes[Condition].EmitString |
| 1630 << "ps" | 1696 << "p" << ((this->getDest()->getType() == IceType_f64) ? "d" : "s") |
| 1631 << "\t"; | 1697 << "\t"; |
| 1632 this->getSrc(1)->emit(Func); | 1698 this->getSrc(1)->emit(Func); |
| 1633 Str << ", "; | 1699 Str << ", "; |
| 1634 this->getDest()->emit(Func); | 1700 this->getDest()->emit(Func); |
| 1635 } | 1701 } |
| 1636 | 1702 |
| 1637 template <class Machine> | 1703 template <class Machine> |
| 1638 void InstX86Cmpps<Machine>::emitIAS(const Cfg *Func) const { | 1704 void InstX86Cmpps<Machine>::emitIAS(const Cfg *Func) const { |
| 1639 typename InstX86Base<Machine>::Traits::Assembler *Asm = | 1705 typename InstX86Base<Machine>::Traits::Assembler *Asm = |
| 1640 Func->getAssembler<typename InstX86Base<Machine>::Traits::Assembler>(); | 1706 Func->getAssembler<typename InstX86Base<Machine>::Traits::Assembler>(); |
| 1641 assert(this->getSrcSize() == 2); | 1707 assert(this->getSrcSize() == 2); |
| 1642 assert(Condition < InstX86Base<Machine>::Traits::Cond::Cmpps_Invalid); | 1708 assert(Condition < InstX86Base<Machine>::Traits::Cond::Cmpps_Invalid); |
| 1643 // Assuming there isn't any load folding for cmpps, and vector constants are | 1709 // Assuming there isn't any load folding for cmpps, and vector constants are |
| 1644 // not allowed in PNaCl. | 1710 // not allowed in PNaCl. |
| 1645 assert(llvm::isa<Variable>(this->getSrc(1))); | 1711 assert(llvm::isa<Variable>(this->getSrc(1))); |
| 1646 auto *Target = InstX86Base<Machine>::getTarget(Func); | 1712 auto *Target = InstX86Base<Machine>::getTarget(Func); |
| 1647 const auto *SrcVar = llvm::cast<Variable>(this->getSrc(1)); | 1713 const auto *SrcVar = llvm::cast<Variable>(this->getSrc(1)); |
| 1648 if (SrcVar->hasReg()) { | 1714 if (SrcVar->hasReg()) { |
| 1649 Asm->cmpps(InstX86Base<Machine>::Traits::getEncodedXmm( | 1715 Asm->cmpps(this->getDest()->getType(), |
| 1716 InstX86Base<Machine>::Traits::getEncodedXmm( | |
| 1650 this->getDest()->getRegNum()), | 1717 this->getDest()->getRegNum()), |
| 1651 InstX86Base<Machine>::Traits::getEncodedXmm(SrcVar->getRegNum()), | 1718 InstX86Base<Machine>::Traits::getEncodedXmm(SrcVar->getRegNum()), |
| 1652 Condition); | 1719 Condition); |
| 1653 } else { | 1720 } else { |
| 1654 typename InstX86Base<Machine>::Traits::Address SrcStackAddr = | 1721 typename InstX86Base<Machine>::Traits::Address SrcStackAddr = |
| 1655 Target->stackVarToAsmOperand(SrcVar); | 1722 Target->stackVarToAsmOperand(SrcVar); |
| 1656 Asm->cmpps(InstX86Base<Machine>::Traits::getEncodedXmm( | 1723 Asm->cmpps(this->getDest()->getType(), |
| 1724 InstX86Base<Machine>::Traits::getEncodedXmm( | |
| 1657 this->getDest()->getRegNum()), | 1725 this->getDest()->getRegNum()), |
| 1658 SrcStackAddr, Condition); | 1726 SrcStackAddr, Condition); |
| 1659 } | 1727 } |
| 1660 } | 1728 } |
| 1661 | 1729 |
| 1662 template <class Machine> | 1730 template <class Machine> |
| 1663 void InstX86Cmpps<Machine>::dump(const Cfg *Func) const { | 1731 void InstX86Cmpps<Machine>::dump(const Cfg *Func) const { |
| 1664 if (!BuildDefs::dump()) | 1732 if (!BuildDefs::dump()) |
| 1665 return; | 1733 return; |
| 1666 Ostream &Str = Func->getContext()->getStrDump(); | 1734 Ostream &Str = Func->getContext()->getStrDump(); |
| (...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3186 return; | 3254 return; |
| 3187 Ostream &Str = Func->getContext()->getStrDump(); | 3255 Ostream &Str = Func->getContext()->getStrDump(); |
| 3188 Str << "IACA_END"; | 3256 Str << "IACA_END"; |
| 3189 } | 3257 } |
| 3190 | 3258 |
| 3191 } // end of namespace X86Internal | 3259 } // end of namespace X86Internal |
| 3192 | 3260 |
| 3193 } // end of namespace Ice | 3261 } // end of namespace Ice |
| 3194 | 3262 |
| 3195 #endif // SUBZERO_SRC_ICEINSTX86BASEIMPL_H | 3263 #endif // SUBZERO_SRC_ICEINSTX86BASEIMPL_H |
| OLD | NEW |