forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedge.h
74 lines (58 loc) · 2.45 KB
/
edge.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#pragma once
#include <boost/intrusive/list.hpp>
#include "hphp/runtime/vm/jit/containers.h"
namespace HPHP::jit {
struct Block;
struct IRInstruction;
/*
* An Edge represents a control-flow edge as an encapsulated pointer to a
* successor block that maintains a list of predecessors of each block.
* The predecessor list is updated by calling setTo().
*/
struct Edge {
Edge() {}
Edge(const Edge&) = delete;
explicit Edge(IRInstruction* inst, Block* to) : m_inst(inst) { setTo(to); }
// The instruction that owns this edge
IRInstruction* inst() const { return m_inst; }
void setInst(IRInstruction* inst) { m_inst = inst; };
// The block this edge takes us to. Changing this property updates
// the affected Block's preds property.
Block* to() const { return m_to; }
void setTo(Block* to);
// The block this edge comes from.
Block* from() const;
// set the to field but don't update any predecessor lists. Only used
// for transient instructions.
void setTransientTo(Block* to) { m_to = to; }
// Use to/from accessors to access or mutate pointers
Edge& operator=(const Edge&) = delete;
private:
Block* m_to{nullptr};
IRInstruction* m_inst{nullptr};
public:
boost::intrusive::list_member_hook<> m_node; // for Block::m_preds
};
using EdgeHookOption = boost::intrusive::member_hook<
Edge,
boost::intrusive::list_member_hook<>,
&Edge::m_node
>;
using EdgeList = boost::intrusive::list<Edge, EdgeHookOption>;
using EdgeSet = jit::flat_set<Edge*>;
}