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

Unified Diff: runtime/vm/intermediate_language_mips.cc

Issue 2947633002: VM-codegen: Clean up the way we emit code for comparison instructions. (Closed)
Patch Set: Simplify DBC ComparisonInstr::EmitNativeCode Created 3 years, 6 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
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_mips.cc
diff --git a/runtime/vm/intermediate_language_mips.cc b/runtime/vm/intermediate_language_mips.cc
index 07959dead945cdd3d628852d344bb0cb03a0f482..e513f5ed3f22e3d5ac63481219c66b9825492c87 100644
--- a/runtime/vm/intermediate_language_mips.cc
+++ b/runtime/vm/intermediate_language_mips.cc
@@ -178,8 +178,11 @@ void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
__ LoadImmediate(result, Smi::RawValue(true_value));
// Emit comparison code. This must not overwrite the result register.
+ // IfThenElseInstr::Supports() should prevent EmitComparisonCode from using
+ // the labels or returning an invalid condition.
BranchLabels labels = {NULL, NULL, NULL}; // Emit branch-free code.
Condition true_condition = comparison()->EmitComparisonCode(compiler, labels);
+ ASSERT(true_condition.IsValid());
if (swapped) {
true_condition = NegateCondition(true_condition);
}
@@ -781,16 +784,15 @@ Condition EqualityCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
}
-void EqualityCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ));
- __ Comment("EqualityCompareInstr");
-
+void ComparisonInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
Label is_true, is_false;
BranchLabels labels = {&is_true, &is_false, &is_false};
Condition true_condition = EmitComparisonCode(compiler, labels);
- EmitBranchOnCondition(compiler, true_condition, labels);
+ if (true_condition.IsValid()) {
+ EmitBranchOnCondition(compiler, true_condition, labels);
+ }
- Register result = locs()->out(0).reg();
+ Register result = this->locs()->out(0).reg();
Label done;
__ Bind(&is_false);
__ LoadObject(result, Bool::False());
@@ -801,14 +803,13 @@ void EqualityCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
}
-void EqualityCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler,
- BranchInstr* branch) {
- __ Comment("EqualityCompareInstr::EmitBranchCode");
- ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ));
-
+void ComparisonInstr::EmitBranchCode(FlowGraphCompiler* compiler,
+ BranchInstr* branch) {
BranchLabels labels = compiler->CreateBranchLabels(branch);
Condition true_condition = EmitComparisonCode(compiler, labels);
- EmitBranchOnCondition(compiler, true_condition, labels);
+ if (true_condition.IsValid()) {
+ EmitBranchOnCondition(compiler, true_condition, labels);
+ }
}
@@ -840,20 +841,6 @@ Condition TestSmiInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
}
-void TestSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- // Never emitted outside of the BranchInstr.
- UNREACHABLE();
-}
-
-
-void TestSmiInstr::EmitBranchCode(FlowGraphCompiler* compiler,
- BranchInstr* branch) {
- BranchLabels labels = compiler->CreateBranchLabels(branch);
- Condition true_condition = EmitComparisonCode(compiler, labels);
- EmitBranchOnCondition(compiler, true_condition, labels);
-}
-
-
LocationSummary* TestCidsInstr::MakeLocationSummary(Zone* zone,
bool opt) const {
const intptr_t kNumInputs = 1;
@@ -906,29 +893,9 @@ Condition TestCidsInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
} else {
__ b(deopt);
}
- // Dummy result as the last instruction is a jump or fall through.
- return Condition(CMPRES1, ZR, AL);
-}
-
-
-void TestCidsInstr::EmitBranchCode(FlowGraphCompiler* compiler,
- BranchInstr* branch) {
- BranchLabels labels = compiler->CreateBranchLabels(branch);
- EmitComparisonCode(compiler, labels);
-}
-
-
-void TestCidsInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- Register result_reg = locs()->out(0).reg();
- Label is_true, is_false, done;
- BranchLabels labels = {&is_true, &is_false, &is_false};
- EmitComparisonCode(compiler, labels);
- __ Bind(&is_false);
- __ LoadObject(result_reg, Bool::False());
- __ b(&done);
- __ Bind(&is_true);
- __ LoadObject(result_reg, Bool::True());
- __ Bind(&done);
+ // Dummy result as this method already did the jump, there's no need
+ // for the caller to branch on a condition.
+ return Condition(ZR, ZR, INVALID_RELATION);
}
@@ -982,35 +949,6 @@ Condition RelationalOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
}
-void RelationalOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- __ Comment("RelationalOpInstr");
-
- Label is_true, is_false;
- BranchLabels labels = {&is_true, &is_false, &is_false};
- Condition true_condition = EmitComparisonCode(compiler, labels);
- EmitBranchOnCondition(compiler, true_condition, labels);
-
- Register result = locs()->out(0).reg();
- Label done;
- __ Bind(&is_false);
- __ LoadObject(result, Bool::False());
- __ b(&done);
- __ Bind(&is_true);
- __ LoadObject(result, Bool::True());
- __ Bind(&done);
-}
-
-
-void RelationalOpInstr::EmitBranchCode(FlowGraphCompiler* compiler,
- BranchInstr* branch) {
- __ Comment("RelationalOpInstr");
-
- BranchLabels labels = compiler->CreateBranchLabels(branch);
- Condition true_condition = EmitComparisonCode(compiler, labels);
- EmitBranchOnCondition(compiler, true_condition, labels);
-}
-
-
LocationSummary* NativeCallInstr::MakeLocationSummary(Zone* zone,
bool opt) const {
return MakeCallSummary(zone);
@@ -3247,6 +3185,7 @@ void CheckedSmiComparisonInstr::EmitBranchCode(FlowGraphCompiler* compiler,
compiler->AddSlowPathCode(slow_path);
EMIT_SMI_CHECK;
Condition true_condition = EmitComparisonCode(compiler, labels);
+ ASSERT(true_condition.IsValid());
EmitBranchOnCondition(compiler, true_condition, labels);
__ Bind(slow_path->exit_label());
}
@@ -3261,6 +3200,7 @@ void CheckedSmiComparisonInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
compiler->AddSlowPathCode(slow_path);
EMIT_SMI_CHECK;
Condition true_condition = EmitComparisonCode(compiler, labels);
+ ASSERT(true_condition.IsValid());
EmitBranchOnCondition(compiler, true_condition, labels);
Register result = locs()->out(0).reg();
__ Bind(&false_label);
@@ -3975,7 +3915,7 @@ Condition DoubleTestOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
}
__ b(labels.true_label);
}
- return Condition(); // Unused.
+ return Condition(ZR, ZR, INVALID_RELATION); // Unused.
} else {
ASSERT(op_kind() == MethodRecognizer::kDouble_getIsInfinite);
__ mfc1(CMPRES1, EvenFRegisterOf(value));
@@ -3990,38 +3930,6 @@ Condition DoubleTestOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
}
}
-void DoubleTestOpInstr::EmitBranchCode(FlowGraphCompiler* compiler,
- BranchInstr* branch) {
- ASSERT(compiler->is_optimizing());
- BranchLabels labels = compiler->CreateBranchLabels(branch);
- Condition true_condition = EmitComparisonCode(compiler, labels);
- // Branches for isNaN are emitted in EmitComparisonCode already.
- if (op_kind() == MethodRecognizer::kDouble_getIsInfinite) {
- EmitBranchOnCondition(compiler, true_condition, labels);
- }
-}
-
-
-void DoubleTestOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- Label is_true, is_false;
- BranchLabels labels = {&is_true, &is_false, &is_false};
- Condition true_condition = EmitComparisonCode(compiler, labels);
- // Branches for isNaN are emitted in EmitComparisonCode already.
- if (op_kind() == MethodRecognizer::kDouble_getIsInfinite) {
- EmitBranchOnCondition(compiler, true_condition, labels);
- }
- const Register result = locs()->out(0).reg();
- Label done;
- __ Comment("return bool");
- __ Bind(&is_false);
- __ LoadObject(result, Bool::False());
- __ b(&done);
- __ Bind(&is_true);
- __ LoadObject(result, Bool::True());
- __ Bind(&done);
-}
-
-
LocationSummary* BinaryFloat32x4OpInstr::MakeLocationSummary(Zone* zone,
bool opt) const {
UNIMPLEMENTED();
@@ -5986,37 +5894,6 @@ Condition StrictCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
}
-void StrictCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- __ Comment("StrictCompareInstr");
- ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT);
-
- Label is_true, is_false;
- BranchLabels labels = {&is_true, &is_false, &is_false};
- Condition true_condition = EmitComparisonCode(compiler, labels);
- EmitBranchOnCondition(compiler, true_condition, labels);
-
- Register result = locs()->out(0).reg();
- Label done;
- __ Bind(&is_false);
- __ LoadObject(result, Bool::False());
- __ b(&done);
- __ Bind(&is_true);
- __ LoadObject(result, Bool::True());
- __ Bind(&done);
-}
-
-
-void StrictCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler,
- BranchInstr* branch) {
- __ Comment("StrictCompareInstr::EmitBranchCode");
- ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT);
-
- BranchLabels labels = compiler->CreateBranchLabels(branch);
- Condition true_condition = EmitComparisonCode(compiler, labels);
- EmitBranchOnCondition(compiler, true_condition, labels);
-}
-
-
LocationSummary* BooleanNegateInstr::MakeLocationSummary(Zone* zone,
bool opt) const {
return LocationSummary::Make(zone, 1, Location::RequiresRegister(),
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698