10b57cec5SDimitry Andric //===-- VPlanVerifier.h -----------------------------------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric ///
90b57cec5SDimitry Andric /// \file
100b57cec5SDimitry Andric /// This file declares the class VPlanVerifier, which contains utility functions
110b57cec5SDimitry Andric /// to check the consistency of a VPlan. This includes the following kinds of
120b57cec5SDimitry Andric /// invariants:
130b57cec5SDimitry Andric ///
140b57cec5SDimitry Andric /// 1. Region/Block invariants:
150b57cec5SDimitry Andric ///   - Region's entry/exit block must have no predecessors/successors,
160b57cec5SDimitry Andric ///     respectively.
170b57cec5SDimitry Andric ///   - Block's parent must be the region immediately containing the block.
180b57cec5SDimitry Andric ///   - Linked blocks must have a bi-directional link (successor/predecessor).
190b57cec5SDimitry Andric ///   - All predecessors/successors of a block must belong to the same region.
200b57cec5SDimitry Andric ///   - Blocks must have no duplicated successor/predecessor.
210b57cec5SDimitry Andric ///
220b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
230b57cec5SDimitry Andric 
240b57cec5SDimitry Andric #ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANVERIFIER_H
250b57cec5SDimitry Andric #define LLVM_TRANSFORMS_VECTORIZE_VPLANVERIFIER_H
260b57cec5SDimitry Andric 
270b57cec5SDimitry Andric namespace llvm {
285ffd83dbSDimitry Andric class VPRegionBlock;
29349cc55cSDimitry Andric class VPlan;
300b57cec5SDimitry Andric 
315ffd83dbSDimitry Andric /// Struct with utility functions that can be used to check the consistency and
320b57cec5SDimitry Andric /// invariants of a VPlan, including the components of its H-CFG.
335ffd83dbSDimitry Andric struct VPlanVerifier {
340b57cec5SDimitry Andric   /// Verify the invariants of the H-CFG starting from \p TopRegion. The
350b57cec5SDimitry Andric   /// verification process comprises the following steps:
360b57cec5SDimitry Andric   /// 1. Region/Block verification: Check the Region/Block verification
370b57cec5SDimitry Andric   /// invariants for every region in the H-CFG.
380b57cec5SDimitry Andric   void verifyHierarchicalCFG(const VPRegionBlock *TopRegion) const;
39349cc55cSDimitry Andric 
40349cc55cSDimitry Andric   /// Verify invariants for general VPlans. Currently it checks the following:
41349cc55cSDimitry Andric   /// 1. all phi-like recipes must be at the beginning of a block, with no other
42349cc55cSDimitry Andric   /// recipes in between. Note that currently there is still an exception for
43349cc55cSDimitry Andric   /// VPBlendRecipes.
44349cc55cSDimitry Andric   static bool verifyPlanIsValid(const VPlan &Plan);
450b57cec5SDimitry Andric };
460b57cec5SDimitry Andric } // namespace llvm
470b57cec5SDimitry Andric 
480b57cec5SDimitry Andric #endif //LLVM_TRANSFORMS_VECTORIZE_VPLANVERIFIER_H
49