Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 : InstX8632(Func, InstX8632::Store, 2, NULL) { | 175 : InstX8632(Func, InstX8632::Store, 2, NULL) { |
| 176 addSource(Value); | 176 addSource(Value); |
| 177 addSource(Mem); | 177 addSource(Mem); |
| 178 } | 178 } |
| 179 | 179 |
| 180 InstX8632Mov::InstX8632Mov(Cfg *Func, Variable *Dest, Operand *Source) | 180 InstX8632Mov::InstX8632Mov(Cfg *Func, Variable *Dest, Operand *Source) |
| 181 : InstX8632(Func, InstX8632::Mov, 1, Dest) { | 181 : InstX8632(Func, InstX8632::Mov, 1, Dest) { |
| 182 addSource(Source); | 182 addSource(Source); |
| 183 } | 183 } |
| 184 | 184 |
| 185 InstX8632Movp::InstX8632Movp(Cfg *Func, Variable *Dest, Operand *Source) | |
| 186 : InstX8632(Func, InstX8632::Movp, 1, Dest) { | |
| 187 addSource(Source); | |
| 188 } | |
| 189 | |
| 185 InstX8632StoreQ::InstX8632StoreQ(Cfg *Func, Operand *Value, OperandX8632 *Mem) | 190 InstX8632StoreQ::InstX8632StoreQ(Cfg *Func, Operand *Value, OperandX8632 *Mem) |
| 186 : InstX8632(Func, InstX8632::StoreQ, 2, NULL) { | 191 : InstX8632(Func, InstX8632::StoreQ, 2, NULL) { |
| 187 addSource(Value); | 192 addSource(Value); |
| 188 addSource(Mem); | 193 addSource(Mem); |
| 189 } | 194 } |
| 190 | 195 |
| 191 InstX8632Movq::InstX8632Movq(Cfg *Func, Variable *Dest, Operand *Source) | 196 InstX8632Movq::InstX8632Movq(Cfg *Func, Variable *Dest, Operand *Source) |
| 192 : InstX8632(Func, InstX8632::Movq, 1, Dest) { | 197 : InstX8632(Func, InstX8632::Movq, 1, Dest) { |
| 193 addSource(Source); | 198 addSource(Source); |
| 194 } | 199 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 215 : InstX8632(Func, InstX8632::Pop, 0, Dest) {} | 220 : InstX8632(Func, InstX8632::Pop, 0, Dest) {} |
| 216 | 221 |
| 217 InstX8632Push::InstX8632Push(Cfg *Func, Operand *Source, | 222 InstX8632Push::InstX8632Push(Cfg *Func, Operand *Source, |
| 218 bool SuppressStackAdjustment) | 223 bool SuppressStackAdjustment) |
| 219 : InstX8632(Func, InstX8632::Push, 1, NULL), | 224 : InstX8632(Func, InstX8632::Push, 1, NULL), |
| 220 SuppressStackAdjustment(SuppressStackAdjustment) { | 225 SuppressStackAdjustment(SuppressStackAdjustment) { |
| 221 addSource(Source); | 226 addSource(Source); |
| 222 } | 227 } |
| 223 | 228 |
| 224 bool InstX8632Mov::isRedundantAssign() const { | 229 bool InstX8632Mov::isRedundantAssign() const { |
| 230 // TODO: The isRedundantAssign() implementations for InstX8632Mov, | |
|
Jim Stichnoth
2014/06/27 23:11:05
TODO(stichnot)
| |
| 231 // InstX8632Movp, and InstX8632Movq are identical. Consolidate them. | |
| 225 Variable *Src = llvm::dyn_cast<Variable>(getSrc(0)); | 232 Variable *Src = llvm::dyn_cast<Variable>(getSrc(0)); |
| 226 if (Src == NULL) | 233 if (Src == NULL) |
| 227 return false; | 234 return false; |
| 228 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { | 235 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { |
| 229 // TODO: On x86-64, instructions like "mov eax, eax" are used to | 236 // TODO: On x86-64, instructions like "mov eax, eax" are used to |
| 230 // clear the upper 32 bits of rax. We need to recognize and | 237 // clear the upper 32 bits of rax. We need to recognize and |
| 231 // preserve these. | 238 // preserve these. |
| 232 return true; | 239 return true; |
| 233 } | 240 } |
| 234 if (!getDest()->hasReg() && !Src->hasReg() && | 241 if (!getDest()->hasReg() && !Src->hasReg() && |
| 235 Dest->getStackOffset() == Src->getStackOffset()) | 242 Dest->getStackOffset() == Src->getStackOffset()) |
| 236 return true; | 243 return true; |
| 237 return false; | 244 return false; |
| 238 } | 245 } |
| 239 | 246 |
| 247 bool InstX8632Movp::isRedundantAssign() const { | |
| 248 Variable *Src = llvm::dyn_cast<Variable>(getSrc(0)); | |
| 249 if (Src == NULL) | |
| 250 return false; | |
| 251 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { | |
| 252 return true; | |
| 253 } | |
| 254 if (!getDest()->hasReg() && !Src->hasReg() && | |
| 255 Dest->getStackOffset() == Src->getStackOffset()) | |
| 256 return true; | |
| 257 return false; | |
| 258 } | |
| 259 | |
| 240 bool InstX8632Movq::isRedundantAssign() const { | 260 bool InstX8632Movq::isRedundantAssign() const { |
| 241 Variable *Src = llvm::dyn_cast<Variable>(getSrc(0)); | 261 Variable *Src = llvm::dyn_cast<Variable>(getSrc(0)); |
| 242 if (Src == NULL) | 262 if (Src == NULL) |
| 243 return false; | 263 return false; |
| 244 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { | 264 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { |
| 245 return true; | 265 return true; |
| 246 } | 266 } |
| 247 if (!getDest()->hasReg() && !Src->hasReg() && | 267 if (!getDest()->hasReg() && !Src->hasReg() && |
| 248 Dest->getStackOffset() == Src->getStackOffset()) | 268 Dest->getStackOffset() == Src->getStackOffset()) |
| 249 return true; | 269 return true; |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 673 } | 693 } |
| 674 | 694 |
| 675 void InstX8632Mov::dump(const Cfg *Func) const { | 695 void InstX8632Mov::dump(const Cfg *Func) const { |
| 676 Ostream &Str = Func->getContext()->getStrDump(); | 696 Ostream &Str = Func->getContext()->getStrDump(); |
| 677 Str << "mov." << getDest()->getType() << " "; | 697 Str << "mov." << getDest()->getType() << " "; |
| 678 dumpDest(Func); | 698 dumpDest(Func); |
| 679 Str << ", "; | 699 Str << ", "; |
| 680 dumpSources(Func); | 700 dumpSources(Func); |
| 681 } | 701 } |
| 682 | 702 |
| 703 void InstX8632Movp::emit(const Cfg *Func) const { | |
| 704 // TODO(wala,stichnot): movups works with all vector operands, but | |
| 705 // there exist other instructions (movaps, movdqa, movdqu) that may | |
| 706 // perform better, depending on the data type and alignment of the | |
| 707 // operands. | |
| 708 Ostream &Str = Func->getContext()->getStrEmit(); | |
| 709 assert(getSrcSize() == 1); | |
| 710 Str << "\tmovups\t"; | |
| 711 getDest()->emit(Func); | |
| 712 Str << ", "; | |
| 713 getSrc(0)->emit(Func); | |
| 714 Str << "\n"; | |
| 715 } | |
| 716 | |
| 683 void InstX8632Movq::emit(const Cfg *Func) const { | 717 void InstX8632Movq::emit(const Cfg *Func) const { |
| 684 Ostream &Str = Func->getContext()->getStrEmit(); | 718 Ostream &Str = Func->getContext()->getStrEmit(); |
| 685 assert(getSrcSize() == 1); | 719 assert(getSrcSize() == 1); |
| 686 assert(getDest()->getType() == IceType_i64 || | 720 assert(getDest()->getType() == IceType_i64 || |
| 687 getDest()->getType() == IceType_f64); | 721 getDest()->getType() == IceType_f64); |
| 688 Str << "\tmovq\t"; | 722 Str << "\tmovq\t"; |
| 689 getDest()->emit(Func); | 723 getDest()->emit(Func); |
| 690 Str << ", "; | 724 Str << ", "; |
| 691 getSrc(0)->emit(Func); | 725 getSrc(0)->emit(Func); |
| 692 Str << "\n"; | 726 Str << "\n"; |
| 693 } | 727 } |
| 694 | 728 |
| 729 void InstX8632Movp::dump(const Cfg *Func) const { | |
| 730 Ostream &Str = Func->getContext()->getStrDump(); | |
| 731 Str << "movups." << getDest()->getType() << " "; | |
| 732 dumpDest(Func); | |
| 733 Str << ", "; | |
| 734 dumpSources(Func); | |
| 735 } | |
| 736 | |
| 695 void InstX8632Movq::dump(const Cfg *Func) const { | 737 void InstX8632Movq::dump(const Cfg *Func) const { |
| 696 Ostream &Str = Func->getContext()->getStrDump(); | 738 Ostream &Str = Func->getContext()->getStrDump(); |
| 697 Str << "movq." << getDest()->getType() << " "; | 739 Str << "movq." << getDest()->getType() << " "; |
| 698 dumpDest(Func); | 740 dumpDest(Func); |
| 699 Str << ", "; | 741 Str << ", "; |
| 700 dumpSources(Func); | 742 dumpSources(Func); |
| 701 } | 743 } |
| 702 | 744 |
| 703 void InstX8632Movsx::emit(const Cfg *Func) const { | 745 void InstX8632Movsx::emit(const Cfg *Func) const { |
| 704 Ostream &Str = Func->getContext()->getStrEmit(); | 746 Ostream &Str = Func->getContext()->getStrEmit(); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 default: | 1053 default: |
| 1012 Str << "???"; | 1054 Str << "???"; |
| 1013 break; | 1055 break; |
| 1014 } | 1056 } |
| 1015 Str << "("; | 1057 Str << "("; |
| 1016 Var->dump(Func); | 1058 Var->dump(Func); |
| 1017 Str << ")"; | 1059 Str << ")"; |
| 1018 } | 1060 } |
| 1019 | 1061 |
| 1020 } // end of namespace Ice | 1062 } // end of namespace Ice |
| OLD | NEW |