• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/perl
2
3# Copyright 2015, VIXL authors
4# 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
29use v5.10.1;
30no warnings 'experimental::smartmatch';
31
32# Assembler header file.
33my $hfile = "src/aarch64/assembler-aarch64.h";
34
35# Extra pseudo instructions added to AArch64.
36my @extras = qw/bind debug dci dc32 dc64 place/;
37
38my %inst = ();  # Global hash of instructions.
39
40# Set record separator to one or more consecutive new lines. This causes $_ to
41# be assigned a 'paragraph' of text for each iteration of the while loop.
42$/ = '';
43
44open(IN, "<$hfile") or die("Can't open header file $hfile.\n");
45while(<IN>)
46{
47  # Find a function formatted like an instruction.
48  if(my($t) = /^  ((?:void|inline void) [a-z][a-z0-9]{0,8}_?)\(/mgp)
49  {
50    # Everything before the function match, ie. the comments.
51    my $before = ${^PREMATCH};
52
53    # Everything after the function match, ie. arguments to the function, if
54    # any, and the closing parenthesis and semi-colon.
55    my $after = ${^POSTMATCH};
56
57    # Extract the instruction.
58    my($i) = $t =~ /(?:void|inline void) ([a-z][a-z0-9]{0,8})/;
59
60    # Extract the comment from before the function. Drop comment characters
61    # and format the architecture version suffix, if present.
62    my $d = $before;
63    $d =~ s|^  // ||;   # Delete comment chars from first line.
64    $d =~ s|\n  //||g;  # Delete comment chars from subsequent lines.
65    $d =~ s|\n$||;      # Delete trailing new line.
66    $d =~ s|\[Armv(.+)\]|_\(Armv$1\)_|gi;
67
68    # Drop any templating that may have prefixed the prototype, and has now
69    # found its way into the description.
70    $d =~ s|\n  template <.*>$||g;
71
72    # Extract and tidy up the function prototype.
73    my($p) = $after =~ /(.*?\))/ms;
74    $p =~ s/\n/\n  /g;
75    $p = "$t(".$p;
76
77    # Establish the type of the instruction.
78    my $type = 'integer';
79    ($p =~ /VRegister/) and $type = 'float';
80    ($i ~~ @extras) and $type = 'pseudo';
81
82    # Special case to distinguish dc() the data constant placing function from
83    # dc() the data cache maintenance instruction.
84    if (($i eq 'dc') and ($p =~ /\(T data\)/)) {
85      $type = 'pseudo';
86    }
87
88    # Push the results into a hash keyed by prototype string.
89    $inst{$p}->{'type'} = $type;
90    $inst{$p}->{'mnemonic'} = $i;
91    $inst{$p}->{'description'} = $d;
92  }
93}
94close(IN);
95
96print <<HEADER;
97VIXL Supported Instruction List
98===============================
99
100This is a list of the AArch64 instructions supported by the VIXL assembler,
101disassembler and simulator. The simulator may not support all floating point
102operations to the precision required by AArch64 - please check the simulator
103source code for details.
104
105HEADER
106
107print describe_insts('AArch64 integer instructions', 'integer');
108print describe_insts('AArch64 floating point and NEON instructions', 'float');
109print describe_insts('Additional or pseudo instructions', 'pseudo');
110
111# Sort instructions by mnemonic and then description.
112sub inst_sort
113{
114  $inst{$a}->{'mnemonic'} cmp $inst{$b}->{'mnemonic'} ||
115  $inst{$a}->{'description'} cmp $inst{$b}->{'description'} ||
116  $a cmp $b;
117}
118
119# Return a Markdown formatted list of instructions of a particular type.
120sub describe_insts
121{
122  my($title, $type) = @_;
123  my $result = '';
124  $result .= "$title\n";
125  $result .= '-' x length($title);
126  $result .= "\n\n";
127
128  foreach my $i (sort inst_sort keys(%inst))
129  {
130    next if($inst{$i}->{'type'} ne $type);
131    $result .= sprintf("### %s ###\n\n%s\n\n",
132                       uc($inst{$i}->{'mnemonic'}),
133                       $inst{$i}->{'description'});
134    $result .= "    $i\n\n\n";
135  }
136  $result .= "\n";
137  return $result
138}
139
140
141