1 //==-- LoongArch64TargetParser - Parser for LoongArch64 features --*- C++ -*-=//
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
7 //===----------------------------------------------------------------------===//
9 // This file implements a target parser to recognise LoongArch hardware features
10 // such as CPU/ARCH and extension names.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/TargetParser/LoongArchTargetParser.h"
17 using namespace llvm::LoongArch
;
19 const FeatureInfo AllFeatures
[] = {
20 #define LOONGARCH_FEATURE(NAME, KIND) {NAME, KIND},
21 #include "llvm/TargetParser/LoongArchTargetParser.def"
24 const ArchInfo AllArchs
[] = {
25 #define LOONGARCH_ARCH(NAME, KIND, FEATURES) \
26 {NAME, LoongArch::ArchKind::KIND, FEATURES},
27 #include "llvm/TargetParser/LoongArchTargetParser.def"
30 LoongArch::ArchKind
LoongArch::parseArch(StringRef Arch
) {
31 for (const auto A
: AllArchs
)
35 return LoongArch::ArchKind::AK_INVALID
;
38 bool LoongArch::getArchFeatures(StringRef Arch
,
39 std::vector
<StringRef
> &Features
) {
40 for (const auto A
: AllArchs
) {
42 for (const auto F
: AllFeatures
)
43 if ((A
.Features
& F
.Kind
) == F
.Kind
&& F
.Kind
!= FK_INVALID
)
44 Features
.push_back(F
.Name
);