Browse Source

- removed unnecessary i386 pass_2 of as- and isnode and added dummy generic ones

Jonas Maebe 24 years ago
parent
commit
f33d23922a
2 changed files with 33 additions and 134 deletions
  1. 12 133
      compiler/i386/n386cnv.pas
  2. 21 1
      compiler/ncnv.pas

+ 12 - 133
compiler/i386/n386cnv.pas

@@ -55,22 +55,14 @@ interface
           procedure second_call_helper(c : tconverttype);
           procedure second_call_helper(c : tconverttype);
        end;
        end;
 
 
-       ti386asnode = class(tasnode)
-          procedure pass_2;override;
-       end;
-
-       ti386isnode = class(tisnode)
-          procedure pass_2;override;
-       end;
-
 implementation
 implementation
 
 
    uses
    uses
-      verbose,globals,systems,
+      verbose,systems,
       symconst,symdef,aasm,
       symconst,symdef,aasm,
       cgbase,temp_gen,pass_2,
       cgbase,temp_gen,pass_2,
       ncon,ncal,
       ncon,ncal,
-      cpubase,cpuasm,
+      cpubase,
       cga,tgcpu,n386util;
       cga,tgcpu,n386util;
 
 
 
 
@@ -84,7 +76,6 @@ implementation
         opsize    : topsize;
         opsize    : topsize;
         hregister,
         hregister,
         hregister2 : tregister;
         hregister2 : tregister;
-        l : tasmlabel;
 
 
       begin
       begin
         { insert range check if not explicit conversion }
         { insert range check if not explicit conversion }
@@ -184,18 +175,14 @@ implementation
                 end
                 end
               else
               else
                 begin
                 begin
-                  emit_reg_reg(A_XOR,S_L,
-                    hregister2,hregister2);
                   if (torddef(resulttype.def).typ=s64bit) and
                   if (torddef(resulttype.def).typ=s64bit) and
-                    is_signed(left.resulttype.def) then
+                     is_signed(left.resulttype.def) then
                     begin
                     begin
-                       getlabel(l);
-                       emit_const_reg(A_TEST,S_L,longint($80000000),makereg32(hregister));
-                       emitjmp(C_Z,l);
-                       emit_reg(A_NOT,S_L,
-                         hregister2);
-                       emitlab(l);
-                    end;
+                      emit_reg_reg(A_MOV,S_L,location.register,hregister2);
+                      emit_const_reg(A_SAR,S_L,31,hregister2);
+                    end
+                   else
+                     emit_reg_reg(A_XOR,S_L,hregister2,hregister2);
                 end;
                 end;
           end;
           end;
       end;
       end;
@@ -484,123 +471,15 @@ implementation
       end;
       end;
 
 
 
 
