head 1.1; branch 1.1.1; access; symbols netbsd-11-0-RC7:1.1.1.2 netbsd-11-0-RC6:1.1.1.2 netbsd-11-0-RC5:1.1.1.2 netbsd-11-0-RC4:1.1.1.2 netbsd-11-0-RC3:1.1.1.2 netbsd-11-0-RC2:1.1.1.2 netbsd-11-0-RC1:1.1.1.2 perseant-exfatfs-base-20250801:1.1.1.2 netbsd-11:1.1.1.2.0.8 netbsd-11-base:1.1.1.2 netbsd-10-1-RELEASE:1.1.1.2 perseant-exfatfs-base-20240630:1.1.1.2 perseant-exfatfs:1.1.1.2.0.6 perseant-exfatfs-base:1.1.1.2 netbsd-10-0-RELEASE:1.1.1.2 netbsd-10-0-RC6:1.1.1.2 netbsd-10-0-RC5:1.1.1.2 netbsd-10-0-RC4:1.1.1.2 netbsd-10-0-RC3:1.1.1.2 netbsd-10-0-RC2:1.1.1.2 netbsd-10-0-RC1:1.1.1.2 netbsd-10:1.1.1.2.0.4 netbsd-10-base:1.1.1.2 cjep_sun2x-base1:1.1.1.2 cjep_sun2x:1.1.1.2.0.2 cjep_sun2x-base:1.1.1.2 cjep_staticlib_x-base1:1.1.1.2 LLVM-249b40b558955afe5ac2b549edcf2d7f859c8cc9:1.1.1.2 cjep_staticlib_x:1.1.1.1.0.4 cjep_staticlib_x-base:1.1.1.1 phil-wifi-20200421:1.1.1.1 phil-wifi-20200411:1.1.1.1 is-mlppp:1.1.1.1.0.2 is-mlppp-base:1.1.1.1 phil-wifi-20200406:1.1.1.1 phil-wifi-20191119:1.1.1.1 LLVM-01f3a59fb3e2542fce74c768718f594d0debd0da:1.1.1.1 LLVM:1.1.1; locks; strict; comment @// @; 1.1 date 2019.11.08.14.30.02; author joerg; state Exp; branches 1.1.1.1; next ; commitid lIv69tfiG0KHw3KB; 1.1.1.1 date 2019.11.08.14.30.02; author joerg; state Exp; branches 1.1.1.1.4.1; next 1.1.1.2; commitid lIv69tfiG0KHw3KB; 1.1.1.2 date 2021.05.30.01.25.35; author joerg; state Exp; branches; next ; commitid uhgdinROdC6tU6VC; 1.1.1.1.4.1 date 2021.05.31.22.07.14; author cjep; state Exp; branches; next ; commitid eWz9SBW0XqKjJlVC; desc @@ 1.1 log @Initial revision @ text @//===--- PPC.cpp - PPC Helpers for Tools ------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "PPC.h" #include "ToolChains/CommonArgs.h" #include "clang/Driver/Driver.h" #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/Options.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Option/ArgList.h" #include "llvm/Support/Host.h" using namespace clang::driver; using namespace clang::driver::tools; using namespace clang; using namespace llvm::opt; /// getPPCTargetCPU - Get the (LLVM) name of the PowerPC cpu we are targeting. std::string ppc::getPPCTargetCPU(const ArgList &Args) { if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) { StringRef CPUName = A->getValue(); if (CPUName == "native") { std::string CPU = llvm::sys::getHostCPUName(); if (!CPU.empty() && CPU != "generic") return CPU; else return ""; } return llvm::StringSwitch(CPUName) .Case("common", "generic") .Case("440", "440") .Case("440fp", "440") .Case("450", "450") .Case("601", "601") .Case("602", "602") .Case("603", "603") .Case("603e", "603e") .Case("603ev", "603ev") .Case("604", "604") .Case("604e", "604e") .Case("620", "620") .Case("630", "pwr3") .Case("G3", "g3") .Case("7400", "7400") .Case("G4", "g4") .Case("7450", "7450") .Case("G4+", "g4+") .Case("750", "750") .Case("970", "970") .Case("G5", "g5") .Case("a2", "a2") .Case("a2q", "a2q") .Case("e500mc", "e500mc") .Case("e5500", "e5500") .Case("power3", "pwr3") .Case("power4", "pwr4") .Case("power5", "pwr5") .Case("power5x", "pwr5x") .Case("power6", "pwr6") .Case("power6x", "pwr6x") .Case("power7", "pwr7") .Case("power8", "pwr8") .Case("power9", "pwr9") .Case("pwr3", "pwr3") .Case("pwr4", "pwr4") .Case("pwr5", "pwr5") .Case("pwr5x", "pwr5x") .Case("pwr6", "pwr6") .Case("pwr6x", "pwr6x") .Case("pwr7", "pwr7") .Case("pwr8", "pwr8") .Case("pwr9", "pwr9") .Case("powerpc", "ppc") .Case("powerpc64", "ppc64") .Case("powerpc64le", "ppc64le") .Default(""); } return ""; } const char *ppc::getPPCAsmModeForCPU(StringRef Name) { return llvm::StringSwitch(Name) .Case("pwr7", "-mpower7") .Case("power7", "-mpower7") .Case("pwr8", "-mpower8") .Case("power8", "-mpower8") .Case("ppc64le", "-mpower8") .Case("pwr9", "-mpower9") .Case("power9", "-mpower9") .Default("-many"); } void ppc::getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple, const ArgList &Args, std::vector &Features) { handleTargetFeaturesGroup(Args, Features, options::OPT_m_ppc_Features_Group); ppc::FloatABI FloatABI = ppc::getPPCFloatABI(D, Args); if (FloatABI == ppc::FloatABI::Soft) Features.push_back("-hard-float"); ppc::ReadGOTPtrMode ReadGOT = ppc::getPPCReadGOTPtrMode(D, Triple, Args); if (ReadGOT == ppc::ReadGOTPtrMode::SecurePlt) Features.push_back("+secure-plt"); } ppc::ReadGOTPtrMode ppc::getPPCReadGOTPtrMode(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) { if (Args.getLastArg(options::OPT_msecure_plt)) return ppc::ReadGOTPtrMode::SecurePlt; if ((Triple.isOSFreeBSD() && Triple.getOSMajorVersion() >= 13) || Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl()) return ppc::ReadGOTPtrMode::SecurePlt; else return ppc::ReadGOTPtrMode::Bss; } ppc::FloatABI ppc::getPPCFloatABI(const Driver &D, const ArgList &Args) { ppc::FloatABI ABI = ppc::FloatABI::Invalid; if (Arg *A = Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float, options::OPT_mfloat_abi_EQ)) { if (A->getOption().matches(options::OPT_msoft_float)) ABI = ppc::FloatABI::Soft; else if (A->getOption().matches(options::OPT_mhard_float)) ABI = ppc::FloatABI::Hard; else { ABI = llvm::StringSwitch(A->getValue()) .Case("soft", ppc::FloatABI::Soft) .Case("hard", ppc::FloatABI::Hard) .Default(ppc::FloatABI::Invalid); if (ABI == ppc::FloatABI::Invalid && !StringRef(A->getValue()).empty()) { D.Diag(clang::diag::err_drv_invalid_mfloat_abi) << A->getAsString(Args); ABI = ppc::FloatABI::Hard; } } } // If unspecified, choose the default based on the platform. if (ABI == ppc::FloatABI::Invalid) { ABI = ppc::FloatABI::Hard; } return ABI; } bool ppc::hasPPCAbiArg(const ArgList &Args, const char *Value) { Arg *A = Args.getLastArg(options::OPT_mabi_EQ); return A && (A->getValue() == StringRef(Value)); } @ 1.1.1.1 log @Import 01f3a59fb3e2542fce74c768718f594d0debd0da from the LLVM mono-repo: clang (without test/, unittests/, www/) llvm (without test/, unittests/) @ text @@ 1.1.1.1.4.1 log @sync with head @ text @d29 1 a29 1 std::string CPU = std::string(llvm::sys::getHostCPUName()); a55 1 .Case("8548", "e500") d59 1 a59 1 .Case("e500", "e500") a70 2 .Case("power10", "pwr10") .Case("future", "future") a79 1 .Case("pwr10", "pwr10") d91 8 a98 10 .Case("pwr7", "-mpower7") .Case("power7", "-mpower7") .Case("pwr8", "-mpower8") .Case("power8", "-mpower8") .Case("ppc64le", "-mpower8") .Case("pwr9", "-mpower9") .Case("power9", "-mpower9") .Case("pwr10", "-mpower10") .Case("power10", "-mpower10") .Default("-many"); a103 3 if (Triple.getSubArch() == llvm::Triple::PPCSubArch_spe) Features.push_back("+spe"); @ 1.1.1.2 log @Import clang 249b40b558955afe5ac2b549edcf2d7f859c8cc9. @ text @d29 1 a29 1 std::string CPU = std::string(llvm::sys::getHostCPUName()); a55 1 .Case("8548", "e500") d59 1 a59 1 .Case("e500", "e500") a70 2 .Case("power10", "pwr10") .Case("future", "future") a79 1 .Case("pwr10", "pwr10") d91 8 a98 10 .Case("pwr7", "-mpower7") .Case("power7", "-mpower7") .Case("pwr8", "-mpower8") .Case("power8", "-mpower8") .Case("ppc64le", "-mpower8") .Case("pwr9", "-mpower9") .Case("power9", "-mpower9") .Case("pwr10", "-mpower10") .Case("power10", "-mpower10") .Default("-many"); a103 3 if (Triple.getSubArch() == llvm::Triple::PPCSubArch_spe) Features.push_back("+spe"); @