Browse Source

* replaced tdictionary with tfphashlist

git-svn-id: trunk@5148 -
peter 19 years ago
parent
commit
1684a6fc32
6 changed files with 112 additions and 143 deletions
  1. 71 80
      compiler/dbgdwarf.pas
  2. 2 10
      compiler/raatt.pas
  3. 1 1
      compiler/rasm.pas
  4. 16 21
      compiler/rautils.pas
  5. 15 16
      compiler/x86/rax86att.pas
  6. 7 15
      compiler/x86/rax86int.pas

+ 71 - 80
compiler/dbgdwarf.pas

@@ -214,7 +214,7 @@ interface
         textrecdef : tdef;
         }
 
-        dirlist: Tdictionary;
+        dirlist: TFPHashObjectList;
         filesequence: Integer;
         loclist: tdynamicarray;
         asmline: TAsmList;
@@ -533,22 +533,24 @@ implementation
     type
       { TDirIndexItem }
 
-      TDirIndexItem = class(TNamedIndexItem)
+      TDirIndexItem = class(TFPHashObject)
       private
-        FFiles: TDictionary;
+        FFiles: TFPHashObjectList;
       public
-        constructor Create(const AName: String; AIndex: Integer);
+        IndexNr : Integer;
+        constructor Create(AList:TFPHashObjectList;const AName: String; AIndex: Integer);
         destructor  Destroy;override;
-        property Files: TDictionary read FFiles;
+        property Files: TFPHashObjectList read FFiles;
       end;
 
       { TFileIndexItem }
 
-      TFileIndexItem = class(TNamedIndexItem)
+      TFileIndexItem = class(TFPHashObject)
       private
         FDirIndex: Integer;
       public
-        constructor Create(const AName: String; ADirIndex, AIndex: Integer);
+        IndexNr : Integer;
+        constructor Create(AList:TFPHashObjectList;const AName: String; ADirIndex, AIndex: Integer);
         property DirIndex: Integer read FDirIndex;
       end;
 
@@ -556,46 +558,45 @@ implementation
 {****************************************************************************
                               procs
 ****************************************************************************}
-procedure AddNamedIndexToList(p:TNamedIndexItem; arg:pointer);
-begin
-  TFPList(Arg).Add(p);
-end;
 
-function DirListSortCompare(AItem1, AItem2: Pointer): Integer;
-begin
-  Result := TDirIndexItem(AItem1).IndexNr - TDirIndexItem(AItem2).IndexNr;
-end;
+    function DirListSortCompare(AItem1, AItem2: Pointer): Integer;
+      begin
+        Result := TDirIndexItem(AItem1).IndexNr - TDirIndexItem(AItem2).IndexNr;
+      end;
+
+
+    function FileListSortCompare(AItem1, AItem2: Pointer): Integer;
+      begin
+        Result := TFileIndexItem(AItem1).IndexNr - TFileIndexItem(AItem2).IndexNr;
+      end;
 
-function FileListSortCompare(AItem1, AItem2: Pointer): Integer;
-begin
-  Result := TFileIndexItem(AItem1).IndexNr - TFileIndexItem(AItem2).IndexNr;
-end;
 
 {****************************************************************************
                               TDirIndexItem
 ****************************************************************************}
 
-    constructor TDirIndexItem.Create(const AName: String; AIndex: Integer);
-    begin
-      inherited CreateName(AName);
-      FFiles := TDictionary.Create;
-      IndexNr := AIndex;
-    end;
+    constructor TDirIndexItem.Create(AList:TFPHashObjectList;const AName: String; AIndex: Integer);
+      begin
+        inherited Create(AList,AName);
+        FFiles := TFPHashObjectList.Create;
+        IndexNr := AIndex;
+      end;
+
 
     destructor TDirIndexItem.Destroy;
-    begin
-      FFiles.Free;
-      FFiles := nil;
-      inherited Destroy;
-    end;
+      begin
+        FFiles.Free;
+        inherited Destroy;
+      end;
+
 
 {****************************************************************************
                               TFileIndexItem
 ****************************************************************************}
 
-    constructor TFileIndexItem.Create(const AName: String; ADirIndex, AIndex: Integer);
+    constructor TFileIndexItem.Create(AList:TFPHashObjectList;const AName: String; ADirIndex, AIndex: Integer);
     begin
