2
$Id: mkppcreg.pp,v 1.7 2003/12/16 21:49:47 florian Exp $
3
Copyright (c) 1998-2002 by Peter Vreman and Florian Klaempfl
5
Convert ppcreg.dat to several .inc files for usage with
6
the Free pascal compiler
8
See the file COPYING.FPC, included in this distribution,
9
for details about the copyright.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
**********************************************************************}
18
const Version = '1.00';
25
regcount_bsstart:byte;
34
stabs : array[0..max_regcount-1] of string[63];
38
mot_regname_index : array[0..max_regcount-1] of byte;
41
procedure readln(var t:text;var s:string);
48
while (not eof(t)) and (c<>#10) do
57
if (i>0) and (s[i]=#13) then
63
function tostr(l : longint) : string;
69
function readstr : string;
76
while (s[i]<>',') and (i<=length(s)) do
89
writeln('Missing "," at line ',line);
90
writeln('Line: "',s,'"');
100
while (s[i] in [' ',#9]) do
104
procedure openinc(var f:text;const fn:string);
106
writeln('creating ',fn);
109
writeln(f,'{ don''t edit, this file is generated from ppcreg.dat }');
113
procedure closeinc(var f:text);
119
procedure build_regnum_index;
124
{Build the registernumber2regindex index.
126
for i:=0 to regcount-1 do
127
regnumber_index[i]:=i;
128
{Step 2: Sort. We use a Shell-Metzner sort.}
131
for h:=0 to regcount-p-1 do
136
if numbers[regnumber_index[j]]>=numbers[regnumber_index[i]] then
138
t:=regnumber_index[i];
139
regnumber_index[i]:=regnumber_index[j];
140
regnumber_index[j]:=t;
150
procedure build_std_regname_index;
155
{Build the registernumber2regindex index.
157
for i:=0 to regcount-1 do
158
std_regname_index[i]:=i;
159
{Step 2: Sort. We use a Shell-Metzner sort.}
162
for h:=0 to regcount-p-1 do
167
if stdnames[std_regname_index[j]]>=stdnames[std_regname_index[i]] then
169
t:=std_regname_index[i];
170
std_regname_index[i]:=std_regname_index[j];
171
std_regname_index[j]:=t;
182
procedure build_gas_regname_index;
187
{Build the registernumber2regindex index.
189
for i:=0 to regcount-1 do
190
gas_regname_index[i]:=i;
191
{Step 2: Sort. We use a Shell-Metzner sort.}
194
for h:=0 to regcount-p-1 do
199
if gasnames[gas_regname_index[j]]>=gasnames[gas_regname_index[i]] then
201
t:=gas_regname_index[i];
202
gas_regname_index[i]:=gas_regname_index[j];
203
gas_regname_index[j]:=t;
214
procedure build_mot_regname_index;
219
{Build the registernumber2regindex index.
221
for i:=0 to regcount-1 do
222
mot_regname_index[i]:=i;
223
{Step 2: Sort. We use a Shell-Metzner sort.}
226
for h:=0 to regcount-p-1 do
231
if motnames[mot_regname_index[j]]>=motnames[mot_regname_index[i]] then
233
t:=mot_regname_index[i];
234
mot_regname_index[i]:=mot_regname_index[j];
235
mot_regname_index[j]:=t;
246
procedure read_ppcreg_file;
252
assign(infile,'ppcreg.dat');
254
while not(eof(infile)) do
261
if (s='') or (s[1]=';') then
265
names[regcount]:=readstr;
267
regtypes[regcount]:=readstr;
269
supregs[regcount]:=readstr;
271
stdnames[regcount]:=readstr;
273
gasnames[regcount]:=readstr;
275
gssnames[regcount]:=readstr;
277
motnames[regcount]:=readstr;
279
stabs[regcount]:=readstr;
280
{ Create register number }
281
if supregs[regcount][1]<>'$' then
283
writeln('Missing $ before number, at line ',line);
284
writeln('Line: "',s,'"');
287
numbers[regcount]:=regtypes[regcount]+'0000'+copy(supregs[regcount],2,255);
290
writeln('Extra chars at end of line, at line ',line);
291
writeln('Line: "',s,'"');
295
if regcount>max_regcount then
297
writeln('Error: Too much registers, please increase maxregcount in source');
304
procedure write_inc_files;
307
norfile,stdfile,motfile,supfile,
308
numfile,stabfile,confile,gasfile,gssfile,
309
rnifile,srifile,mrifile,grifile : text;
314
openinc(confile,'rppccon.inc');
315
openinc(supfile,'rppcsup.inc');
316
openinc(numfile,'rppcnum.inc');
317
openinc(stdfile,'rppcstd.inc');
318
openinc(gasfile,'rppcgas.inc');
319
openinc(gssfile,'rppcgss.inc');
320
openinc(motfile,'rppcmot.inc');
321
openinc(stabfile,'rppcstab.inc');
322
openinc(norfile,'rppcnor.inc');
323
openinc(rnifile,'rppcrni.inc');
324
openinc(srifile,'rppcsri.inc');
325
openinc(grifile,'rppcgri.inc');
326
openinc(mrifile,'rppcmri.inc');
328
for i:=0 to regcount-1 do
332
writeln(numfile,',');
333
writeln(stdfile,',');
334
writeln(gasfile,',');
335
writeln(gssfile,',');
336
writeln(motfile,',');
337
writeln(stabfile,',');
338
writeln(rnifile,',');
339
writeln(srifile,',');
340
writeln(grifile,',');
341
writeln(mrifile,',');
345
writeln(supfile,'RS_',names[i],' = ',supregs[i],';');
346
writeln(confile,'NR_'+names[i],' = ','tregister(',numbers[i],')',';');
347
write(numfile,'tregister(',numbers[i],')');
348
write(stdfile,'''',stdnames[i],'''');
349
write(gasfile,'''',gasnames[i],'''');
350
write(gssfile,'''',gssnames[i],'''');
351
write(motfile,'''',motnames[i],'''');
352
write(stabfile,stabs[i]);
353
write(rnifile,regnumber_index[i]);
354
write(srifile,std_regname_index[i]);
355
write(grifile,gas_regname_index[i]);
356
write(mrifile,mot_regname_index[i]);
358
write(norfile,regcount);
373
writeln(regcount,' registers procesed');
378
writeln('Register Table Converter Version ',Version);
383
while 2*regcount_bsstart<regcount do
384
regcount_bsstart:=regcount_bsstart*2;
386
build_std_regname_index;
387
build_gas_regname_index;
388
build_mot_regname_index;
392
$Log: mkppcreg.pp,v $
393
Revision 1.7 2003/12/16 21:49:47 florian
394
* fixed ppc compilation
396
Revision 1.6 2003/12/10 22:19:28 florian
397
+ short gas register names for smartlinking added
399
Revision 1.5 2003/09/03 20:33:28 peter
400
* fixed sorting of register number
402
Revision 1.4 2003/09/03 19:37:07 peter
405
Revision 1.2 2003/09/03 15:55:01 peter
406
* NEWRA branch merged
408
Revision 1.1.2.1 2003/09/02 20:48:22 peter