Skip to content

Commit

Permalink
Make compatible_types a public function
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Jan 11, 2022
1 parent 014202a commit 13789ac
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
34 changes: 17 additions & 17 deletions gcc/jit/libgccjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ jit_error (gcc::jit::recording::context *ctxt,
gcc::jit::recording::type::accepts_writes_from virtual function on
LTYPE. */

static bool
compatible_types (gcc::jit::recording::type *ltype,
gcc::jit::recording::type *rtype)
bool
gcc_jit_compatible_types (gcc_jit_type *ltype,
gcc_jit_type *rtype)
{
return ltype->accepts_writes_from (rtype);
}
Expand Down Expand Up @@ -2119,7 +2119,7 @@ gcc_jit_context_new_binary_op (gcc_jit_context *ctxt,
RETURN_NULL_IF_FAIL (a, ctxt, loc, "NULL a");
RETURN_NULL_IF_FAIL (b, ctxt, loc, "NULL b");
RETURN_NULL_IF_FAIL_PRINTF4 (
a->get_type ()->unqualified () == b->get_type ()->unqualified (),
gcc_jit_compatible_types ((gcc_jit_type*) a->get_type (), (gcc_jit_type*) b->get_type ()),
ctxt, loc,
"mismatching types for binary op:"
" a: %s (type: %s) b: %s (type: %s)",
Expand Down Expand Up @@ -2228,8 +2228,8 @@ gcc_jit_context_new_call (gcc_jit_context *ctxt,
param->get_type ()->get_debug_string ());

RETURN_NULL_IF_FAIL_PRINTF6 (
compatible_types (param->get_type (),
arg->get_type ()),
gcc_jit_compatible_types ((gcc_jit_type*) param->get_type (),
(gcc_jit_type*) arg->get_type ()),
ctxt, loc,
"mismatching types for argument %d of function \"%s\":"
" assignment to param %s (type: %s) from %s (type: %s)",
Expand Down Expand Up @@ -2317,8 +2317,8 @@ gcc_jit_context_new_call_through_ptr (gcc_jit_context *ctxt,
param_type->get_debug_string ());

RETURN_NULL_IF_FAIL_PRINTF6 (
compatible_types (param_type,
arg->get_type ()),
gcc_jit_compatible_types ((gcc_jit_type*) param_type,
(gcc_jit_type*) arg->get_type ()),
ctxt, loc,
"mismatching types for argument %d of fn_ptr: %s:"
" assignment to param %d (type: %s) from %s (type: %s)",
Expand Down Expand Up @@ -2770,8 +2770,8 @@ gcc_jit_block_add_assignment (gcc_jit_block *block,
RETURN_IF_FAIL (lvalue, ctxt, loc, "NULL lvalue");
RETURN_IF_FAIL (rvalue, ctxt, loc, "NULL rvalue");
RETURN_IF_FAIL_PRINTF4 (
compatible_types (lvalue->get_type (),
rvalue->get_type ()),
gcc_jit_compatible_types ((gcc_jit_type*) lvalue->get_type (),
(gcc_jit_type*) rvalue->get_type ()),
ctxt, loc,
"mismatching types:"
" assignment to %s (type: %s) from %s (type: %s)",
Expand Down Expand Up @@ -2816,8 +2816,8 @@ gcc_jit_block_add_assignment_op (gcc_jit_block *block,
op);
RETURN_IF_FAIL (rvalue, ctxt, loc, "NULL rvalue");
RETURN_IF_FAIL_PRINTF4 (
compatible_types (lvalue->get_type (),
rvalue->get_type ()),
gcc_jit_compatible_types ((gcc_jit_type*) lvalue->get_type (),
(gcc_jit_type*) rvalue->get_type ()),
ctxt, loc,
"mismatching types:"
" assignment to %s (type: %s) involving %s (type: %s)",
Expand Down Expand Up @@ -2973,9 +2973,9 @@ gcc_jit_block_end_with_return (gcc_jit_block *block,
gcc::jit::recording::function *func = block->get_function ();
RETURN_IF_FAIL (rvalue, ctxt, loc, "NULL rvalue");
RETURN_IF_FAIL_PRINTF4 (
compatible_types (
func->get_return_type (),
rvalue->get_type ()),
gcc_jit_compatible_types (
(gcc_jit_type*) func->get_return_type (),
(gcc_jit_type*) rvalue->get_type ()),
ctxt, loc,
"mismatching types:"
" return of %s (type: %s) in function %s (return type: %s)",
Expand Down Expand Up @@ -3973,8 +3973,8 @@ gcc_jit_context_new_rvalue_from_vector (gcc_jit_context *ctxt,
RETURN_NULL_IF_FAIL_PRINTF1 (
elements[i], ctxt, loc, "NULL elements[%zi]", i);
RETURN_NULL_IF_FAIL_PRINTF4 (
compatible_types (element_type,
elements[i]->get_type ()),
gcc_jit_compatible_types ((gcc_jit_type*) element_type,
(gcc_jit_type*) elements[i]->get_type ()),
ctxt, loc,
"mismatching type for element[%zi] (expected type: %s): %s (type: %s)",
i,
Expand Down
5 changes: 5 additions & 0 deletions gcc/jit/libgccjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,11 @@ gcc_jit_type_get_const (gcc_jit_type *type);
extern gcc_jit_type *
gcc_jit_type_get_volatile (gcc_jit_type *type);

/* Given types LTYPE and RTYPE, return true if they are compatible. */
extern bool
gcc_jit_compatible_types (gcc_jit_type *ltype,
gcc_jit_type *rtype);

/* Given type "T", get type "T[N]" (for a constant N). */
extern gcc_jit_type *
gcc_jit_context_new_array_type (gcc_jit_context *ctxt,
Expand Down
5 changes: 5 additions & 0 deletions gcc/jit/libgccjit.map
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,8 @@ LIBGCCJIT_ABI_21 {
global:
gcc_jit_lvalue_set_register_name;
} LIBGCCJIT_ABI_20;

LIBGCCJIT_ABI_22 {
global:
gcc_jit_compatible_types;
} LIBGCCJIT_ABI_21;

0 comments on commit 13789ac

Please sign in to comment.