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); |
| 390 Str << ", beacon="; |
| 391 getBeacon()->dump(Func); |
| 392 } |
| 393 |
373 void InstX8632Label::emit(const Cfg *Func) const { | 394 void InstX8632Label::emit(const Cfg *Func) const { |
374 if (!ALLOW_DUMP) | 395 if (!ALLOW_DUMP) |
375 return; | 396 return; |
376 Ostream &Str = Func->getContext()->getStrEmit(); | 397 Ostream &Str = Func->getContext()->getStrEmit(); |
377 Str << getName(Func) << ":"; | 398 Str << getName(Func) << ":"; |
378 } | 399 } |
379 | 400 |
380 void InstX8632Label::emitIAS(const Cfg *Func) const { | 401 void InstX8632Label::emitIAS(const Cfg *Func) const { |
381 X8632::AssemblerX8632 *Asm = Func->getAssembler<X8632::AssemblerX8632>(); | 402 X8632::AssemblerX8632 *Asm = Func->getAssembler<X8632::AssemblerX8632>(); |
382 Asm->BindLocalLabel(Number); | 403 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 | 603 // The ShiftHack parameter is used to emit "cl" instead of "ecx" for |
583 // shift instructions, in order to be syntactically valid. The | 604 // shift instructions, in order to be syntactically valid. The |
584 // Opcode parameter needs to be char* and not IceString because of | 605 // Opcode parameter needs to be char* and not IceString because of |
585 // template issues. | 606 // template issues. |
586 void InstX8632::emitTwoAddress(const char *Opcode, const Inst *Inst, | 607 void InstX8632::emitTwoAddress(const char *Opcode, const Inst *Inst, |
587 const Cfg *Func, bool ShiftHack) { | 608 const Cfg *Func, bool ShiftHack) { |
588 if (!ALLOW_DUMP) | 609 if (!ALLOW_DUMP) |
589 return; | 610 return; |
590 Ostream &Str = Func->getContext()->getStrEmit(); | 611 Ostream &Str = Func->getContext()->getStrEmit(); |
591 assert(Inst->getSrcSize() == 2); | 612 assert(Inst->getSrcSize() == 2); |
592 Variable *Dest = Inst->getDest(); | 613 Operand *Dest = Inst->getDest(); |
| 614 if (Dest == nullptr) |
| 615 Dest = Inst->getSrc(0); |
593 assert(Dest == Inst->getSrc(0)); | 616 assert(Dest == Inst->getSrc(0)); |
594 Operand *Src1 = Inst->getSrc(1); | 617 Operand *Src1 = Inst->getSrc(1); |
595 Str << "\t" << Opcode << InstX8632::getWidthString(Dest->getType()) << "\t"; | 618 Str << "\t" << Opcode << InstX8632::getWidthString(Dest->getType()) << "\t"; |
596 const auto ShiftReg = llvm::dyn_cast<Variable>(Src1); | 619 const auto ShiftReg = llvm::dyn_cast<Variable>(Src1); |
597 if (ShiftHack && ShiftReg && ShiftReg->getRegNum() == RegX8632::Reg_ecx) | 620 if (ShiftHack && ShiftReg && ShiftReg->getRegNum() == RegX8632::Reg_ecx) |
598 Str << "%cl"; | 621 Str << "%cl"; |
599 else | 622 else |
600 Src1->emit(Func); | 623 Src1->emit(Func); |
601 Str << ", "; | 624 Str << ", "; |
602 Dest->emit(Func); | 625 Dest->emit(Func); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 template <> const char *InstX8632Movsx::Opcode = "movs"; | 927 template <> const char *InstX8632Movsx::Opcode = "movs"; |
905 template <> const char *InstX8632Movzx::Opcode = "movz"; | 928 template <> const char *InstX8632Movzx::Opcode = "movz"; |
906 template <> const char *InstX8632Sqrtss::Opcode = "sqrtss"; | 929 template <> const char *InstX8632Sqrtss::Opcode = "sqrtss"; |
907 template <> const char *InstX8632Cbwdq::Opcode = "cbw/cwd/cdq"; | 930 template <> const char *InstX8632Cbwdq::Opcode = "cbw/cwd/cdq"; |
908 // Mov-like ops | 931 // Mov-like ops |
909 template <> const char *InstX8632Mov::Opcode = "mov"; | 932 template <> const char *InstX8632Mov::Opcode = "mov"; |
910 template <> const char *InstX8632Movp::Opcode = "movups"; | 933 template <> const char *InstX8632Movp::Opcode = "movups"; |
911 template <> const char *InstX8632Movq::Opcode = "movq"; | 934 template <> const char *InstX8632Movq::Opcode = "movq"; |
912 // Binary ops | 935 // Binary ops |
913 template <> const char *InstX8632Add::Opcode = "add"; | 936 template <> const char *InstX8632Add::Opcode = "add"; |
| 937 template <> const char *InstX8632AddRMW::Opcode = "add"; |
914 template <> const char *InstX8632Addps::Opcode = "addps"; | 938 template <> const char *InstX8632Addps::Opcode = "addps"; |
915 template <> const char *InstX8632Adc::Opcode = "adc"; | 939 template <> const char *InstX8632Adc::Opcode = "adc"; |
916 template <> const char *InstX8632Addss::Opcode = "addss"; | 940 template <> const char *InstX8632Addss::Opcode = "addss"; |
917 template <> const char *InstX8632Padd::Opcode = "padd"; | 941 template <> const char *InstX8632Padd::Opcode = "padd"; |
918 template <> const char *InstX8632Sub::Opcode = "sub"; | 942 template <> const char *InstX8632Sub::Opcode = "sub"; |
919 template <> const char *InstX8632Subps::Opcode = "subps"; | 943 template <> const char *InstX8632Subps::Opcode = "subps"; |
920 template <> const char *InstX8632Subss::Opcode = "subss"; | 944 template <> const char *InstX8632Subss::Opcode = "subss"; |
921 template <> const char *InstX8632Sbb::Opcode = "sbb"; | 945 template <> const char *InstX8632Sbb::Opcode = "sbb"; |
922 template <> const char *InstX8632Psub::Opcode = "psub"; | 946 template <> const char *InstX8632Psub::Opcode = "psub"; |
923 template <> const char *InstX8632And::Opcode = "and"; | 947 template <> const char *InstX8632And::Opcode = "and"; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 template <> | 1011 template <> |
988 const X8632::AssemblerX8632::XmmEmitterRegOp InstX8632Sqrtss::Emitter = { | 1012 const X8632::AssemblerX8632::XmmEmitterRegOp InstX8632Sqrtss::Emitter = { |
989 &X8632::AssemblerX8632::sqrtss, &X8632::AssemblerX8632::sqrtss}; | 1013 &X8632::AssemblerX8632::sqrtss, &X8632::AssemblerX8632::sqrtss}; |
990 | 1014 |
991 // Binary GPR ops | 1015 // Binary GPR ops |
992 template <> | 1016 template <> |
993 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632Add::Emitter = { | 1017 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632Add::Emitter = { |
994 &X8632::AssemblerX8632::add, &X8632::AssemblerX8632::add, | 1018 &X8632::AssemblerX8632::add, &X8632::AssemblerX8632::add, |
995 &X8632::AssemblerX8632::add}; | 1019 &X8632::AssemblerX8632::add}; |
996 template <> | 1020 template <> |
| 1021 const X8632::AssemblerX8632::GPREmitterAddrOp InstX8632AddRMW::Emitter = { |
| 1022 &X8632::AssemblerX8632::add, &X8632::AssemblerX8632::add}; |
| 1023 template <> |
997 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632Adc::Emitter = { | 1024 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632Adc::Emitter = { |
998 &X8632::AssemblerX8632::adc, &X8632::AssemblerX8632::adc, | 1025 &X8632::AssemblerX8632::adc, &X8632::AssemblerX8632::adc, |
999 &X8632::AssemblerX8632::adc}; | 1026 &X8632::AssemblerX8632::adc}; |
1000 template <> | 1027 template <> |
1001 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632And::Emitter = { | 1028 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632And::Emitter = { |
1002 &X8632::AssemblerX8632::And, &X8632::AssemblerX8632::And, | 1029 &X8632::AssemblerX8632::And, &X8632::AssemblerX8632::And, |
1003 &X8632::AssemblerX8632::And}; | 1030 &X8632::AssemblerX8632::And}; |
1004 template <> | 1031 template <> |
1005 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632Or::Emitter = { | 1032 const X8632::AssemblerX8632::GPREmitterRegOp InstX8632Or::Emitter = { |
1006 &X8632::AssemblerX8632::Or, &X8632::AssemblerX8632::Or, | 1033 &X8632::AssemblerX8632::Or, &X8632::AssemblerX8632::Or, |
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3002 } | 3029 } |
3003 Str << "("; | 3030 Str << "("; |
3004 if (Func) | 3031 if (Func) |
3005 Var->dump(Func); | 3032 Var->dump(Func); |
3006 else | 3033 else |
3007 Var->dump(Str); | 3034 Var->dump(Str); |
3008 Str << ")"; | 3035 Str << ")"; |
3009 } | 3036 } |
3010 | 3037 |
3011 } // end of namespace Ice | 3038 } // end of namespace Ice |
OLD | NEW |