[x86] Avoid memory form of PUSH/CALL for ATOM.
authorweiliang.lin <weiliang.lin@intel.com>
Tue, 20 Jan 2015 14:59:47 +0000 (06:59 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 20 Jan 2015 14:59:56 +0000 (14:59 +0000)
Review URL: https://codereview.chromium.org/853703002

Cr-Commit-Position: refs/heads/master@{#26163}

src/base/cpu.cc
src/base/cpu.h
src/compiler/ia32/instruction-selector-ia32.cc
src/compiler/x64/instruction-selector-x64.cc
src/flag-definitions.h
src/globals.h
src/ia32/assembler-ia32.cc
src/x64/assembler-x64.cc
src/x64/macro-assembler-x64.cc

index 0cf3fb85304a912dae428e67bf37ddb5c6001789..1be0596699797af81ee5cc9bcfd39093aebab4d8 100644 (file)
@@ -315,6 +315,7 @@ CPU::CPU()
       has_ssse3_(false),
       has_sse41_(false),
       has_sse42_(false),
+      is_atom_(false),
       has_avx_(false),
       has_fma3_(false),
       has_idiva_(false),
@@ -365,6 +366,20 @@ CPU::CPU()
     has_sse42_ = (cpu_info[2] & 0x00100000) != 0;
     has_avx_ = (cpu_info[2] & 0x10000000) != 0;
     if (has_avx_) has_fma3_ = (cpu_info[2] & 0x00001000) != 0;
+
+    if (family_ == 0x6) {
+      switch (model_) {
+        case 0x1c:  // SLT
+        case 0x26:
+        case 0x36:
+        case 0x27:
+        case 0x35:
+        case 0x37:  // SLM
+        case 0x4a:
+        case 0x4d:
+          is_atom_ = true;
+      }
+    }
   }
 
 #if V8_HOST_ARCH_IA32
index 38465f5b358f6654c8f4d28bdb5ce40954e41bbd..193ea5a921b0e7d78d9d71f29c97571bc6f8b35a 100644 (file)
@@ -85,6 +85,7 @@ class CPU FINAL {
   bool has_sse42() const { return has_sse42_; }
   bool has_avx() const { return has_avx_; }
   bool has_fma3() const { return has_fma3_; }
+  bool is_atom() const { return is_atom_; }
 
   // arm features
   bool has_idiva() const { return has_idiva_; }
@@ -119,6 +120,7 @@ class CPU FINAL {
   bool has_ssse3_;
   bool has_sse41_;
   bool has_sse42_;
+  bool is_atom_;
   bool has_avx_;
   bool has_fma3_;
   bool has_idiva_;
index e3a824618dca0f67da43248c4b4e7440610c4fe9..7b6b721a376e5441ed704ecf9c9922324de9d328 100644 (file)
@@ -737,8 +737,11 @@ void InstructionSelector::VisitCall(Node* node) {
   for (auto i = buffer.pushed_nodes.rbegin(); i != buffer.pushed_nodes.rend();
        ++i) {
     // TODO(titzer): handle pushing double parameters.
-    Emit(kIA32Push, nullptr,
-         g.CanBeImmediate(*i) ? g.UseImmediate(*i) : g.Use(*i));
+    InstructionOperand* value =
+        g.CanBeImmediate(*i) ? g.UseImmediate(*i) : IsSupported(ATOM)
+                                                        ? g.UseRegister(*i)
+                                                        : g.Use(*i);
+    Emit(kIA32Push, nullptr, value);
   }
 
   // Select the appropriate opcode based on the call type.
index c1f2e0cb201f671a46f748b88f5cc258227e5387..0e6e220306a8c921d01c8e10a00cf6f524022000 100644 (file)
@@ -942,8 +942,11 @@ void InstructionSelector::VisitCall(Node* node) {
   for (auto i = buffer.pushed_nodes.rbegin(); i != buffer.pushed_nodes.rend();
        ++i) {
     // TODO(titzer): handle pushing double parameters.
-    Emit(kX64Push, nullptr,
-         g.CanBeImmediate(*i) ? g.UseImmediate(*i) : g.Use(*i));
+    InstructionOperand* value =
+        g.CanBeImmediate(*i) ? g.UseImmediate(*i) : IsSupported(ATOM)
+                                                        ? g.UseRegister(*i)
+                                                        : g.Use(*i);
+    Emit(kX64Push, nullptr, value);
   }
 
   // Select the appropriate opcode based on the call type.
index b9794f4c7f287e8cfd0163247b456111d19e37a6..03e22df4ae32a63f10167d00bf8b31d30b56a8f2 100644 (file)
@@ -467,6 +467,7 @@ DEFINE_BOOL(enable_vldr_imm, false,
             "enable use of constant pools for double immediate (ARM only)")
 DEFINE_BOOL(force_long_branches, false,
             "force all emitted branches to be in long mode (MIPS/PPC only)")
+DEFINE_STRING(mcpu, "auto", "enable optimization for specific cpu")
 
 // bootstrapper.cc
 DEFINE_STRING(expose_natives_as, NULL, "expose natives in global object")
index 9db432e5174b8dd9f871dc668485413f84f65b74..4b9f79b9e8b09afc6169930f2caded85a1650076 100644 (file)
@@ -609,6 +609,7 @@ enum CpuFeature {
   SAHF,
   AVX,
   FMA3,
+  ATOM,
   // ARM
   VFP3,
   ARMv7,
index 86a77f964053ea4d221f752ffb5c3a489265fcb7..9815f01b2ca7ab2cd15fbd1a09375347a60aeb50 100644 (file)
@@ -92,14 +92,20 @@ void CpuFeatures::ProbeImpl(bool cross_compile) {
   if (cpu.has_sse3() && FLAG_enable_sse3) supported_ |= 1u << SSE3;
   if (cpu.has_avx() && EnableAVX()) supported_ |= 1u << AVX;
   if (cpu.has_fma3() && FLAG_enable_fma3) supported_ |= 1u << FMA3;
+  if (strcmp(FLAG_mcpu, "auto") == 0) {
+    if (cpu.is_atom()) supported_ |= 1u << ATOM;
+  } else if (strcmp(FLAG_mcpu, "atom") == 0) {
+    supported_ |= 1u << ATOM;
+  }
 }
 
 
 void CpuFeatures::PrintTarget() { }
 void CpuFeatures::PrintFeatures() {
-  printf("SSE3=%d SSE4_1=%d AVX=%d FMA3=%d\n", CpuFeatures::IsSupported(SSE3),
-         CpuFeatures::IsSupported(SSE4_1), CpuFeatures::IsSupported(AVX),
-         CpuFeatures::IsSupported(FMA3));
+  printf("SSE3=%d SSE4_1=%d AVX=%d FMA3=%d ATOM=%d\n",
+         CpuFeatures::IsSupported(SSE3), CpuFeatures::IsSupported(SSE4_1),
+         CpuFeatures::IsSupported(AVX), CpuFeatures::IsSupported(FMA3),
+         CpuFeatures::IsSupported(ATOM));
 }
 
 
index 96422f6863fa86b90b655f3568680a48e61f6731..e4d099392c1ceae5da6eea3389018e18d6dbea81 100644 (file)
@@ -60,15 +60,20 @@ void CpuFeatures::ProbeImpl(bool cross_compile) {
   if (cpu.has_sahf() && FLAG_enable_sahf) supported_ |= 1u << SAHF;
   if (cpu.has_avx() && EnableAVX()) supported_ |= 1u << AVX;
   if (cpu.has_fma3() && FLAG_enable_fma3) supported_ |= 1u << FMA3;
+  if (strcmp(FLAG_mcpu, "auto") == 0) {
+    if (cpu.is_atom()) supported_ |= 1u << ATOM;
+  } else if (strcmp(FLAG_mcpu, "atom") == 0) {
+    supported_ |= 1u << ATOM;
+  }
 }
 
 
 void CpuFeatures::PrintTarget() { }
 void CpuFeatures::PrintFeatures() {
-  printf("SSE3=%d SSE4_1=%d SAHF=%d AVX=%d FMA3=%d\n",
+  printf("SSE3=%d SSE4_1=%d SAHF=%d AVX=%d FMA3=%d ATOM=%d\n",
          CpuFeatures::IsSupported(SSE3), CpuFeatures::IsSupported(SSE4_1),
          CpuFeatures::IsSupported(SAHF), CpuFeatures::IsSupported(AVX),
-         CpuFeatures::IsSupported(FMA3));
+         CpuFeatures::IsSupported(FMA3), CpuFeatures::IsSupported(ATOM));
 }
 
 
index 97e5690c8dcf3a6b0a6c9aae4107ad57ffb89565..7a9319bfa1c7ec367e6afda3c69c64af83af805d 100644 (file)
@@ -3068,7 +3068,7 @@ void MacroAssembler::Call(ExternalReference ext) {
 
 
 void MacroAssembler::Call(const Operand& op) {
-  if (kPointerSize == kInt64Size) {
+  if (kPointerSize == kInt64Size && !CpuFeatures::IsSupported(ATOM)) {
     call(op);
   } else {
     movp(kScratchRegister, op);