Revision: 6242
Author: [email protected]
Date: Mon Jan 10 03:31:21 2011
Log: Crankshaft: Move LParallelMove to lithium.h, add LGap to lithium-x64.h.
Review URL: http://codereview.chromium.org/6132002
http://code.google.com/p/v8/source/detail?r=6242

Modified:
 /branches/bleeding_edge/src/arm/lithium-arm.cc
 /branches/bleeding_edge/src/arm/lithium-arm.h
 /branches/bleeding_edge/src/ia32/lithium-ia32.cc
 /branches/bleeding_edge/src/ia32/lithium-ia32.h
 /branches/bleeding_edge/src/lithium.cc
 /branches/bleeding_edge/src/lithium.h
 /branches/bleeding_edge/src/x64/lithium-x64.cc
 /branches/bleeding_edge/src/x64/lithium-x64.h

=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc      Fri Jan  7 05:44:05 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc      Mon Jan 10 03:31:21 2011
@@ -91,32 +91,6 @@
     stream->Add(" Dead block replaced with B%d", rep->block_id());
   }
 }
-
-
-bool LParallelMove::IsRedundant() const {
-  for (int i = 0; i < move_operands_.length(); ++i) {
-    if (!move_operands_[i].IsRedundant()) return false;
-  }
-  return true;
-}
-
-
-void LParallelMove::PrintDataTo(StringStream* stream) const {
-  for (int i = move_operands_.length() - 1; i >= 0; --i) {
-    if (!move_operands_[i].IsEliminated()) {
-      LOperand* from = move_operands_[i].from();
-      LOperand* to = move_operands_[i].to();
-      if (from->Equals(to)) {
-        to->PrintTo(stream);
-      } else {
-        to->PrintTo(stream);
-        stream->Add(" = ");
-        from->PrintTo(stream);
-      }
-      stream->Add("; ");
-    }
-  }
-}


 bool LGap::IsRedundant() const {
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.h       Fri Jan  7 03:49:22 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.h       Mon Jan 10 03:31:21 2011
@@ -332,27 +332,6 @@
 };


-class LParallelMove : public ZoneObject {
- public:
-  LParallelMove() : move_operands_(4) { }
-
-  void AddMove(LOperand* from, LOperand* to) {
-    move_operands_.Add(LMoveOperands(from, to));
-  }
-
-  bool IsRedundant() const;
-
-  const ZoneList<LMoveOperands>* move_operands() const {
-    return &move_operands_;
-  }
-
-  void PrintDataTo(StringStream* stream) const;
-
- private:
-  ZoneList<LMoveOperands> move_operands_;
-};
-
-
 class LGap: public LInstruction {
  public:
   explicit LGap(HBasicBlock* block)
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Fri Jan 7 03:49:22 2011 +++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Mon Jan 10 03:31:21 2011
@@ -91,32 +91,6 @@
     stream->Add(" Dead block replaced with B%d", rep->block_id());
   }
 }
-
-
-bool LParallelMove::IsRedundant() const {
-  for (int i = 0; i < move_operands_.length(); ++i) {
-    if (!move_operands_[i].IsRedundant()) return false;
-  }
-  return true;
-}
-
-
-void LParallelMove::PrintDataTo(StringStream* stream) const {
-  for (int i = move_operands_.length() - 1; i >= 0; --i) {
-    if (!move_operands_[i].IsEliminated()) {
-      LOperand* from = move_operands_[i].from();
-      LOperand* to = move_operands_[i].to();
-      if (from->Equals(to)) {
-        to->PrintTo(stream);
-      } else {
-        to->PrintTo(stream);
-        stream->Add(" = ");
-        from->PrintTo(stream);
-      }
-      stream->Add("; ");
-    }
-  }
-}


 bool LGap::IsRedundant() const {
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.h     Fri Jan  7 03:49:22 2011
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.h     Mon Jan 10 03:31:21 2011
@@ -335,27 +335,6 @@
 };


-class LParallelMove : public ZoneObject {
- public:
-  LParallelMove() : move_operands_(4) { }
-
-  void AddMove(LOperand* from, LOperand* to) {
-    move_operands_.Add(LMoveOperands(from, to));
-  }
-
-  bool IsRedundant() const;
-
-  const ZoneList<LMoveOperands>* move_operands() const {
-    return &move_operands_;
-  }
-
-  void PrintDataTo(StringStream* stream) const;
-
- private:
-  ZoneList<LMoveOperands> move_operands_;
-};
-
-
 class LGap: public LInstruction {
  public:
   explicit LGap(HBasicBlock* block)
=======================================
--- /branches/bleeding_edge/src/lithium.cc      Fri Jan  7 03:49:22 2011
+++ /branches/bleeding_edge/src/lithium.cc      Mon Jan 10 03:31:21 2011
@@ -174,6 +174,32 @@
   nodes_.Add(result);
   return result;
 }
+
+
+bool LParallelMove::IsRedundant() const {
+  for (int i = 0; i < move_operands_.length(); ++i) {
+    if (!move_operands_[i].IsRedundant()) return false;
+  }
+  return true;
+}
+
+
+void LParallelMove::PrintDataTo(StringStream* stream) const {
+  for (int i = move_operands_.length() - 1; i >= 0; --i) {
+    if (!move_operands_[i].IsEliminated()) {
+      LOperand* from = move_operands_[i].from();
+      LOperand* to = move_operands_[i].to();
+      if (from->Equals(to)) {
+        to->PrintTo(stream);
+      } else {
+        to->PrintTo(stream);
+        stream->Add(" = ");
+        from->PrintTo(stream);
+      }
+      stream->Add("; ");
+    }
+  }
+}


 } }  // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/lithium.h       Fri Jan  7 03:49:22 2011
