diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/libs/llvm12/include/llvm/Support | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/llvm12/include/llvm/Support')
65 files changed, 2630 insertions, 2630 deletions
diff --git a/contrib/libs/llvm12/include/llvm/Support/AArch64TargetParser.def b/contrib/libs/llvm12/include/llvm/Support/AArch64TargetParser.def index cd4762a6ec..332fb555e8 100644 --- a/contrib/libs/llvm12/include/llvm/Support/AArch64TargetParser.def +++ b/contrib/libs/llvm12/include/llvm/Support/AArch64TargetParser.def @@ -51,21 +51,21 @@ AARCH64_ARCH("armv8.6-a", ARMV8_6A, "8.6-A", "v8.6a", AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD | AArch64::AEK_SM4 | AArch64::AEK_SHA3 | AArch64::AEK_BF16 | AArch64::AEK_SHA2 | AArch64::AEK_AES | AArch64::AEK_I8MM)) -AARCH64_ARCH("armv8.7-a", ARMV8_7A, "8.7-A", "v8.7a", - ARMBuildAttrs::CPUArch::v8_A, FK_CRYPTO_NEON_FP_ARMV8, - (AArch64::AEK_CRC | AArch64::AEK_FP | - AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE | - AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD | - AArch64::AEK_SM4 | AArch64::AEK_SHA3 | AArch64::AEK_BF16 | - AArch64::AEK_SHA2 | AArch64::AEK_AES | AArch64::AEK_I8MM)) -// For v8-R, we do not enable crypto and align with GCC that enables a more -// minimal set of optional architecture extensions. -AARCH64_ARCH("armv8-r", ARMV8R, "8-R", "v8r", - ARMBuildAttrs::CPUArch::v8_R, FK_CRYPTO_NEON_FP_ARMV8, - (AArch64::AEK_CRC | AArch64::AEK_RDM | AArch64::AEK_SSBS | - AArch64::AEK_DOTPROD | AArch64::AEK_FP | AArch64::AEK_SIMD | - AArch64::AEK_FP16 | AArch64::AEK_FP16FML | AArch64::AEK_RAS | - AArch64::AEK_RCPC | AArch64::AEK_SB)) +AARCH64_ARCH("armv8.7-a", ARMV8_7A, "8.7-A", "v8.7a", + ARMBuildAttrs::CPUArch::v8_A, FK_CRYPTO_NEON_FP_ARMV8, + (AArch64::AEK_CRC | AArch64::AEK_FP | + AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE | + AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD | + AArch64::AEK_SM4 | AArch64::AEK_SHA3 | AArch64::AEK_BF16 | + AArch64::AEK_SHA2 | AArch64::AEK_AES | AArch64::AEK_I8MM)) +// For v8-R, we do not enable crypto and align with GCC that enables a more +// minimal set of optional architecture extensions. +AARCH64_ARCH("armv8-r", ARMV8R, "8-R", "v8r", + ARMBuildAttrs::CPUArch::v8_R, FK_CRYPTO_NEON_FP_ARMV8, + (AArch64::AEK_CRC | AArch64::AEK_RDM | AArch64::AEK_SSBS | + AArch64::AEK_DOTPROD | AArch64::AEK_FP | AArch64::AEK_SIMD | + AArch64::AEK_FP16 | AArch64::AEK_FP16FML | AArch64::AEK_RAS | + AArch64::AEK_RCPC | AArch64::AEK_SB)) #undef AARCH64_ARCH #ifndef AARCH64_ARCH_EXT_NAME @@ -106,10 +106,10 @@ AARCH64_ARCH_EXT_NAME("i8mm", AArch64::AEK_I8MM, "+i8mm", "-i8mm AARCH64_ARCH_EXT_NAME("f32mm", AArch64::AEK_F32MM, "+f32mm", "-f32mm") AARCH64_ARCH_EXT_NAME("f64mm", AArch64::AEK_F64MM, "+f64mm", "-f64mm") AARCH64_ARCH_EXT_NAME("tme", AArch64::AEK_TME, "+tme", "-tme") -AARCH64_ARCH_EXT_NAME("ls64", AArch64::AEK_LS64, "+ls64", "-ls64") -AARCH64_ARCH_EXT_NAME("brbe", AArch64::AEK_BRBE, "+brbe", "-brbe") -AARCH64_ARCH_EXT_NAME("pauth", AArch64::AEK_PAUTH, "+pauth", "-pauth") -AARCH64_ARCH_EXT_NAME("flagm", AArch64::AEK_FLAGM, "+flagm", "-flagm") +AARCH64_ARCH_EXT_NAME("ls64", AArch64::AEK_LS64, "+ls64", "-ls64") +AARCH64_ARCH_EXT_NAME("brbe", AArch64::AEK_BRBE, "+brbe", "-brbe") +AARCH64_ARCH_EXT_NAME("pauth", AArch64::AEK_PAUTH, "+pauth", "-pauth") +AARCH64_ARCH_EXT_NAME("flagm", AArch64::AEK_FLAGM, "+flagm", "-flagm") #undef AARCH64_ARCH_EXT_NAME #ifndef AARCH64_CPU_NAME @@ -149,11 +149,11 @@ AARCH64_CPU_NAME("cortex-a77", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, AARCH64_CPU_NAME("cortex-a78", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, (AArch64::AEK_FP16 | AArch64::AEK_DOTPROD | AArch64::AEK_RCPC | AArch64::AEK_SSBS)) -AARCH64_CPU_NAME("cortex-a78c", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, - (AArch64::AEK_FP16 | AArch64::AEK_DOTPROD | AArch64::AEK_RCPC | - AArch64::AEK_SSBS)) -AARCH64_CPU_NAME("cortex-r82", ARMV8R, FK_CRYPTO_NEON_FP_ARMV8, false, - (AArch64::AEK_LSE)) +AARCH64_CPU_NAME("cortex-a78c", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, + (AArch64::AEK_FP16 | AArch64::AEK_DOTPROD | AArch64::AEK_RCPC | + AArch64::AEK_SSBS)) +AARCH64_CPU_NAME("cortex-r82", ARMV8R, FK_CRYPTO_NEON_FP_ARMV8, false, + (AArch64::AEK_LSE)) AARCH64_CPU_NAME("cortex-x1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, (AArch64::AEK_FP16 | AArch64::AEK_DOTPROD | AArch64::AEK_RCPC | AArch64::AEK_SSBS)) @@ -164,15 +164,15 @@ AARCH64_CPU_NAME("neoverse-n1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, (AArch64::AEK_DOTPROD | AArch64::AEK_FP16 | AArch64::AEK_PROFILE | AArch64::AEK_RAS | AArch64::AEK_RCPC | AArch64::AEK_SSBS)) -AARCH64_CPU_NAME("neoverse-n2", ARMV8_5A, FK_CRYPTO_NEON_FP_ARMV8, false, - (AArch64::AEK_BF16 | AArch64::AEK_DOTPROD | AArch64::AEK_FP16 | - AArch64::AEK_I8MM | AArch64::AEK_MTE | AArch64::AEK_RAS | - AArch64::AEK_RCPC | AArch64::AEK_SB | AArch64::AEK_SSBS | - AArch64::AEK_SVE | AArch64::AEK_SVE2 | AArch64::AEK_SVE2BITPERM)) -AARCH64_CPU_NAME("neoverse-v1", ARMV8_4A, FK_CRYPTO_NEON_FP_ARMV8, false, - (AArch64::AEK_RAS | AArch64::AEK_SVE | AArch64::AEK_SSBS | - AArch64::AEK_RCPC | AArch64::AEK_FP16 | AArch64::AEK_BF16 | - AArch64::AEK_DOTPROD )) +AARCH64_CPU_NAME("neoverse-n2", ARMV8_5A, FK_CRYPTO_NEON_FP_ARMV8, false, + (AArch64::AEK_BF16 | AArch64::AEK_DOTPROD | AArch64::AEK_FP16 | + AArch64::AEK_I8MM | AArch64::AEK_MTE | AArch64::AEK_RAS | + AArch64::AEK_RCPC | AArch64::AEK_SB | AArch64::AEK_SSBS | + AArch64::AEK_SVE | AArch64::AEK_SVE2 | AArch64::AEK_SVE2BITPERM)) +AARCH64_CPU_NAME("neoverse-v1", ARMV8_4A, FK_CRYPTO_NEON_FP_ARMV8, false, + (AArch64::AEK_RAS | AArch64::AEK_SVE | AArch64::AEK_SSBS | + AArch64::AEK_RCPC | AArch64::AEK_FP16 | AArch64::AEK_BF16 | + AArch64::AEK_DOTPROD )) AARCH64_CPU_NAME("cyclone", ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, (AArch64::AEK_NONE)) AARCH64_CPU_NAME("apple-a7", ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, @@ -189,8 +189,8 @@ AARCH64_CPU_NAME("apple-a12", ARMV8_3A, FK_CRYPTO_NEON_FP_ARMV8, false, (AArch64::AEK_FP16)) AARCH64_CPU_NAME("apple-a13", ARMV8_4A, FK_CRYPTO_NEON_FP_ARMV8, false, (AArch64::AEK_FP16 | AArch64::AEK_FP16FML)) -AARCH64_CPU_NAME("apple-a14", ARMV8_5A, FK_CRYPTO_NEON_FP_ARMV8, false, - (AArch64::AEK_FP16 | AArch64::AEK_FP16FML)) +AARCH64_CPU_NAME("apple-a14", ARMV8_5A, FK_CRYPTO_NEON_FP_ARMV8, false, + (AArch64::AEK_FP16 | AArch64::AEK_FP16FML)) AARCH64_CPU_NAME("apple-s4", ARMV8_3A, FK_CRYPTO_NEON_FP_ARMV8, false, (AArch64::AEK_FP16)) AARCH64_CPU_NAME("apple-s5", ARMV8_3A, FK_CRYPTO_NEON_FP_ARMV8, false, diff --git a/contrib/libs/llvm12/include/llvm/Support/AArch64TargetParser.h b/contrib/libs/llvm12/include/llvm/Support/AArch64TargetParser.h index a879cbc60b..3c8ae8b7b8 100644 --- a/contrib/libs/llvm12/include/llvm/Support/AArch64TargetParser.h +++ b/contrib/libs/llvm12/include/llvm/Support/AArch64TargetParser.h @@ -69,10 +69,10 @@ enum ArchExtKind : uint64_t { AEK_I8MM = 1 << 30, AEK_F32MM = 1ULL << 31, AEK_F64MM = 1ULL << 32, - AEK_LS64 = 1ULL << 33, - AEK_BRBE = 1ULL << 34, - AEK_PAUTH = 1ULL << 35, - AEK_FLAGM = 1ULL << 36, + AEK_LS64 = 1ULL << 33, + AEK_BRBE = 1ULL << 34, + AEK_PAUTH = 1ULL << 35, + AEK_FLAGM = 1ULL << 36, }; enum class ArchKind { @@ -115,7 +115,7 @@ const ArchKind ArchKinds[] = { }; // FIXME: These should be moved to TargetTuple once it exists -bool getExtensionFeatures(uint64_t Extensions, +bool getExtensionFeatures(uint64_t Extensions, std::vector<StringRef> &Features); bool getArchFeatures(ArchKind AK, std::vector<StringRef> &Features); @@ -128,7 +128,7 @@ StringRef getArchExtFeature(StringRef ArchExt); // Information by Name unsigned getDefaultFPU(StringRef CPU, ArchKind AK); -uint64_t getDefaultExtensions(StringRef CPU, ArchKind AK); +uint64_t getDefaultExtensions(StringRef CPU, ArchKind AK); StringRef getDefaultCPU(StringRef Arch); ArchKind getCPUArchKind(StringRef CPU); diff --git a/contrib/libs/llvm12/include/llvm/Support/AMDGPUMetadata.h b/contrib/libs/llvm12/include/llvm/Support/AMDGPUMetadata.h index a123dd4a3c..a52236cf0e 100644 --- a/contrib/libs/llvm12/include/llvm/Support/AMDGPUMetadata.h +++ b/contrib/libs/llvm12/include/llvm/Support/AMDGPUMetadata.h @@ -22,7 +22,7 @@ #ifndef LLVM_SUPPORT_AMDGPUMETADATA_H #define LLVM_SUPPORT_AMDGPUMETADATA_H -#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/StringRef.h" #include <cstdint> #include <string> #include <system_error> @@ -438,7 +438,7 @@ struct Metadata final { }; /// Converts \p String to \p HSAMetadata. -std::error_code fromString(StringRef String, Metadata &HSAMetadata); +std::error_code fromString(StringRef String, Metadata &HSAMetadata); /// Converts \p HSAMetadata to \p String. std::error_code toString(Metadata HSAMetadata, std::string &String); diff --git a/contrib/libs/llvm12/include/llvm/Support/AMDHSAKernelDescriptor.h b/contrib/libs/llvm12/include/llvm/Support/AMDHSAKernelDescriptor.h index 135b06500f..8e1a6f688b 100644 --- a/contrib/libs/llvm12/include/llvm/Support/AMDHSAKernelDescriptor.h +++ b/contrib/libs/llvm12/include/llvm/Support/AMDHSAKernelDescriptor.h @@ -107,7 +107,7 @@ enum : int32_t { #define COMPUTE_PGM_RSRC2(NAME, SHIFT, WIDTH) \ AMDHSA_BITS_ENUM_ENTRY(COMPUTE_PGM_RSRC2_ ## NAME, SHIFT, WIDTH) enum : int32_t { - COMPUTE_PGM_RSRC2(ENABLE_PRIVATE_SEGMENT, 0, 1), + COMPUTE_PGM_RSRC2(ENABLE_PRIVATE_SEGMENT, 0, 1), COMPUTE_PGM_RSRC2(USER_SGPR_COUNT, 1, 5), COMPUTE_PGM_RSRC2(ENABLE_TRAP_HANDLER, 6, 1), COMPUTE_PGM_RSRC2(ENABLE_SGPR_WORKGROUP_ID_X, 7, 1), @@ -169,49 +169,49 @@ struct kernel_descriptor_t { uint8_t reserved2[6]; }; -enum : uint32_t { - GROUP_SEGMENT_FIXED_SIZE_OFFSET = 0, - PRIVATE_SEGMENT_FIXED_SIZE_OFFSET = 4, - RESERVED0_OFFSET = 8, - KERNEL_CODE_ENTRY_BYTE_OFFSET_OFFSET = 16, - RESERVED1_OFFSET = 24, - COMPUTE_PGM_RSRC3_OFFSET = 44, - COMPUTE_PGM_RSRC1_OFFSET = 48, - COMPUTE_PGM_RSRC2_OFFSET = 52, - KERNEL_CODE_PROPERTIES_OFFSET = 56, - RESERVED2_OFFSET = 58, -}; - +enum : uint32_t { + GROUP_SEGMENT_FIXED_SIZE_OFFSET = 0, + PRIVATE_SEGMENT_FIXED_SIZE_OFFSET = 4, + RESERVED0_OFFSET = 8, + KERNEL_CODE_ENTRY_BYTE_OFFSET_OFFSET = 16, + RESERVED1_OFFSET = 24, + COMPUTE_PGM_RSRC3_OFFSET = 44, + COMPUTE_PGM_RSRC1_OFFSET = 48, + COMPUTE_PGM_RSRC2_OFFSET = 52, + KERNEL_CODE_PROPERTIES_OFFSET = 56, + RESERVED2_OFFSET = 58, +}; + static_assert( sizeof(kernel_descriptor_t) == 64, "invalid size for kernel_descriptor_t"); -static_assert(offsetof(kernel_descriptor_t, group_segment_fixed_size) == - GROUP_SEGMENT_FIXED_SIZE_OFFSET, - "invalid offset for group_segment_fixed_size"); -static_assert(offsetof(kernel_descriptor_t, private_segment_fixed_size) == - PRIVATE_SEGMENT_FIXED_SIZE_OFFSET, - "invalid offset for private_segment_fixed_size"); -static_assert(offsetof(kernel_descriptor_t, reserved0) == RESERVED0_OFFSET, - "invalid offset for reserved0"); -static_assert(offsetof(kernel_descriptor_t, kernel_code_entry_byte_offset) == - KERNEL_CODE_ENTRY_BYTE_OFFSET_OFFSET, - "invalid offset for kernel_code_entry_byte_offset"); -static_assert(offsetof(kernel_descriptor_t, reserved1) == RESERVED1_OFFSET, - "invalid offset for reserved1"); -static_assert(offsetof(kernel_descriptor_t, compute_pgm_rsrc3) == - COMPUTE_PGM_RSRC3_OFFSET, - "invalid offset for compute_pgm_rsrc3"); -static_assert(offsetof(kernel_descriptor_t, compute_pgm_rsrc1) == - COMPUTE_PGM_RSRC1_OFFSET, - "invalid offset for compute_pgm_rsrc1"); -static_assert(offsetof(kernel_descriptor_t, compute_pgm_rsrc2) == - COMPUTE_PGM_RSRC2_OFFSET, - "invalid offset for compute_pgm_rsrc2"); -static_assert(offsetof(kernel_descriptor_t, kernel_code_properties) == - KERNEL_CODE_PROPERTIES_OFFSET, - "invalid offset for kernel_code_properties"); -static_assert(offsetof(kernel_descriptor_t, reserved2) == RESERVED2_OFFSET, - "invalid offset for reserved2"); +static_assert(offsetof(kernel_descriptor_t, group_segment_fixed_size) == + GROUP_SEGMENT_FIXED_SIZE_OFFSET, + "invalid offset for group_segment_fixed_size"); +static_assert(offsetof(kernel_descriptor_t, private_segment_fixed_size) == + PRIVATE_SEGMENT_FIXED_SIZE_OFFSET, + "invalid offset for private_segment_fixed_size"); +static_assert(offsetof(kernel_descriptor_t, reserved0) == RESERVED0_OFFSET, + "invalid offset for reserved0"); +static_assert(offsetof(kernel_descriptor_t, kernel_code_entry_byte_offset) == + KERNEL_CODE_ENTRY_BYTE_OFFSET_OFFSET, + "invalid offset for kernel_code_entry_byte_offset"); +static_assert(offsetof(kernel_descriptor_t, reserved1) == RESERVED1_OFFSET, + "invalid offset for reserved1"); +static_assert(offsetof(kernel_descriptor_t, compute_pgm_rsrc3) == + COMPUTE_PGM_RSRC3_OFFSET, + "invalid offset for compute_pgm_rsrc3"); +static_assert(offsetof(kernel_descriptor_t, compute_pgm_rsrc1) == + COMPUTE_PGM_RSRC1_OFFSET, + "invalid offset for compute_pgm_rsrc1"); +static_assert(offsetof(kernel_descriptor_t, compute_pgm_rsrc2) == + COMPUTE_PGM_RSRC2_OFFSET, + "invalid offset for compute_pgm_rsrc2"); +static_assert(offsetof(kernel_descriptor_t, kernel_code_properties) == + KERNEL_CODE_PROPERTIES_OFFSET, + "invalid offset for kernel_code_properties"); +static_assert(offsetof(kernel_descriptor_t, reserved2) == RESERVED2_OFFSET, + "invalid offset for reserved2"); } // end namespace amdhsa } // end namespace llvm diff --git a/contrib/libs/llvm12/include/llvm/Support/ARMTargetParser.def b/contrib/libs/llvm12/include/llvm/Support/ARMTargetParser.def index 5baa4b67d2..37cf0a93bb 100644 --- a/contrib/libs/llvm12/include/llvm/Support/ARMTargetParser.def +++ b/contrib/libs/llvm12/include/llvm/Support/ARMTargetParser.def @@ -118,12 +118,12 @@ ARM_ARCH("armv8.6-a", ARMV8_6A, "8.6-A", "v8.6a", ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS | ARM::AEK_DOTPROD | ARM::AEK_BF16 | ARM::AEK_SHA2 | ARM::AEK_AES | ARM::AEK_I8MM)) -ARM_ARCH("armv8.7-a", ARMV8_7A, "8.7-A", "v8.7a", - ARMBuildAttrs::CPUArch::v8_A, FK_CRYPTO_NEON_FP_ARMV8, - (ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM | - ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS | - ARM::AEK_DOTPROD | ARM::AEK_BF16 | ARM::AEK_SHA2 | ARM::AEK_AES | - ARM::AEK_I8MM)) +ARM_ARCH("armv8.7-a", ARMV8_7A, "8.7-A", "v8.7a", + ARMBuildAttrs::CPUArch::v8_A, FK_CRYPTO_NEON_FP_ARMV8, + (ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM | + ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS | + ARM::AEK_DOTPROD | ARM::AEK_BF16 | ARM::AEK_SHA2 | ARM::AEK_AES | + ARM::AEK_I8MM)) ARM_ARCH("armv8-r", ARMV8R, "8-R", "v8r", ARMBuildAttrs::CPUArch::v8_R, FK_NEON_FP_ARMV8, (ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | @@ -300,19 +300,19 @@ ARM_CPU_NAME("cortex-a76ae", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, (ARM::AEK_FP16 | ARM::AEK_DOTPROD)) ARM_CPU_NAME("cortex-a77", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, (ARM::AEK_FP16 | ARM::AEK_DOTPROD)) -ARM_CPU_NAME("cortex-a78", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, +ARM_CPU_NAME("cortex-a78", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, (ARM::AEK_FP16 | ARM::AEK_DOTPROD)) -ARM_CPU_NAME("cortex-a78c", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, - ARM::AEK_FP16 | ARM::AEK_DOTPROD) +ARM_CPU_NAME("cortex-a78c", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, + ARM::AEK_FP16 | ARM::AEK_DOTPROD) ARM_CPU_NAME("cortex-x1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, (ARM::AEK_FP16 | ARM::AEK_DOTPROD)) ARM_CPU_NAME("neoverse-n1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, (ARM::AEK_FP16 | ARM::AEK_DOTPROD)) -ARM_CPU_NAME("neoverse-n2", ARMV8_5A, FK_CRYPTO_NEON_FP_ARMV8, false, - (ARM::AEK_BF16 | ARM::AEK_DOTPROD | ARM::AEK_I8MM | ARM::AEK_RAS | - ARM::AEK_SB)) -ARM_CPU_NAME("neoverse-v1", ARMV8_4A, FK_CRYPTO_NEON_FP_ARMV8, false, - (ARM::AEK_RAS | ARM::AEK_FP16 | ARM::AEK_BF16 | ARM::AEK_DOTPROD)) +ARM_CPU_NAME("neoverse-n2", ARMV8_5A, FK_CRYPTO_NEON_FP_ARMV8, false, + (ARM::AEK_BF16 | ARM::AEK_DOTPROD | ARM::AEK_I8MM | ARM::AEK_RAS | + ARM::AEK_SB)) +ARM_CPU_NAME("neoverse-v1", ARMV8_4A, FK_CRYPTO_NEON_FP_ARMV8, false, + (ARM::AEK_RAS | ARM::AEK_FP16 | ARM::AEK_BF16 | ARM::AEK_DOTPROD)) ARM_CPU_NAME("cyclone", ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC) ARM_CPU_NAME("exynos-m3", ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC) ARM_CPU_NAME("exynos-m4", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, diff --git a/contrib/libs/llvm12/include/llvm/Support/ARMTargetParser.h b/contrib/libs/llvm12/include/llvm/Support/ARMTargetParser.h index 5dda0d9d1d..901baebefa 100644 --- a/contrib/libs/llvm12/include/llvm/Support/ARMTargetParser.h +++ b/contrib/libs/llvm12/include/llvm/Support/ARMTargetParser.h @@ -257,8 +257,8 @@ StringRef getSubArch(ArchKind AK); StringRef getArchExtName(uint64_t ArchExtKind); StringRef getArchExtFeature(StringRef ArchExt); bool appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK, StringRef ArchExt, - std::vector<StringRef> &Features, - unsigned &ArgFPUKind); + std::vector<StringRef> &Features, + unsigned &ArgFPUKind); StringRef getHWDivName(uint64_t HWDivKind); // Information by Name diff --git a/contrib/libs/llvm12/include/llvm/Support/ARMWinEH.h b/contrib/libs/llvm12/include/llvm/Support/ARMWinEH.h index 4e0aa79565..c35d136f2a 100644 --- a/contrib/libs/llvm12/include/llvm/Support/ARMWinEH.h +++ b/contrib/libs/llvm12/include/llvm/Support/ARMWinEH.h @@ -38,9 +38,9 @@ enum class ReturnType { /// RuntimeFunction - An entry in the table of procedure data (.pdata) /// -/// This is ARM specific, but the Function Start RVA, Flag and -/// ExceptionInformationRVA fields work identically for ARM64. -/// +/// This is ARM specific, but the Function Start RVA, Flag and +/// ExceptionInformationRVA fields work identically for ARM64. +/// /// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 /// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 /// +---------------------------------------------------------------+ @@ -214,85 +214,85 @@ inline uint16_t StackAdjustment(const RuntimeFunction &RF) { /// purpose (r0-r15) and VFP (d0-d31) registers. std::pair<uint16_t, uint32_t> SavedRegisterMask(const RuntimeFunction &RF); -/// RuntimeFunctionARM64 - An entry in the table of procedure data (.pdata) -/// -/// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 -/// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 -/// +---------------------------------------------------------------+ -/// | Function Start RVA | -/// +-----------------+---+-+-------+-----+---------------------+---+ -/// | Frame Size |CR |H| RegI |RegF | Function Length |Flg| -/// +-----------------+---+-+-------+-----+---------------------+---+ -/// -/// See https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling -/// for the full reference for this struct. - -class RuntimeFunctionARM64 { -public: - const support::ulittle32_t BeginAddress; - const support::ulittle32_t UnwindData; - - RuntimeFunctionARM64(const support::ulittle32_t *Data) - : BeginAddress(Data[0]), UnwindData(Data[1]) {} - - RuntimeFunctionARM64(const support::ulittle32_t BeginAddress, - const support::ulittle32_t UnwindData) - : BeginAddress(BeginAddress), UnwindData(UnwindData) {} - - RuntimeFunctionFlag Flag() const { - return RuntimeFunctionFlag(UnwindData & 0x3); - } - - uint32_t ExceptionInformationRVA() const { - assert(Flag() == RuntimeFunctionFlag::RFF_Unpacked && - "unpacked form required for this operation"); - return (UnwindData & ~0x3); - } - - uint32_t PackedUnwindData() const { - assert((Flag() == RuntimeFunctionFlag::RFF_Packed || - Flag() == RuntimeFunctionFlag::RFF_PackedFragment) && - "packed form required for this operation"); - return (UnwindData & ~0x3); - } - uint32_t FunctionLength() const { - assert((Flag() == RuntimeFunctionFlag::RFF_Packed || - Flag() == RuntimeFunctionFlag::RFF_PackedFragment) && - "packed form required for this operation"); - return (((UnwindData & 0x00001ffc) >> 2) << 2); - } - uint8_t RegF() const { - assert((Flag() == RuntimeFunctionFlag::RFF_Packed || - Flag() == RuntimeFunctionFlag::RFF_PackedFragment) && - "packed form required for this operation"); - return ((UnwindData & 0x0000e000) >> 13); - } - uint8_t RegI() const { - assert((Flag() == RuntimeFunctionFlag::RFF_Packed || - Flag() == RuntimeFunctionFlag::RFF_PackedFragment) && - "packed form required for this operation"); - return ((UnwindData & 0x000f0000) >> 16); - } - bool H() const { - assert((Flag() == RuntimeFunctionFlag::RFF_Packed || - Flag() == RuntimeFunctionFlag::RFF_PackedFragment) && - "packed form required for this operation"); - return ((UnwindData & 0x00100000) >> 20); - } - uint8_t CR() const { - assert((Flag() == RuntimeFunctionFlag::RFF_Packed || - Flag() == RuntimeFunctionFlag::RFF_PackedFragment) && - "packed form required for this operation"); - return ((UnwindData & 0x600000) >> 21); - } - uint16_t FrameSize() const { - assert((Flag() == RuntimeFunctionFlag::RFF_Packed || - Flag() == RuntimeFunctionFlag::RFF_PackedFragment) && - "packed form required for this operation"); - return ((UnwindData & 0xff800000) >> 23); - } -}; - +/// RuntimeFunctionARM64 - An entry in the table of procedure data (.pdata) +/// +/// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 +/// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +/// +---------------------------------------------------------------+ +/// | Function Start RVA | +/// +-----------------+---+-+-------+-----+---------------------+---+ +/// | Frame Size |CR |H| RegI |RegF | Function Length |Flg| +/// +-----------------+---+-+-------+-----+---------------------+---+ +/// +/// See https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling +/// for the full reference for this struct. + +class RuntimeFunctionARM64 { +public: + const support::ulittle32_t BeginAddress; + const support::ulittle32_t UnwindData; + + RuntimeFunctionARM64(const support::ulittle32_t *Data) + : BeginAddress(Data[0]), UnwindData(Data[1]) {} + + RuntimeFunctionARM64(const support::ulittle32_t BeginAddress, + const support::ulittle32_t UnwindData) + : BeginAddress(BeginAddress), UnwindData(UnwindData) {} + + RuntimeFunctionFlag Flag() const { + return RuntimeFunctionFlag(UnwindData & 0x3); + } + + uint32_t ExceptionInformationRVA() const { + assert(Flag() == RuntimeFunctionFlag::RFF_Unpacked && + "unpacked form required for this operation"); + return (UnwindData & ~0x3); + } + + uint32_t PackedUnwindData() const { + assert((Flag() == RuntimeFunctionFlag::RFF_Packed || + Flag() == RuntimeFunctionFlag::RFF_PackedFragment) && + "packed form required for this operation"); + return (UnwindData & ~0x3); + } + uint32_t FunctionLength() const { + assert((Flag() == RuntimeFunctionFlag::RFF_Packed || + Flag() == RuntimeFunctionFlag::RFF_PackedFragment) && + "packed form required for this operation"); + return (((UnwindData & 0x00001ffc) >> 2) << 2); + } + uint8_t RegF() const { + assert((Flag() == RuntimeFunctionFlag::RFF_Packed || + Flag() == RuntimeFunctionFlag::RFF_PackedFragment) && + "packed form required for this operation"); + return ((UnwindData & 0x0000e000) >> 13); + } + uint8_t RegI() const { + assert((Flag() == RuntimeFunctionFlag::RFF_Packed || + Flag() == RuntimeFunctionFlag::RFF_PackedFragment) && + "packed form required for this operation"); + return ((UnwindData & 0x000f0000) >> 16); + } + bool H() const { + assert((Flag() == RuntimeFunctionFlag::RFF_Packed || + Flag() == RuntimeFunctionFlag::RFF_PackedFragment) && + "packed form required for this operation"); + return ((UnwindData & 0x00100000) >> 20); + } + uint8_t CR() const { + assert((Flag() == RuntimeFunctionFlag::RFF_Packed || + Flag() == RuntimeFunctionFlag::RFF_PackedFragment) && + "packed form required for this operation"); + return ((UnwindData & 0x600000) >> 21); + } + uint16_t FrameSize() const { + assert((Flag() == RuntimeFunctionFlag::RFF_Packed || + Flag() == RuntimeFunctionFlag::RFF_PackedFragment) && + "packed form required for this operation"); + return ((UnwindData & 0xff800000) >> 23); + } +}; + /// ExceptionDataRecord - An entry in the table of exception data (.xdata) /// /// The format on ARM is: @@ -505,13 +505,13 @@ struct ExceptionDataRecord { uint32_t ExceptionHandlerRVA() const { assert(X() && "Exception Handler RVA is only valid if the X bit is set"); - return Data[HeaderWords(*this) + (E() ? 0 : EpilogueCount()) + CodeWords()]; + return Data[HeaderWords(*this) + (E() ? 0 : EpilogueCount()) + CodeWords()]; } uint32_t ExceptionHandlerParameter() const { assert(X() && "Exception Handler RVA is only valid if the X bit is set"); - return Data[HeaderWords(*this) + (E() ? 0 : EpilogueCount()) + CodeWords() + - 1]; + return Data[HeaderWords(*this) + (E() ? 0 : EpilogueCount()) + CodeWords() + + 1]; } }; diff --git a/contrib/libs/llvm12/include/llvm/Support/AlignOf.h b/contrib/libs/llvm12/include/llvm/Support/AlignOf.h index ce5dc575a3..1521bcebb3 100644 --- a/contrib/libs/llvm12/include/llvm/Support/AlignOf.h +++ b/contrib/libs/llvm12/include/llvm/Support/AlignOf.h @@ -20,20 +20,20 @@ #ifndef LLVM_SUPPORT_ALIGNOF_H #define LLVM_SUPPORT_ALIGNOF_H -#include <type_traits> +#include <type_traits> namespace llvm { /// A suitably aligned and sized character array member which can hold elements /// of any type. /// -/// This template is equivalent to std::aligned_union_t<1, ...>, but we cannot -/// use it due to a bug in the MSVC x86 compiler: -/// https://github.com/microsoft/STL/issues/1533 -/// Using `alignas` here works around the bug. +/// This template is equivalent to std::aligned_union_t<1, ...>, but we cannot +/// use it due to a bug in the MSVC x86 compiler: +/// https://github.com/microsoft/STL/issues/1533 +/// Using `alignas` here works around the bug. template <typename T, typename... Ts> struct AlignedCharArrayUnion { - using AlignedUnion = std::aligned_union_t<1, T, Ts...>; - alignas(alignof(AlignedUnion)) char buffer[sizeof(AlignedUnion)]; + using AlignedUnion = std::aligned_union_t<1, T, Ts...>; + alignas(alignof(AlignedUnion)) char buffer[sizeof(AlignedUnion)]; }; } // end namespace llvm diff --git a/contrib/libs/llvm12/include/llvm/Support/Allocator.h b/contrib/libs/llvm12/include/llvm/Support/Allocator.h index 80f338d7f8..639ae5dcaa 100644 --- a/contrib/libs/llvm12/include/llvm/Support/Allocator.h +++ b/contrib/libs/llvm12/include/llvm/Support/Allocator.h @@ -73,8 +73,8 @@ template <typename AllocatorT = MallocAllocator, size_t SlabSize = 4096, size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128> class BumpPtrAllocatorImpl : public AllocatorBase<BumpPtrAllocatorImpl<AllocatorT, SlabSize, - SizeThreshold, GrowthDelay>>, - private AllocatorT { + SizeThreshold, GrowthDelay>>, + private AllocatorT { public: static_assert(SizeThreshold <= SlabSize, "The SizeThreshold must be at most the SlabSize to ensure " @@ -88,15 +88,15 @@ public: template <typename T> BumpPtrAllocatorImpl(T &&Allocator) - : AllocatorT(std::forward<T &&>(Allocator)) {} + : AllocatorT(std::forward<T &&>(Allocator)) {} // Manually implement a move constructor as we must clear the old allocator's // slabs as a matter of correctness. BumpPtrAllocatorImpl(BumpPtrAllocatorImpl &&Old) - : AllocatorT(static_cast<AllocatorT &&>(Old)), CurPtr(Old.CurPtr), - End(Old.End), Slabs(std::move(Old.Slabs)), + : AllocatorT(static_cast<AllocatorT &&>(Old)), CurPtr(Old.CurPtr), + End(Old.End), Slabs(std::move(Old.Slabs)), CustomSizedSlabs(std::move(Old.CustomSizedSlabs)), - BytesAllocated(Old.BytesAllocated), RedZoneSize(Old.RedZoneSize) { + BytesAllocated(Old.BytesAllocated), RedZoneSize(Old.RedZoneSize) { Old.CurPtr = Old.End = nullptr; Old.BytesAllocated = 0; Old.Slabs.clear(); @@ -118,7 +118,7 @@ public: RedZoneSize = RHS.RedZoneSize; Slabs = std::move(RHS.Slabs); CustomSizedSlabs = std::move(RHS.CustomSizedSlabs); - AllocatorT::operator=(static_cast<AllocatorT &&>(RHS)); + AllocatorT::operator=(static_cast<AllocatorT &&>(RHS)); RHS.CurPtr = RHS.End = nullptr; RHS.BytesAllocated = 0; @@ -178,8 +178,8 @@ public: // If Size is really big, allocate a separate slab for it. size_t PaddedSize = SizeToAllocate + Alignment.value() - 1; if (PaddedSize > SizeThreshold) { - void *NewSlab = - AllocatorT::Allocate(PaddedSize, alignof(std::max_align_t)); + void *NewSlab = + AllocatorT::Allocate(PaddedSize, alignof(std::max_align_t)); // We own the new slab and don't want anyone reading anyting other than // pieces returned from this method. So poison the whole slab. __asan_poison_memory_region(NewSlab, PaddedSize); @@ -339,7 +339,7 @@ private: size_t AllocatedSlabSize = computeSlabSize(Slabs.size()); void *NewSlab = - AllocatorT::Allocate(AllocatedSlabSize, alignof(std::max_align_t)); + AllocatorT::Allocate(AllocatedSlabSize, alignof(std::max_align_t)); // We own the new slab and don't want anyone reading anything other than // pieces returned from this method. So poison the whole slab. __asan_poison_memory_region(NewSlab, AllocatedSlabSize); @@ -355,7 +355,7 @@ private: for (; I != E; ++I) { size_t AllocatedSlabSize = computeSlabSize(std::distance(Slabs.begin(), I)); - AllocatorT::Deallocate(*I, AllocatedSlabSize, alignof(std::max_align_t)); + AllocatorT::Deallocate(*I, AllocatedSlabSize, alignof(std::max_align_t)); } } @@ -364,7 +364,7 @@ private: for (auto &PtrAndSize : CustomSizedSlabs) { void *Ptr = PtrAndSize.first; size_t Size = PtrAndSize.second; - AllocatorT::Deallocate(Ptr, Size, alignof(std::max_align_t)); + AllocatorT::Deallocate(Ptr, Size, alignof(std::max_align_t)); } } diff --git a/contrib/libs/llvm12/include/llvm/Support/AtomicOrdering.h b/contrib/libs/llvm12/include/llvm/Support/AtomicOrdering.h index a93b7fe8a1..fe381ae274 100644 --- a/contrib/libs/llvm12/include/llvm/Support/AtomicOrdering.h +++ b/contrib/libs/llvm12/include/llvm/Support/AtomicOrdering.h @@ -28,7 +28,7 @@ namespace llvm { -/// Atomic ordering for C11 / C++11's memory models. +/// Atomic ordering for C11 / C++11's memory models. /// /// These values cannot change because they are shared with standard library /// implementations as well as with other compilers. @@ -94,7 +94,7 @@ inline const char *toIRString(AtomicOrdering ao) { /// Returns true if ao is stronger than other as defined by the AtomicOrdering /// lattice, which is based on C++'s definition. -inline bool isStrongerThan(AtomicOrdering AO, AtomicOrdering Other) { +inline bool isStrongerThan(AtomicOrdering AO, AtomicOrdering Other) { static const bool lookup[8][8] = { // NA UN RX CO AC RE AR SC /* NotAtomic */ {false, false, false, false, false, false, false, false}, @@ -106,10 +106,10 @@ inline bool isStrongerThan(AtomicOrdering AO, AtomicOrdering Other) { /* acq_rel */ { true, true, true, true, true, true, false, false}, /* seq_cst */ { true, true, true, true, true, true, true, false}, }; - return lookup[static_cast<size_t>(AO)][static_cast<size_t>(Other)]; + return lookup[static_cast<size_t>(AO)][static_cast<size_t>(Other)]; } -inline bool isAtLeastOrStrongerThan(AtomicOrdering AO, AtomicOrdering Other) { +inline bool isAtLeastOrStrongerThan(AtomicOrdering AO, AtomicOrdering Other) { static const bool lookup[8][8] = { // NA UN RX CO AC RE AR SC /* NotAtomic */ { true, false, false, false, false, false, false, false}, @@ -121,26 +121,26 @@ inline bool isAtLeastOrStrongerThan(AtomicOrdering AO, AtomicOrdering Other) { /* acq_rel */ { true, true, true, true, true, true, true, false}, /* seq_cst */ { true, true, true, true, true, true, true, true}, }; - return lookup[static_cast<size_t>(AO)][static_cast<size_t>(Other)]; + return lookup[static_cast<size_t>(AO)][static_cast<size_t>(Other)]; } -inline bool isStrongerThanUnordered(AtomicOrdering AO) { - return isStrongerThan(AO, AtomicOrdering::Unordered); +inline bool isStrongerThanUnordered(AtomicOrdering AO) { + return isStrongerThan(AO, AtomicOrdering::Unordered); } -inline bool isStrongerThanMonotonic(AtomicOrdering AO) { - return isStrongerThan(AO, AtomicOrdering::Monotonic); +inline bool isStrongerThanMonotonic(AtomicOrdering AO) { + return isStrongerThan(AO, AtomicOrdering::Monotonic); } -inline bool isAcquireOrStronger(AtomicOrdering AO) { - return isAtLeastOrStrongerThan(AO, AtomicOrdering::Acquire); +inline bool isAcquireOrStronger(AtomicOrdering AO) { + return isAtLeastOrStrongerThan(AO, AtomicOrdering::Acquire); } -inline bool isReleaseOrStronger(AtomicOrdering AO) { - return isAtLeastOrStrongerThan(AO, AtomicOrdering::Release); +inline bool isReleaseOrStronger(AtomicOrdering AO) { + return isAtLeastOrStrongerThan(AO, AtomicOrdering::Release); } -inline AtomicOrderingCABI toCABI(AtomicOrdering AO) { +inline AtomicOrderingCABI toCABI(AtomicOrdering AO) { static const AtomicOrderingCABI lookup[8] = { /* NotAtomic */ AtomicOrderingCABI::relaxed, /* Unordered */ AtomicOrderingCABI::relaxed, @@ -151,7 +151,7 @@ inline AtomicOrderingCABI toCABI(AtomicOrdering AO) { /* acq_rel */ AtomicOrderingCABI::acq_rel, /* seq_cst */ AtomicOrderingCABI::seq_cst, }; - return lookup[static_cast<size_t>(AO)]; + return lookup[static_cast<size_t>(AO)]; } } // end namespace llvm diff --git a/contrib/libs/llvm12/include/llvm/Support/BinaryItemStream.h b/contrib/libs/llvm12/include/llvm/Support/BinaryItemStream.h index 836ce5af90..73d853e81a 100644 --- a/contrib/libs/llvm12/include/llvm/Support/BinaryItemStream.h +++ b/contrib/libs/llvm12/include/llvm/Support/BinaryItemStream.h @@ -95,7 +95,7 @@ private: if (Offset >= getLength()) return make_error<BinaryStreamError>(stream_error_code::stream_too_short); ++Offset; - auto Iter = llvm::lower_bound(ItemEndOffsets, Offset); + auto Iter = llvm::lower_bound(ItemEndOffsets, Offset); size_t Idx = std::distance(ItemEndOffsets.begin(), Iter); assert(Idx < Items.size() && "binary search for offset failed"); return Idx; diff --git a/contrib/libs/llvm12/include/llvm/Support/CFGDiff.h b/contrib/libs/llvm12/include/llvm/Support/CFGDiff.h index f43f377fc2..398314b4fc 100644 --- a/contrib/libs/llvm12/include/llvm/Support/CFGDiff.h +++ b/contrib/libs/llvm12/include/llvm/Support/CFGDiff.h @@ -37,38 +37,38 @@ // a non-inversed graph, the children are naturally the successors when // InverseEdge is false and the predecessors when InverseEdge is true. -namespace llvm { - -namespace detail { -template <typename Range> -auto reverse_if_helper(Range &&R, std::integral_constant<bool, false>) { - return std::forward<Range>(R); -} - -template <typename Range> -auto reverse_if_helper(Range &&R, std::integral_constant<bool, true>) { - return llvm::reverse(std::forward<Range>(R)); -} - -template <bool B, typename Range> auto reverse_if(Range &&R) { - return reverse_if_helper(std::forward<Range>(R), - std::integral_constant<bool, B>{}); -} -} // namespace detail - -// GraphDiff defines a CFG snapshot: given a set of Update<NodePtr>, provides -// a getChildren method to get a Node's children based on the additional updates -// in the snapshot. The current diff treats the CFG as a graph rather than a +namespace llvm { + +namespace detail { +template <typename Range> +auto reverse_if_helper(Range &&R, std::integral_constant<bool, false>) { + return std::forward<Range>(R); +} + +template <typename Range> +auto reverse_if_helper(Range &&R, std::integral_constant<bool, true>) { + return llvm::reverse(std::forward<Range>(R)); +} + +template <bool B, typename Range> auto reverse_if(Range &&R) { + return reverse_if_helper(std::forward<Range>(R), + std::integral_constant<bool, B>{}); +} +} // namespace detail + +// GraphDiff defines a CFG snapshot: given a set of Update<NodePtr>, provides +// a getChildren method to get a Node's children based on the additional updates +// in the snapshot. The current diff treats the CFG as a graph rather than a // multigraph. Added edges are pruned to be unique, and deleted edges will // remove all existing edges between two blocks. template <typename NodePtr, bool InverseGraph = false> class GraphDiff { - struct DeletesInserts { - SmallVector<NodePtr, 2> DI[2]; + struct DeletesInserts { + SmallVector<NodePtr, 2> DI[2]; }; - using UpdateMapType = SmallDenseMap<NodePtr, DeletesInserts>; - UpdateMapType Succ; - UpdateMapType Pred; - + using UpdateMapType = SmallDenseMap<NodePtr, DeletesInserts>; + UpdateMapType Succ; + UpdateMapType Pred; + // By default, it is assumed that, given a CFG and a set of updates, we wish // to apply these updates as given. If UpdatedAreReverseApplied is set, the // updates will be applied in reverse: deleted edges are considered re-added @@ -81,19 +81,19 @@ template <typename NodePtr, bool InverseGraph = false> class GraphDiff { SmallVector<cfg::Update<NodePtr>, 4> LegalizedUpdates; void printMap(raw_ostream &OS, const UpdateMapType &M) const { - StringRef DIText[2] = {"Delete", "Insert"}; - for (auto Pair : M) { - for (unsigned IsInsert = 0; IsInsert <= 1; ++IsInsert) { - OS << DIText[IsInsert] << " edges: \n"; - for (auto Child : Pair.second.DI[IsInsert]) { - OS << "("; - Pair.first->printAsOperand(OS, false); - OS << ", "; - Child->printAsOperand(OS, false); - OS << ") "; - } + StringRef DIText[2] = {"Delete", "Insert"}; + for (auto Pair : M) { + for (unsigned IsInsert = 0; IsInsert <= 1; ++IsInsert) { + OS << DIText[IsInsert] << " edges: \n"; + for (auto Child : Pair.second.DI[IsInsert]) { + OS << "("; + Pair.first->printAsOperand(OS, false); + OS << ", "; + Child->printAsOperand(OS, false); + OS << ") "; + } } - } + } OS << "\n"; } @@ -101,12 +101,12 @@ public: GraphDiff() : UpdatedAreReverseApplied(false) {} GraphDiff(ArrayRef<cfg::Update<NodePtr>> Updates, bool ReverseApplyUpdates = false) { - cfg::LegalizeUpdates<NodePtr>(Updates, LegalizedUpdates, InverseGraph); + cfg::LegalizeUpdates<NodePtr>(Updates, LegalizedUpdates, InverseGraph); for (auto U : LegalizedUpdates) { unsigned IsInsert = (U.getKind() == cfg::UpdateKind::Insert) == !ReverseApplyUpdates; - Succ[U.getFrom()].DI[IsInsert].push_back(U.getTo()); - Pred[U.getTo()].DI[IsInsert].push_back(U.getFrom()); + Succ[U.getFrom()].DI[IsInsert].push_back(U.getTo()); + Pred[U.getTo()].DI[IsInsert].push_back(U.getFrom()); } UpdatedAreReverseApplied = ReverseApplyUpdates; } @@ -122,56 +122,56 @@ public: auto U = LegalizedUpdates.pop_back_val(); unsigned IsInsert = (U.getKind() == cfg::UpdateKind::Insert) == !UpdatedAreReverseApplied; - auto &SuccDIList = Succ[U.getFrom()]; - auto &SuccList = SuccDIList.DI[IsInsert]; + auto &SuccDIList = Succ[U.getFrom()]; + auto &SuccList = SuccDIList.DI[IsInsert]; assert(SuccList.back() == U.getTo()); SuccList.pop_back(); - if (SuccList.empty() && SuccDIList.DI[!IsInsert].empty()) - Succ.erase(U.getFrom()); + if (SuccList.empty() && SuccDIList.DI[!IsInsert].empty()) + Succ.erase(U.getFrom()); - auto &PredDIList = Pred[U.getTo()]; - auto &PredList = PredDIList.DI[IsInsert]; + auto &PredDIList = Pred[U.getTo()]; + auto &PredList = PredDIList.DI[IsInsert]; assert(PredList.back() == U.getFrom()); PredList.pop_back(); - if (PredList.empty() && PredDIList.DI[!IsInsert].empty()) - Pred.erase(U.getTo()); + if (PredList.empty() && PredDIList.DI[!IsInsert].empty()) + Pred.erase(U.getTo()); return U; } - using VectRet = SmallVector<NodePtr, 8>; - template <bool InverseEdge> VectRet getChildren(NodePtr N) const { - using DirectedNodeT = - std::conditional_t<InverseEdge, Inverse<NodePtr>, NodePtr>; - auto R = children<DirectedNodeT>(N); - VectRet Res = VectRet(detail::reverse_if<!InverseEdge>(R)); - - // Remove nullptr children for clang. - llvm::erase_value(Res, nullptr); - - auto &Children = (InverseEdge != InverseGraph) ? Pred : Succ; - auto It = Children.find(N); - if (It == Children.end()) - return Res; - - // Remove children present in the CFG but not in the snapshot. - for (auto *Child : It->second.DI[0]) - llvm::erase_value(Res, Child); - - // Add children present in the snapshot for not in the real CFG. - auto &AddedChildren = It->second.DI[1]; - llvm::append_range(Res, AddedChildren); - - return Res; + using VectRet = SmallVector<NodePtr, 8>; + template <bool InverseEdge> VectRet getChildren(NodePtr N) const { + using DirectedNodeT = + std::conditional_t<InverseEdge, Inverse<NodePtr>, NodePtr>; + auto R = children<DirectedNodeT>(N); + VectRet Res = VectRet(detail::reverse_if<!InverseEdge>(R)); + + // Remove nullptr children for clang. + llvm::erase_value(Res, nullptr); + + auto &Children = (InverseEdge != InverseGraph) ? Pred : Succ; + auto It = Children.find(N); + if (It == Children.end()) + return Res; + + // Remove children present in the CFG but not in the snapshot. + for (auto *Child : It->second.DI[0]) + llvm::erase_value(Res, Child); + + // Add children present in the snapshot for not in the real CFG. + auto &AddedChildren = It->second.DI[1]; + llvm::append_range(Res, AddedChildren); + + return Res; } void print(raw_ostream &OS) const { OS << "===== GraphDiff: CFG edge changes to create a CFG snapshot. \n" "===== (Note: notion of children/inverse_children depends on " "the direction of edges and the graph.)\n"; - OS << "Children to delete/insert:\n\t"; - printMap(OS, Succ); - OS << "Inverse_children to delete/insert:\n\t"; - printMap(OS, Pred); + OS << "Children to delete/insert:\n\t"; + printMap(OS, Succ); + OS << "Inverse_children to delete/insert:\n\t"; + printMap(OS, Pred); OS << "\n"; } diff --git a/contrib/libs/llvm12/include/llvm/Support/CheckedArithmetic.h b/contrib/libs/llvm12/include/llvm/Support/CheckedArithmetic.h index bc2b18bb14..29be66ad59 100644 --- a/contrib/libs/llvm12/include/llvm/Support/CheckedArithmetic.h +++ b/contrib/libs/llvm12/include/llvm/Support/CheckedArithmetic.h @@ -35,8 +35,8 @@ template <typename T, typename F> std::enable_if_t<std::is_integral<T>::value && sizeof(T) * 8 <= 64, llvm::Optional<T>> checkedOp(T LHS, T RHS, F Op, bool Signed = true) { - llvm::APInt ALHS(sizeof(T) * 8, LHS, Signed); - llvm::APInt ARHS(sizeof(T) * 8, RHS, Signed); + llvm::APInt ALHS(sizeof(T) * 8, LHS, Signed); + llvm::APInt ARHS(sizeof(T) * 8, RHS, Signed); bool Overflow; llvm::APInt Out = (ALHS.*Op)(ARHS, Overflow); if (Overflow) diff --git a/contrib/libs/llvm12/include/llvm/Support/CommandLine.h b/contrib/libs/llvm12/include/llvm/Support/CommandLine.h index b1231bf397..df5b148c14 100644 --- a/contrib/libs/llvm12/include/llvm/Support/CommandLine.h +++ b/contrib/libs/llvm12/include/llvm/Support/CommandLine.h @@ -376,22 +376,22 @@ public: virtual void setDefault() = 0; - // Prints the help string for an option. - // - // This maintains the Indent for multi-line descriptions. - // FirstLineIndentedBy is the count of chars of the first line - // i.e. the one containing the --<option name>. + // Prints the help string for an option. + // + // This maintains the Indent for multi-line descriptions. + // FirstLineIndentedBy is the count of chars of the first line + // i.e. the one containing the --<option name>. static void printHelpStr(StringRef HelpStr, size_t Indent, size_t FirstLineIndentedBy); - // Prints the help string for an enum value. - // - // This maintains the Indent for multi-line descriptions. - // FirstLineIndentedBy is the count of chars of the first line - // i.e. the one containing the =<value>. - static void printEnumValHelpStr(StringRef HelpStr, size_t Indent, - size_t FirstLineIndentedBy); - + // Prints the help string for an enum value. + // + // This maintains the Indent for multi-line descriptions. + // FirstLineIndentedBy is the count of chars of the first line + // i.e. the one containing the =<value>. + static void printEnumValHelpStr(StringRef HelpStr, size_t Indent, + size_t FirstLineIndentedBy); + virtual void getExtraOptionNames(SmallVectorImpl<StringRef> &) {} // addOccurrence - Wrapper around handleOccurrence that enforces Flags. @@ -692,7 +692,7 @@ public: : Values(Options) {} template <class Opt> void apply(Opt &O) const { - for (const auto &Value : Values) + for (const auto &Value : Values) O.getParser().addLiteralOption(Value.Name, Value.Value, Value.Description); } @@ -1501,7 +1501,7 @@ public: template <class... Mods> explicit opt(const Mods &... Ms) - : Option(llvm::cl::Optional, NotHidden), Parser(*this) { + : Option(llvm::cl::Optional, NotHidden), Parser(*this) { apply(this, Ms...); done(); } @@ -2105,14 +2105,14 @@ bool ExpandResponseFiles( llvm::vfs::FileSystem &FS = *llvm::vfs::getRealFileSystem(), llvm::Optional<llvm::StringRef> CurrentDir = llvm::None); -/// A convenience helper which concatenates the options specified by the -/// environment variable EnvVar and command line options, then expands response -/// files recursively. The tokenizer is a predefined GNU or Windows one. -/// \return true if all @files were expanded successfully or there were none. -bool expandResponseFiles(int Argc, const char *const *Argv, const char *EnvVar, - StringSaver &Saver, - SmallVectorImpl<const char *> &NewArgv); - +/// A convenience helper which concatenates the options specified by the +/// environment variable EnvVar and command line options, then expands response +/// files recursively. The tokenizer is a predefined GNU or Windows one. +/// \return true if all @files were expanded successfully or there were none. +bool expandResponseFiles(int Argc, const char *const *Argv, const char *EnvVar, + StringSaver &Saver, + SmallVectorImpl<const char *> &NewArgv); + /// Mark all options not part of this category as cl::ReallyHidden. /// /// \param Category the category of options to keep displaying diff --git a/contrib/libs/llvm12/include/llvm/Support/Compiler.h b/contrib/libs/llvm12/include/llvm/Support/Compiler.h index 18ae5f7f76..07c5bba5ca 100644 --- a/contrib/libs/llvm12/include/llvm/Support/Compiler.h +++ b/contrib/libs/llvm12/include/llvm/Support/Compiler.h @@ -153,7 +153,7 @@ /// LLVM_NODISCARD - Warn if a type or return value is discarded. // Use the 'nodiscard' attribute in C++17 or newer mode. -#if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(nodiscard) +#if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(nodiscard) #define LLVM_NODISCARD [[nodiscard]] #elif LLVM_HAS_CPP_ATTRIBUTE(clang::warn_unused_result) #define LLVM_NODISCARD [[clang::warn_unused_result]] @@ -241,11 +241,11 @@ /// 3.4 supported this but is buggy in various cases and produces unimplemented /// errors, just use it in GCC 4.0 and later. #if __has_attribute(always_inline) || LLVM_GNUC_PREREQ(4, 0, 0) -#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline __attribute__((always_inline)) +#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline __attribute__((always_inline)) #elif defined(_MSC_VER) #define LLVM_ATTRIBUTE_ALWAYS_INLINE __forceinline #else -#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline +#define LLVM_ATTRIBUTE_ALWAYS_INLINE inline #endif #ifdef __GNUC__ @@ -275,7 +275,7 @@ #endif /// LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements. -#if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(fallthrough) +#if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(fallthrough) #define LLVM_FALLTHROUGH [[fallthrough]] #elif LLVM_HAS_CPP_ATTRIBUTE(gnu::fallthrough) #define LLVM_FALLTHROUGH [[gnu::fallthrough]] @@ -321,9 +321,9 @@ #endif // LLVM_ATTRIBUTE_DEPRECATED(decl, "message") -// This macro will be removed. -// Use C++14's attribute instead: [[deprecated("message")]] -#define LLVM_ATTRIBUTE_DEPRECATED(decl, message) [[deprecated(message)]] decl +// This macro will be removed. +// Use C++14's attribute instead: [[deprecated("message")]] +#define LLVM_ATTRIBUTE_DEPRECATED(decl, message) [[deprecated(message)]] decl /// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands /// to an expression which states that it is undefined behavior for the diff --git a/contrib/libs/llvm12/include/llvm/Support/CrashRecoveryContext.h b/contrib/libs/llvm12/include/llvm/Support/CrashRecoveryContext.h index 3be1909872..89429f7493 100644 --- a/contrib/libs/llvm12/include/llvm/Support/CrashRecoveryContext.h +++ b/contrib/libs/llvm12/include/llvm/Support/CrashRecoveryContext.h @@ -51,11 +51,11 @@ class CrashRecoveryContextCleanup; /// executed in any case, whether crash occurs or not. These actions may be used /// to reclaim resources in the case of crash. class CrashRecoveryContext { - void *Impl = nullptr; - CrashRecoveryContextCleanup *head = nullptr; + void *Impl = nullptr; + CrashRecoveryContextCleanup *head = nullptr; public: - CrashRecoveryContext(); + CrashRecoveryContext(); ~CrashRecoveryContext(); /// Register cleanup handler, which is used when the recovery context is @@ -109,10 +109,10 @@ public: LLVM_ATTRIBUTE_NORETURN void HandleExit(int RetCode); - /// Throw again a signal or an exception, after it was catched once by a - /// CrashRecoveryContext. - static bool throwIfCrash(int RetCode); - + /// Throw again a signal or an exception, after it was catched once by a + /// CrashRecoveryContext. + static bool throwIfCrash(int RetCode); + /// In case of a crash, this is the crash identifier. int RetCode = 0; @@ -192,7 +192,7 @@ public: : CrashRecoveryContextCleanupBase< CrashRecoveryContextDestructorCleanup<T>, T>(context, resource) {} - void recoverResources() override { + void recoverResources() override { this->resource->~T(); } }; diff --git a/contrib/libs/llvm12/include/llvm/Support/DOTGraphTraits.h b/contrib/libs/llvm12/include/llvm/Support/DOTGraphTraits.h index e4cb57d8c9..d79a095eaf 100644 --- a/contrib/libs/llvm12/include/llvm/Support/DOTGraphTraits.h +++ b/contrib/libs/llvm12/include/llvm/Support/DOTGraphTraits.h @@ -67,8 +67,8 @@ public: /// isNodeHidden - If the function returns true, the given node is not /// displayed in the graph. - template <typename GraphType> - static bool isNodeHidden(const void *, const GraphType &) { + template <typename GraphType> + static bool isNodeHidden(const void *, const GraphType &) { return false; } diff --git a/contrib/libs/llvm12/include/llvm/Support/Error.h b/contrib/libs/llvm12/include/llvm/Support/Error.h index 6e909257c6..1ac408ff50 100644 --- a/contrib/libs/llvm12/include/llvm/Support/Error.h +++ b/contrib/libs/llvm12/include/llvm/Support/Error.h @@ -636,22 +636,22 @@ private: storage_type *getStorage() { assert(!HasError && "Cannot get value when an error exists!"); - return reinterpret_cast<storage_type *>(&TStorage); + return reinterpret_cast<storage_type *>(&TStorage); } const storage_type *getStorage() const { assert(!HasError && "Cannot get value when an error exists!"); - return reinterpret_cast<const storage_type *>(&TStorage); + return reinterpret_cast<const storage_type *>(&TStorage); } error_type *getErrorStorage() { assert(HasError && "Cannot get error when a value exists!"); - return reinterpret_cast<error_type *>(&ErrorStorage); + return reinterpret_cast<error_type *>(&ErrorStorage); } const error_type *getErrorStorage() const { assert(HasError && "Cannot get error when a value exists!"); - return reinterpret_cast<const error_type *>(&ErrorStorage); + return reinterpret_cast<const error_type *>(&ErrorStorage); } // Used by ExpectedAsOutParameter to reset the checked flag. diff --git a/contrib/libs/llvm12/include/llvm/Support/ErrorHandling.h b/contrib/libs/llvm12/include/llvm/Support/ErrorHandling.h index 22d300662b..73e97d1179 100644 --- a/contrib/libs/llvm12/include/llvm/Support/ErrorHandling.h +++ b/contrib/libs/llvm12/include/llvm/Support/ErrorHandling.h @@ -117,9 +117,9 @@ void install_out_of_memory_new_handler(); /// the following unwind succeeds, e.g. do not trigger additional allocations /// in the unwind chain. /// -/// If no error handler is installed (default), throws a bad_alloc exception -/// if LLVM is compiled with exception support. Otherwise prints the error -/// to standard error and calls abort(). +/// If no error handler is installed (default), throws a bad_alloc exception +/// if LLVM is compiled with exception support. Otherwise prints the error +/// to standard error and calls abort(). LLVM_ATTRIBUTE_NORETURN void report_bad_alloc_error(const char *Reason, bool GenCrashDiag = true); diff --git a/contrib/libs/llvm12/include/llvm/Support/ErrorOr.h b/contrib/libs/llvm12/include/llvm/Support/ErrorOr.h index 0e2e63dff1..67d9a08126 100644 --- a/contrib/libs/llvm12/include/llvm/Support/ErrorOr.h +++ b/contrib/libs/llvm12/include/llvm/Support/ErrorOr.h @@ -242,17 +242,17 @@ private: storage_type *getStorage() { assert(!HasError && "Cannot get value when an error exists!"); - return reinterpret_cast<storage_type *>(&TStorage); + return reinterpret_cast<storage_type *>(&TStorage); } const storage_type *getStorage() const { assert(!HasError && "Cannot get value when an error exists!"); - return reinterpret_cast<const storage_type *>(&TStorage); + return reinterpret_cast<const storage_type *>(&TStorage); } std::error_code *getErrorStorage() { assert(HasError && "Cannot get error when a value exists!"); - return reinterpret_cast<std::error_code *>(&ErrorStorage); + return reinterpret_cast<std::error_code *>(&ErrorStorage); } const std::error_code *getErrorStorage() const { diff --git a/contrib/libs/llvm12/include/llvm/Support/ExitCodes.h b/contrib/libs/llvm12/include/llvm/Support/ExitCodes.h index 0b8ffd58ee..3fe064313f 100644 --- a/contrib/libs/llvm12/include/llvm/Support/ExitCodes.h +++ b/contrib/libs/llvm12/include/llvm/Support/ExitCodes.h @@ -1,44 +1,44 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===-- llvm/Support/ExitCodes.h - Exit codes for exit() -------*- 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 contains definitions of exit codes for exit() function. They are -/// either defined by sysexits.h if it is supported, or defined here if -/// sysexits.h is not supported. -/// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_EXITCODES_H -#define LLVM_SUPPORT_EXITCODES_H - -#include "llvm/Config/llvm-config.h" - -#if HAVE_SYSEXITS_H -#include <sysexits.h> -#elif __MVS__ -// <sysexits.h> does not exist on z/OS. The only value used in LLVM is -// EX_IOERR, which is used to signal a special error condition (broken pipe). -// Define the macro with its usual value from BSD systems, which is chosen to -// not clash with more standard exit codes like 1. -#define EX_IOERR 74 -#elif LLVM_ON_UNIX -#error Exit code EX_IOERR not available -#endif - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===-- llvm/Support/ExitCodes.h - Exit codes for exit() -------*- 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 contains definitions of exit codes for exit() function. They are +/// either defined by sysexits.h if it is supported, or defined here if +/// sysexits.h is not supported. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_EXITCODES_H +#define LLVM_SUPPORT_EXITCODES_H + +#include "llvm/Config/llvm-config.h" + +#if HAVE_SYSEXITS_H +#include <sysexits.h> +#elif __MVS__ +// <sysexits.h> does not exist on z/OS. The only value used in LLVM is +// EX_IOERR, which is used to signal a special error condition (broken pipe). +// Define the macro with its usual value from BSD systems, which is chosen to +// not clash with more standard exit codes like 1. +#define EX_IOERR 74 +#elif LLVM_ON_UNIX +#error Exit code EX_IOERR not available +#endif + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/Support/FileCollector.h b/contrib/libs/llvm12/include/llvm/Support/FileCollector.h index 5312484702..828bc973f9 100644 --- a/contrib/libs/llvm12/include/llvm/Support/FileCollector.h +++ b/contrib/libs/llvm12/include/llvm/Support/FileCollector.h @@ -27,35 +27,35 @@ namespace llvm { class FileCollectorFileSystem; class Twine; -class FileCollectorBase { -public: - FileCollectorBase(); - virtual ~FileCollectorBase(); - - void addFile(const Twine &file); - void addDirectory(const Twine &Dir); - -protected: - bool markAsSeen(StringRef Path) { - if (Path.empty()) - return false; - return Seen.insert(Path).second; - } - - virtual void addFileImpl(StringRef SrcPath) = 0; - - virtual llvm::vfs::directory_iterator - addDirectoryImpl(const llvm::Twine &Dir, - IntrusiveRefCntPtr<vfs::FileSystem> FS, - std::error_code &EC) = 0; - - /// Synchronizes access to internal data structures. - std::mutex Mutex; - - /// Tracks already seen files so they can be skipped. - StringSet<> Seen; -}; - +class FileCollectorBase { +public: + FileCollectorBase(); + virtual ~FileCollectorBase(); + + void addFile(const Twine &file); + void addDirectory(const Twine &Dir); + +protected: + bool markAsSeen(StringRef Path) { + if (Path.empty()) + return false; + return Seen.insert(Path).second; + } + + virtual void addFileImpl(StringRef SrcPath) = 0; + + virtual llvm::vfs::directory_iterator + addDirectoryImpl(const llvm::Twine &Dir, + IntrusiveRefCntPtr<vfs::FileSystem> FS, + std::error_code &EC) = 0; + + /// Synchronizes access to internal data structures. + std::mutex Mutex; + + /// Tracks already seen files so they can be skipped. + StringSet<> Seen; +}; + /// Captures file system interaction and generates data to be later replayed /// with the RedirectingFileSystem. /// @@ -74,29 +74,29 @@ protected: /// /// In order to preserve the relative topology of files we use their real paths /// as relative paths inside of the Root. -class FileCollector : public FileCollectorBase { +class FileCollector : public FileCollectorBase { public: - /// Helper utility that encapsulates the logic for canonicalizing a virtual - /// path and a path to copy from. - class PathCanonicalizer { - public: - struct PathStorage { - SmallString<256> CopyFrom; - SmallString<256> VirtualPath; - }; - - /// Canonicalize a pair of virtual and real paths. - PathStorage canonicalize(StringRef SrcPath); - - private: - /// Replace with a (mostly) real path, or don't modify. Resolves symlinks - /// in the directory, using \a CachedDirs to avoid redundant lookups, but - /// leaves the filename as a possible symlink. - void updateWithRealPath(SmallVectorImpl<char> &Path); - - StringMap<std::string> CachedDirs; - }; - + /// Helper utility that encapsulates the logic for canonicalizing a virtual + /// path and a path to copy from. + class PathCanonicalizer { + public: + struct PathStorage { + SmallString<256> CopyFrom; + SmallString<256> VirtualPath; + }; + + /// Canonicalize a pair of virtual and real paths. + PathStorage canonicalize(StringRef SrcPath); + + private: + /// Replace with a (mostly) real path, or don't modify. Resolves symlinks + /// in the directory, using \a CachedDirs to avoid redundant lookups, but + /// leaves the filename as a possible symlink. + void updateWithRealPath(SmallVectorImpl<char> &Path); + + StringMap<std::string> CachedDirs; + }; + /// \p Root is the directory where collected files are will be stored. /// \p OverlayRoot is VFS mapping root. /// \p Root directory gets created in copyFiles unless it already exists. @@ -129,12 +129,12 @@ private: } protected: - void addFileImpl(StringRef SrcPath) override; + void addFileImpl(StringRef SrcPath) override; llvm::vfs::directory_iterator addDirectoryImpl(const llvm::Twine &Dir, - IntrusiveRefCntPtr<vfs::FileSystem> FS, - std::error_code &EC) override; + IntrusiveRefCntPtr<vfs::FileSystem> FS, + std::error_code &EC) override; /// The directory where collected files are copied to in copyFiles(). const std::string Root; @@ -145,8 +145,8 @@ protected: /// The yaml mapping writer. vfs::YAMLVFSWriter VFSWriter; - /// Helper utility for canonicalizing paths. - PathCanonicalizer Canonicalizer; + /// Helper utility for canonicalizing paths. + PathCanonicalizer Canonicalizer; }; } // end namespace llvm diff --git a/contrib/libs/llvm12/include/llvm/Support/FileSystem.h b/contrib/libs/llvm12/include/llvm/Support/FileSystem.h index bdd39d4e61..4e3ef16c8a 100644 --- a/contrib/libs/llvm12/include/llvm/Support/FileSystem.h +++ b/contrib/libs/llvm12/include/llvm/Support/FileSystem.h @@ -41,7 +41,7 @@ #include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorOr.h" -#include "llvm/Support/FileSystem/UniqueID.h" +#include "llvm/Support/FileSystem/UniqueID.h" #include "llvm/Support/MD5.h" #include <cassert> #include <cstdint> @@ -1118,43 +1118,43 @@ Expected<file_t> openNativeFileForRead(const Twine &Name, OpenFlags Flags = OF_None, SmallVectorImpl<char> *RealPath = nullptr); -/// Try to locks the file during the specified time. -/// -/// This function implements advisory locking on entire file. If it returns -/// <em>errc::success</em>, the file is locked by the calling process. Until the -/// process unlocks the file by calling \a unlockFile, all attempts to lock the -/// same file will fail/block. The process that locked the file may assume that -/// none of other processes read or write this file, provided that all processes -/// lock the file prior to accessing its content. -/// -/// @param FD The descriptor representing the file to lock. -/// @param Timeout Time in milliseconds that the process should wait before -/// reporting lock failure. Zero value means try to get lock only -/// once. -/// @returns errc::success if lock is successfully obtained, -/// errc::no_lock_available if the file cannot be locked, or platform-specific -/// error_code otherwise. -/// -/// @note Care should be taken when using this function in a multithreaded -/// context, as it may not prevent other threads in the same process from -/// obtaining a lock on the same file, even if they are using a different file -/// descriptor. -std::error_code -tryLockFile(int FD, - std::chrono::milliseconds Timeout = std::chrono::milliseconds(0)); - -/// Lock the file. -/// -/// This function acts as @ref tryLockFile but it waits infinitely. -std::error_code lockFile(int FD); - -/// Unlock the file. -/// -/// @param FD The descriptor representing the file to unlock. -/// @returns errc::success if lock is successfully released or platform-specific -/// error_code otherwise. -std::error_code unlockFile(int FD); - +/// Try to locks the file during the specified time. +/// +/// This function implements advisory locking on entire file. If it returns +/// <em>errc::success</em>, the file is locked by the calling process. Until the +/// process unlocks the file by calling \a unlockFile, all attempts to lock the +/// same file will fail/block. The process that locked the file may assume that +/// none of other processes read or write this file, provided that all processes +/// lock the file prior to accessing its content. +/// +/// @param FD The descriptor representing the file to lock. +/// @param Timeout Time in milliseconds that the process should wait before +/// reporting lock failure. Zero value means try to get lock only +/// once. +/// @returns errc::success if lock is successfully obtained, +/// errc::no_lock_available if the file cannot be locked, or platform-specific +/// error_code otherwise. +/// +/// @note Care should be taken when using this function in a multithreaded +/// context, as it may not prevent other threads in the same process from +/// obtaining a lock on the same file, even if they are using a different file +/// descriptor. +std::error_code +tryLockFile(int FD, + std::chrono::milliseconds Timeout = std::chrono::milliseconds(0)); + +/// Lock the file. +/// +/// This function acts as @ref tryLockFile but it waits infinitely. +std::error_code lockFile(int FD); + +/// Unlock the file. +/// +/// @param FD The descriptor representing the file to unlock. +/// @returns errc::success if lock is successfully released or platform-specific +/// error_code otherwise. +std::error_code unlockFile(int FD); + /// @brief Close the file object. This should be used instead of ::close for /// portability. On error, the caller should assume the file is closed, as is /// the case for Process::SafelyCloseFileDescriptor @@ -1166,35 +1166,35 @@ std::error_code unlockFile(int FD); /// means that the filesystem may have failed to perform some buffered writes. std::error_code closeFile(file_t &F); -/// RAII class that facilitates file locking. -class FileLocker { - int FD; ///< Locked file handle. - FileLocker(int FD) : FD(FD) {} - friend class llvm::raw_fd_ostream; - -public: - FileLocker(const FileLocker &L) = delete; - FileLocker(FileLocker &&L) : FD(L.FD) { L.FD = -1; } - ~FileLocker() { - if (FD != -1) - unlockFile(FD); - } - FileLocker &operator=(FileLocker &&L) { - FD = L.FD; - L.FD = -1; - return *this; - } - FileLocker &operator=(const FileLocker &L) = delete; - std::error_code unlock() { - if (FD != -1) { - std::error_code Result = unlockFile(FD); - FD = -1; - return Result; - } - return std::error_code(); - } -}; - +/// RAII class that facilitates file locking. +class FileLocker { + int FD; ///< Locked file handle. + FileLocker(int FD) : FD(FD) {} + friend class llvm::raw_fd_ostream; + +public: + FileLocker(const FileLocker &L) = delete; + FileLocker(FileLocker &&L) : FD(L.FD) { L.FD = -1; } + ~FileLocker() { + if (FD != -1) + unlockFile(FD); + } + FileLocker &operator=(FileLocker &&L) { + FD = L.FD; + L.FD = -1; + return *this; + } + FileLocker &operator=(const FileLocker &L) = delete; + std::error_code unlock() { + if (FD != -1) { + std::error_code Result = unlockFile(FD); + FD = -1; + return Result; + } + return std::error_code(); + } +}; + std::error_code getUniqueID(const Twine Path, UniqueID &Result); /// Get disk space usage information. diff --git a/contrib/libs/llvm12/include/llvm/Support/FileSystem/UniqueID.h b/contrib/libs/llvm12/include/llvm/Support/FileSystem/UniqueID.h index 0703ff4d73..fffe35db83 100644 --- a/contrib/libs/llvm12/include/llvm/Support/FileSystem/UniqueID.h +++ b/contrib/libs/llvm12/include/llvm/Support/FileSystem/UniqueID.h @@ -1,63 +1,63 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- llvm/Support/FileSystem/UniqueID.h - UniqueID for files --*- 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 -// -//===----------------------------------------------------------------------===// -// -// This file is cut out of llvm/Support/FileSystem.h to allow UniqueID to be -// reused without bloating the includes. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H -#define LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H - -#include <cstdint> - -namespace llvm { -namespace sys { -namespace fs { - -class UniqueID { - uint64_t Device; - uint64_t File; - -public: - UniqueID() = default; - UniqueID(uint64_t Device, uint64_t File) : Device(Device), File(File) {} - - bool operator==(const UniqueID &Other) const { - return Device == Other.Device && File == Other.File; - } - bool operator!=(const UniqueID &Other) const { return !(*this == Other); } - bool operator<(const UniqueID &Other) const { - /// Don't use std::tie since it bloats the compile time of this header. - if (Device < Other.Device) - return true; - if (Other.Device < Device) - return false; - return File < Other.File; - } - - uint64_t getDevice() const { return Device; } - uint64_t getFile() const { return File; } -}; - -} // end namespace fs -} // end namespace sys -} // end namespace llvm - -#endif // LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- llvm/Support/FileSystem/UniqueID.h - UniqueID for files --*- 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 +// +//===----------------------------------------------------------------------===// +// +// This file is cut out of llvm/Support/FileSystem.h to allow UniqueID to be +// reused without bloating the includes. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H +#define LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H + +#include <cstdint> + +namespace llvm { +namespace sys { +namespace fs { + +class UniqueID { + uint64_t Device; + uint64_t File; + +public: + UniqueID() = default; + UniqueID(uint64_t Device, uint64_t File) : Device(Device), File(File) {} + + bool operator==(const UniqueID &Other) const { + return Device == Other.Device && File == Other.File; + } + bool operator!=(const UniqueID &Other) const { return !(*this == Other); } + bool operator<(const UniqueID &Other) const { + /// Don't use std::tie since it bloats the compile time of this header. + if (Device < Other.Device) + return true; + if (Other.Device < Device) + return false; + return File < Other.File; + } + + uint64_t getDevice() const { return Device; } + uint64_t getFile() const { return File; } +}; + +} // end namespace fs +} // end namespace sys +} // end namespace llvm + +#endif // LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/Support/FormatVariadic.h b/contrib/libs/llvm12/include/llvm/Support/FormatVariadic.h index f9375ed667..3634b0bac6 100644 --- a/contrib/libs/llvm12/include/llvm/Support/FormatVariadic.h +++ b/contrib/libs/llvm12/include/llvm/Support/FormatVariadic.h @@ -212,10 +212,10 @@ public: // // The characters '{' and '}' are reserved and cannot appear anywhere within a // replacement sequence. Outside of a replacement sequence, in order to print -// a literal '{' it must be doubled as "{{". +// a literal '{' it must be doubled as "{{". // // ===Parameter Indexing=== -// +// // `index` specifies the index of the parameter in the parameter pack to format // into the output. Note that it is possible to refer to the same parameter // index multiple times in a given format string. This makes it possible to diff --git a/contrib/libs/llvm12/include/llvm/Support/GenericDomTree.h b/contrib/libs/llvm12/include/llvm/Support/GenericDomTree.h index 291da3802f..3c5b6057c1 100644 --- a/contrib/libs/llvm12/include/llvm/Support/GenericDomTree.h +++ b/contrib/libs/llvm12/include/llvm/Support/GenericDomTree.h @@ -35,7 +35,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/Support/CFGDiff.h" +#include "llvm/Support/CFGDiff.h" #include "llvm/Support/CFGUpdate.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> @@ -67,7 +67,7 @@ template <class NodeT> class DomTreeNodeBase { NodeT *TheBB; DomTreeNodeBase *IDom; unsigned Level; - SmallVector<DomTreeNodeBase *, 4> Children; + SmallVector<DomTreeNodeBase *, 4> Children; mutable unsigned DFSNumIn = ~0; mutable unsigned DFSNumOut = ~0; @@ -75,9 +75,9 @@ template <class NodeT> class DomTreeNodeBase { DomTreeNodeBase(NodeT *BB, DomTreeNodeBase *iDom) : TheBB(BB), IDom(iDom), Level(IDom ? IDom->Level + 1 : 0) {} - using iterator = typename SmallVector<DomTreeNodeBase *, 4>::iterator; + using iterator = typename SmallVector<DomTreeNodeBase *, 4>::iterator; using const_iterator = - typename SmallVector<DomTreeNodeBase *, 4>::const_iterator; + typename SmallVector<DomTreeNodeBase *, 4>::const_iterator; iterator begin() { return Children.begin(); } iterator end() { return Children.end(); } @@ -218,10 +218,10 @@ void DeleteEdge(DomTreeT &DT, typename DomTreeT::NodePtr From, template <typename DomTreeT> void ApplyUpdates(DomTreeT &DT, - GraphDiff<typename DomTreeT::NodePtr, - DomTreeT::IsPostDominator> &PreViewCFG, - GraphDiff<typename DomTreeT::NodePtr, - DomTreeT::IsPostDominator> *PostViewCFG); + GraphDiff<typename DomTreeT::NodePtr, + DomTreeT::IsPostDominator> &PreViewCFG, + GraphDiff<typename DomTreeT::NodePtr, + DomTreeT::IsPostDominator> *PostViewCFG); template <typename DomTreeT> bool Verify(const DomTreeT &DT, typename DomTreeT::VerificationLevel VL); @@ -470,8 +470,8 @@ protected: return this->Roots[0]; } - /// Find nearest common dominator basic block for basic block A and B. A and B - /// must have tree nodes. + /// Find nearest common dominator basic block for basic block A and B. A and B + /// must have tree nodes. NodeT *findNearestCommonDominator(NodeT *A, NodeT *B) const { assert(A && B && "Pointers are not valid"); assert(A->getParent() == B->getParent() && @@ -487,18 +487,18 @@ protected: DomTreeNodeBase<NodeT> *NodeA = getNode(A); DomTreeNodeBase<NodeT> *NodeB = getNode(B); - assert(NodeA && "A must be in the tree"); - assert(NodeB && "B must be in the tree"); + assert(NodeA && "A must be in the tree"); + assert(NodeB && "B must be in the tree"); // Use level information to go up the tree until the levels match. Then // continue going up til we arrive at the same node. - while (NodeA != NodeB) { + while (NodeA != NodeB) { if (NodeA->getLevel() < NodeB->getLevel()) std::swap(NodeA, NodeB); NodeA = NodeA->IDom; } - return NodeA->getBlock(); + return NodeA->getBlock(); } const NodeT *findNearestCommonDominator(const NodeT *A, @@ -545,41 +545,41 @@ protected: /// The type of updates is the same for DomTreeBase<T> and PostDomTreeBase<T> /// with the same template parameter T. /// - /// \param Updates An unordered sequence of updates to perform. The current - /// CFG and the reverse of these updates provides the pre-view of the CFG. + /// \param Updates An unordered sequence of updates to perform. The current + /// CFG and the reverse of these updates provides the pre-view of the CFG. /// void applyUpdates(ArrayRef<UpdateType> Updates) { - GraphDiff<NodePtr, IsPostDominator> PreViewCFG( - Updates, /*ReverseApplyUpdates=*/true); - DomTreeBuilder::ApplyUpdates(*this, PreViewCFG, nullptr); - } - - /// \param Updates An unordered sequence of updates to perform. The current - /// CFG and the reverse of these updates provides the pre-view of the CFG. - /// \param PostViewUpdates An unordered sequence of update to perform in order - /// to obtain a post-view of the CFG. The DT will be updated assuming the - /// obtained PostViewCFG is the desired end state. - void applyUpdates(ArrayRef<UpdateType> Updates, - ArrayRef<UpdateType> PostViewUpdates) { - if (Updates.empty()) { - GraphDiff<NodePtr, IsPostDom> PostViewCFG(PostViewUpdates); - DomTreeBuilder::ApplyUpdates(*this, PostViewCFG, &PostViewCFG); - } else { - // PreViewCFG needs to merge Updates and PostViewCFG. The updates in - // Updates need to be reversed, and match the direction in PostViewCFG. - // The PostViewCFG is created with updates reversed (equivalent to changes - // made to the CFG), so the PreViewCFG needs all the updates reverse - // applied. - SmallVector<UpdateType> AllUpdates(Updates.begin(), Updates.end()); - for (auto &Update : PostViewUpdates) - AllUpdates.push_back(Update); - GraphDiff<NodePtr, IsPostDom> PreViewCFG(AllUpdates, - /*ReverseApplyUpdates=*/true); - GraphDiff<NodePtr, IsPostDom> PostViewCFG(PostViewUpdates); - DomTreeBuilder::ApplyUpdates(*this, PreViewCFG, &PostViewCFG); - } - } - + GraphDiff<NodePtr, IsPostDominator> PreViewCFG( + Updates, /*ReverseApplyUpdates=*/true); + DomTreeBuilder::ApplyUpdates(*this, PreViewCFG, nullptr); + } + + /// \param Updates An unordered sequence of updates to perform. The current + /// CFG and the reverse of these updates provides the pre-view of the CFG. + /// \param PostViewUpdates An unordered sequence of update to perform in order + /// to obtain a post-view of the CFG. The DT will be updated assuming the + /// obtained PostViewCFG is the desired end state. + void applyUpdates(ArrayRef<UpdateType> Updates, + ArrayRef<UpdateType> PostViewUpdates) { + if (Updates.empty()) { + GraphDiff<NodePtr, IsPostDom> PostViewCFG(PostViewUpdates); + DomTreeBuilder::ApplyUpdates(*this, PostViewCFG, &PostViewCFG); + } else { + // PreViewCFG needs to merge Updates and PostViewCFG. The updates in + // Updates need to be reversed, and match the direction in PostViewCFG. + // The PostViewCFG is created with updates reversed (equivalent to changes + // made to the CFG), so the PreViewCFG needs all the updates reverse + // applied. + SmallVector<UpdateType> AllUpdates(Updates.begin(), Updates.end()); + for (auto &Update : PostViewUpdates) + AllUpdates.push_back(Update); + GraphDiff<NodePtr, IsPostDom> PreViewCFG(AllUpdates, + /*ReverseApplyUpdates=*/true); + GraphDiff<NodePtr, IsPostDom> PostViewCFG(PostViewUpdates); + DomTreeBuilder::ApplyUpdates(*this, PreViewCFG, &PostViewCFG); + } + } + /// Inform the dominator tree about a CFG edge insertion and update the tree. /// /// This function has to be called just before or just after making the update @@ -846,7 +846,7 @@ protected: "NewBB should have a single successor!"); NodeRef NewBBSucc = *GraphT::child_begin(NewBB); - SmallVector<NodeRef, 4> PredBlocks(children<Inverse<N>>(NewBB)); + SmallVector<NodeRef, 4> PredBlocks(children<Inverse<N>>(NewBB)); assert(!PredBlocks.empty() && "No predblocks?"); diff --git a/contrib/libs/llvm12/include/llvm/Support/GenericDomTreeConstruction.h b/contrib/libs/llvm12/include/llvm/Support/GenericDomTreeConstruction.h index 0298e20795..9d3248b877 100644 --- a/contrib/libs/llvm12/include/llvm/Support/GenericDomTreeConstruction.h +++ b/contrib/libs/llvm12/include/llvm/Support/GenericDomTreeConstruction.h @@ -65,7 +65,7 @@ struct SemiNCAInfo { using TreeNodePtr = DomTreeNodeBase<NodeT> *; using RootsT = decltype(DomTreeT::Roots); static constexpr bool IsPostDom = DomTreeT::IsPostDominator; - using GraphDiffT = GraphDiff<NodePtr, IsPostDom>; + using GraphDiffT = GraphDiff<NodePtr, IsPostDom>; // Information record used by Semi-NCA during tree construction. struct InfoRec { @@ -85,17 +85,17 @@ struct SemiNCAInfo { using UpdateT = typename DomTreeT::UpdateType; using UpdateKind = typename DomTreeT::UpdateKind; struct BatchUpdateInfo { - // Note: Updates inside PreViewCFG are aleady legalized. - BatchUpdateInfo(GraphDiffT &PreViewCFG, GraphDiffT *PostViewCFG = nullptr) - : PreViewCFG(PreViewCFG), PostViewCFG(PostViewCFG), - NumLegalized(PreViewCFG.getNumLegalizedUpdates()) {} + // Note: Updates inside PreViewCFG are aleady legalized. + BatchUpdateInfo(GraphDiffT &PreViewCFG, GraphDiffT *PostViewCFG = nullptr) + : PreViewCFG(PreViewCFG), PostViewCFG(PostViewCFG), + NumLegalized(PreViewCFG.getNumLegalizedUpdates()) {} // Remembers if the whole tree was recalculated at some point during the // current batch update. bool IsRecalculated = false; - GraphDiffT &PreViewCFG; - GraphDiffT *PostViewCFG; - const size_t NumLegalized; + GraphDiffT &PreViewCFG; + GraphDiffT *PostViewCFG; + const size_t NumLegalized; }; BatchUpdateInfo *BatchUpdates; @@ -111,24 +111,24 @@ struct SemiNCAInfo { // in progress, we need this information to continue it. } - template <bool Inversed> - static SmallVector<NodePtr, 8> getChildren(NodePtr N, BatchUpdatePtr BUI) { - if (BUI) - return BUI->PreViewCFG.template getChildren<Inversed>(N); - return getChildren<Inversed>(N); - } - - template <bool Inversed> - static SmallVector<NodePtr, 8> getChildren(NodePtr N) { - using DirectedNodeT = - std::conditional_t<Inversed, Inverse<NodePtr>, NodePtr>; - auto R = children<DirectedNodeT>(N); - SmallVector<NodePtr, 8> Res(detail::reverse_if<!Inversed>(R)); - - // Remove nullptr children for clang. - llvm::erase_value(Res, nullptr); - return Res; - } + template <bool Inversed> + static SmallVector<NodePtr, 8> getChildren(NodePtr N, BatchUpdatePtr BUI) { + if (BUI) + return BUI->PreViewCFG.template getChildren<Inversed>(N); + return getChildren<Inversed>(N); + } + + template <bool Inversed> + static SmallVector<NodePtr, 8> getChildren(NodePtr N) { + using DirectedNodeT = + std::conditional_t<Inversed, Inverse<NodePtr>, NodePtr>; + auto R = children<DirectedNodeT>(N); + SmallVector<NodePtr, 8> Res(detail::reverse_if<!Inversed>(R)); + + // Remove nullptr children for clang. + llvm::erase_value(Res, nullptr); + return Res; + } NodePtr getIDom(NodePtr BB) const { auto InfoIt = NodeToInfo.find(BB); @@ -170,8 +170,8 @@ struct SemiNCAInfo { } }; - using NodeOrderMap = DenseMap<NodePtr, unsigned>; - + using NodeOrderMap = DenseMap<NodePtr, unsigned>; + // Custom DFS implementation which can skip nodes based on a provided // predicate. It also collects ReverseChildren so that we don't have to spend // time getting predecessors in SemiNCA. @@ -179,13 +179,13 @@ struct SemiNCAInfo { // If IsReverse is set to true, the DFS walk will be performed backwards // relative to IsPostDom -- using reverse edges for dominators and forward // edges for postdominators. - // - // If SuccOrder is specified then in this order the DFS traverses the children - // otherwise the order is implied by the results of getChildren(). + // + // If SuccOrder is specified then in this order the DFS traverses the children + // otherwise the order is implied by the results of getChildren(). template <bool IsReverse = false, typename DescendCondition> unsigned runDFS(NodePtr V, unsigned LastNum, DescendCondition Condition, - unsigned AttachToNum, - const NodeOrderMap *SuccOrder = nullptr) { + unsigned AttachToNum, + const NodeOrderMap *SuccOrder = nullptr) { assert(V); SmallVector<NodePtr, 64> WorkList = {V}; if (NodeToInfo.count(V) != 0) NodeToInfo[V].Parent = AttachToNum; @@ -201,14 +201,14 @@ struct SemiNCAInfo { NumToNode.push_back(BB); constexpr bool Direction = IsReverse != IsPostDom; // XOR. - auto Successors = getChildren<Direction>(BB, BatchUpdates); - if (SuccOrder && Successors.size() > 1) - llvm::sort( - Successors.begin(), Successors.end(), [=](NodePtr A, NodePtr B) { - return SuccOrder->find(A)->second < SuccOrder->find(B)->second; - }); - - for (const NodePtr Succ : Successors) { + auto Successors = getChildren<Direction>(BB, BatchUpdates); + if (SuccOrder && Successors.size() > 1) + llvm::sort( + Successors.begin(), Successors.end(), [=](NodePtr A, NodePtr B) { + return SuccOrder->find(A)->second < SuccOrder->find(B)->second; + }); + + for (const NodePtr Succ : Successors) { const auto SIT = NodeToInfo.find(Succ); // Don't visit nodes more than once but remember to collect // ReverseChildren. @@ -343,7 +343,7 @@ struct SemiNCAInfo { // to CFG nodes within infinite loops. static bool HasForwardSuccessors(const NodePtr N, BatchUpdatePtr BUI) { assert(N && "N must be a valid node"); - return !getChildren<false>(N, BUI).empty(); + return !getChildren<false>(N, BUI).empty(); } static NodePtr GetEntryNode(const DomTreeT &DT) { @@ -404,32 +404,32 @@ struct SemiNCAInfo { // nodes. if (Total + 1 != Num) { HasNonTrivialRoots = true; - - // SuccOrder is the order of blocks in the function. It is needed to make - // the calculation of the FurthestAway node and the whole PostDomTree - // immune to swap successors transformation (e.g. canonicalizing branch - // predicates). SuccOrder is initialized lazily only for successors of - // reverse unreachable nodes. - Optional<NodeOrderMap> SuccOrder; - auto InitSuccOrderOnce = [&]() { - SuccOrder = NodeOrderMap(); - for (const auto Node : nodes(DT.Parent)) - if (SNCA.NodeToInfo.count(Node) == 0) - for (const auto Succ : getChildren<false>(Node, SNCA.BatchUpdates)) - SuccOrder->try_emplace(Succ, 0); - - // Add mapping for all entries of SuccOrder. - unsigned NodeNum = 0; - for (const auto Node : nodes(DT.Parent)) { - ++NodeNum; - auto Order = SuccOrder->find(Node); - if (Order != SuccOrder->end()) { - assert(Order->second == 0); - Order->second = NodeNum; - } - } - }; - + + // SuccOrder is the order of blocks in the function. It is needed to make + // the calculation of the FurthestAway node and the whole PostDomTree + // immune to swap successors transformation (e.g. canonicalizing branch + // predicates). SuccOrder is initialized lazily only for successors of + // reverse unreachable nodes. + Optional<NodeOrderMap> SuccOrder; + auto InitSuccOrderOnce = [&]() { + SuccOrder = NodeOrderMap(); + for (const auto Node : nodes(DT.Parent)) + if (SNCA.NodeToInfo.count(Node) == 0) + for (const auto Succ : getChildren<false>(Node, SNCA.BatchUpdates)) + SuccOrder->try_emplace(Succ, 0); + + // Add mapping for all entries of SuccOrder. + unsigned NodeNum = 0; + for (const auto Node : nodes(DT.Parent)) { + ++NodeNum; + auto Order = SuccOrder->find(Node); + if (Order != SuccOrder->end()) { + assert(Order->second == 0); + Order->second = NodeNum; + } + } + }; + // Make another DFS pass over all other nodes to find the // reverse-unreachable blocks, and find the furthest paths we'll be able // to make. @@ -454,12 +454,12 @@ struct SemiNCAInfo { // expensive and does not always lead to a minimal set of roots. LLVM_DEBUG(dbgs() << "\t\t\tRunning forward DFS\n"); - if (!SuccOrder) - InitSuccOrderOnce(); - assert(SuccOrder); - - const unsigned NewNum = - SNCA.runDFS<true>(I, Num, AlwaysDescend, Num, &*SuccOrder); + if (!SuccOrder) + InitSuccOrderOnce(); + assert(SuccOrder); + + const unsigned NewNum = + SNCA.runDFS<true>(I, Num, AlwaysDescend, Num, &*SuccOrder); const NodePtr FurthestAway = SNCA.NumToNode[NewNum]; LLVM_DEBUG(dbgs() << "\t\t\tFound a new furthest away node " << "(non-trivial root): " @@ -535,7 +535,7 @@ struct SemiNCAInfo { // If we wound another root in a (forward) DFS walk, remove the current // root from the set of roots, as it is reverse-reachable from the other // one. - if (llvm::is_contained(Roots, N)) { + if (llvm::is_contained(Roots, N)) { LLVM_DEBUG(dbgs() << "\tForward DFS walk found another root " << BlockNamePrinter(N) << "\n\tRemoving root " << BlockNamePrinter(Root) << "\n"); @@ -568,21 +568,21 @@ struct SemiNCAInfo { auto *Parent = DT.Parent; DT.reset(); DT.Parent = Parent; - // If the update is using the actual CFG, BUI is null. If it's using a view, - // BUI is non-null and the PreCFGView is used. When calculating from - // scratch, make the PreViewCFG equal to the PostCFGView, so Post is used. - BatchUpdatePtr PostViewBUI = nullptr; - if (BUI && BUI->PostViewCFG) { - BUI->PreViewCFG = *BUI->PostViewCFG; - PostViewBUI = BUI; - } - // This is rebuilding the whole tree, not incrementally, but PostViewBUI is - // used in case the caller needs a DT update with a CFGView. - SemiNCAInfo SNCA(PostViewBUI); + // If the update is using the actual CFG, BUI is null. If it's using a view, + // BUI is non-null and the PreCFGView is used. When calculating from + // scratch, make the PreViewCFG equal to the PostCFGView, so Post is used. + BatchUpdatePtr PostViewBUI = nullptr; + if (BUI && BUI->PostViewCFG) { + BUI->PreViewCFG = *BUI->PostViewCFG; + PostViewBUI = BUI; + } + // This is rebuilding the whole tree, not incrementally, but PostViewBUI is + // used in case the caller needs a DT update with a CFGView. + SemiNCAInfo SNCA(PostViewBUI); // Step #0: Number blocks in depth-first order and initialize variables used // in later stages of the algorithm. - DT.Roots = FindRoots(DT, PostViewBUI); + DT.Roots = FindRoots(DT, PostViewBUI); SNCA.doFullDFSWalk(DT, AlwaysDescend); SNCA.runSemiNCA(DT); @@ -693,7 +693,7 @@ struct SemiNCAInfo { // root. if (!DT.isVirtualRoot(To->getIDom())) return false; - if (!llvm::is_contained(DT.Roots, To->getBlock())) + if (!llvm::is_contained(DT.Roots, To->getBlock())) return false; // To is not a root, nothing to update. LLVM_DEBUG(dbgs() << "\t\tAfter the insertion, " << BlockNamePrinter(To) @@ -800,7 +800,7 @@ struct SemiNCAInfo { // // Invariant: there is an optimal path from `To` to TN with the minimum // depth being CurrentLevel. - for (const NodePtr Succ : getChildren<IsPostDom>(TN->getBlock(), BUI)) { + for (const NodePtr Succ : getChildren<IsPostDom>(TN->getBlock(), BUI)) { const TreeNodePtr SuccTN = DT.getNode(Succ); assert(SuccTN && "Unreachable successor found at reachable insertion"); @@ -930,8 +930,8 @@ struct SemiNCAInfo { // the DomTree about it. // The check is O(N), so run it only in debug configuration. auto IsSuccessor = [BUI](const NodePtr SuccCandidate, const NodePtr Of) { - auto Successors = getChildren<IsPostDom>(Of, BUI); - return llvm::is_contained(Successors, SuccCandidate); + auto Successors = getChildren<IsPostDom>(Of, BUI); + return llvm::is_contained(Successors, SuccCandidate); }; (void)IsSuccessor; assert(!IsSuccessor(To, From) && "Deleted edge still exists in the CFG!"); @@ -1017,14 +1017,14 @@ struct SemiNCAInfo { const TreeNodePtr TN) { LLVM_DEBUG(dbgs() << "IsReachableFromIDom " << BlockNamePrinter(TN) << "\n"); - auto TNB = TN->getBlock(); - for (const NodePtr Pred : getChildren<!IsPostDom>(TNB, BUI)) { + auto TNB = TN->getBlock(); + for (const NodePtr Pred : getChildren<!IsPostDom>(TNB, BUI)) { LLVM_DEBUG(dbgs() << "\tPred " << BlockNamePrinter(Pred) << "\n"); if (!DT.getNode(Pred)) continue; - const NodePtr Support = DT.findNearestCommonDominator(TNB, Pred); + const NodePtr Support = DT.findNearestCommonDominator(TNB, Pred); LLVM_DEBUG(dbgs() << "\tSupport " << BlockNamePrinter(Support) << "\n"); - if (Support != TNB) { + if (Support != TNB) { LLVM_DEBUG(dbgs() << "\t" << BlockNamePrinter(TN) << " is reachable from support " << BlockNamePrinter(Support) << "\n"); @@ -1065,7 +1065,7 @@ struct SemiNCAInfo { const TreeNodePtr TN = DT.getNode(To); assert(TN); if (TN->getLevel() > Level) return true; - if (!llvm::is_contained(AffectedQueue, To)) + if (!llvm::is_contained(AffectedQueue, To)) AffectedQueue.push_back(To); return false; @@ -1155,34 +1155,34 @@ struct SemiNCAInfo { //===--------------------- DomTree Batch Updater --------------------------=== //~~ - static void ApplyUpdates(DomTreeT &DT, GraphDiffT &PreViewCFG, - GraphDiffT *PostViewCFG) { - // Note: the PostViewCFG is only used when computing from scratch. It's data - // should already included in the PreViewCFG for incremental updates. - const size_t NumUpdates = PreViewCFG.getNumLegalizedUpdates(); + static void ApplyUpdates(DomTreeT &DT, GraphDiffT &PreViewCFG, + GraphDiffT *PostViewCFG) { + // Note: the PostViewCFG is only used when computing from scratch. It's data + // should already included in the PreViewCFG for incremental updates. + const size_t NumUpdates = PreViewCFG.getNumLegalizedUpdates(); if (NumUpdates == 0) return; // Take the fast path for a single update and avoid running the batch update // machinery. if (NumUpdates == 1) { - UpdateT Update = PreViewCFG.popUpdateForIncrementalUpdates(); - if (!PostViewCFG) { - if (Update.getKind() == UpdateKind::Insert) - InsertEdge(DT, /*BUI=*/nullptr, Update.getFrom(), Update.getTo()); - else - DeleteEdge(DT, /*BUI=*/nullptr, Update.getFrom(), Update.getTo()); - } else { - BatchUpdateInfo BUI(*PostViewCFG, PostViewCFG); - if (Update.getKind() == UpdateKind::Insert) - InsertEdge(DT, &BUI, Update.getFrom(), Update.getTo()); - else - DeleteEdge(DT, &BUI, Update.getFrom(), Update.getTo()); - } + UpdateT Update = PreViewCFG.popUpdateForIncrementalUpdates(); + if (!PostViewCFG) { + if (Update.getKind() == UpdateKind::Insert) + InsertEdge(DT, /*BUI=*/nullptr, Update.getFrom(), Update.getTo()); + else + DeleteEdge(DT, /*BUI=*/nullptr, Update.getFrom(), Update.getTo()); + } else { + BatchUpdateInfo BUI(*PostViewCFG, PostViewCFG); + if (Update.getKind() == UpdateKind::Insert) + InsertEdge(DT, &BUI, Update.getFrom(), Update.getTo()); + else + DeleteEdge(DT, &BUI, Update.getFrom(), Update.getTo()); + } return; } - BatchUpdateInfo BUI(PreViewCFG, PostViewCFG); + BatchUpdateInfo BUI(PreViewCFG, PostViewCFG); // Recalculate the DominatorTree when the number of updates // exceeds a threshold, which usually makes direct updating slower than // recalculation. We select this threshold proportional to the @@ -1192,21 +1192,21 @@ struct SemiNCAInfo { // Make unittests of the incremental algorithm work if (DT.DomTreeNodes.size() <= 100) { - if (BUI.NumLegalized > DT.DomTreeNodes.size()) + if (BUI.NumLegalized > DT.DomTreeNodes.size()) CalculateFromScratch(DT, &BUI); - } else if (BUI.NumLegalized > DT.DomTreeNodes.size() / 40) + } else if (BUI.NumLegalized > DT.DomTreeNodes.size() / 40) CalculateFromScratch(DT, &BUI); // If the DominatorTree was recalculated at some point, stop the batch // updates. Full recalculations ignore batch updates and look at the actual // CFG. - for (size_t i = 0; i < BUI.NumLegalized && !BUI.IsRecalculated; ++i) + for (size_t i = 0; i < BUI.NumLegalized && !BUI.IsRecalculated; ++i) ApplyNextUpdate(DT, BUI); } static void ApplyNextUpdate(DomTreeT &DT, BatchUpdateInfo &BUI) { - // Popping the next update, will move the PreViewCFG to the next snapshot. - UpdateT CurrentUpdate = BUI.PreViewCFG.popUpdateForIncrementalUpdates(); + // Popping the next update, will move the PreViewCFG to the next snapshot. + UpdateT CurrentUpdate = BUI.PreViewCFG.popUpdateForIncrementalUpdates(); #if 0 // FIXME: The LLVM_DEBUG macro only plays well with a modular // build of LLVM when the header is marked as textual, but doing @@ -1573,11 +1573,11 @@ void Calculate(DomTreeT &DT) { template <typename DomTreeT> void CalculateWithUpdates(DomTreeT &DT, ArrayRef<typename DomTreeT::UpdateType> Updates) { - // FIXME: Updated to use the PreViewCFG and behave the same as until now. - // This behavior is however incorrect; this actually needs the PostViewCFG. - GraphDiff<typename DomTreeT::NodePtr, DomTreeT::IsPostDominator> PreViewCFG( - Updates, /*ReverseApplyUpdates=*/true); - typename SemiNCAInfo<DomTreeT>::BatchUpdateInfo BUI(PreViewCFG); + // FIXME: Updated to use the PreViewCFG and behave the same as until now. + // This behavior is however incorrect; this actually needs the PostViewCFG. + GraphDiff<typename DomTreeT::NodePtr, DomTreeT::IsPostDominator> PreViewCFG( + Updates, /*ReverseApplyUpdates=*/true); + typename SemiNCAInfo<DomTreeT>::BatchUpdateInfo BUI(PreViewCFG); SemiNCAInfo<DomTreeT>::CalculateFromScratch(DT, &BUI); } @@ -1597,11 +1597,11 @@ void DeleteEdge(DomTreeT &DT, typename DomTreeT::NodePtr From, template <class DomTreeT> void ApplyUpdates(DomTreeT &DT, - GraphDiff<typename DomTreeT::NodePtr, - DomTreeT::IsPostDominator> &PreViewCFG, - GraphDiff<typename DomTreeT::NodePtr, - DomTreeT::IsPostDominator> *PostViewCFG) { - SemiNCAInfo<DomTreeT>::ApplyUpdates(DT, PreViewCFG, PostViewCFG); + GraphDiff<typename DomTreeT::NodePtr, + DomTreeT::IsPostDominator> &PreViewCFG, + GraphDiff<typename DomTreeT::NodePtr, + DomTreeT::IsPostDominator> *PostViewCFG) { + SemiNCAInfo<DomTreeT>::ApplyUpdates(DT, PreViewCFG, PostViewCFG); } template <class DomTreeT> diff --git a/contrib/libs/llvm12/include/llvm/Support/GlobPattern.h b/contrib/libs/llvm12/include/llvm/Support/GlobPattern.h index 3f474af607..5e31bea143 100644 --- a/contrib/libs/llvm12/include/llvm/Support/GlobPattern.h +++ b/contrib/libs/llvm12/include/llvm/Support/GlobPattern.h @@ -38,16 +38,16 @@ public: static Expected<GlobPattern> create(StringRef Pat); bool match(StringRef S) const; - // Returns true for glob pattern "*". Can be used to avoid expensive - // preparation/acquisition of the input for match(). - bool isTrivialMatchAll() const { - if (Prefix && Prefix->empty()) { - assert(!Suffix); - return true; - } - return false; - } - + // Returns true for glob pattern "*". Can be used to avoid expensive + // preparation/acquisition of the input for match(). + bool isTrivialMatchAll() const { + if (Prefix && Prefix->empty()) { + assert(!Suffix); + return true; + } + return false; + } + private: bool matchOne(ArrayRef<BitVector> Pat, StringRef S) const; diff --git a/contrib/libs/llvm12/include/llvm/Support/GraphWriter.h b/contrib/libs/llvm12/include/llvm/Support/GraphWriter.h index a92c8edac7..c4c5b8d521 100644 --- a/contrib/libs/llvm12/include/llvm/Support/GraphWriter.h +++ b/contrib/libs/llvm12/include/llvm/Support/GraphWriter.h @@ -165,7 +165,7 @@ public: writeNode(Node); } - bool isNodeHidden(NodeRef Node) { return DTraits.isNodeHidden(Node, G); } + bool isNodeHidden(NodeRef Node) { return DTraits.isNodeHidden(Node, G); } void writeNode(NodeRef Node) { std::string NodeAttributes = DTraits.getNodeAttributes(Node, G); @@ -233,10 +233,10 @@ public: child_iterator EI = GTraits::child_begin(Node); child_iterator EE = GTraits::child_end(Node); for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) - if (!DTraits.isNodeHidden(*EI, G)) + if (!DTraits.isNodeHidden(*EI, G)) writeEdge(Node, i, EI); for (; EI != EE; ++EI) - if (!DTraits.isNodeHidden(*EI, G)) + if (!DTraits.isNodeHidden(*EI, G)) writeEdge(Node, 64, EI); } diff --git a/contrib/libs/llvm12/include/llvm/Support/Host.h b/contrib/libs/llvm12/include/llvm/Support/Host.h index 2a1c78ffc9..5ce28816d6 100644 --- a/contrib/libs/llvm12/include/llvm/Support/Host.h +++ b/contrib/libs/llvm12/include/llvm/Support/Host.h @@ -72,20 +72,20 @@ namespace sys { StringRef getHostCPUNameForARM(StringRef ProcCpuinfoContent); StringRef getHostCPUNameForS390x(StringRef ProcCpuinfoContent); StringRef getHostCPUNameForBPF(); - - /// Helper functions to extract CPU details from CPUID on x86. - namespace x86 { - enum class VendorSignatures { - UNKNOWN, - GENUINE_INTEL, - AUTHENTIC_AMD, - }; - - /// Returns the host CPU's vendor. - /// MaxLeaf: if a non-nullptr pointer is specified, the EAX value will be - /// assigned to its pointee. - VendorSignatures getVendorSignature(unsigned *MaxLeaf = nullptr); - } // namespace x86 + + /// Helper functions to extract CPU details from CPUID on x86. + namespace x86 { + enum class VendorSignatures { + UNKNOWN, + GENUINE_INTEL, + AUTHENTIC_AMD, + }; + + /// Returns the host CPU's vendor. + /// MaxLeaf: if a non-nullptr pointer is specified, the EAX value will be + /// assigned to its pointee. + VendorSignatures getVendorSignature(unsigned *MaxLeaf = nullptr); + } // namespace x86 } } } diff --git a/contrib/libs/llvm12/include/llvm/Support/InitLLVM.h b/contrib/libs/llvm12/include/llvm/Support/InitLLVM.h index e48dc0d429..eebbf1dea0 100644 --- a/contrib/libs/llvm12/include/llvm/Support/InitLLVM.h +++ b/contrib/libs/llvm12/include/llvm/Support/InitLLVM.h @@ -16,7 +16,7 @@ #ifndef LLVM_SUPPORT_LLVM_H #define LLVM_SUPPORT_LLVM_H -#include "llvm/ADT/Optional.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/PrettyStackTrace.h" @@ -52,7 +52,7 @@ public: private: BumpPtrAllocator Alloc; SmallVector<const char *, 0> Args; - Optional<PrettyStackTraceProgram> StackPrinter; + Optional<PrettyStackTraceProgram> StackPrinter; }; } // namespace llvm diff --git a/contrib/libs/llvm12/include/llvm/Support/InstructionCost.h b/contrib/libs/llvm12/include/llvm/Support/InstructionCost.h index d357470468..0f61a6997a 100644 --- a/contrib/libs/llvm12/include/llvm/Support/InstructionCost.h +++ b/contrib/libs/llvm12/include/llvm/Support/InstructionCost.h @@ -1,249 +1,249 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- InstructionCost.h ----------------------------------------*- 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 defines an InstructionCost class that is used when calculating -/// the cost of an instruction, or a group of instructions. In addition to a -/// numeric value representing the cost the class also contains a state that -/// can be used to encode particular properties, i.e. a cost being invalid or -/// unknown. -/// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_INSTRUCTIONCOST_H -#define LLVM_SUPPORT_INSTRUCTIONCOST_H - -#include "llvm/ADT/Optional.h" - -namespace llvm { - -class raw_ostream; - -class InstructionCost { -public: - using CostType = int; - - /// These states can currently be used to indicate whether a cost is valid or - /// invalid. Examples of an invalid cost might be where the cost is - /// prohibitively expensive and the user wants to prevent certain - /// optimizations being performed. Or perhaps the cost is simply unknown - /// because the operation makes no sense in certain circumstances. These - /// states can be expanded in future to support other cases if necessary. - enum CostState { Valid, Invalid }; - -private: - CostType Value; - CostState State; - - void propagateState(const InstructionCost &RHS) { - if (RHS.State == Invalid) - State = Invalid; - } - -public: - InstructionCost() = default; - - InstructionCost(CostState) = delete; - InstructionCost(CostType Val) : Value(Val), State(Valid) {} - - static InstructionCost getInvalid(CostType Val = 0) { - InstructionCost Tmp(Val); - Tmp.setInvalid(); - return Tmp; - } - - bool isValid() const { return State == Valid; } - void setValid() { State = Valid; } - void setInvalid() { State = Invalid; } - CostState getState() const { return State; } - - /// This function is intended to be used as sparingly as possible, since the - /// class provides the full range of operator support required for arithmetic - /// and comparisons. - Optional<CostType> getValue() const { - if (isValid()) - return Value; - return None; - } - - /// For all of the arithmetic operators provided here any invalid state is - /// perpetuated and cannot be removed. Once a cost becomes invalid it stays - /// invalid, and it also inherits any invalid state from the RHS. Regardless - /// of the state, arithmetic and comparisons work on the actual values in the - /// same way as they would on a basic type, such as integer. - - InstructionCost &operator+=(const InstructionCost &RHS) { - propagateState(RHS); - Value += RHS.Value; - return *this; - } - - InstructionCost &operator+=(const CostType RHS) { - InstructionCost RHS2(RHS); - *this += RHS2; - return *this; - } - - InstructionCost &operator-=(const InstructionCost &RHS) { - propagateState(RHS); - Value -= RHS.Value; - return *this; - } - - InstructionCost &operator-=(const CostType RHS) { - InstructionCost RHS2(RHS); - *this -= RHS2; - return *this; - } - - InstructionCost &operator*=(const InstructionCost &RHS) { - propagateState(RHS); - Value *= RHS.Value; - return *this; - } - - InstructionCost &operator*=(const CostType RHS) { - InstructionCost RHS2(RHS); - *this *= RHS2; - return *this; - } - - InstructionCost &operator/=(const InstructionCost &RHS) { - propagateState(RHS); - Value /= RHS.Value; - return *this; - } - - InstructionCost &operator/=(const CostType RHS) { - InstructionCost RHS2(RHS); - *this /= RHS2; - return *this; - } - - InstructionCost &operator++() { - *this += 1; - return *this; - } - - InstructionCost operator++(int) { - InstructionCost Copy = *this; - ++*this; - return Copy; - } - - InstructionCost &operator--() { - *this -= 1; - return *this; - } - - InstructionCost operator--(int) { - InstructionCost Copy = *this; - --*this; - return Copy; - } - - bool operator==(const InstructionCost &RHS) const { - return State == RHS.State && Value == RHS.Value; - } - - bool operator!=(const InstructionCost &RHS) const { return !(*this == RHS); } - - bool operator==(const CostType RHS) const { - return State == Valid && Value == RHS; - } - - bool operator!=(const CostType RHS) const { return !(*this == RHS); } - - /// For the comparison operators we have chosen to use total ordering with - /// the following rules: - /// 1. If either of the states != Valid then a lexicographical order is - /// applied based upon the state. - /// 2. If both states are valid then order based upon value. - /// This avoids having to add asserts the comparison operators that the states - /// are valid and users can test for validity of the cost explicitly. - bool operator<(const InstructionCost &RHS) const { - if (State != Valid || RHS.State != Valid) - return State < RHS.State; - return Value < RHS.Value; - } - - bool operator>(const InstructionCost &RHS) const { return RHS < *this; } - - bool operator<=(const InstructionCost &RHS) const { return !(RHS < *this); } - - bool operator>=(const InstructionCost &RHS) const { return !(*this < RHS); } - - bool operator<(const CostType RHS) const { - InstructionCost RHS2(RHS); - return *this < RHS2; - } - - bool operator>(const CostType RHS) const { - InstructionCost RHS2(RHS); - return *this > RHS2; - } - - bool operator<=(const CostType RHS) const { - InstructionCost RHS2(RHS); - return *this <= RHS2; - } - - bool operator>=(const CostType RHS) const { - InstructionCost RHS2(RHS); - return *this >= RHS2; - } - - void print(raw_ostream &OS) const; -}; - -inline InstructionCost operator+(const InstructionCost &LHS, - const InstructionCost &RHS) { - InstructionCost LHS2(LHS); - LHS2 += RHS; - return LHS2; -} - -inline InstructionCost operator-(const InstructionCost &LHS, - const InstructionCost &RHS) { - InstructionCost LHS2(LHS); - LHS2 -= RHS; - return LHS2; -} - -inline InstructionCost operator*(const InstructionCost &LHS, - const InstructionCost &RHS) { - InstructionCost LHS2(LHS); - LHS2 *= RHS; - return LHS2; -} - -inline InstructionCost operator/(const InstructionCost &LHS, - const InstructionCost &RHS) { - InstructionCost LHS2(LHS); - LHS2 /= RHS; - return LHS2; -} - -inline raw_ostream &operator<<(raw_ostream &OS, const InstructionCost &V) { - V.print(OS); - return OS; -} - -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- InstructionCost.h ----------------------------------------*- 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 defines an InstructionCost class that is used when calculating +/// the cost of an instruction, or a group of instructions. In addition to a +/// numeric value representing the cost the class also contains a state that +/// can be used to encode particular properties, i.e. a cost being invalid or +/// unknown. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_INSTRUCTIONCOST_H +#define LLVM_SUPPORT_INSTRUCTIONCOST_H + +#include "llvm/ADT/Optional.h" + +namespace llvm { + +class raw_ostream; + +class InstructionCost { +public: + using CostType = int; + + /// These states can currently be used to indicate whether a cost is valid or + /// invalid. Examples of an invalid cost might be where the cost is + /// prohibitively expensive and the user wants to prevent certain + /// optimizations being performed. Or perhaps the cost is simply unknown + /// because the operation makes no sense in certain circumstances. These + /// states can be expanded in future to support other cases if necessary. + enum CostState { Valid, Invalid }; + +private: + CostType Value; + CostState State; + + void propagateState(const InstructionCost &RHS) { + if (RHS.State == Invalid) + State = Invalid; + } + +public: + InstructionCost() = default; + + InstructionCost(CostState) = delete; + InstructionCost(CostType Val) : Value(Val), State(Valid) {} + + static InstructionCost getInvalid(CostType Val = 0) { + InstructionCost Tmp(Val); + Tmp.setInvalid(); + return Tmp; + } + + bool isValid() const { return State == Valid; } + void setValid() { State = Valid; } + void setInvalid() { State = Invalid; } + CostState getState() const { return State; } + + /// This function is intended to be used as sparingly as possible, since the + /// class provides the full range of operator support required for arithmetic + /// and comparisons. + Optional<CostType> getValue() const { + if (isValid()) + return Value; + return None; + } + + /// For all of the arithmetic operators provided here any invalid state is + /// perpetuated and cannot be removed. Once a cost becomes invalid it stays + /// invalid, and it also inherits any invalid state from the RHS. Regardless + /// of the state, arithmetic and comparisons work on the actual values in the + /// same way as they would on a basic type, such as integer. + + InstructionCost &operator+=(const InstructionCost &RHS) { + propagateState(RHS); + Value += RHS.Value; + return *this; + } + + InstructionCost &operator+=(const CostType RHS) { + InstructionCost RHS2(RHS); + *this += RHS2; + return *this; + } + + InstructionCost &operator-=(const InstructionCost &RHS) { + propagateState(RHS); + Value -= RHS.Value; + return *this; + } + + InstructionCost &operator-=(const CostType RHS) { + InstructionCost RHS2(RHS); + *this -= RHS2; + return *this; + } + + InstructionCost &operator*=(const InstructionCost &RHS) { + propagateState(RHS); + Value *= RHS.Value; + return *this; + } + + InstructionCost &operator*=(const CostType RHS) { + InstructionCost RHS2(RHS); + *this *= RHS2; + return *this; + } + + InstructionCost &operator/=(const InstructionCost &RHS) { + propagateState(RHS); + Value /= RHS.Value; + return *this; + } + + InstructionCost &operator/=(const CostType RHS) { + InstructionCost RHS2(RHS); + *this /= RHS2; + return *this; + } + + InstructionCost &operator++() { + *this += 1; + return *this; + } + + InstructionCost operator++(int) { + InstructionCost Copy = *this; + ++*this; + return Copy; + } + + InstructionCost &operator--() { + *this -= 1; + return *this; + } + + InstructionCost operator--(int) { + InstructionCost Copy = *this; + --*this; + return Copy; + } + + bool operator==(const InstructionCost &RHS) const { + return State == RHS.State && Value == RHS.Value; + } + + bool operator!=(const InstructionCost &RHS) const { return !(*this == RHS); } + + bool operator==(const CostType RHS) const { + return State == Valid && Value == RHS; + } + + bool operator!=(const CostType RHS) const { return !(*this == RHS); } + + /// For the comparison operators we have chosen to use total ordering with + /// the following rules: + /// 1. If either of the states != Valid then a lexicographical order is + /// applied based upon the state. + /// 2. If both states are valid then order based upon value. + /// This avoids having to add asserts the comparison operators that the states + /// are valid and users can test for validity of the cost explicitly. + bool operator<(const InstructionCost &RHS) const { + if (State != Valid || RHS.State != Valid) + return State < RHS.State; + return Value < RHS.Value; + } + + bool operator>(const InstructionCost &RHS) const { return RHS < *this; } + + bool operator<=(const InstructionCost &RHS) const { return !(RHS < *this); } + + bool operator>=(const InstructionCost &RHS) const { return !(*this < RHS); } + + bool operator<(const CostType RHS) const { + InstructionCost RHS2(RHS); + return *this < RHS2; + } + + bool operator>(const CostType RHS) const { + InstructionCost RHS2(RHS); + return *this > RHS2; + } + + bool operator<=(const CostType RHS) const { + InstructionCost RHS2(RHS); + return *this <= RHS2; + } + + bool operator>=(const CostType RHS) const { + InstructionCost RHS2(RHS); + return *this >= RHS2; + } + + void print(raw_ostream &OS) const; +}; + +inline InstructionCost operator+(const InstructionCost &LHS, + const InstructionCost &RHS) { + InstructionCost LHS2(LHS); + LHS2 += RHS; + return LHS2; +} + +inline InstructionCost operator-(const InstructionCost &LHS, + const InstructionCost &RHS) { + InstructionCost LHS2(LHS); + LHS2 -= RHS; + return LHS2; +} + +inline InstructionCost operator*(const InstructionCost &LHS, + const InstructionCost &RHS) { + InstructionCost LHS2(LHS); + LHS2 *= RHS; + return LHS2; +} + +inline InstructionCost operator/(const InstructionCost &LHS, + const InstructionCost &RHS) { + InstructionCost LHS2(LHS); + LHS2 /= RHS; + return LHS2; +} + +inline raw_ostream &operator<<(raw_ostream &OS, const InstructionCost &V) { + V.print(OS); + return OS; +} + +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/Support/JSON.h b/contrib/libs/llvm12/include/llvm/Support/JSON.h index 8fd3b1b856..2a25583b03 100644 --- a/contrib/libs/llvm12/include/llvm/Support/JSON.h +++ b/contrib/libs/llvm12/include/llvm/Support/JSON.h @@ -260,14 +260,14 @@ inline bool operator!=(const Array &L, const Array &R) { return !(L == R); } /// === Converting JSON values to C++ types === /// /// The convention is to have a deserializer function findable via ADL: -/// fromJSON(const json::Value&, T&, Path) -> bool -/// -/// The return value indicates overall success, and Path is used for precise -/// error reporting. (The Path::Root passed in at the top level fromJSON call -/// captures any nested error and can render it in context). -/// If conversion fails, fromJSON calls Path::report() and immediately returns. -/// This ensures that the first fatal error survives. -/// +/// fromJSON(const json::Value&, T&, Path) -> bool +/// +/// The return value indicates overall success, and Path is used for precise +/// error reporting. (The Path::Root passed in at the top level fromJSON call +/// captures any nested error and can render it in context). +/// If conversion fails, fromJSON calls Path::report() and immediately returns. +/// This ensures that the first fatal error survives. +/// /// Deserializers are provided for: /// - bool /// - int and int64_t @@ -463,12 +463,12 @@ private: friend class Object; template <typename T, typename... U> void create(U &&... V) { - new (reinterpret_cast<T *>(&Union)) T(std::forward<U>(V)...); + new (reinterpret_cast<T *>(&Union)) T(std::forward<U>(V)...); } template <typename T> T &as() const { // Using this two-step static_cast via void * instead of reinterpret_cast // silences a -Wstrict-aliasing false positive from GCC6 and earlier. - void *Storage = static_cast<void *>(&Union); + void *Storage = static_cast<void *>(&Union); return *static_cast<T *>(Storage); } @@ -571,169 +571,169 @@ inline bool Object::erase(StringRef K) { return M.erase(ObjectKey(K)); } -/// A "cursor" marking a position within a Value. -/// The Value is a tree, and this is the path from the root to the current node. -/// This is used to associate errors with particular subobjects. -class Path { -public: - class Root; - - /// Records that the value at the current path is invalid. - /// Message is e.g. "expected number" and becomes part of the final error. - /// This overwrites any previously written error message in the root. - void report(llvm::StringLiteral Message); - - /// The root may be treated as a Path. - Path(Root &R) : Parent(nullptr), Seg(&R) {} - /// Derives a path for an array element: this[Index] - Path index(unsigned Index) const { return Path(this, Segment(Index)); } - /// Derives a path for an object field: this.Field - Path field(StringRef Field) const { return Path(this, Segment(Field)); } - -private: - /// One element in a JSON path: an object field (.foo) or array index [27]. - /// Exception: the root Path encodes a pointer to the Path::Root. - class Segment { - uintptr_t Pointer; - unsigned Offset; - - public: - Segment() = default; - Segment(Root *R) : Pointer(reinterpret_cast<uintptr_t>(R)) {} - Segment(llvm::StringRef Field) - : Pointer(reinterpret_cast<uintptr_t>(Field.data())), - Offset(static_cast<unsigned>(Field.size())) {} - Segment(unsigned Index) : Pointer(0), Offset(Index) {} - - bool isField() const { return Pointer != 0; } - StringRef field() const { - return StringRef(reinterpret_cast<const char *>(Pointer), Offset); - } - unsigned index() const { return Offset; } - Root *root() const { return reinterpret_cast<Root *>(Pointer); } - }; - - const Path *Parent; - Segment Seg; - - Path(const Path *Parent, Segment S) : Parent(Parent), Seg(S) {} -}; - -/// The root is the trivial Path to the root value. -/// It also stores the latest reported error and the path where it occurred. -class Path::Root { - llvm::StringRef Name; - llvm::StringLiteral ErrorMessage; - std::vector<Path::Segment> ErrorPath; // Only valid in error state. Reversed. - - friend void Path::report(llvm::StringLiteral Message); - -public: - Root(llvm::StringRef Name = "") : Name(Name), ErrorMessage("") {} - // No copy/move allowed as there are incoming pointers. - Root(Root &&) = delete; - Root &operator=(Root &&) = delete; - Root(const Root &) = delete; - Root &operator=(const Root &) = delete; - - /// Returns the last error reported, or else a generic error. - Error getError() const; - /// Print the root value with the error shown inline as a comment. - /// Unrelated parts of the value are elided for brevity, e.g. - /// { - /// "id": 42, - /// "name": /* expected string */ null, - /// "properties": { ... } - /// } - void printErrorContext(const Value &, llvm::raw_ostream &) const; -}; - +/// A "cursor" marking a position within a Value. +/// The Value is a tree, and this is the path from the root to the current node. +/// This is used to associate errors with particular subobjects. +class Path { +public: + class Root; + + /// Records that the value at the current path is invalid. + /// Message is e.g. "expected number" and becomes part of the final error. + /// This overwrites any previously written error message in the root. + void report(llvm::StringLiteral Message); + + /// The root may be treated as a Path. + Path(Root &R) : Parent(nullptr), Seg(&R) {} + /// Derives a path for an array element: this[Index] + Path index(unsigned Index) const { return Path(this, Segment(Index)); } + /// Derives a path for an object field: this.Field + Path field(StringRef Field) const { return Path(this, Segment(Field)); } + +private: + /// One element in a JSON path: an object field (.foo) or array index [27]. + /// Exception: the root Path encodes a pointer to the Path::Root. + class Segment { + uintptr_t Pointer; + unsigned Offset; + + public: + Segment() = default; + Segment(Root *R) : Pointer(reinterpret_cast<uintptr_t>(R)) {} + Segment(llvm::StringRef Field) + : Pointer(reinterpret_cast<uintptr_t>(Field.data())), + Offset(static_cast<unsigned>(Field.size())) {} + Segment(unsigned Index) : Pointer(0), Offset(Index) {} + + bool isField() const { return Pointer != 0; } + StringRef field() const { + return StringRef(reinterpret_cast<const char *>(Pointer), Offset); + } + unsigned index() const { return Offset; } + Root *root() const { return reinterpret_cast<Root *>(Pointer); } + }; + + const Path *Parent; + Segment Seg; + + Path(const Path *Parent, Segment S) : Parent(Parent), Seg(S) {} +}; + +/// The root is the trivial Path to the root value. +/// It also stores the latest reported error and the path where it occurred. +class Path::Root { + llvm::StringRef Name; + llvm::StringLiteral ErrorMessage; + std::vector<Path::Segment> ErrorPath; // Only valid in error state. Reversed. + + friend void Path::report(llvm::StringLiteral Message); + +public: + Root(llvm::StringRef Name = "") : Name(Name), ErrorMessage("") {} + // No copy/move allowed as there are incoming pointers. + Root(Root &&) = delete; + Root &operator=(Root &&) = delete; + Root(const Root &) = delete; + Root &operator=(const Root &) = delete; + + /// Returns the last error reported, or else a generic error. + Error getError() const; + /// Print the root value with the error shown inline as a comment. + /// Unrelated parts of the value are elided for brevity, e.g. + /// { + /// "id": 42, + /// "name": /* expected string */ null, + /// "properties": { ... } + /// } + void printErrorContext(const Value &, llvm::raw_ostream &) const; +}; + // Standard deserializers are provided for primitive types. // See comments on Value. -inline bool fromJSON(const Value &E, std::string &Out, Path P) { +inline bool fromJSON(const Value &E, std::string &Out, Path P) { if (auto S = E.getAsString()) { Out = std::string(*S); return true; } - P.report("expected string"); + P.report("expected string"); return false; } -inline bool fromJSON(const Value &E, int &Out, Path P) { +inline bool fromJSON(const Value &E, int &Out, Path P) { if (auto S = E.getAsInteger()) { Out = *S; return true; } - P.report("expected integer"); + P.report("expected integer"); return false; } -inline bool fromJSON(const Value &E, int64_t &Out, Path P) { +inline bool fromJSON(const Value &E, int64_t &Out, Path P) { if (auto S = E.getAsInteger()) { Out = *S; return true; } - P.report("expected integer"); + P.report("expected integer"); return false; } -inline bool fromJSON(const Value &E, double &Out, Path P) { +inline bool fromJSON(const Value &E, double &Out, Path P) { if (auto S = E.getAsNumber()) { Out = *S; return true; } - P.report("expected number"); + P.report("expected number"); return false; } -inline bool fromJSON(const Value &E, bool &Out, Path P) { +inline bool fromJSON(const Value &E, bool &Out, Path P) { if (auto S = E.getAsBoolean()) { Out = *S; return true; } - P.report("expected boolean"); + P.report("expected boolean"); return false; } -inline bool fromJSON(const Value &E, std::nullptr_t &Out, Path P) { +inline bool fromJSON(const Value &E, std::nullptr_t &Out, Path P) { if (auto S = E.getAsNull()) { Out = *S; return true; } - P.report("expected null"); + P.report("expected null"); return false; } -template <typename T> -bool fromJSON(const Value &E, llvm::Optional<T> &Out, Path P) { +template <typename T> +bool fromJSON(const Value &E, llvm::Optional<T> &Out, Path P) { if (E.getAsNull()) { Out = llvm::None; return true; } T Result; - if (!fromJSON(E, Result, P)) + if (!fromJSON(E, Result, P)) return false; Out = std::move(Result); return true; } -template <typename T> -bool fromJSON(const Value &E, std::vector<T> &Out, Path P) { +template <typename T> +bool fromJSON(const Value &E, std::vector<T> &Out, Path P) { if (auto *A = E.getAsArray()) { Out.clear(); Out.resize(A->size()); for (size_t I = 0; I < A->size(); ++I) - if (!fromJSON((*A)[I], Out[I], P.index(I))) + if (!fromJSON((*A)[I], Out[I], P.index(I))) return false; return true; } - P.report("expected array"); + P.report("expected array"); return false; } template <typename T> -bool fromJSON(const Value &E, std::map<std::string, T> &Out, Path P) { +bool fromJSON(const Value &E, std::map<std::string, T> &Out, Path P) { if (auto *O = E.getAsObject()) { Out.clear(); for (const auto &KV : *O) - if (!fromJSON(KV.second, Out[std::string(llvm::StringRef(KV.first))], - P.field(KV.first))) + if (!fromJSON(KV.second, Out[std::string(llvm::StringRef(KV.first))], + P.field(KV.first))) return false; return true; } - P.report("expected object"); + P.report("expected object"); return false; } @@ -746,59 +746,59 @@ template <typename T> Value toJSON(const llvm::Optional<T> &Opt) { /// /// Example: /// \code -/// bool fromJSON(const Value &E, MyStruct &R, Path P) { -/// ObjectMapper O(E, P); -/// // When returning false, error details were already reported. -/// return O && O.map("mandatory_field", R.MandatoryField) && -/// O.mapOptional("optional_field", R.OptionalField); +/// bool fromJSON(const Value &E, MyStruct &R, Path P) { +/// ObjectMapper O(E, P); +/// // When returning false, error details were already reported. +/// return O && O.map("mandatory_field", R.MandatoryField) && +/// O.mapOptional("optional_field", R.OptionalField); /// } /// \endcode class ObjectMapper { public: - /// If O is not an object, this mapper is invalid and an error is reported. - ObjectMapper(const Value &E, Path P) : O(E.getAsObject()), P(P) { - if (!O) - P.report("expected object"); - } + /// If O is not an object, this mapper is invalid and an error is reported. + ObjectMapper(const Value &E, Path P) : O(E.getAsObject()), P(P) { + if (!O) + P.report("expected object"); + } /// True if the expression is an object. /// Must be checked before calling map(). - operator bool() const { return O; } + operator bool() const { return O; } - /// Maps a property to a field. - /// If the property is missing or invalid, reports an error. - template <typename T> bool map(StringLiteral Prop, T &Out) { + /// Maps a property to a field. + /// If the property is missing or invalid, reports an error. + template <typename T> bool map(StringLiteral Prop, T &Out) { assert(*this && "Must check this is an object before calling map()"); if (const Value *E = O->get(Prop)) - return fromJSON(*E, Out, P.field(Prop)); - P.field(Prop).report("missing value"); + return fromJSON(*E, Out, P.field(Prop)); + P.field(Prop).report("missing value"); return false; } /// Maps a property to a field, if it exists. - /// If the property exists and is invalid, reports an error. + /// If the property exists and is invalid, reports an error. /// (Optional requires special handling, because missing keys are OK). - template <typename T> bool map(StringLiteral Prop, llvm::Optional<T> &Out) { + template <typename T> bool map(StringLiteral Prop, llvm::Optional<T> &Out) { assert(*this && "Must check this is an object before calling map()"); if (const Value *E = O->get(Prop)) - return fromJSON(*E, Out, P.field(Prop)); + return fromJSON(*E, Out, P.field(Prop)); Out = llvm::None; return true; } - /// Maps a property to a field, if it exists. - /// If the property exists and is invalid, reports an error. - /// If the property does not exist, Out is unchanged. - template <typename T> bool mapOptional(StringLiteral Prop, T &Out) { - assert(*this && "Must check this is an object before calling map()"); - if (const Value *E = O->get(Prop)) - return fromJSON(*E, Out, P.field(Prop)); - return true; - } - + /// Maps a property to a field, if it exists. + /// If the property exists and is invalid, reports an error. + /// If the property does not exist, Out is unchanged. + template <typename T> bool mapOptional(StringLiteral Prop, T &Out) { + assert(*this && "Must check this is an object before calling map()"); + if (const Value *E = O->get(Prop)) + return fromJSON(*E, Out, P.field(Prop)); + return true; + } + private: const Object *O; - Path P; + Path P; }; /// Parses the provided JSON source, or returns a ParseError. @@ -822,24 +822,24 @@ public: } }; -/// Version of parse() that converts the parsed value to the type T. -/// RootName describes the root object and is used in error messages. -template <typename T> -Expected<T> parse(const llvm::StringRef &JSON, const char *RootName = "") { - auto V = parse(JSON); - if (!V) - return V.takeError(); - Path::Root R(RootName); - T Result; - if (fromJSON(*V, Result, R)) - return std::move(Result); - return R.getError(); -} - +/// Version of parse() that converts the parsed value to the type T. +/// RootName describes the root object and is used in error messages. +template <typename T> +Expected<T> parse(const llvm::StringRef &JSON, const char *RootName = "") { + auto V = parse(JSON); + if (!V) + return V.takeError(); + Path::Root R(RootName); + T Result; + if (fromJSON(*V, Result, R)) + return std::move(Result); + return R.getError(); +} + /// json::OStream allows writing well-formed JSON without materializing /// all structures as json::Value ahead of time. /// It's faster, lower-level, and less safe than OS << json::Value. -/// It also allows emitting more constructs, such as comments. +/// It also allows emitting more constructs, such as comments. /// /// Only one "top-level" object can be written to a stream. /// Simplest usage involves passing lambdas (Blocks) to fill in containers: @@ -925,21 +925,21 @@ class OStream { Contents(); objectEnd(); } - /// Emit an externally-serialized value. - /// The caller must write exactly one valid JSON value to the provided stream. - /// No validation or formatting of this value occurs. - void rawValue(llvm::function_ref<void(raw_ostream &)> Contents) { - rawValueBegin(); - Contents(OS); - rawValueEnd(); - } - void rawValue(llvm::StringRef Contents) { - rawValue([&](raw_ostream &OS) { OS << Contents; }); - } - /// Emit a JavaScript comment associated with the next printed value. - /// The string must be valid until the next attribute or value is emitted. - /// Comments are not part of standard JSON, and many parsers reject them! - void comment(llvm::StringRef); + /// Emit an externally-serialized value. + /// The caller must write exactly one valid JSON value to the provided stream. + /// No validation or formatting of this value occurs. + void rawValue(llvm::function_ref<void(raw_ostream &)> Contents) { + rawValueBegin(); + Contents(OS); + rawValueEnd(); + } + void rawValue(llvm::StringRef Contents) { + rawValue([&](raw_ostream &OS) { OS << Contents; }); + } + /// Emit a JavaScript comment associated with the next printed value. + /// The string must be valid until the next attribute or value is emitted. + /// Comments are not part of standard JSON, and many parsers reject them! + void comment(llvm::StringRef); // High level functions to output object attributes. // Valid only within an object (any number of times). @@ -966,10 +966,10 @@ class OStream { void objectEnd(); void attributeBegin(llvm::StringRef Key); void attributeEnd(); - raw_ostream &rawValueBegin(); - void rawValueEnd(); + raw_ostream &rawValueBegin(); + void rawValueEnd(); -private: +private: void attributeImpl(llvm::StringRef Key, Block Contents) { attributeBegin(Key); Contents(); @@ -977,21 +977,21 @@ private: } void valueBegin(); - void flushComment(); + void flushComment(); void newline(); enum Context { Singleton, // Top level, or object attribute. Array, Object, - RawValue, // External code writing a value to OS directly. + RawValue, // External code writing a value to OS directly. }; struct State { Context Ctx = Singleton; bool HasValue = false; }; llvm::SmallVector<State, 16> Stack; // Never empty. - llvm::StringRef PendingComment; + llvm::StringRef PendingComment; llvm::raw_ostream &OS; unsigned IndentSize; unsigned Indent = 0; diff --git a/contrib/libs/llvm12/include/llvm/Support/KnownBits.h b/contrib/libs/llvm12/include/llvm/Support/KnownBits.h index e7eaf0bbbf..9026e8891e 100644 --- a/contrib/libs/llvm12/include/llvm/Support/KnownBits.h +++ b/contrib/libs/llvm12/include/llvm/Support/KnownBits.h @@ -22,7 +22,7 @@ #define LLVM_SUPPORT_KNOWNBITS_H #include "llvm/ADT/APInt.h" -#include "llvm/ADT/Optional.h" +#include "llvm/ADT/Optional.h" namespace llvm { @@ -105,9 +105,9 @@ public: /// Returns true if this value is known to be non-negative. bool isNonNegative() const { return Zero.isSignBitSet(); } - /// Returns true if this value is known to be non-zero. - bool isNonZero() const { return !One.isNullValue(); } - + /// Returns true if this value is known to be non-zero. + bool isNonZero() const { return !One.isNullValue(); } + /// Returns true if this value is known to be positive. bool isStrictlyPositive() const { return Zero.isSignBitSet() && !One.isNullValue(); } @@ -121,38 +121,38 @@ public: Zero.setSignBit(); } - /// Return the minimal unsigned value possible given these KnownBits. + /// Return the minimal unsigned value possible given these KnownBits. APInt getMinValue() const { // Assume that all bits that aren't known-ones are zeros. return One; } - /// Return the minimal signed value possible given these KnownBits. - APInt getSignedMinValue() const { - // Assume that all bits that aren't known-ones are zeros. - APInt Min = One; - // Sign bit is unknown. - if (Zero.isSignBitClear()) - Min.setSignBit(); - return Min; - } - - /// Return the maximal unsigned value possible given these KnownBits. + /// Return the minimal signed value possible given these KnownBits. + APInt getSignedMinValue() const { + // Assume that all bits that aren't known-ones are zeros. + APInt Min = One; + // Sign bit is unknown. + if (Zero.isSignBitClear()) + Min.setSignBit(); + return Min; + } + + /// Return the maximal unsigned value possible given these KnownBits. APInt getMaxValue() const { // Assume that all bits that aren't known-zeros are ones. return ~Zero; } - /// Return the maximal signed value possible given these KnownBits. - APInt getSignedMaxValue() const { - // Assume that all bits that aren't known-zeros are ones. - APInt Max = ~Zero; - // Sign bit is unknown. - if (One.isSignBitClear()) - Max.clearSignBit(); - return Max; - } - + /// Return the maximal signed value possible given these KnownBits. + APInt getSignedMaxValue() const { + // Assume that all bits that aren't known-zeros are ones. + APInt Max = ~Zero; + // Sign bit is unknown. + if (One.isSignBitClear()) + Max.clearSignBit(); + return Max; + } + /// Return known bits for a truncation of the value we're tracking. KnownBits trunc(unsigned BitWidth) const { return KnownBits(Zero.trunc(BitWidth), One.trunc(BitWidth)); @@ -197,20 +197,20 @@ public: return *this; } - /// Return known bits for a sign extension or truncation of the value we're - /// tracking. - KnownBits sextOrTrunc(unsigned BitWidth) const { - if (BitWidth > getBitWidth()) - return sext(BitWidth); - if (BitWidth < getBitWidth()) - return trunc(BitWidth); - return *this; - } - - /// Return known bits for a in-register sign extension of the value we're - /// tracking. - KnownBits sextInReg(unsigned SrcBitWidth) const; - + /// Return known bits for a sign extension or truncation of the value we're + /// tracking. + KnownBits sextOrTrunc(unsigned BitWidth) const { + if (BitWidth > getBitWidth()) + return sext(BitWidth); + if (BitWidth < getBitWidth()) + return trunc(BitWidth); + return *this; + } + + /// Return known bits for a in-register sign extension of the value we're + /// tracking. + KnownBits sextInReg(unsigned SrcBitWidth) const; + /// Return a KnownBits with the extracted bits /// [bitPosition,bitPosition+numBits). KnownBits extractBits(unsigned NumBits, unsigned BitPosition) const { @@ -218,10 +218,10 @@ public: One.extractBits(NumBits, BitPosition)); } - /// Return KnownBits based on this, but updated given that the underlying - /// value is known to be greater than or equal to Val. - KnownBits makeGE(const APInt &Val) const; - + /// Return KnownBits based on this, but updated given that the underlying + /// value is known to be greater than or equal to Val. + KnownBits makeGE(const APInt &Val) const; + /// Returns the minimum number of trailing zero bits. unsigned countMinTrailingZeros() const { return Zero.countTrailingOnes(); @@ -282,16 +282,16 @@ public: return getBitWidth() - Zero.countPopulation(); } - /// Create known bits from a known constant. - static KnownBits makeConstant(const APInt &C) { - return KnownBits(~C, C); - } - - /// Compute known bits common to LHS and RHS. - static KnownBits commonBits(const KnownBits &LHS, const KnownBits &RHS) { - return KnownBits(LHS.Zero & RHS.Zero, LHS.One & RHS.One); - } - + /// Create known bits from a known constant. + static KnownBits makeConstant(const APInt &C) { + return KnownBits(~C, C); + } + + /// Compute known bits common to LHS and RHS. + static KnownBits commonBits(const KnownBits &LHS, const KnownBits &RHS) { + return KnownBits(LHS.Zero & RHS.Zero, LHS.One & RHS.One); + } + /// Compute known bits resulting from adding LHS, RHS and a 1-bit Carry. static KnownBits computeForAddCarry( const KnownBits &LHS, const KnownBits &RHS, const KnownBits &Carry); @@ -300,84 +300,84 @@ public: static KnownBits computeForAddSub(bool Add, bool NSW, const KnownBits &LHS, KnownBits RHS); - /// Compute known bits resulting from multiplying LHS and RHS. - static KnownBits computeForMul(const KnownBits &LHS, const KnownBits &RHS); - - /// Compute known bits for udiv(LHS, RHS). - static KnownBits udiv(const KnownBits &LHS, const KnownBits &RHS); - - /// Compute known bits for urem(LHS, RHS). - static KnownBits urem(const KnownBits &LHS, const KnownBits &RHS); - - /// Compute known bits for srem(LHS, RHS). - static KnownBits srem(const KnownBits &LHS, const KnownBits &RHS); - - /// Compute known bits for umax(LHS, RHS). - static KnownBits umax(const KnownBits &LHS, const KnownBits &RHS); - - /// Compute known bits for umin(LHS, RHS). - static KnownBits umin(const KnownBits &LHS, const KnownBits &RHS); - - /// Compute known bits for smax(LHS, RHS). - static KnownBits smax(const KnownBits &LHS, const KnownBits &RHS); - - /// Compute known bits for smin(LHS, RHS). - static KnownBits smin(const KnownBits &LHS, const KnownBits &RHS); - - /// Compute known bits for shl(LHS, RHS). - /// NOTE: RHS (shift amount) bitwidth doesn't need to be the same as LHS. - static KnownBits shl(const KnownBits &LHS, const KnownBits &RHS); - - /// Compute known bits for lshr(LHS, RHS). - /// NOTE: RHS (shift amount) bitwidth doesn't need to be the same as LHS. - static KnownBits lshr(const KnownBits &LHS, const KnownBits &RHS); - - /// Compute known bits for ashr(LHS, RHS). - /// NOTE: RHS (shift amount) bitwidth doesn't need to be the same as LHS. - static KnownBits ashr(const KnownBits &LHS, const KnownBits &RHS); - - /// Determine if these known bits always give the same ICMP_EQ result. - static Optional<bool> eq(const KnownBits &LHS, const KnownBits &RHS); - - /// Determine if these known bits always give the same ICMP_NE result. - static Optional<bool> ne(const KnownBits &LHS, const KnownBits &RHS); - - /// Determine if these known bits always give the same ICMP_UGT result. - static Optional<bool> ugt(const KnownBits &LHS, const KnownBits &RHS); - - /// Determine if these known bits always give the same ICMP_UGE result. - static Optional<bool> uge(const KnownBits &LHS, const KnownBits &RHS); - - /// Determine if these known bits always give the same ICMP_ULT result. - static Optional<bool> ult(const KnownBits &LHS, const KnownBits &RHS); - - /// Determine if these known bits always give the same ICMP_ULE result. - static Optional<bool> ule(const KnownBits &LHS, const KnownBits &RHS); - - /// Determine if these known bits always give the same ICMP_SGT result. - static Optional<bool> sgt(const KnownBits &LHS, const KnownBits &RHS); - - /// Determine if these known bits always give the same ICMP_SGE result. - static Optional<bool> sge(const KnownBits &LHS, const KnownBits &RHS); - - /// Determine if these known bits always give the same ICMP_SLT result. - static Optional<bool> slt(const KnownBits &LHS, const KnownBits &RHS); - - /// Determine if these known bits always give the same ICMP_SLE result. - static Optional<bool> sle(const KnownBits &LHS, const KnownBits &RHS); - - /// Insert the bits from a smaller known bits starting at bitPosition. - void insertBits(const KnownBits &SubBits, unsigned BitPosition) { - Zero.insertBits(SubBits.Zero, BitPosition); - One.insertBits(SubBits.One, BitPosition); - } - - /// Return a subset of the known bits from [bitPosition,bitPosition+numBits). - KnownBits extractBits(unsigned NumBits, unsigned BitPosition) { - return KnownBits(Zero.extractBits(NumBits, BitPosition), - One.extractBits(NumBits, BitPosition)); - } - + /// Compute known bits resulting from multiplying LHS and RHS. + static KnownBits computeForMul(const KnownBits &LHS, const KnownBits &RHS); + + /// Compute known bits for udiv(LHS, RHS). + static KnownBits udiv(const KnownBits &LHS, const KnownBits &RHS); + + /// Compute known bits for urem(LHS, RHS). + static KnownBits urem(const KnownBits &LHS, const KnownBits &RHS); + + /// Compute known bits for srem(LHS, RHS). + static KnownBits srem(const KnownBits &LHS, const KnownBits &RHS); + + /// Compute known bits for umax(LHS, RHS). + static KnownBits umax(const KnownBits &LHS, const KnownBits &RHS); + + /// Compute known bits for umin(LHS, RHS). + static KnownBits umin(const KnownBits &LHS, const KnownBits &RHS); + + /// Compute known bits for smax(LHS, RHS). + static KnownBits smax(const KnownBits &LHS, const KnownBits &RHS); + + /// Compute known bits for smin(LHS, RHS). + static KnownBits smin(const KnownBits &LHS, const KnownBits &RHS); + + /// Compute known bits for shl(LHS, RHS). + /// NOTE: RHS (shift amount) bitwidth doesn't need to be the same as LHS. + static KnownBits shl(const KnownBits &LHS, const KnownBits &RHS); + + /// Compute known bits for lshr(LHS, RHS). + /// NOTE: RHS (shift amount) bitwidth doesn't need to be the same as LHS. + static KnownBits lshr(const KnownBits &LHS, const KnownBits &RHS); + + /// Compute known bits for ashr(LHS, RHS). + /// NOTE: RHS (shift amount) bitwidth doesn't need to be the same as LHS. + static KnownBits ashr(const KnownBits &LHS, const KnownBits &RHS); + + /// Determine if these known bits always give the same ICMP_EQ result. + static Optional<bool> eq(const KnownBits &LHS, const KnownBits &RHS); + + /// Determine if these known bits always give the same ICMP_NE result. + static Optional<bool> ne(const KnownBits &LHS, const KnownBits &RHS); + + /// Determine if these known bits always give the same ICMP_UGT result. + static Optional<bool> ugt(const KnownBits &LHS, const KnownBits &RHS); + + /// Determine if these known bits always give the same ICMP_UGE result. + static Optional<bool> uge(const KnownBits &LHS, const KnownBits &RHS); + + /// Determine if these known bits always give the same ICMP_ULT result. + static Optional<bool> ult(const KnownBits &LHS, const KnownBits &RHS); + + /// Determine if these known bits always give the same ICMP_ULE result. + static Optional<bool> ule(const KnownBits &LHS, const KnownBits &RHS); + + /// Determine if these known bits always give the same ICMP_SGT result. + static Optional<bool> sgt(const KnownBits &LHS, const KnownBits &RHS); + + /// Determine if these known bits always give the same ICMP_SGE result. + static Optional<bool> sge(const KnownBits &LHS, const KnownBits &RHS); + + /// Determine if these known bits always give the same ICMP_SLT result. + static Optional<bool> slt(const KnownBits &LHS, const KnownBits &RHS); + + /// Determine if these known bits always give the same ICMP_SLE result. + static Optional<bool> sle(const KnownBits &LHS, const KnownBits &RHS); + + /// Insert the bits from a smaller known bits starting at bitPosition. + void insertBits(const KnownBits &SubBits, unsigned BitPosition) { + Zero.insertBits(SubBits.Zero, BitPosition); + One.insertBits(SubBits.One, BitPosition); + } + + /// Return a subset of the known bits from [bitPosition,bitPosition+numBits). + KnownBits extractBits(unsigned NumBits, unsigned BitPosition) { + return KnownBits(Zero.extractBits(NumBits, BitPosition), + One.extractBits(NumBits, BitPosition)); + } + /// Update known bits based on ANDing with RHS. KnownBits &operator&=(const KnownBits &RHS); @@ -386,17 +386,17 @@ public: /// Update known bits based on XORing with RHS. KnownBits &operator^=(const KnownBits &RHS); - - /// Compute known bits for the absolute value. - KnownBits abs(bool IntMinIsPoison = false) const; - - KnownBits byteSwap() { - return KnownBits(Zero.byteSwap(), One.byteSwap()); - } - - KnownBits reverseBits() { - return KnownBits(Zero.reverseBits(), One.reverseBits()); - } + + /// Compute known bits for the absolute value. + KnownBits abs(bool IntMinIsPoison = false) const; + + KnownBits byteSwap() { + return KnownBits(Zero.byteSwap(), One.byteSwap()); + } + + KnownBits reverseBits() { + return KnownBits(Zero.reverseBits(), One.reverseBits()); + } }; inline KnownBits operator&(KnownBits LHS, const KnownBits &RHS) { diff --git a/contrib/libs/llvm12/include/llvm/Support/LineIterator.h b/contrib/libs/llvm12/include/llvm/Support/LineIterator.h index 71cc080931..05b5f93c1b 100644 --- a/contrib/libs/llvm12/include/llvm/Support/LineIterator.h +++ b/contrib/libs/llvm12/include/llvm/Support/LineIterator.h @@ -16,10 +16,10 @@ #ifndef LLVM_SUPPORT_LINEITERATOR_H #define LLVM_SUPPORT_LINEITERATOR_H -#include "llvm/ADT/Optional.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" -#include "llvm/Support/MemoryBufferRef.h" +#include "llvm/Support/MemoryBufferRef.h" #include <iterator> namespace llvm { @@ -39,7 +39,7 @@ class MemoryBuffer; /// Note that this iterator requires the buffer to be nul terminated. class line_iterator : public std::iterator<std::forward_iterator_tag, StringRef> { - Optional<MemoryBufferRef> Buffer; + Optional<MemoryBufferRef> Buffer; char CommentMarker = '\0'; bool SkipBlanks = true; @@ -50,10 +50,10 @@ public: /// Default construct an "end" iterator. line_iterator() = default; - /// Construct a new iterator around an unowned memory buffer. - explicit line_iterator(const MemoryBufferRef &Buffer, bool SkipBlanks = true, - char CommentMarker = '\0'); - + /// Construct a new iterator around an unowned memory buffer. + explicit line_iterator(const MemoryBufferRef &Buffer, bool SkipBlanks = true, + char CommentMarker = '\0'); + /// Construct a new iterator around some memory buffer. explicit line_iterator(const MemoryBuffer &Buffer, bool SkipBlanks = true, char CommentMarker = '\0'); diff --git a/contrib/libs/llvm12/include/llvm/Support/MachineValueType.h b/contrib/libs/llvm12/include/llvm/Support/MachineValueType.h index 1972ff987f..02d3979420 100644 --- a/contrib/libs/llvm12/include/llvm/Support/MachineValueType.h +++ b/contrib/libs/llvm12/include/llvm/Support/MachineValueType.h @@ -118,119 +118,119 @@ namespace llvm { v8i64 = 61, // 8 x i64 v16i64 = 62, // 16 x i64 v32i64 = 63, // 32 x i64 - v64i64 = 64, // 64 x i64 - v128i64 = 65, // 128 x i64 - v256i64 = 66, // 256 x i64 + v64i64 = 64, // 64 x i64 + v128i64 = 65, // 128 x i64 + v256i64 = 66, // 256 x i64 - v1i128 = 67, // 1 x i128 + v1i128 = 67, // 1 x i128 FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE = v1i1, LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE = v1i128, - v2f16 = 68, // 2 x f16 - v3f16 = 69, // 3 x f16 - v4f16 = 70, // 4 x f16 - v8f16 = 71, // 8 x f16 - v16f16 = 72, // 16 x f16 - v32f16 = 73, // 32 x f16 - v64f16 = 74, // 64 x f16 - v128f16 = 75, // 128 x f16 - v2bf16 = 76, // 2 x bf16 - v3bf16 = 77, // 3 x bf16 - v4bf16 = 78, // 4 x bf16 - v8bf16 = 79, // 8 x bf16 - v16bf16 = 80, // 16 x bf16 - v32bf16 = 81, // 32 x bf16 - v64bf16 = 82, // 64 x bf16 - v128bf16 = 83, // 128 x bf16 - v1f32 = 84, // 1 x f32 - v2f32 = 85, // 2 x f32 - v3f32 = 86, // 3 x f32 - v4f32 = 87, // 4 x f32 - v5f32 = 88, // 5 x f32 - v8f32 = 89, // 8 x f32 - v16f32 = 90, // 16 x f32 - v32f32 = 91, // 32 x f32 - v64f32 = 92, // 64 x f32 - v128f32 = 93, // 128 x f32 - v256f32 = 94, // 256 x f32 - v512f32 = 95, // 512 x f32 - v1024f32 = 96, // 1024 x f32 - v2048f32 = 97, // 2048 x f32 - v1f64 = 98, // 1 x f64 - v2f64 = 99, // 2 x f64 - v4f64 = 100, // 4 x f64 - v8f64 = 101, // 8 x f64 - v16f64 = 102, // 16 x f64 - v32f64 = 103, // 32 x f64 - v64f64 = 104, // 64 x f64 - v128f64 = 105, // 128 x f64 - v256f64 = 106, // 256 x f64 + v2f16 = 68, // 2 x f16 + v3f16 = 69, // 3 x f16 + v4f16 = 70, // 4 x f16 + v8f16 = 71, // 8 x f16 + v16f16 = 72, // 16 x f16 + v32f16 = 73, // 32 x f16 + v64f16 = 74, // 64 x f16 + v128f16 = 75, // 128 x f16 + v2bf16 = 76, // 2 x bf16 + v3bf16 = 77, // 3 x bf16 + v4bf16 = 78, // 4 x bf16 + v8bf16 = 79, // 8 x bf16 + v16bf16 = 80, // 16 x bf16 + v32bf16 = 81, // 32 x bf16 + v64bf16 = 82, // 64 x bf16 + v128bf16 = 83, // 128 x bf16 + v1f32 = 84, // 1 x f32 + v2f32 = 85, // 2 x f32 + v3f32 = 86, // 3 x f32 + v4f32 = 87, // 4 x f32 + v5f32 = 88, // 5 x f32 + v8f32 = 89, // 8 x f32 + v16f32 = 90, // 16 x f32 + v32f32 = 91, // 32 x f32 + v64f32 = 92, // 64 x f32 + v128f32 = 93, // 128 x f32 + v256f32 = 94, // 256 x f32 + v512f32 = 95, // 512 x f32 + v1024f32 = 96, // 1024 x f32 + v2048f32 = 97, // 2048 x f32 + v1f64 = 98, // 1 x f64 + v2f64 = 99, // 2 x f64 + v4f64 = 100, // 4 x f64 + v8f64 = 101, // 8 x f64 + v16f64 = 102, // 16 x f64 + v32f64 = 103, // 32 x f64 + v64f64 = 104, // 64 x f64 + v128f64 = 105, // 128 x f64 + v256f64 = 106, // 256 x f64 FIRST_FP_FIXEDLEN_VECTOR_VALUETYPE = v2f16, - LAST_FP_FIXEDLEN_VECTOR_VALUETYPE = v256f64, + LAST_FP_FIXEDLEN_VECTOR_VALUETYPE = v256f64, FIRST_FIXEDLEN_VECTOR_VALUETYPE = v1i1, - LAST_FIXEDLEN_VECTOR_VALUETYPE = v256f64, - - nxv1i1 = 107, // n x 1 x i1 - nxv2i1 = 108, // n x 2 x i1 - nxv4i1 = 109, // n x 4 x i1 - nxv8i1 = 110, // n x 8 x i1 - nxv16i1 = 111, // n x 16 x i1 - nxv32i1 = 112, // n x 32 x i1 - nxv64i1 = 113, // n x 64 x i1 - - nxv1i8 = 114, // n x 1 x i8 - nxv2i8 = 115, // n x 2 x i8 - nxv4i8 = 116, // n x 4 x i8 - nxv8i8 = 117, // n x 8 x i8 - nxv16i8 = 118, // n x 16 x i8 - nxv32i8 = 119, // n x 32 x i8 - nxv64i8 = 120, // n x 64 x i8 - - nxv1i16 = 121, // n x 1 x i16 - nxv2i16 = 122, // n x 2 x i16 - nxv4i16 = 123, // n x 4 x i16 - nxv8i16 = 124, // n x 8 x i16 - nxv16i16 = 125, // n x 16 x i16 - nxv32i16 = 126, // n x 32 x i16 - - nxv1i32 = 127, // n x 1 x i32 - nxv2i32 = 128, // n x 2 x i32 - nxv4i32 = 129, // n x 4 x i32 - nxv8i32 = 130, // n x 8 x i32 - nxv16i32 = 131, // n x 16 x i32 - nxv32i32 = 132, // n x 32 x i32 - - nxv1i64 = 133, // n x 1 x i64 - nxv2i64 = 134, // n x 2 x i64 - nxv4i64 = 135, // n x 4 x i64 - nxv8i64 = 136, // n x 8 x i64 - nxv16i64 = 137, // n x 16 x i64 - nxv32i64 = 138, // n x 32 x i64 + LAST_FIXEDLEN_VECTOR_VALUETYPE = v256f64, + + nxv1i1 = 107, // n x 1 x i1 + nxv2i1 = 108, // n x 2 x i1 + nxv4i1 = 109, // n x 4 x i1 + nxv8i1 = 110, // n x 8 x i1 + nxv16i1 = 111, // n x 16 x i1 + nxv32i1 = 112, // n x 32 x i1 + nxv64i1 = 113, // n x 64 x i1 + + nxv1i8 = 114, // n x 1 x i8 + nxv2i8 = 115, // n x 2 x i8 + nxv4i8 = 116, // n x 4 x i8 + nxv8i8 = 117, // n x 8 x i8 + nxv16i8 = 118, // n x 16 x i8 + nxv32i8 = 119, // n x 32 x i8 + nxv64i8 = 120, // n x 64 x i8 + + nxv1i16 = 121, // n x 1 x i16 + nxv2i16 = 122, // n x 2 x i16 + nxv4i16 = 123, // n x 4 x i16 + nxv8i16 = 124, // n x 8 x i16 + nxv16i16 = 125, // n x 16 x i16 + nxv32i16 = 126, // n x 32 x i16 + + nxv1i32 = 127, // n x 1 x i32 + nxv2i32 = 128, // n x 2 x i32 + nxv4i32 = 129, // n x 4 x i32 + nxv8i32 = 130, // n x 8 x i32 + nxv16i32 = 131, // n x 16 x i32 + nxv32i32 = 132, // n x 32 x i32 + + nxv1i64 = 133, // n x 1 x i64 + nxv2i64 = 134, // n x 2 x i64 + nxv4i64 = 135, // n x 4 x i64 + nxv8i64 = 136, // n x 8 x i64 + nxv16i64 = 137, // n x 16 x i64 + nxv32i64 = 138, // n x 32 x i64 FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE = nxv1i1, LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE = nxv32i64, - nxv1f16 = 139, // n x 1 x f16 - nxv2f16 = 140, // n x 2 x f16 - nxv4f16 = 141, // n x 4 x f16 - nxv8f16 = 142, // n x 8 x f16 - nxv16f16 = 143, // n x 16 x f16 - nxv32f16 = 144, // n x 32 x f16 - nxv2bf16 = 145, // n x 2 x bf16 - nxv4bf16 = 146, // n x 4 x bf16 - nxv8bf16 = 147, // n x 8 x bf16 - nxv1f32 = 148, // n x 1 x f32 - nxv2f32 = 149, // n x 2 x f32 - nxv4f32 = 150, // n x 4 x f32 - nxv8f32 = 151, // n x 8 x f32 - nxv16f32 = 152, // n x 16 x f32 - nxv1f64 = 153, // n x 1 x f64 - nxv2f64 = 154, // n x 2 x f64 - nxv4f64 = 155, // n x 4 x f64 - nxv8f64 = 156, // n x 8 x f64 + nxv1f16 = 139, // n x 1 x f16 + nxv2f16 = 140, // n x 2 x f16 + nxv4f16 = 141, // n x 4 x f16 + nxv8f16 = 142, // n x 8 x f16 + nxv16f16 = 143, // n x 16 x f16 + nxv32f16 = 144, // n x 32 x f16 + nxv2bf16 = 145, // n x 2 x bf16 + nxv4bf16 = 146, // n x 4 x bf16 + nxv8bf16 = 147, // n x 8 x bf16 + nxv1f32 = 148, // n x 1 x f32 + nxv2f32 = 149, // n x 2 x f32 + nxv4f32 = 150, // n x 4 x f32 + nxv8f32 = 151, // n x 8 x f32 + nxv16f32 = 152, // n x 16 x f32 + nxv1f64 = 153, // n x 1 x f64 + nxv2f64 = 154, // n x 2 x f64 + nxv4f64 = 155, // n x 4 x f64 + nxv8f64 = 156, // n x 8 x f64 FIRST_FP_SCALABLE_VECTOR_VALUETYPE = nxv1f16, LAST_FP_SCALABLE_VECTOR_VALUETYPE = nxv8f64, @@ -241,27 +241,27 @@ namespace llvm { FIRST_VECTOR_VALUETYPE = v1i1, LAST_VECTOR_VALUETYPE = nxv8f64, - x86mmx = 157, // This is an X86 MMX value + x86mmx = 157, // This is an X86 MMX value - Glue = 158, // This glues nodes together during pre-RA sched + Glue = 158, // This glues nodes together during pre-RA sched - isVoid = 159, // This has no value + isVoid = 159, // This has no value - Untyped = 160, // This value takes a register, but has + Untyped = 160, // This value takes a register, but has // unspecified type. The register class // will be determined by the opcode. - funcref = 161, // WebAssembly's funcref type - externref = 162, // WebAssembly's externref type - x86amx = 163, // This is an X86 AMX value + funcref = 161, // WebAssembly's funcref type + externref = 162, // WebAssembly's externref type + x86amx = 163, // This is an X86 AMX value FIRST_VALUETYPE = 1, // This is always the beginning of the list. - LAST_VALUETYPE = 164, // This always remains at the end of the list. + LAST_VALUETYPE = 164, // This always remains at the end of the list. // This is the current maximum for LAST_VALUETYPE. // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors // This value must be a multiple of 32. - MAX_ALLOWED_VALUETYPE = 192, + MAX_ALLOWED_VALUETYPE = 192, // A value of type llvm::TokenTy token = 248, @@ -434,43 +434,43 @@ namespace llvm { SimpleTy == MVT::iPTRAny); } - /// Return a vector with the same number of elements as this vector, but - /// with the element type converted to an integer type with the same - /// bitwidth. - MVT changeVectorElementTypeToInteger() const { - MVT EltTy = getVectorElementType(); - MVT IntTy = MVT::getIntegerVT(EltTy.getSizeInBits()); - MVT VecTy = MVT::getVectorVT(IntTy, getVectorElementCount()); - assert(VecTy.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE && - "Simple vector VT not representable by simple integer vector VT!"); - return VecTy; - } - - /// Return a VT for a vector type whose attributes match ourselves - /// with the exception of the element type that is chosen by the caller. - MVT changeVectorElementType(MVT EltVT) const { - MVT VecTy = MVT::getVectorVT(EltVT, getVectorElementCount()); - assert(VecTy.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE && - "Simple vector VT not representable by simple integer vector VT!"); - return VecTy; - } - - /// Return the type converted to an equivalently sized integer or vector - /// with integer element type. Similar to changeVectorElementTypeToInteger, - /// but also handles scalars. - MVT changeTypeToInteger() { - if (isVector()) - return changeVectorElementTypeToInteger(); - return MVT::getIntegerVT(getSizeInBits()); - } - + /// Return a vector with the same number of elements as this vector, but + /// with the element type converted to an integer type with the same + /// bitwidth. + MVT changeVectorElementTypeToInteger() const { + MVT EltTy = getVectorElementType(); + MVT IntTy = MVT::getIntegerVT(EltTy.getSizeInBits()); + MVT VecTy = MVT::getVectorVT(IntTy, getVectorElementCount()); + assert(VecTy.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE && + "Simple vector VT not representable by simple integer vector VT!"); + return VecTy; + } + + /// Return a VT for a vector type whose attributes match ourselves + /// with the exception of the element type that is chosen by the caller. + MVT changeVectorElementType(MVT EltVT) const { + MVT VecTy = MVT::getVectorVT(EltVT, getVectorElementCount()); + assert(VecTy.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE && + "Simple vector VT not representable by simple integer vector VT!"); + return VecTy; + } + + /// Return the type converted to an equivalently sized integer or vector + /// with integer element type. Similar to changeVectorElementTypeToInteger, + /// but also handles scalars. + MVT changeTypeToInteger() { + if (isVector()) + return changeVectorElementTypeToInteger(); + return MVT::getIntegerVT(getSizeInBits()); + } + /// Return a VT for a vector type with the same element type but /// half the number of elements. MVT getHalfNumVectorElementsVT() const { MVT EltVT = getVectorElementType(); auto EltCnt = getVectorElementCount(); - assert(EltCnt.isKnownEven() && "Splitting vector, but not in half!"); - return getVectorVT(EltVT, EltCnt.divideCoefficientBy(2)); + assert(EltCnt.isKnownEven() && "Splitting vector, but not in half!"); + return getVectorVT(EltVT, EltCnt.divideCoefficientBy(2)); } /// Returns true if the given vector is a power of 2. @@ -574,9 +574,9 @@ namespace llvm { case v8i64: case v16i64: case v32i64: - case v64i64: - case v128i64: - case v256i64: + case v64i64: + case v128i64: + case v256i64: case nxv1i64: case nxv2i64: case nxv4i64: @@ -634,9 +634,9 @@ namespace llvm { case v8f64: case v16f64: case v32f64: - case v64f64: - case v128f64: - case v256f64: + case v64f64: + case v128f64: + case v256f64: case nxv1f64: case nxv2f64: case nxv4f64: @@ -659,27 +659,27 @@ namespace llvm { case v256i1: case v256i8: case v256i32: - case v256i64: - case v256f32: - case v256f64: return 256; + case v256i64: + case v256f32: + case v256f64: return 256; case v128i1: case v128i8: case v128i16: case v128i32: - case v128i64: + case v128i64: case v128f16: case v128bf16: - case v128f32: - case v128f64: return 128; + case v128f32: + case v128f64: return 128; case v64i1: case v64i8: case v64i16: case v64i32: - case v64i64: + case v64i64: case v64f16: case v64bf16: case v64f32: - case v64f64: + case v64f64: case nxv64i1: case nxv64i8: return 64; case v32i1: @@ -794,12 +794,12 @@ namespace llvm { } ElementCount getVectorElementCount() const { - return ElementCount::get(getVectorNumElements(), isScalableVector()); + return ElementCount::get(getVectorNumElements(), isScalableVector()); } /// Given a vector type, return the minimum number of elements it contains. unsigned getVectorMinNumElements() const { - return getVectorElementCount().getKnownMinValue(); + return getVectorElementCount().getKnownMinValue(); } /// Returns the size of the specified MVT in bits. @@ -967,37 +967,37 @@ namespace llvm { case v32f64: return TypeSize::Fixed(2048); case nxv32i64: return TypeSize::Scalable(2048); case v128i32: - case v64i64: - case v128f32: - case v64f64: return TypeSize::Fixed(4096); + case v64i64: + case v128f32: + case v64f64: return TypeSize::Fixed(4096); case v256i32: - case v128i64: - case v256f32: - case x86amx: - case v128f64: return TypeSize::Fixed(8192); + case v128i64: + case v256f32: + case x86amx: + case v128f64: return TypeSize::Fixed(8192); case v512i32: - case v256i64: - case v512f32: - case v256f64: return TypeSize::Fixed(16384); + case v256i64: + case v512f32: + case v256f64: return TypeSize::Fixed(16384); case v1024i32: case v1024f32: return TypeSize::Fixed(32768); case v2048i32: case v2048f32: return TypeSize::Fixed(65536); - case funcref: - case externref: return TypeSize::Fixed(0); // opaque type + case funcref: + case externref: return TypeSize::Fixed(0); // opaque type } } - /// Return the size of the specified fixed width value type in bits. The - /// function will assert if the type is scalable. - uint64_t getFixedSizeInBits() const { - return getSizeInBits().getFixedSize(); + /// Return the size of the specified fixed width value type in bits. The + /// function will assert if the type is scalable. + uint64_t getFixedSizeInBits() const { + return getSizeInBits().getFixedSize(); + } + + uint64_t getScalarSizeInBits() const { + return getScalarType().getSizeInBits().getFixedSize(); } - uint64_t getScalarSizeInBits() const { - return getScalarType().getSizeInBits().getFixedSize(); - } - /// Return the number of bytes overwritten by a store of the specified value /// type. /// @@ -1021,56 +1021,56 @@ namespace llvm { /// Returns true if the number of bits for the type is a multiple of an /// 8-bit byte. - bool isByteSized() const { return getSizeInBits().isKnownMultipleOf(8); } - - /// Return true if we know at compile time this has more bits than VT. - bool knownBitsGT(MVT VT) const { - return TypeSize::isKnownGT(getSizeInBits(), VT.getSizeInBits()); + bool isByteSized() const { return getSizeInBits().isKnownMultipleOf(8); } + + /// Return true if we know at compile time this has more bits than VT. + bool knownBitsGT(MVT VT) const { + return TypeSize::isKnownGT(getSizeInBits(), VT.getSizeInBits()); + } + + /// Return true if we know at compile time this has more than or the same + /// bits as VT. + bool knownBitsGE(MVT VT) const { + return TypeSize::isKnownGE(getSizeInBits(), VT.getSizeInBits()); + } + + /// Return true if we know at compile time this has fewer bits than VT. + bool knownBitsLT(MVT VT) const { + return TypeSize::isKnownLT(getSizeInBits(), VT.getSizeInBits()); + } + + /// Return true if we know at compile time this has fewer than or the same + /// bits as VT. + bool knownBitsLE(MVT VT) const { + return TypeSize::isKnownLE(getSizeInBits(), VT.getSizeInBits()); } - /// Return true if we know at compile time this has more than or the same - /// bits as VT. - bool knownBitsGE(MVT VT) const { - return TypeSize::isKnownGE(getSizeInBits(), VT.getSizeInBits()); - } - - /// Return true if we know at compile time this has fewer bits than VT. - bool knownBitsLT(MVT VT) const { - return TypeSize::isKnownLT(getSizeInBits(), VT.getSizeInBits()); - } - - /// Return true if we know at compile time this has fewer than or the same - /// bits as VT. - bool knownBitsLE(MVT VT) const { - return TypeSize::isKnownLE(getSizeInBits(), VT.getSizeInBits()); - } - /// Return true if this has more bits than VT. bool bitsGT(MVT VT) const { - assert(isScalableVector() == VT.isScalableVector() && - "Comparison between scalable and fixed types"); - return knownBitsGT(VT); + assert(isScalableVector() == VT.isScalableVector() && + "Comparison between scalable and fixed types"); + return knownBitsGT(VT); } /// Return true if this has no less bits than VT. bool bitsGE(MVT VT) const { - assert(isScalableVector() == VT.isScalableVector() && - "Comparison between scalable and fixed types"); - return knownBitsGE(VT); + assert(isScalableVector() == VT.isScalableVector() && + "Comparison between scalable and fixed types"); + return knownBitsGE(VT); } /// Return true if this has less bits than VT. bool bitsLT(MVT VT) const { - assert(isScalableVector() == VT.isScalableVector() && - "Comparison between scalable and fixed types"); - return knownBitsLT(VT); + assert(isScalableVector() == VT.isScalableVector() && + "Comparison between scalable and fixed types"); + return knownBitsLT(VT); } /// Return true if this has no more bits than VT. bool bitsLE(MVT VT) const { - assert(isScalableVector() == VT.isScalableVector() && - "Comparison between scalable and fixed types"); - return knownBitsLE(VT); + assert(isScalableVector() == VT.isScalableVector() && + "Comparison between scalable and fixed types"); + return knownBitsLE(VT); } static MVT getFloatingPointVT(unsigned BitWidth) { @@ -1171,9 +1171,9 @@ namespace llvm { if (NumElements == 8) return MVT::v8i64; if (NumElements == 16) return MVT::v16i64; if (NumElements == 32) return MVT::v32i64; - if (NumElements == 64) return MVT::v64i64; - if (NumElements == 128) return MVT::v128i64; - if (NumElements == 256) return MVT::v256i64; + if (NumElements == 64) return MVT::v64i64; + if (NumElements == 128) return MVT::v128i64; + if (NumElements == 256) return MVT::v256i64; break; case MVT::i128: if (NumElements == 1) return MVT::v1i128; @@ -1221,9 +1221,9 @@ namespace llvm { if (NumElements == 8) return MVT::v8f64; if (NumElements == 16) return MVT::v16f64; if (NumElements == 32) return MVT::v32f64; - if (NumElements == 64) return MVT::v64f64; - if (NumElements == 128) return MVT::v128f64; - if (NumElements == 256) return MVT::v256f64; + if (NumElements == 64) return MVT::v64f64; + if (NumElements == 128) return MVT::v128f64; + if (NumElements == 256) return MVT::v256f64; break; } return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE); @@ -1312,9 +1312,9 @@ namespace llvm { } static MVT getVectorVT(MVT VT, ElementCount EC) { - if (EC.isScalable()) - return getScalableVectorVT(VT, EC.getKnownMinValue()); - return getVectorVT(VT, EC.getKnownMinValue()); + if (EC.isScalable()) + return getScalableVectorVT(VT, EC.getKnownMinValue()); + return getVectorVT(VT, EC.getKnownMinValue()); } /// Return the value type corresponding to the specified type. This returns diff --git a/contrib/libs/llvm12/include/llvm/Support/MathExtras.h b/contrib/libs/llvm12/include/llvm/Support/MathExtras.h index 367b6478a1..9b5304b084 100644 --- a/contrib/libs/llvm12/include/llvm/Support/MathExtras.h +++ b/contrib/libs/llvm12/include/llvm/Support/MathExtras.h @@ -447,7 +447,7 @@ inline uint64_t maxUIntN(uint64_t N) { inline int64_t minIntN(int64_t N) { assert(N > 0 && N <= 64 && "integer width out of range"); - return UINT64_C(1) + ~(UINT64_C(1) << (N - 1)); + return UINT64_C(1) + ~(UINT64_C(1) << (N - 1)); } /// Gets the maximum value for a N-bit signed integer. diff --git a/contrib/libs/llvm12/include/llvm/Support/MemoryBuffer.h b/contrib/libs/llvm12/include/llvm/Support/MemoryBuffer.h index cf7eed4703..4359b03ffd 100644 --- a/contrib/libs/llvm12/include/llvm/Support/MemoryBuffer.h +++ b/contrib/libs/llvm12/include/llvm/Support/MemoryBuffer.h @@ -26,7 +26,7 @@ #include "llvm/ADT/Twine.h" #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/ErrorOr.h" -#include "llvm/Support/MemoryBufferRef.h" +#include "llvm/Support/MemoryBufferRef.h" #include <cstddef> #include <cstdint> #include <memory> diff --git a/contrib/libs/llvm12/include/llvm/Support/MemoryBufferRef.h b/contrib/libs/llvm12/include/llvm/Support/MemoryBufferRef.h index 54aa49334e..cc387b7fb7 100644 --- a/contrib/libs/llvm12/include/llvm/Support/MemoryBufferRef.h +++ b/contrib/libs/llvm12/include/llvm/Support/MemoryBufferRef.h @@ -1,67 +1,67 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- MemoryBufferRef.h - Memory Buffer Reference --------------*- 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 -// -//===----------------------------------------------------------------------===// -// -// This file defines the MemoryBuffer interface. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_MEMORYBUFFERREF_H -#define LLVM_SUPPORT_MEMORYBUFFERREF_H - -#include "llvm/ADT/StringRef.h" - -namespace llvm { - -class MemoryBuffer; - -class MemoryBufferRef { - StringRef Buffer; - StringRef Identifier; - -public: - MemoryBufferRef() = default; - MemoryBufferRef(const MemoryBuffer &Buffer); - MemoryBufferRef(StringRef Buffer, StringRef Identifier) - : Buffer(Buffer), Identifier(Identifier) {} - - StringRef getBuffer() const { return Buffer; } - StringRef getBufferIdentifier() const { return Identifier; } - - const char *getBufferStart() const { return Buffer.begin(); } - const char *getBufferEnd() const { return Buffer.end(); } - size_t getBufferSize() const { return Buffer.size(); } - - /// Check pointer identity (not value) of identifier and data. - friend bool operator==(const MemoryBufferRef &LHS, - const MemoryBufferRef &RHS) { - return LHS.Buffer.begin() == RHS.Buffer.begin() && - LHS.Buffer.end() == RHS.Buffer.end() && - LHS.Identifier.begin() == RHS.Identifier.begin() && - LHS.Identifier.end() == RHS.Identifier.end(); - } - - friend bool operator!=(const MemoryBufferRef &LHS, - const MemoryBufferRef &RHS) { - return !(LHS == RHS); - } -}; - -} // namespace llvm - -#endif // LLVM_SUPPORT_MEMORYBUFFERREF_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- MemoryBufferRef.h - Memory Buffer Reference --------------*- 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 +// +//===----------------------------------------------------------------------===// +// +// This file defines the MemoryBuffer interface. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_MEMORYBUFFERREF_H +#define LLVM_SUPPORT_MEMORYBUFFERREF_H + +#include "llvm/ADT/StringRef.h" + +namespace llvm { + +class MemoryBuffer; + +class MemoryBufferRef { + StringRef Buffer; + StringRef Identifier; + +public: + MemoryBufferRef() = default; + MemoryBufferRef(const MemoryBuffer &Buffer); + MemoryBufferRef(StringRef Buffer, StringRef Identifier) + : Buffer(Buffer), Identifier(Identifier) {} + + StringRef getBuffer() const { return Buffer; } + StringRef getBufferIdentifier() const { return Identifier; } + + const char *getBufferStart() const { return Buffer.begin(); } + const char *getBufferEnd() const { return Buffer.end(); } + size_t getBufferSize() const { return Buffer.size(); } + + /// Check pointer identity (not value) of identifier and data. + friend bool operator==(const MemoryBufferRef &LHS, + const MemoryBufferRef &RHS) { + return LHS.Buffer.begin() == RHS.Buffer.begin() && + LHS.Buffer.end() == RHS.Buffer.end() && + LHS.Identifier.begin() == RHS.Identifier.begin() && + LHS.Identifier.end() == RHS.Identifier.end(); + } + + friend bool operator!=(const MemoryBufferRef &LHS, + const MemoryBufferRef &RHS) { + return !(LHS == RHS); + } +}; + +} // namespace llvm + +#endif // LLVM_SUPPORT_MEMORYBUFFERREF_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/Support/Parallel.h b/contrib/libs/llvm12/include/llvm/Support/Parallel.h index 4adcf04c2f..ac053bb4cc 100644 --- a/contrib/libs/llvm12/include/llvm/Support/Parallel.h +++ b/contrib/libs/llvm12/include/llvm/Support/Parallel.h @@ -18,7 +18,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Config/llvm-config.h" -#include "llvm/Support/Error.h" +#include "llvm/Support/Error.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/Threading.h" @@ -128,17 +128,17 @@ void parallel_sort(RandomAccessIterator Start, RandomAccessIterator End, llvm::Log2_64(std::distance(Start, End)) + 1); } -// TaskGroup has a relatively high overhead, so we want to reduce -// the number of spawn() calls. We'll create up to 1024 tasks here. -// (Note that 1024 is an arbitrary number. This code probably needs -// improving to take the number of available cores into account.) -enum { MaxTasksPerGroup = 1024 }; - +// TaskGroup has a relatively high overhead, so we want to reduce +// the number of spawn() calls. We'll create up to 1024 tasks here. +// (Note that 1024 is an arbitrary number. This code probably needs +// improving to take the number of available cores into account.) +enum { MaxTasksPerGroup = 1024 }; + template <class IterTy, class FuncTy> void parallel_for_each(IterTy Begin, IterTy End, FuncTy Fn) { - // Limit the number of tasks to MaxTasksPerGroup to limit job scheduling - // overhead on large inputs. - ptrdiff_t TaskSize = std::distance(Begin, End) / MaxTasksPerGroup; + // Limit the number of tasks to MaxTasksPerGroup to limit job scheduling + // overhead on large inputs. + ptrdiff_t TaskSize = std::distance(Begin, End) / MaxTasksPerGroup; if (TaskSize == 0) TaskSize = 1; @@ -152,9 +152,9 @@ void parallel_for_each(IterTy Begin, IterTy End, FuncTy Fn) { template <class IndexTy, class FuncTy> void parallel_for_each_n(IndexTy Begin, IndexTy End, FuncTy Fn) { - // Limit the number of tasks to MaxTasksPerGroup to limit job scheduling - // overhead on large inputs. - ptrdiff_t TaskSize = (End - Begin) / MaxTasksPerGroup; + // Limit the number of tasks to MaxTasksPerGroup to limit job scheduling + // overhead on large inputs. + ptrdiff_t TaskSize = (End - Begin) / MaxTasksPerGroup; if (TaskSize == 0) TaskSize = 1; @@ -170,50 +170,50 @@ void parallel_for_each_n(IndexTy Begin, IndexTy End, FuncTy Fn) { Fn(J); } -template <class IterTy, class ResultTy, class ReduceFuncTy, - class TransformFuncTy> -ResultTy parallel_transform_reduce(IterTy Begin, IterTy End, ResultTy Init, - ReduceFuncTy Reduce, - TransformFuncTy Transform) { - // Limit the number of tasks to MaxTasksPerGroup to limit job scheduling - // overhead on large inputs. - size_t NumInputs = std::distance(Begin, End); - if (NumInputs == 0) - return std::move(Init); - size_t NumTasks = std::min(static_cast<size_t>(MaxTasksPerGroup), NumInputs); - std::vector<ResultTy> Results(NumTasks, Init); - { - // Each task processes either TaskSize or TaskSize+1 inputs. Any inputs - // remaining after dividing them equally amongst tasks are distributed as - // one extra input over the first tasks. - TaskGroup TG; - size_t TaskSize = NumInputs / NumTasks; - size_t RemainingInputs = NumInputs % NumTasks; - IterTy TBegin = Begin; - for (size_t TaskId = 0; TaskId < NumTasks; ++TaskId) { - IterTy TEnd = TBegin + TaskSize + (TaskId < RemainingInputs ? 1 : 0); - TG.spawn([=, &Transform, &Reduce, &Results] { - // Reduce the result of transformation eagerly within each task. - ResultTy R = Init; - for (IterTy It = TBegin; It != TEnd; ++It) - R = Reduce(R, Transform(*It)); - Results[TaskId] = R; - }); - TBegin = TEnd; - } - assert(TBegin == End); - } - - // Do a final reduction. There are at most 1024 tasks, so this only adds - // constant single-threaded overhead for large inputs. Hopefully most - // reductions are cheaper than the transformation. - ResultTy FinalResult = std::move(Results.front()); - for (ResultTy &PartialResult : - makeMutableArrayRef(Results.data() + 1, Results.size() - 1)) - FinalResult = Reduce(FinalResult, std::move(PartialResult)); - return std::move(FinalResult); -} - +template <class IterTy, class ResultTy, class ReduceFuncTy, + class TransformFuncTy> +ResultTy parallel_transform_reduce(IterTy Begin, IterTy End, ResultTy Init, + ReduceFuncTy Reduce, + TransformFuncTy Transform) { + // Limit the number of tasks to MaxTasksPerGroup to limit job scheduling + // overhead on large inputs. + size_t NumInputs = std::distance(Begin, End); + if (NumInputs == 0) + return std::move(Init); + size_t NumTasks = std::min(static_cast<size_t>(MaxTasksPerGroup), NumInputs); + std::vector<ResultTy> Results(NumTasks, Init); + { + // Each task processes either TaskSize or TaskSize+1 inputs. Any inputs + // remaining after dividing them equally amongst tasks are distributed as + // one extra input over the first tasks. + TaskGroup TG; + size_t TaskSize = NumInputs / NumTasks; + size_t RemainingInputs = NumInputs % NumTasks; + IterTy TBegin = Begin; + for (size_t TaskId = 0; TaskId < NumTasks; ++TaskId) { + IterTy TEnd = TBegin + TaskSize + (TaskId < RemainingInputs ? 1 : 0); + TG.spawn([=, &Transform, &Reduce, &Results] { + // Reduce the result of transformation eagerly within each task. + ResultTy R = Init; + for (IterTy It = TBegin; It != TEnd; ++It) + R = Reduce(R, Transform(*It)); + Results[TaskId] = R; + }); + TBegin = TEnd; + } + assert(TBegin == End); + } + + // Do a final reduction. There are at most 1024 tasks, so this only adds + // constant single-threaded overhead for large inputs. Hopefully most + // reductions are cheaper than the transformation. + ResultTy FinalResult = std::move(Results.front()); + for (ResultTy &PartialResult : + makeMutableArrayRef(Results.data() + 1, Results.size() - 1)) + FinalResult = Reduce(FinalResult, std::move(PartialResult)); + return std::move(FinalResult); +} + #endif } // namespace detail @@ -256,22 +256,22 @@ void parallelForEachN(size_t Begin, size_t End, FuncTy Fn) { Fn(I); } -template <class IterTy, class ResultTy, class ReduceFuncTy, - class TransformFuncTy> -ResultTy parallelTransformReduce(IterTy Begin, IterTy End, ResultTy Init, - ReduceFuncTy Reduce, - TransformFuncTy Transform) { -#if LLVM_ENABLE_THREADS - if (parallel::strategy.ThreadsRequested != 1) { - return parallel::detail::parallel_transform_reduce(Begin, End, Init, Reduce, - Transform); - } -#endif - for (IterTy I = Begin; I != End; ++I) - Init = Reduce(std::move(Init), Transform(*I)); - return std::move(Init); -} - +template <class IterTy, class ResultTy, class ReduceFuncTy, + class TransformFuncTy> +ResultTy parallelTransformReduce(IterTy Begin, IterTy End, ResultTy Init, + ReduceFuncTy Reduce, + TransformFuncTy Transform) { +#if LLVM_ENABLE_THREADS + if (parallel::strategy.ThreadsRequested != 1) { + return parallel::detail::parallel_transform_reduce(Begin, End, Init, Reduce, + Transform); + } +#endif + for (IterTy I = Begin; I != End; ++I) + Init = Reduce(std::move(Init), Transform(*I)); + return std::move(Init); +} + // Range wrappers. template <class RangeTy, class Comparator = std::less<decltype(*std::begin(RangeTy()))>> @@ -284,31 +284,31 @@ void parallelForEach(RangeTy &&R, FuncTy Fn) { parallelForEach(std::begin(R), std::end(R), Fn); } -template <class RangeTy, class ResultTy, class ReduceFuncTy, - class TransformFuncTy> -ResultTy parallelTransformReduce(RangeTy &&R, ResultTy Init, - ReduceFuncTy Reduce, - TransformFuncTy Transform) { - return parallelTransformReduce(std::begin(R), std::end(R), Init, Reduce, - Transform); -} - -// Parallel for-each, but with error handling. -template <class RangeTy, class FuncTy> -Error parallelForEachError(RangeTy &&R, FuncTy Fn) { - // The transform_reduce algorithm requires that the initial value be copyable. - // Error objects are uncopyable. We only need to copy initial success values, - // so work around this mismatch via the C API. The C API represents success - // values with a null pointer. The joinErrors discards null values and joins - // multiple errors into an ErrorList. - return unwrap(parallelTransformReduce( - std::begin(R), std::end(R), wrap(Error::success()), - [](LLVMErrorRef Lhs, LLVMErrorRef Rhs) { - return wrap(joinErrors(unwrap(Lhs), unwrap(Rhs))); - }, - [&Fn](auto &&V) { return wrap(Fn(V)); })); -} - +template <class RangeTy, class ResultTy, class ReduceFuncTy, + class TransformFuncTy> +ResultTy parallelTransformReduce(RangeTy &&R, ResultTy Init, + ReduceFuncTy Reduce, + TransformFuncTy Transform) { + return parallelTransformReduce(std::begin(R), std::end(R), Init, Reduce, + Transform); +} + +// Parallel for-each, but with error handling. +template <class RangeTy, class FuncTy> +Error parallelForEachError(RangeTy &&R, FuncTy Fn) { + // The transform_reduce algorithm requires that the initial value be copyable. + // Error objects are uncopyable. We only need to copy initial success values, + // so work around this mismatch via the C API. The C API represents success + // values with a null pointer. The joinErrors discards null values and joins + // multiple errors into an ErrorList. + return unwrap(parallelTransformReduce( + std::begin(R), std::end(R), wrap(Error::success()), + [](LLVMErrorRef Lhs, LLVMErrorRef Rhs) { + return wrap(joinErrors(unwrap(Lhs), unwrap(Rhs))); + }, + [&Fn](auto &&V) { return wrap(Fn(V)); })); +} + } // namespace llvm #endif // LLVM_SUPPORT_PARALLEL_H diff --git a/contrib/libs/llvm12/include/llvm/Support/Path.h b/contrib/libs/llvm12/include/llvm/Support/Path.h index 2c4ecbdcd9..75c8b5e731 100644 --- a/contrib/libs/llvm12/include/llvm/Support/Path.h +++ b/contrib/libs/llvm12/include/llvm/Support/Path.h @@ -458,48 +458,48 @@ bool has_extension(const Twine &path, Style style = Style::native); /// Is path absolute? /// -/// According to cppreference.com, C++17 states: "An absolute path is a path -/// that unambiguously identifies the location of a file without reference to -/// an additional starting location." -/// -/// In other words, the rules are: -/// 1) POSIX style paths with nonempty root directory are absolute. -/// 2) Windows style paths with nonempty root name and root directory are -/// absolute. -/// 3) No other paths are absolute. -/// -/// \see has_root_name -/// \see has_root_directory -/// +/// According to cppreference.com, C++17 states: "An absolute path is a path +/// that unambiguously identifies the location of a file without reference to +/// an additional starting location." +/// +/// In other words, the rules are: +/// 1) POSIX style paths with nonempty root directory are absolute. +/// 2) Windows style paths with nonempty root name and root directory are +/// absolute. +/// 3) No other paths are absolute. +/// +/// \see has_root_name +/// \see has_root_directory +/// /// @param path Input path. /// @result True if the path is absolute, false if it is not. bool is_absolute(const Twine &path, Style style = Style::native); -/// Is path absolute using GNU rules? -/// -/// GNU rules are: -/// 1) Paths starting with a path separator are absolute. -/// 2) Windows style paths are also absolute if they start with a character -/// followed by ':'. -/// 3) No other paths are absolute. -/// -/// On Windows style the path "C:\Users\Default" has "C:" as root name and "\" -/// as root directory. -/// -/// Hence "C:" on Windows is absolute under GNU rules and not absolute under -/// C++17 because it has no root directory. Likewise "/" and "\" on Windows are -/// absolute under GNU and are not absolute under C++17 due to empty root name. -/// -/// \see has_root_name -/// \see has_root_directory -/// -/// @param path Input path. -/// @param style The style of \p path (e.g. Windows or POSIX). "native" style -/// means to derive the style from the host. -/// @result True if the path is absolute following GNU rules, false if it is -/// not. -bool is_absolute_gnu(const Twine &path, Style style = Style::native); - +/// Is path absolute using GNU rules? +/// +/// GNU rules are: +/// 1) Paths starting with a path separator are absolute. +/// 2) Windows style paths are also absolute if they start with a character +/// followed by ':'. +/// 3) No other paths are absolute. +/// +/// On Windows style the path "C:\Users\Default" has "C:" as root name and "\" +/// as root directory. +/// +/// Hence "C:" on Windows is absolute under GNU rules and not absolute under +/// C++17 because it has no root directory. Likewise "/" and "\" on Windows are +/// absolute under GNU and are not absolute under C++17 due to empty root name. +/// +/// \see has_root_name +/// \see has_root_directory +/// +/// @param path Input path. +/// @param style The style of \p path (e.g. Windows or POSIX). "native" style +/// means to derive the style from the host. +/// @result True if the path is absolute following GNU rules, false if it is +/// not. +bool is_absolute_gnu(const Twine &path, Style style = Style::native); + /// Is path relative? /// /// @param path Input path. diff --git a/contrib/libs/llvm12/include/llvm/Support/PluginLoader.h b/contrib/libs/llvm12/include/llvm/Support/PluginLoader.h index 6bc230d7a5..31598eddae 100644 --- a/contrib/libs/llvm12/include/llvm/Support/PluginLoader.h +++ b/contrib/libs/llvm12/include/llvm/Support/PluginLoader.h @@ -23,12 +23,12 @@ #ifndef LLVM_SUPPORT_PLUGINLOADER_H #define LLVM_SUPPORT_PLUGINLOADER_H -#ifndef DONT_GET_PLUGIN_LOADER_OPTION +#ifndef DONT_GET_PLUGIN_LOADER_OPTION #include "llvm/Support/CommandLine.h" -#endif +#endif + +#include <string> -#include <string> - namespace llvm { struct PluginLoader { void operator=(const std::string &Filename); diff --git a/contrib/libs/llvm12/include/llvm/Support/Process.h b/contrib/libs/llvm12/include/llvm/Support/Process.h index 045dcf5cfd..1a605bd085 100644 --- a/contrib/libs/llvm12/include/llvm/Support/Process.h +++ b/contrib/libs/llvm12/include/llvm/Support/Process.h @@ -36,7 +36,7 @@ #include "llvm/Support/Chrono.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Error.h" -#include "llvm/Support/Program.h" +#include "llvm/Support/Program.h" #include <system_error> namespace llvm { @@ -115,12 +115,12 @@ public: /// considered. static Optional<std::string> FindInEnvPath(StringRef EnvName, StringRef FileName, - ArrayRef<std::string> IgnoreList, - char Separator = EnvPathSeparator); + ArrayRef<std::string> IgnoreList, + char Separator = EnvPathSeparator); static Optional<std::string> FindInEnvPath(StringRef EnvName, - StringRef FileName, - char Separator = EnvPathSeparator); + StringRef FileName, + char Separator = EnvPathSeparator); // This functions ensures that the standard file descriptors (input, output, // and error) are properly mapped to a file descriptor before we use any of @@ -220,9 +220,9 @@ public: /// Equivalent to ::exit(), except when running inside a CrashRecoveryContext. /// In that case, the control flow will resume after RunSafely(), like for a /// crash, rather than exiting the current process. - /// Use \arg NoCleanup for calling _exit() instead of exit(). + /// Use \arg NoCleanup for calling _exit() instead of exit(). LLVM_ATTRIBUTE_NORETURN - static void Exit(int RetCode, bool NoCleanup = false); + static void Exit(int RetCode, bool NoCleanup = false); }; } diff --git a/contrib/libs/llvm12/include/llvm/Support/Program.h b/contrib/libs/llvm12/include/llvm/Support/Program.h index aee27fd301..da32d52f2a 100644 --- a/contrib/libs/llvm12/include/llvm/Support/Program.h +++ b/contrib/libs/llvm12/include/llvm/Support/Program.h @@ -21,7 +21,7 @@ #define LLVM_SUPPORT_PROGRAM_H #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/BitVector.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/Config/llvm-config.h" @@ -44,7 +44,7 @@ namespace sys { typedef unsigned long procid_t; // Must match the type of DWORD on Windows. typedef void *process_t; // Must match the type of HANDLE on Windows. #else - typedef ::pid_t procid_t; + typedef ::pid_t procid_t; typedef procid_t process_t; #endif @@ -133,11 +133,11 @@ namespace sys { ///< string is non-empty upon return an error occurred while invoking the ///< program. bool *ExecutionFailed = nullptr, - Optional<ProcessStatistics> *ProcStat = nullptr, ///< If non-zero, - /// provides a pointer to a structure in which process execution - /// statistics will be stored. - BitVector *AffinityMask = nullptr ///< CPUs or processors the new - /// program shall run on. + Optional<ProcessStatistics> *ProcStat = nullptr, ///< If non-zero, + /// provides a pointer to a structure in which process execution + /// statistics will be stored. + BitVector *AffinityMask = nullptr ///< CPUs or processors the new + /// program shall run on. ); /// Similar to ExecuteAndWait, but returns immediately. @@ -150,8 +150,8 @@ namespace sys { ArrayRef<Optional<StringRef>> Redirects = {}, unsigned MemoryLimit = 0, std::string *ErrMsg = nullptr, - bool *ExecutionFailed = nullptr, - BitVector *AffinityMask = nullptr); + bool *ExecutionFailed = nullptr, + BitVector *AffinityMask = nullptr); /// Return true if the given arguments fit within system-specific /// argument length limits. @@ -229,7 +229,7 @@ namespace sys { /// to build a single flat command line appropriate for calling CreateProcess /// on /// Windows. - ErrorOr<std::wstring> flattenWindowsCommandLine(ArrayRef<StringRef> Args); + ErrorOr<std::wstring> flattenWindowsCommandLine(ArrayRef<StringRef> Args); #endif } } diff --git a/contrib/libs/llvm12/include/llvm/Support/RISCVTargetParser.def b/contrib/libs/llvm12/include/llvm/Support/RISCVTargetParser.def index 262a4f6939..6a06f92581 100644 --- a/contrib/libs/llvm12/include/llvm/Support/RISCVTargetParser.def +++ b/contrib/libs/llvm12/include/llvm/Support/RISCVTargetParser.def @@ -1,13 +1,13 @@ -#ifndef PROC_ALIAS -#define PROC_ALIAS(NAME, RV32, RV64) -#endif - -PROC_ALIAS("generic", "generic-rv32", "generic-rv64") -PROC_ALIAS("rocket", "rocket-rv32", "rocket-rv64") -PROC_ALIAS("sifive-7-series", "sifive-7-rv32", "sifive-7-rv64") - -#undef PROC_ALIAS - +#ifndef PROC_ALIAS +#define PROC_ALIAS(NAME, RV32, RV64) +#endif + +PROC_ALIAS("generic", "generic-rv32", "generic-rv64") +PROC_ALIAS("rocket", "rocket-rv32", "rocket-rv64") +PROC_ALIAS("sifive-7-series", "sifive-7-rv32", "sifive-7-rv64") + +#undef PROC_ALIAS + #ifndef PROC #define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) #endif @@ -17,11 +17,11 @@ PROC(GENERIC_RV32, {"generic-rv32"}, FK_NONE, {""}) PROC(GENERIC_RV64, {"generic-rv64"}, FK_64BIT, {""}) PROC(ROCKET_RV32, {"rocket-rv32"}, FK_NONE, {""}) PROC(ROCKET_RV64, {"rocket-rv64"}, FK_64BIT, {""}) -PROC(SIFIVE_732, {"sifive-7-rv32"}, FK_NONE, {""}) -PROC(SIFIVE_764, {"sifive-7-rv64"}, FK_64BIT, {""}) +PROC(SIFIVE_732, {"sifive-7-rv32"}, FK_NONE, {""}) +PROC(SIFIVE_764, {"sifive-7-rv64"}, FK_64BIT, {""}) PROC(SIFIVE_E31, {"sifive-e31"}, FK_NONE, {"rv32imac"}) PROC(SIFIVE_U54, {"sifive-u54"}, FK_64BIT, {"rv64gc"}) -PROC(SIFIVE_E76, {"sifive-e76"}, FK_NONE, {"rv32imafc"}) -PROC(SIFIVE_U74, {"sifive-u74"}, FK_64BIT, {"rv64gc"}) +PROC(SIFIVE_E76, {"sifive-e76"}, FK_NONE, {"rv32imafc"}) +PROC(SIFIVE_U74, {"sifive-u74"}, FK_64BIT, {"rv64gc"}) #undef PROC diff --git a/contrib/libs/llvm12/include/llvm/Support/Signals.h b/contrib/libs/llvm12/include/llvm/Support/Signals.h index a1da026f1c..4a6e0a2473 100644 --- a/contrib/libs/llvm12/include/llvm/Support/Signals.h +++ b/contrib/libs/llvm12/include/llvm/Support/Signals.h @@ -57,9 +57,9 @@ namespace sys { void DisableSystemDialogsOnCrash(); /// Print the stack trace using the given \c raw_ostream object. - /// \param Depth refers to the number of stackframes to print. If not - /// specified, the entire frame is printed. - void PrintStackTrace(raw_ostream &OS, int Depth = 0); + /// \param Depth refers to the number of stackframes to print. If not + /// specified, the entire frame is printed. + void PrintStackTrace(raw_ostream &OS, int Depth = 0); // Run all registered signal handlers. void RunSignalHandlers(); @@ -124,8 +124,8 @@ namespace sys { /// Context is a system-specific failure context: it is the signal type on /// Unix; the ExceptionContext on Windows. void CleanupOnSignal(uintptr_t Context); - - void unregisterHandlers(); + + void unregisterHandlers(); } // End sys namespace } // End llvm namespace diff --git a/contrib/libs/llvm12/include/llvm/Support/Signposts.h b/contrib/libs/llvm12/include/llvm/Support/Signposts.h index 587b4a72eb..26f907fbe2 100644 --- a/contrib/libs/llvm12/include/llvm/Support/Signposts.h +++ b/contrib/libs/llvm12/include/llvm/Support/Signposts.h @@ -24,8 +24,8 @@ #ifndef LLVM_SUPPORT_SIGNPOSTS_H #define LLVM_SUPPORT_SIGNPOSTS_H -#include "llvm/ADT/StringRef.h" - +#include "llvm/ADT/StringRef.h" + namespace llvm { class SignpostEmitterImpl; @@ -40,10 +40,10 @@ public: bool isEnabled() const; - /// Begin a signposted interval for a given object. - void startInterval(const void *O, StringRef Name); - /// End a signposted interval for a given object. - void endInterval(const void *O, StringRef Name); + /// Begin a signposted interval for a given object. + void startInterval(const void *O, StringRef Name); + /// End a signposted interval for a given object. + void endInterval(const void *O, StringRef Name); }; } // end namespace llvm diff --git a/contrib/libs/llvm12/include/llvm/Support/SourceMgr.h b/contrib/libs/llvm12/include/llvm/Support/SourceMgr.h index e210c96f87..96bc515cde 100644 --- a/contrib/libs/llvm12/include/llvm/Support/SourceMgr.h +++ b/contrib/libs/llvm12/include/llvm/Support/SourceMgr.h @@ -179,11 +179,11 @@ public: std::pair<unsigned, unsigned> getLineAndColumn(SMLoc Loc, unsigned BufferID = 0) const; - /// Get a string with the \p SMLoc filename and line number - /// formatted in the standard style. - std::string getFormattedLocationNoOffset(SMLoc Loc, - bool IncludePath = false) const; - + /// Get a string with the \p SMLoc filename and line number + /// formatted in the standard style. + std::string getFormattedLocationNoOffset(SMLoc Loc, + bool IncludePath = false) const; + /// 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 FindLocForLineAndColumn(unsigned BufferID, unsigned LineNo, diff --git a/contrib/libs/llvm12/include/llvm/Support/SwapByteOrder.h b/contrib/libs/llvm12/include/llvm/Support/SwapByteOrder.h index 16a5f5460a..4e54b0adfb 100644 --- a/contrib/libs/llvm12/include/llvm/Support/SwapByteOrder.h +++ b/contrib/libs/llvm12/include/llvm/Support/SwapByteOrder.h @@ -29,7 +29,7 @@ #endif #if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \ - defined(__Fuchsia__) || defined(__EMSCRIPTEN__) + defined(__Fuchsia__) || defined(__EMSCRIPTEN__) #include <endian.h> #elif defined(_AIX) #include <sys/machine.h> diff --git a/contrib/libs/llvm12/include/llvm/Support/SymbolRemappingReader.h b/contrib/libs/llvm12/include/llvm/Support/SymbolRemappingReader.h index 0b6c37f18f..453713740a 100644 --- a/contrib/libs/llvm12/include/llvm/Support/SymbolRemappingReader.h +++ b/contrib/libs/llvm12/include/llvm/Support/SymbolRemappingReader.h @@ -75,7 +75,7 @@ namespace llvm { class SymbolRemappingParseError : public ErrorInfo<SymbolRemappingParseError> { public: - SymbolRemappingParseError(StringRef File, int64_t Line, const Twine &Message) + SymbolRemappingParseError(StringRef File, int64_t Line, const Twine &Message) : File(File), Line(Line), Message(Message.str()) {} void log(llvm::raw_ostream &OS) const override { diff --git a/contrib/libs/llvm12/include/llvm/Support/TargetOpcodes.def b/contrib/libs/llvm12/include/llvm/Support/TargetOpcodes.def index 2cc5c69728..a63d404840 100644 --- a/contrib/libs/llvm12/include/llvm/Support/TargetOpcodes.def +++ b/contrib/libs/llvm12/include/llvm/Support/TargetOpcodes.def @@ -77,10 +77,10 @@ HANDLE_TARGET_OPCODE(SUBREG_TO_REG) /// DBG_VALUE - a mapping of the llvm.dbg.value intrinsic HANDLE_TARGET_OPCODE(DBG_VALUE) -/// DBG_INSTR_REF - A mapping of llvm.dbg.value referring to the instruction -/// that defines the value, rather than a virtual register. -HANDLE_TARGET_OPCODE(DBG_INSTR_REF) - +/// DBG_INSTR_REF - A mapping of llvm.dbg.value referring to the instruction +/// that defines the value, rather than a virtual register. +HANDLE_TARGET_OPCODE(DBG_INSTR_REF) + /// DBG_LABEL - a mapping of the llvm.dbg.label intrinsic HANDLE_TARGET_OPCODE(DBG_LABEL) @@ -110,9 +110,9 @@ HANDLE_TARGET_OPCODE(BUNDLE) HANDLE_TARGET_OPCODE(LIFETIME_START) HANDLE_TARGET_OPCODE(LIFETIME_END) -/// Pseudo probe -HANDLE_TARGET_OPCODE(PSEUDO_PROBE) - +/// Pseudo probe +HANDLE_TARGET_OPCODE(PSEUDO_PROBE) + /// A Stackmap instruction captures the location of live variables at its /// position in the instruction stream. It is followed by a shadow of bytes /// that must lie within the function and not contain another stackmap. @@ -301,12 +301,12 @@ HANDLE_TARGET_OPCODE(G_INTRINSIC_TRUNC) /// INTRINSIC round intrinsic. HANDLE_TARGET_OPCODE(G_INTRINSIC_ROUND) -/// INTRINSIC round to integer intrinsic. -HANDLE_TARGET_OPCODE(G_INTRINSIC_LRINT) - -/// INTRINSIC roundeven intrinsic. -HANDLE_TARGET_OPCODE(G_INTRINSIC_ROUNDEVEN) - +/// INTRINSIC round to integer intrinsic. +HANDLE_TARGET_OPCODE(G_INTRINSIC_LRINT) + +/// INTRINSIC roundeven intrinsic. +HANDLE_TARGET_OPCODE(G_INTRINSIC_ROUNDEVEN) + /// INTRINSIC readcyclecounter HANDLE_TARGET_OPCODE(G_READCYCLECOUNTER) @@ -482,36 +482,36 @@ HANDLE_TARGET_OPCODE(G_USUBSAT) /// Generic saturating signed subtraction. HANDLE_TARGET_OPCODE(G_SSUBSAT) -/// Generic saturating unsigned left shift. -HANDLE_TARGET_OPCODE(G_USHLSAT) - -/// Generic saturating signed left shift. -HANDLE_TARGET_OPCODE(G_SSHLSAT) - -// Perform signed fixed point multiplication -HANDLE_TARGET_OPCODE(G_SMULFIX) - -// Perform unsigned fixed point multiplication -HANDLE_TARGET_OPCODE(G_UMULFIX) - -// Perform signed, saturating fixed point multiplication -HANDLE_TARGET_OPCODE(G_SMULFIXSAT) - -// Perform unsigned, saturating fixed point multiplication -HANDLE_TARGET_OPCODE(G_UMULFIXSAT) - -// Perform signed fixed point division -HANDLE_TARGET_OPCODE(G_SDIVFIX) - -// Perform unsigned fixed point division -HANDLE_TARGET_OPCODE(G_UDIVFIX) - -// Perform signed, saturating fixed point division -HANDLE_TARGET_OPCODE(G_SDIVFIXSAT) - -// Perform unsigned, saturating fixed point division -HANDLE_TARGET_OPCODE(G_UDIVFIXSAT) - +/// Generic saturating unsigned left shift. +HANDLE_TARGET_OPCODE(G_USHLSAT) + +/// Generic saturating signed left shift. +HANDLE_TARGET_OPCODE(G_SSHLSAT) + +// Perform signed fixed point multiplication +HANDLE_TARGET_OPCODE(G_SMULFIX) + +// Perform unsigned fixed point multiplication +HANDLE_TARGET_OPCODE(G_UMULFIX) + +// Perform signed, saturating fixed point multiplication +HANDLE_TARGET_OPCODE(G_SMULFIXSAT) + +// Perform unsigned, saturating fixed point multiplication +HANDLE_TARGET_OPCODE(G_UMULFIXSAT) + +// Perform signed fixed point division +HANDLE_TARGET_OPCODE(G_SDIVFIX) + +// Perform unsigned fixed point division +HANDLE_TARGET_OPCODE(G_UDIVFIX) + +// Perform signed, saturating fixed point division +HANDLE_TARGET_OPCODE(G_SDIVFIXSAT) + +// Perform unsigned, saturating fixed point division +HANDLE_TARGET_OPCODE(G_UDIVFIXSAT) + /// Generic FP addition. HANDLE_TARGET_OPCODE(G_FADD) @@ -536,9 +536,9 @@ HANDLE_TARGET_OPCODE(G_FREM) /// Generic FP exponentiation. HANDLE_TARGET_OPCODE(G_FPOW) -/// Generic FP exponentiation, with an integer exponent. -HANDLE_TARGET_OPCODE(G_FPOWI) - +/// Generic FP exponentiation, with an integer exponent. +HANDLE_TARGET_OPCODE(G_FPOWI) + /// Generic base-e exponential of a value. HANDLE_TARGET_OPCODE(G_FEXP) @@ -617,9 +617,9 @@ HANDLE_TARGET_OPCODE(G_UMIN) /// Generic unsigned integer maximum. HANDLE_TARGET_OPCODE(G_UMAX) -/// Generic integer absolute value. -HANDLE_TARGET_OPCODE(G_ABS) - +/// Generic integer absolute value. +HANDLE_TARGET_OPCODE(G_ABS) + /// Generic BRANCH instruction. This is an unconditional branch. HANDLE_TARGET_OPCODE(G_BR) @@ -704,36 +704,36 @@ HANDLE_TARGET_OPCODE(G_READ_REGISTER) /// write_register intrinsic HANDLE_TARGET_OPCODE(G_WRITE_REGISTER) -/// llvm.memcpy intrinsic -HANDLE_TARGET_OPCODE(G_MEMCPY) - -/// llvm.memmove intrinsic -HANDLE_TARGET_OPCODE(G_MEMMOVE) - -/// llvm.memset intrinsic -HANDLE_TARGET_OPCODE(G_MEMSET) - -/// Vector reductions -HANDLE_TARGET_OPCODE(G_VECREDUCE_SEQ_FADD) -HANDLE_TARGET_OPCODE(G_VECREDUCE_SEQ_FMUL) -HANDLE_TARGET_OPCODE(G_VECREDUCE_FADD) -HANDLE_TARGET_OPCODE(G_VECREDUCE_FMUL) -HANDLE_TARGET_OPCODE(G_VECREDUCE_FMAX) -HANDLE_TARGET_OPCODE(G_VECREDUCE_FMIN) -HANDLE_TARGET_OPCODE(G_VECREDUCE_ADD) -HANDLE_TARGET_OPCODE(G_VECREDUCE_MUL) -HANDLE_TARGET_OPCODE(G_VECREDUCE_AND) -HANDLE_TARGET_OPCODE(G_VECREDUCE_OR) -HANDLE_TARGET_OPCODE(G_VECREDUCE_XOR) -HANDLE_TARGET_OPCODE(G_VECREDUCE_SMAX) -HANDLE_TARGET_OPCODE(G_VECREDUCE_SMIN) -HANDLE_TARGET_OPCODE(G_VECREDUCE_UMAX) -HANDLE_TARGET_OPCODE(G_VECREDUCE_UMIN) - +/// llvm.memcpy intrinsic +HANDLE_TARGET_OPCODE(G_MEMCPY) + +/// llvm.memmove intrinsic +HANDLE_TARGET_OPCODE(G_MEMMOVE) + +/// llvm.memset intrinsic +HANDLE_TARGET_OPCODE(G_MEMSET) + +/// Vector reductions +HANDLE_TARGET_OPCODE(G_VECREDUCE_SEQ_FADD) +HANDLE_TARGET_OPCODE(G_VECREDUCE_SEQ_FMUL) +HANDLE_TARGET_OPCODE(G_VECREDUCE_FADD) +HANDLE_TARGET_OPCODE(G_VECREDUCE_FMUL) +HANDLE_TARGET_OPCODE(G_VECREDUCE_FMAX) +HANDLE_TARGET_OPCODE(G_VECREDUCE_FMIN) +HANDLE_TARGET_OPCODE(G_VECREDUCE_ADD) +HANDLE_TARGET_OPCODE(G_VECREDUCE_MUL) +HANDLE_TARGET_OPCODE(G_VECREDUCE_AND) +HANDLE_TARGET_OPCODE(G_VECREDUCE_OR) +HANDLE_TARGET_OPCODE(G_VECREDUCE_XOR) +HANDLE_TARGET_OPCODE(G_VECREDUCE_SMAX) +HANDLE_TARGET_OPCODE(G_VECREDUCE_SMIN) +HANDLE_TARGET_OPCODE(G_VECREDUCE_UMAX) +HANDLE_TARGET_OPCODE(G_VECREDUCE_UMIN) + /// Marker for the end of the generic opcode. /// This is used to check if an opcode is in the range of the /// generic opcodes. -HANDLE_TARGET_OPCODE_MARKER(PRE_ISEL_GENERIC_OPCODE_END, G_VECREDUCE_UMIN) +HANDLE_TARGET_OPCODE_MARKER(PRE_ISEL_GENERIC_OPCODE_END, G_VECREDUCE_UMIN) /// BUILTIN_OP_END - This must be the last enum value in this list. /// The target-specific post-isel opcode values start here. diff --git a/contrib/libs/llvm12/include/llvm/Support/TargetParser.h b/contrib/libs/llvm12/include/llvm/Support/TargetParser.h index c1cb7deff5..08f0298aae 100644 --- a/contrib/libs/llvm12/include/llvm/Support/TargetParser.h +++ b/contrib/libs/llvm12/include/llvm/Support/TargetParser.h @@ -69,20 +69,20 @@ enum GPUKind : uint32_t { // AMDGCN-based processors. GK_GFX600 = 32, GK_GFX601 = 33, - GK_GFX602 = 34, + GK_GFX602 = 34, GK_GFX700 = 40, GK_GFX701 = 41, GK_GFX702 = 42, GK_GFX703 = 43, GK_GFX704 = 44, - GK_GFX705 = 45, + GK_GFX705 = 45, GK_GFX801 = 50, GK_GFX802 = 51, GK_GFX803 = 52, - GK_GFX805 = 53, - GK_GFX810 = 54, + GK_GFX805 = 53, + GK_GFX810 = 54, GK_GFX900 = 60, GK_GFX902 = 61, @@ -90,18 +90,18 @@ enum GPUKind : uint32_t { GK_GFX906 = 63, GK_GFX908 = 64, GK_GFX909 = 65, - GK_GFX90C = 66, + GK_GFX90C = 66, GK_GFX1010 = 71, GK_GFX1011 = 72, GK_GFX1012 = 73, GK_GFX1030 = 75, - GK_GFX1031 = 76, - GK_GFX1032 = 77, - GK_GFX1033 = 78, + GK_GFX1031 = 76, + GK_GFX1032 = 77, + GK_GFX1033 = 78, GK_AMDGCN_FIRST = GK_GFX600, - GK_AMDGCN_LAST = GK_GFX1033, + GK_AMDGCN_LAST = GK_GFX1033, }; /// Instruction set architecture version. @@ -126,18 +126,18 @@ enum ArchFeatureKind : uint32_t { FEATURE_FAST_DENORMAL_F32 = 1 << 5, // Wavefront 32 is available. - FEATURE_WAVE32 = 1 << 6, - - // Xnack is available. - FEATURE_XNACK = 1 << 7, - - // Sram-ecc is available. - FEATURE_SRAMECC = 1 << 8, + FEATURE_WAVE32 = 1 << 6, + + // Xnack is available. + FEATURE_XNACK = 1 << 7, + + // Sram-ecc is available. + FEATURE_SRAMECC = 1 << 8, }; StringRef getArchNameAMDGCN(GPUKind AK); StringRef getArchNameR600(GPUKind AK); -StringRef getCanonicalArchName(const Triple &T, StringRef Arch); +StringRef getCanonicalArchName(const Triple &T, StringRef Arch); GPUKind parseArchAMDGCN(StringRef CPU); GPUKind parseArchR600(StringRef CPU); unsigned getArchAttrAMDGCN(GPUKind AK); @@ -169,14 +169,14 @@ enum FeatureKind : unsigned { }; bool checkCPUKind(CPUKind Kind, bool IsRV64); -bool checkTuneCPUKind(CPUKind Kind, bool IsRV64); +bool checkTuneCPUKind(CPUKind Kind, bool IsRV64); CPUKind parseCPUKind(StringRef CPU); -CPUKind parseTuneCPUKind(StringRef CPU, bool IsRV64); +CPUKind parseTuneCPUKind(StringRef CPU, bool IsRV64); StringRef getMArchFromMcpu(StringRef CPU); void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64); -void fillValidTuneCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64); +void fillValidTuneCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64); bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector<StringRef> &Features); -StringRef resolveTuneCPUAlias(StringRef TuneCPU, bool IsRV64); +StringRef resolveTuneCPUAlias(StringRef TuneCPU, bool IsRV64); } // namespace RISCV diff --git a/contrib/libs/llvm12/include/llvm/Support/TargetRegistry.h b/contrib/libs/llvm12/include/llvm/Support/TargetRegistry.h index 4191d97e7e..f0e5bd9d0a 100644 --- a/contrib/libs/llvm12/include/llvm/Support/TargetRegistry.h +++ b/contrib/libs/llvm12/include/llvm/Support/TargetRegistry.h @@ -517,8 +517,8 @@ public: S = createWasmStreamer(Ctx, std::move(TAB), std::move(OW), std::move(Emitter), RelaxAll); break; - case Triple::GOFF: - report_fatal_error("GOFF MCObjectStreamer not implemented yet"); + case Triple::GOFF: + report_fatal_error("GOFF MCObjectStreamer not implemented yet"); case Triple::XCOFF: S = createXCOFFStreamer(Ctx, std::move(TAB), std::move(OW), std::move(Emitter), RelaxAll); diff --git a/contrib/libs/llvm12/include/llvm/Support/TaskQueue.h b/contrib/libs/llvm12/include/llvm/Support/TaskQueue.h index fb0a01779e..a7ecb8f518 100644 --- a/contrib/libs/llvm12/include/llvm/Support/TaskQueue.h +++ b/contrib/libs/llvm12/include/llvm/Support/TaskQueue.h @@ -105,7 +105,7 @@ public: IsTaskInFlight = true; } } - return F; + return F; } private: diff --git a/contrib/libs/llvm12/include/llvm/Support/Threading.h b/contrib/libs/llvm12/include/llvm/Support/Threading.h index 5e34ccd1e9..2a776ce6b9 100644 --- a/contrib/libs/llvm12/include/llvm/Support/Threading.h +++ b/contrib/libs/llvm12/include/llvm/Support/Threading.h @@ -217,7 +217,7 @@ void llvm_execute_on_thread_async( return heavyweight_hardware_concurrency(); } - /// Returns a default thread strategy where all available hardware resources + /// Returns a default thread strategy where all available hardware resources /// are to be used, except for those initially excluded by an affinity mask. /// This function takes affinity into consideration. Returns 1 when LLVM is /// configured with LLVM_ENABLE_THREADS=OFF. @@ -227,16 +227,16 @@ void llvm_execute_on_thread_async( return S; } - /// Returns an optimal thread strategy to execute specified amount of tasks. - /// This strategy should prevent us from creating too many threads if we - /// occasionaly have an unexpectedly small amount of tasks. - inline ThreadPoolStrategy optimal_concurrency(unsigned TaskCount = 0) { - ThreadPoolStrategy S; - S.Limit = true; - S.ThreadsRequested = TaskCount; - return S; - } - + /// Returns an optimal thread strategy to execute specified amount of tasks. + /// This strategy should prevent us from creating too many threads if we + /// occasionaly have an unexpectedly small amount of tasks. + inline ThreadPoolStrategy optimal_concurrency(unsigned TaskCount = 0) { + ThreadPoolStrategy S; + S.Limit = true; + S.ThreadsRequested = TaskCount; + return S; + } + /// Return the current thread id, as used in various OS system calls. /// Note that not all platforms guarantee that the value returned will be /// unique across the entire system, so portable code should not assume diff --git a/contrib/libs/llvm12/include/llvm/Support/ToolOutputFile.h b/contrib/libs/llvm12/include/llvm/Support/ToolOutputFile.h index bc28c600cf..f02bb455bc 100644 --- a/contrib/libs/llvm12/include/llvm/Support/ToolOutputFile.h +++ b/contrib/libs/llvm12/include/llvm/Support/ToolOutputFile.h @@ -42,7 +42,7 @@ class ToolOutputFile { /// The flag which indicates whether we should not delete the file. bool Keep; - StringRef getFilename() { return Filename; } + StringRef getFilename() { return Filename; } explicit CleanupInstaller(StringRef Filename); ~CleanupInstaller(); } Installer; @@ -65,9 +65,9 @@ public: /// Return the contained raw_fd_ostream. raw_fd_ostream &os() { return *OS; } - /// Return the filename initialized with. - StringRef getFilename() { return Installer.getFilename(); } - + /// Return the filename initialized with. + StringRef getFilename() { return Installer.getFilename(); } + /// Indicate that the tool's job wrt this output file has been successful and /// the file should not be deleted. void keep() { Installer.Keep = true; } diff --git a/contrib/libs/llvm12/include/llvm/Support/TrigramIndex.h b/contrib/libs/llvm12/include/llvm/Support/TrigramIndex.h index 5e4983cf14..d0becee24c 100644 --- a/contrib/libs/llvm12/include/llvm/Support/TrigramIndex.h +++ b/contrib/libs/llvm12/include/llvm/Support/TrigramIndex.h @@ -34,7 +34,7 @@ #define LLVM_SUPPORT_TRIGRAMINDEX_H #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/StringRef.h" #include <string> #include <unordered_map> #include <vector> @@ -45,7 +45,7 @@ class StringRef; class TrigramIndex { public: /// Inserts a new Regex into the index. - void insert(const std::string &Regex); + void insert(const std::string &Regex); /// Returns true, if special case list definitely does not have a line /// that matches the query. Returns false, if it's not sure. diff --git a/contrib/libs/llvm12/include/llvm/Support/TypeSize.h b/contrib/libs/llvm12/include/llvm/Support/TypeSize.h index 04e610ff14..f6b3393098 100644 --- a/contrib/libs/llvm12/include/llvm/Support/TypeSize.h +++ b/contrib/libs/llvm12/include/llvm/Support/TypeSize.h @@ -22,418 +22,418 @@ #ifndef LLVM_SUPPORT_TYPESIZE_H #define LLVM_SUPPORT_TYPESIZE_H -#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/WithColor.h" -#include <algorithm> -#include <array> -#include <cassert> +#include <algorithm> +#include <array> +#include <cassert> #include <cstdint> -#include <type_traits> +#include <type_traits> namespace llvm { -template <typename LeafTy> struct LinearPolyBaseTypeTraits {}; - -//===----------------------------------------------------------------------===// -// LinearPolyBase - a base class for linear polynomials with multiple -// dimensions. This can e.g. be used to describe offsets that are have both a -// fixed and scalable component. -//===----------------------------------------------------------------------===// - -/// LinearPolyBase describes a linear polynomial: -/// c0 * scale0 + c1 * scale1 + ... + cK * scaleK -/// where the scale is implicit, so only the coefficients are encoded. -template <typename LeafTy> -class LinearPolyBase { +template <typename LeafTy> struct LinearPolyBaseTypeTraits {}; + +//===----------------------------------------------------------------------===// +// LinearPolyBase - a base class for linear polynomials with multiple +// dimensions. This can e.g. be used to describe offsets that are have both a +// fixed and scalable component. +//===----------------------------------------------------------------------===// + +/// LinearPolyBase describes a linear polynomial: +/// c0 * scale0 + c1 * scale1 + ... + cK * scaleK +/// where the scale is implicit, so only the coefficients are encoded. +template <typename LeafTy> +class LinearPolyBase { +public: + using ScalarTy = typename LinearPolyBaseTypeTraits<LeafTy>::ScalarTy; + static constexpr auto Dimensions = LinearPolyBaseTypeTraits<LeafTy>::Dimensions; + static_assert(Dimensions != std::numeric_limits<unsigned>::max(), + "Dimensions out of range"); + +private: + std::array<ScalarTy, Dimensions> Coefficients; + +protected: + LinearPolyBase(ArrayRef<ScalarTy> Values) { + std::copy(Values.begin(), Values.end(), Coefficients.begin()); + } + +public: + friend LeafTy &operator+=(LeafTy &LHS, const LeafTy &RHS) { + for (unsigned I=0; I<Dimensions; ++I) + LHS.Coefficients[I] += RHS.Coefficients[I]; + return LHS; + } + + friend LeafTy &operator-=(LeafTy &LHS, const LeafTy &RHS) { + for (unsigned I=0; I<Dimensions; ++I) + LHS.Coefficients[I] -= RHS.Coefficients[I]; + return LHS; + } + + friend LeafTy &operator*=(LeafTy &LHS, ScalarTy RHS) { + for (auto &C : LHS.Coefficients) + C *= RHS; + return LHS; + } + + friend LeafTy operator+(const LeafTy &LHS, const LeafTy &RHS) { + LeafTy Copy = LHS; + return Copy += RHS; + } + + friend LeafTy operator-(const LeafTy &LHS, const LeafTy &RHS) { + LeafTy Copy = LHS; + return Copy -= RHS; + } + + friend LeafTy operator*(const LeafTy &LHS, ScalarTy RHS) { + LeafTy Copy = LHS; + return Copy *= RHS; + } + + template <typename U = ScalarTy> + friend typename std::enable_if_t<std::is_signed<U>::value, LeafTy> + operator-(const LeafTy &LHS) { + LeafTy Copy = LHS; + return Copy *= -1; + } + + bool operator==(const LinearPolyBase &RHS) const { + return std::equal(Coefficients.begin(), Coefficients.end(), + RHS.Coefficients.begin()); + } + + bool operator!=(const LinearPolyBase &RHS) const { + return !(*this == RHS); + } + + bool isZero() const { + return all_of(Coefficients, [](const ScalarTy &C) { return C == 0; }); + } + bool isNonZero() const { return !isZero(); } + explicit operator bool() const { return isNonZero(); } + + ScalarTy getValue(unsigned Dim) const { return Coefficients[Dim]; } +}; + +//===----------------------------------------------------------------------===// +// StackOffset - Represent an offset with named fixed and scalable components. +//===----------------------------------------------------------------------===// + +class StackOffset; +template <> struct LinearPolyBaseTypeTraits<StackOffset> { + using ScalarTy = int64_t; + static constexpr unsigned Dimensions = 2; +}; + +/// StackOffset is a class to represent an offset with 2 dimensions, +/// named fixed and scalable, respectively. This class allows a value for both +/// dimensions to depict e.g. "8 bytes and 16 scalable bytes", which is needed +/// to represent stack offsets. +class StackOffset : public LinearPolyBase<StackOffset> { +protected: + StackOffset(ScalarTy Fixed, ScalarTy Scalable) + : LinearPolyBase<StackOffset>({Fixed, Scalable}) {} + +public: + StackOffset() : StackOffset({0, 0}) {} + StackOffset(const LinearPolyBase<StackOffset> &Other) + : LinearPolyBase<StackOffset>(Other) {} + static StackOffset getFixed(ScalarTy Fixed) { return {Fixed, 0}; } + static StackOffset getScalable(ScalarTy Scalable) { return {0, Scalable}; } + static StackOffset get(ScalarTy Fixed, ScalarTy Scalable) { + return {Fixed, Scalable}; + } + + ScalarTy getFixed() const { return this->getValue(0); } + ScalarTy getScalable() const { return this->getValue(1); } +}; + +//===----------------------------------------------------------------------===// +// UnivariateLinearPolyBase - a base class for linear polynomials with multiple +// dimensions, but where only one dimension can be set at any time. +// This can e.g. be used to describe sizes that are either fixed or scalable. +//===----------------------------------------------------------------------===// + +/// UnivariateLinearPolyBase is a base class for ElementCount and TypeSize. +/// Like LinearPolyBase it tries to represent a linear polynomial +/// where only one dimension can be set at any time, e.g. +/// 0 * scale0 + 0 * scale1 + ... + cJ * scaleJ + ... + 0 * scaleK +/// The dimension that is set is the univariate dimension. +template <typename LeafTy> +class UnivariateLinearPolyBase { +public: + using ScalarTy = typename LinearPolyBaseTypeTraits<LeafTy>::ScalarTy; + static constexpr auto Dimensions = LinearPolyBaseTypeTraits<LeafTy>::Dimensions; + static_assert(Dimensions != std::numeric_limits<unsigned>::max(), + "Dimensions out of range"); + +protected: + ScalarTy Value; // The value at the univeriate dimension. + unsigned UnivariateDim; // The univeriate dimension. + + UnivariateLinearPolyBase(ScalarTy Val, unsigned UnivariateDim) + : Value(Val), UnivariateDim(UnivariateDim) { + assert(UnivariateDim < Dimensions && "Dimension out of range"); + } + + friend LeafTy &operator+=(LeafTy &LHS, const LeafTy &RHS) { + assert(LHS.UnivariateDim == RHS.UnivariateDim && "Invalid dimensions"); + LHS.Value += RHS.Value; + return LHS; + } + + friend LeafTy &operator-=(LeafTy &LHS, const LeafTy &RHS) { + assert(LHS.UnivariateDim == RHS.UnivariateDim && "Invalid dimensions"); + LHS.Value -= RHS.Value; + return LHS; + } + + friend LeafTy &operator*=(LeafTy &LHS, ScalarTy RHS) { + LHS.Value *= RHS; + return LHS; + } + + friend LeafTy operator+(const LeafTy &LHS, const LeafTy &RHS) { + LeafTy Copy = LHS; + return Copy += RHS; + } + + friend LeafTy operator-(const LeafTy &LHS, const LeafTy &RHS) { + LeafTy Copy = LHS; + return Copy -= RHS; + } + + friend LeafTy operator*(const LeafTy &LHS, ScalarTy RHS) { + LeafTy Copy = LHS; + return Copy *= RHS; + } + + template <typename U = ScalarTy> + friend typename std::enable_if<std::is_signed<U>::value, LeafTy>::type + operator-(const LeafTy &LHS) { + LeafTy Copy = LHS; + return Copy *= -1; + } + public: - using ScalarTy = typename LinearPolyBaseTypeTraits<LeafTy>::ScalarTy; - static constexpr auto Dimensions = LinearPolyBaseTypeTraits<LeafTy>::Dimensions; - static_assert(Dimensions != std::numeric_limits<unsigned>::max(), - "Dimensions out of range"); - -private: - std::array<ScalarTy, Dimensions> Coefficients; - -protected: - LinearPolyBase(ArrayRef<ScalarTy> Values) { - std::copy(Values.begin(), Values.end(), Coefficients.begin()); - } - -public: - friend LeafTy &operator+=(LeafTy &LHS, const LeafTy &RHS) { - for (unsigned I=0; I<Dimensions; ++I) - LHS.Coefficients[I] += RHS.Coefficients[I]; - return LHS; - } - - friend LeafTy &operator-=(LeafTy &LHS, const LeafTy &RHS) { - for (unsigned I=0; I<Dimensions; ++I) - LHS.Coefficients[I] -= RHS.Coefficients[I]; - return LHS; - } - - friend LeafTy &operator*=(LeafTy &LHS, ScalarTy RHS) { - for (auto &C : LHS.Coefficients) - C *= RHS; - return LHS; - } - - friend LeafTy operator+(const LeafTy &LHS, const LeafTy &RHS) { - LeafTy Copy = LHS; - return Copy += RHS; - } - - friend LeafTy operator-(const LeafTy &LHS, const LeafTy &RHS) { - LeafTy Copy = LHS; - return Copy -= RHS; - } - - friend LeafTy operator*(const LeafTy &LHS, ScalarTy RHS) { - LeafTy Copy = LHS; - return Copy *= RHS; - } - - template <typename U = ScalarTy> - friend typename std::enable_if_t<std::is_signed<U>::value, LeafTy> - operator-(const LeafTy &LHS) { - LeafTy Copy = LHS; - return Copy *= -1; - } - - bool operator==(const LinearPolyBase &RHS) const { - return std::equal(Coefficients.begin(), Coefficients.end(), - RHS.Coefficients.begin()); - } - - bool operator!=(const LinearPolyBase &RHS) const { + bool operator==(const UnivariateLinearPolyBase &RHS) const { + return Value == RHS.Value && UnivariateDim == RHS.UnivariateDim; + } + + bool operator!=(const UnivariateLinearPolyBase &RHS) const { return !(*this == RHS); } - bool isZero() const { - return all_of(Coefficients, [](const ScalarTy &C) { return C == 0; }); + bool isZero() const { return !Value; } + bool isNonZero() const { return !isZero(); } + explicit operator bool() const { return isNonZero(); } + ScalarTy getValue() const { return Value; } + ScalarTy getValue(unsigned Dim) const { + return Dim == UnivariateDim ? Value : 0; + } + + /// Add \p RHS to the value at the univariate dimension. + LeafTy getWithIncrement(ScalarTy RHS) { + return static_cast<LeafTy>( + UnivariateLinearPolyBase(Value + RHS, UnivariateDim)); + } + + /// Subtract \p RHS from the value at the univariate dimension. + LeafTy getWithDecrement(ScalarTy RHS) { + return static_cast<LeafTy>( + UnivariateLinearPolyBase(Value - RHS, UnivariateDim)); } - bool isNonZero() const { return !isZero(); } - explicit operator bool() const { return isNonZero(); } - - ScalarTy getValue(unsigned Dim) const { return Coefficients[Dim]; } }; -//===----------------------------------------------------------------------===// -// StackOffset - Represent an offset with named fixed and scalable components. -//===----------------------------------------------------------------------===// - -class StackOffset; -template <> struct LinearPolyBaseTypeTraits<StackOffset> { - using ScalarTy = int64_t; - static constexpr unsigned Dimensions = 2; -}; - -/// StackOffset is a class to represent an offset with 2 dimensions, -/// named fixed and scalable, respectively. This class allows a value for both -/// dimensions to depict e.g. "8 bytes and 16 scalable bytes", which is needed -/// to represent stack offsets. -class StackOffset : public LinearPolyBase<StackOffset> { -protected: - StackOffset(ScalarTy Fixed, ScalarTy Scalable) - : LinearPolyBase<StackOffset>({Fixed, Scalable}) {} - + +//===----------------------------------------------------------------------===// +// LinearPolySize - base class for fixed- or scalable sizes. +// ^ ^ +// | | +// | +----- ElementCount - Leaf class to represent an element count +// | (vscale x unsigned) +// | +// +-------- TypeSize - Leaf class to represent a type size +// (vscale x uint64_t) +//===----------------------------------------------------------------------===// + +/// LinearPolySize is a base class to represent sizes. It is either +/// fixed-sized or it is scalable-sized, but it cannot be both. +template <typename LeafTy> +class LinearPolySize : public UnivariateLinearPolyBase<LeafTy> { + // Make the parent class a friend, so that it can access the protected + // conversion/copy-constructor for UnivariatePolyBase<LeafTy> -> + // LinearPolySize<LeafTy>. + friend class UnivariateLinearPolyBase<LeafTy>; + +public: + using ScalarTy = typename UnivariateLinearPolyBase<LeafTy>::ScalarTy; + enum Dims : unsigned { FixedDim = 0, ScalableDim = 1 }; + +protected: + LinearPolySize(ScalarTy MinVal, Dims D) + : UnivariateLinearPolyBase<LeafTy>(MinVal, D) {} + + LinearPolySize(const UnivariateLinearPolyBase<LeafTy> &V) + : UnivariateLinearPolyBase<LeafTy>(V) {} + public: - StackOffset() : StackOffset({0, 0}) {} - StackOffset(const LinearPolyBase<StackOffset> &Other) - : LinearPolyBase<StackOffset>(Other) {} - static StackOffset getFixed(ScalarTy Fixed) { return {Fixed, 0}; } - static StackOffset getScalable(ScalarTy Scalable) { return {0, Scalable}; } - static StackOffset get(ScalarTy Fixed, ScalarTy Scalable) { - return {Fixed, Scalable}; - } - - ScalarTy getFixed() const { return this->getValue(0); } - ScalarTy getScalable() const { return this->getValue(1); } -}; - -//===----------------------------------------------------------------------===// -// UnivariateLinearPolyBase - a base class for linear polynomials with multiple -// dimensions, but where only one dimension can be set at any time. -// This can e.g. be used to describe sizes that are either fixed or scalable. -//===----------------------------------------------------------------------===// - -/// UnivariateLinearPolyBase is a base class for ElementCount and TypeSize. -/// Like LinearPolyBase it tries to represent a linear polynomial -/// where only one dimension can be set at any time, e.g. -/// 0 * scale0 + 0 * scale1 + ... + cJ * scaleJ + ... + 0 * scaleK -/// The dimension that is set is the univariate dimension. -template <typename LeafTy> -class UnivariateLinearPolyBase { -public: - using ScalarTy = typename LinearPolyBaseTypeTraits<LeafTy>::ScalarTy; - static constexpr auto Dimensions = LinearPolyBaseTypeTraits<LeafTy>::Dimensions; - static_assert(Dimensions != std::numeric_limits<unsigned>::max(), - "Dimensions out of range"); - -protected: - ScalarTy Value; // The value at the univeriate dimension. - unsigned UnivariateDim; // The univeriate dimension. - - UnivariateLinearPolyBase(ScalarTy Val, unsigned UnivariateDim) - : Value(Val), UnivariateDim(UnivariateDim) { - assert(UnivariateDim < Dimensions && "Dimension out of range"); - } - - friend LeafTy &operator+=(LeafTy &LHS, const LeafTy &RHS) { - assert(LHS.UnivariateDim == RHS.UnivariateDim && "Invalid dimensions"); - LHS.Value += RHS.Value; - return LHS; - } - - friend LeafTy &operator-=(LeafTy &LHS, const LeafTy &RHS) { - assert(LHS.UnivariateDim == RHS.UnivariateDim && "Invalid dimensions"); - LHS.Value -= RHS.Value; - return LHS; - } - - friend LeafTy &operator*=(LeafTy &LHS, ScalarTy RHS) { - LHS.Value *= RHS; - return LHS; - } - - friend LeafTy operator+(const LeafTy &LHS, const LeafTy &RHS) { - LeafTy Copy = LHS; - return Copy += RHS; - } - - friend LeafTy operator-(const LeafTy &LHS, const LeafTy &RHS) { - LeafTy Copy = LHS; - return Copy -= RHS; - } - - friend LeafTy operator*(const LeafTy &LHS, ScalarTy RHS) { - LeafTy Copy = LHS; - return Copy *= RHS; - } - - template <typename U = ScalarTy> - friend typename std::enable_if<std::is_signed<U>::value, LeafTy>::type - operator-(const LeafTy &LHS) { - LeafTy Copy = LHS; - return Copy *= -1; - } - -public: - bool operator==(const UnivariateLinearPolyBase &RHS) const { - return Value == RHS.Value && UnivariateDim == RHS.UnivariateDim; - } - - bool operator!=(const UnivariateLinearPolyBase &RHS) const { - return !(*this == RHS); - } - - bool isZero() const { return !Value; } - bool isNonZero() const { return !isZero(); } - explicit operator bool() const { return isNonZero(); } - ScalarTy getValue() const { return Value; } - ScalarTy getValue(unsigned Dim) const { - return Dim == UnivariateDim ? Value : 0; - } - - /// Add \p RHS to the value at the univariate dimension. - LeafTy getWithIncrement(ScalarTy RHS) { - return static_cast<LeafTy>( - UnivariateLinearPolyBase(Value + RHS, UnivariateDim)); - } - - /// Subtract \p RHS from the value at the univariate dimension. - LeafTy getWithDecrement(ScalarTy RHS) { - return static_cast<LeafTy>( - UnivariateLinearPolyBase(Value - RHS, UnivariateDim)); - } -}; - - -//===----------------------------------------------------------------------===// -// LinearPolySize - base class for fixed- or scalable sizes. -// ^ ^ -// | | -// | +----- ElementCount - Leaf class to represent an element count -// | (vscale x unsigned) -// | -// +-------- TypeSize - Leaf class to represent a type size -// (vscale x uint64_t) -//===----------------------------------------------------------------------===// - -/// LinearPolySize is a base class to represent sizes. It is either -/// fixed-sized or it is scalable-sized, but it cannot be both. -template <typename LeafTy> -class LinearPolySize : public UnivariateLinearPolyBase<LeafTy> { - // Make the parent class a friend, so that it can access the protected - // conversion/copy-constructor for UnivariatePolyBase<LeafTy> -> - // LinearPolySize<LeafTy>. - friend class UnivariateLinearPolyBase<LeafTy>; - -public: - using ScalarTy = typename UnivariateLinearPolyBase<LeafTy>::ScalarTy; - enum Dims : unsigned { FixedDim = 0, ScalableDim = 1 }; - -protected: - LinearPolySize(ScalarTy MinVal, Dims D) - : UnivariateLinearPolyBase<LeafTy>(MinVal, D) {} - - LinearPolySize(const UnivariateLinearPolyBase<LeafTy> &V) - : UnivariateLinearPolyBase<LeafTy>(V) {} - -public: - - static LeafTy getFixed(ScalarTy MinVal) { - return static_cast<LeafTy>(LinearPolySize(MinVal, FixedDim)); - } - static LeafTy getScalable(ScalarTy MinVal) { - return static_cast<LeafTy>(LinearPolySize(MinVal, ScalableDim)); - } - static LeafTy get(ScalarTy MinVal, bool Scalable) { - return static_cast<LeafTy>( - LinearPolySize(MinVal, Scalable ? ScalableDim : FixedDim)); - } - static LeafTy getNull() { return get(0, false); } - - /// Returns the minimum value this size can represent. - ScalarTy getKnownMinValue() const { return this->getValue(); } - /// Returns whether the size is scaled by a runtime quantity (vscale). - bool isScalable() const { return this->UnivariateDim == ScalableDim; } - /// A return value of true indicates we know at compile time that the number - /// of elements (vscale * Min) is definitely even. However, returning false - /// does not guarantee that the total number of elements is odd. - bool isKnownEven() const { return (getKnownMinValue() & 0x1) == 0; } - /// This function tells the caller whether the element count is known at - /// compile time to be a multiple of the scalar value RHS. - bool isKnownMultipleOf(ScalarTy RHS) const { - return getKnownMinValue() % RHS == 0; - } - - // Return the minimum value with the assumption that the count is exact. - // Use in places where a scalable count doesn't make sense (e.g. non-vector - // types, or vectors in backends which don't support scalable vectors). - ScalarTy getFixedValue() const { - assert(!isScalable() && - "Request for a fixed element count on a scalable object"); - return getKnownMinValue(); - } - - // For some cases, size ordering between scalable and fixed size types cannot + + static LeafTy getFixed(ScalarTy MinVal) { + return static_cast<LeafTy>(LinearPolySize(MinVal, FixedDim)); + } + static LeafTy getScalable(ScalarTy MinVal) { + return static_cast<LeafTy>(LinearPolySize(MinVal, ScalableDim)); + } + static LeafTy get(ScalarTy MinVal, bool Scalable) { + return static_cast<LeafTy>( + LinearPolySize(MinVal, Scalable ? ScalableDim : FixedDim)); + } + static LeafTy getNull() { return get(0, false); } + + /// Returns the minimum value this size can represent. + ScalarTy getKnownMinValue() const { return this->getValue(); } + /// Returns whether the size is scaled by a runtime quantity (vscale). + bool isScalable() const { return this->UnivariateDim == ScalableDim; } + /// A return value of true indicates we know at compile time that the number + /// of elements (vscale * Min) is definitely even. However, returning false + /// does not guarantee that the total number of elements is odd. + bool isKnownEven() const { return (getKnownMinValue() & 0x1) == 0; } + /// This function tells the caller whether the element count is known at + /// compile time to be a multiple of the scalar value RHS. + bool isKnownMultipleOf(ScalarTy RHS) const { + return getKnownMinValue() % RHS == 0; + } + + // Return the minimum value with the assumption that the count is exact. + // Use in places where a scalable count doesn't make sense (e.g. non-vector + // types, or vectors in backends which don't support scalable vectors). + ScalarTy getFixedValue() const { + assert(!isScalable() && + "Request for a fixed element count on a scalable object"); + return getKnownMinValue(); + } + + // For some cases, size ordering between scalable and fixed size types cannot // be determined at compile time, so such comparisons aren't allowed. // // e.g. <vscale x 2 x i16> could be bigger than <4 x i32> with a runtime // vscale >= 5, equal sized with a vscale of 4, and smaller with // a vscale <= 3. // - // All the functions below make use of the fact vscale is always >= 1, which - // means that <vscale x 4 x i32> is guaranteed to be >= <4 x i32>, etc. - - static bool isKnownLT(const LinearPolySize &LHS, const LinearPolySize &RHS) { - if (!LHS.isScalable() || RHS.isScalable()) - return LHS.getKnownMinValue() < RHS.getKnownMinValue(); - return false; - } - - static bool isKnownGT(const LinearPolySize &LHS, const LinearPolySize &RHS) { - if (LHS.isScalable() || !RHS.isScalable()) - return LHS.getKnownMinValue() > RHS.getKnownMinValue(); - return false; - } - - static bool isKnownLE(const LinearPolySize &LHS, const LinearPolySize &RHS) { - if (!LHS.isScalable() || RHS.isScalable()) - return LHS.getKnownMinValue() <= RHS.getKnownMinValue(); - return false; - } - - static bool isKnownGE(const LinearPolySize &LHS, const LinearPolySize &RHS) { - if (LHS.isScalable() || !RHS.isScalable()) - return LHS.getKnownMinValue() >= RHS.getKnownMinValue(); - return false; - } - - /// We do not provide the '/' operator here because division for polynomial - /// types does not work in the same way as for normal integer types. We can - /// only divide the minimum value (or coefficient) by RHS, which is not the - /// same as - /// (Min * Vscale) / RHS - /// The caller is recommended to use this function in combination with - /// isKnownMultipleOf(RHS), which lets the caller know if it's possible to - /// perform a lossless divide by RHS. - LeafTy divideCoefficientBy(ScalarTy RHS) const { - return static_cast<LeafTy>( - LinearPolySize::get(getKnownMinValue() / RHS, isScalable())); - } - - LeafTy coefficientNextPowerOf2() const { - return static_cast<LeafTy>(LinearPolySize::get( - static_cast<ScalarTy>(llvm::NextPowerOf2(getKnownMinValue())), - isScalable())); - } - - /// Printing function. - void print(raw_ostream &OS) const { - if (isScalable()) - OS << "vscale x "; - OS << getKnownMinValue(); - } -}; - -class ElementCount; -template <> struct LinearPolyBaseTypeTraits<ElementCount> { - using ScalarTy = unsigned; - static constexpr unsigned Dimensions = 2; -}; - -class ElementCount : public LinearPolySize<ElementCount> { -public: - - ElementCount(const LinearPolySize<ElementCount> &V) : LinearPolySize(V) {} - - /// Counting predicates. - /// - ///@{ Number of elements.. - /// Exactly one element. - bool isScalar() const { return !isScalable() && getKnownMinValue() == 1; } - /// One or more elements. - bool isVector() const { - return (isScalable() && getKnownMinValue() != 0) || getKnownMinValue() > 1; - } - ///@} -}; - -// This class is used to represent the size of types. If the type is of fixed -class TypeSize; -template <> struct LinearPolyBaseTypeTraits<TypeSize> { - using ScalarTy = uint64_t; - static constexpr unsigned Dimensions = 2; -}; - -// TODO: Most functionality in this class will gradually be phased out -// so it will resemble LinearPolySize as much as possible. -// -// TypeSize is used to represent the size of types. If the type is of fixed -// size, it will represent the exact size. If the type is a scalable vector, -// it will represent the known minimum size. -class TypeSize : public LinearPolySize<TypeSize> { -public: - TypeSize(const LinearPolySize<TypeSize> &V) : LinearPolySize(V) {} - TypeSize(ScalarTy MinVal, bool IsScalable) - : LinearPolySize(LinearPolySize::get(MinVal, IsScalable)) {} - - static TypeSize Fixed(ScalarTy MinVal) { return TypeSize(MinVal, false); } - static TypeSize Scalable(ScalarTy MinVal) { return TypeSize(MinVal, true); } - - ScalarTy getFixedSize() const { return getFixedValue(); } - ScalarTy getKnownMinSize() const { return getKnownMinValue(); } - - // All code for this class below this point is needed because of the - // temporary implicit conversion to uint64_t. The operator overloads are - // needed because otherwise the conversion of the parent class - // UnivariateLinearPolyBase -> TypeSize is ambiguous. - // TODO: Remove the implicit conversion. - + // All the functions below make use of the fact vscale is always >= 1, which + // means that <vscale x 4 x i32> is guaranteed to be >= <4 x i32>, etc. + + static bool isKnownLT(const LinearPolySize &LHS, const LinearPolySize &RHS) { + if (!LHS.isScalable() || RHS.isScalable()) + return LHS.getKnownMinValue() < RHS.getKnownMinValue(); + return false; + } + + static bool isKnownGT(const LinearPolySize &LHS, const LinearPolySize &RHS) { + if (LHS.isScalable() || !RHS.isScalable()) + return LHS.getKnownMinValue() > RHS.getKnownMinValue(); + return false; + } + + static bool isKnownLE(const LinearPolySize &LHS, const LinearPolySize &RHS) { + if (!LHS.isScalable() || RHS.isScalable()) + return LHS.getKnownMinValue() <= RHS.getKnownMinValue(); + return false; + } + + static bool isKnownGE(const LinearPolySize &LHS, const LinearPolySize &RHS) { + if (LHS.isScalable() || !RHS.isScalable()) + return LHS.getKnownMinValue() >= RHS.getKnownMinValue(); + return false; + } + + /// We do not provide the '/' operator here because division for polynomial + /// types does not work in the same way as for normal integer types. We can + /// only divide the minimum value (or coefficient) by RHS, which is not the + /// same as + /// (Min * Vscale) / RHS + /// The caller is recommended to use this function in combination with + /// isKnownMultipleOf(RHS), which lets the caller know if it's possible to + /// perform a lossless divide by RHS. + LeafTy divideCoefficientBy(ScalarTy RHS) const { + return static_cast<LeafTy>( + LinearPolySize::get(getKnownMinValue() / RHS, isScalable())); + } + + LeafTy coefficientNextPowerOf2() const { + return static_cast<LeafTy>(LinearPolySize::get( + static_cast<ScalarTy>(llvm::NextPowerOf2(getKnownMinValue())), + isScalable())); + } + + /// Printing function. + void print(raw_ostream &OS) const { + if (isScalable()) + OS << "vscale x "; + OS << getKnownMinValue(); + } +}; + +class ElementCount; +template <> struct LinearPolyBaseTypeTraits<ElementCount> { + using ScalarTy = unsigned; + static constexpr unsigned Dimensions = 2; +}; + +class ElementCount : public LinearPolySize<ElementCount> { +public: + + ElementCount(const LinearPolySize<ElementCount> &V) : LinearPolySize(V) {} + + /// Counting predicates. + /// + ///@{ Number of elements.. + /// Exactly one element. + bool isScalar() const { return !isScalable() && getKnownMinValue() == 1; } + /// One or more elements. + bool isVector() const { + return (isScalable() && getKnownMinValue() != 0) || getKnownMinValue() > 1; + } + ///@} +}; + +// This class is used to represent the size of types. If the type is of fixed +class TypeSize; +template <> struct LinearPolyBaseTypeTraits<TypeSize> { + using ScalarTy = uint64_t; + static constexpr unsigned Dimensions = 2; +}; + +// TODO: Most functionality in this class will gradually be phased out +// so it will resemble LinearPolySize as much as possible. +// +// TypeSize is used to represent the size of types. If the type is of fixed +// size, it will represent the exact size. If the type is a scalable vector, +// it will represent the known minimum size. +class TypeSize : public LinearPolySize<TypeSize> { +public: + TypeSize(const LinearPolySize<TypeSize> &V) : LinearPolySize(V) {} + TypeSize(ScalarTy MinVal, bool IsScalable) + : LinearPolySize(LinearPolySize::get(MinVal, IsScalable)) {} + + static TypeSize Fixed(ScalarTy MinVal) { return TypeSize(MinVal, false); } + static TypeSize Scalable(ScalarTy MinVal) { return TypeSize(MinVal, true); } + + ScalarTy getFixedSize() const { return getFixedValue(); } + ScalarTy getKnownMinSize() const { return getKnownMinValue(); } + + // All code for this class below this point is needed because of the + // temporary implicit conversion to uint64_t. The operator overloads are + // needed because otherwise the conversion of the parent class + // UnivariateLinearPolyBase -> TypeSize is ambiguous. + // TODO: Remove the implicit conversion. + // Casts to a uint64_t if this is a fixed-width size. // // This interface is deprecated and will be removed in a future version @@ -445,53 +445,53 @@ public: // To determine how to upgrade the code: // // if (<algorithm works for both scalable and fixed-width vectors>) - // use getKnownMinValue() + // use getKnownMinValue() // else if (<algorithm works only for fixed-width vectors>) { // if <algorithm can be adapted for both scalable and fixed-width vectors> - // update the algorithm and use getKnownMinValue() + // update the algorithm and use getKnownMinValue() // else - // bail out early for scalable vectors and use getFixedValue() + // bail out early for scalable vectors and use getFixedValue() // } - operator ScalarTy() const { + operator ScalarTy() const { #ifdef STRICT_FIXED_SIZE_VECTORS - return getFixedValue(); + return getFixedValue(); #else if (isScalable()) WithColor::warning() << "Compiler has made implicit assumption that " "TypeSize is not scalable. This may or may not " "lead to broken code.\n"; - return getKnownMinValue(); + return getKnownMinValue(); #endif } - // Additional operators needed to avoid ambiguous parses - // because of the implicit conversion hack. - friend TypeSize operator*(const TypeSize &LHS, const int RHS) { - return LHS * (ScalarTy)RHS; + // Additional operators needed to avoid ambiguous parses + // because of the implicit conversion hack. + friend TypeSize operator*(const TypeSize &LHS, const int RHS) { + return LHS * (ScalarTy)RHS; } - friend TypeSize operator*(const TypeSize &LHS, const unsigned RHS) { - return LHS * (ScalarTy)RHS; + friend TypeSize operator*(const TypeSize &LHS, const unsigned RHS) { + return LHS * (ScalarTy)RHS; } - friend TypeSize operator*(const TypeSize &LHS, const int64_t RHS) { - return LHS * (ScalarTy)RHS; + friend TypeSize operator*(const TypeSize &LHS, const int64_t RHS) { + return LHS * (ScalarTy)RHS; } friend TypeSize operator*(const int LHS, const TypeSize &RHS) { - return RHS * LHS; + return RHS * LHS; + } + friend TypeSize operator*(const unsigned LHS, const TypeSize &RHS) { + return RHS * LHS; } - friend TypeSize operator*(const unsigned LHS, const TypeSize &RHS) { - return RHS * LHS; - } friend TypeSize operator*(const int64_t LHS, const TypeSize &RHS) { - return RHS * LHS; + return RHS * LHS; } - friend TypeSize operator*(const uint64_t LHS, const TypeSize &RHS) { - return RHS * LHS; + friend TypeSize operator*(const uint64_t LHS, const TypeSize &RHS) { + return RHS * LHS; } -}; +}; -//===----------------------------------------------------------------------===// -// Utilities -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// +// Utilities +//===----------------------------------------------------------------------===// /// Returns a TypeSize with a known minimum size that is the next integer /// (mod 2**64) that is greater than or equal to \p Value and is a multiple @@ -500,35 +500,35 @@ public: /// Similar to the alignTo functions in MathExtras.h inline TypeSize alignTo(TypeSize Size, uint64_t Align) { assert(Align != 0u && "Align must be non-zero"); - return {(Size.getKnownMinValue() + Align - 1) / Align * Align, + return {(Size.getKnownMinValue() + Align - 1) / Align * Align, Size.isScalable()}; } -/// Stream operator function for `LinearPolySize`. -template <typename LeafTy> -inline raw_ostream &operator<<(raw_ostream &OS, - const LinearPolySize<LeafTy> &PS) { - PS.print(OS); - return OS; -} - -template <typename T> struct DenseMapInfo; +/// Stream operator function for `LinearPolySize`. +template <typename LeafTy> +inline raw_ostream &operator<<(raw_ostream &OS, + const LinearPolySize<LeafTy> &PS) { + PS.print(OS); + return OS; +} + +template <typename T> struct DenseMapInfo; template <> struct DenseMapInfo<ElementCount> { - static inline ElementCount getEmptyKey() { - return ElementCount::getScalable(~0U); - } - static inline ElementCount getTombstoneKey() { - return ElementCount::getFixed(~0U - 1); - } - static unsigned getHashValue(const ElementCount &EltCnt) { - unsigned HashVal = EltCnt.getKnownMinValue() * 37U; - if (EltCnt.isScalable()) - return (HashVal - 1U); + static inline ElementCount getEmptyKey() { + return ElementCount::getScalable(~0U); + } + static inline ElementCount getTombstoneKey() { + return ElementCount::getFixed(~0U - 1); + } + static unsigned getHashValue(const ElementCount &EltCnt) { + unsigned HashVal = EltCnt.getKnownMinValue() * 37U; + if (EltCnt.isScalable()) + return (HashVal - 1U); - return HashVal; + return HashVal; } - static bool isEqual(const ElementCount &LHS, const ElementCount &RHS) { + static bool isEqual(const ElementCount &LHS, const ElementCount &RHS) { return LHS == RHS; } }; diff --git a/contrib/libs/llvm12/include/llvm/Support/VirtualFileSystem.h b/contrib/libs/llvm12/include/llvm/Support/VirtualFileSystem.h index dd75b493f0..4729450b67 100644 --- a/contrib/libs/llvm12/include/llvm/Support/VirtualFileSystem.h +++ b/contrib/libs/llvm12/include/llvm/Support/VirtualFileSystem.h @@ -45,7 +45,7 @@ namespace llvm { class MemoryBuffer; -class MemoryBufferRef; +class MemoryBufferRef; class Twine; namespace vfs { @@ -503,8 +503,8 @@ public: /// false if the file or directory already exists in the file system with /// different contents. bool addFileNoOwn(const Twine &Path, time_t ModificationTime, - const llvm::MemoryBufferRef &Buffer, - Optional<uint32_t> User = None, + const llvm::MemoryBufferRef &Buffer, + Optional<uint32_t> User = None, Optional<uint32_t> Group = None, Optional<llvm::sys::fs::file_type> Type = None, Optional<llvm::sys::fs::perms> Perms = None); @@ -539,7 +539,7 @@ llvm::sys::fs::UniqueID getNextVirtualUniqueID(); /// Gets a \p FileSystem for a virtual file system described in YAML /// format. -std::unique_ptr<FileSystem> +std::unique_ptr<FileSystem> getVFSFromYAML(std::unique_ptr<llvm::MemoryBuffer> Buffer, llvm::SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath, void *DiagContext = nullptr, @@ -690,13 +690,13 @@ private: friend class VFSFromYamlDirIterImpl; friend class RedirectingFileSystemParser; - bool shouldUseExternalFS() const { return IsFallthrough; } + bool shouldUseExternalFS() const { return IsFallthrough; } + + /// Canonicalize path by removing ".", "..", "./", components. This is + /// a VFS request, do not bother about symlinks in the path components + /// but canonicalize in order to perform the correct entry search. + std::error_code makeCanonical(SmallVectorImpl<char> &Path) const; - /// Canonicalize path by removing ".", "..", "./", components. This is - /// a VFS request, do not bother about symlinks in the path components - /// but canonicalize in order to perform the correct entry search. - std::error_code makeCanonical(SmallVectorImpl<char> &Path) const; - // In a RedirectingFileSystem, keys can be specified in Posix or Windows // style (or even a mixture of both), so this comparison helper allows // slashes (representing a root) to match backslashes (and vice versa). Note @@ -761,20 +761,20 @@ private: public: /// Looks up \p Path in \c Roots. - ErrorOr<Entry *> lookupPath(StringRef Path) const; + ErrorOr<Entry *> lookupPath(StringRef Path) const; /// Parses \p Buffer, which is expected to be in YAML format and /// returns a virtual file system representing its contents. - static std::unique_ptr<RedirectingFileSystem> + static std::unique_ptr<RedirectingFileSystem> create(std::unique_ptr<MemoryBuffer> Buffer, SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath, void *DiagContext, IntrusiveRefCntPtr<FileSystem> ExternalFS); - /// Redirect each of the remapped files from first to second. - static std::unique_ptr<RedirectingFileSystem> - create(ArrayRef<std::pair<std::string, std::string>> RemappedFiles, - bool UseExternalNames, FileSystem &ExternalFS); - + /// Redirect each of the remapped files from first to second. + static std::unique_ptr<RedirectingFileSystem> + create(ArrayRef<std::pair<std::string, std::string>> RemappedFiles, + bool UseExternalNames, FileSystem &ExternalFS); + ErrorOr<Status> status(const Twine &Path) override; ErrorOr<std::unique_ptr<File>> openFileForRead(const Twine &Path) override; @@ -795,10 +795,10 @@ public: StringRef getExternalContentsPrefixDir() const; - void setFallthrough(bool Fallthrough); - - std::vector<llvm::StringRef> getRoots() const; - + void setFallthrough(bool Fallthrough); + + std::vector<llvm::StringRef> getRoots() const; + void dump(raw_ostream &OS) const; void dumpEntry(raw_ostream &OS, Entry *E, int NumSpaces = 0) const; #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) diff --git a/contrib/libs/llvm12/include/llvm/Support/Win64EH.h b/contrib/libs/llvm12/include/llvm/Support/Win64EH.h index 78057486b4..a2f44c78da 100644 --- a/contrib/libs/llvm12/include/llvm/Support/Win64EH.h +++ b/contrib/libs/llvm12/include/llvm/Support/Win64EH.h @@ -45,14 +45,14 @@ enum UnwindOpcodes { // The following set of unwind opcodes is for ARM64. They are documented at // https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling UOP_AllocMedium, - UOP_SaveR19R20X, + UOP_SaveR19R20X, UOP_SaveFPLRX, UOP_SaveFPLR, UOP_SaveReg, UOP_SaveRegX, UOP_SaveRegP, UOP_SaveRegPX, - UOP_SaveLRPair, + UOP_SaveLRPair, UOP_SaveFReg, UOP_SaveFRegX, UOP_SaveFRegP, @@ -60,11 +60,11 @@ enum UnwindOpcodes { UOP_SetFP, UOP_AddFP, UOP_Nop, - UOP_End, - UOP_SaveNext, - UOP_TrapFrame, - UOP_Context, - UOP_ClearUnwoundToCall + UOP_End, + UOP_SaveNext, + UOP_TrapFrame, + UOP_Context, + UOP_ClearUnwoundToCall }; /// UnwindCode - This union describes a single operation in a function prolog, diff --git a/contrib/libs/llvm12/include/llvm/Support/X86TargetParser.def b/contrib/libs/llvm12/include/llvm/Support/X86TargetParser.def index 78831f4f66..ec19ce4e7c 100644 --- a/contrib/libs/llvm12/include/llvm/Support/X86TargetParser.def +++ b/contrib/libs/llvm12/include/llvm/Support/X86TargetParser.def @@ -44,7 +44,7 @@ X86_CPU_TYPE(INTEL_KNM, "knm") X86_CPU_TYPE(INTEL_GOLDMONT, "goldmont") X86_CPU_TYPE(INTEL_GOLDMONT_PLUS, "goldmont-plus") X86_CPU_TYPE(INTEL_TREMONT, "tremont") -X86_CPU_TYPE(AMDFAM19H, "amdfam19h") +X86_CPU_TYPE(AMDFAM19H, "amdfam19h") // Alternate names supported by __builtin_cpu_is and target multiversioning. X86_CPU_TYPE_ALIAS(INTEL_BONNELL, "atom") @@ -85,9 +85,9 @@ X86_CPU_SUBTYPE(AMDFAM17H_ZNVER2, "znver2") X86_CPU_SUBTYPE(INTEL_COREI7_CASCADELAKE, "cascadelake") X86_CPU_SUBTYPE(INTEL_COREI7_TIGERLAKE, "tigerlake") X86_CPU_SUBTYPE(INTEL_COREI7_COOPERLAKE, "cooperlake") -X86_CPU_SUBTYPE(INTEL_COREI7_SAPPHIRERAPIDS, "sapphirerapids") -X86_CPU_SUBTYPE(INTEL_COREI7_ALDERLAKE, "alderlake") -X86_CPU_SUBTYPE(AMDFAM19H_ZNVER3, "znver3") +X86_CPU_SUBTYPE(INTEL_COREI7_SAPPHIRERAPIDS, "sapphirerapids") +X86_CPU_SUBTYPE(INTEL_COREI7_ALDERLAKE, "alderlake") +X86_CPU_SUBTYPE(AMDFAM19H_ZNVER3, "znver3") #undef X86_CPU_SUBTYPE @@ -157,8 +157,8 @@ X86_FEATURE (F16C, "f16c") X86_FEATURE (FSGSBASE, "fsgsbase") X86_FEATURE (FXSR, "fxsr") X86_FEATURE (INVPCID, "invpcid") -X86_FEATURE (KL, "kl") -X86_FEATURE (WIDEKL, "widekl") +X86_FEATURE (KL, "kl") +X86_FEATURE (WIDEKL, "widekl") X86_FEATURE (LWP, "lwp") X86_FEATURE (LZCNT, "lzcnt") X86_FEATURE (MOVBE, "movbe") @@ -181,7 +181,7 @@ X86_FEATURE (SHA, "sha") X86_FEATURE (SHSTK, "shstk") X86_FEATURE (TBM, "tbm") X86_FEATURE (TSXLDTRK, "tsxldtrk") -X86_FEATURE (UINTR, "uintr") +X86_FEATURE (UINTR, "uintr") X86_FEATURE (VAES, "vaes") X86_FEATURE (VZEROUPPER, "vzeroupper") X86_FEATURE (WAITPKG, "waitpkg") @@ -191,8 +191,8 @@ X86_FEATURE (XSAVE, "xsave") X86_FEATURE (XSAVEC, "xsavec") X86_FEATURE (XSAVEOPT, "xsaveopt") X86_FEATURE (XSAVES, "xsaves") -X86_FEATURE (HRESET, "hreset") -X86_FEATURE (AVXVNNI, "avxvnni") +X86_FEATURE (HRESET, "hreset") +X86_FEATURE (AVXVNNI, "avxvnni") // These features aren't really CPU features, but the frontend can set them. X86_FEATURE (RETPOLINE_EXTERNAL_THUNK, "retpoline-external-thunk") X86_FEATURE (RETPOLINE_INDIRECT_BRANCHES, "retpoline-indirect-branches") diff --git a/contrib/libs/llvm12/include/llvm/Support/X86TargetParser.h b/contrib/libs/llvm12/include/llvm/Support/X86TargetParser.h index 8f67d20b1b..0113042931 100644 --- a/contrib/libs/llvm12/include/llvm/Support/X86TargetParser.h +++ b/contrib/libs/llvm12/include/llvm/Support/X86TargetParser.h @@ -21,7 +21,7 @@ #define LLVM_SUPPORT_X86TARGETPARSERCOMMON_H #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringMap.h" namespace llvm { class StringRef; @@ -107,8 +107,8 @@ enum CPUKind { CK_IcelakeClient, CK_IcelakeServer, CK_Tigerlake, - CK_SapphireRapids, - CK_Alderlake, + CK_SapphireRapids, + CK_Alderlake, CK_KNL, CK_KNM, CK_Lakemont, @@ -128,26 +128,26 @@ enum CPUKind { CK_BDVER4, CK_ZNVER1, CK_ZNVER2, - CK_ZNVER3, + CK_ZNVER3, CK_x86_64, - CK_x86_64_v2, - CK_x86_64_v3, - CK_x86_64_v4, + CK_x86_64_v2, + CK_x86_64_v3, + CK_x86_64_v4, CK_Geode, }; /// Parse \p CPU string into a CPUKind. Will only accept 64-bit capable CPUs if /// \p Only64Bit is true. CPUKind parseArchX86(StringRef CPU, bool Only64Bit = false); -CPUKind parseTuneCPU(StringRef CPU, bool Only64Bit = false); +CPUKind parseTuneCPU(StringRef CPU, bool Only64Bit = false); /// Provide a list of valid CPU names. If \p Only64Bit is true, the list will /// only contain 64-bit capable CPUs. void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values, - bool Only64Bit = false); -/// Provide a list of valid -mtune names. -void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values, - bool Only64Bit = false); + bool Only64Bit = false); +/// Provide a list of valid -mtune names. +void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values, + bool Only64Bit = false); /// Get the key feature prioritizing target multiversioning. ProcessorFeatures getKeyFeature(CPUKind Kind); @@ -155,10 +155,10 @@ ProcessorFeatures getKeyFeature(CPUKind Kind); /// Fill in the features that \p CPU supports into \p Features. void getFeaturesForCPU(StringRef CPU, SmallVectorImpl<StringRef> &Features); -/// Set or clear entries in \p Features that are implied to be enabled/disabled +/// Set or clear entries in \p Features that are implied to be enabled/disabled /// by the provided \p Feature. -void updateImpliedFeatures(StringRef Feature, bool Enabled, - StringMap<bool> &Features); +void updateImpliedFeatures(StringRef Feature, bool Enabled, + StringMap<bool> &Features); } // namespace X86 } // namespace llvm diff --git a/contrib/libs/llvm12/include/llvm/Support/YAMLParser.h b/contrib/libs/llvm12/include/llvm/Support/YAMLParser.h index 00f9761284..f9682b7048 100644 --- a/contrib/libs/llvm12/include/llvm/Support/YAMLParser.h +++ b/contrib/libs/llvm12/include/llvm/Support/YAMLParser.h @@ -47,7 +47,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/SMLoc.h" -#include "llvm/Support/SourceMgr.h" +#include "llvm/Support/SourceMgr.h" #include <cassert> #include <cstddef> #include <iterator> @@ -85,9 +85,9 @@ bool scanTokens(StringRef Input); /// escaped, but emitted verbatim. std::string escape(StringRef Input, bool EscapePrintable = true); -/// Parse \p S as a bool according to https://yaml.org/type/bool.html. -llvm::Optional<bool> parseBool(StringRef S); - +/// Parse \p S as a bool according to https://yaml.org/type/bool.html. +llvm::Optional<bool> parseBool(StringRef S); + /// This class represents a YAML stream potentially containing multiple /// documents. class Stream { @@ -110,10 +110,10 @@ public: return !failed(); } - void printError(Node *N, const Twine &Msg, - SourceMgr::DiagKind Kind = SourceMgr::DK_Error); - void printError(const SMRange &Range, const Twine &Msg, - SourceMgr::DiagKind Kind = SourceMgr::DK_Error); + void printError(Node *N, const Twine &Msg, + SourceMgr::DiagKind Kind = SourceMgr::DK_Error); + void printError(const SMRange &Range, const Twine &Msg, + SourceMgr::DiagKind Kind = SourceMgr::DK_Error); private: friend class Document; @@ -235,7 +235,7 @@ public: /// Gets the value of this node as a StringRef. /// - /// \param Storage is used to store the content of the returned StringRef if + /// \param Storage is used to store the content of the returned StringRef if /// it requires any modification from how it appeared in the source. /// This happens with escaped characters and multi-line literals. StringRef getValue(SmallVectorImpl<char> &Storage) const; diff --git a/contrib/libs/llvm12/include/llvm/Support/YAMLTraits.h b/contrib/libs/llvm12/include/llvm/Support/YAMLTraits.h index ab5a8cdbf4..aeb23970e2 100644 --- a/contrib/libs/llvm12/include/llvm/Support/YAMLTraits.h +++ b/contrib/libs/llvm12/include/llvm/Support/YAMLTraits.h @@ -26,9 +26,9 @@ #include "llvm/Support/Allocator.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Regex.h" -#include "llvm/Support/SMLoc.h" +#include "llvm/Support/SMLoc.h" #include "llvm/Support/SourceMgr.h" -#include "llvm/Support/VersionTuple.h" +#include "llvm/Support/VersionTuple.h" #include "llvm/Support/YAMLParser.h" #include "llvm/Support/raw_ostream.h" #include <cassert> @@ -70,7 +70,7 @@ struct MappingTraits { // Must provide: // static void mapping(IO &io, T &fields); // Optionally may provide: - // static std::string validate(IO &io, T &fields); + // static std::string validate(IO &io, T &fields); // // The optional flow flag will cause generated YAML to use a flow mapping // (e.g. { a: 0, b: 1 }): @@ -92,7 +92,7 @@ template <class T, class Context> struct MappingContextTraits { // Must provide: // static void mapping(IO &io, T &fields, Context &Ctx); // Optionally may provide: - // static std::string validate(IO &io, T &fields, Context &Ctx); + // static std::string validate(IO &io, T &fields, Context &Ctx); // // The optional flow flag will cause generated YAML to use a flow mapping // (e.g. { a: 0, b: 1 }): @@ -430,7 +430,7 @@ template <class T> struct has_MappingTraits<T, EmptyContext> { // Test if MappingContextTraits<T>::validate() is defined on type T. template <class T, class Context> struct has_MappingValidateTraits { - using Signature_validate = std::string (*)(class IO &, T &, Context &); + using Signature_validate = std::string (*)(class IO &, T &, Context &); template <typename U> static char test(SameType<Signature_validate, &U::validate>*); @@ -444,7 +444,7 @@ template <class T, class Context> struct has_MappingValidateTraits { // Test if MappingTraits<T>::validate() is defined on type T. template <class T> struct has_MappingValidateTraits<T, EmptyContext> { - using Signature_validate = std::string (*)(class IO &, T &); + using Signature_validate = std::string (*)(class IO &, T &); template <typename U> static char test(SameType<Signature_validate, &U::validate> *); @@ -646,7 +646,7 @@ inline bool isNull(StringRef S) { } inline bool isBool(StringRef S) { - // FIXME: using parseBool is causing multiple tests to fail. + // FIXME: using parseBool is causing multiple tests to fail. return S.equals("true") || S.equals("True") || S.equals("TRUE") || S.equals("false") || S.equals("False") || S.equals("FALSE"); } @@ -799,7 +799,7 @@ public: virtual NodeKind getNodeKind() = 0; virtual void setError(const Twine &) = 0; - virtual void setAllowUnknownKeys(bool Allow); + virtual void setAllowUnknownKeys(bool Allow); template <typename T> void enumCase(T &Val, const char* Str, const T ConstVal) { @@ -913,7 +913,7 @@ private: template <typename T, typename Context> void processKeyWithDefault(const char *Key, Optional<T> &Val, const Optional<T> &DefaultValue, bool Required, - Context &Ctx); + Context &Ctx); template <typename T, typename Context> void processKeyWithDefault(const char *Key, T &Val, const T &DefaultValue, @@ -1051,7 +1051,7 @@ yamlize(IO &io, T &Val, bool, Context &Ctx) { else io.beginMapping(); if (io.outputting()) { - std::string Err = MappingTraits<T>::validate(io, Val); + std::string Err = MappingTraits<T>::validate(io, Val); if (!Err.empty()) { errs() << Err << "\n"; assert(Err.empty() && "invalid struct trying to be written as yaml"); @@ -1059,7 +1059,7 @@ yamlize(IO &io, T &Val, bool, Context &Ctx) { } detail::doMapping(io, Val, Ctx); if (!io.outputting()) { - std::string Err = MappingTraits<T>::validate(io, Val); + std::string Err = MappingTraits<T>::validate(io, Val); if (!Err.empty()) io.setError(Err); } @@ -1481,10 +1481,10 @@ private: static bool classof(const MapHNode *) { return true; } - using NameToNodeAndLoc = - StringMap<std::pair<std::unique_ptr<HNode>, SMRange>>; + using NameToNodeAndLoc = + StringMap<std::pair<std::unique_ptr<HNode>, SMRange>>; - NameToNodeAndLoc Mapping; + NameToNodeAndLoc Mapping; SmallVector<std::string, 6> ValidKeys; }; @@ -1506,12 +1506,12 @@ private: std::unique_ptr<Input::HNode> createHNodes(Node *node); void setError(HNode *hnode, const Twine &message); void setError(Node *node, const Twine &message); - void setError(const SMRange &Range, const Twine &message); + void setError(const SMRange &Range, const Twine &message); + + void reportWarning(HNode *hnode, const Twine &message); + void reportWarning(Node *hnode, const Twine &message); + void reportWarning(const SMRange &Range, const Twine &message); - void reportWarning(HNode *hnode, const Twine &message); - void reportWarning(Node *hnode, const Twine &message); - void reportWarning(const SMRange &Range, const Twine &message); - public: // These are only used by operator>>. They could be private // if those templated things could be made friends. @@ -1521,8 +1521,8 @@ public: /// Returns the current node that's being parsed by the YAML Parser. const Node *getCurrentNode() const; - void setAllowUnknownKeys(bool Allow) override; - + void setAllowUnknownKeys(bool Allow) override; + private: SourceMgr SrcMgr; // must be before Strm std::unique_ptr<llvm::yaml::Stream> Strm; @@ -1533,7 +1533,7 @@ private: std::vector<bool> BitValuesUsed; HNode *CurrentNode = nullptr; bool ScalarMatchFound = false; - bool AllowUnknownKeys = false; + bool AllowUnknownKeys = false; }; /// @@ -1593,7 +1593,7 @@ public: private: void output(StringRef s); void outputUpToEndOfLine(StringRef s); - void newLineCheck(bool EmptySequence = false); + void newLineCheck(bool EmptySequence = false); void outputNewLine(); void paddedKey(StringRef key); void flowKey(StringRef Key); @@ -1628,42 +1628,42 @@ private: StringRef PaddingBeforeContainer; }; -template <typename T, typename Context> -void IO::processKeyWithDefault(const char *Key, Optional<T> &Val, - const Optional<T> &DefaultValue, bool Required, - Context &Ctx) { - assert(DefaultValue.hasValue() == false && - "Optional<T> shouldn't have a value!"); - void *SaveInfo; - bool UseDefault = true; - const bool sameAsDefault = outputting() && !Val.hasValue(); - if (!outputting() && !Val.hasValue()) - Val = T(); - if (Val.hasValue() && - this->preflightKey(Key, Required, sameAsDefault, UseDefault, SaveInfo)) { - - // When reading an Optional<X> key from a YAML description, we allow the - // special "<none>" value, which can be used to specify that no value was - // requested, i.e. the DefaultValue will be assigned. The DefaultValue is - // usually None. - bool IsNone = false; - if (!outputting()) - if (auto *Node = dyn_cast<ScalarNode>(((Input *)this)->getCurrentNode())) - // We use rtrim to ignore possible white spaces that might exist when a - // comment is present on the same line. - IsNone = Node->getRawValue().rtrim(' ') == "<none>"; - - if (IsNone) - Val = DefaultValue; - else - yamlize(*this, Val.getValue(), Required, Ctx); - this->postflightKey(SaveInfo); - } else { - if (UseDefault) - Val = DefaultValue; - } -} - +template <typename T, typename Context> +void IO::processKeyWithDefault(const char *Key, Optional<T> &Val, + const Optional<T> &DefaultValue, bool Required, + Context &Ctx) { + assert(DefaultValue.hasValue() == false && + "Optional<T> shouldn't have a value!"); + void *SaveInfo; + bool UseDefault = true; + const bool sameAsDefault = outputting() && !Val.hasValue(); + if (!outputting() && !Val.hasValue()) + Val = T(); + if (Val.hasValue() && + this->preflightKey(Key, Required, sameAsDefault, UseDefault, SaveInfo)) { + + // When reading an Optional<X> key from a YAML description, we allow the + // special "<none>" value, which can be used to specify that no value was + // requested, i.e. the DefaultValue will be assigned. The DefaultValue is + // usually None. + bool IsNone = false; + if (!outputting()) + if (auto *Node = dyn_cast<ScalarNode>(((Input *)this)->getCurrentNode())) + // We use rtrim to ignore possible white spaces that might exist when a + // comment is present on the same line. + IsNone = Node->getRawValue().rtrim(' ') == "<none>"; + + if (IsNone) + Val = DefaultValue; + else + yamlize(*this, Val.getValue(), Required, Ctx); + this->postflightKey(SaveInfo); + } else { + if (UseDefault) + Val = DefaultValue; + } +} + /// YAML I/O does conversion based on types. But often native data types /// are just a typedef of built in intergral types (e.g. int). But the C++ /// type matching system sees through the typedef and all the typedefed types @@ -1724,12 +1724,12 @@ struct ScalarTraits<Hex64> { static QuotingType mustQuote(StringRef) { return QuotingType::None; } }; -template <> struct ScalarTraits<VersionTuple> { - static void output(const VersionTuple &Value, void *, llvm::raw_ostream &Out); - static StringRef input(StringRef, void *, VersionTuple &); - static QuotingType mustQuote(StringRef) { return QuotingType::None; } -}; - +template <> struct ScalarTraits<VersionTuple> { + static void output(const VersionTuple &Value, void *, llvm::raw_ostream &Out); + static StringRef input(StringRef, void *, VersionTuple &); + static QuotingType mustQuote(StringRef) { return QuotingType::None; } +}; + // Define non-member operator>> so that Input can stream in a document list. template <typename T> inline std::enable_if_t<has_DocumentListTraits<T>::value, Input &> diff --git a/contrib/libs/llvm12/include/llvm/Support/raw_ostream.h b/contrib/libs/llvm12/include/llvm/Support/raw_ostream.h index 37dc103e5f..adacc8bb0a 100644 --- a/contrib/libs/llvm12/include/llvm/Support/raw_ostream.h +++ b/contrib/libs/llvm12/include/llvm/Support/raw_ostream.h @@ -22,9 +22,9 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Support/DataTypes.h" +#include "llvm/Support/DataTypes.h" #include <cassert> -#include <chrono> +#include <chrono> #include <cstddef> #include <cstdint> #include <cstring> @@ -39,14 +39,14 @@ class format_object_base; class FormattedString; class FormattedNumber; class FormattedBytes; -template <class T> class LLVM_NODISCARD Expected; +template <class T> class LLVM_NODISCARD Expected; namespace sys { namespace fs { enum FileAccess : unsigned; enum OpenFlags : unsigned; enum CreationDisposition : unsigned; -class FileLocker; +class FileLocker; } // end namespace fs } // end namespace sys @@ -55,16 +55,16 @@ class FileLocker; /// buffered disciplines etc. It is a simple buffer that outputs /// a chunk at a time. class raw_ostream { -public: - // Class kinds to support LLVM-style RTTI. - enum class OStreamKind { - OK_OStream, - OK_FDStream, - }; - +public: + // Class kinds to support LLVM-style RTTI. + enum class OStreamKind { + OK_OStream, + OK_FDStream, + }; + private: - OStreamKind Kind; - + OStreamKind Kind; + /// The buffer is handled in such a way that the buffer is /// uninitialized, unbuffered, or out of space when OutBufCur >= /// OutBufEnd. Thus a single comparison suffices to determine if we @@ -122,10 +122,10 @@ public: static constexpr Colors SAVEDCOLOR = Colors::SAVEDCOLOR; static constexpr Colors RESET = Colors::RESET; - explicit raw_ostream(bool unbuffered = false, - OStreamKind K = OStreamKind::OK_OStream) - : Kind(K), BufferMode(unbuffered ? BufferKind::Unbuffered - : BufferKind::InternalBuffer) { + explicit raw_ostream(bool unbuffered = false, + OStreamKind K = OStreamKind::OK_OStream) + : Kind(K), BufferMode(unbuffered ? BufferKind::Unbuffered + : BufferKind::InternalBuffer) { // Start out ready to flush. OutBufStart = OutBufEnd = OutBufCur = nullptr; } @@ -138,8 +138,8 @@ public: /// tell - Return the current offset with the file. uint64_t tell() const { return current_pos() + GetNumBytesInBuffer(); } - OStreamKind get_kind() const { return Kind; } - + OStreamKind get_kind() const { return Kind; } + //===--------------------------------------------------------------------===// // Configuration Interface //===--------------------------------------------------------------------===// @@ -408,9 +408,9 @@ class raw_pwrite_stream : public raw_ostream { void anchor() override; public: - explicit raw_pwrite_stream(bool Unbuffered = false, - OStreamKind K = OStreamKind::OK_OStream) - : raw_ostream(Unbuffered, K) {} + explicit raw_pwrite_stream(bool Unbuffered = false, + OStreamKind K = OStreamKind::OK_OStream) + : raw_ostream(Unbuffered, K) {} void pwrite(const char *Ptr, size_t Size, uint64_t Offset) { #ifndef NDEBUG uint64_t Pos = tell(); @@ -433,7 +433,7 @@ class raw_fd_ostream : public raw_pwrite_stream { int FD; bool ShouldClose; bool SupportsSeeking = false; - mutable Optional<bool> HasColors; + mutable Optional<bool> HasColors; #ifdef _WIN32 /// True if this fd refers to a Windows console device. Mintty and other @@ -457,18 +457,18 @@ class raw_fd_ostream : public raw_pwrite_stream { /// Determine an efficient buffer size. size_t preferred_buffer_size() const override; - void anchor() override; - -protected: + void anchor() override; + +protected: /// Set the flag indicating that an output error has been encountered. void error_detected(std::error_code EC) { this->EC = EC; } - /// Return the file descriptor. - int get_fd() const { return FD; } + /// Return the file descriptor. + int get_fd() const { return FD; } + + // Update the file position by increasing \p Delta. + void inc_pos(uint64_t Delta) { pos += Delta; } - // Update the file position by increasing \p Delta. - void inc_pos(uint64_t Delta) { pos += Delta; } - public: /// Open the specified file for writing. If an error occurs, information /// about the error is put into EC, and the stream should be immediately @@ -492,8 +492,8 @@ public: /// FD is the file descriptor that this writes to. If ShouldClose is true, /// this closes the file when the stream is destroyed. If FD is for stdout or /// stderr, it will not be closed. - raw_fd_ostream(int fd, bool shouldClose, bool unbuffered = false, - OStreamKind K = OStreamKind::OK_OStream); + raw_fd_ostream(int fd, bool shouldClose, bool unbuffered = false, + OStreamKind K = OStreamKind::OK_OStream); ~raw_fd_ostream() override; @@ -501,7 +501,7 @@ public: /// fsync. void close(); - bool supportsSeeking() const { return SupportsSeeking; } + bool supportsSeeking() const { return SupportsSeeking; } /// Flushes the stream and repositions the underlying file descriptor position /// to the offset specified from the beginning of the file. @@ -529,38 +529,38 @@ public: /// - from The Zen of Python, by Tim Peters /// void clear_error() { EC = std::error_code(); } - - /// Locks the underlying file. - /// - /// @returns RAII object that releases the lock upon leaving the scope, if the - /// locking was successful. Otherwise returns corresponding - /// error code. - /// - /// The function blocks the current thread until the lock become available or - /// error occurs. - /// - /// Possible use of this function may be as follows: - /// - /// @code{.cpp} - /// if (auto L = stream.lock()) { - /// // ... do action that require file to be locked. - /// } else { - /// handleAllErrors(std::move(L.takeError()), [&](ErrorInfoBase &EIB) { - /// // ... handle lock error. - /// }); - /// } - /// @endcode - LLVM_NODISCARD Expected<sys::fs::FileLocker> lock(); - - /// Tries to lock the underlying file within the specified period. - /// - /// @returns RAII object that releases the lock upon leaving the scope, if the - /// locking was successful. Otherwise returns corresponding - /// error code. - /// - /// It is used as @ref lock. - LLVM_NODISCARD - Expected<sys::fs::FileLocker> tryLockFor(std::chrono::milliseconds Timeout); + + /// Locks the underlying file. + /// + /// @returns RAII object that releases the lock upon leaving the scope, if the + /// locking was successful. Otherwise returns corresponding + /// error code. + /// + /// The function blocks the current thread until the lock become available or + /// error occurs. + /// + /// Possible use of this function may be as follows: + /// + /// @code{.cpp} + /// if (auto L = stream.lock()) { + /// // ... do action that require file to be locked. + /// } else { + /// handleAllErrors(std::move(L.takeError()), [&](ErrorInfoBase &EIB) { + /// // ... handle lock error. + /// }); + /// } + /// @endcode + LLVM_NODISCARD Expected<sys::fs::FileLocker> lock(); + + /// Tries to lock the underlying file within the specified period. + /// + /// @returns RAII object that releases the lock upon leaving the scope, if the + /// locking was successful. Otherwise returns corresponding + /// error code. + /// + /// It is used as @ref lock. + LLVM_NODISCARD + Expected<sys::fs::FileLocker> tryLockFor(std::chrono::milliseconds Timeout); }; /// This returns a reference to a raw_fd_ostream for standard output. Use it @@ -578,34 +578,34 @@ raw_fd_ostream &errs(); raw_ostream &nulls(); //===----------------------------------------------------------------------===// -// File Streams -//===----------------------------------------------------------------------===// - -/// A raw_ostream of a file for reading/writing/seeking. -/// -class raw_fd_stream : public raw_fd_ostream { -public: - /// Open the specified file for reading/writing/seeking. If an error occurs, - /// information about the error is put into EC, and the stream should be - /// immediately destroyed. - raw_fd_stream(StringRef Filename, std::error_code &EC); - - /// This reads the \p Size bytes into a buffer pointed by \p Ptr. - /// - /// \param Ptr The start of the buffer to hold data to be read. - /// - /// \param Size The number of bytes to be read. - /// - /// On success, the number of bytes read is returned, and the file position is - /// advanced by this number. On error, -1 is returned, use error() to get the - /// error code. - ssize_t read(char *Ptr, size_t Size); - - /// Check if \p OS is a pointer of type raw_fd_stream*. - static bool classof(const raw_ostream *OS); -}; - -//===----------------------------------------------------------------------===// +// File Streams +//===----------------------------------------------------------------------===// + +/// A raw_ostream of a file for reading/writing/seeking. +/// +class raw_fd_stream : public raw_fd_ostream { +public: + /// Open the specified file for reading/writing/seeking. If an error occurs, + /// information about the error is put into EC, and the stream should be + /// immediately destroyed. + raw_fd_stream(StringRef Filename, std::error_code &EC); + + /// This reads the \p Size bytes into a buffer pointed by \p Ptr. + /// + /// \param Ptr The start of the buffer to hold data to be read. + /// + /// \param Size The number of bytes to be read. + /// + /// On success, the number of bytes read is returned, and the file position is + /// advanced by this number. On error, -1 is returned, use error() to get the + /// error code. + ssize_t read(char *Ptr, size_t Size); + + /// Check if \p OS is a pointer of type raw_fd_stream*. + static bool classof(const raw_ostream *OS); +}; + +//===----------------------------------------------------------------------===// // Output Stream Adaptors //===----------------------------------------------------------------------===// @@ -694,18 +694,18 @@ public: ~buffer_ostream() override { OS << str(); } }; -class buffer_unique_ostream : public raw_svector_ostream { - std::unique_ptr<raw_ostream> OS; - SmallVector<char, 0> Buffer; - - virtual void anchor() override; - -public: - buffer_unique_ostream(std::unique_ptr<raw_ostream> OS) - : raw_svector_ostream(Buffer), OS(std::move(OS)) {} - ~buffer_unique_ostream() override { *OS << str(); } -}; - +class buffer_unique_ostream : public raw_svector_ostream { + std::unique_ptr<raw_ostream> OS; + SmallVector<char, 0> Buffer; + + virtual void anchor() override; + +public: + buffer_unique_ostream(std::unique_ptr<raw_ostream> OS) + : raw_svector_ostream(Buffer), OS(std::move(OS)) {} + ~buffer_unique_ostream() override { *OS << str(); } +}; + } // end namespace llvm #endif // LLVM_SUPPORT_RAW_OSTREAM_H |