LLVM: lib/TargetParser/AArch64TargetParser.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

20#include

21#include

22

23#define DEBUG_TYPE "target-parser"

24

25using namespace llvm;

26

27#define EMIT_FMV_INFO

28#include "llvm/TargetParser/AArch64TargetParserDef.inc"

29

31 if (Arch.size() >= 2 && Arch[0] == 'v' && std::isdigit(Arch[1]))

32 return (Arch[1] - 48);

33 return 0;

34}

35

37

38 std::optional Cpu = parseCpu(CPU);

39 if (!Cpu)

40 return nullptr;

41 return &Cpu->Arch;

42}

43

45 for (const auto *A : AArch64::ArchInfos)

46 if (A->getSubArch() == SubArch)

47 return *A;

48 return {};

49}

50

51std::optionalAArch64::FMVInfo lookupFMVByID(AArch64::ArchExtKind ExtID) {

53 if (Info.ID == ExtID)

55 return {};

56}

57

59

61 for (const StringRef Feature : Features) {

63 if (!FMV && Feature.starts_with('+')) {

66 }

67 if (FMV && FMV->ID)

68 FeatureBits.enable(*FMV->ID);

69 }

70

71

74 if (Info.ID && FeatureBits.Enabled.test(*Info.ID))

75 PriorityMask.setBit(Info.PriorityBit);

76

77 return PriorityMask;

78}

79

81

83 for (const StringRef Feature : Features)

85 if (Info->ID)

86 FeatureBits.enable(*Info->ID);

87

88

91 if (Info.ID && FeatureBits.Enabled.test(*Info.ID))

92 FeaturesMask.setBit(Info.FeatureBit);

93

94 return FeaturesMask;

95}

96

99 std::vector &Features) {

101

102 if (InputExts.test(E.ID) && !E.PosTargetFeature.empty())

103 Features.push_back(E.PosTargetFeature);

104

105 return true;

106}

107

109 for (const auto &A : CpuAliases)

110 if (A.AltName == Name)

111 return A.Name;

112 return Name;

113}

114

116 bool IsNegated = ArchExt.starts_with("no");

118

120 assert(!(AE.has_value() && AE->NegTargetFeature.empty()));

121 return IsNegated ? AE->NegTargetFeature : AE->PosTargetFeature;

122 }

123

125}

126

128 for (const auto &C : CpuInfos)

130

131 for (const auto &Alias : CpuAliases)

132

135

137}

138

140 return TT.isAndroid() || TT.isOSDarwin() || TT.isOSFuchsia() ||

141 TT.isOSWindows() || TT.isOHOSFamily();

142}

143

144

148 return {};

149

151 for (const auto *A : ArchInfos) {

152 if (A->Name.ends_with(Syn))

153 return A;

154 }

155 return {};

156}

157

158std::optionalAArch64::ExtensionInfo

160 if (ArchExt.empty())

161 return {};

163 if (ArchExt == A.UserVisibleName || ArchExt == A.Alias)

164 return A;

165 }

166 return {};

167}

168

170

171 if (FMVExt == "rdma")

172 FMVExt = "rdm";

173

175 if (FMVExt == I.Name)

176 return I;

177 }

178 return {};

179}

180

181std::optionalAArch64::ExtensionInfo

184 if (TargetFeature == E.PosTargetFeature ||

185 TargetFeature == E.NegTargetFeature)

186 return E;

187 return {};

188}

189

191

193

194

195 for (const auto &C : CpuInfos)

196 if (Name == C.Name)

197 return C;

198

199 return {};

200}

201

203 outs() << "All available -march extensions for AArch64\n\n"

205 << left_justify("Architecture Feature(s)", 55)

206 << "Description\n";

208

209 if (!Ext.UserVisibleName.empty() && !Ext.PosTargetFeature.empty()) {

210 outs() << " "

211 << format(Ext.Description.empty() ? "%-20s%s\n" : "%-20s%-55s%s\n",

212 Ext.UserVisibleName.str().c_str(),

213 Ext.ArchFeatureName.str().c_str(),

214 Ext.Description.str().c_str());

215 }

216 }

217}

218

219void

221 outs() << "Extensions enabled for the given AArch64 target\n\n"

