| OLD | NEW |
| 1 //===- subzero/src/IceInstARM32.h - ARM32 machine instructions --*- C++ -*-===// | 1 //===- subzero/src/IceInstARM32.h - ARM32 machine 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 // This file declares the InstARM32 and OperandARM32 classes and | 10 // This file declares the InstARM32 and OperandARM32 classes and |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 class InstARM32 : public InstTarget { | 240 class InstARM32 : public InstTarget { |
| 241 InstARM32() = delete; | 241 InstARM32() = delete; |
| 242 InstARM32(const InstARM32 &) = delete; | 242 InstARM32(const InstARM32 &) = delete; |
| 243 InstARM32 &operator=(const InstARM32 &) = delete; | 243 InstARM32 &operator=(const InstARM32 &) = delete; |
| 244 | 244 |
| 245 public: | 245 public: |
| 246 enum InstKindARM32 { | 246 enum InstKindARM32 { |
| 247 k__Start = Inst::Target, | 247 k__Start = Inst::Target, |
| 248 Adc, |
| 249 Add, |
| 250 And, |
| 251 Ldr, |
| 248 Mov, | 252 Mov, |
| 249 Movt, | 253 Movt, |
| 250 Movw, | 254 Movw, |
| 251 Mvn, | 255 Mvn, |
| 252 Ret, | 256 Ret, |
| 253 Ldr | 257 Rsb, |
| 258 Rsc, |
| 259 Sbc, |
| 260 Sub |
| 254 }; | 261 }; |
| 255 | 262 |
| 256 static const char *getWidthString(Type Ty); | 263 static const char *getWidthString(Type Ty); |
| 257 | 264 |
| 258 void dump(const Cfg *Func) const override; | 265 void dump(const Cfg *Func) const override; |
| 259 | 266 |
| 260 protected: | 267 protected: |
| 261 InstARM32(Cfg *Func, InstKindARM32 Kind, SizeT Maxsrcs, Variable *Dest) | 268 InstARM32(Cfg *Func, InstKindARM32 Kind, SizeT Maxsrcs, Variable *Dest) |
| 262 : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} | 269 : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} |
| 263 ~InstARM32() override {} | 270 ~InstARM32() override {} |
| 264 static bool isClassof(const Inst *Inst, InstKindARM32 MyKind) { | 271 static bool isClassof(const Inst *Inst, InstKindARM32 MyKind) { |
| 265 return Inst->getKind() == static_cast<InstKind>(MyKind); | 272 return Inst->getKind() == static_cast<InstKind>(MyKind); |
| 266 } | 273 } |
| 267 }; | 274 }; |
| 268 | 275 |
| 269 void emitTwoAddr(const char *Opcode, const Inst *Inst, const Cfg *Func); | 276 void emitTwoAddr(const char *Opcode, const Inst *Inst, const Cfg *Func); |
| 277 void emitBinop(const char *Opcode, const Inst *Inst, const Cfg *Func); |
| 270 | 278 |
| 271 // TODO(jvoung): add condition codes if instruction can be predicated. | 279 // TODO(jvoung): add condition codes if instruction can be predicated. |
| 272 | 280 |
| 273 // Instructions of the form x := op(y). | 281 // Instructions of the form x := op(y). |
| 274 template <InstARM32::InstKindARM32 K> | 282 template <InstARM32::InstKindARM32 K> |
| 275 class InstARM32UnaryopGPR : public InstARM32 { | 283 class InstARM32UnaryopGPR : public InstARM32 { |
| 276 InstARM32UnaryopGPR() = delete; | 284 InstARM32UnaryopGPR() = delete; |
| 277 InstARM32UnaryopGPR(const InstARM32UnaryopGPR &) = delete; | 285 InstARM32UnaryopGPR(const InstARM32UnaryopGPR &) = delete; |
| 278 InstARM32UnaryopGPR &operator=(const InstARM32UnaryopGPR &) = delete; | 286 InstARM32UnaryopGPR &operator=(const InstARM32UnaryopGPR &) = delete; |
| 279 | 287 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 private: | 398 private: |
| 391 InstARM32Movlike(Cfg *Func, Variable *Dest, Operand *Source) | 399 InstARM32Movlike(Cfg *Func, Variable *Dest, Operand *Source) |
| 392 : InstARM32(Func, K, 1, Dest) { | 400 : InstARM32(Func, K, 1, Dest) { |
| 393 addSource(Source); | 401 addSource(Source); |
| 394 } | 402 } |
| 395 ~InstARM32Movlike() override {} | 403 ~InstARM32Movlike() override {} |
| 396 | 404 |
| 397 static const char *Opcode; | 405 static const char *Opcode; |
| 398 }; | 406 }; |
| 399 | 407 |
| 408 // Instructions of the form x := y op z. |
| 409 template <InstARM32::InstKindARM32 K> |
| 410 class InstARM32BinopGPR : public InstARM32 { |
| 411 InstARM32BinopGPR() = delete; |
| 412 InstARM32BinopGPR(const InstARM32BinopGPR &) = delete; |
| 413 InstARM32BinopGPR &operator=(const InstARM32BinopGPR &) = delete; |
| 414 |
| 415 public: |
| 416 // Create an ordinary binary-op instruction like add, sub, or rsb. |
| 417 // Dest and Src1 must be registers. |
| 418 static InstARM32BinopGPR *create(Cfg *Func, Variable *Dest, Variable *Src1, |
| 419 Operand *Src2) { |
| 420 return new (Func->allocate<InstARM32BinopGPR>()) |
| 421 InstARM32BinopGPR(Func, Dest, Src1, Src2); |
| 422 } |
| 423 void emit(const Cfg *Func) const override { |
| 424 if (!ALLOW_DUMP) |
| 425 return; |
| 426 emitBinop(Opcode, this, Func); |
| 427 } |
| 428 void emitIAS(const Cfg *Func) const override { |
| 429 (void)Func; |
| 430 llvm::report_fatal_error("Not yet implemented"); |
| 431 } |
| 432 void dump(const Cfg *Func) const override { |
| 433 if (!ALLOW_DUMP) |
| 434 return; |
| 435 Ostream &Str = Func->getContext()->getStrDump(); |
| 436 dumpDest(Func); |
| 437 Str << " = " << Opcode << "." << getDest()->getType() << " "; |
| 438 dumpSources(Func); |
| 439 } |
| 440 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 441 |
| 442 private: |
| 443 InstARM32BinopGPR(Cfg *Func, Variable *Dest, Variable *Src1, Operand *Src2) |
| 444 : InstARM32(Func, K, 2, Dest) { |
| 445 addSource(Src1); |
| 446 addSource(Src2); |
| 447 } |
| 448 ~InstARM32BinopGPR() override {} |
| 449 static const char *Opcode; |
| 450 }; |
| 451 |
| 452 typedef InstARM32BinopGPR<InstARM32::Adc> InstARM32Adc; |
| 453 typedef InstARM32BinopGPR<InstARM32::Add> InstARM32Add; |
| 454 typedef InstARM32BinopGPR<InstARM32::And> InstARM32And; |
| 455 typedef InstARM32BinopGPR<InstARM32::Rsb> InstARM32Rsb; |
| 456 typedef InstARM32BinopGPR<InstARM32::Rsc> InstARM32Rsc; |
| 457 typedef InstARM32BinopGPR<InstARM32::Sbc> InstARM32Sbc; |
| 458 typedef InstARM32BinopGPR<InstARM32::Sub> InstARM32Sub; |
| 400 // Move instruction (variable <- flex). This is more of a pseudo-inst. | 459 // Move instruction (variable <- flex). This is more of a pseudo-inst. |
| 401 // If var is a register, then we use "mov". If var is stack, then we use | 460 // If var is a register, then we use "mov". If var is stack, then we use |
| 402 // "str" to store to the stack. | 461 // "str" to store to the stack. |
| 403 typedef InstARM32Movlike<InstARM32::Mov> InstARM32Mov; | 462 typedef InstARM32Movlike<InstARM32::Mov> InstARM32Mov; |
| 404 // MovT leaves the bottom bits alone so dest is also a source. | 463 // MovT leaves the bottom bits alone so dest is also a source. |
| 405 // This helps indicate that a previous MovW setting dest is not dead code. | 464 // This helps indicate that a previous MovW setting dest is not dead code. |
| 406 typedef InstARM32TwoAddrGPR<InstARM32::Movt> InstARM32Movt; | 465 typedef InstARM32TwoAddrGPR<InstARM32::Movt> InstARM32Movt; |
| 407 typedef InstARM32UnaryopGPR<InstARM32::Movw> InstARM32Movw; | 466 typedef InstARM32UnaryopGPR<InstARM32::Movw> InstARM32Movw; |
| 408 typedef InstARM32UnaryopGPR<InstARM32::Mvn> InstARM32Mvn; | 467 typedef InstARM32UnaryopGPR<InstARM32::Mvn> InstARM32Mvn; |
| 409 | 468 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 // Declare partial template specializations of emit() methods that | 515 // Declare partial template specializations of emit() methods that |
| 457 // already have default implementations. Without this, there is the | 516 // already have default implementations. Without this, there is the |
| 458 // possibility of ODR violations and link errors. | 517 // possibility of ODR violations and link errors. |
| 459 | 518 |
| 460 template <> void InstARM32Movw::emit(const Cfg *Func) const; | 519 template <> void InstARM32Movw::emit(const Cfg *Func) const; |
| 461 template <> void InstARM32Movt::emit(const Cfg *Func) const; | 520 template <> void InstARM32Movt::emit(const Cfg *Func) const; |
| 462 | 521 |
| 463 } // end of namespace Ice | 522 } // end of namespace Ice |
| 464 | 523 |
| 465 #endif // SUBZERO_SRC_ICEINSTARM32_H | 524 #endif // SUBZERO_SRC_ICEINSTARM32_H |
| OLD | NEW |