1 //===--- TargetInfo.cpp - Information about Target machine ----------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file implements the TargetInfo and TargetInfoImpl interfaces.
11 //===----------------------------------------------------------------------===//
13 #include "clang/Basic/TargetInfo.h"
14 #include "clang/Basic/AddressSpaces.h"
15 #include "clang/Basic/CharInfo.h"
16 #include "clang/Basic/Diagnostic.h"
17 #include "clang/Basic/LangOptions.h"
18 #include "llvm/ADT/APFloat.h"
19 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/IR/DataLayout.h"
21 #include "llvm/Support/ErrorHandling.h"
22 #include "llvm/Support/TargetParser.h"
24 using namespace clang;
26 static const LangASMap DefaultAddrSpaceMap = {0};
28 // TargetInfo Constructor.
29 TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) {
30 // Set defaults. Defaults are set for a 32-bit RISC platform, like PPC or
31 // SPARC. These should be overridden by concrete targets as needed.
32 BigEndian = !T.isLittleEndian();
35 NoAsmVariants = false;
36 HasLegalHalfType = false;
41 PointerWidth = PointerAlign = 32;
42 BoolWidth = BoolAlign = 8;
43 IntWidth = IntAlign = 32;
44 LongWidth = LongAlign = 32;
45 LongLongWidth = LongLongAlign = 64;
47 // Fixed point default bit widths
48 ShortAccumWidth = ShortAccumAlign = 16;
49 AccumWidth = AccumAlign = 32;
50 LongAccumWidth = LongAccumAlign = 64;
51 ShortFractWidth = ShortFractAlign = 8;
52 FractWidth = FractAlign = 16;
53 LongFractWidth = LongFractAlign = 32;
55 // Fixed point default integral and fractional bit sizes
56 // We give the _Accum 1 fewer fractional bits than their corresponding _Fract
57 // types by default to have the same number of fractional bits between _Accum
59 PaddingOnUnsignedFixedPoint = false;
65 DefaultAlignForAttributeAligned = 128;
67 // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
68 // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
69 // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
70 // This alignment guarantee also applies to Windows and Android.
71 if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
72 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
74 NewAlign = 0; // Infer from basic type alignment.
84 LargeArrayMinWidth = 0;
86 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 0;
90 SizeType = UnsignedLong;
91 PtrDiffType = SignedLong;
92 IntMaxType = SignedLongLong;
93 IntPtrType = SignedLong;
94 WCharType = SignedInt;
96 Char16Type = UnsignedShort;
97 Char32Type = UnsignedInt;
98 Int64Type = SignedLongLong;
99 SigAtomicType = SignedInt;
100 ProcessIDType = SignedInt;
101 UseSignedCharForObjCBool = true;
102 UseBitFieldTypeAlignment = true;
103 UseZeroLengthBitfieldAlignment = false;
104 UseExplicitBitFieldAlignment = true;
105 ZeroLengthBitfieldBoundary = 0;
106 HalfFormat = &llvm::APFloat::IEEEhalf();
107 FloatFormat = &llvm::APFloat::IEEEsingle();
108 DoubleFormat = &llvm::APFloat::IEEEdouble();
109 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
110 Float128Format = &llvm::APFloat::IEEEquad();
111 MCountName = "mcount";
114 HasAlignMac68kSupport = false;
115 HasBuiltinMSVaList = false;
116 IsRenderScriptTarget = false;
117 HasAArch64SVETypes = false;
118 ARMCDECoprocMask = 0;
120 // Default to no types using fpret.
121 RealTypeUsesObjCFPRet = 0;
123 // Default to not using fp2ret for __Complex long double
124 ComplexLongDoubleUsesFP2Ret = false;
126 // Set the C++ ABI based on the triple.
127 TheCXXABI.set(Triple.isKnownWindowsMSVCEnvironment()
128 ? TargetCXXABI::Microsoft
129 : TargetCXXABI::GenericItanium);
131 // Default to an empty address space map.
132 AddrSpaceMap = &DefaultAddrSpaceMap;
133 UseAddrSpaceMapMangling = false;
135 // Default to an unknown platform name.
136 PlatformName = "unknown";
137 PlatformMinVersion = VersionTuple();
139 MaxOpenCLWorkGroupSize = 1024;
142 // Out of line virtual dtor for TargetInfo.
143 TargetInfo::~TargetInfo() {}
145 void TargetInfo::resetDataLayout(StringRef DL) {
146 DataLayout.reset(new llvm::DataLayout(DL));
150 TargetInfo::checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const {
151 Diags.Report(diag::err_opt_not_valid_on_target) << "cf-protection=branch";
156 TargetInfo::checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const {
157 Diags.Report(diag::err_opt_not_valid_on_target) << "cf-protection=return";
161 /// getTypeName - Return the user string for the specified integer type enum.
162 /// For example, SignedShort -> "short".
163 const char *TargetInfo::getTypeName(IntType T) {
165 default: llvm_unreachable("not an integer!");
166 case SignedChar: return "signed char";
167 case UnsignedChar: return "unsigned char";
168 case SignedShort: return "short";
169 case UnsignedShort: return "unsigned short";
170 case SignedInt: return "int";
171 case UnsignedInt: return "unsigned int";
172 case SignedLong: return "long int";
173 case UnsignedLong: return "long unsigned int";
174 case SignedLongLong: return "long long int";
175 case UnsignedLongLong: return "long long unsigned int";
179 /// getTypeConstantSuffix - Return the constant suffix for the specified
180 /// integer type enum. For example, SignedLong -> "L".
181 const char *TargetInfo::getTypeConstantSuffix(IntType T) const {
183 default: llvm_unreachable("not an integer!");
186 case SignedInt: return "";
187 case SignedLong: return "L";
188 case SignedLongLong: return "LL";
190 if (getCharWidth() < getIntWidth())
194 if (getShortWidth() < getIntWidth())
197 case UnsignedInt: return "U";
198 case UnsignedLong: return "UL";
199 case UnsignedLongLong: return "ULL";
203 /// getTypeFormatModifier - Return the printf format modifier for the
204 /// specified integer type enum. For example, SignedLong -> "l".
206 const char *TargetInfo::getTypeFormatModifier(IntType T) {
208 default: llvm_unreachable("not an integer!");
210 case UnsignedChar: return "hh";
212 case UnsignedShort: return "h";
214 case UnsignedInt: return "";
216 case UnsignedLong: return "l";
218 case UnsignedLongLong: return "ll";
222 /// getTypeWidth - Return the width (in bits) of the specified integer type
223 /// enum. For example, SignedInt -> getIntWidth().
224 unsigned TargetInfo::getTypeWidth(IntType T) const {
226 default: llvm_unreachable("not an integer!");
228 case UnsignedChar: return getCharWidth();
230 case UnsignedShort: return getShortWidth();
232 case UnsignedInt: return getIntWidth();
234 case UnsignedLong: return getLongWidth();
236 case UnsignedLongLong: return getLongLongWidth();
240 TargetInfo::IntType TargetInfo::getIntTypeByWidth(
241 unsigned BitWidth, bool IsSigned) const {
242 if (getCharWidth() == BitWidth)
243 return IsSigned ? SignedChar : UnsignedChar;
244 if (getShortWidth() == BitWidth)
245 return IsSigned ? SignedShort : UnsignedShort;
246 if (getIntWidth() == BitWidth)
247 return IsSigned ? SignedInt : UnsignedInt;
248 if (getLongWidth() == BitWidth)
249 return IsSigned ? SignedLong : UnsignedLong;
250 if (getLongLongWidth() == BitWidth)
251 return IsSigned ? SignedLongLong : UnsignedLongLong;
255 TargetInfo::IntType TargetInfo::getLeastIntTypeByWidth(unsigned BitWidth,
256 bool IsSigned) const {
257 if (getCharWidth() >= BitWidth)
258 return IsSigned ? SignedChar : UnsignedChar;
259 if (getShortWidth() >= BitWidth)
260 return IsSigned ? SignedShort : UnsignedShort;
261 if (getIntWidth() >= BitWidth)
262 return IsSigned ? SignedInt : UnsignedInt;
263 if (getLongWidth() >= BitWidth)
264 return IsSigned ? SignedLong : UnsignedLong;
265 if (getLongLongWidth() >= BitWidth)
266 return IsSigned ? SignedLongLong : UnsignedLongLong;
270 TargetInfo::RealType TargetInfo::getRealTypeByWidth(unsigned BitWidth,
271 bool ExplicitIEEE) const {
272 if (getFloatWidth() == BitWidth)
274 if (getDoubleWidth() == BitWidth)
279 if (&getLongDoubleFormat() == &llvm::APFloat::x87DoubleExtended())
283 // The caller explicitly asked for an IEEE compliant type but we still
284 // have to check if the target supports it.
286 return hasFloat128Type() ? Float128 : NoFloat;
287 if (&getLongDoubleFormat() == &llvm::APFloat::PPCDoubleDouble() ||
288 &getLongDoubleFormat() == &llvm::APFloat::IEEEquad())
290 if (hasFloat128Type())
298 /// getTypeAlign - Return the alignment (in bits) of the specified integer type
299 /// enum. For example, SignedInt -> getIntAlign().
300 unsigned TargetInfo::getTypeAlign(IntType T) const {
302 default: llvm_unreachable("not an integer!");
304 case UnsignedChar: return getCharAlign();
306 case UnsignedShort: return getShortAlign();
308 case UnsignedInt: return getIntAlign();
310 case UnsignedLong: return getLongAlign();
312 case UnsignedLongLong: return getLongLongAlign();
316 /// isTypeSigned - Return whether an integer types is signed. Returns true if
317 /// the type is signed; false otherwise.
318 bool TargetInfo::isTypeSigned(IntType T) {
320 default: llvm_unreachable("not an integer!");
331 case UnsignedLongLong:
336 /// adjust - Set forced language options.
337 /// Apply changes to the target information with respect to certain
338 /// language options which change the target configuration and adjust
339 /// the language based on the target options where applicable.
340 void TargetInfo::adjust(LangOptions &Opts) {
341 if (Opts.NoBitFieldTypeAlign)
342 UseBitFieldTypeAlignment = false;
344 switch (Opts.WCharSize) {
345 default: llvm_unreachable("invalid wchar_t width");
347 case 1: WCharType = Opts.WCharIsSigned ? SignedChar : UnsignedChar; break;
348 case 2: WCharType = Opts.WCharIsSigned ? SignedShort : UnsignedShort; break;
349 case 4: WCharType = Opts.WCharIsSigned ? SignedInt : UnsignedInt; break;
352 if (Opts.AlignDouble) {
353 DoubleAlign = LongLongAlign = 64;
354 LongDoubleAlign = 64;
358 // OpenCL C requires specific widths for types, irrespective of
359 // what these normally are for the target.
360 // We also define long long and long double here, although the
361 // OpenCL standard only mentions these as "reserved".
362 IntWidth = IntAlign = 32;
363 LongWidth = LongAlign = 64;
364 LongLongWidth = LongLongAlign = 128;
365 HalfWidth = HalfAlign = 16;
366 FloatWidth = FloatAlign = 32;
368 // Embedded 32-bit targets (OpenCL EP) might have double C type
369 // defined as float. Let's not override this as it might lead
370 // to generating illegal code that uses 64bit doubles.
371 if (DoubleWidth != FloatWidth) {
372 DoubleWidth = DoubleAlign = 64;
373 DoubleFormat = &llvm::APFloat::IEEEdouble();
375 LongDoubleWidth = LongDoubleAlign = 128;
377 unsigned MaxPointerWidth = getMaxPointerWidth();
378 assert(MaxPointerWidth == 32 || MaxPointerWidth == 64);
379 bool Is32BitArch = MaxPointerWidth == 32;
380 SizeType = Is32BitArch ? UnsignedInt : UnsignedLong;
381 PtrDiffType = Is32BitArch ? SignedInt : SignedLong;
382 IntPtrType = Is32BitArch ? SignedInt : SignedLong;
384 IntMaxType = SignedLongLong;
385 Int64Type = SignedLong;
387 HalfFormat = &llvm::APFloat::IEEEhalf();
388 FloatFormat = &llvm::APFloat::IEEEsingle();
389 LongDoubleFormat = &llvm::APFloat::IEEEquad();
392 if (Opts.DoubleSize) {
393 if (Opts.DoubleSize == 32) {
395 LongDoubleWidth = 32;
396 DoubleFormat = &llvm::APFloat::IEEEsingle();
397 LongDoubleFormat = &llvm::APFloat::IEEEsingle();
398 } else if (Opts.DoubleSize == 64) {
400 LongDoubleWidth = 64;
401 DoubleFormat = &llvm::APFloat::IEEEdouble();
402 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
406 if (Opts.LongDoubleSize) {
407 if (Opts.LongDoubleSize == DoubleWidth) {
408 LongDoubleWidth = DoubleWidth;
409 LongDoubleAlign = DoubleAlign;
410 LongDoubleFormat = DoubleFormat;
411 } else if (Opts.LongDoubleSize == 128) {
412 LongDoubleWidth = LongDoubleAlign = 128;
413 LongDoubleFormat = &llvm::APFloat::IEEEquad();
417 if (Opts.NewAlignOverride)
418 NewAlign = Opts.NewAlignOverride * getCharWidth();
420 // Each unsigned fixed point type has the same number of fractional bits as
421 // its corresponding signed type.
422 PaddingOnUnsignedFixedPoint |= Opts.PaddingOnUnsignedFixedPoint;
423 CheckFixedPointBits();
426 bool TargetInfo::initFeatureMap(
427 llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
428 const std::vector<std::string> &FeatureVec) const {
429 for (const auto &F : FeatureVec) {
431 // Apply the feature via the target.
432 bool Enabled = Name[0] == '+';
433 setFeatureEnabled(Features, Name.substr(1), Enabled);
438 TargetInfo::CallingConvKind
439 TargetInfo::getCallingConvKind(bool ClangABICompat4) const {
440 if (getCXXABI() != TargetCXXABI::Microsoft &&
441 (ClangABICompat4 || getTriple().getOS() == llvm::Triple::PS4))
442 return CCK_ClangABI4OrPS4;
446 LangAS TargetInfo::getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const {
450 return LangAS::opencl_global;
453 return LangAS::opencl_constant;
456 return LangAS::Default;
460 //===----------------------------------------------------------------------===//
463 static StringRef removeGCCRegisterPrefix(StringRef Name) {
464 if (Name[0] == '%' || Name[0] == '#')
465 Name = Name.substr(1);
470 /// isValidClobber - Returns whether the passed in string is
471 /// a valid clobber in an inline asm statement. This is used by
473 bool TargetInfo::isValidClobber(StringRef Name) const {
474 return (isValidGCCRegisterName(Name) ||
475 Name == "memory" || Name == "cc");
478 /// isValidGCCRegisterName - Returns whether the passed in string
479 /// is a valid register name according to GCC. This is used by Sema for
480 /// inline asm statements.
481 bool TargetInfo::isValidGCCRegisterName(StringRef Name) const {
485 // Get rid of any register prefix.
486 Name = removeGCCRegisterPrefix(Name);
490 ArrayRef<const char *> Names = getGCCRegNames();
492 // If we have a number it maps to an entry in the register name array.
493 if (isDigit(Name[0])) {
495 if (!Name.getAsInteger(0, n))
496 return n < Names.size();
499 // Check register names.
500 if (llvm::is_contained(Names, Name))
503 // Check any additional names that we have.
504 for (const AddlRegName &ARN : getGCCAddlRegNames())
505 for (const char *AN : ARN.Names) {
508 // Make sure the register that the additional name is for is within
509 // the bounds of the register names from above.
510 if (AN == Name && ARN.RegNum < Names.size())
514 // Now check aliases.
515 for (const GCCRegAlias &GRA : getGCCRegAliases())
516 for (const char *A : GRA.Aliases) {
526 StringRef TargetInfo::getNormalizedGCCRegisterName(StringRef Name,
527 bool ReturnCanonical) const {
528 assert(isValidGCCRegisterName(Name) && "Invalid register passed in");
530 // Get rid of any register prefix.
531 Name = removeGCCRegisterPrefix(Name);
533 ArrayRef<const char *> Names = getGCCRegNames();
535 // First, check if we have a number.
536 if (isDigit(Name[0])) {
538 if (!Name.getAsInteger(0, n)) {
539 assert(n < Names.size() && "Out of bounds register number!");
544 // Check any additional names that we have.
545 for (const AddlRegName &ARN : getGCCAddlRegNames())
546 for (const char *AN : ARN.Names) {
549 // Make sure the register that the additional name is for is within
550 // the bounds of the register names from above.
551 if (AN == Name && ARN.RegNum < Names.size())
552 return ReturnCanonical ? Names[ARN.RegNum] : Name;
555 // Now check aliases.
556 for (const GCCRegAlias &RA : getGCCRegAliases())
557 for (const char *A : RA.Aliases) {
567 bool TargetInfo::validateOutputConstraint(ConstraintInfo &Info) const {
568 const char *Name = Info.getConstraintStr().c_str();
569 // An output constraint must start with '=' or '+'
570 if (*Name != '=' && *Name != '+')
574 Info.setIsReadWrite();
580 if (!validateAsmConstraint(Name, Info)) {
581 // FIXME: We temporarily return false
582 // so we can add more constraints as we hit it.
583 // Eventually, an unknown constraint should just be treated as 'g'.
587 case '&': // early clobber.
588 Info.setEarlyClobber();
590 case '%': // commutative.
591 // FIXME: Check that there is a another register after this one.
593 case 'r': // general register.
594 Info.setAllowsRegister();
596 case 'm': // memory operand.
597 case 'o': // offsetable memory operand.
598 case 'V': // non-offsetable memory operand.
599 case '<': // autodecrement memory operand.
600 case '>': // autoincrement memory operand.
601 Info.setAllowsMemory();
603 case 'g': // general register, memory operand or immediate integer.
604 case 'X': // any operand.
605 Info.setAllowsRegister();
606 Info.setAllowsMemory();
608 case ',': // multiple alternative constraint. Pass it.
609 // Handle additional optional '=' or '+' modifiers.
610 if (Name[1] == '=' || Name[1] == '+')
613 case '#': // Ignore as constraint.
614 while (Name[1] && Name[1] != ',')
617 case '?': // Disparage slightly code.
618 case '!': // Disparage severely.
619 case '*': // Ignore for choosing register preferences.
620 case 'i': // Ignore i,n,E,F as output constraints (match from the other
631 // Early clobber with a read-write constraint which doesn't permit registers
633 if (Info.earlyClobber() && Info.isReadWrite() && !Info.allowsRegister())
636 // If a constraint allows neither memory nor register operands it contains
637 // only modifiers. Reject it.
638 return Info.allowsMemory() || Info.allowsRegister();
641 bool TargetInfo::resolveSymbolicName(const char *&Name,
642 ArrayRef<ConstraintInfo> OutputConstraints,
643 unsigned &Index) const {
644 assert(*Name == '[' && "Symbolic name did not start with '['");
646 const char *Start = Name;
647 while (*Name && *Name != ']')
655 std::string SymbolicName(Start, Name - Start);
657 for (Index = 0; Index != OutputConstraints.size(); ++Index)
658 if (SymbolicName == OutputConstraints[Index].getName())
664 bool TargetInfo::validateInputConstraint(
665 MutableArrayRef<ConstraintInfo> OutputConstraints,
666 ConstraintInfo &Info) const {
667 const char *Name = Info.ConstraintStr.c_str();
675 // Check if we have a matching constraint
676 if (*Name >= '0' && *Name <= '9') {
677 const char *DigitStart = Name;
678 while (Name[1] >= '0' && Name[1] <= '9')
680 const char *DigitEnd = Name;
682 if (StringRef(DigitStart, DigitEnd - DigitStart + 1)
683 .getAsInteger(10, i))
686 // Check if matching constraint is out of bounds.
687 if (i >= OutputConstraints.size()) return false;
689 // A number must refer to an output only operand.
690 if (OutputConstraints[i].isReadWrite())
693 // If the constraint is already tied, it must be tied to the
694 // same operand referenced to by the number.
695 if (Info.hasTiedOperand() && Info.getTiedOperand() != i)
698 // The constraint should have the same info as the respective
699 // output constraint.
700 Info.setTiedOperand(i, OutputConstraints[i]);
701 } else if (!validateAsmConstraint(Name, Info)) {
702 // FIXME: This error return is in place temporarily so we can
703 // add more constraints as we hit it. Eventually, an unknown
704 // constraint should just be treated as 'g'.
710 if (!resolveSymbolicName(Name, OutputConstraints, Index))
713 // If the constraint is already tied, it must be tied to the
714 // same operand referenced to by the number.
715 if (Info.hasTiedOperand() && Info.getTiedOperand() != Index)
718 // A number must refer to an output only operand.
719 if (OutputConstraints[Index].isReadWrite())
722 Info.setTiedOperand(Index, OutputConstraints[Index]);
725 case '%': // commutative
726 // FIXME: Fail if % is used with the last operand.
728 case 'i': // immediate integer.
730 case 'n': // immediate integer with a known value.
731 Info.setRequiresImmediate();
733 case 'I': // Various constant constraints with target-specific meanings.
741 if (!validateAsmConstraint(Name, Info))
744 case 'r': // general register.
745 Info.setAllowsRegister();
747 case 'm': // memory operand.
748 case 'o': // offsettable memory operand.
749 case 'V': // non-offsettable memory operand.
750 case '<': // autodecrement memory operand.
751 case '>': // autoincrement memory operand.
752 Info.setAllowsMemory();
754 case 'g': // general register, memory operand or immediate integer.
755 case 'X': // any operand.
756 Info.setAllowsRegister();
757 Info.setAllowsMemory();
759 case 'E': // immediate floating point.
760 case 'F': // immediate floating point.
761 case 'p': // address operand.
763 case ',': // multiple alternative constraint. Ignore comma.
765 case '#': // Ignore as constraint.
766 while (Name[1] && Name[1] != ',')
769 case '?': // Disparage slightly code.
770 case '!': // Disparage severely.
771 case '*': // Ignore for choosing register preferences.
781 void TargetInfo::CheckFixedPointBits() const {
782 // Check that the number of fractional and integral bits (and maybe sign) can
783 // fit into the bits given for a fixed point type.
784 assert(ShortAccumScale + getShortAccumIBits() + 1 <= ShortAccumWidth);
785 assert(AccumScale + getAccumIBits() + 1 <= AccumWidth);
786 assert(LongAccumScale + getLongAccumIBits() + 1 <= LongAccumWidth);
787 assert(getUnsignedShortAccumScale() + getUnsignedShortAccumIBits() <=
789 assert(getUnsignedAccumScale() + getUnsignedAccumIBits() <= AccumWidth);
790 assert(getUnsignedLongAccumScale() + getUnsignedLongAccumIBits() <=
793 assert(getShortFractScale() + 1 <= ShortFractWidth);
794 assert(getFractScale() + 1 <= FractWidth);
795 assert(getLongFractScale() + 1 <= LongFractWidth);
796 assert(getUnsignedShortFractScale() <= ShortFractWidth);
797 assert(getUnsignedFractScale() <= FractWidth);
798 assert(getUnsignedLongFractScale() <= LongFractWidth);
800 // Each unsigned fract type has either the same number of fractional bits
801 // as, or one more fractional bit than, its corresponding signed fract type.
802 assert(getShortFractScale() == getUnsignedShortFractScale() ||
803 getShortFractScale() == getUnsignedShortFractScale() - 1);
804 assert(getFractScale() == getUnsignedFractScale() ||
805 getFractScale() == getUnsignedFractScale() - 1);
806 assert(getLongFractScale() == getUnsignedLongFractScale() ||
807 getLongFractScale() == getUnsignedLongFractScale() - 1);
809 // When arranged in order of increasing rank (see 6.3.1.3a), the number of
810 // fractional bits is nondecreasing for each of the following sets of
811 // fixed-point types:
812 // - signed fract types
813 // - unsigned fract types
814 // - signed accum types
815 // - unsigned accum types.
816 assert(getLongFractScale() >= getFractScale() &&
817 getFractScale() >= getShortFractScale());
818 assert(getUnsignedLongFractScale() >= getUnsignedFractScale() &&
819 getUnsignedFractScale() >= getUnsignedShortFractScale());
820 assert(LongAccumScale >= AccumScale && AccumScale >= ShortAccumScale);
821 assert(getUnsignedLongAccumScale() >= getUnsignedAccumScale() &&
822 getUnsignedAccumScale() >= getUnsignedShortAccumScale());
824 // When arranged in order of increasing rank (see 6.3.1.3a), the number of
825 // integral bits is nondecreasing for each of the following sets of
826 // fixed-point types:
827 // - signed accum types
828 // - unsigned accum types
829 assert(getLongAccumIBits() >= getAccumIBits() &&
830 getAccumIBits() >= getShortAccumIBits());
831 assert(getUnsignedLongAccumIBits() >= getUnsignedAccumIBits() &&
832 getUnsignedAccumIBits() >= getUnsignedShortAccumIBits());
834 // Each signed accum type has at least as many integral bits as its
835 // corresponding unsigned accum type.
836 assert(getShortAccumIBits() >= getUnsignedShortAccumIBits());
837 assert(getAccumIBits() >= getUnsignedAccumIBits());
838 assert(getLongAccumIBits() >= getUnsignedLongAccumIBits());
841 void TargetInfo::copyAuxTarget(const TargetInfo *Aux) {
842 auto *Target = static_cast<TransferrableTargetInfo*>(this);
843 auto *Src = static_cast<const TransferrableTargetInfo*>(Aux);