LLVM 20.0.0git
LoongArchTargetParser.cpp
Go to the documentation of this file.
1//===-- LoongArchTargetParser - Parser for LoongArch 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 true;
34 return false;
35}
36
38 std::vector<StringRef> &Features) {
39 for (const auto A : AllArchs) {
40 if (A.Name == Arch) {
41 for (const auto F : AllFeatures)
42 if ((A.Features & F.Kind) == F.Kind)
43 Features.push_back(F.Name);
44 return true;
45 }
46 }
47
48 if (Arch == "la64v1.0" || Arch == "la64v1.1") {
49 Features.push_back("+64bit");
50 Features.push_back("+d");
51 Features.push_back("+lsx");
52 Features.push_back("+ual");
53 if (Arch == "la64v1.1")
54 Features.push_back("+frecipe");
55 return true;
56 }
57
58 return false;
59}
60
62
64 for (const auto A : AllArchs)
65 Values.emplace_back(A.Name);
66}
67
69 // TODO: use a real 32-bit arch name.
70 return Is64Bit ? "loongarch64" : "";
71}
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
std::string Name
const FeatureInfo AllFeatures[]
const ArchInfo AllArchs[]
#define F(x, y, z)
Definition: MD5.cpp:55
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:950
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
StringRef getDefaultArch(bool Is64Bit)
bool getArchFeatures(StringRef Arch, std::vector< StringRef > &Features)
bool isValidCPUName(StringRef TuneCPU)
bool isValidArchName(StringRef Arch)
void fillValidCPUList(SmallVectorImpl< StringRef > &Values)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18