222 << " " << left_justify("Architecture Feature(s)", 55)

223 << "Description\n";

224 std::vector EnabledExtensionsInfo;

225 for (const auto &FeatureName : EnabledFeatureNames) {

226 std::string PosFeatureName = '+' + FeatureName.str();

228 EnabledExtensionsInfo.push_back(*ExtInfo);

229 }

230

231 std::sort(EnabledExtensionsInfo.begin(), EnabledExtensionsInfo.end(),

233 return Lhs.ArchFeatureName < Rhs.ArchFeatureName;

234 });

235

236 for (const auto &Ext : EnabledExtensionsInfo) {

237 outs() << " "

238 << format("%-55s%s\n",

239 Ext.ArchFeatureName.str().c_str(),

240 Ext.Description.str().c_str());

241 }

242}

243

246 for (const auto &E : llvm::AArch64::Extensions)

247 if (E.ID == ExtID)

248 return E;

250}

251

254 return;

255

257

260

261

262

263

264 for (auto Dep : ExtensionDependencies)

265 if (E == Dep.Later)

267

268

269

271

272 if (E == AEK_FP16 && BaseArch->is_superset(ARMV8_4A) &&

273 BaseArch->is_superset(ARMV9A))

275

276

277 if (E == AEK_CRYPTO && BaseArch->is_superset(ARMV8_4A)) {

280 }

281 }

282}

283

285

286

287 if (E == AEK_CRYPTO) {

292 }

293

294

295

296

297

298 if (E == AEK_SVE2AES)

300

301

302

303

304

305 if (E == AEK_SVE2SM4)

307

308

309

310

311

312 if (E == AEK_SVE2SHA3)

314

315 if (E == AEK_SVE2BITPERM){

318 }

319

321 return;

322

324

327

328

329 for (auto Dep : ExtensionDependencies)

330 if (E == Dep.Earlier)

332}

333

337

340 if (CPUExtensions.test(E.ID))

342}

343

352

354 const bool AllowNoDashForm) {

356

357 size_t NChars = 0;

358

359 if (AllowNoDashForm && Modifier.starts_with("no-"))

360 NChars = 3;

362 NChars = 2;

363 bool IsNegated = NChars != 0;

365

367 if (AE->PosTargetFeature.empty() || AE->NegTargetFeature.empty())

368 return false;

369 if (IsNegated)

371 else

373 return true;

374 }

375 return false;

376}

377

379 const std::vectorstd::string &Features,

380 std::vectorstd::string &NonExtensions) {

381 assert(Touched.none() && "Bitset already initialized");

382 for (auto &F : Features) {

383 bool IsNegated = F[0] == '-';

386 if (IsNegated)

388 else

390 continue;

391 }

392 NonExtensions.push_back(F);

393 }

394}

395

397 std::vector Features;

402}

403

407}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static unsigned checkArchVersion(llvm::StringRef Arch)

Definition AArch64TargetParser.cpp:30

const llvm::AArch64::ExtensionInfo & lookupExtensionByID(llvm::AArch64::ArchExtKind ExtID)

Definition AArch64TargetParser.cpp:245

std::optional< AArch64::FMVInfo > lookupFMVByID(AArch64::ArchExtKind ExtID)

Definition AArch64TargetParser.cpp:51

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

Analysis containing CSE Info

static cl::opt< std::set< SPIRV::Extension::Extension >, false, SPIRVExtensionsParser > Extensions("spirv-ext", cl::desc("Specify list of enabled SPIR-V extensions"))

Class for arbitrary precision integers.

void setBit(unsigned BitPosition)

Set the given bit to 1 whose position is given as "bitPosition".

static APInt getZero(unsigned numBits)

Get the '0' value for the specified bit-width.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

constexpr bool test(unsigned I) const

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

void push_back(const T &Elt)

StringRef - Represent a constant reference to a string, i.e.

bool starts_with(StringRef Prefix) const

Check if this string starts with the given Prefix.

constexpr bool empty() const

empty - Check if the string is empty.

StringRef drop_front(size_t N=1) const

Return a StringRef equal to 'this' but with the first N elements dropped.

constexpr size_t size() const

size - Get the string size.

Triple - Helper class for working with autoconf configuration names.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

