View Issue Details

IDProjectCategoryView StatusLast Update
0037131FPCCompilerpublic2020-05-30 13:57
ReporterChristo Crause Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0037131: AVR [patch] Replace findreg_by_gasname with gas_regname_table
DescriptionAttached patch replace itcpugas.findreg_by_gasname with generic version rgbase.findreg_by_name_table. The intention is to limit code duplication.

Similar to patch in issue 0037121 but for different target.
TagsNo tags attached.
Fixed in Revision45509
FPCOldBugId
FPCTarget-
Attached Files

Activities

Christo Crause

2020-05-23 13:46

reporter  

avr-regsearch.patch (1,830 bytes)   
Index: compiler/avr/cpubase.pas
===================================================================
--- compiler/avr/cpubase.pas	(revision 45312)
+++ compiler/avr/cpubase.pas	(working copy)
@@ -111,8 +111,6 @@
       first_mm_supreg    = RS_INVALID;
       first_mm_imreg     = 0;
 
-      regnumber_count_bsstart = 32;
-
       regnumber_table : array[tregisterindex] of tregister = (
         {$i ravrnum.inc}
       );
Index: compiler/avr/itcpugas.pas
===================================================================
--- compiler/avr/itcpugas.pas	(revision 45312)
+++ compiler/avr/itcpugas.pas	(working copy)
@@ -53,39 +53,21 @@
 implementation
 
     uses
-      cutils,verbose;
+      cutils,verbose,rgbase;
 
     const
-      gas_regname_table : array[tregisterindex] of string[7] = (
+      gas_regname_table : TRegNameTable = (
         {$i ravrstd.inc}
       );
 
-      gas_regname_index : array[tregisterindex] of tregisterindex = (
+      gas_regname_index : TRegisterIndexTable = (
         {$i ravrsri.inc}
       );
 
-    function findreg_by_gasname(const s:string):tregisterindex;
-      var
-        i,p : tregisterindex;
-      begin
-        {Binary search.}
-        p:=0;
-        i:=regnumber_count_bsstart;
-        repeat
-          if (p+i<=high(tregisterindex)) and (gas_regname_table[gas_regname_index[p+i]]<=s) then
-            p:=p+i;
-          i:=i shr 1;
-        until i=0;
-        if gas_regname_table[gas_regname_index[p]]=s then
-          findreg_by_gasname:=gas_regname_index[p]
-        else
-          findreg_by_gasname:=0;
-      end;
 
-
     function gas_regnum_search(const s:string):Tregister;
       begin
-        result:=regnumber_table[findreg_by_gasname(s)];
+        result:=regnumber_table[findreg_by_name_table(s,gas_regname_table,gas_regname_index)];
       end;
 
 
avr-regsearch.patch (1,830 bytes)   

Florian

2020-05-26 21:52

administrator   ~0123079

Thanks, applied.

Christo Crause

2020-05-30 13:57

reporter   ~0123147

Thanks

Issue History

Date Modified Username Field Change
2020-05-23 13:46 Christo Crause New Issue
2020-05-23 13:46 Christo Crause File Added: avr-regsearch.patch
2020-05-26 21:52 Florian Assigned To => Florian
2020-05-26 21:52 Florian Status new => resolved
2020-05-26 21:52 Florian Resolution open => fixed
2020-05-26 21:52 Florian Fixed in Version => 3.3.1
2020-05-26 21:52 Florian Fixed in Revision => 45509
2020-05-26 21:52 Florian FPCTarget => -
2020-05-26 21:52 Florian Note Added: 0123079
2020-05-30 13:57 Christo Crause Status resolved => closed
2020-05-30 13:57 Christo Crause Note Added: 0123147