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

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
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-pool.h" 29 #include "src/compiler/zone-pool.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 2977 matching lines...) Expand 10 before | Expand all | Expand 10 after
3014 3015
3015 void WasmGraphBuilder::Int64LoweringForTesting() { 3016 void WasmGraphBuilder::Int64LoweringForTesting() {
3016 if (jsgraph()->machine()->Is32()) { 3017 if (jsgraph()->machine()->Is32()) {
3017 Int64Lowering r(jsgraph()->graph(), jsgraph()->machine(), 3018 Int64Lowering r(jsgraph()->graph(), jsgraph()->machine(),
3018 jsgraph()->common(), jsgraph()->zone(), 3019 jsgraph()->common(), jsgraph()->zone(),
3019 function_signature_); 3020 function_signature_);
3020 r.LowerGraph(); 3021 r.LowerGraph();
3021 } 3022 }
3022 } 3023 }
3023 3024
3025 void WasmGraphBuilder::SimdScalarLoweringForTesting() {
3026 SimdScalarLowering(jsgraph()->graph(), jsgraph()->machine(),
3027 jsgraph()->common(), jsgraph()->zone(),
3028 function_signature_)
3029 .LowerGraph();
3030 }
3031
3024 void WasmGraphBuilder::SetSourcePosition(Node* node, 3032 void WasmGraphBuilder::SetSourcePosition(Node* node,
3025 wasm::WasmCodePosition position) { 3033 wasm::WasmCodePosition position) {
3026 DCHECK_NE(position, wasm::kNoCodePosition); 3034 DCHECK_NE(position, wasm::kNoCodePosition);
3027 compiler::SourcePosition pos(position); 3035 compiler::SourcePosition pos(position);
3028 if (source_position_table_) 3036 if (source_position_table_)
3029 source_position_table_->SetSourcePosition(node, pos); 3037 source_position_table_->SetSourcePosition(node, pos);
3030 } 3038 }
3031 3039
3032 Node* WasmGraphBuilder::CreateS128Value(int32_t value) { 3040 Node* WasmGraphBuilder::CreateS128Value(int32_t value) {
3033 // TODO(gdeepti): Introduce Simd128Constant to common-operator.h and use 3041 // TODO(gdeepti): Introduce Simd128Constant to common-operator.h and use
3034 // instead of creating a SIMD Value. 3042 // instead of creating a SIMD Value.
3035 return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(), 3043 return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(),
3036 Int32Constant(value), Int32Constant(value), 3044 Int32Constant(value), Int32Constant(value),
3037 Int32Constant(value), Int32Constant(value)); 3045 Int32Constant(value), Int32Constant(value));
3038 } 3046 }
3039 3047
3040 Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode, 3048 Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode,
3041 const NodeVector& inputs) { 3049 const NodeVector& inputs) {
3042 switch (opcode) { 3050 switch (opcode) {
3043 case wasm::kExprI32x4Splat: 3051 case wasm::kExprI32x4Splat:
3044 return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(), inputs[0], 3052 return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(), inputs[0],
3045 inputs[0], inputs[0], inputs[0]); 3053 inputs[0], inputs[0], inputs[0]);
3054 case wasm::kExprI32x4Add:
3055 return graph()->NewNode(jsgraph()->machine()->Int32x4Add(), inputs[0],
3056 inputs[1]);
3057 case wasm::kExprF32x4ExtractLane:
3058 return graph()->NewNode(jsgraph()->machine()->Float32x4ExtractLane(),
3059 inputs[0], inputs[1]);
3060 case wasm::kExprF32x4Splat:
3061 return graph()->NewNode(jsgraph()->machine()->CreateFloat32x4(),
3062 inputs[0], inputs[0], inputs[0], inputs[0]);
3063 case wasm::kExprF32x4Add:
3064 return graph()->NewNode(jsgraph()->machine()->Float32x4Add(), inputs[0],
3065 inputs[1]);
3046 default: 3066 default:
3047 return graph()->NewNode(UnsupportedOpcode(opcode), nullptr); 3067 return graph()->NewNode(UnsupportedOpcode(opcode), nullptr);
3048 } 3068 }
3049 } 3069 }
3050 3070
3051 Node* WasmGraphBuilder::SimdExtractLane(wasm::WasmOpcode opcode, uint8_t lane, 3071 Node* WasmGraphBuilder::SimdExtractLane(wasm::WasmOpcode opcode, uint8_t lane,
3052 Node* input) { 3072 Node* input) {
3053 switch (opcode) { 3073 switch (opcode) {
3054 case wasm::kExprI32x4ExtractLane: 3074 case wasm::kExprI32x4ExtractLane:
3055 return graph()->NewNode(jsgraph()->machine()->Int32x4ExtractLane(), input, 3075 return graph()->NewNode(jsgraph()->machine()->Int32x4ExtractLane(), input,
3056 Int32Constant(lane)); 3076 Int32Constant(lane));
3077 case wasm::kExprF32x4ExtractLane:
3078 return graph()->NewNode(jsgraph()->machine()->Float32x4ExtractLane(),
3079 input, Int32Constant(lane));
3057 default: 3080 default:
3058 return graph()->NewNode(UnsupportedOpcode(opcode), nullptr); 3081 return graph()->NewNode(UnsupportedOpcode(opcode), nullptr);
3059 } 3082 }
3060 } 3083 }
3061 3084
3062 static void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag, 3085 static void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
3063 Isolate* isolate, Handle<Code> code, 3086 Isolate* isolate, Handle<Code> code,
3064 const char* message, uint32_t index, 3087 const char* message, uint32_t index,
3065 const wasm::WasmName& module_name, 3088 const wasm::WasmName& module_name,
3066 const wasm::WasmName& func_name) { 3089 const wasm::WasmName& func_name) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
3262 os << "Compilation failed: " << graph_construction_result_ << std::endl; 3285 os << "Compilation failed: " << graph_construction_result_ << std::endl;
3263 } 3286 }
3264 return nullptr; 3287 return nullptr;
3265 } 3288 }
3266 3289
3267 if (machine->Is32()) { 3290 if (machine->Is32()) {
3268 Int64Lowering r(graph, machine, common, jsgraph_->zone(), function_->sig); 3291 Int64Lowering r(graph, machine, common, jsgraph_->zone(), function_->sig);
3269 r.LowerGraph(); 3292 r.LowerGraph();
3270 } 3293 }
3271 3294
3295 SimdScalarLowering(graph, machine, common, jsgraph_->zone(), function_->sig)
3296 .LowerGraph();
3297
3272 int index = static_cast<int>(function_->func_index); 3298 int index = static_cast<int>(function_->func_index);
3273 3299
3274 if (index >= FLAG_trace_wasm_ast_start && index < FLAG_trace_wasm_ast_end) { 3300 if (index >= FLAG_trace_wasm_ast_start && index < FLAG_trace_wasm_ast_end) {
3275 OFStream os(stdout); 3301 OFStream os(stdout);
3276 PrintAst(isolate_->allocator(), body, os, nullptr); 3302 PrintAst(isolate_->allocator(), body, os, nullptr);
3277 } 3303 }
3278 if (FLAG_trace_wasm_decode_time) { 3304 if (FLAG_trace_wasm_decode_time) {
3279 *decode_ms = decode_timer.Elapsed().InMillisecondsF(); 3305 *decode_ms = decode_timer.Elapsed().InMillisecondsF();
3280 } 3306 }
3281 return source_position_table; 3307 return source_position_table;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
3407 function_->code_start_offset), 3433 function_->code_start_offset),
3408 compile_ms); 3434 compile_ms);
3409 } 3435 }
3410 3436
3411 return code; 3437 return code;
3412 } 3438 }
3413 3439
3414 } // namespace compiler 3440 } // namespace compiler
3415 } // namespace internal 3441 } // namespace internal
3416 } // namespace v8 3442 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698