|
|
|
|
@ -437,6 +437,25 @@ namespace mir
|
|
|
|
|
tmp >>= 1;
|
|
|
|
|
++shift;
|
|
|
|
|
}
|
|
|
|
|
if (val == 2)
|
|
|
|
|
{
|
|
|
|
|
int sign_bit = function.CreateVReg(VRegClass::Int);
|
|
|
|
|
block.Append(Opcode::ShrRR,
|
|
|
|
|
{Operand::VReg(sign_bit, VRegClass::Int),
|
|
|
|
|
Operand::VReg(lhs, VRegClass::Int),
|
|
|
|
|
Operand::Imm(31)});
|
|
|
|
|
int biased = function.CreateVReg(VRegClass::Int);
|
|
|
|
|
block.Append(Opcode::AddRR,
|
|
|
|
|
{Operand::VReg(biased, VRegClass::Int),
|
|
|
|
|
Operand::VReg(lhs, VRegClass::Int),
|
|
|
|
|
Operand::VReg(sign_bit, VRegClass::Int)});
|
|
|
|
|
block.Append(Opcode::AsrRR,
|
|
|
|
|
{Operand::VReg(dst, VRegClass::Int),
|
|
|
|
|
Operand::VReg(biased, VRegClass::Int),
|
|
|
|
|
Operand::Imm(shift)});
|
|
|
|
|
value_vregs[value] = dst;
|
|
|
|
|
return dst;
|
|
|
|
|
}
|
|
|
|
|
int bias = (1 << shift) - 1;
|
|
|
|
|
int biased = function.CreateVReg(VRegClass::Int);
|
|
|
|
|
if (bias <= 4095)
|
|
|
|
|
@ -483,6 +502,29 @@ namespace mir
|
|
|
|
|
tmp >>= 1;
|
|
|
|
|
++shift;
|
|
|
|
|
}
|
|
|
|
|
if (abs_val == 2)
|
|
|
|
|
{
|
|
|
|
|
int sign_bit = function.CreateVReg(VRegClass::Int);
|
|
|
|
|
block.Append(Opcode::ShrRR,
|
|
|
|
|
{Operand::VReg(sign_bit, VRegClass::Int),
|
|
|
|
|
Operand::VReg(lhs, VRegClass::Int),
|
|
|
|
|
Operand::Imm(31)});
|
|
|
|
|
int biased = function.CreateVReg(VRegClass::Int);
|
|
|
|
|
block.Append(Opcode::AddRR,
|
|
|
|
|
{Operand::VReg(biased, VRegClass::Int),
|
|
|
|
|
Operand::VReg(lhs, VRegClass::Int),
|
|
|
|
|
Operand::VReg(sign_bit, VRegClass::Int)});
|
|
|
|
|
int pos_q = function.CreateVReg(VRegClass::Int);
|
|
|
|
|
block.Append(Opcode::AsrRR,
|
|
|
|
|
{Operand::VReg(pos_q, VRegClass::Int),
|
|
|
|
|
Operand::VReg(biased, VRegClass::Int),
|
|
|
|
|
Operand::Imm(shift)});
|
|
|
|
|
block.Append(Opcode::NegRR,
|
|
|
|
|
{Operand::VReg(dst, VRegClass::Int),
|
|
|
|
|
Operand::VReg(pos_q, VRegClass::Int)});
|
|
|
|
|
value_vregs[value] = dst;
|
|
|
|
|
return dst;
|
|
|
|
|
}
|
|
|
|
|
int bias = (1 << shift) - 1;
|
|
|
|
|
int biased = function.CreateVReg(VRegClass::Int);
|
|
|
|
|
if (bias <= 4095)
|
|
|
|
|
@ -534,6 +576,24 @@ namespace mir
|
|
|
|
|
int val = rhs_const->GetValue();
|
|
|
|
|
if (val > 0 && (val & (val - 1)) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (val == 2)
|
|
|
|
|
{
|
|
|
|
|
int tmp = function.CreateVReg(VRegClass::Int);
|
|
|
|
|
block.Append(Opcode::AndRR,
|
|
|
|
|
{Operand::VReg(tmp, VRegClass::Int),
|
|
|
|
|
Operand::VReg(lhs, VRegClass::Int),
|
|
|
|
|
Operand::Imm(1)});
|
|
|
|
|
block.Append(Opcode::CmpImm,
|
|
|
|
|
{Operand::VReg(lhs, VRegClass::Int),
|
|
|
|
|
Operand::Imm(0)});
|
|
|
|
|
block.Append(Opcode::Csneg,
|
|
|
|
|
{Operand::VReg(dst, VRegClass::Int),
|
|
|
|
|
Operand::VReg(tmp, VRegClass::Int),
|
|
|
|
|
Operand::VReg(tmp, VRegClass::Int),
|
|
|
|
|
Operand::Imm(static_cast<int>(CondCode::GE))});
|
|
|
|
|
value_vregs[value] = dst;
|
|
|
|
|
return dst;
|
|
|
|
|
}
|
|
|
|
|
int bias = val - 1;
|
|
|
|
|
int biased = function.CreateVReg(VRegClass::Int);
|
|
|
|
|
if (bias <= 4095)
|
|
|
|
|
@ -590,6 +650,24 @@ namespace mir
|
|
|
|
|
if (val < 0 && (-val & (-val - 1)) == 0 && val != -1)
|
|
|
|
|
{
|
|
|
|
|
int abs_val = -val;
|
|
|
|
|
if (abs_val == 2)
|
|
|
|
|
{
|
|
|
|
|
int tmp = function.CreateVReg(VRegClass::Int);
|
|
|
|
|
block.Append(Opcode::AndRR,
|
|
|
|
|
{Operand::VReg(tmp, VRegClass::Int),
|
|
|
|
|
Operand::VReg(lhs, VRegClass::Int),
|
|
|
|
|
Operand::Imm(1)});
|
|
|
|
|
block.Append(Opcode::CmpImm,
|
|
|
|
|
{Operand::VReg(lhs, VRegClass::Int),
|
|
|
|
|
Operand::Imm(0)});
|
|
|
|
|
block.Append(Opcode::Csneg,
|
|
|
|
|
{Operand::VReg(dst, VRegClass::Int),
|
|
|
|
|
Operand::VReg(tmp, VRegClass::Int),
|
|
|
|
|
Operand::VReg(tmp, VRegClass::Int),
|
|
|
|
|
Operand::Imm(static_cast<int>(CondCode::GE))});
|
|
|
|
|
value_vregs[value] = dst;
|
|
|
|
|
return dst;
|
|
|
|
|
}
|
|
|
|
|
int bias = abs_val - 1;
|
|
|
|
|
int biased = function.CreateVReg(VRegClass::Int);
|
|
|
|
|
if (bias <= 4095)
|
|
|
|
|
|