View Issue Details

IDProjectCategoryView StatusLast Update
0037121FPCCompilerpublic2020-05-23 11:04
ReporterChristo Crause Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilitysometimes
Status closedResolutionfixed 
Product Version3.3.1 
Summary0037121: Xtensa [patch] Assembler register search doesn't always find valid register name
DescriptionCompiling the code below generates an error: Error: Unknown identifier "B9".

The current regnumber_count_bsstart value is an inappropriate starting value for the binary search in findreg_by_gasname. The attached patch changes this value to 32.
Steps To Reproduceunit asmtest;

interface

procedure test;

implementation

procedure test; assembler;
label
  lbl;
asm
lbl:
  bt b9, lbl
end;

end.
TagsNo tags attached.
Fixed in Revision45467
FPCOldBugId
FPCTarget-
Attached Files

Activities

Christo Crause

2020-05-20 17:22

reporter  

regsearch.patch (430 bytes)   
Index: xtensa/cpubase.pas
===================================================================
--- xtensa/cpubase.pas	(revision 45312)
+++ xtensa/cpubase.pas	(working copy)
@@ -88,7 +88,7 @@
       first_flag_imreg     = $10;
 
       { TODO: Calculate bsstart}
-      regnumber_count_bsstart = 16;
+      regnumber_count_bsstart = 32;
 
       regnumber_table : array[tregisterindex] of tregister = (
         {$i rxtensanum.inc}
regsearch.patch (430 bytes)   

Christo Crause

2020-05-21 19:33

reporter   ~0122991

Following Sven's mailling list suggestion I changed the patch to rather call the generic search function in rgbase and delete the implementation in itcpugas. This also eliminates the regnumber_count_bsstart constant which caused the issue to start with.
regsearch2.patch (1,472 bytes)   
Index: xtensa/cpubase.pas
===================================================================
--- xtensa/cpubase.pas	(revision 45312)
+++ xtensa/cpubase.pas	(working copy)
@@ -87,9 +87,6 @@
       { firs flag imaginary register }
       first_flag_imreg     = $10;
 
-      { TODO: Calculate bsstart}
-      regnumber_count_bsstart = 16;
-
       regnumber_table : array[tregisterindex] of tregister = (
         {$i rxtensanum.inc}
       );
Index: xtensa/itcpugas.pas
===================================================================
--- xtensa/itcpugas.pas	(revision 45312)
+++ xtensa/itcpugas.pas	(working copy)
@@ -54,28 +54,9 @@
         {$i rxtensasri.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;
 
 
regsearch2.patch (1,472 bytes)   

Florian

2020-05-22 22:55

administrator   ~0123008

Thanks, applied.

Christo Crause

2020-05-23 11:04

reporter   ~0123010

Thanks!

Issue History

Date Modified Username Field Change
2020-05-20 17:22 Christo Crause New Issue
2020-05-20 17:22 Christo Crause File Added: regsearch.patch
2020-05-21 19:33 Christo Crause Note Added: 0122991
2020-05-21 19:33 Christo Crause File Added: regsearch2.patch
2020-05-22 22:55 Florian Assigned To => Florian
2020-05-22 22:55 Florian Status new => resolved
2020-05-22 22:55 Florian Resolution open => fixed
2020-05-22 22:55 Florian Fixed in Revision => 45467
2020-05-22 22:55 Florian FPCTarget => -
2020-05-22 22:55 Florian Note Added: 0123008
2020-05-23 11:04 Christo Crause Status resolved => closed
2020-05-23 11:04 Christo Crause Note Added: 0123010