2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2014 Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_VM_EDGE_H_
18 #define incl_HPHP_VM_EDGE_H_
20 #include <boost/intrusive/list.hpp>
21 #include <boost/noncopyable.hpp>
23 namespace HPHP
{ namespace JIT
{
29 * An Edge represents a control-flow edge as an encapsulated pointer to a
30 * successor block that maintains a list of predecessors of each block.
31 * The predecessor list is updated by calling setTo().
33 struct Edge
: private boost::noncopyable
{
34 Edge() : m_to(nullptr), m_inst(nullptr) {}
35 Edge(const Edge
& other
) : m_to(nullptr), m_inst(nullptr) {
38 explicit Edge(IRInstruction
* inst
, Block
* to
) : m_to(nullptr), m_inst(inst
) {
42 // The instruction that owns this edge
43 IRInstruction
* inst() const { return m_inst
; }
44 void setInst(IRInstruction
* inst
) { m_inst
= inst
; };
46 // The block this edge takes us to. Changing this property updates
47 // the affected Block's preds property.
48 Block
* to() const { return m_to
; }
49 void setTo(Block
* to
);
51 // set the to field but don't update any predecessor lists. Only used
52 // for transient instructions.
53 void setTransientTo(Block
* to
) {
57 // Use to/from accessors to access or mutate pointers
58 Edge
& operator=(const Edge
& other
) = delete;
62 IRInstruction
* m_inst
;
64 boost::intrusive::list_member_hook
<> m_node
; // for Block::m_preds
67 typedef boost::intrusive::member_hook
<Edge
,
68 boost::intrusive::list_member_hook
<>,
71 typedef boost::intrusive::list
<Edge
, EdgeHookOption
> EdgeList
;