add Compiler::truncateThenExtend

This commit is contained in:
Joshua Warner 2014-05-01 11:43:10 -06:00
parent 99fa560257
commit 26d8e8aa1f
3 changed files with 23 additions and 2 deletions

View File

@ -107,6 +107,11 @@ class Compiler {
virtual void checkBounds(Operand* object, unsigned lengthOffset, virtual void checkBounds(Operand* object, unsigned lengthOffset,
Operand* index, intptr_t handler) = 0; Operand* index, intptr_t handler) = 0;
virtual Operand* truncateThenExtend(ir::SignExtendMode signExtend,
ir::Type extendType,
ir::Type truncateType,
Operand* src) = 0;
virtual void store(ir::Type srcType, virtual void store(ir::Type srcType,
Operand* src, Operand* src,
Operand* dst) = 0; Operand* dst) = 0;

View File

@ -2609,6 +2609,22 @@ class MyCompiler: public Compiler {
static_cast<Value*>(index), handler); static_cast<Value*>(index), handler);
} }
virtual Operand* truncateThenExtend(ir::SignExtendMode signExtend,
ir::Type extendType,
ir::Type truncateType,
Operand* src)
{
Value* dst = value(&c, extendType);
appendMove(&c,
signExtend == ir::SignExtend ? lir::Move : lir::MoveZ,
TargetBytesPerWord,
truncateType.size(),
static_cast<Value*>(src),
extendType.size(),
dst);
return dst;
}
virtual void store(ir::Type srcType, virtual void store(ir::Type srcType,
Operand* src, Operand* src,
Operand* dst) Operand* dst)

View File

@ -4831,8 +4831,8 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
} break; } break;
case i2l: case i2l:
frame->pushLong(c->load( frame->pushLong(c->truncateThenExtend(
ir::SignExtend, types.address, types.i4, frame->popInt(), types.i8)); ir::SignExtend, types.i8, types.i4, frame->popInt()));
break; break;
case i2s: { case i2s: {