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_JIT_TYPE_SOURCE_H_
18 #define incl_HPHP_JIT_TYPE_SOURCE_H_
20 #include "hphp/runtime/vm/jit/containers.h"
21 #include "hphp/util/assertions.h"
25 namespace HPHP
{ namespace jit
{
31 * The source of a local's type. Either the current value or a guard.
33 * Used for guard relaxation, as we're constraining a value, local, or stack
34 * slot, and we need to know what guards that type came from.
37 enum class Kind
: uint8_t {
42 static TypeSource
makeValue(SSATmp
* value
) {
46 src
.kind
= Kind::Value
;
50 static TypeSource
makeGuard(const IRInstruction
* guard
) {
54 src
.kind
= Kind::Guard
;
58 bool isGuard() const { return kind
== Kind::Guard
; }
59 bool isValue() const { return kind
== Kind::Value
; }
61 bool operator==(const TypeSource
& rhs
) const {
62 return kind
== rhs
.kind
&& value
== rhs
.value
;
64 bool operator!=(const TypeSource
& rhs
) const {
65 return !operator==(rhs
);
67 bool operator<(const TypeSource
& rhs
) const;
69 std::string
toString() const;
73 SSATmp
* value
{nullptr};
74 const IRInstruction
* guard
;
80 typedef jit::flat_set
<TypeSource
> TypeSourceSet
;
82 std::string
show(const TypeSource
&);
83 std::string
show(const TypeSourceSet
&);