LLVM_ABI bool isX18ReservedByDefault(const Triple &TT)

Definition AArch64TargetParser.cpp:139

LLVM_ABI StringRef getArchExtFeature(StringRef ArchExt)

Definition AArch64TargetParser.cpp:115

LLVM_ABI std::optional< ExtensionInfo > parseArchExtension(StringRef Extension)

Definition AArch64TargetParser.cpp:159

LLVM_ABI std::optional< CpuInfo > parseCpu(StringRef Name)

Definition AArch64TargetParser.cpp:190

LLVM_ABI const std::vector< FMVInfo > & getFMVInfo()

LLVM_ABI const ArchInfo * parseArch(StringRef Arch)

Definition AArch64TargetParser.cpp:145

LLVM_ABI const ArchInfo * getArchForCpu(StringRef CPU)

Definition AArch64TargetParser.cpp:36

LLVM_ABI const ExtensionInfo & getExtensionByID(ArchExtKind(ExtID))

LLVM_ABI void fillValidCPUArchList(SmallVectorImpl< StringRef > &Values)

Definition AArch64TargetParser.cpp:127

LLVM_ABI APInt getCpuSupportsMask(ArrayRef< StringRef > Features)

Definition AArch64TargetParser.cpp:80

LLVM_ABI void printEnabledExtensions(const std::set< StringRef > &EnabledFeatureNames)

Definition AArch64TargetParser.cpp:220

LLVM_ABI std::optional< FMVInfo > parseFMVExtension(StringRef Extension)

Definition AArch64TargetParser.cpp:169

Bitset< AEK_NUM_EXTENSIONS > ExtensionBitset

LLVM_ABI APInt getFMVPriority(ArrayRef< StringRef > Features)

Definition AArch64TargetParser.cpp:58

LLVM_ABI void PrintSupportedExtensions()

Definition AArch64TargetParser.cpp:202

LLVM_ABI std::optional< ExtensionInfo > targetFeatureToExtension(StringRef TargetFeature)

Definition AArch64TargetParser.cpp:182

LLVM_ABI StringRef resolveCPUAlias(StringRef CPU)

Definition AArch64TargetParser.cpp:108

LLVM_ABI bool getExtensionFeatures(const AArch64::ExtensionBitset &Extensions, std::vector< StringRef > &Features)

Definition AArch64TargetParser.cpp:97

LLVM_ABI StringRef getCanonicalArchName(StringRef Arch)

MArch is expected to be of the form (arm|thumb)?(eb)?(v.

LLVM_ABI StringRef getArchSynonym(StringRef Arch)

Converts e.g. "armv8" -> "armv8-a".

@ C

The default llvm calling convention, compatible with C.

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI raw_fd_ostream & outs()

This returns a reference to a raw_fd_ostream for standard output.

void sort(IteratorTy Start, IteratorTy End)

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

format_object< Ts... > format(const char *Fmt, const Ts &... Vals)

These are helper functions used to produce formatted output.

FormattedString left_justify(StringRef Str, unsigned Width)

left_justify - append spaces after string so total output is Width characters.

AArch64::ExtensionBitset DefaultExts

static LLVM_ABI std::optional< ArchInfo > findBySubArch(StringRef SubArch)

Definition AArch64TargetParser.cpp:44

LLVM_ABI bool parseModifier(StringRef Modifier, const bool AllowNoDashForm=false)

Definition AArch64TargetParser.cpp:353

LLVM_ABI void addCPUDefaults(const CpuInfo &CPU)

Definition AArch64TargetParser.cpp:334

LLVM_ABI void enable(ArchExtKind E)

Definition AArch64TargetParser.cpp:252

LLVM_ABI void disable(ArchExtKind E)

Definition AArch64TargetParser.cpp:284

void toLLVMFeatureList(std::vector< T > &Features) const

LLVM_ABI void dump() const

Definition AArch64TargetParser.cpp:396

const ArchInfo * BaseArch

LLVM_ABI void addArchDefaults(const ArchInfo &Arch)

Definition AArch64TargetParser.cpp:344

LLVM_ABI void reconstructFromParsedFeatures(const std::vector< std::string > &Features, std::vector< std::string > &NonExtensions)

Definition AArch64TargetParser.cpp:378