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

61 if (std::optionalAArch64::ExtensionInfo Ext =

64 return FMV;

65}

66

68

71 for (const StringRef Feature : Features) {

72 if (std::optional FMV = getFMVInfoFrom(Feature)) {

73

74 if (FMV->ID)

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

76 else

77 PriorityMask.setBit(FMV->PriorityBit);

78 }

79 }

80

81

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

84 PriorityMask.setBit(Info.PriorityBit);

85

86 return PriorityMask;

87}

88

90

92 for (const StringRef Feature : Features)

93 if (std::optional FMV = getFMVInfoFrom(Feature))

94 if (FMV->ID)

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

96

97

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

101 FeaturesMask.setBit(*Info.FeatureBit);

102

103 return FeaturesMask;

104}

105

108 std::vector &Features) {

110

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

112 Features.push_back(E.PosTargetFeature);

113

114 return true;

115}

116

118 for (const auto &A : CpuAliases)

119 if (A.AltName == Name)

120 return A.Name;

121 return Name;

122}

123

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

127

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

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

131 }

132

134}

135

137 for (const auto &C : CpuInfos)

139

140 for (const auto &Alias : CpuAliases)

141

144

146}

147

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

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

151}

152

153

157 return {};

158

160 for (const auto *A : ArchInfos) {

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

162 return A;

163 }

164 return {};

165}

166

167std::optionalAArch64::ExtensionInfo

169 if (ArchExt.empty())

170 return {};

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

173 return A;

174 }

175 return {};

176}

177

179

180 if (FMVExt == "rdma")

181 FMVExt = "rdm";

182

184 if (FMVExt == I.Name)

185 return I;

186 }

187 return {};

188}

189

190std::optionalAArch64::ExtensionInfo

193 if (TargetFeature == E.PosTargetFeature ||

194 TargetFeature == E.NegTargetFeature)

195 return E;

196 return {};

197}

198

200

202

203

204 for (const auto &C : CpuInfos)

205 if (Name == C.Name)

206 return C;

207

208 return {};

209}

210

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

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

215 << "Description\n";

217

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

219 outs() << " "

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

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

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

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

224 }

225 }

226}

227

228void

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

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

232 << "Description\n";

233 std::vector EnabledExtensionsInfo;

234 for (const auto &FeatureName : EnabledFeatureNames) {

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

237 EnabledExtensionsInfo.push_back(*ExtInfo);

238 }

239

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

242 return Lhs.ArchFeatureName < Rhs.ArchFeatureName;

243 });

244

245 for (const auto &Ext : EnabledExtensionsInfo) {

246 outs() << " "

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

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

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

250 }

251}

252

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

256 if (E.ID == ExtID)

257 return E;

259}

260

263 return;

264

266

269

270

271

272

273 for (auto Dep : ExtensionDependencies)

274 if (E == Dep.Later)

276

277

278

280

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

282 BaseArch->is_superset(ARMV9A))

284

285

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

289 }

290 }

291}

292

294

295

296 if (E == AEK_CRYPTO) {

301 }

302

303

304

305

306

307 if (E == AEK_SVE2AES)

309

310

311

312

313

314 if (E == AEK_SVE2SM4)

316

317

318

319

320

321 if (E == AEK_SVE2SHA3)

323

324 if (E == AEK_SVE2BITPERM){

327 }

328

330 return;

331

333

336

337

338 for (auto Dep : ExtensionDependencies)

339 if (E == Dep.Earlier)

341}

342

346

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

351}

352

361

363 const bool AllowNoDashForm) {

365

366 size_t NChars = 0;

367

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

369 NChars = 3;

371 NChars = 2;

372 bool IsNegated = NChars != 0;

374

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

377 return false;

378 if (IsNegated)

380 else

382 return true;

383 }

384 return false;

385}

386

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

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

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

391 for (auto &F : Features) {

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

395 if (IsNegated)

397 else

399 continue;

400 }

401 NonExtensions.push_back(F);

402 }

403}

404

406 std::vector Features;

411}

412

416}

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

std::optional< AArch64::FMVInfo > getFMVInfoFrom(StringRef Feature)

Definition AArch64TargetParser.cpp:58

static unsigned checkArchVersion(llvm::StringRef Arch)

Definition AArch64TargetParser.cpp:30

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

Definition AArch64TargetParser.cpp:254

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:148

LLVM_ABI StringRef getArchExtFeature(StringRef ArchExt)

Definition AArch64TargetParser.cpp:124

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

Definition AArch64TargetParser.cpp:168

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

Definition AArch64TargetParser.cpp:199

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

LLVM_ABI const ArchInfo * parseArch(StringRef Arch)

Definition AArch64TargetParser.cpp:154

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:136

LLVM_ABI APInt getCpuSupportsMask(ArrayRef< StringRef > Features)

Definition AArch64TargetParser.cpp:89

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

Definition AArch64TargetParser.cpp:229

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

Definition AArch64TargetParser.cpp:178

Bitset< AEK_NUM_EXTENSIONS > ExtensionBitset

LLVM_ABI APInt getFMVPriority(ArrayRef< StringRef > Features)

Definition AArch64TargetParser.cpp:67

LLVM_ABI void PrintSupportedExtensions()

Definition AArch64TargetParser.cpp:211

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

Definition AArch64TargetParser.cpp:191

LLVM_ABI StringRef resolveCPUAlias(StringRef CPU)

Definition AArch64TargetParser.cpp:117

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

Definition AArch64TargetParser.cpp:106

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:362

LLVM_ABI void addCPUDefaults(const CpuInfo &CPU)

Definition AArch64TargetParser.cpp:343

LLVM_ABI void enable(ArchExtKind E)

Definition AArch64TargetParser.cpp:261

LLVM_ABI void disable(ArchExtKind E)

Definition AArch64TargetParser.cpp:293

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

LLVM_ABI void dump() const

Definition AArch64TargetParser.cpp:405

const ArchInfo * BaseArch

LLVM_ABI void addArchDefaults(const ArchInfo &Arch)

Definition AArch64TargetParser.cpp:353

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

Definition AArch64TargetParser.cpp:387