Index: src/compiler/ia32/code-generator-ia32.cc |
diff --git a/src/compiler/ia32/code-generator-ia32.cc b/src/compiler/ia32/code-generator-ia32.cc |
index 7243d621c3d210dff4dacc58f004e324fcc4e4b9..01a26c21ee9d6b55a56478172cc7e2105dd6c4a5 100644 |
--- a/src/compiler/ia32/code-generator-ia32.cc |
+++ b/src/compiler/ia32/code-generator-ia32.cc |
@@ -760,6 +760,21 @@ class OutOfLineRecordWrite final : public OutOfLineCode { |
__ add(esp, Immediate(kDoubleSize)); \ |
} while (false) |
+#define ASSEMBLE_BINOP(asm_instr) \ |
+ do { \ |
+ if (AddressingModeField::decode(instr->opcode()) != kMode_None) { \ |
+ size_t index = 1; \ |
+ Operand right = i.MemoryOperand(&index); \ |
+ __ asm_instr(i.InputRegister(0), right); \ |
+ } else { \ |
+ if (HasImmediateInput(instr, 1)) { \ |
+ __ asm_instr(i.InputOperand(0), i.InputImmediate(1)); \ |
+ } else { \ |
+ __ asm_instr(i.InputRegister(0), i.InputOperand(1)); \ |
+ } \ |
+ } \ |
+ } while (0) |
+ |
void CodeGenerator::AssembleDeconstructFrame() { |
__ mov(esp, ebp); |
__ pop(ebp); |
@@ -1130,18 +1145,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
ASSEMBLE_IEEE754_UNOP(tanh); |
break; |
case kIA32Add: |
- if (HasImmediateInput(instr, 1)) { |
- __ add(i.InputOperand(0), i.InputImmediate(1)); |
- } else { |
- __ add(i.InputRegister(0), i.InputOperand(1)); |
- } |
+ ASSEMBLE_BINOP(add); |
break; |
case kIA32And: |
- if (HasImmediateInput(instr, 1)) { |
- __ and_(i.InputOperand(0), i.InputImmediate(1)); |
- } else { |
- __ and_(i.InputRegister(0), i.InputOperand(1)); |
- } |
+ ASSEMBLE_BINOP(and_); |
break; |
case kIA32Cmp: |
ASSEMBLE_COMPARE(cmp); |
@@ -1189,25 +1196,13 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
__ neg(i.OutputOperand()); |
break; |
case kIA32Or: |
- if (HasImmediateInput(instr, 1)) { |
- __ or_(i.InputOperand(0), i.InputImmediate(1)); |
- } else { |
- __ or_(i.InputRegister(0), i.InputOperand(1)); |
- } |
+ ASSEMBLE_BINOP(or_); |
break; |
case kIA32Xor: |
- if (HasImmediateInput(instr, 1)) { |
- __ xor_(i.InputOperand(0), i.InputImmediate(1)); |
- } else { |
- __ xor_(i.InputRegister(0), i.InputOperand(1)); |
- } |
+ ASSEMBLE_BINOP(xor_); |
break; |
case kIA32Sub: |
- if (HasImmediateInput(instr, 1)) { |
- __ sub(i.InputOperand(0), i.InputImmediate(1)); |
- } else { |
- __ sub(i.InputRegister(0), i.InputOperand(1)); |
- } |
+ ASSEMBLE_BINOP(sub); |
break; |
case kIA32Shl: |
if (HasImmediateInput(instr, 1)) { |