浏览代码

* fixed another couple of arm bugs

florian 21 年之前
父节点
当前提交
de4fa4e7e7
共有 7 个文件被更改,包括 159 次插入45 次删除
  1. 31 13
      compiler/arm/cgcpu.pas
  2. 7 6
      compiler/arm/narmmat.pas
  3. 94 12
      compiler/arm/rgcpu.pas
  4. 9 6
      compiler/cmsgs.pas
  5. 6 3
      compiler/ncgset.pas
  6. 6 2
      compiler/systems.pas
  7. 6 3
      compiler/systems/i_linux.pas

+ 31 - 13
compiler/arm/cgcpu.pas

@@ -108,7 +108,7 @@ unit cgcpu;
 
 
     const
     const
       OpCmp2AsmCond : Array[topcmp] of TAsmCond = (C_NONE,C_EQ,C_GT,
       OpCmp2AsmCond : Array[topcmp] of TAsmCond = (C_NONE,C_EQ,C_GT,
-                           C_LT,C_GE,C_LE,C_NE,C_LE,C_LT,C_GE,C_GT);
+                           C_LT,C_GE,C_LE,C_NE,C_LS,C_CC,C_CS,C_HI);
 
 
     function is_shifter_const(d : dword;var imm_shift : byte) : boolean;
     function is_shifter_const(d : dword;var imm_shift : byte) : boolean;
 
 
@@ -321,28 +321,43 @@ unit cgcpu;
                 begin
                 begin
                   if a>32 then
                   if a>32 then
                     internalerror(200308291);
                     internalerror(200308291);
-                  shifterop_reset(so);
-                  so.shiftmode:=SM_LSL;
-                  so.shiftimm:=a;
-                  list.concat(taicpu.op_reg_reg_shifterop(A_MOV,dst,src,so));
+                  if a<>0 then
+                    begin
+                      shifterop_reset(so);
+                      so.shiftmode:=SM_LSL;
+                      so.shiftimm:=a;
+                      list.concat(taicpu.op_reg_reg_shifterop(A_MOV,dst,src,so));
+                    end
+                  else
+                   list.concat(taicpu.op_reg_reg(A_MOV,dst,src));
                 end;
                 end;
               OP_SHR:
               OP_SHR:
                 begin
                 begin
                   if a>32 then
                   if a>32 then
                     internalerror(200308292);
                     internalerror(200308292);
                   shifterop_reset(so);
                   shifterop_reset(so);
-                  so.shiftmode:=SM_LSR;
-                  so.shiftimm:=a;
-                  list.concat(taicpu.op_reg_reg_shifterop(A_MOV,dst,src,so));
+                  if a<>0 then
+                    begin
+                      so.shiftmode:=SM_LSR;
+                      so.shiftimm:=a;
+                      list.concat(taicpu.op_reg_reg_shifterop(A_MOV,dst,src,so));
+                    end
+                  else
+                   list.concat(taicpu.op_reg_reg(A_MOV,dst,src));
                 end;
                 end;
               OP_SAR:
               OP_SAR:
                 begin
                 begin
                   if a>32 then
                   if a>32 then
                     internalerror(200308291);
                     internalerror(200308291);
-                  shifterop_reset(so);
-                  so.shiftmode:=SM_ASR;
-                  so.shiftimm:=a;
-                  list.concat(taicpu.op_reg_reg_shifterop(A_MOV,dst,src,so));
+                  if a<>0 then
+                    begin
+                      shifterop_reset(so);
+                      so.shiftmode:=SM_ASR;
+                      so.shiftimm:=a;
+                      list.concat(taicpu.op_reg_reg_shifterop(A_MOV,dst,src,so));
+                    end
+                  else
+                   list.concat(taicpu.op_reg_reg(A_MOV,dst,src));
                 end;
                 end;
               else
               else
                 list.concat(taicpu.op_reg_reg_const(op_reg_reg_opcg2asmop[op],dst,src,a));
                 list.concat(taicpu.op_reg_reg_const(op_reg_reg_opcg2asmop[op],dst,src,a));