-{*****************************************************************************
-                             TI386ISNODE
-*****************************************************************************}
-
-    procedure ti386isnode.pass_2;
-      var
-         pushed : tpushed;
-
-      begin
-         { save all used registers }
-         pushusedregisters(pushed,$ff);
-         secondpass(left);
-         clear_location(location);
-         location.loc:=LOC_FLAGS;
-         location.resflags:=F_NE;
-
-         { push instance to check: }
-         case left.location.loc of
-            LOC_REGISTER,LOC_CREGISTER:
-              begin
-                 emit_reg(A_PUSH,
-                   S_L,left.location.register);
-                 ungetregister32(left.location.register);
-              end;
-            LOC_MEM,LOC_REFERENCE:
-              begin
-                 emit_ref(A_PUSH,
-                   S_L,newreference(left.location.reference));
-                 del_reference(left.location.reference);
-              end;
-            else internalerror(100);
-         end;
-
-         { generate type checking }
-         secondpass(right);
-         case right.location.loc of
-            LOC_REGISTER,LOC_CREGISTER:
-              begin
-                 emit_reg(A_PUSH,
-                   S_L,right.location.register);
-                 ungetregister32(right.location.register);
-              end;
-            LOC_MEM,LOC_REFERENCE:
-              begin
-                 emit_ref(A_PUSH,
-                   S_L,newreference(right.location.reference));
-                 del_reference(right.location.reference);
-              end;
-            else internalerror(100);
-         end;
-         saveregvars($ff);
-         emitcall('FPC_DO_IS');
-         emit_reg_reg(A_OR,S_B,R_AL,R_AL);
-         popusedregisters(pushed);
-         maybe_loadself;
-      end;
-
-
-{*****************************************************************************
-                             TI386ASNODE
-*****************************************************************************}
-
-    procedure ti386asnode.pass_2;
-      var
-         pushed : tpushed;
-      begin
-         secondpass(left);
-         { save all used registers }
-         pushusedregisters(pushed,$ff);
-
-         { push instance to check: }
-         case left.location.loc of
-            LOC_REGISTER,LOC_CREGISTER:
-              emit_reg(A_PUSH,
-                S_L,left.location.register);
-            LOC_MEM,LOC_REFERENCE:
-              emit_ref(A_PUSH,
-                S_L,newreference(left.location.reference));
-            else internalerror(100);
-         end;
-
-         { we doesn't modifiy the left side, we check only the type }
-         set_location(location,left.location);
-
-         { generate type checking }
-         secondpass(right);
-         case right.location.loc of
-            LOC_REGISTER,LOC_CREGISTER:
-              begin
-                 emit_reg(A_PUSH,
-                   S_L,right.location.register);
-                 ungetregister32(right.location.register);
-              end;
-            LOC_MEM,LOC_REFERENCE:
-              begin
-                 emit_ref(A_PUSH,
-                   S_L,newreference(right.location.reference));
-                 del_reference(right.location.reference);
-              end;
-            else internalerror(100);
-         end;
-         saveregvars($ff);
-         emitcall('FPC_DO_AS');
-         { restore register, this restores automatically the }
-         { result                                           }
-         popusedregisters(pushed);
-         maybe_loadself;
-      end;
-
 begin
 begin
    ctypeconvnode:=ti386typeconvnode;
    ctypeconvnode:=ti386typeconvnode;
-   cisnode:=ti386isnode;
-   casnode:=ti386asnode;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.24  2001-09-29 21:32:47  jonas
+  Revision 1.25  2001-09-30 16:12:47  jonas
+    - removed unnecessary i386 pass_2 of as- and isnode and added dummy generic ones
+
+  Revision 1.24  2001/09/29 21:32:47  jonas
     * almost all second pass typeconvnode helpers are now processor independent
     * almost all second pass typeconvnode helpers are now processor independent
     * fixed converting boolean to int64/qword
     * fixed converting boolean to int64/qword
     * fixed register allocation bugs which could cause internalerror 10
     * fixed register allocation bugs which could cause internalerror 10

+ 21 - 1
compiler/ncnv.pas

@@ -105,6 +105,7 @@ interface
           constructor create(l,r : tnode);virtual;
           constructor create(l,r : tnode);virtual;
           function pass_1 : tnode;override;
           function pass_1 : tnode;override;
           function det_resulttype:tnode;override;
           function det_resulttype:tnode;override;
+          procedure pass_2;override;
        end;
        end;
        tasnodeclass = class of tasnode;
        tasnodeclass = class of tasnode;
 
 
@@ -112,6 +113,7 @@ interface
           constructor create(l,r : tnode);virtual;
           constructor create(l,r : tnode);virtual;
           function pass_1 : tnode;override;
           function pass_1 : tnode;override;
           function det_resulttype:tnode;override;
           function det_resulttype:tnode;override;
+          procedure pass_2;override;
        end;
        end;
        tisnodeclass = class of tisnode;
        tisnodeclass = class of tisnode;
 
 
@@ -1503,6 +1505,13 @@ implementation
          firstpass(result);
          firstpass(result);
       end;
       end;
 
 
+    { dummy pass_2, it will never be called, but we need one since }
+    { you can't instantiate an abstract class                      }
+    procedure tisnode.pass_2;
+
+      begin
+      end;
+
 
 
 {*****************************************************************************
 {*****************************************************************************
                                 TASNODE
                                 TASNODE
@@ -1563,6 +1572,14 @@ implementation
       end;
       end;
 
 
 
 
+    { dummy pass_2, it will never be called, but we need one since }
+    { you can't instantiate an abstract class                      }
+    procedure tasnode.pass_2;
+
+      begin
+      end;
+
+
 begin
 begin
    ctypeconvnode:=ttypeconvnode;
    ctypeconvnode:=ttypeconvnode;
    casnode:=tasnode;
    casnode:=tasnode;
@@ -1570,7 +1587,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.38  2001-09-29 21:32:46  jonas
+  Revision 1.39  2001-09-30 16:12:46  jonas
+    - removed unnecessary i386 pass_2 of as- and isnode and added dummy generic ones
+
+  Revision 1.38  2001/09/29 21:32:46  jonas
     * almost all second pass typeconvnode helpers are now processor independent
     * almost all second pass typeconvnode helpers are now processor independent
     * fixed converting boolean to int64/qword
     * fixed converting boolean to int64/qword
     * fixed register allocation bugs which could cause internalerror 10
     * fixed register allocation bugs which could cause internalerror 10