Browse Source

no message

florian 23 years ago
parent
commit
30fae40c29
1 changed files with 117 additions and 29 deletions
  1. 117 29
      compiler/ncginl.pas

+ 117 - 29
compiler/ncginl.pas

@@ -116,7 +116,7 @@ implementation
               end;
             in_pi:
               begin
-                second_pi; 
+                second_pi;
               end;
             in_sin_extended:
               begin
@@ -210,17 +210,17 @@ implementation
        truelabel:=otlabel;
        falselabel:=oflabel;
      end;
-          
+
 
 {*****************************************************************************
                           SIZEOF / TYPEOF GENERIC HANDLING
 *****************************************************************************}
-                 
+
     { second_handle_ the sizeof and typeof routines }
     procedure tcginlinenode.second_SizeOfTypeOf;
       var
          href : treference;
-         hregister : tregister;      
+         hregister : tregister;
       begin
         location_reset(location,LOC_REGISTER,OS_ADDR);
         { for both cases load vmt }
@@ -249,9 +249,9 @@ implementation
            end;
         location.register:=hregister;
      end;
-     
-     
-     
+
+
+
 {*****************************************************************************
                           LENGTH GENERIC HANDLING
 *****************************************************************************}
@@ -292,7 +292,7 @@ implementation
     procedure tcginlinenode.second_PredSucc;
       var
          cgsize : TCGSize;
-         cgop : topcg;      
+         cgop : topcg;
       begin
         secondpass(left);
         if inlinenumber=in_pred_x then
@@ -393,9 +393,9 @@ implementation
              end;
           cg.g_overflowcheck(exprasmlist,tcallparanode(left).left);
           cg.g_rangecheck(exprasmlist,tcallparanode(left).left,tcallparanode(left).left.resulttype.def);
-        end;  
-        
-               
+        end;
+
+
 {*****************************************************************************
                          TYPEINFO GENERIC HANDLING
 *****************************************************************************}
@@ -407,8 +407,8 @@ implementation
           location.register:=rg.getaddressregister(exprasmlist);
           reference_reset_symbol(href,tstoreddef(ttypenode(tcallparanode(left).left).resulttype.def).get_rtti_label(fullrtti),0);
           cg.a_loadaddr_ref_reg(exprasmlist,href,location.register);
