[fpc-devel] Different versions of register name search algorithms used
Sven Barth
pascaldragon at googlemail.com
Thu May 21 17:22:00 CEST 2020
Am 20.05.2020 um 18:09 schrieb Christo Crause via fpc-devel:
> While trying to understand bug 0037121I noticed that the predominant
> search algorithm used for finding register names is a binary search
> without a match check. My understanding of this algorithm is that it
> will always run the maximum iterations for the search space before
> terminating. To understand how this is supposed to work I looked at
> other target implementations. I realized that this algorithm is used
> in all but 2 cases: x86 (in itx86int.pas) which uses (what I consider
> to be) a conventional binary search, and mips which uses a linear search.
>
> I don't see a need to have different algorithms for performing what
> appears to be the same function (search for a string in a sorted list
> of strings), is this correct?
>
> Then, I don't understand why the general search algorithm isn't the
> one in itx86int.pas. Is there a compelling reason for preferring the
> 1st algorithm over the conventional binary search?
>
> Thirdly, each target has its own implementation of findreg_by_XXXname,
> is there a reason not to have a single search function shared by all
> targets? This may require some renaming of current variable lists
> such as gas_regname_index and int_regname_index etc. to a common
> convention.
>
> Your thoughts on these questions would be appreciated.
There is a general implementation of the search algorithm in rgbase
which is already used for example by x86/itcpugas.pas as well as
z80/cpubase.pas. So in my opinion the way to go would be to switch the
other targets (as well as x86/itx86int.pas) to use this as well.
Regards,
Sven
More information about the fpc-devel
mailing list