1 /* Internals of libgccjit: classes for recording calls made to the JIT API.
2 Copyright (C) 2013-2015 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef JIT_RECORDING_H
22 #define JIT_RECORDING_H
24 #include "jit-common.h"
25 #include "jit-logging.h"
35 /**********************************************************************
37 **********************************************************************/
42 playback_location (replayer
*r
, location
*loc
);
45 playback_string (string
*str
);
48 playback_block (block
*b
);
50 /* A recording of a call to gcc_jit_context_enable_dump. */
53 const char *m_dumpname
;
57 /* A JIT-compilation context. */
58 class context
: public log_user
61 context (context
*parent_ctxt
);
65 get_builtins_manager ();
67 void record (memento
*m
);
68 void replay_into (replayer
*r
);
69 void disassociate_from_playback ();
72 new_string (const char *text
);
75 new_location (const char *filename
,
78 bool created_by_user
);
81 get_type (enum gcc_jit_types type
);
84 get_int_type (int num_bytes
, int is_signed
);
87 new_array_type (location
*loc
,
92 new_field (location
*loc
,
97 new_struct_type (location
*loc
,
101 new_union_type (location
*loc
,
105 new_function_type (type
*return_type
,
111 new_function_ptr_type (location
*loc
,
118 new_param (location
*loc
,
123 new_function (location
*loc
,
124 enum gcc_jit_function_kind kind
,
130 enum built_in_function builtin_id
);
133 get_builtin_function (const char *name
);
136 new_global (location
*loc
,
137 enum gcc_jit_global_kind kind
,
141 template <typename HOST_TYPE
>
143 new_rvalue_from_const (type
*type
,
147 new_string_literal (const char *value
);
150 new_unary_op (location
*loc
,
151 enum gcc_jit_unary_op op
,
156 new_binary_op (location
*loc
,
157 enum gcc_jit_binary_op op
,
159 rvalue
*a
, rvalue
*b
);
162 new_comparison (location
*loc
,
163 enum gcc_jit_comparison op
,
164 rvalue
*a
, rvalue
*b
);
167 new_call (location
*loc
,
169 int numargs
, rvalue
**args
);
172 new_call_through_ptr (location
*loc
,
174 int numargs
, rvalue
**args
);
177 new_cast (location
*loc
,
182 new_array_access (location
*loc
,
187 set_str_option (enum gcc_jit_str_option opt
,
191 set_int_option (enum gcc_jit_int_option opt
,
195 set_bool_option (enum gcc_jit_bool_option opt
,
199 enable_dump (const char *dumpname
,
203 get_str_option (enum gcc_jit_str_option opt
) const
205 return m_str_options
[opt
];
209 get_int_option (enum gcc_jit_int_option opt
) const
211 return m_int_options
[opt
];
215 get_bool_option (enum gcc_jit_bool_option opt
) const
217 return m_bool_options
[opt
];
224 compile_to_file (enum gcc_jit_output_kind output_kind
,
225 const char *output_path
);
228 add_error (location
*loc
, const char *fmt
, ...)
232 add_error_va (location
*loc
, const char *fmt
, va_list ap
)
236 get_first_error () const;
239 get_last_error () const;
241 bool errors_occurred () const
244 if (m_parent_ctxt
->errors_occurred ())
246 return m_error_count
;
249 type
*get_opaque_FILE_type ();
251 void dump_to_file (const char *path
, bool update_locations
);
253 void dump_reproducer_to_file (const char *path
);
256 get_all_requested_dumps (vec
<recording::requested_dump
> *out
);
259 void log_all_options () const;
260 void log_str_option (enum gcc_jit_str_option opt
) const;
261 void log_int_option (enum gcc_jit_int_option opt
) const;
262 void log_bool_option (enum gcc_jit_bool_option opt
) const;
267 context
*m_parent_ctxt
;
269 /* The ultimate ancestor of the contexts within a family tree of
270 contexts. This has itself as its own m_toplevel_ctxt. */
271 context
*m_toplevel_ctxt
;
275 char *m_first_error_str
;
276 bool m_owns_first_error_str
;
278 char *m_last_error_str
;
279 bool m_owns_last_error_str
;
281 char *m_str_options
[GCC_JIT_NUM_STR_OPTIONS
];
282 int m_int_options
[GCC_JIT_NUM_INT_OPTIONS
];
283 bool m_bool_options
[GCC_JIT_NUM_BOOL_OPTIONS
];
285 /* Dumpfiles that were requested via gcc_jit_context_enable_dump. */
286 auto_vec
<requested_dump
> m_requested_dumps
;
288 /* Recorded API usage. */
289 auto_vec
<memento
*> m_mementos
;
291 /* Specific recordings, for use by dump_to_file. */
292 auto_vec
<compound_type
*> m_compound_types
;
293 auto_vec
<global
*> m_globals
;
294 auto_vec
<function
*> m_functions
;
296 type
*m_basic_types
[NUM_GCC_JIT_TYPES
];
299 builtins_manager
*m_builtins_manager
; // lazily created
303 /* An object with lifetime managed by the context i.e.
304 it lives until the context is released, at which
305 point it itself is cleaned up. */
310 virtual ~memento () {}
312 /* Hook for replaying this. */
313 virtual void replay_into (replayer
*r
) = 0;
315 void set_playback_obj (void *obj
) { m_playback_obj
= obj
; }
318 /* Get the context that owns this object.
320 Implements the post-error-checking part of
321 gcc_jit_object_get_context. */
322 context
*get_context () { return m_ctxt
; }
325 as_object () { return this; }
327 /* Debugging hook, for use in generating error messages etc.
328 Implements the post-error-checking part of
329 gcc_jit_object_get_debug_string. */
333 virtual void write_to_dump (dump
&d
);
334 virtual void write_reproducer (reproducer
&r
) = 0;
335 virtual location
*dyn_cast_location () { return NULL
; }
338 memento (context
*ctxt
)
340 m_playback_obj (NULL
),
341 m_debug_string (NULL
)
346 string
*new_string (const char *text
) { return m_ctxt
->new_string (text
); }
349 virtual string
* make_debug_string () = 0;
355 void *m_playback_obj
;
358 string
*m_debug_string
;
361 /* or just use std::string? */
362 class string
: public memento
365 string (context
*ctxt
, const char *text
);
368 const char *c_str () { return m_buffer
; }
370 static string
* from_printf (context
*ctxt
, const char *fmt
, ...)
373 void replay_into (replayer
*) {}
376 string
* make_debug_string ();
377 void write_reproducer (reproducer
&r
);
384 class location
: public memento
387 location (context
*ctxt
, string
*filename
, int line
, int column
,
388 bool created_by_user
)
390 m_filename (filename
),
393 m_created_by_user (created_by_user
)
396 void replay_into (replayer
*r
);
399 playback_location (replayer
*r
)
401 /* Normally during playback, we can walk forwards through the list of
402 recording objects, playing them back. The ordering of recording
403 ensures that everything that a recording object refers to has
404 already been played back, so we can simply look up the relevant
407 Locations are an exception, due to the "write_to_dump" method of
408 recording::statement. This method can set a new location on a
409 statement after the statement is created, and thus the location
410 appears in the context's memento list *after* the statement that
413 In such circumstances, the statement is replayed *before* the location,
414 when the latter doesn't yet have a playback object.
416 Hence we need to ensure that locations have playback objects. */
421 gcc_assert (m_playback_obj
);
422 return static_cast <playback::location
*> (m_playback_obj
);
425 location
*dyn_cast_location () { return this; }
426 bool created_by_user () const { return m_created_by_user
; }
429 string
* make_debug_string ();
430 void write_reproducer (reproducer
&r
);
436 bool m_created_by_user
;
439 class type
: public memento
442 type
*get_pointer ();
444 type
*get_volatile ();
446 /* Get the type obtained when dereferencing this type.
448 This will return NULL if it's not valid to dereference this type.
449 The caller is responsible for setting an error. */
450 virtual type
*dereference () = 0;
453 virtual function_type
*dyn_cast_function_type () { return NULL
; }
454 virtual function_type
*as_a_function_type() { gcc_unreachable (); return NULL
; }
455 virtual struct_
*dyn_cast_struct () { return NULL
; }
457 /* Is it typesafe to copy to this type from rtype? */
458 virtual bool accepts_writes_from (type
*rtype
)
461 return this == rtype
->unqualified ();
464 /* Strip off "const" etc */
465 virtual type
*unqualified ()
470 virtual bool is_int () const = 0;
471 virtual bool is_float () const = 0;
472 virtual bool is_bool () const = 0;
473 virtual type
*is_pointer () = 0;
474 virtual type
*is_array () = 0;
475 virtual bool is_void () const { return false; }
477 bool is_numeric () const
479 return is_int () || is_float () || is_bool ();
485 return static_cast <playback::type
*> (m_playback_obj
);
488 virtual const char *access_as_type (reproducer
&r
);
493 m_pointer_to_this_type (NULL
)
497 type
*m_pointer_to_this_type
;
500 /* Result of "gcc_jit_context_get_type". */
501 class memento_of_get_type
: public type
504 memento_of_get_type (context
*ctxt
,
505 enum gcc_jit_types kind
)
509 type
*dereference ();
511 bool accepts_writes_from (type
*rtype
)
513 if (m_kind
== GCC_JIT_TYPE_VOID_PTR
)
514 if (rtype
->is_pointer ())
516 /* LHS (this) is type (void *), and the RHS is a pointer:
521 return type::accepts_writes_from (rtype
);
524 bool is_int () const;
525 bool is_float () const;
526 bool is_bool () const;
527 type
*is_pointer () { return dereference (); }
528 type
*is_array () { return NULL
; }
529 bool is_void () const { return m_kind
== GCC_JIT_TYPE_VOID
; }
532 void replay_into (replayer
*r
);
535 string
* make_debug_string ();
536 void write_reproducer (reproducer
&r
);
539 enum gcc_jit_types m_kind
;
542 /* Result of "gcc_jit_type_get_pointer". */
543 class memento_of_get_pointer
: public type
546 memento_of_get_pointer (type
*other_type
)
547 : type (other_type
->m_ctxt
),
548 m_other_type (other_type
) {}
550 type
*dereference () { return m_other_type
; }
552 bool accepts_writes_from (type
*rtype
);
554 void replay_into (replayer
*r
);
556 bool is_int () const { return false; }
557 bool is_float () const { return false; }
558 bool is_bool () const { return false; }
559 type
*is_pointer () { return m_other_type
; }
560 type
*is_array () { return NULL
; }
563 string
* make_debug_string ();
564 void write_reproducer (reproducer
&r
);
570 /* Result of "gcc_jit_type_get_const". */
571 class memento_of_get_const
: public type
574 memento_of_get_const (type
*other_type
)
575 : type (other_type
->m_ctxt
),
576 m_other_type (other_type
) {}
578 type
*dereference () { return m_other_type
->dereference (); }
580 bool accepts_writes_from (type */
*rtype*/
)
582 /* Can't write to a "const". */
586 /* Strip off the "const", giving the underlying type. */
587 type
*unqualified () { return m_other_type
; }
589 bool is_int () const { return m_other_type
->is_int (); }
590 bool is_float () const { return m_other_type
->is_float (); }
591 bool is_bool () const { return m_other_type
->is_bool (); }
592 type
*is_pointer () { return m_other_type
->is_pointer (); }
593 type
*is_array () { return m_other_type
->is_array (); }
595 void replay_into (replayer
*);
598 string
* make_debug_string ();
599 void write_reproducer (reproducer
&r
);
605 /* Result of "gcc_jit_type_get_volatile". */
606 class memento_of_get_volatile
: public type
609 memento_of_get_volatile (type
*other_type
)
610 : type (other_type
->m_ctxt
),
611 m_other_type (other_type
) {}
613 type
*dereference () { return m_other_type
->dereference (); }
615 /* Strip off the "volatile", giving the underlying type. */
616 type
*unqualified () { return m_other_type
; }
618 bool is_int () const { return m_other_type
->is_int (); }
619 bool is_float () const { return m_other_type
->is_float (); }
620 bool is_bool () const { return m_other_type
->is_bool (); }
621 type
*is_pointer () { return m_other_type
->is_pointer (); }
622 type
*is_array () { return m_other_type
->is_array (); }
624 void replay_into (replayer
*);
627 string
* make_debug_string ();
628 void write_reproducer (reproducer
&r
);
634 class array_type
: public type
637 array_type (context
*ctxt
,
643 m_element_type (element_type
),
644 m_num_elements (num_elements
)
647 type
*dereference ();
649 bool is_int () const { return false; }
650 bool is_float () const { return false; }
651 bool is_bool () const { return false; }
652 type
*is_pointer () { return NULL
; }
653 type
*is_array () { return m_element_type
; }
655 void replay_into (replayer
*);
658 string
* make_debug_string ();
659 void write_reproducer (reproducer
&r
);
663 type
*m_element_type
;
667 class function_type
: public type
670 function_type (context
*ctxt
,
676 type
*dereference ();
677 function_type
*dyn_cast_function_type () { return this; }
678 function_type
*as_a_function_type () { return this; }
680 bool is_int () const { return false; }
681 bool is_float () const { return false; }
682 bool is_bool () const { return false; }
683 type
*is_pointer () { return NULL
; }
684 type
*is_array () { return NULL
; }
686 void replay_into (replayer
*);
688 type
* get_return_type () const { return m_return_type
; }
689 const vec
<type
*> &get_param_types () const { return m_param_types
; }
690 int is_variadic () const { return m_is_variadic
; }
692 string
* make_debug_string_with_ptr ();
695 write_deferred_reproducer (reproducer
&r
,
699 string
* make_debug_string ();
700 string
* make_debug_string_with (const char *);
701 void write_reproducer (reproducer
&r
);
705 auto_vec
<type
*> m_param_types
;
709 class field
: public memento
712 field (context
*ctxt
,
723 type
* get_type () const { return m_type
; }
725 compound_type
* get_container () const { return m_container
; }
726 void set_container (compound_type
*c
) { m_container
= c
; }
728 void replay_into (replayer
*);
730 void write_to_dump (dump
&d
);
733 playback_field () const
735 return static_cast <playback::field
*> (m_playback_obj
);
739 string
* make_debug_string ();
740 void write_reproducer (reproducer
&r
);
746 compound_type
*m_container
;
749 /* Base class for struct_ and union_ */
750 class compound_type
: public type
753 compound_type (context
*ctxt
,
757 string
*get_name () const { return m_name
; }
758 location
*get_loc () const { return m_loc
; }
759 fields
* get_fields () { return m_fields
; }
762 set_fields (location
*loc
,
766 type
*dereference ();
768 bool is_int () const { return false; }
769 bool is_float () const { return false; }
770 bool is_bool () const { return false; }
771 type
*is_pointer () { return NULL
; }
772 type
*is_array () { return NULL
; }
774 playback::compound_type
*
775 playback_compound_type ()
777 return static_cast <playback::compound_type
*> (m_playback_obj
);
786 class struct_
: public compound_type
789 struct_ (context
*ctxt
,
793 struct_
*dyn_cast_struct () { return this; }
796 as_type () { return this; }
798 void replay_into (replayer
*r
);
800 const char *access_as_type (reproducer
&r
);
803 string
* make_debug_string ();
804 void write_reproducer (reproducer
&r
);
807 // memento of struct_::set_fields
808 class fields
: public memento
811 fields (compound_type
*struct_or_union
,
815 void replay_into (replayer
*r
);
817 void write_to_dump (dump
&d
);
819 int length () const { return m_fields
.length (); }
820 field
*get_field (int i
) const { return m_fields
[i
]; }
823 string
* make_debug_string ();
824 void write_reproducer (reproducer
&r
);
827 compound_type
*m_struct_or_union
;
828 auto_vec
<field
*> m_fields
;
831 class union_
: public compound_type
834 union_ (context
*ctxt
,
838 void replay_into (replayer
*r
);
841 string
* make_debug_string ();
842 void write_reproducer (reproducer
&r
);
849 /* An abstract base class for operations that visit all rvalues within an
851 Currently the only implementation is class rvalue_usage_validator within
857 virtual ~rvalue_visitor () {}
858 virtual void visit (rvalue
*rvalue
) = 0;
861 class rvalue
: public memento
864 rvalue (context
*ctxt
,
875 location
* get_loc () const { return m_loc
; }
877 /* Get the recording::type of this rvalue.
879 Implements the post-error-checking part of
880 gcc_jit_rvalue_get_type. */
881 type
* get_type () const { return m_type
; }
884 playback_rvalue () const
886 return static_cast <playback::rvalue
*> (m_playback_obj
);
889 access_field (location
*loc
,
893 dereference_field (location
*loc
,
897 dereference (location
*loc
);
900 verify_valid_within_stmt (const char *api_funcname
, statement
*s
);
902 virtual void visit_children (rvalue_visitor
*v
) = 0;
904 void set_scope (function
*scope
);
905 function
*get_scope () const { return m_scope
; }
908 virtual param
*dyn_cast_param () { return NULL
; }
910 virtual const char *access_as_rvalue (reproducer
&r
);
917 function
*m_scope
; /* NULL for globals, non-NULL for locals/params */
920 class lvalue
: public rvalue
923 lvalue (context
*ctxt
,
926 : rvalue (ctxt
, loc
, type_
)
930 playback_lvalue () const
932 return static_cast <playback::lvalue
*> (m_playback_obj
);
936 access_field (location
*loc
,
940 get_address (location
*loc
);
943 as_rvalue () { return this; }
945 const char *access_as_rvalue (reproducer
&r
);
946 virtual const char *access_as_lvalue (reproducer
&r
);
949 class param
: public lvalue
952 param (context
*ctxt
,
956 : lvalue (ctxt
, loc
, type
),
960 as_lvalue () { return this; }
962 void replay_into (replayer
*r
);
964 void visit_children (rvalue_visitor
*) {}
967 playback_param () const
969 return static_cast <playback::param
*> (m_playback_obj
);
972 param
*dyn_cast_param () { return this; }
974 const char *access_as_rvalue (reproducer
&r
);
975 const char *access_as_lvalue (reproducer
&r
);
978 string
* make_debug_string () { return m_name
; }
979 void write_reproducer (reproducer
&r
);
985 class function
: public memento
988 function (context
*ctxt
,
990 enum gcc_jit_function_kind kind
,
996 enum built_in_function builtin_id
);
998 void replay_into (replayer
*r
);
1000 playback::function
*
1001 playback_function () const
1003 return static_cast <playback::function
*> (m_playback_obj
);
1006 enum gcc_jit_function_kind
get_kind () const { return m_kind
; }
1009 new_local (location
*loc
,
1014 new_block (const char *name
);
1016 location
*get_loc () const { return m_loc
; }
1017 type
*get_return_type () const { return m_return_type
; }
1018 string
* get_name () const { return m_name
; }
1019 const vec
<param
*> &get_params () const { return m_params
; }
1021 /* Get the given param by index.
1022 Implements the post-error-checking part of
1023 gcc_jit_function_get_param. */
1024 param
*get_param (int i
) const { return m_params
[i
]; }
1026 bool is_variadic () const { return m_is_variadic
; }
1028 void write_to_dump (dump
&d
);
1032 void dump_to_dot (const char *path
);
1035 string
* make_debug_string ();
1036 void write_reproducer (reproducer
&r
);
1040 enum gcc_jit_function_kind m_kind
;
1041 type
*m_return_type
;
1043 auto_vec
<param
*> m_params
;
1045 enum built_in_function m_builtin_id
;
1046 auto_vec
<local
*> m_locals
;
1047 auto_vec
<block
*> m_blocks
;
1050 class block
: public memento
1053 block (function
*func
, int index
, string
*name
)
1054 : memento (func
->m_ctxt
),
1059 m_has_been_terminated (false),
1060 m_is_reachable (false)
1064 /* Get the recording::function containing this block.
1065 Implements the post-error-checking part of
1066 gcc_jit_block_get_function. */
1067 function
*get_function () { return m_func
; }
1069 bool has_been_terminated () { return m_has_been_terminated
; }
1070 bool is_reachable () { return m_is_reachable
; }
1073 add_eval (location
*loc
,
1077 add_assignment (location
*loc
,
1082 add_assignment_op (location
*loc
,
1084 enum gcc_jit_binary_op op
,
1088 add_comment (location
*loc
,
1092 end_with_conditional (location
*loc
,
1098 end_with_jump (location
*loc
,
1102 end_with_return (location
*loc
,
1106 playback_block () const
1108 return static_cast <playback::block
*> (m_playback_obj
);
1111 void write_to_dump (dump
&d
);
1115 location
*get_loc () const;
1117 statement
*get_first_statement () const;
1118 statement
*get_last_statement () const;
1120 int get_successor_blocks (block
**next1
, block
**next2
) const;
1123 string
* make_debug_string ();
1124 void write_reproducer (reproducer
&r
);
1126 void replay_into (replayer
*r
);
1128 void dump_to_dot (pretty_printer
*pp
);
1129 void dump_edges_to_dot (pretty_printer
*pp
);
1135 auto_vec
<statement
*> m_statements
;
1136 bool m_has_been_terminated
;
1137 bool m_is_reachable
;
1139 friend class function
;
1142 class global
: public lvalue
1145 global (context
*ctxt
,
1147 enum gcc_jit_global_kind kind
,
1150 : lvalue (ctxt
, loc
, type
),
1155 void replay_into (replayer
*);
1157 void visit_children (rvalue_visitor
*) {}
1159 void write_to_dump (dump
&d
);
1162 string
* make_debug_string () { return m_name
; }
1163 void write_reproducer (reproducer
&r
);
1166 enum gcc_jit_global_kind m_kind
;
1170 template <typename HOST_TYPE
>
1171 class memento_of_new_rvalue_from_const
: public rvalue
1174 memento_of_new_rvalue_from_const (context
*ctxt
,
1178 : rvalue (ctxt
, loc
, type
),
1181 void replay_into (replayer
*r
);
1183 void visit_children (rvalue_visitor
*) {}
1186 string
* make_debug_string ();
1187 void write_reproducer (reproducer
&r
);
1193 class memento_of_new_string_literal
: public rvalue
1196 memento_of_new_string_literal (context
*ctxt
,
1199 : rvalue (ctxt
, loc
, ctxt
->get_type (GCC_JIT_TYPE_CONST_CHAR_PTR
)),
1202 void replay_into (replayer
*r
);
1204 void visit_children (rvalue_visitor
*) {}
1207 string
* make_debug_string ();
1208 void write_reproducer (reproducer
&r
);
1214 class unary_op
: public rvalue
1217 unary_op (context
*ctxt
,
1219 enum gcc_jit_unary_op op
,
1222 : rvalue (ctxt
, loc
, result_type
),
1227 void replay_into (replayer
*r
);
1229 void visit_children (rvalue_visitor
*v
);
1232 string
* make_debug_string ();
1233 void write_reproducer (reproducer
&r
);
1236 enum gcc_jit_unary_op m_op
;
1240 class binary_op
: public rvalue
1243 binary_op (context
*ctxt
,
1245 enum gcc_jit_binary_op op
,
1247 rvalue
*a
, rvalue
*b
)
1248 : rvalue (ctxt
, loc
, result_type
),
1253 void replay_into (replayer
*r
);
1255 void visit_children (rvalue_visitor
*v
);
1258 string
* make_debug_string ();
1259 void write_reproducer (reproducer
&r
);
1262 enum gcc_jit_binary_op m_op
;
1267 class comparison
: public rvalue
1270 comparison (context
*ctxt
,
1272 enum gcc_jit_comparison op
,
1273 rvalue
*a
, rvalue
*b
)
1274 : rvalue (ctxt
, loc
, ctxt
->get_type (GCC_JIT_TYPE_BOOL
)),
1280 void replay_into (replayer
*r
);
1282 void visit_children (rvalue_visitor
*v
);
1285 string
* make_debug_string ();
1286 void write_reproducer (reproducer
&r
);
1289 enum gcc_jit_comparison m_op
;
1294 class cast
: public rvalue
1297 cast (context
*ctxt
,
1301 : rvalue (ctxt
, loc
, type_
),
1305 void replay_into (replayer
*r
);
1307 void visit_children (rvalue_visitor
*v
);
1310 string
* make_debug_string ();
1311 void write_reproducer (reproducer
&r
);
1317 class call
: public rvalue
1320 call (context
*ctxt
,
1326 void replay_into (replayer
*r
);
1328 void visit_children (rvalue_visitor
*v
);
1331 string
* make_debug_string ();
1332 void write_reproducer (reproducer
&r
);
1336 auto_vec
<rvalue
*> m_args
;
1339 class call_through_ptr
: public rvalue
1342 call_through_ptr (context
*ctxt
,
1348 void replay_into (replayer
*r
);
1350 void visit_children (rvalue_visitor
*v
);
1353 string
* make_debug_string ();
1354 void write_reproducer (reproducer
&r
);
1358 auto_vec
<rvalue
*> m_args
;
1361 class array_access
: public lvalue
1364 array_access (context
*ctxt
,
1368 : lvalue (ctxt
, loc
, ptr
->get_type ()->dereference ()),
1373 void replay_into (replayer
*r
);
1375 void visit_children (rvalue_visitor
*v
);
1378 string
* make_debug_string ();
1379 void write_reproducer (reproducer
&r
);
1386 class access_field_of_lvalue
: public lvalue
1389 access_field_of_lvalue (context
*ctxt
,
1393 : lvalue (ctxt
, loc
, field
->get_type ()),
1398 void replay_into (replayer
*r
);
1400 void visit_children (rvalue_visitor
*v
);
1403 string
* make_debug_string ();
1404 void write_reproducer (reproducer
&r
);
1411 class access_field_rvalue
: public rvalue
1414 access_field_rvalue (context
*ctxt
,
1418 : rvalue (ctxt
, loc
, field
->get_type ()),
1423 void replay_into (replayer
*r
);
1425 void visit_children (rvalue_visitor
*v
);
1428 string
* make_debug_string ();
1429 void write_reproducer (reproducer
&r
);
1436 class dereference_field_rvalue
: public lvalue
1439 dereference_field_rvalue (context
*ctxt
,
1443 : lvalue (ctxt
, loc
, field
->get_type ()),
1448 void replay_into (replayer
*r
);
1450 void visit_children (rvalue_visitor
*v
);
1453 string
* make_debug_string ();
1454 void write_reproducer (reproducer
&r
);
1461 class dereference_rvalue
: public lvalue
1464 dereference_rvalue (context
*ctxt
,
1467 : lvalue (ctxt
, loc
, val
->get_type ()->dereference ()),
1470 void replay_into (replayer
*r
);
1472 void visit_children (rvalue_visitor
*v
);
1475 string
* make_debug_string ();
1476 void write_reproducer (reproducer
&r
);
1482 class get_address_of_lvalue
: public rvalue
1485 get_address_of_lvalue (context
*ctxt
,
1488 : rvalue (ctxt
, loc
, val
->get_type ()->get_pointer ()),
1492 void replay_into (replayer
*r
);
1494 void visit_children (rvalue_visitor
*v
);
1497 string
* make_debug_string ();
1498 void write_reproducer (reproducer
&r
);
1504 class local
: public lvalue
1507 local (function
*func
, location
*loc
, type
*type_
, string
*name
)
1508 : lvalue (func
->m_ctxt
, loc
, type_
),
1515 void replay_into (replayer
*r
);
1517 void visit_children (rvalue_visitor
*) {}
1519 void write_to_dump (dump
&d
);
1522 string
* make_debug_string () { return m_name
; }
1523 void write_reproducer (reproducer
&r
);
1530 class statement
: public memento
1533 virtual int get_successor_blocks (block
**out_next1
,
1534 block
**out_next2
) const;
1536 void write_to_dump (dump
&d
);
1538 block
*get_block () const { return m_block
; }
1539 location
*get_loc () const { return m_loc
; }
1542 statement (block
*b
, location
*loc
)
1543 : memento (b
->m_ctxt
),
1547 playback::location
*
1548 playback_location (replayer
*r
) const
1550 return ::gcc::jit::recording::playback_location (r
, m_loc
);
1558 class eval
: public statement
1564 : statement (b
, loc
),
1565 m_rvalue (rvalue
) {}
1567 void replay_into (replayer
*r
);
1570 string
* make_debug_string ();
1571 void write_reproducer (reproducer
&r
);
1577 class assignment
: public statement
1580 assignment (block
*b
,
1584 : statement (b
, loc
),
1586 m_rvalue (rvalue
) {}
1588 void replay_into (replayer
*r
);
1591 string
* make_debug_string ();
1592 void write_reproducer (reproducer
&r
);
1599 class assignment_op
: public statement
1602 assignment_op (block
*b
,
1605 enum gcc_jit_binary_op op
,
1607 : statement (b
, loc
),
1610 m_rvalue (rvalue
) {}
1612 void replay_into (replayer
*r
);
1615 string
* make_debug_string ();
1616 void write_reproducer (reproducer
&r
);
1620 enum gcc_jit_binary_op m_op
;
1624 class comment
: public statement
1630 : statement (b
, loc
),
1633 void replay_into (replayer
*r
);
1636 string
* make_debug_string ();
1637 void write_reproducer (reproducer
&r
);
1643 class conditional
: public statement
1646 conditional (block
*b
,
1651 : statement (b
, loc
),
1652 m_boolval (boolval
),
1653 m_on_true (on_true
),
1654 m_on_false (on_false
) {}
1656 void replay_into (replayer
*r
);
1658 int get_successor_blocks (block
**out_next1
,
1659 block
**out_next2
) const;
1662 string
* make_debug_string ();
1663 void write_reproducer (reproducer
&r
);
1671 class jump
: public statement
1677 : statement (b
, loc
),
1678 m_target (target
) {}
1680 void replay_into (replayer
*r
);
1682 int get_successor_blocks (block
**out_next1
,
1683 block
**out_next2
) const;
1686 string
* make_debug_string ();
1687 void write_reproducer (reproducer
&r
);
1693 class return_
: public statement
1699 : statement (b
, loc
),
1700 m_rvalue (rvalue
) {}
1702 void replay_into (replayer
*r
);
1704 int get_successor_blocks (block
**out_next1
,
1705 block
**out_next2
) const;
1708 string
* make_debug_string ();
1709 void write_reproducer (reproducer
&r
);
1715 } // namespace gcc::jit::recording
1717 /* Create a recording::memento_of_new_rvalue_from_const instance and add
1718 it to this context's list of mementos.
1720 Implements the post-error-checking part of
1721 gcc_jit_context_new_rvalue_from_{int|long|double|ptr}. */
1723 template <typename HOST_TYPE
>
1725 recording::context::new_rvalue_from_const (recording::type
*type
,
1728 recording::rvalue
*result
=
1729 new memento_of_new_rvalue_from_const
<HOST_TYPE
> (this, NULL
, type
, value
);
1734 } // namespace gcc::jit
1738 #endif /* JIT_RECORDING_H */