blob: 428558d42dad195e2d6919ccb88f9e6677967439 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// Copyright 2014 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_COMPILER_VERIFIER_H_
6#define V8_COMPILER_VERIFIER_H_
7
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00008#include "src/base/macros.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +00009
10namespace v8 {
11namespace internal {
12namespace compiler {
13
14class Graph;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000015class Edge;
16class Node;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000017class Schedule;
18
19// Verifies properties of a graph, such as the well-formedness of inputs to
20// each node, etc.
21class Verifier {
22 public:
Emily Bernierd0a1eb72015-03-24 16:35:39 -040023 enum Typing { TYPED, UNTYPED };
24
25 static void Run(Graph* graph, Typing typing = TYPED);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000026
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000027#ifdef DEBUG
28 // Verifies consistency of node inputs and uses:
29 // - node inputs should agree with the input count computed from
30 // the node's operator.
31 // - effect inputs should have effect outputs.
32 // - control inputs should have control outputs.
33 // - frame state inputs should be frame states.
34 // - if the node has control uses, it should produce control.
35 // - if the node has effect uses, it should produce effect.
36 // - if the node has frame state uses, it must be a frame state.
37 static void VerifyNode(Node* node);
38
39 // Verify that {replacement} has the required outputs
40 // (effect, control or frame state) to be used as an input for {edge}.
41 static void VerifyEdgeInputReplacement(const Edge& edge,
42 const Node* replacement);
43#else
44 static void VerifyNode(Node* node) {}
45 static void VerifyEdgeInputReplacement(const Edge& edge,
46 const Node* replacement) {}
47#endif // DEBUG
48
Ben Murdochb8a8cc12014-11-26 15:28:44 +000049 private:
50 class Visitor;
51 DISALLOW_COPY_AND_ASSIGN(Verifier);
52};
53
54// Verifies properties of a schedule, such as dominance, phi placement, etc.
55class ScheduleVerifier {
56 public:
57 static void Run(Schedule* schedule);
58};
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000059} // namespace compiler
60} // namespace internal
61} // namespace v8
Ben Murdochb8a8cc12014-11-26 15:28:44 +000062
63#endif // V8_COMPILER_VERIFIER_H_