Commit 18146f45 by David Malcolm Committed by David Malcolm

API extension: add GCC_JIT_UNARY_OP_ABS to enum gcc_jit_unary_op

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.

From-SVN: r219321
parent f63c7f85
2015-01-07 David Malcolm <dmalcolm@redhat.com>
* 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.
2015-01-07 David Malcolm <dmalcolm@redhat.com>
* jit-recording.h (gcc::jit::recording::memento_of_get_type): Fix
typo in comment.
......
......@@ -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
*****************
......
......@@ -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,
......
......@@ -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 *
......
......@@ -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);
......
......@@ -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 *
......
2015-01-07 David Malcolm <dmalcolm@redhat.com>
* jit.dg/test-expressions.c (make_tests_of_unary_ops): Add test of
GCC_JIT_UNARY_OP_ABS.
(verify_unary_ops): Likewise.
2015-01-07 David Malcolm <dmalcolm@redhat.com>
* jit.dg/test-arith-overflow.c: New test case.
* jit.dg/all-non-failing-tests.h: Add test-arith-overflow.c.
* jit.dg/test-combination.c (create_code): Likewise.
......
......@@ -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);
}
/**********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment