| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 // CpuFeatures::Scope fscope(SSE2); | 353 // CpuFeatures::Scope fscope(SSE2); |
| 354 // // Generate SSE2 floating point code. | 354 // // Generate SSE2 floating point code. |
| 355 // } else { | 355 // } else { |
| 356 // // Generate standard x87 floating point code. | 356 // // Generate standard x87 floating point code. |
| 357 // } | 357 // } |
| 358 class CpuFeatures : public AllStatic { | 358 class CpuFeatures : public AllStatic { |
| 359 public: | 359 public: |
| 360 // Feature flags bit positions. They are mostly based on the CPUID spec. | 360 // Feature flags bit positions. They are mostly based on the CPUID spec. |
| 361 // (We assign CPUID itself to one of the currently reserved bits -- | 361 // (We assign CPUID itself to one of the currently reserved bits -- |
| 362 // feel free to change this if needed.) | 362 // feel free to change this if needed.) |
| 363 enum Feature { SSE2 = 26, CMOV = 15, RDTSC = 4, CPUID = 10 }; | 363 enum Feature { SSE3 = 32, SSE2 = 26, CMOV = 15, RDTSC = 4, CPUID = 10 }; |
| 364 // Detect features of the target CPU. Set safe defaults if the serializer | 364 // Detect features of the target CPU. Set safe defaults if the serializer |
| 365 // is enabled (snapshots must be portable). | 365 // is enabled (snapshots must be portable). |
| 366 static void Probe(); | 366 static void Probe(); |
| 367 // Check whether a feature is supported by the target CPU. | 367 // Check whether a feature is supported by the target CPU. |
| 368 static bool IsSupported(Feature f) { return supported_ & (1 << f); } | 368 static bool IsSupported(Feature f) { |
| 369 return (supported_ & (static_cast<uint64_t>(1) << f)) != 0; |
| 370 } |
| 369 // Check whether a feature is currently enabled. | 371 // Check whether a feature is currently enabled. |
| 370 static bool IsEnabled(Feature f) { return enabled_ & (1 << f); } | 372 static bool IsEnabled(Feature f) { |
| 373 return (enabled_ & (static_cast<uint64_t>(1) << f)) != 0; |
| 374 } |
| 371 // Enable a specified feature within a scope. | 375 // Enable a specified feature within a scope. |
| 372 class Scope BASE_EMBEDDED { | 376 class Scope BASE_EMBEDDED { |
| 373 #ifdef DEBUG | 377 #ifdef DEBUG |
| 374 public: | 378 public: |
| 375 explicit Scope(Feature f) { | 379 explicit Scope(Feature f) { |
| 376 ASSERT(CpuFeatures::IsSupported(f)); | 380 ASSERT(CpuFeatures::IsSupported(f)); |
| 377 old_enabled_ = CpuFeatures::enabled_; | 381 old_enabled_ = CpuFeatures::enabled_; |
| 378 CpuFeatures::enabled_ |= (1 << f); | 382 CpuFeatures::enabled_ |= (static_cast<uint64_t>(1) << f); |
| 379 } | 383 } |
| 380 ~Scope() { CpuFeatures::enabled_ = old_enabled_; } | 384 ~Scope() { CpuFeatures::enabled_ = old_enabled_; } |
| 381 private: | 385 private: |
| 382 uint32_t old_enabled_; | 386 uint64_t old_enabled_; |
| 383 #else | 387 #else |
| 384 public: | 388 public: |
| 385 explicit Scope(Feature f) {} | 389 explicit Scope(Feature f) {} |
| 386 #endif | 390 #endif |
| 387 }; | 391 }; |
| 388 private: | 392 private: |
| 389 static uint32_t supported_; | 393 static uint64_t supported_; |
| 390 static uint32_t enabled_; | 394 static uint64_t enabled_; |
| 391 }; | 395 }; |
| 392 | 396 |
| 393 | 397 |
| 394 class Assembler : public Malloced { | 398 class Assembler : public Malloced { |
| 395 private: | 399 private: |
| 396 // The relocation writer's position is kGap bytes below the end of | 400 // The relocation writer's position is kGap bytes below the end of |
| 397 // the generated instructions. This leaves enough space for the | 401 // the generated instructions. This leaves enough space for the |
| 398 // longest possible ia32 instruction (17 bytes as of 9/26/06) and | 402 // longest possible ia32 instruction (17 bytes as of 9/26/06) and |
| 399 // allows for a single, fast space check per instruction. | 403 // allows for a single, fast space check per instruction. |
| 400 static const int kGap = 32; | 404 static const int kGap = 32; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 void fstp_d(const Operand& adr); | 648 void fstp_d(const Operand& adr); |
| 645 | 649 |
| 646 void fild_s(const Operand& adr); | 650 void fild_s(const Operand& adr); |
| 647 void fild_d(const Operand& adr); | 651 void fild_d(const Operand& adr); |
| 648 | 652 |
| 649 void fist_s(const Operand& adr); | 653 void fist_s(const Operand& adr); |
| 650 | 654 |
| 651 void fistp_s(const Operand& adr); | 655 void fistp_s(const Operand& adr); |
| 652 void fistp_d(const Operand& adr); | 656 void fistp_d(const Operand& adr); |
| 653 | 657 |
| 658 void fisttp_s(const Operand& adr); |
| 659 |
| 654 void fabs(); | 660 void fabs(); |
| 655 void fchs(); | 661 void fchs(); |
| 656 | 662 |
| 657 void fadd(int i); | 663 void fadd(int i); |
| 658 void fsub(int i); | 664 void fsub(int i); |
| 659 void fmul(int i); | 665 void fmul(int i); |
| 660 void fdiv(int i); | 666 void fdiv(int i); |
| 661 | 667 |
| 662 void fisub_s(const Operand& adr); | 668 void fisub_s(const Operand& adr); |
| 663 | 669 |
| 664 void faddp(int i = 1); | 670 void faddp(int i = 1); |
| 665 void fsubp(int i = 1); | 671 void fsubp(int i = 1); |
| 666 void fsubrp(int i = 1); | 672 void fsubrp(int i = 1); |
| 667 void fmulp(int i = 1); | 673 void fmulp(int i = 1); |
| 668 void fdivp(int i = 1); | 674 void fdivp(int i = 1); |
| 669 void fprem(); | 675 void fprem(); |
| 670 void fprem1(); | 676 void fprem1(); |
| 671 | 677 |
| 672 void fxch(int i = 1); | 678 void fxch(int i = 1); |
| 673 void fincstp(); | 679 void fincstp(); |
| 674 void ffree(int i = 0); | 680 void ffree(int i = 0); |
| 675 | 681 |
| 676 void ftst(); | 682 void ftst(); |
| 677 void fucomp(int i); | 683 void fucomp(int i); |
| 678 void fucompp(); | 684 void fucompp(); |
| 679 void fcompp(); | 685 void fcompp(); |
| 680 void fnstsw_ax(); | 686 void fnstsw_ax(); |
| 681 void fwait(); | 687 void fwait(); |
| 688 void fnclex(); |
| 682 | 689 |
| 683 void frndint(); | 690 void frndint(); |
| 684 | 691 |
| 685 void sahf(); | 692 void sahf(); |
| 686 void setcc(Condition cc, Register reg); | 693 void setcc(Condition cc, Register reg); |
| 687 | 694 |
| 688 void cpuid(); | 695 void cpuid(); |
| 689 | 696 |
| 690 // SSE2 instructions | 697 // SSE2 instructions |
| 691 void cvttss2si(Register dst, const Operand& src); | 698 void cvttss2si(Register dst, const Operand& src); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 private: | 854 private: |
| 848 Assembler* assembler_; | 855 Assembler* assembler_; |
| 849 #ifdef DEBUG | 856 #ifdef DEBUG |
| 850 int space_before_; | 857 int space_before_; |
| 851 #endif | 858 #endif |
| 852 }; | 859 }; |
| 853 | 860 |
| 854 } } // namespace v8::internal | 861 } } // namespace v8::internal |
| 855 | 862 |
| 856 #endif // V8_ASSEMBLER_IA32_H_ | 863 #endif // V8_ASSEMBLER_IA32_H_ |
| OLD | NEW |