Browse Source

* fixed integer typeconversion problems

Jonas Maebe 22 years ago
parent
commit
54cacc63a5
3 changed files with 29 additions and 9 deletions
  1. 10 5
      compiler/ncgcnv.pas
  2. 14 2
      compiler/ncgutil.pas
  3. 5 2
      compiler/powerpc/cgcpu.pas

+ 10 - 5
compiler/ncgcnv.pas

@@ -93,18 +93,20 @@ interface
         if (ressize<>leftsize) and
         if (ressize<>leftsize) and
            not is_void(left.resulttype.def) then
            not is_void(left.resulttype.def) then
           begin
           begin
-            location_copy(location,left.location);
             { reuse a loc_reference when the newsize is smaller than
             { reuse a loc_reference when the newsize is smaller than
               than the original, else load it to a register }
               than the original, else load it to a register }
             if (location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) and
             if (location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) and
                (ressize<leftsize) then
                (ressize<leftsize) then
              begin
              begin
-               location.size:=newsize;
+               left.location.size:=newsize;
                if (target_info.endian = ENDIAN_BIG) then
                if (target_info.endian = ENDIAN_BIG) then
-                 inc(location.reference.offset,leftsize-ressize);
+                 inc(left.location.reference.offset,leftsize-ressize);
              end
              end
             else
             else
-             location_force_reg(exprasmlist,location,newsize,false);
+              begin
+                location_force_reg(exprasmlist,left.location,newsize,false);
+              end;
+            location_copy(location,left.location);
           end
           end
         else
         else
           begin
           begin
@@ -511,7 +513,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.40  2003-05-23 14:27:35  peter
+  Revision 1.41  2003-05-24 11:59:42  jonas
+    * fixed integer typeconversion problems
+
+  Revision 1.40  2003/05/23 14:27:35  peter
     * remove some unit dependencies
     * remove some unit dependencies
     * current_procinfo changes to store more info
     * current_procinfo changes to store more info
 
 

+ 14 - 2
compiler/ncgutil.pas

@@ -452,7 +452,16 @@ implementation
                  if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
                  if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
                   begin
                   begin
                     if (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then
                     if (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then
-                     l.register.number:=(l.register.number and not $ff) or cgsize2subreg(dst_size);
+                     begin
+{$ifndef i386}
+                       hregisterhi := l.register;
+{$endif not i386}
+                       l.register.number:=(l.register.number and not $ff) or cgsize2subreg(dst_size);
+{$ifndef i386}
+                       { necessary for all processors that do not have subregisters (JM) }
+                       cg.a_load_reg_reg(list,l.size,dst_size,hregisterhi,l.register);
+{$endif not i386}
+                     end;
                     { for big endian systems, the reference's offset must }
                     { for big endian systems, the reference's offset must }
                     { be increased in this case, since they have the      }
                     { be increased in this case, since they have the      }
                     { MSB first in memory and e.g. byte(word_var) should  }
                     { MSB first in memory and e.g. byte(word_var) should  }
@@ -1827,7 +1836,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.105  2003-05-23 14:27:35  peter
+  Revision 1.106  2003-05-24 11:59:42  jonas
+    * fixed integer typeconversion problems
+
+  Revision 1.105  2003/05/23 14:27:35  peter
     * remove some unit dependencies
     * remove some unit dependencies
     * current_procinfo changes to store more info
     * current_procinfo changes to store more info
 
 

+ 5 - 2
compiler/powerpc/cgcpu.pas

@@ -422,7 +422,7 @@ const
              (tosize <> fromsize) and
              (tosize <> fromsize) and
              not(fromsize in [OS_32,OS_S32])) then
              not(fromsize in [OS_32,OS_S32])) then
            begin
            begin
-             case fromsize of
+             case tosize of
                OS_8:
                OS_8:
                  list.concat(taicpu.op_reg_reg_const_const_const(A_RLWINM,
                  list.concat(taicpu.op_reg_reg_const_const_const(A_RLWINM,
                    reg2,reg1,0,31-8+1,31));
                    reg2,reg1,0,31-8+1,31));
@@ -2442,7 +2442,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.95  2003-05-23 18:51:26  jonas
+  Revision 1.96  2003-05-24 11:59:42  jonas
+    * fixed integer typeconversion problems
+
+  Revision 1.95  2003/05/23 18:51:26  jonas
     * fixed support for nested procedures and more parameters than those
     * fixed support for nested procedures and more parameters than those
       which fit in registers (untested/probably not working: calling a
       which fit in registers (untested/probably not working: calling a
       nested procedure from a deeper nested procedure)
       nested procedure from a deeper nested procedure)