[clang] 2283d50 - [LoongArch] add la v1.1 features for sys::getHostCPUFeatures (#115832)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 13 19:25:37 PST 2024
Author: tangaac
Date: 2024-11-14T11:25:32+08:00
New Revision: 2283d50447369fc576eced8aca1cf0f54bdc235b
URL: https://github.com/llvm/llvm-project/commit/2283d50447369fc576eced8aca1cf0f54bdc235b
DIFF: https://github.com/llvm/llvm-project/commit/2283d50447369fc576eced8aca1cf0f54bdc235b.diff
LOG: [LoongArch] add la v1.1 features for sys::getHostCPUFeatures (#115832)
Two features (i.e. `frecipe` and `lam-bh`) are added to
`sys.getHostCPUFeatures`. More features will be added in future.
In addition, this patch adds the features returned by
`sys.getHostCPUFeature` when `-march=native`.
Added:
Modified:
clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
llvm/lib/TargetParser/Host.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
index e69a5562137ccd..987db4638fca88 100644
--- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -135,10 +135,15 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D,
Features.push_back("+lsx");
std::string ArchName;
- if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
- ArchName = A->getValue();
+ const Arg *MArch = Args.getLastArg(options::OPT_march_EQ);
+ if (MArch)
+ ArchName = MArch->getValue();
ArchName = postProcessTargetCPUString(ArchName, Triple);
llvm::LoongArch::getArchFeatures(ArchName, Features);
+ if (MArch && StringRef(MArch->getValue()) == "native")
+ for (auto &F : llvm::sys::getHostCPUFeatures())
+ Features.push_back(
+ Args.MakeArgString((F.second ? "+" : "-") + F.first()));
// Select floating-point features determined by -mdouble-float,
// -msingle-float, -msoft-float and -mfpu.
diff --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index 85a637cfc197ec..a7891d799ae409 100644
--- a/llvm/lib/TargetParser/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -2010,6 +2010,15 @@ const StringMap<bool> sys::getHostCPUFeatures() {
Features["lasx"] = hwcap & (1UL << 5); // HWCAP_LOONGARCH_LASX
Features["lvz"] = hwcap & (1UL << 9); // HWCAP_LOONGARCH_LVZ
+ Features["frecipe"] = cpucfg2 & (1U << 25); // CPUCFG.2.FRECIPE
+ Features["lam-bh"] = cpucfg2 & (1U << 27); // CPUCFG.2.LAM_BH
+
+ // TODO: Need to complete.
+ // Features["div32"] = cpucfg2 & (1U << 26); // CPUCFG.2.DIV32
+ // Features["lamcas"] = cpucfg2 & (1U << 28); // CPUCFG.2.LAMCAS
+ // Features["llacq-screl"] = cpucfg2 & (1U << 29); // CPUCFG.2.LLACQ_SCREL
+ // Features["scq"] = cpucfg2 & (1U << 30); // CPUCFG.2.SCQ
+ // Features["ld-seq-sa"] = cpucfg3 & (1U << 23); // CPUCFG.3.LD_SEQ_SA
return Features;
}
#elif defined(__linux__) && defined(__riscv)
More information about the cfe-commits
mailing list