adjustments for darwin/clang build
This commit is contained in:
parent
77b2514746
commit
3343a7148a
5 changed files with 49 additions and 11 deletions
|
|
@ -5,6 +5,14 @@
|
||||||
#include "xo/expression/llvmintrinsic.hpp"
|
#include "xo/expression/llvmintrinsic.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
// address of &sqrt ambiguous on osx/clang
|
||||||
|
// (perhaps it's a template..?)
|
||||||
|
//
|
||||||
|
double xo_sqrt(double x) {
|
||||||
|
return sqrt(x);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main() {
|
main() {
|
||||||
|
|
@ -20,7 +28,7 @@ main() {
|
||||||
|
|
||||||
{
|
{
|
||||||
auto expr = make_primitive("sqrt",
|
auto expr = make_primitive("sqrt",
|
||||||
&::sqrt,
|
&xo_sqrt,
|
||||||
false /*!explicit_symbol_def*/,
|
false /*!explicit_symbol_def*/,
|
||||||
llvmintrinsic::fp_sqrt);
|
llvmintrinsic::fp_sqrt);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,28 @@
|
||||||
#include "llvm/Transforms/Scalar/GVN.h"
|
#include "llvm/Transforms/Scalar/GVN.h"
|
||||||
#include "llvm/Transforms/Scalar/Reassociate.h"
|
#include "llvm/Transforms/Scalar/Reassociate.h"
|
||||||
#include "llvm/Transforms/Scalar/SimplifyCFG.h"
|
#include "llvm/Transforms/Scalar/SimplifyCFG.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
//double foo(double x) { return x; }
|
namespace {
|
||||||
|
// need wrappers to fix type signature for osx/clang15. Perhaps sqrt() is a macro or template (?)
|
||||||
|
double
|
||||||
|
xo_sqrt(double x)
|
||||||
|
{
|
||||||
|
return ::sqrt(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
xo_sin(double x)
|
||||||
|
{
|
||||||
|
return ::sin(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
xo_cos(double x)
|
||||||
|
{
|
||||||
|
return ::cos(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main() {
|
main() {
|
||||||
|
|
@ -82,7 +102,7 @@ main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto expr = make_primitive("sqrt", &sqrt,
|
auto expr = make_primitive("sqrt", &xo_sqrt,
|
||||||
false /*!explicit_symbol_def*/,
|
false /*!explicit_symbol_def*/,
|
||||||
llvmintrinsic::fp_sqrt);
|
llvmintrinsic::fp_sqrt);
|
||||||
|
|
||||||
|
|
@ -105,7 +125,7 @@ main() {
|
||||||
{
|
{
|
||||||
/* (sqrt 2) */
|
/* (sqrt 2) */
|
||||||
|
|
||||||
auto fn = make_primitive("sqrt", &sqrt,
|
auto fn = make_primitive("sqrt", &xo_sqrt,
|
||||||
false /*!explicit_symbol_def*/,
|
false /*!explicit_symbol_def*/,
|
||||||
llvmintrinsic::fp_sqrt);
|
llvmintrinsic::fp_sqrt);
|
||||||
auto arg = make_constant(2.0);
|
auto arg = make_constant(2.0);
|
||||||
|
|
@ -132,11 +152,11 @@ main() {
|
||||||
/* (lambda (x) (sin (cos x))) */
|
/* (lambda (x) (sin (cos x))) */
|
||||||
|
|
||||||
auto sin = make_primitive("sin",
|
auto sin = make_primitive("sin",
|
||||||
::sin,
|
&xo_sin,
|
||||||
false /*!explicit_symbol_def*/,
|
false /*!explicit_symbol_def*/,
|
||||||
llvmintrinsic::fp_sin);
|
llvmintrinsic::fp_sin);
|
||||||
auto cos = make_primitive("cos",
|
auto cos = make_primitive("cos",
|
||||||
::cos,
|
&xo_cos,
|
||||||
false /*!explicit_symbol_def*/,
|
false /*!explicit_symbol_def*/,
|
||||||
llvmintrinsic::fp_cos);
|
llvmintrinsic::fp_cos);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,15 @@
|
||||||
|
|
||||||
//double foo(double x) { return x; }
|
//double foo(double x) { return x; }
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// need wrappers to pin type signature for osx/clang15
|
||||||
|
double
|
||||||
|
xo_sqrt(double x)
|
||||||
|
{
|
||||||
|
return ::sqrt(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main() {
|
main() {
|
||||||
using xo::scope;
|
using xo::scope;
|
||||||
|
|
@ -68,7 +77,7 @@ main() {
|
||||||
|
|
||||||
{
|
{
|
||||||
auto sqrt = make_primitive("sqrt",
|
auto sqrt = make_primitive("sqrt",
|
||||||
::sqrt,
|
&xo_sqrt,
|
||||||
false /*!explicit_symbol_def*/,
|
false /*!explicit_symbol_def*/,
|
||||||
llvmintrinsic::fp_sqrt);
|
llvmintrinsic::fp_sqrt);
|
||||||
|
|
||||||
|
|
@ -115,7 +124,7 @@ main() {
|
||||||
#elif CHOICE == 2
|
#elif CHOICE == 2
|
||||||
#define FUNCTION_SYMBOL "twice"
|
#define FUNCTION_SYMBOL "twice"
|
||||||
auto root = make_primitive("sqrt",
|
auto root = make_primitive("sqrt",
|
||||||
::sqrt,
|
&xo_sqrt,
|
||||||
false /*!explicit_symbol_def*/,
|
false /*!explicit_symbol_def*/,
|
||||||
llvmintrinsic::fp_sqrt);
|
llvmintrinsic::fp_sqrt);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,6 @@ namespace xo {
|
||||||
{
|
{
|
||||||
/* toplevel expression sequence accepts an
|
/* toplevel expression sequence accepts an
|
||||||
* arbitrary number of expressions.
|
* arbitrary number of expressions.
|
||||||
*
|
|
||||||
* parser::include_token() returns
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
auto p_emit_expr = p_psm->p_emit_expr_;
|
auto p_emit_expr = p_psm->p_emit_expr_;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __APPL__
|
||||||
|
# include <vector> // for std::size_t when building with clang18
|
||||||
|
#endif
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
|
|
@ -58,7 +61,7 @@ namespace xo {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief number of built-in dimensions, convenient for array sizing **/
|
/** @brief number of built-in dimensions, convenient for array sizing **/
|
||||||
static constexpr std::size_t n_dim = static_cast<std::size_t>(dimension::n_dim);
|
static constexpr std::uint64_t n_dim = static_cast<std::uint64_t>(dimension::n_dim);
|
||||||
} /*namespace qty*/
|
} /*namespace qty*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue