Переглянути джерело

* fixed a_load_ref_reg for OS_S8->OS_16 for ppc32, ppc64 and sparc
(and on ppc64 also for OS_S8->OS_32 and OS_S16->OS_32)
* adapted tcnvint6 to check for ppc64 OS_S16->OS_32 conversion
(the old comparison was performed using a 32 bit compare and
therefore did not notice the wrong result)

git-svn-id: trunk@10705 -

Jonas Maebe 17 роки тому
батько
коміт
263984f874

+ 6 - 2
compiler/powerpc/cgcpu.pas

@@ -354,8 +354,12 @@ const
           a_load_store(list,op,reg,ref2);
           { sign extend shortint if necessary, since there is no }
           { load instruction that does that automatically (JM)   }
-          if fromsize = OS_S8 then
-            list.concat(taicpu.op_reg_reg(A_EXTSB,reg,reg));
+          if (fromsize = OS_S8) then
+            begin
+              list.concat(taicpu.op_reg_reg(A_EXTSB,reg,reg));
+              if (tosize = OS_16) then
+                a_load_reg_reg(list,fromsize,tosize,reg,reg);
+            end;
        end;
 
 

+ 9 - 2
compiler/powerpc64/cgcpu.pas

@@ -736,8 +736,15 @@ begin
   a_load_store(list, op, reg, ref2);
   { sign extend shortint if necessary, since there is no
    load instruction that does that automatically (JM) }
-  if fromsize = OS_S8 then
-    list.concat(taicpu.op_reg_reg(A_EXTSB, reg, reg));
+  if (fromsize = OS_S8) then
+    begin
+      list.concat(taicpu.op_reg_reg(A_EXTSB, reg, reg));
+      if (tosize in [OS_16,OS_32]) then
+        a_load_reg_reg(list,fromsize,tosize,reg,reg);
+    end
+  else if (fromsize = OS_S16) and
+          (tosize = OS_32) then
+    a_load_reg_reg(list,fromsize,tosize,reg,reg);
 end;
 
 procedure tcgppc.a_load_reg_reg(list: TAsmList; fromsize, tosize: tcgsize;

+ 3 - 0
compiler/sparc/cgcpu.pas

@@ -540,6 +540,9 @@ implementation
                  InternalError(2002122101);
              end;
              handle_load_store(list,false,op,reg,ref);
+             if (fromsize=OS_S8) and
+                (tosize=OS_16) then
+               a_load_reg_reg(list,fromsize,tosize,reg,reg);
            end;
       end;
 

+ 9 - 5
tests/test/cg/tcnvint6.pp

@@ -11,6 +11,7 @@ var
   c: cardinal;
   shi: shortint;
   si: smallint;
+  i64: int64;
 begin
   b:=$ff;
   Inc(b,$ff);
@@ -68,20 +69,23 @@ begin
     error(31);
   if cardinal(shi)<>$ffffffff then
     error(32);
+  i64:=cardinal(shi);
+  if i64<>$ffffffff then
+    error(33);
 {$ifdef FPC}
   if qword(shi)<>$ffffffffffffffff then
-    error(33);
+    error(34);
 {$endif FPC}
 
   si:=-1;
   if word(si)<>$ffff then
-    error(34);
-  if cardinal(si)<>$ffffffff then
     error(35);
+  if cardinal(si)<>$ffffffff then
+    error(36);
 {$ifdef FPC}
   if qword(si)<>$ffffffffffffffff then
-    error(36);
+    error(37);
 {$endif FPC}
 
   writeln('Test OK.');
-end.
+end.