diff --git a/gcc/jit/libgccjit++.h b/gcc/jit/libgccjit++.h index fdbd3decc8d80..3f9b4755b8a45 100644 --- a/gcc/jit/libgccjit++.h +++ b/gcc/jit/libgccjit++.h @@ -187,6 +187,10 @@ namespace gccjit int value) const; rvalue new_rvalue (type numeric_type, long value) const; +#ifdef __SIZEOF_INT128__ + rvalue new_rvalue (type numeric_type, + __int128_t value) const; +#endif rvalue zero (type numeric_type) const; rvalue one (type numeric_type) const; rvalue new_rvalue (type numeric_type, @@ -941,7 +945,17 @@ context::new_rvalue (type numeric_type, numeric_type.get_inner_type (), value)); } - +#ifdef __SIZEOF_INT128__ +inline rvalue +context::new_rvalue (type numeric_type, + __int128_t value) const +{ + return rvalue ( + gcc_jit_context_new_rvalue_from_int128 (m_inner_ctxt, + numeric_type.get_inner_type (), + value)); +} +#endif inline rvalue context::zero (type numeric_type) const { diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc index 6c3ff9dbaaf51..42649085c403b 100644 --- a/gcc/jit/libgccjit.cc +++ b/gcc/jit/libgccjit.cc @@ -2020,6 +2020,35 @@ gcc_jit_rvalue_set_type (gcc_jit_rvalue *rvalue, gcc_jit_type *new_type) "not a numeric type: %s", \ NUMERIC_TYPE->get_debug_string ()); \ JIT_END_STMT +/* Public entrypoint. See description in libgccjit.h. + + After error-checking, the real work is done by the + gcc::jit::recording::context::new_rvalue_from_const method in + jit-recording.cc. */ +gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_char (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + char value) +{ + RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); + RETURN_NULL_IF_FAIL_NONNULL_NUMERIC_TYPE (ctxt, numeric_type); + + return ((gcc_jit_rvalue *)ctxt + ->new_rvalue_from_const (numeric_type, value)); +} +gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_short (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + short value) +{ + RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); + RETURN_NULL_IF_FAIL_NONNULL_NUMERIC_TYPE (ctxt, numeric_type); + + return ((gcc_jit_rvalue *)ctxt + ->new_rvalue_from_const (numeric_type, value)); +} /* Public entrypoint. See description in libgccjit.h. @@ -2058,7 +2087,20 @@ gcc_jit_context_new_rvalue_from_long (gcc_jit_context *ctxt, return ((gcc_jit_rvalue *)ctxt ->new_rvalue_from_const (numeric_type, value)); } +#ifdef __SIZEOF_INT128__ +gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_int128 (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + __int128_t value) +{ + RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); + RETURN_NULL_IF_FAIL_NONNULL_NUMERIC_TYPE (ctxt, numeric_type); + return ((gcc_jit_rvalue *)ctxt + ->new_rvalue_from_const <__int128_t> (numeric_type, value)); +} +#endif /* Public entrypoint. See description in libgccjit.h. This is essentially equivalent to: @@ -2111,6 +2153,18 @@ gcc_jit_context_new_rvalue_from_double (gcc_jit_context *ctxt, return ((gcc_jit_rvalue *)ctxt ->new_rvalue_from_const (numeric_type, value)); } +gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_float (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + float value) +{ + RETURN_NULL_IF_FAIL (ctxt, NULL, NULL, "NULL context"); + JIT_LOG_FUNC (ctxt->get_logger ()); + RETURN_NULL_IF_FAIL_NONNULL_NUMERIC_TYPE (ctxt, numeric_type); + + return ((gcc_jit_rvalue *)ctxt + ->new_rvalue_from_const (numeric_type, value)); +} /* Public entrypoint. See description in libgccjit.h. diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h index b9b036f444acf..32c7f95b2000a 100644 --- a/gcc/jit/libgccjit.h +++ b/gcc/jit/libgccjit.h @@ -1098,6 +1098,14 @@ gcc_jit_rvalue_set_type (gcc_jit_rvalue *rvalue, gcc_jit_type *new_type); /* Integer constants. */ extern gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_char (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + char value); +extern gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_short (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + short value); +extern gcc_jit_rvalue * gcc_jit_context_new_rvalue_from_int (gcc_jit_context *ctxt, gcc_jit_type *numeric_type, int value); @@ -1106,7 +1114,12 @@ extern gcc_jit_rvalue * gcc_jit_context_new_rvalue_from_long (gcc_jit_context *ctxt, gcc_jit_type *numeric_type, long value); - +#ifdef __SIZEOF_INT128__ +extern gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_int128 (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + __int128_t value); +#endif extern gcc_jit_rvalue * gcc_jit_context_zero (gcc_jit_context *ctxt, gcc_jit_type *numeric_type); @@ -1120,7 +1133,10 @@ extern gcc_jit_rvalue * gcc_jit_context_new_rvalue_from_double (gcc_jit_context *ctxt, gcc_jit_type *numeric_type, double value); - +extern gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_float(gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + float value); /* Pointers. */ extern gcc_jit_rvalue * gcc_jit_context_new_rvalue_from_ptr (gcc_jit_context *ctxt, diff --git a/gcc/jit/libgccjit.map b/gcc/jit/libgccjit.map index f14c2017ac648..f65d37a57d6fc 100644 --- a/gcc/jit/libgccjit.map +++ b/gcc/jit/libgccjit.map @@ -373,3 +373,10 @@ LIBGCCJIT_ABI_42 { global: gcc_jit_lvalue_add_attribute; } LIBGCCJIT_ABI_41; +LIBGCCJIT_ABI_43 { + global: + gcc_jit_context_new_rvalue_from_float; + gcc_jit_context_new_rvalue_from_int128; + gcc_jit_context_new_rvalue_from_short; + gcc_jit_context_new_rvalue_from_char; +} LIBGCCJIT_ABI_42;