From: David Malcolm Date: Fri, 9 Jan 2015 20:10:11 +0000 (+0000) Subject: New jit API entrypoint: gcc_jit_context_new_rvalue_from_long X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ccce3b2ac3c9352501278d36b3c79f049234870b;p=gcc.git New jit API entrypoint: gcc_jit_context_new_rvalue_from_long gcc/jit/ChangeLog: * docs/cp/topics/expressions.rst (Simple expressions): Use ":c:type:" for C types. Document new overload of gcc::jit::context::new_rvalue. * docs/topics/expressions.rst (Simple expressions): Use ":c:type:" for C types. Document new entrypoint gcc_jit_context_new_rvalue_from_long. * docs/_build/texinfo/libgccjit.texi: Regenerate. * jit-playback.c: Within namespace gcc::jit::playback... (context::new_rvalue_from_int): Eliminate in favor of... (context::new_rvalue_from_const ): ...this. (context::new_rvalue_from_double): Eliminate in favor of... (context::new_rvalue_from_const ): ...this. (context::new_rvalue_from_const ): New. (context::new_rvalue_from_ptr): Eliminate in favor of... (context::new_rvalue_from_const ): ...this. * jit-playback.h: Within namespace gcc::jit::playback... (context::new_rvalue_from_int): Eliminate in favor of... (context::new_rvalue_from_const ): ...this. (context::new_rvalue_from_double): Likewise. (context::new_rvalue_from_ptr): Likewise. * jit-recording.c: Within namespace gcc::jit::recording... (context::new_rvalue_from_int): Eliminate. (context::new_rvalue_from_double): Likewise. (context::new_rvalue_from_ptr): Likewise. (class memento_of_new_rvalue_from_const ): Add explicit specialization. (class memento_of_new_rvalue_from_const ): Likewise. (class memento_of_new_rvalue_from_const ): Likewise. (class memento_of_new_rvalue_from_const ): Likewise. (memento_of_new_rvalue_from_int::replay_into): Generalize into... (memento_of_new_rvalue_from_const ::replay_into): ...this... (memento_of_new_rvalue_from_double::replay_into): ...allowing this... (memento_of_new_rvalue_from_ptr::replay_into): ...and this to be deleted. (memento_of_new_rvalue_from_int::make_debug_string): Convert to... (memento_of_new_rvalue_from_const ::make_debug_string): ...this. (memento_of_new_rvalue_from_double::make_debug_string): Convert to... (memento_of_new_rvalue_from_const ::make_debug_string): ...this. (memento_of_new_rvalue_from_ptr::make_debug_string) Convert to... (memento_of_new_rvalue_from_const ::make_debug_string): ...this. (memento_of_new_rvalue_from_const ::make_debug_string): New function. * jit-recording.h: Within namespace gcc::jit::recording... (context::new_rvalue_from_int): Eliminate. (context::new_rvalue_from_double): Likewise. (context::new_rvalue_from_ptr): Likewise, all in favor of... (context::new_rvalue_from_const ): New family of methods. (class memento_of_new_rvalue_from_int): Eliminate. (class memento_of_new_rvalue_from_double): Likewise. (class memento_of_new_rvalue_from_ptr): Likewise. (class memento_of_new_rvalue_from_const ): New family of rvalue subclasses. * libgccjit++.h (gccjit::context::new_rvalue): New overload, for "long". * libgccjit.c (gcc_jit_context_new_rvalue_from_int): Update for rewriting of recording::context::new_rvalue_from_int to recording::context::new_rvalue_from_const . (gcc_jit_context_new_rvalue_from_long): New API entrypoint. (gcc_jit_context_new_rvalue_from_double): Update for rewriting of recording::context::new_rvalue_from_double to recording::context::new_rvalue_from_const . (gcc_jit_context_new_rvalue_from_ptr): Update for rewriting of recording::context::new_rvalue_from_ptr to recording::context::new_rvalue_from_const . * libgccjit.h (gcc_jit_context_new_rvalue_from_long): New API entrypoint. * libgccjit.map (gcc_jit_context_new_rvalue_from_long): Likewise. gcc/testsuite/ChangeLog: * jit.dg/all-non-failing-tests.h: Add test-constants.c. * jit.dg/test-combination.c (create_code): Likewise. (verify_code): Likewise. * jit.dg/test-constants.c: New test case. * jit.dg/test-threads.c: Add test-constants.c. From-SVN: r219401 --- diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog index 9dc133ed3ff..b84ac992cb2 100644 --- a/gcc/jit/ChangeLog +++ b/gcc/jit/ChangeLog @@ -1,3 +1,86 @@ +2015-01-09 David Malcolm + + * docs/cp/topics/expressions.rst (Simple expressions): Use + ":c:type:" for C types. Document new overload of + gcc::jit::context::new_rvalue. + * docs/topics/expressions.rst (Simple expressions): Use + ":c:type:" for C types. Document new entrypoint + gcc_jit_context_new_rvalue_from_long. + * docs/_build/texinfo/libgccjit.texi: Regenerate. + * jit-playback.c: Within namespace gcc::jit::playback... + (context::new_rvalue_from_int): Eliminate in favor of... + (context::new_rvalue_from_const ): ...this. + (context::new_rvalue_from_double): Eliminate in favor of... + (context::new_rvalue_from_const ): ...this. + (context::new_rvalue_from_const ): New. + (context::new_rvalue_from_ptr): Eliminate in favor of... + (context::new_rvalue_from_const ): ...this. + * jit-playback.h: Within namespace gcc::jit::playback... + (context::new_rvalue_from_int): Eliminate in favor of... + (context::new_rvalue_from_const ): ...this. + (context::new_rvalue_from_double): Likewise. + (context::new_rvalue_from_ptr): Likewise. + * jit-recording.c: Within namespace gcc::jit::recording... + (context::new_rvalue_from_int): Eliminate. + (context::new_rvalue_from_double): Likewise. + (context::new_rvalue_from_ptr): Likewise. + (class memento_of_new_rvalue_from_const ): + Add explicit specialization. + (class memento_of_new_rvalue_from_const ): + Likewise. + (class memento_of_new_rvalue_from_const ): + Likewise. + (class memento_of_new_rvalue_from_const ): + Likewise. + (memento_of_new_rvalue_from_int::replay_into): + Generalize into... + (memento_of_new_rvalue_from_const ::replay_into): + ...this... + (memento_of_new_rvalue_from_double::replay_into): + ...allowing this... + (memento_of_new_rvalue_from_ptr::replay_into): + ...and this to be deleted. + (memento_of_new_rvalue_from_int::make_debug_string): + Convert to... + (memento_of_new_rvalue_from_const ::make_debug_string): + ...this. + (memento_of_new_rvalue_from_double::make_debug_string): + Convert to... + (memento_of_new_rvalue_from_const ::make_debug_string): + ...this. + (memento_of_new_rvalue_from_ptr::make_debug_string) + Convert to... + (memento_of_new_rvalue_from_const ::make_debug_string): + ...this. + (memento_of_new_rvalue_from_const ::make_debug_string): + New function. + * jit-recording.h: Within namespace gcc::jit::recording... + (context::new_rvalue_from_int): Eliminate. + (context::new_rvalue_from_double): Likewise. + (context::new_rvalue_from_ptr): Likewise, all in favor of... + (context::new_rvalue_from_const ): New family of + methods. + (class memento_of_new_rvalue_from_int): Eliminate. + (class memento_of_new_rvalue_from_double): Likewise. + (class memento_of_new_rvalue_from_ptr): Likewise. + (class memento_of_new_rvalue_from_const ): New family + of rvalue subclasses. + * libgccjit++.h (gccjit::context::new_rvalue): New overload, for + "long". + * libgccjit.c (gcc_jit_context_new_rvalue_from_int): Update for + rewriting of recording::context::new_rvalue_from_int to + recording::context::new_rvalue_from_const . + (gcc_jit_context_new_rvalue_from_long): New API entrypoint. + (gcc_jit_context_new_rvalue_from_double): Update for + rewriting of recording::context::new_rvalue_from_double to + recording::context::new_rvalue_from_const . + (gcc_jit_context_new_rvalue_from_ptr): Update for + rewriting of recording::context::new_rvalue_from_ptr to + recording::context::new_rvalue_from_const . + * libgccjit.h (gcc_jit_context_new_rvalue_from_long): New API + entrypoint. + * libgccjit.map (gcc_jit_context_new_rvalue_from_long): Likewise. + 2015-01-09 David Malcolm PR jit/64206 diff --git a/gcc/jit/docs/_build/texinfo/libgccjit.texi b/gcc/jit/docs/_build/texinfo/libgccjit.texi index 4c9e2ba6e3f..1f5fcd05926 100644 --- a/gcc/jit/docs/_build/texinfo/libgccjit.texi +++ b/gcc/jit/docs/_build/texinfo/libgccjit.texi @@ -5260,7 +5260,15 @@ Upcast the given rvalue to be an object. @deffn {C Function} gcc_jit_rvalue * gcc_jit_context_new_rvalue_from_int (gcc_jit_context@w{ }*ctxt, gcc_jit_type@w{ }*numeric_type, int@w{ }value) Given a numeric type (integer or floating point), build an rvalue for -the given constant value. +the given constant @code{int} value. +@end deffn + +@geindex gcc_jit_context_new_rvalue_from_long (C function) +@anchor{topics/expressions gcc_jit_context_new_rvalue_from_long}@anchor{7f} +@deffn {C Function} gcc_jit_rvalue * gcc_jit_context_new_rvalue_from_long (gcc_jit_context@w{ }*ctxt, gcc_jit_type@w{ }*numeric_type, long@w{ }value) + +Given a numeric type (integer or floating point), build an rvalue for +the given constant @code{long} value. @end deffn @geindex gcc_jit_context_zero (C function) @@ -5296,18 +5304,18 @@ gcc_jit_context_new_rvalue_from_int (ctxt, numeric_type, 1) @deffn {C Function} gcc_jit_rvalue * gcc_jit_context_new_rvalue_from_double (gcc_jit_context@w{ }*ctxt, gcc_jit_type@w{ }*numeric_type, double@w{ }value) Given a numeric type (integer or floating point), build an rvalue for -the given constant value. +the given constant @code{double} value. @end deffn @geindex gcc_jit_context_new_rvalue_from_ptr (C function) -@anchor{topics/expressions gcc_jit_context_new_rvalue_from_ptr}@anchor{7f} +@anchor{topics/expressions gcc_jit_context_new_rvalue_from_ptr}@anchor{80} @deffn {C Function} gcc_jit_rvalue * gcc_jit_context_new_rvalue_from_ptr (gcc_jit_context@w{ }*ctxt, gcc_jit_type@w{ }*pointer_type, void@w{ }*value) Given a pointer type, build an rvalue for the given address. @end deffn @geindex gcc_jit_context_null (C function) -@anchor{topics/expressions gcc_jit_context_null}@anchor{80} +@anchor{topics/expressions gcc_jit_context_null}@anchor{81} @deffn {C Function} gcc_jit_rvalue *gcc_jit_context_null (gcc_jit_context@w{ }*ctxt, gcc_jit_type@w{ }*pointer_type) Given a pointer type, build an rvalue for @code{NULL}. Essentially this @@ -5321,7 +5329,7 @@ gcc_jit_context_new_rvalue_from_ptr (ctxt, pointer_type, NULL) @end deffn @geindex gcc_jit_context_new_string_literal (C function) -@anchor{topics/expressions gcc_jit_context_new_string_literal}@anchor{81} +@anchor{topics/expressions gcc_jit_context_new_string_literal}@anchor{82} @deffn {C Function} gcc_jit_rvalue * gcc_jit_context_new_string_literal (gcc_jit_context@w{ }*ctxt, const char@w{ }*value) Generate an rvalue for the given NIL-terminated string, of type @@ -5329,19 +5337,19 @@ Generate an rvalue for the given NIL-terminated string, of type @end deffn @node Unary Operations,Binary Operations,Simple expressions,Rvalues -@anchor{topics/expressions unary-operations}@anchor{82} +@anchor{topics/expressions unary-operations}@anchor{83} @subsubsection Unary Operations @geindex gcc_jit_context_new_unary_op (C function) -@anchor{topics/expressions gcc_jit_context_new_unary_op}@anchor{83} +@anchor{topics/expressions gcc_jit_context_new_unary_op}@anchor{84} @deffn {C Function} gcc_jit_rvalue * gcc_jit_context_new_unary_op (gcc_jit_context@w{ }*ctxt, gcc_jit_location@w{ }*loc, enum gcc_jit_unary_op@w{ }op, gcc_jit_type@w{ }*result_type, gcc_jit_rvalue@w{ }*rvalue) Build a unary operation out of an input rvalue. @end deffn @geindex gcc_jit_unary_op (C type) -@anchor{topics/expressions gcc_jit_unary_op}@anchor{84} +@anchor{topics/expressions gcc_jit_unary_op}@anchor{85} @deffn {C Type} enum gcc_jit_unary_op @end deffn @@ -5359,7 +5367,7 @@ C equivalent @item -@pxref{85,,GCC_JIT_UNARY_OP_MINUS} +@pxref{86,,GCC_JIT_UNARY_OP_MINUS} @tab @@ -5367,7 +5375,7 @@ C equivalent @item -@pxref{86,,GCC_JIT_UNARY_OP_BITWISE_NEGATE} +@pxref{87,,GCC_JIT_UNARY_OP_BITWISE_NEGATE} @tab @@ -5375,7 +5383,7 @@ C equivalent @item -@pxref{87,,GCC_JIT_UNARY_OP_LOGICAL_NEGATE} +@pxref{88,,GCC_JIT_UNARY_OP_LOGICAL_NEGATE} @tab @@ -5383,7 +5391,7 @@ C equivalent @item -@pxref{88,,GCC_JIT_UNARY_OP_ABS} +@pxref{89,,GCC_JIT_UNARY_OP_ABS} @tab @@ -5393,7 +5401,7 @@ C equivalent @geindex GCC_JIT_UNARY_OP_MINUS (C macro) -@anchor{topics/expressions GCC_JIT_UNARY_OP_MINUS}@anchor{85} +@anchor{topics/expressions GCC_JIT_UNARY_OP_MINUS}@anchor{86} @deffn {C Macro} GCC_JIT_UNARY_OP_MINUS Negate an arithmetic value; analogous to: @@ -5408,7 +5416,7 @@ in C. @end deffn @geindex GCC_JIT_UNARY_OP_BITWISE_NEGATE (C macro) -@anchor{topics/expressions GCC_JIT_UNARY_OP_BITWISE_NEGATE}@anchor{86} +@anchor{topics/expressions GCC_JIT_UNARY_OP_BITWISE_NEGATE}@anchor{87} @deffn {C Macro} GCC_JIT_UNARY_OP_BITWISE_NEGATE Bitwise negation of an integer value (one's complement); analogous @@ -5424,7 +5432,7 @@ in C. @end deffn @geindex GCC_JIT_UNARY_OP_LOGICAL_NEGATE (C macro) -@anchor{topics/expressions GCC_JIT_UNARY_OP_LOGICAL_NEGATE}@anchor{87} +@anchor{topics/expressions GCC_JIT_UNARY_OP_LOGICAL_NEGATE}@anchor{88} @deffn {C Macro} GCC_JIT_UNARY_OP_LOGICAL_NEGATE Logical negation of an arithmetic or pointer value; analogous to: @@ -5439,7 +5447,7 @@ in C. @end deffn @geindex GCC_JIT_UNARY_OP_ABS (C macro) -@anchor{topics/expressions GCC_JIT_UNARY_OP_ABS}@anchor{88} +@anchor{topics/expressions GCC_JIT_UNARY_OP_ABS}@anchor{89} @deffn {C Macro} GCC_JIT_UNARY_OP_ABS Absolute value of an arithmetic expression; analogous to: @@ -5454,7 +5462,7 @@ in C. @end deffn @node Binary Operations,Comparisons,Unary Operations,Rvalues -@anchor{topics/expressions binary-operations}@anchor{89} +@anchor{topics/expressions binary-operations}@anchor{8a} @subsubsection Binary Operations @@ -5466,7 +5474,7 @@ Build a binary operation out of two constituent rvalues. @end deffn @geindex gcc_jit_binary_op (C type) -@anchor{topics/expressions gcc_jit_binary_op}@anchor{8a} +@anchor{topics/expressions gcc_jit_binary_op}@anchor{8b} @deffn {C Type} enum gcc_jit_binary_op @end deffn @@ -5484,7 +5492,7 @@ C equivalent @item -@pxref{8b,,GCC_JIT_BINARY_OP_PLUS} +@pxref{8c,,GCC_JIT_BINARY_OP_PLUS} @tab @@ -5500,7 +5508,7 @@ C equivalent @item -@pxref{8c,,GCC_JIT_BINARY_OP_MULT} +@pxref{8d,,GCC_JIT_BINARY_OP_MULT} @tab @@ -5508,7 +5516,7 @@ C equivalent @item -@pxref{8d,,GCC_JIT_BINARY_OP_DIVIDE} +@pxref{8e,,GCC_JIT_BINARY_OP_DIVIDE} @tab @@ -5516,7 +5524,7 @@ C equivalent @item -@pxref{8e,,GCC_JIT_BINARY_OP_MODULO} +@pxref{8f,,GCC_JIT_BINARY_OP_MODULO} @tab @@ -5524,7 +5532,7 @@ C equivalent @item -@pxref{8f,,GCC_JIT_BINARY_OP_BITWISE_AND} +@pxref{90,,GCC_JIT_BINARY_OP_BITWISE_AND} @tab @@ -5532,7 +5540,7 @@ C equivalent @item -@pxref{90,,GCC_JIT_BINARY_OP_BITWISE_XOR} +@pxref{91,,GCC_JIT_BINARY_OP_BITWISE_XOR} @tab @@ -5540,7 +5548,7 @@ C equivalent @item -@pxref{91,,GCC_JIT_BINARY_OP_BITWISE_OR} +@pxref{92,,GCC_JIT_BINARY_OP_BITWISE_OR} @tab @@ -5548,7 +5556,7 @@ C equivalent @item -@pxref{92,,GCC_JIT_BINARY_OP_LOGICAL_AND} +@pxref{93,,GCC_JIT_BINARY_OP_LOGICAL_AND} @tab @@ -5556,7 +5564,7 @@ C equivalent @item -@pxref{93,,GCC_JIT_BINARY_OP_LOGICAL_OR} +@pxref{94,,GCC_JIT_BINARY_OP_LOGICAL_OR} @tab @@ -5564,7 +5572,7 @@ C equivalent @item -@pxref{94,,GCC_JIT_BINARY_OP_LSHIFT} +@pxref{95,,GCC_JIT_BINARY_OP_LSHIFT} @tab @@ -5572,7 +5580,7 @@ C equivalent @item -@pxref{95,,GCC_JIT_BINARY_OP_RSHIFT} +@pxref{96,,GCC_JIT_BINARY_OP_RSHIFT} @tab @@ -5582,7 +5590,7 @@ C equivalent @geindex GCC_JIT_BINARY_OP_PLUS (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_PLUS}@anchor{8b} +@anchor{topics/expressions GCC_JIT_BINARY_OP_PLUS}@anchor{8c} @deffn {C Macro} GCC_JIT_BINARY_OP_PLUS Addition of arithmetic values; analogous to: @@ -5595,7 +5603,7 @@ Addition of arithmetic values; analogous to: in C. -For pointer addition, use @pxref{96,,gcc_jit_context_new_array_access()}. +For pointer addition, use @pxref{97,,gcc_jit_context_new_array_access()}. @end deffn @@ -5613,7 +5621,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_MULT (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_MULT}@anchor{8c} +@anchor{topics/expressions GCC_JIT_BINARY_OP_MULT}@anchor{8d} @deffn {C Macro} GCC_JIT_BINARY_OP_MULT Multiplication of a pair of arithmetic values; analogous to: @@ -5628,7 +5636,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_DIVIDE (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_DIVIDE}@anchor{8d} +@anchor{topics/expressions GCC_JIT_BINARY_OP_DIVIDE}@anchor{8e} @deffn {C Macro} GCC_JIT_BINARY_OP_DIVIDE Quotient of division of arithmetic values; analogous to: @@ -5647,7 +5655,7 @@ a floating-point result type indicates floating-point division. @end deffn @geindex GCC_JIT_BINARY_OP_MODULO (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_MODULO}@anchor{8e} +@anchor{topics/expressions GCC_JIT_BINARY_OP_MODULO}@anchor{8f} @deffn {C Macro} GCC_JIT_BINARY_OP_MODULO Remainder of division of arithmetic values; analogous to: @@ -5662,7 +5670,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_BITWISE_AND (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_BITWISE_AND}@anchor{8f} +@anchor{topics/expressions GCC_JIT_BINARY_OP_BITWISE_AND}@anchor{90} @deffn {C Macro} GCC_JIT_BINARY_OP_BITWISE_AND Bitwise AND; analogous to: @@ -5677,7 +5685,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_BITWISE_XOR (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_BITWISE_XOR}@anchor{90} +@anchor{topics/expressions GCC_JIT_BINARY_OP_BITWISE_XOR}@anchor{91} @deffn {C Macro} GCC_JIT_BINARY_OP_BITWISE_XOR Bitwise exclusive OR; analogous to: @@ -5692,7 +5700,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_BITWISE_OR (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_BITWISE_OR}@anchor{91} +@anchor{topics/expressions GCC_JIT_BINARY_OP_BITWISE_OR}@anchor{92} @deffn {C Macro} GCC_JIT_BINARY_OP_BITWISE_OR Bitwise inclusive OR; analogous to: @@ -5707,7 +5715,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_LOGICAL_AND (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_LOGICAL_AND}@anchor{92} +@anchor{topics/expressions GCC_JIT_BINARY_OP_LOGICAL_AND}@anchor{93} @deffn {C Macro} GCC_JIT_BINARY_OP_LOGICAL_AND Logical AND; analogous to: @@ -5722,7 +5730,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_LOGICAL_OR (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_LOGICAL_OR}@anchor{93} +@anchor{topics/expressions GCC_JIT_BINARY_OP_LOGICAL_OR}@anchor{94} @deffn {C Macro} GCC_JIT_BINARY_OP_LOGICAL_OR Logical OR; analogous to: @@ -5737,7 +5745,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_LSHIFT (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_LSHIFT}@anchor{94} +@anchor{topics/expressions GCC_JIT_BINARY_OP_LSHIFT}@anchor{95} @deffn {C Macro} GCC_JIT_BINARY_OP_LSHIFT Left shift; analogous to: @@ -5752,7 +5760,7 @@ in C. @end deffn @geindex GCC_JIT_BINARY_OP_RSHIFT (C macro) -@anchor{topics/expressions GCC_JIT_BINARY_OP_RSHIFT}@anchor{95} +@anchor{topics/expressions GCC_JIT_BINARY_OP_RSHIFT}@anchor{96} @deffn {C Macro} GCC_JIT_BINARY_OP_RSHIFT Right shift; analogous to: @@ -5767,7 +5775,7 @@ in C. @end deffn @node Comparisons,Function calls,Binary Operations,Rvalues -@anchor{topics/expressions comparisons}@anchor{97} +@anchor{topics/expressions comparisons}@anchor{98} @subsubsection Comparisons @@ -5779,7 +5787,7 @@ Build a boolean rvalue out of the comparison of two other rvalues. @end deffn @geindex gcc_jit_comparison (C type) -@anchor{topics/expressions gcc_jit_comparison}@anchor{98} +@anchor{topics/expressions gcc_jit_comparison}@anchor{99} @deffn {C Type} enum gcc_jit_comparison @end deffn @@ -5845,12 +5853,12 @@ C equivalent @node Function calls,Type-coercion,Comparisons,Rvalues -@anchor{topics/expressions function-calls}@anchor{99} +@anchor{topics/expressions function-calls}@anchor{9a} @subsubsection Function calls @geindex gcc_jit_context_new_call (C function) -@anchor{topics/expressions gcc_jit_context_new_call}@anchor{9a} +@anchor{topics/expressions gcc_jit_context_new_call}@anchor{9b} @deffn {C Function} gcc_jit_rvalue * gcc_jit_context_new_call (gcc_jit_context@w{ }*ctxt, gcc_jit_location@w{ }*loc, gcc_jit_function@w{ }*func, int@w{ }numargs, gcc_jit_rvalue@w{ }**args) Given a function and the given table of argument rvalues, construct a @@ -5858,7 +5866,7 @@ call to the function, with the result as an rvalue. @cartouche @quotation Note -@pxref{9a,,gcc_jit_context_new_call()} merely builds a +@pxref{9b,,gcc_jit_context_new_call()} merely builds a @pxref{13,,gcc_jit_rvalue} i.e. an expression that can be evaluated, perhaps as part of a more complicated expression. The call @emph{won't} happen unless you add a statement to a function @@ -5866,7 +5874,7 @@ that evaluates the expression. For example, if you want to call a function and discard the result (or to call a function with @code{void} return type), use -@pxref{9b,,gcc_jit_block_add_eval()}: +@pxref{9c,,gcc_jit_block_add_eval()}: @example /* Add "(void)printf (arg0, arg1);". */ @@ -5885,12 +5893,12 @@ gcc_jit_block_add_eval ( @end deffn @node Type-coercion,,Function calls,Rvalues -@anchor{topics/expressions type-coercion}@anchor{9c} +@anchor{topics/expressions type-coercion}@anchor{9d} @subsubsection Type-coercion @geindex gcc_jit_context_new_cast (C function) -@anchor{topics/expressions gcc_jit_context_new_cast}@anchor{9d} +@anchor{topics/expressions gcc_jit_context_new_cast}@anchor{9e} @deffn {C Function} gcc_jit_rvalue * gcc_jit_context_new_cast (gcc_jit_context@w{ }*ctxt, gcc_jit_location@w{ }*loc, gcc_jit_rvalue@w{ }*rvalue, gcc_jit_type@w{ }*type) Given an rvalue of T, construct another rvalue of another type. @@ -5915,7 +5923,7 @@ P* <-> Q*, for pointer types P and Q @end deffn @node Lvalues,Working with pointers structs and unions,Rvalues,Expressions -@anchor{topics/expressions lvalues}@anchor{9e} +@anchor{topics/expressions lvalues}@anchor{9f} @subsection Lvalues @@ -5929,21 +5937,21 @@ a storage area (such as a variable). It is also usable as an rvalue, where the rvalue is computed by reading from the storage area. @geindex gcc_jit_lvalue_as_object (C function) -@anchor{topics/expressions gcc_jit_lvalue_as_object}@anchor{9f} +@anchor{topics/expressions gcc_jit_lvalue_as_object}@anchor{a0} @deffn {C Function} gcc_jit_object * gcc_jit_lvalue_as_object (gcc_jit_lvalue@w{ }*lvalue) Upcast an lvalue to be an object. @end deffn @geindex gcc_jit_lvalue_as_rvalue (C function) -@anchor{topics/expressions gcc_jit_lvalue_as_rvalue}@anchor{a0} +@anchor{topics/expressions gcc_jit_lvalue_as_rvalue}@anchor{a1} @deffn {C Function} gcc_jit_rvalue * gcc_jit_lvalue_as_rvalue (gcc_jit_lvalue@w{ }*lvalue) Upcast an lvalue to be an rvalue. @end deffn @geindex gcc_jit_lvalue_get_address (C function) -@anchor{topics/expressions gcc_jit_lvalue_get_address}@anchor{a1} +@anchor{topics/expressions gcc_jit_lvalue_get_address}@anchor{a2} @deffn {C Function} gcc_jit_rvalue * gcc_jit_lvalue_get_address (gcc_jit_lvalue@w{ }*lvalue, gcc_jit_location@w{ }*loc) Take the address of an lvalue; analogous to: @@ -5963,24 +5971,24 @@ in C. @end menu @node Global variables,,,Lvalues -@anchor{topics/expressions global-variables}@anchor{a2} +@anchor{topics/expressions global-variables}@anchor{a3} @subsubsection Global variables @geindex gcc_jit_context_new_global (C function) -@anchor{topics/expressions gcc_jit_context_new_global}@anchor{a3} +@anchor{topics/expressions gcc_jit_context_new_global}@anchor{a4} @deffn {C Function} gcc_jit_lvalue * gcc_jit_context_new_global (gcc_jit_context@w{ }*ctxt, gcc_jit_location@w{ }*loc, gcc_jit_type@w{ }*type, const char@w{ }*name) Add a new global variable of the given type and name to the context. @end deffn @node Working with pointers structs and unions,,Lvalues,Expressions -@anchor{topics/expressions working-with-pointers-structs-and-unions}@anchor{a4} +@anchor{topics/expressions working-with-pointers-structs-and-unions}@anchor{a5} @subsection Working with pointers, structs and unions @geindex gcc_jit_rvalue_dereference (C function) -@anchor{topics/expressions gcc_jit_rvalue_dereference}@anchor{a5} +@anchor{topics/expressions gcc_jit_rvalue_dereference}@anchor{a6} @deffn {C Function} gcc_jit_lvalue * gcc_jit_rvalue_dereference (gcc_jit_rvalue@w{ }*rvalue, gcc_jit_location@w{ }*loc) Given an rvalue of pointer type @code{T *}, dereferencing the pointer, @@ -5998,7 +6006,7 @@ in C. Field access is provided separately for both lvalues and rvalues. @geindex gcc_jit_lvalue_access_field (C function) -@anchor{topics/expressions gcc_jit_lvalue_access_field}@anchor{a6} +@anchor{topics/expressions gcc_jit_lvalue_access_field}@anchor{a7} @deffn {C Function} gcc_jit_lvalue * gcc_jit_lvalue_access_field (gcc_jit_lvalue@w{ }*struct_, gcc_jit_location@w{ }*loc, gcc_jit_field@w{ }*field) Given an lvalue of struct or union type, access the given field, @@ -6014,7 +6022,7 @@ in C. @end deffn @geindex gcc_jit_rvalue_access_field (C function) -@anchor{topics/expressions gcc_jit_rvalue_access_field}@anchor{a7} +@anchor{topics/expressions gcc_jit_rvalue_access_field}@anchor{a8} @deffn {C Function} gcc_jit_rvalue * gcc_jit_rvalue_access_field (gcc_jit_rvalue@w{ }*struct_, gcc_jit_location@w{ }*loc, gcc_jit_field@w{ }*field) Given an rvalue of struct or union type, access the given field @@ -6030,7 +6038,7 @@ in C. @end deffn @geindex gcc_jit_rvalue_dereference_field (C function) -@anchor{topics/expressions gcc_jit_rvalue_dereference_field}@anchor{a8} +@anchor{topics/expressions gcc_jit_rvalue_dereference_field}@anchor{a9} @deffn {C Function} gcc_jit_lvalue * gcc_jit_rvalue_dereference_field (gcc_jit_rvalue@w{ }*ptr, gcc_jit_location@w{ }*loc, gcc_jit_field@w{ }*field) Given an rvalue of pointer type @code{T *} where T is of struct or union @@ -6046,7 +6054,7 @@ in C, itself equivalent to @code{(*EXPR).FIELD}. @end deffn @geindex gcc_jit_context_new_array_access (C function) -@anchor{topics/expressions gcc_jit_context_new_array_access}@anchor{96} +@anchor{topics/expressions gcc_jit_context_new_array_access}@anchor{97} @deffn {C Function} gcc_jit_lvalue * gcc_jit_context_new_array_access (gcc_jit_context@w{ }*ctxt, gcc_jit_location@w{ }*loc, gcc_jit_rvalue@w{ }*ptr, gcc_jit_rvalue@w{ }*index) Given an rvalue of pointer type @code{T *}, get at the element @cite{T} at @@ -6081,7 +6089,7 @@ in C (or, indeed, to @code{PTR + INDEX}). @c . @node Creating and using functions,Source Locations,Expressions,Topic Reference -@anchor{topics/functions doc}@anchor{a9}@anchor{topics/functions creating-and-using-functions}@anchor{aa} +@anchor{topics/functions doc}@anchor{aa}@anchor{topics/functions creating-and-using-functions}@anchor{ab} @section Creating and using functions @@ -6094,7 +6102,7 @@ in C (or, indeed, to @code{PTR + INDEX}). @end menu @node Params,Functions,,Creating and using functions -@anchor{topics/functions params}@anchor{ab} +@anchor{topics/functions params}@anchor{ac} @subsection Params @@ -6117,28 +6125,28 @@ Parameters are lvalues, and thus are also rvalues (and objects), so the following upcasts are available: @geindex gcc_jit_param_as_lvalue (C function) -@anchor{topics/functions gcc_jit_param_as_lvalue}@anchor{ac} +@anchor{topics/functions gcc_jit_param_as_lvalue}@anchor{ad} @deffn {C Function} gcc_jit_lvalue * gcc_jit_param_as_lvalue (gcc_jit_param@w{ }*param) Upcasting from param to lvalue. @end deffn @geindex gcc_jit_param_as_rvalue (C function) -@anchor{topics/functions gcc_jit_param_as_rvalue}@anchor{ad} +@anchor{topics/functions gcc_jit_param_as_rvalue}@anchor{ae} @deffn {C Function} gcc_jit_rvalue * gcc_jit_param_as_rvalue (gcc_jit_param@w{ }*param) Upcasting from param to rvalue. @end deffn @geindex gcc_jit_param_as_object (C function) -@anchor{topics/functions gcc_jit_param_as_object}@anchor{ae} +@anchor{topics/functions gcc_jit_param_as_object}@anchor{af} @deffn {C Function} gcc_jit_object * gcc_jit_param_as_object (gcc_jit_param@w{ }*param) Upcasting from param to object. @end deffn @node Functions,Blocks,Params,Creating and using functions -@anchor{topics/functions functions}@anchor{af} +@anchor{topics/functions functions}@anchor{b0} @subsection Functions @@ -6157,7 +6165,7 @@ creating ourselves, or one that we're referencing. Create a gcc_jit_function with the given name and parameters. @geindex gcc_jit_function_kind (C type) -@anchor{topics/functions gcc_jit_function_kind}@anchor{b0} +@anchor{topics/functions gcc_jit_function_kind}@anchor{b1} @deffn {C Type} enum gcc_jit_function_kind @end deffn @@ -6167,7 +6175,7 @@ values: @quotation @geindex GCC_JIT_FUNCTION_EXPORTED (C macro) -@anchor{topics/functions GCC_JIT_FUNCTION_EXPORTED}@anchor{b1} +@anchor{topics/functions GCC_JIT_FUNCTION_EXPORTED}@anchor{b2} @deffn {C Macro} GCC_JIT_FUNCTION_EXPORTED Function is defined by the client code and visible @@ -6179,7 +6187,7 @@ for this function from a @pxref{16,,gcc_jit_result} via @end deffn @geindex GCC_JIT_FUNCTION_INTERNAL (C macro) -@anchor{topics/functions GCC_JIT_FUNCTION_INTERNAL}@anchor{b2} +@anchor{topics/functions GCC_JIT_FUNCTION_INTERNAL}@anchor{b3} @deffn {C Macro} GCC_JIT_FUNCTION_INTERNAL Function is defined by the client code, but is invisible @@ -6187,7 +6195,7 @@ outside of the JIT. Analogous to a "static" function. @end deffn @geindex GCC_JIT_FUNCTION_IMPORTED (C macro) -@anchor{topics/functions GCC_JIT_FUNCTION_IMPORTED}@anchor{b3} +@anchor{topics/functions GCC_JIT_FUNCTION_IMPORTED}@anchor{b4} @deffn {C Macro} GCC_JIT_FUNCTION_IMPORTED Function is not defined by the client code; we're merely @@ -6196,7 +6204,7 @@ header file. @end deffn @geindex GCC_JIT_FUNCTION_ALWAYS_INLINE (C macro) -@anchor{topics/functions GCC_JIT_FUNCTION_ALWAYS_INLINE}@anchor{b4} +@anchor{topics/functions GCC_JIT_FUNCTION_ALWAYS_INLINE}@anchor{b5} @deffn {C Macro} GCC_JIT_FUNCTION_ALWAYS_INLINE Function is only ever inlined into other functions, and is @@ -6213,19 +6221,19 @@ same as GCC_JIT_FUNCTION_INTERNAL. @end deffn @geindex gcc_jit_context_get_builtin_function (C function) -@anchor{topics/functions gcc_jit_context_get_builtin_function}@anchor{b5} +@anchor{topics/functions gcc_jit_context_get_builtin_function}@anchor{b6} @deffn {C Function} gcc_jit_function *gcc_jit_context_get_builtin_function (gcc_jit_context@w{ }*ctxt, const char@w{ }*name) @end deffn @geindex gcc_jit_function_as_object (C function) -@anchor{topics/functions gcc_jit_function_as_object}@anchor{b6} +@anchor{topics/functions gcc_jit_function_as_object}@anchor{b7} @deffn {C Function} gcc_jit_object * gcc_jit_function_as_object (gcc_jit_function@w{ }*func) Upcasting from function to object. @end deffn @geindex gcc_jit_function_get_param (C function) -@anchor{topics/functions gcc_jit_function_get_param}@anchor{b7} +@anchor{topics/functions gcc_jit_function_get_param}@anchor{b8} @deffn {C Function} gcc_jit_param * gcc_jit_function_get_param (gcc_jit_function@w{ }*func, int@w{ }index) Get the param of the given index (0-based). @@ -6247,7 +6255,7 @@ name. @end deffn @node Blocks,Statements,Functions,Creating and using functions -@anchor{topics/functions blocks}@anchor{b8} +@anchor{topics/functions blocks}@anchor{b9} @subsection Blocks @@ -6270,7 +6278,7 @@ one function. @end deffn @geindex gcc_jit_function_new_block (C function) -@anchor{topics/functions gcc_jit_function_new_block}@anchor{b9} +@anchor{topics/functions gcc_jit_function_new_block}@anchor{ba} @deffn {C Function} gcc_jit_block * gcc_jit_function_new_block (gcc_jit_function@w{ }*func, const char@w{ }*name) Create a basic block of the given name. The name may be NULL, but @@ -6280,26 +6288,26 @@ messages. @end deffn @geindex gcc_jit_block_as_object (C function) -@anchor{topics/functions gcc_jit_block_as_object}@anchor{ba} +@anchor{topics/functions gcc_jit_block_as_object}@anchor{bb} @deffn {C Function} gcc_jit_object * gcc_jit_block_as_object (gcc_jit_block@w{ }*block) Upcast from block to object. @end deffn @geindex gcc_jit_block_get_function (C function) -@anchor{topics/functions gcc_jit_block_get_function}@anchor{bb} +@anchor{topics/functions gcc_jit_block_get_function}@anchor{bc} @deffn {C Function} gcc_jit_function * gcc_jit_block_get_function (gcc_jit_block@w{ }*block) Which function is this block within? @end deffn @node Statements,,Blocks,Creating and using functions -@anchor{topics/functions statements}@anchor{bc} +@anchor{topics/functions statements}@anchor{bd} @subsection Statements @geindex gcc_jit_block_add_eval (C function) -@anchor{topics/functions gcc_jit_block_add_eval}@anchor{9b} +@anchor{topics/functions gcc_jit_block_add_eval}@anchor{9c} @deffn {C Function} void gcc_jit_block_add_eval (gcc_jit_block@w{ }*block, gcc_jit_location@w{ }*loc, gcc_jit_rvalue@w{ }*rvalue) Add evaluation of an rvalue, discarding the result @@ -6395,7 +6403,7 @@ block, boolval, on_true, and on_false must be non-NULL. @end deffn @geindex gcc_jit_block_end_with_jump (C function) -@anchor{topics/functions gcc_jit_block_end_with_jump}@anchor{bd} +@anchor{topics/functions gcc_jit_block_end_with_jump}@anchor{be} @deffn {C Function} void gcc_jit_block_end_with_jump (gcc_jit_block@w{ }*block, gcc_jit_location@w{ }*loc, gcc_jit_block@w{ }*target) Terminate a block by adding a jump to the given target block. @@ -6410,7 +6418,7 @@ goto target; @end deffn @geindex gcc_jit_block_end_with_return (C function) -@anchor{topics/functions gcc_jit_block_end_with_return}@anchor{be} +@anchor{topics/functions gcc_jit_block_end_with_return}@anchor{bf} @deffn {C Function} void gcc_jit_block_end_with_return (gcc_jit_block@w{ }*block, gcc_jit_location@w{ }*loc, gcc_jit_rvalue@w{ }*rvalue) Terminate a block by adding evaluation of an rvalue, returning the value. @@ -6425,7 +6433,7 @@ return expression; @end deffn @geindex gcc_jit_block_end_with_void_return (C function) -@anchor{topics/functions gcc_jit_block_end_with_void_return}@anchor{bf} +@anchor{topics/functions gcc_jit_block_end_with_void_return}@anchor{c0} @deffn {C Function} void gcc_jit_block_end_with_void_return (gcc_jit_block@w{ }*block, gcc_jit_location@w{ }*loc) Terminate a block by adding a valueless return, for use within a function @@ -6458,7 +6466,7 @@ return; @c . @node Source Locations,Compilation results,Creating and using functions,Topic Reference -@anchor{topics/locations source-locations}@anchor{c0}@anchor{topics/locations doc}@anchor{c1} +@anchor{topics/locations source-locations}@anchor{c1}@anchor{topics/locations doc}@anchor{c2} @section Source Locations @@ -6504,7 +6512,7 @@ location. @end menu @node Faking it,,,Source Locations -@anchor{topics/locations faking-it}@anchor{c2} +@anchor{topics/locations faking-it}@anchor{c3} @subsection Faking it @@ -6542,7 +6550,7 @@ file, giving you @emph{something} you can step through in the debugger. @c . @node Compilation results,,Source Locations,Topic Reference -@anchor{topics/results compilation-results}@anchor{c3}@anchor{topics/results doc}@anchor{c4} +@anchor{topics/results compilation-results}@anchor{c4}@anchor{topics/results doc}@anchor{c5} @section Compilation results @@ -6573,7 +6581,7 @@ Functions are looked up by name. For this to succeed, a function with a name matching @cite{funcname} must have been created on @cite{result}'s context (or a parent context) via a call to @pxref{11,,gcc_jit_context_new_function()} with @cite{kind} -@pxref{b1,,GCC_JIT_FUNCTION_EXPORTED}: +@pxref{b2,,GCC_JIT_FUNCTION_EXPORTED}: @example gcc_jit_context_new_function (ctxt, @@ -6630,7 +6638,7 @@ valid to use the result, or any code that was obtained by calling @c . @node C++ bindings for libgccjit,Internals,Topic Reference,Top -@anchor{cp/index c-bindings-for-libgccjit}@anchor{c5}@anchor{cp/index doc}@anchor{c6} +@anchor{cp/index c-bindings-for-libgccjit}@anchor{c6}@anchor{cp/index doc}@anchor{c7} @chapter C++ bindings for libgccjit @@ -6772,7 +6780,7 @@ Source Locations @node Tutorial<2>,Topic Reference<2>,,C++ bindings for libgccjit -@anchor{cp/intro/index doc}@anchor{c7}@anchor{cp/intro/index tutorial}@anchor{c8} +@anchor{cp/intro/index doc}@anchor{c8}@anchor{cp/intro/index tutorial}@anchor{c9} @section Tutorial @@ -6802,7 +6810,7 @@ Source Locations @end menu @node Tutorial part 1 "Hello world"<2>,Tutorial part 2 Creating a trivial machine code function<2>,,Tutorial<2> -@anchor{cp/intro/tutorial01 doc}@anchor{c9}@anchor{cp/intro/tutorial01 tutorial-part-1-hello-world}@anchor{ca} +@anchor{cp/intro/tutorial01 doc}@anchor{ca}@anchor{cp/intro/tutorial01 tutorial-part-1-hello-world}@anchor{cb} @subsection Tutorial part 1: "Hello world" @@ -6972,7 +6980,7 @@ hello world @c . @node Tutorial part 2 Creating a trivial machine code function<2>,Tutorial part 3 Loops and variables<2>,Tutorial part 1 "Hello world"<2>,Tutorial<2> -@anchor{cp/intro/tutorial02 doc}@anchor{cb}@anchor{cp/intro/tutorial02 tutorial-part-2-creating-a-trivial-machine-code-function}@anchor{cc} +@anchor{cp/intro/tutorial02 doc}@anchor{cc}@anchor{cp/intro/tutorial02 tutorial-part-2-creating-a-trivial-machine-code-function}@anchor{cd} @subsection Tutorial part 2: Creating a trivial machine code function @@ -7001,7 +7009,7 @@ All state associated with compilation is associated with a @code{gccjit::context}, which is a thin C++ wrapper around the C API's @pxref{8,,gcc_jit_context *}. -Create one using @pxref{cd,,gccjit;;context;;acquire()}: +Create one using @pxref{ce,,gccjit;;context;;acquire()}: @example gccjit::context ctxt; @@ -7014,7 +7022,7 @@ The JIT library has a system of types. It is statically-typed: every expression is of a specific type, fixed at compile-time. In our example, all of the expressions are of the C @cite{int} type, so let's obtain this from the context, as a @code{gccjit::type}, using -@pxref{ce,,gccjit;;context;;get_type()}: +@pxref{cf,,gccjit;;context;;get_type()}: @example gccjit::type int_type = ctxt.get_type (GCC_JIT_TYPE_INT); @@ -7027,7 +7035,7 @@ entity in the API is associated with a @code{gccjit::context}. Memory management is easy: all such "contextual" objects are automatically cleaned up for you when the context is released, using -@pxref{cf,,gccjit;;context;;release()}: +@pxref{d0,,gccjit;;context;;release()}: @example ctxt.release (); @@ -7060,7 +7068,7 @@ The C++ class hierarchy within the @code{gccjit} namespace looks like this: One thing you can do with a @code{gccjit::object} is to ask it for a human-readable description as a @code{std::string}, using -@pxref{d0,,gccjit;;object;;get_debug_string()}: +@pxref{d1,,gccjit;;object;;get_debug_string()}: @example printf ("obj: %s\n", obj.get_debug_string ().c_str ()); @@ -7080,7 +7088,7 @@ This is invaluable when debugging. Let's create the function. To do so, we first need to construct its single parameter, specifying its type and giving it a name, -using @pxref{d1,,gccjit;;context;;new_param()}: +using @pxref{d2,,gccjit;;context;;new_param()}: @example gccjit::param param_i = ctxt.new_param (int_type, "i"); @@ -7129,7 +7137,7 @@ gccjit::block block = func.new_block (); Our basic block is relatively simple: it immediately terminates by returning the value of an expression. -We can build the expression using @pxref{d2,,gccjit;;context;;new_binary_op()}: +We can build the expression using @pxref{d3,,gccjit;;context;;new_binary_op()}: @example gccjit::rvalue expr = @@ -7142,7 +7150,7 @@ gccjit::rvalue expr = A @code{gccjit::rvalue} is another example of a @code{gccjit::object} subclass. As before, we can print it with -@pxref{d0,,gccjit;;object;;get_debug_string()}. +@pxref{d1,,gccjit;;object;;get_debug_string()}. @example printf ("expr: %s\n", expr.get_debug_string ().c_str ()); @@ -7179,7 +7187,7 @@ block.end_with_return (expr); @noindent OK, we've populated the context. We can now compile it using -@pxref{d3,,gccjit;;context;;compile()}: +@pxref{d4,,gccjit;;context;;compile()}: @example gcc_jit_result *result; @@ -7229,12 +7237,12 @@ result: 25 @end menu @node Options<3>,Full example<3>,,Tutorial part 2 Creating a trivial machine code function<2> -@anchor{cp/intro/tutorial02 options}@anchor{d4} +@anchor{cp/intro/tutorial02 options}@anchor{d5} @subsubsection Options To get more information on what's going on, you can set debugging flags -on the context using @pxref{d5,,gccjit;;context;;set_bool_option()}. +on the context using @pxref{d6,,gccjit;;context;;set_bool_option()}. @c (I'm deliberately not mentioning @c :c:macro:`GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE` here since I think @@ -7306,7 +7314,7 @@ square: By default, no optimizations are performed, the equivalent of GCC's @cite{-O0} option. We can turn things up to e.g. @cite{-O3} by calling -@pxref{d6,,gccjit;;context;;set_int_option()} with +@pxref{d7,,gccjit;;context;;set_int_option()} with @pxref{1f,,GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL}: @example @@ -7340,7 +7348,7 @@ square: Naturally this has only a small effect on such a trivial function. @node Full example<3>,,Options<3>,Tutorial part 2 Creating a trivial machine code function<2> -@anchor{cp/intro/tutorial02 full-example}@anchor{d7} +@anchor{cp/intro/tutorial02 full-example}@anchor{d8} @subsubsection Full example @@ -7483,7 +7491,7 @@ result: 25 @c . @node Tutorial part 3 Loops and variables<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2>,Tutorial part 2 Creating a trivial machine code function<2>,Tutorial<2> -@anchor{cp/intro/tutorial03 tutorial-part-3-loops-and-variables}@anchor{d8}@anchor{cp/intro/tutorial03 doc}@anchor{d9} +@anchor{cp/intro/tutorial03 tutorial-part-3-loops-and-variables}@anchor{d9}@anchor{cp/intro/tutorial03 doc}@anchor{da} @subsection Tutorial part 3: Loops and variables @@ -7607,7 +7615,7 @@ gccjit::function func = @end menu @node Expressions lvalues and rvalues<2>,Control flow<2>,,Tutorial part 3 Loops and variables<2> -@anchor{cp/intro/tutorial03 expressions-lvalues-and-rvalues}@anchor{da} +@anchor{cp/intro/tutorial03 expressions-lvalues-and-rvalues}@anchor{db} @subsubsection Expressions: lvalues and rvalues @@ -7680,7 +7688,7 @@ body of a function. Our new example has a new kind of expression: we have two local variables. We create them by calling -@pxref{db,,gccjit;;function;;new_local()}, supplying a type and a name: +@pxref{dc,,gccjit;;function;;new_local()}, supplying a type and a name: @example /* Build locals: */ @@ -7706,7 +7714,7 @@ Instead, having added the local to the function, we have to separately add an assignment of @cite{0} to @cite{local_i} at the beginning of the function. @node Control flow<2>,Visualizing the control flow graph<2>,Expressions lvalues and rvalues<2>,Tutorial part 3 Loops and variables<2> -@anchor{cp/intro/tutorial03 control-flow}@anchor{dc} +@anchor{cp/intro/tutorial03 control-flow}@anchor{dd} @subsubsection Control flow @@ -7745,8 +7753,8 @@ We now populate each block with statements. The entry block @cite{b_initial} consists of initializations followed by a jump to the conditional. We assign @cite{0} to @cite{i} and to @cite{sum}, using -@pxref{dd,,gccjit;;block;;add_assignment()} to add -an assignment statement, and using @pxref{de,,gccjit;;context;;zero()} to get +@pxref{de,,gccjit;;block;;add_assignment()} to add +an assignment statement, and using @pxref{df,,gccjit;;context;;zero()} to get the constant value @cite{0} for the relevant type for the right-hand side of the assignment: @@ -7773,7 +7781,7 @@ C example. It contains a single statement: a conditional, which jumps to one of two destination blocks depending on a boolean @code{gccjit::rvalue}, in this case the comparison of @cite{i} and @cite{n}. -We could build the comparison using @pxref{df,,gccjit;;context;;new_comparison()}: +We could build the comparison using @pxref{e0,,gccjit;;context;;new_comparison()}: @example gccjit::rvalue guard = @@ -7784,7 +7792,7 @@ gccjit::rvalue guard = @noindent and can then use this to add @cite{b_loop_cond}'s sole statement, via -@pxref{e0,,gccjit;;block;;end_with_conditional()}: +@pxref{e1,,gccjit;;block;;end_with_conditional()}: @example b_loop_cond.end_with_conditional (guard); @@ -7816,7 +7824,7 @@ Next, we populate the body of the loop. The C statement @cite{sum += i * i;} is an assignment operation, where an lvalue is modified "in-place". We use -@pxref{e1,,gccjit;;block;;add_assignment_op()} to handle these operations: +@pxref{e2,,gccjit;;block;;add_assignment_op()} to handle these operations: @example /* sum += i * i */ @@ -7844,7 +7852,7 @@ b_loop_body.add_assignment_op (i, @cartouche @quotation Note For numeric constants other than 0 or 1, we could use -@pxref{e2,,gccjit;;context;;new_rvalue()}, which has overloads +@pxref{e3,,gccjit;;context;;new_rvalue()}, which has overloads for both @code{int} and @code{double}. @end quotation @end cartouche @@ -7920,12 +7928,12 @@ result: 285 @noindent @node Visualizing the control flow graph<2>,Full example<4>,Control flow<2>,Tutorial part 3 Loops and variables<2> -@anchor{cp/intro/tutorial03 visualizing-the-control-flow-graph}@anchor{e3} +@anchor{cp/intro/tutorial03 visualizing-the-control-flow-graph}@anchor{e4} @subsubsection Visualizing the control flow graph You can see the control flow graph of a function using -@pxref{e4,,gccjit;;function;;dump_to_dot()}: +@pxref{e5,,gccjit;;function;;dump_to_dot()}: @example func.dump_to_dot ("/tmp/sum-of-squares.dot"); @@ -7959,7 +7967,7 @@ install it with @cite{yum install python-xdot}): @end quotation @node Full example<4>,,Visualizing the control flow graph<2>,Tutorial part 3 Loops and variables<2> -@anchor{cp/intro/tutorial03 full-example}@anchor{e5} +@anchor{cp/intro/tutorial03 full-example}@anchor{e6} @subsubsection Full example @@ -8142,7 +8150,7 @@ loop_test returned: 285 @c . @node Tutorial part 4 Adding JIT-compilation to a toy interpreter<2>,,Tutorial part 3 Loops and variables<2>,Tutorial<2> -@anchor{cp/intro/tutorial04 tutorial-part-4-adding-jit-compilation-to-a-toy-interpreter}@anchor{e6}@anchor{cp/intro/tutorial04 doc}@anchor{e7} +@anchor{cp/intro/tutorial04 tutorial-part-4-adding-jit-compilation-to-a-toy-interpreter}@anchor{e7}@anchor{cp/intro/tutorial04 doc}@anchor{e8} @subsection Tutorial part 4: Adding JIT-compilation to a toy interpreter @@ -8164,7 +8172,7 @@ to it. @end menu @node Our toy interpreter<2>,Compiling to machine code<2>,,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 our-toy-interpreter}@anchor{e8} +@anchor{cp/intro/tutorial04 our-toy-interpreter}@anchor{e9} @subsubsection Our toy interpreter @@ -8572,7 +8580,7 @@ toyvm_function::interpret (int arg, FILE *trace) @end quotation @node Compiling to machine code<2>,Setting things up<2>,Our toy interpreter<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 compiling-to-machine-code}@anchor{e9} +@anchor{cp/intro/tutorial04 compiling-to-machine-code}@anchor{ea} @subsubsection Compiling to machine code @@ -8652,7 +8660,7 @@ This means our compiler has the following state: @end quotation @node Setting things up<2>,Populating the function<2>,Compiling to machine code<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 setting-things-up}@anchor{ea} +@anchor{cp/intro/tutorial04 setting-things-up}@anchor{eb} @subsubsection Setting things up @@ -8820,7 +8828,7 @@ We create the locals within the function. @end quotation @node Populating the function<2>,Verifying the control flow graph<2>,Setting things up<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 populating-the-function}@anchor{eb} +@anchor{cp/intro/tutorial04 populating-the-function}@anchor{ec} @subsubsection Populating the function @@ -8948,7 +8956,7 @@ stack into @code{y} instead erroneously assigned it to @code{x}, leaving @code{y uninitialized. To track this kind of thing down, we can use -@pxref{ec,,gccjit;;block;;add_comment()} to add descriptive comments +@pxref{ed,,gccjit;;block;;add_comment()} to add descriptive comments to the internal representation. This is invaluable when looking through the generated IR for, say @code{factorial}: @@ -9097,14 +9105,14 @@ to the next block. This is analogous to simply incrementing the program counter. @node Verifying the control flow graph<2>,Compiling the context<2>,Populating the function<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 verifying-the-control-flow-graph}@anchor{ed} +@anchor{cp/intro/tutorial04 verifying-the-control-flow-graph}@anchor{ee} @subsubsection Verifying the control flow graph Having finished looping over the blocks, the context is complete. As before, we can verify that the control flow and statements are sane by -using @pxref{e4,,gccjit;;function;;dump_to_dot()}: +using @pxref{e5,,gccjit;;function;;dump_to_dot()}: @example fn.dump_to_dot ("/tmp/factorial.dot"); @@ -9128,7 +9136,7 @@ errors in our compiler. @end quotation @node Compiling the context<2>,Single-stepping through the generated code<2>,Verifying the control flow graph<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 compiling-the-context}@anchor{ee} +@anchor{cp/intro/tutorial04 compiling-the-context}@anchor{ef} @subsubsection Compiling the context @@ -9165,7 +9173,7 @@ We can now run the result: @end quotation @node Single-stepping through the generated code<2>,Examining the generated code<2>,Compiling the context<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 single-stepping-through-the-generated-code}@anchor{ef} +@anchor{cp/intro/tutorial04 single-stepping-through-the-generated-code}@anchor{f0} @subsubsection Single-stepping through the generated code @@ -9179,14 +9187,14 @@ It's possible to debug the generated code. To do this we need to both: @item Set up source code locations for our statements, so that we can meaningfully step through the code. We did this above by -calling @pxref{f0,,gccjit;;context;;new_location()} and using the +calling @pxref{f1,,gccjit;;context;;new_location()} and using the results. @item Enable the generation of debugging information, by setting @pxref{42,,GCC_JIT_BOOL_OPTION_DEBUGINFO} on the @code{gccjit::context} via -@pxref{d5,,gccjit;;context;;set_bool_option()}: +@pxref{d6,,gccjit;;context;;set_bool_option()}: @example ctxt.set_bool_option (GCC_JIT_BOOL_OPTION_DEBUGINFO, 1); @@ -9258,14 +9266,14 @@ optimization level in a regular compiler. @end cartouche @node Examining the generated code<2>,Putting it all together<2>,Single-stepping through the generated code<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 examining-the-generated-code}@anchor{f1} +@anchor{cp/intro/tutorial04 examining-the-generated-code}@anchor{f2} @subsubsection Examining the generated code How good is the optimized code? We can turn up optimizations, by calling -@pxref{d6,,gccjit;;context;;set_int_option()} with +@pxref{d7,,gccjit;;context;;set_int_option()} with @pxref{1f,,GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL}: @example @@ -9447,7 +9455,7 @@ Note that the stack pushing and popping have been eliminated, as has the recursive call (in favor of an iteration). @node Putting it all together<2>,Behind the curtain How does our code get optimized?<2>,Examining the generated code<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 putting-it-all-together}@anchor{f2} +@anchor{cp/intro/tutorial04 putting-it-all-together}@anchor{f3} @subsubsection Putting it all together @@ -9480,7 +9488,7 @@ compiler result: 55 @noindent @node Behind the curtain How does our code get optimized?<2>,,Putting it all together<2>,Tutorial part 4 Adding JIT-compilation to a toy interpreter<2> -@anchor{cp/intro/tutorial04 behind-the-curtain-how-does-our-code-get-optimized}@anchor{f3} +@anchor{cp/intro/tutorial04 behind-the-curtain-how-does-our-code-get-optimized}@anchor{f4} @subsubsection Behind the curtain: How does our code get optimized? @@ -9681,7 +9689,7 @@ representation: @code{initial}, @code{instr4} and @code{instr9}. @end menu @node Optimizing away stack manipulation<2>,Elimination of tail recursion<2>,,Behind the curtain How does our code get optimized?<2> -@anchor{cp/intro/tutorial04 optimizing-away-stack-manipulation}@anchor{f4} +@anchor{cp/intro/tutorial04 optimizing-away-stack-manipulation}@anchor{f5} @subsubsection Optimizing away stack manipulation @@ -9961,7 +9969,7 @@ instr9: @noindent @node Elimination of tail recursion<2>,,Optimizing away stack manipulation<2>,Behind the curtain How does our code get optimized?<2> -@anchor{cp/intro/tutorial04 elimination-of-tail-recursion}@anchor{f5} +@anchor{cp/intro/tutorial04 elimination-of-tail-recursion}@anchor{f6} @subsubsection Elimination of tail recursion @@ -10048,7 +10056,7 @@ instr9: @c . @node Topic Reference<2>,,Tutorial<2>,C++ bindings for libgccjit -@anchor{cp/topics/index doc}@anchor{f6}@anchor{cp/topics/index topic-reference}@anchor{f7} +@anchor{cp/topics/index doc}@anchor{f7}@anchor{cp/topics/index topic-reference}@anchor{f8} @section Topic Reference @@ -10132,22 +10140,22 @@ Source Locations @node Compilation contexts<2>,Objects<2>,,Topic Reference<2> -@anchor{cp/topics/contexts compilation-contexts}@anchor{f8}@anchor{cp/topics/contexts doc}@anchor{f9} +@anchor{cp/topics/contexts compilation-contexts}@anchor{f9}@anchor{cp/topics/contexts doc}@anchor{fa} @subsection Compilation contexts @geindex gccjit;;context (C++ class) -@anchor{cp/topics/contexts gccjit context}@anchor{fa} +@anchor{cp/topics/contexts gccjit context}@anchor{fb} @deffn {C++ Class} gccjit::context @end deffn -The top-level of the C++ API is the @pxref{fa,,gccjit;;context} type. +The top-level of the C++ API is the @pxref{fb,,gccjit;;context} type. -A @pxref{fa,,gccjit;;context} instance encapsulates the state of a +A @pxref{fb,,gccjit;;context} instance encapsulates the state of a compilation. You can set up options on it, and add types, functions and code. -Invoking @pxref{d3,,gccjit;;context;;compile()} on it gives you a +Invoking @pxref{d4,,gccjit;;context;;compile()} on it gives you a @pxref{16,,gcc_jit_result *}. It is a thin wrapper around the C API's @pxref{8,,gcc_jit_context *}. @@ -10162,7 +10170,7 @@ It is a thin wrapper around the C API's @pxref{8,,gcc_jit_context *}. @end menu @node Lifetime-management<2>,Thread-safety<2>,,Compilation contexts<2> -@anchor{cp/topics/contexts lifetime-management}@anchor{fb} +@anchor{cp/topics/contexts lifetime-management}@anchor{fc} @subsubsection Lifetime-management @@ -10171,16 +10179,16 @@ have their lifetime bounded by the context they are created within, and cleanup of such objects is done for you when the context is released. @geindex gccjit;;context;;acquire (C++ function) -@anchor{cp/topics/contexts gccjit context acquire}@anchor{cd} +@anchor{cp/topics/contexts gccjit context acquire}@anchor{ce} @deffn {C++ Function} gccjit::context gccjit::context::acquire () -This function acquires a new @pxref{fa,,gccjit;;context} instance, +This function acquires a new @pxref{fb,,gccjit;;context} instance, which is independent of any others that may be present within this process. @end deffn @geindex gccjit;;context;;release (C++ function) -@anchor{cp/topics/contexts gccjit context release}@anchor{cf} +@anchor{cp/topics/contexts gccjit context release}@anchor{d0} @deffn {C++ Function} void gccjit::context::release () This function releases all resources associated with the given context. @@ -10199,7 +10207,7 @@ ctxt.release (); @end deffn @geindex gccjit;;context;;new_child_context (C++ function) -@anchor{cp/topics/contexts gccjit context new_child_context}@anchor{fc} +@anchor{cp/topics/contexts gccjit context new_child_context}@anchor{fd} @deffn {C++ Function} gccjit::context gccjit::context::new_child_context () Given an existing JIT context, create a child context. @@ -10231,16 +10239,16 @@ there will likely be a performance hit for such nesting. @end deffn @node Thread-safety<2>,Error-handling<3>,Lifetime-management<2>,Compilation contexts<2> -@anchor{cp/topics/contexts thread-safety}@anchor{fd} +@anchor{cp/topics/contexts thread-safety}@anchor{fe} @subsubsection Thread-safety -Instances of @pxref{fa,,gccjit;;context} created via -@pxref{cd,,gccjit;;context;;acquire()} are independent from each other: +Instances of @pxref{fb,,gccjit;;context} created via +@pxref{ce,,gccjit;;context;;acquire()} are independent from each other: only one thread may use a given context at once, but multiple threads could each have their own contexts without needing locks. -Contexts created via @pxref{fc,,gccjit;;context;;new_child_context()} are +Contexts created via @pxref{fd,,gccjit;;context;;new_child_context()} are related to their parent context. They can be partitioned by their ultimate ancestor into independent "family trees". Only one thread within a process may use a given "family tree" of such contexts at once, @@ -10248,7 +10256,7 @@ and if you're using multiple threads you should provide your own locking around entire such context partitions. @node Error-handling<3>,Debugging<2>,Thread-safety<2>,Compilation contexts<2> -@anchor{cp/topics/contexts error-handling}@anchor{fe} +@anchor{cp/topics/contexts error-handling}@anchor{ff} @subsubsection Error-handling @@ -10261,10 +10269,10 @@ NULL. You don't have to check everywhere for NULL results, since the API gracefully handles a NULL being passed in for any argument. Errors are printed on stderr and can be queried using -@pxref{ff,,gccjit;;context;;get_first_error()}. +@pxref{100,,gccjit;;context;;get_first_error()}. @geindex gccjit;;context;;get_first_error (C++ function) -@anchor{cp/topics/contexts gccjit context get_first_error__gccjit contextP}@anchor{ff} +@anchor{cp/topics/contexts gccjit context get_first_error__gccjit contextP}@anchor{100} @deffn {C++ Function} const char* gccjit::context::get_first_error (gccjit::context* ctxt) Returns the first error message that occurred on the context. @@ -10276,18 +10284,18 @@ If no errors occurred, this will be NULL. @end deffn @node Debugging<2>,Options<4>,Error-handling<3>,Compilation contexts<2> -@anchor{cp/topics/contexts debugging}@anchor{100} +@anchor{cp/topics/contexts debugging}@anchor{101} @subsubsection Debugging @geindex gccjit;;context;;dump_to_file (C++ function) -@anchor{cp/topics/contexts gccjit context dump_to_file__ssCR i}@anchor{101} +@anchor{cp/topics/contexts gccjit context dump_to_file__ssCR i}@anchor{102} @deffn {C++ Function} void gccjit::context::dump_to_file (const std::string& path, int update_locations) To help with debugging: dump a C-like representation to the given path, describing what's been set up on the context. -If "update_locations" is true, then also set up @pxref{102,,gccjit;;location} +If "update_locations" is true, then also set up @pxref{103,,gccjit;;location} information throughout the context, pointing at the dump file as if it were a source file. This may be of use in conjunction with @code{GCCJIT::BOOL_OPTION_DEBUGINFO} to allow stepping through the @@ -10295,7 +10303,7 @@ code in a debugger. @end deffn @node Options<4>,,Debugging<2>,Compilation contexts<2> -@anchor{cp/topics/contexts options}@anchor{103} +@anchor{cp/topics/contexts options}@anchor{104} @subsubsection Options @@ -10307,12 +10315,12 @@ code in a debugger. @end menu @node String Options<2>,Boolean options<2>,,Options<4> -@anchor{cp/topics/contexts string-options}@anchor{104} +@anchor{cp/topics/contexts string-options}@anchor{105} @subsubsection String Options @geindex gccjit;;context;;set_str_option (C++ function) -@anchor{cp/topics/contexts gccjit context set_str_option__enum cCP}@anchor{105} +@anchor{cp/topics/contexts gccjit context set_str_option__enum cCP}@anchor{106} @deffn {C++ Function} void gccjit::context::set_str_option (enum gcc_jit_str_option, const char* value) Set a string option of the context. @@ -10323,12 +10331,12 @@ meaning. @end deffn @node Boolean options<2>,Integer options<2>,String Options<2>,Options<4> -@anchor{cp/topics/contexts boolean-options}@anchor{106} +@anchor{cp/topics/contexts boolean-options}@anchor{107} @subsubsection Boolean options @geindex gccjit;;context;;set_bool_option (C++ function) -@anchor{cp/topics/contexts gccjit context set_bool_option__enum i}@anchor{d5} +@anchor{cp/topics/contexts gccjit context set_bool_option__enum i}@anchor{d6} @deffn {C++ Function} void gccjit::context::set_bool_option (enum gcc_jit_bool_option, int value) Set a boolean option of the context. @@ -10339,12 +10347,12 @@ meaning. @end deffn @node Integer options<2>,,Boolean options<2>,Options<4> -@anchor{cp/topics/contexts integer-options}@anchor{107} +@anchor{cp/topics/contexts integer-options}@anchor{108} @subsubsection Integer options @geindex gccjit;;context;;set_int_option (C++ function) -@anchor{cp/topics/contexts gccjit context set_int_option__enum i}@anchor{d6} +@anchor{cp/topics/contexts gccjit context set_int_option__enum i}@anchor{d7} @deffn {C++ Function} void gccjit::context::set_int_option (enum gcc_jit_int_option, int value) Set an integer option of the context. @@ -10372,18 +10380,18 @@ meaning. @c . @node Objects<2>,Types<2>,Compilation contexts<2>,Topic Reference<2> -@anchor{cp/topics/objects objects}@anchor{108}@anchor{cp/topics/objects doc}@anchor{109} +@anchor{cp/topics/objects objects}@anchor{109}@anchor{cp/topics/objects doc}@anchor{10a} @subsection Objects @geindex gccjit;;object (C++ class) -@anchor{cp/topics/objects gccjit object}@anchor{10a} +@anchor{cp/topics/objects gccjit object}@anchor{10b} @deffn {C++ Class} gccjit::object @end deffn Almost every entity in the API (with the exception of -@pxref{fa,,gccjit;;context} and @pxref{16,,gcc_jit_result *}) is a -"contextual" object, a @pxref{10a,,gccjit;;object}. +@pxref{fb,,gccjit;;context} and @pxref{16,,gcc_jit_result *}) is a +"contextual" object, a @pxref{10b,,gccjit;;object}. A JIT object: @@ -10393,7 +10401,7 @@ A JIT object: @itemize * @item -is associated with a @pxref{fa,,gccjit;;context}. +is associated with a @pxref{fb,,gccjit;;context}. @item is automatically cleaned up for you when its context is released so @@ -10419,17 +10427,17 @@ The C++ class hierarchy within the @code{gccjit} namespace looks like this: @noindent -The @pxref{10a,,gccjit;;object} base class has the following operations: +The @pxref{10b,,gccjit;;object} base class has the following operations: @geindex gccjit;;object;;get_context (C++ function) -@anchor{cp/topics/objects gccjit object get_contextC}@anchor{10b} +@anchor{cp/topics/objects gccjit object get_contextC}@anchor{10c} @deffn {C++ Function} gccjit::context gccjit::object::get_context () const Which context is the obj within? @end deffn @geindex gccjit;;object;;get_debug_string (C++ function) -@anchor{cp/topics/objects gccjit object get_debug_stringC}@anchor{d0} +@anchor{cp/topics/objects gccjit object get_debug_stringC}@anchor{d1} @deffn {C++ Function} std::string gccjit::object::get_debug_string () const Generate a human-readable description for the given object. @@ -10469,16 +10477,16 @@ obj: 4.0 * (float)i @c . @node Types<2>,Expressions<2>,Objects<2>,Topic Reference<2> -@anchor{cp/topics/types doc}@anchor{10c}@anchor{cp/topics/types types}@anchor{10d} +@anchor{cp/topics/types doc}@anchor{10d}@anchor{cp/topics/types types}@anchor{10e} @subsection Types @geindex gccjit;;type (C++ class) -@anchor{cp/topics/types gccjit type}@anchor{10e} +@anchor{cp/topics/types gccjit type}@anchor{10f} @deffn {C++ Class} gccjit::type gccjit::type represents a type within the library. It is a subclass -of @pxref{10a,,gccjit;;object}. +of @pxref{10b,,gccjit;;object}. @end deffn Types can be created in several ways: @@ -10488,7 +10496,7 @@ Types can be created in several ways: @item fundamental types can be accessed using -@pxref{ce,,gccjit;;context;;get_type()}: +@pxref{cf,,gccjit;;context;;get_type()}: @example gccjit::type int_type = ctxt.get_type (GCC_JIT_TYPE_INT); @@ -10508,7 +10516,7 @@ See @pxref{b,,gcc_jit_context_get_type()} for the available types. @item derived types can be accessed by using functions such as -@pxref{10f,,gccjit;;type;;get_pointer()} and @pxref{110,,gccjit;;type;;get_const()}: +@pxref{110,,gccjit;;type;;get_pointer()} and @pxref{111,,gccjit;;type;;get_const()}: @example gccjit::type const_int_star = int_type.get_const ().get_pointer (); @@ -10529,12 +10537,12 @@ by creating structures (see below). @end menu @node Standard types<2>,Pointers const and volatile<2>,,Types<2> -@anchor{cp/topics/types standard-types}@anchor{111} +@anchor{cp/topics/types standard-types}@anchor{112} @subsubsection Standard types @geindex gccjit;;context;;get_type (C++ function) -@anchor{cp/topics/types gccjit context get_type__enum}@anchor{ce} +@anchor{cp/topics/types gccjit context get_type__enum}@anchor{cf} @deffn {C++ Function} gccjit::type gccjit::context::get_type (enum gcc_jit_types) Access a specific type. This is a thin wrapper around @@ -10542,14 +10550,14 @@ Access a specific type. This is a thin wrapper around @end deffn @geindex gccjit;;context;;get_int_type (C++ function) -@anchor{cp/topics/types gccjit context get_int_type__s i}@anchor{112} +@anchor{cp/topics/types gccjit context get_int_type__s i}@anchor{113} @deffn {C++ Function} gccjit::type gccjit::context::get_int_type (size_t num_bytes, int is_signed) Access the integer type of the given size. @end deffn @geindex gccjit;;context;;get_int_type (C++ function) -@anchor{cp/topics/types gccjit context get_int_type T}@anchor{113} +@anchor{cp/topics/types gccjit context get_int_type T}@anchor{114} @deffn {C++ Function} gccjit::type gccjit::context::get_int_type () Access the given integer type. For example, you could map the @@ -10563,12 +10571,12 @@ gccjit::type t = ctxt.get_int_type (); @end deffn @node Pointers const and volatile<2>,Structures and unions<2>,Standard types<2>,Types<2> -@anchor{cp/topics/types pointers-const-and-volatile}@anchor{114} +@anchor{cp/topics/types pointers-const-and-volatile}@anchor{115} @subsubsection Pointers, @cite{const}, and @cite{volatile} @geindex gccjit;;type;;get_pointer (C++ function) -@anchor{cp/topics/types gccjit type get_pointer}@anchor{10f} +@anchor{cp/topics/types gccjit type get_pointer}@anchor{110} @deffn {C++ Function} gccjit::type gccjit::type::get_pointer () Given type "T", get type "T*". @@ -10577,21 +10585,21 @@ Given type "T", get type "T*". @c FIXME: get_const doesn't seem to exist @geindex gccjit;;type;;get_const (C++ function) -@anchor{cp/topics/types gccjit type get_const}@anchor{110} +@anchor{cp/topics/types gccjit type get_const}@anchor{111} @deffn {C++ Function} gccjit::type gccjit::type::get_const () Given type "T", get type "const T". @end deffn @geindex gccjit;;type;;get_volatile (C++ function) -@anchor{cp/topics/types gccjit type get_volatile}@anchor{115} +@anchor{cp/topics/types gccjit type get_volatile}@anchor{116} @deffn {C++ Function} gccjit::type gccjit::type::get_volatile () Given type "T", get type "volatile T". @end deffn @geindex gccjit;;context;;new_array_type (C++ function) -@anchor{cp/topics/types gccjit context new_array_type__gccjit type i gccjit location}@anchor{116} +@anchor{cp/topics/types gccjit context new_array_type__gccjit type i gccjit location}@anchor{117} @deffn {C++ Function} gccjit::type gccjit::context::new_array_type (gccjit::type element_type, int num_elements, gccjit::location loc) Given type "T", get type "T[N]" (for a constant N). @@ -10599,31 +10607,31 @@ Param "loc" is optional. @end deffn @node Structures and unions<2>,,Pointers const and volatile<2>,Types<2> -@anchor{cp/topics/types structures-and-unions}@anchor{117} +@anchor{cp/topics/types structures-and-unions}@anchor{118} @subsubsection Structures and unions @geindex gccjit;;struct_ (C++ class) -@anchor{cp/topics/types gccjit struct_}@anchor{118} +@anchor{cp/topics/types gccjit struct_}@anchor{119} @deffn {C++ Class} gccjit::struct_ @end deffn A compound type analagous to a C @cite{struct}. -@pxref{118,,gccjit;;struct_} is a subclass of @pxref{10e,,gccjit;;type} (and thus -of @pxref{10a,,gccjit;;object} in turn). +@pxref{119,,gccjit;;struct_} is a subclass of @pxref{10f,,gccjit;;type} (and thus +of @pxref{10b,,gccjit;;object} in turn). @geindex gccjit;;field (C++ class) -@anchor{cp/topics/types gccjit field}@anchor{119} +@anchor{cp/topics/types gccjit field}@anchor{11a} @deffn {C++ Class} gccjit::field @end deffn -A field within a @pxref{118,,gccjit;;struct_}. +A field within a @pxref{119,,gccjit;;struct_}. -@pxref{119,,gccjit;;field} is a subclass of @pxref{10a,,gccjit;;object}. +@pxref{11a,,gccjit;;field} is a subclass of @pxref{10b,,gccjit;;object}. -You can model C @cite{struct} types by creating @pxref{118,,gccjit;;struct_} and -@pxref{119,,gccjit;;field} instances, in either order: +You can model C @cite{struct} types by creating @pxref{119,,gccjit;;struct_} and +@pxref{11a,,gccjit;;field} instances, in either order: @itemize * @@ -10679,14 +10687,14 @@ node.set_fields (fields); @c FIXME: the above API doesn't seem to exist yet @geindex gccjit;;context;;new_field (C++ function) -@anchor{cp/topics/types gccjit context new_field__gccjit type cCP gccjit location}@anchor{11a} +@anchor{cp/topics/types gccjit context new_field__gccjit type cCP gccjit location}@anchor{11b} @deffn {C++ Function} gccjit::field gccjit::context::new_field (gccjit::type type, const char* name, gccjit::location loc) Construct a new field, with the given type and name. @end deffn @geindex gccjit;;context;;new_struct_type (C++ function) -@anchor{cp/topics/types gccjit context new_struct_type__ssCR std vector field R gccjit location}@anchor{11b} +@anchor{cp/topics/types gccjit context new_struct_type__ssCR std vector field R gccjit location}@anchor{11c} @deffn {C++ Function} gccjit::struct_ gccjit::context::new_struct_type (const std::string& name, std::vector& fields, gccjit::location loc) @quotation @@ -10696,7 +10704,7 @@ Construct a new struct type, with the given name and fields. @end deffn @geindex gccjit;;context;;new_opaque_struct (C++ function) -@anchor{cp/topics/types gccjit context new_opaque_struct__ssCR gccjit location}@anchor{11c} +@anchor{cp/topics/types gccjit context new_opaque_struct__ssCR gccjit location}@anchor{11d} @deffn {C++ Function} gccjit::struct_ gccjit::context::new_opaque_struct (const std::string& name, gccjit::location loc) Construct a new struct type, with the given name, but without @@ -10723,7 +10731,7 @@ size of the struct is not known), or later specified using @c . @node Expressions<2>,Creating and using functions<2>,Types<2>,Topic Reference<2> -@anchor{cp/topics/expressions expressions}@anchor{11d}@anchor{cp/topics/expressions doc}@anchor{11e} +@anchor{cp/topics/expressions expressions}@anchor{11e}@anchor{cp/topics/expressions doc}@anchor{11f} @subsection Expressions @@ -10749,17 +10757,17 @@ Lvalues @node Rvalues<2>,Lvalues<2>,,Expressions<2> -@anchor{cp/topics/expressions rvalues}@anchor{11f} +@anchor{cp/topics/expressions rvalues}@anchor{120} @subsubsection Rvalues @geindex gccjit;;rvalue (C++ class) -@anchor{cp/topics/expressions gccjit rvalue}@anchor{120} +@anchor{cp/topics/expressions gccjit rvalue}@anchor{121} @deffn {C++ Class} gccjit::rvalue @end deffn -A @pxref{120,,gccjit;;rvalue} is an expression that can be computed. It is a -subclass of @pxref{10a,,gccjit;;object}, and is a thin wrapper around +A @pxref{121,,gccjit;;rvalue} is an expression that can be computed. It is a +subclass of @pxref{10b,,gccjit;;object}, and is a thin wrapper around @pxref{13,,gcc_jit_rvalue *} from the C API. It can be simple, e.g.: @@ -10805,7 +10813,7 @@ Every rvalue has an associated type, and the API will check to ensure that types match up correctly (otherwise the context will emit an error). @geindex gccjit;;rvalue;;get_type (C++ function) -@anchor{cp/topics/expressions gccjit rvalue get_type}@anchor{121} +@anchor{cp/topics/expressions gccjit rvalue get_type}@anchor{122} @deffn {C++ Function} gccjit::type gccjit::rvalue::get_type () Get the type of this rvalue. @@ -10822,20 +10830,28 @@ Get the type of this rvalue. @end menu @node Simple expressions<2>,Unary Operations<2>,,Rvalues<2> -@anchor{cp/topics/expressions simple-expressions}@anchor{122} +@anchor{cp/topics/expressions simple-expressions}@anchor{123} @subsubsection Simple expressions @geindex gccjit;;context;;new_rvalue (C++ function) -@anchor{cp/topics/expressions gccjit context new_rvalue__gccjit type iC}@anchor{e2} +@anchor{cp/topics/expressions gccjit context new_rvalue__gccjit type iC}@anchor{e3} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_rvalue (gccjit::type numeric_type, int value) const Given a numeric type (integer or floating point), build an rvalue for the given constant @code{int} value. @end deffn +@geindex gccjit;;context;;new_rvalue (C++ function) +@anchor{cp/topics/expressions gccjit context new_rvalue__gccjit type lC}@anchor{124} +@deffn {C++ Function} gccjit::rvalue gccjit::context::new_rvalue (gccjit::type numeric_type, long value) const + +Given a numeric type (integer or floating point), build an rvalue for +the given constant @code{long} value. +@end deffn + @geindex gccjit;;context;;zero (C++ function) -@anchor{cp/topics/expressions gccjit context zero__gccjit typeC}@anchor{de} +@anchor{cp/topics/expressions gccjit context zero__gccjit typeC}@anchor{df} @deffn {C++ Function} gccjit::rvalue gccjit::context::zero (gccjit::type numeric_type) const Given a numeric type (integer or floating point), get the rvalue for @@ -10849,7 +10865,7 @@ ctxt.new_rvalue (numeric_type, 0) @end deffn @geindex gccjit;;context;;one (C++ function) -@anchor{cp/topics/expressions gccjit context one__gccjit typeC}@anchor{123} +@anchor{cp/topics/expressions gccjit context one__gccjit typeC}@anchor{125} @deffn {C++ Function} gccjit::rvalue gccjit::context::one (gccjit::type numeric_type) const Given a numeric type (integer or floating point), get the rvalue for @@ -10863,22 +10879,22 @@ ctxt.new_rvalue (numeric_type, 1) @end deffn @geindex gccjit;;context;;new_rvalue (C++ function) -@anchor{cp/topics/expressions gccjit context new_rvalue__gccjit type doubleC}@anchor{124} +@anchor{cp/topics/expressions gccjit context new_rvalue__gccjit type doubleC}@anchor{126} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_rvalue (gccjit::type numeric_type, double value) const Given a numeric type (integer or floating point), build an rvalue for -the given constant value. +the given constant @code{double} value. @end deffn @geindex gccjit;;context;;new_rvalue (C++ function) -@anchor{cp/topics/expressions gccjit context new_rvalue__gccjit type voidPC}@anchor{125} +@anchor{cp/topics/expressions gccjit context new_rvalue__gccjit type voidPC}@anchor{127} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_rvalue (gccjit::type pointer_type, void* value) const Given a pointer type, build an rvalue for the given address. @end deffn @geindex gccjit;;context;;new_rvalue (C++ function) -@anchor{cp/topics/expressions gccjit context new_rvalue__ssCRC}@anchor{126} +@anchor{cp/topics/expressions gccjit context new_rvalue__ssCRC}@anchor{128} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_rvalue (const std::string& value) const Generate an rvalue of type @code{GCC_JIT_TYPE_CONST_CHAR_PTR} for @@ -10886,12 +10902,12 @@ the given string. This is akin to a string literal. @end deffn @node Unary Operations<2>,Binary Operations<2>,Simple expressions<2>,Rvalues<2> -@anchor{cp/topics/expressions unary-operations}@anchor{127} +@anchor{cp/topics/expressions unary-operations}@anchor{129} @subsubsection Unary Operations @geindex gccjit;;context;;new_unary_op (C++ function) -@anchor{cp/topics/expressions gccjit context new_unary_op__enum gccjit type gccjit rvalue gccjit location}@anchor{128} +@anchor{cp/topics/expressions gccjit context new_unary_op__enum gccjit type gccjit rvalue gccjit location}@anchor{12a} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_unary_op (enum gcc_jit_unary_op, gccjit::type result_type, gccjit::rvalue rvalue, gccjit::location loc) Build a unary operation out of an input rvalue. @@ -10899,7 +10915,7 @@ Build a unary operation out of an input rvalue. Parameter @code{loc} is optional. This is a thin wrapper around the C API's -@pxref{83,,gcc_jit_context_new_unary_op()} and the available unary +@pxref{84,,gcc_jit_context_new_unary_op()} and the available unary operations are documented there. @end deffn @@ -10907,7 +10923,7 @@ There are shorter ways to spell the various specific kinds of unary operation: @geindex gccjit;;context;;new_minus (C++ function) -@anchor{cp/topics/expressions gccjit context new_minus__gccjit type gccjit rvalue gccjit location}@anchor{129} +@anchor{cp/topics/expressions gccjit context new_minus__gccjit type gccjit rvalue gccjit location}@anchor{12b} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_minus (gccjit::type result_type, gccjit::rvalue a, gccjit::location loc) Negate an arithmetic value; for example: @@ -10928,7 +10944,7 @@ builds the equivalent of this C expression: @end deffn @geindex new_bitwise_negate (C++ function) -@anchor{cp/topics/expressions new_bitwise_negate__gccjit type gccjit rvalue gccjit location}@anchor{12a} +@anchor{cp/topics/expressions new_bitwise_negate__gccjit type gccjit rvalue gccjit location}@anchor{12c} @deffn {C++ Function} gccjit::rvalue new_bitwise_negate (gccjit::type result_type, gccjit::rvalue a, gccjit::location loc) Bitwise negation of an integer value (one's complement); for example: @@ -10949,7 +10965,7 @@ builds the equivalent of this C expression: @end deffn @geindex new_logical_negate (C++ function) -@anchor{cp/topics/expressions new_logical_negate__gccjit type gccjit rvalue gccjit location}@anchor{12b} +@anchor{cp/topics/expressions new_logical_negate__gccjit type gccjit rvalue gccjit location}@anchor{12d} @deffn {C++ Function} gccjit::rvalue new_logical_negate (gccjit::type result_type, gccjit::rvalue a, gccjit::location loc) Logical negation of an arithmetic or pointer value; for example: @@ -10972,7 +10988,7 @@ builds the equivalent of this C expression: The most concise way to spell them is with overloaded operators: @geindex operator- (C++ function) -@anchor{cp/topics/expressions sub-operator__gccjit rvalue}@anchor{12c} +@anchor{cp/topics/expressions sub-operator__gccjit rvalue}@anchor{12e} @deffn {C++ Function} gccjit::rvalue operator- (gccjit::rvalue a) @example @@ -10983,7 +10999,7 @@ gccjit::rvalue negpi = -pi; @end deffn @geindex operator~ (C++ function) -@anchor{cp/topics/expressions inv-operator__gccjit rvalue}@anchor{12d} +@anchor{cp/topics/expressions inv-operator__gccjit rvalue}@anchor{12f} @deffn {C++ Function} gccjit::rvalue operator~ (gccjit::rvalue a) @example @@ -10994,7 +11010,7 @@ gccjit::rvalue mask = ~a; @end deffn @geindex operator! (C++ function) -@anchor{cp/topics/expressions not-operator__gccjit rvalue}@anchor{12e} +@anchor{cp/topics/expressions not-operator__gccjit rvalue}@anchor{130} @deffn {C++ Function} gccjit::rvalue operator! (gccjit::rvalue a) @example @@ -11005,12 +11021,12 @@ gccjit::rvalue guard = !cond; @end deffn @node Binary Operations<2>,Comparisons<2>,Unary Operations<2>,Rvalues<2> -@anchor{cp/topics/expressions binary-operations}@anchor{12f} +@anchor{cp/topics/expressions binary-operations}@anchor{131} @subsubsection Binary Operations @geindex gccjit;;context;;new_binary_op (C++ function) -@anchor{cp/topics/expressions gccjit context new_binary_op__enum gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{d2} +@anchor{cp/topics/expressions gccjit context new_binary_op__enum gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{d3} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_binary_op (enum gcc_jit_binary_op, gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) Build a binary operation out of two constituent rvalues. @@ -11026,59 +11042,59 @@ There are shorter ways to spell the various specific kinds of binary operation: @geindex gccjit;;context;;new_plus (C++ function) -@anchor{cp/topics/expressions gccjit context new_plus__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{130} +@anchor{cp/topics/expressions gccjit context new_plus__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{132} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_plus (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_minus (C++ function) -@anchor{cp/topics/expressions gccjit context new_minus__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{131} +@anchor{cp/topics/expressions gccjit context new_minus__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{133} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_minus (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_mult (C++ function) -@anchor{cp/topics/expressions gccjit context new_mult__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{132} +@anchor{cp/topics/expressions gccjit context new_mult__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{134} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_mult (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_divide (C++ function) -@anchor{cp/topics/expressions gccjit context new_divide__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{133} +@anchor{cp/topics/expressions gccjit context new_divide__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{135} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_divide (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_modulo (C++ function) -@anchor{cp/topics/expressions gccjit context new_modulo__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{134} +@anchor{cp/topics/expressions gccjit context new_modulo__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{136} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_modulo (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_bitwise_and (C++ function) -@anchor{cp/topics/expressions gccjit context new_bitwise_and__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{135} +@anchor{cp/topics/expressions gccjit context new_bitwise_and__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{137} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_bitwise_and (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_bitwise_xor (C++ function) -@anchor{cp/topics/expressions gccjit context new_bitwise_xor__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{136} +@anchor{cp/topics/expressions gccjit context new_bitwise_xor__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{138} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_bitwise_xor (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_bitwise_or (C++ function) -@anchor{cp/topics/expressions gccjit context new_bitwise_or__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{137} +@anchor{cp/topics/expressions gccjit context new_bitwise_or__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{139} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_bitwise_or (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_logical_and (C++ function) -@anchor{cp/topics/expressions gccjit context new_logical_and__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{138} +@anchor{cp/topics/expressions gccjit context new_logical_and__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{13a} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_logical_and (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_logical_or (C++ function) -@anchor{cp/topics/expressions gccjit context new_logical_or__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{139} +@anchor{cp/topics/expressions gccjit context new_logical_or__gccjit type gccjit rvalue gccjit rvalue gccjit location}@anchor{13b} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_logical_or (gccjit::type result_type, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn The most concise way to spell them is with overloaded operators: @geindex operator+ (C++ function) -@anchor{cp/topics/expressions add-operator__gccjit rvalue gccjit rvalue}@anchor{13a} +@anchor{cp/topics/expressions add-operator__gccjit rvalue gccjit rvalue}@anchor{13c} @deffn {C++ Function} gccjit::rvalue operator+ (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11089,7 +11105,7 @@ gccjit::rvalue sum = a + b; @end deffn @geindex operator- (C++ function) -@anchor{cp/topics/expressions sub-operator__gccjit rvalue gccjit rvalue}@anchor{13b} +@anchor{cp/topics/expressions sub-operator__gccjit rvalue gccjit rvalue}@anchor{13d} @deffn {C++ Function} gccjit::rvalue operator- (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11100,7 +11116,7 @@ gccjit::rvalue diff = a - b; @end deffn @geindex operator* (C++ function) -@anchor{cp/topics/expressions mul-operator__gccjit rvalue gccjit rvalue}@anchor{13c} +@anchor{cp/topics/expressions mul-operator__gccjit rvalue gccjit rvalue}@anchor{13e} @deffn {C++ Function} gccjit::rvalue operator* (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11111,7 +11127,7 @@ gccjit::rvalue prod = a * b; @end deffn @geindex operator/ (C++ function) -@anchor{cp/topics/expressions div-operator__gccjit rvalue gccjit rvalue}@anchor{13d} +@anchor{cp/topics/expressions div-operator__gccjit rvalue gccjit rvalue}@anchor{13f} @deffn {C++ Function} gccjit::rvalue operator/ (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11122,7 +11138,7 @@ gccjit::rvalue result = a / b; @end deffn @geindex operator% (C++ function) -@anchor{cp/topics/expressions mod-operator__gccjit rvalue gccjit rvalue}@anchor{13e} +@anchor{cp/topics/expressions mod-operator__gccjit rvalue gccjit rvalue}@anchor{140} @deffn {C++ Function} gccjit::rvalue operator% (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11133,7 +11149,7 @@ gccjit::rvalue mod = a % b; @end deffn @geindex operator& (C++ function) -@anchor{cp/topics/expressions and-operator__gccjit rvalue gccjit rvalue}@anchor{13f} +@anchor{cp/topics/expressions and-operator__gccjit rvalue gccjit rvalue}@anchor{141} @deffn {C++ Function} gccjit::rvalue operator& (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11144,7 +11160,7 @@ gccjit::rvalue x = a & b; @end deffn @geindex operator^ (C++ function) -@anchor{cp/topics/expressions xor-operator__gccjit rvalue gccjit rvalue}@anchor{140} +@anchor{cp/topics/expressions xor-operator__gccjit rvalue gccjit rvalue}@anchor{142} @deffn {C++ Function} gccjit::rvalue operator^ (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11155,7 +11171,7 @@ gccjit::rvalue x = a ^ b; @end deffn @geindex operator| (C++ function) -@anchor{cp/topics/expressions or-operator__gccjit rvalue gccjit rvalue}@anchor{141} +@anchor{cp/topics/expressions or-operator__gccjit rvalue gccjit rvalue}@anchor{143} @deffn {C++ Function} gccjit::rvalue operator| (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11166,7 +11182,7 @@ gccjit::rvalue x = a | b; @end deffn @geindex operator&& (C++ function) -@anchor{cp/topics/expressions sand-operator__gccjit rvalue gccjit rvalue}@anchor{142} +@anchor{cp/topics/expressions sand-operator__gccjit rvalue gccjit rvalue}@anchor{144} @deffn {C++ Function} gccjit::rvalue operator&& (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11177,7 +11193,7 @@ gccjit::rvalue cond = a && b; @end deffn @geindex operator|| (C++ function) -@anchor{cp/topics/expressions sor-operator__gccjit rvalue gccjit rvalue}@anchor{143} +@anchor{cp/topics/expressions sor-operator__gccjit rvalue gccjit rvalue}@anchor{145} @deffn {C++ Function} gccjit::rvalue operator|| (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11200,12 +11216,12 @@ gccjit::rvalue discriminant = (b * b) - (four * a * c); @end quotation @node Comparisons<2>,Function calls<2>,Binary Operations<2>,Rvalues<2> -@anchor{cp/topics/expressions comparisons}@anchor{144} +@anchor{cp/topics/expressions comparisons}@anchor{146} @subsubsection Comparisons @geindex gccjit;;context;;new_comparison (C++ function) -@anchor{cp/topics/expressions gccjit context new_comparison__enum gccjit rvalue gccjit rvalue gccjit location}@anchor{df} +@anchor{cp/topics/expressions gccjit context new_comparison__enum gccjit rvalue gccjit rvalue gccjit location}@anchor{e0} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_comparison (enum gcc_jit_comparison, gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) Build a boolean rvalue out of the comparison of two other rvalues. @@ -11221,39 +11237,39 @@ There are shorter ways to spell the various specific kinds of binary operation: @geindex gccjit;;context;;new_eq (C++ function) -@anchor{cp/topics/expressions gccjit context new_eq__gccjit rvalue gccjit rvalue gccjit location}@anchor{145} +@anchor{cp/topics/expressions gccjit context new_eq__gccjit rvalue gccjit rvalue gccjit location}@anchor{147} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_eq (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_ne (C++ function) -@anchor{cp/topics/expressions gccjit context new_ne__gccjit rvalue gccjit rvalue gccjit location}@anchor{146} +@anchor{cp/topics/expressions gccjit context new_ne__gccjit rvalue gccjit rvalue gccjit location}@anchor{148} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_ne (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_lt (C++ function) -@anchor{cp/topics/expressions gccjit context new_lt__gccjit rvalue gccjit rvalue gccjit location}@anchor{147} +@anchor{cp/topics/expressions gccjit context new_lt__gccjit rvalue gccjit rvalue gccjit location}@anchor{149} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_lt (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_le (C++ function) -@anchor{cp/topics/expressions gccjit context new_le__gccjit rvalue gccjit rvalue gccjit location}@anchor{148} +@anchor{cp/topics/expressions gccjit context new_le__gccjit rvalue gccjit rvalue gccjit location}@anchor{14a} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_le (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_gt (C++ function) -@anchor{cp/topics/expressions gccjit context new_gt__gccjit rvalue gccjit rvalue gccjit location}@anchor{149} +@anchor{cp/topics/expressions gccjit context new_gt__gccjit rvalue gccjit rvalue gccjit location}@anchor{14b} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_gt (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn @geindex gccjit;;context;;new_ge (C++ function) -@anchor{cp/topics/expressions gccjit context new_ge__gccjit rvalue gccjit rvalue gccjit location}@anchor{14a} +@anchor{cp/topics/expressions gccjit context new_ge__gccjit rvalue gccjit rvalue gccjit location}@anchor{14c} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_ge (gccjit::rvalue a, gccjit::rvalue b, gccjit::location loc) @end deffn The most concise way to spell them is with overloaded operators: @geindex operator== (C++ function) -@anchor{cp/topics/expressions eq-operator__gccjit rvalue gccjit rvalue}@anchor{14b} +@anchor{cp/topics/expressions eq-operator__gccjit rvalue gccjit rvalue}@anchor{14d} @deffn {C++ Function} gccjit::rvalue operator== (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11264,7 +11280,7 @@ gccjit::rvalue cond = (a == ctxt.zero (t_int)); @end deffn @geindex operator!= (C++ function) -@anchor{cp/topics/expressions neq-operator__gccjit rvalue gccjit rvalue}@anchor{14c} +@anchor{cp/topics/expressions neq-operator__gccjit rvalue gccjit rvalue}@anchor{14e} @deffn {C++ Function} gccjit::rvalue operator!= (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11275,7 +11291,7 @@ gccjit::rvalue cond = (i != j); @end deffn @geindex operator< (C++ function) -@anchor{cp/topics/expressions lt-operator__gccjit rvalue gccjit rvalue}@anchor{14d} +@anchor{cp/topics/expressions lt-operator__gccjit rvalue gccjit rvalue}@anchor{14f} @deffn {C++ Function} gccjit::rvalue operator< (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11286,7 +11302,7 @@ gccjit::rvalue cond = i < n; @end deffn @geindex operator<= (C++ function) -@anchor{cp/topics/expressions lte-operator__gccjit rvalue gccjit rvalue}@anchor{14e} +@anchor{cp/topics/expressions lte-operator__gccjit rvalue gccjit rvalue}@anchor{150} @deffn {C++ Function} gccjit::rvalue operator<= (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11297,7 +11313,7 @@ gccjit::rvalue cond = i <= n; @end deffn @geindex operator> (C++ function) -@anchor{cp/topics/expressions gt-operator__gccjit rvalue gccjit rvalue}@anchor{14f} +@anchor{cp/topics/expressions gt-operator__gccjit rvalue gccjit rvalue}@anchor{151} @deffn {C++ Function} gccjit::rvalue operator> (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11308,7 +11324,7 @@ gccjit::rvalue cond = (ch > limit); @end deffn @geindex operator>= (C++ function) -@anchor{cp/topics/expressions gte-operator__gccjit rvalue gccjit rvalue}@anchor{150} +@anchor{cp/topics/expressions gte-operator__gccjit rvalue gccjit rvalue}@anchor{152} @deffn {C++ Function} gccjit::rvalue operator>= (gccjit::rvalue a, gccjit::rvalue b) @example @@ -11321,12 +11337,12 @@ gccjit::rvalue cond = (score >= ctxt.new_rvalue (t_int, 100)); @c TODO: beyond this point @node Function calls<2>,Type-coercion<2>,Comparisons<2>,Rvalues<2> -@anchor{cp/topics/expressions function-calls}@anchor{151} +@anchor{cp/topics/expressions function-calls}@anchor{153} @subsubsection Function calls @geindex gcc_jit_context_new_call (C++ function) -@anchor{cp/topics/expressions gcc_jit_context_new_call__gcc_jit_contextP gcc_jit_locationP gcc_jit_functionP i gcc_jit_rvaluePP}@anchor{152} +@anchor{cp/topics/expressions gcc_jit_context_new_call__gcc_jit_contextP gcc_jit_locationP gcc_jit_functionP i gcc_jit_rvaluePP}@anchor{154} @deffn {C++ Function} gcc_jit_rvalue* gcc_jit_context_new_call (gcc_jit_context* ctxt, gcc_jit_location* loc, gcc_jit_function* func, int numargs, gcc_jit_rvalue** args) Given a function and the given table of argument rvalues, construct a @@ -11335,14 +11351,14 @@ call to the function, with the result as an rvalue. @cartouche @quotation Note @code{gccjit::context::new_call()} merely builds a -@pxref{120,,gccjit;;rvalue} i.e. an expression that can be evaluated, +@pxref{121,,gccjit;;rvalue} i.e. an expression that can be evaluated, perhaps as part of a more complicated expression. The call @emph{won't} happen unless you add a statement to a function that evaluates the expression. For example, if you want to call a function and discard the result (or to call a function with @code{void} return type), use -@pxref{153,,gccjit;;block;;add_eval()}: +@pxref{155,,gccjit;;block;;add_eval()}: @example /* Add "(void)printf (arg0, arg1);". */ @@ -11355,12 +11371,12 @@ block.add_eval (ctxt.new_call (printf_func, arg0, arg1)); @end deffn @node Type-coercion<2>,,Function calls<2>,Rvalues<2> -@anchor{cp/topics/expressions type-coercion}@anchor{154} +@anchor{cp/topics/expressions type-coercion}@anchor{156} @subsubsection Type-coercion @geindex gccjit;;context;;new_cast (C++ function) -@anchor{cp/topics/expressions gccjit context new_cast__gccjit rvalue gccjit type gccjit location}@anchor{155} +@anchor{cp/topics/expressions gccjit context new_cast__gccjit rvalue gccjit type gccjit location}@anchor{157} @deffn {C++ Function} gccjit::rvalue gccjit::context::new_cast (gccjit::rvalue rvalue, gccjit::type type, gccjit::location loc) Given an rvalue of T, construct another rvalue of another type. @@ -11385,24 +11401,24 @@ P* <-> Q*, for pointer types P and Q @end deffn @node Lvalues<2>,Working with pointers structs and unions<2>,Rvalues<2>,Expressions<2> -@anchor{cp/topics/expressions lvalues}@anchor{156} +@anchor{cp/topics/expressions lvalues}@anchor{158} @subsubsection Lvalues @geindex gccjit;;lvalue (C++ class) -@anchor{cp/topics/expressions gccjit lvalue}@anchor{157} +@anchor{cp/topics/expressions gccjit lvalue}@anchor{159} @deffn {C++ Class} gccjit::lvalue @end deffn An lvalue is something that can of the @emph{left}-hand side of an assignment: a storage area (such as a variable). It is a subclass of -@pxref{120,,gccjit;;rvalue}, where the rvalue is computed by reading from the +@pxref{121,,gccjit;;rvalue}, where the rvalue is computed by reading from the storage area. It iss a thin wrapper around @pxref{24,,gcc_jit_lvalue *} from the C API. @geindex gccjit;;lvalue;;get_address (C++ function) -@anchor{cp/topics/expressions gccjit lvalue get_address__gccjit location}@anchor{158} +@anchor{cp/topics/expressions gccjit lvalue get_address__gccjit location}@anchor{15a} @deffn {C++ Function} gccjit::rvalue gccjit::lvalue::get_address (gccjit::location loc) Take the address of an lvalue; analogous to: @@ -11424,24 +11440,24 @@ Parameter "loc" is optional. @end menu @node Global variables<2>,,,Lvalues<2> -@anchor{cp/topics/expressions global-variables}@anchor{159} +@anchor{cp/topics/expressions global-variables}@anchor{15b} @subsubsection Global variables @geindex gccjit;;context;;new_global (C++ function) -@anchor{cp/topics/expressions gccjit context new_global__gccjit type cCP gccjit location}@anchor{15a} +@anchor{cp/topics/expressions gccjit context new_global__gccjit type cCP gccjit location}@anchor{15c} @deffn {C++ Function} gccjit::lvalue gccjit::context::new_global (gccjit::type type, const char* name, gccjit::location loc) Add a new global variable of the given type and name to the context. @end deffn @node Working with pointers structs and unions<2>,,Lvalues<2>,Expressions<2> -@anchor{cp/topics/expressions working-with-pointers-structs-and-unions}@anchor{15b} +@anchor{cp/topics/expressions working-with-pointers-structs-and-unions}@anchor{15d} @subsubsection Working with pointers, structs and unions @geindex gccjit;;rvalue;;dereference (C++ function) -@anchor{cp/topics/expressions gccjit rvalue dereference__gccjit location}@anchor{15c} +@anchor{cp/topics/expressions gccjit rvalue dereference__gccjit location}@anchor{15e} @deffn {C++ Function} gccjit::lvalue gccjit::rvalue::dereference (gccjit::location loc) Given an rvalue of pointer type @code{T *}, dereferencing the pointer, @@ -11474,7 +11490,7 @@ gccjit::lvalue content = *ptr; Field access is provided separately for both lvalues and rvalues: @geindex gccjit;;lvalue;;access_field (C++ function) -@anchor{cp/topics/expressions gccjit lvalue access_field__gccjit field gccjit location}@anchor{15d} +@anchor{cp/topics/expressions gccjit lvalue access_field__gccjit field gccjit location}@anchor{15f} @deffn {C++ Function} gccjit::lvalue gccjit::lvalue::access_field (gccjit::field field, gccjit::location loc) Given an lvalue of struct or union type, access the given field, @@ -11490,7 +11506,7 @@ in C. @end deffn @geindex gccjit;;rvalue;;access_field (C++ function) -@anchor{cp/topics/expressions gccjit rvalue access_field__gccjit field gccjit location}@anchor{15e} +@anchor{cp/topics/expressions gccjit rvalue access_field__gccjit field gccjit location}@anchor{160} @deffn {C++ Function} gccjit::rvalue gccjit::rvalue::access_field (gccjit::field field, gccjit::location loc) Given an rvalue of struct or union type, access the given field @@ -11506,7 +11522,7 @@ in C. @end deffn @geindex gccjit;;rvalue;;dereference_field (C++ function) -@anchor{cp/topics/expressions gccjit rvalue dereference_field__gccjit field gccjit location}@anchor{15f} +@anchor{cp/topics/expressions gccjit rvalue dereference_field__gccjit field gccjit location}@anchor{161} @deffn {C++ Function} gccjit::lvalue gccjit::rvalue::dereference_field (gccjit::field field, gccjit::location loc) Given an rvalue of pointer type @code{T *} where T is of struct or union @@ -11522,7 +11538,7 @@ in C, itself equivalent to @code{(*EXPR).FIELD}. @end deffn @geindex gccjit;;context;;new_array_access (C++ function) -@anchor{cp/topics/expressions gccjit context new_array_access__gccjit rvalue gccjit rvalue gccjit location}@anchor{160} +@anchor{cp/topics/expressions gccjit context new_array_access__gccjit rvalue gccjit rvalue gccjit location}@anchor{162} @deffn {C++ Function} gccjit::lvalue gccjit::context::new_array_access (gccjit::rvalue ptr, gccjit::rvalue index, gccjit::location loc) Given an rvalue of pointer type @code{T *}, get at the element @cite{T} at @@ -11541,7 +11557,7 @@ in C (or, indeed, to @code{PTR + INDEX}). Parameter "loc" is optional. @end deffn -For array accesses where you don't need to specify a @pxref{102,,gccjit;;location}, +For array accesses where you don't need to specify a @pxref{103,,gccjit;;location}, two overloaded operators are available: @quotation @@ -11581,7 +11597,7 @@ gccjit::lvalue element = array[0]; @c . @node Creating and using functions<2>,Source Locations<2>,Expressions<2>,Topic Reference<2> -@anchor{cp/topics/functions doc}@anchor{161}@anchor{cp/topics/functions creating-and-using-functions}@anchor{162} +@anchor{cp/topics/functions doc}@anchor{163}@anchor{cp/topics/functions creating-and-using-functions}@anchor{164} @subsection Creating and using functions @@ -11594,36 +11610,36 @@ gccjit::lvalue element = array[0]; @end menu @node Params<2>,Functions<2>,,Creating and using functions<2> -@anchor{cp/topics/functions params}@anchor{163} +@anchor{cp/topics/functions params}@anchor{165} @subsubsection Params @geindex gccjit;;param (C++ class) -@anchor{cp/topics/functions gccjit param}@anchor{164} +@anchor{cp/topics/functions gccjit param}@anchor{166} @deffn {C++ Class} gccjit::param A @cite{gccjit::param} represents a parameter to a function. @end deffn @geindex gccjit;;context;;new_param (C++ function) -@anchor{cp/topics/functions gccjit context new_param__gccjit type cCP gccjit location}@anchor{d1} +@anchor{cp/topics/functions gccjit context new_param__gccjit type cCP gccjit location}@anchor{d2} @deffn {C++ Function} gccjit::param gccjit::context::new_param (gccjit::type type, const char* name, gccjit::location loc) In preparation for creating a function, create a new parameter of the given type and name. @end deffn -@pxref{164,,gccjit;;param} is a subclass of @pxref{157,,gccjit;;lvalue} (and thus -of @pxref{120,,gccjit;;rvalue} and @pxref{10a,,gccjit;;object}). It is a thin +@pxref{166,,gccjit;;param} is a subclass of @pxref{159,,gccjit;;lvalue} (and thus +of @pxref{121,,gccjit;;rvalue} and @pxref{10b,,gccjit;;object}). It is a thin wrapper around the C API's @pxref{25,,gcc_jit_param *}. @node Functions<2>,Blocks<2>,Params<2>,Creating and using functions<2> -@anchor{cp/topics/functions functions}@anchor{165} +@anchor{cp/topics/functions functions}@anchor{167} @subsubsection Functions @geindex gccjit;;function (C++ class) -@anchor{cp/topics/functions gccjit function}@anchor{166} +@anchor{cp/topics/functions gccjit function}@anchor{168} @deffn {C++ Class} gccjit::function A @cite{gccjit::function} represents a function - either one that we're @@ -11641,29 +11657,29 @@ This is a wrapper around the C API's @pxref{11,,gcc_jit_context_new_function()}. @end deffn @geindex gccjit;;context;;get_builtin_function (C++ function) -@anchor{cp/topics/functions gccjit context get_builtin_function__cCP}@anchor{167} +@anchor{cp/topics/functions gccjit context get_builtin_function__cCP}@anchor{169} @deffn {C++ Function} gccjit::function gccjit::context::get_builtin_function (const char* name) This is a wrapper around the C API's -@pxref{b5,,gcc_jit_context_get_builtin_function()}. +@pxref{b6,,gcc_jit_context_get_builtin_function()}. @end deffn @geindex gccjit;;function;;get_param (C++ function) -@anchor{cp/topics/functions gccjit function get_param__iC}@anchor{168} +@anchor{cp/topics/functions gccjit function get_param__iC}@anchor{16a} @deffn {C++ Function} gccjit::param gccjit::function::get_param (int index) const Get the param of the given index (0-based). @end deffn @geindex gccjit;;function;;dump_to_dot (C++ function) -@anchor{cp/topics/functions gccjit function dump_to_dot__cCP}@anchor{e4} +@anchor{cp/topics/functions gccjit function dump_to_dot__cCP}@anchor{e5} @deffn {C++ Function} void gccjit::function::dump_to_dot (const char* path) Emit the function in graphviz format to the given path. @end deffn @geindex gccjit;;function;;new_local (C++ function) -@anchor{cp/topics/functions gccjit function new_local__gccjit type cCP gccjit location}@anchor{db} +@anchor{cp/topics/functions gccjit function new_local__gccjit type cCP gccjit location}@anchor{dc} @deffn {C++ Function} gccjit::lvalue gccjit::function::new_local (gccjit::type type, const char* name, gccjit::location loc) Create a new local variable within the function, of the given type and @@ -11671,19 +11687,19 @@ name. @end deffn @node Blocks<2>,Statements<2>,Functions<2>,Creating and using functions<2> -@anchor{cp/topics/functions blocks}@anchor{169} +@anchor{cp/topics/functions blocks}@anchor{16b} @subsubsection Blocks @geindex gccjit;;block (C++ class) -@anchor{cp/topics/functions gccjit block}@anchor{16a} +@anchor{cp/topics/functions gccjit block}@anchor{16c} @deffn {C++ Class} gccjit::block A @cite{gccjit::block} represents a basic block within a function i.e. a sequence of statements with a single entry point and a single exit point. -@pxref{16a,,gccjit;;block} is a subclass of @pxref{10a,,gccjit;;object}. +@pxref{16c,,gccjit;;block} is a subclass of @pxref{10b,,gccjit;;object}. The first basic block that you create within a function will be the entrypoint. @@ -11696,7 +11712,7 @@ one function. @end deffn @geindex gccjit;;function;;new_block (C++ function) -@anchor{cp/topics/functions gccjit function new_block__cCP}@anchor{16b} +@anchor{cp/topics/functions gccjit function new_block__cCP}@anchor{16d} @deffn {C++ Function} gccjit::block gccjit::function::new_block (const char* name) Create a basic block of the given name. The name may be NULL, but @@ -11706,12 +11722,12 @@ messages. @end deffn @node Statements<2>,,Blocks<2>,Creating and using functions<2> -@anchor{cp/topics/functions statements}@anchor{16c} +@anchor{cp/topics/functions statements}@anchor{16e} @subsubsection Statements @geindex gccjit;;block;;add_eval (C++ function) -@anchor{cp/topics/functions gccjit block add_eval__gccjit rvalue gccjit location}@anchor{153} +@anchor{cp/topics/functions gccjit block add_eval__gccjit rvalue gccjit location}@anchor{155} @deffn {C++ Function} void gccjit::block::add_eval (gccjit::rvalue rvalue, gccjit::location loc) Add evaluation of an rvalue, discarding the result @@ -11727,7 +11743,7 @@ This is equivalent to this C code: @end deffn @geindex gccjit;;block;;add_assignment (C++ function) -@anchor{cp/topics/functions gccjit block add_assignment__gccjit lvalue gccjit rvalue gccjit location}@anchor{dd} +@anchor{cp/topics/functions gccjit block add_assignment__gccjit lvalue gccjit rvalue gccjit location}@anchor{de} @deffn {C++ Function} void gccjit::block::add_assignment (gccjit::lvalue lvalue, gccjit::rvalue rvalue, gccjit::location loc) Add evaluation of an rvalue, assigning the result to the given @@ -11743,7 +11759,7 @@ lvalue = rvalue; @end deffn @geindex gccjit;;block;;add_assignment_op (C++ function) -@anchor{cp/topics/functions gccjit block add_assignment_op__gccjit lvalue enum gccjit rvalue gccjit location}@anchor{e1} +@anchor{cp/topics/functions gccjit block add_assignment_op__gccjit lvalue enum gccjit rvalue gccjit location}@anchor{e2} @deffn {C++ Function} void gccjit::block::add_assignment_op (gccjit::lvalue lvalue, enum gcc_jit_binary_op, gccjit::rvalue rvalue, gccjit::location loc) Add evaluation of an rvalue, using the result to modify an @@ -11773,7 +11789,7 @@ loop_body.add_assignment_op ( @end deffn @geindex gccjit;;block;;add_comment (C++ function) -@anchor{cp/topics/functions gccjit block add_comment__cCP gccjit location}@anchor{ec} +@anchor{cp/topics/functions gccjit block add_comment__cCP gccjit location}@anchor{ed} @deffn {C++ Function} void gccjit::block::add_comment (const char* text, gccjit::location loc) Add a no-op textual comment to the internal representation of the @@ -11787,7 +11803,7 @@ Parameter "loc" is optional. @end deffn @geindex gccjit;;block;;end_with_conditional (C++ function) -@anchor{cp/topics/functions gccjit block end_with_conditional__gccjit rvalue gccjit block gccjit block gccjit location}@anchor{e0} +@anchor{cp/topics/functions gccjit block end_with_conditional__gccjit rvalue gccjit block gccjit block gccjit location}@anchor{e1} @deffn {C++ Function} void gccjit::block::end_with_conditional (gccjit::rvalue boolval, gccjit::block on_true, gccjit::block on_false, gccjit::location loc) Terminate a block by adding evaluation of an rvalue, branching on the @@ -11808,7 +11824,7 @@ block, boolval, on_true, and on_false must be non-NULL. @end deffn @geindex gccjit;;block;;end_with_jump (C++ function) -@anchor{cp/topics/functions gccjit block end_with_jump__gccjit block gccjit location}@anchor{16d} +@anchor{cp/topics/functions gccjit block end_with_jump__gccjit block gccjit location}@anchor{16f} @deffn {C++ Function} void gccjit::block::end_with_jump (gccjit::block target, gccjit::location loc) Terminate a block by adding a jump to the given target block. @@ -11823,7 +11839,7 @@ goto target; @end deffn @geindex gccjit;;block;;end_with_return (C++ function) -@anchor{cp/topics/functions gccjit block end_with_return__gccjit rvalue gccjit location}@anchor{16e} +@anchor{cp/topics/functions gccjit block end_with_return__gccjit rvalue gccjit location}@anchor{170} @deffn {C++ Function} void gccjit::block::end_with_return (gccjit::rvalue rvalue, gccjit::location loc) Terminate a block. @@ -11874,12 +11890,12 @@ return; @c . @node Source Locations<2>,Compilation results<2>,Creating and using functions<2>,Topic Reference<2> -@anchor{cp/topics/locations source-locations}@anchor{16f}@anchor{cp/topics/locations doc}@anchor{170} +@anchor{cp/topics/locations source-locations}@anchor{171}@anchor{cp/topics/locations doc}@anchor{172} @subsection Source Locations @geindex gccjit;;location (C++ class) -@anchor{cp/topics/locations gccjit location}@anchor{102} +@anchor{cp/topics/locations gccjit location}@anchor{103} @deffn {C++ Class} gccjit::location A @cite{gccjit::location} encapsulates a source code location, so that @@ -11890,10 +11906,10 @@ single-step through your language. @cite{gccjit::location} instances are optional: you can always omit them from any C++ API entrypoint accepting one. -You can construct them using @pxref{f0,,gccjit;;context;;new_location()}. +You can construct them using @pxref{f1,,gccjit;;context;;new_location()}. You need to enable @pxref{42,,GCC_JIT_BOOL_OPTION_DEBUGINFO} on the -@pxref{fa,,gccjit;;context} for these locations to actually be usable by +@pxref{fb,,gccjit;;context} for these locations to actually be usable by the debugger: @example @@ -11904,7 +11920,7 @@ ctxt.set_bool_option (GCC_JIT_BOOL_OPTION_DEBUGINFO, 1); @end deffn @geindex gccjit;;context;;new_location (C++ function) -@anchor{cp/topics/locations gccjit context new_location__cCP i i}@anchor{f0} +@anchor{cp/topics/locations gccjit context new_location__cCP i i}@anchor{f1} @deffn {C++ Function} gccjit::location gccjit::context::new_location (const char* filename, int line, int column) Create a @cite{gccjit::location} instance representing the given source @@ -11917,13 +11933,13 @@ location. @end menu @node Faking it<2>,,,Source Locations<2> -@anchor{cp/topics/locations faking-it}@anchor{171} +@anchor{cp/topics/locations faking-it}@anchor{173} @subsubsection Faking it If you don't have source code for your internal representation, but need to debug, you can generate a C-like representation of the functions in -your context using @pxref{101,,gccjit;;context;;dump_to_file()}: +your context using @pxref{102,,gccjit;;context;;dump_to_file()}: @example ctxt.dump_to_file ("/tmp/something.c", @@ -11955,27 +11971,27 @@ file, giving you @emph{something} you can step through in the debugger. @c . @node Compilation results<2>,,Source Locations<2>,Topic Reference<2> -@anchor{cp/topics/results compilation-results}@anchor{172}@anchor{cp/topics/results doc}@anchor{173} +@anchor{cp/topics/results compilation-results}@anchor{174}@anchor{cp/topics/results doc}@anchor{175} @subsection Compilation results @geindex gcc_jit_result (C++ type) -@anchor{cp/topics/results gcc_jit_result}@anchor{174} +@anchor{cp/topics/results gcc_jit_result}@anchor{176} @deffn {C++ Type} gcc_jit_result A @cite{gcc_jit_result} encapsulates the result of compiling a context. @end deffn @geindex gccjit;;context;;compile (C++ function) -@anchor{cp/topics/results gccjit context compile}@anchor{d3} -@deffn {C++ Function} @pxref{174,,gcc_jit_result*} gccjit::context::compile () +@anchor{cp/topics/results gccjit context compile}@anchor{d4} +@deffn {C++ Function} @pxref{176,,gcc_jit_result*} gccjit::context::compile () This calls into GCC and builds the code, returning a @cite{gcc_jit_result *}. @end deffn @geindex gcc_jit_result_get_code (C++ function) -@anchor{cp/topics/results gcc_jit_result_get_code__gcc_jit_resultP cCP}@anchor{175} +@anchor{cp/topics/results gcc_jit_result_get_code__gcc_jit_resultP cCP}@anchor{177} @deffn {C++ Function} void* gcc_jit_result_get_code (gcc_jit_result* result, const char* funcname) Locate a given function within the built machine code. @@ -11984,7 +12000,7 @@ correct type before it can be called. @end deffn @geindex gcc_jit_result_release (C++ function) -@anchor{cp/topics/results gcc_jit_result_release__gcc_jit_resultP}@anchor{176} +@anchor{cp/topics/results gcc_jit_result_release__gcc_jit_resultP}@anchor{178} @deffn {C++ Function} void gcc_jit_result_release (gcc_jit_result* result) Once we're done with the code, this unloads the built .so file. @@ -12010,7 +12026,7 @@ valid to use the result. @c . @node Internals,Indices and tables,C++ bindings for libgccjit,Top -@anchor{internals/index internals}@anchor{177}@anchor{internals/index doc}@anchor{178} +@anchor{internals/index internals}@anchor{179}@anchor{internals/index doc}@anchor{17a} @chapter Internals @@ -12023,7 +12039,7 @@ valid to use the result. @end menu @node Working on the JIT library,Running the test suite,,Internals -@anchor{internals/index working-on-the-jit-library}@anchor{179} +@anchor{internals/index working-on-the-jit-library}@anchor{17b} @section Working on the JIT library @@ -12060,7 +12076,7 @@ gcc/libgccjit.so.0.0.1: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), Here's what those configuration options mean: @geindex command line option; --enable-host-shared -@anchor{internals/index cmdoption--enable-host-shared}@anchor{17a} +@anchor{internals/index cmdoption--enable-host-shared}@anchor{17c} @deffn {Option} --enable-host-shared Configuring with this option means that the compiler is built as @@ -12069,7 +12085,7 @@ but it necessary for a shared library. @end deffn @geindex command line option; --enable-languages=jit@comma{}c++ -@anchor{internals/index cmdoption--enable-languages}@anchor{17b} +@anchor{internals/index cmdoption--enable-languages}@anchor{17d} @deffn {Option} --enable-languages=jit,c++ This specifies which frontends to build. The JIT library looks like @@ -12088,7 +12104,7 @@ c++: error trying to exec 'cc1plus': execvp: No such file or directory @end deffn @geindex command line option; --disable-bootstrap -@anchor{internals/index cmdoption--disable-bootstrap}@anchor{17c} +@anchor{internals/index cmdoption--disable-bootstrap}@anchor{17e} @deffn {Option} --disable-bootstrap For hacking on the "jit" subdirectory, performing a full @@ -12098,7 +12114,7 @@ the compiler can still bootstrap itself. @end deffn @geindex command line option; --enable-checking=release -@anchor{internals/index cmdoption--enable-checking}@anchor{17d} +@anchor{internals/index cmdoption--enable-checking}@anchor{17f} @deffn {Option} --enable-checking=release The compile can perform extensive self-checking as it runs, useful when @@ -12109,7 +12125,7 @@ disable this self-checking. @end deffn @node Running the test suite,Environment variables,Working on the JIT library,Internals -@anchor{internals/index running-the-test-suite}@anchor{17e} +@anchor{internals/index running-the-test-suite}@anchor{180} @section Running the test suite @@ -12172,7 +12188,7 @@ and once a test has been compiled, you can debug it directly: @end menu @node Running under valgrind,,,Running the test suite -@anchor{internals/index running-under-valgrind}@anchor{17f} +@anchor{internals/index running-under-valgrind}@anchor{181} @subsection Running under valgrind @@ -12220,7 +12236,7 @@ When running under valgrind, it's best to have configured gcc with various known false positives. @node Environment variables,Overview of code structure,Running the test suite,Internals -@anchor{internals/index environment-variables}@anchor{180} +@anchor{internals/index environment-variables}@anchor{182} @section Environment variables @@ -12228,7 +12244,7 @@ When running client code against a locally-built libgccjit, three environment variables need to be set up: @geindex environment variable; LD_LIBRARY_PATH -@anchor{internals/index envvar-LD_LIBRARY_PATH}@anchor{181} +@anchor{internals/index envvar-LD_LIBRARY_PATH}@anchor{183} @deffn {Environment Variable} LD_LIBRARY_PATH @quotation @@ -12250,7 +12266,7 @@ libgccjit.so.0.0.1: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), @end deffn @geindex environment variable; PATH -@anchor{internals/index envvar-PATH}@anchor{182} +@anchor{internals/index envvar-PATH}@anchor{184} @deffn {Environment Variable} PATH The library uses a driver executable for converting from .s assembler @@ -12269,7 +12285,7 @@ of development. @end deffn @geindex environment variable; LIBRARY_PATH -@anchor{internals/index envvar-LIBRARY_PATH}@anchor{183} +@anchor{internals/index envvar-LIBRARY_PATH}@anchor{185} @deffn {Environment Variable} LIBRARY_PATH The driver executable invokes the linker, and the latter needs to locate @@ -12305,7 +12321,7 @@ hello world @noindent @node Overview of code structure,,Environment variables,Internals -@anchor{internals/index overview-of-code-structure}@anchor{184} +@anchor{internals/index overview-of-code-structure}@anchor{186} @section Overview of code structure @@ -12724,7 +12740,7 @@ JIT: gcc::jit::logger::~logger() @noindent @node Indices and tables,Index,Internals,Top -@anchor{index indices-and-tables}@anchor{185} +@anchor{index indices-and-tables}@anchor{187} @unnumbered Indices and tables diff --git a/gcc/jit/docs/cp/topics/expressions.rst b/gcc/jit/docs/cp/topics/expressions.rst index 6d9e53b7aa4..b58eeff8ff1 100644 --- a/gcc/jit/docs/cp/topics/expressions.rst +++ b/gcc/jit/docs/cp/topics/expressions.rst @@ -57,7 +57,14 @@ Simple expressions int value) const Given a numeric type (integer or floating point), build an rvalue for - the given constant ``int`` value. + the given constant :c:type:`int` value. + +.. function:: gccjit::rvalue \ + gccjit::context::new_rvalue (gccjit::type numeric_type, \ + long value) const + + Given a numeric type (integer or floating point), build an rvalue for + the given constant :c:type:`long` value. .. function:: gccjit::rvalue \ gccjit::context::zero (gccjit::type numeric_type) const @@ -84,7 +91,7 @@ Simple expressions double value) const Given a numeric type (integer or floating point), build an rvalue for - the given constant value. + the given constant :c:type:`double` value. .. function:: gccjit::rvalue \ gccjit::context::new_rvalue (gccjit::type pointer_type, \ diff --git a/gcc/jit/docs/topics/expressions.rst b/gcc/jit/docs/topics/expressions.rst index 72a10856a27..13a28e895d9 100644 --- a/gcc/jit/docs/topics/expressions.rst +++ b/gcc/jit/docs/topics/expressions.rst @@ -60,7 +60,15 @@ Simple expressions int value) Given a numeric type (integer or floating point), build an rvalue for - the given constant value. + the given constant :c:type:`int` value. + +.. function:: gcc_jit_rvalue *\ + gcc_jit_context_new_rvalue_from_long (gcc_jit_context *ctxt, \ + gcc_jit_type *numeric_type, \ + long value) + + Given a numeric type (integer or floating point), build an rvalue for + the given constant :c:type:`long` value. .. function:: gcc_jit_rvalue *gcc_jit_context_zero (gcc_jit_context *ctxt, \ gcc_jit_type *numeric_type) @@ -88,7 +96,7 @@ Simple expressions double value) Given a numeric type (integer or floating point), build an rvalue for - the given constant value. + the given constant :c:type:`double` value. .. function:: gcc_jit_rvalue *\ gcc_jit_context_new_rvalue_from_ptr (gcc_jit_context *ctxt, \ diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c index 401977827c4..9c3bc17089f 100644 --- a/gcc/jit/jit-playback.c +++ b/gcc/jit/jit-playback.c @@ -486,12 +486,25 @@ new_global (location *loc, return new lvalue (this, inner); } -/* Construct a playback::rvalue instance (wrapping a tree). */ +/* Implementation of the various + gcc::jit::playback::context::new_rvalue_from_const + methods. + Each of these constructs a playback::rvalue instance (wrapping a tree). -playback::rvalue * -playback::context:: -new_rvalue_from_int (type *type, - int value) + These specializations are required to be in the same namespace + as the template, hence we now have to enter the gcc::jit::playback + namespace. */ + +namespace playback +{ + +/* Specialization of making an rvalue from a const, for host . */ + +template <> +rvalue * +context:: +new_rvalue_from_const (type *type, + int value) { // FIXME: type-checking, or coercion? tree inner_type = type->as_tree (); @@ -509,12 +522,37 @@ new_rvalue_from_int (type *type, } } -/* Construct a playback::rvalue instance (wrapping a tree). */ +/* Specialization of making an rvalue from a const, for host . */ -playback::rvalue * -playback::context:: -new_rvalue_from_double (type *type, - double value) +template <> +rvalue * +context:: +new_rvalue_from_const (type *type, + 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 <> +rvalue * +context:: +new_rvalue_from_const (type *type, + double value) { // FIXME: type-checking, or coercion? tree inner_type = type->as_tree (); @@ -539,12 +577,13 @@ new_rvalue_from_double (type *type, return new rvalue (this, inner); } -/* Construct a playback::rvalue instance (wrapping a tree). */ +/* Specialization of making an rvalue from a const, for host . */ -playback::rvalue * -playback::context:: -new_rvalue_from_ptr (type *type, - void *value) +template <> +rvalue * +context:: +new_rvalue_from_const (type *type, + void *value) { tree inner_type = type->as_tree (); /* FIXME: how to ensure we have a wide enough type? */ @@ -552,6 +591,12 @@ new_rvalue_from_ptr (type *type, return new rvalue (this, inner); } +/* We're done implementing the specializations of + gcc::jit::playback::context::new_rvalue_from_const + so we can exit the gcc::jit::playback namespace. */ + +} // namespace playback + /* Construct a playback::rvalue instance (wrapping a tree). */ playback::rvalue * diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h index 3a03b3a9987..07d030e8c30 100644 --- a/gcc/jit/jit-playback.h +++ b/gcc/jit/jit-playback.h @@ -93,17 +93,10 @@ public: type *type, const char *name); + template rvalue * - new_rvalue_from_int (type *type, - int value); - - rvalue * - new_rvalue_from_double (type *type, - double value); - - rvalue * - new_rvalue_from_ptr (type *type, - void *value); + new_rvalue_from_const (type *type, + HOST_TYPE value); rvalue * new_string_literal (const char *value); diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c index a9ff3002e32..63dab380db1 100644 --- a/gcc/jit/jit-recording.c +++ b/gcc/jit/jit-recording.c @@ -647,54 +647,6 @@ recording::context::new_global (recording::location *loc, return result; } -/* Create a recording::memento_of_new_rvalue_from_int instance and add - it to this context's list of mementos. - - Implements the post-error-checking part of - gcc_jit_context_new_rvalue_from_int. */ - -recording::rvalue * -recording::context::new_rvalue_from_int (recording::type *type, - int value) -{ - recording::rvalue *result = - new memento_of_new_rvalue_from_int (this, NULL, type, value); - record (result); - return result; -} - -/* Create a recording::memento_of_new_rvalue_from_double instance and - add it to this context's list of mementos. - - Implements the post-error-checking part of - gcc_jit_context_new_rvalue_from_double. */ - -recording::rvalue * -recording::context::new_rvalue_from_double (recording::type *type, - double value) -{ - recording::rvalue *result = - new memento_of_new_rvalue_from_double (this, NULL, type, value); - record (result); - return result; -} - -/* Create a recording::memento_of_new_rvalue_from_ptr instance and add - it to this context's list of mementos. - - Implements the post-error-checking part of - gcc_jit_context_new_rvalue_from_ptr. */ - -recording::rvalue * -recording::context::new_rvalue_from_ptr (recording::type *type, - void *value) -{ - recording::rvalue *result = - new memento_of_new_rvalue_from_ptr (this, NULL, type, value); - record (result); - return result; -} - /* Create a recording::memento_of_new_string_literal instance and add it to this context's list of mementos. @@ -2702,26 +2654,51 @@ recording::global::replay_into (replayer *r) playback_string (m_name))); } -/* The implementation of class gcc::jit::recording::memento_of_new_rvalue_from_int. */ +/* The implementation of the various const-handling classes: + gcc::jit::recording::memento_of_new_rvalue_from_const . */ -/* Implementation of pure virtual hook recording::memento::replay_into - for recording::memento_of_new_rvalue_from_int. */ +/* 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 ; + +/* Implementation of the pure virtual hook recording::memento::replay_into + for recording::memento_of_new_rvalue_from_const . */ +template void -recording::memento_of_new_rvalue_from_int::replay_into (replayer *r) +recording:: +memento_of_new_rvalue_from_const ::replay_into (replayer *r) { - set_playback_obj (r->new_rvalue_from_int (m_type->playback_type (), - m_value)); + set_playback_obj + (r->new_rvalue_from_const (m_type->playback_type (), + m_value)); } -/* Implementation of recording::memento::make_debug_string for - rvalue_from_int, rendering it as - (TYPE)LITERAL +/* The make_debug_string method varies between the various + memento_of_new_rvalue_from_const classes, so we explicitly + write specializations of it. + + I (dmalcolm) find the code to be clearer if the "recording" vs "playback" + namespaces are written out explicitly, which is why most of this file + doesn't abbreviate things by entering the "recording" namespace. + + However, these specializations are required to be in the same namespace + as the template, hence we now have to enter the gcc::jit::recording + namespace. */ + +namespace recording +{ + +/* The make_debug_string specialization for , which renders it as + (TARGET_TYPE)LITERAL e.g. "(int)42". */ -recording::string * -recording::memento_of_new_rvalue_from_int::make_debug_string () +template <> +string * +memento_of_new_rvalue_from_const ::make_debug_string () { return string::from_printf (m_ctxt, "(%s)%i", @@ -2729,26 +2706,29 @@ recording::memento_of_new_rvalue_from_int::make_debug_string () m_value); } -/* The implementation of class gcc::jit::recording::memento_of_new_rvalue_from_double. */ - -/* Implementation of pure virtual hook recording::memento::replay_into - for recording::memento_of_new_rvalue_from_double. */ +/* The make_debug_string specialization for , rendering it as + (TARGET_TYPE)LITERAL + e.g. + "(long)42". */ -void -recording::memento_of_new_rvalue_from_double::replay_into (replayer *r) +template <> +string * +memento_of_new_rvalue_from_const ::make_debug_string () { - set_playback_obj (r->new_rvalue_from_double (m_type->playback_type (), - m_value)); + return string::from_printf (m_ctxt, + "(%s)%li", + m_type->get_debug_string (), + m_value); } -/* Implementation of recording::memento::make_debug_string for - rvalue_from_double, rendering it as - (TYPE)LITERAL +/* The make_debug_string specialization for , rendering it as + (TARGET_TYPE)LITERAL e.g. "(float)42.0". */ -recording::string * -recording::memento_of_new_rvalue_from_double::make_debug_string () +template <> +string * +memento_of_new_rvalue_from_const ::make_debug_string () { return string::from_printf (m_ctxt, "(%s)%f", @@ -2756,29 +2736,17 @@ recording::memento_of_new_rvalue_from_double::make_debug_string () m_value); } -/* The implementation of class gcc::jit::recording::memento_of_new_rvalue_from_ptr. */ - -/* Implementation of pure virtual hook recording::memento::replay_into - for recording::memento_of_new_rvalue_from_ptr. */ - -void -recording::memento_of_new_rvalue_from_ptr::replay_into (replayer *r) -{ - set_playback_obj (r->new_rvalue_from_ptr (m_type->playback_type (), - m_value)); -} - -/* Implementation of recording::memento::make_debug_string for - rvalue_from_ptr, rendering it as - (TYPE)HEX +/* The make_debug_string specialization for , rendering it as + (TARGET_TYPE)HEX e.g. "(int *)0xdeadbeef" Zero is rendered as NULL e.g. "(int *)NULL". */ -recording::string * -recording::memento_of_new_rvalue_from_ptr::make_debug_string () +template <> +string * +memento_of_new_rvalue_from_const ::make_debug_string () { if (m_value != NULL) return string::from_printf (m_ctxt, @@ -2790,6 +2758,11 @@ recording::memento_of_new_rvalue_from_ptr::make_debug_string () m_type->get_debug_string ()); } +/* We're done specializing make_debug_string, so we can exit the + gcc::jit::recording namespace. */ + +} // namespace recording + /* The implementation of class gcc::jit::recording::memento_of_new_string_literal. */ /* Implementation of pure virtual hook recording::memento::replay_into diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index 94179938d41..8d154874366 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -135,17 +135,10 @@ public: type *type, const char *name); + template rvalue * - new_rvalue_from_int (type *numeric_type, - int value); - - rvalue * - new_rvalue_from_double (type *numeric_type, - double value); - - rvalue * - new_rvalue_from_ptr (type *pointer_type, - void *value); + new_rvalue_from_const (type *type, + HOST_TYPE value); rvalue * new_string_literal (const char *value); @@ -1073,14 +1066,15 @@ private: string *m_name; }; -class memento_of_new_rvalue_from_int : public rvalue +template +class memento_of_new_rvalue_from_const : public rvalue { public: - memento_of_new_rvalue_from_int (context *ctxt, - location *loc, - type *numeric_type, - int value) - : rvalue (ctxt, loc, numeric_type), + memento_of_new_rvalue_from_const (context *ctxt, + location *loc, + type *type, + HOST_TYPE value) + : rvalue (ctxt, loc, type), m_value (value) {} void replay_into (replayer *r); @@ -1089,47 +1083,7 @@ private: string * make_debug_string (); private: - int m_value; -}; - -class memento_of_new_rvalue_from_double : public rvalue -{ -public: - memento_of_new_rvalue_from_double (context *ctxt, - location *loc, - type *numeric_type, - double value) - : rvalue (ctxt, loc, numeric_type), - m_value (value) - {} - - void replay_into (replayer *); - -private: - string * make_debug_string (); - -private: - double m_value; -}; - -class memento_of_new_rvalue_from_ptr : public rvalue -{ -public: - memento_of_new_rvalue_from_ptr (context *ctxt, - location *loc, - type *pointer_type, - void *value) - : rvalue (ctxt, loc, pointer_type), - m_value (value) - {} - - void replay_into (replayer *); - -private: - string * make_debug_string (); - -private: - void *m_value; + HOST_TYPE m_value; }; class memento_of_new_string_literal : public rvalue @@ -1605,6 +1559,23 @@ private: } // namespace gcc::jit::recording +/* Create a recording::memento_of_new_rvalue_from_const instance and add + it to this context's list of mementos. + + Implements the post-error-checking part of + gcc_jit_context_new_rvalue_from_{int|long|double|ptr}. */ + +template +recording::rvalue * +recording::context::new_rvalue_from_const (recording::type *type, + HOST_TYPE value) +{ + recording::rvalue *result = + new memento_of_new_rvalue_from_const (this, NULL, type, value); + record (result); + return result; +} + } // namespace gcc::jit } // namespace gcc diff --git a/gcc/jit/libgccjit++.h b/gcc/jit/libgccjit++.h index 600219ce853..84144e51126 100644 --- a/gcc/jit/libgccjit++.h +++ b/gcc/jit/libgccjit++.h @@ -161,6 +161,8 @@ namespace gccjit rvalue new_rvalue (type numeric_type, int value) const; + rvalue new_rvalue (type numeric_type, + long value) const; rvalue zero (type numeric_type) const; rvalue one (type numeric_type) const; rvalue new_rvalue (type numeric_type, @@ -725,6 +727,16 @@ context::new_rvalue (type numeric_type, value)); } +inline rvalue +context::new_rvalue (type numeric_type, + long value) const +{ + return rvalue ( + gcc_jit_context_new_rvalue_from_long (m_inner_ctxt, + numeric_type.get_inner_type (), + value)); +} + inline rvalue context::zero (type numeric_type) const { diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index 34f201ef035..62d3edf9e1c 100644 --- a/gcc/jit/libgccjit.c +++ b/gcc/jit/libgccjit.c @@ -1080,7 +1080,23 @@ gcc_jit_context_new_rvalue_from_int (gcc_jit_context *ctxt, JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_NULL_IF_FAIL_NONNULL_NUMERIC_TYPE (ctxt, numeric_type); - return (gcc_jit_rvalue *)ctxt->new_rvalue_from_int (numeric_type, value); + return ((gcc_jit_rvalue *)ctxt + ->new_rvalue_from_const (numeric_type, value)); +} + +/* FIXME. */ + +gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_long (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + 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. @@ -1132,7 +1148,8 @@ gcc_jit_context_new_rvalue_from_double (gcc_jit_context *ctxt, JIT_LOG_FUNC (ctxt->get_logger ()); RETURN_NULL_IF_FAIL_NONNULL_NUMERIC_TYPE (ctxt, numeric_type); - return (gcc_jit_rvalue *)ctxt->new_rvalue_from_double (numeric_type, value); + return ((gcc_jit_rvalue *)ctxt + ->new_rvalue_from_const (numeric_type, value)); } /* Public entrypoint. See description in libgccjit.h. @@ -1155,7 +1172,8 @@ gcc_jit_context_new_rvalue_from_ptr (gcc_jit_context *ctxt, "not a pointer type (type: %s)", pointer_type->get_debug_string ()); - return (gcc_jit_rvalue *)ctxt->new_rvalue_from_ptr (pointer_type, value); + return ((gcc_jit_rvalue *)ctxt + ->new_rvalue_from_const (pointer_type, value)); } /* Public entrypoint. See description in libgccjit.h. diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h index 70f26ba5bb5..92eed37fb52 100644 --- a/gcc/jit/libgccjit.h +++ b/gcc/jit/libgccjit.h @@ -632,6 +632,11 @@ gcc_jit_context_new_rvalue_from_int (gcc_jit_context *ctxt, gcc_jit_type *numeric_type, int value); +extern gcc_jit_rvalue * +gcc_jit_context_new_rvalue_from_long (gcc_jit_context *ctxt, + gcc_jit_type *numeric_type, + long value); + extern gcc_jit_rvalue * gcc_jit_context_zero (gcc_jit_context *ctxt, gcc_jit_type *numeric_type); diff --git a/gcc/jit/libgccjit.map b/gcc/jit/libgccjit.map index dc2fa6f3b5c..bc6eb1afaa6 100644 --- a/gcc/jit/libgccjit.map +++ b/gcc/jit/libgccjit.map @@ -56,6 +56,7 @@ gcc_jit_context_new_param; 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_ptr; gcc_jit_context_new_string_literal; gcc_jit_context_new_struct_type; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0050999c999..c0721898e83 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2015-01-09 David Malcolm + + * jit.dg/all-non-failing-tests.h: Add test-constants.c. + * jit.dg/test-combination.c (create_code): Likewise. + (verify_code): Likewise. + * jit.dg/test-constants.c: New test case. + * jit.dg/test-threads.c: Add test-constants.c. + 2015-01-09 Dimitris Papavasiliou PR libobjc/51891 diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h b/gcc/testsuite/jit.dg/all-non-failing-tests.h index beb3d13d45c..14211af220a 100644 --- a/gcc/testsuite/jit.dg/all-non-failing-tests.h +++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h @@ -57,6 +57,13 @@ #undef create_code #undef verify_code +/* test-constants.c */ +#define create_code create_code_constants +#define verify_code verify_code_constants +#include "test-constants.c" +#undef create_code +#undef verify_code + /* test-dot-product.c */ #define create_code create_code_dot_product #define verify_code verify_code_dot_product diff --git a/gcc/testsuite/jit.dg/test-combination.c b/gcc/testsuite/jit.dg/test-combination.c index e99f4d0921d..51316131909 100644 --- a/gcc/testsuite/jit.dg/test-combination.c +++ b/gcc/testsuite/jit.dg/test-combination.c @@ -22,6 +22,7 @@ create_code (gcc_jit_context *ctxt, void * user_data) create_code_arrays (ctxt, user_data); create_code_calling_external_function (ctxt, user_data); create_code_calling_function_ptr (ctxt, user_data); + create_code_constants (ctxt, user_data); create_code_dot_product (ctxt, user_data); create_code_expressions (ctxt, user_data); create_code_factorial (ctxt, user_data); @@ -50,6 +51,7 @@ verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) verify_code_arrays (ctxt, result); verify_code_calling_external_function (ctxt, result); verify_code_calling_function_ptr (ctxt, result); + verify_code_constants (ctxt, result); verify_code_dot_product (ctxt, result); verify_code_expressions (ctxt, result); verify_code_factorial (ctxt, result); diff --git a/gcc/testsuite/jit.dg/test-threads.c b/gcc/testsuite/jit.dg/test-threads.c index cd5ef6a4f62..13e414db878 100644 --- a/gcc/testsuite/jit.dg/test-threads.c +++ b/gcc/testsuite/jit.dg/test-threads.c @@ -122,6 +122,9 @@ const struct testcase testcases[] = { {"calling_function_ptr", create_code_calling_function_ptr, verify_code_calling_function_ptr}, + {"constants", + create_code_constants, + verify_code_constants}, {"dot_product", create_code_dot_product, verify_code_dot_product},