Skip to content

Commit 3c6ea7b

Browse files
authored
Remove 3DNow! from X86TargetParser. (#99352)
This addresses the spurious inclusion of (now unsupported) target features '-3dnow' and '-3dnowa' when disabling mmx (when then caused log output from `clang -mno-mmx`). It should've been part of PR #96246, but was missed. Also tweaks the warning in prfchwintrin.h to not recommend the deprecated mm3dnow.h header.
1 parent 615b7ee commit 3c6ea7b

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

clang/lib/Headers/prfchwintrin.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
#if !defined(__X86INTRIN_H) && !defined(_MM3DNOW_H_INCLUDED)
11-
#error "Never use <prfchwintrin.h> directly; include <x86intrin.h> or <mm3dnow.h> instead."
11+
#error "Never use <prfchwintrin.h> directly; include <x86intrin.h> instead."
1212
#endif
1313

1414
#ifndef __PRFCHWINTRIN_H

clang/test/CodeGen/attr-target-x86.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void __attribute__((target("avx10.1-512"))) avx10_1_512(void) {}
6464
// CHECK: #4 = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87,-avx,-avx10.1-256,-avx10.1-512,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512f,-avx512fp16,-avx512ifma,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint16,-avxvnniint8,-f16c,-fma,-fma4,-sha512,-sm3,-sm4,-sse4.1,-sse4.2,-vaes,-vpclmulqdq,-xop" "tune-cpu"="i686"
6565
// CHECK: #5 = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+cmov,+crc32,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt,-aes,-avx10.1-256,-avx10.1-512,-vaes"
6666
// CHECK-NOT: tune-cpu
67-
// CHECK: #6 = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87,-3dnow,-3dnowa,-mmx"
67+
// CHECK: #6 = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87,-mmx"
6868
// CHECK: #7 = {{.*}}"target-cpu"="lakemont" "target-features"="+cx8,+mmx"
6969
// CHECK-NOT: tune-cpu
7070
// CHECK: #8 = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87" "tune-cpu"="sandybridge"

compiler-rt/lib/builtins/cpu_model/x86.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ enum ProcessorFeatures {
141141
FEATURE_AVX512VP2INTERSECT,
142142
// FIXME: Below Features has some missings comparing to gcc, it's because gcc
143143
// has some not one-to-one mapped in llvm.
144-
FEATURE_3DNOW,
144+
// FEATURE_3DNOW,
145145
// FEATURE_3DNOWP,
146146
FEATURE_ADX = 40,
147147
// FEATURE_ABM,

llvm/include/llvm/TargetParser/X86TargetParser.def

+6-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,12 @@ X86_FEATURE_COMPAT(AVX512BF16, "avx512bf16", 34)
175175
X86_FEATURE_COMPAT(AVX512VP2INTERSECT, "avx512vp2intersect", 35)
176176
// Below Features has some missings comparing to gcc, it's because gcc has some
177177
// not one-to-one mapped in llvm.
178-
X86_FEATURE_COMPAT(3DNOW, "3dnow", 0)
179-
X86_FEATURE (3DNOWA, "3dnowa")
178+
179+
// FIXME: dummy features were added to keep the numeric values of later features
180+
// stable. Since the values need to be ABI stable, they should be changed to
181+
// have explicitly assigned values, and then these dummy features removed.
182+
X86_FEATURE (DUMMYFEATURE1, "__dummyfeature1")
183+
X86_FEATURE (DUMMYFEATURE2, "__dummyfeature2")
180184
X86_FEATURE_COMPAT(ADX, "adx", 0)
181185
X86_FEATURE (64BIT, "64bit")
182186
X86_FEATURE_COMPAT(CLDEMOTE, "cldemote", 0)

llvm/lib/TargetParser/X86TargetParser.cpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,14 @@ constexpr FeatureBitset FeaturesClearwaterforest =
171171

172172
// Geode Processor.
173173
constexpr FeatureBitset FeaturesGeode =
174-
FeatureX87 | FeatureCMPXCHG8B | FeatureMMX | Feature3DNOW | Feature3DNOWA;
174+
FeatureX87 | FeatureCMPXCHG8B | FeatureMMX | FeaturePRFCHW;
175175

176176
// K6 processor.
177177
constexpr FeatureBitset FeaturesK6 = FeatureX87 | FeatureCMPXCHG8B | FeatureMMX;
178178

179179
// K7 and K8 architecture processors.
180180
constexpr FeatureBitset FeaturesAthlon =
181-
FeatureX87 | FeatureCMPXCHG8B | FeatureMMX | Feature3DNOW | Feature3DNOWA;
181+
FeatureX87 | FeatureCMPXCHG8B | FeatureMMX | FeaturePRFCHW;
182182
constexpr FeatureBitset FeaturesAthlonXP =
183183
FeaturesAthlon | FeatureFXSR | FeatureSSE;
184184
constexpr FeatureBitset FeaturesK8 =
@@ -256,8 +256,8 @@ constexpr ProcInfo Processors[] = {
256256
// i486-generation processors.
257257
{ {"i486"}, CK_i486, ~0U, FeatureX87, '\0', false },
258258
{ {"winchip-c6"}, CK_WinChipC6, ~0U, FeaturesPentiumMMX, '\0', false },
259-
{ {"winchip2"}, CK_WinChip2, ~0U, FeaturesPentiumMMX | Feature3DNOW, '\0', false },
260-
{ {"c3"}, CK_C3, ~0U, FeaturesPentiumMMX | Feature3DNOW, '\0', false },
259+
{ {"winchip2"}, CK_WinChip2, ~0U, FeaturesPentiumMMX | FeaturePRFCHW, '\0', false },
260+
{ {"c3"}, CK_C3, ~0U, FeaturesPentiumMMX | FeaturePRFCHW, '\0', false },
261261
// i586-generation processors, P5 microarchitecture based.
262262
{ {"i586"}, CK_i586, ~0U, FeatureX87 | FeatureCMPXCHG8B, '\0', false },
263263
{ {"pentium"}, CK_Pentium, ~0U, FeatureX87 | FeatureCMPXCHG8B, 'B', false },
@@ -386,8 +386,8 @@ constexpr ProcInfo Processors[] = {
386386
{ {"lakemont"}, CK_Lakemont, ~0U, FeatureCMPXCHG8B, '\0', false },
387387
// K6 architecture processors.
388388
{ {"k6"}, CK_K6, ~0U, FeaturesK6, '\0', false },
389-
{ {"k6-2"}, CK_K6_2, ~0U, FeaturesK6 | Feature3DNOW, '\0', false },
390-
{ {"k6-3"}, CK_K6_3, ~0U, FeaturesK6 | Feature3DNOW, '\0', false },
389+
{ {"k6-2"}, CK_K6_2, ~0U, FeaturesK6 | FeaturePRFCHW, '\0', false },
390+
{ {"k6-3"}, CK_K6_3, ~0U, FeaturesK6 | FeaturePRFCHW, '\0', false },
391391
// K7 architecture processors.
392392
{ {"athlon"}, CK_Athlon, ~0U, FeaturesAthlon, '\0', false },
393393
{ {"athlon-tbird"}, CK_Athlon, ~0U, FeaturesAthlon, '\0', false },
@@ -493,6 +493,7 @@ constexpr FeatureBitset ImpliedFeaturesFXSR = {};
493493
constexpr FeatureBitset ImpliedFeaturesINVPCID = {};
494494
constexpr FeatureBitset ImpliedFeaturesLWP = {};
495495
constexpr FeatureBitset ImpliedFeaturesLZCNT = {};
496+
constexpr FeatureBitset ImpliedFeaturesMMX = {};
496497
constexpr FeatureBitset ImpliedFeaturesMWAITX = {};
497498
constexpr FeatureBitset ImpliedFeaturesMOVBE = {};
498499
constexpr FeatureBitset ImpliedFeaturesMOVDIR64B = {};
@@ -520,6 +521,8 @@ constexpr FeatureBitset ImpliedFeaturesWBNOINVD = {};
520521
constexpr FeatureBitset ImpliedFeaturesVZEROUPPER = {};
521522
constexpr FeatureBitset ImpliedFeaturesX87 = {};
522523
constexpr FeatureBitset ImpliedFeaturesXSAVE = {};
524+
constexpr FeatureBitset ImpliedFeaturesDUMMYFEATURE1 = {};
525+
constexpr FeatureBitset ImpliedFeaturesDUMMYFEATURE2 = {};
523526

524527
// Not really CPU features, but need to be in the table because clang uses
525528
// target features to communicate them to the backend.
@@ -534,11 +537,6 @@ constexpr FeatureBitset ImpliedFeaturesXSAVEC = FeatureXSAVE;
534537
constexpr FeatureBitset ImpliedFeaturesXSAVEOPT = FeatureXSAVE;
535538
constexpr FeatureBitset ImpliedFeaturesXSAVES = FeatureXSAVE;
536539

537-
// MMX->3DNOW->3DNOWA chain.
538-
constexpr FeatureBitset ImpliedFeaturesMMX = {};
539-
constexpr FeatureBitset ImpliedFeatures3DNOW = FeatureMMX;
540-
constexpr FeatureBitset ImpliedFeatures3DNOWA = Feature3DNOW;
541-
542540
// SSE/AVX/AVX512F chain.
543541
constexpr FeatureBitset ImpliedFeaturesSSE = {};
544542
constexpr FeatureBitset ImpliedFeaturesSSE2 = FeatureSSE;

0 commit comments

Comments
 (0)