From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 67118 invoked by alias); 15 Jul 2015 20:10:22 -0000 Mailing-List: contact jit-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: jit-owner@gcc.gnu.org Received: (qmail 67103 invoked by uid 89); 15 Jul 2015 20:10:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.98.7 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=AWL,BAYES_50,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-Status: No, score=0.1 required=5.0 tests=AWL,BAYES_50,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: ovh.starynkevitch.net Message-ID: <55A6BE23.6030107@starynkevitch.net> Date: Thu, 01 Jan 2015 00:00:00 -0000 From: Basile Starynkevitch User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: David Malcolm CC: jit@gcc.gnu.org Subject: Re: PATCH trunk GCCJIT: adding gcc_jit_context_new_rvalue_from_long_long, etc... References: <55A6A421.8060707@starynkevitch.net> <1436986339.830.59.camel@surprise> In-Reply-To: <1436986339.830.59.camel@surprise> Content-Type: multipart/mixed; boundary="------------000305010306030504010906" X-SW-Source: 2015-q3/txt/msg00096.txt.bz2 This is a multi-part message in MIME format. --------------000305010306030504010906 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1827 On 07/15/2015 20:52, David Malcolm wrote: > On Wed, 2015-07-15 at 20:19 +0200, Basile Starynkevitch wrote: >> Hello All and David Malcolm >> >> The attached patch (relative to trunk r224842) is adding >> gcc_jit_context_new_rvalue_from_long_long and similar functions to >> GCCJIT. > Here is the slightly improved but still incomplete patch against trunk r225844. I don't send it yet to gcc-patches@ because I know it is incomplete Perhaps it is useless to send it here, but at least it serves as backup for me and to show the slow progress I made so far. Temporary gcc/jit/ChangeLog entry is ####### 2015-07-15 Basile Starynkevitch * libgccjit.h (gcc_jit_context_new_rvalue_from_long_long) (gcc_jit_context_new_rvalue_from_int32) (gcc_jit_context_new_rvalue_from_int64) (gcc_jit_context_new_rvalue_from_intptr): New function declarations. Mention in comments that some of them are same as others. * libgccjit.map: New entries for above functions in LIBGCCJIT_ABI_4/ * libgccjit.c (gcc_jit_context_new_rvalue_from_long_long) (gcc_jit_context_new_rvalue_from_int32) (gcc_jit_context_new_rvalue_from_int64) (gcc_jit_context_new_rvalue_from_intptr): New functions. * jit-playback.c (new_rvalue_from_const ): New specialization. * jit-recording.c (recording::memento_of_new_rvalue_from_const ::write_reproducer): New. ###### Sorry for this incomplete patch. But your comments (if you have a few minutes to spend) are stil welcome. Cheers. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mine, sont seulement les miennes} *** --------------000305010306030504010906 Content-Type: text/x-patch; name="jitlonglongpatch-r225844.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="jitlonglongpatch-r225844.diff" Content-length: 7875 Index: gcc/jit/jit-playback.c =================================================================== --- gcc/jit/jit-playback.c (revision 225844) +++ gcc/jit/jit-playback.c (working copy) @@ -573,6 +573,30 @@ new_rvalue_from_const (type *type, } } + +/* Specialization of making an rvalue from a const, for host . */ + +template <> +rvalue * +context:: +new_rvalue_from_const (type *type, + long long value) +{ + // FIXME: type-checking, or coercion? + tree inner_type = type->as_tree (); + if (INTEGRAL_TYPE_P (inner_type)) + { + tree inner = build_int_cst (inner_type, value); + return new rvalue (this, inner); + } + else + { + REAL_VALUE_TYPE real_value; + real_from_integer (&real_value, VOIDmode, value, SIGNED); + tree inner = build_real (inner_type, real_value); + return new rvalue (this, inner); + } +} /* Specialization of making an rvalue from a const, for host . */ template <> Index: gcc/jit/jit-recording.c =================================================================== --- gcc/jit/jit-recording.c (revision 225844) +++ gcc/jit/jit-recording.c (working copy) @@ -4072,6 +4072,7 @@ recording::global::write_reproducer (reproducer &r /* Explicit specialization of the various mementos we're interested in. */ template class recording::memento_of_new_rvalue_from_const ; template class recording::memento_of_new_rvalue_from_const ; +template class recording::memento_of_new_rvalue_from_const ; template class recording::memento_of_new_rvalue_from_const ; template class recording::memento_of_new_rvalue_from_const ; @@ -4209,6 +4210,43 @@ recording::memento_of_new_rvalue_from_const m_value); } + +/* The write_reproducer specialization for . */ + +template <> +void +recording::memento_of_new_rvalue_from_const ::write_reproducer (reproducer &r) +{ + const char *id = r.make_identifier (this, "rvalue"); + + /* We have to special-case LONG_LONG_MIN like in the previous specialization + and hence we'd get: + error: integer constant is so large that it is unsigned [-Werror] + Workaround this by writing (LONG_LONG_MIN + 1) - 1. */ + if (m_value == LONG_LONG_MIN) + { + r.write (" gcc_jit_rvalue *%s =\n" + " gcc_jit_context_new_rvalue_from_long_long (%s, /* gcc_jit_context *ctxt */\n" + " %s, /* gcc_jit_type *numeric_type */\n" + " %lldLL - 1); /* long long value */\n", + id, + r.get_identifier (get_context ()), + r.get_identifier_as_type (m_type), + m_value + 1);; + return; + } + + r.write (" gcc_jit_rvalue *%s =\n" + " gcc_jit_context_new_rvalue_from_long_long (%s, /* gcc_jit_context *ctxt */\n" + " %s, /* gcc_jit_type *numeric_type */\n" + " %lldLL); /* long long value */\n", + id, + r.get_identifier (get_context ()), + r.get_identifier_as_type (m_type), + m_value); + } + + /* The make_debug_string specialization for , rendering it as (TARGET_TYPE)LITERAL e.g. Index: gcc/jit/libgccjit.c =================================================================== --- gcc/jit/libgccjit.c (revision 225844) +++ gcc/jit/libgccjit.c (working copy) @@ -1154,6 +1154,70 @@ gcc_jit_context_new_rvalue_from_long (gcc_jit_cont ->new_rvalue_from_const (numeric_type, value)); } +/* Public entrypoint. See description in libgccjit.h. */ + +gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_long_long (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + long long 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. */ + +gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_int32 (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + int32_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 (numeric_type, (long) value)); +} + + +/* Public entrypoint. See description in libgccjit.h. */ + +gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_int64 (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + int64_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 (numeric_type, (long long) value)); +} + + +/* Public entrypoint. See description in libgccjit.h. */ + +gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_intptr (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + intptr_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 (numeric_type, (long long) value)); +} + + /* Public entrypoint. See description in libgccjit.h. This is essentially equivalent to: Index: gcc/jit/libgccjit.h =================================================================== --- gcc/jit/libgccjit.h (revision 225844) +++ gcc/jit/libgccjit.h (working copy) @@ -752,6 +752,29 @@ gcc_jit_context_new_rvalue_from_long (gcc_jit_cont long value); extern gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_long_long (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + long long value); + +/* Internally same as gcc_jit_context_new_rvalue_from_long, but takes an int32_t */ +extern gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_int32 (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + int32_t value); + +/* Internally same as gcc_jit_context_new_rvalue_from_long_long, but takes an int64_t */ +extern gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_int64 (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + int64_t value); + +/* Internally same as gcc_jit_context_new_rvalue_from_long_long, but takes an intptr_t */ +extern gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_intptr (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + intptr_t value); + +extern gcc_jit_rvalue * gcc_jit_context_zero (gcc_jit_context *ctxt, gcc_jit_type *numeric_type); Index: gcc/jit/libgccjit.map =================================================================== --- gcc/jit/libgccjit.map (revision 225844) +++ gcc/jit/libgccjit.map (working copy) @@ -62,6 +62,7 @@ LIBGCCJIT_ABI_0 gcc_jit_context_new_rvalue_from_double; gcc_jit_context_new_rvalue_from_int; gcc_jit_context_new_rvalue_from_long; + gcc_jit_context_new_rvalue_from_long_long; gcc_jit_context_new_rvalue_from_ptr; gcc_jit_context_new_string_literal; gcc_jit_context_new_struct_type; @@ -128,3 +129,12 @@ LIBGCCJIT_ABI_3 { gcc_jit_case_as_object; gcc_jit_context_new_case; } LIBGCCJIT_ABI_2; + +# Add support for long long & int32 & int64 & intptr +LIBGCCJIT_ABI_4 { + global: + gcc_jit_context_new_rvalue_from_int32; + gcc_jit_context_new_rvalue_from_int64; + gcc_jit_context_new_rvalue_from_intptr; + gcc_jit_context_new_rvalue_from_long_long; +} LIBGCCJIT_ABI_3; \ No newline at end of file --------------000305010306030504010906--