From 968fc9c6c9f3532e9456b3bf9049e6aa2282de7a Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 29 Nov 2012 14:36:16 +0100 Subject: Fix missing code generation for inplace operations on locals. Change-Id: I8fe7d87eabf2566f251319e8dae005aacc27eb0d Reviewed-by: Lars Knoll --- moth/qv4isel_moth.cpp | 83 +++++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 35 deletions(-) (limited to 'moth') diff --git a/moth/qv4isel_moth.cpp b/moth/qv4isel_moth.cpp index d16678936e..94a06d393b 100644 --- a/moth/qv4isel_moth.cpp +++ b/moth/qv4isel_moth.cpp @@ -578,44 +578,57 @@ void InstructionSelection::visitMove(IR::Move *s) load.targetTempIndex = targetTempIndex; addInstruction(load); } - } else if (IR::Const *c = s->source->asConst()) { - switch (c->type) { - case IR::UndefinedType: { - Instruction::LoadUndefined load; - load.targetTempIndex = targetTempIndex; - addInstruction(load); - } break; - case IR::NullType: { - Instruction::LoadNull load; - load.targetTempIndex = targetTempIndex; - addInstruction(load); - } break; - case IR::BoolType: - if (c->value) { - Instruction::LoadTrue load; - load.targetTempIndex = targetTempIndex; - addInstruction(load); + } else if (s->source->asTemp() || s->source->asConst()) { + if (s->op == IR::OpInvalid) { + if (IR::Temp *t2 = s->source->asTemp()) { + Instruction::MoveTemp move; + move.fromTempIndex = t2->index; + move.toTempIndex = targetTempIndex; + addInstruction(move); } else { - Instruction::LoadFalse load; - load.targetTempIndex = targetTempIndex; - addInstruction(load); + IR::Const *c = s->source->asConst(); + assert(c); + switch (c->type) { + case IR::UndefinedType: { + Instruction::LoadUndefined load; + load.targetTempIndex = targetTempIndex; + addInstruction(load); + } break; + case IR::NullType: { + Instruction::LoadNull load; + load.targetTempIndex = targetTempIndex; + addInstruction(load); + } break; + case IR::BoolType: + if (c->value) { + Instruction::LoadTrue load; + load.targetTempIndex = targetTempIndex; + addInstruction(load); + } else { + Instruction::LoadFalse load; + load.targetTempIndex = targetTempIndex; + addInstruction(load); + } + break; + case IR::NumberType: { + Instruction::LoadNumber load; + load.value = c->value; + load.targetTempIndex = targetTempIndex; + addInstruction(load); + } break; + default: + Q_UNREACHABLE(); + break; + } } - break; - case IR::NumberType: { - Instruction::LoadNumber load; - load.value = c->value; - load.targetTempIndex = targetTempIndex; - addInstruction(load); - } break; - default: - Q_UNREACHABLE(); - break; + } else { + Instruction::Binop binop; + binop.alu = aluOpFunction(s->op); + binop.lhsIsTemp = toValueOrTemp(t, binop.lhs); + binop.rhsIsTemp = toValueOrTemp(s->source, binop.rhs); + binop.targetTempIndex = targetTempIndex; + addInstruction(binop); } - } else if (IR::Temp *t2 = s->source->asTemp()) { - Instruction::MoveTemp move; - move.fromTempIndex = t2->index; - move.toTempIndex = targetTempIndex; - addInstruction(move); } else if (IR::String *str = s->source->asString()) { Instruction::LoadString load; load.value = _engine->newString(*str->value); -- cgit v1.2.3