clang  9.0.0
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 
16 #include "clang/Basic/TargetInfo.h"
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/Support/Compiler.h"
20 
21 namespace clang {
22 namespace targets {
23 
24 class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
25 public:
26  BPFTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
27  : TargetInfo(Triple) {
28  LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
29  SizeType = UnsignedLong;
30  PtrDiffType = SignedLong;
31  IntPtrType = SignedLong;
32  IntMaxType = SignedLong;
33  Int64Type = SignedLong;
34  RegParmMax = 5;
35  if (Triple.getArch() == llvm::Triple::bpfeb) {
36  resetDataLayout("E-m:e-p:64:64-i64:64-n32:64-S128");
37  } else {
38  resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128");
39  }
40  MaxAtomicPromoteWidth = 64;
41  MaxAtomicInlineWidth = 64;
42  TLSSupported = false;
43  }
44 
45  void getTargetDefines(const LangOptions &Opts,
46  MacroBuilder &Builder) const override;
47 
48  bool hasFeature(StringRef Feature) const override {
49  return Feature == "bpf" || Feature == "alu32" || Feature == "dwarfris";
50  }
51 
52  void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
53  bool Enabled) const override {
54  Features[Name] = Enabled;
55  }
56 
57  ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
58 
59  const char *getClobbers() const override { return ""; }
60 
63  }
64 
65  bool isValidGCCRegisterName(StringRef Name) const override { return true; }
66  ArrayRef<const char *> getGCCRegNames() const override { return None; }
67 
68  bool validateAsmConstraint(const char *&Name,
69  TargetInfo::ConstraintInfo &info) const override {
70  return true;
71  }
72 
74  return None;
75  }
76 
78  switch (CC) {
79  default:
80  return CCCR_Warning;
81  case CC_C:
82  case CC_OpenCLKernel:
83  return CCCR_OK;
84  }
85  }
86 
87  bool isValidCPUName(StringRef Name) const override;
88 
89  void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
90 
91  bool setCPU(const std::string &Name) override {
92  StringRef CPUName(Name);
93  return isValidCPUName(CPUName);
94  }
95 };
96 } // namespace targets
97 } // namespace clang
98 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_BPF_H
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition: BPF.h:61
Options for controlling the target.
Definition: TargetOptions.h:26
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:49
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
Definition: BPF.h:48
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition: BPF.h:77
typedef void* __builtin_va_list;
Definition: TargetInfo.h:228
Exposes information about the current target.
Definition: TargetInfo.h:161
BPFTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Definition: BPF.h:26
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:264
bool isValidGCCRegisterName(StringRef Name) const override
Returns whether the passed in string is a valid register name according to GCC.
Definition: BPF.h:65
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:52
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override
Definition: BPF.h:68
Defines the clang::TargetOptions class.
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
Definition: BPF.h:57
ArrayRef< const char * > getGCCRegNames() const override
Definition: BPF.h:66
Dataflow Directional Tag Classes.
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition: BPF.h:59
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:223
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition: BPF.h:73
Defines the clang::TargetInfo interface.
bool setCPU(const std::string &Name) override
Target the specified CPU.
Definition: BPF.h:91