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_JUMP_THREADING_H_
61cb0ef41Sopenharmony_ci#define V8_COMPILER_BACKEND_JUMP_THREADING_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_ci// Forwards jumps to empty basic blocks that end with a second jump to the
151cb0ef41Sopenharmony_ci// destination of the second jump, transitively.
161cb0ef41Sopenharmony_ciclass V8_EXPORT_PRIVATE JumpThreading {
171cb0ef41Sopenharmony_ci public:
181cb0ef41Sopenharmony_ci  // Compute the forwarding map of basic blocks to their ultimate destination.
191cb0ef41Sopenharmony_ci  // Returns {true} if there is at least one block that is forwarded.
201cb0ef41Sopenharmony_ci  static bool ComputeForwarding(Zone* local_zone, ZoneVector<RpoNumber>* result,
211cb0ef41Sopenharmony_ci                                InstructionSequence* code, bool frame_at_start);
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ci  // Rewrite the instructions to forward jumps and branches.
241cb0ef41Sopenharmony_ci  // May also negate some branches.
251cb0ef41Sopenharmony_ci  static void ApplyForwarding(Zone* local_zone,
261cb0ef41Sopenharmony_ci                              ZoneVector<RpoNumber> const& forwarding,
271cb0ef41Sopenharmony_ci                              InstructionSequence* code);
281cb0ef41Sopenharmony_ci};
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci}  // namespace compiler
311cb0ef41Sopenharmony_ci}  // namespace internal
321cb0ef41Sopenharmony_ci}  // namespace v8
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ci#endif  // V8_COMPILER_BACKEND_JUMP_THREADING_H_
35