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 380b57cec5SDimitry Andric // FIXME: generic has to be added to the target 390b57cec5SDimitry Andric 0, // opencl_generic 400b57cec5SDimitry Andric 0, // cuda_device 410b57cec5SDimitry Andric 0, // cuda_constant 42*480093f4SDimitry Andric 0, // cuda_shared 43*480093f4SDimitry Andric 0, // ptr32_sptr 44*480093f4SDimitry Andric 0, // ptr32_uptr 45*480093f4SDimitry Andric 0, // ptr64 460b57cec5SDimitry Andric }; 470b57cec5SDimitry Andric 480b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY TCETargetInfo : public TargetInfo { 490b57cec5SDimitry Andric public: 500b57cec5SDimitry Andric TCETargetInfo(const llvm::Triple &Triple, const TargetOptions &) 510b57cec5SDimitry Andric : TargetInfo(Triple) { 520b57cec5SDimitry Andric TLSSupported = false; 530b57cec5SDimitry Andric IntWidth = 32; 540b57cec5SDimitry Andric LongWidth = LongLongWidth = 32; 550b57cec5SDimitry Andric PointerWidth = 32; 560b57cec5SDimitry Andric IntAlign = 32; 570b57cec5SDimitry Andric LongAlign = LongLongAlign = 32; 580b57cec5SDimitry Andric PointerAlign = 32; 590b57cec5SDimitry Andric SuitableAlign = 32; 600b57cec5SDimitry Andric SizeType = UnsignedInt; 610b57cec5SDimitry Andric IntMaxType = SignedLong; 620b57cec5SDimitry Andric IntPtrType = SignedInt; 630b57cec5SDimitry Andric PtrDiffType = SignedInt; 640b57cec5SDimitry Andric FloatWidth = 32; 650b57cec5SDimitry Andric FloatAlign = 32; 660b57cec5SDimitry Andric DoubleWidth = 32; 670b57cec5SDimitry Andric DoubleAlign = 32; 680b57cec5SDimitry Andric LongDoubleWidth = 32; 690b57cec5SDimitry Andric LongDoubleAlign = 32; 700b57cec5SDimitry Andric FloatFormat = &llvm::APFloat::IEEEsingle(); 710b57cec5SDimitry Andric DoubleFormat = &llvm::APFloat::IEEEsingle(); 720b57cec5SDimitry Andric LongDoubleFormat = &llvm::APFloat::IEEEsingle(); 730b57cec5SDimitry Andric resetDataLayout("E-p:32:32:32-i1:8:8-i8:8:32-" 740b57cec5SDimitry Andric "i16:16:32-i32:32:32-i64:32:32-" 750b57cec5SDimitry Andric "f32:32:32-f64:32:32-v64:32:32-" 760b57cec5SDimitry Andric "v128:32:32-v256:32:32-v512:32:32-" 770b57cec5SDimitry Andric "v1024:32:32-a0:0:32-n32"); 780b57cec5SDimitry Andric AddrSpaceMap = &TCEOpenCLAddrSpaceMap; 790b57cec5SDimitry Andric UseAddrSpaceMapMangling = true; 800b57cec5SDimitry Andric } 810b57cec5SDimitry Andric 820b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 830b57cec5SDimitry Andric MacroBuilder &Builder) const override; 840b57cec5SDimitry Andric 850b57cec5SDimitry Andric bool hasFeature(StringRef Feature) const override { return Feature == "tce"; } 860b57cec5SDimitry Andric 870b57cec5SDimitry Andric ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; } 880b57cec5SDimitry Andric 890b57cec5SDimitry Andric const char *getClobbers() const override { return ""; } 900b57cec5SDimitry Andric 910b57cec5SDimitry Andric BuiltinVaListKind getBuiltinVaListKind() const override { 920b57cec5SDimitry Andric return TargetInfo::VoidPtrBuiltinVaList; 930b57cec5SDimitry Andric } 940b57cec5SDimitry Andric 950b57cec5SDimitry Andric ArrayRef<const char *> getGCCRegNames() const override { return None; } 960b57cec5SDimitry Andric 970b57cec5SDimitry Andric bool validateAsmConstraint(const char *&Name, 980b57cec5SDimitry Andric TargetInfo::ConstraintInfo &info) const override { 990b57cec5SDimitry Andric return true; 1000b57cec5SDimitry Andric } 1010b57cec5SDimitry Andric 1020b57cec5SDimitry Andric ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { 1030b57cec5SDimitry Andric return None; 1040b57cec5SDimitry Andric } 1050b57cec5SDimitry Andric }; 1060b57cec5SDimitry Andric 1070b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY TCELETargetInfo : public TCETargetInfo { 1080b57cec5SDimitry Andric public: 1090b57cec5SDimitry Andric TCELETargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 1100b57cec5SDimitry Andric : TCETargetInfo(Triple, Opts) { 1110b57cec5SDimitry Andric BigEndian = false; 1120b57cec5SDimitry Andric 1130b57cec5SDimitry Andric resetDataLayout("e-p:32:32:32-i1:8:8-i8:8:32-" 1140b57cec5SDimitry Andric "i16:16:32-i32:32:32-i64:32:32-" 1150b57cec5SDimitry Andric "f32:32:32-f64:32:32-v64:32:32-" 1160b57cec5SDimitry Andric "v128:32:32-v256:32:32-v512:32:32-" 1170b57cec5SDimitry Andric "v1024:32:32-a0:0:32-n32"); 1180b57cec5SDimitry Andric } 1190b57cec5SDimitry Andric 1200b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 1210b57cec5SDimitry Andric MacroBuilder &Builder) const override; 1220b57cec5SDimitry Andric }; 1230b57cec5SDimitry Andric } // namespace targets 1240b57cec5SDimitry Andric } // namespace clang 1250b57cec5SDimitry Andric #endif // LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H 126