diff options
author | Erik Verbruggen <erik.verbruggen@me.com> | 2013-09-10 10:18:48 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-20 12:42:48 +0200 |
commit | 09ccfa798a665063bd412d9487413d7352be82af (patch) | |
tree | 180f25548d608bb4881fb66986cb49610de38e54 /src/qml/compiler/qv4isel_moth.cpp | |
parent | 565c9b7661768eadf0ea205ed23557d7a31fc56d (diff) |
V4 interpreter: inline add/sub/mul on numbers.
Change-Id: I36d000acef9426b842847691372e9a786b9a45e8
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4isel_moth.cpp')
-rw-r--r-- | src/qml/compiler/qv4isel_moth.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp index a3f159fcf9..99ca3c5d4e 100644 --- a/src/qml/compiler/qv4isel_moth.cpp +++ b/src/qml/compiler/qv4isel_moth.cpp @@ -121,6 +121,19 @@ inline QV4::BinOp aluOpFunction(V4IR::AluOp op) return 0; } }; + +inline bool isNumberType(V4IR::Expr *e) +{ + switch (e->type) { + case V4IR::SInt32Type: + case V4IR::UInt32Type: + case V4IR::DoubleType: + return true; + default: + return false; + } +} + } // anonymous namespace // TODO: extend to optimize out temp-to-temp moves, where the lifetime of one temp ends at that statement. @@ -532,9 +545,7 @@ void InstructionSelection::binop(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR: Param InstructionSelection::binopHelper(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target) { -#ifdef USE_TYPE_INFO - if (leftSource->type & V4IR::NumberType && rightSource->type & V4IR::NumberType) { - // TODO: add Temp+Const variation on the topic. + if (isNumberType(leftSource) && isNumberType(rightSource)) { switch (oper) { case V4IR::OpAdd: { Instruction::AddNumberParams instr; @@ -542,28 +553,28 @@ Param InstructionSelection::binopHelper(V4IR::AluOp oper, V4IR::Expr *leftSource instr.rhs = getParam(rightSource); instr.result = getResultParam(target); addInstruction(instr); - } return instr.result; + return instr.result; + } case V4IR::OpMul: { Instruction::MulNumberParams instr; instr.lhs = getParam(leftSource); instr.rhs = getParam(rightSource); instr.result = getResultParam(target); addInstruction(instr); - } return instr.result; + return instr.result; + } case V4IR::OpSub: { Instruction::SubNumberParams instr; instr.lhs = getParam(leftSource); instr.rhs = getParam(rightSource); instr.result = getResultParam(target); addInstruction(instr); - } return instr.result; + return instr.result; + } default: break; } } -#else // !USE_TYPE_INFO - //Q_ASSERT(leftSource->asTemp() && rightSource->asTemp()); -#endif // USE_TYPE_INFO if (_stackSlotAllocator && target && leftSource->asTemp()) _stackSlotAllocator->addHint(*leftSource->asTemp(), *target); |