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/LLVM.h"
19 #include "llvm/ADT/IntrusiveRefCntPtr.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/ADT/StringSwitch.h"
23 #include "llvm/ADT/Triple.h"
24 #include "llvm/Support/DataTypes.h"
25 #include "clang/Basic/AddressSpaces.h"
26 #include "clang/Basic/TargetOptions.h"
27 #include "clang/Basic/VersionTuple.h"
28 #include "clang/Basic/Specifiers.h"
38 class DiagnosticsEngine;
44 namespace Builtin { struct Info; }
46 /// \brief The types of C++ ABIs for which we can generate code.
48 /// The generic ("Itanium") C++ ABI, documented at:
49 /// http://www.codesourcery.com/public/cxx-abi/
52 /// The ARM C++ ABI, based largely on the Itanium ABI but with
53 /// significant differences.
54 /// http://infocenter.arm.com
55 /// /help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf
58 /// The Visual Studio ABI. Only scattered official documentation exists.
62 /// \brief Exposes information about the current target.
64 class TargetInfo : public RefCountedBase<TargetInfo> {
65 llvm::IntrusiveRefCntPtr<TargetOptions> TargetOpts;
68 // Target values set by the ctor of the actual target implementation. Default
69 // values are specified by the TargetInfo constructor.
72 bool NoAsmVariants; // True if {|} are normal characters.
73 unsigned char PointerWidth, PointerAlign;
74 unsigned char BoolWidth, BoolAlign;
75 unsigned char IntWidth, IntAlign;
76 unsigned char HalfWidth, HalfAlign;
77 unsigned char FloatWidth, FloatAlign;
78 unsigned char DoubleWidth, DoubleAlign;
79 unsigned char LongDoubleWidth, LongDoubleAlign;
80 unsigned char LargeArrayMinWidth, LargeArrayAlign;
81 unsigned char LongWidth, LongAlign;
82 unsigned char LongLongWidth, LongLongAlign;
83 unsigned char SuitableAlign;
84 unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
85 unsigned short MaxVectorAlign;
86 const char *DescriptionString;
87 const char *UserLabelPrefix;
88 const char *MCountName;
89 const llvm::fltSemantics *HalfFormat, *FloatFormat, *DoubleFormat,
91 unsigned char RegParmMax, SSERegParmMax;
93 const LangAS::Map *AddrSpaceMap;
95 mutable StringRef PlatformName;
96 mutable VersionTuple PlatformMinVersion;
98 unsigned HasAlignMac68kSupport : 1;
99 unsigned RealTypeUsesObjCFPRet : 3;
100 unsigned ComplexLongDoubleUsesFP2Ret : 1;
102 // TargetInfo Constructor. Default initializes all fields.
103 TargetInfo(const std::string &T);
106 /// \brief Construct a target for the given options.
108 /// \param Opts - The options to use to initialize the target. The target may
109 /// modify the options to canonicalize the target feature information to match
110 /// what the backend expects.
111 static TargetInfo* CreateTargetInfo(DiagnosticsEngine &Diags,
112 TargetOptions &Opts);
114 virtual ~TargetInfo();
116 /// \brief Retrieve the target options.
117 TargetOptions &getTargetOpts() const {
118 assert(TargetOpts && "Missing target options");
122 void setTargetOpts(TargetOptions &TargetOpts) {
123 this->TargetOpts = &TargetOpts;
126 ///===---- Target Data Type Query Methods -------------------------------===//
145 /// \brief The different kinds of __builtin_va_list types defined by
146 /// the target implementation.
147 enum BuiltinVaListKind {
148 /// typedef char* __builtin_va_list;
149 CharPtrBuiltinVaList = 0,
151 /// typedef void* __builtin_va_list;
152 VoidPtrBuiltinVaList,
154 /// __builtin_va_list as defined by the PNaCl ABI:
155 /// http://www.chromium.org/nativeclient/pnacl/bitcode-abi#TOC-Machine-Types
156 PNaClABIBuiltinVaList,
158 /// __builtin_va_list as defined by the Power ABI:
159 /// https://www.power.org
160 /// /resources/downloads/Power-Arch-32-bit-ABI-supp-1.0-Embedded.pdf
161 PowerABIBuiltinVaList,
163 /// __builtin_va_list as defined by the x86-64 ABI:
164 /// http://www.x86-64.org/documentation/abi.pdf
165 X86_64ABIBuiltinVaList,
167 /// __builtin_va_list as defined by ARM AAPCS ABI
168 /// http://infocenter.arm.com
169 // /help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf
170 AAPCSABIBuiltinVaList
174 IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType,
175 WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType,
178 /// \brief Whether Objective-C's built-in boolean type should be signed char.
180 /// Otherwise, when this flag is not set, the normal built-in boolean type is
182 unsigned UseSignedCharForObjCBool : 1;
184 /// Control whether the alignment of bit-field types is respected when laying
185 /// out structures. If true, then the alignment of the bit-field type will be
186 /// used to (a) impact the alignment of the containing structure, and (b)
187 /// ensure that the individual bit-field will not straddle an alignment
189 unsigned UseBitFieldTypeAlignment : 1;
191 /// \brief Whether zero length bitfields (e.g., int : 0;) force alignment of
192 /// the next bitfield.
194 /// If the alignment of the zero length bitfield is greater than the member
195 /// that follows it, `bar', `bar' will be aligned as the type of the
196 /// zero-length bitfield.
197 unsigned UseZeroLengthBitfieldAlignment : 1;
199 /// If non-zero, specifies a fixed alignment value for bitfields that follow
200 /// zero length bitfield, regardless of the zero length bitfield type.
201 unsigned ZeroLengthBitfieldBoundary;
204 IntType getSizeType() const { return SizeType; }
205 IntType getIntMaxType() const { return IntMaxType; }
206 IntType getUIntMaxType() const { return UIntMaxType; }
207 IntType getPtrDiffType(unsigned AddrSpace) const {
208 return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
210 IntType getIntPtrType() const { return IntPtrType; }
211 IntType getWCharType() const { return WCharType; }
212 IntType getWIntType() const { return WIntType; }
213 IntType getChar16Type() const { return Char16Type; }
214 IntType getChar32Type() const { return Char32Type; }
215 IntType getInt64Type() const { return Int64Type; }
216 IntType getSigAtomicType() const { return SigAtomicType; }
217 IntType getProcessIDType() const { return ProcessIDType; }
219 /// \brief Return the width (in bits) of the specified integer type enum.
221 /// For example, SignedInt -> getIntWidth().
222 unsigned getTypeWidth(IntType T) const;
224 /// \brief Return the alignment (in bits) of the specified integer type enum.
226 /// For example, SignedInt -> getIntAlign().
227 unsigned getTypeAlign(IntType T) const;
229 /// \brief Returns true if the type is signed; false otherwise.
230 static bool isTypeSigned(IntType T);
232 /// \brief Return the width of pointers on this target, for the
233 /// specified address space.
234 uint64_t getPointerWidth(unsigned AddrSpace) const {
235 return AddrSpace == 0 ? PointerWidth : getPointerWidthV(AddrSpace);
237 uint64_t getPointerAlign(unsigned AddrSpace) const {
238 return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace);
241 /// \brief Return the size of '_Bool' and C++ 'bool' for this target, in bits.
242 unsigned getBoolWidth() const { return BoolWidth; }
244 /// \brief Return the alignment of '_Bool' and C++ 'bool' for this target.
245 unsigned getBoolAlign() const { return BoolAlign; }
247 unsigned getCharWidth() const { return 8; } // FIXME
248 unsigned getCharAlign() const { return 8; } // FIXME
250 /// \brief Return the size of 'signed short' and 'unsigned short' for this
252 unsigned getShortWidth() const { return 16; } // FIXME
254 /// \brief Return the alignment of 'signed short' and 'unsigned short' for
256 unsigned getShortAlign() const { return 16; } // FIXME
258 /// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for
259 /// this target, in bits.
260 unsigned getIntWidth() const { return IntWidth; }
261 unsigned getIntAlign() const { return IntAlign; }
263 /// getLongWidth/Align - Return the size of 'signed long' and 'unsigned long'
264 /// for this target, in bits.
265 unsigned getLongWidth() const { return LongWidth; }
266 unsigned getLongAlign() const { return LongAlign; }
268 /// getLongLongWidth/Align - Return the size of 'signed long long' and
269 /// 'unsigned long long' for this target, in bits.
270 unsigned getLongLongWidth() const { return LongLongWidth; }
271 unsigned getLongLongAlign() const { return LongLongAlign; }
273 /// \brief Return the alignment that is suitable for storing any
274 /// object with a fundamental alignment requirement.
275 unsigned getSuitableAlign() const { return SuitableAlign; }
277 /// getWCharWidth/Align - Return the size of 'wchar_t' for this target, in
279 unsigned getWCharWidth() const { return getTypeWidth(WCharType); }
280 unsigned getWCharAlign() const { return getTypeAlign(WCharType); }
282 /// getChar16Width/Align - Return the size of 'char16_t' for this target, in
284 unsigned getChar16Width() const { return getTypeWidth(Char16Type); }
285 unsigned getChar16Align() const { return getTypeAlign(Char16Type); }
287 /// getChar32Width/Align - Return the size of 'char32_t' for this target, in
289 unsigned getChar32Width() const { return getTypeWidth(Char32Type); }
290 unsigned getChar32Align() const { return getTypeAlign(Char32Type); }
292 /// getHalfWidth/Align/Format - Return the size/align/format of 'half'.
293 unsigned getHalfWidth() const { return HalfWidth; }
294 unsigned getHalfAlign() const { return HalfAlign; }
295 const llvm::fltSemantics &getHalfFormat() const { return *HalfFormat; }
297 /// getFloatWidth/Align/Format - Return the size/align/format of 'float'.
298 unsigned getFloatWidth() const { return FloatWidth; }
299 unsigned getFloatAlign() const { return FloatAlign; }
300 const llvm::fltSemantics &getFloatFormat() const { return *FloatFormat; }
302 /// getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
303 unsigned getDoubleWidth() const { return DoubleWidth; }
304 unsigned getDoubleAlign() const { return DoubleAlign; }
305 const llvm::fltSemantics &getDoubleFormat() const { return *DoubleFormat; }
307 /// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long
309 unsigned getLongDoubleWidth() const { return LongDoubleWidth; }
310 unsigned getLongDoubleAlign() const { return LongDoubleAlign; }
311 const llvm::fltSemantics &getLongDoubleFormat() const {
312 return *LongDoubleFormat;
315 /// \brief Return the value for the C99 FLT_EVAL_METHOD macro.
316 virtual unsigned getFloatEvalMethod() const { return 0; }
318 // getLargeArrayMinWidth/Align - Return the minimum array size that is
319 // 'large' and its alignment.
320 unsigned getLargeArrayMinWidth() const { return LargeArrayMinWidth; }
321 unsigned getLargeArrayAlign() const { return LargeArrayAlign; }
323 /// \brief Return the maximum width lock-free atomic operation which will
324 /// ever be supported for the given target
325 unsigned getMaxAtomicPromoteWidth() const { return MaxAtomicPromoteWidth; }
326 /// \brief Return the maximum width lock-free atomic operation which can be
327 /// inlined given the supported features of the given target.
328 unsigned getMaxAtomicInlineWidth() const { return MaxAtomicInlineWidth; }
330 /// \brief Return the maximum vector alignment supported for the given target.
331 unsigned getMaxVectorAlign() const { return MaxVectorAlign; }
333 /// \brief Return the size of intmax_t and uintmax_t for this target, in bits.
334 unsigned getIntMaxTWidth() const {
335 return getTypeWidth(IntMaxType);
338 /// \brief Return the "preferred" register width on this target.
339 uint64_t getRegisterWidth() const {
340 // Currently we assume the register width on the target matches the pointer
341 // width, we can introduce a new variable for this if/when some target wants
346 /// \brief Returns the default value of the __USER_LABEL_PREFIX__ macro,
347 /// which is the prefix given to user symbols by default.
349 /// On most platforms this is "_", but it is "" on some, and "." on others.
350 const char *getUserLabelPrefix() const {
351 return UserLabelPrefix;
354 /// \brief Returns the name of the mcount instrumentation function.
355 const char *getMCountName() const {
359 /// \brief Check if the Objective-C built-in boolean type should be signed
362 /// Otherwise, if this returns false, the normal built-in boolean type
363 /// should also be used for Objective-C.
364 bool useSignedCharForObjCBool() const {
365 return UseSignedCharForObjCBool;
367 void noSignedCharForObjCBool() {
368 UseSignedCharForObjCBool = false;
371 /// \brief Check whether the alignment of bit-field types is respected
372 /// when laying out structures.
373 bool useBitFieldTypeAlignment() const {
374 return UseBitFieldTypeAlignment;
377 /// \brief Check whether zero length bitfields should force alignment of
379 bool useZeroLengthBitfieldAlignment() const {
380 return UseZeroLengthBitfieldAlignment;
383 /// \brief Get the fixed alignment value in bits for a member that follows
384 /// a zero length bitfield.
385 unsigned getZeroLengthBitfieldBoundary() const {
386 return ZeroLengthBitfieldBoundary;
389 /// \brief Check whether this target support '\#pragma options align=mac68k'.
390 bool hasAlignMac68kSupport() const {
391 return HasAlignMac68kSupport;
394 /// \brief Return the user string for the specified integer type enum.
396 /// For example, SignedShort -> "short".
397 static const char *getTypeName(IntType T);
399 /// \brief Return the constant suffix for the specified integer type enum.
401 /// For example, SignedLong -> "L".
402 static const char *getTypeConstantSuffix(IntType T);
404 /// \brief Check whether the given real type should use the "fpret" flavor of
405 /// Objective-C message passing on this target.
406 bool useObjCFPRetForRealType(RealType T) const {
407 return RealTypeUsesObjCFPRet & (1 << T);
410 /// \brief Check whether _Complex long double should use the "fp2ret" flavor
411 /// of Objective-C message passing on this target.
412 bool useObjCFP2RetForComplexLongDouble() const {
413 return ComplexLongDoubleUsesFP2Ret;
416 ///===---- Other target property query methods --------------------------===//
418 /// \brief Appends the target-specific \#define values for this
419 /// target set to the specified buffer.
420 virtual void getTargetDefines(const LangOptions &Opts,
421 MacroBuilder &Builder) const = 0;
424 /// Return information about target-specific builtins for
425 /// the current primary target, and info about which builtins are non-portable
426 /// across the current set of primary and secondary targets.
427 virtual void getTargetBuiltins(const Builtin::Info *&Records,
428 unsigned &NumRecords) const = 0;
430 /// The __builtin_clz* and __builtin_ctz* built-in
431 /// functions are specified to have undefined results for zero inputs, but
432 /// on targets that support these operations in a way that provides
433 /// well-defined results for zero without loss of performance, it is a good
434 /// idea to avoid optimizing based on that undef behavior.
435 virtual bool isCLZForZeroUndef() const { return true; }
437 /// \brief Returns the kind of __builtin_va_list type that should be used
438 /// with this target.
439 virtual BuiltinVaListKind getBuiltinVaListKind() const = 0;
441 /// \brief Returns whether the passed in string is a valid clobber in an
442 /// inline asm statement.
444 /// This is used by Sema.
445 bool isValidClobber(StringRef Name) const;
447 /// \brief Returns whether the passed in string is a valid register name
448 /// according to GCC.
450 /// This is used by Sema for inline asm statements.
451 bool isValidGCCRegisterName(StringRef Name) const;
453 /// \brief Returns the "normalized" GCC register name.
455 /// For example, on x86 it will return "ax" when "eax" is passed in.
456 StringRef getNormalizedGCCRegisterName(StringRef Name) const;
458 struct ConstraintInfo {
461 CI_AllowsMemory = 0x01,
462 CI_AllowsRegister = 0x02,
463 CI_ReadWrite = 0x04, // "+r" output constraint (read and write).
464 CI_HasMatchingInput = 0x08 // This output operand has a matching input.
469 std::string ConstraintStr; // constraint: "=rm"
470 std::string Name; // Operand name: [foo] with no []'s.
472 ConstraintInfo(StringRef ConstraintStr, StringRef Name)
473 : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
476 const std::string &getConstraintStr() const { return ConstraintStr; }
477 const std::string &getName() const { return Name; }
478 bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; }
479 bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; }
480 bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; }
482 /// \brief Return true if this output operand has a matching
483 /// (tied) input operand.
484 bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; }
486 /// \brief Return true if this input operand is a matching
487 /// constraint that ties it to an output operand.
489 /// If this returns true then getTiedOperand will indicate which output
490 /// operand this is tied to.
491 bool hasTiedOperand() const { return TiedOperand != -1; }
492 unsigned getTiedOperand() const {
493 assert(hasTiedOperand() && "Has no tied operand!");
494 return (unsigned)TiedOperand;
497 void setIsReadWrite() { Flags |= CI_ReadWrite; }
498 void setAllowsMemory() { Flags |= CI_AllowsMemory; }
499 void setAllowsRegister() { Flags |= CI_AllowsRegister; }
500 void setHasMatchingInput() { Flags |= CI_HasMatchingInput; }
502 /// \brief Indicate that this is an input operand that is tied to
503 /// the specified output operand.
505 /// Copy over the various constraint information from the output.
506 void setTiedOperand(unsigned N, ConstraintInfo &Output) {
507 Output.setHasMatchingInput();
508 Flags = Output.Flags;
510 // Don't copy Name or constraint string.
514 // validateOutputConstraint, validateInputConstraint - Checks that
515 // a constraint is valid and provides information about it.
516 // FIXME: These should return a real error instead of just true/false.
517 bool validateOutputConstraint(ConstraintInfo &Info) const;
518 bool validateInputConstraint(ConstraintInfo *OutputConstraints,
520 ConstraintInfo &info) const;
521 virtual bool validateConstraintModifier(StringRef /*Constraint*/,
522 const char /*Modifier*/,
523 unsigned /*Size*/) const {
526 bool resolveSymbolicName(const char *&Name,
527 ConstraintInfo *OutputConstraints,
528 unsigned NumOutputs, unsigned &Index) const;
530 // Constraint parm will be left pointing at the last character of
531 // the constraint. In practice, it won't be changed unless the
532 // constraint is longer than one character.
533 virtual std::string convertConstraint(const char *&Constraint) const {
534 // 'p' defaults to 'r', but can be overridden by targets.
535 if (*Constraint == 'p')
536 return std::string("r");
537 return std::string(1, *Constraint);
540 /// \brief Returns a string of target-specific clobbers, in LLVM format.
541 virtual const char *getClobbers() const = 0;
544 /// \brief Returns the target triple of the primary target.
545 const llvm::Triple &getTriple() const {
549 const char *getTargetDescription() const {
550 return DescriptionString;
554 const char * const Aliases[5];
555 const char * const Register;
559 const char * const Names[5];
560 const unsigned RegNum;
563 /// \brief Does this target support "protected" visibility?
565 /// Any target which dynamic libraries will naturally support
566 /// something like "default" (meaning that the symbol is visible
567 /// outside this shared object) and "hidden" (meaning that it isn't)
568 /// visibilities, but "protected" is really an ELF-specific concept
569 /// with weird semantics designed around the convenience of dynamic
570 /// linker implementations. Which is not to suggest that there's
571 /// consistent target-independent semantics for "default" visibility
572 /// either; the entire thing is pretty badly mangled.
573 virtual bool hasProtectedVisibility() const { return true; }
575 virtual bool useGlobalsForAutomaticVariables() const { return false; }
577 /// \brief Return the section to use for CFString literals, or 0 if no
578 /// special section is used.
579 virtual const char *getCFStringSection() const {
580 return "__DATA,__cfstring";
583 /// \brief Return the section to use for NSString literals, or 0 if no
584 /// special section is used.
585 virtual const char *getNSStringSection() const {
586 return "__OBJC,__cstring_object,regular,no_dead_strip";
589 /// \brief Return the section to use for NSString literals, or 0 if no
590 /// special section is used (NonFragile ABI).
591 virtual const char *getNSStringNonFragileABISection() const {
592 return "__DATA, __objc_stringobj, regular, no_dead_strip";
595 /// \brief An optional hook that targets can implement to perform semantic
596 /// checking on attribute((section("foo"))) specifiers.
598 /// In this case, "foo" is passed in to be checked. If the section
599 /// specifier is invalid, the backend should return a non-empty string
600 /// that indicates the problem.
602 /// This hook is a simple quality of implementation feature to catch errors
603 /// and give good diagnostics in cases when the assembler or code generator
604 /// would otherwise reject the section specifier.
606 virtual std::string isValidSectionSpecifier(StringRef SR) const {
610 /// \brief Set forced language options.
612 /// Apply changes to the target information with respect to certain
613 /// language options which change the target configuration.
614 virtual void setForcedLangOptions(LangOptions &Opts);
616 /// \brief Get the default set of target features for the CPU;
617 /// this should include all legal feature strings on the target.
618 virtual void getDefaultFeatures(llvm::StringMap<bool> &Features) const {
621 /// \brief Get the ABI currently in use.
622 virtual const char *getABI() const {
626 /// \brief Get the C++ ABI currently in use.
627 virtual TargetCXXABI getCXXABI() const {
631 /// \brief Target the specified CPU.
633 /// \return False on error (invalid CPU name).
634 virtual bool setCPU(const std::string &Name) {
638 /// \brief Use the specified ABI.
640 /// \return False on error (invalid ABI name).
641 virtual bool setABI(const std::string &Name) {
645 /// \brief Use this specified C++ ABI.
647 /// \return False on error (invalid C++ ABI name).
648 bool setCXXABI(const std::string &Name) {
649 static const TargetCXXABI Unknown = static_cast<TargetCXXABI>(-1);
650 TargetCXXABI ABI = llvm::StringSwitch<TargetCXXABI>(Name)
651 .Case("arm", CXXABI_ARM)
652 .Case("itanium", CXXABI_Itanium)
653 .Case("microsoft", CXXABI_Microsoft)
655 if (ABI == Unknown) return false;
656 return setCXXABI(ABI);
659 /// \brief Set the C++ ABI to be used by this implementation.
661 /// \return False on error (ABI not valid on this target)
662 virtual bool setCXXABI(TargetCXXABI ABI) {
667 /// \brief Enable or disable a specific target feature;
668 /// the feature name must be valid.
670 /// \return False on error (invalid feature name).
671 virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
673 bool Enabled) const {
677 /// \brief Perform initialization based on the user configured
678 /// set of features (e.g., +sse4).
680 /// The list is guaranteed to have at most one entry per feature.
682 /// The target may modify the features list, to change which options are
683 /// passed onwards to the backend.
684 virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
687 /// \brief Determine whether the given target has the given feature.
688 virtual bool hasFeature(StringRef Feature) const {
692 // \brief Returns maximal number of args passed in registers.
693 unsigned getRegParmMax() const {
694 assert(RegParmMax < 7 && "RegParmMax value is larger than AST can handle");
698 /// \brief Whether the target supports thread-local storage.
699 bool isTLSSupported() const {
703 /// \brief Return true if {|} are normal characters in the asm string.
705 /// If this returns false (the default), then {abc|xyz} is syntax
706 /// that says that when compiling for asm variant #0, "abc" should be
707 /// generated, but when compiling for asm variant #1, "xyz" should be
709 bool hasNoAsmVariants() const {
710 return NoAsmVariants;
713 /// \brief Return the register number that __builtin_eh_return_regno would
714 /// return with the specified argument.
715 virtual int getEHDataRegisterNumber(unsigned RegNo) const {
719 /// \brief Return the section to use for C++ static initialization functions.
720 virtual const char *getStaticInitSectionSpecifier() const {
724 const LangAS::Map &getAddressSpaceMap() const {
725 return *AddrSpaceMap;
728 /// \brief Retrieve the name of the platform as it is used in the
729 /// availability attribute.
730 StringRef getPlatformName() const { return PlatformName; }
732 /// \brief Retrieve the minimum desired version of the platform, to
733 /// which the program should be compiled.
734 VersionTuple getPlatformMinVersion() const { return PlatformMinVersion; }
736 bool isBigEndian() const { return BigEndian; }
738 /// \brief Gets the default calling convention for the given target and
739 /// declaration context.
740 virtual CallingConv getDefaultCallingConv() const {
741 // Not all targets will specify an explicit calling convention that we can
742 // express. This will always do the right thing, even though it's not
743 // an explicit calling convention.
747 enum CallingConvCheckResult {
752 /// \brief Determines whether a given calling convention is valid for the
753 /// target. A calling convention can either be accepted, produce a warning
754 /// and be substituted with the default calling convention, or (someday)
755 /// produce an error (such as using thiscall on a non-instance function).
756 virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const {
767 virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
770 virtual uint64_t getPointerAlignV(unsigned AddrSpace) const {
773 virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const {
776 virtual void getGCCRegNames(const char * const *&Names,
777 unsigned &NumNames) const = 0;
778 virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
779 unsigned &NumAliases) const = 0;
780 virtual void getGCCAddlRegNames(const AddlRegName *&Addl,
781 unsigned &NumAddl) const {
785 virtual bool validateAsmConstraint(const char *&Name,
786 TargetInfo::ConstraintInfo &info) const= 0;
789 } // end namespace clang