2
0
Эх сурвалжийг харах

* assembler inlining working for ag386bin

peter 26 жил өмнө
parent
commit
2bfdf91c5c

+ 6 - 2
compiler/aopt386.pas

@@ -34,7 +34,8 @@ Implementation
 
 Uses
   globtype,
-  globals,i386,DAOpt386,POpt386,CSOpt386;
+  globals,
+  DAOpt386,POpt386,CSOpt386;
 
 
 Procedure Optimize(AsmL: PAasmOutput);
@@ -83,7 +84,10 @@ End.
 
 {
  $Log$
- Revision 1.25  1998-12-29 19:58:27  jonas
+ Revision 1.26  1999-03-31 13:55:03  peter
+   * assembler inlining working for ag386bin
+
+ Revision 1.25  1998/12/29 19:58:27  jonas
    * fixed crash when there are two asm blocks right after each other
 
  Revision 1.24  1998/12/29 18:48:23  jonas

+ 34 - 52
compiler/cg386cal.pas

@@ -23,6 +23,8 @@
 unit cg386cal;
 interface
 
+{$define EXtdebug}
+
     uses
       symtable,tree;
 
@@ -242,21 +244,19 @@ implementation
            begin
               inlined:=true;
               inlinecode:=p^.right;
-              { set it to the same lexical level }
-              p^.procdefinition^.parast^.symtablelevel:=
-                aktprocsym^.definition^.parast^.symtablelevel;
+              { set it to the same lexical level as the local symtable, becuase
+                the para's are stored there }
+              p^.procdefinition^.parast^.symtablelevel:=aktprocsym^.definition^.localst^.symtablelevel;
               if assigned(p^.left) then
-                inlinecode^.para_offset:=
-                  gettempofsizepersistant(inlinecode^.para_size);
-              p^.procdefinition^.parast^.call_offset:=
-                inlinecode^.para_offset;
+                inlinecode^.para_offset:=gettempofsizepersistant(inlinecode^.para_size);
+              p^.procdefinition^.parast^.address_fixup:=inlinecode^.para_offset;
 {$ifdef extdebug}
              Comment(V_debug,
                'inlined parasymtable is at offset '
-               +tostr(p^.procdefinition^.parast^.call_offset));
+               +tostr(p^.procdefinition^.parast^.address_fixup));
              exprasmlist^.concat(new(pai_asm_comment,init(
                strpnew('inlined parasymtable is at offset '
-               +tostr(p^.procdefinition^.parast^.call_offset)))));
+               +tostr(p^.procdefinition^.parast^.address_fixup)))));
 {$endif extdebug}
               p^.right:=nil;
               { disable further inlining of the same proc
@@ -351,7 +351,7 @@ implementation
            begin
               { be found elsewhere }
               if inlined then
-                para_offset:=p^.procdefinition^.parast^.call_offset+
+                para_offset:=p^.procdefinition^.parast^.address_fixup+
                   p^.procdefinition^.parast^.datasize
               else
                 para_offset:=0;
@@ -792,11 +792,12 @@ implementation
               else { inlined proc }
                 { inlined code is in inlinecode }
                 begin
-                   secondpass(inlinecode);
                    { set poinline again }
                    p^.procdefinition^.options:=p^.procdefinition^.options or poinline;
+                   { process the inlinecode }
+                   secondpass(inlinecode);
                    { free the args }
-                   ungetpersistanttemp(p^.procdefinition^.parast^.call_offset,
+                   ungetpersistanttemp(p^.procdefinition^.parast^.address_fixup,
                      p^.procdefinition^.parast^.datasize);
                 end;
            end
@@ -1122,26 +1123,6 @@ implementation
                              SecondProcInlineN
 *****************************************************************************}
 
-    { implementation not complete yet }
-
-    var
-      addr_correction : longint;
-
-    procedure correct_address(p : psym);{$ifndef FPC}far;{$endif}
-      begin
-         if p^.typ=varsym then
-           begin
-             inc(pvarsym(p)^.address,addr_correction);
-{$ifdef extdebug}
-             Comment(V_debug,pvarsym(p)^.name+' is at offset -'
-               +tostr(pvarsym(p)^.address));
-             exprasmlist^.concat(new(pai_asm_comment,init(
-               strpnew(pvarsym(p)^.name+' is at offset -'
-               +tostr(pvarsym(p)^.address)))));
-{$endif extdebug}
-           end;
-      end;
-
 
     procedure secondprocinline(var p : ptree);
        var st : psymtable;
@@ -1162,24 +1143,22 @@ implementation
           oldprocsym:=aktprocsym;
           oldprocinfo:=procinfo;
           { set the return value }
-          procinfo.retdef:=p^.inlineprocdef^.retdef;
+          aktprocsym:=p^.inlineprocsym;
+          procinfo.retdef:=aktprocsym^.definition^.retdef;
           procinfo.retoffset:=p^.retoffset;
           { arg space has been filled by the parent secondcall }
-          st:=p^.inlineprocdef^.localst;
-              { set it to the same lexical level }
-          st^.symtablelevel:=
-            oldprocsym^.definition^.localst^.symtablelevel;
+          st:=aktprocsym^.definition^.localst;
+          { set it to the same lexical level }
+          st^.symtablelevel:=oldprocsym^.definition^.localst^.symtablelevel;
           if st^.datasize>0 then
-            st^.call_offset:=gettempofsizepersistant(st^.datasize);
+            begin
+              st^.address_fixup:=gettempofsizepersistant(st^.datasize);
 {$ifdef extdebug}
-             Comment(V_debug,'local symtable is at offset '
-               +tostr(st^.call_offset));
-          exprasmlist^.concat(new(pai_asm_comment,init(
-          strpnew('local symtable is at offset '
-               +tostr(st^.call_offset)))));
+              Comment(V_debug,'local symtable is at offset '+tostr(st^.address_fixup));
+              exprasmlist^.concat(new(pai_asm_comment,init(strpnew(
+                'local symtable is at offset '+tostr(st^.address_fixup)))));
 {$endif extdebug}
-          addr_correction:=-st^.call_offset-st^.datasize;
-          st^.foreach(correct_address);
+            end;
 {$ifdef extdebug}
           exprasmlist^.concat(new(pai_asm_comment,init('Start of inlined proc')));
 {$endif extdebug}
@@ -1191,18 +1170,18 @@ implementation
           make_global:=false; { to avoid warning }
           genentrycode(inlineentrycode,proc_names,make_global,0,para_size,nostackframe,true);
           exprasmlist^.concatlist(inlineentrycode);
-          secondpass(p^.left);
+          secondpass(p^.inlinetree);
           genexitcode(inlineexitcode,0,false,true);
           exprasmlist^.concatlist(inlineexitcode);
 {$ifdef extdebug}
           exprasmlist^.concat(new(pai_asm_comment,init('End of inlined proc')));
 {$endif extdebug}
-          {we can free the local data now }
+          {we can free the local data now, reset also the fixup address }
           if st^.datasize>0 then
-            ungetpersistanttemp(st^.call_offset,st^.datasize);
-          { set the real address again }
-          addr_correction:=-addr_correction;
-          st^.foreach(correct_address);
+            begin
+              ungetpersistanttemp(st^.address_fixup,st^.datasize);
+              st^.address_fixup:=0;
+            end;
           aktprocsym:=oldprocsym;
           freelabel(aktexitlabel);
           freelabel(aktexit2label);
@@ -1217,7 +1196,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.70  1999-03-24 23:16:46  peter
+  Revision 1.71  1999-03-31 13:55:04  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.70  1999/03/24 23:16:46  peter
     * fixed bugs 212,222,225,227,229,231,233
 
   Revision 1.69  1999/02/25 21:02:21  peter

+ 7 - 9
compiler/cg386ld.pas

@@ -118,13 +118,9 @@ implementation
                                                    inlineparasymtable,localsymtable]) then
                                 begin
                                    p^.location.reference.base:=procinfo.framepointer;
