Skip to content

Commit 3dac214

Browse files
author
Justin Hibbits
committedSep 5, 2019
Add -m(no)-spe to clang
Summary: r337347 added support for the Signal Processing Engine (SPE) to LLVM. This follows that up with the clang side. This adds -mspe and -mno-spe, to match GCC. Subscribers: nemanjai, kbarton, cfe-commits Differential Revision: https://reviews.llvm.org/D49754 llvm-svn: 371066
1 parent 2172f3f commit 3dac214

File tree

6 files changed

+22
-2
lines changed

6 files changed

+22
-2
lines changed
 

Diff for: ‎clang/include/clang/Driver/Options.td

+2
Original file line numberDiff line numberDiff line change
@@ -2269,6 +2269,8 @@ def faltivec : Flag<["-"], "faltivec">, Group<f_Group>, Flags<[DriverOption]>;
22692269
def fno_altivec : Flag<["-"], "fno-altivec">, Group<f_Group>, Flags<[DriverOption]>;
22702270
def maltivec : Flag<["-"], "maltivec">, Group<m_ppc_Features_Group>;
22712271
def mno_altivec : Flag<["-"], "mno-altivec">, Group<m_ppc_Features_Group>;
2272+
def mspe : Flag<["-"], "mspe">, Group<m_ppc_Features_Group>;
2273+
def mno_spe : Flag<["-"], "mno-spe">, Group<m_ppc_Features_Group>;
22722274
def mvsx : Flag<["-"], "mvsx">, Group<m_ppc_Features_Group>;
22732275
def mno_vsx : Flag<["-"], "mno-vsx">, Group<m_ppc_Features_Group>;
22742276
def msecure_plt : Flag<["-"], "msecure-plt">, Group<m_ppc_Features_Group>;

Diff for: ‎clang/lib/Basic/Targets/PPC.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ bool PPCTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
5454
HasFloat128 = true;
5555
} else if (Feature == "+power9-vector") {
5656
HasP9Vector = true;
57+
} else if (Feature == "+spe") {
58+
HasSPE = true;
59+
LongDoubleWidth = LongDoubleAlign = 64;
60+
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
5761
} else if (Feature == "-hard-float") {
5862
FloatABI = SoftFloat;
5963
}
@@ -165,6 +169,10 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
165169
Builder.defineMacro("__VEC__", "10206");
166170
Builder.defineMacro("__ALTIVEC__");
167171
}
172+
if (HasSPE) {
173+
Builder.defineMacro("__SPE__");
174+
Builder.defineMacro("__NO_FPRS__");
175+
}
168176
if (HasVSX)
169177
Builder.defineMacro("__VSX__");
170178
if (HasP8Vector)
@@ -203,7 +211,6 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
203211
// __CMODEL_LARGE__
204212
// _CALL_SYSV
205213
// _CALL_DARWIN
206-
// __NO_FPRS__
207214
}
208215

209216
// Handle explicit options being passed to the compiler here: if we've
@@ -332,6 +339,7 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const {
332339
.Case("extdiv", HasExtDiv)
333340
.Case("float128", HasFloat128)
334341
.Case("power9-vector", HasP9Vector)
342+
.Case("spe", HasSPE)
335343
.Default(false);
336344
}
337345

Diff for: ‎clang/lib/Basic/Targets/PPC.h

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public TargetInfo {
6666
bool HasBPERMD = false;
6767
bool HasExtDiv = false;
6868
bool HasP9Vector = false;
69+
bool HasSPE = false;
6970

7071
protected:
7172
std::string ABI;

Diff for: ‎clang/lib/CodeGen/TargetInfo.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -9726,7 +9726,8 @@ const TargetCodeGenInfo &CodeGenModule::getTargetCodeGenInfo() {
97269726

97279727
case llvm::Triple::ppc:
97289728
return SetCGInfo(
9729-
new PPC32TargetCodeGenInfo(Types, CodeGenOpts.FloatABI == "soft"));
9729+
new PPC32TargetCodeGenInfo(Types, CodeGenOpts.FloatABI == "soft" ||
9730+
getTarget().hasFeature("spe")));
97309731
case llvm::Triple::ppc64:
97319732
if (Triple.isOSBinFormatELF()) {
97329733
PPC64_SVR4_ABIInfo::ABIKind Kind = PPC64_SVR4_ABIInfo::ELFv1;

Diff for: ‎clang/test/Driver/ppc-features.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@
168168
// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-invariant-function-descriptors -minvariant-function-descriptors -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-INVFUNCDESC %s
169169
// CHECK-INVFUNCDESC: "-target-feature" "+invariant-function-descriptors"
170170

171+
// RUN: %clang -target powerpc-unknown-linux-gnu %s -mno-spe -mspe -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-SPE %s
172+
// CHECK-SPE: "-target-feature" "+spe"
173+
171174
// Assembler features
172175
// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o -no-integrated-as 2>&1 | FileCheck -check-prefix=CHECK_BE_AS_ARGS %s
173176
// CHECK_BE_AS_ARGS: "-mppc64"

Diff for: ‎clang/test/Preprocessor/init.c

+5
Original file line numberDiff line numberDiff line change
@@ -7580,6 +7580,11 @@
75807580
//
75817581
// PPC32-LINUX-NOT: _CALL_LINUX
75827582
//
7583+
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-linux-gnu -target-feature +spe < /dev/null | FileCheck -match-full-lines -check-prefix PPC32-SPE %s
7584+
//
7585+
// PPC32-SPE:#define __NO_FPRS__ 1
7586+
// PPC32-SPE:#define __SPE__ 1
7587+
//
75837588
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-apple-darwin8 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-DARWIN %s
75847589
//
75857590
// PPC-DARWIN:#define _ARCH_PPC 1

0 commit comments

Comments
 (0)