1//===-- crc32_hw.cpp --------------------------------------------*- 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#include "checksum.h"
10
11namespace scudo {
12
13#if defined(__CRC32__) || defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)
14u32 computeHardwareCRC32(u32 Crc, uptr Data) {
15 return static_cast<u32>(CRC32_INTRINSIC(Crc, Data));
16}
17#endif // defined(__CRC32__) || defined(__SSE4_2__) ||
18 // defined(__ARM_FEATURE_CRC32)
19
20#if defined(__loongarch__)
21u32 computeHardwareCRC32(u32 Crc, uptr Data) {
22 // The LoongArch CRC intrinsics have the two input arguments swapped, and
23 // expect them to be signed.
24 return static_cast<u32>(
25 CRC32_INTRINSIC(static_cast<long>(Data), static_cast<int>(Crc)));
26}
27#endif // defined(__loongarch__)
28
29} // namespace scudo
30