Explorar el Código

* some assembler writer bugs fixed

florian hace 23 años
padre
commit
b841ba8b16
Se han modificado 2 ficheros con 33 adiciones y 14 borrados
  1. 20 10
      compiler/powerpc/agppcgas.pas
  2. 13 4
      compiler/powerpc/cgcpu.pas

+ 20 - 10
compiler/powerpc/agppcgas.pas

@@ -126,7 +126,7 @@ unit agppcgas;
         'xer','lr','ctr','fpscr'
       );
 
-     symaddr2str: array[trefsymaddr] of string[4] = ('','ha16','lo16');
+     symaddr2str: array[trefsymaddr] of string[2] = ('','ha','l');
 
     function getreferencestring(var ref : treference) : string;
     var
@@ -147,7 +147,7 @@ unit agppcgas;
           if not assigned(symbol) then
              s:=''
            else
-             s:=symaddr2str[symaddr]+'('+symbol.name + ')';
+             s:=symbol.name+symaddr2str[symaddr];
           if offset<0 then
            s:=s+tostr(offset)
           else
@@ -159,8 +159,12 @@ unit agppcgas;
                s:=s+tostr(offset);
             end;
            if (index=R_NO) and (base<>R_NO) then
-             s:=s+'('+reg2str[base]+')'
-           else if (index<>R_NO) and (base<>R_NO) and (offset = 0) then
+             begin
+                if offset=0 then
+                  s:=s+'0';
+                s:=s+'('+reg2str[base]+')'
+             end
+           else if (index<>R_NO) and (base<>R_NO) and (offset=0) then
              s:=s+reg2str[base]+','+reg2str[index]
            else if ((index<>R_NO) or (base<>R_NO)) then
 {$ifndef testing}
@@ -306,11 +310,14 @@ unit agppcgas;
       if is_calljmp(op) then
         begin
           { direct BO/BI in op[0] and op[1] not supported, put them in condition! }
-          if op <> A_B then
-            s:=cond2str(op,taicpu(hp).condition)+','
-          else
-            s:=#9'b'#9;
-          s := s+getopstr_jmp(taicpu(hp).oper[0]);
+          case op of
+             A_B,A_BA,A_BL,A_BLA:
+               s:=#9+op2str[op]+#9
+             else
+               s:=cond2str(op,taicpu(hp).condition)+',';
+          end;
+
+          s:=s+getopstr_jmp(taicpu(hp).oper[0]);
         end
       else
         { process operands }
@@ -339,7 +346,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.10  2002-08-12 15:08:44  carl
+  Revision 1.11  2002-08-17 18:23:53  florian
+    * some assembler writer bugs fixed
+
+  Revision 1.10  2002/08/12 15:08:44  carl
     + stab register indexes for powerpc (moved from gdb to cpubase)
     + tprocessor enumeration moved to cpuinfo
     + linker in target_info is now a class

+ 13 - 4
compiler/powerpc/cgcpu.pas

@@ -1,5 +1,5 @@
 {
-    $Id$
+    $id: cgcpu.pas,v 1.43 2002/08/17 09:23:49 florian Exp $
     Copyright (c) 1998-2002 by Florian Klaempfl
 
     This unit implements the code generator for the PowerPC
@@ -277,7 +277,7 @@ const
               list.concat(taicpu.op_reg_const(A_LI,reg,smallint(a and $ffff)));
               if ((a shr 16) <> 0) or
                  (smallint(a and $ffff) < 0) then
-                list.concat(taicpu.op_reg_const(A_ADDIS,reg,
+                list.concat(taicpu.op_reg_reg_const(A_ADDIS,reg,reg,
                   smallint((a shr 16)+ord(smallint(a and $ffff) < 0))))
             end
           else
@@ -855,6 +855,7 @@ const
          href : treference;
          usesfpr,usesgpr,gotgot : boolean;
          parastart : aword;
+         offset : aword;
 
       begin
         { we do our own localsize calculation }
@@ -936,9 +937,12 @@ const
              else
                list.concat(taicpu.op_sym_ofs(A_BL,objectlibrary.newasmsymbol('_savefpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14)),0));
              }
-             for regcounter:=firstreggpr to R_F31 do
+             for regcounter:=firstregfpu to R_F31 do
                if regcounter in rg.usedbyproc then
                  begin
+                    { reference_reset_base(href,R_1,-localsize);
+                    list.concat(taicpu.op_reg_ref(A_STWU,R_1,href));
+                    }
                  end;
 
              { compute end of gpr save area }
@@ -1041,6 +1045,7 @@ const
           begin
              { address of fpr save area to r11 }
              list.concat(taicpu.op_reg_reg_const(A_ADDI,R_11,R_11,(ord(R_F31)-ord(firstregfpu)+1)*8));
+             {
              if (procinfo.flags and pi_do_call)<>0 then
                list.concat(taicpu.op_sym_ofs(A_BL,objectlibrary.newasmsymbol('_restfpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14)+
                  '_x'),0))
@@ -1049,6 +1054,7 @@ const
                list.concat(taicpu.op_sym_ofs(A_BL,objectlibrary.newasmsymbol('_restfpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14)+
                  '_l'),0));
              genret:=false;
+             }
           end;
         { if we didn't generate the return code, we've to do it now }
         if genret then
@@ -1668,7 +1674,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.43  2002-08-17 09:23:49  florian
+  Revision 1.44  2002-08-17 18:23:53  florian
+    * some assembler writer bugs fixed
+
+  Revision 1.43  2002/08/17 09:23:49  florian
     * first part of procinfo rewrite
 
   Revision 1.42  2002/08/16 14:24:59  carl