blob: 75f22ac97b9bd46c348429a6c95a764b5de74885 [file] [log] [blame]
Erich Keaneebba5922017-07-21 22:37:03 +00001//===--- TCE.h - Declare TCE target feature support -------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file declares TCE TargetInfo objects.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H
15#define LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H
16
17#include "clang/Basic/TargetInfo.h"
18#include "clang/Basic/TargetOptions.h"
19#include "llvm/ADT/Triple.h"
20#include "llvm/Support/Compiler.h"
21
22namespace clang {
23namespace targets {
24
25// llvm and clang cannot be used directly to output native binaries for
26// target, but is used to compile C code to llvm bitcode with correct
27// type and alignment information.
28//
29// TCE uses the llvm bitcode as input and uses it for generating customized
30// target processor and program binary. TCE co-design environment is
31// publicly available in http://tce.cs.tut.fi
32
33static const unsigned TCEOpenCLAddrSpaceMap[] = {
34 0, // Default
35 3, // opencl_global
36 4, // opencl_local
37 5, // opencl_constant
38 // FIXME: generic has to be added to the target
39 0, // opencl_generic
40 0, // cuda_device
41 0, // cuda_constant
42 0 // cuda_shared
43};
44
45class LLVM_LIBRARY_VISIBILITY TCETargetInfo : public TargetInfo {
46public:
47 TCETargetInfo(const llvm::Triple &Triple, const TargetOptions &)
48 : TargetInfo(Triple) {
49 TLSSupported = false;
50 IntWidth = 32;
51 LongWidth = LongLongWidth = 32;
52 PointerWidth = 32;
53 IntAlign = 32;
54 LongAlign = LongLongAlign = 32;
55 PointerAlign = 32;
56 SuitableAlign = 32;
57 SizeType = UnsignedInt;
58 IntMaxType = SignedLong;
59 IntPtrType = SignedInt;
60 PtrDiffType = SignedInt;
61 FloatWidth = 32;
62 FloatAlign = 32;
63 DoubleWidth = 32;
64 DoubleAlign = 32;
65 LongDoubleWidth = 32;
66 LongDoubleAlign = 32;
67 FloatFormat = &llvm::APFloat::IEEEsingle();
68 DoubleFormat = &llvm::APFloat::IEEEsingle();
69 LongDoubleFormat = &llvm::APFloat::IEEEsingle();
70 resetDataLayout("E-p:32:32:32-i1:8:8-i8:8:32-"
71 "i16:16:32-i32:32:32-i64:32:32-"
72 "f32:32:32-f64:32:32-v64:32:32-"
73 "v128:32:32-v256:32:32-v512:32:32-"
74 "v1024:32:32-a0:0:32-n32");
75 AddrSpaceMap = &TCEOpenCLAddrSpaceMap;
76 UseAddrSpaceMapMangling = true;
77 }
78
79 void getTargetDefines(const LangOptions &Opts,
80 MacroBuilder &Builder) const override;
81
82 bool hasFeature(StringRef Feature) const override { return Feature == "tce"; }
83
84 ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
85
86 const char *getClobbers() const override { return ""; }
87
88 BuiltinVaListKind getBuiltinVaListKind() const override {
89 return TargetInfo::VoidPtrBuiltinVaList;
90 }
91
92 ArrayRef<const char *> getGCCRegNames() const override { return None; }
93
94 bool validateAsmConstraint(const char *&Name,
95 TargetInfo::ConstraintInfo &info) const override {
96 return true;
97 }
98
99 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
100 return None;
101 }
102};
103
104class LLVM_LIBRARY_VISIBILITY TCELETargetInfo : public TCETargetInfo {
105public:
106 TCELETargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
107 : TCETargetInfo(Triple, Opts) {
108 BigEndian = false;
109
110 resetDataLayout("e-p:32:32:32-i1:8:8-i8:8:32-"
111 "i16:16:32-i32:32:32-i64:32:32-"
112 "f32:32:32-f64:32:32-v64:32:32-"
113 "v128:32:32-v256:32:32-v512:32:32-"
114 "v1024:32:32-a0:0:32-n32");
115 }
116
117 void getTargetDefines(const LangOptions &Opts,
118 MacroBuilder &Builder) const override;
119};
120} // namespace targets
121} // namespace clang
122#endif // LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H