1 //===--- BPF.cpp - Implement BPF target feature support -------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file implements BPF TargetInfo objects.
11 //===----------------------------------------------------------------------===//
15 #include "clang/Basic/MacroBuilder.h"
16 #include "llvm/ADT/StringRef.h"
18 using namespace clang;
19 using namespace clang::targets;
21 void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
22 MacroBuilder &Builder) const {
23 Builder.defineMacro("__bpf__");
24 Builder.defineMacro("__BPF__");
27 static constexpr llvm::StringLiteral ValidCPUNames[] = {"generic", "v1", "v2",
30 bool BPFTargetInfo::isValidCPUName(StringRef Name) const {
31 return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);
34 void BPFTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {
35 Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));