@@ -1253,7 +1268,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.41  2004-01-27 15:04:06  florian
+  Revision 1.42  2004-01-28 15:36:47  florian
+    * fixed another couple of arm bugs
+
+  Revision 1.41  2004/01/27 15:04:06  florian
     * fixed code generation for math inl. nodes
     * fixed code generation for math inl. nodes
     * more code generator improvements
     * more code generator improvements
 
 

+ 7 - 6
compiler/arm/narmmat.pas

@@ -80,12 +80,10 @@ implementation
                   location_copy(location,left.location);
                   location_copy(location,left.location);
                   inverse_flags(location.resflags);
                   inverse_flags(location.resflags);
                 end;
                 end;
-              LOC_REGISTER, LOC_CREGISTER, LOC_REFERENCE, LOC_CREFERENCE :
+              LOC_REGISTER,LOC_CREGISTER,LOC_REFERENCE,LOC_CREFERENCE :
                 begin
                 begin
                   location_force_reg(exprasmlist,left.location,def_cgsize(left.resulttype.def),true);
                   location_force_reg(exprasmlist,left.location,def_cgsize(left.resulttype.def),true);
-                  ins:=taicpu.op_reg_reg(A_MVN,left.location.register,left.location.register);
-                  ins.oppostfix:=PF_S;
-                  exprasmlist.concat(ins);
+                  exprasmlist.concat(taicpu.op_reg_const(A_CMP,left.location.register,0));
                   location_release(exprasmlist,left.location);
                   location_release(exprasmlist,left.location);
                   location_reset(location,LOC_FLAGS,OS_NO);
                   location_reset(location,LOC_FLAGS,OS_NO);
                   location.resflags:=F_EQ;
                   location.resflags:=F_EQ;
@@ -102,9 +100,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2003-11-02 14:30:03  florian
+  Revision 1.5  2004-01-28 15:36:47  florian
+    * fixed another couple of arm bugs
+
+  Revision 1.4  2003/11/02 14:30:03  florian
     * fixed ARM for new reg. allocation scheme
     * fixed ARM for new reg. allocation scheme
 
 
   Revision 1.3  2003/08/27 00:27:56  florian
   Revision 1.3  2003/08/27 00:27:56  florian
     + same procedure as very day: today's work on arm
     + same procedure as very day: today's work on arm
-}
+}

+ 94 - 12
compiler/arm/rgcpu.pas

@@ -49,6 +49,7 @@ unit rgcpu;
 
 
     uses
     uses
       cgobj, verbose, cutils,
       cgobj, verbose, cutils,
+      procinfo,
       aasmcpu;
       aasmcpu;
 
 
 
 
@@ -66,16 +67,58 @@ unit rgcpu;
       const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);
       const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);
       var
       var
         helpins: tai;
         helpins: tai;
-        ref : treference;
+        tmpref,ref : treference;
+        helplist : taasmoutput;
+        l : tasmlabel;
+        tmpreg : tregister;
       begin
       begin
         ref:=spilltemplist[regs[regidx].orgreg];
         ref:=spilltemplist[regs[regidx].orgreg];
