1 #!/usr/bin/perl 2 3 # Copyright 2015, ARM Limited 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 29 # Assembler header file. 30 my $hfile = "src/vixl/a64/assembler-a64.h"; 31 32 # Extra pseudo instructions added to AArch64. 33 my @extras = qw/bind debug dci dc32 dc64 place/; 34 35 my %inst = (); # Global hash of instructions. 36 37 $/ = ''; 38 open(IN, "<$hfile") or die("Can't open header file $header.\n"); 39 while(<IN>) 40 { 41 # Find a function formatted like an instruction. 42 if(my($t) = /^ ((?:void|inline void) [a-z][a-z0-9]{0,8}_?)\(/mgp) 43 { 44 my $before = ${^PREMATCH}; 45 my $after = ${^POSTMATCH}; 46 47 # Extract the instruction. 48 my($i) = $t =~ /(?:void|inline void) ([a-z][a-z0-9]{0,8})/; 49 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'; 60 ($p =~ /VRegister/) and $type = 'float'; 61 ($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 } 69 close(IN); 70 71 print <<HEADER; 72 VIXL Supported Instruction List 73 =============================== 74 75 This is a list of the AArch64 instructions supported by the VIXL assembler, 76 disassembler and simulator. The simulator may not support all floating point 77 operations to the precision required by AArch64 - please check the simulator 78 source code for details. 79 80 HEADER 81 82 print describe_insts('AArch64 integer instructions', 'integer'); 83 print describe_insts('AArch64 floating point and NEON instructions', 'float'); 84 print describe_insts('Additional or pseudo instructions', 'pseudo'); 85 86 # Sort instructions by mnemonic and then description. 87 sub inst_sort 88 { 89 $inst{$a}->{'mnemonic'} cmp $inst{$b}->{'mnemonic'} || 90 $inst{$a}->{'description'} cmp $inst{$b}->{'description'} || 91 $a cmp $b; 92 } 93 94 # Return a Markdown formatted list of instructions of a particular type. 95 sub describe_insts 96 { 97 my($title, $type) = @_; 98 my $result = ''; 99 $result .= "$title\n"; 100 $result .= '-' x length($title); 101 $result .= "\n\n"; 102 103 foreach my $i (sort inst_sort keys(%inst)) 104 { 105 next if($inst{$i}->{'type'} ne $type); 106 $result .= sprintf("### %s ###\n\n%s\n\n", 107 uc($inst{$i}->{'mnemonic'}), 108 $inst{$i}->{'description'}); 109 $result .= " $i\n\n\n"; 110 } 111 $result .= "\n"; 112 return $result 113 } 114 115 116