blob: cf41a09d76f5f449e8df7cd66000286766a7cf6c [file] [log] [blame]
Erich Keaneebba5922017-07-21 22:37:03 +00001//===--- BPF.cpp - Implement BPF target feature support -------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements BPF TargetInfo objects.
11//
12//===----------------------------------------------------------------------===//
13
14#include "BPF.h"
15#include "Targets.h"
16#include "clang/Basic/MacroBuilder.h"
Erich Keanee44bdb32018-02-08 23:16:55 +000017#include "llvm/ADT/StringRef.h"
Erich Keaneebba5922017-07-21 22:37:03 +000018
19using namespace clang;
20using namespace clang::targets;
21
22void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
23 MacroBuilder &Builder) const {
24 DefineStd(Builder, "bpf", Opts);
25 Builder.defineMacro("__BPF__");
26}
Erich Keanee44bdb32018-02-08 23:16:55 +000027
28static constexpr llvm::StringLiteral ValidCPUNames[] = {"generic", "v1", "v2",
29 "probe"};
30
31bool BPFTargetInfo::isValidCPUName(StringRef Name) const {
32 return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);
33}
34
35void BPFTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {
36 Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
37}