blob: 6d607768d9c5d56cf4c16fb58c65326730c926b8 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// 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_CHANGE_LOWERING_H_
6#define V8_COMPILER_CHANGE_LOWERING_H_
7
8#include "src/compiler/graph-reducer.h"
9
10namespace v8 {
11namespace internal {
12namespace compiler {
13
14// Forward declarations.
15class CommonOperatorBuilder;
Ben Murdoch014dc512016-03-22 12:00:34 +000016struct ElementAccess;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000017class JSGraph;
18class Linkage;
19class MachineOperatorBuilder;
Ben Murdoch014dc512016-03-22 12:00:34 +000020class Operator;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000021
Ben Murdoch014dc512016-03-22 12:00:34 +000022class ChangeLowering final : public Reducer {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000023 public:
Ben Murdoch014dc512016-03-22 12:00:34 +000024 explicit ChangeLowering(JSGraph* jsgraph) : jsgraph_(jsgraph) {}
25 ~ChangeLowering() final;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000026
Ben Murdoch014dc512016-03-22 12:00:34 +000027 Reduction Reduce(Node* node) final;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000028
29 private:
30 Node* HeapNumberValueIndexConstant();
31 Node* SmiMaxValueConstant();
32 Node* SmiShiftBitsConstant();
33
34 Node* AllocateHeapNumberWithValue(Node* value, Node* control);
Emily Bernier958fae72015-03-24 16:35:39 -040035 Node* ChangeInt32ToFloat64(Node* value);
Ben Murdoch014dc512016-03-22 12:00:34 +000036 Node* ChangeInt32ToSmi(Node* value);
Emily Bernier958fae72015-03-24 16:35:39 -040037 Node* ChangeSmiToFloat64(Node* value);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000038 Node* ChangeSmiToInt32(Node* value);
Emily Bernier958fae72015-03-24 16:35:39 -040039 Node* ChangeUint32ToFloat64(Node* value);
40 Node* ChangeUint32ToSmi(Node* value);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000041 Node* LoadHeapNumberValue(Node* value, Node* control);
Emily Bernier958fae72015-03-24 16:35:39 -040042 Node* TestNotSmi(Node* value);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000043
Emily Bernier958fae72015-03-24 16:35:39 -040044 Reduction ChangeBitToBool(Node* value, Node* control);
45 Reduction ChangeBoolToBit(Node* value);
46 Reduction ChangeFloat64ToTagged(Node* value, Node* control);
47 Reduction ChangeInt32ToTagged(Node* value, Node* control);
48 Reduction ChangeTaggedToFloat64(Node* value, Node* control);
49 Reduction ChangeTaggedToUI32(Node* value, Node* control,
50 Signedness signedness);
51 Reduction ChangeUint32ToTagged(Node* value, Node* control);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000052
Ben Murdoch014dc512016-03-22 12:00:34 +000053 Reduction LoadField(Node* node);
54 Reduction StoreField(Node* node);
55 Reduction LoadElement(Node* node);
56 Reduction StoreElement(Node* node);
57 Reduction Allocate(Node* node);
58
59 Node* ComputeIndex(const ElementAccess& access, Node* const key);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000060 Graph* graph() const;
61 Isolate* isolate() const;
62 JSGraph* jsgraph() const { return jsgraph_; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +000063 CommonOperatorBuilder* common() const;
64 MachineOperatorBuilder* machine() const;
65
Ben Murdoch014dc512016-03-22 12:00:34 +000066 JSGraph* const jsgraph_;
67 SetOncePointer<const Operator> allocate_heap_number_operator_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000068};
69
70} // namespace compiler
71} // namespace internal
72} // namespace v8
73
74#endif // V8_COMPILER_CHANGE_LOWERING_H_