blob: defadd95fd098d65f4ce9cd201158e34c67afe52 [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
Ben Murdoch83897452016-05-17 11:12:09 +010059 Node* IsSmi(Node* value);
60 Node* LoadHeapObjectMap(Node* object, Node* control);
61 Node* LoadMapInstanceType(Node* map);
62
63 Reduction ObjectIsNumber(Node* node);
64 Reduction ObjectIsReceiver(Node* node);
65 Reduction ObjectIsSmi(Node* node);
66
Ben Murdoch014dc512016-03-22 12:00:34 +000067 Node* ComputeIndex(const ElementAccess& access, Node* const key);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000068 Graph* graph() const;
69 Isolate* isolate() const;
70 JSGraph* jsgraph() const { return jsgraph_; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +000071 CommonOperatorBuilder* common() const;
72 MachineOperatorBuilder* machine() const;
73
Ben Murdoch014dc512016-03-22 12:00:34 +000074 JSGraph* const jsgraph_;
75 SetOncePointer<const Operator> allocate_heap_number_operator_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000076};
77
78} // namespace compiler
79} // namespace internal
80} // namespace v8
81
82#endif // V8_COMPILER_CHANGE_LOWERING_H_