Coverage Report

Created: 2020-02-25 14:32

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- SystemZ.cpp - SystemZ Helpers for Tools ----------------*- 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 "SystemZ.h"
10
#include "clang/Driver/DriverDiagnostic.h"
11
#include "clang/Driver/Options.h"
12
#include "llvm/Option/ArgList.h"
13
#include "llvm/Support/Host.h"
14
15
using namespace clang::driver;
16
using namespace clang::driver::tools;
17
using namespace clang;
18
using namespace llvm::opt;
19
20
systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D,
21
114
                                              const ArgList &Args) {
22
114
  // Hard float is the default.
23
114
  systemz::FloatABI ABI = systemz::FloatABI::Hard;
24
114
  if (Args.hasArg(options::OPT_mfloat_abi_EQ))
25
6
    D.Diag(diag::err_drv_unsupported_opt)
26
6
      << Args.getLastArg(options::OPT_mfloat_abi_EQ)->getAsString(Args);
27
114
28
114
  if (Arg *A = Args.getLastArg(clang::driver::options::OPT_msoft_float,
29
8
                               options::OPT_mhard_float))
30
8
    if (A->getOption().matches(clang::driver::options::OPT_msoft_float))
31
6
      ABI = systemz::FloatABI::Soft;
32
114
33
114
  return ABI;
34
114
}
35
36
61
std::string systemz::getSystemZTargetCPU(const ArgList &Args) {
37
61
  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
38
28
    llvm::StringRef CPUName = A->getValue();
39
28
40
28
    if (CPUName == "native") {
41
0
      std::string CPU = std::string(llvm::sys::getHostCPUName());
42
0
      if (!CPU.empty() && CPU != "generic")
43
0
        return CPU;
44
0
      else
45
0
        return "";
46
28
    }
47
28
48
28
    return std::string(CPUName);
49
28
  }
50
33
  return "z10";
51
33
}
52
53
void systemz::getSystemZTargetFeatures(const Driver &D, const ArgList &Args,
54
58
                                       std::vector<llvm::StringRef> &Features) {
55
58
  // -m(no-)htm overrides use of the transactional-execution facility.
56
58
  if (Arg *A = Args.getLastArg(options::OPT_mhtm, options::OPT_mno_htm)) {
57
5
    if (A->getOption().matches(options::OPT_mhtm))
58
3
      Features.push_back("+transactional-execution");
59
2
    else
60
2
      Features.push_back("-transactional-execution");
61
5
  }
62
58
  // -m(no-)vx overrides use of the vector facility.
63
58
  if (Arg *A = Args.getLastArg(options::OPT_mvx, options::OPT_mno_vx)) {
64
5
    if (A->getOption().matches(options::OPT_mvx))
65
3
      Features.push_back("+vector");
66
2
    else
67
2
      Features.push_back("-vector");
68
5
  }
69
58
70
58
  systemz::FloatABI FloatABI = systemz::getSystemZFloatABI(D, Args);
71
58
  if (FloatABI == systemz::FloatABI::Soft)
72
3
    Features.push_back("+soft-float");
73
58
}