Skip to content

Commit 30a9941

Browse files
authored
[SPARC][IAS] Add IAS flag handling for ISA levels
Add IAS flag handling for ISA levels we support in LLVM. Reviewers: MaskRay, rorth, brad0, s-barannikov Reviewed By: MaskRay Pull Request: llvm#125151
1 parent 73ab0c0 commit 30a9941

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,6 +2633,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
26332633
bool UseNoExecStack = false;
26342634
bool Msa = false;
26352635
const char *MipsTargetFeature = nullptr;
2636+
llvm::SmallVector<const char *> SparcTargetFeatures;
26362637
StringRef ImplicitIt;
26372638
for (const Arg *A :
26382639
Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler,
@@ -2778,6 +2779,31 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
27782779
if (MipsTargetFeature)
27792780
continue;
27802781
break;
2782+
2783+
case llvm::Triple::sparc:
2784+
case llvm::Triple::sparcel:
2785+
case llvm::Triple::sparcv9:
2786+
if (Value == "--undeclared-regs") {
2787+
// LLVM already allows undeclared use of G registers, so this option
2788+
// becomes a no-op. This solely exists for GNU compatibility.
2789+
// TODO implement --no-undeclared-regs
2790+
continue;
2791+
}
2792+
SparcTargetFeatures =
2793+
llvm::StringSwitch<llvm::SmallVector<const char *>>(Value)
2794+
.Case("-Av8", {"-v8plus"})
2795+
.Case("-Av8plus", {"+v8plus", "+v9"})
2796+
.Case("-Av8plusa", {"+v8plus", "+v9", "+vis"})
2797+
.Case("-Av8plusb", {"+v8plus", "+v9", "+vis", "+vis2"})
2798+
.Case("-Av8plusd", {"+v8plus", "+v9", "+vis", "+vis2", "+vis3"})
2799+
.Case("-Av9", {"+v9"})
2800+
.Case("-Av9a", {"+v9", "+vis"})
2801+
.Case("-Av9b", {"+v9", "+vis", "+vis2"})
2802+
.Case("-Av9d", {"+v9", "+vis", "+vis2", "+vis3"})
2803+
.Default({});
2804+
if (!SparcTargetFeatures.empty())
2805+
continue;
2806+
break;
27812807
}
27822808

27832809
if (Value == "-force_cpusubtype_ALL") {
@@ -2882,6 +2908,10 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
28822908
CmdArgs.push_back("-target-feature");
28832909
CmdArgs.push_back(MipsTargetFeature);
28842910
}
2911+
for (const char *Feature : SparcTargetFeatures) {
2912+
CmdArgs.push_back("-target-feature");
2913+
CmdArgs.push_back(Feature);
2914+
}
28852915

28862916
// forward -fembed-bitcode to assmebler
28872917
if (C.getDriver().embedBitcodeEnabled() ||

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8 2>&1 | \
2+
// RUN: FileCheck -check-prefix=V8 %s
3+
// V8: -cc1as
4+
// V8: "-target-feature" "-v8plus"
5+
6+
// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8plus 2>&1 | \
7+
// RUN: FileCheck -check-prefix=V8PLUS %s
8+
// V8PLUS: -cc1as
9+
// V8PLUS: "-target-feature" "+v8plus"
10+
// V8PLUS: "-target-feature" "+v9"
11+
12+
// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8plusa 2>&1 | \
13+
// RUN: FileCheck -check-prefix=V8PLUSA %s
14+
// V8PLUSA: -cc1as
15+
// V8PLUSA: "-target-feature" "+v8plus"
16+
// V8PLUSA: "-target-feature" "+v9"
17+
// V8PLUSA: "-target-feature" "+vis"
18+
19+
// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8plusb 2>&1 | \
20+
// RUN: FileCheck -check-prefix=V8PLUSB %s
21+
// V8PLUSB: -cc1as
22+
// V8PLUSB: "-target-feature" "+v8plus"
23+
// V8PLUSB: "-target-feature" "+v9"
24+
// V8PLUSB: "-target-feature" "+vis"
25+
// V8PLUSB: "-target-feature" "+vis2"
26+
27+
// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8plusd 2>&1 | \
28+
// RUN: FileCheck -check-prefix=V8PLUSD %s
29+
// V8PLUSD: -cc1as
30+
// V8PLUSD: "-target-feature" "+v8plus"
31+
// V8PLUSD: "-target-feature" "+v9"
32+
// V8PLUSD: "-target-feature" "+vis"
33+
// V8PLUSD: "-target-feature" "+vis2"
34+
// V8PLUSD: "-target-feature" "+vis3"
35+
36+
// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av9 2>&1 | \
37+
// RUN: FileCheck -check-prefix=V9 %s
38+
// V9: -cc1as
39+
// V9: "-target-feature" "+v9"
40+
41+
// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av9a 2>&1 | \
42+
// RUN: FileCheck -check-prefix=V9A %s
43+
// V9A: -cc1as
44+
// V9A: "-target-feature" "+v9"
45+
// V9A: "-target-feature" "+vis"
46+
47+
// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av9b 2>&1 | \
48+
// RUN: FileCheck -check-prefix=V9B %s
49+
// V9B: -cc1as
50+
// V9B: "-target-feature" "+v9"
51+
// V9B: "-target-feature" "+vis"
52+
// V9B: "-target-feature" "+vis2"
53+
54+
// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av9d 2>&1 | \
55+
// RUN: FileCheck -check-prefix=V9D %s
56+
// V9D: -cc1as
57+
// V9D: "-target-feature" "+v9"
58+
// V9D: "-target-feature" "+vis"
59+
// V9D: "-target-feature" "+vis2"
60+
// V9D: "-target-feature" "+vis3"

0 commit comments

Comments
 (0)