Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2595,6 +2595,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
bool UseNoExecStack = false;
bool Msa = false;
const char *MipsTargetFeature = nullptr;
llvm::SmallVector<const char *> SparcTargetFeatures;
StringRef ImplicitIt;
for (const Arg *A :
Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler,
Expand Down Expand Up @@ -2740,6 +2741,31 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
if (MipsTargetFeature)
continue;
break;

case llvm::Triple::sparc:
case llvm::Triple::sparcel:
case llvm::Triple::sparcv9:
if (Value == "--undeclared-regs") {
// LLVM already allows undeclared use of G registers, so this option
// becomes a no-op. This solely exists for GNU compatibility.
// TODO implement --no-undeclared-regs
continue;
}
SparcTargetFeatures =
llvm::StringSwitch<llvm::SmallVector<const char *>>(Value)
.Case("-Av8", {"-v8plus"})
.Case("-Av8plus", {"+v8plus", "+v9"})
.Case("-Av8plusa", {"+v8plus", "+v9", "+vis"})
.Case("-Av8plusb", {"+v8plus", "+v9", "+vis", "+vis2"})
.Case("-Av8plusd", {"+v8plus", "+v9", "+vis", "+vis2", "+vis3"})
.Case("-Av9", {"+v9"})
.Case("-Av9a", {"+v9", "+vis"})
.Case("-Av9b", {"+v9", "+vis", "+vis2"})
.Case("-Av9d", {"+v9", "+vis", "+vis2", "+vis3"})
.Default({});
if (!SparcTargetFeatures.empty())
continue;
break;
}

if (Value == "-force_cpusubtype_ALL") {
Expand Down Expand Up @@ -2844,6 +2870,10 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
CmdArgs.push_back("-target-feature");
CmdArgs.push_back(MipsTargetFeature);
}
for (const char *Feature : SparcTargetFeatures) {
CmdArgs.push_back("-target-feature");
CmdArgs.push_back(Feature);
}

// forward -fembed-bitcode to assmebler
if (C.getDriver().embedBitcodeEnabled() ||
Expand Down
60 changes: 60 additions & 0 deletions clang/test/Driver/sparc-ias-Wa.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8 2>&1 | \
// RUN: FileCheck -check-prefix=V8 %s
// V8: -cc1as
// V8: "-target-feature" "-v8plus"

// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8plus 2>&1 | \
// RUN: FileCheck -check-prefix=V8PLUS %s
// V8PLUS: -cc1as
// V8PLUS: "-target-feature" "+v8plus"
// V8PLUS: "-target-feature" "+v9"

// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8plusa 2>&1 | \
// RUN: FileCheck -check-prefix=V8PLUSA %s
// V8PLUSA: -cc1as
// V8PLUSA: "-target-feature" "+v8plus"
// V8PLUSA: "-target-feature" "+v9"
// V8PLUSA: "-target-feature" "+vis"

// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8plusb 2>&1 | \
// RUN: FileCheck -check-prefix=V8PLUSB %s
// V8PLUSB: -cc1as
// V8PLUSB: "-target-feature" "+v8plus"
// V8PLUSB: "-target-feature" "+v9"
// V8PLUSB: "-target-feature" "+vis"
// V8PLUSB: "-target-feature" "+vis2"

// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8plusd 2>&1 | \
// RUN: FileCheck -check-prefix=V8PLUSD %s
// V8PLUSD: -cc1as
// V8PLUSD: "-target-feature" "+v8plus"
// V8PLUSD: "-target-feature" "+v9"
// V8PLUSD: "-target-feature" "+vis"
// V8PLUSD: "-target-feature" "+vis2"
// V8PLUSD: "-target-feature" "+vis3"

// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av9 2>&1 | \
// RUN: FileCheck -check-prefix=V9 %s
// V9: -cc1as
// V9: "-target-feature" "+v9"

// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av9a 2>&1 | \
// RUN: FileCheck -check-prefix=V9A %s
// V9A: -cc1as
// V9A: "-target-feature" "+v9"
// V9A: "-target-feature" "+vis"

// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av9b 2>&1 | \
// RUN: FileCheck -check-prefix=V9B %s
// V9B: -cc1as
// V9B: "-target-feature" "+v9"
// V9B: "-target-feature" "+vis"
// V9B: "-target-feature" "+vis2"

// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av9d 2>&1 | \
// RUN: FileCheck -check-prefix=V9D %s
// V9D: -cc1as
// V9D: "-target-feature" "+v9"
// V9D: "-target-feature" "+vis"
// V9D: "-target-feature" "+vis2"
// V9D: "-target-feature" "+vis3"
Loading