Bladeren bron

* taicpu_abstract.oper[] changed to pointers

peter 22 jaren geleden
bovenliggende
commit
96f9973b46

+ 105 - 81
compiler/aasmtai.pas

@@ -158,7 +158,7 @@ interface
          { local varsym that will be inserted in pass_2 }
          top_local  : (localsym:pointer;localsymderef:tderef;localsymofs:longint);
       end;
-
+      poper=^toper;
 
 { ait_* types which don't result in executable code or which don't influence   }
 { the way the program runs/behaves, but which may be encountered by the        }
@@ -440,8 +440,10 @@ interface
           condition : TAsmCond;
           { Number of operands to instruction }
           ops       : byte;
+          { Number of allocate oper structures }
+          opercnt   : byte;
           { Operands of instruction }
-          oper      : array[0..max_operands-1] of toper;
+          oper      : array[0..max_operands-1] of poper;
           { Actual opcode of instruction }
           opcode    : tasmop;
 {$ifdef x86}
@@ -456,6 +458,7 @@ interface
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           procedure derefimpl;override;
           procedure SetCondition(const c:TAsmCond);
+          procedure allocate_oper(opers:longint);
           procedure loadconst(opidx:longint;l:aword);
           procedure loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
           procedure loadlocal(opidx:longint;s:pointer;sofs:longint);
@@ -1511,19 +1514,24 @@ implementation
 
 
     destructor taicpu_abstract.Destroy;
-
       var
-        i : longint;
+        i : integer;
       begin
-        for i:=0 to ops-1 do
-        case oper[i].typ of
-          top_ref:
-            dispose(oper[i].ref);
+        for i:=0 to opercnt-1 do
+          begin
+            with oper[i]^ do
+              begin
+                case typ of
+                  top_ref:
+                    dispose(ref);
 {$ifdef ARM}
-          top_shifterop:
-            dispose(oper[i].shifterop);
+                  top_shifterop:
+                     dispose(shifterop);
 {$endif ARM}
-        end;
+                end;
+              end;
+            dispose(oper[i]);
+          end;
         inherited destroy;
       end;
 
@@ -1532,11 +1540,21 @@ implementation
     Loading of operands.
   ---------------------------------------------------------------------}
 
+    procedure taicpu_abstract.allocate_oper(opers:longint);
+      begin
+        while (opers>opercnt) do
+          begin
+            new(oper[opercnt]);
+            fillchar(oper[opercnt]^,sizeof(toper),0);
+            inc(opercnt);
+          end;
+      end;
+
+
     procedure taicpu_abstract.loadconst(opidx:longint;l:aword);
       begin
-        if opidx>=ops then
-         ops:=opidx+1;
-        with oper[opidx] do
+        allocate_oper(opidx+1);
+        with oper[opidx]^ do
          begin
            if typ<>top_const then
              clearop(opidx);
@@ -1550,9 +1568,8 @@ implementation
       begin
         if not assigned(s) then
          internalerror(200204251);
-        if opidx>=ops then
-         ops:=opidx+1;
-        with oper[opidx] do
+        allocate_oper(opidx+1);
+        with oper[opidx]^ do
          begin
            if typ<>top_symbol then
              clearop(opidx);
@@ -1568,9 +1585,8 @@ implementation
       begin
         if not assigned(s) then
          internalerror(200204251);
-        if opidx>=ops then
-         ops:=opidx+1;
-        with oper[opidx] do
+        allocate_oper(opidx+1);
+        with oper[opidx]^ do
          begin
            if typ<>top_local then
              clearop(opidx);
@@ -1583,9 +1599,8 @@ implementation
 
     procedure taicpu_abstract.loadref(opidx:longint;const r:treference);
       begin
-        if opidx>=ops then
-         ops:=opidx+1;
-        with oper[opidx] do
+        allocate_oper(opidx+1);
+        with oper[opidx]^ do
           begin
             if typ<>top_ref then
               begin
@@ -1610,9 +1625,8 @@ implementation
 
     procedure taicpu_abstract.loadreg(opidx:longint;r:tregister);
       begin
-        if opidx>=ops then
-         ops:=opidx+1;
-        with oper[opidx] do
+        allocate_oper(opidx+1);
+        with oper[opidx]^ do
          begin
            if typ<>top_reg then
              clearop(opidx);
@@ -1624,31 +1638,33 @@ implementation
 
     procedure taicpu_abstract.loadoper(opidx:longint;o:toper);
       begin
-        if opidx>=ops then
-         ops:=opidx+1;
+        allocate_oper(opidx+1);
         clearop(opidx);
-        oper[opidx]:=o;
+        oper[opidx]^:=o;
         { copy also the reference }
-        case oper[opidx].typ of
-          top_ref:
-            begin
-              new(oper[opidx].ref);
-              oper[opidx].ref^:=o.ref^;
-            end;
+        with oper[opidx]^ do
+          begin
+            case typ of
+              top_ref:
+                begin
+                  new(ref);
+                  ref^:=o.ref^;
+                end;
 {$ifdef ARM}
-          top_shifterop:
-            begin
-              new(oper[opidx].shifterop);
-              oper[opidx].shifterop^:=o.shifterop^;
-            end;
+              top_shifterop:
+                begin
+                  new(shifterop);
+                  shifterop^:=o.shifterop^;
+                end;
 {$endif ARM}
-         end;
+             end;
+          end;
       end;
 
 
     procedure taicpu_abstract.clearop(opidx:longint);
       begin
-        with oper[opidx] do
+        with oper[opidx]^ do
           case typ of
             top_ref:
               dispose(ref);
@@ -1736,12 +1752,12 @@ implementation
       begin
         spill_registers:=false;
         if (ops = 2) and
-           (oper[1].typ=top_ref) and
+           (oper[1]^.typ=top_ref) and
            { oper[1] can also be ref in case of "lis r3,symbol@ha" or so }
            spilling_decode_loadstore(opcode,op,wasload) then
           begin
             { the register that's being stored/loaded }
-            supreg:=getsupreg(oper[0].reg);
+            supreg:=getsupreg(oper[0]^.reg);
             if supregset_in(r,supreg) then
               begin
                 // Example:
@@ -1762,14 +1778,14 @@ implementation
                 //   st? r21d, 8(r1)
 
                 pos := get_insert_pos(Tai(previous),supreg,
-                                      getsupreg(oper[1].ref^.base),
-                                      getsupreg(oper[1].ref^.index),
+                                      getsupreg(oper[1]^.ref^.base),
+                                      getsupreg(oper[1]^.ref^.index),
                                       unusedregsint);
                 rgget(list,pos,R_SUBWHOLE,helpreg);
                 spill_registers := true;
                 if wasload then
                   begin
-                    helpins:=spilling_create_loadstore(opcode,helpreg,oper[1].ref^);
+                    helpins:=spilling_create_loadstore(opcode,helpreg,oper[1]^.ref^);
                     loadref(1,spilltemplist[supreg]);
                     opcode := op;
                   end
@@ -1790,13 +1806,13 @@ implementation
 
             { now the registers used in the reference }
             { a) base                                 }
-            supreg := getsupreg(oper[1].ref^.base);
+            supreg := getsupreg(oper[1]^.ref^.base);
             if supregset_in(r,supreg) then
               begin
                 if wasload then
-                  pos:=get_insert_pos(Tai(previous),getsupreg(oper[1].ref^.index),getsupreg(oper[0].reg),0,unusedregsint)
+                  pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.index),getsupreg(oper[0]^.reg),0,unusedregsint)
                 else
-                  pos:=get_insert_pos(Tai(previous),getsupreg(oper[1].ref^.index),0,0,unusedregsint);
+                  pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.index),0,0,unusedregsint);
                 rgget(list,pos,R_SUBWHOLE,helpreg);
                 spill_registers:=true;
                 helpins:=spilling_create_load(spilltemplist[supreg],helpreg);
@@ -1804,7 +1820,7 @@ implementation
                   list.insertafter(helpins,list.first)
                 else
                   list.insertafter(helpins,pos.next);
