2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present 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_TRANS_CFG_H_
18 #define incl_HPHP_TRANS_CFG_H_
22 #include "hphp/runtime/vm/jit/translator.h"
23 #include "hphp/runtime/vm/jit/translator-inline.h"
25 namespace HPHP
{ namespace jit
{
28 * A dynamic control-flow graph of single-block translations.
32 static const int64_t kUnknownWeight
= -1;
34 Arc(TransID src
, TransID dst
, int64_t w
)
40 TransID
src() const { return m_src
; }
41 TransID
dst() const { return m_dst
; }
42 int64_t weight() const { return m_weight
; }
43 bool guessed() const { return m_guessed
; }
44 void setWeight(int64_t w
) { m_weight
= w
; }
45 void setGuessed() { m_guessed
= true; }
50 bool m_guessed
; // whether or not m_weight was guessed
53 typedef std::vector
<Arc
*> ArcPtrVec
;
54 typedef hphp_hash_set
<Arc
*, pointer_hash
<Arc
>> ArcPtrSet
;
57 Node(TransID id
, int64_t w
)
63 TransID
transId() const { return m_id
; }
64 int64_t weight() const { return m_weight
; }
65 const ArcPtrVec
& inArcs() const { return m_inArcs
; }
66 const ArcPtrVec
& outArcs() const { return m_outArcs
; }
67 void addInArc (Arc
* arc
) { m_inArcs
.push_back(arc
); }
68 void addOutArc(Arc
* arc
) { m_outArcs
.push_back(arc
); }
77 TransCFG(FuncId funcId
,
78 const ProfData
* profData
,
79 bool inlining
= false);
81 const std::vector
<TransID
>& nodes() const { return m_transIds
; }
82 ArcPtrVec
arcs() const;
83 int64_t weight(TransID id
) const;
84 void setNodeWeight(TransID id
, int64_t weight
);
85 const ArcPtrVec
& inArcs(TransID id
) const;
86 const ArcPtrVec
& outArcs(TransID id
) const;
87 void addNode(TransID id
, int64_t weight
);
88 bool hasNode(TransID id
) const;
89 void addArc(TransID srcId
, TransID dstId
,
91 bool hasArc(TransID srcId
, TransID dstId
) const;
92 void print(std::ostream
& out
,
94 const ProfData
* profData
) const;
97 std::vector
<TransID
> m_transIds
; // vector of TransIDs in the graph
98 std::vector
<Node
> m_nodeInfo
; // info about each node
99 hphp_hash_map
<TransID
, size_t> m_idToIdx
; // map from TransIDs to indices
103 TransIDSet
findPredTrans(const RegionDesc
& rd
, const ProfData
* profData
);