/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Basic/Targets/AVR.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===--- AVR.h - Declare AVR 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 AVR TargetInfo objects. |
10 | | // |
11 | | //===----------------------------------------------------------------------===// |
12 | | |
13 | | #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_AVR_H |
14 | | #define LLVM_CLANG_LIB_BASIC_TARGETS_AVR_H |
15 | | |
16 | | #include "clang/Basic/TargetInfo.h" |
17 | | #include "clang/Basic/TargetOptions.h" |
18 | | #include "llvm/ADT/Triple.h" |
19 | | #include "llvm/Support/Compiler.h" |
20 | | |
21 | | namespace clang { |
22 | | namespace targets { |
23 | | |
24 | | // AVR Target |
25 | | class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public TargetInfo { |
26 | | public: |
27 | | AVRTargetInfo(const llvm::Triple &Triple, const TargetOptions &) |
28 | 10 | : TargetInfo(Triple) { |
29 | 10 | TLSSupported = false; |
30 | 10 | PointerWidth = 16; |
31 | 10 | PointerAlign = 8; |
32 | 10 | IntWidth = 16; |
33 | 10 | IntAlign = 8; |
34 | 10 | LongWidth = 32; |
35 | 10 | LongAlign = 8; |
36 | 10 | LongLongWidth = 64; |
37 | 10 | LongLongAlign = 8; |
38 | 10 | SuitableAlign = 8; |
39 | 10 | DefaultAlignForAttributeAligned = 8; |
40 | 10 | HalfWidth = 16; |
41 | 10 | HalfAlign = 8; |
42 | 10 | FloatWidth = 32; |
43 | 10 | FloatAlign = 8; |
44 | 10 | DoubleWidth = 32; |
45 | 10 | DoubleAlign = 8; |
46 | 10 | DoubleFormat = &llvm::APFloat::IEEEsingle(); |
47 | 10 | LongDoubleWidth = 32; |
48 | 10 | LongDoubleAlign = 8; |
49 | 10 | LongDoubleFormat = &llvm::APFloat::IEEEsingle(); |
50 | 10 | SizeType = UnsignedInt; |
51 | 10 | PtrDiffType = SignedInt; |
52 | 10 | IntPtrType = SignedInt; |
53 | 10 | Char16Type = UnsignedInt; |
54 | 10 | WIntType = SignedInt; |
55 | 10 | Char32Type = UnsignedLong; |
56 | 10 | SigAtomicType = SignedChar; |
57 | 10 | resetDataLayout("e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8"); |
58 | 10 | } clang::targets::AVRTargetInfo::AVRTargetInfo(llvm::Triple const&, clang::TargetOptions const&) Line | Count | Source | 28 | 10 | : TargetInfo(Triple) { | 29 | 10 | TLSSupported = false; | 30 | 10 | PointerWidth = 16; | 31 | 10 | PointerAlign = 8; | 32 | 10 | IntWidth = 16; | 33 | 10 | IntAlign = 8; | 34 | 10 | LongWidth = 32; | 35 | 10 | LongAlign = 8; | 36 | 10 | LongLongWidth = 64; | 37 | 10 | LongLongAlign = 8; | 38 | 10 | SuitableAlign = 8; | 39 | 10 | DefaultAlignForAttributeAligned = 8; | 40 | 10 | HalfWidth = 16; | 41 | 10 | HalfAlign = 8; | 42 | 10 | FloatWidth = 32; | 43 | 10 | FloatAlign = 8; | 44 | 10 | DoubleWidth = 32; | 45 | 10 | DoubleAlign = 8; | 46 | 10 | DoubleFormat = &llvm::APFloat::IEEEsingle(); | 47 | 10 | LongDoubleWidth = 32; | 48 | 10 | LongDoubleAlign = 8; | 49 | 10 | LongDoubleFormat = &llvm::APFloat::IEEEsingle(); | 50 | 10 | SizeType = UnsignedInt; | 51 | 10 | PtrDiffType = SignedInt; | 52 | 10 | IntPtrType = SignedInt; | 53 | 10 | Char16Type = UnsignedInt; | 54 | 10 | WIntType = SignedInt; | 55 | 10 | Char32Type = UnsignedLong; | 56 | 10 | SigAtomicType = SignedChar; | 57 | 10 | resetDataLayout("e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8"); | 58 | 10 | } |
Unexecuted instantiation: clang::targets::AVRTargetInfo::AVRTargetInfo(llvm::Triple const&, clang::TargetOptions const&) |
59 | | |
60 | | void getTargetDefines(const LangOptions &Opts, |
61 | | MacroBuilder &Builder) const override; |
62 | | |
63 | 9 | ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; } |
64 | | |
65 | 7 | BuiltinVaListKind getBuiltinVaListKind() const override { |
66 | 7 | return TargetInfo::VoidPtrBuiltinVaList; |
67 | 7 | } |
68 | | |
69 | 0 | const char *getClobbers() const override { return ""; } |
70 | | |
71 | 0 | ArrayRef<const char *> getGCCRegNames() const override { |
72 | 0 | static const char *const GCCRegNames[] = { |
73 | 0 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", |
74 | 0 | "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", |
75 | 0 | "r20", "r21", "r22", "r23", "r24", "r25", "X", "Y", "Z", "SP" |
76 | 0 | }; |
77 | 0 | return llvm::makeArrayRef(GCCRegNames); |
78 | 0 | } |
79 | | |
80 | 0 | ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { |
81 | 0 | return None; |
82 | 0 | } |
83 | | |
84 | 0 | ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override { |
85 | 0 | static const TargetInfo::AddlRegName AddlRegNames[] = { |
86 | 0 | {{"r26", "r27"}, 26}, |
87 | 0 | {{"r28", "r29"}, 27}, |
88 | 0 | {{"r30", "r31"}, 28}, |
89 | 0 | {{"SPL", "SPH"}, 29}, |
90 | 0 | }; |
91 | 0 | return llvm::makeArrayRef(AddlRegNames); |
92 | 0 | } |
93 | | |
94 | | bool validateAsmConstraint(const char *&Name, |
95 | 2 | TargetInfo::ConstraintInfo &Info) const override { |
96 | 2 | // There aren't any multi-character AVR specific constraints. |
97 | 2 | if (StringRef(Name).size() > 1) |
98 | 2 | return false; |
99 | 0 | |
100 | 0 | switch (*Name) { |
101 | 0 | default: |
102 | 0 | return false; |
103 | 0 | case 'a': // Simple upper registers |
104 | 0 | case 'b': // Base pointer registers pairs |
105 | 0 | case 'd': // Upper register |
106 | 0 | case 'l': // Lower registers |
107 | 0 | case 'e': // Pointer register pairs |
108 | 0 | case 'q': // Stack pointer register |
109 | 0 | case 'r': // Any register |
110 | 0 | case 'w': // Special upper register pairs |
111 | 0 | case 't': // Temporary register |
112 | 0 | case 'x': |
113 | 0 | case 'X': // Pointer register pair X |
114 | 0 | case 'y': |
115 | 0 | case 'Y': // Pointer register pair Y |
116 | 0 | case 'z': |
117 | 0 | case 'Z': // Pointer register pair Z |
118 | 0 | Info.setAllowsRegister(); |
119 | 0 | return true; |
120 | 0 | case 'I': // 6-bit positive integer constant |
121 | 0 | Info.setRequiresImmediate(0, 63); |
122 | 0 | return true; |
123 | 0 | case 'J': // 6-bit negative integer constant |
124 | 0 | Info.setRequiresImmediate(-63, 0); |
125 | 0 | return true; |
126 | 0 | case 'K': // Integer constant (Range: 2) |
127 | 0 | Info.setRequiresImmediate(2); |
128 | 0 | return true; |
129 | 0 | case 'L': // Integer constant (Range: 0) |
130 | 0 | Info.setRequiresImmediate(0); |
131 | 0 | return true; |
132 | 0 | case 'M': // 8-bit integer constant |
133 | 0 | Info.setRequiresImmediate(0, 0xff); |
134 | 0 | return true; |
135 | 0 | case 'N': // Integer constant (Range: -1) |
136 | 0 | Info.setRequiresImmediate(-1); |
137 | 0 | return true; |
138 | 0 | case 'O': // Integer constant (Range: 8, 16, 24) |
139 | 0 | Info.setRequiresImmediate({8, 16, 24}); |
140 | 0 | return true; |
141 | 0 | case 'P': // Integer constant (Range: 1) |
142 | 0 | Info.setRequiresImmediate(1); |
143 | 0 | return true; |
144 | 0 | case 'R': // Integer constant (Range: -6 to 5) |
145 | 0 | Info.setRequiresImmediate(-6, 5); |
146 | 0 | return true; |
147 | 0 | case 'G': // Floating point constant |
148 | 0 | case 'Q': // A memory address based on Y or Z pointer with displacement. |
149 | 0 | return true; |
150 | 0 | } |
151 | 0 | |
152 | 0 | return false; |
153 | 0 | } |
154 | | |
155 | 40 | IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const final { |
156 | 40 | // AVR prefers int for 16-bit integers. |
157 | 40 | return BitWidth == 16 ? (IsSigned 0 ? SignedInt0 : UnsignedInt0 ) |
158 | 40 | : TargetInfo::getIntTypeByWidth(BitWidth, IsSigned); |
159 | 40 | } |
160 | | |
161 | 144 | IntType getLeastIntTypeByWidth(unsigned BitWidth, bool IsSigned) const final { |
162 | 144 | // AVR uses int for int_least16_t and int_fast16_t. |
163 | 144 | return BitWidth == 16 |
164 | 144 | ? (IsSigned 36 ? SignedInt18 : UnsignedInt18 ) |
165 | 144 | : TargetInfo::getLeastIntTypeByWidth(BitWidth, IsSigned)108 ; |
166 | 144 | } |
167 | | |
168 | | bool isValidCPUName(StringRef Name) const override; |
169 | | void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override; |
170 | 1 | bool setCPU(const std::string &Name) override { |
171 | 1 | bool isValid = isValidCPUName(Name); |
172 | 1 | if (isValid) |
173 | 0 | CPU = Name; |
174 | 1 | return isValid; |
175 | 1 | } |
176 | | |
177 | | protected: |
178 | | std::string CPU; |
179 | | }; |
180 | | |
181 | | } // namespace targets |
182 | | } // namespace clang |
183 | | |
184 | | #endif // LLVM_CLANG_LIB_BASIC_TARGETS_AVR_H |