|
@@ -346,9 +346,7 @@ implementation
|
|
|
|
|
|
procedure t68kaddnode.second_addordinal;
|
|
procedure t68kaddnode.second_addordinal;
|
|
var
|
|
var
|
|
- unsigned: boolean;
|
|
|
|
- cgop : topcg;
|
|
|
|
- tmpreg : tregister;
|
|
|
|
|
|
+ cgop : topcg;
|
|
begin
|
|
begin
|
|
{ if we need to handle overflow checking, fall back to the generic cg }
|
|
{ if we need to handle overflow checking, fall back to the generic cg }
|
|
if (nodetype in [addn,subn,muln]) and
|
|
if (nodetype in [addn,subn,muln]) and
|
|
@@ -360,10 +358,6 @@ implementation
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
|
|
- { determine if the comparison will be unsigned }
|
|
|
|
- unsigned:=not(is_signed(left.resultdef)) or
|
|
|
|
- not(is_signed(right.resultdef));
|
|
|
|
-
|
|
|
|
case nodetype of
|
|
case nodetype of
|
|
addn: cgop:=OP_ADD;
|
|
addn: cgop:=OP_ADD;
|
|
xorn: cgop:=OP_XOR;
|
|
xorn: cgop:=OP_XOR;
|
|
@@ -372,7 +366,8 @@ implementation
|
|
subn: cgop:=OP_SUB;
|
|
subn: cgop:=OP_SUB;
|
|
muln:
|
|
muln:
|
|
begin
|
|
begin
|
|
- if unsigned then
|
|
|
|
|
|
+ if not(is_signed(left.resultdef)) or
|
|
|
|
+ not(is_signed(right.resultdef)) then
|
|
cgop:=OP_MUL
|
|
cgop:=OP_MUL
|
|
else
|
|
else
|
|
cgop:=OP_IMUL;
|
|
cgop:=OP_IMUL;
|
|
@@ -382,6 +377,9 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
pass_left_right;
|
|
pass_left_right;
|
|
|
|
+ if (nodetype=subn) and (nf_swapped in flags) then
|
|
|
|
+ swapleftright;
|
|
|
|
+
|
|
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
|
|
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
|
|
|
|
|
|
{ initialize the result }
|
|
{ initialize the result }
|
|
@@ -389,52 +387,22 @@ implementation
|
|
location.register := cg.getintregister(current_asmdata.CurrAsmList,location.size);
|
|
location.register := cg.getintregister(current_asmdata.CurrAsmList,location.size);
|
|
cg.a_load_reg_reg(current_asmdata.CurrAsmlist,left.location.size,location.size,left.location.register,location.register);
|
|
cg.a_load_reg_reg(current_asmdata.CurrAsmlist,left.location.size,location.size,left.location.register,location.register);
|
|
|
|
|
|
- if nodetype<>subn then
|
|
|
|
- begin
|
|
|
|
- if location.size <> right.location.size then
|
|
|
|
- hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
|
|
|
|
-
|
|
|
|
- case right.location.loc of
|
|
|
|
- LOC_REGISTER,
|
|
|
|
- LOC_CREGISTER:
|
|
|
|
- cg.a_op_reg_reg(current_asmdata.CurrAsmList,cgop,def_cgsize(resultdef),right.location.register,location.register);
|
|
|
|
- LOC_CONSTANT:
|
|
|
|
- cg.a_op_const_reg(current_asmdata.CurrAsmList,cgop,def_cgsize(resultdef),right.location.value,location.register);
|
|
|
|
- LOC_REFERENCE,
|
|
|
|
- LOC_CREFERENCE:
|
|
|
|
- cg.a_op_ref_reg(current_asmdata.CurrAsmList,cgop,def_cgsize(resultdef),right.location.reference,location.register);
|
|
|
|
- else
|
|
|
|
- begin
|
|
|
|
- hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
|
|
|
|
- cg.a_op_reg_reg(current_asmdata.CurrAsmList,cgop,def_cgsize(resultdef),right.location.register,location.register);
|
|
|
|
- end;
|
|
|
|
- end
|
|
|
|
- end
|
|
|
|
- else { subtract is a special case since its not commutative }
|
|
|
|
- begin
|
|
|
|
- hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
|
|
|
|
- if (nf_swapped in flags) then
|
|
|
|
- swapleftright;
|
|
|
|
- if left.location.loc<>LOC_CONSTANT then
|
|
|
|
- begin
|
|
|
|
- if right.location.loc<>LOC_CONSTANT then
|
|
|
|
- hlcg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_SUB,resultdef,
|
|
|
|
- right.location.register,left.location.register,
|
|
|
|
- location.register)
|
|
|
|
- else
|
|
|
|
- hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SUB,resultdef,
|
|
|
|
- right.location.value,left.location.register,
|
|
|
|
- location.register);
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- begin
|
|
|
|
- tmpreg:=hlcg.getintregister(current_asmdata.CurrAsmList,resultdef);
|
|
|
|
- hlcg.a_load_const_reg(current_asmdata.CurrAsmList,resultdef,
|
|
|
|
- left.location.value,tmpreg);
|
|
|
|
- hlcg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_SUB,resultdef,
|
|
|
|
- right.location.register,tmpreg,location.register);
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
|
|
+ if (location.size <> right.location.size) or
|
|
|
|
+ not (right.location.loc in [LOC_REGISTER,LOC_CREGISTER,LOC_CONSTANT,LOC_REFERENCE,LOC_CREFERENCE]) then
|
|
|
|
+ hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
|
|
|
|
+
|
|
|
|
+ case right.location.loc of
|
|
|
|
+ LOC_REGISTER,
|
|
|
|
+ LOC_CREGISTER:
|
|
|
|
+ cg.a_op_reg_reg(current_asmdata.CurrAsmList,cgop,def_cgsize(resultdef),right.location.register,location.register);
|
|
|
|
+ LOC_CONSTANT:
|
|
|
|
+ cg.a_op_const_reg(current_asmdata.CurrAsmList,cgop,def_cgsize(resultdef),right.location.value,location.register);
|
|
|
|
+ LOC_REFERENCE,
|
|
|
|
+ LOC_CREFERENCE:
|
|
|
|
+ cg.a_op_ref_reg(current_asmdata.CurrAsmList,cgop,def_cgsize(resultdef),right.location.reference,location.register);
|
|
|
|
+ else
|
|
|
|
+ internalerror(2016052101);
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|