aboutsummaryrefslogtreecommitdiffstats
path: root/moth
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2012-11-29 14:36:16 +0100
committerLars Knoll <lars.knoll@digia.com>2012-11-29 16:17:12 +0100
commit968fc9c6c9f3532e9456b3bf9049e6aa2282de7a (patch)
treec81121ec714af2a57accc7a582115c339c86ca56 /moth
parent6d72378043ac836442dc4bd0f0e407062d161d9b (diff)
Fix missing code generation for inplace operations on locals.
Change-Id: I8fe7d87eabf2566f251319e8dae005aacc27eb0d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'moth')
-rw-r--r--moth/qv4isel_moth.cpp83
1 files changed, 48 insertions, 35 deletions
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);