| OLD | NEW |
| 1 //===- subzero/src/IceInstX86BaseImpl.h - Generic X86 instructions -*- C++ -*=// | 1 //===- subzero/src/IceInstX86BaseImpl.h - Generic X86 instructions -*- C++ -*=// |
| 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 /// \file | 10 /// \file |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 InstArithmetic::OpKind Op, | 50 InstArithmetic::OpKind Op, |
| 51 Variable *Beacon) | 51 Variable *Beacon) |
| 52 : InstX86Base<Machine>(Func, InstX86Base<Machine>::FakeRMW, 3, nullptr), | 52 : InstX86Base<Machine>(Func, InstX86Base<Machine>::FakeRMW, 3, nullptr), |
| 53 Op(Op) { | 53 Op(Op) { |
| 54 this->addSource(Data); | 54 this->addSource(Data); |
| 55 this->addSource(Addr); | 55 this->addSource(Addr); |
| 56 this->addSource(Beacon); | 56 this->addSource(Beacon); |
| 57 } | 57 } |
| 58 | 58 |
| 59 template <class Machine> | 59 template <class Machine> |
| 60 InstX86AdjustStack<Machine>::InstX86AdjustStack(Cfg *Func, int32_t Amount, | |
| 61 Variable *Esp) | |
| 62 : InstX86Base<Machine>(Func, InstX86Base<Machine>::Adjuststack, 1, Esp), | |
| 63 Amount(Amount) { | |
| 64 this->addSource(Esp); | |
| 65 } | |
| 66 | |
| 67 template <class Machine> | |
| 68 InstX86Mul<Machine>::InstX86Mul(Cfg *Func, Variable *Dest, Variable *Source1, | 60 InstX86Mul<Machine>::InstX86Mul(Cfg *Func, Variable *Dest, Variable *Source1, |
| 69 Operand *Source2) | 61 Operand *Source2) |
| 70 : InstX86Base<Machine>(Func, InstX86Base<Machine>::Mul, 2, Dest) { | 62 : InstX86Base<Machine>(Func, InstX86Base<Machine>::Mul, 2, Dest) { |
| 71 this->addSource(Source1); | 63 this->addSource(Source1); |
| 72 this->addSource(Source2); | 64 this->addSource(Source2); |
| 73 } | 65 } |
| 74 | 66 |
| 75 template <class Machine> | 67 template <class Machine> |
| 76 InstX86Shld<Machine>::InstX86Shld(Cfg *Func, Variable *Dest, Variable *Source1, | 68 InstX86Shld<Machine>::InstX86Shld(Cfg *Func, Variable *Dest, Variable *Source1, |
| 77 Operand *Source2) | 69 Operand *Source2) |
| (...skipping 2822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2900 | 2892 |
| 2901 template <class Machine> void InstX86Pop<Machine>::dump(const Cfg *Func) const { | 2893 template <class Machine> void InstX86Pop<Machine>::dump(const Cfg *Func) const { |
| 2902 if (!BuildDefs::dump()) | 2894 if (!BuildDefs::dump()) |
| 2903 return; | 2895 return; |
| 2904 Ostream &Str = Func->getContext()->getStrDump(); | 2896 Ostream &Str = Func->getContext()->getStrDump(); |
| 2905 this->dumpDest(Func); | 2897 this->dumpDest(Func); |
| 2906 Str << " = pop." << this->getDest()->getType() << " "; | 2898 Str << " = pop." << this->getDest()->getType() << " "; |
| 2907 } | 2899 } |
| 2908 | 2900 |
| 2909 template <class Machine> | 2901 template <class Machine> |
| 2910 void InstX86AdjustStack<Machine>::emit(const Cfg *Func) const { | |
| 2911 if (!BuildDefs::dump()) | |
| 2912 return; | |
| 2913 Ostream &Str = Func->getContext()->getStrEmit(); | |
| 2914 if (Amount > 0) | |
| 2915 Str << "\tsubl\t$" << Amount << ", %esp"; | |
| 2916 else | |
| 2917 Str << "\taddl\t$" << -Amount << ", %esp"; | |
| 2918 auto *Target = InstX86Base<Machine>::getTarget(Func); | |
| 2919 Target->updateStackAdjustment(Amount); | |
| 2920 } | |
| 2921 | |
| 2922 template <class Machine> | |
| 2923 void InstX86AdjustStack<Machine>::emitIAS(const Cfg *Func) const { | |
| 2924 typename InstX86Base<Machine>::Traits::Assembler *Asm = | |
| 2925 Func->getAssembler<typename InstX86Base<Machine>::Traits::Assembler>(); | |
| 2926 if (Amount > 0) | |
| 2927 Asm->sub(IceType_i32, | |
| 2928 InstX86Base<Machine>::Traits::RegisterSet::Encoded_Reg_esp, | |
| 2929 Immediate(Amount)); | |
| 2930 else | |
| 2931 Asm->add(IceType_i32, | |
| 2932 InstX86Base<Machine>::Traits::RegisterSet::Encoded_Reg_esp, | |
| 2933 Immediate(-Amount)); | |
| 2934 auto *Target = InstX86Base<Machine>::getTarget(Func); | |
| 2935 Target->updateStackAdjustment(Amount); | |
| 2936 } | |
| 2937 | |
| 2938 template <class Machine> | |
| 2939 void InstX86AdjustStack<Machine>::dump(const Cfg *Func) const { | |
| 2940 if (!BuildDefs::dump()) | |
| 2941 return; | |
| 2942 Ostream &Str = Func->getContext()->getStrDump(); | |
| 2943 if (Amount > 0) | |
| 2944 Str << "esp = sub.i32 esp, " << Amount; | |
| 2945 else | |
| 2946 Str << "esp = add.i32 esp, " << -Amount; | |
| 2947 } | |
| 2948 | |
| 2949 template <class Machine> | |
| 2950 void InstX86Push<Machine>::emit(const Cfg *Func) const { | 2902 void InstX86Push<Machine>::emit(const Cfg *Func) const { |
| 2951 if (!BuildDefs::dump()) | 2903 if (!BuildDefs::dump()) |
| 2952 return; | 2904 return; |
| 2953 Ostream &Str = Func->getContext()->getStrEmit(); | 2905 Ostream &Str = Func->getContext()->getStrEmit(); |
| 2954 assert(this->getSrcSize() == 1); | 2906 assert(this->getSrcSize() == 1); |
| 2955 // Push is currently only used for saving GPRs. | 2907 // Push is currently only used for saving GPRs. |
| 2956 const auto *Var = llvm::cast<Variable>(this->getSrc(0)); | 2908 const auto *Var = llvm::cast<Variable>(this->getSrc(0)); |
| 2957 assert(Var->hasReg()); | 2909 assert(Var->hasReg()); |
| 2958 Str << "\tpush\t"; | 2910 Str << "\tpush\t"; |
| 2959 Var->emit(Func); | 2911 Var->emit(Func); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3234 return; | 3186 return; |
| 3235 Ostream &Str = Func->getContext()->getStrDump(); | 3187 Ostream &Str = Func->getContext()->getStrDump(); |
| 3236 Str << "IACA_END"; | 3188 Str << "IACA_END"; |
| 3237 } | 3189 } |
| 3238 | 3190 |
| 3239 } // end of namespace X86Internal | 3191 } // end of namespace X86Internal |
| 3240 | 3192 |
| 3241 } // end of namespace Ice | 3193 } // end of namespace Ice |
| 3242 | 3194 |
| 3243 #endif // SUBZERO_SRC_ICEINSTX86BASEIMPL_H | 3195 #endif // SUBZERO_SRC_ICEINSTX86BASEIMPL_H |
| OLD | NEW |