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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 : InstX8632(Func, InstX8632::Fld, 1, NULL) { | 296 : InstX8632(Func, InstX8632::Fld, 1, NULL) { |
297 addSource(Src); | 297 addSource(Src); |
298 } | 298 } |
299 | 299 |
300 InstX8632Fstp::InstX8632Fstp(Cfg *Func, Variable *Dest) | 300 InstX8632Fstp::InstX8632Fstp(Cfg *Func, Variable *Dest) |
301 : InstX8632(Func, InstX8632::Fstp, 0, Dest) {} | 301 : InstX8632(Func, InstX8632::Fstp, 0, Dest) {} |
302 | 302 |
303 InstX8632Pop::InstX8632Pop(Cfg *Func, Variable *Dest) | 303 InstX8632Pop::InstX8632Pop(Cfg *Func, Variable *Dest) |
304 : InstX8632(Func, InstX8632::Pop, 0, Dest) {} | 304 : InstX8632(Func, InstX8632::Pop, 0, Dest) {} |
305 | 305 |
306 InstX8632Push::InstX8632Push(Cfg *Func, Operand *Source, | 306 InstX8632Push::InstX8632Push(Cfg *Func, Variable *Source) |
307 bool SuppressStackAdjustment) | 307 : InstX8632(Func, InstX8632::Push, 1, NULL) { |
308 : InstX8632(Func, InstX8632::Push, 1, NULL), | |
309 SuppressStackAdjustment(SuppressStackAdjustment) { | |
310 addSource(Source); | 308 addSource(Source); |
311 } | 309 } |
312 | 310 |
313 InstX8632Ret::InstX8632Ret(Cfg *Func, Variable *Source) | 311 InstX8632Ret::InstX8632Ret(Cfg *Func, Variable *Source) |
314 : InstX8632(Func, InstX8632::Ret, Source ? 1 : 0, NULL) { | 312 : InstX8632(Func, InstX8632::Ret, Source ? 1 : 0, NULL) { |
315 if (Source) | 313 if (Source) |
316 addSource(Source); | 314 addSource(Source); |
317 } | 315 } |
318 | 316 |
319 InstX8632Xadd::InstX8632Xadd(Cfg *Func, Operand *Dest, Variable *Source, | 317 InstX8632Xadd::InstX8632Xadd(Cfg *Func, Operand *Dest, Variable *Source, |
(...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1861 } | 1859 } |
1862 | 1860 |
1863 void InstX8632AdjustStack::dump(const Cfg *Func) const { | 1861 void InstX8632AdjustStack::dump(const Cfg *Func) const { |
1864 Ostream &Str = Func->getContext()->getStrDump(); | 1862 Ostream &Str = Func->getContext()->getStrDump(); |
1865 Str << "esp = sub.i32 esp, " << Amount; | 1863 Str << "esp = sub.i32 esp, " << Amount; |
1866 } | 1864 } |
1867 | 1865 |
1868 void InstX8632Push::emit(const Cfg *Func) const { | 1866 void InstX8632Push::emit(const Cfg *Func) const { |
1869 Ostream &Str = Func->getContext()->getStrEmit(); | 1867 Ostream &Str = Func->getContext()->getStrEmit(); |
1870 assert(getSrcSize() == 1); | 1868 assert(getSrcSize() == 1); |
1871 Type Ty = getSrc(0)->getType(); | 1869 // Push is currently only used for saving GPRs. |
1872 Variable *Var = llvm::dyn_cast<Variable>(getSrc(0)); | 1870 Variable *Var = llvm::cast<Variable>(getSrc(0)); |
1873 if ((isVectorType(Ty) || isScalarFloatingType(Ty)) && Var && Var->hasReg()) { | 1871 assert(Var->hasReg()); |
1874 // The xmm registers can't be directly pushed, so we fake it by | 1872 Str << "\tpush\t"; |
1875 // decrementing esp and then storing to [esp]. | 1873 Var->emit(Func); |
1876 Str << "\tsub\tesp, " << typeWidthInBytes(Ty) << "\n"; | 1874 Str << "\n"; |
1877 if (!SuppressStackAdjustment) | 1875 } |
1878 Func->getTarget()->updateStackAdjustment(typeWidthInBytes(Ty)); | 1876 |
1879 if (isVectorType(Ty)) { | 1877 void InstX8632Push::emitIAS(const Cfg *Func) const { |
1880 Str << "\tmovups\txmmword ptr [esp], "; | 1878 Ostream &Str = Func->getContext()->getStrEmit(); |
1881 } else { | 1879 assert(getSrcSize() == 1); |
1882 Str << "\tmov" << TypeX8632Attributes[Ty].SdSsString << "\t" | 1880 // Push is currently only used for saving GPRs. |
1883 << TypeX8632Attributes[Ty].WidthString << " [esp], "; | 1881 Variable *Var = llvm::cast<Variable>(getSrc(0)); |
1884 } | 1882 assert(Var->hasReg()); |
1885 getSrc(0)->emit(Func); | 1883 x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); |
1886 Str << "\n"; | 1884 intptr_t StartPosition = Asm->GetPosition(); |
1887 } else if (Ty == IceType_f64 && (!Var || !Var->hasReg())) { | 1885 Asm->pushl(RegX8632::getEncodedGPR(Var->getRegNum())); |
1888 // A double on the stack has to be pushed as two halves. Push the | 1886 emitIASBytes(Str, Asm, StartPosition); |
1889 // upper half followed by the lower half for little-endian. TODO: | |
1890 // implement. | |
1891 llvm_unreachable("Missing support for pushing doubles from memory"); | |
1892 } else { | |
1893 Str << "\tpush\t"; | |
1894 getSrc(0)->emit(Func); | |
1895 Str << "\n"; | |
1896 if (!SuppressStackAdjustment) | |
1897 Func->getTarget()->updateStackAdjustment(4); | |
1898 } | |
1899 } | 1887 } |
1900 | 1888 |
1901 void InstX8632Push::dump(const Cfg *Func) const { | 1889 void InstX8632Push::dump(const Cfg *Func) const { |
1902 Ostream &Str = Func->getContext()->getStrDump(); | 1890 Ostream &Str = Func->getContext()->getStrDump(); |
1903 Str << "push." << getSrc(0)->getType() << " "; | 1891 Str << "push." << getSrc(0)->getType() << " "; |
1904 dumpSources(Func); | 1892 dumpSources(Func); |
1905 } | 1893 } |
1906 | 1894 |
1907 template <> void InstX8632Psll::emit(const Cfg *Func) const { | 1895 template <> void InstX8632Psll::emit(const Cfg *Func) const { |
1908 assert(getDest()->getType() == IceType_v8i16 || | 1896 assert(getDest()->getType() == IceType_v8i16 || |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2184 } | 2172 } |
2185 Str << "("; | 2173 Str << "("; |
2186 if (Func) | 2174 if (Func) |
2187 Var->dump(Func); | 2175 Var->dump(Func); |
2188 else | 2176 else |
2189 Var->dump(Str); | 2177 Var->dump(Str); |
2190 Str << ")"; | 2178 Str << ")"; |
2191 } | 2179 } |
2192 | 2180 |
2193 } // end of namespace Ice | 2181 } // end of namespace Ice |
OLD | NEW |