clang 20.0.0git
TCE.h
Go to the documentation of this file.
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
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 // 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
59class LLVM_LIBRARY_VISIBILITY TCETargetInfo : public TargetInfo {
60public:
61 TCETargetInfo(const llvm::Triple &Triple, const TargetOptions &)
62 : TargetInfo(Triple) {
63 TLSSupported = false;
64 IntWidth = 32;
65 LongWidth = LongLongWidth = 32;
66 PointerWidth = 32;
67 IntAlign = 32;
68 LongAlign = LongLongAlign = 32;
69 PointerAlign = 32;
70 SuitableAlign = 32;
71 SizeType = UnsignedInt;
72 IntMaxType = SignedLong;
73 IntPtrType = SignedInt;
74 PtrDiffType = SignedInt;
75 FloatWidth = 32;
76 FloatAlign = 32;
77 DoubleWidth = 32;
78 DoubleAlign = 32;
79 LongDoubleWidth = 32;
80 LongDoubleAlign = 32;
81 FloatFormat = &llvm::APFloat::IEEEsingle();
82 DoubleFormat = &llvm::APFloat::IEEEsingle();
83 LongDoubleFormat = &llvm::APFloat::IEEEsingle();
84 resetDataLayout("E-p:32:32:32-i1:8:8-i8:8:32-"
85 "i16:16:32-i32:32:32-i64:32:32-"
86 "f32:32:32-f64:32:32-v64:32:32-"
87 "v128:32:32-v256:32:32-v512:32:32-"
88 "v1024:32:32-a0:0:32-n32");
89 AddrSpaceMap = &TCEOpenCLAddrSpaceMap;
90 UseAddrSpaceMapMangling = true;
91 }
92
93 void getTargetDefines(const LangOptions &Opts,
94 MacroBuilder &Builder) const override;
95
96 bool hasFeature(StringRef Feature) const override { return Feature == "tce"; }
97
98 ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; }
99
100 std::string_view getClobbers() const override { return ""; }
101
103 return TargetInfo::VoidPtrBuiltinVaList;
104 }
105
106 ArrayRef<const char *> getGCCRegNames() const override { return {}; }
107
108 bool validateAsmConstraint(const char *&Name,
109 TargetInfo::ConstraintInfo &info) const override {
110 return true;
111 }
112
114 return {};
115 }
116};
117
118class LLVM_LIBRARY_VISIBILITY TCELETargetInfo : public TCETargetInfo {
119public:
120 TCELETargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
121 : TCETargetInfo(Triple, Opts) {
122 BigEndian = false;
123
124 resetDataLayout("e-p:32:32:32-i1:8:8-i8:8:32-"
125 "i16:16:32-i32:32:32-i64:32:32-"
126 "f32:32:32-f64:32:32-v64:32:32-"
127 "v128:32:32-v256:32:32-v512:32:32-"
128 "v1024:32:32-a0:0:32-n32");
129 }
130
131 void getTargetDefines(const LangOptions &Opts,
132 MacroBuilder &Builder) const override;
133};
134} // namespace targets
135} // namespace clang
136#endif // LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H
Defines the clang::TargetOptions class.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:499
Exposes information about the current target.
Definition: TargetInfo.h:220
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:318
Options for controlling the target.
Definition: TargetOptions.h:26
TCELETargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: TCE.h:120
ArrayRef< const char * > getGCCRegNames() const override
Definition: TCE.h:106
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition: TCE.h:102
TCETargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Definition: TCE.h:61
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition: TCE.h:113
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
Definition: TCE.h:98
std::string_view getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition: TCE.h:100
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override
Definition: TCE.h:108
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
Definition: TCE.h:96
Defines the clang::TargetInfo interface.
static const unsigned TCEOpenCLAddrSpaceMap[]
Definition: TCE.h:32
The JSON file list parser is used to communicate input to InstallAPI.