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_TRANSLATOR_INL_H_
18 #error "translator-inl.h should only be included by translator.h"
23 ///////////////////////////////////////////////////////////////////////////////
24 // Control flow information.
26 inline ControlFlowInfo
opcodeControlFlowInfo(const Op op
, bool inlining
) {
39 case Op::RetCSuspended
:
42 case Op::IterInit
: // May branch to fail case.
43 case Op::LIterInit
: // Ditto
44 case Op::IterNext
: // Ditto
45 case Op::LIterNext
: // Ditto
48 case Op::BreakTraceHint
:
50 case Op::MemoGetEager
:
51 return ControlFlowInfo::BreaksBB
;
54 return inlining
? ControlFlowInfo::ChangesPC
: ControlFlowInfo::BreaksBB
;
55 case Op::FCallClsMethod
:
56 case Op::FCallClsMethodM
:
57 case Op::FCallClsMethodD
:
58 case Op::FCallClsMethodS
:
59 case Op::FCallClsMethodSD
:
63 case Op::FCallObjMethod
:
64 case Op::FCallObjMethodD
:
67 return ControlFlowInfo::ChangesPC
;
69 return ControlFlowInfo::None
;
73 inline bool opcodeChangesPC(const Op op
) {
74 return opcodeControlFlowInfo(op
, false) >= ControlFlowInfo::ChangesPC
;
77 inline bool opcodeBreaksBB(const Op op
, bool inlining
) {
78 if (op
== Op::ClsCns
|| op
== Op::CGetS
) {
79 // side exits if it misses in the RDS, and may produce an overly
80 // specific type without guarding if the class comes from an
81 // object (during form_region, the class will appear to be a
82 // specific type, but during irgen, it will probably be a generic
85 // We can't mark it BreaksBB because BreaksBB => opcodeChangesPC
88 return opcodeControlFlowInfo(op
, inlining
) == ControlFlowInfo::BreaksBB
;
91 inline bool opcodeIgnoresInnerType(const Op op
) {
94 case Op::RetCSuspended
:
102 ///////////////////////////////////////////////////////////////////////////////
103 // Input and output information.
105 inline std::string
InputInfo::pretty() const {
106 std::string p
= show(loc
);
107 if (dontBreak
) p
+= ":dc";
108 if (dontGuard
) p
+= ":dg";
112 inline std::string
InputInfoVec::pretty() const {
114 for (size_t i
= 0; i
< size(); i
++) {
115 retval
+= (*this)[i
].pretty();
116 if (i
!= size() - 1) {
117 retval
+= std::string(" ");
123 ///////////////////////////////////////////////////////////////////////////////
126 namespace InstrFlags
{
128 inline Operands
operator|(const Operands
& l
, const Operands
& r
) {
129 return Operands(int(r
) | int(l
));
134 ///////////////////////////////////////////////////////////////////////////////