clang 19.0.0git
MSP430.h
Go to the documentation of this file.
1//===--- MSP430.h - Declare MSP430 target feature support -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares MSP430 TargetInfo objects.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_MSP430_H
14#define LLVM_CLANG_LIB_BASIC_TARGETS_MSP430_H
15
18#include "llvm/Support/Compiler.h"
19#include "llvm/TargetParser/Triple.h"
20
21namespace clang {
22namespace targets {
23
24class LLVM_LIBRARY_VISIBILITY MSP430TargetInfo : public TargetInfo {
25 static const char *const GCCRegNames[];
26
27public:
28 MSP430TargetInfo(const llvm::Triple &Triple, const TargetOptions &)
29 : TargetInfo(Triple) {
30 TLSSupported = false;
31 IntWidth = 16;
32 IntAlign = 16;
33 LongWidth = 32;
34 LongLongWidth = 64;
35 LongAlign = LongLongAlign = 16;
36 FloatWidth = 32;
37 FloatAlign = 16;
38 DoubleWidth = LongDoubleWidth = 64;
39 DoubleAlign = LongDoubleAlign = 16;
40 PointerWidth = 16;
41 PointerAlign = 16;
42 SuitableAlign = 16;
43 SizeType = UnsignedInt;
44 IntMaxType = SignedLongLong;
45 IntPtrType = SignedInt;
46 PtrDiffType = SignedInt;
47 SigAtomicType = SignedLong;
48 resetDataLayout("e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16");
49 }
50 void getTargetDefines(const LangOptions &Opts,
51 MacroBuilder &Builder) const override;
52
54 // FIXME: Implement.
55 return std::nullopt;
56 }
57
58 bool allowsLargerPreferedTypeAlignment() const override { return false; }
59
60 bool hasFeature(StringRef Feature) const override {
61 return Feature == "msp430";
62 }
63
64 ArrayRef<const char *> getGCCRegNames() const override;
65
67 // Make r0 - r3 be recognized by llc (f.e., in clobber list)
68 static const TargetInfo::GCCRegAlias GCCRegAliases[] = {
69 {{"r0"}, "pc"},
70 {{"r1"}, "sp"},
71 {{"r2"}, "sr"},
72 {{"r3"}, "cg"},
73 };
74 return llvm::ArrayRef(GCCRegAliases);
75 }
76
77 bool validateAsmConstraint(const char *&Name,
78 TargetInfo::ConstraintInfo &info) const override {
79 // FIXME: implement
80 switch (*Name) {
81 case 'K': // the constant 1
82 case 'L': // constant -1^20 .. 1^19
83 case 'M': // constant 1-4:
84 return true;
85 }
86 // No target constraints for now.
87 return false;
88 }
89
90 std::string_view getClobbers() const override {
91 // FIXME: Is this really right?
92 return "";
93 }
94
96 // FIXME: implement
97 return TargetInfo::CharPtrBuiltinVaList;
98 }
99};
100
101} // namespace targets
102} // namespace clang
103#endif // LLVM_CLANG_LIB_BASIC_TARGETS_MSP430_H
Defines the clang::TargetOptions class.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:449
Exposes information about the current target.
Definition: TargetInfo.h:213
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:311
Options for controlling the target.
Definition: TargetOptions.h:26
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override
Definition: MSP430.h:77
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
Definition: MSP430.h:60
bool allowsLargerPreferedTypeAlignment() const override
Whether target allows to overalign ABI-specified preferred alignment.
Definition: MSP430.h:58
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
Definition: MSP430.h:53
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition: MSP430.h:95
std::string_view getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition: MSP430.h:90
MSP430TargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Definition: MSP430.h:28
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition: MSP430.h:66
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.