mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-31 21:30:51 +02:00
+ generic FPC_CHECKPOINTER
+ first parameter offset in stack now portable * rename some constants + move some cpu stuff to other units - remove unused constents * fix stacksize for some targets * fix generic size problems which depend now on EXTEND_SIZE constant * removing frame pointer in routines is only available for : i386,m68k and vis targets
This commit is contained in:
parent
87aa88e9b7
commit
b4f0af389d
@ -1501,7 +1501,7 @@ implementation
|
||||
|
||||
{ omit stack frame ? }
|
||||
if (not inlined) then
|
||||
if (procinfo^.framepointer=stack_pointer) then
|
||||
if (procinfo^.framepointer=STACK_POINTER_REG) then
|
||||
begin
|
||||
CGMessage(cg_d_stackframe_omited);
|
||||
nostackframe:=true;
|
||||
@ -1518,7 +1518,7 @@ implementation
|
||||
if (aktprocdef.proctypeoption in [potype_unitinit,potype_proginit,potype_unitfinalize]) then
|
||||
parasize:=0
|
||||
else
|
||||
parasize:=aktprocdef.parast.datasize+procinfo^.para_offset-8;
|
||||
parasize:=aktprocdef.parast.datasize+procinfo^.para_offset-target_info.first_parm_offset;
|
||||
nostackframe:=false;
|
||||
if stackframe<>0 then
|
||||
begin
|
||||
@ -2301,7 +2301,17 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.24 2002-04-19 15:39:34 peter
|
||||
Revision 1.25 2002-04-20 21:37:07 carl
|
||||
+ generic FPC_CHECKPOINTER
|
||||
+ first parameter offset in stack now portable
|
||||
* rename some constants
|
||||
+ move some cpu stuff to other units
|
||||
- remove unused constents
|
||||
* fix stacksize for some targets
|
||||
* fix generic size problems which depend now on EXTEND_SIZE constant
|
||||
* removing frame pointer in routines is only available for : i386,m68k and vis targets
|
||||
|
||||
Revision 1.24 2002/04/19 15:39:34 peter
|
||||
* removed some more routines from cga
|
||||
* moved location_force_reg/mem to ncgutil
|
||||
* moved arrayconstructnode secondpass to ncgld
|
||||
|
@ -423,7 +423,7 @@ type
|
||||
LOC_CONSTANT, { constant value }
|
||||
LOC_JUMP, { boolean results only, jump to false or true label }
|
||||
LOC_FLAGS, { boolean results only, flags are set }
|
||||
LOC_CREFERENCE, { in memory constant value }
|
||||
LOC_CREFERENCE, { in memory constant value reference (cannot change) }
|
||||
LOC_REFERENCE, { in memory value }
|
||||
LOC_REGISTER, { in a processor register }
|
||||
LOC_CREGISTER, { Constant register which shouldn't be modified }
|
||||
@ -465,7 +465,10 @@ type
|
||||
|
||||
const
|
||||
general_registers = [R_EAX,R_EBX,R_ECX,R_EDX];
|
||||
|
||||
|
||||
{# Table of registers which can be allocated by the code generator
|
||||
internally, when generating the code.
|
||||
}
|
||||
{ legend: }
|
||||
{ xxxregs = set of all possibly used registers of that type in the code }
|
||||
{ generator }
|
||||
@ -494,86 +497,66 @@ const
|
||||
firstsavemmreg = R_MM0;
|
||||
lastsavemmreg = R_MM7;
|
||||
|
||||
|
||||
{# Constant defining possibly all registers which might require saving }
|
||||
ALL_REGISTERS = [firstreg..lastreg];
|
||||
|
||||
lvaluelocations = [LOC_REFERENCE,LOC_CFPUREGISTER,
|
||||
LOC_CREGISTER,LOC_MMXREGISTER,LOC_CMMXREGISTER];
|
||||
|
||||
registers_saved_on_cdecl = [R_ESI,R_EDI,R_EBX];
|
||||
|
||||
{ generic register names }
|
||||
stack_pointer = R_ESP;
|
||||
frame_pointer = R_EBP;
|
||||
self_pointer = R_ESI;
|
||||
{*****************************************************************************
|
||||
Generic Register names
|
||||
*****************************************************************************}
|
||||
|
||||
{# Stack pointer register }
|
||||
stack_pointer_reg = R_ESP;
|
||||
{# Frame pointer register }
|
||||
frame_pointer_reg = R_EBP;
|
||||
{# Self pointer register : contains the instance address of an
|
||||
object or class. }
|
||||
self_pointer_reg = R_ESI;
|
||||
{# Register for addressing absolute data in a position independant way,
|
||||
such as in PIC code. The exact meaning is ABI specific }
|
||||
pic_offset_reg = R_EBX;
|
||||
{# Results are returned in this register (32-bit values) }
|
||||
accumulator = R_EAX;
|
||||
{# Hi-Results are returned in this register (64-bit value high register) }
|
||||
accumulatorhigh = R_EDX;
|
||||
{ WARNING: don't change to R_ST0!! See comments above implementation of }
|
||||
{ a_loadfpu* methods in rgcpu (JM) }
|
||||
fpuresultreg = R_ST;
|
||||
mmresultreg = R_MM0;
|
||||
{ the register where the vmt offset is passed to the destructor }
|
||||
{ helper routine }
|
||||
vmt_offset_reg = R_EDI;
|
||||
|
||||
{# Registers which are defined as scratch and no need to save across
|
||||
routine calls or in assembler blocks.
|
||||
}
|
||||
scratch_regs : array[1..1] of tregister = (R_EDI);
|
||||
|
||||
{ low and high of the available maximum width integer general purpose }
|
||||
{ registers }
|
||||
LoGPReg = R_EAX;
|
||||
HiGPReg = R_EDI;
|
||||
|
||||
{ low and high of every possible width general purpose register (same as }
|
||||
{ above on most architctures apart from the 80x86) }
|
||||
LoReg = R_EAX;
|
||||
HiReg = R_BL;
|
||||
|
||||
{ sizes }
|
||||
pointer_size = 4;
|
||||
extended_size = 10;
|
||||
mmreg_size = 8;
|
||||
|
||||
|
||||
|
||||
{*****************************************************************************
|
||||
Opcode propeties (needed for optimizer)
|
||||
GCC /ABI linking information
|
||||
*****************************************************************************}
|
||||
|
||||
{$ifndef NOOPT}
|
||||
Type
|
||||
{What an instruction can change}
|
||||
TInsChange = (Ch_None,
|
||||
{Read from a register}
|
||||
Ch_REAX, Ch_RECX, Ch_REDX, Ch_REBX, Ch_RESP, Ch_REBP, Ch_RESI, Ch_REDI,
|
||||
{write from a register}
|
||||
Ch_WEAX, Ch_WECX, Ch_WEDX, Ch_WEBX, Ch_WESP, Ch_WEBP, Ch_WESI, Ch_WEDI,
|
||||
{read and write from/to a register}
|
||||
Ch_RWEAX, Ch_RWECX, Ch_RWEDX, Ch_RWEBX, Ch_RWESP, Ch_RWEBP, Ch_RWESI, Ch_RWEDI,
|
||||
{modify the contents of a register with the purpose of using
|
||||
this changed content afterwards (add/sub/..., but e.g. not rep
|
||||
or movsd)}
|
||||
Ch_MEAX, Ch_MECX, Ch_MEDX, Ch_MEBX, Ch_MESP, Ch_MEBP, Ch_MESI, Ch_MEDI,
|
||||
Ch_CDirFlag {clear direction flag}, Ch_SDirFlag {set dir flag},
|
||||
Ch_RFlags, Ch_WFlags, Ch_RWFlags, Ch_FPU,
|
||||
Ch_Rop1, Ch_Wop1, Ch_RWop1,Ch_Mop1,
|
||||
Ch_Rop2, Ch_Wop2, Ch_RWop2,Ch_Mop2,
|
||||
Ch_Rop3, Ch_WOp3, Ch_RWOp3,Ch_Mop3,
|
||||
Ch_WMemEDI,
|
||||
Ch_All
|
||||
);
|
||||
{# Registers which must be saved when calling a routine declared as
|
||||
cppdecl, cdecl, stdcall, safecall, palmossyscall. The registers
|
||||
saved should be the ones as defined in the target ABI and / or GCC.
|
||||
|
||||
This value can be deduced from the CALLED_USED_REGISTERS array in the
|
||||
GCC source.
|
||||
}
|
||||
std_saved_registers = [R_ESI,R_EDI,R_EBX];
|
||||
{# Required parameter alignment when calling a routine declared as
|
||||
stdcall and cdecl. The alignment value should be the one defined
|
||||
by GCC or the target ABI.
|
||||
|
||||
The value of this constant is equal to the constant
|
||||
PARM_BOUNDARY / BITS_PER_UNIT in the GCC source.
|
||||
}
|
||||
std_param_align = 4;
|
||||
|
||||
|
||||
|
||||
const
|
||||
MaxCh = 3; { Max things a instruction can change }
|
||||
type
|
||||
TInsProp = packed record
|
||||
Ch : Array[1..MaxCh] of TInsChange;
|
||||
end;
|
||||
|
||||
const
|
||||
InsProp : array[tasmop] of TInsProp =
|
||||
{$i i386prop.inc}
|
||||
|
||||
{$endif NOOPT}
|
||||
|
||||
|
||||
{*****************************************************************************
|
||||
@ -712,7 +695,17 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.16 2002-04-15 19:53:54 peter
|
||||
Revision 1.17 2002-04-20 21:37:07 carl
|
||||
+ generic FPC_CHECKPOINTER
|
||||
+ first parameter offset in stack now portable
|
||||
* rename some constants
|
||||
+ move some cpu stuff to other units
|
||||
- remove unused constents
|
||||
* fix stacksize for some targets
|
||||
* fix generic size problems which depend now on EXTEND_SIZE constant
|
||||
* removing frame pointer in routines is only available for : i386,m68k and vis targets
|
||||
|
||||
Revision 1.16 2002/04/15 19:53:54 peter
|
||||
* fixed conflicts between the last 2 commits
|
||||
|
||||
Revision 1.15 2002/04/15 19:44:20 peter
|
||||
|
@ -27,6 +27,7 @@ Unit cpuinfo;
|
||||
Interface
|
||||
|
||||
Type
|
||||
{# Natural integer register type and size for the target machine }
|
||||
AWord = Cardinal;
|
||||
PAWord = ^AWord;
|
||||
|
||||
@ -38,15 +39,29 @@ Type
|
||||
TConstPtrUInt = cardinal;
|
||||
|
||||
Const
|
||||
{ Size of native extended type }
|
||||
{# Size of native extended floating point type }
|
||||
extended_size = 10;
|
||||
{# Size of a pointer }
|
||||
pointer_size = 4;
|
||||
{# Size of a multimedia register }
|
||||
mmreg_size = 8;
|
||||
|
||||
Implementation
|
||||
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.6 2002-04-07 13:41:50 carl
|
||||
Revision 1.7 2002-04-20 21:37:07 carl
|
||||
+ generic FPC_CHECKPOINTER
|
||||
+ first parameter offset in stack now portable
|
||||
* rename some constants
|
||||
+ move some cpu stuff to other units
|
||||
- remove unused constents
|
||||
* fix stacksize for some targets
|
||||
* fix generic size problems which depend now on EXTEND_SIZE constant
|
||||
* removing frame pointer in routines is only available for : i386,m68k and vis targets
|
||||
|
||||
Revision 1.6 2002/04/07 13:41:50 carl
|
||||
- moved type constant
|
||||
|
||||
Revision 1.5 2002/04/02 17:11:34 peter
|
||||
|
@ -27,7 +27,7 @@ Unit CSOpt386;
|
||||
|
||||
Interface
|
||||
|
||||
Uses aasm, cpuinfo, cpubase, cpuasm;
|
||||
Uses aasm, cpuinfo, cpubase, cpuasm, optbase;
|
||||
|
||||
function CSE(asmL: TAAsmoutput; first, last: Tai; pass: longint): boolean;
|
||||
|
||||
@ -352,9 +352,9 @@ Begin {CheckSequence}
|
||||
OrgRegResult := False;
|
||||
with startRegInfo do
|
||||
begin
|
||||
newRegsEncountered := [procinfo^.FramePointer, stack_pointer];
|
||||
newRegsEncountered := [procinfo^.FramePointer, STACK_POINTER_REG];
|
||||
new2OldReg[procinfo^.FramePointer] := procinfo^.FramePointer;
|
||||
new2OldReg[stack_pointer] := stack_pointer;
|
||||
new2OldReg[STACK_POINTER_REG] := STACK_POINTER_REG;
|
||||
oldRegsEncountered := newRegsEncountered;
|
||||
end;
|
||||
|
||||
@ -1323,7 +1323,7 @@ begin
|
||||
(Taicpu(startmod).opcode = A_MOVSX) or
|
||||
(Taicpu(startmod).opcode = A_LEA)) and
|
||||
(Taicpu(startmod).oper[0].typ = top_ref) and
|
||||
(Taicpu(startmod).oper[0].ref^.base = stack_pointer)) or
|
||||
(Taicpu(startmod).oper[0].ref^.base = STACK_POINTER_REG)) or
|
||||
not(reg in pTaiprop(hp1.optInfo)^.usedRegs) or
|
||||
findRegDealloc(reg,p))) then
|
||||
pTaiprop(startMod.optInfo)^.canBeRemoved := true;
|
||||
@ -1984,7 +1984,17 @@ End.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.30 2002-04-15 19:44:20 peter
|
||||
Revision 1.31 2002-04-20 21:37:07 carl
|
||||
+ generic FPC_CHECKPOINTER
|
||||
+ first parameter offset in stack now portable
|
||||
* rename some constants
|
||||
+ move some cpu stuff to other units
|
||||
- remove unused constents
|
||||
* fix stacksize for some targets
|
||||
* fix generic size problems which depend now on EXTEND_SIZE constant
|
||||
* removing frame pointer in routines is only available for : i386,m68k and vis targets
|
||||
|
||||
Revision 1.30 2002/04/15 19:44:20 peter
|
||||
* fixed stackcheck that would be called recursively when a stack
|
||||
error was found
|
||||
* generic changeregsize(reg,size) for i386 register resizing
|
||||
|
@ -31,7 +31,7 @@ Interface
|
||||
Uses
|
||||
GlobType,
|
||||
CClasses,Aasm,
|
||||
cpubase,cpuasm;
|
||||
cpubase,cpuasm,optbase;
|
||||
|
||||
{******************************* Constants *******************************}
|
||||
|
||||
@ -2586,7 +2586,17 @@ End.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.31 2002-04-15 19:44:20 peter
|
||||
Revision 1.32 2002-04-20 21:37:07 carl
|
||||
+ generic FPC_CHECKPOINTER
|
||||
+ first parameter offset in stack now portable
|
||||
* rename some constants
|
||||
+ move some cpu stuff to other units
|
||||
- remove unused constents
|
||||
* fix stacksize for some targets
|
||||
* fix generic size problems which depend now on EXTEND_SIZE constant
|
||||
* removing frame pointer in routines is only available for : i386,m68k and vis targets
|
||||
|
||||
Revision 1.31 2002/04/15 19:44:20 peter
|
||||
* fixed stackcheck that would be called recursively when a stack
|
||||
error was found
|
||||
* generic changeregsize(reg,size) for i386 register resizing
|
||||
|
@ -61,7 +61,7 @@ implementation
|
||||
symconst,symtype,symdef,symsym,symtable,aasm,types,
|
||||
cginfo,cgbase,pass_2,
|
||||
pass_1,nld,ncon,nadd,
|
||||
cpubase,
|
||||
cpuinfo,cpubase,
|
||||
cgobj,cga,tgobj,rgobj,ncgutil,n386util;
|
||||
|
||||
{*****************************************************************************
|
||||
@ -663,7 +663,17 @@ begin
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.26 2002-04-19 15:39:35 peter
|
||||
Revision 1.27 2002-04-20 21:37:07 carl
|
||||
+ generic FPC_CHECKPOINTER
|
||||
+ first parameter offset in stack now portable
|
||||
* rename some constants
|
||||
+ move some cpu stuff to other units
|
||||
- remove unused constents
|
||||
* fix stacksize for some targets
|
||||
* fix generic size problems which depend now on EXTEND_SIZE constant
|
||||
* removing frame pointer in routines is only available for : i386,m68k and vis targets
|
||||
|
||||
Revision 1.26 2002/04/19 15:39:35 peter
|
||||
* removed some more routines from cga
|
||||
* moved location_force_reg/mem to ncgutil
|
||||
* moved arrayconstructnode secondpass to ncgld
|
||||
|
@ -227,7 +227,7 @@ implementation
|
||||
hregister:=rg.getregisterint(exprasmlist);
|
||||
{$ifdef TEMPS_NOT_PUSH}
|
||||
reset_reference(href);
|
||||
href.base:=procinfo^.frame_pointer;
|
||||
href.base:=procinfo^.frame_pointer_reg;
|
||||
href.offset:=p.temp_offset;
|
||||
emit_ref_reg(A_MOV,S_L,href,hregister);
|
||||
{$else TEMPS_NOT_PUSH}
|
||||
@ -274,7 +274,7 @@ implementation
|
||||
begin
|
||||
hregister:=rg.getregisterint(exprasmlist);
|
||||
reset_reference(href);
|
||||
href.base:=procinfo^.frame_pointer;
|
||||
href.base:=procinfo^.frame_pointer_reg;
|
||||
href.offset:=p.temp_offset;
|
||||
emit_ref_reg(A_MOV,S_L,href,hregister);
|
||||
if (p.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
|
||||
@ -1112,7 +1112,17 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.32 2002-04-19 15:39:35 peter
|
||||
Revision 1.33 2002-04-20 21:37:07 carl
|
||||
+ generic FPC_CHECKPOINTER
|
||||
+ first parameter offset in stack now portable
|
||||
* rename some constants
|
||||
+ move some cpu stuff to other units
|
||||
- remove unused constents
|
||||
* fix stacksize for some targets
|
||||
* fix generic size problems which depend now on EXTEND_SIZE constant
|
||||
* removing frame pointer in routines is only available for : i386,m68k and vis targets
|
||||
|
||||
Revision 1.32 2002/04/19 15:39:35 peter
|
||||
* removed some more routines from cga
|
||||
* moved location_force_reg/mem to ncgutil
|
||||
* moved arrayconstructnode secondpass to ncgld
|
||||
|
@ -41,7 +41,7 @@ Uses
|
||||
{$ifdef finaldestdebug}
|
||||
cobjects,
|
||||
{$endif finaldestdebug}
|
||||
tainst,cpubase,cpuasm,DAOpt386,cginfo,rgobj;
|
||||
tainst,cpubase,optbase,cpuasm,DAOpt386,cginfo,rgobj;
|
||||
|
||||
Function RegUsedAfterInstruction(Reg: TRegister; p: Tai; Var UsedRegs: TRegSet): Boolean;
|
||||
Begin
|
||||
@ -1364,7 +1364,7 @@ Begin
|
||||
Taicpu(hp2).opcode := A_MOV;
|
||||
Taicpu(hp2).Loadoper(1,Taicpu(hp1).oper[0]);
|
||||
reference_reset(tmpref);
|
||||
tmpRef.base := stack_pointer;
|
||||
tmpRef.base := STACK_POINTER_REG;
|
||||
tmpRef.offset := l;
|
||||
Taicpu(hp2).loadRef(0,tmpRef);
|
||||
hp4 := hp1;
|
||||
@ -2040,7 +2040,17 @@ End.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.21 2002-04-15 19:44:21 peter
|
||||
Revision 1.22 2002-04-20 21:37:07 carl
|
||||
+ generic FPC_CHECKPOINTER
|
||||
+ first parameter offset in stack now portable
|
||||
* rename some constants
|
||||
+ move some cpu stuff to other units
|
||||
- remove unused constents
|
||||
* fix stacksize for some targets
|
||||
* fix generic size problems which depend now on EXTEND_SIZE constant
|
||||
* removing frame pointer in routines is only available for : i386,m68k and vis targets
|
||||
|
||||
Revision 1.21 2002/04/15 19:44:21 peter
|
||||
* fixed stackcheck that would be called recursively when a stack
|
||||
error was found
|
||||
* generic changeregsize(reg,size) for i386 register resizing
|
||||
|
@ -1123,8 +1123,8 @@ Begin
|
||||
if (opr.ref.index<>R_NO) then
|
||||
Message(asmr_e_wrong_base_index)
|
||||
else if assigned(procinfo^._class) and
|
||||
(oldbase=self_pointer) and
|
||||
(opr.ref.base=self_pointer) then
|
||||
(oldbase=SELF_POINTER_REG) and
|
||||
(opr.ref.base=SELF_POINTER_REG) then
|
||||
begin
|
||||
Message(asmr_w_possible_object_field_bug);
|
||||
{ warn but accept... who knows what people
|
||||
@ -1959,7 +1959,17 @@ finalization
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.24 2002-04-15 19:44:22 peter
|
||||
Revision 1.25 2002-04-20 21:37:07 carl
|
||||
+ generic FPC_CHECKPOINTER
|
||||
+ first parameter offset in stack now portable
|
||||
* rename some constants
|
||||
+ move some cpu stuff to other units
|
||||
- remove unused constents
|
||||
* fix stacksize for some targets
|
||||
* fix generic size problems which depend now on EXTEND_SIZE constant
|
||||
* removing frame pointer in routines is only available for : i386,m68k and vis targets
|
||||
|
||||
Revision 1.24 2002/04/15 19:44:22 peter
|
||||
* fixed stackcheck that would be called recursively when a stack
|
||||
error was found
|
||||
* generic changeregsize(reg,size) for i386 register resizing
|
||||
|
@ -35,7 +35,7 @@ Implementation
|
||||
|
||||
Uses
|
||||
{$ifdef replaceregdebug}cutils,{$endif}
|
||||
verbose,globals,cpubase,cpuasm,daopt386,csopt386,cginfo,rgobj;
|
||||
verbose,globals,cpuinfo,cpubase,cpuasm,daopt386,csopt386,cginfo,rgobj;
|
||||
|
||||
function canBeFirstSwitch(p: Taicpu; reg: tregister): boolean;
|
||||
{ checks whether an operation on reg can be switched to another reg without an }
|
||||
@ -350,7 +350,17 @@ End.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.11 2002-04-15 19:44:22 peter
|
||||
Revision 1.12 2002-04-20 21:37:08 carl
|
||||
+ generic FPC_CHECKPOINTER
|
||||
+ first parameter offset in stack now portable
|
||||
* rename some constants
|
||||
+ move some cpu stuff to other units
|
||||
- remove unused constents
|
||||
* fix stacksize for some targets
|
||||
* fix generic size problems which depend now on EXTEND_SIZE constant
|
||||
* removing frame pointer in routines is only available for : i386,m68k and vis targets
|
||||
|
||||
Revision 1.11 2002/04/15 19:44:22 peter
|
||||
* fixed stackcheck that would be called recursively when a stack
|
||||
error was found
|
||||
* generic changeregsize(reg,size) for i386 register resizing
|
||||
|
Loading…
Reference in New Issue
Block a user