瀏覽代碼

* cleaned up r10705 for ppc, improved comments

git-svn-id: trunk@10721 -
tom_at_work 17 年之前
父節點
當前提交
ee76679326
共有 2 個文件被更改,包括 18 次插入19 次删除
  1. 9 8
      compiler/powerpc/cgcpu.pas
  2. 9 11
      compiler/powerpc64/cgcpu.pas

+ 9 - 8
compiler/powerpc/cgcpu.pas

@@ -352,14 +352,15 @@ const
             fromsize := tosize;
           op := loadinstr[fromsize,ref2.index<>NR_NO,false];
           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
-            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;
+          { sign extend shortint if necessary (because there is
+	   no load instruction to sign extend an 8 bit value automatically) 
+	   and mask out extra sign bits when loading from a smaller signed
+	   to a larger unsigned type }
+          if fromsize = OS_S8 then
+	    begin
+	      a_load_reg_reg(list, OS_8, OS_S8, reg, reg);
+	      a_load_reg_reg(list, OS_S8, tosize, reg, reg);
+	    end;
        end;
 
 

+ 9 - 11
compiler/powerpc64/cgcpu.pas

@@ -734,17 +734,15 @@ begin
     op := A_LWA;
   end;
   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
-    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);
+  { sign extend shortint if necessary (because there is
+   no load instruction to sign extend an 8 bit value automatically)
+   and mask out extra sign bits when loading from a smaller 
+   signed to a larger unsigned type (where it matters) }
+  if (fromsize = OS_S8) then begin
+    a_load_reg_reg(list, OS_8, OS_S8, reg, reg);
+    a_load_reg_reg(list, OS_S8, 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;