Coverage Report

Created: 2020-09-19 12:23

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