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

Side by Side Diff: src/compiler/change-lowering.cc

Issue 1693563004: Convert between tagged and untagged kSimd128 values. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 9 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/change-lowering.h ('k') | src/compiler/opcodes.h » ('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 2014 the V8 project authors. All rights reserved. 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 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 #include "src/compiler/change-lowering.h" 5 #include "src/compiler/change-lowering.h"
6 6
7 #include "src/address-map.h" 7 #include "src/address-map.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 21 matching lines...) Expand all
32 case IrOpcode::kChangeInt32ToTagged: 32 case IrOpcode::kChangeInt32ToTagged:
33 return ChangeInt32ToTagged(node->InputAt(0), control); 33 return ChangeInt32ToTagged(node->InputAt(0), control);
34 case IrOpcode::kChangeTaggedToFloat64: 34 case IrOpcode::kChangeTaggedToFloat64:
35 return ChangeTaggedToFloat64(node->InputAt(0), control); 35 return ChangeTaggedToFloat64(node->InputAt(0), control);
36 case IrOpcode::kChangeTaggedToInt32: 36 case IrOpcode::kChangeTaggedToInt32:
37 return ChangeTaggedToUI32(node->InputAt(0), control, kSigned); 37 return ChangeTaggedToUI32(node->InputAt(0), control, kSigned);
38 case IrOpcode::kChangeTaggedToUint32: 38 case IrOpcode::kChangeTaggedToUint32:
39 return ChangeTaggedToUI32(node->InputAt(0), control, kUnsigned); 39 return ChangeTaggedToUI32(node->InputAt(0), control, kUnsigned);
40 case IrOpcode::kChangeUint32ToTagged: 40 case IrOpcode::kChangeUint32ToTagged:
41 return ChangeUint32ToTagged(node->InputAt(0), control); 41 return ChangeUint32ToTagged(node->InputAt(0), control);
42 #define SIMD128_CASES(TYPE, Type, type, lane_count, lane_type) \
43 case IrOpcode::kChange##Type##ToTagged: \
44 return Change##Type##ToTagged(node->InputAt(0), control); \
45 case IrOpcode::kChangeTaggedTo##Type: \
46 return ChangeTaggedTo##Type(node->InputAt(0), control);
47 SIMD128_TYPES(SIMD128_CASES)
48 #undef SIMD128_CASES
42 case IrOpcode::kLoadField: 49 case IrOpcode::kLoadField:
43 return LoadField(node); 50 return LoadField(node);
44 case IrOpcode::kStoreField: 51 case IrOpcode::kStoreField:
45 return StoreField(node); 52 return StoreField(node);
46 case IrOpcode::kLoadElement: 53 case IrOpcode::kLoadElement:
47 return LoadElement(node); 54 return LoadElement(node);
48 case IrOpcode::kStoreElement: 55 case IrOpcode::kStoreElement:
49 return StoreElement(node); 56 return StoreElement(node);
50 case IrOpcode::kAllocate: 57 case IrOpcode::kAllocate:
51 return Allocate(node); 58 return Allocate(node);
(...skipping 10 matching lines...) Expand all
62 } 69 }
63 UNREACHABLE(); 70 UNREACHABLE();
64 return NoChange(); 71 return NoChange();
65 } 72 }
66 73
67 74
68 Node* ChangeLowering::HeapNumberValueIndexConstant() { 75 Node* ChangeLowering::HeapNumberValueIndexConstant() {
69 return jsgraph()->IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag); 76 return jsgraph()->IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag);
70 } 77 }
71 78
79 Node* ChangeLowering::Simd128ValueIndexConstant() {
80 return jsgraph()->IntPtrConstant(Simd128Value::kValueOffset - kHeapObjectTag);
81 }
72 82
73 Node* ChangeLowering::SmiMaxValueConstant() { 83 Node* ChangeLowering::SmiMaxValueConstant() {
74 return jsgraph()->Int32Constant(Smi::kMaxValue); 84 return jsgraph()->Int32Constant(Smi::kMaxValue);
75 } 85 }
76 86
77 87
78 Node* ChangeLowering::SmiShiftBitsConstant() { 88 Node* ChangeLowering::SmiShiftBitsConstant() {
79 return jsgraph()->IntPtrConstant(kSmiShiftSize + kSmiTagSize); 89 return jsgraph()->IntPtrConstant(kSmiShiftSize + kSmiTagSize);
80 } 90 }
81 91
(...skipping 13 matching lines...) Expand all
95 } 105 }
96 Node* heap_number = graph()->NewNode(allocate_heap_number_operator_.get(), 106 Node* heap_number = graph()->NewNode(allocate_heap_number_operator_.get(),
97 target, context, effect, control); 107 target, context, effect, control);
98 Node* store = graph()->NewNode( 108 Node* store = graph()->NewNode(
99 machine()->Store(StoreRepresentation(MachineRepresentation::kFloat64, 109 machine()->Store(StoreRepresentation(MachineRepresentation::kFloat64,
100 kNoWriteBarrier)), 110 kNoWriteBarrier)),
101 heap_number, HeapNumberValueIndexConstant(), value, heap_number, control); 111 heap_number, HeapNumberValueIndexConstant(), value, heap_number, control);
102 return graph()->NewNode(common()->FinishRegion(), heap_number, store); 112 return graph()->NewNode(common()->FinishRegion(), heap_number, store);
103 } 113 }
104 114
115 #define SIMD128_ALLOCATE(TYPE, Type, type, lane_count, lane_type) \
116 Node* ChangeLowering::Allocate##Type##WithValue(Node* value) { \
117 Callable callable = CodeFactory::Allocate##Type(isolate()); \
118 Node* target = jsgraph()->HeapConstant(callable.code()); \
119 Node* context = jsgraph()->NoContextConstant(); \
120 Node* effect = \
121 graph()->NewNode(common()->BeginRegion(), graph()->start()); \
122 if (!allocate_##type##_value_operator_.is_set()) { \
123 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor( \
124 isolate(), jsgraph()->zone(), callable.descriptor(), 0, \
125 CallDescriptor::kNoFlags, Operator::kNoThrow); \
126 allocate_##type##_value_operator_.set(common()->Call(descriptor)); \
127 } \
128 Node* simd_value = graph()->NewNode( \
129 allocate_##type##_value_operator_.get(), target, context, effect); \
130 Node* store = graph()->NewNode( \
131 machine()->Store(StoreRepresentation(MachineRepresentation::kSimd128, \
132 kNoWriteBarrier)), \
133 simd_value, Simd128ValueIndexConstant(), value, simd_value); \
134 return graph()->NewNode(common()->FinishRegion(), simd_value, store); \
135 }
136 SIMD128_TYPES(SIMD128_ALLOCATE)
137 #undef SIMD128_ALLOCATE
105 138
106 Node* ChangeLowering::ChangeInt32ToFloat64(Node* value) { 139 Node* ChangeLowering::ChangeInt32ToFloat64(Node* value) {
107 return graph()->NewNode(machine()->ChangeInt32ToFloat64(), value); 140 return graph()->NewNode(machine()->ChangeInt32ToFloat64(), value);
108 } 141 }
109 142
110 143
111 Node* ChangeLowering::ChangeInt32ToSmi(Node* value) { 144 Node* ChangeLowering::ChangeInt32ToSmi(Node* value) {
112 if (machine()->Is64()) { 145 if (machine()->Is64()) {
113 value = graph()->NewNode(machine()->ChangeInt32ToInt64(), value); 146 value = graph()->NewNode(machine()->ChangeInt32ToInt64(), value);
114 } 147 }
(...skipping 27 matching lines...) Expand all
142 return graph()->NewNode(machine()->WordShl(), value, SmiShiftBitsConstant()); 175 return graph()->NewNode(machine()->WordShl(), value, SmiShiftBitsConstant());
143 } 176 }
144 177
145 178
146 Node* ChangeLowering::LoadHeapNumberValue(Node* value, Node* control) { 179 Node* ChangeLowering::LoadHeapNumberValue(Node* value, Node* control) {
147 return graph()->NewNode(machine()->Load(MachineType::Float64()), value, 180 return graph()->NewNode(machine()->Load(MachineType::Float64()), value,
148 HeapNumberValueIndexConstant(), graph()->start(), 181 HeapNumberValueIndexConstant(), graph()->start(),
149 control); 182 control);
150 } 183 }
151 184
185 #define SIMD128_LOAD(TYPE, Type, type, lane_count, lane_type) \
186 Node* ChangeLowering::Load##Type##Value(Node* value) { \
187 return graph()->NewNode(machine()->Load(MachineType::Simd128()), value, \
188 Simd128ValueIndexConstant(), graph()->start()); \
189 }
190 SIMD128_TYPES(SIMD128_LOAD)
191 #undef SIMD128_LOAD
152 192
153 Node* ChangeLowering::TestNotSmi(Node* value) { 193 Node* ChangeLowering::TestNotSmi(Node* value) {
154 STATIC_ASSERT(kSmiTag == 0); 194 STATIC_ASSERT(kSmiTag == 0);
155 STATIC_ASSERT(kSmiTagMask == 1); 195 STATIC_ASSERT(kSmiTagMask == 1);
156 return graph()->NewNode(machine()->WordAnd(), value, 196 return graph()->NewNode(machine()->WordAnd(), value,
157 jsgraph()->IntPtrConstant(kSmiTagMask)); 197 jsgraph()->IntPtrConstant(kSmiTagMask));
158 } 198 }
159 199
160 200
161 Reduction ChangeLowering::ChangeBitToBool(Node* value, Node* control) { 201 Reduction ChangeLowering::ChangeBitToBool(Node* value, Node* control) {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 Node* vfalse = 460 Node* vfalse =
421 AllocateHeapNumberWithValue(ChangeUint32ToFloat64(value), if_false); 461 AllocateHeapNumberWithValue(ChangeUint32ToFloat64(value), if_false);
422 462
423 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); 463 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
424 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), 464 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
425 vtrue, vfalse, merge); 465 vtrue, vfalse, merge);
426 466
427 return Replace(phi); 467 return Replace(phi);
428 } 468 }
429 469
470 #define SIMD128_CHANGE(TYPE, SType, type, lane_count, lane_type) \
471 Reduction ChangeLowering::ChangeTaggedTo##SType(Node* value, \
472 Node* control) { \
473 DCHECK(NodeProperties::GetType(value)->Is(Type::TaggedPointer())); \
474 return Replace(Load##SType##Value(value)); \
475 } \
476 \
477 Reduction ChangeLowering::Change##SType##ToTagged(Node* value, \
478 Node* control) { \
479 DCHECK(NodeProperties::GetType(value)->Is(Type::Simd())); \
480 return Replace(Allocate##SType##WithValue(value)); \
481 }
482 SIMD128_TYPES(SIMD128_CHANGE)
483 #undef SIMD128_CHANGE
430 484
431 namespace { 485 namespace {
432 486
433 WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, 487 WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged,
434 MachineRepresentation representation, 488 MachineRepresentation representation,
435 Type* field_type, Type* input_type) { 489 Type* field_type, Type* input_type) {
436 if (field_type->Is(Type::TaggedSigned()) || 490 if (field_type->Is(Type::TaggedSigned()) ||
437 input_type->Is(Type::TaggedSigned())) { 491 input_type->Is(Type::TaggedSigned())) {
438 // Write barriers are only for writes of heap objects. 492 // Write barriers are only for writes of heap objects.
439 return kNoWriteBarrier; 493 return kNoWriteBarrier;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 } 758 }
705 759
706 760
707 MachineOperatorBuilder* ChangeLowering::machine() const { 761 MachineOperatorBuilder* ChangeLowering::machine() const {
708 return jsgraph()->machine(); 762 return jsgraph()->machine();
709 } 763 }
710 764
711 } // namespace compiler 765 } // namespace compiler
712 } // namespace internal 766 } // namespace internal
713 } // namespace v8 767 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/change-lowering.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698