clang  6.0.0svn
Sparc.cpp
Go to the documentation of this file.
1 //===--- Sparc.cpp - Tools Implementations ----------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "Sparc.h"
11 #include "clang/Driver/Driver.h"
13 #include "clang/Driver/Options.h"
14 #include "llvm/ADT/StringSwitch.h"
15 #include "llvm/Option/ArgList.h"
16 
17 using namespace clang::driver;
18 using namespace clang::driver::tools;
19 using namespace clang;
20 using namespace llvm::opt;
21 
22 const char *sparc::getSparcAsmModeForCPU(StringRef Name,
23  const llvm::Triple &Triple) {
24  if (Triple.getArch() == llvm::Triple::sparcv9) {
25  return llvm::StringSwitch<const char *>(Name)
26  .Case("niagara", "-Av9b")
27  .Case("niagara2", "-Av9b")
28  .Case("niagara3", "-Av9d")
29  .Case("niagara4", "-Av9d")
30  .Default("-Av9");
31  } else {
32  return llvm::StringSwitch<const char *>(Name)
33  .Case("v8", "-Av8")
34  .Case("supersparc", "-Av8")
35  .Case("sparclite", "-Asparclite")
36  .Case("f934", "-Asparclite")
37  .Case("hypersparc", "-Av8")
38  .Case("sparclite86x", "-Asparclite")
39  .Case("sparclet", "-Asparclet")
40  .Case("tsc701", "-Asparclet")
41  .Case("v9", "-Av8plus")
42  .Case("ultrasparc", "-Av8plus")
43  .Case("ultrasparc3", "-Av8plus")
44  .Case("niagara", "-Av8plusb")
45  .Case("niagara2", "-Av8plusb")
46  .Case("niagara3", "-Av8plusd")
47  .Case("niagara4", "-Av8plusd")
48  .Case("leon2", "-Av8")
49  .Case("at697e", "-Av8")
50  .Case("at697f", "-Av8")
51  .Case("leon3", "-Av8")
52  .Case("ut699", "-Av8")
53  .Case("gr712rc", "-Av8")
54  .Case("leon4", "-Av8")
55  .Case("gr740", "-Av8")
56  .Default("-Av8");
57  }
58 }
59 
61  const ArgList &Args) {
63  if (Arg *A = Args.getLastArg(clang::driver::options::OPT_msoft_float,
64  options::OPT_mhard_float,
65  options::OPT_mfloat_abi_EQ)) {
66  if (A->getOption().matches(clang::driver::options::OPT_msoft_float))
68  else if (A->getOption().matches(options::OPT_mhard_float))
70  else {
71  ABI = llvm::StringSwitch<sparc::FloatABI>(A->getValue())
72  .Case("soft", sparc::FloatABI::Soft)
73  .Case("hard", sparc::FloatABI::Hard)
74  .Default(sparc::FloatABI::Invalid);
75  if (ABI == sparc::FloatABI::Invalid &&
76  !StringRef(A->getValue()).empty()) {
77  D.Diag(clang::diag::err_drv_invalid_mfloat_abi) << A->getAsString(Args);
79  }
80  }
81  }
82 
83  // If unspecified, choose the default based on the platform.
84  // Only the hard-float ABI on Sparc is standardized, and it is the
85  // default. GCC also supports a nonstandard soft-float ABI mode, also
86  // implemented in LLVM. However as this is not standard we set the default
87  // to be hard-float.
88  if (ABI == sparc::FloatABI::Invalid) {
90  }
91 
92  return ABI;
93 }
94 
95 void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args,
96  std::vector<StringRef> &Features) {
98  if (FloatABI == sparc::FloatABI::Soft)
99  Features.push_back("+soft-float");
100 }
const char * getSparcAsmModeForCPU(llvm::StringRef Name, const llvm::Triple &Triple)
FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args)
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:116
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:65
void getSparcTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector< llvm::StringRef > &Features)
Dataflow Directional Tag Classes.