LLVM 22.0.0git
XtensaTargetParser.cpp
Go to the documentation of this file.
1//==-- XtensaTargetParser - Parser for Xtensa 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 Xtensa hardware features
10//
11//===----------------------------------------------------------------------===//
12
14#include "llvm/ADT/STLExtras.h"
16
17namespace llvm {
18
19namespace Xtensa {
20struct CPUInfo {
24};
25
28 const char *NameCStr;
29 size_t NameLength;
30
32};
33
35#define XTENSA_FEATURE(ID, NAME) {ID, "+" NAME, sizeof(NAME)},
36#include "llvm/TargetParser/XtensaTargetParser.def"
37};
38
39constexpr CPUInfo XtensaCPUInfo[] = {
40#define XTENSA_CPU(ENUM, NAME, FEATURES) {NAME, CK_##ENUM, FEATURES},
41#include "llvm/TargetParser/XtensaTargetParser.def"
42};
43
46#define XTENSA_CPU_ALIAS(NAME, ANAME) .Case(ANAME, NAME)
47#include "llvm/TargetParser/XtensaTargetParser.def"
48 .Default(CPU);
49}
50
53#define XTENSA_CPU_ALIAS(NAME, ANAME) .Case(NAME, ANAME)
54#include "llvm/TargetParser/XtensaTargetParser.def"
55 .Default(CPU);
56}
57
59 CPU = getBaseName(CPU);
61#define XTENSA_CPU(ENUM, NAME, FEATURES) .Case(NAME, CK_##ENUM)
62#include "llvm/TargetParser/XtensaTargetParser.def"
63 .Default(CK_INVALID);
64}
65
66// Get all features for the CPU
67void getCPUFeatures(StringRef CPU, std::vector<StringRef> &Features) {
68 CPU = getBaseName(CPU);
70 [&](const CPUInfo &CI) { return CI.Name == CPU; });
71 assert(I != std::end(XtensaCPUInfo) && "CPU not found!");
72 uint64_t Bits = I->Features;
73
74 for (const auto &F : XtensaFeatureNames) {
75 if ((Bits & F.ID) == F.ID)
76 Features.push_back(F.getName());
77 }
78}
79
80// Find all valid CPUs
81void fillValidCPUList(std::vector<StringRef> &Values) {
82 for (const auto &C : XtensaCPUInfo) {
83 if (C.Kind != CK_INVALID) {
84 Values.emplace_back(C.Name);
86 if (Name != C.Name)
87 Values.emplace_back(Name);
88 }
89 }
90}
91
92} // namespace Xtensa
93} // namespace llvm
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
std::string Name
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
This file contains some templates that are useful if you are working with the STL at all.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
This file implements a target parser to recognise Xtensa hardware features.
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition: StringRef.h:862
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:43
R Default(T Value)
Definition: StringSwitch.h:177
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
void getCPUFeatures(StringRef CPU, SmallVectorImpl< StringRef > &Features)
StringRef getBaseName(StringRef CPU)
const FeatureName XtensaFeatureNames[]
StringRef getAliasName(StringRef CPU)
constexpr CPUInfo XtensaCPUInfo[]
void fillValidCPUList(SmallVectorImpl< StringRef > &Values)
CPUKind parseCPUKind(StringRef CPU)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1777