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

Unified Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 2301293002: kernel -> ssa: implement if-statements (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/ssa/builder_kernel.dart
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index 2e107bce7a3590aebbe5283701a917279120c803..f1294a442e966673024e92a4b2e9a6773b53f638 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:compiler/src/ssa/ssa_branch_builder.dart';
import 'package:kernel/ast.dart' as ir;
import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem;
@@ -67,7 +68,6 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
JavaScriptBackend get backend => compiler.backend;
- LocalsHandler localsHandler;
SourceInformationBuilder sourceInformationBuilder;
KernelAstAdapter astAdapter;
@@ -113,6 +113,23 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
return graph;
}
+ @override
+ HBoolify popBoolified() {
+ HInstruction value = pop();
+ // TODO(het): add boolean conversion type check
Siggi Cherem (dart-lang) 2016/09/01 23:51:21 once you do, would this method move to GraphBuilde
Harry Terkelsen 2016/09/02 17:52:27 Yes, if we also pass in the boolType
+ HInstruction result = new HBoolify(value, backend.boolType);
+ add(result);
+ return result;
+ }
+
+ // TODO(het): This implementation is shared with [SsaBuilder]. Should we just
+ // allow [GraphBuilder] to access `compiler`?
Siggi Cherem (dart-lang) 2016/09/01 23:51:22 seems ok, is it only for boolType? We could also j
Harry Terkelsen 2016/09/02 17:52:27 It's for boolType and for the 'compiler' argument
+ @override
+ pushCheckNull(HInstruction expression) {
+ push(new HIdentity(
+ expression, graph.addConstantNull(compiler), null, backend.boolType));
+ }
+
/// Builds a SSA graph for [method].
void buildMethod(IrFunction method, FunctionElement functionElement) {
openFunction(method, functionElement);
@@ -172,6 +189,15 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
}
@override
+ void visitIfStatement(ir.IfStatement ifStatement) {
+ SsaBranchBuilder branchBuilder = new SsaBranchBuilder(this, compiler);
+ branchBuilder.handleIf(
+ () => ifStatement.condition.accept(this),
+ () => ifStatement.then.accept(this),
+ () => ifStatement.otherwise?.accept(this));
+ }
+
+ @override
void visitIntLiteral(ir.IntLiteral intLiteral) {
stack.add(graph.addConstantInt(intLiteral.value, compiler));
}

Powered by Google App Engine
This is Rietveld 408576698