1 //===--- TargetInfo.h - Expose information about the target -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief Defines the clang::TargetInfo interface.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_BASIC_TARGETINFO_H
16 #define LLVM_CLANG_BASIC_TARGETINFO_H
18 #include "clang/Basic/AddressSpaces.h"
19 #include "clang/Basic/TargetCXXABI.h"
20 #include "clang/Basic/LLVM.h"
21 #include "clang/Basic/Specifiers.h"
22 #include "clang/Basic/TargetOptions.h"
23 #include "clang/Basic/VersionTuple.h"
24 #include "llvm/ADT/IntrusiveRefCntPtr.h"
25 #include "llvm/ADT/StringMap.h"
26 #include "llvm/ADT/StringRef.h"
27 #include "llvm/ADT/StringSwitch.h"
28 #include "llvm/ADT/Triple.h"
29 #include "llvm/Support/DataTypes.h"
39 class DiagnosticsEngine;
45 namespace Builtin { struct Info; }
47 /// \brief Exposes information about the current target.
49 class TargetInfo : public RefCountedBase<TargetInfo> {
50 IntrusiveRefCntPtr<TargetOptions> TargetOpts;
53 // Target values set by the ctor of the actual target implementation. Default
54 // values are specified by the TargetInfo constructor.
57 bool NoAsmVariants; // True if {|} are normal characters.
58 unsigned char PointerWidth, PointerAlign;
59 unsigned char BoolWidth, BoolAlign;
60 unsigned char IntWidth, IntAlign;
61 unsigned char HalfWidth, HalfAlign;
62 unsigned char FloatWidth, FloatAlign;
63 unsigned char DoubleWidth, DoubleAlign;
64 unsigned char LongDoubleWidth, LongDoubleAlign;
65 unsigned char LargeArrayMinWidth, LargeArrayAlign;
66 unsigned char LongWidth, LongAlign;
67 unsigned char LongLongWidth, LongLongAlign;
68 unsigned char SuitableAlign;
69 unsigned char MinGlobalAlign;
70 unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
71 unsigned short MaxVectorAlign;
72 const char *DescriptionString;
73 const char *UserLabelPrefix;
74 const char *MCountName;
75 const llvm::fltSemantics *HalfFormat, *FloatFormat, *DoubleFormat,
77 unsigned char RegParmMax, SSERegParmMax;
78 TargetCXXABI TheCXXABI;
79 const LangAS::Map *AddrSpaceMap;
81 mutable StringRef PlatformName;
82 mutable VersionTuple PlatformMinVersion;
84 unsigned HasAlignMac68kSupport : 1;
85 unsigned RealTypeUsesObjCFPRet : 3;
86 unsigned ComplexLongDoubleUsesFP2Ret : 1;
88 // TargetInfo Constructor. Default initializes all fields.
89 TargetInfo(const llvm::Triple &T);
92 /// \brief Construct a target for the given options.
94 /// \param Opts - The options to use to initialize the target. The target may
95 /// modify the options to canonicalize the target feature information to match
96 /// what the backend expects.
97 static TargetInfo* CreateTargetInfo(DiagnosticsEngine &Diags,
100 virtual ~TargetInfo();
102 /// \brief Retrieve the target options.
103 TargetOptions &getTargetOpts() const {
104 assert(TargetOpts && "Missing target options");
108 void setTargetOpts(TargetOptions *TargetOpts) {
109 this->TargetOpts = TargetOpts;
112 ///===---- Target Data Type Query Methods -------------------------------===//
134 /// \brief The different kinds of __builtin_va_list types defined by
135 /// the target implementation.
136 enum BuiltinVaListKind {
137 /// typedef char* __builtin_va_list;
138 CharPtrBuiltinVaList = 0,
140 /// typedef void* __builtin_va_list;
141 VoidPtrBuiltinVaList,
143 /// __builtin_va_list as defind by the AArch64 ABI
144 /// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055a/IHI0055A_aapcs64.pdf
145 AArch64ABIBuiltinVaList,
147 /// __builtin_va_list as defined by the PNaCl ABI:
148 /// http://www.chromium.org/nativeclient/pnacl/bitcode-abi#TOC-Machine-Types
149 PNaClABIBuiltinVaList,
151 /// __builtin_va_list as defined by the Power ABI:
152 /// https://www.power.org
153 /// /resources/downloads/Power-Arch-32-bit-ABI-supp-1.0-Embedded.pdf
154 PowerABIBuiltinVaList,
156 /// __builtin_va_list as defined by the x86-64 ABI:
157 /// http://www.x86-64.org/documentation/abi.pdf
158 X86_64ABIBuiltinVaList,
160 /// __builtin_va_list as defined by ARM AAPCS ABI
161 /// http://infocenter.arm.com
162 // /help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf
163 AAPCSABIBuiltinVaList,
165 // typedef struct __va_list_tag
169 // void *__overflow_arg_area;
170 // void *__reg_save_area;
176 IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType,
177 WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType,
180 /// \brief Whether Objective-C's built-in boolean type should be signed char.
182 /// Otherwise, when this flag is not set, the normal built-in boolean type is
184 unsigned UseSignedCharForObjCBool : 1;
186 /// Control whether the alignment of bit-field types is respected when laying
187 /// out structures. If true, then the alignment of the bit-field type will be
188 /// used to (a) impact the alignment of the containing structure, and (b)
189 /// ensure that the individual bit-field will not straddle an alignment
191 unsigned UseBitFieldTypeAlignment : 1;
193 /// \brief Whether zero length bitfields (e.g., int : 0;) force alignment of
194 /// the next bitfield.
196 /// If the alignment of the zero length bitfield is greater than the member
197 /// that follows it, `bar', `bar' will be aligned as the type of the
198 /// zero-length bitfield.
199 unsigned UseZeroLengthBitfieldAlignment : 1;
201 /// If non-zero, specifies a fixed alignment value for bitfields that follow
202 /// zero length bitfield, regardless of the zero length bitfield type.
203 unsigned ZeroLengthBitfieldBoundary;
205 /// \brief Specify if mangling based on address space map should be used or
206 /// not for language specific address spaces
207 bool UseAddrSpaceMapMangling;
210 IntType getSizeType() const { return SizeType; }
211 IntType getIntMaxType() const { return IntMaxType; }
212 IntType getUIntMaxType() const { return UIntMaxType; }
213 IntType getPtrDiffType(unsigned AddrSpace) const {
214 return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
216 IntType getIntPtrType() const { return IntPtrType; }
217 IntType getWCharType() const { return WCharType; }
218 IntType getWIntType() const { return WIntType; }
219 IntType getChar16Type() const { return Char16Type; }
220 IntType getChar32Type() const { return Char32Type; }
221 IntType getInt64Type() const { return Int64Type; }
222 IntType getSigAtomicType() const { return SigAtomicType; }
223 IntType getProcessIDType() const { return ProcessIDType; }
225 /// \brief Return the width (in bits) of the specified integer type enum.
227 /// For example, SignedInt -> getIntWidth().
228 unsigned getTypeWidth(IntType T) const;
230 /// \brief Return integer type with specified width.
231 IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const;
233 /// \brief Return floating point type with specified width.
234 RealType getRealTypeByWidth(unsigned BitWidth) const;
236 /// \brief Return the alignment (in bits) of the specified integer type enum.
238 /// For example, SignedInt -> getIntAlign().
239 unsigned getTypeAlign(IntType T) const;
241 /// \brief Returns true if the type is signed; false otherwise.
242 static bool isTypeSigned(IntType T);
244 /// \brief Return the width of pointers on this target, for the
245 /// specified address space.
246 uint64_t getPointerWidth(unsigned AddrSpace) const {
247 return AddrSpace == 0 ? PointerWidth : getPointerWidthV(AddrSpace);
249 uint64_t getPointerAlign(unsigned AddrSpace) const {
250 return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace);
253 /// \brief Return the size of '_Bool' and C++ 'bool' for this target, in bits.
254 unsigned getBoolWidth() const { return BoolWidth; }
256 /// \brief Return the alignment of '_Bool' and C++ 'bool' for this target.
257 unsigned getBoolAlign() const { return BoolAlign; }
259 unsigned getCharWidth() const { return 8; } // FIXME
260 unsigned getCharAlign() const { return 8; } // FIXME
262 /// \brief Return the size of 'signed short' and 'unsigned short' for this
264 unsigned getShortWidth() const { return 16; } // FIXME
266 /// \brief Return the alignment of 'signed short' and 'unsigned short' for
268 unsigned getShortAlign() const { return 16; } // FIXME
270 /// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for
271 /// this target, in bits.
272 unsigned getIntWidth() const { return IntWidth; }
273 unsigned getIntAlign() const { return IntAlign; }
275 /// getLongWidth/Align - Return the size of 'signed long' and 'unsigned long'
276 /// for this target, in bits.
277 unsigned getLongWidth() const { return LongWidth; }
278 unsigned getLongAlign() const { return LongAlign; }
280 /// getLongLongWidth/Align - Return the size of 'signed long long' and
281 /// 'unsigned long long' for this target, in bits.
282 unsigned getLongLongWidth() const { return LongLongWidth; }
283 unsigned getLongLongAlign() const { return LongLongAlign; }
285 /// \brief Determine whether the __int128 type is supported on this target.
286 bool hasInt128Type() const { return getPointerWidth(0) >= 64; } // FIXME
288 /// \brief Return the alignment that is suitable for storing any
289 /// object with a fundamental alignment requirement.
290 unsigned getSuitableAlign() const { return SuitableAlign; }
292 /// getMinGlobalAlign - Return the minimum alignment of a global variable,
293 /// unless its alignment is explicitly reduced via attributes.
294 unsigned getMinGlobalAlign() const { return MinGlobalAlign; }
296 /// getWCharWidth/Align - Return the size of 'wchar_t' for this target, in
298 unsigned getWCharWidth() const { return getTypeWidth(WCharType); }
299 unsigned getWCharAlign() const { return getTypeAlign(WCharType); }
301 /// getChar16Width/Align - Return the size of 'char16_t' for this target, in
303 unsigned getChar16Width() const { return getTypeWidth(Char16Type); }
304 unsigned getChar16Align() const { return getTypeAlign(Char16Type); }
306 /// getChar32Width/Align - Return the size of 'char32_t' for this target, in
308 unsigned getChar32Width() const { return getTypeWidth(Char32Type); }
309 unsigned getChar32Align() const { return getTypeAlign(Char32Type); }
311 /// getHalfWidth/Align/Format - Return the size/align/format of 'half'.
312 unsigned getHalfWidth() const { return HalfWidth; }
313 unsigned getHalfAlign() const { return HalfAlign; }
314 const llvm::fltSemantics &getHalfFormat() const { return *HalfFormat; }
316 /// getFloatWidth/Align/Format - Return the size/align/format of 'float'.
317 unsigned getFloatWidth() const { return FloatWidth; }
318 unsigned getFloatAlign() const { return FloatAlign; }
319 const llvm::fltSemantics &getFloatFormat() const { return *FloatFormat; }
321 /// getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
322 unsigned getDoubleWidth() const { return DoubleWidth; }
323 unsigned getDoubleAlign() const { return DoubleAlign; }
324 const llvm::fltSemantics &getDoubleFormat() const { return *DoubleFormat; }
326 /// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long
328 unsigned getLongDoubleWidth() const { return LongDoubleWidth; }
329 unsigned getLongDoubleAlign() const { return LongDoubleAlign; }
330 const llvm::fltSemantics &getLongDoubleFormat() const {
331 return *LongDoubleFormat;
334 /// \brief Return the value for the C99 FLT_EVAL_METHOD macro.
335 virtual unsigned getFloatEvalMethod() const { return 0; }
337 // getLargeArrayMinWidth/Align - Return the minimum array size that is
338 // 'large' and its alignment.
339 unsigned getLargeArrayMinWidth() const { return LargeArrayMinWidth; }
340 unsigned getLargeArrayAlign() const { return LargeArrayAlign; }
342 /// \brief Return the maximum width lock-free atomic operation which will
343 /// ever be supported for the given target
344 unsigned getMaxAtomicPromoteWidth() const { return MaxAtomicPromoteWidth; }
345 /// \brief Return the maximum width lock-free atomic operation which can be
346 /// inlined given the supported features of the given target.
347 unsigned getMaxAtomicInlineWidth() const { return MaxAtomicInlineWidth; }
349 /// \brief Return the maximum vector alignment supported for the given target.
350 unsigned getMaxVectorAlign() const { return MaxVectorAlign; }
352 /// \brief Return the size of intmax_t and uintmax_t for this target, in bits.
353 unsigned getIntMaxTWidth() const {
354 return getTypeWidth(IntMaxType);
357 // Return the size of unwind_word for this target.
358 unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
360 /// \brief Return the "preferred" register width on this target.
361 unsigned getRegisterWidth() const {
362 // Currently we assume the register width on the target matches the pointer
363 // width, we can introduce a new variable for this if/when some target wants
368 /// \brief Returns the default value of the __USER_LABEL_PREFIX__ macro,
369 /// which is the prefix given to user symbols by default.
371 /// On most platforms this is "_", but it is "" on some, and "." on others.
372 const char *getUserLabelPrefix() const {
373 return UserLabelPrefix;
376 /// \brief Returns the name of the mcount instrumentation function.
377 const char *getMCountName() const {
381 /// \brief Check if the Objective-C built-in boolean type should be signed
384 /// Otherwise, if this returns false, the normal built-in boolean type
385 /// should also be used for Objective-C.
386 bool useSignedCharForObjCBool() const {
387 return UseSignedCharForObjCBool;
389 void noSignedCharForObjCBool() {
390 UseSignedCharForObjCBool = false;
393 /// \brief Check whether the alignment of bit-field types is respected
394 /// when laying out structures.
395 bool useBitFieldTypeAlignment() const {
396 return UseBitFieldTypeAlignment;
399 /// \brief Check whether zero length bitfields should force alignment of
401 bool useZeroLengthBitfieldAlignment() const {
402 return UseZeroLengthBitfieldAlignment;
405 /// \brief Get the fixed alignment value in bits for a member that follows
406 /// a zero length bitfield.
407 unsigned getZeroLengthBitfieldBoundary() const {
408 return ZeroLengthBitfieldBoundary;
411 /// \brief Check whether this target support '\#pragma options align=mac68k'.
412 bool hasAlignMac68kSupport() const {
413 return HasAlignMac68kSupport;
416 /// \brief Return the user string for the specified integer type enum.
418 /// For example, SignedShort -> "short".
419 static const char *getTypeName(IntType T);
421 /// \brief Return the constant suffix for the specified integer type enum.
423 /// For example, SignedLong -> "L".
424 static const char *getTypeConstantSuffix(IntType T);
426 /// \brief Check whether the given real type should use the "fpret" flavor of
427 /// Objective-C message passing on this target.
428 bool useObjCFPRetForRealType(RealType T) const {
429 return RealTypeUsesObjCFPRet & (1 << T);
432 /// \brief Check whether _Complex long double should use the "fp2ret" flavor
433 /// of Objective-C message passing on this target.
434 bool useObjCFP2RetForComplexLongDouble() const {
435 return ComplexLongDoubleUsesFP2Ret;
438 /// \brief Specify if mangling based on address space map should be used or
439 /// not for language specific address spaces
440 bool useAddressSpaceMapMangling() const {
441 return UseAddrSpaceMapMangling;
444 ///===---- Other target property query methods --------------------------===//
446 /// \brief Appends the target-specific \#define values for this
447 /// target set to the specified buffer.
448 virtual void getTargetDefines(const LangOptions &Opts,
449 MacroBuilder &Builder) const = 0;
452 /// Return information about target-specific builtins for
453 /// the current primary target, and info about which builtins are non-portable
454 /// across the current set of primary and secondary targets.
455 virtual void getTargetBuiltins(const Builtin::Info *&Records,
456 unsigned &NumRecords) const = 0;
458 /// The __builtin_clz* and __builtin_ctz* built-in
459 /// functions are specified to have undefined results for zero inputs, but
460 /// on targets that support these operations in a way that provides
461 /// well-defined results for zero without loss of performance, it is a good
462 /// idea to avoid optimizing based on that undef behavior.
463 virtual bool isCLZForZeroUndef() const { return true; }
465 /// \brief Returns the kind of __builtin_va_list type that should be used
466 /// with this target.
467 virtual BuiltinVaListKind getBuiltinVaListKind() const = 0;
469 /// \brief Returns whether the passed in string is a valid clobber in an
470 /// inline asm statement.
472 /// This is used by Sema.
473 bool isValidClobber(StringRef Name) const;
475 /// \brief Returns whether the passed in string is a valid register name
476 /// according to GCC.
478 /// This is used by Sema for inline asm statements.
479 bool isValidGCCRegisterName(StringRef Name) const;
481 /// \brief Returns the "normalized" GCC register name.
483 /// For example, on x86 it will return "ax" when "eax" is passed in.
484 StringRef getNormalizedGCCRegisterName(StringRef Name) const;
486 struct ConstraintInfo {
489 CI_AllowsMemory = 0x01,
490 CI_AllowsRegister = 0x02,
491 CI_ReadWrite = 0x04, // "+r" output constraint (read and write).
492 CI_HasMatchingInput = 0x08 // This output operand has a matching input.
497 std::string ConstraintStr; // constraint: "=rm"
498 std::string Name; // Operand name: [foo] with no []'s.
500 ConstraintInfo(StringRef ConstraintStr, StringRef Name)
501 : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
504 const std::string &getConstraintStr() const { return ConstraintStr; }
505 const std::string &getName() const { return Name; }
506 bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; }
507 bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; }
508 bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; }
510 /// \brief Return true if this output operand has a matching
511 /// (tied) input operand.
512 bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; }
514 /// \brief Return true if this input operand is a matching
515 /// constraint that ties it to an output operand.
517 /// If this returns true then getTiedOperand will indicate which output
518 /// operand this is tied to.
519 bool hasTiedOperand() const { return TiedOperand != -1; }
520 unsigned getTiedOperand() const {
521 assert(hasTiedOperand() && "Has no tied operand!");
522 return (unsigned)TiedOperand;
525 void setIsReadWrite() { Flags |= CI_ReadWrite; }
526 void setAllowsMemory() { Flags |= CI_AllowsMemory; }
527 void setAllowsRegister() { Flags |= CI_AllowsRegister; }
528 void setHasMatchingInput() { Flags |= CI_HasMatchingInput; }
530 /// \brief Indicate that this is an input operand that is tied to
531 /// the specified output operand.
533 /// Copy over the various constraint information from the output.
534 void setTiedOperand(unsigned N, ConstraintInfo &Output) {
535 Output.setHasMatchingInput();
536 Flags = Output.Flags;
538 // Don't copy Name or constraint string.
542 // validateOutputConstraint, validateInputConstraint - Checks that
543 // a constraint is valid and provides information about it.
544 // FIXME: These should return a real error instead of just true/false.
545 bool validateOutputConstraint(ConstraintInfo &Info) const;
546 bool validateInputConstraint(ConstraintInfo *OutputConstraints,
548 ConstraintInfo &info) const;
549 virtual bool validateInputSize(StringRef /*Constraint*/,
550 unsigned /*Size*/) const {
553 virtual bool validateConstraintModifier(StringRef /*Constraint*/,
554 const char /*Modifier*/,
555 unsigned /*Size*/) const {
558 bool resolveSymbolicName(const char *&Name,
559 ConstraintInfo *OutputConstraints,
560 unsigned NumOutputs, unsigned &Index) const;
562 // Constraint parm will be left pointing at the last character of
563 // the constraint. In practice, it won't be changed unless the
564 // constraint is longer than one character.
565 virtual std::string convertConstraint(const char *&Constraint) const {
566 // 'p' defaults to 'r', but can be overridden by targets.
567 if (*Constraint == 'p')
568 return std::string("r");
569 return std::string(1, *Constraint);
572 /// \brief Returns a string of target-specific clobbers, in LLVM format.
573 virtual const char *getClobbers() const = 0;
576 /// \brief Returns the target triple of the primary target.
577 const llvm::Triple &getTriple() const {
581 const char *getTargetDescription() const {
582 return DescriptionString;
586 const char * const Aliases[5];
587 const char * const Register;
591 const char * const Names[5];
592 const unsigned RegNum;
595 /// \brief Does this target support "protected" visibility?
597 /// Any target which dynamic libraries will naturally support
598 /// something like "default" (meaning that the symbol is visible
599 /// outside this shared object) and "hidden" (meaning that it isn't)
600 /// visibilities, but "protected" is really an ELF-specific concept
601 /// with weird semantics designed around the convenience of dynamic
602 /// linker implementations. Which is not to suggest that there's
603 /// consistent target-independent semantics for "default" visibility
604 /// either; the entire thing is pretty badly mangled.
605 virtual bool hasProtectedVisibility() const { return true; }
607 /// \brief Return the section to use for CFString literals, or 0 if no
608 /// special section is used.
609 virtual const char *getCFStringSection() const {
610 return "__DATA,__cfstring";
613 /// \brief Return the section to use for NSString literals, or 0 if no
614 /// special section is used.
615 virtual const char *getNSStringSection() const {
616 return "__OBJC,__cstring_object,regular,no_dead_strip";
619 /// \brief Return the section to use for NSString literals, or 0 if no
620 /// special section is used (NonFragile ABI).
621 virtual const char *getNSStringNonFragileABISection() const {
622 return "__DATA, __objc_stringobj, regular, no_dead_strip";
625 /// \brief An optional hook that targets can implement to perform semantic
626 /// checking on attribute((section("foo"))) specifiers.
628 /// In this case, "foo" is passed in to be checked. If the section
629 /// specifier is invalid, the backend should return a non-empty string
630 /// that indicates the problem.
632 /// This hook is a simple quality of implementation feature to catch errors
633 /// and give good diagnostics in cases when the assembler or code generator
634 /// would otherwise reject the section specifier.
636 virtual std::string isValidSectionSpecifier(StringRef SR) const {
640 /// \brief Set forced language options.
642 /// Apply changes to the target information with respect to certain
643 /// language options which change the target configuration.
644 virtual void setForcedLangOptions(LangOptions &Opts);
646 /// \brief Get the default set of target features for the CPU;
647 /// this should include all legal feature strings on the target.
648 virtual void getDefaultFeatures(llvm::StringMap<bool> &Features) const {
651 /// \brief Get the ABI currently in use.
652 virtual const char *getABI() const {
656 /// \brief Get the C++ ABI currently in use.
657 TargetCXXABI getCXXABI() const {
661 /// \brief Target the specified CPU.
663 /// \return False on error (invalid CPU name).
664 virtual bool setCPU(const std::string &Name) {
668 /// \brief Use the specified ABI.
670 /// \return False on error (invalid ABI name).
671 virtual bool setABI(const std::string &Name) {
675 /// \brief Use the specified unit for FP math.
677 /// \return False on error (invalid unit name).
678 virtual bool setFPMath(StringRef Name) {
682 /// \brief Use this specified C++ ABI.
684 /// \return False on error (invalid C++ ABI name).
685 bool setCXXABI(llvm::StringRef name) {
687 if (!ABI.tryParse(name)) return false;
688 return setCXXABI(ABI);
691 /// \brief Set the C++ ABI to be used by this implementation.
693 /// \return False on error (ABI not valid on this target)
694 virtual bool setCXXABI(TargetCXXABI ABI) {
699 /// \brief Enable or disable a specific target feature;
700 /// the feature name must be valid.
701 virtual void setFeatureEnabled(llvm::StringMap<bool> &Features,
703 bool Enabled) const {
704 Features[Name] = Enabled;
707 /// \brief Perform initialization based on the user configured
708 /// set of features (e.g., +sse4).
710 /// The list is guaranteed to have at most one entry per feature.
712 /// The target may modify the features list, to change which options are
713 /// passed onwards to the backend.
715 /// \return False on error.
716 virtual bool handleTargetFeatures(std::vector<std::string> &Features,
717 DiagnosticsEngine &Diags) {
721 /// \brief Determine whether the given target has the given feature.
722 virtual bool hasFeature(StringRef Feature) const {
726 // \brief Returns maximal number of args passed in registers.
727 unsigned getRegParmMax() const {
728 assert(RegParmMax < 7 && "RegParmMax value is larger than AST can handle");
732 /// \brief Whether the target supports thread-local storage.
733 bool isTLSSupported() const {
737 /// \brief Return true if {|} are normal characters in the asm string.
739 /// If this returns false (the default), then {abc|xyz} is syntax
740 /// that says that when compiling for asm variant #0, "abc" should be
741 /// generated, but when compiling for asm variant #1, "xyz" should be
743 bool hasNoAsmVariants() const {
744 return NoAsmVariants;
747 /// \brief Return the register number that __builtin_eh_return_regno would
748 /// return with the specified argument.
749 virtual int getEHDataRegisterNumber(unsigned RegNo) const {
753 /// \brief Return the section to use for C++ static initialization functions.
754 virtual const char *getStaticInitSectionSpecifier() const {
758 const LangAS::Map &getAddressSpaceMap() const {
759 return *AddrSpaceMap;
762 /// \brief Retrieve the name of the platform as it is used in the
763 /// availability attribute.
764 StringRef getPlatformName() const { return PlatformName; }
766 /// \brief Retrieve the minimum desired version of the platform, to
767 /// which the program should be compiled.
768 VersionTuple getPlatformMinVersion() const { return PlatformMinVersion; }
770 bool isBigEndian() const { return BigEndian; }
772 enum CallingConvMethodType {
778 /// \brief Gets the default calling convention for the given target and
779 /// declaration context.
780 virtual CallingConv getDefaultCallingConv(CallingConvMethodType MT) const {
781 // Not all targets will specify an explicit calling convention that we can
782 // express. This will always do the right thing, even though it's not
783 // an explicit calling convention.
787 enum CallingConvCheckResult {
792 /// \brief Determines whether a given calling convention is valid for the
793 /// target. A calling convention can either be accepted, produce a warning
794 /// and be substituted with the default calling convention, or (someday)
795 /// produce an error (such as using thiscall on a non-instance function).
796 virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const {
806 virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
809 virtual uint64_t getPointerAlignV(unsigned AddrSpace) const {
812 virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const {
815 virtual void getGCCRegNames(const char * const *&Names,
816 unsigned &NumNames) const = 0;
817 virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
818 unsigned &NumAliases) const = 0;
819 virtual void getGCCAddlRegNames(const AddlRegName *&Addl,
820 unsigned &NumAddl) const {
824 virtual bool validateAsmConstraint(const char *&Name,
825 TargetInfo::ConstraintInfo &info) const= 0;
828 } // end namespace clang