Home | History | Annotate | Download | only in ia32
      1 // Copyright 2011 the V8 project authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef V8_IA32_LITHIUM_GAP_RESOLVER_IA32_H_
      6 #define V8_IA32_LITHIUM_GAP_RESOLVER_IA32_H_
      7 
      8 #include "src/v8.h"
      9 
     10 #include "src/lithium.h"
     11 
     12 namespace v8 {
     13 namespace internal {
     14 
     15 class LCodeGen;
     16 class LGapResolver;
     17 
     18 class LGapResolver V8_FINAL BASE_EMBEDDED {
     19  public:
     20   explicit LGapResolver(LCodeGen* owner);
     21 
     22   // Resolve a set of parallel moves, emitting assembler instructions.
     23   void Resolve(LParallelMove* parallel_move);
     24 
     25  private:
     26   // Build the initial list of moves.
     27   void BuildInitialMoveList(LParallelMove* parallel_move);
     28 
     29   // Perform the move at the moves_ index in question (possibly requiring
     30   // other moves to satisfy dependencies).
     31   void PerformMove(int index);
     32 
     33   // Emit any code necessary at the end of a gap move.
     34   void Finish();
     35 
     36   // Add or delete a move from the move graph without emitting any code.
     37   // Used to build up the graph and remove trivial moves.
     38   void AddMove(LMoveOperands move);
     39   void RemoveMove(int index);
     40 
     41   // Report the count of uses of operand as a source in a not-yet-performed
     42   // move.  Used to rebuild use counts.
     43   int CountSourceUses(LOperand* operand);
     44 
     45   // Emit a move and remove it from the move graph.
     46   void EmitMove(int index);
     47 
     48   // Execute a move by emitting a swap of two operands.  The move from
     49   // source to destination is removed from the move graph.
     50   void EmitSwap(int index);
     51 
     52   // Ensure that the given operand is not spilled.
     53   void EnsureRestored(LOperand* operand);
     54 
     55   // Return a register that can be used as a temp register, spilling
     56   // something if necessary.
     57   Register EnsureTempRegister();
     58 
     59   // Return a known free register different from the given one (which could
     60   // be no_reg---returning any free register), or no_reg if there is no such
     61   // register.
     62   Register GetFreeRegisterNot(Register reg);
     63 
     64   // Verify that the state is the initial one, ready to resolve a single
     65   // parallel move.
     66   bool HasBeenReset();
     67 
     68   // Verify the move list before performing moves.
     69   void Verify();
     70 
     71   LCodeGen* cgen_;
     72 
     73   // List of moves not yet resolved.
     74   ZoneList<LMoveOperands> moves_;
     75 
     76   // Source and destination use counts for the general purpose registers.
     77   int source_uses_[Register::kMaxNumAllocatableRegisters];
     78   int destination_uses_[Register::kMaxNumAllocatableRegisters];
     79 
     80   // If we had to spill on demand, the currently spilled register's
     81   // allocation index.
     82   int spilled_register_;
     83 };
     84 
     85 } }  // namespace v8::internal
     86 
     87 #endif  // V8_IA32_LITHIUM_GAP_RESOLVER_IA32_H_
     88