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
21namespace clang {
22namespace 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
32static 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 0, // hlsl_constant
55 0, // hlsl_private
56 0, // hlsl_device
57 0, // hlsl_input
58 0, // hlsl_push_constant
59 // Wasm address space values for this target are dummy values,
60 // as it is only enabled for Wasm targets.
61 20, // wasm_funcref
62};
63
64class LLVM_LIBRARY_VISIBILITY TCETargetInfo : public TargetInfo {
65public:
66 TCETargetInfo(const llvm::Triple &Triple, const TargetOptions &)
67 : TargetInfo(Triple) {
68 TLSSupported = false;
69 IntWidth = 32;
70 LongWidth = LongLongWidth = 32;
71 PointerWidth = 32;
72 IntAlign = 32;
73 LongAlign = LongLongAlign = 32;
74 PointerAlign = 32;
75 SuitableAlign = 32;
76 SizeType = UnsignedInt;
77 IntMaxType = SignedLong;
78 IntPtrType = SignedInt;
79 PtrDiffType = SignedInt;
80 FloatWidth = 32;
81 FloatAlign = 32;
82 DoubleWidth = 32;
83 DoubleAlign = 32;
84 LongDoubleWidth = 32;
85 LongDoubleAlign = 32;
86 FloatFormat = &llvm::APFloat::IEEEsingle();
87 DoubleFormat = &llvm::APFloat::IEEEsingle();
88 LongDoubleFormat = &llvm::APFloat::IEEEsingle();
89 resetDataLayout(DL: "E-p:32:32:32-i1:8:8-i8:8:32-"
90 "i16:16:32-i32:32:32-i64:32:32-"
91 "f32:32:32-f64:32:32-v64:32:32-"
92 "v128:32:32-v256:32:32-v512:32:32-"
93 "v1024:32:32-a0:0:32-n32");
94 AddrSpaceMap = &TCEOpenCLAddrSpaceMap;
95 UseAddrSpaceMapMangling = true;
96 }
97
98 void getTargetDefines(const LangOptions &Opts,
99 MacroBuilder &Builder) const override;
100
101 bool hasFeature(StringRef Feature) const override { return Feature == "tce"; }
102
103 llvm::SmallVector<Builtin::InfosShard> getTargetBuiltins() const override {
104 return {};
105 }
106
107 std::string_view getClobbers() const override { return ""; }
108
109 BuiltinVaListKind getBuiltinVaListKind() const override {
110 return TargetInfo::VoidPtrBuiltinVaList;
111 }
112
113 ArrayRef<const char *> getGCCRegNames() const override { return {}; }
114
115 bool validateAsmConstraint(const char *&Name,
116 TargetInfo::ConstraintInfo &info) const override {
117 return true;
118 }
119
120 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
121 return {};
122 }
123};
124
125class LLVM_LIBRARY_VISIBILITY TCELETargetInfo : public TCETargetInfo {
126public:
127 TCELETargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
128 : TCETargetInfo(Triple, Opts) {
129 BigEndian = false;
130
131 resetDataLayout(DL: "e-p:32:32:32-i1:8:8-i8:8:32-"
132 "i16:16:32-i32:32:32-i64:32:32-"
133 "f32:32:32-f64:32:32-v64:32:32-"
134 "v128:32:32-v256:32:32-v512:32:32-"
135 "v1024:32:32-a0:0:32-n32");
136 }
137
138 void getTargetDefines(const LangOptions &Opts,
139 MacroBuilder &Builder) const override;
140};
141} // namespace targets
142} // namespace clang
143#endif // LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H
144