1 /* Internals of libgccjit: classes for recording calls made to the JIT API.
2 Copyright (C) 2013-2021 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"
33 extern const char * const unary_op_reproducer_strings
[];
34 extern const char * const binary_op_reproducer_strings
[];
40 /**********************************************************************
42 **********************************************************************/
47 playback_location (replayer
*r
, location
*loc
);
50 playback_string (string
*str
);
53 playback_block (block
*b
);
55 /* A recording of a call to gcc_jit_context_enable_dump. */
58 const char *m_dumpname
;
62 /* A JIT-compilation context. */
63 class context
: public log_user
66 context (context
*parent_ctxt
);
70 get_builtins_manager ();
72 void record (memento
*m
);
73 void replay_into (replayer
*r
);
74 void disassociate_from_playback ();
77 new_string (const char *text
, bool escaped
= false);
80 new_location (const char *filename
,
83 bool created_by_user
);
86 get_type (enum gcc_jit_types type
);
89 get_int_type (int num_bytes
, int is_signed
);
92 new_array_type (location
*loc
,
97 new_field (location
*loc
,
102 new_bitfield (location
*loc
,
108 new_struct_type (location
*loc
,
112 new_union_type (location
*loc
,
116 new_function_type (type
*return_type
,
122 new_function_ptr_type (location
*loc
,
129 new_param (location
*loc
,
134 new_function (location
*loc
,
135 enum gcc_jit_function_kind kind
,
141 enum built_in_function builtin_id
);
144 get_builtin_function (const char *name
);
147 new_global (location
*loc
,
148 enum gcc_jit_global_kind kind
,
152 template <typename HOST_TYPE
>
154 new_rvalue_from_const (type
*type
,
158 new_string_literal (const char *value
);
161 new_rvalue_from_vector (location
*loc
,
166 new_unary_op (location
*loc
,
167 enum gcc_jit_unary_op op
,
172 new_binary_op (location
*loc
,
173 enum gcc_jit_binary_op op
,
175 rvalue
*a
, rvalue
*b
);
178 new_comparison (location
*loc
,
179 enum gcc_jit_comparison op
,
180 rvalue
*a
, rvalue
*b
);
183 new_call (location
*loc
,
185 int numargs
, rvalue
**args
);
188 new_call_through_ptr (location
*loc
,
190 int numargs
, rvalue
**args
);
193 new_cast (location
*loc
,
198 new_array_access (location
*loc
,
203 new_case (rvalue
*min_value
,
208 set_str_option (enum gcc_jit_str_option opt
,
212 set_int_option (enum gcc_jit_int_option opt
,
216 set_bool_option (enum gcc_jit_bool_option opt
,
220 set_inner_bool_option (enum inner_bool_option inner_opt
,
224 add_command_line_option (const char *optname
);
227 append_command_line_options (vec
<char *> *argvec
);
230 add_driver_option (const char *optname
);
233 append_driver_options (auto_string_vec
*argvec
);
236 enable_dump (const char *dumpname
,
240 get_str_option (enum gcc_jit_str_option opt
) const
242 return m_str_options
[opt
];
246 get_int_option (enum gcc_jit_int_option opt
) const
248 return m_int_options
[opt
];
252 get_bool_option (enum gcc_jit_bool_option opt
) const
254 return m_bool_options
[opt
];
258 get_inner_bool_option (enum inner_bool_option opt
) const
260 return m_inner_bool_options
[opt
];
267 compile_to_file (enum gcc_jit_output_kind output_kind
,
268 const char *output_path
);
271 add_error (location
*loc
, const char *fmt
, ...)
275 add_error_va (location
*loc
, const char *fmt
, va_list ap
)
279 get_first_error () const;
282 get_last_error () const;
284 bool errors_occurred () const
287 if (m_parent_ctxt
->errors_occurred ())
289 return m_error_count
;
292 type
*get_opaque_FILE_type ();
294 void dump_to_file (const char *path
, bool update_locations
);
296 void dump_reproducer_to_file (const char *path
);
299 get_all_requested_dumps (vec
<recording::requested_dump
> *out
);
301 void set_timer (timer
*t
) { m_timer
= t
; }
302 timer
*get_timer () const { return m_timer
; }
304 void add_top_level_asm (location
*loc
, const char *asm_stmts
);
307 void log_all_options () const;
308 void log_str_option (enum gcc_jit_str_option opt
) const;
309 void log_int_option (enum gcc_jit_int_option opt
) const;
310 void log_bool_option (enum gcc_jit_bool_option opt
) const;
311 void log_inner_bool_option (enum inner_bool_option opt
) const;
316 context
*m_parent_ctxt
;
318 /* The ultimate ancestor of the contexts within a family tree of
319 contexts. This has itself as its own m_toplevel_ctxt. */
320 context
*m_toplevel_ctxt
;
326 char *m_first_error_str
;
327 bool m_owns_first_error_str
;
329 char *m_last_error_str
;
330 bool m_owns_last_error_str
;
332 char *m_str_options
[GCC_JIT_NUM_STR_OPTIONS
];
333 int m_int_options
[GCC_JIT_NUM_INT_OPTIONS
];
334 bool m_bool_options
[GCC_JIT_NUM_BOOL_OPTIONS
];
335 bool m_inner_bool_options
[NUM_INNER_BOOL_OPTIONS
];
336 auto_vec
<char *> m_command_line_options
;
337 auto_vec
<char *> m_driver_options
;
339 /* Dumpfiles that were requested via gcc_jit_context_enable_dump. */
340 auto_vec
<requested_dump
> m_requested_dumps
;
342 /* Recorded API usage. */
343 auto_vec
<memento
*> m_mementos
;
345 /* Specific recordings, for use by dump_to_file. */
346 auto_vec
<compound_type
*> m_compound_types
;
347 auto_vec
<global
*> m_globals
;
348 auto_vec
<function
*> m_functions
;
349 auto_vec
<top_level_asm
*> m_top_level_asms
;
351 type
*m_basic_types
[NUM_GCC_JIT_TYPES
];
354 builtins_manager
*m_builtins_manager
; // lazily created
358 /* An object with lifetime managed by the context i.e.
359 it lives until the context is released, at which
360 point it itself is cleaned up. */
365 virtual ~memento () {}
367 /* Hook for replaying this. */
368 virtual void replay_into (replayer
*r
) = 0;
370 void set_playback_obj (void *obj
) { m_playback_obj
= obj
; }
373 /* Get the context that owns this object.
375 Implements the post-error-checking part of
376 gcc_jit_object_get_context. */
377 context
*get_context () { return m_ctxt
; }
380 as_object () { return this; }
382 /* Debugging hook, for use in generating error messages etc.
383 Implements the post-error-checking part of
384 gcc_jit_object_get_debug_string. */
388 virtual void write_to_dump (dump
&d
);
389 virtual void write_reproducer (reproducer
&r
) = 0;
390 virtual location
*dyn_cast_location () { return NULL
; }
393 memento (context
*ctxt
)
395 m_playback_obj (NULL
),
396 m_debug_string (NULL
)
401 string
*new_string (const char *text
) { return m_ctxt
->new_string (text
); }
404 virtual string
* make_debug_string () = 0;
410 void *m_playback_obj
;
413 string
*m_debug_string
;
416 /* or just use std::string? */
417 class string
: public memento
420 string (context
*ctxt
, const char *text
, bool escaped
);
423 const char *c_str () { return m_buffer
; }
425 static string
* from_printf (context
*ctxt
, const char *fmt
, ...)
428 void replay_into (replayer
*) FINAL OVERRIDE
{}
431 string
* make_debug_string () FINAL OVERRIDE
;
432 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
438 /* Flag to track if this string is the result of string::make_debug_string,
439 to avoid infinite recursion when logging all mementos: don't re-escape
444 class location
: public memento
447 location (context
*ctxt
, string
*filename
, int line
, int column
,
448 bool created_by_user
)
450 m_filename (filename
),
453 m_created_by_user (created_by_user
)
456 void replay_into (replayer
*r
) FINAL OVERRIDE
;
459 playback_location (replayer
*r
)
461 /* Normally during playback, we can walk forwards through the list of
462 recording objects, playing them back. The ordering of recording
463 ensures that everything that a recording object refers to has
464 already been played back, so we can simply look up the relevant
467 Locations are an exception, due to the "write_to_dump" method of
468 recording::statement. This method can set a new location on a
469 statement after the statement is created, and thus the location
470 appears in the context's memento list *after* the statement that
473 In such circumstances, the statement is replayed *before* the location,
474 when the latter doesn't yet have a playback object.
476 Hence we need to ensure that locations have playback objects. */
481 gcc_assert (m_playback_obj
);
482 return static_cast <playback::location
*> (m_playback_obj
);
485 location
*dyn_cast_location () FINAL OVERRIDE
{ return this; }
486 bool created_by_user () const { return m_created_by_user
; }
489 string
* make_debug_string () FINAL OVERRIDE
;
490 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
496 bool m_created_by_user
;
499 class type
: public memento
502 type
*get_pointer ();
504 type
*get_volatile ();
505 type
*get_aligned (size_t alignment_in_bytes
);
506 type
*get_vector (size_t num_units
);
508 /* Get the type obtained when dereferencing this type.
510 This will return NULL if it's not valid to dereference this type.
511 The caller is responsible for setting an error. */
512 virtual type
*dereference () = 0;
513 /* Get the type size in bytes.
515 This is implemented only for memento_of_get_type and
516 memento_of_get_pointer as it is used for initializing globals of
518 virtual size_t get_size () { gcc_unreachable (); }
521 virtual function_type
*dyn_cast_function_type () { return NULL
; }
522 virtual function_type
*as_a_function_type() { gcc_unreachable (); return NULL
; }
523 virtual struct_
*dyn_cast_struct () { return NULL
; }
524 virtual vector_type
*dyn_cast_vector_type () { return NULL
; }
526 /* Is it typesafe to copy to this type from rtype? */
527 virtual bool accepts_writes_from (type
*rtype
)
530 return this->unqualified ()->is_same_type_as (rtype
->unqualified ());
533 virtual bool is_same_type_as (type
*other
)
535 return this == other
;
538 /* Strip off "const" etc */
539 virtual type
*unqualified ()
544 virtual bool is_int () const = 0;
545 virtual bool is_float () const = 0;
546 virtual bool is_bool () const = 0;
547 virtual type
*is_pointer () = 0;
548 virtual type
*is_array () = 0;
549 virtual bool is_void () const { return false; }
550 virtual bool has_known_size () const { return true; }
552 bool is_numeric () const
554 return is_int () || is_float () || is_bool ();
560 return static_cast <playback::type
*> (m_playback_obj
);
563 virtual const char *access_as_type (reproducer
&r
);
568 m_pointer_to_this_type (NULL
)
572 type
*m_pointer_to_this_type
;
575 /* Result of "gcc_jit_context_get_type". */
576 class memento_of_get_type
: public type
579 memento_of_get_type (context
*ctxt
,
580 enum gcc_jit_types kind
)
584 type
*dereference () FINAL OVERRIDE
;
586 size_t get_size () FINAL OVERRIDE
;
588 bool accepts_writes_from (type
*rtype
) FINAL OVERRIDE
590 if (m_kind
== GCC_JIT_TYPE_VOID_PTR
)
591 if (rtype
->is_pointer ())
593 /* LHS (this) is type (void *), and the RHS is a pointer:
598 return type::accepts_writes_from (rtype
);
601 bool is_int () const FINAL OVERRIDE
;
602 bool is_float () const FINAL OVERRIDE
;
603 bool is_bool () const FINAL OVERRIDE
;
604 type
*is_pointer () FINAL OVERRIDE
{ return dereference (); }
605 type
*is_array () FINAL OVERRIDE
{ return NULL
; }
606 bool is_void () const FINAL OVERRIDE
{ return m_kind
== GCC_JIT_TYPE_VOID
; }
609 void replay_into (replayer
*r
) FINAL OVERRIDE
;
612 string
* make_debug_string () FINAL OVERRIDE
;
613 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
616 enum gcc_jit_types m_kind
;
619 /* Result of "gcc_jit_type_get_pointer". */
620 class memento_of_get_pointer
: public type
623 memento_of_get_pointer (type
*other_type
)
624 : type (other_type
->m_ctxt
),
625 m_other_type (other_type
) {}
627 type
*dereference () FINAL OVERRIDE
{ return m_other_type
; }
629 size_t get_size () FINAL OVERRIDE
;
631 bool accepts_writes_from (type
*rtype
) FINAL OVERRIDE
;
633 void replay_into (replayer
*r
) FINAL OVERRIDE
;
635 bool is_int () const FINAL OVERRIDE
{ return false; }
636 bool is_float () const FINAL OVERRIDE
{ return false; }
637 bool is_bool () const FINAL OVERRIDE
{ return false; }
638 type
*is_pointer () FINAL OVERRIDE
{ return m_other_type
; }
639 type
*is_array () FINAL OVERRIDE
{ return NULL
; }
642 string
* make_debug_string () FINAL OVERRIDE
;
643 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
649 /* A decorated version of a type, for get_const, get_volatile,
650 get_aligned, and get_vector. */
652 class decorated_type
: public type
655 decorated_type (type
*other_type
)
656 : type (other_type
->m_ctxt
),
657 m_other_type (other_type
) {}
659 type
*dereference () FINAL OVERRIDE
{ return m_other_type
->dereference (); }
661 bool is_int () const FINAL OVERRIDE
{ return m_other_type
->is_int (); }
662 bool is_float () const FINAL OVERRIDE
{ return m_other_type
->is_float (); }
663 bool is_bool () const FINAL OVERRIDE
{ return m_other_type
->is_bool (); }
664 type
*is_pointer () FINAL OVERRIDE
{ return m_other_type
->is_pointer (); }
665 type
*is_array () FINAL OVERRIDE
{ return m_other_type
->is_array (); }
671 /* Result of "gcc_jit_type_get_const". */
672 class memento_of_get_const
: public decorated_type
675 memento_of_get_const (type
*other_type
)
676 : decorated_type (other_type
) {}
678 bool accepts_writes_from (type */
*rtype*/
) FINAL OVERRIDE
680 /* Can't write to a "const". */
684 /* Strip off the "const", giving the underlying type. */
685 type
*unqualified () FINAL OVERRIDE
{ return m_other_type
; }
687 void replay_into (replayer
*) FINAL OVERRIDE
;
690 string
* make_debug_string () FINAL OVERRIDE
;
691 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
694 /* Result of "gcc_jit_type_get_volatile". */
695 class memento_of_get_volatile
: public decorated_type
698 memento_of_get_volatile (type
*other_type
)
699 : decorated_type (other_type
) {}
701 /* Strip off the "volatile", giving the underlying type. */
702 type
*unqualified () FINAL OVERRIDE
{ return m_other_type
; }
704 void replay_into (replayer
*) FINAL OVERRIDE
;
707 string
* make_debug_string () FINAL OVERRIDE
;
708 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
711 /* Result of "gcc_jit_type_get_aligned". */
712 class memento_of_get_aligned
: public decorated_type
715 memento_of_get_aligned (type
*other_type
, size_t alignment_in_bytes
)
716 : decorated_type (other_type
),
717 m_alignment_in_bytes (alignment_in_bytes
) {}
719 /* Strip off the alignment, giving the underlying type. */
720 type
*unqualified () FINAL OVERRIDE
{ return m_other_type
; }
722 void replay_into (replayer
*) FINAL OVERRIDE
;
725 string
* make_debug_string () FINAL OVERRIDE
;
726 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
729 size_t m_alignment_in_bytes
;
732 /* Result of "gcc_jit_type_get_vector". */
733 class vector_type
: public decorated_type
736 vector_type (type
*other_type
, size_t num_units
)
737 : decorated_type (other_type
),
738 m_num_units (num_units
) {}
740 size_t get_num_units () const { return m_num_units
; }
742 vector_type
*dyn_cast_vector_type () FINAL OVERRIDE
{ return this; }
744 type
*get_element_type () { return m_other_type
; }
746 void replay_into (replayer
*) FINAL OVERRIDE
;
749 string
* make_debug_string () FINAL OVERRIDE
;
750 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
756 class array_type
: public type
759 array_type (context
*ctxt
,
765 m_element_type (element_type
),
766 m_num_elements (num_elements
)
769 type
*dereference () FINAL OVERRIDE
;
771 bool is_int () const FINAL OVERRIDE
{ return false; }
772 bool is_float () const FINAL OVERRIDE
{ return false; }
773 bool is_bool () const FINAL OVERRIDE
{ return false; }
774 type
*is_pointer () FINAL OVERRIDE
{ return NULL
; }
775 type
*is_array () FINAL OVERRIDE
{ return m_element_type
; }
776 int num_elements () { return m_num_elements
; }
778 void replay_into (replayer
*) FINAL OVERRIDE
;
781 string
* make_debug_string () FINAL OVERRIDE
;
782 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
786 type
*m_element_type
;
790 class function_type
: public type
793 function_type (context
*ctxt
,
799 type
*dereference () FINAL OVERRIDE
;
800 function_type
*dyn_cast_function_type () FINAL OVERRIDE
{ return this; }
801 function_type
*as_a_function_type () FINAL OVERRIDE
{ return this; }
803 bool is_same_type_as (type
*other
) FINAL OVERRIDE
;
805 bool is_int () const FINAL OVERRIDE
{ return false; }
806 bool is_float () const FINAL OVERRIDE
{ return false; }
807 bool is_bool () const FINAL OVERRIDE
{ return false; }
808 type
*is_pointer () FINAL OVERRIDE
{ return NULL
; }
809 type
*is_array () FINAL OVERRIDE
{ return NULL
; }
811 void replay_into (replayer
*) FINAL OVERRIDE
;
813 type
* get_return_type () const { return m_return_type
; }
814 const vec
<type
*> &get_param_types () const { return m_param_types
; }
815 int is_variadic () const { return m_is_variadic
; }
817 string
* make_debug_string_with_ptr ();
820 write_deferred_reproducer (reproducer
&r
,
824 string
* make_debug_string () FINAL OVERRIDE
;
825 string
* make_debug_string_with (const char *);
826 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
830 auto_vec
<type
*> m_param_types
;
834 class field
: public memento
837 field (context
*ctxt
,
848 type
* get_type () const { return m_type
; }
850 compound_type
* get_container () const { return m_container
; }
851 void set_container (compound_type
*c
) { m_container
= c
; }
853 void replay_into (replayer
*) OVERRIDE
;
855 void write_to_dump (dump
&d
) OVERRIDE
;
858 playback_field () const
860 return static_cast <playback::field
*> (m_playback_obj
);
864 string
* make_debug_string () OVERRIDE
;
865 void write_reproducer (reproducer
&r
) OVERRIDE
;
871 compound_type
*m_container
;
875 class bitfield
: public field
878 bitfield (context
*ctxt
,
883 : field (ctxt
, loc
, type
, name
),
887 void replay_into (replayer
*) FINAL OVERRIDE
;
889 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
892 string
* make_debug_string () FINAL OVERRIDE
;
893 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
899 /* Base class for struct_ and union_ */
900 class compound_type
: public type
903 compound_type (context
*ctxt
,
907 string
*get_name () const { return m_name
; }
908 location
*get_loc () const { return m_loc
; }
909 fields
* get_fields () { return m_fields
; }
912 set_fields (location
*loc
,
916 type
*dereference () FINAL OVERRIDE
;
918 bool is_int () const FINAL OVERRIDE
{ return false; }
919 bool is_float () const FINAL OVERRIDE
{ return false; }
920 bool is_bool () const FINAL OVERRIDE
{ return false; }
921 type
*is_pointer () FINAL OVERRIDE
{ return NULL
; }
922 type
*is_array () FINAL OVERRIDE
{ return NULL
; }
924 bool has_known_size () const FINAL OVERRIDE
{ return m_fields
!= NULL
; }
926 playback::compound_type
*
927 playback_compound_type ()
929 return static_cast <playback::compound_type
*> (m_playback_obj
);
938 class struct_
: public compound_type
941 struct_ (context
*ctxt
,
945 struct_
*dyn_cast_struct () FINAL OVERRIDE
{ return this; }
948 as_type () { return this; }
950 void replay_into (replayer
*r
) FINAL OVERRIDE
;
952 const char *access_as_type (reproducer
&r
) FINAL OVERRIDE
;
955 string
* make_debug_string () FINAL OVERRIDE
;
956 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
959 // memento of struct_::set_fields
960 class fields
: public memento
963 fields (compound_type
*struct_or_union
,
967 void replay_into (replayer
*r
) FINAL OVERRIDE
;
969 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
971 int length () const { return m_fields
.length (); }
972 field
*get_field (int i
) const { return m_fields
[i
]; }
975 string
* make_debug_string () FINAL OVERRIDE
;
976 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
979 compound_type
*m_struct_or_union
;
980 auto_vec
<field
*> m_fields
;
983 class union_
: public compound_type
986 union_ (context
*ctxt
,
990 void replay_into (replayer
*r
) FINAL OVERRIDE
;
993 string
* make_debug_string () FINAL OVERRIDE
;
994 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
997 /* An abstract base class for operations that visit all rvalues within an
999 Currently the only implementation is class rvalue_usage_validator within
1002 class rvalue_visitor
1005 virtual ~rvalue_visitor () {}
1006 virtual void visit (rvalue
*rvalue
) = 0;
1009 /* When generating debug strings for rvalues we mimic C, so we need to
1010 mimic C's precedence levels when handling compound expressions.
1011 These are in order from strongest precedence to weakest. */
1018 PRECEDENCE_MULTIPLICATIVE
,
1019 PRECEDENCE_ADDITIVE
,
1021 PRECEDENCE_RELATIONAL
,
1022 PRECEDENCE_EQUALITY
,
1023 PRECEDENCE_BITWISE_AND
,
1024 PRECEDENCE_BITWISE_XOR
,
1025 PRECEDENCE_BITWISE_IOR
,
1026 PRECEDENCE_LOGICAL_AND
,
1027 PRECEDENCE_LOGICAL_OR
1030 class rvalue
: public memento
1033 rvalue (context
*ctxt
,
1040 m_parenthesized_string (NULL
)
1045 location
* get_loc () const { return m_loc
; }
1047 /* Get the recording::type of this rvalue.
1049 Implements the post-error-checking part of
1050 gcc_jit_rvalue_get_type. */
1051 type
* get_type () const { return m_type
; }
1054 playback_rvalue () const
1056 return static_cast <playback::rvalue
*> (m_playback_obj
);
1059 access_field (location
*loc
,
1063 dereference_field (location
*loc
,
1067 dereference (location
*loc
);
1070 verify_valid_within_stmt (const char *api_funcname
, statement
*s
);
1072 virtual void visit_children (rvalue_visitor
*v
) = 0;
1074 void set_scope (function
*scope
);
1075 function
*get_scope () const { return m_scope
; }
1077 /* Dynamic casts. */
1078 virtual param
*dyn_cast_param () { return NULL
; }
1079 virtual base_call
*dyn_cast_base_call () { return NULL
; }
1081 virtual const char *access_as_rvalue (reproducer
&r
);
1083 /* Get the debug string, wrapped in parentheses. */
1085 get_debug_string_parens (enum precedence outer_prec
);
1087 virtual bool is_constant () const { return false; }
1088 virtual bool get_wide_int (wide_int
*) const { return false; }
1091 virtual enum precedence
get_precedence () const = 0;
1098 function
*m_scope
; /* NULL for globals, non-NULL for locals/params */
1099 string
*m_parenthesized_string
;
1102 class lvalue
: public rvalue
1105 lvalue (context
*ctxt
,
1108 : rvalue (ctxt
, loc
, type_
)
1112 playback_lvalue () const
1114 return static_cast <playback::lvalue
*> (m_playback_obj
);
1118 access_field (location
*loc
,
1122 get_address (location
*loc
);
1125 as_rvalue () { return this; }
1127 const char *access_as_rvalue (reproducer
&r
) OVERRIDE
;
1128 virtual const char *access_as_lvalue (reproducer
&r
);
1129 virtual bool is_global () const { return false; }
1132 class param
: public lvalue
1135 param (context
*ctxt
,
1139 : lvalue (ctxt
, loc
, type
),
1143 as_lvalue () { return this; }
1145 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1147 void visit_children (rvalue_visitor
*) FINAL OVERRIDE
{}
1150 playback_param () const
1152 return static_cast <playback::param
*> (m_playback_obj
);
1155 param
*dyn_cast_param () FINAL OVERRIDE
{ return this; }
1157 const char *access_as_rvalue (reproducer
&r
) FINAL OVERRIDE
;
1158 const char *access_as_lvalue (reproducer
&r
) FINAL OVERRIDE
;
1161 string
* make_debug_string () FINAL OVERRIDE
{ return m_name
; }
1162 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1163 enum precedence
get_precedence () const FINAL OVERRIDE
1165 return PRECEDENCE_PRIMARY
;
1172 class function
: public memento
1175 function (context
*ctxt
,
1177 enum gcc_jit_function_kind kind
,
1183 enum built_in_function builtin_id
);
1185 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1187 playback::function
*
1188 playback_function () const
1190 return static_cast <playback::function
*> (m_playback_obj
);
1193 enum gcc_jit_function_kind
get_kind () const { return m_kind
; }
1196 new_local (location
*loc
,
1201 new_block (const char *name
);
1203 location
*get_loc () const { return m_loc
; }
1204 type
*get_return_type () const { return m_return_type
; }
1205 string
* get_name () const { return m_name
; }
1206 const vec
<param
*> &get_params () const { return m_params
; }
1208 /* Get the given param by index.
1209 Implements the post-error-checking part of
1210 gcc_jit_function_get_param. */
1211 param
*get_param (int i
) const { return m_params
[i
]; }
1213 bool is_variadic () const { return m_is_variadic
; }
1215 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
1219 void dump_to_dot (const char *path
);
1221 rvalue
*get_address (location
*loc
);
1224 string
* make_debug_string () FINAL OVERRIDE
;
1225 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1229 enum gcc_jit_function_kind m_kind
;
1230 type
*m_return_type
;
1232 auto_vec
<param
*> m_params
;
1234 enum built_in_function m_builtin_id
;
1235 auto_vec
<local
*> m_locals
;
1236 auto_vec
<block
*> m_blocks
;
1237 type
*m_fn_ptr_type
;
1240 class block
: public memento
1243 block (function
*func
, int index
, string
*name
)
1244 : memento (func
->m_ctxt
),
1249 m_has_been_terminated (false),
1250 m_is_reachable (false)
1254 /* Get the recording::function containing this block.
1255 Implements the post-error-checking part of
1256 gcc_jit_block_get_function. */
1257 function
*get_function () { return m_func
; }
1259 bool has_been_terminated () { return m_has_been_terminated
; }
1260 bool is_reachable () { return m_is_reachable
; }
1263 add_eval (location
*loc
,
1267 add_assignment (location
*loc
,
1272 add_assignment_op (location
*loc
,
1274 enum gcc_jit_binary_op op
,
1278 add_comment (location
*loc
,
1282 add_extended_asm (location
*loc
,
1283 const char *asm_template
);
1286 end_with_conditional (location
*loc
,
1292 end_with_jump (location
*loc
,
1296 end_with_return (location
*loc
,
1300 end_with_switch (location
*loc
,
1302 block
*default_block
,
1307 end_with_extended_asm_goto (location
*loc
,
1308 const char *asm_template
,
1309 int num_goto_blocks
,
1310 block
**goto_blocks
,
1311 block
*fallthrough_block
);
1314 playback_block () const
1316 return static_cast <playback::block
*> (m_playback_obj
);
1319 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
1323 location
*get_loc () const;
1325 statement
*get_first_statement () const;
1326 statement
*get_last_statement () const;
1328 vec
<block
*> get_successor_blocks () const;
1331 string
* make_debug_string () FINAL OVERRIDE
;
1332 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1334 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1336 void dump_to_dot (pretty_printer
*pp
);
1337 void dump_edges_to_dot (pretty_printer
*pp
);
1343 auto_vec
<statement
*> m_statements
;
1344 bool m_has_been_terminated
;
1345 bool m_is_reachable
;
1347 friend class function
;
1350 class global
: public lvalue
1353 global (context
*ctxt
,
1355 enum gcc_jit_global_kind kind
,
1358 : lvalue (ctxt
, loc
, type
),
1362 m_initializer
= NULL
;
1363 m_initializer_num_bytes
= 0;
1367 free (m_initializer
);
1370 void replay_into (replayer
*) FINAL OVERRIDE
;
1372 void visit_children (rvalue_visitor
*) FINAL OVERRIDE
{}
1374 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
1376 bool is_global () const FINAL OVERRIDE
{ return true; }
1379 set_initializer (const void *initializer
,
1383 free (m_initializer
);
1384 m_initializer
= xmalloc (num_bytes
);
1385 memcpy (m_initializer
, initializer
, num_bytes
);
1386 m_initializer_num_bytes
= num_bytes
;
1390 string
* make_debug_string () FINAL OVERRIDE
{ return m_name
; }
1391 template <typename T
>
1392 void write_initializer_reproducer (const char *id
, reproducer
&r
);
1393 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1394 enum precedence
get_precedence () const FINAL OVERRIDE
1396 return PRECEDENCE_PRIMARY
;
1400 enum gcc_jit_global_kind m_kind
;
1402 void *m_initializer
;
1403 size_t m_initializer_num_bytes
;
1406 template <typename HOST_TYPE
>
1407 class memento_of_new_rvalue_from_const
: public rvalue
1410 memento_of_new_rvalue_from_const (context
*ctxt
,
1414 : rvalue (ctxt
, loc
, type
),
1417 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1419 void visit_children (rvalue_visitor
*) FINAL OVERRIDE
{}
1421 bool is_constant () const FINAL OVERRIDE
{ return true; }
1423 bool get_wide_int (wide_int
*out
) const FINAL OVERRIDE
;
1426 string
* make_debug_string () FINAL OVERRIDE
;
1427 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1428 enum precedence
get_precedence () const FINAL OVERRIDE
1430 return PRECEDENCE_PRIMARY
;
1437 class memento_of_new_string_literal
: public rvalue
1440 memento_of_new_string_literal (context
*ctxt
,
1443 : rvalue (ctxt
, loc
, ctxt
->get_type (GCC_JIT_TYPE_CONST_CHAR_PTR
)),
1446 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1448 void visit_children (rvalue_visitor
*) FINAL OVERRIDE
{}
1451 string
* make_debug_string () FINAL OVERRIDE
;
1452 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1453 enum precedence
get_precedence () const FINAL OVERRIDE
1455 return PRECEDENCE_PRIMARY
;
1462 class memento_of_new_rvalue_from_vector
: public rvalue
1465 memento_of_new_rvalue_from_vector (context
*ctxt
,
1470 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1472 void visit_children (rvalue_visitor
*) FINAL OVERRIDE
;
1475 string
* make_debug_string () FINAL OVERRIDE
;
1476 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1477 enum precedence
get_precedence () const FINAL OVERRIDE
1479 return PRECEDENCE_PRIMARY
;
1483 vector_type
*m_vector_type
;
1484 auto_vec
<rvalue
*> m_elements
;
1487 class unary_op
: public rvalue
1490 unary_op (context
*ctxt
,
1492 enum gcc_jit_unary_op op
,
1495 : rvalue (ctxt
, loc
, result_type
),
1500 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1502 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1505 string
* make_debug_string () FINAL OVERRIDE
;
1506 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1507 enum precedence
get_precedence () const FINAL OVERRIDE
1509 return PRECEDENCE_UNARY
;
1513 enum gcc_jit_unary_op m_op
;
1517 class binary_op
: public rvalue
1520 binary_op (context
*ctxt
,
1522 enum gcc_jit_binary_op op
,
1524 rvalue
*a
, rvalue
*b
)
1525 : rvalue (ctxt
, loc
, result_type
),
1530 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1532 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1535 string
* make_debug_string () FINAL OVERRIDE
;
1536 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1537 enum precedence
get_precedence () const FINAL OVERRIDE
;
1540 enum gcc_jit_binary_op m_op
;
1545 class comparison
: public rvalue
1548 comparison (context
*ctxt
,
1550 enum gcc_jit_comparison op
,
1551 rvalue
*a
, rvalue
*b
)
1552 : rvalue (ctxt
, loc
, ctxt
->get_type (GCC_JIT_TYPE_BOOL
)),
1558 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1560 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1563 string
* make_debug_string () FINAL OVERRIDE
;
1564 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1565 enum precedence
get_precedence () const FINAL OVERRIDE
;
1568 enum gcc_jit_comparison m_op
;
1573 class cast
: public rvalue
1576 cast (context
*ctxt
,
1580 : rvalue (ctxt
, loc
, type_
),
1584 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1586 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1589 string
* make_debug_string () FINAL OVERRIDE
;
1590 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1591 enum precedence
get_precedence () const FINAL OVERRIDE
1593 return PRECEDENCE_CAST
;
1600 class base_call
: public rvalue
1603 base_call (context
*ctxt
,
1609 enum precedence
get_precedence () const FINAL OVERRIDE
1611 return PRECEDENCE_POSTFIX
;
1614 base_call
*dyn_cast_base_call () FINAL OVERRIDE
{ return this; }
1616 void set_require_tail_call (bool require_tail_call
)
1618 m_require_tail_call
= require_tail_call
;
1622 void write_reproducer_tail_call (reproducer
&r
, const char *id
);
1625 auto_vec
<rvalue
*> m_args
;
1626 bool m_require_tail_call
;
1629 class call
: public base_call
1632 call (context
*ctxt
,
1638 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1640 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1643 string
* make_debug_string () FINAL OVERRIDE
;
1644 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1650 class call_through_ptr
: public base_call
1653 call_through_ptr (context
*ctxt
,
1659 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1661 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1664 string
* make_debug_string () FINAL OVERRIDE
;
1665 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1671 class array_access
: public lvalue
1674 array_access (context
*ctxt
,
1678 : lvalue (ctxt
, loc
, ptr
->get_type ()->dereference ()),
1683 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1685 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1688 string
* make_debug_string () FINAL OVERRIDE
;
1689 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1690 enum precedence
get_precedence () const FINAL OVERRIDE
1692 return PRECEDENCE_POSTFIX
;
1700 class access_field_of_lvalue
: public lvalue
1703 access_field_of_lvalue (context
*ctxt
,
1707 : lvalue (ctxt
, loc
, field
->get_type ()),
1712 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1714 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1717 string
* make_debug_string () FINAL OVERRIDE
;
1718 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1719 enum precedence
get_precedence () const FINAL OVERRIDE
1721 return PRECEDENCE_POSTFIX
;
1729 class access_field_rvalue
: public rvalue
1732 access_field_rvalue (context
*ctxt
,
1736 : rvalue (ctxt
, loc
, field
->get_type ()),
1741 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1743 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1746 string
* make_debug_string () FINAL OVERRIDE
;
1747 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1748 enum precedence
get_precedence () const FINAL OVERRIDE
1750 return PRECEDENCE_POSTFIX
;
1758 class dereference_field_rvalue
: public lvalue
1761 dereference_field_rvalue (context
*ctxt
,
1765 : lvalue (ctxt
, loc
, field
->get_type ()),
1770 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1772 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1775 string
* make_debug_string () FINAL OVERRIDE
;
1776 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1777 enum precedence
get_precedence () const FINAL OVERRIDE
1779 return PRECEDENCE_POSTFIX
;
1787 class dereference_rvalue
: public lvalue
1790 dereference_rvalue (context
*ctxt
,
1793 : lvalue (ctxt
, loc
, val
->get_type ()->dereference ()),
1796 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1798 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1801 string
* make_debug_string () FINAL OVERRIDE
;
1802 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1803 enum precedence
get_precedence () const FINAL OVERRIDE
1805 return PRECEDENCE_UNARY
;
1812 class get_address_of_lvalue
: public rvalue
1815 get_address_of_lvalue (context
*ctxt
,
1818 : rvalue (ctxt
, loc
, val
->get_type ()->get_pointer ()),
1822 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1824 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1827 string
* make_debug_string () FINAL OVERRIDE
;
1828 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1829 enum precedence
get_precedence () const FINAL OVERRIDE
1831 return PRECEDENCE_UNARY
;
1838 class function_pointer
: public rvalue
1841 function_pointer (context
*ctxt
,
1845 : rvalue (ctxt
, loc
, type
),
1848 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1850 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1853 string
* make_debug_string () FINAL OVERRIDE
;
1854 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1855 enum precedence
get_precedence () const FINAL OVERRIDE
1857 return PRECEDENCE_UNARY
;
1864 class local
: public lvalue
1867 local (function
*func
, location
*loc
, type
*type_
, string
*name
)
1868 : lvalue (func
->m_ctxt
, loc
, type_
),
1875 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1877 void visit_children (rvalue_visitor
*) FINAL OVERRIDE
{}
1879 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
1882 string
* make_debug_string () FINAL OVERRIDE
{ return m_name
; }
1883 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1884 enum precedence
get_precedence () const FINAL OVERRIDE
1886 return PRECEDENCE_PRIMARY
;
1894 class statement
: public memento
1897 virtual vec
<block
*> get_successor_blocks () const;
1899 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
1901 block
*get_block () const { return m_block
; }
1902 location
*get_loc () const { return m_loc
; }
1905 statement (block
*b
, location
*loc
)
1906 : memento (b
->m_ctxt
),
1910 playback::location
*
1911 playback_location (replayer
*r
) const
1913 return ::gcc::jit::recording::playback_location (r
, m_loc
);
1921 class eval
: public statement
1927 : statement (b
, loc
),
1928 m_rvalue (rvalue
) {}
1930 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1933 string
* make_debug_string () FINAL OVERRIDE
;
1934 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1940 class assignment
: public statement
1943 assignment (block
*b
,
1947 : statement (b
, loc
),
1949 m_rvalue (rvalue
) {}
1951 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1954 string
* make_debug_string () FINAL OVERRIDE
;
1955 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1962 class assignment_op
: public statement
1965 assignment_op (block
*b
,
1968 enum gcc_jit_binary_op op
,
1970 : statement (b
, loc
),
1973 m_rvalue (rvalue
) {}
1975 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1978 string
* make_debug_string () FINAL OVERRIDE
;
1979 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1983 enum gcc_jit_binary_op m_op
;
1987 class comment
: public statement
1993 : statement (b
, loc
),
1996 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1999 string
* make_debug_string () FINAL OVERRIDE
;
2000 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2006 class conditional
: public statement
2009 conditional (block
*b
,
2014 : statement (b
, loc
),
2015 m_boolval (boolval
),
2016 m_on_true (on_true
),
2017 m_on_false (on_false
) {}
2019 void replay_into (replayer
*r
) FINAL OVERRIDE
;
2021 vec
<block
*> get_successor_blocks () const FINAL OVERRIDE
;
2024 string
* make_debug_string () FINAL OVERRIDE
;
2025 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2033 class jump
: public statement
2039 : statement (b
, loc
),
2040 m_target (target
) {}
2042 void replay_into (replayer
*r
) FINAL OVERRIDE
;
2044 vec
<block
*> get_successor_blocks () const FINAL OVERRIDE
;
2047 string
* make_debug_string () FINAL OVERRIDE
;
2048 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2054 class return_
: public statement
2060 : statement (b
, loc
),
2061 m_rvalue (rvalue
) {}
2063 void replay_into (replayer
*r
) FINAL OVERRIDE
;
2065 vec
<block
*> get_successor_blocks () const FINAL OVERRIDE
;
2068 string
* make_debug_string () FINAL OVERRIDE
;
2069 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2075 class case_
: public memento
2078 case_ (context
*ctxt
,
2083 m_min_value (min_value
),
2084 m_max_value (max_value
),
2085 m_dest_block (dest_block
)
2088 rvalue
*get_min_value () const { return m_min_value
; }
2089 rvalue
*get_max_value () const { return m_max_value
; }
2090 block
*get_dest_block () const { return m_dest_block
; }
2092 void replay_into (replayer
*) FINAL OVERRIDE
{ /* empty */ }
2094 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2097 string
* make_debug_string () FINAL OVERRIDE
;
2100 rvalue
*m_min_value
;
2101 rvalue
*m_max_value
;
2102 block
*m_dest_block
;
2105 class switch_
: public statement
2111 block
*default_block
,
2115 void replay_into (replayer
*r
) FINAL OVERRIDE
;
2117 vec
<block
*> get_successor_blocks () const FINAL OVERRIDE
;
2120 string
* make_debug_string () FINAL OVERRIDE
;
2121 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2125 block
*m_default_block
;
2126 auto_vec
<case_
*> m_cases
;
2129 class asm_operand
: public memento
2132 asm_operand (extended_asm
*ext_asm
,
2133 string
*asm_symbolic_name
,
2134 string
*constraint
);
2136 const char *get_symbolic_name () const
2138 if (m_asm_symbolic_name
)
2139 return m_asm_symbolic_name
->c_str ();
2144 const char *get_constraint () const
2146 return m_constraint
->c_str ();
2149 virtual void print (pretty_printer
*pp
) const;
2152 string
* make_debug_string () FINAL OVERRIDE
;
2155 extended_asm
*m_ext_asm
;
2156 string
*m_asm_symbolic_name
;
2157 string
*m_constraint
;
2160 class output_asm_operand
: public asm_operand
2163 output_asm_operand (extended_asm
*ext_asm
,
2164 string
*asm_symbolic_name
,
2167 : asm_operand (ext_asm
, asm_symbolic_name
, constraint
),
2171 lvalue
*get_lvalue () const { return m_dest
; }
2173 void replay_into (replayer
*) FINAL OVERRIDE
{}
2175 void print (pretty_printer
*pp
) const FINAL OVERRIDE
;
2178 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2184 class input_asm_operand
: public asm_operand
2187 input_asm_operand (extended_asm
*ext_asm
,
2188 string
*asm_symbolic_name
,
2191 : asm_operand (ext_asm
, asm_symbolic_name
, constraint
),
2195 rvalue
*get_rvalue () const { return m_src
; }
2197 void replay_into (replayer
*) FINAL OVERRIDE
{}
2199 void print (pretty_printer
*pp
) const FINAL OVERRIDE
;
2202 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2208 /* Abstract base class for extended_asm statements. */
2210 class extended_asm
: public statement
2213 extended_asm (block
*b
,
2215 string
*asm_template
)
2216 : statement (b
, loc
),
2217 m_asm_template (asm_template
),
2218 m_is_volatile (false),
2222 void set_volatile_flag (bool flag
) { m_is_volatile
= flag
; }
2223 void set_inline_flag (bool flag
) { m_is_inline
= flag
; }
2225 void add_output_operand (const char *asm_symbolic_name
,
2226 const char *constraint
,
2228 void add_input_operand (const char *asm_symbolic_name
,
2229 const char *constraint
,
2231 void add_clobber (const char *victim
);
2233 void replay_into (replayer
*r
) OVERRIDE
;
2235 string
*get_asm_template () const { return m_asm_template
; }
2237 virtual bool is_goto () const = 0;
2238 virtual void maybe_print_gotos (pretty_printer
*) const = 0;
2241 void write_flags (reproducer
&r
);
2242 void write_clobbers (reproducer
&r
);
2245 string
* make_debug_string () FINAL OVERRIDE
;
2246 virtual void maybe_populate_playback_blocks
2247 (auto_vec
<playback::block
*> *out
) = 0;
2250 string
*m_asm_template
;
2253 auto_vec
<output_asm_operand
*> m_output_ops
;
2254 auto_vec
<input_asm_operand
*> m_input_ops
;
2255 auto_vec
<string
*> m_clobbers
;
2258 /* An extended_asm that's not a goto, as created by
2259 gcc_jit_block_add_extended_asm. */
2261 class extended_asm_simple
: public extended_asm
2264 extended_asm_simple (block
*b
,
2266 string
*asm_template
)
2267 : extended_asm (b
, loc
, asm_template
)
2270 void write_reproducer (reproducer
&r
) OVERRIDE
;
2271 bool is_goto () const FINAL OVERRIDE
{ return false; }
2272 void maybe_print_gotos (pretty_printer
*) const FINAL OVERRIDE
{}
2275 void maybe_populate_playback_blocks
2276 (auto_vec
<playback::block
*> *) FINAL OVERRIDE
2280 /* An extended_asm that's a asm goto, as created by
2281 gcc_jit_block_end_with_extended_asm_goto. */
2283 class extended_asm_goto
: public extended_asm
2286 extended_asm_goto (block
*b
,
2288 string
*asm_template
,
2289 int num_goto_blocks
,
2290 block
**goto_blocks
,
2291 block
*fallthrough_block
);
2293 void replay_into (replayer
*r
) FINAL OVERRIDE
;
2294 void write_reproducer (reproducer
&r
) OVERRIDE
;
2296 vec
<block
*> get_successor_blocks () const FINAL OVERRIDE
;
2298 bool is_goto () const FINAL OVERRIDE
{ return true; }
2299 void maybe_print_gotos (pretty_printer
*) const FINAL OVERRIDE
;
2302 void maybe_populate_playback_blocks
2303 (auto_vec
<playback::block
*> *out
) FINAL OVERRIDE
;
2306 auto_vec
<block
*> m_goto_blocks
;
2307 block
*m_fallthrough_block
;
2310 /* A group of top-level asm statements, as created by
2311 gcc_jit_context_add_top_level_asm. */
2313 class top_level_asm
: public memento
2316 top_level_asm (context
*ctxt
, location
*loc
, string
*asm_stmts
);
2318 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
2321 void replay_into (replayer
*r
) FINAL OVERRIDE
;
2322 string
* make_debug_string () FINAL OVERRIDE
;
2323 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2327 string
*m_asm_stmts
;
2330 } // namespace gcc::jit::recording
2332 /* Create a recording::memento_of_new_rvalue_from_const instance and add
2333 it to this context's list of mementos.
2335 Implements the post-error-checking part of
2336 gcc_jit_context_new_rvalue_from_{int|long|double|ptr}. */
2338 template <typename HOST_TYPE
>
2340 recording::context::new_rvalue_from_const (recording::type
*type
,
2343 recording::rvalue
*result
=
2344 new memento_of_new_rvalue_from_const
<HOST_TYPE
> (this, NULL
, type
, value
);
2349 } // namespace gcc::jit
2353 #endif /* JIT_RECORDING_H */