1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | #ifndef LLVM_CLANG_BASIC_TARGETINFO_H |
15 | #define LLVM_CLANG_BASIC_TARGETINFO_H |
16 | |
17 | #include "clang/Basic/AddressSpaces.h" |
18 | #include "clang/Basic/LLVM.h" |
19 | #include "clang/Basic/Specifiers.h" |
20 | #include "clang/Basic/TargetCXXABI.h" |
21 | #include "clang/Basic/TargetOptions.h" |
22 | #include "llvm/ADT/APInt.h" |
23 | #include "llvm/ADT/IntrusiveRefCntPtr.h" |
24 | #include "llvm/ADT/Optional.h" |
25 | #include "llvm/ADT/SmallSet.h" |
26 | #include "llvm/ADT/StringMap.h" |
27 | #include "llvm/ADT/StringRef.h" |
28 | #include "llvm/ADT/Triple.h" |
29 | #include "llvm/IR/DataLayout.h" |
30 | #include "llvm/Support/DataTypes.h" |
31 | #include "llvm/Support/VersionTuple.h" |
32 | #include <cassert> |
33 | #include <string> |
34 | #include <vector> |
35 | |
36 | namespace llvm { |
37 | struct fltSemantics; |
38 | } |
39 | |
40 | namespace clang { |
41 | class DiagnosticsEngine; |
42 | class LangOptions; |
43 | class CodeGenOptions; |
44 | class MacroBuilder; |
45 | class QualType; |
46 | class SourceLocation; |
47 | class SourceManager; |
48 | |
49 | namespace Builtin { struct Info; } |
50 | |
51 | |
52 | |
53 | |
54 | struct TransferrableTargetInfo { |
55 | unsigned char PointerWidth, PointerAlign; |
56 | unsigned char BoolWidth, BoolAlign; |
57 | unsigned char IntWidth, IntAlign; |
58 | unsigned char HalfWidth, HalfAlign; |
59 | unsigned char FloatWidth, FloatAlign; |
60 | unsigned char DoubleWidth, DoubleAlign; |
61 | unsigned char LongDoubleWidth, LongDoubleAlign, Float128Align; |
62 | unsigned char LargeArrayMinWidth, LargeArrayAlign; |
63 | unsigned char LongWidth, LongAlign; |
64 | unsigned char LongLongWidth, LongLongAlign; |
65 | |
66 | |
67 | unsigned char ShortAccumWidth, ShortAccumAlign; |
68 | unsigned char AccumWidth, AccumAlign; |
69 | unsigned char LongAccumWidth, LongAccumAlign; |
70 | unsigned char ShortFractWidth, ShortFractAlign; |
71 | unsigned char FractWidth, FractAlign; |
72 | unsigned char LongFractWidth, LongFractAlign; |
73 | |
74 | |
75 | |
76 | |
77 | |
78 | |
79 | bool PaddingOnUnsignedFixedPoint; |
80 | |
81 | |
82 | |
83 | |
84 | |
85 | |
86 | |
87 | |
88 | unsigned char ShortAccumScale; |
89 | unsigned char AccumScale; |
90 | unsigned char LongAccumScale; |
91 | |
92 | unsigned char SuitableAlign; |
93 | unsigned char DefaultAlignForAttributeAligned; |
94 | unsigned char MinGlobalAlign; |
95 | |
96 | unsigned short NewAlign; |
97 | unsigned short MaxVectorAlign; |
98 | unsigned short MaxTLSAlign; |
99 | |
100 | const llvm::fltSemantics *HalfFormat, *FloatFormat, *DoubleFormat, |
101 | *LongDoubleFormat, *Float128Format; |
102 | |
103 | |
104 | enum IntType { |
105 | NoInt = 0, |
106 | SignedChar, |
107 | UnsignedChar, |
108 | SignedShort, |
109 | UnsignedShort, |
110 | SignedInt, |
111 | UnsignedInt, |
112 | SignedLong, |
113 | UnsignedLong, |
114 | SignedLongLong, |
115 | UnsignedLongLong |
116 | }; |
117 | |
118 | enum RealType { |
119 | NoFloat = 255, |
120 | Float = 0, |
121 | Double, |
122 | LongDouble, |
123 | Float128 |
124 | }; |
125 | protected: |
126 | IntType SizeType, IntMaxType, PtrDiffType, IntPtrType, WCharType, |
127 | WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType, |
128 | ProcessIDType; |
129 | |
130 | |
131 | |
132 | |
133 | |
134 | unsigned UseSignedCharForObjCBool : 1; |
135 | |
136 | |
137 | |
138 | |
139 | |
140 | |
141 | unsigned UseBitFieldTypeAlignment : 1; |
142 | |
143 | |
144 | |
145 | |
146 | |
147 | |
148 | |
149 | unsigned UseZeroLengthBitfieldAlignment : 1; |
150 | |
151 | |
152 | unsigned UseExplicitBitFieldAlignment : 1; |
153 | |
154 | |
155 | |
156 | unsigned ZeroLengthBitfieldBoundary; |
157 | }; |
158 | |
159 | |
160 | |
161 | class TargetInfo : public virtual TransferrableTargetInfo, |
162 | public RefCountedBase<TargetInfo> { |
163 | std::shared_ptr<TargetOptions> TargetOpts; |
164 | llvm::Triple Triple; |
165 | protected: |
166 | |
167 | |
168 | bool BigEndian; |
169 | bool TLSSupported; |
170 | bool VLASupported; |
171 | bool NoAsmVariants; |
172 | bool HasLegalHalfType; |
173 | |
174 | bool HasFloat128; |
175 | bool HasFloat16; |
176 | |
177 | unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth; |
178 | unsigned short SimdDefaultAlign; |
179 | std::unique_ptr<llvm::DataLayout> DataLayout; |
180 | const char *MCountName; |
181 | unsigned char RegParmMax, SSERegParmMax; |
182 | TargetCXXABI TheCXXABI; |
183 | const LangASMap *AddrSpaceMap; |
184 | |
185 | mutable StringRef PlatformName; |
186 | mutable VersionTuple PlatformMinVersion; |
187 | |
188 | unsigned HasAlignMac68kSupport : 1; |
189 | unsigned RealTypeUsesObjCFPRet : 3; |
190 | unsigned ComplexLongDoubleUsesFP2Ret : 1; |
191 | |
192 | unsigned HasBuiltinMSVaList : 1; |
193 | |
194 | unsigned IsRenderScriptTarget : 1; |
195 | |
196 | |
197 | TargetInfo(const llvm::Triple &T); |
198 | |
199 | void resetDataLayout(StringRef DL) { |
200 | DataLayout.reset(new llvm::DataLayout(DL)); |
201 | } |
202 | |
203 | public: |
204 | |
205 | |
206 | |
207 | |
208 | |
209 | static TargetInfo * |
210 | CreateTargetInfo(DiagnosticsEngine &Diags, |
211 | const std::shared_ptr<TargetOptions> &Opts); |
212 | |
213 | virtual ~TargetInfo(); |
214 | |
215 | |
216 | TargetOptions &getTargetOpts() const { |
217 | (0) . __assert_fail ("TargetOpts && \"Missing target options\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/TargetInfo.h", 217, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(TargetOpts && "Missing target options"); |
218 | return *TargetOpts; |
219 | } |
220 | |
221 | |
222 | |
223 | enum BuiltinVaListKind { |
224 | |
225 | CharPtrBuiltinVaList = 0, |
226 | |
227 | |
228 | VoidPtrBuiltinVaList, |
229 | |
230 | |
231 | |
232 | AArch64ABIBuiltinVaList, |
233 | |
234 | |
235 | |
236 | PNaClABIBuiltinVaList, |
237 | |
238 | |
239 | |
240 | |
241 | PowerABIBuiltinVaList, |
242 | |
243 | |
244 | |
245 | X86_64ABIBuiltinVaList, |
246 | |
247 | |
248 | |
249 | |
250 | AAPCSABIBuiltinVaList, |
251 | |
252 | |
253 | |
254 | |
255 | |
256 | |
257 | |
258 | |
259 | SystemZBuiltinVaList |
260 | }; |
261 | |
262 | protected: |
263 | |
264 | |
265 | bool UseAddrSpaceMapMangling; |
266 | |
267 | public: |
268 | IntType getSizeType() const { return SizeType; } |
269 | IntType getSignedSizeType() const { |
270 | switch (SizeType) { |
271 | case UnsignedShort: |
272 | return SignedShort; |
273 | case UnsignedInt: |
274 | return SignedInt; |
275 | case UnsignedLong: |
276 | return SignedLong; |
277 | case UnsignedLongLong: |
278 | return SignedLongLong; |
279 | default: |
280 | llvm_unreachable("Invalid SizeType"); |
281 | } |
282 | } |
283 | IntType getIntMaxType() const { return IntMaxType; } |
284 | IntType getUIntMaxType() const { |
285 | return getCorrespondingUnsignedType(IntMaxType); |
286 | } |
287 | IntType getPtrDiffType(unsigned AddrSpace) const { |
288 | return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace); |
289 | } |
290 | IntType getUnsignedPtrDiffType(unsigned AddrSpace) const { |
291 | return getCorrespondingUnsignedType(getPtrDiffType(AddrSpace)); |
292 | } |
293 | IntType getIntPtrType() const { return IntPtrType; } |
294 | IntType getUIntPtrType() const { |
295 | return getCorrespondingUnsignedType(IntPtrType); |
296 | } |
297 | IntType getWCharType() const { return WCharType; } |
298 | IntType getWIntType() const { return WIntType; } |
299 | IntType getChar16Type() const { return Char16Type; } |
300 | IntType getChar32Type() const { return Char32Type; } |
301 | IntType getInt64Type() const { return Int64Type; } |
302 | IntType getUInt64Type() const { |
303 | return getCorrespondingUnsignedType(Int64Type); |
304 | } |
305 | IntType getSigAtomicType() const { return SigAtomicType; } |
306 | IntType getProcessIDType() const { return ProcessIDType; } |
307 | |
308 | static IntType getCorrespondingUnsignedType(IntType T) { |
309 | switch (T) { |
310 | case SignedChar: |
311 | return UnsignedChar; |
312 | case SignedShort: |
313 | return UnsignedShort; |
314 | case SignedInt: |
315 | return UnsignedInt; |
316 | case SignedLong: |
317 | return UnsignedLong; |
318 | case SignedLongLong: |
319 | return UnsignedLongLong; |
320 | default: |
321 | llvm_unreachable("Unexpected signed integer type"); |
322 | } |
323 | } |
324 | |
325 | |
326 | |
327 | |
328 | |
329 | bool doUnsignedFixedPointTypesHavePadding() const { |
330 | return PaddingOnUnsignedFixedPoint; |
331 | } |
332 | |
333 | |
334 | |
335 | |
336 | unsigned getTypeWidth(IntType T) const; |
337 | |
338 | |
339 | virtual IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const; |
340 | |
341 | |
342 | virtual IntType getLeastIntTypeByWidth(unsigned BitWidth, |
343 | bool IsSigned) const; |
344 | |
345 | |
346 | RealType getRealTypeByWidth(unsigned BitWidth) const; |
347 | |
348 | |
349 | |
350 | |
351 | unsigned getTypeAlign(IntType T) const; |
352 | |
353 | |
354 | static bool isTypeSigned(IntType T); |
355 | |
356 | |
357 | |
358 | uint64_t getPointerWidth(unsigned AddrSpace) const { |
359 | return AddrSpace == 0 ? PointerWidth : getPointerWidthV(AddrSpace); |
360 | } |
361 | uint64_t getPointerAlign(unsigned AddrSpace) const { |
362 | return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace); |
363 | } |
364 | |
365 | |
366 | virtual uint64_t getMaxPointerWidth() const { |
367 | return PointerWidth; |
368 | } |
369 | |
370 | |
371 | |
372 | virtual uint64_t getNullPointerValue(LangAS AddrSpace) const { return 0; } |
373 | |
374 | |
375 | unsigned getBoolWidth() const { return BoolWidth; } |
376 | |
377 | |
378 | unsigned getBoolAlign() const { return BoolAlign; } |
379 | |
380 | unsigned getCharWidth() const { return 8; } |
381 | unsigned getCharAlign() const { return 8; } |
382 | |
383 | |
384 | |
385 | unsigned getShortWidth() const { return 16; } |
386 | |
387 | |
388 | |
389 | unsigned getShortAlign() const { return 16; } |
390 | |
391 | |
392 | |
393 | unsigned getIntWidth() const { return IntWidth; } |
394 | unsigned getIntAlign() const { return IntAlign; } |
395 | |
396 | |
397 | |
398 | unsigned getLongWidth() const { return LongWidth; } |
399 | unsigned getLongAlign() const { return LongAlign; } |
400 | |
401 | |
402 | |
403 | unsigned getLongLongWidth() const { return LongLongWidth; } |
404 | unsigned getLongLongAlign() const { return LongLongAlign; } |
405 | |
406 | |
407 | |
408 | unsigned getShortAccumWidth() const { return ShortAccumWidth; } |
409 | unsigned getShortAccumAlign() const { return ShortAccumAlign; } |
410 | |
411 | |
412 | |
413 | unsigned getAccumWidth() const { return AccumWidth; } |
414 | unsigned getAccumAlign() const { return AccumAlign; } |
415 | |
416 | |
417 | |
418 | unsigned getLongAccumWidth() const { return LongAccumWidth; } |
419 | unsigned getLongAccumAlign() const { return LongAccumAlign; } |
420 | |
421 | |
422 | |
423 | unsigned getShortFractWidth() const { return ShortFractWidth; } |
424 | unsigned getShortFractAlign() const { return ShortFractAlign; } |
425 | |
426 | |
427 | |
428 | unsigned getFractWidth() const { return FractWidth; } |
429 | unsigned getFractAlign() const { return FractAlign; } |
430 | |
431 | |
432 | |
433 | unsigned getLongFractWidth() const { return LongFractWidth; } |
434 | unsigned getLongFractAlign() const { return LongFractAlign; } |
435 | |
436 | |
437 | |
438 | unsigned getShortAccumScale() const { return ShortAccumScale; } |
439 | unsigned getShortAccumIBits() const { |
440 | return ShortAccumWidth - ShortAccumScale - 1; |
441 | } |
442 | |
443 | |
444 | |
445 | unsigned getAccumScale() const { return AccumScale; } |
446 | unsigned getAccumIBits() const { return AccumWidth - AccumScale - 1; } |
447 | |
448 | |
449 | |
450 | unsigned getLongAccumScale() const { return LongAccumScale; } |
451 | unsigned getLongAccumIBits() const { |
452 | return LongAccumWidth - LongAccumScale - 1; |
453 | } |
454 | |
455 | |
456 | |
457 | unsigned getUnsignedShortAccumScale() const { |
458 | return PaddingOnUnsignedFixedPoint ? ShortAccumScale : ShortAccumScale + 1; |
459 | } |
460 | unsigned getUnsignedShortAccumIBits() const { |
461 | return PaddingOnUnsignedFixedPoint |
462 | ? getShortAccumIBits() |
463 | : ShortAccumWidth - getUnsignedShortAccumScale(); |
464 | } |
465 | |
466 | |
467 | |
468 | unsigned getUnsignedAccumScale() const { |
469 | return PaddingOnUnsignedFixedPoint ? AccumScale : AccumScale + 1; |
470 | } |
471 | unsigned getUnsignedAccumIBits() const { |
472 | return PaddingOnUnsignedFixedPoint ? getAccumIBits() |
473 | : AccumWidth - getUnsignedAccumScale(); |
474 | } |
475 | |
476 | |
477 | |
478 | unsigned getUnsignedLongAccumScale() const { |
479 | return PaddingOnUnsignedFixedPoint ? LongAccumScale : LongAccumScale + 1; |
480 | } |
481 | unsigned getUnsignedLongAccumIBits() const { |
482 | return PaddingOnUnsignedFixedPoint |
483 | ? getLongAccumIBits() |
484 | : LongAccumWidth - getUnsignedLongAccumScale(); |
485 | } |
486 | |
487 | |
488 | |
489 | unsigned getShortFractScale() const { return ShortFractWidth - 1; } |
490 | |
491 | |
492 | |
493 | unsigned getFractScale() const { return FractWidth - 1; } |
494 | |
495 | |
496 | |
497 | unsigned getLongFractScale() const { return LongFractWidth - 1; } |
498 | |
499 | |
500 | |
501 | unsigned getUnsignedShortFractScale() const { |
502 | return PaddingOnUnsignedFixedPoint ? getShortFractScale() |
503 | : getShortFractScale() + 1; |
504 | } |
505 | |
506 | |
507 | |
508 | unsigned getUnsignedFractScale() const { |
509 | return PaddingOnUnsignedFixedPoint ? getFractScale() : getFractScale() + 1; |
510 | } |
511 | |
512 | |
513 | |
514 | unsigned getUnsignedLongFractScale() const { |
515 | return PaddingOnUnsignedFixedPoint ? getLongFractScale() |
516 | : getLongFractScale() + 1; |
517 | } |
518 | |
519 | |
520 | virtual bool hasInt128Type() const { |
521 | return (getPointerWidth(0) >= 64) || getTargetOpts().ForceEnableInt128; |
522 | } |
523 | |
524 | |
525 | virtual bool hasLegalHalfType() const { return HasLegalHalfType; } |
526 | |
527 | |
528 | virtual bool hasFloat128Type() const { return HasFloat128; } |
529 | |
530 | |
531 | virtual bool hasFloat16Type() const { return HasFloat16; } |
532 | |
533 | |
534 | |
535 | unsigned getSuitableAlign() const { return SuitableAlign; } |
536 | |
537 | |
538 | |
539 | unsigned getDefaultAlignForAttributeAligned() const { |
540 | return DefaultAlignForAttributeAligned; |
541 | } |
542 | |
543 | |
544 | |
545 | unsigned getMinGlobalAlign() const { return MinGlobalAlign; } |
546 | |
547 | |
548 | |
549 | |
550 | unsigned getNewAlign() const { |
551 | return NewAlign ? NewAlign : std::max(LongDoubleAlign, LongLongAlign); |
552 | } |
553 | |
554 | |
555 | |
556 | unsigned getWCharWidth() const { return getTypeWidth(WCharType); } |
557 | unsigned getWCharAlign() const { return getTypeAlign(WCharType); } |
558 | |
559 | |
560 | |
561 | unsigned getChar16Width() const { return getTypeWidth(Char16Type); } |
562 | unsigned getChar16Align() const { return getTypeAlign(Char16Type); } |
563 | |
564 | |
565 | |
566 | unsigned getChar32Width() const { return getTypeWidth(Char32Type); } |
567 | unsigned getChar32Align() const { return getTypeAlign(Char32Type); } |
568 | |
569 | |
570 | unsigned getHalfWidth() const { return HalfWidth; } |
571 | unsigned getHalfAlign() const { return HalfAlign; } |
572 | const llvm::fltSemantics &getHalfFormat() const { return *HalfFormat; } |
573 | |
574 | |
575 | unsigned getFloatWidth() const { return FloatWidth; } |
576 | unsigned getFloatAlign() const { return FloatAlign; } |
577 | const llvm::fltSemantics &getFloatFormat() const { return *FloatFormat; } |
578 | |
579 | |
580 | unsigned getDoubleWidth() const { return DoubleWidth; } |
581 | unsigned getDoubleAlign() const { return DoubleAlign; } |
582 | const llvm::fltSemantics &getDoubleFormat() const { return *DoubleFormat; } |
583 | |
584 | |
585 | |
586 | unsigned getLongDoubleWidth() const { return LongDoubleWidth; } |
587 | unsigned getLongDoubleAlign() const { return LongDoubleAlign; } |
588 | const llvm::fltSemantics &getLongDoubleFormat() const { |
589 | return *LongDoubleFormat; |
590 | } |
591 | |
592 | |
593 | |
594 | unsigned getFloat128Width() const { return 128; } |
595 | unsigned getFloat128Align() const { return Float128Align; } |
596 | const llvm::fltSemantics &getFloat128Format() const { |
597 | return *Float128Format; |
598 | } |
599 | |
600 | |
601 | |
602 | virtual bool useFloat128ManglingForLongDouble() const { return false; } |
603 | |
604 | |
605 | virtual unsigned getFloatEvalMethod() const { return 0; } |
606 | |
607 | |
608 | |
609 | unsigned getLargeArrayMinWidth() const { return LargeArrayMinWidth; } |
610 | unsigned getLargeArrayAlign() const { return LargeArrayAlign; } |
611 | |
612 | |
613 | |
614 | unsigned getMaxAtomicPromoteWidth() const { return MaxAtomicPromoteWidth; } |
615 | |
616 | |
617 | unsigned getMaxAtomicInlineWidth() const { return MaxAtomicInlineWidth; } |
618 | |
619 | |
620 | virtual void setMaxAtomicWidth() {} |
621 | |
622 | |
623 | virtual bool hasBuiltinAtomic(uint64_t AtomicSizeInBits, |
624 | uint64_t AlignmentInBits) const { |
625 | return AtomicSizeInBits <= AlignmentInBits && |
626 | AtomicSizeInBits <= getMaxAtomicInlineWidth() && |
627 | (AtomicSizeInBits <= getCharWidth() || |
628 | llvm::isPowerOf2_64(AtomicSizeInBits / getCharWidth())); |
629 | } |
630 | |
631 | |
632 | unsigned getMaxVectorAlign() const { return MaxVectorAlign; } |
633 | |
634 | |
635 | |
636 | unsigned getSimdDefaultAlign() const { return SimdDefaultAlign; } |
637 | |
638 | |
639 | unsigned getIntMaxTWidth() const { |
640 | return getTypeWidth(IntMaxType); |
641 | } |
642 | |
643 | |
644 | virtual unsigned getUnwindWordWidth() const { return getPointerWidth(0); } |
645 | |
646 | |
647 | virtual unsigned getRegisterWidth() const { |
648 | |
649 | |
650 | |
651 | return PointerWidth; |
652 | } |
653 | |
654 | |
655 | const char *getMCountName() const { |
656 | return MCountName; |
657 | } |
658 | |
659 | |
660 | |
661 | |
662 | |
663 | |
664 | bool useSignedCharForObjCBool() const { |
665 | return UseSignedCharForObjCBool; |
666 | } |
667 | void noSignedCharForObjCBool() { |
668 | UseSignedCharForObjCBool = false; |
669 | } |
670 | |
671 | |
672 | |
673 | bool useBitFieldTypeAlignment() const { |
674 | return UseBitFieldTypeAlignment; |
675 | } |
676 | |
677 | |
678 | |
679 | bool useZeroLengthBitfieldAlignment() const { |
680 | return UseZeroLengthBitfieldAlignment; |
681 | } |
682 | |
683 | |
684 | |
685 | unsigned getZeroLengthBitfieldBoundary() const { |
686 | return ZeroLengthBitfieldBoundary; |
687 | } |
688 | |
689 | |
690 | |
691 | bool useExplicitBitFieldAlignment() const { |
692 | return UseExplicitBitFieldAlignment; |
693 | } |
694 | |
695 | |
696 | bool hasAlignMac68kSupport() const { |
697 | return HasAlignMac68kSupport; |
698 | } |
699 | |
700 | |
701 | |
702 | |
703 | static const char *getTypeName(IntType T); |
704 | |
705 | |
706 | |
707 | |
708 | const char *getTypeConstantSuffix(IntType T) const; |
709 | |
710 | |
711 | |
712 | |
713 | |
714 | static const char *getTypeFormatModifier(IntType T); |
715 | |
716 | |
717 | |
718 | bool useObjCFPRetForRealType(RealType T) const { |
719 | return RealTypeUsesObjCFPRet & (1 << T); |
720 | } |
721 | |
722 | |
723 | |
724 | bool useObjCFP2RetForComplexLongDouble() const { |
725 | return ComplexLongDoubleUsesFP2Ret; |
726 | } |
727 | |
728 | |
729 | |
730 | |
731 | |
732 | virtual bool useFP16ConversionIntrinsics() const { |
733 | return true; |
734 | } |
735 | |
736 | |
737 | |
738 | bool useAddressSpaceMapMangling() const { |
739 | return UseAddrSpaceMapMangling; |
740 | } |
741 | |
742 | |
743 | |
744 | |
745 | |
746 | virtual void getTargetDefines(const LangOptions &Opts, |
747 | MacroBuilder &Builder) const = 0; |
748 | |
749 | |
750 | |
751 | |
752 | |
753 | virtual ArrayRef<Builtin::Info> getTargetBuiltins() const = 0; |
754 | |
755 | |
756 | |
757 | |
758 | |
759 | |
760 | virtual bool isCLZForZeroUndef() const { return true; } |
761 | |
762 | |
763 | |
764 | virtual BuiltinVaListKind getBuiltinVaListKind() const = 0; |
765 | |
766 | |
767 | |
768 | bool hasBuiltinMSVaList() const { return HasBuiltinMSVaList; } |
769 | |
770 | |
771 | bool isRenderScriptTarget() const { return IsRenderScriptTarget; } |
772 | |
773 | |
774 | |
775 | |
776 | |
777 | bool isValidClobber(StringRef Name) const; |
778 | |
779 | |
780 | |
781 | |
782 | |
783 | virtual bool isValidGCCRegisterName(StringRef Name) const; |
784 | |
785 | |
786 | |
787 | |
788 | |
789 | |
790 | StringRef getNormalizedGCCRegisterName(StringRef Name, |
791 | bool ReturnCanonical = false) const; |
792 | |
793 | |
794 | |
795 | |
796 | |
797 | |
798 | |
799 | virtual StringRef getConstraintRegister(StringRef Constraint, |
800 | StringRef Expression) const { |
801 | return ""; |
802 | } |
803 | |
804 | struct ConstraintInfo { |
805 | enum { |
806 | CI_None = 0x00, |
807 | CI_AllowsMemory = 0x01, |
808 | CI_AllowsRegister = 0x02, |
809 | CI_ReadWrite = 0x04, |
810 | CI_HasMatchingInput = 0x08, |
811 | CI_ImmediateConstant = 0x10, |
812 | CI_EarlyClobber = 0x20, |
813 | }; |
814 | unsigned Flags; |
815 | int TiedOperand; |
816 | struct { |
817 | int Min; |
818 | int Max; |
819 | bool isConstrained; |
820 | } ImmRange; |
821 | llvm::SmallSet<int, 4> ImmSet; |
822 | |
823 | std::string ConstraintStr; |
824 | std::string Name; |
825 | public: |
826 | ConstraintInfo(StringRef ConstraintStr, StringRef Name) |
827 | : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()), |
828 | Name(Name.str()) { |
829 | ImmRange.Min = ImmRange.Max = 0; |
830 | ImmRange.isConstrained = false; |
831 | } |
832 | |
833 | const std::string &getConstraintStr() const { return ConstraintStr; } |
834 | const std::string &getName() const { return Name; } |
835 | bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; } |
836 | bool earlyClobber() { return (Flags & CI_EarlyClobber) != 0; } |
837 | bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; } |
838 | bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; } |
839 | |
840 | |
841 | |
842 | bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; } |
843 | |
844 | |
845 | |
846 | |
847 | |
848 | |
849 | bool hasTiedOperand() const { return TiedOperand != -1; } |
850 | unsigned getTiedOperand() const { |
851 | (0) . __assert_fail ("hasTiedOperand() && \"Has no tied operand!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/TargetInfo.h", 851, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(hasTiedOperand() && "Has no tied operand!"); |
852 | return (unsigned)TiedOperand; |
853 | } |
854 | |
855 | bool requiresImmediateConstant() const { |
856 | return (Flags & CI_ImmediateConstant) != 0; |
857 | } |
858 | bool isValidAsmImmediate(const llvm::APInt &Value) const { |
859 | if (!ImmSet.empty()) |
860 | return Value.isSignedIntN(32) && |
861 | ImmSet.count(Value.getZExtValue()) != 0; |
862 | return !ImmRange.isConstrained || |
863 | (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max)); |
864 | } |
865 | |
866 | void setIsReadWrite() { Flags |= CI_ReadWrite; } |
867 | void setEarlyClobber() { Flags |= CI_EarlyClobber; } |
868 | void setAllowsMemory() { Flags |= CI_AllowsMemory; } |
869 | void setAllowsRegister() { Flags |= CI_AllowsRegister; } |
870 | void setHasMatchingInput() { Flags |= CI_HasMatchingInput; } |
871 | void setRequiresImmediate(int Min, int Max) { |
872 | Flags |= CI_ImmediateConstant; |
873 | ImmRange.Min = Min; |
874 | ImmRange.Max = Max; |
875 | ImmRange.isConstrained = true; |
876 | } |
877 | void setRequiresImmediate(llvm::ArrayRef<int> Exacts) { |
878 | Flags |= CI_ImmediateConstant; |
879 | for (int Exact : Exacts) |
880 | ImmSet.insert(Exact); |
881 | } |
882 | void setRequiresImmediate(int Exact) { |
883 | Flags |= CI_ImmediateConstant; |
884 | ImmSet.insert(Exact); |
885 | } |
886 | void setRequiresImmediate() { |
887 | Flags |= CI_ImmediateConstant; |
888 | } |
889 | |
890 | |
891 | |
892 | |
893 | |
894 | void setTiedOperand(unsigned N, ConstraintInfo &Output) { |
895 | Output.setHasMatchingInput(); |
896 | Flags = Output.Flags; |
897 | TiedOperand = N; |
898 | |
899 | } |
900 | }; |
901 | |
902 | |
903 | |
904 | |
905 | |
906 | |
907 | |
908 | virtual bool validateGlobalRegisterVariable(StringRef RegName, |
909 | unsigned RegSize, |
910 | bool &HasSizeMismatch) const { |
911 | HasSizeMismatch = false; |
912 | return true; |
913 | } |
914 | |
915 | |
916 | |
917 | |
918 | bool validateOutputConstraint(ConstraintInfo &Info) const; |
919 | bool validateInputConstraint(MutableArrayRef<ConstraintInfo> OutputConstraints, |
920 | ConstraintInfo &info) const; |
921 | |
922 | virtual bool validateOutputSize(StringRef , |
923 | unsigned ) const { |
924 | return true; |
925 | } |
926 | |
927 | virtual bool validateInputSize(StringRef , |
928 | unsigned ) const { |
929 | return true; |
930 | } |
931 | virtual bool |
932 | validateConstraintModifier(StringRef , |
933 | char , |
934 | unsigned , |
935 | std::string &) const { |
936 | return true; |
937 | } |
938 | virtual bool |
939 | validateAsmConstraint(const char *&Name, |
940 | TargetInfo::ConstraintInfo &info) const = 0; |
941 | |
942 | bool resolveSymbolicName(const char *&Name, |
943 | ArrayRef<ConstraintInfo> OutputConstraints, |
944 | unsigned &Index) const; |
945 | |
946 | |
947 | |
948 | |
949 | virtual std::string convertConstraint(const char *&Constraint) const { |
950 | |
951 | if (*Constraint == 'p') |
952 | return std::string("r"); |
953 | return std::string(1, *Constraint); |
954 | } |
955 | |
956 | |
957 | virtual const char *getClobbers() const = 0; |
958 | |
959 | |
960 | |
961 | virtual bool isNan2008() const { |
962 | return true; |
963 | } |
964 | |
965 | |
966 | const llvm::Triple &getTriple() const { |
967 | return Triple; |
968 | } |
969 | |
970 | const llvm::DataLayout &getDataLayout() const { |
971 | (0) . __assert_fail ("DataLayout && \"Uninitialized DataLayout!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/TargetInfo.h", 971, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(DataLayout && "Uninitialized DataLayout!"); |
972 | return *DataLayout; |
973 | } |
974 | |
975 | struct GCCRegAlias { |
976 | const char * const Aliases[5]; |
977 | const char * const Register; |
978 | }; |
979 | |
980 | struct AddlRegName { |
981 | const char * const Names[5]; |
982 | const unsigned RegNum; |
983 | }; |
984 | |
985 | |
986 | |
987 | |
988 | |
989 | |
990 | |
991 | |
992 | |
993 | |
994 | |
995 | virtual bool hasProtectedVisibility() const { return true; } |
996 | |
997 | |
998 | |
999 | |
1000 | |
1001 | |
1002 | |
1003 | |
1004 | |
1005 | |
1006 | |
1007 | |
1008 | virtual std::string isValidSectionSpecifier(StringRef SR) const { |
1009 | return ""; |
1010 | } |
1011 | |
1012 | |
1013 | |
1014 | |
1015 | |
1016 | |
1017 | virtual void adjust(LangOptions &Opts); |
1018 | |
1019 | |
1020 | virtual void adjustTargetOptions(const CodeGenOptions &CGOpts, |
1021 | TargetOptions &TargetOpts) const {} |
1022 | |
1023 | |
1024 | |
1025 | |
1026 | |
1027 | virtual bool initFeatureMap(llvm::StringMap<bool> &Features, |
1028 | DiagnosticsEngine &Diags, StringRef CPU, |
1029 | const std::vector<std::string> &FeatureVec) const; |
1030 | |
1031 | |
1032 | virtual StringRef getABI() const { return StringRef(); } |
1033 | |
1034 | |
1035 | TargetCXXABI getCXXABI() const { |
1036 | return TheCXXABI; |
1037 | } |
1038 | |
1039 | |
1040 | |
1041 | |
1042 | virtual bool setCPU(const std::string &Name) { |
1043 | return false; |
1044 | } |
1045 | |
1046 | |
1047 | virtual void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {} |
1048 | |
1049 | |
1050 | virtual bool isValidCPUName(StringRef Name) const { |
1051 | return true; |
1052 | } |
1053 | |
1054 | |
1055 | |
1056 | |
1057 | virtual bool setABI(const std::string &Name) { |
1058 | return false; |
1059 | } |
1060 | |
1061 | |
1062 | |
1063 | |
1064 | virtual bool setFPMath(StringRef Name) { |
1065 | return false; |
1066 | } |
1067 | |
1068 | |
1069 | |
1070 | virtual void setFeatureEnabled(llvm::StringMap<bool> &Features, |
1071 | StringRef Name, |
1072 | bool Enabled) const { |
1073 | Features[Name] = Enabled; |
1074 | } |
1075 | |
1076 | |
1077 | virtual bool isValidFeatureName(StringRef Feature) const { |
1078 | return true; |
1079 | } |
1080 | |
1081 | |
1082 | |
1083 | |
1084 | |
1085 | |
1086 | |
1087 | |
1088 | |
1089 | |
1090 | |
1091 | |
1092 | virtual bool handleTargetFeatures(std::vector<std::string> &Features, |
1093 | DiagnosticsEngine &Diags) { |
1094 | return true; |
1095 | } |
1096 | |
1097 | |
1098 | virtual bool hasFeature(StringRef Feature) const { |
1099 | return false; |
1100 | } |
1101 | |
1102 | |
1103 | |
1104 | bool supportsMultiVersioning() const { |
1105 | return getTriple().getArch() == llvm::Triple::x86 || |
1106 | getTriple().getArch() == llvm::Triple::x86_64; |
1107 | } |
1108 | |
1109 | |
1110 | bool supportsIFunc() const { return getTriple().isOSBinFormatELF(); } |
1111 | |
1112 | |
1113 | |
1114 | virtual bool validateCpuSupports(StringRef Name) const { return false; } |
1115 | |
1116 | |
1117 | |
1118 | virtual unsigned multiVersionSortPriority(StringRef Name) const { |
1119 | return 0; |
1120 | } |
1121 | |
1122 | |
1123 | |
1124 | virtual bool validateCpuIs(StringRef Name) const { return false; } |
1125 | |
1126 | |
1127 | |
1128 | virtual bool validateCPUSpecificCPUDispatch(StringRef Name) const { |
1129 | return false; |
1130 | } |
1131 | |
1132 | |
1133 | virtual char CPUSpecificManglingCharacter(StringRef Name) const { |
1134 | llvm_unreachable( |
1135 | "cpu_specific Multiversioning not implemented on this target"); |
1136 | } |
1137 | |
1138 | |
1139 | |
1140 | |
1141 | virtual void getCPUSpecificCPUDispatchFeatures( |
1142 | StringRef Name, llvm::SmallVectorImpl<StringRef> &Features) const { |
1143 | llvm_unreachable( |
1144 | "cpu_specific Multiversioning not implemented on this target"); |
1145 | } |
1146 | |
1147 | |
1148 | unsigned getRegParmMax() const { |
1149 | (0) . __assert_fail ("RegParmMax < 7 && \"RegParmMax value is larger than AST can handle\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Basic/TargetInfo.h", 1149, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(RegParmMax < 7 && "RegParmMax value is larger than AST can handle"); |
1150 | return RegParmMax; |
1151 | } |
1152 | |
1153 | |
1154 | bool isTLSSupported() const { |
1155 | return TLSSupported; |
1156 | } |
1157 | |
1158 | |
1159 | |
1160 | |
1161 | |
1162 | unsigned short getMaxTLSAlign() const { |
1163 | return MaxTLSAlign; |
1164 | } |
1165 | |
1166 | |
1167 | bool isVLASupported() const { return VLASupported; } |
1168 | |
1169 | |
1170 | bool isSEHTrySupported() const { |
1171 | return getTriple().isOSWindows() && |
1172 | (getTriple().getArch() == llvm::Triple::x86 || |
1173 | getTriple().getArch() == llvm::Triple::x86_64 || |
1174 | getTriple().getArch() == llvm::Triple::aarch64); |
1175 | } |
1176 | |
1177 | |
1178 | |
1179 | |
1180 | |
1181 | |
1182 | |
1183 | bool hasNoAsmVariants() const { |
1184 | return NoAsmVariants; |
1185 | } |
1186 | |
1187 | |
1188 | |
1189 | |
1190 | |
1191 | virtual int getEHDataRegisterNumber(unsigned RegNo) const { |
1192 | return -1; |
1193 | } |
1194 | |
1195 | |
1196 | virtual const char *getStaticInitSectionSpecifier() const { |
1197 | return nullptr; |
1198 | } |
1199 | |
1200 | const LangASMap &getAddressSpaceMap() const { return *AddrSpaceMap; } |
1201 | |
1202 | |
1203 | |
1204 | virtual LangAS getOpenCLBuiltinAddressSpace(unsigned AS) const { |
1205 | return getLangASFromTargetAS(AS); |
1206 | } |
1207 | |
1208 | |
1209 | |
1210 | virtual LangAS getCUDABuiltinAddressSpace(unsigned AS) const { |
1211 | return getLangASFromTargetAS(AS); |
1212 | } |
1213 | |
1214 | |
1215 | |
1216 | |
1217 | |
1218 | virtual llvm::Optional<LangAS> getConstantAddressSpace() const { |
1219 | return LangAS::Default; |
1220 | } |
1221 | |
1222 | |
1223 | |
1224 | StringRef getPlatformName() const { return PlatformName; } |
1225 | |
1226 | |
1227 | |
1228 | VersionTuple getPlatformMinVersion() const { return PlatformMinVersion; } |
1229 | |
1230 | bool isBigEndian() const { return BigEndian; } |
1231 | bool isLittleEndian() const { return !BigEndian; } |
1232 | |
1233 | enum CallingConvMethodType { |
1234 | CCMT_Unknown, |
1235 | CCMT_Member, |
1236 | CCMT_NonMember |
1237 | }; |
1238 | |
1239 | |
1240 | |
1241 | virtual CallingConv getDefaultCallingConv(CallingConvMethodType MT) const { |
1242 | |
1243 | |
1244 | |
1245 | return CC_C; |
1246 | } |
1247 | |
1248 | enum CallingConvCheckResult { |
1249 | CCCR_OK, |
1250 | CCCR_Warning, |
1251 | CCCR_Ignore, |
1252 | }; |
1253 | |
1254 | |
1255 | |
1256 | |
1257 | |
1258 | virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const { |
1259 | switch (CC) { |
1260 | default: |
1261 | return CCCR_Warning; |
1262 | case CC_C: |
1263 | return CCCR_OK; |
1264 | } |
1265 | } |
1266 | |
1267 | enum CallingConvKind { |
1268 | CCK_Default, |
1269 | CCK_ClangABI4OrPS4, |
1270 | CCK_MicrosoftWin64 |
1271 | }; |
1272 | |
1273 | virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const; |
1274 | |
1275 | |
1276 | |
1277 | virtual bool hasSjLjLowering() const { |
1278 | return false; |
1279 | } |
1280 | |
1281 | |
1282 | virtual bool |
1283 | checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const; |
1284 | |
1285 | |
1286 | virtual bool |
1287 | checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const; |
1288 | |
1289 | |
1290 | virtual bool allowsLargerPreferedTypeAlignment() const { return true; } |
1291 | |
1292 | |
1293 | virtual void setSupportedOpenCLOpts() {} |
1294 | |
1295 | |
1296 | virtual void setOpenCLExtensionOpts() { |
1297 | for (const auto &Ext : getTargetOpts().OpenCLExtensionsAsWritten) { |
1298 | getTargetOpts().SupportedOpenCLOptions.support(Ext); |
1299 | } |
1300 | } |
1301 | |
1302 | |
1303 | OpenCLOptions &getSupportedOpenCLOpts() { |
1304 | return getTargetOpts().SupportedOpenCLOptions; |
1305 | } |
1306 | |
1307 | |
1308 | const OpenCLOptions &getSupportedOpenCLOpts() const { |
1309 | return getTargetOpts().SupportedOpenCLOptions; |
1310 | } |
1311 | |
1312 | enum OpenCLTypeKind { |
1313 | OCLTK_Default, |
1314 | OCLTK_ClkEvent, |
1315 | OCLTK_Event, |
1316 | OCLTK_Image, |
1317 | OCLTK_Pipe, |
1318 | OCLTK_Queue, |
1319 | OCLTK_ReserveID, |
1320 | OCLTK_Sampler, |
1321 | }; |
1322 | |
1323 | |
1324 | virtual LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const; |
1325 | |
1326 | |
1327 | virtual unsigned getVtblPtrAddressSpace() const { |
1328 | return 0; |
1329 | } |
1330 | |
1331 | |
1332 | |
1333 | |
1334 | |
1335 | |
1336 | |
1337 | virtual Optional<unsigned> getDWARFAddressSpace(unsigned AddressSpace) const { |
1338 | return None; |
1339 | } |
1340 | |
1341 | |
1342 | |
1343 | const llvm::VersionTuple &getSDKVersion() const { |
1344 | return getTargetOpts().SDKVersion; |
1345 | } |
1346 | |
1347 | |
1348 | virtual bool validateTarget(DiagnosticsEngine &Diags) const { |
1349 | return true; |
1350 | } |
1351 | |
1352 | virtual void setAuxTarget(const TargetInfo *Aux) {} |
1353 | |
1354 | protected: |
1355 | |
1356 | void copyAuxTarget(const TargetInfo *Aux); |
1357 | virtual uint64_t getPointerWidthV(unsigned AddrSpace) const { |
1358 | return PointerWidth; |
1359 | } |
1360 | virtual uint64_t getPointerAlignV(unsigned AddrSpace) const { |
1361 | return PointerAlign; |
1362 | } |
1363 | virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const { |
1364 | return PtrDiffType; |
1365 | } |
1366 | virtual ArrayRef<const char *> getGCCRegNames() const = 0; |
1367 | virtual ArrayRef<GCCRegAlias> getGCCRegAliases() const = 0; |
1368 | virtual ArrayRef<AddlRegName> getGCCAddlRegNames() const { |
1369 | return None; |
1370 | } |
1371 | |
1372 | private: |
1373 | |
1374 | |
1375 | void CheckFixedPointBits() const; |
1376 | }; |
1377 | |
1378 | } |
1379 | |
1380 | #endif |
1381 | |