+++ /branches/bleeding_edge/src/lithium.h       Mon Jan 10 03:31:21 2011
@@ -58,6 +58,27 @@
 };


+class LParallelMove : public ZoneObject {
+ public:
+  LParallelMove() : move_operands_(4) { }
+
+  void AddMove(LOperand* from, LOperand* to) {
+    move_operands_.Add(LMoveOperands(from, to));
+  }
+
+  bool IsRedundant() const;
+
+  const ZoneList<LMoveOperands>* move_operands() const {
+    return &move_operands_;
+  }
+
+  void PrintDataTo(StringStream* stream) const;
+
+ private:
+  ZoneList<LMoveOperands> move_operands_;
+};
+
+
 } }  // namespace v8::internal

 #endif  // V8_LITHIUM_H_
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc      Fri Jan  7 03:49:22 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc      Mon Jan 10 03:31:21 2011
@@ -31,6 +31,28 @@
 namespace v8 {
 namespace internal {

+bool LGap::IsRedundant() const {
+  for (int i = 0; i < 4; i++) {
+    if (parallel_moves_[i] != NULL && !parallel_moves_[i]->IsRedundant()) {
+      return false;
+    }
+  }
+
+  return true;
+}
+
+
+void LGap::PrintDataTo(StringStream* stream) const {
+  for (int i = 0; i < 4; i++) {
+    stream->Add("(");
+    if (parallel_moves_[i] != NULL) {
+      parallel_moves_[i]->PrintDataTo(stream);
+    }
+    stream->Add(") ");
+  }
+}
+
+
 LChunk* LChunkBuilder::Build() {
   ASSERT(is_unused());
   chunk_ = new LChunk(graph());
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.h       Fri Jan  7 03:49:22 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.h       Mon Jan 10 03:31:21 2011
@@ -41,13 +41,44 @@
 class LEnvironment;
 class Translation;

+
+// Type hierarchy:
+//
+// LInstruction
+//   LGap
+
+#define LITHIUM_ALL_INSTRUCTION_LIST(V)         \
+  LITHIUM_CONCRETE_INSTRUCTION_LIST(V)
+
+#define LITHIUM_CONCRETE_INSTRUCTION_LIST(V)    \
+  V(Gap)
+
+
+#define DECLARE_INSTRUCTION(type)                \
+  virtual bool Is##type() const { return true; } \
+  static L##type* cast(LInstruction* instr) {    \
+    ASSERT(instr->Is##type());                   \
+    return reinterpret_cast<L##type*>(instr);    \
+  }
+
+
+#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic)        \
+  virtual void CompileToNative(LCodeGen* generator);        \
+  virtual const char* Mnemonic() const { return mnemonic; } \
+  DECLARE_INSTRUCTION(type)
+
+
+#define DECLARE_HYDROGEN_ACCESSOR(type)     \
+  H##type* hydrogen() const {               \
+    return H##type::cast(hydrogen_value()); \
+  }
+
+
 class LInstruction: public ZoneObject {
  public:
-  LInstruction() { }
+  LInstruction()
+      : hydrogen_value_(NULL) { }
   virtual ~LInstruction() { }
-
-  virtual void PrintTo(StringStream* stream) const { UNIMPLEMENTED(); }
-  virtual void PrintDataTo(StringStream* stream) const { }

   // Predicates should be generated by macro as in lithium-ia32.h.
   virtual bool IsLabel() const {
@@ -58,6 +89,17 @@
     UNIMPLEMENTED();
     return false;
   }
+
+  virtual void CompileToNative(LCodeGen* generator) = 0;
+  virtual const char* Mnemonic() const = 0;
+  virtual void PrintTo(StringStream* stream) const;
+  virtual void PrintDataTo(StringStream* stream) const { }
+
+  // Declare virtual type testers.
+#define DECLARE_DO(type) virtual bool Is##type() const { return false; }
+  LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO)
+#undef DECLARE_DO
+  virtual bool IsControl() const { return false; }

   void set_environment(LEnvironment* env) { environment_.set(env); }
   LEnvironment* environment() const { return environment_.get(); }
@@ -93,32 +135,22 @@
 };


-class LParallelMove : public ZoneObject {
+class LGap: public LInstruction {
  public:
-  LParallelMove() : move_operands_(4) { }
-
-  void AddMove(LOperand* from, LOperand* to) {
-    UNIMPLEMENTED();
+  explicit LGap(HBasicBlock* block)
+      : block_(block) {
+    parallel_moves_[BEFORE] = NULL;
+    parallel_moves_[START] = NULL;
+    parallel_moves_[END] = NULL;
+    parallel_moves_[AFTER] = NULL;
   }

-  const ZoneList<LMoveOperands>* move_operands() const {
-    UNIMPLEMENTED();
-    return NULL;
-  }
-
- private:
-  ZoneList<LMoveOperands> move_operands_;
-};
-
-
-class LGap: public LInstruction {
- public:
-  explicit LGap(HBasicBlock* block) { }
-
-  HBasicBlock* block() const {
-    UNIMPLEMENTED();
-    return NULL;
-  }
+  DECLARE_CONCRETE_INSTRUCTION(Gap, "gap")
+  virtual void PrintDataTo(StringStream* stream) const;
+
+  bool IsRedundant() const;
+
+  HBasicBlock* block() const { return block_; }

   enum InnerPosition {
     BEFORE,
@@ -130,13 +162,12 @@
   };

   LParallelMove* GetOrCreateParallelMove(InnerPosition pos) {
-    UNIMPLEMENTED();
-    return NULL;
+ if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove;
+    return parallel_moves_[pos];
   }

   LParallelMove* GetParallelMove(InnerPosition pos)  {
-    UNIMPLEMENTED();
-    return NULL;
+    return parallel_moves_[pos];
   }

  private:

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to