/** @file PrimitiveInterface.hpp * * Author: Roland Conybeare **/ #pragma once #include "FunctionInterface.hpp" #include "llvmintrinsic.hpp" //#include #include namespace xo { namespace ast { class PrimitiveInterface : public FunctionInterface { public: using void_function_type = void (*)(); public: PrimitiveInterface(TypeDescr fn_type) : FunctionInterface(exprtype::primitive, fn_type) {} /** downcast from Expression **/ static ref::brw from(ref::brw x) { return ref::brw::from(x); } /** if true, Jit will try to explicitly symbol for this primitive * (instead of looking it up in host process). * Don't know if this works. * Do know it's not needed for ::sin(), ::sqrt(). * Do know that my extern "C" functions like ::mul_i32(), ::mul_f64() * need something else. **/ virtual bool explicit_symbol_def() const = 0; /** function address for this primitive **/ virtual void_function_type function_address() const = 0; /** get llvm intrinsic hint for this primitive **/ virtual llvmintrinsic intrinsic() const = 0; // virtual const std::string & name() const; // virtual int n_arg() const; // virtual TypeDescr fn_retval() const; // virtual TypeDescr fn_arg(uint32_t i) const; // ----- Expression ----- virtual std::size_t visit_preorder(VisitFn visitor_fn) override { visitor_fn(this); return 1; } virtual void attach_envs(ref::brw /*p*/) override {} private: }; /*PrimitiveInterface*/ } /*namespace ast*/ } /*namespace xo*/ /** end PrimitiveInterface.hpp **/