/src/llvm-project/clang/lib/Basic/Targets/TCE.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===--- TCE.h - Declare TCE 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 TCE TargetInfo objects. |
10 | | // |
11 | | //===----------------------------------------------------------------------===// |
12 | | |
13 | | #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H |
14 | | #define LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H |
15 | | |
16 | | #include "clang/Basic/TargetInfo.h" |
17 | | #include "clang/Basic/TargetOptions.h" |
18 | | #include "llvm/Support/Compiler.h" |
19 | | #include "llvm/TargetParser/Triple.h" |
20 | | |
21 | | namespace clang { |
22 | | namespace targets { |
23 | | |
24 | | // llvm and clang cannot be used directly to output native binaries for |
25 | | // target, but is used to compile C code to llvm bitcode with correct |
26 | | // type and alignment information. |
27 | | // |
28 | | // TCE uses the llvm bitcode as input and uses it for generating customized |
29 | | // target processor and program binary. TCE co-design environment is |
30 | | // publicly available in http://tce.cs.tut.fi |
31 | | |
32 | | static const unsigned TCEOpenCLAddrSpaceMap[] = { |
33 | | 0, // Default |
34 | | 3, // opencl_global |
35 | | 4, // opencl_local |
36 | | 5, // opencl_constant |
37 | | 0, // opencl_private |
38 | | 1, // opencl_global_device |
39 | | 1, // opencl_global_host |
40 | | // FIXME: generic has to be added to the target |
41 | | 0, // opencl_generic |
42 | | 0, // cuda_device |
43 | | 0, // cuda_constant |
44 | | 0, // cuda_shared |
45 | | 0, // sycl_global |
46 | | 0, // sycl_global_device |
47 | | 0, // sycl_global_host |
48 | | 0, // sycl_local |
49 | | 0, // sycl_private |
50 | | 0, // ptr32_sptr |
51 | | 0, // ptr32_uptr |
52 | | 0, // ptr64 |
53 | | 0, // hlsl_groupshared |
54 | | // Wasm address space values for this target are dummy values, |
55 | | // as it is only enabled for Wasm targets. |
56 | | 20, // wasm_funcref |
57 | | }; |
58 | | |
59 | | class LLVM_LIBRARY_VISIBILITY TCETargetInfo : public TargetInfo { |
60 | | public: |
61 | | TCETargetInfo(const llvm::Triple &Triple, const TargetOptions &) |
62 | 0 | : TargetInfo(Triple) { |
63 | 0 | TLSSupported = false; |
64 | 0 | IntWidth = 32; |
65 | 0 | LongWidth = LongLongWidth = 32; |
66 | 0 | PointerWidth = 32; |
67 | 0 | IntAlign = 32; |
68 | 0 | LongAlign = LongLongAlign = 32; |
69 | 0 | PointerAlign = 32; |
70 | 0 | SuitableAlign = 32; |
71 | 0 | SizeType = UnsignedInt; |
72 | 0 | IntMaxType = SignedLong; |
73 | 0 | IntPtrType = SignedInt; |
74 | 0 | PtrDiffType = SignedInt; |
75 | 0 | FloatWidth = 32; |
76 | 0 | FloatAlign = 32; |
77 | 0 | DoubleWidth = 32; |
78 | 0 | DoubleAlign = 32; |
79 | 0 | LongDoubleWidth = 32; |
80 | 0 | LongDoubleAlign = 32; |
81 | 0 | FloatFormat = &llvm::APFloat::IEEEsingle(); |
82 | 0 | DoubleFormat = &llvm::APFloat::IEEEsingle(); |
83 | 0 | LongDoubleFormat = &llvm::APFloat::IEEEsingle(); |
84 | 0 | resetDataLayout("E-p:32:32:32-i1:8:8-i8:8:32-" |
85 | 0 | "i16:16:32-i32:32:32-i64:32:32-" |
86 | 0 | "f32:32:32-f64:32:32-v64:32:32-" |
87 | 0 | "v128:32:32-v256:32:32-v512:32:32-" |
88 | 0 | "v1024:32:32-a0:0:32-n32"); |
89 | 0 | AddrSpaceMap = &TCEOpenCLAddrSpaceMap; |
90 | 0 | UseAddrSpaceMapMangling = true; |
91 | 0 | } |
92 | | |
93 | | void getTargetDefines(const LangOptions &Opts, |
94 | | MacroBuilder &Builder) const override; |
95 | | |
96 | 0 | bool hasFeature(StringRef Feature) const override { return Feature == "tce"; } |
97 | | |
98 | 0 | ArrayRef<Builtin::Info> getTargetBuiltins() const override { |
99 | 0 | return std::nullopt; |
100 | 0 | } |
101 | | |
102 | 0 | std::string_view getClobbers() const override { return ""; } |
103 | | |
104 | 0 | BuiltinVaListKind getBuiltinVaListKind() const override { |
105 | 0 | return TargetInfo::VoidPtrBuiltinVaList; |
106 | 0 | } |
107 | | |
108 | 0 | ArrayRef<const char *> getGCCRegNames() const override { |
109 | 0 | return std::nullopt; |
110 | 0 | } |
111 | | |
112 | | bool validateAsmConstraint(const char *&Name, |
113 | 0 | TargetInfo::ConstraintInfo &info) const override { |
114 | 0 | return true; |
115 | 0 | } |
116 | | |
117 | 0 | ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { |
118 | 0 | return std::nullopt; |
119 | 0 | } |
120 | | }; |
121 | | |
122 | | class LLVM_LIBRARY_VISIBILITY TCELETargetInfo : public TCETargetInfo { |
123 | | public: |
124 | | TCELETargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) |
125 | 0 | : TCETargetInfo(Triple, Opts) { |
126 | 0 | BigEndian = false; |
127 | |
|
128 | 0 | resetDataLayout("e-p:32:32:32-i1:8:8-i8:8:32-" |
129 | 0 | "i16:16:32-i32:32:32-i64:32:32-" |
130 | 0 | "f32:32:32-f64:32:32-v64:32:32-" |
131 | 0 | "v128:32:32-v256:32:32-v512:32:32-" |
132 | 0 | "v1024:32:32-a0:0:32-n32"); |
133 | 0 | } |
134 | | |
135 | | void getTargetDefines(const LangOptions &Opts, |
136 | | MacroBuilder &Builder) const override; |
137 | | }; |
138 | | } // namespace targets |
139 | | } // namespace clang |
140 | | #endif // LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H |