Skip to content

Commit 9a8d9b7

Browse files
committed
[X86][AVX10] Re-target mavx10.1 and emit warning for mavx10.x-256/512
The 256-bit maximum vector register size control was removed from AVX10 whitepaper, ref: https://cdrdv2.intel.com/v1/dl/getContent/784343 - Re-target m[no-]avx10.1 to enable AVX10.1 with 512-bit maximum vector register size; - Emit warning for m[no-]avx10.x-256, noting AVX10/256 is not supported; - Emit warning for m[no-]avx10.x-512, noting to use m[no-]avx10.x instead; This patch only changes Clang driver behavior. The features avx10.x-256/512 keep unchanged and will be removed in the next release.
1 parent a27da0a commit 9a8d9b7

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6406,11 +6406,11 @@ def mavx10_1_256 : Flag<["-"], "mavx10.1-256">, Group<m_x86_AVX10_Features_Group
64066406
def mno_avx10_1_256 : Flag<["-"], "mno-avx10.1-256">, Group<m_x86_AVX10_Features_Group>;
64076407
def mavx10_1_512 : Flag<["-"], "mavx10.1-512">, Group<m_x86_AVX10_Features_Group>;
64086408
def mno_avx10_1_512 : Flag<["-"], "mno-avx10.1-512">, Alias<mno_avx10_1_256>;
6409-
def mavx10_1 : Flag<["-"], "mavx10.1">, Flags<[Unsupported]>;
6410-
def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Flags<[Unsupported]>;
6409+
def mavx10_1 : Flag<["-"], "mavx10.1">, Group<m_x86_AVX10_Features_Group>;
6410+
def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Group<m_x86_AVX10_Features_Group>;
64116411
def mavx10_2_256 : Flag<["-"], "mavx10.2-256">, Group<m_x86_AVX10_Features_Group>;
64126412
def mavx10_2_512 : Flag<["-"], "mavx10.2-512">, Group<m_x86_AVX10_Features_Group>;
6413-
def mavx10_2 : Flag<["-"], "mavx10.2">, Alias<mavx10_2_512>;
6413+
def mavx10_2 : Flag<["-"], "mavx10.2">, Group<m_x86_AVX10_Features_Group>;
64146414
def mno_avx10_2 : Flag<["-"], "mno-avx10.2">, Group<m_x86_AVX10_Features_Group>;
64156415
def mavx2 : Flag<["-"], "mavx2">, Group<m_x86_Features_Group>;
64166416
def mno_avx2 : Flag<["-"], "mno-avx2">, Group<m_x86_Features_Group>;

clang/lib/Driver/ToolChains/Arch/X86.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,18 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
243243
assert((Version == "1" || Version == "2") && "Invalid AVX10 feature name.");
244244

245245
if (Width == "") {
246-
assert(IsNegative && "Only negative options can omit width.");
247-
Features.push_back(Args.MakeArgString("-" + Name + "-256"));
246+
if (IsNegative)
247+
Features.push_back(Args.MakeArgString("-" + Name + "-256"));
248+
else
249+
Features.push_back(Args.MakeArgString("+" + Name + "-512"));
248250
} else {
249-
assert((Width == "256" || Width == "512") && "Invalid vector length.");
251+
if (Width == "512")
252+
D.Diag(diag::warn_drv_deprecated_arg) << Name << 1 << Name.drop_back(4);
253+
else if (Width == "256")
254+
D.Diag(diag::warn_drv_deprecated_custom)
255+
<< Name << "because AVX10/256 is not supported and will be removed";
256+
else
257+
assert((Width == "256" || Width == "512") && "Invalid vector length.");
250258
Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
251259
}
252260
}

clang/test/Driver/x86-target-features.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,10 @@
395395
// EVEX512: "-target-feature" "+evex512"
396396
// NO-EVEX512: "-target-feature" "-evex512"
397397

