LLVM 17.0.0git
LoongArchTargetParser.cpp
Go to the documentation of this file.
1//==-- LoongArch64TargetParser - Parser for LoongArch64 features --*- C++ -*-=//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements a target parser to recognise LoongArch hardware features
10// such as CPU/ARCH and extension names.
11//
12//===----------------------------------------------------------------------===//
13
15
16using namespace llvm;
17using namespace llvm::LoongArch;
18
20#define LOONGARCH_FEATURE(NAME, KIND) {NAME, KIND},
21#include "llvm/TargetParser/LoongArchTargetParser.def"
22};
23
24const ArchInfo AllArchs[] = {
25#define LOONGARCH_ARCH(NAME, KIND, FEATURES) \
26 {NAME, LoongArch::ArchKind::KIND, FEATURES},
27#include "llvm/TargetParser/LoongArchTargetParser.def"
28};
29
31 for (const auto A : AllArchs)
32 if (A.Name == Arch)
33 return A.Kind;
34
35 return LoongArch::ArchKind::AK_INVALID;
36}
37
39 std::vector<StringRef> &Features) {
40 for (const auto A : AllArchs) {
41 if (A.Name == Arch) {
42 for (const auto F : AllFeatures)
43 if ((A.Features & F.Kind) == F.Kind && F.Kind != FK_INVALID)
44 Features.push_back(F.Name);
45 return true;
46 }
47 }
48 return false;
49}
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
const FeatureInfo AllFeatures[]
const ArchInfo AllArchs[]
#define F(x, y, z)
Definition: MD5.cpp:55
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
bool getArchFeatures(StringRef Arch, std::vector< StringRef > &Features)
ArchKind parseArch(StringRef Arch)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18