diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-01-28 19:38:42 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-02-19 13:40:21 -0800 |
commit | b2298b7e940eccdd3af22855b8d4fce0d8049ca2 (patch) | |
tree | 4f872602195647c9a9a5696b8d666bc88235028e /util | |
parent | 8b78439980c14b776aea64b9dfdd24eb580120f1 (diff) |
qsimd_p.h: let the generator script generate the ARCH target strings
__attribute__((target("arch=xxxx"))) does not work because the compilers
(GCC at least) don't test the CPU features that they are targeting, so
we keep getting "inline failed" compiler errors.
GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90129
Upstream patch: https://github.com/opendcdiag/opendcdiag/pull/59
Change-Id: I6fcda969a9e9427198bffffd16cea09fda4406d2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-x | util/x86simdgen/3rdparty/x86simd_generate.pl | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/util/x86simdgen/3rdparty/x86simd_generate.pl b/util/x86simdgen/3rdparty/x86simd_generate.pl index a07f858dcc..bf942bea53 100755 --- a/util/x86simdgen/3rdparty/x86simd_generate.pl +++ b/util/x86simdgen/3rdparty/x86simd_generate.pl @@ -28,6 +28,7 @@ open(FH, '<', $input_conf_file) or die $!; my $i = 0; my @features; +my %feature_ids; my @architecture_names; my %architectures; my @xsaveStates; @@ -58,7 +59,7 @@ while (<FH>) { @basefeatures = @{$architectures{$based}->{allfeatures}} if $based ne "<>"; @extrafeatures = @{$architectures{$arch}{features}} if defined($architectures{$arch}); @extrafeatures = (@extrafeatures, split(',', $f)); - my @allfeatures = sort (@basefeatures, @extrafeatures); + my @allfeatures = sort { $feature_ids{$a} <=> $feature_ids{$b} } (@basefeatures, @extrafeatures); $architectures{$arch} = { name => $arch, @@ -91,6 +92,7 @@ while (<FH>) { $id =~ s/[^A-Z0-9_]/_/g; push @features, { name => $name, depends => $depends, id => $id, bit => $bit, leaf => $function, comment => $comment }; + $feature_ids{$name} = $i; ++$i; die("Too many features to fit a 64-bit integer") if $i > 64; } @@ -126,12 +128,6 @@ for (my $i = 0; $i < scalar @features; ++$i) { # Feature printf "#define cpu_feature_%-31s (UINT64_C(1) << %d)\n", lc($feature->{id}), $i; - - # Feature string names for Clang and GCC - my $str = $feature->{name} . ',' . $feature->{depends}; - $str =~ s/,$//; - printf "#define QT_FUNCTION_TARGET_STRING_%-17s \"%s\"\n", - $feature->{id}, $str; } # Print the architecture list @@ -160,6 +156,33 @@ for (@architecture_names) { print ")"; } +print "\n// __attribute__ target strings for GCC and Clang"; +for (my $i = 0; $i < scalar @features; ++$i) { + my $feature = $features[$i]; + my $str = $feature->{name} . ',' . $feature->{depends}; + $str =~ s/,$//; + printf "#define QT_FUNCTION_TARGET_STRING_%-17s \"%s\"\n", + $feature->{id}, $str; +} +for (@architecture_names) { + my $arch = $architectures{$_}; + my $base = $arch->{base}; + my $featurestr = ""; + if ($base ne "<>") { + $featurestr = "QT_FUNCTION_TARGET_STRING_ARCH_" . uc($base); + } + + my @features = @{$arch->{features}}; + #@features = map { defined($feature_ids{$_}) ? $_ : () } @features; + if (scalar @features) { + $featurestr .= ' ",' if length $featurestr; + $featurestr .= '"' unless length $featurestr; + $featurestr .= join(',', @features); + $featurestr .= '"'; + } + printf "#define QT_FUNCTION_TARGET_STRING_ARCH_%-12s %s\n", uc($arch->{id}), $featurestr; +} + print q{ static const uint64_t _compilerCpuFeatures = 0}; |