Path: blob/main/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
35294 views
//===--- SystemZ.cpp - SystemZ Helpers for Tools ----------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "SystemZ.h"9#include "clang/Config/config.h"10#include "clang/Driver/DriverDiagnostic.h"11#include "clang/Driver/Options.h"12#include "llvm/Option/ArgList.h"13#include "llvm/TargetParser/Host.h"1415using namespace clang::driver;16using namespace clang::driver::tools;17using namespace clang;18using namespace llvm::opt;1920systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D,21const ArgList &Args) {22// Hard float is the default.23systemz::FloatABI ABI = systemz::FloatABI::Hard;24if (Args.hasArg(options::OPT_mfloat_abi_EQ))25D.Diag(diag::err_drv_unsupported_opt)26<< Args.getLastArg(options::OPT_mfloat_abi_EQ)->getAsString(Args);2728if (Arg *A = Args.getLastArg(clang::driver::options::OPT_msoft_float,29options::OPT_mhard_float))30if (A->getOption().matches(clang::driver::options::OPT_msoft_float))31ABI = systemz::FloatABI::Soft;3233return ABI;34}3536std::string systemz::getSystemZTargetCPU(const ArgList &Args) {37if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {38llvm::StringRef CPUName = A->getValue();3940if (CPUName == "native") {41std::string CPU = std::string(llvm::sys::getHostCPUName());42if (!CPU.empty() && CPU != "generic")43return CPU;44else45return "";46}4748return std::string(CPUName);49}50return CLANG_SYSTEMZ_DEFAULT_ARCH;51}5253void systemz::getSystemZTargetFeatures(const Driver &D, const ArgList &Args,54std::vector<llvm::StringRef> &Features) {55// -m(no-)htm overrides use of the transactional-execution facility.56if (Arg *A = Args.getLastArg(options::OPT_mhtm, options::OPT_mno_htm)) {57if (A->getOption().matches(options::OPT_mhtm))58Features.push_back("+transactional-execution");59else60Features.push_back("-transactional-execution");61}62// -m(no-)vx overrides use of the vector facility.63if (Arg *A = Args.getLastArg(options::OPT_mvx, options::OPT_mno_vx)) {64if (A->getOption().matches(options::OPT_mvx))65Features.push_back("+vector");66else67Features.push_back("-vector");68}6970systemz::FloatABI FloatABI = systemz::getSystemZFloatABI(D, Args);71if (FloatABI == systemz::FloatABI::Soft)72Features.push_back("+soft-float");7374if (const Arg *A = Args.getLastArg(options::OPT_munaligned_symbols,75options::OPT_mno_unaligned_symbols)) {76if (A->getOption().matches(options::OPT_munaligned_symbols))77Features.push_back("+unaligned-symbols");78else79Features.push_back("-unaligned-symbols");80}81}828384