1 //===--- BPF.h - Declare BPF target feature support -------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares BPF TargetInfo objects.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_BPF_H
15 #define LLVM_CLANG_LIB_BASIC_TARGETS_BPF_H
17 #include "clang/Basic/TargetInfo.h"
18 #include "clang/Basic/TargetOptions.h"
19 #include "llvm/ADT/Triple.h"
20 #include "llvm/Support/Compiler.h"
25 class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
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;
36 if (Triple.getArch() == llvm::Triple::bpfeb) {
37 resetDataLayout("E-m:e-p:64:64-i64:64-n32:64-S128");
39 resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128");
41 MaxAtomicPromoteWidth = 64;
42 MaxAtomicInlineWidth = 64;
46 void getTargetDefines(const LangOptions &Opts,
47 MacroBuilder &Builder) const override;
49 bool hasFeature(StringRef Feature) const override { return Feature == "bpf"; }
51 ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
53 const char *getClobbers() const override { return ""; }
55 BuiltinVaListKind getBuiltinVaListKind() const override {
56 return TargetInfo::VoidPtrBuiltinVaList;
59 ArrayRef<const char *> getGCCRegNames() const override { return None; }
61 bool validateAsmConstraint(const char *&Name,
62 TargetInfo::ConstraintInfo &info) const override {
66 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
70 CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
80 bool isValidCPUName(StringRef Name) const override {
81 if (Name == "generic" || Name == "v1" ||
82 Name == "v2" || Name == "probe")
87 bool setCPU(const std::string &Name) override {
88 StringRef CPUName(Name);
89 return isValidCPUName(CPUName);
92 } // namespace targets
94 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_BPF_H