17330f729Sjoerg //===--- TCE.h - Declare TCE target feature support -------------*- C++ -*-===// 27330f729Sjoerg // 37330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 47330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information. 57330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 67330f729Sjoerg // 77330f729Sjoerg //===----------------------------------------------------------------------===// 87330f729Sjoerg // 97330f729Sjoerg // This file declares TCE TargetInfo objects. 107330f729Sjoerg // 117330f729Sjoerg //===----------------------------------------------------------------------===// 127330f729Sjoerg 137330f729Sjoerg #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H 147330f729Sjoerg #define LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H 157330f729Sjoerg 167330f729Sjoerg #include "clang/Basic/TargetInfo.h" 177330f729Sjoerg #include "clang/Basic/TargetOptions.h" 187330f729Sjoerg #include "llvm/ADT/Triple.h" 197330f729Sjoerg #include "llvm/Support/Compiler.h" 207330f729Sjoerg 217330f729Sjoerg namespace clang { 227330f729Sjoerg namespace targets { 237330f729Sjoerg 247330f729Sjoerg // llvm and clang cannot be used directly to output native binaries for 257330f729Sjoerg // target, but is used to compile C code to llvm bitcode with correct 267330f729Sjoerg // type and alignment information. 277330f729Sjoerg // 287330f729Sjoerg // TCE uses the llvm bitcode as input and uses it for generating customized 297330f729Sjoerg // target processor and program binary. TCE co-design environment is 307330f729Sjoerg // publicly available in http://tce.cs.tut.fi 317330f729Sjoerg 327330f729Sjoerg static const unsigned TCEOpenCLAddrSpaceMap[] = { 337330f729Sjoerg 0, // Default 347330f729Sjoerg 3, // opencl_global 357330f729Sjoerg 4, // opencl_local 367330f729Sjoerg 5, // opencl_constant 377330f729Sjoerg 0, // opencl_private 38*e038c9c4Sjoerg 1, // opencl_global_device 39*e038c9c4Sjoerg 1, // opencl_global_host 407330f729Sjoerg // FIXME: generic has to be added to the target 417330f729Sjoerg 0, // opencl_generic 427330f729Sjoerg 0, // cuda_device 437330f729Sjoerg 0, // cuda_constant 44*e038c9c4Sjoerg 0, // cuda_shared 45*e038c9c4Sjoerg 0, // sycl_global 46*e038c9c4Sjoerg 0, // sycl_global_device 47*e038c9c4Sjoerg 0, // sycl_global_host 48*e038c9c4Sjoerg 0, // sycl_local 49*e038c9c4Sjoerg 0, // sycl_private 50*e038c9c4Sjoerg 0, // ptr32_sptr 51*e038c9c4Sjoerg 0, // ptr32_uptr 52*e038c9c4Sjoerg 0, // ptr64 537330f729Sjoerg }; 547330f729Sjoerg 557330f729Sjoerg class LLVM_LIBRARY_VISIBILITY TCETargetInfo : public TargetInfo { 567330f729Sjoerg public: TCETargetInfo(const llvm::Triple & Triple,const TargetOptions &)577330f729Sjoerg TCETargetInfo(const llvm::Triple &Triple, const TargetOptions &) 587330f729Sjoerg : TargetInfo(Triple) { 597330f729Sjoerg TLSSupported = false; 607330f729Sjoerg IntWidth = 32; 617330f729Sjoerg LongWidth = LongLongWidth = 32; 627330f729Sjoerg PointerWidth = 32; 637330f729Sjoerg IntAlign = 32; 647330f729Sjoerg LongAlign = LongLongAlign = 32; 657330f729Sjoerg PointerAlign = 32; 667330f729Sjoerg SuitableAlign = 32; 677330f729Sjoerg SizeType = UnsignedInt; 687330f729Sjoerg IntMaxType = SignedLong; 697330f729Sjoerg IntPtrType = SignedInt; 707330f729Sjoerg PtrDiffType = SignedInt; 717330f729Sjoerg FloatWidth = 32; 727330f729Sjoerg FloatAlign = 32; 737330f729Sjoerg DoubleWidth = 32; 747330f729Sjoerg DoubleAlign = 32; 757330f729Sjoerg LongDoubleWidth = 32; 767330f729Sjoerg LongDoubleAlign = 32; 777330f729Sjoerg FloatFormat = &llvm::APFloat::IEEEsingle(); 787330f729Sjoerg DoubleFormat = &llvm::APFloat::IEEEsingle(); 797330f729Sjoerg LongDoubleFormat = &llvm::APFloat::IEEEsingle(); 807330f729Sjoerg resetDataLayout("E-p:32:32:32-i1:8:8-i8:8:32-" 817330f729Sjoerg "i16:16:32-i32:32:32-i64:32:32-" 827330f729Sjoerg "f32:32:32-f64:32:32-v64:32:32-" 837330f729Sjoerg "v128:32:32-v256:32:32-v512:32:32-" 847330f729Sjoerg "v1024:32:32-a0:0:32-n32"); 857330f729Sjoerg AddrSpaceMap = &TCEOpenCLAddrSpaceMap; 867330f729Sjoerg UseAddrSpaceMapMangling = true; 877330f729Sjoerg } 887330f729Sjoerg 897330f729Sjoerg void getTargetDefines(const LangOptions &Opts, 907330f729Sjoerg MacroBuilder &Builder) const override; 917330f729Sjoerg hasFeature(StringRef Feature)927330f729Sjoerg bool hasFeature(StringRef Feature) const override { return Feature == "tce"; } 937330f729Sjoerg getTargetBuiltins()947330f729Sjoerg ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; } 957330f729Sjoerg getClobbers()967330f729Sjoerg const char *getClobbers() const override { return ""; } 977330f729Sjoerg getBuiltinVaListKind()987330f729Sjoerg BuiltinVaListKind getBuiltinVaListKind() const override { 997330f729Sjoerg return TargetInfo::VoidPtrBuiltinVaList; 1007330f729Sjoerg } 1017330f729Sjoerg getGCCRegNames()1027330f729Sjoerg ArrayRef<const char *> getGCCRegNames() const override { return None; } 1037330f729Sjoerg validateAsmConstraint(const char * & Name,TargetInfo::ConstraintInfo & info)1047330f729Sjoerg bool validateAsmConstraint(const char *&Name, 1057330f729Sjoerg TargetInfo::ConstraintInfo &info) const override { 1067330f729Sjoerg return true; 1077330f729Sjoerg } 1087330f729Sjoerg getGCCRegAliases()1097330f729Sjoerg ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { 1107330f729Sjoerg return None; 1117330f729Sjoerg } 1127330f729Sjoerg }; 1137330f729Sjoerg 1147330f729Sjoerg class LLVM_LIBRARY_VISIBILITY TCELETargetInfo : public TCETargetInfo { 1157330f729Sjoerg public: TCELETargetInfo(const llvm::Triple & Triple,const TargetOptions & Opts)1167330f729Sjoerg TCELETargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 1177330f729Sjoerg : TCETargetInfo(Triple, Opts) { 1187330f729Sjoerg BigEndian = false; 1197330f729Sjoerg 1207330f729Sjoerg resetDataLayout("e-p:32:32:32-i1:8:8-i8:8:32-" 1217330f729Sjoerg "i16:16:32-i32:32:32-i64:32:32-" 1227330f729Sjoerg "f32:32:32-f64:32:32-v64:32:32-" 1237330f729Sjoerg "v128:32:32-v256:32:32-v512:32:32-" 1247330f729Sjoerg "v1024:32:32-a0:0:32-n32"); 1257330f729Sjoerg } 1267330f729Sjoerg 1277330f729Sjoerg void getTargetDefines(const LangOptions &Opts, 1287330f729Sjoerg MacroBuilder &Builder) const override; 1297330f729Sjoerg }; 1307330f729Sjoerg } // namespace targets 1317330f729Sjoerg } // namespace clang 1327330f729Sjoerg #endif // LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H 133