diff --git a/gcc/jit/libgccjit++.h b/gcc/jit/libgccjit++.h index 8dc2112367b..a6d531dc697 100644 --- a/gcc/jit/libgccjit++.h +++ b/gcc/jit/libgccjit++.h @@ -169,6 +169,11 @@ namespace gccjit int is_variadic, location loc = location ()); + type new_function_ptr_type (type return_type, + std::vector ¶ms, + int is_variadic, + location loc = location ()); + function get_builtin_function (const std::string &name); lvalue new_global (enum gcc_jit_global_kind kind, @@ -810,6 +815,29 @@ context::new_function (enum gcc_jit_function_kind kind, is_variadic)); } +inline type +context::new_function_ptr_type (type return_type, + std::vector ¶ms, + int is_variadic, + location loc) +{ + /* Treat std::vector as an array, relying on it not being resized: */ + type *as_array_of_wrappers = params.data(); + + /* Treat the array as being of the underlying pointers, relying on + the wrapper type being such a pointer internally. */ + gcc_jit_type **as_array_of_ptrs = + reinterpret_cast (as_array_of_wrappers); + + return type (gcc_jit_context_new_function_ptr_type ( + m_inner_ctxt, + loc.get_inner_location (), + return_type.get_inner_type (), + params.size (), + as_array_of_ptrs, + is_variadic)); +} + inline function context::get_builtin_function (const std::string &name) {