[clang] 9469ff1 - [PowerPC] Add clang option -m[no-]prefixed
Lei Huang via cfe-commits
cfe-commits at lists.llvm.org
Thu May 13 10:02:16 PDT 2021
Author: Lei Huang
Date: 2021-05-13T12:02:10-05:00
New Revision: 9469ff15b77905245e26fe7f166fc127d813a0c0
URL: https://github.com/llvm/llvm-project/commit/9469ff15b77905245e26fe7f166fc127d813a0c0
DIFF: https://github.com/llvm/llvm-project/commit/9469ff15b77905245e26fe7f166fc127d813a0c0.diff
LOG: [PowerPC] Add clang option -m[no-]prefixed
Add user-facing front end option to turn off power10 prefixed instructions.
Reviewed By: nemanjai
Differential Revision: https://reviews.llvm.org/D102191
Added:
clang/test/Driver/ppc-prefixed.cpp
Modified:
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 78cc0a4e53a5f..1fda2dac0f76f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3254,6 +3254,8 @@ def maltivec : Flag<["-"], "maltivec">, Group<m_ppc_Features_Group>;
def mno_altivec : Flag<["-"], "mno-altivec">, Group<m_ppc_Features_Group>;
def mpcrel: Flag<["-"], "mpcrel">, Group<m_ppc_Features_Group>;
def mno_pcrel: Flag<["-"], "mno-pcrel">, Group<m_ppc_Features_Group>;
+def mprefixed: Flag<["-"], "mprefixed">, Group<m_ppc_Features_Group>;
+def mno_prefixed: Flag<["-"], "mno-prefixed">, Group<m_ppc_Features_Group>;
def mspe : Flag<["-"], "mspe">, Group<m_ppc_Features_Group>;
def mno_spe : Flag<["-"], "mno-spe">, Group<m_ppc_Features_Group>;
def mefpu2 : Flag<["-"], "mefpu2">, Group<m_ppc_Features_Group>;
diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index cd8cc1aed39ea..cc16934292203 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -56,6 +56,8 @@ bool PPCTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
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 @@ void PPCTargetInfo::addP10SpecificFeatures(
Features["mma"] = true;
Features["power10-vector"] = true;
Features["pcrelative-memops"] = true;
+ Features["prefix-instrs"] = true;
return;
}
@@ -419,6 +422,7 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const {
.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 @@ void PPCTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
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 @@ void PPCTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
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/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 3feee82d6ccd0..554f2174fee00 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -73,6 +73,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public TargetInfo {
bool PairedVectorMemops = false;
bool HasP10Vector = false;
bool HasPCRelativeMemops = false;
+ bool HasPrefixInstrs = false;
protected:
std::string ABI;
diff --git a/clang/test/Driver/ppc-prefixed.cpp b/clang/test/Driver/ppc-prefixed.cpp
new file mode 100644
index 0000000000000..3d6a13f83d0b2
--- /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;
+}
More information about the cfe-commits
mailing list