* use pocalls_cdecl and cstylearrayofconst more consistently instead of

ad hoc set constants containing varying number cdecl-like calling
    conventions
   o added pocall_sysv_abi_cdecl and pocall_ms_abi_cdecl to cstylearrayofconst
   o also allow C-style blocks with mwpascal instead of cdecl (mwpascal = cdecl
     with "const" = "constref" for record parameters)
   o did not touch cases related to name mangling and import/export names,
     because those are a real mess and easily break things left and right :/

git-svn-id: trunk@35479 -
This commit is contained in:
Jonas Maebe 2017-02-25 11:46:35 +00:00
parent 1adde89621
commit 4c68ea1000
8 changed files with 13 additions and 12 deletions

View File

@ -132,7 +132,7 @@ unit cpupara;
if ((target_info.abi=abi_eabihf) or (calloption=pocall_hardfloat)) and
(not isvariadic) then
getparaloc:=LOC_MMREGISTER
else if (calloption in [pocall_cdecl,pocall_cppdecl,pocall_softfloat]) or
else if (calloption in cdecl_pocalls) or
(cs_fp_emulation in current_settings.moduleswitches) or
(current_settings.fputype in [fpu_vfpv2,fpu_vfpv3,fpu_vfpv4,fpu_vfpv3_d16,fpu_fpv4_s16]) then
{ the ARM eabi also allows passing VFP values via VFP registers,

View File

@ -575,7 +575,7 @@ interface
pocall_default = pocall_stdcall;
{$endif}
cstylearrayofconst = [pocall_cdecl,pocall_cppdecl,pocall_mwpascal];
cstylearrayofconst = [pocall_cdecl,pocall_cppdecl,pocall_mwpascal,pocall_sysv_abi_cdecl,pocall_ms_abi_cdecl];
modeswitchstr : array[tmodeswitch] of string[18] = ('',
'','','','','','','',

View File

@ -104,7 +104,7 @@ unit cpupara;
only records of a size of 1,2 or 4 bytes in FUNCTION_RETURN_REG }
if ((pd.proccalloption in [pocall_stdcall,pocall_register]) and
(def.size in [1,2,4])) or
((pd.proccalloption in [pocall_cdecl,pocall_cppdecl]) and
((pd.proccalloption in cdecl_pocalls) and
(def.size>0) and
(def.size<=8)) then
begin
@ -121,7 +121,7 @@ unit cpupara;
recorddef :
begin
{ EMX port of GCC returns small records in the FUNCTION_RETURN_REG up to 4 bytes in registers. }
if ((pd.proccalloption in [pocall_cdecl,pocall_cppdecl]) and
if ((pd.proccalloption in cdecl_pocalls) and
(def.size>0) and
(def.size<=4)) then
begin

View File

@ -38,6 +38,7 @@ implementation
uses
globtype,cpubase,procinfo,
symconst,
aasmtai,aasmcpu,aasmdata,
paramgr,
ncal;
@ -47,7 +48,7 @@ begin
pass_1 := inherited pass_1;
if assigned(current_procinfo) and
assigned(procdefinition) and
(procdefinition.proccalloption=pocall_cdecl) then
(procdefinition.proccalloption in cdecl_pocalls) then
include(current_procinfo.flags,pi_needs_got);
end;

View File

@ -839,7 +839,7 @@ implementation
else
begin
if (po_hascallingconvention in tprocvardef(hdef).procoptions) and
(tprocvardef(hdef).proccalloption=pocall_cdecl) then
(tprocvardef(hdef).proccalloption in [pocall_cdecl,pocall_mwpascal]) then
begin
include(tprocvardef(hdef).procoptions,po_is_block);
{ can't check yet whether the parameter types

View File

@ -3234,7 +3234,7 @@ const
{ for objcclasses this is checked later, because the entire
class may be external. }
is_objc_class_or_protocol(tprocdef(pd).struct)) and
not(pd.proccalloption in (cdecl_pocalls + [pocall_mwpascal,pocall_stdcall])) then
not(pd.proccalloption in (cdecl_pocalls + [pocall_stdcall])) then
Message(parser_e_varargs_need_cdecl_and_external);
end
else
@ -3242,7 +3242,7 @@ const
{ both must be defined now }
if not((po_external in pd.procoptions) or
(pd.typ=procvardef)) or
not(pd.proccalloption in (cdecl_pocalls + [pocall_mwpascal,pocall_stdcall])) then
not(pd.proccalloption in (cdecl_pocalls + [pocall_stdcall])) then
Message(parser_e_varargs_need_cdecl_and_external);
end;
end;

View File

@ -220,7 +220,7 @@ unit cpupara;
not(target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin]) or
((varspez = vs_const) and
((calloption = pocall_mwpascal) or
(not (calloption in [pocall_cdecl,pocall_cppdecl]) and
(not (calloption in cdecl_pocalls) and
(def.size > 8)
)
)

View File

@ -185,7 +185,7 @@ begin
(varspez = vs_const) and
(
(
(not (calloption in [pocall_cdecl, pocall_cppdecl]) and
(not (calloption in cdecl_pocalls) and
(def.size > 8))
) or
(calloption = pocall_mwpascal)
@ -371,7 +371,7 @@ begin
end;
{ currently only support C-style array of const }
if (p.proccalloption in [pocall_cdecl, pocall_cppdecl]) and
if (p.proccalloption in cstylearrayofconst) and
is_array_of_const(hp.vardef) then begin
paraloc := hp.paraloc[side].add_location;
{ hack: the paraloc must be valid, but is not actually used }
@ -744,7 +744,7 @@ begin
result := create_paraloc_info_intern(p, callerside, p.paras, curintreg,
curfloatreg, curmmreg, cur_stack_offset, false);
if (p.proccalloption in [pocall_cdecl, pocall_cppdecl, pocall_mwpascal]) then begin
if (p.proccalloption in cstylearrayofconst) then begin
{ just continue loading the parameters in the registers }
result := create_paraloc_info_intern(p, callerside, varargspara, curintreg,
curfloatreg, curmmreg, cur_stack_offset, true);