Browse Source

* New intrinsiccode field for TCallNode to track transmutation from TInlineNode

J. Gareth "Curious Kit" Moreton 2 years ago
parent
commit
ea7b9c73f3
2 changed files with 24 additions and 3 deletions
  1. 23 2
      compiler/ncal.pas
  2. 1 1
      compiler/ppu.pas

+ 23 - 2
compiler/ncal.pas

@@ -36,7 +36,7 @@ interface
        nstate,
        nstate,
        {$endif state_tracking}
        {$endif state_tracking}
        symbase,symtype,symsym,symdef,symtable,
        symbase,symtype,symsym,symdef,symtable,
-       pgentype;
+       pgentype,compinnr;
 
 
     type
     type
        tcallnodeflag = (
        tcallnodeflag = (
@@ -159,6 +159,10 @@ interface
           { varargs parasyms }
           { varargs parasyms }
           varargsparas : tvarargsparalist;
           varargsparas : tvarargsparalist;
 
 
+          { If an inline node is transmuted into a call node, this is the index of
+            the original internal routine }
+          intrinsiccode : TInlineNumber;
+
           { separately specified resultdef for some compilerprocs (e.g.
           { separately specified resultdef for some compilerprocs (e.g.
             you can't have a function with an "array of char" resultdef
             you can't have a function with an "array of char" resultdef
             the RTL) (JM)
             the RTL) (JM)
@@ -173,6 +177,7 @@ interface
           constructor create(l:tnode; v : tprocsym;st : TSymtable; mp: tnode; callflags:tcallnodeflags;sc:tspecializationcontext);virtual;
           constructor create(l:tnode; v : tprocsym;st : TSymtable; mp: tnode; callflags:tcallnodeflags;sc:tspecializationcontext);virtual;
           constructor create_procvar(l,r:tnode);
           constructor create_procvar(l,r:tnode);
           constructor createintern(const name: string; params: tnode);
           constructor createintern(const name: string; params: tnode);
+          constructor createfromintrinsic(const intrinsic: TInlineNumber; const name: string; params: tnode);
           constructor createinternfromunit(const fromunit, procname: string; params: tnode);
           constructor createinternfromunit(const fromunit, procname: string; params: tnode);
           constructor createinternres(const name: string; params: tnode; res:tdef);
           constructor createinternres(const name: string; params: tnode; res:tdef);
           constructor createinternresfromunit(const fromunit, procname: string; params: tnode; res:tdef);
           constructor createinternresfromunit(const fromunit, procname: string; params: tnode; res:tdef);
@@ -317,7 +322,7 @@ implementation
       systems,
       systems,
       verbose,globals,fmodule,ppu,
       verbose,globals,fmodule,ppu,
       aasmbase,aasmdata,
       aasmbase,aasmdata,
-      symconst,defutil,defcmp,compinnr,
+      symconst,defutil,defcmp,
       htypechk,pass_1,
       htypechk,pass_1,
       ncnv,nflw,nld,ninl,nadd,ncon,nmem,nset,nobjc,
       ncnv,nflw,nld,ninl,nadd,ncon,nmem,nset,nobjc,
       pgenutil,
       pgenutil,
@@ -1538,6 +1543,7 @@ implementation
          funcretnode:=nil;
          funcretnode:=nil;
          paralength:=-1;
          paralength:=-1;
          varargsparas:=nil;
          varargsparas:=nil;
+         intrinsiccode:=Default(TInlineNumber);
          if assigned(current_structdef) and
          if assigned(current_structdef) and
             assigned(mp) and
             assigned(mp) and
             assigned(current_procinfo) then
             assigned(current_procinfo) then
@@ -1584,6 +1590,13 @@ implementation
        end;
        end;
 
 
 
 
+     constructor tcallnode.createfromintrinsic(const intrinsic: TInlineNumber; const name: string; params: tnode);
+       begin
+         createintern(name, params);
+         intrinsiccode := intrinsic;
+       end;
+
+
      constructor tcallnode.createinternfromunit(const fromunit, procname: string; params: tnode);
      constructor tcallnode.createinternfromunit(const fromunit, procname: string; params: tnode);
        var
        var
          srsym: tsym;
          srsym: tsym;
@@ -1692,6 +1705,7 @@ implementation
         symtableproc:=nil;
         symtableproc:=nil;
         ppufile.getderef(procdefinitionderef);
         ppufile.getderef(procdefinitionderef);
         ppufile.getset(tppuset4(callnodeflags));
         ppufile.getset(tppuset4(callnodeflags));
+        intrinsiccode:=TInlineNumber(ppufile.getword);
       end;
       end;
 
 
 
 
@@ -1707,6 +1721,7 @@ implementation
         ppufile.putderef(symtableprocentryderef);
         ppufile.putderef(symtableprocentryderef);
         ppufile.putderef(procdefinitionderef);
         ppufile.putderef(procdefinitionderef);
         ppufile.putset(tppuset4(callnodeflags));
         ppufile.putset(tppuset4(callnodeflags));
+        ppufile.putword(word(intrinsiccode));
       end;
       end;
 
 
 
 
@@ -1889,6 +1904,9 @@ implementation
               WriteLn(T, PrintNodeIndention, '<procname>', symtableprocentry.name, '</procname>')
               WriteLn(T, PrintNodeIndention, '<procname>', symtableprocentry.name, '</procname>')
           end;
           end;
 
 
+        if intrinsiccode <> Default(TInlineNumber) then
+          WriteLn(T, PrintNodeIndention, '<intrinsiccode>', intrinsiccode, '</intrinsiccode>');
+
         if assigned(methodpointer) then
         if assigned(methodpointer) then
           begin
           begin
             WriteLn(T, PrintNodeIndention, '<methodpointer>');
             WriteLn(T, PrintNodeIndention, '<methodpointer>');
@@ -1942,6 +1960,9 @@ implementation
               writeln(t,printnodeindention,'proc = <nil>');
               writeln(t,printnodeindention,'proc = <nil>');
           end;
           end;
 
 
+        if intrinsiccode <> Default(TInlineNumber) then
+          writeln(t,printnodeindention,'intrinsiccode = ', intrinsiccode);
+
         if assigned(methodpointer) then
         if assigned(methodpointer) then
           begin
           begin
             writeln(t,printnodeindention,'methodpointer =');
             writeln(t,printnodeindention,'methodpointer =');

+ 1 - 1
compiler/ppu.pas

@@ -48,7 +48,7 @@ const
   CurrentPPUVersion = 208;
   CurrentPPUVersion = 208;
   { for any other changes to the ppu format, increase this version number
   { for any other changes to the ppu format, increase this version number
     (it's a cardinal) }
     (it's a cardinal) }
-  CurrentPPULongVersion = 19;
+  CurrentPPULongVersion = 20;
 
 
 { unit flags }
 { unit flags }
   uf_big_endian          = $000004;
   uf_big_endian          = $000004;