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"
37 /**********************************************************************
39 **********************************************************************/
44 playback_location (replayer
*r
, location
*loc
);
47 playback_string (string
*str
);
50 playback_block (block
*b
);
52 /* A recording of a call to gcc_jit_context_enable_dump. */
55 const char *m_dumpname
;
59 /* A JIT-compilation context. */
60 class context
: public log_user
63 context (context
*parent_ctxt
);
67 get_builtins_manager ();
69 void record (memento
*m
);
70 void replay_into (replayer
*r
);
71 void disassociate_from_playback ();
74 new_string (const char *text
);
77 new_location (const char *filename
,
80 bool created_by_user
);
83 get_type (enum gcc_jit_types type
);
86 get_int_type (int num_bytes
, int is_signed
);
89 new_array_type (location
*loc
,
94 new_field (location
*loc
,
99 new_struct_type (location
*loc
,
103 new_union_type (location
*loc
,
107 new_function_type (type
*return_type
,
113 new_function_ptr_type (location
*loc
,
120 new_param (location
*loc
,
125 new_function (location
*loc
,
126 enum gcc_jit_function_kind kind
,
132 enum built_in_function builtin_id
);
135 get_builtin_function (const char *name
);
138 new_global (location
*loc
,
139 enum gcc_jit_global_kind kind
,
143 template <typename HOST_TYPE
>
145 new_rvalue_from_const (type
*type
,
149 new_string_literal (const char *value
);
152 new_unary_op (location
*loc
,
153 enum gcc_jit_unary_op op
,
158 new_binary_op (location
*loc
,
159 enum gcc_jit_binary_op op
,
161 rvalue
*a
, rvalue
*b
);
164 new_comparison (location
*loc
,
165 enum gcc_jit_comparison op
,
166 rvalue
*a
, rvalue
*b
);
169 new_call (location
*loc
,
171 int numargs
, rvalue
**args
);
174 new_call_through_ptr (location
*loc
,
176 int numargs
, rvalue
**args
);
179 new_cast (location
*loc
,
184 new_array_access (location
*loc
,
189 new_case (rvalue
*min_value
,
194 set_str_option (enum gcc_jit_str_option opt
,
198 set_int_option (enum gcc_jit_int_option opt
,
202 set_bool_option (enum gcc_jit_bool_option opt
,
206 set_inner_bool_option (enum inner_bool_option inner_opt
,
210 add_command_line_option (const char *optname
);
213 append_command_line_options (vec
<char *> *argvec
);
216 enable_dump (const char *dumpname
,
220 get_str_option (enum gcc_jit_str_option opt
) const
222 return m_str_options
[opt
];
226 get_int_option (enum gcc_jit_int_option opt
) const
228 return m_int_options
[opt
];
232 get_bool_option (enum gcc_jit_bool_option opt
) const
234 return m_bool_options
[opt
];
238 get_inner_bool_option (enum inner_bool_option opt
) const
240 return m_inner_bool_options
[opt
];
247 compile_to_file (enum gcc_jit_output_kind output_kind
,
248 const char *output_path
);
251 add_error (location
*loc
, const char *fmt
, ...)
255 add_error_va (location
*loc
, const char *fmt
, va_list ap
)
259 get_first_error () const;
262 get_last_error () const;
264 bool errors_occurred () const
267 if (m_parent_ctxt
->errors_occurred ())
269 return m_error_count
;
272 type
*get_opaque_FILE_type ();
274 void dump_to_file (const char *path
, bool update_locations
);
276 void dump_reproducer_to_file (const char *path
);
279 get_all_requested_dumps (vec
<recording::requested_dump
> *out
);
281 void set_timer (timer
*t
) { m_timer
= t
; }
282 timer
*get_timer () const { return m_timer
; }
285 void log_all_options () const;
286 void log_str_option (enum gcc_jit_str_option opt
) const;
287 void log_int_option (enum gcc_jit_int_option opt
) const;
288 void log_bool_option (enum gcc_jit_bool_option opt
) const;
289 void log_inner_bool_option (enum inner_bool_option opt
) const;
294 context
*m_parent_ctxt
;
296 /* The ultimate ancestor of the contexts within a family tree of
297 contexts. This has itself as its own m_toplevel_ctxt. */
298 context
*m_toplevel_ctxt
;
304 char *m_first_error_str
;
305 bool m_owns_first_error_str
;
307 char *m_last_error_str
;
308 bool m_owns_last_error_str
;
310 char *m_str_options
[GCC_JIT_NUM_STR_OPTIONS
];
311 int m_int_options
[GCC_JIT_NUM_INT_OPTIONS
];
312 bool m_bool_options
[GCC_JIT_NUM_BOOL_OPTIONS
];
313 bool m_inner_bool_options
[NUM_INNER_BOOL_OPTIONS
];
314 auto_vec
<char *> m_command_line_options
;
316 /* Dumpfiles that were requested via gcc_jit_context_enable_dump. */
317 auto_vec
<requested_dump
> m_requested_dumps
;
319 /* Recorded API usage. */
320 auto_vec
<memento
*> m_mementos
;
322 /* Specific recordings, for use by dump_to_file. */
323 auto_vec
<compound_type
*> m_compound_types
;
324 auto_vec
<global
*> m_globals
;
325 auto_vec
<function
*> m_functions
;
327 type
*m_basic_types
[NUM_GCC_JIT_TYPES
];
330 builtins_manager
*m_builtins_manager
; // lazily created
334 /* An object with lifetime managed by the context i.e.
335 it lives until the context is released, at which
336 point it itself is cleaned up. */
341 virtual ~memento () {}
343 /* Hook for replaying this. */
344 virtual void replay_into (replayer
*r
) = 0;
346 void set_playback_obj (void *obj
) { m_playback_obj
= obj
; }
349 /* Get the context that owns this object.
351 Implements the post-error-checking part of
352 gcc_jit_object_get_context. */
353 context
*get_context () { return m_ctxt
; }
356 as_object () { return this; }
358 /* Debugging hook, for use in generating error messages etc.
359 Implements the post-error-checking part of
360 gcc_jit_object_get_debug_string. */
364 virtual void write_to_dump (dump
&d
);
365 virtual void write_reproducer (reproducer
&r
) = 0;
366 virtual location
*dyn_cast_location () { return NULL
; }
369 memento (context
*ctxt
)
371 m_playback_obj (NULL
),
372 m_debug_string (NULL
)
377 string
*new_string (const char *text
) { return m_ctxt
->new_string (text
); }
380 virtual string
* make_debug_string () = 0;
386 void *m_playback_obj
;
389 string
*m_debug_string
;
392 /* or just use std::string? */
393 class string
: public memento
396 string (context
*ctxt
, const char *text
);
399 const char *c_str () { return m_buffer
; }
401 static string
* from_printf (context
*ctxt
, const char *fmt
, ...)
404 void replay_into (replayer
*) {}
407 string
* make_debug_string ();
408 void write_reproducer (reproducer
&r
);
415 class location
: public memento
418 location (context
*ctxt
, string
*filename
, int line
, int column
,
419 bool created_by_user
)
421 m_filename (filename
),
424 m_created_by_user (created_by_user
)
427 void replay_into (replayer
*r
);
430 playback_location (replayer
*r
)
432 /* Normally during playback, we can walk forwards through the list of
433 recording objects, playing them back. The ordering of recording
434 ensures that everything that a recording object refers to has
435 already been played back, so we can simply look up the relevant
438 Locations are an exception, due to the "write_to_dump" method of
439 recording::statement. This method can set a new location on a
440 statement after the statement is created, and thus the location
441 appears in the context's memento list *after* the statement that
444 In such circumstances, the statement is replayed *before* the location,
445 when the latter doesn't yet have a playback object.
447 Hence we need to ensure that locations have playback objects. */
452 gcc_assert (m_playback_obj
);
453 return static_cast <playback::location
*> (m_playback_obj
);
456 location
*dyn_cast_location () { return this; }
457 bool created_by_user () const { return m_created_by_user
; }
460 string
* make_debug_string ();
461 void write_reproducer (reproducer
&r
);
467 bool m_created_by_user
;
470 class type
: public memento
473 type
*get_pointer ();
475 type
*get_volatile ();
477 /* Get the type obtained when dereferencing this type.
479 This will return NULL if it's not valid to dereference this type.
480 The caller is responsible for setting an error. */
481 virtual type
*dereference () = 0;
484 virtual function_type
*dyn_cast_function_type () { return NULL
; }
485 virtual function_type
*as_a_function_type() { gcc_unreachable (); return NULL
; }
486 virtual struct_
*dyn_cast_struct () { return NULL
; }
488 /* Is it typesafe to copy to this type from rtype? */
489 virtual bool accepts_writes_from (type
*rtype
)
492 return this == rtype
->unqualified ();
495 /* Strip off "const" etc */
496 virtual type
*unqualified ()
501 virtual bool is_int () const = 0;
502 virtual bool is_float () const = 0;
503 virtual bool is_bool () const = 0;
504 virtual type
*is_pointer () = 0;
505 virtual type
*is_array () = 0;
506 virtual bool is_void () const { return false; }
507 virtual bool has_known_size () const { return true; }
509 bool is_numeric () const
511 return is_int () || is_float () || is_bool ();
517 return static_cast <playback::type
*> (m_playback_obj
);
520 virtual const char *access_as_type (reproducer
&r
);
525 m_pointer_to_this_type (NULL
)
529 type
*m_pointer_to_this_type
;
532 /* Result of "gcc_jit_context_get_type". */
533 class memento_of_get_type
: public type
536 memento_of_get_type (context
*ctxt
,
537 enum gcc_jit_types kind
)
541 type
*dereference ();
543 bool accepts_writes_from (type
*rtype
)
545 if (m_kind
== GCC_JIT_TYPE_VOID_PTR
)
546 if (rtype
->is_pointer ())
548 /* LHS (this) is type (void *), and the RHS is a pointer:
553 return type::accepts_writes_from (rtype
);
556 bool is_int () const;
557 bool is_float () const;
558 bool is_bool () const;
559 type
*is_pointer () { return dereference (); }
560 type
*is_array () { return NULL
; }
561 bool is_void () const { return m_kind
== GCC_JIT_TYPE_VOID
; }
564 void replay_into (replayer
*r
);
567 string
* make_debug_string ();
568 void write_reproducer (reproducer
&r
);
571 enum gcc_jit_types m_kind
;
574 /* Result of "gcc_jit_type_get_pointer". */
575 class memento_of_get_pointer
: public type
578 memento_of_get_pointer (type
*other_type
)
579 : type (other_type
->m_ctxt
),
580 m_other_type (other_type
) {}
582 type
*dereference () { return m_other_type
; }
584 bool accepts_writes_from (type
*rtype
);
586 void replay_into (replayer
*r
);
588 bool is_int () const { return false; }
589 bool is_float () const { return false; }
590 bool is_bool () const { return false; }
591 type
*is_pointer () { return m_other_type
; }
592 type
*is_array () { return NULL
; }
595 string
* make_debug_string ();
596 void write_reproducer (reproducer
&r
);
602 /* Result of "gcc_jit_type_get_const". */
603 class memento_of_get_const
: public type
606 memento_of_get_const (type
*other_type
)
607 : type (other_type
->m_ctxt
),
608 m_other_type (other_type
) {}
610 type
*dereference () { return m_other_type
->dereference (); }
612 bool accepts_writes_from (type */
*rtype*/
)
614 /* Can't write to a "const". */
618 /* Strip off the "const", giving the underlying type. */
619 type
*unqualified () { return m_other_type
; }
621 bool is_int () const { return m_other_type
->is_int (); }
622 bool is_float () const { return m_other_type
->is_float (); }
623 bool is_bool () const { return m_other_type
->is_bool (); }
624 type
*is_pointer () { return m_other_type
->is_pointer (); }
625 type
*is_array () { return m_other_type
->is_array (); }
627 void replay_into (replayer
*);
630 string
* make_debug_string ();
631 void write_reproducer (reproducer
&r
);
637 /* Result of "gcc_jit_type_get_volatile". */
638 class memento_of_get_volatile
: public type
641 memento_of_get_volatile (type
*other_type
)
642 : type (other_type
->m_ctxt
),
643 m_other_type (other_type
) {}
645 type
*dereference () { return m_other_type
->dereference (); }
647 /* Strip off the "volatile", giving the underlying type. */
648 type
*unqualified () { return m_other_type
; }
650 bool is_int () const { return m_other_type
->is_int (); }
651 bool is_float () const { return m_other_type
->is_float (); }
652 bool is_bool () const { return m_other_type
->is_bool (); }
653 type
*is_pointer () { return m_other_type
->is_pointer (); }
654 type
*is_array () { return m_other_type
->is_array (); }
656 void replay_into (replayer
*);
659 string
* make_debug_string ();
660 void write_reproducer (reproducer
&r
);
666 class array_type
: public type
669 array_type (context
*ctxt
,
675 m_element_type (element_type
),
676 m_num_elements (num_elements
)
679 type
*dereference ();
681 bool is_int () const { return false; }
682 bool is_float () const { return false; }
683 bool is_bool () const { return false; }
684 type
*is_pointer () { return NULL
; }
685 type
*is_array () { return m_element_type
; }
687 void replay_into (replayer
*);
690 string
* make_debug_string ();
691 void write_reproducer (reproducer
&r
);
695 type
*m_element_type
;
699 class function_type
: public type
702 function_type (context
*ctxt
,
708 type
*dereference ();
709 function_type
*dyn_cast_function_type () { return this; }
710 function_type
*as_a_function_type () { return this; }
712 bool is_int () const { return false; }
713 bool is_float () const { return false; }
714 bool is_bool () const { return false; }
715 type
*is_pointer () { return NULL
; }
716 type
*is_array () { return NULL
; }
718 void replay_into (replayer
*);
720 type
* get_return_type () const { return m_return_type
; }
721 const vec
<type
*> &get_param_types () const { return m_param_types
; }
722 int is_variadic () const { return m_is_variadic
; }
724 string
* make_debug_string_with_ptr ();
727 write_deferred_reproducer (reproducer
&r
,
731 string
* make_debug_string ();
732 string
* make_debug_string_with (const char *);
733 void write_reproducer (reproducer
&r
);
737 auto_vec
<type
*> m_param_types
;
741 class field
: public memento
744 field (context
*ctxt
,
755 type
* get_type () const { return m_type
; }
757 compound_type
* get_container () const { return m_container
; }
758 void set_container (compound_type
*c
) { m_container
= c
; }
760 void replay_into (replayer
*);
762 void write_to_dump (dump
&d
);
765 playback_field () const
767 return static_cast <playback::field
*> (m_playback_obj
);
771 string
* make_debug_string ();
772 void write_reproducer (reproducer
&r
);
778 compound_type
*m_container
;
781 /* Base class for struct_ and union_ */
782 class compound_type
: public type
785 compound_type (context
*ctxt
,
789 string
*get_name () const { return m_name
; }
790 location
*get_loc () const { return m_loc
; }
791 fields
* get_fields () { return m_fields
; }
794 set_fields (location
*loc
,
798 type
*dereference ();
800 bool is_int () const { return false; }
801 bool is_float () const { return false; }
802 bool is_bool () const { return false; }
803 type
*is_pointer () { return NULL
; }
804 type
*is_array () { return NULL
; }
806 bool has_known_size () const { return m_fields
!= NULL
; }
808 playback::compound_type
*
809 playback_compound_type ()
811 return static_cast <playback::compound_type
*> (m_playback_obj
);
820 class struct_
: public compound_type
823 struct_ (context
*ctxt
,
827 struct_
*dyn_cast_struct () { return this; }
830 as_type () { return this; }
832 void replay_into (replayer
*r
);
834 const char *access_as_type (reproducer
&r
);
837 string
* make_debug_string ();
838 void write_reproducer (reproducer
&r
);
841 // memento of struct_::set_fields
842 class fields
: public memento
845 fields (compound_type
*struct_or_union
,
849 void replay_into (replayer
*r
);
851 void write_to_dump (dump
&d
);
853 int length () const { return m_fields
.length (); }
854 field
*get_field (int i
) const { return m_fields
[i
]; }
857 string
* make_debug_string ();
858 void write_reproducer (reproducer
&r
);
861 compound_type
*m_struct_or_union
;
862 auto_vec
<field
*> m_fields
;
865 class union_
: public compound_type
868 union_ (context
*ctxt
,
872 void replay_into (replayer
*r
);
875 string
* make_debug_string ();
876 void write_reproducer (reproducer
&r
);
883 /* An abstract base class for operations that visit all rvalues within an
885 Currently the only implementation is class rvalue_usage_validator within
891 virtual ~rvalue_visitor () {}
892 virtual void visit (rvalue
*rvalue
) = 0;
895 /* When generating debug strings for rvalues we mimic C, so we need to
896 mimic C's precedence levels when handling compound expressions.
897 These are in order from strongest precedence to weakest. */
904 PRECEDENCE_MULTIPLICATIVE
,
907 PRECEDENCE_RELATIONAL
,
909 PRECEDENCE_BITWISE_AND
,
910 PRECEDENCE_BITWISE_XOR
,
911 PRECEDENCE_BITWISE_IOR
,
912 PRECEDENCE_LOGICAL_AND
,
913 PRECEDENCE_LOGICAL_OR
916 class rvalue
: public memento
919 rvalue (context
*ctxt
,
926 m_parenthesized_string (NULL
)
931 location
* get_loc () const { return m_loc
; }
933 /* Get the recording::type of this rvalue.
935 Implements the post-error-checking part of
936 gcc_jit_rvalue_get_type. */
937 type
* get_type () const { return m_type
; }
940 playback_rvalue () const
942 return static_cast <playback::rvalue
*> (m_playback_obj
);
945 access_field (location
*loc
,
949 dereference_field (location
*loc
,
953 dereference (location
*loc
);
956 verify_valid_within_stmt (const char *api_funcname
, statement
*s
);
958 virtual void visit_children (rvalue_visitor
*v
) = 0;
960 void set_scope (function
*scope
);
961 function
*get_scope () const { return m_scope
; }
964 virtual param
*dyn_cast_param () { return NULL
; }
966 virtual const char *access_as_rvalue (reproducer
&r
);
968 /* Get the debug string, wrapped in parentheses. */
970 get_debug_string_parens (enum precedence outer_prec
);
972 virtual bool is_constant () const { return false; }
973 virtual bool get_wide_int (wide_int
*) const { return false; }
976 virtual enum precedence
get_precedence () const = 0;
983 function
*m_scope
; /* NULL for globals, non-NULL for locals/params */
984 string
*m_parenthesized_string
;
987 class lvalue
: public rvalue
990 lvalue (context
*ctxt
,
993 : rvalue (ctxt
, loc
, type_
)
997 playback_lvalue () const
999 return static_cast <playback::lvalue
*> (m_playback_obj
);
1003 access_field (location
*loc
,
1007 get_address (location
*loc
);
1010 as_rvalue () { return this; }
1012 const char *access_as_rvalue (reproducer
&r
);
1013 virtual const char *access_as_lvalue (reproducer
&r
);
1016 class param
: public lvalue
1019 param (context
*ctxt
,
1023 : lvalue (ctxt
, loc
, type
),
1027 as_lvalue () { return this; }
1029 void replay_into (replayer
*r
);
1031 void visit_children (rvalue_visitor
*) {}
1034 playback_param () const
1036 return static_cast <playback::param
*> (m_playback_obj
);
1039 param
*dyn_cast_param () { return this; }
1041 const char *access_as_rvalue (reproducer
&r
);
1042 const char *access_as_lvalue (reproducer
&r
);
1045 string
* make_debug_string () { return m_name
; }
1046 void write_reproducer (reproducer
&r
);
1047 enum precedence
get_precedence () const { return PRECEDENCE_PRIMARY
; }
1053 class function
: public memento
1056 function (context
*ctxt
,
1058 enum gcc_jit_function_kind kind
,
1064 enum built_in_function builtin_id
);
1066 void replay_into (replayer
*r
);
1068 playback::function
*
1069 playback_function () const
1071 return static_cast <playback::function
*> (m_playback_obj
);
1074 enum gcc_jit_function_kind
get_kind () const { return m_kind
; }
1077 new_local (location
*loc
,
1082 new_block (const char *name
);
1084 location
*get_loc () const { return m_loc
; }
1085 type
*get_return_type () const { return m_return_type
; }
1086 string
* get_name () const { return m_name
; }
1087 const vec
<param
*> &get_params () const { return m_params
; }
1089 /* Get the given param by index.
1090 Implements the post-error-checking part of
1091 gcc_jit_function_get_param. */
1092 param
*get_param (int i
) const { return m_params
[i
]; }
1094 bool is_variadic () const { return m_is_variadic
; }
1096 void write_to_dump (dump
&d
);
1100 void dump_to_dot (const char *path
);
1103 string
* make_debug_string ();
1104 void write_reproducer (reproducer
&r
);
1108 enum gcc_jit_function_kind m_kind
;
1109 type
*m_return_type
;
1111 auto_vec
<param
*> m_params
;
1113 enum built_in_function m_builtin_id
;
1114 auto_vec
<local
*> m_locals
;
1115 auto_vec
<block
*> m_blocks
;
1118 class block
: public memento
1121 block (function
*func
, int index
, string
*name
)
1122 : memento (func
->m_ctxt
),
1127 m_has_been_terminated (false),
1128 m_is_reachable (false)
1132 /* Get the recording::function containing this block.
1133 Implements the post-error-checking part of
1134 gcc_jit_block_get_function. */
1135 function
*get_function () { return m_func
; }
1137 bool has_been_terminated () { return m_has_been_terminated
; }
1138 bool is_reachable () { return m_is_reachable
; }
1141 add_eval (location
*loc
,
1145 add_assignment (location
*loc
,
1150 add_assignment_op (location
*loc
,
1152 enum gcc_jit_binary_op op
,
1156 add_comment (location
*loc
,
1160 end_with_conditional (location
*loc
,
1166 end_with_jump (location
*loc
,
1170 end_with_return (location
*loc
,
1174 end_with_switch (location
*loc
,
1176 block
*default_block
,
1181 playback_block () const
1183 return static_cast <playback::block
*> (m_playback_obj
);
1186 void write_to_dump (dump
&d
);
1190 location
*get_loc () const;
1192 statement
*get_first_statement () const;
1193 statement
*get_last_statement () const;
1195 vec
<block
*> get_successor_blocks () const;
1198 string
* make_debug_string ();
1199 void write_reproducer (reproducer
&r
);
1201 void replay_into (replayer
*r
);
1203 void dump_to_dot (pretty_printer
*pp
);
1204 void dump_edges_to_dot (pretty_printer
*pp
);
1210 auto_vec
<statement
*> m_statements
;
1211 bool m_has_been_terminated
;
1212 bool m_is_reachable
;
1214 friend class function
;
1217 class global
: public lvalue
1220 global (context
*ctxt
,
1222 enum gcc_jit_global_kind kind
,
1225 : lvalue (ctxt
, loc
, type
),
1230 void replay_into (replayer
*);
1232 void visit_children (rvalue_visitor
*) {}
1234 void write_to_dump (dump
&d
);
1237 string
* make_debug_string () { return m_name
; }
1238 void write_reproducer (reproducer
&r
);
1239 enum precedence
get_precedence () const { return PRECEDENCE_PRIMARY
; }
1242 enum gcc_jit_global_kind m_kind
;
1246 template <typename HOST_TYPE
>
1247 class memento_of_new_rvalue_from_const
: public rvalue
1250 memento_of_new_rvalue_from_const (context
*ctxt
,
1254 : rvalue (ctxt
, loc
, type
),
1257 void replay_into (replayer
*r
);
1259 void visit_children (rvalue_visitor
*) {}
1261 bool is_constant () const { return true; }
1263 bool get_wide_int (wide_int
*out
) const;
1266 string
* make_debug_string ();
1267 void write_reproducer (reproducer
&r
);
1268 enum precedence
get_precedence () const { return PRECEDENCE_PRIMARY
; }
1274 class memento_of_new_string_literal
: public rvalue
1277 memento_of_new_string_literal (context
*ctxt
,
1280 : rvalue (ctxt
, loc
, ctxt
->get_type (GCC_JIT_TYPE_CONST_CHAR_PTR
)),
1283 void replay_into (replayer
*r
);
1285 void visit_children (rvalue_visitor
*) {}
1288 string
* make_debug_string ();
1289 void write_reproducer (reproducer
&r
);
1290 enum precedence
get_precedence () const { return PRECEDENCE_PRIMARY
; }
1296 class unary_op
: public rvalue
1299 unary_op (context
*ctxt
,
1301 enum gcc_jit_unary_op op
,
1304 : rvalue (ctxt
, loc
, result_type
),
1309 void replay_into (replayer
*r
);
1311 void visit_children (rvalue_visitor
*v
);
1314 string
* make_debug_string ();
1315 void write_reproducer (reproducer
&r
);
1316 enum precedence
get_precedence () const {return PRECEDENCE_UNARY
;}
1319 enum gcc_jit_unary_op m_op
;
1323 class binary_op
: public rvalue
1326 binary_op (context
*ctxt
,
1328 enum gcc_jit_binary_op op
,
1330 rvalue
*a
, rvalue
*b
)
1331 : rvalue (ctxt
, loc
, result_type
),
1336 void replay_into (replayer
*r
);
1338 void visit_children (rvalue_visitor
*v
);
1341 string
* make_debug_string ();
1342 void write_reproducer (reproducer
&r
);
1343 enum precedence
get_precedence () const;
1346 enum gcc_jit_binary_op m_op
;
1351 class comparison
: public rvalue
1354 comparison (context
*ctxt
,
1356 enum gcc_jit_comparison op
,
1357 rvalue
*a
, rvalue
*b
)
1358 : rvalue (ctxt
, loc
, ctxt
->get_type (GCC_JIT_TYPE_BOOL
)),
1364 void replay_into (replayer
*r
);
1366 void visit_children (rvalue_visitor
*v
);
1369 string
* make_debug_string ();
1370 void write_reproducer (reproducer
&r
);
1371 enum precedence
get_precedence () const;
1374 enum gcc_jit_comparison m_op
;
1379 class cast
: public rvalue
1382 cast (context
*ctxt
,
1386 : rvalue (ctxt
, loc
, type_
),
1390 void replay_into (replayer
*r
);
1392 void visit_children (rvalue_visitor
*v
);
1395 string
* make_debug_string ();
1396 void write_reproducer (reproducer
&r
);
1397 enum precedence
get_precedence () const { return PRECEDENCE_CAST
; }
1403 class call
: public rvalue
1406 call (context
*ctxt
,
1412 void replay_into (replayer
*r
);
1414 void visit_children (rvalue_visitor
*v
);
1417 string
* make_debug_string ();
1418 void write_reproducer (reproducer
&r
);
1419 enum precedence
get_precedence () const { return PRECEDENCE_POSTFIX
; }
1423 auto_vec
<rvalue
*> m_args
;
1426 class call_through_ptr
: public rvalue
1429 call_through_ptr (context
*ctxt
,
1435 void replay_into (replayer
*r
);
1437 void visit_children (rvalue_visitor
*v
);
1440 string
* make_debug_string ();
1441 void write_reproducer (reproducer
&r
);
1442 enum precedence
get_precedence () const { return PRECEDENCE_POSTFIX
; }
1446 auto_vec
<rvalue
*> m_args
;
1449 class array_access
: public lvalue
1452 array_access (context
*ctxt
,
1456 : lvalue (ctxt
, loc
, ptr
->get_type ()->dereference ()),
1461 void replay_into (replayer
*r
);
1463 void visit_children (rvalue_visitor
*v
);
1466 string
* make_debug_string ();
1467 void write_reproducer (reproducer
&r
);
1468 enum precedence
get_precedence () const { return PRECEDENCE_POSTFIX
; }
1475 class access_field_of_lvalue
: public lvalue
1478 access_field_of_lvalue (context
*ctxt
,
1482 : lvalue (ctxt
, loc
, field
->get_type ()),
1487 void replay_into (replayer
*r
);
1489 void visit_children (rvalue_visitor
*v
);
1492 string
* make_debug_string ();
1493 void write_reproducer (reproducer
&r
);
1494 enum precedence
get_precedence () const { return PRECEDENCE_POSTFIX
; }
1501 class access_field_rvalue
: public rvalue
1504 access_field_rvalue (context
*ctxt
,
1508 : rvalue (ctxt
, loc
, field
->get_type ()),
1513 void replay_into (replayer
*r
);
1515 void visit_children (rvalue_visitor
*v
);
1518 string
* make_debug_string ();
1519 void write_reproducer (reproducer
&r
);
1520 enum precedence
get_precedence () const { return PRECEDENCE_POSTFIX
; }
1527 class dereference_field_rvalue
: public lvalue
1530 dereference_field_rvalue (context
*ctxt
,
1534 : lvalue (ctxt
, loc
, field
->get_type ()),
1539 void replay_into (replayer
*r
);
1541 void visit_children (rvalue_visitor
*v
);
1544 string
* make_debug_string ();
1545 void write_reproducer (reproducer
&r
);
1546 enum precedence
get_precedence () const { return PRECEDENCE_POSTFIX
; }
1553 class dereference_rvalue
: public lvalue
1556 dereference_rvalue (context
*ctxt
,
1559 : lvalue (ctxt
, loc
, val
->get_type ()->dereference ()),
1562 void replay_into (replayer
*r
);
1564 void visit_children (rvalue_visitor
*v
);
1567 string
* make_debug_string ();
1568 void write_reproducer (reproducer
&r
);
1569 enum precedence
get_precedence () const { return PRECEDENCE_UNARY
; }
1575 class get_address_of_lvalue
: public rvalue
1578 get_address_of_lvalue (context
*ctxt
,
1581 : rvalue (ctxt
, loc
, val
->get_type ()->get_pointer ()),
1585 void replay_into (replayer
*r
);
1587 void visit_children (rvalue_visitor
*v
);
1590 string
* make_debug_string ();
1591 void write_reproducer (reproducer
&r
);
1592 enum precedence
get_precedence () const { return PRECEDENCE_UNARY
; }
1598 class local
: public lvalue
1601 local (function
*func
, location
*loc
, type
*type_
, string
*name
)
1602 : lvalue (func
->m_ctxt
, loc
, type_
),
1609 void replay_into (replayer
*r
);
1611 void visit_children (rvalue_visitor
*) {}
1613 void write_to_dump (dump
&d
);
1616 string
* make_debug_string () { return m_name
; }
1617 void write_reproducer (reproducer
&r
);
1618 enum precedence
get_precedence () const { return PRECEDENCE_PRIMARY
; }
1625 class statement
: public memento
1628 virtual vec
<block
*> get_successor_blocks () const;
1630 void write_to_dump (dump
&d
);
1632 block
*get_block () const { return m_block
; }
1633 location
*get_loc () const { return m_loc
; }
1636 statement (block
*b
, location
*loc
)
1637 : memento (b
->m_ctxt
),
1641 playback::location
*
1642 playback_location (replayer
*r
) const
1644 return ::gcc::jit::recording::playback_location (r
, m_loc
);
1652 class eval
: public statement
1658 : statement (b
, loc
),
1659 m_rvalue (rvalue
) {}
1661 void replay_into (replayer
*r
);
1664 string
* make_debug_string ();
1665 void write_reproducer (reproducer
&r
);
1671 class assignment
: public statement
1674 assignment (block
*b
,
1678 : statement (b
, loc
),
1680 m_rvalue (rvalue
) {}
1682 void replay_into (replayer
*r
);
1685 string
* make_debug_string ();
1686 void write_reproducer (reproducer
&r
);
1693 class assignment_op
: public statement
1696 assignment_op (block
*b
,
1699 enum gcc_jit_binary_op op
,
1701 : statement (b
, loc
),
1704 m_rvalue (rvalue
) {}
1706 void replay_into (replayer
*r
);
1709 string
* make_debug_string ();
1710 void write_reproducer (reproducer
&r
);
1714 enum gcc_jit_binary_op m_op
;
1718 class comment
: public statement
1724 : statement (b
, loc
),
1727 void replay_into (replayer
*r
);
1730 string
* make_debug_string ();
1731 void write_reproducer (reproducer
&r
);
1737 class conditional
: public statement
1740 conditional (block
*b
,
1745 : statement (b
, loc
),
1746 m_boolval (boolval
),
1747 m_on_true (on_true
),
1748 m_on_false (on_false
) {}
1750 void replay_into (replayer
*r
);
1752 vec
<block
*> get_successor_blocks () const;
1755 string
* make_debug_string ();
1756 void write_reproducer (reproducer
&r
);
1764 class jump
: public statement
1770 : statement (b
, loc
),
1771 m_target (target
) {}
1773 void replay_into (replayer
*r
);
1775 vec
<block
*> get_successor_blocks () const;
1778 string
* make_debug_string ();
1779 void write_reproducer (reproducer
&r
);
1785 class return_
: public statement
1791 : statement (b
, loc
),
1792 m_rvalue (rvalue
) {}
1794 void replay_into (replayer
*r
);
1796 vec
<block
*> get_successor_blocks () const;
1799 string
* make_debug_string ();
1800 void write_reproducer (reproducer
&r
);
1806 class case_
: public memento
1809 case_ (context
*ctxt
,
1814 m_min_value (min_value
),
1815 m_max_value (max_value
),
1816 m_dest_block (dest_block
)
1819 rvalue
*get_min_value () const { return m_min_value
; }
1820 rvalue
*get_max_value () const { return m_max_value
; }
1821 block
*get_dest_block () const { return m_dest_block
; }
1823 void replay_into (replayer
*) { /* empty */ }
1825 void write_reproducer (reproducer
&r
);
1828 string
* make_debug_string ();
1831 rvalue
*m_min_value
;
1832 rvalue
*m_max_value
;
1833 block
*m_dest_block
;
1836 class switch_
: public statement
1842 block
*default_block
,
1846 void replay_into (replayer
*r
);
1848 vec
<block
*> get_successor_blocks () const;
1851 string
* make_debug_string ();
1852 void write_reproducer (reproducer
&r
);
1856 block
*m_default_block
;
1857 auto_vec
<case_
*> m_cases
;
1860 } // namespace gcc::jit::recording
1862 /* Create a recording::memento_of_new_rvalue_from_const instance and add
1863 it to this context's list of mementos.
1865 Implements the post-error-checking part of
1866 gcc_jit_context_new_rvalue_from_{int|long|double|ptr}. */
1868 template <typename HOST_TYPE
>
1870 recording::context::new_rvalue_from_const (recording::type
*type
,
1873 recording::rvalue
*result
=
1874 new memento_of_new_rvalue_from_const
<HOST_TYPE
> (this, NULL
, type
, value
);
1879 } // namespace gcc::jit
1883 #endif /* JIT_RECORDING_H */