Explorar o código

* keep track of whether we're in an inline assembly block in the llvm
assembler writer, and for now skip writing labels if we are (they
will have to emitted as part of an actual inline assembly block,
not as llvm-style labels)

git-svn-id: trunk@30672 -

Jonas Maebe %!s(int64=10) %!d(string=hai) anos
pai
achega
c8e44e4a7c
Modificáronse 1 ficheiros con 24 adicións e 11 borrados
  1. 24 11
      compiler/llvm/agllvm.pas

+ 24 - 11
compiler/llvm/agllvm.pas

@@ -45,7 +45,7 @@ interface
         procedure WriteDirectiveName(dir: TAsmDirective); virtual;
         procedure WriteDirectiveName(dir: TAsmDirective); virtual;
         procedure WriteRealConst(hp: tai_realconst; do_line: boolean);
         procedure WriteRealConst(hp: tai_realconst; do_line: boolean);
         procedure WriteOrdConst(hp: tai_const);
         procedure WriteOrdConst(hp: tai_const);
-        procedure WriteTai(const replaceforbidden: boolean; const do_line: boolean; var InlineLevel: cardinal; var hp: tai);
+        procedure WriteTai(const replaceforbidden: boolean; const do_line: boolean; var InlineLevel: cardinal; var asmblock: boolean; var hp: tai);
        public
        public
         constructor create(smart: boolean); override;
         constructor create(smart: boolean); override;
         procedure AsmLn; override;
         procedure AsmLn; override;
@@ -264,6 +264,7 @@ implementation
        hs : ansistring;
        hs : ansistring;
        hp: tai;
        hp: tai;
        tmpinline: cardinal;
        tmpinline: cardinal;
+       tmpasmblock: boolean;
      begin
      begin
        case o.typ of
        case o.typ of
          top_reg:
          top_reg:
@@ -313,10 +314,11 @@ implementation
          top_tai:
          top_tai:
            begin
            begin
              tmpinline:=1;
              tmpinline:=1;
+             tmpasmblock:=false;
              hp:=o.ai;
              hp:=o.ai;
              owner.AsmWrite(fstr);
              owner.AsmWrite(fstr);
              fstr:='';
              fstr:='';
-             owner.WriteTai(false,false,tmpinline,hp);
+             owner.WriteTai(false,false,tmpinline,tmpasmblock,hp);
              result:='';
              result:='';
            end;
            end;
 {$if defined(cpuextended) and defined(FPC_HAS_TYPE_EXTENDED)}
 {$if defined(cpuextended) and defined(FPC_HAS_TYPE_EXTENDED)}
@@ -504,6 +506,7 @@ implementation
     var
     var
       hp       : tai;
       hp       : tai;
       InlineLevel : cardinal;
       InlineLevel : cardinal;
+      asmblock: boolean;
       do_line  : boolean;
       do_line  : boolean;
       replaceforbidden: boolean;
       replaceforbidden: boolean;
     begin
     begin
@@ -512,6 +515,7 @@ implementation
       replaceforbidden:=target_asm.dollarsign<>'$';
       replaceforbidden:=target_asm.dollarsign<>'$';
 
 
       InlineLevel:=0;
       InlineLevel:=0;
+      asmblock:=false;
       { lineinfo is only needed for al_procedures (PFV) }
       { lineinfo is only needed for al_procedures (PFV) }
       do_line:=(cs_asm_source in current_settings.globalswitches) or
       do_line:=(cs_asm_source in current_settings.globalswitches) or
                ((cs_lineinfo in current_settings.moduleswitches)
                ((cs_lineinfo in current_settings.moduleswitches)
@@ -528,7 +532,7 @@ implementation
               WriteSourceLine(hp as tailineinfo);
               WriteSourceLine(hp as tailineinfo);
           end;
           end;
 
 
-         WriteTai(replaceforbidden, do_line, InlineLevel, hp);
+         WriteTai(replaceforbidden, do_line, InlineLevel, asmblock, hp);
          hp:=tai(hp.next);
          hp:=tai(hp.next);
        end;
        end;
     end;
     end;
@@ -657,7 +661,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure TLLVMAssember.WriteTai(const replaceforbidden: boolean; const do_line: boolean; var InlineLevel: cardinal; var hp: tai);
+    procedure TLLVMAssember.WriteTai(const replaceforbidden: boolean; const do_line: boolean; var InlineLevel: cardinal; var asmblock: boolean; var hp: tai);
 
 
       procedure WriteTypedConstData(hp: tai_abstracttypedconst);
       procedure WriteTypedConstData(hp: tai_abstracttypedconst);
         var
         var
@@ -726,7 +730,7 @@ implementation
                     AsmWrite(defstr);
                     AsmWrite(defstr);
                     AsmWrite(' ');
                     AsmWrite(' ');
                   end;
                   end;
-                WriteTai(replaceforbidden,do_line,InlineLevel,pval);
+                WriteTai(replaceforbidden,do_line,InlineLevel,asmblock,pval);
               end;
               end;
           end;
           end;
         end;
         end;
@@ -818,7 +822,8 @@ implementation
 
 
           ait_label :
           ait_label :
             begin
             begin
-              if (tai_label(hp).labsym.is_used) then
+              if not asmblock and
+                 (tai_label(hp).labsym.is_used) then
                 begin
                 begin
                   if (tai_label(hp).labsym.bind=AB_PRIVATE_EXTERN) then
                   if (tai_label(hp).labsym.bind=AB_PRIVATE_EXTERN) then
                     begin
                     begin
@@ -908,7 +913,7 @@ implementation
                       hp2:=tai(taillvmdecl(hp).initdata.first);
                       hp2:=tai(taillvmdecl(hp).initdata.first);
                       while assigned(hp2) do
                       while assigned(hp2) do
                         begin
                         begin
-                          WriteTai(replaceforbidden,do_line,InlineLevel,hp2);
+                          WriteTai(replaceforbidden,do_line,InlineLevel,asmblock,hp2);
                           hp2:=tai(hp2.next);
                           hp2:=tai(hp2.next);
                         end;
                         end;
                       dec(fdecllevel);
                       dec(fdecllevel);
@@ -985,10 +990,18 @@ implementation
             end;
             end;
 
 
           ait_marker :
           ait_marker :
-            if tai_marker(hp).kind=mark_NoLineInfoStart then
-              inc(InlineLevel)
-            else if tai_marker(hp).kind=mark_NoLineInfoEnd then
-              dec(InlineLevel);
+            case
+              tai_marker(hp).kind of
+                mark_NoLineInfoStart:
+                  inc(InlineLevel);
+                mark_NoLineInfoEnd:
+                  dec(InlineLevel);
+                { these cannot be nested }
+                mark_AsmBlockStart:
+                  asmblock:=true;
+                mark_AsmBlockEnd:
+                  asmblock:=false;
+              end;
 
 
           ait_directive :
           ait_directive :
             begin
             begin