-        end;  
-        
+        end;
+
 
 {*****************************************************************************
                          ASSIGNED GENERIC HANDLING
@@ -425,7 +425,7 @@ implementation
           if (tcallparanode(left).left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
             begin
               { if pointer is non-nil, and is in register, this directly the value we can use }
-              cg.a_load_reg_reg(exprasmlist, OS_ADDR, tcallparanode(left).left.location.register, hreg);   
+              cg.a_load_reg_reg(exprasmlist, OS_ADDR, tcallparanode(left).left.location.register, hreg);
             end
           else
             begin
@@ -436,56 +436,142 @@ implementation
               cg.a_load_const_reg(exprasmlist, OS_INT, 0, hreg);
               cg.a_label(exprasmlist,ptrvalidlabel);
             end;
+          location.register := hreg;
+          location_reset(location,LOC_REGISTER,OS_INT);
+          WriteLn('Exiting assigned node!');
+        end;
+
+
+{*****************************************************************************
+                     INCLUDE/EXCLUDE GENERIC HANDLING
+*****************************************************************************}
+      procedure tcginlinenode.second_IncludeExclude;
+        var
+         scratch_reg : boolean;
+         hregister : tregister;
+         asmop : tasmop;
+         L : longint;
+         pushedregs : TMaybesave;
+         cgop : topcg;
+         {!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
+        begin
+          location_copy(location,left.location);
+          secondpass(tcallparanode(left).left);
+          if tcallparanode(tcallparanode(left).right).left.nodetype=ordconstn then
+            begin
+              { calculate bit position }
+              l:=1 shl (tordconstnode(tcallparanode(tcallparanode(left).right).left).value mod 32);
+
+              { determine operator }
+              if inlinenumber=in_include_x_y then
+                cgop:=OP_OR
+              else
+                begin
+                  cgop:=OP_AND;
+                  l:=not(l);
+                end;
+              if (tcallparanode(left).left.location.loc=LOC_REFERENCE) then
+                begin
+                  inc(tcallparanode(left).left.location.reference.offset,
+                    (tordconstnode(tcallparanode(tcallparanode(left).right).left).value div 32)*4);
+                  cg.a_op_const_ref(exprasmlist,cgop,OS_INT,l,tcallparanode(left).left.location.reference);
+                  location_release(exprasmlist,tcallparanode(left).left.location);
+                end
+              else
+                { LOC_CREGISTER }
+                begin
+                  cg.a_op_const_reg(exprasmlist,cgop,l,tcallparanode(left).left.location.register);
+                end;
+            end
+          else
+            begin
+              { generate code for the element to set }
+              maybe_save(exprasmlist,tcallparanode(tcallparanode(left).right).left.registers32,
+                        tcallparanode(left).left.location,pushedregs);
+              secondpass(tcallparanode(tcallparanode(left).right).left);
+              maybe_restore(exprasmlist,tcallparanode(left).left.location,pushedregs);
+              { determine asm operator }
+              if inlinenumber=in_include_x_y then
+                 asmop:=A_BTS
+              else
+                 asmop:=A_BTR;
+
+              if tcallparanode(tcallparanode(left).right).left.location.loc in [LOC_CREGISTER,LOC_REGISTER] then
+                { we don't need a mod 32 because this is done automatically  }
+                { by the bts instruction. For proper checking we would       }
+
+                { note: bts doesn't do any mod'ing, that's why we can also use }
+                { it for normalsets! (JM)                                      }
+
+                { need a cmp and jmp, but this should be done by the         }
+                { type cast code which does range checking if necessary (FK) }
+                begin
+                  scratch_reg := FALSE;
+                  WriteLn('HELLO!');
+                  hregister := rg.makeregsize(tcallparanode(tcallparanode(left).right).left.location.register,OS_INT);
+                end
+              else
+                begin
+                  scratch_reg := TRUE;
+                  hregister:=cg.get_scratch_reg_int(exprasmlist);
+                end;
+              cg.a_load_loc_reg(exprasmlist,tcallparanode(tcallparanode(left).right).left.location,hregister);
+              if (tcallparanode(left).left.location.loc=LOC_REFERENCE) then
+                emit_reg_ref(asmop,S_L,hregister,tcallparanode(left).left.location.reference)
+              else
+                emit_reg_reg(asmop,S_L,hregister,tcallparanode(left).left.location.register);
+              if scratch_reg then
+                cg.free_scratch_reg(exprasmlist,hregister);
+            end;
           location_reset(location,LOC_REGISTER,def_cgsize(resulttype.def));
           location.register := rg.makeregsize(hreg,def_cgsize(resulttype.def));
         end;
-*)        
         
         
 {*****************************************************************************
                             FLOAT GENERIC HANDLING
 *****************************************************************************}
 
-{ 
-  These routines all call internal RTL routines, so if they are 
+{
+  These routines all call internal RTL routines, so if they are
   called here, they give an internal error
-}  
+}
     procedure tcginlinenode.second_pi;
       begin
         internalerror(20020718);
       end;
-      
+
     procedure tcginlinenode.second_arctan_real;
       begin
         internalerror(20020718);
       end;
-      
+
     procedure tcginlinenode.second_abs_real;
       begin
         internalerror(20020718);
       end;
-      
-      
+
+
     procedure tcginlinenode.second_sqr_real;
       begin
         internalerror(20020718);
       end;
-      
+
     procedure tcginlinenode.second_sqrt_real;
       begin
         internalerror(20020718);
       end;
-      
+
     procedure tcginlinenode.second_ln_real;
       begin
         internalerror(20020718);
       end;
-      
+
     procedure tcginlinenode.second_cos_real;
       begin
         internalerror(20020718);
       end;
-      
+
     procedure tcginlinenode.second_sin_real;
       begin
         internalerror(20020718);
@@ -497,10 +583,12 @@ end.
 
 {
   $Log$
-  Revision 1.2  2002-07-25 17:55:41  carl
+  Revision 1.3  2002-07-25 22:58:30  florian
+  no message
+
+  Revision 1.2  2002/07/25 17:55:41  carl
     + First working revision
 
   Revision 1.1  2002/07/24 04:07:49  carl
    + first revision (incomplete)
-
-}
+}