| OLD | NEW |
| 1 //===- subzero/src/IceInstX8632.h - Low-level x86 instructions --*- C++ -*-===// | 1 //===- subzero/src/IceInstX8632.h - Low-level 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 // This file declares the InstX8632 and OperandX8632 classes and | 10 // This file declares the InstX8632 and OperandX8632 classes and |
| 11 // their subclasses. This represents the machine instructions and | 11 // their subclasses. This represents the machine instructions and |
| 12 // operands used for x86-32 code selection. | 12 // operands used for x86-32 code selection. |
| 13 // | 13 // |
| 14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
| 15 | 15 |
| 16 #ifndef SUBZERO_SRC_ICEINSTX8632_H | 16 #ifndef SUBZERO_SRC_ICEINSTX8632_H |
| 17 #define SUBZERO_SRC_ICEINSTX8632_H | 17 #define SUBZERO_SRC_ICEINSTX8632_H |
| 18 | 18 |
| 19 #include "assembler_ia32.h" |
| 19 #include "IceDefs.h" | 20 #include "IceDefs.h" |
| 20 #include "IceInst.h" | 21 #include "IceInst.h" |
| 21 #include "IceInstX8632.def" | 22 #include "IceInstX8632.def" |
| 22 #include "IceOperand.h" | 23 #include "IceOperand.h" |
| 23 | 24 |
| 24 namespace Ice { | 25 namespace Ice { |
| 25 | 26 |
| 26 class TargetX8632; | 27 class TargetX8632; |
| 27 | 28 |
| 28 // OperandX8632 extends the Operand hierarchy. Its subclasses are | 29 // OperandX8632 extends the Operand hierarchy. Its subclasses are |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 uint16_t Shift = 0, | 65 uint16_t Shift = 0, |
| 65 SegmentRegisters SegmentReg = DefaultSegment) { | 66 SegmentRegisters SegmentReg = DefaultSegment) { |
| 66 return new (Func->allocate<OperandX8632Mem>()) | 67 return new (Func->allocate<OperandX8632Mem>()) |
| 67 OperandX8632Mem(Func, Ty, Base, Offset, Index, Shift, SegmentReg); | 68 OperandX8632Mem(Func, Ty, Base, Offset, Index, Shift, SegmentReg); |
| 68 } | 69 } |
| 69 Variable *getBase() const { return Base; } | 70 Variable *getBase() const { return Base; } |
| 70 Constant *getOffset() const { return Offset; } | 71 Constant *getOffset() const { return Offset; } |
| 71 Variable *getIndex() const { return Index; } | 72 Variable *getIndex() const { return Index; } |
| 72 uint16_t getShift() const { return Shift; } | 73 uint16_t getShift() const { return Shift; } |
| 73 SegmentRegisters getSegmentRegister() const { return SegmentReg; } | 74 SegmentRegisters getSegmentRegister() const { return SegmentReg; } |
| 75 x86::Address convertToAsmAddress(Assembler *Asm) const; |
| 74 virtual void emit(const Cfg *Func) const; | 76 virtual void emit(const Cfg *Func) const; |
| 75 virtual void dump(const Cfg *Func) const; | 77 virtual void dump(const Cfg *Func) const; |
| 76 | 78 |
| 77 static bool classof(const Operand *Operand) { | 79 static bool classof(const Operand *Operand) { |
| 78 return Operand->getKind() == static_cast<OperandKind>(kMem); | 80 return Operand->getKind() == static_cast<OperandKind>(kMem); |
| 79 } | 81 } |
| 80 | 82 |
| 81 private: | 83 private: |
| 82 OperandX8632Mem(Cfg *Func, Type Ty, Variable *Base, Constant *Offset, | 84 OperandX8632Mem(Cfg *Func, Type Ty, Variable *Base, Constant *Offset, |
| 83 Variable *Index, uint16_t Shift, SegmentRegisters SegmentReg); | 85 Variable *Index, uint16_t Shift, SegmentRegisters SegmentReg); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 223 |
| 222 enum BrCond { | 224 enum BrCond { |
| 223 #define X(tag, dump, emit) tag, | 225 #define X(tag, dump, emit) tag, |
| 224 ICEINSTX8632BR_TABLE | 226 ICEINSTX8632BR_TABLE |
| 225 #undef X | 227 #undef X |
| 226 Br_None | 228 Br_None |
| 227 }; | 229 }; |
| 228 | 230 |
| 229 static const char *getWidthString(Type Ty); | 231 static const char *getWidthString(Type Ty); |
| 230 virtual void emit(const Cfg *Func) const = 0; | 232 virtual void emit(const Cfg *Func) const = 0; |
| 233 virtual void emitIAS(const Cfg *Func) const; |
| 231 virtual void dump(const Cfg *Func) const; | 234 virtual void dump(const Cfg *Func) const; |
| 232 | 235 |
| 233 protected: | 236 protected: |
| 234 InstX8632(Cfg *Func, InstKindX8632 Kind, SizeT Maxsrcs, Variable *Dest) | 237 InstX8632(Cfg *Func, InstKindX8632 Kind, SizeT Maxsrcs, Variable *Dest) |
| 235 : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} | 238 : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} |
| 236 virtual ~InstX8632() {} | 239 virtual ~InstX8632() {} |
| 237 static bool isClassof(const Inst *Inst, InstKindX8632 MyKind) { | 240 static bool isClassof(const Inst *Inst, InstKindX8632 MyKind) { |
| 238 return Inst->getKind() == static_cast<InstKind>(MyKind); | 241 return Inst->getKind() == static_cast<InstKind>(MyKind); |
| 239 } | 242 } |
| 240 | 243 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 348 |
| 346 // AdjustStack instruction - subtracts esp by the given amount and | 349 // AdjustStack instruction - subtracts esp by the given amount and |
| 347 // updates the stack offset during code emission. | 350 // updates the stack offset during code emission. |
| 348 class InstX8632AdjustStack : public InstX8632 { | 351 class InstX8632AdjustStack : public InstX8632 { |
| 349 public: | 352 public: |
| 350 static InstX8632AdjustStack *create(Cfg *Func, SizeT Amount) { | 353 static InstX8632AdjustStack *create(Cfg *Func, SizeT Amount) { |
| 351 return new (Func->allocate<InstX8632AdjustStack>()) | 354 return new (Func->allocate<InstX8632AdjustStack>()) |
| 352 InstX8632AdjustStack(Func, Amount); | 355 InstX8632AdjustStack(Func, Amount); |
| 353 } | 356 } |
| 354 virtual void emit(const Cfg *Func) const; | 357 virtual void emit(const Cfg *Func) const; |
| 358 virtual void emitIAS(const Cfg *Func) const; |
| 355 virtual void dump(const Cfg *Func) const; | 359 virtual void dump(const Cfg *Func) const; |
| 356 static bool classof(const Inst *Inst) { return isClassof(Inst, Adjuststack); } | 360 static bool classof(const Inst *Inst) { return isClassof(Inst, Adjuststack); } |
| 357 | 361 |
| 358 private: | 362 private: |
| 359 InstX8632AdjustStack(Cfg *Func, SizeT Amount); | 363 InstX8632AdjustStack(Cfg *Func, SizeT Amount); |
| 360 InstX8632AdjustStack(const InstX8632AdjustStack &) LLVM_DELETED_FUNCTION; | 364 InstX8632AdjustStack(const InstX8632AdjustStack &) LLVM_DELETED_FUNCTION; |
| 361 InstX8632AdjustStack &operator=(const InstX8632AdjustStack &) | 365 InstX8632AdjustStack &operator=(const InstX8632AdjustStack &) |
| 362 LLVM_DELETED_FUNCTION; | 366 LLVM_DELETED_FUNCTION; |
| 363 SizeT Amount; | 367 SizeT Amount; |
| 364 }; | 368 }; |
| 365 | 369 |
| 366 // Call instruction. Arguments should have already been pushed. | 370 // Call instruction. Arguments should have already been pushed. |
| 367 class InstX8632Call : public InstX8632 { | 371 class InstX8632Call : public InstX8632 { |
| 368 public: | 372 public: |
| 369 static InstX8632Call *create(Cfg *Func, Variable *Dest, Operand *CallTarget) { | 373 static InstX8632Call *create(Cfg *Func, Variable *Dest, Operand *CallTarget) { |
| 370 return new (Func->allocate<InstX8632Call>()) | 374 return new (Func->allocate<InstX8632Call>()) |
| 371 InstX8632Call(Func, Dest, CallTarget); | 375 InstX8632Call(Func, Dest, CallTarget); |
| 372 } | 376 } |
| 373 Operand *getCallTarget() const { return getSrc(0); } | 377 Operand *getCallTarget() const { return getSrc(0); } |
| 374 virtual void emit(const Cfg *Func) const; | 378 virtual void emit(const Cfg *Func) const; |
| 379 virtual void emitIAS(const Cfg *Func) const; |
| 375 virtual void dump(const Cfg *Func) const; | 380 virtual void dump(const Cfg *Func) const; |
| 376 static bool classof(const Inst *Inst) { return isClassof(Inst, Call); } | 381 static bool classof(const Inst *Inst) { return isClassof(Inst, Call); } |
| 377 | 382 |
| 378 private: | 383 private: |
| 379 InstX8632Call(Cfg *Func, Variable *Dest, Operand *CallTarget); | 384 InstX8632Call(Cfg *Func, Variable *Dest, Operand *CallTarget); |
| 380 InstX8632Call(const InstX8632Call &) LLVM_DELETED_FUNCTION; | 385 InstX8632Call(const InstX8632Call &) LLVM_DELETED_FUNCTION; |
| 381 InstX8632Call &operator=(const InstX8632Call &) LLVM_DELETED_FUNCTION; | 386 InstX8632Call &operator=(const InstX8632Call &) LLVM_DELETED_FUNCTION; |
| 382 virtual ~InstX8632Call() {} | 387 virtual ~InstX8632Call() {} |
| 383 }; | 388 }; |
| 384 | 389 |
| 385 // Instructions of the form x := op(x). | 390 // Instructions of the form x := op(x). |
| 386 template <InstX8632::InstKindX8632 K> | 391 template <InstX8632::InstKindX8632 K> |
| 387 class InstX8632Inplaceop : public InstX8632 { | 392 class InstX8632Inplaceop : public InstX8632 { |
| 388 public: | 393 public: |
| 389 static InstX8632Inplaceop *create(Cfg *Func, Operand *SrcDest) { | 394 static InstX8632Inplaceop *create(Cfg *Func, Operand *SrcDest) { |
| 390 return new (Func->allocate<InstX8632Inplaceop>()) | 395 return new (Func->allocate<InstX8632Inplaceop>()) |
| 391 InstX8632Inplaceop(Func, SrcDest); | 396 InstX8632Inplaceop(Func, SrcDest); |
| 392 } | 397 } |
| 393 virtual void emit(const Cfg *Func) const { | 398 virtual void emit(const Cfg *Func) const { |
| 394 Ostream &Str = Func->getContext()->getStrEmit(); | 399 Ostream &Str = Func->getContext()->getStrEmit(); |
| 395 assert(getSrcSize() == 1); | 400 assert(getSrcSize() == 1); |
| 396 Str << "\t" << Opcode << "\t"; | 401 Str << "\t" << Opcode << "\t"; |
| 397 getSrc(0)->emit(Func); | 402 getSrc(0)->emit(Func); |
| 398 Str << "\n"; | 403 Str << "\n"; |
| 399 } | 404 } |
| 405 virtual void emitIAS(const Cfg *Func) const { emit(Func); } |
| 400 virtual void dump(const Cfg *Func) const { | 406 virtual void dump(const Cfg *Func) const { |
| 401 Ostream &Str = Func->getContext()->getStrDump(); | 407 Ostream &Str = Func->getContext()->getStrDump(); |
| 402 dumpDest(Func); | 408 dumpDest(Func); |
| 403 Str << " = " << Opcode << "." << getDest()->getType() << " "; | 409 Str << " = " << Opcode << "." << getDest()->getType() << " "; |
| 404 dumpSources(Func); | 410 dumpSources(Func); |
| 405 } | 411 } |
| 406 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } | 412 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 407 | 413 |
| 408 private: | 414 private: |
| 409 InstX8632Inplaceop(Cfg *Func, Operand *SrcDest) | 415 InstX8632Inplaceop(Cfg *Func, Operand *SrcDest) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 427 } | 433 } |
| 428 virtual void emit(const Cfg *Func) const { | 434 virtual void emit(const Cfg *Func) const { |
| 429 Ostream &Str = Func->getContext()->getStrEmit(); | 435 Ostream &Str = Func->getContext()->getStrEmit(); |
| 430 assert(getSrcSize() == 1); | 436 assert(getSrcSize() == 1); |
| 431 Str << "\t" << Opcode << "\t"; | 437 Str << "\t" << Opcode << "\t"; |
| 432 getDest()->emit(Func); | 438 getDest()->emit(Func); |
| 433 Str << ", "; | 439 Str << ", "; |
| 434 getSrc(0)->emit(Func); | 440 getSrc(0)->emit(Func); |
| 435 Str << "\n"; | 441 Str << "\n"; |
| 436 } | 442 } |
| 443 virtual void emitIAS(const Cfg *Func) const { emit(Func); } |
| 437 virtual void dump(const Cfg *Func) const { | 444 virtual void dump(const Cfg *Func) const { |
| 438 Ostream &Str = Func->getContext()->getStrDump(); | 445 Ostream &Str = Func->getContext()->getStrDump(); |
| 439 dumpDest(Func); | 446 dumpDest(Func); |
| 440 Str << " = " << Opcode << "." << getDest()->getType() << " "; | 447 Str << " = " << Opcode << "." << getDest()->getType() << " "; |
| 441 dumpSources(Func); | 448 dumpSources(Func); |
| 442 } | 449 } |
| 443 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } | 450 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 444 | 451 |
| 445 private: | 452 private: |
| 446 InstX8632Unaryop(Cfg *Func, Variable *Dest, Operand *Src) | 453 InstX8632Unaryop(Cfg *Func, Variable *Dest, Operand *Src) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 462 class InstX8632Binop : public InstX8632 { | 469 class InstX8632Binop : public InstX8632 { |
| 463 public: | 470 public: |
| 464 // Create an ordinary binary-op instruction like add or sub. | 471 // Create an ordinary binary-op instruction like add or sub. |
| 465 static InstX8632Binop *create(Cfg *Func, Variable *Dest, Operand *Source) { | 472 static InstX8632Binop *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| 466 return new (Func->allocate<InstX8632Binop>()) | 473 return new (Func->allocate<InstX8632Binop>()) |
| 467 InstX8632Binop(Func, Dest, Source); | 474 InstX8632Binop(Func, Dest, Source); |
| 468 } | 475 } |
| 469 virtual void emit(const Cfg *Func) const { | 476 virtual void emit(const Cfg *Func) const { |
| 470 emitTwoAddress(Opcode, this, Func, ShiftHack); | 477 emitTwoAddress(Opcode, this, Func, ShiftHack); |
| 471 } | 478 } |
| 479 virtual void emitIAS(const Cfg *Func) const { emit(Func); } |
| 472 virtual void dump(const Cfg *Func) const { | 480 virtual void dump(const Cfg *Func) const { |
| 473 Ostream &Str = Func->getContext()->getStrDump(); | 481 Ostream &Str = Func->getContext()->getStrDump(); |
| 474 dumpDest(Func); | 482 dumpDest(Func); |
| 475 Str << " = " << Opcode << "." << getDest()->getType() << " "; | 483 Str << " = " << Opcode << "." << getDest()->getType() << " "; |
| 476 dumpSources(Func); | 484 dumpSources(Func); |
| 477 } | 485 } |
| 478 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } | 486 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 479 | 487 |
| 480 private: | 488 private: |
| 481 InstX8632Binop(Cfg *Func, Variable *Dest, Operand *Source) | 489 InstX8632Binop(Cfg *Func, Variable *Dest, Operand *Source) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 501 Ostream &Str = Func->getContext()->getStrEmit(); | 509 Ostream &Str = Func->getContext()->getStrEmit(); |
| 502 assert(getSrcSize() == 3); | 510 assert(getSrcSize() == 3); |
| 503 Str << "\t" << Opcode << "\t"; | 511 Str << "\t" << Opcode << "\t"; |
| 504 getDest()->emit(Func); | 512 getDest()->emit(Func); |
| 505 Str << ", "; | 513 Str << ", "; |
| 506 getSrc(1)->emit(Func); | 514 getSrc(1)->emit(Func); |
| 507 Str << ", "; | 515 Str << ", "; |
| 508 getSrc(2)->emit(Func); | 516 getSrc(2)->emit(Func); |
| 509 Str << "\n"; | 517 Str << "\n"; |
| 510 } | 518 } |
| 519 virtual void emitIAS(const Cfg *Func) const { emit(Func); } |
| 511 virtual void dump(const Cfg *Func) const { | 520 virtual void dump(const Cfg *Func) const { |
| 512 Ostream &Str = Func->getContext()->getStrDump(); | 521 Ostream &Str = Func->getContext()->getStrDump(); |
| 513 dumpDest(Func); | 522 dumpDest(Func); |
| 514 Str << " = " << Opcode << "." << getDest()->getType() << " "; | 523 Str << " = " << Opcode << "." << getDest()->getType() << " "; |
| 515 dumpSources(Func); | 524 dumpSources(Func); |
| 516 } | 525 } |
| 517 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } | 526 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 518 | 527 |
| 519 private: | 528 private: |
| 520 InstX8632Ternop(Cfg *Func, Variable *Dest, Operand *Source1, Operand *Source2) | 529 InstX8632Ternop(Cfg *Func, Variable *Dest, Operand *Source1, Operand *Source2) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 542 Ostream &Str = Func->getContext()->getStrEmit(); | 551 Ostream &Str = Func->getContext()->getStrEmit(); |
| 543 assert(getSrcSize() == 2); | 552 assert(getSrcSize() == 2); |
| 544 Str << "\t" << Opcode << "\t"; | 553 Str << "\t" << Opcode << "\t"; |
| 545 getDest()->emit(Func); | 554 getDest()->emit(Func); |
| 546 Str << ", "; | 555 Str << ", "; |
| 547 getSrc(0)->emit(Func); | 556 getSrc(0)->emit(Func); |
| 548 Str << ", "; | 557 Str << ", "; |
| 549 getSrc(1)->emit(Func); | 558 getSrc(1)->emit(Func); |
| 550 Str << "\n"; | 559 Str << "\n"; |
| 551 } | 560 } |
| 561 virtual void emitIAS(const Cfg *Func) const { emit(Func); } |
| 552 virtual void dump(const Cfg *Func) const { | 562 virtual void dump(const Cfg *Func) const { |
| 553 Ostream &Str = Func->getContext()->getStrDump(); | 563 Ostream &Str = Func->getContext()->getStrDump(); |
| 554 dumpDest(Func); | 564 dumpDest(Func); |
| 555 Str << " = " << Opcode << "." << getDest()->getType() << " "; | 565 Str << " = " << Opcode << "." << getDest()->getType() << " "; |
| 556 dumpSources(Func); | 566 dumpSources(Func); |
| 557 } | 567 } |
| 558 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } | 568 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 559 | 569 |
| 560 private: | 570 private: |
| 561 InstX8632ThreeAddressop(Cfg *Func, Variable *Dest, Operand *Source0, | 571 InstX8632ThreeAddressop(Cfg *Func, Variable *Dest, Operand *Source0, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 579 class InstX8632Movlike : public InstX8632 { | 589 class InstX8632Movlike : public InstX8632 { |
| 580 public: | 590 public: |
| 581 static InstX8632Movlike *create(Cfg *Func, Variable *Dest, Operand *Source) { | 591 static InstX8632Movlike *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| 582 return new (Func->allocate<InstX8632Movlike>()) | 592 return new (Func->allocate<InstX8632Movlike>()) |
| 583 InstX8632Movlike(Func, Dest, Source); | 593 InstX8632Movlike(Func, Dest, Source); |
| 584 } | 594 } |
| 585 virtual bool isRedundantAssign() const { | 595 virtual bool isRedundantAssign() const { |
| 586 return checkForRedundantAssign(getDest(), getSrc(0)); | 596 return checkForRedundantAssign(getDest(), getSrc(0)); |
| 587 } | 597 } |
| 588 virtual void emit(const Cfg *Func) const; | 598 virtual void emit(const Cfg *Func) const; |
| 599 virtual void emitIAS(const Cfg *Func) const { emit(Func); } |
| 589 virtual void dump(const Cfg *Func) const { | 600 virtual void dump(const Cfg *Func) const { |
| 590 Ostream &Str = Func->getContext()->getStrDump(); | 601 Ostream &Str = Func->getContext()->getStrDump(); |
| 591 Str << Opcode << "." << getDest()->getType() << " "; | 602 Str << Opcode << "." << getDest()->getType() << " "; |
| 592 dumpDest(Func); | 603 dumpDest(Func); |
| 593 Str << ", "; | 604 Str << ", "; |
| 594 dumpSources(Func); | 605 dumpSources(Func); |
| 595 } | 606 } |
| 596 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } | 607 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 597 | 608 |
| 598 private: | 609 private: |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 | 765 |
| 755 // Conditional move instruction. | 766 // Conditional move instruction. |
| 756 class InstX8632Cmov : public InstX8632 { | 767 class InstX8632Cmov : public InstX8632 { |
| 757 public: | 768 public: |
| 758 static InstX8632Cmov *create(Cfg *Func, Variable *Dest, Operand *Source, | 769 static InstX8632Cmov *create(Cfg *Func, Variable *Dest, Operand *Source, |
| 759 BrCond Cond) { | 770 BrCond Cond) { |
| 760 return new (Func->allocate<InstX8632Cmov>()) | 771 return new (Func->allocate<InstX8632Cmov>()) |
| 761 InstX8632Cmov(Func, Dest, Source, Cond); | 772 InstX8632Cmov(Func, Dest, Source, Cond); |
| 762 } | 773 } |
| 763 virtual void emit(const Cfg *Func) const; | 774 virtual void emit(const Cfg *Func) const; |
| 775 virtual void emitIAS(const Cfg *Func) const; |
| 764 virtual void dump(const Cfg *Func) const; | 776 virtual void dump(const Cfg *Func) const; |
| 765 static bool classof(const Inst *Inst) { return isClassof(Inst, Cmov); } | 777 static bool classof(const Inst *Inst) { return isClassof(Inst, Cmov); } |
| 766 | 778 |
| 767 private: | 779 private: |
| 768 InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source, BrCond Cond); | 780 InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source, BrCond Cond); |
| 769 InstX8632Cmov(const InstX8632Cmov &) LLVM_DELETED_FUNCTION; | 781 InstX8632Cmov(const InstX8632Cmov &) LLVM_DELETED_FUNCTION; |
| 770 InstX8632Cmov &operator=(const InstX8632Cmov &) LLVM_DELETED_FUNCTION; | 782 InstX8632Cmov &operator=(const InstX8632Cmov &) LLVM_DELETED_FUNCTION; |
| 771 virtual ~InstX8632Cmov() {} | 783 virtual ~InstX8632Cmov() {} |
| 772 | 784 |
| 773 BrCond Condition; | 785 BrCond Condition; |
| 774 }; | 786 }; |
| 775 | 787 |
| 776 // Cmpps instruction - compare packed singled-precision floating point | 788 // Cmpps instruction - compare packed singled-precision floating point |
| 777 // values | 789 // values |
| 778 class InstX8632Cmpps : public InstX8632 { | 790 class InstX8632Cmpps : public InstX8632 { |
| 779 public: | 791 public: |
| 780 enum CmppsCond { | 792 enum CmppsCond { |
| 781 #define X(tag, emit) tag, | 793 #define X(tag, emit) tag, |
| 782 ICEINSTX8632CMPPS_TABLE | 794 ICEINSTX8632CMPPS_TABLE |
| 783 #undef X | 795 #undef X |
| 784 Cmpps_Invalid | 796 Cmpps_Invalid |
| 785 }; | 797 }; |
| 786 | 798 |
| 787 static InstX8632Cmpps *create(Cfg *Func, Variable *Dest, Operand *Source, | 799 static InstX8632Cmpps *create(Cfg *Func, Variable *Dest, Operand *Source, |
| 788 CmppsCond Condition) { | 800 CmppsCond Condition) { |
| 789 return new (Func->allocate<InstX8632Cmpps>()) | 801 return new (Func->allocate<InstX8632Cmpps>()) |
| 790 InstX8632Cmpps(Func, Dest, Source, Condition); | 802 InstX8632Cmpps(Func, Dest, Source, Condition); |
| 791 } | 803 } |
| 792 virtual void emit(const Cfg *Func) const; | 804 virtual void emit(const Cfg *Func) const; |
| 805 virtual void emitIAS(const Cfg *Func) const; |
| 793 virtual void dump(const Cfg *Func) const; | 806 virtual void dump(const Cfg *Func) const; |
| 794 static bool classof(const Inst *Inst) { return isClassof(Inst, Cmpps); } | 807 static bool classof(const Inst *Inst) { return isClassof(Inst, Cmpps); } |
| 795 | 808 |
| 796 private: | 809 private: |
| 797 InstX8632Cmpps(Cfg *Func, Variable *Dest, Operand *Source, CmppsCond Cond); | 810 InstX8632Cmpps(Cfg *Func, Variable *Dest, Operand *Source, CmppsCond Cond); |
| 798 InstX8632Cmpps(const InstX8632Cmpps &) LLVM_DELETED_FUNCTION; | 811 InstX8632Cmpps(const InstX8632Cmpps &) LLVM_DELETED_FUNCTION; |
| 799 InstX8632Cmpps &operator=(const InstX8632Cmpps &) LLVM_DELETED_FUNCTION; | 812 InstX8632Cmpps &operator=(const InstX8632Cmpps &) LLVM_DELETED_FUNCTION; |
| 800 virtual ~InstX8632Cmpps() {} | 813 virtual ~InstX8632Cmpps() {} |
| 801 | 814 |
| 802 CmppsCond Condition; | 815 CmppsCond Condition; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 }; | 890 }; |
| 878 | 891 |
| 879 // cmp - Integer compare instruction. | 892 // cmp - Integer compare instruction. |
| 880 class InstX8632Icmp : public InstX8632 { | 893 class InstX8632Icmp : public InstX8632 { |
| 881 public: | 894 public: |
| 882 static InstX8632Icmp *create(Cfg *Func, Operand *Src1, Operand *Src2) { | 895 static InstX8632Icmp *create(Cfg *Func, Operand *Src1, Operand *Src2) { |
| 883 return new (Func->allocate<InstX8632Icmp>()) | 896 return new (Func->allocate<InstX8632Icmp>()) |
| 884 InstX8632Icmp(Func, Src1, Src2); | 897 InstX8632Icmp(Func, Src1, Src2); |
| 885 } | 898 } |
| 886 virtual void emit(const Cfg *Func) const; | 899 virtual void emit(const Cfg *Func) const; |
| 900 virtual void emitIAS(const Cfg *Func) const; |
| 887 virtual void dump(const Cfg *Func) const; | 901 virtual void dump(const Cfg *Func) const; |
| 888 static bool classof(const Inst *Inst) { return isClassof(Inst, Icmp); } | 902 static bool classof(const Inst *Inst) { return isClassof(Inst, Icmp); } |
| 889 | 903 |
| 890 private: | 904 private: |
| 891 InstX8632Icmp(Cfg *Func, Operand *Src1, Operand *Src2); | 905 InstX8632Icmp(Cfg *Func, Operand *Src1, Operand *Src2); |
| 892 InstX8632Icmp(const InstX8632Icmp &) LLVM_DELETED_FUNCTION; | 906 InstX8632Icmp(const InstX8632Icmp &) LLVM_DELETED_FUNCTION; |
| 893 InstX8632Icmp &operator=(const InstX8632Icmp &) LLVM_DELETED_FUNCTION; | 907 InstX8632Icmp &operator=(const InstX8632Icmp &) LLVM_DELETED_FUNCTION; |
| 894 virtual ~InstX8632Icmp() {} | 908 virtual ~InstX8632Icmp() {} |
| 895 }; | 909 }; |
| 896 | 910 |
| 897 // ucomiss/ucomisd - floating-point compare instruction. | 911 // ucomiss/ucomisd - floating-point compare instruction. |
| 898 class InstX8632Ucomiss : public InstX8632 { | 912 class InstX8632Ucomiss : public InstX8632 { |
| 899 public: | 913 public: |
| 900 static InstX8632Ucomiss *create(Cfg *Func, Operand *Src1, Operand *Src2) { | 914 static InstX8632Ucomiss *create(Cfg *Func, Operand *Src1, Operand *Src2) { |
| 901 return new (Func->allocate<InstX8632Ucomiss>()) | 915 return new (Func->allocate<InstX8632Ucomiss>()) |
| 902 InstX8632Ucomiss(Func, Src1, Src2); | 916 InstX8632Ucomiss(Func, Src1, Src2); |
| 903 } | 917 } |
| 904 virtual void emit(const Cfg *Func) const; | 918 virtual void emit(const Cfg *Func) const; |
| 919 virtual void emitIAS(const Cfg *Func) const; |
| 905 virtual void dump(const Cfg *Func) const; | 920 virtual void dump(const Cfg *Func) const; |
| 906 static bool classof(const Inst *Inst) { return isClassof(Inst, Ucomiss); } | 921 static bool classof(const Inst *Inst) { return isClassof(Inst, Ucomiss); } |
| 907 | 922 |
| 908 private: | 923 private: |
| 909 InstX8632Ucomiss(Cfg *Func, Operand *Src1, Operand *Src2); | 924 InstX8632Ucomiss(Cfg *Func, Operand *Src1, Operand *Src2); |
| 910 InstX8632Ucomiss(const InstX8632Ucomiss &) LLVM_DELETED_FUNCTION; | 925 InstX8632Ucomiss(const InstX8632Ucomiss &) LLVM_DELETED_FUNCTION; |
| 911 InstX8632Ucomiss &operator=(const InstX8632Ucomiss &) LLVM_DELETED_FUNCTION; | 926 InstX8632Ucomiss &operator=(const InstX8632Ucomiss &) LLVM_DELETED_FUNCTION; |
| 912 virtual ~InstX8632Ucomiss() {} | 927 virtual ~InstX8632Ucomiss() {} |
| 913 }; | 928 }; |
| 914 | 929 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 | 1038 |
| 1024 // Movsx - copy from a narrower integer type to a wider integer | 1039 // Movsx - copy from a narrower integer type to a wider integer |
| 1025 // type, with sign extension. | 1040 // type, with sign extension. |
| 1026 class InstX8632Movsx : public InstX8632 { | 1041 class InstX8632Movsx : public InstX8632 { |
| 1027 public: | 1042 public: |
| 1028 static InstX8632Movsx *create(Cfg *Func, Variable *Dest, Operand *Source) { | 1043 static InstX8632Movsx *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| 1029 return new (Func->allocate<InstX8632Movsx>()) | 1044 return new (Func->allocate<InstX8632Movsx>()) |
| 1030 InstX8632Movsx(Func, Dest, Source); | 1045 InstX8632Movsx(Func, Dest, Source); |
| 1031 } | 1046 } |
| 1032 virtual void emit(const Cfg *Func) const; | 1047 virtual void emit(const Cfg *Func) const; |
| 1048 virtual void emitIAS(const Cfg *Func) const; |
| 1033 virtual void dump(const Cfg *Func) const; | 1049 virtual void dump(const Cfg *Func) const; |
| 1034 static bool classof(const Inst *Inst) { return isClassof(Inst, Movsx); } | 1050 static bool classof(const Inst *Inst) { return isClassof(Inst, Movsx); } |
| 1035 | 1051 |
| 1036 private: | 1052 private: |
| 1037 InstX8632Movsx(Cfg *Func, Variable *Dest, Operand *Source); | 1053 InstX8632Movsx(Cfg *Func, Variable *Dest, Operand *Source); |
| 1038 InstX8632Movsx(const InstX8632Movsx &) LLVM_DELETED_FUNCTION; | 1054 InstX8632Movsx(const InstX8632Movsx &) LLVM_DELETED_FUNCTION; |
| 1039 InstX8632Movsx &operator=(const InstX8632Movsx &) LLVM_DELETED_FUNCTION; | 1055 InstX8632Movsx &operator=(const InstX8632Movsx &) LLVM_DELETED_FUNCTION; |
| 1040 virtual ~InstX8632Movsx() {} | 1056 virtual ~InstX8632Movsx() {} |
| 1041 }; | 1057 }; |
| 1042 | 1058 |
| 1043 // Movsx - copy from a narrower integer type to a wider integer | 1059 // Movsx - copy from a narrower integer type to a wider integer |
| 1044 // type, with zero extension. | 1060 // type, with zero extension. |
| 1045 class InstX8632Movzx : public InstX8632 { | 1061 class InstX8632Movzx : public InstX8632 { |
| 1046 public: | 1062 public: |
| 1047 static InstX8632Movzx *create(Cfg *Func, Variable *Dest, Operand *Source) { | 1063 static InstX8632Movzx *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| 1048 return new (Func->allocate<InstX8632Movzx>()) | 1064 return new (Func->allocate<InstX8632Movzx>()) |
| 1049 InstX8632Movzx(Func, Dest, Source); | 1065 InstX8632Movzx(Func, Dest, Source); |
| 1050 } | 1066 } |
| 1051 virtual void emit(const Cfg *Func) const; | 1067 virtual void emit(const Cfg *Func) const; |
| 1068 virtual void emitIAS(const Cfg *Func) const; |
| 1052 virtual void dump(const Cfg *Func) const; | 1069 virtual void dump(const Cfg *Func) const; |
| 1053 static bool classof(const Inst *Inst) { return isClassof(Inst, Movzx); } | 1070 static bool classof(const Inst *Inst) { return isClassof(Inst, Movzx); } |
| 1054 | 1071 |
| 1055 private: | 1072 private: |
| 1056 InstX8632Movzx(Cfg *Func, Variable *Dest, Operand *Source); | 1073 InstX8632Movzx(Cfg *Func, Variable *Dest, Operand *Source); |
| 1057 InstX8632Movzx(const InstX8632Movzx &) LLVM_DELETED_FUNCTION; | 1074 InstX8632Movzx(const InstX8632Movzx &) LLVM_DELETED_FUNCTION; |
| 1058 InstX8632Movzx &operator=(const InstX8632Movzx &) LLVM_DELETED_FUNCTION; | 1075 InstX8632Movzx &operator=(const InstX8632Movzx &) LLVM_DELETED_FUNCTION; |
| 1059 virtual ~InstX8632Movzx() {} | 1076 virtual ~InstX8632Movzx() {} |
| 1060 }; | 1077 }; |
| 1061 | 1078 |
| 1062 // Nop instructions of varying length | 1079 // Nop instructions of varying length |
| 1063 class InstX8632Nop : public InstX8632 { | 1080 class InstX8632Nop : public InstX8632 { |
| 1064 public: | 1081 public: |
| 1065 // TODO: Replace with enum. | 1082 // TODO: Replace with enum. |
| 1066 typedef unsigned NopVariant; | 1083 typedef unsigned NopVariant; |
| 1067 | 1084 |
| 1068 static InstX8632Nop *create(Cfg *Func, NopVariant Variant) { | 1085 static InstX8632Nop *create(Cfg *Func, NopVariant Variant) { |
| 1069 return new (Func->allocate<InstX8632Nop>()) InstX8632Nop(Func, Variant); | 1086 return new (Func->allocate<InstX8632Nop>()) InstX8632Nop(Func, Variant); |
| 1070 } | 1087 } |
| 1071 virtual void emit(const Cfg *Func) const; | 1088 virtual void emit(const Cfg *Func) const; |
| 1089 virtual void emitIAS(const Cfg *Func) const; |
| 1072 virtual void dump(const Cfg *Func) const; | 1090 virtual void dump(const Cfg *Func) const; |
| 1073 static bool classof(const Inst *Inst) { return isClassof(Inst, Nop); } | 1091 static bool classof(const Inst *Inst) { return isClassof(Inst, Nop); } |
| 1074 | 1092 |
| 1075 private: | 1093 private: |
| 1076 InstX8632Nop(Cfg *Func, SizeT Length); | 1094 InstX8632Nop(Cfg *Func, SizeT Length); |
| 1077 InstX8632Nop(const InstX8632Nop &) LLVM_DELETED_FUNCTION; | 1095 InstX8632Nop(const InstX8632Nop &) LLVM_DELETED_FUNCTION; |
| 1078 InstX8632Nop &operator=(const InstX8632Nop &) LLVM_DELETED_FUNCTION; | 1096 InstX8632Nop &operator=(const InstX8632Nop &) LLVM_DELETED_FUNCTION; |
| 1079 virtual ~InstX8632Nop() {} | 1097 virtual ~InstX8632Nop() {} |
| 1080 | 1098 |
| 1081 NopVariant Variant; | 1099 NopVariant Variant; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 InstX8632Fstp &operator=(const InstX8632Fstp &) LLVM_DELETED_FUNCTION; | 1132 InstX8632Fstp &operator=(const InstX8632Fstp &) LLVM_DELETED_FUNCTION; |
| 1115 virtual ~InstX8632Fstp() {} | 1133 virtual ~InstX8632Fstp() {} |
| 1116 }; | 1134 }; |
| 1117 | 1135 |
| 1118 class InstX8632Pop : public InstX8632 { | 1136 class InstX8632Pop : public InstX8632 { |
| 1119 public: | 1137 public: |
| 1120 static InstX8632Pop *create(Cfg *Func, Variable *Dest) { | 1138 static InstX8632Pop *create(Cfg *Func, Variable *Dest) { |
| 1121 return new (Func->allocate<InstX8632Pop>()) InstX8632Pop(Func, Dest); | 1139 return new (Func->allocate<InstX8632Pop>()) InstX8632Pop(Func, Dest); |
| 1122 } | 1140 } |
| 1123 virtual void emit(const Cfg *Func) const; | 1141 virtual void emit(const Cfg *Func) const; |
| 1142 virtual void emitIAS(const Cfg *Func) const; |
| 1124 virtual void dump(const Cfg *Func) const; | 1143 virtual void dump(const Cfg *Func) const; |
| 1125 static bool classof(const Inst *Inst) { return isClassof(Inst, Pop); } | 1144 static bool classof(const Inst *Inst) { return isClassof(Inst, Pop); } |
| 1126 | 1145 |
| 1127 private: | 1146 private: |
| 1128 InstX8632Pop(Cfg *Func, Variable *Dest); | 1147 InstX8632Pop(Cfg *Func, Variable *Dest); |
| 1129 InstX8632Pop(const InstX8632Pop &) LLVM_DELETED_FUNCTION; | 1148 InstX8632Pop(const InstX8632Pop &) LLVM_DELETED_FUNCTION; |
| 1130 InstX8632Pop &operator=(const InstX8632Pop &) LLVM_DELETED_FUNCTION; | 1149 InstX8632Pop &operator=(const InstX8632Pop &) LLVM_DELETED_FUNCTION; |
| 1131 virtual ~InstX8632Pop() {} | 1150 virtual ~InstX8632Pop() {} |
| 1132 }; | 1151 }; |
| 1133 | 1152 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1153 // Ret instruction. Currently only supports the "ret" version that | 1172 // Ret instruction. Currently only supports the "ret" version that |
| 1154 // does not pop arguments. This instruction takes a Source operand | 1173 // does not pop arguments. This instruction takes a Source operand |
| 1155 // (for non-void returning functions) for liveness analysis, though | 1174 // (for non-void returning functions) for liveness analysis, though |
| 1156 // a FakeUse before the ret would do just as well. | 1175 // a FakeUse before the ret would do just as well. |
| 1157 class InstX8632Ret : public InstX8632 { | 1176 class InstX8632Ret : public InstX8632 { |
| 1158 public: | 1177 public: |
| 1159 static InstX8632Ret *create(Cfg *Func, Variable *Source = NULL) { | 1178 static InstX8632Ret *create(Cfg *Func, Variable *Source = NULL) { |
| 1160 return new (Func->allocate<InstX8632Ret>()) InstX8632Ret(Func, Source); | 1179 return new (Func->allocate<InstX8632Ret>()) InstX8632Ret(Func, Source); |
| 1161 } | 1180 } |
| 1162 virtual void emit(const Cfg *Func) const; | 1181 virtual void emit(const Cfg *Func) const; |
| 1182 virtual void emitIAS(const Cfg *Func) const; |
| 1163 virtual void dump(const Cfg *Func) const; | 1183 virtual void dump(const Cfg *Func) const; |
| 1164 static bool classof(const Inst *Inst) { return isClassof(Inst, Ret); } | 1184 static bool classof(const Inst *Inst) { return isClassof(Inst, Ret); } |
| 1165 | 1185 |
| 1166 private: | 1186 private: |
| 1167 InstX8632Ret(Cfg *Func, Variable *Source); | 1187 InstX8632Ret(Cfg *Func, Variable *Source); |
| 1168 InstX8632Ret(const InstX8632Ret &) LLVM_DELETED_FUNCTION; | 1188 InstX8632Ret(const InstX8632Ret &) LLVM_DELETED_FUNCTION; |
| 1169 InstX8632Ret &operator=(const InstX8632Ret &) LLVM_DELETED_FUNCTION; | 1189 InstX8632Ret &operator=(const InstX8632Ret &) LLVM_DELETED_FUNCTION; |
| 1170 virtual ~InstX8632Ret() {} | 1190 virtual ~InstX8632Ret() {} |
| 1171 }; | 1191 }; |
| 1172 | 1192 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 template <> void InstX8632Pextr::emit(const Cfg *Func) const; | 1257 template <> void InstX8632Pextr::emit(const Cfg *Func) const; |
| 1238 template <> void InstX8632Pinsr::emit(const Cfg *Func) const; | 1258 template <> void InstX8632Pinsr::emit(const Cfg *Func) const; |
| 1239 template <> void InstX8632Pmull::emit(const Cfg *Func) const; | 1259 template <> void InstX8632Pmull::emit(const Cfg *Func) const; |
| 1240 template <> void InstX8632Pmuludq::emit(const Cfg *Func) const; | 1260 template <> void InstX8632Pmuludq::emit(const Cfg *Func) const; |
| 1241 template <> void InstX8632Psll::emit(const Cfg *Func) const; | 1261 template <> void InstX8632Psll::emit(const Cfg *Func) const; |
| 1242 template <> void InstX8632Psra::emit(const Cfg *Func) const; | 1262 template <> void InstX8632Psra::emit(const Cfg *Func) const; |
| 1243 template <> void InstX8632Psub::emit(const Cfg *Func) const; | 1263 template <> void InstX8632Psub::emit(const Cfg *Func) const; |
| 1244 template <> void InstX8632Sqrtss::emit(const Cfg *Func) const; | 1264 template <> void InstX8632Sqrtss::emit(const Cfg *Func) const; |
| 1245 template <> void InstX8632Subss::emit(const Cfg *Func) const; | 1265 template <> void InstX8632Subss::emit(const Cfg *Func) const; |
| 1246 | 1266 |
| 1267 // Same with emitIAS() methods. |
| 1268 template <> void InstX8632Adc::emitIAS(const Cfg *Func) const; |
| 1269 template <> void InstX8632Add::emitIAS(const Cfg *Func) const; |
| 1270 template <> void InstX8632Addps::emitIAS(const Cfg *Func) const; |
| 1271 template <> void InstX8632Addss::emitIAS(const Cfg *Func) const; |
| 1272 template <> void InstX8632And::emitIAS(const Cfg *Func) const; |
| 1273 template <> void InstX8632Cbwdq::emitIAS(const Cfg *Func) const; |
| 1274 template <> void InstX8632Divps::emitIAS(const Cfg *Func) const; |
| 1275 template <> void InstX8632Divss::emitIAS(const Cfg *Func) const; |
| 1276 template <> void InstX8632Mulps::emitIAS(const Cfg *Func) const; |
| 1277 template <> void InstX8632Mulss::emitIAS(const Cfg *Func) const; |
| 1278 template <> void InstX8632Padd::emitIAS(const Cfg *Func) const; |
| 1279 template <> void InstX8632Psub::emitIAS(const Cfg *Func) const; |
| 1280 template <> void InstX8632Or::emitIAS(const Cfg *Func) const; |
| 1281 template <> void InstX8632Sbb::emitIAS(const Cfg *Func) const; |
| 1282 template <> void InstX8632Sqrtss::emitIAS(const Cfg *Func) const; |
| 1283 template <> void InstX8632Sub::emitIAS(const Cfg *Func) const; |
| 1284 template <> void InstX8632Subps::emitIAS(const Cfg *Func) const; |
| 1285 template <> void InstX8632Subss::emitIAS(const Cfg *Func) const; |
| 1286 template <> void InstX8632Xor::emitIAS(const Cfg *Func) const; |
| 1287 |
| 1247 } // end of namespace Ice | 1288 } // end of namespace Ice |
| 1248 | 1289 |
| 1249 #endif // SUBZERO_SRC_ICEINSTX8632_H | 1290 #endif // SUBZERO_SRC_ICEINSTX8632_H |
| OLD | NEW |