* powerpc64: removed references to global variables 'cg' (it is implicit 'self' in methods of tcg descendants) and 'current_asmdata.currasmlist' (the asmlist to use is passed as argument).

git-svn-id: trunk@27860 -
This commit is contained in:
sergei 2014-06-05 16:06:36 +00:00
parent 0fe656e82d
commit bcddc40150

View File

@ -414,7 +414,7 @@ begin
if (target_info.abi<>abi_powerpc_sysv) then
inherited a_call_reg(list,reg)
else if (not (cs_opt_size in current_settings.optimizerswitches)) then begin
tempreg := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
tempreg := getintregister(list, OS_INT);
{ load actual function entry (reg contains the reference to the function descriptor)
into tempreg }
reference_reset_base(tmpref, reg, 0, sizeof(pint));
@ -722,58 +722,58 @@ var
if (a = 0) then begin
internalerror(2005061701);
end else if (a = 1) then begin
cg.a_load_reg_reg(current_asmdata.CurrAsmList, OS_INT, OS_INT, src, dst);
a_load_reg_reg(list, OS_INT, OS_INT, src, dst);
end else if (a = -1) and (signed) then begin
{ note: only in the signed case possible..., may overflow }
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(negops[cs_check_overflow in current_settings.localswitches], dst, src));
list.concat(taicpu.op_reg_reg(negops[cs_check_overflow in current_settings.localswitches], dst, src));
end else if (ispowerof2(a, power, isNegPower)) then begin
if (signed) then begin
{ From "The PowerPC Compiler Writer's Guide", pg. 52ff }
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_SAR, OS_INT, power,
a_op_const_reg_reg(list, OP_SAR, OS_INT, power,
src, dst);
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_ADDZE, dst, dst));
list.concat(taicpu.op_reg_reg(A_ADDZE, dst, dst));
if (isNegPower) then
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_NEG, dst, dst));
list.concat(taicpu.op_reg_reg(A_NEG, dst, dst));
end else begin
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_SHR, OS_INT, power, src, dst)
a_op_const_reg_reg(list, OP_SHR, OS_INT, power, src, dst)
end;
end else begin
{ replace division by multiplication, both implementations }
{ from "The PowerPC Compiler Writer's Guide" pg. 53ff }
divreg := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
divreg := getintregister(list, OS_INT);
if (signed) then begin
getmagic_signedN(sizeof(aInt)*8, a, magic, shift);
{ load magic value }
cg.a_load_const_reg(current_asmdata.CurrAsmList, OS_INT, magic, divreg);
a_load_const_reg(list, OS_INT, magic, divreg);
{ multiply }
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_MULHD, dst, src, divreg));
list.concat(taicpu.op_reg_reg_reg(A_MULHD, dst, src, divreg));
{ add/subtract numerator }
if (a > 0) and (magic < 0) then begin
cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_ADD, OS_INT, src, dst, dst);
a_op_reg_reg_reg(list, OP_ADD, OS_INT, src, dst, dst);
end else if (a < 0) and (magic > 0) then begin
cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_SUB, OS_INT, src, dst, dst);
a_op_reg_reg_reg(list, OP_SUB, OS_INT, src, dst, dst);
end;
{ shift shift places to the right (arithmetic) }
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_SAR, OS_INT, shift, dst, dst);
a_op_const_reg_reg(list, OP_SAR, OS_INT, shift, dst, dst);
{ extract and add sign bit }
if (a >= 0) then begin
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_SHR, OS_INT, 63, src, divreg);
a_op_const_reg_reg(list, OP_SHR, OS_INT, 63, src, divreg);
end else begin
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_SHR, OS_INT, 63, dst, divreg);
a_op_const_reg_reg(list, OP_SHR, OS_INT, 63, dst, divreg);
end;
cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_ADD, OS_INT, dst, divreg, dst);
a_op_reg_reg_reg(list, OP_ADD, OS_INT, dst, divreg, dst);
end else begin
getmagic_unsignedN(sizeof(aWord)*8, a, u_magic, u_add, u_shift);
{ load magic in divreg }
cg.a_load_const_reg(current_asmdata.CurrAsmList, OS_INT, aint(u_magic), divreg);
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_MULHDU, dst, src, divreg));
a_load_const_reg(list, OS_INT, aint(u_magic), divreg);
list.concat(taicpu.op_reg_reg_reg(A_MULHDU, dst, src, divreg));
if (u_add) then begin
cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_SUB, OS_INT, dst, src, divreg);
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_SHR, OS_INT, 1, divreg, divreg);
cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_ADD, OS_INT, divreg, dst, divreg);
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_SHR, OS_INT, u_shift-1, divreg, dst);
a_op_reg_reg_reg(list, OP_SUB, OS_INT, dst, src, divreg);
a_op_const_reg_reg(list, OP_SHR, OS_INT, 1, divreg, divreg);
a_op_reg_reg_reg(list, OP_ADD, OS_INT, divreg, dst, divreg);
a_op_const_reg_reg(list, OP_SHR, OS_INT, u_shift-1, divreg, dst);
end else begin
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_SHR, OS_INT, u_shift, dst, dst);
a_op_const_reg_reg(list, OP_SHR, OS_INT, u_shift, dst, dst);
end;
end;
end;
@ -819,7 +819,7 @@ begin
else if ispowerof2(a, shift, isneg) then begin
list.concat(taicpu.op_reg_reg_const(A_SLDI, dst, src, shift));
if (isneg) then
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_NEG, dst, dst));
list.concat(taicpu.op_reg_reg(A_NEG, dst, dst));
end else if (a >= low(smallint)) and (a <= high(smallint)) then
list.concat(taicpu.op_reg_reg_const(A_MULLI, dst, src,
smallint(a)))
@ -934,7 +934,7 @@ begin
end;
OP_ROR:
begin
tmpreg := getintregister(current_asmdata.CurrAsmList, OS_INT);
tmpreg := getintregister(list, OS_INT);
list.concat(taicpu.op_reg_reg(A_NEG, tmpreg, src1));
if (size in [OS_64, OS_S64]) then begin
list.concat(taicpu.op_reg_reg_reg_const(A_RLDCL, dst, src2, tmpreg, 0));
@ -993,7 +993,7 @@ begin
opsize := OS_S32
else
opsize := OS_32;
a_load_reg_reg(current_asmdata.CurrAsmList, size, opsize, reg, reg);
a_load_reg_reg(list, size, opsize, reg, reg);
end;
{ can we use immediate compares? }
@ -1005,8 +1005,8 @@ begin
if (useconst) then begin
list.concat(taicpu.op_reg_reg_const(op, NR_CR0, reg, a));
end else begin
tmpreg := getintregister(current_asmdata.CurrAsmList, OS_INT);
a_load_const_reg(current_asmdata.CurrAsmList, opsize, a, tmpreg);
tmpreg := getintregister(list, OS_INT);
a_load_const_reg(list, opsize, a, tmpreg);
list.concat(taicpu.op_reg_reg_reg(op, NR_CR0, reg, tmpreg));
end;
@ -1929,7 +1929,7 @@ begin
{$IFDEF EXTDEBUG}
list.concat(tai_comment.create(strpnew('loading value from TOC reference for ' + symname)));
{$ENDIF EXTDEBUG}
cg.a_load_ref_reg(list, OS_INT, OS_INT, ref, reg);
a_load_ref_reg(list, OS_INT, OS_INT, ref, reg);
end;