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 14
14
#include " clang/Driver/Options.h"
15
15
#include " llvm/TargetParser/Host.h"
16
16
#include " llvm/TargetParser/LoongArchTargetParser.h"
17
+ #include < string>
17
18
18
19
using namespace clang ::driver;
19
20
using namespace clang ::driver::tools;
@@ -135,10 +136,15 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D,
135
136
Features.push_back (" +lsx" );
136
137
137
138
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 ();
140
142
ArchName = postProcessTargetCPUString (ArchName, Triple);
141
143
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 ()));
142
148
143
149
// Select floating-point features determined by -mdouble-float,
144
150
// -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() {
2006
2006
Features[" lasx" ] = hwcap & (1UL << 5 ); // HWCAP_LOONGARCH_LASX
2007
2007
Features[" lvz" ] = hwcap & (1UL << 9 ); // HWCAP_LOONGARCH_LVZ
2008
2008
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
2009
2018
return Features;
2010
2019
}
2011
2020
#elif defined(__linux__) && defined(__riscv)
You can’t perform that action at this time.
0 commit comments