Skip to content

Commit

Permalink
[vm/assembler] Add IMUL with implicit operands
Browse files Browse the repository at this point in the history
Rationale:
Needed for an upcoming improvement of DIV/MOD by constant.

#37789

Change-Id: I3966049a3f14fd3becec797c4bc0038f2852bc1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114680
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
  • Loading branch information
aartbik authored and commit-bot@chromium.org committed Aug 28, 2019
1 parent 040fdf2 commit 451a7dd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions runtime/vm/compiler/assembler/assembler_x64.h
Expand Up @@ -590,6 +590,7 @@ class Assembler : public AssemblerBase {
REGULAR_UNARY(not, 0xF7, 2)
REGULAR_UNARY(neg, 0xF7, 3)
REGULAR_UNARY(mul, 0xF7, 4)
REGULAR_UNARY(imul, 0xF7, 5)
REGULAR_UNARY(div, 0xF7, 6)
REGULAR_UNARY(idiv, 0xF7, 7)
REGULAR_UNARY(inc, 0xFF, 0)
Expand Down
19 changes: 19 additions & 0 deletions runtime/vm/compiler/assembler/assembler_x64_test.cc
Expand Up @@ -855,6 +855,25 @@ ASSEMBLER_TEST_RUN(UnsignedMultiply, test) {
"ret\n");
}

ASSEMBLER_TEST_GENERATE(SignedMultiply64Implicit, assembler) {
__ movq(RAX, Immediate(7));
__ movq(RDX, Immediate(-3));
__ imulq(RDX); // // RDX:RAX = -21
__ addq(RAX, RDX);
__ ret();
}

ASSEMBLER_TEST_RUN(SignedMultiply64Implicit, test) {
typedef int (*SignedMultiply64Implicit)();
EXPECT_EQ(-22, reinterpret_cast<SignedMultiply64Implicit>(test->entry())());
EXPECT_DISASSEMBLY(
"movl rax,7\n"
"movq rdx,-3\n"
"imulq (rax,rdx),rdx\n"
"addq rax,rdx\n"
"ret\n");
}

ASSEMBLER_TEST_GENERATE(SignedMultiply64, assembler) {
__ pushq(R15); // Callee saved.
__ movq(RAX, Immediate(2));
Expand Down

0 comments on commit 451a7dd

Please sign in to comment.