Coverage Report

Created: 2020-09-22 08:39

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