clang 22.0.0git
BPF.h
Go to the documentation of this file.
1//===--- BPF.h - Declare BPF target feature support -------------*- C++ -*-===//
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 declares BPF TargetInfo objects.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_BPF_H
14#define LLVM_CLANG_LIB_BASIC_TARGETS_BPF_H
15
18#include "llvm/Support/Compiler.h"
19#include "llvm/TargetParser/Triple.h"
20
21namespace clang {
22namespace targets {
23
24class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
25 bool HasAlu32 = false;
26
27public:
42
43 void getTargetDefines(const LangOptions &Opts,
44 MacroBuilder &Builder) const override;
45
46 bool hasFeature(StringRef Feature) const override {
47 return Feature == "bpf" || Feature == "alu32" || Feature == "dwarfris";
48 }
49
50 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
51 bool Enabled) const override {
52 Features[Name] = Enabled;
53 }
54 bool handleTargetFeatures(std::vector<std::string> &Features,
55 DiagnosticsEngine &Diags) override;
56
57 llvm::SmallVector<Builtin::InfosShard> getTargetBuiltins() const override;
58
59 std::string_view getClobbers() const override { return ""; }
60
64
65 bool isValidGCCRegisterName(StringRef Name) const override { return true; }
66 ArrayRef<const char *> getGCCRegNames() const override { return {}; }
67
68 bool validateAsmConstraint(const char *&Name,
69 TargetInfo::ConstraintInfo &Info) const override {
70 switch (*Name) {
71 default:
72 break;
73 case 'w':
74 if (HasAlu32) {
75 Info.setAllowsRegister();
76 }
77 break;
78 }
79 return true;
80 }
81
83 return {};
84 }
85
86 bool allowDebugInfoForExternalRef() const override { return true; }
87
89 switch (CC) {
90 default:
91 return CCCR_Warning;
92 case CC_C:
93 case CC_DeviceKernel:
94 return CCCR_OK;
95 }
96 }
97
98 bool isValidCPUName(StringRef Name) const override;
99
100 void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
101
102 bool setCPU(const std::string &Name) override {
103 if (Name == "v3" || Name == "v4") {
104 HasAlu32 = true;
105 }
106
107 StringRef CPUName(Name);
108 return isValidCPUName(CPUName);
109 }
110
111 std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override {
112 return std::make_pair(32, 32);
113 }
114};
115} // namespace targets
116} // namespace clang
117#endif // LLVM_CLANG_LIB_BASIC_TARGETS_BPF_H
Defines the clang::TargetOptions class.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:232
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
TargetInfo(const llvm::Triple &T)
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition TargetInfo.h:333
@ VoidPtrBuiltinVaList
typedef void* __builtin_va_list;
Definition TargetInfo.h:338
unsigned char RegParmMax
Definition TargetInfo.h:256
unsigned char MaxAtomicPromoteWidth
Definition TargetInfo.h:252
void resetDataLayout(StringRef DL)
Set the data layout to the given string.
unsigned char MaxAtomicInlineWidth
Definition TargetInfo.h:252
Options for controlling the target.
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition BPF.h:82
BPFTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Definition BPF.h:28
std::string_view getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition BPF.h:59
void setFeatureEnabled(llvm::StringMap< bool > &Features, StringRef Name, bool Enabled) const override
Enable or disable a specific target feature; the feature name must be valid.
Definition BPF.h:50
bool setCPU(const std::string &Name) override
Target the specified CPU.
Definition BPF.h:102
bool allowDebugInfoForExternalRef() const override
Whether target allows debuginfo types for decl only variables/functions.
Definition BPF.h:86
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
Definition BPF.h:46
std::pair< unsigned, unsigned > hardwareInterferenceSizes() const override
The first value in the pair is the minimum offset between two objects to avoid false sharing (destruc...
Definition BPF.h:111
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override
Definition BPF.h:68
bool isValidCPUName(StringRef Name) const override
Determine whether this TargetInfo supports the given CPU name.
Definition BPF.cpp:85
ArrayRef< const char * > getGCCRegNames() const override
Definition BPF.h:66
bool isValidGCCRegisterName(StringRef Name) const override
Returns whether the passed in string is a valid register name according to GCC.
Definition BPF.h:65
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition BPF.h:88
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition BPF.h:61
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition Specifiers.h:278
@ CC_DeviceKernel
Definition Specifiers.h:292