LLVM
15.0.0git
include
llvm
Support
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
16
#include "
llvm/Support/DataTypes.h
"
17
18
namespace
llvm
{
19
template
<
typename
T>
class
ArrayRef;
20
21
// Compute the CRC-32 of Data.
22
uint32_t
crc32
(ArrayRef<uint8_t>
Data
);
23
24
// Compute the running CRC-32 of Data, with CRC being the previous value of the
25
// checksum.
26
uint32_t
crc32
(
uint32_t
CRC, ArrayRef<uint8_t>
Data
);
27
28
// Class for computing the JamCRC.
29
//
30
// We will use the "Rocksoft^tm Model CRC Algorithm" to describe the properties
31
// of this CRC:
32
// Width : 32
33
// Poly : 04C11DB7
34
// Init : FFFFFFFF
35
// RefIn : True
36
// RefOut : True
37
// XorOut : 00000000
38
// Check : 340BC6D9 (result of CRC for "123456789")
39
//
40
// In other words, this is the same as CRC-32, except that XorOut is 0 instead
41
// of FFFFFFFF.
42
//
43
// N.B. We permit flexibility of the "Init" value. Some consumers of this need
44
// it to be zero.
45
class
JamCRC
{
46
public
:
47
JamCRC
(
uint32_t
Init
= 0xFFFFFFFFU) : CRC(
Init
) {}
48
49
// Update the CRC calculation with Data.
50
void
update
(
ArrayRef<uint8_t>
Data
);
51
52
uint32_t
getCRC
()
const
{
return
CRC; }
53
54
private
:
55
uint32_t
CRC;
56
};
57
58
}
// end namespace llvm
59
60
#endif
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:17
llvm::JamCRC::update
void update(ArrayRef< uint8_t > Data)
Definition:
CRC.cpp:103
llvm::crc32
uint32_t crc32(ArrayRef< uint8_t > Data)
Definition:
CRC.cpp:101
llvm::JamCRC
Definition:
CRC.h:45
llvm::Data
@ Data
Definition:
SIMachineScheduler.h:55
llvm::ArrayRef< uint8_t >
uint32_t
llvm::Init
Definition:
Record.h:281
llvm::JamCRC::JamCRC
JamCRC(uint32_t Init=0xFFFFFFFFU)
Definition:
CRC.h:47
llvm::JamCRC::getCRC
uint32_t getCRC() const
Definition:
CRC.h:52
DataTypes.h
Generated on Sun May 15 2022 16:35:51 for LLVM by
1.8.17