Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: src/compiler/node-properties.h

Issue 883613006: [turbofan] Cleanup the NodeProperties. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/mips64/code-generator-mips64.cc ('k') | src/compiler/node-properties.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_COMPILER_NODE_PROPERTIES_H_ 5 #ifndef V8_COMPILER_NODE_PROPERTIES_H_
6 #define V8_COMPILER_NODE_PROPERTIES_H_ 6 #define V8_COMPILER_NODE_PROPERTIES_H_
7 7
8 #include "src/compiler/node.h" 8 #include "src/compiler/node.h"
9 #include "src/types.h" 9 #include "src/types.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 namespace compiler { 13 namespace compiler {
14 14
15 class Operator; 15 class Operator;
16 16
17 // A facade that simplifies access to the different kinds of inputs to a node. 17 // A facade that simplifies access to the different kinds of inputs to a node.
18 class NodeProperties { 18 class NodeProperties FINAL {
19 public: 19 public:
20 static inline Node* GetValueInput(Node* node, int index); 20 // ---------------------------------------------------------------------------
21 static inline Node* GetContextInput(Node* node); 21 // Input layout.
22 static inline Node* GetFrameStateInput(Node* node); 22 // Inputs are always arranged in order as follows:
23 static inline Node* GetEffectInput(Node* node, int index = 0); 23 // 0 [ values, context, frame state, effects, control ] node->InputCount()
24 static inline Node* GetControlInput(Node* node, int index = 0);
25 24
26 static inline int GetFrameStateIndex(Node* node); 25 static int FirstValueIndex(Node* node) { return 0; }
26 static int FirstContextIndex(Node* node) { return PastValueIndex(node); }
27 static int FirstFrameStateIndex(Node* node) { return PastContextIndex(node); }
28 static int FirstEffectIndex(Node* node) { return PastFrameStateIndex(node); }
29 static int FirstControlIndex(Node* node) { return PastEffectIndex(node); }
30 static int PastValueIndex(Node* node);
31 static int PastContextIndex(Node* node);
32 static int PastFrameStateIndex(Node* node);
33 static int PastEffectIndex(Node* node);
34 static int PastControlIndex(Node* node);
27 35
28 static inline bool IsValueEdge(Edge edge);
29 static inline bool IsContextEdge(Edge edge);
30 static inline bool IsEffectEdge(Edge edge);
31 static inline bool IsControlEdge(Edge edge);
32 36
33 static inline bool IsControl(Node* node); 37 // ---------------------------------------------------------------------------
38 // Input accessors.
34 39
35 static inline void ReplaceContextInput(Node* node, Node* context); 40 static Node* GetValueInput(Node* node, int index);
36 static inline void ReplaceControlInput(Node* node, Node* control); 41 static Node* GetContextInput(Node* node);
37 static inline void ReplaceEffectInput(Node* node, Node* effect, 42 static Node* GetFrameStateInput(Node* node);
38 int index = 0); 43 static Node* GetEffectInput(Node* node, int index = 0);
39 static inline void ReplaceFrameStateInput(Node* node, Node* frame_state); 44 static Node* GetControlInput(Node* node, int index = 0);
40 static inline void RemoveNonValueInputs(Node* node); 45
41 static inline void ReplaceWithValue(Node* node, Node* value, 46
42 Node* effect = nullptr); 47 // ---------------------------------------------------------------------------
48 // Edge kinds.
49
50 static bool IsValueEdge(Edge edge);
51 static bool IsContextEdge(Edge edge);
52 static bool IsFrameStateEdge(Edge edge);
53 static bool IsEffectEdge(Edge edge);
54 static bool IsControlEdge(Edge edge);
55
56
57 // ---------------------------------------------------------------------------
58 // Miscellaneous predicates.
59
60 static bool IsCommon(Node* node) {
61 return IrOpcode::IsCommonOpcode(node->opcode());
62 }
63 static bool IsControl(Node* node) {
64 return IrOpcode::IsControlOpcode(node->opcode());
65 }
66 static bool IsConstant(Node* node) {
67 return IrOpcode::IsConstantOpcode(node->opcode());
68 }
69 static bool IsPhi(Node* node) {
70 return IrOpcode::IsPhiOpcode(node->opcode());
71 }
72
73
74 // ---------------------------------------------------------------------------
75 // Miscellaneous mutators.
76
77 static void ReplaceContextInput(Node* node, Node* context);
78 static void ReplaceControlInput(Node* node, Node* control);
79 static void ReplaceEffectInput(Node* node, Node* effect, int index = 0);
80 static void ReplaceFrameStateInput(Node* node, Node* frame_state);
81 static void RemoveNonValueInputs(Node* node);
82
83 // Replace value uses of {node} with {value} and effect uses of {node} with
84 // {effect}. If {effect == NULL}, then use the effect input to {node}.
85 static void ReplaceWithValue(Node* node, Node* value, Node* effect = nullptr);
86
87
88 // ---------------------------------------------------------------------------
89 // Miscellaneous utilities.
43 90
44 static Node* FindProjection(Node* node, size_t projection_index); 91 static Node* FindProjection(Node* node, size_t projection_index);
45 92
46 static inline bool IsTyped(Node* node);
47 static inline Bounds GetBounds(Node* node);
48 static inline void SetBounds(Node* node, Bounds bounds);
49 static inline void RemoveBounds(Node* node);
50 static inline bool AllValueInputsAreTyped(Node* node);
51 93
52 static inline int FirstValueIndex(Node* node); 94 // ---------------------------------------------------------------------------
53 static inline int FirstContextIndex(Node* node); 95 // Type Bounds.
54 static inline int FirstFrameStateIndex(Node* node);
55 static inline int FirstEffectIndex(Node* node);
56 static inline int FirstControlIndex(Node* node);
57 static inline int PastValueIndex(Node* node);
58 static inline int PastContextIndex(Node* node);
59 static inline int PastFrameStateIndex(Node* node);
60 static inline int PastEffectIndex(Node* node);
61 static inline int PastControlIndex(Node* node);
62 96
97 static bool IsTyped(Node* node) {
98 Bounds const bounds = node->bounds();
99 DCHECK(!bounds.lower == !bounds.upper);
100 return bounds.upper;
101 }
102 static Bounds GetBounds(Node* node) {
103 DCHECK(IsTyped(node));
104 return node->bounds();
105 }
106 static void SetBounds(Node* node, Bounds bounds) {
107 DCHECK_NOT_NULL(bounds.lower);
108 DCHECK_NOT_NULL(bounds.upper);
109 node->set_bounds(bounds);
110 }
111 static void RemoveBounds(Node* node) { node->set_bounds(Bounds()); }
112 static bool AllValueInputsAreTyped(Node* node);
113
114 private:
63 static inline bool IsInputRange(Edge edge, int first, int count); 115 static inline bool IsInputRange(Edge edge, int first, int count);
64 }; 116 };
65 117
66 } // namespace compiler 118 } // namespace compiler
67 } // namespace internal 119 } // namespace internal
68 } // namespace v8 120 } // namespace v8
69 121
70 #endif // V8_COMPILER_NODE_PROPERTIES_H_ 122 #endif // V8_COMPILER_NODE_PROPERTIES_H_
OLDNEW
« no previous file with comments | « src/compiler/mips64/code-generator-mips64.cc ('k') | src/compiler/node-properties.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698