* fixed shlshr which would push ecx when not needed

This commit is contained in:
peter 1998-11-05 14:26:01 +00:00
parent 5d8f909e4e
commit 82aa9f9b00
2 changed files with 34 additions and 30 deletions

View File

@ -193,7 +193,8 @@ implementation
secondpass(p^.left); secondpass(p^.left);
pushed:=maybe_push(p^.right^.registers32,p); pushed:=maybe_push(p^.right^.registers32,p);
secondpass(p^.right); secondpass(p^.right);
if pushed then restore(p); if pushed then
restore(p);
{ load left operators in a register } { load left operators in a register }
if p^.left^.location.loc<>LOC_REGISTER then if p^.left^.location.loc<>LOC_REGISTER then
@ -212,7 +213,8 @@ implementation
hregister1))); hregister1)));
end; end;
end end
else hregister1:=p^.left^.location.register; else
hregister1:=p^.left^.location.register;
{ determine operator } { determine operator }
if p^.treetype=shln then if p^.treetype=shln then
@ -247,7 +249,8 @@ implementation
hregister2))); hregister2)));
end; end;
end end
else hregister2:=p^.right^.location.register; else
hregister2:=p^.right^.location.register;
{ left operator is already in a register } { left operator is already in a register }
{ hence are both in a register } { hence are both in a register }
@ -255,9 +258,7 @@ implementation
if (hregister1=R_ECX) then if (hregister1=R_ECX) then
begin begin
{ then only swap } { then only swap }
emit_reg_reg(A_XCHG,S_L,hregister1, emit_reg_reg(A_XCHG,S_L,hregister1,hregister2);
hregister2);
hregister3:=hregister1; hregister3:=hregister1;
hregister1:=hregister2; hregister1:=hregister2;
hregister2:=hregister3; hregister2:=hregister3;
@ -265,21 +266,15 @@ implementation
{ if second operator not in ECX ? } { if second operator not in ECX ? }
else if (hregister2<>R_ECX) then else if (hregister2<>R_ECX) then
begin begin
{ ECX not occupied then swap with right register } { ECX occupied then push it }
if R_ECX in unused then if not (R_ECX in unused) then
begin begin
emit_reg_reg(A_MOV,S_L,hregister2,R_ECX);
ungetregister32(hregister2);
end
else
begin
{ else save ECX and then copy it }
popecx:=true; popecx:=true;
exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,R_ECX))); exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,R_ECX)));
end;
emit_reg_reg(A_MOV,S_L,hregister2,R_ECX); emit_reg_reg(A_MOV,S_L,hregister2,R_ECX);
ungetregister32(hregister2); ungetregister32(hregister2);
end; end;
end;
{ right operand is in ECX } { right operand is in ECX }
emit_reg_reg(op,S_L,R_CL,hregister1); emit_reg_reg(op,S_L,R_CL,hregister1);
{ maybe ECX back } { maybe ECX back }
@ -287,8 +282,6 @@ implementation
exprasmlist^.concat(new(pai386,op_reg(A_POP,S_L,R_ECX))); exprasmlist^.concat(new(pai386,op_reg(A_POP,S_L,R_ECX)));
p^.location.register:=hregister1; p^.location.register:=hregister1;
end; end;
{ this register is always used when shl/shr are present }
usedinproc:=usedinproc or ($80 shr byte(R_ECX));
end; end;
@ -541,7 +534,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.10 1998-10-20 13:12:38 peter Revision 1.11 1998-11-05 14:26:02 peter
* fixed shlshr which would push ecx when not needed
Revision 1.10 1998/10/20 13:12:38 peter
* fixed 'not not boolean', the location was not set to register * fixed 'not not boolean', the location was not set to register
Revision 1.9 1998/10/20 08:06:42 pierre Revision 1.9 1998/10/20 08:06:42 pierre

View File

@ -113,6 +113,7 @@ implementation
procedure firstshlshr(var p : ptree); procedure firstshlshr(var p : ptree);
var var
t : ptree; t : ptree;
regs : longint;
begin begin
firstpass(p^.left); firstpass(p^.left);
firstpass(p^.right); firstpass(p^.right);
@ -138,7 +139,11 @@ implementation
if codegenerror then if codegenerror then
exit; exit;
calcregisters(p,2,0,0); regs:=1;
if (p^.right^.treetype<>ordconstn) then
inc(regs);
calcregisters(p,regs,0,0);
p^.resulttype:=s32bitdef; p^.resulttype:=s32bitdef;
p^.location.loc:=LOC_REGISTER; p^.location.loc:=LOC_REGISTER;
end; end;
@ -323,7 +328,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.5 1998-10-20 13:12:39 peter Revision 1.6 1998-11-05 14:26:01 peter
* fixed shlshr which would push ecx when not needed
Revision 1.5 1998/10/20 13:12:39 peter
* fixed 'not not boolean', the location was not set to register * fixed 'not not boolean', the location was not set to register
Revision 1.4 1998/10/13 16:50:25 pierre Revision 1.4 1998/10/13 16:50:25 pierre