Commit a367522a authored by whesse@chromium.org's avatar whesse@chromium.org

X64 implementation: comparison operations.

Review URL: http://codereview.chromium.org/146082

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2264 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ecfd1f10
......@@ -504,18 +504,34 @@ void Assembler::immediate_arithmetic_op_32(byte subcode,
void Assembler::immediate_arithmetic_op_8(byte subcode,
const Operand& dst,
Immediate src) {
const Operand& dst,
Immediate src) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
emit_optional_rex_32(dst);
ASSERT(is_int8(src.value_));
ASSERT(is_int8(src.value_) || is_uint8(src.value_));
emit(0x80);
emit_operand(subcode, dst);
emit(src.value_);
}
void Assembler::immediate_arithmetic_op_8(byte subcode,
Register dst,
Immediate src) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
if (dst.code() > 3) {
// Use 64-bit mode byte registers.
emit_rex_64(dst);
}
ASSERT(is_int8(src.value_) || is_uint8(src.value_));
emit(0x80);
emit_modrm(subcode, dst);
emit(src.value_);
}
void Assembler::shift(Register dst, Immediate shift_amount, int subcode) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
......
......@@ -544,6 +544,10 @@ class Assembler : public Malloced {
immediate_arithmetic_op_32(0x0, dst, src);
}
void cmpb(Register dst, Immediate src) {
immediate_arithmetic_op_8(0x7, dst, src);
}
void cmpb(const Operand& dst, Immediate src) {
immediate_arithmetic_op_8(0x7, dst, src);
}
......@@ -1077,10 +1081,13 @@ class Assembler : public Malloced {
void immediate_arithmetic_op_32(byte subcode,
Register dst,
Immediate src);
// Operate on a byte in memory.
// Operate on a byte in memory or register.
void immediate_arithmetic_op_8(byte subcode,
const Operand& dst,
Immediate src);
const Operand& dst,
Immediate src);
void immediate_arithmetic_op_8(byte subcode,
Register dst,
Immediate src);
// Emit machine code for a shift operation.
void shift(Register dst, Immediate shift_amount, int subcode);
// Shift dst by cl % 64 bits.
......
This diff is collapsed.
......@@ -309,6 +309,12 @@ void MacroAssembler::Cmp(Register dst, Handle<Object> source) {
}
void MacroAssembler::Cmp(const Operand& dst, Handle<Object> source) {
Move(kScratchRegister, source);
cmpq(dst, kScratchRegister);
}
void MacroAssembler::Push(Handle<Object> source) {
Move(kScratchRegister, source);
push(kScratchRegister);
......
......@@ -172,6 +172,7 @@ class MacroAssembler: public Assembler {
void Move(Register dst, Handle<Object> source);
void Move(const Operand& dst, Handle<Object> source);
void Cmp(Register dst, Handle<Object> source);
void Cmp(const Operand& dst, Handle<Object> source);
void Push(Handle<Object> source);
// Control Flow
......
......@@ -702,6 +702,39 @@ Result VirtualFrame::RawCallStub(CodeStub* stub) {
}
Result VirtualFrame::CallStub(CodeStub* stub, Result* arg) {
PrepareForCall(0, 0);
arg->ToRegister(rax);
arg->Unuse();
return RawCallStub(stub);
}
Result VirtualFrame::CallStub(CodeStub* stub, Result* arg0, Result* arg1) {
PrepareForCall(0, 0);
if (arg0->is_register() && arg0->reg().is(rax)) {
if (arg1->is_register() && arg1->reg().is(rdx)) {
// Wrong registers.
__ xchg(rax, rdx);
} else {
// Register rdx is free for arg0, which frees rax for arg1.
arg0->ToRegister(rdx);
arg1->ToRegister(rax);
}
} else {
// Register rax is free for arg1, which guarantees rdx is free for
// arg0.
arg1->ToRegister(rax);
arg0->ToRegister(rdx);
}
arg0->Unuse();
arg1->Unuse();
return RawCallStub(stub);
}
void VirtualFrame::SyncElementBelowStackPointer(int index) {
// Emit code to write elements below the stack pointer to their
// (already allocated) stack address.
......
......@@ -307,8 +307,8 @@ class VirtualFrame : public ZoneObject {
// even a register. The argument is consumed by the call.
Result CallStub(CodeStub* stub, Result* arg);
// Call stub that takes a pair of arguments passed in edx (arg0) and
// eax (arg1). The arguments are given as results which do not have
// Call stub that takes a pair of arguments passed in edx (arg0, rdx) and
// eax (arg1, rax). The arguments are given as results which do not have
// to be in the proper registers or even in registers. The
// arguments are consumed by the call.
Result CallStub(CodeStub* stub, Result* arg0, Result* arg1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment