+ use of a dictionary object

for faster opcode searching in assembler readers
    implemented by Kovacs Attila Zoltan
This commit is contained in:
pierre 2000-05-12 21:57:02 +00:00
parent 5f4ec1b1ff
commit cff91a51a2
3 changed files with 51 additions and 20 deletions

View File

@ -196,6 +196,11 @@ type
op2strtable=array[tasmop] of string[11];
pstr2opentry = ^tstr2opentry;
tstr2opentry = object(Tnamedindexobject)
op: TAsmOp;
end;
const
firstop = low(tasmop);
lastop = high(tasmop);
@ -902,7 +907,12 @@ end;
end.
{
$Log$
Revision 1.28 2000-05-10 19:09:07 pierre
Revision 1.29 2000-05-12 21:57:02 pierre
+ use of a dictionary object
for faster opcode searching in assembler readers
implemented by Kovacs Attila Zoltan
Revision 1.28 2000/05/10 19:09:07 pierre
* op2strtable string length changed to 11
Thanks to Kovacs Attila Zoltan
this should be set by nasmconv utility !

View File

@ -96,7 +96,7 @@ var
actasmregister : tregister;
actopsize : topsize;
actcondition : tasmcond;
iasmops : ^op2strtable;
iasmops : Pdictionary;
iasmregs : ^reg2strtable;
@ -105,11 +105,16 @@ Procedure SetupTables;
var
i : tasmop;
j : tregister;
str2opentry: pstr2opentry;
Begin
{ opcodes }
new(iasmops);
new(iasmops,init);
for i:=firstop to lastop do
iasmops^[i] := upper(att_op2str[i]);
begin
new(str2opentry,initname(upper(att_op2str[i])));
str2opentry^.op:=i;
iasmops^.insert(str2opentry);
end;
{ registers }
new(iasmregs);
for j:=firstreg to lastreg do
@ -138,13 +143,13 @@ const
S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_IL,S_IS,S_IQ,S_NO
);
var
str2opentry: pstr2opentry;
i : tasmop;
cond : string[4];
cnd : tasmcond;
len,
j,
sufidx : longint;
hid : string;
Begin
is_asmopcode:=FALSE;
@ -159,11 +164,12 @@ Begin
if copy(s,len+1,length(att_sizesuffixstr[sufidx]))=att_sizesuffixstr[sufidx] then
begin
{ here we search the entire table... }
hid:=copy(s,1,len);
for i:=firstop to lastop do
if (length(hid) > 0) and (hid=iasmops^[i]) then
str2opentry:=nil;
if {(length(s)>0) and} (len>0) then
str2opentry:=pstr2opentry(iasmops^.search(copy(s,1,len)));
if assigned(str2opentry) then
begin
actopcode:=i;
actopcode:=str2opentry^.op;
if att_needsuffix[actopcode]=attsufFPU then
actopsize:=att_sizefpusuffix[sufidx]
else if att_needsuffix[actopcode]=attsufFPUint then
@ -1982,7 +1988,7 @@ var
procedure ra386att_exit;{$ifndef FPC}far;{$endif}
begin
if assigned(iasmops) then
dispose(iasmops);
dispose(iasmops,done);
if assigned(iasmregs) then
dispose(iasmregs);
exitproc:=old_exit;
@ -1995,7 +2001,12 @@ begin
end.
{
$Log$
Revision 1.77 2000-05-11 09:56:21 pierre
Revision 1.78 2000-05-12 21:57:02 pierre
+ use of a dictionary object
for faster opcode searching in assembler readers
implemented by Kovacs Attila Zoltan
Revision 1.77 2000/05/11 09:56:21 pierre
* fixed several compare problems between longints and
const > $80000000 that are treated as int64 constanst
by Delphi reported by Kovacs Attila Zoltan

View File

@ -113,7 +113,7 @@ var
actopcode : tasmop;
actopsize : topsize;
actcondition : tasmcond;
iasmops : ^op2strtable;
iasmops : Pdictionary;
iasmregs : ^reg2strtable;
@ -122,11 +122,16 @@ Procedure SetupTables;
var
i : tasmop;
j : tregister;
str2opentry: pstr2opentry;
Begin
{ opcodes }
new(iasmops);
new(iasmops,init);
for i:=firstop to lastop do
iasmops^[i] := upper(int_op2str[i]);
begin
new(str2opentry,initname(upper(int_op2str[i])));
str2opentry^.op:=i;
iasmops^.insert(str2opentry);
end;
{ registers }
new(iasmregs);
for j:=firstreg to lastreg do
@ -141,7 +146,7 @@ end;
function is_asmopcode(const s: string):boolean;
var
i: tasmop;
str2opentry: pstr2opentry;
cond : string[4];
cnd : tasmcond;
j: longint;
@ -152,10 +157,10 @@ end;
actcondition:=C_None;
actopsize:=S_NO;
for i:=firstop to lastop do
if s=iasmops^[i] then
str2opentry:=pstr2opentry(iasmops^.search(s));
if assigned(str2opentry) then
begin
actopcode:=i;
actopcode:=str2opentry^.op;
actasmtoken:=AS_OPCODE;
is_asmopcode:=TRUE;
exit;
@ -1815,7 +1820,7 @@ var
procedure ra386int_exit;{$ifndef FPC}far;{$endif}
begin
if assigned(iasmops) then
dispose(iasmops);
dispose(iasmops,done);
if assigned(iasmregs) then
dispose(iasmregs);
exitproc:=old_exit;
@ -1828,7 +1833,12 @@ begin
end.
{
$Log$
Revision 1.68 2000-05-12 21:26:23 pierre
Revision 1.69 2000-05-12 21:57:02 pierre
+ use of a dictionary object
for faster opcode searching in assembler readers
implemented by Kovacs Attila Zoltan
Revision 1.68 2000/05/12 21:26:23 pierre
* fix the FDIV FDIVR FSUB FSUBR and popping equivalent
simply by swapping from reverse to normal and vice-versa
when passing from one syntax to the other !