-                                   p^.location.reference.offset:=pvarsym(p^.symtableentry)^.address;
-                                   if (symtabletype in [localsymtable,inlinelocalsymtable]) or
-                                      pvarsym(p^.symtableentry)^.islocalcopy then
-                                     p^.location.reference.offset:=-p^.location.reference.offset
-                                   else
-                                     if (symtabletype in [parasymtable,inlineparasymtable]) then
-                                       inc(p^.location.reference.offset,p^.symtable^.call_offset);
+                                   p^.location.reference.offset:=pvarsym(p^.symtableentry)^.address+p^.symtable^.address_fixup;
+                                   if (symtabletype in [localsymtable,inlinelocalsymtable]) then
+                                     p^.location.reference.offset:=-p^.location.reference.offset;
                                    if (lexlevel>(p^.symtable^.symtablelevel)) then
                                      begin
                                         hregister:=getregister32;
@@ -133,7 +129,6 @@ implementation
                                         hp:=new_reference(procinfo.framepointer,
                                           procinfo.framepointer_offset);
 
-
                                         exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,hp,hregister)));
 
                                         simple_loadn:=false;
@@ -802,7 +797,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.46  1999-03-24 23:16:52  peter
+  Revision 1.47  1999-03-31 13:55:07  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.46  1999/03/24 23:16:52  peter
     * fixed bugs 212,222,225,227,229,231,233
 
   Revision 1.45  1999/02/25 21:02:28  peter

