1 /* A C++ API for libgccjit, purely as inline wrapper functions.
2 Copyright (C) 2014-2024 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GCC is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef LIBGCCJIT_PLUS_PLUS_H
21 #define LIBGCCJIT_PLUS_PLUS_H
23 #include "libgccjit.h"
29 /****************************************************************************
31 ****************************************************************************/
35 /* Indentation indicates inheritance. */
55 /* Errors within the API become C++ exceptions of this class. */
63 context
get_context () const;
65 std::string
get_debug_string () const;
69 object (gcc_jit_object
*obj
);
71 gcc_jit_object
*get_inner_object () const;
74 gcc_jit_object
*m_inner_obj
;
77 inline std::ostream
& operator << (std::ostream
& stream
, const object
&obj
);
79 /* Some client code will want to supply source code locations, others
80 won't. To avoid doubling the number of entrypoints, everything
81 accepting a location also has a default argument. To do this, the
82 other classes need to see that "location" has a default constructor,
83 hence we need to declare it first. */
84 class location
: public object
88 location (gcc_jit_location
*loc
);
90 gcc_jit_location
*get_inner_location () const;
96 static context
acquire ();
98 context (gcc_jit_context
*ctxt
);
100 gccjit::context
new_child_context ();
102 gcc_jit_context
*get_inner_context () { return m_inner_ctxt
; }
106 gcc_jit_result
*compile ();
108 void compile_to_file (enum gcc_jit_output_kind output_kind
,
109 const char *output_path
);
111 void dump_to_file (const std::string
&path
,
112 bool update_locations
);
114 void set_logfile (FILE *logfile
,
118 void dump_reproducer_to_file (const char *path
);
120 void set_str_option (enum gcc_jit_str_option opt
,
123 void set_int_option (enum gcc_jit_int_option opt
,
126 void set_bool_option (enum gcc_jit_bool_option opt
,
129 void set_bool_allow_unreachable_blocks (int bool_value
);
130 void set_bool_use_external_driver (int bool_value
);
132 void add_command_line_option (const char *optname
);
133 void add_driver_option (const char *optname
);
135 void set_timer (gccjit::timer t
);
136 gccjit::timer
get_timer () const;
139 new_location (const std::string
&filename
,
143 type
get_type (enum gcc_jit_types kind
);
144 type
get_int_type (size_t num_bytes
, int is_signed
);
146 /* A way to map a specific int type, using the compiler to
147 get the details automatically e.g.:
148 gccjit::type type = get_int_type <my_int_type_t> (); */
149 template <typename T
>
150 type
get_int_type ();
152 type
new_array_type (type element_type
, int num_elements
,
153 location loc
= location ());
155 field
new_field (type type_
, const std::string
&name
,
156 location loc
= location ());
158 field
new_bitfield (type type_
, int width
, const std::string
&name
,
159 location loc
= location ());
161 struct_
new_struct_type (const std::string
&name
,
162 std::vector
<field
> &fields
,
163 location loc
= location ());
165 struct_
new_opaque_struct_type (const std::string
&name
,
166 location loc
= location ());
168 param
new_param (type type_
,
169 const std::string
&name
,
170 location loc
= location ());
172 function
new_function (enum gcc_jit_function_kind kind
,
174 const std::string
&name
,
175 std::vector
<param
> ¶ms
,
177 location loc
= location ());
179 function
get_builtin_function (const std::string
&name
);
181 lvalue
new_global (enum gcc_jit_global_kind kind
,
183 const std::string
&name
,
184 location loc
= location ());
186 rvalue
new_rvalue (type numeric_type
,
188 rvalue
new_rvalue (type numeric_type
,
190 rvalue
zero (type numeric_type
) const;
191 rvalue
one (type numeric_type
) const;
192 rvalue
new_rvalue (type numeric_type
,
194 rvalue
new_rvalue (type pointer_type
,
196 rvalue
new_rvalue (const std::string
&value
) const;
197 rvalue
new_rvalue (type vector_type
,
198 std::vector
<rvalue
> elements
) const;
200 rvalue
new_struct_ctor (type type_
,
201 std::vector
<field
> &fields
,
202 std::vector
<rvalue
> &values
,
203 location loc
= location ());
205 rvalue
new_array_ctor (type type_
,
206 std::vector
<rvalue
> &values
,
207 location loc
= location ());
209 rvalue
new_union_ctor (type type_
,
212 location loc
= location ());
214 /* Generic unary operations... */
215 rvalue
new_unary_op (enum gcc_jit_unary_op op
,
218 location loc
= location ());
220 /* ...and shorter ways to spell the various specific kinds of
222 rvalue
new_minus (type result_type
,
224 location loc
= location ());
225 rvalue
new_bitwise_negate (type result_type
,
227 location loc
= location ());
228 rvalue
new_logical_negate (type result_type
,
230 location loc
= location ());
232 /* Generic binary operations... */
233 rvalue
new_binary_op (enum gcc_jit_binary_op op
,
236 location loc
= location ());
238 /* ...and shorter ways to spell the various specific kinds of
240 rvalue
new_plus (type result_type
,
242 location loc
= location ());
243 rvalue
new_minus (type result_type
,
245 location loc
= location ());
246 rvalue
new_mult (type result_type
,
248 location loc
= location ());
249 rvalue
new_divide (type result_type
,
251 location loc
= location ());
252 rvalue
new_modulo (type result_type
,
254 location loc
= location ());
255 rvalue
new_bitwise_and (type result_type
,
257 location loc
= location ());
258 rvalue
new_bitwise_xor (type result_type
,
260 location loc
= location ());
261 rvalue
new_bitwise_or (type result_type
,
263 location loc
= location ());
264 rvalue
new_logical_and (type result_type
,
266 location loc
= location ());
267 rvalue
new_logical_or (type result_type
,
269 location loc
= location ());
271 /* Generic comparisons... */
272 rvalue
new_comparison (enum gcc_jit_comparison op
,
274 location loc
= location ());
275 /* ...and shorter ways to spell the various specific kinds of
277 rvalue
new_eq (rvalue a
, rvalue b
,
278 location loc
= location ());
279 rvalue
new_ne (rvalue a
, rvalue b
,
280 location loc
= location ());
281 rvalue
new_lt (rvalue a
, rvalue b
,
282 location loc
= location ());
283 rvalue
new_le (rvalue a
, rvalue b
,
284 location loc
= location ());
285 rvalue
new_gt (rvalue a
, rvalue b
,
286 location loc
= location ());
287 rvalue
new_ge (rvalue a
, rvalue b
,
288 location loc
= location ());
290 /* The most general way of creating a function call. */
291 rvalue
new_call (function func
,
292 std::vector
<rvalue
> &args
,
293 location loc
= location ());
295 /* In addition, we provide a series of overloaded "new_call" methods
296 for specific numbers of args (from 0 - 6), to avoid the need for
297 client code to manually build a vector. */
298 rvalue
new_call (function func
,
299 location loc
= location ());
300 rvalue
new_call (function func
,
302 location loc
= location ());
303 rvalue
new_call (function func
,
304 rvalue arg0
, rvalue arg1
,
305 location loc
= location ());
306 rvalue
new_call (function func
,
307 rvalue arg0
, rvalue arg1
, rvalue arg2
,
308 location loc
= location ());
309 rvalue
new_call (function func
,
310 rvalue arg0
, rvalue arg1
, rvalue arg2
,
312 location loc
= location ());
313 rvalue
new_call (function func
,
314 rvalue arg0
, rvalue arg1
, rvalue arg2
,
315 rvalue arg3
, rvalue arg4
,
316 location loc
= location ());
317 rvalue
new_call (function func
,
318 rvalue arg0
, rvalue arg1
, rvalue arg2
,
319 rvalue arg3
, rvalue arg4
, rvalue arg5
,
320 location loc
= location ());
322 rvalue
new_cast (rvalue expr
,
324 location loc
= location ());
326 lvalue
new_array_access (rvalue ptr
,
328 location loc
= location ());
330 case_
new_case (rvalue min_value
,
334 void add_top_level_asm (const char *asm_stmts
,
335 location loc
= location ());
338 gcc_jit_context
*m_inner_ctxt
;
341 class field
: public object
345 field (gcc_jit_field
*inner
);
347 gcc_jit_field
*get_inner_field () const;
350 class type
: public object
354 type (gcc_jit_type
*inner
);
356 gcc_jit_type
*get_inner_type () const;
360 type
get_volatile ();
361 type
get_aligned (size_t alignment_in_bytes
);
362 type
get_vector (size_t num_units
);
363 type
get_restrict ();
365 // Shortcuts for getting values of numeric types:
370 class struct_
: public type
374 struct_ (gcc_jit_struct
*inner
);
376 gcc_jit_struct
*get_inner_struct () const;
379 class function
: public object
383 function (gcc_jit_function
*func
);
385 gcc_jit_function
*get_inner_function () const;
387 void dump_to_dot (const std::string
&path
);
389 param
get_param (int index
) const;
392 block
new_block (const std::string
&name
);
394 lvalue
new_local (type type_
,
395 const std::string
&name
,
396 location loc
= location ());
398 rvalue
get_address (location loc
= location ());
400 /* A series of overloaded operator () with various numbers of arguments
401 for a very terse way of creating a call to this function. The call
402 is created within the same context as the function itself, which may
403 not be what you want. */
404 rvalue
operator() (location loc
= location ());
405 rvalue
operator() (rvalue arg0
,
406 location loc
= location ());
407 rvalue
operator() (rvalue arg0
, rvalue arg1
,
408 location loc
= location ());
409 rvalue
operator() (rvalue arg0
, rvalue arg1
, rvalue arg2
,
410 location loc
= location ());
413 class block
: public object
417 block (gcc_jit_block
*inner
);
419 gcc_jit_block
*get_inner_block () const;
421 function
get_function () const;
423 void add_eval (rvalue rvalue
,
424 location loc
= location ());
426 void add_assignment (lvalue lvalue
,
428 location loc
= location ());
430 void add_assignment_op (lvalue lvalue
,
431 enum gcc_jit_binary_op op
,
433 location loc
= location ());
435 /* A way to add a function call to the body of a function being
436 defined, with various numbers of args. */
437 rvalue
add_call (function other
,
438 location loc
= location ());
439 rvalue
add_call (function other
,
441 location loc
= location ());
442 rvalue
add_call (function other
,
443 rvalue arg0
, rvalue arg1
,
444 location loc
= location ());
445 rvalue
add_call (function other
,
446 rvalue arg0
, rvalue arg1
, rvalue arg2
,
447 location loc
= location ());
448 rvalue
add_call (function other
,
449 rvalue arg0
, rvalue arg1
, rvalue arg2
, rvalue arg3
,
450 location loc
= location ());
452 void add_comment (const std::string
&text
,
453 location loc
= location ());
455 void end_with_conditional (rvalue boolval
,
458 location loc
= location ());
460 void end_with_jump (block target
,
461 location loc
= location ());
463 void end_with_return (rvalue rvalue
,
464 location loc
= location ());
465 void end_with_return (location loc
= location ());
467 void end_with_switch (rvalue expr
,
469 std::vector
<case_
> cases
,
470 location loc
= location ());
472 extended_asm
add_extended_asm (const std::string
&asm_template
,
473 location loc
= location ());
474 extended_asm
end_with_extended_asm_goto (const std::string
&asm_template
,
475 std::vector
<block
> goto_blocks
,
476 block
*fallthrough_block
,
477 location loc
= location ());
480 class rvalue
: public object
484 rvalue (gcc_jit_rvalue
*inner
);
485 gcc_jit_rvalue
*get_inner_rvalue () const;
489 rvalue
access_field (field field
,
490 location loc
= location ());
492 lvalue
dereference_field (field field
,
493 location loc
= location ());
495 lvalue
dereference (location loc
= location ());
497 rvalue
cast_to (type type_
,
498 location loc
= location ());
501 lvalue
operator[] (rvalue index
);
502 lvalue
operator[] (int index
);
505 class lvalue
: public rvalue
509 lvalue (gcc_jit_lvalue
*inner
);
511 gcc_jit_lvalue
*get_inner_lvalue () const;
513 lvalue
access_field (field field
,
514 location loc
= location ());
516 rvalue
get_address (location loc
= location ());
517 lvalue
set_initializer (const void *blob
, size_t num_bytes
);
518 lvalue
set_initializer_rvalue (rvalue init_value
);
521 class param
: public lvalue
525 param (gcc_jit_param
*inner
);
527 gcc_jit_param
*get_inner_param () const;
530 class case_
: public object
534 case_ (gcc_jit_case
*inner
);
536 gcc_jit_case
*get_inner_case () const;
539 class extended_asm
: public object
543 extended_asm (gcc_jit_extended_asm
*inner
);
546 set_volatile_flag (bool flag
);
549 set_inline_flag (bool flag
);
552 add_output_operand (const std::string
&asm_symbolic_name
,
553 const std::string
&constraint
,
554 gccjit::lvalue dest
);
556 add_output_operand (const std::string
&constraint
,
557 gccjit::lvalue dest
);
560 add_input_operand (const std::string
&asm_symbolic_name
,
561 const std::string
&constraint
,
564 add_input_operand (const std::string
&constraint
,
568 add_clobber (const std::string
&victim
);
570 gcc_jit_extended_asm
*get_inner_extended_asm () const;
573 /* Overloaded operators, for those who want the most terse API
574 (at the possible risk of being a little too magical).
576 In each case, the first parameter is used to determine which context
577 owns the resulting expression, and, where appropriate, what the
580 /* Unary operators. */
581 rvalue
operator- (rvalue a
); // unary minus
582 rvalue
operator~ (rvalue a
); // unary bitwise negate
583 rvalue
operator! (rvalue a
); // unary logical negate
585 /* Binary operators. */
586 rvalue
operator+ (rvalue a
, rvalue b
);
587 rvalue
operator- (rvalue a
, rvalue b
);
588 rvalue
operator* (rvalue a
, rvalue b
);
589 rvalue
operator/ (rvalue a
, rvalue b
);
590 rvalue
operator% (rvalue a
, rvalue b
);
591 rvalue
operator& (rvalue a
, rvalue b
); // bitwise and
592 rvalue
operator^ (rvalue a
, rvalue b
); // bitwise_xor
593 rvalue
operator| (rvalue a
, rvalue b
); // bitwise_or
594 rvalue
operator&& (rvalue a
, rvalue b
); // logical_and
595 rvalue
operator|| (rvalue a
, rvalue b
); // logical_or
598 rvalue
operator== (rvalue a
, rvalue b
);
599 rvalue
operator!= (rvalue a
, rvalue b
);
600 rvalue
operator< (rvalue a
, rvalue b
);
601 rvalue
operator<= (rvalue a
, rvalue b
);
602 rvalue
operator> (rvalue a
, rvalue b
);
603 rvalue
operator>= (rvalue a
, rvalue b
);
606 lvalue
operator* (rvalue ptr
);
612 timer (gcc_jit_timer
*inner_timer
);
614 void push (const char *item_name
);
615 void pop (const char *item_name
);
616 void print (FILE *f_out
) const;
620 gcc_jit_timer
*get_inner_timer () const;
623 gcc_jit_timer
*m_inner_timer
;
629 auto_time (timer t
, const char *item_name
);
630 auto_time (context ctxt
, const char *item_name
);
635 const char *m_item_name
;
639 /****************************************************************************
640 Implementation of the API
641 ****************************************************************************/
645 inline context
context::acquire ()
647 return context (gcc_jit_context_acquire ());
649 inline context::context () : m_inner_ctxt (NULL
) {}
650 inline context::context (gcc_jit_context
*inner
) : m_inner_ctxt (inner
)
656 inline gccjit::context
657 context::new_child_context ()
659 return context (gcc_jit_context_new_child_context (m_inner_ctxt
));
665 gcc_jit_context_release (m_inner_ctxt
);
669 inline gcc_jit_result
*
672 gcc_jit_result
*result
= gcc_jit_context_compile (m_inner_ctxt
);
679 context::compile_to_file (enum gcc_jit_output_kind output_kind
,
680 const char *output_path
)
682 gcc_jit_context_compile_to_file (m_inner_ctxt
,
688 context::dump_to_file (const std::string
&path
,
689 bool update_locations
)
691 gcc_jit_context_dump_to_file (m_inner_ctxt
,
697 context::set_logfile (FILE *logfile
,
701 gcc_jit_context_set_logfile (m_inner_ctxt
,
708 context::dump_reproducer_to_file (const char *path
)
710 gcc_jit_context_dump_reproducer_to_file (m_inner_ctxt
,
715 context::set_str_option (enum gcc_jit_str_option opt
,
718 gcc_jit_context_set_str_option (m_inner_ctxt
, opt
, value
);
723 context::set_int_option (enum gcc_jit_int_option opt
,
726 gcc_jit_context_set_int_option (m_inner_ctxt
, opt
, value
);
731 context::set_bool_option (enum gcc_jit_bool_option opt
,
734 gcc_jit_context_set_bool_option (m_inner_ctxt
, opt
, value
);
738 context::set_bool_allow_unreachable_blocks (int bool_value
)
740 gcc_jit_context_set_bool_allow_unreachable_blocks (m_inner_ctxt
,
745 context::set_bool_use_external_driver (int bool_value
)
747 gcc_jit_context_set_bool_use_external_driver (m_inner_ctxt
,
752 context::add_command_line_option (const char *optname
)
754 gcc_jit_context_add_command_line_option (m_inner_ctxt
, optname
);
758 context::add_driver_option (const char *optname
)
760 gcc_jit_context_add_driver_option (m_inner_ctxt
, optname
);
764 context::set_timer (gccjit::timer t
)
766 gcc_jit_context_set_timer (m_inner_ctxt
, t
.get_inner_timer ());
770 context::get_timer () const
772 return gccjit::timer (gcc_jit_context_get_timer (m_inner_ctxt
));
777 context::new_location (const std::string
&filename
,
781 return location (gcc_jit_context_new_location (m_inner_ctxt
,
788 context::get_type (enum gcc_jit_types kind
)
790 return type (gcc_jit_context_get_type (m_inner_ctxt
, kind
));
794 context::get_int_type (size_t num_bytes
, int is_signed
)
796 return type (gcc_jit_context_get_int_type (m_inner_ctxt
,
801 template <typename T
>
803 context::get_int_type ()
805 return get_int_type (sizeof (T
), std::numeric_limits
<T
>::is_signed
);
809 context::new_array_type (type element_type
, int num_elements
, location loc
)
811 return type (gcc_jit_context_new_array_type (
813 loc
.get_inner_location (),
814 element_type
.get_inner_type (),
819 context::new_field (type type_
, const std::string
&name
, location loc
)
821 return field (gcc_jit_context_new_field (m_inner_ctxt
,
822 loc
.get_inner_location (),
823 type_
.get_inner_type (),
828 context::new_bitfield (type type_
, int width
, const std::string
&name
,
831 return field (gcc_jit_context_new_bitfield (m_inner_ctxt
,
832 loc
.get_inner_location (),
833 type_
.get_inner_type (),
839 context::new_struct_type (const std::string
&name
,
840 std::vector
<field
> &fields
,
843 /* Treat std::vector as an array, relying on it not being resized: */
844 field
*as_array_of_wrappers
= &fields
[0];
846 /* Treat the array as being of the underlying pointers, relying on
847 the wrapper type being such a pointer internally. */
848 gcc_jit_field
**as_array_of_ptrs
=
849 reinterpret_cast<gcc_jit_field
**> (as_array_of_wrappers
);
851 return struct_ (gcc_jit_context_new_struct_type (m_inner_ctxt
,
852 loc
.get_inner_location (),
859 context::new_opaque_struct_type (const std::string
&name
,
862 return struct_ (gcc_jit_context_new_opaque_struct (
864 loc
.get_inner_location (),
869 context::new_param (type type_
,
870 const std::string
&name
,
873 return param (gcc_jit_context_new_param (m_inner_ctxt
,
874 loc
.get_inner_location (),
875 type_
.get_inner_type (),
880 context::new_function (enum gcc_jit_function_kind kind
,
882 const std::string
&name
,
883 std::vector
<param
> ¶ms
,
887 /* Treat std::vector as an array, relying on it not being resized: */
888 param
*as_array_of_wrappers
= ¶ms
[0];
890 /* Treat the array as being of the underlying pointers, relying on
891 the wrapper type being such a pointer internally. */
892 gcc_jit_param
**as_array_of_ptrs
=
893 reinterpret_cast<gcc_jit_param
**> (as_array_of_wrappers
);
895 return function (gcc_jit_context_new_function (m_inner_ctxt
,
896 loc
.get_inner_location (),
898 return_type
.get_inner_type (),
906 context::get_builtin_function (const std::string
&name
)
908 return function (gcc_jit_context_get_builtin_function (m_inner_ctxt
,
913 context::new_global (enum gcc_jit_global_kind kind
,
915 const std::string
&name
,
918 return lvalue (gcc_jit_context_new_global (m_inner_ctxt
,
919 loc
.get_inner_location (),
921 type_
.get_inner_type (),
926 context::new_rvalue (type numeric_type
,
930 gcc_jit_context_new_rvalue_from_int (m_inner_ctxt
,
931 numeric_type
.get_inner_type (),
936 context::new_rvalue (type numeric_type
,
940 gcc_jit_context_new_rvalue_from_long (m_inner_ctxt
,
941 numeric_type
.get_inner_type (),
946 context::zero (type numeric_type
) const
948 return rvalue (gcc_jit_context_zero (m_inner_ctxt
,
949 numeric_type
.get_inner_type ()));
953 context::one (type numeric_type
) const
955 return rvalue (gcc_jit_context_one (m_inner_ctxt
,
956 numeric_type
.get_inner_type ()));
960 context::new_rvalue (type numeric_type
,
964 gcc_jit_context_new_rvalue_from_double (m_inner_ctxt
,
965 numeric_type
.get_inner_type (),
970 context::new_rvalue (type pointer_type
,
974 gcc_jit_context_new_rvalue_from_ptr (m_inner_ctxt
,
975 pointer_type
.get_inner_type (),
980 context::new_rvalue (const std::string
&value
) const
983 gcc_jit_context_new_string_literal (m_inner_ctxt
, value
.c_str ()));
987 context::new_rvalue (type vector_type
,
988 std::vector
<rvalue
> elements
) const
990 /* Treat std::vector as an array, relying on it not being resized: */
991 rvalue
*as_array_of_wrappers
= &elements
[0];
993 /* Treat the array as being of the underlying pointers, relying on
994 the wrapper type being such a pointer internally. */
995 gcc_jit_rvalue
**as_array_of_ptrs
=
996 reinterpret_cast<gcc_jit_rvalue
**> (as_array_of_wrappers
);
999 gcc_jit_context_new_rvalue_from_vector (m_inner_ctxt
,
1001 vector_type
.get_inner_type (),
1007 context::new_unary_op (enum gcc_jit_unary_op op
,
1012 return rvalue (gcc_jit_context_new_unary_op (m_inner_ctxt
,
1013 loc
.get_inner_location (),
1015 result_type
.get_inner_type (),
1016 a
.get_inner_rvalue ()));
1019 context::new_minus (type result_type
,
1023 return rvalue (new_unary_op (GCC_JIT_UNARY_OP_MINUS
,
1024 result_type
, a
, loc
));
1027 context::new_bitwise_negate (type result_type
,
1031 return rvalue (new_unary_op (GCC_JIT_UNARY_OP_BITWISE_NEGATE
,
1032 result_type
, a
, loc
));
1035 context::new_logical_negate (type result_type
,
1039 return rvalue (new_unary_op (GCC_JIT_UNARY_OP_LOGICAL_NEGATE
,
1040 result_type
, a
, loc
));
1044 context::new_binary_op (enum gcc_jit_binary_op op
,
1049 return rvalue (gcc_jit_context_new_binary_op (m_inner_ctxt
,
1050 loc
.get_inner_location (),
1052 result_type
.get_inner_type (),
1053 a
.get_inner_rvalue (),
1054 b
.get_inner_rvalue ()));
1057 context::new_plus (type result_type
,
1061 return new_binary_op (GCC_JIT_BINARY_OP_PLUS
,
1062 result_type
, a
, b
, loc
);
1065 context::new_minus (type result_type
,
1069 return new_binary_op (GCC_JIT_BINARY_OP_MINUS
,
1070 result_type
, a
, b
, loc
);
1073 context::new_mult (type result_type
,
1077 return new_binary_op (GCC_JIT_BINARY_OP_MULT
,
1078 result_type
, a
, b
, loc
);
1081 context::new_divide (type result_type
,
1085 return new_binary_op (GCC_JIT_BINARY_OP_DIVIDE
,
1086 result_type
, a
, b
, loc
);
1089 context::new_modulo (type result_type
,
1093 return new_binary_op (GCC_JIT_BINARY_OP_MODULO
,
1094 result_type
, a
, b
, loc
);
1097 context::new_bitwise_and (type result_type
,
1101 return new_binary_op (GCC_JIT_BINARY_OP_BITWISE_AND
,
1102 result_type
, a
, b
, loc
);
1105 context::new_bitwise_xor (type result_type
,
1109 return new_binary_op (GCC_JIT_BINARY_OP_BITWISE_XOR
,
1110 result_type
, a
, b
, loc
);
1113 context::new_bitwise_or (type result_type
,
1117 return new_binary_op (GCC_JIT_BINARY_OP_BITWISE_OR
,
1118 result_type
, a
, b
, loc
);
1121 context::new_logical_and (type result_type
,
1125 return new_binary_op (GCC_JIT_BINARY_OP_LOGICAL_AND
,
1126 result_type
, a
, b
, loc
);
1129 context::new_logical_or (type result_type
,
1133 return new_binary_op (GCC_JIT_BINARY_OP_LOGICAL_OR
,
1134 result_type
, a
, b
, loc
);
1138 context::new_comparison (enum gcc_jit_comparison op
,
1142 return rvalue (gcc_jit_context_new_comparison (m_inner_ctxt
,
1143 loc
.get_inner_location (),
1145 a
.get_inner_rvalue (),
1146 b
.get_inner_rvalue ()));
1149 context::new_eq (rvalue a
, rvalue b
,
1152 return new_comparison (GCC_JIT_COMPARISON_EQ
,
1156 context::new_ne (rvalue a
, rvalue b
,
1159 return new_comparison (GCC_JIT_COMPARISON_NE
,
1163 context::new_lt (rvalue a
, rvalue b
,
1166 return new_comparison (GCC_JIT_COMPARISON_LT
,
1170 context::new_le (rvalue a
, rvalue b
,
1173 return new_comparison (GCC_JIT_COMPARISON_LE
,
1177 context::new_gt (rvalue a
, rvalue b
,
1180 return new_comparison (GCC_JIT_COMPARISON_GT
,
1184 context::new_ge (rvalue a
, rvalue b
,
1187 return new_comparison (GCC_JIT_COMPARISON_GE
,
1192 context::new_call (function func
,
1193 std::vector
<rvalue
> &args
,
1196 /* Treat std::vector as an array, relying on it not being resized: */
1197 rvalue
*as_array_of_wrappers
= &args
[0];
1199 /* Treat the array as being of the underlying pointers, relying on
1200 the wrapper type being such a pointer internally. */
1201 gcc_jit_rvalue
**as_array_of_ptrs
=
1202 reinterpret_cast<gcc_jit_rvalue
**> (as_array_of_wrappers
);
1203 return gcc_jit_context_new_call (m_inner_ctxt
,
1204 loc
.get_inner_location (),
1205 func
.get_inner_function (),
1210 context::new_call (function func
,
1213 std::vector
<rvalue
> args
;
1214 return new_call (func
, args
, loc
);
1218 context::new_call (function func
,
1222 std::vector
<rvalue
> args(1);
1224 return new_call (func
, args
, loc
);
1227 context::new_call (function func
,
1228 rvalue arg0
, rvalue arg1
,
1231 std::vector
<rvalue
> args(2);
1234 return new_call (func
, args
, loc
);
1237 context::new_call (function func
,
1238 rvalue arg0
, rvalue arg1
, rvalue arg2
,
1241 std::vector
<rvalue
> args(3);
1245 return new_call (func
, args
, loc
);
1248 context::new_call (function func
,
1249 rvalue arg0
, rvalue arg1
, rvalue arg2
,
1253 std::vector
<rvalue
> args(4);
1258 return new_call (func
, args
, loc
);
1261 context::new_call (function func
,
1262 rvalue arg0
, rvalue arg1
, rvalue arg2
,
1263 rvalue arg3
, rvalue arg4
,
1266 std::vector
<rvalue
> args(5);
1272 return new_call (func
, args
, loc
);
1275 context::new_call (function func
,
1276 rvalue arg0
, rvalue arg1
, rvalue arg2
,
1277 rvalue arg3
, rvalue arg4
, rvalue arg5
,
1280 std::vector
<rvalue
> args(6);
1287 return new_call (func
, args
, loc
);
1291 context::new_cast (rvalue expr
,
1295 return rvalue (gcc_jit_context_new_cast (m_inner_ctxt
,
1296 loc
.get_inner_location (),
1297 expr
.get_inner_rvalue (),
1298 type_
.get_inner_type ()));
1302 context::new_array_access (rvalue ptr
,
1306 return lvalue (gcc_jit_context_new_array_access (m_inner_ctxt
,
1307 loc
.get_inner_location (),
1308 ptr
.get_inner_rvalue (),
1309 index
.get_inner_rvalue ()));
1313 context::new_case (rvalue min_value
,
1317 return case_ (gcc_jit_context_new_case (m_inner_ctxt
,
1318 min_value
.get_inner_rvalue (),
1319 max_value
.get_inner_rvalue (),
1320 dest_block
.get_inner_block ()));
1324 context::add_top_level_asm (const char *asm_stmts
, location loc
)
1326 gcc_jit_context_add_top_level_asm (m_inner_ctxt
,
1327 loc
.get_inner_location (),
1333 object::get_context () const
1335 return context (gcc_jit_object_get_context (m_inner_obj
));
1339 object::get_debug_string () const
1341 return gcc_jit_object_get_debug_string (m_inner_obj
);
1344 inline object::object () : m_inner_obj (NULL
) {}
1345 inline object::object (gcc_jit_object
*obj
) : m_inner_obj (obj
)
1351 inline gcc_jit_object
*
1352 object::get_inner_object () const
1357 inline std::ostream
&
1358 operator << (std::ostream
& stream
, const object
&obj
)
1360 return stream
<< obj
.get_debug_string ();
1364 inline location::location () : object () {}
1365 inline location::location (gcc_jit_location
*loc
)
1366 : object (gcc_jit_location_as_object (loc
))
1369 inline gcc_jit_location
*
1370 location::get_inner_location () const
1372 /* Manual downcast: */
1373 return reinterpret_cast<gcc_jit_location
*> (get_inner_object ());
1377 inline field::field () : object () {}
1378 inline field::field (gcc_jit_field
*inner
)
1379 : object (gcc_jit_field_as_object (inner
))
1382 inline gcc_jit_field
*
1383 field::get_inner_field () const
1385 /* Manual downcast: */
1386 return reinterpret_cast<gcc_jit_field
*> (get_inner_object ());
1390 inline type::type () : object () {}
1391 inline type::type (gcc_jit_type
*inner
)
1392 : object (gcc_jit_type_as_object (inner
))
1395 inline gcc_jit_type
*
1396 type::get_inner_type () const
1398 /* Manual downcast: */
1399 return reinterpret_cast<gcc_jit_type
*> (get_inner_object ());
1403 type::get_pointer ()
1405 return type (gcc_jit_type_get_pointer (get_inner_type ()));
1411 return type (gcc_jit_type_get_const (get_inner_type ()));
1415 type::get_restrict ()
1417 return type (gcc_jit_type_get_restrict (get_inner_type ()));
1421 type::get_volatile ()
1423 return type (gcc_jit_type_get_volatile (get_inner_type ()));
1427 type::get_aligned (size_t alignment_in_bytes
)
1429 return type (gcc_jit_type_get_aligned (get_inner_type (),
1430 alignment_in_bytes
));
1434 type::get_vector (size_t num_units
)
1436 return type (gcc_jit_type_get_vector (get_inner_type (),
1443 return get_context ().new_rvalue (*this, 0);
1449 return get_context ().new_rvalue (*this, 1);
1453 inline struct_::struct_ () : type (NULL
) {}
1454 inline struct_::struct_ (gcc_jit_struct
*inner
) :
1455 type (gcc_jit_struct_as_type (inner
))
1459 inline gcc_jit_struct
*
1460 struct_::get_inner_struct () const
1462 /* Manual downcast: */
1463 return reinterpret_cast<gcc_jit_struct
*> (get_inner_object ());
1467 inline function::function () : object () {}
1468 inline function::function (gcc_jit_function
*inner
)
1469 : object (gcc_jit_function_as_object (inner
))
1472 inline gcc_jit_function
*
1473 function::get_inner_function () const
1475 /* Manual downcast: */
1476 return reinterpret_cast<gcc_jit_function
*> (get_inner_object ());
1480 function::dump_to_dot (const std::string
&path
)
1482 gcc_jit_function_dump_to_dot (get_inner_function (),
1487 function::get_param (int index
) const
1489 return param (gcc_jit_function_get_param (get_inner_function (),
1494 function::new_block ()
1496 return block (gcc_jit_function_new_block (get_inner_function (),
1501 function::new_block (const std::string
&name
)
1503 return block (gcc_jit_function_new_block (get_inner_function (),
1508 function::new_local (type type_
,
1509 const std::string
&name
,
1512 return lvalue (gcc_jit_function_new_local (get_inner_function (),
1513 loc
.get_inner_location (),
1514 type_
.get_inner_type (),
1519 function::get_address (location loc
)
1521 return rvalue (gcc_jit_function_get_address (get_inner_function (),
1522 loc
.get_inner_location ()));
1526 block::get_function () const
1528 return function (gcc_jit_block_get_function ( get_inner_block ()));
1532 block::add_eval (rvalue rvalue
,
1535 gcc_jit_block_add_eval (get_inner_block (),
1536 loc
.get_inner_location (),
1537 rvalue
.get_inner_rvalue ());
1541 block::add_assignment (lvalue lvalue
,
1545 gcc_jit_block_add_assignment (get_inner_block (),
1546 loc
.get_inner_location (),
1547 lvalue
.get_inner_lvalue (),
1548 rvalue
.get_inner_rvalue ());
1552 block::add_assignment_op (lvalue lvalue
,
1553 enum gcc_jit_binary_op op
,
1557 gcc_jit_block_add_assignment_op (get_inner_block (),
1558 loc
.get_inner_location (),
1559 lvalue
.get_inner_lvalue (),
1561 rvalue
.get_inner_rvalue ());
1565 block::add_comment (const std::string
&text
,
1568 gcc_jit_block_add_comment (get_inner_block (),
1569 loc
.get_inner_location (),
1574 block::end_with_conditional (rvalue boolval
,
1579 gcc_jit_block_end_with_conditional (get_inner_block (),
1580 loc
.get_inner_location (),
1581 boolval
.get_inner_rvalue (),
1582 on_true
.get_inner_block (),
1583 on_false
.get_inner_block ());
1587 block::end_with_jump (block target
,
1590 gcc_jit_block_end_with_jump (get_inner_block (),
1591 loc
.get_inner_location (),
1592 target
.get_inner_block ());
1596 block::end_with_return (rvalue rvalue
,
1599 gcc_jit_block_end_with_return (get_inner_block (),
1600 loc
.get_inner_location (),
1601 rvalue
.get_inner_rvalue ());
1605 block::end_with_return (location loc
)
1607 gcc_jit_block_end_with_void_return (get_inner_block (),
1608 loc
.get_inner_location ());
1612 block::end_with_switch (rvalue expr
,
1613 block default_block
,
1614 std::vector
<case_
> cases
,
1617 /* Treat std::vector as an array, relying on it not being resized: */
1618 case_
*as_array_of_wrappers
= &cases
[0];
1620 /* Treat the array as being of the underlying pointers, relying on
1621 the wrapper type being such a pointer internally. */
1622 gcc_jit_case
**as_array_of_ptrs
=
1623 reinterpret_cast<gcc_jit_case
**> (as_array_of_wrappers
);
1624 gcc_jit_block_end_with_switch (get_inner_block (),
1625 loc
.get_inner_location (),
1626 expr
.get_inner_rvalue (),
1627 default_block
.get_inner_block (),
1633 block::add_extended_asm (const std::string
&asm_template
,
1636 return gcc_jit_block_add_extended_asm (get_inner_block (),
1637 loc
.get_inner_location (),
1638 asm_template
.c_str ());
1642 block::end_with_extended_asm_goto (const std::string
&asm_template
,
1643 std::vector
<block
> goto_blocks
,
1644 block
*fallthrough_block
,
1647 /* Treat std::vector as an array, relying on it not being resized: */
1648 block
*as_array_of_wrappers
= &goto_blocks
[0];
1650 /* Treat the array as being of the underlying pointers, relying on
1651 the wrapper type being such a pointer internally. */
1652 gcc_jit_block
**as_array_of_ptrs
=
1653 reinterpret_cast<gcc_jit_block
**> (as_array_of_wrappers
);
1654 return gcc_jit_block_end_with_extended_asm_goto
1655 (get_inner_block (),
1656 loc
.get_inner_location (),
1657 asm_template
.c_str (),
1658 goto_blocks
.size (),
1660 fallthrough_block
? fallthrough_block
->get_inner_block () : NULL
);
1664 block::add_call (function other
,
1667 rvalue c
= get_context ().new_call (other
, loc
);
1672 block::add_call (function other
,
1676 rvalue c
= get_context ().new_call (other
, arg0
, loc
);
1681 block::add_call (function other
,
1682 rvalue arg0
, rvalue arg1
,
1685 rvalue c
= get_context ().new_call (other
, arg0
, arg1
, loc
);
1690 block::add_call (function other
,
1691 rvalue arg0
, rvalue arg1
, rvalue arg2
,
1694 rvalue c
= get_context ().new_call (other
, arg0
, arg1
, arg2
, loc
);
1700 block::add_call (function other
,
1701 rvalue arg0
, rvalue arg1
, rvalue arg2
, rvalue arg3
,
1704 rvalue c
= get_context ().new_call (other
, arg0
, arg1
, arg2
, arg3
, loc
);
1710 function::operator() (location loc
)
1712 return get_context ().new_call (*this, loc
);
1715 function::operator() (rvalue arg0
,
1718 return get_context ().new_call (*this,
1723 function::operator() (rvalue arg0
, rvalue arg1
,
1726 return get_context ().new_call (*this,
1731 function::operator() (rvalue arg0
, rvalue arg1
, rvalue arg2
,
1734 return get_context ().new_call (*this,
1740 inline block::block () : object () {}
1741 inline block::block (gcc_jit_block
*inner
)
1742 : object (gcc_jit_block_as_object (inner
))
1745 inline gcc_jit_block
*
1746 block::get_inner_block () const
1748 /* Manual downcast: */
1749 return reinterpret_cast<gcc_jit_block
*> (get_inner_object ());
1753 inline rvalue::rvalue () : object () {}
1754 inline rvalue::rvalue (gcc_jit_rvalue
*inner
)
1755 : object (gcc_jit_rvalue_as_object (inner
))
1758 inline gcc_jit_rvalue
*
1759 rvalue::get_inner_rvalue () const
1761 /* Manual downcast: */
1762 return reinterpret_cast<gcc_jit_rvalue
*> (get_inner_object ());
1768 return type (gcc_jit_rvalue_get_type (get_inner_rvalue ()));
1772 rvalue::access_field (field field
,
1775 return rvalue (gcc_jit_rvalue_access_field (get_inner_rvalue (),
1776 loc
.get_inner_location (),
1777 field
.get_inner_field ()));
1781 rvalue::dereference_field (field field
,
1784 return lvalue (gcc_jit_rvalue_dereference_field (get_inner_rvalue (),
1785 loc
.get_inner_location (),
1786 field
.get_inner_field ()));
1790 rvalue::dereference (location loc
)
1792 return lvalue (gcc_jit_rvalue_dereference (get_inner_rvalue (),
1793 loc
.get_inner_location ()));
1797 rvalue::cast_to (type type_
,
1800 return get_context ().new_cast (*this, type_
, loc
);
1804 rvalue::operator[] (rvalue index
)
1806 return get_context ().new_array_access (*this, index
);
1810 rvalue::operator[] (int index
)
1812 context ctxt
= get_context ();
1813 type int_t
= ctxt
.get_int_type
<int> ();
1814 return ctxt
.new_array_access (*this,
1815 ctxt
.new_rvalue (int_t
,
1819 // class lvalue : public rvalue
1820 inline lvalue::lvalue () : rvalue () {}
1821 inline lvalue::lvalue (gcc_jit_lvalue
*inner
)
1822 : rvalue (gcc_jit_lvalue_as_rvalue (inner
))
1825 inline gcc_jit_lvalue
*
1826 lvalue::get_inner_lvalue () const
1828 /* Manual downcast: */
1829 return reinterpret_cast<gcc_jit_lvalue
*> (get_inner_object ());
1833 lvalue::access_field (field field
, location loc
)
1835 return lvalue (gcc_jit_lvalue_access_field (get_inner_lvalue (),
1836 loc
.get_inner_location (),
1837 field
.get_inner_field ()));
1841 lvalue::get_address (location loc
)
1843 return rvalue (gcc_jit_lvalue_get_address (get_inner_lvalue (),
1844 loc
.get_inner_location ()));
1848 lvalue::set_initializer (const void *blob
, size_t num_bytes
)
1850 gcc_jit_global_set_initializer (get_inner_lvalue (),
1857 lvalue::set_initializer_rvalue (rvalue init_value
)
1859 return lvalue (gcc_jit_global_set_initializer_rvalue (
1860 get_inner_lvalue (),
1861 init_value
.get_inner_rvalue ()));
1865 context::new_struct_ctor (type type_
,
1866 std::vector
<field
> &fields
,
1867 std::vector
<rvalue
> &values
,
1870 field
*pfields
= nullptr;
1872 pfields
= &fields
[0];
1874 gcc_jit_field
**fields_arr
=
1875 reinterpret_cast<gcc_jit_field
**> (pfields
);
1877 rvalue
*pvalues
= nullptr;
1879 pvalues
= &values
[0];
1881 gcc_jit_rvalue
**values_arr
=
1882 reinterpret_cast<gcc_jit_rvalue
**> (pvalues
);
1885 gcc_jit_context_new_struct_constructor (
1887 loc
.get_inner_location (),
1888 type_
.get_inner_type (),
1889 (int)values
.size (),
1895 context::new_array_ctor (type type_
,
1896 std::vector
<rvalue
> &values
,
1899 rvalue
*pvalues
= nullptr;
1901 pvalues
= &values
[0];
1903 gcc_jit_rvalue
**values_arr
=
1904 reinterpret_cast<gcc_jit_rvalue
**> (pvalues
);
1907 gcc_jit_context_new_array_constructor (
1909 loc
.get_inner_location (),
1910 type_
.get_inner_type (),
1911 (int)values
.size (),
1916 context::new_union_ctor (type type_
,
1922 gcc_jit_context_new_union_constructor (
1924 loc
.get_inner_location (),
1925 type_
.get_inner_type (),
1926 field
.get_inner_field (),
1927 value
.get_inner_rvalue ()));
1931 // class param : public lvalue
1932 inline param::param () : lvalue () {}
1933 inline param::param (gcc_jit_param
*inner
)
1934 : lvalue (gcc_jit_param_as_lvalue (inner
))
1937 // class case_ : public object
1938 inline case_::case_ () : object () {}
1939 inline case_::case_ (gcc_jit_case
*inner
)
1940 : object (gcc_jit_case_as_object (inner
))
1944 inline gcc_jit_case
*
1945 case_::get_inner_case () const
1947 /* Manual downcast: */
1948 return reinterpret_cast<gcc_jit_case
*> (get_inner_object ());
1951 // class extended_asm : public object
1952 inline extended_asm::extended_asm () : object () {}
1953 inline extended_asm::extended_asm (gcc_jit_extended_asm
*inner
)
1954 : object (gcc_jit_extended_asm_as_object (inner
))
1958 inline extended_asm
&
1959 extended_asm::set_volatile_flag (bool flag
)
1961 gcc_jit_extended_asm_set_volatile_flag (get_inner_extended_asm (), flag
);
1965 inline extended_asm
&
1966 extended_asm::set_inline_flag (bool flag
)
1968 gcc_jit_extended_asm_set_inline_flag (get_inner_extended_asm (), flag
);
1972 inline extended_asm
&
1973 extended_asm::add_output_operand (const std::string
&asm_symbolic_name
,
1974 const std::string
&constraint
,
1975 gccjit::lvalue dest
)
1977 gcc_jit_extended_asm_add_output_operand
1978 (get_inner_extended_asm (),
1979 asm_symbolic_name
.c_str (),
1980 constraint
.c_str (),
1981 dest
.get_inner_lvalue ());
1985 inline extended_asm
&
1986 extended_asm::add_output_operand (const std::string
&constraint
,
1987 gccjit::lvalue dest
)
1989 gcc_jit_extended_asm_add_output_operand
1990 (get_inner_extended_asm (),
1991 NULL
, /* asm_symbolic_name */
1992 constraint
.c_str (),
1993 dest
.get_inner_lvalue ());
1997 inline extended_asm
&
1998 extended_asm::add_input_operand (const std::string
&asm_symbolic_name
,
1999 const std::string
&constraint
,
2002 gcc_jit_extended_asm_add_input_operand
2003 (get_inner_extended_asm (),
2004 asm_symbolic_name
.c_str (),
2005 constraint
.c_str (),
2006 src
.get_inner_rvalue ());
2010 inline extended_asm
&
2011 extended_asm::add_input_operand (const std::string
&constraint
,
2014 gcc_jit_extended_asm_add_input_operand
2015 (get_inner_extended_asm (),
2016 NULL
, /* asm_symbolic_name */
2017 constraint
.c_str (),
2018 src
.get_inner_rvalue ());
2022 inline extended_asm
&
2023 extended_asm::add_clobber (const std::string
&victim
)
2025 gcc_jit_extended_asm_add_clobber (get_inner_extended_asm (),
2030 inline gcc_jit_extended_asm
*
2031 extended_asm::get_inner_extended_asm () const
2033 /* Manual downcast: */
2034 return reinterpret_cast<gcc_jit_extended_asm
*> (get_inner_object ());
2037 /* Overloaded operators. */
2039 inline rvalue
operator- (rvalue a
)
2041 return a
.get_context ().new_minus (a
.get_type (), a
);
2043 inline rvalue
operator~ (rvalue a
)
2045 return a
.get_context ().new_bitwise_negate (a
.get_type (), a
);
2047 inline rvalue
operator! (rvalue a
)
2049 return a
.get_context ().new_logical_negate (a
.get_type (), a
);
2053 inline rvalue
operator+ (rvalue a
, rvalue b
)
2055 return a
.get_context ().new_plus (a
.get_type (), a
, b
);
2057 inline rvalue
operator- (rvalue a
, rvalue b
)
2059 return a
.get_context ().new_minus (a
.get_type (), a
, b
);
2061 inline rvalue
operator* (rvalue a
, rvalue b
)
2063 return a
.get_context ().new_mult (a
.get_type (), a
, b
);
2065 inline rvalue
operator/ (rvalue a
, rvalue b
)
2067 return a
.get_context ().new_divide (a
.get_type (), a
, b
);
2069 inline rvalue
operator% (rvalue a
, rvalue b
)
2071 return a
.get_context ().new_modulo (a
.get_type (), a
, b
);
2073 inline rvalue
operator& (rvalue a
, rvalue b
)
2075 return a
.get_context ().new_bitwise_and (a
.get_type (), a
, b
);
2077 inline rvalue
operator^ (rvalue a
, rvalue b
)
2079 return a
.get_context ().new_bitwise_xor (a
.get_type (), a
, b
);
2081 inline rvalue
operator| (rvalue a
, rvalue b
)
2083 return a
.get_context ().new_bitwise_or (a
.get_type (), a
, b
);
2085 inline rvalue
operator&& (rvalue a
, rvalue b
)
2087 return a
.get_context ().new_logical_and (a
.get_type (), a
, b
);
2089 inline rvalue
operator|| (rvalue a
, rvalue b
)
2091 return a
.get_context ().new_logical_or (a
.get_type (), a
, b
);
2095 inline rvalue
operator== (rvalue a
, rvalue b
)
2097 return a
.get_context ().new_eq (a
, b
);
2099 inline rvalue
operator!= (rvalue a
, rvalue b
)
2101 return a
.get_context ().new_ne (a
, b
);
2103 inline rvalue
operator< (rvalue a
, rvalue b
)
2105 return a
.get_context ().new_lt (a
, b
);
2107 inline rvalue
operator<= (rvalue a
, rvalue b
)
2109 return a
.get_context ().new_le (a
, b
);
2111 inline rvalue
operator> (rvalue a
, rvalue b
)
2113 return a
.get_context ().new_gt (a
, b
);
2115 inline rvalue
operator>= (rvalue a
, rvalue b
)
2117 return a
.get_context ().new_ge (a
, b
);
2120 /* Dereferencing. */
2121 inline lvalue
operator* (rvalue ptr
)
2123 return ptr
.dereference ();
2130 m_inner_timer
= gcc_jit_timer_new ();
2134 timer::timer (gcc_jit_timer
*inner_timer
)
2136 m_inner_timer
= inner_timer
;
2140 timer::push (const char *item_name
)
2142 gcc_jit_timer_push (m_inner_timer
, item_name
);
2147 timer::pop (const char *item_name
)
2149 gcc_jit_timer_pop (m_inner_timer
, item_name
);
2153 timer::print (FILE *f_out
) const
2155 gcc_jit_timer_print (m_inner_timer
, f_out
);
2158 inline gcc_jit_timer
*
2159 timer::get_inner_timer () const
2161 return m_inner_timer
;
2167 gcc_jit_timer_release (m_inner_timer
);
2168 m_inner_timer
= NULL
;
2174 auto_time::auto_time (timer t
, const char *item_name
)
2176 m_item_name (item_name
)
2182 auto_time::auto_time (context ctxt
, const char *item_name
)
2183 : m_timer (ctxt
.get_timer ()),
2184 m_item_name (item_name
)
2186 m_timer
.push (item_name
);
2190 auto_time::~auto_time ()
2192 m_timer
.pop (m_item_name
);
2200 return gcc_jit_version_major ();
2206 return gcc_jit_version_minor ();
2212 return gcc_jit_version_patchlevel ();
2214 } // namespace version
2215 } // namespace gccjit
2217 #endif /* #ifndef LIBGCCJIT_PLUS_PLUS_H */