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 b355d24941551e72a9035e8a8b9ef53343ed844f..ee05ad00b6ef4e25be89793b4fdd1b1d8dd5fb51 100644 |
--- a/src/compiler/ia32/code-generator-ia32.cc |
+++ b/src/compiler/ia32/code-generator-ia32.cc |
@@ -330,6 +330,33 @@ class OutOfLineRecordWrite final : public OutOfLineCode { |
__ bind(&done); \ |
} while (false) |
+#define ASSEMBLE_COMPARE(asm_instr) \ |
+ do { \ |
+ if (AddressingModeField::decode(instr->opcode()) != kMode_None) { \ |
+ size_t index = 0; \ |
+ Operand left = i.MemoryOperand(&index); \ |
+ if (HasImmediateInput(instr, index)) { \ |
+ __ asm_instr(left, i.InputImmediate(index)); \ |
+ } else { \ |
+ __ asm_instr(left, i.InputRegister(index)); \ |
+ } \ |
+ } else { \ |
+ if (HasImmediateInput(instr, 1)) { \ |
+ if (instr->InputAt(0)->IsRegister()) { \ |
+ __ asm_instr(i.InputRegister(0), i.InputImmediate(1)); \ |
+ } else { \ |
+ __ asm_instr(i.InputOperand(0), i.InputImmediate(1)); \ |
+ } \ |
+ } else { \ |
+ if (instr->InputAt(1)->IsRegister()) { \ |
+ __ asm_instr(i.InputRegister(0), i.InputRegister(1)); \ |
+ } else { \ |
+ __ asm_instr(i.InputRegister(0), i.InputOperand(1)); \ |
+ } \ |
+ } \ |
+ } \ |
+ } while (0) |
+ |
void CodeGenerator::AssembleDeconstructFrame() { |
__ mov(esp, ebp); |
__ pop(ebp); |
@@ -581,38 +608,22 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
} |
break; |
case kIA32Cmp: |
- if (AddressingModeField::decode(instr->opcode()) != kMode_None) { |
- size_t index = 0; |
- Operand operand = i.MemoryOperand(&index); |
- if (HasImmediateInput(instr, index)) { |
- __ cmp(operand, i.InputImmediate(index)); |
- } else { |
- __ cmp(operand, i.InputRegister(index)); |
- } |
- } else { |
- if (HasImmediateInput(instr, 1)) { |
- __ cmp(i.InputOperand(0), i.InputImmediate(1)); |
- } else { |
- __ cmp(i.InputRegister(0), i.InputOperand(1)); |
- } |
- } |
+ ASSEMBLE_COMPARE(cmp); |
+ break; |
+ case kIA32Cmp16: |
+ ASSEMBLE_COMPARE(cmpw); |
+ break; |
+ case kIA32Cmp8: |
+ ASSEMBLE_COMPARE(cmpb); |
break; |
case kIA32Test: |
- if (AddressingModeField::decode(instr->opcode()) != kMode_None) { |
- size_t index = 0; |
- Operand operand = i.MemoryOperand(&index); |
- if (HasImmediateInput(instr, index)) { |
- __ test(operand, i.InputImmediate(index)); |
- } else { |
- __ test(i.InputRegister(index), operand); |
- } |
- } else { |
- if (HasImmediateInput(instr, 1)) { |
- __ test(i.InputOperand(0), i.InputImmediate(1)); |
- } else { |
- __ test(i.InputRegister(0), i.InputOperand(1)); |
- } |
- } |
+ ASSEMBLE_COMPARE(test); |
+ break; |
+ case kIA32Test16: |
+ ASSEMBLE_COMPARE(test_w); |
+ break; |
+ case kIA32Test8: |
+ ASSEMBLE_COMPARE(test_b); |
break; |
case kIA32Imul: |
if (HasImmediateInput(instr, 1)) { |