OLD | NEW |
| (Empty) |
1 // Copyright 2014 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef V8_COMPILER_SIMPLIFIED_NODE_FACTORY_H_ | |
6 #define V8_COMPILER_SIMPLIFIED_NODE_FACTORY_H_ | |
7 | |
8 #include "src/compiler/node.h" | |
9 #include "src/compiler/simplified-operator.h" | |
10 | |
11 namespace v8 { | |
12 namespace internal { | |
13 namespace compiler { | |
14 | |
15 #define SIMPLIFIED() static_cast<NodeFactory*>(this)->simplified() | |
16 #define NEW_NODE_1(op, a) static_cast<NodeFactory*>(this)->NewNode(op, a) | |
17 #define NEW_NODE_2(op, a, b) static_cast<NodeFactory*>(this)->NewNode(op, a, b) | |
18 #define NEW_NODE_3(op, a, b, c) \ | |
19 static_cast<NodeFactory*>(this)->NewNode(op, a, b, c) | |
20 | |
21 template <typename NodeFactory> | |
22 class SimplifiedNodeFactory { | |
23 public: | |
24 Node* BooleanNot(Node* a) { | |
25 return NEW_NODE_1(SIMPLIFIED()->BooleanNot(), a); | |
26 } | |
27 | |
28 Node* NumberEqual(Node* a, Node* b) { | |
29 return NEW_NODE_2(SIMPLIFIED()->NumberEqual(), a, b); | |
30 } | |
31 Node* NumberNotEqual(Node* a, Node* b) { | |
32 return NEW_NODE_2(SIMPLIFIED()->NumberNotEqual(), a, b); | |
33 } | |
34 Node* NumberLessThan(Node* a, Node* b) { | |
35 return NEW_NODE_2(SIMPLIFIED()->NumberLessThan(), a, b); | |
36 } | |
37 Node* NumberLessThanOrEqual(Node* a, Node* b) { | |
38 return NEW_NODE_2(SIMPLIFIED()->NumberLessThanOrEqual(), a, b); | |
39 } | |
40 Node* NumberAdd(Node* a, Node* b) { | |
41 return NEW_NODE_2(SIMPLIFIED()->NumberAdd(), a, b); | |
42 } | |
43 Node* NumberSubtract(Node* a, Node* b) { | |
44 return NEW_NODE_2(SIMPLIFIED()->NumberSubtract(), a, b); | |
45 } | |
46 Node* NumberMultiply(Node* a, Node* b) { | |
47 return NEW_NODE_2(SIMPLIFIED()->NumberMultiply(), a, b); | |
48 } | |
49 Node* NumberDivide(Node* a, Node* b) { | |
50 return NEW_NODE_2(SIMPLIFIED()->NumberDivide(), a, b); | |
51 } | |
52 Node* NumberModulus(Node* a, Node* b) { | |
53 return NEW_NODE_2(SIMPLIFIED()->NumberModulus(), a, b); | |
54 } | |
55 Node* NumberToInt32(Node* a) { | |
56 return NEW_NODE_1(SIMPLIFIED()->NumberToInt32(), a); | |
57 } | |
58 Node* NumberToUint32(Node* a) { | |
59 return NEW_NODE_1(SIMPLIFIED()->NumberToUint32(), a); | |
60 } | |
61 | |
62 Node* ReferenceEqual(Type* type, Node* a, Node* b) { | |
63 return NEW_NODE_2(SIMPLIFIED()->ReferenceEqual(), a, b); | |
64 } | |
65 | |
66 Node* StringEqual(Node* a, Node* b) { | |
67 return NEW_NODE_2(SIMPLIFIED()->StringEqual(), a, b); | |
68 } | |
69 Node* StringLessThan(Node* a, Node* b) { | |
70 return NEW_NODE_2(SIMPLIFIED()->StringLessThan(), a, b); | |
71 } | |
72 Node* StringLessThanOrEqual(Node* a, Node* b) { | |
73 return NEW_NODE_2(SIMPLIFIED()->StringLessThanOrEqual(), a, b); | |
74 } | |
75 Node* StringAdd(Node* a, Node* b) { | |
76 return NEW_NODE_2(SIMPLIFIED()->StringAdd(), a, b); | |
77 } | |
78 | |
79 Node* ChangeTaggedToInt32(Node* a) { | |
80 return NEW_NODE_1(SIMPLIFIED()->ChangeTaggedToInt32(), a); | |
81 } | |
82 Node* ChangeTaggedToUint32(Node* a) { | |
83 return NEW_NODE_1(SIMPLIFIED()->ChangeTaggedToUint32(), a); | |
84 } | |
85 Node* ChangeTaggedToFloat64(Node* a) { | |
86 return NEW_NODE_1(SIMPLIFIED()->ChangeTaggedToFloat64(), a); | |
87 } | |
88 Node* ChangeInt32ToTagged(Node* a) { | |
89 return NEW_NODE_1(SIMPLIFIED()->ChangeInt32ToTagged(), a); | |
90 } | |
91 Node* ChangeUint32ToTagged(Node* a) { | |
92 return NEW_NODE_1(SIMPLIFIED()->ChangeUint32ToTagged(), a); | |
93 } | |
94 Node* ChangeFloat64ToTagged(Node* a) { | |
95 return NEW_NODE_1(SIMPLIFIED()->ChangeFloat64ToTagged(), a); | |
96 } | |
97 Node* ChangeBoolToBit(Node* a) { | |
98 return NEW_NODE_1(SIMPLIFIED()->ChangeBoolToBit(), a); | |
99 } | |
100 Node* ChangeBitToBool(Node* a) { | |
101 return NEW_NODE_1(SIMPLIFIED()->ChangeBitToBool(), a); | |
102 } | |
103 | |
104 Node* LoadField(const FieldAccess& access, Node* object) { | |
105 return NEW_NODE_1(SIMPLIFIED()->LoadField(access), object); | |
106 } | |
107 Node* StoreField(const FieldAccess& access, Node* object, Node* value) { | |
108 return NEW_NODE_2(SIMPLIFIED()->StoreField(access), object, value); | |
109 } | |
110 Node* LoadElement(const ElementAccess& access, Node* object, Node* index) { | |
111 return NEW_NODE_2(SIMPLIFIED()->LoadElement(access), object, index); | |
112 } | |
113 Node* StoreElement(const ElementAccess& access, Node* object, Node* index, | |
114 Node* value) { | |
115 return NEW_NODE_3(SIMPLIFIED()->StoreElement(access), object, index, value); | |
116 } | |
117 }; | |
118 | |
119 #undef NEW_NODE_1 | |
120 #undef NEW_NODE_2 | |
121 #undef NEW_NODE_3 | |
122 #undef SIMPLIFIED | |
123 | |
124 } // namespace compiler | |
125 } // namespace internal | |
126 } // namespace v8 | |
127 | |
128 #endif // V8_COMPILER_SIMPLIFIED_NODE_FACTORY_H_ | |
OLD | NEW |