10b57cec5SDimitry Andric //===--- TCE.h - Declare TCE target feature support -------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file declares TCE TargetInfo objects. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H 140b57cec5SDimitry Andric #define LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #include "clang/Basic/TargetInfo.h" 170b57cec5SDimitry Andric #include "clang/Basic/TargetOptions.h" 180b57cec5SDimitry Andric #include "llvm/ADT/Triple.h" 190b57cec5SDimitry Andric #include "llvm/Support/Compiler.h" 200b57cec5SDimitry Andric 210b57cec5SDimitry Andric namespace clang { 220b57cec5SDimitry Andric namespace targets { 230b57cec5SDimitry Andric 240b57cec5SDimitry Andric // llvm and clang cannot be used directly to output native binaries for 250b57cec5SDimitry Andric // target, but is used to compile C code to llvm bitcode with correct 260b57cec5SDimitry Andric // type and alignment information. 270b57cec5SDimitry Andric // 280b57cec5SDimitry Andric // TCE uses the llvm bitcode as input and uses it for generating customized 290b57cec5SDimitry Andric // target processor and program binary. TCE co-design environment is 300b57cec5SDimitry Andric // publicly available in http://tce.cs.tut.fi 310b57cec5SDimitry Andric 320b57cec5SDimitry Andric static const unsigned TCEOpenCLAddrSpaceMap[] = { 330b57cec5SDimitry Andric 0, // Default 340b57cec5SDimitry Andric 3, // opencl_global 350b57cec5SDimitry Andric 4, // opencl_local 360b57cec5SDimitry Andric 5, // opencl_constant 370b57cec5SDimitry Andric 0, // opencl_private 38e8d8bef9SDimitry Andric 1, // opencl_global_device 39e8d8bef9SDimitry Andric 1, // opencl_global_host 400b57cec5SDimitry Andric // FIXME: generic has to be added to the target 410b57cec5SDimitry Andric 0, // opencl_generic 420b57cec5SDimitry Andric 0, // cuda_device 430b57cec5SDimitry Andric 0, // cuda_constant 44480093f4SDimitry Andric 0, // cuda_shared 45*fe6060f1SDimitry Andric 0, // sycl_global 46*fe6060f1SDimitry Andric 0, // sycl_global_device 47*fe6060f1SDimitry Andric 0, // sycl_global_host 48*fe6060f1SDimitry Andric 0, // sycl_local 49*fe6060f1SDimitry Andric 0, // sycl_private 50480093f4SDimitry Andric 0, // ptr32_sptr 51480093f4SDimitry Andric 0, // ptr32_uptr 52480093f4SDimitry Andric 0, // ptr64 530b57cec5SDimitry Andric }; 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY TCETargetInfo : public TargetInfo { 560b57cec5SDimitry Andric public: 570b57cec5SDimitry Andric TCETargetInfo(const llvm::Triple &Triple, const TargetOptions &) 580b57cec5SDimitry Andric : TargetInfo(Triple) { 590b57cec5SDimitry Andric TLSSupported = false; 600b57cec5SDimitry Andric IntWidth = 32; 610b57cec5SDimitry Andric LongWidth = LongLongWidth = 32; 620b57cec5SDimitry Andric PointerWidth = 32; 630b57cec5SDimitry Andric IntAlign = 32; 640b57cec5SDimitry Andric LongAlign = LongLongAlign = 32; 650b57cec5SDimitry Andric PointerAlign = 32; 660b57cec5SDimitry Andric SuitableAlign = 32; 670b57cec5SDimitry Andric SizeType = UnsignedInt; 680b57cec5SDimitry Andric IntMaxType = SignedLong; 690b57cec5SDimitry Andric IntPtrType = SignedInt; 700b57cec5SDimitry Andric PtrDiffType = SignedInt; 710b57cec5SDimitry Andric FloatWidth = 32; 720b57cec5SDimitry Andric FloatAlign = 32; 730b57cec5SDimitry Andric DoubleWidth = 32; 740b57cec5SDimitry Andric DoubleAlign = 32; 750b57cec5SDimitry Andric LongDoubleWidth = 32; 760b57cec5SDimitry Andric LongDoubleAlign = 32; 770b57cec5SDimitry Andric FloatFormat = &llvm::APFloat::IEEEsingle(); 780b57cec5SDimitry Andric DoubleFormat = &llvm::APFloat::IEEEsingle(); 790b57cec5SDimitry Andric LongDoubleFormat = &llvm::APFloat::IEEEsingle(); 800b57cec5SDimitry Andric resetDataLayout("E-p:32:32:32-i1:8:8-i8:8:32-" 810b57cec5SDimitry Andric "i16:16:32-i32:32:32-i64:32:32-" 820b57cec5SDimitry Andric "f32:32:32-f64:32:32-v64:32:32-" 830b57cec5SDimitry Andric "v128:32:32-v256:32:32-v512:32:32-" 840b57cec5SDimitry Andric "v1024:32:32-a0:0:32-n32"); 850b57cec5SDimitry Andric AddrSpaceMap = &TCEOpenCLAddrSpaceMap; 860b57cec5SDimitry Andric UseAddrSpaceMapMangling = true; 870b57cec5SDimitry Andric } 880b57cec5SDimitry Andric 890b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 900b57cec5SDimitry Andric MacroBuilder &Builder) const override; 910b57cec5SDimitry Andric 920b57cec5SDimitry Andric bool hasFeature(StringRef Feature) const override { return Feature == "tce"; } 930b57cec5SDimitry Andric 940b57cec5SDimitry Andric ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; } 950b57cec5SDimitry Andric 960b57cec5SDimitry Andric const char *getClobbers() const override { return ""; } 970b57cec5SDimitry Andric 980b57cec5SDimitry Andric BuiltinVaListKind getBuiltinVaListKind() const override { 990b57cec5SDimitry Andric return TargetInfo::VoidPtrBuiltinVaList; 1000b57cec5SDimitry Andric } 1010b57cec5SDimitry Andric 1020b57cec5SDimitry Andric ArrayRef<const char *> getGCCRegNames() const override { return None; } 1030b57cec5SDimitry Andric 1040b57cec5SDimitry Andric bool validateAsmConstraint(const char *&Name, 1050b57cec5SDimitry Andric TargetInfo::ConstraintInfo &info) const override { 1060b57cec5SDimitry Andric return true; 1070b57cec5SDimitry Andric } 1080b57cec5SDimitry Andric 1090b57cec5SDimitry Andric ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { 1100b57cec5SDimitry Andric return None; 1110b57cec5SDimitry Andric } 1120b57cec5SDimitry Andric }; 1130b57cec5SDimitry Andric 1140b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY TCELETargetInfo : public TCETargetInfo { 1150b57cec5SDimitry Andric public: 1160b57cec5SDimitry Andric TCELETargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 1170b57cec5SDimitry Andric : TCETargetInfo(Triple, Opts) { 1180b57cec5SDimitry Andric BigEndian = false; 1190b57cec5SDimitry Andric 1200b57cec5SDimitry Andric resetDataLayout("e-p:32:32:32-i1:8:8-i8:8:32-" 1210b57cec5SDimitry Andric "i16:16:32-i32:32:32-i64:32:32-" 1220b57cec5SDimitry Andric "f32:32:32-f64:32:32-v64:32:32-" 1230b57cec5SDimitry Andric "v128:32:32-v256:32:32-v512:32:32-" 1240b57cec5SDimitry Andric "v1024:32:32-a0:0:32-n32"); 1250b57cec5SDimitry Andric } 1260b57cec5SDimitry Andric 1270b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 1280b57cec5SDimitry Andric MacroBuilder &Builder) const override; 1290b57cec5SDimitry Andric }; 1300b57cec5SDimitry Andric } // namespace targets 1310b57cec5SDimitry Andric } // namespace clang 1320b57cec5SDimitry Andric #endif // LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H 133