* Reuse binary search routine from rgbase.pas to look up AT&T register names, removes need in regnumber_count_bsstart constant. Resolves #29471.

git-svn-id: trunk@33076 -
This commit is contained in:
sergei 2016-02-09 16:48:32 +00:00
parent fc2069eca8
commit 2861362780
4 changed files with 30 additions and 25 deletions

1
.gitattributes vendored
View File

@ -14929,6 +14929,7 @@ tests/webtbs/tw2942b.pp svneol=native#text/plain
tests/webtbs/tw2943.pp svneol=native#text/plain tests/webtbs/tw2943.pp svneol=native#text/plain
tests/webtbs/tw2944.pp svneol=native#text/plain tests/webtbs/tw2944.pp svneol=native#text/plain
tests/webtbs/tw2946.pp svneol=native#text/plain tests/webtbs/tw2946.pp svneol=native#text/plain
tests/webtbs/tw29471.pp svneol=native#text/plain
tests/webtbs/tw2949.pp svneol=native#text/plain tests/webtbs/tw2949.pp svneol=native#text/plain
tests/webtbs/tw2953.pp svneol=native#text/plain tests/webtbs/tw2953.pp svneol=native#text/plain
tests/webtbs/tw29546.pp svneol=native#text/pascal tests/webtbs/tw29546.pp svneol=native#text/pascal

View File

@ -183,9 +183,6 @@ uses
{$endif} {$endif}
const const
{ TODO: Calculate bsstart}
regnumber_count_bsstart = 64;
regnumber_table : array[tregisterindex] of tregister = ( regnumber_table : array[tregisterindex] of tregister = (
{$if defined(x86_64)} {$if defined(x86_64)}
{$i r8664num.inc} {$i r8664num.inc}

View File

@ -105,11 +105,11 @@ interface
implementation implementation
uses uses
cutils,verbose; cutils,verbose,rgbase;
const const
{$if defined(x86_64)} {$if defined(x86_64)}
att_regname_table : array[tregisterindex] of string[7] = ( att_regname_table : TRegNameTable = (
{r8664att.inc contains the AT&T name of each register.} {r8664att.inc contains the AT&T name of each register.}
{$i r8664att.inc} {$i r8664att.inc}
); );
@ -120,7 +120,7 @@ implementation
{$i r8664ari.inc} {$i r8664ari.inc}
); );
{$elseif defined(i386)} {$elseif defined(i386)}
att_regname_table : array[tregisterindex] of string[7] = ( att_regname_table : TRegNameTable = (
{r386att.inc contains the AT&T name of each register.} {r386att.inc contains the AT&T name of each register.}
{$i r386att.inc} {$i r386att.inc}
); );
@ -131,7 +131,7 @@ implementation
{$i r386ari.inc} {$i r386ari.inc}
); );
{$elseif defined(i8086)} {$elseif defined(i8086)}
att_regname_table : array[tregisterindex] of string[7] = ( att_regname_table : TRegNameTable = (
{r8086att.inc contains the AT&T name of each register.} {r8086att.inc contains the AT&T name of each register.}
{$i r8086att.inc} {$i r8086att.inc}
); );
@ -143,28 +143,11 @@ implementation
); );
{$endif} {$endif}
function findreg_by_attname(const s:string):byte;
var
i,p : tregisterindex;
begin
{Binary search.}
p:=0;
i:=regnumber_count_bsstart;
repeat
if (p+i<=high(tregisterindex)) and (att_regname_table[att_regname_index[p+i]]<=s) then
p:=p+i;
i:=i shr 1;
until i=0;
if att_regname_table[att_regname_index[p]]=s then
findreg_by_attname:=att_regname_index[p]
else
findreg_by_attname:=0;
end;
function gas_regnum_search(const s:string):Tregister; function gas_regnum_search(const s:string):Tregister;
begin begin
result:=regnumber_table[findreg_by_attname(s)]; result:=regnumber_table[findreg_by_name_table(s,att_regname_table,att_regname_index)];
end; end;

24
tests/webtbs/tw29471.pp Normal file
View File

@ -0,0 +1,24 @@
{ %cpu=x86_64 }
{ %norun }
program avxtest;
{$ASMMODE ATT}
type
TSIMDWord = packed array[0..3] of Double;
procedure SIMDAddWord(var A, B, ARes);assembler;
asm
vmovdqu (%rdi), %ymm2 // <- error 1
vmovdqu (%rsi), %ymm1
vaddpd %ymm1, %ymm2, %ymm0 // <- error 2
vmovdqu %ymm0, (%rdx)
end;
var
V1, V2, Res : TSIMDWord;
begin
SIMDAddWord(V1, V2, Res);
end.