12#include "llvm/ADT/StringSwitch.h"
13#include "llvm/Option/ArgList.h"
14#include "llvm/TargetParser/Host.h"
22 const llvm::Triple &Triple) {
23 if (Triple.getArch() == llvm::Triple::sparcv9) {
26 if (Triple.isOSSolaris())
28 else if (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD())
33 return llvm::StringSwitch<const char *>(Name)
34 .Case(
"niagara",
"-Av9b")
35 .Case(
"niagara2",
"-Av9b")
36 .Case(
"niagara3",
"-Av9d")
37 .Case(
"niagara4",
"-Av9d")
42 if (Triple.isOSSolaris())
43 DefV8CPU =
"-Av8plus";
47 return llvm::StringSwitch<const char *>(Name)
49 .Case(
"supersparc",
"-Av8")
50 .Case(
"sparclite",
"-Asparclite")
51 .Case(
"f934",
"-Asparclite")
52 .Case(
"hypersparc",
"-Av8")
53 .Case(
"sparclite86x",
"-Asparclite")
54 .Case(
"sparclet",
"-Asparclet")
55 .Case(
"tsc701",
"-Asparclet")
56 .Case(
"v9",
"-Av8plus")
57 .Case(
"ultrasparc",
"-Av8plus")
58 .Case(
"ultrasparc3",
"-Av8plus")
59 .Case(
"niagara",
"-Av8plusb")
60 .Case(
"niagara2",
"-Av8plusb")
61 .Case(
"niagara3",
"-Av8plusd")
62 .Case(
"niagara4",
"-Av8plusd")
63 .Case(
"ma2100",
"-Aleon")
64 .Case(
"ma2150",
"-Aleon")
65 .Case(
"ma2155",
"-Aleon")
66 .Case(
"ma2450",
"-Aleon")
67 .Case(
"ma2455",
"-Aleon")
68 .Case(
"ma2x5x",
"-Aleon")
69 .Case(
"ma2080",
"-Aleon")
70 .Case(
"ma2085",
"-Aleon")
71 .Case(
"ma2480",
"-Aleon")
72 .Case(
"ma2485",
"-Aleon")
73 .Case(
"ma2x8x",
"-Aleon")
74 .Case(
"leon2",
"-Av8")
75 .Case(
"at697e",
"-Av8")
76 .Case(
"at697f",
"-Av8")
77 .Case(
"leon3",
"-Aleon")
78 .Case(
"ut699",
"-Av8")
79 .Case(
"gr712rc",
"-Aleon")
80 .Case(
"leon4",
"-Aleon")
81 .Case(
"gr740",
"-Aleon")
82 .Case(
"leon5",
"-Aleon")
88 const ArgList &Args) {
90 if (Arg *A = Args.getLastArg(options::OPT_msoft_float, options::OPT_mno_fpu,
91 options::OPT_mhard_float, options::OPT_mfpu,
92 options::OPT_mfloat_abi_EQ)) {
93 if (A->getOption().matches(options::OPT_msoft_float) ||
94 A->getOption().matches(options::OPT_mno_fpu))
96 else if (A->getOption().matches(options::OPT_mhard_float) ||
97 A->getOption().matches(options::OPT_mfpu))
100 ABI = llvm::StringSwitch<sparc::FloatABI>(A->getValue())
105 !StringRef(A->getValue()).empty()) {
106 D.
Diag(clang::diag::err_drv_invalid_mfloat_abi) << A->getAsString(Args);
125 const llvm::Triple &Triple) {
126 if (
const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
127 StringRef CPUName = A->getValue();
128 if (CPUName ==
"native") {
129 std::string
CPU = std::string(llvm::sys::getHostCPUName());
130 if (!
CPU.empty() && CPU !=
"generic")
134 return std::string(CPUName);
137 if (Triple.getArch() == llvm::Triple::sparc &&
138 (Triple.isOSSolaris() || Triple.isOSLinux()))
145 std::vector<StringRef> &Features) {
148 Features.push_back(
"+soft-float");
150 if (Arg *A = Args.getLastArg(options::OPT_mfsmuld, options::OPT_mno_fsmuld)) {
151 if (A->getOption().matches(options::OPT_mfsmuld))
152 Features.push_back(
"+fsmuld");
154 Features.push_back(
"-fsmuld");
157 if (Arg *A = Args.getLastArg(options::OPT_mpopc, options::OPT_mno_popc)) {
158 if (A->getOption().matches(options::OPT_mpopc))
159 Features.push_back(
"+popc");
161 Features.push_back(
"-popc");
167 bool IsSparcV9ATarget =
168 (Triple.getArch() == llvm::Triple::sparcv9) &&
169 (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD());
170 bool IsSparcV9BTarget = Triple.isOSSolaris();
171 bool IsSparcV8PlusTarget =
172 Triple.getArch() == llvm::Triple::sparc && Triple.isOSSolaris();
173 if (Arg *A = Args.getLastArg(options::OPT_mvis, options::OPT_mno_vis)) {
174 if (A->getOption().matches(options::OPT_mvis))
175 Features.push_back(
"+vis");
177 Features.push_back(
"-vis");
178 }
else if (IsSparcV9ATarget) {
179 Features.push_back(
"+vis");
182 if (Arg *A = Args.getLastArg(options::OPT_mvis2, options::OPT_mno_vis2)) {
183 if (A->getOption().matches(options::OPT_mvis2))
184 Features.push_back(
"+vis2");
186 Features.push_back(
"-vis2");
187 }
else if (IsSparcV9BTarget) {
188 Features.push_back(
"+vis2");
191 if (Arg *A = Args.getLastArg(options::OPT_mvis3, options::OPT_mno_vis3)) {
192 if (A->getOption().matches(options::OPT_mvis3))
193 Features.push_back(
"+vis3");
195 Features.push_back(
"-vis3");
198 if (Arg *A = Args.getLastArg(options::OPT_mhard_quad_float,
199 options::OPT_msoft_quad_float)) {
200 if (A->getOption().matches(options::OPT_mhard_quad_float))
201 Features.push_back(
"+hard-quad-float");
203 Features.push_back(
"-hard-quad-float");
206 if (Arg *A = Args.getLastArg(options::OPT_mv8plus, options::OPT_mno_v8plus)) {
207 if (A->getOption().matches(options::OPT_mv8plus))
208 Features.push_back(
"+v8plus");
209 }
else if (IsSparcV8PlusTarget) {
210 Features.push_back(
"+v8plus");
213 if (Args.hasArg(options::OPT_ffixed_g1))
214 Features.push_back(
"+reserve-g1");
216 if (Args.hasArg(options::OPT_ffixed_g2))
217 Features.push_back(
"+reserve-g2");
219 if (Args.hasArg(options::OPT_ffixed_g3))
220 Features.push_back(
"+reserve-g3");
222 if (Args.hasArg(options::OPT_ffixed_g4))
223 Features.push_back(
"+reserve-g4");
225 if (Args.hasArg(options::OPT_ffixed_g5))
226 Features.push_back(
"+reserve-g5");
228 if (Args.hasArg(options::OPT_ffixed_g6))
229 Features.push_back(
"+reserve-g6");
231 if (Args.hasArg(options::OPT_ffixed_g7))
232 Features.push_back(
"+reserve-g7");
234 if (Args.hasArg(options::OPT_ffixed_o0))
235 Features.push_back(
"+reserve-o0");
237 if (Args.hasArg(options::OPT_ffixed_o1))
238 Features.push_back(
"+reserve-o1");
240 if (Args.hasArg(options::OPT_ffixed_o2))
241 Features.push_back(
"+reserve-o2");
243 if (Args.hasArg(options::OPT_ffixed_o3))
244 Features.push_back(
"+reserve-o3");
246 if (Args.hasArg(options::OPT_ffixed_o4))
247 Features.push_back(
"+reserve-o4");
249 if (Args.hasArg(options::OPT_ffixed_o5))
250 Features.push_back(
"+reserve-o5");
252 if (Args.hasArg(options::OPT_ffixed_l0))
253 Features.push_back(
"+reserve-l0");
255 if (Args.hasArg(options::OPT_ffixed_l1))
256 Features.push_back(
"+reserve-l1");
258 if (Args.hasArg(options::OPT_ffixed_l2))
259 Features.push_back(
"+reserve-l2");
261 if (Args.hasArg(options::OPT_ffixed_l3))
262 Features.push_back(
"+reserve-l3");
264 if (Args.hasArg(options::OPT_ffixed_l4))
265 Features.push_back(
"+reserve-l4");
267 if (Args.hasArg(options::OPT_ffixed_l5))
268 Features.push_back(
"+reserve-l5");
270 if (Args.hasArg(options::OPT_ffixed_l6))
271 Features.push_back(
"+reserve-l6");
273 if (Args.hasArg(options::OPT_ffixed_l7))
274 Features.push_back(
"+reserve-l7");
276 if (Args.hasArg(options::OPT_ffixed_i0))
277 Features.push_back(
"+reserve-i0");
279 if (Args.hasArg(options::OPT_ffixed_i1))
280 Features.push_back(
"+reserve-i1");
282 if (Args.hasArg(options::OPT_ffixed_i2))
283 Features.push_back(
"+reserve-i2");
285 if (Args.hasArg(options::OPT_ffixed_i3))
286 Features.push_back(
"+reserve-i3");
288 if (Args.hasArg(options::OPT_ffixed_i4))
289 Features.push_back(
"+reserve-i4");
291 if (Args.hasArg(options::OPT_ffixed_i5))
292 Features.push_back(
"+reserve-i5");
294 if (Args.hasArg(options::OPT_mfix_gr712rc)) {
295 Features.push_back(
"+fix-tn0009");
296 Features.push_back(
"+fix-tn0011");
297 Features.push_back(
"+fix-tn0012");
298 Features.push_back(
"+fix-tn0013");
301 if (Args.hasArg(options::OPT_mfix_ut700)) {
302 Features.push_back(
"+fix-tn0009");
303 Features.push_back(
"+fix-tn0010");
304 Features.push_back(
"+fix-tn0013");
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
DiagnosticBuilder Diag(unsigned DiagID) const
Top level wrappers for InstallAPI frontend operations.