-        helpins:=taicpu.op_reg_ref(A_LDR,regs[regidx].tempreg,ref);
-        if pos=nil then
-          list.insertafter(helpins,list.first)
+        if abs(ref.offset)>4095 then
+          begin
+            helplist:=taasmoutput.create;
+            reference_reset(tmpref);
+            { create consts entry }
+            objectlibrary.getlabel(l);
+            cg.a_label(current_procinfo.aktlocaldata,l);
+            tmpref.symboldata:=current_procinfo.aktlocaldata.last;
+
+            current_procinfo.aktlocaldata.concat(tai_const.Create_32bit(ref.offset));
+
+            { load consts entry }
+            getregisterinline(helplist,nil,defaultsub,tmpreg);
+            tmpref.symbol:=l;
+            tmpref.base:=NR_R15;
+            helplist.concat(taicpu.op_reg_ref(A_LDR,tmpreg,tmpref));
+
+            if ref.index<>NR_NO then
+              internalerror(200401263);
+            ref.index:=tmpreg;
+            ref.offset:=0;
+
+            helpins:=taicpu.op_reg_ref(A_LDR,regs[regidx].tempreg,ref);
+            helplist.concat(helpins);
+            if pos=nil then
+              list.insertlistafter(list.first,helplist)
+            else
+              list.insertlistafter(pos.next,helplist);
+
+            ungetregisterinline(helplist,tai(helplist.last),regs[regidx].tempreg);
+
+            ungetregisterinline(list,instr,regs[regidx].tempreg);
+            forward_allocation(tai(helpins.next),instr);
+
+            helplist.free;
+          end
         else
         else
-          list.insertafter(helpins,pos.next);
-        ungetregisterinline(list,instr,regs[regidx].tempreg);
-        forward_allocation(tai(helpins.next),instr);
+          begin
+            helpins:=taicpu.op_reg_ref(A_LDR,regs[regidx].tempreg,ref);
+            if pos=nil then
+              list.insertafter(helpins,list.first)
+            else
+              list.insertafter(helpins,pos.next);
+            ungetregisterinline(list,instr,regs[regidx].tempreg);
+            forward_allocation(tai(helpins.next),instr);
+          end;
       end;
       end;
 
 
 
 
@@ -83,12 +126,48 @@ unit rgcpu;
       const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);
       const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);
       var
       var
         helpins: tai;
         helpins: tai;
-        ref : treference;
+        ref,tmpref : treference;
+        helplist : taasmoutput;
+        l : tasmlabel;
+        tmpreg : tregister;
       begin
       begin
         ref:=spilltemplist[regs[regidx].orgreg];
         ref:=spilltemplist[regs[regidx].orgreg];
-        helpins:=taicpu.op_reg_ref(A_STR,regs[regidx].tempreg,ref);
-        list.insertafter(helpins,instr);
-        ungetregisterinline(list,helpins,regs[regidx].tempreg);
+        if abs(ref.offset)>4095 then
+          begin
+            helplist:=taasmoutput.create;
+            reference_reset(tmpref);
+            { create consts entry }
+            objectlibrary.getlabel(l);
+            cg.a_label(current_procinfo.aktlocaldata,l);
+            tmpref.symboldata:=current_procinfo.aktlocaldata.last;
+
+            current_procinfo.aktlocaldata.concat(tai_const.Create_32bit(ref.offset));
+
+            { load consts entry }
+            getregisterinline(helplist,nil,defaultsub,tmpreg);
+            tmpref.symbol:=l;
+            tmpref.base:=NR_R15;
+            helplist.concat(taicpu.op_reg_ref(A_LDR,tmpreg,tmpref));
+
+            if ref.index<>NR_NO then
+              internalerror(200401263);
+            ref.index:=tmpreg;
+            ref.offset:=0;
+
+            helplist.concat(taicpu.op_reg_ref(A_STR,regs[regidx].tempreg,ref));
+            ungetregisterinline(helplist,tai(helplist.last),regs[regidx].tempreg);
+            ungetregisterinline(helplist,tai(helplist.last),tmpreg);
+
+            list.insertlistafter(instr,helplist);
+
+            helplist.free;
+          end
+        else
+          begin
+            helpins:=taicpu.op_reg_ref(A_STR,regs[regidx].tempreg,ref);
+            list.insertafter(helpins,instr);
+            ungetregisterinline(list,helpins,regs[regidx].tempreg);
+          end;
       end;
       end;
 
 
 
 