-      inherited CreateName(Aname);
+      inherited Create(AList,Aname);
       FDirIndex := ADirIndex;
       IndexNr := AIndex;
     end;
@@ -649,9 +650,9 @@ end;
       begin
         inherited Create;
         isdwarf64 := target_cpu in [cpu_iA64,cpu_x86_64,cpu_powerpc64];
-        dirlist := tdictionary.Create;
+        dirlist := TFPHashObjectList.Create;
         { add current dir as first item (index=0) }
-        dirlist.insert(TDirIndexItem.Create('.', 0));
+        TDirIndexItem.Create(dirlist,'.', 0);
         asmline := TAsmList.create;
         loclist := tdynamicarray.Create(4096);
       end;
@@ -689,22 +690,17 @@ end;
         else
           dirname := afile.path^;
 
-        diritem := TDirIndexItem(dirlist.search(dirname));
+        diritem := TDirIndexItem(dirlist.Find(dirname));
         if diritem = nil then
-          begin
-            diritem := TDirIndexItem.Create(dirname, dirlist.Count);
-            diritem := TDirIndexItem(dirlist.insert(diritem));
-          end;
+          diritem := TDirIndexItem.Create(dirlist,dirname, dirlist.Count);
         diridx := diritem.IndexNr;
 
-        fileitem := TFileIndexItem(diritem.files.search(afile.name^));
+        fileitem := TFileIndexItem(diritem.files.Find(afile.name^));
         if fileitem = nil then
           begin
             Inc(filesequence);
-            fileitem := TFileIndexItem.Create(afile.name^, diridx, filesequence);
-            fileitem := TFileIndexItem(diritem.files.insert(fileitem));
+            fileitem := TFileIndexItem.Create(diritem.files,afile.name^, diridx, filesequence);
           end;
-
         Result := fileitem.IndexNr;
       end;
 
@@ -1944,11 +1940,11 @@ end;
       var
         templist: TAsmList;
         linelist: TAsmList;
-        lbl: tasmlabel;
-        n: Integer;
-        ditem: TDirIndexItem;
-        fitem: TFileIndexItem;
-        dlist, flist: TFPList;
+        lbl   : tasmlabel;
+        n,m   : Integer;
+        ditem : TDirIndexItem;
+        fitem : TFileIndexItem;
+        flist : TFPList;
       begin
         { insert .Ltext0 label }
         templist:=TAsmList.create;
@@ -2045,48 +2041,43 @@ end;
           { DW_LNS_set_isa }
         linelist.concat(tai_const.create_8bit(1));
 
-        { generate directory and filelist}
-        dlist := TFPList.Create;
-        flist := TFPList.Create;
+        { Create single list of filenames sorted in IndexNr }
+        flist:=TFPList.Create;
+        for n := 0 to dirlist.Count - 1 do
+          begin
+            ditem := TDirIndexItem(dirlist[n]);
+            for m := 0 to ditem.Files.Count - 1 do
+              flist.Add(ditem.Files[m]);
+          end;
+        flist.Sort(@FileListSortCompare);
 
-        dirlist.foreach_static(@AddNamedIndexToList, dlist);
-        dlist.Sort(@DirListSortCompare);
         { include_directories }
         linelist.concat(tai_comment.Create(strpnew('include_directories')));
