| OLD | NEW |
| 1 //===- subzero/src/IceInstARM32.cpp - ARM32 instruction implementation ----===// | 1 //===- subzero/src/IceInstARM32.cpp - ARM32 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 InstARM32 and OperandARM32 classes, | 10 // This file implements the InstARM32 and OperandARM32 classes, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 assert(Inst->getSrcSize() == 2); | 60 assert(Inst->getSrcSize() == 2); |
| 61 Variable *Dest = Inst->getDest(); | 61 Variable *Dest = Inst->getDest(); |
| 62 assert(Dest == Inst->getSrc(0)); | 62 assert(Dest == Inst->getSrc(0)); |
| 63 Operand *Src1 = Inst->getSrc(1); | 63 Operand *Src1 = Inst->getSrc(1); |
| 64 Str << "\t" << Opcode << "\t"; | 64 Str << "\t" << Opcode << "\t"; |
| 65 Dest->emit(Func); | 65 Dest->emit(Func); |
| 66 Str << ", "; | 66 Str << ", "; |
| 67 Src1->emit(Func); | 67 Src1->emit(Func); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void emitBinop(const char *Opcode, const Inst *Inst, const Cfg *Func) { |
| 71 if (!ALLOW_DUMP) |
| 72 return; |
| 73 Ostream &Str = Func->getContext()->getStrEmit(); |
| 74 assert(Inst->getSrcSize() == 2); |
| 75 Variable *Dest = Inst->getDest(); |
| 76 Operand *Src0 = Inst->getSrc(0); |
| 77 Operand *Src1 = Inst->getSrc(1); |
| 78 Str << "\t" << Opcode << "\t"; |
| 79 Dest->emit(Func); |
| 80 Str << ", "; |
| 81 Src0->emit(Func); |
| 82 Str << ", "; |
| 83 Src1->emit(Func); |
| 84 } |
| 85 |
| 70 OperandARM32Mem::OperandARM32Mem(Cfg * /* Func */, Type Ty, Variable *Base, | 86 OperandARM32Mem::OperandARM32Mem(Cfg * /* Func */, Type Ty, Variable *Base, |
| 71 ConstantInteger32 *ImmOffset, AddrMode Mode) | 87 ConstantInteger32 *ImmOffset, AddrMode Mode) |
| 72 : OperandARM32(kMem, Ty), Base(Base), ImmOffset(ImmOffset), Index(nullptr), | 88 : OperandARM32(kMem, Ty), Base(Base), ImmOffset(ImmOffset), Index(nullptr), |
| 73 ShiftOp(kNoShift), ShiftAmt(0), Mode(Mode) { | 89 ShiftOp(kNoShift), ShiftAmt(0), Mode(Mode) { |
| 74 // The Neg modes are only needed for Reg +/- Reg. | 90 // The Neg modes are only needed for Reg +/- Reg. |
| 75 assert(!isNegAddrMode()); | 91 assert(!isNegAddrMode()); |
| 76 NumVars = 1; | 92 NumVars = 1; |
| 77 Vars = &this->Base; | 93 Vars = &this->Base; |
| 78 } | 94 } |
| 79 | 95 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 171 |
| 156 // ======================== Dump routines ======================== // | 172 // ======================== Dump routines ======================== // |
| 157 | 173 |
| 158 // Two-addr ops | 174 // Two-addr ops |
| 159 template <> const char *InstARM32Movt::Opcode = "movt"; | 175 template <> const char *InstARM32Movt::Opcode = "movt"; |
| 160 // Unary ops | 176 // Unary ops |
| 161 template <> const char *InstARM32Movw::Opcode = "movw"; | 177 template <> const char *InstARM32Movw::Opcode = "movw"; |
| 162 template <> const char *InstARM32Mvn::Opcode = "mvn"; | 178 template <> const char *InstARM32Mvn::Opcode = "mvn"; |
| 163 // Mov-like ops | 179 // Mov-like ops |
| 164 template <> const char *InstARM32Mov::Opcode = "mov"; | 180 template <> const char *InstARM32Mov::Opcode = "mov"; |
| 181 // Binary ops |
| 182 template <> const char *InstARM32Adc::Opcode = "adc"; |
| 183 template <> const char *InstARM32Add::Opcode = "add"; |
| 184 template <> const char *InstARM32And::Opcode = "and"; |
| 185 template <> const char *InstARM32Rsb::Opcode = "rsb"; |
| 186 template <> const char *InstARM32Rsc::Opcode = "rsc"; |
| 187 template <> const char *InstARM32Sbc::Opcode = "sbc"; |
| 188 template <> const char *InstARM32Sub::Opcode = "sub"; |
| 165 | 189 |
| 166 void InstARM32::dump(const Cfg *Func) const { | 190 void InstARM32::dump(const Cfg *Func) const { |
| 167 if (!ALLOW_DUMP) | 191 if (!ALLOW_DUMP) |
| 168 return; | 192 return; |
| 169 Ostream &Str = Func->getContext()->getStrDump(); | 193 Ostream &Str = Func->getContext()->getStrDump(); |
| 170 Str << "[ARM32] "; | 194 Str << "[ARM32] "; |
| 171 Inst::dump(Func); | 195 Inst::dump(Func); |
| 172 } | 196 } |
| 173 | 197 |
| 174 template <> void InstARM32Mov::emit(const Cfg *Func) const { | 198 template <> void InstARM32Mov::emit(const Cfg *Func) const { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } | 291 } |
| 268 | 292 |
| 269 void InstARM32Ret::emit(const Cfg *Func) const { | 293 void InstARM32Ret::emit(const Cfg *Func) const { |
| 270 if (!ALLOW_DUMP) | 294 if (!ALLOW_DUMP) |
| 271 return; | 295 return; |
| 272 assert(getSrcSize() > 0); | 296 assert(getSrcSize() > 0); |
| 273 Variable *LR = llvm::cast<Variable>(getSrc(0)); | 297 Variable *LR = llvm::cast<Variable>(getSrc(0)); |
| 274 assert(LR->hasReg()); | 298 assert(LR->hasReg()); |
| 275 assert(LR->getRegNum() == RegARM32::Reg_lr); | 299 assert(LR->getRegNum() == RegARM32::Reg_lr); |
| 276 Ostream &Str = Func->getContext()->getStrEmit(); | 300 Ostream &Str = Func->getContext()->getStrEmit(); |
| 277 Str << "\tbx\t"; | 301 Str << "\t" << "bx" << "\t"; |
| 278 LR->emit(Func); | 302 LR->emit(Func); |
| 279 } | 303 } |
| 280 | 304 |
| 281 void InstARM32Ret::emitIAS(const Cfg *Func) const { | 305 void InstARM32Ret::emitIAS(const Cfg *Func) const { |
| 282 (void)Func; | 306 (void)Func; |
| 283 llvm_unreachable("Not yet implemented"); | 307 llvm_unreachable("Not yet implemented"); |
| 284 } | 308 } |
| 285 | 309 |
| 286 void InstARM32Ret::dump(const Cfg *Func) const { | 310 void InstARM32Ret::dump(const Cfg *Func) const { |
| 287 if (!ALLOW_DUMP) | 311 if (!ALLOW_DUMP) |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 if (getShiftOp() != kNoShift) { | 425 if (getShiftOp() != kNoShift) { |
| 402 Str << ", " << InstARM32ShiftAttributes[getShiftOp()].EmitString << " "; | 426 Str << ", " << InstARM32ShiftAttributes[getShiftOp()].EmitString << " "; |
| 403 if (Func) | 427 if (Func) |
| 404 getShiftAmt()->dump(Func); | 428 getShiftAmt()->dump(Func); |
| 405 else | 429 else |
| 406 getShiftAmt()->dump(Str); | 430 getShiftAmt()->dump(Str); |
| 407 } | 431 } |
| 408 } | 432 } |
| 409 | 433 |
| 410 } // end of namespace Ice | 434 } // end of namespace Ice |
| OLD | NEW |