+ target_os.stackalignment

+ stack can be aligned at 2 or 4 byte boundaries
This commit is contained in:
peter 1998-10-16 08:51:45 +00:00
parent 39dc89f39f
commit acf9818648
6 changed files with 214 additions and 134 deletions

View File

@ -139,10 +139,10 @@ implementation
{ temporary variables: }
tempdeftype : tdeftype;
tempreference : treference;
r : preference;
s : topsize;
op : tasmop;
r : preference;
opsize : topsize;
op : tasmop;
hreg : tregister;
begin
{ push from left to right if specified }
if push_from_left_to_right and assigned(p^.right) then
@ -238,7 +238,7 @@ implementation
case p^.left^.location.register of
R_EAX,R_EBX,R_ECX,R_EDX,R_ESI,
R_EDI,R_ESP,R_EBP :
begin
begin
inc(pushedparasize,4);
if inlined then
begin
@ -249,52 +249,71 @@ implementation
else
exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,p^.left^.location.register)));
ungetregister32(p^.left^.location.register);
end;
end;
R_AX,R_BX,R_CX,R_DX,R_SI,R_DI:
begin
inc(pushedparasize,2);
if inlined then
begin
r:=new_reference(procinfo.framepointer,para_offset-pushedparasize);
exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_W,
p^.left^.location.register,r)));
end
else
exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_W,p^.left^.location.register)));
ungetregister32(reg16toreg32(p^.left^.location.register));
begin
if target_os.stackalignment=4 then
begin
opsize:=S_L;
hreg:=reg16toreg32(p^.left^.location.register);
inc(pushedparasize,4);
end
else
begin
opsize:=S_W;
hreg:=p^.left^.location.register;
inc(pushedparasize,2);
end;
if inlined then
begin
r:=new_reference(procinfo.framepointer,para_offset-pushedparasize);
exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,opsize,hreg,r)));
end
else
exprasmlist^.concat(new(pai386,op_reg(A_PUSH,opsize,hreg)));
ungetregister32(reg16toreg32(p^.left^.location.register));
end;
R_AL,R_BL,R_CL,R_DL:
begin
inc(pushedparasize,2);
begin
if target_os.stackalignment=4 then
begin
opsize:=S_L;
hreg:=reg8toreg32(p^.left^.location.register);
inc(pushedparasize,4);
end
else
begin
opsize:=S_W;
hreg:=reg8toreg16(p^.left^.location.register);
inc(pushedparasize,2);
end;
{ we must push always 16 bit }
if inlined then
begin
r:=new_reference(procinfo.framepointer,para_offset-pushedparasize);
exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,
reg8toreg16(p^.left^.location.register),r)));
r:=new_reference(procinfo.framepointer,para_offset-pushedparasize);
exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,opsize,hreg,r)));
end
else
exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_W,
reg8toreg16(p^.left^.location.register))));
exprasmlist^.concat(new(pai386,op_reg(A_PUSH,opsize,hreg)));
ungetregister32(reg8toreg32(p^.left^.location.register));
end;
end;
end;
end;
LOC_FPU:
begin
size:=pfloatdef(p^.left^.resulttype)^.size;
inc(pushedparasize,size); { must be before for inlined }
size:=align(pfloatdef(p^.left^.resulttype)^.size,target_os.stackalignment);
inc(pushedparasize,size);
if not inlined then
exprasmlist^.concat(new(pai386,op_const_reg(A_SUB,S_L,size,R_ESP)));
exprasmlist^.concat(new(pai386,op_const_reg(A_SUB,S_L,size,R_ESP)));
r:=new_reference(R_ESP,0);
floatstoreops(pfloatdef(p^.left^.resulttype)^.typ,op,s);
floatstoreops(pfloatdef(p^.left^.resulttype)^.typ,op,opsize);
{ this is the easiest case for inlined !! }
if inlined then
begin
r^.base:=procinfo.framepointer;
r^.offset:=para_offset-pushedparasize;
end;
exprasmlist^.concat(new(pai386,op_ref(op,s,r)));
exprasmlist^.concat(new(pai386,op_ref(op,opsize,r)));
end;
LOC_REFERENCE,LOC_MEM:
begin
@ -318,16 +337,27 @@ implementation
emit_push_mem(tempreference);
end;
1,2 : begin
inc(pushedparasize,2);
if inlined then
if target_os.stackalignment=4 then
begin
exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_W,
newreference(tempreference),R_DI)));
r:=new_reference(procinfo.framepointer,para_offset-pushedparasize);
exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_W,R_DI,r)));
opsize:=S_L;
hreg:=R_EDI;
inc(pushedparasize,4);
end
else
exprasmlist^.concat(new(pai386,op_ref(A_PUSH,S_W,
begin
opsize:=S_W;
hreg:=R_DI;
inc(pushedparasize,2);
end;
if inlined then
begin
exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
newreference(tempreference),hreg)));
r:=new_reference(procinfo.framepointer,para_offset-pushedparasize);
exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,opsize,hreg,r)));
end
else
exprasmlist^.concat(new(pai386,op_ref(A_PUSH,opsize,
newreference(tempreference))));
end;
else
@ -380,7 +410,10 @@ implementation
s80real :
begin
inc(pushedparasize,4);
inc(tempreference.offset,6);
if target_os.stackalignment=4 then
inc(tempreference.offset,8)
else
inc(tempreference.offset,6);
if inlined then
begin
exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
@ -401,17 +434,29 @@ implementation
end
else
emit_push_mem(tempreference);
dec(tempreference.offset,2);
inc(pushedparasize,2);
if inlined then
if target_os.stackalignment=4 then
begin
exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_W,
newreference(tempreference),R_DI)));
r:=new_reference(procinfo.framepointer,para_offset-pushedparasize);
exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_W,R_DI,r)));
opsize:=S_L;
hreg:=R_EDI;
inc(pushedparasize,4);
dec(tempreference.offset,4);
end
else
exprasmlist^.concat(new(pai386,op_ref(A_PUSH,S_W,
begin
opsize:=S_W;
hreg:=R_DI;
inc(pushedparasize,2);
dec(tempreference.offset,2);
end;
if inlined then
begin
exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
newreference(tempreference),hreg)));
r:=new_reference(procinfo.framepointer,para_offset-pushedparasize);
exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,opsize,hreg,r)));
end
else
exprasmlist^.concat(new(pai386,op_ref(A_PUSH,opsize,
newreference(tempreference))));
end;
end;
@ -434,7 +479,7 @@ implementation
begin
{ 32 bit type set ? }
if is_widestring(p^.resulttype) or
is_ansistring(p^.resulttype) or
is_ansistring(p^.resulttype) or
((p^.resulttype^.deftype=setdef) and
(psetdef(p^.resulttype)^.settype=smallset)) then
begin
@ -469,10 +514,7 @@ implementation
end
else
begin
size:=p^.resulttype^.size;
{ Word Alignment }
if Odd(size) then
inc(size);
size:=align(p^.resulttype^.size,target_os.stackalignment);
{ create stack space }
if not inlined then
exprasmlist^.concat(new(pai386,op_const_reg(A_SUB,S_L,size,R_ESP)));
@ -499,7 +541,7 @@ implementation
else
begin
concatcopy(p^.left^.location.reference,
stackref,p^.resulttype^.size,true);
stackref,p^.resulttype^.size,true);
end;
end;
end;
@ -510,50 +552,61 @@ implementation
LOC_JUMP:
begin
getlabel(hlabel);
inc(pushedparasize,2);
if target_os.stackalignment=4 then
begin
opsize:=S_L;
inc(pushedparasize,4);
end
else
begin
opsize:=S_W;
inc(pushedparasize,2);
end;
emitl(A_LABEL,truelabel);
if inlined then
begin
r:=new_reference(procinfo.framepointer,para_offset-pushedparasize);
exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_W,1,r)));
exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,opsize,1,r)));
end
else
exprasmlist^.concat(new(pai386,op_const(A_PUSH,S_W,1)));
exprasmlist^.concat(new(pai386,op_const(A_PUSH,opsize,1)));
emitl(A_JMP,hlabel);
emitl(A_LABEL,falselabel);
if inlined then
begin
r:=new_reference(procinfo.framepointer,para_offset-pushedparasize);
exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_W,0,r)));
exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,opsize,0,r)));
end
else
exprasmlist^.concat(new(pai386,op_const(A_PUSH,S_W,0)));
exprasmlist^.concat(new(pai386,op_const(A_PUSH,opsize,0)));
emitl(A_LABEL,hlabel);
end;
LOC_FLAGS:
begin
if not(R_EAX in unused) then
exprasmlist^.concat(new(pai386,op_reg_reg(A_MOV,S_L,R_EAX,R_EDI)));
{ clear full EAX is faster }
{ but dont you set the equal flag ? }
{exprasmlist^.concat(new(pai386,op_reg_reg(A_XOR,S_L,R_EAX,R_EAX)));}
exprasmlist^.concat(new(pai386,op_reg(flag_2_set[p^.left^.location.resflags],S_B,
R_AL)));
exprasmlist^.concat(new(pai386,op_reg_reg(A_MOVZX,S_BW,R_AL,R_AX)));
{exprasmlist^.concat(new(pai386,op_reg_reg(A_XOR,S_L,R_EAX,R_EAX)));}
inc(pushedparasize,2);
if target_os.stackalignment=4 then
begin
opsize:=S_L;
hreg:=R_EAX;
inc(pushedparasize,4);
end
else
begin
opsize:=S_W;
hreg:=R_AX;
inc(pushedparasize,2);
end;
if inlined then
begin
r:=new_reference(procinfo.framepointer,para_offset-pushedparasize);
exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_W,
R_AX,r)));
exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,opsize,hreg,r)));
end
else
exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_W,R_AX)));
{ this is also false !!!
if not(R_EAX in unused) then
exprasmlist^.concat(new(pai386,op_reg_reg(A_MOV,S_L,R_EAX,R_EDI)));}
exprasmlist^.concat(new(pai386,op_reg(A_PUSH,opsize,hreg)));
if not(R_EAX in unused) then
exprasmlist^.concat(new(pai386,op_reg_reg(A_MOV,S_L,R_EDI,R_EAX)));
end;
@ -1459,7 +1512,11 @@ implementation
end.
{
$Log$
Revision 1.34 1998-10-09 08:56:22 pierre
Revision 1.35 1998-10-16 08:51:45 peter
+ target_os.stackalignment
+ stack can be aligned at 2 or 4 byte boundaries
Revision 1.34 1998/10/09 08:56:22 pierre
* several memory leaks fixed
Revision 1.33 1998/10/06 17:16:39 pierre

View File

@ -78,6 +78,13 @@ unit ptconst;
end;
end;
function is_po_equal(o1,o2:longint):boolean;
begin
{ assembler does not affect }
is_po_equal:=(o1 and not(poassembler))=
(o2 and not(poassembler));
end;
{$R-} {Range check creates problem with init_8bit(-1) !!}
begin
case def^.deftype of
@ -447,9 +454,9 @@ unit ptconst;
exit;
end
else
if not(m_tp_procvar in aktmodeswitches) then
if token=KLAMMERAFFE then
consume(KLAMMERAFFE);
if not(m_tp_procvar in aktmodeswitches) then
if token=KLAMMERAFFE then
consume(KLAMMERAFFE);
getsym(pattern,true);
consume(ID);
if srsym^.typ=unitsym then
@ -465,27 +472,27 @@ unit ptconst;
pd:=pprocsym(srsym)^.definition;
if assigned(pd^.nextoverloaded) then
Message(parser_e_no_overloaded_procvars);
if not((pprocvardef(def)^.options=pd^.options)) or
not(is_equal(pprocvardef(def)^.retdef,pd^.retdef)) then
Message(type_e_mismatch)
else
if is_po_equal(pprocvardef(def)^.options,pd^.options) and
is_equal(pprocvardef(def)^.retdef,pd^.retdef) then
begin
hp1:=pprocvardef(def)^.para1;
hp2:=pd^.para1;
while assigned(hp1) and assigned(hp2) do
begin
hp1:=pprocvardef(def)^.para1;
hp2:=pd^.para1;
while assigned(hp1) and assigned(hp2) do
begin
if not(is_equal(hp1^.data,hp2^.data)) or
not(hp1^.paratyp=hp2^.paratyp) then
begin
Message(type_e_mismatch);
break;
end;
hp1:=hp1^.next;
hp2:=hp2^.next;
end;
if not((hp1=nil) and (hp2=nil)) then
Message(type_e_mismatch);
end;
if not(is_equal(hp1^.data,hp2^.data)) or
not(hp1^.paratyp=hp2^.paratyp) then
begin
Message(type_e_mismatch);
break;
end;
hp1:=hp1^.next;
hp2:=hp2^.next;
end;
if not((hp1=nil) and (hp2=nil)) then
Message(type_e_mismatch);
end
else
Message(type_e_mismatch);
datasegment^.concat(new(pai_const,init_symbol(strpnew(pd^.mangledname))));
if pd^.owner^.symtabletype=unitsymtable then
concat_external(pd^.mangledname,EXT_NEAR);
@ -540,7 +547,11 @@ unit ptconst;
end.
{
$Log$
Revision 1.19 1998-10-12 12:20:58 pierre
Revision 1.20 1998-10-16 08:51:49 peter
+ target_os.stackalignment
+ stack can be aligned at 2 or 4 byte boundaries
Revision 1.19 1998/10/12 12:20:58 pierre
+ added tai_const_symbol_offset
for r : pointer = @var.field;
* better message for different arg names on implementation

View File

@ -78,6 +78,7 @@
{$ifdef GDB}
is_def_stab_written := false;
globalnb := 0;
{$endif GDB}
if assigned(lastglobaldef) then
begin
lastglobaldef^.nextglobal := @self;
@ -90,7 +91,6 @@
end;
lastglobaldef := @self;
nextglobal := nil;
{$endif GDB}
end;
@ -106,6 +106,7 @@
{$ifdef GDB}
is_def_stab_written := false;
globalnb := 0;
{$endif GDB}
if assigned(lastglobaldef) then
begin
lastglobaldef^.nextglobal := @self;
@ -118,13 +119,11 @@
end;
lastglobaldef := @self;
nextglobal := nil;
{$endif GDB}
end;
destructor tdef.done;
begin
{$ifdef GDB}
{ first element ? }
if not(assigned(previousglobal)) then
begin
@ -148,7 +147,6 @@
nextglobal^.previousglobal:=previousglobal;
previousglobal:=nil;
nextglobal:=nil;
{$endif GDB}
end;
@ -1862,7 +1860,7 @@
hp:=para1;
end;
end;
destructor tabstractprocdef.done;
begin
disposepdefcoll(para1);
@ -1941,20 +1939,17 @@
l:=0;
pdc:=para1;
while assigned(pdc) do
begin
case pdc^.paratyp of
vs_value :
l:=l+pdc^.data^.size+(pdc^.data^.size mod 2);
vs_var :
l:=l+sizeof(pointer);
vs_const :
if dont_copy_const_param(pdc^.data) then
l:=l+sizeof(pointer)
else
l:=l+pdc^.data^.size+(pdc^.data^.size mod 2);
end;
pdc:=pdc^.next;
end;
begin
case pdc^.paratyp of
vs_value : inc(l,align(pdc^.data^.size,target_os.stackalignment));
vs_var : inc(l,sizeof(pointer));
vs_const : if dont_copy_const_param(pdc^.data) then
inc(l,sizeof(pointer))
else
inc(l,align(pdc^.data^.size,target_os.stackalignment));
end;
pdc:=pdc^.next;
end;
para_size:=l;
end;
@ -3093,7 +3088,11 @@
{
$Log$
Revision 1.58 1998-10-15 15:13:30 pierre
Revision 1.59 1998-10-16 08:51:51 peter
+ target_os.stackalignment
+ stack can be aligned at 2 or 4 byte boundaries
Revision 1.58 1998/10/15 15:13:30 pierre
+ added oo_hasconstructor and oo_hasdestructor
for objects options

View File

@ -47,10 +47,10 @@
{ address of rtti }
rtti_label : plabel;
{$ifdef GDB}
globalnb : word;
nextglobal,
previousglobal : pdef;
{$ifdef GDB}
globalnb : word;
is_def_stab_written : boolean;
{$endif GDB}
constructor init;
@ -317,11 +317,10 @@
pabstractprocdef = ^tabstractprocdef;
tabstractprocdef = object(tdef)
{ saves a definition to the return type }
retdef : pdef;
fpu_used : byte; { how many stack fpu must be empty }
{ save the procedure options }
options : longint;
para1 : pdefcoll;
retdef : pdef;
fpu_used : byte; { how many stack fpu must be empty }
options : longint; { save the procedure options }
para1 : pdefcoll;
constructor init;
constructor load;
destructor done;virtual;
@ -479,7 +478,11 @@
{
$Log$
Revision 1.3 1998-10-05 21:33:30 peter
Revision 1.4 1998-10-16 08:51:52 peter
+ target_os.stackalignment
+ stack can be aligned at 2 or 4 byte boundaries
Revision 1.3 1998/10/05 21:33:30 peter
* fixed 161,165,166,167,168
Revision 1.2 1998/10/02 07:20:40 florian

View File

@ -1105,11 +1105,7 @@
end;
parasymtable : begin
address:=owner^.datasize;
{ needs word alignment }
if odd(l) then
inc(owner^.datasize,l+1)
else
inc(owner^.datasize,l);
owner^.datasize:=align(owner^.datasize+l,target_os.stackalignment);
end
else
begin
@ -1118,11 +1114,6 @@
inc(owner^.datasize,4-modulo)
else
if (l>=2) and ((modulo and 1)<>0) then
{ nice piece of code !!
inc(owner^.datasize,2-(datasize and 1));
2 - (datasize and 1) is allways 1 in this case
Florian when will your global stream analyser
find this out ?? }
inc(owner^.datasize);
address:=owner^.datasize;
inc(owner^.datasize,l);
@ -1721,7 +1712,11 @@
{
$Log$
Revision 1.52 1998-10-08 17:17:32 pierre
Revision 1.53 1998-10-16 08:51:53 peter
+ target_os.stackalignment
+ stack can be aligned at 2 or 4 byte boundaries
Revision 1.52 1998/10/08 17:17:32 pierre
* current_module old scanner tagged as invalid if unit is recompiled
+ added ppheap for better info on tracegetmem of heaptrc
(adds line column and file index)

View File

@ -120,6 +120,7 @@ unit systems;
Cprefix : string[2];
newline : string[2];
endian : tendian;
stackalignment : longint;
use_function_relative_addresses : boolean;
end;
@ -220,6 +221,7 @@ implementation
Cprefix : '_';
newline : #13#10;
endian : endian_little;
stackalignment : 2;
use_function_relative_addresses : true
),
(
@ -235,6 +237,7 @@ implementation
Cprefix : '_';
newline : #13#10;
endian : endian_little;
stackalignment : 2;
use_function_relative_addresses : true
),
(
@ -250,6 +253,7 @@ implementation
Cprefix : '';
newline : #10;
endian : endian_little;
stackalignment : 4;
use_function_relative_addresses : true
),
(
@ -265,6 +269,7 @@ implementation
Cprefix : '_';
newline : #13#10;
endian : endian_little;
stackalignment : 2;
use_function_relative_addresses : false
),
(
@ -280,6 +285,7 @@ implementation
Cprefix : '_';
newline : #13#10;
endian : endian_little;
stackalignment : 4;
use_function_relative_addresses : true
),
(
@ -295,6 +301,7 @@ implementation
Cprefix : '_';
newline : #10;
endian : endian_big;
stackalignment : 2;
use_function_relative_addresses : false
),
(
@ -310,6 +317,7 @@ implementation
Cprefix : '_';
newline : #10;
endian : endian_big;
stackalignment : 2;
use_function_relative_addresses : false
),
(
@ -325,6 +333,7 @@ implementation
Cprefix : '_';
newline : #13;
endian : endian_big;
stackalignment : 2;
use_function_relative_addresses : false
),
(
@ -340,6 +349,7 @@ implementation
Cprefix : '';
newline : #10;
endian : endian_big;
stackalignment : 2;
use_function_relative_addresses : true
),
(
@ -355,6 +365,7 @@ implementation
Cprefix : '_';
newline : #10;
endian : endian_big;
stackalignment : 2;
use_function_relative_addresses : false
)
);
@ -1141,7 +1152,11 @@ begin
end.
{
$Log$
Revision 1.45 1998-10-15 16:20:41 peter
Revision 1.46 1998-10-16 08:51:54 peter
+ target_os.stackalignment
+ stack can be aligned at 2 or 4 byte boundaries
Revision 1.45 1998/10/15 16:20:41 peter
* removed uses verbose which is not possible! this unit may not use
any other unit !