From 463290b8eacd108ff524f853d2c5cf59a45210f6 Mon Sep 17 00:00:00 2001 From: Eric Caruso Date: Fri, 21 Jun 2013 18:24:00 -0700 Subject: [PATCH] Adds decl and decw instructions that operate on registers Cherry-pick of D851076 which was reverted in the OSS segfault catastrophe. --- hphp/util/asm-x64.h | 3 ++- hphp/util/test/asm.cpp | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/hphp/util/asm-x64.h b/hphp/util/asm-x64.h index a307082398e..e2c083d700d 100644 --- a/hphp/util/asm-x64.h +++ b/hphp/util/asm-x64.h @@ -1090,7 +1090,8 @@ struct X64Assembler { void incl(Reg32 r) { instrR(instr_inc, r); } void incw(Reg16 r) { instrR(instr_inc, r); } void decq(Reg64 r) { instrR(instr_dec, r); } - // decl(Reg32) cannot be encoded; it's REX. + void decl(Reg32 r) { instrR(instr_dec, r); } + void decw(Reg16 r) { instrR(instr_dec, r); } void notb(Reg8 r) { instrR(instr_notb, r); } void not(Reg64 r) { instrR(instr_not, r); } void neg(Reg64 r) { instrR(instr_neg, r); } diff --git a/hphp/util/test/asm.cpp b/hphp/util/test/asm.cpp index 3d50cb341b2..0faa652f74c 100644 --- a/hphp/util/test/asm.cpp +++ b/hphp/util/test/asm.cpp @@ -510,6 +510,41 @@ TEST(Asm, RetImmediate) { ASSERT_FALSE(a.code.base[0] == kOpsizePrefix); } +TEST(Asm, IncDecRegs) { + Asm a; + a.init(10 << 24); + + // incq, incl, incw + a. incq(rax); + a. incl(eax); + a. incw(ax); + a. incq(r15); + a. incl(r15d); + a. incw(r15w); + // decq, decl, decw + a. decq(rax); + a. decl(eax); + a. decw(ax); + a. decq(r15); + a. decl(r15d); + a. decw(r15w); + + expect_asm(a, R"( +inc %rax +inc %eax +inc %ax +inc %r15 +inc %r15d +inc %r15w +dec %rax +dec %eax +dec %ax +dec %r15 +dec %r15d +dec %r15w +)"); +} + TEST(Asm, HighByteReg) { Asm a; a.init(10 << 24); -- 2.11.4.GIT