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

Unified Diff: src/x64/assembler-x64.cc

Issue 115816: Add immediate operands and arithmetic operations to the x64 assembler. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 7 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/x64/assembler-x64.h ('k') | src/x64/assembler-x64-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/assembler-x64.cc
===================================================================
--- src/x64/assembler-x64.cc (revision 2068)
+++ src/x64/assembler-x64.cc (working copy)
@@ -301,24 +301,58 @@
// Assembler Instruction implementations
-void Assembler::add(Register dst, const Operand& src) {
+void Assembler::arithmetic_op(byte opcode, Register reg, const Operand& op) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
- emit_rex_64(dst, src);
- EMIT(0x03);
- emit_operand(dst, src);
+ emit_rex_64(reg, op);
+ EMIT(opcode);
+ emit_operand(reg, op);
}
-void Assembler::add(Register dst, Register src) {
+void Assembler::arithmetic_op(byte opcode, Register dst, Register src) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
emit_rex_64(dst, src);
- EMIT(0x03);
+ EMIT(opcode);
EMIT(0xC0 | (dst.code() & 0x7) << 3 | (src.code() & 0x7));
}
+void Assembler::immediate_arithmetic_op(byte subcode,
+ Register dst,
+ Immediate src) {
+ EnsureSpace ensure_space(this);
+ last_pc_ = pc_;
+ emit_rex_64(rax, dst);
+ if (is_int8(src.value_)) {
+ EMIT(0x83);
+ EMIT(0xC0 | (subcode << 3) | (dst.code() & 0x7));
+ EMIT(src.value_);
+ } else {
+ EMIT(0x81);
+ EMIT(0xC0 | (subcode << 3) | (dst.code() & 0x7));
+ emitl(src.value_);
+ }
+}
+void Assembler::immediate_arithmetic_op(byte subcode,
+ const Operand& dst,
+ Immediate src) {
+ EnsureSpace ensure_space(this);
+ last_pc_ = pc_;
+ emit_rex_64(rax, dst);
+ if (is_int8(src.value_)) {
+ EMIT(0x83);
+ emit_operand(Register::toRegister(subcode), dst);
+ EMIT(src.value_);
+ } else {
+ EMIT(0x81);
+ emit_operand(Register::toRegister(subcode), dst);
+ emitl(src.value_);
+ }
+}
+
+
void Assembler::call(Label* L) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
@@ -327,14 +361,14 @@
if (L->is_bound()) {
int offset = L->pos() - pc_offset() - sizeof(int32_t);
ASSERT(offset <= 0);
- emit(offset);
+ emitl(offset);
} else if (L->is_linked()) {
- emit(L->pos());
+ emitl(L->pos());
L->link_to(pc_offset() - sizeof(int32_t));
} else {
ASSERT(L->is_unused());
int32_t current = pc_offset();
- emit(current);
+ emitl(current);
L->link_to(current);
}
}
@@ -407,20 +441,20 @@
// 0000 1111 1000 tttn #32-bit disp
EMIT(0x0F);
EMIT(0x80 | cc);
- emit(offs - long_size);
+ emitl(offs - long_size);
}
} else if (L->is_linked()) {
// 0000 1111 1000 tttn #32-bit disp
EMIT(0x0F);
EMIT(0x80 | cc);
- emit(L->pos());
+ emitl(L->pos());
L->link_to(pc_offset() - sizeof(int32_t));
} else {
ASSERT(L->is_unused());
EMIT(0x0F);
EMIT(0x80 | cc);
int32_t current = pc_offset();
- emit(current);
+ emitl(current);
L->link_to(current);
}
}
@@ -439,25 +473,25 @@
} else {
// 1110 1001 #32-bit disp
EMIT(0xE9);
- emit(offs - sizeof(int32_t));
+ emitl(offs - sizeof(int32_t));
}
} else if (L->is_linked()) {
// 1110 1001 #32-bit disp
EMIT(0xE9);
- emit(L->pos());
+ emitl(L->pos());
L->link_to(pc_offset() - sizeof(int32_t));
} else {
// 1110 1001 #32-bit disp
ASSERT(L->is_unused());
EMIT(0xE9);
int32_t current = pc_offset();
- emit(current);
+ emitl(current);
L->link_to(current);
}
}
-void Assembler::mov(Register dst, const Operand& src) {
+void Assembler::movq(Register dst, const Operand& src) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
emit_rex_64(dst, src);
@@ -466,7 +500,7 @@
}
-void Assembler::mov(Register dst, Register src) {
+void Assembler::movq(Register dst, Register src) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
emit_rex_64(dst, src);
@@ -475,12 +509,32 @@
}
+void Assembler::movq(Register dst, Immediate value) {
+ EnsureSpace ensure_space(this);
+ last_pc_ = pc_;
+ emit_rex_64(rax, dst);
+ EMIT(0xC7);
+ EMIT(0xC0 | (dst.code() & 0x7));
+ emit(value); // Only 32-bit immediates are possible, not 8-bit immediates.
+}
+
+
+void Assembler::movq(Register dst, int64_t value, RelocInfo::Mode rmode) {
+ EnsureSpace ensure_space(this);
+ last_pc_ = pc_;
+ emit_rex_64(rax, dst);
+ EMIT(0xB8 | (dst.code() & 0x7));
+ emitq(value, rmode);
+}
+
+
void Assembler::nop() {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
EMIT(0x90);
}
+
void Assembler::pop(Register dst) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x64/assembler-x64-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698