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