-                oper[1].ref^.base:=helpreg;
+                oper[1]^.ref^.base:=helpreg;
                 rgunget(list,helpins,helpreg);
                 forward_allocation(Tai(helpins.next),unusedregsint);
 {
@@ -1814,13 +1830,13 @@ implementation
               end;
 
             { b) index }
-            supreg := getsupreg(oper[1].ref^.index);
+            supreg := getsupreg(oper[1]^.ref^.index);
             if supregset_in(r,supreg) then
               begin
                 if wasload then
-                  pos:=get_insert_pos(Tai(previous),getsupreg(oper[1].ref^.base),getsupreg(oper[0].reg),0,unusedregsint)
+                  pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.base),getsupreg(oper[0]^.reg),0,unusedregsint)
                 else
-                  pos:=get_insert_pos(Tai(previous),getsupreg(oper[1].ref^.base),0,0,unusedregsint);
+                  pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.base),0,0,unusedregsint);
                 rgget(list,pos,R_SUBWHOLE,helpreg);
                 spill_registers:=true;
                 helpins:=spilling_create_load(spilltemplist[supreg],helpreg);
@@ -1828,7 +1844,7 @@ implementation
                   list.insertafter(helpins,list.first)
                 else
                   list.insertafter(helpins,pos.next);
-                oper[1].ref^.index:=helpreg;
+                oper[1]^.ref^.index:=helpreg;
                 rgunget(list,helpins,helpreg);
                 forward_allocation(Tai(helpins.next),unusedregsint);
 {
@@ -1844,16 +1860,16 @@ implementation
         { operand 0 is a register and is the destination, the others are sources }
         { and can be either registers or constants                               }
         { exception: branches (is_jmp isn't always set for them)                 }
-        if oper[0].typ <> top_reg then
+        if oper[0]^.typ <> top_reg then
           exit;
-        reg1 := getsupreg(oper[0].reg);
-        if oper[1].typ = top_reg then
-          reg2 := getsupreg(oper[1].reg)
+        reg1 := getsupreg(oper[0]^.reg);
+        if oper[1]^.typ = top_reg then
+          reg2 := getsupreg(oper[1]^.reg)
         else
           reg2 := 0;
         if (ops >= 3) and
-           (oper[2].typ = top_reg) then
-          reg3 := getsupreg(oper[2].reg)
+           (oper[2]^.typ = top_reg) then
+          reg3 := getsupreg(oper[2]^.reg)
         else
           reg3 := 0;
 
@@ -1889,9 +1905,9 @@ implementation
           end;
 
         for i := 1 to 2 do
-          if (oper[i].typ = top_reg) then
+          if (oper[i]^.typ = top_reg) then
             begin
-              supreg:=getsupreg(oper[i].reg);
+              supreg:=getsupreg(oper[i]^.reg);
               if supregset_in(r,supreg) then
                 begin
                   // Example:
@@ -1936,15 +1952,20 @@ implementation
     Function taicpu_abstract.getcopy:TLinkedListItem;
       var
         i : longint;
-        p : TLinkedListItem;
+        p : taicpu_abstract;
       begin
-        p:=inherited getcopy;
+        p:=taicpu_abstract(inherited getcopy);
         { make a copy of the references }
-        for i:=1 to ops do
-         if (taicpu_abstract(p).oper[i-1].typ=top_ref) then
+        p.opercnt:=0;
+        p.allocate_oper(ops);
+        for i:=0 to ops-1 do
           begin
-            new(taicpu_abstract(p).oper[i-1].ref);
-            taicpu_abstract(p).oper[i-1].ref^:=oper[i-1].ref^;
+            p.oper[i]^:=oper[i]^;
+            if (oper[i]^.typ=top_ref) then
+              begin
+                new(p.oper[i]^.ref);
+                p.oper[i]^.ref^:=oper[i]^.ref^;
+              end;
           end;
         getcopy:=p;
       end;
@@ -1957,9 +1978,9 @@ implementation
         inherited ppuload(t,ppufile);
         { hopefully, we don't get problems with big/litte endian here when cross compiling :/ }
         ppufile.getdata(condition,sizeof(tasmcond));
-        ops:=ppufile.getbyte;
-        for i:=1 to ops do
-          ppuloadoper(ppufile,oper[i-1]);
+        allocate_oper(ppufile.getbyte);
+        for i:=0 to ops-1 do
+          ppuloadoper(ppufile,oper[i]^);
         opcode:=tasmop(ppufile.getword);
 {$ifdef i386}
         ppufile.getdata(segprefix,sizeof(Tregister));
@@ -1975,8 +1996,8 @@ implementation
         inherited ppuwrite(ppufile);
         ppufile.putdata(condition,sizeof(tasmcond));
         ppufile.putbyte(ops);
-        for i:=1 to ops do
-          ppuwriteoper(ppufile,oper[i-1]);
+        for i:=0 to ops-1 do
+          ppuwriteoper(ppufile,oper[i]^);
         ppufile.putword(word(opcode));
 {$ifdef i386}
         ppufile.putdata(segprefix,sizeof(Tregister));
@@ -1986,13 +2007,13 @@ implementation
 
 
     procedure taicpu_abstract.derefimpl;
+      var
+        i : integer;
+      begin
+        for i:=0 to ops-1 do
+          ppuderefoper(oper[i]^);
+      end;
 
-    var i:byte;
-
-    begin
-      for i:=1 to ops do
-        ppuderefoper(oper[i-1]);
-    end;
 
 {****************************************************************************
                               tai_align_abstract
@@ -2101,7 +2122,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.44  2003-10-17 14:38:32  peter
+  Revision 1.45  2003-10-21 15:15:35  peter
+    * taicpu_abstract.oper[] changed to pointers
+
+  Revision 1.44  2003/10/17 14:38:32  peter
     * 64k registers supported
     * fixed some memory leaks
 

+ 5 - 2
compiler/assemble.pas

@@ -1185,7 +1185,7 @@ Implementation
                  { fixup the references }
                  for i:=1 to Taicpu(hp).ops do
                   begin
-                    with Taicpu(hp).oper[i-1] do
+                    with Taicpu(hp).oper[i-1]^ do
                      begin
                        case typ of
                          top_ref :
@@ -1661,7 +1661,10 @@ Implementation
 end.
 {
   $Log$
-  Revision 1.57  2003-10-03 14:16:48  marco
+  Revision 1.58  2003-10-21 15:15:36  peter
+    * taicpu_abstract.oper[] changed to pointers
+
+  Revision 1.57  2003/10/03 14:16:48  marco
    * -XP<prefix> support
 
   Revision 1.56  2003/09/30 19:54:23  peter

+ 9 - 6
compiler/i386/ag386int.pas

@@ -604,8 +604,8 @@ implementation
                              (taicpu(hp).opcode=A_PUSH) or
                              (taicpu(hp).opcode=A_POP)
                             ) and
-                            (taicpu(hp).oper[0].typ=top_reg) and
-                            is_segment_reg(taicpu(hp).oper[0].reg)
+                            (taicpu(hp).oper[0]^.typ=top_reg) and
+                            is_segment_reg(taicpu(hp).oper[0]^.reg)
                            ) then
                          AsmWriteln(#9#9'DB'#9'066h');
 
@@ -640,7 +640,7 @@ implementation
                        if (aktoutputformat = as_i386_wasm) and
                         (taicpu(hp).opsize=S_W) and
                         (taicpu(hp).opcode=A_PUSH) and
-                        (taicpu(hp).oper[0].typ=top_const) then
+                        (taicpu(hp).oper[0]^.typ=top_const) then
                         begin
                           AsmWriteln(#9#9'DB 66h,68h ; pushw imm16');
                           AsmWrite(#9#9'DW');
@@ -652,7 +652,7 @@ implementation
                           if is_calljmp(taicpu(hp).opcode) then
                            begin
                              AsmWrite(#9);
-                             WriteOper_jmp(taicpu(hp).oper[0],taicpu(hp).opsize);
+                             WriteOper_jmp(taicpu(hp).oper[0]^,taicpu(hp).opsize);
                            end
                           else
                            begin
@@ -662,7 +662,7 @@ implementation
                                  AsmWrite(#9)
                                 else
                                  AsmWrite(',');
-                                WriteOper(taicpu(hp).oper[i],taicpu(hp).opsize,taicpu(hp).opcode,(i=2));
+                                WriteOper(taicpu(hp).oper[i]^,taicpu(hp).opsize,taicpu(hp).opcode,(i=2));
                               end;
                            end;
                         end;
@@ -875,7 +875,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.42  2003-10-19 01:34:30  florian
+  Revision 1.43  2003-10-21 15:15:36  peter
+    * taicpu_abstract.oper[] changed to pointers
+
+  Revision 1.42  2003/10/19 01:34:30  florian
     * some ppc stuff fixed
     * memory leak fixed
 

+ 13 - 10
compiler/i386/ag386nsm.pas

@@ -647,11 +647,11 @@ interface
                    (taicpu(hp).opcode=A_FMULP))
                   and (taicpu(hp).ops=0) then
                  begin
-                   taicpu(hp).ops:=2;
-                   taicpu(hp).oper[0].typ:=top_reg;
-                   taicpu(hp).oper[0].reg:=NR_ST1;
-                   taicpu(hp).oper[1].typ:=top_reg;
-                   taicpu(hp).oper[1].reg:=NR_ST;
+                   taicpu(hp).allocate_oper(2);
+                   taicpu(hp).oper[0]^.typ:=top_reg;
+                   taicpu(hp).oper[0]^.reg:=NR_ST1;
+                   taicpu(hp).oper[1]^.typ:=top_reg;
+                   taicpu(hp).oper[1]^.reg:=NR_ST;
                  end;
                if taicpu(hp).opcode=A_FWAIT then
                 AsmWriteln(#9#9'DB'#9'09bh')
@@ -663,8 +663,8 @@ interface
                   if (taicpu(hp).opsize=S_W) and
                      ((taicpu(hp).opcode=A_PUSH) or
                       (taicpu(hp).opcode=A_POP)) and
-                      (taicpu(hp).oper[0].typ=top_reg) and
-                      (is_segment_reg(taicpu(hp).oper[0].reg)) then
+                      (taicpu(hp).oper[0]^.typ=top_reg) and
+                      (is_segment_reg(taicpu(hp).oper[0]^.reg)) then
                     AsmWriteln(#9#9'DB'#9'066h');
                   AsmWrite(#9#9+std_op2str[taicpu(hp).opcode]+cond2str[taicpu(hp).condition]);
                   if taicpu(hp).ops<>0 then
@@ -672,7 +672,7 @@ interface
                      if is_calljmp(taicpu(hp).opcode) then
                       begin
                         AsmWrite(#9);
-                        WriteOper_jmp(taicpu(hp).oper[0],taicpu(hp).opcode);
+                        WriteOper_jmp(taicpu(hp).oper[0]^,taicpu(hp).opcode);
                       end
                      else
                       begin
@@ -682,7 +682,7 @@ interface
                             AsmWrite(#9)
                            else
                             AsmWrite(',');
-                           WriteOper(taicpu(hp).oper[i],taicpu(hp).opsize,taicpu(hp).opcode,taicpu(hp).ops,(i=2));
+                           WriteOper(taicpu(hp).oper[i]^,taicpu(hp).opsize,taicpu(hp).opcode,taicpu(hp).ops,(i=2));
                          end;
                       end;
                    end;
@@ -900,7 +900,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.40  2003-10-01 20:34:49  peter
+  Revision 1.41  2003-10-21 15:15:36  peter
+    * taicpu_abstract.oper[] changed to pointers
+
+  Revision 1.40  2003/10/01 20:34:49  peter
     * procinfo unit contains tprocinfo
     * cginfo renamed to cgbase
     * moved cgmessage to verbose

+ 7 - 4
compiler/ncgbas.pas

@@ -208,8 +208,8 @@ interface
                        { fixup the references }
                        for i:=1 to taicpu(hp2).ops do
                         begin
-                          ResolveRef(taicpu(hp2).oper[i-1]);
-                          with taicpu(hp2).oper[i-1] do
+                          ResolveRef(taicpu(hp2).oper[i-1]^);
+                          with taicpu(hp2).oper[i-1]^ do
                            begin
                              case typ of
                                top_ref :
@@ -255,7 +255,7 @@ interface
 {$endif}
                        { fixup the references }
                        for i:=1 to taicpu(hp).ops do
-                         ResolveRef(taicpu(hp).oper[i-1]);
+                         ResolveRef(taicpu(hp).oper[i-1]^);
                      end;
                 end;
                 hp:=tai(hp.next);
@@ -372,7 +372,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.44  2003-10-10 17:48:13  peter
+  Revision 1.45  2003-10-21 15:15:36  peter
+    * taicpu_abstract.oper[] changed to pointers
+
+  Revision 1.44  2003/10/10 17:48:13  peter
     * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
     * tregisteralloctor renamed to trgobj
     * removed rgobj from a lot of units

+ 5 - 2
compiler/ninl.pas

@@ -2006,7 +2006,7 @@ implementation
          if assigned(left) then
            begin
               if left.nodetype=callparan then
-                tcallparanode(left).firstcallparan(false)
+                tcallparanode(left).firstcallparan
               else
                 firstpass(left);
               left_max;
@@ -2358,7 +2358,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.120  2003-10-08 19:19:45  peter
+  Revision 1.121  2003-10-21 15:15:36  peter
+    * taicpu_abstract.oper[] changed to pointers
+
+  Revision 1.120  2003/10/08 19:19:45  peter
     * set_varstate cleanup
 
   Revision 1.119  2003/10/01 20:34:48  peter

+ 17 - 14
compiler/rgobj.pas

@@ -854,9 +854,9 @@ implementation
       i.moveset:=ms_worklist_moves;
       i.instruction:=instr;
       worklist_moves.insert(i);
-      ssupreg:=getsupreg(instr.oper[O_MOV_SOURCE].reg);
+      ssupreg:=getsupreg(instr.oper[O_MOV_SOURCE]^.reg);
       add_to_movelist(ssupreg,i);
-      dsupreg:=getsupreg(instr.oper[O_MOV_DEST].reg);
+      dsupreg:=getsupreg(instr.oper[O_MOV_DEST]^.reg);
       if ssupreg<>dsupreg then
         {Avoid adding the same move instruction twice to a single register.}
         add_to_movelist(dsupreg,i);
@@ -1202,8 +1202,8 @@ implementation
 
     begin
       m:=Tmoveins(worklist_moves.getfirst);
-      x:=get_alias(getsupreg(m.instruction.oper[0].reg));
-      y:=get_alias(getsupreg(m.instruction.oper[1].reg));
+      x:=get_alias(getsupreg(m.instruction.oper[0]^.reg));
+      y:=get_alias(getsupreg(m.instruction.oper[1]^.reg));
       if (y<first_imaginary) then
         begin
           u:=y;
@@ -1259,8 +1259,8 @@ implementation
             m:=reginfo[u].movelist^.data[i];
             if Tmoveins(m).moveset in [ms_worklist_moves,ms_active_moves] then
               begin
-                x:=getsupreg(Tmoveins(m).instruction.oper[0].reg);
-                y:=getsupreg(Tmoveins(m).instruction.oper[1].reg);
+                x:=getsupreg(Tmoveins(m).instruction.oper[0]^.reg);
+                y:=getsupreg(Tmoveins(m).instruction.oper[1]^.reg);
                 if get_alias(y)=get_alias(u) then
                   v:=get_alias(x)
                 else
@@ -1521,9 +1521,9 @@ implementation
             begin
               m:=Tmoveins(movelist[u]^.data[j]);
               {Get the other register of the move instruction.}
-              v:=m.instruction.oper[0].reg.number shr 8;
+              v:=m.instruction.oper[0]^.reg.number shr 8;
               if v=u then
-                v:=m.instruction.oper[1].reg.number shr 8;
+                v:=m.instruction.oper[1]^.reg.number shr 8;
               repeat
                 repeat
                   if (u<>v) and (movelist[v]<>nil) then
@@ -1752,15 +1752,15 @@ implementation
             ait_instruction:
               begin
                 for i:=0 to Taicpu_abstract(p).ops-1 do
-                  case Taicpu_abstract(p).oper[i].typ of
+                  case Taicpu_abstract(p).oper[i]^.typ of
                     Top_reg:
-                       if (getregtype(Taicpu_abstract(p).oper[i].reg)=regtype) then
-                         setsupreg(Taicpu_abstract(p).oper[i].reg,reginfo[getsupreg(Taicpu_abstract(p).oper[i].reg)].colour);
+                       if (getregtype(Taicpu_abstract(p).oper[i]^.reg)=regtype) then
+                         setsupreg(Taicpu_abstract(p).oper[i]^.reg,reginfo[getsupreg(Taicpu_abstract(p).oper[i]^.reg)].colour);
                     Top_ref:
                       begin
                         if regtype=R_INTREGISTER then
                           begin
-                            r:=Taicpu_abstract(p).oper[i].ref;
+                            r:=Taicpu_abstract(p).oper[i]^.ref;
                             if r^.base<>NR_NO then
                               setsupreg(r^.base,reginfo[getsupreg(r^.base)].colour);
                             if r^.index<>NR_NO then
@@ -1770,7 +1770,7 @@ implementation
 {$ifdef arm}
                     Top_shifterop:
                       begin
-                        so:=Taicpu_abstract(p).oper[i].shifterop;
+                        so:=Taicpu_abstract(p).oper[i]^.shifterop;
                         if so^.rs<>NR_NO then
                           setsupreg(so^.rs,table[getsupreg(so^.rs)]);
                       end;
@@ -1796,7 +1796,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.90  2003-10-19 12:36:36  florian
+  Revision 1.91  2003-10-21 15:15:36  peter
+    * taicpu_abstract.oper[] changed to pointers
+
+  Revision 1.90  2003/10/19 12:36:36  florian
     * improved speed; reduced memory usage of the interference bitmap
 
   Revision 1.89  2003/10/19 01:34:30  florian

+ 189 - 183
compiler/x86/aasmcpu.pas

@@ -213,10 +213,10 @@ interface
          procedure ppuderefoper(var o:toper);override;
       private
          { next fields are filled in pass1, so pass2 is faster }
-         insentry  : PInsEntry;
+         inssize   : shortint;
          insoffset,
-         inssize   : longint;
          LastInsOffset : longint; { need to be public to be reset }
+         insentry  : PInsEntry;
          function  InsEnd:longint;
          procedure create_ot;
          function  Matches(p:PInsEntry):longint;
@@ -648,59 +648,62 @@ implementation
         addsize : boolean;
       begin
         s:='['+std_op2str[opcode];
-        for i:=1to ops do
+        for i:=0 to ops-1 do
          begin
-           if i=1 then
-            s:=s+' '
-           else
-            s:=s+',';
-           { type }
-           addsize:=false;
-           if (oper[i-1].ot and OT_XMMREG)=OT_XMMREG then
-            s:=s+'xmmreg'
-           else
-             if (oper[i-1].ot and OT_MMXREG)=OT_MMXREG then
-              s:=s+'mmxreg'
-           else
-             if (oper[i-1].ot and OT_FPUREG)=OT_FPUREG then
-              s:=s+'fpureg'
-           else
-            if (oper[i-1].ot and OT_REGISTER)=OT_REGISTER then
+           with oper[i]^ do
              begin
-               s:=s+'reg';
-               addsize:=true;
-             end
-           else
-            if (oper[i-1].ot and OT_IMMEDIATE)=OT_IMMEDIATE then
-             begin
-               s:=s+'imm';
-               addsize:=true;
-             end
-           else
-            if (oper[i-1].ot and OT_MEMORY)=OT_MEMORY then
-             begin
-               s:=s+'mem';
-               addsize:=true;
-             end
-           else
-             s:=s+'???';
-           { size }
-           if addsize then
-            begin
-              if (oper[i-1].ot and OT_BITS8)<>0 then
-                s:=s+'8'
-              else
-               if (oper[i-1].ot and OT_BITS16)<>0 then
-                s:=s+'16'
-              else
-               if (oper[i-1].ot and OT_BITS32)<>0 then
-                s:=s+'32'
-              else
-                s:=s+'??';
-              { signed }
-              if (oper[i-1].ot and OT_SIGNED)<>0 then
-               s:=s+'s';
-            end;
+               if i=0 then
+                s:=s+' '
+               else
+                s:=s+',';
+               { type }
+               addsize:=false;
+               if (ot and OT_XMMREG)=OT_XMMREG then
+                s:=s+'xmmreg'
+               else
+                 if (ot and OT_MMXREG)=OT_MMXREG then
+                  s:=s+'mmxreg'
+               else
+                 if (ot and OT_FPUREG)=OT_FPUREG then
+                  s:=s+'fpureg'
+               else
+                if (ot and OT_REGISTER)=OT_REGISTER then
+                 begin
+                   s:=s+'reg';
+                   addsize:=true;
+                 end
+               else
+                if (ot and OT_IMMEDIATE)=OT_IMMEDIATE then
+                 begin
+                   s:=s+'imm';
+                   addsize:=true;
+                 end
+               else
+                if (ot and OT_MEMORY)=OT_MEMORY then
+                 begin
+                   s:=s+'mem';
+                   addsize:=true;
+                 end
+               else
+                 s:=s+'???';
+               { size }
+               if addsize then
+                begin
+                  if (ot and OT_BITS8)<>0 then
+                    s:=s+'8'
+                  else
+                   if (ot and OT_BITS16)<>0 then
+                    s:=s+'16'
+                  else
+                   if (ot and OT_BITS32)<>0 then
+                    s:=s+'32'
+                  else
+                    s:=s+'??';
+                  { signed }
+                  if (ot and OT_SIGNED)<>0 then
+                   s:=s+'s';
+                end;
+             end;
          end;
         GetString:=s+']';
       end;
@@ -708,7 +711,7 @@ implementation
 
     procedure taicpu.Swapoperands;
       var
-        p : TOper;
+        p : POper;
       begin
         { Fix the operands which are in AT&T style and we need them in Intel style }
         case ops of
@@ -826,16 +829,16 @@ implementation
 
         if (
             (ops=2) and
-            (oper[0].typ=top_reg) and
-            (oper[1].typ=top_reg) and
+            (oper[0]^.typ=top_reg) and
+            (oper[1]^.typ=top_reg) and
            { if the first is ST and the second is also a register
              it is necessarily ST1 .. ST7 }
-            ((oper[0].reg=NR_ST) or
-             (oper[0].reg=NR_ST0))
+            ((oper[0]^.reg=NR_ST) or
+             (oper[0]^.reg=NR_ST0))
            ) or
            { ((ops=1) and
-            (oper[0].typ=top_reg) and
-            (oper[0].reg in [R_ST1..R_ST7]))  or}
+            (oper[0]^.typ=top_reg) and
+            (oper[0]^.reg in [R_ST1..R_ST7]))  or}
            (ops=0) then
           begin
             if opcode=A_FSUBR then
@@ -857,9 +860,9 @@ implementation
           end;
         if (
             (ops=1) and
-            (oper[0].typ=top_reg) and
-            (getregtype(oper[0].reg)=R_FPUREGISTER) and
-            (oper[0].reg<>NR_ST)
+            (oper[0]^.typ=top_reg) and
+            (getregtype(oper[0]^.reg)=R_FPUREGISTER) and
+            (oper[0]^.reg<>NR_ST)
            ) then
          begin
            if opcode=A_FSUBRP then
@@ -900,7 +903,7 @@ implementation
          exit;
         { update oper[].ot field }
         for i:=0 to ops-1 do
-         with oper[i] do
+         with oper[i]^ do
           begin
             case typ of
               top_reg :
@@ -1002,7 +1005,7 @@ implementation
 
         { Check that no spurious colons or TOs are present }
         for i:=0 to p^.ops-1 do
-         if (oper[i].ot and (not p^.optypes[i]) and (OT_COLON or OT_TO))<>0 then
+         if (oper[i]^.ot and (not p^.optypes[i]) and (OT_COLON or OT_TO))<>0 then
           begin
             Matches:=0;
             exit;
@@ -1011,12 +1014,12 @@ implementation
         { Check that the operand flags all match up }
         for i:=0 to p^.ops-1 do
          begin
-           if ((p^.optypes[i] and (not oper[i].ot)) or
+           if ((p^.optypes[i] and (not oper[i]^.ot)) or
                ((p^.optypes[i] and OT_SIZE_MASK) and
-                ((p^.optypes[i] xor oper[i].ot) and OT_SIZE_MASK)))<>0 then
+                ((p^.optypes[i] xor oper[i]^.ot) and OT_SIZE_MASK)))<>0 then
             begin
-              if ((p^.optypes[i] and (not oper[i].ot) and OT_NON_SIZE) or
-                  (oper[i].ot and OT_SIZE_MASK))<>0 then
+              if ((p^.optypes[i] and (not oper[i]^.ot) and OT_NON_SIZE) or
+                  (oper[i]^.ot and OT_SIZE_MASK))<>0 then
                begin
                  Matches:=0;
                  exit;
@@ -1082,10 +1085,10 @@ implementation
         for i:=0 to p^.ops-1 do
          begin
            if ((p^.optypes[i] and OT_SIZE_MASK)=0) and
-              ((oper[i].ot and OT_SIZE_MASK and (not siz[i]))<>0) and
+              ((oper[i]^.ot and OT_SIZE_MASK and (not siz[i]))<>0) and
               { Immediates can always include smaller size }
-              ((oper[i].ot and OT_IMMEDIATE)=0) and
-               (((p^.optypes[i] and OT_SIZE_MASK) or siz[i])<(oper[i].ot and OT_SIZE_MASK)) then
+              ((oper[i]^.ot and OT_IMMEDIATE)=0) and
+               (((p^.optypes[i] and OT_SIZE_MASK) or siz[i])<(oper[i]^.ot and OT_SIZE_MASK)) then
             Matches:=2;
          end;
       end;
@@ -1265,15 +1268,15 @@ implementation
     function taicpu.needaddrprefix(opidx:byte):boolean;
       begin
         needaddrprefix:=false;
-        if (OT_MEMORY and (not oper[opidx].ot))=0 then
+        if (OT_MEMORY and (not oper[opidx]^.ot))=0 then
           begin
             if (
-                (oper[opidx].ref^.index<>NR_NO) and
-                (getsubreg(oper[opidx].ref^.index)<>R_SUBD)
+                (oper[opidx]^.ref^.index<>NR_NO) and
+                (getsubreg(oper[opidx]^.ref^.index)<>R_SUBD)
                ) or
                (
-                (oper[opidx].ref^.base<>NR_NO) and
-                (getsubreg(oper[opidx].ref^.base)<>R_SUBD)
+                (oper[opidx]^.ref^.base<>NR_NO) and
+                (getsubreg(oper[opidx]^.ref^.base)<>R_SUBD)
                ) then
               needaddrprefix:=true;
           end;
@@ -1517,7 +1520,7 @@ implementation
               begin
                 if (c>=64) and (c<=191) then
                  begin
-                   if not process_ea(oper[(c shr 3) and 7], ea_data, 0) then
+                   if not process_ea(oper[(c shr 3) and 7]^, ea_data, 0) then
                     Message(asmw_e_invalid_effective_address)
                    else
                     inc(len,ea_data.size);
@@ -1583,21 +1586,21 @@ implementation
 
         procedure getvalsym(opidx:longint);
         begin
-          case oper[opidx].typ of
+          case oper[opidx]^.typ of
             top_ref :
               begin
-                currval:=oper[opidx].ref^.offset;
-                currsym:=oper[opidx].ref^.symbol;
+                currval:=oper[opidx]^.ref^.offset;
+                currsym:=oper[opidx]^.ref^.symbol;
               end;
             top_const :
               begin
-                currval:=longint(oper[opidx].val);
+                currval:=longint(oper[opidx]^.val);
                 currsym:=nil;
               end;
             top_symbol :
               begin
-                currval:=oper[opidx].symofs;
-                currsym:=oper[opidx].sym;
+                currval:=oper[opidx]^.symofs;
+                currsym:=oper[opidx]^.sym;
               end;
             else
               Message(asmw_e_immediate_or_reference_expected);
@@ -1645,7 +1648,7 @@ implementation
               end;
             4,6 :
               begin
-                case oper[0].reg of
+                case oper[0]^.reg of
                   NR_CS:
                     bytes[0]:=$e;
                   NR_NO,
@@ -1664,7 +1667,7 @@ implementation
               end;
             5,7 :
               begin
-                case oper[0].reg of
+                case oper[0]^.reg of
                   NR_FS:
                     bytes[0]:=$a0;
                   NR_GS:
@@ -1678,7 +1681,7 @@ implementation
               end;
             8,9,10 :
               begin
-                bytes[0]:=ord(codes^)+regval(oper[c-8].reg);
+                bytes[0]:=ord(codes^)+regval(oper[c-8]^.reg);
                 inc(codes);
                 sec.writebytes(bytes,1);
               end;
@@ -1814,15 +1817,15 @@ implementation
                  begin
                    if (c<127) then
                     begin
-                      if (oper[c and 7].typ=top_reg) then
-                        rfield:=regval(oper[c and 7].reg)
+                      if (oper[c and 7]^.typ=top_reg) then
+                        rfield:=regval(oper[c and 7]^.reg)
                       else
-                        rfield:=regval(oper[c and 7].ref^.base);
+                        rfield:=regval(oper[c and 7]^.ref^.base);
                     end
                    else
                     rfield:=c and 7;
                    opidx:=(c shr 3) and 7;
-                   if not process_ea(oper[opidx], ea_data, rfield) then
+                   if not process_ea(oper[opidx]^,ea_data,rfield) then
                     Message(asmw_e_invalid_effective_address);
 
                    pb:=@bytes;
@@ -1841,19 +1844,19 @@ implementation
                      0 : ;
                      1 :
                        begin
-                         if (oper[opidx].ot and OT_MEMORY)=OT_MEMORY then
-                          sec.writereloc(oper[opidx].ref^.offset,1,oper[opidx].ref^.symbol,RELOC_ABSOLUTE)
+                         if (oper[opidx]^.ot and OT_MEMORY)=OT_MEMORY then
+                          sec.writereloc(oper[opidx]^.ref^.offset,1,oper[opidx]^.ref^.symbol,RELOC_ABSOLUTE)
                          else
                           begin
-                            bytes[0]:=oper[opidx].ref^.offset;
+                            bytes[0]:=oper[opidx]^.ref^.offset;
                             sec.writebytes(bytes,1);
                           end;
                          inc(s);
                        end;
                      2,4 :
                        begin
-                         sec.writereloc(oper[opidx].ref^.offset,ea_data.bytes,
-                           oper[opidx].ref^.symbol,RELOC_ABSOLUTE);
+                         sec.writereloc(oper[opidx]^.ref^.offset,ea_data.bytes,
+                           oper[opidx]^.ref^.symbol,RELOC_ABSOLUTE);
                          inc(s,ea_data.bytes);
                        end;
                    end;
@@ -1872,8 +1875,8 @@ implementation
       {We do not check the number of operands; we assume that nobody constructs
        a mov or xchg instruction with less than 2 operands. (DM)}
       is_nop:=(opcode=A_NOP) or
-              (opcode=A_MOV) and (oper[0].typ=top_reg) and (oper[1].typ=top_reg) and (oper[0].reg=oper[1].reg) or
-              (opcode=A_XCHG) and (oper[0].typ=top_reg) and (oper[1].typ=top_reg) and (oper[0].reg=oper[1].reg);
+              (opcode=A_MOV) and (oper[0]^.typ=top_reg) and (oper[1]^.typ=top_reg) and (oper[0]^.reg=oper[1]^.reg) or
+              (opcode=A_XCHG) and (oper[0]^.typ=top_reg) and (oper[1]^.typ=top_reg) and (oper[0]^.reg=oper[1]^.reg);
     end;
 
     function Taicpu.is_move:boolean;
@@ -1885,7 +1888,7 @@ implementation
        interrest to the register allocation, therefore we only return true
        for a move between two registers. (DM)}
       is_move:=((opcode=A_MOV) or (opcode=A_MOVZX) or (opcode=A_MOVSX)) and
-        ((oper[0].typ=top_reg) and (oper[1].typ=top_reg));
+        ((oper[0]^.typ=top_reg) and (oper[1]^.typ=top_reg));
     end;
 
 
@@ -1921,10 +1924,10 @@ implementation
       case ops of
         1:
           begin
-            if (oper[0].typ=top_reg) and
-               (getregtype(oper[0].reg)=R_INTREGISTER) then
+            if (oper[0]^.typ=top_reg) and
+               (getregtype(oper[0]^.reg)=R_INTREGISTER) then
               begin
-                supreg:=getsupreg(oper[0].reg);
+                supreg:=getsupreg(oper[0]^.reg);
                 if supregset_in(r,supreg) then
                   begin
                     {Situation example:
@@ -1933,15 +1936,15 @@ implementation
                     Change into:
                      push [ebp-12]          ; Replace register by reference }
 {                    hopsize:=reg2opsize(oper[0].reg);}
-                    oper[0].typ:=top_ref;
-                    new(oper[0].ref);
-                    oper[0].ref^:=spilltemplist[supreg];
-{                    oper[0].ref^.size:=hopsize;}
+                    oper[0]^.typ:=top_ref;
+                    new(oper[0]^.ref);
+                    oper[0]^.ref^:=spilltemplist[supreg];
+{                    oper[0]^.ref^.size:=hopsize;}
                   end;
               end;
-            if oper[0].typ=top_ref then
+            if oper[0]^.typ=top_ref then
               begin
-                supreg:=getsupreg(oper[0].ref^.base);
+                supreg:=getsupreg(oper[0]^.ref^.base);
                 if supregset_in(r,supreg) then
                   begin
                     {Situation example:
@@ -1951,23 +1954,23 @@ implementation
 
                      mov r23d,[ebp-12]         ; Use a help register
                      push [r23d+4*r22d]        ; Replace register by helpregister }
-                    subreg:=getsubreg(oper[0].ref^.base);
-                    if oper[0].ref^.index=NR_NO then
+                    subreg:=getsubreg(oper[0]^.ref^.base);
+                    if oper[0]^.ref^.index=NR_NO then
                       pos:=Tai(previous)
                     else
-                      pos:=get_insert_pos(Tai(previous),getsupreg(oper[0].ref^.index),RS_INVALID,RS_INVALID,unusedregsint);
+                      pos:=get_insert_pos(Tai(previous),getsupreg(oper[0]^.ref^.index),RS_INVALID,RS_INVALID,unusedregsint);
                     rgget(list,pos,subreg,helpreg);
                     spill_registers:=true;
-                    helpins:=Taicpu.op_ref_reg(A_MOV,reg2opsize(oper[0].ref^.base),spilltemplist[supreg],helpreg);
+                    helpins:=Taicpu.op_ref_reg(A_MOV,reg2opsize(oper[0]^.ref^.base),spilltemplist[supreg],helpreg);
                     if pos=nil then
                       list.insertafter(helpins,list.first)
                     else
                       list.insertafter(helpins,pos.next);
                     rgunget(list,helpins,helpreg);
                     forward_allocation(Tai(helpins.next),unusedregsint);
-                    oper[0].ref^.base:=helpreg;
+                    oper[0]^.ref^.base:=helpreg;
                   end;
-                supreg:=getsupreg(oper[0].ref^.index);
+                supreg:=getsupreg(oper[0]^.ref^.index);
                 if supregset_in(r,supreg) then
                   begin
                     {Situation example:
@@ -1977,21 +1980,21 @@ implementation
 
                      mov r23d,[ebp-12]         ; Use a help register
                      push [r21d+4*r23d]        ; Replace register by helpregister }
-                    subreg:=getsubreg(oper[0].ref^.index);
-                    if oper[0].ref^.base=NR_NO then
+                    subreg:=getsubreg(oper[0]^.ref^.index);
+                    if oper[0]^.ref^.base=NR_NO then
                       pos:=Tai(previous)
                     else
-                      pos:=get_insert_pos(Tai(previous),getsupreg(oper[0].ref^.base),RS_INVALID,RS_INVALID,unusedregsint);
+                      pos:=get_insert_pos(Tai(previous),getsupreg(oper[0]^.ref^.base),RS_INVALID,RS_INVALID,unusedregsint);
                     rgget(list,pos,subreg,helpreg);
                     spill_registers:=true;
-                    helpins:=Taicpu.op_ref_reg(A_MOV,reg2opsize(oper[0].ref^.index),spilltemplist[supreg],helpreg);
+                    helpins:=Taicpu.op_ref_reg(A_MOV,reg2opsize(oper[0]^.ref^.index),spilltemplist[supreg],helpreg);
                     if pos=nil then
                       list.insertafter(helpins,list.first)
                     else
                       list.insertafter(helpins,pos.next);
                     rgunget(list,helpins,helpreg);
                     forward_allocation(Tai(helpins.next),unusedregsint);
-                    oper[0].ref^.index:=helpreg;
+                    oper[0]^.ref^.index:=helpreg;
                   end;
                 end;
           end;
@@ -2001,9 +2004,9 @@ implementation
               required because the reference can be moved from this instruction
               to a MOV instruction when spilling of the register operand is done }
             for i:=0 to 1 do
-              if oper[i].typ=top_ref then
+              if oper[i]^.typ=top_ref then
                 begin
-                  supreg:=getsupreg(oper[i].ref^.base);
+                  supreg:=getsupreg(oper[i]^.ref^.base);
                   if supregset_in(r,supreg) then
                     begin
                       {Situation example:
@@ -2013,24 +2016,24 @@ implementation
 
                        mov r23d,[ebp-12]         ; Use a help register
                        add r20d,[r23d+4*r22d]    ; Replace register by helpregister }
-                      subreg:=getsubreg(oper[i].ref^.base);
+                      subreg:=getsubreg(oper[i]^.ref^.base);
                       if i=1 then
-                        pos:=get_insert_pos(Tai(previous),getsupreg(oper[i].ref^.index),getsupreg(oper[0].reg),
+                        pos:=get_insert_pos(Tai(previous),getsupreg(oper[i]^.ref^.index),getsupreg(oper[0]^.reg),
                                             RS_INVALID,unusedregsint)
                       else
-                        pos:=get_insert_pos(Tai(previous),getsupreg(oper[i].ref^.index),RS_INVALID,RS_INVALID,unusedregsint);
+                        pos:=get_insert_pos(Tai(previous),getsupreg(oper[i]^.ref^.index),RS_INVALID,RS_INVALID,unusedregsint);
                       rgget(list,pos,subreg,helpreg);
                       spill_registers:=true;
-                      helpins:=Taicpu.op_ref_reg(A_MOV,reg2opsize(oper[i].ref^.base),spilltemplist[supreg],helpreg);
+                      helpins:=Taicpu.op_ref_reg(A_MOV,reg2opsize(oper[i]^.ref^.base),spilltemplist[supreg],helpreg);
                       if pos=nil then
                         list.insertafter(helpins,list.first)
                       else
                         list.insertafter(helpins,pos.next);
-                      oper[i].ref^.base:=helpreg;
+                      oper[i]^.ref^.base:=helpreg;
                       rgunget(list,helpins,helpreg);
                       forward_allocation(Tai(helpins.next),unusedregsint);
                   end;
-                  supreg:=getsupreg(oper[i].ref^.index);
+                  supreg:=getsupreg(oper[i]^.ref^.index);
                   if supregset_in(r,supreg) then
                     begin
                       {Situation example:
@@ -2040,31 +2043,31 @@ implementation
 
                        mov r23d,[ebp-12]         ; Use a help register
                        add r20d,[r21d+4*r23d]    ; Replace register by helpregister }
-                      subreg:=getsubreg(oper[i].ref^.index);
+                      subreg:=getsubreg(oper[i]^.ref^.index);
                       if i=1 then
-                        pos:=get_insert_pos(Tai(previous),getsupreg(oper[i].ref^.base),getsupreg(oper[0].reg),
+                        pos:=get_insert_pos(Tai(previous),getsupreg(oper[i]^.ref^.base),getsupreg(oper[0]^.reg),
                                             RS_INVALID,unusedregsint)
                       else
-                        pos:=get_insert_pos(Tai(previous),getsupreg(oper[i].ref^.base),RS_INVALID,RS_INVALID,unusedregsint);
+                        pos:=get_insert_pos(Tai(previous),getsupreg(oper[i]^.ref^.base),RS_INVALID,RS_INVALID,unusedregsint);
                       rgget(list,pos,subreg,helpreg);
                       spill_registers:=true;
-                      helpins:=Taicpu.op_ref_reg(A_MOV,reg2opsize(oper[i].ref^.index),spilltemplist[supreg],helpreg);
+                      helpins:=Taicpu.op_ref_reg(A_MOV,reg2opsize(oper[i]^.ref^.index),spilltemplist[supreg],helpreg);
                       if pos=nil then
                         list.insertafter(helpins,list.first)
                       else
                         list.insertafter(helpins,pos.next);
-                      oper[i].ref^.index:=helpreg;
+                      oper[i]^.ref^.index:=helpreg;
                       rgunget(list,helpins,helpreg);
                       forward_allocation(Tai(helpins.next),unusedregsint);
                     end;
                 end;
-            if (oper[0].typ=top_reg) and
-               (getregtype(oper[0].reg)=R_INTREGISTER) then
+            if (oper[0]^.typ=top_reg) and
+               (getregtype(oper[0]^.reg)=R_INTREGISTER) then
               begin
-                supreg:=getsupreg(oper[0].reg);
-                subreg:=getsubreg(oper[0].reg);
+                supreg:=getsupreg(oper[0]^.reg);
+                subreg:=getsubreg(oper[0]^.reg);
                 if supregset_in(r,supreg) then
-                  if oper[1].typ=top_ref then
+                  if oper[1]^.typ=top_ref then
                     begin
                       {Situation example:
                        add [r20d],r21d      ; r21d must be spilled into [ebp-12]
@@ -2073,17 +2076,17 @@ implementation
 
                        mov r22d,[ebp-12]    ; Use a help register
                        add [r20d],r22d      ; Replace register by helpregister }
-                      pos:=get_insert_pos(Tai(previous),getsupreg(oper[0].reg),
-                                          getsupreg(oper[1].ref^.base),getsupreg(oper[1].ref^.index),
+                      pos:=get_insert_pos(Tai(previous),getsupreg(oper[0]^.reg),
+                                          getsupreg(oper[1]^.ref^.base),getsupreg(oper[1]^.ref^.index),
                                           unusedregsint);
                       rgget(list,pos,subreg,helpreg);
                       spill_registers:=true;
-                      helpins:=Taicpu.op_ref_reg(A_MOV,reg2opsize(oper[0].reg),spilltemplist[supreg],helpreg);
+                      helpins:=Taicpu.op_ref_reg(A_MOV,reg2opsize(oper[0]^.reg),spilltemplist[supreg],helpreg);
                       if pos=nil then
                         list.insertafter(helpins,list.first)
                       else
                         list.insertafter(helpins,pos.next);
-                      oper[0].reg:=helpreg;
+                      oper[0]^.reg:=helpreg;
                       rgunget(list,helpins,helpreg);
                       forward_allocation(Tai(helpins.next),unusedregsint);
                     end
@@ -2095,19 +2098,19 @@ implementation
                        Change into:
 
                        add r20d,[ebp-12]    ; Replace register by reference }
-                      oper[0].typ:=top_ref;
-                      new(oper[0].ref);
-                      oper[0].ref^:=spilltemplist[supreg];
+                      oper[0]^.typ:=top_ref;
+                      new(oper[0]^.ref);
+                      oper[0]^.ref^:=spilltemplist[supreg];
                     end;
               end;
-            if (oper[1].typ=top_reg) and
-               (getregtype(oper[1].reg)=R_INTREGISTER) then
+            if (oper[1]^.typ=top_reg) and
+               (getregtype(oper[1]^.reg)=R_INTREGISTER) then
               begin
-                supreg:=getsupreg(oper[1].reg);
-                subreg:=getsubreg(oper[1].reg);
+                supreg:=getsupreg(oper[1]^.reg);
+                subreg:=getsubreg(oper[1]^.reg);
                 if supregset_in(r,supreg) then
                   begin
-                    if oper[0].typ=top_ref then
+                    if oper[0]^.typ=top_ref then
                       begin
                         {Situation example:
                          add r20d,[r21d]      ; r20d must be spilled into [ebp-12]
@@ -2116,8 +2119,8 @@ implementation
 
                          mov r22d,[r21d]      ; Use a help register
                          add [ebp-12],r22d    ; Replace register by helpregister }
-                        pos:=get_insert_pos(Tai(previous),getsupreg(oper[0].ref^.base),
-                                            getsupreg(oper[0].ref^.index),RS_INVALID,unusedregsint);
+                        pos:=get_insert_pos(Tai(previous),getsupreg(oper[0]^.ref^.base),
+                                            getsupreg(oper[0]^.ref^.index),RS_INVALID,unusedregsint);
                         rgget(list,pos,subreg,helpreg);
                         spill_registers:=true;
                         op:=A_MOV;
@@ -2127,19 +2130,19 @@ implementation
                             {Because 'movzx memory,register' does not exist...}
                             op:=opcode;
                             opcode:=A_MOV;
-                            opsize:=reg2opsize(oper[1].reg);
+                            opsize:=reg2opsize(oper[1]^.reg);
                           end;
-                        helpins:=Taicpu.op_ref_reg(op,hopsize,oper[0].ref^,helpreg);
+                        helpins:=Taicpu.op_ref_reg(op,hopsize,oper[0]^.ref^,helpreg);
                         if pos=nil then
                           list.insertafter(helpins,list.first)
                         else
                           list.insertafter(helpins,pos.next);
-                        dispose(oper[0].ref);
-                        oper[0].typ:=top_reg;
-                        oper[0].reg:=helpreg;
-                        oper[1].typ:=top_ref;
-                        new(oper[1].ref);
-                        oper[1].ref^:=spilltemplist[supreg];
+                        dispose(oper[0]^.ref);
+                        oper[0]^.typ:=top_reg;
+                        oper[0]^.reg:=helpreg;
+                        oper[1]^.typ:=top_ref;
+                        new(oper[1]^.ref);
+                        oper[1]^.ref^:=spilltemplist[supreg];
                         rgunget(list,helpins,helpreg);
                         forward_allocation(Tai(helpins.next),unusedregsint);
                       end
@@ -2158,32 +2161,32 @@ implementation
                             op:=opcode;
                             hopsize:=opsize;
                             opcode:=A_MOV;
-                            opsize:=reg2opsize(oper[1].reg);
-                            pos:=get_insert_pos(Tai(previous),getsupreg(oper[0].reg),RS_INVALID,RS_INVALID,unusedregsint);
+                            opsize:=reg2opsize(oper[1]^.reg);
+                            pos:=get_insert_pos(Tai(previous),getsupreg(oper[0]^.reg),RS_INVALID,RS_INVALID,unusedregsint);
                             rgget(list,pos,subreg,helpreg);
-                            helpins:=Taicpu.op_reg_reg(op,hopsize,oper[0].reg,helpreg);
+                            helpins:=Taicpu.op_reg_reg(op,hopsize,oper[0]^.reg,helpreg);
                             if pos=nil then
                               list.insertafter(helpins,list.first)
                             else
                               list.insertafter(helpins,pos.next);
-                            oper[0].reg:=helpreg;
+                            oper[0]^.reg:=helpreg;
                             rgunget(list,helpins,helpreg);
                             forward_allocation(Tai(helpins.next),unusedregsint);
                           end;
-                        oper[1].typ:=top_ref;
-                        new(oper[1].ref);
-                        oper[1].ref^:=spilltemplist[supreg];
+                        oper[1]^.typ:=top_ref;
+                        new(oper[1]^.ref);
+                        oper[1]^.ref^:=spilltemplist[supreg];
                       end;
                   end;
               end;
 
             { The i386 instruction set never gets boring...
               some opcodes do not support a memory location as destination }
-            if (oper[1].typ=top_ref) and
+            if (oper[1]^.typ=top_ref) and
                (
-                (oper[0].typ=top_const) or
-                ((oper[0].typ=top_reg) and
-                 (getregtype(oper[0].reg)=R_INTREGISTER))
+                (oper[0]^.typ=top_const) or
+                ((oper[0]^.typ=top_reg) and
+                 (getregtype(oper[0]^.reg)=R_INTREGISTER))
                ) then
               begin
                 case opcode of
@@ -2205,16 +2208,16 @@ implementation
                       rgget(list,Tai(previous),subreg,helpreg);
                       spill_registers:=true;
                       {First help instruction.}
-                      helpins:=Taicpu.op_ref_reg(A_MOV,opsize,oper[1].ref^,helpreg);
+                      helpins:=Taicpu.op_ref_reg(A_MOV,opsize,oper[1]^.ref^,helpreg);
                       if previous=nil then
                         list.insert(helpins)
                       else
                         list.insertafter(helpins,previous);
                       {Second help instruction.}
-                      helpins:=Taicpu.op_reg_ref(A_MOV,opsize,helpreg,oper[1].ref^);
-                      dispose(oper[1].ref);
-                      oper[1].typ:=top_reg;
-                      oper[1].reg:=helpreg;
+                      helpins:=Taicpu.op_reg_ref(A_MOV,opsize,helpreg,oper[1]^.ref^);
+                      dispose(oper[1]^.ref);
+                      oper[1]^.typ:=top_reg;
+                      oper[1]^.reg:=helpreg;
                       list.insertafter(helpins,self);
                       rgunget(list,self,helpreg);
                     end;
@@ -2223,9 +2226,9 @@ implementation
 
             { The i386 instruction set never gets boring...
               some opcodes do not support a memory location as source }
-            if (oper[0].typ=top_ref) and
-               (oper[1].typ=top_reg) and
-               (getregtype(oper[1].reg)=R_INTREGISTER) then
+            if (oper[0]^.typ=top_ref) and
+               (oper[1]^.typ=top_reg) and
+               (getregtype(oper[1]^.reg)=R_INTREGISTER) then
               begin
                 case opcode of
                   A_BT,A_BTS,
@@ -2245,14 +2248,14 @@ implementation
                       rgget(list,Tai(previous),subreg,helpreg);
                       spill_registers:=true;
                       {First help instruction.}
-                      helpins:=Taicpu.op_ref_reg(A_MOV,opsize,oper[0].ref^,helpreg);
+                      helpins:=Taicpu.op_ref_reg(A_MOV,opsize,oper[0]^.ref^,helpreg);
                       if previous=nil then
                         list.insert(helpins)
                       else
                         list.insertafter(helpins,previous);
-                      dispose(oper[0].ref);
-                      oper[0].typ:=top_reg;
-                      oper[0].reg:=helpreg;
+                      dispose(oper[0]^.ref);
+                      oper[0]^.typ:=top_reg;
+                      oper[0]^.reg:=helpreg;
                       rgunget(list,helpins,helpreg);
                     end;
                 end;
@@ -2315,7 +2318,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.32  2003-10-17 14:38:32  peter
+  Revision 1.33  2003-10-21 15:15:36  peter
+    * taicpu_abstract.oper[] changed to pointers
+
+  Revision 1.32  2003/10/17 14:38:32  peter
     * 64k registers supported
     * fixed some memory leaks
 

+ 10 - 7
compiler/x86/agx86att.pas

@@ -176,8 +176,8 @@ interface
         AsmWrite(#9+gas_op2str[op]+cond2str[taicpu(hp).condition]);
         { suffix needed ?  fnstsw,fldcw don't support suffixes
           with binutils 2.9.5 under linux }
-{        if (Taicpu(hp).oper[0].typ=top_reg) and
-            (Taicpu(hp).oper[0].reg.enum>lastreg) then
+{        if (Taicpu(hp).oper[0]^.typ=top_reg) and
+            (Taicpu(hp).oper[0]^.reg.enum>lastreg) then
           internalerror(200301081);}
 
         if (not calljmp) and
@@ -185,8 +185,8 @@ interface
             (op<>A_FNSTSW) and (op<>A_FSTSW) and
             (op<>A_FNSTCW) and (op<>A_FSTCW) and
             (op<>A_FLDCW) and not(
-            (taicpu(hp).oper[0].typ=top_reg) and
-            (getregtype(taicpu(hp).oper[0].reg)=R_FPUREGISTER)
+            (taicpu(hp).oper[0]^.typ=top_reg) and
+            (getregtype(taicpu(hp).oper[0]^.reg)=R_FPUREGISTER)
            ) then
           AsmWrite(gas_opsize2str[taicpu(hp).opsize]);
         { process operands }
@@ -195,7 +195,7 @@ interface
             if calljmp then
              begin
                AsmWrite(#9);
-               WriteOper_jmp(taicpu(hp).oper[0]);
+               WriteOper_jmp(taicpu(hp).oper[0]^);
              end
             else
              begin
@@ -205,7 +205,7 @@ interface
                      AsmWrite(#9)
                    else
                      AsmWrite(',');
-                   WriteOper(taicpu(hp).oper[i]);
+                   WriteOper(taicpu(hp).oper[i]^);
                  end;
              end;
           end;
@@ -289,7 +289,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.8  2003-10-02 21:18:06  peter
+  Revision 1.9  2003-10-21 15:15:36  peter
+    * taicpu_abstract.oper[] changed to pointers
+
+  Revision 1.8  2003/10/02 21:18:06  peter
     * remove asw
 
   Revision 1.7  2003/10/01 20:34:50  peter

+ 6 - 2
compiler/x86/rax86.pas

@@ -661,6 +661,7 @@ begin
   ai:=taicpu.op_none(opcode,siz);
   ai.SetOperandOrder(OpOrder);
   ai.Ops:=Ops;
+  ai.Allocate_oper(Ops);
   for i:=1to Ops do
    begin
      case operands[i].opr.typ of
@@ -700,7 +701,7 @@ begin
                      asize:=OT_BITS80;
                  end;
                if asize<>0 then
-                 ai.oper[i-1].ot:=(ai.oper[i-1].ot and not OT_SIZE_MASK) or asize;
+                 ai.oper[i-1]^.ot:=(ai.oper[i-1]^.ot and not OT_SIZE_MASK) or asize;
              end;
          end;
      end;
@@ -732,7 +733,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.10  2003-10-01 20:34:51  peter
+  Revision 1.11  2003-10-21 15:15:36  peter
+    * taicpu_abstract.oper[] changed to pointers
+
+  Revision 1.10  2003/10/01 20:34:51  peter
     * procinfo unit contains tprocinfo
     * cginfo renamed to cgbase
     * moved cgmessage to verbose