# HG changeset patch # User Max Brister # Date 1339427008 18000 # Node ID c57cfdb37f81a9c88d36278c29acc076c87e6b7e # Parent 006570a76b90a020532ea6d527ea9d8c3e916e75 Add power to jit diff --git a/src/pt-jit.cc b/src/pt-jit.cc --- a/src/pt-jit.cc +++ b/src/pt-jit.cc @@ -55,6 +55,7 @@ #include "ov-usr-fcn.h" #include "ov-scalar.h" #include "pt-all.h" +#include "xpow.h" static llvm::IRBuilder<> builder (llvm::getGlobalContext ()); @@ -180,6 +181,15 @@ } } +extern "C" octave_base_value * +octave_jit_xpow (double a, double b) +{ + octave_value ret = xpow (a, b); + octave_base_value *obv = ret.internal_rep (); + obv->grab (); + return obv; +} + // -------------------- jit_range -------------------- std::ostream& operator<< (std::ostream& os, const jit_range& rng) @@ -404,6 +414,15 @@ add_binary_fcmp (scalar, octave_value::op_gt, llvm::CmpInst::FCMP_UGT); add_binary_fcmp (scalar, octave_value::op_ne, llvm::CmpInst::FCMP_UNE); + llvm::Function *jxpow = create_function ("octave_jit_xpow", any, scalar, + scalar); + engine->addGlobalMapping (jxpow, reinterpret_cast (&octave_jit_xpow)); + { + jit_function::overload ol (jxpow, false, any, scalar, scalar); + binary_ops[octave_value::op_pow].add_overload (ol); + binary_ops[octave_value::op_el_pow].add_overload (ol); + } + llvm::Function *gripe_div0 = create_function ("gripe_divide_by_zero", void_t); engine->addGlobalMapping (gripe_div0, reinterpret_cast (&gripe_divide_by_zero));