rbtree: add rb_search_exact()
[nasm.git] / doc / inslist.pl
blobc7d7da40783b8ef0a642d5b2aaec5fa4095f70b3
1 #!/usr/bin/perl
2 ## --------------------------------------------------------------------------
3 ##
4 ## Copyright 1996-2017 The NASM Authors - All Rights Reserved
5 ## See the file AUTHORS included with the NASM distribution for
6 ## the specific copyright holders.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted provided that the following
10 ## conditions are met:
12 ## * Redistributions of source code must retain the above copyright
13 ## notice, this list of conditions and the following disclaimer.
14 ## * Redistributions in binary form must reproduce the above
15 ## copyright notice, this list of conditions and the following
16 ## disclaimer in the documentation and/or other materials provided
17 ## with the distribution.
18 ##
19 ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
20 ## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21 ## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 ## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 ## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 ## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 ## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31 ## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ## --------------------------------------------------------------------------
36 # inslist.pl produce inslist.src
39 print STDERR "Reading insns.dat...\n";
41 @args = ();
42 undef $output;
43 foreach $arg ( @ARGV ) {
44 if ( $arg =~ /^\-/ ) {
45 if ( $arg =~ /^\-([adins])$/ ) {
46 $output = $1;
47 } else {
48 die "$0: Unknown option: ${arg}\n";
50 } else {
51 push (@args, $arg);
55 $fname = "../insns.dat" unless $fname = $args[0];
56 open (F, '<', $fname) || die "unable to open $fname";
57 print STDERR "Writing inslist.src...\n";
58 open S, '>', 'inslist.src';
59 $line = 0;
60 $insns = 0;
61 while (<F>) {
62 $line++;
63 next if (/^\s*$/); # blank lines
64 if ( /^\s*;/ ) # comments
66 if ( /^\s*;\#\s*(.+)/ ) # section subheader
68 print S "\n\\S{} $1\n\n";
70 next;
72 chomp;
73 unless (/^\s*(\S+)\s+(\S+)\s+(\S+|\[.*\])\s+(\S+)\s*$/) {
74 warn "line $line does not contain four fields\n";
75 next;
77 my @entry = ($1, $2, $3, $4);
79 $entry[1] =~ s/ignore//;
80 $entry[1] =~ s/void//;
82 my @flags = split(/,/, $entry[3]);
83 my @nflags;
84 undef $isavx512;
85 undef @avx512fl;
86 for my $fl (@flags) {
87 next if ($fl =~ /^(ignore|SB|SM|SM2|SQ|AR2|FUTURE)$/);
89 if ($fl =~ /^AVX512(.*)$/) {
90 $isavx512 = 1;
91 push(@avx512fl, $1) unless ($1 eq '');
92 } else {
93 push(@nflags,$fl);
97 if ($isavx512) {
98 unshift(@nflags, "AVX512".join('/', @avx512fl));
101 printf S "\\c %-16s %-24s %s\n",$entry[0],$entry[1], join(',', @nflags);
102 $insns++;
104 print S "\n";
105 close S;
106 close F;
107 printf STDERR "Done: %d instructions\n", $insns;