11cb0ef41Sopenharmony_ci// Copyright 2014 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_COMPILER_BACKEND_GAP_RESOLVER_H_
61cb0ef41Sopenharmony_ci#define V8_COMPILER_BACKEND_GAP_RESOLVER_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "src/compiler/backend/instruction.h"
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_cinamespace v8 {
111cb0ef41Sopenharmony_cinamespace internal {
121cb0ef41Sopenharmony_cinamespace compiler {
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciclass GapResolver final {
151cb0ef41Sopenharmony_ci public:
161cb0ef41Sopenharmony_ci  // Interface used by the gap resolver to emit moves and swaps.
171cb0ef41Sopenharmony_ci  class Assembler {
181cb0ef41Sopenharmony_ci   public:
191cb0ef41Sopenharmony_ci    virtual ~Assembler() = default;
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci    // Assemble move.
221cb0ef41Sopenharmony_ci    virtual void AssembleMove(InstructionOperand* source,
231cb0ef41Sopenharmony_ci                              InstructionOperand* destination) = 0;
241cb0ef41Sopenharmony_ci    // Assemble swap.
251cb0ef41Sopenharmony_ci    virtual void AssembleSwap(InstructionOperand* source,
261cb0ef41Sopenharmony_ci                              InstructionOperand* destination) = 0;
271cb0ef41Sopenharmony_ci  };
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci  explicit GapResolver(Assembler* assembler)
301cb0ef41Sopenharmony_ci      : assembler_(assembler), split_rep_(MachineRepresentation::kSimd128) {}
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci  // Resolve a set of parallel moves, emitting assembler instructions.
331cb0ef41Sopenharmony_ci  V8_EXPORT_PRIVATE void Resolve(ParallelMove* parallel_move);
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ci private:
361cb0ef41Sopenharmony_ci  // Performs the given move, possibly performing other moves to unblock the
371cb0ef41Sopenharmony_ci  // destination operand.
381cb0ef41Sopenharmony_ci  void PerformMove(ParallelMove* moves, MoveOperands* move);
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ci  // Assembler used to emit moves and save registers.
411cb0ef41Sopenharmony_ci  Assembler* const assembler_;
421cb0ef41Sopenharmony_ci
431cb0ef41Sopenharmony_ci  // While resolving moves, the largest FP representation that can be moved.
441cb0ef41Sopenharmony_ci  // Any larger moves must be split into an equivalent series of moves of this
451cb0ef41Sopenharmony_ci  // representation.
461cb0ef41Sopenharmony_ci  MachineRepresentation split_rep_;
471cb0ef41Sopenharmony_ci};
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ci}  // namespace compiler
501cb0ef41Sopenharmony_ci}  // namespace internal
511cb0ef41Sopenharmony_ci}  // namespace v8
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_ci#endif  // V8_COMPILER_BACKEND_GAP_RESOLVER_H_
54