Browse Source

* moved the insertion of fwaits for 8087 from the nasm asm writer to ti8086procinfo.postprocess_code

git-svn-id: trunk@30634 -
nickysn 10 years ago
parent
commit
a6e39edb8f
2 changed files with 31 additions and 8 deletions
  1. 31 1
      compiler/i8086/cpupi.pas
  2. 0 7
      compiler/x86/agx86nsm.pas

+ 31 - 1
compiler/i8086/cpupi.pas

@@ -32,10 +32,14 @@ unit cpupi;
 
     type
        ti8086procinfo = class(tcgprocinfo)
+       private
+         procedure insert_8087_fwaits(list : TAsmList);
+       public
          constructor create(aparent:tprocinfo);override;
          procedure set_first_temp_offset;override;
          function calc_stackframe_size:longint;override;
          procedure generate_parameter_info;override;
+         procedure postprocess_code;override;
        end;
 
 
@@ -44,8 +48,9 @@ unit cpupi;
     uses
       cutils,
       systems,globals,globtype,
+      aasmtai,aasmcpu,
       cgobj,tgobj,paramgr,
-      cpubase,
+      cpubase,cpuinfo,
       cgutils,
       symconst;
 
@@ -95,6 +100,31 @@ unit cpupi;
           para_stack_size := 0;
       end;
 
+
+    procedure ti8086procinfo.insert_8087_fwaits(list : TAsmList);
+      var
+        curtai: tai;
+      begin
+        curtai:=tai(list.First);
+        while assigned(curtai) do
+          begin
+            if (curtai.typ=ait_instruction)
+               and requires_fwait_on_8087(taicpu(curtai).opcode) then
+              list.InsertBefore(taicpu.op_none(A_FWAIT),curtai);
+
+            curtai:=tai(curtai.Next);
+          end;
+      end;
+
+
+    procedure ti8086procinfo.postprocess_code;
+      begin
+        { nickysn note: I don't know if the 187 requires FWAIT before
+          every instruction like the 8087, so I'm including it just in case }
+        if current_settings.cputype<=cpu_186 then
+          insert_8087_fwaits(aktproccode);
+      end;
+
 begin
    cprocinfo:=ti8086procinfo;
 end.

+ 0 - 7
compiler/x86/agx86nsm.pas

@@ -909,13 +909,6 @@ interface
                else
                 begin
                   prefix:='';
-{$ifdef i8086}
-                  { nickysn note: I don't know if the 187 requires FWAIT before
-                    every instruction like the 8087, so I'm including it just in case }
-                  if (current_settings.cputype<=cpu_186) and
-                      requires_fwait_on_8087(fixed_opcode) then
-                    prefix:='wait '+prefix;
-{$endif i8086}
 {$ifndef i8086}
                   { We need to explicitely set
                     word prefix to get selectors