@@ -141,7 +220,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2004-01-26 19:05:56  florian
+  Revision 1.7  2004-01-28 15:36:47  florian
+    * fixed another couple of arm bugs
+
+  Revision 1.6  2004/01/26 19:05:56  florian
     * fixed several arm issues
     * fixed several arm issues
 
 
   Revision 1.5  2003/11/02 14:30:03  florian
   Revision 1.5  2003/11/02 14:30:03  florian

+ 9 - 6
compiler/cmsgs.pas

@@ -206,7 +206,7 @@ var
 begin
 begin
   LoadExtern:=false;
   LoadExtern:=false;
   getmem(buf,bufsize);
   getmem(buf,bufsize);
-{Read the message file}
+  { Read the message file }
   assign(f,fn);
   assign(f,fn);
   {$I-}
   {$I-}
    reset(f);
    reset(f);
@@ -217,7 +217,7 @@ begin
      exit;
      exit;
    end;
    end;
   settextbuf(f,buf^,bufsize);
   settextbuf(f,buf^,bufsize);
-{ First parse the file and count bytes needed }
+  { First parse the file and count bytes needed }
   error:=false;
   error:=false;
   line:=0;
   line:=0;
   multiline:=false;
   multiline:=false;
@@ -271,7 +271,7 @@ begin
      close(f);
      close(f);
      exit;
      exit;
    end;
    end;
-{ now read the buffer in mem }
+  { now read the buffer in mem }
   msgallocsize:=msgsize;
   msgallocsize:=msgsize;
   getmem(msgtxt,msgallocsize);
   getmem(msgtxt,msgallocsize);
   ptxt:=msgtxt;
   ptxt:=msgtxt;
@@ -346,7 +346,7 @@ var
   i : longint;
   i : longint;
 begin
 begin
   { clear }
   { clear }
-  for i:=1to msgparts do
+  for i:=1 to msgparts do
    fillchar(msgidx[i]^,msgidxmax[i]*4,0);
    fillchar(msgidx[i]^,msgidxmax[i]*4,0);
 end;
 end;
 
 
@@ -368,7 +368,7 @@ begin
   while (hp<hpend) do
   while (hp<hpend) do
    begin
    begin
      hp1:=hp;
      hp1:=hp;
-     for i:=1to 5 do
+     for i:=1 to 5 do
       begin
       begin
         number[i]:=hp1^;
         number[i]:=hp1^;
         inc(hp1);
         inc(hp1);
@@ -461,7 +461,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.8  2003-05-10 23:57:23  florian
+  Revision 1.9  2004-01-28 15:36:46  florian
+    * fixed another couple of arm bugs
+
+  Revision 1.8  2003/05/10 23:57:23  florian
     * vmtpointer_offset must be adjusted in after_pass1 as well
     * vmtpointer_offset must be adjusted in after_pass1 as well
 
 
   Revision 1.7  2003/04/22 14:33:38  peter
   Revision 1.7  2003/04/22 14:33:38  peter

+ 6 - 3
compiler/ncgset.pas

@@ -448,7 +448,7 @@ implementation
 
 
                   { emit bit test operation }
                   { emit bit test operation }
                   emit_bit_test_reg_reg(exprasmlist,left.location.register,hr2,hr2);
                   emit_bit_test_reg_reg(exprasmlist,left.location.register,hr2,hr2);
-                  
+
                   { if left > 31 then hr := 0 else hr := $ffffffff }
                   { if left > 31 then hr := 0 else hr := $ffffffff }
                   cg.a_op_const_reg_reg(exprasmlist,OP_SUB,OS_INT,32,left.location.register,hr);
                   cg.a_op_const_reg_reg(exprasmlist,OP_SUB,OS_INT,32,left.location.register,hr);
                   cg.a_op_const_reg(exprasmlist,OP_SAR,OS_INT,31,hr);
                   cg.a_op_const_reg(exprasmlist,OP_SAR,OS_INT,31,hr);
