clang  14.0.0git
SystemZ.cpp
Go to the documentation of this file.
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"
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 
22  const ArgList &Args) {
23  // Hard float is the default.
25  if (Args.hasArg(options::OPT_mfloat_abi_EQ))
26  D.Diag(diag::err_drv_unsupported_opt)
27  << Args.getLastArg(options::OPT_mfloat_abi_EQ)->getAsString(Args);
28 
29  if (Arg *A = Args.getLastArg(clang::driver::options::OPT_msoft_float,
30  options::OPT_mhard_float))
31  if (A->getOption().matches(clang::driver::options::OPT_msoft_float))
33 
34  return ABI;
35 }
36 
37 std::string systemz::getSystemZTargetCPU(const ArgList &Args) {
38  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
39  llvm::StringRef CPUName = A->getValue();
40 
41  if (CPUName == "native") {
42  std::string CPU = std::string(llvm::sys::getHostCPUName());
43  if (!CPU.empty() && CPU != "generic")
44  return CPU;
45  else
46  return "";
47  }
48 
49  return std::string(CPUName);
50  }
51  return CLANG_SYSTEMZ_DEFAULT_ARCH;
52 }
53 
54 void systemz::getSystemZTargetFeatures(const Driver &D, const ArgList &Args,
55  std::vector<llvm::StringRef> &Features) {
56  // -m(no-)htm overrides use of the transactional-execution facility.
57  if (Arg *A = Args.getLastArg(options::OPT_mhtm, options::OPT_mno_htm)) {
58  if (A->getOption().matches(options::OPT_mhtm))
59  Features.push_back("+transactional-execution");
60  else
61  Features.push_back("-transactional-execution");
62  }
63  // -m(no-)vx overrides use of the vector facility.
64  if (Arg *A = Args.getLastArg(options::OPT_mvx, options::OPT_mno_vx)) {
65  if (A->getOption().matches(options::OPT_mvx))
66  Features.push_back("+vector");
67  else
68  Features.push_back("-vector");
69  }
70 
73  Features.push_back("+soft-float");
74 }
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::driver::tools::systemz::FloatABI::Soft
@ Soft
clang::driver::tools
Definition: AIX.h:17
SystemZ.h
clang::driver::Driver::Diag
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:112
clang::driver::tools::systemz::getSystemZTargetFeatures
void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector< llvm::StringRef > &Features)
clang::driver::tools::arm::FloatABI
FloatABI
Definition: ARM.h:43
Options.h
llvm::opt
Definition: DiagnosticOptions.h:19
DriverDiagnostic.h
clang::driver::tools::systemz::FloatABI::Hard
@ Hard
clang::driver::tools::systemz::getSystemZTargetCPU
std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args)
clang
Definition: CalledOnceCheck.h:17
clang::driver::Driver
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:59
clang::driver::tools::systemz::getSystemZFloatABI
FloatABI getSystemZFloatABI(const Driver &D, const llvm::opt::ArgList &Args)
clang::driver
Definition: Action.h:31
clang::driver::tools::systemz::FloatABI
FloatABI
Definition: SystemZ.h:23