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 set_inner_bool_option (enum inner_bool_option inner_opt
,
203 add_command_line_option (const char *optname
);
206 append_command_line_options (vec
<char *> *argvec
);
209 enable_dump (const char *dumpname
,
213 get_str_option (enum gcc_jit_str_option opt
) const
215 return m_str_options
[opt
];
219 get_int_option (enum gcc_jit_int_option opt
) const
221 return m_int_options
[opt
];
225 get_bool_option (enum gcc_jit_bool_option opt
) const
227 return m_bool_options
[opt
];
231 get_inner_bool_option (enum inner_bool_option opt
) const
233 return m_inner_bool_options
[opt
];
240 compile_to_file (enum gcc_jit_output_kind output_kind
,
241 const char *output_path
);
244 add_error (location
*loc
, const char *fmt
, ...)
248 add_error_va (location
*loc
, const char *fmt
, va_list ap
)
252 get_first_error () const;
255 get_last_error () const;
257 bool errors_occurred () const
260 if (m_parent_ctxt
->errors_occurred ())
262 return m_error_count
;
265 type
*get_opaque_FILE_type ();
267 void dump_to_file (const char *path
, bool update_locations
);
269 void dump_reproducer_to_file (const char *path
);
272 get_all_requested_dumps (vec
<recording::requested_dump
> *out
);
275 void log_all_options () const;
276 void log_str_option (enum gcc_jit_str_option opt
) const;
277 void log_int_option (enum gcc_jit_int_option opt
) const;
278 void log_bool_option (enum gcc_jit_bool_option opt
) const;
279 void log_inner_bool_option (enum inner_bool_option opt
) const;
284 context
*m_parent_ctxt
;
286 /* The ultimate ancestor of the contexts within a family tree of
287 contexts. This has itself as its own m_toplevel_ctxt. */
288 context
*m_toplevel_ctxt
;
292 char *m_first_error_str
;
293 bool m_owns_first_error_str
;
295 char *m_last_error_str
;
296 bool m_owns_last_error_str
;
298 char *m_str_options
[GCC_JIT_NUM_STR_OPTIONS
];
299 int m_int_options
[GCC_JIT_NUM_INT_OPTIONS
];
300 bool m_bool_options
[GCC_JIT_NUM_BOOL_OPTIONS
];
301 bool m_inner_bool_options
[NUM_INNER_BOOL_OPTIONS
];
302 auto_vec
<char *> m_command_line_options
;
304 /* Dumpfiles that were requested via gcc_jit_context_enable_dump. */
305 auto_vec
<requested_dump
> m_requested_dumps
;
307 /* Recorded API usage. */
308 auto_vec
<memento
*> m_mementos
;
310 /* Specific recordings, for use by dump_to_file. */
311 auto_vec
<compound_type
*> m_compound_types
;
312 auto_vec
<global
*> m_globals
;
313 auto_vec
<function
*> m_functions
;
315 type
*m_basic_types
[NUM_GCC_JIT_TYPES
];
318 builtins_manager
*m_builtins_manager
; // lazily created
322 /* An object with lifetime managed by the context i.e.
323 it lives until the context is released, at which
324 point it itself is cleaned up. */
329 virtual ~memento () {}
331 /* Hook for replaying this. */
332 virtual void replay_into (replayer
*r
) = 0;
334 void set_playback_obj (void *obj
) { m_playback_obj
= obj
; }
337 /* Get the context that owns this object.
339 Implements the post-error-checking part of
340 gcc_jit_object_get_context. */
341 context
*get_context () { return m_ctxt
; }
344 as_object () { return this; }
346 /* Debugging hook, for use in generating error messages etc.
347 Implements the post-error-checking part of
348 gcc_jit_object_get_debug_string. */
352 virtual void write_to_dump (dump
&d
);
353 virtual void write_reproducer (reproducer
&r
) = 0;
354 virtual location
*dyn_cast_location () { return NULL
; }
357 memento (context
*ctxt
)
359 m_playback_obj (NULL
),
360 m_debug_string (NULL
)
365 string
*new_string (const char *text
) { return m_ctxt
->new_string (text
); }
368 virtual string
* make_debug_string () = 0;
374 void *m_playback_obj
;
377 string
*m_debug_string
;
380 /* or just use std::string? */
381 class string
: public memento
384 string (context
*ctxt
, const char *text
);
387 const char *c_str () { return m_buffer
; }
389 static string
* from_printf (context
*ctxt
, const char *fmt
, ...)
392 void replay_into (replayer
*) {}
395 string
* make_debug_string ();
396 void write_reproducer (reproducer
&r
);
403 class location
: public memento
406 location (context
*ctxt
, string
*filename
, int line
, int column
,
407 bool created_by_user
)
409 m_filename (filename
),
412 m_created_by_user (created_by_user
)
415 void replay_into (replayer
*r
);
418 playback_location (replayer
*r
)
420 /* Normally during playback, we can walk forwards through the list of
421 recording objects, playing them back. The ordering of recording
422 ensures that everything that a recording object refers to has
423 already been played back, so we can simply look up the relevant
426 Locations are an exception, due to the "write_to_dump" method of
427 recording::statement. This method can set a new location on a
428 statement after the statement is created, and thus the location
429 appears in the context's memento list *after* the statement that
432 In such circumstances, the statement is replayed *before* the location,
433 when the latter doesn't yet have a playback object.
435 Hence we need to ensure that locations have playback objects. */
440 gcc_assert (m_playback_obj
);
441 return static_cast <playback::location
*> (m_playback_obj
);
444 location
*dyn_cast_location () { return this; }
445 bool created_by_user () const { return m_created_by_user
; }
448 string
* make_debug_string ();
449 void write_reproducer (reproducer
&r
);
455 bool m_created_by_user
;
458 class type
: public memento
461 type
*get_pointer ();
463 type
*get_volatile ();
465 /* Get the type obtained when dereferencing this type.
467 This will return NULL if it's not valid to dereference this type.
468 The caller is responsible for setting an error. */
469 virtual type
*dereference () = 0;
472 virtual function_type
*dyn_cast_function_type () { return NULL
; }
473 virtual function_type
*as_a_function_type() { gcc_unreachable (); return NULL
; }
474 virtual struct_
*dyn_cast_struct () { return NULL
; }
476 /* Is it typesafe to copy to this type from rtype? */
477 virtual bool accepts_writes_from (type
*rtype
)
480 return this == rtype
->unqualified ();
483 /* Strip off "const" etc */
484 virtual type
*unqualified ()
489 virtual bool is_int () const = 0;
490 virtual bool is_float () const = 0;
491 virtual bool is_bool () const = 0;
492 virtual type
*is_pointer () = 0;
493 virtual type
*is_array () = 0;
494 virtual bool is_void () const { return false; }
496 bool is_numeric () const
498 return is_int () || is_float () || is_bool ();
504 return static_cast <playback::type
*> (m_playback_obj
);
507 virtual const char *access_as_type (reproducer
&r
);
512 m_pointer_to_this_type (NULL
)
516 type
*m_pointer_to_this_type
;
519 /* Result of "gcc_jit_context_get_type". */
520 class memento_of_get_type
: public type
523 memento_of_get_type (context
*ctxt
,
524 enum gcc_jit_types kind
)
528 type
*dereference ();
530 bool accepts_writes_from (type
*rtype
)
532 if (m_kind
== GCC_JIT_TYPE_VOID_PTR
)
533 if (rtype
->is_pointer ())
535 /* LHS (this) is type (void *), and the RHS is a pointer:
540 return type::accepts_writes_from (rtype
);
543 bool is_int () const;
544 bool is_float () const;
545 bool is_bool () const;
546 type
*is_pointer () { return dereference (); }
547 type
*is_array () { return NULL
; }
548 bool is_void () const { return m_kind
== GCC_JIT_TYPE_VOID
; }
551 void replay_into (replayer
*r
);
554 string
* make_debug_string ();
555 void write_reproducer (reproducer
&r
);
558 enum gcc_jit_types m_kind
;
561 /* Result of "gcc_jit_type_get_pointer". */
562 class memento_of_get_pointer
: public type
565 memento_of_get_pointer (type
*other_type
)
566 : type (other_type
->m_ctxt
),
567 m_other_type (other_type
) {}
569 type
*dereference () { return m_other_type
; }
571 bool accepts_writes_from (type
*rtype
);
573 void replay_into (replayer
*r
);
575 bool is_int () const { return false; }
576 bool is_float () const { return false; }
577 bool is_bool () const { return false; }
578 type
*is_pointer () { return m_other_type
; }
579 type
*is_array () { return NULL
; }
582 string
* make_debug_string ();
583 void write_reproducer (reproducer
&r
);
589 /* Result of "gcc_jit_type_get_const". */
590 class memento_of_get_const
: public type
593 memento_of_get_const (type
*other_type
)
594 : type (other_type
->m_ctxt
),
595 m_other_type (other_type
) {}
597 type
*dereference () { return m_other_type
->dereference (); }
599 bool accepts_writes_from (type */
*rtype*/
)
601 /* Can't write to a "const". */
605 /* Strip off the "const", giving the underlying type. */
606 type
*unqualified () { return m_other_type
; }
608 bool is_int () const { return m_other_type
->is_int (); }
609 bool is_float () const { return m_other_type
->is_float (); }
610 bool is_bool () const { return m_other_type
->is_bool (); }
611 type
*is_pointer () { return m_other_type
->is_pointer (); }
612 type
*is_array () { return m_other_type
->is_array (); }
614 void replay_into (replayer
*);
617 string
* make_debug_string ();
618 void write_reproducer (reproducer
&r
);
624 /* Result of "gcc_jit_type_get_volatile". */
625 class memento_of_get_volatile
: public type
628 memento_of_get_volatile (type
*other_type
)
629 : type (other_type
->m_ctxt
),
630 m_other_type (other_type
) {}
632 type
*dereference () { return m_other_type
->dereference (); }
634 /* Strip off the "volatile", giving the underlying type. */
635 type
*unqualified () { return m_other_type
; }
637 bool is_int () const { return m_other_type
->is_int (); }
638 bool is_float () const { return m_other_type
->is_float (); }
639 bool is_bool () const { return m_other_type
->is_bool (); }
640 type
*is_pointer () { return m_other_type
->is_pointer (); }
641 type
*is_array () { return m_other_type
->is_array (); }
643 void replay_into (replayer
*);
646 string
* make_debug_string ();
647 void write_reproducer (reproducer
&r
);
653 class array_type
: public type
656 array_type (context
*ctxt
,
662 m_element_type (element_type
),
663 m_num_elements (num_elements
)
666 type
*dereference ();
668 bool is_int () const { return false; }
669 bool is_float () const { return false; }
670 bool is_bool () const { return false; }
671 type
*is_pointer () { return NULL
; }
672 type
*is_array () { return m_element_type
; }
674 void replay_into (replayer
*);
677 string
* make_debug_string ();
678 void write_reproducer (reproducer
&r
);
682 type
*m_element_type
;
686 class function_type
: public type
689 function_type (context
*ctxt
,
695 type
*dereference ();
696 function_type
*dyn_cast_function_type () { return this; }
697 function_type
*as_a_function_type () { return this; }
699 bool is_int () const { return false; }
700 bool is_float () const { return false; }
701 bool is_bool () const { return false; }
702 type
*is_pointer () { return NULL
; }
703 type
*is_array () { return NULL
; }
705 void replay_into (replayer
*);
707 type
* get_return_type () const { return m_return_type
; }
708 const vec
<type
*> &get_param_types () const { return m_param_types
; }
709 int is_variadic () const { return m_is_variadic
; }
711 string
* make_debug_string_with_ptr ();
714 write_deferred_reproducer (reproducer
&r
,
718 string
* make_debug_string ();
719 string
* make_debug_string_with (const char *);
720 void write_reproducer (reproducer
&r
);
724 auto_vec
<type
*> m_param_types
;
728 class field
: public memento
731 field (context
*ctxt
,
742 type
* get_type () const { return m_type
; }
744 compound_type
* get_container () const { return m_container
; }
745 void set_container (compound_type
*c
) { m_container
= c
; }
747 void replay_into (replayer
*);
749 void write_to_dump (dump
&d
);
752 playback_field () const
754 return static_cast <playback::field
*> (m_playback_obj
);
758 string
* make_debug_string ();
759 void write_reproducer (reproducer
&r
);
765 compound_type
*m_container
;
768 /* Base class for struct_ and union_ */
769 class compound_type
: public type
772 compound_type (context
*ctxt
,
776 string
*get_name () const { return m_name
; }
777 location
*get_loc () const { return m_loc
; }
778 fields
* get_fields () { return m_fields
; }
781 set_fields (location
*loc
,
785 type
*dereference ();
787 bool is_int () const { return false; }
788 bool is_float () const { return false; }
789 bool is_bool () const { return false; }
790 type
*is_pointer () { return NULL
; }
791 type
*is_array () { return NULL
; }
793 playback::compound_type
*
794 playback_compound_type ()
796 return static_cast <playback::compound_type
*> (m_playback_obj
);
805 class struct_
: public compound_type
808 struct_ (context
*ctxt
,
812 struct_
*dyn_cast_struct () { return this; }
815 as_type () { return this; }
817 void replay_into (replayer
*r
);
819 const char *access_as_type (reproducer
&r
);
822 string
* make_debug_string ();
823 void write_reproducer (reproducer
&r
);
826 // memento of struct_::set_fields
827 class fields
: public memento
830 fields (compound_type
*struct_or_union
,
834 void replay_into (replayer
*r
);
836 void write_to_dump (dump
&d
);
838 int length () const { return m_fields
.length (); }
839 field
*get_field (int i
) const { return m_fields
[i
]; }
842 string
* make_debug_string ();
843 void write_reproducer (reproducer
&r
);
846 compound_type
*m_struct_or_union
;
847 auto_vec
<field
*> m_fields
;
850 class union_
: public compound_type
853 union_ (context
*ctxt
,
857 void replay_into (replayer
*r
);
860 string
* make_debug_string ();
861 void write_reproducer (reproducer
&r
);
868 /* An abstract base class for operations that visit all rvalues within an
870 Currently the only implementation is class rvalue_usage_validator within
876 virtual ~rvalue_visitor () {}
877 virtual void visit (rvalue
*rvalue
) = 0;
880 /* When generating debug strings for rvalues we mimic C, so we need to
881 mimic C's precedence levels when handling compound expressions.
882 These are in order from strongest precedence to weakest. */
889 PRECEDENCE_MULTIPLICATIVE
,
892 PRECEDENCE_RELATIONAL
,
894 PRECEDENCE_BITWISE_AND
,
895 PRECEDENCE_BITWISE_XOR
,
896 PRECEDENCE_BITWISE_IOR
,
897 PRECEDENCE_LOGICAL_AND
,
898 PRECEDENCE_LOGICAL_OR
901 class rvalue
: public memento
904 rvalue (context
*ctxt
,
911 m_parenthesized_string (NULL
)
916 location
* get_loc () const { return m_loc
; }
918 /* Get the recording::type of this rvalue.
920 Implements the post-error-checking part of
921 gcc_jit_rvalue_get_type. */
922 type
* get_type () const { return m_type
; }
925 playback_rvalue () const
927 return static_cast <playback::rvalue
*> (m_playback_obj
);
930 access_field (location
*loc
,
934 dereference_field (location
*loc
,
938 dereference (location
*loc
);
941 verify_valid_within_stmt (const char *api_funcname
, statement
*s
);
943 virtual void visit_children (rvalue_visitor
*v
) = 0;
945 void set_scope (function
*scope
);
946 function
*get_scope () const { return m_scope
; }
949 virtual param
*dyn_cast_param () { return NULL
; }
951 virtual const char *access_as_rvalue (reproducer
&r
);
953 /* Get the debug string, wrapped in parentheses. */
955 get_debug_string_parens (enum precedence outer_prec
);
958 virtual enum precedence
get_precedence () const = 0;
965 function
*m_scope
; /* NULL for globals, non-NULL for locals/params */
966 string
*m_parenthesized_string
;
969 class lvalue
: public rvalue
972 lvalue (context
*ctxt
,
975 : rvalue (ctxt
, loc
, type_
)
979 playback_lvalue () const
981 return static_cast <playback::lvalue
*> (m_playback_obj
);
985 access_field (location
*loc
,
989 get_address (location
*loc
);
992 as_rvalue () { return this; }
994 const char *access_as_rvalue (reproducer
&r
);
995 virtual const char *access_as_lvalue (reproducer
&r
);
998 class param
: public lvalue
1001 param (context
*ctxt
,
1005 : lvalue (ctxt
, loc
, type
),
1009 as_lvalue () { return this; }
1011 void replay_into (replayer
*r
);
1013 void visit_children (rvalue_visitor
*) {}
1016 playback_param () const
1018 return static_cast <playback::param
*> (m_playback_obj
);
1021 param
*dyn_cast_param () { return this; }
1023 const char *access_as_rvalue (reproducer
&r
);
1024 const char *access_as_lvalue (reproducer
&r
);
1027 string
* make_debug_string () { return m_name
; }
1028 void write_reproducer (reproducer
&r
);
1029 enum precedence
get_precedence () const { return PRECEDENCE_PRIMARY
; }
1035 class function
: public memento
1038 function (context
*ctxt
,
1040 enum gcc_jit_function_kind kind
,
1046 enum built_in_function builtin_id
);
1048 void replay_into (replayer
*r
);
1050 playback::function
*
1051 playback_function () const
1053 return static_cast <playback::function
*> (m_playback_obj
);
1056 enum gcc_jit_function_kind
get_kind () const { return m_kind
; }
1059 new_local (location
*loc
,
1064 new_block (const char *name
);
1066 location
*get_loc () const { return m_loc
; }
1067 type
*get_return_type () const { return m_return_type
; }
1068 string
* get_name () const { return m_name
; }
1069 const vec
<param
*> &get_params () const { return m_params
; }
1071 /* Get the given param by index.
1072 Implements the post-error-checking part of
1073 gcc_jit_function_get_param. */
1074 param
*get_param (int i
) const { return m_params
[i
]; }
1076 bool is_variadic () const { return m_is_variadic
; }
1078 void write_to_dump (dump
&d
);
1082 void dump_to_dot (const char *path
);
1085 string
* make_debug_string ();
1086 void write_reproducer (reproducer
&r
);
1090 enum gcc_jit_function_kind m_kind
;
1091 type
*m_return_type
;
1093 auto_vec
<param
*> m_params
;
1095 enum built_in_function m_builtin_id
;
1096 auto_vec
<local
*> m_locals
;
1097 auto_vec
<block
*> m_blocks
;
1100 class block
: public memento
1103 block (function
*func
, int index
, string
*name
)
1104 : memento (func
->m_ctxt
),
1109 m_has_been_terminated (false),
1110 m_is_reachable (false)
1114 /* Get the recording::function containing this block.
1115 Implements the post-error-checking part of
1116 gcc_jit_block_get_function. */
1117 function
*get_function () { return m_func
; }
1119 bool has_been_terminated () { return m_has_been_terminated
; }
1120 bool is_reachable () { return m_is_reachable
; }
1123 add_eval (location
*loc
,
1127 add_assignment (location
*loc
,
1132 add_assignment_op (location
*loc
,
1134 enum gcc_jit_binary_op op
,
1138 add_comment (location
*loc
,
1142 end_with_conditional (location
*loc
,
1148 end_with_jump (location
*loc
,
1152 end_with_return (location
*loc
,
1156 playback_block () const
1158 return static_cast <playback::block
*> (m_playback_obj
);
1161 void write_to_dump (dump
&d
);
1165 location
*get_loc () const;
1167 statement
*get_first_statement () const;
1168 statement
*get_last_statement () const;
1170 int get_successor_blocks (block
**next1
, block
**next2
) const;
1173 string
* make_debug_string ();
1174 void write_reproducer (reproducer
&r
);
1176 void replay_into (replayer
*r
);
1178 void dump_to_dot (pretty_printer
*pp
);
1179 void dump_edges_to_dot (pretty_printer
*pp
);
1185 auto_vec
<statement
*> m_statements
;
1186 bool m_has_been_terminated
;
1187 bool m_is_reachable
;
1189 friend class function
;
1192 class global
: public lvalue
1195 global (context
*ctxt
,
1197 enum gcc_jit_global_kind kind
,
1200 : lvalue (ctxt
, loc
, type
),
1205 void replay_into (replayer
*);
1207 void visit_children (rvalue_visitor
*) {}
1209 void write_to_dump (dump
&d
);
1212 string
* make_debug_string () { return m_name
; }
1213 void write_reproducer (reproducer
&r
);
1214 enum precedence
get_precedence () const { return PRECEDENCE_PRIMARY
; }
1217 enum gcc_jit_global_kind m_kind
;
1221 template <typename HOST_TYPE
>
1222 class memento_of_new_rvalue_from_const
: public rvalue
1225 memento_of_new_rvalue_from_const (context
*ctxt
,
1229 : rvalue (ctxt
, loc
, type
),
1232 void replay_into (replayer
*r
);
1234 void visit_children (rvalue_visitor
*) {}
1237 string
* make_debug_string ();
1238 void write_reproducer (reproducer
&r
);
1239 enum precedence
get_precedence () const { return PRECEDENCE_PRIMARY
; }
1245 class memento_of_new_string_literal
: public rvalue
1248 memento_of_new_string_literal (context
*ctxt
,
1251 : rvalue (ctxt
, loc
, ctxt
->get_type (GCC_JIT_TYPE_CONST_CHAR_PTR
)),
1254 void replay_into (replayer
*r
);
1256 void visit_children (rvalue_visitor
*) {}
1259 string
* make_debug_string ();
1260 void write_reproducer (reproducer
&r
);
1261 enum precedence
get_precedence () const { return PRECEDENCE_PRIMARY
; }
1267 class unary_op
: public rvalue
1270 unary_op (context
*ctxt
,
1272 enum gcc_jit_unary_op op
,
1275 : rvalue (ctxt
, loc
, result_type
),
1280 void replay_into (replayer
*r
);
1282 void visit_children (rvalue_visitor
*v
);
1285 string
* make_debug_string ();
1286 void write_reproducer (reproducer
&r
);
1287 enum precedence
get_precedence () const {return PRECEDENCE_UNARY
;}
1290 enum gcc_jit_unary_op m_op
;
1294 class binary_op
: public rvalue
1297 binary_op (context
*ctxt
,
1299 enum gcc_jit_binary_op op
,
1301 rvalue
*a
, rvalue
*b
)
1302 : rvalue (ctxt
, loc
, result_type
),
1307 void replay_into (replayer
*r
);
1309 void visit_children (rvalue_visitor
*v
);
1312 string
* make_debug_string ();
1313 void write_reproducer (reproducer
&r
);
1314 enum precedence
get_precedence () const;
1317 enum gcc_jit_binary_op m_op
;
1322 class comparison
: public rvalue
1325 comparison (context
*ctxt
,
1327 enum gcc_jit_comparison op
,
1328 rvalue
*a
, rvalue
*b
)
1329 : rvalue (ctxt
, loc
, ctxt
->get_type (GCC_JIT_TYPE_BOOL
)),
1335 void replay_into (replayer
*r
);
1337 void visit_children (rvalue_visitor
*v
);
1340 string
* make_debug_string ();
1341 void write_reproducer (reproducer
&r
);
1342 enum precedence
get_precedence () const;
1345 enum gcc_jit_comparison m_op
;
1350 class cast
: public rvalue
1353 cast (context
*ctxt
,
1357 : rvalue (ctxt
, loc
, type_
),
1361 void replay_into (replayer
*r
);
1363 void visit_children (rvalue_visitor
*v
);
1366 string
* make_debug_string ();
1367 void write_reproducer (reproducer
&r
);
1368 enum precedence
get_precedence () const { return PRECEDENCE_CAST
; }
1374 class call
: public rvalue
1377 call (context
*ctxt
,
1383 void replay_into (replayer
*r
);
1385 void visit_children (rvalue_visitor
*v
);
1388 string
* make_debug_string ();
1389 void write_reproducer (reproducer
&r
);
1390 enum precedence
get_precedence () const { return PRECEDENCE_POSTFIX
; }
1394 auto_vec
<rvalue
*> m_args
;
1397 class call_through_ptr
: public rvalue
1400 call_through_ptr (context
*ctxt
,
1406 void replay_into (replayer
*r
);
1408 void visit_children (rvalue_visitor
*v
);
1411 string
* make_debug_string ();
1412 void write_reproducer (reproducer
&r
);
1413 enum precedence
get_precedence () const { return PRECEDENCE_POSTFIX
; }
1417 auto_vec
<rvalue
*> m_args
;
1420 class array_access
: public lvalue
1423 array_access (context
*ctxt
,
1427 : lvalue (ctxt
, loc
, ptr
->get_type ()->dereference ()),
1432 void replay_into (replayer
*r
);
1434 void visit_children (rvalue_visitor
*v
);
1437 string
* make_debug_string ();
1438 void write_reproducer (reproducer
&r
);
1439 enum precedence
get_precedence () const { return PRECEDENCE_POSTFIX
; }
1446 class access_field_of_lvalue
: public lvalue
1449 access_field_of_lvalue (context
*ctxt
,
1453 : lvalue (ctxt
, loc
, field
->get_type ()),
1458 void replay_into (replayer
*r
);
1460 void visit_children (rvalue_visitor
*v
);
1463 string
* make_debug_string ();
1464 void write_reproducer (reproducer
&r
);
1465 enum precedence
get_precedence () const { return PRECEDENCE_POSTFIX
; }
1472 class access_field_rvalue
: public rvalue
1475 access_field_rvalue (context
*ctxt
,
1479 : rvalue (ctxt
, loc
, field
->get_type ()),
1484 void replay_into (replayer
*r
);
1486 void visit_children (rvalue_visitor
*v
);
1489 string
* make_debug_string ();
1490 void write_reproducer (reproducer
&r
);
1491 enum precedence
get_precedence () const { return PRECEDENCE_POSTFIX
; }
1498 class dereference_field_rvalue
: public lvalue
1501 dereference_field_rvalue (context
*ctxt
,
1505 : lvalue (ctxt
, loc
, field
->get_type ()),
1510 void replay_into (replayer
*r
);
1512 void visit_children (rvalue_visitor
*v
);
1515 string
* make_debug_string ();
1516 void write_reproducer (reproducer
&r
);
1517 enum precedence
get_precedence () const { return PRECEDENCE_POSTFIX
; }
1524 class dereference_rvalue
: public lvalue
1527 dereference_rvalue (context
*ctxt
,
1530 : lvalue (ctxt
, loc
, val
->get_type ()->dereference ()),
1533 void replay_into (replayer
*r
);
1535 void visit_children (rvalue_visitor
*v
);
1538 string
* make_debug_string ();
1539 void write_reproducer (reproducer
&r
);
1540 enum precedence
get_precedence () const { return PRECEDENCE_UNARY
; }
1546 class get_address_of_lvalue
: public rvalue
1549 get_address_of_lvalue (context
*ctxt
,
1552 : rvalue (ctxt
, loc
, val
->get_type ()->get_pointer ()),
1556 void replay_into (replayer
*r
);
1558 void visit_children (rvalue_visitor
*v
);
1561 string
* make_debug_string ();
1562 void write_reproducer (reproducer
&r
);
1563 enum precedence
get_precedence () const { return PRECEDENCE_UNARY
; }
1569 class local
: public lvalue
1572 local (function
*func
, location
*loc
, type
*type_
, string
*name
)
1573 : lvalue (func
->m_ctxt
, loc
, type_
),
1580 void replay_into (replayer
*r
);
1582 void visit_children (rvalue_visitor
*) {}
1584 void write_to_dump (dump
&d
);
1587 string
* make_debug_string () { return m_name
; }
1588 void write_reproducer (reproducer
&r
);
1589 enum precedence
get_precedence () const { return PRECEDENCE_PRIMARY
; }
1596 class statement
: public memento
1599 virtual int get_successor_blocks (block
**out_next1
,
1600 block
**out_next2
) const;
1602 void write_to_dump (dump
&d
);
1604 block
*get_block () const { return m_block
; }
1605 location
*get_loc () const { return m_loc
; }
1608 statement (block
*b
, location
*loc
)
1609 : memento (b
->m_ctxt
),
1613 playback::location
*
1614 playback_location (replayer
*r
) const
1616 return ::gcc::jit::recording::playback_location (r
, m_loc
);
1624 class eval
: public statement
1630 : statement (b
, loc
),
1631 m_rvalue (rvalue
) {}
1633 void replay_into (replayer
*r
);
1636 string
* make_debug_string ();
1637 void write_reproducer (reproducer
&r
);
1643 class assignment
: public statement
1646 assignment (block
*b
,
1650 : statement (b
, loc
),
1652 m_rvalue (rvalue
) {}
1654 void replay_into (replayer
*r
);
1657 string
* make_debug_string ();
1658 void write_reproducer (reproducer
&r
);
1665 class assignment_op
: public statement
1668 assignment_op (block
*b
,
1671 enum gcc_jit_binary_op op
,
1673 : statement (b
, loc
),
1676 m_rvalue (rvalue
) {}
1678 void replay_into (replayer
*r
);
1681 string
* make_debug_string ();
1682 void write_reproducer (reproducer
&r
);
1686 enum gcc_jit_binary_op m_op
;
1690 class comment
: public statement
1696 : statement (b
, loc
),
1699 void replay_into (replayer
*r
);
1702 string
* make_debug_string ();
1703 void write_reproducer (reproducer
&r
);
1709 class conditional
: public statement
1712 conditional (block
*b
,
1717 : statement (b
, loc
),
1718 m_boolval (boolval
),
1719 m_on_true (on_true
),
1720 m_on_false (on_false
) {}
1722 void replay_into (replayer
*r
);
1724 int get_successor_blocks (block
**out_next1
,
1725 block
**out_next2
) const;
1728 string
* make_debug_string ();
1729 void write_reproducer (reproducer
&r
);
1737 class jump
: public statement
1743 : statement (b
, loc
),
1744 m_target (target
) {}
1746 void replay_into (replayer
*r
);
1748 int get_successor_blocks (block
**out_next1
,
1749 block
**out_next2
) const;
1752 string
* make_debug_string ();
1753 void write_reproducer (reproducer
&r
);
1759 class return_
: public statement
1765 : statement (b
, loc
),
1766 m_rvalue (rvalue
) {}
1768 void replay_into (replayer
*r
);
1770 int get_successor_blocks (block
**out_next1
,
1771 block
**out_next2
) const;
1774 string
* make_debug_string ();
1775 void write_reproducer (reproducer
&r
);
1781 } // namespace gcc::jit::recording
1783 /* Create a recording::memento_of_new_rvalue_from_const instance and add
1784 it to this context's list of mementos.
1786 Implements the post-error-checking part of
1787 gcc_jit_context_new_rvalue_from_{int|long|double|ptr}. */
1789 template <typename HOST_TYPE
>
1791 recording::context::new_rvalue_from_const (recording::type
*type
,
1794 recording::rvalue
*result
=
1795 new memento_of_new_rvalue_from_const
<HOST_TYPE
> (this, NULL
, type
, value
);
1800 } // namespace gcc::jit
1804 #endif /* JIT_RECORDING_H */