#!/usr/bin/perl @types = ('int', short, long, char); @funcs = (['', vimm, '', unsigned], ['', fixed_vimm, '', unsigned], ['', vgather, 'const *', '...'], [void, vscatter, '', '*', '...'], ['', load, 'const *', unsigned, 'int'], ['', store, '', '*', 'int'], ['', vselect, 'int', '', ''], ['', extract, '', unsigned, unsigned, unsigned], ['', combine, '', '', unsigned, unsigned], ['', fixed_combine, '', unsigned, '', unsigned, unsigned, unsigned], ['', extractelement, '', unsigned], ['', combineelement, '', '', unsigned], ['', constant, '', '...'], ['', fixed_permute, '', unsigned, '', unsigned], # Older forms (for compatibility) ['', vload, 'const *', '...'], ['', vloadi, '', unsigned], [void, vstore, '', '*', '...'] ); sub resolve(@) { my ($str, $type) = @_; $str =~ s//$type/g; return $str; } sub print_decl(@) { my ($func, $type) = @_; my $ext = $type; $ext =~ s/ /_/g; #_... form print resolve($func->[0], $type); print " _$func->[1]_$ext("; for (my $i = 2; $i < $#{$func}; ++$i) { print resolve($func->[$i], $type); print ", "; } print resolve($func->[$#{$func}], $type); print ");\n"; # Alternate (newer, preferred) vllvm_... form print resolve($func->[0], $type); print " vllvm_$func->[1]_$ext("; for (my $i = 2; $i < $#{$func}; ++$i) { print resolve($func->[$i], $type); print ", "; } print resolve($func->[$#{$func}], $type); print ");\n"; if ($type =~ /unsigned\s+(\w+)/) { $ext = 'u'.$1; print resolve($func->[0], $type); print " vllvm_$func->[1]_$ext("; for (my $i = 2; $i < $#{$func}; ++$i) { print resolve($func->[$i], $type); print ", "; } print resolve($func->[$#{$func}], $type); print ");\n"; } } print "// VectorC.h\n"; print "// Header file for Vector C significant functions\n"; print "// File autogenerated by $0\n\n"; print "typedef unsigned char uchar;\n"; print "typedef unsigned short ushort;\n"; print "typedef unsigned int uint;\n"; foreach (@funcs) { my $func = $_; foreach (@types) { my $type = $_; print_decl($func, $type); print_decl($func, "unsigned ".$type); } }