NASM 2.04rc4
[nasm/avx512.git] / phash.pl
blob03f500f3d9b0dcf144d819f81695276950ace685
1 #!/usr/bin/perl
3 # Perfect Minimal Hash Generator written in Perl, which produces
4 # C output.
7 require 'phash.ph';
10 # Main program
12 sub main() {
13 my $n;
14 my %data;
15 my @hashinfo;
16 my $x, $i;
18 %data = read_input();
19 @hashinfo = gen_perfect_hash(\%data);
21 if (!defined(@hashinfo)) {
22 die "$0: no hash found\n";
25 verify_hash_table(\%data, \@hashinfo);
27 ($n, $sv, $f1, $f2, $g) = @hashinfo;
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";
34 print "};\n\n";
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";
41 print "};\n\n";
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";
52 main();