/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Basic/Targets/BPF.h
Line | Count | Source (jump to first uncovered line) |
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" |
17 | | #include "clang/Basic/TargetOptions.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 | | bool HasAlu32 = false; |
27 | | |
28 | | public: |
29 | | BPFTargetInfo(const llvm::Triple &Triple, const TargetOptions &) |
30 | 18 | : TargetInfo(Triple) { |
31 | 18 | LongWidth = LongAlign = PointerWidth = PointerAlign = 64; |
32 | 18 | SizeType = UnsignedLong; |
33 | 18 | PtrDiffType = SignedLong; |
34 | 18 | IntPtrType = SignedLong; |
35 | 18 | IntMaxType = SignedLong; |
36 | 18 | Int64Type = SignedLong; |
37 | 18 | RegParmMax = 5; |
38 | 18 | if (Triple.getArch() == llvm::Triple::bpfeb) { |
39 | 4 | resetDataLayout("E-m:e-p:64:64-i64:64-i128:128-n32:64-S128"); |
40 | 14 | } else { |
41 | 14 | resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"); |
42 | 14 | } |
43 | 18 | MaxAtomicPromoteWidth = 64; |
44 | 18 | MaxAtomicInlineWidth = 64; |
45 | 18 | TLSSupported = false; |
46 | 18 | } clang::targets::BPFTargetInfo::BPFTargetInfo(llvm::Triple const&, clang::TargetOptions const&) Line | Count | Source | 30 | 18 | : TargetInfo(Triple) { | 31 | 18 | LongWidth = LongAlign = PointerWidth = PointerAlign = 64; | 32 | 18 | SizeType = UnsignedLong; | 33 | 18 | PtrDiffType = SignedLong; | 34 | 18 | IntPtrType = SignedLong; | 35 | 18 | IntMaxType = SignedLong; | 36 | 18 | Int64Type = SignedLong; | 37 | 18 | RegParmMax = 5; | 38 | 18 | if (Triple.getArch() == llvm::Triple::bpfeb) { | 39 | 4 | resetDataLayout("E-m:e-p:64:64-i64:64-i128:128-n32:64-S128"); | 40 | 14 | } else { | 41 | 14 | resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"); | 42 | 14 | } | 43 | 18 | MaxAtomicPromoteWidth = 64; | 44 | 18 | MaxAtomicInlineWidth = 64; | 45 | 18 | TLSSupported = false; | 46 | 18 | } |
Unexecuted instantiation: clang::targets::BPFTargetInfo::BPFTargetInfo(llvm::Triple const&, clang::TargetOptions const&) |
47 | | |
48 | | void getTargetDefines(const LangOptions &Opts, |
49 | | MacroBuilder &Builder) const override; |
50 | | |
51 | 11 | bool hasFeature(StringRef Feature) const override { |
52 | 11 | return Feature == "bpf" || Feature == "alu32" || Feature == "dwarfris"; |
53 | 11 | } |
54 | | |
55 | | void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name, |
56 | 0 | bool Enabled) const override { |
57 | 0 | Features[Name] = Enabled; |
58 | 0 | } |
59 | | bool handleTargetFeatures(std::vector<std::string> &Features, |
60 | | DiagnosticsEngine &Diags) override; |
61 | | |
62 | | ArrayRef<Builtin::Info> getTargetBuiltins() const override; |
63 | | |
64 | 0 | const char *getClobbers() const override { return ""; } |
65 | | |
66 | 15 | BuiltinVaListKind getBuiltinVaListKind() const override { |
67 | 15 | return TargetInfo::VoidPtrBuiltinVaList; |
68 | 15 | } |
69 | | |
70 | 0 | bool isValidGCCRegisterName(StringRef Name) const override { return true; } |
71 | 0 | ArrayRef<const char *> getGCCRegNames() const override { return None; } |
72 | | |
73 | | bool validateAsmConstraint(const char *&Name, |
74 | 0 | TargetInfo::ConstraintInfo &Info) const override { |
75 | 0 | switch (*Name) { |
76 | 0 | default: |
77 | 0 | break; |
78 | 0 | case 'w': |
79 | 0 | if (HasAlu32) { |
80 | 0 | Info.setAllowsRegister(); |
81 | 0 | } |
82 | 0 | break; |
83 | 0 | } |
84 | 0 | return true; |
85 | 0 | } |
86 | | |
87 | 0 | ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { |
88 | 0 | return None; |
89 | 0 | } |
90 | | |
91 | 15 | bool allowDebugInfoForExternalRef() const override { return true; } |
92 | | |
93 | 0 | CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { |
94 | 0 | switch (CC) { |
95 | 0 | default: |
96 | 0 | return CCCR_Warning; |
97 | 0 | case CC_C: |
98 | 0 | case CC_OpenCLKernel: |
99 | 0 | return CCCR_OK; |
100 | 0 | } |
101 | 0 | } |
102 | | |
103 | | bool isValidCPUName(StringRef Name) const override; |
104 | | |
105 | | void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override; |
106 | | |
107 | 1 | bool setCPU(const std::string &Name) override { |
108 | 1 | if (Name == "v3") { |
109 | 0 | HasAlu32 = true; |
110 | 0 | } |
111 | | |
112 | 1 | StringRef CPUName(Name); |
113 | 1 | return isValidCPUName(CPUName); |
114 | 1 | } |
115 | | }; |
116 | | } // namespace targets |
117 | | } // namespace clang |
118 | | #endif // LLVM_CLANG_LIB_BASIC_TARGETS_BPF_H |