clang 8.0.0

BPF.cpp
Go to the documentation of this file.
1 //===--- 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"
17 #include "llvm/ADT/StringRef.h"
18
19 using namespace clang;
20 using namespace clang::targets;
21
22 void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
23 MacroBuilder &Builder) const {
24 DefineStd(Builder, "bpf", Opts);
25 Builder.defineMacro("__BPF__");
26 }
27
28 static constexpr llvm::StringLiteral ValidCPUNames[] = {"generic", "v1", "v2",
29 "probe"};
30
31 bool BPFTargetInfo::isValidCPUName(StringRef Name) const {
32 return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames);
33 }
34
35 void BPFTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {
36 Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
37 }
clang::targets::DefineStd
void DefineStd(MacroBuilder &Builder, StringRef MacroName, const LangOptions &Opts)
DefineStd - Define a macro name and standard variants.
Definition: Targets.cpp:55
MacroBuilder.h
Defines the clang::MacroBuilder utility class.
clang::targets
Definition: AArch64.h:22
clang::targets::BPFTargetInfo::fillValidCPUList
void fillValidCPUList(SmallVectorImpl< StringRef > &Values) const override
Fill a SmallVectorImpl with the valid values to setCPU.
Definition: BPF.cpp:35
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:50
llvm::SmallVectorImpl
Definition: LLVM.h:37
BPF.h
ValidCPUNames
static constexpr llvm::StringLiteral ValidCPUNames[]
Definition: BPF.cpp:28
clang::targets::BPFTargetInfo::isValidCPUName
bool isValidCPUName(StringRef Name) const override
brief Determine whether this TargetInfo supports the given CPU name.
Definition: BPF.cpp:31
Targets.h
clang::targets::BPFTargetInfo::getTargetDefines
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
Definition: BPF.cpp:22
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::MacroBuilder
Definition: MacroBuilder.h:24
clang::MacroBuilder::defineMacro
void defineMacro(const Twine &Name, const Twine &Value="1")
Append a #define line for macro of the form "\#define Name Value\n".
Definition: MacroBuilder.h:30