tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

print-inl.h (1936B)


      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.
     15 
     16 // Print() function
     17 
     18 #include <stddef.h>
     19 
     20 #include "hwy/highway.h"
     21 #include "hwy/print.h"
     22 
     23 // Per-target include guard
     24 #if defined(HIGHWAY_HWY_PRINT_INL_H_) == defined(HWY_TARGET_TOGGLE)
     25 #ifdef HIGHWAY_HWY_PRINT_INL_H_
     26 #undef HIGHWAY_HWY_PRINT_INL_H_
     27 #else
     28 #define HIGHWAY_HWY_PRINT_INL_H_
     29 #endif
     30 
     31 #if HWY_TARGET == HWY_RVV
     32 #include "hwy/aligned_allocator.h"
     33 #endif
     34 
     35 HWY_BEFORE_NAMESPACE();
     36 namespace hwy {
     37 namespace HWY_NAMESPACE {
     38 
     39 // Prints lanes around `lane`, in memory order.
     40 template <class D, class V = VFromD<D>>
     41 HWY_API void Print(const D d, const char* caption, V v, size_t lane_u = 0,
     42                   size_t max_lanes = 7) {
     43  const size_t N = Lanes(d);
     44  using T = TFromD<D>;
     45 #if HWY_TARGET == HWY_RVV
     46  auto storage = AllocateAligned<T>(N);
     47  T* HWY_RESTRICT lanes = storage.get();
     48 #else
     49  // This works around an SVE compile error on GCC 11 and 12. Calling
     50  // AllocateAligned here would seem to require it be marked with HWY_ATTR.
     51  HWY_ALIGN T lanes[MaxLanes(d)];
     52 #endif
     53  Store(v, d, lanes);
     54 
     55  const auto info = hwy::detail::MakeTypeInfo<T>();
     56  hwy::detail::PrintArray(info, caption, lanes, N, lane_u, max_lanes);
     57 }
     58 
     59 // NOLINTNEXTLINE(google-readability-namespace-comments)
     60 }  // namespace HWY_NAMESPACE
     61 }  // namespace hwy
     62 HWY_AFTER_NAMESPACE();
     63 
     64 #endif  // per-target include guard