Browse Source

* optimized ofs(proc) on i8086, so it only loads the offset in all memory models

git-svn-id: trunk@38682 -
nickysn 7 years ago
parent
commit
58ead31f49
2 changed files with 21 additions and 4 deletions
  1. 17 3
      compiler/i8086/n8086cnv.pas
  2. 4 1
      compiler/nmem.pas

+ 17 - 3
compiler/i8086/n8086cnv.pas

@@ -69,14 +69,28 @@ implementation
           not is_proc_far(tabstractprocdef(left.resultdef)) then
           not is_proc_far(tabstractprocdef(left.resultdef)) then
           CGMessage1(type_e_procedure_must_be_far,left.resultdef.GetTypeName);
           CGMessage1(type_e_procedure_must_be_far,left.resultdef.GetTypeName);
         Result:=inherited typecheck_proc_to_procvar;
         Result:=inherited typecheck_proc_to_procvar;
+        if tcnf_proc_2_procvar_get_offset_only in convnodeflags then
+          begin
+            if resultdef.typ<>procvardef then
+              internalerror(2018040401);
+            exclude(tprocvardef(resultdef).procoptions,po_far);
+          end;
       end;
       end;
 
 
 
 
     procedure t8086typeconvnode.second_proc_to_procvar;
     procedure t8086typeconvnode.second_proc_to_procvar;
       begin
       begin
-        if is_proc_far(tabstractprocdef(resultdef))<>
-           (current_settings.x86memorymodel in x86_far_code_models) then
-          internalerror(2014041302);
+        if tcnf_proc_2_procvar_get_offset_only in convnodeflags then
+          begin
+            if is_proc_far(tabstractprocdef(resultdef)) then
+              internalerror(2018040402);
+          end
+        else
+          begin
+            if is_proc_far(tabstractprocdef(resultdef))<>
+               (current_settings.x86memorymodel in x86_far_code_models) then
+              internalerror(2014041302);
+          end;
         if is_proc_far(tabstractprocdef(left.resultdef))<>
         if is_proc_far(tabstractprocdef(left.resultdef))<>
            (current_settings.x86memorymodel in x86_far_code_models) then
            (current_settings.x86memorymodel in x86_far_code_models) then
           internalerror(2014041303);
           internalerror(2014041303);

+ 4 - 1
compiler/nmem.pas

@@ -579,7 +579,10 @@ implementation
               begin
               begin
                 if tabstractprocdef(left.resultdef).is_addressonly then
                 if tabstractprocdef(left.resultdef).is_addressonly then
                   begin
                   begin
-                    result:=ctypeconvnode.create_internal(left,tabstractprocdef(left.resultdef).address_type);
+                    if anf_ofs in addrnodeflags then
+                      result:=ctypeconvnode.create_internal(left,tabstractprocdef(left.resultdef).ofs_address_type)
+                    else
+                      result:=ctypeconvnode.create_internal(left,tabstractprocdef(left.resultdef).address_type);
                     include(result.flags,nf_load_procvar);
                     include(result.flags,nf_load_procvar);
                     left:=nil;
                     left:=nil;
                   end
                   end