OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 *reinterpret_cast<Instr16*>(buffer_ + pos) = instr >> 16; | 373 *reinterpret_cast<Instr16*>(buffer_ + pos) = instr >> 16; |
374 *reinterpret_cast<Instr16*>(buffer_ + pos + kInstr16Size) = instr & 0xFFFF; | 374 *reinterpret_cast<Instr16*>(buffer_ + pos + kInstr16Size) = instr & 0xFFFF; |
375 } | 375 } |
376 | 376 |
377 | 377 |
378 void Assembler::thumb32_instr_at_put(byte* pc, Instr instr) { | 378 void Assembler::thumb32_instr_at_put(byte* pc, Instr instr) { |
379 *reinterpret_cast<Instr16*>(pc) = instr >> 16; | 379 *reinterpret_cast<Instr16*>(pc) = instr >> 16; |
380 *reinterpret_cast<Instr16*>(pc + kInstr16Size) = instr & 0xFFFF; | 380 *reinterpret_cast<Instr16*>(pc + kInstr16Size) = instr & 0xFFFF; |
381 } | 381 } |
382 | 382 |
383 | |
384 // add imm t3 - mode 1 | |
385 void Assembler::add_imm_t3(Register dst, Register src1, SBit s, Condition cond, | |
386 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
387 ASSERT(cond == al); | |
Benedikt Meurer
2013/09/17 08:01:54
Why pass cond if it is constant anyway?
| |
388 emit32(thumb32_mode1(ADD_32_IMM3, s) | | |
389 thumb32_2reg_thumb_expand_imm(dst, src1, i, imm3, imm8)); | |
390 } | |
391 | |
392 | |
393 // add imm t4 - mode 3 | |
394 void Assembler::add_imm_t4(Register dst, Register src1, const Operand& src2, | |
395 SBit s, Condition cond) { | |
396 ASSERT(cond == al); | |
Benedikt Meurer
2013/09/17 08:01:54
Same here...
| |
397 // i Rn imm3 Rd imm8 | |
398 emit32(thumb32_mode3(ADD_32_IMM4) | | |
399 thumb32_2reg_zero_extend_imm_split(src1, dst, src2)); | |
400 } | |
401 | |
402 | |
403 // add reg t3 - mode 11 | |
404 void Assembler::add_reg_t3(Register dst, Register src1, const Operand& src2, | |
405 SBit s, Condition cond) { | |
406 ASSERT(cond == al); | |
Benedikt Meurer
2013/09/17 08:01:54
And so on...
| |
407 emit32(thumb32_mode11(ADD_32_REG3, s) | | |
408 thumb32_3reg_shift_imm8(src1, dst, src2)); | |
409 } | |
410 | |
411 | |
412 // sub imm t3 - mode 1 | |
413 void Assembler::sub_imm_t3(Register dst, Register src1, SBit s, Condition cond, | |
414 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
415 ASSERT(cond == al); | |
416 emit32(thumb32_mode1(SUB_32_IMM3, s) | | |
417 thumb32_2reg_thumb_expand_imm(dst, src1, i, imm3, imm8) ); | |
418 } | |
419 | |
420 | |
421 // sub imm t4 - mode 3 | |
422 void Assembler::sub_imm_t4(Register dst, Register src1, const Operand& src2, | |
423 SBit s, Condition cond) { | |
424 emit32(thumb32_mode3(SUB_32_IMM4) | | |
425 thumb32_2reg_zero_extend_imm_split(src1, dst, src2) ); | |
426 } | |
427 | |
428 | |
429 // sub reg t3 - mode 11 | |
430 void Assembler::sub_reg_t3(Register dst, Register src1, const Operand& src2, | |
431 SBit s, Condition cond) { | |
432 ASSERT(cond == al); | |
433 emit32(thumb32_mode11(SUB_32_REG2 , s) | | |
434 thumb32_3reg_shift_imm8(src1, dst, src2)); | |
435 } | |
436 | |
437 | |
438 // mov imm t2 - mode 1 | |
439 void Assembler::mov_imm_t2(Register dst, SBit s, Condition cond, | |
440 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
441 // note : uses imm4 (replaces Rn) | |
442 emit32(thumb32_mode1(MOV_32_IMM2, s) | | |
443 thumb32_2reg_thumb_expand_imm(dst, pc, i, imm3, imm8) ); | |
444 } | |
445 | |
446 | |
447 // mov imm t3 - mode 3 | |
448 void Assembler::mov_imm_t3(Register dst, const Operand& src, SBit s, | |
449 Condition cond) { | |
450 emit32(thumb32_mode3(MOV_32_IMM3) | | |
451 thumb32_1reg_zero_extend_imm_split_4i38(dst, src.imm32_)); | |
452 } | |
453 | |
454 | |
455 // mov reg t2 - mode 11 | |
456 void Assembler::mov_reg_t3(Register dst, const Operand& src, SBit s, | |
457 Condition cond) { | |
458 ASSERT(cond == al); | |
459 emit32(thumb32_mode11(MOV_32_REG3, s) | | |
460 thumb32_3reg_shift_imm8(pc, dst, src)); | |
461 } | |
462 | |
463 | |
464 // teq imm t1 - mode 1 | |
465 void Assembler::teq_imm_t1(Register src1, Condition cond, | |
466 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
467 emit32(thumb32_mode1(TEQ_32_IMM, SetCC) | | |
468 thumb32_2reg_thumb_expand_imm(pc, src1, i, imm3, imm8) ); | |
469 } | |
470 | |
471 | |
472 // teq reg t1 - mode 11 | |
473 void Assembler::teq_reg_t1(Register src1, const Operand& src2, Condition cond) { | |
474 emit32(thumb32_mode11(TEQ_32_REG, SetCC) | | |
475 thumb32_3reg_shift_imm8(src1, pc, src2)); | |
476 } | |
477 | |
478 | |
479 // cmp imm t2 - mode 1 | |
480 void Assembler::cmp_imm_t2(Register src1, Condition cond, | |
481 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
482 ASSERT(cond == al); | |
483 emit32(thumb32_mode1(CMP_32_IMM, SetCC) | | |
484 thumb32_2reg_thumb_expand_imm(pc, src1, i, imm3, imm8) ); | |
485 } | |
486 | |
487 | |
488 // cmp reg t3 - mode 11 | |
489 void Assembler::cmp_reg_t3(Register src1, const Operand& src2, Condition cond) { | |
490 ASSERT(cond == al); | |
491 emit32(thumb32_mode11(CMP_32_REG3, SetCC) | | |
492 thumb32_3reg_shift_imm8(src1, pc, src2)); | |
493 } | |
494 | |
495 | |
496 // lsl imm t2 - mode UNKNOWN | |
497 void Assembler::lsl_imm_t2(Register dst, const Operand& src, SBit s, | |
498 Condition cond) { | |
499 ASSERT(cond == al); | |
500 ASSERT(is_uint5(src.shift_imm_)); | |
501 ASSERT(dst.code() != 13); | |
502 ASSERT(dst.code() != 15); | |
503 ASSERT(src.rm_.code() != 13); | |
504 ASSERT(src.rm_.code() != 15); | |
505 uint32_t imm3 = src.shift_imm_ >> 2; | |
506 uint32_t imm2 = src.shift_imm_ & 0x3; | |
507 ASSERT(imm3 != 0 || imm2 != 0); // see MOV (register) | |
508 emit32(BH15 | BH14 | BH13 | BH11 | BH9 | BH6 | s | BH3 | BH2 | BH1 | BH0 | | |
509 imm3*B12 | dst.code()*B8 | imm2*B6 | src.rm_.code()); | |
510 } | |
511 | |
512 | |
513 // lsl reg t2 - mode 12 | |
514 void Assembler::lsl_reg_t2(Register dst, const Operand& src, SBit s, | |
515 Condition cond) { | |
516 ASSERT(cond == al); | |
517 emit32(thumb32_mode12(LSL_32_REG) | thumb32_3reg_shift(dst, src) | s); | |
518 } | |
519 | |
520 | |
521 // lsr imm t2 - mode UNKNOWN | |
522 void Assembler::lsr_imm_t2(Register dst, const Operand& src, SBit s, | |
523 Condition cond) { | |
524 ASSERT(cond == al); | |
525 ASSERT(is_uint5(src.shift_imm_)); | |
526 ASSERT(dst.code() != 13); | |
527 ASSERT(dst.code() != 15); | |
528 ASSERT(src.rm_.code() != 13); | |
529 ASSERT(src.rm_.code() != 15); | |
530 uint32_t imm3 = src.shift_imm_ >> 2; | |
531 uint32_t imm2 = src.shift_imm_ & 0x3; | |
532 emit32(BH15 | BH14 | BH13 | BH11 | BH9 | BH6 | s | BH3 | BH2 | BH1 | BH0 | | |
533 imm3*B12 | dst.code()*B8 | imm2*B6 | B4 | src.rm_.code()); | |
534 } | |
535 | |
536 | |
537 // lsr reg t2 - mode 12 | |
538 void Assembler::lsr_reg_t2(Register dst, const Operand& src, SBit s, | |
539 Condition cond) { | |
540 ASSERT(cond == al); | |
541 emit32(thumb32_mode12(LSR_32_REG) | thumb32_3reg_shift(dst, src) | s); | |
542 } | |
543 | |
544 | |
545 // asr imm t2 - mode UNKNOWN | |
546 void Assembler::asr_imm_t2(Register dst, const Operand& src, SBit s, | |
547 Condition cond) { | |
548 ASSERT(is_uint5(src.shift_imm_)); | |
549 ASSERT(dst.code() != 13); | |
550 ASSERT(dst.code() != 15); | |
551 ASSERT(src.rm_.code() != 13); | |
552 ASSERT(src.rm_.code() != 15); | |
553 uint32_t imm3 = src.shift_imm_ >> 2; | |
554 uint32_t imm2 = src.shift_imm_ & 0x3; | |
555 emit32(BH15 | BH14 | BH13 | BH11 | BH9 | BH6 | s | BH3 | BH2 | BH1 | BH0 | | |
556 imm3*B12 | dst.code()*B8 | imm2*B6 | B5 | src.rm_.code()); | |
557 } | |
558 | |
559 | |
560 // ror imm t2 - mode UNKNOWN | |
561 void Assembler::ror_imm_t2(Register dst, const Operand& src, SBit s, | |
562 Condition cond) { | |
563 ASSERT(cond == al); | |
564 ASSERT(is_uint5(src.shift_imm_)); | |
565 ASSERT(dst.code() != 13); | |
566 ASSERT(dst.code() != 15); | |
567 ASSERT(src.rm_.code() != 13); | |
568 ASSERT(src.rm_.code() != 15); | |
569 uint32_t imm3 = src.shift_imm_ >> 2; | |
570 uint32_t imm2 = src.shift_imm_ & 0x3; | |
571 emit32(BH15 | BH14 | BH13 | BH11 | BH9 | BH6 | s | BH3 | BH2 | BH1 | BH0 | | |
572 imm3*B12 | dst.code()*B8 | imm2*B6 | B5 | B4 | src.rm_.code()); | |
573 } | |
574 | |
575 | |
576 // asr reg t2 - mode 12 | |
577 void Assembler::asr_reg_t2(Register dst, const Operand& src, SBit s, | |
578 Condition cond) { | |
579 emit32(thumb32_mode12(ASR_32_REG) | thumb32_3reg_shift(dst, src) | s); | |
Benedikt Meurer
2013/09/17 08:01:54
no ASSERT(cond == al) here?
| |
580 } | |
581 | |
582 | |
583 // ror reg t2 - mode 12 | |
584 void Assembler::ror_reg_t2(Register dst, const Operand& src, SBit s, | |
585 Condition cond) { | |
586 ASSERT(cond == al); | |
587 emit32(thumb32_mode12(ROR_32_REG) | thumb32_3reg_shift(dst, src) | s); | |
588 } | |
589 | |
590 | |
591 // and imm t1 - mode 1 | |
592 void Assembler::and_imm_t1(Register dst, Register src1, SBit s, Condition cond, | |
593 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
594 ASSERT(cond == al); | |
595 emit32(thumb32_mode1(AND_32_IMM, s) | | |
596 thumb32_2reg_thumb_expand_imm(dst, src1, i, imm3, imm8) ); | |
597 } | |
598 | |
599 | |
600 // and reg t2 - mode 11 | |
601 void Assembler::and_reg_t2(Register dst, Register src1, const Operand& src2, | |
602 SBit s, Condition cond) { | |
603 // S Rn Rd imm5 type Rm | |
604 ASSERT(cond == al); | |
605 emit32(thumb32_mode11(AND_32_REG2, s) | | |
606 thumb32_3reg_shift_imm8(src1, dst, src2)); | |
607 } | |
608 | |
609 | |
610 // eor imm t1 - mode 1 | |
611 void Assembler::eor_imm_t1(Register dst, Register src1, SBit s, Condition cond, | |
612 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
613 ASSERT(cond == al); | |
614 emit32(thumb32_mode1(EOR_32_IMM, s) | | |
615 thumb32_2reg_thumb_expand_imm(dst, src1, i, imm3, imm8)); | |
616 } | |
617 | |
618 | |
619 // eor reg t2 - mode 11 | |
620 void Assembler::eor_reg_t2(Register dst, Register src1, const Operand& src2, | |
621 SBit s, Condition cond) { | |
622 // S Rn imm3 Rd immm2 type Rm | |
623 ASSERT(cond == al); | |
624 emit32(thumb32_mode11(EOR_32_REG2, s) | | |
625 thumb32_3reg_shift_imm8(src1, dst, src2)); | |
626 } | |
627 | |
628 | |
629 // adc imm t1 - mode 1 | |
630 void Assembler::adc_imm_t1(Register dst, Register src1, SBit s, Condition cond, | |
631 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
632 ASSERT(cond == al); | |
633 emit32(thumb32_mode1(ADC_32_IMM , s) | | |
634 thumb32_2reg_thumb_expand_imm(dst, src1, i, imm3, imm8)); | |
635 } | |
636 | |
637 | |
638 // adc reg t2 - mode 11 | |
639 void Assembler::adc_reg_t2(Register dst, Register src1, const Operand& src2, | |
640 SBit s, Condition cond) { | |
641 // S Rn imm3 Rd imm2 type Rm | |
642 ASSERT(cond == al); | |
643 emit32(thumb32_mode11(ADC_32_REG2, s) | | |
644 thumb32_3reg_shift_imm8(src1, dst, src2)); | |
645 } | |
646 | |
647 | |
648 // sbc imm t1 - mode 1 | |
649 void Assembler::sbc_imm_t1(Register dst, Register src1, SBit s, Condition cond, | |
650 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
651 ASSERT(cond == al); | |
652 emit32(thumb32_mode1(SBC_32_IMM, s) | | |
653 thumb32_2reg_thumb_expand_imm(dst, src1, i, imm3, imm8)); | |
654 } | |
655 | |
656 | |
657 // sbc reg t2 - mode 11 | |
658 void Assembler::sbc_reg_t2(Register dst, Register src1, const Operand& src2, | |
659 SBit s, Condition cond) { | |
660 // S Rn imm3 Rd imm2 type Rm // 3reg | |
661 ASSERT(cond == al); | |
662 emit32(thumb32_mode11(SBC_32_REG2, s) | | |
663 thumb32_3reg_shift_imm8(src1, dst, src2)); | |
664 } | |
665 | |
666 | |
667 // rsb imm t1 - mode 1 | |
668 void Assembler::rsb_imm_t2(Register dst, Register src1, SBit s, Condition cond, | |
669 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
670 // S Rn imm3 Rd imm8 // 2reg | |
671 emit32(thumb32_mode1(RSB_32_IMM, s) | | |
672 thumb32_2reg_thumb_expand_imm(dst, src1, i, imm3, imm8)); | |
673 } | |
674 | |
675 | |
676 // rsb reg t2 - mode 11 | |
677 void Assembler::rsb_reg_t1(Register dst, Register src1, const Operand& src2, | |
678 SBit s, Condition cond) { | |
679 // S Rn imm3 Rd imm2 type Rm // 3reg | |
680 emit32(thumb32_mode11(RSB_32_REG, s) | | |
681 thumb32_3reg_shift_imm8(src1, dst, src2)); | |
682 } | |
683 | |
684 | |
685 // tst imm t1 - mode 1 | |
686 void Assembler::tst_imm_t1(Register src1, Condition cond, | |
687 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
688 // Rn imm3 imm8 // 1reg | |
689 emit32(thumb32_mode1(TST_32_IMM, SetCC) | | |
690 thumb32_2reg_thumb_expand_imm(pc, src1, i, imm3, imm8)); | |
691 } | |
692 | |
693 | |
694 // tst reg t2 - mode 11 | |
695 void Assembler::tst_reg_t2(Register src1, const Operand& src2, Condition cond) { | |
696 // Rn imm3 imm2 type Rm | |
697 ASSERT(cond == al); | |
698 emit32(thumb32_mode11(TST_32_REG2, SetCC) | | |
699 thumb32_3reg_shift_imm8(src1, pc, src2)); | |
700 } | |
701 | |
702 | |
703 // cmn imm t1 - mode 1 | |
704 void Assembler::cmn_imm_t1(Register src1, Condition cond, | |
705 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
706 ASSERT(cond == al); | |
707 // SetCC turns on BH4, which is on for cmm immediate T1 | |
708 emit32(thumb32_mode1(CMN_32_IMM, SetCC) | | |
709 thumb32_2reg_thumb_expand_imm(pc, src1, i, imm3, imm8)); | |
710 } | |
711 | |
712 | |
713 // cmn reg t2 - mode 11 | |
714 void Assembler::cmn_reg_t2(Register src1, const Operand& src2, Condition cond) { | |
715 // Rn imm3 imm2 type Rm // 2reg | |
716 ASSERT(cond == al); | |
717 // SetCC turns on BH4, which is on for cmm register T2 | |
718 emit32(thumb32_mode11(CMN_32_REG2, SetCC) | | |
719 thumb32_3reg_shift_imm8(src1, pc, src2)); | |
720 } | |
721 | |
722 | |
723 // bic imm t1 - mode 1 | |
724 void Assembler::bic_imm_t1(Register dst, Register src1, SBit s, Condition cond, | |
725 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
726 ASSERT(cond == al); | |
727 emit32(thumb32_mode1(BIC_32_IMM, s) | | |
728 thumb32_2reg_thumb_expand_imm(dst, src1, i, imm3, imm8)); | |
729 } | |
730 | |
731 | |
732 // bic reg t2 - mode 11 | |
733 void Assembler::bic_reg_t2(Register dst, Register src1, const Operand& src2, | |
734 SBit s, Condition cond) { | |
735 // S Rn imm3 Rd imm2 type Rm // 3reg | |
736 ASSERT(cond == al); | |
737 emit32(thumb32_mode11(BIC_32_REG2 , s) | | |
738 thumb32_3reg_shift_imm8(src1, dst, src2)); | |
739 } | |
740 | |
741 | |
742 // mul t2 - mode 16 | |
743 void Assembler::mul_t2(Register dst, Register src1, Register src2, | |
744 SBit s, Condition cond) { | |
745 ASSERT(cond == al); | |
746 emit32(thumb32_mode16(MUL_32) | thumb32_4reg(dst, src1, src2, pc)); | |
747 } | |
748 | |
749 | |
750 // mvn imm t1 - mode 1 | |
751 void Assembler::mvn_imm_t1(Register dst, SBit s, Condition cond, | |
752 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
753 ASSERT(cond == al); | |
754 emit32(thumb32_mode1(MVN_32_IMM, s) | | |
755 thumb32_2reg_thumb_expand_imm(dst, pc, i, imm3, imm8)); | |
756 } | |
757 | |
758 | |
759 // mvn reg t2 - mode 11 | |
760 void Assembler::mvn_reg_t2(Register dst, const Operand& src, SBit s, | |
761 Condition cond) { | |
762 ASSERT(cond == al); | |
763 emit32(thumb32_mode11(MVN_32_REG2, s) | | |
764 thumb32_3reg_shift_imm8(pc, dst, src)); | |
765 } | |
766 | |
767 | |
768 // orr imm t1 - mode 1 | |
769 void Assembler::orr_imm_t1(Register dst, Register src1, SBit s, Condition cond, | |
770 uint32_t i, uint32_t imm3, uint32_t imm8) { | |
771 ASSERT(cond == al); | |
772 emit32(thumb32_mode1(ORR_32_IMM, s) | | |
773 thumb32_2reg_thumb_expand_imm(dst, src1, i, imm3, imm8)); | |
774 } | |
775 | |
776 | |
777 // orr reg t2 - mode 11 | |
778 void Assembler::orr_reg_t2(Register dst, Register src1, const Operand& src2, | |
779 SBit s, Condition cond) { | |
780 ASSERT(cond == al); | |
781 emit32(thumb32_mode11(ORR_32_REG2, s) | | |
782 thumb32_3reg_shift_imm8(src1, dst, src2)); | |
783 } | |
784 | |
785 | |
786 // Mode 3, note: | |
787 // bfi imm t1 - mode 3 is included in bfi() | |
788 // bfc imm t1 - mode 3 is included in bfc() | |
789 // usat imm t1 - mode 3 is included in usat() | |
790 // ubfx imm t1 - mode 3 is included in ubfx() | |
791 // Mode 15 | |
792 // clz t1 included in clz() | |
793 | |
794 | |
795 // ldrd imm t1 - has 2 | |
796 void Assembler::ldrd_imm_t1(Register dst1, Register dst2, | |
797 const MemOperand& src) { | |
798 // Note: BH5 is both op2's high bit and W; LDRD_32_IMM_OP2 sets W on | |
799 // so created _x1 | |
800 emit32(thumb32_mode6(LDRD_32_IMM, LDRD_32_IMM_OP2_x1) | | |
801 thumb32_3reg_zero_extend_imm8(dst1, dst2, src)); | |
802 } | |
803 | |
804 | |
805 void Assembler::strd_imm_t1(Register src1, Register src2, | |
806 const MemOperand& dst) { | |
807 emit32(thumb32_mode6(STRD_32_IMM2, STRD_32_IMM2_OP2) | | |
808 thumb32_3reg_zero_extend_imm8(src1, src2, dst)); | |
809 } | |
810 | |
383 } } // namespace v8::internal | 811 } } // namespace v8::internal |
384 | 812 |
385 #endif // V8_TARGET_ARCH_ARM | 813 #endif // V8_TARGET_ARCH_ARM |
386 | 814 |
OLD | NEW |