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")
87 const ArgList &Args) {
89 if (Arg *A = Args.getLastArg(options::OPT_msoft_float, options::OPT_mno_fpu,
90 options::OPT_mhard_float, options::OPT_mfpu,
91 options::OPT_mfloat_abi_EQ)) {
92 if (A->getOption().matches(options::OPT_msoft_float) ||
93 A->getOption().matches(options::OPT_mno_fpu))
95 else if (A->getOption().matches(options::OPT_mhard_float) ||
96 A->getOption().matches(options::OPT_mfpu))
99 ABI = llvm::StringSwitch<sparc::FloatABI>(A->getValue())
104 !StringRef(A->getValue()).empty()) {
105 D.
Diag(clang::diag::err_drv_invalid_mfloat_abi) << A->getAsString(Args);
124 const llvm::Triple &Triple) {
125 if (
const Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) {
126 StringRef CPUName = A->getValue();
127 if (CPUName ==
"native") {
128 std::string
CPU = std::string(llvm::sys::getHostCPUName());
129 if (!
CPU.empty() && CPU !=
"generic")
133 return std::string(CPUName);
136 if (Triple.getArch() == llvm::Triple::sparc &&
137 (Triple.isOSSolaris() || Triple.isOSLinux()))
144 std::vector<StringRef> &Features) {
147 Features.push_back(
"+soft-float");
149 if (Arg *A = Args.getLastArg(options::OPT_mfsmuld, options::OPT_mno_fsmuld)) {
150 if (A->getOption().matches(options::OPT_mfsmuld))
151 Features.push_back(
"+fsmuld");
153 Features.push_back(
"-fsmuld");
156 if (Arg *A = Args.getLastArg(options::OPT_mpopc, options::OPT_mno_popc)) {
157 if (A->getOption().matches(options::OPT_mpopc))
158 Features.push_back(
"+popc");
160 Features.push_back(
"-popc");
166 bool IsSparcV9ATarget =
167 (Triple.getArch() == llvm::Triple::sparcv9) &&
168 (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD());
169 bool IsSparcV9BTarget = Triple.isOSSolaris();
170 bool IsSparcV8PlusTarget =
171 Triple.getArch() == llvm::Triple::sparc && Triple.isOSSolaris();
172 if (Arg *A = Args.getLastArg(options::OPT_mvis, options::OPT_mno_vis)) {
173 if (A->getOption().matches(options::OPT_mvis))
174 Features.push_back(
"+vis");
176 Features.push_back(
"-vis");
177 }
else if (IsSparcV9ATarget) {
178 Features.push_back(
"+vis");
181 if (Arg *A = Args.getLastArg(options::OPT_mvis2, options::OPT_mno_vis2)) {
182 if (A->getOption().matches(options::OPT_mvis2))
183 Features.push_back(
"+vis2");
185 Features.push_back(
"-vis2");
186 }
else if (IsSparcV9BTarget) {
187 Features.push_back(
"+vis2");
190 if (Arg *A = Args.getLastArg(options::OPT_mvis3, options::OPT_mno_vis3)) {
191 if (A->getOption().matches(options::OPT_mvis3))
192 Features.push_back(
"+vis3");
194 Features.push_back(
"-vis3");
197 if (Arg *A = Args.getLastArg(options::OPT_mhard_quad_float,
198 options::OPT_msoft_quad_float)) {
199 if (A->getOption().matches(options::OPT_mhard_quad_float))
200 Features.push_back(
"+hard-quad-float");
202 Features.push_back(
"-hard-quad-float");
205 if (Arg *A = Args.getLastArg(options::OPT_mv8plus, options::OPT_mno_v8plus)) {
206 if (A->getOption().matches(options::OPT_mv8plus))
207 Features.push_back(
"+v8plus");
208 }
else if (IsSparcV8PlusTarget) {
209 Features.push_back(
"+v8plus");
212 if (Args.hasArg(options::OPT_ffixed_g1))
213 Features.push_back(
"+reserve-g1");
215 if (Args.hasArg(options::OPT_ffixed_g2))
216 Features.push_back(
"+reserve-g2");
218 if (Args.hasArg(options::OPT_ffixed_g3))
219 Features.push_back(
"+reserve-g3");
221 if (Args.hasArg(options::OPT_ffixed_g4))
222 Features.push_back(
"+reserve-g4");
224 if (Args.hasArg(options::OPT_ffixed_g5))
225 Features.push_back(
"+reserve-g5");
227 if (Args.hasArg(options::OPT_ffixed_g6))
228 Features.push_back(
"+reserve-g6");
230 if (Args.hasArg(options::OPT_ffixed_g7))
231 Features.push_back(
"+reserve-g7");
233 if (Args.hasArg(options::OPT_ffixed_o0))
234 Features.push_back(
"+reserve-o0");
236 if (Args.hasArg(options::OPT_ffixed_o1))
237 Features.push_back(
"+reserve-o1");
239 if (Args.hasArg(options::OPT_ffixed_o2))
240 Features.push_back(
"+reserve-o2");
242 if (Args.hasArg(options::OPT_ffixed_o3))
243 Features.push_back(
"+reserve-o3");
245 if (Args.hasArg(options::OPT_ffixed_o4))
246 Features.push_back(
"+reserve-o4");
248 if (Args.hasArg(options::OPT_ffixed_o5))
249 Features.push_back(
"+reserve-o5");
251 if (Args.hasArg(options::OPT_ffixed_l0))
252 Features.push_back(
"+reserve-l0");
254 if (Args.hasArg(options::OPT_ffixed_l1))
255 Features.push_back(
"+reserve-l1");
257 if (Args.hasArg(options::OPT_ffixed_l2))
258 Features.push_back(
"+reserve-l2");
260 if (Args.hasArg(options::OPT_ffixed_l3))
261 Features.push_back(
"+reserve-l3");
263 if (Args.hasArg(options::OPT_ffixed_l4))
264 Features.push_back(
"+reserve-l4");
266 if (Args.hasArg(options::OPT_ffixed_l5))
267 Features.push_back(
"+reserve-l5");
269 if (Args.hasArg(options::OPT_ffixed_l6))
270 Features.push_back(
"+reserve-l6");
272 if (Args.hasArg(options::OPT_ffixed_l7))
273 Features.push_back(
"+reserve-l7");
275 if (Args.hasArg(options::OPT_ffixed_i0))
276 Features.push_back(
"+reserve-i0");
278 if (Args.hasArg(options::OPT_ffixed_i1))
279 Features.push_back(
"+reserve-i1");
281 if (Args.hasArg(options::OPT_ffixed_i2))
282 Features.push_back(
"+reserve-i2");
284 if (Args.hasArg(options::OPT_ffixed_i3))
285 Features.push_back(
"+reserve-i3");
287 if (Args.hasArg(options::OPT_ffixed_i4))
288 Features.push_back(
"+reserve-i4");
290 if (Args.hasArg(options::OPT_ffixed_i5))
291 Features.push_back(
"+reserve-i5");
293 if (Args.hasArg(options::OPT_mfix_gr712rc)) {
294 Features.push_back(
"+fix-tn0009");
295 Features.push_back(
"+fix-tn0011");
296 Features.push_back(
"+fix-tn0012");
297 Features.push_back(
"+fix-tn0013");
300 if (Args.hasArg(options::OPT_mfix_ut700)) {
301 Features.push_back(
"+fix-tn0009");
302 Features.push_back(
"+fix-tn0010");
303 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
The JSON file list parser is used to communicate input to InstallAPI.