From b8aabcd04af61e5725925cbca89ba9ead88281a1 Mon Sep 17 00:00:00 2001 From: Francesco Biscani Date: Mon, 5 Aug 2024 11:42:57 +0200 Subject: [PATCH 1/2] Remove unused function. --- include/heyoka/detail/llvm_helpers.hpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/include/heyoka/detail/llvm_helpers.hpp b/include/heyoka/detail/llvm_helpers.hpp index 3aa72cd88..93c0b3dd4 100644 --- a/include/heyoka/detail/llvm_helpers.hpp +++ b/include/heyoka/detail/llvm_helpers.hpp @@ -43,15 +43,6 @@ HEYOKA_DLL_PUBLIC llvm::Type *llvm_type_like(llvm_state &, const T &); HEYOKA_DLL_PUBLIC llvm::Type *make_vector_type(llvm::Type *, std::uint32_t); HEYOKA_DLL_PUBLIC llvm::Type *llvm_ext_type(llvm::Type *); -// Helper to construct an LLVM vector type of size batch_size with elements -// of the LLVM type tp corresponding to the C++ type T. If batch_size is 1, tp -// will be returned. batch_size cannot be zero. -template -inline llvm::Type *to_llvm_vector_type(llvm::LLVMContext &c, std::uint32_t batch_size) -{ - return make_vector_type(to_llvm_type(c), batch_size); -} - HEYOKA_DLL_PUBLIC std::string llvm_mangle_type(llvm::Type *); HEYOKA_DLL_PUBLIC std::uint32_t get_vector_size(llvm::Value *); From 8528a5d735dc1b2d173dfbafe32d9737a1260625 Mon Sep 17 00:00:00 2001 From: Francesco Biscani Date: Mon, 5 Aug 2024 14:34:14 +0200 Subject: [PATCH 2/2] Several renames and a new helper to clarify the situation around LLVM types. --- benchmark/penc_comparison.cpp | 2 +- include/heyoka/detail/llvm_helpers.hpp | 34 +++++- src/continuous_output.cpp | 6 +- src/detail/event_detection.cpp | 10 +- src/detail/llvm_helpers.cpp | 153 ++++++++++++++++--------- src/detail/llvm_helpers_celmec.cpp | 26 ++--- src/detail/real_helpers.cpp | 28 ++--- src/detail/tm_data.cpp | 4 +- src/expression_cfunc.cpp | 24 ++-- src/func.cpp | 8 +- src/llvm_state.cpp | 2 +- src/math/erf.cpp | 8 +- src/number.cpp | 8 +- src/taylor_00.cpp | 2 +- src/taylor_01.cpp | 8 +- src/taylor_02.cpp | 4 +- src/taylor_adaptive.cpp | 8 +- src/taylor_adaptive_batch.cpp | 8 +- test/event_detection.cpp | 3 +- test/event_detection_mp.cpp | 9 +- test/llvm_helpers.cpp | 139 +++++++++++----------- test/number.cpp | 22 ++-- test/poly_enclosures.cpp | 6 +- 23 files changed, 293 insertions(+), 229 deletions(-) diff --git a/benchmark/penc_comparison.cpp b/benchmark/penc_comparison.cpp index 5d514b9dc..98499d334 100644 --- a/benchmark/penc_comparison.cpp +++ b/benchmark/penc_comparison.cpp @@ -68,7 +68,7 @@ void run_benchmark(unsigned order) auto &builder = s.builder(); auto &context = s.context(); - auto val_t = detail::to_llvm_type(context); + auto val_t = detail::to_external_llvm_type(context); auto ptr_val_t = llvm::PointerType::getUnqual(val_t); // Fetch the current insertion block. diff --git a/include/heyoka/detail/llvm_helpers.hpp b/include/heyoka/detail/llvm_helpers.hpp index 93c0b3dd4..3c60deaa3 100644 --- a/include/heyoka/detail/llvm_helpers.hpp +++ b/include/heyoka/detail/llvm_helpers.hpp @@ -28,20 +28,42 @@ HEYOKA_BEGIN_NAMESPACE namespace detail { -HEYOKA_DLL_PUBLIC llvm::Type *to_llvm_type_impl(llvm::LLVMContext &, const std::type_info &, bool); +HEYOKA_DLL_PUBLIC llvm::Type *to_external_llvm_type_impl(llvm::LLVMContext &, const std::type_info &, bool); -// Helper to associate a C++ type to an LLVM type. +// Helper to fetch the external llvm type corresponding to the C++ type T. +// +// The external type is the type to be used in llvm when interfacing with the world +// outside JIT compiled code (e.g., when accessing in JITted code data which +// was created in C++). The external type must be identical (in terms +// of size, alignment and, for structures, layout) to the corresponding C++ type. +// +// In case no llvm type can be associated to T, if err_throw is true, an exception +// will be thrown, otherwise nullptr will be returned. template -inline llvm::Type *to_llvm_type(llvm::LLVMContext &c, bool err_throw = true) +inline llvm::Type *to_external_llvm_type(llvm::LLVMContext &c, bool err_throw = true) { - return to_llvm_type_impl(c, typeid(T), err_throw); + return to_external_llvm_type_impl(c, typeid(T), err_throw); } +// Helper to fetch the internal llvm type corresponding to the C++ type T. +// +// The internal type is the type used in the JITted code to manipulate +// values which in C++ are of type T. It coincides with the external llvm +// type for all supported types apart for mppp::real, which has a +// representation in the JITted code different from its C++ representation. +// +// Because mppp::real's precision is a runtime property (i.e., not encoded +// in the type), if T is mppp::real then the precision must be passed as +// second argument to this function. template -HEYOKA_DLL_PUBLIC llvm::Type *llvm_type_like(llvm_state &, const T &); +HEYOKA_DLL_PUBLIC llvm::Type *to_internal_llvm_type(llvm_state &, long long = 0); + +template +HEYOKA_DLL_PUBLIC llvm::Type *internal_llvm_type_like(llvm_state &, const T &); + +HEYOKA_DLL_PUBLIC llvm::Type *make_external_llvm_type(llvm::Type *); HEYOKA_DLL_PUBLIC llvm::Type *make_vector_type(llvm::Type *, std::uint32_t); -HEYOKA_DLL_PUBLIC llvm::Type *llvm_ext_type(llvm::Type *); HEYOKA_DLL_PUBLIC std::string llvm_mangle_type(llvm::Type *); diff --git a/src/continuous_output.cpp b/src/continuous_output.cpp index 1a10f1b8b..07f1a4123 100644 --- a/src/continuous_output.cpp +++ b/src/continuous_output.cpp @@ -103,7 +103,7 @@ void continuous_output::add_c_out_function(std::uint32_t order, std::uint32_t auto &context = m_llvm_state.context(); // Fetch the internal floating-point type. - auto *fp_t = detail::llvm_type_like(m_llvm_state, m_output[0]); + auto *fp_t = detail::internal_llvm_type_like(m_llvm_state, m_output[0]); // Fetch the current insertion block. auto *orig_bb = builder.GetInsertBlock(); @@ -132,7 +132,7 @@ void continuous_output::add_c_out_function(std::uint32_t order, std::uint32_t // - the pointer to the hi times (read-only), // - the pointer to the lo times (read-only). // No overlap is allowed. All pointers are external. - auto *ext_fp_t = detail::to_llvm_type(context); + auto *ext_fp_t = detail::to_external_llvm_type(context); auto *ptr_t = llvm::PointerType::getUnqual(ext_fp_t); const std::vector fargs(5u, ptr_t); // The function does not return anything. @@ -620,7 +620,7 @@ void continuous_output_batch::add_c_out_function(std::uint32_t order, std::ui // - the pointer to the hi times (read-only), // - the pointer to the lo times (read-only). // No overlap is allowed. - auto fp_t = detail::to_llvm_type(context); + auto fp_t = detail::to_external_llvm_type(context); auto fp_vec_t = detail::make_vector_type(fp_t, m_batch_size); auto ptr_t = llvm::PointerType::getUnqual(fp_t); const std::vector fargs(5, ptr_t); diff --git a/src/detail/event_detection.cpp b/src/detail/event_detection.cpp index d241f908a..f2945898d 100644 --- a/src/detail/event_detection.cpp +++ b/src/detail/event_detection.cpp @@ -370,7 +370,7 @@ llvm::Function *add_poly_translator_1(llvm_state &s, llvm::Type *fp_t, std::uint auto &context = s.context(); // Fetch the external type corresponding to fp_t. - auto *ext_fp_t = llvm_ext_type(fp_t); + auto *ext_fp_t = make_external_llvm_type(fp_t); // Helper to fetch the (i, j) binomial coefficient from // a precomputed global array. The returned value is already @@ -554,7 +554,7 @@ llvm::Function *llvm_add_poly_rtscc(llvm_state &s, llvm::Type *fp_t, std::uint32 auto &context = s.context(); // Fetch the external type. - auto *ext_fp_t = llvm_ext_type(fp_t); + auto *ext_fp_t = make_external_llvm_type(fp_t); // Add the translator and the sign changes counting function. auto *pt = add_poly_translator_1(s, fp_t, n, batch_size); @@ -661,7 +661,7 @@ llvm::Function *llvm_add_fex_check(llvm_state &s, llvm::Type *fp_t, std::uint32_ auto &context = s.context(); // Fetch the external type. - auto *ext_fp_t = llvm_ext_type(fp_t); + auto *ext_fp_t = make_external_llvm_type(fp_t); // Fetch the current insertion block. auto *orig_bb = builder.GetInsertBlock(); @@ -851,7 +851,7 @@ taylor_adaptive::ed_data::ed_data(llvm_state s, std::vector tes, s // Fetch the scalar FP type. // NOTE: s0 is the first value in the state vector of the integrator, // from which the internal floating-point type is deduced. - auto *fp_t = detail::llvm_type_like(m_state, s0); + auto *fp_t = detail::internal_llvm_type_like(m_state, s0); // NOTE: the numeric cast will also ensure that we can // index into the events using 32-bit ints. @@ -1425,7 +1425,7 @@ taylor_adaptive_batch::ed_data::ed_data(llvm_state s, std::vector assert(batch_size != 0u); // LCOV_EXCL_LINE // Fetch the scalar FP type. - auto *fp_t = detail::to_llvm_type(m_state.context()); + auto *fp_t = detail::to_external_llvm_type(m_state.context()); // NOTE: the numeric cast will also ensure that we can // index into the events using 32-bit ints. diff --git a/src/detail/llvm_helpers.cpp b/src/detail/llvm_helpers.cpp index 987d8b83e..010ed98fc 100644 --- a/src/detail/llvm_helpers.cpp +++ b/src/detail/llvm_helpers.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -166,10 +167,10 @@ const auto type_map = []() { return ptr; } - auto *ret = llvm::StructType::create({to_llvm_type(c), to_llvm_type(c), - to_llvm_type(c), - llvm::PointerType::getUnqual(to_llvm_type(c))}, - "heyoka.real"); + auto *ret = llvm::StructType::create( + {to_external_llvm_type(c), to_external_llvm_type(c), + to_external_llvm_type(c), llvm::PointerType::getUnqual(to_external_llvm_type(c))}, + "heyoka.real"); assert(ret != nullptr); assert(llvm::StructType::getTypeByName(c, "heyoka.real") == ret); @@ -203,11 +204,11 @@ bool llvm_stype_can_use_math_intrinsics(llvm_state &s, llvm::Type *tp) // NOTE: by default we assume it is safe to invoke the LLVM intrinsics // on the fundamental C++ floating-point types. - // NOTE: to_llvm_type fails by returning nullptr - in such a case + // NOTE: to_external_llvm_type fails by returning nullptr - in such a case // (which I don't think is currently possible) then the // comparison to tp will fail as tp is not null. - return tp == to_llvm_type(context, false) || tp == to_llvm_type(context, false) - || tp == to_llvm_type(context, false); + return tp == to_external_llvm_type(context, false) || tp == to_external_llvm_type(context, false) + || tp == to_external_llvm_type(context, false); } // Helper to lookup/insert the declaration of an LLVM intrinsic into a module. @@ -266,7 +267,7 @@ llvm::AttributeList llvm_ext_math_func_attrs(llvm_state &s) { // NOTE: use the fabs() f64 intrinsic - hopefully it does not matter // which intrinsic we pick. - auto *f = llvm_lookup_intrinsic(s.builder(), "llvm.fabs", {to_llvm_type(s.context())}, 1); + auto *f = llvm_lookup_intrinsic(s.builder(), "llvm.fabs", {to_external_llvm_type(s.context())}, 1); assert(f != nullptr); return f->getAttributes(); @@ -644,7 +645,7 @@ llvm::Value *llvm_math_intr(llvm_state &s, const std::string &intr_name, #if defined(HEYOKA_HAVE_REAL128) // NOTE: this handles both the scalar and vector cases. - if (scal_t == to_llvm_type(s.context(), false)) { + if (scal_t == to_external_llvm_type(s.context(), false)) { return llvm_scalarise_ext_math_vector_call(s, {args...}, f128_name, lookup_vf_info(f128_name), // NOTE: use the standard math function attributes. llvm_ext_math_func_attrs(s)); @@ -685,21 +686,21 @@ std::optional get_cmath_func_suffix(llvm_state &s, llvm::Type *scal auto &context = s.context(); - if (scal_t == to_llvm_type(context, false)) { + if (scal_t == to_external_llvm_type(context, false)) { return "f"; } - if (scal_t == to_llvm_type(context, false)) { + if (scal_t == to_external_llvm_type(context, false)) { return ""; } - if (scal_t == to_llvm_type(context, false)) { + if (scal_t == to_external_llvm_type(context, false)) { return "l"; } #if defined(HEYOKA_HAVE_REAL128) - if (scal_t == to_llvm_type(context, false)) { + if (scal_t == to_external_llvm_type(context, false)) { return "q"; } @@ -803,7 +804,7 @@ llvm::Value *llvm_math_cmath(llvm_state &s, const std::string &base_name, Args * // Implementation of the function to associate a C++ type to // an LLVM type. -llvm::Type *to_llvm_type_impl(llvm::LLVMContext &c, const std::type_info &tp, bool err_throw) +llvm::Type *to_external_llvm_type_impl(llvm::LLVMContext &c, const std::type_info &tp, bool err_throw) { const auto it = type_map.find(tp); @@ -889,7 +890,7 @@ llvm::Value *to_size_t(llvm_state &s, llvm::Value *n) const auto n_bw = llvm::cast(n->getType()->getScalarType())->getBitWidth(); // Fetch the LLVM type corresponding to size_t, and its bit width. - auto *lst = to_llvm_type(s.context()); + auto *lst = to_external_llvm_type(s.context()); const auto lst_bw = llvm::cast(lst)->getBitWidth(); assert(lst_bw == static_cast(std::numeric_limits::digits)); // LCOV_EXCL_LINE @@ -982,10 +983,10 @@ llvm::Value *ext_load_vector_from_memory(llvm_state &s, llvm::Type *tp, llvm::Va auto &context = s.context(); // Fetch the limb type. - auto *limb_t = to_llvm_type(context); + auto *limb_t = to_external_llvm_type(context); // Fetch the external real struct type. - auto *real_t = to_llvm_type(context); + auto *real_t = to_external_llvm_type(context); // Compute the number of limbs in the internal real type. const auto nlimbs = mppp::prec_to_nlimbs(real_prec); @@ -996,7 +997,7 @@ llvm::Value *ext_load_vector_from_memory(llvm_state &s, llvm::Type *tp, llvm::Va // type matches exactly the precision of the external variable. // Load the precision from the external value. - auto *prec_t = to_llvm_type(context); + auto *prec_t = to_external_llvm_type(context); auto *prec_ptr = builder.CreateInBoundsGEP(real_t, ptr, {builder.getInt32(0), builder.getInt32(0)}); auto *prec = builder.CreateLoad(prec_t, prec_ptr); @@ -1011,12 +1012,12 @@ llvm::Value *ext_load_vector_from_memory(llvm_state &s, llvm::Type *tp, llvm::Va // Read and insert the sign. auto *sign_ptr = builder.CreateInBoundsGEP(real_t, ptr, {builder.getInt32(0), builder.getInt32(1)}); - auto *sign = builder.CreateLoad(to_llvm_type(context), sign_ptr); + auto *sign = builder.CreateLoad(to_external_llvm_type(context), sign_ptr); ret = builder.CreateInsertValue(ret, sign, {0u}); // Read and insert the exponent. auto *exp_ptr = builder.CreateInBoundsGEP(real_t, ptr, {builder.getInt32(0), builder.getInt32(2)}); - auto *exp = builder.CreateLoad(to_llvm_type(context), exp_ptr); + auto *exp = builder.CreateLoad(to_external_llvm_type(context), exp_ptr); ret = builder.CreateInsertValue(ret, exp, {1u}); // Load in a local variable the input pointer to the limbs. @@ -1082,10 +1083,10 @@ void ext_store_vector_to_memory(llvm_state &s, llvm::Value *ptr, llvm::Value *ve auto &context = s.context(); // Fetch the limb type. - auto *limb_t = to_llvm_type(context); + auto *limb_t = to_external_llvm_type(context); // Fetch the external real struct type. - auto *real_t = to_llvm_type(context); + auto *real_t = to_external_llvm_type(context); // Compute the number of limbs in the internal real type. const auto nlimbs = mppp::prec_to_nlimbs(real_prec); @@ -1096,7 +1097,7 @@ void ext_store_vector_to_memory(llvm_state &s, llvm::Value *ptr, llvm::Value *ve // type matches exactly the precision of the external variable. // Load the precision from the external value. - auto *prec_t = to_llvm_type(context); + auto *prec_t = to_external_llvm_type(context); auto *out_prec_ptr = builder.CreateInBoundsGEP(real_t, ptr, {builder.getInt32(0), builder.getInt32(0)}); auto *prec = builder.CreateLoad(prec_t, out_prec_ptr); @@ -2161,7 +2162,7 @@ std::pair llvm_sincos(llvm_state &s, llvm::Value * auto &context = s.context(); - if (scal_t == to_llvm_type(context, false)) { + if (scal_t == to_external_llvm_type(context, false)) { auto &builder = s.builder(); // Convert the vector argument to scalars. @@ -2363,7 +2364,7 @@ llvm::Function *llvm_add_csc(llvm_state &s, llvm::Type *scal_t, std::uint32_t n, auto &context = s.context(); // Fetch the external type. - auto *ext_fp_t = llvm_ext_type(scal_t); + auto *ext_fp_t = make_external_llvm_type(scal_t); // Fetch the vector floating-point type. auto *tp = make_vector_type(scal_t, batch_size); @@ -2538,7 +2539,7 @@ std::pair llvm_penc_interval(llvm_state &s, llvm:: auto &builder = s.builder(); // Fetch the external type. - auto *ext_fp_t = llvm_ext_type(fp_t); + auto *ext_fp_t = make_external_llvm_type(fp_t); // Helper to implement the sum of two intervals. // NOTE: see https://en.wikipedia.org/wiki/Interval_arithmetic. @@ -2642,7 +2643,7 @@ std::pair llvm_penc_cargo_shisha(llvm_state &s, ll auto &builder = s.builder(); // Fetch the external type. - auto *ext_fp_t = llvm_ext_type(fp_t); + auto *ext_fp_t = make_external_llvm_type(fp_t); // bj_series will contain the terms of the series // for the computation of bj. old_bj_series will be @@ -3203,32 +3204,38 @@ llvm::Value *llvm_pow(llvm_state &s, llvm::Value *x, llvm::Value *y) x, y); } -// This helper returns the type to be used for the internal LLVM representation -// of the input value x. -// NOTE: it is not really clear from the naming of this function that -// this returns the *internal* representation, as opposed to to_llvm_type() -// which instead returns the representation used to communicate between -// LLVM and the external world. Perhaps we should consider renaming -// for clarity. template -llvm::Type *llvm_type_like(llvm_state &s, [[maybe_unused]] const T &x) +llvm::Type *to_internal_llvm_type(llvm_state &s, [[maybe_unused]] long long prec) { auto &c = s.context(); #if defined(HEYOKA_HAVE_REAL) - if constexpr (std::is_same_v) { - const auto name = fmt::format("heyoka.real.{}", x.get_prec()); + if constexpr (std::same_as) { + // Checks on prec. + // LCOV_EXCL_START + if (prec == 0 || prec < mppp::real_prec_min() || prec > mppp::real_prec_max()) [[unlikely]] { + throw std::invalid_argument( + fmt::format("An invalid precision value of {} was passed to to_internal_llvm_type()", prec)); + } + // LCOV_EXCL_STOP + + const auto name = fmt::format("heyoka.real.{}", prec); if (auto *ptr = llvm::StructType::getTypeByName(c, name)) { return ptr; } + // Compute the required number of limbs. + // NOTE: this is a computation done in the implementation of mppp::real and + // reproduced here. We should consider exposing this functionality in mp++. + const auto nlimbs + = boost::numeric_cast(prec / GMP_NUMB_BITS + static_cast((prec % GMP_NUMB_BITS) != 0)); + // Fetch the limb array type. - auto *limb_arr_t - = llvm::ArrayType::get(to_llvm_type(c), boost::numeric_cast(x.get_nlimbs())); + auto *limb_arr_t = llvm::ArrayType::get(to_external_llvm_type(c), nlimbs); - auto *ret - = llvm::StructType::create({to_llvm_type(c), to_llvm_type(c), limb_arr_t}, name); + auto *ret = llvm::StructType::create( + {to_external_llvm_type(c), to_external_llvm_type(c), limb_arr_t}, name); assert(ret != nullptr); assert(llvm::StructType::getTypeByName(c, name) == ret); @@ -3236,45 +3243,85 @@ llvm::Type *llvm_type_like(llvm_state &s, [[maybe_unused]] const T &x) return ret; } else { #endif - return to_llvm_type(c); + // NOTE: for anything else than mppp::real, the internal and + // external types coincide. + return to_external_llvm_type(c); +#if defined(HEYOKA_HAVE_REAL) + } +#endif +} + +// Explicit instantiations. +template HEYOKA_DLL_PUBLIC llvm::Type *to_internal_llvm_type(llvm_state &, long long); + +template HEYOKA_DLL_PUBLIC llvm::Type *to_internal_llvm_type(llvm_state &, long long); + +template HEYOKA_DLL_PUBLIC llvm::Type *to_internal_llvm_type(llvm_state &, long long); + +#if defined(HEYOKA_HAVE_REAL128) + +template HEYOKA_DLL_PUBLIC llvm::Type *to_internal_llvm_type(llvm_state &, long long); + +#endif + +#if defined(HEYOKA_HAVE_REAL) + +template HEYOKA_DLL_PUBLIC llvm::Type *to_internal_llvm_type(llvm_state &, long long); + +#endif + +// This helper returns the type to be used for the internal LLVM representation +// of the input value x. +template +llvm::Type *internal_llvm_type_like(llvm_state &s, [[maybe_unused]] const T &x) +{ + auto &c = s.context(); + +#if defined(HEYOKA_HAVE_REAL) + if constexpr (std::is_same_v) { + return to_internal_llvm_type(s, x.get_prec()); + } else { +#endif + // NOTE: for anything else than mppp::real, the internal and + // external types coincide. + return to_external_llvm_type(c); #if defined(HEYOKA_HAVE_REAL) } #endif } // Explicit instantiations. -template HEYOKA_DLL_PUBLIC llvm::Type *llvm_type_like(llvm_state &, const float &); +template HEYOKA_DLL_PUBLIC llvm::Type *internal_llvm_type_like(llvm_state &, const float &); -template HEYOKA_DLL_PUBLIC llvm::Type *llvm_type_like(llvm_state &, const double &); +template HEYOKA_DLL_PUBLIC llvm::Type *internal_llvm_type_like(llvm_state &, const double &); -template HEYOKA_DLL_PUBLIC llvm::Type *llvm_type_like(llvm_state &, const long double &); +template HEYOKA_DLL_PUBLIC llvm::Type *internal_llvm_type_like(llvm_state &, const long double &); #if defined(HEYOKA_HAVE_REAL128) -template HEYOKA_DLL_PUBLIC llvm::Type *llvm_type_like(llvm_state &, const mppp::real128 &); +template HEYOKA_DLL_PUBLIC llvm::Type *internal_llvm_type_like(llvm_state &, const mppp::real128 &); #endif #if defined(HEYOKA_HAVE_REAL) -template HEYOKA_DLL_PUBLIC llvm::Type *llvm_type_like(llvm_state &, const mppp::real &); +template HEYOKA_DLL_PUBLIC llvm::Type *internal_llvm_type_like(llvm_state &, const mppp::real &); #endif -// Compute the LLVM data type to be used for loading external data -// into an LLVM variable of type fp_t. -llvm::Type *llvm_ext_type(llvm::Type *fp_t) +// Fetch the external llvm type corresponding to the input external llvm type. +llvm::Type *make_external_llvm_type(llvm::Type *fp_t) { - if (fp_t->isFloatingPointTy()) { + if (fp_t->isFloatingPointTy() || fp_t->isIntegerTy()) { return fp_t; #if defined(HEYOKA_HAVE_REAL) } else if (llvm_is_real(fp_t) != 0) { - return to_llvm_type(fp_t->getContext()); + return to_external_llvm_type(fp_t->getContext()); #endif // LCOV_EXCL_START } else { throw std::invalid_argument( - fmt::format("Cannot compute the external type for the LLVM type '{}'", llvm_type_name(fp_t))); + fmt::format("Cannot associate an external LLVM type to the internal LLVM type '{}'", llvm_type_name(fp_t))); } // LCOV_EXCL_STOP } diff --git a/src/detail/llvm_helpers_celmec.cpp b/src/detail/llvm_helpers_celmec.cpp index 43ae90dd1..b29356d60 100644 --- a/src/detail/llvm_helpers_celmec.cpp +++ b/src/detail/llvm_helpers_celmec.cpp @@ -76,14 +76,14 @@ number inv_kep_E_pi_like(llvm_state &s, llvm::Type *tp) auto &context = s.context(); - if (tp == to_llvm_type(context, false)) { + if (tp == to_external_llvm_type(context, false)) { return number{boost::math::constants::pi()}; - } else if (tp == to_llvm_type(context, false)) { + } else if (tp == to_external_llvm_type(context, false)) { return number{boost::math::constants::pi()}; - } else if (tp == to_llvm_type(context, false)) { + } else if (tp == to_external_llvm_type(context, false)) { return number{boost::math::constants::pi()}; #if defined(HEYOKA_HAVE_REAL128) - } else if (tp == to_llvm_type(context, false)) { + } else if (tp == to_external_llvm_type(context, false)) { return number{mppp::pi_128}; #endif #if defined(HEYOKA_HAVE_REAL) @@ -196,14 +196,14 @@ std::pair inv_kep_E_dl_twopi_like(llvm_state &s, llvm::Type *fp_ auto &context = s.context(); - if (fp_t == to_llvm_type(context, false)) { + if (fp_t == to_external_llvm_type(context, false)) { return impl(0.f); - } else if (fp_t == to_llvm_type(context, false)) { + } else if (fp_t == to_external_llvm_type(context, false)) { return impl(0.); - } else if (fp_t == to_llvm_type(context, false)) { + } else if (fp_t == to_external_llvm_type(context, false)) { return impl(0.l); #if defined(HEYOKA_HAVE_REAL128) - } else if (fp_t == to_llvm_type(context, false)) { + } else if (fp_t == to_external_llvm_type(context, false)) { return impl(mppp::real128(0)); #endif } @@ -243,14 +243,14 @@ number inv_kep_E_eps_like(llvm_state &s, llvm::Type *tp) auto &context = s.context(); - if (tp == to_llvm_type(context, false)) { + if (tp == to_external_llvm_type(context, false)) { return number{std::numeric_limits::epsilon()}; - } else if (tp == to_llvm_type(context, false)) { + } else if (tp == to_external_llvm_type(context, false)) { return number{std::numeric_limits::epsilon()}; - } else if (tp == to_llvm_type(context, false)) { + } else if (tp == to_external_llvm_type(context, false)) { return number{std::numeric_limits::epsilon()}; #if defined(HEYOKA_HAVE_REAL128) - } else if (tp == to_llvm_type(context, false)) { + } else if (tp == to_external_llvm_type(context, false)) { return number{std::numeric_limits::epsilon()}; #endif #if defined(HEYOKA_HAVE_REAL) @@ -625,7 +625,7 @@ void llvm_add_inv_kep_E_wrapper(llvm_state &s, llvm::Type *scal_t, std::uint32_t auto *impl_f = llvm_add_inv_kep_E(s, scal_t, batch_size); // Fetch the external type. - auto *ext_fp_t = llvm_ext_type(scal_t); + auto *ext_fp_t = make_external_llvm_type(scal_t); // The function arguments: // - output pointer (write only), diff --git a/src/detail/real_helpers.cpp b/src/detail/real_helpers.cpp index 284c0cf60..100684190 100644 --- a/src/detail/real_helpers.cpp +++ b/src/detail/real_helpers.cpp @@ -146,7 +146,7 @@ namespace // Small helper to codegen the MPFR_RNDN constant. llvm::Constant *llvm_mpfr_rndn(llvm_state &s) { - return llvm::ConstantInt::getSigned(to_llvm_type(s.context()), + return llvm::ConstantInt::getSigned(to_external_llvm_type(s.context()), boost::numeric_cast(static_cast(MPFR_RNDN))); } @@ -154,7 +154,7 @@ llvm::Constant *llvm_mpfr_rndn(llvm_state &s) // as an LLVM constant. llvm::Constant *llvm_mpfr_prec(llvm_state &s, mpfr_prec_t prec) { - return llvm::ConstantInt::getSigned(to_llvm_type(s.context()), + return llvm::ConstantInt::getSigned(to_external_llvm_type(s.context()), boost::numeric_cast(prec)); } @@ -180,7 +180,7 @@ std::pair llvm_real_to_mpfr_view(llvm_state &s, ll builder.CreateStore(builder.CreateExtractValue(r, {2u}), limb_arr); // Create the mpfr_struct_t. - auto *real_t = to_llvm_type(s.context()); + auto *real_t = to_external_llvm_type(s.context()); auto *mpfr_struct_inst = builder.CreateAlloca(real_t); // Store the precision. @@ -235,7 +235,7 @@ std::pair llvm_undef_mpfr_view(llvm_state &s, llvm auto *limb_arr = builder.CreateAlloca(limb_arr_t); // Create the mpfr_struct_t. - auto *real_t = to_llvm_type(s.context()); + auto *real_t = to_external_llvm_type(s.context()); auto *mpfr_struct_inst = builder.CreateAlloca(real_t); // Store the precision. @@ -260,7 +260,7 @@ llvm::Value *llvm_mpfr_view_to_real(llvm_state &s, llvm::Value *mpfr_struct_inst auto &builder = s.builder(); - auto *real_t = to_llvm_type(s.context()); + auto *real_t = to_external_llvm_type(s.context()); auto *struct_fp_t = llvm::cast(fp_t); auto *limb_arr_t = struct_fp_t->getElementType(2u); @@ -272,7 +272,7 @@ llvm::Value *llvm_mpfr_view_to_real(llvm_state &s, llvm::Value *mpfr_struct_inst // In debug mode, double check that the precision in the view matches // the precision of fp_t. - auto *prec_t = to_llvm_type(s.context()); + auto *prec_t = to_external_llvm_type(s.context()); // Load the precision value from the view. auto *prec_ptr = builder.CreateInBoundsGEP(real_t, mpfr_struct_inst, {builder.getInt32(0), builder.getInt32(0)}); @@ -344,7 +344,7 @@ llvm::Function *real_nary_op(llvm_state &s, llvm::Type *fp_t, const std::string mpfr_args.push_back(llvm_mpfr_rndn(s)); // Invoke the MPFR primitive. - llvm_invoke_external(s, mpfr_name, to_llvm_type(context), mpfr_args, get_mpfr_attr_list(context)); + llvm_invoke_external(s, mpfr_name, to_external_llvm_type(context), mpfr_args, get_mpfr_attr_list(context)); // Assemble the result. auto *res = llvm_mpfr_view_to_real(s, real_res, limb_arr_res, fp_t); @@ -403,7 +403,8 @@ std::pair llvm_real_sincos(llvm_state &s, llvm::Va mpfr_args.push_back(llvm_mpfr_rndn(s)); // Invoke the MPFR primitive. - llvm_invoke_external(s, "mpfr_sin_cos", to_llvm_type(context), mpfr_args, get_mpfr_attr_list(context)); + llvm_invoke_external(s, "mpfr_sin_cos", to_external_llvm_type(context), mpfr_args, + get_mpfr_attr_list(context)); // Assemble the result. auto *res_sin = llvm_mpfr_view_to_real(s, real_res_sin, limb_arr_res_sin, fp_t); @@ -468,8 +469,8 @@ llvm::Function *real_nary_cmp(llvm_state &s, llvm::Type *fp_t, const std::string } // Invoke the MPFR primitive. - auto *cmp_ret - = llvm_invoke_external(s, mpfr_name, to_llvm_type(context), mpfr_args, get_mpfr_attr_list(context)); + auto *cmp_ret = llvm_invoke_external(s, mpfr_name, to_external_llvm_type(context), mpfr_args, + get_mpfr_attr_list(context)); // Truncate the result to a boolean and return. builder.CreateRet(builder.CreateTrunc(cmp_ret, builder.getInt1Ty())); @@ -666,14 +667,15 @@ llvm::Value *llvm_real_ui_to_fp(llvm_state &s, llvm::Value *n, llvm::Type *fp_t) if (source_int_width == ul_width) { mpfr_args.push_back(f->args().begin()); } else { - mpfr_args.push_back(builder.CreateZExt(f->args().begin(), to_llvm_type(context))); + mpfr_args.push_back(builder.CreateZExt(f->args().begin(), to_external_llvm_type(context))); } // Add the rounding mode. mpfr_args.push_back(llvm_mpfr_rndn(s)); // Invoke the MPFR primitive. - llvm_invoke_external(s, "mpfr_set_ui", to_llvm_type(context), mpfr_args, get_mpfr_attr_list(context)); + llvm_invoke_external(s, "mpfr_set_ui", to_external_llvm_type(context), mpfr_args, + get_mpfr_attr_list(context)); // Assemble the result. auto *res = llvm_mpfr_view_to_real(s, real_res, limb_arr_res, fp_t); @@ -732,7 +734,7 @@ llvm::Value *llvm_real_sgn(llvm_state &s, llvm::Value *x) const std::vector mpfr_args{llvm_real_to_mpfr_view(s, f->args().begin()).first}; // Invoke the MPFR primitive. - auto *int_t = to_llvm_type(context); + auto *int_t = to_external_llvm_type(context); auto *cmp_ret = llvm_invoke_external(s, "heyoka_mpfr_sgn", int_t, mpfr_args, get_mpfr_attr_list(context)); // Compute the int32 return value: cmp_ret == 0 ? 0 : (cmp_ret < 0 ? -1 : 1). diff --git a/src/detail/tm_data.cpp b/src/detail/tm_data.cpp index aae9b701d..0d13dab39 100644 --- a/src/detail/tm_data.cpp +++ b/src/detail/tm_data.cpp @@ -122,8 +122,8 @@ void add_tm_func_nc_mode(llvm_state &st, const std::vector &state, const var_ assert(!state.empty()); // LCOV_EXCL_LINE // NOTE: 'state' has been set up with the correct precision // in the ctor. - auto *fp_t = detail::llvm_type_like(st, state[0]); - auto *ext_fp_t = detail::to_llvm_type(context); + auto *fp_t = detail::internal_llvm_type_like(st, state[0]); + auto *ext_fp_t = detail::to_external_llvm_type(context); auto *ext_ptr_t = llvm::PointerType::getUnqual(ext_fp_t); // Cache the precision. diff --git a/src/expression_cfunc.cpp b/src/expression_cfunc.cpp index f77e73f2e..144916f7a 100644 --- a/src/expression_cfunc.cpp +++ b/src/expression_cfunc.cpp @@ -673,7 +673,7 @@ void add_cfunc_nc_mode(llvm_state &s, llvm::Type *fp_t, llvm::Value *out_ptr, ll std::vector eval_arr; // Fetch the type for external loading. - auto *ext_fp_t = llvm_ext_type(fp_t); + auto *ext_fp_t = make_external_llvm_type(fp_t); // Init it by loading the input values from in_ptr. for (std::uint32_t i = 0; i < nvars; ++i) { @@ -1149,7 +1149,7 @@ void cfunc_c_write_outputs(llvm_state &s, llvm::Type *fp_scal_t, llvm::Value *ou const auto n_pars = gl_arr_size(out_gl[4]); // Fetch the type for external loading. - auto *ext_fp_t = llvm_ext_type(fp_scal_t); + auto *ext_fp_t = make_external_llvm_type(fp_scal_t); // Fetch the vector type. auto *fp_vec_t = make_vector_type(fp_scal_t, batch_size); @@ -1237,7 +1237,7 @@ void add_cfunc_c_mode(llvm_state &s, llvm::Type *fp_type, llvm::Value *out_ptr, auto &md = s.module(); // Fetch the type for external loading. - auto *ext_fp_t = llvm_ext_type(fp_type); + auto *ext_fp_t = make_external_llvm_type(fp_type); // Split dc into segments. const auto s_dc = function_segment_dc(dc, nvars, nuvars); @@ -1452,22 +1452,14 @@ auto add_cfunc_impl(llvm_state &s, const std::string &name, const F &fn, std::ui // - the stride (if requested). // // The pointer arguments cannot overlap. - auto *fp_t = [&]() { -#if defined(HEYOKA_HAVE_REAL) - if constexpr (std::is_same_v) { - return llvm_type_like(s, mppp::real{mppp::real_kind::zero, static_cast(prec)}); - } else { -#endif - return to_llvm_type(context); -#if defined(HEYOKA_HAVE_REAL) - } -#endif - }(); - auto *ext_fp_t = llvm_ext_type(fp_t); + + // Fetch the internal and external types. + auto *fp_t = to_internal_llvm_type(s, prec); + auto *ext_fp_t = make_external_llvm_type(fp_t); std::vector fargs(4, llvm::PointerType::getUnqual(ext_fp_t)); if (strided) { - fargs.push_back(to_llvm_type(context)); + fargs.push_back(to_external_llvm_type(context)); } // The function does not return anything. diff --git a/src/func.cpp b/src/func.cpp index 6e6c7a462..2d8fb602c 100644 --- a/src/func.cpp +++ b/src/func.cpp @@ -710,7 +710,7 @@ llvm::Value *cfunc_nc_param_codegen(llvm_state &s, const param &p, std::uint32_t auto &builder = s.builder(); // Fetch the type for external loading. - auto *ext_fp_t = llvm_ext_type(fp_t); + auto *ext_fp_t = make_external_llvm_type(fp_t); // Determine the index into the parameter array. auto *arr_idx = builder.CreateMul(stride, to_size_t(s, builder.getInt32(p.idx()))); @@ -778,7 +778,7 @@ std::pair> llvm_c_eval_func_name_args(llv auto *val_t = make_vector_type(fp_t, batch_size); // Fetch the type for external loading. - auto *ext_fp_t = llvm_ext_type(fp_t); + auto *ext_fp_t = make_external_llvm_type(fp_t); // Init the name. auto fname = fmt::format("heyoka.llvm_c_eval.{}.", name); @@ -791,7 +791,7 @@ std::pair> llvm_c_eval_func_name_args(llv // - stride value. std::vector fargs{llvm::Type::getInt32Ty(c), llvm::PointerType::getUnqual(val_t), llvm::PointerType::getUnqual(ext_fp_t), llvm::PointerType::getUnqual(ext_fp_t), - to_llvm_type(c)}; + to_external_llvm_type(c)}; // Add the mangling and LLVM arg types for the argument types. for (decltype(args.size()) i = 0; i < args.size(); ++i) { @@ -853,7 +853,7 @@ llvm::Function *llvm_c_eval_func_helper(const std::string &name, auto &context = s.context(); // Fetch the type for external loading. - auto *ext_fp_t = llvm_ext_type(fp_t); + auto *ext_fp_t = make_external_llvm_type(fp_t); // Fetch the vector floating-point type. auto *val_t = make_vector_type(fp_t, batch_size); diff --git a/src/llvm_state.cpp b/src/llvm_state.cpp index 42410b2cc..3d975621f 100644 --- a/src/llvm_state.cpp +++ b/src/llvm_state.cpp @@ -737,7 +737,7 @@ struct llvm_state::jit { // Run several checks to ensure that real_t matches the layout of mppp::real/mpfr_struct_t. // NOTE: these checks need access to the data layout, so we put them here for convenience. const auto &dl = m_lljit->getDataLayout(); - auto *real_t = llvm::cast(detail::to_llvm_type(*m_ctx->getContext())); + auto *real_t = llvm::cast(detail::to_external_llvm_type(*m_ctx->getContext())); const auto *slo = dl.getStructLayout(real_t); assert(slo->getSizeInBytes() == sizeof(mppp::real)); assert(slo->getAlignment().value() == alignof(mppp::real)); diff --git a/src/math/erf.cpp b/src/math/erf.cpp index 8cd162ca8..1a3b070f2 100644 --- a/src/math/erf.cpp +++ b/src/math/erf.cpp @@ -136,14 +136,14 @@ number sqrt_pi_2_like(llvm_state &s, llvm::Type *tp) auto &context = s.context(); - if (tp == to_llvm_type(context, false)) { + if (tp == to_external_llvm_type(context, false)) { return number{std::sqrt(boost::math::constants::pi()) / 2}; - } else if (tp == to_llvm_type(context, false)) { + } else if (tp == to_external_llvm_type(context, false)) { return number{std::sqrt(boost::math::constants::pi()) / 2}; - } else if (tp == to_llvm_type(context, false)) { + } else if (tp == to_external_llvm_type(context, false)) { return number{std::sqrt(boost::math::constants::pi()) / 2}; #if defined(HEYOKA_HAVE_REAL128) - } else if (tp == to_llvm_type(context, false)) { + } else if (tp == to_external_llvm_type(context, false)) { return number{mppp::sqrt(mppp::pi_128) / 2}; #endif #if defined(HEYOKA_HAVE_REAL) diff --git a/src/number.cpp b/src/number.cpp index 8b789bc3d..2aa7412dd 100644 --- a/src/number.cpp +++ b/src/number.cpp @@ -642,14 +642,14 @@ number number_like(llvm_state &s, llvm::Type *tp, double val) auto &context = s.context(); - if (tp == to_llvm_type(context, false)) { + if (tp == to_external_llvm_type(context, false)) { return number{static_cast(val)}; - } else if (tp == to_llvm_type(context, false)) { + } else if (tp == to_external_llvm_type(context, false)) { return number{val}; - } else if (tp == to_llvm_type(context, false)) { + } else if (tp == to_external_llvm_type(context, false)) { return number{static_cast(val)}; #if defined(HEYOKA_HAVE_REAL128) - } else if (tp == to_llvm_type(context, false)) { + } else if (tp == to_external_llvm_type(context, false)) { return number{static_cast(val)}; #endif #if defined(HEYOKA_HAVE_REAL) diff --git a/src/taylor_00.cpp b/src/taylor_00.cpp index 031316fc1..6861f7b8a 100644 --- a/src/taylor_00.cpp +++ b/src/taylor_00.cpp @@ -478,7 +478,7 @@ void taylor_write_tc( auto *fp_vec_t = make_vector_type(fp_t, batch_size); // Fetch the external type corresponding to fp_t. - auto *ext_fp_t = llvm_ext_type(fp_t); + auto *ext_fp_t = make_external_llvm_type(fp_t); // Convert to std::uint32_t for overflow checking and use below. const auto n_sv_funcs = boost::numeric_cast(sv_funcs_dc.size()); diff --git a/src/taylor_01.cpp b/src/taylor_01.cpp index 8f6b9c047..18db4b08b 100644 --- a/src/taylor_01.cpp +++ b/src/taylor_01.cpp @@ -110,7 +110,7 @@ taylor_c_diff_func_name_args(llvm::LLVMContext &context, llvm::Type *fp_t, const auto *val_t = make_vector_type(fp_t, batch_size); // Fetch the external type corresponding to fp_t. - auto *ext_fp_t = llvm_ext_type(fp_t); + auto *ext_fp_t = make_external_llvm_type(fp_t); // Init the name. auto fname = fmt::format("heyoka.taylor_c_diff.{}.", name); @@ -212,7 +212,7 @@ llvm::Value *taylor_codegen_numparam(llvm_state &s, llvm::Type *fp_t, const para auto &builder = s.builder(); // Fetch the external type corresponding to fp_t. - auto *ext_fp_t = llvm_ext_type(fp_t); + auto *ext_fp_t = make_external_llvm_type(fp_t); // Determine the index into the parameter array. // LCOV_EXCL_START @@ -247,7 +247,7 @@ llvm::Value *taylor_c_diff_numparam_codegen(llvm_state &s, llvm::Type *fp_t, con auto &builder = s.builder(); // Fetch the external type corresponding to fp_t. - auto *ext_fp_t = llvm_ext_type(fp_t); + auto *ext_fp_t = make_external_llvm_type(fp_t); // Fetch the pointer into par_ptr. // NOTE: the overflow check is done when constructing the integrator. @@ -949,7 +949,7 @@ void taylor_add_d_out_function(llvm_state &s, llvm::Type *fp_scal_t, std::uint32 auto &context = s.context(); // Fetch the external type corresponding to fp_scal_t. - auto *ext_fp_scal_t = llvm_ext_type(fp_scal_t); + auto *ext_fp_scal_t = make_external_llvm_type(fp_scal_t); // Fetch the current insertion block. auto *orig_bb = builder.GetInsertBlock(); diff --git a/src/taylor_02.cpp b/src/taylor_02.cpp index 62568abc1..9bfdd5238 100644 --- a/src/taylor_02.cpp +++ b/src/taylor_02.cpp @@ -683,7 +683,7 @@ std::pair taylor_compute_jet_compact_mode( auto &md = s.module(); // Fetch the external type corresponding to fp_type. - auto *ext_fp_t = llvm_ext_type(fp_type); + auto *ext_fp_t = make_external_llvm_type(fp_type); // Split dc into segments. const auto s_dc = taylor_segment_dc(dc, n_eq); @@ -1092,7 +1092,7 @@ auto taylor_load_values(llvm_state &s, llvm::Type *fp_t, llvm::Value *in, std::u auto &builder = s.builder(); // Fetch the external type corresponding to fp_t. - auto *ext_fp_t = llvm_ext_type(fp_t); + auto *ext_fp_t = make_external_llvm_type(fp_t); std::vector retval; for (std::uint32_t i = 0; i < n; ++i) { diff --git a/src/taylor_adaptive.cpp b/src/taylor_adaptive.cpp index 642e7929d..38cf97974 100644 --- a/src/taylor_adaptive.cpp +++ b/src/taylor_adaptive.cpp @@ -386,12 +386,12 @@ void taylor_adaptive::finalise_ctor_impl(sys_t vsys, std::vector state, m_order = detail::taylor_order_from_tol(m_tol); // Determine the external fp type. - auto *ext_fp_t = detail::to_llvm_type(m_llvm.context()); + auto *ext_fp_t = detail::to_external_llvm_type(m_llvm.context()); // Determine the internal fp type. // NOTE: in case of mppp::real, we ensured earlier that the tolerance value - // has the correct precision, so that llvm_type_like() will yield the correct internal type. - auto *fp_t = detail::llvm_type_like(m_llvm, m_tol); + // has the correct precision, so that internal_llvm_type_like() will yield the correct internal type. + auto *fp_t = detail::internal_llvm_type_like(m_llvm, m_tol); // Add the stepper function. if (with_events) { @@ -437,7 +437,7 @@ void taylor_adaptive::finalise_ctor_impl(sys_t vsys, std::vector state, // Add the function for the computation of // the dense output. - detail::taylor_add_d_out_function(m_llvm, detail::llvm_type_like(m_llvm, m_state[0]), m_dim, m_order, 1, + detail::taylor_add_d_out_function(m_llvm, detail::internal_llvm_type_like(m_llvm, m_state[0]), m_dim, m_order, 1, high_accuracy); detail::get_logger()->trace("Taylor dense output runtime: {}", sw); diff --git a/src/taylor_adaptive_batch.cpp b/src/taylor_adaptive_batch.cpp index 8b18876ed..a8e0f6046 100644 --- a/src/taylor_adaptive_batch.cpp +++ b/src/taylor_adaptive_batch.cpp @@ -243,10 +243,10 @@ void taylor_adaptive_batch::finalise_ctor_impl(sys_t vsys, std::vector sta m_order = detail::taylor_order_from_tol(m_tol); // Determine the external fp type. - auto *ext_fp_t = detail::to_llvm_type(m_llvm.context()); + auto *ext_fp_t = detail::to_external_llvm_type(m_llvm.context()); // Determine the internal fp type. - auto *fp_t = detail::llvm_type_like(m_llvm, m_tol); + auto *fp_t = detail::internal_llvm_type_like(m_llvm, m_tol); // Add the stepper function. if (with_events) { @@ -284,8 +284,8 @@ void taylor_adaptive_batch::finalise_ctor_impl(sys_t vsys, std::vector sta // Add the function for the computation of // the dense output. - detail::taylor_add_d_out_function(m_llvm, detail::to_llvm_type(m_llvm.context()), m_dim, m_order, m_batch_size, - high_accuracy); + detail::taylor_add_d_out_function(m_llvm, detail::to_external_llvm_type(m_llvm.context()), m_dim, m_order, + m_batch_size, high_accuracy); detail::get_logger()->trace("Taylor batch dense output runtime: {}", sw); sw.reset(); diff --git a/test/event_detection.cpp b/test/event_detection.cpp index bd6a633a6..5ed543dc1 100644 --- a/test/event_detection.cpp +++ b/test/event_detection.cpp @@ -110,7 +110,8 @@ TEST_CASE("fast exclusion check") llvm_state s{kw::opt_level = opt_level}; // Add the function and fetch it. - detail::llvm_add_fex_check(s, detail::to_llvm_type(s.context()), order, batch_size, use_cs); + detail::llvm_add_fex_check(s, detail::to_external_llvm_type(s.context()), order, batch_size, + use_cs); s.compile(); auto fex_check = reinterpret_cast(s.jit_lookup("fex_check")); diff --git a/test/event_detection_mp.cpp b/test/event_detection_mp.cpp index 0daf4b93f..7f45e25d8 100644 --- a/test/event_detection_mp.cpp +++ b/test/event_detection_mp.cpp @@ -67,7 +67,7 @@ TEST_CASE("poly translator 1") llvm_state s{kw::opt_level = opt_level}; - detail::add_poly_translator_1(s, detail::llvm_type_like(s, input[0]), 5, 1); + detail::add_poly_translator_1(s, detail::internal_llvm_type_like(s, input[0]), 5, 1); s.compile(); @@ -96,9 +96,9 @@ TEST_CASE("poly csc") llvm_state s{kw::opt_level = opt_level}; - const auto mname = detail::llvm_mangle_type(detail::llvm_type_like(s, input[0])); + const auto mname = detail::llvm_mangle_type(detail::internal_llvm_type_like(s, input[0])); - detail::llvm_add_csc(s, detail::llvm_type_like(s, input[0]), 5, 1); + detail::llvm_add_csc(s, detail::internal_llvm_type_like(s, input[0]), 5, 1); s.compile(); @@ -152,8 +152,7 @@ TEST_CASE("event construction") { std::ostringstream oss; - t_ev_t ev( - x - 1., kw::callback = [](const taylor_adaptive &, int) { return true; }); + t_ev_t ev(x - 1., kw::callback = [](const taylor_adaptive &, int) { return true; }); oss << ev; diff --git a/test/llvm_helpers.cpp b/test/llvm_helpers.cpp index 711f09216..a09f40f1a 100644 --- a/test/llvm_helpers.cpp +++ b/test/llvm_helpers.cpp @@ -73,7 +73,7 @@ constexpr auto ntrials = 100; TEST_CASE("sgn scalar") { using detail::llvm_sgn; - using detail::to_llvm_type; + using detail::to_external_llvm_type; auto tester = [](auto fp_x) { using fp_t = decltype(fp_x); @@ -85,7 +85,7 @@ TEST_CASE("sgn scalar") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); auto *ft = llvm::FunctionType::get(builder.getInt32Ty(), {val_t}, false); auto *f = llvm::Function::Create(ft, llvm::Function::ExternalLinkage, "sgn", &md); @@ -117,7 +117,7 @@ TEST_CASE("sgn scalar") TEST_CASE("sgn scalar mp") { using detail::llvm_sgn; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using fp_t = mppp::real; @@ -130,8 +130,8 @@ TEST_CASE("sgn scalar mp") auto &builder = s.builder(); auto &context = s.context(); - auto *val_t = to_llvm_type(context); - auto *real_t = detail::llvm_type_like(s, mppp::real{0, prec}); + auto *val_t = to_external_llvm_type(context); + auto *real_t = detail::internal_llvm_type_like(s, mppp::real{0, prec}); auto *ft = llvm::FunctionType::get(builder.getInt32Ty(), {llvm::PointerType::getUnqual(val_t)}, false); auto *f = llvm::Function::Create(ft, llvm::Function::ExternalLinkage, "sgn", &md); @@ -178,7 +178,7 @@ int sgn(T val) TEST_CASE("sgn batch") { using detail::llvm_sgn; - using detail::to_llvm_type; + using detail::to_external_llvm_type; auto tester = [](auto fp_x) { using fp_t = decltype(fp_x); @@ -191,7 +191,7 @@ TEST_CASE("sgn batch") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); auto *ft = llvm::FunctionType::get( builder.getVoidTy(), @@ -242,7 +242,7 @@ TEST_CASE("sgn batch") TEST_CASE("sincos scalar") { using detail::llvm_sincos; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::cos; using std::sin; @@ -256,7 +256,7 @@ TEST_CASE("sincos scalar") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs{val_t, llvm::PointerType::getUnqual(val_t), llvm::PointerType::getUnqual(val_t)}; @@ -299,7 +299,7 @@ TEST_CASE("sincos scalar") TEST_CASE("sincos batch") { using detail::llvm_sincos; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::cos; using std::sin; @@ -314,7 +314,7 @@ TEST_CASE("sincos batch") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs{llvm::PointerType::getUnqual(val_t), llvm::PointerType::getUnqual(val_t), @@ -367,7 +367,7 @@ TEST_CASE("sincos batch") TEST_CASE("sincos mp") { using detail::llvm_sincos; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::cos; using std::sin; @@ -380,8 +380,8 @@ TEST_CASE("sincos mp") auto &builder = s.builder(); auto &context = s.context(); - auto *real_t = to_llvm_type(context); - auto *fp_t = detail::llvm_type_like(s, mppp::real{0, prec}); + auto *real_t = to_external_llvm_type(context); + auto *fp_t = detail::internal_llvm_type_like(s, mppp::real{0, prec}); const std::vector fargs(3u, llvm::PointerType::getUnqual(real_t)); auto *ft = llvm::FunctionType::get(builder.getVoidTy(), fargs, false); @@ -431,7 +431,7 @@ TEST_CASE("inv_kep_E_scalar") llvm_state s{kw::opt_level = opt_level}; // Add the function. - llvm_add_inv_kep_E_wrapper(s, detail::to_llvm_type(s.context()), 1, "hey_kep"); + llvm_add_inv_kep_E_wrapper(s, detail::to_external_llvm_type(s.context()), 1, "hey_kep"); // Compile. s.compile(); @@ -575,7 +575,7 @@ TEST_CASE("inv_kep_E_batch") llvm_state s{kw::opt_level = opt_level}; // Add the function. - llvm_add_inv_kep_E_wrapper(s, detail::to_llvm_type(s.context()), batch_size, "hey_kep"); + llvm_add_inv_kep_E_wrapper(s, detail::to_external_llvm_type(s.context()), batch_size, "hey_kep"); // Compile. s.compile(); @@ -810,7 +810,7 @@ TEST_CASE("inv_kep_E_scalar mp") for (auto opt_level : {0u, 1u, 2u, 3u}) { llvm_state s{kw::opt_level = opt_level}; - auto *fp_t = detail::llvm_type_like(s, mppp::real{0, prec}); + auto *fp_t = detail::internal_llvm_type_like(s, mppp::real{0, prec}); // Add the function. llvm_add_inv_kep_E_wrapper(s, fp_t, 1, "hey_kep"); @@ -1078,7 +1078,7 @@ TEST_CASE("csc_scalar") { using detail::llvm_add_csc; using detail::llvm_mangle_type; - using detail::to_llvm_type; + using detail::to_external_llvm_type; auto tester = [](auto fp_x) { using fp_t = decltype(fp_x); @@ -1088,12 +1088,12 @@ TEST_CASE("csc_scalar") const auto degree = 4u; - llvm_add_csc(s, to_llvm_type(s.context()), degree, 1); + llvm_add_csc(s, to_external_llvm_type(s.context()), degree, 1); s.compile(); - auto f_ptr = reinterpret_cast(s.jit_lookup( - fmt::format("heyoka_csc_degree_{}_{}", degree, llvm_mangle_type(to_llvm_type(s.context()))))); + auto f_ptr = reinterpret_cast(s.jit_lookup(fmt::format( + "heyoka_csc_degree_{}_{}", degree, llvm_mangle_type(to_external_llvm_type(s.context()))))); // Random testing. std::uniform_real_distribution rdist(-10., 10.); @@ -1151,7 +1151,7 @@ TEST_CASE("csc_batch") using detail::llvm_add_csc; using detail::llvm_mangle_type; using detail::make_vector_type; - using detail::to_llvm_type; + using detail::to_external_llvm_type; auto tester = [](auto fp_x) { using fp_t = decltype(fp_x); @@ -1162,13 +1162,13 @@ TEST_CASE("csc_batch") const auto degree = 4u; - llvm_add_csc(s, to_llvm_type(s.context()), degree, batch_size); + llvm_add_csc(s, to_external_llvm_type(s.context()), degree, batch_size); s.compile(); - auto f_ptr = reinterpret_cast(s.jit_lookup( - fmt::format("heyoka_csc_degree_{}_{}", degree, - llvm_mangle_type(make_vector_type(to_llvm_type(s.context()), batch_size))))); + auto f_ptr = reinterpret_cast(s.jit_lookup(fmt::format( + "heyoka_csc_degree_{}_{}", degree, + llvm_mangle_type(make_vector_type(to_external_llvm_type(s.context()), batch_size))))); // Random testing. std::uniform_real_distribution rdist(-10., 10.); @@ -1226,7 +1226,7 @@ TEST_CASE("csc_batch") TEST_CASE("minmax") { - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::isnan; auto tester = [](auto fp_x) { @@ -1240,7 +1240,7 @@ TEST_CASE("minmax") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs{llvm::PointerType::getUnqual(val_t), llvm::PointerType::getUnqual(val_t), @@ -1437,7 +1437,7 @@ TEST_CASE("minmax") TEST_CASE("fma scalar") { using detail::llvm_fma; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::fma; auto tester = [](auto fp_x) { @@ -1450,7 +1450,7 @@ TEST_CASE("fma scalar") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs{val_t, val_t, val_t}; auto *ft = llvm::FunctionType::get(val_t, fargs, false); @@ -1484,7 +1484,7 @@ TEST_CASE("fma scalar") TEST_CASE("fma batch") { using detail::llvm_fma; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::fma; auto tester = [](auto fp_x) { @@ -1498,7 +1498,7 @@ TEST_CASE("fma batch") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs(4u, llvm::PointerType::getUnqual(val_t)); auto *ft = llvm::FunctionType::get(builder.getVoidTy(), fargs, false); @@ -1554,7 +1554,7 @@ TEST_CASE("fma batch") TEST_CASE("fma scalar mp") { using detail::llvm_fma; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::fma; const auto prec = 237u; @@ -1566,8 +1566,8 @@ TEST_CASE("fma scalar mp") auto &builder = s.builder(); auto &context = s.context(); - auto *real_t = to_llvm_type(context); - auto *fp_t = detail::llvm_type_like(s, mppp::real{0, prec}); + auto *real_t = to_external_llvm_type(context); + auto *fp_t = detail::internal_llvm_type_like(s, mppp::real{0, prec}); const std::vector fargs(4u, llvm::PointerType::getUnqual(real_t)); auto *ft = llvm::FunctionType::get(builder.getVoidTy(), fargs, false); @@ -1612,7 +1612,7 @@ TEST_CASE("fma scalar mp") TEST_CASE("eft_product scalar") { using detail::llvm_eft_product; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::abs; auto tester = [](auto fp_x) { @@ -1625,7 +1625,7 @@ TEST_CASE("eft_product scalar") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs{llvm::PointerType::getUnqual(val_t), llvm::PointerType::getUnqual(val_t), val_t, val_t}; @@ -1692,7 +1692,7 @@ TEST_CASE("eft_product scalar") TEST_CASE("eft_product batch") { using detail::llvm_eft_product; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::abs; auto tester = [](auto fp_x) { @@ -1706,7 +1706,7 @@ TEST_CASE("eft_product batch") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs(4u, llvm::PointerType::getUnqual(val_t)); auto *ft = llvm::FunctionType::get(builder.getVoidTy(), fargs, false); @@ -1782,7 +1782,7 @@ TEST_CASE("eft_product batch") TEST_CASE("dl mul scalar") { using detail::llvm_dl_mul; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::abs; auto tester = [](auto fp_x) { @@ -1795,7 +1795,7 @@ TEST_CASE("dl mul scalar") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs{ llvm::PointerType::getUnqual(val_t), llvm::PointerType::getUnqual(val_t), val_t, val_t, val_t, val_t}; @@ -1881,7 +1881,7 @@ TEST_CASE("dl mul scalar") TEST_CASE("dl mul batch") { using detail::llvm_dl_mul; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::abs; auto tester = [](auto fp_x) { @@ -1895,7 +1895,7 @@ TEST_CASE("dl mul batch") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs(6u, llvm::PointerType::getUnqual(val_t)); auto *ft = llvm::FunctionType::get(builder.getVoidTy(), fargs, false); @@ -1997,7 +1997,7 @@ TEST_CASE("dl mul batch") TEST_CASE("dl div scalar") { using detail::llvm_dl_div; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::abs; auto tester = [](auto fp_x) { @@ -2010,7 +2010,7 @@ TEST_CASE("dl div scalar") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs{ llvm::PointerType::getUnqual(val_t), llvm::PointerType::getUnqual(val_t), val_t, val_t, val_t, val_t}; @@ -2092,7 +2092,7 @@ TEST_CASE("dl div scalar") TEST_CASE("dl div batch") { using detail::llvm_dl_div; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::abs; auto tester = [](auto fp_x) { @@ -2106,7 +2106,7 @@ TEST_CASE("dl div batch") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs(6u, llvm::PointerType::getUnqual(val_t)); auto *ft = llvm::FunctionType::get(builder.getVoidTy(), fargs, false); @@ -2203,7 +2203,7 @@ TEST_CASE("dl div batch") TEST_CASE("floor scalar") { using detail::llvm_floor; - using detail::to_llvm_type; + using detail::to_external_llvm_type; auto tester = [](auto fp_x) { using fp_t = decltype(fp_x); @@ -2215,7 +2215,7 @@ TEST_CASE("floor scalar") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs{val_t}; auto *ft = llvm::FunctionType::get(val_t, fargs, false); @@ -2246,7 +2246,7 @@ TEST_CASE("floor scalar") TEST_CASE("floor batch") { using detail::llvm_floor; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::floor; auto tester = [](auto fp_x) { @@ -2260,7 +2260,7 @@ TEST_CASE("floor batch") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs(2u, llvm::PointerType::getUnqual(val_t)); auto *ft = llvm::FunctionType::get(builder.getVoidTy(), fargs, false); @@ -2304,7 +2304,7 @@ TEST_CASE("floor batch") TEST_CASE("dl floor scalar") { using detail::llvm_dl_floor; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::abs; using std::floor; using std::trunc; @@ -2319,7 +2319,7 @@ TEST_CASE("dl floor scalar") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs{llvm::PointerType::getUnqual(val_t), llvm::PointerType::getUnqual(val_t), val_t, val_t}; @@ -2386,7 +2386,7 @@ TEST_CASE("dl floor scalar") TEST_CASE("dl floor batch") { using detail::llvm_dl_floor; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::abs; using std::floor; using std::trunc; @@ -2402,7 +2402,7 @@ TEST_CASE("dl floor batch") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs(4u, llvm::PointerType::getUnqual(val_t)); auto *ft = llvm::FunctionType::get(builder.getVoidTy(), fargs, false); @@ -2481,7 +2481,7 @@ TEST_CASE("dl floor batch") TEST_CASE("dl modulus scalar") { using detail::llvm_dl_modulus; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::floor; auto tester = [](auto fp_x) { @@ -2494,7 +2494,7 @@ TEST_CASE("dl modulus scalar") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs{ llvm::PointerType::getUnqual(val_t), llvm::PointerType::getUnqual(val_t), val_t, val_t, val_t, val_t}; @@ -2559,7 +2559,7 @@ TEST_CASE("dl modulus scalar") TEST_CASE("dl modulus batch") { using detail::llvm_dl_modulus; - using detail::to_llvm_type; + using detail::to_external_llvm_type; using std::floor; auto tester = [](auto fp_x) { @@ -2573,7 +2573,7 @@ TEST_CASE("dl modulus batch") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = to_llvm_type(context); + auto val_t = to_external_llvm_type(context); std::vector fargs(6u, llvm::PointerType::getUnqual(val_t)); auto *ft = llvm::FunctionType::get(builder.getVoidTy(), fargs, false); @@ -2659,19 +2659,19 @@ TEST_CASE("get_alignment") auto &context = s.context(); auto &builder = s.builder(); - auto *tp = detail::to_llvm_type(context); + auto *tp = detail::to_external_llvm_type(context); REQUIRE(detail::get_alignment(md, tp) == alignof(float)); - tp = detail::to_llvm_type(context); + tp = detail::to_external_llvm_type(context); REQUIRE(detail::get_alignment(md, tp) == alignof(double)); #if !defined(HEYOKA_ARCH_PPC) - tp = detail::to_llvm_type(context); + tp = detail::to_external_llvm_type(context); REQUIRE(detail::get_alignment(md, tp) == alignof(long double)); #endif #if defined(HEYOKA_HAVE_REAL128) - tp = detail::to_llvm_type(context); + tp = detail::to_external_llvm_type(context); REQUIRE(detail::get_alignment(md, tp) == alignof(mppp::real128)); #endif @@ -2690,7 +2690,7 @@ TEST_CASE("to_size_t") auto &context = s.context(); std::vector fargs(1, builder.getInt32Ty()); - auto *lst = to_llvm_type(context); + auto *lst = to_external_llvm_type(context); auto *ft = llvm::FunctionType::get(lst, fargs, false); auto *f = llvm::Function::Create(ft, llvm::Function::ExternalLinkage, "test", &s.module()); @@ -2715,7 +2715,7 @@ TEST_CASE("to_size_t") auto &builder = s.builder(); auto &context = s.context(); - auto *lst = to_llvm_type(context); + auto *lst = to_external_llvm_type(context); std::vector fargs{llvm::PointerType::getUnqual(lst), llvm::PointerType::getUnqual(builder.getInt32Ty())}; auto *ft = llvm::FunctionType::get(builder.getVoidTy(), fargs, false); @@ -2755,7 +2755,7 @@ TEST_CASE("to_size_t") auto &context = s.context(); std::vector fargs(1, builder.getInt64Ty()); - auto *lst = to_llvm_type(context); + auto *lst = to_external_llvm_type(context); auto *ft = llvm::FunctionType::get(lst, fargs, false); auto *f = llvm::Function::Create(ft, llvm::Function::ExternalLinkage, "test", &s.module()); @@ -2780,7 +2780,7 @@ TEST_CASE("to_size_t") auto &builder = s.builder(); auto &context = s.context(); - auto *lst = to_llvm_type(context); + auto *lst = to_external_llvm_type(context); std::vector fargs{llvm::PointerType::getUnqual(lst), llvm::PointerType::getUnqual(builder.getInt64Ty())}; auto *ft = llvm::FunctionType::get(builder.getVoidTy(), fargs, false); @@ -2824,7 +2824,7 @@ TEST_CASE("real_ext_load") auto &builder = s.builder(); auto &context = s.context(); - auto *real_t = detail::to_llvm_type(context); + auto *real_t = detail::to_external_llvm_type(context); const auto real_pi_257 = mppp::real_pi(257); @@ -2835,7 +2835,8 @@ TEST_CASE("real_ext_load") builder.SetInsertPoint(llvm::BasicBlock::Create(context, "entry", f)); // Load the input from the first pointer. - auto *real_val = detail::ext_load_vector_from_memory(s, detail::llvm_type_like(s, real_pi_257), f->arg_begin(), 1); + auto *real_val + = detail::ext_load_vector_from_memory(s, detail::internal_llvm_type_like(s, real_pi_257), f->arg_begin(), 1); // Write it out. detail::ext_store_vector_to_memory(s, f->arg_begin() + 1, real_val); diff --git a/test/number.cpp b/test/number.cpp index f22881578..3b534cf5a 100644 --- a/test/number.cpp +++ b/test/number.cpp @@ -429,7 +429,7 @@ TEST_CASE("llvm_codegen") auto &builder = s.builder(); auto &context = s.context(); - auto *fp_t = detail::to_llvm_type(context); + auto *fp_t = detail::to_external_llvm_type(context); auto *ft = llvm::FunctionType::get(fp_t, {}, false); auto *f = llvm::Function::Create(ft, llvm::Function::ExternalLinkage, "test", &md); @@ -453,7 +453,7 @@ TEST_CASE("llvm_codegen") auto &builder = s.builder(); auto &context = s.context(); - auto *fp_t = detail::to_llvm_type(context); + auto *fp_t = detail::to_external_llvm_type(context); auto *ft = llvm::FunctionType::get(fp_t, {}, false); auto *f = llvm::Function::Create(ft, llvm::Function::ExternalLinkage, "test", &md); @@ -476,7 +476,7 @@ TEST_CASE("llvm_codegen") auto &builder = s.builder(); auto &context = s.context(); - auto *fp_t = detail::to_llvm_type(context); + auto *fp_t = detail::to_external_llvm_type(context); auto *ft = llvm::FunctionType::get(fp_t, {}, false); auto *f = llvm::Function::Create(ft, llvm::Function::ExternalLinkage, "test", &md); @@ -504,7 +504,7 @@ TEST_CASE("llvm_codegen") auto &builder = s.builder(); auto &context = s.context(); - auto *fp_t = detail::to_llvm_type(context); + auto *fp_t = detail::to_external_llvm_type(context); auto *ft = llvm::FunctionType::get(fp_t, {}, false); auto *f = llvm::Function::Create(ft, llvm::Function::ExternalLinkage, "test", &md); @@ -528,7 +528,7 @@ TEST_CASE("llvm_codegen") auto &builder = s.builder(); auto &context = s.context(); - auto *fp_t = detail::to_llvm_type(context); + auto *fp_t = detail::to_external_llvm_type(context); auto *ft = llvm::FunctionType::get(fp_t, {}, false); auto *f = llvm::Function::Create(ft, llvm::Function::ExternalLinkage, "test", &md); @@ -551,7 +551,7 @@ TEST_CASE("llvm_codegen") auto &builder = s.builder(); auto &context = s.context(); - auto *fp_t = detail::to_llvm_type(context); + auto *fp_t = detail::to_external_llvm_type(context); auto *ft = llvm::FunctionType::get(fp_t, {}, false); auto *f = llvm::Function::Create(ft, llvm::Function::ExternalLinkage, "test", &md); @@ -650,7 +650,7 @@ TEST_CASE("llvm_codegen") auto &builder = s.builder(); auto &context = s.context(); - auto *fp_t = detail::to_llvm_type(context); + auto *fp_t = detail::to_external_llvm_type(context); auto *ft = llvm::FunctionType::get(fp_t, {}, false); auto *f = llvm::Function::Create(ft, llvm::Function::ExternalLinkage, "test", &md); @@ -674,7 +674,7 @@ TEST_CASE("llvm_codegen") auto &builder = s.builder(); auto &context = s.context(); - auto *real_t = detail::to_llvm_type(context); + auto *real_t = detail::to_external_llvm_type(context); const auto real_pi_256 = mppp::real_pi(256); @@ -683,7 +683,7 @@ TEST_CASE("llvm_codegen") builder.SetInsertPoint(llvm::BasicBlock::Create(context, "entry", f)); - auto *real_val = llvm_codegen(s, detail::llvm_type_like(s, real_pi_256), number{real_pi_256}); + auto *real_val = llvm_codegen(s, detail::internal_llvm_type_like(s, real_pi_256), number{real_pi_256}); detail::ext_store_vector_to_memory(s, f->arg_begin(), real_val); @@ -723,8 +723,8 @@ TEST_CASE("number_like") if (std::numeric_limits::digits == 53) { // NOTE: here we are on Windows + MSVC, where long double == double // and thus C++ long double associates to LLVM double. - // In number_like(), we check tp == to_llvm_type *before* - // tp == to_llvm_type, so we get a number containing + // In number_like(), we check tp == to_external_llvm_type *before* + // tp == to_external_llvm_type, so we get a number containing // double rather than long double. num = detail::number_like(s, llvm::Type::getDoubleTy(s.context()), 42); REQUIRE(num == number{42.}); diff --git a/test/poly_enclosures.cpp b/test/poly_enclosures.cpp index 0d4979567..01fd97867 100644 --- a/test/poly_enclosures.cpp +++ b/test/poly_enclosures.cpp @@ -74,7 +74,7 @@ TEST_CASE("polynomial enclosures") auto &builder = s.builder(); auto &context = s.context(); - auto val_t = detail::to_llvm_type(context); + auto val_t = detail::to_external_llvm_type(context); auto ptr_val_t = llvm::PointerType::getUnqual(val_t); // Fetch the current insertion block. @@ -209,8 +209,8 @@ TEST_CASE("polynomial enclosures mp") auto &builder = s.builder(); auto &context = s.context(); - auto *val_t = detail::llvm_type_like(s, fp_t{0, prec}); - auto *ext_val_t = detail::llvm_ext_type(val_t); + auto *val_t = detail::internal_llvm_type_like(s, fp_t{0, prec}); + auto *ext_val_t = detail::make_external_llvm_type(val_t); auto *ext_ptr_val_t = llvm::PointerType::getUnqual(ext_val_t); // Fetch the current insertion block.