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...) 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...) 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(stichnot): The isRedundantAssign() implementations for |
| 231 // InstX8632Mov, InstX8632Movp, and InstX8632Movq are |
| 232 // identical. Consolidate them. |
225 Variable *Src = llvm::dyn_cast<Variable>(getSrc(0)); | 233 Variable *Src = llvm::dyn_cast<Variable>(getSrc(0)); |
226 if (Src == NULL) | 234 if (Src == NULL) |
227 return false; | 235 return false; |
228 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { | 236 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { |
229 // TODO: On x86-64, instructions like "mov eax, eax" are used to | 237 // 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 | 238 // clear the upper 32 bits of rax. We need to recognize and |
231 // preserve these. | 239 // preserve these. |
232 return true; | 240 return true; |
233 } | 241 } |
234 if (!getDest()->hasReg() && !Src->hasReg() && | 242 if (!getDest()->hasReg() && !Src->hasReg() && |
235 Dest->getStackOffset() == Src->getStackOffset()) | 243 Dest->getStackOffset() == Src->getStackOffset()) |
236 return true; | 244 return true; |
237 return false; | 245 return false; |
238 } | 246 } |
239 | 247 |
| 248 bool InstX8632Movp::isRedundantAssign() const { |
| 249 Variable *Src = llvm::dyn_cast<Variable>(getSrc(0)); |
| 250 if (Src == NULL) |
| 251 return false; |
| 252 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { |
| 253 return true; |
| 254 } |
| 255 if (!getDest()->hasReg() && !Src->hasReg() && |
| 256 Dest->getStackOffset() == Src->getStackOffset()) |
| 257 return true; |
| 258 return false; |
| 259 } |
| 260 |
240 bool InstX8632Movq::isRedundantAssign() const { | 261 bool InstX8632Movq::isRedundantAssign() const { |
241 Variable *Src = llvm::dyn_cast<Variable>(getSrc(0)); | 262 Variable *Src = llvm::dyn_cast<Variable>(getSrc(0)); |
242 if (Src == NULL) | 263 if (Src == NULL) |
243 return false; | 264 return false; |
244 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { | 265 if (getDest()->hasReg() && getDest()->getRegNum() == Src->getRegNum()) { |
245 return true; | 266 return true; |
246 } | 267 } |
247 if (!getDest()->hasReg() && !Src->hasReg() && | 268 if (!getDest()->hasReg() && !Src->hasReg() && |
248 Dest->getStackOffset() == Src->getStackOffset()) | 269 Dest->getStackOffset() == Src->getStackOffset()) |
249 return true; | 270 return true; |
(...skipping 423 matching lines...) Loading... |
673 } | 694 } |
674 | 695 |
675 void InstX8632Mov::dump(const Cfg *Func) const { | 696 void InstX8632Mov::dump(const Cfg *Func) const { |
676 Ostream &Str = Func->getContext()->getStrDump(); | 697 Ostream &Str = Func->getContext()->getStrDump(); |
677 Str << "mov." << getDest()->getType() << " "; | 698 Str << "mov." << getDest()->getType() << " "; |
678 dumpDest(Func); | 699 dumpDest(Func); |
679 Str << ", "; | 700 Str << ", "; |
680 dumpSources(Func); | 701 dumpSources(Func); |
681 } | 702 } |
682 | 703 |
| 704 void InstX8632Movp::emit(const Cfg *Func) const { |
| 705 // TODO(wala,stichnot): movups works with all vector operands, but |
| 706 // there exist other instructions (movaps, movdqa, movdqu) that may |
| 707 // perform better, depending on the data type and alignment of the |
| 708 // operands. |
| 709 Ostream &Str = Func->getContext()->getStrEmit(); |
| 710 assert(getSrcSize() == 1); |
| 711 Str << "\tmovups\t"; |
| 712 getDest()->emit(Func); |
| 713 Str << ", "; |
| 714 getSrc(0)->emit(Func); |
| 715 Str << "\n"; |
| 716 } |
| 717 |
683 void InstX8632Movq::emit(const Cfg *Func) const { | 718 void InstX8632Movq::emit(const Cfg *Func) const { |
684 Ostream &Str = Func->getContext()->getStrEmit(); | 719 Ostream &Str = Func->getContext()->getStrEmit(); |
685 assert(getSrcSize() == 1); | 720 assert(getSrcSize() == 1); |
686 assert(getDest()->getType() == IceType_i64 || | 721 assert(getDest()->getType() == IceType_i64 || |
687 getDest()->getType() == IceType_f64); | 722 getDest()->getType() == IceType_f64); |
688 Str << "\tmovq\t"; | 723 Str << "\tmovq\t"; |
689 getDest()->emit(Func); | 724 getDest()->emit(Func); |
690 Str << ", "; | 725 Str << ", "; |
691 getSrc(0)->emit(Func); | 726 getSrc(0)->emit(Func); |
692 Str << "\n"; | 727 Str << "\n"; |
693 } | 728 } |
694 | 729 |
| 730 void InstX8632Movp::dump(const Cfg *Func) const { |
| 731 Ostream &Str = Func->getContext()->getStrDump(); |
| 732 Str << "movups." << getDest()->getType() << " "; |
| 733 dumpDest(Func); |
| 734 Str << ", "; |
| 735 dumpSources(Func); |
| 736 } |
| 737 |
695 void InstX8632Movq::dump(const Cfg *Func) const { | 738 void InstX8632Movq::dump(const Cfg *Func) const { |
696 Ostream &Str = Func->getContext()->getStrDump(); | 739 Ostream &Str = Func->getContext()->getStrDump(); |
697 Str << "movq." << getDest()->getType() << " "; | 740 Str << "movq." << getDest()->getType() << " "; |
698 dumpDest(Func); | 741 dumpDest(Func); |
699 Str << ", "; | 742 Str << ", "; |
700 dumpSources(Func); | 743 dumpSources(Func); |
701 } | 744 } |
702 | 745 |
703 void InstX8632Movsx::emit(const Cfg *Func) const { | 746 void InstX8632Movsx::emit(const Cfg *Func) const { |
704 Ostream &Str = Func->getContext()->getStrEmit(); | 747 Ostream &Str = Func->getContext()->getStrEmit(); |
(...skipping 306 matching lines...) Loading... |
1011 default: | 1054 default: |
1012 Str << "???"; | 1055 Str << "???"; |
1013 break; | 1056 break; |
1014 } | 1057 } |
1015 Str << "("; | 1058 Str << "("; |
1016 Var->dump(Func); | 1059 Var->dump(Func); |
1017 Str << ")"; | 1060 Str << ")"; |
1018 } | 1061 } |
1019 | 1062 |
1020 } // end of namespace Ice | 1063 } // end of namespace Ice |
OLD | NEW |