forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssa-tmp.h
102 lines (87 loc) · 3.99 KB
/
ssa-tmp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#pragma once
#include "hphp/runtime/vm/jit/type.h"
#include "hphp/runtime/vm/jit/types.h"
#include "hphp/runtime/base/type-variant.h"
namespace HPHP { namespace jit {
struct IRInstruction;
struct IRUnit;
namespace irgen { struct IRBuilder; }
struct SSATmp {
uint32_t id() const { return m_id; }
IRInstruction* inst() const { return m_inst; }
void setInstruction(IRInstruction* i, int dstId = 0);
Type type() const { return m_type; }
void setType(Type t) { m_type = t; }
std::string toString() const;
// Convenience wrapper for type().hasConstVal(...). See type.h for details.
template<typename... Args>
bool hasConstVal(Args&&... args) const {
return type().hasConstVal(std::forward<Args>(args)...);
}
/*
* For SSATmps with a compile-time constant value, the following
* functions allow accessing it.
*
* Pre: inst() && hasConstVal()
*/
bool boolVal() const { return type().boolVal(); }
int64_t intVal() const { return type().intVal(); }
uint64_t rawVal() const { return type().rawVal(); }
double dblVal() const { return type().dblVal(); }
const StringData* strVal() const { return type().strVal(); }
const ArrayData* arrVal() const { return type().arrVal(); }
const ArrayData* shapeVal() const { return type().shapeVal(); }
const ArrayData* vecVal() const { return type().vecVal(); }
const ArrayData* dictVal() const { return type().dictVal(); }
const ArrayData* keysetVal() const { return type().keysetVal(); }
const ArrayData* arrLikeVal() const { return type().arrLikeVal(); }
const Func* funcVal() const { return type().funcVal(); }
const Class* clsVal() const { return type().clsVal(); }
LazyClassData lclsVal() const { return type().lclsVal(); }
const RecordDesc* recVal() const { return type().recVal(); }
const ClsMethDataRef clsmethVal() const { return type().clsmethVal(); }
rds::Handle rdsHandleVal() const { return type().rdsHandleVal(); }
TCA tcaVal() const { return type().tcaVal(); }
Variant variantVal() const;
/*
* @returns: type() <= tag
*
* This should be used for most checks on the types of IRInstruction sources.
*/
bool isA(Type tag) const {
return type() <= tag;
}
/*
* The maximum number of words this SSATmp may need allocated.
* This is based on the type of the temporary (some types never have
* regs, some have two, etc).
*/
int numWords() const;
private:
friend struct IRUnit;
friend struct irgen::IRBuilder;
// May only be created via IRUnit. Note that this class is never
// destructed, so don't add complex members.
SSATmp(uint32_t opndId, IRInstruction* inst, int dstId = 0);
SSATmp(const SSATmp&) = delete;
SSATmp& operator=(const SSATmp&) = delete;
IRInstruction* m_inst;
Type m_type; // type when defined
const uint32_t m_id;
};
}}