@@ -37,7 +37,15 @@ Index: clang/lib/Driver/ToolChains/Clang.cpp
3737 BranchProtectionPAuthLR = false;
3838 GuardedControlStack = false;
3939 } else {
40- @@ -2664,6 +2673,11 @@ static void CollectArgsForIntegratedAssembler(Compilat
40+ @@ -2574,6 +2583,7 @@ static void CollectArgsForIntegratedAssembler(Compilat
41+ bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
42+ bool UseNoExecStack = false;
43+ const char *MipsTargetFeature = nullptr;
44+ + llvm::SmallVector<const char *> SparcTargetFeatures;
45+ StringRef ImplicitIt;
46+ for (const Arg *A :
47+ Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler,
48+ @@ -2664,6 +2674,11 @@ static void CollectArgsForIntegratedAssembler(Compilat
4149 CmdArgs.push_back("-soft-float");
4250 continue;
4351 }
@@ -49,7 +57,62 @@ Index: clang/lib/Driver/ToolChains/Clang.cpp
4957
5058 MipsTargetFeature = llvm::StringSwitch<const char *>(Value)
5159 .Case("-mips1", "+mips1")
52- @@ -5799,8 +5813,12 @@ void Clang::ConstructJob(Compilation &C, const JobActi
60+ @@ -2684,6 +2699,32 @@ static void CollectArgsForIntegratedAssembler(Compilat
61+ .Default(nullptr);
62+ if (MipsTargetFeature)
63+ continue;
64+ + break;
65+ +
66+ + case llvm::Triple::sparc:
67+ + case llvm::Triple::sparcel:
68+ + case llvm::Triple::sparcv9:
69+ + if (Value == "--undeclared-regs") {
70+ + // LLVM already allows undeclared use of G registers, so this option
71+ + // becomes a no-op. This solely exists for GNU compatibility.
72+ + // TODO implement --no-undeclared-regs
73+ + continue;
74+ + }
75+ + SparcTargetFeatures =
76+ + llvm::StringSwitch<llvm::SmallVector<const char *>>(Value)
77+ + .Case("-Av8", {"-v8plus"})
78+ + .Case("-Av8plus", {"+v8plus", "+v9"})
79+ + .Case("-Av8plusa", {"+v8plus", "+v9", "+vis"})
80+ + .Case("-Av8plusb", {"+v8plus", "+v9", "+vis", "+vis2"})
81+ + .Case("-Av8plusd", {"+v8plus", "+v9", "+vis", "+vis2", "+vis3"})
82+ + .Case("-Av9", {"+v9"})
83+ + .Case("-Av9a", {"+v9", "+vis"})
84+ + .Case("-Av9b", {"+v9", "+vis", "+vis2"})
85+ + .Case("-Av9d", {"+v9", "+vis", "+vis2", "+vis3"})
86+ + .Default({});
87+ + if (!SparcTargetFeatures.empty())
88+ + continue;
89+ + break;
90+ }
91+
92+ if (Value == "-force_cpusubtype_ALL") {
93+ @@ -2791,6 +2832,21 @@ static void CollectArgsForIntegratedAssembler(Compilat
94+ CmdArgs.push_back(MipsTargetFeature);
95+ }
96+
97+ + // Those OSes default to enabling VIS on 64-bit SPARC.
98+ + // See also the corresponding code for external assemblers in
99+ + // sparc::getSparcAsmModeForCPU().
100+ + bool IsSparcV9ATarget =
101+ + (C.getDefaultToolChain().getArch() == llvm::Triple::sparcv9) &&
102+ + (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD());
103+ + if (IsSparcV9ATarget && SparcTargetFeatures.empty()) {
104+ + CmdArgs.push_back("-target-feature");
105+ + CmdArgs.push_back("+vis");
106+ + }
107+ + for (const char *Feature : SparcTargetFeatures) {
108+ + CmdArgs.push_back("-target-feature");
109+ + CmdArgs.push_back(Feature);
110+ + }
111+ +
112+ // forward -fembed-bitcode to assmebler
113+ if (C.getDriver().embedBitcodeEnabled() ||
114+ C.getDriver().embedBitcodeMarkerOnly())
115+ @@ -5799,8 +5855,12 @@ void Clang::ConstructJob(Compilation &C, const JobActi
53116 OFastEnabled ? options::OPT_Ofast : options::OPT_fstrict_aliasing;
54117 // We turn strict aliasing off by default if we're Windows MSVC since MSVC
55118 // doesn't do any TBAA.
@@ -63,7 +126,7 @@ Index: clang/lib/Driver/ToolChains/Clang.cpp
63126 CmdArgs.push_back("-relaxed-aliasing");
64127 if (Args.hasFlag(options::OPT_fpointer_tbaa, options::OPT_fno_pointer_tbaa,
65128 false))
66- @@ -6844,7 +6862 ,8 @@ void Clang::ConstructJob(Compilation &C, const JobActi
129+ @@ -6844,7 +6904 ,8 @@ void Clang::ConstructJob(Compilation &C, const JobActi
67130 options::OPT_fno_strict_overflow)) {
68131 if (A->getOption().matches(options::OPT_fno_strict_overflow))
69132 CmdArgs.push_back("-fwrapv");
@@ -73,7 +136,7 @@ Index: clang/lib/Driver/ToolChains/Clang.cpp
73136
74137 Args.AddLastArg(CmdArgs, options::OPT_ffinite_loops,
75138 options::OPT_fno_finite_loops);
76- @@ -6860,7 +6879 ,58 @@ void Clang::ConstructJob(Compilation &C, const JobActi
139+ @@ -6860,7 +6921 ,58 @@ void Clang::ConstructJob(Compilation &C, const JobActi
77140 Args.addOptInFlag(CmdArgs, options::OPT_mspeculative_load_hardening,
78141 options::OPT_mno_speculative_load_hardening);
79142
@@ -133,7 +196,7 @@ Index: clang/lib/Driver/ToolChains/Clang.cpp
133196 RenderSCPOptions(TC, Args, CmdArgs);
134197 RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
135198
136- @@ -6938,6 +7008 ,11 @@ void Clang::ConstructJob(Compilation &C, const JobActi
199+ @@ -6938,6 +7050 ,11 @@ void Clang::ConstructJob(Compilation &C, const JobActi
137200 if (Arg *A = Args.getLastArg(options::OPT_fcf_protection_EQ)) {
138201 CmdArgs.push_back(
139202 Args.MakeArgString(Twine("-fcf-protection=") + A->getValue()));
@@ -145,7 +208,7 @@ Index: clang/lib/Driver/ToolChains/Clang.cpp
145208 }
146209
147210 if (Arg *A = Args.getLastArg(options::OPT_mfunction_return_EQ))
148- @@ -7466,6 +7541 ,18 @@ void Clang::ConstructJob(Compilation &C, const JobActi
211+ @@ -7466,6 +7583 ,18 @@ void Clang::ConstructJob(Compilation &C, const JobActi
149212 options::OPT_fno_rewrite_imports, false);
150213 if (RewriteImports)
151214 CmdArgs.push_back("-frewrite-imports");
0 commit comments