Skip to content

Commit

Permalink
Merge pull request #343 from bluescarni/pr/cleanup
Browse files Browse the repository at this point in the history
General cleanups
  • Loading branch information
bluescarni authored Sep 2, 2023
2 parents e59e24e + 242f52c commit f2ccb29
Show file tree
Hide file tree
Showing 39 changed files with 1 addition and 1,563 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ set(HEYOKA_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/acosh.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/atanh.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/erf.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/tpoly.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/sum.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/prod.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/constants.cpp"
Expand Down
2 changes: 0 additions & 2 deletions include/heyoka/detail/llvm_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ HEYOKA_DLL_PUBLIC void llvm_switch_u32(llvm_state &, llvm::Value *, const std::f

HEYOKA_DLL_PUBLIC std::string llvm_type_name(llvm::Type *);

HEYOKA_DLL_PUBLIC bool compare_function_signature(llvm::Function *, llvm::Type *, const std::vector<llvm::Type *> &);

void llvm_append_block(llvm::Function *, llvm::BasicBlock *);

// Math helpers.
Expand Down
11 changes: 0 additions & 11 deletions include/heyoka/detail/taylor_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,6 @@ inline llvm::Function *taylor_c_diff_func_numpar(llvm_state &s, llvm::Type *fp_t

// Restore the original insertion block.
builder.SetInsertPoint(orig_bb);
} else {
// LCOV_EXCL_START
// The function was created before. Check if the signatures match.
// NOTE: there could be a mismatch if the derivative function was created
// and then optimised - optimisation might remove arguments which are compile-time
// constants.
if (!compare_function_signature(f, val_t, fargs)) {
throw std::invalid_argument(fmt::format(
"Inconsistent function signature for the Taylor derivative of {}() in compact mode detected", name));
}
// LCOV_EXCL_STOP
}

return f;
Expand Down
3 changes: 1 addition & 2 deletions include/heyoka/llvm_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class HEYOKA_DLL_PUBLIC llvm_state
HEYOKA_DLL_LOCAL void ctor_setup_math_flags();

// Low-level implementation details for compilation.
HEYOKA_DLL_LOCAL void optimise();
HEYOKA_DLL_LOCAL void compile_impl();
HEYOKA_DLL_LOCAL void add_obj_trigger();

Expand Down Expand Up @@ -262,8 +263,6 @@ class HEYOKA_DLL_PUBLIC llvm_state
void verify_function(const std::string &);
void verify_function(llvm::Function *);

void optimise();

[[nodiscard]] bool is_compiled() const;

void compile();
Expand Down
1 change: 0 additions & 1 deletion include/heyoka/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@
#include <heyoka/math/tan.hpp>
#include <heyoka/math/tanh.hpp>
#include <heyoka/math/time.hpp>
#include <heyoka/math/tpoly.hpp>

#endif
66 changes: 0 additions & 66 deletions include/heyoka/math/tpoly.hpp

This file was deleted.

33 changes: 0 additions & 33 deletions src/detail/div.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,17 +278,6 @@ llvm::Function *taylor_c_diff_func_div_impl(llvm_state &s, llvm::Type *fp_t, con

// Restore the original insertion block.
builder.SetInsertPoint(orig_bb);
} else {
// LCOV_EXCL_START
// The function was created before. Check if the signatures match.
// NOTE: there could be a mismatch if the derivative function was created
// and then optimised - optimisation might remove arguments which are compile-time
// constants.
if (!compare_function_signature(f, val_t, fargs)) {
throw std::invalid_argument(
"Inconsistent function signature for the Taylor derivative of division in compact mode detected");
}
// LCOV_EXCL_STOP
}

return f;
Expand Down Expand Up @@ -383,17 +372,6 @@ llvm::Function *taylor_c_diff_func_div_impl(llvm_state &s, llvm::Type *fp_t, con

// Restore the original insertion block.
builder.SetInsertPoint(orig_bb);
} else {
// LCOV_EXCL_START
// The function was created before. Check if the signatures match.
// NOTE: there could be a mismatch if the derivative function was created
// and then optimised - optimisation might remove arguments which are compile-time
// constants.
if (!compare_function_signature(f, val_t, fargs)) {
throw std::invalid_argument(
"Inconsistent function signature for the Taylor derivative of division in compact mode detected");
}
// LCOV_EXCL_STOP
}

return f;
Expand Down Expand Up @@ -463,17 +441,6 @@ llvm::Function *taylor_c_diff_func_div_impl(llvm_state &s, llvm::Type *fp_t, con

// Restore the original insertion block.
builder.SetInsertPoint(orig_bb);
} else {
// LCOV_EXCL_START
// The function was created before. Check if the signatures match.
// NOTE: there could be a mismatch if the derivative function was created
// and then optimised - optimisation might remove arguments which are compile-time
// constants.
if (!compare_function_signature(f, val_t, fargs)) {
throw std::invalid_argument(
"Inconsistent function signature for the Taylor derivative of division in compact mode detected");
}
// LCOV_EXCL_STOP
}

return f;
Expand Down
45 changes: 0 additions & 45 deletions src/detail/llvm_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,38 +1460,6 @@ std::string llvm_type_name(llvm::Type *t)
return std::move(ostr.str());
}

// This function will return true if:
//
// - the return type of f is ret, and
// - the argument types of f are the same as in 'args'.
//
// Otherwise, the function will return false.
bool compare_function_signature(llvm::Function *f, llvm::Type *ret, const std::vector<llvm::Type *> &args)
{
assert(f != nullptr);
assert(ret != nullptr);

if (ret != f->getReturnType()) {
// Mismatched return types.
return false;
}

auto *it = f->arg_begin();
for (auto *arg_type : args) {
if (it == f->arg_end() || it->getType() != arg_type) {
// f has fewer arguments than args, or the current
// arguments' types do not match.
return false;
}
++it;
}

// In order for the signatures to match,
// we must be at the end of f's arguments list
// (otherwise f has more arguments than args).
return it == f->arg_end();
}

// Create an LLVM if statement in the form:
// if (cond) {
// then_f();
Expand Down Expand Up @@ -2418,14 +2386,6 @@ llvm::Function *llvm_add_csc(llvm_state &s, llvm::Type *scal_t, std::uint32_t n,

// Restore the original insertion block.
builder.SetInsertPoint(orig_bb);
} else {
// LCOV_EXCL_START
// The function was created before. Check if the signatures match.
if (!compare_function_signature(f, builder.getVoidTy(), fargs)) {
throw std::invalid_argument(
"Inconsistent function signature for the sign changes counter function detected");
}
// LCOV_EXCL_STOP
}

return f;
Expand Down Expand Up @@ -3098,11 +3058,6 @@ llvm::Function *llvm_add_inv_kep_E(llvm_state &s, llvm::Type *fp_t, std::uint32_

// Restore the original insertion block.
builder.SetInsertPoint(orig_bb);
} else {
// The function was created before. Check if the signatures match.
if (!compare_function_signature(f, tp, fargs)) {
throw std::invalid_argument("Inconsistent function signature for the inverse Kepler equation detected");
}
}

return f;
Expand Down
33 changes: 0 additions & 33 deletions src/detail/sub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,6 @@ llvm::Function *taylor_c_diff_func_sub_impl(llvm_state &s, llvm::Type *fp_t, con

// Restore the original insertion block.
builder.SetInsertPoint(orig_bb);
} else {
// LCOV_EXCL_START
// The function was created before. Check if the signatures match.
// NOTE: there could be a mismatch if the derivative function was created
// and then optimised - optimisation might remove arguments which are compile-time
// constants.
if (!compare_function_signature(f, val_t, fargs)) {
throw std::invalid_argument(
"Inconsistent function signature for the Taylor derivative of subtraction in compact mode detected");
}
// LCOV_EXCL_STOP
}

return f;
Expand Down Expand Up @@ -361,17 +350,6 @@ llvm::Function *taylor_c_diff_func_sub_impl(llvm_state &s, llvm::Type *fp_t, con

// Restore the original insertion block.
builder.SetInsertPoint(orig_bb);
} else {
// LCOV_EXCL_START
// The function was created before. Check if the signatures match.
// NOTE: there could be a mismatch if the derivative function was created
// and then optimised - optimisation might remove arguments which are compile-time
// constants.
if (!compare_function_signature(f, val_t, fargs)) {
throw std::invalid_argument(
"Inconsistent function signature for the Taylor derivative of subtraction in compact mode detected");
}
// LCOV_EXCL_STOP
}

return f;
Expand Down Expand Up @@ -429,17 +407,6 @@ llvm::Function *taylor_c_diff_func_sub_impl(llvm_state &s, llvm::Type *fp_t, con

// Restore the original insertion block.
builder.SetInsertPoint(orig_bb);
} else {
// LCOV_EXCL_START
// The function was created before. Check if the signatures match.
// NOTE: there could be a mismatch if the derivative function was created
// and then optimised - optimisation might remove arguments which are compile-time
// constants.
if (!compare_function_signature(f, val_t, fargs)) {
throw std::invalid_argument(
"Inconsistent function signature for the Taylor derivative of subtraction in compact mode detected");
}
// LCOV_EXCL_STOP
}

return f;
Expand Down
11 changes: 0 additions & 11 deletions src/detail/sum_sq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,17 +512,6 @@ llvm::Function *sum_sq_taylor_c_diff_func_impl(llvm_state &s, llvm::Type *fp_t,

// Restore the original insertion block.
builder.SetInsertPoint(orig_bb);
} else {
// The function was created before. Check if the signatures match.
// NOTE: there could be a mismatch if the derivative function was created
// and then optimised - optimisation might remove arguments which are compile-time
// constants.
if (!compare_function_signature(f, val_t, fargs)) {
// LCOV_EXCL_START
throw std::invalid_argument(
"Inconsistent function signature for the Taylor derivative of sum_sq() in compact mode detected");
// LCOV_EXCL_STOP
}
}

return f;
Expand Down
11 changes: 0 additions & 11 deletions src/func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,17 +992,6 @@ llvm::Function *llvm_c_eval_func_helper(const std::string &name,

// Restore the original insertion block.
builder.SetInsertPoint(orig_bb);
} else {
// LCOV_EXCL_START
// The function was created before. Check if the signatures match.
// NOTE: there could be a mismatch if the function was created
// and then optimised - optimisation might remove arguments which are compile-time
// constants.
if (!compare_function_signature(f, val_t, fargs)) {
throw std::invalid_argument(fmt::format(
"Inconsistent function signature for the evaluation of {}() in compact mode detected", name));
}
// LCOV_EXCL_STOP
}

return f;
Expand Down
10 changes: 0 additions & 10 deletions src/math/acos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,16 +392,6 @@ llvm::Function *taylor_c_diff_func_acos_impl(llvm_state &s, llvm::Type *fp_t, co

// Restore the original insertion block.
builder.SetInsertPoint(orig_bb);
} else {
// The function was created before. Check if the signatures match.
// NOTE: there could be a mismatch if the derivative function was created
// and then optimised - optimisation might remove arguments which are compile-time
// constants.
if (!compare_function_signature(f, val_t, fargs)) {
throw std::invalid_argument(
"Inconsistent function signature for the Taylor derivative of the inverse cosine "
"in compact mode detected");
}
}

return f;
Expand Down
10 changes: 0 additions & 10 deletions src/math/acosh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,16 +383,6 @@ llvm::Function *taylor_c_diff_func_acosh_impl(llvm_state &s, llvm::Type *fp_t, c

// Restore the original insertion block.
builder.SetInsertPoint(orig_bb);
} else {
// The function was created before. Check if the signatures match.
// NOTE: there could be a mismatch if the derivative function was created
// and then optimised - optimisation might remove arguments which are compile-time
// constants.
if (!compare_function_signature(f, val_t, fargs)) {
throw std::invalid_argument(
"Inconsistent function signature for the Taylor derivative of the inverse hyperbolic cosine "
"in compact mode detected");
}
}

return f;
Expand Down
9 changes: 0 additions & 9 deletions src/math/asin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,6 @@ llvm::Function *taylor_c_diff_func_asin_impl(llvm_state &s, llvm::Type *fp_t, co

// Restore the original insertion block.
builder.SetInsertPoint(orig_bb);
} else {
// The function was created before. Check if the signatures match.
// NOTE: there could be a mismatch if the derivative function was created
// and then optimised - optimisation might remove arguments which are compile-time
// constants.
if (!compare_function_signature(f, val_t, fargs)) {
throw std::invalid_argument("Inconsistent function signature for the Taylor derivative of the inverse sine "
"in compact mode detected");
}
}

return f;
Expand Down
Loading

0 comments on commit f2ccb29

Please sign in to comment.