clang  17.0.0git
TargetID.h
Go to the documentation of this file.
1 //===--- TargetID.h - Utilities for target ID -------------------*- 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 #ifndef LLVM_CLANG_BASIC_TARGETID_H
10 #define LLVM_CLANG_BASIC_TARGETID_H
11 
12 #include "llvm/ADT/SmallVector.h"
13 #include "llvm/ADT/StringMap.h"
14 #include "llvm/ADT/Triple.h"
15 #include <optional>
16 #include <set>
17 
18 namespace clang {
19 
20 /// Get all feature strings that can be used in target ID for \p Processor.
21 /// Target ID is a processor name with optional feature strings
22 /// postfixed by a plus or minus sign delimited by colons, e.g.
23 /// gfx908:xnack+:sramecc-. Each processor have a limited
24 /// number of predefined features when showing up in a target ID.
26 getAllPossibleTargetIDFeatures(const llvm::Triple &T,
27  llvm::StringRef Processor);
28 
29 /// Get processor name from target ID.
30 /// Returns canonical processor name or empty if the processor name is invalid.
31 llvm::StringRef getProcessorFromTargetID(const llvm::Triple &T,
32  llvm::StringRef OffloadArch);
33 
34 /// Parse a target ID to get processor and feature map.
35 /// Returns canonicalized processor name or std::nullopt if the target ID is
36 /// invalid. Returns target ID features in \p FeatureMap if it is not null
37 /// pointer. This function assumes \p OffloadArch is a valid target ID.
38 /// If the target ID contains feature+, map it to true.
39 /// If the target ID contains feature-, map it to false.
40 /// If the target ID does not contain a feature (default), do not map it.
41 std::optional<llvm::StringRef> parseTargetID(const llvm::Triple &T,
42  llvm::StringRef OffloadArch,
43  llvm::StringMap<bool> *FeatureMap);
44 
45 /// Returns canonical target ID, assuming \p Processor is canonical and all
46 /// entries in \p Features are valid.
47 std::string getCanonicalTargetID(llvm::StringRef Processor,
48  const llvm::StringMap<bool> &Features);
49 
50 /// Get the conflicted pair of target IDs for a compilation or a bundled code
51 /// object, assuming \p TargetIDs are canonicalized. If there is no conflicts,
52 /// returns std::nullopt.
53 std::optional<std::pair<llvm::StringRef, llvm::StringRef>>
54 getConflictTargetIDCombination(const std::set<llvm::StringRef> &TargetIDs);
55 
56 /// Check whether the provided target ID is compatible with the requested
57 /// target ID.
58 bool isCompatibleTargetID(llvm::StringRef Provided, llvm::StringRef Requested);
59 } // namespace clang
60 
61 #endif
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:23
llvm::SmallVector
Definition: LLVM.h:38
clang::parseTargetID
std::optional< llvm::StringRef > parseTargetID(const llvm::Triple &T, llvm::StringRef OffloadArch, llvm::StringMap< bool > *FeatureMap)
Parse a target ID to get processor and feature map.
Definition: TargetID.cpp:105
clang::getProcessorFromTargetID
llvm::StringRef getProcessorFromTargetID(const llvm::Triple &T, llvm::StringRef OffloadArch)
Get processor name from target ID.
Definition: TargetID.cpp:54
clang::getConflictTargetIDCombination
std::optional< std::pair< llvm::StringRef, llvm::StringRef > > getConflictTargetIDCombination(const std::set< llvm::StringRef > &TargetIDs)
Get the conflicted pair of target IDs for a compilation or a bundled code object, assuming TargetIDs ...
Definition: TargetID.cpp:145
clang::getCanonicalTargetID
std::string getCanonicalTargetID(llvm::StringRef Processor, const llvm::StringMap< bool > &Features)
Returns canonical target ID, assuming Processor is canonical and all entries in Features are valid.
Definition: TargetID.cpp:130
clang::isCompatibleTargetID
bool isCompatibleTargetID(llvm::StringRef Provided, llvm::StringRef Requested)
Check whether the provided target ID is compatible with the requested target ID.
Definition: TargetID.cpp:168
clang::getAllPossibleTargetIDFeatures
llvm::SmallVector< llvm::StringRef, 4 > getAllPossibleTargetIDFeatures(const llvm::Triple &T, llvm::StringRef Processor)
Get all feature strings that can be used in target ID for Processor.
Definition: TargetID.cpp:38
clang
Definition: CalledOnceCheck.h:17