diff options
Diffstat (limited to 'gcc/jit/jit-recording.cc')
-rw-r--r-- | gcc/jit/jit-recording.cc | 76 |
1 files changed, 66 insertions, 10 deletions
diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc index 90ac5bd..7c1b3fd 100644 --- a/gcc/jit/jit-recording.cc +++ b/gcc/jit/jit-recording.cc @@ -935,14 +935,16 @@ recording::function_type * recording::context::new_function_type (recording::type *return_type, int num_params, recording::type **param_types, - int is_variadic) + int is_variadic, + bool is_target_builtin) { recording::function_type *fn_type = new function_type (this, return_type, num_params, param_types, - is_variadic); + is_variadic, + is_target_builtin); record (fn_type); return fn_type; } @@ -964,7 +966,8 @@ recording::context::new_function_ptr_type (recording::location *, /* unused loc = new_function_type (return_type, num_params, param_types, - is_variadic); + is_variadic, + false); /* Return a pointer-type to the function type. */ return fn_type->get_pointer (); @@ -1007,7 +1010,7 @@ recording::context::new_function (recording::location *loc, loc, kind, return_type, new_string (name), num_params, params, is_variadic, - builtin_id); + builtin_id, false); record (result); m_functions.safe_push (result); @@ -1046,6 +1049,53 @@ recording::context::get_builtin_function (const char *name) return bm->get_builtin_function (name); } +/* Create a recording::function instance for a target-specific builtin. + + Implements the post-error-checking part of + gcc_jit_context_get_target_builtin_function. */ + +recording::function * +recording::context::get_target_builtin_function (const char *name) +{ + const char *asm_name = name; + if (target_function_types.count (name) == 0) + { + fprintf (stderr, "Cannot find target builtin %s\n", name); + return NULL; + } + + recording::function_type* func_type = target_function_types[name] + ->copy (this)->dyn_cast_function_type (); + const vec<type *>& param_types = func_type->get_param_types (); + recording::param **params = new recording::param *[param_types.length ()]; + + int i; + recording::type *param_type; + FOR_EACH_VEC_ELT (param_types, i, param_type) + { + char buf[16]; + snprintf (buf, 16, "arg%d", i); + params[i] = new_param (NULL, + param_type, + buf); + } + + recording::function *result = + new recording::function (this, + NULL, + GCC_JIT_FUNCTION_IMPORTED, + func_type->get_return_type (), + new_string (asm_name), + param_types.length (), + params, + func_type->is_variadic (), + BUILT_IN_NONE, + true); + record (result); + + return result; +} + /* Create a recording::global instance and add it to this context's list of mementos. @@ -3251,11 +3301,13 @@ recording::function_type::function_type (context *ctxt, type *return_type, int num_params, type **param_types, - int is_variadic) + int is_variadic, + bool is_target_builtin) : type (ctxt), m_return_type (return_type), m_param_types (), - m_is_variadic (is_variadic) + m_is_variadic (is_variadic), + m_is_target_builtin (is_target_builtin) { for (int i = 0; i< num_params; i++) m_param_types.safe_push (param_types[i]); @@ -4204,7 +4256,8 @@ recording::function::function (context *ctxt, int num_params, recording::param **params, int is_variadic, - enum built_in_function builtin_id) + enum built_in_function builtin_id, + bool is_target_builtin) : memento (ctxt), m_loc (loc), m_kind (kind), @@ -4218,7 +4271,8 @@ recording::function::function (context *ctxt, m_fn_ptr_type (NULL), m_attributes (), m_string_attributes (), - m_int_array_attributes () + m_int_array_attributes (), + m_is_target_builtin (is_target_builtin) { for (int i = 0; i< num_params; i++) { @@ -4280,7 +4334,8 @@ recording::function::replay_into (replayer *r) m_builtin_id, m_attributes, m_string_attributes, - m_int_array_attributes)); + m_int_array_attributes, + m_is_target_builtin)); } /* Create a recording::local instance and add it to @@ -4547,7 +4602,8 @@ recording::function::get_address (recording::location *loc) = m_ctxt->new_function_type (m_return_type, m_params.length (), param_types.address (), - m_is_variadic); + m_is_variadic, + m_is_target_builtin); m_fn_ptr_type = fn_type->get_pointer (); } gcc_assert (m_fn_ptr_type); |