From f3391f81a5e27e9729c260d0a319b92ecbe23782 Mon Sep 17 00:00:00 2001 From: nickysn Date: Thu, 15 Feb 2018 17:41:07 +0000 Subject: [PATCH] + introduce a new method tparamanager.asm_result_var(), which determines whether a pure assembler routine should be allocated a 'result' variable git-svn-id: trunk@38245 - --- compiler/paramgr.pas | 11 +++++++++++ compiler/pparautl.pas | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/compiler/paramgr.pas b/compiler/paramgr.pas index b1686303eb..e28fb15e5a 100644 --- a/compiler/paramgr.pas +++ b/compiler/paramgr.pas @@ -46,6 +46,8 @@ unit paramgr; function param_use_paraloc(const cgpara:tcgpara):boolean;virtual; { Returns true if the return value is actually a parameter pointer } function ret_in_param(def:tdef;pd:tabstractprocdef):boolean;virtual; + { Returns true if a result variable should be allocated for an assembler routine } + function asm_result_var(def:tdef;pd:tabstractprocdef):boolean;virtual; function push_high_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;virtual; function keep_para_array_range(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;virtual; @@ -201,6 +203,15 @@ implementation end; + { true if a result variable should be allocated for an assembler routine } + function tparamanager.asm_result_var(def:tdef;pd:tabstractprocdef):boolean; + begin + if not(po_assembler in pd.procoptions) then + internalerror(2018021501); + result:=true; + end; + + function tparamanager.push_high_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean; begin push_high_param:=not(calloption in cdecl_pocalls) and diff --git a/compiler/pparautl.pas b/compiler/pparautl.pas index 80ebfa8cc8..b2f88386d3 100644 --- a/compiler/pparautl.pas +++ b/compiler/pparautl.pas @@ -271,7 +271,8 @@ implementation begin { The result from constructors and destructors can't be accessed directly } if not(pd.proctypeoption in [potype_constructor,potype_destructor]) and - not is_void(pd.returndef) then + not is_void(pd.returndef) and + (not(po_assembler in pd.procoptions) or paramanager.asm_result_var(pd.returndef,pd)) then begin storepos:=current_tokenpos; current_tokenpos:=pd.fileinfo;