File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
clang/lib/Driver/ToolChains/Arch Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 1414#include " clang/Driver/Options.h"
1515#include " llvm/TargetParser/Host.h"
1616#include " llvm/TargetParser/LoongArchTargetParser.h"
17+ #include < string>
1718
1819using namespace clang ::driver;
1920using namespace clang ::driver::tools;
@@ -135,10 +136,15 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D,
135136 Features.push_back (" +lsx" );
136137
137138 std::string ArchName;
138- if (const Arg *A = Args.getLastArg (options::OPT_march_EQ))
139- ArchName = A->getValue ();
139+ const Arg *MArch = Args.getLastArg (options::OPT_march_EQ);
140+ if (MArch)
141+ ArchName = MArch->getValue ();
140142 ArchName = postProcessTargetCPUString (ArchName, Triple);
141143 llvm::LoongArch::getArchFeatures (ArchName, Features);
144+ if ((std::string)(MArch->getValue ()) == " native" )
145+ for (auto &F : llvm::sys::getHostCPUFeatures ())
146+ Features.push_back (
147+ Args.MakeArgString ((F.second ? " +" : " -" ) + F.first ()));
142148
143149 // Select floating-point features determined by -mdouble-float,
144150 // -msingle-float, -msoft-float and -mfpu.
Original file line number Diff line number Diff line change @@ -2006,6 +2006,15 @@ const StringMap<bool> sys::getHostCPUFeatures() {
20062006 Features[" lasx" ] = hwcap & (1UL << 5 ); // HWCAP_LOONGARCH_LASX
20072007 Features[" lvz" ] = hwcap & (1UL << 9 ); // HWCAP_LOONGARCH_LVZ
20082008
2009+ Features[" frecipe" ] = cpucfg2 & (1U << 25 ); // CPUCFG.2.FRECIPE
2010+ Features[" lam-bh" ] = cpucfg2 & (1U << 27 ); // CPUCFG.2.LAM_BH
2011+
2012+ // TODO: Need to complete.
2013+ // Features["div32"] = cpucfg2 & (1U << 26); // CPUCFG.2.DIV32
2014+ // Features["lamcas"] = cpucfg2 & (1U << 28); // CPUCFG.2.LAMCAS
2015+ // Features["llacq-screl"] = cpucfg2 & (1U << 29); // CPUCFG.2.LLACQ_SCREL
2016+ // Features["scq"] = cpucfg2 & (1U << 30); // CPUCFG.2.SCQ
2017+ // Features["ld-seq-sa"] = cpucfg3 & (1U << 23); // CPUCFG.3.LD_SEQ_SA
20092018 return Features;
20102019}
20112020#elif defined(__linux__) && defined(__riscv)
You can’t perform that action at this time.
0 commit comments