Files
clang-p2996/libc/utils/UnitTest/MemoryMatcher.cpp
Guillaume Chatelet 83f9b13d8c [libc] Optimized version of memmove
This implementation relies on storing data in registers for sizes up to 128B.
Then depending on whether `dst` is less (resp. greater) than `src` we move data forward (resp. backward) by chunks of 32B.
We first make sure one of the pointers is aligned to increase performance on large move sizes.

Differential Revision: https://reviews.llvm.org/D114637
2022-02-08 11:55:09 +00:00

47 lines
1.2 KiB
C++

//===-- MemoryMatcher.cpp ---------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "MemoryMatcher.h"
namespace __llvm_libc {
namespace memory {
namespace testing {
bool MemoryMatcher::match(MemoryView actualValue) {
actual = actualValue;
return expected.equals(actual);
}
void display(testutils::StreamWrapper &Stream, char C) {
const auto print = [&Stream](unsigned char I) {
Stream << static_cast<char>(I < 10 ? '0' + I : 'A' + I - 10);
};
print(static_cast<unsigned char>(C) / 16);
print(static_cast<unsigned char>(C) & 15);
}
void display(testutils::StreamWrapper &Stream, MemoryView View) {
for (auto C : View) {
Stream << ' ';
display(Stream, C);
}
}
void MemoryMatcher::explainError(testutils::StreamWrapper &Stream) {
Stream << "expected :";
display(Stream, expected);
Stream << '\n';
Stream << "actual :";
display(Stream, actual);
Stream << '\n';
}
} // namespace testing
} // namespace memory
} // namespace __llvm_libc