LLVM 22.0.0git
CRC.h
Go to the documentation of this file.
1//===-- llvm/Support/CRC.h - Cyclic Redundancy Check-------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains implementations of CRC functions.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_SUPPORT_CRC_H
14#define LLVM_SUPPORT_CRC_H
15
18
19namespace llvm {
20template <typename T> class ArrayRef;
21
22// Compute the CRC-32 of Data.
24
25// Compute the running CRC-32 of Data, with CRC being the previous value of the
26// checksum.
27LLVM_ABI uint32_t crc32(uint32_t CRC, ArrayRef<uint8_t> Data);
28
29// Class for computing the JamCRC.
30//
31// We will use the "Rocksoft^tm Model CRC Algorithm" to describe the properties
32// of this CRC:
33// Width : 32
34// Poly : 04C11DB7
35// Init : FFFFFFFF
36// RefIn : True
37// RefOut : True
38// XorOut : 00000000
39// Check : 340BC6D9 (result of CRC for "123456789")
40//
41// In other words, this is the same as CRC-32, except that XorOut is 0 instead
42// of FFFFFFFF.
43//
44// N.B. We permit flexibility of the "Init" value. Some consumers of this need
45// it to be zero.
46class JamCRC {
47public:
48 JamCRC(uint32_t Init = 0xFFFFFFFFU) : CRC(Init) {}
49
50 // Update the CRC calculation with Data.
52
53 uint32_t getCRC() const { return CRC; }
54
55private:
56 uint32_t CRC;
57};
58
59} // end namespace llvm
60
61#endif
#define LLVM_ABI
Definition Compiler.h:213
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
uint32_t getCRC() const
Definition CRC.h:53
JamCRC(uint32_t Init=0xFFFFFFFFU)
Definition CRC.h:48
LLVM_ABI void update(ArrayRef< uint8_t > Data)
Definition CRC.cpp:103
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI uint32_t crc32(ArrayRef< uint8_t > Data)
Definition CRC.cpp:101
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:189