1b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Copyright 2013 the V8 project authors. All rights reserved. 2b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Use of this source code is governed by a BSD-style license that can be 3b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// found in the LICENSE file. 4b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 5b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#ifndef V8_COMPILER_NODE_PROPERTIES_H_ 6b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#define V8_COMPILER_NODE_PROPERTIES_H_ 7b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 8b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#include "src/compiler/node.h" 9b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#include "src/types.h" 10b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 11b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochnamespace v8 { 12b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochnamespace internal { 13b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochnamespace compiler { 14b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 15b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochclass Operator; 16b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 17b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// A facade that simplifies access to the different kinds of inputs to a node. 18b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochclass NodeProperties { 19b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch public: 20b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline Node* GetValueInput(Node* node, int index); 21b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline Node* GetContextInput(Node* node); 22b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline Node* GetFrameStateInput(Node* node); 23b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline Node* GetEffectInput(Node* node, int index = 0); 24b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline Node* GetControlInput(Node* node, int index = 0); 25b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 26b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline int GetFrameStateIndex(Node* node); 27b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 28b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline bool IsValueEdge(Node::Edge edge); 29b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline bool IsContextEdge(Node::Edge edge); 30b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline bool IsEffectEdge(Node::Edge edge); 31b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline bool IsControlEdge(Node::Edge edge); 32b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 33b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline bool IsControl(Node* node); 34b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 35b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline void ReplaceControlInput(Node* node, Node* control); 36b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline void ReplaceEffectInput(Node* node, Node* effect, 37b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch int index = 0); 38b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline void ReplaceFrameStateInput(Node* node, Node* frame_state); 39b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline void RemoveNonValueInputs(Node* node); 40b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline void ReplaceWithValue(Node* node, Node* value, 41b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch Node* effect = NULL); 42b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 43b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline Bounds GetBounds(Node* node); 44b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline void SetBounds(Node* node, Bounds bounds); 45b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 46b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline int FirstValueIndex(Node* node); 47b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline int FirstContextIndex(Node* node); 48b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline int FirstFrameStateIndex(Node* node); 49b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline int FirstEffectIndex(Node* node); 50b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline int FirstControlIndex(Node* node); 51b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline int PastValueIndex(Node* node); 52b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline int PastContextIndex(Node* node); 53b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline int PastFrameStateIndex(Node* node); 54b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline int PastEffectIndex(Node* node); 55b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline int PastControlIndex(Node* node); 56b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 57b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static inline bool IsInputRange(Node::Edge edge, int first, int count); 58b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch}; 59b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 60b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} // namespace compiler 61b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} // namespace internal 62b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch} // namespace v8 63b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 64b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#endif // V8_COMPILER_NODE_PROPERTIES_H_ 65