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

Side by Side Diff: src/compiler/simd-scalar-lowering.cc

Issue 2838943002: [wasm] Implement 128-bit endian swap for simd type (Closed)
Patch Set: fix sign compare error Created 3 years, 7 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 | « no previous file | src/compiler/wasm-compiler.cc » ('j') | src/compiler/wasm-compiler.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/simd-scalar-lowering.h" 5 #include "src/compiler/simd-scalar-lowering.h"
6 #include "src/compiler/diamond.h" 6 #include "src/compiler/diamond.h"
7 #include "src/compiler/linkage.h" 7 #include "src/compiler/linkage.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 10
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 int result = static_cast<int>(signature->return_count()); 193 int result = static_cast<int>(signature->return_count());
194 for (int i = 0; i < static_cast<int>(signature->return_count()); ++i) { 194 for (int i = 0; i < static_cast<int>(signature->return_count()); ++i) {
195 if (signature->GetReturn(i) == MachineRepresentation::kSimd128) { 195 if (signature->GetReturn(i) == MachineRepresentation::kSimd128) {
196 result += 3; 196 result += 3;
197 } 197 }
198 } 198 }
199 return result; 199 return result;
200 } 200 }
201 201
202 void SimdScalarLowering::GetIndexNodes(Node* index, Node** new_indices) { 202 void SimdScalarLowering::GetIndexNodes(Node* index, Node** new_indices) {
203 #if defined(V8_TARGET_BIG_ENDIAN)
Clemens Hammacher 2017/04/28 09:45:47 It looks like this code would get a lot cleaner if
204 new_indices[3] = index;
205 for (size_t i = 0; i < kMaxLanes - 1; ++i) {
206 new_indices[i] = graph()->NewNode(
207 machine()->Int32Add(), index,
208 graph()->NewNode(common()->Int32Constant(
209 static_cast<int>(kMaxLanes - i - 1) * kLaneWidth)));
210 }
211 #else
203 new_indices[0] = index; 212 new_indices[0] = index;
204 for (size_t i = 1; i < kMaxLanes; ++i) { 213 for (size_t i = 1; i < kMaxLanes; ++i) {
205 new_indices[i] = graph()->NewNode(machine()->Int32Add(), index, 214 new_indices[i] = graph()->NewNode(machine()->Int32Add(), index,
206 graph()->NewNode(common()->Int32Constant( 215 graph()->NewNode(common()->Int32Constant(
207 static_cast<int>(i) * kLaneWidth))); 216 static_cast<int>(i) * kLaneWidth)));
208 } 217 }
218 #endif
209 } 219 }
210 220
211 void SimdScalarLowering::LowerLoadOp(MachineRepresentation rep, Node* node, 221 void SimdScalarLowering::LowerLoadOp(MachineRepresentation rep, Node* node,
212 const Operator* load_op) { 222 const Operator* load_op) {
213 if (rep == MachineRepresentation::kSimd128) { 223 if (rep == MachineRepresentation::kSimd128) {
214 Node* base = node->InputAt(0); 224 Node* base = node->InputAt(0);
215 Node* index = node->InputAt(1); 225 Node* index = node->InputAt(1);
216 Node* indices[kMaxLanes]; 226 Node* indices[kMaxLanes];
217 GetIndexNodes(index, indices); 227 GetIndexNodes(index, indices);
218 Node* rep_nodes[kMaxLanes]; 228 Node* rep_nodes[kMaxLanes];
219 rep_nodes[0] = node; 229 rep_nodes[0] = node;
220 NodeProperties::ChangeOp(rep_nodes[0], load_op); 230 NodeProperties::ChangeOp(rep_nodes[0], load_op);
221 if (node->InputCount() > 2) { 231 if (node->InputCount() > 2) {
222 DCHECK(node->InputCount() > 3); 232 DCHECK(node->InputCount() > 3);
223 Node* effect_input = node->InputAt(2); 233 Node* effect_input = node->InputAt(2);
224 Node* control_input = node->InputAt(3); 234 Node* control_input = node->InputAt(3);
225 rep_nodes[3] = graph()->NewNode(load_op, base, indices[3], effect_input, 235 rep_nodes[3] = graph()->NewNode(load_op, base, indices[3], effect_input,
226 control_input); 236 control_input);
227 rep_nodes[2] = graph()->NewNode(load_op, base, indices[2], rep_nodes[3], 237 rep_nodes[2] = graph()->NewNode(load_op, base, indices[2], rep_nodes[3],
228 control_input); 238 control_input);
229 rep_nodes[1] = graph()->NewNode(load_op, base, indices[1], rep_nodes[2], 239 rep_nodes[1] = graph()->NewNode(load_op, base, indices[1], rep_nodes[2],
230 control_input); 240 control_input);
231 rep_nodes[0]->ReplaceInput(2, rep_nodes[1]); 241 rep_nodes[0]->ReplaceInput(2, rep_nodes[1]);
242 rep_nodes[0]->ReplaceInput(1, indices[0]);
232 } else { 243 } else {
233 for (size_t i = 1; i < kMaxLanes; ++i) { 244 for (size_t i = 1; i < kMaxLanes; ++i) {
234 rep_nodes[i] = graph()->NewNode(load_op, base, indices[i]); 245 rep_nodes[i] = graph()->NewNode(load_op, base, indices[i]);
235 } 246 }
236 } 247 }
237 ReplaceNode(node, rep_nodes); 248 ReplaceNode(node, rep_nodes);
238 } else { 249 } else {
239 DefaultLowering(node); 250 DefaultLowering(node);
240 } 251 }
241 } 252 }
(...skipping 18 matching lines...) Expand all
260 DCHECK(node->InputCount() > 4); 271 DCHECK(node->InputCount() > 4);
261 Node* effect_input = node->InputAt(3); 272 Node* effect_input = node->InputAt(3);
262 Node* control_input = node->InputAt(4); 273 Node* control_input = node->InputAt(4);
263 rep_nodes[3] = graph()->NewNode(store_op, base, indices[3], rep_inputs[3], 274 rep_nodes[3] = graph()->NewNode(store_op, base, indices[3], rep_inputs[3],
264 effect_input, control_input); 275 effect_input, control_input);
265 rep_nodes[2] = graph()->NewNode(store_op, base, indices[2], rep_inputs[2], 276 rep_nodes[2] = graph()->NewNode(store_op, base, indices[2], rep_inputs[2],
266 rep_nodes[3], control_input); 277 rep_nodes[3], control_input);
267 rep_nodes[1] = graph()->NewNode(store_op, base, indices[1], rep_inputs[1], 278 rep_nodes[1] = graph()->NewNode(store_op, base, indices[1], rep_inputs[1],
268 rep_nodes[2], control_input); 279 rep_nodes[2], control_input);
269 rep_nodes[0]->ReplaceInput(3, rep_nodes[1]); 280 rep_nodes[0]->ReplaceInput(3, rep_nodes[1]);
281 rep_nodes[0]->ReplaceInput(1, indices[0]);
270 282
271 } else { 283 } else {
272 for (size_t i = 1; i < kMaxLanes; ++i) { 284 for (size_t i = 1; i < kMaxLanes; ++i) {
273 rep_nodes[i] = 285 rep_nodes[i] =
274 graph()->NewNode(store_op, base, indices[i], rep_inputs[i]); 286 graph()->NewNode(store_op, base, indices[i], rep_inputs[i]);
275 } 287 }
276 } 288 }
277 289
278 ReplaceNode(node, rep_nodes); 290 ReplaceNode(node, rep_nodes);
279 } else { 291 } else {
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 } else { 874 } else {
863 UNREACHABLE(); 875 UNREACHABLE();
864 } 876 }
865 } 877 }
866 ReplaceNode(phi, rep_nodes); 878 ReplaceNode(phi, rep_nodes);
867 } 879 }
868 } 880 }
869 } // namespace compiler 881 } // namespace compiler
870 } // namespace internal 882 } // namespace internal
871 } // namespace v8 883 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/wasm-compiler.cc » ('j') | src/compiler/wasm-compiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698