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

Side by Side Diff: src/compiler/wasm-compiler.cc

Issue 2294743003: [wasm] simd scalar lowering F32x4Add and I32x4Add (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: [wasm] simd scalar lowering F32x4Add and I32x4Add Created 4 years, 2 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/wasm-compiler.h ('k') | src/compiler/wasm-linkage.cc » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/wasm-compiler.h" 5 #include "src/compiler/wasm-compiler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 10
11 #include "src/base/platform/elapsed-timer.h" 11 #include "src/base/platform/elapsed-timer.h"
12 #include "src/base/platform/platform.h" 12 #include "src/base/platform/platform.h"
13 13
14 #include "src/compiler/access-builder.h" 14 #include "src/compiler/access-builder.h"
15 #include "src/compiler/common-operator.h" 15 #include "src/compiler/common-operator.h"
16 #include "src/compiler/diamond.h" 16 #include "src/compiler/diamond.h"
17 #include "src/compiler/graph-visualizer.h" 17 #include "src/compiler/graph-visualizer.h"
18 #include "src/compiler/graph.h" 18 #include "src/compiler/graph.h"
19 #include "src/compiler/instruction-selector.h" 19 #include "src/compiler/instruction-selector.h"
20 #include "src/compiler/int64-lowering.h" 20 #include "src/compiler/int64-lowering.h"
21 #include "src/compiler/js-graph.h" 21 #include "src/compiler/js-graph.h"
22 #include "src/compiler/js-operator.h" 22 #include "src/compiler/js-operator.h"
23 #include "src/compiler/linkage.h" 23 #include "src/compiler/linkage.h"
24 #include "src/compiler/machine-operator.h" 24 #include "src/compiler/machine-operator.h"
25 #include "src/compiler/node-matchers.h" 25 #include "src/compiler/node-matchers.h"
26 #include "src/compiler/pipeline.h" 26 #include "src/compiler/pipeline.h"
27 #include "src/compiler/simd-scalar-lowering.h"
27 #include "src/compiler/source-position.h" 28 #include "src/compiler/source-position.h"
28 #include "src/compiler/zone-stats.h" 29 #include "src/compiler/zone-stats.h"
29 30
30 #include "src/code-factory.h" 31 #include "src/code-factory.h"
31 #include "src/code-stubs.h" 32 #include "src/code-stubs.h"
32 #include "src/factory.h" 33 #include "src/factory.h"
33 #include "src/log-inl.h" 34 #include "src/log-inl.h"
34 35
35 #include "src/wasm/ast-decoder.h" 36 #include "src/wasm/ast-decoder.h"
36 #include "src/wasm/wasm-module.h" 37 #include "src/wasm/wasm-module.h"
(...skipping 3002 matching lines...) Expand 10 before | Expand all | Expand 10 after
3039 3040
3040 void WasmGraphBuilder::Int64LoweringForTesting() { 3041 void WasmGraphBuilder::Int64LoweringForTesting() {
3041 if (jsgraph()->machine()->Is32()) { 3042 if (jsgraph()->machine()->Is32()) {
3042 Int64Lowering r(jsgraph()->graph(), jsgraph()->machine(), 3043 Int64Lowering r(jsgraph()->graph(), jsgraph()->machine(),
3043 jsgraph()->common(), jsgraph()->zone(), 3044 jsgraph()->common(), jsgraph()->zone(),
3044 function_signature_); 3045 function_signature_);
3045 r.LowerGraph(); 3046 r.LowerGraph();
3046 } 3047 }
3047 } 3048 }
3048 3049
3050 void WasmGraphBuilder::SimdScalarLoweringForTesting() {
3051 SimdScalarLowering(jsgraph()->graph(), jsgraph()->machine(),
3052 jsgraph()->common(), jsgraph()->zone(),
3053 function_signature_)
3054 .LowerGraph();
3055 }
3056
3049 void WasmGraphBuilder::SetSourcePosition(Node* node, 3057 void WasmGraphBuilder::SetSourcePosition(Node* node,
3050 wasm::WasmCodePosition position) { 3058 wasm::WasmCodePosition position) {
3051 DCHECK_NE(position, wasm::kNoCodePosition); 3059 DCHECK_NE(position, wasm::kNoCodePosition);
3052 compiler::SourcePosition pos(position); 3060 compiler::SourcePosition pos(position);
3053 if (source_position_table_) 3061 if (source_position_table_)
3054 source_position_table_->SetSourcePosition(node, pos); 3062 source_position_table_->SetSourcePosition(node, pos);
3055 } 3063 }
3056 3064
3057 Node* WasmGraphBuilder::CreateS128Value(int32_t value) { 3065 Node* WasmGraphBuilder::CreateS128Value(int32_t value) {
3058 // TODO(gdeepti): Introduce Simd128Constant to common-operator.h and use 3066 // TODO(gdeepti): Introduce Simd128Constant to common-operator.h and use
3059 // instead of creating a SIMD Value. 3067 // instead of creating a SIMD Value.
3060 return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(), 3068 return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(),
3061 Int32Constant(value), Int32Constant(value), 3069 Int32Constant(value), Int32Constant(value),
3062 Int32Constant(value), Int32Constant(value)); 3070 Int32Constant(value), Int32Constant(value));
3063 } 3071 }
3064 3072
3065 Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode, 3073 Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode,
3066 const NodeVector& inputs) { 3074 const NodeVector& inputs) {
3067 switch (opcode) { 3075 switch (opcode) {
3068 case wasm::kExprI32x4Splat: 3076 case wasm::kExprI32x4Splat:
3069 return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(), inputs[0], 3077 return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(), inputs[0],
3070 inputs[0], inputs[0], inputs[0]); 3078 inputs[0], inputs[0], inputs[0]);
3079 case wasm::kExprI32x4Add:
3080 return graph()->NewNode(jsgraph()->machine()->Int32x4Add(), inputs[0],
3081 inputs[1]);
3082 case wasm::kExprF32x4ExtractLane:
3083 return graph()->NewNode(jsgraph()->machine()->Float32x4ExtractLane(),
3084 inputs[0], inputs[1]);
3085 case wasm::kExprF32x4Splat:
3086 return graph()->NewNode(jsgraph()->machine()->CreateFloat32x4(),
3087 inputs[0], inputs[0], inputs[0], inputs[0]);
3088 case wasm::kExprF32x4Add:
3089 return graph()->NewNode(jsgraph()->machine()->Float32x4Add(), inputs[0],
3090 inputs[1]);
3071 default: 3091 default:
3072 return graph()->NewNode(UnsupportedOpcode(opcode), nullptr); 3092 return graph()->NewNode(UnsupportedOpcode(opcode), nullptr);
3073 } 3093 }
3074 } 3094 }
3075 3095
3076 Node* WasmGraphBuilder::SimdExtractLane(wasm::WasmOpcode opcode, uint8_t lane, 3096 Node* WasmGraphBuilder::SimdExtractLane(wasm::WasmOpcode opcode, uint8_t lane,
3077 Node* input) { 3097 Node* input) {
3078 switch (opcode) { 3098 switch (opcode) {
3079 case wasm::kExprI32x4ExtractLane: 3099 case wasm::kExprI32x4ExtractLane:
3080 return graph()->NewNode(jsgraph()->machine()->Int32x4ExtractLane(), input, 3100 return graph()->NewNode(jsgraph()->machine()->Int32x4ExtractLane(), input,
3081 Int32Constant(lane)); 3101 Int32Constant(lane));
3102 case wasm::kExprF32x4ExtractLane:
3103 return graph()->NewNode(jsgraph()->machine()->Float32x4ExtractLane(),
3104 input, Int32Constant(lane));
3082 default: 3105 default:
3083 return graph()->NewNode(UnsupportedOpcode(opcode), nullptr); 3106 return graph()->NewNode(UnsupportedOpcode(opcode), nullptr);
3084 } 3107 }
3085 } 3108 }
3086 3109
3087 static void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag, 3110 static void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
3088 Isolate* isolate, Handle<Code> code, 3111 Isolate* isolate, Handle<Code> code,
3089 const char* message, uint32_t index, 3112 const char* message, uint32_t index,
3090 const wasm::WasmName& module_name, 3113 const wasm::WasmName& module_name,
3091 const wasm::WasmName& func_name) { 3114 const wasm::WasmName& func_name) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
3287 os << "Compilation failed: " << graph_construction_result_ << std::endl; 3310 os << "Compilation failed: " << graph_construction_result_ << std::endl;
3288 } 3311 }
3289 return nullptr; 3312 return nullptr;
3290 } 3313 }
3291 3314
3292 if (machine->Is32()) { 3315 if (machine->Is32()) {
3293 Int64Lowering r(graph, machine, common, jsgraph_->zone(), function_->sig); 3316 Int64Lowering r(graph, machine, common, jsgraph_->zone(), function_->sig);
3294 r.LowerGraph(); 3317 r.LowerGraph();
3295 } 3318 }
3296 3319
3320 SimdScalarLowering(graph, machine, common, jsgraph_->zone(), function_->sig)
3321 .LowerGraph();
3322
3297 int index = static_cast<int>(function_->func_index); 3323 int index = static_cast<int>(function_->func_index);
3298 3324
3299 if (index >= FLAG_trace_wasm_ast_start && index < FLAG_trace_wasm_ast_end) { 3325 if (index >= FLAG_trace_wasm_ast_start && index < FLAG_trace_wasm_ast_end) {
3300 OFStream os(stdout); 3326 OFStream os(stdout);
3301 PrintAst(isolate_->allocator(), body, os, nullptr); 3327 PrintAst(isolate_->allocator(), body, os, nullptr);
3302 } 3328 }
3303 if (FLAG_trace_wasm_decode_time) { 3329 if (FLAG_trace_wasm_decode_time) {
3304 *decode_ms = decode_timer.Elapsed().InMillisecondsF(); 3330 *decode_ms = decode_timer.Elapsed().InMillisecondsF();
3305 } 3331 }
3306 return source_position_table; 3332 return source_position_table;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
3432 function_->code_start_offset), 3458 function_->code_start_offset),
3433 compile_ms); 3459 compile_ms);
3434 } 3460 }
3435 3461
3436 return code; 3462 return code;
3437 } 3463 }
3438 3464
3439 } // namespace compiler 3465 } // namespace compiler
3440 } // namespace internal 3466 } // namespace internal
3441 } // namespace v8 3467 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/compiler/wasm-linkage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698