[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / lib / Basic / Targets / BPF.cpp
blobc9095c28aec27494414e6021b0c036ff91501067
1 //===--- BPF.cpp - Implement BPF target feature support -------------------===//
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 BPF TargetInfo objects.
11 //===----------------------------------------------------------------------===//
13 #include "BPF.h"
14 #include "Targets.h"
15 #include "clang/Basic/MacroBuilder.h"
16 #include "clang/Basic/TargetBuiltins.h"
17 #include "llvm/ADT/StringRef.h"
19 using namespace clang;
20 using namespace clang::targets;
22 static constexpr Builtin::Info BuiltinInfo[] = {
23 #define BUILTIN(ID, TYPE, ATTRS) \
24 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
25 #include "clang/Basic/BuiltinsBPF.def"
28 void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
29 MacroBuilder &Builder) const {
30 Builder.defineMacro("__bpf__");
31 Builder.defineMacro("__BPF__");
34 static constexpr llvm::StringLiteral ValidCPUNames[] = {"generic", "v1", "v2",
35 "v3", "probe"};
37 bool BPFTargetInfo::isValidCPUName(StringRef Name) const {
38 return llvm::is_contained(ValidCPUNames, Name);
41 void BPFTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {
42 Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
45 ArrayRef<Builtin::Info> BPFTargetInfo::getTargetBuiltins() const {
46 return llvm::ArrayRef(BuiltinInfo,
47 clang::BPF::LastTSBuiltin - Builtin::FirstTSBuiltin);
50 bool BPFTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
51 DiagnosticsEngine &Diags) {
52 for (const auto &Feature : Features) {
53 if (Feature == "+alu32") {
54 HasAlu32 = true;
58 return true;