Commit c2b1e635 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[ia32,root] Cleanup code generator

Change-Id: If4b0725000a7a6bb7da6399b107a965d8cb4c86f
Bug: v8:6666
Reviewed-on: https://chromium-review.googlesource.com/c/1271075
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56667}
parent 6aec5e7a
...@@ -27,7 +27,6 @@ namespace compiler { ...@@ -27,7 +27,6 @@ namespace compiler {
#define kScratchDoubleReg xmm0 #define kScratchDoubleReg xmm0
// Adds IA-32 specific methods for decoding operands. // Adds IA-32 specific methods for decoding operands.
class IA32OperandConverter : public InstructionOperandConverter { class IA32OperandConverter : public InstructionOperandConverter {
public: public:
...@@ -187,6 +186,17 @@ class IA32OperandConverter : public InstructionOperandConverter { ...@@ -187,6 +186,17 @@ class IA32OperandConverter : public InstructionOperandConverter {
UNREACHABLE(); UNREACHABLE();
} }
} }
void MoveInstructionOperandToRegister(Register destination,
InstructionOperand* op) {
if (op->IsImmediate() || op->IsConstant()) {
gen_->tasm()->mov(destination, ToImmediate(op));
} else if (op->IsRegister()) {
gen_->tasm()->Move(destination, ToRegister(op));
} else {
gen_->tasm()->mov(destination, ToOperand(op));
}
}
}; };
...@@ -326,12 +336,8 @@ void MoveOperandIfAliasedWithPoisonRegister(Instruction* call_instruction, ...@@ -326,12 +336,8 @@ void MoveOperandIfAliasedWithPoisonRegister(Instruction* call_instruction,
return; return;
} }
InstructionOperand* op = call_instruction->InputAt(poison_index); i.MoveInstructionOperandToRegister(kSpeculationPoisonRegister,
if (op->IsImmediate() || op->IsConstant()) { call_instruction->InputAt(poison_index));
gen->tasm()->mov(kSpeculationPoisonRegister, i.ToImmediate(op));
} else {
gen->tasm()->mov(kSpeculationPoisonRegister, i.InputOperand(poison_index));
}
} }
void EmitWordLoadPoisoningIfNeeded(CodeGenerator* codegen, void EmitWordLoadPoisoningIfNeeded(CodeGenerator* codegen,
...@@ -439,12 +445,7 @@ void EmitWordLoadPoisoningIfNeeded(CodeGenerator* codegen, ...@@ -439,12 +445,7 @@ void EmitWordLoadPoisoningIfNeeded(CodeGenerator* codegen,
__ mov(edx, i.NextMemoryOperand(2)); \ __ mov(edx, i.NextMemoryOperand(2)); \
__ push(ebx); \ __ push(ebx); \
frame_access_state()->IncreaseSPDelta(1); \ frame_access_state()->IncreaseSPDelta(1); \
InstructionOperand* op = instr->InputAt(0); \ i.MoveInstructionOperandToRegister(ebx, instr->InputAt(0)); \
if (op->IsImmediate() || op->IsConstant()) { \
__ mov(ebx, i.ToImmediate(op)); \
} else { \
__ mov(ebx, i.ToOperand(op)); \
} \
__ push(i.InputRegister(1)); \ __ push(i.InputRegister(1)); \
__ instr1(ebx, eax); \ __ instr1(ebx, eax); \
__ instr2(i.InputRegister(1), edx); \ __ instr2(i.InputRegister(1), edx); \
...@@ -1128,14 +1129,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1128,14 +1129,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
} else { } else {
__ add(i.OutputRegister(0), i.InputRegister(2)); __ add(i.OutputRegister(0), i.InputRegister(2));
} }
InstructionOperand* op = instr->InputAt(1); i.MoveInstructionOperandToRegister(i.OutputRegister(1),
if (op->IsImmediate() || op->IsConstant()) { instr->InputAt(1));
__ mov(i.OutputRegister(1), i.ToImmediate(op));
} else if (op->IsRegister()) {
__ Move(i.OutputRegister(1), i.ToRegister(op));
} else {
__ mov(i.OutputRegister(1), i.ToOperand(op));
}
__ adc(i.OutputRegister(1), Operand(i.InputRegister(3))); __ adc(i.OutputRegister(1), Operand(i.InputRegister(3)));
if (use_temp) { if (use_temp) {
__ Move(i.OutputRegister(0), i.TempRegister(0)); __ Move(i.OutputRegister(0), i.TempRegister(0));
...@@ -1159,14 +1154,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1159,14 +1154,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
} else { } else {
__ sub(i.OutputRegister(0), i.InputRegister(2)); __ sub(i.OutputRegister(0), i.InputRegister(2));
} }
InstructionOperand* op = instr->InputAt(1); i.MoveInstructionOperandToRegister(i.OutputRegister(1),
if (op->IsImmediate() || op->IsConstant()) { instr->InputAt(1));
__ mov(i.OutputRegister(1), i.ToImmediate(op));
} else if (op->IsRegister()) {
__ Move(i.OutputRegister(1), i.ToRegister(op));
} else {
__ mov(i.OutputRegister(1), i.ToOperand(op));
}
__ sbb(i.OutputRegister(1), Operand(i.InputRegister(3))); __ sbb(i.OutputRegister(1), Operand(i.InputRegister(3)));
if (use_temp) { if (use_temp) {
__ Move(i.OutputRegister(0), i.TempRegister(0)); __ Move(i.OutputRegister(0), i.TempRegister(0));
...@@ -1175,12 +1164,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1175,12 +1164,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
} }
case kIA32MulPair: { case kIA32MulPair: {
__ imul(i.OutputRegister(1), i.InputOperand(0)); __ imul(i.OutputRegister(1), i.InputOperand(0));
InstructionOperand* op = instr->InputAt(1); i.MoveInstructionOperandToRegister(i.TempRegister(0), instr->InputAt(1));
if (op->IsImmediate() || op->IsConstant()) {
__ mov(i.TempRegister(0), i.ToImmediate(op));
} else {
__ mov(i.TempRegister(0), i.ToOperand(op));
}
__ imul(i.TempRegister(0), i.InputOperand(2)); __ imul(i.TempRegister(0), i.InputOperand(2));
__ add(i.OutputRegister(1), i.TempRegister(0)); __ add(i.OutputRegister(1), i.TempRegister(0));
__ mov(i.OutputRegister(0), i.InputOperand(0)); __ mov(i.OutputRegister(0), i.InputOperand(0));
...@@ -3700,12 +3684,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -3700,12 +3684,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ mov(i.TempRegister(1), i.NextMemoryOperand(2)); __ mov(i.TempRegister(1), i.NextMemoryOperand(2));
__ push(ebx); __ push(ebx);
frame_access_state()->IncreaseSPDelta(1); frame_access_state()->IncreaseSPDelta(1);
InstructionOperand* op = instr->InputAt(0); i.MoveInstructionOperandToRegister(ebx, instr->InputAt(0));
if (op->IsImmediate() || op->IsConstant()) {
__ mov(ebx, i.ToImmediate(op));
} else {
__ mov(ebx, i.ToOperand(op));
}
__ lock(); __ lock();
__ cmpxchg8b(i.MemoryOperand(2)); __ cmpxchg8b(i.MemoryOperand(2));
__ pop(ebx); __ pop(ebx);
...@@ -3743,12 +3722,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -3743,12 +3722,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ mov(edx, i.NextMemoryOperand(2)); __ mov(edx, i.NextMemoryOperand(2));
__ push(ebx); __ push(ebx);
frame_access_state()->IncreaseSPDelta(1); frame_access_state()->IncreaseSPDelta(1);
InstructionOperand* op = instr->InputAt(0); i.MoveInstructionOperandToRegister(ebx, instr->InputAt(0));
if (op->IsImmediate() || op->IsConstant()) {
__ mov(ebx, i.ToImmediate(op));
} else {
__ mov(ebx, i.ToOperand(op));
}
__ lock(); __ lock();
__ cmpxchg8b(i.MemoryOperand(2)); __ cmpxchg8b(i.MemoryOperand(2));
__ pop(ebx); __ pop(ebx);
...@@ -3788,12 +3762,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -3788,12 +3762,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
TurboAssembler::AllowExplicitEbxAccessScope spill_ebx(tasm()); TurboAssembler::AllowExplicitEbxAccessScope spill_ebx(tasm());
__ push(ebx); __ push(ebx);
frame_access_state()->IncreaseSPDelta(1); frame_access_state()->IncreaseSPDelta(1);
InstructionOperand* op = instr->InputAt(2); i.MoveInstructionOperandToRegister(ebx, instr->InputAt(2));
if (op->IsImmediate() || op->IsConstant()) {
__ mov(ebx, i.ToImmediate(op));
} else {
__ mov(ebx, i.ToOperand(op));
}
__ lock(); __ lock();
__ cmpxchg8b(i.MemoryOperand(4)); __ cmpxchg8b(i.MemoryOperand(4));
__ pop(ebx); __ pop(ebx);
...@@ -3853,12 +3822,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -3853,12 +3822,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
// Save input registers temporarily on the stack. // Save input registers temporarily on the stack.
__ push(ebx); __ push(ebx);
frame_access_state()->IncreaseSPDelta(1); frame_access_state()->IncreaseSPDelta(1);
InstructionOperand* op = instr->InputAt(0); i.MoveInstructionOperandToRegister(ebx, instr->InputAt(0));
if (op->IsImmediate() || op->IsConstant()) {
__ mov(ebx, i.ToImmediate(op));
} else {
__ mov(ebx, i.ToOperand(op));
}
__ push(i.InputRegister(1)); __ push(i.InputRegister(1));
// Negate input in place // Negate input in place
__ neg(ebx); __ neg(ebx);
......
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