浏览代码

+ second_int_to_int implementation which is almost the same as the
generic implementation, but it avoids some unnecessary type conversions

Jonas Maebe 23 年之前
父节点
当前提交
04cb71275a
共有 1 个文件被更改,包括 38 次插入2 次删除
  1. 38 2
      compiler/powerpc/nppccnv.pas

+ 38 - 2
compiler/powerpc/nppccnv.pas

@@ -32,7 +32,7 @@ interface
     type
     type
        tppctypeconvnode = class(tcgtypeconvnode)
        tppctypeconvnode = class(tcgtypeconvnode)
          protected
          protected
-         { procedure second_int_to_int;override; }
+          procedure second_int_to_int;override;
          { procedure second_string_to_string;override; }
          { procedure second_string_to_string;override; }
          { procedure second_cstring_to_pchar;override; }
          { procedure second_cstring_to_pchar;override; }
          { procedure second_string_to_chararray;override; }
          { procedure second_string_to_chararray;override; }
@@ -63,6 +63,7 @@ implementation
       symconst,symdef,aasmbase,aasmtai,
       symconst,symdef,aasmbase,aasmtai,
       cgbase,pass_1,pass_2,
       cgbase,pass_1,pass_2,
       ncon,ncal,
       ncon,ncal,
+      ncgutil,
       cpubase,aasmcpu,
       cpubase,aasmcpu,
       rgobj,tgobj,cgobj,cginfo;
       rgobj,tgobj,cgobj,cginfo;
 
 
@@ -104,6 +105,37 @@ implementation
                              SecondTypeConv
                              SecondTypeConv
 *****************************************************************************}
 *****************************************************************************}
 
 
+    procedure tppctypeconvnode.second_int_to_int;
+      var
+        newsize : tcgsize;
+        size, leftsize : cardinal;
+      begin
+        newsize:=def_cgsize(resulttype.def);
+
+        { insert range check if not explicit conversion }
+        if not(nf_explizit in flags) then
+          cg.g_rangecheck(exprasmlist,left,resulttype.def);
+
+        { is the result size smaller ? }
+        size := resulttype.def.size;
+        leftsize := left.resulttype.def.size;
+        if (size < leftsize) or
+           ((left.location.loc <> LOC_REGISTER) and
+            (size > leftsize)) then
+          begin
+            { reuse the left location by default }
+            location_copy(location,left.location);
+            location_force_reg(exprasmlist,location,newsize,false);
+          end
+        else
+          begin
+            { no special loading is required, reuse current location }
+            location_copy(location,left.location);
+            location.size:=newsize;
+          end;
+      end;
+
+
     procedure tppctypeconvnode.second_int_to_real;
     procedure tppctypeconvnode.second_int_to_real;
 
 
       type
       type
@@ -384,7 +416,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.17  2002-07-27 19:55:15  jonas
+  Revision 1.18  2002-07-29 09:20:20  jonas
+    + second_int_to_int implementation which is almost the same as the
+      generic implementation, but it avoids some unnecessary type conversions
+
+  Revision 1.17  2002/07/27 19:55:15  jonas
     + generic implementation of tcg.g_flags2ref()
     + generic implementation of tcg.g_flags2ref()
     * tcg.flags2xxx() now also needs a size parameter
     * tcg.flags2xxx() now also needs a size parameter