Skip to content

Commit 575177f

Browse files
committed
[X86] Add sub-feature nf (no flags update) for APX
This is a follow-up patch for #74199
1 parent 52c5a81 commit 575177f

File tree

9 files changed

+19
-3
lines changed

9 files changed

+19
-3
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6273,9 +6273,9 @@ def mno_gather : Flag<["-"], "mno-gather">, Group<m_Group>,
62736273
def mno_scatter : Flag<["-"], "mno-scatter">, Group<m_Group>,
62746274
HelpText<"Disable generation of scatter instructions in auto-vectorization(x86 only)">;
62756275
def mapx_features_EQ : CommaJoined<["-"], "mapx-features=">, Group<m_x86_Features_Group>,
6276-
HelpText<"Enable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,cf">;
6276+
HelpText<"Enable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf">;
62776277
def mno_apx_features_EQ : CommaJoined<["-"], "mno-apx-features=">, Group<m_x86_Features_Group>,
6278-
HelpText<"Disable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,cf">;
6278+
HelpText<"Disable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf">;
62796279
// Features egpr, push2pop2, ppx and ndd are validated with llvm-test-suite && cpu2017 on Intel SDE.
62806280
// For stability, we turn on these features only for -mapxf. After a feature pass the validation,
62816281
// we will add it to -mapxf.

clang/lib/Basic/Targets/X86.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
458458
HasNDD = true;
459459
} else if (Feature == "+ccmp") {
460460
HasCCMP = true;
461+
} else if (Feature == "+nf") {
462+
HasNF = true;
461463
} else if (Feature == "+cf") {
462464
HasCF = true;
463465
}
@@ -969,6 +971,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
969971
Builder.defineMacro("__NDD__");
970972
if (HasCCMP)
971973
Builder.defineMacro("__CCMP__");
974+
if (HasNF)
975+
Builder.defineMacro("__NF__");
972976
if (HasCF)
973977
Builder.defineMacro("__CF__");
974978
// Condition here is aligned with the feature set of mapxf in Options.td
@@ -1174,6 +1178,7 @@ bool X86TargetInfo::isValidFeatureName(StringRef Name) const {
11741178
.Case("ppx", true)
11751179
.Case("ndd", true)
11761180
.Case("ccmp", true)
1181+
.Case("nf", true)
11771182
.Case("cf", true)
11781183
.Default(false);
11791184
}
@@ -1296,6 +1301,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const {
12961301
.Case("ppx", HasPPX)
12971302
.Case("ndd", HasNDD)
12981303
.Case("ccmp", HasCCMP)
1304+
.Case("nf", HasNF)
12991305
.Case("cf", HasCF)
13001306
.Default(false);
13011307
}

