Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
Line
Count
Source
1
//===--- Sparc.cpp - Tools Implementations ----------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
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
118
                                         const llvm::Triple &Triple) {
23
118
  if (Triple.getArch() == llvm::Triple::sparcv9) {
24
44
    return llvm::StringSwitch<const char *>(Name)
25
44
        .Case("niagara", "-Av9b")
26
44
        .Case("niagara2", "-Av9b")
27
44
        .Case("niagara3", "-Av9d")
28
44
        .Case("niagara4", "-Av9d")
29
44
        .Default("-Av9");
30
74
  } else {
31
74
    return llvm::StringSwitch<const char *>(Name)
32
74
        .Case("v8", "-Av8")
33
74
        .Case("supersparc", "-Av8")
34
74
        .Case("sparclite", "-Asparclite")
35
74
        .Case("f934", "-Asparclite")
36
74
        .Case("hypersparc", "-Av8")
37
74
        .Case("sparclite86x", "-Asparclite")
38
74
        .Case("sparclet", "-Asparclet")
39
74
        .Case("tsc701", "-Asparclet")
40
74
        .Case("v9", "-Av8plus")
41
74
        .Case("ultrasparc", "-Av8plus")
42
74
        .Case("ultrasparc3", "-Av8plus")
43
74
        .Case("niagara", "-Av8plusb")
44
74
        .Case("niagara2", "-Av8plusb")
45
74
        .Case("niagara3", "-Av8plusd")
46
74
        .Case("niagara4", "-Av8plusd")
47
74
        .Case("ma2100", "-Aleon")
48
74
        .Case("ma2150", "-Aleon")
49
74
        .Case("ma2155", "-Aleon")
50
74
        .Case("ma2450", "-Aleon")
51
74
        .Case("ma2455", "-Aleon")
52
74
        .Case("ma2x5x", "-Aleon")
53
74
        .Case("ma2080", "-Aleon")
54
74
        .Case("ma2085", "-Aleon")
55
74
        .Case("ma2480", "-Aleon")
56
74
        .Case("ma2485", "-Aleon")
57
74
        .Case("ma2x8x", "-Aleon")
58
74
        .Case("myriad2", "-Aleon")
59
74
        .Case("myriad2.1", "-Aleon")
60
74
        .Case("myriad2.2", "-Aleon")
61
74
        .Case("myriad2.3", "-Aleon")
62
74
        .Case("leon2", "-Av8")
63
74
        .Case("at697e", "-Av8")
64
74
        .Case("at697f", "-Av8")
65
74
        .Case("leon3", "-Aleon")
66
74
        .Case("ut699", "-Av8")
67
74
        .Case("gr712rc", "-Aleon")
68
74
        .Case("leon4", "-Aleon")
69
74
        .Case("gr740", "-Aleon")
70
74
        .Default("-Av8");
71
74
  }
72
118
}
73
74
sparc::FloatABI sparc::getSparcFloatABI(const Driver &D,
75
312
                                        const ArgList &Args) {
76
312
  sparc::FloatABI ABI = sparc::FloatABI::Invalid;
77
312
  if (Arg *A = Args.getLastArg(clang::driver::options::OPT_msoft_float,
78
20
                               options::OPT_mhard_float,
79
20
                               options::OPT_mfloat_abi_EQ)) {
80
20
    if (A->getOption().matches(clang::driver::options::OPT_msoft_float))
81
4
      ABI = sparc::FloatABI::Soft;
82
16
    else if (A->getOption().matches(options::OPT_mhard_float))
83
4
      ABI = sparc::FloatABI::Hard;
84
12
    else {
85
12
      ABI = llvm::StringSwitch<sparc::FloatABI>(A->getValue())
86
12
                .Case("soft", sparc::FloatABI::Soft)
87
12
                .Case("hard", sparc::FloatABI::Hard)
88
12
                .Default(sparc::FloatABI::Invalid);
89
12
      if (ABI == sparc::FloatABI::Invalid &&
90
12
          
!StringRef(A->getValue()).empty()4
) {
91
4
        D.Diag(clang::diag::err_drv_invalid_mfloat_abi) << A->getAsString(Args);
92
4
        ABI = sparc::FloatABI::Hard;
93
4
      }
94
12
    }
95
20
  }
96
312
97
312
  // If unspecified, choose the default based on the platform.
98
312
  // Only the hard-float ABI on Sparc is standardized, and it is the
99
312
  // default. GCC also supports a nonstandard soft-float ABI mode, also
100
312
  // implemented in LLVM. However as this is not standard we set the default
101
312
  // to be hard-float.
102
312
  if (ABI == sparc::FloatABI::Invalid) {
103
292
    ABI = sparc::FloatABI::Hard;
104
292
  }
105
312
106
312
  return ABI;
107
312
}
108
109
void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args,
110
156
                                   std::vector<StringRef> &Features) {
111
156
  sparc::FloatABI FloatABI = sparc::getSparcFloatABI(D, Args);
112
156
  if (FloatABI == sparc::FloatABI::Soft)
113
4
    Features.push_back("+soft-float");
114
156
}