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_CHANGE_LOWERING_H_ 6 #define V8_COMPILER_CHANGE_LOWERING_H_ 7 8 #include "src/compiler/graph-reducer.h" 9 10 namespace v8 { 11 namespace internal { 12 namespace compiler { 13 14 // Forward declarations. 15 class CommonOperatorBuilder; 16 struct ElementAccess; 17 class JSGraph; 18 class Linkage; 19 class MachineOperatorBuilder; 20 class Operator; 21 22 class ChangeLowering final : public Reducer { 23 public: ChangeLowering(JSGraph * jsgraph)24 explicit ChangeLowering(JSGraph* jsgraph) : jsgraph_(jsgraph) {} 25 ~ChangeLowering() final; 26 27 Reduction Reduce(Node* node) final; 28 29 private: 30 Node* HeapNumberValueIndexConstant(); 31 Node* SmiMaxValueConstant(); 32 Node* SmiShiftBitsConstant(); 33 34 Node* AllocateHeapNumberWithValue(Node* value, Node* control); 35 Node* ChangeInt32ToFloat64(Node* value); 36 Node* ChangeInt32ToSmi(Node* value); 37 Node* ChangeSmiToFloat64(Node* value); 38 Node* ChangeSmiToInt32(Node* value); 39 Node* ChangeUint32ToFloat64(Node* value); 40 Node* ChangeUint32ToSmi(Node* value); 41 Node* LoadHeapNumberValue(Node* value, Node* control); 42 Node* TestNotSmi(Node* value); 43 44 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); 52 53 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); 60 Graph* graph() const; 61 Isolate* isolate() const; jsgraph()62 JSGraph* jsgraph() const { return jsgraph_; } 63 CommonOperatorBuilder* common() const; 64 MachineOperatorBuilder* machine() const; 65 66 JSGraph* const jsgraph_; 67 SetOncePointer<const Operator> allocate_heap_number_operator_; 68 }; 69 70 } // namespace compiler 71 } // namespace internal 72 } // namespace v8 73 74 #endif // V8_COMPILER_CHANGE_LOWERING_H_ 75