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

Unified Diff: src/mips64/macro-assembler-mips64.cc

Issue 2101123005: [turbofan] Introduce integer multiplication with overflow. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Created 4 years, 5 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 | « src/mips64/macro-assembler-mips64.h ('k') | test/cctest/compiler/test-run-machops.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mips64/macro-assembler-mips64.cc
diff --git a/src/mips64/macro-assembler-mips64.cc b/src/mips64/macro-assembler-mips64.cc
index 9f689190b1fb56757a73729a3b94614201cba68d..97d63a421ca496bc8eea9343d4cc7ffce1ef43ea 100644
--- a/src/mips64/macro-assembler-mips64.cc
+++ b/src/mips64/macro-assembler-mips64.cc
@@ -5871,6 +5871,78 @@ void MacroAssembler::DsubBranchOvf(Register dst, Register left, Register right,
BranchOvfHelper(this, overflow_dst, overflow_label, no_overflow_label);
}
+static inline void BranchOvfHelperMult(MacroAssembler* masm,
+ Register overflow_dst,
+ Label* overflow_label,
+ Label* no_overflow_label) {
+ DCHECK(overflow_label || no_overflow_label);
+ if (!overflow_label) {
+ DCHECK(no_overflow_label);
+ masm->Branch(no_overflow_label, eq, overflow_dst, Operand(zero_reg));
+ } else {
+ masm->Branch(overflow_label, ne, overflow_dst, Operand(zero_reg));
+ if (no_overflow_label) masm->Branch(no_overflow_label);
+ }
+}
+
+void MacroAssembler::MulBranchOvf(Register dst, Register left,
+ const Operand& right, Label* overflow_label,
+ Label* no_overflow_label, Register scratch) {
+ DCHECK(overflow_label || no_overflow_label);
+ if (right.is_reg()) {
+ MulBranchOvf(dst, left, right.rm(), overflow_label, no_overflow_label,
+ scratch);
+ } else {
+ Register overflow_dst = t9;
+ DCHECK(!dst.is(scratch));
+ DCHECK(!dst.is(overflow_dst));
+ DCHECK(!scratch.is(overflow_dst));
+ DCHECK(!left.is(overflow_dst));
+ DCHECK(!left.is(scratch));
+
+ if (dst.is(left)) {
+ Mul(scratch, left, static_cast<int32_t>(right.immediate()));
+ Mulh(overflow_dst, left, static_cast<int32_t>(right.immediate()));
+ mov(dst, scratch);
+ } else {
+ Mul(dst, left, static_cast<int32_t>(right.immediate()));
+ Mulh(overflow_dst, left, static_cast<int32_t>(right.immediate()));
+ }
+
+ dsra32(scratch, dst, 0);
+ xor_(overflow_dst, overflow_dst, scratch);
+
+ BranchOvfHelperMult(this, overflow_dst, overflow_label, no_overflow_label);
+ }
+}
+
+void MacroAssembler::MulBranchOvf(Register dst, Register left, Register right,
+ Label* overflow_label,
+ Label* no_overflow_label, Register scratch) {
+ DCHECK(overflow_label || no_overflow_label);
+ Register overflow_dst = t9;
+ DCHECK(!dst.is(scratch));
+ DCHECK(!dst.is(overflow_dst));
+ DCHECK(!scratch.is(overflow_dst));
+ DCHECK(!overflow_dst.is(left));
+ DCHECK(!overflow_dst.is(right));
+ DCHECK(!scratch.is(left));
+ DCHECK(!scratch.is(right));
+
+ if (dst.is(left) || dst.is(right)) {
+ Mul(scratch, left, right);
+ Mulh(overflow_dst, left, right);
+ mov(dst, scratch);
+ } else {
+ Mul(dst, left, right);
+ Mulh(overflow_dst, left, right);
+ }
+
+ dsra32(scratch, dst, 0);
+ xor_(overflow_dst, overflow_dst, scratch);
+
+ BranchOvfHelperMult(this, overflow_dst, overflow_label, no_overflow_label);
+}
void MacroAssembler::CallRuntime(const Runtime::Function* f, int num_arguments,
SaveFPRegsMode save_doubles,
« no previous file with comments | « src/mips64/macro-assembler-mips64.h ('k') | test/cctest/compiler/test-run-machops.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698