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/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, // ptr32_sptr 46 0, // ptr32_uptr 47 0, // ptr64 48 }; 49 50 class LLVM_LIBRARY_VISIBILITY TCETargetInfo : public TargetInfo { 51 public: 52 TCETargetInfo(const llvm::Triple &Triple, const TargetOptions &) 53 : TargetInfo(Triple) { 54 TLSSupported = false; 55 IntWidth = 32; 56 LongWidth = LongLongWidth = 32; 57 PointerWidth = 32; 58 IntAlign = 32; 59 LongAlign = LongLongAlign = 32; 60 PointerAlign = 32; 61 SuitableAlign = 32; 62 SizeType = UnsignedInt; 63 IntMaxType = SignedLong; 64 IntPtrType = SignedInt; 65 PtrDiffType = SignedInt; 66 FloatWidth = 32; 67 FloatAlign = 32; 68 DoubleWidth = 32; 69 DoubleAlign = 32; 70 LongDoubleWidth = 32; 71 LongDoubleAlign = 32; 72 FloatFormat = &llvm::APFloat::IEEEsingle(); 73 DoubleFormat = &llvm::APFloat::IEEEsingle(); 74 LongDoubleFormat = &llvm::APFloat::IEEEsingle(); 75 resetDataLayout("E-p:32:32:32-i1:8:8-i8:8:32-" 76 "i16:16:32-i32:32:32-i64:32:32-" 77 "f32:32:32-f64:32:32-v64:32:32-" 78 "v128:32:32-v256:32:32-v512:32:32-" 79 "v1024:32:32-a0:0:32-n32"); 80 AddrSpaceMap = &TCEOpenCLAddrSpaceMap; 81 UseAddrSpaceMapMangling = true; 82 } 83 84 void getTargetDefines(const LangOptions &Opts, 85 MacroBuilder &Builder) const override; 86 87 bool hasFeature(StringRef Feature) const override { return Feature == "tce"; } 88 89 ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; } 90 91 const char *getClobbers() const override { return ""; } 92 93 BuiltinVaListKind getBuiltinVaListKind() const override { 94 return TargetInfo::VoidPtrBuiltinVaList; 95 } 96 97 ArrayRef<const char *> getGCCRegNames() const override { return None; } 98 99 bool validateAsmConstraint(const char *&Name, 100 TargetInfo::ConstraintInfo &info) const override { 101 return true; 102 } 103 104 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { 105 return None; 106 } 107 }; 108 109 class LLVM_LIBRARY_VISIBILITY TCELETargetInfo : public TCETargetInfo { 110 public: 111 TCELETargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 112 : TCETargetInfo(Triple, Opts) { 113 BigEndian = false; 114 115 resetDataLayout("e-p:32:32:32-i1:8:8-i8:8:32-" 116 "i16:16:32-i32:32:32-i64:32:32-" 117 "f32:32:32-f64:32:32-v64:32:32-" 118 "v128:32:32-v256:32:32-v512:32:32-" 119 "v1024:32:32-a0:0:32-n32"); 120 } 121 122 void getTargetDefines(const LangOptions &Opts, 123 MacroBuilder &Builder) const override; 124 }; 125 } // namespace targets 126 } // namespace clang 127 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H 128