Skip to content

Commit 3853116

Browse files
authored
[SPARC][Driver] Set correct IAS mode defaults for Linux and Free/OpenBSD (#130108)
On those OSes, clang should set the assembler to enable VIS by default. This is already the case when clang calls an external assembler, so make sure clang+IAS use the same defaults. This should fix [issue #125124](#125124).
1 parent 81d7eef commit 3853116

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2875,6 +2875,17 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
28752875
CmdArgs.push_back("-target-feature");
28762876
CmdArgs.push_back(MipsTargetFeature);
28772877
}
2878+
2879+
// Those OSes default to enabling VIS on 64-bit SPARC.
2880+
// See also the corresponding code for external assemblers in
2881+
// sparc::getSparcAsmModeForCPU().
2882+
bool IsSparcV9ATarget =
2883+
(C.getDefaultToolChain().getArch() == llvm::Triple::sparcv9) &&
2884+
(Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD());
2885+
if (IsSparcV9ATarget && SparcTargetFeatures.empty()) {
2886+
CmdArgs.push_back("-target-feature");
2887+
CmdArgs.push_back("+vis");
2888+
}
28782889
for (const char *Feature : SparcTargetFeatures) {
28792890
CmdArgs.push_back("-target-feature");
28802891
CmdArgs.push_back(Feature);

clang/test/Driver/sparc-ias-Wa.s

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,12 @@
5858
// V9D: "-target-feature" "+vis"
5959
// V9D: "-target-feature" "+vis2"
6060
// V9D: "-target-feature" "+vis3"
61+
62+
// RUN: %clang --target=sparc64-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
63+
// RUN: FileCheck -check-prefix=VIS-DEFAULT %s
64+
// RUN: %clang --target=sparc64-freebsd -### -fintegrated-as -c %s 2>&1 | \
65+
// RUN: FileCheck -check-prefix=VIS-DEFAULT %s
66+
// RUN: %clang --target=sparc64-openbsd -### -fintegrated-as -c %s 2>&1 | \
67+
// RUN: FileCheck -check-prefix=VIS-DEFAULT %s
68+
// VIS-DEFAULT: -cc1as
69+
// VIS-DEFAULT: "-target-feature" "+vis"

0 commit comments

Comments
 (0)