Clean up elf symbol table section
[platform/upstream/nasm.git] / phash.pl
1 #!/usr/bin/perl
2 #
3 # Perfect Minimal Hash Generator written in Perl, which produces
4 # C output.
5 #
6
7 require 'phash.ph';
8
9 #
10 # Main program
11 #
12 sub main() {
13     my $n;
14     my %data;
15     my @hashinfo;
16     my $x, $i;
17
18     %data = read_input();
19     @hashinfo = gen_perfect_hash(\%data);
20
21     if (!defined(@hashinfo)) {
22         die "$0: no hash found\n";
23     }
24
25     verify_hash_table(\%data, \@hashinfo);
26
27     ($n, $sv, $f1, $f2, $g) = @hashinfo;
28
29     print "static int HASHNAME_fg1[$n] =\n";
30     print "{\n";
31     for ($i = 0; $i < $n; $i++) {
32         print "\t", ${$g}[${$f1}[$i]], "\n";
33     }
34     print "};\n\n";
35
36     print "static int HASHNAME_fg2[$n] =\n";
37     print "{\n";
38     for ($i = 0; $i < $n; $i++) {
39         print "\t", ${$g}[${$f2}[$i]], "\n";
40     }
41     print "};\n\n";
42
43     print "struct p_hash HASHNAME =\n";
44     print "{\n";
45     print "\t$n\n";
46     print "\t$sv\n";
47     print "\tHASHNAME_fg1,\n";
48     print "\tHASHNAME_fg2,\n";
49     print "};\n";
50 }
51
52 main();