b96b364827e4cbe19b93f75e8213f8fbb42229bf
5 numfiles
= int(sys
.argv
[1])
6 tablesz
= int(sys
.argv
[2])
9 filenum
= int(sys
.argv
[1])
10 numfiles
= int(sys
.argv
[2])
11 tablesz
= int(sys
.argv
[3])
16 for line
in sys
.stdin
:
17 (name
, mtch
, msk
) = line
.split('(')[1].split(')')[0].split(',')
18 match
[name
] = int(mtch
,16)
19 mask
[name
] = int(msk
,16)
22 for name
in match
.iterkeys():
23 if (mask
[name
] & (tablesz
-1)) == mask
[name
]:
24 for i
in range(match
[name
]+1, tablesz
):
25 if (i
& mask
[name
]) == match
[name
]:
26 redundant
[i
] = match
[name
]
29 for i
in range(0, tablesz
):
31 for name
in match
.iterkeys():
32 if match
[name
] % tablesz
== (i
& mask
[name
]):
34 if not used
and illegal
== -1:
37 redundant
[i
] = illegal
39 if filenum
== numfiles
:
40 print '#include "processor.h"'
41 print 'const insn_func_t processor_t::dispatch_table[DISPATCH_TABLE_SIZE] = {'
42 for i
in range(0, tablesz
):
46 print ' &processor_t::insn_func_%d,' % func
49 if filenum
== numfiles
+1:
50 print 'static const size_t DISPATCH_TABLE_SIZE = %d;' % tablesz
51 print 'static const insn_func_t dispatch_table[DISPATCH_TABLE_SIZE];'
52 for i
in range(0, tablesz
):
53 if i
not in redundant
:
54 print 'reg_t insn_func_%d(insn_t insn, reg_t reg);' % i
57 print '#include "insn_header.h"'
59 for i
in range(0, tablesz
):
60 if i
% numfiles
!= filenum
or i
in redundant
:
63 print 'reg_t processor_t::insn_func_%d(insn_t insn, reg_t pc)' % i
65 for name
in match
.iterkeys():
66 if match
[name
] % tablesz
== (i
& mask
[name
]):
67 print ' if((insn.bits & 0x%x) == 0x%x)' % (mask
[name
] & ~
(tablesz
-1), \
68 match
[name
] & ~
(tablesz
-1))
70 print ' reg_t npc = pc + insn_length(0x%x);' % match
[name
]
71 print ' #include "insns/%s.h"' % name
76 print ' throw trap_illegal_instruction;'