void set_result(Value x, LIR_Opr opr) { assert(opr->is_valid(), "must set to valid value"); assert(x->operand()->is_illegal(), "operand should never change"); assert(!opr->is_register() || opr->is_virtual(), "should never set result to a physical register"); x->set_operand(opr); assert(opr == x->operand(), "must be"); if (opr->is_virtual()) { _instruction_for_operand.at_put_grow(opr->vreg_number(), x, NULL); } }
void LIRGenerator::do_Convert(Convert* x) { // flags that vary for the different operations and different SSE-settings bool fixed_input, fixed_result, round_result, needs_stub; switch (x->op()) { case Bytecodes::_i2l: // fall through case Bytecodes::_l2i: // fall through case Bytecodes::_i2b: // fall through case Bytecodes::_i2c: // fall through case Bytecodes::_i2s: fixed_input = false; fixed_result = false; round_result = false; needs_stub = false; break; case Bytecodes::_f2d: fixed_input = UseSSE == 1; fixed_result = false; round_result = false; needs_stub = false; break; case Bytecodes::_d2f: fixed_input = false; fixed_result = UseSSE == 1; round_result = UseSSE < 1; needs_stub = false; break; case Bytecodes::_i2f: fixed_input = false; fixed_result = false; round_result = UseSSE < 1; needs_stub = false; break; case Bytecodes::_i2d: fixed_input = false; fixed_result = false; round_result = false; needs_stub = false; break; case Bytecodes::_f2i: fixed_input = false; fixed_result = false; round_result = false; needs_stub = true; break; case Bytecodes::_d2i: fixed_input = false; fixed_result = false; round_result = false; needs_stub = true; break; case Bytecodes::_l2f: fixed_input = false; fixed_result = UseSSE >= 1; round_result = UseSSE < 1; needs_stub = false; break; case Bytecodes::_l2d: fixed_input = false; fixed_result = UseSSE >= 2; round_result = UseSSE < 2; needs_stub = false; break; case Bytecodes::_f2l: fixed_input = true; fixed_result = true; round_result = false; needs_stub = false; break; case Bytecodes::_d2l: fixed_input = true; fixed_result = true; round_result = false; needs_stub = false; break; default: ShouldNotReachHere(); } LIRItem value(x->value(), this); value.load_item(); LIR_Opr input = value.result(); LIR_Opr result = rlock(x); // arguments of lir_convert LIR_Opr conv_input = input; LIR_Opr conv_result = result; ConversionStub* stub = NULL; if (fixed_input) { conv_input = fixed_register_for(input->type()); __ move(input, conv_input); } assert(fixed_result == false || round_result == false, "cannot set both"); if (fixed_result) { conv_result = fixed_register_for(result->type()); } else if (round_result) { result = new_register(result->type()); set_vreg_flag(result, must_start_in_memory); } if (needs_stub) { stub = new ConversionStub(x->op(), conv_input, conv_result); } __ convert(x->op(), conv_input, conv_result, stub); if (result != conv_result) { __ move(conv_result, result); } assert(result->is_virtual(), "result must be virtual register"); set_result(x, result); }
LIR_Opr result() { assert(_destroys_register==not_destroyed||(!_result->is_register()||_result->is_virtual()), "shouldn't use set_destroys_register with physical regsiters"); if(_destroys_register==awaiting_copy&&_result->is_register()){ LIR_Opr new_result=_gen->new_register(type())->set_destroyed(); gen()->lir()->move(_result, new_result); _destroys_register = destroyed; _result=new_result; } return _result; }
LIR_Opr result() { assert(!_destroys_register || (!_result->is_register() || _result->is_virtual()), "shouldn't use set_destroys_register with physical regsiters"); if (_destroys_register && _result->is_register()) { if (_new_result->is_illegal()) { _new_result = _gen->new_register(type()); gen()->lir()->move(_result, _new_result); } return _new_result; } else { return _result; } return _result; }
// Item will be loaded into a byte register; Intel only void LIRItem::load_byte_item() { load_item(); LIR_Opr res = result(); if (!res->is_virtual() || !_gen->is_vreg_flag_set(res, LIRGenerator::byte_reg)) { // make sure that it is a byte register assert(!value()->type()->is_float() && !value()->type()->is_double(), "can't load floats in byte register"); LIR_Opr reg = _gen->rlock_byte(T_BYTE); __ move(res, reg); _result = reg; } }
VMReg FrameMap::regname(LIR_Opr opr) const { if (opr->is_single_cpu()) { assert(!opr->is_virtual(), "should not see virtual registers here"); return opr->as_register()->as_VMReg(); } else if (opr->is_single_stack()) { return sp_offset2vmreg(sp_offset_for_slot(opr->single_stack_ix())); } else if (opr->is_address()) { LIR_Address* addr = opr->as_address_ptr(); assert(addr->base() == stack_pointer(), "sp based addressing only"); return sp_offset2vmreg(in_ByteSize(addr->index()->as_jint())); } ShouldNotReachHere(); return VMRegImpl::Bad(); }