LLVM 22.0.0git
Spelling.cpp
Go to the documentation of this file.
1//===-------------------------------------------------------------- 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
10
11#include "llvm/ADT/StringRef.h"
13
14#include <cassert>
15
16using namespace llvm;
17
18static bool Contains(directive::VersionRange V, int P) {
19 return V.Min <= P && P <= V.Max;
20}
21
24 assert(llvm::isInt<8 * sizeof(int)>(Version) && "Version value out of range");
25
26 int V = Version;
27 // Do a linear search to find the first Spelling that contains Version.
28 // The condition "contains(S, Version)" does not partition the list of
29 // spellings, so std::[lower|upper]_bound cannot be used.
30 // In practice the list of spellings is expected to be very short, so
31 // linear search seems appropriate. In general, an interval tree may be
32 // a better choice, but in this case it may be an overkill.
33 for (auto &S : Range) {
34 if (Contains(S.Versions, V))
35 return S.Name;
36 }
37 return StringRef();
38}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
#define P(N)
static bool Contains(directive::VersionRange V, int P)
Definition: Spelling.cpp:18
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
A range adaptor for a pair of iterators.
LLVM_ABI StringRef FindName(llvm::iterator_range< const Spelling * >, unsigned Version)
Definition: Spelling.cpp:22
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
Definition: MathExtras.h:174