OLD | NEW |
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 #include "src/compiler/common-operator.h" | 6 #include "src/compiler/common-operator.h" |
7 #include "src/compiler/graph.h" | 7 #include "src/compiler/graph.h" |
8 #include "src/compiler/node-properties-inl.h" | 8 #include "src/compiler/node-properties-inl.h" |
9 #include "src/compiler/simplified-operator.h" | 9 #include "src/compiler/simplified-operator.h" |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 ASSERT_THAT(smi, IsProjection(0, IsInt32AddWithOverflow(val, val))); | 130 ASSERT_THAT(smi, IsProjection(0, IsInt32AddWithOverflow(val, val))); |
131 | 131 |
132 Node* heap_number = NodeProperties::GetValueInput(phi, 0); | 132 Node* heap_number = NodeProperties::GetValueInput(phi, 0); |
133 ASSERT_EQ(IrOpcode::kCall, heap_number->opcode()); | 133 ASSERT_EQ(IrOpcode::kCall, heap_number->opcode()); |
134 | 134 |
135 Node* merge = NodeProperties::GetControlInput(phi); | 135 Node* merge = NodeProperties::GetControlInput(phi); |
136 ASSERT_EQ(IrOpcode::kMerge, merge->opcode()); | 136 ASSERT_EQ(IrOpcode::kMerge, merge->opcode()); |
137 | 137 |
138 const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag; | 138 const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag; |
139 EXPECT_THAT(NodeProperties::GetControlInput(merge, 0), | 139 EXPECT_THAT(NodeProperties::GetControlInput(merge, 0), |
140 IsStore(kMachineFloat64, kNoWriteBarrier, heap_number, | 140 IsStore(mFloat64, kNoWriteBarrier, heap_number, |
141 IsInt32Constant(kValueOffset), | 141 IsInt32Constant(kValueOffset), |
142 IsChangeInt32ToFloat64(val), _, heap_number)); | 142 IsChangeInt32ToFloat64(val), _, heap_number)); |
143 | 143 |
144 Node* if_true = NodeProperties::GetControlInput(heap_number); | 144 Node* if_true = NodeProperties::GetControlInput(heap_number); |
145 ASSERT_EQ(IrOpcode::kIfTrue, if_true->opcode()); | 145 ASSERT_EQ(IrOpcode::kIfTrue, if_true->opcode()); |
146 | 146 |
147 Node* if_false = NodeProperties::GetControlInput(merge, 1); | 147 Node* if_false = NodeProperties::GetControlInput(merge, 1); |
148 ASSERT_EQ(IrOpcode::kIfFalse, if_false->opcode()); | 148 ASSERT_EQ(IrOpcode::kIfFalse, if_false->opcode()); |
149 | 149 |
150 Node* branch = NodeProperties::GetControlInput(if_true); | 150 Node* branch = NodeProperties::GetControlInput(if_true); |
151 EXPECT_EQ(branch, NodeProperties::GetControlInput(if_false)); | 151 EXPECT_EQ(branch, NodeProperties::GetControlInput(if_false)); |
152 EXPECT_THAT(branch, | 152 EXPECT_THAT(branch, |
153 IsBranch(IsProjection(1, IsInt32AddWithOverflow(val, val)), | 153 IsBranch(IsProjection(1, IsInt32AddWithOverflow(val, val)), |
154 graph()->start())); | 154 graph()->start())); |
155 } | 155 } |
156 | 156 |
157 | 157 |
158 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToFloat64) { | 158 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToFloat64) { |
159 Node* val = Parameter(0); | 159 Node* val = Parameter(0); |
160 Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), val); | 160 Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), val); |
161 Reduction reduction = Reduce(node); | 161 Reduction reduction = Reduce(node); |
162 ASSERT_TRUE(reduction.Changed()); | 162 ASSERT_TRUE(reduction.Changed()); |
163 | 163 |
164 const int32_t kShiftAmount = | 164 const int32_t kShiftAmount = |
165 kSmiTagSize + SmiTagging<kPointerSize>::kSmiShiftSize; | 165 kSmiTagSize + SmiTagging<kPointerSize>::kSmiShiftSize; |
166 const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag; | 166 const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag; |
167 Node* phi = reduction.replacement(); | 167 Node* phi = reduction.replacement(); |
168 ASSERT_THAT( | 168 ASSERT_THAT(phi, |
169 phi, IsPhi(IsLoad(kMachineFloat64, val, IsInt32Constant(kValueOffset), _), | 169 IsPhi(IsLoad(mFloat64, val, IsInt32Constant(kValueOffset), _), |
170 IsChangeInt32ToFloat64( | 170 IsChangeInt32ToFloat64( |
171 IsWord32Sar(val, IsInt32Constant(kShiftAmount))), | 171 IsWord32Sar(val, IsInt32Constant(kShiftAmount))), |
172 _)); | 172 _)); |
173 | 173 |
174 Node* merge = NodeProperties::GetControlInput(phi); | 174 Node* merge = NodeProperties::GetControlInput(phi); |
175 ASSERT_EQ(IrOpcode::kMerge, merge->opcode()); | 175 ASSERT_EQ(IrOpcode::kMerge, merge->opcode()); |
176 | 176 |
177 Node* if_true = NodeProperties::GetControlInput(merge, 0); | 177 Node* if_true = NodeProperties::GetControlInput(merge, 0); |
178 ASSERT_EQ(IrOpcode::kIfTrue, if_true->opcode()); | 178 ASSERT_EQ(IrOpcode::kIfTrue, if_true->opcode()); |
179 | 179 |
180 Node* if_false = NodeProperties::GetControlInput(merge, 1); | 180 Node* if_false = NodeProperties::GetControlInput(merge, 1); |
181 ASSERT_EQ(IrOpcode::kIfFalse, if_false->opcode()); | 181 ASSERT_EQ(IrOpcode::kIfFalse, if_false->opcode()); |
182 | 182 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToFloat64) { | 222 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToFloat64) { |
223 Node* val = Parameter(0); | 223 Node* val = Parameter(0); |
224 Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), val); | 224 Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), val); |
225 Reduction reduction = Reduce(node); | 225 Reduction reduction = Reduce(node); |
226 ASSERT_TRUE(reduction.Changed()); | 226 ASSERT_TRUE(reduction.Changed()); |
227 | 227 |
228 const int32_t kShiftAmount = | 228 const int32_t kShiftAmount = |
229 kSmiTagSize + SmiTagging<kPointerSize>::kSmiShiftSize; | 229 kSmiTagSize + SmiTagging<kPointerSize>::kSmiShiftSize; |
230 const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag; | 230 const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag; |
231 Node* phi = reduction.replacement(); | 231 Node* phi = reduction.replacement(); |
232 ASSERT_THAT( | 232 ASSERT_THAT(phi, |
233 phi, IsPhi(IsLoad(kMachineFloat64, val, IsInt32Constant(kValueOffset), _), | 233 IsPhi(IsLoad(mFloat64, val, IsInt32Constant(kValueOffset), _), |
234 IsChangeInt32ToFloat64(IsConvertInt64ToInt32( | 234 IsChangeInt32ToFloat64(IsConvertInt64ToInt32( |
235 IsWord64Sar(val, IsInt32Constant(kShiftAmount)))), | 235 IsWord64Sar(val, IsInt32Constant(kShiftAmount)))), |
236 _)); | 236 _)); |
237 | 237 |
238 Node* merge = NodeProperties::GetControlInput(phi); | 238 Node* merge = NodeProperties::GetControlInput(phi); |
239 ASSERT_EQ(IrOpcode::kMerge, merge->opcode()); | 239 ASSERT_EQ(IrOpcode::kMerge, merge->opcode()); |
240 | 240 |
241 Node* if_true = NodeProperties::GetControlInput(merge, 0); | 241 Node* if_true = NodeProperties::GetControlInput(merge, 0); |
242 ASSERT_EQ(IrOpcode::kIfTrue, if_true->opcode()); | 242 ASSERT_EQ(IrOpcode::kIfTrue, if_true->opcode()); |
243 | 243 |
244 Node* if_false = NodeProperties::GetControlInput(merge, 1); | 244 Node* if_false = NodeProperties::GetControlInput(merge, 1); |
245 ASSERT_EQ(IrOpcode::kIfFalse, if_false->opcode()); | 245 ASSERT_EQ(IrOpcode::kIfFalse, if_false->opcode()); |
246 | 246 |
247 Node* branch = NodeProperties::GetControlInput(if_true); | 247 Node* branch = NodeProperties::GetControlInput(if_true); |
248 EXPECT_EQ(branch, NodeProperties::GetControlInput(if_false)); | 248 EXPECT_EQ(branch, NodeProperties::GetControlInput(if_false)); |
249 STATIC_ASSERT(kSmiTag == 0); | 249 STATIC_ASSERT(kSmiTag == 0); |
250 STATIC_ASSERT(kSmiTagSize == 1); | 250 STATIC_ASSERT(kSmiTagSize == 1); |
251 EXPECT_THAT(branch, IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)), | 251 EXPECT_THAT(branch, IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)), |
252 graph()->start())); | 252 graph()->start())); |
253 } | 253 } |
254 | 254 |
255 } // namespace compiler | 255 } // namespace compiler |
256 } // namespace internal | 256 } // namespace internal |
257 } // namespace v8 | 257 } // namespace v8 |
OLD | NEW |