398-
// RUN: not %clang --target=i386 -march=i386 -mavx10.1 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=UNSUPPORT-AVX10 %s
399-
// RUN: not %clang --target=i386 -march=i386 -mno-avx10.1 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=UNSUPPORT-AVX10 %s
400-
// RUN: %clang --target=i386 -mavx10.1-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_1_256 %s
401-
// RUN: %clang --target=i386 -mavx10.1-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_1_512 %s
398+
// RUN: %clang --target=i386 -march=i386 -mavx10.1 %s -### -o %t.o 2>&1 -Werror | FileCheck -check-prefix=AVX10_1_512 %s
399+
// RUN: %clang --target=i386 -march=i386 -mno-avx10.1 %s -### -o %t.o 2>&1 -Werror | FileCheck -check-prefix=NO-AVX10_1 %s
400+
// RUN: %clang --target=i386 -mavx10.1-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=AVX10_1_256,WARN-AVX10-256 %s
401+
// RUN: %clang --target=i386 -mavx10.1-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=AVX10_1_512,WARN-AVX10-512 %s
402402
// RUN: %clang --target=i386 -mavx10.1-256 -mavx10.1-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_1_512 %s
403403
// RUN: %clang --target=i386 -mavx10.1-512 -mavx10.1-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_1_256 %s
404404
// RUN: not %clang --target=i386 -march=i386 -mavx10.1-128 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=BAD-AVX10 %s
@@ -408,13 +408,15 @@
408408
// RUN: %clang --target=i386 -march=i386 -mavx10.1-256 -mno-avx512f %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10-AVX512 %s
409409
// RUN: %clang --target=i386 -march=i386 -mavx10.1-256 -mevex512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10-EVEX512 %s
410410
// RUN: %clang --target=i386 -march=i386 -mavx10.1-256 -mno-evex512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10-EVEX512 %s
411-
// RUN: %clang --target=i386 -mavx10.2 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_2_512 %s
412-
// RUN: %clang --target=i386 -mno-avx10.2 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-AVX10_2 %s
413-
// RUN: %clang --target=i386 -mavx10.2-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_2_256 %s
414-
// RUN: %clang --target=i386 -mavx10.2-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_2_512 %s
411+
// RUN: %clang --target=i386 -mavx10.2 %s -### -o %t.o 2>&1 -Werror | FileCheck -check-prefix=AVX10_2_512 %s
412+
// RUN: %clang --target=i386 -mno-avx10.2 %s -### -o %t.o 2>&1 -Werror | FileCheck -check-prefix=NO-AVX10_2 %s
413+
// RUN: %clang --target=i386 -mavx10.2-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=AVX10_2_256,WARN-AVX10-256 %s
414+
// RUN: %clang --target=i386 -mavx10.2-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=AVX10_2_512,WARN-AVX10-512 %s
415415
// RUN: %clang --target=i386 -mavx10.2-256 -mavx10.1-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=AVX10_2_256,AVX10_1_512 %s
416416
// RUN: %clang --target=i386 -mavx10.2-512 -mavx10.1-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=AVX10_2_512,AVX10_1_256 %s
417-
// UNSUPPORT-AVX10: error: unsupported option '-m{{.*}}avx10.1' for target 'i386'
417+
// WARN-AVX10-256: warning: argument 'avx10.{{.*}}-256' is deprecated, because AVX10/256 is not supported and will be removed [-Wdeprecated]
418+
// WARN-AVX10-512: warning: argument 'avx10.{{.*}}-512' is deprecated, use 'avx10.{{.*}}' instead [-Wdeprecated]
419+
// NO-AVX10_1: "-target-feature" "-avx10.1-256"
418420
// NO-AVX10_2: "-target-feature" "-avx10.2-256"
419421
// AVX10_2_256: "-target-feature" "+avx10.2-256"
420422
// AVX10_2_512: "-target-feature" "+avx10.2-512"

0 commit comments

Comments
 (0)