Bug 1867925 - Mark some storage-access-api tests as intermittent after wpt-sync....
[gecko.git] / third_party / highway / hwy / print.h
blob13792866a35c6af1045d12bad7e8e8458841d9a8
1 // Copyright 2022 Google LLC
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
16 #ifndef HWY_PRINT_H_
17 #define HWY_PRINT_H_
19 // Helpers for printing vector lanes.
21 #include <stddef.h>
22 #include <stdio.h>
24 #include "hwy/base.h"
25 #include "hwy/highway_export.h"
27 namespace hwy {
29 namespace detail {
31 // For implementing value comparisons etc. as type-erased functions to reduce
32 // template bloat.
33 struct TypeInfo {
34 size_t sizeof_t;
35 bool is_float;
36 bool is_signed;
39 template <typename T>
40 HWY_INLINE TypeInfo MakeTypeInfo() {
41 TypeInfo info;
42 info.sizeof_t = sizeof(T);
43 info.is_float = IsFloat<T>();
44 info.is_signed = IsSigned<T>();
45 return info;
48 HWY_DLLEXPORT void TypeName(const TypeInfo& info, size_t N, char* string100);
49 HWY_DLLEXPORT void ToString(const TypeInfo& info, const void* ptr,
50 char* string100);
52 HWY_DLLEXPORT void PrintArray(const TypeInfo& info, const char* caption,
53 const void* array_void, size_t N,
54 size_t lane_u = 0, size_t max_lanes = 7);
56 } // namespace detail
58 template <typename T>
59 HWY_NOINLINE void PrintValue(T value) {
60 char str[100];
61 detail::ToString(hwy::detail::MakeTypeInfo<T>(), &value, str);
62 fprintf(stderr, "%s,", str);
65 template <typename T>
66 HWY_NOINLINE void PrintArray(const T* value, size_t count) {
67 detail::PrintArray(hwy::detail::MakeTypeInfo<T>(), "", value, count, 0,
68 count);
71 } // namespace hwy
73 #endif // HWY_PRINT_H_