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#include <vector>
17
18namespace llvm {
19
20namespace Xtensa {
26
29 const char *NameCStr;
30 size_t NameLength;
31
33};
34
36#define XTENSA_FEATURE(ID, NAME) {ID, "+" NAME, sizeof(NAME)},
37#include "llvm/TargetParser/XtensaTargetParser.def"
38};
39
40constexpr CPUInfo XtensaCPUInfo[] = {
41#define XTENSA_CPU(ENUM, NAME, FEATURES) {NAME, CK_##ENUM, FEATURES},
42#include "llvm/TargetParser/XtensaTargetParser.def"
43};
44
47#define XTENSA_CPU_ALIAS(NAME, ANAME) .Case(ANAME, NAME)
48#include "llvm/TargetParser/XtensaTargetParser.def"
49 .Default(CPU);
50}
51
54#define XTENSA_CPU_ALIAS(NAME, ANAME) .Case(NAME, ANAME)
55#include "llvm/TargetParser/XtensaTargetParser.def"
56 .Default(CPU);
57}
58
60 CPU = getBaseName(CPU);
62#define XTENSA_CPU(ENUM, NAME, FEATURES) .Case(NAME, CK_##ENUM)
63#include "llvm/TargetParser/XtensaTargetParser.def"
64 .Default(CK_INVALID);
65}
66
67// Get all features for the CPU
68void getCPUFeatures(StringRef CPU, std::vector<StringRef> &Features) {
69 CPU = getBaseName(CPU);
71 [&](const CPUInfo &CI) { return CI.Name == CPU; });
72 assert(I != std::end(XtensaCPUInfo) && "CPU not found!");
73 uint64_t Bits = I->Features;
74
75 for (const auto &F : XtensaFeatureNames) {
76 if ((Bits & F.ID) == F.ID)
77 Features.push_back(F.getName());
78 }
79}
80
81// Find all valid CPUs
82void fillValidCPUList(std::vector<StringRef> &Values) {
83 for (const auto &C : XtensaCPUInfo) {
84 if (C.Kind != CK_INVALID) {
85 Values.emplace_back(C.Name);
86 StringRef Name = getAliasName(C.Name);
87 if (Name != C.Name)
88 Values.emplace_back(Name);
89 }
90 }
91}
92
93} // namespace Xtensa
94} // namespace llvm
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
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:854
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
A switch()-like statement whose cases are string literals.
@ 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.
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:1758