Remove SpillFrame, merge its memory effects into CallEffects and InlineEnterEffects
[hiphop-php.git] / hphp / runtime / vm / jit / trans-cfg.h
blob5ecc1dbd059c5e155a15b1de2edfe9dd05dc8987
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
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_
20 #include <vector>
22 #include "hphp/runtime/vm/jit/translator.h"
23 #include "hphp/runtime/vm/jit/translator-inline.h"
25 namespace HPHP { namespace jit {
27 /**
28 * A dynamic control-flow graph of single-block translations.
30 struct TransCFG {
31 struct Arc {
32 static const int64_t kUnknownWeight = -1;
34 Arc(TransID src, TransID dst, int64_t w)
35 : m_src(src)
36 , m_dst(dst)
37 , m_weight(w)
38 , m_guessed(false)
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; }
46 private:
47 TransID m_src;
48 TransID m_dst;
49 int64_t m_weight;
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;
56 struct Node {
57 Node(TransID id, int64_t w)
58 : m_id(id)
59 , m_weight(w)
61 ~Node();
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); }
69 private:
70 TransID m_id;
71 int64_t m_weight;
72 ArcPtrVec m_inArcs;
73 ArcPtrVec m_outArcs;
76 TransCFG() {}
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,
90 int64_t weight=0);
91 bool hasArc(TransID srcId, TransID dstId) const;
92 void print(std::ostream& out,
93 FuncId funcId,
94 const ProfData* profData) const;
96 private:
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
100 // in m_nodeInfo
103 TransIDSet findPredTrans(const RegionDesc& rd, const ProfData* profData);
107 #endif