Showing with 69 additions and 22 deletions.
  1. +28 −8 src/ia32/assembler-ia32-inl.h
  2. +1 −0 src/ia32/assembler-ia32.h
  3. +1 −1 src/ia32/macroassembler-ia32.cc
  4. +35 −10 src/x64/assembler-x64-inl.h
  5. +2 −2 src/x64/assembler-x64.cc
  6. +1 −0 src/x64/assembler-x64.h
  7. +1 −1 src/x64/macroassembler-x64.cc
@@ -32,8 +32,13 @@ inline void Assembler::emit_modrm(Register dst, Register src) {

inline void Assembler::emit_modrm(Register dst, Operand& src) {
if (src.scale() == Operand::one) {
emitb(0x80 | dst.low() << 3 | src.base().low());
emitl(src.disp());
if (src.byte_disp()) {
emitb(0x40 | dst.low() << 3 | src.base().low());
emitb(src.disp());
} else {
emitb(0x80 | dst.low() << 3 | src.base().low());
emitl(src.disp());
}
} else {
}
}
@@ -45,8 +50,13 @@ inline void Assembler::emit_modrm(Register dst, uint32_t op) {


inline void Assembler::emit_modrm(Operand& dst, uint32_t op) {
emitb(0x80 | op << 3 | dst.base().low());
emitl(dst.disp());
if (dst.byte_disp()) {
emitb(0x40 | op << 3 | dst.base().low());
emitb(dst.disp());
} else {
emitb(0x80 | op << 3 | dst.base().low());
emitl(dst.disp());
}
}


@@ -66,14 +76,24 @@ inline void Assembler::emit_modrm(DoubleRegister dst, DoubleRegister src) {


inline void Assembler::emit_modrm(DoubleRegister dst, Operand& src) {
emitb(0x80 | dst.low() << 3 | src.base().low());
emitl(src.disp());
if (src.byte_disp()) {
emitb(0x40 | dst.low() << 3 | src.base().low());
emitb(src.disp());
} else {
emitb(0x80 | dst.low() << 3 | src.base().low());
emitl(src.disp());
}
}


inline void Assembler::emit_modrm(Operand& dst, DoubleRegister src) {
emitb(0x80 | dst.base().low() << 3 | src.low());
emitl(dst.disp());
if (dst.byte_disp()) {
emitb(0x40 | dst.base().low() << 3 | src.low());
emitb(dst.disp());
} else {
emitb(0x80 | dst.base().low() << 3 | src.low());
emitl(dst.disp());
}
}


@@ -168,6 +168,7 @@ class Operand : public ZoneObject {
inline Register base(Register base) { return base_ = base; }
inline Scale scale(Scale scale) { return scale_ = scale; }
inline int32_t disp(int32_t disp) { return disp_ = disp; }
inline bool byte_disp() { return disp() > -128 && disp() < 128; }

private:
Register base_;
@@ -602,7 +602,7 @@ void Masm::Call(Register addr) {


void Masm::Call(Operand& addr) {
while ((offset() & 0x1) != 0x0) {
while ((offset() & 0x1) != 0x1) {
nop();
}
call(addr);
@@ -67,8 +67,13 @@ inline void Assembler::emit_modrm(Register dst) {

inline void Assembler::emit_modrm(Operand &dst) {
if (dst.scale() == Operand::one) {
emitb(0x80 | dst.base().low());
emitl(dst.disp());
if (dst.byte_disp()) {
emitb(0x40 | dst.base().low());
emitb(dst.disp());
} else {
emitb(0x80 | dst.base().low());
emitl(dst.disp());
}
} else {
// TODO: Support scales
}
@@ -82,8 +87,13 @@ inline void Assembler::emit_modrm(Register dst, Register src) {

inline void Assembler::emit_modrm(Register dst, Operand& src) {
if (src.scale() == Operand::one) {
emitb(0x80 | dst.low() << 3 | src.base().low());
emitl(src.disp());
if (src.byte_disp()) {
emitb(0x40 | dst.low() << 3 | src.base().low());
emitb(src.disp());
} else {
emitb(0x80 | dst.low() << 3 | src.base().low());
emitl(src.disp());
}
} else {
}
}
@@ -95,8 +105,13 @@ inline void Assembler::emit_modrm(Register dst, uint32_t op) {


inline void Assembler::emit_modrm(Operand& dst, uint32_t op) {
emitb(0x80 | op << 3 | dst.base().low());
emitl(dst.disp());
if (dst.byte_disp()) {
emitb(0x40 | op << 3 | dst.base().low());
emitb(dst.disp());
} else {
emitb(0x80 | op << 3 | dst.base().low());
emitl(dst.disp());
}
}


@@ -116,14 +131,24 @@ inline void Assembler::emit_modrm(DoubleRegister dst, DoubleRegister src) {


inline void Assembler::emit_modrm(DoubleRegister dst, Operand& src) {
emitb(0x80 | dst.low() << 3 | src.base().low());
emitl(src.disp());
if (src.byte_disp()) {
emitb(0x40 | dst.low() << 3 | src.base().low());
emitb(src.disp());
} else {
emitb(0x80 | dst.low() << 3 | src.base().low());
emitl(src.disp());
}
}


inline void Assembler::emit_modrm(Operand& dst, DoubleRegister src) {
emitb(0x80 | dst.base().low() | src.low() << 3);
emitl(dst.disp());
if (dst.byte_disp()) {
emitb(0x40 | dst.base().low() | src.low() << 3);
emitb(dst.disp());
} else {
emitb(0x80 | dst.base().low() | src.low() << 3);
emitl(dst.disp());
}
}


@@ -389,9 +389,9 @@ void Assembler::subq(Register dst, Immediate src) {

void Assembler::subqb(Register dst, Immediate src) {
emit_rexw(rax, dst);
emitb(0x83);
emitb(0x81);
emit_modrm(dst, 0x05);
emitb(src.value());
emitl(src.value());
}


@@ -208,6 +208,7 @@ class Operand : public ZoneObject {
inline Register base(Register base) { return base_ = base; }
inline Scale scale(Scale scale) { return scale_ = scale; }
inline int32_t disp(int32_t disp) { return disp_ = disp; }
inline bool byte_disp() { return disp() > -128 && disp() < 128; }

private:
Register base_;
@@ -587,7 +587,7 @@ void Masm::Call(Register addr) {


void Masm::Call(Operand& addr) {
while ((offset() & 0x1) != 0x1) {
while ((offset() & 0x1) != 0x0) {
nop();
}
callq(addr);