]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/Basic/Targets/BPF.h
Merge clang trunk r321017 to contrib/llvm/tools/clang.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / lib / Basic / Targets / BPF.h
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"
18 #include "clang/Basic/TargetOptions.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
55   BuiltinVaListKind getBuiltinVaListKind() const override {
56     return TargetInfo::VoidPtrBuiltinVaList;
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
66   ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
67     return None;
68   }
69
70   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
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