5 #include "src/compiler/graph.h" 9 #include "src/base/bits.h" 10 #include "src/compiler/graph-visualizer.h" 11 #include "src/compiler/node-properties.h" 12 #include "src/compiler/node.h" 13 #include "src/compiler/verifier.h" 19 Graph::Graph(Zone* zone)
28 void Graph::Decorate(Node* node) {
29 for (GraphDecorator*
const decorator : decorators_) {
30 decorator->Decorate(node);
35 void Graph::AddDecorator(GraphDecorator* decorator) {
36 decorators_.push_back(decorator);
40 void Graph::RemoveDecorator(GraphDecorator* decorator) {
41 auto const it = std::find(decorators_.begin(), decorators_.end(), decorator);
42 DCHECK(it != decorators_.end());
43 decorators_.erase(it);
46 Node* Graph::NewNode(
const Operator* op,
int input_count, Node*
const* inputs,
48 Node* node = NewNodeUnchecked(op, input_count, inputs, incomplete);
49 Verifier::VerifyNode(node);
53 Node* Graph::NewNodeUnchecked(
const Operator* op,
int input_count,
54 Node*
const* inputs,
bool incomplete) {
56 Node::New(zone(), NextNodeId(), op, input_count, inputs, incomplete);
62 Node* Graph::CloneNode(
const Node* node) {
63 DCHECK_NOT_NULL(node);
64 Node*
const clone = Node::Clone(zone(), NextNodeId(), node);
70 NodeId Graph::NextNodeId() {
71 NodeId
const id = next_node_id_;
72 CHECK(!base::bits::UnsignedAddOverflow32(
id, 1, &next_node_id_));
76 void Graph::Print()
const { StdoutStream{} << AsRPO(*
this); }