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

Side by Side Diff: test/compiler-unittests/change-lowering-unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698