aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm12/lib/Support
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/llvm12/lib/Support
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
downloadydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/Support')
-rw-r--r--contrib/libs/llvm12/lib/Support/AArch64TargetParser.cpp26
-rw-r--r--contrib/libs/llvm12/lib/Support/AMDGPUMetadata.cpp2
-rw-r--r--contrib/libs/llvm12/lib/Support/APFixedPoint.cpp1148
-rw-r--r--contrib/libs/llvm12/lib/Support/APFloat.cpp98
-rw-r--r--contrib/libs/llvm12/lib/Support/APInt.cpp18
-rw-r--r--contrib/libs/llvm12/lib/Support/ARMAttributeParser.cpp2
-rw-r--r--contrib/libs/llvm12/lib/Support/ARMTargetParser.cpp40
-rw-r--r--contrib/libs/llvm12/lib/Support/CRC.cpp2
-rw-r--r--contrib/libs/llvm12/lib/Support/CachePruning.cpp6
-rw-r--r--contrib/libs/llvm12/lib/Support/CommandLine.cpp90
-rw-r--r--contrib/libs/llvm12/lib/Support/Compression.cpp4
-rw-r--r--contrib/libs/llvm12/lib/Support/ConvertUTFWrapper.cpp4
-rw-r--r--contrib/libs/llvm12/lib/Support/CrashRecoveryContext.cpp66
-rw-r--r--contrib/libs/llvm12/lib/Support/DebugCounter.cpp2
-rw-r--r--contrib/libs/llvm12/lib/Support/DynamicLibrary.cpp2
-rw-r--r--contrib/libs/llvm12/lib/Support/ELFAttributeParser.cpp2
-rw-r--r--contrib/libs/llvm12/lib/Support/Error.cpp8
-rw-r--r--contrib/libs/llvm12/lib/Support/ErrorHandling.cpp14
-rw-r--r--contrib/libs/llvm12/lib/Support/FileCollector.cpp158
-rw-r--r--contrib/libs/llvm12/lib/Support/FormatVariadic.cpp22
-rw-r--r--contrib/libs/llvm12/lib/Support/Host.cpp388
-rw-r--r--contrib/libs/llvm12/lib/Support/InitLLVM.cpp18
-rw-r--r--contrib/libs/llvm12/lib/Support/InstructionCost.cpp48
-rw-r--r--contrib/libs/llvm12/lib/Support/JSON.cpp412
-rw-r--r--contrib/libs/llvm12/lib/Support/KnownBits.cpp794
-rw-r--r--contrib/libs/llvm12/lib/Support/LineIterator.cpp12
-rw-r--r--contrib/libs/llvm12/lib/Support/LowLevelType.cpp2
-rw-r--r--contrib/libs/llvm12/lib/Support/MemoryBufferRef.cpp38
-rw-r--r--contrib/libs/llvm12/lib/Support/Path.cpp64
-rw-r--r--contrib/libs/llvm12/lib/Support/PrettyStackTrace.cpp22
-rw-r--r--contrib/libs/llvm12/lib/Support/Process.cpp28
-rw-r--r--contrib/libs/llvm12/lib/Support/Program.cpp18
-rw-r--r--contrib/libs/llvm12/lib/Support/SHA1.cpp2
-rw-r--r--contrib/libs/llvm12/lib/Support/Signals.cpp14
-rw-r--r--contrib/libs/llvm12/lib/Support/Signposts.cpp42
-rw-r--r--contrib/libs/llvm12/lib/Support/SmallVector.cpp118
-rw-r--r--contrib/libs/llvm12/lib/Support/SourceMgr.cpp76
-rw-r--r--contrib/libs/llvm12/lib/Support/TargetParser.cpp166
-rw-r--r--contrib/libs/llvm12/lib/Support/Timer.cpp20
-rw-r--r--contrib/libs/llvm12/lib/Support/TrigramIndex.cpp2
-rw-r--r--contrib/libs/llvm12/lib/Support/Triple.cpp132
-rw-r--r--contrib/libs/llvm12/lib/Support/Unicode.cpp22
-rw-r--r--contrib/libs/llvm12/lib/Support/Unix/Path.inc142
-rw-r--r--contrib/libs/llvm12/lib/Support/Unix/Process.inc6
-rw-r--r--contrib/libs/llvm12/lib/Support/Unix/Program.inc10
-rw-r--r--contrib/libs/llvm12/lib/Support/Unix/Signals.inc36
-rw-r--r--contrib/libs/llvm12/lib/Support/Unix/Threading.inc16
-rw-r--r--contrib/libs/llvm12/lib/Support/VirtualFileSystem.cpp254
-rw-r--r--contrib/libs/llvm12/lib/Support/Windows/Path.inc112
-rw-r--r--contrib/libs/llvm12/lib/Support/Windows/Process.inc4
-rw-r--r--contrib/libs/llvm12/lib/Support/Windows/Program.inc78
-rw-r--r--contrib/libs/llvm12/lib/Support/Windows/Signals.inc8
-rw-r--r--contrib/libs/llvm12/lib/Support/Windows/Threading.inc38
-rw-r--r--contrib/libs/llvm12/lib/Support/X86TargetParser.cpp416
-rw-r--r--contrib/libs/llvm12/lib/Support/YAMLParser.cpp232
-rw-r--r--contrib/libs/llvm12/lib/Support/YAMLTraits.cpp108
-rw-r--r--contrib/libs/llvm12/lib/Support/raw_ostream.cpp112
-rw-r--r--contrib/libs/llvm12/lib/Support/ya.make10
58 files changed, 2867 insertions, 2867 deletions
diff --git a/contrib/libs/llvm12/lib/Support/AArch64TargetParser.cpp b/contrib/libs/llvm12/lib/Support/AArch64TargetParser.cpp
index 503a7bd49d..9580c26af6 100644
--- a/contrib/libs/llvm12/lib/Support/AArch64TargetParser.cpp
+++ b/contrib/libs/llvm12/lib/Support/AArch64TargetParser.cpp
@@ -35,11 +35,11 @@ unsigned AArch64::getDefaultFPU(StringRef CPU, AArch64::ArchKind AK) {
.Default(ARM::FK_INVALID);
}
-uint64_t AArch64::getDefaultExtensions(StringRef CPU, AArch64::ArchKind AK) {
+uint64_t AArch64::getDefaultExtensions(StringRef CPU, AArch64::ArchKind AK) {
if (CPU == "generic")
return AArch64ARCHNames[static_cast<unsigned>(AK)].ArchBaseExtensions;
- return StringSwitch<uint64_t>(CPU)
+ return StringSwitch<uint64_t>(CPU)
#define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
.Case(NAME, AArch64ARCHNames[static_cast<unsigned>(ArchKind::ID)] \
.ArchBaseExtensions | \
@@ -59,7 +59,7 @@ AArch64::ArchKind AArch64::getCPUArchKind(StringRef CPU) {
.Default(ArchKind::INVALID);
}
-bool AArch64::getExtensionFeatures(uint64_t Extensions,
+bool AArch64::getExtensionFeatures(uint64_t Extensions,
std::vector<StringRef> &Features) {
if (Extensions == AArch64::AEK_INVALID)
return false;
@@ -100,12 +100,12 @@ bool AArch64::getExtensionFeatures(uint64_t Extensions,
Features.push_back("+sve2-bitperm");
if (Extensions & AEK_RCPC)
Features.push_back("+rcpc");
- if (Extensions & AEK_BRBE)
- Features.push_back("+brbe");
- if (Extensions & AEK_PAUTH)
- Features.push_back("+pauth");
- if (Extensions & AEK_FLAGM)
- Features.push_back("+flagm");
+ if (Extensions & AEK_BRBE)
+ Features.push_back("+brbe");
+ if (Extensions & AEK_PAUTH)
+ Features.push_back("+pauth");
+ if (Extensions & AEK_FLAGM)
+ Features.push_back("+flagm");
return true;
}
@@ -124,10 +124,10 @@ bool AArch64::getArchFeatures(AArch64::ArchKind AK,
Features.push_back("+v8.5a");
if (AK == AArch64::ArchKind::ARMV8_6A)
Features.push_back("+v8.6a");
- if (AK == AArch64::ArchKind::ARMV8_7A)
- Features.push_back("+v8.7a");
- if(AK == AArch64::ArchKind::ARMV8R)
- Features.push_back("+v8r");
+ if (AK == AArch64::ArchKind::ARMV8_7A)
+ Features.push_back("+v8.7a");
+ if(AK == AArch64::ArchKind::ARMV8R)
+ Features.push_back("+v8r");
return AK != ArchKind::INVALID;
}
diff --git a/contrib/libs/llvm12/lib/Support/AMDGPUMetadata.cpp b/contrib/libs/llvm12/lib/Support/AMDGPUMetadata.cpp
index 3d6325134d..57ec007030 100644
--- a/contrib/libs/llvm12/lib/Support/AMDGPUMetadata.cpp
+++ b/contrib/libs/llvm12/lib/Support/AMDGPUMetadata.cpp
@@ -210,7 +210,7 @@ struct MappingTraits<HSAMD::Metadata> {
namespace AMDGPU {
namespace HSAMD {
-std::error_code fromString(StringRef String, Metadata &HSAMetadata) {
+std::error_code fromString(StringRef String, Metadata &HSAMetadata) {
yaml::Input YamlInput(String);
YamlInput >> HSAMetadata;
return YamlInput.error();
diff --git a/contrib/libs/llvm12/lib/Support/APFixedPoint.cpp b/contrib/libs/llvm12/lib/Support/APFixedPoint.cpp
index 9764dd51f5..ff11333f51 100644
--- a/contrib/libs/llvm12/lib/Support/APFixedPoint.cpp
+++ b/contrib/libs/llvm12/lib/Support/APFixedPoint.cpp
@@ -1,574 +1,574 @@
-//===- APFixedPoint.cpp - Fixed point constant handling ---------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-/// \file
-/// Defines the implementation for the fixed point number interface.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/ADT/APFixedPoint.h"
-#include "llvm/ADT/APFloat.h"
-
-namespace llvm {
-
-APFixedPoint APFixedPoint::convert(const FixedPointSemantics &DstSema,
- bool *Overflow) const {
- APSInt NewVal = Val;
- unsigned DstWidth = DstSema.getWidth();
- unsigned DstScale = DstSema.getScale();
- bool Upscaling = DstScale > getScale();
- if (Overflow)
- *Overflow = false;
-
- if (Upscaling) {
- NewVal = NewVal.extend(NewVal.getBitWidth() + DstScale - getScale());
- NewVal <<= (DstScale - getScale());
- } else {
- NewVal >>= (getScale() - DstScale);
- }
-
- auto Mask = APInt::getBitsSetFrom(
- NewVal.getBitWidth(),
- std::min(DstScale + DstSema.getIntegralBits(), NewVal.getBitWidth()));
- APInt Masked(NewVal & Mask);
-
- // Change in the bits above the sign
- if (!(Masked == Mask || Masked == 0)) {
- // Found overflow in the bits above the sign
- if (DstSema.isSaturated())
- NewVal = NewVal.isNegative() ? Mask : ~Mask;
- else if (Overflow)
- *Overflow = true;
- }
-
- // If the dst semantics are unsigned, but our value is signed and negative, we
- // clamp to zero.
- if (!DstSema.isSigned() && NewVal.isSigned() && NewVal.isNegative()) {
- // Found negative overflow for unsigned result
- if (DstSema.isSaturated())
- NewVal = 0;
- else if (Overflow)
- *Overflow = true;
- }
-
- NewVal = NewVal.extOrTrunc(DstWidth);
- NewVal.setIsSigned(DstSema.isSigned());
- return APFixedPoint(NewVal, DstSema);
-}
-
-int APFixedPoint::compare(const APFixedPoint &Other) const {
- APSInt ThisVal = getValue();
- APSInt OtherVal = Other.getValue();
- bool ThisSigned = Val.isSigned();
- bool OtherSigned = OtherVal.isSigned();
- unsigned OtherScale = Other.getScale();
- unsigned OtherWidth = OtherVal.getBitWidth();
-
- unsigned CommonWidth = std::max(Val.getBitWidth(), OtherWidth);
-
- // Prevent overflow in the event the widths are the same but the scales differ
- CommonWidth += getScale() >= OtherScale ? getScale() - OtherScale
- : OtherScale - getScale();
-
- ThisVal = ThisVal.extOrTrunc(CommonWidth);
- OtherVal = OtherVal.extOrTrunc(CommonWidth);
-
- unsigned CommonScale = std::max(getScale(), OtherScale);
- ThisVal = ThisVal.shl(CommonScale - getScale());
- OtherVal = OtherVal.shl(CommonScale - OtherScale);
-
- if (ThisSigned && OtherSigned) {
- if (ThisVal.sgt(OtherVal))
- return 1;
- else if (ThisVal.slt(OtherVal))
- return -1;
- } else if (!ThisSigned && !OtherSigned) {
- if (ThisVal.ugt(OtherVal))
- return 1;
- else if (ThisVal.ult(OtherVal))
- return -1;
- } else if (ThisSigned && !OtherSigned) {
- if (ThisVal.isSignBitSet())
- return -1;
- else if (ThisVal.ugt(OtherVal))
- return 1;
- else if (ThisVal.ult(OtherVal))
- return -1;
- } else {
- // !ThisSigned && OtherSigned
- if (OtherVal.isSignBitSet())
- return 1;
- else if (ThisVal.ugt(OtherVal))
- return 1;
- else if (ThisVal.ult(OtherVal))
- return -1;
- }
-
- return 0;
-}
-
-APFixedPoint APFixedPoint::getMax(const FixedPointSemantics &Sema) {
- bool IsUnsigned = !Sema.isSigned();
- auto Val = APSInt::getMaxValue(Sema.getWidth(), IsUnsigned);
- if (IsUnsigned && Sema.hasUnsignedPadding())
- Val = Val.lshr(1);
- return APFixedPoint(Val, Sema);
-}
-
-APFixedPoint APFixedPoint::getMin(const FixedPointSemantics &Sema) {
- auto Val = APSInt::getMinValue(Sema.getWidth(), !Sema.isSigned());
- return APFixedPoint(Val, Sema);
-}
-
-bool FixedPointSemantics::fitsInFloatSemantics(
- const fltSemantics &FloatSema) const {
- // A fixed point semantic fits in a floating point semantic if the maximum
- // and minimum values as integers of the fixed point semantic can fit in the
- // floating point semantic.
-
- // If these values do not fit, then a floating point rescaling of the true
- // maximum/minimum value will not fit either, so the floating point semantic
- // cannot be used to perform such a rescaling.
-
- APSInt MaxInt = APFixedPoint::getMax(*this).getValue();
- APFloat F(FloatSema);
- APFloat::opStatus Status = F.convertFromAPInt(MaxInt, MaxInt.isSigned(),
- APFloat::rmNearestTiesToAway);
- if ((Status & APFloat::opOverflow) || !isSigned())
- return !(Status & APFloat::opOverflow);
-
- APSInt MinInt = APFixedPoint::getMin(*this).getValue();
- Status = F.convertFromAPInt(MinInt, MinInt.isSigned(),
- APFloat::rmNearestTiesToAway);
- return !(Status & APFloat::opOverflow);
-}
-
-FixedPointSemantics FixedPointSemantics::getCommonSemantics(
- const FixedPointSemantics &Other) const {
- unsigned CommonScale = std::max(getScale(), Other.getScale());
- unsigned CommonWidth =
- std::max(getIntegralBits(), Other.getIntegralBits()) + CommonScale;
-
- bool ResultIsSigned = isSigned() || Other.isSigned();
- bool ResultIsSaturated = isSaturated() || Other.isSaturated();
- bool ResultHasUnsignedPadding = false;
- if (!ResultIsSigned) {
- // Both are unsigned.
- ResultHasUnsignedPadding = hasUnsignedPadding() &&
- Other.hasUnsignedPadding() && !ResultIsSaturated;
- }
-
- // If the result is signed, add an extra bit for the sign. Otherwise, if it is
- // unsigned and has unsigned padding, we only need to add the extra padding
- // bit back if we are not saturating.
- if (ResultIsSigned || ResultHasUnsignedPadding)
- CommonWidth++;
-
- return FixedPointSemantics(CommonWidth, CommonScale, ResultIsSigned,
- ResultIsSaturated, ResultHasUnsignedPadding);
-}
-
-APFixedPoint APFixedPoint::add(const APFixedPoint &Other,
- bool *Overflow) const {
- auto CommonFXSema = Sema.getCommonSemantics(Other.getSemantics());
- APFixedPoint ConvertedThis = convert(CommonFXSema);
- APFixedPoint ConvertedOther = Other.convert(CommonFXSema);
- APSInt ThisVal = ConvertedThis.getValue();
- APSInt OtherVal = ConvertedOther.getValue();
- bool Overflowed = false;
-
- APSInt Result;
- if (CommonFXSema.isSaturated()) {
- Result = CommonFXSema.isSigned() ? ThisVal.sadd_sat(OtherVal)
- : ThisVal.uadd_sat(OtherVal);
- } else {
- Result = ThisVal.isSigned() ? ThisVal.sadd_ov(OtherVal, Overflowed)
- : ThisVal.uadd_ov(OtherVal, Overflowed);
- }
-
- if (Overflow)
- *Overflow = Overflowed;
-
- return APFixedPoint(Result, CommonFXSema);
-}
-
-APFixedPoint APFixedPoint::sub(const APFixedPoint &Other,
- bool *Overflow) const {
- auto CommonFXSema = Sema.getCommonSemantics(Other.getSemantics());
- APFixedPoint ConvertedThis = convert(CommonFXSema);
- APFixedPoint ConvertedOther = Other.convert(CommonFXSema);
- APSInt ThisVal = ConvertedThis.getValue();
- APSInt OtherVal = ConvertedOther.getValue();
- bool Overflowed = false;
-
- APSInt Result;
- if (CommonFXSema.isSaturated()) {
- Result = CommonFXSema.isSigned() ? ThisVal.ssub_sat(OtherVal)
- : ThisVal.usub_sat(OtherVal);
- } else {
- Result = ThisVal.isSigned() ? ThisVal.ssub_ov(OtherVal, Overflowed)
- : ThisVal.usub_ov(OtherVal, Overflowed);
- }
-
- if (Overflow)
- *Overflow = Overflowed;
-
- return APFixedPoint(Result, CommonFXSema);
-}
-
-APFixedPoint APFixedPoint::mul(const APFixedPoint &Other,
- bool *Overflow) const {
- auto CommonFXSema = Sema.getCommonSemantics(Other.getSemantics());
- APFixedPoint ConvertedThis = convert(CommonFXSema);
- APFixedPoint ConvertedOther = Other.convert(CommonFXSema);
- APSInt ThisVal = ConvertedThis.getValue();
- APSInt OtherVal = ConvertedOther.getValue();
- bool Overflowed = false;
-
- // Widen the LHS and RHS so we can perform a full multiplication.
- unsigned Wide = CommonFXSema.getWidth() * 2;
- if (CommonFXSema.isSigned()) {
- ThisVal = ThisVal.sextOrSelf(Wide);
- OtherVal = OtherVal.sextOrSelf(Wide);
- } else {
- ThisVal = ThisVal.zextOrSelf(Wide);
- OtherVal = OtherVal.zextOrSelf(Wide);
- }
-
- // Perform the full multiplication and downscale to get the same scale.
- //
- // Note that the right shifts here perform an implicit downwards rounding.
- // This rounding could discard bits that would technically place the result
- // outside the representable range. We interpret the spec as allowing us to
- // perform the rounding step first, avoiding the overflow case that would
- // arise.
- APSInt Result;
- if (CommonFXSema.isSigned())
- Result = ThisVal.smul_ov(OtherVal, Overflowed)
- .ashr(CommonFXSema.getScale());
- else
- Result = ThisVal.umul_ov(OtherVal, Overflowed)
- .lshr(CommonFXSema.getScale());
- assert(!Overflowed && "Full multiplication cannot overflow!");
- Result.setIsSigned(CommonFXSema.isSigned());
-
- // If our result lies outside of the representative range of the common
- // semantic, we either have overflow or saturation.
- APSInt Max = APFixedPoint::getMax(CommonFXSema).getValue()
- .extOrTrunc(Wide);
- APSInt Min = APFixedPoint::getMin(CommonFXSema).getValue()
- .extOrTrunc(Wide);
- if (CommonFXSema.isSaturated()) {
- if (Result < Min)
- Result = Min;
- else if (Result > Max)
- Result = Max;
- } else
- Overflowed = Result < Min || Result > Max;
-
- if (Overflow)
- *Overflow = Overflowed;
-
- return APFixedPoint(Result.sextOrTrunc(CommonFXSema.getWidth()),
- CommonFXSema);
-}
-
-APFixedPoint APFixedPoint::div(const APFixedPoint &Other,
- bool *Overflow) const {
- auto CommonFXSema = Sema.getCommonSemantics(Other.getSemantics());
- APFixedPoint ConvertedThis = convert(CommonFXSema);
- APFixedPoint ConvertedOther = Other.convert(CommonFXSema);
- APSInt ThisVal = ConvertedThis.getValue();
- APSInt OtherVal = ConvertedOther.getValue();
- bool Overflowed = false;
-
- // Widen the LHS and RHS so we can perform a full division.
- unsigned Wide = CommonFXSema.getWidth() * 2;
- if (CommonFXSema.isSigned()) {
- ThisVal = ThisVal.sextOrSelf(Wide);
- OtherVal = OtherVal.sextOrSelf(Wide);
- } else {
- ThisVal = ThisVal.zextOrSelf(Wide);
- OtherVal = OtherVal.zextOrSelf(Wide);
- }
-
- // Upscale to compensate for the loss of precision from division, and
- // perform the full division.
- ThisVal = ThisVal.shl(CommonFXSema.getScale());
- APSInt Result;
- if (CommonFXSema.isSigned()) {
- APInt Rem;
- APInt::sdivrem(ThisVal, OtherVal, Result, Rem);
- // If the quotient is negative and the remainder is nonzero, round
- // towards negative infinity by subtracting epsilon from the result.
- if (ThisVal.isNegative() != OtherVal.isNegative() && !Rem.isNullValue())
- Result = Result - 1;
- } else
- Result = ThisVal.udiv(OtherVal);
- Result.setIsSigned(CommonFXSema.isSigned());
-
- // If our result lies outside of the representative range of the common
- // semantic, we either have overflow or saturation.
- APSInt Max = APFixedPoint::getMax(CommonFXSema).getValue()
- .extOrTrunc(Wide);
- APSInt Min = APFixedPoint::getMin(CommonFXSema).getValue()
- .extOrTrunc(Wide);
- if (CommonFXSema.isSaturated()) {
- if (Result < Min)
- Result = Min;
- else if (Result > Max)
- Result = Max;
- } else
- Overflowed = Result < Min || Result > Max;
-
- if (Overflow)
- *Overflow = Overflowed;
-
- return APFixedPoint(Result.sextOrTrunc(CommonFXSema.getWidth()),
- CommonFXSema);
-}
-
-APFixedPoint APFixedPoint::shl(unsigned Amt, bool *Overflow) const {
- APSInt ThisVal = Val;
- bool Overflowed = false;
-
- // Widen the LHS.
- unsigned Wide = Sema.getWidth() * 2;
- if (Sema.isSigned())
- ThisVal = ThisVal.sextOrSelf(Wide);
- else
- ThisVal = ThisVal.zextOrSelf(Wide);
-
- // Clamp the shift amount at the original width, and perform the shift.
- Amt = std::min(Amt, ThisVal.getBitWidth());
- APSInt Result = ThisVal << Amt;
- Result.setIsSigned(Sema.isSigned());
-
- // If our result lies outside of the representative range of the
- // semantic, we either have overflow or saturation.
- APSInt Max = APFixedPoint::getMax(Sema).getValue().extOrTrunc(Wide);
- APSInt Min = APFixedPoint::getMin(Sema).getValue().extOrTrunc(Wide);
- if (Sema.isSaturated()) {
- if (Result < Min)
- Result = Min;
- else if (Result > Max)
- Result = Max;
- } else
- Overflowed = Result < Min || Result > Max;
-
- if (Overflow)
- *Overflow = Overflowed;
-
- return APFixedPoint(Result.sextOrTrunc(Sema.getWidth()), Sema);
-}
-
-void APFixedPoint::toString(SmallVectorImpl<char> &Str) const {
- APSInt Val = getValue();
- unsigned Scale = getScale();
-
- if (Val.isSigned() && Val.isNegative() && Val != -Val) {
- Val = -Val;
- Str.push_back('-');
- }
-
- APSInt IntPart = Val >> Scale;
-
- // Add 4 digits to hold the value after multiplying 10 (the radix)
- unsigned Width = Val.getBitWidth() + 4;
- APInt FractPart = Val.zextOrTrunc(Scale).zext(Width);
- APInt FractPartMask = APInt::getAllOnesValue(Scale).zext(Width);
- APInt RadixInt = APInt(Width, 10);
-
- IntPart.toString(Str, /*Radix=*/10);
- Str.push_back('.');
- do {
- (FractPart * RadixInt)
- .lshr(Scale)
- .toString(Str, /*Radix=*/10, Val.isSigned());
- FractPart = (FractPart * RadixInt) & FractPartMask;
- } while (FractPart != 0);
-}
-
-APFixedPoint APFixedPoint::negate(bool *Overflow) const {
- if (!isSaturated()) {
- if (Overflow)
- *Overflow =
- (!isSigned() && Val != 0) || (isSigned() && Val.isMinSignedValue());
- return APFixedPoint(-Val, Sema);
- }
-
- // We never overflow for saturation
- if (Overflow)
- *Overflow = false;
-
- if (isSigned())
- return Val.isMinSignedValue() ? getMax(Sema) : APFixedPoint(-Val, Sema);
- else
- return APFixedPoint(Sema);
-}
-
-APSInt APFixedPoint::convertToInt(unsigned DstWidth, bool DstSign,
- bool *Overflow) const {
- APSInt Result = getIntPart();
- unsigned SrcWidth = getWidth();
-
- APSInt DstMin = APSInt::getMinValue(DstWidth, !DstSign);
- APSInt DstMax = APSInt::getMaxValue(DstWidth, !DstSign);
-
- if (SrcWidth < DstWidth) {
- Result = Result.extend(DstWidth);
- } else if (SrcWidth > DstWidth) {
- DstMin = DstMin.extend(SrcWidth);
- DstMax = DstMax.extend(SrcWidth);
- }
-
- if (Overflow) {
- if (Result.isSigned() && !DstSign) {
- *Overflow = Result.isNegative() || Result.ugt(DstMax);
- } else if (Result.isUnsigned() && DstSign) {
- *Overflow = Result.ugt(DstMax);
- } else {
- *Overflow = Result < DstMin || Result > DstMax;
- }
- }
-
- Result.setIsSigned(DstSign);
- return Result.extOrTrunc(DstWidth);
-}
-
-const fltSemantics *APFixedPoint::promoteFloatSemantics(const fltSemantics *S) {
- if (S == &APFloat::BFloat())
- return &APFloat::IEEEdouble();
- else if (S == &APFloat::IEEEhalf())
- return &APFloat::IEEEsingle();
- else if (S == &APFloat::IEEEsingle())
- return &APFloat::IEEEdouble();
- else if (S == &APFloat::IEEEdouble())
- return &APFloat::IEEEquad();
- llvm_unreachable("Could not promote float type!");
-}
-
-APFloat APFixedPoint::convertToFloat(const fltSemantics &FloatSema) const {
- // For some operations, rounding mode has an effect on the result, while
- // other operations are lossless and should never result in rounding.
- // To signify which these operations are, we define two rounding modes here.
- APFloat::roundingMode RM = APFloat::rmNearestTiesToEven;
- APFloat::roundingMode LosslessRM = APFloat::rmTowardZero;
-
- // Make sure that we are operating in a type that works with this fixed-point
- // semantic.
- const fltSemantics *OpSema = &FloatSema;
- while (!Sema.fitsInFloatSemantics(*OpSema))
- OpSema = promoteFloatSemantics(OpSema);
-
- // Convert the fixed point value bits as an integer. If the floating point
- // value does not have the required precision, we will round according to the
- // given mode.
- APFloat Flt(*OpSema);
- APFloat::opStatus S = Flt.convertFromAPInt(Val, Sema.isSigned(), RM);
-
- // If we cared about checking for precision loss, we could look at this
- // status.
- (void)S;
-
- // Scale down the integer value in the float to match the correct scaling
- // factor.
- APFloat ScaleFactor(std::pow(2, -(int)Sema.getScale()));
- bool Ignored;
- ScaleFactor.convert(*OpSema, LosslessRM, &Ignored);
- Flt.multiply(ScaleFactor, LosslessRM);
-
- if (OpSema != &FloatSema)
- Flt.convert(FloatSema, RM, &Ignored);
-
- return Flt;
-}
-
-APFixedPoint APFixedPoint::getFromIntValue(const APSInt &Value,
- const FixedPointSemantics &DstFXSema,
- bool *Overflow) {
- FixedPointSemantics IntFXSema = FixedPointSemantics::GetIntegerSemantics(
- Value.getBitWidth(), Value.isSigned());
- return APFixedPoint(Value, IntFXSema).convert(DstFXSema, Overflow);
-}
-
-APFixedPoint
-APFixedPoint::getFromFloatValue(const APFloat &Value,
- const FixedPointSemantics &DstFXSema,
- bool *Overflow) {
- // For some operations, rounding mode has an effect on the result, while
- // other operations are lossless and should never result in rounding.
- // To signify which these operations are, we define two rounding modes here,
- // even though they are the same mode.
- APFloat::roundingMode RM = APFloat::rmTowardZero;
- APFloat::roundingMode LosslessRM = APFloat::rmTowardZero;
-
- const fltSemantics &FloatSema = Value.getSemantics();
-
- if (Value.isNaN()) {
- // Handle NaN immediately.
- if (Overflow)
- *Overflow = true;
- return APFixedPoint(DstFXSema);
- }
-
- // Make sure that we are operating in a type that works with this fixed-point
- // semantic.
- const fltSemantics *OpSema = &FloatSema;
- while (!DstFXSema.fitsInFloatSemantics(*OpSema))
- OpSema = promoteFloatSemantics(OpSema);
-
- APFloat Val = Value;
-
- bool Ignored;
- if (&FloatSema != OpSema)
- Val.convert(*OpSema, LosslessRM, &Ignored);
-
- // Scale up the float so that the 'fractional' part of the mantissa ends up in
- // the integer range instead. Rounding mode is irrelevant here.
- // It is fine if this overflows to infinity even for saturating types,
- // since we will use floating point comparisons to check for saturation.
- APFloat ScaleFactor(std::pow(2, DstFXSema.getScale()));
- ScaleFactor.convert(*OpSema, LosslessRM, &Ignored);
- Val.multiply(ScaleFactor, LosslessRM);
-
- // Convert to the integral representation of the value. This rounding mode
- // is significant.
- APSInt Res(DstFXSema.getWidth(), !DstFXSema.isSigned());
- Val.convertToInteger(Res, RM, &Ignored);
-
- // Round the integral value and scale back. This makes the
- // overflow calculations below work properly. If we do not round here,
- // we risk checking for overflow with a value that is outside the
- // representable range of the fixed-point semantic even though no overflow
- // would occur had we rounded first.
- ScaleFactor = APFloat(std::pow(2, -(int)DstFXSema.getScale()));
- ScaleFactor.convert(*OpSema, LosslessRM, &Ignored);
- Val.roundToIntegral(RM);
- Val.multiply(ScaleFactor, LosslessRM);
-
- // Check for overflow/saturation by checking if the floating point value
- // is outside the range representable by the fixed-point value.
- APFloat FloatMax = getMax(DstFXSema).convertToFloat(*OpSema);
- APFloat FloatMin = getMin(DstFXSema).convertToFloat(*OpSema);
- bool Overflowed = false;
- if (DstFXSema.isSaturated()) {
- if (Val > FloatMax)
- Res = getMax(DstFXSema).getValue();
- else if (Val < FloatMin)
- Res = getMin(DstFXSema).getValue();
- } else
- Overflowed = Val > FloatMax || Val < FloatMin;
-
- if (Overflow)
- *Overflow = Overflowed;
-
- return APFixedPoint(Res, DstFXSema);
-}
-
-} // namespace llvm
+//===- APFixedPoint.cpp - Fixed point constant handling ---------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+/// \file
+/// Defines the implementation for the fixed point number interface.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/APFixedPoint.h"
+#include "llvm/ADT/APFloat.h"
+
+namespace llvm {
+
+APFixedPoint APFixedPoint::convert(const FixedPointSemantics &DstSema,
+ bool *Overflow) const {
+ APSInt NewVal = Val;
+ unsigned DstWidth = DstSema.getWidth();
+ unsigned DstScale = DstSema.getScale();
+ bool Upscaling = DstScale > getScale();
+ if (Overflow)
+ *Overflow = false;
+
+ if (Upscaling) {
+ NewVal = NewVal.extend(NewVal.getBitWidth() + DstScale - getScale());
+ NewVal <<= (DstScale - getScale());
+ } else {
+ NewVal >>= (getScale() - DstScale);
+ }
+
+ auto Mask = APInt::getBitsSetFrom(
+ NewVal.getBitWidth(),
+ std::min(DstScale + DstSema.getIntegralBits(), NewVal.getBitWidth()));
+ APInt Masked(NewVal & Mask);
+
+ // Change in the bits above the sign
+ if (!(Masked == Mask || Masked == 0)) {
+ // Found overflow in the bits above the sign
+ if (DstSema.isSaturated())
+ NewVal = NewVal.isNegative() ? Mask : ~Mask;
+ else if (Overflow)
+ *Overflow = true;
+ }
+
+ // If the dst semantics are unsigned, but our value is signed and negative, we
+ // clamp to zero.
+ if (!DstSema.isSigned() && NewVal.isSigned() && NewVal.isNegative()) {
+ // Found negative overflow for unsigned result
+ if (DstSema.isSaturated())
+ NewVal = 0;
+ else if (Overflow)
+ *Overflow = true;
+ }
+
+ NewVal = NewVal.extOrTrunc(DstWidth);
+ NewVal.setIsSigned(DstSema.isSigned());
+ return APFixedPoint(NewVal, DstSema);
+}
+
+int APFixedPoint::compare(const APFixedPoint &Other) const {
+ APSInt ThisVal = getValue();
+ APSInt OtherVal = Other.getValue();
+ bool ThisSigned = Val.isSigned();
+ bool OtherSigned = OtherVal.isSigned();
+ unsigned OtherScale = Other.getScale();
+ unsigned OtherWidth = OtherVal.getBitWidth();
+
+ unsigned CommonWidth = std::max(Val.getBitWidth(), OtherWidth);
+
+ // Prevent overflow in the event the widths are the same but the scales differ
+ CommonWidth += getScale() >= OtherScale ? getScale() - OtherScale
+ : OtherScale - getScale();
+
+ ThisVal = ThisVal.extOrTrunc(CommonWidth);
+ OtherVal = OtherVal.extOrTrunc(CommonWidth);
+
+ unsigned CommonScale = std::max(getScale(), OtherScale);
+ ThisVal = ThisVal.shl(CommonScale - getScale());
+ OtherVal = OtherVal.shl(CommonScale - OtherScale);
+
+ if (ThisSigned && OtherSigned) {
+ if (ThisVal.sgt(OtherVal))
+ return 1;
+ else if (ThisVal.slt(OtherVal))
+ return -1;
+ } else if (!ThisSigned && !OtherSigned) {
+ if (ThisVal.ugt(OtherVal))
+ return 1;
+ else if (ThisVal.ult(OtherVal))
+ return -1;
+ } else if (ThisSigned && !OtherSigned) {
+ if (ThisVal.isSignBitSet())
+ return -1;
+ else if (ThisVal.ugt(OtherVal))
+ return 1;
+ else if (ThisVal.ult(OtherVal))
+ return -1;
+ } else {
+ // !ThisSigned && OtherSigned
+ if (OtherVal.isSignBitSet())
+ return 1;
+ else if (ThisVal.ugt(OtherVal))
+ return 1;
+ else if (ThisVal.ult(OtherVal))
+ return -1;
+ }
+
+ return 0;
+}
+
+APFixedPoint APFixedPoint::getMax(const FixedPointSemantics &Sema) {
+ bool IsUnsigned = !Sema.isSigned();
+ auto Val = APSInt::getMaxValue(Sema.getWidth(), IsUnsigned);
+ if (IsUnsigned && Sema.hasUnsignedPadding())
+ Val = Val.lshr(1);
+ return APFixedPoint(Val, Sema);
+}
+
+APFixedPoint APFixedPoint::getMin(const FixedPointSemantics &Sema) {
+ auto Val = APSInt::getMinValue(Sema.getWidth(), !Sema.isSigned());
+ return APFixedPoint(Val, Sema);
+}
+
+bool FixedPointSemantics::fitsInFloatSemantics(
+ const fltSemantics &FloatSema) const {
+ // A fixed point semantic fits in a floating point semantic if the maximum
+ // and minimum values as integers of the fixed point semantic can fit in the
+ // floating point semantic.
+
+ // If these values do not fit, then a floating point rescaling of the true
+ // maximum/minimum value will not fit either, so the floating point semantic
+ // cannot be used to perform such a rescaling.
+
+ APSInt MaxInt = APFixedPoint::getMax(*this).getValue();
+ APFloat F(FloatSema);
+ APFloat::opStatus Status = F.convertFromAPInt(MaxInt, MaxInt.isSigned(),
+ APFloat::rmNearestTiesToAway);
+ if ((Status & APFloat::opOverflow) || !isSigned())
+ return !(Status & APFloat::opOverflow);
+
+ APSInt MinInt = APFixedPoint::getMin(*this).getValue();
+ Status = F.convertFromAPInt(MinInt, MinInt.isSigned(),
+ APFloat::rmNearestTiesToAway);
+ return !(Status & APFloat::opOverflow);
+}
+
+FixedPointSemantics FixedPointSemantics::getCommonSemantics(
+ const FixedPointSemantics &Other) const {
+ unsigned CommonScale = std::max(getScale(), Other.getScale());
+ unsigned CommonWidth =
+ std::max(getIntegralBits(), Other.getIntegralBits()) + CommonScale;
+
+ bool ResultIsSigned = isSigned() || Other.isSigned();
+ bool ResultIsSaturated = isSaturated() || Other.isSaturated();
+ bool ResultHasUnsignedPadding = false;
+ if (!ResultIsSigned) {
+ // Both are unsigned.
+ ResultHasUnsignedPadding = hasUnsignedPadding() &&
+ Other.hasUnsignedPadding() && !ResultIsSaturated;
+ }
+
+ // If the result is signed, add an extra bit for the sign. Otherwise, if it is
+ // unsigned and has unsigned padding, we only need to add the extra padding
+ // bit back if we are not saturating.
+ if (ResultIsSigned || ResultHasUnsignedPadding)
+ CommonWidth++;
+
+ return FixedPointSemantics(CommonWidth, CommonScale, ResultIsSigned,
+ ResultIsSaturated, ResultHasUnsignedPadding);
+}
+
+APFixedPoint APFixedPoint::add(const APFixedPoint &Other,
+ bool *Overflow) const {
+ auto CommonFXSema = Sema.getCommonSemantics(Other.getSemantics());
+ APFixedPoint ConvertedThis = convert(CommonFXSema);
+ APFixedPoint ConvertedOther = Other.convert(CommonFXSema);
+ APSInt ThisVal = ConvertedThis.getValue();
+ APSInt OtherVal = ConvertedOther.getValue();
+ bool Overflowed = false;
+
+ APSInt Result;
+ if (CommonFXSema.isSaturated()) {
+ Result = CommonFXSema.isSigned() ? ThisVal.sadd_sat(OtherVal)
+ : ThisVal.uadd_sat(OtherVal);
+ } else {
+ Result = ThisVal.isSigned() ? ThisVal.sadd_ov(OtherVal, Overflowed)
+ : ThisVal.uadd_ov(OtherVal, Overflowed);
+ }
+
+ if (Overflow)
+ *Overflow = Overflowed;
+
+ return APFixedPoint(Result, CommonFXSema);
+}
+
+APFixedPoint APFixedPoint::sub(const APFixedPoint &Other,
+ bool *Overflow) const {
+ auto CommonFXSema = Sema.getCommonSemantics(Other.getSemantics());
+ APFixedPoint ConvertedThis = convert(CommonFXSema);
+ APFixedPoint ConvertedOther = Other.convert(CommonFXSema);
+ APSInt ThisVal = ConvertedThis.getValue();
+ APSInt OtherVal = ConvertedOther.getValue();
+ bool Overflowed = false;
+
+ APSInt Result;
+ if (CommonFXSema.isSaturated()) {
+ Result = CommonFXSema.isSigned() ? ThisVal.ssub_sat(OtherVal)
+ : ThisVal.usub_sat(OtherVal);
+ } else {
+ Result = ThisVal.isSigned() ? ThisVal.ssub_ov(OtherVal, Overflowed)
+ : ThisVal.usub_ov(OtherVal, Overflowed);
+ }
+
+ if (Overflow)
+ *Overflow = Overflowed;
+
+ return APFixedPoint(Result, CommonFXSema);
+}
+
+APFixedPoint APFixedPoint::mul(const APFixedPoint &Other,
+ bool *Overflow) const {
+ auto CommonFXSema = Sema.getCommonSemantics(Other.getSemantics());
+ APFixedPoint ConvertedThis = convert(CommonFXSema);
+ APFixedPoint ConvertedOther = Other.convert(CommonFXSema);
+ APSInt ThisVal = ConvertedThis.getValue();
+ APSInt OtherVal = ConvertedOther.getValue();
+ bool Overflowed = false;
+
+ // Widen the LHS and RHS so we can perform a full multiplication.
+ unsigned Wide = CommonFXSema.getWidth() * 2;
+ if (CommonFXSema.isSigned()) {
+ ThisVal = ThisVal.sextOrSelf(Wide);
+ OtherVal = OtherVal.sextOrSelf(Wide);
+ } else {
+ ThisVal = ThisVal.zextOrSelf(Wide);
+ OtherVal = OtherVal.zextOrSelf(Wide);
+ }
+
+ // Perform the full multiplication and downscale to get the same scale.
+ //
+ // Note that the right shifts here perform an implicit downwards rounding.
+ // This rounding could discard bits that would technically place the result
+ // outside the representable range. We interpret the spec as allowing us to
+ // perform the rounding step first, avoiding the overflow case that would
+ // arise.
+ APSInt Result;
+ if (CommonFXSema.isSigned())
+ Result = ThisVal.smul_ov(OtherVal, Overflowed)
+ .ashr(CommonFXSema.getScale());
+ else
+ Result = ThisVal.umul_ov(OtherVal, Overflowed)
+ .lshr(CommonFXSema.getScale());
+ assert(!Overflowed && "Full multiplication cannot overflow!");
+ Result.setIsSigned(CommonFXSema.isSigned());
+
+ // If our result lies outside of the representative range of the common
+ // semantic, we either have overflow or saturation.
+ APSInt Max = APFixedPoint::getMax(CommonFXSema).getValue()
+ .extOrTrunc(Wide);
+ APSInt Min = APFixedPoint::getMin(CommonFXSema).getValue()
+ .extOrTrunc(Wide);
+ if (CommonFXSema.isSaturated()) {
+ if (Result < Min)
+ Result = Min;
+ else if (Result > Max)
+ Result = Max;
+ } else
+ Overflowed = Result < Min || Result > Max;
+
+ if (Overflow)
+ *Overflow = Overflowed;
+
+ return APFixedPoint(Result.sextOrTrunc(CommonFXSema.getWidth()),
+ CommonFXSema);
+}
+
+APFixedPoint APFixedPoint::div(const APFixedPoint &Other,
+ bool *Overflow) const {
+ auto CommonFXSema = Sema.getCommonSemantics(Other.getSemantics());
+ APFixedPoint ConvertedThis = convert(CommonFXSema);
+ APFixedPoint ConvertedOther = Other.convert(CommonFXSema);
+ APSInt ThisVal = ConvertedThis.getValue();
+ APSInt OtherVal = ConvertedOther.getValue();
+ bool Overflowed = false;
+
+ // Widen the LHS and RHS so we can perform a full division.
+ unsigned Wide = CommonFXSema.getWidth() * 2;
+ if (CommonFXSema.isSigned()) {
+ ThisVal = ThisVal.sextOrSelf(Wide);
+ OtherVal = OtherVal.sextOrSelf(Wide);
+ } else {
+ ThisVal = ThisVal.zextOrSelf(Wide);
+ OtherVal = OtherVal.zextOrSelf(Wide);
+ }
+
+ // Upscale to compensate for the loss of precision from division, and
+ // perform the full division.
+ ThisVal = ThisVal.shl(CommonFXSema.getScale());
+ APSInt Result;
+ if (CommonFXSema.isSigned()) {
+ APInt Rem;
+ APInt::sdivrem(ThisVal, OtherVal, Result, Rem);
+ // If the quotient is negative and the remainder is nonzero, round
+ // towards negative infinity by subtracting epsilon from the result.
+ if (ThisVal.isNegative() != OtherVal.isNegative() && !Rem.isNullValue())
+ Result = Result - 1;
+ } else
+ Result = ThisVal.udiv(OtherVal);
+ Result.setIsSigned(CommonFXSema.isSigned());
+
+ // If our result lies outside of the representative range of the common
+ // semantic, we either have overflow or saturation.
+ APSInt Max = APFixedPoint::getMax(CommonFXSema).getValue()
+ .extOrTrunc(Wide);
+ APSInt Min = APFixedPoint::getMin(CommonFXSema).getValue()
+ .extOrTrunc(Wide);
+ if (CommonFXSema.isSaturated()) {
+ if (Result < Min)
+ Result = Min;
+ else if (Result > Max)
+ Result = Max;
+ } else
+ Overflowed = Result < Min || Result > Max;
+
+ if (Overflow)
+ *Overflow = Overflowed;
+
+ return APFixedPoint(Result.sextOrTrunc(CommonFXSema.getWidth()),
+ CommonFXSema);
+}
+
+APFixedPoint APFixedPoint::shl(unsigned Amt, bool *Overflow) const {
+ APSInt ThisVal = Val;
+ bool Overflowed = false;
+
+ // Widen the LHS.
+ unsigned Wide = Sema.getWidth() * 2;
+ if (Sema.isSigned())
+ ThisVal = ThisVal.sextOrSelf(Wide);
+ else
+ ThisVal = ThisVal.zextOrSelf(Wide);
+
+ // Clamp the shift amount at the original width, and perform the shift.
+ Amt = std::min(Amt, ThisVal.getBitWidth());
+ APSInt Result = ThisVal << Amt;
+ Result.setIsSigned(Sema.isSigned());
+
+ // If our result lies outside of the representative range of the
+ // semantic, we either have overflow or saturation.
+ APSInt Max = APFixedPoint::getMax(Sema).getValue().extOrTrunc(Wide);
+ APSInt Min = APFixedPoint::getMin(Sema).getValue().extOrTrunc(Wide);
+ if (Sema.isSaturated()) {
+ if (Result < Min)
+ Result = Min;
+ else if (Result > Max)
+ Result = Max;
+ } else
+ Overflowed = Result < Min || Result > Max;
+
+ if (Overflow)
+ *Overflow = Overflowed;
+
+ return APFixedPoint(Result.sextOrTrunc(Sema.getWidth()), Sema);
+}
+
+void APFixedPoint::toString(SmallVectorImpl<char> &Str) const {
+ APSInt Val = getValue();
+ unsigned Scale = getScale();
+
+ if (Val.isSigned() && Val.isNegative() && Val != -Val) {
+ Val = -Val;
+ Str.push_back('-');
+ }
+
+ APSInt IntPart = Val >> Scale;
+
+ // Add 4 digits to hold the value after multiplying 10 (the radix)
+ unsigned Width = Val.getBitWidth() + 4;
+ APInt FractPart = Val.zextOrTrunc(Scale).zext(Width);
+ APInt FractPartMask = APInt::getAllOnesValue(Scale).zext(Width);
+ APInt RadixInt = APInt(Width, 10);
+
+ IntPart.toString(Str, /*Radix=*/10);
+ Str.push_back('.');
+ do {
+ (FractPart * RadixInt)
+ .lshr(Scale)
+ .toString(Str, /*Radix=*/10, Val.isSigned());
+ FractPart = (FractPart * RadixInt) & FractPartMask;
+ } while (FractPart != 0);
+}
+
+APFixedPoint APFixedPoint::negate(bool *Overflow) const {
+ if (!isSaturated()) {
+ if (Overflow)
+ *Overflow =
+ (!isSigned() && Val != 0) || (isSigned() && Val.isMinSignedValue());
+ return APFixedPoint(-Val, Sema);
+ }
+
+ // We never overflow for saturation
+ if (Overflow)
+ *Overflow = false;
+
+ if (isSigned())
+ return Val.isMinSignedValue() ? getMax(Sema) : APFixedPoint(-Val, Sema);
+ else
+ return APFixedPoint(Sema);
+}
+
+APSInt APFixedPoint::convertToInt(unsigned DstWidth, bool DstSign,
+ bool *Overflow) const {
+ APSInt Result = getIntPart();
+ unsigned SrcWidth = getWidth();
+
+ APSInt DstMin = APSInt::getMinValue(DstWidth, !DstSign);
+ APSInt DstMax = APSInt::getMaxValue(DstWidth, !DstSign);
+
+ if (SrcWidth < DstWidth) {
+ Result = Result.extend(DstWidth);
+ } else if (SrcWidth > DstWidth) {
+ DstMin = DstMin.extend(SrcWidth);
+ DstMax = DstMax.extend(SrcWidth);
+ }
+
+ if (Overflow) {
+ if (Result.isSigned() && !DstSign) {
+ *Overflow = Result.isNegative() || Result.ugt(DstMax);
+ } else if (Result.isUnsigned() && DstSign) {
+ *Overflow = Result.ugt(DstMax);
+ } else {
+ *Overflow = Result < DstMin || Result > DstMax;
+ }
+ }
+
+ Result.setIsSigned(DstSign);
+ return Result.extOrTrunc(DstWidth);
+}
+
+const fltSemantics *APFixedPoint::promoteFloatSemantics(const fltSemantics *S) {
+ if (S == &APFloat::BFloat())
+ return &APFloat::IEEEdouble();
+ else if (S == &APFloat::IEEEhalf())
+ return &APFloat::IEEEsingle();
+ else if (S == &APFloat::IEEEsingle())
+ return &APFloat::IEEEdouble();
+ else if (S == &APFloat::IEEEdouble())
+ return &APFloat::IEEEquad();
+ llvm_unreachable("Could not promote float type!");
+}
+
+APFloat APFixedPoint::convertToFloat(const fltSemantics &FloatSema) const {
+ // For some operations, rounding mode has an effect on the result, while
+ // other operations are lossless and should never result in rounding.
+ // To signify which these operations are, we define two rounding modes here.
+ APFloat::roundingMode RM = APFloat::rmNearestTiesToEven;
+ APFloat::roundingMode LosslessRM = APFloat::rmTowardZero;
+
+ // Make sure that we are operating in a type that works with this fixed-point
+ // semantic.
+ const fltSemantics *OpSema = &FloatSema;
+ while (!Sema.fitsInFloatSemantics(*OpSema))
+ OpSema = promoteFloatSemantics(OpSema);
+
+ // Convert the fixed point value bits as an integer. If the floating point
+ // value does not have the required precision, we will round according to the
+ // given mode.
+ APFloat Flt(*OpSema);
+ APFloat::opStatus S = Flt.convertFromAPInt(Val, Sema.isSigned(), RM);
+
+ // If we cared about checking for precision loss, we could look at this
+ // status.
+ (void)S;
+
+ // Scale down the integer value in the float to match the correct scaling
+ // factor.
+ APFloat ScaleFactor(std::pow(2, -(int)Sema.getScale()));
+ bool Ignored;
+ ScaleFactor.convert(*OpSema, LosslessRM, &Ignored);
+ Flt.multiply(ScaleFactor, LosslessRM);
+
+ if (OpSema != &FloatSema)
+ Flt.convert(FloatSema, RM, &Ignored);
+
+ return Flt;
+}
+
+APFixedPoint APFixedPoint::getFromIntValue(const APSInt &Value,
+ const FixedPointSemantics &DstFXSema,
+ bool *Overflow) {
+ FixedPointSemantics IntFXSema = FixedPointSemantics::GetIntegerSemantics(
+ Value.getBitWidth(), Value.isSigned());
+ return APFixedPoint(Value, IntFXSema).convert(DstFXSema, Overflow);
+}
+
+APFixedPoint
+APFixedPoint::getFromFloatValue(const APFloat &Value,
+ const FixedPointSemantics &DstFXSema,
+ bool *Overflow) {
+ // For some operations, rounding mode has an effect on the result, while
+ // other operations are lossless and should never result in rounding.
+ // To signify which these operations are, we define two rounding modes here,
+ // even though they are the same mode.
+ APFloat::roundingMode RM = APFloat::rmTowardZero;
+ APFloat::roundingMode LosslessRM = APFloat::rmTowardZero;
+
+ const fltSemantics &FloatSema = Value.getSemantics();
+
+ if (Value.isNaN()) {
+ // Handle NaN immediately.
+ if (Overflow)
+ *Overflow = true;
+ return APFixedPoint(DstFXSema);
+ }
+
+ // Make sure that we are operating in a type that works with this fixed-point
+ // semantic.
+ const fltSemantics *OpSema = &FloatSema;
+ while (!DstFXSema.fitsInFloatSemantics(*OpSema))
+ OpSema = promoteFloatSemantics(OpSema);
+
+ APFloat Val = Value;
+
+ bool Ignored;
+ if (&FloatSema != OpSema)
+ Val.convert(*OpSema, LosslessRM, &Ignored);
+
+ // Scale up the float so that the 'fractional' part of the mantissa ends up in
+ // the integer range instead. Rounding mode is irrelevant here.
+ // It is fine if this overflows to infinity even for saturating types,
+ // since we will use floating point comparisons to check for saturation.
+ APFloat ScaleFactor(std::pow(2, DstFXSema.getScale()));
+ ScaleFactor.convert(*OpSema, LosslessRM, &Ignored);
+ Val.multiply(ScaleFactor, LosslessRM);
+
+ // Convert to the integral representation of the value. This rounding mode
+ // is significant.
+ APSInt Res(DstFXSema.getWidth(), !DstFXSema.isSigned());
+ Val.convertToInteger(Res, RM, &Ignored);
+
+ // Round the integral value and scale back. This makes the
+ // overflow calculations below work properly. If we do not round here,
+ // we risk checking for overflow with a value that is outside the
+ // representable range of the fixed-point semantic even though no overflow
+ // would occur had we rounded first.
+ ScaleFactor = APFloat(std::pow(2, -(int)DstFXSema.getScale()));
+ ScaleFactor.convert(*OpSema, LosslessRM, &Ignored);
+ Val.roundToIntegral(RM);
+ Val.multiply(ScaleFactor, LosslessRM);
+
+ // Check for overflow/saturation by checking if the floating point value
+ // is outside the range representable by the fixed-point value.
+ APFloat FloatMax = getMax(DstFXSema).convertToFloat(*OpSema);
+ APFloat FloatMin = getMin(DstFXSema).convertToFloat(*OpSema);
+ bool Overflowed = false;
+ if (DstFXSema.isSaturated()) {
+ if (Val > FloatMax)
+ Res = getMax(DstFXSema).getValue();
+ else if (Val < FloatMin)
+ Res = getMin(DstFXSema).getValue();
+ } else
+ Overflowed = Val > FloatMax || Val < FloatMin;
+
+ if (Overflow)
+ *Overflow = Overflowed;
+
+ return APFixedPoint(Res, DstFXSema);
+}
+
+} // namespace llvm
diff --git a/contrib/libs/llvm12/lib/Support/APFloat.cpp b/contrib/libs/llvm12/lib/Support/APFloat.cpp
index 5dea98ee39..59961d9bab 100644
--- a/contrib/libs/llvm12/lib/Support/APFloat.cpp
+++ b/contrib/libs/llvm12/lib/Support/APFloat.cpp
@@ -755,7 +755,7 @@ void IEEEFloat::copySignificand(const IEEEFloat &rhs) {
void IEEEFloat::makeNaN(bool SNaN, bool Negative, const APInt *fill) {
category = fcNaN;
sign = Negative;
- exponent = exponentNaN();
+ exponent = exponentNaN();
integerPart *significand = significandParts();
unsigned numParts = partCount();
@@ -842,7 +842,7 @@ bool IEEEFloat::isSignificandAllOnes() const {
// Test if the significand excluding the integral bit is all ones. This allows
// us to test for binade boundaries.
const integerPart *Parts = significandParts();
- const unsigned PartCount = partCountForBits(semantics->precision);
+ const unsigned PartCount = partCountForBits(semantics->precision);
for (unsigned i = 0; i < PartCount - 1; i++)
if (~Parts[i])
return false;
@@ -850,8 +850,8 @@ bool IEEEFloat::isSignificandAllOnes() const {
// Set the unused high bits to all ones when we compare.
const unsigned NumHighBits =
PartCount*integerPartWidth - semantics->precision + 1;
- assert(NumHighBits <= integerPartWidth && NumHighBits > 0 &&
- "Can not have more high bits to fill than integerPartWidth");
+ assert(NumHighBits <= integerPartWidth && NumHighBits > 0 &&
+ "Can not have more high bits to fill than integerPartWidth");
const integerPart HighBitFill =
~integerPart(0) << (integerPartWidth - NumHighBits);
if (~(Parts[PartCount - 1] | HighBitFill))
@@ -864,16 +864,16 @@ bool IEEEFloat::isSignificandAllZeros() const {
// Test if the significand excluding the integral bit is all zeros. This
// allows us to test for binade boundaries.
const integerPart *Parts = significandParts();
- const unsigned PartCount = partCountForBits(semantics->precision);
+ const unsigned PartCount = partCountForBits(semantics->precision);
for (unsigned i = 0; i < PartCount - 1; i++)
if (Parts[i])
return false;
- // Compute how many bits are used in the final word.
+ // Compute how many bits are used in the final word.
const unsigned NumHighBits =
PartCount*integerPartWidth - semantics->precision + 1;
- assert(NumHighBits < integerPartWidth && "Can not have more high bits to "
+ assert(NumHighBits < integerPartWidth && "Can not have more high bits to "
"clear than integerPartWidth");
const integerPart HighBitMask = ~integerPart(0) >> NumHighBits;
@@ -927,7 +927,7 @@ IEEEFloat::IEEEFloat(const fltSemantics &ourSemantics, integerPart value) {
IEEEFloat::IEEEFloat(const fltSemantics &ourSemantics) {
initialize(&ourSemantics);
- makeZero(false);
+ makeZero(false);
}
// Delegate to the previous constructor, because later copy constructor may
@@ -2243,14 +2243,14 @@ IEEEFloat::opStatus IEEEFloat::convert(const fltSemantics &toSemantics,
if (!X86SpecialNan && semantics == &semX87DoubleExtended)
APInt::tcSetBit(significandParts(), semantics->precision - 1);
- // Convert of sNaN creates qNaN and raises an exception (invalid op).
- // This also guarantees that a sNaN does not become Inf on a truncation
- // that loses all payload bits.
- if (isSignaling()) {
- makeQuiet();
- fs = opInvalidOp;
- } else {
- fs = opOK;
+ // Convert of sNaN creates qNaN and raises an exception (invalid op).
+ // This also guarantees that a sNaN does not become Inf on a truncation
+ // that loses all payload bits.
+ if (isSignaling()) {
+ makeQuiet();
+ fs = opInvalidOp;
+ } else {
+ fs = opOK;
}
} else {
*losesInfo = false;
@@ -3384,13 +3384,13 @@ void IEEEFloat::initFromF80LongDoubleAPInt(const APInt &api) {
sign = static_cast<unsigned int>(i2>>15);
if (myexponent == 0 && mysignificand == 0) {
- makeZero(sign);
+ makeZero(sign);
} else if (myexponent==0x7fff && mysignificand==0x8000000000000000ULL) {
- makeInf(sign);
+ makeInf(sign);
} else if ((myexponent == 0x7fff && mysignificand != 0x8000000000000000ULL) ||
(myexponent != 0x7fff && myexponent != 0 && myintegerbit == 0)) {
category = fcNaN;
- exponent = exponentNaN();
+ exponent = exponentNaN();
significandParts()[0] = mysignificand;
significandParts()[1] = 0;
} else {
@@ -3441,14 +3441,14 @@ void IEEEFloat::initFromQuadrupleAPInt(const APInt &api) {
sign = static_cast<unsigned int>(i2>>63);
if (myexponent==0 &&
(mysignificand==0 && mysignificand2==0)) {
- makeZero(sign);
+ makeZero(sign);
} else if (myexponent==0x7fff &&
(mysignificand==0 && mysignificand2==0)) {
- makeInf(sign);
+ makeInf(sign);
} else if (myexponent==0x7fff &&
(mysignificand!=0 || mysignificand2 !=0)) {
category = fcNaN;
- exponent = exponentNaN();
+ exponent = exponentNaN();
significandParts()[0] = mysignificand;
significandParts()[1] = mysignificand2;
} else {
@@ -3474,12 +3474,12 @@ void IEEEFloat::initFromDoubleAPInt(const APInt &api) {
sign = static_cast<unsigned int>(i>>63);
if (myexponent==0 && mysignificand==0) {
- makeZero(sign);
+ makeZero(sign);
} else if (myexponent==0x7ff && mysignificand==0) {
- makeInf(sign);
+ makeInf(sign);
} else if (myexponent==0x7ff && mysignificand!=0) {
category = fcNaN;
- exponent = exponentNaN();
+ exponent = exponentNaN();
*significandParts() = mysignificand;
} else {
category = fcNormal;
@@ -3503,12 +3503,12 @@ void IEEEFloat::initFromFloatAPInt(const APInt &api) {
sign = i >> 31;
if (myexponent==0 && mysignificand==0) {
- makeZero(sign);
+ makeZero(sign);
} else if (myexponent==0xff && mysignificand==0) {
- makeInf(sign);
+ makeInf(sign);
} else if (myexponent==0xff && mysignificand!=0) {
category = fcNaN;
- exponent = exponentNaN();
+ exponent = exponentNaN();
*significandParts() = mysignificand;
} else {
category = fcNormal;
@@ -3532,12 +3532,12 @@ void IEEEFloat::initFromBFloatAPInt(const APInt &api) {
sign = i >> 15;
if (myexponent == 0 && mysignificand == 0) {
- makeZero(sign);
+ makeZero(sign);
} else if (myexponent == 0xff && mysignificand == 0) {
- makeInf(sign);
+ makeInf(sign);
} else if (myexponent == 0xff && mysignificand != 0) {
category = fcNaN;
- exponent = exponentNaN();
+ exponent = exponentNaN();
*significandParts() = mysignificand;
} else {
category = fcNormal;
@@ -3561,12 +3561,12 @@ void IEEEFloat::initFromHalfAPInt(const APInt &api) {
sign = i >> 15;
if (myexponent==0 && mysignificand==0) {
- makeZero(sign);
+ makeZero(sign);
} else if (myexponent==0x1f && mysignificand==0) {
- makeInf(sign);
+ makeInf(sign);
} else if (myexponent==0x1f && mysignificand!=0) {
category = fcNaN;
- exponent = exponentNaN();
+ exponent = exponentNaN();
*significandParts() = mysignificand;
} else {
category = fcNormal;
@@ -4124,29 +4124,29 @@ IEEEFloat::opStatus IEEEFloat::next(bool nextDown) {
return result;
}
-APFloatBase::ExponentType IEEEFloat::exponentNaN() const {
- return semantics->maxExponent + 1;
-}
-
-APFloatBase::ExponentType IEEEFloat::exponentInf() const {
- return semantics->maxExponent + 1;
-}
-
-APFloatBase::ExponentType IEEEFloat::exponentZero() const {
- return semantics->minExponent - 1;
-}
-
+APFloatBase::ExponentType IEEEFloat::exponentNaN() const {
+ return semantics->maxExponent + 1;
+}
+
+APFloatBase::ExponentType IEEEFloat::exponentInf() const {
+ return semantics->maxExponent + 1;
+}
+
+APFloatBase::ExponentType IEEEFloat::exponentZero() const {
+ return semantics->minExponent - 1;
+}
+
void IEEEFloat::makeInf(bool Negative) {
category = fcInfinity;
sign = Negative;
- exponent = exponentInf();
+ exponent = exponentInf();
APInt::tcSet(significandParts(), 0, partCount());
}
void IEEEFloat::makeZero(bool Negative) {
category = fcZero;
sign = Negative;
- exponent = exponentZero();
+ exponent = exponentZero();
APInt::tcSet(significandParts(), 0, partCount());
}
@@ -4874,6 +4874,6 @@ APFloat::opStatus APFloat::convertToInteger(APSInt &result,
return status;
}
-} // namespace llvm
+} // namespace llvm
#undef APFLOAT_DISPATCH_ON_SEMANTICS
diff --git a/contrib/libs/llvm12/lib/Support/APInt.cpp b/contrib/libs/llvm12/lib/Support/APInt.cpp
index 12ceb2df11..895e530a59 100644
--- a/contrib/libs/llvm12/lib/Support/APInt.cpp
+++ b/contrib/libs/llvm12/lib/Support/APInt.cpp
@@ -338,7 +338,7 @@ void APInt::flipAllBitsSlowCase() {
/// Toggles a given bit to its opposite value.
void APInt::flipBit(unsigned bitPosition) {
assert(bitPosition < BitWidth && "Out of the bit-width range!");
- setBitVal(bitPosition, !(*this)[bitPosition]);
+ setBitVal(bitPosition, !(*this)[bitPosition]);
}
void APInt::insertBits(const APInt &subBits, unsigned bitPosition) {
@@ -392,8 +392,8 @@ void APInt::insertBits(const APInt &subBits, unsigned bitPosition) {
// General case - set/clear individual bits in dst based on src.
// TODO - there is scope for optimization here, but at the moment this code
// path is barely used so prefer readability over performance.
- for (unsigned i = 0; i != subBitWidth; ++i)
- setBitVal(bitPosition + i, subBits[i]);
+ for (unsigned i = 0; i != subBitWidth; ++i)
+ setBitVal(bitPosition + i, subBits[i]);
}
void APInt::insertBits(uint64_t subBits, unsigned bitPosition, unsigned numBits) {
@@ -961,12 +961,12 @@ APInt APInt::sextOrTrunc(unsigned width) const {
return *this;
}
-APInt APInt::truncOrSelf(unsigned width) const {
- if (BitWidth > width)
- return trunc(width);
- return *this;
-}
-
+APInt APInt::truncOrSelf(unsigned width) const {
+ if (BitWidth > width)
+ return trunc(width);
+ return *this;
+}
+
APInt APInt::zextOrSelf(unsigned width) const {
if (BitWidth < width)
return zext(width);
diff --git a/contrib/libs/llvm12/lib/Support/ARMAttributeParser.cpp b/contrib/libs/llvm12/lib/Support/ARMAttributeParser.cpp
index 459691923a..5076d8548e 100644
--- a/contrib/libs/llvm12/lib/Support/ARMAttributeParser.cpp
+++ b/contrib/libs/llvm12/lib/Support/ARMAttributeParser.cpp
@@ -113,7 +113,7 @@ Error ARMAttributeParser::ARM_ISA_use(AttrType tag) {
}
Error ARMAttributeParser::THUMB_ISA_use(AttrType tag) {
- static const char *strings[] = {"Not Permitted", "Thumb-1", "Thumb-2", "Permitted"};
+ static const char *strings[] = {"Not Permitted", "Thumb-1", "Thumb-2", "Permitted"};
return parseStringAttribute("THUMB_ISA_use", tag, makeArrayRef(strings));
}
diff --git a/contrib/libs/llvm12/lib/Support/ARMTargetParser.cpp b/contrib/libs/llvm12/lib/Support/ARMTargetParser.cpp
index eb425cbb1d..028fb5d413 100644
--- a/contrib/libs/llvm12/lib/Support/ARMTargetParser.cpp
+++ b/contrib/libs/llvm12/lib/Support/ARMTargetParser.cpp
@@ -76,7 +76,7 @@ unsigned ARM::parseArchVersion(StringRef Arch) {
case ArchKind::ARMV8_4A:
case ArchKind::ARMV8_5A:
case ArchKind::ARMV8_6A:
- case ArchKind::ARMV8_7A:
+ case ArchKind::ARMV8_7A:
case ArchKind::ARMV8R:
case ArchKind::ARMV8MBaseline:
case ArchKind::ARMV8MMainline:
@@ -112,7 +112,7 @@ ARM::ProfileKind ARM::parseArchProfile(StringRef Arch) {
case ArchKind::ARMV8_4A:
case ArchKind::ARMV8_5A:
case ArchKind::ARMV8_6A:
- case ArchKind::ARMV8_7A:
+ case ArchKind::ARMV8_7A:
return ProfileKind::A;
case ArchKind::ARMV2:
case ArchKind::ARMV2A:
@@ -156,7 +156,7 @@ StringRef ARM::getArchSynonym(StringRef Arch) {
.Case("v8.4a", "v8.4-a")
.Case("v8.5a", "v8.5-a")
.Case("v8.6a", "v8.6-a")
- .Case("v8.7a", "v8.7-a")
+ .Case("v8.7a", "v8.7-a")
.Case("v8r", "v8-r")
.Case("v8m.base", "v8-m.base")
.Case("v8m.main", "v8-m.main")
@@ -258,7 +258,7 @@ ARM::ISAKind ARM::parseArchISA(StringRef Arch) {
unsigned ARM::parseFPU(StringRef FPU) {
StringRef Syn = getFPUSynonym(FPU);
- for (const auto &F : FPUNames) {
+ for (const auto &F : FPUNames) {
if (Syn == F.getName())
return F.ID;
}
@@ -283,8 +283,8 @@ StringRef ARM::getCanonicalArchName(StringRef Arch) {
// Begins with "arm" / "thumb", move past it.
if (A.startswith("arm64_32"))
offset = 8;
- else if (A.startswith("arm64e"))
- offset = 6;
+ else if (A.startswith("arm64e"))
+ offset = 6;
else if (A.startswith("arm64"))
offset = 5;
else if (A.startswith("aarch64_32"))
@@ -414,7 +414,7 @@ bool ARM::getExtensionFeatures(uint64_t Extensions,
if (Extensions == AEK_INVALID)
return false;
- for (const auto &AE : ARCHExtNames) {
+ for (const auto &AE : ARCHExtNames) {
if ((Extensions & AE.ID) == AE.ID && AE.Feature)
Features.push_back(AE.Feature);
else if (AE.NegFeature)
@@ -441,7 +441,7 @@ unsigned ARM::getArchAttr(ARM::ArchKind AK) {
}
StringRef ARM::getArchExtName(uint64_t ArchExtKind) {
- for (const auto &AE : ARCHExtNames) {
+ for (const auto &AE : ARCHExtNames) {
if (ArchExtKind == AE.ID)
return AE.getName();
}
@@ -458,7 +458,7 @@ static bool stripNegationPrefix(StringRef &Name) {
StringRef ARM::getArchExtFeature(StringRef ArchExt) {
bool Negated = stripNegationPrefix(ArchExt);
- for (const auto &AE : ARCHExtNames) {
+ for (const auto &AE : ARCHExtNames) {
if (AE.Feature && ArchExt == AE.getName())
return StringRef(Negated ? AE.NegFeature : AE.Feature);
}
@@ -495,10 +495,10 @@ static unsigned findDoublePrecisionFPU(unsigned InputFPUKind) {
return ARM::FK_INVALID;
}
-bool ARM::appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK,
- StringRef ArchExt,
- std::vector<StringRef> &Features,
- unsigned &ArgFPUID) {
+bool ARM::appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK,
+ StringRef ArchExt,
+ std::vector<StringRef> &Features,
+ unsigned &ArgFPUID) {
size_t StartingNumFeatures = Features.size();
const bool Negated = stripNegationPrefix(ArchExt);
@@ -507,7 +507,7 @@ bool ARM::appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK,
if (ID == AEK_INVALID)
return false;
- for (const auto &AE : ARCHExtNames) {
+ for (const auto &AE : ARCHExtNames) {
if (Negated) {
if ((AE.ID & ID) == ID && AE.NegFeature)
Features.push_back(AE.NegFeature);
@@ -533,14 +533,14 @@ bool ARM::appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK,
} else {
FPUKind = getDefaultFPU(CPU, AK);
}
- ArgFPUID = FPUKind;
+ ArgFPUID = FPUKind;
return ARM::getFPUFeatures(FPUKind, Features);
}
return StartingNumFeatures != Features.size();
}
StringRef ARM::getHWDivName(uint64_t HWDivKind) {
- for (const auto &D : HWDivNames) {
+ for (const auto &D : HWDivNames) {
if (HWDivKind == D.ID)
return D.getName();
}
@@ -553,7 +553,7 @@ StringRef ARM::getDefaultCPU(StringRef Arch) {
return StringRef();
// Look for multiple AKs to find the default for pair AK+Name.
- for (const auto &CPU : CPUNames) {
+ for (const auto &CPU : CPUNames) {
if (CPU.ArchID == AK && CPU.Default)
return CPU.getName();
}
@@ -564,7 +564,7 @@ StringRef ARM::getDefaultCPU(StringRef Arch) {
uint64_t ARM::parseHWDiv(StringRef HWDiv) {
StringRef Syn = getHWDivSynonym(HWDiv);
- for (const auto &D : HWDivNames) {
+ for (const auto &D : HWDivNames) {
if (Syn == D.getName())
return D.ID;
}
@@ -572,7 +572,7 @@ uint64_t ARM::parseHWDiv(StringRef HWDiv) {
}
uint64_t ARM::parseArchExt(StringRef ArchExt) {
- for (const auto &A : ARCHExtNames) {
+ for (const auto &A : ARCHExtNames) {
if (ArchExt == A.getName())
return A.ID;
}
@@ -580,7 +580,7 @@ uint64_t ARM::parseArchExt(StringRef ArchExt) {
}
ARM::ArchKind ARM::parseCPUArch(StringRef CPU) {
- for (const auto &C : CPUNames) {
+ for (const auto &C : CPUNames) {
if (CPU == C.getName())
return C.ArchID;
}
diff --git a/contrib/libs/llvm12/lib/Support/CRC.cpp b/contrib/libs/llvm12/lib/Support/CRC.cpp
index 2bc668beed..58d18eb89c 100644
--- a/contrib/libs/llvm12/lib/Support/CRC.cpp
+++ b/contrib/libs/llvm12/lib/Support/CRC.cpp
@@ -25,7 +25,7 @@
using namespace llvm;
-#if !LLVM_ENABLE_ZLIB
+#if !LLVM_ENABLE_ZLIB
static const uint32_t CRCTable[256] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
diff --git a/contrib/libs/llvm12/lib/Support/CachePruning.cpp b/contrib/libs/llvm12/lib/Support/CachePruning.cpp
index 5c5759ffba..ed9825af35 100644
--- a/contrib/libs/llvm12/lib/Support/CachePruning.cpp
+++ b/contrib/libs/llvm12/lib/Support/CachePruning.cpp
@@ -211,12 +211,12 @@ bool llvm::pruneCache(StringRef Path, CachePruningPolicy Policy) {
// Walk all of the files within this directory.
for (sys::fs::directory_iterator File(CachePathNative, EC), FileEnd;
File != FileEnd && !EC; File.increment(EC)) {
- // Ignore filenames not beginning with "llvmcache-" or "Thin-". This
+ // Ignore filenames not beginning with "llvmcache-" or "Thin-". This
// includes the timestamp file as well as any files created by the user.
// This acts as a safeguard against data loss if the user specifies the
// wrong directory as their cache directory.
- StringRef filename = sys::path::filename(File->path());
- if (!filename.startswith("llvmcache-") && !filename.startswith("Thin-"))
+ StringRef filename = sys::path::filename(File->path());
+ if (!filename.startswith("llvmcache-") && !filename.startswith("Thin-"))
continue;
// Look at this file. If we can't stat it, there's nothing interesting
diff --git a/contrib/libs/llvm12/lib/Support/CommandLine.cpp b/contrib/libs/llvm12/lib/Support/CommandLine.cpp
index 123a23a524..fef6bc3687 100644
--- a/contrib/libs/llvm12/lib/Support/CommandLine.cpp
+++ b/contrib/libs/llvm12/lib/Support/CommandLine.cpp
@@ -464,7 +464,7 @@ void Option::addCategory(OptionCategory &C) {
// must be explicitly added if you want multiple categories that include it.
if (&C != &GeneralCategory && Categories[0] == &GeneralCategory)
Categories[0] = &C;
- else if (!is_contained(Categories, &C))
+ else if (!is_contained(Categories, &C))
Categories.push_back(&C);
}
@@ -531,7 +531,7 @@ Option *CommandLineParser::LookupOption(SubCommand &Sub, StringRef &Arg,
// If we have an equals sign, remember the value.
if (EqualPos == StringRef::npos) {
// Look up the option.
- return Sub.OptionsMap.lookup(Arg);
+ return Sub.OptionsMap.lookup(Arg);
}
// If the argument before the = is a valid option name and the option allows
@@ -828,7 +828,7 @@ void cl::TokenizeGNUCommandLine(StringRef Src, StringSaver &Saver,
// Consume runs of whitespace.
if (Token.empty()) {
while (I != E && isWhitespace(Src[I])) {
- // Mark the end of lines in response files.
+ // Mark the end of lines in response files.
if (MarkEOLs && Src[I] == '\n')
NewArgv.push_back(nullptr);
++I;
@@ -865,9 +865,9 @@ void cl::TokenizeGNUCommandLine(StringRef Src, StringSaver &Saver,
if (isWhitespace(C)) {
if (!Token.empty())
NewArgv.push_back(Saver.save(StringRef(Token)).data());
- // Mark the end of lines in response files.
- if (MarkEOLs && C == '\n')
- NewArgv.push_back(nullptr);
+ // Mark the end of lines in response files.
+ if (MarkEOLs && C == '\n')
+ NewArgv.push_back(nullptr);
Token.clear();
continue;
}
@@ -955,8 +955,8 @@ tokenizeWindowsCommandLineImpl(StringRef Src, StringSaver &Saver,
// No special characters: slice out the substring and start the next
// token. Copy the string if the caller asks us to.
AddToken(AlwaysCopy ? Saver.save(NormalChars) : NormalChars);
- if (I < E && Src[I] == '\n')
- MarkEOL();
+ if (I < E && Src[I] == '\n')
+ MarkEOL();
} else if (Src[I] == '\"') {
Token += NormalChars;
State = QUOTED;
@@ -1204,7 +1204,7 @@ bool cl::ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer,
};
// Check for recursive response files.
- if (any_of(drop_begin(FileStack), IsEquivalent)) {
+ if (any_of(drop_begin(FileStack), IsEquivalent)) {
// This file is recursive, so we leave it in the argument stream and
// move on.
AllExpanded = false;
@@ -1247,22 +1247,22 @@ bool cl::ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer,
return AllExpanded;
}
-bool cl::expandResponseFiles(int Argc, const char *const *Argv,
- const char *EnvVar, StringSaver &Saver,
- SmallVectorImpl<const char *> &NewArgv) {
- auto Tokenize = Triple(sys::getProcessTriple()).isOSWindows()
- ? cl::TokenizeWindowsCommandLine
- : cl::TokenizeGNUCommandLine;
- // The environment variable specifies initial options.
- if (EnvVar)
- if (llvm::Optional<std::string> EnvValue = sys::Process::GetEnv(EnvVar))
- Tokenize(*EnvValue, Saver, NewArgv, /*MarkEOLs=*/false);
-
- // Command line options can override the environment variable.
- NewArgv.append(Argv + 1, Argv + Argc);
- return ExpandResponseFiles(Saver, Tokenize, NewArgv);
-}
-
+bool cl::expandResponseFiles(int Argc, const char *const *Argv,
+ const char *EnvVar, StringSaver &Saver,
+ SmallVectorImpl<const char *> &NewArgv) {
+ auto Tokenize = Triple(sys::getProcessTriple()).isOSWindows()
+ ? cl::TokenizeWindowsCommandLine
+ : cl::TokenizeGNUCommandLine;
+ // The environment variable specifies initial options.
+ if (EnvVar)
+ if (llvm::Optional<std::string> EnvValue = sys::Process::GetEnv(EnvVar))
+ Tokenize(*EnvValue, Saver, NewArgv, /*MarkEOLs=*/false);
+
+ // Command line options can override the environment variable.
+ NewArgv.append(Argv + 1, Argv + Argc);
+ return ExpandResponseFiles(Saver, Tokenize, NewArgv);
+}
+
bool cl::readConfigFile(StringRef CfgFile, StringSaver &Saver,
SmallVectorImpl<const char *> &Argv) {
SmallString<128> AbsPath;
@@ -1726,19 +1726,19 @@ void Option::printHelpStr(StringRef HelpStr, size_t Indent,
}
}
-void Option::printEnumValHelpStr(StringRef HelpStr, size_t BaseIndent,
- size_t FirstLineIndentedBy) {
- const StringRef ValHelpPrefix = " ";
- assert(BaseIndent >= FirstLineIndentedBy);
- std::pair<StringRef, StringRef> Split = HelpStr.split('\n');
- outs().indent(BaseIndent - FirstLineIndentedBy)
- << ArgHelpPrefix << ValHelpPrefix << Split.first << "\n";
- while (!Split.second.empty()) {
- Split = Split.second.split('\n');
- outs().indent(BaseIndent + ValHelpPrefix.size()) << Split.first << "\n";
- }
-}
-
+void Option::printEnumValHelpStr(StringRef HelpStr, size_t BaseIndent,
+ size_t FirstLineIndentedBy) {
+ const StringRef ValHelpPrefix = " ";
+ assert(BaseIndent >= FirstLineIndentedBy);
+ std::pair<StringRef, StringRef> Split = HelpStr.split('\n');
+ outs().indent(BaseIndent - FirstLineIndentedBy)
+ << ArgHelpPrefix << ValHelpPrefix << Split.first << "\n";
+ while (!Split.second.empty()) {
+ Split = Split.second.split('\n');
+ outs().indent(BaseIndent + ValHelpPrefix.size()) << Split.first << "\n";
+ }
+}
+
// Print out the option for the alias.
void alias::printOptionInfo(size_t GlobalWidth) const {
outs() << PrintArg(ArgStr);
@@ -1984,17 +1984,17 @@ void generic_parser_base::printOptionInfo(const Option &O,
StringRef Description = getDescription(i);
if (!shouldPrintOption(OptionName, Description, O))
continue;
- size_t FirstLineIndent = OptionName.size() + OptionPrefixesSize;
+ size_t FirstLineIndent = OptionName.size() + OptionPrefixesSize;
outs() << OptionPrefix << OptionName;
if (OptionName.empty()) {
outs() << EmptyOption;
- assert(FirstLineIndent >= EmptyOption.size());
- FirstLineIndent += EmptyOption.size();
+ assert(FirstLineIndent >= EmptyOption.size());
+ FirstLineIndent += EmptyOption.size();
}
if (!Description.empty())
- Option::printEnumValHelpStr(Description, GlobalWidth, FirstLineIndent);
- else
- outs() << '\n';
+ Option::printEnumValHelpStr(Description, GlobalWidth, FirstLineIndent);
+ else
+ outs() << '\n';
}
} else {
if (!O.HelpStr.empty())
@@ -2599,7 +2599,7 @@ void cl::HideUnrelatedOptions(ArrayRef<const cl::OptionCategory *> Categories,
SubCommand &Sub) {
for (auto &I : Sub.OptionsMap) {
for (auto &Cat : I.second->Categories) {
- if (!is_contained(Categories, Cat) && Cat != &GenericCategory)
+ if (!is_contained(Categories, Cat) && Cat != &GenericCategory)
I.second->setHiddenFlag(cl::ReallyHidden);
}
}
diff --git a/contrib/libs/llvm12/lib/Support/Compression.cpp b/contrib/libs/llvm12/lib/Support/Compression.cpp
index b8c77cf69b..a6a73ac879 100644
--- a/contrib/libs/llvm12/lib/Support/Compression.cpp
+++ b/contrib/libs/llvm12/lib/Support/Compression.cpp
@@ -17,13 +17,13 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
-#if LLVM_ENABLE_ZLIB
+#if LLVM_ENABLE_ZLIB
#include <zlib.h>
#endif
using namespace llvm;
-#if LLVM_ENABLE_ZLIB
+#if LLVM_ENABLE_ZLIB
static Error createError(StringRef Err) {
return make_error<StringError>(Err, inconvertibleErrorCode());
}
diff --git a/contrib/libs/llvm12/lib/Support/ConvertUTFWrapper.cpp b/contrib/libs/llvm12/lib/Support/ConvertUTFWrapper.cpp
index d8d46712a5..429c0c50f4 100644
--- a/contrib/libs/llvm12/lib/Support/ConvertUTFWrapper.cpp
+++ b/contrib/libs/llvm12/lib/Support/ConvertUTFWrapper.cpp
@@ -97,8 +97,8 @@ bool convertUTF16ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out) {
const UTF16 *Src = reinterpret_cast<const UTF16 *>(SrcBytes.begin());
const UTF16 *SrcEnd = reinterpret_cast<const UTF16 *>(SrcBytes.end());
- assert((uintptr_t)Src % sizeof(UTF16) == 0);
-
+ assert((uintptr_t)Src % sizeof(UTF16) == 0);
+
// Byteswap if necessary.
std::vector<UTF16> ByteSwapped;
if (Src[0] == UNI_UTF16_BYTE_ORDER_MARK_SWAPPED) {
diff --git a/contrib/libs/llvm12/lib/Support/CrashRecoveryContext.cpp b/contrib/libs/llvm12/lib/Support/CrashRecoveryContext.cpp
index 3d3ca7f567..6c2529df51 100644
--- a/contrib/libs/llvm12/lib/Support/CrashRecoveryContext.cpp
+++ b/contrib/libs/llvm12/lib/Support/CrashRecoveryContext.cpp
@@ -9,7 +9,7 @@
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/ExitCodes.h"
+#include "llvm/Support/ExitCodes.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/ThreadLocal.h"
@@ -95,13 +95,13 @@ static void uninstallExceptionOrSignalHandlers();
CrashRecoveryContextCleanup::~CrashRecoveryContextCleanup() {}
-CrashRecoveryContext::CrashRecoveryContext() {
- // On Windows, if abort() was previously triggered (and caught by a previous
- // CrashRecoveryContext) the Windows CRT removes our installed signal handler,
- // so we need to install it again.
- sys::DisableSystemDialogsOnCrash();
-}
-
+CrashRecoveryContext::CrashRecoveryContext() {
+ // On Windows, if abort() was previously triggered (and caught by a previous
+ // CrashRecoveryContext) the Windows CRT removes our installed signal handler,
+ // so we need to install it again.
+ sys::DisableSystemDialogsOnCrash();
+}
+
CrashRecoveryContext::~CrashRecoveryContext() {
// Reclaim registered resources.
CrashRecoveryContextCleanup *i = head;
@@ -375,10 +375,10 @@ static void CrashRecoverySignalHandler(int Signal) {
sigaddset(&SigMask, Signal);
sigprocmask(SIG_UNBLOCK, &SigMask, nullptr);
- // Return the same error code as if the program crashed, as mentioned in the
- // section "Exit Status for Commands":
- // https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html
- int RetCode = 128 + Signal;
+ // Return the same error code as if the program crashed, as mentioned in the
+ // section "Exit Status for Commands":
+ // https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html
+ int RetCode = 128 + Signal;
// Don't consider a broken pipe as a crash (see clang/lib/Driver/Driver.cpp)
if (Signal == SIGPIPE)
@@ -442,27 +442,27 @@ void CrashRecoveryContext::HandleExit(int RetCode) {
llvm_unreachable("Most likely setjmp wasn't called!");
}
-bool CrashRecoveryContext::throwIfCrash(int RetCode) {
-#if defined(_WIN32)
- // On Windows, the high bits are reserved for kernel return codes. Values
- // starting with 0x80000000 are reserved for "warnings"; values of 0xC0000000
- // and up are for "errors". In practice, both are interpreted as a
- // non-continuable signal.
- unsigned Code = ((unsigned)RetCode & 0xF0000000) >> 28;
- if (Code != 0xC && Code != 8)
- return false;
- ::RaiseException(RetCode, 0, 0, NULL);
-#else
- // On Unix, signals are represented by return codes of 128 or higher.
- // Exit code 128 is a reserved value and should not be raised as a signal.
- if (RetCode <= 128)
- return false;
- llvm::sys::unregisterHandlers();
- raise(RetCode - 128);
-#endif
- return true;
-}
-
+bool CrashRecoveryContext::throwIfCrash(int RetCode) {
+#if defined(_WIN32)
+ // On Windows, the high bits are reserved for kernel return codes. Values
+ // starting with 0x80000000 are reserved for "warnings"; values of 0xC0000000
+ // and up are for "errors". In practice, both are interpreted as a
+ // non-continuable signal.
+ unsigned Code = ((unsigned)RetCode & 0xF0000000) >> 28;
+ if (Code != 0xC && Code != 8)
+ return false;
+ ::RaiseException(RetCode, 0, 0, NULL);
+#else
+ // On Unix, signals are represented by return codes of 128 or higher.
+ // Exit code 128 is a reserved value and should not be raised as a signal.
+ if (RetCode <= 128)
+ return false;
+ llvm::sys::unregisterHandlers();
+ raise(RetCode - 128);
+#endif
+ return true;
+}
+
// FIXME: Portability.
static void setThreadBackgroundPriority() {
#ifdef __APPLE__
diff --git a/contrib/libs/llvm12/lib/Support/DebugCounter.cpp b/contrib/libs/llvm12/lib/Support/DebugCounter.cpp
index 7bb231c792..2269b9c126 100644
--- a/contrib/libs/llvm12/lib/Support/DebugCounter.cpp
+++ b/contrib/libs/llvm12/lib/Support/DebugCounter.cpp
@@ -118,7 +118,7 @@ void DebugCounter::push_back(const std::string &Val) {
void DebugCounter::print(raw_ostream &OS) const {
SmallVector<StringRef, 16> CounterNames(RegisteredCounters.begin(),
RegisteredCounters.end());
- sort(CounterNames);
+ sort(CounterNames);
auto &Us = instance();
OS << "Counters and values:\n";
diff --git a/contrib/libs/llvm12/lib/Support/DynamicLibrary.cpp b/contrib/libs/llvm12/lib/Support/DynamicLibrary.cpp
index bdf7462367..d645dd3e7c 100644
--- a/contrib/libs/llvm12/lib/Support/DynamicLibrary.cpp
+++ b/contrib/libs/llvm12/lib/Support/DynamicLibrary.cpp
@@ -39,7 +39,7 @@ public:
HandleSet() : Process(nullptr) {}
~HandleSet();
- HandleList::iterator Find(void *Handle) { return find(Handles, Handle); }
+ HandleList::iterator Find(void *Handle) { return find(Handles, Handle); }
bool Contains(void *Handle) {
return Handle == Process || Find(Handle) != Handles.end();
diff --git a/contrib/libs/llvm12/lib/Support/ELFAttributeParser.cpp b/contrib/libs/llvm12/lib/Support/ELFAttributeParser.cpp
index 2a30794bc1..1f784c0970 100644
--- a/contrib/libs/llvm12/lib/Support/ELFAttributeParser.cpp
+++ b/contrib/libs/llvm12/lib/Support/ELFAttributeParser.cpp
@@ -200,7 +200,7 @@ Error ELFAttributeParser::parse(ArrayRef<uint8_t> section,
// Unrecognized format-version.
uint8_t formatVersion = de.getU8(cursor);
- if (formatVersion != ELFAttrs::Format_Version)
+ if (formatVersion != ELFAttrs::Format_Version)
return createStringError(errc::invalid_argument,
"unrecognized format-version: 0x" +
utohexstr(formatVersion));
diff --git a/contrib/libs/llvm12/lib/Support/Error.cpp b/contrib/libs/llvm12/lib/Support/Error.cpp
index e7ab4387df..b8d1b5e63c 100644
--- a/contrib/libs/llvm12/lib/Support/Error.cpp
+++ b/contrib/libs/llvm12/lib/Support/Error.cpp
@@ -168,7 +168,7 @@ void LLVMDisposeErrorMessage(char *ErrMsg) { delete[] ErrMsg; }
LLVMErrorTypeId LLVMGetStringErrorTypeId() {
return reinterpret_cast<void *>(&StringError::ID);
}
-
-LLVMErrorRef LLVMCreateStringError(const char *ErrMsg) {
- return wrap(make_error<StringError>(ErrMsg, inconvertibleErrorCode()));
-}
+
+LLVMErrorRef LLVMCreateStringError(const char *ErrMsg) {
+ return wrap(make_error<StringError>(ErrMsg, inconvertibleErrorCode()));
+}
diff --git a/contrib/libs/llvm12/lib/Support/ErrorHandling.cpp b/contrib/libs/llvm12/lib/Support/ErrorHandling.cpp
index ce6344284f..d8b607773b 100644
--- a/contrib/libs/llvm12/lib/Support/ErrorHandling.cpp
+++ b/contrib/libs/llvm12/lib/Support/ErrorHandling.cpp
@@ -168,11 +168,11 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
#else
// Don't call the normal error handler. It may allocate memory. Directly write
// an OOM to stderr and abort.
- const char *OOMMessage = "LLVM ERROR: out of memory\n";
- const char *Newline = "\n";
- (void)!::write(2, OOMMessage, strlen(OOMMessage));
- (void)!::write(2, Reason, strlen(Reason));
- (void)!::write(2, Newline, strlen(Newline));
+ const char *OOMMessage = "LLVM ERROR: out of memory\n";
+ const char *Newline = "\n";
+ (void)!::write(2, OOMMessage, strlen(OOMMessage));
+ (void)!::write(2, Reason, strlen(Reason));
+ (void)!::write(2, Newline, strlen(Newline));
abort();
#endif
}
@@ -194,8 +194,8 @@ static void out_of_memory_new_handler() {
void llvm::install_out_of_memory_new_handler() {
std::new_handler old = std::set_new_handler(out_of_memory_new_handler);
(void)old;
- assert((old == nullptr || old == out_of_memory_new_handler) &&
- "new-handler already installed");
+ assert((old == nullptr || old == out_of_memory_new_handler) &&
+ "new-handler already installed");
}
#endif
diff --git a/contrib/libs/llvm12/lib/Support/FileCollector.cpp b/contrib/libs/llvm12/lib/Support/FileCollector.cpp
index 99482075f6..3ff2871a38 100644
--- a/contrib/libs/llvm12/lib/Support/FileCollector.cpp
+++ b/contrib/libs/llvm12/lib/Support/FileCollector.cpp
@@ -15,22 +15,22 @@
using namespace llvm;
-FileCollectorBase::FileCollectorBase() = default;
-FileCollectorBase::~FileCollectorBase() = default;
-
-void FileCollectorBase::addFile(const Twine &File) {
- std::lock_guard<std::mutex> lock(Mutex);
- std::string FileStr = File.str();
- if (markAsSeen(FileStr))
- addFileImpl(FileStr);
-}
-
-void FileCollectorBase::addDirectory(const Twine &Dir) {
- assert(sys::fs::is_directory(Dir));
- std::error_code EC;
- addDirectoryImpl(Dir, vfs::getRealFileSystem(), EC);
-}
-
+FileCollectorBase::FileCollectorBase() = default;
+FileCollectorBase::~FileCollectorBase() = default;
+
+void FileCollectorBase::addFile(const Twine &File) {
+ std::lock_guard<std::mutex> lock(Mutex);
+ std::string FileStr = File.str();
+ if (markAsSeen(FileStr))
+ addFileImpl(FileStr);
+}
+
+void FileCollectorBase::addDirectory(const Twine &Dir) {
+ assert(sys::fs::is_directory(Dir));
+ std::error_code EC;
+ addDirectoryImpl(Dir, vfs::getRealFileSystem(), EC);
+}
+
static bool isCaseSensitivePath(StringRef Path) {
SmallString<256> TmpDest = Path, UpperDest, RealDest;
@@ -53,82 +53,82 @@ FileCollector::FileCollector(std::string Root, std::string OverlayRoot)
: Root(std::move(Root)), OverlayRoot(std::move(OverlayRoot)) {
}
-void FileCollector::PathCanonicalizer::updateWithRealPath(
- SmallVectorImpl<char> &Path) {
- StringRef SrcPath(Path.begin(), Path.size());
- StringRef Filename = sys::path::filename(SrcPath);
- StringRef Directory = sys::path::parent_path(SrcPath);
-
- // Use real_path to fix any symbolic link component present in the directory
- // part of the path, caching the search because computing the real path is
- // expensive.
+void FileCollector::PathCanonicalizer::updateWithRealPath(
+ SmallVectorImpl<char> &Path) {
+ StringRef SrcPath(Path.begin(), Path.size());
+ StringRef Filename = sys::path::filename(SrcPath);
+ StringRef Directory = sys::path::parent_path(SrcPath);
+
+ // Use real_path to fix any symbolic link component present in the directory
+ // part of the path, caching the search because computing the real path is
+ // expensive.
SmallString<256> RealPath;
- auto DirWithSymlink = CachedDirs.find(Directory);
- if (DirWithSymlink == CachedDirs.end()) {
- // FIXME: Should this be a call to FileSystem::getRealpath(), in some
- // cases? What if there is nothing on disk?
- if (sys::fs::real_path(Directory, RealPath))
- return;
- CachedDirs[Directory] = std::string(RealPath.str());
+ auto DirWithSymlink = CachedDirs.find(Directory);
+ if (DirWithSymlink == CachedDirs.end()) {
+ // FIXME: Should this be a call to FileSystem::getRealpath(), in some
+ // cases? What if there is nothing on disk?
+ if (sys::fs::real_path(Directory, RealPath))
+ return;
+ CachedDirs[Directory] = std::string(RealPath.str());
} else {
RealPath = DirWithSymlink->second;
}
- // Finish recreating the path by appending the original filename, since we
- // don't need to resolve symlinks in the filename.
- //
- // FIXME: If we can cope with this, maybe we can cope without calling
- // getRealPath() at all when there's no ".." component.
- sys::path::append(RealPath, Filename);
+ // Finish recreating the path by appending the original filename, since we
+ // don't need to resolve symlinks in the filename.
+ //
+ // FIXME: If we can cope with this, maybe we can cope without calling
+ // getRealPath() at all when there's no ".." component.
+ sys::path::append(RealPath, Filename);
- // Swap to create the output.
- Path.swap(RealPath);
+ // Swap to create the output.
+ Path.swap(RealPath);
}
-/// Make Path absolute.
-static void makeAbsolute(SmallVectorImpl<char> &Path) {
+/// Make Path absolute.
+static void makeAbsolute(SmallVectorImpl<char> &Path) {
// We need an absolute src path to append to the root.
- sys::fs::make_absolute(Path);
+ sys::fs::make_absolute(Path);
// Canonicalize src to a native path to avoid mixed separator styles.
- sys::path::native(Path);
+ sys::path::native(Path);
// Remove redundant leading "./" pieces and consecutive separators.
- Path.erase(Path.begin(), sys::path::remove_leading_dotslash(
- StringRef(Path.begin(), Path.size()))
- .begin());
-}
+ Path.erase(Path.begin(), sys::path::remove_leading_dotslash(
+ StringRef(Path.begin(), Path.size()))
+ .begin());
+}
-FileCollector::PathCanonicalizer::PathStorage
-FileCollector::PathCanonicalizer::canonicalize(StringRef SrcPath) {
- PathStorage Paths;
- Paths.VirtualPath = SrcPath;
- makeAbsolute(Paths.VirtualPath);
+FileCollector::PathCanonicalizer::PathStorage
+FileCollector::PathCanonicalizer::canonicalize(StringRef SrcPath) {
+ PathStorage Paths;
+ Paths.VirtualPath = SrcPath;
+ makeAbsolute(Paths.VirtualPath);
// If a ".." component is present after a symlink component, remove_dots may
// lead to the wrong real destination path. Let the source be canonicalized
// like that but make sure we always use the real path for the destination.
- Paths.CopyFrom = Paths.VirtualPath;
- updateWithRealPath(Paths.CopyFrom);
-
- // Canonicalize the virtual path by removing "..", "." components.
- sys::path::remove_dots(Paths.VirtualPath, /*remove_dot_dot=*/true);
-
- return Paths;
-}
-
-void FileCollector::addFileImpl(StringRef SrcPath) {
- PathCanonicalizer::PathStorage Paths = Canonicalizer.canonicalize(SrcPath);
-
+ Paths.CopyFrom = Paths.VirtualPath;
+ updateWithRealPath(Paths.CopyFrom);
+
+ // Canonicalize the virtual path by removing "..", "." components.
+ sys::path::remove_dots(Paths.VirtualPath, /*remove_dot_dot=*/true);
+
+ return Paths;
+}
+
+void FileCollector::addFileImpl(StringRef SrcPath) {
+ PathCanonicalizer::PathStorage Paths = Canonicalizer.canonicalize(SrcPath);
+
SmallString<256> DstPath = StringRef(Root);
- sys::path::append(DstPath, sys::path::relative_path(Paths.CopyFrom));
+ sys::path::append(DstPath, sys::path::relative_path(Paths.CopyFrom));
// Always map a canonical src path to its real path into the YAML, by doing
// this we map different virtual src paths to the same entry in the VFS
// overlay, which is a way to emulate symlink inside the VFS; this is also
// needed for correctness, not doing that can lead to module redefinition
// errors.
- addFileToMapping(Paths.VirtualPath, DstPath);
+ addFileToMapping(Paths.VirtualPath, DstPath);
}
llvm::vfs::directory_iterator
@@ -182,18 +182,18 @@ std::error_code FileCollector::copyFiles(bool StopOnError) {
std::lock_guard<std::mutex> lock(Mutex);
for (auto &entry : VFSWriter.getMappings()) {
- // Get the status of the original file/directory.
- sys::fs::file_status Stat;
- if (std::error_code EC = sys::fs::status(entry.VPath, Stat)) {
- if (StopOnError)
- return EC;
- continue;
- }
-
- // Continue if the file doesn't exist.
- if (Stat.type() == sys::fs::file_type::file_not_found)
- continue;
-
+ // Get the status of the original file/directory.
+ sys::fs::file_status Stat;
+ if (std::error_code EC = sys::fs::status(entry.VPath, Stat)) {
+ if (StopOnError)
+ return EC;
+ continue;
+ }
+
+ // Continue if the file doesn't exist.
+ if (Stat.type() == sys::fs::file_type::file_not_found)
+ continue;
+
// Create directory tree.
if (std::error_code EC =
sys::fs::create_directories(sys::path::parent_path(entry.RPath),
diff --git a/contrib/libs/llvm12/lib/Support/FormatVariadic.cpp b/contrib/libs/llvm12/lib/Support/FormatVariadic.cpp
index f6d48bcd50..06d423907a 100644
--- a/contrib/libs/llvm12/lib/Support/FormatVariadic.cpp
+++ b/contrib/libs/llvm12/lib/Support/FormatVariadic.cpp
@@ -91,26 +91,26 @@ formatv_object_base::parseReplacementItem(StringRef Spec) {
std::pair<ReplacementItem, StringRef>
formatv_object_base::splitLiteralAndReplacement(StringRef Fmt) {
- while (!Fmt.empty()) {
+ while (!Fmt.empty()) {
// Everything up until the first brace is a literal.
- if (Fmt.front() != '{') {
- std::size_t BO = Fmt.find_first_of('{');
+ if (Fmt.front() != '{') {
+ std::size_t BO = Fmt.find_first_of('{');
return std::make_pair(ReplacementItem{Fmt.substr(0, BO)}, Fmt.substr(BO));
- }
+ }
- StringRef Braces = Fmt.take_while([](char C) { return C == '{'; });
+ StringRef Braces = Fmt.take_while([](char C) { return C == '{'; });
// If there is more than one brace, then some of them are escaped. Treat
// these as replacements.
if (Braces.size() > 1) {
size_t NumEscapedBraces = Braces.size() / 2;
- StringRef Middle = Fmt.take_front(NumEscapedBraces);
- StringRef Right = Fmt.drop_front(NumEscapedBraces * 2);
+ StringRef Middle = Fmt.take_front(NumEscapedBraces);
+ StringRef Right = Fmt.drop_front(NumEscapedBraces * 2);
return std::make_pair(ReplacementItem{Middle}, Right);
}
// An unterminated open brace is undefined. We treat the rest of the string
// as a literal replacement, but we assert to indicate that this is
// undefined and that we consider it an error.
- std::size_t BC = Fmt.find_first_of('}');
+ std::size_t BC = Fmt.find_first_of('}');
if (BC == StringRef::npos) {
assert(
false &&
@@ -121,12 +121,12 @@ formatv_object_base::splitLiteralAndReplacement(StringRef Fmt) {
// Even if there is a closing brace, if there is another open brace before
// this closing brace, treat this portion as literal, and try again with the
// next one.
- std::size_t BO2 = Fmt.find_first_of('{', 1);
+ std::size_t BO2 = Fmt.find_first_of('{', 1);
if (BO2 < BC)
return std::make_pair(ReplacementItem{Fmt.substr(0, BO2)},
Fmt.substr(BO2));
- StringRef Spec = Fmt.slice(1, BC);
+ StringRef Spec = Fmt.slice(1, BC);
StringRef Right = Fmt.substr(BC + 1);
auto RI = parseReplacementItem(Spec);
@@ -135,7 +135,7 @@ formatv_object_base::splitLiteralAndReplacement(StringRef Fmt) {
// If there was an error parsing the replacement item, treat it as an
// invalid replacement spec, and just continue.
- Fmt = Fmt.drop_front(BC + 1);
+ Fmt = Fmt.drop_front(BC + 1);
}
return std::make_pair(ReplacementItem{Fmt}, StringRef());
}
diff --git a/contrib/libs/llvm12/lib/Support/Host.cpp b/contrib/libs/llvm12/lib/Support/Host.cpp
index 09146c47ff..4f09e7d3b9 100644
--- a/contrib/libs/llvm12/lib/Support/Host.cpp
+++ b/contrib/libs/llvm12/lib/Support/Host.cpp
@@ -161,14 +161,14 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) {
// Look for the CPU implementer line.
StringRef Implementer;
StringRef Hardware;
- StringRef Part;
+ StringRef Part;
for (unsigned I = 0, E = Lines.size(); I != E; ++I) {
if (Lines[I].startswith("CPU implementer"))
Implementer = Lines[I].substr(15).ltrim("\t :");
if (Lines[I].startswith("Hardware"))
Hardware = Lines[I].substr(8).ltrim("\t :");
- if (Lines[I].startswith("CPU part"))
- Part = Lines[I].substr(8).ltrim("\t :");
+ if (Lines[I].startswith("CPU part"))
+ Part = Lines[I].substr(8).ltrim("\t :");
}
if (Implementer == "0x41") { // ARM Ltd.
@@ -178,89 +178,89 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) {
return "cortex-a53";
- // The CPU part is a 3 digit hexadecimal number with a 0x prefix. The
- // values correspond to the "Part number" in the CP15/c0 register. The
- // contents are specified in the various processor manuals.
- // This corresponds to the Main ID Register in Technical Reference Manuals.
- // and is used in programs like sys-utils
- return StringSwitch<const char *>(Part)
- .Case("0x926", "arm926ej-s")
- .Case("0xb02", "mpcore")
- .Case("0xb36", "arm1136j-s")
- .Case("0xb56", "arm1156t2-s")
- .Case("0xb76", "arm1176jz-s")
- .Case("0xc08", "cortex-a8")
- .Case("0xc09", "cortex-a9")
- .Case("0xc0f", "cortex-a15")
- .Case("0xc20", "cortex-m0")
- .Case("0xc23", "cortex-m3")
- .Case("0xc24", "cortex-m4")
- .Case("0xd22", "cortex-m55")
- .Case("0xd02", "cortex-a34")
- .Case("0xd04", "cortex-a35")
- .Case("0xd03", "cortex-a53")
- .Case("0xd07", "cortex-a57")
- .Case("0xd08", "cortex-a72")
- .Case("0xd09", "cortex-a73")
- .Case("0xd0a", "cortex-a75")
- .Case("0xd0b", "cortex-a76")
- .Case("0xd0d", "cortex-a77")
- .Case("0xd41", "cortex-a78")
- .Case("0xd44", "cortex-x1")
- .Case("0xd0c", "neoverse-n1")
- .Case("0xd49", "neoverse-n2")
- .Default("generic");
+ // The CPU part is a 3 digit hexadecimal number with a 0x prefix. The
+ // values correspond to the "Part number" in the CP15/c0 register. The
+ // contents are specified in the various processor manuals.
+ // This corresponds to the Main ID Register in Technical Reference Manuals.
+ // and is used in programs like sys-utils
+ return StringSwitch<const char *>(Part)
+ .Case("0x926", "arm926ej-s")
+ .Case("0xb02", "mpcore")
+ .Case("0xb36", "arm1136j-s")
+ .Case("0xb56", "arm1156t2-s")
+ .Case("0xb76", "arm1176jz-s")
+ .Case("0xc08", "cortex-a8")
+ .Case("0xc09", "cortex-a9")
+ .Case("0xc0f", "cortex-a15")
+ .Case("0xc20", "cortex-m0")
+ .Case("0xc23", "cortex-m3")
+ .Case("0xc24", "cortex-m4")
+ .Case("0xd22", "cortex-m55")
+ .Case("0xd02", "cortex-a34")
+ .Case("0xd04", "cortex-a35")
+ .Case("0xd03", "cortex-a53")
+ .Case("0xd07", "cortex-a57")
+ .Case("0xd08", "cortex-a72")
+ .Case("0xd09", "cortex-a73")
+ .Case("0xd0a", "cortex-a75")
+ .Case("0xd0b", "cortex-a76")
+ .Case("0xd0d", "cortex-a77")
+ .Case("0xd41", "cortex-a78")
+ .Case("0xd44", "cortex-x1")
+ .Case("0xd0c", "neoverse-n1")
+ .Case("0xd49", "neoverse-n2")
+ .Default("generic");
}
if (Implementer == "0x42" || Implementer == "0x43") { // Broadcom | Cavium.
- return StringSwitch<const char *>(Part)
- .Case("0x516", "thunderx2t99")
- .Case("0x0516", "thunderx2t99")
- .Case("0xaf", "thunderx2t99")
- .Case("0x0af", "thunderx2t99")
- .Case("0xa1", "thunderxt88")
- .Case("0x0a1", "thunderxt88")
- .Default("generic");
+ return StringSwitch<const char *>(Part)
+ .Case("0x516", "thunderx2t99")
+ .Case("0x0516", "thunderx2t99")
+ .Case("0xaf", "thunderx2t99")
+ .Case("0x0af", "thunderx2t99")
+ .Case("0xa1", "thunderxt88")
+ .Case("0x0a1", "thunderxt88")
+ .Default("generic");
}
if (Implementer == "0x46") { // Fujitsu Ltd.
- return StringSwitch<const char *>(Part)
- .Case("0x001", "a64fx")
- .Default("generic");
+ return StringSwitch<const char *>(Part)
+ .Case("0x001", "a64fx")
+ .Default("generic");
}
if (Implementer == "0x4e") { // NVIDIA Corporation
- return StringSwitch<const char *>(Part)
- .Case("0x004", "carmel")
- .Default("generic");
+ return StringSwitch<const char *>(Part)
+ .Case("0x004", "carmel")
+ .Default("generic");
}
if (Implementer == "0x48") // HiSilicon Technologies, Inc.
- // The CPU part is a 3 digit hexadecimal number with a 0x prefix. The
- // values correspond to the "Part number" in the CP15/c0 register. The
- // contents are specified in the various processor manuals.
- return StringSwitch<const char *>(Part)
- .Case("0xd01", "tsv110")
- .Default("generic");
+ // The CPU part is a 3 digit hexadecimal number with a 0x prefix. The
+ // values correspond to the "Part number" in the CP15/c0 register. The
+ // contents are specified in the various processor manuals.
+ return StringSwitch<const char *>(Part)
+ .Case("0xd01", "tsv110")
+ .Default("generic");
if (Implementer == "0x51") // Qualcomm Technologies, Inc.
- // The CPU part is a 3 digit hexadecimal number with a 0x prefix. The
- // values correspond to the "Part number" in the CP15/c0 register. The
- // contents are specified in the various processor manuals.
- return StringSwitch<const char *>(Part)
- .Case("0x06f", "krait") // APQ8064
- .Case("0x201", "kryo")
- .Case("0x205", "kryo")
- .Case("0x211", "kryo")
- .Case("0x800", "cortex-a73") // Kryo 2xx Gold
- .Case("0x801", "cortex-a73") // Kryo 2xx Silver
- .Case("0x802", "cortex-a75") // Kryo 3xx Gold
- .Case("0x803", "cortex-a75") // Kryo 3xx Silver
- .Case("0x804", "cortex-a76") // Kryo 4xx Gold
- .Case("0x805", "cortex-a76") // Kryo 4xx/5xx Silver
- .Case("0xc00", "falkor")
- .Case("0xc01", "saphira")
- .Default("generic");
+ // The CPU part is a 3 digit hexadecimal number with a 0x prefix. The
+ // values correspond to the "Part number" in the CP15/c0 register. The
+ // contents are specified in the various processor manuals.
+ return StringSwitch<const char *>(Part)
+ .Case("0x06f", "krait") // APQ8064
+ .Case("0x201", "kryo")
+ .Case("0x205", "kryo")
+ .Case("0x211", "kryo")
+ .Case("0x800", "cortex-a73") // Kryo 2xx Gold
+ .Case("0x801", "cortex-a73") // Kryo 2xx Silver
+ .Case("0x802", "cortex-a75") // Kryo 3xx Gold
+ .Case("0x803", "cortex-a75") // Kryo 3xx Silver
+ .Case("0x804", "cortex-a76") // Kryo 4xx Gold
+ .Case("0x805", "cortex-a76") // Kryo 4xx/5xx Silver
+ .Case("0xc00", "falkor")
+ .Case("0xc01", "saphira")
+ .Default("generic");
if (Implementer == "0x53") { // Samsung Electronics Co., Ltd.
// The Exynos chips have a convoluted ID scheme that doesn't seem to follow
// any predictive pattern across variants and parts.
@@ -305,7 +305,7 @@ StringRef sys::detail::getHostCPUNameForS390x(StringRef ProcCpuinfoContent) {
SmallVector<StringRef, 32> CPUFeatures;
for (unsigned I = 0, E = Lines.size(); I != E; ++I)
if (Lines[I].startswith("features")) {
- size_t Pos = Lines[I].find(':');
+ size_t Pos = Lines[I].find(':');
if (Pos != StringRef::npos) {
Lines[I].drop_front(Pos + 1).split(CPUFeatures, ' ');
break;
@@ -490,42 +490,42 @@ static bool getX86CpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX,
#endif
}
-namespace llvm {
-namespace sys {
-namespace detail {
-namespace x86 {
-
-VendorSignatures getVendorSignature(unsigned *MaxLeaf) {
- unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
- if (MaxLeaf == nullptr)
- MaxLeaf = &EAX;
- else
- *MaxLeaf = 0;
-
- if (!isCpuIdSupported())
- return VendorSignatures::UNKNOWN;
-
- if (getX86CpuIDAndInfo(0, MaxLeaf, &EBX, &ECX, &EDX) || *MaxLeaf < 1)
- return VendorSignatures::UNKNOWN;
-
- // "Genu ineI ntel"
- if (EBX == 0x756e6547 && EDX == 0x49656e69 && ECX == 0x6c65746e)
- return VendorSignatures::GENUINE_INTEL;
-
- // "Auth enti cAMD"
- if (EBX == 0x68747541 && EDX == 0x69746e65 && ECX == 0x444d4163)
- return VendorSignatures::AUTHENTIC_AMD;
-
- return VendorSignatures::UNKNOWN;
-}
-
-} // namespace x86
-} // namespace detail
-} // namespace sys
-} // namespace llvm
-
-using namespace llvm::sys::detail::x86;
-
+namespace llvm {
+namespace sys {
+namespace detail {
+namespace x86 {
+
+VendorSignatures getVendorSignature(unsigned *MaxLeaf) {
+ unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
+ if (MaxLeaf == nullptr)
+ MaxLeaf = &EAX;
+ else
+ *MaxLeaf = 0;
+
+ if (!isCpuIdSupported())
+ return VendorSignatures::UNKNOWN;
+
+ if (getX86CpuIDAndInfo(0, MaxLeaf, &EBX, &ECX, &EDX) || *MaxLeaf < 1)
+ return VendorSignatures::UNKNOWN;
+
+ // "Genu ineI ntel"
+ if (EBX == 0x756e6547 && EDX == 0x49656e69 && ECX == 0x6c65746e)
+ return VendorSignatures::GENUINE_INTEL;
+
+ // "Auth enti cAMD"
+ if (EBX == 0x68747541 && EDX == 0x69746e65 && ECX == 0x444d4163)
+ return VendorSignatures::AUTHENTIC_AMD;
+
+ return VendorSignatures::UNKNOWN;
+}
+
+} // namespace x86
+} // namespace detail
+} // namespace sys
+} // namespace llvm
+
+using namespace llvm::sys::detail::x86;
+
/// getX86CpuIDAndInfoEx - Execute the specified cpuid with subleaf and return
/// the 4 values in the specified arguments. If we can't run cpuid on the host,
/// return true.
@@ -743,13 +743,13 @@ getIntelProcessorTypeAndSubtype(unsigned Family, unsigned Model,
*Subtype = X86::INTEL_COREI7_ICELAKE_SERVER;
break;
- // Sapphire Rapids:
- case 0x8f:
- CPU = "sapphirerapids";
- *Type = X86::INTEL_COREI7;
- *Subtype = X86::INTEL_COREI7_SAPPHIRERAPIDS;
- break;
-
+ // Sapphire Rapids:
+ case 0x8f:
+ CPU = "sapphirerapids";
+ *Type = X86::INTEL_COREI7;
+ *Subtype = X86::INTEL_COREI7_SAPPHIRERAPIDS;
+ break;
+
case 0x1c: // Most 45 nm Intel Atom processors
case 0x26: // 45 nm Atom Lincroft
case 0x27: // 32 nm Atom Medfield
@@ -976,14 +976,14 @@ getAMDProcessorTypeAndSubtype(unsigned Family, unsigned Model,
break; // 00h-0Fh: Zen1
}
break;
- case 25:
- CPU = "znver3";
- *Type = X86::AMDFAM19H;
- if (Model <= 0x0f) {
- *Subtype = X86::AMDFAM19H_ZNVER3;
- break; // 00h-0Fh: Zen3
- }
- break;
+ case 25:
+ CPU = "znver3";
+ *Type = X86::AMDFAM19H;
+ if (Model <= 0x0f) {
+ *Subtype = X86::AMDFAM19H_ZNVER3;
+ break; // 00h-0Fh: Zen3
+ }
+ break;
default:
break; // Unknown AMD CPU.
}
@@ -1123,12 +1123,12 @@ static void getAvailableFeatures(unsigned ECX, unsigned EDX, unsigned MaxLeaf,
}
StringRef sys::getHostCPUName() {
- unsigned MaxLeaf = 0;
- const VendorSignatures Vendor = getVendorSignature(&MaxLeaf);
- if (Vendor == VendorSignatures::UNKNOWN)
+ unsigned MaxLeaf = 0;
+ const VendorSignatures Vendor = getVendorSignature(&MaxLeaf);
+ if (Vendor == VendorSignatures::UNKNOWN)
return "generic";
- unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
+ unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
getX86CpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX);
unsigned Family = 0, Model = 0;
@@ -1143,10 +1143,10 @@ StringRef sys::getHostCPUName() {
StringRef CPU;
- if (Vendor == VendorSignatures::GENUINE_INTEL) {
+ if (Vendor == VendorSignatures::GENUINE_INTEL) {
CPU = getIntelProcessorTypeAndSubtype(Family, Model, Features, &Type,
&Subtype);
- } else if (Vendor == VendorSignatures::AUTHENTIC_AMD) {
+ } else if (Vendor == VendorSignatures::AUTHENTIC_AMD) {
CPU = getAMDProcessorTypeAndSubtype(Family, Model, Features, &Type,
&Subtype);
}
@@ -1248,19 +1248,19 @@ StringRef sys::getHostCPUName() {
}
#else
StringRef sys::getHostCPUName() { return "generic"; }
-namespace llvm {
-namespace sys {
-namespace detail {
-namespace x86 {
-
-VendorSignatures getVendorSignature(unsigned *MaxLeaf) {
- return VendorSignatures::UNKNOWN;
-}
-
-} // namespace x86
-} // namespace detail
-} // namespace sys
-} // namespace llvm
+namespace llvm {
+namespace sys {
+namespace detail {
+namespace x86 {
+
+VendorSignatures getVendorSignature(unsigned *MaxLeaf) {
+ return VendorSignatures::UNKNOWN;
+}
+
+} // namespace x86
+} // namespace detail
+} // namespace sys
+} // namespace llvm
#endif
#if defined(__linux__) && (defined(__i386__) || defined(__x86_64__))
@@ -1311,27 +1311,27 @@ int computeHostNumPhysicalCores() {
}
return CPU_COUNT(&Enabled);
}
-#elif defined(__linux__) && defined(__powerpc__)
-int computeHostNumPhysicalCores() {
- cpu_set_t Affinity;
- if (sched_getaffinity(0, sizeof(Affinity), &Affinity) == 0)
- return CPU_COUNT(&Affinity);
-
- // The call to sched_getaffinity() may have failed because the Affinity
- // mask is too small for the number of CPU's on the system (i.e. the
- // system has more than 1024 CPUs). Allocate a mask large enough for
- // twice as many CPUs.
- cpu_set_t *DynAffinity;
- DynAffinity = CPU_ALLOC(2048);
- if (sched_getaffinity(0, CPU_ALLOC_SIZE(2048), DynAffinity) == 0) {
- int NumCPUs = CPU_COUNT(DynAffinity);
- CPU_FREE(DynAffinity);
- return NumCPUs;
- }
- return -1;
-}
-#elif defined(__linux__) && defined(__s390x__)
-int computeHostNumPhysicalCores() { return sysconf(_SC_NPROCESSORS_ONLN); }
+#elif defined(__linux__) && defined(__powerpc__)
+int computeHostNumPhysicalCores() {
+ cpu_set_t Affinity;
+ if (sched_getaffinity(0, sizeof(Affinity), &Affinity) == 0)
+ return CPU_COUNT(&Affinity);
+
+ // The call to sched_getaffinity() may have failed because the Affinity
+ // mask is too small for the number of CPU's on the system (i.e. the
+ // system has more than 1024 CPUs). Allocate a mask large enough for
+ // twice as many CPUs.
+ cpu_set_t *DynAffinity;
+ DynAffinity = CPU_ALLOC(2048);
+ if (sched_getaffinity(0, CPU_ALLOC_SIZE(2048), DynAffinity) == 0) {
+ int NumCPUs = CPU_COUNT(DynAffinity);
+ CPU_FREE(DynAffinity);
+ return NumCPUs;
+ }
+ return -1;
+}
+#elif defined(__linux__) && defined(__s390x__)
+int computeHostNumPhysicalCores() { return sysconf(_SC_NPROCESSORS_ONLN); }
#elif defined(__APPLE__) && defined(__x86_64__)
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -1351,28 +1351,28 @@ int computeHostNumPhysicalCores() {
}
return count;
}
-#elif defined(__MVS__)
-int computeHostNumPhysicalCores() {
- enum {
- // Byte offset of the pointer to the Communications Vector Table (CVT) in
- // the Prefixed Save Area (PSA). The table entry is a 31-bit pointer and
- // will be zero-extended to uintptr_t.
- FLCCVT = 16,
- // Byte offset of the pointer to the Common System Data Area (CSD) in the
- // CVT. The table entry is a 31-bit pointer and will be zero-extended to
- // uintptr_t.
- CVTCSD = 660,
- // Byte offset to the number of live CPs in the LPAR, stored as a signed
- // 32-bit value in the table.
- CSD_NUMBER_ONLINE_STANDARD_CPS = 264,
- };
- char *PSA = 0;
- char *CVT = reinterpret_cast<char *>(
- static_cast<uintptr_t>(reinterpret_cast<unsigned int &>(PSA[FLCCVT])));
- char *CSD = reinterpret_cast<char *>(
- static_cast<uintptr_t>(reinterpret_cast<unsigned int &>(CVT[CVTCSD])));
- return reinterpret_cast<int &>(CSD[CSD_NUMBER_ONLINE_STANDARD_CPS]);
-}
+#elif defined(__MVS__)
+int computeHostNumPhysicalCores() {
+ enum {
+ // Byte offset of the pointer to the Communications Vector Table (CVT) in
+ // the Prefixed Save Area (PSA). The table entry is a 31-bit pointer and
+ // will be zero-extended to uintptr_t.
+ FLCCVT = 16,
+ // Byte offset of the pointer to the Common System Data Area (CSD) in the
+ // CVT. The table entry is a 31-bit pointer and will be zero-extended to
+ // uintptr_t.
+ CVTCSD = 660,
+ // Byte offset to the number of live CPs in the LPAR, stored as a signed
+ // 32-bit value in the table.
+ CSD_NUMBER_ONLINE_STANDARD_CPS = 264,
+ };
+ char *PSA = 0;
+ char *CVT = reinterpret_cast<char *>(
+ static_cast<uintptr_t>(reinterpret_cast<unsigned int &>(PSA[FLCCVT])));
+ char *CSD = reinterpret_cast<char *>(
+ static_cast<uintptr_t>(reinterpret_cast<unsigned int &>(CVT[CVTCSD])));
+ return reinterpret_cast<int &>(CSD[CSD_NUMBER_ONLINE_STANDARD_CPS]);
+}
#elif defined(_WIN32) && LLVM_ENABLE_THREADS != 0
// Defined in llvm/lib/Support/Windows/Threading.inc
int computeHostNumPhysicalCores();
@@ -1502,13 +1502,13 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
Features["avx512bitalg"] = HasLeaf7 && ((ECX >> 12) & 1) && HasAVX512Save;
Features["avx512vpopcntdq"] = HasLeaf7 && ((ECX >> 14) & 1) && HasAVX512Save;
Features["rdpid"] = HasLeaf7 && ((ECX >> 22) & 1);
- Features["kl"] = HasLeaf7 && ((ECX >> 23) & 1); // key locker
+ Features["kl"] = HasLeaf7 && ((ECX >> 23) & 1); // key locker
Features["cldemote"] = HasLeaf7 && ((ECX >> 25) & 1);
Features["movdiri"] = HasLeaf7 && ((ECX >> 27) & 1);
Features["movdir64b"] = HasLeaf7 && ((ECX >> 28) & 1);
Features["enqcmd"] = HasLeaf7 && ((ECX >> 29) & 1);
- Features["uintr"] = HasLeaf7 && ((EDX >> 5) & 1);
+ Features["uintr"] = HasLeaf7 && ((EDX >> 5) & 1);
Features["avx512vp2intersect"] =
HasLeaf7 && ((EDX >> 8) & 1) && HasAVX512Save;
Features["serialize"] = HasLeaf7 && ((EDX >> 14) & 1);
@@ -1529,9 +1529,9 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
Features["amx-int8"] = HasLeaf7 && ((EDX >> 25) & 1) && HasAMXSave;
bool HasLeaf7Subleaf1 =
MaxLevel >= 7 && !getX86CpuIDAndInfoEx(0x7, 0x1, &EAX, &EBX, &ECX, &EDX);
- Features["avxvnni"] = HasLeaf7Subleaf1 && ((EAX >> 4) & 1) && HasAVXSave;
+ Features["avxvnni"] = HasLeaf7Subleaf1 && ((EAX >> 4) & 1) && HasAVXSave;
Features["avx512bf16"] = HasLeaf7Subleaf1 && ((EAX >> 5) & 1) && HasAVX512Save;
- Features["hreset"] = HasLeaf7Subleaf1 && ((EAX >> 22) & 1);
+ Features["hreset"] = HasLeaf7Subleaf1 && ((EAX >> 22) & 1);
bool HasLeafD = MaxLevel >= 0xd &&
!getX86CpuIDAndInfoEx(0xd, 0x1, &EAX, &EBX, &ECX, &EDX);
@@ -1546,10 +1546,10 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
Features["ptwrite"] = HasLeaf14 && ((EBX >> 4) & 1);
- bool HasLeaf19 =
- MaxLevel >= 0x19 && !getX86CpuIDAndInfo(0x19, &EAX, &EBX, &ECX, &EDX);
- Features["widekl"] = HasLeaf7 && HasLeaf19 && ((EBX >> 2) & 1);
-
+ bool HasLeaf19 =
+ MaxLevel >= 0x19 && !getX86CpuIDAndInfo(0x19, &EAX, &EBX, &ECX, &EDX);
+ Features["widekl"] = HasLeaf7 && HasLeaf19 && ((EBX >> 2) & 1);
+
return true;
}
#elif defined(__linux__) && (defined(__arm__) || defined(__aarch64__))
diff --git a/contrib/libs/llvm12/lib/Support/InitLLVM.cpp b/contrib/libs/llvm12/lib/Support/InitLLVM.cpp
index 152de6ebae..e81b5d1fd1 100644
--- a/contrib/libs/llvm12/lib/Support/InitLLVM.cpp
+++ b/contrib/libs/llvm12/lib/Support/InitLLVM.cpp
@@ -22,17 +22,17 @@ using namespace llvm;
using namespace llvm::sys;
InitLLVM::InitLLVM(int &Argc, const char **&Argv,
- bool InstallPipeSignalExitHandler) {
+ bool InstallPipeSignalExitHandler) {
if (InstallPipeSignalExitHandler)
- // The pipe signal handler must be installed before any other handlers are
- // registered. This is because the Unix \ref RegisterHandlers function does
- // not perform a sigaction() for SIGPIPE unless a one-shot handler is
- // present, to allow long-lived processes (like lldb) to fully opt-out of
- // llvm's SIGPIPE handling and ignore the signal safely.
+ // The pipe signal handler must be installed before any other handlers are
+ // registered. This is because the Unix \ref RegisterHandlers function does
+ // not perform a sigaction() for SIGPIPE unless a one-shot handler is
+ // present, to allow long-lived processes (like lldb) to fully opt-out of
+ // llvm's SIGPIPE handling and ignore the signal safely.
sys::SetOneShotPipeSignalFunction(sys::DefaultOneShotPipeSignalHandler);
- // Initialize the stack printer after installing the one-shot pipe signal
- // handler, so we can perform a sigaction() for SIGPIPE on Unix if requested.
- StackPrinter.emplace(Argc, Argv);
+ // Initialize the stack printer after installing the one-shot pipe signal
+ // handler, so we can perform a sigaction() for SIGPIPE on Unix if requested.
+ StackPrinter.emplace(Argc, Argv);
sys::PrintStackTraceOnErrorSignal(Argv[0]);
install_out_of_memory_new_handler();
diff --git a/contrib/libs/llvm12/lib/Support/InstructionCost.cpp b/contrib/libs/llvm12/lib/Support/InstructionCost.cpp
index c485ce9107..17ea31b7d1 100644
--- a/contrib/libs/llvm12/lib/Support/InstructionCost.cpp
+++ b/contrib/libs/llvm12/lib/Support/InstructionCost.cpp
@@ -1,24 +1,24 @@
-//===- InstructionCost.cpp --------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-/// \file
-/// This file includes the function definitions for the InstructionCost class
-/// that is used when calculating the cost of an instruction, or a group of
-/// instructions.
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Support/InstructionCost.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace llvm;
-
-void InstructionCost::print(raw_ostream &OS) const {
- if (isValid())
- OS << Value;
- else
- OS << "Invalid";
-}
+//===- InstructionCost.cpp --------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file includes the function definitions for the InstructionCost class
+/// that is used when calculating the cost of an instruction, or a group of
+/// instructions.
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/InstructionCost.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+
+void InstructionCost::print(raw_ostream &OS) const {
+ if (isValid())
+ OS << Value;
+ else
+ OS << "Invalid";
+}
diff --git a/contrib/libs/llvm12/lib/Support/JSON.cpp b/contrib/libs/llvm12/lib/Support/JSON.cpp
index dbfd673553..f23694efc4 100644
--- a/contrib/libs/llvm12/lib/Support/JSON.cpp
+++ b/contrib/libs/llvm12/lib/Support/JSON.cpp
@@ -7,11 +7,11 @@
//===---------------------------------------------------------------------===//
#include "llvm/Support/JSON.h"
-#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/ConvertUTF.h"
-#include "llvm/Support/Error.h"
+#include "llvm/Support/Error.h"
#include "llvm/Support/Format.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/raw_ostream.h"
#include <cctype>
namespace llvm {
@@ -109,7 +109,7 @@ void Value::copyFrom(const Value &M) {
case T_Boolean:
case T_Double:
case T_Integer:
- memcpy(&Union, &M.Union, sizeof(Union));
+ memcpy(&Union, &M.Union, sizeof(Union));
break;
case T_StringRef:
create<StringRef>(M.as<StringRef>());
@@ -133,7 +133,7 @@ void Value::moveFrom(const Value &&M) {
case T_Boolean:
case T_Double:
case T_Integer:
- memcpy(&Union, &M.Union, sizeof(Union));
+ memcpy(&Union, &M.Union, sizeof(Union));
break;
case T_StringRef:
create<StringRef>(M.as<StringRef>());
@@ -201,161 +201,161 @@ bool operator==(const Value &L, const Value &R) {
llvm_unreachable("Unknown value kind");
}
-void Path::report(llvm::StringLiteral Msg) {
- // Walk up to the root context, and count the number of segments.
- unsigned Count = 0;
- const Path *P;
- for (P = this; P->Parent != nullptr; P = P->Parent)
- ++Count;
- Path::Root *R = P->Seg.root();
- // Fill in the error message and copy the path (in reverse order).
- R->ErrorMessage = Msg;
- R->ErrorPath.resize(Count);
- auto It = R->ErrorPath.begin();
- for (P = this; P->Parent != nullptr; P = P->Parent)
- *It++ = P->Seg;
-}
-
-Error Path::Root::getError() const {
- std::string S;
- raw_string_ostream OS(S);
- OS << (ErrorMessage.empty() ? "invalid JSON contents" : ErrorMessage);
- if (ErrorPath.empty()) {
- if (!Name.empty())
- OS << " when parsing " << Name;
- } else {
- OS << " at " << (Name.empty() ? "(root)" : Name);
- for (const Path::Segment &S : llvm::reverse(ErrorPath)) {
- if (S.isField())
- OS << '.' << S.field();
- else
- OS << '[' << S.index() << ']';
- }
- }
- return createStringError(llvm::inconvertibleErrorCode(), OS.str());
-}
-
-namespace {
-
-std::vector<const Object::value_type *> sortedElements(const Object &O) {
- std::vector<const Object::value_type *> Elements;
- for (const auto &E : O)
- Elements.push_back(&E);
- llvm::sort(Elements,
- [](const Object::value_type *L, const Object::value_type *R) {
- return L->first < R->first;
- });
- return Elements;
-}
-
-// Prints a one-line version of a value that isn't our main focus.
-// We interleave writes to OS and JOS, exploiting the lack of extra buffering.
-// This is OK as we own the implementation.
-void abbreviate(const Value &V, OStream &JOS) {
- switch (V.kind()) {
- case Value::Array:
- JOS.rawValue(V.getAsArray()->empty() ? "[]" : "[ ... ]");
- break;
- case Value::Object:
- JOS.rawValue(V.getAsObject()->empty() ? "{}" : "{ ... }");
- break;
- case Value::String: {
- llvm::StringRef S = *V.getAsString();
- if (S.size() < 40) {
- JOS.value(V);
- } else {
- std::string Truncated = fixUTF8(S.take_front(37));
- Truncated.append("...");
- JOS.value(Truncated);
- }
- break;
- }
- default:
- JOS.value(V);
- }
-}
-
-// Prints a semi-expanded version of a value that is our main focus.
-// Array/Object entries are printed, but not recursively as they may be huge.
-void abbreviateChildren(const Value &V, OStream &JOS) {
- switch (V.kind()) {
- case Value::Array:
- JOS.array([&] {
- for (const auto &I : *V.getAsArray())
- abbreviate(I, JOS);
- });
- break;
- case Value::Object:
- JOS.object([&] {
- for (const auto *KV : sortedElements(*V.getAsObject())) {
- JOS.attributeBegin(KV->first);
- abbreviate(KV->second, JOS);
- JOS.attributeEnd();
- }
- });
- break;
- default:
- JOS.value(V);
- }
-}
-
-} // namespace
-
-void Path::Root::printErrorContext(const Value &R, raw_ostream &OS) const {
- OStream JOS(OS, /*IndentSize=*/2);
- // PrintValue recurses down the path, printing the ancestors of our target.
- // Siblings of nodes along the path are printed with abbreviate(), and the
- // target itself is printed with the somewhat richer abbreviateChildren().
- // 'Recurse' is the lambda itself, to allow recursive calls.
- auto PrintValue = [&](const Value &V, ArrayRef<Segment> Path, auto &Recurse) {
- // Print the target node itself, with the error as a comment.
- // Also used if we can't follow our path, e.g. it names a field that
- // *should* exist but doesn't.
- auto HighlightCurrent = [&] {
- std::string Comment = "error: ";
- Comment.append(ErrorMessage.data(), ErrorMessage.size());
- JOS.comment(Comment);
- abbreviateChildren(V, JOS);
- };
- if (Path.empty()) // We reached our target.
- return HighlightCurrent();
- const Segment &S = Path.back(); // Path is in reverse order.
- if (S.isField()) {
- // Current node is an object, path names a field.
- llvm::StringRef FieldName = S.field();
- const Object *O = V.getAsObject();
- if (!O || !O->get(FieldName))
- return HighlightCurrent();
- JOS.object([&] {
- for (const auto *KV : sortedElements(*O)) {
- JOS.attributeBegin(KV->first);
- if (FieldName.equals(KV->first))
- Recurse(KV->second, Path.drop_back(), Recurse);
- else
- abbreviate(KV->second, JOS);
- JOS.attributeEnd();
- }
- });
- } else {
- // Current node is an array, path names an element.
- const Array *A = V.getAsArray();
- if (!A || S.index() >= A->size())
- return HighlightCurrent();
- JOS.array([&] {
- unsigned Current = 0;
- for (const auto &V : *A) {
- if (Current++ == S.index())
- Recurse(V, Path.drop_back(), Recurse);
- else
- abbreviate(V, JOS);
- }
- });
- }
- };
- PrintValue(R, ErrorPath, PrintValue);
-}
-
+void Path::report(llvm::StringLiteral Msg) {
+ // Walk up to the root context, and count the number of segments.
+ unsigned Count = 0;
+ const Path *P;
+ for (P = this; P->Parent != nullptr; P = P->Parent)
+ ++Count;
+ Path::Root *R = P->Seg.root();
+ // Fill in the error message and copy the path (in reverse order).
+ R->ErrorMessage = Msg;
+ R->ErrorPath.resize(Count);
+ auto It = R->ErrorPath.begin();
+ for (P = this; P->Parent != nullptr; P = P->Parent)
+ *It++ = P->Seg;
+}
+
+Error Path::Root::getError() const {
+ std::string S;
+ raw_string_ostream OS(S);
+ OS << (ErrorMessage.empty() ? "invalid JSON contents" : ErrorMessage);
+ if (ErrorPath.empty()) {
+ if (!Name.empty())
+ OS << " when parsing " << Name;
+ } else {
+ OS << " at " << (Name.empty() ? "(root)" : Name);
+ for (const Path::Segment &S : llvm::reverse(ErrorPath)) {
+ if (S.isField())
+ OS << '.' << S.field();
+ else
+ OS << '[' << S.index() << ']';
+ }
+ }
+ return createStringError(llvm::inconvertibleErrorCode(), OS.str());
+}
+
namespace {
+
+std::vector<const Object::value_type *> sortedElements(const Object &O) {
+ std::vector<const Object::value_type *> Elements;
+ for (const auto &E : O)
+ Elements.push_back(&E);
+ llvm::sort(Elements,
+ [](const Object::value_type *L, const Object::value_type *R) {
+ return L->first < R->first;
+ });
+ return Elements;
+}
+
+// Prints a one-line version of a value that isn't our main focus.
+// We interleave writes to OS and JOS, exploiting the lack of extra buffering.
+// This is OK as we own the implementation.
+void abbreviate(const Value &V, OStream &JOS) {
+ switch (V.kind()) {
+ case Value::Array:
+ JOS.rawValue(V.getAsArray()->empty() ? "[]" : "[ ... ]");
+ break;
+ case Value::Object:
+ JOS.rawValue(V.getAsObject()->empty() ? "{}" : "{ ... }");
+ break;
+ case Value::String: {
+ llvm::StringRef S = *V.getAsString();
+ if (S.size() < 40) {
+ JOS.value(V);
+ } else {
+ std::string Truncated = fixUTF8(S.take_front(37));
+ Truncated.append("...");
+ JOS.value(Truncated);
+ }
+ break;
+ }
+ default:
+ JOS.value(V);
+ }
+}
+
+// Prints a semi-expanded version of a value that is our main focus.
+// Array/Object entries are printed, but not recursively as they may be huge.
+void abbreviateChildren(const Value &V, OStream &JOS) {
+ switch (V.kind()) {
+ case Value::Array:
+ JOS.array([&] {
+ for (const auto &I : *V.getAsArray())
+ abbreviate(I, JOS);
+ });
+ break;
+ case Value::Object:
+ JOS.object([&] {
+ for (const auto *KV : sortedElements(*V.getAsObject())) {
+ JOS.attributeBegin(KV->first);
+ abbreviate(KV->second, JOS);
+ JOS.attributeEnd();
+ }
+ });
+ break;
+ default:
+ JOS.value(V);
+ }
+}
+
+} // namespace
+
+void Path::Root::printErrorContext(const Value &R, raw_ostream &OS) const {
+ OStream JOS(OS, /*IndentSize=*/2);
+ // PrintValue recurses down the path, printing the ancestors of our target.
+ // Siblings of nodes along the path are printed with abbreviate(), and the
+ // target itself is printed with the somewhat richer abbreviateChildren().
+ // 'Recurse' is the lambda itself, to allow recursive calls.
+ auto PrintValue = [&](const Value &V, ArrayRef<Segment> Path, auto &Recurse) {
+ // Print the target node itself, with the error as a comment.
+ // Also used if we can't follow our path, e.g. it names a field that
+ // *should* exist but doesn't.
+ auto HighlightCurrent = [&] {
+ std::string Comment = "error: ";
+ Comment.append(ErrorMessage.data(), ErrorMessage.size());
+ JOS.comment(Comment);
+ abbreviateChildren(V, JOS);
+ };
+ if (Path.empty()) // We reached our target.
+ return HighlightCurrent();
+ const Segment &S = Path.back(); // Path is in reverse order.
+ if (S.isField()) {
+ // Current node is an object, path names a field.
+ llvm::StringRef FieldName = S.field();
+ const Object *O = V.getAsObject();
+ if (!O || !O->get(FieldName))
+ return HighlightCurrent();
+ JOS.object([&] {
+ for (const auto *KV : sortedElements(*O)) {
+ JOS.attributeBegin(KV->first);
+ if (FieldName.equals(KV->first))
+ Recurse(KV->second, Path.drop_back(), Recurse);
+ else
+ abbreviate(KV->second, JOS);
+ JOS.attributeEnd();
+ }
+ });
+ } else {
+ // Current node is an array, path names an element.
+ const Array *A = V.getAsArray();
+ if (!A || S.index() >= A->size())
+ return HighlightCurrent();
+ JOS.array([&] {
+ unsigned Current = 0;
+ for (const auto &V : *A) {
+ if (Current++ == S.index())
+ Recurse(V, Path.drop_back(), Recurse);
+ else
+ abbreviate(V, JOS);
+ }
+ });
+ }
+ };
+ PrintValue(R, ErrorPath, PrintValue);
+}
+
+namespace {
// Simple recursive-descent JSON parser.
class Parser {
public:
@@ -779,40 +779,40 @@ void llvm::json::OStream::valueBegin() {
}
if (Stack.back().Ctx == Array)
newline();
- flushComment();
+ flushComment();
Stack.back().HasValue = true;
}
-void OStream::comment(llvm::StringRef Comment) {
- assert(PendingComment.empty() && "Only one comment per value!");
- PendingComment = Comment;
-}
-
-void OStream::flushComment() {
- if (PendingComment.empty())
- return;
- OS << (IndentSize ? "/* " : "/*");
- // Be sure not to accidentally emit "*/". Transform to "* /".
- while (!PendingComment.empty()) {
- auto Pos = PendingComment.find("*/");
- if (Pos == StringRef::npos) {
- OS << PendingComment;
- PendingComment = "";
- } else {
- OS << PendingComment.take_front(Pos) << "* /";
- PendingComment = PendingComment.drop_front(Pos + 2);
- }
- }
- OS << (IndentSize ? " */" : "*/");
- // Comments are on their own line unless attached to an attribute value.
- if (Stack.size() > 1 && Stack.back().Ctx == Singleton) {
- if (IndentSize)
- OS << ' ';
- } else {
- newline();
- }
-}
-
+void OStream::comment(llvm::StringRef Comment) {
+ assert(PendingComment.empty() && "Only one comment per value!");
+ PendingComment = Comment;
+}
+
+void OStream::flushComment() {
+ if (PendingComment.empty())
+ return;
+ OS << (IndentSize ? "/* " : "/*");
+ // Be sure not to accidentally emit "*/". Transform to "* /".
+ while (!PendingComment.empty()) {
+ auto Pos = PendingComment.find("*/");
+ if (Pos == StringRef::npos) {
+ OS << PendingComment;
+ PendingComment = "";
+ } else {
+ OS << PendingComment.take_front(Pos) << "* /";
+ PendingComment = PendingComment.drop_front(Pos + 2);
+ }
+ }
+ OS << (IndentSize ? " */" : "*/");
+ // Comments are on their own line unless attached to an attribute value.
+ if (Stack.size() > 1 && Stack.back().Ctx == Singleton) {
+ if (IndentSize)
+ OS << ' ';
+ } else {
+ newline();
+ }
+}
+
void llvm::json::OStream::newline() {
if (IndentSize) {
OS.write('\n');
@@ -834,7 +834,7 @@ void llvm::json::OStream::arrayEnd() {
if (Stack.back().HasValue)
newline();
OS << ']';
- assert(PendingComment.empty());
+ assert(PendingComment.empty());
Stack.pop_back();
assert(!Stack.empty());
}
@@ -853,7 +853,7 @@ void llvm::json::OStream::objectEnd() {
if (Stack.back().HasValue)
newline();
OS << '}';
- assert(PendingComment.empty());
+ assert(PendingComment.empty());
Stack.pop_back();
assert(!Stack.empty());
}
@@ -863,7 +863,7 @@ void llvm::json::OStream::attributeBegin(llvm::StringRef Key) {
if (Stack.back().HasValue)
OS << ',';
newline();
- flushComment();
+ flushComment();
Stack.back().HasValue = true;
Stack.emplace_back();
Stack.back().Ctx = Singleton;
@@ -881,23 +881,23 @@ void llvm::json::OStream::attributeBegin(llvm::StringRef Key) {
void llvm::json::OStream::attributeEnd() {
assert(Stack.back().Ctx == Singleton);
assert(Stack.back().HasValue && "Attribute must have a value");
- assert(PendingComment.empty());
+ assert(PendingComment.empty());
Stack.pop_back();
assert(Stack.back().Ctx == Object);
}
-raw_ostream &llvm::json::OStream::rawValueBegin() {
- valueBegin();
- Stack.emplace_back();
- Stack.back().Ctx = RawValue;
- return OS;
-}
-
-void llvm::json::OStream::rawValueEnd() {
- assert(Stack.back().Ctx == RawValue);
- Stack.pop_back();
-}
-
+raw_ostream &llvm::json::OStream::rawValueBegin() {
+ valueBegin();
+ Stack.emplace_back();
+ Stack.back().Ctx = RawValue;
+ return OS;
+}
+
+void llvm::json::OStream::rawValueEnd() {
+ assert(Stack.back().Ctx == RawValue);
+ Stack.pop_back();
+}
+
} // namespace json
} // namespace llvm
diff --git a/contrib/libs/llvm12/lib/Support/KnownBits.cpp b/contrib/libs/llvm12/lib/Support/KnownBits.cpp
index 3623a54ae4..dcd51675e9 100644
--- a/contrib/libs/llvm12/lib/Support/KnownBits.cpp
+++ b/contrib/libs/llvm12/lib/Support/KnownBits.cpp
@@ -83,403 +83,403 @@ KnownBits KnownBits::computeForAddSub(bool Add, bool NSW,
return KnownOut;
}
-KnownBits KnownBits::sextInReg(unsigned SrcBitWidth) const {
- unsigned BitWidth = getBitWidth();
- assert(0 < SrcBitWidth && SrcBitWidth <= BitWidth &&
- "Illegal sext-in-register");
-
- if (SrcBitWidth == BitWidth)
- return *this;
-
- unsigned ExtBits = BitWidth - SrcBitWidth;
- KnownBits Result;
- Result.One = One << ExtBits;
- Result.Zero = Zero << ExtBits;
- Result.One.ashrInPlace(ExtBits);
- Result.Zero.ashrInPlace(ExtBits);
- return Result;
-}
-
-KnownBits KnownBits::makeGE(const APInt &Val) const {
- // Count the number of leading bit positions where our underlying value is
- // known to be less than or equal to Val.
- unsigned N = (Zero | Val).countLeadingOnes();
-
- // For each of those bit positions, if Val has a 1 in that bit then our
- // underlying value must also have a 1.
- APInt MaskedVal(Val);
- MaskedVal.clearLowBits(getBitWidth() - N);
- return KnownBits(Zero, One | MaskedVal);
-}
-
-KnownBits KnownBits::umax(const KnownBits &LHS, const KnownBits &RHS) {
- // If we can prove that LHS >= RHS then use LHS as the result. Likewise for
- // RHS. Ideally our caller would already have spotted these cases and
- // optimized away the umax operation, but we handle them here for
- // completeness.
- if (LHS.getMinValue().uge(RHS.getMaxValue()))
- return LHS;
- if (RHS.getMinValue().uge(LHS.getMaxValue()))
- return RHS;
-
- // If the result of the umax is LHS then it must be greater than or equal to
- // the minimum possible value of RHS. Likewise for RHS. Any known bits that
- // are common to these two values are also known in the result.
- KnownBits L = LHS.makeGE(RHS.getMinValue());
- KnownBits R = RHS.makeGE(LHS.getMinValue());
- return KnownBits::commonBits(L, R);
-}
-
-KnownBits KnownBits::umin(const KnownBits &LHS, const KnownBits &RHS) {
- // Flip the range of values: [0, 0xFFFFFFFF] <-> [0xFFFFFFFF, 0]
- auto Flip = [](const KnownBits &Val) { return KnownBits(Val.One, Val.Zero); };
- return Flip(umax(Flip(LHS), Flip(RHS)));
-}
-
-KnownBits KnownBits::smax(const KnownBits &LHS, const KnownBits &RHS) {
- // Flip the range of values: [-0x80000000, 0x7FFFFFFF] <-> [0, 0xFFFFFFFF]
- auto Flip = [](const KnownBits &Val) {
- unsigned SignBitPosition = Val.getBitWidth() - 1;
- APInt Zero = Val.Zero;
- APInt One = Val.One;
- Zero.setBitVal(SignBitPosition, Val.One[SignBitPosition]);
- One.setBitVal(SignBitPosition, Val.Zero[SignBitPosition]);
- return KnownBits(Zero, One);
- };
- return Flip(umax(Flip(LHS), Flip(RHS)));
-}
-
-KnownBits KnownBits::smin(const KnownBits &LHS, const KnownBits &RHS) {
- // Flip the range of values: [-0x80000000, 0x7FFFFFFF] <-> [0xFFFFFFFF, 0]
- auto Flip = [](const KnownBits &Val) {
- unsigned SignBitPosition = Val.getBitWidth() - 1;
- APInt Zero = Val.One;
- APInt One = Val.Zero;
- Zero.setBitVal(SignBitPosition, Val.Zero[SignBitPosition]);
- One.setBitVal(SignBitPosition, Val.One[SignBitPosition]);
- return KnownBits(Zero, One);
- };
- return Flip(umax(Flip(LHS), Flip(RHS)));
-}
-
-KnownBits KnownBits::shl(const KnownBits &LHS, const KnownBits &RHS) {
- unsigned BitWidth = LHS.getBitWidth();
- KnownBits Known(BitWidth);
-
- // If the shift amount is a valid constant then transform LHS directly.
- if (RHS.isConstant() && RHS.getConstant().ult(BitWidth)) {
- unsigned Shift = RHS.getConstant().getZExtValue();
- Known = LHS;
- Known.Zero <<= Shift;
- Known.One <<= Shift;
- // Low bits are known zero.
- Known.Zero.setLowBits(Shift);
- return Known;
- }
-
- // No matter the shift amount, the trailing zeros will stay zero.
- unsigned MinTrailingZeros = LHS.countMinTrailingZeros();
-
- // Minimum shift amount low bits are known zero.
- if (RHS.getMinValue().ult(BitWidth)) {
- MinTrailingZeros += RHS.getMinValue().getZExtValue();
- MinTrailingZeros = std::min(MinTrailingZeros, BitWidth);
- }
-
- Known.Zero.setLowBits(MinTrailingZeros);
- return Known;
-}
-
-KnownBits KnownBits::lshr(const KnownBits &LHS, const KnownBits &RHS) {
- unsigned BitWidth = LHS.getBitWidth();
- KnownBits Known(BitWidth);
-
- if (RHS.isConstant() && RHS.getConstant().ult(BitWidth)) {
- unsigned Shift = RHS.getConstant().getZExtValue();
- Known = LHS;
- Known.Zero.lshrInPlace(Shift);
- Known.One.lshrInPlace(Shift);
- // High bits are known zero.
- Known.Zero.setHighBits(Shift);
- return Known;
- }
-
- // No matter the shift amount, the leading zeros will stay zero.
- unsigned MinLeadingZeros = LHS.countMinLeadingZeros();
-
- // Minimum shift amount high bits are known zero.
- if (RHS.getMinValue().ult(BitWidth)) {
- MinLeadingZeros += RHS.getMinValue().getZExtValue();
- MinLeadingZeros = std::min(MinLeadingZeros, BitWidth);
- }
-
- Known.Zero.setHighBits(MinLeadingZeros);
- return Known;
-}
-
-KnownBits KnownBits::ashr(const KnownBits &LHS, const KnownBits &RHS) {
- unsigned BitWidth = LHS.getBitWidth();
- KnownBits Known(BitWidth);
-
- if (RHS.isConstant() && RHS.getConstant().ult(BitWidth)) {
- unsigned Shift = RHS.getConstant().getZExtValue();
- Known = LHS;
- Known.Zero.ashrInPlace(Shift);
- Known.One.ashrInPlace(Shift);
- return Known;
- }
-
- // No matter the shift amount, the leading sign bits will stay.
- unsigned MinLeadingZeros = LHS.countMinLeadingZeros();
- unsigned MinLeadingOnes = LHS.countMinLeadingOnes();
-
- // Minimum shift amount high bits are known sign bits.
- if (RHS.getMinValue().ult(BitWidth)) {
- if (MinLeadingZeros) {
- MinLeadingZeros += RHS.getMinValue().getZExtValue();
- MinLeadingZeros = std::min(MinLeadingZeros, BitWidth);
- }
- if (MinLeadingOnes) {
- MinLeadingOnes += RHS.getMinValue().getZExtValue();
- MinLeadingOnes = std::min(MinLeadingOnes, BitWidth);
- }
- }
-
- Known.Zero.setHighBits(MinLeadingZeros);
- Known.One.setHighBits(MinLeadingOnes);
- return Known;
-}
-
-Optional<bool> KnownBits::eq(const KnownBits &LHS, const KnownBits &RHS) {
- if (LHS.isConstant() && RHS.isConstant())
- return Optional<bool>(LHS.getConstant() == RHS.getConstant());
- if (LHS.One.intersects(RHS.Zero) || RHS.One.intersects(LHS.Zero))
- return Optional<bool>(false);
- return None;
-}
-
-Optional<bool> KnownBits::ne(const KnownBits &LHS, const KnownBits &RHS) {
- if (Optional<bool> KnownEQ = eq(LHS, RHS))
- return Optional<bool>(!KnownEQ.getValue());
- return None;
-}
-
-Optional<bool> KnownBits::ugt(const KnownBits &LHS, const KnownBits &RHS) {
- // LHS >u RHS -> false if umax(LHS) <= umax(RHS)
- if (LHS.getMaxValue().ule(RHS.getMinValue()))
- return Optional<bool>(false);
- // LHS >u RHS -> true if umin(LHS) > umax(RHS)
- if (LHS.getMinValue().ugt(RHS.getMaxValue()))
- return Optional<bool>(true);
- return None;
-}
-
-Optional<bool> KnownBits::uge(const KnownBits &LHS, const KnownBits &RHS) {
- if (Optional<bool> IsUGT = ugt(RHS, LHS))
- return Optional<bool>(!IsUGT.getValue());
- return None;
-}
-
-Optional<bool> KnownBits::ult(const KnownBits &LHS, const KnownBits &RHS) {
- return ugt(RHS, LHS);
-}
-
-Optional<bool> KnownBits::ule(const KnownBits &LHS, const KnownBits &RHS) {
- return uge(RHS, LHS);
-}
-
-Optional<bool> KnownBits::sgt(const KnownBits &LHS, const KnownBits &RHS) {
- // LHS >s RHS -> false if smax(LHS) <= smax(RHS)
- if (LHS.getSignedMaxValue().sle(RHS.getSignedMinValue()))
- return Optional<bool>(false);
- // LHS >s RHS -> true if smin(LHS) > smax(RHS)
- if (LHS.getSignedMinValue().sgt(RHS.getSignedMaxValue()))
- return Optional<bool>(true);
- return None;
-}
-
-Optional<bool> KnownBits::sge(const KnownBits &LHS, const KnownBits &RHS) {
- if (Optional<bool> KnownSGT = sgt(RHS, LHS))
- return Optional<bool>(!KnownSGT.getValue());
- return None;
-}
-
-Optional<bool> KnownBits::slt(const KnownBits &LHS, const KnownBits &RHS) {
- return sgt(RHS, LHS);
-}
-
-Optional<bool> KnownBits::sle(const KnownBits &LHS, const KnownBits &RHS) {
- return sge(RHS, LHS);
-}
-
-KnownBits KnownBits::abs(bool IntMinIsPoison) const {
- // If the source's MSB is zero then we know the rest of the bits already.
- if (isNonNegative())
- return *this;
-
- // Absolute value preserves trailing zero count.
- KnownBits KnownAbs(getBitWidth());
- KnownAbs.Zero.setLowBits(countMinTrailingZeros());
-
- // We only know that the absolute values's MSB will be zero if INT_MIN is
- // poison, or there is a set bit that isn't the sign bit (otherwise it could
- // be INT_MIN).
- if (IntMinIsPoison || (!One.isNullValue() && !One.isMinSignedValue()))
- KnownAbs.Zero.setSignBit();
-
- // FIXME: Handle known negative input?
- // FIXME: Calculate the negated Known bits and combine them?
- return KnownAbs;
-}
-
-KnownBits KnownBits::computeForMul(const KnownBits &LHS, const KnownBits &RHS) {
- unsigned BitWidth = LHS.getBitWidth();
-
- assert(!LHS.hasConflict() && !RHS.hasConflict());
- // Compute a conservative estimate for high known-0 bits.
- unsigned LeadZ =
- std::max(LHS.countMinLeadingZeros() + RHS.countMinLeadingZeros(),
- BitWidth) -
- BitWidth;
- LeadZ = std::min(LeadZ, BitWidth);
-
- // The result of the bottom bits of an integer multiply can be
- // inferred by looking at the bottom bits of both operands and
- // multiplying them together.
- // We can infer at least the minimum number of known trailing bits
- // of both operands. Depending on number of trailing zeros, we can
- // infer more bits, because (a*b) <=> ((a/m) * (b/n)) * (m*n) assuming
- // a and b are divisible by m and n respectively.
- // We then calculate how many of those bits are inferrable and set
- // the output. For example, the i8 mul:
- // a = XXXX1100 (12)
- // b = XXXX1110 (14)
- // We know the bottom 3 bits are zero since the first can be divided by
- // 4 and the second by 2, thus having ((12/4) * (14/2)) * (2*4).
- // Applying the multiplication to the trimmed arguments gets:
- // XX11 (3)
- // X111 (7)
- // -------
- // XX11
- // XX11
- // XX11
- // XX11
- // -------
- // XXXXX01
- // Which allows us to infer the 2 LSBs. Since we're multiplying the result
- // by 8, the bottom 3 bits will be 0, so we can infer a total of 5 bits.
- // The proof for this can be described as:
- // Pre: (C1 >= 0) && (C1 < (1 << C5)) && (C2 >= 0) && (C2 < (1 << C6)) &&
- // (C7 == (1 << (umin(countTrailingZeros(C1), C5) +
- // umin(countTrailingZeros(C2), C6) +
- // umin(C5 - umin(countTrailingZeros(C1), C5),
- // C6 - umin(countTrailingZeros(C2), C6)))) - 1)
- // %aa = shl i8 %a, C5
- // %bb = shl i8 %b, C6
- // %aaa = or i8 %aa, C1
- // %bbb = or i8 %bb, C2
- // %mul = mul i8 %aaa, %bbb
- // %mask = and i8 %mul, C7
- // =>
- // %mask = i8 ((C1*C2)&C7)
- // Where C5, C6 describe the known bits of %a, %b
- // C1, C2 describe the known bottom bits of %a, %b.
- // C7 describes the mask of the known bits of the result.
- const APInt &Bottom0 = LHS.One;
- const APInt &Bottom1 = RHS.One;
-
- // How many times we'd be able to divide each argument by 2 (shr by 1).
- // This gives us the number of trailing zeros on the multiplication result.
- unsigned TrailBitsKnown0 = (LHS.Zero | LHS.One).countTrailingOnes();
- unsigned TrailBitsKnown1 = (RHS.Zero | RHS.One).countTrailingOnes();
- unsigned TrailZero0 = LHS.countMinTrailingZeros();
- unsigned TrailZero1 = RHS.countMinTrailingZeros();
- unsigned TrailZ = TrailZero0 + TrailZero1;
-
- // Figure out the fewest known-bits operand.
- unsigned SmallestOperand =
- std::min(TrailBitsKnown0 - TrailZero0, TrailBitsKnown1 - TrailZero1);
- unsigned ResultBitsKnown = std::min(SmallestOperand + TrailZ, BitWidth);
-
- APInt BottomKnown =
- Bottom0.getLoBits(TrailBitsKnown0) * Bottom1.getLoBits(TrailBitsKnown1);
-
- KnownBits Res(BitWidth);
- Res.Zero.setHighBits(LeadZ);
- Res.Zero |= (~BottomKnown).getLoBits(ResultBitsKnown);
- Res.One = BottomKnown.getLoBits(ResultBitsKnown);
- return Res;
-}
-
-KnownBits KnownBits::udiv(const KnownBits &LHS, const KnownBits &RHS) {
- unsigned BitWidth = LHS.getBitWidth();
- assert(!LHS.hasConflict() && !RHS.hasConflict());
- KnownBits Known(BitWidth);
-
- // For the purposes of computing leading zeros we can conservatively
- // treat a udiv as a logical right shift by the power of 2 known to
- // be less than the denominator.
- unsigned LeadZ = LHS.countMinLeadingZeros();
- unsigned RHSMaxLeadingZeros = RHS.countMaxLeadingZeros();
-
- if (RHSMaxLeadingZeros != BitWidth)
- LeadZ = std::min(BitWidth, LeadZ + BitWidth - RHSMaxLeadingZeros - 1);
-
- Known.Zero.setHighBits(LeadZ);
- return Known;
-}
-
-KnownBits KnownBits::urem(const KnownBits &LHS, const KnownBits &RHS) {
- unsigned BitWidth = LHS.getBitWidth();
- assert(!LHS.hasConflict() && !RHS.hasConflict());
- KnownBits Known(BitWidth);
-
- if (RHS.isConstant() && RHS.getConstant().isPowerOf2()) {
- // The upper bits are all zero, the lower ones are unchanged.
- APInt LowBits = RHS.getConstant() - 1;
- Known.Zero = LHS.Zero | ~LowBits;
- Known.One = LHS.One & LowBits;
- return Known;
- }
-
- // Since the result is less than or equal to either operand, any leading
- // zero bits in either operand must also exist in the result.
- uint32_t Leaders =
- std::max(LHS.countMinLeadingZeros(), RHS.countMinLeadingZeros());
- Known.Zero.setHighBits(Leaders);
- return Known;
-}
-
-KnownBits KnownBits::srem(const KnownBits &LHS, const KnownBits &RHS) {
- unsigned BitWidth = LHS.getBitWidth();
- assert(!LHS.hasConflict() && !RHS.hasConflict());
- KnownBits Known(BitWidth);
-
- if (RHS.isConstant() && RHS.getConstant().isPowerOf2()) {
- // The low bits of the first operand are unchanged by the srem.
- APInt LowBits = RHS.getConstant() - 1;
- Known.Zero = LHS.Zero & LowBits;
- Known.One = LHS.One & LowBits;
-
- // If the first operand is non-negative or has all low bits zero, then
- // the upper bits are all zero.
- if (LHS.isNonNegative() || LowBits.isSubsetOf(LHS.Zero))
- Known.Zero |= ~LowBits;
-
- // If the first operand is negative and not all low bits are zero, then
- // the upper bits are all one.
- if (LHS.isNegative() && LowBits.intersects(LHS.One))
- Known.One |= ~LowBits;
- return Known;
- }
-
- // The sign bit is the LHS's sign bit, except when the result of the
- // remainder is zero. If it's known zero, our sign bit is also zero.
- if (LHS.isNonNegative())
- Known.makeNonNegative();
- return Known;
-}
-
+KnownBits KnownBits::sextInReg(unsigned SrcBitWidth) const {
+ unsigned BitWidth = getBitWidth();
+ assert(0 < SrcBitWidth && SrcBitWidth <= BitWidth &&
+ "Illegal sext-in-register");
+
+ if (SrcBitWidth == BitWidth)
+ return *this;
+
+ unsigned ExtBits = BitWidth - SrcBitWidth;
+ KnownBits Result;
+ Result.One = One << ExtBits;
+ Result.Zero = Zero << ExtBits;
+ Result.One.ashrInPlace(ExtBits);
+ Result.Zero.ashrInPlace(ExtBits);
+ return Result;
+}
+
+KnownBits KnownBits::makeGE(const APInt &Val) const {
+ // Count the number of leading bit positions where our underlying value is
+ // known to be less than or equal to Val.
+ unsigned N = (Zero | Val).countLeadingOnes();
+
+ // For each of those bit positions, if Val has a 1 in that bit then our
+ // underlying value must also have a 1.
+ APInt MaskedVal(Val);
+ MaskedVal.clearLowBits(getBitWidth() - N);
+ return KnownBits(Zero, One | MaskedVal);
+}
+
+KnownBits KnownBits::umax(const KnownBits &LHS, const KnownBits &RHS) {
+ // If we can prove that LHS >= RHS then use LHS as the result. Likewise for
+ // RHS. Ideally our caller would already have spotted these cases and
+ // optimized away the umax operation, but we handle them here for
+ // completeness.
+ if (LHS.getMinValue().uge(RHS.getMaxValue()))
+ return LHS;
+ if (RHS.getMinValue().uge(LHS.getMaxValue()))
+ return RHS;
+
+ // If the result of the umax is LHS then it must be greater than or equal to
+ // the minimum possible value of RHS. Likewise for RHS. Any known bits that
+ // are common to these two values are also known in the result.
+ KnownBits L = LHS.makeGE(RHS.getMinValue());
+ KnownBits R = RHS.makeGE(LHS.getMinValue());
+ return KnownBits::commonBits(L, R);
+}
+
+KnownBits KnownBits::umin(const KnownBits &LHS, const KnownBits &RHS) {
+ // Flip the range of values: [0, 0xFFFFFFFF] <-> [0xFFFFFFFF, 0]
+ auto Flip = [](const KnownBits &Val) { return KnownBits(Val.One, Val.Zero); };
+ return Flip(umax(Flip(LHS), Flip(RHS)));
+}
+
+KnownBits KnownBits::smax(const KnownBits &LHS, const KnownBits &RHS) {
+ // Flip the range of values: [-0x80000000, 0x7FFFFFFF] <-> [0, 0xFFFFFFFF]
+ auto Flip = [](const KnownBits &Val) {
+ unsigned SignBitPosition = Val.getBitWidth() - 1;
+ APInt Zero = Val.Zero;
+ APInt One = Val.One;
+ Zero.setBitVal(SignBitPosition, Val.One[SignBitPosition]);
+ One.setBitVal(SignBitPosition, Val.Zero[SignBitPosition]);
+ return KnownBits(Zero, One);
+ };
+ return Flip(umax(Flip(LHS), Flip(RHS)));
+}
+
+KnownBits KnownBits::smin(const KnownBits &LHS, const KnownBits &RHS) {
+ // Flip the range of values: [-0x80000000, 0x7FFFFFFF] <-> [0xFFFFFFFF, 0]
+ auto Flip = [](const KnownBits &Val) {
+ unsigned SignBitPosition = Val.getBitWidth() - 1;
+ APInt Zero = Val.One;
+ APInt One = Val.Zero;
+ Zero.setBitVal(SignBitPosition, Val.Zero[SignBitPosition]);
+ One.setBitVal(SignBitPosition, Val.One[SignBitPosition]);
+ return KnownBits(Zero, One);
+ };
+ return Flip(umax(Flip(LHS), Flip(RHS)));
+}
+
+KnownBits KnownBits::shl(const KnownBits &LHS, const KnownBits &RHS) {
+ unsigned BitWidth = LHS.getBitWidth();
+ KnownBits Known(BitWidth);
+
+ // If the shift amount is a valid constant then transform LHS directly.
+ if (RHS.isConstant() && RHS.getConstant().ult(BitWidth)) {
+ unsigned Shift = RHS.getConstant().getZExtValue();
+ Known = LHS;
+ Known.Zero <<= Shift;
+ Known.One <<= Shift;
+ // Low bits are known zero.
+ Known.Zero.setLowBits(Shift);
+ return Known;
+ }
+
+ // No matter the shift amount, the trailing zeros will stay zero.
+ unsigned MinTrailingZeros = LHS.countMinTrailingZeros();
+
+ // Minimum shift amount low bits are known zero.
+ if (RHS.getMinValue().ult(BitWidth)) {
+ MinTrailingZeros += RHS.getMinValue().getZExtValue();
+ MinTrailingZeros = std::min(MinTrailingZeros, BitWidth);
+ }
+
+ Known.Zero.setLowBits(MinTrailingZeros);
+ return Known;
+}
+
+KnownBits KnownBits::lshr(const KnownBits &LHS, const KnownBits &RHS) {
+ unsigned BitWidth = LHS.getBitWidth();
+ KnownBits Known(BitWidth);
+
+ if (RHS.isConstant() && RHS.getConstant().ult(BitWidth)) {
+ unsigned Shift = RHS.getConstant().getZExtValue();
+ Known = LHS;
+ Known.Zero.lshrInPlace(Shift);
+ Known.One.lshrInPlace(Shift);
+ // High bits are known zero.
+ Known.Zero.setHighBits(Shift);
+ return Known;
+ }
+
+ // No matter the shift amount, the leading zeros will stay zero.
+ unsigned MinLeadingZeros = LHS.countMinLeadingZeros();
+
+ // Minimum shift amount high bits are known zero.
+ if (RHS.getMinValue().ult(BitWidth)) {
+ MinLeadingZeros += RHS.getMinValue().getZExtValue();
+ MinLeadingZeros = std::min(MinLeadingZeros, BitWidth);
+ }
+
+ Known.Zero.setHighBits(MinLeadingZeros);
+ return Known;
+}
+
+KnownBits KnownBits::ashr(const KnownBits &LHS, const KnownBits &RHS) {
+ unsigned BitWidth = LHS.getBitWidth();
+ KnownBits Known(BitWidth);
+
+ if (RHS.isConstant() && RHS.getConstant().ult(BitWidth)) {
+ unsigned Shift = RHS.getConstant().getZExtValue();
+ Known = LHS;
+ Known.Zero.ashrInPlace(Shift);
+ Known.One.ashrInPlace(Shift);
+ return Known;
+ }
+
+ // No matter the shift amount, the leading sign bits will stay.
+ unsigned MinLeadingZeros = LHS.countMinLeadingZeros();
+ unsigned MinLeadingOnes = LHS.countMinLeadingOnes();
+
+ // Minimum shift amount high bits are known sign bits.
+ if (RHS.getMinValue().ult(BitWidth)) {
+ if (MinLeadingZeros) {
+ MinLeadingZeros += RHS.getMinValue().getZExtValue();
+ MinLeadingZeros = std::min(MinLeadingZeros, BitWidth);
+ }
+ if (MinLeadingOnes) {
+ MinLeadingOnes += RHS.getMinValue().getZExtValue();
+ MinLeadingOnes = std::min(MinLeadingOnes, BitWidth);
+ }
+ }
+
+ Known.Zero.setHighBits(MinLeadingZeros);
+ Known.One.setHighBits(MinLeadingOnes);
+ return Known;
+}
+
+Optional<bool> KnownBits::eq(const KnownBits &LHS, const KnownBits &RHS) {
+ if (LHS.isConstant() && RHS.isConstant())
+ return Optional<bool>(LHS.getConstant() == RHS.getConstant());
+ if (LHS.One.intersects(RHS.Zero) || RHS.One.intersects(LHS.Zero))
+ return Optional<bool>(false);
+ return None;
+}
+
+Optional<bool> KnownBits::ne(const KnownBits &LHS, const KnownBits &RHS) {
+ if (Optional<bool> KnownEQ = eq(LHS, RHS))
+ return Optional<bool>(!KnownEQ.getValue());
+ return None;
+}
+
+Optional<bool> KnownBits::ugt(const KnownBits &LHS, const KnownBits &RHS) {
+ // LHS >u RHS -> false if umax(LHS) <= umax(RHS)
+ if (LHS.getMaxValue().ule(RHS.getMinValue()))
+ return Optional<bool>(false);
+ // LHS >u RHS -> true if umin(LHS) > umax(RHS)
+ if (LHS.getMinValue().ugt(RHS.getMaxValue()))
+ return Optional<bool>(true);
+ return None;
+}
+
+Optional<bool> KnownBits::uge(const KnownBits &LHS, const KnownBits &RHS) {
+ if (Optional<bool> IsUGT = ugt(RHS, LHS))
+ return Optional<bool>(!IsUGT.getValue());
+ return None;
+}
+
+Optional<bool> KnownBits::ult(const KnownBits &LHS, const KnownBits &RHS) {
+ return ugt(RHS, LHS);
+}
+
+Optional<bool> KnownBits::ule(const KnownBits &LHS, const KnownBits &RHS) {
+ return uge(RHS, LHS);
+}
+
+Optional<bool> KnownBits::sgt(const KnownBits &LHS, const KnownBits &RHS) {
+ // LHS >s RHS -> false if smax(LHS) <= smax(RHS)
+ if (LHS.getSignedMaxValue().sle(RHS.getSignedMinValue()))
+ return Optional<bool>(false);
+ // LHS >s RHS -> true if smin(LHS) > smax(RHS)
+ if (LHS.getSignedMinValue().sgt(RHS.getSignedMaxValue()))
+ return Optional<bool>(true);
+ return None;
+}
+
+Optional<bool> KnownBits::sge(const KnownBits &LHS, const KnownBits &RHS) {
+ if (Optional<bool> KnownSGT = sgt(RHS, LHS))
+ return Optional<bool>(!KnownSGT.getValue());
+ return None;
+}
+
+Optional<bool> KnownBits::slt(const KnownBits &LHS, const KnownBits &RHS) {
+ return sgt(RHS, LHS);
+}
+
+Optional<bool> KnownBits::sle(const KnownBits &LHS, const KnownBits &RHS) {
+ return sge(RHS, LHS);
+}
+
+KnownBits KnownBits::abs(bool IntMinIsPoison) const {
+ // If the source's MSB is zero then we know the rest of the bits already.
+ if (isNonNegative())
+ return *this;
+
+ // Absolute value preserves trailing zero count.
+ KnownBits KnownAbs(getBitWidth());
+ KnownAbs.Zero.setLowBits(countMinTrailingZeros());
+
+ // We only know that the absolute values's MSB will be zero if INT_MIN is
+ // poison, or there is a set bit that isn't the sign bit (otherwise it could
+ // be INT_MIN).
+ if (IntMinIsPoison || (!One.isNullValue() && !One.isMinSignedValue()))
+ KnownAbs.Zero.setSignBit();
+
+ // FIXME: Handle known negative input?
+ // FIXME: Calculate the negated Known bits and combine them?
+ return KnownAbs;
+}
+
+KnownBits KnownBits::computeForMul(const KnownBits &LHS, const KnownBits &RHS) {
+ unsigned BitWidth = LHS.getBitWidth();
+
+ assert(!LHS.hasConflict() && !RHS.hasConflict());
+ // Compute a conservative estimate for high known-0 bits.
+ unsigned LeadZ =
+ std::max(LHS.countMinLeadingZeros() + RHS.countMinLeadingZeros(),
+ BitWidth) -
+ BitWidth;
+ LeadZ = std::min(LeadZ, BitWidth);
+
+ // The result of the bottom bits of an integer multiply can be
+ // inferred by looking at the bottom bits of both operands and
+ // multiplying them together.
+ // We can infer at least the minimum number of known trailing bits
+ // of both operands. Depending on number of trailing zeros, we can
+ // infer more bits, because (a*b) <=> ((a/m) * (b/n)) * (m*n) assuming
+ // a and b are divisible by m and n respectively.
+ // We then calculate how many of those bits are inferrable and set
+ // the output. For example, the i8 mul:
+ // a = XXXX1100 (12)
+ // b = XXXX1110 (14)
+ // We know the bottom 3 bits are zero since the first can be divided by
+ // 4 and the second by 2, thus having ((12/4) * (14/2)) * (2*4).
+ // Applying the multiplication to the trimmed arguments gets:
+ // XX11 (3)
+ // X111 (7)
+ // -------
+ // XX11
+ // XX11
+ // XX11
+ // XX11
+ // -------
+ // XXXXX01
+ // Which allows us to infer the 2 LSBs. Since we're multiplying the result
+ // by 8, the bottom 3 bits will be 0, so we can infer a total of 5 bits.
+ // The proof for this can be described as:
+ // Pre: (C1 >= 0) && (C1 < (1 << C5)) && (C2 >= 0) && (C2 < (1 << C6)) &&
+ // (C7 == (1 << (umin(countTrailingZeros(C1), C5) +
+ // umin(countTrailingZeros(C2), C6) +
+ // umin(C5 - umin(countTrailingZeros(C1), C5),
+ // C6 - umin(countTrailingZeros(C2), C6)))) - 1)
+ // %aa = shl i8 %a, C5
+ // %bb = shl i8 %b, C6
+ // %aaa = or i8 %aa, C1
+ // %bbb = or i8 %bb, C2
+ // %mul = mul i8 %aaa, %bbb
+ // %mask = and i8 %mul, C7
+ // =>
+ // %mask = i8 ((C1*C2)&C7)
+ // Where C5, C6 describe the known bits of %a, %b
+ // C1, C2 describe the known bottom bits of %a, %b.
+ // C7 describes the mask of the known bits of the result.
+ const APInt &Bottom0 = LHS.One;
+ const APInt &Bottom1 = RHS.One;
+
+ // How many times we'd be able to divide each argument by 2 (shr by 1).
+ // This gives us the number of trailing zeros on the multiplication result.
+ unsigned TrailBitsKnown0 = (LHS.Zero | LHS.One).countTrailingOnes();
+ unsigned TrailBitsKnown1 = (RHS.Zero | RHS.One).countTrailingOnes();
+ unsigned TrailZero0 = LHS.countMinTrailingZeros();
+ unsigned TrailZero1 = RHS.countMinTrailingZeros();
+ unsigned TrailZ = TrailZero0 + TrailZero1;
+
+ // Figure out the fewest known-bits operand.
+ unsigned SmallestOperand =
+ std::min(TrailBitsKnown0 - TrailZero0, TrailBitsKnown1 - TrailZero1);
+ unsigned ResultBitsKnown = std::min(SmallestOperand + TrailZ, BitWidth);
+
+ APInt BottomKnown =
+ Bottom0.getLoBits(TrailBitsKnown0) * Bottom1.getLoBits(TrailBitsKnown1);
+
+ KnownBits Res(BitWidth);
+ Res.Zero.setHighBits(LeadZ);
+ Res.Zero |= (~BottomKnown).getLoBits(ResultBitsKnown);
+ Res.One = BottomKnown.getLoBits(ResultBitsKnown);
+ return Res;
+}
+
+KnownBits KnownBits::udiv(const KnownBits &LHS, const KnownBits &RHS) {
+ unsigned BitWidth = LHS.getBitWidth();
+ assert(!LHS.hasConflict() && !RHS.hasConflict());
+ KnownBits Known(BitWidth);
+
+ // For the purposes of computing leading zeros we can conservatively
+ // treat a udiv as a logical right shift by the power of 2 known to
+ // be less than the denominator.
+ unsigned LeadZ = LHS.countMinLeadingZeros();
+ unsigned RHSMaxLeadingZeros = RHS.countMaxLeadingZeros();
+
+ if (RHSMaxLeadingZeros != BitWidth)
+ LeadZ = std::min(BitWidth, LeadZ + BitWidth - RHSMaxLeadingZeros - 1);
+
+ Known.Zero.setHighBits(LeadZ);
+ return Known;
+}
+
+KnownBits KnownBits::urem(const KnownBits &LHS, const KnownBits &RHS) {
+ unsigned BitWidth = LHS.getBitWidth();
+ assert(!LHS.hasConflict() && !RHS.hasConflict());
+ KnownBits Known(BitWidth);
+
+ if (RHS.isConstant() && RHS.getConstant().isPowerOf2()) {
+ // The upper bits are all zero, the lower ones are unchanged.
+ APInt LowBits = RHS.getConstant() - 1;
+ Known.Zero = LHS.Zero | ~LowBits;
+ Known.One = LHS.One & LowBits;
+ return Known;
+ }
+
+ // Since the result is less than or equal to either operand, any leading
+ // zero bits in either operand must also exist in the result.
+ uint32_t Leaders =
+ std::max(LHS.countMinLeadingZeros(), RHS.countMinLeadingZeros());
+ Known.Zero.setHighBits(Leaders);
+ return Known;
+}
+
+KnownBits KnownBits::srem(const KnownBits &LHS, const KnownBits &RHS) {
+ unsigned BitWidth = LHS.getBitWidth();
+ assert(!LHS.hasConflict() && !RHS.hasConflict());
+ KnownBits Known(BitWidth);
+
+ if (RHS.isConstant() && RHS.getConstant().isPowerOf2()) {
+ // The low bits of the first operand are unchanged by the srem.
+ APInt LowBits = RHS.getConstant() - 1;
+ Known.Zero = LHS.Zero & LowBits;
+ Known.One = LHS.One & LowBits;
+
+ // If the first operand is non-negative or has all low bits zero, then
+ // the upper bits are all zero.
+ if (LHS.isNonNegative() || LowBits.isSubsetOf(LHS.Zero))
+ Known.Zero |= ~LowBits;
+
+ // If the first operand is negative and not all low bits are zero, then
+ // the upper bits are all one.
+ if (LHS.isNegative() && LowBits.intersects(LHS.One))
+ Known.One |= ~LowBits;
+ return Known;
+ }
+
+ // The sign bit is the LHS's sign bit, except when the result of the
+ // remainder is zero. If it's known zero, our sign bit is also zero.
+ if (LHS.isNonNegative())
+ Known.makeNonNegative();
+ return Known;
+}
+
KnownBits &KnownBits::operator&=(const KnownBits &RHS) {
// Result bit is 0 if either operand bit is 0.
Zero |= RHS.Zero;
diff --git a/contrib/libs/llvm12/lib/Support/LineIterator.cpp b/contrib/libs/llvm12/lib/Support/LineIterator.cpp
index 7bdf1271ac..6b0a3f3886 100644
--- a/contrib/libs/llvm12/lib/Support/LineIterator.cpp
+++ b/contrib/libs/llvm12/lib/Support/LineIterator.cpp
@@ -33,11 +33,11 @@ static bool skipIfAtLineEnd(const char *&P) {
line_iterator::line_iterator(const MemoryBuffer &Buffer, bool SkipBlanks,
char CommentMarker)
- : line_iterator(Buffer.getMemBufferRef(), SkipBlanks, CommentMarker) {}
-
-line_iterator::line_iterator(const MemoryBufferRef &Buffer, bool SkipBlanks,
- char CommentMarker)
- : Buffer(Buffer.getBufferSize() ? Optional<MemoryBufferRef>(Buffer) : None),
+ : line_iterator(Buffer.getMemBufferRef(), SkipBlanks, CommentMarker) {}
+
+line_iterator::line_iterator(const MemoryBufferRef &Buffer, bool SkipBlanks,
+ char CommentMarker)
+ : Buffer(Buffer.getBufferSize() ? Optional<MemoryBufferRef>(Buffer) : None),
CommentMarker(CommentMarker), SkipBlanks(SkipBlanks), LineNumber(1),
CurrentLine(Buffer.getBufferSize() ? Buffer.getBufferStart() : nullptr,
0) {
@@ -82,7 +82,7 @@ void line_iterator::advance() {
if (*Pos == '\0') {
// We've hit the end of the buffer, reset ourselves to the end state.
- Buffer = None;
+ Buffer = None;
CurrentLine = StringRef();
return;
}
diff --git a/contrib/libs/llvm12/lib/Support/LowLevelType.cpp b/contrib/libs/llvm12/lib/Support/LowLevelType.cpp
index 63559d5ac3..cd406ae649 100644
--- a/contrib/libs/llvm12/lib/Support/LowLevelType.cpp
+++ b/contrib/libs/llvm12/lib/Support/LowLevelType.cpp
@@ -23,7 +23,7 @@ LLT::LLT(MVT VT) {
} else if (VT.isValid()) {
// Aggregates are no different from real scalars as far as GlobalISel is
// concerned.
- assert(VT.getSizeInBits().isNonZero() && "invalid zero-sized type");
+ assert(VT.getSizeInBits().isNonZero() && "invalid zero-sized type");
init(/*IsPointer=*/false, /*IsVector=*/false, /*NumElements=*/0,
VT.getSizeInBits(), /*AddressSpace=*/0);
} else {
diff --git a/contrib/libs/llvm12/lib/Support/MemoryBufferRef.cpp b/contrib/libs/llvm12/lib/Support/MemoryBufferRef.cpp
index a93853c0ac..e37aa357e8 100644
--- a/contrib/libs/llvm12/lib/Support/MemoryBufferRef.cpp
+++ b/contrib/libs/llvm12/lib/Support/MemoryBufferRef.cpp
@@ -1,19 +1,19 @@
-//===- MemoryBufferRef.cpp - Memory Buffer Reference ----------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the MemoryBufferRef interface.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Support/MemoryBufferRef.h"
-#include "llvm/Support/MemoryBuffer.h"
-
-using namespace llvm;
-
-MemoryBufferRef::MemoryBufferRef(const MemoryBuffer &Buffer)
- : Buffer(Buffer.getBuffer()), Identifier(Buffer.getBufferIdentifier()) {}
+//===- MemoryBufferRef.cpp - Memory Buffer Reference ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the MemoryBufferRef interface.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/MemoryBufferRef.h"
+#include "llvm/Support/MemoryBuffer.h"
+
+using namespace llvm;
+
+MemoryBufferRef::MemoryBufferRef(const MemoryBuffer &Buffer)
+ : Buffer(Buffer.getBuffer()), Identifier(Buffer.getBufferIdentifier()) {}
diff --git a/contrib/libs/llvm12/lib/Support/Path.cpp b/contrib/libs/llvm12/lib/Support/Path.cpp
index ef223ae5ac..4319bd23a8 100644
--- a/contrib/libs/llvm12/lib/Support/Path.cpp
+++ b/contrib/libs/llvm12/lib/Support/Path.cpp
@@ -355,8 +355,8 @@ StringRef root_path(StringRef path, Style style) {
// {C:/,//net/}, so get the first two components.
return path.substr(0, b->size() + pos->size());
}
- // just {C:,//net}, return the first component.
- return *b;
+ // just {C:,//net}, return the first component.
+ return *b;
}
// POSIX style root directory.
@@ -466,7 +466,7 @@ StringRef parent_path(StringRef path, Style style) {
size_t end_pos = parent_path_end(path, style);
if (end_pos == StringRef::npos)
return StringRef();
- return path.substr(0, end_pos);
+ return path.substr(0, end_pos);
}
void remove_filename(SmallVectorImpl<char> &path, Style style) {
@@ -579,10 +579,10 @@ StringRef stem(StringRef path, Style style) {
size_t pos = fname.find_last_of('.');
if (pos == StringRef::npos)
return fname;
- if ((fname.size() == 1 && fname == ".") ||
- (fname.size() == 2 && fname == ".."))
- return fname;
- return fname.substr(0, pos);
+ if ((fname.size() == 1 && fname == ".") ||
+ (fname.size() == 2 && fname == ".."))
+ return fname;
+ return fname.substr(0, pos);
}
StringRef extension(StringRef path, Style style) {
@@ -590,10 +590,10 @@ StringRef extension(StringRef path, Style style) {
size_t pos = fname.find_last_of('.');
if (pos == StringRef::npos)
return StringRef();
- if ((fname.size() == 1 && fname == ".") ||
- (fname.size() == 2 && fname == ".."))
- return StringRef();
- return fname.substr(pos);
+ if ((fname.size() == 1 && fname == ".") ||
+ (fname.size() == 2 && fname == ".."))
+ return StringRef();
+ return fname.substr(pos);
}
bool is_separator(char value, Style style) {
@@ -677,24 +677,24 @@ bool is_absolute(const Twine &path, Style style) {
return rootDir && rootName;
}
-bool is_absolute_gnu(const Twine &path, Style style) {
- SmallString<128> path_storage;
- StringRef p = path.toStringRef(path_storage);
-
- // Handle '/' which is absolute for both Windows and POSIX systems.
- // Handle '\\' on Windows.
- if (!p.empty() && is_separator(p.front(), style))
- return true;
-
- if (real_style(style) == Style::windows) {
- // Handle drive letter pattern (a character followed by ':') on Windows.
- if (p.size() >= 2 && (p[0] && p[1] == ':'))
- return true;
- }
-
- return false;
-}
-
+bool is_absolute_gnu(const Twine &path, Style style) {
+ SmallString<128> path_storage;
+ StringRef p = path.toStringRef(path_storage);
+
+ // Handle '/' which is absolute for both Windows and POSIX systems.
+ // Handle '\\' on Windows.
+ if (!p.empty() && is_separator(p.front(), style))
+ return true;
+
+ if (real_style(style) == Style::windows) {
+ // Handle drive letter pattern (a character followed by ':') on Windows.
+ if (p.size() >= 2 && (p[0] && p[1] == ':'))
+ return true;
+ }
+
+ return false;
+}
+
bool is_relative(const Twine &path, Style style) {
return !is_absolute(path, style);
}
@@ -1293,7 +1293,7 @@ Expected<TempFile> TempFile::create(const Twine &Model, unsigned Mode) {
#endif
return std::move(Ret);
}
-} // namespace fs
+} // namespace fs
-} // namespace sys
-} // namespace llvm
+} // namespace sys
+} // namespace llvm
diff --git a/contrib/libs/llvm12/lib/Support/PrettyStackTrace.cpp b/contrib/libs/llvm12/lib/Support/PrettyStackTrace.cpp
index 5d3d95b5e7..49c6d24917 100644
--- a/contrib/libs/llvm12/lib/Support/PrettyStackTrace.cpp
+++ b/contrib/libs/llvm12/lib/Support/PrettyStackTrace.cpp
@@ -25,7 +25,7 @@
#include <cassert>
#include <cstdarg>
#include <cstdio>
-#include <cstring>
+#include <cstring>
#include <tuple>
#ifdef HAVE_CRASHREPORTERCLIENT_H
@@ -254,16 +254,16 @@ void PrettyStackTraceFormat::print(raw_ostream &OS) const { OS << Str << "\n"; }
void PrettyStackTraceProgram::print(raw_ostream &OS) const {
OS << "Program arguments: ";
// Print the argument list.
- for (int I = 0; I < ArgC; ++I) {
- const bool HaveSpace = ::strchr(ArgV[I], ' ');
- if (I)
- OS << ' ';
- if (HaveSpace)
- OS << '"';
- OS.write_escaped(ArgV[I]);
- if (HaveSpace)
- OS << '"';
- }
+ for (int I = 0; I < ArgC; ++I) {
+ const bool HaveSpace = ::strchr(ArgV[I], ' ');
+ if (I)
+ OS << ' ';
+ if (HaveSpace)
+ OS << '"';
+ OS.write_escaped(ArgV[I]);
+ if (HaveSpace)
+ OS << '"';
+ }
OS << '\n';
}
diff --git a/contrib/libs/llvm12/lib/Support/Process.cpp b/contrib/libs/llvm12/lib/Support/Process.cpp
index e081444487..c80f01e6db 100644
--- a/contrib/libs/llvm12/lib/Support/Process.cpp
+++ b/contrib/libs/llvm12/lib/Support/Process.cpp
@@ -20,8 +20,8 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
-#include <stdlib.h> // for _Exit
-
+#include <stdlib.h> // for _Exit
+
using namespace llvm;
using namespace sys;
@@ -30,22 +30,22 @@ using namespace sys;
//=== independent code.
//===----------------------------------------------------------------------===//
-Optional<std::string>
-Process::FindInEnvPath(StringRef EnvName, StringRef FileName, char Separator) {
- return FindInEnvPath(EnvName, FileName, {}, Separator);
+Optional<std::string>
+Process::FindInEnvPath(StringRef EnvName, StringRef FileName, char Separator) {
+ return FindInEnvPath(EnvName, FileName, {}, Separator);
}
Optional<std::string> Process::FindInEnvPath(StringRef EnvName,
StringRef FileName,
- ArrayRef<std::string> IgnoreList,
- char Separator) {
+ ArrayRef<std::string> IgnoreList,
+ char Separator) {
assert(!path::is_absolute(FileName));
Optional<std::string> FoundPath;
Optional<std::string> OptPath = Process::GetEnv(EnvName);
if (!OptPath.hasValue())
return FoundPath;
- const char EnvPathSeparatorStr[] = {Separator, '\0'};
+ const char EnvPathSeparatorStr[] = {Separator, '\0'};
SmallVector<StringRef, 8> Dirs;
SplitString(OptPath.getValue(), Dirs, EnvPathSeparatorStr);
@@ -93,14 +93,14 @@ static bool coreFilesPrevented = !LLVM_ENABLE_CRASH_DUMPS;
bool Process::AreCoreFilesPrevented() { return coreFilesPrevented; }
LLVM_ATTRIBUTE_NORETURN
-void Process::Exit(int RetCode, bool NoCleanup) {
+void Process::Exit(int RetCode, bool NoCleanup) {
if (CrashRecoveryContext *CRC = CrashRecoveryContext::GetCurrent())
CRC->HandleExit(RetCode);
-
- if (NoCleanup)
- _Exit(RetCode);
- else
- ::exit(RetCode);
+
+ if (NoCleanup)
+ _Exit(RetCode);
+ else
+ ::exit(RetCode);
}
// Include the platform-specific parts of this class.
diff --git a/contrib/libs/llvm12/lib/Support/Program.cpp b/contrib/libs/llvm12/lib/Support/Program.cpp
index c7a59642b2..6505a40034 100644
--- a/contrib/libs/llvm12/lib/Support/Program.cpp
+++ b/contrib/libs/llvm12/lib/Support/Program.cpp
@@ -26,20 +26,20 @@ using namespace sys;
static bool Execute(ProcessInfo &PI, StringRef Program,
ArrayRef<StringRef> Args, Optional<ArrayRef<StringRef>> Env,
ArrayRef<Optional<StringRef>> Redirects,
- unsigned MemoryLimit, std::string *ErrMsg,
- BitVector *AffinityMask);
+ unsigned MemoryLimit, std::string *ErrMsg,
+ BitVector *AffinityMask);
int sys::ExecuteAndWait(StringRef Program, ArrayRef<StringRef> Args,
Optional<ArrayRef<StringRef>> Env,
ArrayRef<Optional<StringRef>> Redirects,
unsigned SecondsToWait, unsigned MemoryLimit,
std::string *ErrMsg, bool *ExecutionFailed,
- Optional<ProcessStatistics> *ProcStat,
- BitVector *AffinityMask) {
+ Optional<ProcessStatistics> *ProcStat,
+ BitVector *AffinityMask) {
assert(Redirects.empty() || Redirects.size() == 3);
ProcessInfo PI;
- if (Execute(PI, Program, Args, Env, Redirects, MemoryLimit, ErrMsg,
- AffinityMask)) {
+ if (Execute(PI, Program, Args, Env, Redirects, MemoryLimit, ErrMsg,
+ AffinityMask)) {
if (ExecutionFailed)
*ExecutionFailed = false;
ProcessInfo Result =
@@ -58,13 +58,13 @@ ProcessInfo sys::ExecuteNoWait(StringRef Program, ArrayRef<StringRef> Args,
Optional<ArrayRef<StringRef>> Env,
ArrayRef<Optional<StringRef>> Redirects,
unsigned MemoryLimit, std::string *ErrMsg,
- bool *ExecutionFailed, BitVector *AffinityMask) {
+ bool *ExecutionFailed, BitVector *AffinityMask) {
assert(Redirects.empty() || Redirects.size() == 3);
ProcessInfo PI;
if (ExecutionFailed)
*ExecutionFailed = false;
- if (!Execute(PI, Program, Args, Env, Redirects, MemoryLimit, ErrMsg,
- AffinityMask))
+ if (!Execute(PI, Program, Args, Env, Redirects, MemoryLimit, ErrMsg,
+ AffinityMask))
if (ExecutionFailed)
*ExecutionFailed = true;
diff --git a/contrib/libs/llvm12/lib/Support/SHA1.cpp b/contrib/libs/llvm12/lib/Support/SHA1.cpp
index 5dce44af9e..8d2bb97907 100644
--- a/contrib/libs/llvm12/lib/Support/SHA1.cpp
+++ b/contrib/libs/llvm12/lib/Support/SHA1.cpp
@@ -225,7 +225,7 @@ void SHA1::update(ArrayRef<uint8_t> Data) {
// Fast buffer filling for large inputs.
while (Data.size() >= BLOCK_LENGTH) {
assert(InternalState.BufferOffset == 0);
- static_assert(BLOCK_LENGTH % 4 == 0, "");
+ static_assert(BLOCK_LENGTH % 4 == 0, "");
constexpr size_t BLOCK_LENGTH_32 = BLOCK_LENGTH / 4;
for (size_t I = 0; I < BLOCK_LENGTH_32; ++I)
InternalState.Buffer.L[I] = support::endian::read32be(&Data[I * 4]);
diff --git a/contrib/libs/llvm12/lib/Support/Signals.cpp b/contrib/libs/llvm12/lib/Support/Signals.cpp
index 29be4df959..02e9f801d5 100644
--- a/contrib/libs/llvm12/lib/Support/Signals.cpp
+++ b/contrib/libs/llvm12/lib/Support/Signals.cpp
@@ -44,9 +44,9 @@ static cl::opt<bool, true>
cl::desc("Disable symbolizing crash backtraces."),
cl::location(DisableSymbolicationFlag), cl::Hidden);
-constexpr char DisableSymbolizationEnv[] = "LLVM_DISABLE_SYMBOLIZATION";
-constexpr char LLVMSymbolizerPathEnv[] = "LLVM_SYMBOLIZER_PATH";
-
+constexpr char DisableSymbolizationEnv[] = "LLVM_DISABLE_SYMBOLIZATION";
+constexpr char LLVMSymbolizerPathEnv[] = "LLVM_SYMBOLIZER_PATH";
+
// Callbacks to run in signal handler must be lock-free because a signal handler
// could be running as we add new callbacks. We don't add unbounded numbers of
// callbacks, an array is therefore sufficient.
@@ -108,7 +108,7 @@ static FormattedNumber format_ptr(void *PC) {
LLVM_ATTRIBUTE_USED
static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace,
int Depth, llvm::raw_ostream &OS) {
- if (DisableSymbolicationFlag || getenv(DisableSymbolizationEnv))
+ if (DisableSymbolicationFlag || getenv(DisableSymbolizationEnv))
return false;
// Don't recursively invoke the llvm-symbolizer binary.
@@ -120,9 +120,9 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace,
// Use llvm-symbolizer tool to symbolize the stack traces. First look for it
// alongside our binary, then in $PATH.
ErrorOr<std::string> LLVMSymbolizerPathOrErr = std::error_code();
- if (const char *Path = getenv(LLVMSymbolizerPathEnv)) {
- LLVMSymbolizerPathOrErr = sys::findProgramByName(Path);
- } else if (!Argv0.empty()) {
+ if (const char *Path = getenv(LLVMSymbolizerPathEnv)) {
+ LLVMSymbolizerPathOrErr = sys::findProgramByName(Path);
+ } else if (!Argv0.empty()) {
StringRef Parent = llvm::sys::path::parent_path(Argv0);
if (!Parent.empty())
LLVMSymbolizerPathOrErr = sys::findProgramByName("llvm-symbolizer", Parent);
diff --git a/contrib/libs/llvm12/lib/Support/Signposts.cpp b/contrib/libs/llvm12/lib/Support/Signposts.cpp
index 8de6e0cc04..9408373912 100644
--- a/contrib/libs/llvm12/lib/Support/Signposts.cpp
+++ b/contrib/libs/llvm12/lib/Support/Signposts.cpp
@@ -13,7 +13,7 @@
#include "llvm/Config/config.h"
#if LLVM_SUPPORT_XCODE_SIGNPOSTS
#include "llvm/ADT/DenseMap.h"
-#include "llvm/Support/Mutex.h"
+#include "llvm/Support/Mutex.h"
#error #include <os/signpost.h>
#endif // if LLVM_SUPPORT_XCODE_SIGNPOSTS
@@ -34,22 +34,22 @@ void LogDeleter(os_log_t *X) {
namespace llvm {
class SignpostEmitterImpl {
- using LogPtrTy = std::unique_ptr<os_log_t, std::function<void(os_log_t *)>>;
+ using LogPtrTy = std::unique_ptr<os_log_t, std::function<void(os_log_t *)>>;
using LogTy = LogPtrTy::element_type;
LogPtrTy SignpostLog;
- DenseMap<const void *, os_signpost_id_t> Signposts;
- sys::SmartMutex<true> Mutex;
+ DenseMap<const void *, os_signpost_id_t> Signposts;
+ sys::SmartMutex<true> Mutex;
LogTy &getLogger() const { return *SignpostLog; }
- os_signpost_id_t getSignpostForObject(const void *O) {
- sys::SmartScopedLock<true> Lock(Mutex);
- const auto &I = Signposts.find(O);
+ os_signpost_id_t getSignpostForObject(const void *O) {
+ sys::SmartScopedLock<true> Lock(Mutex);
+ const auto &I = Signposts.find(O);
if (I != Signposts.end())
return I->second;
const auto &Inserted = Signposts.insert(
- std::make_pair(O, os_signpost_id_make_with_pointer(getLogger(), O)));
+ std::make_pair(O, os_signpost_id_make_with_pointer(getLogger(), O)));
return Inserted.first->second;
}
@@ -58,19 +58,19 @@ public:
bool isEnabled() const { return os_signpost_enabled(*SignpostLog); }
- void startInterval(const void *O, llvm::StringRef Name) {
+ void startInterval(const void *O, llvm::StringRef Name) {
if (isEnabled()) {
- // Both strings used here are required to be constant literal strings.
- os_signpost_interval_begin(getLogger(), getSignpostForObject(O),
- "LLVM Timers", "Begin %s", Name.data());
+ // Both strings used here are required to be constant literal strings.
+ os_signpost_interval_begin(getLogger(), getSignpostForObject(O),
+ "LLVM Timers", "Begin %s", Name.data());
}
}
- void endInterval(const void *O, llvm::StringRef Name) {
+ void endInterval(const void *O, llvm::StringRef Name) {
if (isEnabled()) {
- // Both strings used here are required to be constant literal strings.
- os_signpost_interval_end(getLogger(), getSignpostForObject(O),
- "LLVM Timers", "End %s", Name.data());
+ // Both strings used here are required to be constant literal strings.
+ os_signpost_interval_end(getLogger(), getSignpostForObject(O),
+ "LLVM Timers", "End %s", Name.data());
}
}
};
@@ -86,7 +86,7 @@ public:
SignpostEmitter::SignpostEmitter() {
#if HAVE_ANY_SIGNPOST_IMPL
Impl = new SignpostEmitterImpl();
-#else // if HAVE_ANY_SIGNPOST_IMPL
+#else // if HAVE_ANY_SIGNPOST_IMPL
Impl = nullptr;
#endif // if !HAVE_ANY_SIGNPOST_IMPL
}
@@ -105,18 +105,18 @@ bool SignpostEmitter::isEnabled() const {
#endif // if !HAVE_ANY_SIGNPOST_IMPL
}
-void SignpostEmitter::startInterval(const void *O, StringRef Name) {
+void SignpostEmitter::startInterval(const void *O, StringRef Name) {
#if HAVE_ANY_SIGNPOST_IMPL
if (Impl == nullptr)
return;
- return Impl->startInterval(O, Name);
+ return Impl->startInterval(O, Name);
#endif // if !HAVE_ANY_SIGNPOST_IMPL
}
-void SignpostEmitter::endInterval(const void *O, StringRef Name) {
+void SignpostEmitter::endInterval(const void *O, StringRef Name) {
#if HAVE_ANY_SIGNPOST_IMPL
if (Impl == nullptr)
return;
- Impl->endInterval(O, Name);
+ Impl->endInterval(O, Name);
#endif // if !HAVE_ANY_SIGNPOST_IMPL
}
diff --git a/contrib/libs/llvm12/lib/Support/SmallVector.cpp b/contrib/libs/llvm12/lib/Support/SmallVector.cpp
index 0005f78409..f25422dc2f 100644
--- a/contrib/libs/llvm12/lib/Support/SmallVector.cpp
+++ b/contrib/libs/llvm12/lib/Support/SmallVector.cpp
@@ -12,9 +12,9 @@
#include "llvm/ADT/SmallVector.h"
#include <cstdint>
-#ifdef LLVM_ENABLE_EXCEPTIONS
-#include <stdexcept>
-#endif
+#ifdef LLVM_ENABLE_EXCEPTIONS
+#include <stdexcept>
+#endif
using namespace llvm;
// Check that no bytes are wasted and everything is well-aligned.
@@ -45,72 +45,72 @@ static_assert(sizeof(SmallVector<char, 0>) ==
sizeof(void *) * 2 + sizeof(void *),
"1 byte elements have word-sized type for size and capacity");
-/// Report that MinSize doesn't fit into this vector's size type. Throws
-/// std::length_error or calls report_fatal_error.
-LLVM_ATTRIBUTE_NORETURN
-static void report_size_overflow(size_t MinSize, size_t MaxSize);
-static void report_size_overflow(size_t MinSize, size_t MaxSize) {
- std::string Reason = "SmallVector unable to grow. Requested capacity (" +
- std::to_string(MinSize) +
- ") is larger than maximum value for size type (" +
- std::to_string(MaxSize) + ")";
-#ifdef LLVM_ENABLE_EXCEPTIONS
- throw std::length_error(Reason);
-#else
- report_fatal_error(Reason);
-#endif
-}
-
-/// Report that this vector is already at maximum capacity. Throws
-/// std::length_error or calls report_fatal_error.
-LLVM_ATTRIBUTE_NORETURN static void report_at_maximum_capacity(size_t MaxSize);
-static void report_at_maximum_capacity(size_t MaxSize) {
- std::string Reason =
- "SmallVector capacity unable to grow. Already at maximum size " +
- std::to_string(MaxSize);
-#ifdef LLVM_ENABLE_EXCEPTIONS
- throw std::length_error(Reason);
-#else
- report_fatal_error(Reason);
-#endif
-}
-
+/// Report that MinSize doesn't fit into this vector's size type. Throws
+/// std::length_error or calls report_fatal_error.
+LLVM_ATTRIBUTE_NORETURN
+static void report_size_overflow(size_t MinSize, size_t MaxSize);
+static void report_size_overflow(size_t MinSize, size_t MaxSize) {
+ std::string Reason = "SmallVector unable to grow. Requested capacity (" +
+ std::to_string(MinSize) +
+ ") is larger than maximum value for size type (" +
+ std::to_string(MaxSize) + ")";
+#ifdef LLVM_ENABLE_EXCEPTIONS
+ throw std::length_error(Reason);
+#else
+ report_fatal_error(Reason);
+#endif
+}
+
+/// Report that this vector is already at maximum capacity. Throws
+/// std::length_error or calls report_fatal_error.
+LLVM_ATTRIBUTE_NORETURN static void report_at_maximum_capacity(size_t MaxSize);
+static void report_at_maximum_capacity(size_t MaxSize) {
+ std::string Reason =
+ "SmallVector capacity unable to grow. Already at maximum size " +
+ std::to_string(MaxSize);
+#ifdef LLVM_ENABLE_EXCEPTIONS
+ throw std::length_error(Reason);
+#else
+ report_fatal_error(Reason);
+#endif
+}
+
// Note: Moving this function into the header may cause performance regression.
template <class Size_T>
-static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) {
- constexpr size_t MaxSize = std::numeric_limits<Size_T>::max();
-
+static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) {
+ constexpr size_t MaxSize = std::numeric_limits<Size_T>::max();
+
// Ensure we can fit the new capacity.
// This is only going to be applicable when the capacity is 32 bit.
- if (MinSize > MaxSize)
- report_size_overflow(MinSize, MaxSize);
+ if (MinSize > MaxSize)
+ report_size_overflow(MinSize, MaxSize);
// Ensure we can meet the guarantee of space for at least one more element.
// The above check alone will not catch the case where grow is called with a
- // default MinSize of 0, but the current capacity cannot be increased.
+ // default MinSize of 0, but the current capacity cannot be increased.
// This is only going to be applicable when the capacity is 32 bit.
- if (OldCapacity == MaxSize)
- report_at_maximum_capacity(MaxSize);
+ if (OldCapacity == MaxSize)
+ report_at_maximum_capacity(MaxSize);
// In theory 2*capacity can overflow if the capacity is 64 bit, but the
// original capacity would never be large enough for this to be a problem.
- size_t NewCapacity = 2 * OldCapacity + 1; // Always grow.
- return std::min(std::max(NewCapacity, MinSize), MaxSize);
-}
-
-// Note: Moving this function into the header may cause performance regression.
-template <class Size_T>
-void *SmallVectorBase<Size_T>::mallocForGrow(size_t MinSize, size_t TSize,
- size_t &NewCapacity) {
- NewCapacity = getNewCapacity<Size_T>(MinSize, TSize, this->capacity());
- return llvm::safe_malloc(NewCapacity * TSize);
-}
-
-// Note: Moving this function into the header may cause performance regression.
-template <class Size_T>
-void SmallVectorBase<Size_T>::grow_pod(void *FirstEl, size_t MinSize,
- size_t TSize) {
- size_t NewCapacity = getNewCapacity<Size_T>(MinSize, TSize, this->capacity());
+ size_t NewCapacity = 2 * OldCapacity + 1; // Always grow.
+ return std::min(std::max(NewCapacity, MinSize), MaxSize);
+}
+
+// Note: Moving this function into the header may cause performance regression.
+template <class Size_T>
+void *SmallVectorBase<Size_T>::mallocForGrow(size_t MinSize, size_t TSize,
+ size_t &NewCapacity) {
+ NewCapacity = getNewCapacity<Size_T>(MinSize, TSize, this->capacity());
+ return llvm::safe_malloc(NewCapacity * TSize);
+}
+
+// Note: Moving this function into the header may cause performance regression.
+template <class Size_T>
+void SmallVectorBase<Size_T>::grow_pod(void *FirstEl, size_t MinSize,
+ size_t TSize) {
+ size_t NewCapacity = getNewCapacity<Size_T>(MinSize, TSize, this->capacity());
void *NewElts;
if (BeginX == FirstEl) {
NewElts = safe_malloc(NewCapacity * TSize);
@@ -129,7 +129,7 @@ void SmallVectorBase<Size_T>::grow_pod(void *FirstEl, size_t MinSize,
template class llvm::SmallVectorBase<uint32_t>;
// Disable the uint64_t instantiation for 32-bit builds.
-// Both uint32_t and uint64_t instantiations are needed for 64-bit builds.
+// Both uint32_t and uint64_t instantiations are needed for 64-bit builds.
// This instantiation will never be used in 32-bit builds, and will cause
// warnings when sizeof(Size_T) > sizeof(size_t).
#if SIZE_MAX > UINT32_MAX
diff --git a/contrib/libs/llvm12/lib/Support/SourceMgr.cpp b/contrib/libs/llvm12/lib/Support/SourceMgr.cpp
index 89b7dc939d..63ee3d49a8 100644
--- a/contrib/libs/llvm12/lib/Support/SourceMgr.cpp
+++ b/contrib/libs/llvm12/lib/Support/SourceMgr.cpp
@@ -180,7 +180,7 @@ std::pair<unsigned, unsigned>
SourceMgr::getLineAndColumn(SMLoc Loc, unsigned BufferID) const {
if (!BufferID)
BufferID = FindBufferContainingLoc(Loc);
- assert(BufferID && "Invalid location!");
+ assert(BufferID && "Invalid location!");
auto &SB = getBufferInfo(BufferID);
const char *Ptr = Loc.getPointer();
@@ -193,30 +193,30 @@ SourceMgr::getLineAndColumn(SMLoc Loc, unsigned BufferID) const {
return std::make_pair(LineNo, Ptr - BufStart - NewlineOffs);
}
-// FIXME: Note that the formatting of source locations is spread between
-// multiple functions, some in SourceMgr and some in SMDiagnostic. A better
-// solution would be a general-purpose source location formatter
-// in one of those two classes, or possibly in SMLoc.
-
-/// Get a string with the source location formatted in the standard
-/// style, but without the line offset. If \p IncludePath is true, the path
-/// is included. If false, only the file name and extension are included.
-std::string SourceMgr::getFormattedLocationNoOffset(SMLoc Loc,
- bool IncludePath) const {
- auto BufferID = FindBufferContainingLoc(Loc);
- assert(BufferID && "Invalid location!");
- auto FileSpec = getBufferInfo(BufferID).Buffer->getBufferIdentifier();
-
- if (IncludePath) {
- return FileSpec.str() + ":" + std::to_string(FindLineNumber(Loc, BufferID));
- } else {
- auto I = FileSpec.find_last_of("/\\");
- I = (I == FileSpec.size()) ? 0 : (I + 1);
- return FileSpec.substr(I).str() + ":" +
- std::to_string(FindLineNumber(Loc, BufferID));
- }
-}
-
+// FIXME: Note that the formatting of source locations is spread between
+// multiple functions, some in SourceMgr and some in SMDiagnostic. A better
+// solution would be a general-purpose source location formatter
+// in one of those two classes, or possibly in SMLoc.
+
+/// Get a string with the source location formatted in the standard
+/// style, but without the line offset. If \p IncludePath is true, the path
+/// is included. If false, only the file name and extension are included.
+std::string SourceMgr::getFormattedLocationNoOffset(SMLoc Loc,
+ bool IncludePath) const {
+ auto BufferID = FindBufferContainingLoc(Loc);
+ assert(BufferID && "Invalid location!");
+ auto FileSpec = getBufferInfo(BufferID).Buffer->getBufferIdentifier();
+
+ if (IncludePath) {
+ return FileSpec.str() + ":" + std::to_string(FindLineNumber(Loc, BufferID));
+ } else {
+ auto I = FileSpec.find_last_of("/\\");
+ I = (I == FileSpec.size()) ? 0 : (I + 1);
+ return FileSpec.substr(I).str() + ":" +
+ std::to_string(FindLineNumber(Loc, BufferID));
+ }
+}
+
/// Given a line and column number in a mapped buffer, turn it into an SMLoc.
/// This will return a null SMLoc if the line/column location is invalid.
SMLoc SourceMgr::FindLocForLineAndColumn(unsigned BufferID, unsigned LineNo,
@@ -267,7 +267,7 @@ SMDiagnostic SourceMgr::GetMessage(SMLoc Loc, SourceMgr::DiagKind Kind,
SmallVector<std::pair<unsigned, unsigned>, 4> ColRanges;
std::pair<unsigned, unsigned> LineAndCol;
StringRef BufferID = "<unknown>";
- StringRef LineStr;
+ StringRef LineStr;
if (Loc.isValid()) {
unsigned CurBuf = FindBufferContainingLoc(Loc);
@@ -288,7 +288,7 @@ SMDiagnostic SourceMgr::GetMessage(SMLoc Loc, SourceMgr::DiagKind Kind,
const char *BufEnd = CurMB->getBufferEnd();
while (LineEnd != BufEnd && LineEnd[0] != '\n' && LineEnd[0] != '\r')
++LineEnd;
- LineStr = StringRef(LineStart, LineEnd - LineStart);
+ LineStr = StringRef(LineStart, LineEnd - LineStart);
// Convert any ranges to column ranges that only intersect the line of the
// location.
@@ -370,8 +370,8 @@ SMDiagnostic::SMDiagnostic(const SourceMgr &sm, SMLoc L, StringRef FN, int Line,
ArrayRef<std::pair<unsigned, unsigned>> Ranges,
ArrayRef<SMFixIt> Hints)
: SM(&sm), Loc(L), Filename(std::string(FN)), LineNo(Line), ColumnNo(Col),
- Kind(Kind), Message(Msg), LineContents(LineStr), Ranges(Ranges.vec()),
- FixIts(Hints.begin(), Hints.end()) {
+ Kind(Kind), Message(Msg), LineContents(LineStr), Ranges(Ranges.vec()),
+ FixIts(Hints.begin(), Hints.end()) {
llvm::sort(FixIts);
}
@@ -386,12 +386,12 @@ static void buildFixItLine(std::string &CaretLine, std::string &FixItLine,
size_t PrevHintEndCol = 0;
- for (const llvm::SMFixIt &Fixit : FixIts) {
+ for (const llvm::SMFixIt &Fixit : FixIts) {
// If the fixit contains a newline or tab, ignore it.
- if (Fixit.getText().find_first_of("\n\r\t") != StringRef::npos)
+ if (Fixit.getText().find_first_of("\n\r\t") != StringRef::npos)
continue;
- SMRange R = Fixit.getRange();
+ SMRange R = Fixit.getRange();
// If the line doesn't contain any part of the range, then ignore it.
if (R.Start.getPointer() > LineEnd || R.End.getPointer() < LineStart)
@@ -420,15 +420,15 @@ static void buildFixItLine(std::string &CaretLine, std::string &FixItLine,
// FIXME: This assertion is intended to catch unintended use of multibyte
// characters in fixits. If we decide to do this, we'll have to track
// separate byte widths for the source and fixit lines.
- assert((size_t)sys::locale::columnWidth(Fixit.getText()) ==
- Fixit.getText().size());
+ assert((size_t)sys::locale::columnWidth(Fixit.getText()) ==
+ Fixit.getText().size());
// This relies on one byte per column in our fixit hints.
- unsigned LastColumnModified = HintCol + Fixit.getText().size();
+ unsigned LastColumnModified = HintCol + Fixit.getText().size();
if (LastColumnModified > FixItLine.size())
FixItLine.resize(LastColumnModified, ' ');
- llvm::copy(Fixit.getText(), FixItLine.begin() + HintCol);
+ llvm::copy(Fixit.getText(), FixItLine.begin() + HintCol);
PrevHintEndCol = LastColumnModified;
@@ -522,7 +522,7 @@ void SMDiagnostic::print(const char *ProgName, raw_ostream &OS, bool ShowColors,
// map like Clang's TextDiagnostic. For now, we'll just handle tabs by
// expanding them later, and bail out rather than show incorrect ranges and
// misaligned fixits for any other odd characters.
- if (any_of(LineContents, isNonASCII)) {
+ if (any_of(LineContents, isNonASCII)) {
printSourceLine(OS, LineContents);
return;
}
@@ -532,7 +532,7 @@ void SMDiagnostic::print(const char *ProgName, raw_ostream &OS, bool ShowColors,
std::string CaretLine(NumColumns + 1, ' ');
// Expand any ranges.
- for (const std::pair<unsigned, unsigned> &R : Ranges)
+ for (const std::pair<unsigned, unsigned> &R : Ranges)
std::fill(&CaretLine[R.first],
&CaretLine[std::min((size_t)R.second, CaretLine.size())], '~');
diff --git a/contrib/libs/llvm12/lib/Support/TargetParser.cpp b/contrib/libs/llvm12/lib/Support/TargetParser.cpp
index 3ccdc55b30..9cf604de34 100644
--- a/contrib/libs/llvm12/lib/Support/TargetParser.cpp
+++ b/contrib/libs/llvm12/lib/Support/TargetParser.cpp
@@ -30,7 +30,7 @@ struct GPUInfo {
unsigned Features;
};
-constexpr GPUInfo R600GPUs[] = {
+constexpr GPUInfo R600GPUs[] = {
// Name Canonical Kind Features
// Name
{{"r600"}, {"r600"}, GK_R600, FEATURE_NONE },
@@ -63,7 +63,7 @@ constexpr GPUInfo R600GPUs[] = {
// This table should be sorted by the value of GPUKind
// Don't bother listing the implicitly true features
-constexpr GPUInfo AMDGCNGPUs[] = {
+constexpr GPUInfo AMDGCNGPUs[] = {
// Name Canonical Kind Features
// Name
{{"gfx600"}, {"gfx600"}, GK_GFX600, FEATURE_FAST_FMA_F32},
@@ -71,9 +71,9 @@ constexpr GPUInfo AMDGCNGPUs[] = {
{{"gfx601"}, {"gfx601"}, GK_GFX601, FEATURE_NONE},
{{"pitcairn"}, {"gfx601"}, GK_GFX601, FEATURE_NONE},
{{"verde"}, {"gfx601"}, GK_GFX601, FEATURE_NONE},
- {{"gfx602"}, {"gfx602"}, GK_GFX602, FEATURE_NONE},
- {{"hainan"}, {"gfx602"}, GK_GFX602, FEATURE_NONE},
- {{"oland"}, {"gfx602"}, GK_GFX602, FEATURE_NONE},
+ {{"gfx602"}, {"gfx602"}, GK_GFX602, FEATURE_NONE},
+ {{"hainan"}, {"gfx602"}, GK_GFX602, FEATURE_NONE},
+ {{"oland"}, {"gfx602"}, GK_GFX602, FEATURE_NONE},
{{"gfx700"}, {"gfx700"}, GK_GFX700, FEATURE_NONE},
{{"kaveri"}, {"gfx700"}, GK_GFX700, FEATURE_NONE},
{{"gfx701"}, {"gfx701"}, GK_GFX701, FEATURE_FAST_FMA_F32},
@@ -84,43 +84,43 @@ constexpr GPUInfo AMDGCNGPUs[] = {
{{"mullins"}, {"gfx703"}, GK_GFX703, FEATURE_NONE},
{{"gfx704"}, {"gfx704"}, GK_GFX704, FEATURE_NONE},
{{"bonaire"}, {"gfx704"}, GK_GFX704, FEATURE_NONE},
- {{"gfx705"}, {"gfx705"}, GK_GFX705, FEATURE_NONE},
- {{"gfx801"}, {"gfx801"}, GK_GFX801, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"carrizo"}, {"gfx801"}, GK_GFX801, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"gfx802"}, {"gfx802"}, GK_GFX802, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"iceland"}, {"gfx802"}, GK_GFX802, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"tonga"}, {"gfx802"}, GK_GFX802, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"gfx803"}, {"gfx803"}, GK_GFX803, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"fiji"}, {"gfx803"}, GK_GFX803, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"polaris10"}, {"gfx803"}, GK_GFX803, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"polaris11"}, {"gfx803"}, GK_GFX803, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"gfx805"}, {"gfx805"}, GK_GFX805, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"tongapro"}, {"gfx805"}, GK_GFX805, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"gfx810"}, {"gfx810"}, GK_GFX810, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"stoney"}, {"gfx810"}, GK_GFX810, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"gfx900"}, {"gfx900"}, GK_GFX900, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"gfx902"}, {"gfx902"}, GK_GFX902, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"gfx904"}, {"gfx904"}, GK_GFX904, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"gfx906"}, {"gfx906"}, GK_GFX906, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC},
- {{"gfx908"}, {"gfx908"}, GK_GFX908, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC},
- {{"gfx909"}, {"gfx909"}, GK_GFX909, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"gfx90c"}, {"gfx90c"}, GK_GFX90C, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
- {{"gfx1010"}, {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK},
- {{"gfx1011"}, {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK},
- {{"gfx1012"}, {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK},
+ {{"gfx705"}, {"gfx705"}, GK_GFX705, FEATURE_NONE},
+ {{"gfx801"}, {"gfx801"}, GK_GFX801, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"carrizo"}, {"gfx801"}, GK_GFX801, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"gfx802"}, {"gfx802"}, GK_GFX802, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"iceland"}, {"gfx802"}, GK_GFX802, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"tonga"}, {"gfx802"}, GK_GFX802, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"gfx803"}, {"gfx803"}, GK_GFX803, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"fiji"}, {"gfx803"}, GK_GFX803, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"polaris10"}, {"gfx803"}, GK_GFX803, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"polaris11"}, {"gfx803"}, GK_GFX803, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"gfx805"}, {"gfx805"}, GK_GFX805, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"tongapro"}, {"gfx805"}, GK_GFX805, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"gfx810"}, {"gfx810"}, GK_GFX810, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"stoney"}, {"gfx810"}, GK_GFX810, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"gfx900"}, {"gfx900"}, GK_GFX900, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"gfx902"}, {"gfx902"}, GK_GFX902, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"gfx904"}, {"gfx904"}, GK_GFX904, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"gfx906"}, {"gfx906"}, GK_GFX906, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC},
+ {{"gfx908"}, {"gfx908"}, GK_GFX908, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC},
+ {{"gfx909"}, {"gfx909"}, GK_GFX909, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"gfx90c"}, {"gfx90c"}, GK_GFX90C, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+ {{"gfx1010"}, {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK},
+ {{"gfx1011"}, {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK},
+ {{"gfx1012"}, {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK},
{{"gfx1030"}, {"gfx1030"}, GK_GFX1030, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
- {{"gfx1031"}, {"gfx1031"}, GK_GFX1031, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
- {{"gfx1032"}, {"gfx1032"}, GK_GFX1032, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
- {{"gfx1033"}, {"gfx1033"}, GK_GFX1033, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+ {{"gfx1031"}, {"gfx1031"}, GK_GFX1031, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+ {{"gfx1032"}, {"gfx1032"}, GK_GFX1032, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+ {{"gfx1033"}, {"gfx1033"}, GK_GFX1033, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
};
const GPUInfo *getArchEntry(AMDGPU::GPUKind AK, ArrayRef<GPUInfo> Table) {
GPUInfo Search = { {""}, {""}, AK, AMDGPU::FEATURE_NONE };
- auto I =
- llvm::lower_bound(Table, Search, [](const GPUInfo &A, const GPUInfo &B) {
- return A.Kind < B.Kind;
- });
+ auto I =
+ llvm::lower_bound(Table, Search, [](const GPUInfo &A, const GPUInfo &B) {
+ return A.Kind < B.Kind;
+ });
if (I == Table.end())
return nullptr;
@@ -195,17 +195,17 @@ AMDGPU::IsaVersion AMDGPU::getIsaVersion(StringRef GPU) {
switch (AK) {
case GK_GFX600: return {6, 0, 0};
case GK_GFX601: return {6, 0, 1};
- case GK_GFX602: return {6, 0, 2};
+ case GK_GFX602: return {6, 0, 2};
case GK_GFX700: return {7, 0, 0};
case GK_GFX701: return {7, 0, 1};
case GK_GFX702: return {7, 0, 2};
case GK_GFX703: return {7, 0, 3};
case GK_GFX704: return {7, 0, 4};
- case GK_GFX705: return {7, 0, 5};
+ case GK_GFX705: return {7, 0, 5};
case GK_GFX801: return {8, 0, 1};
case GK_GFX802: return {8, 0, 2};
case GK_GFX803: return {8, 0, 3};
- case GK_GFX805: return {8, 0, 5};
+ case GK_GFX805: return {8, 0, 5};
case GK_GFX810: return {8, 1, 0};
case GK_GFX900: return {9, 0, 0};
case GK_GFX902: return {9, 0, 2};
@@ -213,27 +213,27 @@ AMDGPU::IsaVersion AMDGPU::getIsaVersion(StringRef GPU) {
case GK_GFX906: return {9, 0, 6};
case GK_GFX908: return {9, 0, 8};
case GK_GFX909: return {9, 0, 9};
- case GK_GFX90C: return {9, 0, 12};
+ case GK_GFX90C: return {9, 0, 12};
case GK_GFX1010: return {10, 1, 0};
case GK_GFX1011: return {10, 1, 1};
case GK_GFX1012: return {10, 1, 2};
case GK_GFX1030: return {10, 3, 0};
- case GK_GFX1031: return {10, 3, 1};
- case GK_GFX1032: return {10, 3, 2};
- case GK_GFX1033: return {10, 3, 3};
+ case GK_GFX1031: return {10, 3, 1};
+ case GK_GFX1032: return {10, 3, 2};
+ case GK_GFX1033: return {10, 3, 3};
default: return {0, 0, 0};
}
}
-StringRef AMDGPU::getCanonicalArchName(const Triple &T, StringRef Arch) {
- assert(T.isAMDGPU());
- auto ProcKind = T.isAMDGCN() ? parseArchAMDGCN(Arch) : parseArchR600(Arch);
- if (ProcKind == GK_NONE)
- return StringRef();
-
- return T.isAMDGCN() ? getArchNameAMDGCN(ProcKind) : getArchNameR600(ProcKind);
-}
-
+StringRef AMDGPU::getCanonicalArchName(const Triple &T, StringRef Arch) {
+ assert(T.isAMDGPU());
+ auto ProcKind = T.isAMDGCN() ? parseArchAMDGCN(Arch) : parseArchR600(Arch);
+ if (ProcKind == GK_NONE)
+ return StringRef();
+
+ return T.isAMDGCN() ? getArchNameAMDGCN(ProcKind) : getArchNameR600(ProcKind);
+}
+
namespace llvm {
namespace RISCV {
@@ -257,12 +257,12 @@ bool checkCPUKind(CPUKind Kind, bool IsRV64) {
return RISCVCPUInfo[static_cast<unsigned>(Kind)].is64Bit() == IsRV64;
}
-bool checkTuneCPUKind(CPUKind Kind, bool IsRV64) {
- if (Kind == CK_INVALID)
- return false;
- return RISCVCPUInfo[static_cast<unsigned>(Kind)].is64Bit() == IsRV64;
-}
-
+bool checkTuneCPUKind(CPUKind Kind, bool IsRV64) {
+ if (Kind == CK_INVALID)
+ return false;
+ return RISCVCPUInfo[static_cast<unsigned>(Kind)].is64Bit() == IsRV64;
+}
+
CPUKind parseCPUKind(StringRef CPU) {
return llvm::StringSwitch<CPUKind>(CPU)
#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) .Case(NAME, CK_##ENUM)
@@ -270,22 +270,22 @@ CPUKind parseCPUKind(StringRef CPU) {
.Default(CK_INVALID);
}
-StringRef resolveTuneCPUAlias(StringRef TuneCPU, bool IsRV64) {
- return llvm::StringSwitch<StringRef>(TuneCPU)
-#define PROC_ALIAS(NAME, RV32, RV64) .Case(NAME, IsRV64 ? StringRef(RV64) : StringRef(RV32))
-#include "llvm/Support/RISCVTargetParser.def"
- .Default(TuneCPU);
-}
-
-CPUKind parseTuneCPUKind(StringRef TuneCPU, bool IsRV64) {
- TuneCPU = resolveTuneCPUAlias(TuneCPU, IsRV64);
-
- return llvm::StringSwitch<CPUKind>(TuneCPU)
-#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) .Case(NAME, CK_##ENUM)
-#include "llvm/Support/RISCVTargetParser.def"
- .Default(CK_INVALID);
-}
-
+StringRef resolveTuneCPUAlias(StringRef TuneCPU, bool IsRV64) {
+ return llvm::StringSwitch<StringRef>(TuneCPU)
+#define PROC_ALIAS(NAME, RV32, RV64) .Case(NAME, IsRV64 ? StringRef(RV64) : StringRef(RV32))
+#include "llvm/Support/RISCVTargetParser.def"
+ .Default(TuneCPU);
+}
+
+CPUKind parseTuneCPUKind(StringRef TuneCPU, bool IsRV64) {
+ TuneCPU = resolveTuneCPUAlias(TuneCPU, IsRV64);
+
+ return llvm::StringSwitch<CPUKind>(TuneCPU)
+#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) .Case(NAME, CK_##ENUM)
+#include "llvm/Support/RISCVTargetParser.def"
+ .Default(CK_INVALID);
+}
+
StringRef getMArchFromMcpu(StringRef CPU) {
CPUKind Kind = parseCPUKind(CPU);
return RISCVCPUInfo[static_cast<unsigned>(Kind)].DefaultMarch;
@@ -298,15 +298,15 @@ void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64) {
}
}
-void fillValidTuneCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64) {
- for (const auto &C : RISCVCPUInfo) {
- if (C.Kind != CK_INVALID && IsRV64 == C.is64Bit())
- Values.emplace_back(C.Name);
- }
-#define PROC_ALIAS(NAME, RV32, RV64) Values.emplace_back(StringRef(NAME));
-#include "llvm/Support/RISCVTargetParser.def"
-}
-
+void fillValidTuneCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64) {
+ for (const auto &C : RISCVCPUInfo) {
+ if (C.Kind != CK_INVALID && IsRV64 == C.is64Bit())
+ Values.emplace_back(C.Name);
+ }
+#define PROC_ALIAS(NAME, RV32, RV64) Values.emplace_back(StringRef(NAME));
+#include "llvm/Support/RISCVTargetParser.def"
+}
+
// Get all features except standard extension feature
bool getCPUFeaturesExceptStdExt(CPUKind Kind,
std::vector<StringRef> &Features) {
diff --git a/contrib/libs/llvm12/lib/Support/Timer.cpp b/contrib/libs/llvm12/lib/Support/Timer.cpp
index f5a512f9a2..b2cfb4a4aa 100644
--- a/contrib/libs/llvm12/lib/Support/Timer.cpp
+++ b/contrib/libs/llvm12/lib/Support/Timer.cpp
@@ -53,11 +53,11 @@ namespace {
InfoOutputFilename("info-output-file", cl::value_desc("filename"),
cl::desc("File to append -stats and -timer output to"),
cl::Hidden, cl::location(getLibSupportInfoOutputFilename()));
-
- static cl::opt<bool>
- SortTimers("sort-timers", cl::desc("In the report, sort the timers in each group "
- "in wall clock time order"),
- cl::init(true), cl::Hidden);
+
+ static cl::opt<bool>
+ SortTimers("sort-timers", cl::desc("In the report, sort the timers in each group "
+ "in wall clock time order"),
+ cl::init(true), cl::Hidden);
}
std::unique_ptr<raw_fd_ostream> llvm::CreateInfoOutputFile() {
@@ -143,7 +143,7 @@ TimeRecord TimeRecord::getCurrentTime(bool Start) {
void Timer::startTimer() {
assert(!Running && "Cannot start a running timer");
Running = Triggered = true;
- Signposts->startInterval(this, getName());
+ Signposts->startInterval(this, getName());
StartTime = TimeRecord::getCurrentTime(true);
}
@@ -152,7 +152,7 @@ void Timer::stopTimer() {
Running = false;
Time += TimeRecord::getCurrentTime(false);
Time -= StartTime;
- Signposts->endInterval(this, getName());
+ Signposts->endInterval(this, getName());
}
void Timer::clear() {
@@ -306,9 +306,9 @@ void TimerGroup::addTimer(Timer &T) {
}
void TimerGroup::PrintQueuedTimers(raw_ostream &OS) {
- // Perhaps sort the timers in descending order by amount of time taken.
- if (SortTimers)
- llvm::sort(TimersToPrint);
+ // Perhaps sort the timers in descending order by amount of time taken.
+ if (SortTimers)
+ llvm::sort(TimersToPrint);
TimeRecord Total;
for (const PrintRecord &Record : TimersToPrint)
diff --git a/contrib/libs/llvm12/lib/Support/TrigramIndex.cpp b/contrib/libs/llvm12/lib/Support/TrigramIndex.cpp
index 4370adc9c3..accc001dd7 100644
--- a/contrib/libs/llvm12/lib/Support/TrigramIndex.cpp
+++ b/contrib/libs/llvm12/lib/Support/TrigramIndex.cpp
@@ -25,7 +25,7 @@ static bool isAdvancedMetachar(unsigned Char) {
return strchr(RegexAdvancedMetachars, Char) != nullptr;
}
-void TrigramIndex::insert(const std::string &Regex) {
+void TrigramIndex::insert(const std::string &Regex) {
if (Defeated) return;
std::set<unsigned> Was;
unsigned Cnt = 0;
diff --git a/contrib/libs/llvm12/lib/Support/Triple.cpp b/contrib/libs/llvm12/lib/Support/Triple.cpp
index 4f483c9652..e764c79aa6 100644
--- a/contrib/libs/llvm12/lib/Support/Triple.cpp
+++ b/contrib/libs/llvm12/lib/Support/Triple.cpp
@@ -36,7 +36,7 @@ StringRef Triple::getArchTypeName(ArchType Kind) {
case avr: return "avr";
case bpfeb: return "bpfeb";
case bpfel: return "bpfel";
- case csky: return "csky";
+ case csky: return "csky";
case hexagon: return "hexagon";
case hsail64: return "hsail64";
case hsail: return "hsail";
@@ -54,7 +54,7 @@ StringRef Triple::getArchTypeName(ArchType Kind) {
case ppc64: return "powerpc64";
case ppc64le: return "powerpc64le";
case ppc: return "powerpc";
- case ppcle: return "powerpcle";
+ case ppcle: return "powerpcle";
case r600: return "r600";
case renderscript32: return "renderscript32";
case renderscript64: return "renderscript64";
@@ -102,8 +102,8 @@ StringRef Triple::getArchTypePrefix(ArchType Kind) {
case ppc64:
case ppc64le:
- case ppc:
- case ppcle: return "ppc";
+ case ppc:
+ case ppcle: return "ppc";
case mips:
case mipsel:
@@ -154,7 +154,7 @@ StringRef Triple::getArchTypePrefix(ArchType Kind) {
case riscv64: return "riscv";
case ve: return "ve";
- case csky: return "csky";
+ case csky: return "csky";
}
}
@@ -219,7 +219,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case WASI: return "wasi";
case WatchOS: return "watchos";
case Win32: return "windows";
- case ZOS: return "zos";
+ case ZOS: return "zos";
}
llvm_unreachable("Invalid OSType");
@@ -240,7 +240,7 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) {
case GNUEABI: return "gnueabi";
case GNUEABIHF: return "gnueabihf";
case GNUX32: return "gnux32";
- case GNUILP32: return "gnu_ilp32";
+ case GNUILP32: return "gnu_ilp32";
case Itanium: return "itanium";
case MSVC: return "msvc";
case MacABI: return "macabi";
@@ -289,8 +289,8 @@ Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) {
.Case("ppc64", ppc64)
.Case("ppc32", ppc)
.Case("ppc", ppc)
- .Case("ppc32le", ppcle)
- .Case("ppcle", ppcle)
+ .Case("ppc32le", ppcle)
+ .Case("ppcle", ppcle)
.Case("ppc64le", ppc64le)
.Case("r600", r600)
.Case("amdgcn", amdgcn)
@@ -326,7 +326,7 @@ Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) {
.Case("renderscript32", renderscript32)
.Case("renderscript64", renderscript64)
.Case("ve", ve)
- .Case("csky", csky)
+ .Case("csky", csky)
.Default(UnknownArch);
}
@@ -402,7 +402,7 @@ static Triple::ArchType parseArch(StringRef ArchName) {
.Cases("i786", "i886", "i986", Triple::x86)
.Cases("amd64", "x86_64", "x86_64h", Triple::x86_64)
.Cases("powerpc", "powerpcspe", "ppc", "ppc32", Triple::ppc)
- .Cases("powerpcle", "ppcle", "ppc32le", Triple::ppcle)
+ .Cases("powerpcle", "ppcle", "ppc32le", Triple::ppcle)
.Cases("powerpc64", "ppu", "ppc64", Triple::ppc64)
.Cases("powerpc64le", "ppc64le", Triple::ppc64le)
.Case("xscale", Triple::arm)
@@ -413,7 +413,7 @@ static Triple::ArchType parseArch(StringRef ArchName) {
.Case("arc", Triple::arc)
.Case("arm64", Triple::aarch64)
.Case("arm64_32", Triple::aarch64_32)
- .Case("arm64e", Triple::aarch64)
+ .Case("arm64e", Triple::aarch64)
.Case("arm", Triple::arm)
.Case("armeb", Triple::armeb)
.Case("thumb", Triple::thumb)
@@ -458,7 +458,7 @@ static Triple::ArchType parseArch(StringRef ArchName) {
.Case("ve", Triple::ve)
.Case("wasm32", Triple::wasm32)
.Case("wasm64", Triple::wasm64)
- .Case("csky", Triple::csky)
+ .Case("csky", Triple::csky)
.Default(Triple::UnknownArch);
// Some architectures require special parsing logic just to compute the
@@ -511,7 +511,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("solaris", Triple::Solaris)
.StartsWith("win32", Triple::Win32)
.StartsWith("windows", Triple::Win32)
- .StartsWith("zos", Triple::ZOS)
+ .StartsWith("zos", Triple::ZOS)
.StartsWith("haiku", Triple::Haiku)
.StartsWith("minix", Triple::Minix)
.StartsWith("rtems", Triple::RTEMS)
@@ -536,27 +536,27 @@ static Triple::OSType parseOS(StringRef OSName) {
static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
return StringSwitch<Triple::EnvironmentType>(EnvironmentName)
- .StartsWith("eabihf", Triple::EABIHF)
- .StartsWith("eabi", Triple::EABI)
- .StartsWith("gnuabin32", Triple::GNUABIN32)
- .StartsWith("gnuabi64", Triple::GNUABI64)
- .StartsWith("gnueabihf", Triple::GNUEABIHF)
- .StartsWith("gnueabi", Triple::GNUEABI)
- .StartsWith("gnux32", Triple::GNUX32)
- .StartsWith("gnu_ilp32", Triple::GNUILP32)
- .StartsWith("code16", Triple::CODE16)
- .StartsWith("gnu", Triple::GNU)
- .StartsWith("android", Triple::Android)
- .StartsWith("musleabihf", Triple::MuslEABIHF)
- .StartsWith("musleabi", Triple::MuslEABI)
- .StartsWith("musl", Triple::Musl)
- .StartsWith("msvc", Triple::MSVC)
- .StartsWith("itanium", Triple::Itanium)
- .StartsWith("cygnus", Triple::Cygnus)
- .StartsWith("coreclr", Triple::CoreCLR)
- .StartsWith("simulator", Triple::Simulator)
- .StartsWith("macabi", Triple::MacABI)
- .Default(Triple::UnknownEnvironment);
+ .StartsWith("eabihf", Triple::EABIHF)
+ .StartsWith("eabi", Triple::EABI)
+ .StartsWith("gnuabin32", Triple::GNUABIN32)
+ .StartsWith("gnuabi64", Triple::GNUABI64)
+ .StartsWith("gnueabihf", Triple::GNUEABIHF)
+ .StartsWith("gnueabi", Triple::GNUEABI)
+ .StartsWith("gnux32", Triple::GNUX32)
+ .StartsWith("gnu_ilp32", Triple::GNUILP32)
+ .StartsWith("code16", Triple::CODE16)
+ .StartsWith("gnu", Triple::GNU)
+ .StartsWith("android", Triple::Android)
+ .StartsWith("musleabihf", Triple::MuslEABIHF)
+ .StartsWith("musleabi", Triple::MuslEABI)
+ .StartsWith("musl", Triple::Musl)
+ .StartsWith("msvc", Triple::MSVC)
+ .StartsWith("itanium", Triple::Itanium)
+ .StartsWith("cygnus", Triple::Cygnus)
+ .StartsWith("coreclr", Triple::CoreCLR)
+ .StartsWith("simulator", Triple::Simulator)
+ .StartsWith("macabi", Triple::MacABI)
+ .Default(Triple::UnknownEnvironment);
}
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
@@ -566,7 +566,7 @@ static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
.EndsWith("xcoff", Triple::XCOFF)
.EndsWith("coff", Triple::COFF)
.EndsWith("elf", Triple::ELF)
- .EndsWith("goff", Triple::GOFF)
+ .EndsWith("goff", Triple::GOFF)
.EndsWith("macho", Triple::MachO)
.EndsWith("wasm", Triple::Wasm)
.Default(Triple::UnknownObjectFormat);
@@ -580,9 +580,9 @@ static Triple::SubArchType parseSubArch(StringRef SubArchName) {
if (SubArchName == "powerpcspe")
return Triple::PPCSubArch_spe;
- if (SubArchName == "arm64e")
- return Triple::AArch64SubArch_arm64e;
-
+ if (SubArchName == "arm64e")
+ return Triple::AArch64SubArch_arm64e;
+
StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
// For now, this is the small part. Early return.
@@ -643,8 +643,8 @@ static Triple::SubArchType parseSubArch(StringRef SubArchName) {
return Triple::ARMSubArch_v8_5a;
case ARM::ArchKind::ARMV8_6A:
return Triple::ARMSubArch_v8_6a;
- case ARM::ArchKind::ARMV8_7A:
- return Triple::ARMSubArch_v8_7a;
+ case ARM::ArchKind::ARMV8_7A:
+ return Triple::ARMSubArch_v8_7a;
case ARM::ArchKind::ARMV8R:
return Triple::ARMSubArch_v8r;
case ARM::ArchKind::ARMV8MBaseline:
@@ -663,7 +663,7 @@ static StringRef getObjectFormatTypeName(Triple::ObjectFormatType Kind) {
case Triple::UnknownObjectFormat: return "";
case Triple::COFF: return "coff";
case Triple::ELF: return "elf";
- case Triple::GOFF: return "goff";
+ case Triple::GOFF: return "goff";
case Triple::MachO: return "macho";
case Triple::Wasm: return "wasm";
case Triple::XCOFF: return "xcoff";
@@ -695,7 +695,7 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
case Triple::avr:
case Triple::bpfeb:
case Triple::bpfel:
- case Triple::csky:
+ case Triple::csky:
case Triple::hexagon:
case Triple::hsail64:
case Triple::hsail:
@@ -711,7 +711,7 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
case Triple::nvptx64:
case Triple::nvptx:
case Triple::ppc64le:
- case Triple::ppcle:
+ case Triple::ppcle:
case Triple::r600:
case Triple::renderscript32:
case Triple::renderscript64:
@@ -736,11 +736,11 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
return Triple::XCOFF;
return Triple::ELF;
- case Triple::systemz:
- if (T.isOSzOS())
- return Triple::GOFF;
- return Triple::ELF;
-
+ case Triple::systemz:
+ if (T.isOSzOS())
+ return Triple::GOFF;
+ return Triple::ELF;
+
case Triple::wasm32:
case Triple::wasm64:
return Triple::Wasm;
@@ -1038,7 +1038,7 @@ StringRef Triple::getOSAndEnvironmentName() const {
}
static unsigned EatNumber(StringRef &Str) {
- assert(!Str.empty() && isDigit(Str[0]) && "Not a number");
+ assert(!Str.empty() && isDigit(Str[0]) && "Not a number");
unsigned Result = 0;
do {
@@ -1047,7 +1047,7 @@ static unsigned EatNumber(StringRef &Str) {
// Eat the digit.
Str = Str.substr(1);
- } while (!Str.empty() && isDigit(Str[0]));
+ } while (!Str.empty() && isDigit(Str[0]));
return Result;
}
@@ -1270,7 +1270,7 @@ static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) {
case llvm::Triple::arc:
case llvm::Triple::arm:
case llvm::Triple::armeb:
- case llvm::Triple::csky:
+ case llvm::Triple::csky:
case llvm::Triple::hexagon:
case llvm::Triple::hsail:
case llvm::Triple::kalimba:
@@ -1280,7 +1280,7 @@ static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) {
case llvm::Triple::mipsel:
case llvm::Triple::nvptx:
case llvm::Triple::ppc:
- case llvm::Triple::ppcle:
+ case llvm::Triple::ppcle:
case llvm::Triple::r600:
case llvm::Triple::renderscript32:
case llvm::Triple::riscv32:
@@ -1354,7 +1354,7 @@ Triple Triple::get32BitArchVariant() const {
case Triple::arc:
case Triple::arm:
case Triple::armeb:
- case Triple::csky:
+ case Triple::csky:
case Triple::hexagon:
case Triple::hsail:
case Triple::kalimba:
@@ -1364,7 +1364,7 @@ Triple Triple::get32BitArchVariant() const {
case Triple::mipsel:
case Triple::nvptx:
case Triple::ppc:
- case Triple::ppcle:
+ case Triple::ppcle:
case Triple::r600:
case Triple::renderscript32:
case Triple::riscv32:
@@ -1391,7 +1391,7 @@ Triple Triple::get32BitArchVariant() const {
case Triple::mips64el: T.setArch(Triple::mipsel); break;
case Triple::nvptx64: T.setArch(Triple::nvptx); break;
case Triple::ppc64: T.setArch(Triple::ppc); break;
- case Triple::ppc64le: T.setArch(Triple::ppcle); break;
+ case Triple::ppc64le: T.setArch(Triple::ppcle); break;
case Triple::renderscript64: T.setArch(Triple::renderscript32); break;
case Triple::riscv64: T.setArch(Triple::riscv32); break;
case Triple::sparcv9: T.setArch(Triple::sparc); break;
@@ -1408,7 +1408,7 @@ Triple Triple::get64BitArchVariant() const {
case Triple::UnknownArch:
case Triple::arc:
case Triple::avr:
- case Triple::csky:
+ case Triple::csky:
case Triple::hexagon:
case Triple::kalimba:
case Triple::lanai:
@@ -1456,7 +1456,7 @@ Triple Triple::get64BitArchVariant() const {
case Triple::mipsel: T.setArch(Triple::mips64el); break;
case Triple::nvptx: T.setArch(Triple::nvptx64); break;
case Triple::ppc: T.setArch(Triple::ppc64); break;
- case Triple::ppcle: T.setArch(Triple::ppc64le); break;
+ case Triple::ppcle: T.setArch(Triple::ppc64le); break;
case Triple::renderscript32: T.setArch(Triple::renderscript64); break;
case Triple::riscv32: T.setArch(Triple::riscv64); break;
case Triple::sparc: T.setArch(Triple::sparcv9); break;
@@ -1503,7 +1503,7 @@ Triple Triple::getBigEndianArchVariant() const {
case Triple::x86_64:
case Triple::xcore:
case Triple::ve:
- case Triple::csky:
+ case Triple::csky:
// ARM is intentionally unsupported here, changing the architecture would
// drop any arch suffixes.
@@ -1516,7 +1516,7 @@ Triple Triple::getBigEndianArchVariant() const {
case Triple::bpfel: T.setArch(Triple::bpfeb); break;
case Triple::mips64el:T.setArch(Triple::mips64); break;
case Triple::mipsel: T.setArch(Triple::mips); break;
- case Triple::ppcle: T.setArch(Triple::ppc); break;
+ case Triple::ppcle: T.setArch(Triple::ppc); break;
case Triple::ppc64le: T.setArch(Triple::ppc64); break;
case Triple::sparcel: T.setArch(Triple::sparc); break;
case Triple::tcele: T.setArch(Triple::tce); break;
@@ -1548,7 +1548,7 @@ Triple Triple::getLittleEndianArchVariant() const {
case Triple::bpfeb: T.setArch(Triple::bpfel); break;
case Triple::mips64: T.setArch(Triple::mips64el); break;
case Triple::mips: T.setArch(Triple::mipsel); break;
- case Triple::ppc: T.setArch(Triple::ppcle); break;
+ case Triple::ppc: T.setArch(Triple::ppcle); break;
case Triple::ppc64: T.setArch(Triple::ppc64le); break;
case Triple::sparc: T.setArch(Triple::sparcel); break;
case Triple::tce: T.setArch(Triple::tcele); break;
@@ -1568,7 +1568,7 @@ bool Triple::isLittleEndian() const {
case Triple::arm:
case Triple::avr:
case Triple::bpfel:
- case Triple::csky:
+ case Triple::csky:
case Triple::hexagon:
case Triple::hsail64:
case Triple::hsail:
@@ -1580,7 +1580,7 @@ bool Triple::isLittleEndian() const {
case Triple::msp430:
case Triple::nvptx64:
case Triple::nvptx:
- case Triple::ppcle:
+ case Triple::ppcle:
case Triple::ppc64le:
case Triple::r600:
case Triple::renderscript32:
@@ -1667,9 +1667,9 @@ VersionTuple Triple::getMinimumSupportedOSVersion() const {
// ARM64 simulators are supported for iOS 14+.
if (isMacCatalystEnvironment() || isSimulatorEnvironment())
return VersionTuple(14, 0, 0);
- // ARM64e slice is supported starting from iOS 14.
- if (isArm64e())
- return VersionTuple(14, 0, 0);
+ // ARM64e slice is supported starting from iOS 14.
+ if (isArm64e())
+ return VersionTuple(14, 0, 0);
break;
case Triple::TvOS:
// ARM64 simulators are supported for tvOS 14+.
diff --git a/contrib/libs/llvm12/lib/Support/Unicode.cpp b/contrib/libs/llvm12/lib/Support/Unicode.cpp
index bb6e75555b..cdfc3042c5 100644
--- a/contrib/libs/llvm12/lib/Support/Unicode.cpp
+++ b/contrib/libs/llvm12/lib/Support/Unicode.cpp
@@ -339,22 +339,22 @@ static inline int charWidth(int UCS)
return 1;
}
-static bool isprintableascii(char c) { return c > 31 && c < 127; }
-
+static bool isprintableascii(char c) { return c > 31 && c < 127; }
+
int columnWidthUTF8(StringRef Text) {
unsigned ColumnWidth = 0;
unsigned Length;
for (size_t i = 0, e = Text.size(); i < e; i += Length) {
Length = getNumBytesForUTF8(Text[i]);
-
- // fast path for ASCII characters
- if (Length == 1) {
- if (!isprintableascii(Text[i]))
- return ErrorNonPrintableCharacter;
- ColumnWidth += 1;
- continue;
- }
-
+
+ // fast path for ASCII characters
+ if (Length == 1) {
+ if (!isprintableascii(Text[i]))
+ return ErrorNonPrintableCharacter;
+ ColumnWidth += 1;
+ continue;
+ }
+
if (Length <= 0 || i + Length > Text.size())
return ErrorInvalidUTF8;
UTF32 buf[1];
diff --git a/contrib/libs/llvm12/lib/Support/Unix/Path.inc b/contrib/libs/llvm12/lib/Support/Unix/Path.inc
index 996b8aebf6..1c2fc15fc5 100644
--- a/contrib/libs/llvm12/lib/Support/Unix/Path.inc
+++ b/contrib/libs/llvm12/lib/Support/Unix/Path.inc
@@ -33,7 +33,7 @@
#include <dirent.h>
#include <pwd.h>
-#include <sys/file.h>
+#include <sys/file.h>
#ifdef __APPLE__
#include <mach-o/dyld.h>
@@ -147,9 +147,9 @@ test_dir(char ret[PATH_MAX], const char *dir, const char *bin)
static char *
getprogpath(char ret[PATH_MAX], const char *bin)
{
- if (bin == nullptr)
- return nullptr;
-
+ if (bin == nullptr)
+ return nullptr;
+
/* First approach: absolute path. */
if (bin[0] == '/') {
if (test_dir(ret, "/", bin) == 0)
@@ -793,16 +793,16 @@ std::error_code setLastAccessAndModificationTime(int FD, TimePoint<> AccessTime,
if (::futimes(FD, Times))
return std::error_code(errno, std::generic_category());
return std::error_code();
-#elif defined(__MVS__)
- attrib_t Attr;
- memset(&Attr, 0, sizeof(Attr));
- Attr.att_atimechg = 1;
- Attr.att_atime = sys::toTimeT(AccessTime);
- Attr.att_mtimechg = 1;
- Attr.att_mtime = sys::toTimeT(ModificationTime);
- if (::__fchattr(FD, &Attr, sizeof(Attr)) != 0)
- return std::error_code(errno, std::generic_category());
- return std::error_code();
+#elif defined(__MVS__)
+ attrib_t Attr;
+ memset(&Attr, 0, sizeof(Attr));
+ Attr.att_atimechg = 1;
+ Attr.att_atime = sys::toTimeT(AccessTime);
+ Attr.att_mtimechg = 1;
+ Attr.att_mtime = sys::toTimeT(ModificationTime);
+ if (::__fchattr(FD, &Attr, sizeof(Attr)) != 0)
+ return std::error_code(errno, std::generic_category());
+ return std::error_code();
#else
#warning Missing futimes() and futimens()
return make_error_code(errc::function_not_supported);
@@ -1067,13 +1067,13 @@ file_t getStdoutHandle() { return 1; }
file_t getStderrHandle() { return 2; }
Expected<size_t> readNativeFile(file_t FD, MutableArrayRef<char> Buf) {
-#if defined(__APPLE__)
- size_t Size = std::min<size_t>(Buf.size(), INT32_MAX);
-#else
- size_t Size = Buf.size();
-#endif
+#if defined(__APPLE__)
+ size_t Size = std::min<size_t>(Buf.size(), INT32_MAX);
+#else
+ size_t Size = Buf.size();
+#endif
ssize_t NumRead =
- sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size);
+ sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size);
if (ssize_t(NumRead) == -1)
return errorCodeToError(std::error_code(errno, std::generic_category()));
return NumRead;
@@ -1081,69 +1081,69 @@ Expected<size_t> readNativeFile(file_t FD, MutableArrayRef<char> Buf) {
Expected<size_t> readNativeFileSlice(file_t FD, MutableArrayRef<char> Buf,
uint64_t Offset) {
-#if defined(__APPLE__)
- size_t Size = std::min<size_t>(Buf.size(), INT32_MAX);
-#else
- size_t Size = Buf.size();
-#endif
+#if defined(__APPLE__)
+ size_t Size = std::min<size_t>(Buf.size(), INT32_MAX);
+#else
+ size_t Size = Buf.size();
+#endif
#ifdef HAVE_PREAD
ssize_t NumRead =
- sys::RetryAfterSignal(-1, ::pread, FD, Buf.data(), Size, Offset);
+ sys::RetryAfterSignal(-1, ::pread, FD, Buf.data(), Size, Offset);
#else
if (lseek(FD, Offset, SEEK_SET) == -1)
return errorCodeToError(std::error_code(errno, std::generic_category()));
ssize_t NumRead =
- sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size);
+ sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size);
#endif
if (NumRead == -1)
return errorCodeToError(std::error_code(errno, std::generic_category()));
return NumRead;
}
-std::error_code tryLockFile(int FD, std::chrono::milliseconds Timeout) {
- auto Start = std::chrono::steady_clock::now();
- auto End = Start + Timeout;
- do {
- struct flock Lock;
- memset(&Lock, 0, sizeof(Lock));
- Lock.l_type = F_WRLCK;
- Lock.l_whence = SEEK_SET;
- Lock.l_start = 0;
- Lock.l_len = 0;
- if (::fcntl(FD, F_SETLK, &Lock) != -1)
- return std::error_code();
- int Error = errno;
- if (Error != EACCES && Error != EAGAIN)
- return std::error_code(Error, std::generic_category());
- usleep(1000);
- } while (std::chrono::steady_clock::now() < End);
- return make_error_code(errc::no_lock_available);
-}
-
-std::error_code lockFile(int FD) {
- struct flock Lock;
- memset(&Lock, 0, sizeof(Lock));
- Lock.l_type = F_WRLCK;
- Lock.l_whence = SEEK_SET;
- Lock.l_start = 0;
- Lock.l_len = 0;
- if (::fcntl(FD, F_SETLKW, &Lock) != -1)
- return std::error_code();
- int Error = errno;
- return std::error_code(Error, std::generic_category());
-}
-
-std::error_code unlockFile(int FD) {
- struct flock Lock;
- Lock.l_type = F_UNLCK;
- Lock.l_whence = SEEK_SET;
- Lock.l_start = 0;
- Lock.l_len = 0;
- if (::fcntl(FD, F_SETLK, &Lock) != -1)
- return std::error_code();
- return std::error_code(errno, std::generic_category());
-}
-
+std::error_code tryLockFile(int FD, std::chrono::milliseconds Timeout) {
+ auto Start = std::chrono::steady_clock::now();
+ auto End = Start + Timeout;
+ do {
+ struct flock Lock;
+ memset(&Lock, 0, sizeof(Lock));
+ Lock.l_type = F_WRLCK;
+ Lock.l_whence = SEEK_SET;
+ Lock.l_start = 0;
+ Lock.l_len = 0;
+ if (::fcntl(FD, F_SETLK, &Lock) != -1)
+ return std::error_code();
+ int Error = errno;
+ if (Error != EACCES && Error != EAGAIN)
+ return std::error_code(Error, std::generic_category());
+ usleep(1000);
+ } while (std::chrono::steady_clock::now() < End);
+ return make_error_code(errc::no_lock_available);
+}
+
+std::error_code lockFile(int FD) {
+ struct flock Lock;
+ memset(&Lock, 0, sizeof(Lock));
+ Lock.l_type = F_WRLCK;
+ Lock.l_whence = SEEK_SET;
+ Lock.l_start = 0;
+ Lock.l_len = 0;
+ if (::fcntl(FD, F_SETLKW, &Lock) != -1)
+ return std::error_code();
+ int Error = errno;
+ return std::error_code(Error, std::generic_category());
+}
+
+std::error_code unlockFile(int FD) {
+ struct flock Lock;
+ Lock.l_type = F_UNLCK;
+ Lock.l_whence = SEEK_SET;
+ Lock.l_start = 0;
+ Lock.l_len = 0;
+ if (::fcntl(FD, F_SETLK, &Lock) != -1)
+ return std::error_code();
+ return std::error_code(errno, std::generic_category());
+}
+
std::error_code closeFile(file_t &F) {
file_t TmpF = F;
F = kInvalidFile;
diff --git a/contrib/libs/llvm12/lib/Support/Unix/Process.inc b/contrib/libs/llvm12/lib/Support/Unix/Process.inc
index 7425d084da..8058a3b7ce 100644
--- a/contrib/libs/llvm12/lib/Support/Unix/Process.inc
+++ b/contrib/libs/llvm12/lib/Support/Unix/Process.inc
@@ -313,7 +313,7 @@ unsigned Process::StandardErrColumns() {
return getColumns();
}
-#ifdef LLVM_ENABLE_TERMINFO
+#ifdef LLVM_ENABLE_TERMINFO
// We manually declare these extern functions because finding the correct
// headers from various terminfo, curses, or other sources is harder than
// writing their specs down.
@@ -323,12 +323,12 @@ extern "C" int del_curterm(struct term *termp);
extern "C" int tigetnum(char *capname);
#endif
-#ifdef LLVM_ENABLE_TERMINFO
+#ifdef LLVM_ENABLE_TERMINFO
static ManagedStatic<std::mutex> TermColorMutex;
#endif
static bool terminalHasColors(int fd) {
-#ifdef LLVM_ENABLE_TERMINFO
+#ifdef LLVM_ENABLE_TERMINFO
// First, acquire a global lock because these C routines are thread hostile.
std::lock_guard<std::mutex> G(*TermColorMutex);
diff --git a/contrib/libs/llvm12/lib/Support/Unix/Program.inc b/contrib/libs/llvm12/lib/Support/Unix/Program.inc
index fb56fa4b0d..a018bc06d1 100644
--- a/contrib/libs/llvm12/lib/Support/Unix/Program.inc
+++ b/contrib/libs/llvm12/lib/Support/Unix/Program.inc
@@ -174,8 +174,8 @@ toNullTerminatedCStringArray(ArrayRef<StringRef> Strings, StringSaver &Saver) {
static bool Execute(ProcessInfo &PI, StringRef Program,
ArrayRef<StringRef> Args, Optional<ArrayRef<StringRef>> Env,
ArrayRef<Optional<StringRef>> Redirects,
- unsigned MemoryLimit, std::string *ErrMsg,
- BitVector *AffinityMask) {
+ unsigned MemoryLimit, std::string *ErrMsg,
+ BitVector *AffinityMask) {
if (!llvm::sys::fs::exists(Program)) {
if (ErrMsg)
*ErrMsg = std::string("Executable \"") + Program.str() +
@@ -183,9 +183,9 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
return false;
}
- assert(!AffinityMask && "Starting a process with an affinity mask is "
- "currently not supported on Unix!");
-
+ assert(!AffinityMask && "Starting a process with an affinity mask is "
+ "currently not supported on Unix!");
+
BumpPtrAllocator Allocator;
StringSaver Saver(Allocator);
std::vector<const char *> ArgVector, EnvVector;
diff --git a/contrib/libs/llvm12/lib/Support/Unix/Signals.inc b/contrib/libs/llvm12/lib/Support/Unix/Signals.inc
index 3d7b5d2fe5..8906d28ddd 100644
--- a/contrib/libs/llvm12/lib/Support/Unix/Signals.inc
+++ b/contrib/libs/llvm12/lib/Support/Unix/Signals.inc
@@ -36,7 +36,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/Config/config.h"
#include "llvm/Demangle/Demangle.h"
-#include "llvm/Support/ExitCodes.h"
+#include "llvm/Support/ExitCodes.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/Format.h"
@@ -331,7 +331,7 @@ static void RegisterHandlers() { // Not signal-safe.
registerHandler(S, SignalKind::IsInfo);
}
-void sys::unregisterHandlers() {
+void sys::unregisterHandlers() {
// Restore all of the signal handlers to how they were before we showed up.
for (unsigned i = 0, e = NumRegisteredSignals.load(); i != e; ++i) {
sigaction(RegisteredSignalInfo[i].SigNo,
@@ -367,7 +367,7 @@ static RETSIGTYPE SignalHandler(int Sig) {
// crashes when we return and the signal reissues. This also ensures that if
// we crash in our signal handler that the program will terminate immediately
// instead of recursing in the signal handler.
- sys::unregisterHandlers();
+ sys::unregisterHandlers();
// Unmask all potentially blocked kill signals.
sigset_t SigMask;
@@ -382,15 +382,15 @@ static RETSIGTYPE SignalHandler(int Sig) {
OneShotPipeSignalFunction.exchange(nullptr))
return OldOneShotPipeFunction();
- bool IsIntSig = llvm::is_contained(IntSigs, Sig);
- if (IsIntSig)
+ bool IsIntSig = llvm::is_contained(IntSigs, Sig);
+ if (IsIntSig)
if (auto OldInterruptFunction = InterruptFunction.exchange(nullptr))
return OldInterruptFunction();
- if (Sig == SIGPIPE || IsIntSig) {
- raise(Sig); // Execute the default handler.
+ if (Sig == SIGPIPE || IsIntSig) {
+ raise(Sig); // Execute the default handler.
return;
- }
+ }
}
// Otherwise if it is a fault (like SEGV) run any handler.
@@ -555,7 +555,7 @@ static int unwindBacktrace(void **StackTrace, int MaxEntries) {
//
// On glibc systems we have the 'backtrace' function, which works nicely, but
// doesn't demangle symbols.
-void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) {
+void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) {
#if ENABLE_BACKTRACES
static void *StackTrace[256];
int depth = 0;
@@ -572,15 +572,15 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) {
#endif
if (!depth)
return;
- // If "Depth" is not provided by the caller, use the return value of
- // backtrace() for printing a symbolized stack trace.
- if (!Depth)
- Depth = depth;
- if (printSymbolizedStackTrace(Argv0, StackTrace, Depth, OS))
+ // If "Depth" is not provided by the caller, use the return value of
+ // backtrace() for printing a symbolized stack trace.
+ if (!Depth)
+ Depth = depth;
+ if (printSymbolizedStackTrace(Argv0, StackTrace, Depth, OS))
return;
- OS << "Stack dump without symbol names (ensure you have llvm-symbolizer in "
- "your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point "
- "to it):\n";
+ OS << "Stack dump without symbol names (ensure you have llvm-symbolizer in "
+ "your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point "
+ "to it):\n";
#if HAVE_DLFCN_H && HAVE_DLADDR
int width = 0;
for (int i = 0; i < depth; ++i) {
@@ -622,7 +622,7 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) {
OS << '\n';
}
#elif defined(HAVE_BACKTRACE)
- backtrace_symbols_fd(StackTrace, Depth, STDERR_FILENO);
+ backtrace_symbols_fd(StackTrace, Depth, STDERR_FILENO);
#endif
#endif
}
diff --git a/contrib/libs/llvm12/lib/Support/Unix/Threading.inc b/contrib/libs/llvm12/lib/Support/Unix/Threading.inc
index a745495d6e..4e8c82dbac 100644
--- a/contrib/libs/llvm12/lib/Support/Unix/Threading.inc
+++ b/contrib/libs/llvm12/lib/Support/Unix/Threading.inc
@@ -28,7 +28,7 @@
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <errno.h>
-#include <sys/cpuset.h>
+#include <sys/cpuset.h>
#include <sys/sysctl.h>
#include <sys/user.h>
#include <unistd.h>
@@ -283,13 +283,13 @@ SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) {
#include <thread>
int computeHostNumHardwareThreads() {
-#if defined(__FreeBSD__)
- cpuset_t mask;
- CPU_ZERO(&mask);
- if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(mask),
- &mask) == 0)
- return CPU_COUNT(&mask);
-#elif defined(__linux__)
+#if defined(__FreeBSD__)
+ cpuset_t mask;
+ CPU_ZERO(&mask);
+ if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(mask),
+ &mask) == 0)
+ return CPU_COUNT(&mask);
+#elif defined(__linux__)
cpu_set_t Set;
if (sched_getaffinity(0, sizeof(Set), &Set) == 0)
return CPU_COUNT(&Set);
diff --git a/contrib/libs/llvm12/lib/Support/VirtualFileSystem.cpp b/contrib/libs/llvm12/lib/Support/VirtualFileSystem.cpp
index c0ccadfce0..e725a868c7 100644
--- a/contrib/libs/llvm12/lib/Support/VirtualFileSystem.cpp
+++ b/contrib/libs/llvm12/lib/Support/VirtualFileSystem.cpp
@@ -897,12 +897,12 @@ bool InMemoryFileSystem::addFile(const Twine &P, time_t ModificationTime,
}
bool InMemoryFileSystem::addFileNoOwn(const Twine &P, time_t ModificationTime,
- const llvm::MemoryBufferRef &Buffer,
+ const llvm::MemoryBufferRef &Buffer,
Optional<uint32_t> User,
Optional<uint32_t> Group,
Optional<llvm::sys::fs::file_type> Type,
Optional<llvm::sys::fs::perms> Perms) {
- return addFile(P, ModificationTime, llvm::MemoryBuffer::getMemBuffer(Buffer),
+ return addFile(P, ModificationTime, llvm::MemoryBuffer::getMemBuffer(Buffer),
std::move(User), std::move(Group), std::move(Type),
std::move(Perms));
}
@@ -1187,14 +1187,14 @@ RedirectingFileSystem::setCurrentWorkingDirectory(const Twine &Path) {
return {};
}
-std::error_code RedirectingFileSystem::isLocal(const Twine &Path_,
+std::error_code RedirectingFileSystem::isLocal(const Twine &Path_,
bool &Result) {
- SmallString<256> Path;
- Path_.toVector(Path);
-
- if (std::error_code EC = makeCanonical(Path))
- return {};
-
+ SmallString<256> Path;
+ Path_.toVector(Path);
+
+ if (std::error_code EC = makeCanonical(Path))
+ return {};
+
return ExternalFS->isLocal(Path, Result);
}
@@ -1229,21 +1229,21 @@ std::error_code RedirectingFileSystem::makeAbsolute(SmallVectorImpl<char> &Path)
directory_iterator RedirectingFileSystem::dir_begin(const Twine &Dir,
std::error_code &EC) {
- SmallString<256> Path;
- Dir.toVector(Path);
-
- EC = makeCanonical(Path);
- if (EC)
- return {};
-
- ErrorOr<RedirectingFileSystem::Entry *> E = lookupPath(Path);
+ SmallString<256> Path;
+ Dir.toVector(Path);
+
+ EC = makeCanonical(Path);
+ if (EC)
+ return {};
+
+ ErrorOr<RedirectingFileSystem::Entry *> E = lookupPath(Path);
if (!E) {
EC = E.getError();
if (shouldUseExternalFS() && EC == errc::no_such_file_or_directory)
- return ExternalFS->dir_begin(Path, EC);
+ return ExternalFS->dir_begin(Path, EC);
return {};
}
- ErrorOr<Status> S = status(Path, *E);
+ ErrorOr<Status> S = status(Path, *E);
if (!S) {
EC = S.getError();
return {};
@@ -1256,7 +1256,7 @@ directory_iterator RedirectingFileSystem::dir_begin(const Twine &Dir,
auto *D = cast<RedirectingFileSystem::RedirectingDirectoryEntry>(*E);
return directory_iterator(std::make_shared<VFSFromYamlDirIterImpl>(
- Path, D->contents_begin(), D->contents_end(),
+ Path, D->contents_begin(), D->contents_end(),
/*IterateExternalFS=*/shouldUseExternalFS(), *ExternalFS, EC));
}
@@ -1268,17 +1268,17 @@ StringRef RedirectingFileSystem::getExternalContentsPrefixDir() const {
return ExternalContentsPrefixDir;
}
-void RedirectingFileSystem::setFallthrough(bool Fallthrough) {
- IsFallthrough = Fallthrough;
-}
-
-std::vector<StringRef> RedirectingFileSystem::getRoots() const {
- std::vector<StringRef> R;
- for (const auto &Root : Roots)
- R.push_back(Root->getName());
- return R;
-}
-
+void RedirectingFileSystem::setFallthrough(bool Fallthrough) {
+ IsFallthrough = Fallthrough;
+}
+
+std::vector<StringRef> RedirectingFileSystem::getRoots() const {
+ std::vector<StringRef> R;
+ for (const auto &Root : Roots)
+ R.push_back(Root->getName());
+ return R;
+}
+
void RedirectingFileSystem::dump(raw_ostream &OS) const {
for (const auto &Root : Roots)
dumpEntry(OS, Root.get());
@@ -1383,8 +1383,8 @@ class llvm::vfs::RedirectingFileSystemParser {
return true;
}
-public:
- static RedirectingFileSystem::Entry *
+public:
+ static RedirectingFileSystem::Entry *
lookupOrCreateEntry(RedirectingFileSystem *FS, StringRef Name,
RedirectingFileSystem::Entry *ParentEntry = nullptr) {
if (!ParentEntry) { // Look for a existent root
@@ -1426,7 +1426,7 @@ public:
return DE->getLastContent();
}
-private:
+private:
void uniqueOverlayTree(RedirectingFileSystem *FS,
RedirectingFileSystem::Entry *SrcE,
RedirectingFileSystem::Entry *NewParentE = nullptr) {
@@ -1752,7 +1752,7 @@ public:
}
};
-std::unique_ptr<RedirectingFileSystem>
+std::unique_ptr<RedirectingFileSystem>
RedirectingFileSystem::create(std::unique_ptr<MemoryBuffer> Buffer,
SourceMgr::DiagHandlerTy DiagHandler,
StringRef YAMLFilePath, void *DiagContext,
@@ -1792,80 +1792,80 @@ RedirectingFileSystem::create(std::unique_ptr<MemoryBuffer> Buffer,
if (!P.parse(Root, FS.get()))
return nullptr;
- return FS;
-}
-
-std::unique_ptr<RedirectingFileSystem> RedirectingFileSystem::create(
- ArrayRef<std::pair<std::string, std::string>> RemappedFiles,
- bool UseExternalNames, FileSystem &ExternalFS) {
- std::unique_ptr<RedirectingFileSystem> FS(
- new RedirectingFileSystem(&ExternalFS));
- FS->UseExternalNames = UseExternalNames;
-
- StringMap<RedirectingFileSystem::Entry *> Entries;
-
- for (auto &Mapping : llvm::reverse(RemappedFiles)) {
- SmallString<128> From = StringRef(Mapping.first);
- SmallString<128> To = StringRef(Mapping.second);
- {
- auto EC = ExternalFS.makeAbsolute(From);
- (void)EC;
- assert(!EC && "Could not make absolute path");
- }
-
- // Check if we've already mapped this file. The first one we see (in the
- // reverse iteration) wins.
- RedirectingFileSystem::Entry *&ToEntry = Entries[From];
- if (ToEntry)
- continue;
-
- // Add parent directories.
- RedirectingFileSystem::Entry *Parent = nullptr;
- StringRef FromDirectory = llvm::sys::path::parent_path(From);
- for (auto I = llvm::sys::path::begin(FromDirectory),
- E = llvm::sys::path::end(FromDirectory);
- I != E; ++I) {
- Parent = RedirectingFileSystemParser::lookupOrCreateEntry(FS.get(), *I,
- Parent);
- }
- assert(Parent && "File without a directory?");
- {
- auto EC = ExternalFS.makeAbsolute(To);
- (void)EC;
- assert(!EC && "Could not make absolute path");
- }
-
- // Add the file.
- auto NewFile =
- std::make_unique<RedirectingFileSystem::RedirectingFileEntry>(
- llvm::sys::path::filename(From), To,
- UseExternalNames
- ? RedirectingFileSystem::RedirectingFileEntry::NK_External
- : RedirectingFileSystem::RedirectingFileEntry::NK_Virtual);
- ToEntry = NewFile.get();
- cast<RedirectingFileSystem::RedirectingDirectoryEntry>(Parent)->addContent(
- std::move(NewFile));
- }
-
- return FS;
-}
-
-std::error_code
-RedirectingFileSystem::makeCanonical(SmallVectorImpl<char> &Path) const {
+ return FS;
+}
+
+std::unique_ptr<RedirectingFileSystem> RedirectingFileSystem::create(
+ ArrayRef<std::pair<std::string, std::string>> RemappedFiles,
+ bool UseExternalNames, FileSystem &ExternalFS) {
+ std::unique_ptr<RedirectingFileSystem> FS(
+ new RedirectingFileSystem(&ExternalFS));
+ FS->UseExternalNames = UseExternalNames;
+
+ StringMap<RedirectingFileSystem::Entry *> Entries;
+
+ for (auto &Mapping : llvm::reverse(RemappedFiles)) {
+ SmallString<128> From = StringRef(Mapping.first);
+ SmallString<128> To = StringRef(Mapping.second);
+ {
+ auto EC = ExternalFS.makeAbsolute(From);
+ (void)EC;
+ assert(!EC && "Could not make absolute path");
+ }
+
+ // Check if we've already mapped this file. The first one we see (in the
+ // reverse iteration) wins.
+ RedirectingFileSystem::Entry *&ToEntry = Entries[From];
+ if (ToEntry)
+ continue;
+
+ // Add parent directories.
+ RedirectingFileSystem::Entry *Parent = nullptr;
+ StringRef FromDirectory = llvm::sys::path::parent_path(From);
+ for (auto I = llvm::sys::path::begin(FromDirectory),
+ E = llvm::sys::path::end(FromDirectory);
+ I != E; ++I) {
+ Parent = RedirectingFileSystemParser::lookupOrCreateEntry(FS.get(), *I,
+ Parent);
+ }
+ assert(Parent && "File without a directory?");
+ {
+ auto EC = ExternalFS.makeAbsolute(To);
+ (void)EC;
+ assert(!EC && "Could not make absolute path");
+ }
+
+ // Add the file.
+ auto NewFile =
+ std::make_unique<RedirectingFileSystem::RedirectingFileEntry>(
+ llvm::sys::path::filename(From), To,
+ UseExternalNames
+ ? RedirectingFileSystem::RedirectingFileEntry::NK_External
+ : RedirectingFileSystem::RedirectingFileEntry::NK_Virtual);
+ ToEntry = NewFile.get();
+ cast<RedirectingFileSystem::RedirectingDirectoryEntry>(Parent)->addContent(
+ std::move(NewFile));
+ }
+
+ return FS;
+}
+
+std::error_code
+RedirectingFileSystem::makeCanonical(SmallVectorImpl<char> &Path) const {
if (std::error_code EC = makeAbsolute(Path))
return EC;
- llvm::SmallString<256> CanonicalPath =
- canonicalize(StringRef(Path.data(), Path.size()));
- if (CanonicalPath.empty())
+ llvm::SmallString<256> CanonicalPath =
+ canonicalize(StringRef(Path.data(), Path.size()));
+ if (CanonicalPath.empty())
return make_error_code(llvm::errc::invalid_argument);
- Path.assign(CanonicalPath.begin(), CanonicalPath.end());
- return {};
-}
-
-ErrorOr<RedirectingFileSystem::Entry *>
-RedirectingFileSystem::lookupPath(StringRef Path) const {
+ Path.assign(CanonicalPath.begin(), CanonicalPath.end());
+ return {};
+}
+
+ErrorOr<RedirectingFileSystem::Entry *>
+RedirectingFileSystem::lookupPath(StringRef Path) const {
sys::path::const_iterator Start = sys::path::begin(Path);
sys::path::const_iterator End = sys::path::end(Path);
for (const auto &Root : Roots) {
@@ -1940,13 +1940,13 @@ ErrorOr<Status> RedirectingFileSystem::status(const Twine &Path,
}
}
-ErrorOr<Status> RedirectingFileSystem::status(const Twine &Path_) {
- SmallString<256> Path;
- Path_.toVector(Path);
-
- if (std::error_code EC = makeCanonical(Path))
- return EC;
-
+ErrorOr<Status> RedirectingFileSystem::status(const Twine &Path_) {
+ SmallString<256> Path;
+ Path_.toVector(Path);
+
+ if (std::error_code EC = makeCanonical(Path))
+ return EC;
+
ErrorOr<RedirectingFileSystem::Entry *> Result = lookupPath(Path);
if (!Result) {
if (shouldUseExternalFS() &&
@@ -1984,13 +1984,13 @@ public:
} // namespace
ErrorOr<std::unique_ptr<File>>
-RedirectingFileSystem::openFileForRead(const Twine &Path_) {
- SmallString<256> Path;
- Path_.toVector(Path);
-
- if (std::error_code EC = makeCanonical(Path))
- return EC;
-
+RedirectingFileSystem::openFileForRead(const Twine &Path_) {
+ SmallString<256> Path;
+ Path_.toVector(Path);
+
+ if (std::error_code EC = makeCanonical(Path))
+ return EC;
+
ErrorOr<RedirectingFileSystem::Entry *> E = lookupPath(Path);
if (!E) {
if (shouldUseExternalFS() &&
@@ -2020,14 +2020,14 @@ RedirectingFileSystem::openFileForRead(const Twine &Path_) {
}
std::error_code
-RedirectingFileSystem::getRealPath(const Twine &Path_,
+RedirectingFileSystem::getRealPath(const Twine &Path_,
SmallVectorImpl<char> &Output) const {
- SmallString<256> Path;
- Path_.toVector(Path);
-
- if (std::error_code EC = makeCanonical(Path))
- return EC;
-
+ SmallString<256> Path;
+ Path_.toVector(Path);
+
+ if (std::error_code EC = makeCanonical(Path))
+ return EC;
+
ErrorOr<RedirectingFileSystem::Entry *> Result = lookupPath(Path);
if (!Result) {
if (shouldUseExternalFS() &&
@@ -2047,7 +2047,7 @@ RedirectingFileSystem::getRealPath(const Twine &Path_,
: llvm::errc::invalid_argument;
}
-std::unique_ptr<FileSystem>
+std::unique_ptr<FileSystem>
vfs::getVFSFromYAML(std::unique_ptr<MemoryBuffer> Buffer,
SourceMgr::DiagHandlerTy DiagHandler,
StringRef YAMLFilePath, void *DiagContext,
@@ -2088,7 +2088,7 @@ void vfs::collectVFSFromYAML(std::unique_ptr<MemoryBuffer> Buffer,
SmallVectorImpl<YAMLVFSEntry> &CollectedEntries,
void *DiagContext,
IntrusiveRefCntPtr<FileSystem> ExternalFS) {
- std::unique_ptr<RedirectingFileSystem> VFS = RedirectingFileSystem::create(
+ std::unique_ptr<RedirectingFileSystem> VFS = RedirectingFileSystem::create(
std::move(Buffer), DiagHandler, YAMLFilePath, DiagContext,
std::move(ExternalFS));
ErrorOr<RedirectingFileSystem::Entry *> RootE = VFS->lookupPath("/");
diff --git a/contrib/libs/llvm12/lib/Support/Windows/Path.inc b/contrib/libs/llvm12/lib/Support/Windows/Path.inc
index adcbd1b5f8..8155050d47 100644
--- a/contrib/libs/llvm12/lib/Support/Windows/Path.inc
+++ b/contrib/libs/llvm12/lib/Support/Windows/Path.inc
@@ -402,22 +402,22 @@ std::error_code is_local(int FD, bool &Result) {
}
static std::error_code setDeleteDisposition(HANDLE Handle, bool Delete) {
- // Clear the FILE_DISPOSITION_INFO flag first, before checking if it's a
- // network file. On Windows 7 the function realPathFromHandle() below fails
- // if the FILE_DISPOSITION_INFO flag was already set to 'DeleteFile = true' by
- // a prior call.
- FILE_DISPOSITION_INFO Disposition;
- Disposition.DeleteFile = false;
- if (!SetFileInformationByHandle(Handle, FileDispositionInfo, &Disposition,
- sizeof(Disposition)))
- return mapWindowsError(::GetLastError());
- if (!Delete)
- return std::error_code();
-
- // Check if the file is on a network (non-local) drive. If so, don't
- // continue when DeleteFile is true, since it prevents opening the file for
- // writes. Note -- this will leak temporary files on disk, but only when the
- // target file is on a network drive.
+ // Clear the FILE_DISPOSITION_INFO flag first, before checking if it's a
+ // network file. On Windows 7 the function realPathFromHandle() below fails
+ // if the FILE_DISPOSITION_INFO flag was already set to 'DeleteFile = true' by
+ // a prior call.
+ FILE_DISPOSITION_INFO Disposition;
+ Disposition.DeleteFile = false;
+ if (!SetFileInformationByHandle(Handle, FileDispositionInfo, &Disposition,
+ sizeof(Disposition)))
+ return mapWindowsError(::GetLastError());
+ if (!Delete)
+ return std::error_code();
+
+ // Check if the file is on a network (non-local) drive. If so, don't
+ // continue when DeleteFile is true, since it prevents opening the file for
+ // writes. Note -- this will leak temporary files on disk, but only when the
+ // target file is on a network drive.
SmallVector<wchar_t, 128> FinalPath;
if (std::error_code EC = realPathFromHandle(Handle, FinalPath))
return EC;
@@ -429,9 +429,9 @@ static std::error_code setDeleteDisposition(HANDLE Handle, bool Delete) {
if (!IsLocal)
return std::error_code();
- // The file is on a local drive, we can safely set FILE_DISPOSITION_INFO's
- // flag.
- Disposition.DeleteFile = true;
+ // The file is on a local drive, we can safely set FILE_DISPOSITION_INFO's
+ // flag.
+ Disposition.DeleteFile = true;
if (!SetFileInformationByHandle(Handle, FileDispositionInfo, &Disposition,
sizeof(Disposition)))
return mapWindowsError(::GetLastError());
@@ -1287,43 +1287,43 @@ Expected<size_t> readNativeFileSlice(file_t FileHandle,
return readNativeFileImpl(FileHandle, Buf, &Overlapped);
}
-std::error_code tryLockFile(int FD, std::chrono::milliseconds Timeout) {
- DWORD Flags = LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY;
- OVERLAPPED OV = {};
- file_t File = convertFDToNativeFile(FD);
- auto Start = std::chrono::steady_clock::now();
- auto End = Start + Timeout;
- do {
- if (::LockFileEx(File, Flags, 0, MAXDWORD, MAXDWORD, &OV))
- return std::error_code();
- DWORD Error = ::GetLastError();
- if (Error == ERROR_LOCK_VIOLATION) {
- ::Sleep(1);
- continue;
- }
- return mapWindowsError(Error);
- } while (std::chrono::steady_clock::now() < End);
- return mapWindowsError(ERROR_LOCK_VIOLATION);
-}
-
-std::error_code lockFile(int FD) {
- DWORD Flags = LOCKFILE_EXCLUSIVE_LOCK;
- OVERLAPPED OV = {};
- file_t File = convertFDToNativeFile(FD);
- if (::LockFileEx(File, Flags, 0, MAXDWORD, MAXDWORD, &OV))
- return std::error_code();
- DWORD Error = ::GetLastError();
- return mapWindowsError(Error);
-}
-
-std::error_code unlockFile(int FD) {
- OVERLAPPED OV = {};
- file_t File = convertFDToNativeFile(FD);
- if (::UnlockFileEx(File, 0, MAXDWORD, MAXDWORD, &OV))
- return std::error_code();
- return mapWindowsError(::GetLastError());
-}
-
+std::error_code tryLockFile(int FD, std::chrono::milliseconds Timeout) {
+ DWORD Flags = LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY;
+ OVERLAPPED OV = {};
+ file_t File = convertFDToNativeFile(FD);
+ auto Start = std::chrono::steady_clock::now();
+ auto End = Start + Timeout;
+ do {
+ if (::LockFileEx(File, Flags, 0, MAXDWORD, MAXDWORD, &OV))
+ return std::error_code();
+ DWORD Error = ::GetLastError();
+ if (Error == ERROR_LOCK_VIOLATION) {
+ ::Sleep(1);
+ continue;
+ }
+ return mapWindowsError(Error);
+ } while (std::chrono::steady_clock::now() < End);
+ return mapWindowsError(ERROR_LOCK_VIOLATION);
+}
+
+std::error_code lockFile(int FD) {
+ DWORD Flags = LOCKFILE_EXCLUSIVE_LOCK;
+ OVERLAPPED OV = {};
+ file_t File = convertFDToNativeFile(FD);
+ if (::LockFileEx(File, Flags, 0, MAXDWORD, MAXDWORD, &OV))
+ return std::error_code();
+ DWORD Error = ::GetLastError();
+ return mapWindowsError(Error);
+}
+
+std::error_code unlockFile(int FD) {
+ OVERLAPPED OV = {};
+ file_t File = convertFDToNativeFile(FD);
+ if (::UnlockFileEx(File, 0, MAXDWORD, MAXDWORD, &OV))
+ return std::error_code();
+ return mapWindowsError(::GetLastError());
+}
+
std::error_code closeFile(file_t &F) {
file_t TmpF = F;
F = kInvalidFile;
diff --git a/contrib/libs/llvm12/lib/Support/Windows/Process.inc b/contrib/libs/llvm12/lib/Support/Windows/Process.inc
index 910d2395d2..38ba20bd91 100644
--- a/contrib/libs/llvm12/lib/Support/Windows/Process.inc
+++ b/contrib/libs/llvm12/lib/Support/Windows/Process.inc
@@ -228,8 +228,8 @@ static std::error_code GetExecutableName(SmallVectorImpl<char> &Filename) {
if (EC)
return EC;
- // Make a copy of the filename since assign makes the StringRef invalid.
- std::string Base = sys::path::filename(Filename.data()).str();
+ // Make a copy of the filename since assign makes the StringRef invalid.
+ std::string Base = sys::path::filename(Filename.data()).str();
Filename.assign(Base.begin(), Base.end());
return std::error_code();
}
diff --git a/contrib/libs/llvm12/lib/Support/Windows/Program.inc b/contrib/libs/llvm12/lib/Support/Windows/Program.inc
index f1d612cf3c..e3c07e9da9 100644
--- a/contrib/libs/llvm12/lib/Support/Windows/Program.inc
+++ b/contrib/libs/llvm12/lib/Support/Windows/Program.inc
@@ -171,8 +171,8 @@ static HANDLE RedirectIO(Optional<StringRef> Path, int fd,
static bool Execute(ProcessInfo &PI, StringRef Program,
ArrayRef<StringRef> Args, Optional<ArrayRef<StringRef>> Env,
ArrayRef<Optional<StringRef>> Redirects,
- unsigned MemoryLimit, std::string *ErrMsg,
- BitVector *AffinityMask) {
+ unsigned MemoryLimit, std::string *ErrMsg,
+ BitVector *AffinityMask) {
if (!sys::fs::can_execute(Program)) {
if (ErrMsg)
*ErrMsg = "program not executable";
@@ -190,13 +190,13 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
// Windows wants a command line, not an array of args, to pass to the new
// process. We have to concatenate them all, while quoting the args that
// have embedded spaces (or are empty).
- auto Result = flattenWindowsCommandLine(Args);
- if (std::error_code ec = Result.getError()) {
- SetLastError(ec.value());
- MakeErrMsg(ErrMsg, std::string("Unable to convert command-line to UTF-16"));
- return false;
- }
- std::wstring Command = *Result;
+ auto Result = flattenWindowsCommandLine(Args);
+ if (std::error_code ec = Result.getError()) {
+ SetLastError(ec.value());
+ MakeErrMsg(ErrMsg, std::string("Unable to convert command-line to UTF-16"));
+ return false;
+ }
+ std::wstring Command = *Result;
// The pointer to the environment block for the new process.
std::vector<wchar_t> EnvBlock;
@@ -213,7 +213,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
return false;
}
- llvm::append_range(EnvBlock, EnvString);
+ llvm::append_range(EnvBlock, EnvString);
EnvBlock.push_back(0);
}
EnvBlock.push_back(0);
@@ -278,15 +278,15 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
return false;
}
- unsigned CreateFlags = CREATE_UNICODE_ENVIRONMENT;
- if (AffinityMask)
- CreateFlags |= CREATE_SUSPENDED;
+ unsigned CreateFlags = CREATE_UNICODE_ENVIRONMENT;
+ if (AffinityMask)
+ CreateFlags |= CREATE_SUSPENDED;
- std::vector<wchar_t> CommandUtf16(Command.size() + 1, 0);
- std::copy(Command.begin(), Command.end(), CommandUtf16.begin());
- BOOL rc = CreateProcessW(ProgramUtf16.data(), CommandUtf16.data(), 0, 0, TRUE,
- CreateFlags, EnvBlock.empty() ? 0 : EnvBlock.data(),
- 0, &si, &pi);
+ std::vector<wchar_t> CommandUtf16(Command.size() + 1, 0);
+ std::copy(Command.begin(), Command.end(), CommandUtf16.begin());
+ BOOL rc = CreateProcessW(ProgramUtf16.data(), CommandUtf16.data(), 0, 0, TRUE,
+ CreateFlags, EnvBlock.empty() ? 0 : EnvBlock.data(),
+ 0, &si, &pi);
DWORD err = GetLastError();
// Regardless of whether the process got created or not, we are done with
@@ -334,13 +334,13 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
}
}
- // Set the affinity mask
- if (AffinityMask) {
- ::SetProcessAffinityMask(pi.hProcess,
- (DWORD_PTR)AffinityMask->getData().front());
- ::ResumeThread(pi.hThread);
- }
-
+ // Set the affinity mask
+ if (AffinityMask) {
+ ::SetProcessAffinityMask(pi.hProcess,
+ (DWORD_PTR)AffinityMask->getData().front());
+ ::ResumeThread(pi.hThread);
+ }
+
return true;
}
@@ -387,7 +387,7 @@ static std::string quoteSingleArg(StringRef Arg) {
}
namespace llvm {
-ErrorOr<std::wstring> sys::flattenWindowsCommandLine(ArrayRef<StringRef> Args) {
+ErrorOr<std::wstring> sys::flattenWindowsCommandLine(ArrayRef<StringRef> Args) {
std::string Command;
for (StringRef Arg : Args) {
if (argNeedsQuotes(Arg))
@@ -398,11 +398,11 @@ ErrorOr<std::wstring> sys::flattenWindowsCommandLine(ArrayRef<StringRef> Args) {
Command.push_back(' ');
}
- SmallVector<wchar_t, MAX_PATH> CommandUtf16;
- if (std::error_code ec = windows::UTF8ToUTF16(Command, CommandUtf16))
- return ec;
-
- return std::wstring(CommandUtf16.begin(), CommandUtf16.end());
+ SmallVector<wchar_t, MAX_PATH> CommandUtf16;
+ if (std::error_code ec = windows::UTF8ToUTF16(Command, CommandUtf16))
+ return ec;
+
+ return std::wstring(CommandUtf16.begin(), CommandUtf16.end());
}
ProcessInfo sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait,
@@ -547,16 +547,16 @@ llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents,
bool llvm::sys::commandLineFitsWithinSystemLimits(StringRef Program,
ArrayRef<StringRef> Args) {
- // The documentation on CreateProcessW states that the size of the argument
- // lpCommandLine must not be greater than 32767 characters, including the
- // Unicode terminating null character. We use smaller value to reduce risk
- // of getting invalid command line due to unaccounted factors.
- static const size_t MaxCommandStringLength = 32000;
+ // The documentation on CreateProcessW states that the size of the argument
+ // lpCommandLine must not be greater than 32767 characters, including the
+ // Unicode terminating null character. We use smaller value to reduce risk
+ // of getting invalid command line due to unaccounted factors.
+ static const size_t MaxCommandStringLength = 32000;
SmallVector<StringRef, 8> FullArgs;
FullArgs.push_back(Program);
FullArgs.append(Args.begin(), Args.end());
- auto Result = flattenWindowsCommandLine(FullArgs);
- assert(!Result.getError());
- return (Result->size() + 1) <= MaxCommandStringLength;
+ auto Result = flattenWindowsCommandLine(FullArgs);
+ assert(!Result.getError());
+ return (Result->size() + 1) <= MaxCommandStringLength;
}
}
diff --git a/contrib/libs/llvm12/lib/Support/Windows/Signals.inc b/contrib/libs/llvm12/lib/Support/Windows/Signals.inc
index 3758582b35..f97e42a6df 100644
--- a/contrib/libs/llvm12/lib/Support/Windows/Signals.inc
+++ b/contrib/libs/llvm12/lib/Support/Windows/Signals.inc
@@ -552,8 +552,8 @@ static void LocalPrintStackTrace(raw_ostream &OS, PCONTEXT C) {
StackFrame, C);
}
-void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) {
- // FIXME: Handle "Depth" parameter to print stack trace upto specified Depth
+void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) {
+ // FIXME: Handle "Depth" parameter to print stack trace upto specified Depth
LocalPrintStackTrace(OS, nullptr);
}
@@ -869,5 +869,5 @@ static BOOL WINAPI LLVMConsoleCtrlHandler(DWORD dwCtrlType) {
#pragma GCC diagnostic warning "-Wformat"
#pragma GCC diagnostic warning "-Wformat-extra-args"
#endif
-
-void sys::unregisterHandlers() {}
+
+void sys::unregisterHandlers() {}
diff --git a/contrib/libs/llvm12/lib/Support/Windows/Threading.inc b/contrib/libs/llvm12/lib/Support/Windows/Threading.inc
index 6448bb478d..d96f3ded72 100644
--- a/contrib/libs/llvm12/lib/Support/Windows/Threading.inc
+++ b/contrib/libs/llvm12/lib/Support/Windows/Threading.inc
@@ -195,25 +195,25 @@ static ArrayRef<ProcessorGroup> getProcessorGroups() {
if (!IterateProcInfo(RelationProcessorCore, HandleProc))
return std::vector<ProcessorGroup>();
- // If there's an affinity mask set, assume the user wants to constrain the
- // current process to only a single CPU group. On Windows, it is not
- // possible for affinity masks to cross CPU group boundaries.
- DWORD_PTR ProcessAffinityMask = 0, SystemAffinityMask = 0;
- if (::GetProcessAffinityMask(GetCurrentProcess(), &ProcessAffinityMask,
- &SystemAffinityMask) &&
- ProcessAffinityMask != SystemAffinityMask) {
- // We don't expect more that 4 CPU groups on Windows (256 processors).
- USHORT GroupCount = 4;
- USHORT GroupArray[4]{};
- if (::GetProcessGroupAffinity(GetCurrentProcess(), &GroupCount,
- GroupArray)) {
- assert(GroupCount == 1 &&
- "On startup, a program is expected to be assigned only to "
- "one processor group!");
- unsigned CurrentGroupID = GroupArray[0];
- ProcessorGroup NewG{Groups[CurrentGroupID]};
- NewG.Affinity = ProcessAffinityMask;
- NewG.UsableThreads = countPopulation(ProcessAffinityMask);
+ // If there's an affinity mask set, assume the user wants to constrain the
+ // current process to only a single CPU group. On Windows, it is not
+ // possible for affinity masks to cross CPU group boundaries.
+ DWORD_PTR ProcessAffinityMask = 0, SystemAffinityMask = 0;
+ if (::GetProcessAffinityMask(GetCurrentProcess(), &ProcessAffinityMask,
+ &SystemAffinityMask) &&
+ ProcessAffinityMask != SystemAffinityMask) {
+ // We don't expect more that 4 CPU groups on Windows (256 processors).
+ USHORT GroupCount = 4;
+ USHORT GroupArray[4]{};
+ if (::GetProcessGroupAffinity(GetCurrentProcess(), &GroupCount,
+ GroupArray)) {
+ assert(GroupCount == 1 &&
+ "On startup, a program is expected to be assigned only to "
+ "one processor group!");
+ unsigned CurrentGroupID = GroupArray[0];
+ ProcessorGroup NewG{Groups[CurrentGroupID]};
+ NewG.Affinity = ProcessAffinityMask;
+ NewG.UsableThreads = countPopulation(ProcessAffinityMask);
Groups.clear();
Groups.push_back(NewG);
}
diff --git a/contrib/libs/llvm12/lib/Support/X86TargetParser.cpp b/contrib/libs/llvm12/lib/Support/X86TargetParser.cpp
index d738511465..b4772bb7a4 100644
--- a/contrib/libs/llvm12/lib/Support/X86TargetParser.cpp
+++ b/contrib/libs/llvm12/lib/Support/X86TargetParser.cpp
@@ -116,160 +116,160 @@ struct FeatureInfo {
} // end anonymous namespace
#define X86_FEATURE(ENUM, STRING) \
- constexpr FeatureBitset Feature##ENUM = {X86::FEATURE_##ENUM};
+ constexpr FeatureBitset Feature##ENUM = {X86::FEATURE_##ENUM};
#include "llvm/Support/X86TargetParser.def"
// Pentium with MMX.
-constexpr FeatureBitset FeaturesPentiumMMX =
+constexpr FeatureBitset FeaturesPentiumMMX =
FeatureX87 | FeatureCMPXCHG8B | FeatureMMX;
// Pentium 2 and 3.
-constexpr FeatureBitset FeaturesPentium2 =
+constexpr FeatureBitset FeaturesPentium2 =
FeatureX87 | FeatureCMPXCHG8B | FeatureMMX | FeatureFXSR;
-constexpr FeatureBitset FeaturesPentium3 = FeaturesPentium2 | FeatureSSE;
+constexpr FeatureBitset FeaturesPentium3 = FeaturesPentium2 | FeatureSSE;
// Pentium 4 CPUs
-constexpr FeatureBitset FeaturesPentium4 = FeaturesPentium3 | FeatureSSE2;
-constexpr FeatureBitset FeaturesPrescott = FeaturesPentium4 | FeatureSSE3;
-constexpr FeatureBitset FeaturesNocona =
+constexpr FeatureBitset FeaturesPentium4 = FeaturesPentium3 | FeatureSSE2;
+constexpr FeatureBitset FeaturesPrescott = FeaturesPentium4 | FeatureSSE3;
+constexpr FeatureBitset FeaturesNocona =
FeaturesPrescott | Feature64BIT | FeatureCMPXCHG16B;
// Basic 64-bit capable CPU.
-constexpr FeatureBitset FeaturesX86_64 = FeaturesPentium4 | Feature64BIT;
-constexpr FeatureBitset FeaturesX86_64_V2 = FeaturesX86_64 | FeatureSAHF |
- FeaturePOPCNT | FeatureSSE4_2 |
- FeatureCMPXCHG16B;
-constexpr FeatureBitset FeaturesX86_64_V3 =
- FeaturesX86_64_V2 | FeatureAVX2 | FeatureBMI | FeatureBMI2 | FeatureF16C |
- FeatureFMA | FeatureLZCNT | FeatureMOVBE | FeatureXSAVE;
-constexpr FeatureBitset FeaturesX86_64_V4 = FeaturesX86_64_V3 |
- FeatureAVX512BW | FeatureAVX512CD |
- FeatureAVX512DQ | FeatureAVX512VL;
+constexpr FeatureBitset FeaturesX86_64 = FeaturesPentium4 | Feature64BIT;
+constexpr FeatureBitset FeaturesX86_64_V2 = FeaturesX86_64 | FeatureSAHF |
+ FeaturePOPCNT | FeatureSSE4_2 |
+ FeatureCMPXCHG16B;
+constexpr FeatureBitset FeaturesX86_64_V3 =
+ FeaturesX86_64_V2 | FeatureAVX2 | FeatureBMI | FeatureBMI2 | FeatureF16C |
+ FeatureFMA | FeatureLZCNT | FeatureMOVBE | FeatureXSAVE;
+constexpr FeatureBitset FeaturesX86_64_V4 = FeaturesX86_64_V3 |
+ FeatureAVX512BW | FeatureAVX512CD |
+ FeatureAVX512DQ | FeatureAVX512VL;
// Intel Core CPUs
-constexpr FeatureBitset FeaturesCore2 =
+constexpr FeatureBitset FeaturesCore2 =
FeaturesNocona | FeatureSAHF | FeatureSSSE3;
-constexpr FeatureBitset FeaturesPenryn = FeaturesCore2 | FeatureSSE4_1;
-constexpr FeatureBitset FeaturesNehalem =
+constexpr FeatureBitset FeaturesPenryn = FeaturesCore2 | FeatureSSE4_1;
+constexpr FeatureBitset FeaturesNehalem =
FeaturesPenryn | FeaturePOPCNT | FeatureSSE4_2;
-constexpr FeatureBitset FeaturesWestmere = FeaturesNehalem | FeaturePCLMUL;
-constexpr FeatureBitset FeaturesSandyBridge =
+constexpr FeatureBitset FeaturesWestmere = FeaturesNehalem | FeaturePCLMUL;
+constexpr FeatureBitset FeaturesSandyBridge =
FeaturesWestmere | FeatureAVX | FeatureXSAVE | FeatureXSAVEOPT;
-constexpr FeatureBitset FeaturesIvyBridge =
+constexpr FeatureBitset FeaturesIvyBridge =
FeaturesSandyBridge | FeatureF16C | FeatureFSGSBASE | FeatureRDRND;
-constexpr FeatureBitset FeaturesHaswell =
+constexpr FeatureBitset FeaturesHaswell =
FeaturesIvyBridge | FeatureAVX2 | FeatureBMI | FeatureBMI2 | FeatureFMA |
FeatureINVPCID | FeatureLZCNT | FeatureMOVBE;
-constexpr FeatureBitset FeaturesBroadwell =
+constexpr FeatureBitset FeaturesBroadwell =
FeaturesHaswell | FeatureADX | FeaturePRFCHW | FeatureRDSEED;
// Intel Knights Landing and Knights Mill
// Knights Landing has feature parity with Broadwell.
-constexpr FeatureBitset FeaturesKNL =
+constexpr FeatureBitset FeaturesKNL =
FeaturesBroadwell | FeatureAES | FeatureAVX512F | FeatureAVX512CD |
FeatureAVX512ER | FeatureAVX512PF | FeaturePREFETCHWT1;
-constexpr FeatureBitset FeaturesKNM = FeaturesKNL | FeatureAVX512VPOPCNTDQ;
+constexpr FeatureBitset FeaturesKNM = FeaturesKNL | FeatureAVX512VPOPCNTDQ;
// Intel Skylake processors.
-constexpr FeatureBitset FeaturesSkylakeClient =
+constexpr FeatureBitset FeaturesSkylakeClient =
FeaturesBroadwell | FeatureAES | FeatureCLFLUSHOPT | FeatureXSAVEC |
FeatureXSAVES | FeatureSGX;
// SkylakeServer inherits all SkylakeClient features except SGX.
// FIXME: That doesn't match gcc.
-constexpr FeatureBitset FeaturesSkylakeServer =
+constexpr FeatureBitset FeaturesSkylakeServer =
(FeaturesSkylakeClient & ~FeatureSGX) | FeatureAVX512F | FeatureAVX512CD |
FeatureAVX512DQ | FeatureAVX512BW | FeatureAVX512VL | FeatureCLWB |
FeaturePKU;
-constexpr FeatureBitset FeaturesCascadeLake =
+constexpr FeatureBitset FeaturesCascadeLake =
FeaturesSkylakeServer | FeatureAVX512VNNI;
-constexpr FeatureBitset FeaturesCooperLake =
+constexpr FeatureBitset FeaturesCooperLake =
FeaturesCascadeLake | FeatureAVX512BF16;
// Intel 10nm processors.
-constexpr FeatureBitset FeaturesCannonlake =
+constexpr FeatureBitset FeaturesCannonlake =
FeaturesSkylakeClient | FeatureAVX512F | FeatureAVX512CD | FeatureAVX512DQ |
FeatureAVX512BW | FeatureAVX512VL | FeatureAVX512IFMA | FeatureAVX512VBMI |
FeaturePKU | FeatureSHA;
-constexpr FeatureBitset FeaturesICLClient =
+constexpr FeatureBitset FeaturesICLClient =
FeaturesCannonlake | FeatureAVX512BITALG | FeatureAVX512VBMI2 |
FeatureAVX512VNNI | FeatureAVX512VPOPCNTDQ | FeatureCLWB | FeatureGFNI |
FeatureRDPID | FeatureVAES | FeatureVPCLMULQDQ;
-constexpr FeatureBitset FeaturesICLServer =
+constexpr FeatureBitset FeaturesICLServer =
FeaturesICLClient | FeaturePCONFIG | FeatureWBNOINVD;
-constexpr FeatureBitset FeaturesTigerlake =
+constexpr FeatureBitset FeaturesTigerlake =
FeaturesICLClient | FeatureAVX512VP2INTERSECT | FeatureMOVDIR64B |
- FeatureMOVDIRI | FeatureSHSTK | FeatureKL | FeatureWIDEKL;
-constexpr FeatureBitset FeaturesSapphireRapids =
- FeaturesICLServer | FeatureAMX_TILE | FeatureAMX_INT8 | FeatureAMX_BF16 |
- FeatureAVX512BF16 | FeatureAVX512VP2INTERSECT | FeatureCLDEMOTE |
- FeatureENQCMD | FeatureMOVDIR64B | FeatureMOVDIRI | FeaturePTWRITE |
- FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
- FeatureWAITPKG | FeatureAVXVNNI;
-constexpr FeatureBitset FeaturesAlderlake =
- FeaturesSkylakeClient | FeatureCLDEMOTE | FeatureHRESET | FeaturePTWRITE |
- FeatureSERIALIZE | FeatureWAITPKG | FeatureAVXVNNI;
+ FeatureMOVDIRI | FeatureSHSTK | FeatureKL | FeatureWIDEKL;
+constexpr FeatureBitset FeaturesSapphireRapids =
+ FeaturesICLServer | FeatureAMX_TILE | FeatureAMX_INT8 | FeatureAMX_BF16 |
+ FeatureAVX512BF16 | FeatureAVX512VP2INTERSECT | FeatureCLDEMOTE |
+ FeatureENQCMD | FeatureMOVDIR64B | FeatureMOVDIRI | FeaturePTWRITE |
+ FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
+ FeatureWAITPKG | FeatureAVXVNNI;
+constexpr FeatureBitset FeaturesAlderlake =
+ FeaturesSkylakeClient | FeatureCLDEMOTE | FeatureHRESET | FeaturePTWRITE |
+ FeatureSERIALIZE | FeatureWAITPKG | FeatureAVXVNNI;
// Intel Atom processors.
// Bonnell has feature parity with Core2 and adds MOVBE.
-constexpr FeatureBitset FeaturesBonnell = FeaturesCore2 | FeatureMOVBE;
+constexpr FeatureBitset FeaturesBonnell = FeaturesCore2 | FeatureMOVBE;
// Silvermont has parity with Westmere and Bonnell plus PRFCHW and RDRND.
-constexpr FeatureBitset FeaturesSilvermont =
+constexpr FeatureBitset FeaturesSilvermont =
FeaturesBonnell | FeaturesWestmere | FeaturePRFCHW | FeatureRDRND;
-constexpr FeatureBitset FeaturesGoldmont =
+constexpr FeatureBitset FeaturesGoldmont =
FeaturesSilvermont | FeatureAES | FeatureCLFLUSHOPT | FeatureFSGSBASE |
FeatureRDSEED | FeatureSHA | FeatureXSAVE | FeatureXSAVEC |
FeatureXSAVEOPT | FeatureXSAVES;
-constexpr FeatureBitset FeaturesGoldmontPlus =
+constexpr FeatureBitset FeaturesGoldmontPlus =
FeaturesGoldmont | FeaturePTWRITE | FeatureRDPID | FeatureSGX;
-constexpr FeatureBitset FeaturesTremont =
+constexpr FeatureBitset FeaturesTremont =
FeaturesGoldmontPlus | FeatureCLWB | FeatureGFNI;
// Geode Processor.
-constexpr FeatureBitset FeaturesGeode =
+constexpr FeatureBitset FeaturesGeode =
FeatureX87 | FeatureCMPXCHG8B | FeatureMMX | Feature3DNOW | Feature3DNOWA;
// K6 processor.
-constexpr FeatureBitset FeaturesK6 = FeatureX87 | FeatureCMPXCHG8B | FeatureMMX;
+constexpr FeatureBitset FeaturesK6 = FeatureX87 | FeatureCMPXCHG8B | FeatureMMX;
// K7 and K8 architecture processors.
-constexpr FeatureBitset FeaturesAthlon =
+constexpr FeatureBitset FeaturesAthlon =
FeatureX87 | FeatureCMPXCHG8B | FeatureMMX | Feature3DNOW | Feature3DNOWA;
-constexpr FeatureBitset FeaturesAthlonXP =
+constexpr FeatureBitset FeaturesAthlonXP =
FeaturesAthlon | FeatureFXSR | FeatureSSE;
-constexpr FeatureBitset FeaturesK8 =
+constexpr FeatureBitset FeaturesK8 =
FeaturesAthlonXP | FeatureSSE2 | Feature64BIT;
-constexpr FeatureBitset FeaturesK8SSE3 = FeaturesK8 | FeatureSSE3;
-constexpr FeatureBitset FeaturesAMDFAM10 =
+constexpr FeatureBitset FeaturesK8SSE3 = FeaturesK8 | FeatureSSE3;
+constexpr FeatureBitset FeaturesAMDFAM10 =
FeaturesK8SSE3 | FeatureCMPXCHG16B | FeatureLZCNT | FeaturePOPCNT |
FeaturePRFCHW | FeatureSAHF | FeatureSSE4_A;
// Bobcat architecture processors.
-constexpr FeatureBitset FeaturesBTVER1 =
+constexpr FeatureBitset FeaturesBTVER1 =
FeatureX87 | FeatureCMPXCHG8B | FeatureCMPXCHG16B | Feature64BIT |
FeatureFXSR | FeatureLZCNT | FeatureMMX | FeaturePOPCNT | FeaturePRFCHW |
FeatureSSE | FeatureSSE2 | FeatureSSE3 | FeatureSSSE3 | FeatureSSE4_A |
FeatureSAHF;
-constexpr FeatureBitset FeaturesBTVER2 =
+constexpr FeatureBitset FeaturesBTVER2 =
FeaturesBTVER1 | FeatureAES | FeatureAVX | FeatureBMI | FeatureF16C |
FeatureMOVBE | FeaturePCLMUL | FeatureXSAVE | FeatureXSAVEOPT;
// AMD Bulldozer architecture processors.
-constexpr FeatureBitset FeaturesBDVER1 =
+constexpr FeatureBitset FeaturesBDVER1 =
FeatureX87 | FeatureAES | FeatureAVX | FeatureCMPXCHG8B |
FeatureCMPXCHG16B | Feature64BIT | FeatureFMA4 | FeatureFXSR | FeatureLWP |
FeatureLZCNT | FeatureMMX | FeaturePCLMUL | FeaturePOPCNT | FeaturePRFCHW |
FeatureSAHF | FeatureSSE | FeatureSSE2 | FeatureSSE3 | FeatureSSSE3 |
FeatureSSE4_1 | FeatureSSE4_2 | FeatureSSE4_A | FeatureXOP | FeatureXSAVE;
-constexpr FeatureBitset FeaturesBDVER2 =
+constexpr FeatureBitset FeaturesBDVER2 =
FeaturesBDVER1 | FeatureBMI | FeatureFMA | FeatureF16C | FeatureTBM;
-constexpr FeatureBitset FeaturesBDVER3 =
+constexpr FeatureBitset FeaturesBDVER3 =
FeaturesBDVER2 | FeatureFSGSBASE | FeatureXSAVEOPT;
-constexpr FeatureBitset FeaturesBDVER4 = FeaturesBDVER3 | FeatureAVX2 |
- FeatureBMI2 | FeatureMOVBE |
- FeatureMWAITX | FeatureRDRND;
+constexpr FeatureBitset FeaturesBDVER4 = FeaturesBDVER3 | FeatureAVX2 |
+ FeatureBMI2 | FeatureMOVBE |
+ FeatureMWAITX | FeatureRDRND;
// AMD Zen architecture processors.
-constexpr FeatureBitset FeaturesZNVER1 =
+constexpr FeatureBitset FeaturesZNVER1 =
FeatureX87 | FeatureADX | FeatureAES | FeatureAVX | FeatureAVX2 |
FeatureBMI | FeatureBMI2 | FeatureCLFLUSHOPT | FeatureCLZERO |
FeatureCMPXCHG8B | FeatureCMPXCHG16B | Feature64BIT | FeatureF16C |
@@ -279,13 +279,13 @@ constexpr FeatureBitset FeaturesZNVER1 =
FeatureSSE | FeatureSSE2 | FeatureSSE3 | FeatureSSSE3 | FeatureSSE4_1 |
FeatureSSE4_2 | FeatureSSE4_A | FeatureXSAVE | FeatureXSAVEC |
FeatureXSAVEOPT | FeatureXSAVES;
-constexpr FeatureBitset FeaturesZNVER2 =
+constexpr FeatureBitset FeaturesZNVER2 =
FeaturesZNVER1 | FeatureCLWB | FeatureRDPID | FeatureWBNOINVD;
-static constexpr FeatureBitset FeaturesZNVER3 = FeaturesZNVER2 |
- FeatureINVPCID | FeaturePKU |
- FeatureVAES | FeatureVPCLMULQDQ;
+static constexpr FeatureBitset FeaturesZNVER3 = FeaturesZNVER2 |
+ FeatureINVPCID | FeaturePKU |
+ FeatureVAES | FeatureVPCLMULQDQ;
-constexpr ProcInfo Processors[] = {
+constexpr ProcInfo Processors[] = {
// Empty processor. Include X87 and CMPXCHG8 for backwards compatibility.
{ {""}, CK_None, ~0U, FeatureX87 | FeatureCMPXCHG8B },
// i386-generation processors.
@@ -357,10 +357,10 @@ constexpr ProcInfo Processors[] = {
{ {"icelake-server"}, CK_IcelakeServer, FEATURE_AVX512VBMI2, FeaturesICLServer },
// Tigerlake microarchitecture based processors.
{ {"tigerlake"}, CK_Tigerlake, FEATURE_AVX512VP2INTERSECT, FeaturesTigerlake },
- // Sapphire Rapids microarchitecture based processors.
- { {"sapphirerapids"}, CK_SapphireRapids, FEATURE_AVX512VP2INTERSECT, FeaturesSapphireRapids },
- // Alderlake microarchitecture based processors.
- { {"alderlake"}, CK_Alderlake, FEATURE_AVX2, FeaturesAlderlake },
+ // Sapphire Rapids microarchitecture based processors.
+ { {"sapphirerapids"}, CK_SapphireRapids, FEATURE_AVX512VP2INTERSECT, FeaturesSapphireRapids },
+ // Alderlake microarchitecture based processors.
+ { {"alderlake"}, CK_Alderlake, FEATURE_AVX2, FeaturesAlderlake },
// Knights Landing processor.
{ {"knl"}, CK_KNL, FEATURE_AVX512F, FeaturesKNL },
// Knights Mill processor.
@@ -398,18 +398,18 @@ constexpr ProcInfo Processors[] = {
// Zen architecture processors.
{ {"znver1"}, CK_ZNVER1, FEATURE_AVX2, FeaturesZNVER1 },
{ {"znver2"}, CK_ZNVER2, FEATURE_AVX2, FeaturesZNVER2 },
- { {"znver3"}, CK_ZNVER3, FEATURE_AVX2, FeaturesZNVER3 },
+ { {"znver3"}, CK_ZNVER3, FEATURE_AVX2, FeaturesZNVER3 },
// Generic 64-bit processor.
{ {"x86-64"}, CK_x86_64, ~0U, FeaturesX86_64 },
- { {"x86-64-v2"}, CK_x86_64_v2, ~0U, FeaturesX86_64_V2 },
- { {"x86-64-v3"}, CK_x86_64_v3, ~0U, FeaturesX86_64_V3 },
- { {"x86-64-v4"}, CK_x86_64_v4, ~0U, FeaturesX86_64_V4 },
+ { {"x86-64-v2"}, CK_x86_64_v2, ~0U, FeaturesX86_64_V2 },
+ { {"x86-64-v3"}, CK_x86_64_v3, ~0U, FeaturesX86_64_V3 },
+ { {"x86-64-v4"}, CK_x86_64_v4, ~0U, FeaturesX86_64_V4 },
// Geode processors.
{ {"geode"}, CK_Geode, ~0U, FeaturesGeode },
};
-constexpr const char *NoTuneList[] = {"x86-64-v2", "x86-64-v3", "x86-64-v4"};
-
+constexpr const char *NoTuneList[] = {"x86-64-v2", "x86-64-v3", "x86-64-v4"};
+
X86::CPUKind llvm::X86::parseArchX86(StringRef CPU, bool Only64Bit) {
for (const auto &P : Processors)
if (P.Name == CPU && (P.Features[FEATURE_64BIT] || !Only64Bit))
@@ -418,12 +418,12 @@ X86::CPUKind llvm::X86::parseArchX86(StringRef CPU, bool Only64Bit) {
return CK_None;
}
-X86::CPUKind llvm::X86::parseTuneCPU(StringRef CPU, bool Only64Bit) {
- if (llvm::is_contained(NoTuneList, CPU))
- return CK_None;
- return parseArchX86(CPU, Only64Bit);
-}
-
+X86::CPUKind llvm::X86::parseTuneCPU(StringRef CPU, bool Only64Bit) {
+ if (llvm::is_contained(NoTuneList, CPU))
+ return CK_None;
+ return parseArchX86(CPU, Only64Bit);
+}
+
void llvm::X86::fillValidCPUArchList(SmallVectorImpl<StringRef> &Values,
bool Only64Bit) {
for (const auto &P : Processors)
@@ -431,14 +431,14 @@ void llvm::X86::fillValidCPUArchList(SmallVectorImpl<StringRef> &Values,
Values.emplace_back(P.Name);
}
-void llvm::X86::fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values,
- bool Only64Bit) {
- for (const ProcInfo &P : Processors)
- if (!P.Name.empty() && (P.Features[FEATURE_64BIT] || !Only64Bit) &&
- !llvm::is_contained(NoTuneList, P.Name))
- Values.emplace_back(P.Name);
-}
-
+void llvm::X86::fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values,
+ bool Only64Bit) {
+ for (const ProcInfo &P : Processors)
+ if (!P.Name.empty() && (P.Features[FEATURE_64BIT] || !Only64Bit) &&
+ !llvm::is_contained(NoTuneList, P.Name))
+ Values.emplace_back(P.Name);
+}
+
ProcessorFeatures llvm::X86::getKeyFeature(X86::CPUKind Kind) {
// FIXME: Can we avoid a linear search here? The table might be sorted by
// CPUKind so we could binary search?
@@ -453,131 +453,131 @@ ProcessorFeatures llvm::X86::getKeyFeature(X86::CPUKind Kind) {
}
// Features with no dependencies.
-constexpr FeatureBitset ImpliedFeatures64BIT = {};
-constexpr FeatureBitset ImpliedFeaturesADX = {};
-constexpr FeatureBitset ImpliedFeaturesBMI = {};
-constexpr FeatureBitset ImpliedFeaturesBMI2 = {};
-constexpr FeatureBitset ImpliedFeaturesCLDEMOTE = {};
-constexpr FeatureBitset ImpliedFeaturesCLFLUSHOPT = {};
-constexpr FeatureBitset ImpliedFeaturesCLWB = {};
-constexpr FeatureBitset ImpliedFeaturesCLZERO = {};
-constexpr FeatureBitset ImpliedFeaturesCMOV = {};
-constexpr FeatureBitset ImpliedFeaturesCMPXCHG16B = {};
-constexpr FeatureBitset ImpliedFeaturesCMPXCHG8B = {};
-constexpr FeatureBitset ImpliedFeaturesENQCMD = {};
-constexpr FeatureBitset ImpliedFeaturesFSGSBASE = {};
-constexpr FeatureBitset ImpliedFeaturesFXSR = {};
-constexpr FeatureBitset ImpliedFeaturesINVPCID = {};
-constexpr FeatureBitset ImpliedFeaturesLWP = {};
-constexpr FeatureBitset ImpliedFeaturesLZCNT = {};
-constexpr FeatureBitset ImpliedFeaturesMWAITX = {};
-constexpr FeatureBitset ImpliedFeaturesMOVBE = {};
-constexpr FeatureBitset ImpliedFeaturesMOVDIR64B = {};
-constexpr FeatureBitset ImpliedFeaturesMOVDIRI = {};
-constexpr FeatureBitset ImpliedFeaturesPCONFIG = {};
-constexpr FeatureBitset ImpliedFeaturesPOPCNT = {};
-constexpr FeatureBitset ImpliedFeaturesPKU = {};
-constexpr FeatureBitset ImpliedFeaturesPREFETCHWT1 = {};
-constexpr FeatureBitset ImpliedFeaturesPRFCHW = {};
-constexpr FeatureBitset ImpliedFeaturesPTWRITE = {};
-constexpr FeatureBitset ImpliedFeaturesRDPID = {};
-constexpr FeatureBitset ImpliedFeaturesRDRND = {};
-constexpr FeatureBitset ImpliedFeaturesRDSEED = {};
-constexpr FeatureBitset ImpliedFeaturesRTM = {};
-constexpr FeatureBitset ImpliedFeaturesSAHF = {};
-constexpr FeatureBitset ImpliedFeaturesSERIALIZE = {};
-constexpr FeatureBitset ImpliedFeaturesSGX = {};
-constexpr FeatureBitset ImpliedFeaturesSHSTK = {};
-constexpr FeatureBitset ImpliedFeaturesTBM = {};
-constexpr FeatureBitset ImpliedFeaturesTSXLDTRK = {};
-constexpr FeatureBitset ImpliedFeaturesUINTR = {};
-constexpr FeatureBitset ImpliedFeaturesWAITPKG = {};
-constexpr FeatureBitset ImpliedFeaturesWBNOINVD = {};
-constexpr FeatureBitset ImpliedFeaturesVZEROUPPER = {};
-constexpr FeatureBitset ImpliedFeaturesX87 = {};
-constexpr FeatureBitset ImpliedFeaturesXSAVE = {};
+constexpr FeatureBitset ImpliedFeatures64BIT = {};
+constexpr FeatureBitset ImpliedFeaturesADX = {};
+constexpr FeatureBitset ImpliedFeaturesBMI = {};
+constexpr FeatureBitset ImpliedFeaturesBMI2 = {};
+constexpr FeatureBitset ImpliedFeaturesCLDEMOTE = {};
+constexpr FeatureBitset ImpliedFeaturesCLFLUSHOPT = {};
+constexpr FeatureBitset ImpliedFeaturesCLWB = {};
+constexpr FeatureBitset ImpliedFeaturesCLZERO = {};
+constexpr FeatureBitset ImpliedFeaturesCMOV = {};
+constexpr FeatureBitset ImpliedFeaturesCMPXCHG16B = {};
+constexpr FeatureBitset ImpliedFeaturesCMPXCHG8B = {};
+constexpr FeatureBitset ImpliedFeaturesENQCMD = {};
+constexpr FeatureBitset ImpliedFeaturesFSGSBASE = {};
+constexpr FeatureBitset ImpliedFeaturesFXSR = {};
+constexpr FeatureBitset ImpliedFeaturesINVPCID = {};
+constexpr FeatureBitset ImpliedFeaturesLWP = {};
+constexpr FeatureBitset ImpliedFeaturesLZCNT = {};
+constexpr FeatureBitset ImpliedFeaturesMWAITX = {};
+constexpr FeatureBitset ImpliedFeaturesMOVBE = {};
+constexpr FeatureBitset ImpliedFeaturesMOVDIR64B = {};
+constexpr FeatureBitset ImpliedFeaturesMOVDIRI = {};
+constexpr FeatureBitset ImpliedFeaturesPCONFIG = {};
+constexpr FeatureBitset ImpliedFeaturesPOPCNT = {};
+constexpr FeatureBitset ImpliedFeaturesPKU = {};
+constexpr FeatureBitset ImpliedFeaturesPREFETCHWT1 = {};
+constexpr FeatureBitset ImpliedFeaturesPRFCHW = {};
+constexpr FeatureBitset ImpliedFeaturesPTWRITE = {};
+constexpr FeatureBitset ImpliedFeaturesRDPID = {};
+constexpr FeatureBitset ImpliedFeaturesRDRND = {};
+constexpr FeatureBitset ImpliedFeaturesRDSEED = {};
+constexpr FeatureBitset ImpliedFeaturesRTM = {};
+constexpr FeatureBitset ImpliedFeaturesSAHF = {};
+constexpr FeatureBitset ImpliedFeaturesSERIALIZE = {};
+constexpr FeatureBitset ImpliedFeaturesSGX = {};
+constexpr FeatureBitset ImpliedFeaturesSHSTK = {};
+constexpr FeatureBitset ImpliedFeaturesTBM = {};
+constexpr FeatureBitset ImpliedFeaturesTSXLDTRK = {};
+constexpr FeatureBitset ImpliedFeaturesUINTR = {};
+constexpr FeatureBitset ImpliedFeaturesWAITPKG = {};
+constexpr FeatureBitset ImpliedFeaturesWBNOINVD = {};
+constexpr FeatureBitset ImpliedFeaturesVZEROUPPER = {};
+constexpr FeatureBitset ImpliedFeaturesX87 = {};
+constexpr FeatureBitset ImpliedFeaturesXSAVE = {};
// Not really CPU features, but need to be in the table because clang uses
// target features to communicate them to the backend.
-constexpr FeatureBitset ImpliedFeaturesRETPOLINE_EXTERNAL_THUNK = {};
-constexpr FeatureBitset ImpliedFeaturesRETPOLINE_INDIRECT_BRANCHES = {};
-constexpr FeatureBitset ImpliedFeaturesRETPOLINE_INDIRECT_CALLS = {};
-constexpr FeatureBitset ImpliedFeaturesLVI_CFI = {};
-constexpr FeatureBitset ImpliedFeaturesLVI_LOAD_HARDENING = {};
+constexpr FeatureBitset ImpliedFeaturesRETPOLINE_EXTERNAL_THUNK = {};
+constexpr FeatureBitset ImpliedFeaturesRETPOLINE_INDIRECT_BRANCHES = {};
+constexpr FeatureBitset ImpliedFeaturesRETPOLINE_INDIRECT_CALLS = {};
+constexpr FeatureBitset ImpliedFeaturesLVI_CFI = {};
+constexpr FeatureBitset ImpliedFeaturesLVI_LOAD_HARDENING = {};
// XSAVE features are dependent on basic XSAVE.
-constexpr FeatureBitset ImpliedFeaturesXSAVEC = FeatureXSAVE;
-constexpr FeatureBitset ImpliedFeaturesXSAVEOPT = FeatureXSAVE;
-constexpr FeatureBitset ImpliedFeaturesXSAVES = FeatureXSAVE;
+constexpr FeatureBitset ImpliedFeaturesXSAVEC = FeatureXSAVE;
+constexpr FeatureBitset ImpliedFeaturesXSAVEOPT = FeatureXSAVE;
+constexpr FeatureBitset ImpliedFeaturesXSAVES = FeatureXSAVE;
// MMX->3DNOW->3DNOWA chain.
-constexpr FeatureBitset ImpliedFeaturesMMX = {};
-constexpr FeatureBitset ImpliedFeatures3DNOW = FeatureMMX;
-constexpr FeatureBitset ImpliedFeatures3DNOWA = Feature3DNOW;
+constexpr FeatureBitset ImpliedFeaturesMMX = {};
+constexpr FeatureBitset ImpliedFeatures3DNOW = FeatureMMX;
+constexpr FeatureBitset ImpliedFeatures3DNOWA = Feature3DNOW;
// SSE/AVX/AVX512F chain.
-constexpr FeatureBitset ImpliedFeaturesSSE = {};
-constexpr FeatureBitset ImpliedFeaturesSSE2 = FeatureSSE;
-constexpr FeatureBitset ImpliedFeaturesSSE3 = FeatureSSE2;
-constexpr FeatureBitset ImpliedFeaturesSSSE3 = FeatureSSE3;
-constexpr FeatureBitset ImpliedFeaturesSSE4_1 = FeatureSSSE3;
-constexpr FeatureBitset ImpliedFeaturesSSE4_2 = FeatureSSE4_1;
-constexpr FeatureBitset ImpliedFeaturesAVX = FeatureSSE4_2;
-constexpr FeatureBitset ImpliedFeaturesAVX2 = FeatureAVX;
-constexpr FeatureBitset ImpliedFeaturesAVX512F =
+constexpr FeatureBitset ImpliedFeaturesSSE = {};
+constexpr FeatureBitset ImpliedFeaturesSSE2 = FeatureSSE;
+constexpr FeatureBitset ImpliedFeaturesSSE3 = FeatureSSE2;
+constexpr FeatureBitset ImpliedFeaturesSSSE3 = FeatureSSE3;
+constexpr FeatureBitset ImpliedFeaturesSSE4_1 = FeatureSSSE3;
+constexpr FeatureBitset ImpliedFeaturesSSE4_2 = FeatureSSE4_1;
+constexpr FeatureBitset ImpliedFeaturesAVX = FeatureSSE4_2;
+constexpr FeatureBitset ImpliedFeaturesAVX2 = FeatureAVX;
+constexpr FeatureBitset ImpliedFeaturesAVX512F =
FeatureAVX2 | FeatureF16C | FeatureFMA;
// Vector extensions that build on SSE or AVX.
-constexpr FeatureBitset ImpliedFeaturesAES = FeatureSSE2;
-constexpr FeatureBitset ImpliedFeaturesF16C = FeatureAVX;
-constexpr FeatureBitset ImpliedFeaturesFMA = FeatureAVX;
-constexpr FeatureBitset ImpliedFeaturesGFNI = FeatureSSE2;
-constexpr FeatureBitset ImpliedFeaturesPCLMUL = FeatureSSE2;
-constexpr FeatureBitset ImpliedFeaturesSHA = FeatureSSE2;
-constexpr FeatureBitset ImpliedFeaturesVAES = FeatureAES | FeatureAVX;
-constexpr FeatureBitset ImpliedFeaturesVPCLMULQDQ = FeatureAVX | FeaturePCLMUL;
+constexpr FeatureBitset ImpliedFeaturesAES = FeatureSSE2;
+constexpr FeatureBitset ImpliedFeaturesF16C = FeatureAVX;
+constexpr FeatureBitset ImpliedFeaturesFMA = FeatureAVX;
+constexpr FeatureBitset ImpliedFeaturesGFNI = FeatureSSE2;
+constexpr FeatureBitset ImpliedFeaturesPCLMUL = FeatureSSE2;
+constexpr FeatureBitset ImpliedFeaturesSHA = FeatureSSE2;
+constexpr FeatureBitset ImpliedFeaturesVAES = FeatureAES | FeatureAVX;
+constexpr FeatureBitset ImpliedFeaturesVPCLMULQDQ = FeatureAVX | FeaturePCLMUL;
// AVX512 features.
-constexpr FeatureBitset ImpliedFeaturesAVX512CD = FeatureAVX512F;
-constexpr FeatureBitset ImpliedFeaturesAVX512BW = FeatureAVX512F;
-constexpr FeatureBitset ImpliedFeaturesAVX512DQ = FeatureAVX512F;
-constexpr FeatureBitset ImpliedFeaturesAVX512ER = FeatureAVX512F;
-constexpr FeatureBitset ImpliedFeaturesAVX512PF = FeatureAVX512F;
-constexpr FeatureBitset ImpliedFeaturesAVX512VL = FeatureAVX512F;
-
-constexpr FeatureBitset ImpliedFeaturesAVX512BF16 = FeatureAVX512BW;
-constexpr FeatureBitset ImpliedFeaturesAVX512BITALG = FeatureAVX512BW;
-constexpr FeatureBitset ImpliedFeaturesAVX512IFMA = FeatureAVX512F;
-constexpr FeatureBitset ImpliedFeaturesAVX512VNNI = FeatureAVX512F;
-constexpr FeatureBitset ImpliedFeaturesAVX512VPOPCNTDQ = FeatureAVX512F;
-constexpr FeatureBitset ImpliedFeaturesAVX512VBMI = FeatureAVX512BW;
-constexpr FeatureBitset ImpliedFeaturesAVX512VBMI2 = FeatureAVX512BW;
-constexpr FeatureBitset ImpliedFeaturesAVX512VP2INTERSECT = FeatureAVX512F;
+constexpr FeatureBitset ImpliedFeaturesAVX512CD = FeatureAVX512F;
+constexpr FeatureBitset ImpliedFeaturesAVX512BW = FeatureAVX512F;
+constexpr FeatureBitset ImpliedFeaturesAVX512DQ = FeatureAVX512F;
+constexpr FeatureBitset ImpliedFeaturesAVX512ER = FeatureAVX512F;
+constexpr FeatureBitset ImpliedFeaturesAVX512PF = FeatureAVX512F;
+constexpr FeatureBitset ImpliedFeaturesAVX512VL = FeatureAVX512F;
+
+constexpr FeatureBitset ImpliedFeaturesAVX512BF16 = FeatureAVX512BW;
+constexpr FeatureBitset ImpliedFeaturesAVX512BITALG = FeatureAVX512BW;
+constexpr FeatureBitset ImpliedFeaturesAVX512IFMA = FeatureAVX512F;
+constexpr FeatureBitset ImpliedFeaturesAVX512VNNI = FeatureAVX512F;
+constexpr FeatureBitset ImpliedFeaturesAVX512VPOPCNTDQ = FeatureAVX512F;
+constexpr FeatureBitset ImpliedFeaturesAVX512VBMI = FeatureAVX512BW;
+constexpr FeatureBitset ImpliedFeaturesAVX512VBMI2 = FeatureAVX512BW;
+constexpr FeatureBitset ImpliedFeaturesAVX512VP2INTERSECT = FeatureAVX512F;
// FIXME: These two aren't really implemented and just exist in the feature
// list for __builtin_cpu_supports. So omit their dependencies.
-constexpr FeatureBitset ImpliedFeaturesAVX5124FMAPS = {};
-constexpr FeatureBitset ImpliedFeaturesAVX5124VNNIW = {};
+constexpr FeatureBitset ImpliedFeaturesAVX5124FMAPS = {};
+constexpr FeatureBitset ImpliedFeaturesAVX5124VNNIW = {};
// SSE4_A->FMA4->XOP chain.
-constexpr FeatureBitset ImpliedFeaturesSSE4_A = FeatureSSE3;
-constexpr FeatureBitset ImpliedFeaturesFMA4 = FeatureAVX | FeatureSSE4_A;
-constexpr FeatureBitset ImpliedFeaturesXOP = FeatureFMA4;
+constexpr FeatureBitset ImpliedFeaturesSSE4_A = FeatureSSE3;
+constexpr FeatureBitset ImpliedFeaturesFMA4 = FeatureAVX | FeatureSSE4_A;
+constexpr FeatureBitset ImpliedFeaturesXOP = FeatureFMA4;
// AMX Features
-constexpr FeatureBitset ImpliedFeaturesAMX_TILE = {};
-constexpr FeatureBitset ImpliedFeaturesAMX_BF16 = FeatureAMX_TILE;
-constexpr FeatureBitset ImpliedFeaturesAMX_INT8 = FeatureAMX_TILE;
-constexpr FeatureBitset ImpliedFeaturesHRESET = {};
-
-// Key Locker Features
-constexpr FeatureBitset ImpliedFeaturesKL = FeatureSSE2;
-constexpr FeatureBitset ImpliedFeaturesWIDEKL = FeatureKL;
-
-// AVXVNNI Features
-constexpr FeatureBitset ImpliedFeaturesAVXVNNI = FeatureAVX2;
-
-constexpr FeatureInfo FeatureInfos[X86::CPU_FEATURE_MAX] = {
+constexpr FeatureBitset ImpliedFeaturesAMX_TILE = {};
+constexpr FeatureBitset ImpliedFeaturesAMX_BF16 = FeatureAMX_TILE;
+constexpr FeatureBitset ImpliedFeaturesAMX_INT8 = FeatureAMX_TILE;
+constexpr FeatureBitset ImpliedFeaturesHRESET = {};
+
+// Key Locker Features
+constexpr FeatureBitset ImpliedFeaturesKL = FeatureSSE2;
+constexpr FeatureBitset ImpliedFeaturesWIDEKL = FeatureKL;
+
+// AVXVNNI Features
+constexpr FeatureBitset ImpliedFeaturesAVXVNNI = FeatureAVX2;
+
+constexpr FeatureInfo FeatureInfos[X86::CPU_FEATURE_MAX] = {
#define X86_FEATURE(ENUM, STR) {{STR}, ImpliedFeatures##ENUM},
#include "llvm/Support/X86TargetParser.def"
};
@@ -595,9 +595,9 @@ void llvm::X86::getFeaturesForCPU(StringRef CPU,
Bits &= ~Feature64BIT;
// Add the string version of all set bits.
- for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i)
- if (Bits[i] && !FeatureInfos[i].Name.empty())
- EnabledFeatures.push_back(FeatureInfos[i].Name);
+ for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i)
+ if (Bits[i] && !FeatureInfos[i].Name.empty())
+ EnabledFeatures.push_back(FeatureInfos[i].Name);
}
// For each feature that is (transitively) implied by this feature, set it.
@@ -631,9 +631,9 @@ static void getImpliedDisabledFeatures(FeatureBitset &Bits, unsigned Value) {
} while (Prev != Bits);
}
-void llvm::X86::updateImpliedFeatures(
+void llvm::X86::updateImpliedFeatures(
StringRef Feature, bool Enabled,
- StringMap<bool> &Features) {
+ StringMap<bool> &Features) {
auto I = llvm::find_if(
FeatureInfos, [&](const FeatureInfo &FI) { return FI.Name == Feature; });
if (I == std::end(FeatureInfos)) {
@@ -649,8 +649,8 @@ void llvm::X86::updateImpliedFeatures(
getImpliedDisabledFeatures(ImpliedBits,
std::distance(std::begin(FeatureInfos), I));
- // Update the map entry for all implied features.
- for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i)
- if (ImpliedBits[i] && !FeatureInfos[i].Name.empty())
- Features[FeatureInfos[i].Name] = Enabled;
+ // Update the map entry for all implied features.
+ for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i)
+ if (ImpliedBits[i] && !FeatureInfos[i].Name.empty())
+ Features[FeatureInfos[i].Name] = Enabled;
}
diff --git a/contrib/libs/llvm12/lib/Support/YAMLParser.cpp b/contrib/libs/llvm12/lib/Support/YAMLParser.cpp
index f68ba0d065..cddc30daf6 100644
--- a/contrib/libs/llvm12/lib/Support/YAMLParser.cpp
+++ b/contrib/libs/llvm12/lib/Support/YAMLParser.cpp
@@ -200,12 +200,12 @@ static UTF8Decoded decodeUTF8(StringRef Range) {
StringRef::iterator End = Range.end();
// 1 byte: [0x00, 0x7f]
// Bit pattern: 0xxxxxxx
- if (Position < End && (*Position & 0x80) == 0) {
- return std::make_pair(*Position, 1);
+ if (Position < End && (*Position & 0x80) == 0) {
+ return std::make_pair(*Position, 1);
}
// 2 bytes: [0x80, 0x7ff]
// Bit pattern: 110xxxxx 10xxxxxx
- if (Position + 1 < End && ((*Position & 0xE0) == 0xC0) &&
+ if (Position + 1 < End && ((*Position & 0xE0) == 0xC0) &&
((*(Position + 1) & 0xC0) == 0x80)) {
uint32_t codepoint = ((*Position & 0x1F) << 6) |
(*(Position + 1) & 0x3F);
@@ -214,7 +214,7 @@ static UTF8Decoded decodeUTF8(StringRef Range) {
}
// 3 bytes: [0x8000, 0xffff]
// Bit pattern: 1110xxxx 10xxxxxx 10xxxxxx
- if (Position + 2 < End && ((*Position & 0xF0) == 0xE0) &&
+ if (Position + 2 < End && ((*Position & 0xF0) == 0xE0) &&
((*(Position + 1) & 0xC0) == 0x80) &&
((*(Position + 2) & 0xC0) == 0x80)) {
uint32_t codepoint = ((*Position & 0x0F) << 12) |
@@ -228,7 +228,7 @@ static UTF8Decoded decodeUTF8(StringRef Range) {
}
// 4 bytes: [0x10000, 0x10FFFF]
// Bit pattern: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- if (Position + 3 < End && ((*Position & 0xF8) == 0xF0) &&
+ if (Position + 3 < End && ((*Position & 0xF8) == 0xF0) &&
((*(Position + 1) & 0xC0) == 0x80) &&
((*(Position + 2) & 0xC0) == 0x80) &&
((*(Position + 3) & 0xC0) == 0x80)) {
@@ -715,7 +715,7 @@ std::string yaml::escape(StringRef Input, bool EscapePrintable) {
// Found invalid char.
SmallString<4> Val;
encodeUTF8(0xFFFD, Val);
- llvm::append_range(EscapedInput, Val);
+ llvm::append_range(EscapedInput, Val);
// FIXME: Error reporting.
return EscapedInput;
}
@@ -746,92 +746,92 @@ std::string yaml::escape(StringRef Input, bool EscapePrintable) {
return EscapedInput;
}
-llvm::Optional<bool> yaml::parseBool(StringRef S) {
- switch (S.size()) {
- case 1:
- switch (S.front()) {
- case 'y':
- case 'Y':
- return true;
- case 'n':
- case 'N':
- return false;
- default:
- return None;
- }
- case 2:
- switch (S.front()) {
- case 'O':
- if (S[1] == 'N') // ON
- return true;
- LLVM_FALLTHROUGH;
- case 'o':
- if (S[1] == 'n') //[Oo]n
- return true;
- return None;
- case 'N':
- if (S[1] == 'O') // NO
- return false;
- LLVM_FALLTHROUGH;
- case 'n':
- if (S[1] == 'o') //[Nn]o
- return false;
- return None;
- default:
- return None;
- }
- case 3:
- switch (S.front()) {
- case 'O':
- if (S.drop_front() == "FF") // OFF
- return false;
- LLVM_FALLTHROUGH;
- case 'o':
- if (S.drop_front() == "ff") //[Oo]ff
- return false;
- return None;
- case 'Y':
- if (S.drop_front() == "ES") // YES
- return true;
- LLVM_FALLTHROUGH;
- case 'y':
- if (S.drop_front() == "es") //[Yy]es
- return true;
- return None;
- default:
- return None;
- }
- case 4:
- switch (S.front()) {
- case 'T':
- if (S.drop_front() == "RUE") // TRUE
- return true;
- LLVM_FALLTHROUGH;
- case 't':
- if (S.drop_front() == "rue") //[Tt]rue
- return true;
- return None;
- default:
- return None;
- }
- case 5:
- switch (S.front()) {
- case 'F':
- if (S.drop_front() == "ALSE") // FALSE
- return false;
- LLVM_FALLTHROUGH;
- case 'f':
- if (S.drop_front() == "alse") //[Ff]alse
- return false;
- return None;
- default:
- return None;
- }
- default:
- return None;
- }
-}
-
+llvm::Optional<bool> yaml::parseBool(StringRef S) {
+ switch (S.size()) {
+ case 1:
+ switch (S.front()) {
+ case 'y':
+ case 'Y':
+ return true;
+ case 'n':
+ case 'N':
+ return false;
+ default:
+ return None;
+ }
+ case 2:
+ switch (S.front()) {
+ case 'O':
+ if (S[1] == 'N') // ON
+ return true;
+ LLVM_FALLTHROUGH;
+ case 'o':
+ if (S[1] == 'n') //[Oo]n
+ return true;
+ return None;
+ case 'N':
+ if (S[1] == 'O') // NO
+ return false;
+ LLVM_FALLTHROUGH;
+ case 'n':
+ if (S[1] == 'o') //[Nn]o
+ return false;
+ return None;
+ default:
+ return None;
+ }
+ case 3:
+ switch (S.front()) {
+ case 'O':
+ if (S.drop_front() == "FF") // OFF
+ return false;
+ LLVM_FALLTHROUGH;
+ case 'o':
+ if (S.drop_front() == "ff") //[Oo]ff
+ return false;
+ return None;
+ case 'Y':
+ if (S.drop_front() == "ES") // YES
+ return true;
+ LLVM_FALLTHROUGH;
+ case 'y':
+ if (S.drop_front() == "es") //[Yy]es
+ return true;
+ return None;
+ default:
+ return None;
+ }
+ case 4:
+ switch (S.front()) {
+ case 'T':
+ if (S.drop_front() == "RUE") // TRUE
+ return true;
+ LLVM_FALLTHROUGH;
+ case 't':
+ if (S.drop_front() == "rue") //[Tt]rue
+ return true;
+ return None;
+ default:
+ return None;
+ }
+ case 5:
+ switch (S.front()) {
+ case 'F':
+ if (S.drop_front() == "ALSE") // FALSE
+ return false;
+ LLVM_FALLTHROUGH;
+ case 'f':
+ if (S.drop_front() == "alse") //[Ff]alse
+ return false;
+ return None;
+ default:
+ return None;
+ }
+ default:
+ return None;
+ }
+}
+
Scanner::Scanner(StringRef Input, SourceMgr &sm, bool ShowColors,
std::error_code *EC)
: SM(sm), ShowColors(ShowColors), EC(EC) {
@@ -856,7 +856,7 @@ void Scanner::init(MemoryBufferRef Buffer) {
IsSimpleKeyAllowed = true;
Failed = false;
std::unique_ptr<MemoryBuffer> InputBufferOwner =
- MemoryBuffer::getMemBuffer(Buffer, /*RequiresNullTerminator=*/false);
+ MemoryBuffer::getMemBuffer(Buffer, /*RequiresNullTerminator=*/false);
SM.AddNewSourceBuffer(std::move(InputBufferOwner), SMLoc());
}
@@ -981,9 +981,9 @@ void Scanner::advanceWhile(SkipWhileFunc Func) {
Current = Final;
}
-static bool is_ns_hex_digit(const char C) { return isAlnum(C); }
+static bool is_ns_hex_digit(const char C) { return isAlnum(C); }
-static bool is_ns_word_char(const char C) { return C == '-' || isAlpha(C); }
+static bool is_ns_word_char(const char C) { return C == '-' || isAlpha(C); }
void Scanner::scan_ns_uri_char() {
while (true) {
@@ -1111,7 +1111,7 @@ bool Scanner::rollIndent( int ToColumn
}
void Scanner::skipComment() {
- if (Current == End || *Current != '#')
+ if (Current == End || *Current != '#')
return;
while (true) {
// This may skip more than one byte, thus Column is only incremented
@@ -1126,7 +1126,7 @@ void Scanner::skipComment() {
void Scanner::scanToNextToken() {
while (true) {
- while (Current != End && (*Current == ' ' || *Current == '\t')) {
+ while (Current != End && (*Current == ' ' || *Current == '\t')) {
skip(1);
}
@@ -1361,7 +1361,7 @@ bool Scanner::scanFlowScalar(bool IsDoubleQuoted) {
&& wasEscaped(Start + 1, Current));
} else {
skip(1);
- while (Current != End) {
+ while (Current != End) {
// Skip a ' followed by another '.
if (Current + 1 < End && *Current == '\'' && *(Current + 1) == '\'') {
skip(2);
@@ -1409,14 +1409,14 @@ bool Scanner::scanPlainScalar() {
unsigned LeadingBlanks = 0;
assert(Indent >= -1 && "Indent must be >= -1 !");
unsigned indent = static_cast<unsigned>(Indent + 1);
- while (Current != End) {
+ while (Current != End) {
if (*Current == '#')
break;
- while (Current != End && !isBlankOrBreak(Current)) {
- if (FlowLevel && *Current == ':' &&
- (Current + 1 == End ||
- !(isBlankOrBreak(Current + 1) || *(Current + 1) == ','))) {
+ while (Current != End && !isBlankOrBreak(Current)) {
+ if (FlowLevel && *Current == ':' &&
+ (Current + 1 == End ||
+ !(isBlankOrBreak(Current + 1) || *(Current + 1) == ','))) {
setError("Found unexpected ':' while scanning a plain scalar", Current);
return false;
}
@@ -1486,7 +1486,7 @@ bool Scanner::scanAliasOrAnchor(bool IsAlias) {
StringRef::iterator Start = Current;
unsigned ColStart = Column;
skip(1);
- while (Current != End) {
+ while (Current != End) {
if ( *Current == '[' || *Current == ']'
|| *Current == '{' || *Current == '}'
|| *Current == ','
@@ -1499,7 +1499,7 @@ bool Scanner::scanAliasOrAnchor(bool IsAlias) {
++Column;
}
- if (Start + 1 == Current) {
+ if (Start + 1 == Current) {
setError("Got empty alias or anchor", Start);
return false;
}
@@ -1851,15 +1851,15 @@ Stream::~Stream() = default;
bool Stream::failed() { return scanner->failed(); }
-void Stream::printError(Node *N, const Twine &Msg, SourceMgr::DiagKind Kind) {
- printError(N ? N->getSourceRange() : SMRange(), Msg, Kind);
-}
-
-void Stream::printError(const SMRange &Range, const Twine &Msg,
- SourceMgr::DiagKind Kind) {
- scanner->printError(Range.Start, Kind, Msg, Range);
+void Stream::printError(Node *N, const Twine &Msg, SourceMgr::DiagKind Kind) {
+ printError(N ? N->getSourceRange() : SMRange(), Msg, Kind);
}
+void Stream::printError(const SMRange &Range, const Twine &Msg,
+ SourceMgr::DiagKind Kind) {
+ scanner->printError(Range.Start, Kind, Msg, Range);
+}
+
document_iterator Stream::begin() {
if (CurrentDoc)
report_fatal_error("Can only iterate over the stream once");
@@ -1976,11 +1976,11 @@ StringRef ScalarNode::getValue(SmallVectorImpl<char> &Storage) const {
Storage.reserve(UnquotedValue.size());
for (; i != StringRef::npos; i = UnquotedValue.find('\'')) {
StringRef Valid(UnquotedValue.begin(), i);
- llvm::append_range(Storage, Valid);
+ llvm::append_range(Storage, Valid);
Storage.push_back('\'');
UnquotedValue = UnquotedValue.substr(i + 2);
}
- llvm::append_range(Storage, UnquotedValue);
+ llvm::append_range(Storage, UnquotedValue);
return StringRef(Storage.begin(), Storage.size());
}
return UnquotedValue;
@@ -1999,7 +1999,7 @@ StringRef ScalarNode::unescapeDoubleQuoted( StringRef UnquotedValue
for (; i != StringRef::npos; i = UnquotedValue.find_first_of("\\\r\n")) {
// Insert all previous chars into Storage.
StringRef Valid(UnquotedValue.begin(), i);
- llvm::append_range(Storage, Valid);
+ llvm::append_range(Storage, Valid);
// Chop off inserted chars.
UnquotedValue = UnquotedValue.substr(i);
@@ -2131,7 +2131,7 @@ StringRef ScalarNode::unescapeDoubleQuoted( StringRef UnquotedValue
UnquotedValue = UnquotedValue.substr(1);
}
}
- llvm::append_range(Storage, UnquotedValue);
+ llvm::append_range(Storage, UnquotedValue);
return StringRef(Storage.begin(), Storage.size());
}
diff --git a/contrib/libs/llvm12/lib/Support/YAMLTraits.cpp b/contrib/libs/llvm12/lib/Support/YAMLTraits.cpp
index aa6163a761..a84e4f57d1 100644
--- a/contrib/libs/llvm12/lib/Support/YAMLTraits.cpp
+++ b/contrib/libs/llvm12/lib/Support/YAMLTraits.cpp
@@ -48,10 +48,10 @@ void IO::setContext(void *Context) {
Ctxt = Context;
}
-void IO::setAllowUnknownKeys(bool Allow) {
- llvm_unreachable("Only supported for Input");
-}
-
+void IO::setAllowUnknownKeys(bool Allow) {
+ llvm_unreachable("Only supported for Input");
+}
+
//===----------------------------------------------------------------------===//
// Input
//===----------------------------------------------------------------------===//
@@ -175,7 +175,7 @@ bool Input::preflightKey(const char *Key, bool Required, bool, bool &UseDefault,
return false;
}
MN->ValidKeys.push_back(Key);
- HNode *Value = MN->Mapping[Key].first.get();
+ HNode *Value = MN->Mapping[Key].first.get();
if (!Value) {
if (Required)
setError(CurrentNode, Twine("missing required key '") + Key + "'");
@@ -201,12 +201,12 @@ void Input::endMapping() {
return;
for (const auto &NN : MN->Mapping) {
if (!is_contained(MN->ValidKeys, NN.first())) {
- const SMRange &ReportLoc = NN.second.second;
- if (!AllowUnknownKeys) {
- setError(ReportLoc, Twine("unknown key '") + NN.first() + "'");
- break;
- } else
- reportWarning(ReportLoc, Twine("unknown key '") + NN.first() + "'");
+ const SMRange &ReportLoc = NN.second.second;
+ if (!AllowUnknownKeys) {
+ setError(ReportLoc, Twine("unknown key '") + NN.first() + "'");
+ break;
+ } else
+ reportWarning(ReportLoc, Twine("unknown key '") + NN.first() + "'");
}
}
}
@@ -378,24 +378,24 @@ void Input::setError(Node *node, const Twine &message) {
EC = make_error_code(errc::invalid_argument);
}
-void Input::setError(const SMRange &range, const Twine &message) {
- Strm->printError(range, message);
- EC = make_error_code(errc::invalid_argument);
-}
-
-void Input::reportWarning(HNode *hnode, const Twine &message) {
- assert(hnode && "HNode must not be NULL");
- Strm->printError(hnode->_node, message, SourceMgr::DK_Warning);
-}
-
-void Input::reportWarning(Node *node, const Twine &message) {
- Strm->printError(node, message, SourceMgr::DK_Warning);
-}
-
-void Input::reportWarning(const SMRange &range, const Twine &message) {
- Strm->printError(range, message, SourceMgr::DK_Warning);
-}
-
+void Input::setError(const SMRange &range, const Twine &message) {
+ Strm->printError(range, message);
+ EC = make_error_code(errc::invalid_argument);
+}
+
+void Input::reportWarning(HNode *hnode, const Twine &message) {
+ assert(hnode && "HNode must not be NULL");
+ Strm->printError(hnode->_node, message, SourceMgr::DK_Warning);
+}
+
+void Input::reportWarning(Node *node, const Twine &message) {
+ Strm->printError(node, message, SourceMgr::DK_Warning);
+}
+
+void Input::reportWarning(const SMRange &range, const Twine &message) {
+ Strm->printError(range, message, SourceMgr::DK_Warning);
+}
+
std::unique_ptr<Input::HNode> Input::createHNodes(Node *N) {
SmallString<128> StringStorage;
if (ScalarNode *SN = dyn_cast<ScalarNode>(N)) {
@@ -439,8 +439,8 @@ std::unique_ptr<Input::HNode> Input::createHNodes(Node *N) {
auto ValueHNode = createHNodes(Value);
if (EC)
break;
- mapHNode->Mapping[KeyStr] =
- std::make_pair(std::move(ValueHNode), KeyNode->getSourceRange());
+ mapHNode->Mapping[KeyStr] =
+ std::make_pair(std::move(ValueHNode), KeyNode->getSourceRange());
}
return std::move(mapHNode);
} else if (isa<NullNode>(N)) {
@@ -455,8 +455,8 @@ void Input::setError(const Twine &Message) {
setError(CurrentNode, Message);
}
-void Input::setAllowUnknownKeys(bool Allow) { AllowUnknownKeys = Allow; }
-
+void Input::setAllowUnknownKeys(bool Allow) { AllowUnknownKeys = Allow; }
+
bool Input::canElideEmptySequence() {
return false;
}
@@ -592,7 +592,7 @@ void Output::endSequence() {
// If we did not emit anything, we should explicitly emit an empty sequence
if (StateStack.back() == inSeqFirstElement) {
Padding = PaddingBeforeContainer;
- newLineCheck(/*EmptySequence=*/true);
+ newLineCheck(/*EmptySequence=*/true);
output("[]");
Padding = "\n";
}
@@ -798,7 +798,7 @@ void Output::outputNewLine() {
// if seq in middle, use "- " if firstKey, else use " "
//
-void Output::newLineCheck(bool EmptySequence) {
+void Output::newLineCheck(bool EmptySequence) {
if (Padding != "\n") {
output(Padding);
Padding = {};
@@ -807,7 +807,7 @@ void Output::newLineCheck(bool EmptySequence) {
outputNewLine();
Padding = {};
- if (StateStack.size() == 0 || EmptySequence)
+ if (StateStack.size() == 0 || EmptySequence)
return;
unsigned Indent = StateStack.size() - 1;
@@ -884,8 +884,8 @@ void ScalarTraits<bool>::output(const bool &Val, void *, raw_ostream &Out) {
}
StringRef ScalarTraits<bool>::input(StringRef Scalar, void *, bool &Val) {
- if (llvm::Optional<bool> Parsed = parseBool(Scalar)) {
- Val = *Parsed;
+ if (llvm::Optional<bool> Parsed = parseBool(Scalar)) {
+ Val = *Parsed;
return StringRef();
}
return "invalid boolean";
@@ -1056,7 +1056,7 @@ StringRef ScalarTraits<float>::input(StringRef Scalar, void *, float &Val) {
}
void ScalarTraits<Hex8>::output(const Hex8 &Val, void *, raw_ostream &Out) {
- Out << format("0x%" PRIX8, (uint8_t)Val);
+ Out << format("0x%" PRIX8, (uint8_t)Val);
}
StringRef ScalarTraits<Hex8>::input(StringRef Scalar, void *, Hex8 &Val) {
@@ -1070,7 +1070,7 @@ StringRef ScalarTraits<Hex8>::input(StringRef Scalar, void *, Hex8 &Val) {
}
void ScalarTraits<Hex16>::output(const Hex16 &Val, void *, raw_ostream &Out) {
- Out << format("0x%" PRIX16, (uint16_t)Val);
+ Out << format("0x%" PRIX16, (uint16_t)Val);
}
StringRef ScalarTraits<Hex16>::input(StringRef Scalar, void *, Hex16 &Val) {
@@ -1084,7 +1084,7 @@ StringRef ScalarTraits<Hex16>::input(StringRef Scalar, void *, Hex16 &Val) {
}
void ScalarTraits<Hex32>::output(const Hex32 &Val, void *, raw_ostream &Out) {
- Out << format("0x%" PRIX32, (uint32_t)Val);
+ Out << format("0x%" PRIX32, (uint32_t)Val);
}
StringRef ScalarTraits<Hex32>::input(StringRef Scalar, void *, Hex32 &Val) {
@@ -1098,7 +1098,7 @@ StringRef ScalarTraits<Hex32>::input(StringRef Scalar, void *, Hex32 &Val) {
}
void ScalarTraits<Hex64>::output(const Hex64 &Val, void *, raw_ostream &Out) {
- Out << format("0x%" PRIX64, (uint64_t)Val);
+ Out << format("0x%" PRIX64, (uint64_t)Val);
}
StringRef ScalarTraits<Hex64>::input(StringRef Scalar, void *, Hex64 &Val) {
@@ -1108,15 +1108,15 @@ StringRef ScalarTraits<Hex64>::input(StringRef Scalar, void *, Hex64 &Val) {
Val = Num;
return StringRef();
}
-
-void ScalarTraits<VersionTuple>::output(const VersionTuple &Val, void *,
- llvm::raw_ostream &Out) {
- Out << Val.getAsString();
-}
-
-StringRef ScalarTraits<VersionTuple>::input(StringRef Scalar, void *,
- VersionTuple &Val) {
- if (Val.tryParse(Scalar))
- return "invalid version format";
- return StringRef();
-}
+
+void ScalarTraits<VersionTuple>::output(const VersionTuple &Val, void *,
+ llvm::raw_ostream &Out) {
+ Out << Val.getAsString();
+}
+
+StringRef ScalarTraits<VersionTuple>::input(StringRef Scalar, void *,
+ VersionTuple &Val) {
+ if (Val.tryParse(Scalar))
+ return "invalid version format";
+ return StringRef();
+}
diff --git a/contrib/libs/llvm12/lib/Support/raw_ostream.cpp b/contrib/libs/llvm12/lib/Support/raw_ostream.cpp
index 8f10d136bc..343806afb5 100644
--- a/contrib/libs/llvm12/lib/Support/raw_ostream.cpp
+++ b/contrib/libs/llvm12/lib/Support/raw_ostream.cpp
@@ -618,9 +618,9 @@ raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
/// FD is the file descriptor that this writes to. If ShouldClose is true, this
/// closes the file when the stream is destroyed.
-raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered,
- OStreamKind K)
- : raw_pwrite_stream(unbuffered, K), FD(fd), ShouldClose(shouldClose) {
+raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered,
+ OStreamKind K)
+ : raw_pwrite_stream(unbuffered, K), FD(fd), ShouldClose(shouldClose) {
if (FD < 0 ) {
ShouldClose = false;
return;
@@ -857,26 +857,26 @@ bool raw_fd_ostream::is_displayed() const {
}
bool raw_fd_ostream::has_colors() const {
- if (!HasColors)
- HasColors = sys::Process::FileDescriptorHasColors(FD);
- return *HasColors;
-}
-
-Expected<sys::fs::FileLocker> raw_fd_ostream::lock() {
- std::error_code EC = sys::fs::lockFile(FD);
- if (!EC)
- return sys::fs::FileLocker(FD);
- return errorCodeToError(EC);
-}
-
-Expected<sys::fs::FileLocker>
-raw_fd_ostream::tryLockFor(std::chrono::milliseconds Timeout) {
- std::error_code EC = sys::fs::tryLockFile(FD, Timeout);
- if (!EC)
- return sys::fs::FileLocker(FD);
- return errorCodeToError(EC);
-}
-
+ if (!HasColors)
+ HasColors = sys::Process::FileDescriptorHasColors(FD);
+ return *HasColors;
+}
+
+Expected<sys::fs::FileLocker> raw_fd_ostream::lock() {
+ std::error_code EC = sys::fs::lockFile(FD);
+ if (!EC)
+ return sys::fs::FileLocker(FD);
+ return errorCodeToError(EC);
+}
+
+Expected<sys::fs::FileLocker>
+raw_fd_ostream::tryLockFor(std::chrono::milliseconds Timeout) {
+ std::error_code EC = sys::fs::tryLockFile(FD, Timeout);
+ if (!EC)
+ return sys::fs::FileLocker(FD);
+ return errorCodeToError(EC);
+}
+
void raw_fd_ostream::anchor() {}
//===----------------------------------------------------------------------===//
@@ -904,37 +904,37 @@ raw_ostream &llvm::nulls() {
}
//===----------------------------------------------------------------------===//
-// File Streams
-//===----------------------------------------------------------------------===//
-
-raw_fd_stream::raw_fd_stream(StringRef Filename, std::error_code &EC)
- : raw_fd_ostream(getFD(Filename, EC, sys::fs::CD_CreateAlways,
- sys::fs::FA_Write | sys::fs::FA_Read,
- sys::fs::OF_None),
- true, false, OStreamKind::OK_FDStream) {
- if (EC)
- return;
-
- // Do not support non-seekable files.
- if (!supportsSeeking())
- EC = std::make_error_code(std::errc::invalid_argument);
-}
-
-ssize_t raw_fd_stream::read(char *Ptr, size_t Size) {
- assert(get_fd() >= 0 && "File already closed.");
- ssize_t Ret = ::read(get_fd(), (void *)Ptr, Size);
- if (Ret >= 0)
- inc_pos(Ret);
- else
- error_detected(std::error_code(errno, std::generic_category()));
- return Ret;
-}
-
-bool raw_fd_stream::classof(const raw_ostream *OS) {
- return OS->get_kind() == OStreamKind::OK_FDStream;
-}
-
-//===----------------------------------------------------------------------===//
+// File Streams
+//===----------------------------------------------------------------------===//
+
+raw_fd_stream::raw_fd_stream(StringRef Filename, std::error_code &EC)
+ : raw_fd_ostream(getFD(Filename, EC, sys::fs::CD_CreateAlways,
+ sys::fs::FA_Write | sys::fs::FA_Read,
+ sys::fs::OF_None),
+ true, false, OStreamKind::OK_FDStream) {
+ if (EC)
+ return;
+
+ // Do not support non-seekable files.
+ if (!supportsSeeking())
+ EC = std::make_error_code(std::errc::invalid_argument);
+}
+
+ssize_t raw_fd_stream::read(char *Ptr, size_t Size) {
+ assert(get_fd() >= 0 && "File already closed.");
+ ssize_t Ret = ::read(get_fd(), (void *)Ptr, Size);
+ if (Ret >= 0)
+ inc_pos(Ret);
+ else
+ error_detected(std::error_code(errno, std::generic_category()));
+ return Ret;
+}
+
+bool raw_fd_stream::classof(const raw_ostream *OS) {
+ return OS->get_kind() == OStreamKind::OK_FDStream;
+}
+
+//===----------------------------------------------------------------------===//
// raw_string_ostream
//===----------------------------------------------------------------------===//
@@ -987,5 +987,5 @@ void raw_null_ostream::pwrite_impl(const char *Ptr, size_t Size,
void raw_pwrite_stream::anchor() {}
void buffer_ostream::anchor() {}
-
-void buffer_unique_ostream::anchor() {}
+
+void buffer_unique_ostream::anchor() {}
diff --git a/contrib/libs/llvm12/lib/Support/ya.make b/contrib/libs/llvm12/lib/Support/ya.make
index b3f49d0f2a..0a01d9dadd 100644
--- a/contrib/libs/llvm12/lib/Support/ya.make
+++ b/contrib/libs/llvm12/lib/Support/ya.make
@@ -21,8 +21,8 @@ LICENSE(
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
PEERDIR(
- contrib/libs/llvm12
- contrib/libs/llvm12/lib/Demangle
+ contrib/libs/llvm12
+ contrib/libs/llvm12/lib/Demangle
contrib/libs/zlib
)
@@ -38,7 +38,7 @@ SRCS(
AArch64TargetParser.cpp
ABIBreak.cpp
AMDGPUMetadata.cpp
- APFixedPoint.cpp
+ APFixedPoint.cpp
APFloat.cpp
APInt.cpp
APSInt.cpp
@@ -89,7 +89,7 @@ SRCS(
Hashing.cpp
Host.cpp
InitLLVM.cpp
- InstructionCost.cpp
+ InstructionCost.cpp
IntEqClasses.cpp
IntervalMap.cpp
ItaniumManglingCanonicalizer.cpp
@@ -106,7 +106,7 @@ SRCS(
MemAlloc.cpp
Memory.cpp
MemoryBuffer.cpp
- MemoryBufferRef.cpp
+ MemoryBufferRef.cpp
NativeFormatting.cpp
OptimizedStructLayout.cpp
Optional.cpp