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 && *Info.ID == ExtID)

55 return {};

56}

57

59

61 for (const StringRef Feature : Features) {

63 if (!FMV) {

66 }

67 if (FMV && FMV->ID)

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

69 }

70

71

75 PriorityMask |= (1ULL << Info.PriorityBit);

76

77 return PriorityMask;

78}

79

81

83 for (const StringRef Feature : Features)

87

88

92 FeaturesMask |= (1ULL << 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;

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 return E;

186 return {};

187}

188

190

192

193

194 for (const auto &C : CpuInfos)

195 if (Name == C.Name)

196 return C;

197

198 return {};

199}

200

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

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

205 << "Description\n";

207

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

209 outs() << " "

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

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

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

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

214 }

215 }

216}

217

218void

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

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

222 << "Description\n";

223 std::vector EnabledExtensionsInfo;

224 for (const auto &FeatureName : EnabledFeatureNames) {

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

227 EnabledExtensionsInfo.push_back(*ExtInfo);

228 }

229

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

232 return Lhs.ArchFeatureName < Rhs.ArchFeatureName;

233 });

234

235 for (const auto &Ext : EnabledExtensionsInfo) {

236 outs() << " "

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

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

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

240 }

241}

242

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

246 if (E.ID == ExtID)

247 return E;

249}

250

253 return;

254

256

257 Touched.set(E);

259

260

261

262

263 for (auto Dep : ExtensionDependencies)

264 if (E == Dep.Later)

265 enable(Dep.Earlier);

266

267

268

269 if (BaseArch) {

270

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

272 !BaseArch->is_superset(ARMV9A))

273 enable(AEK_FP16FML);

274

275

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

277 enable(AEK_SHA3);

278 enable(AEK_SM4);

279 }

280 }

281}

282

284

285

286 if (E == AEK_CRYPTO) {

287 disable(AEK_AES);

288 disable(AEK_SHA2);

289 disable(AEK_SHA3);

290 disable(AEK_SM4);

291 }

292

293

294

295

296

297 if (E == AEK_SVE2AES)

298 disable(AEK_SVEAES);

299

300 if (E == AEK_SVE2BITPERM){

301 disable(AEK_SVEBITPERM);

302 disable(AEK_SVE2);

303 }

304

306 return;

307

309

310 Touched.set(E);

312

313

314 for (auto Dep : ExtensionDependencies)

315 if (E == Dep.Earlier)

316 disable(Dep.Later);

317}

318

321 BaseArch = &CPU.Arch;

322

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

326 enable(E.ID);

327}

328

331 BaseArch = &Arch;

332

335 enable(E.ID);

336}

337

339 const bool AllowNoDashForm) {

341

342 size_t NChars = 0;

343

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

345 NChars = 3;

347 NChars = 2;

348 bool IsNegated = NChars != 0;

350

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

353 return false;

354 if (IsNegated)

355 disable(AE->ID);

356 else

357 enable(AE->ID);

358 return true;

359 }

360 return false;

361}

362

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

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

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

367 for (auto &F : Features) {

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

370 Touched.set(AE->ID);

371 if (IsNegated)

373 else

375 continue;

376 }

377 NonExtensions.push_back(F);

378 }

379}

380

382 std::vector Features;

383 toLLVMFeatureList(Features);

387}

388

392}

static unsigned checkArchVersion(llvm::StringRef Arch)

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

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

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

Analysis containing CSE Info

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

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

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.

bool isX18ReservedByDefault(const Triple &TT)

StringRef getArchExtFeature(StringRef ArchExt)

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

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

const ArchInfo * parseArch(StringRef Arch)

const ArchInfo * getArchForCpu(StringRef CPU)

uint64_t getFMVPriority(ArrayRef< StringRef > Features)

void fillValidCPUArchList(SmallVectorImpl< StringRef > &Values)

const ExtensionInfo & getExtensionByID(ArchExtKind(ExtID))

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

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

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

void PrintSupportedExtensions()

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

StringRef resolveCPUAlias(StringRef CPU)

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

uint64_t getCpuSupportsMask(ArrayRef< StringRef > Features)

StringRef getCanonicalArchName(StringRef Arch)

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

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.

raw_fd_ostream & outs()

This returns a reference to a raw_fd_ostream for standard output.

void sort(IteratorTy Start, IteratorTy End)

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 std::optional< ArchInfo > findBySubArch(StringRef SubArch)

AArch64::ExtensionBitset getImpliedExtensions() const

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

void addCPUDefaults(const CpuInfo &CPU)

void enable(ArchExtKind E)

void disable(ArchExtKind E)

void addArchDefaults(const ArchInfo &Arch)

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