}
+TEST_F(AssemblerX86Test, CmovlAddress) {
+ GetAssembler()->cmovl(x86::kEqual, x86::Register(x86::EAX), x86::Address(
+ x86::Register(x86::EDI), x86::Register(x86::EBX), x86::TIMES_4, 12));
+ GetAssembler()->cmovl(x86::kNotEqual, x86::Register(x86::EDI), x86::Address(
+ x86::Register(x86::ESI), x86::Register(x86::EBX), x86::TIMES_4, 12));
+ GetAssembler()->cmovl(x86::kEqual, x86::Register(x86::EDI), x86::Address(
+ x86::Register(x86::EDI), x86::Register(x86::EAX), x86::TIMES_4, 12));
+ const char* expected =
+ "cmovzl 0xc(%EDI,%EBX,4), %eax\n"
+ "cmovnzl 0xc(%ESI,%EBX,4), %edi\n"
+ "cmovzl 0xc(%EDI,%EAX,4), %edi\n";
+
+ DriverStr(expected, "cmovl_address");
+}
+
/////////////////
// Near labels //
/////////////////
}
+void X86_64Assembler::cmov(Condition c, CpuRegister dst, const Address& src, bool is64bit) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ if (is64bit) {
+ EmitRex64(dst, src);
+ } else {
+ EmitOptionalRex32(dst, src);
+ }
+ EmitUint8(0x0F);
+ EmitUint8(0x40 + c);
+ EmitOperand(dst.LowBits(), src);
+}
+
+
void X86_64Assembler::movzxb(CpuRegister dst, CpuRegister src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitOptionalByteRegNormalizingRex32(dst, src);
DriverStr(expected, "popcntq_address");
}
+TEST_F(AssemblerX86_64Test, CmovlAddress) {
+ GetAssembler()->cmov(x86_64::kEqual, x86_64::CpuRegister(x86_64::R10), x86_64::Address(
+ x86_64::CpuRegister(x86_64::RDI), x86_64::CpuRegister(x86_64::RBX), x86_64::TIMES_4, 12), false);
+ GetAssembler()->cmov(x86_64::kNotEqual, x86_64::CpuRegister(x86_64::RDI), x86_64::Address(
+ x86_64::CpuRegister(x86_64::R10), x86_64::CpuRegister(x86_64::RBX), x86_64::TIMES_4, 12), false);
+ GetAssembler()->cmov(x86_64::kEqual, x86_64::CpuRegister(x86_64::RDI), x86_64::Address(
+ x86_64::CpuRegister(x86_64::RDI), x86_64::CpuRegister(x86_64::R9), x86_64::TIMES_4, 12), false);
+ const char* expected =
+ "cmovzl 0xc(%RDI,%RBX,4), %R10d\n"
+ "cmovnzl 0xc(%R10,%RBX,4), %edi\n"
+ "cmovzl 0xc(%RDI,%R9,4), %edi\n";
+
+ DriverStr(expected, "cmovl_address");
+}
+
+TEST_F(AssemblerX86_64Test, CmovqAddress) {
+ GetAssembler()->cmov(x86_64::kEqual, x86_64::CpuRegister(x86_64::R10), x86_64::Address(
+ x86_64::CpuRegister(x86_64::RDI), x86_64::CpuRegister(x86_64::RBX), x86_64::TIMES_4, 12), true);
+ GetAssembler()->cmov(x86_64::kNotEqual, x86_64::CpuRegister(x86_64::RDI), x86_64::Address(
+ x86_64::CpuRegister(x86_64::R10), x86_64::CpuRegister(x86_64::RBX), x86_64::TIMES_4, 12), true);
+ GetAssembler()->cmov(x86_64::kEqual, x86_64::CpuRegister(x86_64::RDI), x86_64::Address(
+ x86_64::CpuRegister(x86_64::RDI), x86_64::CpuRegister(x86_64::R9), x86_64::TIMES_4, 12), true);
+ const char* expected =
+ "cmovzq 0xc(%RDI,%RBX,4), %R10\n"
+ "cmovnzq 0xc(%R10,%RBX,4), %rdi\n"
+ "cmovzq 0xc(%RDI,%R9,4), %rdi\n";
+
+ DriverStr(expected, "cmovq_address");
+}
+
+
/////////////////
// Near labels //
/////////////////