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