From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30711 invoked by alias); 7 Jan 2015 20:43:19 -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 30691 invoked by uid 89); 7 Jan 2015 20:43:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.98.5 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com From: David Malcolm To: jit@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH, committed] API extension: add GCC_JIT_UNARY_OP_ABS to enum gcc_jit_unary_op Date: Thu, 01 Jan 2015 00:00:00 -0000 Message-Id: <1420663910-38842-1-git-send-email-dmalcolm@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-SW-Source: 2015-q1/txt/msg00005.txt.bz2 This adds GCC_JIT_UNARY_OP_ABS to the end of enum gcc_jit_unary_op, and so should not change ABI. Takes jit.sum from: # of expected passes 6121 to: # of expected passes 6196 Committed to trunk as r219321. gcc/jit/ChangeLog: * docs/topics/expressions.rst (Unary Operations): Add GCC_JIT_UNARY_OP_ABS. * jit-playback.c (gcc::jit::playback::context::new_unary_op): Likewise. * jit-recording.c (unary_op_strings): Likewise. * libgccjit.c (gcc_jit_context_new_unary_op): Update checking of "op" to reflect addition of GCC_JIT_UNARY_OP_ABS. * libgccjit.h (enum gcc_jit_unary_op): Add GCC_JIT_UNARY_OP_ABS. * docs/_build/texinfo/libgccjit.texi: Regenerate. gcc/testsuite/ChangeLog: * jit.dg/test-expressions.c (make_tests_of_unary_ops): Add test of GCC_JIT_UNARY_OP_ABS. (verify_unary_ops): Likewise. --- gcc/jit/docs/topics/expressions.rst | 11 +++++++++++ gcc/jit/jit-playback.c | 4 ++++ gcc/jit/jit-recording.c | 1 + gcc/jit/libgccjit.c | 2 +- gcc/jit/libgccjit.h | 8 +++++++- gcc/testsuite/jit.dg/test-expressions.c | 13 +++++++++++++ 6 files changed, 37 insertions(+), 2 deletions(-) diff --git a/gcc/jit/docs/topics/expressions.rst b/gcc/jit/docs/topics/expressions.rst index 1cf9641..72a1085 100644 --- a/gcc/jit/docs/topics/expressions.rst +++ b/gcc/jit/docs/topics/expressions.rst @@ -137,6 +137,7 @@ Unary Operation C equivalent :c:macro:`GCC_JIT_UNARY_OP_MINUS` `-(EXPR)` :c:macro:`GCC_JIT_UNARY_OP_BITWISE_NEGATE` `~(EXPR)` :c:macro:`GCC_JIT_UNARY_OP_LOGICAL_NEGATE` `!(EXPR)` +:c:macro:`GCC_JIT_UNARY_OP_ABS` `abs (EXPR)` ========================================== ============ .. c:macro:: GCC_JIT_UNARY_OP_MINUS @@ -170,6 +171,16 @@ Unary Operation C equivalent in C. +.. c:macro:: GCC_JIT_UNARY_OP_ABS + + Absolute value of an arithmetic expression; analogous to: + + .. code-block:: c + + abs (EXPR) + + in C. + Binary Operations ***************** diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c index cf42e5a..013ee0f 100644 --- a/gcc/jit/jit-playback.c +++ b/gcc/jit/jit-playback.c @@ -615,6 +615,10 @@ new_unary_op (location *loc, if (loc) set_tree_location (inner_result, loc); return new rvalue (this, inner_result); + + case GCC_JIT_UNARY_OP_ABS: + inner_op = ABS_EXPR; + break; } inner_result = build1 (inner_op, diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c index d228274..dc7a7fb 100644 --- a/gcc/jit/jit-recording.c +++ b/gcc/jit/jit-recording.c @@ -2797,6 +2797,7 @@ static const char * const unary_op_strings[] = { "-", /* GCC_JIT_UNARY_OP_MINUS */ "~", /* GCC_JIT_UNARY_OP_BITWISE_NEGATE */ "!", /* GCC_JIT_UNARY_OP_LOGICAL_NEGATE */ + "abs ", /* GCC_JIT_UNARY_OP_ABS */ }; recording::string * diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index bd0ae91..6853bb0 100644 --- a/gcc/jit/libgccjit.c +++ b/gcc/jit/libgccjit.c @@ -1180,7 +1180,7 @@ gcc_jit_context_new_unary_op (gcc_jit_context *ctxt, /* LOC can be NULL. */ RETURN_NULL_IF_FAIL_PRINTF1 ( (op >= GCC_JIT_UNARY_OP_MINUS - && op <= GCC_JIT_UNARY_OP_LOGICAL_NEGATE), + && op <= GCC_JIT_UNARY_OP_ABS), ctxt, loc, "unrecognized value for enum gcc_jit_unary_op: %i", op); diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h index e89635c..2049795 100644 --- a/gcc/jit/libgccjit.h +++ b/gcc/jit/libgccjit.h @@ -649,7 +649,13 @@ enum gcc_jit_unary_op /* Logical negation of an arithmetic or pointer value; analogous to: !(EXPR) in C. */ - GCC_JIT_UNARY_OP_LOGICAL_NEGATE + GCC_JIT_UNARY_OP_LOGICAL_NEGATE, + + /* Absolute value of an arithmetic expression; analogous to: + abs (EXPR) + in C. */ + GCC_JIT_UNARY_OP_ABS + }; extern gcc_jit_rvalue * diff --git a/gcc/testsuite/jit.dg/test-expressions.c b/gcc/testsuite/jit.dg/test-expressions.c index 87abb76..7e33b56 100644 --- a/gcc/testsuite/jit.dg/test-expressions.c +++ b/gcc/testsuite/jit.dg/test-expressions.c @@ -73,6 +73,12 @@ make_tests_of_unary_ops (gcc_jit_context *ctxt) GCC_JIT_UNARY_OP_LOGICAL_NEGATE, "test_UNARY_OP_LOGICAL_NEGATE_on_int"), "!(a)"); + CHECK_STRING_VALUE ( + make_test_of_unary_op (ctxt, + int_type, + GCC_JIT_UNARY_OP_ABS, + "test_UNARY_OP_ABS_on_int"), + "abs (a)"); } static void @@ -104,6 +110,13 @@ verify_unary_ops (gcc_jit_result *result) CHECK_VALUE (test_UNARY_OP_LOGICAL_NEGATE_on_int (42), 0); CHECK_VALUE (test_UNARY_OP_LOGICAL_NEGATE_on_int (-5), 0); + test_fn test_UNARY_OP_ABS_on_int = + (test_fn)gcc_jit_result_get_code (result, + "test_UNARY_OP_ABS_on_int"); + CHECK_NON_NULL (test_UNARY_OP_ABS_on_int); + CHECK_VALUE (test_UNARY_OP_ABS_on_int (0), 0); + CHECK_VALUE (test_UNARY_OP_ABS_on_int (42), 42); + CHECK_VALUE (test_UNARY_OP_ABS_on_int (-5), 5); } /********************************************************************** -- 1.8.5.3