|
@@ -82,11 +82,13 @@ implementation
|
|
var
|
|
var
|
|
helper1, helper2: TRegister;
|
|
helper1, helper2: TRegister;
|
|
so: tshifterop;
|
|
so: tshifterop;
|
|
|
|
+ opsize: TCgSize;
|
|
begin
|
|
begin
|
|
|
|
+ opsize:=def_cgsize(resultdef);
|
|
if tordconstnode(right).value=0 then
|
|
if tordconstnode(right).value=0 then
|
|
internalerror(2020021601)
|
|
internalerror(2020021601)
|
|
else if tordconstnode(right).value=1 then
|
|
else if tordconstnode(right).value=1 then
|
|
- cg.a_load_reg_reg(current_asmdata.CurrAsmList, OS_INT, OS_INT, numerator, resultreg)
|
|
|
|
|
|
+ cg.a_load_reg_reg(current_asmdata.CurrAsmList, opsize, opsize, numerator, resultreg)
|
|
else if (tordconstnode(right).value = int64(-1)) then
|
|
else if (tordconstnode(right).value = int64(-1)) then
|
|
begin
|
|
begin
|
|
// note: only in the signed case possible..., may overflow
|
|
// note: only in the signed case possible..., may overflow
|
|
@@ -100,26 +102,26 @@ implementation
|
|
begin
|
|
begin
|
|
if (is_signed(right.resultdef)) then
|
|
if (is_signed(right.resultdef)) then
|
|
begin
|
|
begin
|
|
- helper2:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
|
|
|
|
|
|
+ helper2:=cg.getintregister(current_asmdata.CurrAsmList,opsize);
|
|
if power = 1 then
|
|
if power = 1 then
|
|
helper1:=numerator
|
|
helper1:=numerator
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
- helper1:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
|
|
|
|
- cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SAR,OS_INT,63,numerator,helper1);
|
|
|
|
|
|
+ helper1:=cg.getintregister(current_asmdata.CurrAsmList,opsize);
|
|
|
|
+ cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SAR,opsize,resultdef.size*8-1,numerator,helper1);
|
|
end;
|
|
end;
|
|
shifterop_reset(so);
|
|
shifterop_reset(so);
|
|
so.shiftmode:=SM_LSR;
|
|
so.shiftmode:=SM_LSR;
|
|
- so.shiftimm:=64-power;
|
|
|
|
|
|
+ so.shiftimm:=resultdef.size*8-power;
|
|
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg_shifterop(A_ADD,helper2,numerator,helper1,so));
|
|
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg_shifterop(A_ADD,helper2,numerator,helper1,so));
|
|
- cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SAR,OS_INT,power,helper2,resultreg);
|
|
|
|
|
|
+ cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SAR,def_cgsize(resultdef),power,helper2,resultreg);
|
|
end
|
|
end
|
|
else
|
|
else
|
|
- cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SHR,OS_INT,power,numerator,resultreg)
|
|
|
|
|
|
+ cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SHR,opsize,power,numerator,resultreg)
|
|
end
|
|
end
|
|
else
|
|
else
|
|
{ Everything else is handled in the generic code }
|
|
{ Everything else is handled in the generic code }
|
|
- cg.g_div_const_reg_reg(current_asmdata.CurrAsmList,def_cgsize(resultdef),
|
|
|
|
|
|
+ cg.g_div_const_reg_reg(current_asmdata.CurrAsmList,opsize,
|
|
tordconstnode(right).value.svalue,numerator,resultreg);
|
|
tordconstnode(right).value.svalue,numerator,resultreg);
|
|
end;
|
|
end;
|
|
|
|
|