clang  10.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 
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  static const Builtin::Info BuiltinInfo[];
26 
27 public:
28  BPFTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
29  : TargetInfo(Triple) {
30  LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
31  SizeType = UnsignedLong;
32  PtrDiffType = SignedLong;
33  IntPtrType = SignedLong;
34  IntMaxType = SignedLong;
35  Int64Type = SignedLong;
36  RegParmMax = 5;
37  if (Triple.getArch() == llvm::Triple::bpfeb) {
38  resetDataLayout("E-m:e-p:64:64-i64:64-n32:64-S128");
39  } else {
40  resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128");
41  }
42  MaxAtomicPromoteWidth = 64;
43  MaxAtomicInlineWidth = 64;
44  TLSSupported = false;
45  }
46 
47  void getTargetDefines(const LangOptions &Opts,
48  MacroBuilder &Builder) const override;
49 
50  bool hasFeature(StringRef Feature) const override {
51  return Feature == "bpf" || Feature == "alu32" || Feature == "dwarfris";
52  }
53 
54  void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
55  bool Enabled) const override {
56  Features[Name] = Enabled;
57  }
58 
59  ArrayRef<Builtin::Info> getTargetBuiltins() const override;
60 
61  const char *getClobbers() const override { return ""; }
62 
65  }
66 
67  bool isValidGCCRegisterName(StringRef Name) const override { return true; }
68  ArrayRef<const char *> getGCCRegNames() const override { return None; }
69 
70  bool validateAsmConstraint(const char *&Name,
71  TargetInfo::ConstraintInfo &info) const override {
72  return true;
73  }
74 
76  return None;
77  }
78 
79  bool allowDebugInfoForExternalVar() const override { return true; }
80 
82  switch (CC) {
83  default:
84  return CCCR_Warning;
85  case CC_C:
86  case CC_OpenCLKernel:
87  return CCCR_OK;
88  }
89  }
90 
91  bool isValidCPUName(StringRef Name) const override;
92 
93  void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
94 
95  bool setCPU(const std::string &Name) override {
96  StringRef CPUName(Name);
97  return isValidCPUName(CPUName);
98  }
99 };
100 } // namespace targets
101 } // namespace clang
102 #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:63
static const Builtin::Info BuiltinInfo[]
Definition: Builtins.cpp:20
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:53
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
Definition: BPF.h:50
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition: BPF.h:81
typedef void* __builtin_va_list;
Definition: TargetInfo.h:231
Exposes information about the current target.
Definition: TargetInfo.h:164
BPFTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Definition: BPF.h:28
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:265
bool isValidGCCRegisterName(StringRef Name) const override
Returns whether the passed in string is a valid register name according to GCC.
Definition: BPF.h:67
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:54
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override
Definition: BPF.h:70
Defines the clang::TargetOptions class.
bool allowDebugInfoForExternalVar() const override
Whether target allows debuginfo types for decl only variables.
Definition: BPF.h:79
ArrayRef< const char * > getGCCRegNames() const override
Definition: BPF.h:68
Dataflow Directional Tag Classes.
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition: BPF.h:61
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:226
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition: BPF.h:75
Defines the clang::TargetInfo interface.
bool setCPU(const std::string &Name) override
Target the specified CPU.
Definition: BPF.h:95