Coverage Report

Created: 2022-07-16 07:03

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Basic/Targets/BPF.cpp
Line
Count
Source (jump to first uncovered line)
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.
10
//
11
//===----------------------------------------------------------------------===//
12
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"
18
19
using namespace clang;
20
using namespace clang::targets;
21
22
const Builtin::Info BPFTargetInfo::BuiltinInfo[] = {
23
#define BUILTIN(ID, TYPE, ATTRS)                                               \
24
  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
25
#include "clang/Basic/BuiltinsBPF.def"
26
};
27
28
void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
29
17
                                     MacroBuilder &Builder) const {
30
17
  Builder.defineMacro("__bpf__");
31
17
  Builder.defineMacro("__BPF__");
32
17
}
33
34
static constexpr llvm::StringLiteral ValidCPUNames[] = {"generic", "v1", "v2",
35
                                                        "v3", "probe"};
36
37
1
bool BPFTargetInfo::isValidCPUName(StringRef Name) const {
38
1
  return llvm::is_contained(ValidCPUNames, Name);
39
1
}
40
41
1
void BPFTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {
42
1
  Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames));
43
1
}
44
45
17
ArrayRef<Builtin::Info> BPFTargetInfo::getTargetBuiltins() const {
46
17
  return llvm::makeArrayRef(BuiltinInfo, clang::BPF::LastTSBuiltin -
47
17
                                             Builtin::FirstTSBuiltin);
48
17
}
49
50
bool BPFTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
51
17
                                         DiagnosticsEngine &Diags) {
52
17
  for (const auto &Feature : Features) {
53
0
    if (Feature == "+alu32") {
54
0
      HasAlu32 = true;
55
0
    }
56
0
  }
57
58
17
  return true;
59
17
}