diff --git a/compiler/ncgcon.pas b/compiler/ncgcon.pas index d633ee4c15..2f055c53cc 100644 --- a/compiler/ncgcon.pas +++ b/compiler/ncgcon.pas @@ -32,10 +32,12 @@ interface type tcgdataconstnode = class(tdataconstnode) + function pass_1 : tnode;override; procedure pass_generate_code;override; end; tcgrealconstnode = class(trealconstnode) + function pass_1 : tnode;override; procedure pass_generate_code;override; end; @@ -48,10 +50,12 @@ interface end; tcgstringconstnode = class(tstringconstnode) + function pass_1 : tnode;override; procedure pass_generate_code;override; end; tcgsetconstnode = class(tsetconstnode) + function pass_1 : tnode;override; protected function emitvarsetconst: tasmsymbol; virtual; procedure handlevarsetconst; @@ -64,6 +68,7 @@ interface end; tcgguidconstnode = class(tguidconstnode) + function pass_1 : tnode;override; procedure pass_generate_code;override; end; @@ -74,7 +79,7 @@ implementation globtype,widestr,systems, verbose,globals,cutils, symconst,symdef,aasmtai,aasmdata,aasmcpu,defutil, - cpuinfo,cpubase, + procinfo,cpuinfo,cpubase, cgbase,cgobj,cgutils, ncgutil, cclasses,asmutils,tgobj ; @@ -84,6 +89,20 @@ implementation TCGREALCONSTNODE *****************************************************************************} + + procedure needs_got_for_pic; + begin + if (cs_create_pic in current_settings.moduleswitches) and + assigned(current_procinfo) then + include(current_procinfo.flags,pi_needs_got); + end; + + function tcgdataconstnode.pass_1 : tnode; + begin + pass_1:=inherited pass_1; + needs_got_for_pic; + end; + procedure tcgdataconstnode.pass_generate_code; var l : tasmlabel; @@ -108,6 +127,12 @@ implementation TCGREALCONSTNODE *****************************************************************************} + function tcgrealconstnode.pass_1 : tnode; + begin + pass_1:=inherited pass_1; + needs_got_for_pic; + end; + procedure tcgrealconstnode.pass_generate_code; { I suppose the parser/pass_1 must make sure the generated real } { constants are actually supported by the target processor? (JM) } @@ -255,6 +280,12 @@ implementation TCGSTRINGCONSTNODE *****************************************************************************} + function tcgstringconstnode.pass_1 : tnode; + begin + pass_1:=inherited pass_1; + needs_got_for_pic; + end; + procedure tcgstringconstnode.pass_generate_code; var lastlabel: tasmlabofs; @@ -389,6 +420,12 @@ implementation {***************************************************************************** TCGSETCONSTNODE *****************************************************************************} + function tcgsetconstnode.pass_1 : tnode; + begin + pass_1:=inherited pass_1; + needs_got_for_pic; + end; + function tcgsetconstnode.emitvarsetconst: tasmsymbol; type @@ -523,6 +560,12 @@ implementation TCGGUIDCONSTNODE *****************************************************************************} + function tcgguidconstnode.pass_1 : tnode; + begin + pass_1:=inherited pass_1; + needs_got_for_pic; + end; + procedure tcgguidconstnode.pass_generate_code; var tmplabel : TAsmLabel; @@ -552,4 +595,5 @@ begin csetconstnode:=tcgsetconstnode; cnilnode:=tcgnilnode; cguidconstnode:=tcgguidconstnode; + global_used:=@needs_got_for_pic; end.