xref: /freebsd/contrib/llvm-project/clang/lib/Basic/Targets/MSP430.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
10b57cec5SDimitry Andric //===--- MSP430.h - Declare MSP430 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 MSP430 TargetInfo objects.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_MSP430_H
140b57cec5SDimitry Andric #define LLVM_CLANG_LIB_BASIC_TARGETS_MSP430_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 class LLVM_LIBRARY_VISIBILITY MSP430TargetInfo : public TargetInfo {
250b57cec5SDimitry Andric   static const char *const GCCRegNames[];
260b57cec5SDimitry Andric 
270b57cec5SDimitry Andric public:
280b57cec5SDimitry Andric   MSP430TargetInfo(const llvm::Triple &Triple, const TargetOptions &)
290b57cec5SDimitry Andric       : TargetInfo(Triple) {
300b57cec5SDimitry Andric     TLSSupported = false;
310b57cec5SDimitry Andric     IntWidth = 16;
320b57cec5SDimitry Andric     IntAlign = 16;
330b57cec5SDimitry Andric     LongWidth = 32;
340b57cec5SDimitry Andric     LongLongWidth = 64;
350b57cec5SDimitry Andric     LongAlign = LongLongAlign = 16;
360b57cec5SDimitry Andric     FloatWidth = 32;
370b57cec5SDimitry Andric     FloatAlign = 16;
380b57cec5SDimitry Andric     DoubleWidth = LongDoubleWidth = 64;
390b57cec5SDimitry Andric     DoubleAlign = LongDoubleAlign = 16;
400b57cec5SDimitry Andric     PointerWidth = 16;
410b57cec5SDimitry Andric     PointerAlign = 16;
420b57cec5SDimitry Andric     SuitableAlign = 16;
430b57cec5SDimitry Andric     SizeType = UnsignedInt;
440b57cec5SDimitry Andric     IntMaxType = SignedLongLong;
450b57cec5SDimitry Andric     IntPtrType = SignedInt;
460b57cec5SDimitry Andric     PtrDiffType = SignedInt;
470b57cec5SDimitry Andric     SigAtomicType = SignedLong;
480b57cec5SDimitry Andric     resetDataLayout("e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16");
490b57cec5SDimitry Andric   }
500b57cec5SDimitry Andric   void getTargetDefines(const LangOptions &Opts,
510b57cec5SDimitry Andric                         MacroBuilder &Builder) const override;
520b57cec5SDimitry Andric 
530b57cec5SDimitry Andric   ArrayRef<Builtin::Info> getTargetBuiltins() const override {
540b57cec5SDimitry Andric     // FIXME: Implement.
55*bdd1243dSDimitry Andric     return std::nullopt;
560b57cec5SDimitry Andric   }
570b57cec5SDimitry Andric 
580b57cec5SDimitry Andric   bool allowsLargerPreferedTypeAlignment() const override { return false; }
590b57cec5SDimitry Andric 
600b57cec5SDimitry Andric   bool hasFeature(StringRef Feature) const override {
610b57cec5SDimitry Andric     return Feature == "msp430";
620b57cec5SDimitry Andric   }
630b57cec5SDimitry Andric 
640b57cec5SDimitry Andric   ArrayRef<const char *> getGCCRegNames() const override;
650b57cec5SDimitry Andric 
660b57cec5SDimitry Andric   ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
675ffd83dbSDimitry Andric     // Make r0 - r3 be recognized by llc (f.e., in clobber list)
685ffd83dbSDimitry Andric     static const TargetInfo::GCCRegAlias GCCRegAliases[] = {
695ffd83dbSDimitry Andric         {{"r0"}, "pc"},
705ffd83dbSDimitry Andric         {{"r1"}, "sp"},
715ffd83dbSDimitry Andric         {{"r2"}, "sr"},
725ffd83dbSDimitry Andric         {{"r3"}, "cg"},
735ffd83dbSDimitry Andric     };
74*bdd1243dSDimitry Andric     return llvm::ArrayRef(GCCRegAliases);
750b57cec5SDimitry Andric   }
760b57cec5SDimitry Andric 
770b57cec5SDimitry Andric   bool validateAsmConstraint(const char *&Name,
780b57cec5SDimitry Andric                              TargetInfo::ConstraintInfo &info) const override {
790b57cec5SDimitry Andric     // FIXME: implement
800b57cec5SDimitry Andric     switch (*Name) {
810b57cec5SDimitry Andric     case 'K': // the constant 1
820b57cec5SDimitry Andric     case 'L': // constant -1^20 .. 1^19
830b57cec5SDimitry Andric     case 'M': // constant 1-4:
840b57cec5SDimitry Andric       return true;
850b57cec5SDimitry Andric     }
860b57cec5SDimitry Andric     // No target constraints for now.
870b57cec5SDimitry Andric     return false;
880b57cec5SDimitry Andric   }
890b57cec5SDimitry Andric 
900b57cec5SDimitry Andric   const char *getClobbers() const override {
910b57cec5SDimitry Andric     // FIXME: Is this really right?
920b57cec5SDimitry Andric     return "";
930b57cec5SDimitry Andric   }
940b57cec5SDimitry Andric 
950b57cec5SDimitry Andric   BuiltinVaListKind getBuiltinVaListKind() const override {
960b57cec5SDimitry Andric     // FIXME: implement
970b57cec5SDimitry Andric     return TargetInfo::CharPtrBuiltinVaList;
980b57cec5SDimitry Andric   }
990b57cec5SDimitry Andric };
1000b57cec5SDimitry Andric 
1010b57cec5SDimitry Andric } // namespace targets
1020b57cec5SDimitry Andric } // namespace clang
1030b57cec5SDimitry Andric #endif // LLVM_CLANG_LIB_BASIC_TARGETS_MSP430_H
104