1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | #include "Sparc.h" |
10 | #include "clang/Driver/Driver.h" |
11 | #include "clang/Driver/DriverDiagnostic.h" |
12 | #include "clang/Driver/Options.h" |
13 | #include "llvm/ADT/StringSwitch.h" |
14 | #include "llvm/Option/ArgList.h" |
15 | |
16 | using namespace clang::driver; |
17 | using namespace clang::driver::tools; |
18 | using namespace clang; |
19 | using namespace llvm::opt; |
20 | |
21 | const char *sparc::getSparcAsmModeForCPU(StringRef Name, |
22 | const llvm::Triple &Triple) { |
23 | if (Triple.getArch() == llvm::Triple::sparcv9) { |
24 | return llvm::StringSwitch<const char *>(Name) |
25 | .Case("niagara", "-Av9b") |
26 | .Case("niagara2", "-Av9b") |
27 | .Case("niagara3", "-Av9d") |
28 | .Case("niagara4", "-Av9d") |
29 | .Default("-Av9"); |
30 | } else { |
31 | return llvm::StringSwitch<const char *>(Name) |
32 | .Case("v8", "-Av8") |
33 | .Case("supersparc", "-Av8") |
34 | .Case("sparclite", "-Asparclite") |
35 | .Case("f934", "-Asparclite") |
36 | .Case("hypersparc", "-Av8") |
37 | .Case("sparclite86x", "-Asparclite") |
38 | .Case("sparclet", "-Asparclet") |
39 | .Case("tsc701", "-Asparclet") |
40 | .Case("v9", "-Av8plus") |
41 | .Case("ultrasparc", "-Av8plus") |
42 | .Case("ultrasparc3", "-Av8plus") |
43 | .Case("niagara", "-Av8plusb") |
44 | .Case("niagara2", "-Av8plusb") |
45 | .Case("niagara3", "-Av8plusd") |
46 | .Case("niagara4", "-Av8plusd") |
47 | .Case("ma2100", "-Aleon") |
48 | .Case("ma2150", "-Aleon") |
49 | .Case("ma2155", "-Aleon") |
50 | .Case("ma2450", "-Aleon") |
51 | .Case("ma2455", "-Aleon") |
52 | .Case("ma2x5x", "-Aleon") |
53 | .Case("ma2080", "-Aleon") |
54 | .Case("ma2085", "-Aleon") |
55 | .Case("ma2480", "-Aleon") |
56 | .Case("ma2485", "-Aleon") |
57 | .Case("ma2x8x", "-Aleon") |
58 | .Case("myriad2", "-Aleon") |
59 | .Case("myriad2.1", "-Aleon") |
60 | .Case("myriad2.2", "-Aleon") |
61 | .Case("myriad2.3", "-Aleon") |
62 | .Case("leon2", "-Av8") |
63 | .Case("at697e", "-Av8") |
64 | .Case("at697f", "-Av8") |
65 | .Case("leon3", "-Aleon") |
66 | .Case("ut699", "-Av8") |
67 | .Case("gr712rc", "-Aleon") |
68 | .Case("leon4", "-Aleon") |
69 | .Case("gr740", "-Aleon") |
70 | .Default("-Av8"); |
71 | } |
72 | } |
73 | |
74 | sparc::FloatABI sparc::getSparcFloatABI(const Driver &D, |
75 | const ArgList &Args) { |
76 | sparc::FloatABI ABI = sparc::FloatABI::Invalid; |
77 | if (Arg *A = Args.getLastArg(clang::driver::options::OPT_msoft_float, |
78 | options::OPT_mhard_float, |
79 | options::OPT_mfloat_abi_EQ)) { |
80 | if (A->getOption().matches(clang::driver::options::OPT_msoft_float)) |
81 | ABI = sparc::FloatABI::Soft; |
82 | else if (A->getOption().matches(options::OPT_mhard_float)) |
83 | ABI = sparc::FloatABI::Hard; |
84 | else { |
85 | ABI = llvm::StringSwitch<sparc::FloatABI>(A->getValue()) |
86 | .Case("soft", sparc::FloatABI::Soft) |
87 | .Case("hard", sparc::FloatABI::Hard) |
88 | .Default(sparc::FloatABI::Invalid); |
89 | if (ABI == sparc::FloatABI::Invalid && |
90 | !StringRef(A->getValue()).empty()) { |
91 | D.Diag(clang::diag::err_drv_invalid_mfloat_abi) << A->getAsString(Args); |
92 | ABI = sparc::FloatABI::Hard; |
93 | } |
94 | } |
95 | } |
96 | |
97 | |
98 | |
99 | |
100 | |
101 | |
102 | if (ABI == sparc::FloatABI::Invalid) { |
103 | ABI = sparc::FloatABI::Hard; |
104 | } |
105 | |
106 | return ABI; |
107 | } |
108 | |
109 | void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args, |
110 | std::vector<StringRef> &Features) { |
111 | sparc::FloatABI FloatABI = sparc::getSparcFloatABI(D, Args); |
112 | if (FloatABI == sparc::FloatABI::Soft) |
113 | Features.push_back("+soft-float"); |
114 | } |
115 | |