diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3254,6 +3254,8 @@ def mno_altivec : Flag<["-"], "mno-altivec">, Group; def mpcrel: Flag<["-"], "mpcrel">, Group; def mno_pcrel: Flag<["-"], "mno-pcrel">, Group; +def mprefixed: Flag<["-"], "mprefixed">, Group; +def mno_prefixed: Flag<["-"], "mno-prefixed">, Group; def mspe : Flag<["-"], "mspe">, Group; def mno_spe : Flag<["-"], "mno-spe">, Group; def mefpu2 : Flag<["-"], "mefpu2">, Group; diff --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h --- a/clang/lib/Basic/Targets/PPC.h +++ b/clang/lib/Basic/Targets/PPC.h @@ -73,6 +73,7 @@ bool PairedVectorMemops = false; bool HasP10Vector = false; bool HasPCRelativeMemops = false; + bool HasPrefixInstrs = false; protected: std::string ABI; diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp --- a/clang/lib/Basic/Targets/PPC.cpp +++ b/clang/lib/Basic/Targets/PPC.cpp @@ -56,6 +56,8 @@ HasP10Vector = true; } else if (Feature == "+pcrelative-memops") { HasPCRelativeMemops = true; + } else if (Feature == "+prefix-instrs") { + HasPrefixInstrs = true; } else if (Feature == "+spe" || Feature == "+efpu2") { HasSPE = true; LongDoubleWidth = LongDoubleAlign = 64; @@ -394,6 +396,7 @@ Features["mma"] = true; Features["power10-vector"] = true; Features["pcrelative-memops"] = true; + Features["prefix-instrs"] = true; return; } @@ -419,6 +422,7 @@ .Case("paired-vector-memops", PairedVectorMemops) .Case("power10-vector", HasP10Vector) .Case("pcrelative-memops", HasPCRelativeMemops) + .Case("prefix-instrs", HasPrefixInstrs) .Case("spe", HasSPE) .Case("mma", HasMMA) .Case("rop-protect", HasROPProtect) @@ -451,6 +455,8 @@ Features["power8-vector"] = Features["power9-vector"] = true; if (Name == "pcrel") Features["pcrelative-memops"] = true; + else if (Name == "prefixed") + Features["prefix-instrs"] = true; else Features[Name] = true; } else { @@ -471,6 +477,8 @@ Features["power10-vector"] = false; if (Name == "pcrel") Features["pcrelative-memops"] = false; + else if (Name == "prefixed") + Features["prefix-instrs"] = false; else Features[Name] = false; } diff --git a/clang/test/Driver/ppc-prefixed.cpp b/clang/test/Driver/ppc-prefixed.cpp new file mode 100644 --- /dev/null +++ b/clang/test/Driver/ppc-prefixed.cpp @@ -0,0 +1,12 @@ +// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 -mprefixed -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-PREFIXED %s +// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 -mno-prefixed -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOPREFIXED %s +// CHECK-NOPREFIXED: "-target-feature" "-prefixed" +// CHECK-PREFIXED: "-target-feature" "+prefixed" + +// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -emit-llvm -S %s -o - | grep "attributes.*+prefix-instrs" +// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mprefixed -emit-llvm -S %s -o - | grep "attributes.*+prefix-instrs" +// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mno-prefixed -emit-llvm -S %s -o - | grep "attributes.*\-prefix-instrs" + +int main(int argc, char *argv[]) { + return 0; +}