1*0b57cec5SDimitry Andric //===--- TCE.h - Declare TCE target feature support -------------*- C++ -*-===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric // 9*0b57cec5SDimitry Andric // This file declares TCE TargetInfo objects. 10*0b57cec5SDimitry Andric // 11*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 12*0b57cec5SDimitry Andric 13*0b57cec5SDimitry Andric #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H 14*0b57cec5SDimitry Andric #define LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H 15*0b57cec5SDimitry Andric 16*0b57cec5SDimitry Andric #include "clang/Basic/TargetInfo.h" 17*0b57cec5SDimitry Andric #include "clang/Basic/TargetOptions.h" 18*0b57cec5SDimitry Andric #include "llvm/ADT/Triple.h" 19*0b57cec5SDimitry Andric #include "llvm/Support/Compiler.h" 20*0b57cec5SDimitry Andric 21*0b57cec5SDimitry Andric namespace clang { 22*0b57cec5SDimitry Andric namespace targets { 23*0b57cec5SDimitry Andric 24*0b57cec5SDimitry Andric // llvm and clang cannot be used directly to output native binaries for 25*0b57cec5SDimitry Andric // target, but is used to compile C code to llvm bitcode with correct 26*0b57cec5SDimitry Andric // type and alignment information. 27*0b57cec5SDimitry Andric // 28*0b57cec5SDimitry Andric // TCE uses the llvm bitcode as input and uses it for generating customized 29*0b57cec5SDimitry Andric // target processor and program binary. TCE co-design environment is 30*0b57cec5SDimitry Andric // publicly available in http://tce.cs.tut.fi 31*0b57cec5SDimitry Andric 32*0b57cec5SDimitry Andric static const unsigned TCEOpenCLAddrSpaceMap[] = { 33*0b57cec5SDimitry Andric 0, // Default 34*0b57cec5SDimitry Andric 3, // opencl_global 35*0b57cec5SDimitry Andric 4, // opencl_local 36*0b57cec5SDimitry Andric 5, // opencl_constant 37*0b57cec5SDimitry Andric 0, // opencl_private 38*0b57cec5SDimitry Andric // FIXME: generic has to be added to the target 39*0b57cec5SDimitry Andric 0, // opencl_generic 40*0b57cec5SDimitry Andric 0, // cuda_device 41*0b57cec5SDimitry Andric 0, // cuda_constant 42*0b57cec5SDimitry Andric 0 // cuda_shared 43*0b57cec5SDimitry Andric }; 44*0b57cec5SDimitry Andric 45*0b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY TCETargetInfo : public TargetInfo { 46*0b57cec5SDimitry Andric public: 47*0b57cec5SDimitry Andric TCETargetInfo(const llvm::Triple &Triple, const TargetOptions &) 48*0b57cec5SDimitry Andric : TargetInfo(Triple) { 49*0b57cec5SDimitry Andric TLSSupported = false; 50*0b57cec5SDimitry Andric IntWidth = 32; 51*0b57cec5SDimitry Andric LongWidth = LongLongWidth = 32; 52*0b57cec5SDimitry Andric PointerWidth = 32; 53*0b57cec5SDimitry Andric IntAlign = 32; 54*0b57cec5SDimitry Andric LongAlign = LongLongAlign = 32; 55*0b57cec5SDimitry Andric PointerAlign = 32; 56*0b57cec5SDimitry Andric SuitableAlign = 32; 57*0b57cec5SDimitry Andric SizeType = UnsignedInt; 58*0b57cec5SDimitry Andric IntMaxType = SignedLong; 59*0b57cec5SDimitry Andric IntPtrType = SignedInt; 60*0b57cec5SDimitry Andric PtrDiffType = SignedInt; 61*0b57cec5SDimitry Andric FloatWidth = 32; 62*0b57cec5SDimitry Andric FloatAlign = 32; 63*0b57cec5SDimitry Andric DoubleWidth = 32; 64*0b57cec5SDimitry Andric DoubleAlign = 32; 65*0b57cec5SDimitry Andric LongDoubleWidth = 32; 66*0b57cec5SDimitry Andric LongDoubleAlign = 32; 67*0b57cec5SDimitry Andric FloatFormat = &llvm::APFloat::IEEEsingle(); 68*0b57cec5SDimitry Andric DoubleFormat = &llvm::APFloat::IEEEsingle(); 69*0b57cec5SDimitry Andric LongDoubleFormat = &llvm::APFloat::IEEEsingle(); 70*0b57cec5SDimitry Andric resetDataLayout("E-p:32:32:32-i1:8:8-i8:8:32-" 71*0b57cec5SDimitry Andric "i16:16:32-i32:32:32-i64:32:32-" 72*0b57cec5SDimitry Andric "f32:32:32-f64:32:32-v64:32:32-" 73*0b57cec5SDimitry Andric "v128:32:32-v256:32:32-v512:32:32-" 74*0b57cec5SDimitry Andric "v1024:32:32-a0:0:32-n32"); 75*0b57cec5SDimitry Andric AddrSpaceMap = &TCEOpenCLAddrSpaceMap; 76*0b57cec5SDimitry Andric UseAddrSpaceMapMangling = true; 77*0b57cec5SDimitry Andric } 78*0b57cec5SDimitry Andric 79*0b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 80*0b57cec5SDimitry Andric MacroBuilder &Builder) const override; 81*0b57cec5SDimitry Andric 82*0b57cec5SDimitry Andric bool hasFeature(StringRef Feature) const override { return Feature == "tce"; } 83*0b57cec5SDimitry Andric 84*0b57cec5SDimitry Andric ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; } 85*0b57cec5SDimitry Andric 86*0b57cec5SDimitry Andric const char *getClobbers() const override { return ""; } 87*0b57cec5SDimitry Andric 88*0b57cec5SDimitry Andric BuiltinVaListKind getBuiltinVaListKind() const override { 89*0b57cec5SDimitry Andric return TargetInfo::VoidPtrBuiltinVaList; 90*0b57cec5SDimitry Andric } 91*0b57cec5SDimitry Andric 92*0b57cec5SDimitry Andric ArrayRef<const char *> getGCCRegNames() const override { return None; } 93*0b57cec5SDimitry Andric 94*0b57cec5SDimitry Andric bool validateAsmConstraint(const char *&Name, 95*0b57cec5SDimitry Andric TargetInfo::ConstraintInfo &info) const override { 96*0b57cec5SDimitry Andric return true; 97*0b57cec5SDimitry Andric } 98*0b57cec5SDimitry Andric 99*0b57cec5SDimitry Andric ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { 100*0b57cec5SDimitry Andric return None; 101*0b57cec5SDimitry Andric } 102*0b57cec5SDimitry Andric }; 103*0b57cec5SDimitry Andric 104*0b57cec5SDimitry Andric class LLVM_LIBRARY_VISIBILITY TCELETargetInfo : public TCETargetInfo { 105*0b57cec5SDimitry Andric public: 106*0b57cec5SDimitry Andric TCELETargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) 107*0b57cec5SDimitry Andric : TCETargetInfo(Triple, Opts) { 108*0b57cec5SDimitry Andric BigEndian = false; 109*0b57cec5SDimitry Andric 110*0b57cec5SDimitry Andric resetDataLayout("e-p:32:32:32-i1:8:8-i8:8:32-" 111*0b57cec5SDimitry Andric "i16:16:32-i32:32:32-i64:32:32-" 112*0b57cec5SDimitry Andric "f32:32:32-f64:32:32-v64:32:32-" 113*0b57cec5SDimitry Andric "v128:32:32-v256:32:32-v512:32:32-" 114*0b57cec5SDimitry Andric "v1024:32:32-a0:0:32-n32"); 115*0b57cec5SDimitry Andric } 116*0b57cec5SDimitry Andric 117*0b57cec5SDimitry Andric void getTargetDefines(const LangOptions &Opts, 118*0b57cec5SDimitry Andric MacroBuilder &Builder) const override; 119*0b57cec5SDimitry Andric }; 120*0b57cec5SDimitry Andric } // namespace targets 121*0b57cec5SDimitry Andric } // namespace clang 122*0b57cec5SDimitry Andric #endif // LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H 123