blob: 192de96a8dba4cda5f938bc311eccf46caf6c7fb [file] [log] [blame]
armvixlad96eda2013-06-14 11:42:37 +01001#!/usr/bin/perl
2
armvixl5289c592015-03-02 13:52:04 +00003# Copyright 2015, ARM Limited
armvixlad96eda2013-06-14 11:42:37 +01004# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are met:
8#
9# * Redistributions of source code must retain the above copyright notice,
10# this list of conditions and the following disclaimer.
11# * Redistributions in binary form must reproduce the above copyright notice,
12# this list of conditions and the following disclaimer in the documentation
13# and/or other materials provided with the distribution.
14# * Neither the name of ARM Limited nor the names of its contributors may be
15# used to endorse or promote products derived from this software without
16# specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
19# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29# Assembler header file.
30my $hfile = "src/a64/assembler-a64.h";
31
32# Extra pseudo instructions added to AArch64.
armvixlc68cb642014-09-25 18:49:30 +010033my @extras = qw/bind debug dci dc32 dc64 place/;
armvixlad96eda2013-06-14 11:42:37 +010034
35my %inst = (); # Global hash of instructions.
36
37$/ = '';
38open(IN, "<$hfile") or die("Can't open header file $header.\n");
39while(<IN>)
40{
41 # Find a function formatted like an instruction.
armvixl5289c592015-03-02 13:52:04 +000042 if(my($t) = /^ ((?:void|inline void) [a-z][a-z0-9]{0,8}_?)\(/mgp)
armvixlad96eda2013-06-14 11:42:37 +010043 {
44 my $before = ${^PREMATCH};
45 my $after = ${^POSTMATCH};
46
47 # Extract the instruction.
armvixl5289c592015-03-02 13:52:04 +000048 my($i) = $t =~ /(?:void|inline void) ([a-z][a-z0-9]{0,8})/;
armvixlad96eda2013-06-14 11:42:37 +010049
50 # Extract the comment from before the function.
51 my($d) = $before =~ /.* \/\/ ([A-Z].+?\.)$/;
52
53 # Extract and tidy up the function prototype.
54 my($p) = $after =~ /(.*?\))/ms;
55 $p =~ s/\n/\n /g;
56 $p = "$t(".$p;
57
58 # Establish the type of the instruction.
59 my $type = 'integer';
armvixl5289c592015-03-02 13:52:04 +000060 ($p =~ /VRegister/) and $type = 'float';
armvixlad96eda2013-06-14 11:42:37 +010061 ($i ~~ @extras) and $type = 'pseudo';
62
63 # Push the results into a hash keyed by prototype string.
64 $inst{$p}->{'type'} = $type;
65 $inst{$p}->{'mnemonic'} = $i;
66 $inst{$p}->{'description'} = $d;
67 }
68}
69close(IN);
70
71print <<HEADER;
72VIXL Supported Instruction List
73===============================
74
75This is a list of the AArch64 instructions supported by the VIXL assembler,
76disassembler and simulator. The simulator may not support all floating point
77operations to the precision required by AArch64 - please check the simulator
78source code for details.
79
80HEADER
81
82print describe_insts('AArch64 integer instructions', 'integer');
armvixl5289c592015-03-02 13:52:04 +000083print describe_insts('AArch64 floating point and NEON instructions', 'float');
armvixlad96eda2013-06-14 11:42:37 +010084print describe_insts('Additional or pseudo instructions', 'pseudo');
85
86# Sort instructions by mnemonic and then description.
87sub inst_sort
88{
89 $inst{$a}->{'mnemonic'} cmp $inst{$b}->{'mnemonic'} ||
90 $inst{$a}->{'description'} cmp $inst{$b}->{'description'};
91}
92
93# Return a Markdown formatted list of instructions of a particular type.
94sub describe_insts
95{
96 my($title, $type) = @_;
97 my $result = '';
98 $result .= "$title\n";
99 $result .= '-' x length($title);
100 $result .= "\n\n";
101
102 foreach my $i (sort inst_sort keys(%inst))
103 {
104 next if($inst{$i}->{'type'} ne $type);
armvixl5289c592015-03-02 13:52:04 +0000105 $result .= sprintf("### %s ###\n\n%s\n\n",
106 uc($inst{$i}->{'mnemonic'}),
107 $inst{$i}->{'description'});
armvixlad96eda2013-06-14 11:42:37 +0100108 $result .= " $i\n\n\n";
109 }
110 $result .= "\n";
111 return $result
112}
113
114