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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 Vars = Func->allocateArrayOf<Variable *>(NumVars); | 104 Vars = Func->allocateArrayOf<Variable *>(NumVars); |
| 105 SizeT I = 0; | 105 SizeT I = 0; |
| 106 if (Base) | 106 if (Base) |
| 107 Vars[I++] = Base; | 107 Vars[I++] = Base; |
| 108 if (Index) | 108 if (Index) |
| 109 Vars[I++] = Index; | 109 Vars[I++] = Index; |
| 110 assert(I == NumVars); | 110 assert(I == NumVars); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 InstX8632FakeRMW::InstX8632FakeRMW(Cfg *Func, Operand *Data, Operand *Addr, | |
| 115 InstArithmetic::OpKind Op, Variable *Beacon) | |
| 116 : InstX8632(Func, InstX8632::FakeRMW, 3, nullptr), Op(Op) { | |
| 117 addSource(Data); | |
| 118 addSource(Addr); | |
| 119 addSource(Beacon); | |
| 120 } | |
| 121 | |
| 114 InstX8632AdjustStack::InstX8632AdjustStack(Cfg *Func, SizeT Amount, | 122 InstX8632AdjustStack::InstX8632AdjustStack(Cfg *Func, SizeT Amount, |
| 115 Variable *Esp) | 123 Variable *Esp) |
| 116 : InstX8632(Func, InstX8632::Adjuststack, 1, Esp), Amount(Amount) { | 124 : InstX8632(Func, InstX8632::Adjuststack, 1, Esp), Amount(Amount) { |
| 117 addSource(Esp); | 125 addSource(Esp); |
| 118 } | 126 } |
| 119 | 127 |
| 120 InstX8632Mul::InstX8632Mul(Cfg *Func, Variable *Dest, Variable *Source1, | 128 InstX8632Mul::InstX8632Mul(Cfg *Func, Variable *Dest, Variable *Source1, |
| 121 Operand *Source2) | 129 Operand *Source2) |
| 122 : InstX8632(Func, InstX8632::Mul, 2, Dest) { | 130 : InstX8632(Func, InstX8632::Mul, 2, Dest) { |
| 123 addSource(Source1); | 131 addSource(Source1); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 // ======================== Dump routines ======================== // | 371 // ======================== Dump routines ======================== // |
| 364 | 372 |
| 365 void InstX8632::dump(const Cfg *Func) const { | 373 void InstX8632::dump(const Cfg *Func) const { |
| 366 if (!ALLOW_DUMP) | 374 if (!ALLOW_DUMP) |
| 367 return; | 375 return; |
| 368 Ostream &Str = Func->getContext()->getStrDump(); | 376 Ostream &Str = Func->getContext()->getStrDump(); |
| 369 Str << "[X8632] "; | 377 Str << "[X8632] "; |
| 370 Inst::dump(Func); | 378 Inst::dump(Func); |
| 371 } | 379 } |
| 372 | 380 |
| 381 void InstX8632FakeRMW::dump(const Cfg *Func) const { | |
| 382 if (!ALLOW_DUMP) | |
| 383 return; | |
| 384 Ostream &Str = Func->getContext()->getStrDump(); | |
| 385 Type Ty = getData()->getType(); | |
| 386 Str << "rmw " << InstArithmetic::getOpName(getOp()) << " " << Ty << " *"; | |
| 387 getAddr()->dump(Func); | |
| 388 Str << ", "; | |
| 389 getData()->dump(Func); | |
|
jvoung (off chromium)
2015/06/16 17:59:21
Would it be helpful for this to dump the beacon to
Jim Stichnoth
2015/06/17 00:15:40
Done.
| |
| 390 } | |
| 391 | |
| 373 void InstX8632Label::emit(const Cfg *Func) const { | 392 void InstX8632Label::emit(const Cfg *Func) const { |
| 374 if (!ALLOW_DUMP) | 393 if (!ALLOW_DUMP) |
| 375 return; | 394 return; |
| 376 Ostream &Str = Func->getContext()->getStrEmit(); | 395 Ostream &Str = Func->getContext()->getStrEmit(); |
| 377 Str << getName(Func) << ":"; | 396 Str << getName(Func) << ":"; |
| 378 } | 397 } |
| 379 | 398 |
| 380 void InstX8632Label::emitIAS(const Cfg *Func) const { | 399 void InstX8632Label::emitIAS(const Cfg *Func) const { |
| 381 X8632::AssemblerX8632 *Asm = Func->getAssembler<X8632::AssemblerX8632>(); | 400 X8632::AssemblerX8632 *Asm = Func->getAssembler<X8632::AssemblerX8632>(); |
| 382 Asm->BindLocalLabel(Number); | 401 Asm->BindLocalLabel(Number); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 582 // The ShiftHack parameter is used to emit "cl" instead of "ecx" for | 601 // The ShiftHack parameter is used to emit "cl" instead of "ecx" for |
| 583 // shift instructions, in order to be syntactically valid. The | 602 // shift instructions, in order to be syntactically valid. The |
| 584 // Opcode parameter needs to be char* and not IceString because of | 603 // Opcode parameter needs to be char* and not IceString because of |
| 585 // template issues. | 604 // template issues. |
| 586 void InstX8632::emitTwoAddress(const char *Opcode, const Inst *Inst, | 605 void InstX8632::emitTwoAddress(const char *Opcode, const Inst *Inst, |
| 587 const Cfg *Func, bool ShiftHack) { | 606 const Cfg *Func, bool ShiftHack) { |
| 588 if (!ALLOW_DUMP) | 607 if (!ALLOW_DUMP) |
| 589 return; | 608 return; |
| 590 Ostream &Str = Func->getContext()->getStrEmit(); | 609 Ostream &Str = Func->getContext()->getStrEmit(); |
| 591 assert(Inst->getSrcSize() == 2); | 610 assert(Inst->getSrcSize() == 2); |
| 592 Variable *Dest = Inst->getDest(); | 611 Operand *Dest = Inst->getDest(); |
| 612 if (Dest == nullptr) | |
| 613 Dest = Inst->getSrc(0); | |
| 593 assert(Dest == Inst->getSrc(0)); | 614 assert(Dest == Inst->getSrc(0)); |
| 594 Operand *Src1 = Inst->getSrc(1); | 615 Operand *Src1 = Inst->getSrc(1); |
| 595 Str << "\t" << Opcode << InstX8632::getWidthString(Dest->getType()) << "\t"; | 616 Str << "\t" << Opcode << InstX8632::getWidthString(Dest->getType()) << "\t"; |
| 596 const auto ShiftReg = llvm::dyn_cast<Variable>(Src1); | 617 const auto ShiftReg = llvm::dyn_cast<Variable>(Src1); |
| 597 if (ShiftHack && ShiftReg && ShiftReg->getRegNum() == RegX8632::Reg_ecx) | 618 if (ShiftHack && ShiftReg && ShiftReg->getRegNum() == RegX8632::Reg_ecx) |
| 598 Str << "%cl"; | 619 Str << "%cl"; |
| 599 else | 620 else |
| 600 Src1->emit(Func); | 621 Src1->emit(Func); |
| 601 Str << ", "; | 622 Str << ", "; |
| 602 Dest->emit(Func); | 623 Dest->emit(Func); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 904 template <> const char *InstX8632Movsx::Opcode = "movs"; | 925 template <> const char *InstX8632Movsx::Opcode = "movs"; |
| 905 template <> const char *InstX8632Movzx::Opcode = "movz"; | 926 template <> const char *InstX8632Movzx::Opcode = "movz"; |
| 906 template <> const char *InstX8632Sqrtss::Opcode = "sqrtss"; | 927 template <> const char *InstX8632Sqrtss::Opcode = "sqrtss"; |
| 907 template <> const char *InstX8632Cbwdq::Opcode = "cbw/cwd/cdq"; | 928 template <> const char *InstX8632Cbwdq::Opcode = "cbw/cwd/cdq"; |
| 908 // Mov-like ops | 929 // Mov-like ops |
| 909 template <> const char *InstX8632Mov::Opcode = "mov"; | 930 template <> const char *InstX8632Mov::Opcode = "mov"; |
| 910 template <> const char *InstX8632Movp::Opcode = "movups"; | 931 template <> const char *InstX8632Movp::Opcode = "movups"; |
| 911 template <> const char *InstX8632Movq::Opcode = "movq"; | 932 template <> const char *InstX8632Movq::Opcode = "movq"; |
| 912 // Binary ops | 933 // Binary ops |
| 913 template <> const char *InstX8632Add::Opcode = "add"; | 934 template <> const char *InstX8632Add::Opcode = "add"; |
| 935 template <> const char *InstX8632AddRMW::Opcode = "add"; | |
| 914 template <> const char *InstX8632Addps::Opcode = "addps"; | 936 template <> const char *InstX8632Addps::Opcode = "addps"; |
| 915 template <> const char *InstX8632Adc::Opcode = "adc"; | 937 template <> const char *InstX8632Adc::Opcode = "adc"; |
| 916 template <> const char *InstX8632Addss::Opcode = "addss"; | 938 template <> const char *InstX8632Addss::Opcode = "addss"; |
| 917 template <> const char *InstX8632Padd::Opcode = "padd"; | 939 template <> const char *InstX8632Padd::Opcode = "padd"; |
| 918 template <> const char *InstX8632Sub::Opcode = "sub"; | 940 template <> const char *InstX8632Sub::Opcode = "sub"; |
| 919 template <> const char *InstX8632Subps::Opcode = "subps"; | 941 template <> const char *InstX8632Subps::Opcode = "subps"; |
| 920 template <> const char *InstX8632Subss::Opcode = "subss"; | 942 template <> const char *InstX8632Subss::Opcode = "subss"; |
| 921 template <> const char *InstX8632Sbb::Opcode = "sbb"; | 943 template <> const char *InstX8632Sbb::Opcode = "sbb"; |
| 922 template <> const char *InstX8632Psub::Opcode = "psub"; | 944 template <> const char *InstX8632Psub::Opcode = "psub"; |
| 923 template <> const char *InstX8632And::Opcode = "and"; | 945 template <> const char *InstX8632And::Opcode = "and"; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 987 template <> | 1009 template <> |
| 988 const X8632::AssemblerX8632::XmmEmitterRegOp InstX8632Sqrtss::Emitter = { | 1010 const X8632::AssemblerX8632::XmmEmitterRegOp InstX8632Sqrtss::Emitter = { |
| 989 &X8632::AssemblerX8632::sqrtss, &X8632::AssemblerX8632::sqrtss}; | 1011 &X8632::AssemblerX8632::sqrtss, &X8632::AssemblerX8632::sqrtss}; |
| 990 | 1012 |
| 991 // Binary GPR ops | 1013 // Binary GPR ops |
| 992 template <> | 1014 template <> |
| 993 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632Add::Emitter = { | 1015 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632Add::Emitter = { |
| 994 &X8632::AssemblerX8632::add, &X8632::AssemblerX8632::add, | 1016 &X8632::AssemblerX8632::add, &X8632::AssemblerX8632::add, |
| 995 &X8632::AssemblerX8632::add}; | 1017 &X8632::AssemblerX8632::add}; |
| 996 template <> | 1018 template <> |
| 1019 const X8632::AssemblerX8632::GPREmitterAddrOp InstX8632AddRMW::Emitter = { | |
| 1020 &X8632::AssemblerX8632::add, &X8632::AssemblerX8632::add}; | |
| 1021 template <> | |
| 997 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632Adc::Emitter = { | 1022 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632Adc::Emitter = { |
| 998 &X8632::AssemblerX8632::adc, &X8632::AssemblerX8632::adc, | 1023 &X8632::AssemblerX8632::adc, &X8632::AssemblerX8632::adc, |
| 999 &X8632::AssemblerX8632::adc}; | 1024 &X8632::AssemblerX8632::adc}; |
| 1000 template <> | 1025 template <> |
| 1001 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632And::Emitter = { | 1026 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632And::Emitter = { |
| 1002 &X8632::AssemblerX8632::And, &X8632::AssemblerX8632::And, | 1027 &X8632::AssemblerX8632::And, &X8632::AssemblerX8632::And, |
| 1003 &X8632::AssemblerX8632::And}; | 1028 &X8632::AssemblerX8632::And}; |
| 1004 template <> | 1029 template <> |
| 1005 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632Or::Emitter = { | 1030 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632Or::Emitter = { |
| 1006 &X8632::AssemblerX8632::Or, &X8632::AssemblerX8632::Or, | 1031 &X8632::AssemblerX8632::Or, &X8632::AssemblerX8632::Or, |
| (...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3002 } | 3027 } |
| 3003 Str << "("; | 3028 Str << "("; |
| 3004 if (Func) | 3029 if (Func) |
| 3005 Var->dump(Func); | 3030 Var->dump(Func); |
| 3006 else | 3031 else |
| 3007 Var->dump(Str); | 3032 Var->dump(Str); |
| 3008 Str << ")"; | 3033 Str << ")"; |
| 3009 } | 3034 } |
| 3010 | 3035 |
| 3011 } // end of namespace Ice | 3036 } // end of namespace Ice |
| OLD | NEW |