chromium/v8/src/base/division-by-constant.cc

// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/base/division-by-constant.h"

#include <stdint.h>

#include <type_traits>

#include "src/base/logging.h"
#include "src/base/macros.h"

namespace v8 {
namespace base {

template <class T, std::enable_if_t<std::is_unsigned_v<T>, bool>>
MagicNumbersForDivision<T> SignedDivisionByConstant(T d) {}

template <class T>
MagicNumbersForDivision<T> UnsignedDivisionByConstant(T d,
                                                      unsigned leading_zeros) {}


// -----------------------------------------------------------------------------
// Instantiations.

template struct EXPORT_TEMPLATE_DEFINE(V8_BASE_EXPORT)
    MagicNumbersForDivision<uint32_t>;
template struct EXPORT_TEMPLATE_DEFINE(V8_BASE_EXPORT)
    MagicNumbersForDivision<uint64_t>;

template EXPORT_TEMPLATE_DEFINE()
    MagicNumbersForDivision<uint32_t> SignedDivisionByConstant(uint32_t d);
template EXPORT_TEMPLATE_DEFINE()
    MagicNumbersForDivision<uint64_t> SignedDivisionByConstant(uint64_t d);

template EXPORT_TEMPLATE_DEFINE()
    MagicNumbersForDivision<uint32_t> UnsignedDivisionByConstant(
        uint32_t d, unsigned leading_zeros);
template EXPORT_TEMPLATE_DEFINE()
    MagicNumbersForDivision<uint64_t> UnsignedDivisionByConstant(
        uint64_t d, unsigned leading_zeros);

}  // namespace base
}  // namespace v8