+ 73 - 21
compiler/cobjects.pas

@@ -69,6 +69,7 @@ unit cobjects;
           { does nothing }
           constructor init;
           destructor done;virtual;
+          function getcopy:plinkedlist_item;virtual;
        end;
 
        pstring_item = ^tstring_item;
@@ -101,6 +102,8 @@ unit cobjects;
           { concats another list at the end and make this list empty }
           procedure concatlist(p : plinkedlist);
 
+          procedure concatlistcopy(p : plinkedlist);
+
           { removes p from the list (p isn't disposed) }
           { it's not tested if p is in the list !      }
           procedure remove(p : plinkedlist_item);
@@ -682,15 +685,28 @@ end;
 
     constructor tlinkedlist_item.init;
       begin
-         previous:=nil;
-         next:=nil;
+        previous:=nil;
+        next:=nil;
       end;
 
+
     destructor tlinkedlist_item.done;
       begin
       end;
 
 
+    function tlinkedlist_item.getcopy:plinkedlist_item;
+      var
+        l : longint;
+        p : plinkedlist_item;
+      begin
+        l:=sizeof(self);
+        getmem(p,l);
+        move(self,p^,l);
+        getcopy:=p;
+      end;
+
+
 {****************************************************************************
                             TSTRING_ITEM
  ****************************************************************************}
@@ -764,31 +780,36 @@ end;
 
     procedure tlinkedlist.concat(p : plinkedlist_item);
       begin
-         p^.previous:=nil;
-         p^.next:=nil;
-         if not(assigned(first)) then
-           first:=p
-           else
-             begin
-                last^.next:=p;
-                p^.previous:=last;
-             end;
-         last:=p;
+        if not(assigned(first)) then
+         begin
+           first:=p;
+           p^.previous:=nil;
+           p^.next:=nil;
+         end
+        else
+         begin
+           last^.next:=p;
+           p^.previous:=last;
+           p^.next:=nil;
+         end;
+        last:=p;
       end;
 
 
     procedure tlinkedlist.insert(p : plinkedlist_item);
       begin
-         p^.previous:=nil;
-         p^.next:=nil;
          if not(assigned(first)) then
-           last:=p
+          begin
+            last:=p;
+            p^.previous:=nil;
+            p^.next:=nil;
+          end
          else
-           begin
-              first^.previous:=p;
-              p^.next:=first;
-              first:=p;
-           end;
+          begin
+            first^.previous:=p;
+            p^.previous:=nil;
+            p^.next:=first;
+          end;
          first:=p;
       end;
 
@@ -845,6 +866,34 @@ end;
       end;
 
 
+    procedure tlinkedlist.concatlistcopy(p : plinkedlist);
+      var
+        hp,hp2 : plinkedlist_item;
+      begin
+         hp:=p^.first;
+         while assigned(hp) do
+          begin
+            hp2:=hp^.getcopy;
+            if assigned(hp2) then
+             begin
+               if not(assigned(first)) then
+                begin
+                  first:=hp2;
+                  hp2^.previous:=nil;
+                  hp2^.next:=nil;
+                end
+               else
+                begin
+                  last^.next:=hp2;
+                  hp2^.previous:=last;
+                  hp2^.next:=nil;
+                end;
+               last:=hp2;
+             end;
+            hp:=hp^.next;
+          end;
+      end;
+
     function tlinkedlist.empty:boolean;
       begin
         empty:=(first=nil);
@@ -1563,7 +1612,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.21  1999-03-19 16:35:29  pierre
+  Revision 1.22  1999-03-31 13:55:10  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.21  1999/03/19 16:35:29  pierre
    * Tnamed_object done also removed left and right
 
   Revision 1.20  1999/03/18 20:30:45  peter

+ 53 - 3
compiler/pass_2.pas

@@ -120,8 +120,55 @@ implementation
 
 
     procedure secondasm(var p : ptree);
+{$ifdef AG386BIN}
+      var
+        hp,hp2 : pai;
+        localfixup,parafixup,
+        i : longint;
+        r : preference;
+{$endif}
       begin
-         exprasmlist^.concatlist(p^.p_asm);
+{$ifdef AG386BIN}
+         if (aktprocsym^.definition^.options and poinline)<>0 then
+           begin
+             localfixup:=aktprocsym^.definition^.localst^.address_fixup;
+             parafixup:=aktprocsym^.definition^.parast^.address_fixup;
+             hp:=pai(p^.p_asm^.first);
+             while assigned(hp) do
+              begin
+                hp2:=pai(hp^.getcopy);
+                case hp2^.typ of
+                  ait_instruction :
+                     begin
+                       { fixup the references }
+                       for i:=1 to pai386(hp2)^.ops do
+                        if pai386(hp2)^.oper[i-1].typ=top_ref then
+                         begin
+                           r:=pai386(hp2)^.oper[i-1].ref;
+                           case r^.options of
+                             ref_parafixup :
+                               r^.offsetfixup:=parafixup;
+                             ref_localfixup :
+                               r^.offsetfixup:=localfixup;
+                           end;
+                         end;
+                       exprasmlist^.concat(hp2);
+                     end;
+                   ait_marker :
+                     begin
+                     { it's not an assembler block anymore }
+                       if not(pai_marker(hp2)^.kind in [AsmBlockStart, AsmBlockEnd]) then
+                        exprasmlist^.concat(hp2);
+                     end;
+                   else
+                     exprasmlist^.concat(hp2);
+                end;
+                hp:=pai(hp^.next);
+              end
+           end
+         else
+{$endif}
+           exprasmlist^.concatlist(p^.p_asm);
          if not p^.object_preserved then
           begin
 {$ifdef i386}
@@ -361,7 +408,7 @@ implementation
                            dec(procinfo.retoffset,4);
 
                          dec(procinfo.call_offset,4);
-                         aktprocsym^.definition^.parast^.call_offset:=procinfo.call_offset;
+                         aktprocsym^.definition^.parast^.address_fixup:=procinfo.call_offset;
                        end;
                      end;
                    if (p^.registers32<4) then
@@ -500,7 +547,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.16  1999-03-24 23:17:11  peter
+  Revision 1.17  1999-03-31 13:55:11  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.16  1999/03/24 23:17:11  peter
     * fixed bugs 212,222,225,227,229,231,233
 
   Revision 1.15  1999/02/22 02:15:25  peter

+ 5 - 2
compiler/pexpr.pas

@@ -1397,7 +1397,7 @@ unit pexpr;
                               p1:=gencallnode(nil,nil);
                               p1^.right:=p2;
                               p1^.unit_specific:=unit_specific;
-                              p1^.symtableprocentry:=sym;
+                              p1^.symtableprocentry:=pprocsym(sym);
                               if token=LKLAMMER then
                                 begin
                                    consume(LKLAMMER);
@@ -1976,7 +1976,10 @@ unit pexpr;
 end.
 {
   $Log$
-  Revision 1.89  1999-03-26 00:05:36  peter
+  Revision 1.90  1999-03-31 13:55:12  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.89  1999/03/26 00:05:36  peter
     * released valintern
     + deffile is now removed when compiling is finished
     * ^( compiles now correct

+ 17 - 16
compiler/pstatmnt.pas

@@ -701,12 +701,6 @@ unit pstatmnt;
         asmstat : ptree;
         Marker : Pai;
       begin
-         if (aktprocsym^.definition^.options and poinline)<>0 then
-           Begin
-              Message1(parser_w_not_supported_for_inline,'asm statement');
-              Message(parser_w_inlining_disabled);
-              aktprocsym^.definition^.options:= aktprocsym^.definition^.options and not poinline;
-           End;
          Inside_asm_statement:=true;
          case aktasmmode of
 {$ifdef i386}
@@ -720,7 +714,15 @@ unit pstatmnt;
   {$endif NoRA386Int}
   {$ifndef NoRA386Dir}
            asmmode_i386_direct:
-             asmstat:=ra386dir.assemble;
+             begin
+               if (aktprocsym^.definition^.options and poinline)<>0 then
+                 Begin
+                    Message1(parser_w_not_supported_for_inline,'direct asm');
+                    Message(parser_w_inlining_disabled);
+                    aktprocsym^.definition^.options:= aktprocsym^.definition^.options and not poinline;
+                 End;
+               asmstat:=ra386dir.assemble;
+             end;
   {$endif NoRA386Dir}
 {$endif}
 {$ifdef m68k}
@@ -1231,7 +1233,8 @@ unit pstatmnt;
          { temporary space is set, while the BEGIN of the procedure }
          if symtablestack^.symtabletype=localsymtable then
            procinfo.firsttemp := -symtablestack^.datasize
-         else procinfo.firsttemp := 0;
+         else
+           procinfo.firsttemp := 0;
 
          { assembler code does not allocate }
          { space for the return value       }
@@ -1265,14 +1268,9 @@ unit pstatmnt;
                (aktprocsym^.definition^.parast^.datasize=0) and
                not(ret_in_param(aktprocsym^.definition^.retdef)) then
                begin
-{$ifdef i386}
-                  procinfo.framepointer:=R_ESP;
-{$endif}
-{$ifdef m68k}
-                  procinfo.framepointer:=R_SP;
-{$endif}
+                  procinfo.framepointer:=stack_pointer;
                   { set the right value for parameters }
-                  dec(aktprocsym^.definition^.parast^.call_offset,target_os.size_of_pointer);
+                  dec(aktprocsym^.definition^.parast^.address_fixup,target_os.size_of_pointer);
                   dec(procinfo.call_offset,target_os.size_of_pointer);
               end;
           { force the asm statement }
@@ -1288,7 +1286,10 @@ unit pstatmnt;
 end.
 {
   $Log$
-  Revision 1.71  1999-03-10 11:23:29  pierre
+  Revision 1.72  1999-03-31 13:55:15  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.71  1999/03/10 11:23:29  pierre
    * typecheck for exit(value) : resulttype was not set
 
   Revision 1.70  1999/03/04 13:55:45  pierre

+ 5 - 2
compiler/ra386dir.pas

@@ -194,7 +194,7 @@ unit Ra386dir;
                                                   begin
                                                      l:=pvarsym(sym)^.address;
                                                      { set offset }
-                                                     inc(l,aktprocsym^.definition^.parast^.call_offset);
+                                                     inc(l,aktprocsym^.definition^.parast^.address_fixup);
                                                      hs:=tostr(l)+'('+att_reg2str[procinfo.framepointer]+')';
                                                      if pos(',',s) > 0 then
                                                        pvarsym(sym)^.is_valid:=1;
@@ -295,7 +295,10 @@ unit Ra386dir;
 end.
 {
   $Log$
-  Revision 1.16  1999-03-24 23:17:22  peter
+  Revision 1.17  1999-03-31 13:55:18  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.16  1999/03/24 23:17:22  peter
     * fixed bugs 212,222,225,227,229,231,233
 
   Revision 1.15  1999/03/01 13:22:26  pierre

+ 5 - 2
compiler/rautils.pas

@@ -1447,7 +1447,7 @@ end;
                      begin
                        l:=pvarsym(sym)^.address;
                        { set offset }
-                       inc(l,aktprocsym^.definition^.parast^.call_offset);
+                       inc(l,aktprocsym^.definition^.parast^.address_fixup);
                      end;
                     pvarsym(sym)^.is_valid:=1;
                     inc(pvarsym(sym)^.refs);
@@ -1791,7 +1791,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.7  1999-03-24 23:17:23  peter
+  Revision 1.8  1999-03-31 13:55:19  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.7  1999/03/24 23:17:23  peter
     * fixed bugs 212,222,225,227,229,231,233
 
   Revision 1.6  1999/03/01 13:22:25  pierre

+ 18 - 7
compiler/scandir.inc

@@ -31,13 +31,14 @@ type
      _DIR_D,_DIR_DEBUGINFO,_DIR_DEFINE,_DIR_DESCRIPTION,
      _DIR_ELSE,_DIR_ENDIF,_DIR_ERROR,_DIR_EXTENDEDSYNTAX,
      _DIR_FATAL,
+     _DIR_GOTO,
      _DIR_HINT,_DIR_HINTS,
      _DIR_I,_DIR_I386_ATT,_DIR_I386_DIRECT,_DIR_I386_INTEL,_DIR_IOCHECKS,
        _DIR_IF,_DIR_IFDEF,_DIR_IFNDEF,_DIR_IFOPT,_DIR_INCLUDE,_DIR_INCLUDEPATH,
-       _DIR_INFO,
+       _DIR_INFO,_DIR_INLINE,
      _DIR_L,_DIR_LIBRARYPATH,_DIR_LINK,_DIR_LINKLIB,_DIR_LOCALSYMBOLS,
        _DIR_LONGSTRINGS,
-     _DIR_M,_DIR_MEMORY,_DIR_MESSAGE,_DIR_MINENUMSIZE,_DIR_MMX,_DIR_MODE,
+     _DIR_M,_DIR_MACRO,_DIR_MEMORY,_DIR_MESSAGE,_DIR_MINENUMSIZE,_DIR_MMX,_DIR_MODE,
      _DIR_NOTE,_DIR_NOTES,
      _DIR_OBJECTPATH,_DIR_OPENSTRINGS,_DIR_OUTPUT_FORMAT,_DIR_OVERFLOWCHECKS,
      _DIR_PACKENUM,_DIR_PACKRECORDS,
@@ -59,13 +60,14 @@ const
      'D','DEBUGINFO','DEFINE','DESCRIPTION',
      'ELSE','ENDIF','ERROR','EXTENDEDSYNTAX',
      'FATAL',
+     'GOTO',
      'HINT','HINTS',
      'I','I386_ATT','I386_DIRECT','I386_INTEL','IOCHECKS',
        'IF','IFDEF','IFNDEF','IFOPT','INCLUDE','INCLUDEPATH',
-       'INFO',
+       'INFO','INLINE',
      'L','LIBRARYPATH','LINK','LINKLIB','LOCALSYMBOLS',
        'LONGSTRINGS',
-     'M','MEMORY','MESSAGE','MINENUMSIZE','MMX','MODE',
+     'M','MACRO','MEMORY','MESSAGE','MINENUMSIZE','MMX','MODE',
      'NOTE','NOTES',
      'OBJECTPATH','OPENSTRINGS','OUTPUT_FORMAT','OVERFLOWCHECKS',
      'PACKENUM','PACKRECORDS',
@@ -477,8 +479,11 @@ const
       begin
         sw:=cs_modulenone;
         case t of
-           _DIR_SMARTLINK : sw:=cs_smartlink;
-           _DIR_STATIC    : sw:=cs_static_keyword;
+          _DIR_GOTO      : sw:=cs_support_goto;
+          _DIR_MACRO     : sw:=cs_support_macro;
+          _DIR_INLINE    : sw:=cs_support_inline;
+          _DIR_SMARTLINK : sw:=cs_smartlink;
+          _DIR_STATIC    : sw:=cs_static_keyword;
         end;
         state:=current_scanner^.readstate;
         if (sw<>cs_modulenone) and (state in ['-','+']) then
@@ -958,6 +963,7 @@ const
          {_DIR_ERROR} dir_message,
          {_DIR_EXTENDEDSYNTAX} dir_delphiswitch,
          {_DIR_FATAL} dir_message,
+         {_DIR_GOTO} dir_moduleswitch,
          {_DIR_HINT} dir_message,
          {_DIR_HINTS} dir_setverbose,
          {_DIR_I} dir_include,
@@ -972,6 +978,7 @@ const
          {_DIR_INCLUDE} dir_include,
          {_DIR_INCLUDEPATH} dir_includepath,
          {_DIR_INFO} dir_message,
+         {_DIR_INLINE} dir_moduleswitch,
          {_DIR_L} dir_linkobject,
          {_DIR_LIBRARYPATH} dir_librarypath,
          {_DIR_LINK} dir_linkobject,
@@ -979,6 +986,7 @@ const
          {_DIR_LOCALSYMBOLS} dir_delphiswitch,
          {_DIR_LONGSTRINGS} dir_delphiswitch,
          {_DIR_M} dir_memory,
+         {_DIR_MACRO} dir_moduleswitch,
          {_DIR_MEMORY} dir_memory,
          {_DIR_MESSAGE} dir_message,
          {_DIR_MINENUMSIZE} dir_packenum,
@@ -1079,7 +1087,10 @@ const
 
 {
   $Log$
-  Revision 1.49  1999-03-26 00:05:44  peter
+  Revision 1.50  1999-03-31 13:55:20  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.49  1999/03/26 00:05:44  peter
     * released valintern
     + deffile is now removed when compiling is finished
     * ^( compiles now correct

+ 5 - 4
compiler/symsym.inc

@@ -913,7 +913,6 @@
          _mangledname:=nil;
          varspez:=vs_value;
          address:=0;
-         localaddress:=-1;
          islocalcopy:=false;
          localvarsym:=nil;
          refs:=0;
@@ -974,7 +973,6 @@
            address:=readlong
          else
            address:=0;
-         localaddress:=-1;
          islocalcopy:=false;
          localvarsym:=nil;
          definition:=readdefref;
@@ -1268,7 +1266,7 @@
             stabstring := strpnew('"'+name+':'+st
                   +definition^.numberstring+'",'+
                   tostr(N_PSYM)+',0,'+tostr(fileinfo.line)+','+
-                  tostr(address+owner^.call_offset));
+                  tostr(address+owner^.address_fixup));
                   {offset to ebp => will not work if the framepointer is esp
                   so some optimizing will make things harder to debug }
          end
@@ -1870,7 +1868,10 @@
 
 {
   $Log$
-  Revision 1.75  1999-03-24 23:17:27  peter
+  Revision 1.76  1999-03-31 13:55:21  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.75  1999/03/24 23:17:27  peter
     * fixed bugs 212,222,225,227,229,231,233
 
   Revision 1.74  1999/02/23 18:29:27  pierre

+ 4 - 2
compiler/symsymh.inc

@@ -177,7 +177,6 @@
        tvarsym = object(tsym)
           address      : longint;
           localvarsym  : pvarsym;
-          localaddress : longint;  { address of the local copy of a value para, -1 means not used }
           islocalcopy  : boolean;
           definition   : pdef;
           refs         : longint;
@@ -335,7 +334,10 @@
 
 {
   $Log$
-  Revision 1.16  1999-03-24 23:17:29  peter
+  Revision 1.17  1999-03-31 13:55:23  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.16  1999/03/24 23:17:29  peter
     * fixed bugs 212,222,225,227,229,231,233
 
   Revision 1.15  1999/02/22 13:07:11  pierre

+ 19 - 19
compiler/tccal.pas

@@ -327,6 +327,8 @@ implementation
          hcvt : tconverttype;
          regi : tregister;
          store_valid, old_count_ref : boolean;
+      label
+        errorexit;
 
       { check if the resulttype from tree p is equal with def, needed
         for stringconstn and formaldef }
@@ -428,7 +430,7 @@ implementation
                    firstcallparan(p^.left,nil);
                    count_ref:=old_count_ref;
                    if codegenerror then
-                     exit;
+                     goto errorexit;
                 end;
               firstpass(p^.right);
 
@@ -450,7 +452,7 @@ implementation
                    firstcallparan(p^.left,pprocvardef(p^.right^.resulttype)^.para1);
                    count_ref:=old_count_ref;
                    if codegenerror then
-                     exit;
+                     goto errorexit;
                 end;
               p^.resulttype:=pprocvardef(p^.right^.resulttype)^.retdef;
               { this was missing, leads to a bug below if
@@ -471,7 +473,7 @@ implementation
                    count_ref:=old_count_ref;
                    must_be_valid:=store_valid;
                    if codegenerror then
-                     exit;
+                     goto errorexit;
                 end;
 
               aktcallprocsym:=pprocsym(p^.symtableprocentry);
@@ -547,7 +549,7 @@ implementation
                     begin
                        CGMessage(parser_e_wrong_parameter_size);
                        aktcallprocsym^.write_parameter_lists;
-                       exit;
+                       goto errorexit;
                     end;
 
                 { now we can compare parameter after parameter }
@@ -659,7 +661,7 @@ implementation
                        begin
                           CGMessage1(parser_e_wrong_parameter_type,tostr(l));
                           aktcallprocsym^.write_parameter_lists;
-                          exit;
+                          goto errorexit;
                        end
                       else
                        begin
@@ -670,7 +672,7 @@ implementation
                          p^.is_first:=false;
                          p^.disposetyp:=dt_nothing;
                          firstpass(p);
-                         exit;
+                         goto errorexit;
                        end;
                      end;
 
@@ -858,7 +860,7 @@ implementation
                      begin
                         CGMessage(cg_e_cant_choose_overload_function);
                         aktcallprocsym^.write_parameter_lists;
-                        exit;
+                        goto errorexit;
                      end;
 {$ifdef TEST_PROCSYMS}
                    if (procs=nil) and assigned(nextprocsym) then
@@ -925,13 +927,7 @@ implementation
                    putnode(p);
                    firstpass(pt);
                    p:=pt;
-
-                   must_be_valid:=store_valid;
-                   if codegenerror then
-                     exit;
-
-                   dispose(procs);
-                   exit;
+                   goto errorexit;
                 end
               else
                 { no intern procedure => we do a call }
@@ -1075,10 +1071,7 @@ implementation
            end;
 
          if inlined then
-           begin
-              p^.right:=inlinecode;
-              p^.procdefinition^.options:=p^.procdefinition^.options or  poinline;
-           end;
+           p^.right:=inlinecode;
          { determine the registers of the procedure variable }
          { is this OK for inlined procs also ?? (PM)         }
          if assigned(p^.right) then
@@ -1098,8 +1091,12 @@ implementation
               p^.registersmmx:=max(p^.left^.registersmmx,p^.registersmmx);
 {$endif SUPPORT_MMX}
            end;
+      errorexit:
+         { Reset some settings back }
          if assigned(procs) then
            dispose(procs);
+         if inlined then
+           p^.procdefinition^.options:=p^.procdefinition^.options or poinline;
          aktcallprocsym:=oldcallprocsym;
          must_be_valid:=store_valid;
       end;
@@ -1120,7 +1117,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.29  1999-03-24 23:17:34  peter
+  Revision 1.30  1999-03-31 13:55:27  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.29  1999/03/24 23:17:34  peter
     * fixed bugs 212,222,225,227,229,231,233
 
   Revision 1.28  1999/03/23 14:43:03  peter

+ 12 - 10
compiler/tree.pas

@@ -215,7 +215,7 @@ unit tree;
              assignn : (assigntyp : tassigntyp;concat_string : boolean);
              loadn : (symtableentry : psym;symtable : psymtable;
                       is_absolute,is_first : boolean);
-             calln : (symtableprocentry : psym;
+             calln : (symtableprocentry : pprocsym;
                       symtableproc : psymtable;procdefinition : pprocdef;
                       methodpointer : ptree;
                       no_check,unit_specific,
@@ -230,8 +230,7 @@ unit tree;
              typeconvn : (convtyp : tconverttype;explizit : boolean);
              typen : (typenodetype : pdef);
              inlinen : (inlinenumber : byte;inlineconst:boolean);
-             procinlinen : (inlineprocdef : pprocdef;
-                            retoffset,para_offset,para_size : longint);
+             procinlinen : (inlinetree:ptree;inlineprocsym:pprocsym;retoffset,para_offset,para_size : longint);
              setconstn : (value_set : pconstset;lab_set:plabel);
              loopn : (t1,t2 : ptree;backward : boolean);
              asmn : (p_asm : paasmoutput;object_preserved : boolean);
@@ -1211,22 +1210,22 @@ unit tree;
 
       begin
          p:=getnode;
-         p^.disposetyp:=dt_left;
+         p^.disposetyp:=dt_nothing;
          p^.treetype:=procinlinen;
-         p^.inlineprocdef:=callp^.procdefinition;
+         p^.inlineprocsym:=callp^.symtableprocentry;
          p^.retoffset:=-4; { less dangerous as zero (PM) }
          p^.para_offset:=0;
-         p^.para_size:=p^.inlineprocdef^.para_size;
-         if ret_in_param(p^.inlineprocdef^.retdef) then
+         p^.para_size:=p^.inlineprocsym^.definition^.para_size;
+         if ret_in_param(p^.inlineprocsym^.definition^.retdef) then
            p^.para_size:=p^.para_size+target_os.size_of_pointer;
          { copy args }
-         p^.left:=getcopy(code);
+         p^.inlinetree:=code;
          p^.registers32:=code^.registers32;
          p^.registersfpu:=code^.registersfpu;
 {$ifdef SUPPORT_MMX}
          p^.registersmmx:=0;
 {$endif SUPPORT_MMX}
-         p^.resulttype:=p^.inlineprocdef^.retdef;
+         p^.resulttype:=p^.inlineprocsym^.definition^.retdef;
          genprocinlinenode:=p;
       end;
 
@@ -1714,7 +1713,10 @@ unit tree;
 end.
 {
   $Log$
-  Revision 1.70  1999-03-26 00:05:49  peter
+  Revision 1.71  1999-03-31 13:55:28  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.70  1999/03/26 00:05:49  peter
     * released valintern
     + deffile is now removed when compiling is finished
     * ^( compiles now correct