Difference between revisions of "FPC Internals/Parameters"

From Lazarus wiki
Jump to navigationJump to search
m
m
Line 4: Line 4:
 
CPU target should implement parameter manager in '''cpupara.pas''' unit.
 
CPU target should implement parameter manager in '''cpupara.pas''' unit.
  
The unit should initialize the global '''ParamManager''' variable if an instance of the CPU specific class.
+
The unit should initialize the global '''ParaManager''' variable if an instance of the CPU specific class.
 
  ParaManager:=tcpuparamanager.create
 
  ParaManager:=tcpuparamanager.create
  
 
The basic TParaManager class cannot and should not be created, as it contain the abstract methods that should be implemented by CPU target implementation class.
 
The basic TParaManager class cannot and should not be created, as it contain the abstract methods that should be implemented by CPU target implementation class.
 +
 +
==Methods to Implement===
 +
The following methods are critical for CPU target implementation
 +
===push_addr_param===
 +
Returns true if a parameter is too large to copy and only  the address is pushed.
 +
function push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;virtual;abstract;
 +
===create_paraloc_info===
 +
This is used to populate the location information on all parameters
 +
for the routine as seen in either the caller or the callee. It returns
 +
the size allocated on the stack
 +
function  create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;virtual;abstract;
 +
===create_varargs_paraloc_info===
 +
This is used to populate the location information on all parameters
 +
for the routine that are passed as varargs. It returns
 +
the size allocated on the stack (including the normal parameters)
 +
function  create_varargs_paraloc_info(p : tabstractprocdef; side: tcallercallee; varargspara:tvarargsparalist):longint;virtual;abstract;
 +
===get_funcretloc===
 +
Returns the location of the function result if p had def as
 +
function result instead of its actual result. Used if the compiler
 +
forces the function result to something different than the real
 +
result. 
 +
function  get_funcretloc(p : tabstractprocdef; side: tcallercallee; forcetempdef: tdef): tcgpara;virtual;abstract;
 +
 +
  
 
==See Also==
 
==See Also==

Revision as of 15:59, 15 October 2019

FPC is using the CPU target specified parameter manager to manage the location of parameters passed into and routines.


CPU target should implement parameter manager in cpupara.pas unit.

The unit should initialize the global ParaManager variable if an instance of the CPU specific class.

ParaManager:=tcpuparamanager.create

The basic TParaManager class cannot and should not be created, as it contain the abstract methods that should be implemented by CPU target implementation class.

Methods to Implement=

The following methods are critical for CPU target implementation

push_addr_param

Returns true if a parameter is too large to copy and only the address is pushed.

function push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;virtual;abstract;

create_paraloc_info

This is used to populate the location information on all parameters for the routine as seen in either the caller or the callee. It returns the size allocated on the stack

function  create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;virtual;abstract;

create_varargs_paraloc_info

This is used to populate the location information on all parameters for the routine that are passed as varargs. It returns the size allocated on the stack (including the normal parameters)

function  create_varargs_paraloc_info(p : tabstractprocdef; side: tcallercallee; varargspara:tvarargsparalist):longint;virtual;abstract;

get_funcretloc

Returns the location of the function result if p had def as function result instead of its actual result. Used if the compiler forces the function result to something different than the real result.

function  get_funcretloc(p : tabstractprocdef; side: tcallercallee; forcetempdef: tdef): tcgpara;virtual;abstract;


See Also