| OLD | NEW |
| 1 //===- subzero/src/IceInstMips32.cpp - Mips32 instruction implementation --===// | 1 //===- subzero/src/IceInstMips32.cpp - Mips32 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 /// \file | 10 /// \file |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 bool OperandMIPS32Mem::canHoldOffset(Type Ty, bool SignExt, int32_t Offset) { | 39 bool OperandMIPS32Mem::canHoldOffset(Type Ty, bool SignExt, int32_t Offset) { |
| 40 (void)SignExt; | 40 (void)SignExt; |
| 41 (void)Ty; | 41 (void)Ty; |
| 42 if ((std::numeric_limits<int16_t>::min() <= Offset) && | 42 if ((std::numeric_limits<int16_t>::min() <= Offset) && |
| 43 (Offset <= std::numeric_limits<int16_t>::max())) | 43 (Offset <= std::numeric_limits<int16_t>::max())) |
| 44 return true; | 44 return true; |
| 45 return false; | 45 return false; |
| 46 } | 46 } |
| 47 | 47 |
| 48 OperandMIPS32Mem::OperandMIPS32Mem(Cfg *Func, Type Ty, Variable *Base, | 48 OperandMIPS32Mem::OperandMIPS32Mem(Cfg *Func, Type Ty, Variable *Base, |
| 49 ConstantInteger32 *ImmOffset, AddrMode Mode) | 49 Operand *ImmOffset, AddrMode Mode) |
| 50 : OperandMIPS32(kMem, Ty), Base(Base), ImmOffset(ImmOffset), Mode(Mode) { | 50 : OperandMIPS32(kMem, Ty), Base(Base), ImmOffset(ImmOffset), Mode(Mode) { |
| 51 // The Neg modes are only needed for Reg +/- Reg. | 51 // The Neg modes are only needed for Reg +/- Reg. |
| 52 (void)Func; | 52 (void)Func; |
| 53 // assert(!isNegAddrMode()); | 53 // assert(!isNegAddrMode()); |
| 54 NumVars = 1; | 54 NumVars = 1; |
| 55 Vars = &this->Base; | 55 Vars = &this->Base; |
| 56 } | 56 } |
| 57 | 57 |
| 58 const char *InstMIPS32::getWidthString(Type Ty) { | 58 const char *InstMIPS32::getWidthString(Type Ty) { |
| 59 (void)Ty; | 59 (void)Ty; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 template <> const char *InstMIPS32Subu::Opcode = "subu"; | 114 template <> const char *InstMIPS32Subu::Opcode = "subu"; |
| 115 template <> const char *InstMIPS32Sw::Opcode = "sw"; | 115 template <> const char *InstMIPS32Sw::Opcode = "sw"; |
| 116 template <> const char *InstMIPS32Swc1::Opcode = "swc1"; | 116 template <> const char *InstMIPS32Swc1::Opcode = "swc1"; |
| 117 template <> const char *InstMIPS32Trunc_l_d::Opcode = "trunc.l.d"; | 117 template <> const char *InstMIPS32Trunc_l_d::Opcode = "trunc.l.d"; |
| 118 template <> const char *InstMIPS32Trunc_l_s::Opcode = "trunc.l.s"; | 118 template <> const char *InstMIPS32Trunc_l_s::Opcode = "trunc.l.s"; |
| 119 template <> const char *InstMIPS32Trunc_w_d::Opcode = "trunc.w.d"; | 119 template <> const char *InstMIPS32Trunc_w_d::Opcode = "trunc.w.d"; |
| 120 template <> const char *InstMIPS32Trunc_w_s::Opcode = "trunc.w.s"; | 120 template <> const char *InstMIPS32Trunc_w_s::Opcode = "trunc.w.s"; |
| 121 template <> const char *InstMIPS32Xor::Opcode = "xor"; | 121 template <> const char *InstMIPS32Xor::Opcode = "xor"; |
| 122 template <> const char *InstMIPS32Xori::Opcode = "xori"; | 122 template <> const char *InstMIPS32Xori::Opcode = "xori"; |
| 123 | 123 |
| 124 template <> void InstMIPS32Lui::emit(const Cfg *Func) const { |
| 125 if (!BuildDefs::dump()) |
| 126 return; |
| 127 Ostream &Str = Func->getContext()->getStrEmit(); |
| 128 assert(getSrcSize() == 1); |
| 129 Str << "\t" << Opcode << "\t"; |
| 130 getDest()->emit(Func); |
| 131 Str << ", "; |
| 132 auto *Src0 = llvm::cast<Constant>(getSrc(0)); |
| 133 if (auto *CR = llvm::dyn_cast<ConstantRelocatable>(Src0)) { |
| 134 emitRelocOp(Str, Reloc); |
| 135 Str << "("; |
| 136 CR->emitWithoutPrefix(Func->getTarget()); |
| 137 Str << ")"; |
| 138 } else { |
| 139 Src0->emit(Func); |
| 140 } |
| 141 } |
| 142 |
| 124 template <> void InstMIPS32Mflo::emit(const Cfg *Func) const { | 143 template <> void InstMIPS32Mflo::emit(const Cfg *Func) const { |
| 125 if (!BuildDefs::dump()) | 144 if (!BuildDefs::dump()) |
| 126 return; | 145 return; |
| 127 emitUnaryopGPRFLoHi(Opcode, this, Func); | 146 emitUnaryopGPRFLoHi(Opcode, this, Func); |
| 128 } | 147 } |
| 129 | 148 |
| 130 template <> void InstMIPS32Mfhi::emit(const Cfg *Func) const { | 149 template <> void InstMIPS32Mfhi::emit(const Cfg *Func) const { |
| 131 if (!BuildDefs::dump()) | 150 if (!BuildDefs::dump()) |
| 132 return; | 151 return; |
| 133 emitUnaryopGPRFLoHi(Opcode, this, Func); | 152 emitUnaryopGPRFLoHi(Opcode, this, Func); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 return; | 272 return; |
| 254 Ostream &Str = Func->getContext()->getStrDump(); | 273 Ostream &Str = Func->getContext()->getStrDump(); |
| 255 Str << "[MIPS32] "; | 274 Str << "[MIPS32] "; |
| 256 Inst::dump(Func); | 275 Inst::dump(Func); |
| 257 } | 276 } |
| 258 | 277 |
| 259 void OperandMIPS32Mem::emit(const Cfg *Func) const { | 278 void OperandMIPS32Mem::emit(const Cfg *Func) const { |
| 260 if (!BuildDefs::dump()) | 279 if (!BuildDefs::dump()) |
| 261 return; | 280 return; |
| 262 Ostream &Str = Func->getContext()->getStrEmit(); | 281 Ostream &Str = Func->getContext()->getStrEmit(); |
| 263 ConstantInteger32 *Offset = getOffset(); | 282 Operand *Offset = getOffset(); |
| 264 Offset->emit(Func); | 283 if (auto *CR = llvm::dyn_cast<ConstantRelocatable>(Offset)) { |
| 284 CR->emitWithoutPrefix(Func->getTarget()); |
| 285 } else |
| 286 Offset->emit(Func); |
| 265 Str << "("; | 287 Str << "("; |
| 266 getBase()->emit(Func); | 288 getBase()->emit(Func); |
| 267 Str << ")"; | 289 Str << ")"; |
| 268 } | 290 } |
| 269 | 291 |
| 270 void InstMIPS32::emitUnaryopGPR(const char *Opcode, const InstMIPS32 *Inst, | 292 void InstMIPS32::emitUnaryopGPR(const char *Opcode, const InstMIPS32 *Inst, |
| 271 const Cfg *Func) { | 293 const Cfg *Func) { |
| 272 if (!BuildDefs::dump()) | 294 if (!BuildDefs::dump()) |
| 273 return; | 295 return; |
| 274 Ostream &Str = Func->getContext()->getStrEmit(); | 296 Ostream &Str = Func->getContext()->getStrEmit(); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 } | 595 } |
| 574 | 596 |
| 575 Str << "\t"; | 597 Str << "\t"; |
| 576 getDest()->emit(Func); | 598 getDest()->emit(Func); |
| 577 Str << ", "; | 599 Str << ", "; |
| 578 getSrc(0)->emit(Func); | 600 getSrc(0)->emit(Func); |
| 579 } | 601 } |
| 580 | 602 |
| 581 } // end of namespace MIPS32 | 603 } // end of namespace MIPS32 |
| 582 } // end of namespace Ice | 604 } // end of namespace Ice |
| OLD | NEW |