OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 bool is_int16() const { | 293 bool is_int16() const { |
294 return -32768 <= x_ && x_ < 32768 && RelocInfo::IsNone(rmode_); | 294 return -32768 <= x_ && x_ < 32768 && RelocInfo::IsNone(rmode_); |
295 } | 295 } |
296 | 296 |
297 private: | 297 private: |
298 inline explicit Immediate(Label* value); | 298 inline explicit Immediate(Label* value); |
299 | 299 |
300 int x_; | 300 int x_; |
301 RelocInfo::Mode rmode_; | 301 RelocInfo::Mode rmode_; |
302 | 302 |
| 303 friend class Operand; |
303 friend class Assembler; | 304 friend class Assembler; |
304 friend class MacroAssembler; | 305 friend class MacroAssembler; |
305 }; | 306 }; |
306 | 307 |
307 | 308 |
308 // ----------------------------------------------------------------------------- | 309 // ----------------------------------------------------------------------------- |
309 // Machine instruction Operands | 310 // Machine instruction Operands |
310 | 311 |
311 enum ScaleFactor { | 312 enum ScaleFactor { |
312 times_1 = 0, | 313 times_1 = 0, |
313 times_2 = 1, | 314 times_2 = 1, |
314 times_4 = 2, | 315 times_4 = 2, |
315 times_8 = 3, | 316 times_8 = 3, |
316 times_int_size = times_4, | 317 times_int_size = times_4, |
317 times_half_pointer_size = times_2, | 318 times_half_pointer_size = times_2, |
318 times_pointer_size = times_4, | 319 times_pointer_size = times_4, |
319 times_twice_pointer_size = times_8 | 320 times_twice_pointer_size = times_8 |
320 }; | 321 }; |
321 | 322 |
322 | 323 |
323 class Operand BASE_EMBEDDED { | 324 class Operand BASE_EMBEDDED { |
324 public: | 325 public: |
| 326 // reg |
| 327 INLINE(explicit Operand(Register reg)); |
| 328 |
325 // XMM reg | 329 // XMM reg |
326 INLINE(explicit Operand(XMMRegister xmm_reg)); | 330 INLINE(explicit Operand(XMMRegister xmm_reg)); |
327 | 331 |
328 // [disp/r] | 332 // [disp/r] |
329 INLINE(explicit Operand(int32_t disp, RelocInfo::Mode rmode)); | 333 INLINE(explicit Operand(int32_t disp, RelocInfo::Mode rmode)); |
330 // disp only must always be relocated | 334 |
| 335 // [disp/r] |
| 336 INLINE(explicit Operand(Immediate imm)); |
331 | 337 |
332 // [base + disp/r] | 338 // [base + disp/r] |
333 explicit Operand(Register base, int32_t disp, | 339 explicit Operand(Register base, int32_t disp, |
334 RelocInfo::Mode rmode = RelocInfo::NONE32); | 340 RelocInfo::Mode rmode = RelocInfo::NONE32); |
335 | 341 |
336 // [base + index*scale + disp/r] | 342 // [base + index*scale + disp/r] |
337 explicit Operand(Register base, | 343 explicit Operand(Register base, |
338 Register index, | 344 Register index, |
339 ScaleFactor scale, | 345 ScaleFactor scale, |
340 int32_t disp, | 346 int32_t disp, |
(...skipping 16 matching lines...) Expand all Loading... |
357 return Operand(index, scale, reinterpret_cast<int32_t>(arr.address()), | 363 return Operand(index, scale, reinterpret_cast<int32_t>(arr.address()), |
358 RelocInfo::EXTERNAL_REFERENCE); | 364 RelocInfo::EXTERNAL_REFERENCE); |
359 } | 365 } |
360 | 366 |
361 static Operand ForCell(Handle<Cell> cell) { | 367 static Operand ForCell(Handle<Cell> cell) { |
362 AllowDeferredHandleDereference embedding_raw_address; | 368 AllowDeferredHandleDereference embedding_raw_address; |
363 return Operand(reinterpret_cast<int32_t>(cell.location()), | 369 return Operand(reinterpret_cast<int32_t>(cell.location()), |
364 RelocInfo::CELL); | 370 RelocInfo::CELL); |
365 } | 371 } |
366 | 372 |
| 373 static Operand ForRegisterPlusImmediate(Register base, Immediate imm) { |
| 374 return Operand(base, imm.x_, imm.rmode_); |
| 375 } |
| 376 |
367 // Returns true if this Operand is a wrapper for the specified register. | 377 // Returns true if this Operand is a wrapper for the specified register. |
368 bool is_reg(Register reg) const; | 378 bool is_reg(Register reg) const; |
369 | 379 |
370 // Returns true if this Operand is a wrapper for one register. | 380 // Returns true if this Operand is a wrapper for one register. |
371 bool is_reg_only() const; | 381 bool is_reg_only() const; |
372 | 382 |
373 // Asserts that this Operand is a wrapper for one register and returns the | 383 // Asserts that this Operand is a wrapper for one register and returns the |
374 // register. | 384 // register. |
375 Register reg() const; | 385 Register reg() const; |
376 | 386 |
377 private: | 387 private: |
378 // reg | |
379 INLINE(explicit Operand(Register reg)); | |
380 | |
381 // Set the ModRM byte without an encoded 'reg' register. The | 388 // Set the ModRM byte without an encoded 'reg' register. The |
382 // register is encoded later as part of the emit_operand operation. | 389 // register is encoded later as part of the emit_operand operation. |
383 inline void set_modrm(int mod, Register rm); | 390 inline void set_modrm(int mod, Register rm); |
384 | 391 |
385 inline void set_sib(ScaleFactor scale, Register index, Register base); | 392 inline void set_sib(ScaleFactor scale, Register index, Register base); |
386 inline void set_disp8(int8_t disp); | 393 inline void set_disp8(int8_t disp); |
387 inline void set_dispr(int32_t disp, RelocInfo::Mode rmode); | 394 inline void set_dispr(int32_t disp, RelocInfo::Mode rmode); |
388 | 395 |
389 byte buf_[6]; | 396 byte buf_[6]; |
390 // The number of bytes in buf_. | 397 // The number of bytes in buf_. |
391 unsigned int len_; | 398 unsigned int len_; |
392 // Only valid if len_ > 4. | 399 // Only valid if len_ > 4. |
393 RelocInfo::Mode rmode_; | 400 RelocInfo::Mode rmode_; |
394 | 401 |
395 friend class Assembler; | 402 friend class Assembler; |
396 friend class MacroAssembler; | 403 friend class MacroAssembler; |
397 friend class LCodeGen; | |
398 }; | 404 }; |
399 | 405 |
400 | 406 |
401 // ----------------------------------------------------------------------------- | 407 // ----------------------------------------------------------------------------- |
402 // A Displacement describes the 32bit immediate field of an instruction which | 408 // A Displacement describes the 32bit immediate field of an instruction which |
403 // may be used together with a Label in order to refer to a yet unknown code | 409 // may be used together with a Label in order to refer to a yet unknown code |
404 // position. Displacements stored in the instruction stream are used to describe | 410 // position. Displacements stored in the instruction stream are used to describe |
405 // the instruction and to chain a list of instructions using the same Label. | 411 // the instruction and to chain a list of instructions using the same Label. |
406 // A Displacement contains 2 different fields: | 412 // A Displacement contains 2 different fields: |
407 // | 413 // |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 void cmov(Condition cc, Register dst, const Operand& src); | 646 void cmov(Condition cc, Register dst, const Operand& src); |
641 | 647 |
642 // Flag management. | 648 // Flag management. |
643 void cld(); | 649 void cld(); |
644 | 650 |
645 // Repetitive string instructions. | 651 // Repetitive string instructions. |
646 void rep_movs(); | 652 void rep_movs(); |
647 void rep_stos(); | 653 void rep_stos(); |
648 void stos(); | 654 void stos(); |
649 | 655 |
650 // Exchange two registers | 656 // Exchange |
651 void xchg(Register dst, Register src); | 657 void xchg(Register dst, Register src); |
| 658 void xchg(Register dst, const Operand& src); |
652 | 659 |
653 // Arithmetics | 660 // Arithmetics |
654 void adc(Register dst, int32_t imm32); | 661 void adc(Register dst, int32_t imm32); |
655 void adc(Register dst, const Operand& src); | 662 void adc(Register dst, const Operand& src); |
656 | 663 |
657 void add(Register dst, Register src) { add(dst, Operand(src)); } | 664 void add(Register dst, Register src) { add(dst, Operand(src)); } |
658 void add(Register dst, const Operand& src); | 665 void add(Register dst, const Operand& src); |
659 void add(const Operand& dst, Register src); | 666 void add(const Operand& dst, Register src); |
660 void add(Register dst, const Immediate& imm) { add(Operand(dst), imm); } | 667 void add(Register dst, const Immediate& imm) { add(Operand(dst), imm); } |
661 void add(const Operand& dst, const Immediate& x); | 668 void add(const Operand& dst, const Immediate& x); |
(...skipping 21 matching lines...) Expand all Loading... |
683 void cmp(const Operand& op, Handle<Object> handle); | 690 void cmp(const Operand& op, Handle<Object> handle); |
684 | 691 |
685 void dec_b(Register dst); | 692 void dec_b(Register dst); |
686 void dec_b(const Operand& dst); | 693 void dec_b(const Operand& dst); |
687 | 694 |
688 void dec(Register dst); | 695 void dec(Register dst); |
689 void dec(const Operand& dst); | 696 void dec(const Operand& dst); |
690 | 697 |
691 void cdq(); | 698 void cdq(); |
692 | 699 |
693 void idiv(Register src); | 700 void idiv(Register src) { idiv(Operand(src)); } |
| 701 void idiv(const Operand& src); |
| 702 void div(Register src) { div(Operand(src)); } |
| 703 void div(const Operand& src); |
694 | 704 |
695 // Signed multiply instructions. | 705 // Signed multiply instructions. |
696 void imul(Register src); // edx:eax = eax * src. | 706 void imul(Register src); // edx:eax = eax * src. |
697 void imul(Register dst, Register src) { imul(dst, Operand(src)); } | 707 void imul(Register dst, Register src) { imul(dst, Operand(src)); } |
698 void imul(Register dst, const Operand& src); // dst = dst * src. | 708 void imul(Register dst, const Operand& src); // dst = dst * src. |
699 void imul(Register dst, Register src, int32_t imm32); // dst = src * imm32. | 709 void imul(Register dst, Register src, int32_t imm32); // dst = src * imm32. |
| 710 void imul(Register dst, const Operand& src, int32_t imm32); |
700 | 711 |
701 void inc(Register dst); | 712 void inc(Register dst); |
702 void inc(const Operand& dst); | 713 void inc(const Operand& dst); |
703 | 714 |
704 void lea(Register dst, const Operand& src); | 715 void lea(Register dst, const Operand& src); |
705 | 716 |
706 // Unsigned multiply instruction. | 717 // Unsigned multiply instruction. |
707 void mul(Register src); // edx:eax = eax * reg. | 718 void mul(Register src); // edx:eax = eax * reg. |
708 | 719 |
709 void neg(Register dst); | 720 void neg(Register dst); |
| 721 void neg(const Operand& dst); |
710 | 722 |
711 void not_(Register dst); | 723 void not_(Register dst); |
| 724 void not_(const Operand& dst); |
712 | 725 |
713 void or_(Register dst, int32_t imm32); | 726 void or_(Register dst, int32_t imm32); |
714 void or_(Register dst, Register src) { or_(dst, Operand(src)); } | 727 void or_(Register dst, Register src) { or_(dst, Operand(src)); } |
715 void or_(Register dst, const Operand& src); | 728 void or_(Register dst, const Operand& src); |
716 void or_(const Operand& dst, Register src); | 729 void or_(const Operand& dst, Register src); |
717 void or_(Register dst, const Immediate& imm) { or_(Operand(dst), imm); } | 730 void or_(Register dst, const Immediate& imm) { or_(Operand(dst), imm); } |
718 void or_(const Operand& dst, const Immediate& x); | 731 void or_(const Operand& dst, const Immediate& x); |
719 | 732 |
720 void rcl(Register dst, uint8_t imm8); | 733 void rcl(Register dst, uint8_t imm8); |
721 void rcr(Register dst, uint8_t imm8); | 734 void rcr(Register dst, uint8_t imm8); |
722 void ror(Register dst, uint8_t imm8); | 735 void ror(Register dst, uint8_t imm8); |
723 void ror_cl(Register dst); | 736 void ror_cl(Register dst); |
724 | 737 |
725 void sar(Register dst, uint8_t imm8); | 738 void sar(Register dst, uint8_t imm8) { sar(Operand(dst), imm8); } |
726 void sar_cl(Register dst); | 739 void sar(const Operand& dst, uint8_t imm8); |
| 740 void sar_cl(Register dst) { sar_cl(Operand(dst)); } |
| 741 void sar_cl(const Operand& dst); |
727 | 742 |
728 void sbb(Register dst, const Operand& src); | 743 void sbb(Register dst, const Operand& src); |
729 | 744 |
730 void shld(Register dst, Register src) { shld(dst, Operand(src)); } | 745 void shld(Register dst, Register src) { shld(dst, Operand(src)); } |
731 void shld(Register dst, const Operand& src); | 746 void shld(Register dst, const Operand& src); |
732 | 747 |
733 void shl(Register dst, uint8_t imm8); | 748 void shl(Register dst, uint8_t imm8) { shl(Operand(dst), imm8); } |
734 void shl_cl(Register dst); | 749 void shl(const Operand& dst, uint8_t imm8); |
| 750 void shl_cl(Register dst) { shl_cl(Operand(dst)); } |
| 751 void shl_cl(const Operand& dst); |
735 | 752 |
736 void shrd(Register dst, Register src) { shrd(dst, Operand(src)); } | 753 void shrd(Register dst, Register src) { shrd(dst, Operand(src)); } |
737 void shrd(Register dst, const Operand& src); | 754 void shrd(Register dst, const Operand& src); |
738 | 755 |
739 void shr(Register dst, uint8_t imm8); | 756 void shr(Register dst, uint8_t imm8) { shr(Operand(dst), imm8); } |
740 void shr_cl(Register dst); | 757 void shr(const Operand& dst, uint8_t imm8); |
| 758 void shr_cl(Register dst) { shr_cl(Operand(dst)); } |
| 759 void shr_cl(const Operand& dst); |
741 | 760 |
742 void sub(Register dst, const Immediate& imm) { sub(Operand(dst), imm); } | 761 void sub(Register dst, const Immediate& imm) { sub(Operand(dst), imm); } |
743 void sub(const Operand& dst, const Immediate& x); | 762 void sub(const Operand& dst, const Immediate& x); |
744 void sub(Register dst, Register src) { sub(dst, Operand(src)); } | 763 void sub(Register dst, Register src) { sub(dst, Operand(src)); } |
745 void sub(Register dst, const Operand& src); | 764 void sub(Register dst, const Operand& src); |
746 void sub(const Operand& dst, Register src); | 765 void sub(const Operand& dst, Register src); |
747 | 766 |
748 void test(Register reg, const Immediate& imm); | 767 void test(Register reg, const Immediate& imm); |
749 void test(Register reg0, Register reg1) { test(reg0, Operand(reg1)); } | 768 void test(Register reg0, Register reg1) { test(reg0, Operand(reg1)); } |
750 void test(Register reg, const Operand& op); | 769 void test(Register reg, const Operand& op); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 void mulps(XMMRegister dst, XMMRegister src) { mulps(dst, Operand(src)); } | 933 void mulps(XMMRegister dst, XMMRegister src) { mulps(dst, Operand(src)); } |
915 void divps(XMMRegister dst, const Operand& src); | 934 void divps(XMMRegister dst, const Operand& src); |
916 void divps(XMMRegister dst, XMMRegister src) { divps(dst, Operand(src)); } | 935 void divps(XMMRegister dst, XMMRegister src) { divps(dst, Operand(src)); } |
917 | 936 |
918 // SSE2 instructions | 937 // SSE2 instructions |
919 void cvttss2si(Register dst, const Operand& src); | 938 void cvttss2si(Register dst, const Operand& src); |
920 void cvttss2si(Register dst, XMMRegister src) { | 939 void cvttss2si(Register dst, XMMRegister src) { |
921 cvttss2si(dst, Operand(src)); | 940 cvttss2si(dst, Operand(src)); |
922 } | 941 } |
923 void cvttsd2si(Register dst, const Operand& src); | 942 void cvttsd2si(Register dst, const Operand& src); |
| 943 void cvttsd2si(Register dst, XMMRegister src) { |
| 944 cvttsd2si(dst, Operand(src)); |
| 945 } |
924 void cvtsd2si(Register dst, XMMRegister src); | 946 void cvtsd2si(Register dst, XMMRegister src); |
925 | 947 |
926 void cvtsi2sd(XMMRegister dst, Register src) { cvtsi2sd(dst, Operand(src)); } | 948 void cvtsi2sd(XMMRegister dst, Register src) { cvtsi2sd(dst, Operand(src)); } |
927 void cvtsi2sd(XMMRegister dst, const Operand& src); | 949 void cvtsi2sd(XMMRegister dst, const Operand& src); |
928 void cvtss2sd(XMMRegister dst, XMMRegister src); | 950 void cvtss2sd(XMMRegister dst, XMMRegister src); |
929 void cvtsd2ss(XMMRegister dst, XMMRegister src); | 951 void cvtsd2ss(XMMRegister dst, XMMRegister src); |
930 | 952 |
931 void addsd(XMMRegister dst, XMMRegister src); | 953 void addsd(XMMRegister dst, XMMRegister src); |
932 void addsd(XMMRegister dst, const Operand& src); | 954 void addsd(XMMRegister dst, const Operand& src); |
933 void subsd(XMMRegister dst, XMMRegister src); | 955 void subsd(XMMRegister dst, XMMRegister src); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 private: | 1182 private: |
1161 Assembler* assembler_; | 1183 Assembler* assembler_; |
1162 #ifdef DEBUG | 1184 #ifdef DEBUG |
1163 int space_before_; | 1185 int space_before_; |
1164 #endif | 1186 #endif |
1165 }; | 1187 }; |
1166 | 1188 |
1167 } } // namespace v8::internal | 1189 } } // namespace v8::internal |
1168 | 1190 |
1169 #endif // V8_IA32_ASSEMBLER_IA32_H_ | 1191 #endif // V8_IA32_ASSEMBLER_IA32_H_ |
OLD | NEW |