blob: d5c2c6799b6ab8023bd467bcd2e3ea226d3689fc [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
armvixl0f35e362016-05-10 13:57:58 +010029use v5.10.1;
30no warnings 'experimental::smartmatch';
31
armvixlad96eda2013-06-14 11:42:37 +010032# Assembler header file.
armvixldb644342015-07-21 11:37:10 +010033my $hfile = "src/vixl/a64/assembler-a64.h";
armvixlad96eda2013-06-14 11:42:37 +010034
35# Extra pseudo instructions added to AArch64.
armvixlc68cb642014-09-25 18:49:30 +010036my @extras = qw/bind debug dci dc32 dc64 place/;
armvixlad96eda2013-06-14 11:42:37 +010037
38my %inst = (); # Global hash of instructions.
39
40$/ = '';
armvixl0f35e362016-05-10 13:57:58 +010041open(IN, "<$hfile") or die("Can't open header file $hfile.\n");
armvixlad96eda2013-06-14 11:42:37 +010042while(<IN>)
43{
44 # Find a function formatted like an instruction.
armvixl5289c592015-03-02 13:52:04 +000045 if(my($t) = /^ ((?:void|inline void) [a-z][a-z0-9]{0,8}_?)\(/mgp)
armvixlad96eda2013-06-14 11:42:37 +010046 {
47 my $before = ${^PREMATCH};
48 my $after = ${^POSTMATCH};
49
50 # Extract the instruction.
armvixl5289c592015-03-02 13:52:04 +000051 my($i) = $t =~ /(?:void|inline void) ([a-z][a-z0-9]{0,8})/;
armvixlad96eda2013-06-14 11:42:37 +010052
53 # Extract the comment from before the function.
54 my($d) = $before =~ /.* \/\/ ([A-Z].+?\.)$/;
55
56 # Extract and tidy up the function prototype.
57 my($p) = $after =~ /(.*?\))/ms;
58 $p =~ s/\n/\n /g;
59 $p = "$t(".$p;
60
61 # Establish the type of the instruction.
62 my $type = 'integer';
armvixl5289c592015-03-02 13:52:04 +000063 ($p =~ /VRegister/) and $type = 'float';
armvixlad96eda2013-06-14 11:42:37 +010064 ($i ~~ @extras) and $type = 'pseudo';
65
66 # Push the results into a hash keyed by prototype string.
67 $inst{$p}->{'type'} = $type;
68 $inst{$p}->{'mnemonic'} = $i;
69 $inst{$p}->{'description'} = $d;
70 }
71}
72close(IN);
73
74print <<HEADER;
75VIXL Supported Instruction List
76===============================
77
78This is a list of the AArch64 instructions supported by the VIXL assembler,
79disassembler and simulator. The simulator may not support all floating point
80operations to the precision required by AArch64 - please check the simulator
81source code for details.
82
83HEADER
84
85print describe_insts('AArch64 integer instructions', 'integer');
armvixl5289c592015-03-02 13:52:04 +000086print describe_insts('AArch64 floating point and NEON instructions', 'float');
armvixlad96eda2013-06-14 11:42:37 +010087print describe_insts('Additional or pseudo instructions', 'pseudo');
88
89# Sort instructions by mnemonic and then description.
90sub inst_sort
91{
92 $inst{$a}->{'mnemonic'} cmp $inst{$b}->{'mnemonic'} ||
armvixldb644342015-07-21 11:37:10 +010093 $inst{$a}->{'description'} cmp $inst{$b}->{'description'} ||
94 $a cmp $b;
armvixlad96eda2013-06-14 11:42:37 +010095}
96
97# Return a Markdown formatted list of instructions of a particular type.
98sub describe_insts
99{
100 my($title, $type) = @_;
101 my $result = '';
102 $result .= "$title\n";
103 $result .= '-' x length($title);
104 $result .= "\n\n";
105
106 foreach my $i (sort inst_sort keys(%inst))
107 {
108 next if($inst{$i}->{'type'} ne $type);
armvixl5289c592015-03-02 13:52:04 +0000109 $result .= sprintf("### %s ###\n\n%s\n\n",
110 uc($inst{$i}->{'mnemonic'}),
111 $inst{$i}->{'description'});
armvixlad96eda2013-06-14 11:42:37 +0100112 $result .= " $i\n\n\n";
113 }
114 $result .= "\n";
115 return $result
116}
117
118