clang  6.0.0svn
BPF.h
Go to the documentation of this file.
1 //===--- BPF.h - Declare BPF target feature support -------------*- C++ -*-===//
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 declares BPF TargetInfo objects.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_BPF_H
15 #define LLVM_CLANG_LIB_BASIC_TARGETS_BPF_H
16 
17 #include "clang/Basic/TargetInfo.h"
19 #include "llvm/ADT/Triple.h"
20 #include "llvm/Support/Compiler.h"
21 
22 namespace clang {
23 namespace targets {
24 
25 class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
26 public:
27  BPFTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
28  : TargetInfo(Triple) {
29  LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
30  SizeType = UnsignedLong;
31  PtrDiffType = SignedLong;
32  IntPtrType = SignedLong;
33  IntMaxType = SignedLong;
34  Int64Type = SignedLong;
35  RegParmMax = 5;
36  if (Triple.getArch() == llvm::Triple::bpfeb) {
37  resetDataLayout("E-m:e-p:64:64-i64:64-n32:64-S128");
38  } else {
39  resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128");
40  }
41  MaxAtomicPromoteWidth = 64;
42  MaxAtomicInlineWidth = 64;
43  TLSSupported = false;
44  }
45 
46  void getTargetDefines(const LangOptions &Opts,
47  MacroBuilder &Builder) const override;
48 
49  bool hasFeature(StringRef Feature) const override { return Feature == "bpf"; }
50 
51  ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
52 
53  const char *getClobbers() const override { return ""; }
54 
57  }
58 
59  ArrayRef<const char *> getGCCRegNames() const override { return None; }
60 
61  bool validateAsmConstraint(const char *&Name,
62  TargetInfo::ConstraintInfo &info) const override {
63  return true;
64  }
65 
67  return None;
68  }
69 
71  switch (CC) {
72  default:
73  return CCCR_Warning;
74  case CC_C:
75  case CC_OpenCLKernel:
76  return CCCR_OK;
77  }
78  }
79 
80  bool isValidCPUName(StringRef Name) const override {
81  if (Name == "generic" || Name == "v1" ||
82  Name == "v2" || Name == "probe")
83  return true;
84  return false;
85  }
86 
87  bool setCPU(const std::string &Name) override {
88  StringRef CPUName(Name);
89  return isValidCPUName(CPUName);
90  }
91 };
92 } // namespace targets
93 } // namespace clang
94 #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:55
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:48
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
Definition: BPF.h:49
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition: BPF.h:70
typedef void* __builtin_va_list;
Definition: TargetInfo.h:157
Exposes information about the current target.
Definition: TargetInfo.h:54
BPFTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Definition: BPF.h:27
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:233
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override
Definition: BPF.h:61
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:51
ArrayRef< const char * > getGCCRegNames() const override
Definition: BPF.h:59
Dataflow Directional Tag Classes.
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition: BPF.h:53
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:152
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition: BPF.h:66
Defines the clang::TargetInfo interface.
bool isValidCPUName(StringRef Name) const override
brief Determine whether this TargetInfo supports the given CPU name.
Definition: BPF.h:80
bool setCPU(const std::string &Name) override
Target the specified CPU.
Definition: BPF.h:87