clang/lib/Basic/Targets/X86.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo {
173173
bool HasPPX = false;
174174
bool HasNDD = false;
175175
bool HasCCMP = false;
176+
bool HasNF = false;
176177
bool HasCF = false;
177178

178179
protected:

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
273273

274274
for (StringRef Value : A->getValues()) {
275275
if (Value == "egpr" || Value == "push2pop2" || Value == "ppx" ||
276-
Value == "ndd" || Value == "ccmp" || Value == "cf") {
276+
Value == "ndd" || Value == "ccmp" || Value == "nf" ||
277+
Value == "cf") {
277278
Features.push_back(
278279
Args.MakeArgString((IsNegative ? "-" : "+") + Value));
279280
continue;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,14 @@
436436
// RUN: %clang -target x86_64-unknown-linux-gnu -mapx-features=ppx %s -### -o %t.o 2>&1 | FileCheck -check-prefix=PPX %s
437437
// RUN: %clang -target x86_64-unknown-linux-gnu -mapx-features=ndd %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NDD %s
438438
// RUN: %clang -target x86_64-unknown-linux-gnu -mapx-features=ccmp %s -### -o %t.o 2>&1 | FileCheck -check-prefix=CCMP %s
439+
// RUN: %clang -target x86_64-unknown-linux-gnu -mapx-features=nf %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NF %s
439440
// RUN: %clang -target x86_64-unknown-linux-gnu -mapx-features=cf %s -### -o %t.o 2>&1 | FileCheck -check-prefix=CF %s
440441
// EGPR: "-target-feature" "+egpr"
441442
// PUSH2POP2: "-target-feature" "+push2pop2"
442443
// PPX: "-target-feature" "+ppx"
443444
// NDD: "-target-feature" "+ndd"
444445
// CCMP: "-target-feature" "+ccmp"
446+
// NF: "-target-feature" "+nf"
445447
// CF: "-target-feature" "+cf"
446448

447449
// RUN: %clang -target x86_64-unknown-linux-gnu -mapx-features=egpr,ndd %s -### -o %t.o 2>&1 | FileCheck -check-prefix=EGPR-NDD %s

clang/test/Preprocessor/x86_target_features.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,12 +802,14 @@
802802
// RUN: %clang -target x86_64-unknown-unknown -march=x86-64 -mapx-features=ppx -x c -E -dM -o - %s | FileCheck --check-prefix=PPX %s
803803
// RUN: %clang -target x86_64-unknown-unknown -march=x86-64 -mapx-features=ndd -x c -E -dM -o - %s | FileCheck --check-prefix=NDD %s
804804
// RUN: %clang -target x86_64-unknown-unknown -march=x86-64 -mapx-features=ccmp -x c -E -dM -o - %s | FileCheck --check-prefix=CCMP %s
805+
// RUN: %clang -target x86_64-unknown-unknown -march=x86-64 -mapx-features=nf -x c -E -dM -o - %s | FileCheck --check-prefix=NF %s
805806
// RUN: %clang -target x86_64-unknown-unknown -march=x86-64 -mapx-features=cf -x c -E -dM -o - %s | FileCheck --check-prefix=CF %s
806807
// RUN: %clang -target x86_64-unknown-unknown -march=x86-64 -mapxf -x c -E -dM -o - %s | FileCheck --check-prefixes=EGPR,PUSH2POP2,PPX,NDD,APXF %s
807808
// APXF: #define __APX_F__ 1
808809
// CCMP: #define __CCMP__ 1
809810
// CF: #define __CF__ 1
810811
// EGPR: #define __EGPR__ 1
811812
// NDD: #define __NDD__ 1
813+
// NF: #define __NF__ 1
812814
// PPX: #define __PPX__ 1
813815
// PUSH2POP2: #define __PUSH2POP2__ 1

llvm/include/llvm/TargetParser/X86TargetParser.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ X86_FEATURE_COMPAT(USERMSR, "usermsr", 0)
253253
X86_FEATURE_COMPAT(AVX10_1, "avx10.1-256", 0)
254254
X86_FEATURE_COMPAT(AVX10_1_512, "avx10.1-512", 0)
255255
X86_FEATURE (EVEX512, "evex512")
256+
X86_FEATURE (NF, "nf")
256257
X86_FEATURE (CF, "cf")
257258
// These features aren't really CPU features, but the frontend can set them.
258259
X86_FEATURE (RETPOLINE_EXTERNAL_THUNK, "retpoline-external-thunk")

llvm/lib/Target/X86/X86.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ def FeatureNDD : SubtargetFeature<"ndd", "HasNDD", "true",
351351
"Support non-destructive destination">;
352352
def FeatureCCMP : SubtargetFeature<"ccmp", "HasCCMP", "true",
353353
"Support conditional cmp & test instructions">;
354+
def FeatureNF : SubtargetFeature<"nf", "HasNF", "true",
355+
"Support status flags update suppression">;
354356
def FeatureCF : SubtargetFeature<"cf", "HasCF", "true",
355357
"Support conditional faulting">;
356358

llvm/lib/TargetParser/X86TargetParser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ constexpr FeatureBitset ImpliedFeaturesPush2Pop2 = {};
632632
constexpr FeatureBitset ImpliedFeaturesPPX = {};
633633
constexpr FeatureBitset ImpliedFeaturesNDD = {};
634634
constexpr FeatureBitset ImpliedFeaturesCCMP = {};
635+
constexpr FeatureBitset ImpliedFeaturesNF = {};
635636
constexpr FeatureBitset ImpliedFeaturesCF = {};
636637

637638
constexpr FeatureInfo FeatureInfos[X86::CPU_FEATURE_MAX] = {

0 commit comments

Comments
 (0)