17330f729Sjoerg //===--- MSP430.h - Declare MSP430 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 MSP430 TargetInfo objects. 107330f729Sjoerg // 117330f729Sjoerg //===----------------------------------------------------------------------===// 127330f729Sjoerg 137330f729Sjoerg #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_MSP430_H 147330f729Sjoerg #define LLVM_CLANG_LIB_BASIC_TARGETS_MSP430_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 class LLVM_LIBRARY_VISIBILITY MSP430TargetInfo : public TargetInfo { 257330f729Sjoerg static const char *const GCCRegNames[]; 267330f729Sjoerg 277330f729Sjoerg public: MSP430TargetInfo(const llvm::Triple & Triple,const TargetOptions &)287330f729Sjoerg MSP430TargetInfo(const llvm::Triple &Triple, const TargetOptions &) 297330f729Sjoerg : TargetInfo(Triple) { 307330f729Sjoerg TLSSupported = false; 317330f729Sjoerg IntWidth = 16; 327330f729Sjoerg IntAlign = 16; 337330f729Sjoerg LongWidth = 32; 347330f729Sjoerg LongLongWidth = 64; 357330f729Sjoerg LongAlign = LongLongAlign = 16; 367330f729Sjoerg FloatWidth = 32; 377330f729Sjoerg FloatAlign = 16; 387330f729Sjoerg DoubleWidth = LongDoubleWidth = 64; 397330f729Sjoerg DoubleAlign = LongDoubleAlign = 16; 407330f729Sjoerg PointerWidth = 16; 417330f729Sjoerg PointerAlign = 16; 427330f729Sjoerg SuitableAlign = 16; 437330f729Sjoerg SizeType = UnsignedInt; 447330f729Sjoerg IntMaxType = SignedLongLong; 457330f729Sjoerg IntPtrType = SignedInt; 467330f729Sjoerg PtrDiffType = SignedInt; 477330f729Sjoerg SigAtomicType = SignedLong; 487330f729Sjoerg resetDataLayout("e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16"); 497330f729Sjoerg } 507330f729Sjoerg void getTargetDefines(const LangOptions &Opts, 517330f729Sjoerg MacroBuilder &Builder) const override; 527330f729Sjoerg getTargetBuiltins()537330f729Sjoerg ArrayRef<Builtin::Info> getTargetBuiltins() const override { 547330f729Sjoerg // FIXME: Implement. 557330f729Sjoerg return None; 567330f729Sjoerg } 577330f729Sjoerg allowsLargerPreferedTypeAlignment()587330f729Sjoerg bool allowsLargerPreferedTypeAlignment() const override { return false; } 597330f729Sjoerg hasFeature(StringRef Feature)607330f729Sjoerg bool hasFeature(StringRef Feature) const override { 617330f729Sjoerg return Feature == "msp430"; 627330f729Sjoerg } 637330f729Sjoerg 647330f729Sjoerg ArrayRef<const char *> getGCCRegNames() const override; 657330f729Sjoerg getGCCRegAliases()667330f729Sjoerg ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { 67*e038c9c4Sjoerg // Make r0 - r3 be recognized by llc (f.e., in clobber list) 68*e038c9c4Sjoerg static const TargetInfo::GCCRegAlias GCCRegAliases[] = { 69*e038c9c4Sjoerg {{"r0"}, "pc"}, 70*e038c9c4Sjoerg {{"r1"}, "sp"}, 71*e038c9c4Sjoerg {{"r2"}, "sr"}, 72*e038c9c4Sjoerg {{"r3"}, "cg"}, 73*e038c9c4Sjoerg }; 74*e038c9c4Sjoerg return llvm::makeArrayRef(GCCRegAliases); 757330f729Sjoerg } 767330f729Sjoerg validateAsmConstraint(const char * & Name,TargetInfo::ConstraintInfo & info)777330f729Sjoerg bool validateAsmConstraint(const char *&Name, 787330f729Sjoerg TargetInfo::ConstraintInfo &info) const override { 797330f729Sjoerg // FIXME: implement 807330f729Sjoerg switch (*Name) { 817330f729Sjoerg case 'K': // the constant 1 827330f729Sjoerg case 'L': // constant -1^20 .. 1^19 837330f729Sjoerg case 'M': // constant 1-4: 847330f729Sjoerg return true; 857330f729Sjoerg } 867330f729Sjoerg // No target constraints for now. 877330f729Sjoerg return false; 887330f729Sjoerg } 897330f729Sjoerg getClobbers()907330f729Sjoerg const char *getClobbers() const override { 917330f729Sjoerg // FIXME: Is this really right? 927330f729Sjoerg return ""; 937330f729Sjoerg } 947330f729Sjoerg getBuiltinVaListKind()957330f729Sjoerg BuiltinVaListKind getBuiltinVaListKind() const override { 967330f729Sjoerg // FIXME: implement 977330f729Sjoerg return TargetInfo::CharPtrBuiltinVaList; 987330f729Sjoerg } 997330f729Sjoerg }; 1007330f729Sjoerg 1017330f729Sjoerg } // namespace targets 1027330f729Sjoerg } // namespace clang 1037330f729Sjoerg #endif // LLVM_CLANG_LIB_BASIC_TARGETS_MSP430_H 104