@@ -475,10 +475,10 @@ implementation
                   else
                   else
                     { adjust for endianess differences }
                     { adjust for endianess differences }
                     inc(right.location.reference.offset,(tordconstnode(left).value shr 3) xor 3);
                     inc(right.location.reference.offset,(tordconstnode(left).value shr 3) xor 3);
-                  location_release(exprasmlist,right.location);
                   { allocate a register for the result }
                   { allocate a register for the result }
                   location.register := cg.getintregister(exprasmlist,location.size);
                   location.register := cg.getintregister(exprasmlist,location.size);
                   cg.a_load_ref_reg(exprasmlist,OS_8,location.size,right.location.reference, location.register);
                   cg.a_load_ref_reg(exprasmlist,OS_8,location.size,right.location.reference, location.register);
+                  location_release(exprasmlist,right.location);
                   cg.a_op_const_reg(exprasmlist,OP_SHR,location.size,tordconstnode(left).value and 7,
                   cg.a_op_const_reg(exprasmlist,OP_SHR,location.size,tordconstnode(left).value and 7,
                     location.register);
                     location.register);
                   cg.a_op_const_reg(exprasmlist,OP_AND,location.size,1,location.register);
                   cg.a_op_const_reg(exprasmlist,OP_AND,location.size,1,location.register);
@@ -1010,7 +1010,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.54  2003-12-09 19:14:50  jonas
+  Revision 1.55  2004-01-28 15:36:46  florian
+    * fixed another couple of arm bugs
+
+  Revision 1.54  2003/12/09 19:14:50  jonas
     * fixed and optimized in-node with constant smallset
     * fixed and optimized in-node with constant smallset
     * some register usage optimisations.
     * some register usage optimisations.
 
 

+ 6 - 2
compiler/systems.pas

@@ -230,7 +230,8 @@ interface
        );
        );
 
 
        psysteminfo = ^tsysteminfo;
        psysteminfo = ^tsysteminfo;
-       tsysteminfo = packed record
+       { using packed causes bus errors on processors which require alignment }
+       tsysteminfo = record
           system       : tsystem;
           system       : tsystem;
           name         : string[34];
           name         : string[34];
           shortname    : string[9];
           shortname    : string[9];
@@ -649,7 +650,10 @@ finalization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.80  2004-01-21 20:53:50  marco
+  Revision 1.81  2004-01-28 15:36:46  florian
+    * fixed another couple of arm bugs
+
+  Revision 1.80  2004/01/21 20:53:50  marco
    * Copy and pasted some structures from Net- to OpenBSD (3.4+ ELF!)
    * Copy and pasted some structures from Net- to OpenBSD (3.4+ ELF!)
 
 
   Revision 1.79  2004/01/14 23:39:05  florian
   Revision 1.79  2004/01/14 23:39:05  florian

+ 6 - 3
compiler/systems/i_linux.pas

@@ -457,8 +457,8 @@ unit i_linux;
                 constalignmax   : 4;
                 constalignmax   : 4;
                 varalignmin     : 0;
                 varalignmin     : 0;
                 varalignmax     : 4;
                 varalignmax     : 4;
-                localalignmin   : 0;
-                localalignmax   : 4;
+                localalignmin   : 4;
+                localalignmax   : 8;
                 recordalignmin  : 0;
                 recordalignmin  : 0;
                 recordalignmax  : 4;
                 recordalignmax  : 4;
                 maxCrecordalign : 4
                 maxCrecordalign : 4
@@ -514,7 +514,10 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.21  2004-01-26 19:05:56  florian
+  Revision 1.22  2004-01-28 15:36:47  florian
+    * fixed another couple of arm bugs
+
+  Revision 1.21  2004/01/26 19:05:56  florian
     * fixed several arm issues
     * fixed several arm issues
 
 
   Revision 1.20  2004/01/12 22:11:39  peter
   Revision 1.20  2004/01/12 22:11:39  peter