-          { list }
-        for n := 0 to dlist.Count - 1 do
-        begin
-          ditem := TDirIndexItem(dlist[n]);
-          ditem.Files.foreach_static(@AddNamedIndexToList, flist);
-          if ditem.Name = '.' then Continue;
-
-          linelist.concat(tai_string.create(ditem.Name+#0));
-        end;
-          { end of list }
+        for n := 0 to dirlist.Count - 1 do
+          begin
+            ditem := TDirIndexItem(dirlist[n]);
+            if ditem.Name = '.' then
+              Continue;
+            linelist.concat(tai_string.create(ditem.Name+#0));
+          end;
         linelist.concat(tai_const.create_8bit(0));
 
         { file_names }
         linelist.concat(tai_comment.Create(strpnew('file_names')));
-          { list }
-        flist.Sort(@FileListSortCompare);
         for n := 0 to flist.Count - 1 do
-        begin
-          fitem := TFileIndexItem(flist[n]);
-          { file name }
-          linelist.concat(tai_string.create(fitem.Name+#0));
-          { directory index }
-          linelist.concat(tai_const.create_uleb128bit(fitem.DirIndex));
-          { last modification }
-          linelist.concat(tai_const.create_uleb128bit(0));
-          { file length }
-          linelist.concat(tai_const.create_uleb128bit(0));
-        end;
-          { end of list }
+          begin
+            fitem := TFileIndexItem(flist[n]);
+            { file name }
+            linelist.concat(tai_string.create(fitem.Name+#0));
+            { directory index }
+            linelist.concat(tai_const.create_uleb128bit(fitem.DirIndex));
+            { last modification }
+            linelist.concat(tai_const.create_uleb128bit(0));
+            { file length }
+            linelist.concat(tai_const.create_uleb128bit(0));
+          end;
         linelist.concat(tai_const.create_8bit(0));
 
-        dlist.free;
-        flist.free;
-
         { end of debug line header }
         linelist.concat(tai_symbol.createname('.Lehdebug_line0',AT_DATA,0));
         linelist.concat(tai_comment.Create(strpnew('=== header end ===')));

+ 2 - 10
compiler/raatt.pas

@@ -122,20 +122,12 @@ unit raatt;
 
 
     procedure tattreader.SetupTables;
-      { creates uppercased symbol tables for speed access }
       var
         i : tasmop;
-        str2opentry: tstr2opentry;
       Begin
-        { opcodes }
-        iasmops:=TDictionary.Create;
-        iasmops.delete_doubles:=true;
+        iasmops:=TFPHashList.create;
         for i:=firstop to lastop do
-          begin
-            str2opentry:=tstr2opentry.createname(upper(gas_op2str[i]));
-            str2opentry.op:=i;
-            iasmops.insert(str2opentry);
-          end;
+          iasmops.Add(upper(gas_op2str[i]),Pointer(PtrInt(i)));
       end;
 
 

+ 1 - 1
compiler/rasm.pas

@@ -43,7 +43,7 @@ unit rasm;
          actopcode      : tasmop;
          actasmregister : tregister;
          actcondition   : tasmcond;
-         iasmops        : tdictionary;
+         iasmops        : TFPHashList;
          constructor create;override;
          destructor destroy;override;
        end;

+ 16 - 21
compiler/rautils.pas

@@ -40,15 +40,15 @@ Const
 
 Type
   { Each local label has this structure associated with it }
-  TLocalLabel = class(TNamedIndexItem)
+  TLocalLabel = class(TFPHashObject)
     Emitted : boolean;
-    constructor Create(const n:string);
+    constructor Create(AList:TFPHashObjectList;const n:string);
     function  Gettasmlabel:tasmlabel;
   private
     lab : tasmlabel;
   end;
 
-  TLocalLabelList = class(TDictionary)
+  TLocalLabelList = class(TFPHashObjectList)
     procedure CheckEmitted;
   end;
 
@@ -122,10 +122,6 @@ type
     Procedure Swapoperands;
   end;
 
-  tstr2opentry = class(Tnamedindexitem)
-    op: TAsmOp;
-  end;
-
   {---------------------------------------------------------------------}
   {                   Expression parser types                           }
   {---------------------------------------------------------------------}
@@ -1094,9 +1090,9 @@ end;
                                  TLocalLabel
 ***************************************************************************}
 
-constructor TLocalLabel.create(const n:string);
+constructor TLocalLabel.create(AList:TFPHashObjectList;const n:string);
 begin
-  inherited CreateName(n);
+  inherited Create(AList,n);
   lab:=nil;
   emitted:=false;
 end;
@@ -1118,15 +1114,17 @@ end;
                              TLocalLabelList
 ***************************************************************************}
 
-procedure LocalLabelEmitted(p:tnamedindexitem;arg:pointer);
-begin
-  if not TLocalLabel(p).emitted  then
-   Message1(asmr_e_unknown_label_identifier,p.name);
-end;
-
 procedure TLocalLabelList.CheckEmitted;
+var
+  i : longint;
+  lab : TLocalLabel;
 begin
-  ForEach_Static(@LocalLabelEmitted,nil)
+  for i:=0 to LocalLabelList.Count-1 do
+    begin
+      lab:=TLocalLabel(LocalLabelList[i]);
+      if not lab.emitted then
+        Message1(asmr_e_unknown_label_identifier,lab.name);
+    end;
 end;
 
 
@@ -1136,12 +1134,9 @@ var
 Begin
   CreateLocalLabel:=true;
 { Check if it already is defined }
-  lab:=TLocalLabel(LocalLabellist.Search(s));
+  lab:=TLocalLabel(LocalLabellist.Find(s));
   if not assigned(lab) then
-   begin
-     lab:=TLocalLabel.Create(s);
-     LocalLabellist.Insert(lab);
-   end;
+    lab:=TLocalLabel.Create(LocalLabellist,s);
 { set emitted flag and check for dup syms }
   if emit then
    begin

+ 15 - 16
compiler/x86/rax86att.pas

@@ -731,7 +731,6 @@ Implementation
           S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_IL,S_IS,S_IQ,S_NO
         );
       var
-        str2opentry: tstr2opentry;
         cond : string[4];
         cnd  : tasmcond;
         len,
@@ -750,22 +749,22 @@ Implementation
            len:=length(s)-length(att_sizesuffixstr[sufidx]);
            if copy(s,len+1,length(att_sizesuffixstr[sufidx]))=att_sizesuffixstr[sufidx] then
             begin
-              { here we search the entire table... }
-              str2opentry:=nil;
-              if {(length(s)>0) and} (len>0) then
-                str2opentry:=tstr2opentry(iasmops.search(copy(s,1,len)));
-              if assigned(str2opentry) then
+              { Search opcodes }
+              if len>0 then
                 begin
-                  actopcode:=str2opentry.op;
-                  if gas_needsuffix[actopcode]=attsufFPU then
-                   actopsize:=att_sizefpusuffix[sufidx]
-                  else if gas_needsuffix[actopcode]=attsufFPUint then
-                   actopsize:=att_sizefpuintsuffix[sufidx]
-                  else
-                   actopsize:=att_sizesuffix[sufidx];
-                  actasmtoken:=AS_OPCODE;
-                  is_asmopcode:=TRUE;
-                  exit;
+                  actopcode:=tasmop(PtrInt(iasmops.Find(copy(s,1,len))));
+                  if actopcode<>A_NONE then
+                    begin
+                      if gas_needsuffix[actopcode]=attsufFPU then
+                       actopsize:=att_sizefpusuffix[sufidx]
+                      else if gas_needsuffix[actopcode]=attsufFPUint then
+                       actopsize:=att_sizefpuintsuffix[sufidx]
+                      else
+                       actopsize:=att_sizesuffix[sufidx];
+                      actasmtoken:=AS_OPCODE;
+                      is_asmopcode:=TRUE;
+                      exit;
+                    end;
                 end;
               { not found, check condition opcodes }
               j:=0;

+ 7 - 15
compiler/x86/rax86int.pas

@@ -135,19 +135,11 @@ Unit Rax86int;
     constructor tx86intreader.create;
       var
         i : tasmop;
-        str2opentry: tstr2opentry;
       Begin
         inherited create;
-        { opcodes }
-        { creates uppercased symbol tables for speed access }
-        iasmops:=tdictionary.create;
-        iasmops.delete_doubles:=true;
+        iasmops:=TFPHashList.create;
         for i:=firstop to lastop do
-          begin
-            str2opentry:=tstr2opentry.createname(upper(std_op2str[i]));
-            str2opentry.op:=i;
-            iasmops.insert(str2opentry);
-          end;
+          iasmops.Add(upper(std_op2str[i]),Pointer(PtrInt(i)));
       end;
 
 
@@ -158,7 +150,6 @@ Unit Rax86int;
 
      function tx86intreader.is_asmopcode(const s: string):boolean;
        var
-         str2opentry: tstr2opentry;
          cond : string[4];
          cnd : tasmcond;
          j: longint;
@@ -169,14 +160,15 @@ Unit Rax86int;
          actcondition:=C_None;
          actopsize:=S_NO;
 
-         str2opentry:=tstr2opentry(iasmops.search(s));
-         if assigned(str2opentry) then
+         { Search opcodes }
+         actopcode:=tasmop(PtrInt(iasmops.Find(s)));
+         if actopcode<>A_NONE then
            begin
-             actopcode:=str2opentry.op;
              actasmtoken:=AS_OPCODE;
-             is_asmopcode:=TRUE;
+             result:=TRUE;
              exit;
            end;
+           
          { not found yet, check condition opcodes }
          j:=0;
          while (j<CondAsmOps) do